@telia-ace/widget-core 1.3.41-rc.1 → 1.3.41

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.
Files changed (3) hide show
  1. package/index.js +2 -2
  2. package/index.mjs +81 -82
  3. package/package.json +2 -2
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: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:
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _=require("@webprovisions/bootstrapping"),v=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(v.selectImplementations(c)(n))return i[1]}).filter(i=>!!i);return(t?[t]:[]).concat(s)},e.rootElementResolver||(()=>document.body)),H=n=>{const t=[];return[(s,i)=>{t.push(n.subscribe(s,i))},()=>{t.forEach(s=>{s()})}]};class O{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 T{constructor(t,e,s){this.platform=t,this.node=e,this.actions=new N(t,new O(t).withId(e.id),s);const[i,c]=H(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 N(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 N{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 T(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=v.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 A{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 M=(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);M(o,t,e)}},P=(n,t,e)=>{if(e(n)!==!0){const s=t[n.id]||"default",i=n.children[s];M(i,t,e)}},C=(n,t)=>{const e=[];return P(n,t,s=>{e.push(s)}),e},V=(n,t,e)=>{let s;return P(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 P(this.root,this.switches,s=>{Object.keys(t).every(c=>t[c]===s[c])&&e.push(s)}),e}get(t){return V(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]),R=n=>n instanceof Date?!1:n&&typeof n=="object"&&!Array.isArray(n),b=(n,...t)=>{if(!t.length)return n;const e=t.shift();if(R(n)&&R(e))for(const s in e)R(e[s])?(n[s]||Object.assign(n,{[s]:{}}),b(n[s],e[s])):Object.assign(n,{[s]:e[s]});return b(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 L;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=b({},(L=r.parent)==null?void 0:L.attributes.context));const D=[],I=[],$=[];if(r.changesets.forEach(f=>{const[m,k]=f;X(k.breakpoints,n.breakpoints)&&(y&&(typeof m.properties=="function"?D.push(m.properties):b(r.attributes.properties,m.properties)),x&&(typeof m.layout=="function"?I.push(m.layout):b(r.attributes.layout,m.layout)),d&&(typeof m.context=="function"?$.push(m.context):b(r.attributes.context,m.context)))}),D.forEach(f=>{b(r.attributes.properties,f(r.attributes.properties))}),I.forEach(f=>{b(r.attributes.layout,f(r.attributes.layout))}),$.forEach(f=>{b(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(k=>{h(k,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 B{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 A(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
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;
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 A(this.events,t);return e.detached&&this.nodes.detached.push(s),s}components(){return new O(this)}actions(t,e){return new N(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 O(c);h.ofType(t),o=h}else o=t;const a={},u=h=>{const r=a[h.id];return r?Promise.resolve(r.controller):B.getInstance(n).then(p=>new T(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 j="#____version____#",E=class E extends v.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 E("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)}};E.version=`${j} (${v.version})`;let S=E;class ot extends v.Implementation{constructor(){super(...arguments),this.bindings=[]}}class rt extends v.Plugin{constructor(t,e){super(t,e)}}var q=(n=>(n.open="open",n.closed="closed",n.hidden="hidden",n))(q||{});class ct extends v.WidgetType{constructor(t){super(t)}}exports.ActionResolver=Q;exports.ActionsController=N;exports.ComponentNode=A;exports.ComponentNodeController=T;exports.ComponentPlatform=B;exports.ComponentQuery=O;exports.ComponentResolver=it;exports.Environment=S;exports.Implementation=ot;exports.Plugin=rt;exports.WidgetRenderState=q;exports.WidgetType=ct;exports.asDescriptor=st;exports.bootstrap=z;exports.componentConfigurationApi=F;exports.createChildren=w;exports.createComponentModel=et;exports.createEventSubscriber=H;exports.extendComponent=nt;exports.findComponent=V;exports.findVisibleComponents=C;exports.traverseComponents=P;exports.version=j;
package/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
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
- import { uuid as E, Logger as O } from "@telia-ace/widget-utilities";
2
+ import { selectImplementations as M, createConfigurationApi as V, Environment as j, version as q, Implementation as z, Plugin as Q, WidgetType as F } from "@webprovisions/platform";
3
+ import { uuid as O, Logger as N } from "@telia-ace/widget-utilities";
4
4
  class at {
5
5
  constructor(t) {
6
6
  const { events: e } = t.get("$widget");
@@ -49,7 +49,7 @@ const pt = (n, t, e = {}) => H(
49
49
  }
50
50
  ];
51
51
  };
52
- class N {
52
+ class P {
53
53
  constructor(t, e = []) {
54
54
  this.platform = t, this.rules = e;
55
55
  }
@@ -66,11 +66,11 @@ class N {
66
66
  return new K(this.platform, this);
67
67
  }
68
68
  }
69
- class S {
69
+ class L {
70
70
  constructor(t, e, s) {
71
- this.platform = t, this.node = e, this.actions = new P(
71
+ this.platform = t, this.node = e, this.actions = new k(
72
72
  t,
73
- new N(t).withId(e.id),
73
+ new P(t).withId(e.id),
74
74
  s
75
75
  );
76
76
  const [i, c] = G(
@@ -106,7 +106,7 @@ class S {
106
106
  }
107
107
  class K {
108
108
  constructor(t, e, s = !0) {
109
- this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new P(this.platform, this.target);
109
+ this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new k(this.platform, this.target);
110
110
  }
111
111
  writeProperties(t, e) {
112
112
  this.removes.push(
@@ -164,7 +164,7 @@ const U = (n, t, e) => {
164
164
  };
165
165
  return i(t, {}, e);
166
166
  };
167
- class P {
167
+ class k {
168
168
  constructor(t, e, s) {
169
169
  this.platform = t, this.target = e, this.ns = s, this.subscriptions = [], this.create = this.create.bind(this);
170
170
  }
@@ -198,7 +198,7 @@ class P {
198
198
  )).map((h) => h.fn);
199
199
  return Promise.all(
200
200
  a.map((h) => {
201
- const r = new S(
201
+ const r = new L(
202
202
  this.platform,
203
203
  h,
204
204
  this.ns
@@ -251,9 +251,9 @@ const ut = V((n) => {
251
251
  );
252
252
  });
253
253
  });
254
- class I {
254
+ class S {
255
255
  constructor(t, e) {
256
- this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = E(), this.type = e, this.attributes = {
256
+ this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = O(), this.type = e, this.attributes = {
257
257
  context: {},
258
258
  properties: {},
259
259
  layout: {},
@@ -262,7 +262,7 @@ class I {
262
262
  }
263
263
  mount(t, e) {
264
264
  let s = t.get("mounted-nodes");
265
- return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && O.error(
265
+ return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && N.error(
266
266
  "Trying to mount an already mounted component node.",
267
267
  this
268
268
  ), () => {
@@ -342,24 +342,24 @@ class I {
342
342
  }), delete t.parent;
343
343
  }
344
344
  }
345
- const D = (n, t, e) => {
345
+ const _ = (n, t, e) => {
346
346
  for (let s = 0, i = n.length; s < i && e(n[s]) !== !0; s++) {
347
347
  const c = t[n[s].id] || "default", o = n[s].getChildren(c);
348
- D(o, t, e);
348
+ _(o, t, e);
349
349
  }
350
- }, k = (n, t, e) => {
350
+ }, $ = (n, t, e) => {
351
351
  if (e(n) !== !0) {
352
352
  const s = t[n.id] || "default", i = n.children[s];
353
- D(i, t, e);
353
+ _(i, t, e);
354
354
  }
355
- }, x = (n, t) => {
355
+ }, w = (n, t) => {
356
356
  const e = [];
357
- return k(n, t, (s) => {
357
+ return $(n, t, (s) => {
358
358
  e.push(s);
359
359
  }), e;
360
360
  }, W = (n, t, e) => {
361
361
  let s;
362
- return k(n, t, (i) => {
362
+ return $(n, t, (i) => {
363
363
  if (e(i))
364
364
  return s = i, !0;
365
365
  }), s;
@@ -369,24 +369,24 @@ class Y {
369
369
  this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe(
370
370
  "components:node-appended",
371
371
  (i, c) => {
372
- this.all.push(c.node), this.visible = x(t, e);
372
+ this.all.push(c.node), this.visible = w(t, e);
373
373
  }
374
374
  ), s.subscribe(
375
375
  "components:node-removed",
376
376
  (i, c) => {
377
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);
378
+ o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(c.node), o > -1 && this.visible.splice(o, 1), this.visible = w(t, e);
379
379
  }
380
380
  ), s.subscribe(
381
381
  "components:node-switched",
382
382
  (i, c) => {
383
- this.visible = x(t, e);
383
+ this.visible = w(t, e);
384
384
  }
385
385
  );
386
386
  }
387
387
  query(t = {}) {
388
388
  const e = [];
389
- return k(this.root, this.switches, (s) => {
389
+ return $(this.root, this.switches, (s) => {
390
390
  Object.keys(t).every((c) => t[c] === s[c]) && e.push(s);
391
391
  }), e;
392
392
  }
@@ -412,13 +412,12 @@ const X = (n) => {
412
412
  return e;
413
413
  }, Z = (n) => n.map(
414
414
  ([e, s]) => [X(e), e, s]
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
- if (!t.length)
417
- return n;
415
+ ).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), C = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), v = (n, ...t) => {
416
+ if (!t.length) return n;
418
417
  const e = t.shift();
419
- if (w(n) && w(e))
418
+ if (C(n) && C(e))
420
419
  for (const s in e)
421
- w(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), v(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
420
+ C(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), v(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
422
421
  return v(n, ...t);
423
422
  }, tt = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), et = (n, t) => {
424
423
  let e = [], s = [], i;
@@ -427,7 +426,7 @@ const X = (n) => {
427
426
  const a = /* @__PURE__ */ new Map(), u = Z(
428
427
  e.map((r, p) => [r, s[p]])
429
428
  ), h = (r, p) => {
430
- var T;
429
+ var I;
431
430
  const l = a.get(r) || {}, d = p.context && !l.context, b = p.properties && !l.properties, g = p.layout && !l.layout;
432
431
  a.set(r, {
433
432
  context: l.context || d,
@@ -435,31 +434,31 @@ const X = (n) => {
435
434
  layout: l.layout || g
436
435
  }), b && (r.attributes.properties = {}), g && (r.attributes.layout = {}), d && (r.attributes.context = v(
437
436
  {},
438
- (T = r.parent) == null ? void 0 : T.attributes.context
437
+ (I = r.parent) == null ? void 0 : I.attributes.context
439
438
  ));
440
- const $ = [], R = [], A = [];
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) => {
439
+ const R = [], A = [], T = [];
440
+ if (r.changesets.forEach((m) => {
441
+ const [f, x] = m;
442
+ tt(x.breakpoints, n.breakpoints) && (b && (typeof f.properties == "function" ? R.push(
443
+ f.properties
444
+ ) : v(r.attributes.properties, f.properties)), g && (typeof f.layout == "function" ? A.push(f.layout) : v(r.attributes.layout, f.layout)), d && (typeof f.context == "function" ? T.push(
445
+ f.context
446
+ ) : v(r.attributes.context, f.context)));
447
+ }), R.forEach((m) => {
449
448
  v(
450
449
  r.attributes.properties,
451
- f(r.attributes.properties)
450
+ m(r.attributes.properties)
452
451
  );
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));
452
+ }), A.forEach((m) => {
453
+ v(r.attributes.layout, m(r.attributes.layout));
454
+ }), T.forEach((m) => {
455
+ v(r.attributes.context, m(r.attributes.context));
457
456
  }), d || p.recursive) {
458
- const f = n.getBranch(r), m = p.recursive ? p : {
457
+ const m = n.getBranch(r), f = p.recursive ? p : {
459
458
  context: !!d
460
459
  };
461
- r.getChildren(f).forEach((y) => {
462
- h(y, m);
460
+ r.getChildren(m).forEach((x) => {
461
+ h(x, f);
463
462
  });
464
463
  }
465
464
  };
@@ -481,7 +480,7 @@ const X = (n) => {
481
480
  class st {
482
481
  constructor(t, e = {}) {
483
482
  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
- const s = new I(this.events, "root");
483
+ const s = new S(this.events, "root");
485
484
  s.name = `root-${t.name}`, this.nodes = new Y(s, this.switches, this.events);
486
485
  const i = this.processNode = et(
487
486
  this,
@@ -603,14 +602,14 @@ class st {
603
602
  * @param type Type of node.
604
603
  */
605
604
  createNode(t, e = {}) {
606
- const s = new I(this.events, t);
605
+ const s = new S(this.events, t);
607
606
  return e.detached && this.nodes.detached.push(s), s;
608
607
  }
609
608
  components() {
610
- return new N(this);
609
+ return new P(this);
611
610
  }
612
611
  actions(t, e) {
613
- return new P(this, t, e);
612
+ return new k(this, t, e);
614
613
  }
615
614
  write(t) {
616
615
  const {
@@ -619,7 +618,7 @@ class st {
619
618
  attributes: i,
620
619
  options: c = {},
621
620
  removable: o
622
- } = t, a = t.key || E(), h = { changeset: [i, c], target: s, removes: [] };
621
+ } = t, a = t.key || O(), h = { changeset: [i, c], target: s, removes: [] };
623
622
  if (e) {
624
623
  const r = this.providers[e];
625
624
  r.write(a, s, i, c), h.removes.push(() => {
@@ -666,14 +665,14 @@ const nt = (n) => {
666
665
  definitionId: n,
667
666
  overrides: []
668
667
  };
669
- }, C = (n, t, e, s, i, c) => {
668
+ }, E = (n, t, e, s, i, c) => {
670
669
  e.forEach((o) => {
671
670
  const a = nt(o), u = s[a.definitionId];
672
671
  if (a.definitionId === "view") {
673
672
  const h = n.createNode("view");
674
673
  h.name = "view", Object.keys(i).forEach((r) => {
675
674
  const p = i[r];
676
- C(
675
+ E(
677
676
  n,
678
677
  h,
679
678
  [p.entry],
@@ -703,7 +702,7 @@ const nt = (n) => {
703
702
  } else {
704
703
  const h = s[a.definitionId];
705
704
  if (process.env.NODE_ENV !== "production" && !h) {
706
- O.error(
705
+ N.error(
707
706
  `No definition found for component type '${a.definitionId}'.`
708
707
  );
709
708
  return;
@@ -712,7 +711,7 @@ const nt = (n) => {
712
711
  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
712
  const l = { breakpoints: p.breakpoints };
714
713
  p.properties && r.writeProperties(p.properties, l), p.context && r.writeContext(p.context, l), p.layout && r.writeLayout(p.layout, l);
715
- }), h.children && C(
714
+ }), h.children && E(
716
715
  n,
717
716
  r,
718
717
  h.children,
@@ -730,7 +729,7 @@ const nt = (n) => {
730
729
  p.matches ? n.addBreakpoint(a) : n.removeBreakpoint(a);
731
730
  };
732
731
  h.addListener(r), o.push(() => h.removeListener(r));
733
- }), C(n, n.nodes.root, [e], s, c), () => o.forEach((a) => {
732
+ }), E(n, n.nodes.root, [e], s, c), () => o.forEach((a) => {
734
733
  a();
735
734
  });
736
735
  }, dt = (n, t) => ({
@@ -738,16 +737,16 @@ const nt = (n) => {
738
737
  type: n.type,
739
738
  name: n.name,
740
739
  branch: t || "default"
741
- }), mt = (n, t, e, s = E(), i = {}) => n.getAsync("components").then((c) => {
740
+ }), ft = (n, t, e, s = O(), i = {}) => n.getAsync("components").then((c) => {
742
741
  let o;
743
742
  if (typeof t == "string") {
744
- const h = new N(c);
743
+ const h = new P(c);
745
744
  h.ofType(t), o = h;
746
745
  } else
747
746
  o = t;
748
747
  const a = {}, u = (h) => {
749
748
  const r = a[h.id];
750
- return r ? Promise.resolve(r.controller) : st.getInstance(n).then((p) => new S(p, h, s));
749
+ return r ? Promise.resolve(r.controller) : st.getInstance(n).then((p) => new L(p, h, s));
751
750
  };
752
751
  c.events.subscribe(
753
752
  "components:node-enter",
@@ -769,9 +768,9 @@ const nt = (n) => {
769
768
  }
770
769
  );
771
770
  });
772
- class ft {
771
+ class mt {
773
772
  constructor(t) {
774
- this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new O();
773
+ this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new N();
775
774
  const { events: e } = t.get("$widget");
776
775
  this.events = e;
777
776
  }
@@ -804,7 +803,7 @@ class ft {
804
803
  };
805
804
  }
806
805
  }
807
- const it = "#____version____#", _ = class L extends q {
806
+ const it = "#____version____#", y = class y extends j {
808
807
  constructor(t, e = []) {
809
808
  super(t, e, {
810
809
  transformPluginSettings: (s, i, c) => {
@@ -838,7 +837,7 @@ const it = "#____version____#", _ = class L extends q {
838
837
  const e = [B].concat(
839
838
  t.configurationApiExtensions || []
840
839
  );
841
- return new L("humany", e);
840
+ return new y("humany", e);
842
841
  }
843
842
  /**
844
843
  * Creates a widget runtime based on provided configuration and retains configuration handlers
@@ -865,46 +864,46 @@ const it = "#____version____#", _ = class L extends q {
865
864
  return !!(t && typeof t == "object" && t.container && typeof t.container.get == "function" && t.container.get("$environment") === t && t.container.owner === t);
866
865
  }
867
866
  };
868
- _.version = `${it} (${j})`;
869
- let vt = _;
870
- class bt extends z {
867
+ y.version = `${it} (${q})`;
868
+ let D = y;
869
+ class vt extends z {
871
870
  constructor() {
872
871
  super(...arguments), this.bindings = [];
873
872
  }
874
873
  }
875
- class gt extends Q {
874
+ class bt extends Q {
876
875
  constructor(t, e) {
877
876
  super(t, e);
878
877
  }
879
878
  }
880
879
  var ot = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(ot || {});
881
- class yt extends F {
880
+ class gt extends F {
882
881
  constructor(t) {
883
882
  super(t);
884
883
  }
885
884
  }
886
885
  export {
887
886
  at as ActionResolver,
888
- P as ActionsController,
889
- I as ComponentNode,
890
- S as ComponentNodeController,
887
+ k as ActionsController,
888
+ S as ComponentNode,
889
+ L as ComponentNodeController,
891
890
  st as ComponentPlatform,
892
- N as ComponentQuery,
893
- ft as ComponentResolver,
894
- vt as Environment,
895
- bt as Implementation,
896
- gt as Plugin,
891
+ P as ComponentQuery,
892
+ mt as ComponentResolver,
893
+ D as Environment,
894
+ vt as Implementation,
895
+ bt as Plugin,
897
896
  ot as WidgetRenderState,
898
- yt as WidgetType,
897
+ gt as WidgetType,
899
898
  dt as asDescriptor,
900
899
  pt as bootstrap,
901
900
  ut as componentConfigurationApi,
902
- C as createChildren,
901
+ E as createChildren,
903
902
  lt as createComponentModel,
904
903
  G as createEventSubscriber,
905
- mt as extendComponent,
904
+ ft as extendComponent,
906
905
  W as findComponent,
907
- x as findVisibleComponents,
908
- k as traverseComponents,
906
+ w as findVisibleComponents,
907
+ $ as traverseComponents,
909
908
  it as version
910
909
  };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-core",
3
- "version": "1.3.41-rc.1",
3
+ "version": "1.3.41",
4
4
  "dependencies": {
5
5
  "@webprovisions/platform": "^1.1.4",
6
6
  "@webprovisions/bootstrapping": "^1.0.14",
7
- "@telia-ace/widget-utilities": "^1.3.41-rc.1"
7
+ "@telia-ace/widget-utilities": "^1.3.41"
8
8
  },
9
9
  "main": "./index.js",
10
10
  "module": "./index.mjs",