@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 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
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("node:fs/promises"),c=require("node:path"),v=require("@styleframe/transpiler"),m=require("@styleframe/license"),f=require("@styleframe/core"),C=require("chokidar"),y=require("node:fs"),E=require("jiti");async function u(i){try{return(await l.stat(i)).isDirectory()}catch{return!1}}async function S(i,{clean:t=!0,outputDir:e="./styleframe",transpiler:r}={}){await m.validateInstanceLicense(i,{licenseKey:m.getLicenseKeyFromEnv()||"",environment:process.env.NODE_ENV||"development",isBuild:!0});const n=await v.transpile(i,r),a=await u(e);t&&a&&await l.rm(e,{recursive:!0});for(const o of n.files){const s=c.join(e,o.name),w=c.dirname(s);await u(w)||await l.mkdir(w,{recursive:!0}),await l.writeFile(s,o.content)}}function p(i,t){return E.createJiti(i,{fsCache:!1,moduleCache:!1,alias:t})}function h(i){const t=new Map;for(const[e,r]of Object.entries(i)){if(e==="default")continue;let n=null;f.isRecipe(r)?(n="recipe",r._exportName=e):f.isSelector(r)&&(n="selector",r._exportName=e),n&&t.set(e,{name:e,type:n})}return t}async function x(i,t={}){const{alias:e,validateInstance:r=!0,jiti:n}=t,o=await(n??p(c.dirname(i),e)).import(i);if(!o.default)throw new Error(`Missing default export in ${i}. Expected a Styleframe instance.`);if(r&&!f.isStyleframe(o.default))throw new Error(`Invalid default export in ${i}. Expected a Styleframe instance created with styleframe().`);const s=h(o);return{module:o,instance:o.default,exports:s}}async function b(i,t={}){const{alias:e,jiti:r}=t,a=await(r??p(c.dirname(i),e)).import(i),o=h(a);return{module:a,exports:o}}const g=[".ts",".mts",".cts",".js",".mjs",".cjs"];function J(i){return g.some(t=>i.endsWith(t))}function j(i,t){const e=c.isAbsolute(t)?t:c.join(i,t);if(J(e))return y.existsSync(e)?e:void 0;for(const r of g){const n=`${e}${r}`;if(y.existsSync(n))return n}}async function d({cwd:i=process.cwd(),entry:t="styleframe.config"}={}){const e=j(i,t);if(!e)return f.styleframe();const{instance:r}=await x(e);return r}async function M({cwd:i=process.cwd(),entry:t="styleframe.config",onUpdate:e,onError:r}={}){const n=j(i,t);if(!n)throw new Error(`Config file not found: ${t}`);const a=C.watch(n,{ignoreInitial:!0});return a.on("change",async()=>{try{const o=await d({entry:n});e?.(o)}catch(o){r?.(o instanceof Error?o:new Error(String(o)))}}),a.on("unlink",()=>{r?.(new Error(`Config file was deleted: ${n}`))}),{config:await d({entry:n}),configFile:n,unwatch:()=>a.close()}}function O(i={}){return E.createJiti(process.cwd(),{interopDefault:!0,moduleCache:!0,...i})}function q(i,...t){const e=i.cache;if(e)for(const r of t){const n=c.resolve(r);typeof e=="object"&&e!==null&&(e instanceof Map?(e.delete(n),e.delete(`file://${n}`)):typeof e=="object"&&(delete e[n],delete e[`file://${n}`]))}}function $(i){const t=i.cache;if(t){if(t instanceof Map)t.clear();else if(typeof t=="object")for(const e of Object.keys(t))delete t[e]}}exports.build=S;exports.clearAllJitiCache=$;exports.clearJitiCache=q;exports.createLoader=p;exports.createSharedJiti=O;exports.directoryExists=u;exports.loadConfiguration=d;exports.loadExtensionModule=b;exports.loadModule=x;exports.trackExports=h;exports.watchConfiguration=M;
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;
@@ -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 { }
@@ -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 { stat as E, rm as x, mkdir as j, writeFile as v } from "node:fs/promises";
2
- import s from "node:path";
3
- import { transpile as g } from "@styleframe/transpiler";
4
- import { validateInstanceLicense as C, getLicenseKeyFromEnv as S } from "@styleframe/license";
5
- import { isRecipe as b, isSelector as O, isStyleframe as $, styleframe as D } from "@styleframe/core";
6
- import { watch as J } from "chokidar";
7
- import { existsSync as l } from "node:fs";
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
- async function u(i) {
10
- try {
11
- return (await E(i)).isDirectory();
12
- } catch {
13
- return !1;
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
- async function T(i, { clean: t = !0, outputDir: e = "./styleframe", transpiler: o } = {}) {
17
- await C(i, {
18
- licenseKey: S() || "",
19
- environment: process.env.NODE_ENV || "development",
20
- isBuild: !0
21
- });
22
- const n = await g(i, o), a = await u(e);
23
- t && a && await x(e, { recursive: !0 });
24
- for (const r of n.files) {
25
- const c = s.join(e, r.name), f = s.dirname(c);
26
- await u(f) || await j(f, { recursive: !0 }), await v(c, r.content);
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
- function p(i, t) {
30
- return m(i, {
31
- fsCache: !1,
32
- moduleCache: !1,
33
- alias: t
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 w(i) {
37
- const t = /* @__PURE__ */ new Map();
38
- for (const [e, o] of Object.entries(i)) {
39
- if (e === "default") continue;
40
- let n = null;
41
- b(o) ? (n = "recipe", o._exportName = e) : O(o) && (n = "selector", o._exportName = e), n && t.set(e, { name: e, type: n });
42
- }
43
- return t;
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 M(i, t = {}) {
46
- const { alias: e, validateInstance: o = !0, jiti: n } = t, r = await (n ?? p(s.dirname(i), e)).import(i);
47
- if (!r.default)
48
- throw new Error(
49
- `Missing default export in ${i}. Expected a Styleframe instance.`
50
- );
51
- if (o && !$(r.default))
52
- throw new Error(
53
- `Invalid default export in ${i}. Expected a Styleframe instance created with styleframe().`
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 z(i, t = {}) {
63
- const { alias: e, jiti: o } = t, a = await (o ?? p(s.dirname(i), e)).import(i), r = w(a);
64
- return { module: a, exports: r };
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
- const h = [".ts", ".mts", ".cts", ".js", ".mjs", ".cjs"];
67
- function N(i) {
68
- return h.some((t) => i.endsWith(t));
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 y(i, t) {
71
- const e = s.isAbsolute(t) ? t : s.join(i, t);
72
- if (N(e))
73
- return l(e) ? e : void 0;
74
- for (const o of h) {
75
- const n = `${e}${o}`;
76
- if (l(n))
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 d({
81
- cwd: i = process.cwd(),
82
- entry: t = "styleframe.config"
83
- } = {}) {
84
- const e = y(i, t);
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 B({
91
- cwd: i = process.cwd(),
92
- entry: t = "styleframe.config",
93
- onUpdate: e,
94
- onError: o
95
- } = {}) {
96
- const n = y(i, t);
97
- if (!n)
98
- throw new Error(`Config file not found: ${t}`);
99
- const a = J(n, { ignoreInitial: !0 });
100
- return a.on("change", async () => {
101
- try {
102
- const r = await d({ entry: n });
103
- e?.(r);
104
- } catch (r) {
105
- o?.(r instanceof Error ? r : new Error(String(r)));
106
- }
107
- }), a.on("unlink", () => {
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
- function U(i = {}) {
116
- return m(process.cwd(), {
117
- interopDefault: !0,
118
- moduleCache: !0,
119
- // Enable module caching for shared dependencies
120
- ...i
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 V(i, ...t) {
124
- const e = i.cache;
125
- if (e)
126
- for (const o of t) {
127
- const n = s.resolve(o);
128
- typeof e == "object" && e !== null && (e instanceof Map ? (e.delete(n), e.delete(`file://${n}`)) : typeof e == "object" && (delete e[n], delete e[`file://${n}`]));
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 W(i) {
132
- const t = i.cache;
133
- if (t) {
134
- if (t instanceof Map)
135
- t.clear();
136
- else if (typeof t == "object")
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
- export {
142
- T as build,
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.1",
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
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js",
12
- "require": "./dist/index.cjs"
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.3.0",
31
+ "@styleframe/core": "^3.6.1",
27
32
  "@styleframe/license": "^2.0.2",
28
- "@styleframe/transpiler": "^3.2.0"
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.0.0",
33
- "@styleframe/core": "^3.3.0",
38
+ "@styleframe/config-vite": "^3.1.0",
39
+ "@styleframe/core": "^3.6.1",
34
40
  "@styleframe/license": "^2.0.2",
35
- "@styleframe/transpiler": "^3.2.0",
36
- "@vitest/coverage-v8": "^3.2.4",
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": "^7.0.6",
40
- "vite-plugin-dts": "^4.5.4",
41
- "vitest": "^3.2.4"
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",