@fluxion-ui/vite-plugin-fluxion 0.0.3 → 0.0.4
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.
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@fluxion-ui/compiler-nui"),r=require("@fluxion-ui/shared");function n(n={}){const{include:o=[".nui"]}=n;let
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@fluxion-ui/compiler-nui"),r=require("@fluxion-ui/shared");function n(n={}){const{include:o=[".nui"],indentSize:t}=n;let i;function u(e){return o.some(r=>e.endsWith(r))}return{name:"fluxion",configResolved(e){i=e},enforce:"pre",transform(n,o){if(!u(o))return null;try{const u=e.compile(n,{filename:o,isBrowser:!0,indentSize:t});if(u.errors.length>0){for(const e of u.errors)r.warn(`[fluxion] ${o}: ${e.message}`);if("development"===i.mode)return{code:"export default function() { return document.createElement('div'); }",map:null};throw u.errors[0]}return{code:u.code,map:null}}catch(e){throw r.warn(`[fluxion] Failed to compile ${o}: ${e.message}`),e}},handleHotUpdate({file:e,server:r}){if(u(e))return r.ws.send({type:"full-reload",path:e}),[]}}}exports.default=n,exports.fluxionPlugin=n;
|
|
2
2
|
//# sourceMappingURL=vite-plugin-fluxion.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-fluxion.cjs","sources":["../src/index.ts"],"sourcesContent":["/**\n * vite-plugin-fluxion\n * Vite 插件,用于编译 .nui 文件\n */\n\nimport { Plugin, ResolvedConfig } from 'vite'\nimport { compile
|
|
1
|
+
{"version":3,"file":"vite-plugin-fluxion.cjs","sources":["../src/index.ts"],"sourcesContent":["/**\n * vite-plugin-fluxion\n * Vite 插件,用于编译 .nui 文件\n */\n\nimport { Plugin, ResolvedConfig } from 'vite'\nimport { compile } from '@fluxion-ui/compiler-nui'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 插件选项\n */\nexport interface FluxionPluginOptions {\n\t// 是否在开发模式\n\tisProduction?: boolean\n\t// 自定义 .nui 文件扩展名\n\tinclude?: string[]\n\t// 缩进大小(空格数量,默认 2;Tab 会被视为 indentSize 个空格)\n\tindentSize?: number\n}\n\n/**\n * 创建 Fluxion Vite 插件\n */\nexport function fluxionPlugin(options: FluxionPluginOptions = {}): Plugin {\n\tconst { include = ['.nui'], indentSize } = options\n\n\tlet config: ResolvedConfig\n\n\t/**\n\t * 检查文件是否应该被处理\n\t */\n\tfunction isNuiFile(id: string): boolean {\n\t\treturn include.some(ext => id.endsWith(ext))\n\t}\n\n\treturn {\n\t\tname: 'fluxion',\n\n\t\tconfigResolved(resolvedConfig) {\n\t\t\tconfig = resolvedConfig\n\t\t},\n\n\t\t/**\n\t\t * 解析 .nui 文件的导入\n\t\t * 使 Vite 能够正确处理 .nui 文件\n\t\t */\n\t\tenforce: 'pre',\n\n\t\t/**\n\t\t * 转换 .nui 文件为 JavaScript\n\t\t */\n\t\ttransform(code, id) {\n\t\t\tif (!isNuiFile(id)) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// 编译 .nui 文件\n\t\t\t\tconst result = compile(code, {\n\t\t\t\t\tfilename: id,\n\t\t\t\t\tisBrowser: true,\n\t\t\t\t\tindentSize\n\t\t\t\t})\n\n\t\t\t\t// 报告编译错误\n\t\t\t\tif (result.errors.length > 0) {\n\t\t\t\t\tfor (const error of result.errors) {\n\t\t\t\t\t\twarn(`[fluxion] ${id}: ${error.message}`)\n\t\t\t\t\t}\n\t\t\t\t\t// 在开发模式下,返回错误信息\n\t\t\t\t\tif (config.mode === 'development') {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcode: `export default function() { return document.createElement('div'); }`,\n\t\t\t\t\t\t\tmap: null\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow result.errors[0]\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tmap: null\n\t\t\t\t}\n\t\t\t} catch (e: any) {\n\t\t\t\twarn(`[fluxion] Failed to compile ${id}: ${e.message}`)\n\t\t\t\tthrow e\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * 处理 HMR\n\t\t */\n\t\thandleHotUpdate({ file, server }) {\n\t\t\tif (isNuiFile(file)) {\n\t\t\t\t// 触发完全重载\n\t\t\t\tserver.ws.send({\n\t\t\t\t\ttype: 'full-reload',\n\t\t\t\t\tpath: file\n\t\t\t\t})\n\t\t\t\treturn []\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport default fluxionPlugin"],"names":["fluxionPlugin","options","include","indentSize","config","isNuiFile","id","some","ext","endsWith","name","configResolved","resolvedConfig","enforce","transform","code","result","compile","filename","isBrowser","errors","length","error","warn","message","mode","map","e","handleHotUpdate","file","server","ws","send","type","path"],"mappings":"8IAwBO,SAASA,EAAcC,EAAgC,IAC7D,MAAMC,QAAEA,EAAU,CAAC,QAAMC,WAAGA,GAAeF,EAE3C,IAAIG,EAKJ,SAASC,EAAUC,GAClB,OAAOJ,EAAQK,KAAKC,GAAOF,EAAGG,SAASD,GACxC,CAEA,MAAO,CACNE,KAAM,UAEN,cAAAC,CAAeC,GACdR,EAASQ,CACV,EAMAC,QAAS,MAKT,SAAAC,CAAUC,EAAMT,GACf,IAAKD,EAAUC,GACd,OAAO,KAGR,IAEC,MAAMU,EAASC,EAAAA,QAAQF,EAAM,CAC5BG,SAAUZ,EACVa,WAAW,EACXhB,eAID,GAAIa,EAAOI,OAAOC,OAAS,EAAG,CAC7B,IAAA,MAAWC,KAASN,EAAOI,OAC1BG,EAAAA,KAAK,aAAajB,MAAOgB,EAAME,WAGhC,GAAoB,gBAAhBpB,EAAOqB,KACV,MAAO,CACNV,KAAM,sEACNW,IAAK,MAGP,MAAMV,EAAOI,OAAO,EACrB,CAEA,MAAO,CACNL,KAAMC,EAAOD,KACbW,IAAK,KAEP,OAASC,GAER,MADAJ,EAAAA,KAAK,+BAA+BjB,MAAOqB,EAAEH,WACvCG,CACP,CACD,EAKA,eAAAC,EAAgBC,KAAEA,EAAAC,OAAMA,IACvB,GAAIzB,EAAUwB,GAMb,OAJAC,EAAOC,GAAGC,KAAK,CACdC,KAAM,cACNC,KAAML,IAEA,EAET,EAEF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-fluxion.d.ts","sources":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"vite-plugin-fluxion.d.ts","sources":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{compile as e}from"@fluxion-ui/compiler-nui";import{warn as r}from"@fluxion-ui/shared";function
|
|
1
|
+
import{compile as e}from"@fluxion-ui/compiler-nui";import{warn as r}from"@fluxion-ui/shared";function n(n={}){const{include:o=[".nui"],indentSize:t}=n;let i;function l(e){return o.some(r=>e.endsWith(r))}return{name:"fluxion",configResolved(e){i=e},enforce:"pre",transform(n,o){if(!l(o))return null;try{const l=e(n,{filename:o,isBrowser:!0,indentSize:t});if(l.errors.length>0){for(const e of l.errors)r(`[fluxion] ${o}: ${e.message}`);if("development"===i.mode)return{code:"export default function() { return document.createElement('div'); }",map:null};throw l.errors[0]}return{code:l.code,map:null}}catch(e){throw r(`[fluxion] Failed to compile ${o}: ${e.message}`),e}},handleHotUpdate({file:e,server:r}){if(l(e))return r.ws.send({type:"full-reload",path:e}),[]}}}export{n as default,n as fluxionPlugin};
|
|
2
2
|
//# sourceMappingURL=vite-plugin-fluxion.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite-plugin-fluxion.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * vite-plugin-fluxion\n * Vite 插件,用于编译 .nui 文件\n */\n\nimport { Plugin, ResolvedConfig } from 'vite'\nimport { compile
|
|
1
|
+
{"version":3,"file":"vite-plugin-fluxion.js","sources":["../src/index.ts"],"sourcesContent":["/**\n * vite-plugin-fluxion\n * Vite 插件,用于编译 .nui 文件\n */\n\nimport { Plugin, ResolvedConfig } from 'vite'\nimport { compile } from '@fluxion-ui/compiler-nui'\nimport { warn } from '@fluxion-ui/shared'\n\n/**\n * 插件选项\n */\nexport interface FluxionPluginOptions {\n\t// 是否在开发模式\n\tisProduction?: boolean\n\t// 自定义 .nui 文件扩展名\n\tinclude?: string[]\n\t// 缩进大小(空格数量,默认 2;Tab 会被视为 indentSize 个空格)\n\tindentSize?: number\n}\n\n/**\n * 创建 Fluxion Vite 插件\n */\nexport function fluxionPlugin(options: FluxionPluginOptions = {}): Plugin {\n\tconst { include = ['.nui'], indentSize } = options\n\n\tlet config: ResolvedConfig\n\n\t/**\n\t * 检查文件是否应该被处理\n\t */\n\tfunction isNuiFile(id: string): boolean {\n\t\treturn include.some(ext => id.endsWith(ext))\n\t}\n\n\treturn {\n\t\tname: 'fluxion',\n\n\t\tconfigResolved(resolvedConfig) {\n\t\t\tconfig = resolvedConfig\n\t\t},\n\n\t\t/**\n\t\t * 解析 .nui 文件的导入\n\t\t * 使 Vite 能够正确处理 .nui 文件\n\t\t */\n\t\tenforce: 'pre',\n\n\t\t/**\n\t\t * 转换 .nui 文件为 JavaScript\n\t\t */\n\t\ttransform(code, id) {\n\t\t\tif (!isNuiFile(id)) {\n\t\t\t\treturn null\n\t\t\t}\n\n\t\t\ttry {\n\t\t\t\t// 编译 .nui 文件\n\t\t\t\tconst result = compile(code, {\n\t\t\t\t\tfilename: id,\n\t\t\t\t\tisBrowser: true,\n\t\t\t\t\tindentSize\n\t\t\t\t})\n\n\t\t\t\t// 报告编译错误\n\t\t\t\tif (result.errors.length > 0) {\n\t\t\t\t\tfor (const error of result.errors) {\n\t\t\t\t\t\twarn(`[fluxion] ${id}: ${error.message}`)\n\t\t\t\t\t}\n\t\t\t\t\t// 在开发模式下,返回错误信息\n\t\t\t\t\tif (config.mode === 'development') {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tcode: `export default function() { return document.createElement('div'); }`,\n\t\t\t\t\t\t\tmap: null\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tthrow result.errors[0]\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\tcode: result.code,\n\t\t\t\t\tmap: null\n\t\t\t\t}\n\t\t\t} catch (e: any) {\n\t\t\t\twarn(`[fluxion] Failed to compile ${id}: ${e.message}`)\n\t\t\t\tthrow e\n\t\t\t}\n\t\t},\n\n\t\t/**\n\t\t * 处理 HMR\n\t\t */\n\t\thandleHotUpdate({ file, server }) {\n\t\t\tif (isNuiFile(file)) {\n\t\t\t\t// 触发完全重载\n\t\t\t\tserver.ws.send({\n\t\t\t\t\ttype: 'full-reload',\n\t\t\t\t\tpath: file\n\t\t\t\t})\n\t\t\t\treturn []\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport default fluxionPlugin"],"names":["fluxionPlugin","options","include","indentSize","config","isNuiFile","id","some","ext","endsWith","name","configResolved","resolvedConfig","enforce","transform","code","result","compile","filename","isBrowser","errors","length","error","warn","message","mode","map","e","handleHotUpdate","file","server","ws","send","type","path"],"mappings":"6FAwBO,SAASA,EAAcC,EAAgC,IAC7D,MAAMC,QAAEA,EAAU,CAAC,QAAMC,WAAGA,GAAeF,EAE3C,IAAIG,EAKJ,SAASC,EAAUC,GAClB,OAAOJ,EAAQK,KAAKC,GAAOF,EAAGG,SAASD,GACxC,CAEA,MAAO,CACNE,KAAM,UAEN,cAAAC,CAAeC,GACdR,EAASQ,CACV,EAMAC,QAAS,MAKT,SAAAC,CAAUC,EAAMT,GACf,IAAKD,EAAUC,GACd,OAAO,KAGR,IAEC,MAAMU,EAASC,EAAQF,EAAM,CAC5BG,SAAUZ,EACVa,WAAW,EACXhB,eAID,GAAIa,EAAOI,OAAOC,OAAS,EAAG,CAC7B,IAAA,MAAWC,KAASN,EAAOI,OAC1BG,EAAK,aAAajB,MAAOgB,EAAME,WAGhC,GAAoB,gBAAhBpB,EAAOqB,KACV,MAAO,CACNV,KAAM,sEACNW,IAAK,MAGP,MAAMV,EAAOI,OAAO,EACrB,CAEA,MAAO,CACNL,KAAMC,EAAOD,KACbW,IAAK,KAEP,OAASC,GAER,MADAJ,EAAK,+BAA+BjB,MAAOqB,EAAEH,WACvCG,CACP,CACD,EAKA,eAAAC,EAAgBC,KAAEA,EAAAC,OAAMA,IACvB,GAAIzB,EAAUwB,GAMb,OAJAC,EAAOC,GAAGC,KAAK,CACdC,KAAM,cACNC,KAAML,IAEA,EAET,EAEF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluxion-ui/vite-plugin-fluxion",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Vite plugin for Fluxion framework - compile .nui files",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/vite-plugin-fluxion.cjs",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"author": "Fluxion Team",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@fluxion-ui/compiler-nui": "0.0.
|
|
33
|
-
"@fluxion-ui/shared": "0.0.
|
|
32
|
+
"@fluxion-ui/compiler-nui": "0.0.4",
|
|
33
|
+
"@fluxion-ui/shared": "0.0.4"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
|