@telia-ace/widget-core 1.0.1 → 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 (89) hide show
  1. package/LICENSE.txt +5 -5
  2. package/README.md +3 -3
  3. package/{lib-esm → dist}/action-resolver.d.ts +0 -0
  4. package/{lib-esm → dist}/component-platform/actions-controller.d.ts +0 -0
  5. package/{lib-esm → dist}/component-platform/changeset-provider.d.ts +0 -0
  6. package/dist/component-platform/component-configuration-api.d.ts +2 -0
  7. package/{lib-esm → dist}/component-platform/component-controller.d.ts +0 -0
  8. package/{lib-esm → dist}/component-platform/component-node-collection.d.ts +0 -0
  9. package/{lib-esm → dist}/component-platform/component-node.d.ts +0 -0
  10. package/{lib → dist}/component-platform/component-platform.d.ts +4 -0
  11. package/{lib-esm → dist}/component-platform/component-query.d.ts +0 -0
  12. package/dist/component-platform/create-component-model.d.ts +36 -0
  13. package/dist/component-platform/custom-component-handler.d.ts +21 -0
  14. package/{lib-esm → dist}/component-platform/descriptor.d.ts +0 -0
  15. package/{lib-esm → dist}/component-platform/extend-component.d.ts +0 -0
  16. package/{lib → dist}/component-platform/index.d.ts +3 -1
  17. package/{lib-esm → dist}/component-platform/queries.d.ts +0 -0
  18. package/{lib-esm → dist}/component-platform/state-processor.d.ts +0 -0
  19. package/{lib-esm → dist}/component-resolver.d.ts +0 -0
  20. package/{lib-esm → dist}/event-subscriber.d.ts +0 -0
  21. package/dist/index.d.ts +8 -0
  22. package/dist/index.js +1047 -0
  23. package/dist/index.js.map +1 -0
  24. package/{lib-esm → dist}/types/configuration.d.ts +0 -0
  25. package/{lib-esm → dist}/types/index.d.ts +0 -0
  26. package/{lib-esm → dist}/types/ui.d.ts +0 -1
  27. package/package.json +9 -9
  28. package/lib/action-resolver.d.ts +0 -8
  29. package/lib/action-resolver.js +0 -19
  30. package/lib/component-platform/actions-controller.d.ts +0 -40
  31. package/lib/component-platform/actions-controller.js +0 -119
  32. package/lib/component-platform/changeset-provider.d.ts +0 -8
  33. package/lib/component-platform/changeset-provider.js +0 -2
  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.js +0 -209
  41. package/lib/component-platform/component-query.d.ts +0 -16
  42. package/lib/component-platform/component-query.js +0 -35
  43. package/lib/component-platform/create-component-model.d.ts +0 -19
  44. package/lib/component-platform/create-component-model.js +0 -126
  45. package/lib/component-platform/descriptor.d.ts +0 -8
  46. package/lib/component-platform/descriptor.js +0 -12
  47. package/lib/component-platform/extend-component.d.ts +0 -8
  48. package/lib/component-platform/extend-component.js +0 -57
  49. package/lib/component-platform/index.js +0 -24
  50. package/lib/component-platform/queries.d.ts +0 -6
  51. package/lib/component-platform/queries.js +0 -53
  52. package/lib/component-platform/state-processor.d.ts +0 -12
  53. package/lib/component-platform/state-processor.js +0 -209
  54. package/lib/component-resolver.d.ts +0 -14
  55. package/lib/component-resolver.js +0 -49
  56. package/lib/event-subscriber.d.ts +0 -7
  57. package/lib/event-subscriber.js +0 -22
  58. package/lib/index.d.ts +0 -8
  59. package/lib/index.js +0 -39
  60. package/lib/types/configuration.d.ts +0 -86
  61. package/lib/types/configuration.js +0 -16
  62. package/lib/types/index.d.ts +0 -2
  63. package/lib/types/index.js +0 -18
  64. package/lib/types/ui.d.ts +0 -55
  65. package/lib/types/ui.js +0 -2
  66. package/lib-esm/action-resolver.js +0 -17
  67. package/lib-esm/component-platform/actions-controller.js +0 -116
  68. package/lib-esm/component-platform/changeset-provider.js +0 -1
  69. package/lib-esm/component-platform/component-controller.js +0 -116
  70. package/lib-esm/component-platform/component-node-collection.js +0 -48
  71. package/lib-esm/component-platform/component-node.js +0 -187
  72. package/lib-esm/component-platform/component-platform.d.ts +0 -50
  73. package/lib-esm/component-platform/component-platform.js +0 -206
  74. package/lib-esm/component-platform/component-query.js +0 -32
  75. package/lib-esm/component-platform/create-component-model.d.ts +0 -19
  76. package/lib-esm/component-platform/create-component-model.js +0 -121
  77. package/lib-esm/component-platform/descriptor.js +0 -8
  78. package/lib-esm/component-platform/extend-component.js +0 -53
  79. package/lib-esm/component-platform/index.d.ts +0 -16
  80. package/lib-esm/component-platform/index.js +0 -9
  81. package/lib-esm/component-platform/queries.js +0 -46
  82. package/lib-esm/component-platform/state-processor.js +0 -205
  83. package/lib-esm/component-resolver.js +0 -47
  84. package/lib-esm/event-subscriber.js +0 -18
  85. package/lib-esm/index.d.ts +0 -8
  86. package/lib-esm/index.js +0 -5
  87. package/lib-esm/types/configuration.js +0 -13
  88. package/lib-esm/types/index.js +0 -2
  89. package/lib-esm/types/ui.js +0 -1
