@solidjs/web 2.0.0-rc.15 → 2.0.0-rc.17
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/README.md +1 -1
- package/dist/server.dev.js +361 -483
- package/dist/server.js +346 -391
- package/dist/server.observe.js +346 -391
- package/dist/web.dev.js +110 -55
- package/dist/web.js +51 -50
- package/dist/web.observe.js +61 -55
- package/frames/dist/client.dev.js +610 -621
- package/frames/dist/client.js +540 -566
- package/frames/dist/client.observe.js +571 -573
- package/frames/dist/regions.js +43 -2
- package/frames/dist/server.dev.js +793 -424
- package/frames/dist/server.js +792 -371
- package/frames/dist/server.observe.js +792 -371
- package/frames/dist/wire.js +371 -6
- package/package.json +11 -11
- package/serialization/dist/decode.js +9 -7
- package/serialization/dist/serialization.js +9 -7
- package/serialization/types/serializer-decode.d.ts +2 -2
- package/server-functions/dist/client.dev.js +13 -22
- package/server-functions/dist/client.js +11 -22
- package/server-functions/dist/client.observe.js +13 -22
- package/server-functions/dist/rich-args.js +84 -1
- package/server-functions/dist/server.dev.js +194 -20
- package/server-functions/dist/server.js +194 -20
- package/server-functions/dist/server.observe.js +194 -20
- package/skills/server-components/SKILL.md +74 -185
- package/types/client.d.ts +27 -5
- package/types/diagnostics.d.ts +16 -0
- package/types/frames/assets-tier.d.ts +2 -2
- package/types/frames/client.d.ts +8 -3
- package/types/frames/frame-client.d.ts +121 -157
- package/types/frames/frame-morph.d.ts +28 -0
- package/types/frames/frame-sink.d.ts +13 -9
- package/types/frames/frame-transport.d.ts +30 -1
- package/types/frames/regions-tier.d.ts +15 -0
- package/types/frames/serializer-decode.d.ts +2 -2
- package/types/frames/server.d.ts +0 -52
- package/types/frames/wire-tier.d.ts +54 -1
- package/types/index.d.ts +2 -2
- package/types/jsx.d.ts +11 -5
- package/types/observe.d.ts +14 -7
- package/types/render.d.ts +3 -1
- package/types/response.d.ts +5 -4
- package/types/serializer-decode.d.ts +2 -2
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +27 -9
- package/types/server-functions/server.d.ts +23 -2
- package/types/server-functions/shared.d.ts +19 -0
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server-observe.d.ts +3 -2
- package/types/server.d.ts +58 -77
- package/frames/dist/bind.dev.js +0 -326
- package/frames/dist/bind.js +0 -295
- package/types/frames/bind-tier.d.ts +0 -60
package/types/server.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getOwner, createComponent, untrack, merge as mergeProps } from "solid-js";
|
|
2
|
-
import {
|
|
2
|
+
import { ssrScope as scope } from "solid-js/internal";
|
|
3
3
|
import type { Owner } from "solid-js";
|
|
4
4
|
import type { ServerErrorSite } from "solid-js/internal";
|
|
5
5
|
import { effect, memo } from "./render.js";
|
|
@@ -216,21 +216,7 @@ export interface SSRResponseOptions {
|
|
|
216
216
|
*/
|
|
217
217
|
export type FetchMiddleware = (request: Request, next: (request?: Request) => Promise<Response>) => Response | Promise<Response>;
|
|
218
218
|
export { createComponent, effect, memo, untrack, mergeProps, scope, getOwner };
|
|
219
|
-
export { sharedConfig };
|
|
220
219
|
export { DOMWithState, ChildProperties, DOMElements, SVGElements, MathMLElements, VoidElements, RawTextElements, Namespaces, DelegatedEvents } from "./constants.js";
|
|
221
|
-
/**
|
|
222
|
-
* The script half of a `CSPNonce`. The surfaces that emit one script take a
|
|
223
|
-
* `CSPNonce` and project it themselves; this stays exported only for
|
|
224
|
-
* `@solidjs/vite-plugin`'s generated handler, which still imports it.
|
|
225
|
-
* @internal
|
|
226
|
-
*/
|
|
227
|
-
export declare function scriptNonce(nonce?: CSPNonce): string | undefined;
|
|
228
|
-
/**
|
|
229
|
-
* The style half of a `CSPNonce`. Exported only for
|
|
230
|
-
* `@solidjs/vite-plugin`'s generated handler, which still imports it.
|
|
231
|
-
* @internal
|
|
232
|
-
*/
|
|
233
|
-
export declare function styleNonce(nonce?: CSPNonce): string | undefined;
|
|
234
220
|
export declare function useHead(tag: HeadTag | HeadTag[] | (() => HeadTag | HeadTag[])): void;
|
|
235
221
|
export declare function renderToString<T>(fn: () => T, options?: {
|
|
236
222
|
nonce?: CSPNonce;
|
|
@@ -278,7 +264,8 @@ export declare function renderToStream<T>(fn: () => T, options?: {
|
|
|
278
264
|
* `<Errored>` fallback (`handling: "fallback"`), a rejected fragment
|
|
279
265
|
* (`"client"`), a hydration value that would not serialize
|
|
280
266
|
* (`"serialize"`) — and the one that fails the request (`"failed"`),
|
|
281
|
-
* once per error
|
|
267
|
+
* once per error per kind per request (per render outside one), with
|
|
268
|
+
* where it was met. A one-argument listener still
|
|
282
269
|
* works; it hears them all — filter on `context.handling` for the
|
|
283
270
|
* request-failing ones alone. Without a hook (here or ambient) a
|
|
284
271
|
* failure that fails the request goes to `console.error`.
|
|
@@ -361,12 +348,34 @@ export declare function ssrGroup<T extends () => any[]>(fn: T, n: number): T;
|
|
|
361
348
|
* commit through the render core, and the response's end-latch sweep is
|
|
362
349
|
* always the last one).
|
|
363
350
|
*/
|
|
364
|
-
export declare function createLiveHoles(sink: any, scoped: any): {
|
|
351
|
+
export declare function createLiveHoles(sink: any, scoped: any, settled: any, errorScope: any): {
|
|
365
352
|
suppressed: number;
|
|
366
353
|
sweeping: boolean;
|
|
367
354
|
parent: any;
|
|
368
|
-
recordStamp: number;
|
|
369
355
|
gateHit: boolean;
|
|
356
|
+
sweptOwners: boolean;
|
|
357
|
+
scope: any;
|
|
358
|
+
visit: any;
|
|
359
|
+
dry: boolean;
|
|
360
|
+
/**
|
|
361
|
+
* The id of a positional slot call: at render time (and on a retry,
|
|
362
|
+
* which renders) the render-positional id the proxy minted, `given`,
|
|
363
|
+
* kept for the call's position; on a sweep, the id that position had —
|
|
364
|
+
* or, for a position no render reached, `prop#~<scope>.<n>` (the `~`
|
|
365
|
+
* keeps it apart from render ids and `$key` ids, whose alphabet has
|
|
366
|
+
* none). Outside every hole, `given` as it is.
|
|
367
|
+
*/
|
|
368
|
+
slotId(prop: any, given: any): any;
|
|
369
|
+
/** A slot occurrence reached by the evaluation in progress; `forget` runs
|
|
370
|
+
* once a re-evaluation of its hole no longer reaches it. */
|
|
371
|
+
seen(id: any, forget: any): void;
|
|
372
|
+
/**
|
|
373
|
+
* Enter a nested hole's scope on the path that resolves it unminted (a
|
|
374
|
+
* sweep's interior, a suppressed window): the same scope a first render
|
|
375
|
+
* gives it inside `content()`. Returns the scope to restore, or
|
|
376
|
+
* undefined when none was entered.
|
|
377
|
+
*/
|
|
378
|
+
nest(hole: any): any;
|
|
370
379
|
/**
|
|
371
380
|
* Intercept a thunk content hole: resolve it, and — when the evaluation
|
|
372
381
|
* proves re-runnable — mint an id, wrap the output in its marker pair,
|
|
@@ -382,8 +391,9 @@ export declare function createLiveHoles(sink: any, scoped: any): {
|
|
|
382
391
|
mint(): number;
|
|
383
392
|
/** Whether interception may arm at the current evaluation point —
|
|
384
393
|
* `ssr()` asks before opening an attr capture (the `data-lha`
|
|
385
|
-
* injection must not touch out-of-scope bytes
|
|
386
|
-
* gated inside `content()`
|
|
394
|
+
* injection must not touch out-of-scope bytes, nor address an element
|
|
395
|
+
* nothing can change; content holes are gated inside `content()`
|
|
396
|
+
* itself). */
|
|
387
397
|
active(): boolean;
|
|
388
398
|
/**
|
|
389
399
|
* Register an element's attr-hole capture (built by `ssr()`'s in-tag
|
|
@@ -409,53 +419,12 @@ export declare function ssrStyle(value: string | {
|
|
|
409
419
|
}): string;
|
|
410
420
|
export declare function ssrStyleProperty(name: string, value: any): string;
|
|
411
421
|
export declare function ssrStyleProperties(...entries: any[]): string;
|
|
412
|
-
export declare function ssrElement(name: string, props: any | any[] | (() => any | any[]), children: any, needsId: boolean, skip?: (key: string) => boolean, attrs?: string | (() => string)
|
|
422
|
+
export declare function ssrElement(name: string, props: any | any[] | (() => any | any[]), children: any, needsId: boolean, skip?: (key: string) => boolean, attrs?: string | (() => string)): {
|
|
413
423
|
t: string;
|
|
414
424
|
};
|
|
415
425
|
export declare function ssrElementAttribute(key: string, value: any): string;
|
|
416
426
|
export declare function ssrAttribute(key: string, value: any): string;
|
|
417
427
|
export declare function ssrHydrationKey(): string;
|
|
418
|
-
export declare const CLAIMS_STREAM = 1;
|
|
419
|
-
export declare const CLAIMS_DOCUMENT = 2;
|
|
420
|
-
/** The brand on a binding slot's stand-in for one property read. */
|
|
421
|
-
export declare const SLOT_VALUE: unique symbol;
|
|
422
|
-
/** Marker attribute prefix on a consuming element (`_s:class`, `_s:on:click`, `_s:ref`). */
|
|
423
|
-
export declare const SLOT_MARKER = "_s:";
|
|
424
|
-
/** Faces a stand-in can come from (`slotValue`'s `face`). */
|
|
425
|
-
export declare const SLOT_FACE_STREAM = 0;
|
|
426
|
-
export declare const SLOT_FACE_DATA = 1;
|
|
427
|
-
export declare const SLOT_FACE_MARKUP = 2;
|
|
428
|
-
export declare function isSlotValue(value: unknown): boolean;
|
|
429
|
-
/**
|
|
430
|
-
* A binding slot's stand-in for one property read. `face` says what the
|
|
431
|
-
* occurrence's fill produced where this read happens: nothing (the stream
|
|
432
|
-
* face never runs fills), a data object (the document face — `value` is
|
|
433
|
-
* the t=0 value of `key`), or markup (the document face ran the fill and
|
|
434
|
-
* it returned content — a read off it is a dev finding at the position).
|
|
435
|
-
* The server has no value to compute with — on the stream face none at
|
|
436
|
-
* all, on the document face only the t=0 one — so the ONLY thing a stand-in
|
|
437
|
-
* can be is the whole value at one position. Every coercion the runtime can
|
|
438
|
-
* see (a template literal, `+`, a comparison, an explicit `String()`) is a
|
|
439
|
-
* dev finding, and it renders NOTHING on either face: the document face
|
|
440
|
-
* never shows a t=0 value the stream face cannot reproduce, so a misuse is
|
|
441
|
-
* visible on the first render rather than on the first refetch. Truthiness
|
|
442
|
-
* (`if (row.done)`, `row.x && …`) has no hook and is the one misuse only
|
|
443
|
-
* the rule can catch — a stand-in is an object and always truthy.
|
|
444
|
-
* @internal Created by the slot proxies (frames server).
|
|
445
|
-
*/
|
|
446
|
-
export declare function slotValue(occurrence: string, key: string, value: unknown, face: number): object;
|
|
447
|
-
/**
|
|
448
|
-
* The compiled per-element hole for ref/onXxx positions on a server
|
|
449
|
-
* intrinsic (behind the `serverComponents` compiler option):
|
|
450
|
-
* `ctx.claims ? ssrClaim({ click: expr, ref: expr2 }) : ""`. The compiler
|
|
451
|
-
* drops handler and ref expressions from plain SSR output, so this is
|
|
452
|
-
* where a stand-in at one of those positions is seen. A server-local
|
|
453
|
-
* function there can never run (the server has no client to run it on);
|
|
454
|
-
* dev says so, inside the component barrier only. An element with a
|
|
455
|
-
* handler position bound is an EVENT-SLOT consumer and carries the
|
|
456
|
-
* replay-window stamp beside its markers (`eventSlotStamp`).
|
|
457
|
-
*/
|
|
458
|
-
export declare function ssrClaim(map: Record<string, unknown>): string;
|
|
459
428
|
/**
|
|
460
429
|
* A render's link handler (`setLinkClaim`): given an anchor's link-relevant
|
|
461
430
|
* attributes — `href`, and `target` / `rel` / `download` / `link` /
|
|
@@ -464,7 +433,7 @@ export declare function ssrClaim(map: Record<string, unknown>): string;
|
|
|
464
433
|
* (`" data-active"`, `' data-active aria-current="page"'`), or `""`.
|
|
465
434
|
* Synchronous and pure; the markup is the handler's own and is written
|
|
466
435
|
* verbatim.
|
|
467
|
-
* @
|
|
436
|
+
* @internal
|
|
468
437
|
*/
|
|
469
438
|
export type LinkClaimHandler = (attrs: Readonly<Record<string, unknown>>) => string;
|
|
470
439
|
/**
|
|
@@ -514,13 +483,20 @@ export interface ServerErrorContext extends Omit<ServerErrorSite, "event"> {
|
|
|
514
483
|
}
|
|
515
484
|
/**
|
|
516
485
|
* The server error hook (see `configureServerErrors`): every failure the
|
|
517
|
-
* server runtime handles or fails on, once per error object
|
|
518
|
-
*
|
|
519
|
-
*
|
|
520
|
-
*
|
|
521
|
-
*
|
|
486
|
+
* server runtime handles or fails on, once per error object per `kind` per
|
|
487
|
+
* request (per render when no request is in scope — never once per
|
|
488
|
+
* process: an error object one request met and another meets again is
|
|
489
|
+
* heard by both), with where it was met. A direct server-function call that
|
|
490
|
+
* throws during SSR and the `<Errored>` that contains it are heard as both:
|
|
491
|
+
* `server-function` (the call failed), then `render` (the render fell back),
|
|
492
|
+
* so `kind: "render"` alone answers whether a render failed. Return the value the client should receive in
|
|
493
|
+
* place of the error — rendered into the fallback, serialized for
|
|
494
|
+
* hydration, sent as the RPC error — or nothing for the default policy (a
|
|
495
|
+
* generic `Error` outside the dev build, the error itself in it;
|
|
496
|
+
* `markSafeError` still passes through).
|
|
522
497
|
* A returned value is taken as intended client-facing content and is not
|
|
523
|
-
* sanitized again. Ignored for `handling: "failed"`, which has no wire
|
|
498
|
+
* sanitized again. Ignored for `handling: "failed"`, which has no wire, and
|
|
499
|
+
* once an earlier kind's sight gave one: every road carries the first.
|
|
524
500
|
*
|
|
525
501
|
* One road a mapping does not reach: a rejected async source's serialized
|
|
526
502
|
* rejection is encoded the moment the source rejects, ahead of the boundary
|
|
@@ -538,9 +514,10 @@ export interface ServerErrorsConfig {
|
|
|
538
514
|
* `init()` makes to see every failure the runtime handles in production:
|
|
539
515
|
* an `<Errored>` fallback rendered, a `<Loading>` fragment rejected, a
|
|
540
516
|
* server-function throw (HTTP dispatch or an in-process call during SSR),
|
|
541
|
-
* the failure that fails a request. Called once per error object
|
|
542
|
-
*
|
|
543
|
-
*
|
|
517
|
+
* the failure that fails a request. Called once per error object per kind
|
|
518
|
+
* per request (per render outside one), at first sight, wherever the runtime
|
|
519
|
+
* met it; its return, when given, is the wire value (see
|
|
520
|
+
* `ServerErrorHook`). A per-request hook — `renderToStream`'s
|
|
544
521
|
* `onError`, the server-function handler's — overrides it for that
|
|
545
522
|
* request. Registered on `globalThis` under a registered symbol, so a
|
|
546
523
|
* bundled server build and an instrumented `--import`ed module share it.
|
|
@@ -561,8 +538,8 @@ export declare function configureServerErrors(config: ServerErrorsConfig): void;
|
|
|
561
538
|
* function the runtime reports, such as a throw a framework's request
|
|
562
539
|
* handler catches from its middleware. The ambient server error hook hears
|
|
563
540
|
* it as `{ kind: "request", handling: "failed", event }`, once per error
|
|
564
|
-
* object, and its return is ignored, as for every `handling:
|
|
565
|
-
* render failure is the render's: a synchronous throw out of
|
|
541
|
+
* object per request, and its return is ignored, as for every `handling:
|
|
542
|
+
* "failed"`. A render failure is the render's: a synchronous throw out of
|
|
566
543
|
* `renderToString` or `renderToStream` was already heard as `kind:
|
|
567
544
|
* "render"` before the caller caught it, so reporting it here adds nothing.
|
|
568
545
|
* With no hook registered the failure goes to `console.error`, as a render
|
|
@@ -651,12 +628,13 @@ export declare function getHydrationWriter(): HydrationWriter | undefined;
|
|
|
651
628
|
* // in <Router>'s server render
|
|
652
629
|
* setLinkClaim(attrs => matchLink(attrs, location) ? ' data-active aria-current="page"' : "");
|
|
653
630
|
* ```
|
|
654
|
-
* @
|
|
631
|
+
* @internal
|
|
655
632
|
*/
|
|
656
633
|
export declare function setLinkClaim(handler: LinkClaimHandler | undefined): boolean;
|
|
657
634
|
/**
|
|
658
635
|
* Server: `false`. The client reads the `links` hydration record a render
|
|
659
636
|
* with a link handler wrote (`setLinkClaim`); see the client entry.
|
|
637
|
+
* @internal
|
|
660
638
|
*/
|
|
661
639
|
export declare function hasServerLinkState(): boolean;
|
|
662
640
|
/** Server stub — the registry is the client's. See the client entry. */
|
|
@@ -691,7 +669,10 @@ export declare function createSSRResponse(result: {
|
|
|
691
669
|
}): void;
|
|
692
670
|
}, event: RequestEvent | undefined, options?: SSRResponseOptions): Promise<Response>;
|
|
693
671
|
export declare function composeMiddleware(middlewares: FetchMiddleware[]): (request: Request, next: (request?: Request) => Response | Promise<Response>) => Promise<Response>;
|
|
694
|
-
/**
|
|
672
|
+
/**
|
|
673
|
+
* Options for `registerElementClaim` (see the client entry); inert on the server.
|
|
674
|
+
* @internal
|
|
675
|
+
*/
|
|
695
676
|
export type ElementClaimOptions = {
|
|
696
677
|
/**
|
|
697
678
|
* Attribute names whose compiler-owned writes re-claim an already claimed
|
|
@@ -708,5 +689,5 @@ export declare function claimElement<T extends Element>(node: T, owner?: Owner |
|
|
|
708
689
|
export declare function claimElementTree<T extends Node>(root: T): T;
|
|
709
690
|
/** Server: `fn()`. No event is dispatched during SSR, so there is no interaction to join. */
|
|
710
691
|
export declare function dispatchAsInteraction<T>(_e: Event, fn: () => T): T;
|
|
711
|
-
export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
|
|
692
|
+
export { notSup as style, notSup as insert, notSup as spread, notSup as delegateEvents, notSup as registerDelegatedRoot, notSup as unregisterDelegatedRoot, notSup as registerDelegatedContainer, notSup as unregisterDelegatedContainer, notSup as getDelegatedRoot, notSup as dynamicProperty, notSup as setAttribute, notSup as setAttributeNS, notSup as addEvent, notSup as render, notSup as template, notSup as setProperty, notSup as setStatefulProperty, notSup as className, notSup as assign, notSup as hydrate, notSup as getNextElement, notSup as getNextMatch, notSup as getNextMarker, notSup as runHydrationEvents, notSup as ref, notSup as setStyleProperty, notSup as readShallow, notSup as acquireAsset };
|
|
712
693
|
declare function notSup(): void;
|
package/frames/dist/bind.dev.js
DELETED
|
@@ -1,326 +0,0 @@
|
|
|
1
|
-
import { DEV, OBSERVE, createSignal, untrack, createRenderEffect, onCleanup } from 'solid-js';
|
|
2
|
-
import { assign, runHydrationEvents } from '@solidjs/web';
|
|
3
|
-
import { sharedConfig } from 'solid-js/internal';
|
|
4
|
-
import { isAsyncValue as isAsyncValue$1 } from '@solidjs/web/frames';
|
|
5
|
-
|
|
6
|
-
const SLOT_MARKER = "_s:";
|
|
7
|
-
const SLOT_TEXT = SLOT_MARKER + "t=";
|
|
8
|
-
function isAsyncValue(v) {
|
|
9
|
-
return v !== null && typeof v === "object" && (typeof v.then === "function" || typeof v[Symbol.asyncIterator] === "function");
|
|
10
|
-
}
|
|
11
|
-
function shapeOf(v) {
|
|
12
|
-
return v === null ? "null" : typeof Node === "function" && v instanceof Node ? "a DOM node" : Array.isArray(v) ? "an array" : isAsyncValue(v) ? "an async value" : typeof v;
|
|
13
|
-
}
|
|
14
|
-
function slotShapeFinding(data, message) {
|
|
15
|
-
DEV.report(OBSERVE.diagnostics.emit({
|
|
16
|
-
code: "BINDING_SLOT_POSITION",
|
|
17
|
-
kind: "render",
|
|
18
|
-
severity: "warn",
|
|
19
|
-
message,
|
|
20
|
-
data
|
|
21
|
-
}, null));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function slotEntry(entry, pos) {
|
|
25
|
-
const colon = entry.indexOf(":");
|
|
26
|
-
if (colon < 1) return null;
|
|
27
|
-
const eq = entry.indexOf("=", colon);
|
|
28
|
-
return [entry.slice(0, colon), {
|
|
29
|
-
pos,
|
|
30
|
-
key: decodeURIComponent(eq === -1 ? entry.slice(colon + 1) : entry.slice(colon + 1, eq)),
|
|
31
|
-
name: eq === -1 ? undefined : decodeURIComponent(entry.slice(eq + 1))
|
|
32
|
-
}];
|
|
33
|
-
}
|
|
34
|
-
function consumersOf(elements, occurrence) {
|
|
35
|
-
let consumers = elements.get(occurrence);
|
|
36
|
-
if (consumers === undefined) elements.set(occurrence, consumers = []);
|
|
37
|
-
return Array.isArray(consumers) ? consumers : null;
|
|
38
|
-
}
|
|
39
|
-
function text(start, elements) {
|
|
40
|
-
const parsed = slotEntry(start.data.slice(SLOT_TEXT.length), "text");
|
|
41
|
-
const consumers = parsed && consumersOf(elements, parsed[0]);
|
|
42
|
-
if (!consumers) return;
|
|
43
|
-
const element = start.parentNode;
|
|
44
|
-
let consumer;
|
|
45
|
-
for (let i = consumers.length; i-- && !consumer;) if (consumers[i].element === element) consumer = consumers[i];
|
|
46
|
-
consumer || consumers.push(consumer = {
|
|
47
|
-
element,
|
|
48
|
-
positions: []
|
|
49
|
-
});
|
|
50
|
-
parsed[1].start = start;
|
|
51
|
-
consumer.positions.push(parsed[1]);
|
|
52
|
-
}
|
|
53
|
-
function slotPositions(el) {
|
|
54
|
-
const attrs = el.attributes;
|
|
55
|
-
let out = null;
|
|
56
|
-
for (let i = 0; i < attrs.length; i++) {
|
|
57
|
-
const attr = attrs[i];
|
|
58
|
-
if (!attr.name.startsWith(SLOT_MARKER)) continue;
|
|
59
|
-
const pos = attr.name.slice(SLOT_MARKER.length);
|
|
60
|
-
for (const entry of attr.value.split(",")) {
|
|
61
|
-
const parsed = slotEntry(entry, pos);
|
|
62
|
-
if (!parsed) continue;
|
|
63
|
-
out || (out = Object.create(null));
|
|
64
|
-
(out[parsed[0]] || (out[parsed[0]] = [])).push(parsed[1]);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return out;
|
|
68
|
-
}
|
|
69
|
-
function positions(el, elements) {
|
|
70
|
-
const byOccurrence = slotPositions(el);
|
|
71
|
-
if (byOccurrence !== null) {
|
|
72
|
-
for (const occurrence in byOccurrence) {
|
|
73
|
-
const consumers = consumersOf(elements, occurrence);
|
|
74
|
-
if (consumers) consumers.push({
|
|
75
|
-
element: el,
|
|
76
|
-
positions: byOccurrence[occurrence]
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
function consumersEqual(a, b) {
|
|
82
|
-
if (a.length !== b.length) return false;
|
|
83
|
-
for (let i = 0; i < a.length; i++) {
|
|
84
|
-
const x = a[i];
|
|
85
|
-
const y = b[i];
|
|
86
|
-
if (x.element !== y.element || x.positions.length !== y.positions.length) return false;
|
|
87
|
-
for (let j = 0; j < x.positions.length; j++) {
|
|
88
|
-
const p = x.positions[j];
|
|
89
|
-
const q = y.positions[j];
|
|
90
|
-
if (p.pos !== q.pos || p.key !== q.key || p.name !== q.name || p.start !== q.start) return false;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
const byFrame = new WeakMap();
|
|
96
|
-
function occurrencesOf(frame) {
|
|
97
|
-
let slots = byFrame.get(frame);
|
|
98
|
-
if (!slots) byFrame.set(frame, slots = new Map());
|
|
99
|
-
return slots;
|
|
100
|
-
}
|
|
101
|
-
function sync(frame, occurrence, consumers) {
|
|
102
|
-
const slots = occurrencesOf(frame);
|
|
103
|
-
const entry = slots.get(occurrence);
|
|
104
|
-
if (!entry) slots.set(occurrence, {
|
|
105
|
-
consumers,
|
|
106
|
-
rebind: undefined
|
|
107
|
-
});else if (!entry.consumers) entry.consumers = consumers;else if (!consumersEqual(entry.consumers, consumers)) {
|
|
108
|
-
entry.consumers = consumers;
|
|
109
|
-
entry.rebind && entry.rebind(consumers);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
function rebinder(frame, occurrence, fn) {
|
|
113
|
-
const slots = occurrencesOf(frame);
|
|
114
|
-
const entry = slots.get(occurrence);
|
|
115
|
-
if (entry) entry.rebind = fn;else slots.set(occurrence, {
|
|
116
|
-
consumers: undefined,
|
|
117
|
-
rebind: fn
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
function unmount(frame, occurrence) {
|
|
121
|
-
byFrame.get(frame)?.delete(occurrence);
|
|
122
|
-
}
|
|
123
|
-
function owned(el) {
|
|
124
|
-
const attrs = el.attributes;
|
|
125
|
-
let out = null;
|
|
126
|
-
for (let i = 0; i < attrs.length; i++) {
|
|
127
|
-
const name = attrs[i].name;
|
|
128
|
-
if (!name.startsWith(SLOT_MARKER)) continue;
|
|
129
|
-
const pos = name.slice(SLOT_MARKER.length);
|
|
130
|
-
if (pos === "ref" || pos.startsWith("on:")) continue;
|
|
131
|
-
out || (out = {
|
|
132
|
-
attrs: new Set(),
|
|
133
|
-
class: null,
|
|
134
|
-
style: null
|
|
135
|
-
});
|
|
136
|
-
if (pos !== "class" && pos !== "style") {
|
|
137
|
-
out.attrs.add(pos);
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
for (const entry of attrs[i].value.split(",")) {
|
|
141
|
-
const eq = entry.indexOf("=");
|
|
142
|
-
if (eq === -1) {
|
|
143
|
-
out.attrs.add(pos);
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
(out[pos] || (out[pos] = [])).push(decodeURIComponent(entry.slice(eq + 1)));
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
return out;
|
|
150
|
-
}
|
|
151
|
-
function morphOwnedClass(oldEl, value, names) {
|
|
152
|
-
const list = oldEl.classList;
|
|
153
|
-
const set = new Set(value ? value.split(/\s+/) : []);
|
|
154
|
-
set.delete("");
|
|
155
|
-
for (const name of names) list.contains(name) ? set.add(name) : set.delete(name);
|
|
156
|
-
const next = [...set].join(" ");
|
|
157
|
-
if (next === (oldEl.getAttribute("class") || "")) return false;
|
|
158
|
-
next ? oldEl.setAttribute("class", next) : oldEl.removeAttribute("class");
|
|
159
|
-
return true;
|
|
160
|
-
}
|
|
161
|
-
function morphOwnedStyle(oldEl, value, names) {
|
|
162
|
-
const style = oldEl.style;
|
|
163
|
-
const saved = names.map(name => [name, style.getPropertyValue(name), style.getPropertyPriority(name)]);
|
|
164
|
-
const before = oldEl.getAttribute("style");
|
|
165
|
-
value ? oldEl.setAttribute("style", value) : oldEl.removeAttribute("style");
|
|
166
|
-
for (const [name, v, priority] of saved) {
|
|
167
|
-
v ? style.setProperty(name, v, priority) : style.removeProperty(name);
|
|
168
|
-
}
|
|
169
|
-
return oldEl.getAttribute("style") !== before;
|
|
170
|
-
}
|
|
171
|
-
function apply(oldEl, name, value, owned) {
|
|
172
|
-
if (owned.attrs.has(name)) return false;
|
|
173
|
-
if ((name === "class" || name === "style") && owned[name] !== null) {
|
|
174
|
-
return name === "class" ? morphOwnedClass(oldEl, value, owned.class) : morphOwnedStyle(oldEl, value, owned.style);
|
|
175
|
-
}
|
|
176
|
-
return undefined;
|
|
177
|
-
}
|
|
178
|
-
const handlerOwners = new WeakMap();
|
|
179
|
-
function bind(fill, args, ctx, label) {
|
|
180
|
-
const [consumers, setConsumers] = createSignal(ctx.positions);
|
|
181
|
-
ctx.onRebind(setConsumers);
|
|
182
|
-
const raw = untrack(() => fill(args), label);
|
|
183
|
-
const node = typeof Node === "function" && raw instanceof Node;
|
|
184
|
-
const pending = isAsyncValue$1(raw);
|
|
185
|
-
if ((raw == null || typeof raw !== "object" || Array.isArray(raw) || node || pending)) {
|
|
186
|
-
const shape = shapeOf(raw);
|
|
187
|
-
slotShapeFinding({
|
|
188
|
-
reason: "fill-shape",
|
|
189
|
-
occurrence: ctx.key,
|
|
190
|
-
shape
|
|
191
|
-
}, `[BINDING_SLOT_POSITION] The fill for \`${ctx.key}\` returned ${shape}; server markup reads ` + `its properties at bound positions, so it must return an object (\`{ done, onToggle, … }\`). ` + `Nothing binds.`);
|
|
192
|
-
}
|
|
193
|
-
const out = raw == null || typeof raw !== "object" || node || pending ? {} : raw;
|
|
194
|
-
const token = {};
|
|
195
|
-
const state = new WeakMap();
|
|
196
|
-
let bound = new Set();
|
|
197
|
-
createRenderEffect(() => consumers().map(valuesFor), writes => {
|
|
198
|
-
const next = new Set();
|
|
199
|
-
for (const {
|
|
200
|
-
element,
|
|
201
|
-
positions,
|
|
202
|
-
values,
|
|
203
|
-
texts
|
|
204
|
-
} of writes) {
|
|
205
|
-
next.add(element);
|
|
206
|
-
write(element, positions, values);
|
|
207
|
-
for (const [start, v, key] of texts) writeText(start, v, key);
|
|
208
|
-
}
|
|
209
|
-
for (const element of bound) if (!next.has(element)) release(element);
|
|
210
|
-
bound = next;
|
|
211
|
-
});
|
|
212
|
-
onCleanup(() => {
|
|
213
|
-
for (const element of bound) release(element);
|
|
214
|
-
});
|
|
215
|
-
function valuesFor({
|
|
216
|
-
element,
|
|
217
|
-
positions
|
|
218
|
-
}) {
|
|
219
|
-
const props = {};
|
|
220
|
-
const texts = [];
|
|
221
|
-
let classNames = null;
|
|
222
|
-
let styleProps = null;
|
|
223
|
-
for (const {
|
|
224
|
-
pos,
|
|
225
|
-
key,
|
|
226
|
-
name,
|
|
227
|
-
start
|
|
228
|
-
} of positions) {
|
|
229
|
-
if (pos === "ref" || pos.startsWith("on:")) continue;
|
|
230
|
-
if (pos === "text") texts.push([start, out[key], key]);else if (pos === "class" || pos === "style") {
|
|
231
|
-
if (name === undefined) props[pos] = out[key];else if (pos === "class") (classNames || (classNames = {}))[name] = !!out[key];else (styleProps || (styleProps = {}))[name] = out[key];
|
|
232
|
-
} else props[pos] = out[key];
|
|
233
|
-
}
|
|
234
|
-
if (classNames !== null && !("class" in props)) props.class = classNames;
|
|
235
|
-
if (styleProps !== null && !("style" in props)) props.style = styleProps;
|
|
236
|
-
return {
|
|
237
|
-
element,
|
|
238
|
-
positions,
|
|
239
|
-
values: props,
|
|
240
|
-
texts
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
function write(element, positions, props) {
|
|
244
|
-
let st = state.get(element);
|
|
245
|
-
if (!st) state.set(element, st = {
|
|
246
|
-
prev: {},
|
|
247
|
-
handlers: {},
|
|
248
|
-
ref: undefined,
|
|
249
|
-
refId: ""
|
|
250
|
-
});
|
|
251
|
-
const handlers = {};
|
|
252
|
-
const refKeys = [];
|
|
253
|
-
for (const {
|
|
254
|
-
pos,
|
|
255
|
-
key
|
|
256
|
-
} of positions) {
|
|
257
|
-
if (pos === "ref") refKeys.push(key);else if (pos.startsWith("on:")) handlers["on" + pos[3].toUpperCase() + pos.slice(4)] = key;
|
|
258
|
-
}
|
|
259
|
-
let owners = handlerOwners.get(element);
|
|
260
|
-
if (!owners) handlerOwners.set(element, owners = {});
|
|
261
|
-
let events = false;
|
|
262
|
-
for (const prop in handlers) {
|
|
263
|
-
events = true;
|
|
264
|
-
const key = handlers[prop];
|
|
265
|
-
let h = st.handlers[prop];
|
|
266
|
-
if (h === undefined || h.key !== key) st.handlers[prop] = h = {
|
|
267
|
-
key,
|
|
268
|
-
value: untrack(() => out[key])
|
|
269
|
-
};
|
|
270
|
-
props[prop] = h.value;
|
|
271
|
-
owners[prop] = token;
|
|
272
|
-
}
|
|
273
|
-
const clearing = {};
|
|
274
|
-
for (const prop in st.handlers) {
|
|
275
|
-
if (prop in handlers) continue;
|
|
276
|
-
delete st.handlers[prop];
|
|
277
|
-
if (owners[prop] === token) {
|
|
278
|
-
delete owners[prop];
|
|
279
|
-
clearing[prop] = true;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
if (refKeys.length) {
|
|
283
|
-
const id = refKeys.join(",");
|
|
284
|
-
if (st.refId !== id) {
|
|
285
|
-
const refs = refKeys.map(k => untrack(() => out[k]));
|
|
286
|
-
st.refId = id;
|
|
287
|
-
st.ref = el => {
|
|
288
|
-
for (const r of refs) typeof r === "function" && r(el);
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
props.ref = st.ref;
|
|
292
|
-
}
|
|
293
|
-
for (const k in st.prev) {
|
|
294
|
-
if (k in props || k === "ref" || k in clearing) continue;
|
|
295
|
-
delete st.prev[k];
|
|
296
|
-
}
|
|
297
|
-
assign(element, props, true, st.prev);
|
|
298
|
-
if (events && sharedConfig.completed && !sharedConfig.completed.has(element)) {
|
|
299
|
-
sharedConfig.completed.add(element);
|
|
300
|
-
runHydrationEvents();
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
function release(element) {
|
|
304
|
-
if (!state.has(element)) return;
|
|
305
|
-
write(element, [], {});
|
|
306
|
-
state.delete(element);
|
|
307
|
-
}
|
|
308
|
-
function writeText(start, v, key) {
|
|
309
|
-
let s = "";
|
|
310
|
-
if (typeof v === "string" || typeof v === "number") s = "" + v;else if (v != null && typeof v !== "boolean") {
|
|
311
|
-
const shape = shapeOf(v);
|
|
312
|
-
slotShapeFinding({
|
|
313
|
-
reason: "text-shape",
|
|
314
|
-
occurrence: ctx.key,
|
|
315
|
-
key,
|
|
316
|
-
shape
|
|
317
|
-
}, `[BINDING_SLOT_POSITION] \`${key}\` of \`${ctx.key}\` is placed as text, but the fill ` + `returned ${shape} for it. A text position renders a string or number; markup belongs ` + `in a template slot. The text is cleared.`);
|
|
318
|
-
}
|
|
319
|
-
const n = start.nextSibling;
|
|
320
|
-
if (n && n.nodeType === 3) {
|
|
321
|
-
if (n.data !== s) n.data = s;
|
|
322
|
-
} else if (s) start.after(s);
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
export { apply, bind, owned, positions, rebinder, sync, text, unmount };
|