vue-jsx-vapor 2.3.0 → 2.3.1
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/api.cjs +2 -5
- package/dist/api.d.cts +6 -7
- package/dist/api.d.ts +6 -7
- package/dist/api.js +3 -6
- package/dist/astro.cjs +14 -18
- package/dist/astro.d.cts +4 -5
- package/dist/astro.d.ts +4 -5
- package/dist/astro.js +13 -17
- package/dist/chunk-BCwAaXi7.cjs +31 -0
- package/dist/core-B29W1zp3.cjs +32 -0
- package/dist/core-BDE4GLH8.js +25 -0
- package/dist/esbuild.cjs +12 -14
- package/dist/esbuild.d.cts +6 -7
- package/dist/esbuild.d.ts +6 -7
- package/dist/esbuild.js +8 -10
- package/dist/index.cjs +66 -78
- package/dist/index.d.cts +4 -3
- package/dist/index.d.ts +4 -3
- package/dist/index.js +59 -80
- package/dist/jsx-runtime.cjs +14 -13
- package/dist/jsx-runtime.d.cts +24 -23
- package/dist/jsx-runtime.d.ts +24 -23
- package/dist/jsx-runtime.js +9 -13
- package/dist/nuxt.cjs +23 -26
- package/dist/nuxt.d.cts +6 -7
- package/dist/nuxt.d.ts +6 -7
- package/dist/nuxt.js +19 -23
- package/dist/options-HYvLzmlg.js +0 -0
- package/dist/options.cjs +1 -1
- package/dist/options.d-BAyccQwr.d.ts +20 -0
- package/dist/options.d-CA70vgwp.d.cts +20 -0
- package/dist/options.d.cts +2 -17
- package/dist/options.d.ts +2 -17
- package/dist/options.js +1 -1
- package/dist/raw-C8eD8f6a.js +214 -0
- package/dist/raw-Dr3UcxgN.cjs +221 -0
- package/dist/raw.cjs +4 -8
- package/dist/raw.d.cts +5 -6
- package/dist/raw.d.ts +5 -6
- package/dist/raw.js +4 -7
- package/dist/rolldown.cjs +14 -15
- package/dist/rolldown.d.cts +6 -7
- package/dist/rolldown.d.ts +6 -7
- package/dist/rolldown.js +9 -11
- package/dist/rollup.cjs +12 -14
- package/dist/rollup.d.cts +6 -7
- package/dist/rollup.d.ts +6 -7
- package/dist/rollup.js +8 -10
- package/dist/rspack.cjs +12 -14
- package/dist/rspack.d.cts +4 -5
- package/dist/rspack.d.ts +4 -5
- package/dist/rspack.js +8 -10
- package/dist/unplugin-BMMTjSOs.js +32 -0
- package/dist/unplugin-ChZxAtQ0.cjs +51 -0
- package/dist/unplugin.cjs +9 -13
- package/dist/unplugin.d.cts +6 -8
- package/dist/unplugin.d.ts +6 -8
- package/dist/unplugin.js +6 -13
- package/dist/vite-BSUI3W42.js +7 -0
- package/dist/vite-D_zoULH4.cjs +13 -0
- package/dist/vite.cjs +8 -12
- package/dist/vite.d.cts +6 -7
- package/dist/vite.d.ts +6 -7
- package/dist/vite.js +7 -10
- package/dist/volar.cjs +18 -18
- package/dist/volar.d.cts +5 -6
- package/dist/volar.d.ts +5 -6
- package/dist/volar.js +12 -13
- package/dist/webpack-BXmoWpIv.cjs +13 -0
- package/dist/webpack-CeYJ9dJv.js +7 -0
- package/dist/webpack.cjs +8 -12
- package/dist/webpack.d.cts +6 -7
- package/dist/webpack.d.ts +6 -7
- package/dist/webpack.js +7 -10
- package/package.json +6 -6
- package/dist/chunk-4HP6QVER.js +0 -10
- package/dist/chunk-F7CI4ATH.cjs +0 -43
- package/dist/chunk-G2KD2VHX.js +0 -43
- package/dist/chunk-GODVM7NB.cjs +0 -1
- package/dist/chunk-GY6DSRCV.cjs +0 -22
- package/dist/chunk-HNBQ42EP.js +0 -10
- package/dist/chunk-M4VKLZSB.cjs +0 -10
- package/dist/chunk-QBIU4H54.cjs +0 -10
- package/dist/chunk-SAJ6WS2A.js +0 -22
- package/dist/chunk-T3F6TYMY.js +0 -265
- package/dist/chunk-VSS2IZIS.cjs +0 -265
- /package/dist/{chunk-JNAGPWSX.js → options-CulFO0WS.cjs} +0 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
import { transformVueJsxVapor } from "./core-BDE4GLH8.js";
|
|
2
|
+
import { transformSync } from "@babel/core";
|
|
3
|
+
import babelTypescript from "@babel/plugin-transform-typescript";
|
|
4
|
+
import macros from "@vue-jsx-vapor/macros/raw";
|
|
5
|
+
import { transformJsxDirective } from "@vue-macros/jsx-directive/api";
|
|
6
|
+
import { createFilter, normalizePath } from "unplugin-utils";
|
|
7
|
+
import { isFunctionalNode } from "@vue-jsx-vapor/macros/api";
|
|
8
|
+
import getHash from "hash-sum";
|
|
9
|
+
import { relative } from "pathe";
|
|
10
|
+
import jsx from "@vue/babel-plugin-jsx";
|
|
11
|
+
|
|
12
|
+
//#region src/core/ssr.ts
|
|
13
|
+
const ssrRegisterHelperId = "/__vue-jsx-ssr-register-helper";
|
|
14
|
+
const ssrRegisterHelperCode = `import { useSSRContext } from "vue"\nexport const ssrRegisterHelper = ${ssrRegisterHelper.toString()}`;
|
|
15
|
+
/**
|
|
16
|
+
* This function is serialized with toString() and evaluated as a virtual
|
|
17
|
+
* module during SSR
|
|
18
|
+
*/
|
|
19
|
+
function ssrRegisterHelper(comp, filename) {
|
|
20
|
+
const setup = comp.setup;
|
|
21
|
+
comp.setup = (props, ctx) => {
|
|
22
|
+
const ssrContext = useSSRContext();
|
|
23
|
+
(ssrContext.modules || (ssrContext.modules = new Set())).add(filename);
|
|
24
|
+
if (setup) return setup(props, ctx);
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function injectSSR(id, hotComponents, root = "") {
|
|
28
|
+
const normalizedId = normalizePath(relative(root, id));
|
|
29
|
+
let ssrInjectCode = `\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"\nconst __moduleId = ${JSON.stringify(normalizedId)}`;
|
|
30
|
+
for (const { local } of hotComponents) ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)`;
|
|
31
|
+
return ssrInjectCode;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
//#region src/core/hmr.ts
|
|
36
|
+
function injectHMRAndSSR(result, id, options) {
|
|
37
|
+
const ssr = options?.ssr;
|
|
38
|
+
const defineComponentNames = options?.defineComponentNames ?? ["defineComponent", "defineVaporComponent"];
|
|
39
|
+
const { ast } = result;
|
|
40
|
+
const declaredComponents = [];
|
|
41
|
+
const hotComponents = [];
|
|
42
|
+
let hasDefaultExport = false;
|
|
43
|
+
for (const node of ast.program.body) {
|
|
44
|
+
if (node.type === "VariableDeclaration") {
|
|
45
|
+
const names = parseComponentDecls(node, defineComponentNames);
|
|
46
|
+
if (names.length) declaredComponents.push(...names);
|
|
47
|
+
}
|
|
48
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
49
|
+
if (node.declaration && node.declaration.type === "VariableDeclaration") hotComponents.push(...parseComponentDecls(node.declaration, defineComponentNames).map((name) => ({
|
|
50
|
+
local: name,
|
|
51
|
+
exported: name,
|
|
52
|
+
id: getHash(id + name)
|
|
53
|
+
})));
|
|
54
|
+
else if (node.specifiers.length) {
|
|
55
|
+
for (const spec of node.specifiers) if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") {
|
|
56
|
+
const matched = declaredComponents.find((name) => name === spec.local.name);
|
|
57
|
+
if (matched) hotComponents.push({
|
|
58
|
+
local: spec.local.name,
|
|
59
|
+
exported: spec.exported.name,
|
|
60
|
+
id: getHash(id + spec.exported.name)
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
66
|
+
if (node.declaration.type === "Identifier") {
|
|
67
|
+
const _name = node.declaration.name;
|
|
68
|
+
const matched = declaredComponents.find((name) => name === _name);
|
|
69
|
+
if (matched) hotComponents.push({
|
|
70
|
+
local: _name,
|
|
71
|
+
exported: "default",
|
|
72
|
+
id: getHash(`${id}default`)
|
|
73
|
+
});
|
|
74
|
+
} else if (isDefineComponentCall(node.declaration, defineComponentNames) || isFunctionalNode(node.declaration)) {
|
|
75
|
+
hasDefaultExport = true;
|
|
76
|
+
hotComponents.push({
|
|
77
|
+
local: "__default__",
|
|
78
|
+
exported: "default",
|
|
79
|
+
id: getHash(`${id}default`)
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (hotComponents.length) {
|
|
85
|
+
if (hasDefaultExport || ssr) result.code = `${result.code.replaceAll(`export default `, `const __default__ = `)}\nexport default __default__`;
|
|
86
|
+
if (!ssr && !/\?vue&type=script/.test(id)) {
|
|
87
|
+
let code = result.code;
|
|
88
|
+
let callbackCode = ``;
|
|
89
|
+
for (const { local, exported, id: id$1 } of hotComponents) {
|
|
90
|
+
code += `\n${local}.__hmrId = "${id$1}"\n__VUE_HMR_RUNTIME__.createRecord("${id$1}", ${local})`;
|
|
91
|
+
callbackCode += `
|
|
92
|
+
__VUE_HMR_RUNTIME__.rerender(mod['${exported}'].__hmrId, mod['${exported}'].setup || mod['${exported}'])`;
|
|
93
|
+
}
|
|
94
|
+
code += `
|
|
95
|
+
if (import.meta.hot) {
|
|
96
|
+
import.meta.hot.accept((mod) => {${callbackCode}\n})
|
|
97
|
+
}`;
|
|
98
|
+
result.code = code;
|
|
99
|
+
}
|
|
100
|
+
if (ssr) result.code += injectSSR(id, hotComponents, options?.root);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function parseComponentDecls(node, fnNames) {
|
|
104
|
+
const names = [];
|
|
105
|
+
for (const decl of node.declarations) if (decl.id.type === "Identifier" && (isDefineComponentCall(decl.init, fnNames) || isFunctionalNode(decl.init))) names.push(decl.id.name);
|
|
106
|
+
return names;
|
|
107
|
+
}
|
|
108
|
+
function isDefineComponentCall(node, names) {
|
|
109
|
+
return !!(node && node.type === "CallExpression" && node.callee.type === "Identifier" && names.includes(node.callee.name));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/core/runtime.ts?raw
|
|
114
|
+
var runtime_default = "import {\n effectScope,\n insert,\n isFragment,\n remove,\n renderEffect,\n VaporFragment\n} from \"vue\";\nexport { shallowRef as useRef } from \"vue\";\nfunction createFragment(nodes, anchor = document.createTextNode(\"\")) {\n const frag = new VaporFragment(nodes);\n frag.anchor = anchor;\n return frag;\n}\nfunction normalizeValue(value, anchor) {\n if (value instanceof Node || isFragment(value)) {\n anchor && (anchor.textContent = \"\");\n return value;\n } else if (Array.isArray(value)) {\n anchor && (anchor.textContent = \"\");\n return createFragment(\n value.map((i) => normalizeValue(i)),\n anchor\n );\n } else {\n const result = value == null || typeof value === \"boolean\" ? \"\" : String(value);\n if (anchor) {\n anchor.textContent = result;\n return anchor;\n } else {\n return document.createTextNode(result);\n }\n }\n}\nfunction resolveValue(current, value, anchor) {\n const node = normalizeValue(value, anchor);\n if (current) {\n if (isFragment(current)) {\n const { anchor: anchor2 } = current;\n if (anchor2 && anchor2.parentNode) {\n remove(current.nodes, anchor2.parentNode);\n insert(node, anchor2.parentNode, anchor2);\n anchor2.remove();\n }\n } else if (current instanceof Node) {\n if (isFragment(node) && current.parentNode) {\n insert(node, current.parentNode, current);\n current.remove();\n } else if (node instanceof Node) {\n if (current.nodeType === 3 && node.nodeType === 3) {\n current.textContent = node.textContent;\n return current;\n } else if (current.parentNode) {\n current.parentNode.replaceChild(node, current);\n }\n }\n }\n }\n return node;\n}\nfunction resolveValues(values = [], _anchor) {\n const nodes = [];\n const scopes = [];\n for (const [index, value] of values.entries()) {\n const anchor = index === values.length - 1 ? _anchor : void 0;\n if (typeof value === \"function\") {\n renderEffect(() => {\n if (scopes[index]) scopes[index].stop();\n scopes[index] = effectScope();\n nodes[index] = scopes[index].run(\n () => resolveValue(nodes[index], value(), anchor)\n );\n });\n } else {\n nodes[index] = resolveValue(nodes[index], value, anchor);\n }\n }\n return nodes;\n}\nexport function setNodes(anchor, ...values) {\n const resolvedValues = resolveValues(values, anchor);\n anchor.parentNode && insert(resolvedValues, anchor.parentNode, anchor);\n}\nexport function createNodes(...values) {\n return resolveValues(values);\n}\n";
|
|
115
|
+
|
|
116
|
+
//#endregion
|
|
117
|
+
//#region src/core/vue-jsx.ts
|
|
118
|
+
function transformVueJsx(code, id, needSourceMap = false) {
|
|
119
|
+
const result = transformSync(code, {
|
|
120
|
+
plugins: [jsx, ...id.endsWith(".tsx") ? [[babelTypescript, {
|
|
121
|
+
isTSX: true,
|
|
122
|
+
allowExtensions: true
|
|
123
|
+
}]] : []],
|
|
124
|
+
filename: id,
|
|
125
|
+
sourceMaps: needSourceMap,
|
|
126
|
+
sourceFileName: id,
|
|
127
|
+
babelrc: false,
|
|
128
|
+
configFile: false
|
|
129
|
+
});
|
|
130
|
+
if (result?.code) return {
|
|
131
|
+
code: result.code,
|
|
132
|
+
map: result.map
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region src/raw.ts
|
|
138
|
+
const plugin = (options = {}) => {
|
|
139
|
+
const transformInclude = createFilter(options?.include || /\.[cm]?[jt]sx$/, options?.exclude || /node_modules/);
|
|
140
|
+
let root = "";
|
|
141
|
+
let needHMR = false;
|
|
142
|
+
let needSourceMap = false;
|
|
143
|
+
return [
|
|
144
|
+
{
|
|
145
|
+
name: "vue-jsx-vapor",
|
|
146
|
+
vite: {
|
|
147
|
+
config(config) {
|
|
148
|
+
return {
|
|
149
|
+
esbuild: { include: /\.ts$/ },
|
|
150
|
+
define: {
|
|
151
|
+
__VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
|
|
152
|
+
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false,
|
|
153
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ ?? false
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
configResolved(config) {
|
|
158
|
+
root = config.root;
|
|
159
|
+
needHMR = config.command === "serve";
|
|
160
|
+
needSourceMap = config.command === "serve" || !!config.build.sourcemap;
|
|
161
|
+
}
|
|
162
|
+
},
|
|
163
|
+
resolveId(id) {
|
|
164
|
+
if (id === ssrRegisterHelperId) return id;
|
|
165
|
+
if (normalizePath(id) === "vue-jsx-vapor/runtime") return id;
|
|
166
|
+
},
|
|
167
|
+
loadInclude(id) {
|
|
168
|
+
if (id === ssrRegisterHelperId) return true;
|
|
169
|
+
return normalizePath(id) === "vue-jsx-vapor/runtime";
|
|
170
|
+
},
|
|
171
|
+
load(id) {
|
|
172
|
+
if (id === ssrRegisterHelperId) return ssrRegisterHelperCode;
|
|
173
|
+
if (normalizePath(id) === "vue-jsx-vapor/runtime") return runtime_default;
|
|
174
|
+
},
|
|
175
|
+
transformInclude,
|
|
176
|
+
transform(code, id, opt) {
|
|
177
|
+
const result = transformVueJsxVapor(code, id, options, needSourceMap);
|
|
178
|
+
if (result?.code) {
|
|
179
|
+
(needHMR || opt?.ssr) && injectHMRAndSSR(result, id, {
|
|
180
|
+
ssr: opt?.ssr,
|
|
181
|
+
root
|
|
182
|
+
});
|
|
183
|
+
return {
|
|
184
|
+
code: result.code,
|
|
185
|
+
map: result.map
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: "@vue-macros/jsx-directive",
|
|
192
|
+
transformInclude,
|
|
193
|
+
transform(code, id, opt) {
|
|
194
|
+
if (options.interop || opt?.ssr) return transformJsxDirective(code, id, {
|
|
195
|
+
lib: "vue",
|
|
196
|
+
prefix: "v-",
|
|
197
|
+
version: 3.6
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
name: "@vitejs/plugin-vue-jsx",
|
|
203
|
+
transformInclude,
|
|
204
|
+
transform(code, id, opt) {
|
|
205
|
+
if (options.interop || opt?.ssr) return transformVueJsx(code, id, needSourceMap);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
...options.macros === false ? [] : options.macros ? [macros(options.macros === true ? void 0 : options.macros)] : []
|
|
209
|
+
];
|
|
210
|
+
};
|
|
211
|
+
var raw_default = plugin;
|
|
212
|
+
|
|
213
|
+
//#endregion
|
|
214
|
+
export { raw_default };
|
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const require_chunk = require('./chunk-BCwAaXi7.cjs');
|
|
3
|
+
const require_core = require('./core-B29W1zp3.cjs');
|
|
4
|
+
const __babel_core = require_chunk.__toESM(require("@babel/core"));
|
|
5
|
+
const __babel_plugin_transform_typescript = require_chunk.__toESM(require("@babel/plugin-transform-typescript"));
|
|
6
|
+
const __vue_jsx_vapor_macros_raw = require_chunk.__toESM(require("@vue-jsx-vapor/macros/raw"));
|
|
7
|
+
const __vue_macros_jsx_directive_api = require_chunk.__toESM(require("@vue-macros/jsx-directive/api"));
|
|
8
|
+
const unplugin_utils = require_chunk.__toESM(require("unplugin-utils"));
|
|
9
|
+
const __vue_jsx_vapor_macros_api = require_chunk.__toESM(require("@vue-jsx-vapor/macros/api"));
|
|
10
|
+
const hash_sum = require_chunk.__toESM(require("hash-sum"));
|
|
11
|
+
const pathe = require_chunk.__toESM(require("pathe"));
|
|
12
|
+
const __vue_babel_plugin_jsx = require_chunk.__toESM(require("@vue/babel-plugin-jsx"));
|
|
13
|
+
|
|
14
|
+
//#region src/core/ssr.ts
|
|
15
|
+
const ssrRegisterHelperId = "/__vue-jsx-ssr-register-helper";
|
|
16
|
+
const ssrRegisterHelperCode = `import { useSSRContext } from "vue"\nexport const ssrRegisterHelper = ${ssrRegisterHelper.toString()}`;
|
|
17
|
+
/**
|
|
18
|
+
* This function is serialized with toString() and evaluated as a virtual
|
|
19
|
+
* module during SSR
|
|
20
|
+
*/
|
|
21
|
+
function ssrRegisterHelper(comp, filename) {
|
|
22
|
+
const setup = comp.setup;
|
|
23
|
+
comp.setup = (props, ctx) => {
|
|
24
|
+
const ssrContext = useSSRContext();
|
|
25
|
+
(ssrContext.modules || (ssrContext.modules = new Set())).add(filename);
|
|
26
|
+
if (setup) return setup(props, ctx);
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function injectSSR(id, hotComponents, root = "") {
|
|
30
|
+
const normalizedId = (0, unplugin_utils.normalizePath)((0, pathe.relative)(root, id));
|
|
31
|
+
let ssrInjectCode = `\nimport { ssrRegisterHelper } from "${ssrRegisterHelperId}"\nconst __moduleId = ${JSON.stringify(normalizedId)}`;
|
|
32
|
+
for (const { local } of hotComponents) ssrInjectCode += `\nssrRegisterHelper(${local}, __moduleId)`;
|
|
33
|
+
return ssrInjectCode;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/core/hmr.ts
|
|
38
|
+
function injectHMRAndSSR(result, id, options) {
|
|
39
|
+
const ssr = options?.ssr;
|
|
40
|
+
const defineComponentNames = options?.defineComponentNames ?? ["defineComponent", "defineVaporComponent"];
|
|
41
|
+
const { ast } = result;
|
|
42
|
+
const declaredComponents = [];
|
|
43
|
+
const hotComponents = [];
|
|
44
|
+
let hasDefaultExport = false;
|
|
45
|
+
for (const node of ast.program.body) {
|
|
46
|
+
if (node.type === "VariableDeclaration") {
|
|
47
|
+
const names = parseComponentDecls(node, defineComponentNames);
|
|
48
|
+
if (names.length) declaredComponents.push(...names);
|
|
49
|
+
}
|
|
50
|
+
if (node.type === "ExportNamedDeclaration") {
|
|
51
|
+
if (node.declaration && node.declaration.type === "VariableDeclaration") hotComponents.push(...parseComponentDecls(node.declaration, defineComponentNames).map((name) => ({
|
|
52
|
+
local: name,
|
|
53
|
+
exported: name,
|
|
54
|
+
id: (0, hash_sum.default)(id + name)
|
|
55
|
+
})));
|
|
56
|
+
else if (node.specifiers.length) {
|
|
57
|
+
for (const spec of node.specifiers) if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") {
|
|
58
|
+
const matched = declaredComponents.find((name) => name === spec.local.name);
|
|
59
|
+
if (matched) hotComponents.push({
|
|
60
|
+
local: spec.local.name,
|
|
61
|
+
exported: spec.exported.name,
|
|
62
|
+
id: (0, hash_sum.default)(id + spec.exported.name)
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (node.type === "ExportDefaultDeclaration") {
|
|
68
|
+
if (node.declaration.type === "Identifier") {
|
|
69
|
+
const _name = node.declaration.name;
|
|
70
|
+
const matched = declaredComponents.find((name) => name === _name);
|
|
71
|
+
if (matched) hotComponents.push({
|
|
72
|
+
local: _name,
|
|
73
|
+
exported: "default",
|
|
74
|
+
id: (0, hash_sum.default)(`${id}default`)
|
|
75
|
+
});
|
|
76
|
+
} else if (isDefineComponentCall(node.declaration, defineComponentNames) || (0, __vue_jsx_vapor_macros_api.isFunctionalNode)(node.declaration)) {
|
|
77
|
+
hasDefaultExport = true;
|
|
78
|
+
hotComponents.push({
|
|
79
|
+
local: "__default__",
|
|
80
|
+
exported: "default",
|
|
81
|
+
id: (0, hash_sum.default)(`${id}default`)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (hotComponents.length) {
|
|
87
|
+
if (hasDefaultExport || ssr) result.code = `${result.code.replaceAll(`export default `, `const __default__ = `)}\nexport default __default__`;
|
|
88
|
+
if (!ssr && !/\?vue&type=script/.test(id)) {
|
|
89
|
+
let code = result.code;
|
|
90
|
+
let callbackCode = ``;
|
|
91
|
+
for (const { local, exported, id: id$1 } of hotComponents) {
|
|
92
|
+
code += `\n${local}.__hmrId = "${id$1}"\n__VUE_HMR_RUNTIME__.createRecord("${id$1}", ${local})`;
|
|
93
|
+
callbackCode += `
|
|
94
|
+
__VUE_HMR_RUNTIME__.rerender(mod['${exported}'].__hmrId, mod['${exported}'].setup || mod['${exported}'])`;
|
|
95
|
+
}
|
|
96
|
+
code += `
|
|
97
|
+
if (import.meta.hot) {
|
|
98
|
+
import.meta.hot.accept((mod) => {${callbackCode}\n})
|
|
99
|
+
}`;
|
|
100
|
+
result.code = code;
|
|
101
|
+
}
|
|
102
|
+
if (ssr) result.code += injectSSR(id, hotComponents, options?.root);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function parseComponentDecls(node, fnNames) {
|
|
106
|
+
const names = [];
|
|
107
|
+
for (const decl of node.declarations) if (decl.id.type === "Identifier" && (isDefineComponentCall(decl.init, fnNames) || (0, __vue_jsx_vapor_macros_api.isFunctionalNode)(decl.init))) names.push(decl.id.name);
|
|
108
|
+
return names;
|
|
109
|
+
}
|
|
110
|
+
function isDefineComponentCall(node, names) {
|
|
111
|
+
return !!(node && node.type === "CallExpression" && node.callee.type === "Identifier" && names.includes(node.callee.name));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//#endregion
|
|
115
|
+
//#region src/core/runtime.ts?raw
|
|
116
|
+
var runtime_default = "import {\n effectScope,\n insert,\n isFragment,\n remove,\n renderEffect,\n VaporFragment\n} from \"vue\";\nexport { shallowRef as useRef } from \"vue\";\nfunction createFragment(nodes, anchor = document.createTextNode(\"\")) {\n const frag = new VaporFragment(nodes);\n frag.anchor = anchor;\n return frag;\n}\nfunction normalizeValue(value, anchor) {\n if (value instanceof Node || isFragment(value)) {\n anchor && (anchor.textContent = \"\");\n return value;\n } else if (Array.isArray(value)) {\n anchor && (anchor.textContent = \"\");\n return createFragment(\n value.map((i) => normalizeValue(i)),\n anchor\n );\n } else {\n const result = value == null || typeof value === \"boolean\" ? \"\" : String(value);\n if (anchor) {\n anchor.textContent = result;\n return anchor;\n } else {\n return document.createTextNode(result);\n }\n }\n}\nfunction resolveValue(current, value, anchor) {\n const node = normalizeValue(value, anchor);\n if (current) {\n if (isFragment(current)) {\n const { anchor: anchor2 } = current;\n if (anchor2 && anchor2.parentNode) {\n remove(current.nodes, anchor2.parentNode);\n insert(node, anchor2.parentNode, anchor2);\n anchor2.remove();\n }\n } else if (current instanceof Node) {\n if (isFragment(node) && current.parentNode) {\n insert(node, current.parentNode, current);\n current.remove();\n } else if (node instanceof Node) {\n if (current.nodeType === 3 && node.nodeType === 3) {\n current.textContent = node.textContent;\n return current;\n } else if (current.parentNode) {\n current.parentNode.replaceChild(node, current);\n }\n }\n }\n }\n return node;\n}\nfunction resolveValues(values = [], _anchor) {\n const nodes = [];\n const scopes = [];\n for (const [index, value] of values.entries()) {\n const anchor = index === values.length - 1 ? _anchor : void 0;\n if (typeof value === \"function\") {\n renderEffect(() => {\n if (scopes[index]) scopes[index].stop();\n scopes[index] = effectScope();\n nodes[index] = scopes[index].run(\n () => resolveValue(nodes[index], value(), anchor)\n );\n });\n } else {\n nodes[index] = resolveValue(nodes[index], value, anchor);\n }\n }\n return nodes;\n}\nexport function setNodes(anchor, ...values) {\n const resolvedValues = resolveValues(values, anchor);\n anchor.parentNode && insert(resolvedValues, anchor.parentNode, anchor);\n}\nexport function createNodes(...values) {\n return resolveValues(values);\n}\n";
|
|
117
|
+
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/core/vue-jsx.ts
|
|
120
|
+
function transformVueJsx(code, id, needSourceMap = false) {
|
|
121
|
+
const result = (0, __babel_core.transformSync)(code, {
|
|
122
|
+
plugins: [__vue_babel_plugin_jsx.default, ...id.endsWith(".tsx") ? [[__babel_plugin_transform_typescript.default, {
|
|
123
|
+
isTSX: true,
|
|
124
|
+
allowExtensions: true
|
|
125
|
+
}]] : []],
|
|
126
|
+
filename: id,
|
|
127
|
+
sourceMaps: needSourceMap,
|
|
128
|
+
sourceFileName: id,
|
|
129
|
+
babelrc: false,
|
|
130
|
+
configFile: false
|
|
131
|
+
});
|
|
132
|
+
if (result?.code) return {
|
|
133
|
+
code: result.code,
|
|
134
|
+
map: result.map
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
//#endregion
|
|
139
|
+
//#region src/raw.ts
|
|
140
|
+
const plugin = (options = {}) => {
|
|
141
|
+
const transformInclude = (0, unplugin_utils.createFilter)(options?.include || /\.[cm]?[jt]sx$/, options?.exclude || /node_modules/);
|
|
142
|
+
let root = "";
|
|
143
|
+
let needHMR = false;
|
|
144
|
+
let needSourceMap = false;
|
|
145
|
+
return [
|
|
146
|
+
{
|
|
147
|
+
name: "vue-jsx-vapor",
|
|
148
|
+
vite: {
|
|
149
|
+
config(config) {
|
|
150
|
+
return {
|
|
151
|
+
esbuild: { include: /\.ts$/ },
|
|
152
|
+
define: {
|
|
153
|
+
__VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
|
|
154
|
+
__VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false,
|
|
155
|
+
__VUE_PROD_HYDRATION_MISMATCH_DETAILS__: config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ ?? false
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
configResolved(config) {
|
|
160
|
+
root = config.root;
|
|
161
|
+
needHMR = config.command === "serve";
|
|
162
|
+
needSourceMap = config.command === "serve" || !!config.build.sourcemap;
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
resolveId(id) {
|
|
166
|
+
if (id === ssrRegisterHelperId) return id;
|
|
167
|
+
if ((0, unplugin_utils.normalizePath)(id) === "vue-jsx-vapor/runtime") return id;
|
|
168
|
+
},
|
|
169
|
+
loadInclude(id) {
|
|
170
|
+
if (id === ssrRegisterHelperId) return true;
|
|
171
|
+
return (0, unplugin_utils.normalizePath)(id) === "vue-jsx-vapor/runtime";
|
|
172
|
+
},
|
|
173
|
+
load(id) {
|
|
174
|
+
if (id === ssrRegisterHelperId) return ssrRegisterHelperCode;
|
|
175
|
+
if ((0, unplugin_utils.normalizePath)(id) === "vue-jsx-vapor/runtime") return runtime_default;
|
|
176
|
+
},
|
|
177
|
+
transformInclude,
|
|
178
|
+
transform(code, id, opt) {
|
|
179
|
+
const result = require_core.transformVueJsxVapor(code, id, options, needSourceMap);
|
|
180
|
+
if (result?.code) {
|
|
181
|
+
(needHMR || opt?.ssr) && injectHMRAndSSR(result, id, {
|
|
182
|
+
ssr: opt?.ssr,
|
|
183
|
+
root
|
|
184
|
+
});
|
|
185
|
+
return {
|
|
186
|
+
code: result.code,
|
|
187
|
+
map: result.map
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
name: "@vue-macros/jsx-directive",
|
|
194
|
+
transformInclude,
|
|
195
|
+
transform(code, id, opt) {
|
|
196
|
+
if (options.interop || opt?.ssr) return (0, __vue_macros_jsx_directive_api.transformJsxDirective)(code, id, {
|
|
197
|
+
lib: "vue",
|
|
198
|
+
prefix: "v-",
|
|
199
|
+
version: 3.6
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
name: "@vitejs/plugin-vue-jsx",
|
|
205
|
+
transformInclude,
|
|
206
|
+
transform(code, id, opt) {
|
|
207
|
+
if (options.interop || opt?.ssr) return transformVueJsx(code, id, needSourceMap);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
...options.macros === false ? [] : options.macros ? [(0, __vue_jsx_vapor_macros_raw.default)(options.macros === true ? void 0 : options.macros)] : []
|
|
211
|
+
];
|
|
212
|
+
};
|
|
213
|
+
var raw_default = plugin;
|
|
214
|
+
|
|
215
|
+
//#endregion
|
|
216
|
+
Object.defineProperty(exports, 'raw_default', {
|
|
217
|
+
enumerable: true,
|
|
218
|
+
get: function () {
|
|
219
|
+
return raw_default;
|
|
220
|
+
}
|
|
221
|
+
});
|
package/dist/raw.cjs
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
2
|
+
require('./core-B29W1zp3.cjs');
|
|
3
|
+
const require_raw = require('./raw-Dr3UcxgN.cjs');
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
require('./chunk-GY6DSRCV.cjs');
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.default = _chunkVSS2IZIScjs.raw_default;
|
|
8
|
-
|
|
9
|
-
module.exports = exports.default;
|
|
5
|
+
exports.default = require_raw.raw_default
|
package/dist/raw.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Options } from
|
|
2
|
-
import { UnpluginOptions } from
|
|
3
|
-
import '@vue-jsx-vapor/compiler';
|
|
4
|
-
import '@vue-jsx-vapor/macros';
|
|
5
|
-
import 'unplugin-utils';
|
|
1
|
+
import { Options } from "./options.d-CA70vgwp.cjs";
|
|
2
|
+
import { UnpluginOptions } from "unplugin";
|
|
6
3
|
|
|
4
|
+
//#region src/raw.d.ts
|
|
7
5
|
declare const plugin: (options?: Options) => UnpluginOptions[];
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
export { plugin as default };
|
package/dist/raw.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { Options } from
|
|
2
|
-
import { UnpluginOptions } from
|
|
3
|
-
import '@vue-jsx-vapor/compiler';
|
|
4
|
-
import '@vue-jsx-vapor/macros';
|
|
5
|
-
import 'unplugin-utils';
|
|
1
|
+
import { Options } from "./options.d-BAyccQwr.js";
|
|
2
|
+
import { UnpluginOptions } from "unplugin";
|
|
6
3
|
|
|
4
|
+
//#region src/raw.d.ts
|
|
7
5
|
declare const plugin: (options?: Options) => UnpluginOptions[];
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
export { plugin as default };
|
package/dist/raw.js
CHANGED
package/dist/rolldown.cjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
6
|
-
require('./
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
module.exports = exports.default;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
const require_chunk = require('./chunk-BCwAaXi7.cjs');
|
|
4
|
+
require('./core-B29W1zp3.cjs');
|
|
5
|
+
require('./raw-Dr3UcxgN.cjs');
|
|
6
|
+
require('./options-CulFO0WS.cjs');
|
|
7
|
+
const require_unplugin = require('./unplugin-ChZxAtQ0.cjs');
|
|
8
|
+
const unplugin = require_chunk.__toESM(require("unplugin"));
|
|
9
|
+
|
|
10
|
+
//#region src/rolldown.ts
|
|
11
|
+
var rolldown_default = (0, unplugin.createRollupPlugin)(require_unplugin.unpluginFactory);
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.default = rolldown_default
|
package/dist/rolldown.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@vue-jsx-vapor/compiler';
|
|
4
|
-
import '@vue-jsx-vapor/macros';
|
|
5
|
-
import 'unplugin-utils';
|
|
1
|
+
import { Options } from "./options.d-CA70vgwp.cjs";
|
|
2
|
+
import { Plugin } from "rollup";
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
//#region src/rolldown.d.ts
|
|
5
|
+
declare const _default: (options?: Options | undefined) => Plugin<any> | Plugin<any>[];
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
export { _default as default };
|
package/dist/rolldown.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@vue-jsx-vapor/compiler';
|
|
4
|
-
import '@vue-jsx-vapor/macros';
|
|
5
|
-
import 'unplugin-utils';
|
|
1
|
+
import { Options } from "./options.d-BAyccQwr.js";
|
|
2
|
+
import { Plugin } from "rollup";
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
//#region src/rolldown.d.ts
|
|
5
|
+
declare const _default: (options?: Options | undefined) => Plugin<any> | Plugin<any>[];
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
export { _default as default };
|
package/dist/rolldown.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import "./
|
|
5
|
-
import "./chunk-T3F6TYMY.js";
|
|
6
|
-
import "./chunk-SAJ6WS2A.js";
|
|
7
|
-
|
|
8
|
-
// src/rolldown.ts
|
|
1
|
+
import "./core-BDE4GLH8.js";
|
|
2
|
+
import "./raw-C8eD8f6a.js";
|
|
3
|
+
import "./options-HYvLzmlg.js";
|
|
4
|
+
import { unpluginFactory } from "./unplugin-BMMTjSOs.js";
|
|
9
5
|
import { createRollupPlugin } from "unplugin";
|
|
6
|
+
|
|
7
|
+
//#region src/rolldown.ts
|
|
10
8
|
var rolldown_default = createRollupPlugin(unpluginFactory);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
};
|
|
9
|
+
|
|
10
|
+
//#endregion
|
|
11
|
+
export { rolldown_default as default };
|
package/dist/rollup.cjs
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
require('./
|
|
5
|
-
require('./
|
|
6
|
-
require('./
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var rollup_default =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.default = rollup_default
|
|
13
|
-
|
|
14
|
-
module.exports = exports.default;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
3
|
+
require('./core-B29W1zp3.cjs');
|
|
4
|
+
require('./raw-Dr3UcxgN.cjs');
|
|
5
|
+
require('./options-CulFO0WS.cjs');
|
|
6
|
+
const require_unplugin = require('./unplugin-ChZxAtQ0.cjs');
|
|
7
|
+
|
|
8
|
+
//#region src/rollup.ts
|
|
9
|
+
var rollup_default = require_unplugin.unplugin_default.rollup;
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
exports.default = rollup_default
|
package/dist/rollup.d.cts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@vue-jsx-vapor/compiler';
|
|
4
|
-
import '@vue-jsx-vapor/macros';
|
|
5
|
-
import 'unplugin-utils';
|
|
1
|
+
import { Options } from "./options.d-CA70vgwp.cjs";
|
|
2
|
+
import { Plugin } from "rollup";
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
//#region src/rollup.d.ts
|
|
5
|
+
declare const _default: (options?: Options | undefined) => Plugin<any>[];
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
export { _default as default };
|
package/dist/rollup.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import '@vue-jsx-vapor/compiler';
|
|
4
|
-
import '@vue-jsx-vapor/macros';
|
|
5
|
-
import 'unplugin-utils';
|
|
1
|
+
import { Options } from "./options.d-BAyccQwr.js";
|
|
2
|
+
import { Plugin } from "rollup";
|
|
6
3
|
|
|
7
|
-
|
|
4
|
+
//#region src/rollup.d.ts
|
|
5
|
+
declare const _default: (options?: Options | undefined) => Plugin<any>[];
|
|
8
6
|
|
|
9
|
-
|
|
7
|
+
//#endregion
|
|
8
|
+
export { _default as default };
|