@absolutejs/absolute 0.19.0-beta.448 → 0.19.0-beta.449

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
@@ -171240,12 +171240,12 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171240
171240
  }, toStaticStreamingSlotDefinition = (value) => typeof value === "function" ? { resolve: value } : value, isObjectRecord = (value) => typeof value === "object" && value !== null, isStaticStreamingSlotDefinitions = (value) => isObjectRecord(value), resolveStaticStreamingDefinitions = (moduleExports) => {
171241
171241
  const candidate = isStaticStreamingSlotDefinitions(moduleExports.streamingSlots) ? moduleExports.streamingSlots : isStaticStreamingSlotDefinitions(moduleExports.default) ? moduleExports.default : null;
171242
171242
  return candidate;
171243
- }, sidecarExtensions, resolveSidecarCandidates = (pagePath) => {
171243
+ }, serverModuleExtensions, resolveSidecarCandidates = (pagePath) => {
171244
171244
  const pageExt = extname3(pagePath);
171245
171245
  if (!pageExt)
171246
171246
  return [];
171247
171247
  const pageStem = pagePath.slice(0, -pageExt.length);
171248
- return sidecarExtensions.map((extension) => `${pageStem}${extension}`);
171248
+ return serverModuleExtensions.map((extension) => `${pageStem}${extension}`);
171249
171249
  }, fileExists = async (path) => await Bun.file(path).exists(), loadStaticStreamingModule = async (pagePath) => {
171250
171250
  for (const candidate of resolveSidecarCandidates(pagePath)) {
171251
171251
  if (!await fileExists(candidate))
@@ -171256,7 +171256,7 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171256
171256
  const moduleExports = await import(moduleUrl.href);
171257
171257
  const definitions = resolveStaticStreamingDefinitions(moduleExports);
171258
171258
  if (!definitions) {
171259
- throw new Error(`Static streaming sidecar "${candidate}" must export a default value or named "streamingSlots" object.`);
171259
+ throw new Error(`Static streaming module "${candidate}" must export a default value or named "streamingSlots" object.`);
171260
171260
  }
171261
171261
  return definitions;
171262
171262
  }
@@ -171268,7 +171268,7 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171268
171268
  }
171269
171269
  const definitions = await loadStaticStreamingModule(pagePath);
171270
171270
  if (!definitions) {
171271
- throw new Error(`Static page "${pagePath}" uses <abs-stream-slot> but no sidecar slot module was found. Create a sibling ".slots.ts" file that exports defineStaticStreamingSlots({...}).`);
171271
+ throw new Error(`Static page "${pagePath}" uses <abs-stream-slot> but no page-adjacent server module was found. Create a sibling ".server.ts" file that exports defineStaticStreamingSlots({...}).`);
171272
171272
  }
171273
171273
  return tagDefinitions.map((tag) => {
171274
171274
  const entry = definitions[tag.resolver];
@@ -171288,12 +171288,19 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171288
171288
  var init_staticStreaming = __esm(() => {
171289
171289
  STATIC_SLOT_TAG_RE = /<abs-stream-slot\b([^>]*?)(?:\/>|>([\s\S]*?)<\/abs-stream-slot>)/gi;
171290
171290
  ATTRIBUTE_RE = /([A-Za-z_:][-A-Za-z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
171291
- sidecarExtensions = [".slots.ts", ".slots.js", ".slots.mjs"];
171291
+ serverModuleExtensions = [
171292
+ ".server.ts",
171293
+ ".server.js",
171294
+ ".server.mjs",
171295
+ ".slots.ts",
171296
+ ".slots.js",
171297
+ ".slots.mjs"
171298
+ ];
171292
171299
  });
171293
171300
 
171294
171301
  // src/build/staticIslandPages.ts
171295
171302
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
171296
- var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:[\\s\\S]*?)<\\/(?:absolute-island|island)>)", ATTRIBUTE_RE_SOURCE = `([A-Za-z_:][-A-Za-z0-9_:.]*)\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, islandFrameworks, islandHydrationModes, isRecord4 = (value) => typeof value === "object" && value !== null, isIslandFramework = (value) => islandFrameworks.some((framework) => framework === value), isIslandHydrationMode = (value) => islandHydrationModes.some((mode) => mode === value), parseIslandAttributes = (attributeString) => {
171303
+ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:[\\s\\S]*?)<\\/(?:absolute-island|island)>)", ATTRIBUTE_RE_SOURCE = `([A-Za-z_:][-A-Za-z0-9_:.]*)\\s*=\\s*(?:"([^"]*)"|'([^']*)')`, islandFrameworks, islandHydrationModes, isRecord4 = (value) => typeof value === "object" && value !== null, isIslandFramework = (value) => islandFrameworks.some((framework) => framework === value), isIslandHydrationMode = (value) => islandHydrationModes.some((mode) => mode === value), parseHtmlAttributes = (attributeString) => {
171297
171304
  const attributeRe = new RegExp(ATTRIBUTE_RE_SOURCE, "g");
