@player-ui/async-node-plugin 0.7.5--canary.443.15842 → 0.7.5-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.
@@ -1354,8 +1354,16 @@ var AsyncNodePlugin = function() {
1354
1354
  }
1355
1355
  return targetMap;
1356
1356
  };
1357
- var hasAsync = function hasAsync(obj) {
1358
- return Object.prototype.hasOwnProperty.call(obj, "async");
1357
+ var hasTemplateValues = function hasTemplateValues(obj, localKey) {
1358
+ return Object.hasOwnProperty.call(obj, "template") && Array.isArray(obj === null || obj === void 0 ? void 0 : obj.template) && obj.template.length && obj.template.find(function(tmpl) {
1359
+ return tmpl.output === localKey;
1360
+ });
1361
+ };
1362
+ var hasSwitchKey = function hasSwitchKey(localKey) {
1363
+ return localKey === "staticSwitch" || localKey === "dynamicSwitch";
1364
+ };
1365
+ var hasTemplateKey = function hasTemplateKey(localKey) {
1366
+ return localKey === "template";
1359
1367
  };
1360
1368
  var getNodeID = function getNodeID(node) {
1361
1369
  var _node_value;
@@ -1645,7 +1653,7 @@ var AsyncNodePlugin = function() {
1645
1653
  exports.merge = merge;
1646
1654
  exports.mergeDeep = mergeDeep;
1647
1655
  exports.mergeIn = mergeIn;
1648
- exports.omit = omit5;
1656
+ exports.omit = omit4;
1649
1657
  exports.addDefaults = addDefaults;
1650
1658
  exports.default = void 0;
1651
1659
  var INVALID_ARGS = "INVALID_ARGS";
@@ -1819,7 +1827,7 @@ var AsyncNodePlugin = function() {
1819
1827
  }
1820
1828
  return setIn8(a, path, nextVal);
1821
1829
  }
1822
- function omit5(obj, attrs) {
1830
+ function omit4(obj, attrs) {
1823
1831
  var omitList = Array.isArray(attrs) ? attrs : [
1824
1832
  attrs
1825
1833
  ];
@@ -1905,7 +1913,7 @@ var AsyncNodePlugin = function() {
1905
1913
  merge: merge,
1906
1914
  mergeDeep: mergeDeep,
1907
1915
  mergeIn: mergeIn,
1908
- omit: omit5,
1916
+ omit: omit4,
1909
1917
  addDefaults: addDefaults
1910
1918
  };
1911
1919
  var _default = timm;
@@ -2622,6 +2630,12 @@ var AsyncNodePlugin = function() {
2622
2630
  value: function clear() {
2623
2631
  this.store = createSortedArray();
2624
2632
  }
2633
+ },
2634
+ {
2635
+ /** Check if the registry is empty*/ key: "isRegistryEmpty",
2636
+ value: function isRegistryEmpty() {
2637
+ return this.store.array.length === 0;
2638
+ }
2625
2639
  }
2626
2640
  ]);
2627
2641
  return Registry;
@@ -4341,7 +4355,6 @@ var AsyncNodePlugin = function() {
4341
4355
  * If undefined, the original value is used.
4342
4356
  * If null, we ignore this node all together
4343
4357
  */ onCreateASTNode: new SyncWaterfallHook(),
4344
- determineNodeType: new SyncBailHook(),
4345
4358
  parseNode: new SyncBailHook()
4346
4359
  };
4347
4360
  }
@@ -4356,21 +4369,6 @@ var AsyncNodePlugin = function() {
4356
4369
  return viewNode;
4357
4370
  }
4358
4371
  },
