@styleframe/plugin 2.0.2 → 2.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/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/src-DZUr2xdj.js.map +1 -1
- package/dist/webpack.d.ts +2 -2
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Options } from "./types-Clt7t35T.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as unplugin2 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:
|
|
7
|
+
declare const unplugin: unplugin2.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.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;cAsCa,iBAAiB,gBAAgB;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;cAsCa,iBAAiB,gBAAgB;cAyGjC,UAAQ,SAAA,CAAA,iBAAA"}
|
package/dist/src-DZUr2xdj.js.map
CHANGED
|
@@ -1 +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(
|
|
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,aAAa;AACZ,oBAAiB,QAAQ,KAAK,SAAS,QAAQ;;EAEhD,MAAM,KAAK,IAAI;AACd,OACC,OAAO,kCACP,OAAO,+BACN;IACD,IAAI,WAAW;IACf,MAAM,OAAO,GAAG,SAAS,OAAO,GAAG,QAAQ;AAE3C,QAAI,CAAC,QAAQ,UAAU,SAAS,OAAO;AACtC,aAAQ,IAAI,GAAG;AACf,aAAQ,KAAK,2BAA2B;;IAGzC,MAAM,UAAU,EAAE;AAClB,SAAK,MAAM,SAAS,SAAS;AAC5B,UAAK,aAAa,MAAM;AAExB,SAAI;AACH,cAAQ,KACP,MAAM,kBAAkB,OAAO,EAAE,MAAM,EAAE,eAAe,CACxD;cACO,OAAO;AACf,iBAAW;AACX,cAAQ,MAAM,iCAAiC,SAAS,MAAM;;;IAIhE,MAAM,OAAO,QAAQ,QACnB,KAAK,WACL,MACA,OACA,OAAO,MAAM,QACX,SAAS,SAAS,GAAG,QAAQ,IAAI,KAAK,WACvC,GACA,EACF,GACA;AAED,QAAI,CAAC,QAAQ,UAAU,SAAS,SAAS,CAAC,UAAU;AACnD,aAAQ,QAAQ,mCAAmC;AACnD,aAAQ,IAAI,GAAG;;AAGhB,WAAO,EAAE,MAAM;;;EAGjB,MAAM,EACL,MAAM,gBAAgB,KAAK;GAC1B,MAAM,gBAAgB,OAAO,OAAe;AAE3C,WADY,IAAI,QAAQ,YAAY,cAAc,GAAG,IACtC,MAAM,IAAI,QAAQ,YAAY,eAAe,GAAG;;AAIhE,OAAI,QAAQ,SAAS,IAAI,KAAK,EAAE;IAE/B,MAAM,YACJ,MAAM,cAAc,+BAA+B,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"}
|
package/dist/webpack.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Options } from "./types-Clt7t35T.js";
|
|
2
|
-
import * as
|
|
2
|
+
import * as unplugin0 from "unplugin";
|
|
3
3
|
|
|
4
4
|
//#region src/webpack.d.ts
|
|
5
|
-
declare const _default: (options?: Options | undefined) =>
|
|
5
|
+
declare const _default: (options?: Options | undefined) => unplugin0.WebpackPluginInstance;
|
|
6
6
|
//#endregion
|
|
7
7
|
export { _default as default };
|
|
8
8
|
//# sourceMappingURL=webpack.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@styleframe/plugin",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.
|
|
4
|
+
"version": "2.0.3",
|
|
5
5
|
"description": "Unplugin for Styleframe. Use it with Vite, Webpack, Astro, Nuxt, Rollup, Rspack, and more.",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"keywords": [
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"@styleframe/license": "^2.0.0",
|
|
82
82
|
"consola": "^3.4.2",
|
|
83
83
|
"unplugin": "^2.3.4",
|
|
84
|
-
"@styleframe/loader": "2.0.
|
|
85
|
-
"@styleframe/transpiler": "2.0.
|
|
84
|
+
"@styleframe/loader": "2.0.3",
|
|
85
|
+
"@styleframe/transpiler": "2.0.3"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@farmfe/core": "^1.7.11",
|
|
@@ -98,7 +98,7 @@
|
|
|
98
98
|
"vite": "^6.3.5",
|
|
99
99
|
"vitest": "^3.1.4",
|
|
100
100
|
"webpack": "^5.99.9",
|
|
101
|
-
"@styleframe/config-typescript": "2.0.
|
|
101
|
+
"@styleframe/config-typescript": "2.0.3"
|
|
102
102
|
},
|
|
103
103
|
"homepage": "https://github.com/styleframe-dev/styleframe#readme",
|
|
104
104
|
"bugs": {
|