@player-ui/player 0.8.0-next.0 → 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.
- package/dist/Player.native.js +469 -4094
- package/dist/Player.native.js.map +1 -1
- package/dist/cjs/index.cjs +293 -407
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.legacy-esm.js +291 -409
- package/dist/index.mjs +291 -409
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -8
- package/src/binding/__tests__/resolver.test.ts +4 -4
- package/src/binding-grammar/{ebnf → __tests__/ebnf}/index.ts +2 -2
- package/src/binding-grammar/__tests__/parser.test.ts +2 -2
- package/src/binding-grammar/{parsimmon → __tests__/parsimmon}/index.ts +2 -2
- package/src/binding-grammar/index.ts +0 -2
- package/src/plugins/default-view-plugin.ts +4 -0
- package/src/view/__tests__/view.immutable.test.ts +8 -1
- package/src/view/__tests__/view.test.ts +59 -1
- package/src/view/parser/__tests__/parser.test.ts +16 -1
- package/src/view/parser/index.ts +46 -262
- package/src/view/parser/utils.ts +23 -3
- package/src/view/plugins/__tests__/__snapshots__/asset.test.ts.snap +215 -0
- package/src/view/plugins/__tests__/__snapshots__/multi-node.test.ts.snap +67 -0
- package/src/view/plugins/__tests__/__snapshots__/template.test.ts.snap +56 -54
- package/src/view/plugins/__tests__/applicability.test.ts +24 -16
- package/src/view/plugins/__tests__/asset.test.ts +140 -0
- package/src/view/plugins/__tests__/multi-node.test.ts +38 -0
- package/src/view/plugins/__tests__/template.test.ts +48 -388
- package/src/view/plugins/applicability.ts +39 -23
- package/src/view/plugins/asset.ts +42 -0
- package/src/view/plugins/index.ts +3 -1
- package/src/view/plugins/multi-node.ts +73 -0
- package/src/view/plugins/switch.ts +81 -50
- package/src/view/plugins/{template-plugin.ts → template.ts} +38 -24
- package/src/view/resolver/__tests__/edgecases.test.ts +14 -1
- package/src/view/view.ts +2 -7
- package/types/binding-grammar/index.d.ts +0 -2
- package/types/view/parser/index.d.ts +6 -11
- package/types/view/parser/utils.d.ts +11 -2
- package/types/view/plugins/applicability.d.ts +1 -0
- package/types/view/plugins/asset.d.ts +8 -0
- package/types/view/plugins/index.d.ts +3 -1
- package/types/view/plugins/multi-node.d.ts +8 -0
- package/types/view/plugins/switch.d.ts +2 -1
- package/types/view/plugins/{template-plugin.d.ts → template.d.ts} +2 -2
- package/types/binding-grammar/ebnf/index.d.ts +0 -4
- package/types/binding-grammar/ebnf/types.d.ts +0 -75
- package/types/binding-grammar/parsimmon/index.d.ts +0 -4
- /package/src/binding-grammar/{ebnf → __tests__/ebnf}/binding.ebnf +0 -0
- /package/src/binding-grammar/{ebnf → __tests__/ebnf}/types.ts +0 -0
package/dist/index.mjs
CHANGED
|
@@ -20,9 +20,9 @@ var toExpression = (value) => ({
|
|
|
20
20
|
name: "Expression",
|
|
21
21
|
value
|
|
22
22
|
});
|
|
23
|
-
var toPath = (
|
|
23
|
+
var toPath = (path) => ({
|
|
24
24
|
name: "PathNode",
|
|
25
|
-
path
|
|
25
|
+
path
|
|
26
26
|
});
|
|
27
27
|
var toQuery = (key, value) => ({
|
|
28
28
|
name: "Query",
|
|
@@ -39,60 +39,6 @@ var toConcatenatedNode = (values) => {
|
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/binding-grammar/parsimmon/index.ts
|
|
43
|
-
import flatten from "arr-flatten";
|
|
44
|
-
import P from "parsimmon";
|
|
45
|
-
var doubleQuote = P.string('"');
|
|
46
|
-
var singleQuote = P.string("'");
|
|
47
|
-
var backTick = P.string("`");
|
|
48
|
-
var identifier = P.regex(/[\w\-@]+/).desc("identifier").map(toValue);
|
|
49
|
-
var path;
|
|
50
|
-
var futurePath = P.lazy(() => path);
|
|
51
|
-
var nestedPath = futurePath.trim(P.optWhitespace).wrap(P.string("{{"), P.string("}}")).map(toPath);
|
|
52
|
-
var nestedExpression = P.regex(/[^`]*/).wrap(backTick, backTick).map(toExpression);
|
|
53
|
-
var segment = P.alt(identifier, nestedPath, nestedExpression).atLeast(1).map(flatten).map(toConcatenatedNode);
|
|
54
|
-
var optionallyQuotedSegment = P.alt(
|
|
55
|
-
P.regex(/[^"]*/).wrap(doubleQuote, doubleQuote).map(toValue),
|
|
56
|
-
P.regex(/[^']*/).wrap(singleQuote, singleQuote).map(toValue),
|
|
57
|
-
segment
|
|
58
|
-
);
|
|
59
|
-
var query = P.seq(
|
|
60
|
-
optionallyQuotedSegment,
|
|
61
|
-
P.string("=").times(1, 3).trim(P.optWhitespace),
|
|
62
|
-
optionallyQuotedSegment
|
|
63
|
-
).map(([key, , value]) => toQuery(key, value));
|
|
64
|
-
var brackets = P.alt(query, optionallyQuotedSegment).trim(P.optWhitespace).wrap(P.string("["), P.string("]")).many();
|
|
65
|
-
var segmentAndBrackets = P.seqMap(segment, brackets, (s, bs) => [s, ...bs]);
|
|
66
|
-
path = P.sepBy(segmentAndBrackets, P.string(".")).map(flatten);
|
|
67
|
-
|
|
68
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/binding-grammar/ebnf/index.ts
|
|
69
|
-
import { Grammars } from "ebnf";
|
|
70
|
-
var parser = new Grammars.W3C.Parser(`
|
|
71
|
-
value ::= segment_and_bracket (SEGMENT_SEPARATOR segment_and_bracket)*
|
|
72
|
-
segment ::= concatenated | expression | modelRef | identifier
|
|
73
|
-
concatenated ::= (expression | modelRef | identifier)+
|
|
74
|
-
modelRef ::= OPEN_CURL OPEN_CURL value CLOSE_CURL CLOSE_CURL
|
|
75
|
-
identifier ::= [\\w\\-@]+
|
|
76
|
-
query ::= WHITESPACE* optionally_quoted_segment WHITESPACE* EQUALS EQUALS? EQUALS? WHITESPACE* optionally_quoted_segment WHITESPACE*
|
|
77
|
-
brackets ::= OPEN_BRACKET WHITESPACE* (query | optionally_quoted_segment) WHITESPACE* CLOSE_BRACKET
|
|
78
|
-
segment_and_bracket ::= segment brackets*
|
|
79
|
-
quoted_value ::= [^"']*
|
|
80
|
-
optionally_quoted_segment ::= WHITESPACE* SINGLE_QUOTE quoted_value SINGLE_QUOTE WHITESPACE* | WHITESPACE* DOUBLE_QUOTE quoted_value DOUBLE_QUOTE WHITESPACE* | WHITESPACE* segment WHITESPACE*
|
|
81
|
-
expression_value ::= [^\`]*
|
|
82
|
-
expression ::= BACK_TICK expression_value BACK_TICK
|
|
83
|
-
|
|
84
|
-
EQUALS ::= "="
|
|
85
|
-
SEGMENT_SEPARATOR ::= "."
|
|
86
|
-
SINGLE_QUOTE ::= "'"
|
|
87
|
-
DOUBLE_QUOTE ::= '"'
|
|
88
|
-
WHITESPACE ::= " "
|
|
89
|
-
OPEN_CURL ::= "{"
|
|
90
|
-
CLOSE_CURL ::= "}"
|
|
91
|
-
OPEN_BRACKET ::= "["
|
|
92
|
-
CLOSE_BRACKET ::= "]"
|
|
93
|
-
BACK_TICK ::= "\`"
|
|
94
|
-
`);
|
|
95
|
-
|
|
96
42
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/binding-grammar/custom/index.ts
|
|
97
43
|
var SEGMENT_SEPARATOR = ".";
|
|
98
44
|
var OPEN_CURL = "{";
|
|
@@ -123,14 +69,14 @@ var isIdentifierChar = (char) => {
|
|
|
123
69
|
charCode === 125;
|
|
124
70
|
return !matches;
|
|
125
71
|
};
|
|
126
|
-
var parse = (
|
|
72
|
+
var parse = (path) => {
|
|
127
73
|
let index = 1;
|
|
128
|
-
let ch =
|
|
74
|
+
let ch = path.charAt(0);
|
|
129
75
|
const next = (expected) => {
|
|
130
76
|
if (expected && ch !== expected) {
|
|
131
77
|
throw new Error(`Expected char: ${expected} but got: ${ch}`);
|
|
132
78
|
}
|
|
133
|
-
ch =
|
|
79
|
+
ch = path.charAt(index);
|
|
134
80
|
index += 1;
|
|
135
81
|
return ch;
|
|
136
82
|
};
|
|
@@ -139,7 +85,7 @@ var parse = (path2) => {
|
|
|
139
85
|
next();
|
|
140
86
|
}
|
|
141
87
|
};
|
|
142
|
-
const
|
|
88
|
+
const identifier = () => {
|
|
143
89
|
if (!isIdentifierChar(ch)) {
|
|
144
90
|
return;
|
|
145
91
|
}
|
|
@@ -185,7 +131,7 @@ var parse = (path2) => {
|
|
|
185
131
|
return toValue(value);
|
|
186
132
|
}
|
|
187
133
|
};
|
|
188
|
-
const
|
|
134
|
+
const nestedPath = () => {
|
|
189
135
|
if (ch === OPEN_CURL) {
|
|
190
136
|
next(OPEN_CURL);
|
|
191
137
|
next(OPEN_CURL);
|
|
@@ -195,8 +141,8 @@ var parse = (path2) => {
|
|
|
195
141
|
return modelRef;
|
|
196
142
|
}
|
|
197
143
|
};
|
|
198
|
-
const simpleSegment = () =>
|
|
199
|
-
const
|
|
144
|
+
const simpleSegment = () => nestedPath() ?? expression() ?? identifier();
|
|
145
|
+
const segment = () => {
|
|
200
146
|
const segments = [];
|
|
201
147
|
let nextSegment = simpleSegment();
|
|
202
148
|
while (nextSegment !== void 0) {
|
|
@@ -208,13 +154,13 @@ var parse = (path2) => {
|
|
|
208
154
|
}
|
|
209
155
|
return toConcatenatedNode(segments);
|
|
210
156
|
};
|
|
211
|
-
const
|
|
157
|
+
const optionallyQuotedSegment = () => {
|
|
212
158
|
whitespace();
|
|
213
159
|
if (ch === SINGLE_QUOTE || ch === DOUBLE_QUOTE) {
|
|
214
|
-
const
|
|
215
|
-
next(
|
|
160
|
+
const singleQuote = ch === SINGLE_QUOTE;
|
|
161
|
+
next(singleQuote ? SINGLE_QUOTE : DOUBLE_QUOTE);
|
|
216
162
|
const id = regex(/[^'"]+/);
|
|
217
|
-
next(
|
|
163
|
+
next(singleQuote ? SINGLE_QUOTE : DOUBLE_QUOTE);
|
|
218
164
|
return id;
|
|
219
165
|
}
|
|
220
166
|
return simpleSegment();
|
|
@@ -232,12 +178,12 @@ var parse = (path2) => {
|
|
|
232
178
|
if (ch === OPEN_BRACKET) {
|
|
233
179
|
next(OPEN_BRACKET);
|
|
234
180
|
whitespace();
|
|
235
|
-
let value =
|
|
181
|
+
let value = optionallyQuotedSegment();
|
|
236
182
|
if (value) {
|
|
237
183
|
whitespace();
|
|
238
184
|
if (equals()) {
|
|
239
185
|
whitespace();
|
|
240
|
-
const second =
|
|
186
|
+
const second = optionallyQuotedSegment();
|
|
241
187
|
value = toQuery(value, second);
|
|
242
188
|
whitespace();
|
|
243
189
|
}
|
|
@@ -252,7 +198,7 @@ var parse = (path2) => {
|
|
|
252
198
|
};
|
|
253
199
|
const parseSegmentAndBrackets = () => {
|
|
254
200
|
const parsed = [];
|
|
255
|
-
const firstSegment =
|
|
201
|
+
const firstSegment = segment();
|
|
256
202
|
if (firstSegment) {
|
|
257
203
|
parsed.push(firstSegment);
|
|
258
204
|
let bracketSegment = parseBracket();
|
|
@@ -326,12 +272,12 @@ function findInArray(array, key, value) {
|
|
|
326
272
|
var BindingInstance = class _BindingInstance {
|
|
327
273
|
constructor(raw, factory = (rawBinding) => new _BindingInstance(rawBinding)) {
|
|
328
274
|
const split = Array.isArray(raw) ? raw : raw.split(".");
|
|
329
|
-
this.split = split.map((
|
|
330
|
-
if (typeof
|
|
331
|
-
return
|
|
275
|
+
this.split = split.map((segment) => {
|
|
276
|
+
if (typeof segment === "number") {
|
|
277
|
+
return segment;
|
|
332
278
|
}
|
|
333
|
-
const tryNum = Number(
|
|
334
|
-
return isNaN(tryNum) ?
|
|
279
|
+
const tryNum = Number(segment);
|
|
280
|
+
return isNaN(tryNum) ? segment : tryNum;
|
|
335
281
|
});
|
|
336
282
|
Object.freeze(this.split);
|
|
337
283
|
this.joined = this.split.join(".");
|
|
@@ -418,13 +364,13 @@ function resolveBindingAST(bindingPathNode, options, hooks) {
|
|
|
418
364
|
}
|
|
419
365
|
throw new Error(`Unable to resolve value for node: ${node.name}`);
|
|
420
366
|
}
|
|
421
|
-
function appendPathSegments(
|
|
422
|
-
if (typeof
|
|
423
|
-
|
|
367
|
+
function appendPathSegments(segment) {
|
|
368
|
+
if (typeof segment === "string" && segment.indexOf(".") > -1) {
|
|
369
|
+
segment.split(".").forEach((i) => {
|
|
424
370
|
context.path.push(maybeConvertToNum(i));
|
|
425
371
|
});
|
|
426
372
|
} else {
|
|
427
|
-
context.path.push(
|
|
373
|
+
context.path.push(segment);
|
|
428
374
|
}
|
|
429
375
|
}
|
|
430
376
|
function resolveNode(_node) {
|
|
@@ -495,21 +441,21 @@ var BindingParser = class {
|
|
|
495
441
|
* Takes a binding path, parses it, and returns an equivalent, normalized
|
|
496
442
|
* representation of that path.
|
|
497
443
|
*/
|
|
498
|
-
normalizePath(
|
|
499
|
-
if (!BINDING_BRACKETS_REGEX.test(
|
|
500
|
-
return { path:
|
|
444
|
+
normalizePath(path, resolveOptions) {
|
|
445
|
+
if (!BINDING_BRACKETS_REGEX.test(path) && LAZY_BINDING_REGEX.test(path) && this.hooks.skipOptimization.call(path) !== true) {
|
|
446
|
+
return { path: path.split("."), updates: void 0 };
|
|
501
447
|
}
|
|
502
|
-
const ast = this.parseCache[
|
|
503
|
-
this.parseCache[
|
|
448
|
+
const ast = this.parseCache[path] ?? parse(path);
|
|
449
|
+
this.parseCache[path] = ast;
|
|
504
450
|
if (typeof ast !== "object" || !ast?.status) {
|
|
505
451
|
throw new TypeError(
|
|
506
|
-
`Cannot normalize path "${
|
|
452
|
+
`Cannot normalize path "${path}": ${ast?.error ?? "Unknown Error."}`
|
|
507
453
|
);
|
|
508
454
|
}
|
|
509
455
|
try {
|
|
510
456
|
return resolveBindingAST(ast.path, resolveOptions, this.hooks);
|
|
511
457
|
} catch (e) {
|
|
512
|
-
throw new NestedError2(`Cannot resolve binding: ${
|
|
458
|
+
throw new NestedError2(`Cannot resolve binding: ${path}`, e);
|
|
513
459
|
}
|
|
514
460
|
}
|
|
515
461
|
getBindingForNormalizedResult(normalized) {
|
|
@@ -535,25 +481,25 @@ var BindingParser = class {
|
|
|
535
481
|
let updates = {};
|
|
536
482
|
const joined = Array.isArray(rawBinding) ? rawBinding.join(".") : String(rawBinding);
|
|
537
483
|
const normalizeConfig = {
|
|
538
|
-
getValue: (
|
|
539
|
-
const normalized2 = this.normalizePath(
|
|
484
|
+
getValue: (path) => {
|
|
485
|
+
const normalized2 = this.normalizePath(path.join("."), normalizeConfig);
|
|
540
486
|
return options.get(this.getBindingForNormalizedResult(normalized2));
|
|
541
487
|
},
|
|
542
488
|
evaluate: (exp) => {
|
|
543
489
|
return options.evaluate(exp);
|
|
544
490
|
},
|
|
545
|
-
convertToPath: (
|
|
546
|
-
if (
|
|
491
|
+
convertToPath: (path) => {
|
|
492
|
+
if (path === void 0) {
|
|
547
493
|
throw new Error(
|
|
548
494
|
"Attempted to convert undefined value to binding path"
|
|
549
495
|
);
|
|
550
496
|
}
|
|
551
|
-
if (typeof
|
|
497
|
+
if (typeof path !== "string" && typeof path !== "number" && typeof path !== "boolean") {
|
|
552
498
|
throw new Error(
|
|
553
|
-
`Attempting to convert ${typeof
|
|
499
|
+
`Attempting to convert ${typeof path} to a binding path.`
|
|
554
500
|
);
|
|
555
501
|
}
|
|
556
|
-
const normalized2 = this.normalizePath(String(
|
|
502
|
+
const normalized2 = this.normalizePath(String(path), normalizeConfig);
|
|
557
503
|
if (normalized2.updates) {
|
|
558
504
|
updates = {
|
|
559
505
|
...updates,
|
|
@@ -1387,17 +1333,17 @@ function parseExpression(expr, options) {
|
|
|
1387
1333
|
break;
|
|
1388
1334
|
}
|
|
1389
1335
|
}
|
|
1390
|
-
const
|
|
1391
|
-
if (Object.prototype.hasOwnProperty.call(literals,
|
|
1336
|
+
const identifier = expr.slice(start, index);
|
|
1337
|
+
if (Object.prototype.hasOwnProperty.call(literals, identifier)) {
|
|
1392
1338
|
return {
|
|
1393
1339
|
__id: ExpNodeOpaqueIdentifier,
|
|
1394
1340
|
type: "Literal",
|
|
1395
|
-
value: literals[
|
|
1396
|
-
raw:
|
|
1341
|
+
value: literals[identifier],
|
|
1342
|
+
raw: identifier,
|
|
1397
1343
|
location: getLocation(start)
|
|
1398
1344
|
};
|
|
1399
1345
|
}
|
|
1400
|
-
if (
|
|
1346
|
+
if (identifier === thisStr) {
|
|
1401
1347
|
return {
|
|
1402
1348
|
__id: ExpNodeOpaqueIdentifier,
|
|
1403
1349
|
type: "ThisExpression",
|
|
@@ -1407,7 +1353,7 @@ function parseExpression(expr, options) {
|
|
|
1407
1353
|
return {
|
|
1408
1354
|
__id: ExpNodeOpaqueIdentifier,
|
|
1409
1355
|
type: "Identifier",
|
|
1410
|
-
name:
|
|
1356
|
+
name: identifier,
|
|
1411
1357
|
location: getLocation(start)
|
|
1412
1358
|
};
|
|
1413
1359
|
}
|
|
@@ -2038,7 +1984,7 @@ var ProxyLogger = class {
|
|
|
2038
1984
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/schema/schema.ts
|
|
2039
1985
|
import { SyncWaterfallHook as SyncWaterfallHook3 } from "tapable-ts";
|
|
2040
1986
|
var identify = (val) => val;
|
|
2041
|
-
function
|
|
1987
|
+
function parse2(schema) {
|
|
2042
1988
|
const expandedPaths = /* @__PURE__ */ new Map();
|
|
2043
1989
|
if (!schema.ROOT) {
|
|
2044
1990
|
return expandedPaths;
|
|
@@ -2049,10 +1995,10 @@ function parse4(schema) {
|
|
|
2049
1995
|
if (!next) {
|
|
2050
1996
|
break;
|
|
2051
1997
|
}
|
|
2052
|
-
const { node, path
|
|
1998
|
+
const { node, path, visited } = next;
|
|
2053
1999
|
Object.entries(node).forEach(([prop, type]) => {
|
|
2054
|
-
const
|
|
2055
|
-
const nestedPathStr =
|
|
2000
|
+
const nestedPath = [...path, prop];
|
|
2001
|
+
const nestedPathStr = nestedPath.join(".");
|
|
2056
2002
|
if (expandedPaths.has(nestedPathStr)) {
|
|
2057
2003
|
throw new Error(
|
|
2058
2004
|
"Path has already been processed. There's either a loop somewhere or a bug"
|
|
@@ -2065,14 +2011,14 @@ function parse4(schema) {
|
|
|
2065
2011
|
}
|
|
2066
2012
|
expandedPaths.set(nestedPathStr, type);
|
|
2067
2013
|
if (type.isArray) {
|
|
2068
|
-
|
|
2014
|
+
nestedPath.push("[]");
|
|
2069
2015
|
}
|
|
2070
2016
|
if (type.isRecord) {
|
|
2071
|
-
|
|
2017
|
+
nestedPath.push("{}");
|
|
2072
2018
|
}
|
|
2073
2019
|
if (type.type && schema[type.type]) {
|
|
2074
2020
|
parseQueue.push({
|
|
2075
|
-
path:
|
|
2021
|
+
path: nestedPath,
|
|
2076
2022
|
node: schema[type.type],
|
|
2077
2023
|
visited: /* @__PURE__ */ new Set([...visited, type.type])
|
|
2078
2024
|
});
|
|
@@ -2090,7 +2036,7 @@ var SchemaController = class {
|
|
|
2090
2036
|
this.hooks = {
|
|
2091
2037
|
resolveTypeForBinding: new SyncWaterfallHook3()
|
|
2092
2038
|
};
|
|
2093
|
-
this.schema = schema ?
|
|
2039
|
+
this.schema = schema ? parse2(schema) : /* @__PURE__ */ new Map();
|
|
2094
2040
|
}
|
|
2095
2041
|
addFormatters(fns) {
|
|
2096
2042
|
fns.forEach((def) => {
|
|
@@ -2440,7 +2386,7 @@ import dlv from "dlv";
|
|
|
2440
2386
|
import { dequal } from "dequal";
|
|
2441
2387
|
|
|
2442
2388
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/parser/index.ts
|
|
2443
|
-
import {
|
|
2389
|
+
import { setIn as setIn4 } from "timm";
|
|
2444
2390
|
import { SyncBailHook as SyncBailHook3, SyncWaterfallHook as SyncWaterfallHook4 } from "tapable-ts";
|
|
2445
2391
|
|
|
2446
2392
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/parser/types.ts
|
|
@@ -2459,8 +2405,14 @@ var NodeType = /* @__PURE__ */ ((NodeType2) => {
|
|
|
2459
2405
|
})(NodeType || {});
|
|
2460
2406
|
|
|
2461
2407
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/parser/utils.ts
|
|
2462
|
-
function
|
|
2463
|
-
return Object.
|
|
2408
|
+
function hasTemplateValues(obj, localKey) {
|
|
2409
|
+
return Object.hasOwnProperty.call(obj, "template") && Array.isArray(obj?.template) && obj.template.length && obj.template.find((tmpl) => tmpl.output === localKey);
|
|
2410
|
+
}
|
|
2411
|
+
function hasSwitchKey(localKey) {
|
|
2412
|
+
return localKey === "staticSwitch" || localKey === "dynamicSwitch";
|
|
2413
|
+
}
|
|
2414
|
+
function hasTemplateKey(localKey) {
|
|
2415
|
+
return localKey === "template";
|
|
2464
2416
|
}
|
|
2465
2417
|
function getNodeID(node) {
|
|
2466
2418
|
if (!node) {
|
|
@@ -2497,7 +2449,6 @@ var Parser = class {
|
|
|
2497
2449
|
* If null, we ignore this node all together
|
|
2498
2450
|
*/
|
|
2499
2451
|
onCreateASTNode: new SyncWaterfallHook4(),
|
|
2500
|
-
determineNodeType: new SyncBailHook3(),
|
|
2501
2452
|
parseNode: new SyncBailHook3()
|
|
2502
2453
|
};
|
|
2503
2454
|
}
|
|
@@ -2508,21 +2459,6 @@ var Parser = class {
|
|
|
2508
2459
|
}
|
|
2509
2460
|
return viewNode;
|
|
2510
2461
|
}
|
|
2511
|
-
parseAsync(obj, type, options) {
|
|
2512
|
-
const parsedAsync = this.parseObject(omit2(obj, "async"), type, options);
|
|
2513
|
-
const parsedNodeId = getNodeID(parsedAsync);
|
|
2514
|
-
if (parsedAsync !== null && parsedNodeId) {
|
|
2515
|
-
return this.createASTNode(
|
|
2516
|
-
{
|
|
2517
|
-
id: parsedNodeId,
|
|
2518
|
-
type: "async" /* Async */,
|
|
2519
|
-
value: parsedAsync
|
|
2520
|
-
},
|
|
2521
|
-
obj
|
|
2522
|
-
);
|
|
2523
|
-
}
|
|
2524
|
-
return null;
|
|
2525
|
-
}
|
|
2526
2462
|
createASTNode(node, value) {
|
|
2527
2463
|
const tapped = this.hooks.onCreateASTNode.call(node, value);
|
|
2528
2464
|
if (tapped === void 0) {
|
|
@@ -2530,32 +2466,16 @@ var Parser = class {
|
|
|
2530
2466
|
}
|
|
2531
2467
|
return tapped;
|
|
2532
2468
|
}
|
|
2533
|
-
/**
|
|
2534
|
-
* Checks if there are templated values in the object
|
|
2535
|
-
*
|
|
2536
|
-
* @param obj - The Parsed Object to check to see if we have a template array type for
|
|
2537
|
-
* @param localKey - The key being checked
|
|
2538
|
-
*/
|
|
2539
|
-
hasTemplateValues(obj, localKey) {
|
|
2540
|
-
return Object.hasOwnProperty.call(obj, "template") && Array.isArray(obj?.template) && obj.template.length && obj.template.find((tmpl) => tmpl.output === localKey);
|
|
2541
|
-
}
|
|
2542
|
-
hasSwitchKey(localKey) {
|
|
2543
|
-
return localKey === "staticSwitch";
|
|
2544
|
-
}
|
|
2545
2469
|
parseObject(obj, type = "value" /* Value */, options = { templateDepth: 0 }) {
|
|
2546
|
-
const
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
);
|
|
2554
|
-
if (parsedNode) {
|
|
2555
|
-
return parsedNode;
|
|
2556
|
-
}
|
|
2470
|
+
const parsedNode = this.hooks.parseNode.call(
|
|
2471
|
+
obj,
|
|
2472
|
+
type,
|
|
2473
|
+
options
|
|
2474
|
+
);
|
|
2475
|
+
if (parsedNode || parsedNode === null) {
|
|
2476
|
+
return parsedNode;
|
|
2557
2477
|
}
|
|
2558
|
-
const parseLocalObject = (currentValue, objToParse,
|
|
2478
|
+
const parseLocalObject = (currentValue, objToParse, path = []) => {
|
|
2559
2479
|
if (typeof objToParse !== "object" || objToParse === null) {
|
|
2560
2480
|
return { value: objToParse, children: [] };
|
|
2561
2481
|
}
|
|
@@ -2575,182 +2495,44 @@ var Parser = class {
|
|
|
2575
2495
|
value: currentValue
|
|
2576
2496
|
};
|
|
2577
2497
|
const newValue = objEntries.reduce((accumulation, current) => {
|
|
2578
|
-
|
|
2498
|
+
let { value: value2 } = accumulation;
|
|
2499
|
+
const { children: children2 } = accumulation;
|
|
2579
2500
|
const [localKey, localValue] = current;
|
|
2580
|
-
|
|
2581
|
-
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
...rest,
|
|
2589
|
-
children: [
|
|
2590
|
-
...children2,
|
|
2591
|
-
{
|
|
2592
|
-
path: [...path2, "asset"],
|
|
2593
|
-
value: assetAST
|
|
2594
|
-
}
|
|
2595
|
-
]
|
|
2596
|
-
};
|
|
2597
|
-
}
|
|
2598
|
-
} else if (this.hooks.determineNodeType.call(localKey) === "template" /* Template */ && Array.isArray(localValue)) {
|
|
2599
|
-
const templateChildren = localValue.map((template) => {
|
|
2600
|
-
const templateAST = this.hooks.onCreateASTNode.call(
|
|
2601
|
-
{
|
|
2602
|
-
type: "template" /* Template */,
|
|
2603
|
-
depth: options.templateDepth ?? 0,
|
|
2604
|
-
data: template.data,
|
|
2605
|
-
template: template.value,
|
|
2606
|
-
dynamic: template.dynamic ?? false
|
|
2607
|
-
},
|
|
2608
|
-
template
|
|
2609
|
-
);
|
|
2610
|
-
if (templateAST?.type === "multi-node" /* MultiNode */) {
|
|
2611
|
-
templateAST.values.forEach((v) => {
|
|
2612
|
-
v.parent = templateAST;
|
|
2613
|
-
});
|
|
2614
|
-
}
|
|
2615
|
-
if (templateAST) {
|
|
2616
|
-
return {
|
|
2617
|
-
path: [...path2, template.output],
|
|
2618
|
-
value: templateAST
|
|
2619
|
-
};
|
|
2620
|
-
}
|
|
2621
|
-
return;
|
|
2622
|
-
}).filter((element) => !!element);
|
|
2623
|
-
return {
|
|
2624
|
-
...rest,
|
|
2625
|
-
children: [...children2, ...templateChildren]
|
|
2626
|
-
};
|
|
2627
|
-
} else if (localValue && this.hooks.determineNodeType.call(localValue) === "switch" /* Switch */ || this.hasSwitchKey(localKey)) {
|
|
2628
|
-
const localSwitch = this.hooks.parseNode.call(
|
|
2629
|
-
this.hasSwitchKey(localKey) ? { [localKey]: localValue } : localValue,
|
|
2630
|
-
"value" /* Value */,
|
|
2631
|
-
options,
|
|
2632
|
-
"switch" /* Switch */
|
|
2633
|
-
);
|
|
2634
|
-
if (localSwitch && localSwitch.type === "value" /* Value */ && localSwitch.children?.length === 1 && localSwitch.value === void 0) {
|
|
2635
|
-
const firstChild = localSwitch.children[0];
|
|
2636
|
-
return {
|
|
2637
|
-
...rest,
|
|
2638
|
-
children: [
|
|
2639
|
-
...children2,
|
|
2640
|
-
{
|
|
2641
|
-
path: [...path2, localKey, ...firstChild.path],
|
|
2642
|
-
value: firstChild.value
|
|
2643
|
-
}
|
|
2644
|
-
]
|
|
2645
|
-
};
|
|
2646
|
-
}
|
|
2647
|
-
if (localSwitch) {
|
|
2648
|
-
return {
|
|
2649
|
-
...rest,
|
|
2650
|
-
children: [
|
|
2651
|
-
...children2,
|
|
2652
|
-
{
|
|
2653
|
-
path: [...path2, localKey],
|
|
2654
|
-
value: localSwitch
|
|
2655
|
-
}
|
|
2656
|
-
]
|
|
2657
|
-
};
|
|
2658
|
-
}
|
|
2659
|
-
} else if (localValue && hasAsync(localValue)) {
|
|
2660
|
-
const localAsync = this.parseAsync(
|
|
2661
|
-
localValue,
|
|
2662
|
-
"value" /* Value */,
|
|
2663
|
-
options
|
|
2664
|
-
);
|
|
2665
|
-
if (localAsync) {
|
|
2666
|
-
children2.push({
|
|
2667
|
-
path: [...path2, localKey],
|
|
2668
|
-
value: localAsync
|
|
2669
|
-
});
|
|
2670
|
-
}
|
|
2671
|
-
} else if (localValue && Array.isArray(localValue)) {
|
|
2672
|
-
const childValues = localValue.map(
|
|
2673
|
-
(childVal) => this.parseObject(childVal, "value" /* Value */, options)
|
|
2674
|
-
).filter((child) => !!child);
|
|
2675
|
-
if (childValues.length > 0) {
|
|
2676
|
-
const multiNode = this.hooks.onCreateASTNode.call(
|
|
2677
|
-
{
|
|
2678
|
-
type: "multi-node" /* MultiNode */,
|
|
2679
|
-
override: !this.hasTemplateValues(localObj, localKey),
|
|
2680
|
-
values: childValues
|
|
2681
|
-
},
|
|
2682
|
-
localValue
|
|
2683
|
-
);
|
|
2684
|
-
if (multiNode?.type === "multi-node" /* MultiNode */) {
|
|
2685
|
-
multiNode.values.forEach((v) => {
|
|
2686
|
-
v.parent = multiNode;
|
|
2687
|
-
});
|
|
2688
|
-
}
|
|
2689
|
-
if (multiNode) {
|
|
2690
|
-
return {
|
|
2691
|
-
...rest,
|
|
2692
|
-
children: [
|
|
2693
|
-
...children2,
|
|
2694
|
-
{
|
|
2695
|
-
path: [...path2, localKey],
|
|
2696
|
-
value: multiNode
|
|
2697
|
-
}
|
|
2698
|
-
]
|
|
2699
|
-
};
|
|
2700
|
-
}
|
|
2501
|
+
const newChildren = this.hooks.parseNode.call(
|
|
2502
|
+
localValue,
|
|
2503
|
+
"value" /* Value */,
|
|
2504
|
+
options,
|
|
2505
|
+
{
|
|
2506
|
+
path,
|
|
2507
|
+
key: localKey,
|
|
2508
|
+
parentObj: localObj
|
|
2701
2509
|
}
|
|
2510
|
+
);
|
|
2511
|
+
if (newChildren) {
|
|
2512
|
+
children2.push(...newChildren);
|
|
2702
2513
|
} else if (localValue && typeof localValue === "object") {
|
|
2703
|
-
const
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
determineNodeType
|
|
2710
|
-
);
|
|
2711
|
-
if (parsedNode) {
|
|
2712
|
-
return {
|
|
2713
|
-
...rest,
|
|
2714
|
-
children: [
|
|
2715
|
-
...children2,
|
|
2716
|
-
{
|
|
2717
|
-
path: [...path2, localKey],
|
|
2718
|
-
value: parsedNode
|
|
2719
|
-
}
|
|
2720
|
-
]
|
|
2721
|
-
};
|
|
2722
|
-
}
|
|
2723
|
-
} else {
|
|
2724
|
-
const result = parseLocalObject(accumulation.value, localValue, [
|
|
2725
|
-
...path2,
|
|
2726
|
-
localKey
|
|
2727
|
-
]);
|
|
2728
|
-
return {
|
|
2729
|
-
value: result.value,
|
|
2730
|
-
children: [...children2, ...result.children]
|
|
2731
|
-
};
|
|
2732
|
-
}
|
|
2514
|
+
const result = parseLocalObject(accumulation.value, localValue, [
|
|
2515
|
+
...path,
|
|
2516
|
+
localKey
|
|
2517
|
+
]);
|
|
2518
|
+
value2 = result.value;
|
|
2519
|
+
children2.push(...result.children);
|
|
2733
2520
|
} else {
|
|
2734
|
-
|
|
2735
|
-
accumulation.value,
|
|
2736
|
-
[...path2, localKey],
|
|
2737
|
-
localValue
|
|
2738
|
-
);
|
|
2739
|
-
return {
|
|
2740
|
-
children: children2,
|
|
2741
|
-
value: value2
|
|
2742
|
-
};
|
|
2521
|
+
value2 = setIn4(accumulation.value, [...path, localKey], localValue);
|
|
2743
2522
|
}
|
|
2744
|
-
return
|
|
2523
|
+
return {
|
|
2524
|
+
value: value2,
|
|
2525
|
+
children: children2
|
|
2526
|
+
};
|
|
2745
2527
|
}, defaultValue);
|
|
2746
2528
|
return newValue;
|
|
2747
2529
|
};
|
|
2748
2530
|
const { value, children } = parseLocalObject(void 0, obj);
|
|
2749
|
-
const baseAst = value === void 0 && children.length
|
|
2531
|
+
const baseAst = value === void 0 && !children.length ? void 0 : {
|
|
2750
2532
|
type,
|
|
2751
2533
|
value
|
|
2752
2534
|
};
|
|
2753
|
-
if (baseAst
|
|
2535
|
+
if (baseAst && children.length) {
|
|
2754
2536
|
const parent = baseAst;
|
|
2755
2537
|
parent.children = children;
|
|
2756
2538
|
children.forEach((child) => {
|
|
@@ -3105,13 +2887,13 @@ var Resolver = class {
|
|
|
3105
2887
|
|
|
3106
2888
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/view.ts
|
|
3107
2889
|
var CrossfieldProvider = class {
|
|
3108
|
-
constructor(initialView,
|
|
2890
|
+
constructor(initialView, parser, logger) {
|
|
3109
2891
|
this.allValidations = /* @__PURE__ */ new Set();
|
|
3110
2892
|
this.byBinding = /* @__PURE__ */ new Map();
|
|
3111
2893
|
this.logger = logger;
|
|
3112
|
-
this.parse(initialView,
|
|
2894
|
+
this.parse(initialView, parser);
|
|
3113
2895
|
}
|
|
3114
|
-
parse(contentView,
|
|
2896
|
+
parse(contentView, parser) {
|
|
3115
2897
|
const xfieldRefs = contentView.validation;
|
|
3116
2898
|
if (xfieldRefs === void 0) {
|
|
3117
2899
|
return;
|
|
@@ -3131,7 +2913,7 @@ var CrossfieldProvider = class {
|
|
|
3131
2913
|
this.allValidations.add(withDefaults);
|
|
3132
2914
|
const { ref } = vRef;
|
|
3133
2915
|
if (ref) {
|
|
3134
|
-
const parsed =
|
|
2916
|
+
const parsed = parser(ref);
|
|
3135
2917
|
if (this.byBinding.has(parsed)) {
|
|
3136
2918
|
this.byBinding.get(parsed)?.push(withDefaults);
|
|
3137
2919
|
} else {
|
|
@@ -3178,12 +2960,12 @@ var ViewInstance = class {
|
|
|
3178
2960
|
"templatePlugin not set for View, legacy templates may not work"
|
|
3179
2961
|
);
|
|
3180
2962
|
}
|
|
3181
|
-
const
|
|
3182
|
-
this.hooks.parser.call(
|
|
3183
|
-
this.rootNode =
|
|
2963
|
+
const parser = new Parser();
|
|
2964
|
+
this.hooks.parser.call(parser);
|
|
2965
|
+
this.rootNode = parser.parseView(this.initialView);
|
|
3184
2966
|
this.resolver = new Resolver(this.rootNode, {
|
|
3185
2967
|
...this.resolverOptions,
|
|
3186
|
-
parseNode:
|
|
2968
|
+
parseNode: parser.parseObject.bind(parser)
|
|
3187
2969
|
});
|
|
3188
2970
|
this.hooks.resolver.call(this.resolver);
|
|
3189
2971
|
}
|
|
@@ -3248,10 +3030,10 @@ var Builder = class {
|
|
|
3248
3030
|
* @param path - The path at which to add the child
|
|
3249
3031
|
* @param child - The child node
|
|
3250
3032
|
*/
|
|
3251
|
-
static addChild(node,
|
|
3033
|
+
static addChild(node, path, child) {
|
|
3252
3034
|
child.parent = node;
|
|
3253
3035
|
const newChild = {
|
|
3254
|
-
path: Array.isArray(
|
|
3036
|
+
path: Array.isArray(path) ? path : [path],
|
|
3255
3037
|
value: child
|
|
3256
3038
|
};
|
|
3257
3039
|
node.children = node.children || [];
|
|
@@ -3260,7 +3042,7 @@ var Builder = class {
|
|
|
3260
3042
|
}
|
|
3261
3043
|
};
|
|
3262
3044
|
|
|
3263
|
-
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/template
|
|
3045
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/template.ts
|
|
3264
3046
|
import { SyncWaterfallHook as SyncWaterfallHook6 } from "tapable-ts";
|
|
3265
3047
|
var TemplatePlugin = class {
|
|
3266
3048
|
constructor(options) {
|
|
@@ -3315,39 +3097,44 @@ var TemplatePlugin = class {
|
|
|
3315
3097
|
};
|
|
3316
3098
|
return result;
|
|
3317
3099
|
}
|
|
3318
|
-
applyParser(
|
|
3319
|
-
|
|
3100
|
+
applyParser(parser) {
|
|
3101
|
+
parser.hooks.onCreateASTNode.tap("template", (node) => {
|
|
3320
3102
|
if (node && node.type === "template" /* Template */ && !node.dynamic) {
|
|
3321
3103
|
return this.parseTemplate(
|
|
3322
|
-
|
|
3104
|
+
parser.parseObject.bind(parser),
|
|
3323
3105
|
node,
|
|
3324
3106
|
this.options
|
|
3325
3107
|
);
|
|
3326
3108
|
}
|
|
3327
3109
|
return node;
|
|
3328
3110
|
});
|
|
3329
|
-
|
|
3330
|
-
if (obj === "template") {
|
|
3331
|
-
return "template" /* Template */;
|
|
3332
|
-
}
|
|
3333
|
-
});
|
|
3334
|
-
parser2.hooks.parseNode.tap(
|
|
3111
|
+
parser.hooks.parseNode.tap(
|
|
3335
3112
|
"template",
|
|
3336
|
-
(obj, _nodeType, options,
|
|
3337
|
-
if (
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3113
|
+
(obj, _nodeType, options, childOptions) => {
|
|
3114
|
+
if (childOptions && hasTemplateKey(childOptions.key)) {
|
|
3115
|
+
return obj.map((template) => {
|
|
3116
|
+
const templateAST = parser.createASTNode(
|
|
3117
|
+
{
|
|
3118
|
+
type: "template" /* Template */,
|
|
3119
|
+
depth: options.templateDepth ?? 0,
|
|
3120
|
+
data: template.data,
|
|
3121
|
+
template: template.value,
|
|
3122
|
+
dynamic: template.dynamic ?? false
|
|
3123
|
+
},
|
|
3124
|
+
template
|
|
3125
|
+
);
|
|
3126
|
+
if (!templateAST)
|
|
3127
|
+
return;
|
|
3128
|
+
if (templateAST.type === "multi-node" /* MultiNode */) {
|
|
3129
|
+
templateAST.values.forEach((v) => {
|
|
3130
|
+
v.parent = templateAST;
|
|
3131
|
+
});
|
|
3132
|
+
}
|
|
3133
|
+
return {
|
|
3134
|
+
path: [...childOptions.path, template.output],
|
|
3135
|
+
value: templateAST
|
|
3136
|
+
};
|
|
3137
|
+
}).filter(Boolean);
|
|
3351
3138
|
}
|
|
3352
3139
|
}
|
|
3353
3140
|
);
|
|
@@ -3457,7 +3244,7 @@ var StringResolverPlugin = class {
|
|
|
3457
3244
|
propsToSkip = /* @__PURE__ */ new Set(["exp"]);
|
|
3458
3245
|
}
|
|
3459
3246
|
const nodePath = findBasePath(node, resolver);
|
|
3460
|
-
if (nodePath.length > 0 && nodePath.some((
|
|
3247
|
+
if (nodePath.length > 0 && nodePath.some((segment) => propsToSkip.has(segment.toString()))) {
|
|
3461
3248
|
return node.value;
|
|
3462
3249
|
}
|
|
3463
3250
|
return resolveAllRefs(node.value, options, propsToSkip);
|
|
@@ -3471,8 +3258,11 @@ var StringResolverPlugin = class {
|
|
|
3471
3258
|
};
|
|
3472
3259
|
|
|
3473
3260
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/applicability.ts
|
|
3474
|
-
import { omit as
|
|
3261
|
+
import { omit as omit2 } from "timm";
|
|
3475
3262
|
var ApplicabilityPlugin = class {
|
|
3263
|
+
isApplicability(obj) {
|
|
3264
|
+
return obj && Object.prototype.hasOwnProperty.call(obj, "applicability");
|
|
3265
|
+
}
|
|
3476
3266
|
applyResolver(resolver) {
|
|
3477
3267
|
resolver.hooks.beforeResolve.tap(
|
|
3478
3268
|
"applicability",
|
|
@@ -3489,35 +3279,39 @@ var ApplicabilityPlugin = class {
|
|
|
3489
3279
|
}
|
|
3490
3280
|
);
|
|
3491
3281
|
}
|
|
3492
|
-
applyParser(
|
|
3493
|
-
|
|
3494
|
-
if (Object.prototype.hasOwnProperty.call(obj, "applicability")) {
|
|
3495
|
-
return "applicability" /* Applicability */;
|
|
3496
|
-
}
|
|
3497
|
-
});
|
|
3498
|
-
parser2.hooks.parseNode.tap(
|
|
3282
|
+
applyParser(parser) {
|
|
3283
|
+
parser.hooks.parseNode.tap(
|
|
3499
3284
|
"applicability",
|
|
3500
|
-
(obj, nodeType, options,
|
|
3501
|
-
if (
|
|
3502
|
-
const parsedApplicability =
|
|
3503
|
-
|
|
3285
|
+
(obj, nodeType, options, childOptions) => {
|
|
3286
|
+
if (this.isApplicability(obj)) {
|
|
3287
|
+
const parsedApplicability = parser.parseObject(
|
|
3288
|
+
omit2(obj, "applicability"),
|
|
3504
3289
|
nodeType,
|
|
3505
3290
|
options
|
|
3506
3291
|
);
|
|
3507
|
-
if (parsedApplicability
|
|
3508
|
-
|
|
3509
|
-
{
|
|
3510
|
-
type: "applicability" /* Applicability */,
|
|
3511
|
-
expression: obj.applicability,
|
|
3512
|
-
value: parsedApplicability
|
|
3513
|
-
},
|
|
3514
|
-
obj
|
|
3515
|
-
);
|
|
3516
|
-
if (applicabilityNode?.type === "applicability" /* Applicability */) {
|
|
3517
|
-
applicabilityNode.value.parent = applicabilityNode;
|
|
3518
|
-
}
|
|
3519
|
-
return applicabilityNode;
|
|
3292
|
+
if (!parsedApplicability) {
|
|
3293
|
+
return childOptions ? [] : null;
|
|
3520
3294
|
}
|
|
3295
|
+
const applicabilityNode = parser.createASTNode(
|
|
3296
|
+
{
|
|
3297
|
+
type: "applicability" /* Applicability */,
|
|
3298
|
+
expression: obj.applicability,
|
|
3299
|
+
value: parsedApplicability
|
|
3300
|
+
},
|
|
3301
|
+
obj
|
|
3302
|
+
);
|
|
3303
|
+
if (!applicabilityNode) {
|
|
3304
|
+
return childOptions ? [] : null;
|
|
3305
|
+
}
|
|
3306
|
+
if (applicabilityNode.type === "applicability" /* Applicability */) {
|
|
3307
|
+
applicabilityNode.value.parent = applicabilityNode;
|
|
3308
|
+
}
|
|
3309
|
+
return childOptions ? [
|
|
3310
|
+
{
|
|
3311
|
+
path: [...childOptions.path, childOptions.key],
|
|
3312
|
+
value: applicabilityNode
|
|
3313
|
+
}
|
|
3314
|
+
] : applicabilityNode;
|
|
3521
3315
|
}
|
|
3522
3316
|
}
|
|
3523
3317
|
);
|
|
@@ -3542,58 +3336,67 @@ var SwitchPlugin = class {
|
|
|
3542
3336
|
}
|
|
3543
3337
|
return EMPTY_NODE;
|
|
3544
3338
|
}
|
|
3545
|
-
|
|
3546
|
-
|
|
3339
|
+
isSwitch(obj) {
|
|
3340
|
+
return obj && (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch"));
|
|
3341
|
+
}
|
|
3342
|
+
applyParser(parser) {
|
|
3343
|
+
parser.hooks.onCreateASTNode.tap("switch", (node) => {
|
|
3547
3344
|
if (node && node.type === "switch" /* Switch */ && !node.dynamic) {
|
|
3548
3345
|
return this.resolveSwitch(node, this.options);
|
|
3549
3346
|
}
|
|
3550
3347
|
return node;
|
|
3551
3348
|
});
|
|
3552
|
-
|
|
3553
|
-
if (Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") || Object.prototype.hasOwnProperty.call(obj, "staticSwitch")) {
|
|
3554
|
-
return "switch" /* Switch */;
|
|
3555
|
-
}
|
|
3556
|
-
});
|
|
3557
|
-
parser2.hooks.parseNode.tap(
|
|
3349
|
+
parser.hooks.parseNode.tap(
|
|
3558
3350
|
"switch",
|
|
3559
|
-
(obj, _nodeType, options,
|
|
3560
|
-
if (
|
|
3561
|
-
const
|
|
3562
|
-
const
|
|
3563
|
-
const
|
|
3564
|
-
switchContent.
|
|
3351
|
+
(obj, _nodeType, options, childOptions) => {
|
|
3352
|
+
if (this.isSwitch(obj) || childOptions && hasSwitchKey(childOptions.key)) {
|
|
3353
|
+
const objToParse = childOptions && hasSwitchKey(childOptions.key) ? { [childOptions.key]: obj } : obj;
|
|
3354
|
+
const dynamic = "dynamicSwitch" in objToParse;
|
|
3355
|
+
const switchContent = dynamic ? objToParse.dynamicSwitch : objToParse.staticSwitch;
|
|
3356
|
+
const cases = switchContent.map(
|
|
3565
3357
|
(switchCase) => {
|
|
3566
3358
|
const { case: switchCaseExpr, ...switchBody } = switchCase;
|
|
3567
|
-
const value =
|
|
3359
|
+
const value = parser.parseObject(
|
|
3568
3360
|
switchBody,
|
|
3569
3361
|
"value" /* Value */,
|
|
3570
3362
|
options
|
|
3571
3363
|
);
|
|
3572
3364
|
if (value) {
|
|
3573
|
-
|
|
3365
|
+
return {
|
|
3574
3366
|
case: switchCaseExpr,
|
|
3575
3367
|
value
|
|
3576
|
-
}
|
|
3368
|
+
};
|
|
3577
3369
|
}
|
|
3370
|
+
return;
|
|
3578
3371
|
}
|
|
3579
|
-
);
|
|
3580
|
-
const switchAST =
|
|
3372
|
+
).filter(Boolean);
|
|
3373
|
+
const switchAST = parser.createASTNode(
|
|
3581
3374
|
{
|
|
3582
3375
|
type: "switch" /* Switch */,
|
|
3583
3376
|
dynamic,
|
|
3584
3377
|
cases
|
|
3585
3378
|
},
|
|
3586
|
-
|
|
3379
|
+
objToParse
|
|
3587
3380
|
);
|
|
3588
|
-
if (switchAST
|
|
3381
|
+
if (!switchAST || switchAST.type === "empty" /* Empty */) {
|
|
3382
|
+
return childOptions ? [] : null;
|
|
3383
|
+
}
|
|
3384
|
+
if (switchAST.type === "switch" /* Switch */) {
|
|
3589
3385
|
switchAST.cases.forEach((sCase) => {
|
|
3590
3386
|
sCase.value.parent = switchAST;
|
|
3591
3387
|
});
|
|
3592
3388
|
}
|
|
3593
|
-
if (
|
|
3594
|
-
|
|
3389
|
+
if (childOptions) {
|
|
3390
|
+
let path = [...childOptions.path, childOptions.key];
|
|
3391
|
+
let value = switchAST;
|
|
3392
|
+
if (switchAST.type === "value" /* Value */ && switchAST.children?.length === 1 && switchAST.value === void 0) {
|
|
3393
|
+
const firstChild = switchAST.children[0];
|
|
3394
|
+
path = [...path, ...firstChild.path];
|
|
3395
|
+
value = firstChild.value;
|
|
3396
|
+
}
|
|
3397
|
+
return [{ path, value }];
|
|
3595
3398
|
}
|
|
3596
|
-
return switchAST
|
|
3399
|
+
return switchAST;
|
|
3597
3400
|
}
|
|
3598
3401
|
}
|
|
3599
3402
|
);
|
|
@@ -3612,6 +3415,79 @@ var SwitchPlugin = class {
|
|
|
3612
3415
|
}
|
|
3613
3416
|
};
|
|
3614
3417
|
|
|
3418
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/multi-node.ts
|
|
3419
|
+
var MultiNodePlugin = class {
|
|
3420
|
+
applyParser(parser) {
|
|
3421
|
+
parser.hooks.parseNode.tap(
|
|
3422
|
+
"multi-node",
|
|
3423
|
+
(obj, nodeType, options, childOptions) => {
|
|
3424
|
+
if (childOptions && !hasTemplateKey(childOptions.key) && Array.isArray(obj)) {
|
|
3425
|
+
const values = obj.map(
|
|
3426
|
+
(childVal) => parser.parseObject(childVal, "value" /* Value */, options)
|
|
3427
|
+
).filter((child) => !!child);
|
|
3428
|
+
if (!values.length) {
|
|
3429
|
+
return [];
|
|
3430
|
+
}
|
|
3431
|
+
const multiNode = parser.createASTNode(
|
|
3432
|
+
{
|
|
3433
|
+
type: "multi-node" /* MultiNode */,
|
|
3434
|
+
override: !hasTemplateValues(
|
|
3435
|
+
childOptions.parentObj,
|
|
3436
|
+
childOptions.key
|
|
3437
|
+
),
|
|
3438
|
+
values
|
|
3439
|
+
},
|
|
3440
|
+
obj
|
|
3441
|
+
);
|
|
3442
|
+
if (!multiNode) {
|
|
3443
|
+
return [];
|
|
3444
|
+
}
|
|
3445
|
+
if (multiNode.type === "multi-node" /* MultiNode */) {
|
|
3446
|
+
multiNode.values.forEach((v) => {
|
|
3447
|
+
v.parent = multiNode;
|
|
3448
|
+
});
|
|
3449
|
+
}
|
|
3450
|
+
return [
|
|
3451
|
+
{
|
|
3452
|
+
path: [...childOptions.path, childOptions.key],
|
|
3453
|
+
value: multiNode
|
|
3454
|
+
}
|
|
3455
|
+
];
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
);
|
|
3459
|
+
}
|
|
3460
|
+
apply(view) {
|
|
3461
|
+
view.hooks.parser.tap("multi-node", this.applyParser.bind(this));
|
|
3462
|
+
}
|
|
3463
|
+
};
|
|
3464
|
+
|
|
3465
|
+
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/view/plugins/asset.ts
|
|
3466
|
+
var AssetPlugin = class {
|
|
3467
|
+
applyParser(parser) {
|
|
3468
|
+
parser.hooks.parseNode.tap(
|
|
3469
|
+
"asset",
|
|
3470
|
+
(obj, nodeType, options, childOptions) => {
|
|
3471
|
+
if (childOptions?.key === "asset" && typeof obj === "object") {
|
|
3472
|
+
const assetAST = parser.parseObject(obj, "asset" /* Asset */, options);
|
|
3473
|
+
if (!assetAST) {
|
|
3474
|
+
return [];
|
|
3475
|
+
}
|
|
3476
|
+
return [
|
|
3477
|
+
{
|
|
3478
|
+
path: [...childOptions.path, childOptions.key],
|
|
3479
|
+
value: assetAST
|
|
3480
|
+
}
|
|
3481
|
+
];
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
);
|
|
3485
|
+
}
|
|
3486
|
+
apply(view) {
|
|
3487
|
+
view.hooks.parser.tap("asset", this.applyParser.bind(this));
|
|
3488
|
+
}
|
|
3489
|
+
};
|
|
3490
|
+
|
|
3615
3491
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/player.ts
|
|
3616
3492
|
import { setIn as setIn7 } from "timm";
|
|
3617
3493
|
import deferred from "p-defer";
|
|
@@ -4471,11 +4347,11 @@ var ValidationController = class {
|
|
|
4471
4347
|
getValidationForBinding(binding) {
|
|
4472
4348
|
return this.validations.get(binding);
|
|
4473
4349
|
}
|
|
4474
|
-
forView(
|
|
4350
|
+
forView(parser) {
|
|
4475
4351
|
return {
|
|
4476
4352
|
_getValidationForBinding: (binding) => {
|
|
4477
4353
|
return this.getValidationForBinding(
|
|
4478
|
-
isBinding(binding) ? binding :
|
|
4354
|
+
isBinding(binding) ? binding : parser(binding)
|
|
4479
4355
|
);
|
|
4480
4356
|
},
|
|
4481
4357
|
getAll: () => {
|
|
@@ -4512,7 +4388,7 @@ var ValidationController = class {
|
|
|
4512
4388
|
"Section functionality should be provided by the view plugin"
|
|
4513
4389
|
);
|
|
4514
4390
|
},
|
|
4515
|
-
type: (binding) => this.schema.getType(isBinding(binding) ? binding :
|
|
4391
|
+
type: (binding) => this.schema.getType(isBinding(binding) ? binding : parser(binding))
|
|
4516
4392
|
};
|
|
4517
4393
|
}
|
|
4518
4394
|
};
|
|
@@ -4954,7 +4830,7 @@ var DataController = class {
|
|
|
4954
4830
|
};
|
|
4955
4831
|
|
|
4956
4832
|
// ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/core/player/src/controllers/constants/utils.ts
|
|
4957
|
-
function
|
|
4833
|
+
function flatten(obj, roots = [], sep = ".") {
|
|
4958
4834
|
return Object.keys(obj).reduce(
|
|
4959
4835
|
(memo, prop) => ({
|
|
4960
4836
|
// create a new object
|
|
@@ -4962,7 +4838,7 @@ function flatten2(obj, roots = [], sep = ".") {
|
|
|
4962
4838
|
...memo,
|
|
4963
4839
|
...Object.prototype.toString.call(obj[prop]) === "[object Object]" ? (
|
|
4964
4840
|
// keep working if value is an object
|
|
4965
|
-
|
|
4841
|
+
flatten(obj[prop], roots.concat([prop]))
|
|
4966
4842
|
) : (
|
|
4967
4843
|
// include current prop and value and prefix prop with the roots
|
|
4968
4844
|
{ [roots.concat([prop]).join(sep)]: obj[prop] }
|
|
@@ -4972,7 +4848,7 @@ function flatten2(obj, roots = [], sep = ".") {
|
|
|
4972
4848
|
);
|
|
4973
4849
|
}
|
|
4974
4850
|
function objectToBatchSet(obj) {
|
|
4975
|
-
const flattenedObj =
|
|
4851
|
+
const flattenedObj = flatten(obj);
|
|
4976
4852
|
const batchTxn = [];
|
|
4977
4853
|
Object.keys(flattenedObj).forEach((key) => {
|
|
4978
4854
|
batchTxn.push([new BindingInstance(key), flattenedObj[key]]);
|
|
@@ -4994,8 +4870,8 @@ var ConstantsController = class {
|
|
|
4994
4870
|
}
|
|
4995
4871
|
}
|
|
4996
4872
|
getConstants(key, namespace, fallback) {
|
|
4997
|
-
const
|
|
4998
|
-
return this.tempStore.get(namespace)?.get(
|
|
4873
|
+
const path = new BindingInstance(key);
|
|
4874
|
+
return this.tempStore.get(namespace)?.get(path) ?? this.store.get(namespace)?.get(path) ?? fallback;
|
|
4999
4875
|
}
|
|
5000
4876
|
setTemporaryValues(data, namespace) {
|
|
5001
4877
|
if (this.tempStore.has(namespace)) {
|
|
@@ -5101,12 +4977,14 @@ var DefaultViewPlugin = class {
|
|
|
5101
4977
|
player.hooks.viewController.tap(this.name, (viewController) => {
|
|
5102
4978
|
viewController.hooks.view.tap(this.name, (view) => {
|
|
5103
4979
|
const pluginOptions = toNodeResolveOptions(view.resolverOptions);
|
|
4980
|
+
new AssetPlugin().apply(view);
|
|
5104
4981
|
new SwitchPlugin(pluginOptions).apply(view);
|
|
5105
4982
|
new ApplicabilityPlugin().apply(view);
|
|
5106
4983
|
new StringResolverPlugin().apply(view);
|
|
5107
4984
|
const templatePlugin = new TemplatePlugin(pluginOptions);
|
|
5108
4985
|
templatePlugin.apply(view);
|
|
5109
4986
|
view.hooks.onTemplatePluginCreated.call(templatePlugin);
|
|
4987
|
+
new MultiNodePlugin().apply(view);
|
|
5110
4988
|
});
|
|
5111
4989
|
});
|
|
5112
4990
|
}
|
|
@@ -5451,6 +5329,7 @@ _Player.info = {
|
|
|
5451
5329
|
var Player = _Player;
|
|
5452
5330
|
export {
|
|
5453
5331
|
ApplicabilityPlugin,
|
|
5332
|
+
AssetPlugin,
|
|
5454
5333
|
AssetTransformCorePlugin,
|
|
5455
5334
|
BINDING_BRACKETS_REGEX,
|
|
5456
5335
|
BindingInstance,
|
|
@@ -5470,6 +5349,7 @@ export {
|
|
|
5470
5349
|
FlowInstance,
|
|
5471
5350
|
LocalModel,
|
|
5472
5351
|
LocalStateStore,
|
|
5352
|
+
MultiNodePlugin,
|
|
5473
5353
|
NOOPDataModel,
|
|
5474
5354
|
NOOP_MODEL,
|
|
5475
5355
|
NOT_STARTED_STATE,
|
|
@@ -5503,13 +5383,15 @@ export {
|
|
|
5503
5383
|
findNextExp,
|
|
5504
5384
|
getBindingSegments,
|
|
5505
5385
|
getNodeID,
|
|
5506
|
-
|
|
5386
|
+
hasSwitchKey,
|
|
5387
|
+
hasTemplateKey,
|
|
5388
|
+
hasTemplateValues,
|
|
5507
5389
|
isBinding,
|
|
5508
5390
|
isErrorWithLocation,
|
|
5509
5391
|
isExpressionNode,
|
|
5510
5392
|
isObjectExpression,
|
|
5511
5393
|
maybeConvertToNum,
|
|
5512
|
-
|
|
5394
|
+
parse2 as parse,
|
|
5513
5395
|
parseExpression,
|
|
5514
5396
|
removeBindingAndChildrenFromMap,
|
|
5515
5397
|
resolveDataRefs,
|