4359
- {
4360
- key: "parseAsync",
4361
- value: function parseAsync(obj, type, options) {
4362
- var parsedAsync = this.parseObject((0, import_timm5.omit)(obj, "async"), type, options);
4363
- var parsedNodeId = getNodeID(parsedAsync);
4364
- if (parsedAsync !== null && parsedNodeId) {
4365
- return this.createASTNode({
4366
- id: parsedNodeId,
4367
- type: "async",
4368
- value: parsedAsync
4369
- }, obj);
4370
- }
4371
- return null;
4372
- }
4373
- },
4374
4372
  {
4375
4373
  key: "createASTNode",
4376
4374
  value: function createASTNode(node, value) {
@@ -4381,25 +4379,6 @@ var AsyncNodePlugin = function() {
4381
4379
  return tapped;
4382
4380
  }
4383
4381
  },
4384
- {
4385
- /**
4386
- * Checks if there are templated values in the object
4387
- *
4388
- * @param obj - The Parsed Object to check to see if we have a template array type for
4389
- * @param localKey - The key being checked
4390
- */ key: "hasTemplateValues",
4391
- value: function hasTemplateValues(obj, localKey) {
4392
- return Object.hasOwnProperty.call(obj, "template") && Array.isArray(obj === null || obj === void 0 ? void 0 : obj.template) && obj.template.length && obj.template.find(function(tmpl) {
4393
- return tmpl.output === localKey;
4394
- });
4395
- }
4396
- },
4397
- {
4398
- key: "hasSwitchKey",
4399
- value: function hasSwitchKey(localKey) {
4400
- return localKey === "staticSwitch";
4401
- }
4402
- },
4403
4382
  {
4404
4383
  key: "parseObject",
4405
4384
  value: function parseObject(obj) {
@@ -4407,12 +4386,9 @@ var AsyncNodePlugin = function() {
4407
4386
  templateDepth: 0
4408
4387
  };
4409
4388
  var _this = this;
4410
- var nodeType = this.hooks.determineNodeType.call(obj);
4411
- if (nodeType !== void 0) {
4412
- var parsedNode = this.hooks.parseNode.call(obj, type, options, nodeType);
4413
- if (parsedNode) {
4414
- return parsedNode;
4415
- }
4389
+ var parsedNode = this.hooks.parseNode.call(obj, type, options);
4390
+ if (parsedNode || parsedNode === null) {
4391
+ return parsedNode;
4416
4392
  }
4417
4393
  var parseLocalObject = function(currentValue, objToParse) {
4418
4394
  var path = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
@@ -4442,166 +4418,42 @@ var AsyncNodePlugin = function() {
4442
4418
  value: currentValue
4443
4419
  };
4444
4420
  var newValue = objEntries.reduce(function(accumulation, current) {
4445
- var children2 = accumulation.children, rest = _object_without_properties(accumulation, [
4446
- "children"
4447
- ]);
4421
+ var value2 = accumulation.value;
4422
+ var children2 = accumulation.children;
4448
4423
  var _current = _sliced_to_array(current, 2), localKey = _current[0], localValue = _current[1];
4449
- if (localKey === "asset" && typeof localValue === "object") {
4450
- var assetAST = _this.parseObject(localValue, "asset", options);
4451
- if (assetAST) {
4452
- return _object_spread_props(_object_spread({}, rest), {
4453
- children: _to_consumable_array(children2).concat([
4454
- {
4455
- path: _to_consumable_array(path).concat([
4456
- "asset"
4457
- ]),
4458
- value: assetAST
4459
- }
4460
- ])
4461
- });
4462
- }
4463
- } else if (_this.hooks.determineNodeType.call(localKey) === "template" && Array.isArray(localValue)) {
4464
- var templateChildren = localValue.map(function(template) {
4465
- var _options_templateDepth, _template_dynamic;
4466
- var templateAST = _this.hooks.onCreateASTNode.call({
4467
- type: "template",
4468
- depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
4469
- data: template.data,
4470
- template: template.value,
4471
- dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
4472
- }, template);
4473
- if ((templateAST === null || templateAST === void 0 ? void 0 : templateAST.type) === "multi-node") {
4474
- templateAST.values.forEach(function(v) {
4475
- v.parent = templateAST;
4476
- });
4477
- }
4478
- if (templateAST) {
4479
- return {
4480
- path: _to_consumable_array(path).concat([
4481
- template.output
4482
- ]),
4483
- value: templateAST
4484
- };
4485
- }
4486
- return;
4487
- }).filter(function(element) {
4488
- return !!element;
4489
- });
4490
- return _object_spread_props(_object_spread({}, rest), {
4491
- children: _to_consumable_array(children2).concat(_to_consumable_array(templateChildren))
4492
- });
4493
- } else if (localValue && _this.hooks.determineNodeType.call(localValue) === "switch" || _this.hasSwitchKey(localKey)) {
4494
- var _localSwitch_children;
4495
- var localSwitch = _this.hooks.parseNode.call(_this.hasSwitchKey(localKey) ? _define_property({}, localKey, localValue) : localValue, "value", options, "switch");
4496
- if (localSwitch && localSwitch.type === "value" && ((_localSwitch_children = localSwitch.children) === null || _localSwitch_children === void 0 ? void 0 : _localSwitch_children.length) === 1 && localSwitch.value === void 0) {
4497
- var firstChild = localSwitch.children[0];
4498
- return _object_spread_props(_object_spread({}, rest), {
4499
- children: _to_consumable_array(children2).concat([
4500
- {
4501
- path: _to_consumable_array(path).concat([
4502
- localKey
4503
- ], _to_consumable_array(firstChild.path)),
4504
- value: firstChild.value
4505
- }
4506
- ])
4507
- });
4508
- }
4509
- if (localSwitch) {
4510
- return _object_spread_props(_object_spread({}, rest), {
4511
- children: _to_consumable_array(children2).concat([
4512
- {
4513
- path: _to_consumable_array(path).concat([
4514
- localKey
4515
- ]),
4516
- value: localSwitch
4517
- }
4518
- ])
4519
- });
4520
- }
4521
- } else if (localValue && hasAsync(localValue)) {
4522
- var localAsync = _this.parseAsync(localValue, "value", options);
4523
- if (localAsync) {
4524
- children2.push({
4525
- path: _to_consumable_array(path).concat([
4526
- localKey
4527
- ]),
4528
- value: localAsync
4529
- });
4530
- }
4531
- } else if (localValue && Array.isArray(localValue)) {
4532
- var childValues = localValue.map(function(childVal) {
4533
- return _this.parseObject(childVal, "value", options);
4534
- }).filter(function(child) {
4535
- return !!child;
4536
- });
4537
- if (childValues.length > 0) {
4538
- var multiNode = _this.hooks.onCreateASTNode.call({
4539
- type: "multi-node",
4540
- override: !_this.hasTemplateValues(localObj, localKey),
4541
- values: childValues
4542
- }, localValue);
4543
- if ((multiNode === null || multiNode === void 0 ? void 0 : multiNode.type) === "multi-node") {
4544
- multiNode.values.forEach(function(v) {
4545
- v.parent = multiNode;
4546
- });
4547
- }
4548
- if (multiNode) {
4549
- return _object_spread_props(_object_spread({}, rest), {
4550
- children: _to_consumable_array(children2).concat([
4551
- {
4552
- path: _to_consumable_array(path).concat([
4553
- localKey
4554
- ]),
4555
- value: multiNode
4556
- }
4557
- ])
4558
- });
4559
- }
4560
- }
4424
+ var newChildren = _this.hooks.parseNode.call(localValue, "value", options, {
4425
+ path: path,
4426
+ key: localKey,
4427
+ parentObj: localObj
4428
+ });
4429
+ if (newChildren) {
4430
+ var _children2;
4431
+ (_children2 = children2).push.apply(_children2, _to_consumable_array(newChildren));
4561
4432
  } else if (localValue && typeof localValue === "object") {
4562
- var determineNodeType = _this.hooks.determineNodeType.call(localValue);
4563
- if (determineNodeType === "applicability") {
4564
- var parsedNode = _this.hooks.parseNode.call(localValue, "value", options, determineNodeType);
4565
- if (parsedNode) {
4566
- return _object_spread_props(_object_spread({}, rest), {
4567
- children: _to_consumable_array(children2).concat([
4568
- {
4569
- path: _to_consumable_array(path).concat([
4570
- localKey
4571
- ]),
4572
- value: parsedNode
4573
- }
4574
- ])
4575
- });
4576
- }
4577
- } else {
4578
- var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
4579
- localKey
4580
- ]));
4581
- return {
4582
- value: result.value,
4583
- children: _to_consumable_array(children2).concat(_to_consumable_array(result.children))
4584
- };
4585
- }
4433
+ var _children21;
4434
+ var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
4435
+ localKey
4436
+ ]));
4437
+ value2 = result.value;
4438
+ (_children21 = children2).push.apply(_children21, _to_consumable_array(result.children));
4586
4439
  } else {
4587
- var value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(path).concat([
4440
+ value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(path).concat([
4588
4441
  localKey
4589
4442
  ]), localValue);
4590
- return {
4591
- children: children2,
4592
- value: value2
4593
- };
4594
4443
  }
4595
- return accumulation;
4444
+ return {
4445
+ value: value2,
4446
+ children: children2
4447
+ };
4596
4448
  }, defaultValue);
4597
4449
  return newValue;
4598
4450
  };
