@telia-ace/widget-core 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/{lib-esm → dist}/action-resolver.d.ts +0 -0
  2. package/{lib-esm → dist}/component-platform/actions-controller.d.ts +0 -0
  3. package/{lib-esm → dist}/component-platform/changeset-provider.d.ts +0 -0
  4. package/{lib-esm → dist}/component-platform/component-configuration-api.d.ts +0 -0
  5. package/{lib-esm → dist}/component-platform/component-controller.d.ts +0 -0
  6. package/{lib-esm → dist}/component-platform/component-node-collection.d.ts +0 -0
  7. package/{lib-esm → dist}/component-platform/component-node.d.ts +0 -0
  8. package/{lib-esm → dist}/component-platform/component-platform.d.ts +0 -0
  9. package/{lib-esm → dist}/component-platform/component-query.d.ts +0 -0
  10. package/{lib-esm → dist}/component-platform/create-component-model.d.ts +0 -0
  11. package/{lib-esm → dist}/component-platform/custom-component-handler.d.ts +0 -0
  12. package/{lib-esm → dist}/component-platform/descriptor.d.ts +0 -0
  13. package/{lib-esm → dist}/component-platform/extend-component.d.ts +0 -0
  14. package/{lib-esm → dist}/component-platform/index.d.ts +0 -0
  15. package/{lib-esm → dist}/component-platform/queries.d.ts +0 -0
  16. package/{lib-esm → dist}/component-platform/state-processor.d.ts +0 -0
  17. package/{lib-esm → dist}/component-resolver.d.ts +0 -0
  18. package/{lib-esm → dist}/event-subscriber.d.ts +0 -0
  19. package/{lib-esm → dist}/index.d.ts +0 -0
  20. package/dist/index.js +1047 -0
  21. package/dist/index.js.map +1 -0
  22. package/{lib-esm → dist}/types/configuration.d.ts +0 -0
  23. package/{lib-esm → dist}/types/index.d.ts +0 -0
  24. package/{lib-esm → dist}/types/ui.d.ts +0 -0
  25. package/package.json +9 -9
  26. package/lib/action-resolver.d.ts +0 -8
  27. package/lib/action-resolver.js +0 -19
  28. package/lib/component-platform/actions-controller.d.ts +0 -40
  29. package/lib/component-platform/actions-controller.js +0 -119
  30. package/lib/component-platform/changeset-provider.d.ts +0 -8
  31. package/lib/component-platform/changeset-provider.js +0 -2
  32. package/lib/component-platform/component-configuration-api.d.ts +0 -2
  33. package/lib/component-platform/component-configuration-api.js +0 -32
  34. package/lib/component-platform/component-controller.d.ts +0 -38
  35. package/lib/component-platform/component-controller.js +0 -119
  36. package/lib/component-platform/component-node-collection.d.ts +0 -18
  37. package/lib/component-platform/component-node-collection.js +0 -51
  38. package/lib/component-platform/component-node.d.ts +0 -63
  39. package/lib/component-platform/component-node.js +0 -190
  40. package/lib/component-platform/component-platform.d.ts +0 -54
  41. package/lib/component-platform/component-platform.js +0 -220
  42. package/lib/component-platform/component-query.d.ts +0 -16
  43. package/lib/component-platform/component-query.js +0 -35
  44. package/lib/component-platform/create-component-model.d.ts +0 -36
  45. package/lib/component-platform/create-component-model.js +0 -141
  46. package/lib/component-platform/custom-component-handler.d.ts +0 -21
  47. package/lib/component-platform/custom-component-handler.js +0 -16
  48. package/lib/component-platform/descriptor.d.ts +0 -8
  49. package/lib/component-platform/descriptor.js +0 -12
  50. package/lib/component-platform/extend-component.d.ts +0 -8
  51. package/lib/component-platform/extend-component.js +0 -57
  52. package/lib/component-platform/index.d.ts +0 -18
  53. package/lib/component-platform/index.js +0 -30
  54. package/lib/component-platform/queries.d.ts +0 -6
  55. package/lib/component-platform/queries.js +0 -53
  56. package/lib/component-platform/state-processor.d.ts +0 -12
  57. package/lib/component-platform/state-processor.js +0 -209
  58. package/lib/component-resolver.d.ts +0 -14
  59. package/lib/component-resolver.js +0 -49
  60. package/lib/event-subscriber.d.ts +0 -7
  61. package/lib/event-subscriber.js +0 -22
  62. package/lib/index.d.ts +0 -8
  63. package/lib/index.js +0 -41
  64. package/lib/types/configuration.d.ts +0 -86
  65. package/lib/types/configuration.js +0 -16
  66. package/lib/types/index.d.ts +0 -2
  67. package/lib/types/index.js +0 -18
  68. package/lib/types/ui.d.ts +0 -54
  69. package/lib/types/ui.js +0 -2
  70. package/lib-esm/action-resolver.js +0 -17
  71. package/lib-esm/component-platform/actions-controller.js +0 -116
  72. package/lib-esm/component-platform/changeset-provider.js +0 -1
  73. package/lib-esm/component-platform/component-configuration-api.js +0 -30
  74. package/lib-esm/component-platform/component-controller.js +0 -116
  75. package/lib-esm/component-platform/component-node-collection.js +0 -48
  76. package/lib-esm/component-platform/component-node.js +0 -187
  77. package/lib-esm/component-platform/component-platform.js +0 -217
  78. package/lib-esm/component-platform/component-query.js +0 -32
  79. package/lib-esm/component-platform/create-component-model.js +0 -135
  80. package/lib-esm/component-platform/custom-component-handler.js +0 -13
  81. package/lib-esm/component-platform/descriptor.js +0 -8
  82. package/lib-esm/component-platform/extend-component.js +0 -53
  83. package/lib-esm/component-platform/index.js +0 -10
  84. package/lib-esm/component-platform/queries.js +0 -46
  85. package/lib-esm/component-platform/state-processor.js +0 -205
  86. package/lib-esm/component-resolver.js +0 -47
  87. package/lib-esm/event-subscriber.js +0 -18
  88. package/lib-esm/index.js +0 -5
  89. package/lib-esm/types/configuration.js +0 -13
  90. package/lib-esm/types/index.js +0 -2
  91. package/lib-esm/types/ui.js +0 -1
