@telia-ace/widget-core 1.0.14 → 1.0.15

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.
@@ -31,6 +31,6 @@ export declare const createChildren: (platform: ComponentPlatform, node: Compone
31
31
  [name: string]: ComponentSettings;
32
32
  }, views: {
33
33
  [key: string]: ViewDefinition;
34
- }, branch?: string | undefined) => void;
34
+ }, branch?: string) => void;
35
35
  export declare const createComponentModel: (platform: ComponentPlatform, settings: WidgetSettings) => EventSubscriptionCancellation;
36
36
  export {};
@@ -5,4 +5,4 @@ export declare type ComponentDescriptor = {
5
5
  name?: string;
6
6
  branch: string;
7
7
  };
8
- export declare const asDescriptor: (node: ComponentNode, branch?: string | undefined) => ComponentDescriptor;
8
+ export declare const asDescriptor: (node: ComponentNode, branch?: string) => ComponentDescriptor;
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
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/action-resolver.ts","../src/event-subscriber.ts","../src/component-platform/component-query.ts","../src/component-platform/component-controller.ts","../src/component-platform/actions-controller.ts","../src/component-platform/component-configuration-api.ts","../src/component-platform/component-node.ts","../src/component-platform/queries.ts","../src/component-platform/component-node-collection.ts","../src/component-platform/custom-component-handler.ts","../src/component-platform/state-processor.ts","../src/component-platform/component-platform.ts","../src/component-platform/create-component-model.ts","../src/component-platform/descriptor.ts","../src/component-platform/extend-component.ts","../src/component-resolver.ts","../src/types/configuration.ts"],"sourcesContent":["import {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n Widget,\r\n} from '@webprovisions/platform';\r\n\r\nexport type Action = (origin: string, action: string, value?: any) => void;\r\n\r\nexport default class ActionResolver {\r\n private events: EventManager;\r\n\r\n constructor(container: Container) {\r\n const { events }: Widget = container.get('$widget');\r\n this.events = events.createChild(this);\r\n }\r\n\r\n action(target: string, action: string, value: any): void {\r\n this.events.dispatch('data:action', { action, value, target }, { bubbles: true });\r\n }\r\n\r\n subscribe(origin: string, fn: Action): EventSubscriptionCancellation {\r\n return this.events.subscribe(\r\n 'data:action',\r\n (e, { action, value, target }) => origin === target && fn(origin, action, value)\r\n );\r\n }\r\n}\r\n","import {\r\n EventListener,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n} from '@webprovisions/platform';\r\n\r\nexport type SubscribeDelegate = (type: string, listener: EventListener) => void;\r\n\r\n/**\r\n * Creates s subscriber for the specified `EventManager` and provides a single cancellation\r\n * function for all registered subscriptions.\r\n */\r\nexport const createEventSubscriber = (\r\n events: EventManager\r\n): [SubscribeDelegate, EventSubscriptionCancellation] => {\r\n const subs: EventSubscriptionCancellation[] = [];\r\n\r\n const subscribe = (type: string, listener: EventListener) => {\r\n subs.push(events.subscribe(type, listener));\r\n };\r\n\r\n return [\r\n subscribe,\r\n () => {\r\n subs.forEach((sub) => {\r\n sub();\r\n });\r\n },\r\n ];\r\n};\r\n","import { AbstractComponentController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\n\r\nexport type ComponentQueryRule = {\r\n id?: string;\r\n type?: string;\r\n};\r\n\r\nexport class ComponentQuery {\r\n constructor(private platform: ComponentPlatform, public rules: ComponentQueryRule[] = []) {}\r\n\r\n match(node: ComponentNode) {\r\n return this.rules.every((rule) => {\r\n if (rule.id && rule.id !== node.id) {\r\n return false;\r\n }\r\n if (rule.type && rule.type !== node.type) {\r\n return false;\r\n }\r\n return true;\r\n });\r\n }\r\n\r\n ofType(type: string): ComponentQuery {\r\n this.rules.push({ type });\r\n return this;\r\n }\r\n\r\n withId(id: string): ComponentQuery {\r\n this.rules.push({ id });\r\n return this;\r\n }\r\n\r\n select(): AbstractComponentController {\r\n return new AbstractComponentController(this.platform, this);\r\n }\r\n}\r\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { createEventSubscriber, SubscribeDelegate } from '../event-subscriber';\r\nimport { ActionsController } from './actions-controller';\r\nimport {\r\n ChangesetOptions,\r\n ComponentNode,\r\n ComponentNodeContext,\r\n ComponentNodeLayout,\r\n ComponentNodeProperties,\r\n RemoveChangeset,\r\n} from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport interface ComponentController {\r\n actions: ActionsController;\r\n\r\n writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options: ChangesetOptions): void;\r\n\r\n writeLayout(context: Partial<ComponentNodeLayout>, options: ChangesetOptions): void;\r\n\r\n dispose(): void;\r\n}\r\n\r\nexport class ComponentNodeController implements ComponentController {\r\n actions: ActionsController;\r\n\r\n private subscribe: SubscribeDelegate;\r\n private unsubscribe: EventSubscriptionCancellation;\r\n\r\n constructor(private platform: ComponentPlatform, public node: ComponentNode, ns?: string) {\r\n this.actions = new ActionsController(\r\n platform,\r\n new ComponentQuery(platform).withId(node.id),\r\n ns\r\n );\r\n const [subscribe, unsubscribe] = createEventSubscriber(this.platform.events);\r\n this.subscribe = subscribe;\r\n this.unsubscribe = unsubscribe;\r\n }\r\n\r\n properties<T extends ComponentNodeProperties>(\r\n updated?: (properties: T) => void | Partial<ComponentNodeProperties>\r\n ): T {\r\n if (updated) {\r\n this.node.touchProperties((properties) => updated(<T>properties));\r\n }\r\n return <T>this.node.attributes.properties;\r\n }\r\n\r\n context(updated?: (context: ComponentNodeContext) => void): ComponentNodeContext {\r\n if (updated) {\r\n this.subscribe('components:context-changed', (event, { node }) => {\r\n if (node === this.node) {\r\n updated(this.node.attributes.context);\r\n }\r\n });\r\n }\r\n return this.node.attributes.context;\r\n }\r\n\r\n layout(updated?: (layout: ComponentNodeLayout) => void): ComponentNodeLayout {\r\n if (updated) {\r\n this.subscribe('components:layout-changed', (event, { node }) => {\r\n if (node === this.node) {\r\n updated(this.node.attributes.layout);\r\n }\r\n });\r\n }\r\n return this.node.attributes.layout;\r\n }\r\n\r\n writeProperties(\r\n properties:\r\n | Partial<ComponentNodeProperties>\r\n | ((properties: ComponentNodeProperties) => Partial<ComponentNodeProperties>),\r\n options?: ChangesetOptions\r\n ): void {\r\n this.node.writeProperties(properties, options);\r\n }\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\r\n this.node.writeProperties(context, options);\r\n }\r\n\r\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\r\n this.node.writeLayout(layout, options);\r\n }\r\n\r\n dispose() {\r\n this.unsubscribe();\r\n this.actions.dispose();\r\n }\r\n}\r\n\r\nexport class AbstractComponentController implements ComponentController {\r\n actions: ActionsController;\r\n private removes: RemoveChangeset[] = [];\r\n\r\n constructor(\r\n private platform: ComponentPlatform,\r\n private target: ComponentQuery,\r\n private clearOnDispose = true\r\n ) {\r\n this.actions = new ActionsController(this.platform, this.target);\r\n }\r\n\r\n writeProperties(\r\n properties: Partial<ComponentNodeProperties>,\r\n options?: ChangesetOptions\r\n ): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { properties },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { context },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { layout },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n dispose() {\r\n this.removes.forEach((remove) => {\r\n remove();\r\n });\r\n this.actions.dispose();\r\n }\r\n}\r\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { ComponentNodeController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport type ActionData = any;\r\n\r\nexport type ActionHandler = (data: any, options: any, instance: ComponentNodeController) => any;\r\nexport type NextActionDelegate = (data: any, options?: any) => Promise<any>;\r\nexport type WatchActionDelegate = (\r\n input: ActionData,\r\n next: NextActionDelegate,\r\n instance: ComponentNodeController\r\n) => Promise<any> | any;\r\nexport type ActionWatcherContext = {\r\n source: ComponentNode;\r\n action: string;\r\n};\r\n\r\nexport type ActionsState = {\r\n handlers: {\r\n fn: ActionHandler;\r\n key: string;\r\n target: ComponentQuery;\r\n ns?: string;\r\n }[];\r\n\r\n watchers: {\r\n target: ComponentQuery;\r\n fn: WatchActionDelegate;\r\n key: string;\r\n ns?: string;\r\n }[];\r\n};\r\n\r\ntype ActionWatcherExecutionResult = {\r\n data: any;\r\n options: any;\r\n cancelled: boolean;\r\n};\r\n\r\nconst executeActionListeners = (\r\n listeners: WatchActionDelegate[],\r\n data: any,\r\n controller: ComponentNodeController\r\n): Promise<ActionWatcherExecutionResult> => {\r\n const stack = listeners.concat();\r\n const dispatch = (\r\n data: any,\r\n globalOptions: any,\r\n controller: ComponentNodeController\r\n ): Promise<ActionWatcherExecutionResult> => {\r\n let cancelled = true;\r\n if (stack.length) {\r\n const handler = stack.shift() as WatchActionDelegate;\r\n\r\n const next = (data: any, options: any) => {\r\n cancelled = false;\r\n return dispatch(data, Object.assign({}, globalOptions, options), controller);\r\n };\r\n\r\n return Promise.resolve(handler(data, next, controller)).then((result) => ({\r\n ...result,\r\n cancelled,\r\n }));\r\n }\r\n\r\n return Promise.resolve({ data, cancelled: false, options: globalOptions });\r\n };\r\n return dispatch(data, {}, controller);\r\n};\r\n\r\nexport class ActionsController {\r\n private subscriptions: (() => void)[] = [];\r\n constructor(\r\n private platform: ComponentPlatform,\r\n private target: ComponentQuery,\r\n private ns?: string\r\n ) {\r\n this.create = this.create.bind(this);\r\n }\r\n\r\n create(key: string, fn: ActionHandler = () => {}): EventSubscriptionCancellation {\r\n const handler = {\r\n key,\r\n fn,\r\n target: this.target,\r\n ns: this.ns,\r\n };\r\n this.platform.actionsState.handlers.push(handler);\r\n const subscription = () => {\r\n const index = this.platform.actionsState.handlers.indexOf(handler);\r\n if (index > -1) {\r\n this.platform.actionsState.handlers.splice(index, 1);\r\n }\r\n };\r\n this.subscriptions.push(subscription);\r\n return subscription;\r\n }\r\n\r\n dispatch(key: string, data: any): Promise<{ [instanceId: string]: any }> {\r\n const instances: ComponentNode[] = this.platform.nodes.all.concat(\r\n this.platform.nodes.detached\r\n );\r\n\r\n const output: { [instanceId: string]: any } = {};\r\n\r\n // handlers matching the specified pattern.\r\n const handlers = this.platform.actionsState.handlers.filter(\r\n (handler) => handler.key === key && (!handler.ns || !this.ns || handler.ns === this.ns)\r\n );\r\n\r\n return Promise.all(\r\n handlers.map((handler) => {\r\n // select all matching instances for this particular\r\n // handler (a handler can be mapped to many instances)\r\n const matchedInstances = instances.filter(\r\n (instance) => handler.target.match(instance) && this.target.match(instance)\r\n );\r\n\r\n // execute watchers for each matched instance\r\n const watchers = this.platform.actionsState.watchers\r\n .filter((watcher) => {\r\n return (\r\n watcher.key === key &&\r\n (!watcher.ns || !this.ns || watcher.ns === this.ns) &&\r\n matchedInstances.some((instance) => watcher.target.match(instance))\r\n );\r\n })\r\n .map((watcher) => watcher.fn);\r\n\r\n // execute watchers and handler for each instance\r\n return Promise.all(\r\n matchedInstances.map((node) => {\r\n const controller = new ComponentNodeController(\r\n this.platform,\r\n node,\r\n this.ns\r\n );\r\n return executeActionListeners(watchers, data, controller).then((input) => {\r\n const { data = {}, options, cancelled } = input;\r\n return Promise.resolve(\r\n cancelled ? {} : handler.fn(data, options, controller)\r\n ).then((handlerResponse) => {\r\n output[node.id] = handlerResponse;\r\n });\r\n });\r\n })\r\n );\r\n })\r\n ).then(() => output);\r\n }\r\n\r\n watch(key: string, fn: WatchActionDelegate): EventSubscriptionCancellation {\r\n let parsedKey = key;\r\n let parsedNs = this.ns;\r\n const sections = key.split('.');\r\n\r\n if (sections.length > 1) {\r\n parsedNs = sections[0];\r\n parsedKey = sections.splice(1).join('.');\r\n }\r\n const watcher = {\r\n fn,\r\n target: this.target,\r\n key: parsedKey,\r\n ns: parsedNs,\r\n };\r\n this.platform.actionsState.watchers.push(watcher);\r\n const subscription = () => {\r\n const index = this.platform.actionsState.watchers.indexOf(watcher);\r\n if (index > -1) {\r\n this.platform.actionsState.watchers.splice(index, 1);\r\n }\r\n };\r\n this.subscriptions.push(subscription);\r\n return subscription;\r\n }\r\n\r\n dispose() {\r\n this.subscriptions.forEach((unsubscribe) => unsubscribe());\r\n }\r\n}\r\n","import { createConfigurationApi } from '@webprovisions/platform';\r\nimport { CustomHandlerCallback } from './custom-component-handler';\r\n\r\ntype Options = {\r\n handlers?: [string, CustomHandlerCallback][];\r\n};\r\n\r\nexport default createConfigurationApi((builder) => {\r\n builder.createCommand('components', (context) => (config: Options) => {\r\n context.events.subscribeOnce('components:platform-created', (event, { platform }) => {\r\n if (config.handlers) {\r\n config.handlers.forEach(([key, handler]) => {\r\n platform.addComponentHandler(key, handler);\r\n });\r\n }\r\n });\r\n });\r\n});\r\n","import { Logger, uuid } from '@telia-ace/widget-utilities';\r\nimport { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { Breakpoints } from '../types';\r\n\r\nexport type ComponentNodeEventData = { node: ComponentNode };\r\n\r\nexport type RemoveChangeset = () => void;\r\n\r\nexport type ComponentNodeAttributes = {\r\n tags: string[];\r\n properties: ComponentNodeProperties;\r\n context: ComponentNodeContext;\r\n layout: ComponentNodeLayout;\r\n};\r\n\r\nexport type ResolveComponentNodeProperties = (\r\n properties: ComponentNodeProperties\r\n) => Partial<ComponentNodeProperties> | void;\r\n\r\nexport type ResolveComponentNodeContext = (\r\n context: ComponentNodeContext\r\n) => Partial<ComponentNodeContext>;\r\n\r\nexport type ResolveComponentNodeLayout = (\r\n layout: ComponentNodeLayout\r\n) => Partial<ComponentNodeLayout>;\r\n\r\nexport type ComponentNodeSettings = {\r\n tags?: string[];\r\n properties?: ComponentNodeProperties | ResolveComponentNodeProperties;\r\n context?: ComponentNodeContext | ResolveComponentNodeContext;\r\n layout?: ComponentNodeLayout | ResolveComponentNodeLayout;\r\n};\r\n\r\nexport type ComponentNodeProperties = { [key: string]: any };\r\n\r\nexport type ComponentNodeContext = { [key: string]: any };\r\n\r\nexport type ComponentNodeLayout = {\r\n size?: Size;\r\n indent?: number;\r\n order?: number;\r\n};\r\n\r\nexport type Size = number | 'full' | 'none';\r\n\r\nexport type UnmountComponentNode = () => void;\r\n\r\nexport type ChangesetOptions = {\r\n breakpoints?: Breakpoints;\r\n};\r\n\r\nexport type Changeset = [Partial<ComponentNodeSettings>, ChangesetOptions];\r\n\r\nexport class ComponentNode {\r\n id: string;\r\n type: string;\r\n name?: string;\r\n parent?: ComponentNode;\r\n tags: string[] = [];\r\n children: { [key: string]: ComponentNode[] } = {};\r\n changesets: Changeset[] = [];\r\n attributes: ComponentNodeAttributes;\r\n\r\n private mountCount = 0;\r\n\r\n constructor(private events: EventManager, type: string) {\r\n this.id = uuid();\r\n this.type = type;\r\n this.attributes = {\r\n context: {},\r\n properties: {},\r\n layout: {},\r\n tags: [],\r\n };\r\n // write default attributes\r\n this.writeLayout({ size: 'full', indent: 0 });\r\n }\r\n\r\n mount(viewOutletContainer: Container, element?: HTMLElement): UnmountComponentNode {\r\n let mountedNodes: Map<ComponentNode, EventSubscriptionCancellation> =\r\n viewOutletContainer.get('mounted-nodes');\r\n\r\n if (!mountedNodes) {\r\n mountedNodes = new Map<ComponentNode, EventSubscriptionCancellation>();\r\n viewOutletContainer.register('mounted-nodes', mountedNodes);\r\n }\r\n\r\n if (mountedNodes.has(this)) {\r\n if (process.env.NODE_ENV !== 'production') {\r\n Logger.error('Trying to mount an already mounted component node.', this);\r\n }\r\n return () => {};\r\n }\r\n\r\n /**\r\n * Dispatched when a node is mounted in a component.\r\n * This happens once for every `ViewOutlet`.\r\n */\r\n this.events.dispatch('components:node-mounted', { node: this });\r\n\r\n if (this.mountCount === 0) {\r\n this.mountCount = this.mountCount + 1;\r\n /**\r\n * Dispatched when a node is mounted in a component the first time.\r\n */\r\n this.events.dispatch('components:node-enter', { node: this });\r\n }\r\n\r\n return () => {\r\n mountedNodes.delete(this);\r\n this.events.dispatch('components:node-unmounted', { node: this });\r\n\r\n this.mountCount = this.mountCount - 1;\r\n if (this.mountCount === 0) {\r\n this.events.dispatch('components:node-exit', { node: this });\r\n }\r\n };\r\n }\r\n\r\n appendChild(node: ComponentNode, branch: string = 'default') {\r\n if (node.parent) {\r\n if (node.parent === this) {\r\n return;\r\n }\r\n node.parent.removeChild(node);\r\n }\r\n node.parent = this;\r\n\r\n if (!this.children[branch]) {\r\n this.children[branch] = [];\r\n }\r\n this.children[branch].push(node);\r\n\r\n this.events.dispatch('components:node-appended', { node });\r\n }\r\n\r\n prependChild(node: ComponentNode, branch: string = 'default') {\r\n if (node.parent) {\r\n if (node.parent === this) {\r\n return;\r\n }\r\n node.parent.removeChild(node);\r\n }\r\n node.parent = this;\r\n\r\n if (!this.children[branch]) {\r\n this.children[branch] = [];\r\n }\r\n this.children[branch].unshift(node);\r\n\r\n this.events.dispatch('components:node-appended', { node });\r\n }\r\n\r\n touchProperties(\r\n properties: ResolveComponentNodeProperties,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { properties };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n return () => {\r\n if (removable) {\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n }\r\n }\r\n };\r\n }\r\n\r\n writeProperties(\r\n properties: Partial<ComponentNodeProperties> | ResolveComponentNodeProperties,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { properties };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n return () => {\r\n if (removable) {\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n }\r\n }\r\n };\r\n }\r\n\r\n writeLayout(\r\n layout: Partial<ComponentNodeLayout> | ResolveComponentNodeLayout,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { layout };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-layout', { node: this });\r\n return () => {\r\n if (!removable) {\r\n return;\r\n }\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-layout', { node: this });\r\n }\r\n };\r\n }\r\n\r\n writeContext(\r\n context: Partial<ComponentNodeContext> | ResolveComponentNodeContext,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { context };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-context', { node: this });\r\n return () => {\r\n if (!removable) {\r\n return;\r\n }\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-context', { node: this });\r\n }\r\n };\r\n }\r\n\r\n getChildren(branch: string = 'default'): ComponentNode[] {\r\n const children = this.children[branch] || [];\r\n return children.reduce((acc, node, i) => {\r\n const { order: index = i } = node.attributes.layout;\r\n if (!acc[index]) {\r\n acc[index] = node;\r\n } else {\r\n acc.splice(index, 0, node);\r\n }\r\n return acc;\r\n }, Array(children.length));\r\n }\r\n\r\n remove() {\r\n if (this.parent) {\r\n this.parent.removeChild(this);\r\n }\r\n }\r\n\r\n removeChild(node: ComponentNode) {\r\n Object.keys(this.children).forEach((branch) => {\r\n const children = this.children[branch];\r\n const indexToRemove = children.indexOf(node);\r\n if (indexToRemove > -1) {\r\n children.splice(indexToRemove, 1);\r\n this.events.dispatch('components:node-removed', { node, parentNode: this });\r\n }\r\n });\r\n delete node.parent;\r\n }\r\n}\r\n","import { ComponentNode } from './component-node';\r\nimport { SwitchMap } from './component-platform';\r\n\r\nconst traverseComponentsRecursive = (\r\n nodes: ComponentNode[],\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean | void\r\n) => {\r\n for (let i = 0, y = nodes.length; i < y; i++) {\r\n if (fn(nodes[i]) === true) {\r\n break;\r\n }\r\n const branch = switches[nodes[i].id] || 'default';\r\n const children = nodes[i].getChildren(branch);\r\n traverseComponentsRecursive(children, switches, fn);\r\n }\r\n};\r\n\r\nexport const traverseComponents = (\r\n root: ComponentNode,\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean | void\r\n) => {\r\n if (fn(root) !== true) {\r\n const branch = switches[root.id] || 'default';\r\n const children = root.children[branch];\r\n traverseComponentsRecursive(children, switches, fn);\r\n }\r\n};\r\n\r\nexport const findVisibleComponents = (\r\n root: ComponentNode,\r\n switches: SwitchMap\r\n): ComponentNode[] => {\r\n const nodes: ComponentNode[] = [];\r\n traverseComponents(root, switches, (node) => {\r\n nodes.push(node);\r\n });\r\n return nodes;\r\n};\r\n\r\nexport const findComponent = (\r\n root: ComponentNode,\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean\r\n) => {\r\n let matched: ComponentNode | undefined;\r\n traverseComponents(root, switches, (node) => {\r\n if (fn(node)) {\r\n matched = node;\r\n return true;\r\n }\r\n });\r\n return matched;\r\n};\r\n\r\nexport const getAncestors = (node: ComponentNode) => {\r\n if (!node.parent) {\r\n return [];\r\n }\r\n const tree: ComponentNode[] = [];\r\n let currentNode: ComponentNode | undefined = node.parent;\r\n while (currentNode) {\r\n tree.unshift(currentNode);\r\n currentNode = currentNode.parent;\r\n }\r\n return tree;\r\n};\r\n","import { EventManager } from '@webprovisions/platform';\r\nimport { ComponentNode, ComponentNodeEventData } from './component-node';\r\nimport { SwitchMap } from './component-platform';\r\nimport { findComponent, findVisibleComponents, traverseComponents } from './queries';\r\n\r\nexport type QueryDescriptor = {\r\n id?: string;\r\n type?: string;\r\n name?: string;\r\n};\r\n\r\nexport class ComponentNodeCollection {\r\n all: ComponentNode[] = [];\r\n visible: ComponentNode[] = [];\r\n detached: ComponentNode[] = [];\r\n\r\n constructor(public root: ComponentNode, private switches: SwitchMap, events: EventManager) {\r\n events.subscribe('components:node-appended', (event, data: ComponentNodeEventData) => {\r\n this.all.push(data.node);\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n events.subscribe('components:node-removed', (event, data: ComponentNodeEventData) => {\r\n let indexToRemove = this.all.indexOf(data.node);\r\n if (indexToRemove > -1) {\r\n this.all.splice(indexToRemove, 1);\r\n }\r\n indexToRemove = this.visible.indexOf(data.node);\r\n if (indexToRemove > -1) {\r\n this.visible.splice(indexToRemove, 1);\r\n }\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n events.subscribe('components:node-switched', (event, data: ComponentNodeEventData) => {\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n }\r\n\r\n query(query: QueryDescriptor = {}): ComponentNode[] {\r\n const nodes: ComponentNode[] = [];\r\n traverseComponents(this.root, this.switches, (node) => {\r\n const match = Object.keys(query).every((member) => {\r\n return (<any>query)[member] === (<any>node)[member];\r\n });\r\n if (match) {\r\n nodes.push(node);\r\n }\r\n });\r\n return nodes;\r\n }\r\n\r\n get(id: string) {\r\n return (\r\n findComponent(this.root, this.switches, (node) => node.id === id) ||\r\n this.detached.find((node) => node.id === id)\r\n );\r\n }\r\n}\r\n","import { ComponentReference, ComponentSettings, ViewDefinition } from '../types';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { NormalizedComponentReference } from './create-component-model';\r\n\r\nexport type CustomHandlerCallback = (\r\n ref: NormalizedComponentReference,\r\n options: {\r\n platform: ComponentPlatform;\r\n node: ComponentNode;\r\n references: ComponentReference[];\r\n definitions: { [name: string]: ComponentSettings };\r\n views: { [key: string]: ViewDefinition };\r\n branch?: string;\r\n }\r\n) => void;\r\n\r\nexport class CustomComponentHandler {\r\n private handlers = new Map<string, CustomHandlerCallback>();\r\n\r\n add(name: string, fn: CustomHandlerCallback) {\r\n this.handlers.set(name, fn);\r\n }\r\n\r\n get(name: string) {\r\n return this.handlers.get(name);\r\n }\r\n}\r\n","import { ComponentPlatform } from '.';\r\nimport { Breakpoints } from '../types';\r\nimport {\r\n ComponentNode,\r\n ResolveComponentNodeContext,\r\n ResolveComponentNodeLayout,\r\n ResolveComponentNodeProperties,\r\n} from './component-node';\r\n\r\nexport type ProcessOptions = {\r\n context?: boolean;\r\n properties?: boolean;\r\n layout?: boolean;\r\n recursive?: boolean;\r\n};\r\n\r\nexport type StateProcessor = (node: ComponentNode, options: ProcessOptions) => void;\r\n\r\nconst calculateNodeIndex = (node: ComponentNode): number => {\r\n let currentNode = node;\r\n let index = 0;\r\n\r\n while (currentNode.parent) {\r\n index = index + 1;\r\n currentNode = currentNode.parent;\r\n }\r\n\r\n return index;\r\n};\r\n\r\nconst sortQueue = (queue: [ComponentNode, ProcessOptions][]): [ComponentNode, ProcessOptions][] => {\r\n const mapped: [number, ComponentNode, ProcessOptions][] = queue.map(([node, options]) => {\r\n return [calculateNodeIndex(node), node, options];\r\n });\r\n return mapped\r\n .sort(([a], [b]) => a - b)\r\n .map(([, node, options]) => {\r\n return [node, options];\r\n });\r\n};\r\n\r\nconst isObject = (item: any) => {\r\n return item && typeof item === 'object' && !Array.isArray(item);\r\n};\r\n\r\nconst mergeDeep = (target: any, ...sources: any[]): any => {\r\n if (!sources.length) return target;\r\n const source = sources.shift();\r\n\r\n if (isObject(target) && isObject(source)) {\r\n for (const key in source) {\r\n if (isObject(source[key])) {\r\n if (!target[key]) Object.assign(target, { [key]: {} });\r\n mergeDeep(target[key], source[key]);\r\n } else {\r\n Object.assign(target, { [key]: source[key] });\r\n }\r\n }\r\n }\r\n return mergeDeep(target, ...sources);\r\n};\r\n\r\nconst matchesBreakpoint = (b1: Breakpoints | undefined, b2: string[]) => {\r\n if (!b1 || b1 === 'all') {\r\n return true;\r\n }\r\n return b1.some((b1) => b2.indexOf(b1) > -1);\r\n};\r\n\r\nexport type ProcessResult = Map<ComponentNode, ProcessOptions>;\r\n\r\nexport type ProcessReportCallback = (report: ProcessResult) => void;\r\n\r\nexport const createStateProcessor = (\r\n platform: ComponentPlatform,\r\n callback: ProcessReportCallback\r\n): StateProcessor => {\r\n let nodeQueue: ComponentNode[] = [];\r\n let optionsQueue: ProcessOptions[] = [];\r\n\r\n let timeout: NodeJS.Timeout;\r\n\r\n const flush = () => {\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.time('state-processor.flush');\r\n }\r\n const processHistory: Map<ComponentNode, ProcessOptions> = new Map();\r\n const sortedQueue = sortQueue(nodeQueue.map((node, i) => [node, optionsQueue[i]]));\r\n\r\n const processNode = (node: ComponentNode, options: ProcessOptions) => {\r\n const history = processHistory.get(node) || {};\r\n\r\n // todo: this doesnt take overrides into account\r\n const processContext = options.context && !history.context;\r\n const processProperties = options.properties && !history.properties;\r\n const processLayout = options.layout && !history.layout;\r\n\r\n processHistory.set(node, {\r\n context: history.context || processContext,\r\n properties: history.properties || processProperties,\r\n layout: history.layout || processLayout,\r\n });\r\n\r\n if (processProperties) {\r\n node.attributes.properties = {};\r\n }\r\n if (processLayout) {\r\n node.attributes.layout = {};\r\n }\r\n\r\n if (processContext) {\r\n node.attributes.context = mergeDeep({}, node.parent?.attributes.context);\r\n }\r\n\r\n const propertyResolvers: ResolveComponentNodeProperties[] = [];\r\n const layoutResolvers: ResolveComponentNodeLayout[] = [];\r\n const contextResolvers: ResolveComponentNodeContext[] = [];\r\n\r\n node.changesets.forEach((changeset) => {\r\n const [change, options] = changeset;\r\n if (matchesBreakpoint(options.breakpoints, platform.breakpoints)) {\r\n if (processProperties) {\r\n if (typeof change.properties === 'function') {\r\n propertyResolvers.push(\r\n <ResolveComponentNodeProperties>change.properties\r\n );\r\n } else {\r\n mergeDeep(node.attributes.properties, change.properties);\r\n }\r\n }\r\n\r\n if (processLayout) {\r\n if (typeof change.layout === 'function') {\r\n layoutResolvers.push(<ResolveComponentNodeLayout>change.layout);\r\n } else {\r\n mergeDeep(node.attributes.layout, change.layout);\r\n }\r\n }\r\n\r\n if (processContext) {\r\n if (typeof change.context === 'function') {\r\n contextResolvers.push(<ResolveComponentNodeContext>change.context);\r\n } else {\r\n mergeDeep(node.attributes.context, change.context);\r\n }\r\n }\r\n }\r\n });\r\n\r\n propertyResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.properties, resolver(node.attributes.properties));\r\n });\r\n\r\n layoutResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.layout, resolver(node.attributes.layout));\r\n });\r\n\r\n contextResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.context, resolver(node.attributes.context));\r\n });\r\n\r\n if (processContext || options.recursive) {\r\n const branch = platform.getBranch(node);\r\n const childOptions: ProcessOptions = options.recursive\r\n ? options\r\n : {\r\n context: !!processContext,\r\n };\r\n node.getChildren(branch).forEach((child) => {\r\n processNode(child, childOptions);\r\n });\r\n }\r\n };\r\n\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.timeEnd('state-processor.flush');\r\n }\r\n\r\n sortedQueue.forEach(([node, options]) => {\r\n processNode(node, options);\r\n });\r\n\r\n nodeQueue = [];\r\n optionsQueue = [];\r\n\r\n callback(processHistory);\r\n };\r\n\r\n const schedule = () => {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(flush, 0);\r\n };\r\n\r\n return (node, options) => {\r\n const index = nodeQueue.indexOf(node);\r\n\r\n if (index > -1) {\r\n // if node already exist in queue, update its options\r\n const summary = optionsQueue[index];\r\n if (options.context) {\r\n summary.context = true;\r\n }\r\n if (options.properties) {\r\n summary.properties = true;\r\n }\r\n if (options.layout) {\r\n summary.layout = true;\r\n }\r\n if (options.recursive) {\r\n summary.recursive = true;\r\n }\r\n return schedule();\r\n }\r\n\r\n nodeQueue.push(node);\r\n optionsQueue.push(options);\r\n\r\n return schedule();\r\n };\r\n};\r\n","import { uuid } from '@telia-ace/widget-utilities';\r\nimport {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n Widget,\r\n} from '@webprovisions/platform';\r\nimport { ActionsController, ActionsState } from './actions-controller';\r\nimport { ChangesetProvider } from './changeset-provider';\r\nimport {\r\n Changeset,\r\n ChangesetOptions,\r\n ComponentNode,\r\n ComponentNodeEventData,\r\n ComponentNodeSettings,\r\n RemoveChangeset,\r\n} from './component-node';\r\nimport { ComponentNodeCollection } from './component-node-collection';\r\nimport { ComponentQuery } from './component-query';\r\nimport { CustomComponentHandler, CustomHandlerCallback } from './custom-component-handler';\r\nimport { createStateProcessor, StateProcessor } from './state-processor';\r\n\r\nexport type MergeOptions = { breakpoints?: string[] };\r\n\r\ntype AbstractChangesetRecord = {\r\n changeset: Changeset;\r\n target: ComponentQuery;\r\n removes: RemoveChangeset[];\r\n};\r\n\r\nexport type SwitchMap = { [id: string]: string };\r\n\r\nexport type ChangesetData = {\r\n key?: string;\r\n target: ComponentQuery;\r\n attributes: Partial<ComponentNodeSettings>;\r\n options?: ChangesetOptions;\r\n removable?: boolean;\r\n provider?: string;\r\n};\r\n\r\nexport class ComponentPlatform {\r\n events: EventManager;\r\n breakpoints: string[] = [];\r\n nodes: ComponentNodeCollection;\r\n // internal\r\n actionsState: ActionsState = { handlers: [], watchers: [] };\r\n\r\n private switches: SwitchMap = {};\r\n private changesets: AbstractChangesetRecord[] = [];\r\n private subscriptions: EventSubscriptionCancellation[] = [];\r\n private processNode: StateProcessor;\r\n private customComponentHandler = new CustomComponentHandler();\r\n\r\n constructor(widget: Widget, private providers: { [key: string]: ChangesetProvider } = {}) {\r\n this.events = widget.events.createChild(this);\r\n const root = new ComponentNode(this.events, 'root');\r\n root.name = `root-${widget.name}`;\r\n this.nodes = new ComponentNodeCollection(root, this.switches, this.events);\r\n\r\n const processNode = (this.processNode = createStateProcessor(this, (report) => {\r\n const nodes = Array.from(report.keys());\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.info(`STATE PROCESSOR: ${nodes.length} node(s) processed:\r\n${nodes.map(\r\n (node) => `${node.name || '<no name>'} (${node.id})\r\n`\r\n)}`);\r\n }\r\n nodes.forEach((node) => {\r\n const options = report.get(node);\r\n if (node.parent && node.parent.type === 'root') {\r\n this.events.dispatch('components:root-children-changed', { node });\r\n }\r\n if (options?.context) {\r\n this.events.dispatch('components:context-changed', { node });\r\n }\r\n if (options?.properties) {\r\n this.events.dispatch('components:properties-changed', { node });\r\n }\r\n if (options?.layout) {\r\n this.events.dispatch('components:layout-changed', { node });\r\n }\r\n });\r\n this.events.dispatch('components:component-model-initialized', {}, { bubbles: true });\r\n }));\r\n\r\n Promise.all(\r\n Object.keys(providers).map((key) => {\r\n const provider = providers[key];\r\n return provider.load(this);\r\n })\r\n );\r\n\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:node-appended',\r\n (event, data: ComponentNodeEventData) => {\r\n const { node } = data;\r\n this.changesets.forEach((record) => {\r\n const { changeset, target, removes } = record;\r\n const [change, options] = changeset;\r\n if (target.match(data.node)) {\r\n if (change.properties) {\r\n removes.push(node.writeProperties(change.properties, options));\r\n }\r\n if (change.context) {\r\n removes.push(node.writeContext(change.context, options));\r\n }\r\n if (change.layout) {\r\n removes.push(node.writeLayout(change.layout, options));\r\n }\r\n }\r\n });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:node-appended',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true, context: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-properties',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-context',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true, context: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-indent',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { layout: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-layout',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { layout: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe('components:node-switched', (event, { node, branch }) => {\r\n processNode(node, {\r\n layout: true,\r\n recursive: true,\r\n properties: true,\r\n context: true,\r\n });\r\n })\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe('components:node-removed', (event, { parentNode }) => {\r\n processNode(parentNode, { properties: true });\r\n })\r\n );\r\n\r\n if (this.events.parent) {\r\n this.events.parent.dispatch('components:platform-created', { platform: this });\r\n }\r\n }\r\n\r\n static getInstance(container: Container): Promise<ComponentPlatform> {\r\n return container.getAsync('components');\r\n }\r\n\r\n addBreakpoint(name: string) {\r\n if (this.breakpoints.indexOf(name) === -1) {\r\n this.breakpoints.push(name);\r\n this.processNode(this.nodes.root, {\r\n context: true,\r\n properties: true,\r\n layout: true,\r\n recursive: true,\r\n });\r\n }\r\n }\r\n\r\n removeBreakpoint(name: string) {\r\n const indexToRemove = this.breakpoints.indexOf(name);\r\n if (indexToRemove > -1) {\r\n this.breakpoints.splice(indexToRemove, 1);\r\n this.processNode(this.nodes.root, {\r\n context: true,\r\n properties: true,\r\n layout: true,\r\n recursive: true,\r\n });\r\n }\r\n }\r\n\r\n setSwitch(node: ComponentNode, branch: string) {\r\n this.switches[node.id] = branch;\r\n this.events.dispatch('components:node-switched', { node, branch });\r\n }\r\n\r\n getBranch(node: ComponentNode): string | undefined {\r\n return this.switches[node.id];\r\n }\r\n\r\n /**\r\n * Creates a `ComponentNode` of the specified type.\r\n * @param type Type of node.\r\n */\r\n createNode(type: string, options: { detached?: boolean } = {}): ComponentNode {\r\n const node = new ComponentNode(this.events, type);\r\n if (options.detached) {\r\n this.nodes.detached.push(node);\r\n }\r\n return node;\r\n }\r\n\r\n components(): ComponentQuery {\r\n return new ComponentQuery(this);\r\n }\r\n\r\n actions(target: ComponentQuery, ns: string): ActionsController {\r\n return new ActionsController(this, <any>target, ns);\r\n }\r\n\r\n write(data: ChangesetData): RemoveChangeset {\r\n const { provider: providerName, target, attributes, options = {}, removable } = data;\r\n const key = data.key || uuid();\r\n const changeset: Changeset = [attributes, options];\r\n const record: AbstractChangesetRecord = { changeset, target, removes: [] };\r\n if (providerName) {\r\n const provider = this.providers[providerName];\r\n provider.write(key, target, attributes, options);\r\n record.removes.push(() => {\r\n provider.remove(key);\r\n });\r\n }\r\n\r\n this.changesets.push(record);\r\n this.nodes.all.forEach((node) => {\r\n if (target.match(node)) {\r\n let remove: RemoveChangeset = () => {};\r\n if (attributes.properties) {\r\n remove = node.writeProperties(attributes.properties, options, removable);\r\n }\r\n if (attributes.context) {\r\n remove = node.writeContext(attributes.context, options, removable);\r\n }\r\n if (attributes.layout) {\r\n remove = node.writeContext(attributes.layout, options, removable);\r\n }\r\n record.removes.push(remove);\r\n }\r\n });\r\n return () => {\r\n if (removable) {\r\n record.removes.forEach((remove) => remove());\r\n const indexToRemove = this.changesets.indexOf(record);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n }\r\n }\r\n };\r\n }\r\n\r\n addComponentHandler(definitionType: string, fn: CustomHandlerCallback) {\r\n this.customComponentHandler.add(definitionType, fn);\r\n }\r\n\r\n getComponentHandler(definitionType: string) {\r\n return this.customComponentHandler.get(definitionType);\r\n }\r\n\r\n dispose() {\r\n this.subscriptions.forEach((sub) => sub());\r\n }\r\n}\r\n","import { Logger } from '@telia-ace/widget-utilities';\r\nimport { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { Breakpoints, ComponentSettings, ViewDefinition, WidgetSettings } from '../types';\r\nimport {\r\n ComponentNode,\r\n ComponentNodeContext,\r\n ComponentNodeLayout,\r\n ComponentNodeProperties,\r\n} from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\n\r\ntype ComponentReference = string | [string, ...ComponentReferenceOverride[]];\r\n\r\ntype ComponentReferenceOverride = {\r\n breakpoints?: Breakpoints;\r\n tags?: string[];\r\n context?: ComponentNodeContext;\r\n properties?: ComponentNodeProperties;\r\n layout?: ComponentNodeLayout;\r\n};\r\n\r\nexport type NormalizedComponentReference = {\r\n definitionId: string;\r\n overrides: ComponentReferenceOverride[];\r\n};\r\n\r\nexport const normalizeReference = (reference: ComponentReference): NormalizedComponentReference => {\r\n if (Array.isArray(reference)) {\r\n const [definitionId, ...overrides] = reference;\r\n return {\r\n definitionId,\r\n overrides,\r\n };\r\n }\r\n return {\r\n definitionId: reference,\r\n overrides: [],\r\n };\r\n};\r\n\r\nexport type ComponentHandlerOptions = {\r\n platform: ComponentPlatform;\r\n node: ComponentNode;\r\n references: ComponentReference[];\r\n definitions: { [name: string]: ComponentSettings };\r\n views: { [key: string]: ViewDefinition };\r\n branch?: string;\r\n};\r\n\r\nexport const createChildren = (\r\n platform: ComponentPlatform,\r\n node: ComponentNode,\r\n references: ComponentReference[],\r\n definitions: { [name: string]: ComponentSettings },\r\n views: { [key: string]: ViewDefinition },\r\n branch?: string\r\n) => {\r\n references.forEach((ref) => {\r\n const childRef = normalizeReference(ref);\r\n const childDef = definitions[childRef.definitionId];\r\n if (childRef.definitionId === 'view') {\r\n const viewNode = platform.createNode('view');\r\n viewNode.name = 'view';\r\n Object.keys(views).forEach((key) => {\r\n const viewDef = views[key];\r\n createChildren(platform, viewNode, [viewDef.entry], definitions, views, key);\r\n });\r\n node.appendChild(viewNode);\r\n\r\n childRef.overrides.forEach((override) => {\r\n if (override.properties) {\r\n viewNode.writeProperties(override.properties, {\r\n breakpoints: override.breakpoints,\r\n });\r\n }\r\n if (override.context) {\r\n viewNode.writeContext(override.context, { breakpoints: override.breakpoints });\r\n }\r\n if (override.layout) {\r\n viewNode.writeLayout(override.layout, { breakpoints: override.breakpoints });\r\n }\r\n });\r\n } else if (platform.getComponentHandler(childDef.type)) {\r\n const handle = platform.getComponentHandler(childDef.type);\r\n if (handle) {\r\n handle(childRef, {\r\n platform,\r\n node,\r\n references,\r\n definitions,\r\n views,\r\n branch,\r\n });\r\n }\r\n } else {\r\n const childDef = definitions[childRef.definitionId];\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (!childDef) {\r\n Logger.error(\r\n `No definition found for component type '${childRef.definitionId}'.`\r\n );\r\n return;\r\n }\r\n }\r\n const childNode = platform.createNode(childDef.type);\r\n childNode.name = childRef.definitionId;\r\n childNode.tags = childDef.tags || [];\r\n if (childDef.properties) {\r\n childNode.writeProperties(childDef.properties);\r\n }\r\n if (childDef.context) {\r\n childNode.writeContext(childDef.context);\r\n }\r\n if (childDef.layout) {\r\n childNode.writeLayout(childDef.layout);\r\n }\r\n node.appendChild(childNode, branch);\r\n\r\n childRef.overrides.forEach((override) => {\r\n const options = { breakpoints: override.breakpoints };\r\n if (override.properties) {\r\n childNode.writeProperties(override.properties, options);\r\n }\r\n if (override.context) {\r\n childNode.writeContext(override.context, options);\r\n }\r\n if (override.layout) {\r\n childNode.writeLayout(override.layout, options);\r\n }\r\n });\r\n\r\n if (childDef.children) {\r\n createChildren(platform, childNode, childDef.children, definitions, views);\r\n }\r\n }\r\n });\r\n};\r\n\r\nexport const createComponentModel = (\r\n platform: ComponentPlatform,\r\n settings: WidgetSettings\r\n): EventSubscriptionCancellation => {\r\n const { entry, components, breakpoints, views } = settings;\r\n const subscriptions: EventSubscriptionCancellation[] = [];\r\n\r\n Object.keys(breakpoints).forEach((name) => {\r\n const query = breakpoints[name];\r\n const list = window.matchMedia(query);\r\n if (list.matches) {\r\n platform.breakpoints.push(name);\r\n }\r\n const listener = (event: MediaQueryListEvent) => {\r\n if (event.matches) {\r\n platform.addBreakpoint(name);\r\n } else {\r\n platform.removeBreakpoint(name);\r\n }\r\n };\r\n list.addListener(listener);\r\n subscriptions.push(() => list.removeListener(listener));\r\n });\r\n\r\n createChildren(platform, platform.nodes.root, [entry], components, views);\r\n\r\n return () =>\r\n subscriptions.forEach((sub) => {\r\n sub();\r\n });\r\n};\r\n","import { ComponentNode } from './component-node';\r\n\r\nexport type ComponentDescriptor = {\r\n id: string;\r\n type?: string;\r\n name?: string;\r\n branch: string;\r\n};\r\n\r\nexport const asDescriptor = (node: ComponentNode, branch?: string): ComponentDescriptor => {\r\n return {\r\n id: node.id,\r\n type: node.type,\r\n name: node.name,\r\n branch: branch || 'default',\r\n };\r\n};\r\n","import { uuid } from '@telia-ace/widget-utilities';\r\nimport { Container, EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { ComponentNodeController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport type ExtendComponentHandler = (controller: ComponentNodeController) => any;\r\n\r\nexport type ExtendComponentOptions = {\r\n reuseController?: boolean;\r\n};\r\n\r\nexport const extendComponent = (\r\n container: Container,\r\n typeOrQuery: string | ComponentQuery,\r\n handler: ExtendComponentHandler,\r\n ns: string = uuid(),\r\n options: ExtendComponentOptions = {}\r\n): Promise<void> => {\r\n return container.getAsync('components').then((components: ComponentPlatform) => {\r\n let target: ComponentQuery;\r\n if (typeof typeOrQuery === 'string') {\r\n const collection = new ComponentQuery(components);\r\n collection.ofType(typeOrQuery);\r\n target = collection;\r\n } else {\r\n target = typeOrQuery;\r\n }\r\n\r\n const managedInstances: {\r\n [instanceId: string]: {\r\n dispose: EventSubscriptionCancellation;\r\n controller: ComponentNodeController;\r\n };\r\n } = {};\r\n\r\n const getOrCreateController = (node: ComponentNode): Promise<ComponentNodeController> => {\r\n const existing = managedInstances[node.id];\r\n if (existing) {\r\n return Promise.resolve(existing.controller);\r\n }\r\n return ComponentPlatform.getInstance(container).then((platform) => {\r\n return new ComponentNodeController(platform, node, ns);\r\n });\r\n };\r\n\r\n components.events.subscribe(\r\n 'components:node-enter',\r\n (event, { node }: { node: ComponentNode }) => {\r\n if (target.match(node)) {\r\n getOrCreateController(node).then((controller) => {\r\n Promise.resolve(handler(controller)).then((dispose) => {\r\n managedInstances[node.id] = {\r\n dispose,\r\n controller,\r\n };\r\n });\r\n });\r\n }\r\n }\r\n );\r\n components.events.subscribe(\r\n 'components:node-exit',\r\n (event, { node }: { node: ComponentNode }) => {\r\n const instance = managedInstances[node.id];\r\n if (instance) {\r\n instance.dispose && instance.dispose();\r\n if (!options.reuseController) {\r\n instance.controller.dispose();\r\n delete managedInstances[node.id];\r\n }\r\n }\r\n }\r\n );\r\n });\r\n};\r\n","import { Logger } from '@telia-ace/widget-utilities';\r\nimport {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n WidgetType,\r\n} from '@webprovisions/platform';\r\n\r\nexport type ReactComponent = any | null;\r\n\r\nexport default class ComponentResolver {\r\n aliases: Map<string, string> = new Map();\r\n components: Map<string, any> = new Map();\r\n events: EventManager;\r\n logger = new Logger();\r\n\r\n constructor(container: Container) {\r\n const { events }: WidgetType = container.get('$widget');\r\n this.events = events;\r\n }\r\n\r\n getComponent(key: string): ReactComponent {\r\n const alias = this.aliases.get(key);\r\n const component = this.components.get(alias || key) || null;\r\n\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (!component) {\r\n this.logger.warn(\r\n alias || key,\r\n `Unable to resolve component: \"${\r\n alias || key\r\n }\". You most likely forgot to register the required plugin for: ${\r\n alias || key\r\n }.`\r\n );\r\n }\r\n }\r\n\r\n return component;\r\n }\r\n\r\n registerComponent(key: string, component: ReactComponent): EventSubscriptionCancellation {\r\n this.components.set(key, component);\r\n\r\n this.events.dispatch('component-resolver:resolve', key);\r\n\r\n return () => {\r\n this.components.delete(key);\r\n };\r\n }\r\n\r\n registerResolver(\r\n key: string,\r\n fn: (component: ReactComponent) => void\r\n ): EventSubscriptionCancellation {\r\n return this.events.subscribe('component-resolver:resolve', (e, data: string) => {\r\n if (data === key) {\r\n const component = this.getComponent(key);\r\n fn(component);\r\n }\r\n });\r\n }\r\n\r\n registerAlias(alias: string, key: string): EventSubscriptionCancellation {\r\n this.aliases.set(alias, key);\r\n\r\n this.events.dispatch('component-resolver:resolve', alias);\r\n\r\n return () => {\r\n this.aliases.delete(alias);\r\n };\r\n }\r\n}\r\n","import { ComponentNodeLayout } from '../component-platform';\r\n\r\nexport type ComponentSettings = {\r\n type: string;\r\n context?: Context;\r\n properties?: Properties;\r\n layout?: ComponentNodeLayout;\r\n tags?: string[];\r\n children?: ComponentReference[];\r\n};\r\n\r\nenum HistoryMode {\r\n scopedHash = 'scopedHash',\r\n hash = 'hash',\r\n browser = 'browser',\r\n memory = 'memory',\r\n}\r\n\r\nexport type RoutingSettings = {\r\n initialPath: string;\r\n mode: HistoryMode;\r\n basePath?: string;\r\n};\r\n\r\nexport type ComponentReference = string | [string, ...ComponentReferenceOverride[]];\r\n\r\nexport type Properties = { [key: string]: any };\r\n\r\nexport type Context = { [key: string]: any };\r\n\r\nexport type ViewDefinition = {\r\n path: string | string[];\r\n entry: ComponentReference;\r\n};\r\n\r\nexport type Breakpoints = 'all' | string[];\r\n\r\nexport type ComponentReferenceOverride = {\r\n breakpoints?: Breakpoints;\r\n size?: number | 'full' | 'none';\r\n indent?: number;\r\n tags?: string[];\r\n context?: Context;\r\n properties?: Properties;\r\n};\r\n\r\nexport type ComponentDefinitionMap = {\r\n [name: string]: ComponentSettings;\r\n};\r\n\r\nexport type WidgetSettings = {\r\n data: { projection: string; site?: 'current' | 'referrer'; forceHttps?: boolean };\r\n components: ComponentDefinitionMap;\r\n entry: ComponentReference;\r\n breakpoints: { [name: string]: string };\r\n routing: RoutingSettings;\r\n views: { [name: string]: ViewDefinition };\r\n integrationResources: { path: string; mediaQueriesSupported: boolean }[];\r\n trigger?: { symbol?: Symbol; label?: string; action?: string };\r\n activate?: boolean | null;\r\n plugins?: { [key: string]: any };\r\n};\r\n\r\nexport type MinMax = {\r\n min: string;\r\n max: string;\r\n};\r\n\r\ntype Symbol = {\r\n type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;\r\n content: string;\r\n};\r\n\r\nexport enum WidgetRenderState {\r\n open = 'open',\r\n closed = 'closed',\r\n hidden = 'hidden',\r\n}\r\n"],"names":[],"mappings":";;;;;;;;;;;;;;AASA,MAAqB,GAAe;AAAA,EAGhC,YAAY,GAAsB;AAC9B,UAAM,EAAE,cAAmB,EAAU,IAAI,SAAS;AAC7C,SAAA,SAAS,EAAO,YAAY,IAAI;AAAA,EACzC;AAAA,EAEA,OAAO,GAAgB,GAAgB,GAAkB;AAChD,SAAA,OAAO,SAAS,eAAe,EAAE,WAAQ,UAAO,aAAU,EAAE,SAAS,GAAM,CAAA;AAAA,EACpF;AAAA,EAEA,UAAU,GAAgB,GAA2C;AACjE,WA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;AAAA,EAEA,kBAAkB,GAAa,GAA0D;AAChF,gBAAA,WAAW,IAAI,GAAK,CAAS,GAE7B,KAAA,OAAO,SAAS,8BAA8B,CAAG,GAE/C,MAAM;AACJ,WAAA,WAAW,OAAO,CAAG;AAAA,IAAA;AAAA,EAElC;AAAA,EAEA,iBACI,GACA,GAC6B;AAC7B,WAAO,KAAK,OAAO,UAAU,8BAA8B,CAAC,GAAG,MAAiB;AAC5E,UAAI,MAAS,GAAK;AACR,cAAA,IAAY,KAAK,aAAa,CAAG;AACvC,UAAG,CAAS;AAAA,MAChB;AAAA,IAAA,CACH;AAAA,EACL;AAAA,EAEA,cAAc,GAAe,GAA4C;AAChE,gBAAA,QAAQ,IAAI,GAAO,CAAG,GAEtB,KAAA,OAAO,SAAS,8BAA8B,CAAK,GAEjD,MAAM;AACJ,WAAA,QAAQ,OAAO,CAAK;AAAA,IAAA;AAAA,EAEjC;AACJ;ACCY,IAAA,uBAAA,MACD,GAAA,OAAA,QACE,EAAA,SAAA,UACA,EAAA,SAAA,UAHD,IAAA,MAAA,CAAA,CAAA;"}
1
+ {"version":3,"file":"index.js","sources":["../src/action-resolver.ts","../src/event-subscriber.ts","../src/component-platform/component-query.ts","../src/component-platform/component-controller.ts","../src/component-platform/actions-controller.ts","../src/component-platform/component-configuration-api.ts","../src/component-platform/component-node.ts","../src/component-platform/queries.ts","../src/component-platform/component-node-collection.ts","../src/component-platform/custom-component-handler.ts","../src/component-platform/state-processor.ts","../src/component-platform/component-platform.ts","../src/component-platform/create-component-model.ts","../src/component-platform/descriptor.ts","../src/component-platform/extend-component.ts","../src/component-resolver.ts","../src/types/configuration.ts"],"sourcesContent":["import {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n Widget,\r\n} from '@webprovisions/platform';\r\n\r\nexport type Action = (origin: string, action: string, value?: any) => void;\r\n\r\nexport default class ActionResolver {\r\n private events: EventManager;\r\n\r\n constructor(container: Container) {\r\n const { events }: Widget = container.get('$widget');\r\n this.events = events.createChild(this);\r\n }\r\n\r\n action(target: string, action: string, value: any): void {\r\n this.events.dispatch('data:action', { action, value, target }, { bubbles: true });\r\n }\r\n\r\n subscribe(origin: string, fn: Action): EventSubscriptionCancellation {\r\n return this.events.subscribe(\r\n 'data:action',\r\n (e, { action, value, target }) => origin === target && fn(origin, action, value)\r\n );\r\n }\r\n}\r\n","import {\r\n EventListener,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n} from '@webprovisions/platform';\r\n\r\nexport type SubscribeDelegate = (type: string, listener: EventListener) => void;\r\n\r\n/**\r\n * Creates s subscriber for the specified `EventManager` and provides a single cancellation\r\n * function for all registered subscriptions.\r\n */\r\nexport const createEventSubscriber = (\r\n events: EventManager\r\n): [SubscribeDelegate, EventSubscriptionCancellation] => {\r\n const subs: EventSubscriptionCancellation[] = [];\r\n\r\n const subscribe = (type: string, listener: EventListener) => {\r\n subs.push(events.subscribe(type, listener));\r\n };\r\n\r\n return [\r\n subscribe,\r\n () => {\r\n subs.forEach((sub) => {\r\n sub();\r\n });\r\n },\r\n ];\r\n};\r\n","import { AbstractComponentController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\n\r\nexport type ComponentQueryRule = {\r\n id?: string;\r\n type?: string;\r\n};\r\n\r\nexport class ComponentQuery {\r\n constructor(private platform: ComponentPlatform, public rules: ComponentQueryRule[] = []) {}\r\n\r\n match(node: ComponentNode) {\r\n return this.rules.every((rule) => {\r\n if (rule.id && rule.id !== node.id) {\r\n return false;\r\n }\r\n if (rule.type && rule.type !== node.type) {\r\n return false;\r\n }\r\n return true;\r\n });\r\n }\r\n\r\n ofType(type: string): ComponentQuery {\r\n this.rules.push({ type });\r\n return this;\r\n }\r\n\r\n withId(id: string): ComponentQuery {\r\n this.rules.push({ id });\r\n return this;\r\n }\r\n\r\n select(): AbstractComponentController {\r\n return new AbstractComponentController(this.platform, this);\r\n }\r\n}\r\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { createEventSubscriber, SubscribeDelegate } from '../event-subscriber';\r\nimport { ActionsController } from './actions-controller';\r\nimport {\r\n ChangesetOptions,\r\n ComponentNode,\r\n ComponentNodeContext,\r\n ComponentNodeLayout,\r\n ComponentNodeProperties,\r\n RemoveChangeset,\r\n} from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport interface ComponentController {\r\n actions: ActionsController;\r\n\r\n writeProperties(properties: Partial<ComponentNodeProperties>, options: ChangesetOptions): void;\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options: ChangesetOptions): void;\r\n\r\n writeLayout(context: Partial<ComponentNodeLayout>, options: ChangesetOptions): void;\r\n\r\n dispose(): void;\r\n}\r\n\r\nexport class ComponentNodeController implements ComponentController {\r\n actions: ActionsController;\r\n\r\n private subscribe: SubscribeDelegate;\r\n private unsubscribe: EventSubscriptionCancellation;\r\n\r\n constructor(private platform: ComponentPlatform, public node: ComponentNode, ns?: string) {\r\n this.actions = new ActionsController(\r\n platform,\r\n new ComponentQuery(platform).withId(node.id),\r\n ns\r\n );\r\n const [subscribe, unsubscribe] = createEventSubscriber(this.platform.events);\r\n this.subscribe = subscribe;\r\n this.unsubscribe = unsubscribe;\r\n }\r\n\r\n properties<T extends ComponentNodeProperties>(\r\n updated?: (properties: T) => void | Partial<ComponentNodeProperties>\r\n ): T {\r\n if (updated) {\r\n this.node.touchProperties((properties) => updated(<T>properties));\r\n }\r\n return <T>this.node.attributes.properties;\r\n }\r\n\r\n context(updated?: (context: ComponentNodeContext) => void): ComponentNodeContext {\r\n if (updated) {\r\n this.subscribe('components:context-changed', (event, { node }) => {\r\n if (node === this.node) {\r\n updated(this.node.attributes.context);\r\n }\r\n });\r\n }\r\n return this.node.attributes.context;\r\n }\r\n\r\n layout(updated?: (layout: ComponentNodeLayout) => void): ComponentNodeLayout {\r\n if (updated) {\r\n this.subscribe('components:layout-changed', (event, { node }) => {\r\n if (node === this.node) {\r\n updated(this.node.attributes.layout);\r\n }\r\n });\r\n }\r\n return this.node.attributes.layout;\r\n }\r\n\r\n writeProperties(\r\n properties:\r\n | Partial<ComponentNodeProperties>\r\n | ((properties: ComponentNodeProperties) => Partial<ComponentNodeProperties>),\r\n options?: ChangesetOptions\r\n ): void {\r\n this.node.writeProperties(properties, options);\r\n }\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\r\n this.node.writeProperties(context, options);\r\n }\r\n\r\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\r\n this.node.writeLayout(layout, options);\r\n }\r\n\r\n dispose() {\r\n this.unsubscribe();\r\n this.actions.dispose();\r\n }\r\n}\r\n\r\nexport class AbstractComponentController implements ComponentController {\r\n actions: ActionsController;\r\n private removes: RemoveChangeset[] = [];\r\n\r\n constructor(\r\n private platform: ComponentPlatform,\r\n private target: ComponentQuery,\r\n private clearOnDispose = true\r\n ) {\r\n this.actions = new ActionsController(this.platform, this.target);\r\n }\r\n\r\n writeProperties(\r\n properties: Partial<ComponentNodeProperties>,\r\n options?: ChangesetOptions\r\n ): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { properties },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n writeContext(context: Partial<ComponentNodeContext>, options?: ChangesetOptions): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { context },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n writeLayout(layout: Partial<ComponentNodeLayout>, options?: ChangesetOptions): void {\r\n this.removes.push(\r\n this.platform.write({\r\n options,\r\n attributes: { layout },\r\n target: this.target,\r\n removable: this.clearOnDispose,\r\n })\r\n );\r\n }\r\n\r\n dispose() {\r\n this.removes.forEach((remove) => {\r\n remove();\r\n });\r\n this.actions.dispose();\r\n }\r\n}\r\n","import { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { ComponentNodeController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport type ActionData = any;\r\n\r\nexport type ActionHandler = (data: any, options: any, instance: ComponentNodeController) => any;\r\nexport type NextActionDelegate = (data: any, options?: any) => Promise<any>;\r\nexport type WatchActionDelegate = (\r\n input: ActionData,\r\n next: NextActionDelegate,\r\n instance: ComponentNodeController\r\n) => Promise<any> | any;\r\nexport type ActionWatcherContext = {\r\n source: ComponentNode;\r\n action: string;\r\n};\r\n\r\nexport type ActionsState = {\r\n handlers: {\r\n fn: ActionHandler;\r\n key: string;\r\n target: ComponentQuery;\r\n ns?: string;\r\n }[];\r\n\r\n watchers: {\r\n target: ComponentQuery;\r\n fn: WatchActionDelegate;\r\n key: string;\r\n ns?: string;\r\n }[];\r\n};\r\n\r\ntype ActionWatcherExecutionResult = {\r\n data: any;\r\n options: any;\r\n cancelled: boolean;\r\n};\r\n\r\nconst executeActionListeners = (\r\n listeners: WatchActionDelegate[],\r\n data: any,\r\n controller: ComponentNodeController\r\n): Promise<ActionWatcherExecutionResult> => {\r\n const stack = listeners.concat();\r\n const dispatch = (\r\n data: any,\r\n globalOptions: any,\r\n controller: ComponentNodeController\r\n ): Promise<ActionWatcherExecutionResult> => {\r\n let cancelled = true;\r\n if (stack.length) {\r\n const handler = stack.shift() as WatchActionDelegate;\r\n\r\n const next = (data: any, options: any) => {\r\n cancelled = false;\r\n return dispatch(data, Object.assign({}, globalOptions, options), controller);\r\n };\r\n\r\n return Promise.resolve(handler(data, next, controller)).then((result) => ({\r\n ...result,\r\n cancelled,\r\n }));\r\n }\r\n\r\n return Promise.resolve({ data, cancelled: false, options: globalOptions });\r\n };\r\n return dispatch(data, {}, controller);\r\n};\r\n\r\nexport class ActionsController {\r\n private subscriptions: (() => void)[] = [];\r\n constructor(\r\n private platform: ComponentPlatform,\r\n private target: ComponentQuery,\r\n private ns?: string\r\n ) {\r\n this.create = this.create.bind(this);\r\n }\r\n\r\n create(key: string, fn: ActionHandler = () => {}): EventSubscriptionCancellation {\r\n const handler = {\r\n key,\r\n fn,\r\n target: this.target,\r\n ns: this.ns,\r\n };\r\n this.platform.actionsState.handlers.push(handler);\r\n const subscription = () => {\r\n const index = this.platform.actionsState.handlers.indexOf(handler);\r\n if (index > -1) {\r\n this.platform.actionsState.handlers.splice(index, 1);\r\n }\r\n };\r\n this.subscriptions.push(subscription);\r\n return subscription;\r\n }\r\n\r\n dispatch(key: string, data: any): Promise<{ [instanceId: string]: any }> {\r\n const instances: ComponentNode[] = this.platform.nodes.all.concat(\r\n this.platform.nodes.detached\r\n );\r\n\r\n const output: { [instanceId: string]: any } = {};\r\n\r\n // handlers matching the specified pattern.\r\n const handlers = this.platform.actionsState.handlers.filter(\r\n (handler) => handler.key === key && (!handler.ns || !this.ns || handler.ns === this.ns)\r\n );\r\n\r\n return Promise.all(\r\n handlers.map((handler) => {\r\n // select all matching instances for this particular\r\n // handler (a handler can be mapped to many instances)\r\n const matchedInstances = instances.filter(\r\n (instance) => handler.target.match(instance) && this.target.match(instance)\r\n );\r\n\r\n // execute watchers for each matched instance\r\n const watchers = this.platform.actionsState.watchers\r\n .filter((watcher) => {\r\n return (\r\n watcher.key === key &&\r\n (!watcher.ns || !this.ns || watcher.ns === this.ns) &&\r\n matchedInstances.some((instance) => watcher.target.match(instance))\r\n );\r\n })\r\n .map((watcher) => watcher.fn);\r\n\r\n // execute watchers and handler for each instance\r\n return Promise.all(\r\n matchedInstances.map((node) => {\r\n const controller = new ComponentNodeController(\r\n this.platform,\r\n node,\r\n this.ns\r\n );\r\n return executeActionListeners(watchers, data, controller).then((input) => {\r\n const { data = {}, options, cancelled } = input;\r\n return Promise.resolve(\r\n cancelled ? {} : handler.fn(data, options, controller)\r\n ).then((handlerResponse) => {\r\n output[node.id] = handlerResponse;\r\n });\r\n });\r\n })\r\n );\r\n })\r\n ).then(() => output);\r\n }\r\n\r\n watch(key: string, fn: WatchActionDelegate): EventSubscriptionCancellation {\r\n let parsedKey = key;\r\n let parsedNs = this.ns;\r\n const sections = key.split('.');\r\n\r\n if (sections.length > 1) {\r\n parsedNs = sections[0];\r\n parsedKey = sections.splice(1).join('.');\r\n }\r\n const watcher = {\r\n fn,\r\n target: this.target,\r\n key: parsedKey,\r\n ns: parsedNs,\r\n };\r\n this.platform.actionsState.watchers.push(watcher);\r\n const subscription = () => {\r\n const index = this.platform.actionsState.watchers.indexOf(watcher);\r\n if (index > -1) {\r\n this.platform.actionsState.watchers.splice(index, 1);\r\n }\r\n };\r\n this.subscriptions.push(subscription);\r\n return subscription;\r\n }\r\n\r\n dispose() {\r\n this.subscriptions.forEach((unsubscribe) => unsubscribe());\r\n }\r\n}\r\n","import { createConfigurationApi } from '@webprovisions/platform';\r\nimport { CustomHandlerCallback } from './custom-component-handler';\r\n\r\ntype Options = {\r\n handlers?: [string, CustomHandlerCallback][];\r\n};\r\n\r\nexport default createConfigurationApi((builder) => {\r\n builder.createCommand('components', (context) => (config: Options) => {\r\n context.events.subscribeOnce('components:platform-created', (event, { platform }) => {\r\n if (config.handlers) {\r\n config.handlers.forEach(([key, handler]) => {\r\n platform.addComponentHandler(key, handler);\r\n });\r\n }\r\n });\r\n });\r\n});\r\n","import { Logger, uuid } from '@telia-ace/widget-utilities';\r\nimport { Container, EventManager, EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { Breakpoints } from '../types';\r\n\r\nexport type ComponentNodeEventData = { node: ComponentNode };\r\n\r\nexport type RemoveChangeset = () => void;\r\n\r\nexport type ComponentNodeAttributes = {\r\n tags: string[];\r\n properties: ComponentNodeProperties;\r\n context: ComponentNodeContext;\r\n layout: ComponentNodeLayout;\r\n};\r\n\r\nexport type ResolveComponentNodeProperties = (\r\n properties: ComponentNodeProperties\r\n) => Partial<ComponentNodeProperties> | void;\r\n\r\nexport type ResolveComponentNodeContext = (\r\n context: ComponentNodeContext\r\n) => Partial<ComponentNodeContext>;\r\n\r\nexport type ResolveComponentNodeLayout = (\r\n layout: ComponentNodeLayout\r\n) => Partial<ComponentNodeLayout>;\r\n\r\nexport type ComponentNodeSettings = {\r\n tags?: string[];\r\n properties?: ComponentNodeProperties | ResolveComponentNodeProperties;\r\n context?: ComponentNodeContext | ResolveComponentNodeContext;\r\n layout?: ComponentNodeLayout | ResolveComponentNodeLayout;\r\n};\r\n\r\nexport type ComponentNodeProperties = { [key: string]: any };\r\n\r\nexport type ComponentNodeContext = { [key: string]: any };\r\n\r\nexport type ComponentNodeLayout = {\r\n size?: Size;\r\n indent?: number;\r\n order?: number;\r\n};\r\n\r\nexport type Size = number | 'full' | 'none';\r\n\r\nexport type UnmountComponentNode = () => void;\r\n\r\nexport type ChangesetOptions = {\r\n breakpoints?: Breakpoints;\r\n};\r\n\r\nexport type Changeset = [Partial<ComponentNodeSettings>, ChangesetOptions];\r\n\r\nexport class ComponentNode {\r\n id: string;\r\n type: string;\r\n name?: string;\r\n parent?: ComponentNode;\r\n tags: string[] = [];\r\n children: { [key: string]: ComponentNode[] } = {};\r\n changesets: Changeset[] = [];\r\n attributes: ComponentNodeAttributes;\r\n\r\n private mountCount = 0;\r\n\r\n constructor(private events: EventManager, type: string) {\r\n this.id = uuid();\r\n this.type = type;\r\n this.attributes = {\r\n context: {},\r\n properties: {},\r\n layout: {},\r\n tags: [],\r\n };\r\n // write default attributes\r\n this.writeLayout({ size: 'full', indent: 0 });\r\n }\r\n\r\n mount(viewOutletContainer: Container, element?: HTMLElement): UnmountComponentNode {\r\n let mountedNodes: Map<ComponentNode, EventSubscriptionCancellation> =\r\n viewOutletContainer.get('mounted-nodes');\r\n\r\n if (!mountedNodes) {\r\n mountedNodes = new Map<ComponentNode, EventSubscriptionCancellation>();\r\n viewOutletContainer.register('mounted-nodes', mountedNodes);\r\n }\r\n\r\n if (mountedNodes.has(this)) {\r\n if (process.env.NODE_ENV !== 'production') {\r\n Logger.error('Trying to mount an already mounted component node.', this);\r\n }\r\n return () => {};\r\n }\r\n\r\n /**\r\n * Dispatched when a node is mounted in a component.\r\n * This happens once for every `ViewOutlet`.\r\n */\r\n this.events.dispatch('components:node-mounted', { node: this });\r\n\r\n if (this.mountCount === 0) {\r\n this.mountCount = this.mountCount + 1;\r\n /**\r\n * Dispatched when a node is mounted in a component the first time.\r\n */\r\n this.events.dispatch('components:node-enter', { node: this });\r\n }\r\n\r\n return () => {\r\n mountedNodes.delete(this);\r\n this.events.dispatch('components:node-unmounted', { node: this });\r\n\r\n this.mountCount = this.mountCount - 1;\r\n if (this.mountCount === 0) {\r\n this.events.dispatch('components:node-exit', { node: this });\r\n }\r\n };\r\n }\r\n\r\n appendChild(node: ComponentNode, branch: string = 'default') {\r\n if (node.parent) {\r\n if (node.parent === this) {\r\n return;\r\n }\r\n node.parent.removeChild(node);\r\n }\r\n node.parent = this;\r\n\r\n if (!this.children[branch]) {\r\n this.children[branch] = [];\r\n }\r\n this.children[branch].push(node);\r\n\r\n this.events.dispatch('components:node-appended', { node });\r\n }\r\n\r\n prependChild(node: ComponentNode, branch: string = 'default') {\r\n if (node.parent) {\r\n if (node.parent === this) {\r\n return;\r\n }\r\n node.parent.removeChild(node);\r\n }\r\n node.parent = this;\r\n\r\n if (!this.children[branch]) {\r\n this.children[branch] = [];\r\n }\r\n this.children[branch].unshift(node);\r\n\r\n this.events.dispatch('components:node-appended', { node });\r\n }\r\n\r\n touchProperties(\r\n properties: ResolveComponentNodeProperties,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { properties };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n return () => {\r\n if (removable) {\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n }\r\n }\r\n };\r\n }\r\n\r\n writeProperties(\r\n properties: Partial<ComponentNodeProperties> | ResolveComponentNodeProperties,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { properties };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n return () => {\r\n if (removable) {\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-properties', { node: this });\r\n }\r\n }\r\n };\r\n }\r\n\r\n writeLayout(\r\n layout: Partial<ComponentNodeLayout> | ResolveComponentNodeLayout,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { layout };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-layout', { node: this });\r\n return () => {\r\n if (!removable) {\r\n return;\r\n }\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-layout', { node: this });\r\n }\r\n };\r\n }\r\n\r\n writeContext(\r\n context: Partial<ComponentNodeContext> | ResolveComponentNodeContext,\r\n options: ChangesetOptions = {},\r\n removable?: boolean\r\n ): RemoveChangeset {\r\n const attributes: Partial<ComponentNodeSettings> = { context };\r\n const changeset: Changeset = [attributes, options];\r\n this.changesets.push(changeset);\r\n this.events.dispatch('components:set-context', { node: this });\r\n return () => {\r\n if (!removable) {\r\n return;\r\n }\r\n const indexToRemove = this.changesets.indexOf(changeset);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n this.events.dispatch('components:set-context', { node: this });\r\n }\r\n };\r\n }\r\n\r\n getChildren(branch: string = 'default'): ComponentNode[] {\r\n const children = this.children[branch] || [];\r\n return children.reduce((acc, node, i) => {\r\n const { order: index = i } = node.attributes.layout;\r\n if (!acc[index]) {\r\n acc[index] = node;\r\n } else {\r\n acc.splice(index, 0, node);\r\n }\r\n return acc;\r\n }, Array(children.length));\r\n }\r\n\r\n remove() {\r\n if (this.parent) {\r\n this.parent.removeChild(this);\r\n }\r\n }\r\n\r\n removeChild(node: ComponentNode) {\r\n Object.keys(this.children).forEach((branch) => {\r\n const children = this.children[branch];\r\n const indexToRemove = children.indexOf(node);\r\n if (indexToRemove > -1) {\r\n children.splice(indexToRemove, 1);\r\n this.events.dispatch('components:node-removed', { node, parentNode: this });\r\n }\r\n });\r\n delete node.parent;\r\n }\r\n}\r\n","import { ComponentNode } from './component-node';\r\nimport { SwitchMap } from './component-platform';\r\n\r\nconst traverseComponentsRecursive = (\r\n nodes: ComponentNode[],\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean | void\r\n) => {\r\n for (let i = 0, y = nodes.length; i < y; i++) {\r\n if (fn(nodes[i]) === true) {\r\n break;\r\n }\r\n const branch = switches[nodes[i].id] || 'default';\r\n const children = nodes[i].getChildren(branch);\r\n traverseComponentsRecursive(children, switches, fn);\r\n }\r\n};\r\n\r\nexport const traverseComponents = (\r\n root: ComponentNode,\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean | void\r\n) => {\r\n if (fn(root) !== true) {\r\n const branch = switches[root.id] || 'default';\r\n const children = root.children[branch];\r\n traverseComponentsRecursive(children, switches, fn);\r\n }\r\n};\r\n\r\nexport const findVisibleComponents = (\r\n root: ComponentNode,\r\n switches: SwitchMap\r\n): ComponentNode[] => {\r\n const nodes: ComponentNode[] = [];\r\n traverseComponents(root, switches, (node) => {\r\n nodes.push(node);\r\n });\r\n return nodes;\r\n};\r\n\r\nexport const findComponent = (\r\n root: ComponentNode,\r\n switches: SwitchMap,\r\n fn: (node: ComponentNode) => boolean\r\n) => {\r\n let matched: ComponentNode | undefined;\r\n traverseComponents(root, switches, (node) => {\r\n if (fn(node)) {\r\n matched = node;\r\n return true;\r\n }\r\n });\r\n return matched;\r\n};\r\n\r\nexport const getAncestors = (node: ComponentNode) => {\r\n if (!node.parent) {\r\n return [];\r\n }\r\n const tree: ComponentNode[] = [];\r\n let currentNode: ComponentNode | undefined = node.parent;\r\n while (currentNode) {\r\n tree.unshift(currentNode);\r\n currentNode = currentNode.parent;\r\n }\r\n return tree;\r\n};\r\n","import { EventManager } from '@webprovisions/platform';\r\nimport { ComponentNode, ComponentNodeEventData } from './component-node';\r\nimport { SwitchMap } from './component-platform';\r\nimport { findComponent, findVisibleComponents, traverseComponents } from './queries';\r\n\r\nexport type QueryDescriptor = {\r\n id?: string;\r\n type?: string;\r\n name?: string;\r\n};\r\n\r\nexport class ComponentNodeCollection {\r\n all: ComponentNode[] = [];\r\n visible: ComponentNode[] = [];\r\n detached: ComponentNode[] = [];\r\n\r\n constructor(public root: ComponentNode, private switches: SwitchMap, events: EventManager) {\r\n events.subscribe('components:node-appended', (event, data: ComponentNodeEventData) => {\r\n this.all.push(data.node);\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n events.subscribe('components:node-removed', (event, data: ComponentNodeEventData) => {\r\n let indexToRemove = this.all.indexOf(data.node);\r\n if (indexToRemove > -1) {\r\n this.all.splice(indexToRemove, 1);\r\n }\r\n indexToRemove = this.visible.indexOf(data.node);\r\n if (indexToRemove > -1) {\r\n this.visible.splice(indexToRemove, 1);\r\n }\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n events.subscribe('components:node-switched', (event, data: ComponentNodeEventData) => {\r\n this.visible = findVisibleComponents(root, switches);\r\n });\r\n }\r\n\r\n query(query: QueryDescriptor = {}): ComponentNode[] {\r\n const nodes: ComponentNode[] = [];\r\n traverseComponents(this.root, this.switches, (node) => {\r\n const match = Object.keys(query).every((member) => {\r\n return (<any>query)[member] === (<any>node)[member];\r\n });\r\n if (match) {\r\n nodes.push(node);\r\n }\r\n });\r\n return nodes;\r\n }\r\n\r\n get(id: string) {\r\n return (\r\n findComponent(this.root, this.switches, (node) => node.id === id) ||\r\n this.detached.find((node) => node.id === id)\r\n );\r\n }\r\n}\r\n","import { ComponentReference, ComponentSettings, ViewDefinition } from '../types';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { NormalizedComponentReference } from './create-component-model';\r\n\r\nexport type CustomHandlerCallback = (\r\n ref: NormalizedComponentReference,\r\n options: {\r\n platform: ComponentPlatform;\r\n node: ComponentNode;\r\n references: ComponentReference[];\r\n definitions: { [name: string]: ComponentSettings };\r\n views: { [key: string]: ViewDefinition };\r\n branch?: string;\r\n }\r\n) => void;\r\n\r\nexport class CustomComponentHandler {\r\n private handlers = new Map<string, CustomHandlerCallback>();\r\n\r\n add(name: string, fn: CustomHandlerCallback) {\r\n this.handlers.set(name, fn);\r\n }\r\n\r\n get(name: string) {\r\n return this.handlers.get(name);\r\n }\r\n}\r\n","import { ComponentPlatform } from '.';\r\nimport { Breakpoints } from '../types';\r\nimport {\r\n ComponentNode,\r\n ResolveComponentNodeContext,\r\n ResolveComponentNodeLayout,\r\n ResolveComponentNodeProperties,\r\n} from './component-node';\r\n\r\nexport type ProcessOptions = {\r\n context?: boolean;\r\n properties?: boolean;\r\n layout?: boolean;\r\n recursive?: boolean;\r\n};\r\n\r\nexport type StateProcessor = (node: ComponentNode, options: ProcessOptions) => void;\r\n\r\nconst calculateNodeIndex = (node: ComponentNode): number => {\r\n let currentNode = node;\r\n let index = 0;\r\n\r\n while (currentNode.parent) {\r\n index = index + 1;\r\n currentNode = currentNode.parent;\r\n }\r\n\r\n return index;\r\n};\r\n\r\nconst sortQueue = (queue: [ComponentNode, ProcessOptions][]): [ComponentNode, ProcessOptions][] => {\r\n const mapped: [number, ComponentNode, ProcessOptions][] = queue.map(([node, options]) => {\r\n return [calculateNodeIndex(node), node, options];\r\n });\r\n return mapped\r\n .sort(([a], [b]) => a - b)\r\n .map(([, node, options]) => {\r\n return [node, options];\r\n });\r\n};\r\n\r\nconst isObject = (item: any) => {\r\n return item && typeof item === 'object' && !Array.isArray(item);\r\n};\r\n\r\nconst mergeDeep = (target: any, ...sources: any[]): any => {\r\n if (!sources.length) return target;\r\n const source = sources.shift();\r\n\r\n if (isObject(target) && isObject(source)) {\r\n for (const key in source) {\r\n if (isObject(source[key])) {\r\n if (!target[key]) Object.assign(target, { [key]: {} });\r\n mergeDeep(target[key], source[key]);\r\n } else {\r\n Object.assign(target, { [key]: source[key] });\r\n }\r\n }\r\n }\r\n return mergeDeep(target, ...sources);\r\n};\r\n\r\nconst matchesBreakpoint = (b1: Breakpoints | undefined, b2: string[]) => {\r\n if (!b1 || b1 === 'all') {\r\n return true;\r\n }\r\n return b1.some((b1) => b2.indexOf(b1) > -1);\r\n};\r\n\r\nexport type ProcessResult = Map<ComponentNode, ProcessOptions>;\r\n\r\nexport type ProcessReportCallback = (report: ProcessResult) => void;\r\n\r\nexport const createStateProcessor = (\r\n platform: ComponentPlatform,\r\n callback: ProcessReportCallback\r\n): StateProcessor => {\r\n let nodeQueue: ComponentNode[] = [];\r\n let optionsQueue: ProcessOptions[] = [];\r\n\r\n let timeout: NodeJS.Timeout;\r\n\r\n const flush = () => {\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.time('state-processor.flush');\r\n }\r\n const processHistory: Map<ComponentNode, ProcessOptions> = new Map();\r\n const sortedQueue = sortQueue(nodeQueue.map((node, i) => [node, optionsQueue[i]]));\r\n\r\n const processNode = (node: ComponentNode, options: ProcessOptions) => {\r\n const history = processHistory.get(node) || {};\r\n\r\n // todo: this doesnt take overrides into account\r\n const processContext = options.context && !history.context;\r\n const processProperties = options.properties && !history.properties;\r\n const processLayout = options.layout && !history.layout;\r\n\r\n processHistory.set(node, {\r\n context: history.context || processContext,\r\n properties: history.properties || processProperties,\r\n layout: history.layout || processLayout,\r\n });\r\n\r\n if (processProperties) {\r\n node.attributes.properties = {};\r\n }\r\n if (processLayout) {\r\n node.attributes.layout = {};\r\n }\r\n\r\n if (processContext) {\r\n node.attributes.context = mergeDeep({}, node.parent?.attributes.context);\r\n }\r\n\r\n const propertyResolvers: ResolveComponentNodeProperties[] = [];\r\n const layoutResolvers: ResolveComponentNodeLayout[] = [];\r\n const contextResolvers: ResolveComponentNodeContext[] = [];\r\n\r\n node.changesets.forEach((changeset) => {\r\n const [change, options] = changeset;\r\n if (matchesBreakpoint(options.breakpoints, platform.breakpoints)) {\r\n if (processProperties) {\r\n if (typeof change.properties === 'function') {\r\n propertyResolvers.push(\r\n <ResolveComponentNodeProperties>change.properties\r\n );\r\n } else {\r\n mergeDeep(node.attributes.properties, change.properties);\r\n }\r\n }\r\n\r\n if (processLayout) {\r\n if (typeof change.layout === 'function') {\r\n layoutResolvers.push(<ResolveComponentNodeLayout>change.layout);\r\n } else {\r\n mergeDeep(node.attributes.layout, change.layout);\r\n }\r\n }\r\n\r\n if (processContext) {\r\n if (typeof change.context === 'function') {\r\n contextResolvers.push(<ResolveComponentNodeContext>change.context);\r\n } else {\r\n mergeDeep(node.attributes.context, change.context);\r\n }\r\n }\r\n }\r\n });\r\n\r\n propertyResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.properties, resolver(node.attributes.properties));\r\n });\r\n\r\n layoutResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.layout, resolver(node.attributes.layout));\r\n });\r\n\r\n contextResolvers.forEach((resolver) => {\r\n mergeDeep(node.attributes.context, resolver(node.attributes.context));\r\n });\r\n\r\n if (processContext || options.recursive) {\r\n const branch = platform.getBranch(node);\r\n const childOptions: ProcessOptions = options.recursive\r\n ? options\r\n : {\r\n context: !!processContext,\r\n };\r\n node.getChildren(branch).forEach((child) => {\r\n processNode(child, childOptions);\r\n });\r\n }\r\n };\r\n\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.timeEnd('state-processor.flush');\r\n }\r\n\r\n sortedQueue.forEach(([node, options]) => {\r\n processNode(node, options);\r\n });\r\n\r\n nodeQueue = [];\r\n optionsQueue = [];\r\n\r\n callback(processHistory);\r\n };\r\n\r\n const schedule = () => {\r\n clearTimeout(timeout);\r\n timeout = setTimeout(flush, 0);\r\n };\r\n\r\n return (node, options) => {\r\n const index = nodeQueue.indexOf(node);\r\n\r\n if (index > -1) {\r\n // if node already exist in queue, update its options\r\n const summary = optionsQueue[index];\r\n if (options.context) {\r\n summary.context = true;\r\n }\r\n if (options.properties) {\r\n summary.properties = true;\r\n }\r\n if (options.layout) {\r\n summary.layout = true;\r\n }\r\n if (options.recursive) {\r\n summary.recursive = true;\r\n }\r\n return schedule();\r\n }\r\n\r\n nodeQueue.push(node);\r\n optionsQueue.push(options);\r\n\r\n return schedule();\r\n };\r\n};\r\n","import { uuid } from '@telia-ace/widget-utilities';\r\nimport {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n Widget,\r\n} from '@webprovisions/platform';\r\nimport { ActionsController, ActionsState } from './actions-controller';\r\nimport { ChangesetProvider } from './changeset-provider';\r\nimport {\r\n Changeset,\r\n ChangesetOptions,\r\n ComponentNode,\r\n ComponentNodeEventData,\r\n ComponentNodeSettings,\r\n RemoveChangeset,\r\n} from './component-node';\r\nimport { ComponentNodeCollection } from './component-node-collection';\r\nimport { ComponentQuery } from './component-query';\r\nimport { CustomComponentHandler, CustomHandlerCallback } from './custom-component-handler';\r\nimport { createStateProcessor, StateProcessor } from './state-processor';\r\n\r\nexport type MergeOptions = { breakpoints?: string[] };\r\n\r\ntype AbstractChangesetRecord = {\r\n changeset: Changeset;\r\n target: ComponentQuery;\r\n removes: RemoveChangeset[];\r\n};\r\n\r\nexport type SwitchMap = { [id: string]: string };\r\n\r\nexport type ChangesetData = {\r\n key?: string;\r\n target: ComponentQuery;\r\n attributes: Partial<ComponentNodeSettings>;\r\n options?: ChangesetOptions;\r\n removable?: boolean;\r\n provider?: string;\r\n};\r\n\r\nexport class ComponentPlatform {\r\n events: EventManager;\r\n breakpoints: string[] = [];\r\n nodes: ComponentNodeCollection;\r\n // internal\r\n actionsState: ActionsState = { handlers: [], watchers: [] };\r\n\r\n private switches: SwitchMap = {};\r\n private changesets: AbstractChangesetRecord[] = [];\r\n private subscriptions: EventSubscriptionCancellation[] = [];\r\n private processNode: StateProcessor;\r\n private customComponentHandler = new CustomComponentHandler();\r\n\r\n constructor(widget: Widget, private providers: { [key: string]: ChangesetProvider } = {}) {\r\n this.events = widget.events.createChild(this);\r\n const root = new ComponentNode(this.events, 'root');\r\n root.name = `root-${widget.name}`;\r\n this.nodes = new ComponentNodeCollection(root, this.switches, this.events);\r\n\r\n const processNode = (this.processNode = createStateProcessor(this, (report) => {\r\n const nodes = Array.from(report.keys());\r\n if (process.env.NODE_ENV !== 'production') {\r\n console.info(`STATE PROCESSOR: ${nodes.length} node(s) processed:\r\n${nodes.map(\r\n (node) => `${node.name || '<no name>'} (${node.id})\r\n`\r\n)}`);\r\n }\r\n nodes.forEach((node) => {\r\n const options = report.get(node);\r\n if (node.parent && node.parent.type === 'root') {\r\n this.events.dispatch('components:root-children-changed', { node });\r\n }\r\n if (options?.context) {\r\n this.events.dispatch('components:context-changed', { node });\r\n }\r\n if (options?.properties) {\r\n this.events.dispatch('components:properties-changed', { node });\r\n }\r\n if (options?.layout) {\r\n this.events.dispatch('components:layout-changed', { node });\r\n }\r\n });\r\n this.events.dispatch('components:component-model-initialized', {}, { bubbles: true });\r\n }));\r\n\r\n Promise.all(\r\n Object.keys(providers).map((key) => {\r\n const provider = providers[key];\r\n return provider.load(this);\r\n })\r\n );\r\n\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:node-appended',\r\n (event, data: ComponentNodeEventData) => {\r\n const { node } = data;\r\n this.changesets.forEach((record) => {\r\n const { changeset, target, removes } = record;\r\n const [change, options] = changeset;\r\n if (target.match(data.node)) {\r\n if (change.properties) {\r\n removes.push(node.writeProperties(change.properties, options));\r\n }\r\n if (change.context) {\r\n removes.push(node.writeContext(change.context, options));\r\n }\r\n if (change.layout) {\r\n removes.push(node.writeLayout(change.layout, options));\r\n }\r\n }\r\n });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:node-appended',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true, context: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-properties',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-context',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { properties: true, context: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-indent',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { layout: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe(\r\n 'components:set-layout',\r\n (event, data: ComponentNodeEventData) => {\r\n processNode(data.node, { layout: true });\r\n }\r\n )\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe('components:node-switched', (event, { node, branch }) => {\r\n processNode(node, {\r\n layout: true,\r\n recursive: true,\r\n properties: true,\r\n context: true,\r\n });\r\n })\r\n );\r\n this.subscriptions.push(\r\n this.events.subscribe('components:node-removed', (event, { parentNode }) => {\r\n processNode(parentNode, { properties: true });\r\n })\r\n );\r\n\r\n if (this.events.parent) {\r\n this.events.parent.dispatch('components:platform-created', { platform: this });\r\n }\r\n }\r\n\r\n static getInstance(container: Container): Promise<ComponentPlatform> {\r\n return container.getAsync('components');\r\n }\r\n\r\n addBreakpoint(name: string) {\r\n if (this.breakpoints.indexOf(name) === -1) {\r\n this.breakpoints.push(name);\r\n this.processNode(this.nodes.root, {\r\n context: true,\r\n properties: true,\r\n layout: true,\r\n recursive: true,\r\n });\r\n }\r\n }\r\n\r\n removeBreakpoint(name: string) {\r\n const indexToRemove = this.breakpoints.indexOf(name);\r\n if (indexToRemove > -1) {\r\n this.breakpoints.splice(indexToRemove, 1);\r\n this.processNode(this.nodes.root, {\r\n context: true,\r\n properties: true,\r\n layout: true,\r\n recursive: true,\r\n });\r\n }\r\n }\r\n\r\n setSwitch(node: ComponentNode, branch: string) {\r\n this.switches[node.id] = branch;\r\n this.events.dispatch('components:node-switched', { node, branch });\r\n }\r\n\r\n getBranch(node: ComponentNode): string | undefined {\r\n return this.switches[node.id];\r\n }\r\n\r\n /**\r\n * Creates a `ComponentNode` of the specified type.\r\n * @param type Type of node.\r\n */\r\n createNode(type: string, options: { detached?: boolean } = {}): ComponentNode {\r\n const node = new ComponentNode(this.events, type);\r\n if (options.detached) {\r\n this.nodes.detached.push(node);\r\n }\r\n return node;\r\n }\r\n\r\n components(): ComponentQuery {\r\n return new ComponentQuery(this);\r\n }\r\n\r\n actions(target: ComponentQuery, ns: string): ActionsController {\r\n return new ActionsController(this, <any>target, ns);\r\n }\r\n\r\n write(data: ChangesetData): RemoveChangeset {\r\n const { provider: providerName, target, attributes, options = {}, removable } = data;\r\n const key = data.key || uuid();\r\n const changeset: Changeset = [attributes, options];\r\n const record: AbstractChangesetRecord = { changeset, target, removes: [] };\r\n if (providerName) {\r\n const provider = this.providers[providerName];\r\n provider.write(key, target, attributes, options);\r\n record.removes.push(() => {\r\n provider.remove(key);\r\n });\r\n }\r\n\r\n this.changesets.push(record);\r\n this.nodes.all.forEach((node) => {\r\n if (target.match(node)) {\r\n let remove: RemoveChangeset = () => {};\r\n if (attributes.properties) {\r\n remove = node.writeProperties(attributes.properties, options, removable);\r\n }\r\n if (attributes.context) {\r\n remove = node.writeContext(attributes.context, options, removable);\r\n }\r\n if (attributes.layout) {\r\n remove = node.writeContext(attributes.layout, options, removable);\r\n }\r\n record.removes.push(remove);\r\n }\r\n });\r\n return () => {\r\n if (removable) {\r\n record.removes.forEach((remove) => remove());\r\n const indexToRemove = this.changesets.indexOf(record);\r\n if (indexToRemove > -1) {\r\n this.changesets.splice(indexToRemove, 1);\r\n }\r\n }\r\n };\r\n }\r\n\r\n addComponentHandler(definitionType: string, fn: CustomHandlerCallback) {\r\n this.customComponentHandler.add(definitionType, fn);\r\n }\r\n\r\n getComponentHandler(definitionType: string) {\r\n return this.customComponentHandler.get(definitionType);\r\n }\r\n\r\n dispose() {\r\n this.subscriptions.forEach((sub) => sub());\r\n }\r\n}\r\n","import { Logger } from '@telia-ace/widget-utilities';\r\nimport { EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { Breakpoints, ComponentSettings, ViewDefinition, WidgetSettings } from '../types';\r\nimport {\r\n ComponentNode,\r\n ComponentNodeContext,\r\n ComponentNodeLayout,\r\n ComponentNodeProperties,\r\n} from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\n\r\ntype ComponentReference = string | [string, ...ComponentReferenceOverride[]];\r\n\r\ntype ComponentReferenceOverride = {\r\n breakpoints?: Breakpoints;\r\n tags?: string[];\r\n context?: ComponentNodeContext;\r\n properties?: ComponentNodeProperties;\r\n layout?: ComponentNodeLayout;\r\n};\r\n\r\nexport type NormalizedComponentReference = {\r\n definitionId: string;\r\n overrides: ComponentReferenceOverride[];\r\n};\r\n\r\nexport const normalizeReference = (reference: ComponentReference): NormalizedComponentReference => {\r\n if (Array.isArray(reference)) {\r\n const [definitionId, ...overrides] = reference;\r\n return {\r\n definitionId,\r\n overrides,\r\n };\r\n }\r\n return {\r\n definitionId: reference,\r\n overrides: [],\r\n };\r\n};\r\n\r\nexport type ComponentHandlerOptions = {\r\n platform: ComponentPlatform;\r\n node: ComponentNode;\r\n references: ComponentReference[];\r\n definitions: { [name: string]: ComponentSettings };\r\n views: { [key: string]: ViewDefinition };\r\n branch?: string;\r\n};\r\n\r\nexport const createChildren = (\r\n platform: ComponentPlatform,\r\n node: ComponentNode,\r\n references: ComponentReference[],\r\n definitions: { [name: string]: ComponentSettings },\r\n views: { [key: string]: ViewDefinition },\r\n branch?: string\r\n) => {\r\n references.forEach((ref) => {\r\n const childRef = normalizeReference(ref);\r\n const childDef = definitions[childRef.definitionId];\r\n if (childRef.definitionId === 'view') {\r\n const viewNode = platform.createNode('view');\r\n viewNode.name = 'view';\r\n Object.keys(views).forEach((key) => {\r\n const viewDef = views[key];\r\n createChildren(platform, viewNode, [viewDef.entry], definitions, views, key);\r\n });\r\n node.appendChild(viewNode);\r\n\r\n childRef.overrides.forEach((override) => {\r\n if (override.properties) {\r\n viewNode.writeProperties(override.properties, {\r\n breakpoints: override.breakpoints,\r\n });\r\n }\r\n if (override.context) {\r\n viewNode.writeContext(override.context, { breakpoints: override.breakpoints });\r\n }\r\n if (override.layout) {\r\n viewNode.writeLayout(override.layout, { breakpoints: override.breakpoints });\r\n }\r\n });\r\n } else if (platform.getComponentHandler(childDef.type)) {\r\n const handle = platform.getComponentHandler(childDef.type);\r\n if (handle) {\r\n handle(childRef, {\r\n platform,\r\n node,\r\n references,\r\n definitions,\r\n views,\r\n branch,\r\n });\r\n }\r\n } else {\r\n const childDef = definitions[childRef.definitionId];\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (!childDef) {\r\n Logger.error(\r\n `No definition found for component type '${childRef.definitionId}'.`\r\n );\r\n return;\r\n }\r\n }\r\n const childNode = platform.createNode(childDef.type);\r\n childNode.name = childRef.definitionId;\r\n childNode.tags = childDef.tags || [];\r\n if (childDef.properties) {\r\n childNode.writeProperties(childDef.properties);\r\n }\r\n if (childDef.context) {\r\n childNode.writeContext(childDef.context);\r\n }\r\n if (childDef.layout) {\r\n childNode.writeLayout(childDef.layout);\r\n }\r\n node.appendChild(childNode, branch);\r\n\r\n childRef.overrides.forEach((override) => {\r\n const options = { breakpoints: override.breakpoints };\r\n if (override.properties) {\r\n childNode.writeProperties(override.properties, options);\r\n }\r\n if (override.context) {\r\n childNode.writeContext(override.context, options);\r\n }\r\n if (override.layout) {\r\n childNode.writeLayout(override.layout, options);\r\n }\r\n });\r\n\r\n if (childDef.children) {\r\n createChildren(platform, childNode, childDef.children, definitions, views);\r\n }\r\n }\r\n });\r\n};\r\n\r\nexport const createComponentModel = (\r\n platform: ComponentPlatform,\r\n settings: WidgetSettings\r\n): EventSubscriptionCancellation => {\r\n const { entry, components, breakpoints, views } = settings;\r\n const subscriptions: EventSubscriptionCancellation[] = [];\r\n\r\n Object.keys(breakpoints).forEach((name) => {\r\n const query = breakpoints[name];\r\n const list = window.matchMedia(query);\r\n if (list.matches) {\r\n platform.breakpoints.push(name);\r\n }\r\n const listener = (event: MediaQueryListEvent) => {\r\n if (event.matches) {\r\n platform.addBreakpoint(name);\r\n } else {\r\n platform.removeBreakpoint(name);\r\n }\r\n };\r\n list.addListener(listener);\r\n subscriptions.push(() => list.removeListener(listener));\r\n });\r\n\r\n createChildren(platform, platform.nodes.root, [entry], components, views);\r\n\r\n return () =>\r\n subscriptions.forEach((sub) => {\r\n sub();\r\n });\r\n};\r\n","import { ComponentNode } from './component-node';\r\n\r\nexport type ComponentDescriptor = {\r\n id: string;\r\n type?: string;\r\n name?: string;\r\n branch: string;\r\n};\r\n\r\nexport const asDescriptor = (node: ComponentNode, branch?: string): ComponentDescriptor => {\r\n return {\r\n id: node.id,\r\n type: node.type,\r\n name: node.name,\r\n branch: branch || 'default',\r\n };\r\n};\r\n","import { uuid } from '@telia-ace/widget-utilities';\r\nimport { Container, EventSubscriptionCancellation } from '@webprovisions/platform';\r\nimport { ComponentNodeController } from './component-controller';\r\nimport { ComponentNode } from './component-node';\r\nimport { ComponentPlatform } from './component-platform';\r\nimport { ComponentQuery } from './component-query';\r\n\r\nexport type ExtendComponentHandler = (controller: ComponentNodeController) => any;\r\n\r\nexport type ExtendComponentOptions = {\r\n reuseController?: boolean;\r\n};\r\n\r\nexport const extendComponent = (\r\n container: Container,\r\n typeOrQuery: string | ComponentQuery,\r\n handler: ExtendComponentHandler,\r\n ns: string = uuid(),\r\n options: ExtendComponentOptions = {}\r\n): Promise<void> => {\r\n return container.getAsync('components').then((components: ComponentPlatform) => {\r\n let target: ComponentQuery;\r\n if (typeof typeOrQuery === 'string') {\r\n const collection = new ComponentQuery(components);\r\n collection.ofType(typeOrQuery);\r\n target = collection;\r\n } else {\r\n target = typeOrQuery;\r\n }\r\n\r\n const managedInstances: {\r\n [instanceId: string]: {\r\n dispose: EventSubscriptionCancellation;\r\n controller: ComponentNodeController;\r\n };\r\n } = {};\r\n\r\n const getOrCreateController = (node: ComponentNode): Promise<ComponentNodeController> => {\r\n const existing = managedInstances[node.id];\r\n if (existing) {\r\n return Promise.resolve(existing.controller);\r\n }\r\n return ComponentPlatform.getInstance(container).then((platform) => {\r\n return new ComponentNodeController(platform, node, ns);\r\n });\r\n };\r\n\r\n components.events.subscribe(\r\n 'components:node-enter',\r\n (event, { node }: { node: ComponentNode }) => {\r\n if (target.match(node)) {\r\n getOrCreateController(node).then((controller) => {\r\n Promise.resolve(handler(controller)).then((dispose) => {\r\n managedInstances[node.id] = {\r\n dispose,\r\n controller,\r\n };\r\n });\r\n });\r\n }\r\n }\r\n );\r\n components.events.subscribe(\r\n 'components:node-exit',\r\n (event, { node }: { node: ComponentNode }) => {\r\n const instance = managedInstances[node.id];\r\n if (instance) {\r\n instance.dispose && instance.dispose();\r\n if (!options.reuseController) {\r\n instance.controller.dispose();\r\n delete managedInstances[node.id];\r\n }\r\n }\r\n }\r\n );\r\n });\r\n};\r\n","import { Logger } from '@telia-ace/widget-utilities';\r\nimport {\r\n Container,\r\n EventManager,\r\n EventSubscriptionCancellation,\r\n WidgetType,\r\n} from '@webprovisions/platform';\r\n\r\nexport type ReactComponent = any | null;\r\n\r\nexport default class ComponentResolver {\r\n aliases: Map<string, string> = new Map();\r\n components: Map<string, any> = new Map();\r\n events: EventManager;\r\n logger = new Logger();\r\n\r\n constructor(container: Container) {\r\n const { events }: WidgetType = container.get('$widget');\r\n this.events = events;\r\n }\r\n\r\n getComponent(key: string): ReactComponent {\r\n const alias = this.aliases.get(key);\r\n const component = this.components.get(alias || key) || null;\r\n\r\n if (process.env.NODE_ENV !== 'production') {\r\n if (!component) {\r\n this.logger.warn(\r\n alias || key,\r\n `Unable to resolve component: \"${\r\n alias || key\r\n }\". You most likely forgot to register the required plugin for: ${\r\n alias || key\r\n }.`\r\n );\r\n }\r\n }\r\n\r\n return component;\r\n }\r\n\r\n registerComponent(key: string, component: ReactComponent): EventSubscriptionCancellation {\r\n this.components.set(key, component);\r\n\r\n this.events.dispatch('component-resolver:resolve', key);\r\n\r\n return () => {\r\n this.components.delete(key);\r\n };\r\n }\r\n\r\n registerResolver(\r\n key: string,\r\n fn: (component: ReactComponent) => void\r\n ): EventSubscriptionCancellation {\r\n return this.events.subscribe('component-resolver:resolve', (e, data: string) => {\r\n if (data === key) {\r\n const component = this.getComponent(key);\r\n fn(component);\r\n }\r\n });\r\n }\r\n\r\n registerAlias(alias: string, key: string): EventSubscriptionCancellation {\r\n this.aliases.set(alias, key);\r\n\r\n this.events.dispatch('component-resolver:resolve', alias);\r\n\r\n return () => {\r\n this.aliases.delete(alias);\r\n };\r\n }\r\n}\r\n","import { ComponentNodeLayout } from '../component-platform';\r\n\r\nexport type ComponentSettings = {\r\n type: string;\r\n context?: Context;\r\n properties?: Properties;\r\n layout?: ComponentNodeLayout;\r\n tags?: string[];\r\n children?: ComponentReference[];\r\n};\r\n\r\nenum HistoryMode {\r\n scopedHash = 'scopedHash',\r\n hash = 'hash',\r\n browser = 'browser',\r\n memory = 'memory',\r\n}\r\n\r\nexport type RoutingSettings = {\r\n initialPath: string;\r\n mode: HistoryMode;\r\n basePath?: string;\r\n};\r\n\r\nexport type ComponentReference = string | [string, ...ComponentReferenceOverride[]];\r\n\r\nexport type Properties = { [key: string]: any };\r\n\r\nexport type Context = { [key: string]: any };\r\n\r\nexport type ViewDefinition = {\r\n path: string | string[];\r\n entry: ComponentReference;\r\n};\r\n\r\nexport type Breakpoints = 'all' | string[];\r\n\r\nexport type ComponentReferenceOverride = {\r\n breakpoints?: Breakpoints;\r\n size?: number | 'full' | 'none';\r\n indent?: number;\r\n tags?: string[];\r\n context?: Context;\r\n properties?: Properties;\r\n};\r\n\r\nexport type ComponentDefinitionMap = {\r\n [name: string]: ComponentSettings;\r\n};\r\n\r\nexport type WidgetSettings = {\r\n data: { projection: string; site?: 'current' | 'referrer'; forceHttps?: boolean };\r\n components: ComponentDefinitionMap;\r\n entry: ComponentReference;\r\n breakpoints: { [name: string]: string };\r\n routing: RoutingSettings;\r\n views: { [name: string]: ViewDefinition };\r\n integrationResources: { path: string; mediaQueriesSupported: boolean }[];\r\n trigger?: { symbol?: Symbol; label?: string; action?: string };\r\n activate?: boolean | null;\r\n plugins?: { [key: string]: any };\r\n};\r\n\r\nexport type MinMax = {\r\n min: string;\r\n max: string;\r\n};\r\n\r\ntype Symbol = {\r\n type: 'Uri' | 'Svg' | 'FontAwesome' | 'Text' | string;\r\n content: string;\r\n};\r\n\r\nexport enum WidgetRenderState {\r\n open = 'open',\r\n closed = 'closed',\r\n hidden = 'hidden',\r\n}\r\n"],"names":["ActionResolver","container","__publicField","events","target","action","value","origin","fn","e","createEventSubscriber","subs","type","listener","sub","ComponentQuery","platform","rules","node","rule","id","AbstractComponentController","ComponentNodeController","ns","ActionsController","subscribe","unsubscribe","updated","properties","event","options","context","layout","clearOnDispose","remove","executeActionListeners","listeners","data","controller","stack","dispatch","globalOptions","cancelled","handler","next","result","__spreadProps","__spreadValues","key","subscription","index","instances","output","handlers","matchedInstances","instance","watchers","watcher","input","handlerResponse","parsedKey","parsedNs","sections","componentConfigurationApi","createConfigurationApi","builder","config","ComponentNode","uuid","viewOutletContainer","element","mountedNodes","Logger","branch","removable","changeset","indexToRemove","children","acc","i","traverseComponentsRecursive","nodes","switches","y","traverseComponents","root","findVisibleComponents","findComponent","matched","ComponentNodeCollection","query","member","CustomComponentHandler","name","calculateNodeIndex","currentNode","sortQueue","queue","a","b","isObject","item","mergeDeep","sources","source","matchesBreakpoint","b1","b2","createStateProcessor","callback","nodeQueue","optionsQueue","timeout","flush","processHistory","sortedQueue","processNode","history","processContext","processProperties","processLayout","_a","propertyResolvers","layoutResolvers","contextResolvers","change","resolver","childOptions","child","schedule","summary","ComponentPlatform","widget","providers","report","record","removes","parentNode","providerName","attributes","provider","definitionType","normalizeReference","reference","definitionId","overrides","createChildren","references","definitions","views","ref","childRef","childDef","viewNode","viewDef","override","handle","childNode","createComponentModel","settings","entry","components","breakpoints","subscriptions","list","asDescriptor","extendComponent","typeOrQuery","collection","managedInstances","getOrCreateController","existing","dispose","ComponentResolver","alias","component","WidgetRenderState"],"mappings":";;;;;;;;;;;;;;;AASA,MAAqBA,GAAe;AAAA,EAGhC,YAAYC,GAAsB;AAF1B,IAAAC,EAAA;AAGJ,UAAM,EAAE,QAAAC,EAAmB,IAAAF,EAAU,IAAI,SAAS;AAC7C,SAAA,SAASE,EAAO,YAAY,IAAI;AAAA,EACzC;AAAA,EAEA,OAAOC,GAAgBC,GAAgBC,GAAkB;AAChD,SAAA,OAAO,SAAS,eAAe,EAAE,QAAAD,GAAQ,OAAAC,GAAO,QAAAF,KAAU,EAAE,SAAS,GAAM,CAAA;AAAA,EACpF;AAAA,EAEA,UAAUG,GAAgBC,GAA2C;AACjE,WAAO,KAAK,OAAO;AAAA,MACf;AAAA,MACA,CAACC,GAAG,EAAE,QAAAJ,GAAQ,OAAAC,GAAO,QAAAF,EAAa,MAAAG,MAAWH,KAAUI,EAAGD,GAAQF,GAAQC,CAAK;AAAA,IAAA;AAAA,EAEvF;AACJ;ACfa,MAAAI,IAAwB,CACjCP,MACqD;AACrD,QAAMQ,IAAwC,CAAA;AAMvC,SAAA;AAAA,IAJW,CAACC,GAAcC,MAA4B;AACzD,MAAAF,EAAK,KAAKR,EAAO,UAAUS,GAAMC,CAAQ,CAAC;AAAA,IAAA;AAAA,IAK1C,MAAM;AACG,MAAAF,EAAA,QAAQ,CAACG,MAAQ;AACd,QAAAA;MAAA,CACP;AAAA,IACL;AAAA,EAAA;AAER;ACpBO,MAAMC,EAAe;AAAA,EACxB,YAAoBC,GAAoCC,IAA8B,IAAI;AAAtE,SAAA,WAAAD,GAAoC,KAAA,QAAAC;AAAA,EAAmC;AAAA,EAE3F,MAAMC,GAAqB;AACvB,WAAO,KAAK,MAAM,MAAM,CAACC,MACjB,EAAAA,EAAK,MAAMA,EAAK,OAAOD,EAAK,MAG5BC,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@@
1
1
  export declare type Theme = {
2
2
  gap: string;
3
3
  accessibility: {
4
- isTabbing: boolean;
5
4
  border: string;
6
5
  colors: {
7
6
  inactiveText: string;
@@ -50,5 +49,4 @@ export declare type Theme = {
50
49
  export declare type ModeWrapper = React.FC<{
51
50
  className: string;
52
51
  route: string;
53
- isTabbing: boolean;
54
52
  }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-core",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
4
4
  "description": "Core framework for ACE widgets.",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "author": "Telia Company AB",
@@ -8,6 +8,7 @@
8
8
  "telia"
9
9
  ],
10
10
  "main": "dist/index.js",
11
+ "sourceMain": "src/index.ts",
11
12
  "type": "module",
12
13
  "types": "dist/index.d.ts",
13
14
  "files": [
@@ -21,14 +22,13 @@
21
22
  "scripts": {
22
23
  "clean": "rimraf ./dist",
23
24
  "precompile": "tsc -emitDeclarationOnly",
24
- "compile": "vite build",
25
- "postcompile": "node scripts/print-version.js"
25
+ "compile": "vite build"
26
26
  },
27
27
  "sideEffects": false,
28
28
  "dependencies": {
29
- "@telia-ace/widget-utilities": "^1.0.3",
29
+ "@telia-ace/widget-utilities": "^1.0.4",
30
30
  "@webprovisions/bootstrapping": "^1.0.12",
31
31
  "@webprovisions/platform": "^1.1.2"
32
32
  },
33
- "gitHead": "e9e22ff408d32106cc60212d14fb1ff63dd5c1e1"
33
+ "gitHead": "9cb0d80e6c65317a2e27a381ebe24fd0662f33e8"
34
34
  }