@wix/zero-config-implementation 1.42.0 → 1.43.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 +8 -3
- package/dist/index.js +968 -967
- package/package.json +2 -2
- package/src/index.ts +12 -5
- package/src/manifest-pipeline.ts +15 -13
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.43.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": "
|
|
87
|
+
"falconPackageHash": "2d91bb3d2ec5e1ed0c93907f33a6c14307f0cfe7d85c2a4b3210af66"
|
|
88
88
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { EditorReactComponent } from '@wix/zero-config-schema'
|
|
2
|
-
import { Result, type ResultAsync, okAsync } from 'neverthrow'
|
|
2
|
+
import { Result, type ResultAsync, errAsync, okAsync } from 'neverthrow'
|
|
3
3
|
import type { ComponentType } from 'react'
|
|
4
4
|
|
|
5
5
|
import { toEditorReactComponent } from './converters'
|
|
@@ -34,6 +34,7 @@ export interface ManifestResult {
|
|
|
34
34
|
* @errors
|
|
35
35
|
* - {@link NotFoundError} — Source file does not exist (phase: `compile`)
|
|
36
36
|
* - {@link ParseError} — TypeScript config or component types could not be parsed (phase: `compile` | `extract`)
|
|
37
|
+
* - {@link IoError} — Component loaded but render/extractors failed (phase: `render`)
|
|
37
38
|
*/
|
|
38
39
|
export interface ExtractComponentManifestOptions extends RunExtractorsOptions {
|
|
39
40
|
onError?: (error: ExtractionError) => void
|
|
@@ -43,7 +44,10 @@ export function extractComponentManifestResult(
|
|
|
43
44
|
componentPath: string,
|
|
44
45
|
compiledEntryPath: string,
|
|
45
46
|
options?: ExtractComponentManifestOptions,
|
|
46
|
-
): ResultAsync<
|
|
47
|
+
): ResultAsync<
|
|
48
|
+
ManifestResult,
|
|
49
|
+
InstanceType<typeof NotFoundError> | InstanceType<typeof ParseError> | InstanceType<typeof IoError>
|
|
50
|
+
> {
|
|
47
51
|
const errors: ExtractionError[] = []
|
|
48
52
|
const report = (error: ExtractionError): void => {
|
|
49
53
|
errors.push(error)
|
|
@@ -81,7 +85,7 @@ export function extractComponentManifestResult(
|
|
|
81
85
|
failure: null as LoadModuleFailure | null,
|
|
82
86
|
}))
|
|
83
87
|
.orElse((failure) => okAsync({ loadComponent: () => null as ComponentType<unknown> | null, failure }))
|
|
84
|
-
.
|
|
88
|
+
.andThen(({ loadComponent, failure }) => {
|
|
85
89
|
if (failure) {
|
|
86
90
|
if (failure.esmError) {
|
|
87
91
|
report({
|
|
@@ -114,7 +118,7 @@ export function extractComponentManifestResult(
|
|
|
114
118
|
})
|
|
115
119
|
}
|
|
116
120
|
|
|
117
|
-
// Step 5: Process the default-exported component (non-fatal)
|
|
121
|
+
// Step 5: Process the default-exported component (non-fatal unless render fails after load)
|
|
118
122
|
const processResult = processComponent(
|
|
119
123
|
componentInfo,
|
|
120
124
|
loadComponent,
|
|
@@ -123,8 +127,11 @@ export function extractComponentManifestResult(
|
|
|
123
127
|
report,
|
|
124
128
|
options,
|
|
125
129
|
)
|
|
130
|
+
if (!processResult.ok) {
|
|
131
|
+
return errAsync(processResult.error)
|
|
132
|
+
}
|
|
126
133
|
const component = toEditorReactComponent(processResult.component)
|
|
127
|
-
return { component, errors }
|
|
134
|
+
return okAsync({ component, errors })
|
|
128
135
|
})
|
|
129
136
|
})
|
|
130
137
|
}
|
package/src/manifest-pipeline.ts
CHANGED
|
@@ -41,9 +41,9 @@ export interface ComponentInfoWithCss extends CoupledComponentInfo {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/** The result of processing a single component through the manifest pipeline. */
|
|
44
|
-
export
|
|
45
|
-
component: ComponentInfoWithCss
|
|
46
|
-
}
|
|
44
|
+
export type ProcessComponentResult =
|
|
45
|
+
| { ok: true; component: ComponentInfoWithCss }
|
|
46
|
+
| { ok: false; error: InstanceType<typeof IoError> }
|
|
47
47
|
|
|
48
48
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
49
49
|
// Component Processing
|
|
@@ -53,9 +53,12 @@ export interface ProcessComponentResult {
|
|
|
53
53
|
* Processes a single component through the full manifest pipeline:
|
|
54
54
|
* loading, rendering with prop tracking, CSS extraction, and selector matching.
|
|
55
55
|
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
56
|
+
* On success (`ok: true`), returns enriched component info. Non-fatal loader/CSS
|
|
57
|
+
* issues are reported via `report` only; when the module did not load, a fallback
|
|
58
|
+
* manifest (TS props without DOM coupling) is still returned.
|
|
59
|
+
*
|
|
60
|
+
* When the component was loaded but render/extractors throw, returns `ok: false`
|
|
61
|
+
* with an {@link IoError} — Tier-1 callers should turn that into a failed `Result`.
|
|
59
62
|
*/
|
|
60
63
|
export function processComponent(
|
|
61
64
|
componentInfo: ComponentInfo,
|
|
@@ -117,14 +120,12 @@ export function processComponent(
|
|
|
117
120
|
propUsages: state.stores.propUsages,
|
|
118
121
|
}
|
|
119
122
|
} catch (thrownError) {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
phase: 'render',
|
|
123
|
-
error: new IoError(thrownError instanceof Error ? thrownError.message : String(thrownError), {
|
|
124
|
-
cause: thrownError instanceof Error ? thrownError : undefined,
|
|
125
|
-
props: { phase: 'render' },
|
|
126
|
-
}),
|
|
123
|
+
const error = new IoError(thrownError instanceof Error ? thrownError.message : String(thrownError), {
|
|
124
|
+
cause: thrownError instanceof Error ? thrownError : undefined,
|
|
125
|
+
props: { phase: 'render' },
|
|
127
126
|
})
|
|
127
|
+
report({ componentName, phase: 'render', error })
|
|
128
|
+
return { ok: false, error }
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
|
|
@@ -174,6 +175,7 @@ export function processComponent(
|
|
|
174
175
|
}
|
|
175
176
|
|
|
176
177
|
return {
|
|
178
|
+
ok: true,
|
|
177
179
|
component: {
|
|
178
180
|
...enhancedInfo,
|
|
179
181
|
css,
|