vue-jsx-vapor 2.5.4-beta.1 → 2.6.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.
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-jKAq0dFf.cjs";
2
- import * as esbuild4 from "esbuild";
2
+ import * as esbuild1 from "esbuild";
3
3
 
4
4
  //#region src/esbuild.d.ts
5
- declare const _default: (options?: Options | undefined) => esbuild4.Plugin;
5
+ declare const _default: (options?: Options | undefined) => esbuild1.Plugin;
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/esbuild.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Options } from "./options-CBMw6D8V.js";
2
- import * as esbuild2 from "esbuild";
2
+ import * as esbuild1 from "esbuild";
3
3
 
4
4
  //#region src/esbuild.d.ts
5
- declare const _default: (options?: Options | undefined) => esbuild2.Plugin;
5
+ declare const _default: (options?: Options | undefined) => esbuild1.Plugin;
6
6
  //#endregion
7
7
  export { _default as default };
package/dist/index.cjs CHANGED
@@ -1,162 +1,9 @@
1
- const require_chunk = require('./chunk-CUT6urMc.cjs');
2
- const vue = require_chunk.__toESM(require("vue"));
3
1
 
4
- //#region src/core/runtime.ts
5
- function isBlock(val) {
6
- return val instanceof Node || Array.isArray(val) || (0, vue.isVaporComponent)(val) || (0, vue.isFragment)(val);
7
- }
8
- function getCurrentInstance() {
9
- return vue.currentInstance || vue.getCurrentInstance();
10
- }
11
- const createProxyComponent = (createComponent$1, type, props, ...args) => {
12
- if (type === vue.Fragment) {
13
- type = (_, { slots }) => slots.default();
14
- props = null;
15
- }
16
- if (vue.currentInstance && vue.currentInstance.appContext.vapor) typeof type === "function" && (type.__vapor = true);
17
- return createComponent$1(type, props, ...args);
18
- };
19
- const createComponent = (type, ...args) => {
20
- return createProxyComponent(vue.createComponent, type, ...args);
21
- };
22
- const createComponentWithFallback = (type, ...args) => createProxyComponent(vue.createComponentWithFallback, type, ...args);
23
- /**
24
- * Returns the props of the current component instance.
25
- *
26
- * @example
27
- * ```tsx
28
- * import { useProps } from 'vue-jsx-vapor'
29
- *
30
- * defineComponent(({ foo = '' })=>{
31
- * const props = useProps() // { foo: '' }
32
- * })
33
- * ```
34
- */
35
- function useProps() {
36
- const i = getCurrentInstance();
37
- return i.props;
38
- }
39
- /**
40
- * Returns the merged props and attrs of the current component.\
41
- * Equivalent to `useProps()` + `useAttrs()`.
42
- *
43
- * @example
44
- * ```tsx
45
- * import { useFullProps } from 'vue-jsx-vapor'
46
- *
47
- * defineComponent((props) => {
48
- * const fullProps = useFullProps() // = useAttrs() + useProps()
49
- * })
50
- */
51
- function useFullProps() {
52
- return (0, vue.proxyRefs)({
53
- ...(0, vue.toRefs)(useProps()),
54
- ...(0, vue.toRefs)((0, vue.useAttrs)())
55
- });
56
- }
57
- function createFragment(nodes, anchor = document.createTextNode("")) {
58
- const frag = new vue.VaporFragment(nodes);
59
- frag.anchor = anchor;
60
- return frag;
61
- }
62
- function normalizeNode$1(node, anchor) {
63
- if (node instanceof Node || (0, vue.isFragment)(node)) {
64
- anchor && (anchor.textContent = "");
65
- return node;
66
- } else if ((0, vue.isVaporComponent)(node)) {
67
- anchor && (anchor.textContent = "");
68
- return createFragment(node, anchor);
69
- } else if (Array.isArray(node)) {
70
- anchor && (anchor.textContent = "");
71
- return createFragment(node.map((i) => normalizeNode$1(i)), anchor);
72
- } else {
73
- const result = node == null || typeof node === "boolean" ? "" : String(node);
74
- if (anchor) {
75
- anchor.textContent = result;
76
- return anchor;
77
- } else return document.createTextNode(result);
78
- }
79
- }
80
- function resolveValue(current, value, _anchor) {
81
- const node = normalizeNode$1(value, _anchor);
82
- if (current) {
83
- if ((0, vue.isFragment)(current)) {
84
- const { anchor } = current;
85
- if (anchor && anchor.parentNode) {
86
- (0, vue.remove)(current.nodes, anchor.parentNode);
87
- (0, vue.insert)(node, anchor.parentNode, anchor);
88
- !_anchor && anchor.parentNode.removeChild(anchor);
89
- }
90
- } else if (current instanceof Node) {
91
- if ((0, vue.isFragment)(node) && current.parentNode) {
92
- (0, vue.insert)(node, current.parentNode, current);
93
- current.parentNode.removeChild(current);
94
- } else if (node instanceof Node) {
95
- if (current.nodeType === 3 && node.nodeType === 3) {
96
- current.textContent = node.textContent;
97
- return current;
98
- } else if (current.parentNode) current.parentNode.replaceChild(node, current);
99
- }
100
- }
101
- }
102
- return node;
103
- }
104
- function resolveValues(values = [], _anchor) {
105
- const nodes = [];
106
- const frag = createFragment(nodes, _anchor);
107
- const scopes = [];
108
- for (const [index, value] of values.entries()) {
109
- const anchor = index === values.length - 1 ? _anchor : void 0;
110
- if (typeof value === "function") (0, vue.renderEffect)(() => {
111
- if (scopes[index]) scopes[index].stop();
112
- scopes[index] = new vue.EffectScope();
113
- nodes[index] = scopes[index].run(() => resolveValue(nodes[index], value(), anchor));
114
- });
115
- else nodes[index] = resolveValue(nodes[index], value, anchor);
116
- }
117
- return frag;
118
- }
119
- function setNodes(anchor, ...values) {
120
- const resolvedValues = resolveValues(values, anchor);
121
- anchor.parentNode && (0, vue.insert)(resolvedValues, anchor.parentNode, anchor);
122
- }
123
- function createNodes(...values) {
124
- return resolveValues(values);
125
- }
126
2
 
