@telia-ace/widget-core 1.0.15 → 1.0.16-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/action-resolver.ts","../src/event-subscriber.ts","../src/component-platform/component-query.ts","../src/component-platform/component-controller.ts","../src/component-platform/actions-controller.ts","../src/component-platform/component-configuration-api.ts","../src/component-platform/component-node.ts","../src/component-platform/queries.ts","../src/component-platform/component-node-collection.ts","../src/component-platform/custom-component-handler.ts","../src/component-platform/state-processor.ts","../src/component-platform/component-platform.ts","../src/component-platform/create-component-model.ts","../src/component-platform/descriptor.ts","../src/component-platform/extend-component.ts","../src/component-resolver.ts","../src/types/configuration.ts"],"sourcesContent":["import {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n Widget,\r\n} from '@webprovisions/platform';\r\n\r\nexport type Action = (origin: string, action: string, value?: any) => void;\r\n\r\nexport default class ActionResolver {\r\n private events: EventManager;\r\n\r\n constructor(container: Container) {\r\n const { events }: Widget = container.get('$widget');\r\n this.events = events.createChild(this);\r\n }\r\n\r\n action(target: string, action: string, value: any): void {\r\n this.events.dispatch('data:action', { action, value, target }, { bubbles: true });\r\n }\r\n\r\n subscribe(origin: string, fn: Action): EventSubscriptionCancellation {\r\n return this.events.subscribe(\r\n 'data:action',\r\n (e, { action, value, target }) => origin === target && fn(origin, action, value)\r\n );\r\n }\r\n}\r\n","import {\r\n EventListener,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n} from '@webprovisions/platform';\r\n\r\nexport type SubscribeDelegate = (type: string, listener: EventListener) => void;\r\n\r\n/**\r\n * Creates s subscriber for the specified `EventManager` and provides a single cancellation\r\n * function for all registered subscriptions.\r\n */\r\nexport const createEventSubscriber = (\r\n events: EventManager\r\n): [SubscribeDelegate, EventSubscriptionCancellation] => {\r\n const subs: EventSubscriptionCancellation[] = [];\r\n\r\n const subscribe = (type: string, listener: EventListener) => {\r\n subs.push(events.subscribe(type, listener));\r\n };\r\n\r\n return [\r\n subscribe,\r\n () => {\r\n subs.forEach((sub) => {\r\n sub();\r\n });\r\n },\r\n ];\r\n};\r\n","import { AbstractComponentController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\n\r\nexport type ComponentQueryRule = {\r\n id?: string;\r\n type?: string;\r\n};\r\n\r\nexport class ComponentQuery {\r\n constructor(private platform: ComponentPlatform, public rules: ComponentQueryRule[] = []) {}\r\n\r\n match(node: ComponentNode) {\r\n return this.rules.every((rule) => {\r\n if (rule.id && rule.id !== node.id) {\r\n return false;\r\n }\r\n if (rule.type && rule.type !== node.type) {\r\n return false;\r\n }\r\n return true;\r\n });\r\n }\r\n\r\n ofType(type: string): ComponentQuery {\r\n this.rules.push({ type });\r\n return this;\r\n }\r\n\r\n withId(id: string): ComponentQuery {\r\n this.rules.push({ id });\r\n return this;\r\n }\r\n\r\n select(): AbstractComponentController {\r\n return new AbstractComponentController(this.platform, this);\r\n }\r\n}\r\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { createEventSubscriber, SubscribeDelegate } from '../event-subscriber';\r\nimport { ActionsController } from './actions-controller';\r\nimport {\r\n ChangesetOptions,\r\n ComponentNode,\r\n ComponentNodeContext,\r\n ComponentNodeLayout,\r\n ComponentNodeProperties,\r\n RemoveChangeset,\r\n} from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport interface ComponentController {\r\n actions: ActionsController;\r\n\r\n writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options: ChangesetOptions): void;\r\n\r\n writeLayout(context: Partial<ComponentNodeLayout>, options: ChangesetOptions): void;\r\n\r\n dispose(): void;\r\n}\r\n\r\nexport class ComponentNodeController implements ComponentController {\r\n actions: ActionsController;\r\n\r\n private subscribe: SubscribeDelegate;\r\n private unsubscribe: EventSubscriptionCancellation;\r\n\r\n constructor(private platform: ComponentPlatform, public node: ComponentNode, ns?: string) {\r\n this.actions = new ActionsController(\r\n platform,\r\n new ComponentQuery(platform).withId(node.id),\r\n ns\r\n );\r\n const [subscribe, unsubscribe] = createEventSubscriber(this.platform.events);\r\n this.subscribe = subscribe;\r\n this.unsubscribe = unsubscribe;\r\n }\r\n\r\n properties<T extends ComponentNodeProperties>(\r\n updated?: (properties: T) => void | Partial<ComponentNodeProperties>\r\n ): T {\r\n if (updated) {\r\n this.node.touchProperties((properties) => updated(<T>properties));\r\n }\r\n return <T>this.node.attributes.properties;\r\n }\r\n\r\n context(updated?: (context: ComponentNodeContext) => void): ComponentNodeContext {\r\n if (updated) {\r\n this.subscribe('components:context-changed', (event, { node }) => {\r\n if (node === this.node) {\r\n updated(this.node.attributes.context);\r\n }\r\n });\r\n }\r\n return this.node.attributes.context;\r\n }\r\n\r\n layout(updated?: (layout: ComponentNodeLayout) => void): ComponentNodeLayout {\r\n if (updated) {\r\n this.subscribe('components:layout-changed', (event, { node }) => {\r\n if (node === this.node) {\r\n updated(this.node.attributes.layout);\r\n }\r\n });\r\n }\r\n return this.node.attributes.layout;\r\n }\r\n\r\n writeProperties(\r\n properties:\r\n | Partial<ComponentNodeProperties>\r\n | ((properties: ComponentNodeProperties) => Partial<ComponentNodeProperties>),\r\n options?: ChangesetOptions\r\n ): void {\r\n this.node.writeProperties(properties, options);\r\n }\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\r\n this.node.writeProperties(context, options);\r\n }\r\n\r\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\r\n this.node.writeLayout(layout, options);\r\n }\r\n\r\n dispose() {\r\n this.unsubscribe();\r\n this.actions.dispose();\r\n }\r\n}\r\n\r\nexport class AbstractComponentController implements ComponentController {\r\n actions: ActionsController;\r\n private removes: RemoveChangeset[] = [];\r\n\r\n constructor(\r\n private platform: ComponentPlatform,\r\n private target: ComponentQuery,\r\n private clearOnDispose = true\r\n ) {\r\n this.actions = new ActionsController(this.platform, this.target);\r\n }\r\n\r\n writeProperties(\r\n properties: Partial<ComponentNodeProperties>,\r\n options?: ChangesetOptions\r\n ): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { properties },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { context },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { layout },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n dispose() {\r\n this.removes.forEach((remove) => {\r\n remove();\r\n });\r\n this.actions.dispose();\r\n }\r\n}\r\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { ComponentNodeController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport type ActionData = any;\r\n\r\nexport type ActionHandler = (data: any, options: any, instance: ComponentNodeController) => any;\r\nexport type NextActionDelegate = (data: any, options?: any) => Promise<any>;\r\nexport type WatchActionDelegate = (\r\n input: ActionData,\r\n next: NextActionDelegate,\r\n instance: ComponentNodeController\r\n) => Promise<any> | any;\r\nexport type ActionWatcherContext = {\r\n source: ComponentNode;\r\n action: string;\r\n};\r\n\r\nexport type ActionsState = {\r\n handlers: {\r\n fn: ActionHandler;\r\n key: string;\r\n target: ComponentQuery;\r\n ns?: string;\r\n }[];\r\n\r\n watchers: {\r\n target: ComponentQuery;\r\n fn: WatchActionDelegate;\r\n key: string;\r\n ns?: string;\r\n }[];\r\n};\r\n\r\ntype ActionWatcherExecutionResult = {\r\n data: any;\r\n options: any;\r\n cancelled: boolean;\r\n};\r\n\r\nconst executeActionListeners = (\r\n listeners: WatchActionDelegate[],\r\n data: any,\r\n controller: ComponentNodeController\r\n): Promise<ActionWatcherExecutionResult> => {\r\n const stack = listeners.concat();\r\n const dispatch = (\r\n data: any,\r\n globalOptions: any,\r\n controller: ComponentNodeController\r\n ): Promise<ActionWatcherExecutionResult> => {\r\n let cancelled = true;\r\n if (stack.length) {\r\n const handler = stack.shift() as WatchActionDelegate;\r\n\r\n const next = (data: any, options: any) => {\r\n cancelled = false;\r\n return dispatch(data, Object.assign({}, globalOptions, options), controller);\r\n };\r\n\r\n return Promise.resolve(handler(data, next, controller)).then((result) => ({\r\n ...result,\r\n cancelled,\r\n }));\r\n }\r\n\r\n return Promise.resolve({ data, cancelled: false, options: globalOptions });\r\n };\r\n return dispatch(data, {}, controller);\r\n};\r\n\r\nexport class ActionsController {\r\n private subscriptions: (() => void)[] = [];\r\n constructor(\r\n private platform: ComponentPlatform,\r\n private target: ComponentQuery,\r\n private ns?: string\r\n ) {\r\n this.create = this.create.bind(this);\r\n }\r\n\r\n create(key: string, fn: ActionHandler = () => {}): EventSubscriptionCancellation {\r\n const handler = {\r\n key,\r\n fn,\r\n target: this.target,\r\n ns: this.ns,\r\n };\r\n this.platform.actionsState.handlers.push(handler);\r\n const subscription = () => {\r\n const index = this.platform.actionsState.handlers.indexOf(handler);\r\n if (index > -1) {\r\n this.platform.actionsState.handlers.splice(index, 1);\r\n }\r\n };\r\n this.subscriptions.push(subscription);\r\n return subscription;\r\n }\r\n\r\n dispatch(key: string, data: any): Promise<{ [instanceId: string]: any }> {\r\n const instances: ComponentNode[] = this.platform.nodes.all.concat(\r\n this.platform.nodes.detached\r\n );\r\n\r\n const output: { [instanceId: string]: any } = {};\r\n\r\n // handlers matching the specified pattern.\r\n const handlers = this.platform.actionsState.handlers.filter(\r\n (handler) => handler.key === key && (!handler.ns || !this.ns || handler.ns === this.ns)\r\n );\r\n\r\n return Promise.all(\r\n handlers.map((handler) => {\r\n // select all matching instances for this particular\r\n // handler (a handler can be mapped to many instances)\r\n const matchedInstances = instances.filter(\r\n (instance) => handler.target.match(instance) && this.target.match(instance)\r\n );\r\n\r\n // execute watchers for each matched instance\r\n const watchers = this.platform.actionsState.watchers\r\n .filter((watcher) => {\r\n return (\r\n watcher.key === key &&\r\n (!watcher.ns || !this.ns || watcher.ns === this.ns) &&\r\n matchedInstances.some((instance) => watcher.target.match(instance))\r\n );\r\n })\r\n .map((watcher) => watcher.fn);\r\n\r\n // execute watchers and handler for each instance\r\n return Promise.all(\r\n matchedInstances.map((node) => {\r\n const controller = new ComponentNodeController(\r\n this.platform,\r\n node,\r\n this.ns\r\n );\r\n return executeActionListeners(watchers, data, controller).then((input) => {\r\n const { data = {}, options, cancelled } = input;\r\n return Promise.resolve(\r\n cancelled ? {} : handler.fn(data, options, controller)\r\n ).then((handlerResponse) => {\r\n output[node.id] = handlerResponse;\r\n });\r\n });\r\n })\r\n );\r\n })\r\n ).then(() => output);\r\n }\r\n\r\n watch(key: string, fn: WatchActionDelegate): EventSubscriptionCancellation {\r\n let parsedKey = key;\r\n let parsedNs = this.ns;\r\n const sections = key.split('.');\r\n\r\n if (sections.length > 1) {\r\n parsedNs = sections[0];\r\n parsedKey = sections.splice(1).join('.');\r\n }\r\n const watcher = {\r\n fn,\r\n target: this.target,\r\n key: parsedKey,\r\n ns: parsedNs,\r\n };\r\n this.platform.actionsState.watchers.push(watcher);\r\n const subscription = () => {\r\n const index = this.platform.actionsState.watchers.indexOf(watcher);\r\n if (index > -1) {\r\n this.platform.actionsState.watchers.splice(index, 1);\r\n }\r\n };\r\n this.subscriptions.push(subscription);\r\n return subscription;\r\n }\r\n\r\n dispose() {\r\n this.subscriptions.forEach((unsubscribe) => unsubscribe());\r\n }\r\n}\r\n","import { createConfigurationApi } from '@webprovisions/platform';\r\nimport { CustomHandlerCallback } from './custom-component-handler';\r\n\r\ntype Options = {\r\n handlers?: [string, CustomHandlerCallback][];\r\n};\r\n\r\nexport default createConfigurationApi((builder) => {\r\n builder.createCommand('components', (context) => (config: Options) => {\r\n context.events.subscribeOnce('components:platform-created', (event, { platform }) => {\r\n if (config.handlers) {\r\n config.handlers.forEach(([key, handler]) => {\r\n platform.addComponentHandler(key, handler);\r\n });\r\n }\r\n });\r\n });\r\n});\r\n","import { Logger, uuid } from '@telia-ace/widget-utilities';\r\nimport { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { Breakpoints } from '../types';\r\n\r\nexport type ComponentNodeEventData = { node: ComponentNode };\r\n\r\nexport type RemoveChangeset = () => void;\r\n\r\nexport type ComponentNodeAttributes = {\r\n tags: string[];\r\n properties: ComponentNodeProperties;\r\n context: ComponentNodeContext;\r\n layout: ComponentNodeLayout;\r\n};\r\n\r\nexport type ResolveComponentNodeProperties = (\r\n properties: ComponentNodeProperties\r\n) => Partial<ComponentNodeProperties> | void;\r\n\r\nexport type ResolveComponentNodeContext = (\r\n context: ComponentNodeContext\r\n) => Partial<ComponentNodeContext>;\r\n\r\nexport type ResolveComponentNodeLayout = (\r\n layout: ComponentNodeLayout\r\n) => Partial<ComponentNodeLayout>;\r\n\r\nexport type ComponentNodeSettings = {\r\n tags?: string[];\r\n properties?: ComponentNodeProperties | ResolveComponentNodeProperties;\r\n context?: ComponentNodeContext | ResolveComponentNodeContext;\r\n layout?: ComponentNodeLayout | ResolveComponentNodeLayout;\r\n};\r\n\r\nexport type ComponentNodeProperties = { [key: string]: any };\r\n\r\nexport type ComponentNodeContext = { [key: string]: any };\r\n\r\nexport type ComponentNodeLayout = {\r\n size?: Size;\r\n indent?: number;\r\n order?: number;\r\n};\r\n\r\nexport type Size = number | 'full' | 'none';\r\n\r\nexport type UnmountComponentNode = () => void;\r\n\r\nexport type ChangesetOptions = {\r\n breakpoints?: Breakpoints;\r\n};\r\n\r\nexport type Changeset = [Partial<ComponentNodeSettings>, ChangesetOptions];\r\n\r\nexport class ComponentNode {\r\n id: string;\r\n type: string;\r\n name?: string;\r\n parent?: ComponentNode;\r\n tags: string[] = [];\r\n children: { [key: string]: ComponentNode[] } = {};\r\n changesets: Changeset[] = [];\r\n attributes: ComponentNodeAttributes;\r\n\r\n private mountCount = 0;\r\n\r\n constructor(private events: EventManager, type: string) {\r\n this.id = uuid();\r\n this.type = type;\r\n this.attributes = {\r\n context: {},\r\n properties: {},\r\n layout: {},\r\n tags: [],\r\n };\r\n // write default attributes\r\n this.writeLayout({ size: 'full', indent: 0 });\r\n }\r\n\r\n mount(viewOutletContainer: Container, element?: HTMLElement): UnmountComponentNode {\r\n let mountedNodes: Map<ComponentNode, EventSubscriptionCancellation> =\r\n viewOutletContainer.get('mounted-nodes');\r\n\r\n if (!mountedNodes) {\r\n mountedNodes = new Map<ComponentNode, EventSubscriptionCancellation>();\r\n viewOutletContainer.register('mounted-nodes', mountedNodes);\r\n }\r\n\r\n if (mountedNodes.has(this)) {\r\n if (process.env.NODE_ENV !== 'production') {\r\n Logger.error('Trying to mount an already mounted component node.', this);\r\n }\r\n return () => {};\r\n }\r\n\r\n /**\r\n * Dispatched when a node is mounted in a component.\r\n * This happens once for every `ViewOutlet`.\r\n */\r\n this.events.dispatch('components:node-mounted', { node: this });\r\n\r\n if (this.mountCount === 0) {\r\n this.mountCount = this.mountCount + 1;\r\n /**\r\n * Dispatched when a node is mounted in a component the first time.\r\n */\r\n this.events.dispatch('components:node-enter', { node: this });\r\n }\r\n\r\n return () => {\r\n mountedNodes.delete(this);\r\n this.events.dispatch('components:node-unmounted', { node: this });\r\n\r\n this.mountCount = this.mountCount - 1;\r\n if (this.mountCount === 0) {\r\n this.events.dispatch('components:node-exit', { node: this });\r\n }\r\n };\r\n }\r\n\r\n appendChild(node: ComponentNode, branch: string = 'default') {\r\n if (node.parent) {\r\n if (node.parent === this) {\r\n return;\r\n }\r\n node.parent.removeChild(node);\r\n }\r\n node.parent = this;\r\n\r\n if (!this.children[branch]) {\r\n this.children[branch] = [];\r\n }\r\n this.children[branch].push(node);\r\n\r\n this.events.dispatch('components:node-appended', { node });\r\n }\r\n\r\n prependChild(node: ComponentNode, branch: string = 'default') {\r\n if (node.parent) {\r\n if (node.parent === this) {\r\n return;\r\n }\r\n node.parent.removeChild(node);\r\n }\r\n node.parent = this;\r\n\r\n if (!this.children[branch]) {\r\n this.children[branch] = [];\r\n }\r\n this.children[branch].unshift(node);\r\n\r\n this.events.dispatch('components:node-appended', { node });\r\n }\r\n\r\n touchProperties(\r\n properties: ResolveComponentNodeProperties,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { properties };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n return () => {\r\n if (removable) {\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n }\r\n }\r\n };\r\n }\r\n\r\n writeProperties(\r\n properties: Partial<ComponentNodeProperties> | ResolveComponentNodeProperties,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { properties };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n return () => {\r\n if (removable) {\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n }\r\n }\r\n };\r\n }\r\n\r\n writeLayout(\r\n layout: Partial<ComponentNodeLayout> | ResolveComponentNodeLayout,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { layout };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-layout', { node: this });\r\n return () => {\r\n if (!removable) {\r\n return;\r\n }\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-layout', { node: this });\r\n }\r\n };\r\n }\r\n\r\n writeContext(\r\n context: Partial<ComponentNodeContext> | ResolveComponentNodeContext,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { context };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-context', { node: this });\r\n return () => {\r\n if (!removable) {\r\n return;\r\n }\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-context', { node: this });\r\n }\r\n };\r\n }\r\n\r\n getChildren(branch: string = 'default'): ComponentNode[] {\r\n const children = this.children[branch] || [];\r\n return children.reduce((acc, node, i) => {\r\n const { order: index = i } = node.attributes.layout;\r\n if (!acc[index]) {\r\n acc[index] = node;\r\n } else {\r\n acc.splice(index, 0, node);\r\n }\r\n return acc;\r\n }, Array(children.length));\r\n }\r\n\r\n remove() {\r\n if (this.parent) {\r\n this.parent.removeChild(this);\r\n }\r\n }\r\n\r\n removeChild(node: ComponentNode) {\r\n Object.keys(this.children).forEach((branch) => {\r\n const children = this.children[branch];\r\n const indexToRemove = children.indexOf(node);\r\n if (indexToRemove > -1) {\r\n children.splice(indexToRemove, 1);\r\n this.events.dispatch('components:node-removed', { node, parentNode: this });\r\n }\r\n });\r\n delete node.parent;\r\n }\r\n}\r\n","import { ComponentNode } from './component-node';\r\nimport { SwitchMap } from './component-platform';\r\n\r\nconst traverseComponentsRecursive = (\r\n nodes: ComponentNode[],\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean | void\r\n) => {\r\n for (let i = 0, y = nodes.length; i < y; i++) {\r\n if (fn(nodes[i]) === true) {\r\n break;\r\n }\r\n const branch = switches[nodes[i].id] || 'default';\r\n const children = nodes[i].getChildren(branch);\r\n traverseComponentsRecursive(children, switches, fn);\r\n }\r\n};\r\n\r\nexport const traverseComponents = (\r\n root: ComponentNode,\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean | void\r\n) => {\r\n if (fn(root) !== true) {\r\n const branch = switches[root.id] || 'default';\r\n const children = root.children[branch];\r\n traverseComponentsRecursive(children, switches, fn);\r\n }\r\n};\r\n\r\nexport const findVisibleComponents = (\r\n root: ComponentNode,\r\n switches: SwitchMap\r\n): ComponentNode[] => {\r\n const nodes: ComponentNode[] = [];\r\n traverseComponents(root, switches, (node) => {\r\n nodes.push(node);\r\n });\r\n return nodes;\r\n};\r\n\r\nexport const findComponent = (\r\n root: ComponentNode,\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean\r\n) => {\r\n let matched: ComponentNode | undefined;\r\n traverseComponents(root, switches, (node) => {\r\n if (fn(node)) {\r\n matched = node;\r\n return true;\r\n }\r\n });\r\n return matched;\r\n};\r\n\r\nexport const getAncestors = (node: ComponentNode) => {\r\n if (!node.parent) {\r\n return [];\r\n }\r\n const tree: ComponentNode[] = [];\r\n let currentNode: ComponentNode | undefined = node.parent;\r\n while (currentNode) {\r\n tree.unshift(currentNode);\r\n currentNode = currentNode.parent;\r\n }\r\n return tree;\r\n};\r\n","import { EventManager } from '@webprovisions/platform';\r\nimport { ComponentNode, ComponentNodeEventData } from './component-node';\r\nimport { SwitchMap } from './component-platform';\r\nimport { findComponent, findVisibleComponents, traverseComponents } from './queries';\r\n\r\nexport type QueryDescriptor = {\r\n id?: string;\r\n type?: string;\r\n name?: string;\r\n};\r\n\r\nexport class ComponentNodeCollection {\r\n all: ComponentNode[] = [];\r\n visible: ComponentNode[] = [];\r\n detached: ComponentNode[] = [];\r\n\r\n constructor(public root: ComponentNode, private switches: SwitchMap, events: EventManager) {\r\n events.subscribe('components:node-appended', (event, data: ComponentNodeEventData) => {\r\n this.all.push(data.node);\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n events.subscribe('components:node-removed', (event, data: ComponentNodeEventData) => {\r\n let indexToRemove = this.all.indexOf(data.node);\r\n if (indexToRemove > -1) {\r\n this.all.splice(indexToRemove, 1);\r\n }\r\n indexToRemove = this.visible.indexOf(data.node);\r\n if (indexToRemove > -1) {\r\n this.visible.splice(indexToRemove, 1);\r\n }\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n events.subscribe('components:node-switched', (event, data: ComponentNodeEventData) => {\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n }\r\n\r\n query(query: QueryDescriptor = {}): ComponentNode[] {\r\n const nodes: ComponentNode[] = [];\r\n traverseComponents(this.root, this.switches, (node) => {\r\n const match = Object.keys(query).every((member) => {\r\n return (<any>query)[member] === (<any>node)[member];\r\n });\r\n if (match) {\r\n nodes.push(node);\r\n }\r\n });\r\n return nodes;\r\n }\r\n\r\n get(id: string) {\r\n return (\r\n findComponent(this.root, this.switches, (node) => node.id === id) ||\r\n this.detached.find((node) => node.id === id)\r\n );\r\n }\r\n}\r\n","import { ComponentReference, ComponentSettings, ViewDefinition } from '../types';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { NormalizedComponentReference } from './create-component-model';\r\n\r\nexport type CustomHandlerCallback = (\r\n ref: NormalizedComponentReference,\r\n options: {\r\n platform: ComponentPlatform;\r\n node: ComponentNode;\r\n references: ComponentReference[];\r\n definitions: { [name: string]: ComponentSettings };\r\n views: { [key: string]: ViewDefinition };\r\n branch?: string;\r\n }\r\n) => void;\r\n\r\nexport class CustomComponentHandler {\r\n private handlers = new Map<string, CustomHandlerCallback>();\r\n\r\n add(name: string, fn: CustomHandlerCallback) {\r\n this.handlers.set(name, fn);\r\n }\r\n\r\n get(name: string) {\r\n return this.handlers.get(name);\r\n }\r\n}\r\n","import { ComponentPlatform } from '.';\r\nimport { Breakpoints } from '../types';\r\nimport {\r\n ComponentNode,\r\n ResolveComponentNodeContext,\r\n ResolveComponentNodeLayout,\r\n ResolveComponentNodeProperties,\r\n} from './component-node';\r\n\r\nexport type ProcessOptions = {\r\n context?: boolean;\r\n properties?: boolean;\r\n layout?: boolean;\r\n recursive?: boolean;\r\n};\r\n\r\nexport type StateProcessor = (node: ComponentNode, options: ProcessOptions) => void;\r\n\r\nconst calculateNodeIndex = (node: ComponentNode): number => {\r\n let currentNode = node;\r\n let index = 0;\r\n\r\n while (currentNode.parent) {\r\n index = index + 1;\r\n currentNode = currentNode.parent;\r\n }\r\n\r\n return index;\r\n};\r\n\r\nconst sortQueue = (queue: [ComponentNode, ProcessOptions][]): [ComponentNode, ProcessOptions][] => {\r\n const mapped: [number, ComponentNode, ProcessOptions][] = queue.map(([node, options]) => {\r\n return [calculateNodeIndex(node), node, options];\r\n });\r\n return mapped\r\n .sort(([a], [b]) => a - b)\r\n .map(([, node, options]) => {\r\n return [node, options];\r\n });\r\n};\r\n\r\nconst isObject = (item: any) => {\r\n return item && typeof item === 'object' && !Array.isArray(item);\r\n};\r\n\r\nconst mergeDeep = (target: any, ...sources: any[]): any => {\r\n if (!sources.length) return target;\r\n const source = sources.shift();\r\n\r\n if (isObject(target) && isObject(source)) {\r\n for (const key in source) {\r\n if (isObject(source[key])) {\r\n if (!target[key]) Object.assign(target, { [key]: {} });\r\n mergeDeep(target[key], source[key]);\r\n } else {\r\n Object.assign(target, { [key]: source[key] });\r\n }\r\n }\r\n }\r\n return mergeDeep(target, ...sources);\r\n};\r\n\r\nconst matchesBreakpoint = (b1: Breakpoints | undefined, b2: string[]) => {\r\n if (!b1 || b1 === 'all') {\r\n return true;\r\n }\r\n return b1.some((b1) => b2.indexOf(b1) > -1);\r\n};\r\n\r\nexport type ProcessResult = Map<ComponentNode, ProcessOptions>;\r\n\r\nexport type ProcessReportCallback = (report: ProcessResult) => void;\r\n\r\nexport const createStateProcessor = (\r\n platform: ComponentPlatform,\r\n callback: ProcessReportCallback\r\n): StateProcessor => {\r\n let nodeQueue: ComponentNode[] = [];\r\n let optionsQueue: ProcessOptions[] = [];\r\n\r\n let timeout: NodeJS.Timeout;\r\n\r\n const flush = () => {\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.time('state-processor.flush');\r\n }\r\n const processHistory: Map<ComponentNode, ProcessOptions> = new Map();\r\n const sortedQueue = sortQueue(nodeQueue.map((node, i) => [node, optionsQueue[i]]));\r\n\r\n const processNode = (node: ComponentNode, options: ProcessOptions) => {\r\n const history = processHistory.get(node) || {};\r\n\r\n // todo: this doesnt take overrides into account\r\n const processContext = options.context && !history.context;\r\n const processProperties = options.properties && !history.properties;\r\n const processLayout = options.layout && !history.layout;\r\n\r\n processHistory.set(node, {\r\n context: history.context || processContext,\r\n properties: history.properties || processProperties,\r\n layout: history.layout || processLayout,\r\n });\r\n\r\n if (processProperties) {\r\n node.attributes.properties = {};\r\n }\r\n if (processLayout) {\r\n node.attributes.layout = {};\r\n }\r\n\r\n if (processContext) {\r\n node.attributes.context = mergeDeep({}, node.parent?.attributes.context);\r\n }\r\n\r\n const propertyResolvers: ResolveComponentNodeProperties[] = [];\r\n const layoutResolvers: ResolveComponentNodeLayout[] = [];\r\n const contextResolvers: ResolveComponentNodeContext[] = [];\r\n\r\n node.changesets.forEach((changeset) => {\r\n const [change, options] = changeset;\r\n if (matchesBreakpoint(options.breakpoints, platform.breakpoints)) {\r\n if (processProperties) {\r\n if (typeof change.properties === 'function') {\r\n propertyResolvers.push(\r\n <ResolveComponentNodeProperties>change.properties\r\n );\r\n } else {\r\n mergeDeep(node.attributes.properties, change.properties);\r\n }\r\n }\r\n\r\n if (processLayout) {\r\n if (typeof change.layout === 'function') {\r\n layoutResolvers.push(<ResolveComponentNodeLayout>change.layout);\r\n } else {\r\n mergeDeep(node.attributes.layout, change.layout);\r\n }\r\n }\r\n\r\n if (processContext) {\r\n if (typeof change.context === 'function') {\r\n contextResolvers.push(<ResolveComponentNodeContext>change.context);\r\n } else {\r\n mergeDeep(node.attributes.context, change.context);\r\n }\r\n }\r\n }\r\n });\r\n\r\n propertyResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.properties, resolver(node.attributes.properties));\r\n });\r\n\r\n layoutResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.layout, resolver(node.attributes.layout));\r\n });\r\n\r\n contextResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.context, resolver(node.attributes.context));\r\n });\r\n\r\n if (processContext || options.recursive) {\r\n const branch = platform.getBranch(node);\r\n const childOptions: ProcessOptions = options.recursive\r\n ? options\r\n : {\r\n context: !!processContext,\r\n };\r\n node.getChildren(branch).forEach((child) => {\r\n processNode(child, childOptions);\r\n });\r\n }\r\n };\r\n\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.timeEnd('state-processor.flush');\r\n }\r\n\r\n sortedQueue.forEach(([node, options]) => {\r\n processNode(node, options);\r\n });\r\n\r\n nodeQueue = [];\r\n optionsQueue = [];\r\n\r\n callback(processHistory);\r\n };\r\n\r\n const schedule = () => {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(flush, 0);\r\n };\r\n\r\n return (node, options) => {\r\n const index = nodeQueue.indexOf(node);\r\n\r\n if (index > -1) {\r\n // if node already exist in queue, update its options\r\n const summary = optionsQueue[index];\r\n if (options.context) {\r\n summary.context = true;\r\n }\r\n if (options.properties) {\r\n summary.properties = true;\r\n }\r\n if (options.layout) {\r\n summary.layout = true;\r\n }\r\n if (options.recursive) {\r\n summary.recursive = true;\r\n }\r\n return schedule();\r\n }\r\n\r\n nodeQueue.push(node);\r\n optionsQueue.push(options);\r\n\r\n return schedule();\r\n };\r\n};\r\n","import { uuid } from '@telia-ace/widget-utilities';\r\nimport {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n Widget,\r\n} from '@webprovisions/platform';\r\nimport { ActionsController, ActionsState } from './actions-controller';\r\nimport { ChangesetProvider } from './changeset-provider';\r\nimport {\r\n Changeset,\r\n ChangesetOptions,\r\n ComponentNode,\r\n ComponentNodeEventData,\r\n ComponentNodeSettings,\r\n RemoveChangeset,\r\n} from './component-node';\r\nimport { ComponentNodeCollection } from './component-node-collection';\r\nimport { ComponentQuery } from './component-query';\r\nimport { CustomComponentHandler, CustomHandlerCallback } from './custom-component-handler';\r\nimport { createStateProcessor, StateProcessor } from './state-processor';\r\n\r\nexport type MergeOptions = { breakpoints?: string[] };\r\n\r\ntype AbstractChangesetRecord = {\r\n changeset: Changeset;\r\n target: ComponentQuery;\r\n removes: RemoveChangeset[];\r\n};\r\n\r\nexport type SwitchMap = { [id: string]: string };\r\n\r\nexport type ChangesetData = {\r\n key?: string;\r\n target: ComponentQuery;\r\n attributes: Partial<ComponentNodeSettings>;\r\n options?: ChangesetOptions;\r\n removable?: boolean;\r\n provider?: string;\r\n};\r\n\r\nexport class ComponentPlatform {\r\n events: EventManager;\r\n breakpoints: string[] = [];\r\n nodes: ComponentNodeCollection;\r\n // internal\r\n actionsState: ActionsState = { handlers: [], watchers: [] };\r\n\r\n private switches: SwitchMap = {};\r\n private changesets: AbstractChangesetRecord[] = [];\r\n private subscriptions: EventSubscriptionCancellation[] = [];\r\n private processNode: StateProcessor;\r\n private customComponentHandler = new CustomComponentHandler();\r\n\r\n constructor(widget: Widget, private providers: { [key: string]: ChangesetProvider } = {}) {\r\n this.events = widget.events.createChild(this);\r\n const root = new ComponentNode(this.events, 'root');\r\n root.name = `root-${widget.name}`;\r\n this.nodes = new ComponentNodeCollection(root, this.switches, this.events);\r\n\r\n const processNode = (this.processNode = createStateProcessor(this, (report) => {\r\n const nodes = Array.from(report.keys());\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.info(`STATE PROCESSOR: ${nodes.length} node(s) processed:\r\n${nodes.map(\r\n (node) => `${node.name || '<no name>'} (${node.id})\r\n`\r\n)}`);\r\n }\r\n nodes.forEach((node) => {\r\n const options = report.get(node);\r\n if (node.parent && node.parent.type === 'root') {\r\n this.events.dispatch('components:root-children-changed', { node });\r\n }\r\n if (options?.context) {\r\n this.events.dispatch('components:context-changed', { node });\r\n }\r\n if (options?.properties) {\r\n this.events.dispatch('components:properties-changed', { node });\r\n }\r\n if (options?.layout) {\r\n this.events.dispatch('components:layout-changed', { node });\r\n }\r\n });\r\n this.events.dispatch('components:component-model-initialized', {}, { bubbles: true });\r\n }));\r\n\r\n Promise.all(\r\n Object.keys(providers).map((key) => {\r\n const provider = providers[key];\r\n return provider.load(this);\r\n })\r\n );\r\n\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:node-appended',\r\n (event, data: ComponentNodeEventData) => {\r\n const { node } = data;\r\n this.changesets.forEach((record) => {\r\n const { changeset, target, removes } = record;\r\n const [change, options] = changeset;\r\n if (target.match(data.node)) {\r\n if (change.properties) {\r\n removes.push(node.writeProperties(change.properties, options));\r\n }\r\n if (change.context) {\r\n removes.push(node.writeContext(change.context, options));\r\n }\r\n if (change.layout) {\r\n removes.push(node.writeLayout(change.layout, options));\r\n }\r\n }\r\n });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:node-appended',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true, context: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-properties',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-context',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true, context: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-indent',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { layout: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-layout',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { layout: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe('components:node-switched', (event, { node, branch }) => {\r\n processNode(node, {\r\n layout: true,\r\n recursive: true,\r\n properties: true,\r\n context: true,\r\n });\r\n })\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe('components:node-removed', (event, { parentNode }) => {\r\n processNode(parentNode, { properties: true });\r\n })\r\n );\r\n\r\n if (this.events.parent) {\r\n this.events.parent.dispatch('components:platform-created', { platform: this });\r\n }\r\n }\r\n\r\n static getInstance(container: Container): Promise<ComponentPlatform> {\r\n return container.getAsync('components');\r\n }\r\n\r\n addBreakpoint(name: string) {\r\n if (this.breakpoints.indexOf(name) === -1) {\r\n this.breakpoints.push(name);\r\n this.processNode(this.nodes.root, {\r\n context: true,\r\n properties: true,\r\n layout: true,\r\n recursive: true,\r\n });\r\n }\r\n }\r\n\r\n removeBreakpoint(name: string) {\r\n const indexToRemove = this.breakpoints.indexOf(name);\r\n if (indexToRemove > -1) {\r\n this.breakpoints.splice(indexToRemove, 1);\r\n this.processNode(this.nodes.root, {\r\n context: true,\r\n properties: true,\r\n layout: true,\r\n recursive: true,\r\n });\r\n }\r\n }\r\n\r\n setSwitch(node: ComponentNode, branch: string) {\r\n this.switches[node.id] = branch;\r\n this.events.dispatch('components:node-switched', { node, branch });\r\n }\r\n\r\n getBranch(node: ComponentNode): string | undefined {\r\n return this.switches[node.id];\r\n }\r\n\r\n /**\r\n * Creates a `ComponentNode` of the specified type.\r\n * @param type Type of node.\r\n */\r\n createNode(type: string, options: { detached?: boolean } = {}): ComponentNode {\r\n const node = new ComponentNode(this.events, type);\r\n if (options.detached) {\r\n this.nodes.detached.push(node);\r\n }\r\n return node;\r\n }\r\n\r\n components(): ComponentQuery {\r\n return new ComponentQuery(this);\r\n }\r\n\r\n actions(target: ComponentQuery, ns: string): ActionsController {\r\n return new ActionsController(this, <any>target, ns);\r\n }\r\n\r\n write(data: ChangesetData): RemoveChangeset {\r\n const { provider: providerName, target, attributes, options = {}, removable } = data;\r\n const key = data.key || uuid();\r\n const changeset: Changeset = [attributes, options];\r\n const record: AbstractChangesetRecord = { changeset, target, removes: [] };\r\n if (providerName) {\r\n const provider = this.providers[providerName];\r\n provider.write(key, target, attributes, options);\r\n record.removes.push(() => {\r\n provider.remove(key);\r\n });\r\n }\r\n\r\n this.changesets.push(record);\r\n this.nodes.all.forEach((node) => {\r\n if (target.match(node)) {\r\n let remove: RemoveChangeset = () => {};\r\n if (attributes.properties) {\r\n remove = node.writeProperties(attributes.properties, options, removable);\r\n }\r\n if (attributes.context) {\r\n remove = node.writeContext(attributes.context, options, removable);\r\n }\r\n if (attributes.layout) {\r\n remove = node.writeContext(attributes.layout, options, removable);\r\n }\r\n record.removes.push(remove);\r\n }\r\n });\r\n return () => {\r\n if (removable) {\r\n record.removes.forEach((remove) => remove());\r\n const indexToRemove = this.changesets.indexOf(record);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n }\r\n }\r\n };\r\n }\r\n\r\n addComponentHandler(definitionType: string, fn: CustomHandlerCallback) {\r\n this.customComponentHandler.add(definitionType, fn);\r\n }\r\n\r\n getComponentHandler(definitionType: string) {\r\n return this.customComponentHandler.get(definitionType);\r\n }\r\n\r\n dispose() {\r\n this.subscriptions.forEach((sub) => sub());\r\n }\r\n}\r\n","import { Logger } from '@telia-ace/widget-utilities';\r\nimport { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { Breakpoints, ComponentSettings, ViewDefinition, WidgetSettings } from '../types';\r\nimport {\r\n ComponentNode,\r\n ComponentNodeContext,\r\n ComponentNodeLayout,\r\n ComponentNodeProperties,\r\n} from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\n\r\ntype ComponentReference = string | [string, ...ComponentReferenceOverride[]];\r\n\r\ntype ComponentReferenceOverride = {\r\n breakpoints?: Breakpoints;\r\n tags?: string[];\r\n context?: ComponentNodeContext;\r\n properties?: ComponentNodeProperties;\r\n layout?: ComponentNodeLayout;\r\n};\r\n\r\nexport type NormalizedComponentReference = {\r\n definitionId: string;\r\n overrides: ComponentReferenceOverride[];\r\n};\r\n\r\nexport const normalizeReference = (reference: ComponentReference): NormalizedComponentReference => {\r\n if (Array.isArray(reference)) {\r\n const [definitionId, ...overrides] = reference;\r\n return {\r\n definitionId,\r\n overrides,\r\n };\r\n }\r\n return {\r\n definitionId: reference,\r\n overrides: [],\r\n };\r\n};\r\n\r\nexport type ComponentHandlerOptions = {\r\n platform: ComponentPlatform;\r\n node: ComponentNode;\r\n references: ComponentReference[];\r\n definitions: { [name: string]: ComponentSettings };\r\n views: { [key: string]: ViewDefinition };\r\n branch?: string;\r\n};\r\n\r\nexport const createChildren = (\r\n platform: ComponentPlatform,\r\n node: ComponentNode,\r\n references: ComponentReference[],\r\n definitions: { [name: string]: ComponentSettings },\r\n views: { [key: string]: ViewDefinition },\r\n branch?: string\r\n) => {\r\n references.forEach((ref) => {\r\n const childRef = normalizeReference(ref);\r\n const childDef = definitions[childRef.definitionId];\r\n if (childRef.definitionId === 'view') {\r\n const viewNode = platform.createNode('view');\r\n viewNode.name = 'view';\r\n Object.keys(views).forEach((key) => {\r\n const viewDef = views[key];\r\n createChildren(platform, viewNode, [viewDef.entry], definitions, views, key);\r\n });\r\n node.appendChild(viewNode);\r\n\r\n childRef.overrides.forEach((override) => {\r\n if (override.properties) {\r\n viewNode.writeProperties(override.properties, {\r\n breakpoints: override.breakpoints,\r\n });\r\n }\r\n if (override.context) {\r\n viewNode.writeContext(override.context, { breakpoints: override.breakpoints });\r\n }\r\n if (override.layout) {\r\n viewNode.writeLayout(override.layout, { breakpoints: override.breakpoints });\r\n }\r\n });\r\n } else if (platform.getComponentHandler(childDef.type)) {\r\n const handle = platform.getComponentHandler(childDef.type);\r\n if (handle) {\r\n handle(childRef, {\r\n platform,\r\n node,\r\n references,\r\n definitions,\r\n views,\r\n branch,\r\n });\r\n }\r\n } else {\r\n const childDef = definitions[childRef.definitionId];\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (!childDef) {\r\n Logger.error(\r\n `No definition found for component type '${childRef.definitionId}'.`\r\n );\r\n return;\r\n }\r\n }\r\n const childNode = platform.createNode(childDef.type);\r\n childNode.name = childRef.definitionId;\r\n childNode.tags = childDef.tags || [];\r\n if (childDef.properties) {\r\n childNode.writeProperties(childDef.properties);\r\n }\r\n if (childDef.context) {\r\n childNode.writeContext(childDef.context);\r\n }\r\n if (childDef.layout) {\r\n childNode.writeLayout(childDef.layout);\r\n }\r\n node.appendChild(childNode, branch);\r\n\r\n childRef.overrides.forEach((override) => {\r\n const options = { breakpoints: override.breakpoints };\r\n if (override.properties) {\r\n childNode.writeProperties(override.properties, options);\r\n }\r\n if (override.context) {\r\n childNode.writeContext(override.context, options);\r\n }\r\n if (override.layout) {\r\n childNode.writeLayout(override.layout, options);\r\n }\r\n });\r\n\r\n if (childDef.children) {\r\n createChildren(platform, childNode, childDef.children, definitions, views);\r\n }\r\n }\r\n });\r\n};\r\n\r\nexport const createComponentModel = (\r\n platform: ComponentPlatform,\r\n settings: WidgetSettings\r\n): EventSubscriptionCancellation => {\r\n const { entry, components, breakpoints, views } = settings;\r\n const subscriptions: EventSubscriptionCancellation[] = [];\r\n\r\n Object.keys(breakpoints).forEach((name) => {\r\n const query = breakpoints[name];\r\n const list = window.matchMedia(query);\r\n if (list.matches) {\r\n platform.breakpoints.push(name);\r\n }\r\n const listener = (event: MediaQueryListEvent) => {\r\n if (event.matches) {\r\n platform.addBreakpoint(name);\r\n } else {\r\n platform.removeBreakpoint(name);\r\n }\r\n };\r\n list.addListener(listener);\r\n subscriptions.push(() => list.removeListener(listener));\r\n });\r\n\r\n createChildren(platform, platform.nodes.root, [entry], components, views);\r\n\r\n return () =>\r\n subscriptions.forEach((sub) => {\r\n sub();\r\n });\r\n};\r\n","import { ComponentNode } from './component-node';\r\n\r\nexport type ComponentDescriptor = {\r\n id: string;\r\n type?: string;\r\n name?: string;\r\n branch: string;\r\n};\r\n\r\nexport const asDescriptor = (node: ComponentNode, branch?: string): ComponentDescriptor => {\r\n return {\r\n id: node.id,\r\n type: node.type,\r\n name: node.name,\r\n branch: branch || 'default',\r\n };\r\n};\r\n","import { uuid } from '@telia-ace/widget-utilities';\r\nimport { Container, EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { ComponentNodeController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport type ExtendComponentHandler = (controller: ComponentNodeController) => any;\r\n\r\nexport type ExtendComponentOptions = {\r\n reuseController?: boolean;\r\n};\r\n\r\nexport const extendComponent = (\r\n container: Container,\r\n typeOrQuery: string | ComponentQuery,\r\n handler: ExtendComponentHandler,\r\n ns: string = uuid(),\r\n options: ExtendComponentOptions = {}\r\n): Promise<void> => {\r\n return container.getAsync('components').then((components: ComponentPlatform) => {\r\n let target: ComponentQuery;\r\n if (typeof typeOrQuery === 'string') {\r\n const collection = new ComponentQuery(components);\r\n collection.ofType(typeOrQuery);\r\n target = collection;\r\n } else {\r\n target = typeOrQuery;\r\n }\r\n\r\n const managedInstances: {\r\n [instanceId: string]: {\r\n dispose: EventSubscriptionCancellation;\r\n controller: ComponentNodeController;\r\n };\r\n } = {};\r\n\r\n const getOrCreateController = (node: ComponentNode): Promise<ComponentNodeController> => {\r\n const existing = managedInstances[node.id];\r\n if (existing) {\r\n return Promise.resolve(existing.controller);\r\n }\r\n return ComponentPlatform.getInstance(container).then((platform) => {\r\n return new ComponentNodeController(platform, node, ns);\r\n });\r\n };\r\n\r\n components.events.subscribe(\r\n 'components:node-enter',\r\n (event, { node }: { node: ComponentNode }) => {\r\n if (target.match(node)) {\r\n getOrCreateController(node).then((controller) => {\r\n Promise.resolve(handler(controller)).then((dispose) => {\r\n managedInstances[node.id] = {\r\n dispose,\r\n controller,\r\n };\r\n });\r\n });\r\n }\r\n }\r\n );\r\n components.events.subscribe(\r\n 'components:node-exit',\r\n (event, { node }: { node: ComponentNode }) => {\r\n const instance = managedInstances[node.id];\r\n if (instance) {\r\n instance.dispose && instance.dispose();\r\n if (!options.reuseController) {\r\n instance.controller.dispose();\r\n delete managedInstances[node.id];\r\n }\r\n }\r\n }\r\n );\r\n });\r\n};\r\n","import { Logger } from '@telia-ace/widget-utilities';\r\nimport {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n WidgetType,\r\n} from '@webprovisions/platform';\r\n\r\nexport type ReactComponent = any | null;\r\n\r\nexport default class ComponentResolver {\r\n aliases: Map<string, string> = new Map();\r\n components: Map<string, any> = new Map();\r\n events: EventManager;\r\n logger = new Logger();\r\n\r\n constructor(container: Container) {\r\n const { events }: WidgetType = container.get('$widget');\r\n this.events = events;\r\n }\r\n\r\n getComponent(key: string): ReactComponent {\r\n const alias = this.aliases.get(key);\r\n const component = this.components.get(alias || key) || null;\r\n\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (!component) {\r\n this.logger.warn(\r\n alias || key,\r\n `Unable to resolve component: \"${\r\n alias || key\r\n }\". You most likely forgot to register the required plugin for: ${\r\n alias || key\r\n }.`\r\n );\r\n }\r\n }\r\n\r\n return component;\r\n }\r\n\r\n registerComponent(key: string, component: ReactComponent): EventSubscriptionCancellation {\r\n this.components.set(key, component);\r\n\r\n this.events.dispatch('component-resolver:resolve', key);\r\n\r\n return () => {\r\n this.components.delete(key);\r\n };\r\n }\r\n\r\n registerResolver(\r\n key: string,\r\n fn: (component: ReactComponent) => void\r\n ): EventSubscriptionCancellation {\r\n return this.events.subscribe('component-resolver:resolve', (e, data: string) => {\r\n if (data === key) {\r\n const component = this.getComponent(key);\r\n fn(component);\r\n }\r\n });\r\n }\r\n\r\n registerAlias(alias: string, key: string): EventSubscriptionCancellation {\r\n this.aliases.set(alias, key);\r\n\r\n this.events.dispatch('component-resolver:resolve', alias);\r\n\r\n return () => {\r\n this.aliases.delete(alias);\r\n };\r\n }\r\n}\r\n","import { ComponentNodeLayout } from '../component-platform';\r\n\r\nexport type ComponentSettings = {\r\n type: string;\r\n context?: Context;\r\n properties?: Properties;\r\n layout?: ComponentNodeLayout;\r\n tags?: string[];\r\n children?: ComponentReference[];\r\n};\r\n\r\nenum HistoryMode {\r\n scopedHash = 'scopedHash',\r\n hash = 'hash',\r\n browser = 'browser',\r\n memory = 'memory',\r\n}\r\n\r\nexport type RoutingSettings = {\r\n initialPath: string;\r\n mode: HistoryMode;\r\n basePath?: string;\r\n};\r\n\r\nexport type ComponentReference = string | [string, ...ComponentReferenceOverride[]];\r\n\r\nexport type Properties = { [key: string]: any };\r\n\r\nexport type Context = { [key: string]: any };\r\n\r\nexport type ViewDefinition = {\r\n path: string | string[];\r\n entry: ComponentReference;\r\n};\r\n\r\nexport type Breakpoints = 'all' | string[];\r\n\r\nexport type ComponentReferenceOverride = {\r\n breakpoints?: Breakpoints;\r\n size?: number | 'full' | 'none';\r\n indent?: number;\r\n tags?: string[];\r\n context?: Context;\r\n properties?: Properties;\r\n};\r\n\r\nexport type ComponentDefinitionMap = {\r\n [name: string]: ComponentSettings;\r\n};\r\n\r\nexport type WidgetSettings = {\r\n data: { projection: string; site?: 'current' | 'referrer'; forceHttps?: boolean };\r\n components: ComponentDefinitionMap;\r\n entry: ComponentReference;\r\n breakpoints: { [name: string]: string };\r\n routing: RoutingSettings;\r\n views: { [name: string]: ViewDefinition };\r\n integrationResources: { path: string; mediaQueriesSupported: boolean }[];\r\n trigger?: { symbol?: Symbol; label?: string; action?: string };\r\n activate?: boolean | null;\r\n plugins?: { [key: string]: any };\r\n};\r\n\r\nexport type MinMax = {\r\n min: string;\r\n max: string;\r\n};\r\n\r\ntype Symbol = {\r\n type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;\r\n content: string;\r\n};\r\n\r\nexport enum WidgetRenderState {\r\n open = 'open',\r\n closed = 'closed',\r\n hidden = 'hidden',\r\n}\r\n"],"names":["ActionResolver","container","__publicField","events","target","action","value","origin","fn","e","createEventSubscriber","subs","type","listener","sub","ComponentQuery","platform","rules","node","rule","id","AbstractComponentController","ComponentNodeController","ns","ActionsController","subscribe","unsubscribe","updated","properties","event","options","context","layout","clearOnDispose","remove","executeActionListeners","listeners","data","controller","stack","dispatch","globalOptions","cancelled","handler","next","result","__spreadProps","__spreadValues","key","subscription","index","instances","output","handlers","matchedInstances","instance","watchers","watcher","input","handlerResponse","parsedKey","parsedNs","sections","componentConfigurationApi","createConfigurationApi","builder","config","ComponentNode","uuid","viewOutletContainer","element","mountedNodes","Logger","branch","removable","changeset","indexToRemove","children","acc","i","traverseComponentsRecursive","nodes","switches","y","traverseComponents","root","findVisibleComponents","findComponent","matched","ComponentNodeCollection","query","member","CustomComponentHandler","name","calculateNodeIndex","currentNode","sortQueue","queue","a","b","isObject","item","mergeDeep","sources","source","matchesBreakpoint","b1","b2","createStateProcessor","callback","nodeQueue","optionsQueue","timeout","flush","processHistory","sortedQueue","processNode","history","processContext","processProperties","processLayout","_a","propertyResolvers","layoutResolvers","contextResolvers","change","resolver","childOptions","child","schedule","summary","ComponentPlatform","widget","providers","report","record","removes","parentNode","providerName","attributes","provider","definitionType","normalizeReference","reference","definitionId","overrides","createChildren","references","definitions","views","ref","childRef","childDef","viewNode","viewDef","override","handle","childNode","createComponentModel","settings","entry","components","breakpoints","subscriptions","list","asDescriptor","extendComponent","typeOrQuery","collection","managedInstances","getOrCreateController","existing","dispose","ComponentResolver","alias","component","WidgetRenderState"],"mappings":";;;;;;;;;;;;;;;AASA,MAAqBA,GAAe;AAAA,EAGhC,YAAYC,GAAsB;AAF1B,IAAAC,EAAA;AAGJ,UAAM,EAAE,QAAAC,EAAmB,IAAAF,EAAU,IAAI,SAAS;AAC7C,SAAA,SAASE,EAAO,YAAY,IAAI;AAAA,EACzC;AAAA,EAEA,OAAOC,GAAgBC,GAAgBC,GAAkB;AAChD,SAAA,OAAO,SAAS,eAAe,EAAE,QAAAD,GAAQ,OAAAC,GAAO,QAAAF,KAAU,EAAE,SAAS,GAAM,CAAA;AAAA,EACpF;AAAA,EAEA,UAAUG,GAAgBC,GAA2C;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;AAChF,gBAAA,WAAW,IAAI/H,GAAK+H,CAAS,GAE7B,KAAA,OAAO,SAAS,8BAA8B/H,CAAG,GAE/C,MAAM;AACJ,WAAA,WAAW,OAAOA,CAAG;AAAA,IAAA;AAAA,EAElC;AAAA,EAEA,iBACIA,GACAxC,GAC6B;AAC7B,WAAO,KAAK,OAAO,UAAU,8BAA8B,CAACC,GAAG4B,MAAiB;AAC5E,UAAIA,MAASW,GAAK;AACR,cAAA+H,IAAY,KAAK,aAAa/H,CAAG;AACvC,QAAAxC,EAAGuK,CAAS;AAAA,MAChB;AAAA,IAAA,CACH;AAAA,EACL;AAAA,EAEA,cAAcD,GAAe9H,GAA4C;AAChE,gBAAA,QAAQ,IAAI8H,GAAO9H,CAAG,GAEtB,KAAA,OAAO,SAAS,8BAA8B8H,CAAK,GAEjD,MAAM;AACJ,WAAA,QAAQ,OAAOA,CAAK;AAAA,IAAA;AAAA,EAEjC;AACJ;ACCY,IAAAE,uBAAAA,OACRA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,SAAS,UAHDA,IAAAA,MAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"index.js","sources":["../src/action-resolver.ts","../src/event-subscriber.ts","../src/component-platform/component-query.ts","../src/component-platform/component-controller.ts","../src/component-platform/actions-controller.ts","../src/component-platform/component-configuration-api.ts","../src/component-platform/component-node.ts","../src/component-platform/queries.ts","../src/component-platform/component-node-collection.ts","../src/component-platform/custom-component-handler.ts","../src/component-platform/state-processor.ts","../src/component-platform/component-platform.ts","../src/component-platform/create-component-model.ts","../src/component-platform/descriptor.ts","../src/component-platform/extend-component.ts","../src/component-resolver.ts","../src/types/configuration.ts"],"sourcesContent":["import {\n Container,\n EventManager,\n EventSubscriptionCancellation,\n Widget,\n} from '@webprovisions/platform';\n\nexport type Action = (origin: string, action: string, value?: any) => void;\n\nexport default class ActionResolver {\n private events: EventManager;\n\n constructor(container: Container) {\n const { events }: Widget = container.get('$widget');\n this.events = events.createChild(this);\n }\n\n action(target: string, action: string, value: any): void {\n this.events.dispatch('data:action', { action, value, target }, { bubbles: true });\n }\n\n subscribe(origin: string, fn: Action): EventSubscriptionCancellation {\n return this.events.subscribe(\n 'data:action',\n (e, { action, value, target }) => origin === target && fn(origin, action, value)\n );\n }\n}\n","import {\n EventListener,\n EventManager,\n EventSubscriptionCancellation,\n} from '@webprovisions/platform';\n\nexport type SubscribeDelegate = (type: string, listener: EventListener) => void;\n\n/**\n * Creates s subscriber for the specified `EventManager` and provides a single cancellation\n * function for all registered subscriptions.\n */\nexport const createEventSubscriber = (\n events: EventManager\n): [SubscribeDelegate, EventSubscriptionCancellation] => {\n const subs: EventSubscriptionCancellation[] = [];\n\n const subscribe = (type: string, listener: EventListener) => {\n subs.push(events.subscribe(type, listener));\n };\n\n return [\n subscribe,\n () => {\n subs.forEach((sub) => {\n sub();\n });\n },\n ];\n};\n","import { AbstractComponentController } from './component-controller';\nimport { ComponentNode } from './component-node';\nimport { ComponentPlatform } from './component-platform';\n\nexport type ComponentQueryRule = {\n id?: string;\n type?: string;\n};\n\nexport class ComponentQuery {\n constructor(private platform: ComponentPlatform, public rules: ComponentQueryRule[] = []) {}\n\n match(node: ComponentNode) {\n return this.rules.every((rule) => {\n if (rule.id && rule.id !== node.id) {\n return false;\n }\n if (rule.type && rule.type !== node.type) {\n return false;\n }\n return true;\n });\n }\n\n ofType(type: string): ComponentQuery {\n this.rules.push({ type });\n return this;\n }\n\n withId(id: string): ComponentQuery {\n this.rules.push({ id });\n return this;\n }\n\n select(): AbstractComponentController {\n return new AbstractComponentController(this.platform, this);\n }\n}\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\nimport { createEventSubscriber, SubscribeDelegate } from '../event-subscriber';\nimport { ActionsController } from './actions-controller';\nimport {\n ChangesetOptions,\n ComponentNode,\n ComponentNodeContext,\n ComponentNodeLayout,\n ComponentNodeProperties,\n RemoveChangeset,\n} from './component-node';\nimport { ComponentPlatform } from './component-platform';\nimport { ComponentQuery } from './component-query';\n\nexport interface ComponentController {\n actions: ActionsController;\n\n writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;\n\n writeContext(context: Partial<ComponentNodeContext>, options: ChangesetOptions): void;\n\n writeLayout(context: Partial<ComponentNodeLayout>, options: ChangesetOptions): void;\n\n dispose(): void;\n}\n\nexport class ComponentNodeController implements ComponentController {\n actions: ActionsController;\n\n private subscribe: SubscribeDelegate;\n private unsubscribe: EventSubscriptionCancellation;\n\n constructor(private platform: ComponentPlatform, public node: ComponentNode, ns?: string) {\n this.actions = new ActionsController(\n platform,\n new ComponentQuery(platform).withId(node.id),\n ns\n );\n const [subscribe, unsubscribe] = createEventSubscriber(this.platform.events);\n this.subscribe = subscribe;\n this.unsubscribe = unsubscribe;\n }\n\n properties<T extends ComponentNodeProperties>(\n updated?: (properties: T) => void | Partial<ComponentNodeProperties>\n ): T {\n if (updated) {\n this.node.touchProperties((properties) => updated(<T>properties));\n }\n return <T>this.node.attributes.properties;\n }\n\n context(updated?: (context: ComponentNodeContext) => void): ComponentNodeContext {\n if (updated) {\n this.subscribe('components:context-changed', (event, { node }) => {\n if (node === this.node) {\n updated(this.node.attributes.context);\n }\n });\n }\n return this.node.attributes.context;\n }\n\n layout(updated?: (layout: ComponentNodeLayout) => void): ComponentNodeLayout {\n if (updated) {\n this.subscribe('components:layout-changed', (event, { node }) => {\n if (node === this.node) {\n updated(this.node.attributes.layout);\n }\n });\n }\n return this.node.attributes.layout;\n }\n\n writeProperties(\n properties:\n | Partial<ComponentNodeProperties>\n | ((properties: ComponentNodeProperties) => Partial<ComponentNodeProperties>),\n options?: ChangesetOptions\n ): void {\n this.node.writeProperties(properties, options);\n }\n\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\n this.node.writeProperties(context, options);\n }\n\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\n this.node.writeLayout(layout, options);\n }\n\n dispose() {\n this.unsubscribe();\n this.actions.dispose();\n }\n}\n\nexport class AbstractComponentController implements ComponentController {\n actions: ActionsController;\n private removes: RemoveChangeset[] = [];\n\n constructor(\n private platform: ComponentPlatform,\n private target: ComponentQuery,\n private clearOnDispose = true\n ) {\n this.actions = new ActionsController(this.platform, this.target);\n }\n\n writeProperties(\n properties: Partial<ComponentNodeProperties>,\n options?: ChangesetOptions\n ): void {\n this.removes.push(\n this.platform.write({\n options,\n attributes: { properties },\n target: this.target,\n removable: this.clearOnDispose,\n })\n );\n }\n\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\n this.removes.push(\n this.platform.write({\n options,\n attributes: { context },\n target: this.target,\n removable: this.clearOnDispose,\n })\n );\n }\n\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\n this.removes.push(\n this.platform.write({\n options,\n attributes: { layout },\n target: this.target,\n removable: this.clearOnDispose,\n })\n );\n }\n\n dispose() {\n this.removes.forEach((remove) => {\n remove();\n });\n this.actions.dispose();\n }\n}\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\nimport { ComponentNodeController } from './component-controller';\nimport { ComponentNode } from './component-node';\nimport { ComponentPlatform } from './component-platform';\nimport { ComponentQuery } from './component-query';\n\nexport type ActionData = any;\n\nexport type ActionHandler = (data: any, options: any, instance: ComponentNodeController) => any;\nexport type NextActionDelegate = (data: any, options?: any) => Promise<any>;\nexport type WatchActionDelegate = (\n input: ActionData,\n next: NextActionDelegate,\n instance: ComponentNodeController\n) => Promise<any> | any;\nexport type ActionWatcherContext = {\n source: ComponentNode;\n action: string;\n};\n\nexport type ActionsState = {\n handlers: {\n fn: ActionHandler;\n key: string;\n target: ComponentQuery;\n ns?: string;\n }[];\n\n watchers: {\n target: ComponentQuery;\n fn: WatchActionDelegate;\n key: string;\n ns?: string;\n }[];\n};\n\ntype ActionWatcherExecutionResult = {\n data: any;\n options: any;\n cancelled: boolean;\n};\n\nconst executeActionListeners = (\n listeners: WatchActionDelegate[],\n data: any,\n controller: ComponentNodeController\n): Promise<ActionWatcherExecutionResult> => {\n const stack = listeners.concat();\n const dispatch = (\n data: any,\n globalOptions: any,\n controller: ComponentNodeController\n ): Promise<ActionWatcherExecutionResult> => {\n let cancelled = true;\n if (stack.length) {\n const handler = stack.shift() as WatchActionDelegate;\n\n const next = (data: any, options: any) => {\n cancelled = false;\n return dispatch(data, Object.assign({}, globalOptions, options), controller);\n };\n\n return Promise.resolve(handler(data, next, controller)).then((result) => ({\n ...result,\n cancelled,\n }));\n }\n\n return Promise.resolve({ data, cancelled: false, options: globalOptions });\n };\n return dispatch(data, {}, controller);\n};\n\nexport class ActionsController {\n private subscriptions: (() => void)[] = [];\n constructor(\n private platform: ComponentPlatform,\n private target: ComponentQuery,\n private ns?: string\n ) {\n this.create = this.create.bind(this);\n }\n\n create(key: string, fn: ActionHandler = () => {}): EventSubscriptionCancellation {\n const handler = {\n key,\n fn,\n target: this.target,\n ns: this.ns,\n };\n this.platform.actionsState.handlers.push(handler);\n const subscription = () => {\n const index = this.platform.actionsState.handlers.indexOf(handler);\n if (index > -1) {\n this.platform.actionsState.handlers.splice(index, 1);\n }\n };\n this.subscriptions.push(subscription);\n return subscription;\n }\n\n dispatch(key: string, data: any): Promise<{ [instanceId: string]: any }> {\n const instances: ComponentNode[] = this.platform.nodes.all.concat(\n this.platform.nodes.detached\n );\n\n const output: { [instanceId: string]: any } = {};\n\n // handlers matching the specified pattern.\n const handlers = this.platform.actionsState.handlers.filter(\n (handler) => handler.key === key && (!handler.ns || !this.ns || handler.ns === this.ns)\n );\n\n return Promise.all(\n handlers.map((handler) => {\n // select all matching instances for this particular\n // handler (a handler can be mapped to many instances)\n const matchedInstances = instances.filter(\n (instance) => handler.target.match(instance) && this.target.match(instance)\n );\n\n // execute watchers for each matched instance\n const watchers = this.platform.actionsState.watchers\n .filter((watcher) => {\n return (\n watcher.key === key &&\n (!watcher.ns || !this.ns || watcher.ns === this.ns) &&\n matchedInstances.some((instance) => watcher.target.match(instance))\n );\n })\n .map((watcher) => watcher.fn);\n\n // execute watchers and handler for each instance\n return Promise.all(\n matchedInstances.map((node) => {\n const controller = new ComponentNodeController(\n this.platform,\n node,\n this.ns\n );\n return executeActionListeners(watchers, data, controller).then((input) => {\n const { data = {}, options, cancelled } = input;\n return Promise.resolve(\n cancelled ? {} : handler.fn(data, options, controller)\n ).then((handlerResponse) => {\n output[node.id] = handlerResponse;\n });\n });\n })\n );\n })\n ).then(() => output);\n }\n\n watch(key: string, fn: WatchActionDelegate): EventSubscriptionCancellation {\n let parsedKey = key;\n let parsedNs = this.ns;\n const sections = key.split('.');\n\n if (sections.length > 1) {\n parsedNs = sections[0];\n parsedKey = sections.splice(1).join('.');\n }\n const watcher = {\n fn,\n target: this.target,\n key: parsedKey,\n ns: parsedNs,\n };\n this.platform.actionsState.watchers.push(watcher);\n const subscription = () => {\n const index = this.platform.actionsState.watchers.indexOf(watcher);\n if (index > -1) {\n this.platform.actionsState.watchers.splice(index, 1);\n }\n };\n this.subscriptions.push(subscription);\n return subscription;\n }\n\n dispose() {\n this.subscriptions.forEach((unsubscribe) => unsubscribe());\n }\n}\n","import { createConfigurationApi } from '@webprovisions/platform';\nimport { CustomHandlerCallback } from './custom-component-handler';\n\ntype Options = {\n handlers?: [string, CustomHandlerCallback][];\n};\n\nexport default createConfigurationApi((builder) => {\n builder.createCommand('components', (context) => (config: Options) => {\n context.events.subscribeOnce('components:platform-created', (event, { platform }) => {\n if (config.handlers) {\n config.handlers.forEach(([key, handler]) => {\n platform.addComponentHandler(key, handler);\n });\n }\n });\n });\n});\n","import { Logger, uuid } from '@telia-ace/widget-utilities';\nimport { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';\nimport { Breakpoints } from '../types';\n\nexport type ComponentNodeEventData = { node: ComponentNode };\n\nexport type RemoveChangeset = () => void;\n\nexport type ComponentNodeAttributes = {\n tags: string[];\n properties: ComponentNodeProperties;\n context: ComponentNodeContext;\n layout: ComponentNodeLayout;\n};\n\nexport type ResolveComponentNodeProperties = (\n properties: ComponentNodeProperties\n) => Partial<ComponentNodeProperties> | void;\n\nexport type ResolveComponentNodeContext = (\n context: ComponentNodeContext\n) => Partial<ComponentNodeContext>;\n\nexport type ResolveComponentNodeLayout = (\n layout: ComponentNodeLayout\n) => Partial<ComponentNodeLayout>;\n\nexport type ComponentNodeSettings = {\n tags?: string[];\n properties?: ComponentNodeProperties | ResolveComponentNodeProperties;\n context?: ComponentNodeContext | ResolveComponentNodeContext;\n layout?: ComponentNodeLayout | ResolveComponentNodeLayout;\n};\n\nexport type ComponentNodeProperties = { [key: string]: any };\n\nexport type ComponentNodeContext = { [key: string]: any };\n\nexport type ComponentNodeLayout = {\n size?: Size;\n indent?: number;\n order?: number;\n};\n\nexport type Size = number | 'full' | 'none';\n\nexport type UnmountComponentNode = () => void;\n\nexport type ChangesetOptions = {\n breakpoints?: Breakpoints;\n};\n\nexport type Changeset = [Partial<ComponentNodeSettings>, ChangesetOptions];\n\nexport class ComponentNode {\n id: string;\n type: string;\n name?: string;\n parent?: ComponentNode;\n tags: string[] = [];\n children: { [key: string]: ComponentNode[] } = {};\n changesets: Changeset[] = [];\n attributes: ComponentNodeAttributes;\n\n private mountCount = 0;\n\n constructor(private events: EventManager, type: string) {\n this.id = uuid();\n this.type = type;\n this.attributes = {\n context: {},\n properties: {},\n layout: {},\n tags: [],\n };\n // write default attributes\n this.writeLayout({ size: 'full', indent: 0 });\n }\n\n mount(viewOutletContainer: Container, element?: HTMLElement): UnmountComponentNode {\n let mountedNodes: Map<ComponentNode, EventSubscriptionCancellation> =\n viewOutletContainer.get('mounted-nodes');\n\n if (!mountedNodes) {\n mountedNodes = new Map<ComponentNode, EventSubscriptionCancellation>();\n viewOutletContainer.register('mounted-nodes', mountedNodes);\n }\n\n if (mountedNodes.has(this)) {\n if (process.env.NODE_ENV !== 'production') {\n Logger.error('Trying to mount an already mounted component node.', this);\n }\n return () => {};\n }\n\n /**\n * Dispatched when a node is mounted in a component.\n * This happens once for every `ViewOutlet`.\n */\n this.events.dispatch('components:node-mounted', { node: this });\n\n if (this.mountCount === 0) {\n this.mountCount = this.mountCount + 1;\n /**\n * Dispatched when a node is mounted in a component the first time.\n */\n this.events.dispatch('components:node-enter', { node: this });\n }\n\n return () => {\n mountedNodes.delete(this);\n this.events.dispatch('components:node-unmounted', { node: this });\n\n this.mountCount = this.mountCount - 1;\n if (this.mountCount === 0) {\n this.events.dispatch('components:node-exit', { node: this });\n }\n };\n }\n\n appendChild(node: ComponentNode, branch: string = 'default') {\n if (node.parent) {\n if (node.parent === this) {\n return;\n }\n node.parent.removeChild(node);\n }\n node.parent = this;\n\n if (!this.children[branch]) {\n this.children[branch] = [];\n }\n this.children[branch].push(node);\n\n this.events.dispatch('components:node-appended', { node });\n }\n\n prependChild(node: ComponentNode, branch: string = 'default') {\n if (node.parent) {\n if (node.parent === this) {\n return;\n }\n node.parent.removeChild(node);\n }\n node.parent = this;\n\n if (!this.children[branch]) {\n this.children[branch] = [];\n }\n this.children[branch].unshift(node);\n\n this.events.dispatch('components:node-appended', { node });\n }\n\n touchProperties(\n properties: ResolveComponentNodeProperties,\n options: ChangesetOptions = {},\n removable?: boolean\n ): RemoveChangeset {\n const attributes: Partial<ComponentNodeSettings> = { properties };\n const changeset: Changeset = [attributes, options];\n this.changesets.push(changeset);\n this.events.dispatch('components:set-properties', { node: this });\n return () => {\n if (removable) {\n const indexToRemove = this.changesets.indexOf(changeset);\n if (indexToRemove > -1) {\n this.changesets.splice(indexToRemove, 1);\n this.events.dispatch('components:set-properties', { node: this });\n }\n }\n };\n }\n\n writeProperties(\n properties: Partial<ComponentNodeProperties> | ResolveComponentNodeProperties,\n options: ChangesetOptions = {},\n removable?: boolean\n ): RemoveChangeset {\n const attributes: Partial<ComponentNodeSettings> = { properties };\n const changeset: Changeset = [attributes, options];\n this.changesets.push(changeset);\n this.events.dispatch('components:set-properties', { node: this });\n return () => {\n if (removable) {\n const indexToRemove = this.changesets.indexOf(changeset);\n if (indexToRemove > -1) {\n this.changesets.splice(indexToRemove, 1);\n this.events.dispatch('components:set-properties', { node: this });\n }\n }\n };\n }\n\n writeLayout(\n layout: Partial<ComponentNodeLayout> | ResolveComponentNodeLayout,\n options: ChangesetOptions = {},\n removable?: boolean\n ): RemoveChangeset {\n const attributes: Partial<ComponentNodeSettings> = { layout };\n const changeset: Changeset = [attributes, options];\n this.changesets.push(changeset);\n this.events.dispatch('components:set-layout', { node: this });\n return () => {\n if (!removable) {\n return;\n }\n const indexToRemove = this.changesets.indexOf(changeset);\n if (indexToRemove > -1) {\n this.changesets.splice(indexToRemove, 1);\n this.events.dispatch('components:set-layout', { node: this });\n }\n };\n }\n\n writeContext(\n context: Partial<ComponentNodeContext> | ResolveComponentNodeContext,\n options: ChangesetOptions = {},\n removable?: boolean\n ): RemoveChangeset {\n const attributes: Partial<ComponentNodeSettings> = { context };\n const changeset: Changeset = [attributes, options];\n this.changesets.push(changeset);\n this.events.dispatch('components:set-context', { node: this });\n return () => {\n if (!removable) {\n return;\n }\n const indexToRemove = this.changesets.indexOf(changeset);\n if (indexToRemove > -1) {\n this.changesets.splice(indexToRemove, 1);\n this.events.dispatch('components:set-context', { node: this });\n }\n };\n }\n\n getChildren(branch: string = 'default'): ComponentNode[] {\n const children = this.children[branch] || [];\n return children.reduce((acc, node, i) => {\n const { order: index = i } = node.attributes.layout;\n if (!acc[index]) {\n acc[index] = node;\n } else {\n acc.splice(index, 0, node);\n }\n return acc;\n }, Array(children.length));\n }\n\n remove() {\n if (this.parent) {\n this.parent.removeChild(this);\n }\n }\n\n removeChild(node: ComponentNode) {\n Object.keys(this.children).forEach((branch) => {\n const children = this.children[branch];\n const indexToRemove = children.indexOf(node);\n if (indexToRemove > -1) {\n children.splice(indexToRemove, 1);\n this.events.dispatch('components:node-removed', { node, parentNode: this });\n }\n });\n delete node.parent;\n }\n}\n","import { ComponentNode } from './component-node';\nimport { SwitchMap } from './component-platform';\n\nconst traverseComponentsRecursive = (\n nodes: ComponentNode[],\n switches: SwitchMap,\n fn: (node: ComponentNode) => boolean | void\n) => {\n for (let i = 0, y = nodes.length; i < y; i++) {\n if (fn(nodes[i]) === true) {\n break;\n }\n const branch = switches[nodes[i].id] || 'default';\n const children = nodes[i].getChildren(branch);\n traverseComponentsRecursive(children, switches, fn);\n }\n};\n\nexport const traverseComponents = (\n root: ComponentNode,\n switches: SwitchMap,\n fn: (node: ComponentNode) => boolean | void\n) => {\n if (fn(root) !== true) {\n const branch = switches[root.id] || 'default';\n const children = root.children[branch];\n traverseComponentsRecursive(children, switches, fn);\n }\n};\n\nexport const findVisibleComponents = (\n root: ComponentNode,\n switches: SwitchMap\n): ComponentNode[] => {\n const nodes: ComponentNode[] = [];\n traverseComponents(root, switches, (node) => {\n nodes.push(node);\n });\n return nodes;\n};\n\nexport const findComponent = (\n root: ComponentNode,\n switches: SwitchMap,\n fn: (node: ComponentNode) => boolean\n) => {\n let matched: ComponentNode | undefined;\n traverseComponents(root, switches, (node) => {\n if (fn(node)) {\n matched = node;\n return true;\n }\n });\n return matched;\n};\n\nexport const getAncestors = (node: ComponentNode) => {\n if (!node.parent) {\n return [];\n }\n const tree: ComponentNode[] = [];\n let currentNode: ComponentNode | undefined = node.parent;\n while (currentNode) {\n tree.unshift(currentNode);\n currentNode = currentNode.parent;\n }\n return tree;\n};\n","import { EventManager } from '@webprovisions/platform';\nimport { ComponentNode, ComponentNodeEventData } from './component-node';\nimport { SwitchMap } from './component-platform';\nimport { findComponent, findVisibleComponents, traverseComponents } from './queries';\n\nexport type QueryDescriptor = {\n id?: string;\n type?: string;\n name?: string;\n};\n\nexport class ComponentNodeCollection {\n all: ComponentNode[] = [];\n visible: ComponentNode[] = [];\n detached: ComponentNode[] = [];\n\n constructor(public root: ComponentNode, private switches: SwitchMap, events: EventManager) {\n events.subscribe('components:node-appended', (event, data: ComponentNodeEventData) => {\n this.all.push(data.node);\n this.visible = findVisibleComponents(root, switches);\n });\n events.subscribe('components:node-removed', (event, data: ComponentNodeEventData) => {\n let indexToRemove = this.all.indexOf(data.node);\n if (indexToRemove > -1) {\n this.all.splice(indexToRemove, 1);\n }\n indexToRemove = this.visible.indexOf(data.node);\n if (indexToRemove > -1) {\n this.visible.splice(indexToRemove, 1);\n }\n this.visible = findVisibleComponents(root, switches);\n });\n events.subscribe('components:node-switched', (event, data: ComponentNodeEventData) => {\n this.visible = findVisibleComponents(root, switches);\n });\n }\n\n query(query: QueryDescriptor = {}): ComponentNode[] {\n const nodes: ComponentNode[] = [];\n traverseComponents(this.root, this.switches, (node) => {\n const match = Object.keys(query).every((member) => {\n return (<any>query)[member] === (<any>node)[member];\n });\n if (match) {\n nodes.push(node);\n }\n });\n return nodes;\n }\n\n get(id: string) {\n return (\n findComponent(this.root, this.switches, (node) => node.id === id) ||\n this.detached.find((node) => node.id === id)\n );\n }\n}\n","import { ComponentReference, ComponentSettings, ViewDefinition } from '../types';\nimport { ComponentNode } from './component-node';\nimport { ComponentPlatform } from './component-platform';\nimport { NormalizedComponentReference } from './create-component-model';\n\nexport type CustomHandlerCallback = (\n ref: NormalizedComponentReference,\n options: {\n platform: ComponentPlatform;\n node: ComponentNode;\n references: ComponentReference[];\n definitions: { [name: string]: ComponentSettings };\n views: { [key: string]: ViewDefinition };\n branch?: string;\n }\n) => void;\n\nexport class CustomComponentHandler {\n private handlers = new Map<string, CustomHandlerCallback>();\n\n add(name: string, fn: CustomHandlerCallback) {\n this.handlers.set(name, fn);\n }\n\n get(name: string) {\n return this.handlers.get(name);\n }\n}\n","import { ComponentPlatform } from '.';\nimport { Breakpoints } from '../types';\nimport {\n ComponentNode,\n ResolveComponentNodeContext,\n ResolveComponentNodeLayout,\n ResolveComponentNodeProperties,\n} from './component-node';\n\nexport type ProcessOptions = {\n context?: boolean;\n properties?: boolean;\n layout?: boolean;\n recursive?: boolean;\n};\n\nexport type StateProcessor = (node: ComponentNode, options: ProcessOptions) => void;\n\nconst calculateNodeIndex = (node: ComponentNode): number => {\n let currentNode = node;\n let index = 0;\n\n while (currentNode.parent) {\n index = index + 1;\n currentNode = currentNode.parent;\n }\n\n return index;\n};\n\nconst sortQueue = (queue: [ComponentNode, ProcessOptions][]): [ComponentNode, ProcessOptions][] => {\n const mapped: [number, ComponentNode, ProcessOptions][] = queue.map(([node, options]) => {\n return [calculateNodeIndex(node), node, options];\n });\n return mapped\n .sort(([a], [b]) => a - b)\n .map(([, node, options]) => {\n return [node, options];\n });\n};\n\nconst isObject = (item: any) => {\n return item && typeof item === 'object' && !Array.isArray(item);\n};\n\nconst mergeDeep = (target: any, ...sources: any[]): any => {\n if (!sources.length) return target;\n const source = sources.shift();\n\n if (isObject(target) && isObject(source)) {\n for (const key in source) {\n if (isObject(source[key])) {\n if (!target[key]) Object.assign(target, { [key]: {} });\n mergeDeep(target[key], source[key]);\n } else {\n Object.assign(target, { [key]: source[key] });\n }\n }\n }\n return mergeDeep(target, ...sources);\n};\n\nconst matchesBreakpoint = (b1: Breakpoints | undefined, b2: string[]) => {\n if (!b1 || b1 === 'all') {\n return true;\n }\n return b1.some((b1) => b2.indexOf(b1) > -1);\n};\n\nexport type ProcessResult = Map<ComponentNode, ProcessOptions>;\n\nexport type ProcessReportCallback = (report: ProcessResult) => void;\n\nexport const createStateProcessor = (\n platform: ComponentPlatform,\n callback: ProcessReportCallback\n): StateProcessor => {\n let nodeQueue: ComponentNode[] = [];\n let optionsQueue: ProcessOptions[] = [];\n\n let timeout: NodeJS.Timeout;\n\n const flush = () => {\n if (process.env.NODE_ENV !== 'production') {\n console.time('state-processor.flush');\n }\n const processHistory: Map<ComponentNode, ProcessOptions> = new Map();\n const sortedQueue = sortQueue(nodeQueue.map((node, i) => [node, optionsQueue[i]]));\n\n const processNode = (node: ComponentNode, options: ProcessOptions) => {\n const history = processHistory.get(node) || {};\n\n // todo: this doesnt take overrides into account\n const processContext = options.context && !history.context;\n const processProperties = options.properties && !history.properties;\n const processLayout = options.layout && !history.layout;\n\n processHistory.set(node, {\n context: history.context || processContext,\n properties: history.properties || processProperties,\n layout: history.layout || processLayout,\n });\n\n if (processProperties) {\n node.attributes.properties = {};\n }\n if (processLayout) {\n node.attributes.layout = {};\n }\n\n if (processContext) {\n node.attributes.context = mergeDeep({}, node.parent?.attributes.context);\n }\n\n const propertyResolvers: ResolveComponentNodeProperties[] = [];\n const layoutResolvers: ResolveComponentNodeLayout[] = [];\n const contextResolvers: ResolveComponentNodeContext[] = [];\n\n node.changesets.forEach((changeset) => {\n const [change, options] = changeset;\n if (matchesBreakpoint(options.breakpoints, platform.breakpoints)) {\n if (processProperties) {\n if (typeof change.properties === 'function') {\n propertyResolvers.push(\n <ResolveComponentNodeProperties>change.properties\n );\n } else {\n mergeDeep(node.attributes.properties, change.properties);\n }\n }\n\n if (processLayout) {\n if (typeof change.layout === 'function') {\n layoutResolvers.push(<ResolveComponentNodeLayout>change.layout);\n } else {\n mergeDeep(node.attributes.layout, change.layout);\n }\n }\n\n if (processContext) {\n if (typeof change.context === 'function') {\n contextResolvers.push(<ResolveComponentNodeContext>change.context);\n } else {\n mergeDeep(node.attributes.context, change.context);\n }\n }\n }\n });\n\n propertyResolvers.forEach((resolver) => {\n mergeDeep(node.attributes.properties, resolver(node.attributes.properties));\n });\n\n layoutResolvers.forEach((resolver) => {\n mergeDeep(node.attributes.layout, resolver(node.attributes.layout));\n });\n\n contextResolvers.forEach((resolver) => {\n mergeDeep(node.attributes.context, resolver(node.attributes.context));\n });\n\n if (processContext || options.recursive) {\n const branch = platform.getBranch(node);\n const childOptions: ProcessOptions = options.recursive\n ? options\n : {\n context: !!processContext,\n };\n node.getChildren(branch).forEach((child) => {\n processNode(child, childOptions);\n });\n }\n };\n\n if (process.env.NODE_ENV !== 'production') {\n console.timeEnd('state-processor.flush');\n }\n\n sortedQueue.forEach(([node, options]) => {\n processNode(node, options);\n });\n\n nodeQueue = [];\n optionsQueue = [];\n\n callback(processHistory);\n };\n\n const schedule = () => {\n clearTimeout(timeout);\n timeout = setTimeout(flush, 0);\n };\n\n return (node, options) => {\n const index = nodeQueue.indexOf(node);\n\n if (index > -1) {\n // if node already exist in queue, update its options\n const summary = optionsQueue[index];\n if (options.context) {\n summary.context = true;\n }\n if (options.properties) {\n summary.properties = true;\n }\n if (options.layout) {\n summary.layout = true;\n }\n if (options.recursive) {\n summary.recursive = true;\n }\n return schedule();\n }\n\n nodeQueue.push(node);\n optionsQueue.push(options);\n\n return schedule();\n };\n};\n","import { uuid } from '@telia-ace/widget-utilities';\nimport {\n Container,\n EventManager,\n EventSubscriptionCancellation,\n Widget,\n} from '@webprovisions/platform';\nimport { ActionsController, ActionsState } from './actions-controller';\nimport { ChangesetProvider } from './changeset-provider';\nimport {\n Changeset,\n ChangesetOptions,\n ComponentNode,\n ComponentNodeEventData,\n ComponentNodeSettings,\n RemoveChangeset,\n} from './component-node';\nimport { ComponentNodeCollection } from './component-node-collection';\nimport { ComponentQuery } from './component-query';\nimport { CustomComponentHandler, CustomHandlerCallback } from './custom-component-handler';\nimport { createStateProcessor, StateProcessor } from './state-processor';\n\nexport type MergeOptions = { breakpoints?: string[] };\n\ntype AbstractChangesetRecord = {\n changeset: Changeset;\n target: ComponentQuery;\n removes: RemoveChangeset[];\n};\n\nexport type SwitchMap = { [id: string]: string };\n\nexport type ChangesetData = {\n key?: string;\n target: ComponentQuery;\n attributes: Partial<ComponentNodeSettings>;\n options?: ChangesetOptions;\n removable?: boolean;\n provider?: string;\n};\n\nexport class ComponentPlatform {\n events: EventManager;\n breakpoints: string[] = [];\n nodes: ComponentNodeCollection;\n // internal\n actionsState: ActionsState = { handlers: [], watchers: [] };\n\n private switches: SwitchMap = {};\n private changesets: AbstractChangesetRecord[] = [];\n private subscriptions: EventSubscriptionCancellation[] = [];\n private processNode: StateProcessor;\n private customComponentHandler = new CustomComponentHandler();\n\n constructor(widget: Widget, private providers: { [key: string]: ChangesetProvider } = {}) {\n this.events = widget.events.createChild(this);\n const root = new ComponentNode(this.events, 'root');\n root.name = `root-${widget.name}`;\n this.nodes = new ComponentNodeCollection(root, this.switches, this.events);\n\n const processNode = (this.processNode = createStateProcessor(this, (report) => {\n const nodes = Array.from(report.keys());\n if (process.env.NODE_ENV !== 'production') {\n console.info(`STATE PROCESSOR: ${nodes.length} node(s) processed:\n${nodes.map(\n (node) => `${node.name || '<no name>'} (${node.id})\n`\n)}`);\n }\n nodes.forEach((node) => {\n const options = report.get(node);\n if (node.parent && node.parent.type === 'root') {\n this.events.dispatch('components:root-children-changed', { node });\n }\n if (options?.context) {\n this.events.dispatch('components:context-changed', { node });\n }\n if (options?.properties) {\n this.events.dispatch('components:properties-changed', { node });\n }\n if (options?.layout) {\n this.events.dispatch('components:layout-changed', { node });\n }\n });\n this.events.dispatch('components:component-model-initialized', {}, { bubbles: true });\n }));\n\n Promise.all(\n Object.keys(providers).map((key) => {\n const provider = providers[key];\n return provider.load(this);\n })\n );\n\n this.subscriptions.push(\n this.events.subscribe(\n 'components:node-appended',\n (event, data: ComponentNodeEventData) => {\n const { node } = data;\n this.changesets.forEach((record) => {\n const { changeset, target, removes } = record;\n const [change, options] = changeset;\n if (target.match(data.node)) {\n if (change.properties) {\n removes.push(node.writeProperties(change.properties, options));\n }\n if (change.context) {\n removes.push(node.writeContext(change.context, options));\n }\n if (change.layout) {\n removes.push(node.writeLayout(change.layout, options));\n }\n }\n });\n }\n )\n );\n this.subscriptions.push(\n this.events.subscribe(\n 'components:node-appended',\n (event, data: ComponentNodeEventData) => {\n processNode(data.node, { properties: true, context: true });\n }\n )\n );\n this.subscriptions.push(\n this.events.subscribe(\n 'components:set-properties',\n (event, data: ComponentNodeEventData) => {\n processNode(data.node, { properties: true });\n }\n )\n );\n this.subscriptions.push(\n this.events.subscribe(\n 'components:set-context',\n (event, data: ComponentNodeEventData) => {\n processNode(data.node, { properties: true, context: true });\n }\n )\n );\n this.subscriptions.push(\n this.events.subscribe(\n 'components:set-indent',\n (event, data: ComponentNodeEventData) => {\n processNode(data.node, { layout: true });\n }\n )\n );\n this.subscriptions.push(\n this.events.subscribe(\n 'components:set-layout',\n (event, data: ComponentNodeEventData) => {\n processNode(data.node, { layout: true });\n }\n )\n );\n this.subscriptions.push(\n this.events.subscribe('components:node-switched', (event, { node, branch }) => {\n processNode(node, {\n layout: true,\n recursive: true,\n properties: true,\n context: true,\n });\n })\n );\n this.subscriptions.push(\n this.events.subscribe('components:node-removed', (event, { parentNode }) => {\n processNode(parentNode, { properties: true });\n })\n );\n\n if (this.events.parent) {\n this.events.parent.dispatch('components:platform-created', { platform: this });\n }\n }\n\n static getInstance(container: Container): Promise<ComponentPlatform> {\n return container.getAsync('components');\n }\n\n addBreakpoint(name: string) {\n if (this.breakpoints.indexOf(name) === -1) {\n this.breakpoints.push(name);\n this.processNode(this.nodes.root, {\n context: true,\n properties: true,\n layout: true,\n recursive: true,\n });\n }\n }\n\n removeBreakpoint(name: string) {\n const indexToRemove = this.breakpoints.indexOf(name);\n if (indexToRemove > -1) {\n this.breakpoints.splice(indexToRemove, 1);\n this.processNode(this.nodes.root, {\n context: true,\n properties: true,\n layout: true,\n recursive: true,\n });\n }\n }\n\n setSwitch(node: ComponentNode, branch: string) {\n this.switches[node.id] = branch;\n this.events.dispatch('components:node-switched', { node, branch });\n }\n\n getBranch(node: ComponentNode): string | undefined {\n return this.switches[node.id];\n }\n\n /**\n * Creates a `ComponentNode` of the specified type.\n * @param type Type of node.\n */\n createNode(type: string, options: { detached?: boolean } = {}): ComponentNode {\n const node = new ComponentNode(this.events, type);\n if (options.detached) {\n this.nodes.detached.push(node);\n }\n return node;\n }\n\n components(): ComponentQuery {\n return new ComponentQuery(this);\n }\n\n actions(target: ComponentQuery, ns: string): ActionsController {\n return new ActionsController(this, <any>target, ns);\n }\n\n write(data: ChangesetData): RemoveChangeset {\n const { provider: providerName, target, attributes, options = {}, removable } = data;\n const key = data.key || uuid();\n const changeset: Changeset = [attributes, options];\n const record: AbstractChangesetRecord = { changeset, target, removes: [] };\n if (providerName) {\n const provider = this.providers[providerName];\n provider.write(key, target, attributes, options);\n record.removes.push(() => {\n provider.remove(key);\n });\n }\n\n this.changesets.push(record);\n this.nodes.all.forEach((node) => {\n if (target.match(node)) {\n let remove: RemoveChangeset = () => {};\n if (attributes.properties) {\n remove = node.writeProperties(attributes.properties, options, removable);\n }\n if (attributes.context) {\n remove = node.writeContext(attributes.context, options, removable);\n }\n if (attributes.layout) {\n remove = node.writeContext(attributes.layout, options, removable);\n }\n record.removes.push(remove);\n }\n });\n return () => {\n if (removable) {\n record.removes.forEach((remove) => remove());\n const indexToRemove = this.changesets.indexOf(record);\n if (indexToRemove > -1) {\n this.changesets.splice(indexToRemove, 1);\n }\n }\n };\n }\n\n addComponentHandler(definitionType: string, fn: CustomHandlerCallback) {\n this.customComponentHandler.add(definitionType, fn);\n }\n\n getComponentHandler(definitionType: string) {\n return this.customComponentHandler.get(definitionType);\n }\n\n dispose() {\n this.subscriptions.forEach((sub) => sub());\n }\n}\n","import { Logger } from '@telia-ace/widget-utilities';\nimport { EventSubscriptionCancellation } from '@webprovisions/platform';\nimport { Breakpoints, ComponentSettings, ViewDefinition, WidgetSettings } from '../types';\nimport {\n ComponentNode,\n ComponentNodeContext,\n ComponentNodeLayout,\n ComponentNodeProperties,\n} from './component-node';\nimport { ComponentPlatform } from './component-platform';\n\ntype ComponentReference = string | [string, ...ComponentReferenceOverride[]];\n\ntype ComponentReferenceOverride = {\n breakpoints?: Breakpoints;\n tags?: string[];\n context?: ComponentNodeContext;\n properties?: ComponentNodeProperties;\n layout?: ComponentNodeLayout;\n};\n\nexport type NormalizedComponentReference = {\n definitionId: string;\n overrides: ComponentReferenceOverride[];\n};\n\nexport const normalizeReference = (reference: ComponentReference): NormalizedComponentReference => {\n if (Array.isArray(reference)) {\n const [definitionId, ...overrides] = reference;\n return {\n definitionId,\n overrides,\n };\n }\n return {\n definitionId: reference,\n overrides: [],\n };\n};\n\nexport type ComponentHandlerOptions = {\n platform: ComponentPlatform;\n node: ComponentNode;\n references: ComponentReference[];\n definitions: { [name: string]: ComponentSettings };\n views: { [key: string]: ViewDefinition };\n branch?: string;\n};\n\nexport const createChildren = (\n platform: ComponentPlatform,\n node: ComponentNode,\n references: ComponentReference[],\n definitions: { [name: string]: ComponentSettings },\n views: { [key: string]: ViewDefinition },\n branch?: string\n) => {\n references.forEach((ref) => {\n const childRef = normalizeReference(ref);\n const childDef = definitions[childRef.definitionId];\n if (childRef.definitionId === 'view') {\n const viewNode = platform.createNode('view');\n viewNode.name = 'view';\n Object.keys(views).forEach((key) => {\n const viewDef = views[key];\n createChildren(platform, viewNode, [viewDef.entry], definitions, views, key);\n });\n node.appendChild(viewNode);\n\n childRef.overrides.forEach((override) => {\n if (override.properties) {\n viewNode.writeProperties(override.properties, {\n breakpoints: override.breakpoints,\n });\n }\n if (override.context) {\n viewNode.writeContext(override.context, { breakpoints: override.breakpoints });\n }\n if (override.layout) {\n viewNode.writeLayout(override.layout, { breakpoints: override.breakpoints });\n }\n });\n } else if (platform.getComponentHandler(childDef.type)) {\n const handle = platform.getComponentHandler(childDef.type);\n if (handle) {\n handle(childRef, {\n platform,\n node,\n references,\n definitions,\n views,\n branch,\n });\n }\n } else {\n const childDef = definitions[childRef.definitionId];\n if (process.env.NODE_ENV !== 'production') {\n if (!childDef) {\n Logger.error(\n `No definition found for component type '${childRef.definitionId}'.`\n );\n return;\n }\n }\n const childNode = platform.createNode(childDef.type);\n childNode.name = childRef.definitionId;\n childNode.tags = childDef.tags || [];\n if (childDef.properties) {\n childNode.writeProperties(childDef.properties);\n }\n if (childDef.context) {\n childNode.writeContext(childDef.context);\n }\n if (childDef.layout) {\n childNode.writeLayout(childDef.layout);\n }\n node.appendChild(childNode, branch);\n\n childRef.overrides.forEach((override) => {\n const options = { breakpoints: override.breakpoints };\n if (override.properties) {\n childNode.writeProperties(override.properties, options);\n }\n if (override.context) {\n childNode.writeContext(override.context, options);\n }\n if (override.layout) {\n childNode.writeLayout(override.layout, options);\n }\n });\n\n if (childDef.children) {\n createChildren(platform, childNode, childDef.children, definitions, views);\n }\n }\n });\n};\n\nexport const createComponentModel = (\n platform: ComponentPlatform,\n settings: WidgetSettings\n): EventSubscriptionCancellation => {\n const { entry, components, breakpoints, views } = settings;\n const subscriptions: EventSubscriptionCancellation[] = [];\n\n Object.keys(breakpoints).forEach((name) => {\n const query = breakpoints[name];\n const list = window.matchMedia(query);\n if (list.matches) {\n platform.breakpoints.push(name);\n }\n const listener = (event: MediaQueryListEvent) => {\n if (event.matches) {\n platform.addBreakpoint(name);\n } else {\n platform.removeBreakpoint(name);\n }\n };\n list.addListener(listener);\n subscriptions.push(() => list.removeListener(listener));\n });\n\n createChildren(platform, platform.nodes.root, [entry], components, views);\n\n return () =>\n subscriptions.forEach((sub) => {\n sub();\n });\n};\n","import { ComponentNode } from './component-node';\n\nexport type ComponentDescriptor = {\n id: string;\n type?: string;\n name?: string;\n branch: string;\n};\n\nexport const asDescriptor = (node: ComponentNode, branch?: string): ComponentDescriptor => {\n return {\n id: node.id,\n type: node.type,\n name: node.name,\n branch: branch || 'default',\n };\n};\n","import { uuid } from '@telia-ace/widget-utilities';\nimport { Container, EventSubscriptionCancellation } from '@webprovisions/platform';\nimport { ComponentNodeController } from './component-controller';\nimport { ComponentNode } from './component-node';\nimport { ComponentPlatform } from './component-platform';\nimport { ComponentQuery } from './component-query';\n\nexport type ExtendComponentHandler = (controller: ComponentNodeController) => any;\n\nexport type ExtendComponentOptions = {\n reuseController?: boolean;\n};\n\nexport const extendComponent = (\n container: Container,\n typeOrQuery: string | ComponentQuery,\n handler: ExtendComponentHandler,\n ns: string = uuid(),\n options: ExtendComponentOptions = {}\n): Promise<void> => {\n return container.getAsync('components').then((components: ComponentPlatform) => {\n let target: ComponentQuery;\n if (typeof typeOrQuery === 'string') {\n const collection = new ComponentQuery(components);\n collection.ofType(typeOrQuery);\n target = collection;\n } else {\n target = typeOrQuery;\n }\n\n const managedInstances: {\n [instanceId: string]: {\n dispose: EventSubscriptionCancellation;\n controller: ComponentNodeController;\n };\n } = {};\n\n const getOrCreateController = (node: ComponentNode): Promise<ComponentNodeController> => {\n const existing = managedInstances[node.id];\n if (existing) {\n return Promise.resolve(existing.controller);\n }\n return ComponentPlatform.getInstance(container).then((platform) => {\n return new ComponentNodeController(platform, node, ns);\n });\n };\n\n components.events.subscribe(\n 'components:node-enter',\n (event, { node }: { node: ComponentNode }) => {\n if (target.match(node)) {\n getOrCreateController(node).then((controller) => {\n Promise.resolve(handler(controller)).then((dispose) => {\n managedInstances[node.id] = {\n dispose,\n controller,\n };\n });\n });\n }\n }\n );\n components.events.subscribe(\n 'components:node-exit',\n (event, { node }: { node: ComponentNode }) => {\n const instance = managedInstances[node.id];\n if (instance) {\n instance.dispose && instance.dispose();\n if (!options.reuseController) {\n instance.controller.dispose();\n delete managedInstances[node.id];\n }\n }\n }\n );\n });\n};\n","import { Logger } from '@telia-ace/widget-utilities';\nimport {\n Container,\n EventManager,\n EventSubscriptionCancellation,\n WidgetType,\n} from '@webprovisions/platform';\n\nexport type ReactComponent = any | null;\n\nexport default class ComponentResolver {\n aliases: Map<string, string> = new Map();\n components: Map<string, any> = new Map();\n events: EventManager;\n logger = new Logger();\n\n constructor(container: Container) {\n const { events }: WidgetType = container.get('$widget');\n this.events = events;\n }\n\n getComponent(key: string): ReactComponent {\n const alias = this.aliases.get(key);\n const component = this.components.get(alias || key) || null;\n\n if (process.env.NODE_ENV !== 'production') {\n if (!component) {\n this.logger.warn(\n alias || key,\n `Unable to resolve component: \"${\n alias || key\n }\". You most likely forgot to register the required plugin for: ${\n alias || key\n }.`\n );\n }\n }\n\n return component;\n }\n\n registerComponent(key: string, component: ReactComponent): EventSubscriptionCancellation {\n this.components.set(key, component);\n\n this.events.dispatch('component-resolver:resolve', key);\n\n return () => {\n this.components.delete(key);\n };\n }\n\n registerResolver(\n key: string,\n fn: (component: ReactComponent) => void\n ): EventSubscriptionCancellation {\n return this.events.subscribe('component-resolver:resolve', (e, data: string) => {\n if (data === key) {\n const component = this.getComponent(key);\n fn(component);\n }\n });\n }\n\n registerAlias(alias: string, key: string): EventSubscriptionCancellation {\n this.aliases.set(alias, key);\n\n this.events.dispatch('component-resolver:resolve', alias);\n\n return () => {\n this.aliases.delete(alias);\n };\n }\n}\n","import { ComponentNodeLayout } from '../component-platform';\n\nexport type ComponentSettings = {\n type: string;\n context?: Context;\n properties?: Properties;\n layout?: ComponentNodeLayout;\n tags?: string[];\n children?: ComponentReference[];\n};\n\nenum HistoryMode {\n scopedHash = 'scopedHash',\n hash = 'hash',\n browser = 'browser',\n memory = 'memory',\n}\n\nexport type RoutingSettings = {\n initialPath: string;\n mode: HistoryMode;\n basePath?: string;\n};\n\nexport type ComponentReference = string | [string, ...ComponentReferenceOverride[]];\n\nexport type Properties = { [key: string]: any };\n\nexport type Context = { [key: string]: any };\n\nexport type ViewDefinition = {\n path: string | string[];\n entry: ComponentReference;\n};\n\nexport type Breakpoints = 'all' | string[];\n\nexport type ComponentReferenceOverride = {\n breakpoints?: Breakpoints;\n size?: number | 'full' | 'none';\n indent?: number;\n tags?: string[];\n context?: Context;\n properties?: Properties;\n};\n\nexport type ComponentDefinitionMap = {\n [name: string]: ComponentSettings;\n};\n\nexport type WidgetSettings = {\n data: { projection: string; site?: 'current' | 'referrer'; forceHttps?: boolean };\n components: ComponentDefinitionMap;\n entry: ComponentReference;\n breakpoints: { [name: string]: string };\n routing: RoutingSettings;\n views: { [name: string]: ViewDefinition };\n integrationResources: { path: string; mediaQueriesSupported: boolean }[];\n trigger?: { symbol?: Symbol; label?: string; action?: string };\n activate?: boolean | null;\n plugins?: { [key: string]: any };\n};\n\nexport type MinMax = {\n min: string;\n max: string;\n};\n\ntype Symbol = {\n type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;\n content: string;\n};\n\nexport enum WidgetRenderState {\n open = 'open',\n closed = 'closed',\n hidden = 'hidden',\n}\n"],"names":["ActionResolver","container","__publicField","events","target","action","value","origin","fn","e","createEventSubscriber","subs","type","listener","sub","ComponentQuery","platform","rules","node","rule","id","AbstractComponentController","ComponentNodeController","ns","ActionsController","subscribe","unsubscribe","updated","properties","event","options","context","layout","clearOnDispose","remove","executeActionListeners","listeners","data","controller","stack","dispatch","globalOptions","cancelled","handler","next","result","__spreadProps","__spreadValues","key","subscription","index","instances","output","handlers","matchedInstances","instance","watchers","watcher","input","handlerResponse","parsedKey","parsedNs","sections","componentConfigurationApi","createConfigurationApi","builder","config","ComponentNode","uuid","viewOutletContainer","element","mountedNodes","Logger","branch","removable","changeset","indexToRemove","children","acc","i","traverseComponentsRecursive","nodes","switches","y","traverseComponents","root","findVisibleComponents","findComponent","matched","ComponentNodeCollection","query","member","CustomComponentHandler","name","calculateNodeIndex","currentNode","sortQueue","queue","a","b","isObject","item","mergeDeep","sources","source","matchesBreakpoint","b1","b2","createStateProcessor","callback","nodeQueue","optionsQueue","timeout","flush","processHistory","sortedQueue","processNode","history","processContext","processProperties","processLayout","_a","propertyResolvers","layoutResolvers","contextResolvers","change","resolver","childOptions","child","schedule","summary","ComponentPlatform","widget","providers","report","record","removes","parentNode","providerName","attributes","provider","definitionType","normalizeReference","reference","definitionId","overrides","createChildren","references","definitions","views","ref","childRef","childDef","viewNode","viewDef","override","handle","childNode","createComponentModel","settings","entry","components","breakpoints","subscriptions","list","asDescriptor","extendComponent","typeOrQuery","collection","managedInstances","getOrCreateController","existing","dispose","ComponentResolver","alias","component","WidgetRenderState"],"mappings":";;;;;;;;;;;;;;;AASA,MAAqBA,GAAe;AAAA,EAGhC,YAAYC,GAAsB;AAF1B,IAAAC,EAAA;AAGJ,UAAM,EAAE,QAAAC,EAAmB,IAAAF,EAAU,IAAI,SAAS;AAC7C,SAAA,SAASE,EAAO,YAAY,IAAI;AAAA,EACzC;AAAA,EAEA,OAAOC,GAAgBC,GAAgBC,GAAkB;AAChD,SAAA,OAAO,SAAS,eAAe,EAAE,QAAAD,GAAQ,OAAAC,GAAO,QAAAF,KAAU,EAAE,SAAS,GAAM,CAAA;AAAA,EACpF;AAAA,EAEA,UAAUG,GAAgBC,GAA2C;AACjE,WAAO,KAAK,OAAO;AAAA,MACf;AAAA,MACA,CAACC,GAAG,EAAE,QAAAJ,GA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B/H,CAAG,GAE/C,MAAM;AACJ,WAAA,WAAW,OAAOA,CAAG;AAAA,IAAA;AAAA,EAElC;AAAA,EAEA,iBACIA,GACAxC,GAC6B;AAC7B,WAAO,KAAK,OAAO,UAAU,8BAA8B,CAACC,GAAG4B,MAAiB;AAC5E,UAAIA,MAASW,GAAK;AACR,cAAA+H,IAAY,KAAK,aAAa/H,CAAG;AACvC,QAAAxC,EAAGuK,CAAS;AAAA,MAChB;AAAA,IAAA,CACH;AAAA,EACL;AAAA,EAEA,cAAcD,GAAe9H,GAA4C;AAChE,gBAAA,QAAQ,IAAI8H,GAAO9H,CAAG,GAEtB,KAAA,OAAO,SAAS,8BAA8B8H,CAAK,GAEjD,MAAM;AACJ,WAAA,QAAQ,OAAOA,CAAK;AAAA,IAAA;AAAA,EAEjC;AACJ;ACCY,IAAAE,uBAAAA,OACRA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,SAAS,UAHDA,IAAAA,MAAA,CAAA,CAAA;"}
@@ -1,86 +1,86 @@
1
- import { ComponentNodeLayout } from '../component-platform';
2
- export declare type ComponentSettings = {
3
- type: string;
4
- context?: Context;
5
- properties?: Properties;
6
- layout?: ComponentNodeLayout;
7
- tags?: string[];
8
- children?: ComponentReference[];
9
- };
10
- declare enum HistoryMode {
11
- scopedHash = "scopedHash",
12
- hash = "hash",
13
- browser = "browser",
14
- memory = "memory"
15
- }
16
- export declare type RoutingSettings = {
17
- initialPath: string;
18
- mode: HistoryMode;
19
- basePath?: string;
20
- };
21
- export declare type ComponentReference = string | [string, ...ComponentReferenceOverride[]];
22
- export declare type Properties = {
23
- [key: string]: any;
24
- };
25
- export declare type Context = {
26
- [key: string]: any;
27
- };
28
- export declare type ViewDefinition = {
29
- path: string | string[];
30
- entry: ComponentReference;
31
- };
32
- export declare type Breakpoints = 'all' | string[];
33
- export declare type ComponentReferenceOverride = {
34
- breakpoints?: Breakpoints;
35
- size?: number | 'full' | 'none';
36
- indent?: number;
37
- tags?: string[];
38
- context?: Context;
39
- properties?: Properties;
40
- };
41
- export declare type ComponentDefinitionMap = {
42
- [name: string]: ComponentSettings;
43
- };
44
- export declare type WidgetSettings = {
45
- data: {
46
- projection: string;
47
- site?: 'current' | 'referrer';
48
- forceHttps?: boolean;
49
- };
50
- components: ComponentDefinitionMap;
51
- entry: ComponentReference;
52
- breakpoints: {
53
- [name: string]: string;
54
- };
55
- routing: RoutingSettings;
56
- views: {
57
- [name: string]: ViewDefinition;
58
- };
59
- integrationResources: {
60
- path: string;
61
- mediaQueriesSupported: boolean;
62
- }[];
63
- trigger?: {
64
- symbol?: Symbol;
65
- label?: string;
66
- action?: string;
67
- };
68
- activate?: boolean | null;
69
- plugins?: {
70
- [key: string]: any;
71
- };
72
- };
73
- export declare type MinMax = {
74
- min: string;
75
- max: string;
76
- };
77
- declare type Symbol = {
78
- type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;
79
- content: string;
80
- };
81
- export declare enum WidgetRenderState {
82
- open = "open",
83
- closed = "closed",
84
- hidden = "hidden"
85
- }
86
- export {};
1
+ import { ComponentNodeLayout } from '../component-platform';
2
+ export declare type ComponentSettings = {
3
+ type: string;
4
+ context?: Context;
5
+ properties?: Properties;
6
+ layout?: ComponentNodeLayout;
7
+ tags?: string[];
8
+ children?: ComponentReference[];
9
+ };
10
+ declare enum HistoryMode {
11
+ scopedHash = "scopedHash",
12
+ hash = "hash",
13
+ browser = "browser",
14
+ memory = "memory"
15
+ }
16
+ export declare type RoutingSettings = {
17
+ initialPath: string;
18
+ mode: HistoryMode;
19
+ basePath?: string;
20
+ };
21
+ export declare type ComponentReference = string | [string, ...ComponentReferenceOverride[]];
22
+ export declare type Properties = {
23
+ [key: string]: any;
24
+ };
25
+ export declare type Context = {
26
+ [key: string]: any;
27
+ };
28
+ export declare type ViewDefinition = {
29
+ path: string | string[];
30
+ entry: ComponentReference;
31
+ };
32
+ export declare type Breakpoints = 'all' | string[];
33
+ export declare type ComponentReferenceOverride = {
34
+ breakpoints?: Breakpoints;
35
+ size?: number | 'full' | 'none';
36
+ indent?: number;
37
+ tags?: string[];
38
+ context?: Context;
39
+ properties?: Properties;
40
+ };
41
+ export declare type ComponentDefinitionMap = {
42
+ [name: string]: ComponentSettings;
43
+ };
44
+ export declare type WidgetSettings = {
45
+ data: {
46
+ projection: string;
47
+ site?: 'current' | 'referrer';
48
+ forceHttps?: boolean;
49
+ };
50
+ components: ComponentDefinitionMap;
51
+ entry: ComponentReference;
52
+ breakpoints: {
53
+ [name: string]: string;
54
+ };
55
+ routing: RoutingSettings;
56
+ views: {
57
+ [name: string]: ViewDefinition;
58
+ };
59
+ integrationResources: {
60
+ path: string;
61
+ mediaQueriesSupported: boolean;
62
+ }[];
63
+ trigger?: {
64
+ symbol?: Symbol;
65
+ label?: string;
66
+ action?: string;
67
+ };
68
+ activate?: boolean | null;
69
+ plugins?: {
70
+ [key: string]: any;
71
+ };
72
+ };
73
+ export declare type MinMax = {
74
+ min: string;
75
+ max: string;
76
+ };
77
+ declare type Symbol = {
78
+ type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;
79
+ content: string;
80
+ };
81
+ export declare enum WidgetRenderState {
82
+ open = "open",
83
+ closed = "closed",
84
+ hidden = "hidden"
85
+ }
86
+ export {};