@telia-ace/widget-core 1.0.14 → 1.0.16-next.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.
package/dist/index.js CHANGED
@@ -1,19 +1,21 @@
1
- var M = Object.defineProperty, V = Object.defineProperties;
2
- var _ = Object.getOwnPropertyDescriptors;
3
- var I = Object.getOwnPropertySymbols;
4
- var z = Object.prototype.hasOwnProperty, Q = Object.prototype.propertyIsEnumerable;
5
- var L = (n, t, e) => t in n ? M(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, S = (n, t) => {
1
+ var V = Object.defineProperty, _ = Object.defineProperties;
2
+ var z = Object.getOwnPropertyDescriptors;
3
+ var S = Object.getOwnPropertySymbols;
4
+ var Q = Object.prototype.hasOwnProperty, q = Object.prototype.propertyIsEnumerable;
5
+ var w = (n, t, e) => t in n ? V(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, j = (n, t) => {
6
6
  for (var e in t || (t = {}))
7
- z.call(t, e) && L(n, e, t[e]);
8
- if (I)
9
- for (var e of I(t))
10
- Q.call(t, e) && L(n, e, t[e]);
7
+ Q.call(t, e) && w(n, e, t[e]);
8
+ if (S)
9
+ for (var e of S(t))
10
+ q.call(t, e) && w(n, e, t[e]);
11
11
  return n;
12
- }, j = (n, t) => V(n, _(t));
13
- import { createConfigurationApi as q } from "@webprovisions/platform";
14
- import { uuid as E, Logger as O } from "@telia-ace/widget-utilities";
15
- class ct {
12
+ }, H = (n, t) => _(n, z(t));
13
+ var l = (n, t, e) => (w(n, typeof t != "symbol" ? t + "" : t, e), e);
14
+ import { createConfigurationApi as K } from "@webprovisions/platform";
15
+ import { uuid as N, Logger as k } from "@telia-ace/widget-utilities";
16
+ class ht {
16
17
  constructor(t) {
18
+ l(this, "events");
17
19
  const { events: e } = t.get("$widget");
18
20
  this.events = e.createChild(this);
19
21
  }
@@ -21,10 +23,13 @@ class ct {
21
23
  this.events.dispatch("data:action", { action: e, value: s, target: t }, { bubbles: !0 });
22
24
  }
23
25
  subscribe(t, e) {
24
- return this.events.subscribe("data:action", (s, { action: r, value: c, target: o }) => t === o && e(t, r, c));
26
+ return this.events.subscribe(
27
+ "data:action",
28
+ (s, { action: r, value: c, target: o }) => t === o && e(t, r, c)
29
+ );
25
30
  }
26
31
  }
27
- const K = (n) => {
32
+ const U = (n) => {
28
33
  const t = [];
29
34
  return [
30
35
  (s, r) => {
@@ -37,7 +42,7 @@ const K = (n) => {
37
42
  }
38
43
  ];
39
44
  };
40
- class N {
45
+ class P {
41
46
  constructor(t, e = []) {
42
47
  this.platform = t, this.rules = e;
43
48
  }
@@ -51,13 +56,20 @@ class N {
51
56
  return this.rules.push({ id: t }), this;
52
57
  }
53
58
  select() {
54
- return new U(this.platform, this);
59
+ return new Y(this.platform, this);
55
60
  }
56
61
  }
57
- class $ {
62
+ class B {
58
63
  constructor(t, e, s) {
59
- this.platform = t, this.node = e, this.actions = new k(t, new N(t).withId(e.id), s);
60
- const [r, c] = K(this.platform.events);
64
+ l(this, "actions");
65
+ l(this, "subscribe");
66
+ l(this, "unsubscribe");
67
+ this.platform = t, this.node = e, this.actions = new R(
68
+ t,
69
+ new P(t).withId(e.id),
70
+ s
71
+ );
72
+ const [r, c] = U(this.platform.events);
61
73
  this.subscribe = r, this.unsubscribe = c;
62
74
  }
63
75
  properties(t) {
@@ -86,33 +98,41 @@ class $ {
86
98
  this.unsubscribe(), this.actions.dispose();
87
99
  }
88
100
  }
89
- class U {
101
+ class Y {
90
102
  constructor(t, e, s = !0) {
91
- this.platform = t, this.target = e, this.clearOnDispose = s, this.removes = [], this.actions = new k(this.platform, this.target);
103
+ l(this, "actions");
104
+ l(this, "removes", []);
105
+ this.platform = t, this.target = e, this.clearOnDispose = s, this.actions = new R(this.platform, this.target);
92
106
  }
93
107
  writeProperties(t, e) {
94
- this.removes.push(this.platform.write({
95
- options: e,
96
- attributes: { properties: t },
97
- target: this.target,
98
- removable: this.clearOnDispose
99
- }));
108
+ this.removes.push(
109
+ this.platform.write({
110
+ options: e,
111
+ attributes: { properties: t },
112
+ target: this.target,
113
+ removable: this.clearOnDispose
114
+ })
115
+ );
100
116
  }
101
117
  writeContext(t, e) {
102
- this.removes.push(this.platform.write({
103
- options: e,
104
- attributes: { context: t },
105
- target: this.target,
106
- removable: this.clearOnDispose
107
- }));
118
+ this.removes.push(
119
+ this.platform.write({
120
+ options: e,
121
+ attributes: { context: t },
122
+ target: this.target,
123
+ removable: this.clearOnDispose
124
+ })
125
+ );
108
126
  }
109
127
  writeLayout(t, e) {
110
- this.removes.push(this.platform.write({
111
- options: e,
112
- attributes: { layout: t },
113
- target: this.target,
114
- removable: this.clearOnDispose
115
- }));
128
+ this.removes.push(
129
+ this.platform.write({
130
+ options: e,
131
+ attributes: { layout: t },
132
+ target: this.target,
133
+ removable: this.clearOnDispose
134
+ })
135
+ );
116
136
  }
117
137
  dispose() {
118
138
  this.removes.forEach((t) => {
@@ -120,12 +140,12 @@ class U {
120
140
  }), this.actions.dispose();
121
141
  }
122
142
  }
123
- const Y = (n, t, e) => {
143
+ const F = (n, t, e) => {
124
144
  const s = n.concat(), r = (c, o, a) => {
125
145
  let u = !0;
126
146
  if (s.length) {
127
- const h = s.shift(), i = (p, l) => (u = !1, r(p, Object.assign({}, o, l), a));
128
- return Promise.resolve(h(c, i, a)).then((p) => j(S({}, p), {
147
+ const h = s.shift(), i = (p, d) => (u = !1, r(p, Object.assign({}, o, d), a));
148
+ return Promise.resolve(h(c, i, a)).then((p) => H(j({}, p), {
129
149
  cancelled: u
130
150
  }));
131
151
  }
@@ -133,9 +153,10 @@ const Y = (n, t, e) => {
133
153
  };
134
154
  return r(t, {}, e);
135
155
  };
136
- class k {
156
+ class R {
137
157
  constructor(t, e, s) {
138
- this.platform = t, this.target = e, this.ns = s, this.subscriptions = [], this.create = this.create.bind(this);
158
+ l(this, "subscriptions", []);
159
+ this.platform = t, this.target = e, this.ns = s, this.create = this.create.bind(this);
139
160
  }
140
161
  create(t, e = () => {
141
162
  }) {
@@ -153,19 +174,35 @@ class k {
153
174
  return this.subscriptions.push(r), r;
154
175
  }
155
176
  dispatch(t, e) {
156
- const s = this.platform.nodes.all.concat(this.platform.nodes.detached), r = {}, c = this.platform.actionsState.handlers.filter((o) => o.key === t && (!o.ns || !this.ns || o.ns === this.ns));
157
- return Promise.all(c.map((o) => {
158
- const a = s.filter((h) => o.target.match(h) && this.target.match(h)), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some((i) => h.target.match(i))).map((h) => h.fn);
159
- return Promise.all(a.map((h) => {
160
- const i = new $(this.platform, h, this.ns);
161
- return Y(u, e, i).then((p) => {
162
- const { data: l = {}, options: d, cancelled: v } = p;
163
- return Promise.resolve(v ? {} : o.fn(l, d, i)).then((g) => {
164
- r[h.id] = g;
165
- });
166
- });
167
- }));
168
- })).then(() => r);
177
+ const s = this.platform.nodes.all.concat(
178
+ this.platform.nodes.detached
179
+ ), r = {}, c = this.platform.actionsState.handlers.filter(
180
+ (o) => o.key === t && (!o.ns || !this.ns || o.ns === this.ns)
181
+ );
182
+ return Promise.all(
183
+ c.map((o) => {
184
+ const a = s.filter(
185
+ (h) => o.target.match(h) && this.target.match(h)
186
+ ), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some((i) => h.target.match(i))).map((h) => h.fn);
187
+ return Promise.all(
188
+ a.map((h) => {
189
+ const i = new B(
190
+ this.platform,
191
+ h,
192
+ this.ns
193
+ );
194
+ return F(u, e, i).then((p) => {
195
+ const { data: d = {}, options: f, cancelled: g } = p;
196
+ return Promise.resolve(
197
+ g ? {} : o.fn(d, f, i)
198
+ ).then((y) => {
199
+ r[h.id] = y;
200
+ });
201
+ });
202
+ })
203
+ );
204
+ })
205
+ ).then(() => r);
169
206
  }
170
207
  watch(t, e) {
171
208
  let s = t, r = this.ns;
@@ -188,7 +225,7 @@ class k {
188
225
  this.subscriptions.forEach((t) => t());
189
226
  }
190
227
  }
191
- const ht = q((n) => {
228
+ const at = K((n) => {
192
229
  n.createCommand("components", (t) => (e) => {
193
230
  t.events.subscribeOnce("components:platform-created", (s, { platform: r }) => {
194
231
  e.handlers && e.handlers.forEach(([c, o]) => {
@@ -197,9 +234,18 @@ const ht = q((n) => {
197
234
  });
198
235
  });
199
236
  });
200
- class H {
237
+ class $ {
201
238
  constructor(t, e) {
202
- this.events = t, this.tags = [], this.children = {}, this.changesets = [], this.mountCount = 0, this.id = E(), this.type = e, this.attributes = {
239
+ l(this, "id");
240
+ l(this, "type");
241
+ l(this, "name");
242
+ l(this, "parent");
243
+ l(this, "tags", []);
244
+ l(this, "children", {});
245
+ l(this, "changesets", []);
246
+ l(this, "attributes");
247
+ l(this, "mountCount", 0);
248
+ this.events = t, this.id = N(), this.type = e, this.attributes = {
203
249
  context: {},
204
250
  properties: {},
205
251
  layout: {},
@@ -208,7 +254,7 @@ class H {
208
254
  }
209
255
  mount(t, e) {
210
256
  let s = t.get("mounted-nodes");
211
- return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && O.error("Trying to mount an already mounted component node.", this), () => {
257
+ return s || (s = /* @__PURE__ */ new Map(), t.register("mounted-nodes", s)), s.has(this) ? (process.env.NODE_ENV !== "production" && k.error("Trying to mount an already mounted component node.", this), () => {
212
258
  }) : (this.events.dispatch("components:node-mounted", { node: this }), this.mountCount === 0 && (this.mountCount = this.mountCount + 1, this.events.dispatch("components:node-enter", { node: this })), () => {
213
259
  s.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 });
214
260
  });
@@ -282,52 +328,55 @@ class H {
282
328
  }), delete t.parent;
283
329
  }
284
330
  }
285
- const B = (n, t, e) => {
331
+ const M = (n, t, e) => {
286
332
  for (let s = 0, r = n.length; s < r && e(n[s]) !== !0; s++) {
287
333
  const c = t[n[s].id] || "default", o = n[s].getChildren(c);
288
- B(o, t, e);
334
+ M(o, t, e);
289
335
  }
290
- }, P = (n, t, e) => {
336
+ }, A = (n, t, e) => {
291
337
  if (e(n) !== !0) {
292
338
  const s = t[n.id] || "default", r = n.children[s];
293
- B(r, t, e);
339
+ M(r, t, e);
294
340
  }
295
- }, x = (n, t) => {
341
+ }, C = (n, t) => {
296
342
  const e = [];
297
- return P(n, t, (s) => {
343
+ return A(n, t, (s) => {
298
344
  e.push(s);
299
345
  }), e;
300
- }, F = (n, t, e) => {
346
+ }, G = (n, t, e) => {
301
347
  let s;
302
- return P(n, t, (r) => {
348
+ return A(n, t, (r) => {
303
349
  if (e(r))
304
350
  return s = r, !0;
305
351
  }), s;
306
352
  };
307
- class G {
353
+ class J {
308
354
  constructor(t, e, s) {
309
- this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe("components:node-appended", (r, c) => {
310
- this.all.push(c.node), this.visible = x(t, e);
355
+ l(this, "all", []);
356
+ l(this, "visible", []);
357
+ l(this, "detached", []);
358
+ this.root = t, this.switches = e, s.subscribe("components:node-appended", (r, c) => {
359
+ this.all.push(c.node), this.visible = C(t, e);
311
360
  }), s.subscribe("components:node-removed", (r, c) => {
312
361
  let o = this.all.indexOf(c.node);
313
- o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(c.node), o > -1 && this.visible.splice(o, 1), this.visible = x(t, e);
362
+ o > -1 && this.all.splice(o, 1), o = this.visible.indexOf(c.node), o > -1 && this.visible.splice(o, 1), this.visible = C(t, e);
314
363
  }), s.subscribe("components:node-switched", (r, c) => {
315
- this.visible = x(t, e);
364
+ this.visible = C(t, e);
316
365
  });
317
366
  }
318
367
  query(t = {}) {
319
368
  const e = [];
320
- return P(this.root, this.switches, (s) => {
369
+ return A(this.root, this.switches, (s) => {
321
370
  Object.keys(t).every((c) => t[c] === s[c]) && e.push(s);
322
371
  }), e;
323
372
  }
324
373
  get(t) {
325
- return F(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
374
+ return G(this.root, this.switches, (e) => e.id === t) || this.detached.find((e) => e.id === t);
326
375
  }
327
376
  }
328
- class J {
377
+ class X {
329
378
  constructor() {
330
- this.handlers = /* @__PURE__ */ new Map();
379
+ l(this, "handlers", /* @__PURE__ */ new Map());
331
380
  }
332
381
  add(t, e) {
333
382
  this.handlers.set(t, e);
@@ -336,47 +385,49 @@ class J {
336
385
  return this.handlers.get(t);
337
386
  }
338
387
  }
339
- const X = (n) => {
388
+ const Z = (n) => {
340
389
  let t = n, e = 0;
341
390
  for (; t.parent; )
342
391
  e = e + 1, t = t.parent;
343
392
  return e;
344
- }, Z = (n) => n.map(([e, s]) => [X(e), e, s]).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), w = (n) => n && typeof n == "object" && !Array.isArray(n), b = (n, ...t) => {
393
+ }, W = (n) => n.map(([e, s]) => [Z(e), e, s]).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), E = (n) => n && typeof n == "object" && !Array.isArray(n), v = (n, ...t) => {
345
394
  if (!t.length)
346
395
  return n;
347
396
  const e = t.shift();
348
- if (w(n) && w(e))
397
+ if (E(n) && E(e))
349
398
  for (const s in e)
350
- w(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), b(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
351
- return b(n, ...t);
352
- }, W = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), tt = (n, t) => {
399
+ E(e[s]) ? (n[s] || Object.assign(n, { [s]: {} }), v(n[s], e[s])) : Object.assign(n, { [s]: e[s] });
400
+ return v(n, ...t);
401
+ }, tt = (n, t) => !n || n === "all" ? !0 : n.some((e) => t.indexOf(e) > -1), et = (n, t) => {
353
402
  let e = [], s = [], r;
354
403
  const c = () => {
355
404
  process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
356
- const a = /* @__PURE__ */ new Map(), u = Z(e.map((i, p) => [i, s[p]])), h = (i, p) => {
357
- var T;
358
- const l = a.get(i) || {}, d = p.context && !l.context, v = p.properties && !l.properties, g = p.layout && !l.layout;
405
+ const a = /* @__PURE__ */ new Map(), u = W(e.map((i, p) => [i, s[p]])), h = (i, p) => {
406
+ var L;
407
+ const d = a.get(i) || {}, f = p.context && !d.context, g = p.properties && !d.properties, y = p.layout && !d.layout;
359
408
  a.set(i, {
360
- context: l.context || d,
361
- properties: l.properties || v,
362
- layout: l.layout || g
363
- }), v && (i.attributes.properties = {}), g && (i.attributes.layout = {}), d && (i.attributes.context = b({}, (T = i.parent) == null ? void 0 : T.attributes.context));
364
- const R = [], A = [], D = [];
365
- if (i.changesets.forEach((m) => {
366
- const [f, y] = m;
367
- W(y.breakpoints, n.breakpoints) && (v && (typeof f.properties == "function" ? R.push(f.properties) : b(i.attributes.properties, f.properties)), g && (typeof f.layout == "function" ? A.push(f.layout) : b(i.attributes.layout, f.layout)), d && (typeof f.context == "function" ? D.push(f.context) : b(i.attributes.context, f.context)));
368
- }), R.forEach((m) => {
369
- b(i.attributes.properties, m(i.attributes.properties));
370
- }), A.forEach((m) => {
371
- b(i.attributes.layout, m(i.attributes.layout));
372
- }), D.forEach((m) => {
373
- b(i.attributes.context, m(i.attributes.context));
374
- }), d || p.recursive) {
375
- const m = n.getBranch(i), f = p.recursive ? p : {
376
- context: !!d
409
+ context: d.context || f,
410
+ properties: d.properties || g,
411
+ layout: d.layout || y
412
+ }), g && (i.attributes.properties = {}), y && (i.attributes.layout = {}), f && (i.attributes.context = v({}, (L = i.parent) == null ? void 0 : L.attributes.context));
413
+ const D = [], T = [], I = [];
414
+ if (i.changesets.forEach((b) => {
415
+ const [m, x] = b;
416
+ tt(x.breakpoints, n.breakpoints) && (g && (typeof m.properties == "function" ? D.push(
417
+ m.properties
418
+ ) : v(i.attributes.properties, m.properties)), y && (typeof m.layout == "function" ? T.push(m.layout) : v(i.attributes.layout, m.layout)), f && (typeof m.context == "function" ? I.push(m.context) : v(i.attributes.context, m.context)));
419
+ }), D.forEach((b) => {
420
+ v(i.attributes.properties, b(i.attributes.properties));
421
+ }), T.forEach((b) => {
422
+ v(i.attributes.layout, b(i.attributes.layout));
423
+ }), I.forEach((b) => {
424
+ v(i.attributes.context, b(i.attributes.context));
425
+ }), f || p.recursive) {
426
+ const b = n.getBranch(i), m = p.recursive ? p : {
427
+ context: !!f
377
428
  };
378
- i.getChildren(m).forEach((y) => {
379
- h(y, f);
429
+ i.getChildren(b).forEach((x) => {
430
+ h(x, m);
380
431
  });
381
432
  }
382
433
  };
@@ -395,46 +446,93 @@ const X = (n) => {
395
446
  return e.push(a), s.push(u), o();
396
447
  };
397
448
  };
398
- class et {
449
+ class st {
399
450
  constructor(t, e = {}) {
400
- this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new J(), this.events = t.events.createChild(this);
401
- const s = new H(this.events, "root");
402
- s.name = `root-${t.name}`, this.nodes = new G(s, this.switches, this.events);
403
- const r = this.processNode = tt(this, (c) => {
451
+ l(this, "events");
452
+ l(this, "breakpoints", []);
453
+ l(this, "nodes");
454
+ l(this, "actionsState", { handlers: [], watchers: [] });
455
+ l(this, "switches", {});
456
+ l(this, "changesets", []);
457
+ l(this, "subscriptions", []);
458
+ l(this, "processNode");
459
+ l(this, "customComponentHandler", new X());
460
+ this.providers = e, this.events = t.events.createChild(this);
461
+ const s = new $(this.events, "root");
462
+ s.name = `root-${t.name}`, this.nodes = new J(s, this.switches, this.events);
463
+ const r = this.processNode = et(this, (c) => {
404
464
  const o = Array.from(c.keys());
405
465
  process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${o.length} node(s) processed:
406
- ${o.map((a) => `${a.name || "<no name>"} (${a.id})
407
- `)}`), o.forEach((a) => {
466
+ ${o.map(
467
+ (a) => `${a.name || "<no name>"} (${a.id})
468
+ `
469
+ )}`), o.forEach((a) => {
408
470
  const u = c.get(a);
409
471
  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 });
410
472
  }), this.events.dispatch("components:component-model-initialized", {}, { bubbles: !0 });
411
473
  });
412
- Promise.all(Object.keys(e).map((c) => e[c].load(this))), this.subscriptions.push(this.events.subscribe("components:node-appended", (c, o) => {
413
- const { node: a } = o;
414
- this.changesets.forEach((u) => {
415
- const { changeset: h, target: i, removes: p } = u, [l, d] = h;
416
- i.match(o.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)));
417
- });
418
- })), this.subscriptions.push(this.events.subscribe("components:node-appended", (c, o) => {
419
- r(o.node, { properties: !0, context: !0 });
420
- })), this.subscriptions.push(this.events.subscribe("components:set-properties", (c, o) => {
421
- r(o.node, { properties: !0 });
422
- })), this.subscriptions.push(this.events.subscribe("components:set-context", (c, o) => {
423
- r(o.node, { properties: !0, context: !0 });
424
- })), this.subscriptions.push(this.events.subscribe("components:set-indent", (c, o) => {
425
- r(o.node, { layout: !0 });
426
- })), this.subscriptions.push(this.events.subscribe("components:set-layout", (c, o) => {
427
- r(o.node, { layout: !0 });
428
- })), this.subscriptions.push(this.events.subscribe("components:node-switched", (c, { node: o, branch: a }) => {
429
- r(o, {
430
- layout: !0,
431
- recursive: !0,
432
- properties: !0,
433
- context: !0
434
- });
435
- })), this.subscriptions.push(this.events.subscribe("components:node-removed", (c, { parentNode: o }) => {
436
- r(o, { properties: !0 });
437
- })), this.events.parent && this.events.parent.dispatch("components:platform-created", { platform: this });
474
+ Promise.all(
475
+ Object.keys(e).map((c) => e[c].load(this))
476
+ ), this.subscriptions.push(
477
+ this.events.subscribe(
478
+ "components:node-appended",
479
+ (c, o) => {
480
+ const { node: a } = o;
481
+ this.changesets.forEach((u) => {
482
+ const { changeset: h, target: i, removes: p } = u, [d, f] = h;
483
+ i.match(o.node) && (d.properties && p.push(a.writeProperties(d.properties, f)), d.context && p.push(a.writeContext(d.context, f)), d.layout && p.push(a.writeLayout(d.layout, f)));
484
+ });
485
+ }
486
+ )
487
+ ), this.subscriptions.push(
488
+ this.events.subscribe(
489
+ "components:node-appended",
490
+ (c, o) => {
491
+ r(o.node, { properties: !0, context: !0 });
492
+ }
493
+ )
494
+ ), this.subscriptions.push(
495
+ this.events.subscribe(
496
+ "components:set-properties",
497
+ (c, o) => {
498
+ r(o.node, { properties: !0 });
499
+ }
500
+ )
501
+ ), this.subscriptions.push(
502
+ this.events.subscribe(
503
+ "components:set-context",
504
+ (c, o) => {
505
+ r(o.node, { properties: !0, context: !0 });
506
+ }
507
+ )
508
+ ), this.subscriptions.push(
509
+ this.events.subscribe(
510
+ "components:set-indent",
511
+ (c, o) => {
512
+ r(o.node, { layout: !0 });
513
+ }
514
+ )
515
+ ), this.subscriptions.push(
516
+ this.events.subscribe(
517
+ "components:set-layout",
518
+ (c, o) => {
519
+ r(o.node, { layout: !0 });
520
+ }
521
+ )
522
+ ), this.subscriptions.push(
523
+ this.events.subscribe("components:node-switched", (c, { node: o, branch: a }) => {
524
+ r(o, {
525
+ layout: !0,
526
+ recursive: !0,
527
+ properties: !0,
528
+ context: !0
529
+ });
530
+ })
531
+ ), this.subscriptions.push(
532
+ this.events.subscribe("components:node-removed", (c, { parentNode: o }) => {
533
+ r(o, { properties: !0 });
534
+ })
535
+ ), this.events.parent && this.events.parent.dispatch("components:platform-created", { platform: this });
438
536
  }
439
537
  static getInstance(t) {
440
538
  return t.getAsync("components");
@@ -463,17 +561,17 @@ ${o.map((a) => `${a.name || "<no name>"} (${a.id})
463
561
  return this.switches[t.id];
464
562
  }
465
563
  createNode(t, e = {}) {
466
- const s = new H(this.events, t);
564
+ const s = new $(this.events, t);
467
565
  return e.detached && this.nodes.detached.push(s), s;
468
566
  }
469
567
  components() {
470
- return new N(this);
568
+ return new P(this);
471
569
  }
472
570
  actions(t, e) {
473
- return new k(this, t, e);
571
+ return new R(this, t, e);
474
572
  }
475
573
  write(t) {
476
- const { provider: e, target: s, attributes: r, options: c = {}, removable: o } = t, a = t.key || E(), h = { changeset: [r, c], target: s, removes: [] };
574
+ const { provider: e, target: s, attributes: r, options: c = {}, removable: o } = t, a = t.key || N(), h = { changeset: [r, c], target: s, removes: [] };
477
575
  if (e) {
478
576
  const i = this.providers[e];
479
577
  i.write(a, s, r, c), h.removes.push(() => {
@@ -504,7 +602,7 @@ ${o.map((a) => `${a.name || "<no name>"} (${a.id})
504
602
  this.subscriptions.forEach((t) => t());
505
603
  }
506
604
  }
507
- const st = (n) => {
605
+ const nt = (n) => {
508
606
  if (Array.isArray(n)) {
509
607
  const [t, ...e] = n;
510
608
  return {
@@ -516,14 +614,14 @@ const st = (n) => {
516
614
  definitionId: n,
517
615
  overrides: []
518
616
  };
519
- }, C = (n, t, e, s, r, c) => {
617
+ }, O = (n, t, e, s, r, c) => {
520
618
  e.forEach((o) => {
521
- const a = st(o), u = s[a.definitionId];
619
+ const a = nt(o), u = s[a.definitionId];
522
620
  if (a.definitionId === "view") {
523
621
  const h = n.createNode("view");
524
622
  h.name = "view", Object.keys(r).forEach((i) => {
525
623
  const p = r[i];
526
- C(n, h, [p.entry], s, r, i);
624
+ O(n, h, [p.entry], s, r, i);
527
625
  }), t.appendChild(h), a.overrides.forEach((i) => {
528
626
  i.properties && h.writeProperties(i.properties, {
529
627
  breakpoints: i.breakpoints
@@ -542,17 +640,19 @@ const st = (n) => {
542
640
  } else {
543
641
  const h = s[a.definitionId];
544
642
  if (process.env.NODE_ENV !== "production" && !h) {
545
- O.error(`No definition found for component type '${a.definitionId}'.`);
643
+ k.error(
644
+ `No definition found for component type '${a.definitionId}'.`
645
+ );
546
646
  return;
547
647
  }
548
648
  const i = n.createNode(h.type);
549
649
  i.name = a.definitionId, i.tags = h.tags || [], h.properties && i.writeProperties(h.properties), h.context && i.writeContext(h.context), h.layout && i.writeLayout(h.layout), t.appendChild(i, c), a.overrides.forEach((p) => {
550
- const l = { breakpoints: p.breakpoints };
551
- p.properties && i.writeProperties(p.properties, l), p.context && i.writeContext(p.context, l), p.layout && i.writeLayout(p.layout, l);
552
- }), h.children && C(n, i, h.children, s, r);
650
+ const d = { breakpoints: p.breakpoints };
651
+ p.properties && i.writeProperties(p.properties, d), p.context && i.writeContext(p.context, d), p.layout && i.writeLayout(p.layout, d);
652
+ }), h.children && O(n, i, h.children, s, r);
553
653
  }
554
654
  });
555
- }, at = (n, t) => {
655
+ }, pt = (n, t) => {
556
656
  const { entry: e, components: s, breakpoints: r, views: c } = t, o = [];
557
657
  return Object.keys(r).forEach((a) => {
558
658
  const u = r[a], h = window.matchMedia(u);
@@ -561,48 +661,60 @@ const st = (n) => {
561
661
  p.matches ? n.addBreakpoint(a) : n.removeBreakpoint(a);
562
662
  };
563
663
  h.addListener(i), o.push(() => h.removeListener(i));
564
- }), C(n, n.nodes.root, [e], s, c), () => o.forEach((a) => {
664
+ }), O(n, n.nodes.root, [e], s, c), () => o.forEach((a) => {
565
665
  a();
566
666
  });
567
- }, pt = (n, t) => ({
667
+ }, ut = (n, t) => ({
568
668
  id: n.id,
569
669
  type: n.type,
570
670
  name: n.name,
571
671
  branch: t || "default"
572
- }), ut = (n, t, e, s = E(), r = {}) => n.getAsync("components").then((c) => {
672
+ }), lt = (n, t, e, s = N(), r = {}) => n.getAsync("components").then((c) => {
573
673
  let o;
574
674
  if (typeof t == "string") {
575
- const h = new N(c);
675
+ const h = new P(c);
576
676
  h.ofType(t), o = h;
577
677
  } else
578
678
  o = t;
579
679
  const a = {}, u = (h) => {
580
680
  const i = a[h.id];
581
- return i ? Promise.resolve(i.controller) : et.getInstance(n).then((p) => new $(p, h, s));
681
+ return i ? Promise.resolve(i.controller) : st.getInstance(n).then((p) => new B(p, h, s));
582
682
  };
583
- c.events.subscribe("components:node-enter", (h, { node: i }) => {
584
- o.match(i) && u(i).then((p) => {
585
- Promise.resolve(e(p)).then((l) => {
586
- a[i.id] = {
587
- dispose: l,
588
- controller: p
589
- };
683
+ c.events.subscribe(
684
+ "components:node-enter",
685
+ (h, { node: i }) => {
686
+ o.match(i) && u(i).then((p) => {
687
+ Promise.resolve(e(p)).then((d) => {
688
+ a[i.id] = {
689
+ dispose: d,
690
+ controller: p
691
+ };
692
+ });
590
693
  });
591
- });
592
- }), c.events.subscribe("components:node-exit", (h, { node: i }) => {
593
- const p = a[i.id];
594
- p && (p.dispose && p.dispose(), r.reuseController || (p.controller.dispose(), delete a[i.id]));
595
- });
694
+ }
695
+ ), c.events.subscribe(
696
+ "components:node-exit",
697
+ (h, { node: i }) => {
698
+ const p = a[i.id];
699
+ p && (p.dispose && p.dispose(), r.reuseController || (p.controller.dispose(), delete a[i.id]));
700
+ }
701
+ );
596
702
  });
597
- class lt {
703
+ class dt {
598
704
  constructor(t) {
599
- this.aliases = /* @__PURE__ */ new Map(), this.components = /* @__PURE__ */ new Map(), this.logger = new O();
705
+ l(this, "aliases", /* @__PURE__ */ new Map());
706
+ l(this, "components", /* @__PURE__ */ new Map());
707
+ l(this, "events");
708
+ l(this, "logger", new k());
600
709
  const { events: e } = t.get("$widget");
601
710
  this.events = e;
602
711
  }
603
712
  getComponent(t) {
604
713
  const e = this.aliases.get(t), s = this.components.get(e || t) || null;
605
- return process.env.NODE_ENV !== "production" && (s || this.logger.warn(e || t, `Unable to resolve component: "${e || t}". You most likely forgot to register the required plugin for: ${e || t}.`)), s;
714
+ return process.env.NODE_ENV !== "production" && (s || this.logger.warn(
715
+ e || t,
716
+ `Unable to resolve component: "${e || t}". You most likely forgot to register the required plugin for: ${e || t}.`
717
+ )), s;
606
718
  }
607
719
  registerComponent(t, e) {
608
720
  return this.components.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
@@ -623,24 +735,24 @@ class lt {
623
735
  };
624
736
  }
625
737
  }
626
- var nt = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(nt || {});
738
+ var it = /* @__PURE__ */ ((n) => (n.open = "open", n.closed = "closed", n.hidden = "hidden", n))(it || {});
627
739
  export {
628
- ct as ActionResolver,
629
- k as ActionsController,
630
- H as ComponentNode,
631
- $ as ComponentNodeController,
632
- et as ComponentPlatform,
633
- N as ComponentQuery,
634
- lt as ComponentResolver,
635
- nt as WidgetRenderState,
636
- pt as asDescriptor,
637
- ht as componentConfigurationApi,
638
- C as createChildren,
639
- at as createComponentModel,
640
- K as createEventSubscriber,
641
- ut as extendComponent,
642
- F as findComponent,
643
- x as findVisibleComponents,
644
- P as traverseComponents
740
+ ht as ActionResolver,
741
+ R as ActionsController,
742
+ $ as ComponentNode,
743
+ B as ComponentNodeController,
744
+ st as ComponentPlatform,
745
+ P as ComponentQuery,
746
+ dt as ComponentResolver,
747
+ it as WidgetRenderState,
748
+ ut as asDescriptor,
749
+ at as componentConfigurationApi,
750
+ O as createChildren,
751
+ pt as createComponentModel,
752
+ U as createEventSubscriber,
753
+ lt as extendComponent,
754
+ G as findComponent,
755
+ C as findVisibleComponents,
756
+ A as traverseComponents
645
757
  };
646
758
  //# sourceMappingURL=index.js.map