@ogygia/core 0.11.2 → 0.11.4
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.d.ts +2 -1
- package/dist/kit-handle.d.ts +20 -0
- package/dist/kit-handle.js +0 -0
- package/dist/plugin/index.d.ts +3 -4
- package/dist/plugin/server.d.ts +3 -2
- package/dist/server/reversible.js +12 -5
- package/package.json +1 -1
package/dist/hooks.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { Handle } from "./kit-handle.js";
|
|
1
2
|
import { TransformKind } from "./server/reversible.js";
|
|
2
3
|
import { ogygiaTransport } from "./transport.js";
|
|
3
4
|
import { DocumentOptions, document } from "./document.js";
|
|
4
5
|
import { LiftResult, LiftedRegion, RegionKind, RegionSpan, liftRegions, restoreRegions, scanRegions } from "./server/split-regions.js";
|
|
5
|
-
import {
|
|
6
|
+
import { RequestEvent } from "@sveltejs/kit";
|
|
6
7
|
/**
|
|
7
8
|
* Options for {@link handle}.
|
|
8
9
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { RequestEvent } from "@sveltejs/kit";
|
|
2
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
3
|
+
/** Kit's `resolve()` options. */
|
|
4
|
+
export interface ResolveOptions {
|
|
5
|
+
transformPageChunk?(input: {
|
|
6
|
+
html: string;
|
|
7
|
+
done: boolean;
|
|
8
|
+
}): MaybePromise<string | undefined>;
|
|
9
|
+
filterSerializedResponseHeaders?(name: string, value: string): boolean;
|
|
10
|
+
preload?(input: {
|
|
11
|
+
type: "font" | "css" | "js" | "asset";
|
|
12
|
+
path: string;
|
|
13
|
+
}): boolean;
|
|
14
|
+
}
|
|
15
|
+
/** Kit's `Handle` hook. */
|
|
16
|
+
export type Handle = (input: {
|
|
17
|
+
event: RequestEvent;
|
|
18
|
+
resolve: (event: RequestEvent, opts?: ResolveOptions) => MaybePromise<Response>;
|
|
19
|
+
}) => MaybePromise<Response>;
|
|
20
|
+
export {};
|
|
File without changes
|
package/dist/plugin/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Handle, ResolveOptions } from "../kit-handle.js";
|
|
1
2
|
import { RequestFacts } from "./facts.js";
|
|
2
3
|
import { Ask, Notify, ServerHooks } from "./hooks.js";
|
|
3
4
|
import { DevtoolsEventInput } from "../events/schema.js";
|
|
@@ -5,7 +6,7 @@ import { DeferredRegion, og_html_region, region } from "../region.js";
|
|
|
5
6
|
import { RouteConfig, RouteConfigMatcher, register_route_config } from "./routes.js";
|
|
6
7
|
import { LateRegion, open_late_scope, take_late_regions } from "../late-region-registry.js";
|
|
7
8
|
import { LATE_BOOT_SCRIPT, late_chunk, late_slot } from "../server/late-wire.js";
|
|
8
|
-
import {
|
|
9
|
+
import { RequestEvent } from "@sveltejs/kit";
|
|
9
10
|
/** The server process, as one plugin sees it (handed to `setup`, and on every `ctx.app`). */
|
|
10
11
|
export interface ServerApp<Options = undefined> {
|
|
11
12
|
/** The plugin's name (its package name). */
|
|
@@ -81,8 +82,6 @@ export interface RequestContext<Options = undefined, State = undefined> {
|
|
|
81
82
|
perVisitor(reason: string): void;
|
|
82
83
|
}
|
|
83
84
|
type MaybePromise<T> = T | Promise<T>;
|
|
84
|
-
/** Kit's `resolve()` options (a `transformPageChunk`, `filterSerializedResponseHeaders`, …). */
|
|
85
|
-
export type ResolveOptions = NonNullable<Parameters<Parameters<Handle>[0]["resolve"]>[1]>;
|
|
86
85
|
/** A request as an AROUND hook sees it: before anything is decided about it. */
|
|
87
86
|
export interface HandleContext<Options = undefined> {
|
|
88
87
|
/** Kit's own event, untouched. */
|
|
@@ -124,4 +123,4 @@ export declare const STORED_DOCUMENT_META = "<meta name=\"ogygia-stored\" conten
|
|
|
124
123
|
/** A deferred region value whose HTML the browser fetches from `url` (a capability the plugin minted,
|
|
125
124
|
* `''` for an inert one). HTML only: whatever islands the answer carries wake themselves. */
|
|
126
125
|
export declare function deferredRegion(id: string, url: string): DeferredRegion;
|
|
127
|
-
export { type DevtoolsEventInput, LATE_BOOT_SCRIPT, type LateRegion, type RequestFacts, type RouteConfig, type RouteConfigMatcher, type ServerHooks, og_html_region as htmlRegion, late_chunk as lateChunk, late_slot as lateSlot, open_late_scope as openLateScope, region, register_route_config as registerRouteConfig, take_late_regions as takeLateRegions };
|
|
126
|
+
export { type DevtoolsEventInput, type Handle, LATE_BOOT_SCRIPT, type LateRegion, type RequestFacts, type ResolveOptions, type RouteConfig, type RouteConfigMatcher, type ServerHooks, og_html_region as htmlRegion, late_chunk as lateChunk, late_slot as lateSlot, open_late_scope as openLateScope, region, register_route_config as registerRouteConfig, take_late_regions as takeLateRegions };
|
package/dist/plugin/server.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Handle, ResolveOptions } from "../kit-handle.js";
|
|
2
|
+
import { RequestContext, ServerApp, ServerPlugin } from "./index.js";
|
|
2
3
|
import { RequestFacts } from "./facts.js";
|
|
3
4
|
import { CapabilitySigner } from "./capability.js";
|
|
4
|
-
import {
|
|
5
|
+
import { RequestEvent } from "@sveltejs/kit";
|
|
5
6
|
/** One plugin's server half as the build lists it (`virtual:ogygia/server-plugins`). */
|
|
6
7
|
export interface ServerPluginEntry {
|
|
7
8
|
name: string;
|
|
@@ -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
|
|
495
|
-
*
|
|
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
|
-
|
|
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, {
|