@ogygia/core 0.11.1 → 0.11.3

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/hooks.js CHANGED
@@ -413,6 +413,14 @@ function has_body_close(carry, chunk) {
413
413
  function csr_page_of(html, body_end, event, bag) {
414
414
  return event?.route?.id != null ? bag?.page?.error != null ? error_route_is_csr_true(event.route.id) : route_is_csr_true(event.route.id) : body_end !== -1 && html_has_kit_bootstrap(html, body_end);
415
415
  }
416
+ /** The drop-in `setContext` page root (`<script data-ogygia-provide-page>`), or '' when the request
417
+ * set nothing an island can read. Drops any non-serializable value (function / store / class
418
+ * instance) instead of crashing. */
419
+ function page_ctx_script(bag) {
420
+ if (!bag?.ctx?.size) return "";
421
+ const payload = serialize_provided_context(bag.ctx);
422
+ return payload ? emit_ogygia_script("ctx", payload, PAGE_CTX_MARKER) : "";
423
+ }
416
424
  /** The restorer, inline (runtime/restore.ts — self-contained, so its source runs as is): restores the
417
425
  * document now, and stays as `__og_restore` / `__og_restore_adopt` for hole answers and router swaps. */
418
426
  const RESTORER_SCRIPT = `<script data-og-restore>(function(){var r=${restore.toString()};window.__og_restore=r;window.__og_restore_adopt=${restore_adopt.toString()};r(document)})()<\/script>`;
@@ -630,9 +638,10 @@ var OgygiaHandle = class {
630
638
  if (head !== null) {
631
639
  head_inject = CSR_META;
632
640
  if (devtools_boot_url && !head.includes("data-ogygia-devtools-boot")) head_inject += `<script type="module" data-ogygia-devtools-boot src="${devtools_boot_url}"><\/script>`;
641
+ if (bag) bag.kit_with_runtime = page_declares_runtime_script(head);
633
642
  }
634
643
  if (head !== null && bag?.transform_head) head_inject = bag.transform_head + head_inject;
635
- const tail = spans.body_end !== -1 && bag ? (bag.transform_body ?? "") + bag.tail.render(null) : "";
644
+ const tail = spans.body_end !== -1 && bag ? (bag.transform_body ?? "") + bag.tail.render(null) + (bag.kit_with_runtime ? page_ctx_script(bag) : "") : "";
636
645
  if (head === null && !tail) return html;
637
646
  const ordered = head === null ? null : runtime_first(head, null);
638
647
  return assemble(html, spans, ordered === head ? null : ordered, head_inject, tail);
@@ -735,13 +744,10 @@ var OgygiaHandle = class {
735
744
  scripts.push(fnm_script);
736
745
  fnm_bytes = fnm_script.length;
737
746
  }
738
- const provided = bag?.ctx;
739
- if (provided?.size) {
740
- const payload = serialize_provided_context(provided);
741
- if (payload) {
742
- scripts.push(emit_ogygia_script("ctx", payload, PAGE_CTX_MARKER));
743
- ctx_bytes = payload.length;
744
- }
747
+ const ctx_script = page_ctx_script(bag);
748
+ if (ctx_script) {
749
+ scripts.push(ctx_script);
750
+ ctx_bytes = ctx_script.length;
745
751
  }
746
752
  this.append_devtools_seed(scripts, bag);
747
753
  const out = assemble(html, spans, head_out, head_inject, scripts.join(""));
@@ -490,9 +490,11 @@ const attr_map = (attrs) => {
490
490
  * gives (Svelte's children in the light DOM), never in the transform's server form only the
491
491
  * component's first hydrate reads (that form, morphed into a live host, left the transform's tree in
492
492
  * its light DOM: a site nav collapsed to one unstyled item after an in-place navigation). In a
493
- * document loaded as one, every one in Svelte-owned markup, and every one with Svelte-owned markup
494
- * below it (a server-owned host around an island: adopting it would reach into the island). A first
495
- * pass, so the marking pass knows a host's plan before it reaches the host's children.
493
+ * document loaded as one, every one in Svelte-owned markup, and every one with Svelte-owned markup or
494
+ * a hole below it (a server-owned host around an island or a hole: adopting it would reach into a
495
+ * region ogygia hydrates or swaps — a web component relocating its slotted children moved a hole's
496
+ * fallback twice, and its tabs kept a second copy of a document listener). A first pass, so the
497
+ * marking pass knows a host's plan before it reaches the host's children.
496
498
  */
497
499
  function plan_hosts(html, kind, csr, answer) {
498
500
  const planned = [];
@@ -507,13 +509,18 @@ function plan_hosts(html, kind, csr, answer) {
507
509
  const parent = stack[stack.length - 1];
508
510
  const foreign = name === "svg" || name === "math" || !!parent?.foreign;
509
511
  let owned = name === "body" && kind === "document" && csr || (parent ? parent.owned : false);
510
- if (name === "ogygia-region") owned = region_kind(parse_attrs(html, tok.name_end, tok.end - 1)) === "island";
512
+ let swapped = false;
513
+ if (name === "ogygia-region") {
514
+ const region = region_kind(parse_attrs(html, tok.name_end, tok.end - 1));
515
+ owned = region === "island";
516
+ swapped = region === "hole";
517
+ }
511
518
  let host = -1;
512
519
  if (in_body && is_custom(name, foreign)) {
513
520
  host = planned.length;
514
521
  planned.push(answer || kind !== "document" || owned);
515
522
  }
516
- if (owned && !(parent ? parent.owned : false)) {
523
+ if ((owned || swapped) && !(parent ? parent.owned : false)) {
517
524
  for (const f of stack) if (f.host !== -1) planned[f.host] = true;
518
525
  }
519
526
  if (!(VOID.has(name) || tok.self && foreign)) push(stack, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogygia/core",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "The core of ogygia (SSR islands for SvelteKit): apps install `ogygia`, plugins build on this",
5
5
  "homepage": "https://ogygiajs.dev",
6
6
  "bugs": {