@fictjs/compiler 0.2.3 → 0.3.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 +5 -0
- package/dist/index.cjs +1016 -429
- package/dist/index.d.cts +37 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.js +1016 -429
- package/package.json +10 -10
package/dist/index.d.cts
CHANGED
|
@@ -52,6 +52,18 @@ interface FictCompilerOptions {
|
|
|
52
52
|
* If omitted, the compiler uses a process-wide cache.
|
|
53
53
|
*/
|
|
54
54
|
moduleMetadata?: Map<string, ModuleReactiveMetadata>;
|
|
55
|
+
/**
|
|
56
|
+
* Emit module metadata sidecar files to enable cross-process metadata resolution.
|
|
57
|
+
* - true: always emit
|
|
58
|
+
* - false: never emit
|
|
59
|
+
* - 'auto' or undefined: emit only when no external metadata store/resolver is provided
|
|
60
|
+
*/
|
|
61
|
+
emitModuleMetadata?: boolean | 'auto';
|
|
62
|
+
/**
|
|
63
|
+
* File extension suffix for module metadata sidecars.
|
|
64
|
+
* Defaults to '.fict.meta.json'.
|
|
65
|
+
*/
|
|
66
|
+
moduleMetadataExtension?: string;
|
|
55
67
|
/**
|
|
56
68
|
* Optional hook to resolve module metadata for a given import source.
|
|
57
69
|
* Tooling can override the default resolution strategy.
|
|
@@ -67,6 +79,31 @@ interface FictCompilerOptions {
|
|
|
67
79
|
projectVersion?: number;
|
|
68
80
|
configPath?: string;
|
|
69
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Function names that create reactive scopes. Callbacks passed to these functions
|
|
84
|
+
* are treated as component-like contexts where $state and $effect can be used.
|
|
85
|
+
*
|
|
86
|
+
* This is useful for testing libraries (e.g., renderHook) and other scenarios
|
|
87
|
+
* where reactive code runs in non-component contexts.
|
|
88
|
+
*
|
|
89
|
+
* Limitations (by design):
|
|
90
|
+
* - Only direct calls are recognized (e.g., renderHook(() => ...), utils.renderHook(() => ...)).
|
|
91
|
+
* - Only the first argument is treated as the reactive callback.
|
|
92
|
+
* - Aliased/indirect calls are not recognized (e.g., const rh = renderHook; rh(() => ...)).
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // In vite.config.ts or babel config:
|
|
97
|
+
* reactiveScopes: ['renderHook', 'createReactiveScope']
|
|
98
|
+
*
|
|
99
|
+
* // Then in tests:
|
|
100
|
+
* renderHook(() => {
|
|
101
|
+
* let count = $state(0) // Now allowed!
|
|
102
|
+
* return count
|
|
103
|
+
* })
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
reactiveScopes?: string[];
|
|
70
107
|
}
|
|
71
108
|
|
|
72
109
|
declare function resolveModuleMetadata(source: string, importer: string | undefined, options?: FictCompilerOptions): ModuleReactiveMetadata | undefined;
|
package/dist/index.d.ts
CHANGED
|
@@ -52,6 +52,18 @@ interface FictCompilerOptions {
|
|
|
52
52
|
* If omitted, the compiler uses a process-wide cache.
|
|
53
53
|
*/
|
|
54
54
|
moduleMetadata?: Map<string, ModuleReactiveMetadata>;
|
|
55
|
+
/**
|
|
56
|
+
* Emit module metadata sidecar files to enable cross-process metadata resolution.
|
|
57
|
+
* - true: always emit
|
|
58
|
+
* - false: never emit
|
|
59
|
+
* - 'auto' or undefined: emit only when no external metadata store/resolver is provided
|
|
60
|
+
*/
|
|
61
|
+
emitModuleMetadata?: boolean | 'auto';
|
|
62
|
+
/**
|
|
63
|
+
* File extension suffix for module metadata sidecars.
|
|
64
|
+
* Defaults to '.fict.meta.json'.
|
|
65
|
+
*/
|
|
66
|
+
moduleMetadataExtension?: string;
|
|
55
67
|
/**
|
|
56
68
|
* Optional hook to resolve module metadata for a given import source.
|
|
57
69
|
* Tooling can override the default resolution strategy.
|
|
@@ -67,6 +79,31 @@ interface FictCompilerOptions {
|
|
|
67
79
|
projectVersion?: number;
|
|
68
80
|
configPath?: string;
|
|
69
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Function names that create reactive scopes. Callbacks passed to these functions
|
|
84
|
+
* are treated as component-like contexts where $state and $effect can be used.
|
|
85
|
+
*
|
|
86
|
+
* This is useful for testing libraries (e.g., renderHook) and other scenarios
|
|
87
|
+
* where reactive code runs in non-component contexts.
|
|
88
|
+
*
|
|
89
|
+
* Limitations (by design):
|
|
90
|
+
* - Only direct calls are recognized (e.g., renderHook(() => ...), utils.renderHook(() => ...)).
|
|
91
|
+
* - Only the first argument is treated as the reactive callback.
|
|
92
|
+
* - Aliased/indirect calls are not recognized (e.g., const rh = renderHook; rh(() => ...)).
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // In vite.config.ts or babel config:
|
|
97
|
+
* reactiveScopes: ['renderHook', 'createReactiveScope']
|
|
98
|
+
*
|
|
99
|
+
* // Then in tests:
|
|
100
|
+
* renderHook(() => {
|
|
101
|
+
* let count = $state(0) // Now allowed!
|
|
102
|
+
* return count
|
|
103
|
+
* })
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
reactiveScopes?: string[];
|
|
70
107
|
}
|
|
71
108
|
|
|
72
109
|
declare function resolveModuleMetadata(source: string, importer: string | undefined, options?: FictCompilerOptions): ModuleReactiveMetadata | undefined;
|