@player-ui/async-node-plugin 0.8.0-next.3 → 0.8.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AsyncNodePlugin.native.js +294 -324
- package/dist/AsyncNodePlugin.native.js.map +1 -1
- package/dist/cjs/index.cjs +73 -64
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +73 -64
- package/dist/index.mjs +73 -64
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/index.test.ts +443 -327
- package/src/index.ts +101 -80
- package/types/index.d.ts +22 -4
|
@@ -1354,8 +1354,16 @@ var AsyncNodePlugin = function() {
|
|
|
1354
1354
|
}
|
|
1355
1355
|
return targetMap;
|
|
1356
1356
|
};
|
|
1357
|
-
var
|
|
1358
|
-
return Object.
|
|
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";
|
|
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 =
|
|
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
|
|
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:
|
|
1916
|
+
omit: omit4,
|
|
1909
1917
|
addDefaults: addDefaults
|
|
1910
1918
|
};
|
|
1911
1919
|
var _default = timm;
|
|
@@ -4347,7 +4355,6 @@ var AsyncNodePlugin = function() {
|
|
|
4347
4355
|
* If undefined, the original value is used.
|
|
4348
4356
|
* If null, we ignore this node all together
|
|
4349
4357
|
*/ onCreateASTNode: new SyncWaterfallHook(),
|
|
4350
|
-
determineNodeType: new SyncBailHook(),
|
|
4351
4358
|
parseNode: new SyncBailHook()
|
|
4352
4359
|
};
|
|
4353
4360
|
}
|
|
@@ -4362,21 +4369,6 @@ var AsyncNodePlugin = function() {
|
|
|
4362
4369
|
return viewNode;
|
|
4363
4370
|
}
|
|
4364
4371
|
},
|
|
4365
|
-
{
|
|
4366
|
-
key: "parseAsync",
|
|
4367
|
-
value: function parseAsync(obj, type, options) {
|
|
4368
|
-
var parsedAsync = this.parseObject((0, import_timm5.omit)(obj, "async"), type, options);
|
|
4369
|
-
var parsedNodeId = getNodeID(parsedAsync);
|
|
4370
|
-
if (parsedAsync !== null && parsedNodeId) {
|
|
4371
|
-
return this.createASTNode({
|
|
4372
|
-
id: parsedNodeId,
|
|
4373
|
-
type: "async",
|
|
4374
|
-
value: parsedAsync
|
|
4375
|
-
}, obj);
|
|
4376
|
-
}
|
|
4377
|
-
return null;
|
|
4378
|
-
}
|
|
4379
|
-
},
|
|
4380
4372
|
{
|
|
4381
4373
|
key: "createASTNode",
|
|
4382
4374
|
value: function createASTNode(node, value) {
|
|
@@ -4387,25 +4379,6 @@ var AsyncNodePlugin = function() {
|
|
|
4387
4379
|
return tapped;
|
|
4388
4380
|
}
|
|
4389
4381
|
},
|
|
4390
|
-
{
|
|
4391
|
-
/**
|
|
4392
|
-
* Checks if there are templated values in the object
|
|
4393
|
-
*
|
|
4394
|
-
* @param obj - The Parsed Object to check to see if we have a template array type for
|
|
4395
|
-
* @param localKey - The key being checked
|
|
4396
|
-
*/ key: "hasTemplateValues",
|
|
4397
|
-
value: function hasTemplateValues(obj, localKey) {
|
|
4398
|
-
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) {
|
|
4399
|
-
return tmpl.output === localKey;
|
|
4400
|
-
});
|
|
4401
|
-
}
|
|
4402
|
-
},
|
|
4403
|
-
{
|
|
4404
|
-
key: "hasSwitchKey",
|
|
4405
|
-
value: function hasSwitchKey(localKey) {
|
|
4406
|
-
return localKey === "staticSwitch";
|
|
4407
|
-
}
|
|
4408
|
-
},
|
|
4409
4382
|
{
|
|
4410
4383
|
key: "parseObject",
|
|
4411
4384
|
value: function parseObject(obj) {
|
|
@@ -4413,12 +4386,9 @@ var AsyncNodePlugin = function() {
|
|
|
4413
4386
|
templateDepth: 0
|
|
4414
4387
|
};
|
|
4415
4388
|
var _this = this;
|
|
4416
|
-
var
|
|
4417
|
-
if (
|
|
4418
|
-
|
|
4419
|
-
if (parsedNode) {
|
|
4420
|
-
return parsedNode;
|
|
4421
|
-
}
|
|
4389
|
+
var parsedNode = this.hooks.parseNode.call(obj, type, options);
|
|
4390
|
+
if (parsedNode || parsedNode === null) {
|
|
4391
|
+
return parsedNode;
|
|
4422
4392
|
}
|
|
4423
4393
|
var parseLocalObject = function(currentValue, objToParse) {
|
|
4424
4394
|
var path = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
@@ -4448,166 +4418,42 @@ var AsyncNodePlugin = function() {
|
|
|
4448
4418
|
value: currentValue
|
|
4449
4419
|
};
|
|
4450
4420
|
var newValue = objEntries.reduce(function(accumulation, current) {
|
|
4451
|
-
var
|
|
4452
|
-
|
|
4453
|
-
]);
|
|
4421
|
+
var value2 = accumulation.value;
|
|
4422
|
+
var children2 = accumulation.children;
|
|
4454
4423
|
var _current = _sliced_to_array(current, 2), localKey = _current[0], localValue = _current[1];
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
]),
|
|
4464
|
-
value: assetAST
|
|
4465
|
-
}
|
|
4466
|
-
])
|
|
4467
|
-
});
|
|
4468
|
-
}
|
|
4469
|
-
} else if (_this.hooks.determineNodeType.call(localKey) === "template" && Array.isArray(localValue)) {
|
|
4470
|
-
var templateChildren = localValue.map(function(template) {
|
|
4471
|
-
var _options_templateDepth, _template_dynamic;
|
|
4472
|
-
var templateAST = _this.hooks.onCreateASTNode.call({
|
|
4473
|
-
type: "template",
|
|
4474
|
-
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
4475
|
-
data: template.data,
|
|
4476
|
-
template: template.value,
|
|
4477
|
-
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
4478
|
-
}, template);
|
|
4479
|
-
if ((templateAST === null || templateAST === void 0 ? void 0 : templateAST.type) === "multi-node") {
|
|
4480
|
-
templateAST.values.forEach(function(v) {
|
|
4481
|
-
v.parent = templateAST;
|
|
4482
|
-
});
|
|
4483
|
-
}
|
|
4484
|
-
if (templateAST) {
|
|
4485
|
-
return {
|
|
4486
|
-
path: _to_consumable_array(path).concat([
|
|
4487
|
-
template.output
|
|
4488
|
-
]),
|
|
4489
|
-
value: templateAST
|
|
4490
|
-
};
|
|
4491
|
-
}
|
|
4492
|
-
return;
|
|
4493
|
-
}).filter(function(element) {
|
|
4494
|
-
return !!element;
|
|
4495
|
-
});
|
|
4496
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4497
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(templateChildren))
|
|
4498
|
-
});
|
|
4499
|
-
} else if (localValue && _this.hooks.determineNodeType.call(localValue) === "switch" || _this.hasSwitchKey(localKey)) {
|
|
4500
|
-
var _localSwitch_children;
|
|
4501
|
-
var localSwitch = _this.hooks.parseNode.call(_this.hasSwitchKey(localKey) ? _define_property({}, localKey, localValue) : localValue, "value", options, "switch");
|
|
4502
|
-
if (localSwitch && localSwitch.type === "value" && ((_localSwitch_children = localSwitch.children) === null || _localSwitch_children === void 0 ? void 0 : _localSwitch_children.length) === 1 && localSwitch.value === void 0) {
|
|
4503
|
-
var firstChild = localSwitch.children[0];
|
|
4504
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4505
|
-
children: _to_consumable_array(children2).concat([
|
|
4506
|
-
{
|
|
4507
|
-
path: _to_consumable_array(path).concat([
|
|
4508
|
-
localKey
|
|
4509
|
-
], _to_consumable_array(firstChild.path)),
|
|
4510
|
-
value: firstChild.value
|
|
4511
|
-
}
|
|
4512
|
-
])
|
|
4513
|
-
});
|
|
4514
|
-
}
|
|
4515
|
-
if (localSwitch) {
|
|
4516
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4517
|
-
children: _to_consumable_array(children2).concat([
|
|
4518
|
-
{
|
|
4519
|
-
path: _to_consumable_array(path).concat([
|
|
4520
|
-
localKey
|
|
4521
|
-
]),
|
|
4522
|
-
value: localSwitch
|
|
4523
|
-
}
|
|
4524
|
-
])
|
|
4525
|
-
});
|
|
4526
|
-
}
|
|
4527
|
-
} else if (localValue && hasAsync(localValue)) {
|
|
4528
|
-
var localAsync = _this.parseAsync(localValue, "value", options);
|
|
4529
|
-
if (localAsync) {
|
|
4530
|
-
children2.push({
|
|
4531
|
-
path: _to_consumable_array(path).concat([
|
|
4532
|
-
localKey
|
|
4533
|
-
]),
|
|
4534
|
-
value: localAsync
|
|
4535
|
-
});
|
|
4536
|
-
}
|
|
4537
|
-
} else if (localValue && Array.isArray(localValue)) {
|
|
4538
|
-
var childValues = localValue.map(function(childVal) {
|
|
4539
|
-
return _this.parseObject(childVal, "value", options);
|
|
4540
|
-
}).filter(function(child) {
|
|
4541
|
-
return !!child;
|
|
4542
|
-
});
|
|
4543
|
-
if (childValues.length > 0) {
|
|
4544
|
-
var multiNode = _this.hooks.onCreateASTNode.call({
|
|
4545
|
-
type: "multi-node",
|
|
4546
|
-
override: !_this.hasTemplateValues(localObj, localKey),
|
|
4547
|
-
values: childValues
|
|
4548
|
-
}, localValue);
|
|
4549
|
-
if ((multiNode === null || multiNode === void 0 ? void 0 : multiNode.type) === "multi-node") {
|
|
4550
|
-
multiNode.values.forEach(function(v) {
|
|
4551
|
-
v.parent = multiNode;
|
|
4552
|
-
});
|
|
4553
|
-
}
|
|
4554
|
-
if (multiNode) {
|
|
4555
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4556
|
-
children: _to_consumable_array(children2).concat([
|
|
4557
|
-
{
|
|
4558
|
-
path: _to_consumable_array(path).concat([
|
|
4559
|
-
localKey
|
|
4560
|
-
]),
|
|
4561
|
-
value: multiNode
|
|
4562
|
-
}
|
|
4563
|
-
])
|
|
4564
|
-
});
|
|
4565
|
-
}
|
|
4566
|
-
}
|
|
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));
|
|
4567
4432
|
} else if (localValue && typeof localValue === "object") {
|
|
4568
|
-
var
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4572
|
-
|
|
4573
|
-
|
|
4574
|
-
{
|
|
4575
|
-
path: _to_consumable_array(path).concat([
|
|
4576
|
-
localKey
|
|
4577
|
-
]),
|
|
4578
|
-
value: parsedNode
|
|
4579
|
-
}
|
|
4580
|
-
])
|
|
4581
|
-
});
|
|
4582
|
-
}
|
|
4583
|
-
} else {
|
|
4584
|
-
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
|
|
4585
|
-
localKey
|
|
4586
|
-
]));
|
|
4587
|
-
return {
|
|
4588
|
-
value: result.value,
|
|
4589
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(result.children))
|
|
4590
|
-
};
|
|
4591
|
-
}
|
|
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));
|
|
4592
4439
|
} else {
|
|
4593
|
-
|
|
4440
|
+
value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(path).concat([
|
|
4594
4441
|
localKey
|
|
4595
4442
|
]), localValue);
|
|
4596
|
-
return {
|
|
4597
|
-
children: children2,
|
|
4598
|
-
value: value2
|
|
4599
|
-
};
|
|
4600
4443
|
}
|
|
4601
|
-
return
|
|
4444
|
+
return {
|
|
4445
|
+
value: value2,
|
|
4446
|
+
children: children2
|
|
4447
|
+
};
|
|
4602
4448
|
}, defaultValue);
|
|
4603
4449
|
return newValue;
|
|
4604
4450
|
};
|
|
4605
4451
|
var _parseLocalObject = parseLocalObject(void 0, obj), value = _parseLocalObject.value, children = _parseLocalObject.children;
|
|
4606
|
-
var baseAst = value === void 0 && children.length
|
|
4452
|
+
var baseAst = value === void 0 && !children.length ? void 0 : {
|
|
4607
4453
|
type: type,
|
|
4608
4454
|
value: value
|
|
4609
4455
|
};
|
|
4610
|
-
if (baseAst
|
|
4456
|
+
if (baseAst && children.length) {
|
|
4611
4457
|
var parent = baseAst;
|
|
4612
4458
|
parent.children = children;
|
|
4613
4459
|
children.forEach(function(child) {
|
|
@@ -5095,24 +4941,30 @@ var AsyncNodePlugin = function() {
|
|
|
5095
4941
|
}
|
|
5096
4942
|
return node;
|
|
5097
4943
|
});
|
|
5098
|
-
parser.hooks.
|
|
5099
|
-
if (
|
|
5100
|
-
return
|
|
5101
|
-
|
|
5102
|
-
|
|
5103
|
-
|
|
5104
|
-
|
|
5105
|
-
|
|
5106
|
-
|
|
5107
|
-
|
|
5108
|
-
|
|
5109
|
-
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
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);
|
|
5116
4968
|
}
|
|
5117
4969
|
});
|
|
5118
4970
|
}
|
|
@@ -5256,6 +5108,12 @@ var AsyncNodePlugin = function() {
|
|
|
5256
5108
|
_class_call_check(this, ApplicabilityPlugin);
|
|
5257
5109
|
}
|
|
5258
5110
|
_create_class(ApplicabilityPlugin, [
|
|
5111
|
+
{
|
|
5112
|
+
key: "isApplicability",
|
|
5113
|
+
value: function isApplicability(obj) {
|
|
5114
|
+
return obj && Object.prototype.hasOwnProperty.call(obj, "applicability");
|
|
5115
|
+
}
|
|
5116
|
+
},
|
|
5259
5117
|
{
|
|
5260
5118
|
key: "applyResolver",
|
|
5261
5119
|
value: function applyResolver(resolver) {
|
|
@@ -5275,25 +5133,32 @@ var AsyncNodePlugin = function() {
|
|
|
5275
5133
|
{
|
|
5276
5134
|
key: "applyParser",
|
|
5277
5135
|
value: function applyParser(parser) {
|
|
5278
|
-
|
|
5279
|
-
|
|
5280
|
-
|
|
5281
|
-
}
|
|
5282
|
-
});
|
|
5283
|
-
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, determinedNodeType) {
|
|
5284
|
-
if (determinedNodeType === "applicability") {
|
|
5136
|
+
var _this = this;
|
|
5137
|
+
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, childOptions) {
|
|
5138
|
+
if (_this.isApplicability(obj)) {
|
|
5285
5139
|
var parsedApplicability = parser.parseObject((0, import_timm7.omit)(obj, "applicability"), nodeType, options);
|
|
5286
|
-
if (parsedApplicability
|
|
5287
|
-
|
|
5288
|
-
|
|
5289
|
-
|
|
5290
|
-
|
|
5291
|
-
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
return
|
|
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;
|
|
5150
|
+
}
|
|
5151
|
+
if (applicabilityNode.type === "applicability") {
|
|
5152
|
+
applicabilityNode.value.parent = applicabilityNode;
|
|
5296
5153
|
}
|
|
5154
|
+
return childOptions ? [
|
|
5155
|
+
{
|
|
5156
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
5157
|
+
childOptions.key
|
|
5158
|
+
]),
|
|
5159
|
+
value: applicabilityNode
|
|
5160
|
+
}
|
|
5161
|
+
] : applicabilityNode;
|
|
5297
5162
|
}
|
|
5298
5163
|
});
|
|
5299
5164
|
}
|
|
@@ -5343,6 +5208,12 @@ var AsyncNodePlugin = function() {
|
|
|
5343
5208
|
return EMPTY_NODE;
|
|
5344
5209
|
}
|
|
5345
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
|
+
},
|
|
5346
5217
|
{
|
|
5347
5218
|
key: "applyParser",
|
|
5348
5219
|
value: function applyParser(parser) {
|
|
@@ -5353,42 +5224,56 @@ var AsyncNodePlugin = function() {
|
|
|
5353
5224
|
}
|
|
5354
5225
|
return node;
|
|
5355
5226
|
});
|
|
5356
|
-
parser.hooks.
|
|
5357
|
-
if (
|
|
5358
|
-
|
|
5359
|
-
|
|
5360
|
-
|
|
5361
|
-
|
|
5362
|
-
if (determinedNodeType === "switch") {
|
|
5363
|
-
var dynamic = "dynamicSwitch" in obj;
|
|
5364
|
-
var switchContent = "dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;
|
|
5365
|
-
var cases = [];
|
|
5366
|
-
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) {
|
|
5367
5233
|
var switchCaseExpr = switchCase.case, switchBody = _object_without_properties(switchCase, [
|
|
5368
5234
|
"case"
|
|
5369
5235
|
]);
|
|
5370
5236
|
var value = parser.parseObject(switchBody, "value", options);
|
|
5371
5237
|
if (value) {
|
|
5372
|
-
|
|
5238
|
+
return {
|
|
5373
5239
|
case: switchCaseExpr,
|
|
5374
5240
|
value: value
|
|
5375
|
-
}
|
|
5241
|
+
};
|
|
5376
5242
|
}
|
|
5377
|
-
|
|
5378
|
-
|
|
5243
|
+
return;
|
|
5244
|
+
}).filter(Boolean);
|
|
5245
|
+
var switchAST = parser.createASTNode({
|
|
5379
5246
|
type: "switch",
|
|
5380
5247
|
dynamic: dynamic,
|
|
5381
5248
|
cases: cases
|
|
5382
|
-
},
|
|
5383
|
-
if (
|
|
5249
|
+
}, objToParse);
|
|
5250
|
+
if (!switchAST || switchAST.type === "empty") {
|
|
5251
|
+
return childOptions ? [] : null;
|
|
5252
|
+
}
|
|
5253
|
+
if (switchAST.type === "switch") {
|
|
5384
5254
|
switchAST.cases.forEach(function(sCase) {
|
|
5385
5255
|
sCase.value.parent = switchAST;
|
|
5386
5256
|
});
|
|
5387
5257
|
}
|
|
5388
|
-
if (
|
|
5389
|
-
|
|
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
|
+
];
|
|
5390
5275
|
}
|
|
5391
|
-
return switchAST
|
|
5276
|
+
return switchAST;
|
|
5392
5277
|
}
|
|
5393
5278
|
});
|
|
5394
5279
|
}
|
|
@@ -5415,6 +5300,93 @@ var AsyncNodePlugin = function() {
|
|
|
5415
5300
|
]);
|
|
5416
5301
|
return SwitchPlugin;
|
|
5417
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
|
+
}();
|
|
5418
5390
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
5419
5391
|
function FlowInstance(id, flow, options) {
|
|
5420
5392
|
_class_call_check(this, FlowInstance);
|
|
@@ -7117,12 +7089,14 @@ var AsyncNodePlugin = function() {
|
|
|
7117
7089
|
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
7118
7090
|
viewController.hooks.view.tap(_this.name, function(view) {
|
|
7119
7091
|
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
7092
|
+
new AssetPlugin().apply(view);
|
|
7120
7093
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
7121
7094
|
new ApplicabilityPlugin().apply(view);
|
|
7122
7095
|
new StringResolverPlugin().apply(view);
|
|
7123
7096
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7124
7097
|
templatePlugin.apply(view);
|
|
7125
7098
|
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
7099
|
+
new MultiNodePlugin().apply(view);
|
|
7126
7100
|
});
|
|
7127
7101
|
});
|
|
7128
7102
|
}
|
|
@@ -7563,38 +7537,32 @@ var AsyncNodePlugin = function() {
|
|
|
7563
7537
|
}
|
|
7564
7538
|
_create_class(AsyncNodePluginPlugin, [
|
|
7565
7539
|
{
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
var parsedNodeId = getNodeID(parsedAsync);
|
|
7583
|
-
if (parsedAsync !== null && parsedNodeId) {
|
|
7584
|
-
return parser.createASTNode({
|
|
7585
|
-
id: parsedNodeId,
|
|
7586
|
-
type: NodeType.Async,
|
|
7587
|
-
value: parsedAsync
|
|
7588
|
-
}, obj);
|
|
7589
|
-
}
|
|
7590
|
-
return null;
|
|
7591
|
-
}
|
|
7592
|
-
});
|
|
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
|
+
}
|
|
7593
7556
|
}
|
|
7594
7557
|
},
|
|
7595
7558
|
{
|
|
7596
|
-
|
|
7597
|
-
|
|
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) {
|
|
7598
7566
|
var _this = this;
|
|
7599
7567
|
resolver.hooks.beforeResolve.tap(this.name, function(node, options) {
|
|
7600
7568
|
var resolvedNode;
|
|
@@ -7610,22 +7578,19 @@ var AsyncNodePlugin = function() {
|
|
|
7610
7578
|
if (!resolvedNode && (node === null || node === void 0 ? void 0 : node.type) === NodeType.Async) {
|
|
7611
7579
|
var _this1 = _this;
|
|
7612
7580
|
(0, import_queue_microtask2.default)(/*#__PURE__*/ _async_to_generator(function() {
|
|
7613
|
-
var _this_basePlugin, result
|
|
7581
|
+
var _this_basePlugin, result;
|
|
7614
7582
|
return _ts_generator(this, function(_state) {
|
|
7615
7583
|
switch(_state.label){
|
|
7616
7584
|
case 0:
|
|
7617
7585
|
return [
|
|
7618
7586
|
4,
|
|
7619
|
-
(_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
|
+
})
|
|
7620
7590
|
];
|
|
7621
7591
|
case 1:
|
|
7622
7592
|
result = _state.sent();
|
|
7623
|
-
|
|
7624
|
-
if (parsedNode) {
|
|
7625
|
-
;
|
|
7626
|
-
_this1.resolvedMapping.set(node.id, parsedNode);
|
|
7627
|
-
(_this_currentView = _this1.currentView) === null || _this_currentView === void 0 ? void 0 : _this_currentView.updateAsync();
|
|
7628
|
-
}
|
|
7593
|
+
_this1.handleAsyncUpdate(node, result, options, _this1.currentView);
|
|
7629
7594
|
return [
|
|
7630
7595
|
2
|
|
7631
7596
|
];
|
|
@@ -7639,51 +7604,56 @@ var AsyncNodePlugin = function() {
|
|
|
7639
7604
|
}
|
|
7640
7605
|
},
|
|
7641
7606
|
{
|
|
7642
|
-
key: "
|
|
7643
|
-
value: function
|
|
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) {
|
|
7644
7621
|
var _this = this;
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
|
|
7648
|
-
var
|
|
7649
|
-
if (
|
|
7650
|
-
|
|
7651
|
-
if (mappedValue) {
|
|
7652
|
-
resolvedNode = mappedValue;
|
|
7653
|
-
}
|
|
7654
|
-
} else {
|
|
7655
|
-
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;
|
|
7656
7628
|
}
|
|
7657
|
-
var
|
|
7658
|
-
|
|
7659
|
-
|
|
7660
|
-
|
|
7661
|
-
|
|
7662
|
-
|
|
7663
|
-
|
|
7664
|
-
|
|
7665
|
-
|
|
7666
|
-
|
|
7667
|
-
|
|
7668
|
-
|
|
7669
|
-
|
|
7670
|
-
|
|
7671
|
-
parsedNode = options.parseNode && result ? options.parseNode(result) : void 0;
|
|
7672
|
-
_this1.resolvedMapping.set(node.id, parsedNode ? parsedNode : node);
|
|
7673
|
-
view.updateAsync();
|
|
7674
|
-
return [
|
|
7675
|
-
2
|
|
7676
|
-
];
|
|
7677
|
-
}
|
|
7678
|
-
});
|
|
7679
|
-
}));
|
|
7680
|
-
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
|
+
] : [];
|
|
7681
7643
|
}
|
|
7682
|
-
return
|
|
7683
|
-
}
|
|
7644
|
+
return asyncAST;
|
|
7645
|
+
}
|
|
7684
7646
|
});
|
|
7685
7647
|
}
|
|
7686
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
|
+
},
|
|
7687
7657
|
{
|
|
7688
7658
|
key: "applyPlugin",
|
|
7689
7659
|
value: function applyPlugin(asyncNodePlugin) {
|