@telia-ace/widget-core 1.1.2-rc.1 → 1.1.2-rc.3

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.
@@ -2,7 +2,7 @@ export { ActionsController } from './actions-controller';
2
2
  export type { WatchActionDelegate } from './actions-controller';
3
3
  export type { ChangesetProvider } from './changeset-provider';
4
4
  export { default as componentConfigurationApi } from './component-configuration-api';
5
- export { AbstractComponentController, ComponentNodeController } from './component-controller';
5
+ export { AbstractComponentController, ComponentNodeController, } from './component-controller';
6
6
  export { ComponentNode } from './component-node';
7
7
  export type { ChangesetOptions, ComponentNodeAttributes, ComponentNodeContext, ComponentNodeLayout, ComponentNodeProperties, ComponentNodeSettings, Size, } from './component-node';
8
8
  export { ComponentPlatform } from './component-platform';
@@ -14,5 +14,5 @@ export type { ComponentHandlerOptions, NormalizedComponentReference, } from './c
14
14
  export { asDescriptor } from './descriptor';
15
15
  export type { ComponentDescriptor } from './descriptor';
16
16
  export { extendComponent } from './extend-component';
17
- export type { ExtendComponentHandler, ExtendComponentOptions } from './extend-component';
18
- export { findComponent, findVisibleComponents, traverseComponents } from './queries';
17
+ export type { ExtendComponentHandler, ExtendComponentOptions, } from './extend-component';
18
+ export { findComponent, findVisibleComponents, traverseComponents, } from './queries';
package/index.mjs CHANGED
@@ -7,7 +7,11 @@ class at {
7
7
  this.events = e.createChild(this);
8
8
  }
9
9
  action(t, e, s) {
10
- this.events.dispatch("data:action", { action: e, value: s, target: t }, { bubbles: !0 });
10
+ this.events.dispatch(
11
+ "data:action",
12
+ { action: e, value: s, target: t },
13
+ { bubbles: !0 }
14
+ );
11
15
  }
12
16
  subscribe(t, e) {
13
17
  return this.events.subscribe(
@@ -27,7 +31,9 @@ const pt = (n, t, e = {}) => L(
27
31
  if (B(r)(n))
28
32
  return i[1];
29
33
  }).filter((i) => !!i);
30
- return (t ? [t] : []).concat(s);
34
+ return (t ? [t] : []).concat(
35
+ s
36
+ );
31
37
  },
32
38
  e.rootElementResolver || (() => document.body)
33
39
  ), F = (n) => {
@@ -67,7 +73,9 @@ class S {
67
73
  new N(t).withId(e.id),
68
74
  s
69
75
  );
70
- const [i, r] = F(this.platform.events);
76
+ const [i, r] = F(
77
+ this.platform.events
78
+ );
71
79
  this.subscribe = i, this.unsubscribe = r;
72
80
  }