127
- //#endregion
128
- //#region src/core/h.ts
129
- function normalizeNode(node) {
130
- if (node == null || typeof node === "boolean") return [];
131
- else if (Array.isArray(node) && node.length) return node.map(normalizeNode);
132
- else if (isBlock(node)) return node;
133
- else return (0, vue.createTextNode)(String(node));
134
- }
135
- function h(type, propsOrChildren, children) {
136
- const l = arguments.length;
137
- if (l === 2) if (typeof propsOrChildren === "object" && !Array.isArray(propsOrChildren)) {
138
- if (isBlock(propsOrChildren)) return createComponentWithFallback(type, null, { default: () => normalizeNode(propsOrChildren) });
139
- return createComponentWithFallback(type, propsOrChildren ? { $: [() => propsOrChildren] } : null);
140
- } else return createComponentWithFallback(type, null, { default: () => normalizeNode(propsOrChildren) });
141
- else {
142
- if (l > 3) children = Array.prototype.slice.call(arguments, 2);
143
- return createComponentWithFallback(type, propsOrChildren ? { $: [() => propsOrChildren] } : null, children ? typeof children === "object" && !Array.isArray(children) ? children : { default: () => normalizeNode(children) } : void 0);
144
- }
145
- }
146
-
147
- //#endregion
148
- exports.createComponent = createComponent;
149
- exports.createComponentWithFallback = createComponentWithFallback;
150
- exports.createNodes = createNodes;
151
- exports.getCurrentInstance = getCurrentInstance;
152
- exports.h = h;
153
- exports.isBlock = isBlock;
154
- exports.setNodes = setNodes;
155
- exports.useFullProps = useFullProps;
156
- exports.useProps = useProps;
157
- Object.defineProperty(exports, 'useRef', {
158
- enumerable: true,
159
- get: function () {
160
- return vue.shallowRef;
161
- }
162
- });
3
+ var __vue_jsx_vapor_runtime = require("@vue-jsx-vapor/runtime");
4
+ Object.keys(__vue_jsx_vapor_runtime).forEach(function (k) {
5
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
6
+ enumerable: true,
7
+ get: function () { return __vue_jsx_vapor_runtime[k]; }
8
+ });
9
+ });