@fluxion-ui/vite-plugin-fluxion 0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026-present, Fluxion Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +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 t;function u(e){return o.some(r=>e.endsWith(r))}return{name:"fluxion",configResolved(e){t=e},enforce:"pre",transform(n,o){if(!u(o))return null;try{const u=e.compile(n,{filename:o,isBrowser:!0});if(u.errors.length>0){for(const e of u.errors)r.warn(`[fluxion] ${o}: ${e.message}`);if("development"===t.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
+ //# sourceMappingURL=vite-plugin-fluxion.cjs.map
@@ -0,0 +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, NuiCompileResult } 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}\n\n/**\n * 创建 Fluxion Vite 插件\n */\nexport function fluxionPlugin(options: FluxionPluginOptions = {}): Plugin {\n\tconst { include = ['.nui'] } = 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})\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","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":"8IAsBO,SAASA,EAAcC,EAAgC,IAC7D,MAAMC,QAAEA,EAAU,CAAC,SAAYD,EAE/B,IAAIE,EAKJ,SAASC,EAAUC,GAClB,OAAOH,EAAQI,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,IAIZ,GAAIH,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"}
@@ -0,0 +1,22 @@
1
+ import { Plugin } from 'vite';
2
+
3
+ /**
4
+ * vite-plugin-fluxion
5
+ * Vite 插件,用于编译 .nui 文件
6
+ */
7
+
8
+ /**
9
+ * 插件选项
10
+ */
11
+ interface FluxionPluginOptions {
12
+ isProduction?: boolean;
13
+ include?: string[];
14
+ }
15
+ /**
16
+ * 创建 Fluxion Vite 插件
17
+ */
18
+ declare function fluxionPlugin(options?: FluxionPluginOptions): Plugin;
19
+
20
+ export { fluxionPlugin as default, fluxionPlugin };
21
+ export type { FluxionPluginOptions };
22
+ //# sourceMappingURL=vite-plugin-fluxion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-fluxion.d.ts","sources":[],"mappings":";;;;;;;;;;;;;;;;;;;;;","names":[]}
@@ -0,0 +1,2 @@
1
+ import{compile as e}from"@fluxion-ui/compiler-nui";import{warn as r}from"@fluxion-ui/shared";function o(o={}){const{include:n=[".nui"]}=o;let t;function i(e){return n.some(r=>e.endsWith(r))}return{name:"fluxion",configResolved(e){t=e},enforce:"pre",transform(o,n){if(!i(n))return null;try{const i=e(o,{filename:n,isBrowser:!0});if(i.errors.length>0){for(const e of i.errors)r(`[fluxion] ${n}: ${e.message}`);if("development"===t.mode)return{code:"export default function() { return document.createElement('div'); }",map:null};throw i.errors[0]}return{code:i.code,map:null}}catch(e){throw r(`[fluxion] Failed to compile ${n}: ${e.message}`),e}},handleHotUpdate({file:e,server:r}){if(i(e))return r.ws.send({type:"full-reload",path:e}),[]}}}export{o as default,o as fluxionPlugin};
2
+ //# sourceMappingURL=vite-plugin-fluxion.js.map
@@ -0,0 +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, NuiCompileResult } 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}\n\n/**\n * 创建 Fluxion Vite 插件\n */\nexport function fluxionPlugin(options: FluxionPluginOptions = {}): Plugin {\n\tconst { include = ['.nui'] } = 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})\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","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":"6FAsBO,SAASA,EAAcC,EAAgC,IAC7D,MAAMC,QAAEA,EAAU,CAAC,SAAYD,EAE/B,IAAIE,EAKJ,SAASC,EAAUC,GAClB,OAAOH,EAAQI,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,IAIZ,GAAIH,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 ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@fluxion-ui/vite-plugin-fluxion",
3
+ "version": "0.0.3",
4
+ "description": "Vite plugin for Fluxion framework - compile .nui files",
5
+ "type": "module",
6
+ "main": "./dist/vite-plugin-fluxion.cjs",
7
+ "module": "./dist/vite-plugin-fluxion.js",
8
+ "types": "./dist/vite-plugin-fluxion.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "import": "./dist/vite-plugin-fluxion.js",
12
+ "require": "./dist/vite-plugin-fluxion.cjs",
13
+ "types": "./dist/vite-plugin-fluxion.d.ts"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/AiFu-o/fluxion"
22
+ },
23
+ "keywords": [
24
+ "fluxion",
25
+ "vite",
26
+ "plugin",
27
+ "nui"
28
+ ],
29
+ "author": "Fluxion Team",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@fluxion-ui/compiler-nui": "0.0.3",
33
+ "@fluxion-ui/shared": "0.0.3"
34
+ },
35
+ "peerDependencies": {
36
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0"
37
+ },
38
+ "devDependencies": {
39
+ "vite": "^8.0.0"
40
+ }
41
+ }