@telia-ace/widget-core 1.0.28 → 1.1.1-rc.0

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 (35) hide show
  1. package/index.js +3 -0
  2. package/index.mjs +2021 -0
  3. package/package.json +7 -30
  4. package/LICENSE.txt +0 -6
  5. package/README.md +0 -3
  6. package/dist/index.js +0 -824
  7. package/dist/index.js.map +0 -1
  8. /package/{dist/action-resolver.d.ts → action-resolver.d.ts} +0 -0
  9. /package/{dist/bootstrap.d.ts → bootstrap.d.ts} +0 -0
  10. /package/{dist/component-platform → component-platform}/actions-controller.d.ts +0 -0
  11. /package/{dist/component-platform → component-platform}/changeset-provider.d.ts +0 -0
  12. /package/{dist/component-platform → component-platform}/component-configuration-api.d.ts +0 -0
  13. /package/{dist/component-platform → component-platform}/component-controller.d.ts +0 -0
  14. /package/{dist/component-platform → component-platform}/component-node-collection.d.ts +0 -0
  15. /package/{dist/component-platform → component-platform}/component-node.d.ts +0 -0
  16. /package/{dist/component-platform → component-platform}/component-platform.d.ts +0 -0
  17. /package/{dist/component-platform → component-platform}/component-query.d.ts +0 -0
  18. /package/{dist/component-platform → component-platform}/create-component-model.d.ts +0 -0
  19. /package/{dist/component-platform → component-platform}/custom-component-handler.d.ts +0 -0
  20. /package/{dist/component-platform → component-platform}/descriptor.d.ts +0 -0
  21. /package/{dist/component-platform → component-platform}/extend-component.d.ts +0 -0
  22. /package/{dist/component-platform → component-platform}/index.d.ts +0 -0
  23. /package/{dist/component-platform → component-platform}/queries.d.ts +0 -0
  24. /package/{dist/component-platform → component-platform}/state-processor.d.ts +0 -0
  25. /package/{dist/component-resolver.d.ts → component-resolver.d.ts} +0 -0
  26. /package/{dist/environment.d.ts → environment.d.ts} +0 -0
  27. /package/{dist/event-subscriber.d.ts → event-subscriber.d.ts} +0 -0
  28. /package/{dist/implementation.d.ts → implementation.d.ts} +0 -0
  29. /package/{dist/index.d.ts → index.d.ts} +0 -0
  30. /package/{dist/plugin.d.ts → plugin.d.ts} +0 -0
  31. /package/{dist/types → types}/configuration.d.ts +0 -0
  32. /package/{dist/types → types}/index.d.ts +0 -0
  33. /package/{dist/types → types}/ui.d.ts +0 -0
  34. /package/{dist/version.d.ts → version.d.ts} +0 -0
  35. /package/{dist/widget-type.d.ts → widget-type.d.ts} +0 -0
