@player-ui/common-types-plugin 0.8.0-next.1 → 0.8.0-next.10
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 CommonTypesPlugin = 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" || 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;
|
|
@@ -1653,7 +1661,7 @@ var CommonTypesPlugin = function() {
|
|
|
1653
1661
|
exports.merge = merge;
|
|
1654
1662
|
exports.mergeDeep = mergeDeep;
|
|
1655
1663
|
exports.mergeIn = mergeIn;
|
|
1656
|
-
exports.omit =
|
|
1664
|
+
exports.omit = omit3;
|
|
1657
1665
|
exports.addDefaults = addDefaults;
|
|
1658
1666
|
exports.default = void 0;
|
|
1659
1667
|
var INVALID_ARGS = "INVALID_ARGS";
|
|
@@ -1827,7 +1835,7 @@ var CommonTypesPlugin = function() {
|
|
|
1827
1835
|
}
|
|
1828
1836
|
return setIn8(a, path, nextVal);
|
|
1829
1837
|
}
|
|
1830
|
-
function
|
|
1838
|
+
function omit3(obj, attrs) {
|
|
1831
1839
|
var omitList = Array.isArray(attrs) ? attrs : [
|
|
1832
1840
|
attrs
|
|
1833
1841
|
];
|
|
@@ -1913,7 +1921,7 @@ var CommonTypesPlugin = function() {
|
|
|
1913
1921
|
merge: merge,
|
|
1914
1922
|
mergeDeep: mergeDeep,
|
|
1915
1923
|
mergeIn: mergeIn,
|
|
1916
|
-
omit:
|
|
1924
|
+
omit: omit3,
|
|
1917
1925
|
addDefaults: addDefaults
|
|
1918
1926
|
};
|
|
1919
1927
|
var _default = timm;
|
|
@@ -2672,6 +2680,12 @@ var CommonTypesPlugin = function() {
|
|
|
2672
2680
|
value: function clear() {
|
|
2673
2681
|
this.store = createSortedArray();
|
|
2674
2682
|
}
|
|
2683
|
+
},
|
|
2684
|
+
{
|
|
2685
|
+
/** Check if the registry is empty*/ key: "isRegistryEmpty",
|
|
2686
|
+
value: function isRegistryEmpty() {
|
|
2687
|
+
return this.store.array.length === 0;
|
|
2688
|
+
}
|
|
2675
2689
|
}
|
|
2676
2690
|
]);
|
|
2677
2691
|
return Registry;
|
|
@@ -4378,7 +4392,6 @@ var CommonTypesPlugin = function() {
|
|
|
4378
4392
|
* If undefined, the original value is used.
|
|
4379
4393
|
* If null, we ignore this node all together
|
|
4380
4394
|
*/ onCreateASTNode: new SyncWaterfallHook(),
|
|
4381
|
-
determineNodeType: new SyncBailHook(),
|
|
4382
4395
|
parseNode: new SyncBailHook()
|
|
4383
4396
|
};
|
|
4384
4397
|
}
|
|
@@ -4393,21 +4406,6 @@ var CommonTypesPlugin = function() {
|
|
|
4393
4406
|
return viewNode;
|
|
4394
4407
|
}
|
|
4395
4408
|
},
|
|
4396
|
-
{
|
|
4397
|
-
key: "parseAsync",
|
|
4398
|
-
value: function parseAsync(obj, type, options) {
|
|
4399
|
-
var parsedAsync = this.parseObject((0, import_timm5.omit)(obj, "async"), type, options);
|
|
4400
|
-
var parsedNodeId = getNodeID(parsedAsync);
|
|
4401
|
-
if (parsedAsync !== null && parsedNodeId) {
|
|
4402
|
-
return this.createASTNode({
|
|
4403
|
-
id: parsedNodeId,
|
|
4404
|
-
type: "async",
|
|
4405
|
-
value: parsedAsync
|
|
4406
|
-
}, obj);
|
|
4407
|
-
}
|
|
4408
|
-
return null;
|
|
4409
|
-
}
|
|
4410
|
-
},
|
|
4411
4409
|
{
|
|
4412
4410
|
key: "createASTNode",
|
|
4413
4411
|
value: function createASTNode(node, value) {
|
|
@@ -4418,25 +4416,6 @@ var CommonTypesPlugin = function() {
|
|
|
4418
4416
|
return tapped;
|
|
4419
4417
|
}
|
|
4420
4418
|
},
|
|
4421
|
-
{
|
|
4422
|
-
/**
|
|
4423
|
-
* Checks if there are templated values in the object
|
|
4424
|
-
*
|
|
4425
|
-
* @param obj - The Parsed Object to check to see if we have a template array type for
|
|
4426
|
-
* @param localKey - The key being checked
|
|
4427
|
-
*/ key: "hasTemplateValues",
|
|
4428
|
-
value: function hasTemplateValues(obj, localKey) {
|
|
4429
|
-
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) {
|
|
4430
|
-
return tmpl.output === localKey;
|
|
4431
|
-
});
|
|
4432
|
-
}
|
|
4433
|
-
},
|
|
4434
|
-
{
|
|
4435
|
-
key: "hasSwitchKey",
|
|
4436
|
-
value: function hasSwitchKey(localKey) {
|
|
4437
|
-
return localKey === "staticSwitch";
|
|
4438
|
-
}
|
|
4439
|
-
},
|
|
4440
4419
|
{
|
|
4441
4420
|
key: "parseObject",
|
|
4442
4421
|
value: function parseObject(obj) {
|
|
@@ -4444,12 +4423,9 @@ var CommonTypesPlugin = function() {
|
|
|
4444
4423
|
templateDepth: 0
|
|
4445
4424
|
};
|
|
4446
4425
|
var _this = this;
|
|
4447
|
-
var
|
|
4448
|
-
if (
|
|
4449
|
-
|
|
4450
|
-
if (parsedNode) {
|
|
4451
|
-
return parsedNode;
|
|
4452
|
-
}
|
|
4426
|
+
var parsedNode = this.hooks.parseNode.call(obj, type, options);
|
|
4427
|
+
if (parsedNode || parsedNode === null) {
|
|
4428
|
+
return parsedNode;
|
|
4453
4429
|
}
|
|
4454
4430
|
var parseLocalObject = function(currentValue, objToParse) {
|
|
4455
4431
|
var path = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
@@ -4479,166 +4455,42 @@ var CommonTypesPlugin = function() {
|
|
|
4479
4455
|
value: currentValue
|
|
4480
4456
|
};
|
|
4481
4457
|
var newValue = objEntries.reduce(function(accumulation, current) {
|
|
4482
|
-
var
|
|
4483
|
-
|
|
4484
|
-
]);
|
|
4458
|
+
var value2 = accumulation.value;
|
|
4459
|
+
var children2 = accumulation.children;
|
|
4485
4460
|
var _current = _sliced_to_array(current, 2), localKey = _current[0], localValue = _current[1];
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
]),
|
|
4495
|
-
value: assetAST
|
|
4496
|
-
}
|
|
4497
|
-
])
|
|
4498
|
-
});
|
|
4499
|
-
}
|
|
4500
|
-
} else if (_this.hooks.determineNodeType.call(localKey) === "template" && Array.isArray(localValue)) {
|
|
4501
|
-
var templateChildren = localValue.map(function(template) {
|
|
4502
|
-
var _options_templateDepth, _template_dynamic;
|
|
4503
|
-
var templateAST = _this.hooks.onCreateASTNode.call({
|
|
4504
|
-
type: "template",
|
|
4505
|
-
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
4506
|
-
data: template.data,
|
|
4507
|
-
template: template.value,
|
|
4508
|
-
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
4509
|
-
}, template);
|
|
4510
|
-
if ((templateAST === null || templateAST === void 0 ? void 0 : templateAST.type) === "multi-node") {
|
|
4511
|
-
templateAST.values.forEach(function(v) {
|
|
4512
|
-
v.parent = templateAST;
|
|
4513
|
-
});
|
|
4514
|
-
}
|
|
4515
|
-
if (templateAST) {
|
|
4516
|
-
return {
|
|
4517
|
-
path: _to_consumable_array(path).concat([
|
|
4518
|
-
template.output
|
|
4519
|
-
]),
|
|
4520
|
-
value: templateAST
|
|
4521
|
-
};
|
|
4522
|
-
}
|
|
4523
|
-
return;
|
|
4524
|
-
}).filter(function(element) {
|
|
4525
|
-
return !!element;
|
|
4526
|
-
});
|
|
4527
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4528
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(templateChildren))
|
|
4529
|
-
});
|
|
4530
|
-
} else if (localValue && _this.hooks.determineNodeType.call(localValue) === "switch" || _this.hasSwitchKey(localKey)) {
|
|
4531
|
-
var _localSwitch_children;
|
|
4532
|
-
var localSwitch = _this.hooks.parseNode.call(_this.hasSwitchKey(localKey) ? _define_property({}, localKey, localValue) : localValue, "value", options, "switch");
|
|
4533
|
-
if (localSwitch && localSwitch.type === "value" && ((_localSwitch_children = localSwitch.children) === null || _localSwitch_children === void 0 ? void 0 : _localSwitch_children.length) === 1 && localSwitch.value === void 0) {
|
|
4534
|
-
var firstChild = localSwitch.children[0];
|
|
4535
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4536
|
-
children: _to_consumable_array(children2).concat([
|
|
4537
|
-
{
|
|
4538
|
-
path: _to_consumable_array(path).concat([
|
|
4539
|
-
localKey
|
|
4540
|
-
], _to_consumable_array(firstChild.path)),
|
|
4541
|
-
value: firstChild.value
|
|
4542
|
-
}
|
|
4543
|
-
])
|
|
4544
|
-
});
|
|
4545
|
-
}
|
|
4546
|
-
if (localSwitch) {
|
|
4547
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4548
|
-
children: _to_consumable_array(children2).concat([
|
|
4549
|
-
{
|
|
4550
|
-
path: _to_consumable_array(path).concat([
|
|
4551
|
-
localKey
|
|
4552
|
-
]),
|
|
4553
|
-
value: localSwitch
|
|
4554
|
-
}
|
|
4555
|
-
])
|
|
4556
|
-
});
|
|
4557
|
-
}
|
|
4558
|
-
} else if (localValue && hasAsync(localValue)) {
|
|
4559
|
-
var localAsync = _this.parseAsync(localValue, "value", options);
|
|
4560
|
-
if (localAsync) {
|
|
4561
|
-
children2.push({
|
|
4562
|
-
path: _to_consumable_array(path).concat([
|
|
4563
|
-
localKey
|
|
4564
|
-
]),
|
|
4565
|
-
value: localAsync
|
|
4566
|
-
});
|
|
4567
|
-
}
|
|
4568
|
-
} else if (localValue && Array.isArray(localValue)) {
|
|
4569
|
-
var childValues = localValue.map(function(childVal) {
|
|
4570
|
-
return _this.parseObject(childVal, "value", options);
|
|
4571
|
-
}).filter(function(child) {
|
|
4572
|
-
return !!child;
|
|
4573
|
-
});
|
|
4574
|
-
if (childValues.length > 0) {
|
|
4575
|
-
var multiNode = _this.hooks.onCreateASTNode.call({
|
|
4576
|
-
type: "multi-node",
|
|
4577
|
-
override: !_this.hasTemplateValues(localObj, localKey),
|
|
4578
|
-
values: childValues
|
|
4579
|
-
}, localValue);
|
|
4580
|
-
if ((multiNode === null || multiNode === void 0 ? void 0 : multiNode.type) === "multi-node") {
|
|
4581
|
-
multiNode.values.forEach(function(v) {
|
|
4582
|
-
v.parent = multiNode;
|
|
4583
|
-
});
|
|
4584
|
-
}
|
|
4585
|
-
if (multiNode) {
|
|
4586
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4587
|
-
children: _to_consumable_array(children2).concat([
|
|
4588
|
-
{
|
|
4589
|
-
path: _to_consumable_array(path).concat([
|
|
4590
|
-
localKey
|
|
4591
|
-
]),
|
|
4592
|
-
value: multiNode
|
|
4593
|
-
}
|
|
4594
|
-
])
|
|
4595
|
-
});
|
|
4596
|
-
}
|
|
4597
|
-
}
|
|
4461
|
+
var newChildren = _this.hooks.parseNode.call(localValue, "value", options, {
|
|
4462
|
+
path: path,
|
|
4463
|
+
key: localKey,
|
|
4464
|
+
parentObj: localObj
|
|
4465
|
+
});
|
|
4466
|
+
if (newChildren) {
|
|
4467
|
+
var _children2;
|
|
4468
|
+
(_children2 = children2).push.apply(_children2, _to_consumable_array(newChildren));
|
|
4598
4469
|
} else if (localValue && typeof localValue === "object") {
|
|
4599
|
-
var
|
|
4600
|
-
|
|
4601
|
-
|
|
4602
|
-
|
|
4603
|
-
|
|
4604
|
-
|
|
4605
|
-
{
|
|
4606
|
-
path: _to_consumable_array(path).concat([
|
|
4607
|
-
localKey
|
|
4608
|
-
]),
|
|
4609
|
-
value: parsedNode
|
|
4610
|
-
}
|
|
4611
|
-
])
|
|
4612
|
-
});
|
|
4613
|
-
}
|
|
4614
|
-
} else {
|
|
4615
|
-
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
|
|
4616
|
-
localKey
|
|
4617
|
-
]));
|
|
4618
|
-
return {
|
|
4619
|
-
value: result.value,
|
|
4620
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(result.children))
|
|
4621
|
-
};
|
|
4622
|
-
}
|
|
4470
|
+
var _children21;
|
|
4471
|
+
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
|
|
4472
|
+
localKey
|
|
4473
|
+
]));
|
|
4474
|
+
value2 = result.value;
|
|
4475
|
+
(_children21 = children2).push.apply(_children21, _to_consumable_array(result.children));
|
|
4623
4476
|
} else {
|
|
4624
|
-
|
|
4477
|
+
value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(path).concat([
|
|
4625
4478
|
localKey
|
|
4626
4479
|
]), localValue);
|
|
4627
|
-
return {
|
|
4628
|
-
children: children2,
|
|
4629
|
-
value: value2
|
|
4630
|
-
};
|
|
4631
4480
|
}
|
|
4632
|
-
return
|
|
4481
|
+
return {
|
|
4482
|
+
value: value2,
|
|
4483
|
+
children: children2
|
|
4484
|
+
};
|
|
4633
4485
|
}, defaultValue);
|
|
4634
4486
|
return newValue;
|
|
4635
4487
|
};
|
|
4636
4488
|
var _parseLocalObject = parseLocalObject(void 0, obj), value = _parseLocalObject.value, children = _parseLocalObject.children;
|
|
4637
|
-
var baseAst = value === void 0 && children.length
|
|
4489
|
+
var baseAst = value === void 0 && !children.length ? void 0 : {
|
|
4638
4490
|
type: type,
|
|
4639
4491
|
value: value
|
|
4640
4492
|
};
|
|
4641
|
-
if (baseAst
|
|
4493
|
+
if (baseAst && children.length) {
|
|
4642
4494
|
var parent = baseAst;
|
|
4643
4495
|
parent.children = children;
|
|
4644
4496
|
children.forEach(function(child) {
|
|
@@ -5126,24 +4978,30 @@ var CommonTypesPlugin = function() {
|
|
|
5126
4978
|
}
|
|
5127
4979
|
return node;
|
|
5128
4980
|
});
|
|
5129
|
-
parser.hooks.
|
|
5130
|
-
if (
|
|
5131
|
-
return
|
|
5132
|
-
|
|
5133
|
-
|
|
5134
|
-
|
|
5135
|
-
|
|
5136
|
-
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
4981
|
+
parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
|
|
4982
|
+
if (childOptions && hasTemplateKey(childOptions.key)) {
|
|
4983
|
+
return obj.map(function(template) {
|
|
4984
|
+
var _options_templateDepth, _template_dynamic;
|
|
4985
|
+
var templateAST = parser.createASTNode({
|
|
4986
|
+
type: "template",
|
|
4987
|
+
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
4988
|
+
data: template.data,
|
|
4989
|
+
template: template.value,
|
|
4990
|
+
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
4991
|
+
}, template);
|
|
4992
|
+
if (!templateAST) return;
|
|
4993
|
+
if (templateAST.type === "multi-node") {
|
|
4994
|
+
templateAST.values.forEach(function(v) {
|
|
4995
|
+
v.parent = templateAST;
|
|
4996
|
+
});
|
|
4997
|
+
}
|
|
4998
|
+
return {
|
|
4999
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
5000
|
+
template.output
|
|
5001
|
+
]),
|
|
5002
|
+
value: templateAST
|
|
5003
|
+
};
|
|
5004
|
+
}).filter(Boolean);
|
|
5147
5005
|
}
|
|
5148
5006
|
});
|
|
5149
5007
|
}
|
|
@@ -5287,6 +5145,12 @@ var CommonTypesPlugin = function() {
|
|
|
5287
5145
|
_class_call_check(this, ApplicabilityPlugin);
|
|
5288
5146
|
}
|
|
5289
5147
|
_create_class(ApplicabilityPlugin, [
|
|
5148
|
+
{
|
|
5149
|
+
key: "isApplicability",
|
|
5150
|
+
value: function isApplicability(obj) {
|
|
5151
|
+
return obj && Object.prototype.hasOwnProperty.call(obj, "applicability");
|
|
5152
|
+
}
|
|
5153
|
+
},
|
|
5290
5154
|
{
|
|
5291
5155
|
key: "applyResolver",
|
|
5292
5156
|
value: function applyResolver(resolver) {
|
|
@@ -5306,25 +5170,32 @@ var CommonTypesPlugin = function() {
|
|
|
5306
5170
|
{
|
|
5307
5171
|
key: "applyParser",
|
|
5308
5172
|
value: function applyParser(parser) {
|
|
5309
|
-
|
|
5310
|
-
|
|
5311
|
-
|
|
5312
|
-
}
|
|
5313
|
-
});
|
|
5314
|
-
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, determinedNodeType) {
|
|
5315
|
-
if (determinedNodeType === "applicability") {
|
|
5173
|
+
var _this = this;
|
|
5174
|
+
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, childOptions) {
|
|
5175
|
+
if (_this.isApplicability(obj)) {
|
|
5316
5176
|
var parsedApplicability = parser.parseObject((0, import_timm7.omit)(obj, "applicability"), nodeType, options);
|
|
5317
|
-
if (parsedApplicability
|
|
5318
|
-
|
|
5319
|
-
|
|
5320
|
-
|
|
5321
|
-
|
|
5322
|
-
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
return
|
|
5177
|
+
if (!parsedApplicability) {
|
|
5178
|
+
return childOptions ? [] : null;
|
|
5179
|
+
}
|
|
5180
|
+
var applicabilityNode = parser.createASTNode({
|
|
5181
|
+
type: "applicability",
|
|
5182
|
+
expression: obj.applicability,
|
|
5183
|
+
value: parsedApplicability
|
|
5184
|
+
}, obj);
|
|
5185
|
+
if (!applicabilityNode) {
|
|
5186
|
+
return childOptions ? [] : null;
|
|
5327
5187
|
}
|
|
5188
|
+
if (applicabilityNode.type === "applicability") {
|
|
5189
|
+
applicabilityNode.value.parent = applicabilityNode;
|
|
5190
|
+
}
|
|
5191
|
+
return childOptions ? [
|
|
5192
|
+
{
|
|
5193
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
5194
|
+
childOptions.key
|
|
5195
|
+
]),
|
|
5196
|
+
value: applicabilityNode
|
|
5197
|
+
}
|
|
5198
|
+
] : applicabilityNode;
|
|
5328
5199
|
}
|
|
5329
5200
|
});
|
|
5330
5201
|
}
|
|
@@ -5374,6 +5245,12 @@ var CommonTypesPlugin = function() {
|
|
|
5374
5245
|
return EMPTY_NODE;
|
|
5375
5246
|
}
|
|
5376
5247
|
},
|
|
5248
|
+
{
|
|
5249
|
+
key: "isSwitch",
|
|
5250
|
+
value: function isSwitch(obj) {
|
|
5251
|
+
return obj && (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch"));
|
|
5252
|
+
}
|
|
5253
|
+
},
|
|
5377
5254
|
{
|
|
5378
5255
|
key: "applyParser",
|
|
5379
5256
|
value: function applyParser(parser) {
|
|
@@ -5384,42 +5261,56 @@ var CommonTypesPlugin = function() {
|
|
|
5384
5261
|
}
|
|
5385
5262
|
return node;
|
|
5386
5263
|
});
|
|
5387
|
-
parser.hooks.
|
|
5388
|
-
if (
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5392
|
-
|
|
5393
|
-
if (determinedNodeType === "switch") {
|
|
5394
|
-
var dynamic = "dynamicSwitch" in obj;
|
|
5395
|
-
var switchContent = "dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;
|
|
5396
|
-
var cases = [];
|
|
5397
|
-
switchContent.forEach(function(switchCase) {
|
|
5264
|
+
parser.hooks.parseNode.tap("switch", function(obj, _nodeType, options, childOptions) {
|
|
5265
|
+
if (_this.isSwitch(obj) || childOptions && hasSwitchKey(childOptions.key)) {
|
|
5266
|
+
var objToParse = childOptions && hasSwitchKey(childOptions.key) ? _define_property({}, childOptions.key, obj) : obj;
|
|
5267
|
+
var dynamic = "dynamicSwitch" in objToParse;
|
|
5268
|
+
var switchContent = dynamic ? objToParse.dynamicSwitch : objToParse.staticSwitch;
|
|
5269
|
+
var cases = switchContent.map(function(switchCase) {
|
|
5398
5270
|
var switchCaseExpr = switchCase.case, switchBody = _object_without_properties(switchCase, [
|
|
5399
5271
|
"case"
|
|
5400
5272
|
]);
|
|
5401
5273
|
var value = parser.parseObject(switchBody, "value", options);
|
|
5402
5274
|
if (value) {
|
|
5403
|
-
|
|
5275
|
+
return {
|
|
5404
5276
|
case: switchCaseExpr,
|
|
5405
5277
|
value: value
|
|
5406
|
-
}
|
|
5278
|
+
};
|
|
5407
5279
|
}
|
|
5408
|
-
|
|
5409
|
-
|
|
5280
|
+
return;
|
|
5281
|
+
}).filter(Boolean);
|
|
5282
|
+
var switchAST = parser.createASTNode({
|
|
5410
5283
|
type: "switch",
|
|
5411
5284
|
dynamic: dynamic,
|
|
5412
5285
|
cases: cases
|
|
5413
|
-
},
|
|
5414
|
-
if (
|
|
5286
|
+
}, objToParse);
|
|
5287
|
+
if (!switchAST || switchAST.type === "empty") {
|
|
5288
|
+
return childOptions ? [] : null;
|
|
5289
|
+
}
|
|
5290
|
+
if (switchAST.type === "switch") {
|
|
5415
5291
|
switchAST.cases.forEach(function(sCase) {
|
|
5416
5292
|
sCase.value.parent = switchAST;
|
|
5417
5293
|
});
|
|
5418
5294
|
}
|
|
5419
|
-
if (
|
|
5420
|
-
|
|
5295
|
+
if (childOptions) {
|
|
5296
|
+
var _switchAST_children;
|
|
5297
|
+
var path = _to_consumable_array(childOptions.path).concat([
|
|
5298
|
+
childOptions.key
|
|
5299
|
+
]);
|
|
5300
|
+
var value = switchAST;
|
|
5301
|
+
if (switchAST.type === "value" && ((_switchAST_children = switchAST.children) === null || _switchAST_children === void 0 ? void 0 : _switchAST_children.length) === 1 && switchAST.value === void 0) {
|
|
5302
|
+
var firstChild = switchAST.children[0];
|
|
5303
|
+
path = _to_consumable_array(path).concat(_to_consumable_array(firstChild.path));
|
|
5304
|
+
value = firstChild.value;
|
|
5305
|
+
}
|
|
5306
|
+
return [
|
|
5307
|
+
{
|
|
5308
|
+
path: path,
|
|
5309
|
+
value: value
|
|
5310
|
+
}
|
|
5311
|
+
];
|
|
5421
5312
|
}
|
|
5422
|
-
return switchAST
|
|
5313
|
+
return switchAST;
|
|
5423
5314
|
}
|
|
5424
5315
|
});
|
|
5425
5316
|
}
|
|
@@ -5446,6 +5337,93 @@ var CommonTypesPlugin = function() {
|
|
|
5446
5337
|
]);
|
|
5447
5338
|
return SwitchPlugin;
|
|
5448
5339
|
}();
|
|
5340
|
+
var MultiNodePlugin = /*#__PURE__*/ function() {
|
|
5341
|
+
function MultiNodePlugin() {
|
|
5342
|
+
_class_call_check(this, MultiNodePlugin);
|
|
5343
|
+
}
|
|
5344
|
+
_create_class(MultiNodePlugin, [
|
|
5345
|
+
{
|
|
5346
|
+
key: "applyParser",
|
|
5347
|
+
value: function applyParser(parser) {
|
|
5348
|
+
parser.hooks.parseNode.tap("multi-node", function(obj, nodeType, options, childOptions) {
|
|
5349
|
+
if (childOptions && !hasTemplateKey(childOptions.key) && Array.isArray(obj)) {
|
|
5350
|
+
var values = obj.map(function(childVal) {
|
|
5351
|
+
return parser.parseObject(childVal, "value", options);
|
|
5352
|
+
}).filter(function(child) {
|
|
5353
|
+
return !!child;
|
|
5354
|
+
});
|
|
5355
|
+
if (!values.length) {
|
|
5356
|
+
return [];
|
|
5357
|
+
}
|
|
5358
|
+
var multiNode = parser.createASTNode({
|
|
5359
|
+
type: "multi-node",
|
|
5360
|
+
override: !hasTemplateValues(childOptions.parentObj, childOptions.key),
|
|
5361
|
+
values: values
|
|
5362
|
+
}, obj);
|
|
5363
|
+
if (!multiNode) {
|
|
5364
|
+
return [];
|
|
5365
|
+
}
|
|
5366
|
+
if (multiNode.type === "multi-node") {
|
|
5367
|
+
multiNode.values.forEach(function(v) {
|
|
5368
|
+
v.parent = multiNode;
|
|
5369
|
+
});
|
|
5370
|
+
}
|
|
5371
|
+
return [
|
|
5372
|
+
{
|
|
5373
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
5374
|
+
childOptions.key
|
|
5375
|
+
]),
|
|
5376
|
+
value: multiNode
|
|
5377
|
+
}
|
|
5378
|
+
];
|
|
5379
|
+
}
|
|
5380
|
+
});
|
|
5381
|
+
}
|
|
5382
|
+
},
|
|
5383
|
+
{
|
|
5384
|
+
key: "apply",
|
|
5385
|
+
value: function apply(view) {
|
|
5386
|
+
view.hooks.parser.tap("multi-node", this.applyParser.bind(this));
|
|
5387
|
+
}
|
|
5388
|
+
}
|
|
5389
|
+
]);
|
|
5390
|
+
return MultiNodePlugin;
|
|
5391
|
+
}();
|
|
5392
|
+
var AssetPlugin = /*#__PURE__*/ function() {
|
|
5393
|
+
function AssetPlugin() {
|
|
5394
|
+
_class_call_check(this, AssetPlugin);
|
|
5395
|
+
}
|
|
5396
|
+
_create_class(AssetPlugin, [
|
|
5397
|
+
{
|
|
5398
|
+
key: "applyParser",
|
|
5399
|
+
value: function applyParser(parser) {
|
|
5400
|
+
parser.hooks.parseNode.tap("asset", function(obj, nodeType, options, childOptions) {
|
|
5401
|
+
if ((childOptions === null || childOptions === void 0 ? void 0 : childOptions.key) === "asset" && typeof obj === "object") {
|
|
5402
|
+
var assetAST = parser.parseObject(obj, "asset", options);
|
|
5403
|
+
if (!assetAST) {
|
|
5404
|
+
return [];
|
|
5405
|
+
}
|
|
5406
|
+
return [
|
|
5407
|
+
{
|
|
5408
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
5409
|
+
childOptions.key
|
|
5410
|
+
]),
|
|
5411
|
+
value: assetAST
|
|
5412
|
+
}
|
|
5413
|
+
];
|
|
5414
|
+
}
|
|
5415
|
+
});
|
|
5416
|
+
}
|
|
5417
|
+
},
|
|
5418
|
+
{
|
|
5419
|
+
key: "apply",
|
|
5420
|
+
value: function apply(view) {
|
|
5421
|
+
view.hooks.parser.tap("asset", this.applyParser.bind(this));
|
|
5422
|
+
}
|
|
5423
|
+
}
|
|
5424
|
+
]);
|
|
5425
|
+
return AssetPlugin;
|
|
5426
|
+
}();
|
|
5449
5427
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
5450
5428
|
function FlowInstance(id, flow, options) {
|
|
5451
5429
|
_class_call_check(this, FlowInstance);
|
|
@@ -7148,12 +7126,14 @@ var CommonTypesPlugin = function() {
|
|
|
7148
7126
|
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
7149
7127
|
viewController.hooks.view.tap(_this.name, function(view) {
|
|
7150
7128
|
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
7129
|
+
new AssetPlugin().apply(view);
|
|
7151
7130
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
7152
7131
|
new ApplicabilityPlugin().apply(view);
|
|
7153
7132
|
new StringResolverPlugin().apply(view);
|
|
7154
7133
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7155
7134
|
templatePlugin.apply(view);
|
|
7156
7135
|
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
7136
|
+
new MultiNodePlugin().apply(view);
|
|
7157
7137
|
});
|
|
7158
7138
|
});
|
|
7159
7139
|
}
|