@teleporthq/teleport-plugin-common 0.45.3-alpha.0 → 0.45.13
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__/builders/html-builders.ts +9 -2
- package/__tests__/builders/style-builders.ts +135 -1
- package/__tests__/node-handlers/node-to-html/index.ts +2 -0
- package/__tests__/node-handlers/node-to-jsx/attribute-value-mapper.ts +77 -0
- package/__tests__/node-handlers/node-to-jsx/calendar-events-reviver.ts +176 -0
- package/__tests__/node-handlers/node-to-jsx/chart-data-guard.ts +101 -0
- package/__tests__/node-handlers/node-to-jsx/cms-list-repeater-ecommerce-source.ts +79 -0
- package/__tests__/node-handlers/node-to-jsx/cms-list-repeater-loading.ts +122 -0
- package/__tests__/node-handlers/node-to-jsx/index.ts +719 -3
- package/__tests__/node-handlers/node-to-jsx/url-search-params-expression.ts +59 -0
- package/__tests__/node-handlers/node-to-jsx/utils.ts +635 -3
- package/__tests__/utils/ast-utils.ts +188 -0
- package/__tests__/utils/content-property-sanitiser.ts +156 -0
- package/__tests__/utils/page-seeds-state-from-data-source.ts +70 -0
- package/__tests__/utils/parse-string-with-template-expressions.ts +82 -0
- package/__tests__/utils/resource-auth-scheme.ts +55 -0
- package/__tests__/utils/route-utils.ts +118 -0
- package/__tests__/utils/style-utils.ts +59 -0
- package/__tests__/utils/template-expression-balance.ts +83 -0
- package/__tests__/utils/url-query-writer.ts +239 -0
- package/__tests__/utils/url-search-param-sync.ts +138 -0
- package/__tests__/utils/url-search-params.ts +48 -0
- package/dist/cjs/builders/ast-builders.d.ts +2 -0
- package/dist/cjs/builders/ast-builders.d.ts.map +1 -1
- package/dist/cjs/builders/ast-builders.js +41 -3
- package/dist/cjs/builders/ast-builders.js.map +1 -1
- package/dist/cjs/builders/hast-builders.d.ts +1 -0
- package/dist/cjs/builders/hast-builders.d.ts.map +1 -1
- package/dist/cjs/builders/hast-builders.js +11 -1
- package/dist/cjs/builders/hast-builders.js.map +1 -1
- package/dist/cjs/builders/style-builders.d.ts +8 -2
- package/dist/cjs/builders/style-builders.d.ts.map +1 -1
- package/dist/cjs/builders/style-builders.js +80 -33
- package/dist/cjs/builders/style-builders.js.map +1 -1
- package/dist/cjs/index.d.ts +5 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +10 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/node-handlers/node-to-html/constants.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-html/constants.js +2 -0
- package/dist/cjs/node-handlers/node-to-html/constants.js.map +1 -1
- package/dist/cjs/node-handlers/node-to-html/index.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-html/index.js +69 -1
- package/dist/cjs/node-handlers/node-to-html/index.js.map +1 -1
- package/dist/cjs/node-handlers/node-to-html/types.d.ts +5 -1
- package/dist/cjs/node-handlers/node-to-html/types.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-html/utils.d.ts +2 -1
- package/dist/cjs/node-handlers/node-to-html/utils.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-html/utils.js +174 -13
- 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 +1443 -45
- package/dist/cjs/node-handlers/node-to-jsx/index.js.map +1 -1
- package/dist/cjs/node-handlers/node-to-jsx/types.d.ts +60 -6
- package/dist/cjs/node-handlers/node-to-jsx/types.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-jsx/utils.d.ts +80 -7
- package/dist/cjs/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
- package/dist/cjs/node-handlers/node-to-jsx/utils.js +883 -72
- 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 +163 -11
- package/dist/cjs/utils/ast-utils.d.ts.map +1 -1
- package/dist/cjs/utils/ast-utils.js +1013 -75
- package/dist/cjs/utils/ast-utils.js.map +1 -1
- package/dist/cjs/utils/hast-utils.d.ts +8 -6
- package/dist/cjs/utils/hast-utils.d.ts.map +1 -1
- package/dist/cjs/utils/hast-utils.js +28 -4
- package/dist/cjs/utils/hast-utils.js.map +1 -1
- package/dist/cjs/utils/nested-selector-commas.d.ts +2 -0
- package/dist/cjs/utils/nested-selector-commas.d.ts.map +1 -0
- package/dist/cjs/utils/nested-selector-commas.js +81 -0
- package/dist/cjs/utils/nested-selector-commas.js.map +1 -0
- package/dist/cjs/utils/route-utils.d.ts +117 -0
- package/dist/cjs/utils/route-utils.d.ts.map +1 -0
- package/dist/cjs/utils/route-utils.js +212 -0
- package/dist/cjs/utils/route-utils.js.map +1 -0
- package/dist/cjs/utils/style-utils.d.ts +1 -0
- package/dist/cjs/utils/style-utils.d.ts.map +1 -1
- package/dist/cjs/utils/style-utils.js +181 -2
- package/dist/cjs/utils/style-utils.js.map +1 -1
- package/dist/cjs/utils/template-expression-balance.d.ts +58 -0
- package/dist/cjs/utils/template-expression-balance.d.ts.map +1 -0
- package/dist/cjs/utils/template-expression-balance.js +181 -0
- package/dist/cjs/utils/template-expression-balance.js.map +1 -0
- package/dist/cjs/utils/types.d.ts +3 -0
- package/dist/cjs/utils/types.d.ts.map +1 -0
- package/dist/cjs/utils/types.js +3 -0
- package/dist/cjs/utils/types.js.map +1 -0
- package/dist/cjs/utils/url-query-writer.d.ts +123 -0
- package/dist/cjs/utils/url-query-writer.d.ts.map +1 -0
- package/dist/cjs/utils/url-query-writer.js +260 -0
- package/dist/cjs/utils/url-query-writer.js.map +1 -0
- package/dist/cjs/utils/url-search-param-sync.d.ts +4 -0
- package/dist/cjs/utils/url-search-param-sync.d.ts.map +1 -0
- package/dist/cjs/utils/url-search-param-sync.js +241 -0
- package/dist/cjs/utils/url-search-param-sync.js.map +1 -0
- package/dist/cjs/utils/url-search-params.d.ts +48 -0
- package/dist/cjs/utils/url-search-params.d.ts.map +1 -0
- package/dist/cjs/utils/url-search-params.js +109 -0
- package/dist/cjs/utils/url-search-params.js.map +1 -0
- package/dist/esm/builders/ast-builders.d.ts +2 -0
- package/dist/esm/builders/ast-builders.d.ts.map +1 -1
- package/dist/esm/builders/ast-builders.js +40 -4
- package/dist/esm/builders/ast-builders.js.map +1 -1
- package/dist/esm/builders/hast-builders.d.ts +1 -0
- package/dist/esm/builders/hast-builders.d.ts.map +1 -1
- package/dist/esm/builders/hast-builders.js +9 -0
- package/dist/esm/builders/hast-builders.js.map +1 -1
- package/dist/esm/builders/style-builders.d.ts +8 -2
- package/dist/esm/builders/style-builders.d.ts.map +1 -1
- package/dist/esm/builders/style-builders.js +78 -32
- package/dist/esm/builders/style-builders.js.map +1 -1
- package/dist/esm/index.d.ts +5 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +5 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/node-handlers/node-to-html/constants.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-html/constants.js +2 -0
- package/dist/esm/node-handlers/node-to-html/constants.js.map +1 -1
- package/dist/esm/node-handlers/node-to-html/index.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-html/index.js +71 -3
- package/dist/esm/node-handlers/node-to-html/index.js.map +1 -1
- package/dist/esm/node-handlers/node-to-html/types.d.ts +5 -1
- package/dist/esm/node-handlers/node-to-html/types.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-html/utils.d.ts +2 -1
- package/dist/esm/node-handlers/node-to-html/utils.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-html/utils.js +170 -13
- 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 +1442 -47
- package/dist/esm/node-handlers/node-to-jsx/index.js.map +1 -1
- package/dist/esm/node-handlers/node-to-jsx/types.d.ts +60 -6
- package/dist/esm/node-handlers/node-to-jsx/types.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-jsx/utils.d.ts +80 -7
- package/dist/esm/node-handlers/node-to-jsx/utils.d.ts.map +1 -1
- package/dist/esm/node-handlers/node-to-jsx/utils.js +875 -70
- 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 +163 -11
- package/dist/esm/utils/ast-utils.d.ts.map +1 -1
- package/dist/esm/utils/ast-utils.js +989 -75
- package/dist/esm/utils/ast-utils.js.map +1 -1
- package/dist/esm/utils/hast-utils.d.ts +8 -6
- package/dist/esm/utils/hast-utils.d.ts.map +1 -1
- package/dist/esm/utils/hast-utils.js +26 -3
- package/dist/esm/utils/hast-utils.js.map +1 -1
- package/dist/esm/utils/nested-selector-commas.d.ts +2 -0
- package/dist/esm/utils/nested-selector-commas.d.ts.map +1 -0
- package/dist/esm/utils/nested-selector-commas.js +77 -0
- package/dist/esm/utils/nested-selector-commas.js.map +1 -0
- package/dist/esm/utils/route-utils.d.ts +117 -0
- package/dist/esm/utils/route-utils.d.ts.map +1 -0
- package/dist/esm/utils/route-utils.js +179 -0
- package/dist/esm/utils/route-utils.js.map +1 -0
- package/dist/esm/utils/style-utils.d.ts +1 -0
- package/dist/esm/utils/style-utils.d.ts.map +1 -1
- package/dist/esm/utils/style-utils.js +179 -1
- package/dist/esm/utils/style-utils.js.map +1 -1
- package/dist/esm/utils/template-expression-balance.d.ts +58 -0
- package/dist/esm/utils/template-expression-balance.d.ts.map +1 -0
- package/dist/esm/utils/template-expression-balance.js +174 -0
- package/dist/esm/utils/template-expression-balance.js.map +1 -0
- package/dist/esm/utils/types.d.ts +3 -0
- package/dist/esm/utils/types.d.ts.map +1 -0
- package/dist/esm/utils/types.js +2 -0
- package/dist/esm/utils/types.js.map +1 -0
- package/dist/esm/utils/url-query-writer.d.ts +123 -0
- package/dist/esm/utils/url-query-writer.d.ts.map +1 -0
- package/dist/esm/utils/url-query-writer.js +229 -0
- package/dist/esm/utils/url-query-writer.js.map +1 -0
- package/dist/esm/utils/url-search-param-sync.d.ts +4 -0
- package/dist/esm/utils/url-search-param-sync.d.ts.map +1 -0
- package/dist/esm/utils/url-search-param-sync.js +213 -0
- package/dist/esm/utils/url-search-param-sync.js.map +1 -0
- package/dist/esm/utils/url-search-params.d.ts +48 -0
- package/dist/esm/utils/url-search-params.d.ts.map +1 -0
- package/dist/esm/utils/url-search-params.js +81 -0
- package/dist/esm/utils/url-search-params.js.map +1 -0
- package/package.json +4 -4
- package/src/builders/ast-builders.ts +80 -3
- package/src/builders/hast-builders.ts +11 -0
- package/src/builders/style-builders.ts +121 -43
- package/src/index.ts +22 -1
- package/src/node-handlers/node-to-html/constants.ts +2 -0
- package/src/node-handlers/node-to-html/index.ts +126 -6
- package/src/node-handlers/node-to-html/types.ts +6 -0
- package/src/node-handlers/node-to-html/utils.ts +228 -14
- package/src/node-handlers/node-to-jsx/index.ts +2135 -62
- package/src/node-handlers/node-to-jsx/types.ts +75 -32
- package/src/node-handlers/node-to-jsx/utils.ts +1173 -84
- package/src/utils/ast-utils.ts +1316 -127
- package/src/utils/hast-utils.ts +37 -9
- package/src/utils/nested-selector-commas.ts +88 -0
- package/src/utils/route-utils.ts +214 -0
- package/src/utils/style-utils.ts +183 -1
- package/src/utils/template-expression-balance.ts +196 -0
- package/src/utils/types.ts +25 -0
- package/src/utils/url-query-writer.ts +318 -0
- package/src/utils/url-search-param-sync.ts +303 -0
- package/src/utils/url-search-params.ts +122 -0
|
@@ -4,16 +4,57 @@ import {
|
|
|
4
4
|
UIDLPropDefinition,
|
|
5
5
|
UIDLDependency,
|
|
6
6
|
UIDLStateDefinition,
|
|
7
|
-
|
|
7
|
+
UIDLGlobalReference,
|
|
8
|
+
UIDLGlobalStateDefinition,
|
|
9
|
+
UIDLLocaleAttributeReference,
|
|
8
10
|
} from '@teleporthq/teleport-types'
|
|
9
11
|
|
|
12
|
+
export interface GlobalStateReferenceEntry {
|
|
13
|
+
id: string
|
|
14
|
+
name: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface HoistedConstant {
|
|
18
|
+
name: string
|
|
19
|
+
expression: types.Expression
|
|
20
|
+
}
|
|
21
|
+
|
|
10
22
|
export interface JSXGenerationParams {
|
|
11
23
|
propDefinitions: Record<string, UIDLPropDefinition>
|
|
12
24
|
stateDefinitions: Record<string, UIDLStateDefinition>
|
|
13
|
-
|
|
25
|
+
globalStateDefinitions: Record<string, UIDLGlobalStateDefinition>
|
|
26
|
+
nodesLookup: Record<string, types.JSXElement | types.JSXExpressionContainer>
|
|
14
27
|
dependencies: Record<string, UIDLDependency>
|
|
15
28
|
windowImports: Record<string, types.ExpressionStatement>
|
|
16
|
-
|
|
29
|
+
localeReferences: types.JSXElement[]
|
|
30
|
+
/**
|
|
31
|
+
* Attributes bound to a translation key (`placeholder`, `alt`, `title`, …).
|
|
32
|
+
* Unlike a translated CHILD — which becomes a `<span>` the framework plugin
|
|
33
|
+
* fills with `dangerouslySetInnerHTML` — an attribute needs a plain string,
|
|
34
|
+
* so the attribute is emitted with the main-language text and recorded here
|
|
35
|
+
* for the framework's i18n plugin to rewrite into a translation lookup.
|
|
36
|
+
*/
|
|
37
|
+
localeAttributeReferences: UIDLLocaleAttributeReference[]
|
|
38
|
+
globalReferences: Array<UIDLGlobalReference['content']['id']>
|
|
39
|
+
globalStateReferences: GlobalStateReferenceEntry[]
|
|
40
|
+
hoistedConstants: HoistedConstant[]
|
|
41
|
+
/** When set, native form fields with `name` bind `value`/`checked` from this object state */
|
|
42
|
+
formStoreStateName?: string
|
|
43
|
+
/** Context propagated from a parent thq-autocomplete to its child option/clear elements */
|
|
44
|
+
autocompleteContext?: {
|
|
45
|
+
fieldName: string
|
|
46
|
+
inputHtmlId: string
|
|
47
|
+
formStateName?: string
|
|
48
|
+
isOpenStateName: string
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* On a dynamic details page, the name under which the fetched row is exposed
|
|
52
|
+
* to the page component as a prop (i.e. `initialPropsData.exposeAs.name`).
|
|
53
|
+
* A `referenceType: 'local'` reference at the page root (no enclosing
|
|
54
|
+
* repeater) resolves to `props.<detailsPageExposeAsName>.<refPath>` —
|
|
55
|
+
* conceptually "a column on the fetched row".
|
|
56
|
+
*/
|
|
57
|
+
detailsPageExposeAsName?: string
|
|
17
58
|
}
|
|
18
59
|
|
|
19
60
|
export interface JSXGenerationOptions {
|
|
@@ -29,6 +70,7 @@ export interface JSXGenerationOptions {
|
|
|
29
70
|
prop: string
|
|
30
71
|
state: string
|
|
31
72
|
local: string
|
|
73
|
+
ctx?: string
|
|
32
74
|
}
|
|
33
75
|
|
|
34
76
|
/*
|
|
@@ -55,6 +97,20 @@ export interface JSXGenerationOptions {
|
|
|
55
97
|
slotHandling?: 'native' | 'props'
|
|
56
98
|
customElementTag?: (name: string) => string
|
|
57
99
|
domHTMLInjection?: (content: string) => types.JSXElement
|
|
100
|
+
/*
|
|
101
|
+
The local context identifier for references inside repeaters/loops
|
|
102
|
+
For example, in a cms-list-repeater with renderPropIdentifier="conditions",
|
|
103
|
+
local references should resolve to properties of "conditions"
|
|
104
|
+
*/
|
|
105
|
+
localIdentifier?: string
|
|
106
|
+
/**
|
|
107
|
+
* On a dynamic details page, the name under which the fetched row is exposed
|
|
108
|
+
* to the page component as a prop (matches JSXGenerationParams field of the
|
|
109
|
+
* same name). Mirrored here so helpers that only receive `options` — notably
|
|
110
|
+
* `createDynamicValueExpression` — can resolve page-root `local` references
|
|
111
|
+
* without plumbing `params` through every call site.
|
|
112
|
+
*/
|
|
113
|
+
detailsPageExposeAsName?: string
|
|
58
114
|
}
|
|
59
115
|
|
|
60
116
|
export type NodeToJSX<NodeType, ReturnType> = (
|
|
@@ -67,38 +123,25 @@ export type JSXASTReturnType =
|
|
|
67
123
|
| string
|
|
68
124
|
| types.JSXExpressionContainer
|
|
69
125
|
| types.JSXElement
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
|
77
|
-
| '-'
|
|
78
|
-
| '/'
|
|
79
|
-
| '%'
|
|
80
|
-
| '*'
|
|
81
|
-
| '**'
|
|
82
|
-
| '&'
|
|
83
|
-
| '|'
|
|
84
|
-
| '>>'
|
|
85
|
-
| '>>>'
|
|
86
|
-
| '<<'
|
|
87
|
-
| '^'
|
|
88
|
-
| '=='
|
|
89
|
-
| '!='
|
|
90
|
-
| '!=='
|
|
91
|
-
| 'in'
|
|
92
|
-
| 'instanceof'
|
|
93
|
-
| '>'
|
|
94
|
-
| '<'
|
|
95
|
-
| '>='
|
|
96
|
-
| '<='
|
|
97
|
-
|
|
98
|
-
export type UnaryOperation = '+' | '-' | 'void' | 'throw' | 'delete' | '!' | '~' | 'typeof'
|
|
126
|
+
// Any Babel expression is legal as a JSX child — the printer wraps it in
|
|
127
|
+
// `{ ... }` when needed. The union intentionally broadens to `Expression`
|
|
128
|
+
// so helpers like `createDynamicValueExpression` can return specific
|
|
129
|
+
// subtypes (Identifier / MemberExpression / OptionalMemberExpression /
|
|
130
|
+
// LogicalExpression / CallExpression / ConditionalExpression …) without
|
|
131
|
+
// each call site needing to cast.
|
|
132
|
+
| types.Expression
|
|
99
133
|
|
|
100
134
|
export interface ConditionalIdentifier {
|
|
101
135
|
key: string
|
|
102
136
|
type: string
|
|
103
137
|
prefix?: string
|
|
138
|
+
referenceType?: string
|
|
139
|
+
/**
|
|
140
|
+
* True when `key` is raw JavaScript SOURCE (a UIDL `expr` reference) rather
|
|
141
|
+
* than the name of a binding. The two are emitted differently: a binding name
|
|
142
|
+
* has to survive the reserved-word sanitiser (`class` -> `class_`), while
|
|
143
|
+
* source must not be rewritten by it — the literal `false` is a value, and
|
|
144
|
+
* `false_` is an undefined variable that throws while the page renders.
|
|
145
|
+
*/
|
|
146
|
+
isExpression?: boolean
|
|
104
147
|
}
|