@soonspacejs/plugin-flow 2.13.4 → 2.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/flows/index.d.ts +1 -0
- package/dist/flows/nodes/Node.d.ts +2 -1
- package/dist/flows/utils.d.ts +3 -4
- package/dist/index.esm.js +1 -1
- package/dist/triggers/ComponentTrigger.d.ts +6 -5
- package/dist/triggers/Trigger.d.ts +17 -2
- package/dist/triggers/types.d.ts +4 -0
- package/package.json +3 -3
package/dist/flows/index.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ declare class Node {
|
|
|
21
21
|
init(): void;
|
|
22
22
|
readContext<T = any>(key: string): T | undefined;
|
|
23
23
|
writeContext(key: string, value: any): void;
|
|
24
|
-
findProp(name: string, type: NodePropType['type']):
|
|
24
|
+
findProp(name: string, type: NodePropType['type'] | NodePropType['type'][]): undefined | NodePropType;
|
|
25
25
|
/**
|
|
26
26
|
* 等待前置节点执行完毕
|
|
27
27
|
*/
|
|
@@ -41,5 +41,6 @@ declare class Node {
|
|
|
41
41
|
*/
|
|
42
42
|
run(global: NodeGlobalType): Promise<void>;
|
|
43
43
|
cleanup(): void;
|
|
44
|
+
protected getValue(prop: NodePropType): any;
|
|
44
45
|
}
|
|
45
46
|
export { Node, };
|
package/dist/flows/utils.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Object3D } from 'three';
|
|
2
|
-
import SoonSpace, {
|
|
2
|
+
import SoonSpace, { BaseObject3D } from 'soonspacejs';
|
|
3
3
|
import { FlowParser } from './FlowParser';
|
|
4
4
|
import { Node } from './nodes';
|
|
5
5
|
import { NodeType } from './types';
|
|
6
6
|
export declare function parseNodeByType(parser: FlowParser, node: NodeType): Node;
|
|
7
7
|
export declare function parseValue<T = any>(value: string): T;
|
|
8
8
|
export declare function waitFor(fn: () => Promise<void>, wait: boolean): Promise<void>;
|
|
9
|
-
export declare function
|
|
10
|
-
export declare function getModelByUuids(ssp: SoonSpace, uuids: string[]): Model[];
|
|
11
|
-
export declare function getModelByFamilyId(ssp: SoonSpace, family: string): Model | null;
|
|
9
|
+
export declare function getObjectByIds(ssp: SoonSpace, ids: string[]): BaseObject3D[];
|
|
12
10
|
export declare function getMeshByUserDataUuid(object: Object3D, uuid: string): Object3D | null;
|
|
11
|
+
export declare function filterNodes(prevNode: Node, result: Node[]): Node[];
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EventDispatcher as s}from"three";import t from"soonspacejs";import{AnimationPlayer as e}from"umanager-animation-parser";class i{constructor(s){this.id=s.id,this.source=s.source,this.target=s.target}}let n=0;class o{constructor(s,t){this.prevNodes=[],this.postNodes=[],this.execOrder=0,this.cleanSets=new Set,this.onBefore=null,this.onAfter=null,this.parser=s,this.ssp=s.ssp,this.id=t.id,this.type=t.type,this.props=t.props,this.init()}init(){this.ctx={},this.promise=new Promise(((s,t)=>{this.resolve=s,this.reject=t}))}readContext(s){return this.ctx[s]}writeContext(s,t){this.ctx[s]=t}findProp(s,t){return this.props.find((e=>e.name===s&&e.type===t))}async waitForPrevNodes(){await Promise.all(this.prevNodes.map((s=>s.promise)))}mergeContext(){this.prevNodes.forEach((s=>{Object.assign(this.ctx,s.ctx)}))}async exec(s){}async run(s){var t,e,i,o;await this.waitForPrevNodes(),this.mergeContext(),await(null===(e=null!==(t=this.onBefore)&&void 0!==t?t:this.parser.onNodeBefore)||void 0===e?void 0:e(this));try{this.execOrder=++n,await this.exec(s)}catch(s){throw this.reject(s),s}await(null===(o=null!==(i=this.onAfter)&&void 0!==i?i:this.parser.onNodeAfter)||void 0===o?void 0:o(this)),this.resolve()}cleanup(){this.cleanSets.forEach((s=>s())),this.cleanSets.clear()}}class c extends o{constructor(s,t){super(s,t)}}var a,r;!function(s){s.LOCAL="LOCAL",s.READ_CTX="READ_CTX",s.WRITE_CTX="WRITE_CTX"}(a||(a={})),function(s){s.START="START",s.COLOR="COLOR",s.NUMBER="NUMBER",s.HIGHLIGHT="HIGHLIGHT",s.UN_HIGHLIGHT="UN_HIGHLIGHT",s.OPACITY="OPACITY",s.UN_OPACITY="UN_OPACITY",s.EMISSIVE="EMISSIVE",s.UN_EMISSIVE="UN_EMISSIVE",s.MESH="MESH",s.MESHES="MESHES",s.MODEL="MODEL",s.MODELS="MODELS",s.DELAY="DELAY",s.SHOW="SHOW",s.HIDE="HIDE",s.CLIP_ANIMATION="CLIP_ANIMATION",s.UN_CLIP_ANIMATION="UN_CLIP_ANIMATION",s.TWEEN_ANIMATION="TWEEN_ANIMATION",s.UN_TWEEN_ANIMATION="UN_TWEEN_ANIMATION",s.COMPONENT_TWEEN_ANIMATION="COMPONENT_TWEEN_ANIMATION",s.UN_COMPONENT_TWEEN_ANIMATION="UN_COMPONENT_TWEEN_ANIMATION"}(r||(r={}));class h extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("color",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);s&&t&&this.writeContext(Y(t.value),Y(s.value))}}class l extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("number",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);s&&t&&this.writeContext(Y(t.value),Y(s.value))}}const{objectHandle:d}=t.utils;class u extends o{constructor(s,t){super(s,t)}filterHighlightObject(s){const t=[];return d(s,(s=>{this.ssp.viewport.scener.selectedObjects.highlight.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL),t=this.findProp("color",a.LOCAL),e=this.findProp("opacity",a.LOCAL);if(s&&t&&e){const i=K(this.ssp,Y(s.value)),n=Y(t.value),o=Y(e.value);if(i){const s=this.filterHighlightObject(i);this.ssp.highlightShow(s,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unHighlightShow(s)}))}}}}const{objectHandle:p}=t.utils;class f extends o{constructor(s,t){super(s,t)}filterUnHighlightObject(s){const t=[];return p(s,(s=>{this.ssp.viewport.scener.selectedObjects.highlight.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL);if(s){const t=K(this.ssp,Y(s.value));if(t){const s=this.filterUnHighlightObject(t);this.ssp.unHighlightShow(s),this.cleanSets.add((()=>{this.ssp.highlightShow(s)}))}}}}const{objectHandle:E}=t.utils;class O extends o{constructor(s,t){super(s,t)}filterOpacityObject(s){const t=[];return E(s,(s=>{this.ssp.viewport.scener.selectedObjects.opacity.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL),t=this.findProp("color",a.LOCAL),e=this.findProp("opacity",a.LOCAL);if(s&&t&&e){const i=K(this.ssp,Y(s.value)),n=Y(t.value),o=Y(e.value);if(i){const s=this.filterOpacityObject(i);this.ssp.opacityShow(s,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unOpacityShow(s)}))}}}}const{objectHandle:C}=t.utils;class v extends o{constructor(s,t){super(s,t)}filterUnOpacityObject(s){const t=[];return C(s,(s=>{this.ssp.viewport.scener.selectedObjects.opacity.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.LOCAL);if(s){const t=K(this.ssp,Y(s.value));if(t){const s=this.filterUnOpacityObject(t);this.ssp.unOpacityShow(s),this.cleanSets.add((()=>{this.ssp.opacityShow(s)}))}}}}const{objectHandle:N}=t.utils;class A extends o{constructor(s,t){super(s,t)}filterEmissiveObject(s){const t=[];return N(s,(s=>{this.ssp.viewport.scener.selectedObjects.emissive.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX),t=this.findProp("color",a.READ_CTX),e=this.findProp("baseColor",a.READ_CTX),i=this.findProp("minOpacity",a.READ_CTX),n=this.findProp("maxOpacity",a.READ_CTX),o=this.findProp("duration",a.READ_CTX);if(s&&t&&e&&i&&n&&o){const c=this.readContext(Y(s.value)),a=this.readContext(Y(t.value)),r=this.readContext(Y(e.value)),h=this.readContext(Y(i.value)),l=this.readContext(Y(n.value)),d=this.readContext(Y(o.value));if(c){const s=this.filterEmissiveObject(c);this.ssp.emissiveShow(s,{color:a,baseColor:r,minOpacity:h,maxOpacity:l,duration:d}),this.cleanSets.add((()=>{this.ssp.unEmissiveShow(s)}))}}}}const{objectHandle:I}=t.utils;class T extends o{constructor(s,t){super(s,t)}filterUnEmissiveObject(s){const t=[];return I(s,(s=>{this.ssp.viewport.scener.selectedObjects.emissive.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX);if(s){const t=this.readContext(Y(s.value));if(t){const s=this.filterUnEmissiveObject(t);this.ssp.unEmissiveShow(s),this.cleanSets.add((()=>{this.ssp.emissiveShow(s)}))}}}}const L=Symbol("meshCache");class w extends o{constructor(s,t){super(s,t)}async exec(s){var t;const{viewport:{scene:e}}=this.ssp,i=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this))||e;s[L]||(s[L]={});const n=this.findProp("mesh",a.LOCAL),o=this.findProp("out",a.WRITE_CTX);if(n&&o){let t=null;const e=Y(n.value),c=Y(o.value),a=s[L][e];if(a)return void(t=a);const r=V(i,e);r&&(t=r,s[L][e]=r),this.writeContext(c,t)}}}const g=Symbol("meshesCache");class _ extends o{constructor(s,t){super(s,t)}async exec(s){var t;const{viewport:{scene:e}}=this.ssp,i=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this))||e;s[g]||(s[g]={});const n=this.findProp("meshes",a.LOCAL),o=this.findProp("out",a.WRITE_CTX);if(n&&o){const t=[],e=Y(n.value),c=Y(o.value);e.forEach((e=>{const n=s[g][e];if(n)return void t.push(n);const o=V(i,e);o&&(t.push(o),s[g][e]=o)})),this.writeContext(c,t)}}}class x extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("model",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);if(s&&t){const o=Y(s.value),c=Y(t.value);this.writeContext(c,(e=this.ssp,i=o,null!==(n=e.getAllModel().find((s=>s.userData.id===i||s.userData.uuid===i)))&&void 0!==n?n:null))}var e,i,n}}class M extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("models",a.LOCAL),t=this.findProp("out",a.WRITE_CTX);if(s&&t){const e=Y(s.value),i=Y(t.value);this.writeContext(i,K(this.ssp,e))}}}class m extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("delay",a.LOCAL);if(s){const e=Y(s.value);await t.utils.sleep(e)}}}const{objectHandle:S}=t.utils;class y extends o{constructor(s,t){super(s,t)}filterShowObject(s){const t=[];return S(s,(s=>{!1===s.visible&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX);if(s){const t=this.readContext(Y(s.value));if(t){const s=this.filterShowObject(t),e=t=>{S(s,(s=>{s.visible=t})),this.ssp.render()};e(!0),this.cleanSets.add((()=>e(!1)))}}}}const{objectHandle:P}=t.utils;class b extends o{constructor(s,t){super(s,t)}filterHideObject(s){const t=[];return P(s,(s=>{!0===s.visible&&t.push(s)})),t}async exec(){const s=this.findProp("objects",a.READ_CTX);if(s){const t=this.readContext(Y(s.value));if(t){const s=this.filterHideObject(t),e=t=>{P(s,(s=>{s.visible=t})),this.ssp.render()};e(!1),this.cleanSets.add((()=>e(!0)))}}}}class H extends o{constructor(s,t){super(s,t)}async exec(s){var t;let e=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this));if(!e){const s=this.findProp("object",a.READ_CTX);s&&(e=this.readContext(Y(s.value)))}const i=this.findProp("animation",a.LOCAL);if(e&&i){const s=Y(i.value),t=e.animations[s];t&&(this.ssp.playModelAnimation(e,t),this.cleanSets.add((()=>{this.ssp.stopModelAnimation(e,t)})))}}}class D extends o{constructor(s,t){super(s,t)}async exec(s){var t;let e=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this));if(!e){const s=this.findProp("object",a.READ_CTX);s&&(e=this.readContext(Y(s.value)))}const i=this.findProp("animation",a.LOCAL);if(e&&i){const s=Y(i.value),t=e.animations[s];t&&this.ssp.stopModelAnimation(e,t)}}}const j=new Map;function R(s){var t,e;null===(t=j.get(s))||void 0===t||t.forEach((s=>s.stop())),null===(e=j.get(s))||void 0===e||e.clear()}class U extends o{constructor(s,t){super(s,t)}async exec(s){var t;const i=this.findProp("object",a.READ_CTX),n=this.findProp("animation",a.LOCAL),o=this.findProp("wait",a.LOCAL);if(i&&n&&o){const c=this.readContext(Y(i.value)),a=Y(n.value),r=Y(o.value);if(c){const i=await(null===(t=s.getAnimations)||void 0===t?void 0:t.call(s,this,c,a));if(i){const s=i.find((s=>s.id===a));s&&await F((async()=>{const t=c.matrix.clone();await async function(s,t,i){var n;const{id:o,keyframes:c}=i,a=new e(s,t);j.has(o)||j.set(o,new Set),null===(n=j.get(o))||void 0===n||n.add(a),await a.play(c)}(this.ssp,c,s),this.cleanSets.add((()=>{R(s.id),c&&t.decompose(c.position,c.quaternion,c.scale)}))}),r)}}}}}class G extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",a.LOCAL);if(s){R(Y(s.value))}}}const W=new Map;function B(s){var t,e;null===(t=W.get(s))||void 0===t||t.forEach((s=>s.stop())),null===(e=W.get(s))||void 0===e||e.clear()}class X extends o{constructor(s,t){super(s,t)}async exec(s){var t;const i=this.findProp("object",a.READ_CTX),n=this.findProp("animation",a.LOCAL),o=this.findProp("wait",a.LOCAL);if(i&&n&&o){const c=this.readContext(Y(i.value)),a=Y(n.value),r=Y(o.value);if(c){const n=await(null===(t=s.getComponentAnimations)||void 0===t?void 0:t.call(s,this,c,a));if(n){const s=n.find((s=>s.id===a));if(s){let t=null;"Mesh"===i.valueType?t=c:"Model"===i.valueType&&(t=V(c,s.refId)),t&&await F((async()=>{if(t){const i=t.matrix.clone();await async function(s,t,i){var n;const{id:o,keyframes:c}=i,a=new e(s,t);W.has(o)||W.set(o,new Set),null===(n=W.get(o))||void 0===n||n.add(a),await a.play(c)}(this.ssp,t,s),this.cleanSets.add((()=>{B(s.id),t&&i.decompose(t.position,t.quaternion,t.scale)}))}}),r)}}}}}}class k extends o{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",a.LOCAL);if(s){B(Y(s.value))}}}function Y(s){return JSON.parse(s)}async function F(s,t){t?await s():s()}function K(s,t){const e=new Set(t);return s.getAllModel().filter((s=>e.has(s.userData.id)||e.has(s.userData.uuid)))}function V(s,t){if(s.userData.key===t)return s;for(let e=0,i=s.children.length;e<i;e++){const i=V(s.children[e],t);if(null!==i)return i}return null}const{utils:{sleep:q}}=t;class J extends s{constructor(s,t){super(),this.onNodeBefore=null,this.onNodeAfter=null,this.ssp=s,this.flow=t,this.nodes=[],this.nodesMap=new Map,this.edges=[],this.edgesMap=new Map}addNode(s){this.nodes.push(s),this.nodesMap.set(s.id,s)}addEdge(s){this.edges.push(s),this.edgesMap.set(s.id,s)}getNodeById(s){return this.nodesMap.get(s)}getEdgeById(s){return this.edgesMap.get(s)}clear(){this.nodes.length=0,this.nodesMap.clear(),this.edges.length=0,this.edgesMap.clear()}parse(){this.clear();const{nodes:s,edges:t}=this.flow;s.forEach((s=>{const t=function(s,t){switch(t.type){case r.START:return new c(s,t);case r.COLOR:return new h(s,t);case r.NUMBER:return new l(s,t);case r.HIGHLIGHT:return new u(s,t);case r.UN_HIGHLIGHT:return new f(s,t);case r.OPACITY:return new O(s,t);case r.UN_OPACITY:return new v(s,t);case r.EMISSIVE:return new A(s,t);case r.UN_EMISSIVE:return new T(s,t);case r.MESH:return new w(s,t);case r.MESHES:return new _(s,t);case r.MODEL:return new x(s,t);case r.MODELS:return new M(s,t);case r.DELAY:return new m(s,t);case r.SHOW:return new y(s,t);case r.HIDE:return new b(s,t);case r.CLIP_ANIMATION:return new H(s,t);case r.UN_CLIP_ANIMATION:return new D(s,t);case r.TWEEN_ANIMATION:return new U(s,t);case r.UN_TWEEN_ANIMATION:return new G(s,t);case r.COMPONENT_TWEEN_ANIMATION:return new X(s,t);case r.UN_COMPONENT_TWEEN_ANIMATION:return new k(s,t);default:return new o(s,t)}}(this,s);this.addNode(t)})),t.forEach((s=>{const t=new i(s);this.addEdge(t);const e=this.getNodeById(s.source),n=this.getNodeById(s.target);e&&n&&(e.postNodes.push(n),n.prevNodes.push(e))}))}async run(s={}){const t=this.nodes.filter((s=>s.prevNodes.length||s.postNodes.length)).map((t=>t.run(s)));await Promise.all(t)}async debug(s={},t=1500){this.onNodeAfter=async()=>await q(t),await this.run(s)}stop(){this.nodes.forEach((s=>s.reject(new Error("Flow stopped"))))}cleanup(){this.nodes.sort(((s,t)=>t.execOrder-s.execOrder)).forEach((s=>s.cleanup()))}dispose(){this.stop(),this.cleanup()}}class z extends J{constructor(s,t){super(s,t),this.flow=t}}class Q{constructor(s){this.disposables=[],this.ssp=s}dispose(){this.disposables.forEach((s=>s()))}}var Z,$,ss,ts;!function(s){s.GLOBAL="GLOBAL",s.SELF="SELF",s.OTHER="OTHER"}(Z||(Z={})),function(s){s.FLOW="FLOW",s.ANIMATION="ANIMATION",s.DELAY="DELAY"}($||($={})),function(s){s.GLOBAL="GLOBAL",s.INSTANCE="INSTANCE",s.FAMILY="FAMILY"}(ss||(ss={})),function(s){s.MOUSE_CLICK="MOUSE_CLICK",s.MOUSE_DB_CLICK="MOUSE_DB_CLICK",s.MOUSE_RIGHT_CLICK="MOUSE_RIGHT_CLICK",s.THING_PROP_CHANGE="THING_PROP_CHANGE",s.THING_EVENT="THING_EVENT",s.LOADED="LOADED"}(ts||(ts={}));const{groupBy:es}=t.utils;class is extends Q{constructor(s,t,e,i){super(s),this.target=t,this.interaction=e,this.flows=i,this.flowsMap=es(i,"id"),this.init()}init(){switch(this.interaction.type){case ts.MOUSE_CLICK:this.initMouseClick();break;case ts.MOUSE_DB_CLICK:this.initMouseDbClick();break;case ts.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case ts.LOADED:this.initLoaded();break;case ts.THING_PROP_CHANGE:this.initThingPropChange();break;case ts.THING_EVENT:this.initThingEvent()}}modelHandler(s){var t;const{currentTarget:e}=s;null===(t=this.interaction.obsTargets)||void 0===t||t.forEach((s=>{s===e.userData.key&&this.execBehavior()}))}runFlowByIds(s){s.forEach((s=>{const t=this.flowsMap.get(s);if(t){const s=new z(this.ssp,t[0]);s.parse(),s.run({getTarget:async()=>this.target})}}))}async execBehavior(){const{behaviors:s}=this.interaction;null==s||s.forEach((s=>{if(s.action===$.FLOW)s.actionRefs&&this.runFlowByIds(s.actionRefs)}))}initMouseClick(){this.ssp.signals.modelClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelClick.remove(this.modelHandler)))}initMouseDbClick(){this.ssp.signals.modelDblClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelDblClick.remove(this.modelHandler)))}initMouseRightClick(){this.ssp.signals.modelRightClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelRightClick.remove(this.modelHandler)))}initLoaded(){const s=()=>{this.execBehavior()};this.target.addEventListener("load",s),this.disposables.push((()=>this.target.removeEventListener("load",s)))}initThingPropChange(){}initThingEvent(){}}export{z as ComponentFlowParser,is as ComponentTrigger,J as FlowParser,$ as InteractionAction,Z as InteractionActionType,ss as InteractionObsType,ts as InteractionType,a as NodePropTypeEnum,r as NodeTypeEnum,Q as Trigger};
|
|
1
|
+
import{EventDispatcher as s}from"three";import t from"soonspacejs";import{AnimationPlayer as e}from"umanager-animation-parser";import{FlowParser as i,InteractionAction as n,InteractionType as o,InteractionObsType as r}from"@soonspacejs/plugin-flow";class a{constructor(s){this.id=s.id,this.source=s.source,this.target=s.target}}var c,h;!function(s){s.LOCAL="LOCAL",s.READ_CTX="READ_CTX",s.WRITE_CTX="WRITE_CTX"}(c||(c={})),function(s){s.START="START",s.COLOR="COLOR",s.NUMBER="NUMBER",s.HIGHLIGHT="HIGHLIGHT",s.UN_HIGHLIGHT="UN_HIGHLIGHT",s.OPACITY="OPACITY",s.UN_OPACITY="UN_OPACITY",s.EMISSIVE="EMISSIVE",s.UN_EMISSIVE="UN_EMISSIVE",s.MESH="MESH",s.MESHES="MESHES",s.MODEL="MODEL",s.MODELS="MODELS",s.DELAY="DELAY",s.SHOW="SHOW",s.HIDE="HIDE",s.CLIP_ANIMATION="CLIP_ANIMATION",s.UN_CLIP_ANIMATION="UN_CLIP_ANIMATION",s.TWEEN_ANIMATION="TWEEN_ANIMATION",s.UN_TWEEN_ANIMATION="UN_TWEEN_ANIMATION",s.COMPONENT_TWEEN_ANIMATION="COMPONENT_TWEEN_ANIMATION",s.UN_COMPONENT_TWEEN_ANIMATION="UN_COMPONENT_TWEEN_ANIMATION"}(h||(h={}));let l=0;class d{constructor(s,t){this.prevNodes=[],this.postNodes=[],this.execOrder=0,this.cleanSets=new Set,this.onBefore=null,this.onAfter=null,this.parser=s,this.ssp=s.ssp,this.id=t.id,this.type=t.type,this.props=t.props,this.init()}init(){this.ctx={},this.promise=new Promise(((s,t)=>{this.resolve=s,this.reject=t}))}readContext(s){return this.ctx[s]}writeContext(s,t){this.ctx[s]=t}findProp(s,t){if(!(t instanceof Array))return this.props.find((e=>e.name===s&&e.type===t));for(const e of t){const t=this.findProp(s,e);if(t)return t}}async waitForPrevNodes(){await Promise.all(this.prevNodes.map((s=>s.promise)))}mergeContext(){this.prevNodes.forEach((s=>{Object.assign(this.ctx,s.ctx)}))}async exec(s){}async run(s){var t,e,i,n;await this.waitForPrevNodes(),this.mergeContext(),await(null===(e=null!==(t=this.onBefore)&&void 0!==t?t:this.parser.onNodeBefore)||void 0===e?void 0:e(this));try{this.execOrder=++l,await this.exec(s)}catch(s){throw this.reject(s),s}await(null===(n=null!==(i=this.onAfter)&&void 0!==i?i:this.parser.onNodeAfter)||void 0===n?void 0:n(this)),this.resolve()}cleanup(){this.cleanSets.forEach((s=>s())),this.cleanSets.clear()}getValue(s){return s.type===c.READ_CTX?this.readContext(q(s.value).variableName):s.type===c.LOCAL?"objects"===s.name?z(this.ssp,q(s.value)):q(s.value):void 0}}class u extends d{constructor(s,t){super(s,t)}}class p extends d{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("color",c.LOCAL),t=this.findProp("out",c.WRITE_CTX);s&&t&&this.writeContext(q(t.value),q(s.value))}}class f extends d{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("number",c.LOCAL),t=this.findProp("out",c.WRITE_CTX);s&&t&&this.writeContext(q(t.value),q(s.value))}}const{objectHandle:E}=t.utils;class C extends d{constructor(s,t){super(s,t)}filterHighlightObject(s){const t=[];return E(s,(s=>{this.ssp.viewport.scener.selectedObjects.highlight.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",[c.READ_CTX,c.LOCAL]),t=this.findProp("color",[c.READ_CTX,c.LOCAL]),e=this.findProp("opacity",[c.READ_CTX,c.LOCAL]);if(s&&t&&e){const i=this.getValue(s),n=this.getValue(t),o=this.getValue(e);if(i){const s=this.filterHighlightObject(i);this.ssp.highlightShow(s,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unHighlightShow(s)}))}}}}const{objectHandle:v}=t.utils;class O extends d{constructor(s,t){super(s,t)}filterUnHighlightObject(s){const t=[];return v(s,(s=>{this.ssp.viewport.scener.selectedObjects.highlight.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",c.LOCAL);if(s){const t=z(this.ssp,q(s.value));if(t){const s=this.filterUnHighlightObject(t);this.ssp.unHighlightShow(s),this.cleanSets.add((()=>{this.ssp.highlightShow(s)}))}}}}const{objectHandle:g}=t.utils;class T extends d{constructor(s,t){super(s,t)}filterOpacityObject(s){const t=[];return g(s,(s=>{this.ssp.viewport.scener.selectedObjects.opacity.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",[c.READ_CTX,c.LOCAL]),t=this.findProp("color",[c.READ_CTX,c.LOCAL]),e=this.findProp("opacity",[c.READ_CTX,c.LOCAL]);if(s&&t&&e){const i=this.getValue(s),n=this.getValue(t),o=this.getValue(e);if(i){const s=this.filterOpacityObject(i);this.ssp.opacityShow(s,{color:n,opacity:o}),this.cleanSets.add((()=>{this.ssp.unOpacityShow(s)}))}}}}const{objectHandle:A}=t.utils;class I extends d{constructor(s,t){super(s,t)}filterUnOpacityObject(s){const t=[];return A(s,(s=>{this.ssp.viewport.scener.selectedObjects.opacity.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",c.LOCAL);if(s){const t=z(this.ssp,q(s.value));if(t){const s=this.filterUnOpacityObject(t);this.ssp.unOpacityShow(s),this.cleanSets.add((()=>{this.ssp.opacityShow(s)}))}}}}const{objectHandle:N}=t.utils;class w extends d{constructor(s,t){super(s,t)}filterEmissiveObject(s){const t=[];return N(s,(s=>{this.ssp.viewport.scener.selectedObjects.emissive.has(s)||t.push(s)})),t}async exec(){const s=this.findProp("objects",c.READ_CTX),t=this.findProp("color",c.READ_CTX),e=this.findProp("baseColor",c.READ_CTX),i=this.findProp("minOpacity",c.READ_CTX),n=this.findProp("maxOpacity",c.READ_CTX),o=this.findProp("duration",c.READ_CTX);if(s&&t&&e&&i&&n&&o){const r=this.readContext(q(s.value)),a=this.readContext(q(t.value)),c=this.readContext(q(e.value)),h=this.readContext(q(i.value)),l=this.readContext(q(n.value)),d=this.readContext(q(o.value));if(r){const s=this.filterEmissiveObject(r);this.ssp.emissiveShow(s,{color:a,baseColor:c,minOpacity:h,maxOpacity:l,duration:d}),this.cleanSets.add((()=>{this.ssp.unEmissiveShow(s)}))}}}}const{objectHandle:L}=t.utils;class m extends d{constructor(s,t){super(s,t)}filterUnEmissiveObject(s){const t=[];return L(s,(s=>{this.ssp.viewport.scener.selectedObjects.emissive.has(s)&&t.push(s)})),t}async exec(){const s=this.findProp("objects",c.READ_CTX);if(s){const t=this.readContext(q(s.value));if(t){const s=this.filterUnEmissiveObject(t);this.ssp.unEmissiveShow(s),this.cleanSets.add((()=>{this.ssp.emissiveShow(s)}))}}}}const _=Symbol("meshCache");class b extends d{constructor(s,t){super(s,t)}async exec(s){var t;const{viewport:{scene:e}}=this.ssp,i=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this))||e;s[_]||(s[_]={});const n=this.findProp("mesh",c.LOCAL),o=this.findProp("out",c.WRITE_CTX);if(n&&o){let t=null;const e=q(n.value),r=q(o.value),a=s[_][e];if(a)return void(t=a);const c=Q(i,e);c&&(t=c,s[_][e]=c),this.writeContext(r,t)}}}const y=Symbol("meshesCache");class M extends d{constructor(s,t){super(s,t)}async exec(s){var t;const{viewport:{scene:e}}=this.ssp,i=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this))||e;s[y]||(s[y]={});const n=this.findProp("meshes",c.LOCAL),o=this.findProp("out",c.WRITE_CTX);if(n&&o){const t=[],e=q(n.value),r=q(o.value);e.forEach((e=>{const n=s[y][e];if(n)return void t.push(n);const o=Q(i,e);o&&(t.push(o),s[y][e]=o)})),this.writeContext(r,t)}}}class x extends d{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("model",c.LOCAL),t=this.findProp("out",c.WRITE_CTX);if(s&&t){const e=q(s.value),i=q(t.value);this.writeContext(i,this.ssp.getObjectById(e))}}}class P extends d{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("models",c.LOCAL),t=this.findProp("out",c.WRITE_CTX);if(s&&t){const e=q(s.value),i=q(t.value);this.writeContext(i,z(this.ssp,e))}}}class S extends d{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("delay",c.LOCAL);if(s){const e=q(s.value);await t.utils.sleep(e)}}}const{objectHandle:H}=t.utils;class R extends d{constructor(s,t){super(s,t)}filterShowObject(s){const t=[];return H(s,(s=>{!1===s.visible&&t.push(s)})),t}async exec(){const s=this.findProp("objects",c.READ_CTX);if(s){const t=this.readContext(q(s.value));if(t){const s=this.filterShowObject(t),e=t=>{H(s,(s=>{s.visible=t})),this.ssp.render()};e(!0),this.cleanSets.add((()=>e(!1)))}}}}const{objectHandle:D}=t.utils;class j extends d{constructor(s,t){super(s,t)}filterHideObject(s){const t=[];return D(s,(s=>{!0===s.visible&&t.push(s)})),t}async exec(){const s=this.findProp("objects",c.READ_CTX);if(s){const t=this.readContext(q(s.value));if(t){const s=this.filterHideObject(t),e=t=>{D(s,(s=>{s.visible=t})),this.ssp.render()};e(!1),this.cleanSets.add((()=>e(!0)))}}}}class k extends d{constructor(s,t){super(s,t)}async exec(s){var t;let e=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this));if(!e){const s=this.findProp("object",c.READ_CTX);s&&(e=this.readContext(q(s.value)))}const i=this.findProp("animation",c.LOCAL);if(e&&i){const s=q(i.value),t=e.animations[s];t&&(this.ssp.playModelAnimation(e,t),this.cleanSets.add((()=>{this.ssp.stopModelAnimation(e,t)})))}}}class B extends d{constructor(s,t){super(s,t)}async exec(s){var t;let e=await(null===(t=s.getTarget)||void 0===t?void 0:t.call(s,this));if(!e){const s=this.findProp("object",c.READ_CTX);s&&(e=this.readContext(q(s.value)))}const i=this.findProp("animation",c.LOCAL);if(e&&i){const s=q(i.value),t=e.animations[s];t&&this.ssp.stopModelAnimation(e,t)}}}const U=new Map;function G(s){var t,e;null===(t=U.get(s))||void 0===t||t.forEach((s=>s.stop())),null===(e=U.get(s))||void 0===e||e.clear()}class X extends d{constructor(s,t){super(s,t)}async exec(s){var t;const i=this.findProp("object",c.READ_CTX),n=this.findProp("animation",c.LOCAL),o=this.findProp("wait",c.LOCAL);if(i&&n&&o){const r=this.readContext(q(i.value)),a=q(n.value),c=q(o.value);if(r){const i=await(null===(t=s.getAnimations)||void 0===t?void 0:t.call(s,this,r,a));if(i){const s=i.find((s=>s.id===a));s&&await J((async()=>{const t=r.matrix.clone();await async function(s,t,i){var n;const{id:o,keyframes:r}=i,a=new e(s,t);U.has(o)||U.set(o,new Set),null===(n=U.get(o))||void 0===n||n.add(a),await a.play(r)}(this.ssp,r,s),this.cleanSets.add((()=>{G(s.id),r&&t.decompose(r.position,r.quaternion,r.scale)}))}),c)}}}}}class W extends d{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",c.LOCAL);if(s){G(q(s.value))}}}const V=new Map;function F(s){var t,e;null===(t=V.get(s))||void 0===t||t.forEach((s=>s.stop())),null===(e=V.get(s))||void 0===e||e.clear()}class K extends d{constructor(s,t){super(s,t)}async exec(s){var t;const i=this.findProp("object",c.READ_CTX),n=this.findProp("animation",c.LOCAL),o=this.findProp("wait",c.LOCAL);if(i&&n&&o){const r=this.readContext(q(i.value)),a=q(n.value),c=q(o.value);if(r){const n=await(null===(t=s.getComponentAnimations)||void 0===t?void 0:t.call(s,this,r,a));if(n){const s=n.find((s=>s.id===a));if(s){let t=null;"Mesh"===i.valueType?t=r:"Model"===i.valueType&&(t=Q(r,s.refId)),t&&await J((async()=>{if(t){const i=t.matrix.clone();await async function(s,t,i){var n;const{id:o,keyframes:r}=i,a=new e(s,t);V.has(o)||V.set(o,new Set),null===(n=V.get(o))||void 0===n||n.add(a),await a.play(r)}(this.ssp,t,s),this.cleanSets.add((()=>{F(s.id),t&&i.decompose(t.position,t.quaternion,t.scale)}))}}),c)}}}}}}class Y extends d{constructor(s,t){super(s,t)}async exec(){const s=this.findProp("animation",c.LOCAL);if(s){F(q(s.value))}}}function q(s){return JSON.parse(s)}async function J(s,t){t?await s():s()}function z(s,t){return t.map((t=>s.getObjectById(t))).filter(Boolean)}function Q(s,t){if(s.userData.key===t)return s;for(let e=0,i=s.children.length;e<i;e++){const i=Q(s.children[e],t);if(null!==i)return i}return null}const{utils:{sleep:Z}}=t;class $ extends s{constructor(s,t){super(),this.onNodeBefore=null,this.onNodeAfter=null,this.ssp=s,this.flow=t,this.nodes=[],this.nodesMap=new Map,this.edges=[],this.edgesMap=new Map}addNode(s){this.nodes.push(s),this.nodesMap.set(s.id,s)}addEdge(s){this.edges.push(s),this.edgesMap.set(s.id,s)}getNodeById(s){return this.nodesMap.get(s)}getEdgeById(s){return this.edgesMap.get(s)}clear(){this.nodes.length=0,this.nodesMap.clear(),this.edges.length=0,this.edgesMap.clear()}parse(){this.clear();const{nodes:s,edges:t}=this.flow;s.forEach((s=>{const t=function(s,t){switch(t.type){case h.START:return new u(s,t);case h.COLOR:return new p(s,t);case h.NUMBER:return new f(s,t);case h.HIGHLIGHT:return new C(s,t);case h.UN_HIGHLIGHT:return new O(s,t);case h.OPACITY:return new T(s,t);case h.UN_OPACITY:return new I(s,t);case h.EMISSIVE:return new w(s,t);case h.UN_EMISSIVE:return new m(s,t);case h.MESH:return new b(s,t);case h.MESHES:return new M(s,t);case h.MODEL:return new x(s,t);case h.MODELS:return new P(s,t);case h.DELAY:return new S(s,t);case h.SHOW:return new R(s,t);case h.HIDE:return new j(s,t);case h.CLIP_ANIMATION:return new k(s,t);case h.UN_CLIP_ANIMATION:return new B(s,t);case h.TWEEN_ANIMATION:return new X(s,t);case h.UN_TWEEN_ANIMATION:return new W(s,t);case h.COMPONENT_TWEEN_ANIMATION:return new K(s,t);case h.UN_COMPONENT_TWEEN_ANIMATION:return new Y(s,t);default:return new d(s,t)}}(this,s);this.addNode(t)})),t.forEach((s=>{const t=new a(s);this.addEdge(t);const e=this.getNodeById(s.source),i=this.getNodeById(s.target);e&&i&&(e.postNodes.push(i),i.prevNodes.push(e))}))}async run(s={}){const t=this.nodes.filter((s=>s.prevNodes.length||s.postNodes.length)).map((t=>t.run(s)));await Promise.all(t)}async debug(s={},t=1500){const e=this.onNodeAfter;this.onNodeAfter=async s=>{await Z(t),null==e||e(s)},await this.run(s)}stop(){this.nodes.forEach((s=>s.reject(new Error("Flow stopped"))))}cleanup(){this.nodes.sort(((s,t)=>t.execOrder-s.execOrder)).forEach((s=>s.cleanup()))}dispose(){this.stop(),this.cleanup()}}class ss extends ${constructor(s,t){super(s,t),this.flow=t}}function ts(s,t,e,i){if("a"===e&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?s!==t||!i:!t.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===e?i:"a"===e?i.call(s):i?i.value:t.get(s)}var es,is,ns;"function"==typeof SuppressedError&&SuppressedError;const{groupBy:os}=t.utils;class rs{constructor(s,t,e,i){es.add(this),this.disposables=[],this.ssp=s,this.interaction=t,this.flows=e,this.flowsMap=os(e,"id"),this.options=i||{},ts(this,es,"m",is).call(this)}modelHandler(s){var t;const{target:e}=s;null===(t=this.interaction.obsTargets)||void 0===t||t.forEach((s=>{s===e.userData.sid&&this.execBehavior()}))}runFlowByIds(s){s.forEach((s=>{const t=this.flowsMap.get(s);if(t){const s=new i(this.ssp,t[0]);s.parse(),s.run({getTarget:ts(this,es,"m",ns)})}}))}async execBehavior(){var s,t,e,i;try{const{behaviors:e}=this.interaction;null==e||e.forEach((s=>{if(s.action===n.FLOW)s.actionRefs&&this.runFlowByIds(s.actionRefs)})),(null===(s=this.options)||void 0===s?void 0:s.onTrigger)&&(null===(t=this.options)||void 0===t||t.onTrigger(this.interaction))}catch(s){(null===(e=this.options)||void 0===e?void 0:e.onError)&&(null===(i=this.options)||void 0===i||i.onError(s))}}initMouseClick(){const s=this.modelHandler.bind(this);this.ssp.signals.modelClick.add(s),this.disposables.push((()=>this.ssp.signals.modelClick.remove(s)))}initMouseDbClick(){const s=this.modelHandler.bind(this);this.ssp.signals.modelDblClick.add(s),this.disposables.push((()=>this.ssp.signals.modelDblClick.remove(s)))}initMouseRightClick(){const s=this.modelHandler.bind(this);this.ssp.signals.modelRightClick.add(s),this.disposables.push((()=>this.ssp.signals.modelRightClick.remove(s)))}initLoaded(){(()=>{this.execBehavior()})()}initThingPropChange(){}initThingEvent(){}dispose(){this.disposables.forEach((s=>s()))}}var as,cs,hs,ls,ds,us,ps;es=new WeakSet,is=function(){switch(this.interaction.type){case o.MOUSE_CLICK:this.initMouseClick();break;case o.MOUSE_DB_CLICK:this.initMouseDbClick();break;case o.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case o.LOADED:this.initLoaded();break;case o.THING_PROP_CHANGE:this.initThingPropChange();break;case o.THING_EVENT:this.initThingEvent()}},ns=async function(s){const{obsType:t,obsTargets:e}=this.interaction;if(t===r.GLOBAL)return null;if(t===r.INSTANCE){const s=null==e?void 0:e.map((s=>{const t=this.ssp.getModelById(s);return t||console.warn("Target not found:",s),t}));return s?s[0]:null}return null},function(s){s.GLOBAL="GLOBAL",s.SELF="SELF",s.OTHER="OTHER"}(as||(as={})),function(s){s.FLOW="FLOW",s.ANIMATION="ANIMATION",s.DELAY="DELAY"}(cs||(cs={})),function(s){s.GLOBAL="GLOBAL",s.INSTANCE="INSTANCE",s.FAMILY="FAMILY"}(hs||(hs={})),function(s){s.MOUSE_CLICK="MOUSE_CLICK",s.MOUSE_DB_CLICK="MOUSE_DB_CLICK",s.MOUSE_RIGHT_CLICK="MOUSE_RIGHT_CLICK",s.THING_PROP_CHANGE="THING_PROP_CHANGE",s.THING_EVENT="THING_EVENT",s.LOADED="LOADED"}(ls||(ls={}));const{groupBy:fs}=t.utils;class Es extends rs{constructor(s,t,e,i){super(s,t,e,i),ds.add(this),this.flows=e,this.flowsMap=fs(e,"id"),ts(this,ds,"m",us).call(this)}async getObsTarget(s){console.log("currentNode",s);const{obsType:t,obsTargets:e}=this.interaction;if(t===hs.GLOBAL)return null;if(t===hs.INSTANCE){const s=null==e?void 0:e.map((s=>{const t=this.ssp.getModelById(s);return t||console.warn("Target not found:",s),t}));return s?s[0]:null}return null}modelHandler(s){var t;const{currentTarget:e}=s;null===(t=this.interaction.obsTargets)||void 0===t||t.forEach((s=>{s===e.userData.key&&this.execBehavior()}))}runFlowByIds(s){s.forEach((s=>{const t=this.flowsMap.get(s);if(t){const s=new ss(this.ssp,t[0]);s.parse(),s.run({getTarget:this.getObsTarget})}}))}async execBehavior(){var s,t,e,i;try{const{behaviors:e}=this.interaction;null==e||e.forEach((s=>{if(s.action===cs.FLOW)s.actionRefs&&this.runFlowByIds(s.actionRefs)})),(null===(s=this.options)||void 0===s?void 0:s.onTrigger)&&(null===(t=this.options)||void 0===t||t.onTrigger(this.interaction))}catch(s){(null===(e=this.options)||void 0===e?void 0:e.onError)&&(null===(i=this.options)||void 0===i||i.onError(s))}}initMouseClick(){this.ssp.signals.modelClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelClick.remove(this.modelHandler)))}initMouseDbClick(){this.ssp.signals.modelDblClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelDblClick.remove(this.modelHandler)))}initMouseRightClick(){this.ssp.signals.modelRightClick.add(this.modelHandler),this.disposables.push((()=>this.ssp.signals.modelRightClick.remove(this.modelHandler)))}initLoaded(){const s=()=>{this.execBehavior()};this.getObsTarget().then((t=>{t&&(t.addEventListener("load",s),this.disposables.push((()=>t.removeEventListener("load",s))))}))}initThingPropChange(){this.ssp.signals.thingModelPropsChange.add(ts(this,ds,"m",ps)),this.disposables.push((()=>this.ssp.signals.thingModelPropsChange.remove(ts(this,ds,"m",ps))))}initThingEvent(){}onThingPropChange(s){this.ssp.signals.thingModelPropsChange.dispatch({propKey:s})}}ds=new WeakSet,us=function(){switch(this.interaction.type){case ls.MOUSE_CLICK:this.initMouseClick();break;case ls.MOUSE_DB_CLICK:this.initMouseDbClick();break;case ls.MOUSE_RIGHT_CLICK:this.initMouseRightClick();break;case ls.LOADED:this.initLoaded();break;case ls.THING_PROP_CHANGE:this.initThingPropChange();break;case ls.THING_EVENT:this.initThingEvent()}},ps=function(s){var t;const{propKey:e}=s;null===(t=this.interaction.obsProps)||void 0===t||t.forEach((s=>{s===e&&this.execBehavior()}))};export{ss as ComponentFlowParser,Es as ComponentTrigger,$ as FlowParser,cs as InteractionAction,as as InteractionActionType,hs as InteractionObsType,ls as InteractionType,d as Node,c as NodePropTypeEnum,h as NodeTypeEnum,rs as Trigger};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import SoonSpace, { Model, ModelEventParams } from 'soonspacejs';
|
|
2
2
|
import { Trigger } from './Trigger';
|
|
3
|
-
import { Interaction } from './types';
|
|
3
|
+
import { Interaction, TriggerOptions } from './types';
|
|
4
4
|
import { ComponentFlowType } from '../flows/types';
|
|
5
|
+
import { Node } from '../flows';
|
|
5
6
|
declare class ComponentTrigger extends Trigger {
|
|
6
|
-
|
|
7
|
-
interaction: Interaction;
|
|
7
|
+
#private;
|
|
8
8
|
flows: ComponentFlowType[];
|
|
9
9
|
flowsMap: Map<string, ComponentFlowType[]>;
|
|
10
|
-
constructor(ssp: SoonSpace,
|
|
11
|
-
|
|
10
|
+
constructor(ssp: SoonSpace, interaction: Interaction, flows: ComponentFlowType[], options: TriggerOptions);
|
|
11
|
+
getObsTarget(currentNode?: Node): Promise<Model | null>;
|
|
12
12
|
modelHandler(params: ModelEventParams): void;
|
|
13
13
|
runFlowByIds(flowIds: string[]): void;
|
|
14
14
|
execBehavior(): Promise<void>;
|
|
@@ -18,5 +18,6 @@ declare class ComponentTrigger extends Trigger {
|
|
|
18
18
|
initLoaded(): void;
|
|
19
19
|
initThingPropChange(): void;
|
|
20
20
|
initThingEvent(): void;
|
|
21
|
+
onThingPropChange(newProps: string): void;
|
|
21
22
|
}
|
|
22
23
|
export { ComponentTrigger, };
|
|
@@ -1,8 +1,23 @@
|
|
|
1
|
-
import SoonSpace from 'soonspacejs';
|
|
1
|
+
import SoonSpace, { ModelEventParams } from 'soonspacejs';
|
|
2
|
+
import { FlowType, Interaction, TriggerOptions } from '@soonspacejs/plugin-flow';
|
|
2
3
|
declare class Trigger {
|
|
4
|
+
#private;
|
|
3
5
|
ssp: SoonSpace;
|
|
6
|
+
interaction: Interaction;
|
|
7
|
+
flows: FlowType[];
|
|
8
|
+
flowsMap: Map<string, FlowType[]>;
|
|
9
|
+
options: TriggerOptions;
|
|
4
10
|
disposables: (() => void)[];
|
|
5
|
-
constructor(ssp: SoonSpace);
|
|
11
|
+
constructor(ssp: SoonSpace, interaction: Interaction, flows: FlowType[], options: TriggerOptions);
|
|
12
|
+
modelHandler(params: ModelEventParams): void;
|
|
13
|
+
runFlowByIds(flowIds: string[]): void;
|
|
14
|
+
execBehavior(): Promise<void>;
|
|
15
|
+
initMouseClick(): void;
|
|
16
|
+
initMouseDbClick(): void;
|
|
17
|
+
initMouseRightClick(): void;
|
|
18
|
+
initLoaded(): void;
|
|
19
|
+
initThingPropChange(): void;
|
|
20
|
+
initThingEvent(): void;
|
|
6
21
|
dispose(): void;
|
|
7
22
|
}
|
|
8
23
|
export { Trigger, };
|
package/dist/triggers/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soonspacejs/plugin-flow",
|
|
3
3
|
"pluginName": "FlowPlugin",
|
|
4
|
-
"version": "2.13.
|
|
4
|
+
"version": "2.13.5",
|
|
5
5
|
"description": "FlowPlugin plugin for SoonSpace.js",
|
|
6
6
|
"main": "dist/index.esm.js",
|
|
7
7
|
"module": "dist/index.esm.js",
|
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
],
|
|
14
14
|
"author": "xunwei",
|
|
15
15
|
"license": "UNLICENSED",
|
|
16
|
-
"gitHead": "
|
|
16
|
+
"gitHead": "e19da4dc04255f2374645aa083e0116668894874",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"soonspacejs": "2.13.
|
|
18
|
+
"soonspacejs": "2.13.5",
|
|
19
19
|
"umanager-animation-parser": "^0.0.6"
|
|
20
20
|
}
|
|
21
21
|
}
|