@bgub/fig 0.0.1 → 0.1.0-alpha.1
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/CHANGELOG.md +501 -0
- package/README.md +50 -19
- package/dist/element-BZ7r9ncY.d.ts +342 -0
- package/dist/element-DmbzNH0T.js +299 -0
- package/dist/element-DmbzNH0T.js.map +1 -0
- package/dist/hooks-QDRabULx.d.ts +158 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +4 -4
- package/dist/internal.d.ts +212 -6
- package/dist/internal.js +14 -43
- package/dist/internal.js.map +1 -1
- package/dist/jsx-runtime.d.ts +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/payload-format-KTNaSI4h.js +366 -0
- package/dist/payload-format-KTNaSI4h.js.map +1 -0
- package/dist/payload.d.ts +92 -0
- package/dist/payload.js +429 -0
- package/dist/payload.js.map +1 -0
- package/dist/{transition-DEqcImne.js → resource-kXeIR52S.js} +121 -71
- package/dist/resource-kXeIR52S.js.map +1 -0
- package/dist/{data-store-CRnNAT9-.js → transition-CC4kjjrU.js} +165 -54
- package/dist/transition-CC4kjjrU.js.map +1 -0
- package/package.json +5 -6
- package/dist/data-CHJh_xU9.d.ts +0 -79
- package/dist/data-h46EcMnE.js +0 -37
- package/dist/data-h46EcMnE.js.map +0 -1
- package/dist/data-store-CRnNAT9-.js.map +0 -1
- package/dist/data-store-EQOLQsW4.d.ts +0 -32
- package/dist/element-Bh_k9c3N.js +0 -179
- package/dist/element-Bh_k9c3N.js.map +0 -1
- package/dist/element-CCOOi4Ka.d.ts +0 -209
- package/dist/server.browser.d.ts +0 -9
- package/dist/server.browser.js +0 -8
- package/dist/server.browser.js.map +0 -1
- package/dist/server.d.ts +0 -9
- package/dist/server.js +0 -9
- package/dist/server.js.map +0 -1
- package/dist/transition-Cl6mAPcx.d.ts +0 -96
- package/dist/transition-DEqcImne.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payload.js","names":["attachAssets"],"sources":["../src/payload.ts"],"sourcesContent":["import type { FigDataHydrationEntry } from \"./data.ts\";\nimport {\n type AwaitedFigNode,\n createElement,\n type ElementType,\n FigElementSymbol,\n type FigNode,\n Fragment,\n type Key,\n type Props,\n Suspense,\n ViewTransition,\n} from \"./element.ts\";\nimport { readPromise } from \"./hooks.ts\";\nimport {\n decodePayloadDataEntries,\n decodePayloadRecord,\n decodePayloadValueTag,\n errorFromPayloadValue,\n isPayloadSpecialModel,\n jsonPayloadCodec,\n type PayloadDecodeRefs,\n type PayloadElementModel,\n type PayloadModel,\n type PayloadRow,\n type PayloadRowDecoder,\n type PayloadSpecialModel,\n type SerializedAssetResource,\n} from \"./payload-format.ts\";\nimport {\n assetResourceDestination,\n assets as attachAssets,\n type FigAssetResource,\n isFigAssetResource,\n} from \"./resource.ts\";\nimport { isThenable, trackThenable } from \"./thenables.ts\";\n\nexport interface PayloadClientReference {\n assets?: readonly FigAssetResource[];\n exportName?: string;\n id: string;\n ssr?: boolean;\n}\n\nexport type ResolveClientReference = (\n reference: PayloadClientReference,\n) => ElementType<any> | PromiseLike<ElementType<any>> | undefined;\n\n/**\n * A caller-owned stateful resolver: a `ResolveClientReference` that also\n * owns component identity. Decodes given one (as `resolveClientReference`)\n * resolve every client reference to a single resolver-owned wrapper per\n * reference id, so re-decoding a payload updates islands in place instead\n * of remounting them. The caller owns the lifetime: drop entries when their\n * modules change (HMR) or the manifest swaps.\n */\nexport interface PayloadClientReferenceResolver {\n (\n reference: PayloadClientReference,\n ): ElementType<any> | PromiseLike<ElementType<any>> | undefined;\n clear(): void;\n delete(id: string): boolean;\n}\n\nconst resolverEntries = new WeakMap<\n ResolveClientReference,\n Map<string, ElementType<any>>\n>();\n\nexport function createPayloadClientReferenceResolver(\n resolve: ResolveClientReference,\n): PayloadClientReferenceResolver {\n const entries = new Map<string, ElementType<any>>();\n const resolver = Object.assign(\n (reference: PayloadClientReference) => resolve(reference),\n {\n clear: (): void => entries.clear(),\n delete: (id: string): boolean => entries.delete(id),\n },\n );\n resolverEntries.set(resolver, entries);\n return resolver;\n}\n\n// Reveal gates ride the decoded element instances, not the reference\n// wrapper: each decode attaches its own gate to the elements it\n// materializes. Identity lives on the component type; the asset dependency\n// lives on the element — so a mounted island (a previous decode's elements)\n// can never be re-suspended by a newer decode's pending assets, while the\n// newer decode's elements gate on exactly the assets they declared.\n// Elements minted outside a decode from a cached component carry no gate\n// and render ungated: they declared no dependency.\nconst elementGates = new WeakMap<Props, Promise<void>>();\nconst elementAssets = new WeakMap<Props, readonly FigAssetResource[]>();\n\nexport type PayloadDecodeCompletion =\n | { status: \"aborted\" }\n | { status: \"complete\" }\n | { status: \"failed\"; error: unknown };\n\nexport interface PayloadDecodeOptions {\n /**\n * Receives decoded `data` rows for hydration into a data store. The\n * capability itself is expected to be generation-guarded and to ignore\n * entries after its caller loses authority.\n */\n hydrate?: (entries: readonly FigDataHydrationEntry[]) => void;\n /**\n * Observes every outlined hole rejection — an `error` row or a stream\n * failure stranding referenced rows, before or after the root fulfills.\n * Abort cancellation is excluded. Called once per rejected hole; the\n * observer is never awaited and cannot break decoding.\n */\n onHoleError?: (error: unknown) => unknown;\n /**\n * Observes the end of ingestion: called exactly once when the stream\n * settles as complete, failed, or aborted. Post-root failures reject the\n * holes they strand, but a failure with no pending slot is otherwise\n * invisible — this is the hook for reporting it. The callback is never\n * awaited, and its exceptions and rejections are swallowed, so an\n * observer cannot block or break decode teardown.\n */\n onStreamDone?: (result: PayloadDecodeCompletion) => unknown;\n /**\n * Called with delivery asset resources as soon as their rows arrive\n * (e.g. fig-dom's insertAssetResources). A returned promise gates the\n * reveal of only the content that declared a dependency on those assets;\n * gate settlement — fulfilled or rejected — releases the reveal, so a\n * failed asset never blocks content.\n */\n prepareAssets?: (\n assets: readonly FigAssetResource[],\n ) => void | PromiseLike<void>;\n /**\n * Retains delivery asset dependencies as `assets(...)` declarations on\n * their decoded owners. Document metadata is always retained because its\n * owner may mutate the document only when it commits. Server document\n * renderers enable this option to retain delivery assets too.\n */\n retainAssets?: boolean;\n /**\n * Resolves client-reference rows to components. A plain function keeps\n * identity per decode: gated and asynchronously resolved references decode\n * to per-decode wrappers and remount on re-decode. A stateful resolver\n * (created by `createPayloadClientReferenceResolver`) keeps every\n * resolvable reference's identity stable across the decodes sharing it.\n */\n resolveClientReference?: ResolveClientReference;\n signal?: AbortSignal;\n}\n\nclass PayloadDecodeAbortedError extends Error {\n constructor(reason?: unknown) {\n super(\n \"Payload decode aborted.\",\n reason === undefined ? undefined : { cause: reason },\n );\n this.name = \"PayloadDecodeAbortedError\";\n }\n}\n\n/**\n * Decode a payload row stream. The returned promise resolves with the\n * decoded root FigNode as soon as the root row decodes (and rejects only\n * when the stream fails before producing a root value, or with the root\n * row's own error); decoding continues in the background, filling outlined\n * holes as their rows arrive. Post-root failures reject the holes they\n * strand and report through `onStreamDone`. Aborting `options.signal`\n * ignores remaining rows and rejects unresolved holes with an internal\n * cancellation reason.\n */\nexport function decodePayloadStream(\n stream: ReadableStream<Uint8Array>,\n options: PayloadDecodeOptions = {},\n): Promise<AwaitedFigNode> {\n return new PayloadStreamDecode(stream, options).value;\n}\n\ntype DecodeChunk = {\n // The chunk's row has been ingested (decoded or rejected); reveal may still\n // be waiting on an asset gate. Truncation and abort reject only chunks\n // whose rows never arrived.\n arrived: boolean;\n // Materialized lazily: most rows settle synchronously at arrival and are\n // only ever read through result, so eagerly allocating a promise and\n // its controls per row would be waste.\n deferred: Deferred<unknown> | null;\n id: number;\n promise: Promise<unknown> | null;\n result:\n | { status: \"pending\" }\n | { status: \"fulfilled\"; value: unknown }\n | { status: \"rejected\"; error: unknown };\n};\n\ntype DecodingElement = {\n $$typeof: symbol;\n key: Key | null;\n props: Props;\n type: ElementType<any>;\n};\n\nconst noop = (): void => undefined;\n\ninterface Deferred<T> {\n promise: Promise<T>;\n reject: (reason: unknown) => void;\n resolve: (value: T) => void;\n}\n\nfunction deferred<T>(): Deferred<T> {\n let resolve: Deferred<T>[\"resolve\"] = noop;\n let reject: Deferred<T>[\"reject\"] = noop;\n const promise = new Promise<T>((innerResolve, innerReject) => {\n resolve = innerResolve;\n reject = innerReject;\n });\n return { promise, reject, resolve };\n}\n\nfunction decodeAssetResources(\n serialized: readonly SerializedAssetResource[] | undefined,\n): FigAssetResource[] | null {\n if (serialized === undefined) return null;\n const assets = serialized.filter(isFigAssetResource);\n return assets.length === 0 ? null : assets;\n}\n\nclass PayloadStreamDecode {\n readonly value: Promise<AwaitedFigNode>;\n\n private readonly chunks = new Map<number, DecodeChunk>();\n private readonly objectRefs = new Map<number, unknown>();\n // Asset gates registered for a row id (assets rows carry `for`); consumed\n // when that row arrives.\n private readonly rowGates = new Map<number, Array<PromiseLike<void>>>();\n private readonly rowAssets = new Map<number, readonly FigAssetResource[]>();\n // Unsettled reveal gates for arrived client rows, attached per element as\n // models referencing the row materialize (see elementGates).\n private readonly clientRowGates = new Map<number, Promise<void>>();\n private readonly clientRowAssets = new Map<\n number,\n readonly FigAssetResource[]\n >();\n private readonly rowDecoder: PayloadRowDecoder;\n private reader: ReadableStreamDefaultReader<Uint8Array> | null = null;\n private done = false;\n // Resolved on abort so arrived-but-gated chunks reveal instead of waiting\n // for asset gates that may never settle.\n private readonly gateRelease = deferred<void>();\n private removeAbortListener: () => void = noop;\n // One closure and one refs adapter reused across every decoded model, so\n // the per-node decode loop allocates only the decoded values themselves.\n private readonly decodeChild = (model: PayloadModel): unknown =>\n this.decodeModel(model);\n private readonly valueRefs: PayloadDecodeRefs = {\n define: (id, create, fill) => this.defineObjectRef(id, create, fill),\n read: (id) => {\n if (!this.objectRefs.has(id)) {\n throw new Error(`Payload referenced unknown object id ${id}.`);\n }\n return this.objectRefs.get(id);\n },\n };\n\n constructor(\n stream: ReadableStream<Uint8Array>,\n private readonly options: PayloadDecodeOptions,\n ) {\n this.rowDecoder = jsonPayloadCodec.createDecoder((row) =>\n this.handleRow(row),\n );\n this.value = this.chunkPromise(this.getChunk(0)) as Promise<AwaitedFigNode>;\n\n void this.ingest(stream);\n\n const signal = options.signal;\n if (signal !== undefined) {\n if (signal.aborted) {\n this.abort(signal.reason);\n } else {\n const onAbort = () => this.abort(signal.reason);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n this.removeAbortListener = () =>\n signal.removeEventListener(\"abort\", onAbort);\n }\n }\n }\n\n abort(reason?: unknown): void {\n if (this.done) return;\n const error = new PayloadDecodeAbortedError(reason);\n this.gateRelease.resolve(undefined);\n void this.reader?.cancel(error).catch(noop);\n this.rejectUnresolved(error);\n this.settle({ status: \"aborted\" });\n }\n\n private async ingest(stream: ReadableStream<Uint8Array>): Promise<void> {\n const reader = stream.getReader();\n this.reader = reader;\n\n try {\n for (;;) {\n const { done, value } = await reader.read();\n if (this.done) return;\n if (done) break;\n this.rowDecoder.decode(value);\n }\n this.rowDecoder.flush();\n this.finishIngestion();\n } catch (error) {\n if (this.done) return;\n void reader.cancel(error).catch(noop);\n this.failIngestion(error);\n }\n }\n\n private finishIngestion(): void {\n let truncated = false;\n for (const chunk of this.chunks.values()) {\n if (!chunk.arrived) {\n truncated = true;\n break;\n }\n }\n if (truncated) {\n // The server closes the stream only after every outlined row has been\n // written, so an unresolved reference at end-of-stream is truncation.\n this.failIngestion(\n new Error(\"Payload stream ended before all referenced rows arrived.\"),\n );\n return;\n }\n this.settle({ status: \"complete\" });\n }\n\n private failIngestion(error: unknown): void {\n if (this.done) return;\n this.rejectUnresolved(error);\n this.settle({ status: \"failed\", error });\n }\n\n private rejectUnresolved(error: unknown): void {\n for (const chunk of this.chunks.values()) {\n if (chunk.arrived) continue;\n chunk.arrived = true;\n this.rejectChunk(chunk, error);\n }\n }\n\n private settle(result: PayloadDecodeCompletion): void {\n if (this.done) return;\n this.done = true;\n this.removeAbortListener();\n try {\n const observed = this.options.onStreamDone?.(result);\n // An async observer's rejection must not surface as an unhandled\n // rejection any more than a sync throw may break teardown.\n if (isThenable(observed)) void Promise.resolve(observed).then(noop, noop);\n } catch {\n // An observer must not be able to break ingestion teardown.\n }\n }\n\n private handleRow(row: PayloadRow): void {\n if (this.done) return;\n\n switch (row.tag) {\n case \"model\": {\n const chunk = this.getChunk(row.id);\n let decoded = this.decodeModel(row.value);\n const retainedAssets = this.rowAssets.get(row.id);\n if (retainedAssets !== undefined) {\n this.rowAssets.delete(row.id);\n decoded = attachAssets(retainedAssets, decoded as FigNode);\n }\n chunk.arrived = true;\n const gates = this.rowGates.get(row.id);\n if (gates === undefined) {\n this.fulfillChunk(chunk, decoded);\n return;\n }\n this.rowGates.delete(row.id);\n void Promise.race([Promise.all(gates), this.gateRelease.promise]).then(\n () => this.fulfillChunk(chunk, decoded),\n );\n return;\n }\n case \"client\": {\n const chunk = this.getChunk(row.id);\n const reference: PayloadClientReference = { id: row.value.id };\n if (row.value.exportName !== undefined) {\n reference.exportName = row.value.exportName;\n }\n if (row.value.ssr === true) reference.ssr = true;\n const assets = decodeAssetResources(row.value.assets);\n if (assets !== null) {\n reference.assets = assets;\n }\n const retainedAssets = this.retainedAssets(assets);\n if (retainedAssets !== null) {\n this.clientRowAssets.set(row.id, retainedAssets);\n }\n const gate = this.prepareAssets(assets);\n if (gate !== null) {\n // Elements referencing this row inherit the gate as they\n // materialize; once it settles there is nothing left to gate.\n // Track it now so a gate that settles before its first render\n // read (e.g. awaited by a router's pre-commit prepare) resolves\n // synchronously instead of suspending for a retry beat.\n trackThenable(gate);\n this.clientRowGates.set(row.id, gate);\n void gate.then(() => {\n this.clientRowGates.delete(row.id);\n });\n }\n const component = this.clientReferenceComponent(\n reference,\n gate,\n retainedAssets !== null,\n );\n chunk.arrived = true;\n this.fulfillChunk(chunk, component);\n return;\n }\n case \"error\": {\n const chunk = this.getChunk(row.id);\n chunk.arrived = true;\n // Reveal-gating a failure is pointless; drop any gates aimed here.\n this.rowGates.delete(row.id);\n this.rowAssets.delete(row.id);\n this.rejectChunk(chunk, errorFromPayloadValue(row.value));\n return;\n }\n case \"data\": {\n const hydrate = this.options.hydrate;\n if (hydrate === undefined) return;\n hydrate(decodePayloadDataEntries(row.value));\n return;\n }\n case \"assets\": {\n const decodedAssets = decodeAssetResources(row.value);\n const retainedAssets = this.retainedAssets(decodedAssets);\n if (retainedAssets !== null && row.for !== undefined) {\n const retained = this.rowAssets.get(row.for);\n this.rowAssets.set(\n row.for,\n retained === undefined\n ? retainedAssets\n : [...retained, ...retainedAssets],\n );\n }\n const gate = this.prepareAssets(decodedAssets);\n if (gate === null || row.for === undefined) return;\n const gates = this.rowGates.get(row.for);\n if (gates === undefined) this.rowGates.set(row.for, [gate]);\n else gates.push(gate);\n return;\n }\n }\n }\n\n // Never rejects and never blocks content on a failed asset: a rejected\n // prepareAssets result (or synchronous throw) settles the gate.\n private prepareAssets(\n assets: readonly FigAssetResource[] | null,\n ): Promise<void> | null {\n const prepare = this.options.prepareAssets;\n if (prepare === undefined || assets === null) return null;\n const delivery = assets.filter(\n (resource) => assetResourceDestination(resource) === \"stream\",\n );\n if (delivery.length === 0) return null;\n\n let result: void | PromiseLike<void>;\n try {\n result = prepare(delivery);\n } catch {\n return null;\n }\n if (!isThenable(result)) return null;\n const gate = Promise.resolve(result).then(noop, noop);\n trackThenable(gate);\n return gate;\n }\n\n private retainedAssets(\n assets: readonly FigAssetResource[] | null,\n ): readonly FigAssetResource[] | null {\n if (assets === null) return null;\n const retained =\n this.options.retainAssets === true\n ? assets\n : assets.filter(\n (resource) => assetResourceDestination(resource) === \"head\",\n );\n return retained.length === 0 ? null : retained;\n }\n\n private clientReferenceComponent(\n reference: PayloadClientReference,\n gate: Promise<void> | null,\n retainsAssets: boolean,\n ): ElementType<any> {\n const resolve = this.options.resolveClientReference;\n const entries =\n resolve === undefined ? undefined : resolverEntries.get(resolve);\n const existing = entries?.get(reference.id);\n if (existing !== undefined) return existing;\n\n let resolved: ReturnType<ResolveClientReference>;\n try {\n resolved = resolve?.(reference);\n } catch (error) {\n resolved = Promise.reject(error);\n }\n\n if (resolved === undefined) {\n // Never cached: a stateful resolver that cannot resolve this\n // reference must not latch the error component for later decodes\n // that can.\n return function PayloadUnresolvedClientComponent(): never {\n throw new Error(\n `Cannot render client reference \"${reference.id}\" because decodePayloadStream was not configured with a matching resolveClientReference.`,\n );\n };\n }\n\n // Without a stateful resolver, an ungated synchronously resolved\n // reference decodes to the component itself, so its element type is\n // stable across decodes whenever the resolver's answer is — re-decoding\n // updates the client component in place and its state survives.\n if (\n entries === undefined &&\n gate === null &&\n !isThenable(resolved) &&\n !retainsAssets\n ) {\n return resolved;\n }\n\n const component = clientReferenceWrapper(resolved, reference.id);\n entries?.set(reference.id, component);\n return component;\n }\n\n private getChunk(id: number): DecodeChunk {\n const existing = this.chunks.get(id);\n if (existing !== undefined) return existing;\n\n const chunk: DecodeChunk = {\n arrived: false,\n deferred: null,\n id,\n promise: null,\n result: { status: \"pending\" },\n };\n this.chunks.set(id, chunk);\n return chunk;\n }\n\n // Materializes (and registers with the thenable registry) on first access:\n // a settled chunk becomes an already-settled promise, a pending one gets\n // live resolvers that fulfillChunk/rejectChunk drive.\n private chunkPromise(chunk: DecodeChunk): Promise<unknown> {\n if (chunk.promise !== null) return chunk.promise;\n\n if (chunk.result.status === \"fulfilled\") {\n chunk.promise = Promise.resolve(chunk.result.value);\n } else if (chunk.result.status === \"rejected\") {\n chunk.promise = Promise.reject(chunk.result.error);\n // Holes nobody awaits must not become unhandled rejections; readers\n // still observe the stored error.\n void chunk.promise.catch(noop);\n } else {\n chunk.deferred = deferred<unknown>();\n chunk.promise = chunk.deferred.promise;\n }\n trackThenable(chunk.promise);\n return chunk.promise;\n }\n\n private fulfillChunk(chunk: DecodeChunk, value: unknown): void {\n if (chunk.result.status !== \"pending\") return;\n chunk.result = { status: \"fulfilled\", value };\n chunk.deferred?.resolve(value);\n }\n\n private rejectChunk(chunk: DecodeChunk, error: unknown): void {\n if (chunk.result.status !== \"pending\") return;\n chunk.result = { error, status: \"rejected\" };\n if (chunk.deferred !== null) {\n chunk.deferred.reject(error);\n void chunk.promise?.catch(noop);\n }\n if (chunk.id !== 0 && !(error instanceof PayloadDecodeAbortedError)) {\n this.observeHoleError(error);\n }\n }\n\n private observeHoleError(error: unknown): void {\n try {\n const observed = this.options.onHoleError?.(error);\n if (isThenable(observed)) void Promise.resolve(observed).then(noop, noop);\n } catch {\n // Error attribution/reporting is observational and cannot break decode.\n }\n }\n\n readChunkForRender(id: number): unknown {\n const chunk = this.getChunk(id);\n if (chunk.result.status === \"rejected\") throw chunk.result.error;\n if (chunk.result.status === \"pending\")\n return readPromise(this.chunkPromise(chunk));\n return chunk.result.value;\n }\n\n private decodeModel(model: PayloadModel): unknown {\n if (model === null) return null;\n if (Array.isArray(model)) return model.map(this.decodeChild);\n if (typeof model !== \"object\") return model;\n\n if (isPayloadSpecialModel(model)) return this.decodeSpecialModel(model);\n\n return decodePayloadRecord(model, this.decodeChild);\n }\n\n private decodeSpecialModel(\n model: PayloadElementModel | PayloadSpecialModel,\n ): unknown {\n switch (model.$fig) {\n case \"element\": {\n if (model.id !== undefined) {\n return this.defineObjectRef(\n model.id,\n (): DecodingElement => ({\n $$typeof: FigElementSymbol,\n key: model.key,\n props: {},\n type: Fragment,\n }),\n (element) => {\n element.type = this.decodeElementType(model.type);\n const props = this.decodeModel(model.props) as Props;\n element.props = props;\n this.attachElementDelivery(model.type, props);\n },\n );\n }\n const type = this.decodeElementType(model.type);\n const props = this.decodeModel(model.props) as Props & {\n key?: Key | null;\n };\n if (model.key !== null) props.key = model.key;\n const element = createElement(type, props);\n // createElement copies props, so the gate keys the element's own\n // props object — the one the component will receive.\n this.attachElementDelivery(model.type, element.props);\n return element;\n }\n case \"client\": {\n const chunk = this.chunks.get(model.id);\n if (chunk === undefined || chunk.result.status !== \"fulfilled\") {\n throw new Error(\n `Payload model referenced client row ${model.id} before it arrived.`,\n );\n }\n return chunk.result.value;\n }\n case \"fragment\":\n return Fragment;\n case \"lazy\":\n // Materialize the hole's chunk now: abort and truncation reject\n // every unresolved chunk, which must include holes that decoded but\n // were never read.\n this.getChunk(model.id);\n return createElement(PayloadStreamHole, { decode: this, id: model.id });\n case \"promise\":\n // Promise props are handed straight to consumers, so the promise\n // (and its thenable-registry tracking) materializes here.\n return this.chunkPromise(this.getChunk(model.id));\n case \"suspense\":\n return Suspense;\n case \"view-transition\":\n return ViewTransition;\n default:\n // Every remaining tag is an ordinary value tag; the shared codec\n // decoder handles it against this decode's request-wide ref store.\n return decodePayloadValueTag(model, this.valueRefs, this.decodeChild);\n }\n }\n\n private decodeElementType(\n type: string | PayloadSpecialModel,\n ): ElementType<any> {\n if (typeof type === \"string\") return type;\n return this.decodeSpecialModel(type) as ElementType<any>;\n }\n\n // A client-referencing element inherits its decode's unsettled row gate;\n // the reference wrapper reads it per element instance at render.\n private attachElementDelivery(\n typeModel: string | PayloadSpecialModel,\n props: Props,\n ): void {\n if (typeof typeModel === \"string\" || typeModel.$fig !== \"client\") return;\n const gate = this.clientRowGates.get(typeModel.id);\n if (gate !== undefined) elementGates.set(props, gate);\n const assets = this.clientRowAssets.get(typeModel.id);\n if (assets !== undefined) elementAssets.set(props, assets);\n }\n\n private defineObjectRef<T>(\n id: number,\n create: () => T,\n fill: (value: T) => void,\n ): T {\n if (this.objectRefs.has(id)) return this.objectRefs.get(id) as T;\n\n const value = create();\n this.objectRefs.set(id, value);\n try {\n fill(value);\n return value;\n } catch (error) {\n this.objectRefs.delete(id);\n throw error;\n }\n }\n}\n\nfunction PayloadStreamHole(props: {\n decode: PayloadStreamDecode;\n id: number;\n}): FigNode {\n return props.decode.readChunkForRender(props.id) as FigNode;\n}\n\n// The one client-reference wrapper: attaches the per-element asset\n// declarations, reads the per-element reveal gate (elementGates), resolves\n// the component, renders it. Owned by a stateful resolver it is reused\n// across decodes, so island identity survives re-decodes whether a given\n// decode arrives gated or not; otherwise it lives for a single decode.\n// Asynchronous resolution starts at row arrival — overlapping the rest of\n// the stream instead of serializing behind it — and latches its type;\n// thenable tracking lets a resolution settled before its first render read\n// synchronously instead of suspending for a retry beat.\n//\n// Assets attach above the suspension points: the outer component always\n// completes, so a renderer delivers the declarations with the segment that\n// contains the reference even while the module load or reveal gate still\n// suspends the content below. The reveal gate and the reference's own\n// props ride explicit content props — createElement clones props objects,\n// so the per-element WeakMaps cannot be read through the inner element.\nfunction clientReferenceWrapper(\n resolved: ElementType<any> | PromiseLike<ElementType<any>>,\n referenceId: string,\n): ElementType<any> {\n let render: (props: Props) => FigNode;\n if (!isThenable(resolved)) {\n render = (props) => createElement(resolved, props);\n } else {\n const pending = Promise.resolve(resolved);\n trackThenable(pending);\n let type: ElementType<any> | null = null;\n render = (props) => {\n if (type === null) {\n type = clientReferenceType(readPromise(pending), referenceId);\n }\n return createElement(type, props);\n };\n }\n\n function PayloadClientContent(content: {\n gate?: Promise<void>;\n props: Props;\n }): FigNode {\n // Suspends while pending; gates never reject (prepareAssets results\n // settle through noop handlers).\n if (content.gate !== undefined) readPromise(content.gate);\n return render(content.props);\n }\n\n return function PayloadClientComponent(props: Props): FigNode {\n return attachElementAssets(\n props,\n createElement(PayloadClientContent, {\n gate: elementGates.get(props),\n props,\n }),\n );\n };\n}\n\nfunction attachElementAssets(props: Props, node: FigNode): FigNode {\n const resources = elementAssets.get(props);\n return resources === undefined ? node : attachAssets(resources, node);\n}\n\nfunction clientReferenceType(value: unknown, id: string): ElementType<any> {\n if (typeof value === \"function\") return value as ElementType<any>;\n throw new Error(`Client reference \"${id}\" did not resolve to a component.`);\n}\n"],"mappings":";;;;AAgEA,MAAM,kCAAkB,IAAI,QAG1B;AAEF,SAAgB,qCACd,SACgC;CAChC,MAAM,0BAAU,IAAI,IAA8B;CAClD,MAAM,WAAW,OAAO,QACrB,cAAsC,QAAQ,SAAS,GACxD;EACE,aAAmB,QAAQ,MAAM;EACjC,SAAS,OAAwB,QAAQ,OAAO,EAAE;CACpD,CACF;CACA,gBAAgB,IAAI,UAAU,OAAO;CACrC,OAAO;AACT;AAUA,MAAM,+BAAe,IAAI,QAA8B;AACvD,MAAM,gCAAgB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AAK;EAC7B,IAAI;GACF,KAAK,KAAK;GACV,OAAO;EACT,SAAS,OAAO;GACd,KAAK,WAAW,OAAO,EAAE;GACzB,MAAM;EACR;CACF;AACF;AAEA,SAAS,kBAAkB,OAGf;CACV,OAAO,MAAM,OAAO,mBAAmB,MAAM,EAAE;AACjD;AAkBA,SAAS,uBACP,UACA,aACkB;CAClB,IAAI;CACJ,IAAI,CAAC,WAAW,QAAQ,GACtB,UAAU,UAAU,cAAc,UAAU,KAAK;MAC5C;EACL,MAAM,UAAU,QAAQ,QAAQ,QAAQ;EACxC,cAAc,OAAO;EACrB,IAAI,OAAgC;EACpC,UAAU,UAAU;GAClB,IAAI,SAAS,MACX,OAAO,oBAAoB,YAAY,OAAO,GAAG,WAAW;GAE9D,OAAO,cAAc,MAAM,KAAK;EAClC;CACF;CAEA,SAAS,qBAAqB,SAGlB;EAGV,IAAI,QAAQ,SAAS,KAAA,GAAW,YAAY,QAAQ,IAAI;EACxD,OAAO,OAAO,QAAQ,KAAK;CAC7B;CAEA,OAAO,SAAS,uBAAuB,OAAuB;EAC5D,OAAO,oBACL,OACA,cAAc,sBAAsB;GAClC,MAAM,aAAa,IAAI,KAAK;GAC5B;EACF,CAAC,CACH;CACF;AACF;AAEA,SAAS,oBAAoB,OAAc,MAAwB;CACjE,MAAM,YAAY,cAAc,IAAI,KAAK;CACzC,OAAO,cAAc,KAAA,IAAY,OAAOA,OAAa,WAAW,IAAI;AACtE;AAEA,SAAS,oBAAoB,OAAgB,IAA8B;CACzE,IAAI,OAAO,UAAU,YAAY,OAAO;CACxC,MAAM,IAAI,MAAM,qBAAqB,GAAG,kCAAkC;AAC5E"}
|
|
@@ -1,17 +1,44 @@
|
|
|
1
|
-
import { g as createElement, n as Assets } from "./element-
|
|
2
|
-
//#region src/
|
|
3
|
-
const
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { g as createElement, n as Assets } from "./element-DmbzNH0T.js";
|
|
2
|
+
//#region src/thenables.ts
|
|
3
|
+
const thenableRecords = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
function recordFor(thenable) {
|
|
5
|
+
const key = thenable;
|
|
6
|
+
let record = thenableRecords.get(key);
|
|
7
|
+
if (record === void 0) {
|
|
8
|
+
record = { status: "pending" };
|
|
9
|
+
thenableRecords.set(key, record);
|
|
10
|
+
thenable.then((value) => {
|
|
11
|
+
record = {
|
|
12
|
+
status: "fulfilled",
|
|
13
|
+
value
|
|
14
|
+
};
|
|
15
|
+
thenableRecords.set(key, record);
|
|
16
|
+
}, (reason) => {
|
|
17
|
+
record = {
|
|
18
|
+
reason,
|
|
19
|
+
status: "rejected"
|
|
20
|
+
};
|
|
21
|
+
thenableRecords.set(key, record);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
return record;
|
|
9
25
|
}
|
|
10
|
-
function
|
|
11
|
-
|
|
26
|
+
function trackThenable(thenable) {
|
|
27
|
+
recordFor(thenable);
|
|
28
|
+
}
|
|
29
|
+
function readThenable(thenable) {
|
|
30
|
+
const record = recordFor(thenable);
|
|
31
|
+
if (record.status === "fulfilled") return record.value;
|
|
32
|
+
if (record.status === "rejected") throw record.reason;
|
|
33
|
+
throw thenable;
|
|
34
|
+
}
|
|
35
|
+
function isThenable(value) {
|
|
36
|
+
if (typeof value !== "object" && typeof value !== "function" || value === null) return false;
|
|
37
|
+
return "then" in value && typeof value.then === "function";
|
|
12
38
|
}
|
|
13
39
|
//#endregion
|
|
14
40
|
//#region src/resource.ts
|
|
41
|
+
const PreventAssetResourceHoistSymbol = Symbol.for("fig.prevent-asset-resource-hoist");
|
|
15
42
|
function assets(value, children) {
|
|
16
43
|
return createElement(Assets, { assets: value }, children);
|
|
17
44
|
}
|
|
@@ -72,7 +99,7 @@ function meta(options) {
|
|
|
72
99
|
};
|
|
73
100
|
}
|
|
74
101
|
function isFigAssetResource(value) {
|
|
75
|
-
if (typeof value !== "object" || value === null) return false;
|
|
102
|
+
if (typeof value !== "object" || value === null || !("kind" in value)) return false;
|
|
76
103
|
switch (value.kind) {
|
|
77
104
|
case "stylesheet":
|
|
78
105
|
case "preload":
|
|
@@ -110,39 +137,48 @@ function assetResourceDestination(resource) {
|
|
|
110
137
|
return resource.kind === "title" || resource.kind === "meta" ? "head" : "stream";
|
|
111
138
|
}
|
|
112
139
|
function assetResourceFromHostProps(type, props) {
|
|
113
|
-
|
|
140
|
+
if (props[PreventAssetResourceHoistSymbol] === true) return null;
|
|
141
|
+
return resourceFromHost(type, (name) => props[name], props.children, true);
|
|
142
|
+
}
|
|
143
|
+
function preventAssetResourceHoist(props) {
|
|
144
|
+
Object.defineProperty(props, PreventAssetResourceHoistSymbol, {
|
|
145
|
+
enumerable: true,
|
|
146
|
+
value: true
|
|
147
|
+
});
|
|
148
|
+
return props;
|
|
114
149
|
}
|
|
115
150
|
function assetResourceFromHostAttributes(type, getAttribute) {
|
|
116
|
-
return resourceFromHost(type, getAttribute);
|
|
151
|
+
return resourceFromHost(type, getAttribute, void 0, false);
|
|
117
152
|
}
|
|
118
153
|
function assetResourceHostAttributes(resource) {
|
|
119
154
|
const pairs = [];
|
|
120
155
|
switch (resource.kind) {
|
|
121
156
|
case "stylesheet":
|
|
122
|
-
pairs.push(["rel", "stylesheet"], ["href", resource.href], ["data-fig-resource-key", resource.key], ["data-precedence", resource.precedence], ["media", resource.media], ["crossorigin", resource.
|
|
157
|
+
pairs.push(["rel", "stylesheet"], ["href", resource.href], ["data-fig-resource-key", resource.key], ["data-precedence", resource.precedence], ["media", resource.media], ["crossorigin", resource.crossorigin]);
|
|
123
158
|
break;
|
|
124
159
|
case "preload":
|
|
125
|
-
pairs.push(["rel", "preload"], ["href", resource.href], ["as", resource.as], ["data-fig-resource-key", resource.key], ["type", resource.type], ["crossorigin", resource.
|
|
160
|
+
pairs.push(["rel", "preload"], ["href", resource.href], ["as", resource.as], ["data-fig-resource-key", resource.key], ["type", resource.type], ["crossorigin", resource.crossorigin], ["fetchpriority", resource.fetchpriority]);
|
|
126
161
|
break;
|
|
127
162
|
case "modulepreload":
|
|
128
|
-
pairs.push(["rel", "modulepreload"], ["href", resource.href], ["data-fig-resource-key", resource.key], ["crossorigin", resource.
|
|
163
|
+
pairs.push(["rel", "modulepreload"], ["href", resource.href], ["data-fig-resource-key", resource.key], ["crossorigin", resource.crossorigin], ["fetchpriority", resource.fetchpriority]);
|
|
129
164
|
break;
|
|
130
165
|
case "font":
|
|
131
|
-
pairs.push(["rel", "preload"], ["href", resource.href], ["as", "font"], ["data-fig-resource-key", resource.key], ["type", resource.type], ["crossorigin", resource.
|
|
166
|
+
pairs.push(["rel", "preload"], ["href", resource.href], ["as", "font"], ["data-fig-resource-key", resource.key], ["type", resource.type], ["crossorigin", resource.crossorigin ?? "anonymous"], ["fetchpriority", resource.fetchpriority]);
|
|
132
167
|
break;
|
|
133
168
|
case "preconnect":
|
|
134
|
-
pairs.push(["rel", "preconnect"], ["href", resource.href], ["data-fig-resource-key", resource.key], ["crossorigin", resource.
|
|
169
|
+
pairs.push(["rel", "preconnect"], ["href", resource.href], ["data-fig-resource-key", resource.key], ["crossorigin", resource.crossorigin]);
|
|
135
170
|
break;
|
|
136
171
|
case "script":
|
|
137
|
-
pairs.push(["src", resource.src], ["type", resource.module === true ? "module" : void 0], ["data-fig-resource-key", resource.key], ["async", resource.async ?? resource.defer !== true ? true : void 0], ["defer", resource.defer === true ? true : void 0], ["crossorigin", resource.
|
|
172
|
+
pairs.push(["src", resource.src], ["type", resource.module === true ? "module" : void 0], ["data-fig-resource-key", resource.key], ["async", resource.async ?? resource.defer !== true ? true : void 0], ["defer", resource.defer === true ? true : void 0], ["crossorigin", resource.crossorigin]);
|
|
138
173
|
break;
|
|
139
174
|
case "title":
|
|
140
175
|
case "meta": break;
|
|
141
176
|
}
|
|
142
177
|
return pairs.filter((pair) => pair[1] !== void 0);
|
|
143
178
|
}
|
|
144
|
-
function resourceFromHost(type, prop, children) {
|
|
179
|
+
function resourceFromHost(type, prop, children, requireAsyncScript = false) {
|
|
145
180
|
const withKey = (resource) => {
|
|
181
|
+
if (resource === null) return null;
|
|
146
182
|
const key = readProp(prop, "data-fig-resource-key");
|
|
147
183
|
return key === void 0 ? resource : {
|
|
148
184
|
...resource,
|
|
@@ -150,54 +186,84 @@ function resourceFromHost(type, prop, children) {
|
|
|
150
186
|
};
|
|
151
187
|
};
|
|
152
188
|
switch (type.toLowerCase()) {
|
|
153
|
-
case "title":
|
|
154
|
-
|
|
155
|
-
value: textResourceValue(children)
|
|
156
|
-
});
|
|
157
|
-
case "meta":
|
|
158
|
-
if (readProp(prop, "itemProp", "itemprop") !== void 0) return null;
|
|
189
|
+
case "title":
|
|
190
|
+
if (readProp(prop, "itemprop") !== void 0) return null;
|
|
159
191
|
return withKey({
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
httpEquiv: readProp(prop, "httpEquiv", "http-equiv"),
|
|
163
|
-
kind: "meta",
|
|
164
|
-
name: readProp(prop, "name"),
|
|
165
|
-
property: readProp(prop, "property")
|
|
192
|
+
kind: "title",
|
|
193
|
+
value: textResourceValue(children)
|
|
166
194
|
});
|
|
167
|
-
case "
|
|
195
|
+
case "meta":
|
|
196
|
+
if (readProp(prop, "itemprop") !== void 0) return null;
|
|
197
|
+
return withKey(metaResourceFromHost(prop));
|
|
198
|
+
case "link": return withKey(linkResourceFromHost(prop));
|
|
168
199
|
case "script": {
|
|
169
200
|
const src = readProp(prop, "src");
|
|
170
|
-
|
|
201
|
+
const async = hasBooleanAttribute(prop("async"));
|
|
202
|
+
if (src === void 0 || requireAsyncScript && !async) return null;
|
|
171
203
|
return withKey({
|
|
172
|
-
async
|
|
173
|
-
|
|
174
|
-
defer: prop("defer")
|
|
204
|
+
async,
|
|
205
|
+
crossorigin: readCrossorigin(prop),
|
|
206
|
+
defer: hasBooleanAttribute(prop("defer")),
|
|
175
207
|
kind: "script",
|
|
176
|
-
module: prop("
|
|
208
|
+
module: prop("type") === "module",
|
|
177
209
|
src
|
|
178
210
|
});
|
|
179
211
|
}
|
|
180
212
|
default: return null;
|
|
181
213
|
}
|
|
182
214
|
}
|
|
183
|
-
function
|
|
184
|
-
|
|
215
|
+
function metaResourceFromHost(prop) {
|
|
216
|
+
const charset = readProp(prop, "charset");
|
|
217
|
+
const httpEquiv = readProp(prop, "http-equiv");
|
|
218
|
+
const name = readProp(prop, "name");
|
|
219
|
+
const property = readProp(prop, "property");
|
|
220
|
+
if ([
|
|
221
|
+
charset,
|
|
222
|
+
httpEquiv,
|
|
223
|
+
name,
|
|
224
|
+
property
|
|
225
|
+
].filter((value) => value !== void 0).length !== 1) return null;
|
|
226
|
+
if (charset !== void 0) return {
|
|
227
|
+
charset,
|
|
228
|
+
kind: "meta"
|
|
229
|
+
};
|
|
230
|
+
const content = readProp(prop, "content");
|
|
231
|
+
if (content === void 0) return null;
|
|
232
|
+
if (httpEquiv !== void 0) return {
|
|
233
|
+
content,
|
|
234
|
+
"http-equiv": httpEquiv,
|
|
235
|
+
kind: "meta"
|
|
236
|
+
};
|
|
237
|
+
if (name !== void 0) return {
|
|
238
|
+
content,
|
|
239
|
+
kind: "meta",
|
|
240
|
+
name
|
|
241
|
+
};
|
|
242
|
+
if (property !== void 0) return {
|
|
243
|
+
content,
|
|
244
|
+
kind: "meta",
|
|
245
|
+
property
|
|
246
|
+
};
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
function hasBooleanAttribute(value) {
|
|
250
|
+
return value !== void 0 && value !== null && value !== false;
|
|
185
251
|
}
|
|
186
252
|
function linkResourceFromHost(prop) {
|
|
187
253
|
const rel = readProp(prop, "rel")?.toLowerCase();
|
|
188
254
|
const href = readProp(prop, "href");
|
|
189
|
-
if (rel === void 0 || href === void 0 || readProp(prop, "
|
|
255
|
+
if (rel === void 0 || href === void 0 || readProp(prop, "itemprop") !== void 0) return null;
|
|
190
256
|
if (rel === "stylesheet") return {
|
|
191
257
|
blocking: prop("blocking") === "none" ? "none" : void 0,
|
|
192
|
-
|
|
258
|
+
crossorigin: readCrossorigin(prop),
|
|
193
259
|
href,
|
|
194
260
|
kind: "stylesheet",
|
|
195
261
|
media: readProp(prop, "media"),
|
|
196
262
|
precedence: readProp(prop, "precedence", "data-precedence")
|
|
197
263
|
};
|
|
198
264
|
if (rel === "modulepreload") return {
|
|
199
|
-
|
|
200
|
-
|
|
265
|
+
crossorigin: readCrossorigin(prop),
|
|
266
|
+
fetchpriority: fetchpriorityProp(readProp(prop, "fetchpriority")),
|
|
201
267
|
href,
|
|
202
268
|
kind: "modulepreload"
|
|
203
269
|
};
|
|
@@ -206,15 +272,15 @@ function linkResourceFromHost(prop) {
|
|
|
206
272
|
if (as === void 0) return null;
|
|
207
273
|
return {
|
|
208
274
|
as,
|
|
209
|
-
|
|
210
|
-
|
|
275
|
+
crossorigin: readCrossorigin(prop),
|
|
276
|
+
fetchpriority: fetchpriorityProp(readProp(prop, "fetchpriority")),
|
|
211
277
|
href,
|
|
212
278
|
kind: "preload",
|
|
213
279
|
type: readProp(prop, "type")
|
|
214
280
|
};
|
|
215
281
|
}
|
|
216
282
|
if (rel === "preconnect") return {
|
|
217
|
-
|
|
283
|
+
crossorigin: readCrossorigin(prop),
|
|
218
284
|
href,
|
|
219
285
|
kind: "preconnect"
|
|
220
286
|
};
|
|
@@ -231,45 +297,29 @@ function stringProp(value) {
|
|
|
231
297
|
if (typeof value === "string" || typeof value === "number" || typeof value === "bigint" || value === true) return String(value);
|
|
232
298
|
throw new Error("Resource host props must be serializable during server render.");
|
|
233
299
|
}
|
|
234
|
-
function
|
|
235
|
-
return
|
|
300
|
+
function readCrossorigin(prop) {
|
|
301
|
+
return crossoriginProp(readProp(prop, "crossorigin"));
|
|
236
302
|
}
|
|
237
|
-
function
|
|
303
|
+
function crossoriginProp(value) {
|
|
238
304
|
return value === "anonymous" || value === "use-credentials" || value === "" ? value : void 0;
|
|
239
305
|
}
|
|
240
|
-
function
|
|
306
|
+
function fetchpriorityProp(value) {
|
|
241
307
|
return value === "high" || value === "low" || value === "auto" ? value : void 0;
|
|
242
308
|
}
|
|
243
309
|
function textResourceValue(node) {
|
|
244
310
|
if (node === null || node === void 0 || typeof node === "boolean") return "";
|
|
245
311
|
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
246
312
|
if (Array.isArray(node)) return node.map(textResourceValue).join("");
|
|
313
|
+
if (isThenable(node)) return textResourceValue(readThenable(node));
|
|
247
314
|
throw new Error("<title> can only contain text during server render.");
|
|
248
315
|
}
|
|
249
316
|
function metaResourceKey(resource) {
|
|
250
317
|
if (resource.charset !== void 0) return `meta:charset:${resource.charset}`;
|
|
251
318
|
if (resource.name !== void 0) return `meta:name:${resource.name}`;
|
|
252
319
|
if (resource.property !== void 0) return `meta:property:${resource.property}`;
|
|
253
|
-
|
|
254
|
-
return `meta:${resource.content ?? ""}`;
|
|
255
|
-
}
|
|
256
|
-
//#endregion
|
|
257
|
-
//#region src/transition.ts
|
|
258
|
-
let transitionHandler = (callback) => callback();
|
|
259
|
-
/**
|
|
260
|
-
* Runs state updates scheduled by `callback` at transition priority. If
|
|
261
|
-
* `callback` returns a thenable, updates after an `await` remain in the
|
|
262
|
-
* transition priority scope until it settles.
|
|
263
|
-
*/
|
|
264
|
-
function transition(callback) {
|
|
265
|
-
return transitionHandler(callback);
|
|
266
|
-
}
|
|
267
|
-
function setTransitionHandler(handler) {
|
|
268
|
-
const previous = transitionHandler;
|
|
269
|
-
transitionHandler = handler;
|
|
270
|
-
return previous;
|
|
320
|
+
return `meta:http-equiv:${resource["http-equiv"]}`;
|
|
271
321
|
}
|
|
272
322
|
//#endregion
|
|
273
|
-
export {
|
|
323
|
+
export { title as _, assetResourceKey as a, trackThenable as b, font as c, modulepreload as d, preconnect as f, stylesheet as g, script as h, assetResourceHostAttributes as i, isFigAssetResource as l, preventAssetResourceHoist as m, assetResourceFromHostAttributes as n, assets as o, preload as p, assetResourceFromHostProps as r, clientReferenceAssets as s, assetResourceDestination as t, meta as u, isThenable as v, readThenable as y };
|
|
274
324
|
|
|
275
|
-
//# sourceMappingURL=
|
|
325
|
+
//# sourceMappingURL=resource-kXeIR52S.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-kXeIR52S.js","names":[],"sources":["../src/thenables.ts","../src/resource.ts"],"sourcesContent":["export type Thenable<T = unknown> = PromiseLike<T> & object;\n\ntype ThenableRecord<T> =\n | { status: \"pending\" }\n | { status: \"fulfilled\"; value: T }\n | { status: \"rejected\"; reason: unknown };\n\n// One process-wide registry keyed by thenable identity: the reconciler's\n// readPromise, the server renderers' dispatchers, and preloaders all share\n// it, so suspend/settle semantics cannot drift between client and server.\nconst thenableRecords = new WeakMap<object, ThenableRecord<unknown>>();\n\nfunction recordFor<T>(thenable: PromiseLike<T>): ThenableRecord<T> {\n const key = thenable as Thenable<T>;\n let record = thenableRecords.get(key) as ThenableRecord<T> | undefined;\n\n if (record === undefined) {\n record = { status: \"pending\" };\n thenableRecords.set(key, record);\n thenable.then(\n (value) => {\n record = { status: \"fulfilled\", value };\n thenableRecords.set(key, record);\n },\n (reason: unknown) => {\n record = { reason, status: \"rejected\" };\n thenableRecords.set(key, record);\n },\n );\n }\n\n return record;\n}\n\n// Starts tracking without reading. Preloaders call this when they begin a\n// load so that a thenable settled before its first render read resolves\n// synchronously instead of suspending for one retry beat.\nexport function trackThenable<T>(thenable: PromiseLike<T>): void {\n recordFor(thenable);\n}\n\nexport function readThenable<T>(thenable: PromiseLike<T>): T {\n const record = recordFor(thenable);\n if (record.status === \"fulfilled\") return record.value;\n if (record.status === \"rejected\") throw record.reason;\n throw thenable;\n}\n\nexport function isThenable(value: unknown): value is Thenable {\n if (\n (typeof value !== \"object\" && typeof value !== \"function\") ||\n value === null\n ) {\n return false;\n }\n\n return \"then\" in value && typeof value.then === \"function\";\n}\n","import {\n Assets,\n createElement,\n type FigClientReference,\n type FigElement,\n type FigNode,\n type Props,\n} from \"./element.ts\";\nimport { isThenable, readThenable } from \"./thenables.ts\";\n\nconst PreventAssetResourceHoistSymbol = Symbol.for(\n \"fig.prevent-asset-resource-hoist\",\n);\ntype AssetResourceHostProps = Props & {\n [PreventAssetResourceHoistSymbol]?: true;\n};\n\nexport type AssetResourceBlocking = \"reveal\" | \"none\";\nexport type CrossOrigin = \"anonymous\" | \"use-credentials\" | \"\";\nexport type FetchPriority = \"high\" | \"low\" | \"auto\";\nexport type AssetResourceDestination = \"head\" | \"stream\";\n\nexport type FigAssetResource =\n | StylesheetResource\n | PreloadResource\n | ModulePreloadResource\n | ScriptResource\n | FontResource\n | PreconnectResource\n | TitleResource\n | MetaResource;\n\ninterface ResourceBase {\n key?: string;\n}\n\nexport interface StylesheetResource extends ResourceBase {\n blocking?: AssetResourceBlocking;\n crossorigin?: CrossOrigin;\n href: string;\n kind: \"stylesheet\";\n media?: string;\n precedence?: string;\n}\n\nexport interface PreloadResource extends ResourceBase {\n as: string;\n crossorigin?: CrossOrigin;\n fetchpriority?: FetchPriority;\n href: string;\n kind: \"preload\";\n type?: string;\n}\n\nexport interface ModulePreloadResource extends ResourceBase {\n crossorigin?: CrossOrigin;\n fetchpriority?: FetchPriority;\n href: string;\n kind: \"modulepreload\";\n}\n\nexport interface ScriptResource extends ResourceBase {\n async?: boolean;\n crossorigin?: CrossOrigin;\n defer?: boolean;\n kind: \"script\";\n module?: boolean;\n src: string;\n}\n\nexport interface FontResource extends ResourceBase {\n crossorigin?: CrossOrigin;\n fetchpriority?: FetchPriority;\n href: string;\n kind: \"font\";\n type: string;\n}\n\nexport interface PreconnectResource extends ResourceBase {\n crossorigin?: CrossOrigin;\n href: string;\n kind: \"preconnect\";\n}\n\nexport interface TitleResource extends ResourceBase {\n kind: \"title\";\n value: string;\n}\n\ninterface MetaResourceBase extends ResourceBase {\n kind: \"meta\";\n}\n\ntype DistributiveOmit<Value, Key extends PropertyKey> = Value extends unknown\n ? Omit<Value, Key>\n : never;\n\nexport type MetaResource =\n | (MetaResourceBase & {\n charset: string;\n content?: never;\n \"http-equiv\"?: never;\n name?: never;\n property?: never;\n })\n | (MetaResourceBase & {\n charset?: never;\n content: string;\n \"http-equiv\"?: never;\n name: string;\n property?: never;\n })\n | (MetaResourceBase & {\n charset?: never;\n content: string;\n \"http-equiv\"?: never;\n name?: never;\n property: string;\n })\n | (MetaResourceBase & {\n charset?: never;\n content: string;\n \"http-equiv\": string;\n name?: never;\n property?: never;\n });\n\nexport type MetaResourceOptions = DistributiveOmit<MetaResource, \"kind\">;\n\nexport type FigAssetResourceList =\n | FigAssetResource\n | readonly FigAssetResource[];\n\n// Asset resources a client reference contributes when it renders. Eager for\n// hand-written lists; a thunk for bundler-manifest resolution that may not be\n// available until serialization time, or that maps paths differently per build.\nexport type ClientReferenceAssets =\n | FigAssetResourceList\n | (() => FigAssetResourceList);\n\nexport interface AssetsProps {\n assets: FigAssetResourceList;\n children?: FigNode;\n}\n\nexport function assets(\n value: FigAssetResourceList,\n children?: FigNode,\n): FigElement<AssetsProps> {\n return createElement(Assets, { assets: value }, children);\n}\n\nexport function stylesheet(\n href: string,\n options: Omit<StylesheetResource, \"href\" | \"kind\"> = {},\n): StylesheetResource {\n return { ...options, href, kind: \"stylesheet\" };\n}\n\nexport function preload(\n href: string,\n as: string,\n options: Omit<PreloadResource, \"as\" | \"href\" | \"kind\"> = {},\n): PreloadResource {\n return { ...options, as, href, kind: \"preload\" };\n}\n\nexport function modulepreload(\n href: string,\n options: Omit<ModulePreloadResource, \"href\" | \"kind\"> = {},\n): ModulePreloadResource {\n return { ...options, href, kind: \"modulepreload\" };\n}\n\nexport function script(\n src: string,\n options: Omit<ScriptResource, \"kind\" | \"src\"> = {},\n): ScriptResource {\n return { ...options, kind: \"script\", src };\n}\n\nexport function font(\n href: string,\n type: string,\n options: Omit<FontResource, \"href\" | \"kind\" | \"type\"> = {},\n): FontResource {\n return { ...options, href, kind: \"font\", type };\n}\n\nexport function preconnect(\n href: string,\n options: Omit<PreconnectResource, \"href\" | \"kind\"> = {},\n): PreconnectResource {\n return { ...options, href, kind: \"preconnect\" };\n}\n\nexport function title(value: string): TitleResource {\n return { kind: \"title\", value };\n}\n\nexport function meta(options: MetaResourceOptions): MetaResource {\n return { ...options, kind: \"meta\" };\n}\n\nexport function isFigAssetResource(value: unknown): value is FigAssetResource {\n if (typeof value !== \"object\" || value === null || !(\"kind\" in value)) {\n return false;\n }\n\n switch (value.kind) {\n case \"stylesheet\":\n case \"preload\":\n case \"modulepreload\":\n case \"script\":\n case \"font\":\n case \"preconnect\":\n case \"title\":\n case \"meta\":\n return true;\n default:\n return false;\n }\n}\n\nexport function clientReferenceAssets(\n reference: FigClientReference,\n): readonly FigAssetResource[] {\n const value = reference.assets;\n if (value === undefined) return [];\n\n // Resolved on each call rather than memoized: a lazy resolver may read a\n // manifest that is not loaded until serialization, and a consumer that wants\n // to cache can do so against the stable reference identity.\n const list = typeof value === \"function\" ? value() : value;\n if (isFigAssetResource(list)) return [list];\n // A thunk that yields nothing (e.g. a missing manifest entry) normalizes to an\n // empty list rather than leaking a non-array through the readonly contract.\n return Array.isArray(list) ? list : [];\n}\n\nexport function assetResourceKey(resource: FigAssetResource): string {\n // A document carries a single <title>; collapse every title to one key even\n // when an author supplies an explicit key, so the singleton invariant cannot\n // be bypassed into emitting multiple <title> elements (invalid HTML).\n if (resource.kind === \"title\") return \"title\";\n\n // A font is serialized and inserted as <link rel=\"preload\" as=\"font\">, so an\n // explicit key must also live in the preload key space.\n if (resource.kind === \"font\" && resource.key !== undefined)\n return `preload:${resource.key}`;\n\n if (resource.key !== undefined) return `${resource.kind}:${resource.key}`;\n\n switch (resource.kind) {\n case \"stylesheet\":\n return `stylesheet:${resource.href}`;\n case \"preload\":\n return `preload:${resource.as}:${resource.href}`;\n case \"modulepreload\":\n return `modulepreload:${resource.href}`;\n case \"script\":\n return `script:${resource.src}`;\n case \"font\":\n // A font is loaded as <link rel=\"preload\" as=\"font\">, so it must share the\n // preload-font key space across every package (SSR registry, payload record,\n // client insert) — otherwise a font() and an equivalent preload(href,\n // \"font\") would key separately and fail to dedupe.\n return `preload:font:${resource.href}`;\n case \"preconnect\":\n return `preconnect:${resource.href}`;\n case \"meta\":\n return metaResourceKey(resource);\n }\n}\n\nexport function assetResourceDestination(\n resource: FigAssetResource,\n): AssetResourceDestination {\n return resource.kind === \"title\" || resource.kind === \"meta\"\n ? \"head\"\n : \"stream\";\n}\n\nexport function assetResourceFromHostProps(\n type: string,\n props: Props,\n): FigAssetResource | null {\n if (\n (props as AssetResourceHostProps)[PreventAssetResourceHoistSymbol] === true\n ) {\n return null;\n }\n return resourceFromHost(type, (name) => props[name], props.children, true);\n}\n\nexport function preventAssetResourceHoist<P extends Props>(props: P): P {\n Object.defineProperty(props, PreventAssetResourceHoistSymbol, {\n enumerable: true,\n value: true,\n });\n return props;\n}\n\nexport function assetResourceFromHostAttributes(\n type: string,\n getAttribute: (name: string) => unknown,\n): FigAssetResource | null {\n return resourceFromHost(type, getAttribute, undefined, false);\n}\n\nexport type AssetResourceHostAttribute = readonly [\n name: string,\n value: string | true,\n];\n\n// Canonical attribute serialization for hoisted asset-resource elements,\n// shared by the server's registry writer and the client's head insertion so\n// the two renders cannot drift. `true` marks a boolean attribute (bare on\n// the server, empty-string in the DOM). Server-only attributes (id, nonce)\n// stay with the server writer; title/meta are written by their own paths.\nexport function assetResourceHostAttributes(\n resource: FigAssetResource,\n): AssetResourceHostAttribute[] {\n const pairs: Array<readonly [string, string | true | undefined]> = [];\n\n switch (resource.kind) {\n case \"stylesheet\":\n pairs.push(\n [\"rel\", \"stylesheet\"],\n [\"href\", resource.href],\n [\"data-fig-resource-key\", resource.key],\n [\"data-precedence\", resource.precedence],\n [\"media\", resource.media],\n [\"crossorigin\", resource.crossorigin],\n );\n break;\n case \"preload\":\n pairs.push(\n [\"rel\", \"preload\"],\n [\"href\", resource.href],\n [\"as\", resource.as],\n [\"data-fig-resource-key\", resource.key],\n [\"type\", resource.type],\n [\"crossorigin\", resource.crossorigin],\n [\"fetchpriority\", resource.fetchpriority],\n );\n break;\n case \"modulepreload\":\n pairs.push(\n [\"rel\", \"modulepreload\"],\n [\"href\", resource.href],\n [\"data-fig-resource-key\", resource.key],\n [\"crossorigin\", resource.crossorigin],\n [\"fetchpriority\", resource.fetchpriority],\n );\n break;\n case \"font\":\n pairs.push(\n [\"rel\", \"preload\"],\n [\"href\", resource.href],\n [\"as\", \"font\"],\n [\"data-fig-resource-key\", resource.key],\n [\"type\", resource.type],\n [\"crossorigin\", resource.crossorigin ?? \"anonymous\"],\n [\"fetchpriority\", resource.fetchpriority],\n );\n break;\n case \"preconnect\":\n pairs.push(\n [\"rel\", \"preconnect\"],\n [\"href\", resource.href],\n [\"data-fig-resource-key\", resource.key],\n [\"crossorigin\", resource.crossorigin],\n );\n break;\n case \"script\":\n pairs.push(\n [\"src\", resource.src],\n [\"type\", resource.module === true ? \"module\" : undefined],\n [\"data-fig-resource-key\", resource.key],\n // Hoisted scripts default to async, but an explicit defer opts into\n // ordered execution and must not be overridden (async wins over\n // defer in browsers).\n [\n \"async\",\n (resource.async ?? resource.defer !== true) ? true : undefined,\n ],\n [\"defer\", resource.defer === true ? true : undefined],\n [\"crossorigin\", resource.crossorigin],\n );\n break;\n case \"title\":\n case \"meta\":\n break;\n }\n\n return pairs.filter(\n (pair): pair is readonly [string, string | true] => pair[1] !== undefined,\n );\n}\n\nfunction resourceFromHost(\n type: string,\n prop: (name: string) => unknown,\n children?: FigNode,\n requireAsyncScript = false,\n): FigAssetResource | null {\n const withKey = (\n resource: FigAssetResource | null,\n ): FigAssetResource | null => {\n if (resource === null) return null;\n const key = readProp(prop, \"data-fig-resource-key\");\n return key === undefined ? resource : { ...resource, key };\n };\n\n switch (type.toLowerCase()) {\n case \"title\":\n if (readProp(prop, \"itemprop\") !== undefined) return null;\n return withKey({ kind: \"title\", value: textResourceValue(children) });\n case \"meta\":\n if (readProp(prop, \"itemprop\") !== undefined) return null;\n return withKey(metaResourceFromHost(prop));\n case \"link\":\n return withKey(linkResourceFromHost(prop));\n case \"script\": {\n const src = readProp(prop, \"src\");\n // A raw script keeps native placement and execution semantics unless the\n // author explicitly marks it async. Explicit script() descriptors remain\n // the opt-in path for hoisted defer, module, or synchronous scripts.\n const async = hasBooleanAttribute(prop(\"async\"));\n if (src === undefined || (requireAsyncScript && !async)) return null;\n return withKey({\n async,\n crossorigin: readCrossorigin(prop),\n defer: hasBooleanAttribute(prop(\"defer\")),\n kind: \"script\",\n module: prop(\"type\") === \"module\",\n src,\n });\n }\n default:\n return null;\n }\n}\n\nfunction metaResourceFromHost(\n prop: (name: string) => unknown,\n): MetaResource | null {\n const charset = readProp(prop, \"charset\");\n const httpEquiv = readProp(prop, \"http-equiv\");\n const name = readProp(prop, \"name\");\n const property = readProp(prop, \"property\");\n const identities = [charset, httpEquiv, name, property].filter(\n (value) => value !== undefined,\n );\n\n if (identities.length !== 1) return null;\n if (charset !== undefined) return { charset, kind: \"meta\" };\n\n const content = readProp(prop, \"content\");\n if (content === undefined) return null;\n if (httpEquiv !== undefined) {\n return { content, \"http-equiv\": httpEquiv, kind: \"meta\" };\n }\n if (name !== undefined) return { content, kind: \"meta\", name };\n if (property !== undefined) return { content, kind: \"meta\", property };\n return null;\n}\n\nfunction hasBooleanAttribute(value: unknown): boolean {\n return value !== undefined && value !== null && value !== false;\n}\n\nfunction linkResourceFromHost(\n prop: (name: string) => unknown,\n): FigAssetResource | null {\n const rel = readProp(prop, \"rel\")?.toLowerCase();\n const href = readProp(prop, \"href\");\n if (\n rel === undefined ||\n href === undefined ||\n readProp(prop, \"itemprop\") !== undefined\n ) {\n return null;\n }\n\n if (rel === \"stylesheet\") {\n return {\n blocking: prop(\"blocking\") === \"none\" ? \"none\" : undefined,\n crossorigin: readCrossorigin(prop),\n href,\n kind: \"stylesheet\",\n media: readProp(prop, \"media\"),\n // Hoisted elements serialize the canonical data-precedence attribute;\n // host-rendered <link precedence> keeps the author-facing prop name.\n precedence: readProp(prop, \"precedence\", \"data-precedence\"),\n };\n }\n\n if (rel === \"modulepreload\") {\n return {\n crossorigin: readCrossorigin(prop),\n fetchpriority: fetchpriorityProp(readProp(prop, \"fetchpriority\")),\n href,\n kind: \"modulepreload\",\n };\n }\n\n if (rel === \"preload\") {\n const as = readProp(prop, \"as\");\n if (as === undefined) return null;\n return {\n as,\n crossorigin: readCrossorigin(prop),\n fetchpriority: fetchpriorityProp(readProp(prop, \"fetchpriority\")),\n href,\n kind: \"preload\",\n type: readProp(prop, \"type\"),\n };\n }\n\n if (rel === \"preconnect\") {\n return {\n crossorigin: readCrossorigin(prop),\n href,\n kind: \"preconnect\",\n };\n }\n\n return null;\n}\n\nfunction readProp(\n prop: (name: string) => unknown,\n ...names: string[]\n): string | undefined {\n for (const name of names) {\n const value = stringProp(prop(name));\n if (value !== undefined) return value;\n }\n\n return undefined;\n}\n\nfunction stringProp(value: unknown): string | undefined {\n if (value === undefined || value === null || value === false)\n return undefined;\n if (\n typeof value === \"string\" ||\n typeof value === \"number\" ||\n typeof value === \"bigint\" ||\n value === true\n ) {\n return String(value);\n }\n\n throw new Error(\n \"Resource host props must be serializable during server render.\",\n );\n}\n\nfunction readCrossorigin(\n prop: (name: string) => unknown,\n): CrossOrigin | undefined {\n return crossoriginProp(readProp(prop, \"crossorigin\"));\n}\n\nfunction crossoriginProp(value: unknown): CrossOrigin | undefined {\n return value === \"anonymous\" || value === \"use-credentials\" || value === \"\"\n ? value\n : undefined;\n}\n\nfunction fetchpriorityProp(value: unknown): FetchPriority | undefined {\n return value === \"high\" || value === \"low\" || value === \"auto\"\n ? value\n : undefined;\n}\n\nfunction textResourceValue(node: FigNode): string {\n if (node === null || node === undefined || typeof node === \"boolean\") {\n return \"\";\n }\n if (typeof node === \"string\" || typeof node === \"number\") return String(node);\n if (Array.isArray(node)) return node.map(textResourceValue).join(\"\");\n if (isThenable(node)) return textResourceValue(readThenable(node));\n\n throw new Error(\"<title> can only contain text during server render.\");\n}\n\nfunction metaResourceKey(resource: MetaResource): string {\n if (resource.charset !== undefined) return `meta:charset:${resource.charset}`;\n if (resource.name !== undefined) return `meta:name:${resource.name}`;\n if (resource.property !== undefined)\n return `meta:property:${resource.property}`;\n return `meta:http-equiv:${resource[\"http-equiv\"]}`;\n}\n"],"mappings":";;AAUA,MAAM,kCAAkB,IAAI,QAAyC;AAErE,SAAS,UAAa,UAA6C;CACjE,MAAM,MAAM;CACZ,IAAI,SAAS,gBAAgB,IAAI,GAAG;CAEpC,IAAI,WAAW,KAAA,GAAW;EACxB,SAAS,EAAE,QAAQ,UAAU;EAC7B,gBAAgB,IAAI,KAAK,MAAM;EAC/B,SAAS,MACN,UAAU;GACT,SAAS;IAAE,QAAQ;IAAa;GAAM;GACtC,gBAAgB,IAAI,KAAK,MAAM;EACjC,IACC,WAAoB;GACnB,SAAS;IAAE;IAAQ,QAAQ;GAAW;GACtC,gBAAgB,IAAI,KAAK,MAAM;EACjC,CACF;CACF;CAEA,OAAO;AACT;AAKA,SAAgB,cAAiB,UAAgC;CAC/D,UAAU,QAAQ;AACpB;AAEA,SAAgB,aAAgB,UAA6B;CAC3D,MAAM,SAAS,UAAU,QAAQ;CACjC,IAAI,OAAO,WAAW,aAAa,OAAO,OAAO;CACjD,IAAI,OAAO,WAAW,YAAY,MAAM,OAAO;CAC/C,MAAM;AACR;AAEA,SAAgB,WAAW,OAAmC;CAC5D,IACG,OAAO,UAAU,YAAY,OAAO,UAAU,cAC/C,UAAU,MAEV,OAAO;CAGT,OAAO,UAAU,SAAS,OAAO,MAAM,SAAS;AAClD;;;AC/CA,MAAM,kCAAkC,OAAO,IAC7C,kCACF;AAqIA,SAAgB,OACd,OACA,UACyB;CACzB,OAAO,cAAc,QAAQ,EAAE,QAAQ,MAAM,GAAG,QAAQ;AAC1D;AAEA,SAAgB,WACd,MACA,UAAqD,CAAC,GAClC;CACpB,OAAO;EAAE,GAAG;EAAS;EAAM,MAAM;CAAa;AAChD;AAEA,SAAgB,QACd,MACA,IACA,UAAyD,CAAC,GACzC;CACjB,OAAO;EAAE,GAAG;EAAS;EAAI;EAAM,MAAM;CAAU;AACjD;AAEA,SAAgB,cACd,M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