nexa-runtime 0.6.4 → 0.7.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.
@@ -59,7 +59,33 @@ export function mountComponent(vnode, parent, options, anchor = null) {
59
59
  if (devtools?.registerComponent) {
60
60
  devtools.registerComponent(comp.name || comp.__hmrId || 'Anonymous', instance);
61
61
  }
62
- const childSlots = extractSlots(vnode.children);
62
+ let childSlots = {};
63
+ if (vnode.children && typeof vnode.children === 'object' && !Array.isArray(vnode.children) && !vnode.children._type) {
64
+ childSlots = vnode.children;
65
+ }
66
+ else if (Array.isArray(vnode.children) && vnode.children.length === 1 && typeof vnode.children[0] === 'object' && !vnode.children[0]._type) {
67
+ childSlots = vnode.children[0];
68
+ }
69
+ else {
70
+ childSlots = extractSlots(vnode.children);
71
+ }
72
+ const slotsSignal = signal(childSlots);
73
+ // Use a proxy or dynamic getters for slots to ensure they are always fresh
74
+ const slotsProxy = new Proxy({}, {
75
+ get(_, name) {
76
+ if (name === 'value')
77
+ return slotsSignal.value;
78
+ return (props) => {
79
+ const slotData = slotsSignal.value[name] || (name === 'default' && slotsSignal.value.default ? slotsSignal.value.default : null);
80
+ if (!slotData)
81
+ return null;
82
+ if (typeof slotData === 'function') {
83
+ return slotData(props);
84
+ }
85
+ return buildSlotResult(slotData);
86
+ };
87
+ }
88
+ });
63
89
  function buildSlotResult(nodes) {
64
90
  if (nodes.length === 0)
65
91
  return null;
@@ -75,18 +101,6 @@ export function mountComponent(vnode, parent, options, anchor = null) {
75
101
  component: null,
76
102
  };
77
103
  }
78
- const slotsSignal = signal(childSlots);
79
- // Use a proxy or dynamic getters for slots to ensure they are always fresh
80
- const slotsProxy = new Proxy({}, {
81
- get(_, name) {
82
- return (_props) => {
83
- const nodes = slotsSignal.value[name] || (name === 'default' ? [] : null);
84
- if (!nodes)
85
- return null;
86
- return buildSlotResult(nodes);
87
- };
88
- }
89
- });
90
104
  const setupCtx = {
91
105
  emit: (event, ...args) => {
92
106
  const key = `on${event[0].toUpperCase()}${event.slice(1)}`;
@@ -158,7 +158,17 @@ function updateNode(vnode, options) {
158
158
  instance.props.value = resolveProps(instance.component, vnode.props ?? {});
159
159
  }
160
160
  if (instance.slots) {
161
- instance.slots.value = extractSlots(vnode.children);
161
+ let childSlots = {};
162
+ if (vnode.children && typeof vnode.children === 'object' && !Array.isArray(vnode.children) && !vnode.children._type) {
163
+ childSlots = vnode.children;
164
+ }
165
+ else if (Array.isArray(vnode.children) && vnode.children.length === 1 && typeof vnode.children[0] === 'object' && !vnode.children[0]._type) {
166
+ childSlots = vnode.children[0];
167
+ }
168
+ else {
169
+ childSlots = extractSlots(vnode.children);
170
+ }
171
+ instance.slots.value = childSlots;
162
172
  }
163
173
  });
164
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nexa-runtime",
3
- "version": "0.6.4",
3
+ "version": "0.7.1",
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.6.4"
16
+ "nexa-reactivity": "0.7.1"
17
17
  },
18
18
  "files": [
19
19
  "dist"