@wix/zero-config-implementation 1.36.0 → 1.37.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/README.md CHANGED
@@ -15,19 +15,24 @@ Peer dependencies: `react` (^18 || ^19), `react-dom` (^18 || ^19), `typescript`
15
15
  ### Programmatic
16
16
 
17
17
  ```ts
18
- import { extractComponentManifest } from '@wix/zero-config'
18
+ import { extractComponentManifest, extractComponentManifestResult } from '@wix/zero-config'
19
19
 
20
- const result = await extractComponentManifest(
20
+ const manifest = await extractComponentManifest(
21
21
  './src/MyComponent.tsx',
22
22
  './dist/index.js', // path to the compiled JS entry of the component's package
23
23
  )
24
24
 
25
+ console.log(manifest.component) // EditorReactComponent
26
+ console.log(manifest.errors) // non-fatal ExtractionError[]
27
+
28
+ // If you prefer neverthrow ResultAsync semantics:
29
+ const result = await extractComponentManifestResult('./src/MyComponent.tsx', './dist/index.js')
25
30
  result.match(
26
- (manifest) => {
27
- console.log(manifest.component) // EditorReactComponent
28
- console.log(manifest.errors) // non-fatal ExtractionError[]
31
+ (manifestResult) => {
32
+ console.log(manifestResult.component)
33
+ console.log(manifestResult.errors)
29
34
  },
30
- (err) => console.error(err),
35
+ (error) => console.error(error),
31
36
  )
32
37
  ```
33
38
 
@@ -53,7 +58,8 @@ npx @wix/zero-config
53
58
 
54
59
  ## API layers
55
60
 
56
- - **Tier 1 — High-level:** `extractComponentManifest()` — one call, default pipeline.
61
+ - **Tier 1 — High-level:** `extractComponentManifest()` — one call, default pipeline (`Promise<ManifestResult>`).
62
+ - **Tier 1 (neverthrow variant):** `extractComponentManifestResult()` — same pipeline with `ResultAsync` return.
57
63
  - **Tier 2 — Pipeline building blocks:** `compileTsFile`, `extractAllComponentInfo`, `extractCssImports`, `processComponent`, `runExtractors`, `ExtractorStore`, `buildElementTree`, `createPropTrackerExtractor`, `createCssPropertiesExtractor`, `parseCss`, `toEditorReactComponent`, and exported types (e.g. `ComponentInfo`, `PropInfo`, `ExtractionResult`, `ReactExtractor`).
58
64
  - **Tier 3 — Low-level:** `renderWithExtractors`, `CreateElementListener` for custom createElement/JSX interception.
59
65
 
package/dist/index.d.ts CHANGED
@@ -813,7 +813,7 @@ declare type ExternalPluginsOptions<PluginsArg extends Plugins> = {
813
813
 
814
814
  export declare function extractAllComponentInfo(program: default_2.Program, filePath: string): ComponentInfo[];
815
815
 
816
- export declare function extractComponentManifest(componentPath: string, compiledEntryPath: string, options?: ExtractComponentManifestOptions): ResultAsync<ManifestResult, InstanceType<typeof NotFoundError> | InstanceType<typeof ParseError>>;
816
+ export declare function extractComponentManifest(componentPath: string, compiledEntryPath: string, options?: ExtractComponentManifestOptions): Promise<ManifestResult>;
817
817
 
818
818
  /**
819
819
  * Extract component manifest from a TypeScript source file.
@@ -829,6 +829,8 @@ export declare interface ExtractComponentManifestOptions extends RunExtractorsOp
829
829
  onError?: (error: ExtractionError) => void;
830
830
  }
831
831
 
832
+ export declare function extractComponentManifestResult(componentPath: string, compiledEntryPath: string, options?: ExtractComponentManifestOptions): ResultAsync<ManifestResult, InstanceType<typeof NotFoundError> | InstanceType<typeof ParseError>>;
833
+
832
834
  export declare function extractCssImports(program: Program): string[];
833
835
 
834
836
  /**
package/dist/index.js CHANGED
@@ -2930,14 +2930,14 @@ const Np = {
2930
2930
  /** Process exit code used by BaseError.exit(). */
2931
2931
  exitCode: 1
2932
2932
  }
2933
- }), Jp = hn.subclass("NotFoundError"), Ba = hn.subclass("ParseError"), B7 = hn.subclass("ValidationError"), $a = hn.subclass("IoError"), gw = hn.subclass("DefectError", {
2933
+ }), Jp = hn.subclass("NotFoundError"), Ba = hn.subclass("ParseError"), y7 = hn.subclass("ValidationError"), $a = hn.subclass("IoError"), gw = hn.subclass("DefectError", {
2934
2934
  props: {
2935
2935
  phase: "internal",
2936
2936
  isDefect: !0,
2937
2937
  exitCode: 70
2938
2938
  }
2939
2939
  }), fw = "https://github.com/wix-private/ZeroConfig/issues";