4599
4451
  var _parseLocalObject = parseLocalObject(void 0, obj), value = _parseLocalObject.value, children = _parseLocalObject.children;
4600
- var baseAst = value === void 0 && children.length === 0 ? void 0 : {
4452
+ var baseAst = value === void 0 && !children.length ? void 0 : {
4601
4453
  type: type,
4602
4454
  value: value
4603
4455
  };
4604
- if (baseAst !== void 0 && children.length > 0) {
4456
+ if (baseAst && children.length) {
4605
4457
  var parent = baseAst;
4606
4458
  parent.children = children;
4607
4459
  children.forEach(function(child) {
@@ -5089,24 +4941,30 @@ var AsyncNodePlugin = function() {
5089
4941
  }
5090
4942
  return node;
5091
4943
  });
5092
- parser.hooks.determineNodeType.tap("template", function(obj) {
5093
- if (obj === "template") {
5094
- return "template";
5095
- }
5096
- });
5097
- parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, determinedNodeType) {
5098
- if (determinedNodeType === "template") {
5099
- var _options_templateDepth, _obj_dynamic;
5100
- var templateNode = parser.createASTNode({
5101
- type: "template",
5102
- depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
5103
- data: obj.data,
5104
- template: obj.value,
5105
- dynamic: (_obj_dynamic = obj.dynamic) !== null && _obj_dynamic !== void 0 ? _obj_dynamic : false
5106
- }, obj);
5107
- if (templateNode) {
5108
- return templateNode;
5109
- }
4944
+ parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
4945
+ if (childOptions && hasTemplateKey(childOptions.key)) {
4946
+ return obj.map(function(template) {
4947
+ var _options_templateDepth, _template_dynamic;
4948
+ var templateAST = parser.createASTNode({
4949
+ type: "template",
4950
+ depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
4951
+ data: template.data,
4952
+ template: template.value,
4953
+ dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
4954
+ }, template);
4955
+ if (!templateAST) return;
4956
+ if (templateAST.type === "multi-node") {
4957
+ templateAST.values.forEach(function(v) {
4958
+ v.parent = templateAST;
4959
+ });
4960
+ }
4961
+ return {
4962
+ path: _to_consumable_array(childOptions.path).concat([
4963
+ template.output
4964
+ ]),
4965
+ value: templateAST
4966
+ };
4967
+ }).filter(Boolean);
5110
4968
  }
5111
4969
  });
5112
4970
  }
@@ -5250,6 +5108,12 @@ var AsyncNodePlugin = function() {
5250
5108
  _class_call_check(this, ApplicabilityPlugin);
5251
5109
  }
5252
5110
  _create_class(ApplicabilityPlugin, [
5111
+ {
5112
+ key: "isApplicability",
5113
+ value: function isApplicability(obj) {
5114
+ return obj && Object.prototype.hasOwnProperty.call(obj, "applicability");
5115
+ }
5116
+ },
5253
5117
  {
5254
5118
  key: "applyResolver",
5255
5119
  value: function applyResolver(resolver) {
@@ -5269,25 +5133,32 @@ var AsyncNodePlugin = function() {
5269
5133
  {
5270
5134
  key: "applyParser",
5271
5135
  value: function applyParser(parser) {
5272
- parser.hooks.determineNodeType.tap("applicability", function(obj) {
5273
- if (Object.prototype.hasOwnProperty.call(obj, "applicability")) {
5274
- return "applicability";
5275
- }
5276
- });
5277
- parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, determinedNodeType) {
5278
- if (determinedNodeType === "applicability") {
5136
+ var _this = this;
5137
+ parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, childOptions) {
5138
+ if (_this.isApplicability(obj)) {
5279
5139
  var parsedApplicability = parser.parseObject((0, import_timm7.omit)(obj, "applicability"), nodeType, options);
5280
- if (parsedApplicability !== null) {
5281
- var applicabilityNode = parser.createASTNode({
5282
- type: "applicability",
5283
- expression: obj.applicability,
5284
- value: parsedApplicability
5285
- }, obj);
5286
- if ((applicabilityNode === null || applicabilityNode === void 0 ? void 0 : applicabilityNode.type) === "applicability") {
5287
- applicabilityNode.value.parent = applicabilityNode;
5288
- }
5289
- return applicabilityNode;
5140
+ if (!parsedApplicability) {
5141
+ return childOptions ? [] : null;
5142
+ }
5143
+ var applicabilityNode = parser.createASTNode({
5144
+ type: "applicability",
5145
+ expression: obj.applicability,
5146
+ value: parsedApplicability
5147
+ }, obj);
5148
+ if (!applicabilityNode) {
5149
+ return childOptions ? [] : null;
5290
5150
  }
5151
+ if (applicabilityNode.type === "applicability") {
5152
+ applicabilityNode.value.parent = applicabilityNode;
5153
+ }
5154
+ return childOptions ? [
5155
+ {
5156
+ path: _to_consumable_array(childOptions.path).concat([
5157
+ childOptions.key
5158
+ ]),
5159
+ value: applicabilityNode
5160
+ }
5161
+ ] : applicabilityNode;
5291
5162
  }
5292
5163
  });
5293
5164
  }
@@ -5337,6 +5208,12 @@ var AsyncNodePlugin = function() {
5337
5208
  return EMPTY_NODE;
5338
5209
  }
5339
5210
  },
5211
+ {
5212
+ key: "isSwitch",
5213
+ value: function isSwitch(obj) {
5214
+ return obj && (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch"));
5215
+ }
5216
+ },
5340
5217
  {
5341
5218
  key: "applyParser",
5342
5219
  value: function applyParser(parser) {
@@ -5347,42 +5224,56 @@ var AsyncNodePlugin = function() {
5347
5224
  }
5348
5225
  return node;
5349
5226
  });
5350
- parser.hooks.determineNodeType.tap("switch", function(obj) {
5351
- if (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch")) {
5352
- return "switch";
5353
- }
5354
- });
5355
- parser.hooks.parseNode.tap("switch", function(obj, _nodeType, options, determinedNodeType) {
5356
- if (determinedNodeType === "switch") {
5357
- var dynamic = "dynamicSwitch" in obj;
5358
- var switchContent = "dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;
5359
- var cases = [];
5360
- switchContent.forEach(function(switchCase) {
5227
+ parser.hooks.parseNode.tap("switch", function(obj, _nodeType, options, childOptions) {
5228
+ if (_this.isSwitch(obj) || childOptions && hasSwitchKey(childOptions.key)) {
5229
+ var objToParse = childOptions && hasSwitchKey(childOptions.key) ? _define_property({}, childOptions.key, obj) : obj;
5230
+ var dynamic = "dynamicSwitch" in objToParse;
5231
+ var switchContent = dynamic ? objToParse.dynamicSwitch : objToParse.staticSwitch;
5232
+ var cases = switchContent.map(function(switchCase) {
5361
5233
  var switchCaseExpr = switchCase.case, switchBody = _object_without_properties(switchCase, [
5362
5234
  "case"
5363
5235
  ]);
5364
5236
  var value = parser.parseObject(switchBody, "value", options);
5365
5237
  if (value) {
5366
- cases.push({
5238
+ return {
5367
5239
  case: switchCaseExpr,
5368
5240
  value: value
5369
- });
5241
+ };
5370
5242
  }
5371
- });
5372
- var switchAST = parser.hooks.onCreateASTNode.call({
5243
+ return;
5244
+ }).filter(Boolean);
5245
+ var switchAST = parser.createASTNode({
5373
5246
  type: "switch",
5374
5247
  dynamic: dynamic,
5375
5248
  cases: cases
5376
- }, obj);
5377
- if ((switchAST === null || switchAST === void 0 ? void 0 : switchAST.type) === "switch") {
5249
+ }, objToParse);
5250
+ if (!switchAST || switchAST.type === "empty") {
5251
+ return childOptions ? [] : null;
5252
+ }
5253
+ if (switchAST.type === "switch") {
5378
5254
  switchAST.cases.forEach(function(sCase) {
5379
5255
  sCase.value.parent = switchAST;
5380
5256
  });
5381
5257
  }
5382
- if ((switchAST === null || switchAST === void 0 ? void 0 : switchAST.type) === "empty") {
5383
- return null;
5258
+ if (childOptions) {
5259
+ var _switchAST_children;
5260
+ var path = _to_consumable_array(childOptions.path).concat([
5261
+ childOptions.key
5262
+ ]);
5263
+ var value = switchAST;
5264
+ if (switchAST.type === "value" && ((_switchAST_children = switchAST.children) === null || _switchAST_children === void 0 ? void 0 : _switchAST_children.length) === 1 && switchAST.value === void 0) {
5265
+ var firstChild = switchAST.children[0];
5266
+ path = _to_consumable_array(path).concat(_to_consumable_array(firstChild.path));
5267
+ value = firstChild.value;
5268
+ }
5269
+ return [
5270
+ {
5271
+ path: path,
5272
+ value: value
5273
+ }
5274
+ ];
5384
5275
  }
5385
- return switchAST !== null && switchAST !== void 0 ? switchAST : null;
5276
+ return switchAST;
5386
5277
  }
5387
5278
  });
5388
5279
  }
@@ -5409,6 +5300,93 @@ var AsyncNodePlugin = function() {
5409
5300
  ]);
5410
5301
  return SwitchPlugin;
5411
5302
  }();
5303
+ var MultiNodePlugin = /*#__PURE__*/ function() {
5304
+ function MultiNodePlugin() {
5305
+ _class_call_check(this, MultiNodePlugin);
5306
+ }
5307
+ _create_class(MultiNodePlugin, [
5308
+ {
5309
+ key: "applyParser",
5310
+ value: function applyParser(parser) {
5311
+ parser.hooks.parseNode.tap("multi-node", function(obj, nodeType, options, childOptions) {
5312
+ if (childOptions && !hasTemplateKey(childOptions.key) && Array.isArray(obj)) {
5313
+ var values = obj.map(function(childVal) {
5314
+ return parser.parseObject(childVal, "value", options);
5315
+ }).filter(function(child) {
5316
+ return !!child;
5317
+ });
5318
+ if (!values.length) {
5319
+ return [];
5320
+ }
5321
+ var multiNode = parser.createASTNode({
5322
+ type: "multi-node",
5323
+ override: !hasTemplateValues(childOptions.parentObj, childOptions.key),
5324
+ values: values
5325
+ }, obj);
5326
+ if (!multiNode) {
5327
+ return [];
5328
+ }
5329
+ if (multiNode.type === "multi-node") {
5330
+ multiNode.values.forEach(function(v) {
5331
+ v.parent = multiNode;
5332
+ });
5333
+ }
5334
+ return [
5335
+ {
5336
+ path: _to_consumable_array(childOptions.path).concat([
5337
+ childOptions.key
5338
+ ]),
5339
+ value: multiNode
5340
+ }
5341
+ ];
5342
+ }
5343
+ });
5344
+ }
5345
+ },
5346
+ {
5347
+ key: "apply",
5348
+ value: function apply(view) {
5349
+ view.hooks.parser.tap("multi-node", this.applyParser.bind(this));
5350
+ }
5351
+ }
5352
+ ]);
5353
+ return MultiNodePlugin;
5354
+ }();
5355
+ var AssetPlugin = /*#__PURE__*/ function() {
5356
+ function AssetPlugin() {
5357
+ _class_call_check(this, AssetPlugin);
5358
+ }
5359
+ _create_class(AssetPlugin, [
5360
+ {
5361
+ key: "applyParser",
5362
+ value: function applyParser(parser) {
5363
+ parser.hooks.parseNode.tap("asset", function(obj, nodeType, options, childOptions) {
5364
+ if ((childOptions === null || childOptions === void 0 ? void 0 : childOptions.key) === "asset" && typeof obj === "object") {
5365
+ var assetAST = parser.parseObject(obj, "asset", options);
5366
+ if (!assetAST) {
5367
+ return [];
5368
+ }
5369
+ return [
5370
+ {
5371
+ path: _to_consumable_array(childOptions.path).concat([
5372
+ childOptions.key
5373
+ ]),
5374
+ value: assetAST
5375
+ }
5376
+ ];
5377
+ }
5378
+ });
5379
+ }
5380
+ },
5381
+ {
5382
+ key: "apply",
5383
+ value: function apply(view) {
5384
+ view.hooks.parser.tap("asset", this.applyParser.bind(this));
5385
+ }
5386
+ }
5387
+ ]);
5388
+ return AssetPlugin;
5389
+ }();
5412
5390
  var FlowInstance = /*#__PURE__*/ function() {
5413
5391
  function FlowInstance(id, flow, options) {
5414
5392
  _class_call_check(this, FlowInstance);
@@ -7111,12 +7089,14 @@ var AsyncNodePlugin = function() {
7111
7089
  player.hooks.viewController.tap(this.name, function(viewController) {
7112
7090
  viewController.hooks.view.tap(_this.name, function(view) {
7113
7091
  var pluginOptions = toNodeResolveOptions(view.resolverOptions);
7092
+ new AssetPlugin().apply(view);
7114
7093
  new SwitchPlugin(pluginOptions).apply(view);
7115
7094
  new ApplicabilityPlugin().apply(view);
7116
7095
  new StringResolverPlugin().apply(view);
7117
7096
  var templatePlugin = new TemplatePlugin(pluginOptions);
7118
7097
  templatePlugin.apply(view);
7119
7098
  view.hooks.onTemplatePluginCreated.call(templatePlugin);
7099
+ new MultiNodePlugin().apply(view);
7120
7100
  });
7121
7101
  });
7122
7102
  }
@@ -7557,38 +7537,32 @@ var AsyncNodePlugin = function() {
7557
7537
  }
7558
7538
  _create_class(AsyncNodePluginPlugin, [
7559
7539
  {
7560
- key: "isAsync",
7561
- value: function isAsync(node) {
7562
- return (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async;
7563
- }
7564
- },
7565
- {
7566
- key: "applyParser",
7567
- value: function applyParser(parser) {
7568
- parser.hooks.determineNodeType.tap(this.name, function(obj) {
7569
- if (Object.prototype.hasOwnProperty.call(obj, "async")) {
7570
- return NodeType.Async;
7571
- }
7572
- });
7573
- parser.hooks.parseNode.tap(this.name, function(obj, nodeType, options, determinedNodeType) {
7574
- if (determinedNodeType === NodeType.Async) {
7575
- var parsedAsync = parser.parseObject((0, import_timm10.omit)(obj, "async"), nodeType, options);
7576
- var parsedNodeId = getNodeID(parsedAsync);
7577
- if (parsedAsync !== null && parsedNodeId) {
7578
- return parser.createASTNode({
7579
- id: parsedNodeId,
7580
- type: NodeType.Async,
7581
- value: parsedAsync
7582
- }, obj);
7583
- }
7584
- return null;
7585
- }
7586
- });
7540
+ /**
7541
+ * Updates the node asynchronously based on the result provided.
7542
+ * This method is responsible for handling the update logic of asynchronous nodes.
7543
+ * It checks if the node needs to be updated based on the new result and updates the mapping accordingly.
7544
+ * If an update is necessary, it triggers an asynchronous update on the view.
7545
+ * @param node The asynchronous node that might be updated.
7546
+ * @param result The result obtained from resolving the async node. This could be any data structure or value.
7547
+ * @param options Options provided for node resolution, including a potential parseNode function to process the result.
7548
+ * @param view The view instance where the node resides. This can be undefined if the view is not currently active.
7549
+ */ key: "handleAsyncUpdate",
7550
+ value: function handleAsyncUpdate(node, result, options, view) {
7551
+ var parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
7552
+ if (this.resolvedMapping.get(node.id) !== parsedNode) {
7553
+ this.resolvedMapping.set(node.id, parsedNode ? parsedNode : node);
7554
+ view === null || view === void 0 ? void 0 : view.updateAsync();
7555
+ }
7587
7556
  }
7588
7557
  },
7589
7558
  {
7590
- key: "applyResolverHooks",
7591
- value: function applyResolverHooks(resolver) {
7559
+ /**
7560
+ * Handles the asynchronous API integration for resolving nodes.
7561
+ * This method sets up a hook on the resolver's `beforeResolve` event to process async nodes.
7562
+ * @param resolver The resolver instance to attach the hook to.
7563
+ * @param view
7564
+ */ key: "applyResolver",
7565
+ value: function applyResolver(resolver) {
7592
7566
  var _this = this;
7593
7567
  resolver.hooks.beforeResolve.tap(this.name, function(node, options) {
7594
7568
  var resolvedNode;
@@ -7604,22 +7578,19 @@ var AsyncNodePlugin = function() {
7604
7578
  if (!resolvedNode && (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async) {
7605
7579
  var _this1 = _this;
7606
7580
  (0, import_queue_microtask2.default)(/*#__PURE__*/ _async_to_generator(function() {
7607
- var _this_basePlugin, result, parsedNode, _this_currentView;
7581
+ var _this_basePlugin, result;
7608
7582
  return _ts_generator(this, function(_state) {
7609
7583
  switch(_state.label){
7610
7584
  case 0:
7611
7585
  return [
7612
7586
  4,
7613
- (_this_basePlugin = _this1.basePlugin) === null || _this_basePlugin === void 0 ? void 0 : _this_basePlugin.hooks.onAsyncNode.call(node)
7587
+ (_this_basePlugin = _this1.basePlugin) === null || _this_basePlugin === void 0 ? void 0 : _this_basePlugin.hooks.onAsyncNode.call(node, function(result2) {
7588
+ _this1.handleAsyncUpdate(node, result2, options, _this1.currentView);
7589
+ })
7614
7590
  ];
7615
7591
  case 1:
7616
7592
  result = _state.sent();
7617
- parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
7618
- if (parsedNode) {
7619
- ;
7620
- _this1.resolvedMapping.set(node.id, parsedNode);
7621
- (_this_currentView = _this1.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.updateAsync();
7622
- }
7593
+ _this1.handleAsyncUpdate(node, result, options, _this1.currentView);
7623
7594
  return [
7624
7595
  2
7625
7596
  ];
@@ -7633,51 +7604,56 @@ var AsyncNodePlugin = function() {
7633
7604
  }
7634
7605
  },
7635
7606
  {
7636
- key: "apply",
7637
- value: function apply(view) {
7607
+ key: "isAsync",
7608
+ value: function isAsync(node) {
7609
+ return (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async;
7610
+ }
7611
+ },
7612
+ {
7613
+ key: "isDeterminedAsync",
7614
+ value: function isDeterminedAsync(obj) {
7615
+ return obj && Object.prototype.hasOwnProperty.call(obj, "async");
7616
+ }
7617
+ },
7618
+ {
7619
+ key: "applyParser",
7620
+ value: function applyParser(parser) {
7638
7621
  var _this = this;
7639
- view.hooks.parser.tap("template", this.applyParser.bind(this));
7640
- view.hooks.resolver.tap("template", function(resolver) {
7641
- resolver.hooks.beforeResolve.tap(_this.name, function(node, options) {
7642
- var resolvedNode;
7643
- if (_this.isAsync(node)) {
7644
- var mappedValue = _this.resolvedMapping.get(node.id);
7645
- if (mappedValue) {
7646
- resolvedNode = mappedValue;
7647
- }
7648
- } else {
7649
- resolvedNode = null;
7622
+ parser.hooks.parseNode.tap(this.name, function(obj, nodeType, options, childOptions) {
7623
+ if (_this.isDeterminedAsync(obj)) {
7624
+ var parsedAsync = parser.parseObject((0, import_timm10.omit)(obj, "async"), nodeType, options);
7625
+ var parsedNodeId = getNodeID(parsedAsync);
7626
+ if (parsedAsync === null || !parsedNodeId) {
7627
+ return childOptions ? [] : null;
7650
7628
  }
7651
- var newNode = resolvedNode || node;
7652
- if (!resolvedNode && (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async) {
7653
- var _this1 = _this;
7654
- (0, import_queue_microtask2.default)(/*#__PURE__*/ _async_to_generator(function() {
7655
- var _this_basePlugin, result, parsedNode;
7656
- return _ts_generator(this, function(_state) {
7657
- switch(_state.label){
7658
- case 0:
7659
- return [
7660
- 4,
7661
- (_this_basePlugin = _this1.basePlugin) === null || _this_basePlugin === void 0 ? void 0 : _this_basePlugin.hooks.onAsyncNode.call(node)
7662
- ];
7663
- case 1:
7664
- result = _state.sent();
7665
- parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
7666
- _this1.resolvedMapping.set(node.id, parsedNode ? parsedNode : node);
7667
- view.updateAsync();
7668
- return [
7669
- 2
7670
- ];
7671
- }
7672
- });
7673
- }));
7674
- return node;
7629
+ var asyncAST = parser.createASTNode({
7630
+ id: parsedNodeId,
7631
+ type: NodeType.Async,
7632
+ value: parsedAsync
7633
+ }, obj);
7634
+ if (childOptions) {
7635
+ return asyncAST ? [
7636
+ {
7637
+ path: _to_consumable_array(childOptions.path).concat([
7638
+ childOptions.key
7639
+ ]),
7640
+ value: asyncAST
7641
+ }
7642
+ ] : [];
7675
7643
  }
7676
- return newNode;
7677
- });
7644
+ return asyncAST;
7645
+ }
7678
7646
  });
7679
7647
  }
7680
7648
  },
7649
+ {
7650
+ key: "apply",
7651
+ value: function apply(view) {
7652
+ this.currentView = view;
7653
+ view.hooks.parser.tap("async", this.applyParser.bind(this));
7654
+ view.hooks.resolver.tap("async", this.applyResolver.bind(this));
7655
+ }
7656
+ },
7681
7657
  {
7682
7658
  key: "applyPlugin",
7683
7659
  value: function applyPlugin(asyncNodePlugin) {