@player-tools/dsl 0.13.0--canary.221.5662 → 0.13.0--canary.231.5678

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,7 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  ));
29
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
30
 
31
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/index.ts
31
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/index.ts
32
32
  var src_exports = {};
33
33
  __export(src_exports, {
34
34
  Asset: () => Asset,
@@ -85,10 +85,10 @@ __export(src_exports, {
85
85
  });
86
86
  module.exports = __toCommonJS(src_exports);
87
87
 
88
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/components.tsx
88
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/components.tsx
89
89
  var import_react2 = __toESM(require("react"));
90
90
 
91
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/auto-id.tsx
91
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/auto-id.tsx
92
92
  var import_react = __toESM(require("react"));
93
93
  var import_react_json_reconciler = require("react-json-reconciler");
94
94
  var IDSuffixContext = import_react.default.createContext("root");
@@ -161,10 +161,10 @@ var ObjectWithIndexTracking = (props) => {
161
161
  return /* @__PURE__ */ import_react.default.createElement(OptionalIDSuffixProvider, { wrapperRef: ref }, /* @__PURE__ */ import_react.default.createElement("obj", { ref }, props.children));
162
162
  };
163
163
 
164
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/utils.tsx
164
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/utils.tsx
165
165
  var React3 = __toESM(require("react"));
166
166
 
167
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/string-templates/index.ts
167
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/string-templates/index.ts
168
168
  var React2 = __toESM(require("react"));
169
169
  var import_player = require("@player-ui/player");
170
170
  var OpaqueIdentifier = Symbol("TemplateStringType");
@@ -284,7 +284,7 @@ var isBindingTemplateInstance = (val) => {
284
284
  return val !== null && typeof val === "object" && val[OpaqueIdentifier] === true && val.__type === "binding";
285
285
  };
286
286
 
287
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/utils.tsx
287
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/utils.tsx
288
288
  function toArray(val) {
289
289
  return Array.isArray(val) ? val : [val];
290
290
  }
@@ -405,7 +405,7 @@ function mapExpressionHandlersToFunctions(functions) {
405
405
  return result;
406
406
  }
407
407
 
408
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/components.tsx
408
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/components.tsx
409
409
  var SlotContext = import_react2.default.createContext(void 0);
410
410
  var AssetWrapper = import_react2.default.forwardRef(function AssetWrapper2(props, ref) {
411
411
  const { children, ...rest } = props;
@@ -502,7 +502,7 @@ function createSlot(options) {
502
502
  };
503
503
  }
504
504
 
505
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/switch.tsx
505
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/switch.tsx
506
506
  var import_react3 = __toESM(require("react"));
507
507
  var import_react_json_reconciler2 = require("react-json-reconciler");
508
508
  var SwitchContext = import_react3.default.createContext({});
@@ -572,7 +572,7 @@ var Case = (props) => {
572
572
  };
573
573
  Switch.Case = Case;
574
574
 
575
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/template.tsx
575
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/template.tsx
576
576
  var import_react4 = __toESM(require("react"));
577
577
  var import_react_json_reconciler3 = require("react-json-reconciler");
578
578
  var TemplateContext = import_react4.default.createContext({
@@ -718,10 +718,10 @@ var Template = (props) => {
718
718
  ), /* @__PURE__ */ import_react4.default.createElement("value", { ref: valueRef, value: void 0 })));
719
719
  };
720
720
 
721
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/index.ts
721
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/index.ts
722
722
  __reExport(src_exports, require("react-json-reconciler"), module.exports);
723
723
 
724
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/schema.ts
724
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/schema.ts
725
725
  var import_dequal = require("dequal");
726
726
  var import_tapable_ts = require("tapable-ts");
727
727
  var bindingSymbol = Symbol("binding");
@@ -891,13 +891,13 @@ var getRefStringFromObject = (obj) => {
891
891
  return getBindingFromObject(obj).toRefString();
892
892
  };
893
893
 
894
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/compiler.ts
894
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/compiler.ts
895
895
  var import_react6 = __toESM(require("react"));
896
896
  var import_source_map_js = require("source-map-js");
897
897
  var import_react_json_reconciler4 = require("react-json-reconciler");
898
898
  var import_tapable_ts2 = require("tapable-ts");
899
899
 
900
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/utils.ts
900
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/utils.ts
901
901
  var import_react5 = __toESM(require("react"));
902
902
  var fingerprintContent = (content, filename) => {
903
903
  if (content !== null || content !== void 0) {
@@ -913,7 +913,7 @@ var fingerprintContent = (content, filename) => {
913
913
  }
914
914
  };
915
915
 
916
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/compiler.ts
916
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/compiler.ts
917
917
  var parseNavigationExpressions = (nav) => {
918
918
  function replaceExpWithStr(obj) {
919
919
  function convExp(value) {
@@ -1066,13 +1066,13 @@ var DSLCompiler = class {
1066
1066
  }
1067
1067
  };
1068
1068
 
1069
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/types.ts
1069
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/types.ts
1070
1070
  var DefaultCompilerContentTypes = ["view", "flow", "schema"];
1071
1071
  function isDefaultCompilerContentType(t) {
1072
1072
  return DefaultCompilerContentTypes.includes(t);
1073
1073
  }
1074
1074
 
1075
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/expressions/native.ts
1075
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/expressions/native.ts
1076
1076
  var escapePrimitive = (val) => {
1077
1077
  switch (typeof val) {
1078
1078
  case "string": {
@@ -1118,7 +1118,7 @@ var nand = (...values) => {
1118
1118
  return not(and(...values));
1119
1119
  };
1120
1120
 
1121
- // ../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/expressions/testing.ts
1121
+ // ../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/expressions/testing.ts
1122
1122
  var import_player2 = require("@player-ui/player");
1123
1123
  function testExpression(exp, initialData, expressions) {
1124
1124
  const localModel = new import_player2.LocalModel(initialData);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/components.tsx","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/auto-id.tsx","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/utils.tsx","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/string-templates/index.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/switch.tsx","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/template.tsx","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/schema.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/compiler.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/utils.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/compiler/types.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/expressions/native.ts","../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/src/expressions/testing.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./auto-id\";\nexport * from \"./types\";\nexport * from \"./string-templates\";\nexport * from \"./utils\";\nexport * from \"./switch\";\nexport * from \"./template\";\nexport * from \"react-json-reconciler\";\nexport * from \"./compiler/schema\";\nexport * from \"./compiler\";\nexport * from \"./compiler/types\";\nexport * from \"./expressions/native\";\nexport * from \"./expressions/testing\";\n","import React from \"react\";\nimport type { ObjectNode, PropertyNode } from \"react-json-reconciler\";\nimport type { View as ViewType } from \"@player-ui/types\";\nimport type { PlayerApplicability, WithChildren } from \"./types\";\nimport {\n IDProvider,\n IDSuffixProvider,\n IndexSuffixStopContext,\n OptionalIDSuffixProvider,\n useGetIdPrefix,\n} from \"./auto-id\";\nimport {\n normalizeText,\n normalizeToCollection,\n toJsonElement,\n toJsonProperties,\n flattenChildren,\n mergeRefs,\n} from \"./utils\";\nimport { isBindingTemplateInstance } from \"./string-templates\";\n\nexport type AssetProps = PlayerApplicability & {\n /** id of the asset */\n id?: string;\n\n /** the asset type */\n type: string;\n\n /** Any other properties on the asset */\n children?: React.ReactNode;\n\n /** other things that we don't know about */\n [key: string]: unknown;\n};\n\nexport const SlotContext = React.createContext<\n | {\n /** The property name for the slot */\n propertyName: string;\n /** If the slot represents an array */\n isArray: boolean;\n /** If the items in the slot should be wrapped in an \"asset\" object */\n wrapInAsset: boolean;\n /** Other props to add to the slot */\n additionalProperties?: any;\n /** The ref to the property node */\n ref: React.RefObject<PropertyNode>;\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n }\n | undefined\n>(undefined);\n\n/**\n * Wraps the children in an `asset` object.\n * Additional props are added to the top level object\n */\nexport const AssetWrapper = React.forwardRef<\n ObjectNode,\n WithChildren<{ [key: string]: unknown }>\n>(function AssetWrapper(props, ref) {\n const { children, ...rest } = props;\n\n return (\n <obj ref={ref}>\n {toJsonProperties(rest)}\n <property name=\"asset\">{children}</property>\n </obj>\n );\n});\n\n/** Create a ID property for a node */\nexport const GeneratedIDProperty = (props: {\n /** the id to use if supplied by the user */\n id?: string;\n}) => {\n const currentPrefixId = useGetIdPrefix();\n return <property name=\"id\">{props.id ?? currentPrefixId}</property>;\n};\n\n/** An asset */\nexport const Asset = React.forwardRef<ObjectNode, AssetProps>((props, ref) => {\n const { id, type, applicability, children, ...rest } = props;\n const slotContext = React.useContext(SlotContext);\n const localRef = React.useRef<ObjectNode>(null);\n const Wrapper = slotContext?.wrapInAsset ? AssetWrapper : React.Fragment;\n\n const getResolvedValue = () => {\n if (applicability !== undefined) {\n if (typeof applicability === \"boolean\") {\n return applicability;\n }\n if (isBindingTemplateInstance(applicability)) {\n // converts bindings to use {{ }}\n return applicability.toString();\n }\n return applicability.toValue();\n }\n };\n\n return (\n <Wrapper\n ref={slotContext?.wrapInAsset ? mergeRefs([ref, localRef]) : undefined}\n {...(slotContext?.wrapInAsset && slotContext?.additionalProperties\n ? slotContext?.additionalProperties\n : {})}\n >\n <OptionalIDSuffixProvider wrapperRef={localRef}>\n <SlotContext.Provider value={undefined}>\n <IDProvider id={id}>\n <obj\n ref={\n slotContext?.wrapInAsset\n ? undefined\n : mergeRefs([ref, localRef])\n }\n >\n <GeneratedIDProperty id={id} />\n <property name=\"type\">{type}</property>\n {applicability !== undefined && (\n <property name=\"applicability\">\n <value value={getResolvedValue()} />\n </property>\n )}\n {toJsonProperties(rest)}\n {children}\n </obj>\n </IDProvider>\n </SlotContext.Provider>\n </OptionalIDSuffixProvider>\n </Wrapper>\n );\n});\n\nAsset.displayName = \"Asset\";\n\nAsset.defaultProps = {\n id: undefined,\n children: undefined,\n};\n\nexport const View = React.forwardRef<ObjectNode, AssetProps & ViewType>(\n (props, ref) => {\n const { validation, children, ...rest } = props;\n\n return (\n <Asset ref={ref} {...rest}>\n {validation && (\n <property key=\"validation\" name=\"validation\">\n {toJsonElement(validation, \"validation\", {\n propertiesToSkip: [\"ref\"],\n })}\n </property>\n )}\n {children}\n </Asset>\n );\n },\n);\n\nView.displayName = \"View\";\n\nView.defaultProps = {\n id: undefined,\n children: undefined,\n};\n\n/** A component to generate a named property slot */\nexport const Slot = (props: {\n /** The name of the slot */\n name: string;\n\n /** if the slot is an array or single object */\n isArray?: boolean;\n\n /** if each item should be wrapped in an asset */\n wrapInAsset?: boolean;\n\n /** Any children to render in the slot */\n children?: React.ReactNode;\n\n /** Other properties to add to the slot */\n additionalProperties?: any;\n\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n}) => {\n const { TextComp, CollectionComp } = props;\n const children = flattenChildren(props.children);\n const propRef = React.useRef<PropertyNode>(null);\n\n return (\n <property ref={propRef} name={props.name}>\n <IDSuffixProvider suffix={props.name}>\n <IndexSuffixStopContext.Provider value={false}>\n <SlotContext.Provider\n value={{\n ref: propRef,\n propertyName: props.name,\n wrapInAsset: props.wrapInAsset ?? false,\n isArray: props.isArray ?? false,\n additionalProperties: props.additionalProperties,\n TextComp,\n CollectionComp,\n }}\n >\n {props.isArray && (\n <array>\n {React.Children.map(children, (child, index) => {\n return (\n <React.Fragment key={`${props.name}-${index}`}>\n {normalizeText({ node: child, TextComp })}\n </React.Fragment>\n );\n })}\n </array>\n )}\n\n {!props.isArray &&\n normalizeToCollection({\n node: children,\n TextComp,\n CollectionComp,\n })}\n </SlotContext.Provider>\n </IndexSuffixStopContext.Provider>\n </IDSuffixProvider>\n </property>\n );\n};\n\n/** Create a slot for a given property */\nexport function createSlot<SlotProps = unknown>(options: {\n /** The name of the slot */\n name: string;\n\n /** if the slot is an array or single object */\n isArray?: boolean;\n\n /** if each item should be wrapped in an asset */\n wrapInAsset?: boolean;\n\n /** Any children to render in the slot */\n children?: React.ReactNode;\n\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n}) {\n // eslint-disable-next-line react/display-name\n return (\n props: {\n /** An object to include in this property */\n children?: React.ReactNode;\n } & SlotProps,\n ) => {\n const { children, ...other } = props;\n return (\n <Slot {...options} additionalProperties={other}>\n {children}\n </Slot>\n );\n };\n}\n","import React from \"react\";\nimport type { ObjectNode, JsonNode } from \"react-json-reconciler\";\nimport { flattenNodes } from \"react-json-reconciler\";\nimport { SlotContext } from \"./components\";\nimport type { WithChildren } from \"./types\";\n\nconst IDSuffixContext = React.createContext<string>(\"root\");\n\nexport const IndexSuffixStopContext = React.createContext<boolean>(false);\n\n/** Get the generated id */\nexport const useGetIdPrefix = () => {\n return React.useContext(IDSuffixContext);\n};\n\n/** Add a suffix to a generated id */\nexport const IDSuffixProvider = (\n props: WithChildren<{\n /** The suffix to append */\n suffix: string;\n }>,\n) => {\n const currentPrefix = useGetIdPrefix();\n\n return (\n <IDSuffixContext.Provider\n value={[\n currentPrefix === \"root\" ? undefined : currentPrefix,\n props.suffix,\n ]\n .filter(Boolean)\n .join(\"-\")}\n >\n {props.children}\n </IDSuffixContext.Provider>\n );\n};\n\n/** Override the generated id with the supplied one */\nexport const IDProvider = (\n props: WithChildren<{\n /** The new id to use */\n id?: string;\n }>,\n) => {\n if (props.id) {\n return (\n <IDSuffixContext.Provider value={props.id}>\n {props.children}\n </IDSuffixContext.Provider>\n );\n }\n\n return <>{props.children}</>;\n};\n\n/** Get the index of an item in a slot */\nexport const useIndexInSlot = (ref: React.RefObject<JsonNode>) => {\n const [index, setIndex] = React.useState(-1);\n const slotContext = React.useContext(SlotContext);\n\n React.useEffect(() => {\n if (!slotContext?.isArray) {\n throw new Error(\"Cannot get index in non-array slot\");\n }\n\n if (ref.current && slotContext?.ref.current?.valueNode?.type === \"array\") {\n const allChildren = flattenNodes(\n slotContext.ref.current.valueNode.children,\n );\n const foundIndex = allChildren.indexOf(ref.current);\n\n if (foundIndex !== index) {\n setIndex(foundIndex);\n }\n }\n }, [index, ref, slotContext?.isArray, slotContext?.ref]);\n\n return index;\n};\n\n/** Add the index to the id path when in an array slot */\nexport const IDSuffixIndexProvider = (\n props: WithChildren<{\n /** The ref to use */\n wrapperRef: React.RefObject<JsonNode>;\n\n /** if the suffix is in a template, the id to use */\n templateIndex?: string;\n }>,\n) => {\n const slotIndex = useIndexInSlot(props.wrapperRef);\n\n const stopIndex = React.useContext(IndexSuffixStopContext);\n\n if (stopIndex) {\n return <>{props.children}</>;\n }\n\n return (\n <IDSuffixProvider suffix={props.templateIndex ?? String(slotIndex)}>\n <IndexSuffixStopContext.Provider value>\n {props.children}\n </IndexSuffixStopContext.Provider>\n </IDSuffixProvider>\n );\n};\n\n/** Wrap a slot with the index if in an array slot */\nexport const OptionalIDSuffixProvider = (\n props: WithChildren<{\n /** The ref to walk upwards and use as an index */\n wrapperRef: React.RefObject<JsonNode>;\n\n /** if the suffix is in a template, the id to use */\n templateIndex?: string;\n }>,\n) => {\n const slotContext = React.useContext(SlotContext);\n\n if (slotContext?.isArray) {\n return (\n <IDSuffixIndexProvider\n wrapperRef={props.wrapperRef}\n templateIndex={props.templateIndex}\n >\n {props.children}\n </IDSuffixIndexProvider>\n );\n }\n\n return <>{props.children}</>;\n};\n\n/** An object wrapper that tracks its index from a parent */\nexport const ObjectWithIndexTracking = (props: WithChildren) => {\n const ref = React.useRef<ObjectNode>(null);\n\n return (\n <OptionalIDSuffixProvider wrapperRef={ref}>\n <obj ref={ref}>{props.children}</obj>\n </OptionalIDSuffixProvider>\n );\n};\n","import * as React from \"react\";\nimport {\n expression,\n ExpressionTemplateInstance,\n isTemplateStringInstance,\n TemplateStringComponent,\n} from \"./string-templates\";\nimport type {\n ExpressionArray,\n toJsonOptions,\n WithTemplateTypes,\n} from \"./types\";\nimport { Schema } from \"@player-ui/types\";\nimport { ExpressionHandler } from \"@player-ui/player\";\n\n/** Get an array version of the value */\nexport function toArray<T>(val: T | Array<T>): Array<T> {\n return Array.isArray(val) ? val : [val];\n}\n\n/** Create a component version */\nexport function toJsonElement(\n value: any,\n indexOrKey?: number | string,\n options?: toJsonOptions,\n): React.ReactElement {\n const indexProp = typeof indexOrKey === \"number\" ? { key: indexOrKey } : null;\n\n /** Allow users to pass in BindingTemplateInstance and ExpressionTemplateInstance directly without turning them into strings first */\n if (isTemplateStringInstance(value)) {\n if (\n typeof indexOrKey === \"string\" &&\n options?.propertiesToSkip?.includes(indexOrKey)\n ) {\n return <value {...indexProp}>{value.toValue()}</value>;\n }\n\n return <value {...indexProp}>{value.toRefString()}</value>;\n }\n\n if (Array.isArray(value)) {\n return (\n <array {...indexProp}>\n {value.map((item, idx) => toJsonElement(item, idx, options))}\n </array>\n );\n }\n\n if (typeof value === \"object\" && value !== null) {\n return (\n <obj {...indexProp}>\n {Object.keys(value).map((key) => (\n <property key={key} name={key}>\n {toJsonElement(value[key], key, options)}\n </property>\n ))}\n </obj>\n );\n }\n\n return <value {...indexProp} value={value} />;\n}\n\n/** Create a fragment for the properties */\nexport function toJsonProperties(\n value: Record<string, any>,\n options: toJsonOptions = { propertiesToSkip: [\"applicability\"] },\n): React.JSX.Element[] {\n return Object.keys(value).map((key) => {\n return (\n <property key={key} name={key}>\n {toJsonElement(value[key], key, options)}\n </property>\n );\n });\n}\n\n/** Create a text asset if needed */\nexport function normalizeText(options: {\n /** The current node */\n node: React.ReactNode;\n\n /** A component to render a text asset */\n TextComp?: React.ComponentType<any>;\n}): React.ReactNode {\n const { node, TextComp } = options;\n\n const nodeArr = React.Children.toArray(node);\n\n if (\n nodeArr.every(\n (n) => React.isValidElement(n) && n.type !== TemplateStringComponent,\n )\n ) {\n return node;\n }\n\n if (TextComp) {\n return <TextComp>{nodeArr}</TextComp>;\n }\n\n throw new Error(\n `Tried to convert node to Text Asset, but no Component was supplied.`,\n );\n}\n\n/** Create a collection if needed */\nexport function normalizeToCollection(options: {\n /** the node to look at */\n node: React.ReactNode;\n\n /** A Text asset */\n TextComp?: React.ComponentType;\n\n /** A collection asset */\n CollectionComp?: React.ComponentType<any>;\n}): React.ReactNode {\n const { node, CollectionComp } = options;\n\n if (\n React.Children.count(node) > 1 &&\n React.Children.toArray(node).every((n) => typeof n !== \"string\")\n ) {\n if (!CollectionComp) {\n throw new Error(\n `Tried to convert array to a collection asset, but no Component was given.`,\n );\n }\n\n return <CollectionComp>{node}</CollectionComp>;\n }\n\n return normalizeText({ ...options, node });\n}\n\ntype ReactChildArray = ReturnType<typeof React.Children.toArray>;\n\n/**\n *\n * Hoisted from https://github.com/gregberge/react-flatten-children/blob/master/src/index.tsx\n * Peer dependencies were wrong and can't be reasonably patch it everywhere\n */\nexport function flattenChildren(children: React.ReactNode): ReactChildArray {\n const childrenArray = React.Children.toArray(children);\n return childrenArray.reduce((flatChildren: ReactChildArray, child) => {\n if ((child as React.ReactElement<any>).type === React.Fragment) {\n return flatChildren.concat(\n flattenChildren((child as React.ReactElement<any>).props.children),\n );\n }\n\n flatChildren.push(child);\n\n return flatChildren;\n }, []);\n}\n/**\n * Hoisted from https://github.com/gregberge/react-merge-refs/blob/main/src/index.tsx\n * Published packages are ESM only or have bad esm distributions causing issues when\n * used in an esm environment\n */\nexport function mergeRefs<T = any>(\n refs: Array<\n React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null\n >,\n): React.RefCallback<T> {\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n };\n}\n\ntype TypesToReferences<T> = {\n [P in keyof T]: T[P] extends Schema.DataType<infer DT> ? DT : unknown;\n};\n\n/** Generates object reference properties from the provided object */\nexport function getObjectReferences<\n OriginalPropertiesObject,\n ReferencesPropertyObject,\n>(\n propertiesObject: OriginalPropertiesObject,\n): TypesToReferences<ReferencesPropertyObject> {\n const result: any = {};\n\n for (const itemProp in propertiesObject) {\n if (Object.prototype.hasOwnProperty.call(propertiesObject, itemProp)) {\n const refName = `${itemProp}Ref`;\n result[refName as keyof ReferencesPropertyObject] = { type: itemProp };\n }\n }\n\n return result;\n}\n\nfunction parseArg(arg: unknown, deref = false): any {\n if (isTemplateStringInstance(arg)) {\n return `'${deref ? arg.toRefString() : arg.toValue()}'`;\n } else if (Array.isArray(arg)) {\n return `[${arg.map((a) => parseArg(a, true)).join(\", \")}]`;\n } else if (typeof arg === \"string\") {\n return `'${arg}'`;\n } else {\n return arg;\n }\n}\n\nfunction generateDSLFunction<R>(\n name: string,\n args: Array<unknown>,\n): ExpressionTemplateInstance<R> {\n const expressionArgs: Array<unknown> = [];\n args.forEach((arg) => {\n expressionArgs.push(parseArg(arg));\n });\n\n return expression`${name}(${expressionArgs.join(\", \")})`;\n}\n\n/**\n * Convert an single ExpressionHandler function to a DSL expression function\n */\nexport function wrapFunctionInType<T extends Array<unknown>, R>(\n fn: ExpressionHandler<T, R>,\n): (...args: WithTemplateTypes<T>) => ExpressionTemplateInstance<R> {\n return (...args: WithTemplateTypes<T>): ExpressionTemplateInstance<R> => {\n return generateDSLFunction(fn.name, args);\n };\n}\n\n/**\n * Create a DSL Expression generation function by name and args specified by\n * generic parameters\n */\nexport function makeFunctionByName<T extends Array<unknown>, R>(\n name: string,\n): (...args: WithTemplateTypes<T>) => ExpressionTemplateInstance<R> {\n return (...args: WithTemplateTypes<T>): ExpressionTemplateInstance<R> => {\n return generateDSLFunction(name, args);\n };\n}\n\n/**\n * Takes map of functions and wraps them in a DSL syntax generator\n */\nexport function mapExpressionHandlersToFunctions<\n T extends Record<string, ExpressionHandler<any, any>>,\n>(functions: T): ExpressionArray<T> {\n const result: any = {};\n for (const fn of Object.values(functions)) {\n result[fn.name] = wrapFunctionInType(fn);\n }\n return result;\n}\n","import * as React from \"react\";\nimport { parseExpression, isErrorWithLocation } from \"@player-ui/player\";\n\nexport type TemplateInstanceRefStringContext = \"binding\" | \"expression\";\nexport interface TemplateRefStringOptions {\n /** If this template string is inside of another binding or expression */\n nestedContext?: TemplateInstanceRefStringContext;\n}\nexport interface TemplateInstanceRefStringOptions {\n /** The array of strings for the template */\n strings: ReadonlyArray<string>;\n /** the other data that's present in the template */\n other: Array<string | TemplateStringType>;\n\n /** If this template string is inside of another binding or expression */\n nestedContext?: TemplateInstanceRefStringContext;\n\n /** Convert the value to a reference nested in the given context */\n toRefString: (\n options: TemplateRefStringOptions | undefined,\n value: string,\n ) => string;\n}\n\nconst OpaqueIdentifier: unique symbol = Symbol(\"TemplateStringType\");\n\nexport type TemplateStringType<\n T extends string | number | boolean | unknown = any,\n> = React.ReactElement & {\n /** An identifier to show that this is a template type */\n [OpaqueIdentifier]: true;\n /** The value of the template string when in another string */\n toString: () => string;\n /** the raw value of the template string */\n toValue: () => string;\n /** the dereferenced value when used in another */\n toRefString: (options?: TemplateRefStringOptions) => T;\n /** Underlying type of this binding */\n type: T;\n};\n\nexport type BindingTemplateInstance<\n DataType extends string | number | boolean | unknown = any,\n> = TemplateStringType<DataType> & {\n /** An identifier for a binding instance */\n __type: \"binding\";\n};\n\nexport type ExpressionTemplateInstance<\n ReturnType extends string | number | boolean | unknown = any,\n> = TemplateStringType<ReturnType> & {\n /** The identifier for an expression instance */\n __type: \"expression\";\n};\n\n/** A react component for rendering a template string type */\nexport const TemplateStringComponent = (props: {\n /** The string value of the child template string */\n value: string;\n}): React.ReactElement<{\n value: string;\n}> => {\n return React.createElement(\n \"value\",\n {\n value: props.value,\n },\n null,\n );\n};\n\n/** The generic template string handler */\nconst createTemplateInstance = (\n options: TemplateInstanceRefStringOptions,\n): TemplateStringType => {\n const value = options.strings.reduce((sum, next, i) => {\n const element = options.other[i];\n if (typeof element === \"string\") {\n return sum + next + element;\n }\n\n return sum + next + (element?.toRefString(options) ?? \"\");\n }, \"\");\n\n /** Try to parse the expression as valid */\n if (options.nestedContext === \"expression\") {\n try {\n parseExpression(value);\n } catch (e) {\n if (e instanceof Error) {\n let message: string;\n if (isErrorWithLocation(e)) {\n message = `${e} in expression: \\r\\n ${\n value.slice(0, e.index + 1) + \"\\u2588\" + value.slice(e.index + 1)\n }`;\n } else {\n message = `${e} in expression ${value}`;\n }\n throw new Error(message);\n }\n\n throw new Error(`Unknown problem parsing expression ${e}`);\n }\n }\n\n /** get the unwrapped version */\n const toString = () => {\n return options.toRefString({}, value);\n };\n\n /** get the raw value of the template */\n const toValue = () => {\n return value;\n };\n\n /** This lets us use it directly as a child element in React */\n const element = React.createElement(\n TemplateStringComponent,\n {\n value: toString(),\n },\n null,\n ) as TemplateStringType;\n\n return {\n ...element,\n [OpaqueIdentifier]: true,\n toString,\n toValue,\n toRefString: (refStringOptions?: TemplateRefStringOptions) => {\n return options.toRefString(refStringOptions, value);\n },\n };\n};\n\n/** Helper for Iterating the binding to add a dynamic numeric value to each index found */\nconst addBindingIndexes = (binding: string): string => {\n let currentIndex = 0;\n\n return binding.replace(/_index_/g, () => {\n const result = `_index${currentIndex > 0 ? currentIndex : \"\"}_`;\n currentIndex += 1;\n\n return result;\n });\n};\n\n/** Creating an instance of a handler for bindings */\nconst createBindingTemplateInstance = (\n options: Omit<TemplateInstanceRefStringOptions, \"toRefString\">,\n): BindingTemplateInstance => {\n const templateInstance = createTemplateInstance({\n ...options,\n strings: options.strings.map((element: string) =>\n addBindingIndexes(element),\n ),\n other: options.other.map((element) =>\n typeof element === \"string\" ? addBindingIndexes(element) : element,\n ),\n toRefString: (context, value) => {\n return `{{${value}}}`;\n },\n }) as BindingTemplateInstance;\n\n templateInstance.__type = \"binding\";\n\n return templateInstance;\n};\n\n/** Creating an instance of a handler for bindings */\nconst createExpressionTemplateInstance = (\n options: Omit<TemplateInstanceRefStringOptions, \"toRefString\">,\n) => {\n const templateInstance = createTemplateInstance({\n ...options,\n toRefString: (contextOptions, value) => {\n if (contextOptions?.nestedContext === \"expression\") {\n return value;\n }\n\n const inBinding = contextOptions?.nestedContext === \"binding\";\n return `${inBinding ? \"`\" : \"@[\"}${value}${inBinding ? \"`\" : \"]@\"}`;\n },\n }) as ExpressionTemplateInstance;\n\n templateInstance.__type = \"expression\";\n\n return templateInstance;\n};\n\n/** A tagged-template constructor for a binding */\nexport const binding = <T>(\n strings: TemplateStringsArray,\n ...nested: Array<TemplateStringType | string>\n): BindingTemplateInstance<T> => {\n return createBindingTemplateInstance({\n strings,\n other: nested,\n nestedContext: \"binding\",\n });\n};\n\n/** A tagged-template constructor for an expression */\nexport const expression = <T>(\n strings: TemplateStringsArray,\n ...nested: Array<\n ExpressionTemplateInstance | BindingTemplateInstance | string\n >\n): ExpressionTemplateInstance<T> => {\n return createExpressionTemplateInstance({\n strings,\n other: nested,\n nestedContext: \"expression\",\n });\n};\n\n/** Check if a value is a template string */\nexport const isTemplateStringInstance = (\n val: unknown,\n): val is ExpressionTemplateInstance | BindingTemplateInstance => {\n return (\n val !== null &&\n typeof val === \"object\" &&\n (val as any)[OpaqueIdentifier] === true\n );\n};\n\n/** Check if a value is a binding */\nexport const isBindingTemplateInstance = (\n val: unknown,\n): val is BindingTemplateInstance => {\n return (\n val !== null &&\n typeof val === \"object\" &&\n (val as any)[OpaqueIdentifier] === true &&\n (val as BindingTemplateInstance).__type === \"binding\"\n );\n};\n","import type { PropsWithChildren } from \"react\";\nimport React from \"react\";\nimport type { ArrayNode, JsonNode, ObjectNode } from \"react-json-reconciler\";\nimport { flattenNodes } from \"react-json-reconciler\";\nimport { SlotContext } from \".\";\nimport { IDSuffixProvider, OptionalIDSuffixProvider } from \"./auto-id\";\nimport type {\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n} from \"./string-templates\";\nimport { isTemplateStringInstance } from \"./string-templates\";\nimport { normalizeToCollection, toJsonProperties } from \"./utils\";\n\nexport interface SwitchProps {\n /** defaults to a staticSwitch */\n isDynamic?: boolean;\n}\n\nconst SwitchContext = React.createContext<\n SwitchProps & {\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n }\n>({});\n\n/**\n * Switches allow users to fork content between 1 or more assets\n */\nexport const Switch = (props: PropsWithChildren<SwitchProps>) => {\n const slotContext = React.useContext(SlotContext);\n const propertyNode = React.useRef<ObjectNode>(null);\n\n return (\n <obj ref={propertyNode}>\n <SwitchContext.Provider\n value={{\n ...props,\n TextComp: slotContext?.TextComp,\n CollectionComp: slotContext?.CollectionComp,\n }}\n >\n <OptionalIDSuffixProvider wrapperRef={propertyNode}>\n <property name={props.isDynamic ? \"dynamicSwitch\" : \"staticSwitch\"}>\n <SlotContext.Provider value={undefined}>\n <array>{props.children}</array>\n </SlotContext.Provider>\n </property>\n </OptionalIDSuffixProvider>\n </SwitchContext.Provider>\n {slotContext?.additionalProperties &&\n toJsonProperties(slotContext.additionalProperties)}\n </obj>\n );\n};\n\nexport interface CaseProps {\n /** the test for this case statement */\n exp?: ExpressionTemplateInstance | BindingTemplateInstance | boolean;\n}\n\n/** Find the first parent array */\nconst findParentArray = (node: JsonNode): ArrayNode => {\n if (node.type === \"array\") {\n return node;\n }\n\n if (node.parent) {\n return findParentArray(node.parent);\n }\n\n throw new Error(\"can't find parent array\");\n};\n\n/** Find the index of the item in an array */\nconst findArrayIndex = (node: JsonNode): number => {\n const parentArray = findParentArray(node);\n const allSearch = flattenNodes(parentArray.children);\n return allSearch.indexOf(node);\n};\n\n/** A case for a switch */\nconst Case = (props: PropsWithChildren<CaseProps>) => {\n const slotContext = React.useContext(SlotContext);\n const switchContext = React.useContext(SwitchContext);\n const [caseIndex, setCaseIndex] = React.useState(-1);\n const caseNode = React.useRef<ObjectNode>(null);\n\n React.useLayoutEffect(() => {\n if (caseNode.current) {\n const index = findArrayIndex(caseNode.current);\n if (index !== caseIndex) {\n setCaseIndex(index);\n }\n }\n }, [caseIndex]);\n\n let expValue: string | boolean = true;\n\n if (props.exp !== undefined) {\n expValue = isTemplateStringInstance(props.exp)\n ? props.exp.toValue()\n : props.exp;\n }\n\n return (\n <obj ref={caseNode}>\n <property name=\"case\">\n <value value={expValue} />\n </property>\n <IDSuffixProvider\n suffix={`${\n switchContext.isDynamic ? \"dynamicSwitch\" : \"staticSwitch\"\n }-${caseIndex}`}\n >\n <SlotContext.Provider\n value={\n slotContext ? { ...slotContext, wrapInAsset: false } : undefined\n }\n >\n <property name=\"asset\">\n {normalizeToCollection({\n node: props.children,\n TextComp: switchContext?.TextComp,\n CollectionComp: switchContext?.CollectionComp,\n })}\n </property>\n </SlotContext.Provider>\n </IDSuffixProvider>\n </obj>\n );\n};\n\nSwitch.Case = Case;\n","import React from \"react\";\nimport type { ObjectNode, JsonNode } from \"react-json-reconciler\";\nimport {\n ArrayNode,\n PropertyNode,\n ValueNode,\n createPortal,\n ProxyNode,\n toJSON,\n} from \"react-json-reconciler\";\nimport { OptionalIDSuffixProvider } from \"./auto-id\";\nimport type { BindingTemplateInstance } from \"./string-templates\";\nimport type { WithChildren } from \"./types\";\nimport { toJsonElement } from \"./utils\";\n\nexport interface TemplateContextType {\n /** The number of nested templates */\n depth: number;\n}\n\nexport const TemplateContext: React.Context<TemplateContextType> =\n React.createContext<TemplateContextType>({\n depth: 0,\n });\n\nexport interface TemplateProps {\n /** The source binding */\n data: BindingTemplateInstance;\n\n /** The target property */\n output?: string;\n\n /** The template value */\n children: React.ReactNode;\n\n /** boolean that specifies whether template should recompute when data changes */\n dynamic?: boolean;\n\n /** Specifies the expanded template placement in relation to existing elements*/\n placement?: \"append\" | \"prepend\";\n}\n\n/**\n * Represents the position information for template insertion\n */\ninterface PositionInfo {\n placement?: \"append\" | \"prepend\";\n insertionIndex?: number;\n}\n\n/**\n * Determines placement based on its proxy node and uses that for AST parity\n */\nfunction determinePositionInfo(proxyNode: ProxyNode | null): PositionInfo {\n const result: PositionInfo = {\n placement: undefined,\n insertionIndex: undefined,\n };\n\n if (!proxyNode || !proxyNode.parent) {\n return result;\n }\n\n if (proxyNode.parent.type === \"array\") {\n const parentArray = proxyNode.parent;\n const proxyIndex = parentArray.items.indexOf(proxyNode);\n\n // Check if there are any non-proxy items before this proxy\n const hasNonProxyBefore = parentArray.items\n .slice(0, proxyIndex)\n .some((item) => item.type !== \"proxy\");\n\n const hasNonProxyAfter = parentArray.items\n .slice(proxyIndex + 1)\n .some((item) => item.type !== \"proxy\");\n\n if (hasNonProxyBefore) {\n result.placement = \"append\";\n } else if (hasNonProxyAfter) {\n result.placement = \"prepend\";\n }\n }\n\n const containingSlot = proxyNode.parent?.parent;\n if (\n containingSlot &&\n containingSlot.type === \"property\" &&\n containingSlot.keyNode.type === \"value\"\n ) {\n const parentObject = getParentObject(proxyNode);\n if (parentObject) {\n const index = parentObject.properties.findIndex((properties) => {\n return properties.keyNode.value === containingSlot.keyNode.value;\n });\n\n // Assigns AST ordering based on placement\n if (index !== -1) {\n result.insertionIndex =\n result.placement === \"prepend\" ? index : index + 1;\n }\n }\n }\n\n return result;\n}\n\n/** Add a template instance to the object */\nfunction addTemplateToObject(\n obj: ObjectNode,\n templateObj: ObjectNode,\n templateParentNodeType: string,\n insertionIndex: number | undefined,\n): () => void {\n // find a template property\n // add one if none exists\n\n let templateProp = obj.properties.find(\n (p) => p.keyNode.value === \"template\" && p.valueNode?.type === \"array\",\n );\n\n if (!templateProp) {\n templateProp = new PropertyNode(new ValueNode(\"template\"), new ArrayNode());\n templateProp.parent = obj;\n obj.properties.splice(\n insertionIndex ?? obj.properties.length - 1,\n 0,\n templateProp,\n );\n }\n\n const templateItems = templateProp.valueNode as ArrayNode;\n\n templateItems.items.push(templateObj);\n\n templateObj.parent = templateItems;\n\n const templateParentProp = obj.properties.find(\n (p) =>\n p.keyNode.value === templateParentNodeType &&\n p.valueNode?.type === \"array\",\n );\n\n if (templateParentProp) {\n const indexOfTemplateParent = obj.properties.indexOf(templateParentProp, 1);\n const templateParentValueNode =\n obj.properties[indexOfTemplateParent]?.valueNode;\n if (templateParentValueNode) {\n const templateParentArray = toJSON(templateParentValueNode);\n\n // Delete the parent of template if it is an empty array\n if (\n Array.isArray(templateParentArray) &&\n templateParentArray.length === 0\n ) {\n obj.properties.splice(indexOfTemplateParent, 1);\n }\n }\n }\n\n return () => {\n // Remove the template item from the list\n templateItems.items = templateItems.items.filter((t) => t !== templateObj);\n\n // Clean up the whole template if it's removed\n if (templateItems.children.length === 0 && templateProp) {\n obj.properties.splice(obj.properties.indexOf(templateProp, 1));\n }\n };\n}\n\n/** Context provider wrapper to handle nested templates */\nconst TemplateProvider = (props: WithChildren) => {\n const baseContext = React.useContext(TemplateContext);\n\n return (\n <TemplateContext.Provider value={{ depth: baseContext.depth + 1 }}>\n {props.children}\n </TemplateContext.Provider>\n );\n};\n\n/** Find the first object node in the tree */\nconst getParentObject = (node: JsonNode): ObjectNode | undefined => {\n if (node.type === \"object\") {\n return node;\n }\n\n if (node.parent) {\n return getParentObject(node.parent);\n }\n};\n\n/** Find the property of the node on the parent */\nconst getParentProperty = (node: JsonNode): PropertyNode | undefined => {\n if (node.type === \"property\") {\n return node;\n }\n\n if (node.parent) {\n return getParentProperty(node.parent);\n }\n};\n\n/** A template allows users to dynamically map over an array of data */\nexport const Template = (props: TemplateProps): React.JSX.Element => {\n const baseContext = React.useContext(TemplateContext);\n const dynamicProp = props.dynamic ?? false;\n const [outputProp, setOutputProp] = React.useState<string | undefined>(\n props.output,\n );\n const proxyRef = React.useRef<ProxyNode>(null);\n const valueRef = React.useRef<ValueNode>(null);\n const outputElement = React.useMemo(() => new ProxyNode(), []);\n\n React.useLayoutEffect(() => {\n // Get the output prop\n const propNode = proxyRef.current && getParentProperty(proxyRef.current);\n\n if (outputProp === undefined && propNode) {\n setOutputProp(propNode.keyNode.value);\n }\n }, [proxyRef, outputProp]);\n\n React.useEffect(() => {\n const templateObj = outputElement.items[0] as ObjectNode;\n if (proxyRef.current) {\n const parentObject = getParentObject(proxyRef.current);\n\n if (!parentObject) {\n throw new Error(\"Unable to find parent to add template to\");\n }\n\n if (!outputProp) {\n return;\n }\n\n const { insertionIndex } = determinePositionInfo(proxyRef.current);\n\n // remove the template when unmounted\n return addTemplateToObject(\n parentObject,\n templateObj,\n outputProp,\n insertionIndex,\n );\n }\n }, [proxyRef, outputProp, outputElement.items]);\n\n // Get position information for the template\n const { placement: inferredPlacement } = determinePositionInfo(\n proxyRef.current,\n );\n\n // Use the explicitly provided placement or the inferred one\n const resolvedPlacement = props.placement || inferredPlacement;\n\n return (\n <proxy ref={proxyRef}>\n <>\n {\n createPortal(\n <OptionalIDSuffixProvider\n wrapperRef={valueRef}\n templateIndex={`_index${\n baseContext.depth === 0 ? \"\" : baseContext.depth\n }_`}\n >\n <TemplateProvider>\n <object>\n <property name=\"data\">{props.data.toValue()}</property>\n <property name=\"output\">{outputProp}</property>\n <property name=\"value\">{props.children}</property>\n {dynamicProp && (\n <property name=\"dynamic\">\n {toJsonElement(dynamicProp)}\n </property>\n )}\n {resolvedPlacement && (\n <property name=\"placement\">\n {toJsonElement(resolvedPlacement)}\n </property>\n )}\n </object>\n </TemplateProvider>\n </OptionalIDSuffixProvider>,\n outputElement,\n ) as any\n }\n <value ref={valueRef} value={undefined} />\n </>\n </proxy>\n );\n};\n","import type { Schema, Language } from \"@player-ui/types\";\nimport { dequal } from \"dequal\";\nimport { SyncWaterfallHook } from \"tapable-ts\";\nimport type { LoggingInterface } from \"..\";\nimport { binding as b } from \"..\";\nimport type { BindingTemplateInstance } from \"../string-templates\";\n\nconst bindingSymbol = Symbol(\"binding\");\n\n/** Symbol to indicate that a schema node should be generated with a different name */\nexport const SchemaTypeName: unique symbol = Symbol(\"Schema Rename\");\n\ninterface SchemaChildren {\n /** Object property that will be used to create the intermediate type */\n name: string;\n\n /** Object properties children that will be parsed */\n child: object;\n}\n\ntype SchemaNode = (Schema.DataType | Language.DataTypeRef) & {\n /** Overwrite the name of the generated type */\n [SchemaTypeName]?: string;\n};\n\ninterface GeneratedDataType {\n /** The SchemaNode that was generated */\n node: SchemaNode;\n /** How many times it has been generated */\n count: number;\n}\n\n/**\n * Type Guard for the `Schema.DataType` and `Language.DataTypeRef` type\n * A bit hacky but since `Schema.Schema` must have a `Schema.DataType` as\n * the final product we have to call it that even if it is a `Language.DataTypeRef`\n */\nconst isTypeDef = (property: SchemaNode): property is Schema.DataType => {\n return (property as Schema.DataType).type !== undefined;\n};\n\n/**\n * Generator for `Schema.Schema` Objects\n */\nexport class SchemaGenerator {\n private children: Array<SchemaChildren>;\n private generatedDataTypes: Map<string, GeneratedDataType>;\n private logger: LoggingInterface;\n\n public hooks: {\n createSchemaNode: SyncWaterfallHook<\n [\n node: Schema.DataType<unknown>,\n originalProperty: Record<string | symbol, unknown>,\n ],\n Record<string, any>\n >;\n } = {\n createSchemaNode: new SyncWaterfallHook<\n [\n node: Schema.DataType,\n originalProperty: Record<string | symbol, unknown>,\n ]\n >(),\n };\n\n constructor(logger?: LoggingInterface) {\n this.children = [];\n this.generatedDataTypes = new Map();\n this.logger = logger ?? console;\n }\n\n /**\n * Converts an object to a `Schema.Schema` representation\n * Note: uses iteration to prevent potentially very deep recursion on large objects\n */\n public toSchema = (schema: any): Schema.Schema => {\n const newSchema: Schema.Schema = {\n ROOT: {},\n };\n\n this.children = [];\n this.generatedDataTypes.clear();\n\n Object.keys(schema).forEach((property) => {\n const subType = schema[property] as SchemaNode;\n newSchema.ROOT[property] = this.hooks.createSchemaNode.call(\n this.processChild(property, subType),\n subType as any,\n );\n });\n\n while (this.children.length > 0) {\n const c = this.children.pop();\n if (c === undefined) {\n break;\n }\n\n const { name, child } = c;\n const typeDef = {} as any;\n\n Object.keys(child).forEach((property) => {\n const subType = (child as any)[property] as SchemaNode;\n typeDef[property] = this.hooks.createSchemaNode.call(\n this.processChild(property, subType),\n subType as any,\n );\n });\n newSchema[name] = typeDef;\n }\n\n return newSchema;\n };\n\n /**\n * Processes the children of an object Node\n * Newly discovered children get added to the provided array\n */\n private processChild(property: string, subType: SchemaNode): Schema.DataType {\n if (isTypeDef(subType)) {\n return subType;\n }\n\n let intermediateType;\n let child;\n\n if (Array.isArray(subType)) {\n if (subType.length > 1) {\n this.logger.warn(\n `Type ${property} has multiple types in array, should only contain one top level object type. Only taking first defined type`,\n );\n }\n\n const subTypeName = subType[0][SchemaTypeName] ?? property;\n intermediateType = this.makePlaceholderArrayType(subTypeName);\n [child] = subType;\n } else {\n const subTypeName = subType[SchemaTypeName] ?? property;\n intermediateType = this.makePlaceholderType(subTypeName);\n child = subType;\n }\n\n this.children.push({ name: intermediateType.type, child });\n\n if (this.generatedDataTypes.has(intermediateType.type)) {\n const generatedType = this.generatedDataTypes.get(\n intermediateType.type,\n ) as GeneratedDataType;\n if (\n !dequal(\n child,\n this.generatedDataTypes.get(intermediateType.type)?.node as object,\n )\n ) {\n generatedType.count += 1;\n const newIntermediateType = {\n ...intermediateType,\n type: `${intermediateType.type}${generatedType.count}`,\n };\n this.logger.warn(\n `WARNING: Generated two intermediate types with the name: ${intermediateType.type} that are of different shapes, using artificial type ${newIntermediateType.type}`,\n );\n intermediateType = newIntermediateType;\n this.children.pop();\n this.children.push({ name: intermediateType.type, child });\n }\n }\n\n this.generatedDataTypes.set(intermediateType.type, {\n node: subType,\n count: 1,\n });\n return intermediateType;\n }\n\n /**\n * Make an intermediate `Schema.DataType` object given a name\n */\n private makePlaceholderType = (typeName: string): Schema.DataType => {\n return {\n type: `${typeName}Type`,\n };\n };\n\n /**\n * Make an intermediate `Schema.DataType` object with array support given a name\n */\n private makePlaceholderArrayType(typeName: string): Schema.DataType {\n return {\n type: `${typeName}Type`,\n isArray: true,\n };\n }\n}\n\nexport type MakeArrayIntoIndexRef<T extends any[]> = {\n [key: number]: MakeBindingRefable<T[0]>;\n /** Used when referencing bindings from within a template */\n _index_: MakeBindingRefable<T[0]>;\n} & BindingTemplateInstance;\n\nexport type MakeBindingRefable<T> = {\n [P in keyof T]: T[P] extends object[]\n ? MakeArrayIntoIndexRef<T[P]>\n : T[P] extends unknown[]\n ? T[P]\n : MakeBindingRefable<T[P]>;\n} & BindingTemplateInstance<T>;\n\n/**\n * Adds bindings to an object so that the object can be directly used in JSX\n */\nexport function makeBindingsForObject<Type>(\n obj: Type,\n arrayAccessorKeys: string[] = [\"_index_\"],\n): MakeBindingRefable<Type> {\n /** Proxy to track binding callbacks */\n const accessor = (paths: string[]) => {\n const bindingMap = new WeakMap<any, BindingTemplateInstance>();\n\n return {\n ownKeys(target: any) {\n return Reflect.ownKeys(target);\n },\n\n get(target: any, key: any): any {\n const bindingKeys = Object.keys(target);\n\n // If there is an array of primitives, just return a copy of that array\n if (\n Array.isArray(target[key]) &&\n target[key].length > 0 &&\n target[key].every((it: any) => typeof it !== \"object\")\n ) {\n return [...target[key]];\n }\n\n if (!bindingMap.has(target)) {\n bindingMap.set(target, b`${paths.join(\".\")}`);\n }\n\n if (key === bindingSymbol) {\n return paths;\n }\n\n if (\n Array.isArray(target) &&\n (arrayAccessorKeys.includes(key) || typeof key === \"number\")\n ) {\n return new Proxy(target[0], accessor(paths.concat([key])));\n }\n\n if (bindingKeys.includes(key) && typeof target[key] === \"object\") {\n return new Proxy(target[key], accessor(paths.concat([key])));\n }\n\n const createdInstance = bindingMap.get(target) as any;\n return createdInstance?.[key];\n },\n };\n };\n\n return new Proxy(obj, accessor([])) as MakeBindingRefable<Type>;\n}\n\n/**\n * Generates binding for an object property\n */\nexport const getBindingFromObject = (obj: any): BindingTemplateInstance => {\n const baseBindings = obj[bindingSymbol] as string[];\n if (!Array.isArray(baseBindings) || baseBindings.length === 0) {\n throw new Error(`Unable to get binding for ${obj}`);\n }\n\n return b`${baseBindings.join(\".\")}`;\n};\n\n/**\n * Returns the binding string from an object path\n */\nexport const getBindingStringFromObject = (obj: any): string => {\n return getBindingFromObject(obj).toString();\n};\n\n/**\n * Returns the ref string from an object path\n */\nexport const getRefStringFromObject = (obj: any): string => {\n return getBindingFromObject(obj).toRefString();\n};\n","import React from \"react\";\nimport type { JsonType } from \"react-json-reconciler\";\nimport { SourceMapGenerator, SourceMapConsumer } from \"source-map-js\";\nimport { render } from \"react-json-reconciler\";\nimport type { Flow, View, Navigation as PlayerNav } from \"@player-ui/types\";\nimport {\n AsyncSeriesHook,\n AsyncSeriesWaterfallHook,\n SyncHook,\n} from \"tapable-ts\";\nimport { fingerprintContent } from \"./utils\";\nimport type {\n LoggingInterface,\n CompilerReturn,\n SerializeContext,\n} from \"./types\";\nimport type { Navigation } from \"../types\";\nimport { SchemaGenerator } from \"./schema\";\n\n/**\n * Argument passed to the DSLCompiler onEnd hook\n * Defined as an object so additional fields can be added later without breaking API\n * */\nexport interface OnEndArg {\n /** target output directory **/\n output: string;\n}\n\n/** Recursively find BindingTemplateInstance and call toValue on them */\nconst parseNavigationExpressions = (nav: Navigation): PlayerNav => {\n /** Same as above but signature changed */\n function replaceExpWithStr(obj: any): any {\n /** call toValue if BindingTemplateInstance otherwise continue */\n function convExp(value: any): any {\n return value && typeof value === \"object\" && value.__type === \"expression\"\n ? value.toValue() // exp, onStart, and onEnd don't need to be wrapped in @[]@\n : replaceExpWithStr(value);\n }\n\n if (Array.isArray(obj)) {\n return obj.map(convExp);\n }\n\n if (typeof obj === \"object\") {\n const copy = { ...obj };\n for (const [key, value] of Object.entries(copy)) {\n copy[key] = convExp(value);\n }\n\n return copy;\n }\n\n return obj;\n }\n\n return replaceExpWithStr(nav);\n};\n\ntype SourceMapList = Array<{\n /** The mappings of the original */\n sourceMap: string;\n /**\n * The id of the view we're indexing off of\n * This should be a unique global identifier within the generated code\n * e.g. `\"id\": \"view_0\",`\n */\n offsetIndexSearch: string;\n /** The generated source that produced the map */\n source: string;\n}>;\n\n/** Given a list of source maps for all generated views, merge them into 1 */\nconst mergeSourceMaps = (\n sourceMaps: SourceMapList,\n generated: string,\n): string => {\n const generator = new SourceMapGenerator();\n sourceMaps.forEach(({ sourceMap, offsetIndexSearch, source }) => {\n const generatedLineOffset = generated\n .split(\"\\n\")\n .findIndex((line) => line.includes(offsetIndexSearch));\n\n const sourceLineOffset = source\n .split(\"\\n\")\n .findIndex((line) => line.includes(offsetIndexSearch));\n\n const lineOffset = generatedLineOffset - sourceLineOffset;\n\n const generatedLine = generated.split(\"\\n\")[generatedLineOffset];\n const sourceLine = source.split(\"\\n\")[sourceLineOffset];\n\n const generatedColumn = generatedLine.indexOf(offsetIndexSearch);\n const sourceColumn = sourceLine.indexOf(offsetIndexSearch);\n const columnOffset = generatedColumn - sourceColumn;\n\n const consumer = new SourceMapConsumer(JSON.parse(sourceMap));\n consumer.eachMapping((mapping) => {\n generator.addMapping({\n generated: {\n line: mapping.generatedLine + lineOffset,\n column: mapping.generatedColumn + columnOffset,\n },\n original: {\n line: mapping.originalLine,\n column: mapping.originalColumn,\n },\n source: mapping.source,\n });\n });\n });\n\n return generator.toString();\n};\n\n/** A compiler for transforming DSL content into JSON */\nexport class DSLCompiler {\n public readonly logger: LoggingInterface;\n public hooks = {\n // Hook to access the schema generator instance when initialized\n schemaGenerator: new SyncHook<[SchemaGenerator]>(),\n // Hook to access pre-compilation object\n preProcessFlow: new AsyncSeriesWaterfallHook<[object]>(),\n // Hook to access post-compilation Flow before output is written\n postProcessFlow: new AsyncSeriesWaterfallHook<[Flow]>(),\n // Hook called after all files are compiled. Revives the output directory\n onEnd: new AsyncSeriesHook<[OnEndArg]>(),\n };\n\n private schemaGenerator?: SchemaGenerator;\n\n constructor(logger?: LoggingInterface) {\n this.logger = logger ?? console;\n }\n\n /** Convert an object (flow, view, schema, etc) into it's JSON representation */\n async serialize(\n value: unknown,\n context?: SerializeContext,\n ): Promise<CompilerReturn> {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"Unable to serialize non-object\");\n }\n\n const type = context?.type ? context.type : fingerprintContent(value);\n\n if (!this.schemaGenerator) {\n this.schemaGenerator = new SchemaGenerator(this.logger);\n this.hooks.schemaGenerator.call(this.schemaGenerator);\n }\n\n if (type === \"view\") {\n const { jsonValue, sourceMap } = await render(value as any, {\n collectSourceMap: true,\n });\n\n return {\n value: jsonValue,\n sourceMap,\n };\n }\n\n if (type === \"flow\") {\n // Source maps from all the nested views\n // Merge these together before returning\n const allSourceMaps: SourceMapList = [];\n\n // Assume this is a flow\n const copiedValue: Flow = {\n ...(value as any),\n };\n\n copiedValue.views = (await Promise.all(\n copiedValue?.views?.map(async (node: any) => {\n if (React.isValidElement(node)) {\n const { jsonValue, sourceMap, stringValue } = await render(node, {\n collectSourceMap: true,\n });\n\n if (sourceMap) {\n // Find the line that is the id of the view\n // Use that as the identifier for the sourcemap offset calc\n const searchIdLine = stringValue\n .split(\"\\n\")\n .find((line) =>\n line.includes(\n `\"id\": \"${(jsonValue as Record<string, string>).id}\"`,\n ),\n );\n\n if (searchIdLine) {\n allSourceMaps.push({\n sourceMap,\n offsetIndexSearch: searchIdLine,\n source: stringValue,\n });\n }\n }\n\n return jsonValue;\n }\n\n return node;\n }) ?? [],\n )) as View[];\n\n // Go through the flow and sub out any view refs that are react elements w/ the right id\n if (\"navigation\" in value) {\n Object.entries((value as Flow).navigation).forEach(([navKey, node]) => {\n if (typeof node === \"object\") {\n Object.entries(node).forEach(([nodeKey, flowNode]) => {\n if (\n flowNode &&\n typeof flowNode === \"object\" &&\n \"state_type\" in flowNode &&\n flowNode.state_type === \"VIEW\" &&\n React.isValidElement(flowNode.ref)\n ) {\n const actualViewIndex = (value as Flow).views?.indexOf?.(\n flowNode.ref as any,\n );\n\n if (actualViewIndex !== undefined && actualViewIndex > -1) {\n const actualId = copiedValue.views?.[actualViewIndex]?.id;\n\n (copiedValue as any).navigation[navKey][nodeKey].ref =\n actualId;\n }\n }\n });\n }\n });\n }\n\n if (\"schema\" in copiedValue) {\n copiedValue.schema = this.schemaGenerator.toSchema(copiedValue.schema);\n }\n\n copiedValue.navigation = parseNavigationExpressions(\n copiedValue.navigation,\n );\n\n if (value) {\n const postProcessFlow =\n await this.hooks.postProcessFlow.call(copiedValue);\n\n return {\n value: postProcessFlow as JsonType,\n sourceMap: mergeSourceMaps(\n allSourceMaps,\n JSON.stringify(copiedValue, null, 2),\n ),\n };\n }\n }\n\n // Type has been set to \"schema\"\n return {\n value: this.schemaGenerator.toSchema(value) as JsonType,\n };\n }\n}\n","import React from \"react\";\nimport type { DefaultCompilerContentType } from \"./types\";\n\n/** Basic way of identifying the type of file based on the default content export */\nexport const fingerprintContent = (\n content: unknown,\n filename?: string,\n): DefaultCompilerContentType | undefined => {\n if (content !== null || content !== undefined) {\n if (React.isValidElement(content as any)) {\n return \"view\";\n }\n\n if (typeof content === \"object\" && \"navigation\" in (content as any)) {\n return \"flow\";\n }\n\n if (!filename || filename.includes(\"schema\")) {\n return \"schema\";\n }\n }\n};\n","import type {\n Schema,\n Navigation,\n Flow,\n Expression,\n ExpressionObject,\n NavigationFlow,\n NavigationFlowState,\n NavigationFlowViewState,\n} from \"@player-ui/types\";\nimport type { JsonType } from \"react-json-reconciler\";\nimport type { RemoveUnknownIndex, AddUnknownIndex } from \"../types\";\nimport type { DSLSchema } from \"../types\";\n\nexport type NavigationFlowReactViewState = Omit<\n NavigationFlowViewState,\n \"ref\"\n> & {\n /** The view element */\n ref: React.ReactElement | string;\n};\n\nexport type NavFlowState =\n | Exclude<NavigationFlowState, NavigationFlowViewState>\n | NavigationFlowReactViewState;\n\nexport type NavigationFlowWithReactView = Pick<\n NavigationFlow,\n \"startState\" | \"onStart\" | \"onEnd\"\n> & {\n [key: string]:\n | undefined\n | string\n | Expression\n | ExpressionObject\n | NavFlowState;\n};\n\nexport type NavigationWithReactViews = Pick<Navigation, \"BEGIN\"> &\n Record<string, string | NavigationFlowWithReactView>;\n\nexport type FlowWithoutUnknown = RemoveUnknownIndex<Flow>;\nexport type FlowWithReactViews = AddUnknownIndex<\n Omit<FlowWithoutUnknown, \"views\" | \"navigation\"> & {\n /** An array of JSX view elements */\n views?: Array<React.ReactElement>;\n\n /** The navigation element */\n navigation?: NavigationWithReactViews;\n }\n>;\n\nexport type DSLFlow = Omit<FlowWithReactViews, \"schema\"> & {\n /** A DSL compliant schema */\n schema?: DSLSchema;\n};\n\nexport type SerializeType = \"view\" | \"flow\" | \"schema\" | \"navigation\";\n\nexport type SerializablePlayerExportTypes =\n | React.ReactElement\n | FlowWithReactViews\n | Schema.Schema\n | Navigation;\n\nexport type LoggingInterface = Pick<Console, \"warn\" | \"error\" | \"log\">;\n\nexport type CompilationResult = {\n /** What type of file is generated */\n contentType: string;\n /** The output path */\n outputFile: string;\n /** the input file */\n inputFile: string;\n};\n\nexport type CompilerReturn = {\n /** the JSON value of the source */\n value: JsonType | undefined;\n\n /** The sourcemap of the content */\n sourceMap?: string;\n};\n\n/** The different type of default content items the compiler handles */\nconst DefaultCompilerContentTypes = [\"view\", \"flow\", \"schema\"] as const;\n\nexport type DefaultCompilerContentType =\n (typeof DefaultCompilerContentTypes)[number];\n\n/** Helper function to determine whether a content type is compiler default */\nexport function isDefaultCompilerContentType(\n t: string,\n): t is DefaultCompilerContentType {\n return DefaultCompilerContentTypes.includes(t as DefaultCompilerContentType);\n}\n\nexport interface SerializeContext {\n /** The type of the content being compiled */\n type: DefaultCompilerContentType;\n}\n","import {\n expression as e,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n isTemplateStringInstance,\n isBindingTemplateInstance,\n} from \"..\";\n\ntype Argument<T> =\n | string\n | boolean\n | number\n | undefined\n | BindingTemplateInstance<T>\n | ExpressionTemplateInstance<T>;\n\nconst escapePrimitive = <T>(\n val: Exclude<\n Argument<T>,\n BindingTemplateInstance<T> | ExpressionTemplateInstance<T>\n >,\n): string => {\n switch (typeof val) {\n case \"string\": {\n return `'${val}'`;\n }\n case \"undefined\": {\n return \"null\";\n }\n default: {\n return `${val}`;\n }\n }\n};\n\nconst handleBindingOrExpression = (\n val: BindingTemplateInstance | ExpressionTemplateInstance,\n) => {\n if (isBindingTemplateInstance(val)) {\n return val.toRefString();\n } else {\n return `(${val.toValue()})`;\n }\n};\n\nconst handleArgument = <T>(arg: Argument<T>): string => {\n return isTemplateStringInstance(arg)\n ? handleBindingOrExpression(arg)\n : escapePrimitive(arg);\n};\n\n/**\n * Performs an assigment of a value to a binding by returning the expression\n * {{<binding>}} = <value>\n * @param binding\n * @param value\n */\nexport const assign = <T>(\n binding: BindingTemplateInstance<any>,\n value: Argument<T>,\n): ExpressionTemplateInstance<void> => {\n return e`${binding} = ${isTemplateStringInstance(value) ? value : escapePrimitive(value)}`;\n};\n\n/**\n * Returns an equality comparison between the two values\n */\nexport const equals = <A, B>(\n a: Argument<A>,\n b: Argument<B>,\n): ExpressionTemplateInstance<boolean> => {\n return e`${handleArgument(a)} == ${handleArgument(b)}`;\n};\n\n/**\n * Returns the negated version of the binding/expression\n * by returning !(<value>)\n * @param binding Binding/Expression to invert\n * @returns Negated binding/expression\n */\nexport const not = (\n value: BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>,\n): ExpressionTemplateInstance<boolean> => {\n return e<boolean>`!(${value})`;\n};\n\n/**\n * Creates an expression for the logical or'ing of the provided values\n * e.g: <exp1> || <exp2> || ...\n * @param values Array of bindings/expressions to logically or\n * @returns boolean\n */\nexport const or = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return e`${values.map(handleBindingOrExpression).join(\" || \")}` as ExpressionTemplateInstance<boolean>;\n};\n\n/**\n * Creates an expression for the logical nor'ing of the provided values\n * e.g: !(<exp1> || <exp2> || ...)\n * @param values Array of bindings/expressions to logically nor\n * @returns boolean\n */\nexport const nor = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return not(or(...values));\n};\n\n/**\n * Creates an expression for the logical and'ing of the provided values\n * e.g: <exp1> && <exp2> && ...\n * @param values Array of bindings/expressions to logically and\n * @returns boolean\n */\nexport const and = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return e`${values.map(handleBindingOrExpression).join(\" && \")}` as ExpressionTemplateInstance<boolean>;\n};\n\n/**\n * Creates an expression for the logical nand'ing of the provided values\n * e.g: !(<exp1> && <exp2> && ...)\n * @param values Array of bindings/expressions to logically nand\n * @returns boolean\n */\nexport const nand = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return not(and(...values));\n};\n","import {\n BindingParser,\n ExpressionEvaluator,\n ExpressionHandler,\n ExpressionType,\n LocalModel,\n withParser,\n} from \"@player-ui/player\";\nimport { ExpressionTemplateInstance } from \"../string-templates\";\n\n/**\n * Test harness to make testing expressions easier.\n * Given an expreesion and an initial data model the harness will execute the expression\n * on and return the new state of the data model.\n * @param exp expression to execute\n * @param initialData data model to operate on\n * @param expressions expression handlers for functions that are called\n * @returns Final data model state\n */\nexport function testExpression(\n exp: ExpressionTemplateInstance,\n initialData: object,\n expressions?: Map<string, ExpressionHandler<any[], any>>,\n): object {\n // Setup Mock Player model and parsers\n const localModel = new LocalModel(initialData);\n const bindingParser = new BindingParser({\n get: localModel.get,\n set: localModel.set,\n evaluate: (exp: ExpressionType) => {\n return evaluator.evaluate(exp);\n },\n });\n\n const model = withParser(localModel, bindingParser.parse);\n const evaluator = new ExpressionEvaluator({ model });\n expressions?.forEach((fn, name) => evaluator.addExpressionFunction(name, fn));\n evaluator.evaluate(exp.toValue());\n return localModel.get();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAkB;;;ACAlB,mBAAkB;AAElB,mCAA6B;AAI7B,IAAM,kBAAkB,aAAAC,QAAM,cAAsB,MAAM;AAEnD,IAAM,yBAAyB,aAAAA,QAAM,cAAuB,KAAK;AAGjE,IAAM,iBAAiB,MAAM;AAClC,SAAO,aAAAA,QAAM,WAAW,eAAe;AACzC;AAGO,IAAM,mBAAmB,CAC9B,UAIG;AACH,QAAM,gBAAgB,eAAe;AAErC,SACE,6BAAAA,QAAA;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,OAAO;AAAA,QACL,kBAAkB,SAAS,SAAY;AAAA,QACvC,MAAM;AAAA,MACR,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AAAA;AAAA,IAEV,MAAM;AAAA,EACT;AAEJ;AAGO,IAAM,aAAa,CACxB,UAIG;AACH,MAAI,MAAM,IAAI;AACZ,WACE,6BAAAA,QAAA,cAAC,gBAAgB,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;AAKO,IAAM,SAAS,CACpB,GACA,MACwC;AACxC,SAAO,aAAI,eAAe,CAAC,CAAC,OAAO,eAAe,CAAC,CAAC;AACtD;AAQO,IAAM,MAAM,CACjB,UACwC;AACxC,SAAO,eAAe,KAAK;AAC7B;AAQO,IAAM,KAAK,IACb,WAGqC;AACxC,SAAO,aAAI,OAAO,IAAI,yBAAyB,EAAE,KAAK,MAAM,CAAC;AAC/D;AAQO,IAAM,MAAM,IACd,WAGqC;AACxC,SAAO,IAAI,GAAG,GAAG,MAAM,CAAC;AAC1B;AAQO,IAAM,MAAM,IACd,WAGqC;AACxC,SAAO,aAAI,OAAO,IAAI,yBAAyB,EAAE,KAAK,MAAM,CAAC;AAC/D;AAQO,IAAM,OAAO,IACf,WAGqC;AACxC,SAAO,IAAI,IAAI,GAAG,MAAM,CAAC;AAC3B;;;AC5IA,IAAAC,iBAOO;AAYA,SAAS,eACd,KACA,aACA,aACQ;AAER,QAAM,aAAa,IAAI,0BAAW,WAAW;AAC7C,QAAM,gBAAgB,IAAI,6BAAc;AAAA,IACtC,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,UAAU,CAACC,SAAwB;AACjC,aAAO,UAAU,SAASA,IAAG;AAAA,IAC/B;AAAA,EACF,CAAC;AAED,QAAM,YAAQ,2BAAW,YAAY,cAAc,KAAK;AACxD,QAAM,YAAY,IAAI,mCAAoB,EAAE,MAAM,CAAC;AACnD,eAAa,QAAQ,CAAC,IAAI,SAAS,UAAU,sBAAsB,MAAM,EAAE,CAAC;AAC5E,YAAU,SAAS,IAAI,QAAQ,CAAC;AAChC,SAAO,WAAW,IAAI;AACxB;","names":["import_react","React","React","React","element","binding","React","AssetWrapper","import_react","import_react_json_reconciler","React","import_react","import_react_json_reconciler","React","import_react","import_react_json_reconciler","import_tapable_ts","import_react","React","React","binding","import_player","exp"]}
1
+ {"version":3,"sources":["../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/components.tsx","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/auto-id.tsx","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/utils.tsx","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/string-templates/index.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/switch.tsx","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/template.tsx","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/schema.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/compiler.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/utils.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/compiler/types.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/expressions/native.ts","../../../../../../../../../../../../../execroot/_main/bazel-out/k8-fastbuild/bin/language/dsl/react/src/expressions/testing.ts"],"sourcesContent":["export * from \"./components\";\nexport * from \"./auto-id\";\nexport * from \"./types\";\nexport * from \"./string-templates\";\nexport * from \"./utils\";\nexport * from \"./switch\";\nexport * from \"./template\";\nexport * from \"react-json-reconciler\";\nexport * from \"./compiler/schema\";\nexport * from \"./compiler\";\nexport * from \"./compiler/types\";\nexport * from \"./expressions/native\";\nexport * from \"./expressions/testing\";\n","import React from \"react\";\nimport type { ObjectNode, PropertyNode } from \"react-json-reconciler\";\nimport type { View as ViewType } from \"@player-ui/types\";\nimport type { PlayerApplicability, WithChildren } from \"./types\";\nimport {\n IDProvider,\n IDSuffixProvider,\n IndexSuffixStopContext,\n OptionalIDSuffixProvider,\n useGetIdPrefix,\n} from \"./auto-id\";\nimport {\n normalizeText,\n normalizeToCollection,\n toJsonElement,\n toJsonProperties,\n flattenChildren,\n mergeRefs,\n} from \"./utils\";\nimport { isBindingTemplateInstance } from \"./string-templates\";\n\nexport type AssetProps = PlayerApplicability & {\n /** id of the asset */\n id?: string;\n\n /** the asset type */\n type: string;\n\n /** Any other properties on the asset */\n children?: React.ReactNode;\n\n /** other things that we don't know about */\n [key: string]: unknown;\n};\n\nexport const SlotContext = React.createContext<\n | {\n /** The property name for the slot */\n propertyName: string;\n /** If the slot represents an array */\n isArray: boolean;\n /** If the items in the slot should be wrapped in an \"asset\" object */\n wrapInAsset: boolean;\n /** Other props to add to the slot */\n additionalProperties?: any;\n /** The ref to the property node */\n ref: React.RefObject<PropertyNode>;\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n }\n | undefined\n>(undefined);\n\n/**\n * Wraps the children in an `asset` object.\n * Additional props are added to the top level object\n */\nexport const AssetWrapper = React.forwardRef<\n ObjectNode,\n WithChildren<{ [key: string]: unknown }>\n>(function AssetWrapper(props, ref) {\n const { children, ...rest } = props;\n\n return (\n <obj ref={ref}>\n {toJsonProperties(rest)}\n <property name=\"asset\">{children}</property>\n </obj>\n );\n});\n\n/** Create a ID property for a node */\nexport const GeneratedIDProperty = (props: {\n /** the id to use if supplied by the user */\n id?: string;\n}) => {\n const currentPrefixId = useGetIdPrefix();\n return <property name=\"id\">{props.id ?? currentPrefixId}</property>;\n};\n\n/** An asset */\nexport const Asset = React.forwardRef<ObjectNode, AssetProps>((props, ref) => {\n const { id, type, applicability, children, ...rest } = props;\n const slotContext = React.useContext(SlotContext);\n const localRef = React.useRef<ObjectNode>(null);\n const Wrapper = slotContext?.wrapInAsset ? AssetWrapper : React.Fragment;\n\n const getResolvedValue = () => {\n if (applicability !== undefined) {\n if (typeof applicability === \"boolean\") {\n return applicability;\n }\n if (isBindingTemplateInstance(applicability)) {\n // converts bindings to use {{ }}\n return applicability.toString();\n }\n return applicability.toValue();\n }\n };\n\n return (\n <Wrapper\n ref={slotContext?.wrapInAsset ? mergeRefs([ref, localRef]) : undefined}\n {...(slotContext?.wrapInAsset && slotContext?.additionalProperties\n ? slotContext?.additionalProperties\n : {})}\n >\n <OptionalIDSuffixProvider wrapperRef={localRef}>\n <SlotContext.Provider value={undefined}>\n <IDProvider id={id}>\n <obj\n ref={\n slotContext?.wrapInAsset\n ? undefined\n : mergeRefs([ref, localRef])\n }\n >\n <GeneratedIDProperty id={id} />\n <property name=\"type\">{type}</property>\n {applicability !== undefined && (\n <property name=\"applicability\">\n <value value={getResolvedValue()} />\n </property>\n )}\n {toJsonProperties(rest)}\n {children}\n </obj>\n </IDProvider>\n </SlotContext.Provider>\n </OptionalIDSuffixProvider>\n </Wrapper>\n );\n});\n\nAsset.displayName = \"Asset\";\n\nAsset.defaultProps = {\n id: undefined,\n children: undefined,\n};\n\nexport const View = React.forwardRef<ObjectNode, AssetProps & ViewType>(\n (props, ref) => {\n const { validation, children, ...rest } = props;\n\n return (\n <Asset ref={ref} {...rest}>\n {validation && (\n <property key=\"validation\" name=\"validation\">\n {toJsonElement(validation, \"validation\", {\n propertiesToSkip: [\"ref\"],\n })}\n </property>\n )}\n {children}\n </Asset>\n );\n },\n);\n\nView.displayName = \"View\";\n\nView.defaultProps = {\n id: undefined,\n children: undefined,\n};\n\n/** A component to generate a named property slot */\nexport const Slot = (props: {\n /** The name of the slot */\n name: string;\n\n /** if the slot is an array or single object */\n isArray?: boolean;\n\n /** if each item should be wrapped in an asset */\n wrapInAsset?: boolean;\n\n /** Any children to render in the slot */\n children?: React.ReactNode;\n\n /** Other properties to add to the slot */\n additionalProperties?: any;\n\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n}) => {\n const { TextComp, CollectionComp } = props;\n const children = flattenChildren(props.children);\n const propRef = React.useRef<PropertyNode>(null);\n\n return (\n <property ref={propRef} name={props.name}>\n <IDSuffixProvider suffix={props.name}>\n <IndexSuffixStopContext.Provider value={false}>\n <SlotContext.Provider\n value={{\n ref: propRef,\n propertyName: props.name,\n wrapInAsset: props.wrapInAsset ?? false,\n isArray: props.isArray ?? false,\n additionalProperties: props.additionalProperties,\n TextComp,\n CollectionComp,\n }}\n >\n {props.isArray && (\n <array>\n {React.Children.map(children, (child, index) => {\n return (\n <React.Fragment key={`${props.name}-${index}`}>\n {normalizeText({ node: child, TextComp })}\n </React.Fragment>\n );\n })}\n </array>\n )}\n\n {!props.isArray &&\n normalizeToCollection({\n node: children,\n TextComp,\n CollectionComp,\n })}\n </SlotContext.Provider>\n </IndexSuffixStopContext.Provider>\n </IDSuffixProvider>\n </property>\n );\n};\n\n/** Create a slot for a given property */\nexport function createSlot<SlotProps = unknown>(options: {\n /** The name of the slot */\n name: string;\n\n /** if the slot is an array or single object */\n isArray?: boolean;\n\n /** if each item should be wrapped in an asset */\n wrapInAsset?: boolean;\n\n /** Any children to render in the slot */\n children?: React.ReactNode;\n\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n}) {\n // eslint-disable-next-line react/display-name\n return (\n props: {\n /** An object to include in this property */\n children?: React.ReactNode;\n } & SlotProps,\n ) => {\n const { children, ...other } = props;\n return (\n <Slot {...options} additionalProperties={other}>\n {children}\n </Slot>\n );\n };\n}\n","import React from \"react\";\nimport type { ObjectNode, JsonNode } from \"react-json-reconciler\";\nimport { flattenNodes } from \"react-json-reconciler\";\nimport { SlotContext } from \"./components\";\nimport type { WithChildren } from \"./types\";\n\nconst IDSuffixContext = React.createContext<string>(\"root\");\n\nexport const IndexSuffixStopContext = React.createContext<boolean>(false);\n\n/** Get the generated id */\nexport const useGetIdPrefix = () => {\n return React.useContext(IDSuffixContext);\n};\n\n/** Add a suffix to a generated id */\nexport const IDSuffixProvider = (\n props: WithChildren<{\n /** The suffix to append */\n suffix: string;\n }>,\n) => {\n const currentPrefix = useGetIdPrefix();\n\n return (\n <IDSuffixContext.Provider\n value={[\n currentPrefix === \"root\" ? undefined : currentPrefix,\n props.suffix,\n ]\n .filter(Boolean)\n .join(\"-\")}\n >\n {props.children}\n </IDSuffixContext.Provider>\n );\n};\n\n/** Override the generated id with the supplied one */\nexport const IDProvider = (\n props: WithChildren<{\n /** The new id to use */\n id?: string;\n }>,\n) => {\n if (props.id) {\n return (\n <IDSuffixContext.Provider value={props.id}>\n {props.children}\n </IDSuffixContext.Provider>\n );\n }\n\n return <>{props.children}</>;\n};\n\n/** Get the index of an item in a slot */\nexport const useIndexInSlot = (ref: React.RefObject<JsonNode>) => {\n const [index, setIndex] = React.useState(-1);\n const slotContext = React.useContext(SlotContext);\n\n React.useEffect(() => {\n if (!slotContext?.isArray) {\n throw new Error(\"Cannot get index in non-array slot\");\n }\n\n if (ref.current && slotContext?.ref.current?.valueNode?.type === \"array\") {\n const allChildren = flattenNodes(\n slotContext.ref.current.valueNode.children,\n );\n const foundIndex = allChildren.indexOf(ref.current);\n\n if (foundIndex !== index) {\n setIndex(foundIndex);\n }\n }\n }, [index, ref, slotContext?.isArray, slotContext?.ref]);\n\n return index;\n};\n\n/** Add the index to the id path when in an array slot */\nexport const IDSuffixIndexProvider = (\n props: WithChildren<{\n /** The ref to use */\n wrapperRef: React.RefObject<JsonNode>;\n\n /** if the suffix is in a template, the id to use */\n templateIndex?: string;\n }>,\n) => {\n const slotIndex = useIndexInSlot(props.wrapperRef);\n\n const stopIndex = React.useContext(IndexSuffixStopContext);\n\n if (stopIndex) {\n return <>{props.children}</>;\n }\n\n return (\n <IDSuffixProvider suffix={props.templateIndex ?? String(slotIndex)}>\n <IndexSuffixStopContext.Provider value>\n {props.children}\n </IndexSuffixStopContext.Provider>\n </IDSuffixProvider>\n );\n};\n\n/** Wrap a slot with the index if in an array slot */\nexport const OptionalIDSuffixProvider = (\n props: WithChildren<{\n /** The ref to walk upwards and use as an index */\n wrapperRef: React.RefObject<JsonNode>;\n\n /** if the suffix is in a template, the id to use */\n templateIndex?: string;\n }>,\n) => {\n const slotContext = React.useContext(SlotContext);\n\n if (slotContext?.isArray) {\n return (\n <IDSuffixIndexProvider\n wrapperRef={props.wrapperRef}\n templateIndex={props.templateIndex}\n >\n {props.children}\n </IDSuffixIndexProvider>\n );\n }\n\n return <>{props.children}</>;\n};\n\n/** An object wrapper that tracks its index from a parent */\nexport const ObjectWithIndexTracking = (props: WithChildren) => {\n const ref = React.useRef<ObjectNode>(null);\n\n return (\n <OptionalIDSuffixProvider wrapperRef={ref}>\n <obj ref={ref}>{props.children}</obj>\n </OptionalIDSuffixProvider>\n );\n};\n","import * as React from \"react\";\nimport {\n expression,\n ExpressionTemplateInstance,\n isTemplateStringInstance,\n TemplateStringComponent,\n} from \"./string-templates\";\nimport type {\n ExpressionArray,\n toJsonOptions,\n WithTemplateTypes,\n} from \"./types\";\nimport { Schema } from \"@player-ui/types\";\nimport { ExpressionHandler } from \"@player-ui/player\";\n\n/** Get an array version of the value */\nexport function toArray<T>(val: T | Array<T>): Array<T> {\n return Array.isArray(val) ? val : [val];\n}\n\n/** Create a component version */\nexport function toJsonElement(\n value: any,\n indexOrKey?: number | string,\n options?: toJsonOptions,\n): React.ReactElement {\n const indexProp = typeof indexOrKey === \"number\" ? { key: indexOrKey } : null;\n\n /** Allow users to pass in BindingTemplateInstance and ExpressionTemplateInstance directly without turning them into strings first */\n if (isTemplateStringInstance(value)) {\n if (\n typeof indexOrKey === \"string\" &&\n options?.propertiesToSkip?.includes(indexOrKey)\n ) {\n return <value {...indexProp}>{value.toValue()}</value>;\n }\n\n return <value {...indexProp}>{value.toRefString()}</value>;\n }\n\n if (Array.isArray(value)) {\n return (\n <array {...indexProp}>\n {value.map((item, idx) => toJsonElement(item, idx, options))}\n </array>\n );\n }\n\n if (typeof value === \"object\" && value !== null) {\n return (\n <obj {...indexProp}>\n {Object.keys(value).map((key) => (\n <property key={key} name={key}>\n {toJsonElement(value[key], key, options)}\n </property>\n ))}\n </obj>\n );\n }\n\n return <value {...indexProp} value={value} />;\n}\n\n/** Create a fragment for the properties */\nexport function toJsonProperties(\n value: Record<string, any>,\n options: toJsonOptions = { propertiesToSkip: [\"applicability\"] },\n): React.JSX.Element[] {\n return Object.keys(value).map((key) => {\n return (\n <property key={key} name={key}>\n {toJsonElement(value[key], key, options)}\n </property>\n );\n });\n}\n\n/** Create a text asset if needed */\nexport function normalizeText(options: {\n /** The current node */\n node: React.ReactNode;\n\n /** A component to render a text asset */\n TextComp?: React.ComponentType<any>;\n}): React.ReactNode {\n const { node, TextComp } = options;\n\n const nodeArr = React.Children.toArray(node);\n\n if (\n nodeArr.every(\n (n) => React.isValidElement(n) && n.type !== TemplateStringComponent,\n )\n ) {\n return node;\n }\n\n if (TextComp) {\n return <TextComp>{nodeArr}</TextComp>;\n }\n\n throw new Error(\n `Tried to convert node to Text Asset, but no Component was supplied.`,\n );\n}\n\n/** Create a collection if needed */\nexport function normalizeToCollection(options: {\n /** the node to look at */\n node: React.ReactNode;\n\n /** A Text asset */\n TextComp?: React.ComponentType;\n\n /** A collection asset */\n CollectionComp?: React.ComponentType<any>;\n}): React.ReactNode {\n const { node, CollectionComp } = options;\n\n if (\n React.Children.count(node) > 1 &&\n React.Children.toArray(node).every((n) => typeof n !== \"string\")\n ) {\n if (!CollectionComp) {\n throw new Error(\n `Tried to convert array to a collection asset, but no Component was given.`,\n );\n }\n\n return <CollectionComp>{node}</CollectionComp>;\n }\n\n return normalizeText({ ...options, node });\n}\n\ntype ReactChildArray = ReturnType<typeof React.Children.toArray>;\n\n/**\n *\n * Hoisted from https://github.com/gregberge/react-flatten-children/blob/master/src/index.tsx\n * Peer dependencies were wrong and can't be reasonably patch it everywhere\n */\nexport function flattenChildren(children: React.ReactNode): ReactChildArray {\n const childrenArray = React.Children.toArray(children);\n return childrenArray.reduce((flatChildren: ReactChildArray, child) => {\n if ((child as React.ReactElement<any>).type === React.Fragment) {\n return flatChildren.concat(\n flattenChildren((child as React.ReactElement<any>).props.children),\n );\n }\n\n flatChildren.push(child);\n\n return flatChildren;\n }, []);\n}\n/**\n * Hoisted from https://github.com/gregberge/react-merge-refs/blob/main/src/index.tsx\n * Published packages are ESM only or have bad esm distributions causing issues when\n * used in an esm environment\n */\nexport function mergeRefs<T = any>(\n refs: Array<\n React.MutableRefObject<T> | React.LegacyRef<T> | undefined | null\n >,\n): React.RefCallback<T> {\n return (value) => {\n refs.forEach((ref) => {\n if (typeof ref === \"function\") {\n ref(value);\n } else if (ref != null) {\n (ref as React.MutableRefObject<T | null>).current = value;\n }\n });\n };\n}\n\ntype TypesToReferences<T> = {\n [P in keyof T]: T[P] extends Schema.DataType<infer DT> ? DT : unknown;\n};\n\n/** Generates object reference properties from the provided object */\nexport function getObjectReferences<\n OriginalPropertiesObject,\n ReferencesPropertyObject,\n>(\n propertiesObject: OriginalPropertiesObject,\n): TypesToReferences<ReferencesPropertyObject> {\n const result: any = {};\n\n for (const itemProp in propertiesObject) {\n if (Object.prototype.hasOwnProperty.call(propertiesObject, itemProp)) {\n const refName = `${itemProp}Ref`;\n result[refName as keyof ReferencesPropertyObject] = { type: itemProp };\n }\n }\n\n return result;\n}\n\nfunction parseArg(arg: unknown, deref = false): any {\n if (isTemplateStringInstance(arg)) {\n return `'${deref ? arg.toRefString() : arg.toValue()}'`;\n } else if (Array.isArray(arg)) {\n return `[${arg.map((a) => parseArg(a, true)).join(\", \")}]`;\n } else if (typeof arg === \"string\") {\n return `'${arg}'`;\n } else {\n return arg;\n }\n}\n\nfunction generateDSLFunction<R>(\n name: string,\n args: Array<unknown>,\n): ExpressionTemplateInstance<R> {\n const expressionArgs: Array<unknown> = [];\n args.forEach((arg) => {\n expressionArgs.push(parseArg(arg));\n });\n\n return expression`${name}(${expressionArgs.join(\", \")})`;\n}\n\n/**\n * Convert an single ExpressionHandler function to a DSL expression function\n */\nexport function wrapFunctionInType<T extends Array<unknown>, R>(\n fn: ExpressionHandler<T, R>,\n): (...args: WithTemplateTypes<T>) => ExpressionTemplateInstance<R> {\n return (...args: WithTemplateTypes<T>): ExpressionTemplateInstance<R> => {\n return generateDSLFunction(fn.name, args);\n };\n}\n\n/**\n * Create a DSL Expression generation function by name and args specified by\n * generic parameters\n */\nexport function makeFunctionByName<T extends Array<unknown>, R>(\n name: string,\n): (...args: WithTemplateTypes<T>) => ExpressionTemplateInstance<R> {\n return (...args: WithTemplateTypes<T>): ExpressionTemplateInstance<R> => {\n return generateDSLFunction(name, args);\n };\n}\n\n/**\n * Takes map of functions and wraps them in a DSL syntax generator\n */\nexport function mapExpressionHandlersToFunctions<\n T extends Record<string, ExpressionHandler<any, any>>,\n>(functions: T): ExpressionArray<T> {\n const result: any = {};\n for (const fn of Object.values(functions)) {\n result[fn.name] = wrapFunctionInType(fn);\n }\n return result;\n}\n","import * as React from \"react\";\nimport { parseExpression, isErrorWithLocation } from \"@player-ui/player\";\n\nexport type TemplateInstanceRefStringContext = \"binding\" | \"expression\";\nexport interface TemplateRefStringOptions {\n /** If this template string is inside of another binding or expression */\n nestedContext?: TemplateInstanceRefStringContext;\n}\nexport interface TemplateInstanceRefStringOptions {\n /** The array of strings for the template */\n strings: ReadonlyArray<string>;\n /** the other data that's present in the template */\n other: Array<string | TemplateStringType>;\n\n /** If this template string is inside of another binding or expression */\n nestedContext?: TemplateInstanceRefStringContext;\n\n /** Convert the value to a reference nested in the given context */\n toRefString: (\n options: TemplateRefStringOptions | undefined,\n value: string,\n ) => string;\n}\n\nconst OpaqueIdentifier: unique symbol = Symbol(\"TemplateStringType\");\n\nexport type TemplateStringType<\n T extends string | number | boolean | unknown = any,\n> = React.ReactElement & {\n /** An identifier to show that this is a template type */\n [OpaqueIdentifier]: true;\n /** The value of the template string when in another string */\n toString: () => string;\n /** the raw value of the template string */\n toValue: () => string;\n /** the dereferenced value when used in another */\n toRefString: (options?: TemplateRefStringOptions) => T;\n /** Underlying type of this binding */\n type: T;\n};\n\nexport type BindingTemplateInstance<\n DataType extends string | number | boolean | unknown = any,\n> = TemplateStringType<DataType> & {\n /** An identifier for a binding instance */\n __type: \"binding\";\n};\n\nexport type ExpressionTemplateInstance<\n ReturnType extends string | number | boolean | unknown = any,\n> = TemplateStringType<ReturnType> & {\n /** The identifier for an expression instance */\n __type: \"expression\";\n};\n\n/** A react component for rendering a template string type */\nexport const TemplateStringComponent = (props: {\n /** The string value of the child template string */\n value: string;\n}): React.ReactElement<{\n value: string;\n}> => {\n return React.createElement(\n \"value\",\n {\n value: props.value,\n },\n null,\n );\n};\n\n/** The generic template string handler */\nconst createTemplateInstance = (\n options: TemplateInstanceRefStringOptions,\n): TemplateStringType => {\n const value = options.strings.reduce((sum, next, i) => {\n const element = options.other[i];\n if (typeof element === \"string\") {\n return sum + next + element;\n }\n\n return sum + next + (element?.toRefString(options) ?? \"\");\n }, \"\");\n\n /** Try to parse the expression as valid */\n if (options.nestedContext === \"expression\") {\n try {\n parseExpression(value);\n } catch (e) {\n if (e instanceof Error) {\n let message: string;\n if (isErrorWithLocation(e)) {\n message = `${e} in expression: \\r\\n ${\n value.slice(0, e.index + 1) + \"\\u2588\" + value.slice(e.index + 1)\n }`;\n } else {\n message = `${e} in expression ${value}`;\n }\n throw new Error(message);\n }\n\n throw new Error(`Unknown problem parsing expression ${e}`);\n }\n }\n\n /** get the unwrapped version */\n const toString = () => {\n return options.toRefString({}, value);\n };\n\n /** get the raw value of the template */\n const toValue = () => {\n return value;\n };\n\n /** This lets us use it directly as a child element in React */\n const element = React.createElement(\n TemplateStringComponent,\n {\n value: toString(),\n },\n null,\n ) as TemplateStringType;\n\n return {\n ...element,\n [OpaqueIdentifier]: true,\n toString,\n toValue,\n toRefString: (refStringOptions?: TemplateRefStringOptions) => {\n return options.toRefString(refStringOptions, value);\n },\n };\n};\n\n/** Helper for Iterating the binding to add a dynamic numeric value to each index found */\nconst addBindingIndexes = (binding: string): string => {\n let currentIndex = 0;\n\n return binding.replace(/_index_/g, () => {\n const result = `_index${currentIndex > 0 ? currentIndex : \"\"}_`;\n currentIndex += 1;\n\n return result;\n });\n};\n\n/** Creating an instance of a handler for bindings */\nconst createBindingTemplateInstance = (\n options: Omit<TemplateInstanceRefStringOptions, \"toRefString\">,\n): BindingTemplateInstance => {\n const templateInstance = createTemplateInstance({\n ...options,\n strings: options.strings.map((element: string) =>\n addBindingIndexes(element),\n ),\n other: options.other.map((element) =>\n typeof element === \"string\" ? addBindingIndexes(element) : element,\n ),\n toRefString: (context, value) => {\n return `{{${value}}}`;\n },\n }) as BindingTemplateInstance;\n\n templateInstance.__type = \"binding\";\n\n return templateInstance;\n};\n\n/** Creating an instance of a handler for bindings */\nconst createExpressionTemplateInstance = (\n options: Omit<TemplateInstanceRefStringOptions, \"toRefString\">,\n) => {\n const templateInstance = createTemplateInstance({\n ...options,\n toRefString: (contextOptions, value) => {\n if (contextOptions?.nestedContext === \"expression\") {\n return value;\n }\n\n const inBinding = contextOptions?.nestedContext === \"binding\";\n return `${inBinding ? \"`\" : \"@[\"}${value}${inBinding ? \"`\" : \"]@\"}`;\n },\n }) as ExpressionTemplateInstance;\n\n templateInstance.__type = \"expression\";\n\n return templateInstance;\n};\n\n/** A tagged-template constructor for a binding */\nexport const binding = <T>(\n strings: TemplateStringsArray,\n ...nested: Array<TemplateStringType | string>\n): BindingTemplateInstance<T> => {\n return createBindingTemplateInstance({\n strings,\n other: nested,\n nestedContext: \"binding\",\n });\n};\n\n/** A tagged-template constructor for an expression */\nexport const expression = <T>(\n strings: TemplateStringsArray,\n ...nested: Array<\n ExpressionTemplateInstance | BindingTemplateInstance | string\n >\n): ExpressionTemplateInstance<T> => {\n return createExpressionTemplateInstance({\n strings,\n other: nested,\n nestedContext: \"expression\",\n });\n};\n\n/** Check if a value is a template string */\nexport const isTemplateStringInstance = (\n val: unknown,\n): val is ExpressionTemplateInstance | BindingTemplateInstance => {\n return (\n val !== null &&\n typeof val === \"object\" &&\n (val as any)[OpaqueIdentifier] === true\n );\n};\n\n/** Check if a value is a binding */\nexport const isBindingTemplateInstance = (\n val: unknown,\n): val is BindingTemplateInstance => {\n return (\n val !== null &&\n typeof val === \"object\" &&\n (val as any)[OpaqueIdentifier] === true &&\n (val as BindingTemplateInstance).__type === \"binding\"\n );\n};\n","import type { PropsWithChildren } from \"react\";\nimport React from \"react\";\nimport type { ArrayNode, JsonNode, ObjectNode } from \"react-json-reconciler\";\nimport { flattenNodes } from \"react-json-reconciler\";\nimport { SlotContext } from \".\";\nimport { IDSuffixProvider, OptionalIDSuffixProvider } from \"./auto-id\";\nimport type {\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n} from \"./string-templates\";\nimport { isTemplateStringInstance } from \"./string-templates\";\nimport { normalizeToCollection, toJsonProperties } from \"./utils\";\n\nexport interface SwitchProps {\n /** defaults to a staticSwitch */\n isDynamic?: boolean;\n}\n\nconst SwitchContext = React.createContext<\n SwitchProps & {\n /** A text component if we hit a string but expect an asset */\n TextComp?: React.ComponentType;\n\n /** A component to create a collection asset is we get an array but need a single element */\n CollectionComp?: React.ComponentType;\n }\n>({});\n\n/**\n * Switches allow users to fork content between 1 or more assets\n */\nexport const Switch = (props: PropsWithChildren<SwitchProps>) => {\n const slotContext = React.useContext(SlotContext);\n const propertyNode = React.useRef<ObjectNode>(null);\n\n return (\n <obj ref={propertyNode}>\n <SwitchContext.Provider\n value={{\n ...props,\n TextComp: slotContext?.TextComp,\n CollectionComp: slotContext?.CollectionComp,\n }}\n >\n <OptionalIDSuffixProvider wrapperRef={propertyNode}>\n <property name={props.isDynamic ? \"dynamicSwitch\" : \"staticSwitch\"}>\n <SlotContext.Provider value={undefined}>\n <array>{props.children}</array>\n </SlotContext.Provider>\n </property>\n </OptionalIDSuffixProvider>\n </SwitchContext.Provider>\n {slotContext?.additionalProperties &&\n toJsonProperties(slotContext.additionalProperties)}\n </obj>\n );\n};\n\nexport interface CaseProps {\n /** the test for this case statement */\n exp?: ExpressionTemplateInstance | BindingTemplateInstance | boolean;\n}\n\n/** Find the first parent array */\nconst findParentArray = (node: JsonNode): ArrayNode => {\n if (node.type === \"array\") {\n return node;\n }\n\n if (node.parent) {\n return findParentArray(node.parent);\n }\n\n throw new Error(\"can't find parent array\");\n};\n\n/** Find the index of the item in an array */\nconst findArrayIndex = (node: JsonNode): number => {\n const parentArray = findParentArray(node);\n const allSearch = flattenNodes(parentArray.children);\n return allSearch.indexOf(node);\n};\n\n/** A case for a switch */\nconst Case = (props: PropsWithChildren<CaseProps>) => {\n const slotContext = React.useContext(SlotContext);\n const switchContext = React.useContext(SwitchContext);\n const [caseIndex, setCaseIndex] = React.useState(-1);\n const caseNode = React.useRef<ObjectNode>(null);\n\n React.useLayoutEffect(() => {\n if (caseNode.current) {\n const index = findArrayIndex(caseNode.current);\n if (index !== caseIndex) {\n setCaseIndex(index);\n }\n }\n }, [caseIndex]);\n\n let expValue: string | boolean = true;\n\n if (props.exp !== undefined) {\n expValue = isTemplateStringInstance(props.exp)\n ? props.exp.toValue()\n : props.exp;\n }\n\n return (\n <obj ref={caseNode}>\n <property name=\"case\">\n <value value={expValue} />\n </property>\n <IDSuffixProvider\n suffix={`${\n switchContext.isDynamic ? \"dynamicSwitch\" : \"staticSwitch\"\n }-${caseIndex}`}\n >\n <SlotContext.Provider\n value={\n slotContext ? { ...slotContext, wrapInAsset: false } : undefined\n }\n >\n <property name=\"asset\">\n {normalizeToCollection({\n node: props.children,\n TextComp: switchContext?.TextComp,\n CollectionComp: switchContext?.CollectionComp,\n })}\n </property>\n </SlotContext.Provider>\n </IDSuffixProvider>\n </obj>\n );\n};\n\nSwitch.Case = Case;\n","import React from \"react\";\nimport type { ObjectNode, JsonNode } from \"react-json-reconciler\";\nimport {\n ArrayNode,\n PropertyNode,\n ValueNode,\n createPortal,\n ProxyNode,\n toJSON,\n} from \"react-json-reconciler\";\nimport { OptionalIDSuffixProvider } from \"./auto-id\";\nimport type { BindingTemplateInstance } from \"./string-templates\";\nimport type { WithChildren } from \"./types\";\nimport { toJsonElement } from \"./utils\";\n\nexport interface TemplateContextType {\n /** The number of nested templates */\n depth: number;\n}\n\nexport const TemplateContext: React.Context<TemplateContextType> =\n React.createContext<TemplateContextType>({\n depth: 0,\n });\n\nexport interface TemplateProps {\n /** The source binding */\n data: BindingTemplateInstance;\n\n /** The target property */\n output?: string;\n\n /** The template value */\n children: React.ReactNode;\n\n /** boolean that specifies whether template should recompute when data changes */\n dynamic?: boolean;\n\n /** Specifies the expanded template placement in relation to existing elements*/\n placement?: \"append\" | \"prepend\";\n}\n\n/**\n * Represents the position information for template insertion\n */\ninterface PositionInfo {\n placement?: \"append\" | \"prepend\";\n insertionIndex?: number;\n}\n\n/**\n * Determines placement based on its proxy node and uses that for AST parity\n */\nfunction determinePositionInfo(proxyNode: ProxyNode | null): PositionInfo {\n const result: PositionInfo = {\n placement: undefined,\n insertionIndex: undefined,\n };\n\n if (!proxyNode || !proxyNode.parent) {\n return result;\n }\n\n if (proxyNode.parent.type === \"array\") {\n const parentArray = proxyNode.parent;\n const proxyIndex = parentArray.items.indexOf(proxyNode);\n\n // Check if there are any non-proxy items before this proxy\n const hasNonProxyBefore = parentArray.items\n .slice(0, proxyIndex)\n .some((item) => item.type !== \"proxy\");\n\n const hasNonProxyAfter = parentArray.items\n .slice(proxyIndex + 1)\n .some((item) => item.type !== \"proxy\");\n\n if (hasNonProxyBefore) {\n result.placement = \"append\";\n } else if (hasNonProxyAfter) {\n result.placement = \"prepend\";\n }\n }\n\n const containingSlot = proxyNode.parent?.parent;\n if (\n containingSlot &&\n containingSlot.type === \"property\" &&\n containingSlot.keyNode.type === \"value\"\n ) {\n const parentObject = getParentObject(proxyNode);\n if (parentObject) {\n const index = parentObject.properties.findIndex((properties) => {\n return properties.keyNode.value === containingSlot.keyNode.value;\n });\n\n // Assigns AST ordering based on placement\n if (index !== -1) {\n result.insertionIndex =\n result.placement === \"prepend\" ? index : index + 1;\n }\n }\n }\n\n return result;\n}\n\n/** Add a template instance to the object */\nfunction addTemplateToObject(\n obj: ObjectNode,\n templateObj: ObjectNode,\n templateParentNodeType: string,\n insertionIndex: number | undefined,\n): () => void {\n // find a template property\n // add one if none exists\n\n let templateProp = obj.properties.find(\n (p) => p.keyNode.value === \"template\" && p.valueNode?.type === \"array\",\n );\n\n if (!templateProp) {\n templateProp = new PropertyNode(new ValueNode(\"template\"), new ArrayNode());\n templateProp.parent = obj;\n obj.properties.splice(\n insertionIndex ?? obj.properties.length - 1,\n 0,\n templateProp,\n );\n }\n\n const templateItems = templateProp.valueNode as ArrayNode;\n\n templateItems.items.push(templateObj);\n\n templateObj.parent = templateItems;\n\n const templateParentProp = obj.properties.find(\n (p) =>\n p.keyNode.value === templateParentNodeType &&\n p.valueNode?.type === \"array\",\n );\n\n if (templateParentProp) {\n const indexOfTemplateParent = obj.properties.indexOf(templateParentProp, 1);\n const templateParentValueNode =\n obj.properties[indexOfTemplateParent]?.valueNode;\n if (templateParentValueNode) {\n const templateParentArray = toJSON(templateParentValueNode);\n\n // Delete the parent of template if it is an empty array\n if (\n Array.isArray(templateParentArray) &&\n templateParentArray.length === 0\n ) {\n obj.properties.splice(indexOfTemplateParent, 1);\n }\n }\n }\n\n return () => {\n // Remove the template item from the list\n templateItems.items = templateItems.items.filter((t) => t !== templateObj);\n\n // Clean up the whole template if it's removed\n if (templateItems.children.length === 0 && templateProp) {\n obj.properties.splice(obj.properties.indexOf(templateProp, 1));\n }\n };\n}\n\n/** Context provider wrapper to handle nested templates */\nconst TemplateProvider = (props: WithChildren) => {\n const baseContext = React.useContext(TemplateContext);\n\n return (\n <TemplateContext.Provider value={{ depth: baseContext.depth + 1 }}>\n {props.children}\n </TemplateContext.Provider>\n );\n};\n\n/** Find the first object node in the tree */\nconst getParentObject = (node: JsonNode): ObjectNode | undefined => {\n if (node.type === \"object\") {\n return node;\n }\n\n if (node.parent) {\n return getParentObject(node.parent);\n }\n};\n\n/** Find the property of the node on the parent */\nconst getParentProperty = (node: JsonNode): PropertyNode | undefined => {\n if (node.type === \"property\") {\n return node;\n }\n\n if (node.parent) {\n return getParentProperty(node.parent);\n }\n};\n\n/** A template allows users to dynamically map over an array of data */\nexport const Template = (props: TemplateProps): React.JSX.Element => {\n const baseContext = React.useContext(TemplateContext);\n const dynamicProp = props.dynamic ?? false;\n const [outputProp, setOutputProp] = React.useState<string | undefined>(\n props.output,\n );\n const proxyRef = React.useRef<ProxyNode>(null);\n const valueRef = React.useRef<ValueNode>(null);\n const outputElement = React.useMemo(() => new ProxyNode(), []);\n\n React.useLayoutEffect(() => {\n // Get the output prop\n const propNode = proxyRef.current && getParentProperty(proxyRef.current);\n\n if (outputProp === undefined && propNode) {\n setOutputProp(propNode.keyNode.value);\n }\n }, [proxyRef, outputProp]);\n\n React.useEffect(() => {\n const templateObj = outputElement.items[0] as ObjectNode;\n if (proxyRef.current) {\n const parentObject = getParentObject(proxyRef.current);\n\n if (!parentObject) {\n throw new Error(\"Unable to find parent to add template to\");\n }\n\n if (!outputProp) {\n return;\n }\n\n const { insertionIndex } = determinePositionInfo(proxyRef.current);\n\n // remove the template when unmounted\n return addTemplateToObject(\n parentObject,\n templateObj,\n outputProp,\n insertionIndex,\n );\n }\n }, [proxyRef, outputProp, outputElement.items]);\n\n // Get position information for the template\n const { placement: inferredPlacement } = determinePositionInfo(\n proxyRef.current,\n );\n\n // Use the explicitly provided placement or the inferred one\n const resolvedPlacement = props.placement || inferredPlacement;\n\n return (\n <proxy ref={proxyRef}>\n <>\n {\n createPortal(\n <OptionalIDSuffixProvider\n wrapperRef={valueRef}\n templateIndex={`_index${\n baseContext.depth === 0 ? \"\" : baseContext.depth\n }_`}\n >\n <TemplateProvider>\n <object>\n <property name=\"data\">{props.data.toValue()}</property>\n <property name=\"output\">{outputProp}</property>\n <property name=\"value\">{props.children}</property>\n {dynamicProp && (\n <property name=\"dynamic\">\n {toJsonElement(dynamicProp)}\n </property>\n )}\n {resolvedPlacement && (\n <property name=\"placement\">\n {toJsonElement(resolvedPlacement)}\n </property>\n )}\n </object>\n </TemplateProvider>\n </OptionalIDSuffixProvider>,\n outputElement,\n ) as any\n }\n <value ref={valueRef} value={undefined} />\n </>\n </proxy>\n );\n};\n","import type { Schema, Language } from \"@player-ui/types\";\nimport { dequal } from \"dequal\";\nimport { SyncWaterfallHook } from \"tapable-ts\";\nimport type { LoggingInterface } from \"..\";\nimport { binding as b } from \"..\";\nimport type { BindingTemplateInstance } from \"../string-templates\";\n\nconst bindingSymbol = Symbol(\"binding\");\n\n/** Symbol to indicate that a schema node should be generated with a different name */\nexport const SchemaTypeName: unique symbol = Symbol(\"Schema Rename\");\n\ninterface SchemaChildren {\n /** Object property that will be used to create the intermediate type */\n name: string;\n\n /** Object properties children that will be parsed */\n child: object;\n}\n\ntype SchemaNode = (Schema.DataType | Language.DataTypeRef) & {\n /** Overwrite the name of the generated type */\n [SchemaTypeName]?: string;\n};\n\ninterface GeneratedDataType {\n /** The SchemaNode that was generated */\n node: SchemaNode;\n /** How many times it has been generated */\n count: number;\n}\n\n/**\n * Type Guard for the `Schema.DataType` and `Language.DataTypeRef` type\n * A bit hacky but since `Schema.Schema` must have a `Schema.DataType` as\n * the final product we have to call it that even if it is a `Language.DataTypeRef`\n */\nconst isTypeDef = (property: SchemaNode): property is Schema.DataType => {\n return (property as Schema.DataType).type !== undefined;\n};\n\n/**\n * Generator for `Schema.Schema` Objects\n */\nexport class SchemaGenerator {\n private children: Array<SchemaChildren>;\n private generatedDataTypes: Map<string, GeneratedDataType>;\n private logger: LoggingInterface;\n\n public hooks: {\n createSchemaNode: SyncWaterfallHook<\n [\n node: Schema.DataType<unknown>,\n originalProperty: Record<string | symbol, unknown>,\n ],\n Record<string, any>\n >;\n } = {\n createSchemaNode: new SyncWaterfallHook<\n [\n node: Schema.DataType,\n originalProperty: Record<string | symbol, unknown>,\n ]\n >(),\n };\n\n constructor(logger?: LoggingInterface) {\n this.children = [];\n this.generatedDataTypes = new Map();\n this.logger = logger ?? console;\n }\n\n /**\n * Converts an object to a `Schema.Schema` representation\n * Note: uses iteration to prevent potentially very deep recursion on large objects\n */\n public toSchema = (schema: any): Schema.Schema => {\n const newSchema: Schema.Schema = {\n ROOT: {},\n };\n\n this.children = [];\n this.generatedDataTypes.clear();\n\n Object.keys(schema).forEach((property) => {\n const subType = schema[property] as SchemaNode;\n newSchema.ROOT[property] = this.hooks.createSchemaNode.call(\n this.processChild(property, subType),\n subType as any,\n );\n });\n\n while (this.children.length > 0) {\n const c = this.children.pop();\n if (c === undefined) {\n break;\n }\n\n const { name, child } = c;\n const typeDef = {} as any;\n\n Object.keys(child).forEach((property) => {\n const subType = (child as any)[property] as SchemaNode;\n typeDef[property] = this.hooks.createSchemaNode.call(\n this.processChild(property, subType),\n subType as any,\n );\n });\n newSchema[name] = typeDef;\n }\n\n return newSchema;\n };\n\n /**\n * Processes the children of an object Node\n * Newly discovered children get added to the provided array\n */\n private processChild(property: string, subType: SchemaNode): Schema.DataType {\n if (isTypeDef(subType)) {\n return subType;\n }\n\n let intermediateType;\n let child;\n\n if (Array.isArray(subType)) {\n if (subType.length > 1) {\n this.logger.warn(\n `Type ${property} has multiple types in array, should only contain one top level object type. Only taking first defined type`,\n );\n }\n\n const subTypeName = subType[0][SchemaTypeName] ?? property;\n intermediateType = this.makePlaceholderArrayType(subTypeName);\n [child] = subType;\n } else {\n const subTypeName = subType[SchemaTypeName] ?? property;\n intermediateType = this.makePlaceholderType(subTypeName);\n child = subType;\n }\n\n this.children.push({ name: intermediateType.type, child });\n\n if (this.generatedDataTypes.has(intermediateType.type)) {\n const generatedType = this.generatedDataTypes.get(\n intermediateType.type,\n ) as GeneratedDataType;\n if (\n !dequal(\n child,\n this.generatedDataTypes.get(intermediateType.type)?.node as object,\n )\n ) {\n generatedType.count += 1;\n const newIntermediateType = {\n ...intermediateType,\n type: `${intermediateType.type}${generatedType.count}`,\n };\n this.logger.warn(\n `WARNING: Generated two intermediate types with the name: ${intermediateType.type} that are of different shapes, using artificial type ${newIntermediateType.type}`,\n );\n intermediateType = newIntermediateType;\n this.children.pop();\n this.children.push({ name: intermediateType.type, child });\n }\n }\n\n this.generatedDataTypes.set(intermediateType.type, {\n node: subType,\n count: 1,\n });\n return intermediateType;\n }\n\n /**\n * Make an intermediate `Schema.DataType` object given a name\n */\n private makePlaceholderType = (typeName: string): Schema.DataType => {\n return {\n type: `${typeName}Type`,\n };\n };\n\n /**\n * Make an intermediate `Schema.DataType` object with array support given a name\n */\n private makePlaceholderArrayType(typeName: string): Schema.DataType {\n return {\n type: `${typeName}Type`,\n isArray: true,\n };\n }\n}\n\nexport type MakeArrayIntoIndexRef<T extends any[]> = {\n [key: number]: MakeBindingRefable<T[0]>;\n /** Used when referencing bindings from within a template */\n _index_: MakeBindingRefable<T[0]>;\n} & BindingTemplateInstance;\n\nexport type MakeBindingRefable<T> = {\n [P in keyof T]: T[P] extends object[]\n ? MakeArrayIntoIndexRef<T[P]>\n : T[P] extends unknown[]\n ? T[P]\n : MakeBindingRefable<T[P]>;\n} & BindingTemplateInstance<T>;\n\n/**\n * Adds bindings to an object so that the object can be directly used in JSX\n */\nexport function makeBindingsForObject<Type>(\n obj: Type,\n arrayAccessorKeys: string[] = [\"_index_\"],\n): MakeBindingRefable<Type> {\n /** Proxy to track binding callbacks */\n const accessor = (paths: string[]) => {\n const bindingMap = new WeakMap<any, BindingTemplateInstance>();\n\n return {\n ownKeys(target: any) {\n return Reflect.ownKeys(target);\n },\n\n get(target: any, key: any): any {\n const bindingKeys = Object.keys(target);\n\n // If there is an array of primitives, just return a copy of that array\n if (\n Array.isArray(target[key]) &&\n target[key].length > 0 &&\n target[key].every((it: any) => typeof it !== \"object\")\n ) {\n return [...target[key]];\n }\n\n if (!bindingMap.has(target)) {\n bindingMap.set(target, b`${paths.join(\".\")}`);\n }\n\n if (key === bindingSymbol) {\n return paths;\n }\n\n if (\n Array.isArray(target) &&\n (arrayAccessorKeys.includes(key) || typeof key === \"number\")\n ) {\n return new Proxy(target[0], accessor(paths.concat([key])));\n }\n\n if (bindingKeys.includes(key) && typeof target[key] === \"object\") {\n return new Proxy(target[key], accessor(paths.concat([key])));\n }\n\n const createdInstance = bindingMap.get(target) as any;\n return createdInstance?.[key];\n },\n };\n };\n\n return new Proxy(obj, accessor([])) as MakeBindingRefable<Type>;\n}\n\n/**\n * Generates binding for an object property\n */\nexport const getBindingFromObject = (obj: any): BindingTemplateInstance => {\n const baseBindings = obj[bindingSymbol] as string[];\n if (!Array.isArray(baseBindings) || baseBindings.length === 0) {\n throw new Error(`Unable to get binding for ${obj}`);\n }\n\n return b`${baseBindings.join(\".\")}`;\n};\n\n/**\n * Returns the binding string from an object path\n */\nexport const getBindingStringFromObject = (obj: any): string => {\n return getBindingFromObject(obj).toString();\n};\n\n/**\n * Returns the ref string from an object path\n */\nexport const getRefStringFromObject = (obj: any): string => {\n return getBindingFromObject(obj).toRefString();\n};\n","import React from \"react\";\nimport type { JsonType } from \"react-json-reconciler\";\nimport { SourceMapGenerator, SourceMapConsumer } from \"source-map-js\";\nimport { render } from \"react-json-reconciler\";\nimport type { Flow, View, Navigation as PlayerNav } from \"@player-ui/types\";\nimport {\n AsyncSeriesHook,\n AsyncSeriesWaterfallHook,\n SyncHook,\n} from \"tapable-ts\";\nimport { fingerprintContent } from \"./utils\";\nimport type {\n LoggingInterface,\n CompilerReturn,\n SerializeContext,\n} from \"./types\";\nimport type { Navigation } from \"../types\";\nimport { SchemaGenerator } from \"./schema\";\n\n/**\n * Argument passed to the DSLCompiler onEnd hook\n * Defined as an object so additional fields can be added later without breaking API\n * */\nexport interface OnEndArg {\n /** target output directory **/\n output: string;\n}\n\n/** Recursively find BindingTemplateInstance and call toValue on them */\nconst parseNavigationExpressions = (nav: Navigation): PlayerNav => {\n /** Same as above but signature changed */\n function replaceExpWithStr(obj: any): any {\n /** call toValue if BindingTemplateInstance otherwise continue */\n function convExp(value: any): any {\n return value && typeof value === \"object\" && value.__type === \"expression\"\n ? value.toValue() // exp, onStart, and onEnd don't need to be wrapped in @[]@\n : replaceExpWithStr(value);\n }\n\n if (Array.isArray(obj)) {\n return obj.map(convExp);\n }\n\n if (typeof obj === \"object\") {\n const copy = { ...obj };\n for (const [key, value] of Object.entries(copy)) {\n copy[key] = convExp(value);\n }\n\n return copy;\n }\n\n return obj;\n }\n\n return replaceExpWithStr(nav);\n};\n\ntype SourceMapList = Array<{\n /** The mappings of the original */\n sourceMap: string;\n /**\n * The id of the view we're indexing off of\n * This should be a unique global identifier within the generated code\n * e.g. `\"id\": \"view_0\",`\n */\n offsetIndexSearch: string;\n /** The generated source that produced the map */\n source: string;\n}>;\n\n/** Given a list of source maps for all generated views, merge them into 1 */\nconst mergeSourceMaps = (\n sourceMaps: SourceMapList,\n generated: string,\n): string => {\n const generator = new SourceMapGenerator();\n sourceMaps.forEach(({ sourceMap, offsetIndexSearch, source }) => {\n const generatedLineOffset = generated\n .split(\"\\n\")\n .findIndex((line) => line.includes(offsetIndexSearch));\n\n const sourceLineOffset = source\n .split(\"\\n\")\n .findIndex((line) => line.includes(offsetIndexSearch));\n\n const lineOffset = generatedLineOffset - sourceLineOffset;\n\n const generatedLine = generated.split(\"\\n\")[generatedLineOffset];\n const sourceLine = source.split(\"\\n\")[sourceLineOffset];\n\n const generatedColumn = generatedLine.indexOf(offsetIndexSearch);\n const sourceColumn = sourceLine.indexOf(offsetIndexSearch);\n const columnOffset = generatedColumn - sourceColumn;\n\n const consumer = new SourceMapConsumer(JSON.parse(sourceMap));\n consumer.eachMapping((mapping) => {\n generator.addMapping({\n generated: {\n line: mapping.generatedLine + lineOffset,\n column: mapping.generatedColumn + columnOffset,\n },\n original: {\n line: mapping.originalLine,\n column: mapping.originalColumn,\n },\n source: mapping.source,\n });\n });\n });\n\n return generator.toString();\n};\n\n/** A compiler for transforming DSL content into JSON */\nexport class DSLCompiler {\n public readonly logger: LoggingInterface;\n public hooks = {\n // Hook to access the schema generator instance when initialized\n schemaGenerator: new SyncHook<[SchemaGenerator]>(),\n // Hook to access pre-compilation object\n preProcessFlow: new AsyncSeriesWaterfallHook<[object]>(),\n // Hook to access post-compilation Flow before output is written\n postProcessFlow: new AsyncSeriesWaterfallHook<[Flow]>(),\n // Hook called after all files are compiled. Revives the output directory\n onEnd: new AsyncSeriesHook<[OnEndArg]>(),\n };\n\n private schemaGenerator?: SchemaGenerator;\n\n constructor(logger?: LoggingInterface) {\n this.logger = logger ?? console;\n }\n\n /** Convert an object (flow, view, schema, etc) into it's JSON representation */\n async serialize(\n value: unknown,\n context?: SerializeContext,\n ): Promise<CompilerReturn> {\n if (typeof value !== \"object\" || value === null) {\n throw new Error(\"Unable to serialize non-object\");\n }\n\n const type = context?.type ? context.type : fingerprintContent(value);\n\n if (!this.schemaGenerator) {\n this.schemaGenerator = new SchemaGenerator(this.logger);\n this.hooks.schemaGenerator.call(this.schemaGenerator);\n }\n\n if (type === \"view\") {\n const { jsonValue, sourceMap } = await render(value as any, {\n collectSourceMap: true,\n });\n\n return {\n value: jsonValue,\n sourceMap,\n };\n }\n\n if (type === \"flow\") {\n // Source maps from all the nested views\n // Merge these together before returning\n const allSourceMaps: SourceMapList = [];\n\n // Assume this is a flow\n const copiedValue: Flow = {\n ...(value as any),\n };\n\n copiedValue.views = (await Promise.all(\n copiedValue?.views?.map(async (node: any) => {\n if (React.isValidElement(node)) {\n const { jsonValue, sourceMap, stringValue } = await render(node, {\n collectSourceMap: true,\n });\n\n if (sourceMap) {\n // Find the line that is the id of the view\n // Use that as the identifier for the sourcemap offset calc\n const searchIdLine = stringValue\n .split(\"\\n\")\n .find((line) =>\n line.includes(\n `\"id\": \"${(jsonValue as Record<string, string>).id}\"`,\n ),\n );\n\n if (searchIdLine) {\n allSourceMaps.push({\n sourceMap,\n offsetIndexSearch: searchIdLine,\n source: stringValue,\n });\n }\n }\n\n return jsonValue;\n }\n\n return node;\n }) ?? [],\n )) as View[];\n\n // Go through the flow and sub out any view refs that are react elements w/ the right id\n if (\"navigation\" in value) {\n Object.entries((value as Flow).navigation).forEach(([navKey, node]) => {\n if (typeof node === \"object\") {\n Object.entries(node).forEach(([nodeKey, flowNode]) => {\n if (\n flowNode &&\n typeof flowNode === \"object\" &&\n \"state_type\" in flowNode &&\n flowNode.state_type === \"VIEW\" &&\n React.isValidElement(flowNode.ref)\n ) {\n const actualViewIndex = (value as Flow).views?.indexOf?.(\n flowNode.ref as any,\n );\n\n if (actualViewIndex !== undefined && actualViewIndex > -1) {\n const actualId = copiedValue.views?.[actualViewIndex]?.id;\n\n (copiedValue as any).navigation[navKey][nodeKey].ref =\n actualId;\n }\n }\n });\n }\n });\n }\n\n if (\"schema\" in copiedValue) {\n copiedValue.schema = this.schemaGenerator.toSchema(copiedValue.schema);\n }\n\n copiedValue.navigation = parseNavigationExpressions(\n copiedValue.navigation,\n );\n\n if (value) {\n const postProcessFlow =\n await this.hooks.postProcessFlow.call(copiedValue);\n\n return {\n value: postProcessFlow as JsonType,\n sourceMap: mergeSourceMaps(\n allSourceMaps,\n JSON.stringify(copiedValue, null, 2),\n ),\n };\n }\n }\n\n // Type has been set to \"schema\"\n return {\n value: this.schemaGenerator.toSchema(value) as JsonType,\n };\n }\n}\n","import React from \"react\";\nimport type { DefaultCompilerContentType } from \"./types\";\n\n/** Basic way of identifying the type of file based on the default content export */\nexport const fingerprintContent = (\n content: unknown,\n filename?: string,\n): DefaultCompilerContentType | undefined => {\n if (content !== null || content !== undefined) {\n if (React.isValidElement(content as any)) {\n return \"view\";\n }\n\n if (typeof content === \"object\" && \"navigation\" in (content as any)) {\n return \"flow\";\n }\n\n if (!filename || filename.includes(\"schema\")) {\n return \"schema\";\n }\n }\n};\n","import type {\n Schema,\n Navigation,\n Flow,\n Expression,\n ExpressionObject,\n NavigationFlow,\n NavigationFlowState,\n NavigationFlowViewState,\n} from \"@player-ui/types\";\nimport type { JsonType } from \"react-json-reconciler\";\nimport type { RemoveUnknownIndex, AddUnknownIndex } from \"../types\";\nimport type { DSLSchema } from \"../types\";\n\nexport type NavigationFlowReactViewState = Omit<\n NavigationFlowViewState,\n \"ref\"\n> & {\n /** The view element */\n ref: React.ReactElement | string;\n};\n\nexport type NavFlowState =\n | Exclude<NavigationFlowState, NavigationFlowViewState>\n | NavigationFlowReactViewState;\n\nexport type NavigationFlowWithReactView = Pick<\n NavigationFlow,\n \"startState\" | \"onStart\" | \"onEnd\"\n> & {\n [key: string]:\n | undefined\n | string\n | Expression\n | ExpressionObject\n | NavFlowState;\n};\n\nexport type NavigationWithReactViews = Pick<Navigation, \"BEGIN\"> &\n Record<string, string | NavigationFlowWithReactView>;\n\nexport type FlowWithoutUnknown = RemoveUnknownIndex<Flow>;\nexport type FlowWithReactViews = AddUnknownIndex<\n Omit<FlowWithoutUnknown, \"views\" | \"navigation\"> & {\n /** An array of JSX view elements */\n views?: Array<React.ReactElement>;\n\n /** The navigation element */\n navigation?: NavigationWithReactViews;\n }\n>;\n\nexport type DSLFlow = Omit<FlowWithReactViews, \"schema\"> & {\n /** A DSL compliant schema */\n schema?: DSLSchema;\n};\n\nexport type SerializeType = \"view\" | \"flow\" | \"schema\" | \"navigation\";\n\nexport type SerializablePlayerExportTypes =\n | React.ReactElement\n | FlowWithReactViews\n | Schema.Schema\n | Navigation;\n\nexport type LoggingInterface = Pick<Console, \"warn\" | \"error\" | \"log\">;\n\nexport type CompilationResult = {\n /** What type of file is generated */\n contentType: string;\n /** The output path */\n outputFile: string;\n /** the input file */\n inputFile: string;\n};\n\nexport type CompilerReturn = {\n /** the JSON value of the source */\n value: JsonType | undefined;\n\n /** The sourcemap of the content */\n sourceMap?: string;\n};\n\n/** The different type of default content items the compiler handles */\nconst DefaultCompilerContentTypes = [\"view\", \"flow\", \"schema\"] as const;\n\nexport type DefaultCompilerContentType =\n (typeof DefaultCompilerContentTypes)[number];\n\n/** Helper function to determine whether a content type is compiler default */\nexport function isDefaultCompilerContentType(\n t: string,\n): t is DefaultCompilerContentType {\n return DefaultCompilerContentTypes.includes(t as DefaultCompilerContentType);\n}\n\nexport interface SerializeContext {\n /** The type of the content being compiled */\n type: DefaultCompilerContentType;\n}\n","import {\n expression as e,\n BindingTemplateInstance,\n ExpressionTemplateInstance,\n isTemplateStringInstance,\n isBindingTemplateInstance,\n} from \"..\";\n\ntype Argument<T> =\n | string\n | boolean\n | number\n | undefined\n | BindingTemplateInstance<T>\n | ExpressionTemplateInstance<T>;\n\nconst escapePrimitive = <T>(\n val: Exclude<\n Argument<T>,\n BindingTemplateInstance<T> | ExpressionTemplateInstance<T>\n >,\n): string => {\n switch (typeof val) {\n case \"string\": {\n return `'${val}'`;\n }\n case \"undefined\": {\n return \"null\";\n }\n default: {\n return `${val}`;\n }\n }\n};\n\nconst handleBindingOrExpression = (\n val: BindingTemplateInstance | ExpressionTemplateInstance,\n) => {\n if (isBindingTemplateInstance(val)) {\n return val.toRefString();\n } else {\n return `(${val.toValue()})`;\n }\n};\n\nconst handleArgument = <T>(arg: Argument<T>): string => {\n return isTemplateStringInstance(arg)\n ? handleBindingOrExpression(arg)\n : escapePrimitive(arg);\n};\n\n/**\n * Performs an assigment of a value to a binding by returning the expression\n * {{<binding>}} = <value>\n * @param binding\n * @param value\n */\nexport const assign = <T>(\n binding: BindingTemplateInstance<any>,\n value: Argument<T>,\n): ExpressionTemplateInstance<void> => {\n return e`${binding} = ${isTemplateStringInstance(value) ? value : escapePrimitive(value)}`;\n};\n\n/**\n * Returns an equality comparison between the two values\n */\nexport const equals = <A, B>(\n a: Argument<A>,\n b: Argument<B>,\n): ExpressionTemplateInstance<boolean> => {\n return e`${handleArgument(a)} == ${handleArgument(b)}`;\n};\n\n/**\n * Returns the negated version of the binding/expression\n * by returning !(<value>)\n * @param binding Binding/Expression to invert\n * @returns Negated binding/expression\n */\nexport const not = (\n value: BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>,\n): ExpressionTemplateInstance<boolean> => {\n return e<boolean>`!(${value})`;\n};\n\n/**\n * Creates an expression for the logical or'ing of the provided values\n * e.g: <exp1> || <exp2> || ...\n * @param values Array of bindings/expressions to logically or\n * @returns boolean\n */\nexport const or = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return e`${values.map(handleBindingOrExpression).join(\" || \")}` as ExpressionTemplateInstance<boolean>;\n};\n\n/**\n * Creates an expression for the logical nor'ing of the provided values\n * e.g: !(<exp1> || <exp2> || ...)\n * @param values Array of bindings/expressions to logically nor\n * @returns boolean\n */\nexport const nor = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return not(or(...values));\n};\n\n/**\n * Creates an expression for the logical and'ing of the provided values\n * e.g: <exp1> && <exp2> && ...\n * @param values Array of bindings/expressions to logically and\n * @returns boolean\n */\nexport const and = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return e`${values.map(handleBindingOrExpression).join(\" && \")}` as ExpressionTemplateInstance<boolean>;\n};\n\n/**\n * Creates an expression for the logical nand'ing of the provided values\n * e.g: !(<exp1> && <exp2> && ...)\n * @param values Array of bindings/expressions to logically nand\n * @returns boolean\n */\nexport const nand = (\n ...values: Array<\n BindingTemplateInstance<boolean> | ExpressionTemplateInstance<boolean>\n >\n): ExpressionTemplateInstance<boolean> => {\n return not(and(...values));\n};\n","import {\n BindingParser,\n ExpressionEvaluator,\n ExpressionHandler,\n ExpressionType,\n LocalModel,\n withParser,\n} from \"@player-ui/player\";\nimport { ExpressionTemplateInstance } from \"../string-templates\";\n\n/**\n * Test harness to make testing expressions easier.\n * Given an expreesion and an initial data model the harness will execute the expression\n * on and return the new state of the data model.\n * @param exp expression to execute\n * @param initialData data model to operate on\n * @param expressions expression handlers for functions that are called\n * @returns Final data model state\n */\nexport function testExpression(\n exp: ExpressionTemplateInstance,\n initialData: object,\n expressions?: Map<string, ExpressionHandler<any[], any>>,\n): object {\n // Setup Mock Player model and parsers\n const localModel = new LocalModel(initialData);\n const bindingParser = new BindingParser({\n get: localModel.get,\n set: localModel.set,\n evaluate: (exp: ExpressionType) => {\n return evaluator.evaluate(exp);\n },\n });\n\n const model = withParser(localModel, bindingParser.parse);\n const evaluator = new ExpressionEvaluator({ model });\n expressions?.forEach((fn, name) => evaluator.addExpressionFunction(name, fn));\n evaluator.evaluate(exp.toValue());\n return localModel.get();\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,gBAAkB;;;ACAlB,mBAAkB;AAElB,mCAA6B;AAI7B,IAAM,kBAAkB,aAAAC,QAAM,cAAsB,MAAM;AAEnD,IAAM,yBAAyB,aAAAA,QAAM,cAAuB,KAAK;AAGjE,IAAM,iBAAiB,MAAM;AAClC,SAAO,aAAAA,QAAM,WAAW,eAAe;AACzC;AAGO,IAAM,mBAAmB,CAC9B,UAIG;AACH,QAAM,gBAAgB,eAAe;AAErC,SACE,6BAAAA,QAAA;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,OAAO;AAAA,QACL,kBAAkB,SAAS,SAAY;AAAA,QACvC,MAAM;AAAA,MACR,EACG,OAAO,OAAO,EACd,KAAK,GAAG;AAAA;AAAA,IAEV,MAAM;AAAA,EACT;AAEJ;AAGO,IAAM,aAAa,CACxB,UAIG;AACH,MAAI,MAAM,IAAI;AACZ,WACE,6BAAAA,QAAA,cAAC,gBAAgB,UAAhB,EAAyB,OAAO,MAAM,MACpC,MAAM,QACT;AAAA,EAEJ;AAEA,SAAO,6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C,OAAO,eAAe,CAAC,CAAC;AACtD;AAQO,IAAM,MAAM,CACjB,UACwC;AACxC,SAAO,eAAe,KAAK;AAC7B;AAQO,IAAM,KAAK,IACb,WAGqC;AACxC,SAAO,aAAI,OAAO,IAAI,yBAAyB,EAAE,KAAK,MAAM,CAAC;AAC/D;AAQO,IAAM,MAAM,IACd,WAGqC;AACxC,SAAO,IAAI,GAAG,GAAG,MAAM,CAAC;AAC1B;AAQO,IAAM,MAAM,IACd,WAGqC;AACxC,SAAO,aAAI,OAAO,IAAI,yBAAyB,EAAE,KAAK,MAAM,CAAC;AAC/D;AAQO,IAAM,OAAO,IACf,WAGqC;AACxC,SAAO,IAAI,IAAI,GAAG,MAAM,CAAC;AAC3B;;;AC5IA,IAAAC,iBAOO;AAYA,SAAS,eACd,KACA,aACA,aACQ;AAER,QAAM,aAAa,IAAI,0BAAW,WAAW;AAC7C,QAAM,gBAAgB,IAAI,6BAAc;AAAA,IACtC,KAAK,WAAW;AAAA,IAChB,KAAK,WAAW;AAAA,IAChB,UAAU,CAACC,SAAwB;AACjC,aAAO,UAAU,SAASA,IAAG;AAAA,IAC/B;AAAA,EACF,CAAC;AAED,QAAM,YAAQ,2BAAW,YAAY,cAAc,KAAK;AACxD,QAAM,YAAY,IAAI,mCAAoB,EAAE,MAAM,CAAC;AACnD,eAAa,QAAQ,CAAC,IAAI,SAAS,UAAU,sBAAsB,MAAM,EAAE,CAAC;AAC5E,YAAU,SAAS,IAAI,QAAQ,CAAC;AAChC,SAAO,WAAW,IAAI;AACxB;","names":["import_react","React","React","React","element","binding","React","AssetWrapper","import_react","import_react_json_reconciler","React","import_react","import_react_json_reconciler","React","import_react","import_react_json_reconciler","import_tapable_ts","import_react","React","React","binding","import_player","exp"]}