@styleframe/loader 3.0.1 → 3.0.3
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/CHANGELOG.md +20 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +146 -0
- package/dist/index.d.mts +146 -0
- package/dist/index.js +127 -139
- package/package.json +19 -16
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @styleframe/loader
|
|
2
2
|
|
|
3
|
+
## 3.0.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#238](https://github.com/styleframe-dev/styleframe/pull/238) [`4ace91d`](https://github.com/styleframe-dev/styleframe/commit/4ace91d5e15020c29d585848ee66f6250946b2d1) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Bundle type declarations on build. The shared Vite config now enables `vite-plugin-dts`'s `bundleTypes`, so each package ships a single rolled-up `.d.ts` per entry (via `@microsoft/api-extractor`) instead of a tree of per-file declarations. `@microsoft/api-extractor` is now a peer dependency of `@styleframe/config-vite`.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`4ace91d`](https://github.com/styleframe-dev/styleframe/commit/4ace91d5e15020c29d585848ee66f6250946b2d1)]:
|
|
10
|
+
- @styleframe/core@3.6.1
|
|
11
|
+
- @styleframe/transpiler@3.4.1
|
|
12
|
+
|
|
13
|
+
## 3.0.2
|
|
14
|
+
|
|
15
|
+
### Patch Changes
|
|
16
|
+
|
|
17
|
+
- [#233](https://github.com/styleframe-dev/styleframe/pull/233) [`0ef38e6`](https://github.com/styleframe-dev/styleframe/commit/0ef38e69ca941cefab31463c23980f52cae1541f) Thanks [@alexgrozav](https://github.com/alexgrozav)! - Migrate from Vite 7 to Vite 8 with native Rolldown integration. Replace esbuild transforms with Oxc in the plugin, rename `rollupOptions` to `rolldownOptions`, upgrade `vite-plugin-dts` v4 to v5 (`rollupTypes` → `bundleTypes`), and bump vitest from v3 to v4.
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [[`c7ff8c8`](https://github.com/styleframe-dev/styleframe/commit/c7ff8c89776b2e117b0f45f3e1f8ca6695f24a29), [`6acd766`](https://github.com/styleframe-dev/styleframe/commit/6acd766eefc82139d8cd98dfb9b553449945d704), [`dc99d46`](https://github.com/styleframe-dev/styleframe/commit/dc99d4699046f5e5f3dcac965648fd50b0339412), [`6941920`](https://github.com/styleframe-dev/styleframe/commit/6941920a50e560e4686aebd154bb6aea4c59c258), [`0ef38e6`](https://github.com/styleframe-dev/styleframe/commit/0ef38e69ca941cefab31463c23980f52cae1541f)]:
|
|
20
|
+
- @styleframe/core@3.6.0
|
|
21
|
+
- @styleframe/transpiler@3.4.0
|
|
22
|
+
|
|
3
23
|
## 3.0.1
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("node:fs/promises"),l=require("node:path");l=s(l,1);let u=require("@styleframe/transpiler"),d=require("@styleframe/license"),f=require("@styleframe/core"),p=require("chokidar"),m=require("node:fs"),h=require("jiti");async function g(e){try{return(await(0,c.stat)(e)).isDirectory()}catch{return!1}}async function _(e,{clean:t=!0,outputDir:n=`./styleframe`,transpiler:r}={}){await(0,d.validateInstanceLicense)(e,{licenseKey:(0,d.getLicenseKeyFromEnv)()||``,environment:process.env.NODE_ENV||`development`,isBuild:!0});let i=await(0,u.transpile)(e,r),a=await g(n);t&&a&&await(0,c.rm)(n,{recursive:!0});for(let e of i.files){let t=l.default.join(n,e.name),r=l.default.dirname(t);await g(r)||await(0,c.mkdir)(r,{recursive:!0}),await(0,c.writeFile)(t,e.content)}}function v(e,t){return(0,h.createJiti)(e,{fsCache:!1,moduleCache:!1,alias:t})}function y(e){let t=new Map;for(let[n,r]of Object.entries(e)){if(n===`default`)continue;let e=null;(0,f.isRecipe)(r)?(e=`recipe`,r._exportName=n):(0,f.isSelector)(r)&&(e=`selector`,r._exportName=n),e&&t.set(n,{name:n,type:e})}return t}async function b(e,t={}){let{alias:n,validateInstance:r=!0,jiti:i}=t,a=await(i??v(l.default.dirname(e),n)).import(e);if(!a.default)throw Error(`Missing default export in ${e}. Expected a Styleframe instance.`);if(r&&!(0,f.isStyleframe)(a.default))throw Error(`Invalid default export in ${e}. Expected a Styleframe instance created with styleframe().`);let o=y(a);return{module:a,instance:a.default,exports:o}}async function x(e,t={}){let{alias:n,jiti:r}=t,i=await(r??v(l.default.dirname(e),n)).import(e);return{module:i,exports:y(i)}}var S=[`.ts`,`.mts`,`.cts`,`.js`,`.mjs`,`.cjs`];function C(e){return S.some(t=>e.endsWith(t))}function w(e,t){let n=l.default.isAbsolute(t)?t:l.default.join(e,t);if(C(n))return(0,m.existsSync)(n)?n:void 0;for(let e of S){let t=`${n}${e}`;if((0,m.existsSync)(t))return t}}async function T({cwd:e=process.cwd(),entry:t=`styleframe.config`}={}){let n=w(e,t);if(!n)return(0,f.styleframe)();let{instance:r}=await b(n);return r}async function E({cwd:e=process.cwd(),entry:t=`styleframe.config`,onUpdate:n,onError:r}={}){let i=w(e,t);if(!i)throw Error(`Config file not found: ${t}`);let a=(0,p.watch)(i,{ignoreInitial:!0});return a.on(`change`,async()=>{try{let e=await T({entry:i});n?.(e)}catch(e){r?.(e instanceof Error?e:Error(String(e)))}}),a.on(`unlink`,()=>{r?.(Error(`Config file was deleted: ${i}`))}),{config:await T({entry:i}),configFile:i,unwatch:()=>a.close()}}function D(e={}){return(0,h.createJiti)(process.cwd(),{interopDefault:!0,moduleCache:!0,...e})}function O(e,...t){let n=e.cache;if(n)for(let e of t){let t=l.default.resolve(e);typeof n==`object`&&n&&(n instanceof Map?(n.delete(t),n.delete(`file://${t}`)):typeof n==`object`&&(delete n[t],delete n[`file://${t}`]))}}function k(e){let t=e.cache;if(t){if(t instanceof Map)t.clear();else if(typeof t==`object`)for(let e of Object.keys(t))delete t[e]}}exports.build=_,exports.clearAllJitiCache=k,exports.clearJitiCache=O,exports.createLoader=v,exports.createSharedJiti=D,exports.directoryExists=g,exports.loadConfiguration=T,exports.loadExtensionModule=x,exports.loadModule=b,exports.trackExports=y,exports.watchConfiguration=E;
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Jiti } from 'jiti';
|
|
2
|
+
import { JitiOptions } from 'jiti';
|
|
3
|
+
import { Styleframe } from '@styleframe/core';
|
|
4
|
+
import { TranspileOptions } from '@styleframe/transpiler';
|
|
5
|
+
|
|
6
|
+
export declare function build(instance: Styleframe, { clean, outputDir, transpiler }?: BuildOptions): Promise<void>;
|
|
7
|
+
|
|
8
|
+
export declare type BuildOptions = {
|
|
9
|
+
clean?: boolean;
|
|
10
|
+
outputDir?: string;
|
|
11
|
+
transpiler?: TranspileOptions;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Clears the entire jiti module cache.
|
|
16
|
+
* Useful for full rebuilds or when dependency graph is unclear.
|
|
17
|
+
*/
|
|
18
|
+
export declare function clearAllJitiCache(jiti: Jiti): void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Clears specific modules from the jiti cache.
|
|
22
|
+
* Call this when a file changes to ensure it's reloaded on next import.
|
|
23
|
+
*
|
|
24
|
+
* @param jiti - The jiti instance to clear cache from
|
|
25
|
+
* @param filePaths - Absolute paths of files to invalidate
|
|
26
|
+
*/
|
|
27
|
+
export declare function clearJitiCache(jiti: Jiti, ...filePaths: string[]): void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create a jiti instance with standard configuration.
|
|
31
|
+
*
|
|
32
|
+
* @param basePath - Directory to resolve imports from
|
|
33
|
+
* @param alias - Optional alias configuration for virtual modules
|
|
34
|
+
*/
|
|
35
|
+
export declare function createLoader(basePath: string, alias?: Record<string, string>): Jiti;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a shared jiti instance with module caching enabled.
|
|
39
|
+
* Use this when loading multiple styleframe config files to avoid
|
|
40
|
+
* re-compiling shared dependencies.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const jiti = createSharedJiti();
|
|
45
|
+
*
|
|
46
|
+
* // Both loads will share cached modules
|
|
47
|
+
* const config1 = await loadConfigurationFromPath('./button.styleframe.ts', { jiti });
|
|
48
|
+
* const config2 = await loadConfigurationFromPath('./badge.styleframe.ts', { jiti });
|
|
49
|
+
*
|
|
50
|
+
* // Invalidate cache when files change (for HMR)
|
|
51
|
+
* clearJitiCache(jiti, './theme/useTokens.ts');
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function createSharedJiti(options?: JitiOptions): Jiti;
|
|
55
|
+
|
|
56
|
+
export declare function directoryExists(path: string): Promise<boolean>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Export information for a recipe or selector
|
|
60
|
+
*/
|
|
61
|
+
export declare interface ExportInfo {
|
|
62
|
+
/** Export name (e.g., "buttonRecipe") */
|
|
63
|
+
name: string;
|
|
64
|
+
/** Type of export */
|
|
65
|
+
type: "recipe" | "selector";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { Jiti }
|
|
69
|
+
|
|
70
|
+
export { JitiOptions }
|
|
71
|
+
|
|
72
|
+
export declare function loadConfiguration({ cwd, entry, }?: {
|
|
73
|
+
cwd?: string;
|
|
74
|
+
entry?: string;
|
|
75
|
+
}): Promise<Styleframe>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Load a module without validating the default export.
|
|
79
|
+
* Useful for extension files that may not have a default export.
|
|
80
|
+
*
|
|
81
|
+
* @param filePath - Absolute path to the module file
|
|
82
|
+
* @param options - Loading options (without validateInstance)
|
|
83
|
+
*/
|
|
84
|
+
export declare function loadExtensionModule(filePath: string, options?: Omit<LoadModuleOptions, "validateInstance">): Promise<LoadExtensionModuleResult>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Result of loading an extension module (no instance validation)
|
|
88
|
+
*/
|
|
89
|
+
export declare interface LoadExtensionModuleResult {
|
|
90
|
+
/** The raw module exports */
|
|
91
|
+
module: Record<string, unknown>;
|
|
92
|
+
/** Tracked exports (recipes and selectors with _exportName set) */
|
|
93
|
+
exports: Map<string, ExportInfo>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Load a TypeScript/JavaScript module using jiti.
|
|
98
|
+
* Tracks _exportName on recipes/selectors and validates the default export.
|
|
99
|
+
*
|
|
100
|
+
* @param filePath - Absolute path to the module file
|
|
101
|
+
* @param options - Loading options
|
|
102
|
+
*/
|
|
103
|
+
export declare function loadModule(filePath: string, options?: LoadModuleOptions): Promise<LoadModuleResult>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Options for loading a module with jiti
|
|
107
|
+
*/
|
|
108
|
+
export declare interface LoadModuleOptions {
|
|
109
|
+
/** jiti alias configuration (e.g., for virtual modules) */
|
|
110
|
+
alias?: Record<string, string>;
|
|
111
|
+
/** Whether to validate that default export is a Styleframe instance (default: true) */
|
|
112
|
+
validateInstance?: boolean;
|
|
113
|
+
/** Optional shared jiti instance to reuse across multiple loads */
|
|
114
|
+
jiti?: Jiti;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Result of loading a module
|
|
119
|
+
*/
|
|
120
|
+
export declare interface LoadModuleResult {
|
|
121
|
+
/** The raw module exports */
|
|
122
|
+
module: Record<string, unknown>;
|
|
123
|
+
/** The default export (Styleframe instance) */
|
|
124
|
+
instance: Styleframe;
|
|
125
|
+
/** Tracked exports (recipes and selectors with _exportName set) */
|
|
126
|
+
exports: Map<string, ExportInfo>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Track _exportName on recipes and selectors in a module.
|
|
131
|
+
* Returns a map of export info for recipes and selectors.
|
|
132
|
+
*/
|
|
133
|
+
export declare function trackExports(module: Record<string, unknown>): Map<string, ExportInfo>;
|
|
134
|
+
|
|
135
|
+
export declare function watchConfiguration({ cwd, entry, onUpdate, onError, }?: {
|
|
136
|
+
cwd?: string;
|
|
137
|
+
entry?: string;
|
|
138
|
+
onUpdate?: (config: Styleframe) => void;
|
|
139
|
+
onError?: (error: Error) => void;
|
|
140
|
+
}): Promise<{
|
|
141
|
+
config: Styleframe;
|
|
142
|
+
configFile: string;
|
|
143
|
+
unwatch: () => Promise<void>;
|
|
144
|
+
}>;
|
|
145
|
+
|
|
146
|
+
export { }
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { Jiti } from 'jiti';
|
|
2
|
+
import { JitiOptions } from 'jiti';
|
|
3
|
+
import { Styleframe } from '@styleframe/core';
|
|
4
|
+
import { TranspileOptions } from '@styleframe/transpiler';
|
|
5
|
+
|
|
6
|
+
export declare function build(instance: Styleframe, { clean, outputDir, transpiler }?: BuildOptions): Promise<void>;
|
|
7
|
+
|
|
8
|
+
export declare type BuildOptions = {
|
|
9
|
+
clean?: boolean;
|
|
10
|
+
outputDir?: string;
|
|
11
|
+
transpiler?: TranspileOptions;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Clears the entire jiti module cache.
|
|
16
|
+
* Useful for full rebuilds or when dependency graph is unclear.
|
|
17
|
+
*/
|
|
18
|
+
export declare function clearAllJitiCache(jiti: Jiti): void;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Clears specific modules from the jiti cache.
|
|
22
|
+
* Call this when a file changes to ensure it's reloaded on next import.
|
|
23
|
+
*
|
|
24
|
+
* @param jiti - The jiti instance to clear cache from
|
|
25
|
+
* @param filePaths - Absolute paths of files to invalidate
|
|
26
|
+
*/
|
|
27
|
+
export declare function clearJitiCache(jiti: Jiti, ...filePaths: string[]): void;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Create a jiti instance with standard configuration.
|
|
31
|
+
*
|
|
32
|
+
* @param basePath - Directory to resolve imports from
|
|
33
|
+
* @param alias - Optional alias configuration for virtual modules
|
|
34
|
+
*/
|
|
35
|
+
export declare function createLoader(basePath: string, alias?: Record<string, string>): Jiti;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates a shared jiti instance with module caching enabled.
|
|
39
|
+
* Use this when loading multiple styleframe config files to avoid
|
|
40
|
+
* re-compiling shared dependencies.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* const jiti = createSharedJiti();
|
|
45
|
+
*
|
|
46
|
+
* // Both loads will share cached modules
|
|
47
|
+
* const config1 = await loadConfigurationFromPath('./button.styleframe.ts', { jiti });
|
|
48
|
+
* const config2 = await loadConfigurationFromPath('./badge.styleframe.ts', { jiti });
|
|
49
|
+
*
|
|
50
|
+
* // Invalidate cache when files change (for HMR)
|
|
51
|
+
* clearJitiCache(jiti, './theme/useTokens.ts');
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function createSharedJiti(options?: JitiOptions): Jiti;
|
|
55
|
+
|
|
56
|
+
export declare function directoryExists(path: string): Promise<boolean>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Export information for a recipe or selector
|
|
60
|
+
*/
|
|
61
|
+
export declare interface ExportInfo {
|
|
62
|
+
/** Export name (e.g., "buttonRecipe") */
|
|
63
|
+
name: string;
|
|
64
|
+
/** Type of export */
|
|
65
|
+
type: "recipe" | "selector";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { Jiti }
|
|
69
|
+
|
|
70
|
+
export { JitiOptions }
|
|
71
|
+
|
|
72
|
+
export declare function loadConfiguration({ cwd, entry, }?: {
|
|
73
|
+
cwd?: string;
|
|
74
|
+
entry?: string;
|
|
75
|
+
}): Promise<Styleframe>;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Load a module without validating the default export.
|
|
79
|
+
* Useful for extension files that may not have a default export.
|
|
80
|
+
*
|
|
81
|
+
* @param filePath - Absolute path to the module file
|
|
82
|
+
* @param options - Loading options (without validateInstance)
|
|
83
|
+
*/
|
|
84
|
+
export declare function loadExtensionModule(filePath: string, options?: Omit<LoadModuleOptions, "validateInstance">): Promise<LoadExtensionModuleResult>;
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Result of loading an extension module (no instance validation)
|
|
88
|
+
*/
|
|
89
|
+
export declare interface LoadExtensionModuleResult {
|
|
90
|
+
/** The raw module exports */
|
|
91
|
+
module: Record<string, unknown>;
|
|
92
|
+
/** Tracked exports (recipes and selectors with _exportName set) */
|
|
93
|
+
exports: Map<string, ExportInfo>;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Load a TypeScript/JavaScript module using jiti.
|
|
98
|
+
* Tracks _exportName on recipes/selectors and validates the default export.
|
|
99
|
+
*
|
|
100
|
+
* @param filePath - Absolute path to the module file
|
|
101
|
+
* @param options - Loading options
|
|
102
|
+
*/
|
|
103
|
+
export declare function loadModule(filePath: string, options?: LoadModuleOptions): Promise<LoadModuleResult>;
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Options for loading a module with jiti
|
|
107
|
+
*/
|
|
108
|
+
export declare interface LoadModuleOptions {
|
|
109
|
+
/** jiti alias configuration (e.g., for virtual modules) */
|
|
110
|
+
alias?: Record<string, string>;
|
|
111
|
+
/** Whether to validate that default export is a Styleframe instance (default: true) */
|
|
112
|
+
validateInstance?: boolean;
|
|
113
|
+
/** Optional shared jiti instance to reuse across multiple loads */
|
|
114
|
+
jiti?: Jiti;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Result of loading a module
|
|
119
|
+
*/
|
|
120
|
+
export declare interface LoadModuleResult {
|
|
121
|
+
/** The raw module exports */
|
|
122
|
+
module: Record<string, unknown>;
|
|
123
|
+
/** The default export (Styleframe instance) */
|
|
124
|
+
instance: Styleframe;
|
|
125
|
+
/** Tracked exports (recipes and selectors with _exportName set) */
|
|
126
|
+
exports: Map<string, ExportInfo>;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Track _exportName on recipes and selectors in a module.
|
|
131
|
+
* Returns a map of export info for recipes and selectors.
|
|
132
|
+
*/
|
|
133
|
+
export declare function trackExports(module: Record<string, unknown>): Map<string, ExportInfo>;
|
|
134
|
+
|
|
135
|
+
export declare function watchConfiguration({ cwd, entry, onUpdate, onError, }?: {
|
|
136
|
+
cwd?: string;
|
|
137
|
+
entry?: string;
|
|
138
|
+
onUpdate?: (config: Styleframe) => void;
|
|
139
|
+
onError?: (error: Error) => void;
|
|
140
|
+
}): Promise<{
|
|
141
|
+
config: Styleframe;
|
|
142
|
+
configFile: string;
|
|
143
|
+
unwatch: () => Promise<void>;
|
|
144
|
+
}>;
|
|
145
|
+
|
|
146
|
+
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,153 +1,141 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { transpile as
|
|
4
|
-
import {
|
|
5
|
-
import { isRecipe as
|
|
6
|
-
import { watch as
|
|
7
|
-
import { existsSync as
|
|
1
|
+
import { mkdir as e, rm as t, stat as n, writeFile as r } from "node:fs/promises";
|
|
2
|
+
import i from "node:path";
|
|
3
|
+
import { transpile as a } from "@styleframe/transpiler";
|
|
4
|
+
import { getLicenseKeyFromEnv as o, validateInstanceLicense as s } from "@styleframe/license";
|
|
5
|
+
import { isRecipe as c, isSelector as l, isStyleframe as u, styleframe as d } from "@styleframe/core";
|
|
6
|
+
import { watch as f } from "chokidar";
|
|
7
|
+
import { existsSync as p } from "node:fs";
|
|
8
8
|
import { createJiti as m } from "jiti";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
//#region src/utils.ts
|
|
10
|
+
async function h(e) {
|
|
11
|
+
try {
|
|
12
|
+
return (await n(e)).isDirectory();
|
|
13
|
+
} catch {
|
|
14
|
+
return !1;
|
|
15
|
+
}
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/build.ts
|
|
19
|
+
async function g(n, { clean: c = !0, outputDir: l = "./styleframe", transpiler: u } = {}) {
|
|
20
|
+
await s(n, {
|
|
21
|
+
licenseKey: o() || "",
|
|
22
|
+
environment: process.env.NODE_ENV || "development",
|
|
23
|
+
isBuild: !0
|
|
24
|
+
});
|
|
25
|
+
let d = await a(n, u), f = await h(l);
|
|
26
|
+
c && f && await t(l, { recursive: !0 });
|
|
27
|
+
for (let t of d.files) {
|
|
28
|
+
let n = i.join(l, t.name), a = i.dirname(n);
|
|
29
|
+
await h(a) || await e(a, { recursive: !0 }), await r(n, t.content);
|
|
30
|
+
}
|
|
28
31
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
//#endregion
|
|
33
|
+
//#region src/module.ts
|
|
34
|
+
function _(e, t) {
|
|
35
|
+
return m(e, {
|
|
36
|
+
fsCache: !1,
|
|
37
|
+
moduleCache: !1,
|
|
38
|
+
alias: t
|
|
39
|
+
});
|
|
35
40
|
}
|
|
36
|
-
function
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
function v(e) {
|
|
42
|
+
let t = /* @__PURE__ */ new Map();
|
|
43
|
+
for (let [n, r] of Object.entries(e)) {
|
|
44
|
+
if (n === "default") continue;
|
|
45
|
+
let e = null;
|
|
46
|
+
c(r) ? (e = "recipe", r._exportName = n) : l(r) && (e = "selector", r._exportName = n), e && t.set(n, {
|
|
47
|
+
name: n,
|
|
48
|
+
type: e
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return t;
|
|
44
52
|
}
|
|
45
|
-
async function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const c = w(r);
|
|
56
|
-
return {
|
|
57
|
-
module: r,
|
|
58
|
-
instance: r.default,
|
|
59
|
-
exports: c
|
|
60
|
-
};
|
|
53
|
+
async function y(e, t = {}) {
|
|
54
|
+
let { alias: n, validateInstance: r = !0, jiti: a } = t, o = await (a ?? _(i.dirname(e), n)).import(e);
|
|
55
|
+
if (!o.default) throw Error(`Missing default export in ${e}. Expected a Styleframe instance.`);
|
|
56
|
+
if (r && !u(o.default)) throw Error(`Invalid default export in ${e}. Expected a Styleframe instance created with styleframe().`);
|
|
57
|
+
let s = v(o);
|
|
58
|
+
return {
|
|
59
|
+
module: o,
|
|
60
|
+
instance: o.default,
|
|
61
|
+
exports: s
|
|
62
|
+
};
|
|
61
63
|
}
|
|
62
|
-
async function
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
async function b(e, t = {}) {
|
|
65
|
+
let { alias: n, jiti: r } = t, a = await (r ?? _(i.dirname(e), n)).import(e);
|
|
66
|
+
return {
|
|
67
|
+
module: a,
|
|
68
|
+
exports: v(a)
|
|
69
|
+
};
|
|
65
70
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region src/config.ts
|
|
73
|
+
var x = [
|
|
74
|
+
".ts",
|
|
75
|
+
".mts",
|
|
76
|
+
".cts",
|
|
77
|
+
".js",
|
|
78
|
+
".mjs",
|
|
79
|
+
".cjs"
|
|
80
|
+
];
|
|
81
|
+
function S(e) {
|
|
82
|
+
return x.some((t) => e.endsWith(t));
|
|
69
83
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return n;
|
|
78
|
-
}
|
|
84
|
+
function C(e, t) {
|
|
85
|
+
let n = i.isAbsolute(t) ? t : i.join(e, t);
|
|
86
|
+
if (S(n)) return p(n) ? n : void 0;
|
|
87
|
+
for (let e of x) {
|
|
88
|
+
let t = `${n}${e}`;
|
|
89
|
+
if (p(t)) return t;
|
|
90
|
+
}
|
|
79
91
|
}
|
|
80
|
-
async function
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
} =
|
|
84
|
-
|
|
85
|
-
if (!e)
|
|
86
|
-
return D();
|
|
87
|
-
const { instance: o } = await M(e);
|
|
88
|
-
return o;
|
|
92
|
+
async function w({ cwd: e = process.cwd(), entry: t = "styleframe.config" } = {}) {
|
|
93
|
+
let n = C(e, t);
|
|
94
|
+
if (!n) return d();
|
|
95
|
+
let { instance: r } = await y(n);
|
|
96
|
+
return r;
|
|
89
97
|
}
|
|
90
|
-
async function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
o?.(new Error(`Config file was deleted: ${n}`));
|
|
109
|
-
}), {
|
|
110
|
-
config: await d({ entry: n }),
|
|
111
|
-
configFile: n,
|
|
112
|
-
unwatch: () => a.close()
|
|
113
|
-
};
|
|
98
|
+
async function T({ cwd: e = process.cwd(), entry: t = "styleframe.config", onUpdate: n, onError: r } = {}) {
|
|
99
|
+
let i = C(e, t);
|
|
100
|
+
if (!i) throw Error(`Config file not found: ${t}`);
|
|
101
|
+
let a = f(i, { ignoreInitial: !0 });
|
|
102
|
+
return a.on("change", async () => {
|
|
103
|
+
try {
|
|
104
|
+
let e = await w({ entry: i });
|
|
105
|
+
n?.(e);
|
|
106
|
+
} catch (e) {
|
|
107
|
+
r?.(e instanceof Error ? e : Error(String(e)));
|
|
108
|
+
}
|
|
109
|
+
}), a.on("unlink", () => {
|
|
110
|
+
r?.(/* @__PURE__ */ Error(`Config file was deleted: ${i}`));
|
|
111
|
+
}), {
|
|
112
|
+
config: await w({ entry: i }),
|
|
113
|
+
configFile: i,
|
|
114
|
+
unwatch: () => a.close()
|
|
115
|
+
};
|
|
114
116
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/jiti.ts
|
|
119
|
+
function E(e = {}) {
|
|
120
|
+
return m(process.cwd(), {
|
|
121
|
+
interopDefault: !0,
|
|
122
|
+
moduleCache: !0,
|
|
123
|
+
...e
|
|
124
|
+
});
|
|
122
125
|
}
|
|
123
|
-
function
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
126
|
+
function D(e, ...t) {
|
|
127
|
+
let n = e.cache;
|
|
128
|
+
if (n) for (let e of t) {
|
|
129
|
+
let t = i.resolve(e);
|
|
130
|
+
typeof n == "object" && n && (n instanceof Map ? (n.delete(t), n.delete(`file://${t}`)) : typeof n == "object" && (delete n[t], delete n[`file://${t}`]));
|
|
131
|
+
}
|
|
130
132
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
for (const e of Object.keys(t))
|
|
138
|
-
delete t[e];
|
|
139
|
-
}
|
|
133
|
+
function O(e) {
|
|
134
|
+
let t = e.cache;
|
|
135
|
+
if (t) {
|
|
136
|
+
if (t instanceof Map) t.clear();
|
|
137
|
+
else if (typeof t == "object") for (let e of Object.keys(t)) delete t[e];
|
|
138
|
+
}
|
|
140
139
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
W as clearAllJitiCache,
|
|
144
|
-
V as clearJitiCache,
|
|
145
|
-
p as createLoader,
|
|
146
|
-
U as createSharedJiti,
|
|
147
|
-
u as directoryExists,
|
|
148
|
-
d as loadConfiguration,
|
|
149
|
-
z as loadExtensionModule,
|
|
150
|
-
M as loadModule,
|
|
151
|
-
w as trackExports,
|
|
152
|
-
B as watchConfiguration
|
|
153
|
-
};
|
|
140
|
+
//#endregion
|
|
141
|
+
export { g as build, O as clearAllJitiCache, D as clearJitiCache, _ as createLoader, E as createSharedJiti, h as directoryExists, w as loadConfiguration, b as loadExtensionModule, y as loadModule, v as trackExports, T as watchConfiguration };
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleframe/loader",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./dist/index.d.mts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./dist/index.d.cts",
|
|
16
|
+
"default": "./dist/index.cjs"
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
},
|
|
15
20
|
"files": [
|
|
@@ -23,22 +28,23 @@
|
|
|
23
28
|
"jiti": "^2.4.2"
|
|
24
29
|
},
|
|
25
30
|
"peerDependencies": {
|
|
26
|
-
"@styleframe/core": "^3.
|
|
31
|
+
"@styleframe/core": "^3.6.1",
|
|
27
32
|
"@styleframe/license": "^2.0.2",
|
|
28
|
-
"@styleframe/transpiler": "^3.
|
|
33
|
+
"@styleframe/transpiler": "^3.4.1"
|
|
29
34
|
},
|
|
30
35
|
"devDependencies": {
|
|
36
|
+
"@microsoft/api-extractor": "^7.58.7",
|
|
31
37
|
"@styleframe/config-typescript": "^3.0.0",
|
|
32
|
-
"@styleframe/config-vite": "^3.
|
|
33
|
-
"@styleframe/core": "^3.
|
|
38
|
+
"@styleframe/config-vite": "^3.1.0",
|
|
39
|
+
"@styleframe/core": "^3.6.1",
|
|
34
40
|
"@styleframe/license": "^2.0.2",
|
|
35
|
-
"@styleframe/transpiler": "^3.
|
|
36
|
-
"@vitest/coverage-v8": "^
|
|
41
|
+
"@styleframe/transpiler": "^3.4.1",
|
|
42
|
+
"@vitest/coverage-v8": "^4.1.7",
|
|
37
43
|
"tsx": "^4.20.6",
|
|
38
44
|
"typescript": "^5.8.3",
|
|
39
|
-
"vite": "^
|
|
40
|
-
"vite-plugin-dts": "^
|
|
41
|
-
"vitest": "^
|
|
45
|
+
"vite": "^8.0.14",
|
|
46
|
+
"vite-plugin-dts": "^5.0.1",
|
|
47
|
+
"vitest": "^4.1.7"
|
|
42
48
|
},
|
|
43
49
|
"homepage": "https://github.com/styleframe-dev/styleframe#readme",
|
|
44
50
|
"bugs": {
|
|
@@ -49,9 +55,6 @@
|
|
|
49
55
|
"url": "git+https://github.com/styleframe-dev/styleframe.git"
|
|
50
56
|
},
|
|
51
57
|
"author": "Alex Grozav <alex@styleframe.dev>",
|
|
52
|
-
"overrides": {
|
|
53
|
-
"vite": "npm:rolldown-vite@latest"
|
|
54
|
-
},
|
|
55
58
|
"scripts": {
|
|
56
59
|
"dev": "vite build --watch",
|
|
57
60
|
"build": "pnpm typecheck && vite build",
|