vue-jsx-vapor 2.1.7 → 2.2.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.
Files changed (41) hide show
  1. package/dist/api.cjs +2 -2
  2. package/dist/api.d.cts +2 -12
  3. package/dist/api.d.ts +2 -12
  4. package/dist/api.js +1 -1
  5. package/dist/astro.cjs +4 -4
  6. package/dist/astro.js +3 -3
  7. package/dist/{chunk-E4OOBQM6.js → chunk-4HP6QVER.js} +1 -1
  8. package/dist/{chunk-JOQ6HUZ7.cjs → chunk-F7CI4ATH.cjs} +2 -2
  9. package/dist/{chunk-G5FQVEHY.js → chunk-G2KD2VHX.js} +1 -1
  10. package/dist/chunk-GY6DSRCV.cjs +22 -0
  11. package/dist/{chunk-WKWVDEIZ.js → chunk-HNBQ42EP.js} +1 -1
  12. package/dist/{chunk-4FRXY2W6.cjs → chunk-M4VKLZSB.cjs} +2 -2
  13. package/dist/{chunk-WAOMEMCZ.cjs → chunk-QBIU4H54.cjs} +2 -2
  14. package/dist/chunk-SAJ6WS2A.js +22 -0
  15. package/dist/chunk-T3F6TYMY.js +265 -0
  16. package/dist/chunk-VSS2IZIS.cjs +265 -0
  17. package/dist/esbuild.cjs +4 -4
  18. package/dist/esbuild.js +3 -3
  19. package/dist/nuxt.cjs +7 -7
  20. package/dist/nuxt.js +5 -5
  21. package/dist/raw.cjs +3 -3
  22. package/dist/raw.js +2 -2
  23. package/dist/rolldown.cjs +4 -4
  24. package/dist/rolldown.d.cts +1 -1
  25. package/dist/rolldown.d.ts +1 -1
  26. package/dist/rolldown.js +3 -3
  27. package/dist/rollup.cjs +4 -4
  28. package/dist/rollup.js +3 -3
  29. package/dist/rspack.cjs +4 -4
  30. package/dist/rspack.js +3 -3
  31. package/dist/unplugin.cjs +4 -4
  32. package/dist/unplugin.js +3 -3
  33. package/dist/vite.cjs +5 -5
  34. package/dist/vite.js +4 -4
  35. package/dist/webpack.cjs +5 -5
  36. package/dist/webpack.js +4 -4
  37. package/package.json +8 -5
  38. package/dist/chunk-CVVA3UFV.cjs +0 -58
  39. package/dist/chunk-GY27NIU6.cjs +0 -134
  40. package/dist/chunk-K7YI4ZKB.js +0 -134
  41. package/dist/chunk-MBCYFLIE.js +0 -58
