@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/build.js CHANGED
@@ -171334,12 +171334,12 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171334
171334
  }, toStaticStreamingSlotDefinition = (value) => typeof value === "function" ? { resolve: value } : value, isObjectRecord = (value) => typeof value === "object" && value !== null, isStaticStreamingSlotDefinitions = (value) => isObjectRecord(value), resolveStaticStreamingDefinitions = (moduleExports) => {
171335
171335
  const candidate = isStaticStreamingSlotDefinitions(moduleExports.streamingSlots) ? moduleExports.streamingSlots : isStaticStreamingSlotDefinitions(moduleExports.default) ? moduleExports.default : null;
171336
171336
  return candidate;
171337
- }, sidecarExtensions, resolveSidecarCandidates = (pagePath) => {
171337
+ }, serverModuleExtensions, resolveSidecarCandidates = (pagePath) => {
171338
171338
  const pageExt = extname4(pagePath);
171339
171339
  if (!pageExt)
171340
171340
  return [];
171341
171341
  const pageStem = pagePath.slice(0, -pageExt.length);
171342
- return sidecarExtensions.map((extension) => `${pageStem}${extension}`);
171342
+ return serverModuleExtensions.map((extension) => `${pageStem}${extension}`);
171343
171343
  }, fileExists = async (path) => await Bun.file(path).exists(), loadStaticStreamingModule = async (pagePath) => {
171344
171344
  for (const candidate of resolveSidecarCandidates(pagePath)) {
171345
171345
  if (!await fileExists(candidate))
@@ -171350,7 +171350,7 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171350
171350
  const moduleExports = await import(moduleUrl.href);
171351
171351
  const definitions = resolveStaticStreamingDefinitions(moduleExports);
171352
171352
  if (!definitions) {
171353
- throw new Error(`Static streaming sidecar "${candidate}" must export a default value or named "streamingSlots" object.`);
171353
+ throw new Error(`Static streaming module "${candidate}" must export a default value or named "streamingSlots" object.`);
171354
171354
  }
171355
171355
  return definitions;
171356
171356
  }
@@ -171362,7 +171362,7 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171362
171362
  }
171363
171363
  const definitions = await loadStaticStreamingModule(pagePath);
171364
171364
  if (!definitions) {
171365
- 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({...}).`);
171365
+ 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({...}).`);
171366
171366
  }
171367
171367
  return tagDefinitions.map((tag) => {
171368
171368
  const entry = definitions[tag.resolver];
@@ -171382,12 +171382,19 @@ var defineStaticStreamingSlots = (slots) => slots, STATIC_SLOT_TAG_RE, ATTRIBUTE
171382
171382
  var init_staticStreaming = __esm(() => {
171383
171383
  STATIC_SLOT_TAG_RE = /<abs-stream-slot\b([^>]*?)(?:\/>|>([\s\S]*?)<\/abs-stream-slot>)/gi;
171384
171384
  ATTRIBUTE_RE = /([A-Za-z_:][-A-Za-z0-9_:.]*)\s*=\s*(?:"([^"]*)"|'([^']*)')/g;
171385
- sidecarExtensions = [".slots.ts", ".slots.js", ".slots.mjs"];
171385
+ serverModuleExtensions = [
171386
+ ".server.ts",
171387
+ ".server.js",
171388
+ ".server.mjs",
171389
+ ".slots.ts",
171390
+ ".slots.js",
171391
+ ".slots.mjs"
171392
+ ];
171386
171393
  });
171387
171394
 
171388
171395
  // src/build/staticIslandPages.ts
171389
171396
  import { readFileSync as readFileSync3, writeFileSync as writeFileSync3 } from "fs";
171390
- 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) => {
171397
+ 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) => {
171391
171398
  const attributeRe = new RegExp(ATTRIBUTE_RE_SOURCE, "g");
171392
171399
  const attributes = new Map;
171393
171400
  let match = attributeRe.exec(attributeString);
@@ -171401,7 +171408,7 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
171401
171408
  }
171402
171409
  return attributes;
171403
171410
  }, parseIslandTag = (attributeString) => {
171404
- const attributes = parseIslandAttributes(attributeString);
171411
+ const attributes = parseHtmlAttributes(attributeString);
171405
171412
  const framework = attributes.get("framework");
171406
171413
  const component = attributes.get("component");
171407
171414
  const hydrate = attributes.get("hydrate") ?? "load";
@@ -171450,6 +171457,48 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
171450
171457
  }
171451
171458
  const renderedSegments = await Promise.all(segments.map(async (segment) => segment.before + (segment.props ? await renderIslandMarkup(registry, segment.props) : segment.fullMatch)));
171452
171459
  return renderedSegments.join("") + originalHtml.slice(lastIndex);
