@wix/zero-config-implementation 1.7.0 → 1.8.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.
@@ -1,6 +1,6 @@
1
1
  export { ExtractorStore } from './store';
2
2
  export { runExtractors } from './runner';
3
- export type { ExtractionResult } from './runner';
3
+ export type { ExtractionResult, RunExtractorsOptions } from './runner';
4
4
  export { buildElementTree } from './tree-builder';
5
5
  export type { ExtractedElement } from './tree-builder';
6
6
  export type { ReactExtractor, RenderContext, CreateElementEvent, RenderCompleteEvent } from './types';
@@ -8,6 +8,10 @@ export interface ExtractionResult {
8
8
  store: ExtractorStore;
9
9
  elements: ExtractedElement[];
10
10
  }
11
+ export interface RunExtractorsOptions {
12
+ /** Optional HOC to wrap the component before rendering (e.g. a context provider). */
13
+ wrapper?: (component: ComponentType<unknown>) => ComponentType<unknown>;
14
+ }
11
15
  /**
12
16
  * Runs extractors through the full lifecycle and returns extraction results.
13
17
  *
@@ -16,4 +20,4 @@ export interface ExtractionResult {
16
20
  * @param extractors - Array of extractors to run
17
21
  * @returns Extraction results including HTML, store, and element tree
18
22
  */
19
- export declare function runExtractors(componentInfo: ComponentInfo, component: ComponentType<unknown>, extractors: ReactExtractor[]): ExtractionResult;
23
+ export declare function runExtractors(componentInfo: ComponentInfo, component: ComponentType<unknown>, extractors: ReactExtractor[], options?: RunExtractorsOptions): ExtractionResult;
@@ -4,7 +4,7 @@
4
4
  * Core infrastructure and pluggable extractors for the React information extraction system.
5
5
  */
6
6
  export { ExtractorStore, runExtractors, buildElementTree, } from './core';
7
- export type { ExtractionResult, ExtractedElement, ReactExtractor, RenderContext, CreateElementEvent, RenderCompleteEvent, } from './core';
7
+ export type { ExtractionResult, RunExtractorsOptions, ExtractedElement, ReactExtractor, RenderContext, CreateElementEvent, RenderCompleteEvent, } from './core';
8
8
  export { createPropTrackerExtractor } from './prop-tracker';
9
9
  export type { PropTrackerData, PropTrackerExtractorState } from './prop-tracker';
10
10
  export { createCssPropertiesExtractor } from './css-properties';
@@ -4,6 +4,6 @@
4
4
  * API: runExtractors() with pluggable extractors
5
5
  */
6
6
  export { ExtractorStore, runExtractors, buildElementTree, createPropTrackerExtractor, createCssPropertiesExtractor, } from './extractors';
7
- export type { ExtractionResult, ExtractedElement, ReactExtractor, RenderContext, CreateElementEvent, RenderCompleteEvent, PropTrackerData, PropTrackerExtractorState, CssPropertiesData, } from './extractors';
7
+ export type { ExtractionResult, RunExtractorsOptions, ExtractedElement, ReactExtractor, RenderContext, CreateElementEvent, RenderCompleteEvent, PropTrackerData, PropTrackerExtractorState, CssPropertiesData, } from './extractors';
8
8
  export type { CoupledComponentInfo, CoupledProp, TrackingStores, DOMBinding, PropReadInfo, PropWriteInfo, PropSpyMeta, } from './types';
9
9
  export type { PropSpyContext } from './utils/prop-spy';
@@ -1,5 +1,5 @@
1
1
  import { ComponentInfo } from './information-extractors/ts';
2
- import { CoupledComponentInfo } from './information-extractors/react';
2
+ import { RunExtractorsOptions, CoupledComponentInfo } from './information-extractors/react';
3
3
  import { CSSParserAPI } from './information-extractors/css';
4
4
  import { ComponentType } from 'react';
5
5
  /** A non-fatal issue encountered during component processing. */
@@ -30,4 +30,4 @@ export interface ProcessComponentResult {
30
30
  * encountered during processing. Always returns a component, falling back
31
31
  * to minimal info (without DOM coupling) when rendering fails.
32
32
  */
33
- export declare function processComponent(componentInfo: ComponentInfo, loadComponent: (componentName: string) => ComponentType<unknown> | null, cssImportPaths: string[], loaderHasError?: boolean): ProcessComponentResult;
33
+ export declare function processComponent(componentInfo: ComponentInfo, loadComponent: (componentName: string) => ComponentType<unknown> | null, cssImportPaths: string[], loaderHasError?: boolean, options?: RunExtractorsOptions): ProcessComponentResult;
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.0",
7
+ "version": "1.8.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",
@@ -74,5 +74,5 @@
74
74
  ]
75
75
  }
76
76
  },
77
- "falconPackageHash": "95c3bb44ab2a1406f75946ef5d30cec9f4ce31059113151e31289d75"
77
+ "falconPackageHash": "8ca973dc7cc82c6e8d0a333de6717b866e33337ee211bd335f3fa800"
78
78
  }
package/src/index.ts CHANGED
@@ -13,6 +13,7 @@ import { type NotFoundError, ParseError } from './errors'
13
13
  // Component loader helpers
14
14
  import { findComponent, loadModule } from './module-loader'
15
15
 
16
+ import type { RunExtractorsOptions } from './information-extractors/react'
16
17
  // Pipeline orchestration
