@player-ui/player 0.4.0-next.5 → 0.4.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.
- package/dist/index.cjs.js +64 -18
- package/dist/index.d.ts +18 -10
- package/dist/index.esm.js +64 -18
- package/dist/player.dev.js +4112 -4066
- package/dist/player.prod.js +1 -1
- package/package.json +3 -3
- package/src/controllers/data.ts +0 -2
- package/src/player.ts +20 -21
- package/src/plugins/default-exp-plugin.ts +57 -0
- package/src/schema/schema.ts +28 -9
- package/src/string-resolver/index.ts +18 -7
- package/src/validator/validation-middleware.ts +4 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1916,6 +1916,9 @@ function parse(schema) {
|
|
|
1916
1916
|
if (type.isArray) {
|
|
1917
1917
|
nestedPath.push("[]");
|
|
1918
1918
|
}
|
|
1919
|
+
if (type.isRecord) {
|
|
1920
|
+
nestedPath.push("{}");
|
|
1921
|
+
}
|
|
1919
1922
|
if (type.type && schema[type.type]) {
|
|
1920
1923
|
parseQueue.push({
|
|
1921
1924
|
path: nestedPath,
|
|
@@ -1964,8 +1967,20 @@ class SchemaController {
|
|
|
1964
1967
|
if (cached) {
|
|
1965
1968
|
return cached;
|
|
1966
1969
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1970
|
+
let bindingArray = binding.asArray();
|
|
1971
|
+
let normalized = bindingArray.map((p) => typeof p === "number" ? "[]" : p).join(".");
|
|
1972
|
+
if (normalized) {
|
|
1973
|
+
this.bindingSchemaNormalizedCache.set(binding, normalized);
|
|
1974
|
+
bindingArray = normalized.split(".");
|
|
1975
|
+
}
|
|
1976
|
+
bindingArray.forEach((item) => {
|
|
1977
|
+
const recordBinding = bindingArray.map((p) => p === item ? "{}" : p).join(".");
|
|
1978
|
+
if (this.schema.get(recordBinding)) {
|
|
1979
|
+
this.bindingSchemaNormalizedCache.set(binding, recordBinding);
|
|
1980
|
+
bindingArray = recordBinding.split(".");
|
|
1981
|
+
normalized = recordBinding;
|
|
1982
|
+
}
|
|
1983
|
+
});
|
|
1969
1984
|
return normalized;
|
|
1970
1985
|
}
|
|
1971
1986
|
getType(binding) {
|
|
@@ -2052,6 +2067,9 @@ function findNextExp(str) {
|
|
|
2052
2067
|
};
|
|
2053
2068
|
}
|
|
2054
2069
|
function resolveExpressionsInString(val, { evaluate }) {
|
|
2070
|
+
if (!evaluate) {
|
|
2071
|
+
return val;
|
|
2072
|
+
}
|
|
2055
2073
|
const expMatch = /@\[.*?\]@/;
|
|
2056
2074
|
let newVal = val;
|
|
2057
2075
|
let match = newVal.match(expMatch);
|
|
@@ -2071,7 +2089,7 @@ function resolveExpressionsInString(val, { evaluate }) {
|
|
|
2071
2089
|
function resolveDataRefsInString(val, options) {
|
|
2072
2090
|
const { model } = options;
|
|
2073
2091
|
let workingString = resolveExpressionsInString(val, options);
|
|
2074
|
-
if (typeof workingString !== "string" || workingString.indexOf(DOUBLE_OPEN_CURLY) === -1) {
|
|
2092
|
+
if (!model || typeof workingString !== "string" || workingString.indexOf(DOUBLE_OPEN_CURLY) === -1) {
|
|
2075
2093
|
return workingString;
|
|
2076
2094
|
}
|
|
2077
2095
|
while (workingString.indexOf(DOUBLE_OPEN_CURLY) !== -1) {
|
|
@@ -2100,9 +2118,9 @@ function traverseObject(val, options) {
|
|
|
2100
2118
|
const keys = Object.keys(val);
|
|
2101
2119
|
let newVal = val;
|
|
2102
2120
|
if (keys.length > 0) {
|
|
2103
|
-
|
|
2121
|
+
keys.forEach((key) => {
|
|
2104
2122
|
newVal = timm.setIn(newVal, [key], traverseObject(val[key], options));
|
|
2105
|
-
}
|
|
2123
|
+
});
|
|
2106
2124
|
}
|
|
2107
2125
|
return newVal;
|
|
2108
2126
|
}
|
|
@@ -2154,7 +2172,7 @@ class ValidationMiddleware {
|
|
|
2154
2172
|
} else if (validations instanceof Set) {
|
|
2155
2173
|
validations.forEach((validation) => {
|
|
2156
2174
|
invalidBindings.push(validation.binding);
|
|
2157
|
-
if (!validation.isStrong) {
|
|
2175
|
+
if (!validation.isStrong && validation.binding.asString() === binding.asString()) {
|
|
2158
2176
|
nextTransaction.push([validation.binding, value]);
|
|
2159
2177
|
}
|
|
2160
2178
|
});
|
|
@@ -4242,7 +4260,6 @@ class DataController {
|
|
|
4242
4260
|
}
|
|
4243
4261
|
});
|
|
4244
4262
|
this.hooks.onSet.call(normalizedTransaction);
|
|
4245
|
-
this.hooks.onSet.call(normalizedTransaction);
|
|
4246
4263
|
if (setUpdates.length > 0) {
|
|
4247
4264
|
this.hooks.onUpdate.call(setUpdates, options);
|
|
4248
4265
|
}
|
|
@@ -4401,6 +4418,39 @@ class FlowExpPlugin {
|
|
|
4401
4418
|
}
|
|
4402
4419
|
}
|
|
4403
4420
|
|
|
4421
|
+
const createFormatFunction = (schema) => {
|
|
4422
|
+
const handler = (ctx, value, formatName) => {
|
|
4423
|
+
var _a, _b;
|
|
4424
|
+
return (_b = (_a = schema.getFormatterForType({ type: formatName })) == null ? void 0 : _a.format(value)) != null ? _b : value;
|
|
4425
|
+
};
|
|
4426
|
+
return handler;
|
|
4427
|
+
};
|
|
4428
|
+
class DefaultExpPlugin {
|
|
4429
|
+
constructor() {
|
|
4430
|
+
this.name = "flow-exp-plugin";
|
|
4431
|
+
}
|
|
4432
|
+
apply(player) {
|
|
4433
|
+
let formatFunction;
|
|
4434
|
+
player.hooks.schema.tap(this.name, (schemaController) => {
|
|
4435
|
+
formatFunction = createFormatFunction(schemaController);
|
|
4436
|
+
});
|
|
4437
|
+
player.hooks.expressionEvaluator.tap(this.name, (expEvaluator) => {
|
|
4438
|
+
if (formatFunction) {
|
|
4439
|
+
expEvaluator.addExpressionFunction("format", formatFunction);
|
|
4440
|
+
}
|
|
4441
|
+
expEvaluator.addExpressionFunction("log", (ctx, ...args) => {
|
|
4442
|
+
player.logger.info(...args);
|
|
4443
|
+
});
|
|
4444
|
+
expEvaluator.addExpressionFunction("debug", (ctx, ...args) => {
|
|
4445
|
+
player.logger.debug(...args);
|
|
4446
|
+
});
|
|
4447
|
+
expEvaluator.addExpressionFunction("eval", (ctx, ...args) => {
|
|
4448
|
+
return ctx.evaluate(...args);
|
|
4449
|
+
});
|
|
4450
|
+
});
|
|
4451
|
+
}
|
|
4452
|
+
}
|
|
4453
|
+
|
|
4404
4454
|
const NOT_STARTED_STATE = {
|
|
4405
4455
|
ref: Symbol("not-started"),
|
|
4406
4456
|
status: "not-started"
|
|
@@ -4445,8 +4495,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
4445
4495
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
4446
4496
|
});
|
|
4447
4497
|
};
|
|
4448
|
-
const PLAYER_VERSION = "0.4.0-next.
|
|
4449
|
-
const COMMIT = "
|
|
4498
|
+
const PLAYER_VERSION = "0.4.0-next.6";
|
|
4499
|
+
const COMMIT = "380eb6be2e6d61675cf721c4c3e64821099e5fbe";
|
|
4450
4500
|
const _Player = class {
|
|
4451
4501
|
constructor(config) {
|
|
4452
4502
|
this.logger = new TapableLogger();
|
|
@@ -4467,14 +4517,15 @@ const _Player = class {
|
|
|
4467
4517
|
resolveFlowContent: new tapableTs.SyncWaterfallHook()
|
|
4468
4518
|
};
|
|
4469
4519
|
var _a;
|
|
4470
|
-
const initialPlugins = [];
|
|
4471
|
-
const flowExpPlugin = new FlowExpPlugin();
|
|
4472
|
-
initialPlugins.push(flowExpPlugin);
|
|
4473
4520
|
if (config == null ? void 0 : config.logger) {
|
|
4474
4521
|
this.logger.addHandler(config.logger);
|
|
4475
4522
|
}
|
|
4476
4523
|
this.config = config || {};
|
|
4477
|
-
this.config.plugins = [
|
|
4524
|
+
this.config.plugins = [
|
|
4525
|
+
new DefaultExpPlugin(),
|
|
4526
|
+
...this.config.plugins || [],
|
|
4527
|
+
new FlowExpPlugin()
|
|
4528
|
+
];
|
|
4478
4529
|
(_a = this.config.plugins) == null ? void 0 : _a.forEach((plugin) => {
|
|
4479
4530
|
plugin.apply(this);
|
|
4480
4531
|
});
|
|
@@ -4658,11 +4709,6 @@ const _Player = class {
|
|
|
4658
4709
|
this.hooks.view.call(view);
|
|
4659
4710
|
});
|
|
4660
4711
|
this.hooks.viewController.call(viewController);
|
|
4661
|
-
const formatFunction = (ctx, value, formatName) => {
|
|
4662
|
-
var _a, _b;
|
|
4663
|
-
return (_b = (_a = schema.getFormatterForType({ type: formatName })) == null ? void 0 : _a.format(value)) != null ? _b : value;
|
|
4664
|
-
};
|
|
4665
|
-
expressionEvaluator.addExpressionFunction("format", formatFunction);
|
|
4666
4712
|
return {
|
|
4667
4713
|
start: () => {
|
|
4668
4714
|
flowController.start().then((endState) => {
|
package/dist/index.d.ts
CHANGED
|
@@ -1504,7 +1504,7 @@ declare class ValidatorRegistry {
|
|
|
1504
1504
|
}
|
|
1505
1505
|
|
|
1506
1506
|
/** Expand the authored schema into a set of paths -> DataTypes */
|
|
1507
|
-
declare function parse(schema: Schema.Schema): Map<string, Schema.
|
|
1507
|
+
declare function parse(schema: Schema.Schema): Map<string, Schema.DataTypes>;
|
|
1508
1508
|
/**
|
|
1509
1509
|
* The Schema is the central hub for all data invariants, and metaData associated with the data-model itself
|
|
1510
1510
|
* Outside of the types defined in the JSON payload, it doesn't manage or keep any state.
|
|
@@ -1513,18 +1513,18 @@ declare function parse(schema: Schema.Schema): Map<string, Schema.DataType>;
|
|
|
1513
1513
|
declare class SchemaController implements ValidationProvider {
|
|
1514
1514
|
private formatters;
|
|
1515
1515
|
private types;
|
|
1516
|
-
readonly schema: Map<string, Schema.
|
|
1516
|
+
readonly schema: Map<string, Schema.DataTypes>;
|
|
1517
1517
|
private bindingSchemaNormalizedCache;
|
|
1518
1518
|
readonly hooks: {
|
|
1519
|
-
resolveTypeForBinding: SyncWaterfallHook<[Schema.
|
|
1519
|
+
resolveTypeForBinding: SyncWaterfallHook<[Schema.DataTypes | undefined, BindingInstance], Record<string, any>>;
|
|
1520
1520
|
};
|
|
1521
1521
|
constructor(schema?: Schema.Schema);
|
|
1522
1522
|
addFormatters(fns: Array<FormatType<any, any, FormatOptions>>): void;
|
|
1523
1523
|
addDataTypes(types: Array<Schema.DataType<any>>): void;
|
|
1524
1524
|
getValidationsForBinding(binding: BindingInstance): Array<ValidationObject> | undefined;
|
|
1525
1525
|
private normalizeBinding;
|
|
1526
|
-
getType(binding: BindingInstance): Schema.
|
|
1527
|
-
getApparentType(binding: BindingInstance): Schema.
|
|
1526
|
+
getType(binding: BindingInstance): Schema.DataTypes | undefined;
|
|
1527
|
+
getApparentType(binding: BindingInstance): Schema.DataTypes | undefined;
|
|
1528
1528
|
getTypeDefinition(dataType: string): Schema.DataType<any> | undefined;
|
|
1529
1529
|
getFormatterForType(formatReference: Formatting.Reference): FormatDefinition<unknown, unknown> | undefined;
|
|
1530
1530
|
/**
|
|
@@ -1535,10 +1535,16 @@ declare class SchemaController implements ValidationProvider {
|
|
|
1535
1535
|
}
|
|
1536
1536
|
|
|
1537
1537
|
interface Options {
|
|
1538
|
-
/**
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1538
|
+
/**
|
|
1539
|
+
* The model to use when resolving refs
|
|
1540
|
+
* Passing `false` will skip trying to resolve any direct model refs ({{foo}})
|
|
1541
|
+
*/
|
|
1542
|
+
model: false | DataModelWithParser;
|
|
1543
|
+
/**
|
|
1544
|
+
* A function to evaluate an expression
|
|
1545
|
+
* Passing `false` will skip trying to evaluate any expressions (@[ foo() ]@)
|
|
1546
|
+
*/
|
|
1547
|
+
evaluate: false | ((exp: Expression) => any);
|
|
1542
1548
|
}
|
|
1543
1549
|
/** Search the given string for the coordinates of the next expression to resolve */
|
|
1544
1550
|
declare function findNextExp(str: string): {
|
|
@@ -1565,6 +1571,8 @@ interface PlayerPlugin {
|
|
|
1565
1571
|
*/
|
|
1566
1572
|
apply: (player: Player) => void;
|
|
1567
1573
|
}
|
|
1574
|
+
interface ExtendedPlayerPlugin<Assets = void, Views = void, Expressions = void, DataTypes = void> {
|
|
1575
|
+
}
|
|
1568
1576
|
interface PlayerConfigOptions {
|
|
1569
1577
|
/** A set of plugins to load */
|
|
1570
1578
|
plugins?: PlayerPlugin[];
|
|
@@ -1651,4 +1659,4 @@ declare class FlowExpPlugin implements PlayerPlugin {
|
|
|
1651
1659
|
apply(player: Player): void;
|
|
1652
1660
|
}
|
|
1653
1661
|
|
|
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 };
|
|
1662
|
+
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, ExtendedPlayerPlugin, 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
|
@@ -1903,6 +1903,9 @@ function parse(schema) {
|
|
|
1903
1903
|
if (type.isArray) {
|
|
1904
1904
|
nestedPath.push("[]");
|
|
1905
1905
|
}
|
|
1906
|
+
if (type.isRecord) {
|
|
1907
|
+
nestedPath.push("{}");
|
|
1908
|
+
}
|
|
1906
1909
|
if (type.type && schema[type.type]) {
|
|
1907
1910
|
parseQueue.push({
|
|
1908
1911
|
path: nestedPath,
|
|
@@ -1951,8 +1954,20 @@ class SchemaController {
|
|
|
1951
1954
|
if (cached) {
|
|
1952
1955
|
return cached;
|
|
1953
1956
|
}
|
|
1954
|
-
|
|
1955
|
-
|
|
1957
|
+
let bindingArray = binding.asArray();
|
|
1958
|
+
let normalized = bindingArray.map((p) => typeof p === "number" ? "[]" : p).join(".");
|
|
1959
|
+
if (normalized) {
|
|
1960
|
+
this.bindingSchemaNormalizedCache.set(binding, normalized);
|
|
1961
|
+
bindingArray = normalized.split(".");
|
|
1962
|
+
}
|
|
1963
|
+
bindingArray.forEach((item) => {
|
|
1964
|
+
const recordBinding = bindingArray.map((p) => p === item ? "{}" : p).join(".");
|
|
1965
|
+
if (this.schema.get(recordBinding)) {
|
|
1966
|
+
this.bindingSchemaNormalizedCache.set(binding, recordBinding);
|
|
1967
|
+
bindingArray = recordBinding.split(".");
|
|
1968
|
+
normalized = recordBinding;
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1956
1971
|
return normalized;
|
|
1957
1972
|
}
|
|
1958
1973
|
getType(binding) {
|
|
@@ -2039,6 +2054,9 @@ function findNextExp(str) {
|
|
|
2039
2054
|
};
|
|
2040
2055
|
}
|
|
2041
2056
|
function resolveExpressionsInString(val, { evaluate }) {
|
|
2057
|
+
if (!evaluate) {
|
|
2058
|
+
return val;
|
|
2059
|
+
}
|
|
2042
2060
|
const expMatch = /@\[.*?\]@/;
|
|
2043
2061
|
let newVal = val;
|
|
2044
2062
|
let match = newVal.match(expMatch);
|
|
@@ -2058,7 +2076,7 @@ function resolveExpressionsInString(val, { evaluate }) {
|
|
|
2058
2076
|
function resolveDataRefsInString(val, options) {
|
|
2059
2077
|
const { model } = options;
|
|
2060
2078
|
let workingString = resolveExpressionsInString(val, options);
|
|
2061
|
-
if (typeof workingString !== "string" || workingString.indexOf(DOUBLE_OPEN_CURLY) === -1) {
|
|
2079
|
+
if (!model || typeof workingString !== "string" || workingString.indexOf(DOUBLE_OPEN_CURLY) === -1) {
|
|
2062
2080
|
return workingString;
|
|
2063
2081
|
}
|
|
2064
2082
|
while (workingString.indexOf(DOUBLE_OPEN_CURLY) !== -1) {
|
|
@@ -2087,9 +2105,9 @@ function traverseObject(val, options) {
|
|
|
2087
2105
|
const keys = Object.keys(val);
|
|
2088
2106
|
let newVal = val;
|
|
2089
2107
|
if (keys.length > 0) {
|
|
2090
|
-
|
|
2108
|
+
keys.forEach((key) => {
|
|
2091
2109
|
newVal = setIn(newVal, [key], traverseObject(val[key], options));
|
|
2092
|
-
}
|
|
2110
|
+
});
|
|
2093
2111
|
}
|
|
2094
2112
|
return newVal;
|
|
2095
2113
|
}
|
|
@@ -2141,7 +2159,7 @@ class ValidationMiddleware {
|
|
|
2141
2159
|
} else if (validations instanceof Set) {
|
|
2142
2160
|
validations.forEach((validation) => {
|
|
2143
2161
|
invalidBindings.push(validation.binding);
|
|
2144
|
-
if (!validation.isStrong) {
|
|
2162
|
+
if (!validation.isStrong && validation.binding.asString() === binding.asString()) {
|
|
2145
2163
|
nextTransaction.push([validation.binding, value]);
|
|
2146
2164
|
}
|
|
2147
2165
|
});
|
|
@@ -4229,7 +4247,6 @@ class DataController {
|
|
|
4229
4247
|
}
|
|
4230
4248
|
});
|
|
4231
4249
|
this.hooks.onSet.call(normalizedTransaction);
|
|
4232
|
-
this.hooks.onSet.call(normalizedTransaction);
|
|
4233
4250
|
if (setUpdates.length > 0) {
|
|
4234
4251
|
this.hooks.onUpdate.call(setUpdates, options);
|
|
4235
4252
|
}
|
|
@@ -4388,6 +4405,39 @@ class FlowExpPlugin {
|
|
|
4388
4405
|
}
|
|
4389
4406
|
}
|
|
4390
4407
|
|
|
4408
|
+
const createFormatFunction = (schema) => {
|
|
4409
|
+
const handler = (ctx, value, formatName) => {
|
|
4410
|
+
var _a, _b;
|
|
4411
|
+
return (_b = (_a = schema.getFormatterForType({ type: formatName })) == null ? void 0 : _a.format(value)) != null ? _b : value;
|
|
4412
|
+
};
|
|
4413
|
+
return handler;
|
|
4414
|
+
};
|
|
4415
|
+
class DefaultExpPlugin {
|
|
4416
|
+
constructor() {
|
|
4417
|
+
this.name = "flow-exp-plugin";
|
|
4418
|
+
}
|
|
4419
|
+
apply(player) {
|
|
4420
|
+
let formatFunction;
|
|
4421
|
+
player.hooks.schema.tap(this.name, (schemaController) => {
|
|
4422
|
+
formatFunction = createFormatFunction(schemaController);
|
|
4423
|
+
});
|
|
4424
|
+
player.hooks.expressionEvaluator.tap(this.name, (expEvaluator) => {
|
|
4425
|
+
if (formatFunction) {
|
|
4426
|
+
expEvaluator.addExpressionFunction("format", formatFunction);
|
|
4427
|
+
}
|
|
4428
|
+
expEvaluator.addExpressionFunction("log", (ctx, ...args) => {
|
|
4429
|
+
player.logger.info(...args);
|
|
4430
|
+
});
|
|
4431
|
+
expEvaluator.addExpressionFunction("debug", (ctx, ...args) => {
|
|
4432
|
+
player.logger.debug(...args);
|
|
4433
|
+
});
|
|
4434
|
+
expEvaluator.addExpressionFunction("eval", (ctx, ...args) => {
|
|
4435
|
+
return ctx.evaluate(...args);
|
|
4436
|
+
});
|
|
4437
|
+
});
|
|
4438
|
+
}
|
|
4439
|
+
}
|
|
4440
|
+
|
|
4391
4441
|
const NOT_STARTED_STATE = {
|
|
4392
4442
|
ref: Symbol("not-started"),
|
|
4393
4443
|
status: "not-started"
|
|
@@ -4432,8 +4482,8 @@ var __async = (__this, __arguments, generator) => {
|
|
|
4432
4482
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
4433
4483
|
});
|
|
4434
4484
|
};
|
|
4435
|
-
const PLAYER_VERSION = "0.4.0-next.
|
|
4436
|
-
const COMMIT = "
|
|
4485
|
+
const PLAYER_VERSION = "0.4.0-next.6";
|
|
4486
|
+
const COMMIT = "380eb6be2e6d61675cf721c4c3e64821099e5fbe";
|
|
4437
4487
|
const _Player = class {
|
|
4438
4488
|
constructor(config) {
|
|
4439
4489
|
this.logger = new TapableLogger();
|
|
@@ -4454,14 +4504,15 @@ const _Player = class {
|
|
|
4454
4504
|
resolveFlowContent: new SyncWaterfallHook()
|
|
4455
4505
|
};
|
|
4456
4506
|
var _a;
|
|
4457
|
-
const initialPlugins = [];
|
|
4458
|
-
const flowExpPlugin = new FlowExpPlugin();
|
|
4459
|
-
initialPlugins.push(flowExpPlugin);
|
|
4460
4507
|
if (config == null ? void 0 : config.logger) {
|
|
4461
4508
|
this.logger.addHandler(config.logger);
|
|
4462
4509
|
}
|
|
4463
4510
|
this.config = config || {};
|
|
4464
|
-
this.config.plugins = [
|
|
4511
|
+
this.config.plugins = [
|
|
4512
|
+
new DefaultExpPlugin(),
|
|
4513
|
+
...this.config.plugins || [],
|
|
4514
|
+
new FlowExpPlugin()
|
|
4515
|
+
];
|
|
4465
4516
|
(_a = this.config.plugins) == null ? void 0 : _a.forEach((plugin) => {
|
|
4466
4517
|
plugin.apply(this);
|
|
4467
4518
|
});
|
|
@@ -4645,11 +4696,6 @@ const _Player = class {
|
|
|
4645
4696
|
this.hooks.view.call(view);
|
|
4646
4697
|
});
|
|
4647
4698
|
this.hooks.viewController.call(viewController);
|
|
4648
|
-
const formatFunction = (ctx, value, formatName) => {
|
|
4649
|
-
var _a, _b;
|
|
4650
|
-
return (_b = (_a = schema.getFormatterForType({ type: formatName })) == null ? void 0 : _a.format(value)) != null ? _b : value;
|
|
4651
|
-
};
|
|
4652
|
-
expressionEvaluator.addExpressionFunction("format", formatFunction);
|
|
4653
4699
|
return {
|
|
4654
4700
|
start: () => {
|
|
4655
4701
|
flowController.start().then((endState) => {
|