@wix/zero-config-implementation 1.57.0 → 1.59.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/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "1.57.0",
7
+ "version": "1.59.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.4.0"
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": "4bf67c86fbcf48e852357c95257847e893cf3fac4b102da995bb8c5c"
88
+ "falconPackageHash": "3762cf48efbed240f0744fc678539dd9e70ea2021dc6171c70fb714b"
89
89
  }
@@ -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/public-schemas',
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/public-schemas packages.
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 public-schemas (Builder) types - map directly to DATA_TYPE via explicit lookup
376
- if (source === '@wix/public-schemas' || source === '@wix/editor-react-types') {
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/public-schemas A11y.
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/public-schemas A11y.
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/public-schemas' || packageName === '@wix/editor-react-types') {
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/public-schemas' || packageName === '@wix/editor-react-types') {
199
+ if (packageName === '@wix/editor-react-types') {
200
200
  if (isValidWixSemanticType(typeString)) {
201
201
  return {
202
202
  kind: 'semantic',
@@ -4,6 +4,7 @@ import { ResultAsync, errAsync } from 'neverthrow'
4
4
  import { parseNative } from 'tsconfck'
5
5
  import ts from 'typescript'
6
6
  import { NotFoundError, ParseError } from './errors'
7
+ import { createCompilerHostWithBundledLibs } from './ts-lib-host'
7
8
 
8
9
  /**
9
10
  * Compile a TypeScript file into a ts.Program.
@@ -30,5 +31,8 @@ export function compileTsFile(
30
31
  cause: error as Error,
31
32
  props: { phase: 'compile' },
32
33
  }),
33
- ).map(({ result }) => ts.createProgram([filePath], result.options))
34
+ ).map(({ result }) => {
35
+ const compilerHost = createCompilerHostWithBundledLibs(result.options)
36
+ return ts.createProgram([filePath], result.options, compilerHost)
37
+ })
34
38
  }
@@ -0,0 +1,44 @@
1
+ import { createRequire } from 'node:module'
2
+ import path from 'node:path'
3
+ import ts from 'typescript'
4
+
5
+ /**
6
+ * Creates a `ts.CompilerHost` that resolves TypeScript's `lib.*.d.ts` files
7
+ * from the host project's installed `typescript` package, rather than from
8
+ * the (potentially bundled) `typescript` we imported.
9
+ *
10
+ * Why: consumers that bundle this package (esbuild/tsup) inline `typescript`'s
11
+ * JS but cannot reach its on-disk `lib.*.d.ts` files at runtime. Without this
12
+ * override, `ts.getDefaultLibFilePath` returns a non-existent path and global
13
+ * symbols like `Array` and `Promise` go missing, silently collapsing prop types
14
+ * to `any`. `typescript` is declared as a peer dependency, so we can rely on
15
+ * the host project having an intact on-disk install reachable from its cwd.
16
+ */
17
+ export function createCompilerHostWithBundledLibs(options: ts.CompilerOptions): ts.CompilerHost {
18
+ const compilerHost = ts.createCompilerHost(options, true)
19
+ const hostLibDirectory = resolveHostTypeScriptLibDirectory()
20
+ if (!hostLibDirectory) return compilerHost
21
+
22
+ compilerHost.getDefaultLibLocation = () => hostLibDirectory
23
+ compilerHost.getDefaultLibFileName = (compilerOptions) =>
24
+ path.join(hostLibDirectory, ts.getDefaultLibFileName(compilerOptions))
25
+
26
+ return compilerHost
27
+ }
28
+
29
+ /**
30
+ * Locates the `lib/` directory of the host project's installed `typescript`
31
+ * package, walking up from the current working directory. Returns `undefined`
32
+ * if `typescript` cannot be resolved — in which case the default host's own
33
+ * lib location is used (correct for non-bundled callers, broken for bundled
34
+ * callers without a peer install).
35
+ */
36
+ function resolveHostTypeScriptLibDirectory(): string | undefined {
37
+ try {
38
+ const requireFromCwd = createRequire(path.join(process.cwd(), 'package.json'))
39
+ const typescriptEntryPath = requireFromCwd.resolve('typescript/lib/typescript.js')
40
+ return path.dirname(typescriptEntryPath)
41
+ } catch {
42
+ return undefined
43
+ }
44
+ }
@@ -1,8 +1,8 @@
1
1
  import type { DATA } from '@wix/react-component-schema'
2
2
 
3
3
  /**
4
- * Maps @wix/public-schemas type names (PascalCase) to their DATA_TYPE keys.
5
- * Derived from the exports of @wix/public-schemas.
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',