nexa-runtime 0.5.1 → 0.6.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/component/Transition.d.ts +0 -1
- package/dist/component/Transition.js +0 -1
- package/dist/component/asyncComponent.d.ts +0 -1
- package/dist/component/asyncComponent.js +0 -1
- package/dist/component/defineComponent.d.ts +0 -1
- package/dist/component/defineComponent.js +0 -1
- package/dist/component/errorBoundary.d.ts +0 -1
- package/dist/component/errorBoundary.js +3 -4
- package/dist/component/index.d.ts +1 -1
- package/dist/component/index.js +1 -1
- package/dist/component/inject.d.ts +2 -0
- package/dist/component/inject.js +16 -0
- package/dist/component/lifecycle.d.ts +0 -1
- package/dist/component/lifecycle.js +0 -1
- package/dist/component/suspense.d.ts +0 -1
- package/dist/component/suspense.js +3 -4
- package/dist/directives/index.d.ts +0 -1
- package/dist/directives/index.js +4 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/scheduler.d.ts +3 -2
- package/dist/scheduler.d.ts.map +1 -1
- package/dist/scheduler.js +32 -13
- package/dist/scheduler.js.map +1 -1
- package/dist/ssr/hydrate.d.ts +0 -1
- package/dist/ssr/hydrate.js +3 -1
- package/dist/ssr/hydrate.js.map +1 -1
- package/dist/ssr/renderToStream.d.ts +0 -1
- package/dist/ssr/renderToStream.js +0 -1
- package/dist/ssr/renderToString.d.ts +0 -1
- package/dist/ssr/renderToString.js +4 -2
- package/dist/vdom/diff.d.ts +0 -1
- package/dist/vdom/diff.js +8 -12
- package/dist/vdom/dom.d.ts +0 -1
- package/dist/vdom/dom.js +45 -14
- package/dist/vdom/h.d.ts +0 -1
- package/dist/vdom/h.js +4 -3
- package/dist/vdom/hmr.d.ts +0 -1
- package/dist/vdom/hmr.js +3 -2
- package/dist/vdom/index.d.ts +0 -1
- package/dist/vdom/index.js +0 -1
- package/dist/vdom/mountComponent.d.ts +1 -1
- package/dist/vdom/mountComponent.d.ts.map +1 -1
- package/dist/vdom/mountComponent.js +116 -33
- package/dist/vdom/mountComponent.js.map +1 -1
- package/dist/vdom/mountProps.d.ts +0 -1
- package/dist/vdom/mountProps.js +31 -9
- package/dist/vdom/patch.d.ts +0 -1
- package/dist/vdom/patch.d.ts.map +1 -1
- package/dist/vdom/patch.js +27 -13
- package/dist/vdom/patch.js.map +1 -1
- package/dist/vdom/renderer.d.ts +0 -1
- package/dist/vdom/renderer.js +0 -1
- package/dist/vdom/scope.d.ts +0 -1
- package/dist/vdom/scope.js +0 -1
- package/dist/vdom/slots.d.ts +0 -1
- package/dist/vdom/slots.js +9 -2
- package/dist/vdom/transition.d.ts +0 -1
- package/dist/vdom/transition.js +0 -1
- package/dist/vdom/types.d.ts +4 -2
- package/dist/vdom/types.js +0 -1
- package/dist/vdom/unmount.d.ts +0 -1
- package/dist/vdom/unmount.js +25 -24
- package/package.json +2 -2
- package/dist/component/defineComponent.d.ts.map +0 -1
- package/dist/component/defineComponent.js.map +0 -1
- package/dist/component/index.js.map +0 -1
- package/dist/component/lifecycle.d.ts.map +0 -1
- package/dist/component/lifecycle.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/ssr/renderToStream.d.ts.map +0 -1
- package/dist/ssr/renderToStream.js.map +0 -1
- package/dist/ssr/renderToString.d.ts.map +0 -1
- package/dist/ssr/renderToString.js.map +0 -1
- package/dist/vdom/diff.d.ts.map +0 -1
- package/dist/vdom/diff.js.map +0 -1
- package/dist/vdom/h.js.map +0 -1
- package/dist/vdom/hmr.d.ts.map +0 -1
- package/dist/vdom/hmr.js.map +0 -1
- package/dist/vdom/index.js.map +0 -1
- package/dist/vdom/renderer.d.ts.map +0 -1
- package/dist/vdom/renderer.js.map +0 -1
- package/dist/vdom/scope.d.ts.map +0 -1
- package/dist/vdom/scope.js.map +0 -1
- package/dist/vdom/slots.d.ts.map +0 -1
- package/dist/vdom/slots.js.map +0 -1
- package/dist/vdom/transition.d.ts.map +0 -1
- package/dist/vdom/transition.js.map +0 -1
- package/dist/vdom/types.d.ts.map +0 -1
- package/dist/vdom/types.js.map +0 -1
- package/dist/vdom/unmount.d.ts.map +0 -1
- package/dist/vdom/unmount.js.map +0 -1
|
@@ -1,23 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { signal, track, Effect } from 'nexa-reactivity';
|
|
2
2
|
import { Fragment } from './types';
|
|
3
3
|
import { extractSlots } from './slots';
|
|
4
|
-
import { setCurrentInstance, runLifecycle } from '../component/lifecycle';
|
|
4
|
+
import { setCurrentInstance, getCurrentInstance, runLifecycle } from '../component/lifecycle';
|
|
5
5
|
import { getCurrentErrorBoundary } from '../component/errorBoundary';
|
|
6
6
|
import { pushScope, popScope } from './scope';
|
|
7
7
|
import { mount, applyPatches } from './patch';
|
|
8
8
|
import { diff } from './diff';
|
|
9
9
|
import { registerInstance } from './hmr';
|
|
10
|
+
import { queueJob, flushJobs } from '../scheduler';
|
|
10
11
|
let currentComponent = null;
|
|
12
|
+
export const resolveProps = (comp, rawProps) => {
|
|
13
|
+
const props = {};
|
|
14
|
+
const declaredProps = comp.props;
|
|
15
|
+
if (rawProps) {
|
|
16
|
+
for (const key in rawProps) {
|
|
17
|
+
props[key] = rawProps[key];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (declaredProps && typeof declaredProps === 'object' && !Array.isArray(declaredProps)) {
|
|
21
|
+
for (const key in declaredProps) {
|
|
22
|
+
if (props[key] === undefined) {
|
|
23
|
+
const propDef = declaredProps[key];
|
|
24
|
+
if (propDef && typeof propDef === 'object' && 'default' in propDef) {
|
|
25
|
+
props[key] = typeof propDef.default === 'function' ? propDef.default() : propDef.default;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return props;
|
|
31
|
+
};
|
|
11
32
|
export function mountComponent(vnode, parent, options, anchor = null) {
|
|
12
33
|
const comp = vnode.tag;
|
|
13
34
|
const prevComponent = currentComponent;
|
|
14
|
-
const hmrTrigger = signal(0);
|
|
15
35
|
const instance = {
|
|
16
36
|
component: comp,
|
|
17
|
-
props: signal(vnode.props ?? {}),
|
|
37
|
+
props: signal(resolveProps(comp, vnode.props ?? {})),
|
|
18
38
|
setupState: {},
|
|
19
39
|
vnode: null,
|
|
20
40
|
mounted: false,
|
|
41
|
+
depth: prevComponent ? prevComponent.depth + 1 : 0,
|
|
42
|
+
parent: prevComponent,
|
|
43
|
+
provides: prevComponent ? Object.create(prevComponent.provides) : {},
|
|
21
44
|
lifecycle: {
|
|
22
45
|
beforeMount: [],
|
|
23
46
|
mounted: [],
|
|
@@ -26,14 +49,16 @@ export function mountComponent(vnode, parent, options, anchor = null) {
|
|
|
26
49
|
beforeUnmount: [],
|
|
27
50
|
unmounted: [],
|
|
28
51
|
},
|
|
29
|
-
update:
|
|
30
|
-
hmrTrigger.value++;
|
|
31
|
-
},
|
|
52
|
+
update: null,
|
|
32
53
|
};
|
|
33
54
|
vnode.component = instance;
|
|
34
55
|
currentComponent = instance;
|
|
35
56
|
setCurrentInstance(instance);
|
|
36
57
|
registerInstance(instance);
|
|
58
|
+
const devtools = (typeof window !== 'undefined') ? window.__NEXA_DEVTOOLS__ : null;
|
|
59
|
+
if (devtools?.registerComponent) {
|
|
60
|
+
devtools.registerComponent(comp.name || comp.__hmrId || 'Anonymous', instance);
|
|
61
|
+
}
|
|
37
62
|
const childSlots = extractSlots(vnode.children);
|
|
38
63
|
function buildSlotResult(nodes) {
|
|
39
64
|
if (nodes.length === 0)
|
|
@@ -54,15 +79,19 @@ export function mountComponent(vnode, parent, options, anchor = null) {
|
|
|
54
79
|
// Use a proxy or dynamic getters for slots to ensure they are always fresh
|
|
55
80
|
const slotsProxy = new Proxy({}, {
|
|
56
81
|
get(_, name) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
82
|
+
return (_props) => {
|
|
83
|
+
const nodes = slotsSignal.value[name] || (name === 'default' ? [] : null);
|
|
84
|
+
if (!nodes)
|
|
85
|
+
return null;
|
|
86
|
+
return buildSlotResult(nodes);
|
|
87
|
+
};
|
|
61
88
|
}
|
|
62
89
|
});
|
|
63
90
|
const setupCtx = {
|
|
64
91
|
emit: (event, ...args) => {
|
|
65
|
-
const
|
|
92
|
+
const key = `on${event[0].toUpperCase()}${event.slice(1)}`;
|
|
93
|
+
const resolvedProps = instance.props.value;
|
|
94
|
+
const handler = resolvedProps?.[key] || vnode.props?.[key];
|
|
66
95
|
if (handler)
|
|
67
96
|
handler(...args);
|
|
68
97
|
},
|
|
@@ -72,8 +101,18 @@ export function mountComponent(vnode, parent, options, anchor = null) {
|
|
|
72
101
|
let setupState = {};
|
|
73
102
|
let renderFn = comp.render;
|
|
74
103
|
let setupReturnedRender = false;
|
|
104
|
+
const propsProxy = new Proxy({}, {
|
|
105
|
+
get(_, key) {
|
|
106
|
+
track(instance.props, 'value');
|
|
107
|
+
const val = instance.props.value[key];
|
|
108
|
+
if (val && typeof val === 'object' && 'value' in val && typeof val.peek === 'function') {
|
|
109
|
+
return val.value;
|
|
110
|
+
}
|
|
111
|
+
return val;
|
|
112
|
+
}
|
|
113
|
+
});
|
|
75
114
|
if (comp.setup) {
|
|
76
|
-
const result = comp.setup(
|
|
115
|
+
const result = comp.setup(propsProxy, setupCtx);
|
|
77
116
|
if (typeof result === 'function') {
|
|
78
117
|
renderFn = result;
|
|
79
118
|
setupReturnedRender = true;
|
|
@@ -86,56 +125,100 @@ export function mountComponent(vnode, parent, options, anchor = null) {
|
|
|
86
125
|
runLifecycle(instance, 'beforeMount');
|
|
87
126
|
let el = null;
|
|
88
127
|
if (renderFn || comp.render) {
|
|
89
|
-
const ctx = {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
128
|
+
const ctx = new Proxy({}, {
|
|
129
|
+
get(_, key) {
|
|
130
|
+
if (key === 'props')
|
|
131
|
+
return instance.props.value;
|
|
132
|
+
if (key === '$slots')
|
|
133
|
+
return setupCtx.slots;
|
|
134
|
+
if (key === 'emit')
|
|
135
|
+
return setupCtx.emit;
|
|
136
|
+
if (key in setupState)
|
|
137
|
+
return setupState[key];
|
|
138
|
+
if (instance.props.value && key in instance.props.value) {
|
|
139
|
+
const val = instance.props.value[key];
|
|
140
|
+
if (val && typeof val === 'object' && 'value' in val && typeof val.peek === 'function') {
|
|
141
|
+
return val.value;
|
|
142
|
+
}
|
|
143
|
+
return val;
|
|
144
|
+
}
|
|
145
|
+
return undefined;
|
|
146
|
+
},
|
|
147
|
+
has(_, key) {
|
|
148
|
+
return key === 'props' || key === '$slots' || key === 'emit' || key in setupState || (instance.props.value && key in instance.props.value);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
instance.update = new Effect(() => {
|
|
152
|
+
const prevComp = currentComponent;
|
|
153
|
+
const prevInst = getCurrentInstance();
|
|
98
154
|
try {
|
|
155
|
+
currentComponent = instance;
|
|
156
|
+
setCurrentInstance(instance);
|
|
99
157
|
pushScope(comp.__scopeId);
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
158
|
+
let newVNode = setupReturnedRender ? renderFn(ctx) : comp.render(ctx);
|
|
159
|
+
// Normalize: wrap arrays in Fragments
|
|
160
|
+
if (Array.isArray(newVNode)) {
|
|
161
|
+
newVNode = {
|
|
162
|
+
_type: 'fragment',
|
|
163
|
+
tag: Fragment,
|
|
164
|
+
props: null,
|
|
165
|
+
children: newVNode,
|
|
166
|
+
el: null,
|
|
167
|
+
key: null,
|
|
168
|
+
component: null
|
|
169
|
+
};
|
|
170
|
+
}
|
|
103
171
|
if (!newVNode) {
|
|
104
|
-
|
|
105
|
-
return;
|
|
172
|
+
newVNode = { _type: 'text', tag: null, props: null, children: null, el: null, key: null, component: null, text: '' };
|
|
106
173
|
}
|
|
107
|
-
if (
|
|
174
|
+
if (!instance.mounted) {
|
|
108
175
|
instance.vnode = newVNode;
|
|
109
176
|
el = mount(newVNode, parent, options, anchor);
|
|
110
177
|
instance.mounted = true;
|
|
111
|
-
isFirstRender = false;
|
|
112
178
|
runLifecycle(instance, 'mounted');
|
|
179
|
+
if (instance._needsUpdate) {
|
|
180
|
+
instance._needsUpdate = false;
|
|
181
|
+
queueJob(instance);
|
|
182
|
+
flushJobs();
|
|
183
|
+
}
|
|
113
184
|
}
|
|
114
185
|
else {
|
|
115
186
|
runLifecycle(instance, 'beforeUpdate');
|
|
116
|
-
const patches = diff(
|
|
187
|
+
const patches = diff(instance.vnode, newVNode, parent);
|
|
117
188
|
applyPatches(patches, options);
|
|
118
189
|
instance.vnode = newVNode;
|
|
119
190
|
runLifecycle(instance, 'updated');
|
|
120
191
|
}
|
|
121
192
|
popScope(comp.__scopeId);
|
|
122
|
-
|
|
193
|
+
currentComponent = prevComp;
|
|
194
|
+
setCurrentInstance(prevInst);
|
|
123
195
|
}
|
|
124
196
|
catch (err) {
|
|
125
197
|
popScope(comp.__scopeId);
|
|
198
|
+
currentComponent = prevComp;
|
|
199
|
+
setCurrentInstance(prevInst);
|
|
126
200
|
const boundary = getCurrentErrorBoundary();
|
|
127
201
|
if (boundary) {
|
|
128
|
-
boundary.handleError(err
|
|
202
|
+
boundary.handleError(err);
|
|
129
203
|
}
|
|
130
204
|
else {
|
|
131
205
|
throw err;
|
|
132
206
|
}
|
|
133
207
|
}
|
|
208
|
+
}, () => {
|
|
209
|
+
if (instance.mounted) {
|
|
210
|
+
queueJob(instance);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
;
|
|
214
|
+
instance._needsUpdate = true;
|
|
215
|
+
}
|
|
134
216
|
});
|
|
217
|
+
instance.update.priority = 200;
|
|
218
|
+
instance.update.run();
|
|
135
219
|
}
|
|
136
220
|
popScope(comp.__scopeId);
|
|
137
221
|
currentComponent = prevComponent;
|
|
138
222
|
setCurrentInstance(prevComponent);
|
|
139
223
|
return el;
|
|
140
224
|
}
|
|
141
|
-
//# sourceMappingURL=mountComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mountComponent.js","sourceRoot":"","sources":["../../src/vdom/mountComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"mountComponent.js","sourceRoot":"","sources":["../../src/vdom/mountComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,EAAsC,QAAQ,EAAE,MAAM,SAAS,CAAA;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC7C,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAA;AAC7B,OAAO,EAAE,gBAAgB,EAAE,MAAM,OAAO,CAAA;AAExC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAEvC,IAAI,gBAAgB,GAA6B,IAAI,CAAA;AAErD,MAAM,UAAU,cAAc,CAC5B,KAAY,EACZ,MAAW,EACX,OAAwB,EACxB,SAAc,IAAI;IAElB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAU,CAAA;IAC7B,MAAM,aAAa,GAAG,gBAAgB,CAAA;IAEtC,MAAM,UAAU,GAAG,MAAM,CAAC,CAAC,CAAC,CAAA;IAE5B,MAAM,QAAQ,GAAsB;QAClC,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QAChC,UAAU,EAAE,EAAE;QACd,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,KA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,GAAG,aAAa,CAAA;IAChC,kBAAkB,CAAC,aAAa,CAAC,CAAA;IAEjC,OAAO,EAAE,CAAA;AACX,CAAC"}
|
package/dist/vdom/mountProps.js
CHANGED
|
@@ -5,7 +5,11 @@ export function mountProps(el, props) {
|
|
|
5
5
|
const prevProps = el._props || {};
|
|
6
6
|
el._props = { ...props };
|
|
7
7
|
for (const key of Object.keys(props)) {
|
|
8
|
-
|
|
8
|
+
let val = props[key];
|
|
9
|
+
// Unwrap signals automatically for prop bindings
|
|
10
|
+
if (val && typeof val === 'object' && 'value' in val && typeof val.peek === 'function') {
|
|
11
|
+
val = val.value;
|
|
12
|
+
}
|
|
9
13
|
if (val === prevProps[key] && key !== 'value')
|
|
10
14
|
continue; // Skip if unchanged
|
|
11
15
|
if (key === 'key')
|
|
@@ -44,10 +48,21 @@ export function mountProps(el, props) {
|
|
|
44
48
|
el.setAttribute('class', val);
|
|
45
49
|
}
|
|
46
50
|
else if (val && typeof val === 'object') {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
let classes = [];
|
|
52
|
+
if (Array.isArray(val)) {
|
|
53
|
+
for (const item of val) {
|
|
54
|
+
if (typeof item === 'string') {
|
|
55
|
+
classes.push(item);
|
|
56
|
+
}
|
|
57
|
+
else if (item && typeof item === 'object') {
|
|
58
|
+
classes.push(...Object.keys(item).filter(k => item[k]));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
classes = Object.keys(val).filter(k => val[k]);
|
|
64
|
+
}
|
|
65
|
+
el.setAttribute('class', classes.filter(Boolean).join(' '));
|
|
51
66
|
}
|
|
52
67
|
}
|
|
53
68
|
else if (key === 'style') {
|
|
@@ -65,9 +80,17 @@ export function mountProps(el, props) {
|
|
|
65
80
|
el.value = String(val);
|
|
66
81
|
}
|
|
67
82
|
else if (key === 'vShow') {
|
|
68
|
-
|
|
69
|
-
el.
|
|
70
|
-
}
|
|
83
|
+
if (el._vShowEffect) {
|
|
84
|
+
el._vShowEffect.dispose();
|
|
85
|
+
}
|
|
86
|
+
if (val) {
|
|
87
|
+
el._vShowEffect = effect(() => {
|
|
88
|
+
el.style.display = val.value ? '' : 'none';
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
delete el._vShowEffect;
|
|
93
|
+
}
|
|
71
94
|
}
|
|
72
95
|
else if (typeof val === 'boolean') {
|
|
73
96
|
if (val)
|
|
@@ -80,4 +103,3 @@ export function mountProps(el, props) {
|
|
|
80
103
|
}
|
|
81
104
|
}
|
|
82
105
|
}
|
|
83
|
-
//# sourceMappingURL=mountProps.js.map
|
package/dist/vdom/patch.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ import { type VNode, type PatchOp } from './types';
|
|
|
2
2
|
import { type RendererOptions } from './renderer';
|
|
3
3
|
export declare function applyPatches(patches: PatchOp[], options: RendererOptions): void;
|
|
4
4
|
export declare function mount(vnode: VNode | any, parent: any, options: RendererOptions, anchor?: any): any;
|
|
5
|
-
//# sourceMappingURL=patch.d.ts.map
|
package/dist/vdom/patch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../src/vdom/patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,
|
|
1
|
+
{"version":3,"file":"patch.d.ts","sourceRoot":"","sources":["../../src/vdom/patch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,KAAK,EAAE,KAAK,OAAO,EAAY,MAAM,SAAS,CAAA;AAQ5D,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD,wBAAgB,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,IAAI,CA+B/E;AAED,wBAAgB,KAAK,CACnB,KAAK,EAAE,KAAK,GAAG,GAAG,EAClB,MAAM,EAAE,GAAG,EACX,OAAO,EAAE,eAAe,EACxB,MAAM,GAAE,GAAU,GACjB,GAAG,CAoGL"}
|
package/dist/vdom/patch.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Fragment } from './types';
|
|
1
2
|
import { h } from './h';
|
|
2
|
-
import { mountComponent } from './mountComponent';
|
|
3
|
+
import { mountComponent, resolveProps } from './mountComponent';
|
|
3
4
|
import { unmount, animateLeave } from './unmount';
|
|
4
5
|
import { applyEnterClasses } from './transition';
|
|
5
6
|
import { effect, batch } from 'nexa-reactivity';
|
|
@@ -41,6 +42,17 @@ export function applyPatches(patches, options) {
|
|
|
41
42
|
export function mount(vnode, parent, options, anchor = null) {
|
|
42
43
|
if (!vnode)
|
|
43
44
|
return null;
|
|
45
|
+
if (Array.isArray(vnode)) {
|
|
46
|
+
vnode = {
|
|
47
|
+
_type: 'fragment',
|
|
48
|
+
tag: Fragment,
|
|
49
|
+
props: null,
|
|
50
|
+
children: vnode,
|
|
51
|
+
el: null,
|
|
52
|
+
key: null,
|
|
53
|
+
component: null
|
|
54
|
+
};
|
|
55
|
+
}
|
|
44
56
|
if (vnode && !vnode._type && (typeof vnode === 'object' || typeof vnode === 'function')) {
|
|
45
57
|
vnode = h(vnode, null);
|
|
46
58
|
}
|
|
@@ -80,13 +92,13 @@ export function mount(vnode, parent, options, anchor = null) {
|
|
|
80
92
|
}
|
|
81
93
|
case 'fragment': {
|
|
82
94
|
const children = vnode.children ?? [];
|
|
83
|
-
|
|
95
|
+
const anchorNode = createComment('fragment');
|
|
96
|
+
vnode.el = anchorNode;
|
|
97
|
+
insert(anchorNode, parent, anchor);
|
|
84
98
|
for (const child of children) {
|
|
85
|
-
|
|
86
|
-
if (!firstEl)
|
|
87
|
-
firstEl = childEl;
|
|
99
|
+
mount(child, parent, options, anchorNode);
|
|
88
100
|
}
|
|
89
|
-
return
|
|
101
|
+
return anchorNode;
|
|
90
102
|
}
|
|
91
103
|
case 'component': {
|
|
92
104
|
const el = mountComponent(vnode, parent, options, anchor);
|
|
@@ -108,21 +120,22 @@ export function mount(vnode, parent, options, anchor = null) {
|
|
|
108
120
|
}
|
|
109
121
|
return placeholder;
|
|
110
122
|
}
|
|
123
|
+
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
|
|
124
|
+
console.warn(`Nexa Teleport: target not found`, targetSelector);
|
|
125
|
+
}
|
|
111
126
|
return null;
|
|
112
127
|
}
|
|
113
128
|
}
|
|
114
129
|
return null;
|
|
115
130
|
}
|
|
116
|
-
function mountChildren(vnode, parent, options) {
|
|
131
|
+
function mountChildren(vnode, parent, options, anchor = null) {
|
|
117
132
|
const children = vnode.children ?? [];
|
|
118
133
|
for (const child of children) {
|
|
119
|
-
mount(child, parent, options);
|
|
134
|
+
mount(child, parent, options, anchor);
|
|
120
135
|
}
|
|
121
136
|
}
|
|
122
137
|
function replaceNode(oldV, newV, parent, options, anchor) {
|
|
123
|
-
|
|
124
|
-
unmount(oldV, parent, options);
|
|
125
|
-
}
|
|
138
|
+
unmount(oldV, parent, options);
|
|
126
139
|
mount(newV, parent, options, anchor);
|
|
127
140
|
}
|
|
128
141
|
function updateNode(vnode, options) {
|
|
@@ -141,7 +154,9 @@ function updateNode(vnode, options) {
|
|
|
141
154
|
const instance = vnode.component;
|
|
142
155
|
if (instance) {
|
|
143
156
|
batch(() => {
|
|
144
|
-
instance.props
|
|
157
|
+
if (instance.props) {
|
|
158
|
+
instance.props.value = resolveProps(instance.component, vnode.props ?? {});
|
|
159
|
+
}
|
|
145
160
|
if (instance.slots) {
|
|
146
161
|
instance.slots.value = extractSlots(vnode.children);
|
|
147
162
|
}
|
|
@@ -149,4 +164,3 @@ function updateNode(vnode, options) {
|
|
|
149
164
|
}
|
|
150
165
|
}
|
|
151
166
|
}
|
|
152
|
-
//# sourceMappingURL=patch.js.map
|
package/dist/vdom/patch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"patch.js","sourceRoot":"","sources":["../../src/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AAE,CAAC;YAChB,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;gBAC9B,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAA;YAClD,CAAC;QACH,CAAC;IACH,CAAC;SAAM,IAAI,KAAK,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;QACvC,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAA;QAChC,IAAI,QAAQ,EAAE,CAAC;YACb,KAAK,CAAC,GAAG,EAAE;gBACT,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACnB,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAA;gBAC1C,CAAC;gBACD,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;oBACnB,QAAQ,CAAC,KAAK,CAAC,KAAK,GAAG,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;gBACrD,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/vdom/renderer.d.ts
CHANGED
package/dist/vdom/renderer.js
CHANGED
package/dist/vdom/scope.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ export declare function pushScope(scopeId: string | undefined): void;
|
|
|
2
2
|
export declare function popScope(scopeId: string | undefined): void;
|
|
3
3
|
export declare function currentScope(): string | undefined;
|
|
4
4
|
export declare function injectStyle(id: string, css: string): void;
|
|
5
|
-
//# sourceMappingURL=scope.d.ts.map
|
package/dist/vdom/scope.js
CHANGED
package/dist/vdom/slots.d.ts
CHANGED
package/dist/vdom/slots.js
CHANGED
|
@@ -5,8 +5,15 @@ export function extractSlots(children) {
|
|
|
5
5
|
const slotName = child.props?.slot || 'default';
|
|
6
6
|
if (!childSlots[slotName])
|
|
7
7
|
childSlots[slotName] = [];
|
|
8
|
-
|
|
8
|
+
if (child._type === 'element' && child.tag === 'template') {
|
|
9
|
+
const templateChildren = child.children ?? [];
|
|
10
|
+
for (const templateChild of templateChildren) {
|
|
11
|
+
childSlots[slotName].push(templateChild);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
childSlots[slotName].push(child);
|
|
16
|
+
}
|
|
9
17
|
}
|
|
10
18
|
return childSlots;
|
|
11
19
|
}
|
|
12
|
-
//# sourceMappingURL=slots.js.map
|
|
@@ -13,4 +13,3 @@ export type TransitionProps = {
|
|
|
13
13
|
export declare function applyEnterClasses(vnode: VNode, name: string): void;
|
|
14
14
|
export declare function applyLeaveClasses(vnode: VNode, name: string): Promise<void>;
|
|
15
15
|
export declare function isTransitionVNode(vnode: VNode): boolean;
|
|
16
|
-
//# sourceMappingURL=transition.d.ts.map
|
package/dist/vdom/transition.js
CHANGED
package/dist/vdom/types.d.ts
CHANGED
|
@@ -18,8 +18,11 @@ export type ComponentInstance = {
|
|
|
18
18
|
vnode: VNode | null;
|
|
19
19
|
mounted: boolean;
|
|
20
20
|
lifecycle: LifecycleHooks;
|
|
21
|
-
update:
|
|
21
|
+
update: any;
|
|
22
22
|
slots?: any;
|
|
23
|
+
depth: number;
|
|
24
|
+
parent: ComponentInstance | null;
|
|
25
|
+
provides: Record<string | symbol, any>;
|
|
23
26
|
};
|
|
24
27
|
export type LifecycleHooks = {
|
|
25
28
|
beforeMount: (() => void)[];
|
|
@@ -53,4 +56,3 @@ export type VNode = {
|
|
|
53
56
|
};
|
|
54
57
|
export declare const Fragment: unique symbol;
|
|
55
58
|
export declare const Teleport: unique symbol;
|
|
56
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/vdom/types.js
CHANGED
package/dist/vdom/unmount.d.ts
CHANGED
|
@@ -2,4 +2,3 @@ import { type VNode } from './types';
|
|
|
2
2
|
import { type RendererOptions } from './renderer';
|
|
3
3
|
export declare function unmount(vnode: VNode, parent: any, options: RendererOptions): void;
|
|
4
4
|
export declare function animateLeave(vnode: VNode, _parent: any, nameOrTrue: string | true, options: RendererOptions): void;
|
|
5
|
-
//# sourceMappingURL=unmount.d.ts.map
|
package/dist/vdom/unmount.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
1
|
import { runLifecycle } from '../component/lifecycle';
|
|
2
2
|
import { unregisterInstance } from './hmr';
|
|
3
3
|
export function unmount(vnode, parent, options) {
|
|
4
|
-
if (vnode
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
if (vnode.el) {
|
|
8
|
-
if (vnode._type === 'text' || vnode._type === 'element') {
|
|
9
|
-
options.remove(vnode.el);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const children = vnode.children ?? [];
|
|
13
|
-
if (vnode._type === 'teleport') {
|
|
14
|
-
const targetSelector = vnode.props?.to;
|
|
15
|
-
const target = typeof targetSelector === 'string'
|
|
16
|
-
? options.querySelector(targetSelector)
|
|
17
|
-
: targetSelector;
|
|
18
|
-
for (const child of children) {
|
|
19
|
-
unmount(child, target || parent, options);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
for (const child of children) {
|
|
24
|
-
unmount(child, parent, options);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
4
|
+
if (!vnode)
|
|
5
|
+
return;
|
|
27
6
|
if (vnode._type === 'component') {
|
|
28
7
|
const instance = vnode.component;
|
|
8
|
+
runLifecycle(instance, 'beforeUnmount');
|
|
9
|
+
const devtools = typeof window !== 'undefined' && window.__NEXA_DEVTOOLS__;
|
|
10
|
+
devtools?.unregisterComponent(instance);
|
|
29
11
|
if (instance.vnode) {
|
|
30
12
|
unmount(instance.vnode, parent, options);
|
|
31
13
|
}
|
|
32
14
|
unregisterInstance(instance);
|
|
33
15
|
runLifecycle(instance, 'unmounted');
|
|
34
16
|
vnode.component = null;
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
// Remove the physical element/node
|
|
20
|
+
if (vnode.el) {
|
|
21
|
+
if (vnode.el._vShowEffect) {
|
|
22
|
+
vnode.el._vShowEffect.dispose();
|
|
23
|
+
delete vnode.el._vShowEffect;
|
|
24
|
+
}
|
|
25
|
+
options.remove(vnode.el);
|
|
26
|
+
}
|
|
27
|
+
// Fragments and Teleports need to unmount their children explicitly
|
|
28
|
+
// because they don't have a single wrapping DOM element that removes everything.
|
|
29
|
+
if (vnode._type === 'fragment' || vnode._type === 'teleport' || vnode._type === 'element') {
|
|
30
|
+
const children = vnode.children ?? [];
|
|
31
|
+
const target = vnode._type === 'teleport'
|
|
32
|
+
? (typeof vnode.props?.to === 'string' ? options.querySelector(vnode.props.to) : vnode.props?.to)
|
|
33
|
+
: parent;
|
|
34
|
+
for (const child of children) {
|
|
35
|
+
unmount(child, target || parent, options);
|
|
36
|
+
}
|
|
35
37
|
}
|
|
36
38
|
}
|
|
37
39
|
export function animateLeave(vnode, _parent, nameOrTrue, options) {
|
|
@@ -59,4 +61,3 @@ export function animateLeave(vnode, _parent, nameOrTrue, options) {
|
|
|
59
61
|
el.classList.add(`${name}-leave-to`);
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
|
-
//# sourceMappingURL=unmount.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexa-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"nexa-reactivity": "0.
|
|
16
|
+
"nexa-reactivity": "0.6.0"
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineComponent.d.ts","sourceRoot":"","sources":["../../src/component/defineComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,SAAS,CAE/D"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defineComponent.js","sourceRoot":"","sources":["../../src/component/defineComponent.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,eAAe,CAAC,SAAoB;IAClD,OAAO,SAAS,CAAA;AAClB,CAAC"}
|