@teleporthq/teleport-plugin-common 0.43.41 → 0.43.44
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/__tests__/node-handlers/node-to-jsx/utils.ts +55 -0
- package/__tests__/utils/url-search-param-sync.ts +42 -0
- package/dist/cjs/node-handlers/node-to-html/utils.js +24 -11
- package/dist/cjs/node-handlers/node-to-html/utils.js.map +1 -1
- package/dist/cjs/node-handlers/node-to-jsx/index.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-jsx/index.js +117 -4
- package/dist/cjs/node-handlers/node-to-jsx/index.js.map +1 -1
- package/dist/cjs/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-jsx/utils.js +41 -22
- package/dist/cjs/node-handlers/node-to-jsx/utils.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils/ast-utils.d.ts.map +1 -1
- package/dist/cjs/utils/ast-utils.js +36 -0
- package/dist/cjs/utils/ast-utils.js.map +1 -1
- package/dist/cjs/utils/url-search-param-sync.d.ts +2 -2
- package/dist/cjs/utils/url-search-param-sync.d.ts.map +1 -1
- package/dist/cjs/utils/url-search-param-sync.js +38 -6
- package/dist/cjs/utils/url-search-param-sync.js.map +1 -1
- package/dist/esm/node-handlers/node-to-html/utils.js +24 -11
- package/dist/esm/node-handlers/node-to-html/utils.js.map +1 -1
- package/dist/esm/node-handlers/node-to-jsx/index.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-jsx/index.js +115 -5
- package/dist/esm/node-handlers/node-to-jsx/index.js.map +1 -1
- package/dist/esm/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-jsx/utils.js +41 -22
- package/dist/esm/node-handlers/node-to-jsx/utils.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils/ast-utils.d.ts.map +1 -1
- package/dist/esm/utils/ast-utils.js +36 -0
- package/dist/esm/utils/ast-utils.js.map +1 -1
- package/dist/esm/utils/url-search-param-sync.d.ts +2 -2
- package/dist/esm/utils/url-search-param-sync.d.ts.map +1 -1
- package/dist/esm/utils/url-search-param-sync.js +38 -6
- package/dist/esm/utils/url-search-param-sync.js.map +1 -1
- package/package.json +4 -4
- package/src/node-handlers/node-to-html/utils.ts +33 -11
- package/src/node-handlers/node-to-jsx/index.ts +190 -22
- package/src/node-handlers/node-to-jsx/utils.ts +63 -30
- package/src/utils/ast-utils.ts +39 -0
- package/src/utils/url-search-param-sync.ts +50 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"url-search-param-sync.js","sourceRoot":"","sources":["../../../src/utils/url-search-param-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,0EAA0E;AAC1E,EAAE;AACF,gBAAgB;AAChB,8EAA8E;AAC9E,4EAA4E;AAC5E,iEAAiE;AACjE,iFAAiF;AACjF,iEAAiE;AACjE,kFAAkF;AAClF,wEAAwE;AACxE,EAAE;AACF,4EAA4E;AAC5E,uEAAuE;AACvE,0CAA0C;AAE1C,6EAA6E;AAC7E,4EAA4E;AAC5E,yEAAyE;AACzE,4EAA4E;AAC5E,sDAAsD;AACtD,IAAM,mBAAmB,GAAG,4BAA4B,CAAA;AAExD,iFAAiF;AACjF,0EAA0E;AAC1E,IAAM,WAAW,GAAG,UAAC,MAAwB,EAAE,QAAgB;IAC7D,IAAI,mBAAmB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;QACtC,OAAO,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAA;KAClE;IACD,OAAO,KAAK,CAAC,gBAAgB,CAAC,MAAM,EAAE,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,IAAI,CAAC,CAAA;AAC5E,CAAC,CAAA;AAED,IAAM,iBAAiB,GAAG,UAAC,QAAgB;IACzC,OAAA,WAAW,CACT,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,EAC7E,QAAQ,CACT;AAHD,CAGC,CAAA;AAEH,2EAA2E;AAC3E,8EAA8E;AAC9E,qEAAqE;AACrE,IAAM,KAAK,GAAG,UAAC,IAAsB;IACnC,OAAA,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAqB;AAA1D,CAA0D,CAAA;AAE5D,2EAA2E;AAC3E,yDAAyD;AACzD,EAAE;AACF,sBAAsB;AACtB,gDAAgD;AAChD,kCAAkC;AAClC,8CAA8C;AAC9C,iEAAiE;AACjE,0CAA0C;AAC1C,eAAe;AACf,8DAA8D;AAC9D,QAAQ;AACR,6EAA6E;AAC7E,sBAAsB;AACtB,2DAA2D;AAC3D,mBAAmB;AACnB,0BAA0B;AAC1B,QAAQ;AACR,2CAA2C;AAC3C,EAAE;AACF,+EAA+E;AAC/E,6EAA6E;AAC7E,6EAA6E;AAC7E,wEAAwE;AACxE,EAAE;AACF,SAAS;AACT,2EAA2E;AAC3E,4DAA4D;AAC5D,6EAA6E;AAC7E,2EAA2E;AAC3E,6EAA6E;AAC7E,+EAA+E;AAC/E,6EAA6E;AAC7E,2EAA2E;AAC3E,sEAAsE;AACtE,mEAAmE;AACnE,6EAA6E;AAC7E,6EAA6E;AAC7E,UAAU;AACV,0EAA0E;AAC1E,iCAAiC;AACjC,MAAM,CAAC,IAAM,uBAAuB,GAAG,UACrC,QAAgB,EAChB,SAA2B,EAC3B,OAAyB;
|
|
1
|
+
{"version":3,"file":"url-search-param-sync.js","sourceRoot":"","sources":["../../../src/utils/url-search-param-sync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAA;AAErC,0EAA0E;AAC1E,EAAE;AACF,gBAAgB;AAChB,8E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E;YACjC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;SACzE,CAAC;QACF,gEAAgE;QAChE,KAAK,CAAC,mBAAmB,CACvB,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YACjD,KAAK,CAAC,uBAAuB,CAC3B,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAC1B,KAAK,CAAC,qBAAqB,CACzB,KAAK,CAAC,gBAAgB,CACpB,KAAK,EACL,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EACxB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAChC,EACD,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EACxB,KAAK,CAAC,UAAU,CAAC,aAAa,CAAC,CAChC,CACF;SACF,CAAC,CACH;KACF,CAAC,CAAA;IAEF,OAAO,KAAK,CAAC,mBAAmB,CAC9B,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,UAAU,CAAC,WAAW,CAAC,EAAE;QAClD,KAAK,CAAC,uBAAuB,CAAC,EAAE,EAAE,UAAU,CAAC;QAC7C,KAAK,CAAC,eAAe,CAAC;YACpB,iBAAiB,CAAC,QAAQ,CAAC;YAC3B,KAAK,CAAC,gBAAgB,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;SAChF,CAAC;KACH,CAAC,CACH,CAAA;AACH,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teleporthq/teleport-plugin-common",
|
|
3
|
-
"version": "0.43.
|
|
3
|
+
"version": "0.43.44",
|
|
4
4
|
"description": "Common building and modelating functions for ASTs and HASTs",
|
|
5
5
|
"author": "teleportHQ",
|
|
6
6
|
"license": "MIT",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"@babel/core": "^7.5.5",
|
|
28
28
|
"@babel/preset-react": "^7.22.5",
|
|
29
29
|
"@babel/types": "^7.5.5",
|
|
30
|
-
"@teleporthq/teleport-shared": "^0.43.
|
|
31
|
-
"@teleporthq/teleport-types": "^0.43.
|
|
30
|
+
"@teleporthq/teleport-shared": "^0.43.44",
|
|
31
|
+
"@teleporthq/teleport-types": "^0.43.44",
|
|
32
32
|
"jss": "^10.0.0",
|
|
33
33
|
"jss-preset-default": "^10.0.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "c5cac00d70ddb1ebaa54836043880014d6772e78"
|
|
36
36
|
}
|
|
@@ -230,6 +230,18 @@ const stringifyOperandValue = (
|
|
|
230
230
|
return String(value)
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
/**
|
|
234
|
+
* Collection operators dereference `.length` / `.includes` on the bound value,
|
|
235
|
+
* which is nullish far more often than it looks (an optional CMS column, a
|
|
236
|
+
* category without an image, a not-yet-hydrated state). Coercing to an empty
|
|
237
|
+
* collection first keeps a hide-this-node condition from throwing
|
|
238
|
+
* `Cannot read properties of null` mid-render. A non-empty string stays
|
|
239
|
+
* truthy, so string semantics are preserved. Mirrors `createNullSafeCollection`
|
|
240
|
+
* in the JSX handler — keep the two in sync.
|
|
241
|
+
*/
|
|
242
|
+
const nullSafeCollection = (identifier: string, empty: '[]' | '{}' = '[]') =>
|
|
243
|
+
`(${identifier} || ${empty})`
|
|
244
|
+
|
|
233
245
|
const stringifyConditionalExpression = (
|
|
234
246
|
identifier: string,
|
|
235
247
|
operation: string,
|
|
@@ -238,39 +250,49 @@ const stringifyConditionalExpression = (
|
|
|
238
250
|
) => {
|
|
239
251
|
// Array/object operators
|
|
240
252
|
if (operation === 'isEmpty') {
|
|
241
|
-
return `${identifier}.length === 0`
|
|
253
|
+
return `${nullSafeCollection(identifier)}.length === 0`
|
|
242
254
|
}
|
|
243
255
|
if (operation === 'isNotEmpty') {
|
|
244
|
-
return `${identifier}.length > 0`
|
|
256
|
+
return `${nullSafeCollection(identifier)}.length > 0`
|
|
245
257
|
}
|
|
246
258
|
if (operation === 'lengthEquals') {
|
|
247
|
-
return `${identifier}.length === ${stringifyOperandValue(value)}`
|
|
259
|
+
return `${nullSafeCollection(identifier)}.length === ${stringifyOperandValue(value)}`
|
|
248
260
|
}
|
|
249
261
|
if (operation === 'lengthGreaterThan') {
|
|
250
|
-
return `${identifier}.length > ${stringifyOperandValue(value)}`
|
|
262
|
+
return `${nullSafeCollection(identifier)}.length > ${stringifyOperandValue(value)}`
|
|
251
263
|
}
|
|
252
264
|
if (operation === 'lengthLessThan') {
|
|
253
|
-
return `${identifier}.length < ${stringifyOperandValue(value)}`
|
|
265
|
+
return `${nullSafeCollection(identifier)}.length < ${stringifyOperandValue(value)}`
|
|
254
266
|
}
|
|
255
267
|
if (operation === 'contains') {
|
|
256
268
|
const operandStr = stringifyOperandValue(value)
|
|
257
269
|
if (containsField) {
|
|
258
|
-
return `${
|
|
270
|
+
return `${nullSafeCollection(
|
|
271
|
+
identifier
|
|
272
|
+
)}.some(item => item.${containsField} === ${operandStr})`
|
|
259
273
|
}
|
|
260
|
-
return `${identifier}.includes(${operandStr})`
|
|
274
|
+
return `${nullSafeCollection(identifier)}.includes(${operandStr})`
|
|
261
275
|
}
|
|
262
276
|
if (operation === 'notContains') {
|
|
263
277
|
const operandStr = stringifyOperandValue(value)
|
|
264
278
|
if (containsField) {
|
|
265
|
-
return `!${
|
|
279
|
+
return `!${nullSafeCollection(
|
|
280
|
+
identifier
|
|
281
|
+
)}.some(item => item.${containsField} === ${operandStr})`
|
|
266
282
|
}
|
|
267
|
-
return `!${identifier}.includes(${operandStr})`
|
|
283
|
+
return `!${nullSafeCollection(identifier)}.includes(${operandStr})`
|
|
268
284
|
}
|
|
269
285
|
if (operation === 'hasKey') {
|
|
270
|
-
return `Object.prototype.hasOwnProperty.call(${
|
|
286
|
+
return `Object.prototype.hasOwnProperty.call(${nullSafeCollection(
|
|
287
|
+
identifier,
|
|
288
|
+
'{}'
|
|
289
|
+
)}, ${stringifyOperandValue(value)})`
|
|
271
290
|
}
|
|
272
291
|
if (operation === 'notHasKey') {
|
|
273
|
-
return `!Object.prototype.hasOwnProperty.call(${
|
|
292
|
+
return `!Object.prototype.hasOwnProperty.call(${nullSafeCollection(
|
|
293
|
+
identifier,
|
|
294
|
+
'{}'
|
|
295
|
+
)}, ${stringifyOperandValue(value)})`
|
|
274
296
|
}
|
|
275
297
|
|
|
276
298
|
// Standard operators
|
|
@@ -45,12 +45,58 @@ import {
|
|
|
45
45
|
parseStringWithTemplateExpressions,
|
|
46
46
|
parseJSExpressionAsAST,
|
|
47
47
|
convertToReactAttributeName,
|
|
48
|
+
convertValueToLiteral,
|
|
48
49
|
GLOBAL_REF_ID_MAP,
|
|
49
50
|
sanitizeExprContent,
|
|
50
51
|
} from '../../utils/ast-utils'
|
|
51
52
|
import { createJSXTag, createSelfClosingJSXTag } from '../../builders/ast-builders'
|
|
52
53
|
import { DEFAULT_JSX_OPTIONS } from './constants'
|
|
53
54
|
import { ASTBuilders, ASTUtils } from '../..'
|
|
55
|
+
import ParsedASTNode from '../../utils/parsed-ast'
|
|
56
|
+
|
|
57
|
+
// Runtime predicate that drops a DataProvider filter whose destination
|
|
58
|
+
// resolves to an empty value: `''` / `null` / `undefined`, or an empty
|
|
59
|
+
// array-overlap set (`[]` / `['']`). Selecting a "show all" reset must mean
|
|
60
|
+
// "no filter", not a query that matches zero rows. Kept in sync with the
|
|
61
|
+
// Next.js pages plugin's `buildNonEmptyDestinationPredicate` (duplicated here
|
|
62
|
+
// because teleport-plugin-common must not depend on teleport-plugin-next-data-source).
|
|
63
|
+
const buildNonEmptyFilterDestinationPredicate = (): types.ArrowFunctionExpression => {
|
|
64
|
+
const f = types.identifier('__f')
|
|
65
|
+
const dest = types.memberExpression(f, types.identifier('destination'))
|
|
66
|
+
const isEmptyArray = types.logicalExpression(
|
|
67
|
+
'&&',
|
|
68
|
+
types.callExpression(
|
|
69
|
+
types.memberExpression(types.identifier('Array'), types.identifier('isArray')),
|
|
70
|
+
[dest]
|
|
71
|
+
),
|
|
72
|
+
types.binaryExpression(
|
|
73
|
+
'===',
|
|
74
|
+
types.memberExpression(
|
|
75
|
+
types.callExpression(types.memberExpression(dest, types.identifier('filter')), [
|
|
76
|
+
types.identifier('Boolean'),
|
|
77
|
+
]),
|
|
78
|
+
types.identifier('length')
|
|
79
|
+
),
|
|
80
|
+
types.numericLiteral(0)
|
|
81
|
+
)
|
|
82
|
+
)
|
|
83
|
+
return types.arrowFunctionExpression(
|
|
84
|
+
[f],
|
|
85
|
+
types.logicalExpression(
|
|
86
|
+
'&&',
|
|
87
|
+
types.logicalExpression(
|
|
88
|
+
'&&',
|
|
89
|
+
types.logicalExpression(
|
|
90
|
+
'&&',
|
|
91
|
+
types.binaryExpression('!==', dest, types.stringLiteral('')),
|
|
92
|
+
types.binaryExpression('!==', dest, types.nullLiteral())
|
|
93
|
+
),
|
|
94
|
+
types.binaryExpression('!==', dest, types.identifier('undefined'))
|
|
95
|
+
),
|
|
96
|
+
types.unaryExpression('!', isEmptyArray)
|
|
97
|
+
)
|
|
98
|
+
)
|
|
99
|
+
}
|
|
54
100
|
|
|
55
101
|
// Global references in the UIDL come in two shapes:
|
|
56
102
|
// Shape A: { id: "ecommerce", refPath: ["Cart", "total"] }
|
|
@@ -147,12 +193,29 @@ const trackGlobalRefsInExpression = (expression: string, params: JSXGenerationPa
|
|
|
147
193
|
}
|
|
148
194
|
}
|
|
149
195
|
|
|
196
|
+
// The recognised runtime identifiers a `global` reference's `id` can legitimately
|
|
197
|
+
// already hold (Shape A). Anything else — notably the opaque `TQ_...` node id every
|
|
198
|
+
// dynamic UIDL reference carries for editor bookkeeping — is not a real identifier
|
|
199
|
+
// and must be re-derived from `refPath` (Shape B/C), or code generation would emit
|
|
200
|
+
// an undeclared variable that throws at runtime.
|
|
201
|
+
const KNOWN_GLOBAL_REF_IDS = new Set([
|
|
202
|
+
'locale',
|
|
203
|
+
'locales',
|
|
204
|
+
'currentUser',
|
|
205
|
+
'userIsLoggedIn',
|
|
206
|
+
'ecommerce',
|
|
207
|
+
'cart',
|
|
208
|
+
])
|
|
209
|
+
|
|
150
210
|
const normalizeGlobalRef = <
|
|
151
211
|
T extends { content: { id: string; refPath?: string[]; referenceType: string } }
|
|
152
212
|
>(
|
|
153
213
|
node: T
|
|
154
214
|
): T => {
|
|
155
|
-
if (
|
|
215
|
+
if (!node.content.refPath || node.content.refPath.length === 0) {
|
|
216
|
+
return node
|
|
217
|
+
}
|
|
218
|
+
if (node.content.id && KNOWN_GLOBAL_REF_IDS.has(node.content.id)) {
|
|
156
219
|
return node
|
|
157
220
|
}
|
|
158
221
|
const firstSeg = node.content.refPath[0]
|
|
@@ -528,6 +591,85 @@ const maybeAddFormStoreFieldBinding = (
|
|
|
528
591
|
}
|
|
529
592
|
}
|
|
530
593
|
|
|
594
|
+
// Style plugins (styled-jsx, css-modules, styled-components, react-jss, plugin-css)
|
|
595
|
+
// emit ONE flat, component-scope CSS block/class-map from `element.style`, so a
|
|
596
|
+
// dynamic style value only resolves correctly there when the identifier it needs
|
|
597
|
+
// is reachable from that top-level scope (e.g. `token`/`prop`). A `ctx` reference
|
|
598
|
+
// resolves to the render-prop identifier of the enclosing repeater/data-source —
|
|
599
|
+
// only in scope inside that repeater's own render callback — and other reference
|
|
600
|
+
// types (`state`, `local`, `global`, `globalState`, ...) are never routed through
|
|
601
|
+
// `element.style` by any known UIDL producer either. When one shows up anyway, the
|
|
602
|
+
// only place that still knows the correct enclosing scope is here, while building
|
|
603
|
+
// this exact JSX node, so resolve it into an inline `style` attribute (mirroring
|
|
604
|
+
// how `dynamicStyleBindings` already handles ctx/state-bound styles) and strip it
|
|
605
|
+
// out of `element.style` so no downstream style plugin re-processes — and chokes
|
|
606
|
+
// on — the same entry.
|
|
607
|
+
const resolveScopedDynamicStyleValues = (
|
|
608
|
+
style: UIDLElement['style'],
|
|
609
|
+
elementTag: types.JSXElement,
|
|
610
|
+
params: JSXGenerationParams,
|
|
611
|
+
options: JSXGenerationOptions
|
|
612
|
+
): void => {
|
|
613
|
+
if (!style) {
|
|
614
|
+
return
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
const inlineStyleOverrides: Record<string, ParsedASTNode> = {}
|
|
618
|
+
for (const cssProperty of Object.keys(style)) {
|
|
619
|
+
const styleValue = style[cssProperty]
|
|
620
|
+
const camelCaseProperty = cssProperty.replace(/-([a-z])/g, (_, letter: string) =>
|
|
621
|
+
letter.toUpperCase()
|
|
622
|
+
)
|
|
623
|
+
|
|
624
|
+
// A pre-resolved expression style value (e.g. a data-source-bound style whose
|
|
625
|
+
// mapper already produced the full member-access expression). The UIDL style
|
|
626
|
+
// type is narrowed to static|dynamic, so read the discriminator via a cast.
|
|
627
|
+
// Inline the parsed expression and strip it so no CSS/styled-jsx plugin sees it.
|
|
628
|
+
const rawStyleValue = styleValue as { type?: string; content?: unknown }
|
|
629
|
+
if (rawStyleValue.type === 'expr') {
|
|
630
|
+
const exprContent = rawStyleValue.content
|
|
631
|
+
if (typeof exprContent === 'string' && exprContent.length > 0) {
|
|
632
|
+
inlineStyleOverrides[camelCaseProperty] = new ParsedASTNode(
|
|
633
|
+
parseJSExpressionAsAST(exprContent)
|
|
634
|
+
)
|
|
635
|
+
delete style[cssProperty]
|
|
636
|
+
}
|
|
637
|
+
continue
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
// Skip: `token` → CSS variable (handled by the style plugin); a SIMPLE `prop`
|
|
641
|
+
// (no refPath) → the style plugin's `${props.x}` interpolation. A prop WITH a
|
|
642
|
+
// refPath (an object prop's field, e.g. `product.color`) MUST be inlined here
|
|
643
|
+
// instead — styled-jsx's prop case emits only `props.<id>` and would drop the
|
|
644
|
+
// refPath, producing `props.product` instead of `props.product.color`.
|
|
645
|
+
const isSimpleProp =
|
|
646
|
+
styleValue.type === 'dynamic' &&
|
|
647
|
+
styleValue.content.referenceType === 'prop' &&
|
|
648
|
+
!(styleValue.content.refPath && styleValue.content.refPath.length > 0)
|
|
649
|
+
if (
|
|
650
|
+
styleValue.type !== 'dynamic' ||
|
|
651
|
+
styleValue.content.referenceType === 'token' ||
|
|
652
|
+
isSimpleProp
|
|
653
|
+
) {
|
|
654
|
+
continue
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
const resolvedExpr = resolveDynamicReferenceExpression(styleValue, params, options)
|
|
658
|
+
const fallback = (styleValue.content as { fallback?: string | number | boolean }).fallback
|
|
659
|
+
const finalExpr =
|
|
660
|
+
fallback !== undefined && fallback !== ''
|
|
661
|
+
? types.logicalExpression('||', resolvedExpr, convertValueToLiteral(fallback))
|
|
662
|
+
: resolvedExpr
|
|
663
|
+
inlineStyleOverrides[camelCaseProperty] = new ParsedASTNode(finalExpr)
|
|
664
|
+
|
|
665
|
+
delete style[cssProperty]
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
if (Object.keys(inlineStyleOverrides).length > 0) {
|
|
669
|
+
addAttributeToJSXTag(elementTag, 'style', inlineStyleOverrides)
|
|
670
|
+
}
|
|
671
|
+
}
|
|
672
|
+
|
|
531
673
|
const generateElementNode: NodeToJSX<UIDLElementNode, types.JSXElement> = (
|
|
532
674
|
node,
|
|
533
675
|
params,
|
|
@@ -535,7 +677,7 @@ const generateElementNode: NodeToJSX<UIDLElementNode, types.JSXElement> = (
|
|
|
535
677
|
) => {
|
|
536
678
|
const { dependencies, nodesLookup } = params
|
|
537
679
|
const options = { ...DEFAULT_JSX_OPTIONS, ...jsxOptions }
|
|
538
|
-
const { elementType, selfClosing, children, key, attrs, dependency, events } = node.content
|
|
680
|
+
const { elementType, selfClosing, children, key, attrs, dependency, events, style } = node.content
|
|
539
681
|
|
|
540
682
|
const originalElementName = elementType || 'component'
|
|
541
683
|
let tagName = originalElementName
|
|
@@ -604,6 +746,8 @@ const generateElementNode: NodeToJSX<UIDLElementNode, types.JSXElement> = (
|
|
|
604
746
|
)
|
|
605
747
|
}
|
|
606
748
|
|
|
749
|
+
resolveScopedDynamicStyleValues(style, elementTag, params, options)
|
|
750
|
+
|
|
607
751
|
if (events) {
|
|
608
752
|
Object.keys(events).forEach((eventKey) => {
|
|
609
753
|
addEventHandlerToTag(elementTag, eventKey, events[eventKey], params, options)
|
|
@@ -1645,29 +1789,41 @@ const generateDataSourceNode: NodeToJSX<
|
|
|
1645
1789
|
if (property.type === 'static') {
|
|
1646
1790
|
// Special handling for filters array - convert dynamic destinations
|
|
1647
1791
|
if (attrKey === 'filters' && Array.isArray(property.content)) {
|
|
1792
|
+
const filterEntries = property.content.map(
|
|
1793
|
+
(filter: { source?: string; destination?: unknown; operand?: string }) =>
|
|
1794
|
+
types.objectExpression([
|
|
1795
|
+
types.objectProperty(
|
|
1796
|
+
types.identifier('source'),
|
|
1797
|
+
types.stringLiteral(filter.source || '')
|
|
1798
|
+
),
|
|
1799
|
+
types.objectProperty(
|
|
1800
|
+
types.identifier('destination'),
|
|
1801
|
+
ASTUtils.convertFilterDestinationToExpression(filter.destination, {
|
|
1802
|
+
dynamicReferencePrefixMap: options.dynamicReferencePrefixMap,
|
|
1803
|
+
})
|
|
1804
|
+
),
|
|
1805
|
+
types.objectProperty(
|
|
1806
|
+
types.identifier('operand'),
|
|
1807
|
+
types.stringLiteral(filter.operand || '')
|
|
1808
|
+
),
|
|
1809
|
+
])
|
|
1810
|
+
)
|
|
1811
|
+
// Drop conditions whose destination resolves to an empty value at
|
|
1812
|
+
// runtime (empty string / null / undefined, or an empty
|
|
1813
|
+
// array-overlap set) so a "show all" reset means no filter rather
|
|
1814
|
+
// than a query that matches zero rows. Mirrors the Next.js pages
|
|
1815
|
+
// path's `buildNonEmptyDestinationPredicate` (kept inline here
|
|
1816
|
+
// because teleport-plugin-common must not depend on the
|
|
1817
|
+
// next-data-source plugin).
|
|
1648
1818
|
acc.push(
|
|
1649
1819
|
types.objectProperty(
|
|
1650
1820
|
types.stringLiteral(attrKey),
|
|
1651
|
-
types.
|
|
1652
|
-
|
|
1653
|
-
(
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
types.stringLiteral(filter.source || '')
|
|
1658
|
-
),
|
|
1659
|
-
types.objectProperty(
|
|
1660
|
-
types.identifier('destination'),
|
|
1661
|
-
ASTUtils.convertFilterDestinationToExpression(filter.destination, {
|
|
1662
|
-
dynamicReferencePrefixMap: options.dynamicReferencePrefixMap,
|
|
1663
|
-
})
|
|
1664
|
-
),
|
|
1665
|
-
types.objectProperty(
|
|
1666
|
-
types.identifier('operand'),
|
|
1667
|
-
types.stringLiteral(filter.operand || '')
|
|
1668
|
-
),
|
|
1669
|
-
])
|
|
1670
|
-
)
|
|
1821
|
+
types.callExpression(
|
|
1822
|
+
types.memberExpression(
|
|
1823
|
+
types.arrayExpression(filterEntries),
|
|
1824
|
+
types.identifier('filter')
|
|
1825
|
+
),
|
|
1826
|
+
[buildNonEmptyFilterDestinationPredicate()]
|
|
1671
1827
|
)
|
|
1672
1828
|
)
|
|
1673
1829
|
)
|
|
@@ -1872,6 +2028,18 @@ const generateCMSListRepeaterNode: NodeToJSX<UIDLCMSListRepeaterNode, types.JSXE
|
|
|
1872
2028
|
}
|
|
1873
2029
|
repeaterItemsExpr = types.logicalExpression('||', expr, types.arrayExpression([]))
|
|
1874
2030
|
params.globalReferences.push('ecommerce' as Parameters<typeof params.globalReferences.push>[0])
|
|
2031
|
+
} else if (source === 'ecommerceCategories') {
|
|
2032
|
+
// The `E-Commerce Categories` global (the nested category tree) is baked
|
|
2033
|
+
// onto the ecommerce context as `ecommerce.ecommerceCategories`. Fixed
|
|
2034
|
+
// one-segment path (independent of the item name) → `ecommerce?.ecommerceCategories || []`.
|
|
2035
|
+
const expr = types.optionalMemberExpression(
|
|
2036
|
+
types.identifier('ecommerce'),
|
|
2037
|
+
types.identifier('ecommerceCategories'),
|
|
2038
|
+
false,
|
|
2039
|
+
true
|
|
2040
|
+
)
|
|
2041
|
+
repeaterItemsExpr = types.logicalExpression('||', expr, types.arrayExpression([]))
|
|
2042
|
+
params.globalReferences.push('ecommerce' as Parameters<typeof params.globalReferences.push>[0])
|
|
1875
2043
|
} else {
|
|
1876
2044
|
// Resolve any global-state reference encoded in `source` and register it
|
|
1877
2045
|
// so the `next-global-state` component plugin destructures the matching
|
|
@@ -985,6 +985,48 @@ const resolveOperandExpression = (
|
|
|
985
985
|
return convertValueToLiteral(operand, conditionalIdentifier.type)
|
|
986
986
|
}
|
|
987
987
|
|
|
988
|
+
/**
|
|
989
|
+
* Coerce a conditional identifier to an empty collection when it is null or
|
|
990
|
+
* undefined, so the collection operators below can dereference it safely.
|
|
991
|
+
*
|
|
992
|
+
* The bound value is absent far more often than it looks: an optional CMS
|
|
993
|
+
* column, a category without an image, a state that has not hydrated yet. A
|
|
994
|
+
* bare `x.length` / `x.includes(...)` then throws `Cannot read properties of
|
|
995
|
+
* null` during render and takes the whole page down with an unhandled runtime
|
|
996
|
+
* error — a condition whose entire job is to HIDE a node must never be able to
|
|
997
|
+
* do that. `x || []` keeps string semantics intact (a non-empty string is
|
|
998
|
+
* truthy and carries both `.length` and `.includes`) while turning nullish
|
|
999
|
+
* values into a harmless empty collection; objects get `{}` for `Object.keys`
|
|
1000
|
+
* / `hasOwnProperty`, which reject `null` outright.
|
|
1001
|
+
*/
|
|
1002
|
+
const createNullSafeCollection = (
|
|
1003
|
+
identifier: types.Expression,
|
|
1004
|
+
conditionalIdentifier: ConditionalIdentifier,
|
|
1005
|
+
t = types
|
|
1006
|
+
): types.Expression =>
|
|
1007
|
+
t.logicalExpression(
|
|
1008
|
+
'||',
|
|
1009
|
+
identifier,
|
|
1010
|
+
conditionalIdentifier.type === 'object' ? t.objectExpression([]) : t.arrayExpression([])
|
|
1011
|
+
)
|
|
1012
|
+
|
|
1013
|
+
/** `x.length` — via `Object.keys(x).length` for objects — on a nullish-safe target. */
|
|
1014
|
+
const createLengthExpression = (
|
|
1015
|
+
identifier: types.Expression,
|
|
1016
|
+
conditionalIdentifier: ConditionalIdentifier,
|
|
1017
|
+
t = types
|
|
1018
|
+
): types.Expression => {
|
|
1019
|
+
const target = createNullSafeCollection(identifier, conditionalIdentifier, t)
|
|
1020
|
+
return conditionalIdentifier.type === 'object'
|
|
1021
|
+
? t.memberExpression(
|
|
1022
|
+
t.callExpression(t.memberExpression(t.identifier('Object'), t.identifier('keys')), [
|
|
1023
|
+
target,
|
|
1024
|
+
]),
|
|
1025
|
+
t.identifier('length')
|
|
1026
|
+
)
|
|
1027
|
+
: t.memberExpression(target, t.identifier('length'))
|
|
1028
|
+
}
|
|
1029
|
+
|
|
988
1030
|
export const createBinaryExpression = (
|
|
989
1031
|
condition: {
|
|
990
1032
|
operation: string
|
|
@@ -1005,36 +1047,25 @@ export const createBinaryExpression = (
|
|
|
1005
1047
|
|
|
1006
1048
|
// Array/Object operators
|
|
1007
1049
|
if (operation === 'isEmpty') {
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
conditionalIdentifier
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
identifier,
|
|
1014
|
-
]),
|
|
1015
|
-
t.identifier('length')
|
|
1016
|
-
)
|
|
1017
|
-
: t.memberExpression(identifier, t.identifier('length'))
|
|
1018
|
-
return t.binaryExpression('===', lengthExpr, t.numericLiteral(0))
|
|
1050
|
+
return t.binaryExpression(
|
|
1051
|
+
'===',
|
|
1052
|
+
createLengthExpression(identifier, conditionalIdentifier, t),
|
|
1053
|
+
t.numericLiteral(0)
|
|
1054
|
+
)
|
|
1019
1055
|
}
|
|
1020
1056
|
|
|
1021
1057
|
if (operation === 'isNotEmpty') {
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
]),
|
|
1028
|
-
t.identifier('length')
|
|
1029
|
-
)
|
|
1030
|
-
: t.memberExpression(identifier, t.identifier('length'))
|
|
1031
|
-
return t.binaryExpression('>', lengthExpr, t.numericLiteral(0))
|
|
1058
|
+
return t.binaryExpression(
|
|
1059
|
+
'>',
|
|
1060
|
+
createLengthExpression(identifier, conditionalIdentifier, t),
|
|
1061
|
+
t.numericLiteral(0)
|
|
1062
|
+
)
|
|
1032
1063
|
}
|
|
1033
1064
|
|
|
1034
1065
|
if (operation === 'lengthEquals' && operand !== undefined) {
|
|
1035
1066
|
return t.binaryExpression(
|
|
1036
1067
|
'===',
|
|
1037
|
-
|
|
1068
|
+
createLengthExpression(identifier, conditionalIdentifier, t),
|
|
1038
1069
|
resolveOperandExpression(operand, conditionalIdentifier, options)
|
|
1039
1070
|
)
|
|
1040
1071
|
}
|
|
@@ -1042,7 +1073,7 @@ export const createBinaryExpression = (
|
|
|
1042
1073
|
if (operation === 'lengthGreaterThan' && operand !== undefined) {
|
|
1043
1074
|
return t.binaryExpression(
|
|
1044
1075
|
'>',
|
|
1045
|
-
|
|
1076
|
+
createLengthExpression(identifier, conditionalIdentifier, t),
|
|
1046
1077
|
resolveOperandExpression(operand, conditionalIdentifier, options)
|
|
1047
1078
|
)
|
|
1048
1079
|
}
|
|
@@ -1050,17 +1081,18 @@ export const createBinaryExpression = (
|
|
|
1050
1081
|
if (operation === 'lengthLessThan' && operand !== undefined) {
|
|
1051
1082
|
return t.binaryExpression(
|
|
1052
1083
|
'<',
|
|
1053
|
-
|
|
1084
|
+
createLengthExpression(identifier, conditionalIdentifier, t),
|
|
1054
1085
|
resolveOperandExpression(operand, conditionalIdentifier, options)
|
|
1055
1086
|
)
|
|
1056
1087
|
}
|
|
1057
1088
|
|
|
1058
1089
|
if (operation === 'contains' && operand !== undefined) {
|
|
1059
1090
|
const operandExpr = resolveOperandExpression(operand, conditionalIdentifier, options)
|
|
1091
|
+
const target = createNullSafeCollection(identifier, conditionalIdentifier, t)
|
|
1060
1092
|
|
|
1061
1093
|
if (containsField) {
|
|
1062
1094
|
const itemParam = t.identifier('__item')
|
|
1063
|
-
return t.callExpression(t.memberExpression(
|
|
1095
|
+
return t.callExpression(t.memberExpression(target, t.identifier('some')), [
|
|
1064
1096
|
t.arrowFunctionExpression(
|
|
1065
1097
|
[itemParam],
|
|
1066
1098
|
t.binaryExpression(
|
|
@@ -1072,17 +1104,18 @@ export const createBinaryExpression = (
|
|
|
1072
1104
|
])
|
|
1073
1105
|
}
|
|
1074
1106
|
|
|
1075
|
-
return t.callExpression(t.memberExpression(
|
|
1107
|
+
return t.callExpression(t.memberExpression(target, t.identifier('includes')), [operandExpr])
|
|
1076
1108
|
}
|
|
1077
1109
|
|
|
1078
1110
|
if (operation === 'notContains' && operand !== undefined) {
|
|
1079
1111
|
const operandExpr = resolveOperandExpression(operand, conditionalIdentifier, options)
|
|
1112
|
+
const target = createNullSafeCollection(identifier, conditionalIdentifier, t)
|
|
1080
1113
|
|
|
1081
1114
|
if (containsField) {
|
|
1082
1115
|
const itemParam = t.identifier('__item')
|
|
1083
1116
|
return t.unaryExpression(
|
|
1084
1117
|
'!',
|
|
1085
|
-
t.callExpression(t.memberExpression(
|
|
1118
|
+
t.callExpression(t.memberExpression(target, t.identifier('some')), [
|
|
1086
1119
|
t.arrowFunctionExpression(
|
|
1087
1120
|
[itemParam],
|
|
1088
1121
|
t.binaryExpression(
|
|
@@ -1097,7 +1130,7 @@ export const createBinaryExpression = (
|
|
|
1097
1130
|
|
|
1098
1131
|
return t.unaryExpression(
|
|
1099
1132
|
'!',
|
|
1100
|
-
t.callExpression(t.memberExpression(
|
|
1133
|
+
t.callExpression(t.memberExpression(target, t.identifier('includes')), [operandExpr])
|
|
1101
1134
|
)
|
|
1102
1135
|
}
|
|
1103
1136
|
|
|
@@ -1111,7 +1144,7 @@ export const createBinaryExpression = (
|
|
|
1111
1144
|
),
|
|
1112
1145
|
t.identifier('call')
|
|
1113
1146
|
),
|
|
1114
|
-
[identifier, operandExpr]
|
|
1147
|
+
[createNullSafeCollection(identifier, conditionalIdentifier, t), operandExpr]
|
|
1115
1148
|
)
|
|
1116
1149
|
}
|
|
1117
1150
|
|
|
@@ -1127,7 +1160,7 @@ export const createBinaryExpression = (
|
|
|
1127
1160
|
),
|
|
1128
1161
|
t.identifier('call')
|
|
1129
1162
|
),
|
|
1130
|
-
[identifier, operandExpr]
|
|
1163
|
+
[createNullSafeCollection(identifier, conditionalIdentifier, t), operandExpr]
|
|
1131
1164
|
)
|
|
1132
1165
|
)
|
|
1133
1166
|
}
|
package/src/utils/ast-utils.ts
CHANGED
|
@@ -477,6 +477,45 @@ export const addAttributeToJSXTag = (
|
|
|
477
477
|
return
|
|
478
478
|
}
|
|
479
479
|
|
|
480
|
+
// An object-valued attribute (e.g. `style={{ ... }}`) can be contributed by
|
|
481
|
+
// more than one independent code path — e.g. a ctx-scoped dynamic style value
|
|
482
|
+
// resolved at JSX-build time, and a `dynamicStyleBindings` inline style added
|
|
483
|
+
// later by a style plugin. Pushing a second `style` JSXAttribute would silently
|
|
484
|
+
// drop one of the two (JS keeps only the last of duplicate object keys once
|
|
485
|
+
// transpiled), so merge into the existing ObjectExpression instead, replacing
|
|
486
|
+
// any property with a matching key so the newer value wins.
|
|
487
|
+
if (
|
|
488
|
+
attribute &&
|
|
489
|
+
attribute.value?.type === 'JSXExpressionContainer' &&
|
|
490
|
+
attribute.value.expression.type === 'ObjectExpression' &&
|
|
491
|
+
attributeDefinition.value?.type === 'JSXExpressionContainer' &&
|
|
492
|
+
attributeDefinition.value.expression.type === 'ObjectExpression'
|
|
493
|
+
) {
|
|
494
|
+
const existingProps = attribute.value.expression.properties
|
|
495
|
+
attributeDefinition.value.expression.properties.forEach((newProp) => {
|
|
496
|
+
if (newProp.type !== 'ObjectProperty' || newProp.key.type === 'PrivateName') {
|
|
497
|
+
existingProps.push(newProp)
|
|
498
|
+
return
|
|
499
|
+
}
|
|
500
|
+
const newKeyName =
|
|
501
|
+
newProp.key.type === 'Identifier' ? newProp.key.name : String((newProp.key as any).value)
|
|
502
|
+
const existingIndex = existingProps.findIndex((prop) => {
|
|
503
|
+
if (prop.type !== 'ObjectProperty' || prop.key.type === 'PrivateName') {
|
|
504
|
+
return false
|
|
505
|
+
}
|
|
506
|
+
const existingKeyName =
|
|
507
|
+
prop.key.type === 'Identifier' ? prop.key.name : String((prop.key as any).value)
|
|
508
|
+
return existingKeyName === newKeyName
|
|
509
|
+
})
|
|
510
|
+
if (existingIndex >= 0) {
|
|
511
|
+
existingProps[existingIndex] = newProp
|
|
512
|
+
} else {
|
|
513
|
+
existingProps.push(newProp)
|
|
514
|
+
}
|
|
515
|
+
})
|
|
516
|
+
return
|
|
517
|
+
}
|
|
518
|
+
|
|
480
519
|
jsxNode.openingElement.attributes.push(attributeDefinition)
|
|
481
520
|
}
|
|
482
521
|
|