@absolutejs/absolute 0.19.0-beta.381 → 0.19.0-beta.382

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/dist/index.js CHANGED
@@ -180058,7 +180058,9 @@ var getStreamSwapRuntimeScript = () => `(function(){${stripFunctionWrapper(strea
180058
180058
  init_escapeScriptContent();
180059
180059
  var SLOT_ID_PREFIX = "abs-slot-";
180060
180060
  var SLOT_PLACEHOLDER_PREFIX = "slot-";
180061
+ var CLOSING_BODY_TAG = "</body>";
180061
180062
  var CLOSING_HEAD_TAG = "</head>";
180063
+ var CLOSING_BODY_TAG_LENGTH = CLOSING_BODY_TAG.length;
180062
180064
  var CLOSING_HEAD_TAG_LENGTH = CLOSING_HEAD_TAG.length;
180063
180065
  var CLOSING_PAGE_TAG_REGEX = /<\/body>\s*<\/html>\s*$/i;
180064
180066
  var STREAMING_RUNTIME_GLOBAL = "__ABS_SLOT_ENQUEUE__";
@@ -180082,6 +180084,13 @@ var injectHtmlIntoHead = (html, injection) => {
180082
180084
  }
180083
180085
  return `${html}${injection}`;
180084
180086
  };
180087
+ var injectHtmlIntoBody = (html, injection) => {
180088
+ const closingBodyIndex = html.indexOf(CLOSING_BODY_TAG);
180089
+ if (closingBodyIndex >= 0) {
180090
+ return `${html.slice(0, closingBodyIndex)}${injection}${html.slice(closingBodyIndex)}`;
180091
+ }
180092
+ return `${html}${injection}`;
180093
+ };
180085
180094
  var toUint8 = (value, encoder) => encoder.encode(value);
180086
180095
  var currentStreamingSlotPolicy = {
180087
180096
  timeoutMs: STREAMING_SLOT_TIMEOUT_MS,
@@ -180346,11 +180355,12 @@ var streamOutOfOrderSlots = ({
180346
180355
  }
180347
180356
  });
180348
180357
  };
180349
- var injectStreamingRuntimeIntoStream = (stream, nonce) => {
180358
+ var injectStreamingRuntimeIntoStream = (stream, nonce, runtimePlacement = "head") => {
180350
180359
  const runtimeTag = renderStreamingSlotsRuntimeTag(nonce);
180351
180360
  const encoder = new TextEncoder;
180352
180361
  const decoder = new TextDecoder;
180353
- const lookbehind = CLOSING_HEAD_TAG_LENGTH - 1;
180362
+ const closingTag = runtimePlacement === "body" ? CLOSING_BODY_TAG : CLOSING_HEAD_TAG;
180363
+ const lookbehind = (runtimePlacement === "body" ? CLOSING_BODY_TAG_LENGTH : CLOSING_HEAD_TAG_LENGTH) - 1;
180354
180364
  return new ReadableStream({
180355
180365
  async start(controller) {
180356
180366
  const reader = stream.getReader();
@@ -180369,9 +180379,9 @@ var injectStreamingRuntimeIntoStream = (stream, nonce) => {
180369
180379
  pending = "";
180370
180380
  continue;
180371
180381
  }
180372
- const headIndex = pending.indexOf(CLOSING_HEAD_TAG);
180373
- if (headIndex >= 0) {
180374
- const withRuntime = `${pending.slice(0, headIndex)}${runtimeTag}${pending.slice(headIndex)}`;
180382
+ const closingTagIndex = pending.indexOf(closingTag);
180383
+ if (closingTagIndex >= 0) {
180384
+ const withRuntime = `${pending.slice(0, closingTagIndex)}${runtimeTag}${pending.slice(closingTagIndex)}`;
180375
180385
  controller.enqueue(encoder.encode(withRuntime));
180376
180386
  pending = "";
180377
180387
  injected = true;
@@ -180385,7 +180395,7 @@ var injectStreamingRuntimeIntoStream = (stream, nonce) => {
180385
180395
  }
180386
180396
  pending += decoder.decode();
180387
180397
  if (!injected) {
180388
- pending = injectHtmlIntoHead(pending, runtimeTag);
180398
+ pending = runtimePlacement === "body" ? injectHtmlIntoBody(pending, runtimeTag) : injectHtmlIntoHead(pending, runtimeTag);
180389
180399
  }
180390
180400
  if (pending.length > 0) {
180391
180401
  controller.enqueue(encoder.encode(pending));
@@ -180402,7 +180412,8 @@ var appendStreamingSlotPatchesToStream = (stream, slots = [], {
180402
180412
  nonce,
180403
180413
  onError,
180404
180414
  onSlotMetric,
180405
- policy
180415
+ policy,
180416
+ runtimePlacement = "head"
180406
180417
  } = {}) => {
180407
180418
  const resolvedPolicy = resolveStreamingSlotPolicy(policy);
180408
180419
  const combinedOnError = createCombinedSlotErrorHandler(resolvedPolicy.onError, onError);
@@ -180419,7 +180430,7 @@ var appendStreamingSlotPatchesToStream = (stream, slots = [], {
180419
180430
  });
180420
180431
  if (preparedSlots.length === 0)
180421
180432
  return stream;
180422
- const source = injectRuntime ? injectStreamingRuntimeIntoStream(stream, nonce) : stream;
180433
+ const source = injectRuntime ? injectStreamingRuntimeIntoStream(stream, nonce, runtimePlacement) : stream;
180423
180434
  const encoder = new TextEncoder;
180424
180435
  const decoder = new TextDecoder;
180425
180436
  const reader = source.getReader();
@@ -180538,7 +180549,7 @@ var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
180538
180549
  };
180539
180550
 
180540
180551
  // src/core/wrapPageHandlerWithStreamingSlots.ts
180541
- var wrapPageHandlerWithStreamingSlots = (handler) => (...args) => withRegisteredStreamingSlots(() => handler(...args));
180552
+ var wrapPageHandlerWithStreamingSlots = (handler, options) => (...args) => withRegisteredStreamingSlots(() => handler(...args), options);
180542
180553
 
180543
180554
  // src/react/index.ts
180544
180555
  init_pageHandler();
@@ -187387,6 +187398,7 @@ export {
187387
187398
  isIslandComponentDefinition,
187388
187399
  injectStreamingRuntimeIntoStream,
187389
187400
  injectHtmlIntoHead,
187401
+ injectHtmlIntoBody,
187390
187402
  hmrState,
187391
187403
  handleReactPageRequest2 as handleReactPageRequest,
187392
187404
  handleHTMXPageRequest,
@@ -187465,5 +187477,5 @@ export {
187465
187477
  ANGULAR_INIT_TIMEOUT_MS
187466
187478
  };
187467
187479
 
187468
- //# debugId=1700989D577CE61D64756E2164756E21
187480
+ //# debugId=2C0A56D9102CF6B564756E2164756E21
187469
187481
  //# sourceMappingURL=index.js.map