@async/framework 0.11.2 → 0.11.4

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/browser.ts CHANGED
@@ -186,6 +186,10 @@ const __asyncSignalModule = (() => {
186
186
  };
187
187
  },
188
188
 
189
+ _cloneSignalDeclaration() {
190
+ return asyncSignal(id, fn);
191
+ },
192
+
189
193
  _restore(snapshot = {}) {
190
194
  if (!isAsyncSignalSnapshot(snapshot)) {
191
195
  return state.set(snapshot);
@@ -957,7 +961,12 @@ const __cacheModule = (() => {
957
961
  return registryStore.entries(`${type}.entries`);
958
962
  },
959
963
 
960
- _adoptMany() {
964
+ _adoptMany(map = {}) {
965
+ for (const [id, definition] of Object.entries(map ?? {})) {
966
+ if (!definitions.has(id)) {
967
+ registryApi.register(id, definition);
968
+ }
969
+ }
961
970
  return registryApi;
962
971
  }
963
972
  }, registryStore, type);
@@ -1115,6 +1124,10 @@ const __signalsModule = (() => {
1115
1124
 
1116
1125
  snapshot() {
1117
1126
  return value;
1127
+ },
1128
+
1129
+ _cloneSignalDeclaration() {
1130
+ return createSignal(value);
1118
1131
  }
1119
1132
  };
1120
1133
 
@@ -1157,6 +1170,10 @@ const __signalsModule = (() => {
1157
1170
  return backing.snapshot();
1158
1171
  },
1159
1172
 
1173
+ _cloneSignalDeclaration() {
1174
+ return computed(fn);
1175
+ },
1176
+
1160
1177
  _bindRegistry(registry, id) {
1161
1178
  return registry.effect(() => {
1162
1179
  backing.set(fn.call({
@@ -1181,6 +1198,9 @@ const __signalsModule = (() => {
1181
1198
  [effectKind]: true,
1182
1199
  kind: "effect",
1183
1200
  fn,
1201
+ _cloneSignalDeclaration() {
1202
+ return effect(fn);
1203
+ },
1184
1204
  _bindRegistry(registry) {
1185
1205
  return registry.effect(fn);
1186
1206
  }
@@ -1389,6 +1409,24 @@ const __signalsModule = (() => {
1389
1409
  return requireEntry(entries, id);
1390
1410
  },
1391
1411
 
1412
+ _setPath(path, value) {
1413
+ const parsed = parseRootPath(path);
1414
+ if (!entries.has(parsed.id)) {
1415
+ if (asyncDescriptors.has(parsed.id)) {
1416
+ materializeAsyncSignal(parsed.id);
1417
+ } else {
1418
+ registry.register(parsed.id, createSignal(parsed.parts.length === 0 ? value : {}));
1419
+ }
1420
+ }
1421
+ const entry = requireEntry(entries, parsed.id);
1422
+ if (parsed.parts.length === 0) {
1423
+ return entry.set(value);
1424
+ }
1425
+ const nextValue = setPath(entry.value, parsed.parts, value);
1426
+ entry.set(nextValue);
1427
+ return value;
1428
+ },
1429
+
1392
1430
  _setContext(context = {}) {
1393
1431
  Object.assign(runtimeContext, context);
1394
1432
  return registry;
@@ -1399,10 +1437,14 @@ const __signalsModule = (() => {
1399
1437
  },
1400
1438
 
1401
1439
  _adoptMany(map = {}) {
1402
- for (const id of Object.keys(map ?? {})) {
1403
- if (entries.has(id)) {
1404
- bindEntry(id, entries.get(id));
1440
+ for (const [id, signalLike] of Object.entries(map ?? {})) {
1441
+ if (!entries.has(id)) {
1442
+ const entry = cloneSignalDeclaration(signalLike);
1443
+ entries.set(id, entry);
1444
+ bindEntry(id, entry);
1445
+ continue;
1405
1446
  }
1447
+ bindEntry(id, entries.get(id));
1406
1448
  }
1407
1449
  return registry;
1408
1450
  }
@@ -1441,6 +1483,14 @@ const __signalsModule = (() => {
1441
1483
  return { id, parts, path };
1442
1484
  }
1443
1485
 
1486
+ function parseRootPath(path) {
1487
+ if (typeof path !== "string" || path.length === 0) {
1488
+ throw new TypeError("Signal path must be a non-empty string.");
1489
+ }
1490
+ const [id, ...parts] = path.split(".");
1491
+ return { id, parts, path };
1492
+ }
1493
+
1444
1494
  function materializeAsyncSignal(id) {
1445
1495
  if (entries.has(id) || !asyncDescriptors.has(id)) {
1446
1496
  return;
@@ -1480,6 +1530,16 @@ const __signalsModule = (() => {
1480
1530
  return createSignal(signalLike);
1481
1531
  }
1482
1532
 
1533
+ function cloneSignalDeclaration(signalLike) {
1534
+ if (typeof signalLike?._cloneSignalDeclaration === "function") {
1535
+ return signalLike._cloneSignalDeclaration();
1536
+ }
1537
+ if (isSignalLike(signalLike)) {
1538
+ return createSignal(typeof signalLike.snapshot === "function" ? signalLike.snapshot() : signalLike.value);
1539
+ }
1540
+ return createSignal(signalLike);
1541
+ }
1542
+
1483
1543
  function isSignalLike(value) {
1484
1544
  return Boolean(value && typeof value === "object" && typeof value.subscribe === "function");
1485
1545
  }
@@ -1658,7 +1718,7 @@ const __signalsModule = (() => {
1658
1718
  frame.add(path);
1659
1719
  }
1660
1720
  }
1661
- return { createSignal, computed, effect, createSignalRegistry, isSignalRef, signal };
1721
+ return { createSignal, computed, effect, createSignalRegistry, cloneSignalDeclaration, isSignalRef, signal };
1662
1722
  })();
1663
1723
 
1664
1724
  const __htmlModule = (() => {
@@ -1900,7 +1960,12 @@ const __componentModule = (() => {
1900
1960
  return lazyComponents.get(id);
1901
1961
  },
1902
1962
 
1903
- _adoptMany() {
1963
+ _adoptMany(map = {}) {
1964
+ for (const [id, Component] of Object.entries(map ?? {})) {
1965
+ if (!entries.has(id)) {
1966
+ registry.register(id, Component);
1967
+ }
1968
+ }
1904
1969
  return registry;
1905
1970
  }
1906
1971
  }, registryStore, type);
@@ -2740,7 +2805,12 @@ const __handlersModule = (() => {
2740
2805
  return results;
2741
2806
  },
2742
2807
 
2743
- _adoptMany() {
2808
+ _adoptMany(map = {}) {
2809
+ for (const [id, fn] of Object.entries(map ?? {})) {
2810
+ if (!handlers.has(id)) {
2811
+ registry.register(id, fn);
2812
+ }
2813
+ }
2744
2814
  return registry;
2745
2815
  }
2746
2816
  }, registryStore, type);
@@ -4029,7 +4099,12 @@ const __partialsModule = (() => {
4029
4099
  return normalizePartialResult(result, partialContext);
4030
4100
  },
4031
4101
 
4032
- _adoptMany() {
4102
+ _adoptMany(map = {}) {
4103
+ for (const [id, fn] of Object.entries(map ?? {})) {
4104
+ if (!entries.has(id)) {
4105
+ registry.register(id, fn);
4106
+ }
4107
+ }
4033
4108
  return registry;
4034
4109
  }
4035
4110
  }, registryStore, type);
@@ -4181,7 +4256,11 @@ const __routerModule = (() => {
4181
4256
  },
4182
4257
 
4183
4258
  _adoptMany(map = {}) {
4184
- for (const pattern of Object.keys(map ?? {})) {
4259
+ for (const [pattern, definition] of Object.entries(map ?? {})) {
4260
+ if (!entries.has(pattern)) {
4261
+ registry.register(pattern, definition);
4262
+ continue;
4263
+ }
4185
4264
  adoptRoute(pattern, entries.get(pattern));
4186
4265
  }
4187
4266
  return registry;
@@ -4677,7 +4756,7 @@ const __appModule = (() => {
4677
4756
  const { createRouteRegistry, createRouter } = __routerModule;
4678
4757
  const { createScheduler } = __schedulerModule;
4679
4758
  const { createServerNamespace } = __serverModule;
4680
- const { createSignal, createSignalRegistry } = __signalsModule;
4759
+ const { cloneSignalDeclaration, createSignal, createSignalRegistry } = __signalsModule;
4681
4760
  const { createRegistryStore } = __registryStoreModule;
4682
4761
  const { attributeName, normalizeAttributeConfig } = __attributesModule;
4683
4762
  const { createLazyRegistry, defineRegistrySnapshot, sameRegistryValue } = __lazyRegistryModule;
@@ -4760,7 +4839,7 @@ const __appModule = (() => {
4760
4839
  registryAssets: options.registryAssets,
4761
4840
  importModule: options.importModule
4762
4841
  });
4763
- const registry = options.registry ?? app.registry.view({ target });
4842
+ const registry = options.registry ?? createRuntimeRegistry(app.registry, { target });
4764
4843
  const signals = options.signals ?? createSignalRegistry(undefined, { registry, type: "signal", lazyRegistry });
4765
4844
  const handlers = options.handlers ?? createHandlerRegistry(undefined, { registry, type: "handler", lazyRegistry });
4766
4845
  const serverCache = createCacheRegistry(undefined, { registry, type: "cache.server" });
@@ -4952,7 +5031,7 @@ const __appModule = (() => {
4952
5031
 
4953
5032
  if (result.signals) {
4954
5033
  for (const [path, value] of Object.entries(result.signals)) {
4955
- setOrRegisterSignal(signals, path, value);
5034
+ applySignalPatch(signals, path, value);
4956
5035
  }
4957
5036
  }
4958
5037
  if (result.cache?.browser) {
@@ -5141,6 +5220,22 @@ const __appModule = (() => {
5141
5220
  registry?.registerMany?.(entries);
5142
5221
  }
5143
5222
 
5223
+ function createRuntimeRegistry(appRegistry, { target } = {}) {
5224
+ const declarations = appRegistry.rawSnapshot();
5225
+ return createRegistryStore({
5226
+ ...declarations,
5227
+ signal: cloneSignalDeclarations(declarations.signal)
5228
+ }, { target });
5229
+ }
5230
+
5231
+ function cloneSignalDeclarations(signals = {}) {
5232
+ const cloned = {};
5233
+ for (const [id, signalLike] of Object.entries(signals ?? {})) {
5234
+ cloned[id] = cloneSignalDeclaration(signalLike);
5235
+ }
5236
+ return cloned;
5237
+ }
5238
+
5144
5239
  function emptyDeclarations() {
5145
5240
  return {
5146
5241
  signal: {},
@@ -5214,8 +5309,9 @@ const __appModule = (() => {
5214
5309
 
5215
5310
  function applySnapshotToRuntime(runtime, snapshot = {}, options = {}) {
5216
5311
  const normalized = normalizeSnapshot(snapshot);
5217
- for (const [path, value] of Object.entries(normalized.signal)) {
5218
- setOrRegisterSignal(runtime.signals, path, value);
5312
+ mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5313
+ for (const [id, value] of Object.entries(normalized.signal)) {
5314
+ restoreSignalEntry(runtime.signals, id, value);
5219
5315
  }
5220
5316
  runtime.browser.cache.restore(normalized.cache.browser);
5221
5317
  mergeRegistryEntries(runtime, "handler", normalized.handler, runtime.handlers, options);
@@ -5223,7 +5319,6 @@ const __appModule = (() => {
5223
5319
  mergeRegistryEntries(runtime, "partial", normalized.partial, runtime.partials, options);
5224
5320
  mergeRegistryEntries(runtime, "route", normalized.route, runtime.routes, options);
5225
5321
  mergeRegistryEntries(runtime, "component", normalized.component, runtime.components, options);
5226
- mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5227
5322
  return runtime;
5228
5323
  }
5229
5324
 
@@ -5329,16 +5424,26 @@ const __appModule = (() => {
5329
5424
  }
5330
5425
  }
5331
5426
 
5332
- function setOrRegisterSignal(signals, path, value) {
5333
- const id = String(path).split(".")[0];
5427
+ function restoreSignalEntry(signals, id, value) {
5334
5428
  if (signals.has?.(id)) {
5335
- if (path === id) {
5336
- const entry = signals._entry?.(id);
5337
- if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5338
- entry._restore(value);
5339
- return;
5340
- }
5429
+ const entry = signals._entry?.(id);
5430
+ if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5431
+ entry._restore(value);
5432
+ return;
5341
5433
  }
5434
+ signals.set(id, value);
5435
+ return;
5436
+ }
5437
+ signals.register(id, createSignal(value));
5438
+ }
5439
+
5440
+ function applySignalPatch(signals, path, value) {
5441
+ if (typeof signals._setPath === "function") {
5442
+ signals._setPath(path, value);
5443
+ return;
5444
+ }
5445
+ const id = String(path).split(".")[0];
5446
+ if (signals.has?.(id)) {
5342
5447
  signals.set(path, value);
5343
5448
  return;
5344
5449
  }
package/browser.umd.js CHANGED
@@ -196,6 +196,10 @@
196
196
  };
197
197
  },
198
198
 
199
+ _cloneSignalDeclaration() {
200
+ return asyncSignal(id, fn);
201
+ },
202
+
199
203
  _restore(snapshot = {}) {
200
204
  if (!isAsyncSignalSnapshot(snapshot)) {
201
205
  return state.set(snapshot);
@@ -967,7 +971,12 @@
967
971
  return registryStore.entries(`${type}.entries`);
968
972
  },
969
973
 
970
- _adoptMany() {
974
+ _adoptMany(map = {}) {
975
+ for (const [id, definition] of Object.entries(map ?? {})) {
976
+ if (!definitions.has(id)) {
977
+ registryApi.register(id, definition);
978
+ }
979
+ }
971
980
  return registryApi;
972
981
  }
973
982
  }, registryStore, type);
@@ -1125,6 +1134,10 @@
1125
1134
 
1126
1135
  snapshot() {
1127
1136
  return value;
1137
+ },
1138
+
1139
+ _cloneSignalDeclaration() {
1140
+ return createSignal(value);
1128
1141
  }
1129
1142
  };
1130
1143
 
@@ -1167,6 +1180,10 @@
1167
1180
  return backing.snapshot();
1168
1181
  },
1169
1182
 
1183
+ _cloneSignalDeclaration() {
1184
+ return computed(fn);
1185
+ },
1186
+
1170
1187
  _bindRegistry(registry, id) {
1171
1188
  return registry.effect(() => {
1172
1189
  backing.set(fn.call({
@@ -1191,6 +1208,9 @@
1191
1208
  [effectKind]: true,
1192
1209
  kind: "effect",
1193
1210
  fn,
1211
+ _cloneSignalDeclaration() {
1212
+ return effect(fn);
1213
+ },
1194
1214
  _bindRegistry(registry) {
1195
1215
  return registry.effect(fn);
1196
1216
  }
@@ -1399,6 +1419,24 @@
1399
1419
  return requireEntry(entries, id);
1400
1420
  },
1401
1421
 
1422
+ _setPath(path, value) {
1423
+ const parsed = parseRootPath(path);
1424
+ if (!entries.has(parsed.id)) {
1425
+ if (asyncDescriptors.has(parsed.id)) {
1426
+ materializeAsyncSignal(parsed.id);
1427
+ } else {
1428
+ registry.register(parsed.id, createSignal(parsed.parts.length === 0 ? value : {}));
1429
+ }
1430
+ }
1431
+ const entry = requireEntry(entries, parsed.id);
1432
+ if (parsed.parts.length === 0) {
1433
+ return entry.set(value);
1434
+ }
1435
+ const nextValue = setPath(entry.value, parsed.parts, value);
1436
+ entry.set(nextValue);
1437
+ return value;
1438
+ },
1439
+
1402
1440
  _setContext(context = {}) {
1403
1441
  Object.assign(runtimeContext, context);
1404
1442
  return registry;
@@ -1409,10 +1447,14 @@
1409
1447
  },
1410
1448
 
1411
1449
  _adoptMany(map = {}) {
1412
- for (const id of Object.keys(map ?? {})) {
1413
- if (entries.has(id)) {
1414
- bindEntry(id, entries.get(id));
1450
+ for (const [id, signalLike] of Object.entries(map ?? {})) {
1451
+ if (!entries.has(id)) {
1452
+ const entry = cloneSignalDeclaration(signalLike);
1453
+ entries.set(id, entry);
1454
+ bindEntry(id, entry);
1455
+ continue;
1415
1456
  }
1457
+ bindEntry(id, entries.get(id));
1416
1458
  }
1417
1459
  return registry;
1418
1460
  }
@@ -1451,6 +1493,14 @@
1451
1493
  return { id, parts, path };
1452
1494
  }
1453
1495
 
1496
+ function parseRootPath(path) {
1497
+ if (typeof path !== "string" || path.length === 0) {
1498
+ throw new TypeError("Signal path must be a non-empty string.");
1499
+ }
1500
+ const [id, ...parts] = path.split(".");
1501
+ return { id, parts, path };
1502
+ }
1503
+
1454
1504
  function materializeAsyncSignal(id) {
1455
1505
  if (entries.has(id) || !asyncDescriptors.has(id)) {
1456
1506
  return;
@@ -1490,6 +1540,16 @@
1490
1540
  return createSignal(signalLike);
1491
1541
  }
1492
1542
 
1543
+ function cloneSignalDeclaration(signalLike) {
1544
+ if (typeof signalLike?._cloneSignalDeclaration === "function") {
1545
+ return signalLike._cloneSignalDeclaration();
1546
+ }
1547
+ if (isSignalLike(signalLike)) {
1548
+ return createSignal(typeof signalLike.snapshot === "function" ? signalLike.snapshot() : signalLike.value);
1549
+ }
1550
+ return createSignal(signalLike);
1551
+ }
1552
+
1493
1553
  function isSignalLike(value) {
1494
1554
  return Boolean(value && typeof value === "object" && typeof value.subscribe === "function");
1495
1555
  }
@@ -1668,7 +1728,7 @@
1668
1728
  frame.add(path);
1669
1729
  }
1670
1730
  }
1671
- return { createSignal, computed, effect, createSignalRegistry, isSignalRef, signal };
1731
+ return { createSignal, computed, effect, createSignalRegistry, cloneSignalDeclaration, isSignalRef, signal };
1672
1732
  })();
1673
1733
 
1674
1734
  const __htmlModule = (() => {
@@ -1910,7 +1970,12 @@
1910
1970
  return lazyComponents.get(id);
1911
1971
  },
1912
1972
 
1913
- _adoptMany() {
1973
+ _adoptMany(map = {}) {
1974
+ for (const [id, Component] of Object.entries(map ?? {})) {
1975
+ if (!entries.has(id)) {
1976
+ registry.register(id, Component);
1977
+ }
1978
+ }
1914
1979
  return registry;
1915
1980
  }
1916
1981
  }, registryStore, type);
@@ -2750,7 +2815,12 @@
2750
2815
  return results;
2751
2816
  },
2752
2817
 
2753
- _adoptMany() {
2818
+ _adoptMany(map = {}) {
2819
+ for (const [id, fn] of Object.entries(map ?? {})) {
2820
+ if (!handlers.has(id)) {
2821
+ registry.register(id, fn);
2822
+ }
2823
+ }
2754
2824
  return registry;
2755
2825
  }
2756
2826
  }, registryStore, type);
@@ -4039,7 +4109,12 @@
4039
4109
  return normalizePartialResult(result, partialContext);
4040
4110
  },
4041
4111
 
4042
- _adoptMany() {
4112
+ _adoptMany(map = {}) {
4113
+ for (const [id, fn] of Object.entries(map ?? {})) {
4114
+ if (!entries.has(id)) {
4115
+ registry.register(id, fn);
4116
+ }
4117
+ }
4043
4118
  return registry;
4044
4119
  }
4045
4120
  }, registryStore, type);
@@ -4191,7 +4266,11 @@
4191
4266
  },
4192
4267
 
4193
4268
  _adoptMany(map = {}) {
4194
- for (const pattern of Object.keys(map ?? {})) {
4269
+ for (const [pattern, definition] of Object.entries(map ?? {})) {
4270
+ if (!entries.has(pattern)) {
4271
+ registry.register(pattern, definition);
4272
+ continue;
4273
+ }
4195
4274
  adoptRoute(pattern, entries.get(pattern));
4196
4275
  }
4197
4276
  return registry;
@@ -4687,7 +4766,7 @@
4687
4766
  const { createRouteRegistry, createRouter } = __routerModule;
4688
4767
  const { createScheduler } = __schedulerModule;
4689
4768
  const { createServerNamespace } = __serverModule;
4690
- const { createSignal, createSignalRegistry } = __signalsModule;
4769
+ const { cloneSignalDeclaration, createSignal, createSignalRegistry } = __signalsModule;
4691
4770
  const { createRegistryStore } = __registryStoreModule;
4692
4771
  const { attributeName, normalizeAttributeConfig } = __attributesModule;
4693
4772
  const { createLazyRegistry, defineRegistrySnapshot, sameRegistryValue } = __lazyRegistryModule;
@@ -4770,7 +4849,7 @@
4770
4849
  registryAssets: options.registryAssets,
4771
4850
  importModule: options.importModule
4772
4851
  });
4773
- const registry = options.registry ?? app.registry.view({ target });
4852
+ const registry = options.registry ?? createRuntimeRegistry(app.registry, { target });
4774
4853
  const signals = options.signals ?? createSignalRegistry(undefined, { registry, type: "signal", lazyRegistry });
4775
4854
  const handlers = options.handlers ?? createHandlerRegistry(undefined, { registry, type: "handler", lazyRegistry });
4776
4855
  const serverCache = createCacheRegistry(undefined, { registry, type: "cache.server" });
@@ -4962,7 +5041,7 @@
4962
5041
 
4963
5042
  if (result.signals) {
4964
5043
  for (const [path, value] of Object.entries(result.signals)) {
4965
- setOrRegisterSignal(signals, path, value);
5044
+ applySignalPatch(signals, path, value);
4966
5045
  }
4967
5046
  }
4968
5047
  if (result.cache?.browser) {
@@ -5151,6 +5230,22 @@
5151
5230
  registry?.registerMany?.(entries);
5152
5231
  }
5153
5232
 
5233
+ function createRuntimeRegistry(appRegistry, { target } = {}) {
5234
+ const declarations = appRegistry.rawSnapshot();
5235
+ return createRegistryStore({
5236
+ ...declarations,
5237
+ signal: cloneSignalDeclarations(declarations.signal)
5238
+ }, { target });
5239
+ }
5240
+
5241
+ function cloneSignalDeclarations(signals = {}) {
5242
+ const cloned = {};
5243
+ for (const [id, signalLike] of Object.entries(signals ?? {})) {
5244
+ cloned[id] = cloneSignalDeclaration(signalLike);
5245
+ }
5246
+ return cloned;
5247
+ }
5248
+
5154
5249
  function emptyDeclarations() {
5155
5250
  return {
5156
5251
  signal: {},
@@ -5224,8 +5319,9 @@
5224
5319
 
5225
5320
  function applySnapshotToRuntime(runtime, snapshot = {}, options = {}) {
5226
5321
  const normalized = normalizeSnapshot(snapshot);
5227
- for (const [path, value] of Object.entries(normalized.signal)) {
5228
- setOrRegisterSignal(runtime.signals, path, value);
5322
+ mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5323
+ for (const [id, value] of Object.entries(normalized.signal)) {
5324
+ restoreSignalEntry(runtime.signals, id, value);
5229
5325
  }
5230
5326
  runtime.browser.cache.restore(normalized.cache.browser);
5231
5327
  mergeRegistryEntries(runtime, "handler", normalized.handler, runtime.handlers, options);
@@ -5233,7 +5329,6 @@
5233
5329
  mergeRegistryEntries(runtime, "partial", normalized.partial, runtime.partials, options);
5234
5330
  mergeRegistryEntries(runtime, "route", normalized.route, runtime.routes, options);
5235
5331
  mergeRegistryEntries(runtime, "component", normalized.component, runtime.components, options);
5236
- mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5237
5332
  return runtime;
5238
5333
  }
5239
5334
 
@@ -5339,16 +5434,26 @@
5339
5434
  }
5340
5435
  }
5341
5436
 
5342
- function setOrRegisterSignal(signals, path, value) {
5343
- const id = String(path).split(".")[0];
5437
+ function restoreSignalEntry(signals, id, value) {
5344
5438
  if (signals.has?.(id)) {
5345
- if (path === id) {
5346
- const entry = signals._entry?.(id);
5347
- if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5348
- entry._restore(value);
5349
- return;
5350
- }
5439
+ const entry = signals._entry?.(id);
5440
+ if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5441
+ entry._restore(value);
5442
+ return;
5351
5443
  }
5444
+ signals.set(id, value);
5445
+ return;
5446
+ }
5447
+ signals.register(id, createSignal(value));
5448
+ }
5449
+
5450
+ function applySignalPatch(signals, path, value) {
5451
+ if (typeof signals._setPath === "function") {
5452
+ signals._setPath(path, value);
5453
+ return;
5454
+ }
5455
+ const id = String(path).split(".")[0];
5456
+ if (signals.has?.(id)) {
5352
5457
  signals.set(path, value);
5353
5458
  return;
5354
5459
  }