73
81
  properties(t) {
@@ -140,11 +148,17 @@ const K = (n, t, e) => {
140
148
  const s = n.concat(), i = (r, c, a) => {
141
149
  let u = !0;
142
150
  if (s.length) {
143
- const h = s.shift(), o = (p, l) => (u = !1, i(p, Object.assign({}, c, l), a));
144
- return Promise.resolve(h(r, o, a)).then((p) => ({
145
- ...p,
146
- cancelled: u
147
- }));
151
+ const h = s.shift(), o = (p, l) => (u = !1, i(
152
+ p,
153
+ Object.assign({}, c, l),
154
+ a
155
+ ));
156
+ return Promise.resolve(h(r, o, a)).then(
157
+ (p) => ({
158
+ ...p,
159
+ cancelled: u
160
+ })
161
+ );
148
162
  }
149
163
  return Promise.resolve({ data: r, cancelled: !1, options: c });
150
164
  };
@@ -179,7 +193,9 @@ class P {
179
193
  r.map((c) => {
180
194
  const a = s.filter(
181
195
  (h) => c.target.match(h) && this.target.match(h)
182
- ), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some((o) => h.target.match(o))).map((h) => h.fn);
196
+ ), u = this.platform.actionsState.watchers.filter((h) => h.key === t && (!h.ns || !this.ns || h.ns === this.ns) && a.some(
197
+ (o) => h.target.match(o)
198
+ )).map((h) => h.fn);
183
199
  return Promise.all(
184
200
  a.map((h) => {
185
201
  const o = new S(
@@ -187,14 +203,16 @@ class P {
187
203
  h,
188
204
  this.ns
189
205
  );
190
- return K(u, e, o).then((p) => {
191
- const { data: l = {}, options: d, cancelled: b } = p;
192
- return Promise.resolve(
193
- b ? {} : c.fn(l, d, o)
194
- ).then((g) => {
195
- i[h.id] = g;
196
- });
197
- });
206
+ return K(u, e, o).then(
207
+ (p) => {
208
+ const { data: l = {}, options: d, cancelled: b } = p;
209
+ return Promise.resolve(
210
+ b ? {} : c.fn(l, d, o)
211
+ ).then((g) => {
212
+ i[h.id] = g;
213
+ });
214
+ }
215
+ );
198
216
  })
199
217
  );
200
218
  })
@@ -223,11 +241,14 @@ class P {
223
241
  }
224
242
  const ut = M((n) => {
225
243
  n.createCommand("components", (t) => (e) => {
226
- t.events.subscribeOnce("components:platform-created", (s, { platform: i }) => {
227
- e.handlers && e.handlers.forEach(([r, c]) => {
228
- i.addComponentHandler(r, c);
229
- });
230
- });
244
+ t.events.subscribeOnce(
245
+ "components:platform-created",
246
+ (s, { platform: i }) => {
247
+ e.handlers && e.handlers.forEach(([r, c]) => {
248
+ i.addComponentHandler(r, c);
249
+ });
250
+ }
251
+ );
231
252
  });
232
253
  });
233
254
  class I {
@@ -345,14 +366,23 @@ const D = (n, t, e) => {
345
366
  };
346
367
  class W {
347
368
  constructor(t, e, s) {
348
- this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe("components:node-appended", (i, r) => {
349
- this.all.push(r.node), this.visible = x(t, e);
350
- }), s.subscribe("components:node-removed", (i, r) => {
351
- let c = this.all.indexOf(r.node);
352
- c > -1 && this.all.splice(c, 1), c = this.visible.indexOf(r.node), c > -1 && this.visible.splice(c, 1), this.visible = x(t, e);
353
- }), s.subscribe("components:node-switched", (i, r) => {
354
- this.visible = x(t, e);
355
- });
369
+ this.root = t, this.switches = e, this.all = [], this.visible = [], this.detached = [], s.subscribe(
370
+ "components:node-appended",
371
+ (i, r) => {
372
+ this.all.push(r.node), this.visible = x(t, e);
373
+ }
374
+ ), s.subscribe(
375
+ "components:node-removed",
376
+ (i, r) => {
377
+ let c = this.all.indexOf(r.node);
378
+ c > -1 && this.all.splice(c, 1), c = this.visible.indexOf(r.node), c > -1 && this.visible.splice(c, 1), this.visible = x(t, e);
379
+ }
380
+ ), s.subscribe(
381
+ "components:node-switched",
382
+ (i, r) => {
383
+ this.visible = x(t, e);
384
+ }
385
+ );
356
386
  }
357
387
  query(t = {}) {
358
388
  const e = [];
@@ -380,7 +410,9 @@ const J = (n) => {
380
410
  for (; t.parent; )
381
411
  e = e + 1, t = t.parent;
382
412
  return e;
383
- }, X = (n) => n.map(([e, s]) => [J(e), e, s]).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), w = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), v = (n, ...t) => {
413
+ }, X = (n) => n.map(
414
+ ([e, s]) => [J(e), e, s]
415
+ ).sort(([e], [s]) => e - s).map(([, e, s]) => [e, s]), w = (n) => n instanceof Date ? !1 : n && typeof n == "object" && !Array.isArray(n), v = (n, ...t) => {
384
416
  if (!t.length)
385
417
  return n;
386
418
  const e = t.shift();
@@ -392,22 +424,32 @@ const J = (n) => {
392
424
  let e = [], s = [], i;
393
425
  const r = () => {
394
426
  process.env.NODE_ENV !== "production" && console.time("state-processor.flush");
395
- const a = /* @__PURE__ */ new Map(), u = X(e.map((o, p) => [o, s[p]])), h = (o, p) => {
427
+ const a = /* @__PURE__ */ new Map(), u = X(
428
+ e.map((o, p) => [o, s[p]])
429
+ ), h = (o, p) => {
396
430
  var T;
397
431
  const l = a.get(o) || {}, d = p.context && !l.context, b = p.properties && !l.properties, g = p.layout && !l.layout;
398
432
  a.set(o, {
399
433
  context: l.context || d,
400
434
  properties: l.properties || b,
401
435
  layout: l.layout || g
402
- }), b && (o.attributes.properties = {}), g && (o.attributes.layout = {}), d && (o.attributes.context = v({}, (T = o.parent) == null ? void 0 : T.attributes.context));
436
+ }), b && (o.attributes.properties = {}), g && (o.attributes.layout = {}), d && (o.attributes.context = v(
437
+ {},
438
+ (T = o.parent) == null ? void 0 : T.attributes.context
439
+ ));
403
440
  const $ = [], R = [], A = [];
404
441
  if (o.changesets.forEach((m) => {
405
442
  const [f, y] = m;
406
443
  Z(y.breakpoints, n.breakpoints) && (b && (typeof f.properties == "function" ? $.push(
407
444
  f.properties
408
- ) : v(o.attributes.properties, f.properties)), g && (typeof f.layout == "function" ? R.push(f.layout) : v(o.attributes.layout, f.layout)), d && (typeof f.context == "function" ? A.push(f.context) : v(o.attributes.context, f.context)));
445
+ ) : v(o.attributes.properties, f.properties)), g && (typeof f.layout == "function" ? R.push(f.layout) : v(o.attributes.layout, f.layout)), d && (typeof f.context == "function" ? A.push(
446
+ f.context
447
+ ) : v(o.attributes.context, f.context)));
409
448
  }), $.forEach((m) => {
410
- v(o.attributes.properties, m(o.attributes.properties));
449
+ v(
450
+ o.attributes.properties,
451
+ m(o.attributes.properties)
452
+ );
411
453
  }), R.forEach((m) => {
412
454
  v(o.attributes.layout, m(o.attributes.layout));
413
455
  }), A.forEach((m) => {
@@ -441,17 +483,24 @@ class et {
441
483
  this.providers = e, this.breakpoints = [], this.actionsState = { handlers: [], watchers: [] }, this.switches = {}, this.changesets = [], this.subscriptions = [], this.customComponentHandler = new Y(), this.events = t.events.createChild(this);
442
484
  const s = new I(this.events, "root");
443
485
  s.name = `root-${t.name}`, this.nodes = new W(s, this.switches, this.events);
444
- const i = this.processNode = tt(this, (r) => {
445
- const c = Array.from(r.keys());
446
- process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${c.length} node(s) processed:
486
+ const i = this.processNode = tt(
487
+ this,
488
+ (r) => {
489
+ const c = Array.from(r.keys());
490
+ process.env.NODE_ENV !== "production" && console.info(`STATE PROCESSOR: ${c.length} node(s) processed:
447
491
  ${c.map(
448
- (a) => `${a.name || "<no name>"} (${a.id})
492
+ (a) => `${a.name || "<no name>"} (${a.id})
449
493
  `
450
- )}`), c.forEach((a) => {
451
- const u = r.get(a);
452
- 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 });
453
- }), this.events.dispatch("components:component-model-initialized", {}, { bubbles: !0 });
454
- });
494
+ )}`), c.forEach((a) => {
495
+ const u = r.get(a);
496
+ 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 });
497
+ }), this.events.dispatch(
498
+ "components:component-model-initialized",
499
+ {},
500
+ { bubbles: !0 }
501
+ );
502
+ }
503
+ );
455
504
  Promise.all(
456
505
  Object.keys(e).map((r) => e[r].load(this))
457
506
  ), this.subscriptions.push(
@@ -501,19 +550,27 @@ ${c.map(
501
550
  }
502
551
  )
503
552
  ), this.subscriptions.push(
504
- this.events.subscribe("components:node-switched", (r, { node: c, branch: a }) => {
505
- i(c, {
506
- layout: !0,
507
- recursive: !0,
508
- properties: !0,
509
- context: !0
510
- });
511
- })
553
+ this.events.subscribe(
554
+ "components:node-switched",
555
+ (r, { node: c, branch: a }) => {
556
+ i(c, {
557
+ layout: !0,
558
+ recursive: !0,
559
+ properties: !0,
560
+ context: !0
561
+ });
562
+ }
563
+ )
512
564
  ), this.subscriptions.push(
513
- this.events.subscribe("components:node-removed", (r, { parentNode: c }) => {
514
- i(c, { properties: !0 });
515
- })
516
- ), this.events.parent && this.events.parent.dispatch("components:platform-created", { platform: this });
565
+ this.events.subscribe(
566
+ "components:node-removed",
567
+ (r, { parentNode: c }) => {
568
+ i(c, { properties: !0 });
569
+ }
570
+ )
571
+ ), this.events.parent && this.events.parent.dispatch("components:platform-created", {
572
+ platform: this
573
+ });
517
574
  }
518
575
  static getInstance(t) {
519
576
  return t.getAsync("components");
@@ -556,7 +613,13 @@ ${c.map(
556
613
  return new P(this, t, e);
557
614
  }
558
615
  write(t) {
559
- const { provider: e, target: s, attributes: i, options: r = {}, removable: c } = t, a = t.key || E(), h = { changeset: [i, r], target: s, removes: [] };
616
+ const {
617
+ provider: e,
618
+ target: s,
619
+ attributes: i,
620
+ options: r = {},
621
+ removable: c
622
+ } = t, a = t.key || E(), h = { changeset: [i, r], target: s, removes: [] };
560
623
  if (e) {
561
624
  const o = this.providers[e];
562
625
  o.write(a, s, i, r), h.removes.push(() => {
@@ -567,7 +630,11 @@ ${c.map(
567
630
  if (s.match(o)) {
568
631
  let p = () => {
569
632
  };
570
- i.properties && (p = o.writeProperties(i.properties, r, c)), i.context && (p = o.writeContext(i.context, r, c)), i.layout && (p = o.writeContext(i.layout, r, c)), h.removes.push(p);
633
+ i.properties && (p = o.writeProperties(
634
+ i.properties,
635
+ r,
636
+ c
637
+ )), i.context && (p = o.writeContext(i.context, r, c)), i.layout && (p = o.writeContext(i.layout, r, c)), h.removes.push(p);
571
638
  }
572
639
  }), () => {
573
640
  if (c) {
@@ -606,11 +673,22 @@ const st = (n) => {
606
673
  const h = n.createNode("view");
607
674
  h.name = "view", Object.keys(i).forEach((o) => {
608
675
  const p = i[o];
609
- C(n, h, [p.entry], s, i, o);
676
+ C(
677
+ n,
678
+ h,
679
+ [p.entry],
680
+ s,
681
+ i,
682
+ o
683
+ );
610
684
  }), t.appendChild(h), a.overrides.forEach((o) => {
611
685
  o.properties && h.writeProperties(o.properties, {
612
686
  breakpoints: o.breakpoints
613
- }), o.context && h.writeContext(o.context, { breakpoints: o.breakpoints }), o.layout && h.writeLayout(o.layout, { breakpoints: o.breakpoints });
687
+ }), o.context && h.writeContext(o.context, {
688
+ breakpoints: o.breakpoints
689
+ }), o.layout && h.writeLayout(o.layout, {
690
+ breakpoints: o.breakpoints
691
+ });
614
692
  });
615
693
  } else if (n.getComponentHandler(u.type)) {
616
694
  const h = n.getComponentHandler(u.type);
@@ -634,7 +712,13 @@ const st = (n) => {
634
712
  o.name = a.definitionId, o.tags = h.tags || [], h.properties && o.writeProperties(h.properties), h.context && o.writeContext(h.context), h.layout && o.writeLayout(h.layout), t.appendChild(o, r), a.overrides.forEach((p) => {
635
713
  const l = { breakpoints: p.breakpoints };
636
714
  p.properties && o.writeProperties(p.properties, l), p.context && o.writeContext(p.context, l), p.layout && o.writeLayout(p.layout, l);
637
- }), h.children && C(n, o, h.children, s, i);
715
+ }), h.children && C(
716
+ n,
717
+ o,
718
+ h.children,
719
+ s,
720
+ i
721
+ );
638
722
  }
639
723
  });
640
724
  }, lt = (n, t) => {
@@ -704,12 +788,15 @@ class mt {
704
788
  };
705
789
  }
706
790
  registerResolver(t, e) {
707
- return this.events.subscribe("component-resolver:resolve", (s, i) => {
708
- if (i === t) {
709
- const r = this.getComponent(t);
710
- e(r);
791
+ return this.events.subscribe(
792
+ "component-resolver:resolve",
793
+ (s, i) => {
794
+ if (i === t) {
795
+ const r = this.getComponent(t);
796
+ e(r);
797
+ }
711
798
  }
712
- });
799
+ );
713
800
  }
714
801
  registerAlias(t, e) {
715
802
  return this.aliases.set(t, e), this.events.dispatch("component-resolver:resolve", t), () => {
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@telia-ace/widget-core",
3
- "version": "1.1.2-rc.1",
3
+ "version": "1.1.2-rc.3",
4
4
  "dependencies": {
5
5
  "@webprovisions/platform": "^1.1.4",
6
6
  "@webprovisions/bootstrapping": "^1.0.14",
7
- "@telia-ace/widget-utilities": "^1.1.2-rc.1"
7
+ "@telia-ace/widget-utilities": "^1.1.2-rc.3"
8
8
  },
9
9
  "main": "./index.js",
10
10
  "module": "./index.mjs",