@player-tools/dsl 0.4.1-next.0 → 0.5.0--canary.62.1176

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -12,7 +12,26 @@ var sourceMapJs = require('source-map-js');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
14
 
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ n["default"] = e;
30
+ return Object.freeze(n);
31
+ }
32
+
15
33
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
34
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
16
35
  var mergeRefs__default = /*#__PURE__*/_interopDefaultLegacy(mergeRefs);
17
36
 
18
37
  const IDSuffixContext = React__default["default"].createContext("root");
@@ -100,7 +119,7 @@ var __spreadValues$5 = (a, b) => {
100
119
  var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
101
120
  const OpaqueIdentifier = Symbol("TemplateStringType");
102
121
  const TemplateStringComponent = (props) => {
103
- return React__default["default"].createElement("value", {
122
+ return React__namespace.createElement("value", {
104
123
  value: props.value
105
124
  }, null);
106
125
  };
@@ -125,7 +144,7 @@ const createTemplateInstance = (options) => {
125
144
  const toValue = () => {
126
145
  return value;
127
146
  };
128
- const element = React__default["default"].createElement(TemplateStringComponent, {
147
+ const element = React__namespace.createElement(TemplateStringComponent, {
129
148
  value: toString()
130
149
  }, null);
131
150
  return __spreadProps$4(__spreadValues$5({}, element), {
@@ -203,27 +222,27 @@ function toJsonElement(value, indexOrKey, options) {
203
222
  var _a;
204
223
  const indexProp = typeof indexOrKey === "number" ? { key: indexOrKey } : null;
205
224
  if (Array.isArray(value)) {
206
- return /* @__PURE__ */ React__default["default"].createElement("array", __spreadValues$4({}, indexProp), value.map((item, idx) => toJsonElement(item, idx, options)));
225
+ return /* @__PURE__ */ React__namespace.createElement("array", __spreadValues$4({}, indexProp), value.map((item, idx) => toJsonElement(item, idx, options)));
207
226
  }
208
227
  if (isTemplateStringInstance(value)) {
209
228
  if (typeof indexOrKey === "string" && ((_a = options == null ? void 0 : options.propertiesToSkip) == null ? void 0 : _a.includes(indexOrKey))) {
210
- return /* @__PURE__ */ React__default["default"].createElement("value", __spreadValues$4({}, indexProp), value.toValue());
229
+ return /* @__PURE__ */ React__namespace.createElement("value", __spreadValues$4({}, indexProp), value.toValue());
211
230
  }
212
- return /* @__PURE__ */ React__default["default"].createElement("value", __spreadValues$4({}, indexProp), value.toRefString());
231
+ return /* @__PURE__ */ React__namespace.createElement("value", __spreadValues$4({}, indexProp), value.toRefString());
213
232
  }
214
233
  if (typeof value === "object" && value !== null) {
215
- return /* @__PURE__ */ React__default["default"].createElement("obj", __spreadValues$4({}, indexProp), Object.keys(value).map((key) => /* @__PURE__ */ React__default["default"].createElement("property", {
234
+ return /* @__PURE__ */ React__namespace.createElement("obj", __spreadValues$4({}, indexProp), Object.keys(value).map((key) => /* @__PURE__ */ React__namespace.createElement("property", {
216
235
  key,
217
236
  name: key
218
237
  }, toJsonElement(value[key], key, options))));
219
238
  }
220
- return /* @__PURE__ */ React__default["default"].createElement("value", __spreadProps$3(__spreadValues$4({}, indexProp), {
239
+ return /* @__PURE__ */ React__namespace.createElement("value", __spreadProps$3(__spreadValues$4({}, indexProp), {
221
240
  value
222
241
  }));
223
242
  }
224
243
  function toJsonProperties(value, options = { propertiesToSkip: ["applicability"] }) {
225
244
  return Object.keys(value).map((key) => {
226
- return /* @__PURE__ */ React__default["default"].createElement("property", {
245
+ return /* @__PURE__ */ React__namespace.createElement("property", {
227
246
  key,
228
247
  name: key
229
248
  }, toJsonElement(value[key], key, options));
@@ -231,29 +250,29 @@ function toJsonProperties(value, options = { propertiesToSkip: ["applicability"]
231
250
  }
232
251
  function normalizeText(options) {
233
252
  const { node, TextComp } = options;
234
- const nodeArr = React__default["default"].Children.toArray(node);
235
- if (nodeArr.every((n) => React__default["default"].isValidElement(n) && n.type !== TemplateStringComponent)) {
253
+ const nodeArr = React__namespace.Children.toArray(node);
254
+ if (nodeArr.every((n) => React__namespace.isValidElement(n) && n.type !== TemplateStringComponent)) {
236
255
  return node;
237
256
  }
238
257
  if (TextComp) {
239
- return /* @__PURE__ */ React__default["default"].createElement(TextComp, null, nodeArr);
258
+ return /* @__PURE__ */ React__namespace.createElement(TextComp, null, nodeArr);
240
259
  }
241
260
  throw new Error(`Tried to convert node to Text Asset, but no Component was supplied.`);
242
261
  }
243
262
  function normalizeToCollection(options) {
244
263
  const { node, CollectionComp } = options;
245
- if (React__default["default"].Children.count(node) > 1 && React__default["default"].Children.toArray(node).every((n) => typeof n !== "string")) {
264
+ if (React__namespace.Children.count(node) > 1 && React__namespace.Children.toArray(node).every((n) => typeof n !== "string")) {
246
265
  if (!CollectionComp) {
247
266
  throw new Error(`Tried to convert array to a collection asset, but no Component was given.`);
248
267
  }
249
- return /* @__PURE__ */ React__default["default"].createElement(CollectionComp, null, node);
268
+ return /* @__PURE__ */ React__namespace.createElement(CollectionComp, null, node);
250
269
  }
251
270
  return normalizeText(__spreadProps$3(__spreadValues$4({}, options), { node }));
252
271
  }
253
272
  function flattenChildren(children) {
254
- const childrenArray = React__default["default"].Children.toArray(children);
273
+ const childrenArray = React__namespace.Children.toArray(children);
255
274
  return childrenArray.reduce((flatChildren, child) => {
256
- if (child.type === React__default["default"].Fragment) {
275
+ if (child.type === React__namespace.Fragment) {
257
276
  return flatChildren.concat(flattenChildren(child.props.children));
258
277
  }
259
278
  flatChildren.push(child);
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _player_ui_types from '@player-ui/types';
2
2
  import { Asset as Asset$1, Navigation as Navigation$1, Expression, Schema, NavigationFlowViewState, NavigationFlowState, NavigationFlow, ExpressionObject, Flow } from '@player-ui/types';
3
- import React$1, { PropsWithChildren } from 'react';
3
+ import * as React$1 from 'react';
4
+ import React__default, { PropsWithChildren } from 'react';
4
5
  import { PropertyNode, ObjectNode, JsonNode, JsonType } from 'react-json-reconciler';
5
6
  export * from 'react-json-reconciler';
6
7
  import { SyncWaterfallHook, SyncHook, AsyncSeriesWaterfallHook, AsyncSeriesHook } from 'tapable-ts';
@@ -97,11 +98,11 @@ declare type AssetProps = PlayerApplicability & {
97
98
  /** the asset type */
98
99
  type: string;
99
100
  /** Any other properties on the asset */
100
- children?: React$1.ReactNode;
101
+ children?: React__default.ReactNode;
101
102
  /** other things that we don't know about */
102
103
  [key: string]: unknown;
103
104
  };
104
- declare const SlotContext: React$1.Context<{
105
+ declare const SlotContext: React__default.Context<{
105
106
  /** The property name for the slot */
106
107
  propertyName: string;
107
108
  /** If the slot represents an array */
@@ -111,37 +112,37 @@ declare const SlotContext: React$1.Context<{
111
112
  /** Other props to add to the slot */
112
113
  additionalProperties?: any;
113
114
  /** The ref to the property node */
114
- ref: React$1.RefObject<PropertyNode>;
115
+ ref: React__default.RefObject<PropertyNode>;
115
116
  /** A text component if we hit a string but expect an asset */
116
- TextComp?: React$1.ComponentType<{}> | undefined;
117
+ TextComp?: React__default.ComponentType<{}> | undefined;
117
118
  /** A component to create a collection asset is we get an array but need a single element */
118
- CollectionComp?: React$1.ComponentType<{}> | undefined;
119
+ CollectionComp?: React__default.ComponentType<{}> | undefined;
119
120
  } | undefined>;
120
121
  /**
121
122
  * Wraps the children in an `asset` object.
122
123
  * Additional props are added to the top level object
123
124
  */
124
- declare const AssetWrapper: React$1.ForwardRefExoticComponent<Pick<WithChildren<{
125
+ declare const AssetWrapper: React__default.ForwardRefExoticComponent<Omit<WithChildren<{
125
126
  [key: string]: any;
126
- }>, string | number> & React$1.RefAttributes<ObjectNode>>;
127
+ }>, "ref"> & React__default.RefAttributes<ObjectNode>>;
127
128
  /** Create a ID property for a node */
128
129
  declare const GeneratedIDProperty: (props: {
129
130
  /** the id to use if supplied by the user */
130
131
  id?: string;
131
- }) => JSX.Element;
132
+ }) => React__default.JSX.Element;
132
133
  /** An asset */
133
- declare const Asset: React$1.ForwardRefExoticComponent<Pick<AssetProps, string | number> & React$1.RefAttributes<ObjectNode>>;
134
- declare const View: React$1.ForwardRefExoticComponent<Pick<PlayerApplicability & {
134
+ declare const Asset: React__default.ForwardRefExoticComponent<Omit<AssetProps, "ref"> & React__default.RefAttributes<ObjectNode>>;
135
+ declare const View: React__default.ForwardRefExoticComponent<Omit<PlayerApplicability & {
135
136
  [key: string]: unknown;
136
137
  /** id of the asset */
137
138
  id?: string | undefined;
138
139
  /** the asset type */
139
140
  type: string;
140
141
  /** Any other properties on the asset */
141
- children?: React$1.ReactNode;
142
+ children?: React__default.ReactNode;
142
143
  } & _player_ui_types.Asset<string> & {
143
144
  validation?: _player_ui_types.Validation.CrossfieldReference[] | undefined;
144
- }, keyof _player_ui_types.Asset<string>> & React$1.RefAttributes<ObjectNode>>;
145
+ }, "ref"> & React__default.RefAttributes<ObjectNode>>;
145
146
  /** A component to generate a named property slot */
146
147
  declare const Slot: (props: {
147
148
  /** The name of the slot */
@@ -151,14 +152,14 @@ declare const Slot: (props: {
151
152
  /** if each item should be wrapped in an asset */
152
153
  wrapInAsset?: boolean;
153
154
  /** Any children to render in the slot */
154
- children?: React$1.ReactNode;
155
+ children?: React__default.ReactNode;
155
156
  /** Other properties to add to the slot */
156
157
  additionalProperties?: any;
157
158
  /** A text component if we hit a string but expect an asset */
158
- TextComp?: React$1.ComponentType;
159
+ TextComp?: React__default.ComponentType;
159
160
  /** A component to create a collection asset is we get an array but need a single element */
160
- CollectionComp?: React$1.ComponentType;
161
- }) => JSX.Element;
161
+ CollectionComp?: React__default.ComponentType;
162
+ }) => React__default.JSX.Element;
162
163
  /** Create a slot for a given property */
163
164
  declare function createSlot<SlotProps = unknown>(options: {
164
165
  /** The name of the slot */
@@ -168,58 +169,58 @@ declare function createSlot<SlotProps = unknown>(options: {
168
169
  /** if each item should be wrapped in an asset */
169
170
  wrapInAsset?: boolean;
170
171
  /** Any children to render in the slot */
171
- children?: React$1.ReactNode;
172
+ children?: React__default.ReactNode;
172
173
  /** A text component if we hit a string but expect an asset */
173
- TextComp?: React$1.ComponentType;
174
+ TextComp?: React__default.ComponentType;
174
175
  /** A component to create a collection asset is we get an array but need a single element */
175
- CollectionComp?: React$1.ComponentType;
176
+ CollectionComp?: React__default.ComponentType;
176
177
  }): (props: {
177
178
  /** An object to include in this property */
178
- children?: React$1.ReactNode;
179
- } & SlotProps) => JSX.Element;
179
+ children?: React__default.ReactNode;
180
+ } & SlotProps) => React__default.JSX.Element;
180
181
 
181
- declare const IndexSuffixStopContext: React$1.Context<boolean>;
182
+ declare const IndexSuffixStopContext: React__default.Context<boolean>;
182
183
  /** Get the generated id */
183
184
  declare const useGetIdPrefix: () => string;
184
185
  /** Add a suffix to a generated id */
185
186
  declare const IDSuffixProvider: (props: WithChildren<{
186
187
  /** The suffix to append */
187
188
  suffix: string;
188
- }>) => JSX.Element;
189
+ }>) => React__default.JSX.Element;
189
190
  /** Override the generated id with the supplied one */
190
191
  declare const IDProvider: (props: WithChildren<{
191
192
  /** The new id to use */
192
193
  id?: string;
193
- }>) => JSX.Element;
194
+ }>) => React__default.JSX.Element;
194
195
  /** Get the index of an item in a slot */
195
- declare const useIndexInSlot: (ref: React$1.RefObject<JsonNode>) => number;
196
+ declare const useIndexInSlot: (ref: React__default.RefObject<JsonNode>) => number;
196
197
  /** Add the index to the id path when in an array slot */
197
198
  declare const IDSuffixIndexProvider: (props: WithChildren<{
198
199
  /** The ref to use */
199
- wrapperRef: React$1.RefObject<JsonNode>;
200
+ wrapperRef: React__default.RefObject<JsonNode>;
200
201
  /** if the suffix is in a template, the id to use */
201
202
  templateIndex?: string;
202
- }>) => JSX.Element;
203
+ }>) => React__default.JSX.Element;
203
204
  /** Wrap a slot with the index if in an array slot */
204
205
  declare const OptionalIDSuffixProvider: (props: WithChildren<{
205
206
  /** The ref to walk upwards and use as an index */
206
- wrapperRef: React$1.RefObject<JsonNode>;
207
+ wrapperRef: React__default.RefObject<JsonNode>;
207
208
  /** if the suffix is in a template, the id to use */
208
209
  templateIndex?: string;
209
- }>) => JSX.Element;
210
+ }>) => React__default.JSX.Element;
210
211
 
211
212
  /** Get an array version of the value */
212
213
  declare function toArray<T>(val: T | Array<T>): Array<T>;
213
214
  /** Create a component version */
214
215
  declare function toJsonElement(value: any, indexOrKey?: number | string, options?: toJsonOptions): React$1.ReactElement;
215
216
  /** Create a fragment for the properties */
216
- declare function toJsonProperties(value: Record<string, any>, options?: toJsonOptions): JSX.Element[];
217
+ declare function toJsonProperties(value: Record<string, any>, options?: toJsonOptions): React$1.JSX.Element[];
217
218
  /** Create a text asset if needed */
218
219
  declare function normalizeText(options: {
219
220
  /** The current node */
220
221
  node: React$1.ReactNode;
221
222
  /** A component to render a text asset */
222
- TextComp?: React$1.ComponentType;
223
+ TextComp?: React$1.ComponentType<any>;
223
224
  }): React$1.ReactNode;
224
225
  /** Create a collection if needed */
225
226
  declare function normalizeToCollection(options: {
@@ -228,8 +229,8 @@ declare function normalizeToCollection(options: {
228
229
  /** A Text asset */
229
230
  TextComp?: React$1.ComponentType;
230
231
  /** A collection asset */
231
- CollectionComp?: React$1.ComponentType;
232
- }): React$1.ReactNode;
232
+ CollectionComp?: React$1.ComponentType<any>;
233
+ }): string | number | boolean | Iterable<React$1.ReactNode> | React$1.JSX.Element | null | undefined;
233
234
  declare type ReactChildArray = ReturnType<typeof React$1.Children.toArray>;
234
235
  /**
235
236
  *
@@ -246,8 +247,8 @@ interface SwitchProps {
246
247
  * Switches allow users to fork content between 1 or more assets
247
248
  */
248
249
  declare const Switch: {
249
- (props: PropsWithChildren<SwitchProps>): JSX.Element;
250
- Case: (props: PropsWithChildren<CaseProps>) => JSX.Element;
250
+ (props: PropsWithChildren<SwitchProps>): React__default.JSX.Element;
251
+ Case: (props: PropsWithChildren<CaseProps>) => React__default.JSX.Element;
251
252
  };
252
253
  interface CaseProps {
253
254
  /** the test for this case statement */
@@ -258,19 +259,19 @@ interface TemplateContextType {
258
259
  /** The number of nested templates */
259
260
  depth: number;
260
261
  }
261
- declare const TemplateContext: React$1.Context<TemplateContextType>;
262
+ declare const TemplateContext: React__default.Context<TemplateContextType>;
262
263
  interface TemplateProps {
263
264
  /** The source binding */
264
265
  data: BindingTemplateInstance;
265
266
  /** The target property */
266
267
  output?: string;
267
268
  /** The template value */
268
- children: React$1.ReactNode;
269
+ children: React__default.ReactNode;
269
270
  /** boolean that specifies whether template should recompute when data changes */
270
271
  dynamic?: boolean;
271
272
  }
272
273
  /** A template allows users to dynamically map over an array of data */
273
- declare const Template: (props: TemplateProps) => JSX.Element;
274
+ declare const Template: (props: TemplateProps) => React__default.JSX.Element;
274
275
 
275
276
  declare const SchemaTypeName: unique symbol;
276
277
  /**
package/dist/index.esm.js CHANGED
@@ -1,4 +1,5 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
+ import React__default from 'react';
2
3
  import mergeRefs from 'react-merge-refs';
3
4
  import { flattenNodes, ProxyNode, createPortal, PropertyNode, ValueNode, ArrayNode, toJSON, render } from 'react-json-reconciler';
4
5
  export * from 'react-json-reconciler';
@@ -7,14 +8,14 @@ import { dequal } from 'dequal';
7
8
  import { SyncWaterfallHook, SyncHook, AsyncSeriesWaterfallHook, AsyncSeriesHook } from 'tapable-ts';
8
9
  import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
9
10
 
10
- const IDSuffixContext = React.createContext("root");
11
- const IndexSuffixStopContext = React.createContext(false);
11
+ const IDSuffixContext = React__default.createContext("root");
12
+ const IndexSuffixStopContext = React__default.createContext(false);
12
13
  const useGetIdPrefix = () => {
13
- return React.useContext(IDSuffixContext);
14
+ return React__default.useContext(IDSuffixContext);
14
15
  };
15
16
  const IDSuffixProvider = (props) => {
16
17
  const currentPrefix = useGetIdPrefix();
17
- return /* @__PURE__ */ React.createElement(IDSuffixContext.Provider, {
18
+ return /* @__PURE__ */ React__default.createElement(IDSuffixContext.Provider, {
18
19
  value: [
19
20
  currentPrefix === "root" ? void 0 : currentPrefix,
20
21
  props.suffix
@@ -23,16 +24,16 @@ const IDSuffixProvider = (props) => {
23
24
  };
24
25
  const IDProvider = (props) => {
25
26
  if (props.id) {
26
- return /* @__PURE__ */ React.createElement(IDSuffixContext.Provider, {
27
+ return /* @__PURE__ */ React__default.createElement(IDSuffixContext.Provider, {
27
28
  value: props.id
28
29
  }, props.children);
29
30
  }
30
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
31
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, props.children);
31
32
  };
32
33
  const useIndexInSlot = (ref) => {
33
- const [index, setIndex] = React.useState(-1);
34
- const slotContext = React.useContext(SlotContext);
35
- React.useEffect(() => {
34
+ const [index, setIndex] = React__default.useState(-1);
35
+ const slotContext = React__default.useContext(SlotContext);
36
+ React__default.useEffect(() => {
36
37
  var _a, _b;
37
38
  if (!(slotContext == null ? void 0 : slotContext.isArray)) {
38
39
  throw new Error("Cannot get index in non-array slot");
@@ -50,25 +51,25 @@ const useIndexInSlot = (ref) => {
50
51
  const IDSuffixIndexProvider = (props) => {
51
52
  var _a;
52
53
  const slotIndex = useIndexInSlot(props.wrapperRef);
53
- const stopIndex = React.useContext(IndexSuffixStopContext);
54
+ const stopIndex = React__default.useContext(IndexSuffixStopContext);
54
55
  if (stopIndex) {
55
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
56
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, props.children);
56
57
  }
57
- return /* @__PURE__ */ React.createElement(IDSuffixProvider, {
58
+ return /* @__PURE__ */ React__default.createElement(IDSuffixProvider, {
58
59
  suffix: (_a = props.templateIndex) != null ? _a : String(slotIndex)
59
- }, /* @__PURE__ */ React.createElement(IndexSuffixStopContext.Provider, {
60
+ }, /* @__PURE__ */ React__default.createElement(IndexSuffixStopContext.Provider, {
60
61
  value: true
61
62
  }, props.children));
62
63
  };
63
64
  const OptionalIDSuffixProvider = (props) => {
64
- const slotContext = React.useContext(SlotContext);
65
+ const slotContext = React__default.useContext(SlotContext);
65
66
  if (slotContext == null ? void 0 : slotContext.isArray) {
66
- return /* @__PURE__ */ React.createElement(IDSuffixIndexProvider, {
67
+ return /* @__PURE__ */ React__default.createElement(IDSuffixIndexProvider, {
67
68
  wrapperRef: props.wrapperRef,
68
69
  templateIndex: props.templateIndex
69
70
  }, props.children);
70
71
  }
71
- return /* @__PURE__ */ React.createElement(React.Fragment, null, props.children);
72
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, props.children);
72
73
  };
73
74
 
74
75
  var __defProp$5 = Object.defineProperty;
@@ -284,44 +285,44 @@ var __objRest = (source, exclude) => {
284
285
  }
285
286
  return target;
286
287
  };
287
- const SlotContext = React.createContext(void 0);
288
- const AssetWrapper = React.forwardRef((props, ref) => {
288
+ const SlotContext = React__default.createContext(void 0);
289
+ const AssetWrapper = React__default.forwardRef((props, ref) => {
289
290
  const _a = props, { children } = _a, rest = __objRest(_a, ["children"]);
290
- return /* @__PURE__ */ React.createElement("obj", {
291
+ return /* @__PURE__ */ React__default.createElement("obj", {
291
292
  ref
292
- }, toJsonProperties(rest), /* @__PURE__ */ React.createElement("property", {
293
+ }, toJsonProperties(rest), /* @__PURE__ */ React__default.createElement("property", {
293
294
  name: "asset"
294
295
  }, children));
295
296
  });
296
297
  const GeneratedIDProperty = (props) => {
297
298
  var _a;
298
299
  const currentPrefixId = useGetIdPrefix();
299
- return /* @__PURE__ */ React.createElement("property", {
300
+ return /* @__PURE__ */ React__default.createElement("property", {
300
301
  name: "id"
301
302
  }, (_a = props.id) != null ? _a : currentPrefixId);
302
303
  };
303
- const Asset = React.forwardRef((props, ref) => {
304
+ const Asset = React__default.forwardRef((props, ref) => {
304
305
  const _a = props, { id, type, applicability, children } = _a, rest = __objRest(_a, ["id", "type", "applicability", "children"]);
305
- const slotContext = React.useContext(SlotContext);
306
- const localRef = React.useRef(null);
307
- const Wrapper = (slotContext == null ? void 0 : slotContext.wrapInAsset) ? AssetWrapper : React.Fragment;
308
- return /* @__PURE__ */ React.createElement(Wrapper, __spreadValues$3({
306
+ const slotContext = React__default.useContext(SlotContext);
307
+ const localRef = React__default.useRef(null);
308
+ const Wrapper = (slotContext == null ? void 0 : slotContext.wrapInAsset) ? AssetWrapper : React__default.Fragment;
309
+ return /* @__PURE__ */ React__default.createElement(Wrapper, __spreadValues$3({
309
310
  ref: (slotContext == null ? void 0 : slotContext.wrapInAsset) ? mergeRefs([ref, localRef]) : void 0
310
- }, (slotContext == null ? void 0 : slotContext.wrapInAsset) && (slotContext == null ? void 0 : slotContext.additionalProperties) ? slotContext == null ? void 0 : slotContext.additionalProperties : {}), /* @__PURE__ */ React.createElement(OptionalIDSuffixProvider, {
311
+ }, (slotContext == null ? void 0 : slotContext.wrapInAsset) && (slotContext == null ? void 0 : slotContext.additionalProperties) ? slotContext == null ? void 0 : slotContext.additionalProperties : {}), /* @__PURE__ */ React__default.createElement(OptionalIDSuffixProvider, {
311
312
  wrapperRef: localRef
312
- }, /* @__PURE__ */ React.createElement(SlotContext.Provider, {
313
+ }, /* @__PURE__ */ React__default.createElement(SlotContext.Provider, {
313
314
  value: void 0
314
- }, /* @__PURE__ */ React.createElement(IDProvider, {
315
+ }, /* @__PURE__ */ React__default.createElement(IDProvider, {
315
316
  id
316
- }, /* @__PURE__ */ React.createElement("obj", {
317
+ }, /* @__PURE__ */ React__default.createElement("obj", {
317
318
  ref: (slotContext == null ? void 0 : slotContext.wrapInAsset) ? void 0 : mergeRefs([ref, localRef])
318
- }, /* @__PURE__ */ React.createElement(GeneratedIDProperty, {
319
+ }, /* @__PURE__ */ React__default.createElement(GeneratedIDProperty, {
319
320
  id
320
- }), /* @__PURE__ */ React.createElement("property", {
321
+ }), /* @__PURE__ */ React__default.createElement("property", {
321
322
  name: "type"
322
- }, type), applicability !== void 0 && /* @__PURE__ */ React.createElement("property", {
323
+ }, type), applicability !== void 0 && /* @__PURE__ */ React__default.createElement("property", {
323
324
  name: "applicability"
324
- }, /* @__PURE__ */ React.createElement("value", {
325
+ }, /* @__PURE__ */ React__default.createElement("value", {
325
326
  value: typeof applicability === "boolean" ? applicability : applicability.toValue()
326
327
  })), toJsonProperties(rest), children)))));
327
328
  });
@@ -329,11 +330,11 @@ Asset.defaultProps = {
329
330
  id: void 0,
330
331
  children: void 0
331
332
  };
332
- const View = React.forwardRef((props, ref) => {
333
+ const View = React__default.forwardRef((props, ref) => {
333
334
  const _a = props, { validation, children } = _a, rest = __objRest(_a, ["validation", "children"]);
334
- return /* @__PURE__ */ React.createElement(Asset, __spreadValues$3({
335
+ return /* @__PURE__ */ React__default.createElement(Asset, __spreadValues$3({
335
336
  ref
336
- }, rest), validation && /* @__PURE__ */ React.createElement("property", {
337
+ }, rest), validation && /* @__PURE__ */ React__default.createElement("property", {
337
338
  key: "validation",
338
339
  name: "validation"
339
340
  }, toJsonElement(validation, "validation", {
@@ -348,15 +349,15 @@ const Slot = (props) => {
348
349
  var _a, _b;
349
350
  const { TextComp, CollectionComp } = props;
350
351
  const children = flattenChildren(props.children);
351
- const propRef = React.useRef(null);
352
- return /* @__PURE__ */ React.createElement("property", {
352
+ const propRef = React__default.useRef(null);
353
+ return /* @__PURE__ */ React__default.createElement("property", {
353
354
  ref: propRef,
354
355
  name: props.name
355
- }, /* @__PURE__ */ React.createElement(IDSuffixProvider, {
356
+ }, /* @__PURE__ */ React__default.createElement(IDSuffixProvider, {
356
357
  suffix: props.name
357
- }, /* @__PURE__ */ React.createElement(IndexSuffixStopContext.Provider, {
358
+ }, /* @__PURE__ */ React__default.createElement(IndexSuffixStopContext.Provider, {
358
359
  value: false
359
- }, /* @__PURE__ */ React.createElement(SlotContext.Provider, {
360
+ }, /* @__PURE__ */ React__default.createElement(SlotContext.Provider, {
360
361
  value: {
361
362
  ref: propRef,
362
363
  propertyName: props.name,
@@ -366,8 +367,8 @@ const Slot = (props) => {
366
367
  TextComp,
367
368
  CollectionComp
368
369
  }
369
- }, props.isArray && /* @__PURE__ */ React.createElement("array", null, React.Children.map(children, (child, index) => {
370
- return /* @__PURE__ */ React.createElement(React.Fragment, {
370
+ }, props.isArray && /* @__PURE__ */ React__default.createElement("array", null, React__default.Children.map(children, (child, index) => {
371
+ return /* @__PURE__ */ React__default.createElement(React__default.Fragment, {
371
372
  key: `${props.name}-${index}`
372
373
  }, normalizeText({ node: child, TextComp }));
373
374
  })), !props.isArray && normalizeToCollection({
@@ -379,7 +380,7 @@ const Slot = (props) => {
379
380
  function createSlot(options) {
380
381
  return (props) => {
381
382
  const _a = props, { children } = _a, other = __objRest(_a, ["children"]);
382
- return /* @__PURE__ */ React.createElement(Slot, __spreadProps$2(__spreadValues$3({}, options), {
383
+ return /* @__PURE__ */ React__default.createElement(Slot, __spreadProps$2(__spreadValues$3({}, options), {
383
384
  additionalProperties: other
384
385
  }), children);
385
386
  };
@@ -404,24 +405,24 @@ var __spreadValues$2 = (a, b) => {
404
405
  return a;
405
406
  };
406
407
  var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
407
- const SwitchContext = React.createContext({});
408
+ const SwitchContext = React__default.createContext({});
408
409
  const Switch = (props) => {
409
- const slotContext = React.useContext(SlotContext);
410
- const propertyNode = React.useRef(null);
411
- return /* @__PURE__ */ React.createElement("obj", {
410
+ const slotContext = React__default.useContext(SlotContext);
411
+ const propertyNode = React__default.useRef(null);
412
+ return /* @__PURE__ */ React__default.createElement("obj", {
412
413
  ref: propertyNode
413
- }, /* @__PURE__ */ React.createElement(SwitchContext.Provider, {
414
+ }, /* @__PURE__ */ React__default.createElement(SwitchContext.Provider, {
414
415
  value: __spreadProps$1(__spreadValues$2({}, props), {
415
416
  TextComp: slotContext == null ? void 0 : slotContext.TextComp,
416
417
  CollectionComp: slotContext == null ? void 0 : slotContext.CollectionComp
417
418
  })
418
- }, /* @__PURE__ */ React.createElement(OptionalIDSuffixProvider, {
419
+ }, /* @__PURE__ */ React__default.createElement(OptionalIDSuffixProvider, {
419
420
  wrapperRef: propertyNode
420
- }, /* @__PURE__ */ React.createElement("property", {
421
+ }, /* @__PURE__ */ React__default.createElement("property", {
421
422
  name: props.isDynamic ? "dynamicSwitch" : "staticSwitch"
422
- }, /* @__PURE__ */ React.createElement(SlotContext.Provider, {
423
+ }, /* @__PURE__ */ React__default.createElement(SlotContext.Provider, {
423
424
  value: void 0
424
- }, /* @__PURE__ */ React.createElement("array", null, props.children))))), (slotContext == null ? void 0 : slotContext.additionalProperties) && toJsonProperties(slotContext.additionalProperties));
425
+ }, /* @__PURE__ */ React__default.createElement("array", null, props.children))))), (slotContext == null ? void 0 : slotContext.additionalProperties) && toJsonProperties(slotContext.additionalProperties));
425
426
  };
426
427
  const findParentArray = (node) => {
427
428
  if (node.type === "array") {
@@ -438,11 +439,11 @@ const findArrayIndex = (node) => {
438
439
  return allSearch.indexOf(node);
439
440
  };
440
441
  const Case = (props) => {
441
- const slotContext = React.useContext(SlotContext);
442
- const switchContext = React.useContext(SwitchContext);
443
- const [caseIndex, setCaseIndex] = React.useState(-1);
444
- const caseNode = React.useRef(null);
445
- React.useLayoutEffect(() => {
442
+ const slotContext = React__default.useContext(SlotContext);
443
+ const switchContext = React__default.useContext(SwitchContext);
444
+ const [caseIndex, setCaseIndex] = React__default.useState(-1);
445
+ const caseNode = React__default.useRef(null);
446
+ React__default.useLayoutEffect(() => {
446
447
  if (caseNode.current) {
447
448
  const index = findArrayIndex(caseNode.current);
448
449
  if (index !== caseIndex) {
@@ -454,17 +455,17 @@ const Case = (props) => {
454
455
  if (props.exp !== void 0) {
455
456
  expValue = isTemplateStringInstance(props.exp) ? props.exp.toValue() : props.exp;
456
457
  }
457
- return /* @__PURE__ */ React.createElement("obj", {
458
+ return /* @__PURE__ */ React__default.createElement("obj", {
458
459
  ref: caseNode
459
- }, /* @__PURE__ */ React.createElement("property", {
460
+ }, /* @__PURE__ */ React__default.createElement("property", {
460
461
  name: "case"
461
- }, /* @__PURE__ */ React.createElement("value", {
462
+ }, /* @__PURE__ */ React__default.createElement("value", {
462
463
  value: expValue
463
- })), /* @__PURE__ */ React.createElement(IDSuffixProvider, {
464
+ })), /* @__PURE__ */ React__default.createElement(IDSuffixProvider, {
464
465
  suffix: `${switchContext.isDynamic ? "dynamicSwitch" : "staticSwitch"}-${caseIndex}`
465
- }, /* @__PURE__ */ React.createElement(SlotContext.Provider, {
466
+ }, /* @__PURE__ */ React__default.createElement(SlotContext.Provider, {
466
467
  value: slotContext ? __spreadProps$1(__spreadValues$2({}, slotContext), { wrapInAsset: false }) : void 0
467
- }, /* @__PURE__ */ React.createElement("property", {
468
+ }, /* @__PURE__ */ React__default.createElement("property", {
468
469
  name: "asset"
469
470
  }, normalizeToCollection({
470
471
  node: props.children,
@@ -474,7 +475,7 @@ const Case = (props) => {
474
475
  };
475
476
  Switch.Case = Case;
476
477
 
477
- const TemplateContext = React.createContext({
478
+ const TemplateContext = React__default.createContext({
478
479
  depth: 0
479
480
  });
480
481
  function addTemplateToObject(obj, templateObj, templateParentNodeType) {
@@ -513,8 +514,8 @@ function addTemplateToObject(obj, templateObj, templateParentNodeType) {
513
514
  };
514
515
  }
515
516
  const TemplateProvider = (props) => {
516
- const baseContext = React.useContext(TemplateContext);
517
- return /* @__PURE__ */ React.createElement(TemplateContext.Provider, {
517
+ const baseContext = React__default.useContext(TemplateContext);
518
+ return /* @__PURE__ */ React__default.createElement(TemplateContext.Provider, {
518
519
  value: { depth: baseContext.depth + 1 }
519
520
  }, props.children);
520
521
  };
@@ -536,19 +537,19 @@ const getParentProperty = (node) => {
536
537
  };
537
538
  const Template = (props) => {
538
539
  var _a;
539
- const baseContext = React.useContext(TemplateContext);
540
+ const baseContext = React__default.useContext(TemplateContext);
540
541
  const dynamicProp = (_a = props.dynamic) != null ? _a : false;
541
- const [outputProp, setOutputProp] = React.useState(props.output);
542
- const proxyRef = React.useRef(null);
543
- const valueRef = React.useRef(null);
544
- const outputElement = React.useMemo(() => new ProxyNode(), []);
545
- React.useLayoutEffect(() => {
542
+ const [outputProp, setOutputProp] = React__default.useState(props.output);
543
+ const proxyRef = React__default.useRef(null);
544
+ const valueRef = React__default.useRef(null);
545
+ const outputElement = React__default.useMemo(() => new ProxyNode(), []);
546
+ React__default.useLayoutEffect(() => {
546
547
  const propNode = proxyRef.current && getParentProperty(proxyRef.current);
547
548
  if (outputProp === void 0 && propNode) {
548
549
  setOutputProp(propNode.keyNode.value);
549
550
  }
550
551
  }, [proxyRef, outputProp]);
551
- React.useEffect(() => {
552
+ React__default.useEffect(() => {
552
553
  const templateObj = outputElement.items[0];
553
554
  if (proxyRef.current) {
554
555
  const parentObject = getParentObject(proxyRef.current);
@@ -561,20 +562,20 @@ const Template = (props) => {
561
562
  return addTemplateToObject(parentObject, templateObj, outputProp);
562
563
  }
563
564
  }, [proxyRef, outputProp, outputElement.items]);
564
- return /* @__PURE__ */ React.createElement("proxy", {
565
+ return /* @__PURE__ */ React__default.createElement("proxy", {
565
566
  ref: proxyRef
566
- }, createPortal(/* @__PURE__ */ React.createElement(OptionalIDSuffixProvider, {
567
+ }, createPortal(/* @__PURE__ */ React__default.createElement(OptionalIDSuffixProvider, {
567
568
  wrapperRef: valueRef,
568
569
  templateIndex: `_index${baseContext.depth === 0 ? "" : baseContext.depth}_`
569
- }, /* @__PURE__ */ React.createElement(TemplateProvider, null, /* @__PURE__ */ React.createElement("object", null, /* @__PURE__ */ React.createElement("property", {
570
+ }, /* @__PURE__ */ React__default.createElement(TemplateProvider, null, /* @__PURE__ */ React__default.createElement("object", null, /* @__PURE__ */ React__default.createElement("property", {
570
571
  name: "data"
571
- }, props.data.toValue()), /* @__PURE__ */ React.createElement("property", {
572
+ }, props.data.toValue()), /* @__PURE__ */ React__default.createElement("property", {
572
573
  name: "output"
573
- }, outputProp), /* @__PURE__ */ React.createElement("property", {
574
+ }, outputProp), /* @__PURE__ */ React__default.createElement("property", {
574
575
  name: "value"
575
- }, props.children), dynamicProp && /* @__PURE__ */ React.createElement("property", {
576
+ }, props.children), dynamicProp && /* @__PURE__ */ React__default.createElement("property", {
576
577
  name: "dynamic"
577
- }, toJsonElement(dynamicProp))))), outputElement), /* @__PURE__ */ React.createElement("value", {
578
+ }, toJsonElement(dynamicProp))))), outputElement), /* @__PURE__ */ React__default.createElement("value", {
578
579
  ref: valueRef,
579
580
  value: void 0
580
581
  }));
@@ -734,7 +735,7 @@ const getRefStringFromObject = (obj) => {
734
735
 
735
736
  const fingerprintContent = (content, filename) => {
736
737
  if (content !== null || content !== void 0) {
737
- if (React.isValidElement(content)) {
738
+ if (React__default.isValidElement(content)) {
738
739
  return "view";
739
740
  }
740
741
  if (typeof content === "object" && "navigation" in content) {
@@ -857,7 +858,7 @@ class DSLCompiler {
857
858
  const allSourceMaps = [];
858
859
  const copiedValue = __spreadValues({}, value);
859
860
  copiedValue.views = yield Promise.all((_b = (_a = copiedValue == null ? void 0 : copiedValue.views) == null ? void 0 : _a.map((node) => __async(this, null, function* () {
860
- if (React.isValidElement(node)) {
861
+ if (React__default.isValidElement(node)) {
861
862
  const { jsonValue, sourceMap, stringValue } = yield render(node, {
862
863
  collectSourceMap: true
863
864
  });
@@ -880,7 +881,7 @@ class DSLCompiler {
880
881
  if (typeof node === "object") {
881
882
  Object.entries(node).forEach(([nodeKey, flowNode]) => {
882
883
  var _a2, _b2, _c, _d;
883
- if (flowNode && typeof flowNode === "object" && "state_type" in flowNode && flowNode.state_type === "VIEW" && React.isValidElement(flowNode.ref)) {
884
+ if (flowNode && typeof flowNode === "object" && "state_type" in flowNode && flowNode.state_type === "VIEW" && React__default.isValidElement(flowNode.ref)) {
884
885
  const actualViewIndex = (_b2 = (_a2 = value.views) == null ? void 0 : _a2.indexOf) == null ? void 0 : _b2.call(_a2, flowNode.ref);
885
886
  if (actualViewIndex !== void 0 && actualViewIndex > -1) {
886
887
  const actualId = (_d = (_c = copiedValue.views) == null ? void 0 : _c[actualViewIndex]) == null ? void 0 : _d.id;
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "@player-tools/dsl",
3
- "version": "0.4.1-next.0",
3
+ "version": "0.5.0--canary.62.1176",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org"
7
7
  },
8
8
  "peerDependencies": {
9
- "react": "^17.0.2"
9
+ "react": "^18.2.0",
10
+ "@types/react": "^18.2.45"
10
11
  },
11
12
  "dependencies": {
12
13
  "@player-ui/types": "0.4.3",
@@ -19,7 +20,7 @@
19
20
  "jsonc-parser": "^2.3.1",
20
21
  "mkdirp": "^1.0.4",
21
22
  "react-flatten-children": "^1.1.2",
22
- "react-json-reconciler": "^2.0.0",
23
+ "react-json-reconciler": "^3.0.1",
23
24
  "react-merge-refs": "^1.1.0",
24
25
  "source-map-js": "^1.0.2",
25
26
  "ts-node": "^10.4.0",
@@ -142,7 +142,7 @@ export class DSLCompiler {
142
142
  this.hooks.schemaGenerator.call(schemaGenerator);
143
143
 
144
144
  if (type === 'view') {
145
- const { jsonValue, sourceMap } = await render(value, {
145
+ const { jsonValue, sourceMap } = await render(value as any, {
146
146
  collectSourceMap: true,
147
147
  });
148
148
 
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
2
  import { parseExpression } from '@player-ui/player';
3
3
 
4
4
  export type TemplateInstanceRefStringContext = 'binding' | 'expression';
package/src/utils.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import * as React from 'react';
2
2
  import {
3
3
  isTemplateStringInstance,
4
4
  TemplateStringComponent,
@@ -73,7 +73,7 @@ export function normalizeText(options: {
73
73
  node: React.ReactNode;
74
74
 
75
75
  /** A component to render a text asset */
76
- TextComp?: React.ComponentType;
76
+ TextComp?: React.ComponentType<any>;
77
77
  }): React.ReactNode {
78
78
  const { node, TextComp } = options;
79
79
 
@@ -105,7 +105,7 @@ export function normalizeToCollection(options: {
105
105
  TextComp?: React.ComponentType;
106
106
 
107
107
  /** A collection asset */
108
- CollectionComp?: React.ComponentType;
108
+ CollectionComp?: React.ComponentType<any>;
109
109
  }) {
110
110
  const { node, CollectionComp } = options;
111
111