@@ -1,58 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
-
3
- var _chunkGY27NIU6cjs = require('./chunk-GY27NIU6.cjs');
4
-
5
- // src/raw.ts
6
- var _raw = require('@vue-jsx-vapor/macros/raw'); var _raw2 = _interopRequireDefault(_raw);
7
- var _unpluginutils = require('unplugin-utils');
8
-
9
- // src/core/runtime.ts?raw
10
- 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';
11
-
12
- // src/raw.ts
13
- var plugin = (options = {}) => {
14
- const transformInclude = _unpluginutils.createFilter.call(void 0,
15
- _optionalChain([options, 'optionalAccess', _ => _.include]) || /\.[cm]?[jt]sx?$/,
16
- _optionalChain([options, 'optionalAccess', _2 => _2.exclude])
17
- );
18
- return [
19
- {
20
- name: "vue-jsx-vapor",
21
- vite: {
22
- config(config) {
23
- return {
24
- // only apply esbuild to ts files
25
- // since we are handling jsx and tsx now
26
- esbuild: {
27
- include: /\.ts$/
28
- },
29
- define: {
30
- __VUE_OPTIONS_API__: _nullishCoalesce(_optionalChain([config, 'access', _3 => _3.define, 'optionalAccess', _4 => _4.__VUE_OPTIONS_API__]), () => ( true)),
31
- __VUE_PROD_DEVTOOLS__: _nullishCoalesce(_optionalChain([config, 'access', _5 => _5.define, 'optionalAccess', _6 => _6.__VUE_PROD_DEVTOOLS__]), () => ( false)),
32
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: _nullishCoalesce(_optionalChain([config, 'access', _7 => _7.define, 'optionalAccess', _8 => _8.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__]), () => ( false))
33
- }
34
- };
35
- }
36
- },
37
- resolveId(id) {
38
- if (_unpluginutils.normalizePath.call(void 0, id) === "vue-jsx-vapor/runtime") return id;
39
- },
40
- loadInclude(id) {
41
- return _unpluginutils.normalizePath.call(void 0, id) === "vue-jsx-vapor/runtime";
42
- },
43
- load(id) {
44
- if (_unpluginutils.normalizePath.call(void 0, id) === "vue-jsx-vapor/runtime") return runtime_default;
45
- },
46
- transformInclude,
47
- transform(code, id) {
48
- return _chunkGY27NIU6cjs.transformVueJsxVapor.call(void 0, code, id, options);
49
- }
50
- },
51
- ...options.macros === false ? [] : options.macros ? [_raw2.default.call(void 0, options.macros === true ? void 0 : options.macros)] : []
52
- ];
53
- };
54
- var raw_default = plugin;
55
-
56
-
57
-
58
- exports.raw_default = raw_default;
@@ -1,134 +0,0 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/core/index.ts
2
- var _core = require('@babel/core');
3
- var _plugintransformtypescript = require('@babel/plugin-transform-typescript'); var _plugintransformtypescript2 = _interopRequireDefault(_plugintransformtypescript);
4
- var _babel = require('@vue-jsx-vapor/babel'); var _babel2 = _interopRequireDefault(_babel);
5
-
6
- // src/core/hmr.ts
7
- var _api = require('@vue-jsx-vapor/macros/api');
8
- var _hashsum = require('hash-sum'); var _hashsum2 = _interopRequireDefault(_hashsum);
9
- function registerHMR(result, id, defineComponentNames = ["defineComponent", "defineVaporComponent"]) {
10
- const { ast } = result;
11
- const declaredComponents = [];
12
- const hotComponents = [];
13
- let hasDefaultExport = false;
14
- const ssr = false;
15
- for (const node of ast.program.body) {
16
- if (node.type === "VariableDeclaration") {
17
- const names = parseComponentDecls(node, defineComponentNames);
18
- if (names.length) {
19
- declaredComponents.push(...names);
20
- }
21
- }
22
- if (node.type === "ExportNamedDeclaration") {
23
- if (node.declaration && node.declaration.type === "VariableDeclaration") {
24
- hotComponents.push(
25
- ...parseComponentDecls(node.declaration, defineComponentNames).map(
26
- (name) => ({
27
- local: name,
28
- exported: name,
29
- id: _hashsum2.default.call(void 0, id + name)
30
- })
31
- )
32
- );
33
- } else if (node.specifiers.length) {
34
- for (const spec of node.specifiers) {
35
- if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") {
36
- const matched = declaredComponents.find(
37
- (name) => name === spec.local.name
38
- );
39
- if (matched) {
40
- hotComponents.push({
41
- local: spec.local.name,
42
- exported: spec.exported.name,
43
- id: _hashsum2.default.call(void 0, id + spec.exported.name)
44
- });
45
- }
46
- }
47
- }
48
- }
49
- }
50
- if (node.type === "ExportDefaultDeclaration") {
51
- if (node.declaration.type === "Identifier") {
52
- const _name = node.declaration.name;
53
- const matched = declaredComponents.find((name) => name === _name);
54
- if (matched) {
55
- hotComponents.push({
56
- local: _name,
57
- exported: "default",
58
- id: _hashsum2.default.call(void 0, `${id}default`)
59
- });
60
- }
61
- } else if (isDefineComponentCall(node.declaration, defineComponentNames) || _api.isFunctionalNode.call(void 0, node.declaration)) {
62
- hasDefaultExport = true;
63
- hotComponents.push({
64
- local: "__default__",
65
- exported: "default",
66
- id: _hashsum2.default.call(void 0, `${id}default`)
67
- });
68
- }
69
- }
70
- }
71
- if (hotComponents.length) {
72
- if (hasDefaultExport || ssr) {
73
- result.code = `${result.code.replaceAll(
74
- `export default `,
75
- `const __default__ = `
76
- )}
77
- export default __default__`;
78
- }
79
- if (!ssr && !/\?vue&type=script/.test(id)) {
80
- let code = result.code;
81
- let callbackCode = ``;
82
- for (const { local, exported, id: id2 } of hotComponents) {
83
- code += `
84
- ${local}.__hmrId = "${id2}"
85
- __VUE_HMR_RUNTIME__.createRecord("${id2}", ${local})`;
86
- callbackCode += `
87
- __VUE_HMR_RUNTIME__.rerender(mod['${exported}'].__hmrId, mod['${exported}'].setup || mod['${exported}'])`;
88
- }
89
- code += `
90
- if (import.meta.hot) {
91
- import.meta.hot.accept((mod) => {${callbackCode}
92
- })
93
- }`;
94
- result.code = code;
95
- }
96
- }
97
- }
98
- function parseComponentDecls(node, fnNames) {
99
- const names = [];
100
- for (const decl of node.declarations) {
101
- if (decl.id.type === "Identifier" && (isDefineComponentCall(decl.init, fnNames) || _api.isFunctionalNode.call(void 0, decl.init)))
102
- names.push(decl.id.name);
103
- }
104
- return names;
105
- }
106
- function isDefineComponentCall(node, names) {
107
- return !!(node && node.type === "CallExpression" && node.callee.type === "Identifier" && names.includes(node.callee.name));
108
- }
109
-
110
- // src/core/index.ts
111
- function transformVueJsxVapor(code, id, options) {
112
- const result = _core.transformSync.call(void 0, code, {
113
- plugins: [
114
- [_babel2.default, { compile: _optionalChain([options, 'optionalAccess', _ => _.compile]), interop: _optionalChain([options, 'optionalAccess', _2 => _2.interop]) }],
115
- id.endsWith(".tsx") ? [_plugintransformtypescript2.default, { isTSX: true, allowExtensions: true }] : null
116
- ].filter((i) => i !== null),
117
- filename: id,
118
- sourceMaps: true,
119
- sourceFileName: id,
120
- babelrc: false,
121
- configFile: false,
122
- ast: true
123
- });
124
- if (result) registerHMR(result, id);
125
- if (_optionalChain([result, 'optionalAccess', _3 => _3.code]))
126
- return {
127
- code: result.code,
128
- map: result.map
129
- };
130
- }
131
-
132
-
133
-
134
- exports.transformVueJsxVapor = transformVueJsxVapor;
@@ -1,134 +0,0 @@
1
- // src/core/index.ts
2
- import { transformSync } from "@babel/core";
3
- import babelTypescript from "@babel/plugin-transform-typescript";
4
- import jsx from "@vue-jsx-vapor/babel";
5
-
6
- // src/core/hmr.ts
7
- import { isFunctionalNode } from "@vue-jsx-vapor/macros/api";
8
- import getHash from "hash-sum";
9
- function registerHMR(result, id, defineComponentNames = ["defineComponent", "defineVaporComponent"]) {
10
- const { ast } = result;
11
- const declaredComponents = [];
12
- const hotComponents = [];
13
- let hasDefaultExport = false;
14
- const ssr = false;
15
- for (const node of ast.program.body) {
16
- if (node.type === "VariableDeclaration") {
17
- const names = parseComponentDecls(node, defineComponentNames);
18
- if (names.length) {
19
- declaredComponents.push(...names);
20
- }
21
- }
22
- if (node.type === "ExportNamedDeclaration") {
23
- if (node.declaration && node.declaration.type === "VariableDeclaration") {
24
- hotComponents.push(
25
- ...parseComponentDecls(node.declaration, defineComponentNames).map(
26
- (name) => ({
27
- local: name,
28
- exported: name,
29
- id: getHash(id + name)
30
- })
31
- )
32
- );
33
- } else if (node.specifiers.length) {
34
- for (const spec of node.specifiers) {
35
- if (spec.type === "ExportSpecifier" && spec.exported.type === "Identifier") {
36
- const matched = declaredComponents.find(
37
- (name) => name === spec.local.name
38
- );
39
- if (matched) {
40
- hotComponents.push({
41
- local: spec.local.name,
42
- exported: spec.exported.name,
43
- id: getHash(id + spec.exported.name)
44
- });
45
- }
46
- }
47
- }
48
- }
49
- }
50
- if (node.type === "ExportDefaultDeclaration") {
51
- if (node.declaration.type === "Identifier") {
52
- const _name = node.declaration.name;
53
- const matched = declaredComponents.find((name) => name === _name);
54
- if (matched) {
55
- hotComponents.push({
56
- local: _name,
57
- exported: "default",
58
- id: getHash(`${id}default`)
59
- });
60
- }
61
- } else if (isDefineComponentCall(node.declaration, defineComponentNames) || isFunctionalNode(node.declaration)) {
62
- hasDefaultExport = true;
63
- hotComponents.push({
64
- local: "__default__",
65
- exported: "default",
66
- id: getHash(`${id}default`)
67
- });
68
- }
69
- }
70
- }
71
- if (hotComponents.length) {
72
- if (hasDefaultExport || ssr) {
73
- result.code = `${result.code.replaceAll(
74
- `export default `,
75
- `const __default__ = `
76
- )}
77
- export default __default__`;
78
- }
79
- if (!ssr && !/\?vue&type=script/.test(id)) {
80
- let code = result.code;
81
- let callbackCode = ``;
82
- for (const { local, exported, id: id2 } of hotComponents) {
83
- code += `
84
- ${local}.__hmrId = "${id2}"
85
- __VUE_HMR_RUNTIME__.createRecord("${id2}", ${local})`;
86
- callbackCode += `
87
- __VUE_HMR_RUNTIME__.rerender(mod['${exported}'].__hmrId, mod['${exported}'].setup || mod['${exported}'])`;
88
- }
89
- code += `
90
- if (import.meta.hot) {
91
- import.meta.hot.accept((mod) => {${callbackCode}
92
- })
93
- }`;
94
- result.code = code;
95
- }
96
- }
97
- }
98
- function parseComponentDecls(node, fnNames) {
99
- const names = [];
100
- for (const decl of node.declarations) {
101
- if (decl.id.type === "Identifier" && (isDefineComponentCall(decl.init, fnNames) || isFunctionalNode(decl.init)))
102
- names.push(decl.id.name);
103
- }
104
- return names;
105
- }
106
- function isDefineComponentCall(node, names) {
107
- return !!(node && node.type === "CallExpression" && node.callee.type === "Identifier" && names.includes(node.callee.name));
108
- }
109
-
110
- // src/core/index.ts
111
- function transformVueJsxVapor(code, id, options) {
112
- const result = transformSync(code, {
113
- plugins: [
114
- [jsx, { compile: options?.compile, interop: options?.interop }],
115
- id.endsWith(".tsx") ? [babelTypescript, { isTSX: true, allowExtensions: true }] : null
116
- ].filter((i) => i !== null),
117
- filename: id,
118
- sourceMaps: true,
119
- sourceFileName: id,
120
- babelrc: false,
121
- configFile: false,
122
- ast: true
123
- });
124
- if (result) registerHMR(result, id);
125
- if (result?.code)
126
- return {
127
- code: result.code,
128
- map: result.map
129
- };
130
- }
131
-
132
- export {
133
- transformVueJsxVapor
134
- };
@@ -1,58 +0,0 @@
1
- import {
2
- transformVueJsxVapor
3
- } from "./chunk-K7YI4ZKB.js";
4
-
5
- // src/raw.ts
6
- import Macros from "@vue-jsx-vapor/macros/raw";
7
- import { createFilter, normalizePath } from "unplugin-utils";
8
-
9
- // src/core/runtime.ts?raw
10
- 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';
11
-
12
- // src/raw.ts
13
- var plugin = (options = {}) => {
14
- const transformInclude = createFilter(
15
- options?.include || /\.[cm]?[jt]sx?$/,
16
- options?.exclude
17
- );
18
- return [
19
- {
20
- name: "vue-jsx-vapor",
21
- vite: {
22
- config(config) {
23
- return {
24
- // only apply esbuild to ts files
25
- // since we are handling jsx and tsx now
26
- esbuild: {
27
- include: /\.ts$/
28
- },
29
- define: {
30
- __VUE_OPTIONS_API__: config.define?.__VUE_OPTIONS_API__ ?? true,
31
- __VUE_PROD_DEVTOOLS__: config.define?.__VUE_PROD_DEVTOOLS__ ?? false,
32
- __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: config.define?.__VUE_PROD_HYDRATION_MISMATCH_DETAILS__ ?? false
33
- }
34
- };
35
- }
36
- },
37
- resolveId(id) {
38
- if (normalizePath(id) === "vue-jsx-vapor/runtime") return id;
39
- },
40
- loadInclude(id) {
41
- return normalizePath(id) === "vue-jsx-vapor/runtime";
42
- },
43
- load(id) {
44
- if (normalizePath(id) === "vue-jsx-vapor/runtime") return runtime_default;
45
- },
46
- transformInclude,
47
- transform(code, id) {
48
- return transformVueJsxVapor(code, id, options);
49
- }
50
- },
51
- ...options.macros === false ? [] : options.macros ? [Macros(options.macros === true ? void 0 : options.macros)] : []
52
- ];
53
- };
54
- var raw_default = plugin;
55
-
56
- export {
57
- raw_default
58
- };