@async/framework 0.11.3 → 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/framework.ts CHANGED
@@ -1411,6 +1411,24 @@ const __signalsModule = (() => {
1411
1411
  return requireEntry(entries, id);
1412
1412
  },
1413
1413
 
1414
+ _setPath(path, value) {
1415
+ const parsed = parseRootPath(path);
1416
+ if (!entries.has(parsed.id)) {
1417
+ if (asyncDescriptors.has(parsed.id)) {
1418
+ materializeAsyncSignal(parsed.id);
1419
+ } else {
1420
+ registry.register(parsed.id, createSignal(parsed.parts.length === 0 ? value : {}));
1421
+ }
1422
+ }
1423
+ const entry = requireEntry(entries, parsed.id);
1424
+ if (parsed.parts.length === 0) {
1425
+ return entry.set(value);
1426
+ }
1427
+ const nextValue = setPath(entry.value, parsed.parts, value);
1428
+ entry.set(nextValue);
1429
+ return value;
1430
+ },
1431
+
1414
1432
  _setContext(context = {}) {
1415
1433
  Object.assign(runtimeContext, context);
1416
1434
  return registry;
@@ -1467,6 +1485,14 @@ const __signalsModule = (() => {
1467
1485
  return { id, parts, path };
1468
1486
  }
1469
1487
 
1488
+ function parseRootPath(path) {
1489
+ if (typeof path !== "string" || path.length === 0) {
1490
+ throw new TypeError("Signal path must be a non-empty string.");
1491
+ }
1492
+ const [id, ...parts] = path.split(".");
1493
+ return { id, parts, path };
1494
+ }
1495
+
1470
1496
  function materializeAsyncSignal(id) {
1471
1497
  if (entries.has(id) || !asyncDescriptors.has(id)) {
1472
1498
  return;
@@ -5007,7 +5033,7 @@ const __appModule = (() => {
5007
5033
 
5008
5034
  if (result.signals) {
5009
5035
  for (const [path, value] of Object.entries(result.signals)) {
5010
- setOrRegisterSignal(signals, path, value);
5036
+ applySignalPatch(signals, path, value);
5011
5037
  }
5012
5038
  }
5013
5039
  if (result.cache?.browser) {
@@ -5285,8 +5311,9 @@ const __appModule = (() => {
5285
5311
 
5286
5312
  function applySnapshotToRuntime(runtime, snapshot = {}, options = {}) {
5287
5313
  const normalized = normalizeSnapshot(snapshot);
5288
- for (const [path, value] of Object.entries(normalized.signal)) {
5289
- setOrRegisterSignal(runtime.signals, path, value);
5314
+ mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5315
+ for (const [id, value] of Object.entries(normalized.signal)) {
5316
+ restoreSignalEntry(runtime.signals, id, value);
5290
5317
  }
5291
5318
  runtime.browser.cache.restore(normalized.cache.browser);
5292
5319
  mergeRegistryEntries(runtime, "handler", normalized.handler, runtime.handlers, options);
@@ -5294,7 +5321,6 @@ const __appModule = (() => {
5294
5321
  mergeRegistryEntries(runtime, "partial", normalized.partial, runtime.partials, options);
5295
5322
  mergeRegistryEntries(runtime, "route", normalized.route, runtime.routes, options);
5296
5323
  mergeRegistryEntries(runtime, "component", normalized.component, runtime.components, options);
5297
- mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5298
5324
  return runtime;
5299
5325
  }
5300
5326
 
@@ -5400,16 +5426,26 @@ const __appModule = (() => {
5400
5426
  }
5401
5427
  }
5402
5428
 
5403
- function setOrRegisterSignal(signals, path, value) {
5404
- const id = String(path).split(".")[0];
5429
+ function restoreSignalEntry(signals, id, value) {
5405
5430
  if (signals.has?.(id)) {
5406
- if (path === id) {
5407
- const entry = signals._entry?.(id);
5408
- if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5409
- entry._restore(value);
5410
- return;
5411
- }
5431
+ const entry = signals._entry?.(id);
5432
+ if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5433
+ entry._restore(value);
5434
+ return;
5412
5435
  }
5436
+ signals.set(id, value);
5437
+ return;
5438
+ }
5439
+ signals.register(id, createSignal(value));
5440
+ }
5441
+
5442
+ function applySignalPatch(signals, path, value) {
5443
+ if (typeof signals._setPath === "function") {
5444
+ signals._setPath(path, value);
5445
+ return;
5446
+ }
5447
+ const id = String(path).split(".")[0];
5448
+ if (signals.has?.(id)) {
5413
5449
  signals.set(path, value);
5414
5450
  return;
5415
5451
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@async/framework",
3
- "version": "0.11.3",
3
+ "version": "0.11.4",
4
4
  "description": "No-build Loader app runtime with browser and server entrypoints, signals, command events, route partials, cache split, SSR activation, and streaming boundaries.",
5
5
  "type": "module",
6
6
  "main": "./server.js",
package/server.js CHANGED
@@ -1410,6 +1410,24 @@ const __signalsModule = (() => {
1410
1410
  return requireEntry(entries, id);
1411
1411
  },
1412
1412
 
1413
+ _setPath(path, value) {
1414
+ const parsed = parseRootPath(path);
1415
+ if (!entries.has(parsed.id)) {
1416
+ if (asyncDescriptors.has(parsed.id)) {
1417
+ materializeAsyncSignal(parsed.id);
1418
+ } else {
1419
+ registry.register(parsed.id, createSignal(parsed.parts.length === 0 ? value : {}));
1420
+ }
1421
+ }
1422
+ const entry = requireEntry(entries, parsed.id);
1423
+ if (parsed.parts.length === 0) {
1424
+ return entry.set(value);
1425
+ }
1426
+ const nextValue = setPath(entry.value, parsed.parts, value);
1427
+ entry.set(nextValue);
1428
+ return value;
1429
+ },
1430
+
1413
1431
  _setContext(context = {}) {
1414
1432
  Object.assign(runtimeContext, context);
1415
1433
  return registry;
@@ -1466,6 +1484,14 @@ const __signalsModule = (() => {
1466
1484
  return { id, parts, path };
1467
1485
  }
1468
1486
 
1487
+ function parseRootPath(path) {
1488
+ if (typeof path !== "string" || path.length === 0) {
1489
+ throw new TypeError("Signal path must be a non-empty string.");
1490
+ }
1491
+ const [id, ...parts] = path.split(".");
1492
+ return { id, parts, path };
1493
+ }
1494
+
1469
1495
  function materializeAsyncSignal(id) {
1470
1496
  if (entries.has(id) || !asyncDescriptors.has(id)) {
1471
1497
  return;
@@ -5006,7 +5032,7 @@ const __appModule = (() => {
5006
5032
 
5007
5033
  if (result.signals) {
5008
5034
  for (const [path, value] of Object.entries(result.signals)) {
5009
- setOrRegisterSignal(signals, path, value);
5035
+ applySignalPatch(signals, path, value);
5010
5036
  }
5011
5037
  }
5012
5038
  if (result.cache?.browser) {
@@ -5284,8 +5310,9 @@ const __appModule = (() => {
5284
5310
 
5285
5311
  function applySnapshotToRuntime(runtime, snapshot = {}, options = {}) {
5286
5312
  const normalized = normalizeSnapshot(snapshot);
5287
- for (const [path, value] of Object.entries(normalized.signal)) {
5288
- setOrRegisterSignal(runtime.signals, path, value);
5313
+ mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5314
+ for (const [id, value] of Object.entries(normalized.signal)) {
5315
+ restoreSignalEntry(runtime.signals, id, value);
5289
5316
  }
5290
5317
  runtime.browser.cache.restore(normalized.cache.browser);
5291
5318
  mergeRegistryEntries(runtime, "handler", normalized.handler, runtime.handlers, options);
@@ -5293,7 +5320,6 @@ const __appModule = (() => {
5293
5320
  mergeRegistryEntries(runtime, "partial", normalized.partial, runtime.partials, options);
5294
5321
  mergeRegistryEntries(runtime, "route", normalized.route, runtime.routes, options);
5295
5322
  mergeRegistryEntries(runtime, "component", normalized.component, runtime.components, options);
5296
- mergeRegistryEntries(runtime, "asyncSignal", normalized.asyncSignal, null, options);
5297
5323
  return runtime;
5298
5324
  }
5299
5325
 
@@ -5399,16 +5425,26 @@ const __appModule = (() => {
5399
5425
  }
5400
5426
  }
5401
5427
 
5402
- function setOrRegisterSignal(signals, path, value) {
5403
- const id = String(path).split(".")[0];
5428
+ function restoreSignalEntry(signals, id, value) {
5404
5429
  if (signals.has?.(id)) {
5405
- if (path === id) {
5406
- const entry = signals._entry?.(id);
5407
- if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5408
- entry._restore(value);
5409
- return;
5410
- }
5430
+ const entry = signals._entry?.(id);
5431
+ if (typeof entry?._restore === "function" && isAsyncSignalSnapshot(value)) {
5432
+ entry._restore(value);
5433
+ return;
5411
5434
  }
5435
+ signals.set(id, value);
5436
+ return;
5437
+ }
5438
+ signals.register(id, createSignal(value));
5439
+ }
5440
+
5441
+ function applySignalPatch(signals, path, value) {
5442
+ if (typeof signals._setPath === "function") {
5443
+ signals._setPath(path, value);
5444
+ return;
5445
+ }
5446
+ const id = String(path).split(".")[0];
5447
+ if (signals.has?.(id)) {
5412
5448
  signals.set(path, value);
5413
5449
  return;
5414
5450
  }