@styleframe/plugin 1.0.1 → 2.0.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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @styleframe/plugin
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#50](https://github.com/styleframe-dev/styleframe/pull/50) [`0593c52`](https://github.com/styleframe-dev/styleframe/commit/0593c52798b8846d3c49762621baeb66354e0356) Thanks [@alexgrozav](https://github.com/alexgrozav)! - feat: add license check integration
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`0593c52`](https://github.com/styleframe-dev/styleframe/commit/0593c52798b8846d3c49762621baeb66354e0356)]:
12
+ - @styleframe/transpiler@1.1.0
13
+ - @styleframe/loader@1.1.0
14
+
3
15
  ## 1.0.1
4
16
 
5
17
  ### Patch Changes
package/dist/astro.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { src_default } from "./src-mpvRItvZ.js";
2
+ import { src_default } from "./src-DZUr2xdj.js";
3
3
 
4
4
  //#region src/astro.ts
5
5
  var astro_default = (options) => ({
package/dist/esbuild.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { unpluginFactory } from "./src-mpvRItvZ.js";
2
+ import { unpluginFactory } from "./src-DZUr2xdj.js";
3
3
  import { createEsbuildPlugin } from "unplugin";
4
4
 
5
5
  //#region src/esbuild.ts
package/dist/farm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { unpluginFactory } from "./src-mpvRItvZ.js";
2
+ import { unpluginFactory } from "./src-DZUr2xdj.js";
3
3
  import { createFarmPlugin } from "unplugin";
4
4
 
5
5
  //#region src/farm.ts
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { Options } from "./types-Clt7t35T.js";
2
- import * as unplugin0 from "unplugin";
2
+ import * as unplugin1 from "unplugin";
3
3
  import { UnpluginFactory } from "unplugin";
4
4
 
5
5
  //#region src/index.d.ts
6
6
  declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
- declare const unplugin: unplugin0.UnpluginInstance<Options | undefined, boolean>;
7
+ declare const unplugin: unplugin1.UnpluginInstance<Options | undefined, boolean>;
8
8
  //#endregion
9
9
  export { unplugin as default, unplugin, unpluginFactory };
10
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;cAwBa,iBAAiB,gBAAgB;cAkGjC,UAAQ,SAAA,CAAA,iBAAA"}
1
+ {"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;cAsCa,iBAAiB,gBAAgB;cAmHjC,UAAQ,SAAA,CAAA,iBAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { src_default, unplugin, unpluginFactory } from "./src-mpvRItvZ.js";
2
+ import { src_default, unplugin, unpluginFactory } from "./src-DZUr2xdj.js";
3
3
 
4
4
  export { src_default as default, unplugin, unpluginFactory };
package/dist/nuxt.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import "./src-mpvRItvZ.js";
3
- import { vite_default } from "./vite-Cs6rddMM.js";
4
- import { webpack_default } from "./webpack-D2mM1N3t.js";
2
+ import "./src-DZUr2xdj.js";
3
+ import { vite_default } from "./vite-DmSF1ssW.js";
4
+ import { webpack_default } from "./webpack-D94H_tz3.js";
5
5
  import { addVitePlugin, addWebpackPlugin, defineNuxtModule } from "@nuxt/kit";
6
6
 
7
7
  //#region src/nuxt.ts
package/dist/rollup.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { unpluginFactory } from "./src-mpvRItvZ.js";
2
+ import { unpluginFactory } from "./src-DZUr2xdj.js";
3
3
  import { createRollupPlugin } from "unplugin";
4
4
 
5
5
  //#region src/rollup.ts
package/dist/rspack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { unpluginFactory } from "./src-mpvRItvZ.js";
2
+ import { unpluginFactory } from "./src-DZUr2xdj.js";
3
3
  import { createRspackPlugin } from "unplugin";
4
4
 
5
5
  //#region src/rspack.ts
@@ -1,17 +1,25 @@
1
1
  import { DEFAULT_ENTRY, DEFAULT_OPTIONS, PLUGIN_NAME, RESOLVED_VIRTUAL_CSS_MODULE_ID, RESOLVED_VIRTUAL_TS_MODULE_ID, VIRTUAL_CSS_MODULE_ID, VIRTUAL_TS_MODULE_ID } from "./constants-CnbAL4bY.js";
2
+ import path from "node:path";
3
+ import { getLicenseKeyFromEnv, validateInstanceLicense } from "@styleframe/license";
2
4
  import { loadConfigurationFromPath } from "@styleframe/loader";
3
5
  import { transpile } from "@styleframe/transpiler";
4
6
  import { consola } from "consola";
5
- import path from "node:path";
6
7
  import { createUnplugin } from "unplugin";
7
8
 
8
9
  //#region src/index.ts
9
- async function loadAndBuildEntry(entry, options) {
10
- return transpile(await loadConfigurationFromPath(entry), options);
10
+ async function loadAndBuildEntry(entry, options, isBuild) {
11
+ const instance = await loadConfigurationFromPath(entry);
12
+ await validateInstanceLicense(instance, {
13
+ licenseKey: getLicenseKeyFromEnv() || "",
14
+ environment: process.env.NODE_ENV || "development",
15
+ isBuild
16
+ });
17
+ return transpile(instance, options);
11
18
  }
12
19
  const unpluginFactory = (options = DEFAULT_OPTIONS) => {
13
20
  const rawEntry = options.entry ?? DEFAULT_ENTRY;
14
21
  const entries = (typeof rawEntry === "string" ? [rawEntry] : rawEntry).map((p) => path.isAbsolute(p) ? p : path.resolve(process.cwd(), p));
22
+ let isBuildCommand = false;
15
23
  return {
16
24
  name: PLUGIN_NAME,
17
25
  enforce: "pre",
@@ -19,6 +27,9 @@ const unpluginFactory = (options = DEFAULT_OPTIONS) => {
19
27
  if (id === VIRTUAL_CSS_MODULE_ID) return RESOLVED_VIRTUAL_CSS_MODULE_ID;
20
28
  else if (id === VIRTUAL_TS_MODULE_ID) return RESOLVED_VIRTUAL_TS_MODULE_ID;
21
29
  },
30
+ buildStart() {
31
+ isBuildCommand = process.argv.includes("build");
32
+ },
22
33
  async load(id) {
23
34
  if (id === RESOLVED_VIRTUAL_CSS_MODULE_ID || id === RESOLVED_VIRTUAL_TS_MODULE_ID) {
24
35
  let hasError = false;
@@ -31,7 +42,7 @@ const unpluginFactory = (options = DEFAULT_OPTIONS) => {
31
42
  for (const entry of entries) {
32
43
  this.addWatchFile(entry);
33
44
  try {
34
- results.push(await loadAndBuildEntry(entry, { type }));
45
+ results.push(await loadAndBuildEntry(entry, { type }, isBuildCommand));
35
46
  } catch (error) {
36
47
  hasError = true;
37
48
  consola.error(`[styleframe] Failed to build: ${entry}`, error);
@@ -64,4 +75,4 @@ var src_default = unplugin;
64
75
 
65
76
  //#endregion
66
77
  export { src_default, unplugin, unpluginFactory };
67
- //# sourceMappingURL=src-mpvRItvZ.js.map
78
+ //# sourceMappingURL=src-DZUr2xdj.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-DZUr2xdj.js","names":["unpluginFactory: UnpluginFactory<Options | undefined>","entries: string[]"],"sources":["../src/index.ts"],"sourcesContent":["import path from \"node:path\";\nimport {\n\tgetLicenseKeyFromEnv,\n\tvalidateInstanceLicense,\n} from \"@styleframe/license\";\nimport { loadConfigurationFromPath } from \"@styleframe/loader\";\nimport type { TranspileOptions } from \"@styleframe/transpiler\";\nimport { transpile } from \"@styleframe/transpiler\";\nimport { consola } from \"consola\";\nimport type { UnpluginFactory } from \"unplugin\";\nimport { createUnplugin } from \"unplugin\";\nimport {\n\tDEFAULT_ENTRY,\n\tDEFAULT_OPTIONS,\n\tPLUGIN_NAME,\n\tRESOLVED_VIRTUAL_CSS_MODULE_ID,\n\tRESOLVED_VIRTUAL_TS_MODULE_ID,\n\tVIRTUAL_CSS_MODULE_ID,\n\tVIRTUAL_TS_MODULE_ID,\n} from \"./constants\";\nimport type { Options } from \"./types\";\n\nasync function loadAndBuildEntry(\n\tentry: string,\n\toptions: TranspileOptions,\n\tisBuild: boolean,\n) {\n\tconst instance = await loadConfigurationFromPath(entry);\n\n\tawait validateInstanceLicense(instance, {\n\t\tlicenseKey: getLicenseKeyFromEnv() || \"\",\n\t\tenvironment: process.env.NODE_ENV || \"development\",\n\t\tisBuild,\n\t});\n\n\treturn transpile(instance, options);\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (\n\toptions = DEFAULT_OPTIONS,\n) => {\n\tconst rawEntry = options.entry ?? DEFAULT_ENTRY;\n\tconst entries: string[] = (\n\t\ttypeof rawEntry === \"string\" ? [rawEntry] : rawEntry\n\t).map((p) => (path.isAbsolute(p) ? p : path.resolve(process.cwd(), p)));\n\n\tlet isBuildCommand = false;\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\t\tenforce: \"pre\",\n\t\tresolveId(id) {\n\t\t\tif (id === VIRTUAL_CSS_MODULE_ID) {\n\t\t\t\treturn RESOLVED_VIRTUAL_CSS_MODULE_ID;\n\t\t\t} else if (id === VIRTUAL_TS_MODULE_ID) {\n\t\t\t\treturn RESOLVED_VIRTUAL_TS_MODULE_ID;\n\t\t\t}\n\t\t},\n\t\tbuildStart() {\n\t\t\tisBuildCommand = process.argv.includes(\"build\");\n\t\t},\n\t\tasync load(id) {\n\t\t\tif (\n\t\t\t\tid === RESOLVED_VIRTUAL_CSS_MODULE_ID ||\n\t\t\t\tid === RESOLVED_VIRTUAL_TS_MODULE_ID\n\t\t\t) {\n\t\t\t\tlet hasError = false;\n\t\t\t\tconst type = id.endsWith(\".css\") ? \"css\" : \"ts\";\n\n\t\t\t\tif (!options.silent && type === \"css\") {\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t\tconsola.info(`[styleframe] Building...`);\n\t\t\t\t}\n\n\t\t\t\tconst results = [];\n\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\tthis.addWatchFile(entry);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresults.push(\n\t\t\t\t\t\t\tawait loadAndBuildEntry(\n\t\t\t\t\t\t\t\tentry,\n\t\t\t\t\t\t\t\t{ type },\n\t\t\t\t\t\t\t\tisBuildCommand,\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\thasError = true;\n\t\t\t\t\t\tconsola.error(\n\t\t\t\t\t\t\t`[styleframe] Failed to build: ${entry}`,\n\t\t\t\t\t\t\terror,\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst code = results.reduce(\n\t\t\t\t\t(acc, result) =>\n\t\t\t\t\t\tacc +\n\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\tresult.files.reduce(\n\t\t\t\t\t\t\t(fileAcc, file) => `${fileAcc}\\n${file.content}`,\n\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"\",\n\t\t\t\t);\n\n\t\t\t\tif (!options.silent && type === \"css\" && !hasError) {\n\t\t\t\t\tconsola.success(`[styleframe] Built successfully.`);\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t}\n\n\t\t\t\treturn { code };\n\t\t\t}\n\t\t},\n\t\tvite: {\n\t\t\tasync handleHotUpdate(ctx) {\n\t\t\t\tconst getModuleById = async (id: string) => {\n\t\t\t\t\tconst mod = ctx.server?.moduleGraph.getModuleById(id);\n\t\t\t\t\treturn (\n\t\t\t\t\t\tmod ??\n\t\t\t\t\t\t(await ctx.server?.moduleGraph.getModuleByUrl(id))\n\t\t\t\t\t);\n\t\t\t\t};\n\n\t\t\t\t// If a tracked entry changed, rebuild it and invalidate the virtual css module\n\t\t\t\tif (entries.includes(ctx.file)) {\n\t\t\t\t\t// Invalidate the virtual module so HMR pushes the updated css\n\t\t\t\t\tconst cssModule =\n\t\t\t\t\t\t(await getModuleById(RESOLVED_VIRTUAL_CSS_MODULE_ID)) ??\n\t\t\t\t\t\t(await getModuleById(VIRTUAL_CSS_MODULE_ID));\n\n\t\t\t\t\t// Invalidate the virtual module so HMR pushes the updated typescript module\n\t\t\t\t\tconst tsModule =\n\t\t\t\t\t\t(await getModuleById(RESOLVED_VIRTUAL_TS_MODULE_ID)) ??\n\t\t\t\t\t\t(await getModuleById(VIRTUAL_TS_MODULE_ID));\n\n\t\t\t\t\tif (cssModule || tsModule) {\n\t\t\t\t\t\t// Tell Vite that this module is affected\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t...(cssModule ? [cssModule] : []),\n\t\t\t\t\t\t\t...(tsModule ? [tsModule] : []),\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t\t// Fall back to a full reload if for some reason we didn’t find the module\n\t\t\t\t\tctx.server?.ws.send({ type: \"full-reload\" });\n\t\t\t\t}\n\n\t\t\t\treturn ctx.modules;\n\t\t\t},\n\t\t},\n\t};\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;;AAsBA,eAAe,kBACd,OACA,SACA,SACC;CACD,MAAM,WAAW,MAAM,0BAA0B,MAAM;AAEvD,OAAM,wBAAwB,UAAU;EACvC,YAAY,sBAAsB,IAAI;EACtC,aAAa,QAAQ,IAAI,YAAY;EACrC;EACA,CAAC;AAEF,QAAO,UAAU,UAAU,QAAQ;;AAGpC,MAAaA,mBACZ,UAAU,oBACN;CACJ,MAAM,WAAW,QAAQ,SAAS;CAClC,MAAMC,WACL,OAAO,aAAa,WAAW,CAAC,SAAS,GAAG,UAC3C,KAAK,MAAO,KAAK,WAAW,EAAE,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,EAAE,EAAE,CAAE;CAEvE,IAAI,iBAAiB;AAErB,QAAO;EACN,MAAM;EACN,SAAS;EACT,UAAU,IAAI;AACb,OAAI,OAAO,s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AAG,EAAE,CAC9B;AAGF,QAAI,QAAQ,GAAG,KAAK,EAAE,MAAM,eAAe,CAAC;;AAG7C,UAAO,IAAI;KAEZ;EACD;;AAGF,MAAa,WAA2B,+BAAe,gBAAgB;AAEvE,kBAAe"}
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-mpvRItvZ.js";
1
+ import { unpluginFactory } from "./src-DZUr2xdj.js";
2
2
  import { createVitePlugin } from "unplugin";
3
3
 
4
4
  //#region src/vite.ts
@@ -6,4 +6,4 @@ var vite_default = createVitePlugin(unpluginFactory);
6
6
 
7
7
  //#endregion
8
8
  export { vite_default };
9
- //# sourceMappingURL=vite-Cs6rddMM.js.map
9
+ //# sourceMappingURL=vite-DmSF1ssW.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vite-Cs6rddMM.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\n\nexport default createVitePlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,mBAAe,iBAAiB,gBAAgB"}
1
+ {"version":3,"file":"vite-DmSF1ssW.js","names":[],"sources":["../src/vite.ts"],"sourcesContent":["import { createVitePlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\n\nexport default createVitePlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,mBAAe,iBAAiB,gBAAgB"}
package/dist/vite.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import "./src-mpvRItvZ.js";
3
- import { vite_default } from "./vite-Cs6rddMM.js";
2
+ import "./src-DZUr2xdj.js";
3
+ import { vite_default } from "./vite-DmSF1ssW.js";
4
4
 
5
5
  export { vite_default as default };
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-mpvRItvZ.js";
1
+ import { unpluginFactory } from "./src-DZUr2xdj.js";
2
2
  import { createWebpackPlugin } from "unplugin";
3
3
 
4
4
  //#region src/webpack.ts
@@ -6,4 +6,4 @@ var webpack_default = createWebpackPlugin(unpluginFactory);
6
6
 
7
7
  //#endregion
8
8
  export { webpack_default };
9
- //# sourceMappingURL=webpack-D2mM1N3t.js.map
9
+ //# sourceMappingURL=webpack-D94H_tz3.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"webpack-D2mM1N3t.js","names":[],"sources":["../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\n\nexport default createWebpackPlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,sBAAe,oBAAoB,gBAAgB"}
1
+ {"version":3,"file":"webpack-D94H_tz3.js","names":[],"sources":["../src/webpack.ts"],"sourcesContent":["import { createWebpackPlugin } from \"unplugin\";\nimport { unpluginFactory } from \".\";\n\nexport default createWebpackPlugin(unpluginFactory);\n"],"mappings":";;;;AAGA,sBAAe,oBAAoB,gBAAgB"}
package/dist/webpack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import "./src-mpvRItvZ.js";
3
- import { webpack_default } from "./webpack-D2mM1N3t.js";
2
+ import "./src-DZUr2xdj.js";
3
+ import { webpack_default } from "./webpack-D94H_tz3.js";
4
4
 
5
5
  export { webpack_default as default };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@styleframe/plugin",
3
3
  "type": "module",
4
- "version": "1.0.1",
4
+ "version": "2.0.0",
5
5
  "description": "Unplugin for Styleframe. Use it with Vite, Webpack, Astro, Nuxt, Rollup, Rspack, and more.",
6
6
  "license": "MIT",
7
7
  "keywords": [
@@ -78,10 +78,11 @@
78
78
  }
79
79
  },
80
80
  "dependencies": {
81
+ "@styleframe/license": "^1.1.0",
81
82
  "consola": "^3.4.2",
82
83
  "unplugin": "^2.3.4",
83
- "@styleframe/loader": "^1.0.3",
84
- "@styleframe/transpiler": "^1.0.3"
84
+ "@styleframe/loader": "^2.0.0",
85
+ "@styleframe/transpiler": "^2.0.0"
85
86
  },
86
87
  "devDependencies": {
87
88
  "@farmfe/core": "^1.7.11",
@@ -97,7 +98,7 @@
97
98
  "vite": "^6.3.5",
98
99
  "vitest": "^3.1.4",
99
100
  "webpack": "^5.99.9",
100
- "@styleframe/config-typescript": "^1.0.1"
101
+ "@styleframe/config-typescript": "^2.0.0"
101
102
  },
102
103
  "homepage": "https://github.com/styleframe-dev/styleframe#readme",
103
104
  "bugs": {
@@ -1 +0,0 @@
1
- {"version":3,"file":"src-mpvRItvZ.js","names":["unpluginFactory: UnpluginFactory<Options | undefined>","entries: string[]"],"sources":["../src/index.ts"],"sourcesContent":["import { loadConfigurationFromPath } from \"@styleframe/loader\";\nimport type { TranspileOptions } from \"@styleframe/transpiler\";\nimport { transpile } from \"@styleframe/transpiler\";\nimport { consola } from \"consola\";\nimport path from \"node:path\";\nimport type { UnpluginFactory } from \"unplugin\";\nimport { createUnplugin } from \"unplugin\";\nimport {\n\tDEFAULT_ENTRY,\n\tDEFAULT_OPTIONS,\n\tPLUGIN_NAME,\n\tRESOLVED_VIRTUAL_CSS_MODULE_ID,\n\tRESOLVED_VIRTUAL_TS_MODULE_ID,\n\tVIRTUAL_CSS_MODULE_ID,\n\tVIRTUAL_TS_MODULE_ID,\n} from \"./constants\";\nimport type { Options } from \"./types\";\n\nasync function loadAndBuildEntry(entry: string, options: TranspileOptions) {\n\tconst instance = await loadConfigurationFromPath(entry);\n\n\treturn transpile(instance, options);\n}\n\nexport const unpluginFactory: UnpluginFactory<Options | undefined> = (\n\toptions = DEFAULT_OPTIONS,\n) => {\n\tconst rawEntry = options.entry ?? DEFAULT_ENTRY;\n\tconst entries: string[] = (\n\t\ttypeof rawEntry === \"string\" ? [rawEntry] : rawEntry\n\t).map((p) => (path.isAbsolute(p) ? p : path.resolve(process.cwd(), p)));\n\n\treturn {\n\t\tname: PLUGIN_NAME,\n\t\tenforce: \"pre\",\n\t\tresolveId(id) {\n\t\t\tif (id === VIRTUAL_CSS_MODULE_ID) {\n\t\t\t\treturn RESOLVED_VIRTUAL_CSS_MODULE_ID;\n\t\t\t} else if (id === VIRTUAL_TS_MODULE_ID) {\n\t\t\t\treturn RESOLVED_VIRTUAL_TS_MODULE_ID;\n\t\t\t}\n\t\t},\n\t\tasync load(id) {\n\t\t\tif (\n\t\t\t\tid === RESOLVED_VIRTUAL_CSS_MODULE_ID ||\n\t\t\t\tid === RESOLVED_VIRTUAL_TS_MODULE_ID\n\t\t\t) {\n\t\t\t\tlet hasError = false;\n\t\t\t\tconst type = id.endsWith(\".css\") ? \"css\" : \"ts\";\n\n\t\t\t\tif (!options.silent && type === \"css\") {\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t\tconsola.info(`[styleframe] Building...`);\n\t\t\t\t}\n\n\t\t\t\tconst results = [];\n\t\t\t\tfor (const entry of entries) {\n\t\t\t\t\tthis.addWatchFile(entry);\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tresults.push(await loadAndBuildEntry(entry, { type }));\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\thasError = true;\n\t\t\t\t\t\tconsola.error(`[styleframe] Failed to build: ${entry}`, error);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst code = results.reduce(\n\t\t\t\t\t(acc, result) =>\n\t\t\t\t\t\tacc +\n\t\t\t\t\t\t\"\\n\" +\n\t\t\t\t\t\tresult.files.reduce(\n\t\t\t\t\t\t\t(fileAcc, file) => `${fileAcc}\\n${file.content}`,\n\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t),\n\t\t\t\t\t\"\",\n\t\t\t\t);\n\n\t\t\t\tif (!options.silent && type === \"css\" && !hasError) {\n\t\t\t\t\tconsola.success(`[styleframe] Built successfully.`);\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t}\n\n\t\t\t\treturn { code };\n\t\t\t}\n\t\t},\n\t\tvite: {\n\t\t\tasync handleHotUpdate(ctx) {\n\t\t\t\tconst getModuleById = async (id: string) => {\n\t\t\t\t\tconst mod = ctx.server?.moduleGraph.getModuleById(id);\n\t\t\t\t\treturn mod ?? (await ctx.server?.moduleGraph.getModuleByUrl(id));\n\t\t\t\t};\n\n\t\t\t\t// If a tracked entry changed, rebuild it and invalidate the virtual css module\n\t\t\t\tif (entries.includes(ctx.file)) {\n\t\t\t\t\t// Invalidate the virtual module so HMR pushes the updated css\n\t\t\t\t\tconst cssModule =\n\t\t\t\t\t\t(await getModuleById(RESOLVED_VIRTUAL_CSS_MODULE_ID)) ??\n\t\t\t\t\t\t(await getModuleById(VIRTUAL_CSS_MODULE_ID));\n\n\t\t\t\t\t// Invalidate the virtual module so HMR pushes the updated typescript module\n\t\t\t\t\tconst tsModule =\n\t\t\t\t\t\t(await getModuleById(RESOLVED_VIRTUAL_TS_MODULE_ID)) ??\n\t\t\t\t\t\t(await getModuleById(VIRTUAL_TS_MODULE_ID));\n\n\t\t\t\t\tif (cssModule || tsModule) {\n\t\t\t\t\t\t// Tell Vite that this module is affected\n\t\t\t\t\t\treturn [\n\t\t\t\t\t\t\t...(cssModule ? [cssModule] : []),\n\t\t\t\t\t\t\t...(tsModule ? [tsModule] : []),\n\t\t\t\t\t\t];\n\t\t\t\t\t}\n\t\t\t\t\t// Fall back to a full reload if for some reason we didn’t find the module\n\t\t\t\t\tctx.server?.ws.send({ type: \"full-reload\" });\n\t\t\t\t}\n\n\t\t\t\treturn ctx.modules;\n\t\t\t},\n\t\t},\n\t};\n};\n\nexport const unplugin = /* #__PURE__ */ createUnplugin(unpluginFactory);\n\nexport default unplugin;\n"],"mappings":";;;;;;;;AAkBA,eAAe,kBAAkB,OAAe,SAA2B;AAG1E,QAAO,UAFU,MAAM,0BAA0B,MAAM,EAE5B,QAAQ;;AAGpC,MAAaA,mBACZ,UAAU,oBACN;CACJ,MAAM,WAAW,QAAQ,SAAS;CAClC,MAAMC,WACL,OAAO,aAAa,WAAW,CAAC,SAAS,GAAG,UAC3C,KAAK,MAAO,KAAK,WAAW,EAAE,GAAG,IAAI,KAAK,QAAQ,QAAQ,KAAK,EAAE,EAAE,C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