@player-ui/player 0.11.1-next.0 → 0.11.2-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -6,12 +6,12 @@
6
6
  "types"
7
7
  ],
8
8
  "name": "@player-ui/player",
9
- "version": "0.11.1-next.0",
9
+ "version": "0.11.2-next.0",
10
10
  "main": "dist/cjs/index.cjs",
11
11
  "dependencies": {
12
- "@player-ui/partial-match-registry": "0.11.1-next.0",
13
- "@player-ui/make-flow": "0.11.1-next.0",
14
- "@player-ui/types": "0.11.1-next.0",
12
+ "@player-ui/partial-match-registry": "0.11.2-next.0",
13
+ "@player-ui/make-flow": "0.11.2-next.0",
14
+ "@player-ui/types": "0.11.2-next.0",
15
15
  "@types/dlv": "^1.1.4",
16
16
  "dequal": "^2.0.2",
17
17
  "dlv": "^1.1.3",
@@ -1,5 +1,5 @@
1
- import { SyncWaterfallHook, SyncHook } from "tapable-ts";
2
- import { setIn, addLast, clone } from "timm";
1
+ import { SyncHook, SyncWaterfallHook } from "tapable-ts";
2
+ import { addLast, clone, setIn } from "timm";
3
3
  import dlv from "dlv";
4
4
  import { dequal } from "dequal";
5
5
  import type { BindingInstance, BindingLike } from "../../binding";
@@ -10,13 +10,8 @@ import type {
10
10
  } from "../../data";
11
11
  import { DependencyModel, withParser } from "../../data";
12
12
  import type { Logger } from "../../logger";
13
- import type { Node } from "../parser";
14
- import { NodeType } from "../parser";
15
- import {
16
- caresAboutDataChanges,
17
- toNodeResolveOptions,
18
- unpackAndPush,
19
- } from "./utils";
13
+ import { Node, NodeType } from "../parser";
14
+ import { caresAboutDataChanges, toNodeResolveOptions } from "./utils";
20
15
  import type { Resolve } from "./types";
21
16
  import { getNodeID } from "../parser/utils";
22
17
 
@@ -276,6 +271,13 @@ export class Resolver {
276
271
  type: NodeType.Empty,
277
272
  };
278
273
 
274
+ const isNestedMultiNodeWithAsync =
275
+ resolvedAST.type === NodeType.MultiNode &&
276
+ partiallyResolvedParent?.parent?.parent?.type === NodeType.MultiNode &&
277
+ partiallyResolvedParent.parent.type === NodeType.Value &&
278
+ resolvedAST.parent?.type === NodeType.Asset &&
279
+ resolvedAST.parent.value.id.includes("async");
280
+
279
281
  const isNestedMultiNode =
280
282
  resolvedAST.type === NodeType.MultiNode &&
281
283
  partiallyResolvedParent?.parent?.type === NodeType.MultiNode &&
@@ -334,7 +336,11 @@ export class Resolver {
334
336
  return update;
335
337
  }
336
338
 
337
- resolvedAST.parent = partiallyResolvedParent;
339
+ if (isNestedMultiNodeWithAsync) {
340
+ resolvedAST.parent = partiallyResolvedParent.parent;
341
+ } else {
342
+ resolvedAST.parent = partiallyResolvedParent;
343
+ }
338
344
 
339
345
  resolveOptions.node = resolvedAST;
340
346
 
@@ -399,6 +405,10 @@ export class Resolver {
399
405
  ? partiallyResolvedParent?.parent
400
406
  : node;
401
407
 
408
+ const hasAsync = resolvedAST.values
409
+ .map((value, index) => (value.type === NodeType.Async ? index : -1))
410
+ .filter((index) => index !== -1);
411
+
402
412
  const newValues = resolvedAST.values.map((mValue) => {
403
413
  const mTree = this.computeTree(
404
414
  mValue,
@@ -423,6 +433,7 @@ export class Resolver {
423
433
  mTree.value.asset &&
424
434
  Array.isArray(mTree.value.asset.values)
425
435
  ) {
436
+ // This flatten function only changed the values not node structure
426
437
  unpackAndPush(mTree.value, childValue);
427
438
  } else {
428
439
  childValue.push(mTree.value);
@@ -438,7 +449,16 @@ export class Resolver {
438
449
  return mTree.node;
439
450
  });
440
451
 
441
- resolvedAST.values = newValues;
452
+ if (hasAsync.length > 0) {
453
+ // this likely turned into a nested multinode, attempt to flatten in node structure
454
+ const copy = newValues;
455
+ hasAsync.forEach((index) => {
456
+ if (copy[index]) copy.splice(index, 1, ...unpackNode(copy[index]));
457
+ });
458
+ resolvedAST.values = copy;
459
+ } else {
460
+ resolvedAST.values = newValues;
461
+ }
442
462
  resolved = childValue;
443
463
  }
444
464
 
@@ -477,3 +497,40 @@ export class Resolver {
477
497
  return update;
478
498
  }
479
499
  }
500
+
501
+ /**
502
+ * helper function to flatten a potential nested array and combine with initial array
503
+ */
504
+ function unpackAndPush(item: any | any[], initial: any[]): void {
505
+ if (item.asset.values && Array.isArray(item.asset.values)) {
506
+ item.asset.values.forEach((i: any) => {
507
+ unpackAndPush(i, initial);
508
+ });
509
+ } else {
510
+ initial.push(item);
511
+ }
512
+ }
513
+
514
+ function unpackNode(item: Node.Node) {
515
+ const unpacked: Node.Node[] = [];
516
+ if (
517
+ "children" in item &&
518
+ item.children?.[0]?.value.type === NodeType.Asset &&
519
+ (item.children?.[0]?.value as Node.Asset).children
520
+ ) {
521
+ if (
522
+ (item.children?.[0]?.value as Node.Asset).children?.[0]?.value.type ===
523
+ NodeType.MultiNode
524
+ ) {
525
+ (
526
+ (item.children?.[0]?.value as Node.Asset).children?.[0]
527
+ ?.value as Node.MultiNode
528
+ ).values.forEach((value) => {
529
+ unpacked.push(value);
530
+ });
531
+ }
532
+ } else {
533
+ unpacked.push(item);
534
+ }
535
+ return unpacked;
536
+ }
@@ -55,16 +55,3 @@ export function toNodeResolveOptions(
55
55
  resolverOptions.evaluator.evaluate(exp, resolverOptions),
56
56
  };
57
57
  }
58
-
59
- /**
60
- * helper function to flatten a potential nested array and combine with initial array
61
- */
62
- export function unpackAndPush(item: any | any[], initial: any[]) {
63
- if (item.asset.values && Array.isArray(item.asset.values)) {
64
- item.asset.values.forEach((i: any) => {
65
- unpackAndPush(i, initial);
66
- });
67
- } else {
68
- initial.push(item);
69
- }
70
- }
@@ -1,6 +1,6 @@
1
- import { SyncWaterfallHook, SyncHook } from "tapable-ts";
1
+ import { SyncHook, SyncWaterfallHook } from "tapable-ts";
2
2
  import type { BindingInstance } from "../../binding";
3
- import type { Node } from "../parser";
3
+ import { Node } from "../parser";
4
4
  import type { Resolve } from "./types";
5
5
  export * from "./types";
6
6
  export * from "./utils";
@@ -4,8 +4,4 @@ import type { Resolve } from "./types";
4
4
  export declare function caresAboutDataChanges(dataChanges?: Set<BindingInstance>, dependencies?: Set<BindingInstance>): boolean;
5
5
  /** Convert the options object for a resolver to one for a node */
6
6
  export declare function toNodeResolveOptions(resolverOptions: Resolve.ResolverOptions): Resolve.NodeResolveOptions;
7
- /**
8
- * helper function to flatten a potential nested array and combine with initial array
9
- */
10
- export declare function unpackAndPush(item: any | any[], initial: any[]): void;
11
7
  //# sourceMappingURL=utils.d.ts.map