17
18
  import { processComponent } from './manifest-pipeline'
18
19
  export type {
@@ -36,6 +37,8 @@ export interface ManifestResult {
36
37
  errors: ExtractionError[]
37
38
  }
38
39
 
40
+ export type { RunExtractorsOptions } from './information-extractors/react'
41
+
39
42
  export interface ExtractionError {
40
43
  componentName: string
41
44
  phase: 'render' | 'coupling' | 'css' | 'loader' | 'conversion'
@@ -59,6 +62,7 @@ export interface ExtractionError {
59
62
  export function extractComponentManifest(
60
63
  componentPath: string,
61
64
  compiledEntryPath: string,
65
+ options?: RunExtractorsOptions,
62
66
  ): ResultAsync<ManifestResult, InstanceType<typeof NotFoundError> | InstanceType<typeof ParseError>> {
63
67
  // Step 1: Load the compiled package module (non-fatal)
64
68
  return loadModule(compiledEntryPath)
@@ -126,7 +130,7 @@ export function extractComponentManifest(
126
130
  }
127
131
 
128
132
  // Step 5: Process the default-exported component (non-fatal)
129
- const processResult = processComponent(componentInfo, loadComponent, cssImportPaths, !!loaderError)
133
+ const processResult = processComponent(componentInfo, loadComponent, cssImportPaths, !!loaderError, options)
130
134
  errors.push(...processResult.warnings)
131
135
  const component = toEditorReactComponent(processResult.component)
132
136
 
@@ -1,6 +1,6 @@
1
1
  export { ExtractorStore } from './store'
2
2
  export { runExtractors } from './runner'
3
- export type { ExtractionResult } from './runner'
3
+ export type { ExtractionResult, RunExtractorsOptions } from './runner'
4
4
  export { buildElementTree } from './tree-builder'
5
5
  export type { ExtractedElement } from './tree-builder'
6
6
  export type { ReactExtractor, RenderContext, CreateElementEvent, RenderCompleteEvent } from './types'
@@ -27,6 +27,11 @@ export interface ExtractionResult {
27
27
  elements: ExtractedElement[]
28
28
  }
29
29
 
30
+ export interface RunExtractorsOptions {
31
+ /** Optional HOC to wrap the component before rendering (e.g. a context provider). */
32
+ wrapper?: (component: ComponentType<unknown>) => ComponentType<unknown>
33
+ }
34
+
30
35
  // ─────────────────────────────────────────────────────────────────────────────
31
36
  // Runner
32
37
  // ─────────────────────────────────────────────────────────────────────────────
@@ -43,6 +48,7 @@ export function runExtractors(
43
48
  componentInfo: ComponentInfo,
44
49
  component: ComponentType<unknown>,
45
50
  extractors: ReactExtractor[],
51
+ options?: RunExtractorsOptions,
46
52
  ): ExtractionResult {
47
53
  // Reset mock counter for reproducible results
48
54
  resetMockCounter()
@@ -74,8 +80,11 @@ export function runExtractors(
74
80
  },
75
81
  ]
76
82
 
83
+ // Apply optional HOC wrapper before rendering
84
+ const renderComponent = options?.wrapper ? options.wrapper(context.component) : context.component
85
+
77
86
  // Phase 2: Render with element creation interception
78
- const html = renderWithExtractors(context.component, context.props, listeners, store)
87
+ const html = renderWithExtractors(renderComponent, context.props, listeners, store)
79
88
 
80
89
  // Phase 3: renderComplete - extractors can post-process
81
90
  for (const ext of extractors) {
@@ -12,6 +12,7 @@ export {
12
12
  } from './core'
13
13
  export type {
14
14
  ExtractionResult,
15
+ RunExtractorsOptions,
15
16
  ExtractedElement,
16
17
  ReactExtractor,
17
18
  RenderContext,
@@ -21,6 +21,7 @@ export {
21
21
  export type {
22
22
  // Core types
23
23
  ExtractionResult,
24
+ RunExtractorsOptions,
24
25
  ExtractedElement,
25
26
  ReactExtractor,
26
27
  RenderContext,
@@ -6,6 +6,7 @@ import type { PropInfo } from './information-extractors/ts/types'
6
6
  import {
7
7
  type ExtractedElement,
8
8
  type PropTrackerData,
9
+ type RunExtractorsOptions,
9
10
  createCssPropertiesExtractor,
10
11
  createPropTrackerExtractor,
11
12
  runExtractors,
@@ -62,6 +63,7 @@ export function processComponent(
62
63
  loadComponent: (componentName: string) => ComponentType<unknown> | null,
63
64
  cssImportPaths: string[],
64
65
  loaderHasError?: boolean,
66
+ options?: RunExtractorsOptions,
65
67
  ): ProcessComponentResult {
66
68
  const warnings: ExtractionWarning[] = []
67
69
 
@@ -97,7 +99,7 @@ export function processComponent(
97
99
  const { extractor: propTracker, state } = createPropTrackerExtractor()
98
100
  const cssExtractor = createCssPropertiesExtractor()
99
101
 
100
- const result = runExtractors(componentInfo, Component, [propTracker, cssExtractor])
102
+ const result = runExtractors(componentInfo, Component, [propTracker, cssExtractor], options)
101
103
  html = result.html
102
104
  extractedElements = result.elements
103
105