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

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
@@ -173232,7 +173232,7 @@ ${registrations}
173232
173232
  ({ tsLibDir } = cached);
173233
173233
  cached.lastUsed = Date.now();
173234
173234
  } else {
173235
- const tsPath = __require.resolve("/home/alexkahn/abs/absolutejs/node_modules/typescript/lib/typescript.js");
173235
+ const tsPath = __require.resolve("typescript");
173236
173236
  const tsRootDir = dirname9(tsPath);
173237
173237
  tsLibDir = tsRootDir.endsWith("lib") ? tsRootDir : resolve18(tsRootDir, "lib");
173238
173238
  const config = readConfiguration("./tsconfig.json");
@@ -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();
@@ -180504,14 +180515,21 @@ var cloneHeaders = (response) => {
180504
180515
  const headers = new Headers(response.headers);
180505
180516
  return headers;
180506
180517
  };
180507
- var enhanceHtmlResponseWithStreamingSlots = (response, { nonce, onError, streamingSlots = [], policy } = {}) => {
180518
+ var enhanceHtmlResponseWithStreamingSlots = (response, {
180519
+ nonce,
180520
+ onError,
180521
+ runtimePlacement,
180522
+ streamingSlots = [],
180523
+ policy
180524
+ } = {}) => {
180508
180525
  if (!response.body || streamingSlots.length === 0) {
180509
180526
  return response;
180510
180527
  }
180511
180528
  const body = appendStreamingSlotPatchesToStream(response.body, streamingSlots, {
180512
180529
  nonce,
180513
180530
  onError,
180514
- policy
180531
+ policy,
180532
+ runtimePlacement
180515
180533
  });
180516
180534
  return new Response(body, {
180517
180535
  headers: cloneHeaders(response),
@@ -180538,7 +180556,7 @@ var withRegisteredStreamingSlots = async (renderResponse, options = {}) => {
180538
180556
  };
180539
180557
 
180540
180558
  // src/core/wrapPageHandlerWithStreamingSlots.ts
180541
- var wrapPageHandlerWithStreamingSlots = (handler) => (...args) => withRegisteredStreamingSlots(() => handler(...args));
180559
+ var wrapPageHandlerWithStreamingSlots = (handler, options) => (...args) => withRegisteredStreamingSlots(() => handler(...args), options);
180542
180560
 
180543
180561
  // src/react/index.ts
180544
180562
  init_pageHandler();
@@ -187387,6 +187405,7 @@ export {
187387
187405
  isIslandComponentDefinition,
187388
187406
  injectStreamingRuntimeIntoStream,
187389
187407
  injectHtmlIntoHead,
187408
+ injectHtmlIntoBody,
187390
187409
  hmrState,
187391
187410
  handleReactPageRequest2 as handleReactPageRequest,
187392
187411
  handleHTMXPageRequest,
@@ -187465,5 +187484,5 @@ export {
187465
187484
  ANGULAR_INIT_TIMEOUT_MS
187466
187485
  };
187467
187486
 
187468
- //# debugId=1700989D577CE61D64756E2164756E21
187487
+ //# debugId=FE2617E75731F68364756E2164756E21
187469
187488
  //# sourceMappingURL=index.js.map