@@ -0,0 +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":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AASA,MAAqB,eAAe;AAAA,EAGhC,YAAY,WAAsB;AAC9B,UAAM,EAAE,WAAmB,UAAU,IAAI,SAAS;AAC7C,SAAA,SAAS,OAAO,YAAY,IAAI;AAAA,EACzC;AAAA,EAEA,OAAO,QAAgB,QAAgB,OAAkB;AAChD,SAAA,OAAO,SAAS,eAAe,EAAE,QAAQ,OAAO,UAAU,EAAE,SAAS,KAAM,CAAA;AAAA,EACpF;AAAA,EAEA,UAAU,QAAgB,IAA2C;AACjE,WAAO,KAAK,OAAO,UACf,eACA,CAAC,GAAG,EAAE,QAAQ,OAAO,aAAa,WAAW,UAAU,GAAG,QAAQ,QAAQ,KAAK,CACnF;AAAA,EACJ;AACJ;ACfa,MAAA,wBAAwB,CACjC,WACqD;AACrD,QAAM,OAAwC,CAAA;AAExC,QAAA,YAAY,CAAC,MAAc,aAA4B;AACzD,SAAK,KAAK,OAAO,UAAU,MAAM,QAAQ,CAAC;AAAA,EAAA;AAGvC,SAAA;AAAA,IACH;AAAA,IACA,MAAM;AACG,WAAA,QAAQ,CAAC,QAAQ;AACd;MAAA,CACP;AAAA,IACL;AAAA,EAAA;AAER;ACpBO,MAAM,eAAe;AAAA,EACxB,YAAoB,UAAo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AAExD,WAAO,MAAM;AACJ,WAAA,QAAQ,OAAO,KAAK;AAAA,IAAA;AAAA,EAEjC;AACJ;ACCY,IAAA,sCAAA,uBAAL;AACI,qBAAA,UAAA;AACE,qBAAA,YAAA;AACA,qBAAA,YAAA;AAHD,SAAA;AAAA,GAAA,qBAAA,CAAA,CAAA;;"}
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,33 +1,33 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-core",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Core framework for ACE widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
7
7
  "keywords": [
8
8
  "telia"
9
9
  ],