@@ -1,16 +0,0 @@
1
- export { ActionsController } from './actions-controller';
2
- export type { WatchActionDelegate } from './actions-controller';
3
- export type { ChangesetProvider } from './changeset-provider';
4
- export { AbstractComponentController, ComponentNodeController } from './component-controller';
5
- export { ComponentNode } from './component-node';
6
- export type { ChangesetOptions, ComponentNodeAttributes, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties, ComponentNodeSettings, Size, } from './component-node';
7
- export { ComponentPlatform } from './component-platform';
8
- export type { SwitchMap } from './component-platform';
9
- export { ComponentQuery } from './component-query';
10
- export type { ComponentQueryRule } from './component-query';
11
- export { createComponentModel } from './create-component-model';
12
- export { asDescriptor } from './descriptor';
13
- export type { ComponentDescriptor } from './descriptor';
14
- export { extendComponent } from './extend-component';
15
- export type { ExtendComponentHandler, ExtendComponentOptions } from './extend-component';
16
- export { findComponent, findVisibleComponents, traverseComponents } from './queries';
@@ -1,9 +0,0 @@
1
- export { ActionsController } from './actions-controller';
2
- export { AbstractComponentController, ComponentNodeController } from './component-controller';
3
- export { ComponentNode } from './component-node';
4
- export { ComponentPlatform } from './component-platform';
5
- export { ComponentQuery } from './component-query';
6
- export { createComponentModel } from './create-component-model';
7
- export { asDescriptor } from './descriptor';
8
- export { extendComponent } from './extend-component';
9
- export { findComponent, findVisibleComponents, traverseComponents } from './queries';
@@ -1,46 +0,0 @@
1
- var traverseComponentsRecursive = function (nodes, switches, fn) {
2
- for (var i = 0, y = nodes.length; i < y; i++) {
3
- if (fn(nodes[i]) === true) {
4
- break;
5
- }
6
- var branch = switches[nodes[i].id] || 'default';
7
- var children = nodes[i].getChildren(branch);
8
- traverseComponentsRecursive(children, switches, fn);
9
- }
10
- };
11
- export var traverseComponents = function (root, switches, fn) {
12
- if (fn(root) !== true) {
13
- var branch = switches[root.id] || 'default';
14
- var children = root.children[branch];
15
- traverseComponentsRecursive(children, switches, fn);
16
- }
17
- };
18
- export var findVisibleComponents = function (root, switches) {
19
- var nodes = [];
20
- traverseComponents(root, switches, function (node) {
21
- nodes.push(node);
22
- });
23
- return nodes;
24
- };
25
- export var findComponent = function (root, switches, fn) {
26
- var matched;
27
- traverseComponents(root, switches, function (node) {
28
- if (fn(node)) {
29
- matched = node;
30
- return true;
31
- }
32
- });
33
- return matched;
34
- };
35
- export var getAncestors = function (node) {
36
- if (!node.parent) {
37
- return [];
38
- }
39
- var tree = [];
40
- var currentNode = node.parent;
41
- while (currentNode) {
42
- tree.unshift(currentNode);
43
- currentNode = currentNode.parent;
44
- }
45
- return tree;
46
- };
@@ -1,205 +0,0 @@
1
- var __read = (this && this.__read) || function (o, n) {
2
- var m = typeof Symbol === "function" && o[Symbol.iterator];
3
- if (!m) return o;
4
- var i = m.call(o), r, ar = [], e;
5
- try {
6
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7
- }
8
- catch (error) { e = { error: error }; }
9
- finally {
10
- try {
11
- if (r && !r.done && (m = i["return"])) m.call(i);
12
- }
13
- finally { if (e) throw e.error; }
14
- }
15
- return ar;
16
- };
17
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
18
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
19
- if (ar || !(i in from)) {
20
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21
- ar[i] = from[i];
22
- }
23
- }
24
- return to.concat(ar || Array.prototype.slice.call(from));
25
- };
26
- var calculateNodeIndex = function (node) {
27
- var currentNode = node;
28
- var index = 0;
29
- while (currentNode.parent) {
30
- index = index + 1;
31
- currentNode = currentNode.parent;
32
- }
33
- return index;
34
- };
35
- var sortQueue = function (queue) {
36
- var mapped = queue.map(function (_a) {
37
- var _b = __read(_a, 2), node = _b[0], options = _b[1];
38
- return [calculateNodeIndex(node), node, options];
39
- });
40
- return mapped
41
- .sort(function (_a, _b) {
42
- var _c = __read(_a, 1), a = _c[0];
43
- var _d = __read(_b, 1), b = _d[0];
44
- return a - b;
45
- })
46
- .map(function (_a) {
47
- var _b = __read(_a, 3), node = _b[1], options = _b[2];
48
- return [node, options];
49
- });
50
- };
51
- var isObject = function (item) {
52
- return item && typeof item === 'object' && !Array.isArray(item);
53
- };
54
- var mergeDeep = function (target) {
55
- var _a, _b;
56
- var sources = [];
57
- for (var _i = 1; _i < arguments.length; _i++) {
58
- sources[_i - 1] = arguments[_i];
59
- }
60
- if (!sources.length)
61
- return target;
62
- var source = sources.shift();
63
- if (isObject(target) && isObject(source)) {
64
- for (var key in source) {
65
- if (isObject(source[key])) {
66
- if (!target[key])
67
- Object.assign(target, (_a = {}, _a[key] = {}, _a));
68
- mergeDeep(target[key], source[key]);
69
- }
70
- else {
71
- Object.assign(target, (_b = {}, _b[key] = source[key], _b));
72
- }
73
- }
74
- }
75
- return mergeDeep.apply(void 0, __spreadArray([target], __read(sources), false));
76
- };
77
- var matchesBreakpoint = function (b1, b2) {
78
- if (!b1 || b1 === 'all') {
79
- return true;
80
- }
81
- return b1.some(function (b1) { return b2.indexOf(b1) > -1; });
82
- };
83
- export var createStateProcessor = function (platform, callback) {
84
- var nodeQueue = [];
85
- var optionsQueue = [];
86
- var timeout;
87
- var flush = function () {
88
- if (process.env.NODE_ENV !== 'production') {
89
- console.time('state-processor.flush');
90
- }
91
- var processHistory = new Map();
92
- var sortedQueue = sortQueue(nodeQueue.map(function (node, i) { return [node, optionsQueue[i]]; }));
93
- var processNode = function (node, options) {
94
- var _a;
95
- var history = processHistory.get(node) || {};
96
- // todo: this doesnt take overrides into account
97
- var processContext = options.context && !history.context;
98
- var processProperties = options.properties && !history.properties;
99
- var processLayout = options.layout && !history.layout;
100
- processHistory.set(node, {
101
- context: history.context || processContext,
102
- properties: history.properties || processProperties,
103
- layout: history.layout || processLayout,
104
- });
105
- if (processProperties) {
106
- node.attributes.properties = {};
107
- }
108
- if (processLayout) {
109
- node.attributes.layout = {};
110
- }
111
- if (processContext) {
112
- node.attributes.context = mergeDeep({}, (_a = node.parent) === null || _a === void 0 ? void 0 : _a.attributes.context);
113
- }
114
- var propertyResolvers = [];
115
- var layoutResolvers = [];
116
- var contextResolvers = [];
117
- node.changesets.forEach(function (changeset) {
118
- var _a = __read(changeset, 2), change = _a[0], options = _a[1];
119
- if (matchesBreakpoint(options.breakpoints, platform.breakpoints)) {
120
- if (processProperties) {
121
- if (typeof change.properties === 'function') {
122
- propertyResolvers.push(change.properties);
123
- }
124
- else {
125
- mergeDeep(node.attributes.properties, change.properties);
126
- }
127
- }
128
- if (processLayout) {
129
- if (typeof change.layout === 'function') {
130
- layoutResolvers.push(change.layout);
131
- }
132
- else {
133
- mergeDeep(node.attributes.layout, change.layout);
134
- }
135
- }
136
- if (processContext) {
137
- if (typeof change.context === 'function') {
138
- contextResolvers.push(change.context);
139
- }
140
- else {
141
- mergeDeep(node.attributes.context, change.context);
142
- }
143
- }
144
- }
145
- });
146
- propertyResolvers.forEach(function (resolver) {
147
- mergeDeep(node.attributes.properties, resolver(node.attributes.properties));
148
- });
149
- layoutResolvers.forEach(function (resolver) {
150
- mergeDeep(node.attributes.layout, resolver(node.attributes.layout));
151
- });
152
- contextResolvers.forEach(function (resolver) {
153
- mergeDeep(node.attributes.context, resolver(node.attributes.context));
154
- });
155
- if (processContext || options.recursive) {
156
- var branch = platform.getBranch(node);
157
- var childOptions_1 = options.recursive
158
- ? options
159
- : {
160
- context: !!processContext,
161
- };
162
- node.getChildren(branch).forEach(function (child) {
163
- processNode(child, childOptions_1);
164
- });
165
- }
166
- };
167
- if (process.env.NODE_ENV !== 'production') {
168
- console.timeEnd('state-processor.flush');
169
- }
170
- sortedQueue.forEach(function (_a) {
171
- var _b = __read(_a, 2), node = _b[0], options = _b[1];
172
- processNode(node, options);
173
- });
174
- nodeQueue = [];
175
- optionsQueue = [];
176
- callback(processHistory);
177
- };
178
- var schedule = function () {
179
- clearTimeout(timeout);
180
- timeout = setTimeout(flush, 0);
181
- };
182
- return function (node, options) {
183
- var index = nodeQueue.indexOf(node);
184
- if (index > -1) {
185
- // if node already exist in queue, update its options
186
- var summary = optionsQueue[index];
187
- if (options.context) {
188
- summary.context = true;
189
- }
190
- if (options.properties) {
191
- summary.properties = true;
192
- }
193
- if (options.layout) {
194
- summary.layout = true;
195
- }
196
- if (options.recursive) {
197
- summary.recursive = true;
198
- }
199
- return schedule();
200
- }
201
- nodeQueue.push(node);
202
- optionsQueue.push(options);
203
- return schedule();
204
- };
205
- };
@@ -1,47 +0,0 @@
1
- import { Logger } from '@telia-ace/widget-utilities';
2
- var ComponentResolver = /** @class */ (function () {
3
- function ComponentResolver(container) {
4
- this.aliases = new Map();
5
- this.components = new Map();
6
- this.logger = new Logger();
7
- var events = container.get('$widget').events;
8
- this.events = events;
9
- }
10
- ComponentResolver.prototype.getComponent = function (key) {
11
- var alias = this.aliases.get(key);
12
- var component = this.components.get(alias || key) || null;
13
- if (process.env.NODE_ENV !== 'production') {
14
- if (!component) {
15
- this.logger.warn(alias || key, "Unable to resolve component: \"".concat(alias || key, "\". You most likely forgot to register the required plugin for: ").concat(alias || key, "."));
16
- }
17
- }
18
- return component;
19
- };
20
- ComponentResolver.prototype.registerComponent = function (key, component) {
21
- var _this = this;
22
- this.components.set(key, component);
23
- this.events.dispatch('component-resolver:resolve', key);
24
- return function () {
25
- _this.components.delete(key);
26
- };
27
- };
28
- ComponentResolver.prototype.registerResolver = function (key, fn) {
29
- var _this = this;
30
- return this.events.subscribe('component-resolver:resolve', function (e, data) {
31
- if (data === key) {
32
- var component = _this.getComponent(key);
33
- fn(component);
34
- }
35
- });
36
- };
37
- ComponentResolver.prototype.registerAlias = function (alias, key) {
38
- var _this = this;
39
- this.aliases.set(alias, key);
40
- this.events.dispatch('component-resolver:resolve', alias);
41
- return function () {
42
- _this.aliases.delete(alias);
43
- };
44
- };
45
- return ComponentResolver;
46
- }());
47
- export default ComponentResolver;
@@ -1,18 +0,0 @@
1
- /**
2
- * Creates s subscriber for the specified `EventManager` and provides a single cancellation
3
- * function for all registered subscriptions.
4
- */
5
- export var createEventSubscriber = function (events) {
6
- var subs = [];
7
- var subscribe = function (type, listener) {
8
- subs.push(events.subscribe(type, listener));
9
- };
10
- return [
11
- subscribe,
12
- function () {
13
- subs.forEach(function (sub) {
14
- sub();
15
- });
16
- },
17
- ];
18
- };
@@ -1,8 +0,0 @@
1
- export { default as ActionResolver } from './action-resolver';
2
- export { ActionsController, asDescriptor, ComponentNode, ComponentNodeController, ComponentPlatform, ComponentQuery, createComponentModel, extendComponent, findComponent, findVisibleComponents, traverseComponents, } from './component-platform';
3
- export type { ChangesetOptions, ChangesetProvider, ComponentDescriptor, ComponentNodeAttributes, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties, ComponentNodeSettings, ComponentQueryRule, ExtendComponentHandler, ExtendComponentOptions, Size, SwitchMap, WatchActionDelegate, } from './component-platform';
4
- export { default as ComponentResolver } from './component-resolver';
5
- export type { ReactComponent } from './component-resolver';
6
- export { createEventSubscriber } from './event-subscriber';
7
- export type { SubscribeDelegate } from './event-subscriber';
8
- export * from './types';
package/lib-esm/index.js DELETED
@@ -1,5 +0,0 @@
1
- export { default as ActionResolver } from './action-resolver';
2
- export { ActionsController, asDescriptor, ComponentNode, ComponentNodeController, ComponentPlatform, ComponentQuery, createComponentModel, extendComponent, findComponent, findVisibleComponents, traverseComponents, } from './component-platform';
3
- export { default as ComponentResolver } from './component-resolver';
4
- export { createEventSubscriber } from './event-subscriber';
5
- export * from './types';
@@ -1,13 +0,0 @@
1
- var HistoryMode;
2
- (function (HistoryMode) {
3
- HistoryMode["scopedHash"] = "scopedHash";
4
- HistoryMode["hash"] = "hash";
5
- HistoryMode["browser"] = "browser";
6
- HistoryMode["memory"] = "memory";
7
- })(HistoryMode || (HistoryMode = {}));
8
- export var WidgetRenderState;
9
- (function (WidgetRenderState) {
10
- WidgetRenderState["open"] = "open";
11
- WidgetRenderState["closed"] = "closed";
12
- WidgetRenderState["hidden"] = "hidden";
13
- })(WidgetRenderState || (WidgetRenderState = {}));
@@ -1,2 +0,0 @@
1
- export * from './configuration';
2
- export * from './ui';
@@ -1 +0,0 @@
1
- export {};