@ogygia/core 0.11.1 → 0.11.2

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.
Files changed (2) hide show
  1. package/dist/hooks.js +14 -8
  2. package/package.json +1 -1
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(""));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ogygia/core",
3
- "version": "0.11.1",
3
+ "version": "0.11.2",
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": {