Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@player-ui/player

Package Overview
Dependencies
Maintainers
0
Versions
294
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@player-ui/player - npm Package Compare versions

Comparing version 0.7.4-next.4 to 0.7.5--canary.432.14776

dist/cjs/index.cjs

88

package.json
{
"name": "@player-ui/player",
"version": "0.7.4-next.4",
"private": false,
"publishConfig": {
"registry": "https://registry.npmjs.org"
},
"peerDependencies": {},
"version": "0.7.5--canary.432.14776",
"main": "dist/cjs/index.cjs",
"dependencies": {
"@player-ui/partial-match-registry": "0.7.4-next.4",
"@player-ui/types": "0.7.4-next.4",
"@player-ui/partial-match-registry": "0.7.5--canary.432.14776",
"@player-ui/make-flow": "0.7.5--canary.432.14776",
"@player-ui/types": "0.7.5--canary.432.14776",
"@types/dlv": "^1.1.4",
"dequal": "^2.0.2",
"dlv": "^1.1.3",
"error-polyfill": "^0.1.3",
"p-defer": "^3.0.0",
"queue-microtask": "^1.2.3",
"tapable-ts": "^0.2.3",
"parsimmon": "^1.12.0",
"@types/parsimmon": "^1.10.0",
"arr-flatten": "^1.1.0",
"ebnf": "^1.9.0",
"timm": "^1.6.2",
"error-polyfill": "^0.1.3",
"ts-nested-error": "^1.2.1",
"@babel/runtime": "7.15.4"
"tslib": "^2.6.2"
},
"main": "dist/index.cjs.js",
"module": "dist/index.esm.js",
"typings": "dist/index.d.ts",
"module": "dist/index.legacy-esm.js",
"types": "types/index.d.ts",
"bundle": "dist/Player.native.js",
"sideEffects": false,
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/player-ui/player-ui"
"exports": {
"./package.json": "./package.json",
"./dist/index.css": "./dist/index.css",
".": {
"types": "./types/index.d.ts",
"import": "./dist/index.mjs",
"default": "./dist/cjs/index.cjs"
}
},
"bugs": {
"url": "https://github.com/player-ui/player-ui/issues"
},
"homepage": "https://player-ui.github.io",
"contributors": [
{
"name": "Adam Dierkens",
"url": "https://github.com/adierkens"
},
{
"name": "Spencer Hamm",
"url": "https://github.com/spentacular"
},
{
"name": "Harris Borawski",
"url": "https://github.com/hborawski"
},
{
"name": "Jeremiah Zucker",
"url": "https://github.com/sugarmanz"
},
{
"name": "Ketan Reddy",
"url": "https://github.com/KetanReddy"
},
{
"name": "Brocollie08",
"url": "https://github.com/brocollie08"
},
{
"name": "Kelly Harrop",
"url": "https://github.com/kharrop"
},
{
"name": "Alejandro Fimbres",
"url": "https://github.com/lexfm"
},
{
"name": "Rafael Campos",
"url": "https://github.com/rafbcampos"
}
"files": [
"dist",
"src",
"types"
],
"bundle": "./dist/player.prod.js"
"peerDependencies": {}
}

@@ -10,3 +10,3 @@ export interface Node<T extends string> {

*/
export interface PathNode extends Node<'PathNode'> {
export interface PathNode extends Node<"PathNode"> {
/** The path in the model that this node represents */

@@ -20,3 +20,3 @@ path: Array<AnyNode>;

*/
export interface QueryNode extends Node<'Query'> {
export interface QueryNode extends Node<"Query"> {
/** The key to query */

@@ -30,3 +30,3 @@ key: AnyNode;

/** A simple segment */
export interface ValueNode extends Node<'Value'> {
export interface ValueNode extends Node<"Value"> {
/** The segment value */

@@ -37,3 +37,3 @@ value: string | number;

/** A nested expression */
export interface ExpressionNode extends Node<'Expression'> {
export interface ExpressionNode extends Node<"Expression"> {
/** The expression */

@@ -45,3 +45,3 @@ value: string;

export const toValue = (value: string | number): ValueNode => ({
name: 'Value',
name: "Value",
value,

@@ -52,3 +52,3 @@ });

export const toExpression = (value: string): ExpressionNode => ({
name: 'Expression',
name: "Expression",
value,

@@ -59,3 +59,3 @@ });

export const toPath = (path: Array<AnyNode>): PathNode => ({
name: 'PathNode',
name: "PathNode",
path,

@@ -66,3 +66,3 @@ });

export const toQuery = (key: AnyNode, value?: AnyNode): QueryNode => ({
name: 'Query',
name: "Query",
key,

@@ -74,3 +74,3 @@ value,

export const toConcatenatedNode = (
values: Array<PathNode | ValueNode | ExpressionNode>
values: Array<PathNode | ValueNode | ExpressionNode>,
): PathNode | ValueNode | ConcatenatedNode | ExpressionNode => {

@@ -82,3 +82,3 @@ if (values.length === 1) {

return {
name: 'Concatenated',
name: "Concatenated",
value: values,

@@ -92,3 +92,3 @@ };

*/
export interface ConcatenatedNode extends Node<'Concatenated'> {
export interface ConcatenatedNode extends Node<"Concatenated"> {
/** A list of nested paths, or value nodes to concat together to form a segment */

@@ -95,0 +95,0 @@ value: Array<PathNode | ValueNode | ExpressionNode>;

@@ -9,3 +9,3 @@ import type {

ExpressionNode,
} from '../ast';
} from "../ast";
import {

@@ -17,13 +17,13 @@ toValue,

toExpression,
} from '../ast';
} from "../ast";
const SEGMENT_SEPARATOR = '.';
const OPEN_CURL = '{';
const CLOSE_CURL = '}';
const OPEN_BRACKET = '[';
const CLOSE_BRACKET = ']';
const EQUALS = '=';
const SEGMENT_SEPARATOR = ".";
const OPEN_CURL = "{";
const CLOSE_CURL = "}";
const OPEN_BRACKET = "[";
const CLOSE_BRACKET = "]";
const EQUALS = "=";
const SINGLE_QUOTE = "'";
const DOUBLE_QUOTE = '"';
const BACK_TICK = '`';
const BACK_TICK = "`";
// const IDENTIFIER_REGEX = /[\w\-@]+/;

@@ -70,3 +70,2 @@

index += 1;
// console.log(`Index: ${index} Char: ${ch}`);
return ch;

@@ -78,3 +77,3 @@ };

/* eslint-disable no-unmodified-loop-condition */
while (ch === ' ') {
while (ch === " ") {
next();

@@ -259,3 +258,3 @@ }

const parsed = [];
const parsed: Array<AnyNode> = [];

@@ -262,0 +261,0 @@ const firstSegment = segment();

@@ -1,4 +0,2 @@

export * from './ast';
export { parse as parseParsimmon } from './parsimmon';
export { parse as parseEBNF } from './ebnf';
export { parse as parseCustom } from './custom';
export * from "./ast";
export { parse as parseCustom } from "./custom";

@@ -1,2 +0,2 @@

import { getBindingSegments } from './utils';
import { getBindingSegments } from "./utils";

@@ -34,3 +34,3 @@ export interface BindingParserOptions {

raw: RawBinding,
options?: Partial<BindingParserOptions>
options?: Partial<BindingParserOptions>,
) => BindingInstance;

@@ -48,7 +48,7 @@

raw: RawBinding,
factory = (rawBinding: RawBinding) => new BindingInstance(rawBinding)
factory = (rawBinding: RawBinding) => new BindingInstance(rawBinding),
) {
const split = Array.isArray(raw) ? raw : raw.split('.');
const split = Array.isArray(raw) ? raw : raw.split(".");
this.split = split.map((segment) => {
if (typeof segment === 'number') {
if (typeof segment === "number") {
return segment;

@@ -61,3 +61,3 @@ }

Object.freeze(this.split);
this.joined = this.split.join('.');
this.joined = this.split.join(".");
this.factory = factory;

@@ -64,0 +64,0 @@ }

@@ -1,16 +0,16 @@

import { SyncBailHook, SyncWaterfallHook } from 'tapable-ts';
import { NestedError } from 'ts-nested-error';
import type { ParserResult, AnyNode } from '../binding-grammar';
import { SyncBailHook, SyncWaterfallHook } from "tapable-ts";
import { NestedError } from "ts-nested-error";
import type { ParserResult, AnyNode } from "../binding-grammar/index";
import {
// We can swap this with whichever parser we want to use
parseCustom as parseBinding,
} from '../binding-grammar';
import type { BindingParserOptions, BindingLike } from './binding';
import { BindingInstance } from './binding';
import { isBinding } from './utils';
import type { NormalizedResult, ResolveBindingASTOptions } from './resolver';
import { resolveBindingAST } from './resolver';
} from "../binding-grammar";
import type { BindingParserOptions, BindingLike } from "./binding";
import { BindingInstance } from "./binding";
import { isBinding } from "./utils";
import type { NormalizedResult, ResolveBindingASTOptions } from "./resolver";
import { resolveBindingAST } from "./resolver";
export * from './utils';
export * from './binding';
export * from "./utils";
export * from "./binding";

@@ -23,9 +23,9 @@ export const SIMPLE_BINDING_REGEX = /^[\w\-@]+(\.[\w\-@]+)*$/;

get: () => {
throw new Error('Not Implemented');
throw new Error("Not Implemented");
},
set: () => {
throw new Error('Not Implemented');
throw new Error("Not Implemented");
},
evaluate: () => {
throw new Error('Not Implemented');
throw new Error("Not Implemented");
},

@@ -63,3 +63,3 @@ };

path: string,
resolveOptions: ResolveBindingASTOptions
resolveOptions: ResolveBindingASTOptions,
) {

@@ -75,3 +75,3 @@ /**

) {
return { path: path.split('.'), updates: undefined } as NormalizedResult;
return { path: path.split("."), updates: undefined } as NormalizedResult;
}

@@ -82,5 +82,5 @@

if (typeof ast !== 'object' || !ast?.status) {
if (typeof ast !== "object" || !ast?.status) {
throw new TypeError(
`Cannot normalize path "${path}": ${ast?.error ?? 'Unknown Error.'}`
`Cannot normalize path "${path}": ${ast?.error ?? "Unknown Error."}`,
);

@@ -97,5 +97,5 @@ }

private getBindingForNormalizedResult(
normalized: NormalizedResult
normalized: NormalizedResult,
): BindingInstance {
const normalizedStr = normalized.path.join('.');
const normalizedStr = normalized.path.join(".");

@@ -107,4 +107,4 @@ if (this.cache[normalizedStr]) {

const created = new BindingInstance(
normalizedStr === '' ? [] : normalized.path,
this.parse
normalizedStr === "" ? [] : normalized.path,
this.parse,
);

@@ -118,3 +118,3 @@ this.cache[normalizedStr] = created;

rawBinding: BindingLike,
overrides: Partial<BindingParserOptions> = {}
overrides: Partial<BindingParserOptions> = {},
): BindingInstance {

@@ -133,3 +133,3 @@ if (isBinding(rawBinding)) {

const joined = Array.isArray(rawBinding)
? rawBinding.join('.')
? rawBinding.join(".")
: String(rawBinding);

@@ -139,3 +139,3 @@

getValue: (path: Array<string | number>) => {
const normalized = this.normalizePath(path.join('.'), normalizeConfig);
const normalized = this.normalizePath(path.join("."), normalizeConfig);

@@ -150,3 +150,3 @@ return options.get(this.getBindingForNormalizedResult(normalized));

throw new Error(
'Attempted to convert undefined value to binding path'
"Attempted to convert undefined value to binding path",
);

@@ -156,8 +156,8 @@ }

if (
typeof path !== 'string' &&
typeof path !== 'number' &&
typeof path !== 'boolean'
typeof path !== "string" &&
typeof path !== "number" &&
typeof path !== "boolean"
) {
throw new Error(
`Attempting to convert ${typeof path} to a binding path.`
`Attempting to convert ${typeof path} to a binding path.`,
);

@@ -175,6 +175,6 @@ }

const joinedNormalizedPath = normalized.path.join('.');
const joinedNormalizedPath = normalized.path.join(".");
if (joinedNormalizedPath === '') {
throw new Error('Nested path resolved to an empty path');
if (joinedNormalizedPath === "") {
throw new Error("Nested path resolved to an empty path");
}

@@ -202,3 +202,3 @@

updates[updatedBinding],
]
],
);

@@ -205,0 +205,0 @@

@@ -1,5 +0,5 @@

import { NestedError } from 'ts-nested-error';
import type { SyncWaterfallHook } from 'tapable-ts';
import type { PathNode, AnyNode } from '../binding-grammar';
import { findInArray, maybeConvertToNum } from './utils';
import { NestedError } from "ts-nested-error";
import type { SyncWaterfallHook } from "tapable-ts";
import type { PathNode, AnyNode } from "../binding-grammar";
import { findInArray, maybeConvertToNum } from "./utils";

@@ -36,3 +36,3 @@ export interface NormalizedResult {

options: ResolveBindingASTOptions,
hooks?: ResolveBindingASTHooks
hooks?: ResolveBindingASTHooks,
): NormalizedResult {

@@ -49,7 +49,7 @@ const context: Required<NormalizedResult> = {

function getValueForNode(node: AnyNode): any {
if (node.name === 'Value') {
if (node.name === "Value") {
return node.value;
}
if (node.name === 'PathNode') {
if (node.name === "PathNode") {
const nestedResolvedValue = resolveBindingAST(node, options);

@@ -66,3 +66,3 @@

return options.convertToPath(
options.getValue(nestedResolvedValue.path)
options.getValue(nestedResolvedValue.path),
);

@@ -72,3 +72,3 @@ } catch (e: any) {

`Unable to resolve path segment: ${nestedResolvedValue.path}`,
e
e,
);

@@ -78,3 +78,3 @@ }

if (node.name === 'Expression') {
if (node.name === "Expression") {
try {

@@ -94,4 +94,4 @@ const actualValue = options.evaluate(node.value);

function appendPathSegments(segment: string | number) {
if (typeof segment === 'string' && segment.indexOf('.') > -1) {
segment.split('.').forEach((i) => {
if (typeof segment === "string" && segment.indexOf(".") > -1) {
segment.split(".").forEach((i) => {
context.path.push(maybeConvertToNum(i));

@@ -110,12 +110,12 @@ });

switch (resolvedNode.name) {
case 'Expression':
case 'PathNode':
case "Expression":
case "PathNode":
appendPathSegments(getValueForNode(resolvedNode));
break;
case 'Value':
case "Value":
appendPathSegments(resolvedNode.value);
break;
case 'Query': {
case "Query": {
// Look for an object at the path with the given key/val criteria

@@ -134,3 +134,3 @@ const objToQuery: Record<string, any>[] =

context.updates[
[...context.path, objToQuery.length, resolvedKey].join('.')
[...context.path, objToQuery.length, resolvedKey].join(".")
] = resolvedValue;

@@ -145,4 +145,4 @@ context.path.push(objToQuery.length);

case 'Concatenated':
context.path.push(resolvedNode.value.map(getValueForNode).join(''));
case "Concatenated":
context.path.push(resolvedNode.value.map(getValueForNode).join(""));
break;

@@ -149,0 +149,0 @@

@@ -1,6 +0,6 @@

import type { BindingLike, BindingInstance } from './binding';
import type { BindingLike, BindingInstance } from "./binding";
/** Check if the parameter representing a binding is already of the Binding class */
export function isBinding(binding: BindingLike): binding is BindingInstance {
return !(typeof binding === 'string' || Array.isArray(binding));
return !(typeof binding === "string" || Array.isArray(binding));
}

@@ -23,3 +23,3 @@

export function getBindingSegments(
binding: BindingLike
binding: BindingLike,
): Array<string | number> {

@@ -30,4 +30,4 @@ if (Array.isArray(binding)) {

if (typeof binding === 'string') {
return binding.split('.');
if (typeof binding === "string") {
return binding.split(".");
}

@@ -42,6 +42,6 @@

key: string | number,
value: T
value: T,
): number | undefined {
return array.findIndex((obj) => {
if (obj && typeof obj === 'object') {
if (obj && typeof obj === "object") {
// Intentional double-equals because we want '4' to be coerced to 4

@@ -48,0 +48,0 @@ // eslint-disable-next-line eqeqeq

@@ -1,4 +0,4 @@

import { LocalModel } from '../../data';
import { BindingInstance } from '../../binding';
import { objectToBatchSet } from './utils';
import { LocalModel } from "../../data";
import { BindingInstance } from "../../binding";
import { objectToBatchSet } from "./utils";

@@ -5,0 +5,0 @@ export interface ConstantsProvider {

@@ -1,5 +0,5 @@

import { BindingInstance } from '../../binding';
import { BindingInstance } from "../../binding";
/** Recursively flattens a nested object to be an object of depth 1 with keys being the full path in the orginal object */
export function flatten(obj: any, roots: [string][] = [], sep = '.'): any {
export function flatten(obj: any, roots: [string][] = [], sep = "."): any {
return (

@@ -16,3 +16,3 @@ Object

...memo,
...(Object.prototype.toString.call(obj[prop]) === '[object Object]'
...(Object.prototype.toString.call(obj[prop]) === "[object Object]"
? // keep working if value is an object

@@ -23,3 +23,3 @@ flatten(obj[prop], roots.concat([prop]))

}),
{}
{},
)

@@ -26,0 +26,0 @@ );

@@ -1,6 +0,6 @@

import { SyncHook, SyncWaterfallHook, SyncBailHook } from 'tapable-ts';
import { dequal } from 'dequal';
import type { Logger } from '../../logger';
import type { BindingParser, BindingLike } from '../../binding';
import { BindingInstance } from '../../binding';
import { SyncHook, SyncWaterfallHook, SyncBailHook } from "tapable-ts";
import { dequal } from "dequal";
import type { Logger } from "../../logger";
import type { BindingParser, BindingLike } from "../../binding";
import { BindingInstance } from "../../binding";
import type {

@@ -13,6 +13,6 @@ BatchSetTransaction,

DataModelMiddleware,
} from '../../data';
import { PipelinedDataModel, LocalModel } from '../../data';
import type { RawSetTransaction } from '../../types';
import { ReadOnlyDataController } from './utils';
} from "../../data";
import { PipelinedDataModel, LocalModel } from "../../data";
import type { RawSetTransaction } from "../../types";
import { ReadOnlyDataController } from "./utils";

@@ -60,3 +60,3 @@ /** The orchestrator for player data */

logger?: Logger;
}
},
) {

@@ -85,3 +85,3 @@ this.logger = options.logger;

value: any,
deformat: boolean
deformat: boolean,
) {

@@ -97,3 +97,3 @@ if (deformat) {

transaction: RawSetTransaction,
options?: DataModelOptions
options?: DataModelOptions,
): Updates {

@@ -121,3 +121,3 @@ let normalizedTransaction: BatchSetTransaction = [];

];
}
},
) as BatchSetTransaction;

@@ -139,3 +139,3 @@ }

this.logger?.debug(
`Skipping update for path: ${binding.asString()}. Value was unchanged: ${oldVal}`
`Skipping update for path: ${binding.asString()}. Value was unchanged: ${oldVal}`,
);

@@ -146,3 +146,3 @@ } else {

this.logger?.debug(
`Setting path: ${binding.asString()} from: ${oldVal} to: ${newVal}`
`Setting path: ${binding.asString()} from: ${oldVal} to: ${newVal}`,
);

@@ -153,3 +153,3 @@ }

},
[]
[],
);

@@ -170,3 +170,3 @@

tr.oldValue
} to: ${tr.newValue}`
} to: ${tr.newValue}`,
);

@@ -187,3 +187,3 @@ setUpdates.push(tr);

private resolve(binding: BindingLike, readOnly: boolean): BindingInstance {
return Array.isArray(binding) || typeof binding === 'string'
return Array.isArray(binding) || typeof binding === "string"
? this.pathResolver.parse(binding, { readOnly })

@@ -221,7 +221,7 @@ : binding;

if (
typeof binding !== 'string' &&
typeof binding !== "string" &&
!Array.isArray(binding) &&
!(binding instanceof BindingInstance)
) {
throw new Error('Invalid arguments: delete expects a data path (string)');
throw new Error("Invalid arguments: delete expects a data path (string)");
}

@@ -239,3 +239,3 @@

const existedBeforeDelete =
typeof parentValue === 'object' &&
typeof parentValue === "object" &&
parentValue !== null &&

@@ -254,3 +254,3 @@ Object.prototype.hasOwnProperty.call(parentValue, property);

public serialize(): object {
return this.hooks.serialize.call(this.get(''));
return this.hooks.serialize.call(this.get(""));
}

@@ -257,0 +257,0 @@

@@ -1,1 +0,1 @@

export * from './controller';
export * from "./controller";
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { DataController } from '.';
import type { Logger } from '../../logger';
import type { BindingLike } from '../../binding';
import type { DataController } from ".";
import type { Logger } from "../../logger";
import type { BindingLike } from "../../binding";
import type {

@@ -9,3 +9,3 @@ DataModelWithParser,

Updates,
} from '../../data';
} from "../../data";

@@ -30,6 +30,6 @@ /** Wrapper for the Data Controller Class that prevents writes */

transaction: [BindingLike, any][],
options?: DataModelOptions | undefined
options?: DataModelOptions | undefined,
): Updates {
this.logger?.error(
'Error: Tried to set in a read only instance of the DataController'
"Error: Tried to set in a read only instance of the DataController",
);

@@ -41,5 +41,5 @@ return [];

this.logger?.error(
'Error: Tried to delete in a read only instance of the DataController'
"Error: Tried to delete in a read only instance of the DataController",
);
}
}

@@ -1,6 +0,6 @@

import { SyncHook } from 'tapable-ts';
import type { Navigation, NavigationFlowEndState } from '@player-ui/types';
import type { Logger } from '../../logger';
import type { NamedState, TransitionOptions } from './flow';
import { FlowInstance } from './flow';
import { SyncHook } from "tapable-ts";
import type { Navigation, NavigationFlowEndState } from "@player-ui/types";
import type { Logger } from "../../logger";
import type { TransitionOptions } from "./flow";
import { FlowInstance } from "./flow";

@@ -23,3 +23,3 @@ /** A manager for the navigation section of a Content blob */

logger?: Logger;
}
},
) {

@@ -39,3 +39,3 @@ this.navigation = navigation;

if (this.current === undefined) {
throw new Error('Not currently in a flow. Cannot transition.');
throw new Error("Not currently in a flow. Cannot transition.");
}

@@ -59,5 +59,5 @@

if (startFlow === null || typeof startFlow !== 'object') {
if (startFlow === null || typeof startFlow !== "object") {
return Promise.reject(
new Error(`Flow: ${startState} needs to be an object`)
new Error(`Flow: ${startState} needs to be an object`),
);

@@ -71,4 +71,4 @@ }

flow.hooks.afterTransition.tap('flow-controller', (flowInstance) => {
if (flowInstance.currentState?.value.state_type === 'FLOW') {
flow.hooks.afterTransition.tap("flow-controller", (flowInstance) => {
if (flowInstance.currentState?.value.state_type === "FLOW") {
const subflowId = flowInstance.currentState?.value.ref;

@@ -78,3 +78,3 @@ this.log?.debug(`Loading subflow ${subflowId}`);

this.log?.debug(
`Subflow ended. Using outcome: ${subFlowEndState.outcome}`
`Subflow ended. Using outcome: ${subFlowEndState.outcome}`,
);

@@ -99,3 +99,3 @@ flowInstance.transition(subFlowEndState?.outcome);

if (!this.navigation.BEGIN) {
return Promise.reject(new Error('Must supply a BEGIN state'));
return Promise.reject(new Error("Must supply a BEGIN state"));
}

@@ -102,0 +102,0 @@

@@ -1,4 +0,4 @@

import { SyncBailHook, SyncHook, SyncWaterfallHook } from 'tapable-ts';
import type { DeferredPromise } from 'p-defer';
import defer from 'p-defer';
import { SyncBailHook, SyncHook, SyncWaterfallHook } from "tapable-ts";
import type { DeferredPromise } from "p-defer";
import defer from "p-defer";
import type {

@@ -8,4 +8,4 @@ NavigationFlow,

NavigationFlowEndState,
} from '@player-ui/types';
import type { Logger } from '../../logger';
} from "@player-ui/types";
import type { Logger } from "../../logger";

@@ -26,3 +26,3 @@ export interface NamedState {

name: string,
options?: TransitionOptions
options?: TransitionOptions,
) => void;

@@ -75,3 +75,3 @@

logger?: Logger;
}
},
) {

@@ -84,10 +84,10 @@ this.id = id;

this.hooks.transition.tap(
'startPromise',
"startPromise",
async (_oldState, nextState: NamedState) => {
const newState = nextState.value;
if (this.flowPromise && newState.state_type === 'END') {
if (this.flowPromise && newState.state_type === "END") {
this.flowPromise.resolve(newState);
}
}
},
);

@@ -99,3 +99,3 @@ }

if (this.flowPromise) {
this.log?.warn('Already called start for flow');
this.log?.warn("Already called start for flow");

@@ -126,9 +126,9 @@ return this.flowPromise.promise;

throw new Error(
`Transitioning while ongoing transition from ${this.currentState?.name} is in progress is not supported`
`Transitioning while ongoing transition from ${this.currentState?.name} is in progress is not supported`,
);
}
if (this.currentState?.value.state_type === 'END') {
if (this.currentState?.value.state_type === "END") {
this.log?.warn(
`Skipping transition using ${transitionValue}. Already at and END state`
`Skipping transition using ${transitionValue}. Already at and END state`,
);

@@ -150,3 +150,3 @@

this.log?.debug(
`Skipping transition from ${this.currentState.name} b/c hook told us to`
`Skipping transition from ${this.currentState.name} b/c hook told us to`,
);

@@ -159,6 +159,6 @@ return;

this.currentState.value,
transitionValue
transitionValue,
);
if (!('transitions' in state)) {
if (!("transitions" in state)) {
throw new Error(`No transitions defined for ${this.currentState.value}`);

@@ -168,7 +168,7 @@ }

const { transitions } = state;
const nextState = transitions[transitionValue] || transitions['*'];
const nextState = transitions[transitionValue] || transitions["*"];
if (nextState === undefined) {
this.log?.warn(
`No transition from ${this.currentState.name} using ${transitionValue} or *`
`No transition from ${this.currentState.name} using ${transitionValue} or *`,
);

@@ -180,3 +180,3 @@

this.log?.debug(
`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `
`Transitioning from ${this.currentState.name} to ${nextState} using ${transitionValue} `,
);

@@ -196,4 +196,4 @@

!this.flow[stateName] ||
typeof nextState !== 'object' ||
!('state_type' in nextState)
typeof nextState !== "object" ||
!("state_type" in nextState)
) {

@@ -219,3 +219,3 @@ this.log?.error(`Flow doesn't contain any states named: ${stateName}`);

if (newCurrentState.value.state_type === 'END' && this.flow.onEnd) {
if (newCurrentState.value.state_type === "END" && this.flow.onEnd) {
this.hooks.onEnd.call(this.flow.onEnd);

@@ -222,0 +222,0 @@ }

@@ -1,2 +0,2 @@

export * from './flow';
export * from './controller';
export * from "./flow";
export * from "./controller";

@@ -1,5 +0,5 @@

export * from './flow';
export * from './validation';
export * from './view';
export * from './data/controller';
export * from './constants';
export * from "./flow";
export * from "./validation";
export * from "./view";
export * from "./data/controller";
export * from "./constants";

@@ -1,4 +0,4 @@

import type { Validation } from '@player-ui/types';
import type { ViewPlugin, Resolver, Node, ViewInstance } from '../../view';
import { NodeType } from '../../view';
import type { Validation } from "@player-ui/types";
import type { ViewPlugin, Resolver, Node, ViewInstance } from "../../view";
import { NodeType } from "../../view";
import type {

@@ -8,7 +8,7 @@ BindingInstance,

BindingFactory,
} from '../../binding';
import { isBinding } from '../../binding';
import type { ValidationResponse } from '../../validator';
} from "../../binding";
import { isBinding } from "../../binding";
import type { ValidationResponse } from "../../validator";
const CONTEXT = 'validation-binding-tracker';
const CONTEXT = "validation-binding-tracker";

@@ -95,4 +95,4 @@ export interface BindingTracker {

[...lastViewUpdateChangeSet].filter((b) =>
trackedBindingsForNode.has(b)
)
trackedBindingsForNode.has(b),
),
);

@@ -154,3 +154,4 @@

(eow) =>
eow.displayTarget === 'field' || eow.displayTarget === undefined
eow.displayTarget === "field" ||
eow.displayTarget === undefined,
);

@@ -192,3 +193,3 @@

if (eow && eow.displayTarget === 'section') {
if (eow && eow.displayTarget === "section") {
validations.push(eow);

@@ -201,3 +202,3 @@ }

register: (registerOptions) => {
if (registerOptions?.type === 'section') {
if (registerOptions?.type === "section") {
if (!sections.has(node)) {

@@ -228,7 +229,7 @@ sections.set(node, new Set());

.get(value)
?.forEach((b) => newlyComputed.add(b))
?.forEach((b) => newlyComputed.add(b)),
);
}
if ('children' in resolvedNode && resolvedNode.children) {
if ("children" in resolvedNode && resolvedNode.children) {
resolvedNode.children.forEach((child) => {

@@ -245,3 +246,3 @@ currentBindingTree

resolvedNode,
lastComputedBindingTree.get(originalNode) ?? new Set()
lastComputedBindingTree.get(originalNode) ?? new Set(),
);

@@ -273,3 +274,3 @@ }

}
}
},
);

@@ -276,0 +277,0 @@ }

@@ -1,9 +0,9 @@

import type { Validation } from '@player-ui/types';
import { SyncHook, SyncWaterfallHook } from 'tapable-ts';
import { setIn } from 'timm';
import type { Validation } from "@player-ui/types";
import { SyncHook, SyncWaterfallHook } from "tapable-ts";
import { setIn } from "timm";
import type { BindingInstance, BindingFactory } from '../../binding';
import { isBinding } from '../../binding';
import type { DataModelWithParser, DataModelMiddleware } from '../../data';
import type { SchemaController } from '../../schema';
import type { BindingInstance, BindingFactory } from "../../binding";
import { isBinding } from "../../binding";
import type { DataModelWithParser, DataModelMiddleware } from "../../data";
import type { SchemaController } from "../../schema";
import type {

@@ -18,3 +18,3 @@ ErrorValidationResponse,

StrongOrWeakBinding,
} from '../../validator';
} from "../../validator";
import {

@@ -24,21 +24,21 @@ ValidationMiddleware,

removeBindingAndChildrenFromMap,
} from '../../validator';
import type { Logger } from '../../logger';
import { ProxyLogger } from '../../logger';
import type { Resolve, ViewInstance } from '../../view';
import { caresAboutDataChanges } from '../../view';
import { replaceParams } from '../../utils';
import { resolveDataRefs } from '../../string-resolver';
} from "../../validator";
import type { Logger } from "../../logger";
import { ProxyLogger } from "../../logger";
import type { Resolve, ViewInstance } from "../../view";
import { caresAboutDataChanges } from "../../view";
import { replaceParams } from "../../utils";
import { resolveDataRefs } from "../../string-resolver";
import type {
ExpressionEvaluatorOptions,
ExpressionType,
} from '../../expressions';
import type { BindingTracker } from './binding-tracker';
import { ValidationBindingTrackerViewPlugin } from './binding-tracker';
} from "../../expressions";
import type { BindingTracker } from "./binding-tracker";
import { ValidationBindingTrackerViewPlugin } from "./binding-tracker";
export const SCHEMA_VALIDATION_PROVIDER_NAME = 'schema';
export const VIEW_VALIDATION_PROVIDER_NAME = 'view';
export const SCHEMA_VALIDATION_PROVIDER_NAME = "schema";
export const VIEW_VALIDATION_PROVIDER_NAME = "view";
export const VALIDATION_PROVIDER_NAME_SYMBOL: unique symbol = Symbol.for(
'validation-provider-name'
"validation-provider-name",
);

@@ -53,3 +53,3 @@

ValidatorContext,
'validation' | 'schemaType'
"validation" | "schemaType"
>;

@@ -59,3 +59,3 @@

/** The validation is being actively shown */
state: 'active';
state: "active";

@@ -77,3 +77,3 @@ /** The validation response */

/** A common key to differentiate between errors and warnings */
type: 'warning';
type: "warning";

@@ -88,3 +88,3 @@ /** The underlying validation this tracks */

/** warnings start with no state, but can active or dismissed */
state: 'none' | 'dismissed';
state: "none" | "dismissed";
}

@@ -97,3 +97,3 @@ | ActiveWarning

/** A common key to differentiate between errors and warnings */
type: 'error';
type: "error";

@@ -108,3 +108,3 @@ /** The underlying validation this tracks */

/** Errors start with no state an can be activated */
state: 'none';
state: "none";
}

@@ -125,3 +125,3 @@ | ActiveError

function createStatefulValidationObject(
obj: ValidationObjectWithSource
obj: ValidationObjectWithSource,
): StatefulValidationObject {

@@ -131,3 +131,3 @@ return {

type: obj.severity,
state: 'none',
state: "none",
isBlockingNavigation: false,

@@ -169,3 +169,3 @@ };

log?: Logger,
weakBindings?: Set<BindingInstance>
weakBindings?: Set<BindingInstance>,
) {

@@ -187,3 +187,3 @@ this.onDismiss = onDismiss;

private checkIfBlocking(statefulObj: StatefulValidationObject) {
if (statefulObj.state === 'active') {
if (statefulObj.state === "active") {
const { isBlockingNavigation } = statefulObj;

@@ -198,3 +198,3 @@ return isBlockingNavigation;

return this.applicableValidations.reduce((all, statefulObj) => {
if (statefulObj.state === 'active' && statefulObj.response) {
if (statefulObj.state === "active" && statefulObj.response) {
all.push({

@@ -212,6 +212,6 @@ ...statefulObj.response,

const firstInvalid = this.applicableValidations.find((statefulObj) => {
return statefulObj.state === 'active' && statefulObj.response;
return statefulObj.state === "active" && statefulObj.response;
});
if (firstInvalid?.state === 'active') {
if (firstInvalid?.state === "active") {
return {

@@ -227,3 +227,3 @@ ...firstInvalid.response,

canDismiss: boolean,
phase: Validation.Trigger
phase: Validation.Trigger,
) {

@@ -233,3 +233,3 @@ // If the currentState is not load, skip those

(originalValue) => {
if (originalValue.state === 'dismissed') {
if (originalValue.state === "dismissed") {
// Don't rerun any dismissed warnings

@@ -242,19 +242,19 @@ return originalValue;

originalValue.value.blocking ??
((originalValue.value.severity === 'warning' && 'once') || true);
((originalValue.value.severity === "warning" && "once") || true);
const obj = setIn(
originalValue,
['value', 'blocking'],
blocking
["value", "blocking"],
blocking,
) as StatefulValidationObject;
const isBlockingNavigation =
blocking === true || (blocking === 'once' && !canDismiss);
blocking === true || (blocking === "once" && !canDismiss);
if (
phase === 'navigation' &&
obj.state === 'active' &&
phase === "navigation" &&
obj.state === "active" &&
obj.value.blocking !== true
) {
if (obj.value.severity === 'warning') {
if (obj.value.severity === "warning") {
const warn = obj as ActiveWarning;

@@ -264,7 +264,7 @@ if (

warn.response.dismiss &&
(warn.response.blocking !== 'once' || !warn.response.blocking)
(warn.response.blocking !== "once" || !warn.response.blocking)
) {
warn.response.dismiss();
} else {
if (warn?.response.blocking === 'once') {
if (warn?.response.blocking === "once") {
warn.response.blocking = false;

@@ -285,12 +285,12 @@ }

value: obj.value,
state: response ? 'active' : 'none',
state: response ? "active" : "none",
isBlockingNavigation,
dismissable:
obj.value.severity === 'warning' && phase === 'navigation',
obj.value.severity === "warning" && phase === "navigation",
response: response
? {
...obj.value,
message: response.message ?? 'Something is broken',
message: response.message ?? "Something is broken",
severity: obj.value.severity,
displayTarget: obj.value.displayTarget ?? 'field',
displayTarget: obj.value.displayTarget ?? "field",
}

@@ -300,5 +300,5 @@ : undefined,

if (newState.state === 'active' && obj.value.severity === 'warning') {
if (newState.state === "active" && obj.value.severity === "warning") {
(newState.response as WarningValidationResponse).dismiss = () => {
(newState as StatefulWarning).state = 'dismissed';
(newState as StatefulWarning).state = "dismissed";
this.onDismiss?.();

@@ -309,3 +309,3 @@ };

return newState;
}
},
);

@@ -317,7 +317,7 @@ }

canDismiss: boolean,
runner: ValidationRunner
runner: ValidationRunner,
) {
const newApplicableValidations: StatefulValidationObject[] = [];
if (phase === 'load' && this.currentPhase !== undefined) {
if (phase === "load" && this.currentPhase !== undefined) {
// Tried to run the 'load' phase twice. Aborting

@@ -327,3 +327,3 @@ return;

if (this.currentPhase === 'navigation' || phase === this.currentPhase) {
if (this.currentPhase === "navigation" || phase === this.currentPhase) {
// Already added all the types. No need to continue adding new validations

@@ -334,7 +334,7 @@ this.runApplicableValidations(runner, canDismiss, phase);

if (phase === 'load') {
this.currentPhase = 'load';
if (phase === "load") {
this.currentPhase = "load";
this.applicableValidations = [...this.validationsByState.load];
} else if (phase === 'change' && this.currentPhase === 'load') {
this.currentPhase = 'change';
} else if (phase === "change" && this.currentPhase === "load") {
this.currentPhase = "change";
// The transition to the 'change' type can only come from a 'load' type

@@ -346,4 +346,4 @@ this.applicableValidations = [

} else if (
phase === 'navigation' &&
(this.currentPhase === 'load' || this.currentPhase === 'change')
phase === "navigation" &&
(this.currentPhase === "load" || this.currentPhase === "change")
) {

@@ -357,4 +357,4 @@ // Can transition to a nav state from a change or load

!(
element.type === 'error' &&
element.state === 'active' &&
element.type === "error" &&
element.state === "active" &&
element.isBlockingNavigation === false

@@ -370,5 +370,5 @@ )

...this.validationsByState.navigation,
...(this.currentPhase === 'load' ? this.validationsByState.change : []),
...(this.currentPhase === "load" ? this.validationsByState.change : []),
];
this.currentPhase = 'navigation';
this.currentPhase = "navigation";
}

@@ -421,3 +421,3 @@

provider: ValidationProvider;
}>
}>,
],

@@ -475,3 +475,3 @@ {

this.validations,
binding
binding,
);

@@ -488,7 +488,7 @@

this.updateValidationsForBinding(binding, 'change', this.options);
this.updateValidationsForBinding(binding, "change", this.options);
const strongValidation = this.getValidationForBinding(binding);
// return validation issues directly on bindings first
if (strongValidation?.get()?.severity === 'error') {
if (strongValidation?.get()?.severity === "error") {
return strongValidation.get();

@@ -503,5 +503,5 @@ }

new Set([binding]),
weakValidation.weakBindings
weakValidation.weakBindings,
) &&
weakValidation?.get()?.severity === 'error'
weakValidation?.get()?.severity === "error"
) {

@@ -528,3 +528,3 @@ weakValidation?.weakBindings.forEach((weakBinding) => {

},
{ logger: new ProxyLogger(() => this.options?.logger) }
{ logger: new ProxyLogger(() => this.options?.logger) },
),

@@ -548,6 +548,6 @@ ];

getValidationsForBinding: (
binding: BindingInstance
binding: BindingInstance,
): Array<ValidationObject> | undefined => {
return this.viewValidationProvider?.getValidationsForBinding?.(
binding
binding,
);

@@ -603,7 +603,7 @@ },

binding,
'load',
"load",
this.options,
() => {
view.update(new Set([binding]));
}
},
);

@@ -626,3 +626,3 @@

validationContext?: SimpleValidatorContext,
onDismiss?: () => void
onDismiss?: () => void,
): void {

@@ -635,3 +635,3 @@ const context = validationContext ?? this.options;

if (trigger === 'load') {
if (trigger === "load") {
// Get all of the validations from each provider

@@ -647,3 +647,3 @@ const possibleValidations = this.getValidationProviders().reduce<

[VALIDATION_PROVIDER_NAME_SYMBOL]: provider.source,
})) ?? [])
})) ?? []),
);

@@ -663,4 +663,4 @@

onDismiss,
this.options?.logger
)
this.options?.logger,
),
);

@@ -682,3 +682,3 @@ }

// Also run any validations that binding or sub-binding is a weak binding of
if (trigger !== 'load') {
if (trigger !== "load") {
this.validations.forEach((validation, vBinding) => {

@@ -693,3 +693,3 @@ if (

vBinding,
context
context,
);

@@ -706,6 +706,6 @@ return response ? { message: response.message } : undefined;

binding: BindingInstance,
context: SimpleValidatorContext | undefined = this.options
context: SimpleValidatorContext | undefined = this.options,
) {
if (!context) {
throw new Error('No context provided to validation runner');
throw new Error("No context provided to validation runner");
}

@@ -733,3 +733,3 @@

exp: ExpressionType,
options: ExpressionEvaluatorOptions = { model }
options: ExpressionEvaluatorOptions = { model },
) => context.evaluate(exp, options),

@@ -742,5 +742,5 @@ model,

includeInvalid: true,
formatted: validationObj.dataTarget === 'formatted',
formatted: validationObj.dataTarget === "formatted",
}),
validationObj
validationObj,
);

@@ -771,3 +771,3 @@

private updateValidationsForView(trigger: Validation.Trigger): void {
const isNavigationTrigger = trigger === 'navigation';
const isNavigationTrigger = trigger === "navigation";
const lastActiveBindings = this.activeBindings;

@@ -805,4 +805,4 @@

Array.from(this.getBindings()).filter(
(b) => this.validations.get(b)?.get() !== undefined
)
(b) => this.validations.get(b)?.get() !== undefined,
),
);

@@ -832,3 +832,3 @@ }

/** Executes all known validations for the tracked bindings using the given model */
validateView(trigger: Validation.Trigger = 'navigation'): {
validateView(trigger: Validation.Trigger = "navigation"): {
/** Indicating if the view can proceed without error */

@@ -850,7 +850,7 @@ canTransition: boolean;

allValidations?.forEach((v) => {
if (trigger === 'navigation' && v.blocking) {
if (trigger === "navigation" && v.blocking) {
this.options?.logger.debug(
`Validation on binding: ${b.asString()} is preventing navigation. ${JSON.stringify(
v
)}`
v,
)}`,
);

@@ -875,3 +875,3 @@

public getValidationForBinding(
binding: BindingInstance
binding: BindingInstance,
): ValidatedBinding | undefined {

@@ -885,3 +885,3 @@ return this.validations.get(binding);

return this.getValidationForBinding(
isBinding(binding) ? binding : parser(binding)
isBinding(binding) ? binding : parser(binding),
);

@@ -911,19 +911,19 @@ },

get() {
throw new Error('Error Access be provided by the view plugin');
throw new Error("Error Access be provided by the view plugin");
},
getValidationsForBinding() {
throw new Error('Error rollup should be provided by the view plugin');
throw new Error("Error rollup should be provided by the view plugin");
},
getChildren() {
throw new Error('Error rollup should be provided by the view plugin');
throw new Error("Error rollup should be provided by the view plugin");
},
getValidationsForSection() {
throw new Error('Error rollup should be provided by the view plugin');
throw new Error("Error rollup should be provided by the view plugin");
},
track: () => {
throw new Error('Tracking should be provided by the view plugin');
throw new Error("Tracking should be provided by the view plugin");
},
register: () => {
throw new Error(
'Section functionality should be provided by the view plugin'
"Section functionality should be provided by the view plugin",
);

@@ -930,0 +930,0 @@ },

@@ -1,2 +0,2 @@

export * from './controller';
export * from './binding-tracker';
export * from "./controller";
export * from "./binding-tracker";

@@ -1,6 +0,6 @@

import type { Node } from '../../view';
import { NodeType } from '../../view';
import { LocalStateStore } from './store';
import type { TransformRegistry } from './types';
import type { ViewController } from './controller';
import type { Node } from "../../view";
import { NodeType } from "../../view";
import { LocalStateStore } from "./store";
import type { TransformRegistry } from "./types";
import type { ViewController } from "./controller";

@@ -35,14 +35,14 @@ /** Traverse up the nodes until the target is found */

this.stateStore = new Map();
this.beforeResolveSymbol = Symbol('before resolve');
this.resolveSymbol = Symbol('resolve');
this.beforeResolveCountSymbol = Symbol('before resolve count');
this.resolveCountSymbol = Symbol('resolve count');
this.beforeResolveSymbol = Symbol("before resolve");
this.resolveSymbol = Symbol("resolve");
this.beforeResolveCountSymbol = Symbol("before resolve count");
this.resolveCountSymbol = Symbol("resolve count");
}
apply(viewController: ViewController) {
viewController.hooks.view.tap('asset-transform', (view) => {
viewController.hooks.view.tap("asset-transform", (view) => {
// Clear out everything when we create a new view
this.stateStore.clear();
view.hooks.resolver.tap('asset-transform', (resolver) => {
view.hooks.resolver.tap("asset-transform", (resolver) => {
let lastUpdatedNode: Node.Node | undefined;

@@ -78,3 +78,3 @@

useSharedState: (
key: string | symbol
key: string | symbol,
): (<T>(initialState: T) => readonly [T, (value: T) => void]) => {

@@ -86,3 +86,3 @@ return store.useSharedState(key);

stepKey,
countKey
countKey,
)(initialState);

@@ -93,4 +93,4 @@ },

resolver.hooks.beforeResolve.tap('asset-transform', (node, options) => {
if (node && (node.type === 'asset' || node.type === 'view')) {
resolver.hooks.beforeResolve.tap("asset-transform", (node, options) => {
if (node && (node.type === "asset" || node.type === "view")) {
const transform = this.registry.get(node.value);

@@ -101,3 +101,3 @@

options.node ?? node,
this.beforeResolveSymbol
this.beforeResolveSymbol,
);

@@ -112,7 +112,7 @@

resolver.hooks.afterUpdate.tap('asset-transform', () => {
resolver.hooks.afterUpdate.tap("asset-transform", () => {
lastUpdatedNode = undefined;
});
resolver.hooks.skipResolve.tap('asset-transform', (skip, node) => {
resolver.hooks.skipResolve.tap("asset-transform", (skip, node) => {
if (!skip || !lastUpdatedNode) {

@@ -129,3 +129,3 @@ return skip;

resolver.hooks.afterResolve.tap(
'asset-transform',
"asset-transform",
(value, node, options) => {

@@ -151,3 +151,3 @@ if (node.type !== NodeType.Asset && node.type !== NodeType.View) {

return value;
}
},
);

@@ -154,0 +154,0 @@ });

@@ -1,15 +0,15 @@

import { SyncHook, SyncWaterfallHook } from 'tapable-ts';
import queueMicrotask from 'queue-microtask';
import { Registry } from '@player-ui/partial-match-registry';
import type { View, NavigationFlowViewState } from '@player-ui/types';
import { SyncHook, SyncWaterfallHook } from "tapable-ts";
import queueMicrotask from "queue-microtask";
import { Registry } from "@player-ui/partial-match-registry";
import type { View, NavigationFlowViewState } from "@player-ui/types";
import { resolveDataRefsInString } from '../../string-resolver';
import type { Resolve } from '../../view';
import { ViewInstance } from '../../view';
import type { Logger } from '../../logger';
import type { FlowInstance, FlowController } from '../flow';
import type { DataController } from '../data/controller';
import { AssetTransformCorePlugin } from './asset-transform';
import type { TransformRegistry } from './types';
import type { BindingInstance } from '../../binding';
import { resolveDataRefsInString } from "../../string-resolver";
import type { Resolve } from "../../view";
import { ViewInstance } from "../../view";
import type { Logger } from "../../logger";
import type { FlowInstance, FlowController } from "../flow";
import type { DataController } from "../data/controller";
import { AssetTransformCorePlugin } from "./asset-transform";
import type { TransformRegistry } from "./types";
import type { BindingInstance } from "../../binding";

@@ -54,3 +54,3 @@ export interface ViewControllerOptions {

initialViews: View[],
options: Resolve.ResolverOptions & ViewControllerOptions
options: Resolve.ResolverOptions & ViewControllerOptions,
) {

@@ -64,3 +64,3 @@ this.viewOptions = options;

},
{}
{},
);

@@ -71,6 +71,6 @@

options.flowController.hooks.flow.tap(
'viewController',
"viewController",
(flow: FlowInstance) => {
flow.hooks.transition.tap('viewController', (_oldState, newState) => {
if (newState.value.state_type === 'VIEW') {
flow.hooks.transition.tap("viewController", (_oldState, newState) => {
if (newState.value.state_type === "VIEW") {
this.onView(newState.value);

@@ -81,3 +81,3 @@ } else {

});
}
},
);

@@ -97,12 +97,12 @@

options.model.hooks.onUpdate.tap(
'viewController',
"viewController",
(updates, updateOptions) => {
update(
new Set(updates.map((t) => t.binding)),
updateOptions?.silent ?? false
updateOptions?.silent ?? false,
);
}
},
);
options.model.hooks.onDelete.tap('viewController', (binding) => {
options.model.hooks.onDelete.tap("viewController", (binding) => {
const parentBinding = binding.parent();

@@ -112,3 +112,3 @@ const property = binding.key();

// Deleting an array item will trigger an update for the entire array
if (typeof property === 'number' && parentBinding) {
if (typeof property === "number" && parentBinding) {
update(new Set([parentBinding]));

@@ -157,3 +157,3 @@ } else {

evaluate: this.viewOptions.evaluator.evaluate,
})
}),
);

@@ -172,3 +172,3 @@

viewId,
state
state,
);

@@ -175,0 +175,0 @@

@@ -1,4 +0,4 @@

export * from './asset-transform';
export * from './controller';
export * from './store';
export * from './types';
export * from "./asset-transform";
export * from "./controller";
export * from "./store";
export * from "./types";
export interface Store {
useLocalState<T>(initialState: T): readonly [T, (value: T) => void];
useSharedState<T>(
key: string | symbol
key: string | symbol,
): (initialState: T) => readonly [T, (value: T) => void];

@@ -11,6 +11,6 @@ }

key: string | symbol,
countKey: symbol
countKey: symbol,
): (initialState: T) => readonly [T, (value: T) => void];
useSharedState<T>(
key: string | symbol
key: string | symbol,
): (initialState: T) => readonly [T, (value: T) => void];

@@ -17,0 +17,0 @@ }

@@ -1,6 +0,6 @@

import type { Asset } from '@player-ui/types';
import type { Registry } from '@player-ui/partial-match-registry';
import type { Asset } from "@player-ui/types";
import type { Registry } from "@player-ui/partial-match-registry";
import type { Resolve, Node } from '../../view';
import type { Store } from './store';
import type { Resolve, Node } from "../../view";
import type { Store } from "./store";

@@ -11,3 +11,3 @@ /** Transform function that is ran on the Asset before it's resolved */

options: Resolve.NodeResolveOptions,
store: Store
store: Store,
) => Node.Node;

@@ -18,7 +18,7 @@

AuthoredAsset extends Asset = Asset,
TransformedAsset extends Asset = AuthoredAsset
TransformedAsset extends Asset = AuthoredAsset,
> = (
asset: AuthoredAsset,
options: Resolve.NodeResolveOptions,
store: Store
store: Store,
) => TransformedAsset;

@@ -25,0 +25,0 @@

@@ -1,2 +0,2 @@

import type { BindingInstance } from '../binding';
import type { BindingInstance } from "../binding";
import type {

@@ -8,5 +8,5 @@ BatchSetTransaction,

Updates,
} from './model';
} from "./model";
export type DependencySets = 'core' | 'children';
export type DependencySets = "core" | "children";

@@ -35,6 +35,6 @@ /** A class to track usage of read/writes to/from a data model */

this.namedDependencySets = {};
this.namedSet = 'core';
this.namedSet = "core";
this.createSubset('core');
this.createSubset('children');
this.createSubset("core");
this.createSubset("children");
}

@@ -66,3 +66,3 @@

public trackDefault() {
this.namedSet = 'core';
this.namedSet = "core";
}

@@ -100,6 +100,6 @@

this.namedDependencySets = {};
this.namedSet = 'core';
this.namedSet = "core";
this.createSubset('core', true);
this.createSubset('children', true);
this.createSubset("core", true);
this.createSubset("children", true);
}

@@ -109,3 +109,3 @@

binding: BindingInstance,
namedSet = this.namedSet
namedSet = this.namedSet,
): void {

@@ -121,3 +121,3 @@ if (namedSet) {

binding: BindingInstance,
namedSet = this.namedSet
namedSet = this.namedSet,
): void {

@@ -132,3 +132,3 @@ if (namedSet) {

public addChildReadDep(binding: BindingInstance): void {
this.addReadDep(binding, 'children');
this.addReadDep(binding, "children");
}

@@ -151,3 +151,3 @@ }

options?: DataModelOptions,
next?: DataModelImpl | undefined
next?: DataModelImpl | undefined,
): Updates {

@@ -162,3 +162,3 @@ transaction.forEach(([binding]) => this.addWriteDep(binding));

options?: DataModelOptions,
next?: DataModelImpl | undefined
next?: DataModelImpl | undefined,
) {

@@ -173,3 +173,3 @@ this.addReadDep(binding);

options?: DataModelOptions,
next?: DataModelImpl | undefined
next?: DataModelImpl | undefined,
) {

@@ -176,0 +176,0 @@ this.addWriteDep(binding);

@@ -1,4 +0,4 @@

export * from './dependency-tracker';
export * from './model';
export * from './noop-model';
export * from './local-model';
export * from "./dependency-tracker";
export * from "./model";
export * from "./noop-model";
export * from "./local-model";

@@ -1,5 +0,5 @@

import get from 'dlv';
import { setIn, omit, removeAt } from 'timm';
import type { BindingInstance } from '../binding';
import type { BatchSetTransaction, DataModelImpl, Updates } from './model';
import get from "dlv";
import { setIn, omit, removeAt } from "timm";
import type { BindingInstance } from "../binding";
import type { BatchSetTransaction, DataModelImpl, Updates } from "./model";

@@ -53,3 +53,3 @@ /**

parentBinding.asArray(),
removeAt(parentValue, binding.key() as number)
removeAt(parentValue, binding.key() as number),
) as any;

@@ -60,3 +60,3 @@ } else {

parentBinding.asArray(),
omit(parentValue, binding.key() as string)
omit(parentValue, binding.key() as string),
) as any;

@@ -63,0 +63,0 @@ }

@@ -1,5 +0,5 @@

import { SyncHook } from 'tapable-ts';
import type { BindingLike, BindingFactory } from '../binding';
import { BindingInstance, isBinding } from '../binding';
import { NOOP_MODEL } from './noop-model';
import { SyncHook } from "tapable-ts";
import type { BindingLike, BindingFactory } from "../binding";
import { BindingInstance, isBinding } from "../binding";
import { NOOP_MODEL } from "./noop-model";

@@ -75,3 +75,3 @@ export const ROOT_BINDING = new BindingInstance([]);

options?: DataModelOptions,
next?: DataModelImpl
next?: DataModelImpl,
): Updates;

@@ -82,3 +82,3 @@

options?: DataModelOptions,
next?: DataModelImpl
next?: DataModelImpl,
): any;

@@ -89,3 +89,3 @@

options?: DataModelOptions,
next?: DataModelImpl
next?: DataModelImpl,
): void;

@@ -99,3 +99,3 @@

model: DataModelImpl<Options>,
parseBinding: BindingFactory
parseBinding: BindingFactory,
): DataModelWithParser<Options> {

@@ -105,3 +105,3 @@ /** Parse something into a binding if it requires it */

binding: BindingLike,
readOnly: boolean
readOnly: boolean,
): BindingInstance {

@@ -117,3 +117,3 @@ const parsed = isBinding(binding)

if (!parsed) {
throw new Error('Unable to parse binding');
throw new Error("Unable to parse binding");
}

@@ -131,3 +131,3 @@

transaction.map(([key, val]) => [maybeParse(key, false), val]),
options
options,
);

@@ -145,3 +145,3 @@ },

defaultOptions?: DataModelOptions,
next?: DataModelImpl
next?: DataModelImpl,
): DataModelImpl {

@@ -189,3 +189,3 @@ if (!next) {

export function constructModelForPipeline(
pipeline: DataPipeline
pipeline: DataPipeline,
): DataModelImpl {

@@ -205,3 +205,3 @@ if (pipeline.length === 0) {

(nextModel, middleware) => toModel(middleware, options, nextModel),
undefined
undefined,
) ?? NOOP_MODEL;

@@ -251,3 +251,3 @@

this.pipeline.forEach((middleware) => {
if ('reset' in middleware) {
if ("reset" in middleware) {
middleware.reset?.();

@@ -262,7 +262,7 @@ }

transaction: BatchSetTransaction,
options?: DataModelOptions
options?: DataModelOptions,
): Updates {
const appliedTransaction = this.effectiveDataModel.set(
transaction,
options
options,
);

@@ -269,0 +269,0 @@ this.hooks.onSet.call(transaction);

@@ -1,2 +0,2 @@

import type { DataModelImpl } from './model';
import type { DataModelImpl } from "./model";

@@ -3,0 +3,0 @@ /**

@@ -1,4 +0,4 @@

import type { Binding } from '@player-ui/types';
import type { Binding } from "@player-ui/types";
import type { BindingLike } from '../binding';
import type { BindingLike } from "../binding";
import type {

@@ -8,3 +8,3 @@ ExpressionHandler,

ExpressionNode,
} from './types';
} from "./types";

@@ -15,3 +15,3 @@ /** Sets a value to the data-model */

binding,
value
value,
) => {

@@ -24,3 +24,3 @@ _context.model.set([[binding as BindingLike, value]]);

_context: ExpressionContext,
binding
binding,
) => {

@@ -33,3 +33,3 @@ return _context.model.get(binding as BindingLike);

_context: ExpressionContext,
binding
binding,
) => {

@@ -36,0 +36,0 @@ return _context.model.delete(binding);

@@ -1,7 +0,7 @@

import { SyncWaterfallHook, SyncBailHook } from 'tapable-ts';
import { NestedError } from 'ts-nested-error';
import { parseExpression } from './parser';
import * as DEFAULT_EXPRESSION_HANDLERS from './evaluator-functions';
import { isExpressionNode } from './types';
import { isObjectExpression } from './utils';
import { SyncWaterfallHook, SyncBailHook } from "tapable-ts";
import { NestedError } from "ts-nested-error";
import { parseExpression } from "./parser";
import * as DEFAULT_EXPRESSION_HANDLERS from "./evaluator-functions";
import { isExpressionNode } from "./types";
import { isObjectExpression } from "./utils";
import type {

@@ -14,3 +14,3 @@ ExpressionNode,

ExpressionHandler,
} from './types';
} from "./types";

@@ -33,41 +33,41 @@ /** a && b -- but handles short cutting if the first value is false */

// TODO: A lot of these functions used to do type coercion. Not sure if we want to keep that behavior or not.
'+': (a: any, b: any) => a + b,
'-': (a: any, b: any) => a - b,
'*': (a: any, b: any) => a * b,
'/': (a: any, b: any) => a / b,
'%': (a: any, b: any) => a % b,
"+": (a: any, b: any) => a + b,
"-": (a: any, b: any) => a - b,
"*": (a: any, b: any) => a * b,
"/": (a: any, b: any) => a / b,
"%": (a: any, b: any) => a % b,
// eslint-disable-next-line
'==': (a: any, b: any) => a == b,
"==": (a: any, b: any) => a == b,
// eslint-disable-next-line
'!=': (a: any, b: any) => a != b,
'>': (a: any, b: any) => a > b,
'>=': (a: any, b: any) => a >= b,
'<': (a: any, b: any) => a < b,
'<=': (a: any, b: any) => a <= b,
'&&': andandOperator,
'||': ororOperator,
'!==': (a: any, b: any) => a !== b,
'===': (a: any, b: any) => a === b,
"!=": (a: any, b: any) => a != b,
">": (a: any, b: any) => a > b,
">=": (a: any, b: any) => a >= b,
"<": (a: any, b: any) => a < b,
"<=": (a: any, b: any) => a <= b,
"&&": andandOperator,
"||": ororOperator,
"!==": (a: any, b: any) => a !== b,
"===": (a: any, b: any) => a === b,
// eslint-disable-next-line
'|': (a: any, b: any) => a | b,
"|": (a: any, b: any) => a | b,
// eslint-disable-next-line
'&': (a: any, b: any) => a & b,
'+=': (a: any, b: any) => a + b,
'-=': (a: any, b: any) => a - b,
"&": (a: any, b: any) => a & b,
"+=": (a: any, b: any) => a + b,
"-=": (a: any, b: any) => a - b,
// eslint-disable-next-line
'&=': (a: any, b: any) => a & b,
"&=": (a: any, b: any) => a & b,
// eslint-disable-next-line
'|=': (a: any, b: any) => a | b,
"|=": (a: any, b: any) => a | b,
};
const DEFAULT_UNARY_OPERATORS: Record<string, UnaryOperator> = {
'-': (a: any) => -a,
'+': (a: any) => Number(a),
'!': (a: any) => !a,
"-": (a: any) => -a,
"+": (a: any) => Number(a),
"!": (a: any) => !a,
};

@@ -90,3 +90,3 @@

HookOptions,
'resolveNode' | 'evaluate'
"resolveNode" | "evaluate"
>;

@@ -96,3 +96,3 @@

exp: ExpressionType,
options?: ExpressionEvaluatorOptions
options?: ExpressionEvaluatorOptions,
) => any;

@@ -130,3 +130,3 @@

expressions: new Map<string, ExpressionHandler<any, any>>(
Object.entries(DEFAULT_EXPRESSION_HANDLERS)
Object.entries(DEFAULT_EXPRESSION_HANDLERS),
),

@@ -147,3 +147,3 @@ };

this.hooks.resolve.tap('ExpressionEvaluator', this._resolveNode.bind(this));
this.hooks.resolve.tap("ExpressionEvaluator", this._resolveNode.bind(this));
this.evaluate = this.evaluate.bind(this);

@@ -154,3 +154,3 @@ }

expr: ExpressionType,
options?: ExpressionEvaluatorOptions
options?: ExpressionEvaluatorOptions,
): any {

@@ -173,4 +173,4 @@ const resolvedOpts = this.hooks.resolveOptions.call({

if (
typeof expression === 'number' ||
typeof expression === 'boolean' ||
typeof expression === "number" ||
typeof expression === "boolean" ||
expression === undefined ||

@@ -190,3 +190,3 @@ expression === null

(_nothing, exp) => this.evaluate(exp, options),
null
null,
);

@@ -200,3 +200,3 @@ }

name: string,
handler: ExpressionHandler<T, R>
handler: ExpressionHandler<T, R>,
): void {

@@ -227,3 +227,3 @@ this.operators.expressions.set(name, handler);

private _execString(exp: string, options: HookOptions) {
if (exp === '') {
if (exp === "") {
return exp;

@@ -268,3 +268,3 @@ }

node: ExpressionNode,
options: HookOptions
options: HookOptions,
) {

@@ -278,19 +278,19 @@ const { resolveNode, model } = options;

if (node.type === 'Literal') {
if (node.type === "Literal") {
return node.value;
}
if (node.type === 'Identifier') {
if (node.type === "Identifier") {
return this.vars[node.name];
}
if (node.type === 'Compound' || node.type === 'ThisExpression') {
if (node.type === "Compound" || node.type === "ThisExpression") {
throw new Error(`Expression type: ${node.type} is not supported`);
}
if (node.type === 'BinaryExpression' || node.type === 'LogicalExpression') {
if (node.type === "BinaryExpression" || node.type === "LogicalExpression") {
const operator = this.operators.binary.get(node.operator);
if (operator) {
if ('resolveParams' in operator) {
if ("resolveParams" in operator) {
if (operator.resolveParams === false) {

@@ -303,3 +303,3 @@ return operator(expressionContext, node.left, node.right);

resolveNode(node.left),
resolveNode(node.right)
resolveNode(node.right),
);

@@ -314,7 +314,7 @@ }

if (node.type === 'UnaryExpression') {
if (node.type === "UnaryExpression") {
const operator = this.operators.unary.get(node.operator);
if (operator) {
if ('resolveParams' in operator) {
if ("resolveParams" in operator) {
return operator(

@@ -324,3 +324,3 @@ expressionContext,

? node.argument
: resolveNode(node.argument)
: resolveNode(node.argument),
);

@@ -335,3 +335,3 @@ }

if (node.type === 'Object') {
if (node.type === "Object") {
const { attributes } = node;

@@ -349,3 +349,3 @@ const resolvedAttributes: any = {};

if (node.type === 'CallExpression') {
if (node.type === "CallExpression") {
const expressionName = node.callTarget.name;

@@ -359,3 +359,3 @@

if ('resolveParams' in operator && operator.resolveParams === false) {
if ("resolveParams" in operator && operator.resolveParams === false) {
return operator(expressionContext, ...node.args);

@@ -369,7 +369,7 @@ }

if (node.type === 'ModelRef') {
if (node.type === "ModelRef") {
return model.get(node.ref, { context: { model: options.model } });
}
if (node.type === 'MemberExpression') {
if (node.type === "MemberExpression") {
const obj = resolveNode(node.object);

@@ -381,4 +381,4 @@ const prop = resolveNode(node.property);

if (node.type === 'Assignment') {
if (node.left.type === 'ModelRef') {
if (node.type === "Assignment") {
if (node.left.type === "ModelRef") {
const value = resolveNode(node.right);

@@ -390,3 +390,3 @@ model.set([[node.left.ref, value]]);

if (node.left.type === 'Identifier') {
if (node.left.type === "Identifier") {
const value = resolveNode(node.right);

@@ -400,3 +400,3 @@ this.vars[node.left.name] = value;

if (node.type === 'ConditionalExpression') {
if (node.type === "ConditionalExpression") {
const result = resolveNode(node.test) ? node.consequent : node.alternate;

@@ -407,7 +407,7 @@

if (node.type === 'ArrayExpression') {
if (node.type === "ArrayExpression") {
return node.elements.map((ele) => resolveNode(ele));
}
if (node.type === 'Modification') {
if (node.type === "Modification") {
const operation = this.operators.binary.get(node.operator);

@@ -418,3 +418,3 @@

if ('resolveParams' in operation) {
if ("resolveParams" in operation) {
if (operation.resolveParams === false) {

@@ -426,3 +426,3 @@ newValue = operation(expressionContext, node.left, node.right);

resolveNode(node.left),
resolveNode(node.right)
resolveNode(node.right),
);

@@ -434,5 +434,5 @@ }

if (node.left.type === 'ModelRef') {
if (node.left.type === "ModelRef") {
model.set([[node.left.ref, newValue]]);
} else if (node.left.type === 'Identifier') {
} else if (node.left.type === "Identifier") {
this.vars[node.left.name] = newValue;

@@ -439,0 +439,0 @@ }

@@ -1,4 +0,4 @@

export * from './evaluator';
export * from './types';
export * from './utils';
export * from './parser';
export * from "./evaluator";
export * from "./types";
export * from "./utils";
export * from "./parser";

@@ -10,4 +10,4 @@ /* eslint @typescript-eslint/no-use-before-define: 0 */

NodeLocation,
} from './types';
import { ExpNodeOpaqueIdentifier } from './types';
} from "./types";
import { ExpNodeOpaqueIdentifier } from "./types";

@@ -36,3 +36,3 @@ const PERIOD_CODE = 46; // '.'

// Values are set to `true` (it really doesn't matter)
const unaryOps = { '-': t, '!': t, '~': t, '+': t };
const unaryOps = { "-": t, "!": t, "~": t, "+": t };

@@ -43,29 +43,29 @@ // Also use a map for the binary operations but set their values to their

const binaryOps: Record<string, number> = {
'=': 3,
'+=': 3,
'-=': 3,
'&=': 3,
'|=': 3,
"=": 3,
"+=": 3,
"-=": 3,
"&=": 3,
"|=": 3,
// Conditional: 4,
'||': 5,
'&&': 6,
'|': 7,
'^': 8,
'&': 9,
'==': 10,
'!=': 10,
'===': 10,
'!==': 10,
'<': 11,
'>': 11,
'<=': 11,
'>=': 11,
'<<': 12,
'>>': 12,
'>>>': 12,
'+': 13,
'-': 13,
'*': 14,
'/': 14,
'%': 14,
"||": 5,
"&&": 6,
"|": 7,
"^": 8,
"&": 9,
"==": 10,
"!=": 10,
"===": 10,
"!==": 10,
"<": 11,
">": 11,
"<=": 11,
">=": 11,
"<<": 12,
">>": 12,
">>>": 12,
"+": 13,
"-": 13,
"*": 14,
"/": 14,
"%": 14,
};

@@ -122,3 +122,3 @@

// Except for `this`, which is special. This could be changed to something like `'self'` as well
const thisStr = 'this';
const thisStr = "this";

@@ -138,19 +138,19 @@ /** Returns the precedence of a binary operator or `0` if it isn't a binary operator */

right: string,
location?: NodeLocation
location?: NodeLocation,
) {
let type: ExpressionNodeType;
if (operator === '||' || operator === '&&') {
type = 'LogicalExpression';
} else if (operator === '=') {
type = 'Assignment';
if (operator === "||" || operator === "&&") {
type = "LogicalExpression";
} else if (operator === "=") {
type = "Assignment";
} else if (
operator === '+=' ||
operator === '-=' ||
operator === '&=' ||
operator === '|='
operator === "+=" ||
operator === "-=" ||
operator === "&=" ||
operator === "|="
) {
type = 'Modification';
type = "Modification";
} else {
type = 'BinaryExpression';
type = "BinaryExpression";
}

@@ -205,3 +205,3 @@

strict?: boolean;
}
},
): ExpressionNode {

@@ -269,3 +269,3 @@ const strictMode = options?.strict ?? true;

if (key) {
throwError('A key was defined but a value was not', index);
throwError("A key was defined but a value was not", index);
}

@@ -279,3 +279,3 @@

if (chCode !== SQUOTE_CODE && chCode !== DQUOTE_CODE) {
throwError('An object must start wtih a key', index);
throwError("An object must start wtih a key", index);
}

@@ -292,3 +292,3 @@

} else {
throwError('A colon must follow an object key', index);
throwError("A colon must follow an object key", index);
}

@@ -304,3 +304,3 @@ } else {

} else if (chCode !== CCURL_CODE) {
throwError('Please add a comma to add another key', index);
throwError("Please add a comma to add another key", index);
}

@@ -323,3 +323,3 @@

__id: ExpNodeOpaqueIdentifier,
type: 'Object',
type: "Object",
attributes,

@@ -355,3 +355,3 @@ location: getLocation(startCharIndex),

if (!consequent) {
throwError('Expected expression', index);
throwError("Expected expression", index);
}

@@ -366,3 +366,3 @@

if (!alternate) {
throwError('Expected expression', index);
throwError("Expected expression", index);
}

@@ -372,3 +372,3 @@

__id: ExpNodeOpaqueIdentifier,
type: 'ConditionalExpression',
type: "ConditionalExpression",
test,

@@ -381,3 +381,3 @@ consequent,

throwError('Expected :', index);
throwError("Expected :", index);
}

@@ -462,3 +462,3 @@

right,
createSpanningLocation(left.location, right.location)
createSpanningLocation(left.location, right.location),
);

@@ -486,3 +486,3 @@ stack.push(node);

node,
createSpanningLocation(stack[i - 2].location, node.location)
createSpanningLocation(stack[i - 2].location, node.location),
);

@@ -541,3 +541,3 @@ i -= 2;

__id: ExpNodeOpaqueIdentifier,
type: 'UnaryExpression',
type: "UnaryExpression",
operator: toCheck,

@@ -561,3 +561,3 @@ argument: gobbleToken(),

function gobbleNumericLiteral() {
let num = '';
let num = "";
const startCharIndex = index;

@@ -579,3 +579,3 @@

let ch = exprI(index);
if (ch === 'e' || ch === 'E') {
if (ch === "e" || ch === "E") {
// Exponent marker

@@ -585,3 +585,3 @@ num += exprI(index++);

if (ch === '+' || ch === '-') {
if (ch === "+" || ch === "-") {
// Exponent sign

@@ -606,6 +606,6 @@ num += exprI(index++);

`Variable names cannot start with a number (${num}${exprI(index)})`,
index
index,
);
} else if (chCode === PERIOD_CODE) {
throwError('Unexpected period', index);
throwError("Unexpected period", index);
}

@@ -615,3 +615,3 @@

__id: ExpNodeOpaqueIdentifier,
type: 'Literal',
type: "Literal",
value: parseFloat(num),

@@ -629,3 +629,3 @@ raw: num,

const quote = exprI(index++);
let str = '';
let str = "";
let closed = false;

@@ -642,3 +642,3 @@ const startCharIndex = index;

if (ch !== '\\') {
if (ch !== "\\") {
str += ch;

@@ -652,19 +652,19 @@ continue;

switch (ch) {
case 'n':
str += '\n';
case "n":
str += "\n";
break;
case 'r':
str += '\r';
case "r":
str += "\r";
break;
case 't':
str += '\t';
case "t":
str += "\t";
break;
case 'b':
str += '\b';
case "b":
str += "\b";
break;
case 'f':
str += '\f';
case "f":
str += "\f";
break;
case 'v':
str += '\u000B';
case "v":
str += "\u000B";
break;

@@ -681,3 +681,3 @@ default:

__id: ExpNodeOpaqueIdentifier,
type: 'Literal',
type: "Literal",
value: str,

@@ -694,3 +694,3 @@ raw: `${quote}${str}${quote}`,

function gobbleModelRef() {
let str = '';
let str = "";
let closed = false;

@@ -704,3 +704,3 @@ let openBraceCount = 1;

if (ch === '}' && exprICode(index) === CCURL_CODE) {
if (ch === "}" && exprICode(index) === CCURL_CODE) {
index++;

@@ -714,6 +714,6 @@ openBraceCount--;

str += '}}';
} else if (ch === '{' && exprICode(index) === OCURL_CODE) {
str += "}}";
} else if (ch === "{" && exprICode(index) === OCURL_CODE) {
openBraceCount++;
str += '{{';
str += "{{";
index++;

@@ -731,3 +731,3 @@ } else {

__id: ExpNodeOpaqueIdentifier,
type: 'ModelRef',
type: "ModelRef",
ref: str,

@@ -768,3 +768,3 @@ location: getLocation(startCharIndex),

__id: ExpNodeOpaqueIdentifier,
type: 'Literal',
type: "Literal",
value: (literals as any)[identifier],

@@ -779,3 +779,3 @@ raw: identifier,

__id: ExpNodeOpaqueIdentifier,
type: 'ThisExpression',
type: "ThisExpression",
location: getLocation(start),

@@ -787,3 +787,3 @@ };

__id: ExpNodeOpaqueIdentifier,
type: 'Identifier',
type: "Identifier",
name: identifier,

@@ -824,4 +824,4 @@ location: getLocation(start),

if (!node || node.type === 'Compound') {
throwError('Expected comma', index);
if (!node || node.type === "Compound") {
throwError("Expected comma", index);
}

@@ -865,3 +865,3 @@

__id: ExpNodeOpaqueIdentifier,
type: 'MemberExpression',
type: "MemberExpression",
computed: false,

@@ -875,3 +875,3 @@ object: node,

__id: ExpNodeOpaqueIdentifier,
type: 'MemberExpression',
type: "MemberExpression",
computed: true,

@@ -887,3 +887,3 @@ object: node,

if (charIndex !== CBRACK_CODE) {
throwError('Unclosed [', index);
throwError("Unclosed [", index);
}

@@ -896,3 +896,3 @@

__id: ExpNodeOpaqueIdentifier,
type: 'CallExpression',
type: "CallExpression",
args: gobbleArguments(CPAREN_CODE),

@@ -928,3 +928,3 @@ callTarget: node,

throwError('Unclosed (', index);
throwError("Unclosed (", index);
}

@@ -943,3 +943,3 @@

__id: ExpNodeOpaqueIdentifier,
type: 'ArrayExpression',
type: "ArrayExpression",
elements: gobbleArguments(CBRACK_CODE),

@@ -982,3 +982,3 @@ location: getLocation(startCharIndex),

__id: ExpNodeOpaqueIdentifier,
type: 'Compound',
type: "Compound",
body: nodes,

@@ -994,3 +994,3 @@ location: getLocation(0),

__id: ExpNodeOpaqueIdentifier,
type: 'Compound',
type: "Compound",
body: nodes,

@@ -997,0 +997,0 @@ location: getLocation(0),

@@ -1,3 +0,3 @@

import type { DataModelWithParser } from '../data';
import type { Logger } from '../logger';
import type { DataModelWithParser } from "../data";
import type { Logger } from "../logger";

@@ -55,7 +55,7 @@ export type ExpressionObjectType = {

T extends readonly unknown[] = unknown[],
R = void
R = void,
> = ((context: ExpressionContext, ...args: T) => R) &
Partial<OperatorProcessingOptions>;
export const ExpNodeOpaqueIdentifier = Symbol('Expression Node ID');
export const ExpNodeOpaqueIdentifier = Symbol("Expression Node ID");

@@ -65,3 +65,3 @@ /** Checks if the input is an already processed Expression node */

return (
typeof x === 'object' &&
typeof x === "object" &&
x !== null &&

@@ -115,3 +115,3 @@ !Array.isArray(x) &&

export interface LiteralNode extends BaseNode<'Literal'> {
export interface LiteralNode extends BaseNode<"Literal"> {
/** A node that holds a literal value */

@@ -125,3 +125,3 @@ value: string | number;

export interface BinaryNode
extends BaseNode<'BinaryExpression'>,
extends BaseNode<"BinaryExpression">,
DirectionalNode {

@@ -133,3 +133,3 @@ /** The operation to perform on the nodes */

export interface LogicalNode
extends BaseNode<'LogicalExpression'>,
extends BaseNode<"LogicalExpression">,
DirectionalNode {

@@ -140,3 +140,3 @@ /** The logical operation to perform on the nodes */

export interface UnaryNode extends BaseNode<'UnaryExpression'> {
export interface UnaryNode extends BaseNode<"UnaryExpression"> {
/** The operation to perform on the node */

@@ -149,5 +149,5 @@ operator: string;

export type ThisNode = BaseNode<'ThisExpression'>;
export type ThisNode = BaseNode<"ThisExpression">;
export interface ModelRefNode extends BaseNode<'ModelRef'> {
export interface ModelRefNode extends BaseNode<"ModelRef"> {
/** The binding that the model reference points to */

@@ -157,3 +157,3 @@ ref: string;

export interface ObjectNode extends BaseNode<'Object'> {
export interface ObjectNode extends BaseNode<"Object"> {
/** */

@@ -169,3 +169,3 @@ attributes: Array<{

export interface MemberExpressionNode extends BaseNode<'MemberExpression'> {
export interface MemberExpressionNode extends BaseNode<"MemberExpression"> {
/** The object to be introspected */

@@ -182,3 +182,3 @@ object: ExpressionNode;

export interface ConditionalExpressionNode
extends BaseNode<'ConditionalExpression'> {
extends BaseNode<"ConditionalExpression"> {
/** The test for the ternary */

@@ -194,3 +194,3 @@ test: ExpressionNode;

export interface CompoundNode extends BaseNode<'Compound'> {
export interface CompoundNode extends BaseNode<"Compound"> {
/** The contents of the compound expression */

@@ -200,3 +200,3 @@ body: ExpressionNode[];

export interface CallExpressionNode extends BaseNode<'CallExpression'> {
export interface CallExpressionNode extends BaseNode<"CallExpression"> {
/** The arguments to the function */

@@ -209,3 +209,3 @@ args: ExpressionNode[];

export interface ArrayExpressionNode extends BaseNode<'ArrayExpression'> {
export interface ArrayExpressionNode extends BaseNode<"ArrayExpression"> {
/** The items in an array */

@@ -215,3 +215,3 @@ elements: ExpressionNode[];

export interface IdentifierNode extends BaseNode<'Identifier'> {
export interface IdentifierNode extends BaseNode<"Identifier"> {
/** The variable name */

@@ -221,6 +221,6 @@ name: string;

export type AssignmentNode = BaseNode<'Assignment'> & DirectionalNode;
export type AssignmentNode = BaseNode<"Assignment"> & DirectionalNode;
export interface ModificationNode
extends BaseNode<'Modification'>,
extends BaseNode<"Modification">,
DirectionalNode {

@@ -248,3 +248,3 @@ /** The operator for the modification */

export type ExpressionNodeType = ExpressionNode['type'];
export type ExpressionNodeType = ExpressionNode["type"];

@@ -251,0 +251,0 @@ export interface ErrorWithLocation extends Error {

@@ -1,2 +0,2 @@

import { isExpressionNode } from './types';
import { isExpressionNode } from "./types";
import type {

@@ -10,7 +10,7 @@ ErrorWithLocation,

NodePosition,
} from './types';
} from "./types";
/** Generates a function by removing the first context argument */
export function withoutContext<T extends unknown[], Return>(
fn: (...args: T) => Return
fn: (...args: T) => Return,
): ExpressionHandler<T, Return> {

@@ -31,3 +31,3 @@ return (_context, ...args) => fn(...args);

node: ExpressionNode,
position: NodePosition
position: NodePosition,
): ExpressionNode | undefined {

@@ -38,6 +38,6 @@ // This is just mapping recursively over nodes in the tree

switch (node.type) {
case 'Modification':
case 'Assignment':
case 'LogicalExpression':
case 'BinaryExpression': {
case "Modification":
case "Assignment":
case "LogicalExpression":
case "BinaryExpression": {
const check =

@@ -53,3 +53,3 @@ findClosestNodeAtPosition(node.left, position) ??

case 'UnaryExpression': {
case "UnaryExpression": {
const checkArg = findClosestNodeAtPosition(node.argument, position);

@@ -63,3 +63,3 @@ if (checkArg) {

case 'MemberExpression': {
case "MemberExpression": {
const checkObject =

@@ -75,3 +75,3 @@ findClosestNodeAtPosition(node.object, position) ??

case 'ConditionalExpression': {
case "ConditionalExpression": {
const checkObject =

@@ -88,9 +88,9 @@ findClosestNodeAtPosition(node.test, position) ??

case 'ArrayExpression':
case 'Compound': {
case "ArrayExpression":
case "Compound": {
const elements =
node.type === 'ArrayExpression' ? node.elements : node.body;
node.type === "ArrayExpression" ? node.elements : node.body;
const anyElements = elements.find((e) =>
findClosestNodeAtPosition(e, position)
findClosestNodeAtPosition(e, position),
);

@@ -105,3 +105,3 @@

case 'Object': {
case "Object": {
const checkObject = node.attributes.reduce<ExpressionNode | undefined>(

@@ -115,3 +115,3 @@ (found, next) => {

},
undefined
undefined,
);

@@ -126,3 +126,3 @@

case 'CallExpression': {
case "CallExpression": {
const anyArgs =

@@ -149,3 +149,3 @@ node.args.find((arg) => {

export function isObjectExpression(
expr: ExpressionType
expr: ExpressionType,
): expr is ExpressionObjectType {

@@ -157,6 +157,6 @@ if (isExpressionNode(expr)) {

return (
typeof expr === 'object' &&
typeof expr === "object" &&
expr !== null &&
!Array.isArray(expr) &&
'value' in expr
"value" in expr
);

@@ -163,0 +163,0 @@ }

// Add the types export first so it's naming takes precedence
export * from '@player-ui/types';
export * from './binding';
export * from './data';
export * from './expressions';
export * from './logger';
export * from './schema';
export * from './string-resolver';
export * from './validator';
export * from './view';
export * from "@player-ui/types";
export * from "./binding/index";
export * from "./data/index";
export * from "./expressions/index";
export * from "./logger/index";
export * from "./schema/index";
export * from "./string-resolver/index";
export * from "./validator/index";
export * from "./view/index";
export * from './player';
export * from './controllers';
export * from './types';
export * from './plugins/flow-exp-plugin';
export * from "./player";
export * from "./controllers/index";
export * from "./types";
export * from "./plugins/flow-exp-plugin";

@@ -1,5 +0,5 @@

import type { Logger, Severity } from './types';
import { severities } from './types';
import type { Logger, Severity } from "./types";
import { severities } from "./types";
export type ConsoleHandler = Pick<typeof console, 'log' | 'warn' | 'error'>;
export type ConsoleHandler = Pick<typeof console, "log" | "warn" | "error">;

@@ -11,3 +11,3 @@ /** A Logger implementation that uses console */

constructor(severity: Severity = 'warn', _console: ConsoleHandler = console) {
constructor(severity: Severity = "warn", _console: ConsoleHandler = console) {
this.severity = severity;

@@ -45,7 +45,7 @@ this._console = _console;

public readonly trace = this.createHandler('trace');
public readonly debug = this.createHandler('debug');
public readonly info = this.createHandler('info');
public readonly warn = this.createHandler('warn');
public readonly error = this.createHandler('error');
public readonly trace = this.createHandler("trace");
public readonly debug = this.createHandler("debug");
public readonly info = this.createHandler("info");
public readonly warn = this.createHandler("warn");
public readonly error = this.createHandler("error");
}

@@ -1,5 +0,5 @@

export * from './types';
export { default as ConsoleLogger } from './consoleLogger';
export { default as NoopLogger } from './noopLogger';
export { default as TapableLogger } from './tapableLogger';
export { default as ProxyLogger } from './proxyLogger';
export * from "./types";
export { default as ConsoleLogger } from "./consoleLogger";
export { default as NoopLogger } from "./noopLogger";
export { default as TapableLogger } from "./tapableLogger";
export { default as ProxyLogger } from "./proxyLogger";

@@ -1,2 +0,2 @@

import type { Logger } from './types';
import type { Logger } from "./types";

@@ -3,0 +3,0 @@ /** An empty function so the logger ignore everything */

@@ -1,2 +0,2 @@

import type { Logger, Severity, LoggerProvider } from './types';
import type { Logger, Severity, LoggerProvider } from "./types";

@@ -20,7 +20,7 @@ /**

public readonly trace = this.createHandler('trace');
public readonly debug = this.createHandler('debug');
public readonly info = this.createHandler('info');
public readonly warn = this.createHandler('warn');
public readonly error = this.createHandler('error');
public readonly trace = this.createHandler("trace");
public readonly debug = this.createHandler("debug");
public readonly info = this.createHandler("info");
public readonly warn = this.createHandler("warn");
public readonly error = this.createHandler("error");
}

@@ -1,3 +0,3 @@

import { SyncHook } from 'tapable-ts';
import type { Logger, Severity } from './types';
import { SyncHook } from "tapable-ts";
import type { Logger, Severity } from "./types";

@@ -33,7 +33,7 @@ /** A logger that has a tapable subscriptions to callbacks */

public readonly trace = this.createHandler('trace');
public readonly debug = this.createHandler('debug');
public readonly info = this.createHandler('info');
public readonly warn = this.createHandler('warn');
public readonly error = this.createHandler('error');
public readonly trace = this.createHandler("trace");
public readonly debug = this.createHandler("debug");
public readonly info = this.createHandler("info");
public readonly warn = this.createHandler("warn");
public readonly error = this.createHandler("error");
}
export type LogFn = (...args: Array<any>) => void;
export const severities = ['trace', 'debug', 'info', 'warn', 'error'] as const;
export type Severity = typeof severities[number];
export const severities = ["trace", "debug", "info", "warn", "error"] as const;
export type Severity = (typeof severities)[number];
export type Logger = Record<Severity, LogFn>;
export type LoggerProvider = () => Logger | undefined;

@@ -1,15 +0,15 @@

import { setIn } from 'timm';
import deferred from 'p-defer';
import type { Flow as FlowType, FlowResult } from '@player-ui/types';
import { setIn } from "timm";
import deferred from "p-defer";
import type { Flow as FlowType, FlowResult } from "@player-ui/types";
import { SyncHook, SyncWaterfallHook } from 'tapable-ts';
import type { Logger } from './logger';
import { TapableLogger } from './logger';
import type { ExpressionType } from './expressions';
import { ExpressionEvaluator } from './expressions';
import { SchemaController } from './schema';
import { BindingParser } from './binding';
import type { ViewInstance } from './view';
import { resolveDataRefs } from './string-resolver';
import type { FlowInstance } from './controllers';
import { SyncHook, SyncWaterfallHook } from "tapable-ts";
import type { Logger } from "./logger";
import { TapableLogger } from "./logger";
import type { ExpressionType } from "./expressions";
import { ExpressionEvaluator } from "./expressions";
import { SchemaController } from "./schema";
import { BindingParser } from "./binding";
import type { ViewInstance } from "./view";
import { resolveDataRefs } from "./string-resolver";
import type { FlowInstance } from "./controllers";
import {

@@ -21,5 +21,5 @@ ConstantsController,

FlowController,
} from './controllers';
import { FlowExpPlugin } from './plugins/flow-exp-plugin';
import { DefaultExpPlugin } from './plugins/default-exp-plugin';
} from "./controllers";
import { FlowExpPlugin } from "./plugins/flow-exp-plugin";
import { DefaultExpPlugin } from "./plugins/default-exp-plugin";
import type {

@@ -30,8 +30,9 @@ PlayerFlowState,

ErrorState,
} from './types';
import { NOT_STARTED_STATE } from './types';
} from "./types";
import { NOT_STARTED_STATE } from "./types";
import { DefaultViewPlugin } from "./plugins/default-view-plugin";
// Variables injected at build time
const PLAYER_VERSION = '0.7.4-next.4';
const COMMIT = '498d9be0ba0bbbe6839b7d227d3900eabbd24cdd';
const PLAYER_VERSION = "__VERSION__";
const COMMIT = "__GIT_COMMIT__";

@@ -63,3 +64,3 @@ export interface PlayerPlugin {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
DataTypes = void
DataTypes = void,
> {}

@@ -142,2 +143,3 @@

new DefaultExpPlugin(),
new DefaultViewPlugin(),
...(this.config.plugins || []),

@@ -158,3 +160,3 @@ new FlowExpPlugin(),

public findPlugin<Plugin extends PlayerPlugin>(
symbol: symbol
symbol: symbol,
): Plugin | undefined {

@@ -167,3 +169,3 @@ return this.config.plugins?.find((el) => el.symbol === symbol) as Plugin;

symbol: symbol,
apply: (plugin: Plugin) => void
apply: (plugin: Plugin) => void,
): void {

@@ -217,3 +219,3 @@ const plugin = this.findPlugin<Plugin>(symbol);

/** the state object to kick if off */
state: Omit<InProgressState, 'ref'>;
state: Omit<InProgressState, "ref">;
} {

@@ -264,3 +266,3 @@ const userFlow = this.hooks.resolveFlowContent.call(userContent);

dataController.hooks.format.tap('player', (value, binding) => {
dataController.hooks.format.tap("player", (value, binding) => {
const formatter = schema.getFormatter(binding);

@@ -271,3 +273,3 @@

dataController.hooks.deformat.tap('player', (value, binding) => {
dataController.hooks.deformat.tap("player", (value, binding) => {
const formatter = schema.getFormatter(binding);

@@ -279,4 +281,4 @@

dataController.hooks.resolveDefaultValue.tap(
'player',
(binding) => schema.getApparentType(binding)?.default
"player",
(binding) => schema.getApparentType(binding)?.default,
);

@@ -294,3 +296,3 @@

expressionEvaluator.hooks.onError.tap('player', (e) => {
expressionEvaluator.hooks.onError.tap("player", (e) => {
flowResultDeferred.reject(e);

@@ -310,10 +312,10 @@

flowController.hooks.flow.tap('player', (flow: FlowInstance) => {
flow.hooks.beforeTransition.tap('player', (state, transitionVal) => {
flowController.hooks.flow.tap("player", (flow: FlowInstance) => {
flow.hooks.beforeTransition.tap("player", (state, transitionVal) => {
/** Checks to see if there are any transitions for a specific transition state (i.e. next, back). If not, it will default to * */
const computedTransitionVal = state.transitions[transitionVal]
? transitionVal
: '*';
: "*";
if (state.onEnd && state.transitions[computedTransitionVal]) {
if (typeof state.onEnd === 'object' && 'exp' in state.onEnd) {
if (typeof state.onEnd === "object" && "exp" in state.onEnd) {
expressionEvaluator?.evaluate(state.onEnd.exp);

@@ -327,3 +329,3 @@ } else {

if (
!('transitions' in state) ||
!("transitions" in state) ||
!state.transitions[computedTransitionVal]

@@ -337,11 +339,11 @@ ) {

state,
['transitions', computedTransitionVal],
resolveStrings(state.transitions[computedTransitionVal])
["transitions", computedTransitionVal],
resolveStrings(state.transitions[computedTransitionVal]),
) as any;
});
flow.hooks.skipTransition.tap('validation', (currentState) => {
if (currentState?.value.state_type === 'VIEW') {
flow.hooks.skipTransition.tap("validation", (currentState) => {
if (currentState?.value.state_type === "VIEW") {
const { canTransition, validations } =
validationController.validateView('navigation');
validationController.validateView("navigation");

@@ -359,14 +361,14 @@ if (!canTransition && validations) {

flow.hooks.resolveTransitionNode.tap('player', (state) => {
flow.hooks.resolveTransitionNode.tap("player", (state) => {
let newState = state;
if ('ref' in state) {
newState = setIn(state, ['ref'], resolveStrings(state.ref)) as any;
if ("ref" in state) {
newState = setIn(state, ["ref"], resolveStrings(state.ref)) as any;
}
if ('param' in state) {
if ("param" in state) {
newState = setIn(
state,
['param'],
resolveStrings(state.param, false)
["param"],
resolveStrings(state.param, false),
) as any;

@@ -378,4 +380,4 @@ }

flow.hooks.transition.tap('player', (_oldState, newState) => {
if (newState.value.state_type !== 'VIEW') {
flow.hooks.transition.tap("player", (_oldState, newState) => {
if (newState.value.state_type !== "VIEW") {
validationController.reset();

@@ -385,8 +387,8 @@ }

flow.hooks.afterTransition.tap('player', (flowInstance) => {
flow.hooks.afterTransition.tap("player", (flowInstance) => {
const value = flowInstance.currentState?.value;
if (value && value.state_type === 'ACTION') {
if (value && value.state_type === "ACTION") {
const { exp } = value;
flowController?.transition(
String(expressionEvaluator?.evaluate(exp))
String(expressionEvaluator?.evaluate(exp)),
);

@@ -438,3 +440,3 @@ }

});
viewController.hooks.view.tap('player', (view) => {
viewController.hooks.view.tap("player", (view) => {
validationController.onView(view);

@@ -466,3 +468,3 @@ this.hooks.view.call(view);

state: {
status: 'in-progress',
status: "in-progress",
flowResult: flowResultDeferred.promise,

@@ -486,3 +488,3 @@ controllers: {

public async start(payload: FlowType): Promise<CompletedState> {
const ref = Symbol(payload?.id ?? 'payload');
const ref = Symbol(payload?.id ?? "payload");

@@ -493,3 +495,3 @@ /** A check to avoid updating the state for a flow that's not the current one */

this.logger.warn(
`Received update for a flow that's not the current one`
`Received update for a flow that's not the current one`,
);

@@ -506,3 +508,3 @@

this.setState({
status: 'not-started',
status: "not-started",
ref,

@@ -524,3 +526,3 @@ });

ref,
status: 'completed',
status: "completed",
flow: state.flow,

@@ -538,3 +540,3 @@ controllers: {

const errorState: ErrorState = {
status: 'error',
status: "error",
ref,

@@ -541,0 +543,0 @@ flow: payload,

@@ -1,4 +0,4 @@

import type { ExpressionHandler, ExpressionType } from '../expressions';
import type { SchemaController } from '../schema';
import type { Player, PlayerPlugin } from '../player';
import type { ExpressionHandler, ExpressionType } from "../expressions";
import type { SchemaController } from "../schema";
import type { Player, PlayerPlugin } from "../player";

@@ -13,3 +13,3 @@ /** Gets formatter for given formatName and formats value if found, returns value otherwise */

value,
formatName
formatName,
) => {

@@ -28,3 +28,3 @@ return (

export class DefaultExpPlugin implements PlayerPlugin {
name = 'flow-exp-plugin';
name = "flow-exp-plugin";

@@ -40,10 +40,10 @@ apply(player: Player) {

if (formatFunction) {
expEvaluator.addExpressionFunction('format', formatFunction);
expEvaluator.addExpressionFunction("format", formatFunction);
}
expEvaluator.addExpressionFunction('log', (ctx, ...args) => {
expEvaluator.addExpressionFunction("log", (ctx, ...args) => {
player.logger.info(...args);
});
expEvaluator.addExpressionFunction('debug', (ctx, ...args) => {
expEvaluator.addExpressionFunction("debug", (ctx, ...args) => {
player.logger.debug(...args);

@@ -53,6 +53,6 @@ });

expEvaluator.addExpressionFunction(
'eval',
"eval",
(ctx, ...args: [ExpressionType]) => {
return ctx.evaluate(...args);
}
},
);

@@ -59,0 +59,0 @@ });

@@ -5,6 +5,6 @@ import type {

NavigationFlowState,
} from '@player-ui/types';
import type { ExpressionEvaluator, ExpressionType } from '../expressions';
import type { FlowInstance } from '../controllers';
import type { Player, PlayerPlugin } from '../player';
} from "@player-ui/types";
import type { ExpressionEvaluator, ExpressionType } from "../expressions";
import type { FlowInstance } from "../controllers";
import type { Player, PlayerPlugin } from "../player";

@@ -17,3 +17,3 @@ /**

export class FlowExpPlugin implements PlayerPlugin {
name = 'flow-exp-plugin';
name = "flow-exp-plugin";

@@ -30,3 +30,3 @@ apply(player: Player) {

if (exp) {
if (typeof exp === 'object' && 'exp' in exp) {
if (typeof exp === "object" && "exp" in exp) {
expressionEvaluator?.evaluate(exp.exp);

@@ -33,0 +33,0 @@ } else {

@@ -1,2 +0,2 @@

export * from './types';
export * from './schema';
export * from "./types";
export * from "./schema";

@@ -1,7 +0,7 @@

import { SyncWaterfallHook } from 'tapable-ts';
import type { Schema as SchemaType, Formatting } from '@player-ui/types';
import { SyncWaterfallHook } from "tapable-ts";
import type { Schema as SchemaType, Formatting } from "@player-ui/types";
import type { BindingInstance } from '../binding';
import type { ValidationProvider, ValidationObject } from '../validator';
import type { FormatDefinition, FormatOptions, FormatType } from './types';
import type { BindingInstance } from "../binding";
import type { ValidationProvider, ValidationObject } from "../validator";
import type { FormatDefinition, FormatOptions, FormatType } from "./types";

@@ -13,3 +13,3 @@ /** A function that returns itself */

export function parse(
schema: SchemaType.Schema
schema: SchemaType.Schema,
): Map<string, SchemaType.DataTypes> {

@@ -45,3 +45,3 @@ const expandedPaths = new Map<string, SchemaType.DataTypes>();

const nestedPathStr = nestedPath.join('.');
const nestedPathStr = nestedPath.join(".");

@@ -51,3 +51,3 @@ if (expandedPaths.has(nestedPathStr)) {

throw new Error(
"Path has already been processed. There's either a loop somewhere or a bug"
"Path has already been processed. There's either a loop somewhere or a bug",
);

@@ -58,3 +58,3 @@ }

throw new Error(
`Path already contained type: ${type.type}. This likely indicates a loop in the schema`
`Path already contained type: ${type.type}. This likely indicates a loop in the schema`,
);

@@ -66,7 +66,7 @@ }

if (type.isArray) {
nestedPath.push('[]');
nestedPath.push("[]");
}
if (type.isRecord) {
nestedPath.push('{}');
nestedPath.push("{}");
}

@@ -125,3 +125,3 @@

getValidationsForBinding(
binding: BindingInstance
binding: BindingInstance,
): Array<ValidationObject> | undefined {

@@ -136,4 +136,4 @@ const typeDef = this.getApparentType(binding);

return typeDef.validation.map((vRef) => ({
severity: 'error',
trigger: 'change',
severity: "error",
trigger: "change",
...vRef,

@@ -151,8 +151,8 @@ }));

let normalized = bindingArray
.map((p) => (typeof p === 'number' ? '[]' : p))
.join('.');
.map((p) => (typeof p === "number" ? "[]" : p))
.join(".");
if (normalized) {
this.bindingSchemaNormalizedCache.set(binding, normalized);
bindingArray = normalized.split('.');
bindingArray = normalized.split(".");
}

@@ -162,8 +162,8 @@

const recordBinding = bindingArray
.map((p) => (p === item ? '{}' : p))
.join('.');
.map((p) => (p === item ? "{}" : p))
.join(".");
if (this.schema.get(recordBinding)) {
this.bindingSchemaNormalizedCache.set(binding, recordBinding);
bindingArray = recordBinding.split('.');
bindingArray = recordBinding.split(".");
normalized = recordBinding;

@@ -179,3 +179,3 @@ }

this.schema.get(this.normalizeBinding(binding)),
binding
binding,
);

@@ -185,3 +185,3 @@ }

public getApparentType(
binding: BindingInstance
binding: BindingInstance,
): SchemaType.DataTypes | undefined {

@@ -215,3 +215,3 @@ const schemaType = this.getType(binding);

public getFormatterForType(
formatReference: Formatting.Reference
formatReference: Formatting.Reference,
): FormatDefinition<unknown, unknown> | undefined {

@@ -241,3 +241,3 @@ const { type: formatType, ...options } = formatReference;

public getFormatter(
binding: BindingInstance
binding: BindingInstance,
): FormatDefinition<unknown, unknown> | undefined {

@@ -244,0 +244,0 @@ const type = this.getApparentType(binding);

@@ -1,4 +0,4 @@

import type { Formatting } from '@player-ui/types';
import type { Formatting } from "@player-ui/types";
export type FormatOptions = Omit<Formatting.Reference, 'type'>;
export type FormatOptions = Omit<Formatting.Reference, "type">;

@@ -11,3 +11,3 @@ /**

val: From,
options?: Options
options?: Options,
) => To | undefined;

@@ -34,3 +34,3 @@

UserDisplayType = DataModelType,
Options = undefined
Options = undefined,
> {

@@ -37,0 +37,0 @@ /**

@@ -1,7 +0,7 @@

import { setIn } from 'timm';
import type { Expression } from '@player-ui/types';
import type { DataModelWithParser } from '../data';
import { setIn } from "timm";
import type { Expression } from "@player-ui/types";
import type { DataModelWithParser } from "../data";
const DOUBLE_OPEN_CURLY = '{{';
const DOUBLE_CLOSE_CURLY = '}}';
const DOUBLE_OPEN_CURLY = "{{";
const DOUBLE_CLOSE_CURLY = "}}";

@@ -55,3 +55,3 @@ export interface Options {

workingString = workingString.substring(
nextOpenCurly + DOUBLE_OPEN_CURLY.length
nextOpenCurly + DOUBLE_OPEN_CURLY.length,
);

@@ -64,3 +64,3 @@ offset += nextOpenCurly + DOUBLE_OPEN_CURLY.length;

workingString = workingString.substring(
nextCloseCurly + DOUBLE_CLOSE_CURLY.length
nextCloseCurly + DOUBLE_CLOSE_CURLY.length,
);

@@ -84,3 +84,3 @@ offset += nextCloseCurly + DOUBLE_CLOSE_CURLY.length;

val: string,
{ evaluate }: Options
{ evaluate }: Options,
): string {

@@ -100,4 +100,4 @@ if (!evaluate) {

const expString = expStrWithBrackets.substr(
'@['.length,
expStrWithBrackets.length - '@['.length - ']@'.length
"@[".length,
expStrWithBrackets.length - "@[".length - "]@".length,
);

@@ -110,3 +110,3 @@ const expValue = evaluate(expString);

expStrWithBrackets === val &&
typeof expValue !== 'string'
typeof expValue !== "string"
) {

@@ -134,3 +134,3 @@ return expValue;

!model ||
typeof workingString !== 'string' ||
typeof workingString !== "string" ||
workingString.indexOf(DOUBLE_OPEN_CURLY) === -1

@@ -154,3 +154,3 @@ ) {

start + DOUBLE_OPEN_CURLY.length,
end - DOUBLE_OPEN_CURLY.length
end - DOUBLE_OPEN_CURLY.length,
)

@@ -166,3 +166,3 @@ .trim();

end === workingString.length &&
typeof evaledVal !== 'string'
typeof evaledVal !== "string"
) {

@@ -182,7 +182,7 @@ return evaledVal;

switch (typeof val) {
case 'string': {
case "string": {
return resolveDataRefsInString(val as string, options) as unknown as T;
}
case 'object': {
case "object": {
if (!val) return val;

@@ -198,3 +198,3 @@ // TODO: Do we care refs in keys?

[key],
traverseObject((val as any)[key], options)
traverseObject((val as any)[key], options),
) as any;

@@ -201,0 +201,0 @@ });

@@ -1,6 +0,6 @@

import type { Flow, FlowResult } from '@player-ui/types';
import type { BindingParser, BindingLike } from './binding';
import type { SchemaController } from './schema';
import type { ExpressionEvaluator } from './expressions';
import type { Logger } from './logger';
import type { Flow, FlowResult } from "@player-ui/types";
import type { BindingParser, BindingLike } from "./binding";
import type { SchemaController } from "./schema";
import type { ExpressionEvaluator } from "./expressions";
import type { Logger } from "./logger";
import type {

@@ -11,11 +11,11 @@ ViewController,

FlowController,
} from './controllers';
import type { ReadOnlyDataController } from './controllers/data/utils';
} from "./controllers";
import type { ReadOnlyDataController } from "./controllers/data/utils";
/** The status for a flow's execution state */
export type PlayerFlowStatus =
| 'not-started'
| 'in-progress'
| 'completed'
| 'error';
| "not-started"
| "in-progress"
| "completed"
| "error";

@@ -32,7 +32,7 @@ /** Common interface for the state of Player's flow execution */

/** The beginning state of Player, before it's seen a flow */
export type NotStartedState = BaseFlowState<'not-started'>;
export type NotStartedState = BaseFlowState<"not-started">;
export const NOT_STARTED_STATE: NotStartedState = {
ref: Symbol('not-started'),
status: 'not-started',
ref: Symbol("not-started"),
status: "not-started",
};

@@ -70,3 +70,3 @@

/** A flow is currently executing */
export type InProgressState = BaseFlowState<'in-progress'> &
export type InProgressState = BaseFlowState<"in-progress"> &
PlayerFlowExecutionData & {

@@ -89,3 +89,3 @@ /** A promise that resolves when the flow is completed */

/** The flow completed properly */
export type CompletedState = BaseFlowState<'completed'> &
export type CompletedState = BaseFlowState<"completed"> &
PlayerFlowExecutionData &

@@ -101,3 +101,3 @@ FlowResult & {

/** The flow finished but not successfully */
export type ErrorState = BaseFlowState<'error'> & {
export type ErrorState = BaseFlowState<"error"> & {
/** The currently executing flow */

@@ -104,0 +104,0 @@ flow: Flow;

@@ -1,1 +0,1 @@

export * from './replaceParams';
export * from "./replaceParams";

@@ -12,3 +12,3 @@ const ANY_CHAR_REGEX = /%([a-zA-Z]+)/g;

message: string,
params: Record<string, any>
params: Record<string, any>,
): string {

@@ -15,0 +15,0 @@ return message

@@ -1,2 +0,2 @@

import type { BindingInstance } from '../binding';
import type { BindingInstance } from "../binding";

@@ -12,3 +12,3 @@ /**

sourceMap: Map<BindingInstance, T>,
binding: BindingInstance
binding: BindingInstance,
): Map<BindingInstance, T> {

@@ -28,3 +28,3 @@ const targetMap = new Map(sourceMap);

if (typeof property === 'number') {
if (typeof property === "number") {
// Splice out this index from the rest

@@ -38,3 +38,3 @@

const [childIndex] = b.relative(parentBinding);
return typeof childIndex === 'number' && childIndex > property;
return typeof childIndex === "number" && childIndex > property;
}

@@ -52,3 +52,3 @@

if (typeof childIndex === 'number') {
if (typeof childIndex === "number") {
const newSegments = [childIndex - 1, ...childPath];

@@ -55,0 +55,0 @@ const newChildBinding = parentBinding.descendent(newSegments);

@@ -1,4 +0,4 @@

export * from './validation-middleware';
export * from './types';
export * from './registry';
export * from './binding-map-splice';
export * from "./validation-middleware";
export * from "./types";
export * from "./registry";
export * from "./binding-map-splice";

@@ -1,2 +0,2 @@

import type { ValidatorFunction } from './types';
import type { ValidatorFunction } from "./types";

@@ -3,0 +3,0 @@ /** A registry that tracks validators */

@@ -1,8 +0,8 @@

import type { Schema, Validation } from '@player-ui/types';
import type { Schema, Validation } from "@player-ui/types";
import type { BindingInstance, BindingFactory } from '../binding';
import type { DataModelWithParser } from '../data';
import type { ExpressionEvaluatorFunction } from '../expressions';
import type { Logger } from '../logger';
import type { ConstantsProvider } from '../controllers';
import type { BindingInstance, BindingFactory } from "../binding";
import type { DataModelWithParser } from "../data";
import type { ExpressionEvaluatorFunction } from "../expressions";
import type { Logger } from "../logger";
import type { ConstantsProvider } from "../controllers";

@@ -23,7 +23,7 @@ interface BaseValidationResponse<T = Validation.Severity> {

/** The blocking state of this validation */
blocking?: boolean | 'once';
blocking?: boolean | "once";
}
export interface WarningValidationResponse
extends BaseValidationResponse<'warning'> {
extends BaseValidationResponse<"warning"> {
/** Warning validations can be dismissed without correcting the error */

@@ -33,3 +33,3 @@ dismiss?: () => void;

export type ErrorValidationResponse = BaseValidationResponse<'error'>;
export type ErrorValidationResponse = BaseValidationResponse<"error">;

@@ -40,3 +40,3 @@ export type ValidationResponse =

type RequiredValidationKeys = 'severity' | 'trigger';
type RequiredValidationKeys = "severity" | "trigger";

@@ -53,3 +53,3 @@ export type ValidationObject = Validation.Reference &

getValidationsForBinding?(
binding: BindingInstance
binding: BindingInstance,
): Array<ValidationObjectWithHandler> | undefined;

@@ -86,3 +86,3 @@

value: any,
options?: Options
) => Omit<BaseValidationResponse, 'severity'> | undefined;
options?: Options,
) => Omit<BaseValidationResponse, "severity"> | undefined;

@@ -1,3 +0,3 @@

import { setIn } from 'timm';
import type { BindingInstance } from '../binding';
import { setIn } from "timm";
import type { BindingInstance } from "../binding";
import type {

@@ -9,8 +9,8 @@ BatchSetTransaction,

Updates,
} from '../data';
import { toModel } from '../data';
import type { Logger } from '../logger';
} from "../data";
import { toModel } from "../data";
import type { Logger } from "../logger";
import type { ValidationResponse } from './types';
import { removeBindingAndChildrenFromMap } from './binding-map-splice';
import type { ValidationResponse } from "./types";
import { removeBindingAndChildrenFromMap } from "./binding-map-splice";

@@ -32,3 +32,3 @@ /**

binding: BindingInstance,
model: DataModelImpl
model: DataModelImpl,
) => ValidationResponse | Set<StrongOrWeakBinding> | undefined;

@@ -52,3 +52,3 @@

shouldIncludeInvalid?: (options?: DataModelOptions) => boolean;
}
},
) {

@@ -64,3 +64,3 @@ this.validator = validator;

options?: DataModelOptions,
next?: DataModelImpl
next?: DataModelImpl,
): Updates {

@@ -99,3 +99,3 @@ const asModel = toModel(this, { ...options, includeInvalid: true }, next);

validations.severity
} - ${validations.message}`
} - ${validations.message}`,
);

@@ -110,3 +110,3 @@ }

nextTransaction.forEach(([binding]) =>
this.shadowModelPaths.delete(binding)
this.shadowModelPaths.delete(binding),
);

@@ -136,3 +136,3 @@ const result = next.set(nextTransaction, options);

options?: DataModelOptions,
next?: DataModelImpl
next?: DataModelImpl,
) {

@@ -164,7 +164,7 @@ let val = next?.get(binding, options);

options?: DataModelOptions,
next?: DataModelImpl
next?: DataModelImpl,
) {
this.shadowModelPaths = removeBindingAndChildrenFromMap(
this.shadowModelPaths,
binding
binding,
);

@@ -171,0 +171,0 @@

@@ -1,3 +0,3 @@

import type { Node, AnyAssetType } from '../parser';
import { NodeType } from '../parser';
import type { Node, AnyAssetType } from "../parser";
import { NodeType } from "../parser";

@@ -65,3 +65,3 @@ /**

path: Node.PathSegment | Node.PathSegment[],
child: Node.Node
child: Node.Node,
) {

@@ -68,0 +68,0 @@ // eslint-disable-next-line no-param-reassign

@@ -1,5 +0,5 @@

export * from './view';
export * from './resolver';
export * from './parser';
export * from './builder';
export * from './plugins';
export * from "./view";
export * from "./resolver";
export * from "./parser";
export * from "./builder";
export * from "./plugins";

@@ -1,10 +0,10 @@

import { omit, setIn } from 'timm';
import { SyncBailHook, SyncWaterfallHook } from 'tapable-ts';
import type { Template } from '@player-ui/types';
import type { AnyAssetType, Node } from './types';
import { NodeType } from './types';
import { getNodeID, hasAsync } from './utils';
import { omit, setIn } from "timm";
import { SyncBailHook, SyncWaterfallHook } from "tapable-ts";
import type { Template } from "@player-ui/types";
import type { AnyAssetType, Node } from "./types";
import { NodeType } from "./types";
import { getNodeID, hasAsync } from "./utils";
export * from './types';
export * from './utils';
export * from "./types";
export * from "./utils";

@@ -62,3 +62,3 @@ export const EMPTY_NODE: Node.Empty = {

parseOptions: ParseObjectOptions,
determinedNodeType: NodeType | null
determinedNodeType: NodeType | null,
],

@@ -73,3 +73,3 @@ Node.Node

if (!viewNode) {
throw new Error('Unable to parse object into a view');
throw new Error("Unable to parse object into a view");
}

@@ -83,5 +83,5 @@

type: Node.ChildrenTypes,
options: ParseObjectOptions
options: ParseObjectOptions,
): Node.Node | null {
const parsedAsync = this.parseObject(omit(obj, 'async'), type, options);
const parsedAsync = this.parseObject(omit(obj, "async"), type, options);
const parsedNodeId = getNodeID(parsedAsync);

@@ -95,3 +95,3 @@ if (parsedAsync !== null && parsedNodeId) {

},
obj
obj,
);

@@ -121,3 +121,3 @@ }

return (
Object.hasOwnProperty.call(obj, 'template') &&
Object.hasOwnProperty.call(obj, "template") &&
Array.isArray(obj?.template) &&

@@ -130,3 +130,3 @@ obj.template.length &&

private hasSwitchKey(localKey: string) {
return localKey === ('staticSwitch' || 'dynamicSwitch');
return localKey === ("staticSwitch" || "dynamicSwitch");
}

@@ -137,3 +137,3 @@

type: Node.ChildrenTypes = NodeType.Value,
options: ParseObjectOptions = { templateDepth: 0 }
options: ParseObjectOptions = { templateDepth: 0 },
): Node.Node | null {

@@ -147,3 +147,3 @@ const nodeType = this.hooks.determineNodeType.call(obj);

options,
nodeType
nodeType,
);

@@ -155,8 +155,11 @@ if (parsedNode) {

/**
*
*/
const parseLocalObject = (
currentValue: any,
objToParse: unknown,
path: string[] = []
path: string[] = [],
): NestedObj => {
if (typeof objToParse !== 'object' || objToParse === null) {
if (typeof objToParse !== "object" || objToParse === null) {
return { value: objToParse, children: [] };

@@ -189,8 +192,7 @@ }

const [localKey, localValue] = current;
if (localKey === 'asset' && typeof localValue === 'object') {
if (localKey === "asset" && typeof localValue === "object") {
const assetAST = this.parseObject(
localValue,
NodeType.Asset,
options
options,
);

@@ -204,3 +206,3 @@

{
path: [...path, 'asset'],
path: [...path, "asset"],
value: assetAST,

@@ -225,3 +227,3 @@ },

},
template
template,
);

@@ -264,3 +266,3 @@

options,
NodeType.Switch
NodeType.Switch,
);

@@ -304,3 +306,3 @@

NodeType.Value,
options
options,
);

@@ -316,3 +318,3 @@ if (localAsync) {

.map((childVal) =>
this.parseObject(childVal, NodeType.Value, options)
this.parseObject(childVal, NodeType.Value, options),
)

@@ -328,3 +330,3 @@ .filter((child): child is Node.Node => !!child);

},
localValue
localValue,
);

@@ -351,3 +353,3 @@

}
} else if (localValue && typeof localValue === 'object') {
} else if (localValue && typeof localValue === "object") {
const determineNodeType =

@@ -361,3 +363,3 @@ this.hooks.determineNodeType.call(localValue);

options,
determineNodeType
determineNodeType,
);

@@ -390,3 +392,3 @@ if (parsedNode) {

[...path, localKey],
localValue
localValue,
);

@@ -393,0 +395,0 @@

@@ -1,15 +0,15 @@

import type { Asset as AssetType, Expression, Binding } from '@player-ui/types';
import type { Asset as AssetType, Expression, Binding } from "@player-ui/types";
export type AnyAssetType = AssetType<string>;
export enum NodeType {
Asset = 'asset',
View = 'view',
Applicability = 'applicability',
Template = 'template',
Value = 'value',
MultiNode = 'multi-node',
Switch = 'switch',
Async = 'async',
Unknown = 'unknown',
Empty = 'empty',
Asset = "asset",
View = "view",
Applicability = "applicability",
Template = "template",
Value = "value",
MultiNode = "multi-node",
Switch = "switch",
Async = "async",
Unknown = "unknown",
Empty = "empty",
}

@@ -16,0 +16,0 @@ export declare namespace Node {

@@ -1,6 +0,6 @@

import type { Node } from './types';
import type { Node } from "./types";
/** Check to see if the object contains async */
export function hasAsync(obj: object): boolean {
return Object.prototype.hasOwnProperty.call(obj, 'async');
return Object.prototype.hasOwnProperty.call(obj, "async");
}

@@ -15,5 +15,5 @@

if (
'value' in node &&
typeof node.value === 'object' &&
typeof node.value?.id === 'string'
"value" in node &&
typeof node.value === "object" &&
typeof node.value?.id === "string"
) {

@@ -20,0 +20,0 @@ return node.value.id;

@@ -1,7 +0,7 @@

import { omit } from 'timm';
import type { ViewPlugin, View } from './plugin';
import type { Options } from './options';
import type { Resolver } from '../resolver';
import type { Node, ParseObjectOptions, Parser } from '../parser';
import { NodeType } from '../parser';
import { omit } from "timm";
import type { Options } from "./options";
import type { Resolver } from "../resolver";
import type { Node, ParseObjectOptions, Parser } from "../parser";
import { NodeType } from "../parser";
import { ViewInstance, ViewPlugin } from "../view";

@@ -12,3 +12,3 @@ /** A view plugin to remove inapplicable assets from the tree */

resolver.hooks.beforeResolve.tap(
'applicability',
"applicability",
(node: Node.Node | null, options: Options) => {

@@ -28,3 +28,3 @@ let newNode = node;

return newNode;
}
},
);

@@ -35,4 +35,4 @@ }

/** Switches resolved during the parsing phase are static */
parser.hooks.determineNodeType.tap('applicability', (obj: any) => {
if (Object.prototype.hasOwnProperty.call(obj, 'applicability')) {
parser.hooks.determineNodeType.tap("applicability", (obj: any) => {
if (Object.prototype.hasOwnProperty.call(obj, "applicability")) {
return NodeType.Applicability;

@@ -43,3 +43,3 @@ }

parser.hooks.parseNode.tap(
'applicability',
"applicability",
(

@@ -49,9 +49,9 @@ obj: any,

options: ParseObjectOptions,
determinedNodeType: null | NodeType
determinedNodeType: null | NodeType,
) => {
if (determinedNodeType === NodeType.Applicability) {
const parsedApplicability = parser.parseObject(
omit(obj, 'applicability'),
omit(obj, "applicability"),
nodeType,
options
options,
);

@@ -65,3 +65,3 @@ if (parsedApplicability !== null) {

},
obj
obj,
);

@@ -76,10 +76,10 @@

}
}
},
);
}
apply(view: View) {
view.hooks.resolver.tap('applicability', this.applyResolver.bind(this));
view.hooks.parser.tap('applicability', this.applyParser.bind(this));
apply(view: ViewInstance) {
view.hooks.resolver.tap("applicability", this.applyResolver.bind(this));
view.hooks.parser.tap("applicability", this.applyParser.bind(this));
}
}

@@ -1,5 +0,4 @@

export { default as TemplatePlugin } from './template-plugin';
export { default as StringResolverPlugin } from './string-resolver';
export { default as ApplicabilityPlugin } from './applicability';
export { default as SwitchPlugin } from './switch';
export type { ViewPlugin } from './plugin';
export { default as TemplatePlugin } from "./template-plugin";
export { default as StringResolverPlugin } from "./string-resolver";
export { default as ApplicabilityPlugin } from "./applicability";
export { default as SwitchPlugin } from "./switch";

@@ -1,4 +0,4 @@

import type { Resolve } from '../resolver';
import type { Resolve } from "../resolver";
/** Config options that are required to resolve/update a view */
export type Options = Resolve.NodeResolveOptions;

@@ -1,8 +0,8 @@

import { set } from 'timm';
import { resolveDataRefs } from '../../string-resolver';
import type { Options } from './options';
import type { View, ViewPlugin } from './plugin';
import type { Node } from '../parser';
import { NodeType } from '../parser';
import type { Resolver } from '../resolver';
import { set } from "timm";
import { resolveDataRefs } from "../../string-resolver";
import type { Options } from "./options";
import type { Node } from "../parser";
import { NodeType } from "../parser";
import type { Resolver } from "../resolver";
import { ViewInstance, ViewPlugin } from "../view";

@@ -28,4 +28,4 @@ /** Create a function that checks for a start/end sequence in a string */

const bindingResolveLookup = createPatternMatcher('{{', '}}');
const expressionResolveLookup = createPatternMatcher('@[', ']@');
const bindingResolveLookup = createPatternMatcher("{{", "}}");
const expressionResolveLookup = createPatternMatcher("@[", "]@");

@@ -51,3 +51,3 @@ /** Check to see if a string contains a reference to dynamic content */

resolveOptions: Options,
propertiesToSkip: Set<string | number>
propertiesToSkip: Set<string | number>,
): any {

@@ -57,3 +57,3 @@ if (

node === undefined ||
(typeof node !== 'object' && typeof node !== 'string')
(typeof node !== "object" && typeof node !== "string")
) {

@@ -63,3 +63,3 @@ return node;

if (typeof node === 'string') {
if (typeof node === "string") {
return resolveString(node, resolveOptions);

@@ -79,5 +79,5 @@ }

if (typeof val === 'object') {
if (typeof val === "object") {
newVal = resolveAllRefs(val, resolveOptions, propertiesToSkip);
} else if (typeof val === 'string') {
} else if (typeof val === "string") {
newVal = resolveString(val, resolveOptions);

@@ -97,3 +97,3 @@ }

node: Node.Node,
resolver: Resolver
resolver: Resolver,
): Node.PathSegment[] => {

@@ -105,3 +105,3 @@ const parentNode = node.parent;

if ('children' in parentNode) {
if ("children" in parentNode) {
const original = resolver.getSourceNode(node);

@@ -129,3 +129,3 @@ return (

applyResolver(resolver: Resolver) {
resolver.hooks.resolve.tap('string-resolver', (value, node, options) => {
resolver.hooks.resolve.tap("string-resolver", (value, node, options) => {
if (node.type === NodeType.Empty || node.type === NodeType.Unknown) {

@@ -144,3 +144,3 @@ return null;

propsToSkip = new Set(
node.plugins?.stringResolver?.propertiesToSkip ?? ['exp']
node.plugins?.stringResolver?.propertiesToSkip ?? ["exp"],
);

@@ -158,6 +158,6 @@ if (node.value?.id) {

propsToSkip = this.propertiesToSkipCache.get(
node.parent.parent.value.id
node.parent.parent.value.id,
) as Set<string>;
} else {
propsToSkip = new Set(['exp']);
propsToSkip = new Set(["exp"]);
}

@@ -182,5 +182,5 @@

apply(view: View) {
view.hooks.resolver.tap('string-resolver', this.applyResolver.bind(this));
apply(view: ViewInstance) {
view.hooks.resolver.tap("string-resolver", this.applyResolver.bind(this));
}
}

@@ -1,6 +0,6 @@

import type { View, ViewPlugin } from './plugin';
import type { Options } from './options';
import type { Parser, Node, ParseObjectOptions } from '../parser';
import { EMPTY_NODE, NodeType } from '../parser';
import type { Resolver } from '../resolver';
import type { Options } from "./options";
import type { Parser, Node, ParseObjectOptions } from "../parser";
import { EMPTY_NODE, NodeType } from "../parser";
import type { Resolver } from "../resolver";
import { ViewInstance, ViewPlugin } from "../view";

@@ -28,3 +28,3 @@ /** A view plugin to resolve switches */

/** Switches resolved during the parsing phase are static */
parser.hooks.onCreateASTNode.tap('switch', (node) => {
parser.hooks.onCreateASTNode.tap("switch", (node) => {
if (node && node.type === NodeType.Switch && !node.dynamic) {

@@ -37,6 +37,6 @@ return this.resolveSwitch(node, this.options);

parser.hooks.determineNodeType.tap('switch', (obj) => {
parser.hooks.determineNodeType.tap("switch", (obj) => {
if (
Object.prototype.hasOwnProperty.call(obj, 'dynamicSwitch') ||
Object.prototype.hasOwnProperty.call(obj, 'staticSwitch')
Object.prototype.hasOwnProperty.call(obj, "dynamicSwitch") ||
Object.prototype.hasOwnProperty.call(obj, "staticSwitch")
) {

@@ -48,13 +48,13 @@ return NodeType.Switch;

parser.hooks.parseNode.tap(
'switch',
"switch",
(
obj: any,
nodeType: Node.ChildrenTypes,
_nodeType: Node.ChildrenTypes,
options: ParseObjectOptions,
determinedNodeType: null | NodeType
determinedNodeType: null | NodeType,
) => {
if (determinedNodeType === NodeType.Switch) {
const dynamic = 'dynamicSwitch' in obj;
const dynamic = "dynamicSwitch" in obj;
const switchContent =
'dynamicSwitch' in obj ? obj.dynamicSwitch : obj.staticSwitch;
"dynamicSwitch" in obj ? obj.dynamicSwitch : obj.staticSwitch;

@@ -75,3 +75,3 @@ const cases: Node.SwitchCase[] = [];

NodeType.Value,
options
options,
);

@@ -85,3 +85,3 @@

}
}
},
);

@@ -95,3 +95,3 @@

},
obj
obj,
);

@@ -112,3 +112,3 @@

}
}
},
);

@@ -119,3 +119,3 @@ }

/** Switches resolved during the parsing phase are dynamic */
resolver.hooks.beforeResolve.tap('switch', (node, options) => {
resolver.hooks.beforeResolve.tap("switch", (node, options) => {
if (node && node.type === NodeType.Switch && node.dynamic) {

@@ -129,6 +129,6 @@ return this.resolveSwitch(node, options);

apply(view: View) {
view.hooks.parser.tap('switch', this.applyParser.bind(this));
view.hooks.resolver.tap('switch', this.applyResolver.bind(this));
apply(view: ViewInstance) {
view.hooks.parser.tap("switch", this.applyParser.bind(this));
view.hooks.resolver.tap("switch", this.applyResolver.bind(this));
}
}

@@ -1,8 +0,7 @@

import { SyncWaterfallHook } from 'tapable-ts';
import type { Node, ParseObjectOptions, Parser } from '../parser';
import { NodeType } from '../parser';
import type { ViewPlugin } from '.';
import type { View } from './plugin';
import type { Options } from './options';
import type { Resolver } from '../resolver';
import { SyncWaterfallHook } from "tapable-ts";
import type { Node, ParseObjectOptions, Parser } from "../parser";
import { NodeType } from "../parser";
import type { Options } from "./options";
import type { Resolver } from "../resolver";
import { ViewInstance, ViewPlugin } from "../view";

@@ -27,3 +26,3 @@ export interface TemplateItemInfo {

baseSubstitutions: TemplateSubstitution[],
templateItemInfo: TemplateItemInfo
templateItemInfo: TemplateItemInfo,
) => TemplateSubstitution[];

@@ -48,3 +47,3 @@

node: Node.Template,
options: Options
options: Options,
): Node.Node | null {

@@ -69,3 +68,3 @@ const { template, depth } = node;

{
expression: new RegExp(`_index${depth || ''}_`),
expression: new RegExp(`_index${depth || ""}_`),
value: String(index),

@@ -78,3 +77,3 @@ },

index,
}
},
);

@@ -84,5 +83,5 @@ let templateStr = JSON.stringify(template);

for (const { expression, value } of templateSubstitutions) {
let flags = 'g';
if (typeof expression === 'object') {
flags = `${expression.flags}${expression.global ? '' : 'g'}`;
let flags = "g";
if (typeof expression === "object") {
flags = `${expression.flags}${expression.global ? "" : "g"}`;
}

@@ -112,3 +111,3 @@

applyParser(parser: Parser) {
parser.hooks.onCreateASTNode.tap('template', (node) => {
parser.hooks.onCreateASTNode.tap("template", (node) => {
if (node && node.type === NodeType.Template && !node.dynamic) {

@@ -118,3 +117,3 @@ return this.parseTemplate(

node,
this.options
this.options,
);

@@ -126,4 +125,4 @@ }

parser.hooks.determineNodeType.tap('template', (obj: any) => {
if (obj === 'template') {
parser.hooks.determineNodeType.tap("template", (obj: any) => {
if (obj === "template") {
return NodeType.Template;

@@ -134,8 +133,8 @@ }

parser.hooks.parseNode.tap(
'template',
"template",
(
obj: any,
nodeType: Node.ChildrenTypes,
_nodeType: Node.ChildrenTypes,
options: ParseObjectOptions,
determinedNodeType: null | NodeType
determinedNodeType: null | NodeType,
) => {

@@ -151,3 +150,3 @@ if (determinedNodeType === NodeType.Template) {

},
obj
obj,
);

@@ -159,3 +158,3 @@

}
}
},
);

@@ -165,3 +164,3 @@ }

applyResolverHooks(resolver: Resolver) {
resolver.hooks.beforeResolve.tap('template', (node, options) => {
resolver.hooks.beforeResolve.tap("template", (node, options) => {
if (node && node.type === NodeType.Template && node.dynamic) {

@@ -175,6 +174,6 @@ return this.parseTemplate(options.parseNode, node, options);

apply(view: View) {
view.hooks.parser.tap('template', this.applyParser.bind(this));
view.hooks.resolver.tap('template', this.applyResolverHooks.bind(this));
apply(view: ViewInstance) {
view.hooks.parser.tap("template", this.applyParser.bind(this));
view.hooks.resolver.tap("template", this.applyResolverHooks.bind(this));
}
}

@@ -1,6 +0,6 @@

import { SyncWaterfallHook, SyncHook } from 'tapable-ts';
import { setIn, addLast, clone } from 'timm';
import dlv from 'dlv';
import { dequal } from 'dequal';
import type { BindingInstance, BindingLike } from '../../binding';
import { SyncWaterfallHook, SyncHook } from "tapable-ts";
import { setIn, addLast, clone } from "timm";
import dlv from "dlv";
import { dequal } from "dequal";
import type { BindingInstance, BindingLike } from "../../binding";
import type {

@@ -10,7 +10,7 @@ DataModelOptions,

Updates,
} from '../../data';
import { DependencyModel, withParser } from '../../data';
import type { Logger } from '../../logger';
import type { Node } from '../parser';
import { NodeType } from '../parser';
} from "../../data";
import { DependencyModel, withParser } from "../../data";
import type { Logger } from "../../logger";
import type { Node } from "../parser";
import { NodeType } from "../parser";
import {

@@ -20,8 +20,8 @@ caresAboutDataChanges,

unpackAndPush,
} from './utils';
import type { Resolve } from './types';
import { getNodeID } from '../parser/utils';
} from "./utils";
import type { Resolve } from "./types";
import { getNodeID } from "../parser/utils";
export * from './types';
export * from './utils';
export * from "./types";
export * from "./utils";

@@ -45,3 +45,3 @@ interface NodeUpdate extends Resolve.ResolvedNode {

transaction: [BindingLike, any][],
options?: DataModelOptions
options?: DataModelOptions,
): Updates => {

@@ -169,3 +169,3 @@ return model.set(transaction, {

undefined,
prevASTMap
prevASTMap,
);

@@ -197,7 +197,7 @@ this.resolveCache = resolveCache;

this.logger?.error(
`Cache conflict: Found Asset/View nodes that have conflicting ids: ${id}, may cause cache issues.`
`Cache conflict: Found Asset/View nodes that have conflicting ids: ${id}, may cause cache issues.`,
);
} else if (node.type === NodeType.Value) {
this.logger?.info(
`Cache conflict: Found Value nodes that have conflicting ids: ${id}, may cause cache issues. To improve performance make value node IDs globally unique.`
`Cache conflict: Found Value nodes that have conflicting ids: ${id}, may cause cache issues. To improve performance make value node IDs globally unique.`,
);

@@ -221,6 +221,6 @@ }

Object.keys(clonedNode).forEach((key) => {
if (key === 'parent') return;
if (key === "parent") return;
const value = clonedNode[key];
if (typeof value === 'object' && value !== null) {
if (typeof value === "object" && value !== null) {
clonedNode[key] = Array.isArray(value) ? [...value] : { ...value };

@@ -240,9 +240,9 @@ }

partiallyResolvedParent: Node.Node | undefined,
prevASTMap: Map<Node.Node, Node.Node>
prevASTMap: Map<Node.Node, Node.Node>,
): NodeUpdate {
const dependencyModel = new DependencyModel(options.data.model);
dependencyModel.trackSubset('core');
dependencyModel.trackSubset("core");
const depModelWithParser = withContext(
withParser(dependencyModel, this.options.parseBinding)
withParser(dependencyModel, this.options.parseBinding),
);

@@ -261,3 +261,3 @@

},
node
node,
);

@@ -272,3 +272,3 @@

node,
resolveOptions
resolveOptions,
);

@@ -284,3 +284,3 @@

clonedNode,
resolveOptions
resolveOptions,
) ?? {

@@ -305,3 +305,3 @@ type: NodeType.Empty,

AST: Node.Node,
ASTParent: Node.Node | undefined
ASTParent: Node.Node | undefined,
) => {

@@ -326,9 +326,9 @@ const { node: resolvedASTLocal } = resolvedNode;

originalChildNode,
AST
AST,
);
};
if ('children' in resolvedASTLocal) {
if ("children" in resolvedASTLocal) {
resolvedASTLocal.children?.forEach(({ value: childAST }) =>
handleChildNode(childAST)
handleChildNode(childAST),
);

@@ -359,3 +359,3 @@ } else if (resolvedASTLocal.type === NodeType.MultiNode) {

resolvedAST,
resolveOptions
resolveOptions,
);

@@ -370,5 +370,5 @@

const childDependencies = new Set<BindingInstance>();
dependencyModel.trackSubset('children');
dependencyModel.trackSubset("children");
if ('children' in resolvedAST) {
if ("children" in resolvedAST) {
const newChildren = resolvedAST.children?.map((child) => {

@@ -382,3 +382,3 @@ const computedChildTree = this.computeTree(

resolvedAST,
prevASTMap
prevASTMap,
);

@@ -398,3 +398,3 @@ const {

dlv(resolved, child.path as any[], []),
childValue
childValue,
);

@@ -427,3 +427,3 @@ resolved = setIn(resolved, child.path, arr);

resolvedAST,
prevASTMap
prevASTMap,
);

@@ -445,3 +445,3 @@

mTree.dependencies.forEach((bindingDep) =>
childDependencies.add(bindingDep)
childDependencies.add(bindingDep),
);

@@ -459,6 +459,6 @@

childDependencies.forEach((bindingDep) =>
dependencyModel.addChildReadDep(bindingDep)
dependencyModel.addChildReadDep(bindingDep),
);
dependencyModel.trackSubset('core');
dependencyModel.trackSubset("core");
if (previousResult && !updated) {

@@ -470,3 +470,3 @@ resolved = previousResult?.value;

...resolveOptions,
getDependencies: (scope?: 'core' | 'children') =>
getDependencies: (scope?: "core" | "children") =>
dependencyModel.getDependencies(scope),

@@ -488,3 +488,3 @@ });

isNestedMultiNode ? partiallyResolvedParent?.parent : rawParent,
update
update,
);

@@ -491,0 +491,0 @@ cacheUpdate.set(node, update);

@@ -5,3 +5,3 @@ import type {

Validation as ValidationTypes,
} from '@player-ui/types';
} from "@player-ui/types";
import type {

@@ -11,3 +11,3 @@ BindingInstance,

BindingFactory,
} from '../../binding';
} from "../../binding";
import type {

@@ -17,10 +17,10 @@ DataModelWithParser,

DataModelOptions,
} from '../../data';
import type { ConstantsProvider } from '../../controllers/constants';
import type { TransitionFunction } from '../../controllers';
import type { ExpressionEvaluator, ExpressionType } from '../../expressions';
import type { ValidationResponse } from '../../validator';
import type { Logger } from '../../logger';
import type { SchemaController } from '../../schema';
import type { Node } from '../parser';
} from "../../data";
import type { ConstantsProvider } from "../../controllers/constants";
import type { TransitionFunction } from "../../controllers";
import type { ExpressionEvaluator, ExpressionType } from "../../expressions";
import type { ValidationResponse } from "../../validator";
import type { Logger } from "../../logger";
import type { SchemaController } from "../../schema";
import type { Node } from "../parser";

@@ -39,2 +39,3 @@ export interface ValidationGetResolveOptions {

// eslint-disable-next-line @typescript-eslint/no-namespace
export declare namespace Resolve {

@@ -47,3 +48,3 @@ export interface Validation {

getAll(
options?: ValidationGetResolveOptions
options?: ValidationGetResolveOptions,
): Map<BindingInstance, ValidationResponse> | undefined;

@@ -56,3 +57,3 @@

get: (
options?: ValidationGetResolveOptions
options?: ValidationGetResolveOptions,
) => ValidationResponse | undefined;

@@ -62,3 +63,3 @@

getAll: (
options?: ValidationGetResolveOptions
options?: ValidationGetResolveOptions,
) => Array<ValidationResponse>;

@@ -74,3 +75,3 @@ }

track?: boolean;
} & ValidationGetResolveOptions
} & ValidationGetResolveOptions,
): ValidationResponse | undefined;

@@ -83,3 +84,3 @@

track?: boolean;
} & ValidationGetResolveOptions
} & ValidationGetResolveOptions,
): Array<ValidationResponse>;

@@ -89,3 +90,3 @@

getChildren(
type?: ValidationTypes.DisplayTarget
type?: ValidationTypes.DisplayTarget,
): Array<ValidationResponse>;

@@ -102,3 +103,3 @@

/** While type of Display Target group it should register as */
type: Exclude<ValidationTypes.DisplayTarget, 'field'>;
type: Exclude<ValidationTypes.DisplayTarget, "field">;
}) => void;

@@ -155,3 +156,3 @@ }

/** The data dependencies that were requested during the resolution */
getDependencies?(scope?: 'core' | 'children'): Set<BindingInstance>;
getDependencies?(scope?: "core" | "children"): Set<BindingInstance>;

@@ -195,3 +196,3 @@ /** original node */

node: Node.Node,
options: NodeResolveOptions
options: NodeResolveOptions,
) => Node.Node | null;

@@ -202,3 +203,3 @@

node: Node.Node,
options: NodeResolveOptions
options: NodeResolveOptions,
) => any;

@@ -205,0 +206,0 @@

@@ -1,5 +0,5 @@

import type { BindingInstance, BindingLike } from '../../binding';
import { isBinding } from '../../binding';
import type { ExpressionType } from '../../expressions';
import type { Resolve } from './types';
import type { BindingInstance, BindingLike } from "../../binding";
import { isBinding } from "../../binding";
import type { ExpressionType } from "../../expressions";
import type { Resolve } from "./types";

@@ -9,3 +9,3 @@ /** Check to see if and of the data-changes affect the given dependencies */

dataChanges?: Set<BindingInstance>,
dependencies?: Set<BindingInstance>
dependencies?: Set<BindingInstance>,
) {

@@ -24,4 +24,4 @@ if (!dataChanges || !dependencies) {

(change) =>
change === dep || change.contains(dep) || dep.contains(change)
)
change === dep || change.contains(dep) || dep.contains(change),
),
) !== undefined

@@ -33,3 +33,3 @@ );

export function toNodeResolveOptions(
resolverOptions: Resolve.ResolverOptions
resolverOptions: Resolve.ResolverOptions,
): Resolve.NodeResolveOptions {

@@ -53,3 +53,3 @@ return {

: resolverOptions.parseBinding(bindingLike),
value
value,
)

@@ -56,0 +56,0 @@ : value,

@@ -1,10 +0,10 @@

import { SyncHook } from 'tapable-ts';
import type { View as ViewType } from '@player-ui/types';
import type { BindingInstance, BindingFactory } from '../binding';
import type { ValidationProvider, ValidationObject } from '../validator';
import type { Logger } from '../logger';
import type { Resolve } from './resolver';
import { Resolver, toNodeResolveOptions } from './resolver';
import type { Node } from './parser';
import { Parser } from './parser';
import { SyncHook } from "tapable-ts";
import type { View as ViewType } from "@player-ui/types";
import type { BindingInstance, BindingFactory } from "../binding";
import type { ValidationProvider, ValidationObject } from "../validator";
import type { Logger } from "../logger";
import type { Resolve } from "./resolver";
import { Resolver, toNodeResolveOptions } from "./resolver";
import type { Node } from "./parser";
import { Parser } from "./parser";
import {

@@ -15,3 +15,3 @@ TemplatePlugin,

SwitchPlugin,
} from './plugins';
} from "./plugins";

@@ -40,3 +40,3 @@ /**

this.logger?.warn(
`Unable to register view validations for id: ${contentView.id}. 'validation' property must be an Array.`
`Unable to register view validations for id: ${contentView.id}. 'validation' property must be an Array.`,
);

@@ -54,4 +54,4 @@

const withDefaults: ValidationObject = {
trigger: 'navigation',
severity: 'error',
trigger: "navigation",
severity: "error",
...vRef,

@@ -89,2 +89,3 @@ };

resolver: new SyncHook<[Resolver]>(),
onTemplatePluginCreated: new SyncHook<[TemplatePlugin]>(),
templatePlugin: new SyncHook<[TemplatePlugin]>(),

@@ -100,3 +101,3 @@ };

private templatePlugin: TemplatePlugin;
private templatePlugin: TemplatePlugin | undefined;

@@ -109,8 +110,5 @@ // TODO might want to add a version/timestamp to this to compare updates

this.resolverOptions = resolverOptions;
const pluginOptions = toNodeResolveOptions(resolverOptions);
new SwitchPlugin(pluginOptions).apply(this);
new ApplicabilityPlugin().apply(this);
new StringResolverPlugin().apply(this);
this.templatePlugin = new TemplatePlugin(pluginOptions);
this.templatePlugin.apply(this);
this.hooks.onTemplatePluginCreated.tap("view", (templatePlugin) => {
this.templatePlugin = templatePlugin;
});
}

@@ -130,6 +128,12 @@

this.resolverOptions.parseBinding,
this.resolverOptions.logger
this.resolverOptions.logger,
);
this.hooks.templatePlugin.call(this.templatePlugin);
if (this.templatePlugin) {
this.hooks.templatePlugin.call(this.templatePlugin);
} else {
this.resolverOptions.logger?.warn(
"templatePlugin not set for View, legacy templates may not work",
);
}

@@ -163,1 +167,7 @@ const parser = new Parser();

}
/** A plugin for a view */
export interface ViewPlugin {
/** Called with a view instance */
apply(view: ViewInstance): void;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc