@async/framework 0.11.11 → 0.11.12

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
@@ -5984,101 +5984,25 @@ const __boundaryReceiverModule = (() => {
5984
5984
 
5985
5985
  const normalized = validatePatch(patch);
5986
5986
  const record = boundaryRecord(normalized.boundary);
5987
- if (normalized.seq <= record.lastSeq) {
5988
- const result = {
5989
- status: "ignored-stale",
5990
- boundary: normalized.boundary,
5991
- seq: normalized.seq,
5992
- lastSeq: record.lastSeq
5993
- };
5994
- record.ignored += 1;
5995
- record.lastStatus = result.status;
5996
- remember(result);
5997
- onIgnore?.(result, patch);
5998
- return result;
5999
- }
6000
-
6001
- if (normalized.parentScope !== undefined && isScopeDestroyed(normalized.parentScope)) {
6002
- const result = {
6003
- status: "ignored-destroyed",
6004
- boundary: normalized.boundary,
6005
- seq: normalized.seq,
6006
- parentScope: normalized.parentScope
6007
- };
6008
- record.ignored += 1;
6009
- record.lastStatus = result.status;
6010
- remember(result);
6011
- onIgnore?.(result, patch);
6012
- return result;
6013
- }
6014
-
6015
- record.lastSeq = normalized.seq;
6016
-
6017
- if (Object.hasOwn(normalized, "error")) {
6018
- const error = toStableError(normalized.error);
6019
- const result = {
6020
- status: "errored",
6021
- boundary: normalized.boundary,
6022
- seq: normalized.seq,
6023
- error
6024
- };
6025
- record.errored += 1;
6026
- record.lastStatus = result.status;
6027
- remember(result);
6028
- onError?.(error, result, patch);
6029
- if (throwOnError) {
6030
- throw error;
6031
- }
6032
- return result;
6033
- }
5987
+ let releasePending;
5988
+ const previousPending = record.pending ?? Promise.resolve();
5989
+ const pending = new Promise((resolve) => {
5990
+ releasePending = resolve;
5991
+ });
5992
+ record.pending = pending;
6034
5993
 
6035
- if (normalized.signals) {
6036
- if (!signals || typeof signals.set !== "function") {
6037
- throw new Error("Boundary patch includes signals, but no signal registry is available.");
6038
- }
6039
- for (const [path, value] of Object.entries(normalized.signals)) {
6040
- signals.set(path, value);
5994
+ try {
5995
+ await previousPending;
5996
+ if (destroyed) {
5997
+ throw new Error("Boundary receiver has been destroyed.");
6041
5998
  }
6042
- }
6043
-
6044
- if (normalized.cache?.browser) {
6045
- if (!cache || typeof cache.restore !== "function") {
6046
- throw new Error("Boundary patch includes browser cache, but no cache registry is available.");
5999
+ return await applyBoundaryPatch(record, normalized, patch);
6000
+ } finally {
6001
+ releasePending();
6002
+ if (record.pending === pending) {
6003
+ record.pending = undefined;
6047
6004
  }
6048
- cache.restore(normalized.cache.browser);
6049
- }
6050
-
6051
- if (normalized.html != null) {
6052
- loader.swap(normalized.boundary, normalized.html);
6053
- }
6054
-
6055
- await flushScheduler(scheduler, normalized.scope);
6056
-
6057
- if (normalized.redirect) {
6058
- await followRedirect(normalized.redirect, router, loader);
6059
- const result = {
6060
- status: "redirected",
6061
- boundary: normalized.boundary,
6062
- seq: normalized.seq,
6063
- redirect: normalized.redirect
6064
- };
6065
- record.applied += 1;
6066
- record.lastStatus = result.status;
6067
- remember(result);
6068
- onApply?.(result, patch);
6069
- return result;
6070
6005
  }
6071
-
6072
- const result = {
6073
- status: "applied",
6074
- boundary: normalized.boundary,
6075
- seq: normalized.seq
6076
- };
6077
- record.applied += 1;
6078
- record.lastStatus = result.status;
6079
- remember(result);
6080
- onApply?.(result, patch);
6081
- return result;
6082
6006
  },
6083
6007
 
6084
6008
  inspect() {
@@ -6126,6 +6050,105 @@ const __boundaryReceiverModule = (() => {
6126
6050
 
6127
6051
  return receiver;
6128
6052
 
6053
+ async function applyBoundaryPatch(record, normalized, patch) {
6054
+ if (normalized.seq <= record.lastSeq) {
6055
+ const result = {
6056
+ status: "ignored-stale",
6057
+ boundary: normalized.boundary,
6058
+ seq: normalized.seq,
6059
+ lastSeq: record.lastSeq
6060
+ };
6061
+ record.ignored += 1;
6062
+ record.lastStatus = result.status;
6063
+ remember(result);
6064
+ onIgnore?.(result, patch);
6065
+ return result;
6066
+ }
6067
+
6068
+ if (normalized.parentScope !== undefined && isScopeDestroyed(normalized.parentScope)) {
6069
+ const result = {
6070
+ status: "ignored-destroyed",
6071
+ boundary: normalized.boundary,
6072
+ seq: normalized.seq,
6073
+ parentScope: normalized.parentScope
6074
+ };
6075
+ record.ignored += 1;
6076
+ record.lastStatus = result.status;
6077
+ remember(result);
6078
+ onIgnore?.(result, patch);
6079
+ return result;
6080
+ }
6081
+
6082
+ if (Object.hasOwn(normalized, "error")) {
6083
+ const error = toStableError(normalized.error);
6084
+ const result = {
6085
+ status: "errored",
6086
+ boundary: normalized.boundary,
6087
+ seq: normalized.seq,
6088
+ error
6089
+ };
6090
+ record.lastSeq = normalized.seq;
6091
+ record.errored += 1;
6092
+ record.lastStatus = result.status;
6093
+ remember(result);
6094
+ onError?.(error, result, patch);
6095
+ if (throwOnError) {
6096
+ throw error;
6097
+ }
6098
+ return result;
6099
+ }
6100
+
6101
+ if (normalized.signals) {
6102
+ if (!signals || typeof signals.set !== "function") {
6103
+ throw new Error("Boundary patch includes signals, but no signal registry is available.");
6104
+ }
6105
+ for (const [path, value] of Object.entries(normalized.signals)) {
6106
+ signals.set(path, value);
6107
+ }
6108
+ }
6109
+
6110
+ if (normalized.cache?.browser) {
6111
+ if (!cache || typeof cache.restore !== "function") {
6112
+ throw new Error("Boundary patch includes browser cache, but no cache registry is available.");
6113
+ }
6114
+ cache.restore(normalized.cache.browser);
6115
+ }
6116
+
6117
+ if (normalized.html != null) {
6118
+ loader.swap(normalized.boundary, normalized.html);
6119
+ }
6120
+
6121
+ await flushScheduler(scheduler, normalized.scope);
6122
+
6123
+ if (normalized.redirect) {
6124
+ const result = {
6125
+ status: "redirected",
6126
+ boundary: normalized.boundary,
6127
+ seq: normalized.seq,
6128
+ redirect: normalized.redirect
6129
+ };
6130
+ await followRedirect(normalized.redirect, router, loader);
6131
+ record.applied += 1;
6132
+ record.lastSeq = normalized.seq;
6133
+ record.lastStatus = result.status;
6134
+ remember(result);
6135
+ onApply?.(result, patch);
6136
+ return result;
6137
+ }
6138
+
6139
+ const result = {
6140
+ status: "applied",
6141
+ boundary: normalized.boundary,
6142
+ seq: normalized.seq
6143
+ };
6144
+ record.applied += 1;
6145
+ record.lastSeq = normalized.seq;
6146
+ record.lastStatus = result.status;
6147
+ remember(result);
6148
+ onApply?.(result, patch);
6149
+ return result;
6150
+ }
6151
+
6129
6152
  function boundaryRecord(boundary) {
6130
6153
  if (!boundaries.has(boundary)) {
6131
6154
  boundaries.set(boundary, {
@@ -6133,7 +6156,8 @@ const __boundaryReceiverModule = (() => {
6133
6156
  applied: 0,
6134
6157
  ignored: 0,
6135
6158
  errored: 0,
6136
- lastStatus: undefined
6159
+ lastStatus: undefined,
6160
+ pending: undefined
6137
6161
  });
6138
6162
  }
6139
6163
  return boundaries.get(boundary);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@async/framework",
3
- "version": "0.11.11",
3
+ "version": "0.11.12",
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
@@ -5983,101 +5983,25 @@ const __boundaryReceiverModule = (() => {
5983
5983
 
5984
5984
  const normalized = validatePatch(patch);
5985
5985
  const record = boundaryRecord(normalized.boundary);
5986
- if (normalized.seq <= record.lastSeq) {
5987
- const result = {
5988
- status: "ignored-stale",
5989
- boundary: normalized.boundary,
5990
- seq: normalized.seq,
5991
- lastSeq: record.lastSeq
5992
- };
5993
- record.ignored += 1;
5994
- record.lastStatus = result.status;
5995
- remember(result);
5996
- onIgnore?.(result, patch);
5997
- return result;
5998
- }
5999
-
6000
- if (normalized.parentScope !== undefined && isScopeDestroyed(normalized.parentScope)) {
6001
- const result = {
6002
- status: "ignored-destroyed",
6003
- boundary: normalized.boundary,
6004
- seq: normalized.seq,
6005
- parentScope: normalized.parentScope
6006
- };
6007
- record.ignored += 1;
6008
- record.lastStatus = result.status;
6009
- remember(result);
6010
- onIgnore?.(result, patch);
6011
- return result;
6012
- }
6013
-
6014
- record.lastSeq = normalized.seq;
6015
-
6016
- if (Object.hasOwn(normalized, "error")) {
6017
- const error = toStableError(normalized.error);
6018
- const result = {
6019
- status: "errored",
6020
- boundary: normalized.boundary,
6021
- seq: normalized.seq,
6022
- error
6023
- };
6024
- record.errored += 1;
6025
- record.lastStatus = result.status;
6026
- remember(result);
6027
- onError?.(error, result, patch);
6028
- if (throwOnError) {
6029
- throw error;
6030
- }
6031
- return result;
6032
- }
5986
+ let releasePending;
5987
+ const previousPending = record.pending ?? Promise.resolve();
5988
+ const pending = new Promise((resolve) => {
5989
+ releasePending = resolve;
5990
+ });
5991
+ record.pending = pending;
6033
5992
 
6034
- if (normalized.signals) {
6035
- if (!signals || typeof signals.set !== "function") {
6036
- throw new Error("Boundary patch includes signals, but no signal registry is available.");
6037
- }
6038
- for (const [path, value] of Object.entries(normalized.signals)) {
6039
- signals.set(path, value);
5993
+ try {
5994
+ await previousPending;
5995
+ if (destroyed) {
5996
+ throw new Error("Boundary receiver has been destroyed.");
6040
5997
  }
6041
- }
6042
-
6043
- if (normalized.cache?.browser) {
6044
- if (!cache || typeof cache.restore !== "function") {
6045
- throw new Error("Boundary patch includes browser cache, but no cache registry is available.");
5998
+ return await applyBoundaryPatch(record, normalized, patch);
5999
+ } finally {
6000
+ releasePending();
6001
+ if (record.pending === pending) {
6002
+ record.pending = undefined;
6046
6003
  }
6047
- cache.restore(normalized.cache.browser);
6048
- }
6049
-
6050
- if (normalized.html != null) {
6051
- loader.swap(normalized.boundary, normalized.html);
6052
- }
6053
-
6054
- await flushScheduler(scheduler, normalized.scope);
6055
-
6056
- if (normalized.redirect) {
6057
- await followRedirect(normalized.redirect, router, loader);
6058
- const result = {
6059
- status: "redirected",
6060
- boundary: normalized.boundary,
6061
- seq: normalized.seq,
6062
- redirect: normalized.redirect
6063
- };
6064
- record.applied += 1;
6065
- record.lastStatus = result.status;
6066
- remember(result);
6067
- onApply?.(result, patch);
6068
- return result;
6069
6004
  }
6070
-
6071
- const result = {
6072
- status: "applied",
6073
- boundary: normalized.boundary,
6074
- seq: normalized.seq
6075
- };
6076
- record.applied += 1;
6077
- record.lastStatus = result.status;
6078
- remember(result);
6079
- onApply?.(result, patch);
6080
- return result;
6081
6005
  },
6082
6006
 
6083
6007
  inspect() {
@@ -6125,6 +6049,105 @@ const __boundaryReceiverModule = (() => {
6125
6049
 
6126
6050
  return receiver;
6127
6051
 
6052
+ async function applyBoundaryPatch(record, normalized, patch) {
6053
+ if (normalized.seq <= record.lastSeq) {
6054
+ const result = {
6055
+ status: "ignored-stale",
6056
+ boundary: normalized.boundary,
6057
+ seq: normalized.seq,
6058
+ lastSeq: record.lastSeq
6059
+ };
6060
+ record.ignored += 1;
6061
+ record.lastStatus = result.status;
6062
+ remember(result);
6063
+ onIgnore?.(result, patch);
6064
+ return result;
6065
+ }
6066
+
6067
+ if (normalized.parentScope !== undefined && isScopeDestroyed(normalized.parentScope)) {
6068
+ const result = {
6069
+ status: "ignored-destroyed",
6070
+ boundary: normalized.boundary,
6071
+ seq: normalized.seq,
6072
+ parentScope: normalized.parentScope
6073
+ };
6074
+ record.ignored += 1;
6075
+ record.lastStatus = result.status;
6076
+ remember(result);
6077
+ onIgnore?.(result, patch);
6078
+ return result;
6079
+ }
6080
+
6081
+ if (Object.hasOwn(normalized, "error")) {
6082
+ const error = toStableError(normalized.error);
6083
+ const result = {
6084
+ status: "errored",
6085
+ boundary: normalized.boundary,
6086
+ seq: normalized.seq,
6087
+ error
6088
+ };
6089
+ record.lastSeq = normalized.seq;
6090
+ record.errored += 1;
6091
+ record.lastStatus = result.status;
6092
+ remember(result);
6093
+ onError?.(error, result, patch);
6094
+ if (throwOnError) {
6095
+ throw error;
6096
+ }
6097
+ return result;
6098
+ }
6099
+
6100
+ if (normalized.signals) {
6101
+ if (!signals || typeof signals.set !== "function") {
6102
+ throw new Error("Boundary patch includes signals, but no signal registry is available.");
6103
+ }
6104
+ for (const [path, value] of Object.entries(normalized.signals)) {
6105
+ signals.set(path, value);
6106
+ }
6107
+ }
6108
+
6109
+ if (normalized.cache?.browser) {
6110
+ if (!cache || typeof cache.restore !== "function") {
6111
+ throw new Error("Boundary patch includes browser cache, but no cache registry is available.");
6112
+ }
6113
+ cache.restore(normalized.cache.browser);
6114
+ }
6115
+
6116
+ if (normalized.html != null) {
6117
+ loader.swap(normalized.boundary, normalized.html);
6118
+ }
6119
+
6120
+ await flushScheduler(scheduler, normalized.scope);
6121
+
6122
+ if (normalized.redirect) {
6123
+ const result = {
6124
+ status: "redirected",
6125
+ boundary: normalized.boundary,
6126
+ seq: normalized.seq,
6127
+ redirect: normalized.redirect
6128
+ };
6129
+ await followRedirect(normalized.redirect, router, loader);
6130
+ record.applied += 1;
6131
+ record.lastSeq = normalized.seq;
6132
+ record.lastStatus = result.status;
6133
+ remember(result);
6134
+ onApply?.(result, patch);
6135
+ return result;
6136
+ }
6137
+
6138
+ const result = {
6139
+ status: "applied",
6140
+ boundary: normalized.boundary,
6141
+ seq: normalized.seq
6142
+ };
6143
+ record.applied += 1;
6144
+ record.lastSeq = normalized.seq;
6145
+ record.lastStatus = result.status;
6146
+ remember(result);
6147
+ onApply?.(result, patch);
6148
+ return result;
6149
+ }
6150
+
6128
6151
  function boundaryRecord(boundary) {
6129
6152
  if (!boundaries.has(boundary)) {
6130
6153
  boundaries.set(boundary, {
@@ -6132,7 +6155,8 @@ const __boundaryReceiverModule = (() => {
6132
6155
  applied: 0,
6133
6156
  ignored: 0,
6134
6157
  errored: 0,
6135
- lastStatus: undefined
6158
+ lastStatus: undefined,
6159
+ pending: undefined
6136
6160
  });
6137
6161
  }
6138
6162
  return boundaries.get(boundary);