@styleframe/plugin 2.0.3 → 2.2.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,28 @@
1
1
  # @styleframe/plugin
2
2
 
3
+ ## 2.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#63](https://github.com/styleframe-dev/styleframe/pull/63) [`ec430e1`](https://github.com/styleframe-dev/styleframe/commit/ec430e11502b3dba69c20ee10b24f0302008883c) Thanks [@alexgrozav](https://github.com/alexgrozav)! - feat: add styleframe runtime for recipes
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [[`ec430e1`](https://github.com/styleframe-dev/styleframe/commit/ec430e11502b3dba69c20ee10b24f0302008883c)]:
12
+ - @styleframe/transpiler@2.4.0
13
+
14
+ ## 2.1.0
15
+
16
+ ### Minor Changes
17
+
18
+ - [`628e650`](https://github.com/styleframe-dev/styleframe/commit/628e65039bae5e21ab9a66e16037e7e2791f8c8b) Thanks [@alexgrozav](https://github.com/alexgrozav)! - chore: update dependencies
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`628e650`](https://github.com/styleframe-dev/styleframe/commit/628e65039bae5e21ab9a66e16037e7e2791f8c8b)]:
23
+ - @styleframe/transpiler@2.2.0
24
+ - @styleframe/loader@2.2.0
25
+
3
26
  ## 2.0.2
4
27
 
5
28
  ### Patch Changes
package/dist/astro.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { src_default } from "./src-DZUr2xdj.js";
2
+ import { src_default } from "./src-CbLcGwwa.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-DZUr2xdj.js";
2
+ import { unpluginFactory } from "./src-CbLcGwwa.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-DZUr2xdj.js";
2
+ import { unpluginFactory } from "./src-CbLcGwwa.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 unplugin2 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: unplugin2.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
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import { src_default, unplugin, unpluginFactory } from "./src-DZUr2xdj.js";
2
+ import { src_default, unplugin, unpluginFactory } from "./src-CbLcGwwa.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-DZUr2xdj.js";
3
- import { vite_default } from "./vite-DmSF1ssW.js";
4
- import { webpack_default } from "./webpack-D94H_tz3.js";
2
+ import "./src-CbLcGwwa.js";
3
+ import { vite_default } from "./vite-3J2RRvnX.js";
4
+ import { webpack_default } from "./webpack-UxvifMCT.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-DZUr2xdj.js";
2
+ import { unpluginFactory } from "./src-CbLcGwwa.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-DZUr2xdj.js";
2
+ import { unpluginFactory } from "./src-CbLcGwwa.js";
3
3
  import { createRspackPlugin } from "unplugin";
4
4
 
5
5
  //#region src/rspack.ts
@@ -34,9 +34,9 @@ const unpluginFactory = (options = DEFAULT_OPTIONS) => {
34
34
  if (id === RESOLVED_VIRTUAL_CSS_MODULE_ID || id === RESOLVED_VIRTUAL_TS_MODULE_ID) {
35
35
  let hasError = false;
36
36
  const type = id.endsWith(".css") ? "css" : "ts";
37
- if (!options.silent && type === "css") {
37
+ if (!options.silent) {
38
38
  console.log("");
39
- consola.info(`[styleframe] Building...`);
39
+ consola.info(`[styleframe] Building ${type}...`);
40
40
  }
41
41
  const results = [];
42
42
  for (const entry of entries) {
@@ -49,8 +49,8 @@ const unpluginFactory = (options = DEFAULT_OPTIONS) => {
49
49
  }
50
50
  }
51
51
  const code = results.reduce((acc, result) => acc + "\n" + result.files.reduce((fileAcc, file) => `${fileAcc}\n${file.content}`, ""), "");
52
- if (!options.silent && type === "css" && !hasError) {
53
- consola.success(`[styleframe] Built successfully.`);
52
+ if (!options.silent && !hasError) {
53
+ consola.success(`[styleframe] Built ${type} successfully.`);
54
54
  console.log("");
55
55
  }
56
56
  return { code };
@@ -75,4 +75,4 @@ var src_default = unplugin;
75
75
 
76
76
  //#endregion
77
77
  export { src_default, unplugin, unpluginFactory };
78
- //# sourceMappingURL=src-DZUr2xdj.js.map
78
+ //# sourceMappingURL=src-CbLcGwwa.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"src-CbLcGwwa.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) {\n\t\t\t\t\tconsole.log(\"\");\n\t\t\t\t\tconsola.info(`[styleframe] Building ${type}...`);\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(entry, { type }, isBuildCommand),\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(`[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 && !hasError) {\n\t\t\t\t\tconsola.success(`[styleframe] Built ${type} 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":";;;;;;;;;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,U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IACnD,MAAM,cAAc,sBAAsB;IAG5C,MAAM,WACJ,MAAM,cAAc,8BAA8B,IAClD,MAAM,cAAc,qBAAqB;AAE3C,QAAI,aAAa,SAEhB,QAAO,CACN,GAAI,YAAY,CAAC,UAAU,GAAG,EAAE,EAChC,GAAI,WAAW,CAAC,SAAS,GAAG,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-DZUr2xdj.js";
1
+ import { unpluginFactory } from "./src-CbLcGwwa.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-DmSF1ssW.js.map
9
+ //# sourceMappingURL=vite-3J2RRvnX.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"vite-3J2RRvnX.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-DZUr2xdj.js";
3
- import { vite_default } from "./vite-DmSF1ssW.js";
2
+ import "./src-CbLcGwwa.js";
3
+ import { vite_default } from "./vite-3J2RRvnX.js";
4
4
 
5
5
  export { vite_default as default };
@@ -1,4 +1,4 @@
1
- import { unpluginFactory } from "./src-DZUr2xdj.js";
1
+ import { unpluginFactory } from "./src-CbLcGwwa.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-D94H_tz3.js.map
9
+ //# sourceMappingURL=webpack-UxvifMCT.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"webpack-UxvifMCT.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.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { Options } from "./types-Clt7t35T.js";
2
- import * as unplugin0 from "unplugin";
2
+ import * as webpack0 from "webpack";
3
3
 
4
4
  //#region src/webpack.d.ts
5
- declare const _default: (options?: Options | undefined) => unplugin0.WebpackPluginInstance;
5
+ declare const _default: (options?: Options | undefined) => webpack0.WebpackPluginInstance;
6
6
  //#endregion
7
7
  export { _default as default };
8
8
  //# sourceMappingURL=webpack.d.ts.map
package/dist/webpack.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import "./constants-CnbAL4bY.js";
2
- import "./src-DZUr2xdj.js";
3
- import { webpack_default } from "./webpack-D94H_tz3.js";
2
+ import "./src-CbLcGwwa.js";
3
+ import { webpack_default } from "./webpack-UxvifMCT.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": "2.0.3",
4
+ "version": "2.2.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": [
@@ -79,13 +79,14 @@
79
79
  },
80
80
  "dependencies": {
81
81
  "@styleframe/license": "^2.0.0",
82
+ "@styleframe/loader": "^2.2.0",
83
+ "@styleframe/transpiler": "^2.4.0",
82
84
  "consola": "^3.4.2",
83
- "unplugin": "^2.3.4",
84
- "@styleframe/loader": "2.0.3",
85
- "@styleframe/transpiler": "2.0.3"
85
+ "unplugin": "^2.3.4"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@farmfe/core": "^1.7.11",
89
+ "@styleframe/config-typescript": "^2",
89
90
  "@vitest/coverage-v8": "^3.2.4",
90
91
  "@nuxt/kit": "^3.17.4",
91
92
  "@nuxt/schema": "^3.17.4",
@@ -97,8 +98,7 @@
97
98
  "typescript": "^5.8.3",
98
99
  "vite": "^6.3.5",
99
100
  "vitest": "^3.1.4",
100
- "webpack": "^5.99.9",
101
- "@styleframe/config-typescript": "2.0.3"
101
+ "webpack": "^5.99.9"
102
102
  },
103
103
  "homepage": "https://github.com/styleframe-dev/styleframe#readme",
104
104
  "bugs": {
@@ -1 +0,0 @@
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(entry, { type }, isBuildCommand),\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(`[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":";;;;;;;;;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,sBACV,QAAO;YACG,OAAO,qBACjB,QAAO;;EAGT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