package/dist/index.js DELETED
@@ -1,824 +0,0 @@
1
- var V = Object.defineProperty, j = Object.defineProperties;
2
- var q = Object.getOwnPropertyDescriptors;
3
- var D = Object.getOwnPropertySymbols;
4
- var z = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable;
5
- var S = (s, t, e) => t in s ? V(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e, y = (s, t) => {
6
- for (var e in t || (t = {}))
7
- z.call(t, e) && S(s, e, t[e]);
8
- if (D)
9
- for (var e of D(t))
10
- Q.call(t, e) && S(s, e, t[e]);
11
- return s;
12
- }, _ = (s, t) => j(s, q(t));
13
- import { bootstrapImplementation as F, ConfigurationApi as G } from "@webprovisions/bootstrapping";
14
- import { selectImplementations as K, createConfigurationApi as U, version as W, Environment as Y, Implementation as J, Plugin as X, WidgetType as Z } from "@webprovisions/platform";
15
- import { uuid as O, Logger as N } from "@telia-ace/widget-utilities";
16
- class yt {
17
- constructor(t) {
18
- const { events: e } = t.get("$widget");
19
- this.events = e.createChild(this);
20
- }
21
- action(t, e, n) {
22
- this.events.dispatch("data:action", { action: e, value: n, target: t }, { bubbles: !0 });
23
- }
24
- subscribe(t, e) {
25
- return this.events.subscribe(
26
- "data:action",
27
- (n, { action: i, value: r, target: c }) => t === c && e(t, i, r)
28
- );
29
- }
30
- }
31
- const xt = (s, t, e = {}) => F(
32
- s,
33
- s.bindings,
34
- () => {
35
- const n = s.container.get("$runtimecfg").map((i) => {
36
- const r = i[0];
37
- if (typeof r == "function")
38
- return r;
39
- if (K(r)(s))
40
- return i[1];
41
- }).filter((i) => !!i);
42
- return (t ? [t] : []).concat(n);
43
- },
44
- e.rootElementResolver || (() => document.body)
45
- ), tt = (s) => {
46
- const t = [];
47
- return [
48
- (n, i) => {
49
- t.push(s.subscribe(n, i));
50
- },
51
- () => {
52
- t.forEach((n) => {
53
- n();
54
- });
55
- }
56
- ];
57
- };
58
- class P {
59
- constructor(t, e = []) {
60
- this.platform = t, this.rules = e;
61
- }
62
- match(t) {
63
- return this.rules.every((e) => !(e.id && e.id !== t.id || e.type && e.type !== t.type));
64
- }
65
- ofType(t) {
66
- return this.rules.push({ type: t }), this;
67
- }
68
- withId(t) {
69
- return this.rules.push({ id: t }), this;
70
- }
71
- select() {
72
- return new et(this.platform, this);
73
- }
74
- }
75
- class H {
76
- constructor(t, e, n) {
77
- this.platform = t, this.node = e, this.actions = new k(
78
- t,
79
- new P(t).withId(e.id),
80
- n
81
- );
82
- const [i, r] = tt(this.platform.events);
83
- this.subscribe = i, this.unsubscribe = r;
84
- }
85
- properties(t) {
86
- return t && this.node.touchProperties((e) => t(e)), this.node.attributes.properties;
87
- }
88
- context(t) {
89
- return t && this.subscribe("components:context-changed", (e, { node: n }) => {
90
- n === this.node && t(this.node.attributes.context);
91
- }), this.node.attributes.context;
92
- }
93
- layout(t) {
94
- return t && this.subscribe("components:layout-changed", (e, { node: n }) => {
95
- n === this.node && t(this.node.attributes.layout);
96
- }), this.node.attributes.layout;
97
- }
98
- writeProperties(t, e) {
99
- this.node.writeProperties(t, e);
100
- }
101
- writeContext(t, e) {
102
- this.node.writeProperties(t, e);
103
- }
104
- writeLayout(t, e) {
105
- this.node.writeLayout(t, e);
106
- }
107
- dispose() {
108
- this.unsubscribe(), this.actions.dispose();
109
- }
110
- }
111
- class et {
112
- constructor(t, e, n = !0) {
113
- this.platform = t, this.target = e, this.clearOnDispose = n, this.removes = [], this.actions = new k(this.platform, this.target);
114
- }
115
- writeProperties(t, e) {
116
- this.removes.push(
117
- this.platform.write({
118
- options: e,
119
- attributes: { properties: t },
120
- target: this.target,
121
- removable: this.clearOnDispose
122
- })
123
- );
124
- }
125
- writeContext(t, e) {
126
- this.removes.push(
127
- this.platform.write({
128
- options: e,
129
- attributes: { context: t },
130
- target: this.target,
131
- removable: this.clearOnDispose
132
- })
133
- );
134
- }
135
- writeLayout(t, e) {
136
- this.removes.push(
137
- this.platform.write({
138
- options: e,
139
- attributes: { layout: t },
140
- target: this.target,
141
- removable: this.clearOnDispose
142
- })
143
- );
144
- }
145
- dispose() {
146
- this.removes.forEach((t) => {
147
- t();
148
- }), this.actions.dispose();
149
- }
150
- }
151
- const st = (s, t, e) => {
152
- const n = s.concat(), i = (r, c, a) => {
153
- let u = !0;
154
- if (n.length) {
155
- const h = n.shift(), o = (p, l) => (u = !1, i(p, Object.assign({}, c, l), a));
156
- return Promise.resolve(h(r, o, a)).then((p) => _(y({}, p), {
157
- cancelled: u
158
- }));
159
- }
160
- return Promise.resolve({ data: r, cancelled: !1, options: c });
161
- };
162
- return i(t, {}, e);
163
- };
164
- class k {
165
- constructor(t, e, n) {
166
- this.platform = t, this.target = e, this.ns = n, this.subscriptions = [], this.create = this.create.bind(this);
167
- }
168
- create(t, e = () => {
169
- }) {
170
- const n = {
171
- key: t,
172
- fn: e,
173
- target: this.target,
174
- ns: this.ns
175
- };
176
- this.platform.actionsState.handlers.push(n);
177
- const i = () => {
178
- const r = this.platform.actionsState.handlers.indexOf(n);
179
- r > -1 && this.platform.actionsState.handlers.splice(r, 1);
180
- };
181
- return this.subscriptions.push(i), i;
182
- }
183
- dispatch(t, e) {
184
- const n = this.platform.nodes.all.concat(
185
- this.platform.nodes.detached
186
- ), i = {}, r = this.platform.actionsState.handlers.filter(
187
- (c) => c.key === t && (!c.ns || !this.ns || c.ns === this.ns)
188
- );
189
- return Promise.all(
190
- r.map((c) => {
191
- const a = n.filter(
192
- (h) => c.target.match(h) && this.target.match(h)
193
- ), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some((o) => h.target.match(o))).map((h) => h.fn);
194
- return Promise.all(
195
- a.map((h) => {
196
- const o = new H(
197
- this.platform,
198
- h,
199
- this.ns
200
- );
201
- return st(u, e, o).then((p) => {
202
- const { data: l = {}, options: d, cancelled: b } = p;
203
- return Promise.resolve(
204
- b ? {} : c.fn(l, d, o)
205
- ).then((g) => {
206
- i[h.id] = g;
207
- });
208
- });
209
- })
210
- );
211
- })
212
- ).then(() => i);
213
- }
214
- watch(t, e) {
215
- let n = t, i = this.ns;
216
- const r = t.split(".");
217
- r.length > 1 && (i = r[0], n = r.splice(1).join("."));
218
- const c = {
219
- fn: e,
220
- target: this.target,
221
- key: n,
222
- ns: i
223
- };
224
- this.platform.actionsState.watchers.push(c);
225
- const a = () => {
226
- const u = this.platform.actionsState.watchers.indexOf(c);
227
- u > -1 && this.platform.actionsState.watchers.splice(u, 1);
228
- };
229
- return this.subscriptions.push(a), a;
230
- }
231
- dispose() {
232
- this.subscriptions.forEach((t) => t());
233
- }
234
- }
235
- const wt = U((s) => {
236
- s.createCommand("components", (t) => (e) => {
237
- t.events.subscribeOnce("components:platform-created", (n, { platform: i }) => {
238
- e.handlers && e.handlers.forEach(([r, c]) => {
239
- i.addComponentHandler(r, c);
240
- });
241
- });
242
- });
243
- });
244
- class L {
245
- constructor(t, e) {
246
- this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = O(), this.type = e, this.attributes = {
247
- context: {},
248
- properties: {},
249
- layout: {},
250
- tags: []
251
- }, this.writeLayout({ size: "full", indent: 0 });
252
- }
253
- mount(t, e) {
254
- let n = t.get("mounted-nodes");
255
- return n || (n = /* @__PURE__ */ new Map(), t.register("mounted-nodes", n)), n.has(this) ? (process.env.NODE_ENV !== "production" && N.error("Trying to mount an already mounted component node.", this), () => {
256
- }) : (this.events.dispatch("components:node-mounted", { node: this }), this.mountCount === 0 && (this.mountCount = this.mountCount + 1, this.events.dispatch("components:node-enter", { node: this })), () => {
257
- n.delete(this), this.events.dispatch("components:node-unmounted", { node: this }), this.mountCount = this.mountCount - 1, this.mountCount === 0 && this.events.dispatch("components:node-exit", { node: this });
258
- });
259
- }
260
- appendChild(t, e = "default") {
261
- if (t.parent) {
262
- if (t.parent === this)
263
- return;
264
- t.parent.removeChild(t);
265
- }
266
- t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].push(t), this.events.dispatch("components:node-appended", { node: t });
267
- }
268
- prependChild(t, e = "default") {
269
- if (t.parent) {
270
- if (t.parent === this)
271
- return;
272
- t.parent.removeChild(t);
273
- }
274
- t.parent = this, this.children[e] || (this.children[e] = []), this.children[e].unshift(t), this.events.dispatch("components:node-appended", { node: t });
275
- }
276
- touchProperties(t, e = {}, n) {
277
- const r = [{ properties: t }, e];
278
- return this.changesets.push(r), this.events.dispatch("components:set-properties", { node: this }), () => {
279
- if (n) {
280
- const c = this.changesets.indexOf(r);
281
- c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-properties", { node: this }));
282
- }
283
- };
284
- }
285
- writeProperties(t, e = {}, n) {
286
- const r = [{ properties: t }, e];
287
- return this.changesets.push(r), this.events.dispatch("components:set-properties", { node: this }), () => {
288
- if (n) {
289
- const c = this.changesets.indexOf(r);
290
- c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-properties", { node: this }));
291
- }
292
- };
293
- }
294
- writeLayout(t, e = {}, n) {
295
- const r = [{ layout: t }, e];
296
- return this.changesets.push(r), this.events.dispatch("components:set-layout", { node: this }), () => {
297
- if (!n)
298
- return;
299
- const c = this.changesets.indexOf(r);
300
- c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-layout", { node: this }));
301
- };
302
- }
303
- writeContext(t, e = {}, n) {
304
- const r = [{ context: t }, e];
305
- return this.changesets.push(r), this.events.dispatch("components:set-context", { node: this }), () => {
306
- if (!n)
307
- return;
308
- const c = this.changesets.indexOf(r);
309
- c > -1 && (this.changesets.splice(c, 1), this.events.dispatch("components:set-context", { node: this }));
310
- };
311
- }
312
- getChildren(t = "default") {
313
- const e = this.children[t] || [];
314
- return e.reduce((n, i, r) => {
315
- const { order: c = r } = i.attributes.layout;
316
- return n[c] ? n.splice(c, 0, i) : n[c] = i, n;
317
- }, Array(e.length));
318
- }
319
- remove() {
320
- this.parent && this.parent.removeChild(this);
321
- }
322
- removeChild(t) {
323
- Object.keys(this.children).forEach((e) => {
324
- const n = this.children[e], i = n.indexOf(t);
325
- i > -1 && (n.splice(i, 1), this.events.dispatch("components:node-removed", { node: t, parentNode: this }));
326
- }), delete t.parent;
327
- }
328
- }
329
- const B = (s, t, e) => {
330
- for (let n = 0, i = s.length; n < i && e(s[n]) !== !0; n++) {
331
- const r = t[s[n].id] || "default", c = s[n].getChildren(r);
332
- B(c, t, e);
333
- }
334
- }, $ = (s, t, e) => {
335
- if (e(s) !== !0) {
336
- const n = t[s.id] || "default", i = s.children[n];
337
- B(i, t, e);
338
- }
339
- }, w = (s, t) => {
340
- const e = [];
341
- return $(s, t, (n) => {
342
- e.push(n);
343
- }), e;
344
- }, nt = (s, t, e) => {
345
- let n;
346
- return $(s, t, (i) => {
347
- if (e(i))
348
- return n = i, !0;
349
- }), n;
350
- };
351
- class it {
352
- constructor(t, e, n) {
353
- this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], n.subscribe("components:node-appended", (i, r) => {
354
- this.all.push(r.node), this.visible = w(t, e);
355
- }), n.subscribe("components:node-removed", (i, r) => {
356
- let c = this.all.indexOf(r.node);
357
- c > -1 && this.all.splice(c, 1), c = this.visible.indexOf(r.node), c > -1 && this.visible.splice(c, 1), this.visible = w(t, e);
358
- }), n.subscribe("components:node-switched", (i, r) => {
359
- this.visible = w(t, e);
360
- });
361
- }
362
- query(t = {}) {
363
- const e = [];
364
- return $(this.root, this.switches, (n) => {
365
- Object.keys(t).every((r) => t[r] === n[r]) && e.push(n);
366
- }), e;
367
- }
368
- get(t) {
369
- return nt(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
370
- }
371
- }
372
- class ot {
373
- constructor() {
374
- this.handlers = /* @__PURE__ */ new Map();
375
- }
376
- add(t, e) {
377
- this.handlers.set(t, e);
378
- }
379
- get(t) {
380
- return this.handlers.get(t);
381
- }
382
- }
383
- const rt = (s) => {
384
- let t = s, e = 0;
385
- for (; t.parent; )
386
- e = e + 1, t = t.parent;
387
- return e;
388
- }, ct = (s) => s.map(([e, n]) => [rt(e), e, n]).sort(([e], [n]) => e - n).map(([, e, n]) => [e, n]), C = (s) => s instanceof Date ? !1 : s && typeof s == "object" && !Array.isArray(s), v = (s, ...t) => {
389
- if (!t.length)
390
- return s;
391
- const e = t.shift();
392
- if (C(s) && C(e))
393
- for (const n in e)
394
- C(e[n]) ? (s[n] || Object.assign(s, { [n]: {} }), v(s[n], e[n])) : Object.assign(s, { [n]: e[n] });
395
- return v(s, ...t);
396
- }, ht = (s, t) => !s || s === "all" ? !0 : s.some((e) => t.indexOf(e) > -1), at = (s, t) => {
397
- let e = [], n = [], i;
398
- const r = () => {
399
- process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
400
- const a = /* @__PURE__ */ new Map(), u = ct(e.map((o, p) => [o, n[p]])), h = (o, p) => {
401
- var I;
402
- const l = a.get(o) || {}, d = p.context && !l.context, b = p.properties && !l.properties, g = p.layout && !l.layout;
403
- a.set(o, {
404
- context: l.context || d,
405
- properties: l.properties || b,
406
- layout: l.layout || g
407
- }), b && (o.attributes.properties = {}), g && (o.attributes.layout = {}), d && (o.attributes.context = v({}, (I = o.parent) == null ? void 0 : I.attributes.context));
408
- const R = [], A = [], T = [];
409
- if (o.changesets.forEach((f) => {
410
- const [m, x] = f;
411
- ht(x.breakpoints, s.breakpoints) && (b && (typeof m.properties == "function" ? R.push(
412
- m.properties
413
- ) : v(o.attributes.properties, m.properties)), g && (typeof m.layout == "function" ? A.push(m.layout) : v(o.attributes.layout, m.layout)), d && (typeof m.context == "function" ? T.push(m.context) : v(o.attributes.context, m.context)));
414
- }), R.forEach((f) => {
415
- v(o.attributes.properties, f(o.attributes.properties));
416
- }), A.forEach((f) => {
417
- v(o.attributes.layout, f(o.attributes.layout));
418
- }), T.forEach((f) => {
419
- v(o.attributes.context, f(o.attributes.context));
420
- }), d || p.recursive) {
421
- const f = s.getBranch(o), m = p.recursive ? p : {
422
- context: !!d
423
- };
424
- o.getChildren(f).forEach((x) => {
425
- h(x, m);
426
- });
427
- }
428
- };
429
- process.env.NODE_ENV !== "production" && console.timeEnd("state-processor.flush"), u.forEach(([o, p]) => {
430
- h(o, p);
431
- }), e = [], n = [], t(a);
432
- }, c = () => {
433
- clearTimeout(i), i = setTimeout(r, 0);
434
- };
435
- return (a, u) => {
436
- const h = e.indexOf(a);
437
- if (h > -1) {
438
- const o = n[h];
439
- return u.context && (o.context = !0), u.properties && (o.properties = !0), u.layout && (o.layout = !0), u.recursive && (o.recursive = !0), c();
440
- }
441
- return e.push(a), n.push(u), c();
442
- };
443
- };
444
- class pt {
445
- constructor(t, e = {}) {
446
- this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new ot(), this.events = t.events.createChild(this);
447
- const n = new L(this.events, "root");
448
- n.name = `root-${t.name}`, this.nodes = new it(n, this.switches, this.events);
449
- const i = this.processNode = at(this, (r) => {
450
- const c = Array.from(r.keys());
451
- process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${c.length} node(s) processed:
452
- ${c.map(
453
- (a) => `${a.name || "<no name>"} (${a.id})
454
- `
455
- )}`), c.forEach((a) => {
456
- const u = r.get(a);
457
- a.parent && a.parent.type === "root" && this.events.dispatch("components:root-children-changed", { node: a }), u != null && u.context && this.events.dispatch("components:context-changed", { node: a }), u != null && u.properties && this.events.dispatch("components:properties-changed", { node: a }), u != null && u.layout && this.events.dispatch("components:layout-changed", { node: a });
458
- }), this.events.dispatch("components:component-model-initialized", {}, { bubbles: !0 });
459
- });
460
- Promise.all(
461
- Object.keys(e).map((r) => e[r].load(this))
462
- ), this.subscriptions.push(
463
- this.events.subscribe(
464
- "components:node-appended",
465
- (r, c) => {
466
- const { node: a } = c;
467
- this.changesets.forEach((u) => {
468
- const { changeset: h, target: o, removes: p } = u, [l, d] = h;
469
- o.match(c.node) && (l.properties && p.push(a.writeProperties(l.properties, d)), l.context && p.push(a.writeContext(l.context, d)), l.layout && p.push(a.writeLayout(l.layout, d)));
470
- });
471
- }
472
- )
473
- ), this.subscriptions.push(
474
- this.events.subscribe(
475
- "components:node-appended",
476
- (r, c) => {
477
- i(c.node, { properties: !0, context: !0 });
478
- }
479
- )
480
- ), this.subscriptions.push(
481
- this.events.subscribe(
482
- "components:set-properties",
483
- (r, c) => {
484
- i(c.node, { properties: !0 });
485
- }
486
- )
487
- ), this.subscriptions.push(
488
- this.events.subscribe(
489
- "components:set-context",
490
- (r, c) => {
491
- i(c.node, { properties: !0, context: !0 });
492
- }
493
- )
494
- ), this.subscriptions.push(
495
- this.events.subscribe(
496
- "components:set-indent",
497
- (r, c) => {
498
- i(c.node, { layout: !0 });
499
- }
500
- )
501
- ), this.subscriptions.push(
502
- this.events.subscribe(
503
- "components:set-layout",
504
- (r, c) => {
505
- i(c.node, { layout: !0 });
506
- }
507
- )
508
- ), this.subscriptions.push(
509
- this.events.subscribe("components:node-switched", (r, { node: c, branch: a }) => {
510
- i(c, {
511
- layout: !0,
512
- recursive: !0,
513
- properties: !0,
514
- context: !0
515
- });
516
- })
517
- ), this.subscriptions.push(
518
- this.events.subscribe("components:node-removed", (r, { parentNode: c }) => {
519
- i(c, { properties: !0 });
520
- })
521
- ), this.events.parent && this.events.parent.dispatch("components:platform-created", { platform: this });
522
- }
523
- static getInstance(t) {
524
- return t.getAsync("components");
525
- }
526
- addBreakpoint(t) {
527
- this.breakpoints.indexOf(t) === -1 && (this.breakpoints.push(t), this.processNode(this.nodes.root, {
528
- context: !0,
529
- properties: !0,
530
- layout: !0,
531
- recursive: !0
532
- }));
533
- }
534
- removeBreakpoint(t) {
535
- const e = this.breakpoints.indexOf(t);
536
- e > -1 && (this.breakpoints.splice(e, 1), this.processNode(this.nodes.root, {
537
- context: !0,
538
- properties: !0,
539
- layout: !0,
540
- recursive: !0
541
- }));
542
- }
543
- setSwitch(t, e) {
544
- this.switches[t.id] = e, this.events.dispatch("components:node-switched", { node: t, branch: e });
545
- }
546
- getBranch(t) {
547
- return this.switches[t.id];
548
- }
549
- /**
550
- * Creates a `ComponentNode` of the specified type.
551
- * @param type Type of node.
552
- */
553
- createNode(t, e = {}) {
554
- const n = new L(this.events, t);
555
- return e.detached && this.nodes.detached.push(n), n;
556
- }
557
- components() {
558
- return new P(this);
559
- }
560
- actions(t, e) {
561
- return new k(this, t, e);
562
- }
563
- write(t) {
564
- const { provider: e, target: n, attributes: i, options: r = {}, removable: c } = t, a = t.key || O(), h = { changeset: [i, r], target: n, removes: [] };
565
- if (e) {
566
- const o = this.providers[e];
567
- o.write(a, n, i, r), h.removes.push(() => {
568
- o.remove(a);
569
- });
570
- }
571
- return this.changesets.push(h), this.nodes.all.forEach((o) => {
572
- if (n.match(o)) {
573
- let p = () => {
574
- };
575
- i.properties && (p = o.writeProperties(i.properties, r, c)), i.context && (p = o.writeContext(i.context, r, c)), i.layout && (p = o.writeContext(i.layout, r, c)), h.removes.push(p);
576
- }
577
- }), () => {
578
- if (c) {
579
- h.removes.forEach((p) => p());
580
- const o = this.changesets.indexOf(h);
581
- o > -1 && this.changesets.splice(o, 1);
582
- }
583
- };
584
- }
585
- addComponentHandler(t, e) {
586
- this.customComponentHandler.add(t, e);
587
- }
588
- getComponentHandler(t) {
589
- return this.customComponentHandler.get(t);
590
- }
591
- dispose() {
592
- this.subscriptions.forEach((t) => t());
593
- }
594
- }
595
- const ut = (s) => {
596
- if (Array.isArray(s)) {
597
- const [t, ...e] = s;
598
- return {
599
- definitionId: t,
600
- overrides: e
601
- };
602
- }
603
- return {
604
- definitionId: s,
605
- overrides: []
606
- };
607
- }, E = (s, t, e, n, i, r) => {
608
- e.forEach((c) => {
609
- const a = ut(c), u = n[a.definitionId];
610
- if (a.definitionId === "view") {
611
- const h = s.createNode("view");
612
- h.name = "view", Object.keys(i).forEach((o) => {
613
- const p = i[o];
614
- E(s, h, [p.entry], n, i, o);
615
- }), t.appendChild(h), a.overrides.forEach((o) => {
616
- o.properties && h.writeProperties(o.properties, {
617
- breakpoints: o.breakpoints
618
- }), o.context && h.writeContext(o.context, { breakpoints: o.breakpoints }), o.layout && h.writeLayout(o.layout, { breakpoints: o.breakpoints });
619
- });
620
- } else if (s.getComponentHandler(u.type)) {
621
- const h = s.getComponentHandler(u.type);
622
- h && h(a, {
623
- platform: s,
624
- node: t,
625
- references: e,
626
- definitions: n,
627
- views: i,
628
- branch: r
629
- });
630
- } else {
631
- const h = n[a.definitionId];
632
- if (process.env.NODE_ENV !== "production" && !h) {
633
- N.error(
634
- `No definition found for component type '${a.definitionId}'.`
635
- );
636
- return;
637
- }
638
- const o = s.createNode(h.type);
639
- o.name = a.definitionId, o.tags = h.tags || [], h.properties && o.writeProperties(h.properties), h.context && o.writeContext(h.context), h.layout && o.writeLayout(h.layout), t.appendChild(o, r), a.overrides.forEach((p) => {
640
- const l = { breakpoints: p.breakpoints };
641
- p.properties && o.writeProperties(p.properties, l), p.context && o.writeContext(p.context, l), p.layout && o.writeLayout(p.layout, l);
642
- }), h.children && E(s, o, h.children, n, i);
643
- }
644
- });
645
- }, Ct = (s, t) => {
646
- const { entry: e, components: n, breakpoints: i, views: r } = t, c = [];
647
- return Object.keys(i).forEach((a) => {
648
- const u = i[a], h = window.matchMedia(u);
649
- h.matches && s.breakpoints.push(a);
650
- const o = (p) => {
651
- p.matches ? s.addBreakpoint(a) : s.removeBreakpoint(a);
652
- };
653
- h.addListener(o), c.push(() => h.removeListener(o));
654
- }), E(s, s.nodes.root, [e], n, r), () => c.forEach((a) => {
655
- a();
656
- });
657
- }, Et = (s, t) => ({
658
- id: s.id,
659
- type: s.type,
660
- name: s.name,
661
- branch: t || "default"
662
- }), Ot = (s, t, e, n = O(), i = {}) => s.getAsync("components").then((r) => {
663
- let c;
664
- if (typeof t == "string") {
665
- const h = new P(r);
666
- h.ofType(t), c = h;
667
- } else
668
- c = t;
669
- const a = {}, u = (h) => {
670
- const o = a[h.id];
671
- return o ? Promise.resolve(o.controller) : pt.getInstance(s).then((p) => new H(p, h, n));
672
- };
673
- r.events.subscribe(
674
- "components:node-enter",
675
- (h, { node: o }) => {
676
- c.match(o) && u(o).then((p) => {
677
- Promise.resolve(e(p)).then((l) => {
678
- a[o.id] = {
679
- dispose: l,
680
- controller: p
681
- };
682
- });
683
- });
684
- }
685
- ), r.events.subscribe(
686
- "components:node-exit",
687
- (h, { node: o }) => {
688
- const p = a[o.id];
689
- p && (p.dispose && p.dispose(), i.reuseController || (p.controller.dispose(), delete a[o.id]));
690
- }
691
- );
692
- });
693
- class Nt {
694
- constructor(t) {
695
- this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new N();
696
- const { events: e } = t.get("$widget");
697
- this.events = e;
698
- }
699
- getComponent(t) {
700
- const e = this.aliases.get(t), n = this.components.get(e || t) || null;
701
- return process.env.NODE_ENV !== "production" && (n || this.logger.warn(
702
- e || t,
703
- `Unable to resolve component: "${e || t}". You most likely forgot to register the required plugin for: ${e || t}.`
704
- )), n;
705
- }
706
- registerComponent(t, e) {
707
- return this.components.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
708
- this.components.delete(t);
709
- };
710
- }
711
- registerResolver(t, e) {
712
- return this.events.subscribe("component-resolver:resolve", (n, i) => {
713
- if (i === t) {
714
- const r = this.getComponent(t);
715
- e(r);
716
- }
717
- });
718
- }
719
- registerAlias(t, e) {
720
- return this.aliases.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
721
- this.aliases.delete(t);
722
- };
723
- }
724
- }
725
- const lt = "#____version____#", M = class extends Y {
726
- constructor(s, t = []) {
727
- super(s, t, {
728
- transformPluginSettings: (e, n, i) => {
729
- const r = i.get("$settings"), c = r.plugins && n ? r.plugins[n] || {} : {};
730
- return y(y({}, c), e);
731
- }
732
- });
733
- }
734
- createImplementation(s) {
735
- const t = super.createImplementation(s);
736
- return t.bindings = s.bindings, t;
737
- }
738
- /**
739
- * Performs navigation for widgets matching the specified selector by invoking a
740
- * 'navigate' command.
741
- * @param selector Widget selector matching the widget(s) to perform navigation on.
742
- * @param route Route name.
743
- * @param params Route params.
744
- */
745
- navigate(s, t, e) {
746
- this.widgets.query(s).forEach((n) => n.invoke("navigate", { route: t, params: e }));
747
- }
748
- /**
749
- * Creates a runtime based on provided configuration.
750
- * @param configuration Runtime configuration.
751
- */
752
- static create(s = {}) {
753
- const t = [G].concat(
754
- s.configurationApiExtensions || []
755
- );
756
- return new M("humany", t);
757
- }
758
- /**
759
- * Creates a widget runtime based on provided configuration and retains configuration handlers
760
- * registered on global context. Use this factory to fully support the default embed script.
761
- * Will return any existing widget runtime if available.
762
- * @param configuration Runtime configuration.
763
- * @param global Object to read configuration handlers from (default: window).
764
- */
765
- static createFromGlobal(s, t = {}) {
766
- if (this.isRuntime(s))
767
- return s.patch(t), s;
768
- const e = [], n = s && s._c;
769
- n && n.forEach((r) => e.push(r));
770
- const i = this.create(t);
771
- return i.container.register("$runtimecfg", e), i;
772
- }
773
- /**
774
- * Determines whether the specified object is a valid widget runtime.
775
- * @param obj Object to compare.
776
- */
777
- static isRuntime(s) {
778
- return !!(s && typeof s == "object" && s.container && typeof s.container.get == "function" && s.container.get("$environment") === s && s.container.owner === s);
779
- }
780
- };
781
- let dt = M;
782
- dt.version = `${lt} (${W})`;
783
- class Pt extends J {
784
- constructor() {
785
- super(...arguments), this.bindings = [];
786
- }
787
- }
788
- class kt extends X {
789
- constructor(t, e) {
790
- super(t, e);
791
- }
792
- }
793
- var mt = /* @__PURE__ */ ((s) => (s.open = "open", s.closed = "closed", s.hidden = "hidden", s))(mt || {});
794
- class $t extends Z {
795
- constructor(t) {
796
- super(t);
797
- }
798
- }
799
- export {
800
- yt as ActionResolver,
801
- k as ActionsController,
802
- L as ComponentNode,
803
- H as ComponentNodeController,
804
- pt as ComponentPlatform,
805
- P as ComponentQuery,
806
- Nt as ComponentResolver,
807
- dt as Environment,
808
- Pt as Implementation,
809
- kt as Plugin,
810
- mt as WidgetRenderState,
811
- $t as WidgetType,
812
- Et as asDescriptor,
813
- xt as bootstrap,
814
- wt as componentConfigurationApi,
815
- E as createChildren,
816
- Ct as createComponentModel,
817
- tt as createEventSubscriber,
818
- Ot as extendComponent,
819
- nt as findComponent,
820
- w as findVisibleComponents,
821
- $ as traverseComponents,
822
- lt as version
823
- };
824
- //# sourceMappingURL=index.js.map