10
- "main": "lib/index.js",
11
- "module": "lib-esm/index.js",
10
+ "module": "dist/index.js",
11
+ "types": "dist/index.d.ts",
12
12
  "files": [
13
13
  "LICENSE.txt",
14
14
  "README.md",
15
- "lib/",
16
- "lib-esm/"
15
+ "dist/"
17
16
  ],
18
17
  "publishConfig": {
19
18
  "access": "public"
20
19
  },
21
20
  "scripts": {
22
- "clean": "cleandir lib && cleandir lib-esm",
23
- "compile": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.esm.json && node scripts/print-version.js"
21
+ "clean": "rimraf ./dist",
22
+ "precompile": "tsc -emitDeclarationOnly",
23
+ "compile": "vite build",
24
+ "postcompile": "node scripts/print-version.js"
24
25
  },
25
26
  "sideEffects": false,
26
- "typings": "lib/index.d.ts",
27
27
  "dependencies": {
28
28
  "@telia-ace/widget-utilities": "^1.0.1",
29
29
  "@webprovisions/bootstrapping": "^1.0.12",
30
30
  "@webprovisions/platform": "^1.1.2"
31
31
  },
32
- "gitHead": "34cb85e421c0c4a5bd08ccd899291683a11b3cf9"
32
+ "gitHead": "bdce2ebc96e3f9f92bf2d385b841bce5293f355f"
33
33
  }
