@vune-ui/compiler 0.1.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/dist/ast.d.ts +85 -0
- package/dist/ast.d.ts.map +1 -0
- package/dist/ast.js +531 -0
- package/dist/ast.js.map +1 -0
- package/dist/diagnostics.d.ts +3 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +178 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +40 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline.d.ts +3 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +1316 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/scanner.d.ts +54 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +678 -0
- package/dist/scanner.js.map +1 -0
- package/dist/semantic.d.ts +100 -0
- package/dist/semantic.d.ts.map +1 -0
- package/dist/semantic.js +692 -0
- package/dist/semantic.js.map +1 -0
- package/dist/source-map.d.ts +26 -0
- package/dist/source-map.d.ts.map +1 -0
- package/dist/source-map.js +196 -0
- package/dist/source-map.js.map +1 -0
- package/dist/specialization.d.ts +4 -0
- package/dist/specialization.d.ts.map +1 -0
- package/dist/specialization.js +233 -0
- package/dist/specialization.js.map +1 -0
- package/dist/types.d.ts +50 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/vite.d.ts +17 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +96 -0
- package/dist/vite.js.map +1 -0
- package/package.json +29 -0
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/vite.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { VuneTransformResult, VuneVitePluginOptions } from "./types.js";
|
|
2
|
+
export declare function createVuneVitePlugin(options?: VuneVitePluginOptions): {
|
|
3
|
+
name: string;
|
|
4
|
+
enforce: "pre";
|
|
5
|
+
config(): {
|
|
6
|
+
optimizeDeps: {
|
|
7
|
+
rolldownOptions: {
|
|
8
|
+
plugins: {
|
|
9
|
+
name: string;
|
|
10
|
+
transform: (source: string, id: string) => VuneTransformResult | null;
|
|
11
|
+
}[];
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
transform: (source: string, id: string) => VuneTransformResult | null;
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=vite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.d.ts","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAgC5E,wBAAgB,oBAAoB,CAAC,OAAO,GAAE,qBAA0B;;;;;;;;wCAE3C,MAAM,MAAM,MAAM,KAAG,mBAAmB,GAAG,IAAI;;;;;wBAA/C,MAAM,MAAM,MAAM,KAAG,mBAAmB,GAAG,IAAI;EAqD3E"}
|
package/dist/vite.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { createVuneSourceMap } from "./source-map.js";
|
|
2
|
+
import { hasVuneSyntax, transformVuneSource } from "./pipeline.js";
|
|
3
|
+
function isVuneVueScript(attributes) {
|
|
4
|
+
const language = /\blang\s*=\s*(["'])([^"']+)\1/i.exec(attributes)?.[2];
|
|
5
|
+
return !language || /^(?:vune|js|jsx|ts|tsx|mts|cts)$/i.test(language);
|
|
6
|
+
}
|
|
7
|
+
function isGeneratedVueScript(source) {
|
|
8
|
+
return /\b_defineComponent\(\{/.test(source)
|
|
9
|
+
&& /\bsetup\(__props(?:\s*,|\s*\))/.test(source)
|
|
10
|
+
&& /\b(?:_openBlock|_createBlock|_createElementBlock)\b/.test(source);
|
|
11
|
+
}
|
|
12
|
+
function transformVueSfcSource(source, fileName) {
|
|
13
|
+
const script = /<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi;
|
|
14
|
+
let output = source;
|
|
15
|
+
let changed = false;
|
|
16
|
+
let match;
|
|
17
|
+
while ((match = script.exec(source))) {
|
|
18
|
+
if (!isVuneVueScript(match[1]))
|
|
19
|
+
continue;
|
|
20
|
+
const language = /\blang\s*=\s*(["'])([^"']+)\1/i.exec(match[1])?.[2] ?? "ts";
|
|
21
|
+
if (!hasVuneSyntax(match[2], !/^(?:tsx|jsx)$/i.test(language)))
|
|
22
|
+
continue;
|
|
23
|
+
const transformed = transformVuneSource(match[2], `${fileName}#script`);
|
|
24
|
+
if (transformed === match[2])
|
|
25
|
+
continue;
|
|
26
|
+
const bodyStart = match.index + match[0].indexOf(match[2]);
|
|
27
|
+
const outputStart = bodyStart + (output.length - source.length);
|
|
28
|
+
output = output.slice(0, outputStart) + transformed + output.slice(outputStart + match[2].length);
|
|
29
|
+
changed = true;
|
|
30
|
+
}
|
|
31
|
+
return changed ? output : source;
|
|
32
|
+
}
|
|
33
|
+
export function createVuneVitePlugin(options = {}) {
|
|
34
|
+
const cache = new Map();
|
|
35
|
+
const transform = (source, id) => {
|
|
36
|
+
const fileName = id.split("?", 1)[0];
|
|
37
|
+
const query = id.slice(fileName.length + (id.includes("?") ? 1 : 0));
|
|
38
|
+
// Compiled workspace packages are already TypeScript output. Re-running
|
|
39
|
+
// Vune lowering over their JavaScript can mistake ordinary method calls
|
|
40
|
+
// for authoring syntax and corrupt otherwise valid module code.
|
|
41
|
+
if (/[\\/]node_modules[\\/]/.test(fileName) || /[\\/]dist[\\/]/.test(fileName))
|
|
42
|
+
return null;
|
|
43
|
+
const isVue = /\.vue$/i.test(fileName);
|
|
44
|
+
const isVueTemplate = isVue && /(?:^|&)type=template(?:&|$)/.test(query);
|
|
45
|
+
const isVueStyle = isVue && /(?:^|&)type=style(?:&|$)/.test(query);
|
|
46
|
+
const isVueScript = isVue && (/(?:^|&)type=script(?:&|$)/.test(query)
|
|
47
|
+
|| (!isVueTemplate && !isVueStyle && !/<(?:script|template)\b/i.test(source)));
|
|
48
|
+
if (!isVue && !/\.vune\.tsx?$/.test(fileName) && !/\.[cm]?[jt]sx?$/.test(fileName))
|
|
49
|
+
return null;
|
|
50
|
+
if (options.include) {
|
|
51
|
+
options.include.lastIndex = 0;
|
|
52
|
+
if (!options.include.test(fileName))
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
if (isVue && (isVueTemplate || isVueStyle))
|
|
56
|
+
return null;
|
|
57
|
+
if (isVueScript && isGeneratedVueScript(source))
|
|
58
|
+
return null;
|
|
59
|
+
const vueSource = isVue && !isVueScript
|
|
60
|
+
? transformVueSfcSource(source, fileName)
|
|
61
|
+
: source;
|
|
62
|
+
if (!isVue && !/\.vune\.tsx?$/.test(fileName) && !hasVuneSyntax(source, false))
|
|
63
|
+
return null;
|
|
64
|
+
if (isVue && vueSource === source && !isVueScript)
|
|
65
|
+
return null;
|
|
66
|
+
if (isVueScript && !hasVuneSyntax(source, !/(?:^|&)lang\.(?:tsx|jsx)(?:&|$)/.test(query)))
|
|
67
|
+
return null;
|
|
68
|
+
const cacheKey = isVue ? id : fileName;
|
|
69
|
+
const cached = cache.get(cacheKey);
|
|
70
|
+
if (cached?.source === source)
|
|
71
|
+
return cached.result;
|
|
72
|
+
const code = isVue && !isVueScript ? vueSource : transformVuneSource(source, fileName);
|
|
73
|
+
const transformed = code === source ? null : { code, map: createVuneSourceMap(source, code, fileName) };
|
|
74
|
+
cache.set(cacheKey, { source, result: transformed });
|
|
75
|
+
return transformed;
|
|
76
|
+
};
|
|
77
|
+
const dependencyScanPlugin = {
|
|
78
|
+
name: "vune-compiler:dependency-scan",
|
|
79
|
+
transform,
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
name: "vune-compiler",
|
|
83
|
+
enforce: "pre",
|
|
84
|
+
config() {
|
|
85
|
+
return {
|
|
86
|
+
optimizeDeps: {
|
|
87
|
+
rolldownOptions: {
|
|
88
|
+
plugins: [dependencyScanPlugin],
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
},
|
|
93
|
+
transform,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=vite.js.map
|
package/dist/vite.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAGlE,SAAS,eAAe,CAAC,UAAkB;IACzC,MAAM,QAAQ,GAAG,gCAAgC,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACvE,OAAO,CAAC,QAAQ,IAAI,mCAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AACxE,CAAC;AAED,SAAS,oBAAoB,CAAC,MAAc;IAC1C,OAAO,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC;WACvC,gCAAgC,CAAC,IAAI,CAAC,MAAM,CAAC;WAC7C,qDAAqD,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AACzE,CAAC;AAED,SAAS,qBAAqB,CAAC,MAAc,EAAE,QAAgB;IAC7D,MAAM,MAAM,GAAG,4CAA4C,CAAA;IAC3D,IAAI,MAAM,GAAG,MAAM,CAAA;IACnB,IAAI,OAAO,GAAG,KAAK,CAAA;IACnB,IAAI,KAA6B,CAAA;IACjC,OAAO,CAAC,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YAAE,SAAQ;QACxC,MAAM,QAAQ,GAAG,gCAAgC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ACL,IAAI,EAAE,eAAe;QACrB,OAAO,EAAE,KAAc;QACvB,MAAM;YACJ,OAAO;gBACL,YAAY,EAAE;oBACZ,eAAe,EAAE;wBACf,OAAO,EAAE,CAAC,oBAAoB,CAAC;qBAChC;iBACF;aACF,CAAA;QACH,CAAC;QACD,SAAS;KACV,CAAA;AACH,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vune-ui/compiler",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript-hosted compiler for Vune builder and .vune.ts syntax.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist"
|
|
8
|
+
],
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"check": "tsc -p tsconfig.json --noEmit"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@vune-ui/core": "workspace:*",
|
|
23
|
+
"typescript": "^5.8.3"
|
|
24
|
+
},
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|