2940
- async function y7(e) {
2940
+ async function b7(e) {
2941
2941
  try {
2942
2942
  await e();
2943
2943
  } catch (t) {
@@ -20390,18 +20390,18 @@ const Hn = {
20390
20390
  ...eP,
20391
20391
  ...tP
20392
20392
  }), {
20393
- tokenize: w7,
20393
+ tokenize: k7,
20394
20394
  parse: Oy,
20395
20395
  generate: ui,
20396
20396
  lexer: nP,
20397
- createLexer: k7,
20397
+ createLexer: T7,
20398
20398
  walk: Hy,
20399
- find: T7,
20400
- findLast: N7,
20401
- findAll: R7,
20402
- toPlainObject: M7,
20403
- fromPlainObject: v7,
20404
- fork: L7
20399
+ find: N7,
20400
+ findLast: R7,
20401
+ findAll: M7,
20402
+ toPlainObject: v7,
20403
+ fromPlainObject: L7,
20404
+ fork: x7
20405
20405
  } = rP;
20406
20406
  function aP(e) {
20407
20407
  return e.atrule?.name === "keyframes";
@@ -45783,7 +45783,7 @@ function UV(e) {
45783
45783
  })
45784
45784
  ).map(({ result: r }) => xe.createProgram([e], r.options)) : Wn(new Jp(`File not found: ${t}`, { props: { phase: "compile" } }));
45785
45785
  }
45786
- function Y7(e, t, r) {
45786
+ function OV(e, t, r) {
45787
45787
  const n = [], a = (i) => {
45788
45788
  n.push(i), r?.onError?.(i);
45789
45789
  };
@@ -45840,6 +45840,14 @@ function Y7(e, t, r) {
45840
45840
  });
45841
45841
  });
45842
45842
  }
45843
+ async function W7(e, t, r) {
45844
+ return (await OV(e, t, r)).match(
45845
+ (a) => a,
45846
+ (a) => {
45847
+ throw a;
45848
+ }
45849
+ );
45850
+ }
45843
45851
  export {
45844
45852
  hn as BaseError,
45845
45853
  gw as DefectError,
@@ -45849,7 +45857,7 @@ export {
45849
45857
  Ba as ParseError,
45850
45858
  Ea as Result,
45851
45859
  Tt as ResultAsync,
45852
- B7 as ValidationError,
45860
+ y7 as ValidationError,
45853
45861
  s4 as buildElementTree,
45854
45862
  UV as compileTsFile,
45855
45863
  $3 as createCssPropertiesExtractor,
@@ -45857,7 +45865,8 @@ export {
45857
45865
  dr as err,
45858
45866
  Wn as errAsync,
45859
45867
  lg as extractAllComponentInfo,
45860
- Y7 as extractComponentManifest,
45868
+ W7 as extractComponentManifest,
45869
+ OV as extractComponentManifestResult,
45861
45870
  fk as extractCssImports,
45862
45871
  ak as extractDefaultComponentInfo,
45863
45872
  EV as findComponent,
@@ -45867,5 +45876,5 @@ export {
45867
45876
  iP as parseCss,
45868
45877
  pk as renderWithExtractors,
45869
45878
  u4 as runExtractors,
45870
- y7 as withDefectBoundary
45879
+ b7 as withDefectBoundary
45871
45880
  };
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "registry": "https://registry.npmjs.org/",
5
5
  "access": "public"
6
6
  },
7
- "version": "1.36.0",
7
+ "version": "1.37.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",
@@ -84,5 +84,5 @@
84
84
  ]
85
85
  }
86
86
  },
87
- "falconPackageHash": "783628b17db7e1730658c51eaaddf8d5abc8372807221c09c6828115"
87
+ "falconPackageHash": "ee9a93321f74030e3fae1f44881ad07be78e67c051afcb5ea562b546"
88
88
  }
package/src/index.ts CHANGED
@@ -39,7 +39,7 @@ export interface ExtractComponentManifestOptions extends RunExtractorsOptions {
39
39
  onError?: (error: ExtractionError) => void
40
40
  }
41
41
 
42
- export function extractComponentManifest(
42
+ export function extractComponentManifestResult(
43
43
  componentPath: string,
44
44
  compiledEntryPath: string,
45
45
  options?: ExtractComponentManifestOptions,
@@ -129,6 +129,20 @@ export function extractComponentManifest(
129
129
  })
130
130
  }
131
131
 
132
+ export async function extractComponentManifest(
133
+ componentPath: string,
134
+ compiledEntryPath: string,
135
+ options?: ExtractComponentManifestOptions,
136
+ ): Promise<ManifestResult> {
137
+ const extractionResult = await extractComponentManifestResult(componentPath, compiledEntryPath, options)
138
+ return extractionResult.match(
139
+ (manifestResult) => manifestResult,
140
+ (error) => {
141
+ throw error
142
+ },
143
+ )
144
+ }
145
+
132
146
  // ─────────────────────────────────────────────────────────────────────────────
133
147
  // Public API Exports
134
148
  //