@creact-labs/creact 0.2.7 → 0.2.8

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.
@@ -121,9 +121,23 @@ export function useInstance(construct, props) {
121
121
  outputSignals: new Map(),
122
122
  children: [],
123
123
  setOutputs(outputs) {
124
- // Clear ownership before batch triggers re-renders
125
- // When signals update, components re-execute and create new fibers
126
- // that need to claim the same nodeIds
124
+ // First check if any values actually changed
125
+ let hasChanges = false;
126
+ for (const [key, value] of Object.entries(outputs)) {
127
+ if (!this.outputSignals.has(key)) {
128
+ hasChanges = true;
129
+ break;
130
+ }
131
+ const [read] = this.outputSignals.get(key);
132
+ if (!shallowEqual(read(), value)) {
133
+ hasChanges = true;
134
+ break;
135
+ }
136
+ }
137
+ // Early exit if nothing changed - no re-render needed
138
+ if (!hasChanges)
139
+ return;
140
+ // Only clear ownership and batch if there are actual changes
127
141
  nodeOwnership.clear();
128
142
  batch(() => {
129
143
  for (const [key, value] of Object.entries(outputs)) {
@@ -132,7 +146,6 @@ export function useInstance(construct, props) {
132
146
  }
133
147
  else {
134
148
  const [read, write] = this.outputSignals.get(key);
135
- // Only update if value actually changed
136
149
  if (!shallowEqual(read(), value)) {
137
150
  write(value);
138
151
  }
@@ -214,15 +227,28 @@ export function fillInstanceOutputs(nodeId, outputs) {
214
227
  const node = nodeRegistry.get(nodeId);
215
228
  if (!node)
216
229
  return;
217
- // Clear ownership before batch triggers re-renders
218
- // When signals update, components re-execute and create new fibers
219
- // that need to claim the same nodeIds
230
+ // First check if any values actually changed
231
+ let hasChanges = false;
232
+ for (const [key, value] of Object.entries(outputs)) {
233
+ if (!node.outputSignals.has(key)) {
234
+ hasChanges = true;
235
+ break;
236
+ }
237
+ const [read] = node.outputSignals.get(key);
238
+ if (!shallowEqual(read(), value)) {
239
+ hasChanges = true;
240
+ break;
241
+ }
242
+ }
243
+ // Early exit if nothing changed - no re-render needed
244
+ if (!hasChanges)
245
+ return;
246
+ // Only clear ownership and batch if there are actual changes
220
247
  nodeOwnership.clear();
221
248
  batch(() => {
222
249
  for (const [key, value] of Object.entries(outputs)) {
223
250
  if (node.outputSignals.has(key)) {
224
251
  const [read, write] = node.outputSignals.get(key);
225
- // Only update if value actually changed
226
252
  if (!shallowEqual(read(), value)) {
227
253
  write(value);
228
254
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@creact-labs/creact",
3
- "version": "0.2.7",
3
+ "version": "0.2.8",
4
4
  "type": "module",
5
5
  "description": "Declarative universal reactive runtime",
6
6
  "main": "dist/index.js",