@player-ui/markdown-plugin 0.8.0-next.4 → 0.8.0-next.6
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 MarkdownPlugin = 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(node2) {
|
|
1361
1369
|
var _node2_value;
|
|
@@ -5964,7 +5972,7 @@ var MarkdownPlugin = function() {
|
|
|
5964
5972
|
exports.merge = merge;
|
|
5965
5973
|
exports.mergeDeep = mergeDeep;
|
|
5966
5974
|
exports.mergeIn = mergeIn;
|
|
5967
|
-
exports.omit =
|
|
5975
|
+
exports.omit = omit3;
|
|
5968
5976
|
exports.addDefaults = addDefaults;
|
|
5969
5977
|
exports.default = void 0;
|
|
5970
5978
|
var INVALID_ARGS = "INVALID_ARGS";
|
|
@@ -6138,7 +6146,7 @@ var MarkdownPlugin = function() {
|
|
|
6138
6146
|
}
|
|
6139
6147
|
return setIn8(a, path, nextVal);
|
|
6140
6148
|
}
|
|
6141
|
-
function
|
|
6149
|
+
function omit3(obj, attrs) {
|
|
6142
6150
|
var omitList = Array.isArray(attrs) ? attrs : [
|
|
6143
6151
|
attrs
|
|
6144
6152
|
];
|
|
@@ -6224,7 +6232,7 @@ var MarkdownPlugin = function() {
|
|
|
6224
6232
|
merge: merge,
|
|
6225
6233
|
mergeDeep: mergeDeep,
|
|
6226
6234
|
mergeIn: mergeIn,
|
|
6227
|
-
omit:
|
|
6235
|
+
omit: omit3,
|
|
6228
6236
|
addDefaults: addDefaults
|
|
6229
6237
|
};
|
|
6230
6238
|
var _default = timm;
|
|
@@ -8602,7 +8610,6 @@ var MarkdownPlugin = function() {
|
|
|
8602
8610
|
* If undefined, the original value is used.
|
|
8603
8611
|
* If null, we ignore this node all together
|
|
8604
8612
|
*/ onCreateASTNode: new SyncWaterfallHook(),
|
|
8605
|
-
determineNodeType: new SyncBailHook(),
|
|
8606
8613
|
parseNode: new SyncBailHook()
|
|
8607
8614
|
};
|
|
8608
8615
|
}
|
|
@@ -8617,21 +8624,6 @@ var MarkdownPlugin = function() {
|
|
|
8617
8624
|
return viewNode;
|
|
8618
8625
|
}
|
|
8619
8626
|
},
|
|
8620
|
-
{
|
|
8621
|
-
key: "parseAsync",
|
|
8622
|
-
value: function parseAsync(obj, type, options) {
|
|
8623
|
-
var parsedAsync = this.parseObject((0, import_timm5.omit)(obj, "async"), type, options);
|
|
8624
|
-
var parsedNodeId = getNodeID(parsedAsync);
|
|
8625
|
-
if (parsedAsync !== null && parsedNodeId) {
|
|
8626
|
-
return this.createASTNode({
|
|
8627
|
-
id: parsedNodeId,
|
|
8628
|
-
type: "async",
|
|
8629
|
-
value: parsedAsync
|
|
8630
|
-
}, obj);
|
|
8631
|
-
}
|
|
8632
|
-
return null;
|
|
8633
|
-
}
|
|
8634
|
-
},
|
|
8635
8627
|
{
|
|
8636
8628
|
key: "createASTNode",
|
|
8637
8629
|
value: function createASTNode(node2, value) {
|
|
@@ -8642,25 +8634,6 @@ var MarkdownPlugin = function() {
|
|
|
8642
8634
|
return tapped;
|
|
8643
8635
|
}
|
|
8644
8636
|
},
|
|
8645
|
-
{
|
|
8646
|
-
/**
|
|
8647
|
-
* Checks if there are templated values in the object
|
|
8648
|
-
*
|
|
8649
|
-
* @param obj - The Parsed Object to check to see if we have a template array type for
|
|
8650
|
-
* @param localKey - The key being checked
|
|
8651
|
-
*/ key: "hasTemplateValues",
|
|
8652
|
-
value: function hasTemplateValues(obj, localKey) {
|
|
8653
|
-
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) {
|
|
8654
|
-
return tmpl.output === localKey;
|
|
8655
|
-
});
|
|
8656
|
-
}
|
|
8657
|
-
},
|
|
8658
|
-
{
|
|
8659
|
-
key: "hasSwitchKey",
|
|
8660
|
-
value: function hasSwitchKey(localKey) {
|
|
8661
|
-
return localKey === "staticSwitch";
|
|
8662
|
-
}
|
|
8663
|
-
},
|
|
8664
8637
|
{
|
|
8665
8638
|
key: "parseObject",
|
|
8666
8639
|
value: function parseObject(obj) {
|
|
@@ -8668,12 +8641,9 @@ var MarkdownPlugin = function() {
|
|
|
8668
8641
|
templateDepth: 0
|
|
8669
8642
|
};
|
|
8670
8643
|
var _this = this;
|
|
8671
|
-
var
|
|
8672
|
-
if (
|
|
8673
|
-
|
|
8674
|
-
if (parsedNode) {
|
|
8675
|
-
return parsedNode;
|
|
8676
|
-
}
|
|
8644
|
+
var parsedNode = this.hooks.parseNode.call(obj, type, options);
|
|
8645
|
+
if (parsedNode || parsedNode === null) {
|
|
8646
|
+
return parsedNode;
|
|
8677
8647
|
}
|
|
8678
8648
|
var parseLocalObject = function(currentValue, objToParse) {
|
|
8679
8649
|
var path = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : [];
|
|
@@ -8703,166 +8673,42 @@ var MarkdownPlugin = function() {
|
|
|
8703
8673
|
value: currentValue
|
|
8704
8674
|
};
|
|
8705
8675
|
var newValue = objEntries.reduce(function(accumulation, current) {
|
|
8706
|
-
var
|
|
8707
|
-
|
|
8708
|
-
]);
|
|
8676
|
+
var value2 = accumulation.value;
|
|
8677
|
+
var children2 = accumulation.children;
|
|
8709
8678
|
var _current = _sliced_to_array(current, 2), localKey = _current[0], localValue = _current[1];
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
|
|
8713
|
-
|
|
8714
|
-
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
]),
|
|
8719
|
-
value: assetAST
|
|
8720
|
-
}
|
|
8721
|
-
])
|
|
8722
|
-
});
|
|
8723
|
-
}
|
|
8724
|
-
} else if (_this.hooks.determineNodeType.call(localKey) === "template" && Array.isArray(localValue)) {
|
|
8725
|
-
var templateChildren = localValue.map(function(template) {
|
|
8726
|
-
var _options_templateDepth, _template_dynamic;
|
|
8727
|
-
var templateAST = _this.hooks.onCreateASTNode.call({
|
|
8728
|
-
type: "template",
|
|
8729
|
-
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
8730
|
-
data: template.data,
|
|
8731
|
-
template: template.value,
|
|
8732
|
-
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
8733
|
-
}, template);
|
|
8734
|
-
if ((templateAST === null || templateAST === void 0 ? void 0 : templateAST.type) === "multi-node") {
|
|
8735
|
-
templateAST.values.forEach(function(v) {
|
|
8736
|
-
v.parent = templateAST;
|
|
8737
|
-
});
|
|
8738
|
-
}
|
|
8739
|
-
if (templateAST) {
|
|
8740
|
-
return {
|
|
8741
|
-
path: _to_consumable_array(path).concat([
|
|
8742
|
-
template.output
|
|
8743
|
-
]),
|
|
8744
|
-
value: templateAST
|
|
8745
|
-
};
|
|
8746
|
-
}
|
|
8747
|
-
return;
|
|
8748
|
-
}).filter(function(element) {
|
|
8749
|
-
return !!element;
|
|
8750
|
-
});
|
|
8751
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
8752
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(templateChildren))
|
|
8753
|
-
});
|
|
8754
|
-
} else if (localValue && _this.hooks.determineNodeType.call(localValue) === "switch" || _this.hasSwitchKey(localKey)) {
|
|
8755
|
-
var _localSwitch_children;
|
|
8756
|
-
var localSwitch = _this.hooks.parseNode.call(_this.hasSwitchKey(localKey) ? _define_property({}, localKey, localValue) : localValue, "value", options, "switch");
|
|
8757
|
-
if (localSwitch && localSwitch.type === "value" && ((_localSwitch_children = localSwitch.children) === null || _localSwitch_children === void 0 ? void 0 : _localSwitch_children.length) === 1 && localSwitch.value === void 0) {
|
|
8758
|
-
var firstChild = localSwitch.children[0];
|
|
8759
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
8760
|
-
children: _to_consumable_array(children2).concat([
|
|
8761
|
-
{
|
|
8762
|
-
path: _to_consumable_array(path).concat([
|
|
8763
|
-
localKey
|
|
8764
|
-
], _to_consumable_array(firstChild.path)),
|
|
8765
|
-
value: firstChild.value
|
|
8766
|
-
}
|
|
8767
|
-
])
|
|
8768
|
-
});
|
|
8769
|
-
}
|
|
8770
|
-
if (localSwitch) {
|
|
8771
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
8772
|
-
children: _to_consumable_array(children2).concat([
|
|
8773
|
-
{
|
|
8774
|
-
path: _to_consumable_array(path).concat([
|
|
8775
|
-
localKey
|
|
8776
|
-
]),
|
|
8777
|
-
value: localSwitch
|
|
8778
|
-
}
|
|
8779
|
-
])
|
|
8780
|
-
});
|
|
8781
|
-
}
|
|
8782
|
-
} else if (localValue && hasAsync(localValue)) {
|
|
8783
|
-
var localAsync = _this.parseAsync(localValue, "value", options);
|
|
8784
|
-
if (localAsync) {
|
|
8785
|
-
children2.push({
|
|
8786
|
-
path: _to_consumable_array(path).concat([
|
|
8787
|
-
localKey
|
|
8788
|
-
]),
|
|
8789
|
-
value: localAsync
|
|
8790
|
-
});
|
|
8791
|
-
}
|
|
8792
|
-
} else if (localValue && Array.isArray(localValue)) {
|
|
8793
|
-
var childValues = localValue.map(function(childVal) {
|
|
8794
|
-
return _this.parseObject(childVal, "value", options);
|
|
8795
|
-
}).filter(function(child) {
|
|
8796
|
-
return !!child;
|
|
8797
|
-
});
|
|
8798
|
-
if (childValues.length > 0) {
|
|
8799
|
-
var multiNode = _this.hooks.onCreateASTNode.call({
|
|
8800
|
-
type: "multi-node",
|
|
8801
|
-
override: !_this.hasTemplateValues(localObj, localKey),
|
|
8802
|
-
values: childValues
|
|
8803
|
-
}, localValue);
|
|
8804
|
-
if ((multiNode === null || multiNode === void 0 ? void 0 : multiNode.type) === "multi-node") {
|
|
8805
|
-
multiNode.values.forEach(function(v) {
|
|
8806
|
-
v.parent = multiNode;
|
|
8807
|
-
});
|
|
8808
|
-
}
|
|
8809
|
-
if (multiNode) {
|
|
8810
|
-
return _object_spread_props(_object_spread({}, rest), {
|
|
8811
|
-
children: _to_consumable_array(children2).concat([
|
|
8812
|
-
{
|
|
8813
|
-
path: _to_consumable_array(path).concat([
|
|
8814
|
-
localKey
|
|
8815
|
-
]),
|
|
8816
|
-
value: multiNode
|
|
8817
|
-
}
|
|
8818
|
-
])
|
|
8819
|
-
});
|
|
8820
|
-
}
|
|
8821
|
-
}
|
|
8679
|
+
var newChildren = _this.hooks.parseNode.call(localValue, "value", options, {
|
|
8680
|
+
path: path,
|
|
8681
|
+
key: localKey,
|
|
8682
|
+
parentObj: localObj
|
|
8683
|
+
});
|
|
8684
|
+
if (newChildren) {
|
|
8685
|
+
var _children2;
|
|
8686
|
+
(_children2 = children2).push.apply(_children2, _to_consumable_array(newChildren));
|
|
8822
8687
|
} else if (localValue && typeof localValue === "object") {
|
|
8823
|
-
var
|
|
8824
|
-
|
|
8825
|
-
|
|
8826
|
-
|
|
8827
|
-
|
|
8828
|
-
|
|
8829
|
-
{
|
|
8830
|
-
path: _to_consumable_array(path).concat([
|
|
8831
|
-
localKey
|
|
8832
|
-
]),
|
|
8833
|
-
value: parsedNode
|
|
8834
|
-
}
|
|
8835
|
-
])
|
|
8836
|
-
});
|
|
8837
|
-
}
|
|
8838
|
-
} else {
|
|
8839
|
-
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
|
|
8840
|
-
localKey
|
|
8841
|
-
]));
|
|
8842
|
-
return {
|
|
8843
|
-
value: result.value,
|
|
8844
|
-
children: _to_consumable_array(children2).concat(_to_consumable_array(result.children))
|
|
8845
|
-
};
|
|
8846
|
-
}
|
|
8688
|
+
var _children21;
|
|
8689
|
+
var result = parseLocalObject(accumulation.value, localValue, _to_consumable_array(path).concat([
|
|
8690
|
+
localKey
|
|
8691
|
+
]));
|
|
8692
|
+
value2 = result.value;
|
|
8693
|
+
(_children21 = children2).push.apply(_children21, _to_consumable_array(result.children));
|
|
8847
8694
|
} else {
|
|
8848
|
-
|
|
8695
|
+
value2 = (0, import_timm5.setIn)(accumulation.value, _to_consumable_array(path).concat([
|
|
8849
8696
|
localKey
|
|
8850
8697
|
]), localValue);
|
|
8851
|
-
return {
|
|
8852
|
-
children: children2,
|
|
8853
|
-
value: value2
|
|
8854
|
-
};
|
|
8855
8698
|
}
|
|
8856
|
-
return
|
|
8699
|
+
return {
|
|
8700
|
+
value: value2,
|
|
8701
|
+
children: children2
|
|
8702
|
+
};
|
|
8857
8703
|
}, defaultValue);
|
|
8858
8704
|
return newValue;
|
|
8859
8705
|
};
|
|
8860
8706
|
var _parseLocalObject = parseLocalObject(void 0, obj), value = _parseLocalObject.value, children = _parseLocalObject.children;
|
|
8861
|
-
var baseAst = value === void 0 && children.length
|
|
8707
|
+
var baseAst = value === void 0 && !children.length ? void 0 : {
|
|
8862
8708
|
type: type,
|
|
8863
8709
|
value: value
|
|
8864
8710
|
};
|
|
8865
|
-
if (baseAst
|
|
8711
|
+
if (baseAst && children.length) {
|
|
8866
8712
|
var parent = baseAst;
|
|
8867
8713
|
parent.children = children;
|
|
8868
8714
|
children.forEach(function(child) {
|
|
@@ -9350,24 +9196,30 @@ var MarkdownPlugin = function() {
|
|
|
9350
9196
|
}
|
|
9351
9197
|
return node2;
|
|
9352
9198
|
});
|
|
9353
|
-
parser.hooks.
|
|
9354
|
-
if (
|
|
9355
|
-
return
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
|
|
9368
|
-
|
|
9369
|
-
|
|
9370
|
-
|
|
9199
|
+
parser.hooks.parseNode.tap("template", function(obj, _nodeType, options, childOptions) {
|
|
9200
|
+
if (childOptions && hasTemplateKey(childOptions.key)) {
|
|
9201
|
+
return obj.map(function(template) {
|
|
9202
|
+
var _options_templateDepth, _template_dynamic;
|
|
9203
|
+
var templateAST = parser.createASTNode({
|
|
9204
|
+
type: "template",
|
|
9205
|
+
depth: (_options_templateDepth = options.templateDepth) !== null && _options_templateDepth !== void 0 ? _options_templateDepth : 0,
|
|
9206
|
+
data: template.data,
|
|
9207
|
+
template: template.value,
|
|
9208
|
+
dynamic: (_template_dynamic = template.dynamic) !== null && _template_dynamic !== void 0 ? _template_dynamic : false
|
|
9209
|
+
}, template);
|
|
9210
|
+
if (!templateAST) return;
|
|
9211
|
+
if (templateAST.type === "multi-node") {
|
|
9212
|
+
templateAST.values.forEach(function(v) {
|
|
9213
|
+
v.parent = templateAST;
|
|
9214
|
+
});
|
|
9215
|
+
}
|
|
9216
|
+
return {
|
|
9217
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
9218
|
+
template.output
|
|
9219
|
+
]),
|
|
9220
|
+
value: templateAST
|
|
9221
|
+
};
|
|
9222
|
+
}).filter(Boolean);
|
|
9371
9223
|
}
|
|
9372
9224
|
});
|
|
9373
9225
|
}
|
|
@@ -9511,6 +9363,12 @@ var MarkdownPlugin = function() {
|
|
|
9511
9363
|
_class_call_check(this, ApplicabilityPlugin);
|
|
9512
9364
|
}
|
|
9513
9365
|
_create_class(ApplicabilityPlugin, [
|
|
9366
|
+
{
|
|
9367
|
+
key: "isApplicability",
|
|
9368
|
+
value: function isApplicability(obj) {
|
|
9369
|
+
return obj && Object.prototype.hasOwnProperty.call(obj, "applicability");
|
|
9370
|
+
}
|
|
9371
|
+
},
|
|
9514
9372
|
{
|
|
9515
9373
|
key: "applyResolver",
|
|
9516
9374
|
value: function applyResolver(resolver2) {
|
|
@@ -9530,25 +9388,32 @@ var MarkdownPlugin = function() {
|
|
|
9530
9388
|
{
|
|
9531
9389
|
key: "applyParser",
|
|
9532
9390
|
value: function applyParser(parser) {
|
|
9533
|
-
|
|
9534
|
-
|
|
9535
|
-
|
|
9536
|
-
}
|
|
9537
|
-
});
|
|
9538
|
-
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, determinedNodeType) {
|
|
9539
|
-
if (determinedNodeType === "applicability") {
|
|
9391
|
+
var _this = this;
|
|
9392
|
+
parser.hooks.parseNode.tap("applicability", function(obj, nodeType, options, childOptions) {
|
|
9393
|
+
if (_this.isApplicability(obj)) {
|
|
9540
9394
|
var parsedApplicability = parser.parseObject((0, import_timm7.omit)(obj, "applicability"), nodeType, options);
|
|
9541
|
-
if (parsedApplicability
|
|
9542
|
-
|
|
9543
|
-
type: "applicability",
|
|
9544
|
-
expression: obj.applicability,
|
|
9545
|
-
value: parsedApplicability
|
|
9546
|
-
}, obj);
|
|
9547
|
-
if ((applicabilityNode === null || applicabilityNode === void 0 ? void 0 : applicabilityNode.type) === "applicability") {
|
|
9548
|
-
applicabilityNode.value.parent = applicabilityNode;
|
|
9549
|
-
}
|
|
9550
|
-
return applicabilityNode;
|
|
9395
|
+
if (!parsedApplicability) {
|
|
9396
|
+
return childOptions ? [] : null;
|
|
9551
9397
|
}
|
|
9398
|
+
var applicabilityNode = parser.createASTNode({
|
|
9399
|
+
type: "applicability",
|
|
9400
|
+
expression: obj.applicability,
|
|
9401
|
+
value: parsedApplicability
|
|
9402
|
+
}, obj);
|
|
9403
|
+
if (!applicabilityNode) {
|
|
9404
|
+
return childOptions ? [] : null;
|
|
9405
|
+
}
|
|
9406
|
+
if (applicabilityNode.type === "applicability") {
|
|
9407
|
+
applicabilityNode.value.parent = applicabilityNode;
|
|
9408
|
+
}
|
|
9409
|
+
return childOptions ? [
|
|
9410
|
+
{
|
|
9411
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
9412
|
+
childOptions.key
|
|
9413
|
+
]),
|
|
9414
|
+
value: applicabilityNode
|
|
9415
|
+
}
|
|
9416
|
+
] : applicabilityNode;
|
|
9552
9417
|
}
|
|
9553
9418
|
});
|
|
9554
9419
|
}
|
|
@@ -9598,6 +9463,12 @@ var MarkdownPlugin = function() {
|
|
|
9598
9463
|
return EMPTY_NODE;
|
|
9599
9464
|
}
|
|
9600
9465
|
},
|
|
9466
|
+
{
|
|
9467
|
+
key: "isSwitch",
|
|
9468
|
+
value: function isSwitch(obj) {
|
|
9469
|
+
return obj && (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch"));
|
|
9470
|
+
}
|
|
9471
|
+
},
|
|
9601
9472
|
{
|
|
9602
9473
|
key: "applyParser",
|
|
9603
9474
|
value: function applyParser(parser) {
|
|
@@ -9608,42 +9479,56 @@ var MarkdownPlugin = function() {
|
|
|
9608
9479
|
}
|
|
9609
9480
|
return node2;
|
|
9610
9481
|
});
|
|
9611
|
-
parser.hooks.
|
|
9612
|
-
if (
|
|
9613
|
-
|
|
9614
|
-
|
|
9615
|
-
|
|
9616
|
-
|
|
9617
|
-
if (determinedNodeType === "switch") {
|
|
9618
|
-
var dynamic = "dynamicSwitch" in obj;
|
|
9619
|
-
var switchContent = "dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;
|
|
9620
|
-
var cases = [];
|
|
9621
|
-
switchContent.forEach(function(switchCase) {
|
|
9482
|
+
parser.hooks.parseNode.tap("switch", function(obj, _nodeType, options, childOptions) {
|
|
9483
|
+
if (_this.isSwitch(obj) || childOptions && hasSwitchKey(childOptions.key)) {
|
|
9484
|
+
var objToParse = childOptions && hasSwitchKey(childOptions.key) ? _define_property({}, childOptions.key, obj) : obj;
|
|
9485
|
+
var dynamic = "dynamicSwitch" in objToParse;
|
|
9486
|
+
var switchContent = dynamic ? objToParse.dynamicSwitch : objToParse.staticSwitch;
|
|
9487
|
+
var cases = switchContent.map(function(switchCase) {
|
|
9622
9488
|
var switchCaseExpr = switchCase.case, switchBody = _object_without_properties(switchCase, [
|
|
9623
9489
|
"case"
|
|
9624
9490
|
]);
|
|
9625
9491
|
var value = parser.parseObject(switchBody, "value", options);
|
|
9626
9492
|
if (value) {
|
|
9627
|
-
|
|
9493
|
+
return {
|
|
9628
9494
|
case: switchCaseExpr,
|
|
9629
9495
|
value: value
|
|
9630
|
-
}
|
|
9496
|
+
};
|
|
9631
9497
|
}
|
|
9632
|
-
|
|
9633
|
-
|
|
9498
|
+
return;
|
|
9499
|
+
}).filter(Boolean);
|
|
9500
|
+
var switchAST = parser.createASTNode({
|
|
9634
9501
|
type: "switch",
|
|
9635
9502
|
dynamic: dynamic,
|
|
9636
9503
|
cases: cases
|
|
9637
|
-
},
|
|
9638
|
-
if (
|
|
9504
|
+
}, objToParse);
|
|
9505
|
+
if (!switchAST || switchAST.type === "empty") {
|
|
9506
|
+
return childOptions ? [] : null;
|
|
9507
|
+
}
|
|
9508
|
+
if (switchAST.type === "switch") {
|
|
9639
9509
|
switchAST.cases.forEach(function(sCase) {
|
|
9640
9510
|
sCase.value.parent = switchAST;
|
|
9641
9511
|
});
|
|
9642
9512
|
}
|
|
9643
|
-
if (
|
|
9644
|
-
|
|
9513
|
+
if (childOptions) {
|
|
9514
|
+
var _switchAST_children;
|
|
9515
|
+
var path = _to_consumable_array(childOptions.path).concat([
|
|
9516
|
+
childOptions.key
|
|
9517
|
+
]);
|
|
9518
|
+
var value = switchAST;
|
|
9519
|
+
if (switchAST.type === "value" && ((_switchAST_children = switchAST.children) === null || _switchAST_children === void 0 ? void 0 : _switchAST_children.length) === 1 && switchAST.value === void 0) {
|
|
9520
|
+
var firstChild = switchAST.children[0];
|
|
9521
|
+
path = _to_consumable_array(path).concat(_to_consumable_array(firstChild.path));
|
|
9522
|
+
value = firstChild.value;
|
|
9523
|
+
}
|
|
9524
|
+
return [
|
|
9525
|
+
{
|
|
9526
|
+
path: path,
|
|
9527
|
+
value: value
|
|
9528
|
+
}
|
|
9529
|
+
];
|
|
9645
9530
|
}
|
|
9646
|
-
return switchAST
|
|
9531
|
+
return switchAST;
|
|
9647
9532
|
}
|
|
9648
9533
|
});
|
|
9649
9534
|
}
|
|
@@ -9670,6 +9555,93 @@ var MarkdownPlugin = function() {
|
|
|
9670
9555
|
]);
|
|
9671
9556
|
return SwitchPlugin;
|
|
9672
9557
|
}();
|
|
9558
|
+
var MultiNodePlugin = /*#__PURE__*/ function() {
|
|
9559
|
+
function MultiNodePlugin() {
|
|
9560
|
+
_class_call_check(this, MultiNodePlugin);
|
|
9561
|
+
}
|
|
9562
|
+
_create_class(MultiNodePlugin, [
|
|
9563
|
+
{
|
|
9564
|
+
key: "applyParser",
|
|
9565
|
+
value: function applyParser(parser) {
|
|
9566
|
+
parser.hooks.parseNode.tap("multi-node", function(obj, nodeType, options, childOptions) {
|
|
9567
|
+
if (childOptions && !hasTemplateKey(childOptions.key) && Array.isArray(obj)) {
|
|
9568
|
+
var values = obj.map(function(childVal) {
|
|
9569
|
+
return parser.parseObject(childVal, "value", options);
|
|
9570
|
+
}).filter(function(child) {
|
|
9571
|
+
return !!child;
|
|
9572
|
+
});
|
|
9573
|
+
if (!values.length) {
|
|
9574
|
+
return [];
|
|
9575
|
+
}
|
|
9576
|
+
var multiNode = parser.createASTNode({
|
|
9577
|
+
type: "multi-node",
|
|
9578
|
+
override: !hasTemplateValues(childOptions.parentObj, childOptions.key),
|
|
9579
|
+
values: values
|
|
9580
|
+
}, obj);
|
|
9581
|
+
if (!multiNode) {
|
|
9582
|
+
return [];
|
|
9583
|
+
}
|
|
9584
|
+
if (multiNode.type === "multi-node") {
|
|
9585
|
+
multiNode.values.forEach(function(v) {
|
|
9586
|
+
v.parent = multiNode;
|
|
9587
|
+
});
|
|
9588
|
+
}
|
|
9589
|
+
return [
|
|
9590
|
+
{
|
|
9591
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
9592
|
+
childOptions.key
|
|
9593
|
+
]),
|
|
9594
|
+
value: multiNode
|
|
9595
|
+
}
|
|
9596
|
+
];
|
|
9597
|
+
}
|
|
9598
|
+
});
|
|
9599
|
+
}
|
|
9600
|
+
},
|
|
9601
|
+
{
|
|
9602
|
+
key: "apply",
|
|
9603
|
+
value: function apply(view) {
|
|
9604
|
+
view.hooks.parser.tap("multi-node", this.applyParser.bind(this));
|
|
9605
|
+
}
|
|
9606
|
+
}
|
|
9607
|
+
]);
|
|
9608
|
+
return MultiNodePlugin;
|
|
9609
|
+
}();
|
|
9610
|
+
var AssetPlugin = /*#__PURE__*/ function() {
|
|
9611
|
+
function AssetPlugin() {
|
|
9612
|
+
_class_call_check(this, AssetPlugin);
|
|
9613
|
+
}
|
|
9614
|
+
_create_class(AssetPlugin, [
|
|
9615
|
+
{
|
|
9616
|
+
key: "applyParser",
|
|
9617
|
+
value: function applyParser(parser) {
|
|
9618
|
+
parser.hooks.parseNode.tap("asset", function(obj, nodeType, options, childOptions) {
|
|
9619
|
+
if ((childOptions === null || childOptions === void 0 ? void 0 : childOptions.key) === "asset" && typeof obj === "object") {
|
|
9620
|
+
var assetAST = parser.parseObject(obj, "asset", options);
|
|
9621
|
+
if (!assetAST) {
|
|
9622
|
+
return [];
|
|
9623
|
+
}
|
|
9624
|
+
return [
|
|
9625
|
+
{
|
|
9626
|
+
path: _to_consumable_array(childOptions.path).concat([
|
|
9627
|
+
childOptions.key
|
|
9628
|
+
]),
|
|
9629
|
+
value: assetAST
|
|
9630
|
+
}
|
|
9631
|
+
];
|
|
9632
|
+
}
|
|
9633
|
+
});
|
|
9634
|
+
}
|
|
9635
|
+
},
|
|
9636
|
+
{
|
|
9637
|
+
key: "apply",
|
|
9638
|
+
value: function apply(view) {
|
|
9639
|
+
view.hooks.parser.tap("asset", this.applyParser.bind(this));
|
|
9640
|
+
}
|
|
9641
|
+
}
|
|
9642
|
+
]);
|
|
9643
|
+
return AssetPlugin;
|
|
9644
|
+
}();
|
|
9673
9645
|
var FlowInstance = /*#__PURE__*/ function() {
|
|
9674
9646
|
function FlowInstance(id, flow3, options) {
|
|
9675
9647
|
_class_call_check(this, FlowInstance);
|
|
@@ -11372,12 +11344,14 @@ var MarkdownPlugin = function() {
|
|
|
11372
11344
|
player.hooks.viewController.tap(this.name, function(viewController) {
|
|
11373
11345
|
viewController.hooks.view.tap(_this.name, function(view) {
|
|
11374
11346
|
var pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
11347
|
+
new AssetPlugin().apply(view);
|
|
11375
11348
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
11376
11349
|
new ApplicabilityPlugin().apply(view);
|
|
11377
11350
|
new StringResolverPlugin().apply(view);
|
|
11378
11351
|
var templatePlugin = new TemplatePlugin(pluginOptions);
|
|
11379
11352
|
templatePlugin.apply(view);
|
|
11380
11353
|
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
11354
|
+
new MultiNodePlugin().apply(view);
|
|
11381
11355
|
});
|
|
11382
11356
|
});
|
|
11383
11357
|
}
|