@telia-ace/widget-core 1.0.2 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{lib-esm → dist}/action-resolver.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/actions-controller.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/changeset-provider.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-configuration-api.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-controller.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-node-collection.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-node.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-platform.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/component-query.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/create-component-model.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/custom-component-handler.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/descriptor.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/extend-component.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/index.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/queries.d.ts +0 -0
- package/{lib-esm → dist}/component-platform/state-processor.d.ts +0 -0
- package/{lib-esm → dist}/component-resolver.d.ts +0 -0
- package/{lib-esm → dist}/event-subscriber.d.ts +0 -0
- package/{lib-esm → dist}/index.d.ts +0 -0
- package/dist/index.js +1047 -0
- package/dist/index.js.map +1 -0
- package/{lib-esm → dist}/types/configuration.d.ts +0 -0
- package/{lib-esm → dist}/types/index.d.ts +0 -0
- package/{lib-esm → dist}/types/ui.d.ts +0 -0
- package/package.json +10 -10
- package/lib/action-resolver.d.ts +0 -8
- package/lib/action-resolver.js +0 -19
- package/lib/component-platform/actions-controller.d.ts +0 -40
- package/lib/component-platform/actions-controller.js +0 -119
- package/lib/component-platform/changeset-provider.d.ts +0 -8
- package/lib/component-platform/changeset-provider.js +0 -2
- package/lib/component-platform/component-configuration-api.d.ts +0 -2
- package/lib/component-platform/component-configuration-api.js +0 -32
- package/lib/component-platform/component-controller.d.ts +0 -38
- package/lib/component-platform/component-controller.js +0 -119
- package/lib/component-platform/component-node-collection.d.ts +0 -18
- package/lib/component-platform/component-node-collection.js +0 -51
- package/lib/component-platform/component-node.d.ts +0 -63
- package/lib/component-platform/component-node.js +0 -190
- package/lib/component-platform/component-platform.d.ts +0 -54
- package/lib/component-platform/component-platform.js +0 -220
- package/lib/component-platform/component-query.d.ts +0 -16
- package/lib/component-platform/component-query.js +0 -35
- package/lib/component-platform/create-component-model.d.ts +0 -36
- package/lib/component-platform/create-component-model.js +0 -141
- package/lib/component-platform/custom-component-handler.d.ts +0 -21
- package/lib/component-platform/custom-component-handler.js +0 -16
- package/lib/component-platform/descriptor.d.ts +0 -8
- package/lib/component-platform/descriptor.js +0 -12
- package/lib/component-platform/extend-component.d.ts +0 -8
- package/lib/component-platform/extend-component.js +0 -57
- package/lib/component-platform/index.d.ts +0 -18
- package/lib/component-platform/index.js +0 -30
- package/lib/component-platform/queries.d.ts +0 -6
- package/lib/component-platform/queries.js +0 -53
- package/lib/component-platform/state-processor.d.ts +0 -12
- package/lib/component-platform/state-processor.js +0 -209
- package/lib/component-resolver.d.ts +0 -14
- package/lib/component-resolver.js +0 -49
- package/lib/event-subscriber.d.ts +0 -7
- package/lib/event-subscriber.js +0 -22
- package/lib/index.d.ts +0 -8
- package/lib/index.js +0 -41
- package/lib/types/configuration.d.ts +0 -86
- package/lib/types/configuration.js +0 -16
- package/lib/types/index.d.ts +0 -2
- package/lib/types/index.js +0 -18
- package/lib/types/ui.d.ts +0 -54
- package/lib/types/ui.js +0 -2
- package/lib-esm/action-resolver.js +0 -17
- package/lib-esm/component-platform/actions-controller.js +0 -116
- package/lib-esm/component-platform/changeset-provider.js +0 -1
- package/lib-esm/component-platform/component-configuration-api.js +0 -30
- package/lib-esm/component-platform/component-controller.js +0 -116
- package/lib-esm/component-platform/component-node-collection.js +0 -48
- package/lib-esm/component-platform/component-node.js +0 -187
- package/lib-esm/component-platform/component-platform.js +0 -217
- package/lib-esm/component-platform/component-query.js +0 -32
- package/lib-esm/component-platform/create-component-model.js +0 -135
- package/lib-esm/component-platform/custom-component-handler.js +0 -13
- package/lib-esm/component-platform/descriptor.js +0 -8
- package/lib-esm/component-platform/extend-component.js +0 -53
- package/lib-esm/component-platform/index.js +0 -10
- package/lib-esm/component-platform/queries.js +0 -46
- package/lib-esm/component-platform/state-processor.js +0 -205
- package/lib-esm/component-resolver.js +0 -47
- package/lib-esm/event-subscriber.js +0 -18
- package/lib-esm/index.js +0 -5
- package/lib-esm/types/configuration.js +0 -13
- package/lib-esm/types/index.js +0 -2
- package/lib-esm/types/ui.js +0 -1
|
@@ -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
|
-
};
|
package/lib-esm/index.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { default as ActionResolver } from './action-resolver';
|
|
2
|
-
export { ActionsController, asDescriptor, componentConfigurationApi, ComponentNode, ComponentNodeController, ComponentPlatform, ComponentQuery, createChildren, 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 = {}));
|
package/lib-esm/types/index.js
DELETED
package/lib-esm/types/ui.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|