@@ -1,8 +0,0 @@
1
- import { Container, EventSubscriptionCancellation } from '@webprovisions/platform';
2
- export declare type Action = (origin: string, action: string, value?: any) => void;
3
- export default class ActionResolver {
4
- private events;
5
- constructor(container: Container);
6
- action(target: string, action: string, value: any): void;
7
- subscribe(origin: string, fn: Action): EventSubscriptionCancellation;
8
- }
@@ -1,19 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- var ActionResolver = /** @class */ (function () {
4
- function ActionResolver(container) {
5
- var events = container.get('$widget').events;
6
- this.events = events.createChild(this);
7
- }
8
- ActionResolver.prototype.action = function (target, action, value) {
9
- this.events.dispatch('data:action', { action: action, value: value, target: target }, { bubbles: true });
10
- };
11
- ActionResolver.prototype.subscribe = function (origin, fn) {
12
- return this.events.subscribe('data:action', function (e, _a) {
13
- var action = _a.action, value = _a.value, target = _a.target;
14
- return origin === target && fn(origin, action, value);
15
- });
16
- };
17
- return ActionResolver;
18
- }());
19
- exports.default = ActionResolver;
@@ -1,40 +0,0 @@
1
- import { EventSubscriptionCancellation } from '@webprovisions/platform';
2
- import { ComponentNodeController } from './component-controller';
3
- import { ComponentNode } from './component-node';
4
- import { ComponentPlatform } from './component-platform';
5
- import { ComponentQuery } from './component-query';
6
- export declare type ActionData = any;
7
- export declare type ActionHandler = (data: any, options: any, instance: ComponentNodeController) => any;
8
- export declare type NextActionDelegate = (data: any, options?: any) => Promise<any>;
9
- export declare type WatchActionDelegate = (input: ActionData, next: NextActionDelegate, instance: ComponentNodeController) => Promise<any> | any;
10
- export declare type ActionWatcherContext = {
11
- source: ComponentNode;
12
- action: string;
13
- };
14
- export declare type ActionsState = {
15
- handlers: {
16
- fn: ActionHandler;
17
- key: string;
18
- target: ComponentQuery;
19
- ns?: string;
20
- }[];
21
- watchers: {
22
- target: ComponentQuery;
23
- fn: WatchActionDelegate;
24
- key: string;
25
- ns?: string;
26
- }[];
27
- };
28
- export declare class ActionsController {
29
- private platform;
30
- private target;
31
- private ns?;
32
- private subscriptions;
33
- constructor(platform: ComponentPlatform, target: ComponentQuery, ns?: string | undefined);
34
- create(key: string, fn?: ActionHandler): EventSubscriptionCancellation;
35
- dispatch(key: string, data: any): Promise<{
36
- [instanceId: string]: any;
37
- }>;
38
- watch(key: string, fn: WatchActionDelegate): EventSubscriptionCancellation;
39
- dispose(): void;
40
- }
@@ -1,119 +0,0 @@
1
- "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.ActionsController = void 0;
15
- var component_controller_1 = require("./component-controller");
16
- var executeActionListeners = function (listeners, data, controller) {
17
- var stack = listeners.concat();
18
- var dispatch = function (data, globalOptions, controller) {
19
- var cancelled = true;
20
- if (stack.length) {
21
- var handler = stack.shift();
22
- var next = function (data, options) {
23
- cancelled = false;
24
- return dispatch(data, Object.assign({}, globalOptions, options), controller);
25
- };
26
- return Promise.resolve(handler(data, next, controller)).then(function (result) { return (__assign(__assign({}, result), { cancelled: cancelled })); });
27
- }
28
- return Promise.resolve({ data: data, cancelled: false, options: globalOptions });
29
- };
30
- return dispatch(data, {}, controller);
31
- };
32
- var ActionsController = /** @class */ (function () {
33
- function ActionsController(platform, target, ns) {
34
- this.platform = platform;
35
- this.target = target;
36
- this.ns = ns;
37
- this.subscriptions = [];
38
- this.create = this.create.bind(this);
39
- }
40
- ActionsController.prototype.create = function (key, fn) {
41
- var _this = this;
42
- if (fn === void 0) { fn = function () { }; }
43
- var handler = {
44
- key: key,
45
- fn: fn,
46
- target: this.target,
47
- ns: this.ns,
48
- };
49
- this.platform.actionsState.handlers.push(handler);
50
- var subscription = function () {
51
- var index = _this.platform.actionsState.handlers.indexOf(handler);
52
- if (index > -1) {
53
- _this.platform.actionsState.handlers.splice(index, 1);
54
- }
55
- };
56
- this.subscriptions.push(subscription);
57
- return subscription;
58
- };
59
- ActionsController.prototype.dispatch = function (key, data) {
60
- var _this = this;
61
- var instances = this.platform.nodes.all.concat(this.platform.nodes.detached);
62
- var output = {};
63
- // handlers matching the specified pattern.
64
- var handlers = this.platform.actionsState.handlers.filter(function (handler) { return handler.key === key && (!handler.ns || !_this.ns || handler.ns === _this.ns); });
65
- return Promise.all(handlers.map(function (handler) {
66
- // select all matching instances for this particular
67
- // handler (a handler can be mapped to many instances)
68
- var matchedInstances = instances.filter(function (instance) { return handler.target.match(instance) && _this.target.match(instance); });
69
- // execute watchers for each matched instance
70
- var watchers = _this.platform.actionsState.watchers
71
- .filter(function (watcher) {
72
- return (watcher.key === key &&
73
- (!watcher.ns || !_this.ns || watcher.ns === _this.ns) &&
74
- matchedInstances.some(function (instance) { return watcher.target.match(instance); }));
75
- })
76
- .map(function (watcher) { return watcher.fn; });
77
- // execute watchers and handler for each instance
78
- return Promise.all(matchedInstances.map(function (node) {
79
- var controller = new component_controller_1.ComponentNodeController(_this.platform, node, _this.ns);
80
- return executeActionListeners(watchers, data, controller).then(function (input) {
81
- var _a = input.data, data = _a === void 0 ? {} : _a, options = input.options, cancelled = input.cancelled;
82
- return Promise.resolve(cancelled ? {} : handler.fn(data, options, controller)).then(function (handlerResponse) {
83
- output[node.id] = handlerResponse;
84
- });
85
- });
86
- }));
87
- })).then(function () { return output; });
88
- };
89
- ActionsController.prototype.watch = function (key, fn) {
90
- var _this = this;
91
- var parsedKey = key;
92
- var parsedNs = this.ns;
93
- var sections = key.split('.');
94
- if (sections.length > 1) {
95
- parsedNs = sections[0];
96
- parsedKey = sections.splice(1).join('.');
97
- }
98
- var watcher = {
99
- fn: fn,
100
- target: this.target,
101
- key: parsedKey,
102
- ns: parsedNs,
103
- };
104
- this.platform.actionsState.watchers.push(watcher);
105
- var subscription = function () {
106
- var index = _this.platform.actionsState.watchers.indexOf(watcher);
107
- if (index > -1) {
108
- _this.platform.actionsState.watchers.splice(index, 1);
109
- }
110
- };
111
- this.subscriptions.push(subscription);
112
- return subscription;
113
- };
114
- ActionsController.prototype.dispose = function () {
115
- this.subscriptions.forEach(function (unsubscribe) { return unsubscribe(); });
116
- };
117
- return ActionsController;
118
- }());
119
- exports.ActionsController = ActionsController;
@@ -1,8 +0,0 @@
1
- import { ChangesetOptions, ComponentNodeSettings } from './component-node';
2
- import { ComponentPlatform } from './component-platform';
3
- import { ComponentQuery } from './component-query';
4
- export interface ChangesetProvider {
5
- write: (key: string, target: ComponentQuery, attributes: Partial<ComponentNodeSettings>, options: ChangesetOptions) => void;
6
- remove: (key: string) => void;
7
- load: (platform: ComponentPlatform) => Promise<any>;
8
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- declare const _default: import("@webprovisions/platform").ConfigurationApiDefinition;
2
- export default _default;
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __read = (this && this.__read) || function (o, n) {
3
- var m = typeof Symbol === "function" && o[Symbol.iterator];
4
- if (!m) return o;
5
- var i = m.call(o), r, ar = [], e;
6
- try {
7
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
8
- }
9
- catch (error) { e = { error: error }; }
10
- finally {
11
- try {
12
- if (r && !r.done && (m = i["return"])) m.call(i);
13
- }
14
- finally { if (e) throw e.error; }
15
- }
16
- return ar;
17
- };
18
- Object.defineProperty(exports, "__esModule", { value: true });
19
- var platform_1 = require("@webprovisions/platform");
20
- exports.default = (0, platform_1.createConfigurationApi)(function (builder) {
21
- builder.createCommand('components', function (context) { return function (config) {
22
- context.events.subscribeOnce('components:platform-created', function (event, _a) {
23
- var platform = _a.platform;
24
- if (config.handlers) {
25
- config.handlers.forEach(function (_a) {
26
- var _b = __read(_a, 2), key = _b[0], handler = _b[1];
27
- platform.addComponentHandler(key, handler);
28
- });
29
- }
30
- });
31
- }; });
32
- });
@@ -1,38 +0,0 @@
1
- import { ActionsController } from './actions-controller';
2
- import { ChangesetOptions, ComponentNode, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties } from './component-node';
3
- import { ComponentPlatform } from './component-platform';
4
- import { ComponentQuery } from './component-query';
5
- export interface ComponentController {
6
- actions: ActionsController;
7
- writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;
8
- writeContext(context: Partial<ComponentNodeContext>, options: ChangesetOptions): void;
9
- writeLayout(context: Partial<ComponentNodeLayout>, options: ChangesetOptions): void;
10
- dispose(): void;
11
- }
12
- export declare class ComponentNodeController implements ComponentController {
13
- private platform;
14
- node: ComponentNode;
15
- actions: ActionsController;
16
- private subscribe;
17
- private unsubscribe;
18
- constructor(platform: ComponentPlatform, node: ComponentNode, ns?: string);
19
- properties<T extends ComponentNodeProperties>(updated?: (properties: T) => void | Partial<ComponentNodeProperties>): T;
20
- context(updated?: (context: ComponentNodeContext) => void): ComponentNodeContext;
21
- layout(updated?: (layout: ComponentNodeLayout) => void): ComponentNodeLayout;
22
- writeProperties(properties: Partial<ComponentNodeProperties> | ((properties: ComponentNodeProperties) => Partial<ComponentNodeProperties>), options?: ChangesetOptions): void;
23
- writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void;
24
- writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void;
25
- dispose(): void;
26
- }
27
- export declare class AbstractComponentController implements ComponentController {
28
- private platform;
29
- private target;
30
- private clearOnDispose;
31
- actions: ActionsController;
32
- private removes;
33
- constructor(platform: ComponentPlatform, target: ComponentQuery, clearOnDispose?: boolean);
34
- writeProperties(properties: Partial<ComponentNodeProperties>, options?: ChangesetOptions): void;
35
- writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void;
36
- writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void;
37
- dispose(): void;
38
- }