* TODO refactor: 低代码抽象


** architecture


first level abstract:
uiControlInput+action+ui control(they are contribute???)

+two package(
engine for publish package
engine for editor package
)


second level abstract:
each of the two package = multiple packages


third level abstract:
each package = extensions + contributes(no package)


note: upper level not know down level!






ap assemble/engine package assemble(package level has dependency)/single package assemble(current dependency except pacakge dependent)/element assemble


** ui control

data:
    input:
    - input data(from engine, action)
    handle by uiControlInput
    - config data
    set in element assemble
    output:
    - data pass to action
    e.g. selected Menu Item text, is button clicked, ...
    TODO not trigger in protocol!



split inspector to multiple ui controls(e.g. Input3Float, Text, InputText, CollapsingHeader)

abstract SceneTree's Tree to Tree ui control




api = {
    editorWholePackage service(actually engine-whole-protocol),
}



** action

protocol is ui control's output data type protocol

name defined in implement

action: (meta3dState, api, inputDataFromUIControl) => Promise<meta3dState>
    forward
    backward

api = {
    # getEnginePackage(whole for editor) (meta3dState) => package service,
    # getEngineWholePackage (meta3dState) => package service(actually engine-whole-protocol),
    editorWholePackage service,

    get/setActionState(for all actions' states),

    operate events(e.g. setNeedReplaceAllEvents),

    trigger(
        can trigger other actions
        
        e.g. trigger publish action when select publish menu item!
        ),
}



action come from:
1.market(publish to)
2.input by textarea
# stored in event data
stored in editor file


** uiControlInput

protocol is ui control's input data type protocol

map to ui control: one to one

name defined in implement

uiControlInput: (meta3dState, api) => Promise<ui control's input data>

api = {
    editorWholePackage service,

    get/setActionState(for all actions' states),
}



uiControlInput come from:
1.market(publish to)
2.input by textarea
# stored in event data
stored in editor file

** two packages

package role:
whole for editor
whole for web


each of the two package = multiple packages(other role, e.g. render, scene, post pass, asset)



the two package has dependency, check in engine package assemble



package's protocol is package role(whole for editor/whole for publish)




# ** TODO demo1: ui control: Scene Tree(header+Tree)
** TODO demo1: ui control: Controller




*** TODO package assemble

TODO unify scene,game view
    # TODO api add createGameObjectForScene/GameView, getAllGameObjectsForScene/GameView
    TODO both view share the same state(same Scene Package), but different active camera, so game view only need re-render with different active camera by another Render Package


TODO unify whole for editor, engine protocol

package protocols:
meta3d-engine-whole-protocol
meta3d-editor-whole-protocol
meta3d-engine-scene/scene view render/game view render/web render/asset/ui/event-protocol
core-protocol
    core,root,most
    init: register root pipeline


TODO each package should get each data through package service:
    shouldn't directly get each data through pipeline!
        but can get self data through pipeline!

TODO new api: getPackageService(protocol)=>nullable<package service>

# two kind render package implement:
# SceneViewThreeRender
# GameViewThreeRender

one editor whole package implement = Scene + SceneViewThreeRender(new api: createSpecificDefaultGameObjects) + GameViewThreeRender + Asset

SceneViewThreeRender->render:
set arcball to active->render->restore active cameraView

GameViewThreeRender->render:
render directly with active cameraView

# engine whole editor implement:
editor whole implement:
create default scene(one active cameraView) and invoke SceneViewThreeRender's createSpecificDefaultGameObjects
new api: addToInitFuncs, addToUpdateFuncs, addToRenderFuncs(for run action; flags: isOnlyOnce)
    //so only packages dependent on whole! whole not know packages!
    # in life handle->init: invoke scene, scene view render, ui, event, basic to register funcs
    invoke scene, scene view render, ui, event, basic
new api: getPluggablePackageService(protocol)=>nullable<package service>


TODO remove run extension
# triggerViewDirty
# triggerRun
# registerEventHandler?
if(stop){
    getPluggablePackageService(protocol)->nullable<package service>->renderOnce
}


TODO extension,contribute not know action state





one engine whole package implement = Scene  + WebThreeRender + Asset




TODO refactor file structure???
add packages/:
xxx_packages/
    extensions/
    contributes/
    protocols/
        extensions/
        contributes


TODO packages + actions(contributes) + uiControls(contributes) + uiControlInputs(contributes)





# **** TODO run test: visual, visual run, run app with only editor-whole pacakge
**** DONE run test: visual with only editor-whole pacakge




**** DONE run test: Scene View

TODO add engine-scene, core

TODO add ui, event

TODO add scene view render
    TODO add entry implement
    TODO remove viewrect pipeline
    TODO move convertscenegraph job before render
    TODO merge pipeline
    TODO fix bind arcball event: bind for each view render!
    TODO set viewrect related before render
    TODO set arcball to active->render->restore active cameraView

    TODO pass compile






TODO add ui control




TODO core add entry implement, protocol
    TODO update engine-scene
    TODO update Job
    TODO update sceneview render->root pipeline(move root pipeline type to StateType)

TODO event add entry implement, protocol

TODO refactor get engine core, most, root:use getPackageService("meta3d-core-protocol"):
    add core implement
TODO refactor get engine scene:use getPackageService
TODO refactor get ui:use getPackageService
TODO refactor get event:use getPackageService

TODO refactor get editor whole:use getPackageService
e.g. scenegraph utils-> api.getExtensionService<editorWholeService>(meta3dState, editorWholeProtocolName) 

TODO fix editor whole service->ui, event






TODO update UpdateCameraJob
    TODO update meta3d-view-utils->getViewRect



TODO fix scene:remove unUsed
    TODO create gameObject: not consider un used
    TODO getAllGameObjects when render should exclude arcball gameObject





TODO update editor-whole
    # TODO extract Scenegraph Converter Package?




TODO publish all


TODO need publish:
# editor whole
# sceneview render
# pipeline-camera
# meta3d-pipeline-webgl1-three-sceneviewrender


TODO pass run test:
visual
visualRun
runApp


# **** TODO run test: SceneTree+Scene View+ *Game View
# **** TODO run test: Controller+Scene View


**** DONE run test: Controller+Scene View+ *Game View

# TODO extract Three Render Package from Editor Whole Package for both Editor/Engine Whole Package

# TODO fix update camera job
TODO fix update camera aspect job

# TODO feat:engine-core: add mark pipeline execOnce and exec/not exec for game view render's pipelines
#     bdd test

TODO publish
# action
# ui control
# # core
# editor-whole
#     sceneview render
#     gameview render
sceneview render->pipeline, pro
gameview render->meta3d-editor-gameview-render


TODO run test: only scene view
TODO run test: only game view
    //nullable error
    //arcball together
    //not arcball
    //should run once when init
TODO run test: both view

**** DONE run test: publish(Button)

TODO publish
sceneview render->meta3d-editor-sceneview-render, pipeline, pro
gameview render->meta3d-editor-gameview-render, pipeline

engine whole package
web render package
three package
action publish, pro

editor whole package->remove dispose,scenegraph, api; add three package, export scene extension
editor whole package->extension rename to meta3d-editor-webgl1-three-whole
editor whole package->extension pro

engine scene package->engine scene
engine scene package:
    add dispose


TODO run test

TODO need publish


# **** TODO ap assemble:
# remove extension, contribute, only remain package



**** DONE feat: Selected Package: add start
TODO start entry extension

TODO fix:
findNewestPackage

TODO run test 




**** DONE fix: import package should keep package structure(sub, subsub, ... packages)


TODO update:
publish package
import package
publish app
import app

TODO pass compile


TODO bdd test

TODO run test:
    import package
    debug package

    test completely editor whole package
    debug package
    debug contribute
    publish app
    import app

    # publish->engine run


**** DONE fix: import app should keep package structure(sub, subsub, ... packages)

TODO bdd test

TODO run test


# **** TODO feat: ap assemble space: Debug: should keep package structure
**** DONE feat: ap assemble space: Debug: should all extensions,contributes

TODO update flag

TODO publish app should check flag


**** DONE fix: ap assemble space: Debug: Package-> show Debug: if show one package->switch package: should not show Debug!


**** DONE fix: auto upgrade: upgrade saved/not saved in app packages(not upgrade their extensions/contributes)


TODO run test:app
TODO run test:package


TODO clear debug flag


TODO bdd test

TODO run test



**** DONE refactor: ap assemble space: remove Extensions, Selected Extensions

# TODO remove Store->StartExtension
# TODO remove extension-> isStart



# **** TODO fix: package name duplicate?


*** TODO ui control

UI Control Inspector:
# Rect, Config(old: Specific), Input, Event
Rect, Specific, Input, Event


# TODO rename Specific to Config

# TODO Event is read from ui control output data:
#     TODO remove Config.ts->getUIControlSupportedEventNames, generateHandleUIControlEventStr


**** DONE add Input
map to ui control: one to one

name defined in implement

uiControlInput: (meta3dState, api) => Promise<ui control's input data>


TODO ui
TODO editor whole->register
TODO element mr


TODO contribute third: support get multiple implement of one protocol


TODO element assemble space->UIControlInspector
TODO select only has matched inputs



TODO finish input, pro

TODO update ui control, action


**** DONE bdd test

uiControlInspector

elementmr


**** DONE run test

TODO publish:
meta3d-ui-control-runstopbutton
meta3d-ui



**** DONE Specific get image base64

TODO publish
runstop


TODO pass run test:
    fix View


TODO pass bdd test




*** TODO action


TODO only get editor whole service





*** TODO ui control input


TODO only get editor whole service



*** TODO support import multiple element contributes

TODO Element装配、发布Element to 页面Xxx


TODO add 发布的页面
TODO store elementMR data as a binary file
    TODO remove execOrder
TODO select multiple
TODO remove same name but different version
# TODO ap assemble space: add Elements, SelectedElements
TODO update ElementVisual:
    TODO just merge their Selected UI Controls

# TODO select all: add select all elements

# TODO Contribute Market not show element contribute protocol
TODO remove element contribute protocol





TODO pass compile

TODO pass bdd test

TODO pass run test:
    publish app with two elements
    import app
        fix load, start app 
        fix publish app 
            add selectedElements
            selectedContributes add generated element contribute
        # fix register element in editor whole
        fix import app
            getAllDataOfApp

        compile
        bdd test
        run test
            # need deselect element contribute after import old app
            switch from element to ap: loss ui control inspector data
            import app->publish app->run app: error: already register element contribute



TODO commit




TODO dependency check: check their used ui controls should be selected
//TODO their element contribute protocol can be different

TODO add protocol

# TODO ShowPublishedElement:add account

# before isImportElement

TODO bdd test

TODO run test
    republish elements


# TODO because element contribute dependent on uiControlInput and Action, dependency check should check them! 
TODO because element contribute dependent on uiControlInput and Action, if not has them, use empty instead
    //TODO give warn message(list them)


TODO bdd test



TODO fix: import app->ShowPublishedElement should show selected elements



TODO autograpde: update selected element assemble data

# TODO dispatch user center store

TODO bdd test


*** TODO feat: action, uiControlInput add input textarea so that can get content by select or input

**** DONE input

# TODO generate and register contribute


TODO store in element data:
    TODO add to ui control inspector->input 
    TODO store in element data when publish element
    TODO build from selectedElements get it

    TODO when generate app(in visual, visual run, run app), selectedContributes add generated contribute from element data



# TODO selectedContributes add generated contribute
# refer to generateElementContribute



# TODO update ui control inspector->input: refer to SetInput

TODO auto generate inputName

TODO provide default str


TODO bdd test

TODO run test:
    create, run
        fix select
    run app

    publish app->import app->run




# **** TODO refactor: not add element contribute when publish
#     TODO add when run app
#     TODO not remove when import




**** DONE action


TODO store in element data:
    TODO add to ui control inspector->action 
    TODO store in element data when publish element
    TODO build from selectedElements get it

    TODO when generate app(in visual, visual run, run app), selectedContributes add generated contribute from element data



TODO auto generate actionName

TODO provide default str



TODO pass compile

TODO pass bdd test

TODO pass run test:
    create, run
    run app
    publish app->import app->run

    TODO fix ui:
    rows newline



*** DONE refactor api for input, action
TODO update ui control and input api:
api = {
    editorWholePackage service(actually engine-whole-protocol),
}

api = {
    editorWholePackage service,

    get/setActionState(for all actions' states),
}


TODO add utils api:
e.g.:
nullable->getExn, ...; 
immutable->List, ...


TODO update action,input,uiControl

TODO update immutable



TODO update default input, action file str

TODO run test
    TODO update package: core package add immutable extension






*** DONE update Action
    update api

*** DONE fix: can't get input/action file str!



# *** TODO run test: Controller+Scene View+Game View UI Control



# *** TODO feat: support published element contribute as a new UI Control(higher level)
# dependency:
# used ui control protocols
# used ui control input protocols
# used action protocols

# use case:
# 1.user publish element contribute as TransformInspector(=some InputFloat3 + ...) in element assemble
# 2.user select TransformInspector from Market, use it as a new ui control


# TODO add UIControl assemble


# TODO Scene Tree is published element contribute which = header window + Tree


# *** TODO run test: Publish UI Control

# TODO run test:publish->engine render




*** DONE fix: publish app: can't overwrite app?



# *** TODO element space: fix:  remove scene view, not update visual!
*** DONE element space: fix:  remove last selected ui control, not clear!








*** DONE fix: visual: click runstop button shouldn't error

TODO not trigger in visual?


** DONE specific->imageBase64: show preview

** DONE abstract Controller

TODO move two textures to UI Control Inspector->Config


** DONE fix: input/action file str->name should be unique

e.g. two switch button


TODO fix uiControlName duplicate bug

# TODO fix uiControlInspector->default action file str->event name: add id

TODO p:
switch button +p
button +p


# ** TODO fix: input file str: select custom should refresh


# ** TODO fix: action file str: switch Select should reset eventData


** DONE fix: input/action file str: switch select from custom to other, should reset file str



** DONE fix: event name


# ** TODO fix: start package in ap assemble space->enter Index: should unstart package

# ap->showelements->ap


# * TODO feat: check version's format when publish app and element
** DONE feat: auto generate version when publish element

# 1.can select: major, minor, patch
# 2.generate new major, minor, patch added version!

# default select is patch



TODO search element name to get element version



** DONE feat: auto add version when publish extension,contribute, protocol

add new script


TODO:
pro
implement



** DONE feat: auto generate version when publish package


** DONE refactor: rename to custom


** DONE add custom actions:Array<[actionName, fileStr]> and custom inputs


data change to store in app!

TODO custom action: generate unique protocol name
TODO custom input: generate one same protocol name


TODO remove custom in UIControlInspector

TODO no need to convert



TODO not add generated when generate app, add when enter element assemble instead

TODO when publish app, add custom data to app(still use selected contributes in ap assemble store)

//TODO not add generated when enter app, add generated when publish app instead
TODO update add generated when enter app

TODO update import app


# TODO when switch between Assemble and Index, not remain selected contributes in ap assemble store



TODO pass compile

TODO pass bdd test

TODO pass run test:
    create, run
        TODO not clear custom data when switch
    run app
    publish app->import app->run



** DONE Menu
Menu->Specific: 
# set Array<Array<name:string, actionName:string>>
Array<[menuLabel, Record<menuLabel, string>]>

# TODO actionName use Select

TODO use Textarea directly 


TODO test run, stop
    TODO update core, whole package






# ** TODO fix: import app->start package in ap assemble space->enter Index: should unstart package



** DONE menu add actions


TODO add all actions and extensions

TODO refactor: extract asset package
load-glb


TODO remove import single event action?


TODO update:
# engine-whole
# asset
# editor whole
#     import scene
#     "meta3d-pipeline-webgl1-three-gameviewrender"
#     "meta3d-pipeline-webgl1-three-sceneviewrender"


TODO run test:
    publish
    ...





** DONE Asset
separate header, body:
    header = multiple Image Buttons


TODO add Image Button ui control

TODO add input

TODO update export,import action


TODO update drag to Scene View



TODO action protocol remove type elementState

TODO action->createState get meta3dState



TODO update:
engine-whole
asset
    asset
# ui
editor whole




TODO run test
    load glb
    remove asset
    drag glb to scene




** DONE SceneTree
separate header, body:
    header = multiple Image Buttons


TODO rename to Tree

TODO add Input



TODO update:
engine-whole
ui
    imgui render
editor whole

ui control tree
dispose action



TODO fix:
not selected
set parent bug
ui control should move out



** DONE Inspector
TODO split inspector to multiple ui controls(e.g. Input3Float, Text, InputText, CollapsingHeader + Window)
    split to Inspector(as container) + multiple Component Inspectors(as member)



TODO Window need input 


TODO add Input3Float, InputText, Collapsing

TODO update UIControlInspector, ElementMRUtils


TODO can make inspector show in element visual:
    by set uiControlInput to return true






TODO update:
# engine-whole
# ui
#     imgui render
# editor whole

# ui control tree




TODO pass compile

TODO pass bdd

TODO publish


TODO run test
test type->bool,select->value


TODO fix:





# ** TODO demo2: ui control: Scene Tree(header+Tree)+Inspector(GameObject Inspector which only has a name)





# ** TODO demo3: ui control: Scene Tree(header+Tree)+Inspector(GameObject Inspector which only has a name)+Scene View+Game View




# ** TODO finish other



# ** TODO remove unused ones

# e.g. xxx-sceneview/gameview







# * TODO UI Control可配置化、抽象化


# ** TODO Inspector
# TODO split inspector to multiple ui controls(e.g. Input3Float, Text, InputText, CollapsingHeader)


# TODO can make inspector show in element visual:
#     by set uiControlInput to return true



# split to Inspector(as container) + multiple Component Inspectors(as member)



# Inspector: can edit component;set component's data;
# TODO 加入更多的Component Inspector


# *** TODO active basic camera view
# TODO fix import scene* TODO>active

# *** TODO add component
# **** TODO now only add arcball, basiccameraview, perspective component, no other components
# handle event
#    **** TODO export/import scene/single event: use plugin for GLTFExporter, GLTFLoader to support arcballCameraController
#    **** TODO publish: bind event when active has arcball


# ** TODO SceneTree
# separate header, body:
#     header = multiple Image Buttons
# ** TODO Controller
# abstract to Switch Button with configable two textures



# *** TODO fix: visual: why not show controller button?


# ** TODO Message


# ** TODO Model







# * TODO refactor: remove Specific->label


* DONE fix: stop: should run gameview once

# * TODO refactor: editor whole package not dependent on ui control protocol

* DONE fix: specific->imagebase64 preview image same

* DONE fix: inputNumber

# * TODO Selected UIControls show label instead of display name



# * TODO change input/action file str to same with contribute file
# use:
# export let getContribute = (api) =>{
#     ...
# }


# TODO input

# TODO action


* DONE switch to element assemble, show loading...




* DONE menu->specific: add warn if error



# * TODO fix: change custom action: ui control inspector->event select value not change


* DONE update Action: move uiData to action protocol


# * TODO refactor: continue "ap assemble space: remove Extensions, Selected Extensions"

# TODO remove Store->StartExtension
# TODO remove extension-> isStart



* DONE update api for action,input,uiControl

use api.nullable.xxx, ...


* DONE perf: remove direct dependent one immutable, use immutable extension instead

e.g. use import type {List} from "immutable" instead of import {List} from "immutable"





# * TODO refactor: remove ui control->init

* DONE refactor: move rect out of specficData
* DONE refactor: remove generateUIControlCommonDataStr


* DONE refactor: hide IsDraw


* DONE publish and run test

TODO update 
all packages


TODO remove immutable extension
TODO update core, event,   editor/engine whole


# * TODO refactor: change root/contributes/ to root/actions, root/ui_controls,root/ui_control_inputs; remove root/extensions/, protocol/extension_protocols/




* DONE fix: import single event: 1.export single event 2. import event: render lighter !
if continue 1.->2., then will render more lighter!

TODO fix: action publish: render lighter than visualRun




TODO update 
editor whole
web render
engine whole






* DONE style: import package: show info under import button like import app

* DONE style: select package: show info under select button


* DONE remove meta3d-imgui-webgl1-three-renderer in ui package

# * TODO feat(platform): ap assemble: PackageInspector, ContributeInspector show protocol,implement repo link



# * TODO two kind asset package implement:
# BasicAsset
# DracoKTX2Asset


* TODO publish

pass bdd test

pass ci