@player-tools/dsl 0.4.0--canary.25.914 → 0.4.0-next.1
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 +9 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.esm.js +9 -2
- package/package.json +4 -4
- package/src/compiler/schema.ts +1 -1
- package/src/string-templates/index.ts +9 -0
- package/src/switch.tsx +2 -2
- package/src/template.tsx +18 -21
- package/src/utils.tsx +2 -2
package/dist/index.cjs.js
CHANGED
|
@@ -6,6 +6,7 @@ var React = require('react');
|
|
|
6
6
|
var flattenChildren = require('react-flatten-children');
|
|
7
7
|
var mergeRefs = require('react-merge-refs');
|
|
8
8
|
var reactJsonReconciler = require('react-json-reconciler');
|
|
9
|
+
var player = require('@player-ui/player');
|
|
9
10
|
var signale = require('signale');
|
|
10
11
|
var dequal = require('dequal');
|
|
11
12
|
var tapableTs = require('tapable-ts');
|
|
@@ -116,6 +117,12 @@ const createTemplateInstance = (options) => {
|
|
|
116
117
|
}
|
|
117
118
|
return sum + next + ((_a = element2 == null ? void 0 : element2.toRefString(options)) != null ? _a : "");
|
|
118
119
|
}, "");
|
|
120
|
+
if (options.nestedContext === "expression") {
|
|
121
|
+
const parsedExpression = player.parseExpression(value, { strict: false });
|
|
122
|
+
if (parsedExpression.error) {
|
|
123
|
+
throw parsedExpression.error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
119
126
|
const toString = () => {
|
|
120
127
|
return options.toRefString({}, value);
|
|
121
128
|
};
|
|
@@ -535,7 +542,7 @@ const Template = (props) => {
|
|
|
535
542
|
}, [proxyRef, outputProp, outputElement.items]);
|
|
536
543
|
return /* @__PURE__ */ React__default["default"].createElement("proxy", {
|
|
537
544
|
ref: proxyRef
|
|
538
|
-
},
|
|
545
|
+
}, reactJsonReconciler.createPortal(/* @__PURE__ */ React__default["default"].createElement(OptionalIDSuffixProvider, {
|
|
539
546
|
wrapperRef: valueRef,
|
|
540
547
|
templateIndex: `_index${baseContext.depth === 0 ? "" : baseContext.depth}_`
|
|
541
548
|
}, /* @__PURE__ */ React__default["default"].createElement(TemplateProvider, null, /* @__PURE__ */ React__default["default"].createElement("object", null, /* @__PURE__ */ React__default["default"].createElement("property", {
|
|
@@ -547,7 +554,7 @@ const Template = (props) => {
|
|
|
547
554
|
}, props.children)))), outputElement), /* @__PURE__ */ React__default["default"].createElement("value", {
|
|
548
555
|
ref: valueRef,
|
|
549
556
|
value: void 0
|
|
550
|
-
}))
|
|
557
|
+
}));
|
|
551
558
|
};
|
|
552
559
|
|
|
553
560
|
const bindingSymbol = Symbol("binding");
|
package/dist/index.d.ts
CHANGED
|
@@ -198,7 +198,7 @@ declare function normalizeText(options: {
|
|
|
198
198
|
/** The current node */
|
|
199
199
|
node: React$1.ReactNode;
|
|
200
200
|
/** A component to render a text asset */
|
|
201
|
-
TextComp?: React$1.ComponentType
|
|
201
|
+
TextComp?: React$1.ComponentType;
|
|
202
202
|
}): React$1.ReactNode;
|
|
203
203
|
/** Create a collection if needed */
|
|
204
204
|
declare function normalizeToCollection(options: {
|
|
@@ -207,8 +207,8 @@ declare function normalizeToCollection(options: {
|
|
|
207
207
|
/** A Text asset */
|
|
208
208
|
TextComp?: React$1.ComponentType;
|
|
209
209
|
/** A collection asset */
|
|
210
|
-
CollectionComp?: React$1.ComponentType
|
|
211
|
-
}):
|
|
210
|
+
CollectionComp?: React$1.ComponentType;
|
|
211
|
+
}): React$1.ReactNode;
|
|
212
212
|
|
|
213
213
|
interface SwitchProps {
|
|
214
214
|
/** defaults to a staticSwitch */
|
package/dist/index.esm.js
CHANGED
|
@@ -3,6 +3,7 @@ import flattenChildren from 'react-flatten-children';
|
|
|
3
3
|
import mergeRefs from 'react-merge-refs';
|
|
4
4
|
import { flattenNodes, ProxyNode, createPortal, PropertyNode, ValueNode, ArrayNode, toJSON, render } from 'react-json-reconciler';
|
|
5
5
|
export * from 'react-json-reconciler';
|
|
6
|
+
import { parseExpression } from '@player-ui/player';
|
|
6
7
|
import signale from 'signale';
|
|
7
8
|
import { dequal } from 'dequal';
|
|
8
9
|
import { SyncWaterfallHook, SyncHook } from 'tapable-ts';
|
|
@@ -106,6 +107,12 @@ const createTemplateInstance = (options) => {
|
|
|
106
107
|
}
|
|
107
108
|
return sum + next + ((_a = element2 == null ? void 0 : element2.toRefString(options)) != null ? _a : "");
|
|
108
109
|
}, "");
|
|
110
|
+
if (options.nestedContext === "expression") {
|
|
111
|
+
const parsedExpression = parseExpression(value, { strict: false });
|
|
112
|
+
if (parsedExpression.error) {
|
|
113
|
+
throw parsedExpression.error;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
109
116
|
const toString = () => {
|
|
110
117
|
return options.toRefString({}, value);
|
|
111
118
|
};
|
|
@@ -525,7 +532,7 @@ const Template = (props) => {
|
|
|
525
532
|
}, [proxyRef, outputProp, outputElement.items]);
|
|
526
533
|
return /* @__PURE__ */ React.createElement("proxy", {
|
|
527
534
|
ref: proxyRef
|
|
528
|
-
},
|
|
535
|
+
}, createPortal(/* @__PURE__ */ React.createElement(OptionalIDSuffixProvider, {
|
|
529
536
|
wrapperRef: valueRef,
|
|
530
537
|
templateIndex: `_index${baseContext.depth === 0 ? "" : baseContext.depth}_`
|
|
531
538
|
}, /* @__PURE__ */ React.createElement(TemplateProvider, null, /* @__PURE__ */ React.createElement("object", null, /* @__PURE__ */ React.createElement("property", {
|
|
@@ -537,7 +544,7 @@ const Template = (props) => {
|
|
|
537
544
|
}, props.children)))), outputElement), /* @__PURE__ */ React.createElement("value", {
|
|
538
545
|
ref: valueRef,
|
|
539
546
|
value: void 0
|
|
540
|
-
}))
|
|
547
|
+
}));
|
|
541
548
|
};
|
|
542
549
|
|
|
543
550
|
const bindingSymbol = Symbol("binding");
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@player-tools/dsl",
|
|
3
|
-
"version": "0.4.0
|
|
3
|
+
"version": "0.4.0-next.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
7
7
|
},
|
|
8
8
|
"peerDependencies": {
|
|
9
|
-
"react": "^
|
|
10
|
-
"@types/react": "^18.0.27"
|
|
9
|
+
"react": "^17.0.2"
|
|
11
10
|
},
|
|
12
11
|
"dependencies": {
|
|
13
|
-
"@player-ui/types": "0.4.0-next.
|
|
12
|
+
"@player-ui/types": "0.4.0-next.7",
|
|
13
|
+
"@player-ui/player": "0.4.0-next.7",
|
|
14
14
|
"@types/mkdirp": "^1.0.2",
|
|
15
15
|
"@types/signale": "^1.4.2",
|
|
16
16
|
"chalk": "^4.0.1",
|
package/src/compiler/schema.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Schema, Language } from '@player-ui/types';
|
|
|
2
2
|
import signale from 'signale';
|
|
3
3
|
import { dequal } from 'dequal';
|
|
4
4
|
import { SyncWaterfallHook } from 'tapable-ts';
|
|
5
|
-
import { binding as b } from '
|
|
5
|
+
import { binding as b } from '..';
|
|
6
6
|
import type { BindingTemplateInstance } from '../string-templates';
|
|
7
7
|
|
|
8
8
|
const bindingSymbol = Symbol('binding');
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { parseExpression } from '@player-ui/player';
|
|
2
3
|
|
|
3
4
|
export type TemplateInstanceRefStringContext = 'binding' | 'expression';
|
|
4
5
|
export interface TemplateRefStringOptions {
|
|
@@ -71,6 +72,14 @@ const createTemplateInstance = (
|
|
|
71
72
|
return sum + next + (element?.toRefString(options) ?? '');
|
|
72
73
|
}, '');
|
|
73
74
|
|
|
75
|
+
/** Try to parse the expression as valid */
|
|
76
|
+
if (options.nestedContext === 'expression') {
|
|
77
|
+
const parsedExpression = parseExpression(value, { strict: false });
|
|
78
|
+
if (parsedExpression.error) {
|
|
79
|
+
throw parsedExpression.error;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
74
83
|
/** get the unwrapped version */
|
|
75
84
|
const toString = () => {
|
|
76
85
|
return options.toRefString({}, value);
|
package/src/switch.tsx
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { PropsWithChildren } from 'react';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import type { ArrayNode, JsonNode, ObjectNode } from 'react-json-reconciler';
|
|
4
|
-
import { flattenNodes } from 'react-json-reconciler';
|
|
5
|
-
import { SlotContext } from '
|
|
4
|
+
import { flattenNodes, PropertyNode } from 'react-json-reconciler';
|
|
5
|
+
import { SlotContext } from '.';
|
|
6
6
|
import { IDSuffixProvider, OptionalIDSuffixProvider } from './auto-id';
|
|
7
7
|
import type {
|
|
8
8
|
BindingTemplateInstance,
|
package/src/template.tsx
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable react/jsx-no-useless-fragment */
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import type { ObjectNode, JsonNode } from 'react-json-reconciler';
|
|
4
3
|
import {
|
|
@@ -164,26 +163,24 @@ export const Template = (props: TemplateProps) => {
|
|
|
164
163
|
|
|
165
164
|
return (
|
|
166
165
|
<proxy ref={proxyRef}>
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
>
|
|
175
|
-
<
|
|
176
|
-
<
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
<value ref={valueRef} value={undefined} />
|
|
186
|
-
</>
|
|
166
|
+
{createPortal(
|
|
167
|
+
<OptionalIDSuffixProvider
|
|
168
|
+
wrapperRef={valueRef}
|
|
169
|
+
templateIndex={`_index${
|
|
170
|
+
baseContext.depth === 0 ? '' : baseContext.depth
|
|
171
|
+
}_`}
|
|
172
|
+
>
|
|
173
|
+
<TemplateProvider>
|
|
174
|
+
<object>
|
|
175
|
+
<property name="data">{props.data.toValue()}</property>
|
|
176
|
+
<property name="output">{outputProp}</property>
|
|
177
|
+
<property name="value">{props.children}</property>
|
|
178
|
+
</object>
|
|
179
|
+
</TemplateProvider>
|
|
180
|
+
</OptionalIDSuffixProvider>,
|
|
181
|
+
outputElement
|
|
182
|
+
)}
|
|
183
|
+
<value ref={valueRef} value={undefined} />
|
|
187
184
|
</proxy>
|
|
188
185
|
);
|
|
189
186
|
};
|
package/src/utils.tsx
CHANGED
|
@@ -56,7 +56,7 @@ export function normalizeText(options: {
|
|
|
56
56
|
node: React.ReactNode;
|
|
57
57
|
|
|
58
58
|
/** A component to render a text asset */
|
|
59
|
-
TextComp?: React.ComponentType
|
|
59
|
+
TextComp?: React.ComponentType;
|
|
60
60
|
}): React.ReactNode {
|
|
61
61
|
const { node, TextComp } = options;
|
|
62
62
|
|
|
@@ -88,7 +88,7 @@ export function normalizeToCollection(options: {
|
|
|
88
88
|
TextComp?: React.ComponentType;
|
|
89
89
|
|
|
90
90
|
/** A collection asset */
|
|
91
|
-
CollectionComp?: React.ComponentType
|
|
91
|
+
CollectionComp?: React.ComponentType;
|
|
92
92
|
}) {
|
|
93
93
|
const { node, CollectionComp } = options;
|
|
94
94
|
|