@player-ui/common-types-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.
|
@@ -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";
|
|
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;
|
|
@@ -4384,7 +4392,6 @@ var CommonTypesPlugin = function() {
|
|
|
4384
4392
|
* If undefined, the original value is used.
|
|
4385
4393
|
* If null, we ignore this node all together
|
|
4386
4394
|
*/ onCreateASTNode: new SyncWaterfallHook(),
|
|
4387
|
-
determineNodeType: new SyncBailHook(),
|
|
4388
4395
|
parseNode: new SyncBailHook()
|
|
4389
4396
|
};
|
|
4390
4397
|
}
|
|
@@ -4399,21 +4406,6 @@ var CommonTypesPlugin = function() {
|
|
|
4399
4406
|
return viewNode;
|
|
4400
4407
|
}
|
|
4401
4408
|
},
|
|
4402
|
-
{
|
|
4403
|
-
key: "parseAsync",
|
|
4404
|
-
value: function parseAsync(obj, type, options) {
|
|
4405
|
-
var parsedAsync = this.parseObject((0, import_timm5.omit)(obj, "async"), type, options);
|
|
4406
|
-
var parsedNodeId = getNodeID(parsedAsync);
|
|
4407
|
-
if (parsedAsync !== null && parsedNodeId) {
|
|
4408
|
-
return this.createASTNode({
|
|
4409
|
-
id: parsedNodeId,
|
|
4410
|
-
type: "async",
|
|
4411
|
-
value: parsedAsync
|
|
4412
|
-
}, obj);
|
|
4413
|
-
}
|
|
4414
|
-
return null;
|
|
4415
|
-
}
|
|
4416
|
-
},
|
|
4417
4409
|
{
|
|
4418
4410
|
key: "createASTNode",
|
|
4419
4411
|
value: function createASTNode(node, value) {
|
|
@@ -4424,25 +4416,6 @@ var CommonTypesPlugin = function() {
|
|
|
4424
4416
|
return tapped;
|
|
4425
4417
|
}
|
|
4426
4418
|
},
|
|
4427
|
-
{
|
|
4428
|
-
/**
|
|
4429
|
-
* Checks if there are templated values in the object
|
|
4430
|
-
*
|
|
4431
|
-
* @param obj - The Parsed Object to check to see if we have a template array type for
|
|
4432
|
-
* @param localKey - The key being checked
|
|
4433
|
-
*/ key: "hasTemplateValues",
|
|
4434
|
-
value: function hasTemplateValues(obj, localKey) {
|
|
4435
|
-
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) {
|
|
4436
|
-
return tmpl.output === localKey;
|
|
4437
|
-
});
|
|
4438
|
-
}
|
|
4439
|
-
},
|
|
4440
|
-
{
|
|
4441
|
-
key: "hasSwitchKey",
|
|
4442
|
-
value: function hasSwitchKey(localKey) {
|
|
4443
|
-
return localKey === "staticSwitch";
|
|
4444
|
-
}
|
|
4445
|
-
},
|
|
4446
4419
|
{
|
|
4447
4420
|
key: "parseObject",
|
|
4448
4421
|
value: function parseObject(obj) {
|
|
@@ -4450,12 +4423,9 @@ var CommonTypesPlugin = function() {
|
|
|
4450
4423
|
templateDepth: 0
|
|
4451
4424
|
};
|
|
4452
4425
|
var _this = this;
|
|
4453
|
-
var
|
|
4454
|
-
if (
|
|
4455
|
-
|
|
4456
|
-
if (parsedNode) {
|
|
4457
|
-
return parsedNode;
|
|
4458
|
-
}
|
|
4426
|
+
var parsedNode = this.hooks.parseNode.call(obj, type, options);
|
|
4427
|
+
if (parsedNode || parsedNode === null) {
|
|
4428
|
+
return parsedNode;
|
|
4459
4429
|
}
|
|
4460
4430
|
var parseLocalObject = function(currentValue, objToParse) {
|
|
4461
4431
|
var path = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
@@ -4485,166 +4455,42 @@ var CommonTypesPlugin = function() {
|
|
|
4485
4455
|
value: currentValue
|
|
4486
4456
|
};
|
|
4487
4457
|
var newValue = objEntries.reduce(function(accumulation, current) {
|
|
4488
|
-
var
|
|
4489
|
-
|
|
4490
|
-
]);
|
|
4458
|
+
var value2 = accumulation.value;
|
|
4459
|
+
var children2 = accumulation.children;
|
|
4491
4460
|
var _current = _sliced_to_array(current, 2), localKey = _current[0], localValue = _current[1];
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
]),
|
|
4501
|
-
value: assetAST
|
|
4502
|
-
}
|
|
4503
|
-
])
|
|
4504
|
-
});
|
|
4505
|
-
}
|
|
4506
|
-
} else if (_this.hooks.determineNodeType.call(localKey) === "template" && Array.isArray(localValue)) {
|
|
4507
|
-
var templateChildren = localValue.map(function(template) {
|
|
4508
|
-
var _options_templateDepth, _template_dynamic;
|
|
4509
|
-
var templateAST = _this.hooks.onCreateASTNode.call({
|
|
4510
|
-
type: "template",
|
|
4511
|
-
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
4512
|
-
data: template.data,
|
|
4513
|
-
template: template.value,
|
|
4514
|
-
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
4515
|
-
}, template);
|
|
4516
|
-
if ((templateAST === null || templateAST === void 0 ? void 0 : templateAST.type) === "multi-node") {
|
|
4517
|
-
templateAST.values.forEach(function(v) {
|
|
4518
|
-
v.parent = templateAST;
|
|
4519
|
-
});
|
|
4520
|
-
}
|
|
4521
|
-
if (templateAST) {
|
|
4522
|
-
return {
|
|
4523
|
-
path: _to_consumable_array(path).concat([
|
|
4524
|
-
template.output
|
|
4525
|
-
]),
|
|
4526
|
-
value: templateAST
|
|
4527
|
-
};
|
|
4528
|
-
}
|
|
4529
|
-
return;
|
|
4530
|
-
}).filter(function(element) {
|
|
4531
|
-
return !!element;
|
|
4532
|
-
});
|
|
4533
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4534
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(templateChildren))
|
|
4535
|
-
});
|
|
4536
|
-
} else if (localValue && _this.hooks.determineNodeType.call(localValue) === "switch" || _this.hasSwitchKey(localKey)) {
|
|
4537
|
-
var _localSwitch_children;
|
|
4538
|
-
var localSwitch = _this.hooks.parseNode.call(_this.hasSwitchKey(localKey) ? _define_property({}, localKey, localValue) : localValue, "value", options, "switch");
|
|
4539
|
-
if (localSwitch && localSwitch.type === "value" && ((_localSwitch_children = localSwitch.children) === null || _localSwitch_children === void 0 ? void 0 : _localSwitch_children.length) === 1 && localSwitch.value === void 0) {
|
|
4540
|
-
var firstChild = localSwitch.children[0];
|
|
4541
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4542
|
-
children: _to_consumable_array(children2).concat([
|
|
4543
|
-
{
|
|
4544
|
-
path: _to_consumable_array(path).concat([
|
|
4545
|
-
localKey
|
|
4546
|
-
], _to_consumable_array(firstChild.path)),
|
|
4547
|
-
value: firstChild.value
|
|
4548
|
-
}
|
|
4549
|
-
])
|
|
4550
|
-
});
|
|
4551
|
-
}
|
|
4552
|
-
if (localSwitch) {
|
|
4553
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4554
|
-
children: _to_consumable_array(children2).concat([
|
|
4555
|
-
{
|
|
4556
|
-
path: _to_consumable_array(path).concat([
|
|
4557
|
-
localKey
|
|
4558
|
-
]),
|
|
4559
|
-
value: localSwitch
|
|
4560
|
-
}
|
|
4561
|
-
])
|
|
4562
|
-
});
|
|
4563
|
-
}
|
|
4564
|
-
} else if (localValue && hasAsync(localValue)) {
|
|
4565
|
-
var localAsync = _this.parseAsync(localValue, "value", options);
|
|
4566
|
-
if (localAsync) {
|
|
4567
|
-
children2.push({
|
|
4568
|
-
path: _to_consumable_array(path).concat([
|
|
4569
|
-
localKey
|
|
4570
|
-
]),
|
|
4571
|
-
value: localAsync
|
|
4572
|
-
});
|
|
4573
|
-
}
|
|
4574
|
-
} else if (localValue && Array.isArray(localValue)) {
|
|
4575
|
-
var childValues = localValue.map(function(childVal) {
|
|
4576
|
-
return _this.parseObject(childVal, "value", options);
|
|
4577
|
-
}).filter(function(child) {
|
|
4578
|
-
return !!child;
|
|
4579
|
-
});
|
|
4580
|
-
if (childValues.length > 0) {
|
|
4581
|
-
var multiNode = _this.hooks.onCreateASTNode.call({
|
|
4582
|
-
type: "multi-node",
|
|
4583
|
-
override: !_this.hasTemplateValues(localObj, localKey),
|
|
4584
|
-
values: childValues
|
|
4585
|
-
}, localValue);
|
|
4586
|
-
if ((multiNode === null || multiNode === void 0 ? void 0 : multiNode.type) === "multi-node") {
|
|
4587
|
-
multiNode.values.forEach(function(v) {
|
|
4588
|
-
v.parent = multiNode;
|
|
4589
|
-
});
|
|
4590
|
-
}
|
|
4591
|
-
if (multiNode) {
|
|
4592
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
4593
|
-
children: _to_consumable_array(children2).concat([
|
|
4594
|
-
{
|
|
4595
|
-
path: _to_consumable_array(path).concat([
|
|
4596
|
-
localKey
|
|
4597
|
-
]),
|
|
4598
|
-
value: multiNode
|
|
4599
|
-
}
|
|
4600
|
-
])
|
|
4601
|
-
});
|
|
4602
|
-
}
|
|
4603
|
-
}
|
|
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));
|
|
4604
4469
|
} else if (localValue && typeof localValue === "object") {
|
|
4605
|
-
var
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
{
|
|
4612
|
-
path: _to_consumable_array(path).concat([
|
|
4613
|
-
localKey
|
|
4614
|
-
]),
|
|
4615
|
-
value: parsedNode
|
|
4616
|
-
}
|
|
4617
|
-
])
|
|
4618
|
-
});
|
|
4619
|
-
}
|
|
4620
|
-
} else {
|
|
4621
|
-
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
|
|
4622
|
-
localKey
|
|
4623
|
-
]));
|
|
4624
|
-
return {
|
|
4625
|
-
value: result.value,
|
|
4626
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(result.children))
|
|
4627
|
-
};
|
|
4628
|
-
}
|
|
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));
|
|
4629
4476
|
} else {
|
|
4630
|
-
|
|
4477
|
+
value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(path).concat([
|
|
4631
4478
|
localKey
|
|
4632
4479
|
]), localValue);
|
|
4633
|
-
return {
|
|
4634
|
-
children: children2,
|
|
4635
|
-
value: value2
|
|
4636
|
-
};
|
|
4637
4480
|
}
|
|
4638
|
-
return
|
|
4481
|
+
return {
|
|
4482
|
+
value: value2,
|
|
4483
|
+
children: children2
|
|
4484
|
+
};
|
|
4639
4485
|
}, defaultValue);
|
|
4640
4486
|
return newValue;
|
|
4641
4487
|
};
|
|
4642
4488
|
var _parseLocalObject = parseLocalObject(void 0, obj), value = _parseLocalObject.value, children = _parseLocalObject.children;
|
|
4643
|
-
var baseAst = value === void 0 && children.length
|
|
4489
|
+
var baseAst = value === void 0 && !children.length ? void 0 : {
|
|
4644
4490
|
type: type,
|
|
4645
4491
|
value: value
|
|
4646
4492
|
};
|
|
4647
|
-
if (baseAst
|
|
4493
|
+
if (baseAst && children.length) {
|
|
4648
4494
|
var parent = baseAst;
|
|
4649
4495
|
parent.children = children;
|
|
4650
4496
|
children.forEach(function(child) {
|
|
@@ -5132,24 +4978,30 @@ var CommonTypesPlugin = function() {
|
|
|
5132
4978
|
}
|
|
5133
4979
|
return node;
|
|
5134
4980
|
});
|
|
5135
|
-
parser.hooks.
|
|
5136
|
-
if (
|
|
5137
|
-
return
|
|
5138
|
-
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
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);
|
|
5153
5005
|
}
|
|
5154
5006
|
});
|
|
5155
5007
|
}
|
|
@@ -5293,6 +5145,12 @@ var CommonTypesPlugin = function() {
|
|
|
5293
5145
|
_class_call_check(this, ApplicabilityPlugin);
|
|
5294
5146
|
}
|
|
5295
5147
|
_create_class(ApplicabilityPlugin, [
|
|
5148
|
+
{
|
|
5149
|
+
key: "isApplicability",
|
|
5150
|
+
value: function isApplicability(obj) {
|
|
5151
|
+
return obj && Object.prototype.hasOwnProperty.call(obj, "applicability");
|
|
5152
|
+
}
|
|
5153
|
+
},
|
|
5296
5154
|
{
|
|
5297
5155
|
key: "applyResolver",
|
|
5298
5156
|
value: function applyResolver(resolver) {
|
|
@@ -5312,25 +5170,32 @@ var CommonTypesPlugin = function() {
|
|
|
5312
5170
|
{
|
|
5313
5171
|
key: "applyParser",
|
|
5314
5172
|
value: function applyParser(parser) {
|
|
5315
|
-
|
|
5316
|
-
|
|
5317
|
-
|
|
5318
|
-
}
|
|
5319
|
-
});
|
|
5320
|
-
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, determinedNodeType) {
|
|
5321
|
-
if (determinedNodeType === "applicability") {
|
|
5173
|
+
var _this = this;
|
|
5174
|
+
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, childOptions) {
|
|
5175
|
+
if (_this.isApplicability(obj)) {
|
|
5322
5176
|
var parsedApplicability = parser.parseObject((0, import_timm7.omit)(obj, "applicability"), nodeType, options);
|
|
5323
|
-
if (parsedApplicability
|
|
5324
|
-
|
|
5325
|
-
type: "applicability",
|
|
5326
|
-
expression: obj.applicability,
|
|
5327
|
-
value: parsedApplicability
|
|
5328
|
-
}, obj);
|
|
5329
|
-
if ((applicabilityNode === null || applicabilityNode === void 0 ? void 0 : applicabilityNode.type) === "applicability") {
|
|
5330
|
-
applicabilityNode.value.parent = applicabilityNode;
|
|
5331
|
-
}
|
|
5332
|
-
return applicabilityNode;
|
|
5177
|
+
if (!parsedApplicability) {
|
|
5178
|
+
return childOptions ? [] : null;
|
|
5333
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;
|
|
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;
|
|
5334
5199
|
}
|
|
5335
5200
|
});
|
|
5336
5201
|
}
|
|
@@ -5380,6 +5245,12 @@ var CommonTypesPlugin = function() {
|
|
|
5380
5245
|
return EMPTY_NODE;
|
|
5381
5246
|
}
|
|
5382
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
|
+
},
|
|
5383
5254
|
{
|
|
5384
5255
|
key: "applyParser",
|
|
5385
5256
|
value: function applyParser(parser) {
|
|
@@ -5390,42 +5261,56 @@ var CommonTypesPlugin = function() {
|
|
|
5390
5261
|
}
|
|
5391
5262
|
return node;
|
|
5392
5263
|
});
|
|
5393
|
-
parser.hooks.
|
|
5394
|
-
if (
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
if (determinedNodeType === "switch") {
|
|
5400
|
-
var dynamic = "dynamicSwitch" in obj;
|
|
5401
|
-
var switchContent = "dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;
|
|
5402
|
-
var cases = [];
|
|
5403
|
-
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) {
|
|
5404
5270
|
var switchCaseExpr = switchCase.case, switchBody = _object_without_properties(switchCase, [
|
|
5405
5271
|
"case"
|
|
5406
5272
|
]);
|
|
5407
5273
|
var value = parser.parseObject(switchBody, "value", options);
|
|
5408
5274
|
if (value) {
|
|
5409
|
-
|
|
5275
|
+
return {
|
|
5410
5276
|
case: switchCaseExpr,
|
|
5411
5277
|
value: value
|
|
5412
|
-
}
|
|
5278
|
+
};
|
|
5413
5279
|
}
|
|
5414
|
-
|
|
5415
|
-
|
|
5280
|
+
return;
|
|
5281
|
+
}).filter(Boolean);
|
|
5282
|
+
var switchAST = parser.createASTNode({
|
|
5416
5283
|
type: "switch",
|
|
5417
5284
|
dynamic: dynamic,
|
|
5418
5285
|
cases: cases
|
|
5419
|
-
},
|
|
5420
|
-
if (
|
|
5286
|
+
}, objToParse);
|
|
5287
|
+
if (!switchAST || switchAST.type === "empty") {
|
|
5288
|
+
return childOptions ? [] : null;
|
|
5289
|
+
}
|
|
5290
|
+
if (switchAST.type === "switch") {
|
|
5421
5291
|
switchAST.cases.forEach(function(sCase) {
|
|
5422
5292
|
sCase.value.parent = switchAST;
|
|
5423
5293
|
});
|
|
5424
5294
|
}
|
|
5425
|
-
if (
|
|
5426
|
-
|
|
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
|
+
];
|
|
5427
5312
|
}
|
|
5428
|
-
return switchAST
|
|
5313
|
+
return switchAST;
|
|
5429
5314
|
}
|
|
5430
5315
|
});
|
|
5431
5316
|
}
|
|
@@ -5452,6 +5337,93 @@ var CommonTypesPlugin = function() {
|
|
|
5452
5337
|
]);
|
|
5453
5338
|
return SwitchPlugin;
|
|
5454
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
|
+
}();
|
|
5455
5427
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
5456
5428
|
function FlowInstance(id, flow, options) {
|
|
5457
5429
|
_class_call_check(this, FlowInstance);
|
|
@@ -7154,12 +7126,14 @@ var CommonTypesPlugin = function() {
|
|
|
7154
7126
|
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
7155
7127
|
viewController.hooks.view.tap(_this.name, function(view) {
|
|
7156
7128
|
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
7129
|
+
new AssetPlugin().apply(view);
|
|
7157
7130
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
7158
7131
|
new ApplicabilityPlugin().apply(view);
|
|
7159
7132
|
new StringResolverPlugin().apply(view);
|
|
7160
7133
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
7161
7134
|
templatePlugin.apply(view);
|
|
7162
7135
|
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
7136
|
+
new MultiNodePlugin().apply(view);
|
|
7163
7137
|
});
|
|
7164
7138
|
});
|
|
7165
7139
|
}
|