@wix/zero-config-implementation 1.56.0 → 1.58.0
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.d.ts +3 -2
- package/dist/index.js +1264 -1253
- package/package.json +3 -3
- package/src/component-renderer.ts +29 -10
- package/src/converters/data-item-builder.test.ts +1 -1
- package/src/converters/data-item-builder.ts +3 -3
- package/src/information-extractors/react/utils/mock-generator.ts +2 -2
- package/src/information-extractors/ts/utils/semantic-type-resolver.ts +2 -2
- package/src/wix-type-to-data-type.ts +2 -2
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"registry": "https://registry.npmjs.org/",
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
7
|
-
"version": "1.
|
|
7
|
+
"version": "1.58.0",
|
|
8
8
|
"description": "Core library for extracting component manifests from JS and CSS files",
|
|
9
9
|
"type": "module",
|
|
10
10
|
"main": "dist/index.js",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@wix/react-component-schema": "1.
|
|
47
|
+
"@wix/react-component-schema": "1.5.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
50
|
"@faker-js/faker": "^10.2.0",
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
]
|
|
86
86
|
}
|
|
87
87
|
},
|
|
88
|
-
"falconPackageHash": "
|
|
88
|
+
"falconPackageHash": "f7fcdc7c7a9bd8348098a4e3301700ca40fb26281cd6352c13146b45"
|
|
89
89
|
}
|
|
@@ -30,8 +30,11 @@
|
|
|
30
30
|
* location on disk — a separate React module instance. To cover this case,
|
|
31
31
|
* the renderer also calls `createRequire(compiledEntryPath)` to obtain the
|
|
32
32
|
* user-bundle's React (and `react/jsx-runtime` / `react/jsx-dev-runtime`)
|
|
33
|
-
* and applies the same interceptors to those modules' exports.
|
|
34
|
-
*
|
|
33
|
+
* and applies the same interceptors to those modules' exports. It also
|
|
34
|
+
* drives SSR with the user-bundle's `react-dom/server` so the dispatcher
|
|
35
|
+
* lands on the user React's internals — the same instance the user
|
|
36
|
+
* component reads from — and hooks like `useState` work naturally.
|
|
37
|
+
* Identity guards keep the single-React case a no-op.
|
|
35
38
|
*
|
|
36
39
|
* ## Intercepted Functions
|
|
37
40
|
*
|
|
@@ -134,8 +137,9 @@ function createInterceptor(
|
|
|
134
137
|
* @param store - Shared ExtractorStore, included in each CreateElementEvent
|
|
135
138
|
* @param compiledEntryPath - Optional path to the user's compiled bundle. When
|
|
136
139
|
* provided, the renderer additionally patches the React module instance
|
|
137
|
-
* that the bundle resolves from its own `node_modules`
|
|
138
|
-
*
|
|
140
|
+
* that the bundle resolves from its own `node_modules` and drives SSR
|
|
141
|
+
* with the user-bundle's `react-dom/server` (required when the host
|
|
142
|
+
* bundles its own React; otherwise hooks crash).
|
|
139
143
|
* @returns Static HTML string with trace IDs on DOM elements
|
|
140
144
|
*
|
|
141
145
|
* @example
|
|
@@ -174,9 +178,11 @@ export function renderWithExtractors(
|
|
|
174
178
|
// Resolve the user-bundle's React (and jsx-runtime variants) from the bundle's
|
|
175
179
|
// own location on disk. When the host (e.g. a CLI) bundled its own React, this
|
|
176
180
|
// resolves to a different module instance and must be patched separately.
|
|
177
|
-
//
|
|
178
|
-
//
|
|
181
|
+
// When the user's React is distinct, also resolve its `react-dom/server` and
|
|
182
|
+
// drive SSR with that — the dispatcher then lands on the same React instance
|
|
183
|
+
// the user component reads from, so hooks like `useState` work naturally.
|
|
179
184
|
let userReact: { createElement: ElementCreator } | undefined
|
|
185
|
+
let userRenderToStaticMarkup: typeof renderToStaticMarkup | undefined
|
|
180
186
|
let userJsxRuntime: Record<string, unknown> | undefined
|
|
181
187
|
let userJsxDevRuntime: Record<string, unknown> | undefined
|
|
182
188
|
let origUserCreateElement: ElementCreator | undefined
|
|
@@ -191,6 +197,16 @@ export function renderWithExtractors(
|
|
|
191
197
|
if (candidateReact !== (React as unknown as typeof candidateReact)) {
|
|
192
198
|
userReact = candidateReact
|
|
193
199
|
origUserCreateElement = candidateReact.createElement
|
|
200
|
+
try {
|
|
201
|
+
userRenderToStaticMarkup = (
|
|
202
|
+
userRequire('react-dom/server') as { renderToStaticMarkup: typeof renderToStaticMarkup }
|
|
203
|
+
).renderToStaticMarkup
|
|
204
|
+
} catch (cause) {
|
|
205
|
+
throw new Error(
|
|
206
|
+
`Component bundle at "${compiledEntryPath}" resolves a different React than the host; install "react-dom" alongside "react" so SSR can run against the user's React.`,
|
|
207
|
+
{ cause: cause as Error },
|
|
208
|
+
)
|
|
209
|
+
}
|
|
194
210
|
}
|
|
195
211
|
const candidateJsx = userRequire('react/jsx-runtime') as Record<string, unknown>
|
|
196
212
|
if (candidateJsx !== cjsRuntime) {
|
|
@@ -203,8 +219,10 @@ export function renderWithExtractors(
|
|
|
203
219
|
userJsxDevRuntime = candidateJsxDev
|
|
204
220
|
origUserJsxDEV = candidateJsxDev.jsxDEV
|
|
205
221
|
}
|
|
206
|
-
} catch {
|
|
207
|
-
//
|
|
222
|
+
} catch (error) {
|
|
223
|
+
// The wrapped react-dom error has userReact set; rethrow it.
|
|
224
|
+
// Otherwise the user bundle path doesn't resolve react locally — nothing to patch.
|
|
225
|
+
if (userReact) throw error
|
|
208
226
|
}
|
|
209
227
|
}
|
|
210
228
|
|
|
@@ -245,8 +263,9 @@ export function renderWithExtractors(
|
|
|
245
263
|
userJsxDevRuntime.jsxDEV = interceptedJsxDEV
|
|
246
264
|
}
|
|
247
265
|
|
|
248
|
-
const
|
|
249
|
-
|
|
266
|
+
const renderingReact = userReact ?? React
|
|
267
|
+
const element = renderingReact.createElement(Component, componentProps as Record<string, unknown>)
|
|
268
|
+
return (userRenderToStaticMarkup ?? renderToStaticMarkup)(element)
|
|
250
269
|
} finally {
|
|
251
270
|
// Restore originals
|
|
252
271
|
React.createElement = originalCreateElement
|
|
@@ -49,7 +49,7 @@ describe('buildDataItem — arrayItems oneof branching', () => {
|
|
|
49
49
|
const semanticImage: ResolvedType = {
|
|
50
50
|
kind: 'semantic',
|
|
51
51
|
value: 'Image',
|
|
52
|
-
source: '@wix/
|
|
52
|
+
source: '@wix/editor-react-types',
|
|
53
53
|
}
|
|
54
54
|
const result = buildDataItem(buildArrayProp(semanticImage))
|
|
55
55
|
expect(result.isOk()).toBe(true)
|
|
@@ -344,7 +344,7 @@ function handleUnionType(
|
|
|
344
344
|
}
|
|
345
345
|
|
|
346
346
|
/**
|
|
347
|
-
* Handles semantic types from React and @wix/
|
|
347
|
+
* Handles semantic types from React and @wix/editor-react-types packages.
|
|
348
348
|
* Unknown semantic sources or types silently fall back to text.
|
|
349
349
|
*/
|
|
350
350
|
function handleSemanticType({
|
|
@@ -372,8 +372,8 @@ function handleSemanticType({
|
|
|
372
372
|
return
|
|
373
373
|
}
|
|
374
374
|
|
|
375
|
-
// Wix
|
|
376
|
-
if (source === '@wix/
|
|
375
|
+
// Wix editor-react-types (Builder) types - map directly to DATA_TYPE via explicit lookup
|
|
376
|
+
if (source === '@wix/editor-react-types') {
|
|
377
377
|
const dataTypeKey = WIX_TYPE_TO_DATA_TYPE[semanticValue]
|
|
378
378
|
if (dataTypeKey) {
|
|
379
379
|
dataItem.dataType = DATA_TYPE[dataTypeKey]
|
|
@@ -383,7 +383,7 @@ function generateMockLink(): Record<string, unknown> {
|
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
|
|
386
|
-
// String fields and string-literal-union fields of @wix/
|
|
386
|
+
// String fields and string-literal-union fields of @wix/editor-react-types A11y.
|
|
387
387
|
// These are emitted as unique trackable strings — DOM/React will accept any
|
|
388
388
|
// string for `aria-*` attributes regardless of the TS type union, so the spy
|
|
389
389
|
// markers flow through unchanged and the prop-tracker can detect usage.
|
|
@@ -412,7 +412,7 @@ const A11Y_STRING_FIELDS = [
|
|
|
412
412
|
'ariaInvalid',
|
|
413
413
|
] as const
|
|
414
414
|
|
|
415
|
-
// Numeric fields of @wix/
|
|
415
|
+
// Numeric fields of @wix/editor-react-types A11y.
|
|
416
416
|
const A11Y_NUMBER_FIELDS = ['tabIndex', 'ariaLevel'] as const
|
|
417
417
|
|
|
418
418
|
// Pure-boolean A11y fields (e.g. `multiline`) are intentionally omitted: the
|
|
@@ -74,7 +74,7 @@ function checkForSemanticType(
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// Check Wix types - only ones that map to DATA_TYPE keys
|
|
77
|
-
if (packageName === '@wix/
|
|
77
|
+
if (packageName === '@wix/editor-react-types') {
|
|
78
78
|
if (isValidWixSemanticType(symbolName)) {
|
|
79
79
|
return { kind: 'semantic', value: symbolName, source: packageName }
|
|
80
80
|
}
|
|
@@ -196,7 +196,7 @@ function resolveTypeBody({
|
|
|
196
196
|
}
|
|
197
197
|
|
|
198
198
|
// Check Wix types - only ones that map to DATA_TYPE keys
|
|
199
|
-
if (packageName === '@wix/
|
|
199
|
+
if (packageName === '@wix/editor-react-types') {
|
|
200
200
|
if (isValidWixSemanticType(typeString)) {
|
|
201
201
|
return {
|
|
202
202
|
kind: 'semantic',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { DATA } from '@wix/react-component-schema'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* Maps @wix/
|
|
5
|
-
* Derived from the exports of @wix/
|
|
4
|
+
* Maps @wix/editor-react-types type names (PascalCase) to their DATA_TYPE keys.
|
|
5
|
+
* Derived from the exports of @wix/editor-react-types.
|
|
6
6
|
*/
|
|
7
7
|
export const WIX_TYPE_TO_DATA_TYPE: Record<string, keyof typeof DATA.DATA_TYPE> = {
|
|
8
8
|
Link: 'link',
|