171460
+ }, HTMX_STREAM_SLOT_TAG_RE, requireAttribute = (attributes, name) => {
171461
+ const value = attributes.get(name)?.trim();
171462
+ if (!value) {
171463
+ throw new Error(`Static <abs-htmx-stream-slot> requires a "${name}" attribute.`);
171464
+ }
171465
+ return value;
171466
+ }, injectAttributesIntoSingleRootElement = (fallbackHtml, attributes) => {
171467
+ const trimmed = fallbackHtml.trim();
171468
+ if (!trimmed) {
171469
+ throw new Error("Static <abs-htmx-stream-slot> requires fallback HTML inside the element body.");
171470
+ }
171471
+ const openingTagMatch = trimmed.match(/^<([A-Za-z][\w:-]*)([^>]*)>/);
171472
+ if (!openingTagMatch) {
171473
+ throw new Error("Static <abs-htmx-stream-slot> fallback must start with a single root HTML element.");
171474
+ }
171475
+ const attributeSource = [...attributes.entries()].map(([key, value]) => `${key}="${value}"`).join(" ");
171476
+ if (!attributeSource) {
171477
+ return trimmed;
171478
+ }
171479
+ const [openingTag, tagName, rawExistingAttributes = ""] = openingTagMatch;
171480
+ const existingAttributes = rawExistingAttributes.trim();
171481
+ const mergedAttributes = existingAttributes ? `${existingAttributes} ${attributeSource}` : attributeSource;
171482
+ return trimmed.replace(openingTag, `<${tagName} ${mergedAttributes}>`);
171483
+ }, transformStaticHTMXStreamSlotHtml = (originalHtml) => {
171484
+ let nextIndex = 0;
171485
+ let result = "";
171486
+ let match = HTMX_STREAM_SLOT_TAG_RE.exec(originalHtml);
171487
+ while (match) {
171488
+ const [fullMatch, rawAttributeString = "", innerHtml = ""] = match;
171489
+ const attributes = parseHtmlAttributes(rawAttributeString);
171490
+ const loweredAttributes = new Map([
171491
+ ["hx-get", requireAttribute(attributes, "src")],
171492
+ ["hx-trigger", attributes.get("trigger") ?? "load"],
171493
+ ["hx-swap", attributes.get("swap") ?? "outerHTML"],
171494
+ ["hx-target", attributes.get("target") ?? "this"]
171495
+ ]);
171496
+ result += originalHtml.slice(nextIndex, match.index);
171497
+ result += injectAttributesIntoSingleRootElement(innerHtml, loweredAttributes);
171498
+ nextIndex = match.index + fullMatch.length;
171499
+ match = HTMX_STREAM_SLOT_TAG_RE.exec(originalHtml);
171500
+ }
171501
+ return result + originalHtml.slice(nextIndex);
171453
171502
  }, transformStaticStreamingSlotHtml = (originalHtml) => {
171454
171503
  const slotDefinitions = extractStaticStreamingTags(originalHtml);
171455
171504
  if (slotDefinitions.length === 0) {
@@ -171479,7 +171528,8 @@ var ISLAND_TAG_RE_SOURCE = "<(?:absolute-island|island)\\b([^>]*?)(?:\\/\\>|>(?:
171479
171528
  writeFileSync3(pagePath, transformedHtml);
171480
171529
  }
171481
171530
  }, transformCurrentStaticPageHtml = async (html, options = {}) => {
171482
- const transformedStreamingHtml = options.enableStaticStreaming === false ? html : transformStaticStreamingSlotHtml(html);
171531
+ const transformedHTMXStreamingHtml = options.enableHTMXStreaming === false ? html : transformStaticHTMXStreamSlotHtml(html);
171532
+ const transformedStreamingHtml = options.enableStaticStreaming === false ? transformedHTMXStreamingHtml : transformStaticStreamingSlotHtml(transformedHTMXStreamingHtml);
171483
171533
  const islandTagRe = new RegExp(ISLAND_TAG_RE_SOURCE, "i");
171484
171534
  if (!islandTagRe.test(transformedStreamingHtml)) {
171485
171535
  return transformedStreamingHtml;
@@ -171504,6 +171554,7 @@ var init_staticIslandPages = __esm(() => {
171504
171554
  "angular"
171505
171555
  ];
171506
171556
  islandHydrationModes = ["load", "idle", "visible", "none"];
171557
+ HTMX_STREAM_SLOT_TAG_RE = /<abs-htmx-stream-slot\b([^>]*?)(?:\/>|>([\s\S]*?)<\/abs-htmx-stream-slot>)/gi;
171507
171558
  });
171508
171559
 
171509
171560
  // src/build/outputLogs.ts
@@ -180177,5 +180228,5 @@ export {
180177
180228
  build
180178
180229
  };
180179
180230
 
180180
- //# debugId=A9FEDD816F60A08B64756E2164756E21
180231
+ //# debugId=208D43097DFA5F2464756E2164756E21
180181
180232
  //# sourceMappingURL=build.js.map