171298
171305
  const attributes = new Map;
171299
171306
  let match = attributeRe.exec(attributeString);
@@ -171307,7 +171314,7 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
171307
171314
  }
171308
171315
  return attributes;
171309
171316
  }, parseIslandTag = (attributeString) => {
171310
- const attributes = parseIslandAttributes(attributeString);
171317
+ const attributes = parseHtmlAttributes(attributeString);
171311
171318
  const framework = attributes.get("framework");
171312
171319
  const component = attributes.get("component");
171313
171320
  const hydrate = attributes.get("hydrate") ?? "load";
@@ -171356,6 +171363,48 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
171356
171363
  }
171357
171364
  const renderedSegments = await Promise.all(segments.map(async (segment) => segment.before + (segment.props ? await renderIslandMarkup(registry, segment.props) : segment.fullMatch)));
171358
171365
  return renderedSegments.join("") + originalHtml.slice(lastIndex);
171366
+ }, HTMX_STREAM_SLOT_TAG_RE, requireAttribute = (attributes, name) => {
171367
+ const value = attributes.get(name)?.trim();
171368
+ if (!value) {
171369
+ throw new Error(`Static <abs-htmx-stream-slot> requires a "${name}" attribute.`);
171370
+ }
171371
+ return value;
171372
+ }, injectAttributesIntoSingleRootElement = (fallbackHtml, attributes) => {
171373
+ const trimmed = fallbackHtml.trim();
171374
+ if (!trimmed) {
171375
+ throw new Error("Static <abs-htmx-stream-slot> requires fallback HTML inside the element body.");
171376
+ }
171377
+ const openingTagMatch = trimmed.match(/^<([A-Za-z][\w:-]*)([^>]*)>/);
171378
+ if (!openingTagMatch) {
171379
+ throw new Error("Static <abs-htmx-stream-slot> fallback must start with a single root HTML element.");
171380
+ }
171381
+ const attributeSource = [...attributes.entries()].map(([key, value]) => `${key}="${value}"`).join(" ");
171382
+ if (!attributeSource) {
171383
+ return trimmed;
171384
+ }
171385
+ const [openingTag, tagName, rawExistingAttributes = ""] = openingTagMatch;
171386
+ const existingAttributes = rawExistingAttributes.trim();
171387
+ const mergedAttributes = existingAttributes ? `${existingAttributes} ${attributeSource}` : attributeSource;
171388
+ return trimmed.replace(openingTag, `<${tagName} ${mergedAttributes}>`);
171389
+ }, transformStaticHTMXStreamSlotHtml = (originalHtml) => {
171390
+ let nextIndex = 0;
171391
+ let result = "";
171392
+ let match = HTMX_STREAM_SLOT_TAG_RE.exec(originalHtml);
171393
+ while (match) {
171394
+ const [fullMatch, rawAttributeString = "", innerHtml = ""] = match;
171395
+ const attributes = parseHtmlAttributes(rawAttributeString);
171396
+ const loweredAttributes = new Map([
171397
+ ["hx-get", requireAttribute(attributes, "src")],
171398
+ ["hx-trigger", attributes.get("trigger") ?? "load"],
171399
+ ["hx-swap", attributes.get("swap") ?? "outerHTML"],
171400
+ ["hx-target", attributes.get("target") ?? "this"]
171401
+ ]);
171402
+ result += originalHtml.slice(nextIndex, match.index);
171403
+ result += injectAttributesIntoSingleRootElement(innerHtml, loweredAttributes);
171404
+ nextIndex = match.index + fullMatch.length;
171405
+ match = HTMX_STREAM_SLOT_TAG_RE.exec(originalHtml);
171406
+ }
171407
+ return result + originalHtml.slice(nextIndex);
171359
171408
  }, transformStaticStreamingSlotHtml = (originalHtml) => {
171360
171409
  const slotDefinitions = extractStaticStreamingTags(originalHtml);
171361
171410
  if (slotDefinitions.length === 0) {
@@ -171385,7 +171434,8 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
171385
171434
  writeFileSync3(pagePath, transformedHtml);
171386
171435
  }
171387
171436
  }, transformCurrentStaticPageHtml = async (html, options = {}) => {
171388
- const transformedStreamingHtml = options.enableStaticStreaming === false ? html : transformStaticStreamingSlotHtml(html);
171437
+ const transformedHTMXStreamingHtml = options.enableHTMXStreaming === false ? html : transformStaticHTMXStreamSlotHtml(html);
171438
+ const transformedStreamingHtml = options.enableStaticStreaming === false ? transformedHTMXStreamingHtml : transformStaticStreamingSlotHtml(transformedHTMXStreamingHtml);
171389
171439
  const islandTagRe = new RegExp(ISLAND_TAG_RE_SOURCE, "i");
171390
171440
  if (!islandTagRe.test(transformedStreamingHtml)) {
171391
171441
  return transformedStreamingHtml;
@@ -171410,6 +171460,7 @@ var init_staticIslandPages = __esm(() => {
171410
171460
  "angular"
171411
171461
  ];
171412
171462
  islandHydrationModes = ["load", "idle", "visible", "none"];
171463
+ HTMX_STREAM_SLOT_TAG_RE = /<abs-htmx-stream-slot\b([^>]*?)(?:\/>|>([\s\S]*?)<\/abs-htmx-stream-slot>)/gi;
171413
171464
  });
171414
171465
 
171415
171466
  // src/build/scanEntryPoints.ts
@@ -181317,7 +181368,10 @@ var handleHTMXPageRequest = async (pagePath) => {
181317
181368
  if (extractStaticStreamingTags(html).length > 0) {
181318
181369
  throw new Error(`HTMX page "${pagePath}" uses <abs-stream-slot>, but HTMX pages should use native hx-* fragment requests instead.`);
181319
181370
  }
181320
- return handleStaticPageRequest(pagePath, {}, { enableStaticStreaming: false });
181371
+ return handleStaticPageRequest(pagePath, {}, {
181372
+ enableHTMXStreaming: true,
181373
+ enableStaticStreaming: false
181374
+ });
181321
181375
  };
181322
181376
  // src/core/prepare.ts
181323
181377
  import { existsSync as existsSync23, readdirSync as readdirSync2, readFileSync as readFileSync16 } from "fs";
@@ -188066,5 +188120,5 @@ export {
188066
188120
  ANGULAR_INIT_TIMEOUT_MS
188067
188121
  };
188068
188122
 
188069
- //# debugId=95670B4EA4816FD664756E2164756E21
188123
+ //# debugId=5AE2D9A956DA079764756E2164756E21
188070
188124
  //# sourceMappingURL=index.js.map