glyphix 1.0.1 → 1.0.2

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.
Files changed (2) hide show
  1. package/glyphix.js +1 -1
  2. package/package.json +3 -4
package/glyphix.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var l=require("fs"),v=require("acorn"),o=require("path"),y=require("vite");var a="glyphix_virtual_import.js";var m=require("path");function f(u){return{name:"glyphix-resolve-id",resolveId(s){return s.startsWith("@system.")?{id:s,external:!0}:s.startsWith("/")?{id:`${u.rootPath}${s}`}:{id:s}},load(s){if(s===a)return u.virtualContent}}}function g(u){return{name:"generate-glyphix-bundle",generateBundle(s,i,t){for(let[e,r]of Object.entries(i))if(r.type==="chunk"&&(0,m.relative)(u.rootPath,r.facadeModuleId??"").includes(a)){delete i[e];return}}}}var I=require("crypto"),d=class{constructor(s){this.uxJsFiles=[];this.allEntries=[];this.thirdLibs=[];this.virtualImportContent="";this.rootPath="";this.uxJsFiles=s.source,this.rootPath=s.root}startBuild(){this.uxJsFiles=this.uxJsFiles.map(t=>(0,o.resolve)(this.rootPath,t)),this.uxJsFiles.map((t,e)=>{let r=`$${(0,I.randomUUID)().toString().replaceAll("-","")}`;return this.virtualImportContent+=`import ${r} from "${t}";`,r}).forEach(t=>{this.virtualImportContent+=`console.log(${t});`}),this.uxJsFiles.push(a),this.uxJsFiles.forEach(t=>{if(t===a){this.allEntries.push(t);return}let e=this.parseFileFilterImport(t),r=this.parseModuleEntry(t,e);this.allEntries.push(t),this.allEntries.push(...r)});let i=this.generateViteOption(this.allEntries);(0,y.build)(i)}parseFileFilterImport(s){let i=(0,l.readFileSync)(s).toString(),t=(0,v.parse)(i,{ecmaVersion:2020,sourceType:"module"});return!t||!t.body||!t.body.length?[]:t.body.map(r=>r.type==="ImportDeclaration"?r.source.value:"").filter(r=>r.length&&!r.startsWith("@system.")).map(r=>r.startsWith("/")?(0,o.resolve)(this.rootPath,r):r.startsWith(".")?(0,o.resolve)(s,"..",r):r)}parseModuleEntry(s,i){let t=[];return i.forEach(e=>{if(e===a)return;if(!e.includes("node_modules")&&e.startsWith("/")){t.push(`${this.rootPath}${e}`);return}if(e.startsWith(".")){t.push((0,o.resolve)(s,"..",e));return}let r=require.resolve(e),n=(0,o.dirname)(r);for(;!(0,l.existsSync)((0,o.resolve)(n,"package.json"));)if(n=(0,o.dirname)(n),n===process.cwd())throw Error(`not find module ${e}`);this.thirdLibs.push(e);let h=(0,o.resolve)(n,"package.json"),p=require(h);r=p.module||p.main}),t}generateViteOption(s){return{plugins:[f({rootPath:this.rootPath,virtualContent:this.virtualImportContent}),g({rootPath:this.rootPath})],build:{minify:!0,target:"node20",rollupOptions:{treeshake:!0,input:s,preserveEntrySignatures:"strict",output:{format:"es",dir:(0,o.resolve)(this.rootPath,".vite-dist"),entryFileNames:t=>{let e=(0,o.relative)(this.rootPath,t.facadeModuleId);return this.uxJsFiles.findIndex(r=>r.includes(e))>=0&&!e.startsWith(".")?e:"[name]-[hash].js"},chunkFileNames:t=>{let r=t.moduleIds[t.moduleIds.length-1].split("/"),n=t.name;return r.forEach((h,p)=>{h==="node_modules"&&(n=r[p+1])}),`${n}-[hash].js`},manualChunks:{vendor:this.thirdLibs}}},sourcemap:!1}}}},c=process.env.VITE_BUILD_DIR;if(!c)throw Error("not find env VITE_BUILD_DIR");var x=JSON.parse((0,l.readFileSync)((0,o.resolve)(c,"entry.vite.json")).toString()),P=new d({root:c,source:x.entry});P.startBuild();
2
+ "use strict";var d=Object.create;var p=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var h=Object.getPrototypeOf,f=Object.prototype.hasOwnProperty;var x=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of c(t))!f.call(e,r)&&r!==i&&p(e,r,{get:()=>t[r],enumerable:!(n=u(t,r))||n.enumerable});return e};var g=(e,t,i)=>(i=e!=null?d(h(e)):{},x(t||!e||!e.__esModule?p(i,"default",{value:e,enumerable:!0}):i,e));var a=g(require("esbuild")),o=require("path"),l=require("fs"),m=require("fs-extra"),s=(0,o.resolve)(__dirname,"../app/com.example.app"),y=["app.js","pages/main/index.js","pages/setting/index.js"];(0,m.removeSync)((0,o.resolve)(s,".dist"));a.default.build({entryPoints:y.map(e=>(0,o.resolve)(s,e)),bundle:!0,outdir:(0,o.resolve)(s,".dist"),splitting:!0,format:"esm",external:["@system*"],target:"esnext",plugins:[{name:"glyphix-resolv-path",setup(e){e.onResolve({filter:/^\//},t=>({path:(0,l.existsSync)(t.path)?t.path:(0,o.join)(s,t.path)}))}}]}).then(()=>{console.log("Build completed!")}).catch(e=>{console.error("Build failed:",e)});
package/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "glyphix",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "license": "MIT",
5
5
  "main": "lib/index.js",
6
6
  "bin": {
7
7
  "glyphix": "./glyphix.js"
8
8
  },
9
9
  "dependencies": {
10
- "acorn": "^8.14.0",
11
- "rollup": "^3.10.0",
12
- "vite": "^6.0.6"
10
+ "esbuild": "^0.24.2",
11
+ "fs-extra": "^11.2.0"
13
12
  }
14
13
  }