@telia-ace/widget-core 1.3.31-rc.0 → 1.3.32
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/action-resolver.d.ts +1 -0
- package/bootstrap.d.ts +2 -1
- package/component-platform/actions-controller.d.ts +1 -0
- package/component-platform/component-configuration-api.d.ts +1 -1
- package/component-platform/component-controller.d.ts +1 -0
- package/component-platform/component-node-collection.d.ts +1 -0
- package/component-platform/component-node.d.ts +1 -0
- package/component-platform/component-platform.d.ts +1 -0
- package/component-platform/component-query.d.ts +1 -0
- package/component-platform/create-component-model.d.ts +1 -0
- package/component-platform/custom-component-handler.d.ts +1 -0
- package/component-platform/descriptor.d.ts +1 -0
- package/component-platform/extend-component.d.ts +1 -0
- package/component-platform/queries.d.ts +1 -0
- package/component-platform/state-processor.d.ts +1 -0
- package/component-resolver.d.ts +2 -1
- package/environment.d.ts +2 -1
- package/event-subscriber.d.ts +1 -0
- package/implementation.d.ts +1 -0
- package/index.js +3 -3
- package/index.mjs +231 -231
- package/package.json +2 -2
- package/plugin.d.ts +1 -0
- package/types/configuration.d.ts +1 -0
- package/widget-type.d.ts +1 -0
- package/component-platform/changeset-provider.d.ts +0 -8
package/action-resolver.d.ts
CHANGED
package/bootstrap.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BootstrappedImplementation } from '@webprovisions/bootstrapping';
|
|
2
2
|
import { ConfigureCallback } from '@webprovisions/platform';
|
|
3
|
-
import Implementation from './implementation';
|
|
3
|
+
import { default as Implementation } from './implementation';
|
|
4
|
+
|
|
4
5
|
export type BootstrapOptions = {
|
|
5
6
|
/**
|
|
6
7
|
* Resolver function for the root element to base the bootstrapping on.
|
|
@@ -3,6 +3,7 @@ import { ComponentNodeController } from './component-controller';
|
|
|
3
3
|
import { ComponentNode } from './component-node';
|
|
4
4
|
import { ComponentPlatform } from './component-platform';
|
|
5
5
|
import { ComponentQuery } from './component-query';
|
|
6
|
+
|
|
6
7
|
export type ActionData = any;
|
|
7
8
|
export type ActionHandler = (data: any, options: any, instance: ComponentNodeController) => any;
|
|
8
9
|
export type NextActionDelegate = (data: any, options?: any) => Promise<any>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import(
|
|
1
|
+
declare const _default: import('@webprovisions/platform').ConfigurationApiDefinition;
|
|
2
2
|
export default _default;
|
|
@@ -2,6 +2,7 @@ import { ActionsController } from './actions-controller';
|
|
|
2
2
|
import { ChangesetOptions, ComponentNode, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties } from './component-node';
|
|
3
3
|
import { ComponentPlatform } from './component-platform';
|
|
4
4
|
import { ComponentQuery } from './component-query';
|
|
5
|
+
|
|
5
6
|
export interface ComponentController {
|
|
6
7
|
actions: ActionsController;
|
|
7
8
|
writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;
|
|
@@ -5,6 +5,7 @@ import { ChangesetOptions, ComponentNode, ComponentNodeSettings, RemoveChangeset
|
|
|
5
5
|
import { ComponentNodeCollection } from './component-node-collection';
|
|
6
6
|
import { ComponentQuery } from './component-query';
|
|
7
7
|
import { CustomHandlerCallback } from './custom-component-handler';
|
|
8
|
+
|
|
8
9
|
export type MergeOptions = {
|
|
9
10
|
breakpoints?: string[];
|
|
10
11
|
};
|
|
@@ -2,6 +2,7 @@ import { EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
|
2
2
|
import { Breakpoints, ComponentSettings, ViewDefinition, WidgetSettings } from '../types';
|
|
3
3
|
import { ComponentNode, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties } from './component-node';
|
|
4
4
|
import { ComponentPlatform } from './component-platform';
|
|
5
|
+
|
|
5
6
|
type ComponentReference = string | [string, ...ComponentReferenceOverride[]];
|
|
6
7
|
type ComponentReferenceOverride = {
|
|
7
8
|
breakpoints?: Breakpoints;
|
|
@@ -2,6 +2,7 @@ import { ComponentReference, ComponentSettings, ViewDefinition } from '../types'
|
|
|
2
2
|
import { ComponentNode } from './component-node';
|
|
3
3
|
import { ComponentPlatform } from './component-platform';
|
|
4
4
|
import { NormalizedComponentReference } from './create-component-model';
|
|
5
|
+
|
|
5
6
|
export type CustomHandlerCallback = (ref: NormalizedComponentReference, options: {
|
|
6
7
|
platform: ComponentPlatform;
|
|
7
8
|
node: ComponentNode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Container } from '@webprovisions/platform';
|
|
2
2
|
import { ComponentNodeController } from './component-controller';
|
|
3
3
|
import { ComponentQuery } from './component-query';
|
|
4
|
+
|
|
4
5
|
export type ExtendComponentHandler = (controller: ComponentNodeController) => any;
|
|
5
6
|
export type ExtendComponentOptions = {
|
|
6
7
|
reuseController?: boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComponentNode } from './component-node';
|
|
2
2
|
import { SwitchMap } from './component-platform';
|
|
3
|
+
|
|
3
4
|
export declare const traverseComponents: (root: ComponentNode, switches: SwitchMap, fn: (node: ComponentNode) => boolean | void) => void;
|
|
4
5
|
export declare const findVisibleComponents: (root: ComponentNode, switches: SwitchMap) => ComponentNode[];
|
|
5
6
|
export declare const findComponent: (root: ComponentNode, switches: SwitchMap, fn: (node: ComponentNode) => boolean) => ComponentNode | undefined;
|
package/component-resolver.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { Logger } from '
|
|
1
|
+
import { Logger } from '../../utilities/src/index.ts';
|
|
2
2
|
import { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
3
|
+
|
|
3
4
|
export type ReactComponent = any | null;
|
|
4
5
|
export default class ComponentResolver {
|
|
5
6
|
aliases: Map<string, string>;
|
package/environment.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { BootstrappedImplementationConfiguration } from '@webprovisions/bootstrapping';
|
|
2
2
|
import { ConfigurationApiDefinition, Environment as EnvironmentBase, WidgetSelector } from '@webprovisions/platform';
|
|
3
|
-
import Implementation from './implementation';
|
|
3
|
+
import { default as Implementation } from './implementation';
|
|
4
|
+
|
|
4
5
|
export interface RuntimeConfiguration {
|
|
5
6
|
/**
|
|
6
7
|
* Extensions for the configuration API (optional).
|
package/event-subscriber.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventListener, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';
|
|
2
|
+
|
|
2
3
|
export type SubscribeDelegate = (type: string, listener: EventListener) => void;
|
|
3
4
|
/**
|
|
4
5
|
* Creates s subscriber for the specified `EventManager` and provides a single cancellation
|
package/implementation.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@webprovisions/bootstrapping"),b=require("@webprovisions/platform"),g=require("@telia-ace/widget-utilities");class Q{constructor(t){const{events:e}=t.get("$widget");this.events=e.createChild(this)}action(t,e,s){this.events.dispatch("data:action",{action:e,value:s,target:t},{bubbles:!0})}subscribe(t,e){return this.events.subscribe("data:action",(s,{action:i,value:r,target:c})=>t===c&&e(t,i,r))}}const z=(n,t,e={})=>$.bootstrapImplementation(n,n.bindings,()=>{const s=n.container.get("$runtimecfg").map(i=>{const r=i[0];if(typeof r=="function")return r;if(b.selectImplementations(r)(n))return i[1]}).filter(i=>!!i);return(t?[t]:[]).concat(s)},e.rootElementResolver||(()=>document.body)),L=n=>{const t=[];return[(s,i)=>{t.push(n.subscribe(s,i))},()=>{t.forEach(s=>{s()})}]};class E{constructor(t,e=[]){this.platform=t,this.rules=e}match(t){return this.rules.every(e=>!(e.id&&e.id!==t.id||e.type&&e.type!==t.type))}ofType(t){return this.rules.push({type:t}),this}withId(t){return this.rules.push({id:t}),this}select(){return new U(this.platform,this)}}class A{constructor(t,e,s){this.platform=t,this.node=e,this.actions=new O(t,new E(t).withId(e.id),s);const[i,r]=L(this.platform.events);this.subscribe=i,this.unsubscribe=r}properties(t){return t&&this.node.touchProperties(e=>t(e)),this.node.attributes.properties}context(t){return t&&this.subscribe("components:context-changed",(e,{node:s})=>{s===this.node&&t(this.node.attributes.context)}),this.node.attributes.context}layout(t){return t&&this.subscribe("components:layout-changed",(e,{node:s})=>{s===this.node&&t(this.node.attributes.layout)}),this.node.attributes.layout}writeProperties(t,e){this.node.writeProperties(t,e)}writeContext(t,e){this.node.writeProperties(t,e)}writeLayout(t,e){this.node.writeLayout(t,e)}dispose(){this.unsubscribe(),this.actions.dispose()}}class U{constructor(t,e,s=!0){this.platform=t,this.target=e,this.clearOnDispose=s,this.removes=[],this.actions=new O(this.platform,this.target)}writeProperties(t,e){this.removes.push(this.platform.write({options:e,attributes:{properties:t},target:this.target,removable:this.clearOnDispose}))}writeContext(t,e){this.removes.push(this.platform.write({options:e,attributes:{context:t},target:this.target,removable:this.clearOnDispose}))}writeLayout(t,e){this.removes.push(this.platform.write({options:e,attributes:{layout:t},target:this.target,removable:this.clearOnDispose}))}dispose(){this.removes.forEach(t=>{t()}),this.actions.dispose()}}const W=(n,t,e)=>{const s=n.concat(),i=(r,c,a)=>{let u=!0;if(s.length){const h=s.shift(),o=(p,l)=>(u=!1,i(p,Object.assign({},c,l),a));return Promise.resolve(h(r,o,a)).then(p=>({...p,cancelled:u}))}return Promise.resolve({data:r,cancelled:!1,options:c})};return i(t,{},e)};class O{constructor(t,e,s){this.platform=t,this.target=e,this.ns=s,this.subscriptions=[],this.create=this.create.bind(this)}create(t,e=()=>{}){const s={key:t,fn:e,target:this.target,ns:this.ns};this.platform.actionsState.handlers.push(s);const i=()=>{const r=this.platform.actionsState.handlers.indexOf(s);r>-1&&this.platform.actionsState.handlers.splice(r,1)};return this.subscriptions.push(i),i}dispatch(t,e){const s=this.platform.nodes.all.concat(this.platform.nodes.detached),i={},r=this.platform.actionsState.handlers.filter(c=>c.key===t&&(!c.ns||!this.ns||c.ns===this.ns));return Promise.all(r.map(c=>{const a=s.filter(h=>c.target.match(h)&&this.target.match(h)),u=this.platform.actionsState.watchers.filter(h=>h.key===t&&(!h.ns||!this.ns||h.ns===this.ns)&&a.some(o=>h.target.match(o))).map(h=>h.fn);return Promise.all(a.map(h=>{const o=new A(this.platform,h,this.ns);return W(u,e,o).then(p=>{const{data:l={},options:d,cancelled:y}=p;return Promise.resolve(y?{}:c.fn(l,d,o)).then(x=>{i[h.id]=x})})}))})).then(()=>i)}watch(t,e){let s=t,i=this.ns;const r=t.split(".");r.length>1&&(i=r[0],s=r.splice(1).join("."));const c={fn:e,target:this.target,key:s,ns:i};this.platform.actionsState.watchers.push(c);const a=()=>{const u=this.platform.actionsState.watchers.indexOf(c);u>-1&&this.platform.actionsState.watchers.splice(u,1)};return this.subscriptions.push(a),a}dispose(){this.subscriptions.forEach(t=>t())}}const F=b.createConfigurationApi(n=>{n.createCommand("components",t=>e=>{t.events.subscribeOnce("components:platform-created",(s,{platform:i})=>{e.handlers&&e.handlers.forEach(([r,c])=>{i.addComponentHandler(r,c)})})})});class R{constructor(t,e){this.events=t,this.tags=[],this.children={},this.changesets=[],this.mountCount=0,this.id=g.uuid(),this.type=e,this.attributes={context:{},properties:{},layout:{},tags:[]},this.writeLayout({size:"full",indent:0})}mount(t,e){let s=t.get("mounted-nodes");return s||(s=new Map,t.register("mounted-nodes",s)),s.has(this)?(process.env.NODE_ENV!=="production"&&g.Logger.error("Trying to mount an already mounted component node.",this),()=>{}):(this.events.dispatch("components:node-mounted",{node:this}),this.mountCount===0&&(this.mountCount=this.mountCount+1,this.events.dispatch("components:node-enter",{node:this})),()=>{s.delete(this),this.events.dispatch("components:node-unmounted",{node:this}),this.mountCount=this.mountCount-1,this.mountCount===0&&this.events.dispatch("components:node-exit",{node:this})})}appendChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].push(t),this.events.dispatch("components:node-appended",{node:t})}prependChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].unshift(t),this.events.dispatch("components:node-appended",{node:t})}touchProperties(t,e={},s){const r=[{properties:t},e];return this.changesets.push(r),this.events.dispatch("components:set-properties",{node:this}),()=>{if(s){const c=this.changesets.indexOf(r);c>-1&&(this.changesets.splice(c,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeProperties(t,e={},s){const r=[{properties:t},e];return this.changesets.push(r),this.events.dispatch("components:set-properties",{node:this}),()=>{if(s){const c=this.changesets.indexOf(r);c>-1&&(this.changesets.splice(c,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeLayout(t,e={},s){const r=[{layout:t},e];return this.changesets.push(r),this.events.dispatch("components:set-layout",{node:this}),()=>{if(!s)return;const c=this.changesets.indexOf(r);c>-1&&(this.changesets.splice(c,1),this.events.dispatch("components:set-layout",{node:this}))}}writeContext(t,e={},s){const r=[{context:t},e];return this.changesets.push(r),this.events.dispatch("components:set-context",{node:this}),()=>{if(!s)return;const c=this.changesets.indexOf(r);c>-1&&(this.changesets.splice(c,1),this.events.dispatch("components:set-context",{node:this}))}}getChildren(t="default"){const e=this.children[t]||[];return e.reduce((s,i,r)=>{const{order:c=r}=i.attributes.layout;return s[c]?s.splice(c,0,i):s[c]=i,s},Array(e.length))}remove(){this.parent&&this.parent.removeChild(this)}removeChild(t){Object.keys(this.children).forEach(e=>{const s=this.children[e],i=s.indexOf(t);i>-1&&(s.splice(i,1),this.events.dispatch("components:node-removed",{node:t,parentNode:this}))}),delete t.parent}}const _=(n,t,e)=>{for(let s=0,i=n.length;s<i&&e(n[s])!==!0;s++){const r=t[n[s].id]||"default",c=n[s].getChildren(r);_(c,t,e)}},N=(n,t,e)=>{if(e(n)!==!0){const s=t[n.id]||"default",i=n.children[s];_(i,t,e)}},C=(n,t)=>{const e=[];return N(n,t,s=>{e.push(s)}),e},H=(n,t,e)=>{let s;return N(n,t,i=>{if(e(i))return s=i,!0}),s};class G{constructor(t,e,s){this.root=t,this.switches=e,this.all=[],this.visible=[],this.detached=[],s.subscribe("components:node-appended",(i,r)=>{this.all.push(r.node),this.visible=C(t,e)}),s.subscribe("components:node-removed",(i,r)=>{let c=this.all.indexOf(r.node);c>-1&&this.all.splice(c,1),c=this.visible.indexOf(r.node),c>-1&&this.visible.splice(c,1),this.visible=C(t,e)}),s.subscribe("components:node-switched",(i,r)=>{this.visible=C(t,e)})}query(t={}){const e=[];return N(this.root,this.switches,s=>{Object.keys(t).every(r=>t[r]===s[r])&&e.push(s)}),e}get(t){return H(this.root,this.switches,e=>e.id===t)||this.detached.find(e=>e.id===t)}}class K{constructor(){this.handlers=new Map}add(t,e){this.handlers.set(t,e)}get(t){return this.handlers.get(t)}}const Y=n=>{let t=n,e=0;for(;t.parent;)e=e+1,t=t.parent;return e},J=n=>n.map(([e,s])=>[Y(e),e,s]).sort(([e],[s])=>e-s).map(([,e,s])=>[e,s]),k=n=>n instanceof Date?!1:n&&typeof n=="object"&&!Array.isArray(n),v=(n,...t)=>{if(!t.length)return n;const e=t.shift();if(k(n)&&k(e))for(const s in e)k(e[s])?(n[s]||Object.assign(n,{[s]:{}}),v(n[s],e[s])):Object.assign(n,{[s]:e[s]});return v(n,...t)},X=(n,t)=>!n||n==="all"?!0:n.some(e=>t.indexOf(e)>-1),Z=(n,t)=>{let e=[],s=[],i;const r=()=>{process.env.NODE_ENV!=="production"&&console.time("state-processor.flush");const a=new Map,u=J(e.map((o,p)=>[o,s[p]])),h=(o,p)=>{var I;const l=a.get(o)||{},d=p.context&&!l.context,y=p.properties&&!l.properties,x=p.layout&&!l.layout;a.set(o,{context:l.context||d,properties:l.properties||y,layout:l.layout||x}),y&&(o.attributes.properties={}),x&&(o.attributes.layout={}),d&&(o.attributes.context=v({},(I=o.parent)==null?void 0:I.attributes.context));const S=[],T=[],D=[];if(o.changesets.forEach(f=>{const[m,P]=f;X(P.breakpoints,n.breakpoints)&&(y&&(typeof m.properties=="function"?S.push(m.properties):v(o.attributes.properties,m.properties)),x&&(typeof m.layout=="function"?T.push(m.layout):v(o.attributes.layout,m.layout)),d&&(typeof m.context=="function"?D.push(m.context):v(o.attributes.context,m.context)))}),S.forEach(f=>{v(o.attributes.properties,f(o.attributes.properties))}),T.forEach(f=>{v(o.attributes.layout,f(o.attributes.layout))}),D.forEach(f=>{v(o.attributes.context,f(o.attributes.context))}),d||p.recursive){const f=n.getBranch(o),m=p.recursive?p:{context:!!d};o.getChildren(f).forEach(P=>{h(P,m)})}};process.env.NODE_ENV!=="production"&&console.timeEnd("state-processor.flush"),u.forEach(([o,p])=>{h(o,p)}),e=[],s=[],t(a)},c=()=>{clearTimeout(i),i=setTimeout(r,0)};return(a,u)=>{const h=e.indexOf(a);if(h>-1){const o=s[h];return u.context&&(o.context=!0),u.properties&&(o.properties=!0),u.layout&&(o.layout=!0),u.recursive&&(o.recursive=!0),c()}return e.push(a),s.push(u),c()}};class M{constructor(t,e={}){this.providers=e,this.breakpoints=[],this.actionsState={handlers:[],watchers:[]},this.switches={},this.changesets=[],this.subscriptions=[],this.customComponentHandler=new K,this.events=t.events.createChild(this);const s=new R(this.events,"root");s.name=`root-${t.name}`,this.nodes=new G(s,this.switches,this.events);const i=this.processNode=Z(this,r=>{const c=Array.from(r.keys());process.env.NODE_ENV!=="production"&&console.info(`STATE PROCESSOR: ${c.length} node(s) processed:
|
|
2
|
-
${
|
|
3
|
-
`)}`),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $=require("@webprovisions/bootstrapping"),b=require("@webprovisions/platform"),g=require("@telia-ace/widget-utilities");class Q{constructor(t){const{events:e}=t.get("$widget");this.events=e.createChild(this)}action(t,e,s){this.events.dispatch("data:action",{action:e,value:s,target:t},{bubbles:!0})}subscribe(t,e){return this.events.subscribe("data:action",(s,{action:i,value:c,target:o})=>t===o&&e(t,i,c))}}const z=(n,t,e={})=>$.bootstrapImplementation(n,n.bindings,()=>{const s=n.container.get("$runtimecfg").map(i=>{const c=i[0];if(typeof c=="function")return c;if(b.selectImplementations(c)(n))return i[1]}).filter(i=>!!i);return(t?[t]:[]).concat(s)},e.rootElementResolver||(()=>document.body)),L=n=>{const t=[];return[(s,i)=>{t.push(n.subscribe(s,i))},()=>{t.forEach(s=>{s()})}]};class E{constructor(t,e=[]){this.platform=t,this.rules=e}match(t){return this.rules.every(e=>!(e.id&&e.id!==t.id||e.type&&e.type!==t.type))}ofType(t){return this.rules.push({type:t}),this}withId(t){return this.rules.push({id:t}),this}select(){return new U(this.platform,this)}}class A{constructor(t,e,s){this.platform=t,this.node=e,this.actions=new O(t,new E(t).withId(e.id),s);const[i,c]=L(this.platform.events);this.subscribe=i,this.unsubscribe=c}properties(t){return t&&this.node.touchProperties(e=>t(e)),this.node.attributes.properties}context(t){return t&&this.subscribe("components:context-changed",(e,{node:s})=>{s===this.node&&t(this.node.attributes.context)}),this.node.attributes.context}layout(t){return t&&this.subscribe("components:layout-changed",(e,{node:s})=>{s===this.node&&t(this.node.attributes.layout)}),this.node.attributes.layout}writeProperties(t,e){this.node.writeProperties(t,e)}writeContext(t,e){this.node.writeProperties(t,e)}writeLayout(t,e){this.node.writeLayout(t,e)}dispose(){this.unsubscribe(),this.actions.dispose()}}class U{constructor(t,e,s=!0){this.platform=t,this.target=e,this.clearOnDispose=s,this.removes=[],this.actions=new O(this.platform,this.target)}writeProperties(t,e){this.removes.push(this.platform.write({options:e,attributes:{properties:t},target:this.target,removable:this.clearOnDispose}))}writeContext(t,e){this.removes.push(this.platform.write({options:e,attributes:{context:t},target:this.target,removable:this.clearOnDispose}))}writeLayout(t,e){this.removes.push(this.platform.write({options:e,attributes:{layout:t},target:this.target,removable:this.clearOnDispose}))}dispose(){this.removes.forEach(t=>{t()}),this.actions.dispose()}}const W=(n,t,e)=>{const s=n.concat(),i=(c,o,a)=>{let u=!0;if(s.length){const h=s.shift(),r=(p,l)=>(u=!1,i(p,Object.assign({},o,l),a));return Promise.resolve(h(c,r,a)).then(p=>({...p,cancelled:u}))}return Promise.resolve({data:c,cancelled:!1,options:o})};return i(t,{},e)};class O{constructor(t,e,s){this.platform=t,this.target=e,this.ns=s,this.subscriptions=[],this.create=this.create.bind(this)}create(t,e=()=>{}){const s={key:t,fn:e,target:this.target,ns:this.ns};this.platform.actionsState.handlers.push(s);const i=()=>{const c=this.platform.actionsState.handlers.indexOf(s);c>-1&&this.platform.actionsState.handlers.splice(c,1)};return this.subscriptions.push(i),i}dispatch(t,e){const s=this.platform.nodes.all.concat(this.platform.nodes.detached),i={},c=this.platform.actionsState.handlers.filter(o=>o.key===t&&(!o.ns||!this.ns||o.ns===this.ns));return Promise.all(c.map(o=>{const a=s.filter(h=>o.target.match(h)&&this.target.match(h)),u=this.platform.actionsState.watchers.filter(h=>h.key===t&&(!h.ns||!this.ns||h.ns===this.ns)&&a.some(r=>h.target.match(r))).map(h=>h.fn);return Promise.all(a.map(h=>{const r=new A(this.platform,h,this.ns);return W(u,e,r).then(p=>{const{data:l={},options:d,cancelled:y}=p;return Promise.resolve(y?{}:o.fn(l,d,r)).then(x=>{i[h.id]=x})})}))})).then(()=>i)}watch(t,e){let s=t,i=this.ns;const c=t.split(".");c.length>1&&(i=c[0],s=c.splice(1).join("."));const o={fn:e,target:this.target,key:s,ns:i};this.platform.actionsState.watchers.push(o);const a=()=>{const u=this.platform.actionsState.watchers.indexOf(o);u>-1&&this.platform.actionsState.watchers.splice(u,1)};return this.subscriptions.push(a),a}dispose(){this.subscriptions.forEach(t=>t())}}const F=b.createConfigurationApi(n=>{n.createCommand("components",t=>e=>{t.events.subscribeOnce("components:platform-created",(s,{platform:i})=>{e.handlers&&e.handlers.forEach(([c,o])=>{i.addComponentHandler(c,o)})})})});class R{constructor(t,e){this.events=t,this.tags=[],this.children={},this.changesets=[],this.mountCount=0,this.id=g.uuid(),this.type=e,this.attributes={context:{},properties:{},layout:{},tags:[]},this.writeLayout({size:"full",indent:0})}mount(t,e){let s=t.get("mounted-nodes");return s||(s=new Map,t.register("mounted-nodes",s)),s.has(this)?(process.env.NODE_ENV!=="production"&&g.Logger.error("Trying to mount an already mounted component node.",this),()=>{}):(this.events.dispatch("components:node-mounted",{node:this}),this.mountCount===0&&(this.mountCount=this.mountCount+1,this.events.dispatch("components:node-enter",{node:this})),()=>{s.delete(this),this.events.dispatch("components:node-unmounted",{node:this}),this.mountCount=this.mountCount-1,this.mountCount===0&&this.events.dispatch("components:node-exit",{node:this})})}appendChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].push(t),this.events.dispatch("components:node-appended",{node:t})}prependChild(t,e="default"){if(t.parent){if(t.parent===this)return;t.parent.removeChild(t)}t.parent=this,this.children[e]||(this.children[e]=[]),this.children[e].unshift(t),this.events.dispatch("components:node-appended",{node:t})}touchProperties(t,e={},s){const c=[{properties:t},e];return this.changesets.push(c),this.events.dispatch("components:set-properties",{node:this}),()=>{if(s){const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeProperties(t,e={},s){const c=[{properties:t},e];return this.changesets.push(c),this.events.dispatch("components:set-properties",{node:this}),()=>{if(s){const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-properties",{node:this}))}}}writeLayout(t,e={},s){const c=[{layout:t},e];return this.changesets.push(c),this.events.dispatch("components:set-layout",{node:this}),()=>{if(!s)return;const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-layout",{node:this}))}}writeContext(t,e={},s){const c=[{context:t},e];return this.changesets.push(c),this.events.dispatch("components:set-context",{node:this}),()=>{if(!s)return;const o=this.changesets.indexOf(c);o>-1&&(this.changesets.splice(o,1),this.events.dispatch("components:set-context",{node:this}))}}getChildren(t="default"){const e=this.children[t]||[];return e.reduce((s,i,c)=>{const{order:o=c}=i.attributes.layout;return s[o]?s.splice(o,0,i):s[o]=i,s},Array(e.length))}remove(){this.parent&&this.parent.removeChild(this)}removeChild(t){Object.keys(this.children).forEach(e=>{const s=this.children[e],i=s.indexOf(t);i>-1&&(s.splice(i,1),this.events.dispatch("components:node-removed",{node:t,parentNode:this}))}),delete t.parent}}const _=(n,t,e)=>{for(let s=0,i=n.length;s<i&&e(n[s])!==!0;s++){const c=t[n[s].id]||"default",o=n[s].getChildren(c);_(o,t,e)}},N=(n,t,e)=>{if(e(n)!==!0){const s=t[n.id]||"default",i=n.children[s];_(i,t,e)}},C=(n,t)=>{const e=[];return N(n,t,s=>{e.push(s)}),e},H=(n,t,e)=>{let s;return N(n,t,i=>{if(e(i))return s=i,!0}),s};class G{constructor(t,e,s){this.root=t,this.switches=e,this.all=[],this.visible=[],this.detached=[],s.subscribe("components:node-appended",(i,c)=>{this.all.push(c.node),this.visible=C(t,e)}),s.subscribe("components:node-removed",(i,c)=>{let o=this.all.indexOf(c.node);o>-1&&this.all.splice(o,1),o=this.visible.indexOf(c.node),o>-1&&this.visible.splice(o,1),this.visible=C(t,e)}),s.subscribe("components:node-switched",(i,c)=>{this.visible=C(t,e)})}query(t={}){const e=[];return N(this.root,this.switches,s=>{Object.keys(t).every(c=>t[c]===s[c])&&e.push(s)}),e}get(t){return H(this.root,this.switches,e=>e.id===t)||this.detached.find(e=>e.id===t)}}class K{constructor(){this.handlers=new Map}add(t,e){this.handlers.set(t,e)}get(t){return this.handlers.get(t)}}const Y=n=>{let t=n,e=0;for(;t.parent;)e=e+1,t=t.parent;return e},J=n=>n.map(([e,s])=>[Y(e),e,s]).sort(([e],[s])=>e-s).map(([,e,s])=>[e,s]),k=n=>n instanceof Date?!1:n&&typeof n=="object"&&!Array.isArray(n),v=(n,...t)=>{if(!t.length)return n;const e=t.shift();if(k(n)&&k(e))for(const s in e)k(e[s])?(n[s]||Object.assign(n,{[s]:{}}),v(n[s],e[s])):Object.assign(n,{[s]:e[s]});return v(n,...t)},X=(n,t)=>!n||n==="all"?!0:n.some(e=>t.indexOf(e)>-1),Z=(n,t)=>{let e=[],s=[],i;const c=()=>{process.env.NODE_ENV!=="production"&&console.time("state-processor.flush");const a=new Map,u=J(e.map((r,p)=>[r,s[p]])),h=(r,p)=>{var I;const l=a.get(r)||{},d=p.context&&!l.context,y=p.properties&&!l.properties,x=p.layout&&!l.layout;a.set(r,{context:l.context||d,properties:l.properties||y,layout:l.layout||x}),y&&(r.attributes.properties={}),x&&(r.attributes.layout={}),d&&(r.attributes.context=v({},(I=r.parent)==null?void 0:I.attributes.context));const S=[],T=[],D=[];if(r.changesets.forEach(f=>{const[m,P]=f;X(P.breakpoints,n.breakpoints)&&(y&&(typeof m.properties=="function"?S.push(m.properties):v(r.attributes.properties,m.properties)),x&&(typeof m.layout=="function"?T.push(m.layout):v(r.attributes.layout,m.layout)),d&&(typeof m.context=="function"?D.push(m.context):v(r.attributes.context,m.context)))}),S.forEach(f=>{v(r.attributes.properties,f(r.attributes.properties))}),T.forEach(f=>{v(r.attributes.layout,f(r.attributes.layout))}),D.forEach(f=>{v(r.attributes.context,f(r.attributes.context))}),d||p.recursive){const f=n.getBranch(r),m=p.recursive?p:{context:!!d};r.getChildren(f).forEach(P=>{h(P,m)})}};process.env.NODE_ENV!=="production"&&console.timeEnd("state-processor.flush"),u.forEach(([r,p])=>{h(r,p)}),e=[],s=[],t(a)},o=()=>{clearTimeout(i),i=setTimeout(c,0)};return(a,u)=>{const h=e.indexOf(a);if(h>-1){const r=s[h];return u.context&&(r.context=!0),u.properties&&(r.properties=!0),u.layout&&(r.layout=!0),u.recursive&&(r.recursive=!0),o()}return e.push(a),s.push(u),o()}};class M{constructor(t,e={}){this.providers=e,this.breakpoints=[],this.actionsState={handlers:[],watchers:[]},this.switches={},this.changesets=[],this.subscriptions=[],this.customComponentHandler=new K,this.events=t.events.createChild(this);const s=new R(this.events,"root");s.name=`root-${t.name}`,this.nodes=new G(s,this.switches,this.events);const i=this.processNode=Z(this,c=>{const o=Array.from(c.keys());process.env.NODE_ENV!=="production"&&console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
|
|
2
|
+
${o.map(a=>`${a.name||"<no name>"} (${a.id})
|
|
3
|
+
`)}`),o.forEach(a=>{const u=c.get(a);a.parent&&a.parent.type==="root"&&this.events.dispatch("components:root-children-changed",{node:a}),u!=null&&u.context&&this.events.dispatch("components:context-changed",{node:a}),u!=null&&u.properties&&this.events.dispatch("components:properties-changed",{node:a}),u!=null&&u.layout&&this.events.dispatch("components:layout-changed",{node:a})}),this.events.dispatch("components:component-model-initialized",{},{bubbles:!0})});Promise.all(Object.keys(e).map(c=>e[c].load(this))),this.subscriptions.push(this.events.subscribe("components:node-appended",(c,o)=>{const{node:a}=o;this.changesets.forEach(u=>{const{changeset:h,target:r,removes:p}=u,[l,d]=h;r.match(o.node)&&(l.properties&&p.push(a.writeProperties(l.properties,d)),l.context&&p.push(a.writeContext(l.context,d)),l.layout&&p.push(a.writeLayout(l.layout,d)))})})),this.subscriptions.push(this.events.subscribe("components:node-appended",(c,o)=>{i(o.node,{properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:set-properties",(c,o)=>{i(o.node,{properties:!0})})),this.subscriptions.push(this.events.subscribe("components:set-context",(c,o)=>{i(o.node,{properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:set-indent",(c,o)=>{i(o.node,{layout:!0})})),this.subscriptions.push(this.events.subscribe("components:set-layout",(c,o)=>{i(o.node,{layout:!0})})),this.subscriptions.push(this.events.subscribe("components:node-switched",(c,{node:o,branch:a})=>{i(o,{layout:!0,recursive:!0,properties:!0,context:!0})})),this.subscriptions.push(this.events.subscribe("components:node-removed",(c,{parentNode:o})=>{i(o,{properties:!0})})),this.events.parent&&this.events.parent.dispatch("components:platform-created",{platform:this})}static getInstance(t){return t.getAsync("components")}addBreakpoint(t){this.breakpoints.indexOf(t)===-1&&(this.breakpoints.push(t),this.processNode(this.nodes.root,{context:!0,properties:!0,layout:!0,recursive:!0}))}removeBreakpoint(t){const e=this.breakpoints.indexOf(t);e>-1&&(this.breakpoints.splice(e,1),this.processNode(this.nodes.root,{context:!0,properties:!0,layout:!0,recursive:!0}))}setSwitch(t,e){this.switches[t.id]=e,this.events.dispatch("components:node-switched",{node:t,branch:e})}getBranch(t){return this.switches[t.id]}createNode(t,e={}){const s=new R(this.events,t);return e.detached&&this.nodes.detached.push(s),s}components(){return new E(this)}actions(t,e){return new O(this,t,e)}write(t){const{provider:e,target:s,attributes:i,options:c={},removable:o}=t,a=t.key||g.uuid(),h={changeset:[i,c],target:s,removes:[]};if(e){const r=this.providers[e];r.write(a,s,i,c),h.removes.push(()=>{r.remove(a)})}return this.changesets.push(h),this.nodes.all.forEach(r=>{if(s.match(r)){let p=()=>{};i.properties&&(p=r.writeProperties(i.properties,c,o)),i.context&&(p=r.writeContext(i.context,c,o)),i.layout&&(p=r.writeContext(i.layout,c,o)),h.removes.push(p)}}),()=>{if(o){h.removes.forEach(p=>p());const r=this.changesets.indexOf(h);r>-1&&this.changesets.splice(r,1)}}}addComponentHandler(t,e){this.customComponentHandler.add(t,e)}getComponentHandler(t){return this.customComponentHandler.get(t)}dispose(){this.subscriptions.forEach(t=>t())}}const tt=n=>{if(Array.isArray(n)){const[t,...e]=n;return{definitionId:t,overrides:e}}return{definitionId:n,overrides:[]}},w=(n,t,e,s,i,c)=>{e.forEach(o=>{const a=tt(o),u=s[a.definitionId];if(a.definitionId==="view"){const h=n.createNode("view");h.name="view",Object.keys(i).forEach(r=>{const p=i[r];w(n,h,[p.entry],s,i,r)}),t.appendChild(h),a.overrides.forEach(r=>{r.properties&&h.writeProperties(r.properties,{breakpoints:r.breakpoints}),r.context&&h.writeContext(r.context,{breakpoints:r.breakpoints}),r.layout&&h.writeLayout(r.layout,{breakpoints:r.breakpoints})})}else if(n.getComponentHandler(u.type)){const h=n.getComponentHandler(u.type);h&&h(a,{platform:n,node:t,references:e,definitions:s,views:i,branch:c})}else{const h=s[a.definitionId];if(process.env.NODE_ENV!=="production"&&!h){g.Logger.error(`No definition found for component type '${a.definitionId}'.`);return}const r=n.createNode(h.type);r.name=a.definitionId,r.tags=h.tags||[],h.properties&&r.writeProperties(h.properties),h.context&&r.writeContext(h.context),h.layout&&r.writeLayout(h.layout),t.appendChild(r,c),a.overrides.forEach(p=>{const l={breakpoints:p.breakpoints};p.properties&&r.writeProperties(p.properties,l),p.context&&r.writeContext(p.context,l),p.layout&&r.writeLayout(p.layout,l)}),h.children&&w(n,r,h.children,s,i)}})},et=(n,t)=>{const{entry:e,components:s,breakpoints:i,views:c}=t,o=[];return Object.keys(i).forEach(a=>{const u=i[a],h=window.matchMedia(u);h.matches&&n.breakpoints.push(a);const r=p=>{p.matches?n.addBreakpoint(a):n.removeBreakpoint(a)};h.addListener(r),o.push(()=>h.removeListener(r))}),w(n,n.nodes.root,[e],s,c),()=>o.forEach(a=>{a()})},st=(n,t)=>({id:n.id,type:n.type,name:n.name,branch:t||"default"}),nt=(n,t,e,s=g.uuid(),i={})=>n.getAsync("components").then(c=>{let o;if(typeof t=="string"){const h=new E(c);h.ofType(t),o=h}else o=t;const a={},u=h=>{const r=a[h.id];return r?Promise.resolve(r.controller):M.getInstance(n).then(p=>new A(p,h,s))};c.events.subscribe("components:node-enter",(h,{node:r})=>{o.match(r)&&u(r).then(p=>{Promise.resolve(e(p)).then(l=>{a[r.id]={dispose:l,controller:p}})})}),c.events.subscribe("components:node-exit",(h,{node:r})=>{const p=a[r.id];p&&(p.dispose&&p.dispose(),i.reuseController||(p.controller.dispose(),delete a[r.id]))})});class it{constructor(t){this.aliases=new Map,this.components=new Map,this.logger=new g.Logger;const{events:e}=t.get("$widget");this.events=e}getComponent(t){const e=this.aliases.get(t),s=this.components.get(e||t)||null;return process.env.NODE_ENV!=="production"&&(s||this.logger.warn(e||t,`Unable to resolve component: "${e||t}". You most likely forgot to register the required plugin for: ${e||t}.`)),s}registerComponent(t,e){return this.components.set(t,e),this.events.dispatch("component-resolver:resolve",t),()=>{this.components.delete(t)}}registerResolver(t,e){return this.events.subscribe("component-resolver:resolve",(s,i)=>{if(i===t){const c=this.getComponent(t);e(c)}})}registerAlias(t,e){return this.aliases.set(t,e),this.events.dispatch("component-resolver:resolve",t),()=>{this.aliases.delete(t)}}}const V="#____version____#",B=class j extends b.Environment{constructor(t,e=[]){super(t,e,{transformPluginSettings:(s,i,c)=>{const o=c.get("$settings");return{...o.plugins&&i?o.plugins[i]||{}:{},...s}}})}createImplementation(t){const e=super.createImplementation(t);return e.bindings=t.bindings,e}navigate(t,e,s){this.widgets.query(t).forEach(i=>i.invoke("navigate",{route:e,params:s}))}static create(t={}){const e=[$.ConfigurationApi].concat(t.configurationApiExtensions||[]);return new j("humany",e)}static createFromGlobal(t,e={}){if(this.isRuntime(t))return t.patch(e),t;const s=[],i=t&&t._c;i&&i.forEach(o=>s.push(o));const c=this.create(e);return c.container.register("$runtimecfg",s),c}static isRuntime(t){return!!(t&&typeof t=="object"&&t.container&&typeof t.container.get=="function"&&t.container.get("$environment")===t&&t.container.owner===t)}};B.version=`${V} (${b.version})`;let ot=B;class rt extends b.Implementation{constructor(){super(...arguments),this.bindings=[]}}class ct extends b.Plugin{constructor(t,e){super(t,e)}}var q=(n=>(n.open="open",n.closed="closed",n.hidden="hidden",n))(q||{});class ht extends b.WidgetType{constructor(t){super(t)}}exports.ActionResolver=Q;exports.ActionsController=O;exports.ComponentNode=R;exports.ComponentNodeController=A;exports.ComponentPlatform=M;exports.ComponentQuery=E;exports.ComponentResolver=it;exports.Environment=ot;exports.Implementation=rt;exports.Plugin=ct;exports.WidgetRenderState=q;exports.WidgetType=ht;exports.asDescriptor=st;exports.bootstrap=z;exports.componentConfigurationApi=F;exports.createChildren=w;exports.createComponentModel=et;exports.createEventSubscriber=L;exports.extendComponent=nt;exports.findComponent=H;exports.findVisibleComponents=C;exports.traverseComponents=N;exports.version=V;
|
package/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { bootstrapImplementation as
|
|
2
|
-
import { selectImplementations as
|
|
1
|
+
import { bootstrapImplementation as H, ConfigurationApi as B } from "@webprovisions/bootstrapping";
|
|
2
|
+
import { selectImplementations as M, createConfigurationApi as V, version as j, Environment as q, Implementation as z, Plugin as Q, WidgetType as F } from "@webprovisions/platform";
|
|
3
3
|
import { uuid as E, Logger as O } from "@telia-ace/widget-utilities";
|
|
4
4
|
class at {
|
|
5
5
|
constructor(t) {
|
|
@@ -16,19 +16,19 @@ class at {
|
|
|
16
16
|
subscribe(t, e) {
|
|
17
17
|
return this.events.subscribe(
|
|
18
18
|
"data:action",
|
|
19
|
-
(s, { action: i, value:
|
|
19
|
+
(s, { action: i, value: c, target: o }) => t === o && e(t, i, c)
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
const pt = (n, t, e = {}) =>
|
|
23
|
+
const pt = (n, t, e = {}) => H(
|
|
24
24
|
n,
|
|
25
25
|
n.bindings,
|
|
26
26
|
() => {
|
|
27
27
|
const s = n.container.get("$runtimecfg").map((i) => {
|
|
28
|
-
const
|
|
29
|
-
if (typeof
|
|
30
|
-
return
|
|
31
|
-
if (
|
|
28
|
+
const c = i[0];
|
|
29
|
+
if (typeof c == "function")
|
|
30
|
+
return c;
|
|
31
|
+
if (M(c)(n))
|
|
32
32
|
return i[1];
|
|
33
33
|
}).filter((i) => !!i);
|
|
34
34
|
return (t ? [t] : []).concat(
|
|
@@ -36,7 +36,7 @@ const pt = (n, t, e = {}) => L(
|
|
|
36
36
|
);
|
|
37
37
|
},
|
|
38
38
|
e.rootElementResolver || (() => document.body)
|
|
39
|
-
),
|
|
39
|
+
), G = (n) => {
|
|
40
40
|
const t = [];
|
|
41
41
|
return [
|
|
42
42
|
(s, i) => {
|
|
@@ -63,7 +63,7 @@ class N {
|
|
|
63
63
|
return this.rules.push({ id: t }), this;
|
|
64
64
|
}
|
|
65
65
|
select() {
|
|
66
|
-
return new
|
|
66
|
+
return new K(this.platform, this);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
class S {
|
|
@@ -73,10 +73,10 @@ class S {
|
|
|
73
73
|
new N(t).withId(e.id),
|
|
74
74
|
s
|
|
75
75
|
);
|
|
76
|
-
const [i,
|
|
76
|
+
const [i, c] = G(
|
|
77
77
|
this.platform.events
|
|
78
78
|
);
|
|
79
|
-
this.subscribe = i, this.unsubscribe =
|
|
79
|
+
this.subscribe = i, this.unsubscribe = c;
|
|
80
80
|
}
|
|
81
81
|
properties(t) {
|
|
82
82
|
return t && this.node.touchProperties((e) => t(e)), this.node.attributes.properties;
|
|
@@ -104,7 +104,7 @@ class S {
|
|
|
104
104
|
this.unsubscribe(), this.actions.dispose();
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
-
class
|
|
107
|
+
class K {
|
|
108
108
|
constructor(t, e, s = !0) {
|
|
109
109
|
this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new P(this.platform, this.target);
|
|
110
110
|
}
|
|
@@ -144,23 +144,23 @@ class G {
|
|
|
144
144
|
}), this.actions.dispose();
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
-
const
|
|
148
|
-
const s = n.concat(), i = (
|
|
147
|
+
const U = (n, t, e) => {
|
|
148
|
+
const s = n.concat(), i = (c, o, a) => {
|
|
149
149
|
let u = !0;
|
|
150
150
|
if (s.length) {
|
|
151
|
-
const h = s.shift(),
|
|
151
|
+
const h = s.shift(), r = (p, l) => (u = !1, i(
|
|
152
152
|
p,
|
|
153
|
-
Object.assign({},
|
|
153
|
+
Object.assign({}, o, l),
|
|
154
154
|
a
|
|
155
155
|
));
|
|
156
|
-
return Promise.resolve(h(
|
|
156
|
+
return Promise.resolve(h(c, r, a)).then(
|
|
157
157
|
(p) => ({
|
|
158
158
|
...p,
|
|
159
159
|
cancelled: u
|
|
160
160
|
})
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
|
-
return Promise.resolve({ data:
|
|
163
|
+
return Promise.resolve({ data: c, cancelled: !1, options: o });
|
|
164
164
|
};
|
|
165
165
|
return i(t, {}, e);
|
|
166
166
|
};
|
|
@@ -178,36 +178,36 @@ class P {
|
|
|
178
178
|
};
|
|
179
179
|
this.platform.actionsState.handlers.push(s);
|
|
180
180
|
const i = () => {
|
|
181
|
-
const
|
|
182
|
-
|
|
181
|
+
const c = this.platform.actionsState.handlers.indexOf(s);
|
|
182
|
+
c > -1 && this.platform.actionsState.handlers.splice(c, 1);
|
|
183
183
|
};
|
|
184
184
|
return this.subscriptions.push(i), i;
|
|
185
185
|
}
|
|
186
186
|
dispatch(t, e) {
|
|
187
187
|
const s = this.platform.nodes.all.concat(
|
|
188
188
|
this.platform.nodes.detached
|
|
189
|
-
), i = {},
|
|
190
|
-
(
|
|
189
|
+
), i = {}, c = this.platform.actionsState.handlers.filter(
|
|
190
|
+
(o) => o.key === t && (!o.ns || !this.ns || o.ns === this.ns)
|
|
191
191
|
);
|
|
192
192
|
return Promise.all(
|
|
193
|
-
|
|
193
|
+
c.map((o) => {
|
|
194
194
|
const a = s.filter(
|
|
195
|
-
(h) =>
|
|
195
|
+
(h) => o.target.match(h) && this.target.match(h)
|
|
196
196
|
), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some(
|
|
197
|
-
(
|
|
197
|
+
(r) => h.target.match(r)
|
|
198
198
|
)).map((h) => h.fn);
|
|
199
199
|
return Promise.all(
|
|
200
200
|
a.map((h) => {
|
|
201
|
-
const
|
|
201
|
+
const r = new S(
|
|
202
202
|
this.platform,
|
|
203
203
|
h,
|
|
204
204
|
this.ns
|
|
205
205
|
);
|
|
206
|
-
return
|
|
206
|
+
return U(u, e, r).then(
|
|
207
207
|
(p) => {
|
|
208
208
|
const { data: l = {}, options: d, cancelled: b } = p;
|
|
209
209
|
return Promise.resolve(
|
|
210
|
-
b ? {} :
|
|
210
|
+
b ? {} : o.fn(l, d, r)
|
|
211
211
|
).then((g) => {
|
|
212
212
|
i[h.id] = g;
|
|
213
213
|
});
|
|
@@ -220,17 +220,17 @@ class P {
|
|
|
220
220
|
}
|
|
221
221
|
watch(t, e) {
|
|
222
222
|
let s = t, i = this.ns;
|
|
223
|
-
const
|
|
224
|
-
|
|
225
|
-
const
|
|
223
|
+
const c = t.split(".");
|
|
224
|
+
c.length > 1 && (i = c[0], s = c.splice(1).join("."));
|
|
225
|
+
const o = {
|
|
226
226
|
fn: e,
|
|
227
227
|
target: this.target,
|
|
228
228
|
key: s,
|
|
229
229
|
ns: i
|
|
230
230
|
};
|
|
231
|
-
this.platform.actionsState.watchers.push(
|
|
231
|
+
this.platform.actionsState.watchers.push(o);
|
|
232
232
|
const a = () => {
|
|
233
|
-
const u = this.platform.actionsState.watchers.indexOf(
|
|
233
|
+
const u = this.platform.actionsState.watchers.indexOf(o);
|
|
234
234
|
u > -1 && this.platform.actionsState.watchers.splice(u, 1);
|
|
235
235
|
};
|
|
236
236
|
return this.subscriptions.push(a), a;
|
|
@@ -239,13 +239,13 @@ class P {
|
|
|
239
239
|
this.subscriptions.forEach((t) => t());
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
|
-
const ut =
|
|
242
|
+
const ut = V((n) => {
|
|
243
243
|
n.createCommand("components", (t) => (e) => {
|
|
244
244
|
t.events.subscribeOnce(
|
|
245
245
|
"components:platform-created",
|
|
246
246
|
(s, { platform: i }) => {
|
|
247
|
-
e.handlers && e.handlers.forEach(([
|
|
248
|
-
i.addComponentHandler(
|
|
247
|
+
e.handlers && e.handlers.forEach(([c, o]) => {
|
|
248
|
+
i.addComponentHandler(c, o);
|
|
249
249
|
});
|
|
250
250
|
}
|
|
251
251
|
);
|
|
@@ -287,46 +287,46 @@ class I {
|
|
|
287
287
|
t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].unshift(t), this.events.dispatch("components:node-appended", { node: t });
|
|
288
288
|
}
|
|
289
289
|
touchProperties(t, e = {}, s) {
|
|
290
|
-
const
|
|
291
|
-
return this.changesets.push(
|
|
290
|
+
const c = [{ properties: t }, e];
|
|
291
|
+
return this.changesets.push(c), this.events.dispatch("components:set-properties", { node: this }), () => {
|
|
292
292
|
if (s) {
|
|
293
|
-
const
|
|
294
|
-
|
|
293
|
+
const o = this.changesets.indexOf(c);
|
|
294
|
+
o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-properties", { node: this }));
|
|
295
295
|
}
|
|
296
296
|
};
|
|
297
297
|
}
|
|
298
298
|
writeProperties(t, e = {}, s) {
|
|
299
|
-
const
|
|
300
|
-
return this.changesets.push(
|
|
299
|
+
const c = [{ properties: t }, e];
|
|
300
|
+
return this.changesets.push(c), this.events.dispatch("components:set-properties", { node: this }), () => {
|
|
301
301
|
if (s) {
|
|
302
|
-
const
|
|
303
|
-
|
|
302
|
+
const o = this.changesets.indexOf(c);
|
|
303
|
+
o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-properties", { node: this }));
|
|
304
304
|
}
|
|
305
305
|
};
|
|
306
306
|
}
|
|
307
307
|
writeLayout(t, e = {}, s) {
|
|
308
|
-
const
|
|
309
|
-
return this.changesets.push(
|
|
308
|
+
const c = [{ layout: t }, e];
|
|
309
|
+
return this.changesets.push(c), this.events.dispatch("components:set-layout", { node: this }), () => {
|
|
310
310
|
if (!s)
|
|
311
311
|
return;
|
|
312
|
-
const
|
|
313
|
-
|
|
312
|
+
const o = this.changesets.indexOf(c);
|
|
313
|
+
o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-layout", { node: this }));
|
|
314
314
|
};
|
|
315
315
|
}
|
|
316
316
|
writeContext(t, e = {}, s) {
|
|
317
|
-
const
|
|
318
|
-
return this.changesets.push(
|
|
317
|
+
const c = [{ context: t }, e];
|
|
318
|
+
return this.changesets.push(c), this.events.dispatch("components:set-context", { node: this }), () => {
|
|
319
319
|
if (!s)
|
|
320
320
|
return;
|
|
321
|
-
const
|
|
322
|
-
|
|
321
|
+
const o = this.changesets.indexOf(c);
|
|
322
|
+
o > -1 && (this.changesets.splice(o, 1), this.events.dispatch("components:set-context", { node: this }));
|
|
323
323
|
};
|
|
324
324
|
}
|
|
325
325
|
getChildren(t = "default") {
|
|
326
326
|
const e = this.children[t] || [];
|
|
327
|
-
return e.reduce((s, i,
|
|
328
|
-
const { order:
|
|
329
|
-
return s[
|
|
327
|
+
return e.reduce((s, i, c) => {
|
|
328
|
+
const { order: o = c } = i.attributes.layout;
|
|
329
|
+
return s[o] ? s.splice(o, 0, i) : s[o] = i, s;
|
|
330
330
|
}, Array(e.length));
|
|
331
331
|
}
|
|
332
332
|
remove() {
|
|
@@ -344,8 +344,8 @@ class I {
|
|
|
344
344
|
}
|
|
345
345
|
const D = (n, t, e) => {
|
|
346
346
|
for (let s = 0, i = n.length; s < i && e(n[s]) !== !0; s++) {
|
|
347
|
-
const
|
|
348
|
-
D(
|
|
347
|
+
const c = t[n[s].id] || "default", o = n[s].getChildren(c);
|
|
348
|
+
D(o, t, e);
|
|
349
349
|
}
|
|
350
350
|
}, k = (n, t, e) => {
|
|
351
351
|
if (e(n) !== !0) {
|
|
@@ -357,29 +357,29 @@ const D = (n, t, e) => {
|
|
|
357
357
|
return k(n, t, (s) => {
|
|
358
358
|
e.push(s);
|
|
359
359
|
}), e;
|
|
360
|
-
},
|
|
360
|
+
}, W = (n, t, e) => {
|
|
361
361
|
let s;
|
|
362
362
|
return k(n, t, (i) => {
|
|
363
363
|
if (e(i))
|
|
364
364
|
return s = i, !0;
|
|
365
365
|
}), s;
|
|
366
366
|
};
|
|
367
|
-
class
|
|
367
|
+
class Y {
|
|
368
368
|
constructor(t, e, s) {
|
|
369
369
|
this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe(
|
|
370
370
|
"components:node-appended",
|
|
371
|
-
(i,
|
|
372
|
-
this.all.push(
|
|
371
|
+
(i, c) => {
|
|
372
|
+
this.all.push(c.node), this.visible = x(t, e);
|
|
373
373
|
}
|
|
374
374
|
), s.subscribe(
|
|
375
375
|
"components:node-removed",
|
|
376
|
-
(i,
|
|
377
|
-
let
|
|
378
|
-
|
|
376
|
+
(i, c) => {
|
|
377
|
+
let o = this.all.indexOf(c.node);
|
|
378
|
+
o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(c.node), o > -1 && this.visible.splice(o, 1), this.visible = x(t, e);
|
|
379
379
|
}
|
|
380
380
|
), s.subscribe(
|
|
381
381
|
"components:node-switched",
|
|
382
|
-
(i,
|
|
382
|
+
(i, c) => {
|
|
383
383
|
this.visible = x(t, e);
|
|
384
384
|
}
|
|
385
385
|
);
|
|
@@ -387,14 +387,14 @@ class W {
|
|
|
387
387
|
query(t = {}) {
|
|
388
388
|
const e = [];
|
|
389
389
|
return k(this.root, this.switches, (s) => {
|
|
390
|
-
Object.keys(t).every((
|
|
390
|
+
Object.keys(t).every((c) => t[c] === s[c]) && e.push(s);
|
|
391
391
|
}), e;
|
|
392
392
|
}
|
|
393
393
|
get(t) {
|
|
394
|
-
return
|
|
394
|
+
return W(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
|
|
395
395
|
}
|
|
396
396
|
}
|
|
397
|
-
class
|
|
397
|
+
class J {
|
|
398
398
|
constructor() {
|
|
399
399
|
this.handlers = /* @__PURE__ */ new Map();
|
|
400
400
|
}
|
|
@@ -405,13 +405,13 @@ class Y {
|
|
|
405
405
|
return this.handlers.get(t);
|
|
406
406
|
}
|
|
407
407
|
}
|
|
408
|
-
const
|
|
408
|
+
const X = (n) => {
|
|
409
409
|
let t = n, e = 0;
|
|
410
410
|
for (; t.parent; )
|
|
411
411
|
e = e + 1, t = t.parent;
|
|
412
412
|
return e;
|
|
413
|
-
},
|
|
414
|
-
([e, s]) => [
|
|
413
|
+
}, Z = (n) => n.map(
|
|
414
|
+
([e, s]) => [X(e), e, s]
|
|
415
415
|
).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), w = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), v = (n, ...t) => {
|
|
416
416
|
if (!t.length)
|
|
417
417
|
return n;
|
|
@@ -420,79 +420,79 @@ const J = (n) => {
|
|
|
420
420
|
for (const s in e)
|
|
421
421
|
w(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), v(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
|
|
422
422
|
return v(n, ...t);
|
|
423
|
-
},
|
|
423
|
+
}, tt = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), et = (n, t) => {
|
|
424
424
|
let e = [], s = [], i;
|
|
425
|
-
const
|
|
425
|
+
const c = () => {
|
|
426
426
|
process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
|
|
427
|
-
const a = /* @__PURE__ */ new Map(), u =
|
|
428
|
-
e.map((
|
|
429
|
-
), h = (
|
|
427
|
+
const a = /* @__PURE__ */ new Map(), u = Z(
|
|
428
|
+
e.map((r, p) => [r, s[p]])
|
|
429
|
+
), h = (r, p) => {
|
|
430
430
|
var T;
|
|
431
|
-
const l = a.get(
|
|
432
|
-
a.set(
|
|
431
|
+
const l = a.get(r) || {}, d = p.context && !l.context, b = p.properties && !l.properties, g = p.layout && !l.layout;
|
|
432
|
+
a.set(r, {
|
|
433
433
|
context: l.context || d,
|
|
434
434
|
properties: l.properties || b,
|
|
435
435
|
layout: l.layout || g
|
|
436
|
-
}), b && (
|
|
436
|
+
}), b && (r.attributes.properties = {}), g && (r.attributes.layout = {}), d && (r.attributes.context = v(
|
|
437
437
|
{},
|
|
438
|
-
(T =
|
|
438
|
+
(T = r.parent) == null ? void 0 : T.attributes.context
|
|
439
439
|
));
|
|
440
440
|
const $ = [], R = [], A = [];
|
|
441
|
-
if (
|
|
442
|
-
const [
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
) : v(
|
|
446
|
-
|
|
447
|
-
) : v(
|
|
448
|
-
}), $.forEach((
|
|
441
|
+
if (r.changesets.forEach((f) => {
|
|
442
|
+
const [m, y] = f;
|
|
443
|
+
tt(y.breakpoints, n.breakpoints) && (b && (typeof m.properties == "function" ? $.push(
|
|
444
|
+
m.properties
|
|
445
|
+
) : v(r.attributes.properties, m.properties)), g && (typeof m.layout == "function" ? R.push(m.layout) : v(r.attributes.layout, m.layout)), d && (typeof m.context == "function" ? A.push(
|
|
446
|
+
m.context
|
|
447
|
+
) : v(r.attributes.context, m.context)));
|
|
448
|
+
}), $.forEach((f) => {
|
|
449
449
|
v(
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
r.attributes.properties,
|
|
451
|
+
f(r.attributes.properties)
|
|
452
452
|
);
|
|
453
|
-
}), R.forEach((
|
|
454
|
-
v(
|
|
455
|
-
}), A.forEach((
|
|
456
|
-
v(
|
|
453
|
+
}), R.forEach((f) => {
|
|
454
|
+
v(r.attributes.layout, f(r.attributes.layout));
|
|
455
|
+
}), A.forEach((f) => {
|
|
456
|
+
v(r.attributes.context, f(r.attributes.context));
|
|
457
457
|
}), d || p.recursive) {
|
|
458
|
-
const
|
|
458
|
+
const f = n.getBranch(r), m = p.recursive ? p : {
|
|
459
459
|
context: !!d
|
|
460
460
|
};
|
|
461
|
-
|
|
462
|
-
h(y,
|
|
461
|
+
r.getChildren(f).forEach((y) => {
|
|
462
|
+
h(y, m);
|
|
463
463
|
});
|
|
464
464
|
}
|
|
465
465
|
};
|
|
466
|
-
process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), u.forEach(([
|
|
467
|
-
h(
|
|
466
|
+
process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), u.forEach(([r, p]) => {
|
|
467
|
+
h(r, p);
|
|
468
468
|
}), e = [], s = [], t(a);
|
|
469
|
-
},
|
|
470
|
-
clearTimeout(i), i = setTimeout(
|
|
469
|
+
}, o = () => {
|
|
470
|
+
clearTimeout(i), i = setTimeout(c, 0);
|
|
471
471
|
};
|
|
472
472
|
return (a, u) => {
|
|
473
473
|
const h = e.indexOf(a);
|
|
474
474
|
if (h > -1) {
|
|
475
|
-
const
|
|
476
|
-
return u.context && (
|
|
475
|
+
const r = s[h];
|
|
476
|
+
return u.context && (r.context = !0), u.properties && (r.properties = !0), u.layout && (r.layout = !0), u.recursive && (r.recursive = !0), o();
|
|
477
477
|
}
|
|
478
|
-
return e.push(a), s.push(u),
|
|
478
|
+
return e.push(a), s.push(u), o();
|
|
479
479
|
};
|
|
480
480
|
};
|
|
481
|
-
class
|
|
481
|
+
class st {
|
|
482
482
|
constructor(t, e = {}) {
|
|
483
|
-
this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new
|
|
483
|
+
this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new J(), this.events = t.events.createChild(this);
|
|
484
484
|
const s = new I(this.events, "root");
|
|
485
|
-
s.name = `root-${t.name}`, this.nodes = new
|
|
486
|
-
const i = this.processNode =
|
|
485
|
+
s.name = `root-${t.name}`, this.nodes = new Y(s, this.switches, this.events);
|
|
486
|
+
const i = this.processNode = et(
|
|
487
487
|
this,
|
|
488
|
-
(
|
|
489
|
-
const
|
|
490
|
-
process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${
|
|
491
|
-
${
|
|
488
|
+
(c) => {
|
|
489
|
+
const o = Array.from(c.keys());
|
|
490
|
+
process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
|
|
491
|
+
${o.map(
|
|
492
492
|
(a) => `${a.name || "<no name>"} (${a.id})
|
|
493
493
|
`
|
|
494
|
-
)}`),
|
|
495
|
-
const u =
|
|
494
|
+
)}`), o.forEach((a) => {
|
|
495
|
+
const u = c.get(a);
|
|
496
496
|
a.parent && a.parent.type === "root" && this.events.dispatch("components:root-children-changed", { node: a }), u != null && u.context && this.events.dispatch("components:context-changed", { node: a }), u != null && u.properties && this.events.dispatch("components:properties-changed", { node: a }), u != null && u.layout && this.events.dispatch("components:layout-changed", { node: a });
|
|
497
497
|
}), this.events.dispatch(
|
|
498
498
|
"components:component-model-initialized",
|
|
@@ -502,58 +502,58 @@ class et {
|
|
|
502
502
|
}
|
|
503
503
|
);
|
|
504
504
|
Promise.all(
|
|
505
|
-
Object.keys(e).map((
|
|
505
|
+
Object.keys(e).map((c) => e[c].load(this))
|
|
506
506
|
), this.subscriptions.push(
|
|
507
507
|
this.events.subscribe(
|
|
508
508
|
"components:node-appended",
|
|
509
|
-
(
|
|
510
|
-
const { node: a } =
|
|
509
|
+
(c, o) => {
|
|
510
|
+
const { node: a } = o;
|
|
511
511
|
this.changesets.forEach((u) => {
|
|
512
|
-
const { changeset: h, target:
|
|
513
|
-
|
|
512
|
+
const { changeset: h, target: r, removes: p } = u, [l, d] = h;
|
|
513
|
+
r.match(o.node) && (l.properties && p.push(a.writeProperties(l.properties, d)), l.context && p.push(a.writeContext(l.context, d)), l.layout && p.push(a.writeLayout(l.layout, d)));
|
|
514
514
|
});
|
|
515
515
|
}
|
|
516
516
|
)
|
|
517
517
|
), this.subscriptions.push(
|
|
518
518
|
this.events.subscribe(
|
|
519
519
|
"components:node-appended",
|
|
520
|
-
(
|
|
521
|
-
i(
|
|
520
|
+
(c, o) => {
|
|
521
|
+
i(o.node, { properties: !0, context: !0 });
|
|
522
522
|
}
|
|
523
523
|
)
|
|
524
524
|
), this.subscriptions.push(
|
|
525
525
|
this.events.subscribe(
|
|
526
526
|
"components:set-properties",
|
|
527
|
-
(
|
|
528
|
-
i(
|
|
527
|
+
(c, o) => {
|
|
528
|
+
i(o.node, { properties: !0 });
|
|
529
529
|
}
|
|
530
530
|
)
|
|
531
531
|
), this.subscriptions.push(
|
|
532
532
|
this.events.subscribe(
|
|
533
533
|
"components:set-context",
|
|
534
|
-
(
|
|
535
|
-
i(
|
|
534
|
+
(c, o) => {
|
|
535
|
+
i(o.node, { properties: !0, context: !0 });
|
|
536
536
|
}
|
|
537
537
|
)
|
|
538
538
|
), this.subscriptions.push(
|
|
539
539
|
this.events.subscribe(
|
|
540
540
|
"components:set-indent",
|
|
541
|
-
(
|
|
542
|
-
i(
|
|
541
|
+
(c, o) => {
|
|
542
|
+
i(o.node, { layout: !0 });
|
|
543
543
|
}
|
|
544
544
|
)
|
|
545
545
|
), this.subscriptions.push(
|
|
546
546
|
this.events.subscribe(
|
|
547
547
|
"components:set-layout",
|
|
548
|
-
(
|
|
549
|
-
i(
|
|
548
|
+
(c, o) => {
|
|
549
|
+
i(o.node, { layout: !0 });
|
|
550
550
|
}
|
|
551
551
|
)
|
|
552
552
|
), this.subscriptions.push(
|
|
553
553
|
this.events.subscribe(
|
|
554
554
|
"components:node-switched",
|
|
555
|
-
(
|
|
556
|
-
i(
|
|
555
|
+
(c, { node: o, branch: a }) => {
|
|
556
|
+
i(o, {
|
|
557
557
|
layout: !0,
|
|
558
558
|
recursive: !0,
|
|
559
559
|
properties: !0,
|
|
@@ -564,8 +564,8 @@ class et {
|
|
|
564
564
|
), this.subscriptions.push(
|
|
565
565
|
this.events.subscribe(
|
|
566
566
|
"components:node-removed",
|
|
567
|
-
(
|
|
568
|
-
i(
|
|
567
|
+
(c, { parentNode: o }) => {
|
|
568
|
+
i(o, { properties: !0 });
|
|
569
569
|
}
|
|
570
570
|
)
|
|
571
571
|
), this.events.parent && this.events.parent.dispatch("components:platform-created", {
|
|
@@ -617,30 +617,30 @@ class et {
|
|
|
617
617
|
provider: e,
|
|
618
618
|
target: s,
|
|
619
619
|
attributes: i,
|
|
620
|
-
options:
|
|
621
|
-
removable:
|
|
622
|
-
} = t, a = t.key || E(), h = { changeset: [i,
|
|
620
|
+
options: c = {},
|
|
621
|
+
removable: o
|
|
622
|
+
} = t, a = t.key || E(), h = { changeset: [i, c], target: s, removes: [] };
|
|
623
623
|
if (e) {
|
|
624
|
-
const
|
|
625
|
-
|
|
626
|
-
|
|
624
|
+
const r = this.providers[e];
|
|
625
|
+
r.write(a, s, i, c), h.removes.push(() => {
|
|
626
|
+
r.remove(a);
|
|
627
627
|
});
|
|
628
628
|
}
|
|
629
|
-
return this.changesets.push(h), this.nodes.all.forEach((
|
|
630
|
-
if (s.match(
|
|
629
|
+
return this.changesets.push(h), this.nodes.all.forEach((r) => {
|
|
630
|
+
if (s.match(r)) {
|
|
631
631
|
let p = () => {
|
|
632
632
|
};
|
|
633
|
-
i.properties && (p =
|
|
633
|
+
i.properties && (p = r.writeProperties(
|
|
634
634
|
i.properties,
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
)), i.context && (p =
|
|
635
|
+
c,
|
|
636
|
+
o
|
|
637
|
+
)), i.context && (p = r.writeContext(i.context, c, o)), i.layout && (p = r.writeContext(i.layout, c, o)), h.removes.push(p);
|
|
638
638
|
}
|
|
639
639
|
}), () => {
|
|
640
|
-
if (
|
|
640
|
+
if (o) {
|
|
641
641
|
h.removes.forEach((p) => p());
|
|
642
|
-
const
|
|
643
|
-
|
|
642
|
+
const r = this.changesets.indexOf(h);
|
|
643
|
+
r > -1 && this.changesets.splice(r, 1);
|
|
644
644
|
}
|
|
645
645
|
};
|
|
646
646
|
}
|
|
@@ -654,7 +654,7 @@ class et {
|
|
|
654
654
|
this.subscriptions.forEach((t) => t());
|
|
655
655
|
}
|
|
656
656
|
}
|
|
657
|
-
const
|
|
657
|
+
const nt = (n) => {
|
|
658
658
|
if (Array.isArray(n)) {
|
|
659
659
|
const [t, ...e] = n;
|
|
660
660
|
return {
|
|
@@ -666,28 +666,28 @@ const st = (n) => {
|
|
|
666
666
|
definitionId: n,
|
|
667
667
|
overrides: []
|
|
668
668
|
};
|
|
669
|
-
}, C = (n, t, e, s, i,
|
|
670
|
-
e.forEach((
|
|
671
|
-
const a =
|
|
669
|
+
}, C = (n, t, e, s, i, c) => {
|
|
670
|
+
e.forEach((o) => {
|
|
671
|
+
const a = nt(o), u = s[a.definitionId];
|
|
672
672
|
if (a.definitionId === "view") {
|
|
673
673
|
const h = n.createNode("view");
|
|
674
|
-
h.name = "view", Object.keys(i).forEach((
|
|
675
|
-
const p = i[
|
|
674
|
+
h.name = "view", Object.keys(i).forEach((r) => {
|
|
675
|
+
const p = i[r];
|
|
676
676
|
C(
|
|
677
677
|
n,
|
|
678
678
|
h,
|
|
679
679
|
[p.entry],
|
|
680
680
|
s,
|
|
681
681
|
i,
|
|
682
|
-
|
|
682
|
+
r
|
|
683
683
|
);
|
|
684
|
-
}), t.appendChild(h), a.overrides.forEach((
|
|
685
|
-
|
|
686
|
-
breakpoints:
|
|
687
|
-
}),
|
|
688
|
-
breakpoints:
|
|
689
|
-
}),
|
|
690
|
-
breakpoints:
|
|
684
|
+
}), t.appendChild(h), a.overrides.forEach((r) => {
|
|
685
|
+
r.properties && h.writeProperties(r.properties, {
|
|
686
|
+
breakpoints: r.breakpoints
|
|
687
|
+
}), r.context && h.writeContext(r.context, {
|
|
688
|
+
breakpoints: r.breakpoints
|
|
689
|
+
}), r.layout && h.writeLayout(r.layout, {
|
|
690
|
+
breakpoints: r.breakpoints
|
|
691
691
|
});
|
|
692
692
|
});
|
|
693
693
|
} else if (n.getComponentHandler(u.type)) {
|
|
@@ -698,7 +698,7 @@ const st = (n) => {
|
|
|
698
698
|
references: e,
|
|
699
699
|
definitions: s,
|
|
700
700
|
views: i,
|
|
701
|
-
branch:
|
|
701
|
+
branch: c
|
|
702
702
|
});
|
|
703
703
|
} else {
|
|
704
704
|
const h = s[a.definitionId];
|
|
@@ -708,13 +708,13 @@ const st = (n) => {
|
|
|
708
708
|
);
|
|
709
709
|
return;
|
|
710
710
|
}
|
|
711
|
-
const
|
|
712
|
-
|
|
711
|
+
const r = n.createNode(h.type);
|
|
712
|
+
r.name = a.definitionId, r.tags = h.tags || [], h.properties && r.writeProperties(h.properties), h.context && r.writeContext(h.context), h.layout && r.writeLayout(h.layout), t.appendChild(r, c), a.overrides.forEach((p) => {
|
|
713
713
|
const l = { breakpoints: p.breakpoints };
|
|
714
|
-
p.properties &&
|
|
714
|
+
p.properties && r.writeProperties(p.properties, l), p.context && r.writeContext(p.context, l), p.layout && r.writeLayout(p.layout, l);
|
|
715
715
|
}), h.children && C(
|
|
716
716
|
n,
|
|
717
|
-
|
|
717
|
+
r,
|
|
718
718
|
h.children,
|
|
719
719
|
s,
|
|
720
720
|
i
|
|
@@ -722,15 +722,15 @@ const st = (n) => {
|
|
|
722
722
|
}
|
|
723
723
|
});
|
|
724
724
|
}, lt = (n, t) => {
|
|
725
|
-
const { entry: e, components: s, breakpoints: i, views:
|
|
725
|
+
const { entry: e, components: s, breakpoints: i, views: c } = t, o = [];
|
|
726
726
|
return Object.keys(i).forEach((a) => {
|
|
727
727
|
const u = i[a], h = window.matchMedia(u);
|
|
728
728
|
h.matches && n.breakpoints.push(a);
|
|
729
|
-
const
|
|
729
|
+
const r = (p) => {
|
|
730
730
|
p.matches ? n.addBreakpoint(a) : n.removeBreakpoint(a);
|
|
731
731
|
};
|
|
732
|
-
h.addListener(
|
|
733
|
-
}), C(n, n.nodes.root, [e], s,
|
|
732
|
+
h.addListener(r), o.push(() => h.removeListener(r));
|
|
733
|
+
}), C(n, n.nodes.root, [e], s, c), () => o.forEach((a) => {
|
|
734
734
|
a();
|
|
735
735
|
});
|
|
736
736
|
}, dt = (n, t) => ({
|
|
@@ -738,38 +738,38 @@ const st = (n) => {
|
|
|
738
738
|
type: n.type,
|
|
739
739
|
name: n.name,
|
|
740
740
|
branch: t || "default"
|
|
741
|
-
}),
|
|
742
|
-
let
|
|
741
|
+
}), mt = (n, t, e, s = E(), i = {}) => n.getAsync("components").then((c) => {
|
|
742
|
+
let o;
|
|
743
743
|
if (typeof t == "string") {
|
|
744
|
-
const h = new N(
|
|
745
|
-
h.ofType(t),
|
|
744
|
+
const h = new N(c);
|
|
745
|
+
h.ofType(t), o = h;
|
|
746
746
|
} else
|
|
747
|
-
|
|
747
|
+
o = t;
|
|
748
748
|
const a = {}, u = (h) => {
|
|
749
|
-
const
|
|
750
|
-
return
|
|
749
|
+
const r = a[h.id];
|
|
750
|
+
return r ? Promise.resolve(r.controller) : st.getInstance(n).then((p) => new S(p, h, s));
|
|
751
751
|
};
|
|
752
|
-
|
|
752
|
+
c.events.subscribe(
|
|
753
753
|
"components:node-enter",
|
|
754
|
-
(h, { node:
|
|
755
|
-
|
|
754
|
+
(h, { node: r }) => {
|
|
755
|
+
o.match(r) && u(r).then((p) => {
|
|
756
756
|
Promise.resolve(e(p)).then((l) => {
|
|
757
|
-
a[
|
|
757
|
+
a[r.id] = {
|
|
758
758
|
dispose: l,
|
|
759
759
|
controller: p
|
|
760
760
|
};
|
|
761
761
|
});
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
|
-
),
|
|
764
|
+
), c.events.subscribe(
|
|
765
765
|
"components:node-exit",
|
|
766
|
-
(h, { node:
|
|
767
|
-
const p = a[
|
|
768
|
-
p && (p.dispose && p.dispose(), i.reuseController || (p.controller.dispose(), delete a[
|
|
766
|
+
(h, { node: r }) => {
|
|
767
|
+
const p = a[r.id];
|
|
768
|
+
p && (p.dispose && p.dispose(), i.reuseController || (p.controller.dispose(), delete a[r.id]));
|
|
769
769
|
}
|
|
770
770
|
);
|
|
771
771
|
});
|
|
772
|
-
class
|
|
772
|
+
class ft {
|
|
773
773
|
constructor(t) {
|
|
774
774
|
this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new O();
|
|
775
775
|
const { events: e } = t.get("$widget");
|
|
@@ -792,8 +792,8 @@ class mt {
|
|
|
792
792
|
"component-resolver:resolve",
|
|
793
793
|
(s, i) => {
|
|
794
794
|
if (i === t) {
|
|
795
|
-
const
|
|
796
|
-
e(
|
|
795
|
+
const c = this.getComponent(t);
|
|
796
|
+
e(c);
|
|
797
797
|
}
|
|
798
798
|
}
|
|
799
799
|
);
|
|
@@ -804,21 +804,21 @@ class mt {
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
|
-
const
|
|
808
|
-
constructor(
|
|
809
|
-
super(
|
|
810
|
-
transformPluginSettings: (
|
|
811
|
-
const
|
|
807
|
+
const it = "#____version____#", _ = class L extends q {
|
|
808
|
+
constructor(t, e = []) {
|
|
809
|
+
super(t, e, {
|
|
810
|
+
transformPluginSettings: (s, i, c) => {
|
|
811
|
+
const o = c.get("$settings");
|
|
812
812
|
return {
|
|
813
|
-
...
|
|
814
|
-
...
|
|
813
|
+
...o.plugins && i ? o.plugins[i] || {} : {},
|
|
814
|
+
...s
|
|
815
815
|
};
|
|
816
816
|
}
|
|
817
817
|
});
|
|
818
818
|
}
|
|
819
|
-
createImplementation(
|
|
820
|
-
const
|
|
821
|
-
return
|
|
819
|
+
createImplementation(t) {
|
|
820
|
+
const e = super.createImplementation(t);
|
|
821
|
+
return e.bindings = t.bindings, e;
|
|
822
822
|
}
|
|
823
823
|
/**
|
|
824
824
|
* Performs navigation for widgets matching the specified selector by invoking a
|
|
@@ -827,18 +827,18 @@ const nt = "#____version____#", _ = class extends j {
|
|
|
827
827
|
* @param route Route name.
|
|
828
828
|
* @param params Route params.
|
|
829
829
|
*/
|
|
830
|
-
navigate(
|
|
831
|
-
this.widgets.query(
|
|
830
|
+
navigate(t, e, s) {
|
|
831
|
+
this.widgets.query(t).forEach((i) => i.invoke("navigate", { route: e, params: s }));
|
|
832
832
|
}
|
|
833
833
|
/**
|
|
834
834
|
* Creates a runtime based on provided configuration.
|
|
835
835
|
* @param configuration Runtime configuration.
|
|
836
836
|
*/
|
|
837
|
-
static create(
|
|
838
|
-
const
|
|
839
|
-
|
|
837
|
+
static create(t = {}) {
|
|
838
|
+
const e = [B].concat(
|
|
839
|
+
t.configurationApiExtensions || []
|
|
840
840
|
);
|
|
841
|
-
return new
|
|
841
|
+
return new L("humany", e);
|
|
842
842
|
}
|
|
843
843
|
/**
|
|
844
844
|
* Creates a widget runtime based on provided configuration and retains configuration handlers
|
|
@@ -847,38 +847,38 @@ const nt = "#____version____#", _ = class extends j {
|
|
|
847
847
|
* @param configuration Runtime configuration.
|
|
848
848
|
* @param global Object to read configuration handlers from (default: window).
|
|
849
849
|
*/
|
|
850
|
-
static createFromGlobal(
|
|
851
|
-
if (this.isRuntime(
|
|
852
|
-
return
|
|
853
|
-
const
|
|
854
|
-
|
|
855
|
-
(
|
|
850
|
+
static createFromGlobal(t, e = {}) {
|
|
851
|
+
if (this.isRuntime(t))
|
|
852
|
+
return t.patch(e), t;
|
|
853
|
+
const s = [], i = t && t._c;
|
|
854
|
+
i && i.forEach(
|
|
855
|
+
(o) => s.push(o)
|
|
856
856
|
);
|
|
857
|
-
const
|
|
858
|
-
return
|
|
857
|
+
const c = this.create(e);
|
|
858
|
+
return c.container.register("$runtimecfg", s), c;
|
|
859
859
|
}
|
|
860
860
|
/**
|
|
861
861
|
* Determines whether the specified object is a valid widget runtime.
|
|
862
862
|
* @param obj Object to compare.
|
|
863
863
|
*/
|
|
864
|
-
static isRuntime(
|
|
865
|
-
return !!(
|
|
864
|
+
static isRuntime(t) {
|
|
865
|
+
return !!(t && typeof t == "object" && t.container && typeof t.container.get == "function" && t.container.get("$environment") === t && t.container.owner === t);
|
|
866
866
|
}
|
|
867
867
|
};
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
class
|
|
868
|
+
_.version = `${it} (${j})`;
|
|
869
|
+
let vt = _;
|
|
870
|
+
class bt extends z {
|
|
871
871
|
constructor() {
|
|
872
872
|
super(...arguments), this.bindings = [];
|
|
873
873
|
}
|
|
874
874
|
}
|
|
875
|
-
class
|
|
875
|
+
class gt extends Q {
|
|
876
876
|
constructor(t, e) {
|
|
877
877
|
super(t, e);
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
var ot = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(ot || {});
|
|
881
|
-
class
|
|
881
|
+
class yt extends F {
|
|
882
882
|
constructor(t) {
|
|
883
883
|
super(t);
|
|
884
884
|
}
|
|
@@ -888,23 +888,23 @@ export {
|
|
|
888
888
|
P as ActionsController,
|
|
889
889
|
I as ComponentNode,
|
|
890
890
|
S as ComponentNodeController,
|
|
891
|
-
|
|
891
|
+
st as ComponentPlatform,
|
|
892
892
|
N as ComponentQuery,
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
893
|
+
ft as ComponentResolver,
|
|
894
|
+
vt as Environment,
|
|
895
|
+
bt as Implementation,
|
|
896
|
+
gt as Plugin,
|
|
897
897
|
ot as WidgetRenderState,
|
|
898
|
-
|
|
898
|
+
yt as WidgetType,
|
|
899
899
|
dt as asDescriptor,
|
|
900
900
|
pt as bootstrap,
|
|
901
901
|
ut as componentConfigurationApi,
|
|
902
902
|
C as createChildren,
|
|
903
903
|
lt as createComponentModel,
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
904
|
+
G as createEventSubscriber,
|
|
905
|
+
mt as extendComponent,
|
|
906
|
+
W as findComponent,
|
|
907
907
|
x as findVisibleComponents,
|
|
908
908
|
k as traverseComponents,
|
|
909
|
-
|
|
909
|
+
it as version
|
|
910
910
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@telia-ace/widget-core",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.32",
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"@webprovisions/platform": "^1.1.4",
|
|
6
6
|
"@webprovisions/bootstrapping": "^1.0.14",
|
|
7
|
-
"@telia-ace/widget-utilities": "^1.3.
|
|
7
|
+
"@telia-ace/widget-utilities": "^1.3.32"
|
|
8
8
|
},
|
|
9
9
|
"main": "./index.js",
|
|
10
10
|
"module": "./index.mjs",
|
package/plugin.d.ts
CHANGED
package/types/configuration.d.ts
CHANGED
package/widget-type.d.ts
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { ChangesetOptions, ComponentNodeSettings } from './component-node';
|
|
2
|
-
import { ComponentPlatform } from './component-platform';
|
|
3
|
-
import { ComponentQuery } from './component-query';
|
|
4
|
-
export interface ChangesetProvider {
|
|
5
|
-
write: (key: string, target: ComponentQuery, attributes: Partial<ComponentNodeSettings>, options: ChangesetOptions) => void;
|
|
6
|
-
remove: (key: string) => void;
|
|
7
|
-
load: (platform: ComponentPlatform) => Promise<any>;
|
|
8
|
-
}
|