@player-ui/player 0.4.0-next.3 → 0.4.0-next.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +48 -23
- package/dist/index.d.ts +16 -1
- package/dist/index.esm.js +48 -24
- package/dist/player.dev.js +11968 -0
- package/dist/player.prod.js +2 -0
- package/package.json +3 -3
- package/src/expressions/evaluator.ts +2 -2
- package/src/expressions/index.ts +1 -0
- package/src/expressions/parser.ts +53 -27
- package/src/expressions/types.ts +6 -0
- package/src/player.ts +2 -2
- package/src/view/parser/index.ts +7 -1
package/dist/index.cjs.js
CHANGED
|
@@ -909,7 +909,9 @@ function isIdentifierPart(ch) {
|
|
|
909
909
|
function isModelRefStart(ch0, ch1) {
|
|
910
910
|
return ch0 === OCURL_CODE && ch1 === OCURL_CODE;
|
|
911
911
|
}
|
|
912
|
-
function parseExpression(expr) {
|
|
912
|
+
function parseExpression(expr, options) {
|
|
913
|
+
var _a;
|
|
914
|
+
const strictMode = (_a = options == null ? void 0 : options.strict) != null ? _a : true;
|
|
913
915
|
const charAtFunc = expr.charAt;
|
|
914
916
|
const charCodeAtFunc = expr.charCodeAt;
|
|
915
917
|
const { length } = expr;
|
|
@@ -1303,6 +1305,9 @@ function parseExpression(expr) {
|
|
|
1303
1305
|
}
|
|
1304
1306
|
args.push(node);
|
|
1305
1307
|
}
|
|
1308
|
+
if (charIndex !== termination) {
|
|
1309
|
+
throwError(`Expected ${String.fromCharCode(termination)}`, index);
|
|
1310
|
+
}
|
|
1306
1311
|
return args;
|
|
1307
1312
|
}
|
|
1308
1313
|
function gobbleVariable() {
|
|
@@ -1373,28 +1378,41 @@ function parseExpression(expr) {
|
|
|
1373
1378
|
};
|
|
1374
1379
|
}
|
|
1375
1380
|
const nodes = [];
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
+
try {
|
|
1382
|
+
while (index < length) {
|
|
1383
|
+
const chIndex = exprICode(index);
|
|
1384
|
+
if (chIndex === SEMCOL_CODE || chIndex === COMMA_CODE) {
|
|
1385
|
+
index++;
|
|
1386
|
+
continue;
|
|
1387
|
+
}
|
|
1388
|
+
const node = gobbleExpression();
|
|
1389
|
+
if (node) {
|
|
1390
|
+
nodes.push(node);
|
|
1391
|
+
} else if (index < length) {
|
|
1392
|
+
throwError(`Unexpected "${exprI(index)}"`, index);
|
|
1393
|
+
}
|
|
1381
1394
|
}
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
nodes.push(node);
|
|
1385
|
-
} else if (index < length) {
|
|
1386
|
-
throwError(`Unexpected "${exprI(index)}"`, index);
|
|
1395
|
+
if (nodes.length === 1) {
|
|
1396
|
+
return nodes[0];
|
|
1387
1397
|
}
|
|
1398
|
+
return {
|
|
1399
|
+
__id: ExpNodeOpaqueIdentifier,
|
|
1400
|
+
type: "Compound",
|
|
1401
|
+
body: nodes,
|
|
1402
|
+
location: getLocation(0)
|
|
1403
|
+
};
|
|
1404
|
+
} catch (e) {
|
|
1405
|
+
if (strictMode || !(e instanceof Error)) {
|
|
1406
|
+
throw e;
|
|
1407
|
+
}
|
|
1408
|
+
return {
|
|
1409
|
+
__id: ExpNodeOpaqueIdentifier,
|
|
1410
|
+
type: "Compound",
|
|
1411
|
+
body: nodes,
|
|
1412
|
+
location: getLocation(0),
|
|
1413
|
+
error: e
|
|
1414
|
+
};
|
|
1388
1415
|
}
|
|
1389
|
-
if (nodes.length === 1) {
|
|
1390
|
-
return nodes[0];
|
|
1391
|
-
}
|
|
1392
|
-
return {
|
|
1393
|
-
__id: ExpNodeOpaqueIdentifier,
|
|
1394
|
-
type: "Compound",
|
|
1395
|
-
body: nodes,
|
|
1396
|
-
location: getLocation(0)
|
|
1397
|
-
};
|
|
1398
1416
|
}
|
|
1399
1417
|
|
|
1400
1418
|
const setDataVal = (_context, binding, value) => {
|
|
@@ -2276,7 +2294,13 @@ class Parser {
|
|
|
2276
2294
|
if (!localObj) {
|
|
2277
2295
|
return currentValue;
|
|
2278
2296
|
}
|
|
2279
|
-
const objEntries = Array.isArray(localObj) ? localObj.map((v, i) => [i, v]) :
|
|
2297
|
+
const objEntries = Array.isArray(localObj) ? localObj.map((v, i) => [i, v]) : [
|
|
2298
|
+
...Object.entries(localObj),
|
|
2299
|
+
...Object.getOwnPropertySymbols(localObj).map((s) => [
|
|
2300
|
+
s,
|
|
2301
|
+
localObj[s]
|
|
2302
|
+
])
|
|
2303
|
+
];
|
|
2280
2304
|
const defaultValue = {
|
|
2281
2305
|
children: [],
|
|
2282
2306
|
value: currentValue
|
|
@@ -4421,8 +4445,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
4421
4445
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
4422
4446
|
});
|
|
4423
4447
|
};
|
|
4424
|
-
const PLAYER_VERSION = "0.4.0-next.
|
|
4425
|
-
const COMMIT = "
|
|
4448
|
+
const PLAYER_VERSION = "0.4.0-next.5";
|
|
4449
|
+
const COMMIT = "a7957331b94ce0a7d50709a0d636a406b033300f";
|
|
4426
4450
|
const _Player = class {
|
|
4427
4451
|
constructor(config) {
|
|
4428
4452
|
this.logger = new TapableLogger();
|
|
@@ -4769,6 +4793,7 @@ exports.isBinding = isBinding;
|
|
|
4769
4793
|
exports.isExpressionNode = isExpressionNode;
|
|
4770
4794
|
exports.maybeConvertToNum = maybeConvertToNum;
|
|
4771
4795
|
exports.parse = parse;
|
|
4796
|
+
exports.parseExpression = parseExpression;
|
|
4772
4797
|
exports.resolveDataRefs = resolveDataRefs;
|
|
4773
4798
|
exports.resolveDataRefsInString = resolveDataRefsInString;
|
|
4774
4799
|
exports.resolveExpressionsInString = resolveExpressionsInString;
|
package/dist/index.d.ts
CHANGED
|
@@ -391,6 +391,11 @@ interface BaseNode<T> {
|
|
|
391
391
|
__id: typeof ExpNodeOpaqueIdentifier;
|
|
392
392
|
/** The location of the node in the source expression string */
|
|
393
393
|
location?: NodeLocation;
|
|
394
|
+
/**
|
|
395
|
+
* The error that occurred while parsing this node
|
|
396
|
+
* This is only set if the parsing mode is set to non-strict
|
|
397
|
+
*/
|
|
398
|
+
error?: Error;
|
|
394
399
|
}
|
|
395
400
|
/** A helper interface for nodes that container left and right children */
|
|
396
401
|
interface DirectionalNode {
|
|
@@ -520,6 +525,16 @@ declare function withoutContext<T extends unknown[], Return>(fn: (...args: T) =>
|
|
|
520
525
|
/** Get the node in the expression that's closest to the desired position */
|
|
521
526
|
declare function findClosestNodeAtPosition(node: ExpressionNode, position: NodePosition): ExpressionNode | undefined;
|
|
522
527
|
|
|
528
|
+
/**
|
|
529
|
+
* An expression to AST parser based on JSEP: http://jsep.from.so/
|
|
530
|
+
*/
|
|
531
|
+
|
|
532
|
+
/** Parse out an expression from the string */
|
|
533
|
+
declare function parseExpression(expr: string, options?: {
|
|
534
|
+
/** If true (the default), will throw on invalid expressions */
|
|
535
|
+
strict?: boolean;
|
|
536
|
+
}): ExpressionNode;
|
|
537
|
+
|
|
523
538
|
declare type FormatOptions = Omit<Formatting.Reference, 'type'>;
|
|
524
539
|
/**
|
|
525
540
|
* The return types for the schema don't include options.
|
|
@@ -1636,4 +1651,4 @@ declare class FlowExpPlugin implements PlayerPlugin {
|
|
|
1636
1651
|
apply(player: Player): void;
|
|
1637
1652
|
}
|
|
1638
1653
|
|
|
1639
|
-
export { AnyAssetType, ApplicabilityPlugin, ArrayExpressionNode, AssetTransformCorePlugin, AssignmentNode, BaseFlowState, BaseNode, BatchSetTransaction, BeforeTransformFunction, BinaryNode, BinaryOperator, BinaryOperatorAdvanced, BinaryOperatorBasic, BindingFactory, BindingInstance, BindingLike, BindingParser, BindingParserOptions, BindingTracker, Builder, CallExpressionNode, CompletedState, CompoundNode, ConditionalExpressionNode, ConsoleLogger, ConstantsController, ConstantsProvider, ControllerState, DataController, DataModelImpl, DataModelMiddleware, DataModelOptions, DataModelWithParser, DataPipeline, DependencyMiddleware, DependencyModel, DependencySets, DependencyTracker, DirectionalNode, EMPTY_NODE, ErrorState, ErrorValidationResponse, ExpNodeOpaqueIdentifier, ExpressionContext, ExpressionEvaluator, ExpressionEvaluatorFunction, ExpressionEvaluatorOptions, ExpressionHandler, ExpressionLiteralType, ExpressionNode, ExpressionNodeType, ExpressionType, FlowController, FlowExpPlugin, FlowInstance, FormatDefinition, FormatFunction, FormatHandler, FormatOptions, FormatType, Getter, HookOptions, IdentifierNode, InProgressState, LiteralNode, LocalModel, LocalStateStore, LogFn, Logger, LoggerProvider, LogicalNode, MemberExpressionNode, MiddlewareChecker, ModelRefNode, ModificationNode, NOOPDataModel, NOOP_MODEL, NOT_STARTED_STATE, NamedState, Node, NodeLocation, NodePosition, NodeType, NoopLogger, NotStartedState, ObjectNode, OperatorProcessingOptions, Options, ParseObjectOptions, Parser, PipelinedDataModel, Player, PlayerConfigOptions, PlayerFlowExecutionData, PlayerFlowState, PlayerFlowStatus, PlayerInfo, PlayerPlugin, ProxyLogger, ROOT_BINDING, RawBinding, RawBindingSegment, RawSetTransaction, RawSetType, Resolve, Resolver, SIMPLE_BINDING_REGEX, SchemaController, Severity, StatefulValidationObject, Store, StringResolverPlugin, StrongOrWeakBinding, SwitchPlugin, TapableLogger, TemplatePlugin, ThisNode, TransformFunction, TransformFunctions, TransformRegistry, TransitionFunction, TransitionOptions, UnaryNode, UnaryOperator, Updates, ValidationBindingTrackerViewPlugin, ValidationController, ValidationMiddleware, ValidationObject, ValidationProvider, ValidationResponse, ValidatorContext, ValidatorFunction, ValidatorRegistry, ViewController, ViewControllerOptions, ViewInstance, ViewPlugin, WarningValidationResponse, caresAboutDataChanges, constructModelForPipeline, findClosestNodeAtPosition, findInArray, findNextExp, getBindingSegments, isBinding, isExpressionNode, maybeConvertToNum, parse, resolveDataRefs, resolveDataRefsInString, resolveExpressionsInString, severities, toModel, toNodeResolveOptions, withParser, withoutContext };
|
|
1654
|
+
export { AnyAssetType, ApplicabilityPlugin, ArrayExpressionNode, AssetTransformCorePlugin, AssignmentNode, BaseFlowState, BaseNode, BatchSetTransaction, BeforeTransformFunction, BinaryNode, BinaryOperator, BinaryOperatorAdvanced, BinaryOperatorBasic, BindingFactory, BindingInstance, BindingLike, BindingParser, BindingParserOptions, BindingTracker, Builder, CallExpressionNode, CompletedState, CompoundNode, ConditionalExpressionNode, ConsoleLogger, ConstantsController, ConstantsProvider, ControllerState, DataController, DataModelImpl, DataModelMiddleware, DataModelOptions, DataModelWithParser, DataPipeline, DependencyMiddleware, DependencyModel, DependencySets, DependencyTracker, DirectionalNode, EMPTY_NODE, ErrorState, ErrorValidationResponse, ExpNodeOpaqueIdentifier, ExpressionContext, ExpressionEvaluator, ExpressionEvaluatorFunction, ExpressionEvaluatorOptions, ExpressionHandler, ExpressionLiteralType, ExpressionNode, ExpressionNodeType, ExpressionType, FlowController, FlowExpPlugin, FlowInstance, FormatDefinition, FormatFunction, FormatHandler, FormatOptions, FormatType, Getter, HookOptions, IdentifierNode, InProgressState, LiteralNode, LocalModel, LocalStateStore, LogFn, Logger, LoggerProvider, LogicalNode, MemberExpressionNode, MiddlewareChecker, ModelRefNode, ModificationNode, NOOPDataModel, NOOP_MODEL, NOT_STARTED_STATE, NamedState, Node, NodeLocation, NodePosition, NodeType, NoopLogger, NotStartedState, ObjectNode, OperatorProcessingOptions, Options, ParseObjectOptions, Parser, PipelinedDataModel, Player, PlayerConfigOptions, PlayerFlowExecutionData, PlayerFlowState, PlayerFlowStatus, PlayerInfo, PlayerPlugin, ProxyLogger, ROOT_BINDING, RawBinding, RawBindingSegment, RawSetTransaction, RawSetType, Resolve, Resolver, SIMPLE_BINDING_REGEX, SchemaController, Severity, StatefulValidationObject, Store, StringResolverPlugin, StrongOrWeakBinding, SwitchPlugin, TapableLogger, TemplatePlugin, ThisNode, TransformFunction, TransformFunctions, TransformRegistry, TransitionFunction, TransitionOptions, UnaryNode, UnaryOperator, Updates, ValidationBindingTrackerViewPlugin, ValidationController, ValidationMiddleware, ValidationObject, ValidationProvider, ValidationResponse, ValidatorContext, ValidatorFunction, ValidatorRegistry, ViewController, ViewControllerOptions, ViewInstance, ViewPlugin, WarningValidationResponse, caresAboutDataChanges, constructModelForPipeline, findClosestNodeAtPosition, findInArray, findNextExp, getBindingSegments, isBinding, isExpressionNode, maybeConvertToNum, parse, parseExpression, resolveDataRefs, resolveDataRefsInString, resolveExpressionsInString, severities, toModel, toNodeResolveOptions, withParser, withoutContext };
|
package/dist/index.esm.js
CHANGED
|
@@ -896,7 +896,9 @@ function isIdentifierPart(ch) {
|
|
|
896
896
|
function isModelRefStart(ch0, ch1) {
|
|
897
897
|
return ch0 === OCURL_CODE && ch1 === OCURL_CODE;
|
|
898
898
|
}
|
|
899
|
-
function parseExpression(expr) {
|
|
899
|
+
function parseExpression(expr, options) {
|
|
900
|
+
var _a;
|
|
901
|
+
const strictMode = (_a = options == null ? void 0 : options.strict) != null ? _a : true;
|
|
900
902
|
const charAtFunc = expr.charAt;
|
|
901
903
|
const charCodeAtFunc = expr.charCodeAt;
|
|
902
904
|
const { length } = expr;
|
|
@@ -1290,6 +1292,9 @@ function parseExpression(expr) {
|
|
|
1290
1292
|
}
|
|
1291
1293
|
args.push(node);
|
|
1292
1294
|
}
|
|
1295
|
+
if (charIndex !== termination) {
|
|
1296
|
+
throwError(`Expected ${String.fromCharCode(termination)}`, index);
|
|
1297
|
+
}
|
|
1293
1298
|
return args;
|
|
1294
1299
|
}
|
|
1295
1300
|
function gobbleVariable() {
|
|
@@ -1360,28 +1365,41 @@ function parseExpression(expr) {
|
|
|
1360
1365
|
};
|
|
1361
1366
|
}
|
|
1362
1367
|
const nodes = [];
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
+
try {
|
|
1369
|
+
while (index < length) {
|
|
1370
|
+
const chIndex = exprICode(index);
|
|
1371
|
+
if (chIndex === SEMCOL_CODE || chIndex === COMMA_CODE) {
|
|
1372
|
+
index++;
|
|
1373
|
+
continue;
|
|
1374
|
+
}
|
|
1375
|
+
const node = gobbleExpression();
|
|
1376
|
+
if (node) {
|
|
1377
|
+
nodes.push(node);
|
|
1378
|
+
} else if (index < length) {
|
|
1379
|
+
throwError(`Unexpected "${exprI(index)}"`, index);
|
|
1380
|
+
}
|
|
1368
1381
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
nodes.push(node);
|
|
1372
|
-
} else if (index < length) {
|
|
1373
|
-
throwError(`Unexpected "${exprI(index)}"`, index);
|
|
1382
|
+
if (nodes.length === 1) {
|
|
1383
|
+
return nodes[0];
|
|
1374
1384
|
}
|
|
1385
|
+
return {
|
|
1386
|
+
__id: ExpNodeOpaqueIdentifier,
|
|
1387
|
+
type: "Compound",
|
|
1388
|
+
body: nodes,
|
|
1389
|
+
location: getLocation(0)
|
|
1390
|
+
};
|
|
1391
|
+
} catch (e) {
|
|
1392
|
+
if (strictMode || !(e instanceof Error)) {
|
|
1393
|
+
throw e;
|
|
1394
|
+
}
|
|
1395
|
+
return {
|
|
1396
|
+
__id: ExpNodeOpaqueIdentifier,
|
|
1397
|
+
type: "Compound",
|
|
1398
|
+
body: nodes,
|
|
1399
|
+
location: getLocation(0),
|
|
1400
|
+
error: e
|
|
1401
|
+
};
|
|
1375
1402
|
}
|
|
1376
|
-
if (nodes.length === 1) {
|
|
1377
|
-
return nodes[0];
|
|
1378
|
-
}
|
|
1379
|
-
return {
|
|
1380
|
-
__id: ExpNodeOpaqueIdentifier,
|
|
1381
|
-
type: "Compound",
|
|
1382
|
-
body: nodes,
|
|
1383
|
-
location: getLocation(0)
|
|
1384
|
-
};
|
|
1385
1403
|
}
|
|
1386
1404
|
|
|
1387
1405
|
const setDataVal = (_context, binding, value) => {
|
|
@@ -2263,7 +2281,13 @@ class Parser {
|
|
|
2263
2281
|
if (!localObj) {
|
|
2264
2282
|
return currentValue;
|
|
2265
2283
|
}
|
|
2266
|
-
const objEntries = Array.isArray(localObj) ? localObj.map((v, i) => [i, v]) :
|
|
2284
|
+
const objEntries = Array.isArray(localObj) ? localObj.map((v, i) => [i, v]) : [
|
|
2285
|
+
...Object.entries(localObj),
|
|
2286
|
+
...Object.getOwnPropertySymbols(localObj).map((s) => [
|
|
2287
|
+
s,
|
|
2288
|
+
localObj[s]
|
|
2289
|
+
])
|
|
2290
|
+
];
|
|
2267
2291
|
const defaultValue = {
|
|
2268
2292
|
children: [],
|
|
2269
2293
|
value: currentValue
|
|
@@ -4408,8 +4432,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
4408
4432
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
4409
4433
|
});
|
|
4410
4434
|
};
|
|
4411
|
-
const PLAYER_VERSION = "0.4.0-next.
|
|
4412
|
-
const COMMIT = "
|
|
4435
|
+
const PLAYER_VERSION = "0.4.0-next.5";
|
|
4436
|
+
const COMMIT = "a7957331b94ce0a7d50709a0d636a406b033300f";
|
|
4413
4437
|
const _Player = class {
|
|
4414
4438
|
constructor(config) {
|
|
4415
4439
|
this.logger = new TapableLogger();
|
|
@@ -4705,5 +4729,5 @@ Player.info = {
|
|
|
4705
4729
|
commit: COMMIT
|
|
4706
4730
|
};
|
|
4707
4731
|
|
|
4708
|
-
export { ApplicabilityPlugin, AssetTransformCorePlugin, BindingInstance, BindingParser, Builder, ConsoleLogger, ConstantsController, DataController, DependencyMiddleware, DependencyModel, DependencyTracker, EMPTY_NODE, ExpNodeOpaqueIdentifier, ExpressionEvaluator, FlowController, FlowExpPlugin, FlowInstance, LocalModel, LocalStateStore, NOOPDataModel, NOOP_MODEL, NOT_STARTED_STATE, NodeType, NoopLogger, Parser, PipelinedDataModel, Player, ProxyLogger, ROOT_BINDING, Resolver, SIMPLE_BINDING_REGEX, SchemaController, StringResolverPlugin, SwitchPlugin, TapableLogger, TemplatePlugin, ValidationBindingTrackerViewPlugin, ValidationController, ValidationMiddleware, ValidatorRegistry, ViewController, ViewInstance, caresAboutDataChanges, constructModelForPipeline, findClosestNodeAtPosition, findInArray, findNextExp, getBindingSegments, isBinding, isExpressionNode, maybeConvertToNum, parse, resolveDataRefs, resolveDataRefsInString, resolveExpressionsInString, severities, toModel, toNodeResolveOptions, withParser, withoutContext };
|
|
4732
|
+
export { ApplicabilityPlugin, AssetTransformCorePlugin, BindingInstance, BindingParser, Builder, ConsoleLogger, ConstantsController, DataController, DependencyMiddleware, DependencyModel, DependencyTracker, EMPTY_NODE, ExpNodeOpaqueIdentifier, ExpressionEvaluator, FlowController, FlowExpPlugin, FlowInstance, LocalModel, LocalStateStore, NOOPDataModel, NOOP_MODEL, NOT_STARTED_STATE, NodeType, NoopLogger, Parser, PipelinedDataModel, Player, ProxyLogger, ROOT_BINDING, Resolver, SIMPLE_BINDING_REGEX, SchemaController, StringResolverPlugin, SwitchPlugin, TapableLogger, TemplatePlugin, ValidationBindingTrackerViewPlugin, ValidationController, ValidationMiddleware, ValidatorRegistry, ViewController, ViewInstance, caresAboutDataChanges, constructModelForPipeline, findClosestNodeAtPosition, findInArray, findNextExp, getBindingSegments, isBinding, isExpressionNode, maybeConvertToNum, parse, parseExpression, resolveDataRefs, resolveDataRefsInString, resolveExpressionsInString, severities, toModel, toNodeResolveOptions, withParser, withoutContext };
|
|
4709
4733
|
//# sourceMappingURL=index.esm.js.map
|