@bgub/fig-dom 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,20 @@
1
+ ## @bgub/fig-dom@0.1.2
2
+
3
+ ### Ignore temporary view transition styles during hydration
4
+
5
+ Hydration diagnostics no longer report inline view transition declarations
6
+ that match a streamed surface's `data-fig-vt-*` annotations, including the
7
+ otherwise capture-only `style` attribute. Unrelated authored server styles on
8
+ the same element continue to produce the normal diagnostic.
9
+
10
+ ## @bgub/fig-dom@0.1.1
11
+
12
+ ### Document every JSR entrypoint and exported symbol
13
+
14
+ All Fig packages now publish module documentation for every JSR entrypoint and
15
+ API documentation for their exported symbols. This makes the generated JSR
16
+ reference complete and improves package discovery and quality scores.
17
+
1
18
  ## @bgub/fig-dom@0.1.0
2
19
 
3
20
  ### Publish stable pre-1.0 releases
package/dist/index.d.ts CHANGED
@@ -1,9 +1,11 @@
1
- import { a as Bind, i as HostStyle, n as EmptyPropValue, o as composeBind, r as HostProps, t as HostIntrinsicElements } from "./jsx-C3owhMDw.js";
1
+ import { a as Bind, i as HostStyle, n as EmptyPropValue, o as composeBind, r as HostProps, t as HostIntrinsicElements } from "./jsx-It_Mpx4I.js";
2
2
  import { AwaitedFigNode, DataResource, DataResourceKey, DataResourceKeyInput, FigAssetResource, FigNode, FigPortal, Key, MixinDescriptor } from "@bgub/fig";
3
3
  import { FigRoot, FigRootOptions, RecoverableErrorInfo } from "@bgub/fig-reconciler";
4
4
  import { PayloadDecodeOptions } from "@bgub/fig/payload";
5
5
  //#region src/event-descriptor.d.ts
6
+ /** Describes event options. */
6
7
  type EventOptions = Pick<AddEventListenerOptions, "capture" | "passive">;
8
+ /** Describes event callback. */
7
9
  type EventCallback<E extends Event = Event> = (event: E, signal: AbortSignal) => void;
8
10
  /**
9
11
  * Declares one native listener for an element's `mix` prop. Bubbling
@@ -11,9 +13,11 @@ type EventCallback<E extends Event = Event> = (event: E, signal: AbortSignal) =>
11
13
  * including `focus` and `blur`, attach directly with native semantics.
12
14
  */
13
15
  declare function on<K extends keyof HTMLElementEventMap>(type: K, callback: EventCallback<HTMLElementEventMap[K]>, options?: EventOptions): MixinDescriptor;
16
+ /** On. */
14
17
  declare function on<E extends Event = Event>(type: string, callback: EventCallback<E>, options?: EventOptions): MixinDescriptor;
15
18
  //#endregion
16
19
  //#region src/events.d.ts
20
+ /** Describes container. */
17
21
  type Container = Document | DocumentFragment | Element;
18
22
  //#endregion
19
23
  //#region src/asset-resources.d.ts
@@ -28,22 +32,27 @@ declare function insertAssetResources(resources: readonly FigAssetResource[]): P
28
32
  type PayloadDecoderOptions = Pick<PayloadDecodeOptions, "prepareAssets" | "resolveClientReference" | "retainAssets">;
29
33
  //#endregion
30
34
  //#region src/payload-component.d.ts
35
+ /** Describes payload source. */
31
36
  type PayloadSource = Response | {
32
37
  contentType: string;
33
38
  stream: ReadableStream<Uint8Array>;
34
39
  };
40
+ /** Describes payload component load context. */
35
41
  interface PayloadComponentLoadContext {
36
42
  key: DataResourceKey;
37
43
  signal: AbortSignal;
38
44
  }
45
+ /** Describes payload component loader. */
39
46
  interface PayloadComponentLoader<TProps extends object> extends PayloadDecoderOptions {
40
47
  (props: TProps, context: PayloadComponentLoadContext): PayloadSource | PromiseLike<PayloadSource>;
41
48
  }
49
+ /** Describes payload component options. */
42
50
  interface PayloadComponentOptions<TProps extends object> extends PayloadDecoderOptions {
43
51
  cacheKey?: (props: TProps) => DataResourceKeyInput;
44
52
  key: DataResourceKey;
45
53
  load: PayloadComponentLoader<TProps>;
46
54
  }
55
+ /** Describes payload component. */
47
56
  interface PayloadComponent<TProps extends object> extends DataResource<[TProps], AwaitedFigNode> {
48
57
  (props: TProps & {
49
58
  children?: FigNode;
@@ -55,9 +64,13 @@ interface PayloadComponent<TProps extends object> extends DataResource<[TProps],
55
64
  declare function createPayloadComponent<TProps extends object>(options: PayloadComponentOptions<TProps>): PayloadComponent<TProps>;
56
65
  //#endregion
57
66
  //#region src/index.d.ts
67
+ /** The flush sync. */
58
68
  declare const flushSync: <T>(this: void, callback: () => T) => T;
69
+ /** Creates root. */
59
70
  declare function createRoot(container: Container, options?: FigRootOptions): FigRoot;
71
+ /** Hydrates root. */
60
72
  declare function hydrateRoot(container: Container, children: FigNode, options?: FigRootOptions): FigRoot;
73
+ /** Creates portal. */
61
74
  declare function createPortal(children: FigNode, container: Container, key?: Key | null): FigPortal<Container>;
62
75
  //#endregion
63
76
  export { type Bind, type Container, type EmptyPropValue, type EventCallback, type EventOptions, type FigRoot, type FigRootOptions, type HostIntrinsicElements, type HostProps, type HostStyle, type PayloadComponent, type PayloadComponentLoadContext, type PayloadComponentLoader, type PayloadComponentOptions, type PayloadSource, type RecoverableErrorInfo, composeBind, createPayloadComponent, createPortal, createRoot, flushSync, hydrateRoot, insertAssetResources, on };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/payload-decoder.ts","../src/payload-key.ts","../src/payload-component.ts","../src/index.ts"],"sourcesContent":["import type { AwaitedFigNode, DataResourceLoadContext } from \"@bgub/fig\";\nimport {\n assertPayloadCodecMatches,\n jsonPayloadCodec,\n loadContextCapabilities,\n} from \"@bgub/fig/internal\";\nimport {\n decodePayloadStream,\n type PayloadDecodeOptions,\n} from \"@bgub/fig/payload\";\nimport { insertAssetResources } from \"./asset-resources.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\nconst noop = (): void => undefined;\n\nexport type PayloadDecoderOptions = Pick<\n PayloadDecodeOptions,\n \"prepareAssets\" | \"resolveClientReference\" | \"retainAssets\"\n>;\n\n/**\n * Decodes a validated Payload response within one data-resource generation.\n * The root becomes the entry value, streamed holes keep filling for the\n * generation's lifetime, `data` rows hydrate through its guarded capability,\n * and discovered assets enter the document with dependent reveal gates.\n */\nexport async function decodePayloadResponse(\n response: Response,\n context: DataResourceLoadContext,\n options: PayloadDecoderOptions = {},\n): Promise<AwaitedFigNode> {\n const { signal } = context;\n if (signal.aborted) {\n await response.body?.cancel().catch(noop);\n throw abortReason(signal);\n }\n if (!response.ok) {\n await response.body?.cancel().catch(noop);\n throw new Error(`Payload request failed with status ${response.status}.`);\n }\n const body = response.body;\n if (body === null) {\n throw new Error(\"Payload response did not include a body.\");\n }\n try {\n assertPayloadCodecMatches(\n jsonPayloadCodec,\n response.headers.get(\"content-type\"),\n );\n } catch (error) {\n await body.cancel().catch(noop);\n throw error;\n }\n\n const capabilities = loadContextCapabilities(context);\n return decodePayloadStream(body, {\n // Absent outside a data store: data rows are ignored rather than hydrated.\n hydrate: capabilities?.hydrate,\n onHoleError: capabilities?.attributeError,\n // Post-root failures surface through the rejected holes they strand;\n // observing the stream end keeps a failure that no longer has a pending\n // slot from being silently discarded in development.\n onStreamDone: (result) => {\n if (__DEV__ && result.status === \"failed\") {\n console.error(\n \"Payload decode failed after its root value published:\",\n result.error,\n );\n }\n },\n prepareAssets:\n options.prepareAssets ?? ((assets) => insertAssetResources(assets)),\n retainAssets: options.retainAssets,\n resolveClientReference: options.resolveClientReference,\n signal,\n });\n}\n\nfunction abortReason(signal: AbortSignal): unknown {\n return signal.reason ?? new Error(\"Payload request aborted.\");\n}\n","import type { DataResourceKeyInput } from \"@bgub/fig\";\n\nexport function encodePayloadKey(value: unknown): DataResourceKeyInput {\n const ids = new WeakMap<object, number>();\n let nextId = 1;\n\n function encode(value: unknown): DataResourceKeyInput {\n if (value === null) return null;\n if (value === undefined) return [\"undefined\"];\n if (typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return [\"number\", \"NaN\"];\n if (value === Infinity) return [\"number\", \"Infinity\"];\n if (value === -Infinity) return [\"number\", \"-Infinity\"];\n return Object.is(value, -0) ? [\"number\", \"-0\"] : value;\n }\n if (typeof value === \"bigint\") return [\"bigint\", value.toString()];\n if (typeof value === \"symbol\") {\n const key = Symbol.keyFor(value);\n if (key === undefined) {\n throw new Error(\"Only global Symbol.for symbols can be serialized.\");\n }\n return [\"symbol\", key];\n }\n if (typeof value === \"function\") {\n throw new Error(\"Functions cannot be serialized into the payload.\");\n }\n if (value instanceof Date) {\n const json = value.toJSON();\n if (json === null) {\n throw new Error(\"Invalid Date values cannot be serialized.\");\n }\n return [\"date\", json];\n }\n\n const existing = ids.get(value);\n if (existing !== undefined) return [\"ref\", existing];\n const id = nextId++;\n ids.set(value, id);\n\n if (Array.isArray(value)) {\n return [\"array\", id, value.map(encode)];\n }\n if (value instanceof Map) {\n return [\n \"map\",\n id,\n Array.from(value, ([key, item]) => [encode(key), encode(item)]),\n ];\n }\n if (value instanceof Set) {\n return [\"set\", id, Array.from(value, encode)];\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Cannot serialize ${prototype?.constructor?.name ?? \"object\"} into the payload.`,\n );\n }\n const record = value as Record<string, unknown>;\n return [\n \"object\",\n id,\n Object.keys(record)\n .sort()\n .map((key) => [key, encode(record[key])]),\n ];\n }\n\n return encode(value);\n}\n","import {\n type AwaitedFigNode,\n dataResource,\n type DataResource,\n type DataResourceKey,\n type DataResourceKeyInput,\n type FigNode,\n readData,\n} from \"@bgub/fig\";\nimport { loadContextCapabilities } from \"@bgub/fig/internal\";\nimport {\n decodePayloadResponse,\n type PayloadDecoderOptions,\n} from \"./payload-decoder.ts\";\nimport { encodePayloadKey } from \"./payload-key.ts\";\n\nexport type PayloadSource =\n | Response\n | {\n contentType: string;\n stream: ReadableStream<Uint8Array>;\n };\n\nexport interface PayloadComponentLoadContext {\n key: DataResourceKey;\n signal: AbortSignal;\n}\n\nexport interface PayloadComponentLoader<\n TProps extends object,\n> extends PayloadDecoderOptions {\n (\n props: TProps,\n context: PayloadComponentLoadContext,\n ): PayloadSource | PromiseLike<PayloadSource>;\n}\n\nexport interface PayloadComponentOptions<\n TProps extends object,\n> extends PayloadDecoderOptions {\n cacheKey?: (props: TProps) => DataResourceKeyInput;\n key: DataResourceKey;\n load: PayloadComponentLoader<TProps>;\n}\n\nexport interface PayloadComponent<TProps extends object> extends DataResource<\n [TProps],\n AwaitedFigNode\n> {\n (props: TProps & { children?: FigNode }): FigNode;\n}\n\n/**\n * Creates a renderable Payload tree backed by Fig's ordinary data store.\n */\nexport function createPayloadComponent<TProps extends object>(\n options: PayloadComponentOptions<TProps>,\n): PayloadComponent<TProps> {\n const key = (props: TProps): DataResourceKey => {\n const serialized = serializedProps(props);\n return [\n ...options.key,\n options.cacheKey === undefined ? serialized : options.cacheKey(props),\n ];\n };\n const resource = dataResource<[TProps], AwaitedFigNode>({\n debugArgs: options.cacheKey === undefined ? undefined : serializedProps,\n key,\n load: async (props, context) => {\n const source = await options.load(props, {\n key: loadContextCapabilities(context)?.key ?? key(props),\n signal: context.signal,\n });\n const response =\n source instanceof Response\n ? source\n : new Response(source.stream, {\n headers: { \"content-type\": source.contentType },\n });\n return decodePayloadResponse(response, context, {\n prepareAssets: options.prepareAssets ?? options.load.prepareAssets,\n resolveClientReference:\n options.resolveClientReference ?? options.load.resolveClientReference,\n retainAssets: options.retainAssets ?? options.load.retainAssets,\n });\n },\n });\n\n const component: PayloadComponent<TProps> = Object.assign(\n function PayloadComponent(props: TProps & { children?: FigNode }): FigNode {\n rejectChildren(props);\n return readData(component, props);\n },\n resource,\n );\n Object.defineProperty(component, \"displayName\", {\n configurable: true,\n value: `Payload(${options.key[0]})`,\n });\n\n return component;\n}\n\nfunction serializedProps<TProps extends object>(\n props: TProps,\n): DataResourceKeyInput {\n rejectChildren(props);\n return encodePayloadKey(props);\n}\n\nfunction rejectChildren(props: object): void {\n if (Object.hasOwn(props, \"children\")) {\n throw new Error(\"Payload components do not accept children.\");\n }\n}\n","import type { FigNode, FigPortal, Key } from \"@bgub/fig\";\nimport { createPortalNode } from \"@bgub/fig/internal\";\nimport type {\n FigRoot,\n FigRootOptions,\n RecoverableErrorInfo,\n} from \"@bgub/fig-reconciler\";\nimport { composeBind } from \"./bind.ts\";\nimport {\n type EventCallback,\n type EventOptions,\n on,\n} from \"./event-descriptor.ts\";\nimport { type Container, registerRoot, unregisterRoot } from \"./events.ts\";\nimport { domRenderer } from \"./renderer.ts\";\n\nexport { insertAssetResources } from \"./asset-resources.ts\";\nexport type { Bind } from \"./bind.ts\";\nexport { composeBind };\nexport { type EventCallback, type EventOptions, on };\nexport type {\n EmptyPropValue,\n HostIntrinsicElements,\n HostProps,\n HostStyle,\n} from \"./jsx.ts\";\nexport {\n createPayloadComponent,\n type PayloadComponent,\n type PayloadComponentLoadContext,\n type PayloadComponentLoader,\n type PayloadComponentOptions,\n type PayloadSource,\n} from \"./payload-component.ts\";\n\nexport type { Container, FigRoot, FigRootOptions, RecoverableErrorInfo };\n\nexport const flushSync = domRenderer.flushSync;\n\nexport function createRoot(\n container: Container,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.createRoot(container, options);\n registerRoot(container, { run: (callback) => root.data.run(callback) });\n return withEventTeardown(root, container);\n}\n\nexport function hydrateRoot(\n container: Container,\n children: FigNode,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.hydrateRoot(container, children, options);\n registerRoot(container, {\n hydrate: (target, priority) =>\n domRenderer.hydrateTarget(container, target, priority),\n run: (callback) => root.data.run(callback),\n });\n return withEventTeardown(root, container);\n}\n\nexport function createPortal(\n children: FigNode,\n container: Container,\n key: Key | null = null,\n): FigPortal<Container> {\n return createPortalNode(children, container, key);\n}\n\n// Event routing lives outside the reconciler, so root teardown owns both.\nfunction withEventTeardown(root: FigRoot, container: Container): FigRoot {\n return {\n ...root,\n unmount: () => {\n root.unmount();\n unregisterRoot(container);\n },\n };\n}\n"],"mappings":"gUAeA,MAAM,MAAmB,IAAA,GAazB,eAAsB,EACpB,EACA,EACA,EAAiC,CAAC,EACT,CACzB,GAAM,CAAE,UAAW,EACnB,GAAI,EAAO,QAET,MADA,MAA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,EAAQ,IAChB,EAAY,cAAc,EAAW,EAAQ,CAAQ,EACvD,IAAM,GAAa,EAAK,KAAK,IAAI,CAAQ,CAC3C,CAAC,EACM,EAAkB,EAAM,CAAS,CAC1C,CAEA,SAAgB,EACd,EACA,EACA,EAAkB,KACI,CACtB,OAAO,EAAiB,EAAU,EAAW,CAAG,CAClD,CAGA,SAAS,EAAkB,EAAe,EAA+B,CACvE,MAAO,CACL,GAAG,EACH,YAAe,CACb,EAAK,QAAQ,EACb,EAAe,CAAS,CAC1B,CACF,CACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/payload-decoder.ts","../src/payload-key.ts","../src/payload-component.ts","../src/index.ts"],"sourcesContent":["import type { AwaitedFigNode, DataResourceLoadContext } from \"@bgub/fig\";\nimport {\n assertPayloadCodecMatches,\n jsonPayloadCodec,\n loadContextCapabilities,\n} from \"@bgub/fig/internal\";\nimport {\n decodePayloadStream,\n type PayloadDecodeOptions,\n} from \"@bgub/fig/payload\";\nimport { insertAssetResources } from \"./asset-resources.ts\";\n\ndeclare const __FIG_DEV__: boolean | undefined;\n\nconst __DEV__ = typeof __FIG_DEV__ === \"boolean\" ? __FIG_DEV__ : false;\nconst noop = (): void => undefined;\n\nexport type PayloadDecoderOptions = Pick<\n PayloadDecodeOptions,\n \"prepareAssets\" | \"resolveClientReference\" | \"retainAssets\"\n>;\n\n/**\n * Decodes a validated Payload response within one data-resource generation.\n * The root becomes the entry value, streamed holes keep filling for the\n * generation's lifetime, `data` rows hydrate through its guarded capability,\n * and discovered assets enter the document with dependent reveal gates.\n */\nexport async function decodePayloadResponse(\n response: Response,\n context: DataResourceLoadContext,\n options: PayloadDecoderOptions = {},\n): Promise<AwaitedFigNode> {\n const { signal } = context;\n if (signal.aborted) {\n await response.body?.cancel().catch(noop);\n throw abortReason(signal);\n }\n if (!response.ok) {\n await response.body?.cancel().catch(noop);\n throw new Error(`Payload request failed with status ${response.status}.`);\n }\n const body = response.body;\n if (body === null) {\n throw new Error(\"Payload response did not include a body.\");\n }\n try {\n assertPayloadCodecMatches(\n jsonPayloadCodec,\n response.headers.get(\"content-type\"),\n );\n } catch (error) {\n await body.cancel().catch(noop);\n throw error;\n }\n\n const capabilities = loadContextCapabilities(context);\n return decodePayloadStream(body, {\n // Absent outside a data store: data rows are ignored rather than hydrated.\n hydrate: capabilities?.hydrate,\n onHoleError: capabilities?.attributeError,\n // Post-root failures surface through the rejected holes they strand;\n // observing the stream end keeps a failure that no longer has a pending\n // slot from being silently discarded in development.\n onStreamDone: (result) => {\n if (__DEV__ && result.status === \"failed\") {\n console.error(\n \"Payload decode failed after its root value published:\",\n result.error,\n );\n }\n },\n prepareAssets:\n options.prepareAssets ?? ((assets) => insertAssetResources(assets)),\n retainAssets: options.retainAssets,\n resolveClientReference: options.resolveClientReference,\n signal,\n });\n}\n\nfunction abortReason(signal: AbortSignal): unknown {\n return signal.reason ?? new Error(\"Payload request aborted.\");\n}\n","import type { DataResourceKeyInput } from \"@bgub/fig\";\n\nexport function encodePayloadKey(value: unknown): DataResourceKeyInput {\n const ids = new WeakMap<object, number>();\n let nextId = 1;\n\n function encode(value: unknown): DataResourceKeyInput {\n if (value === null) return null;\n if (value === undefined) return [\"undefined\"];\n if (typeof value === \"string\" || typeof value === \"boolean\") return value;\n if (typeof value === \"number\") {\n if (Number.isNaN(value)) return [\"number\", \"NaN\"];\n if (value === Infinity) return [\"number\", \"Infinity\"];\n if (value === -Infinity) return [\"number\", \"-Infinity\"];\n return Object.is(value, -0) ? [\"number\", \"-0\"] : value;\n }\n if (typeof value === \"bigint\") return [\"bigint\", value.toString()];\n if (typeof value === \"symbol\") {\n const key = Symbol.keyFor(value);\n if (key === undefined) {\n throw new Error(\"Only global Symbol.for symbols can be serialized.\");\n }\n return [\"symbol\", key];\n }\n if (typeof value === \"function\") {\n throw new Error(\"Functions cannot be serialized into the payload.\");\n }\n if (value instanceof Date) {\n const json = value.toJSON();\n if (json === null) {\n throw new Error(\"Invalid Date values cannot be serialized.\");\n }\n return [\"date\", json];\n }\n\n const existing = ids.get(value);\n if (existing !== undefined) return [\"ref\", existing];\n const id = nextId++;\n ids.set(value, id);\n\n if (Array.isArray(value)) {\n return [\"array\", id, value.map(encode)];\n }\n if (value instanceof Map) {\n return [\n \"map\",\n id,\n Array.from(value, ([key, item]) => [encode(key), encode(item)]),\n ];\n }\n if (value instanceof Set) {\n return [\"set\", id, Array.from(value, encode)];\n }\n\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new Error(\n `Cannot serialize ${prototype?.constructor?.name ?? \"object\"} into the payload.`,\n );\n }\n const record = value as Record<string, unknown>;\n return [\n \"object\",\n id,\n Object.keys(record)\n .sort()\n .map((key) => [key, encode(record[key])]),\n ];\n }\n\n return encode(value);\n}\n","import {\n type AwaitedFigNode,\n dataResource,\n type DataResource,\n type DataResourceKey,\n type DataResourceKeyInput,\n type FigNode,\n readData,\n} from \"@bgub/fig\";\nimport { loadContextCapabilities } from \"@bgub/fig/internal\";\nimport {\n decodePayloadResponse,\n type PayloadDecoderOptions,\n} from \"./payload-decoder.ts\";\nimport { encodePayloadKey } from \"./payload-key.ts\";\n\n/** Describes payload source. */\nexport type PayloadSource =\n | Response\n | {\n contentType: string;\n stream: ReadableStream<Uint8Array>;\n };\n\n/** Describes payload component load context. */\nexport interface PayloadComponentLoadContext {\n key: DataResourceKey;\n signal: AbortSignal;\n}\n\n/** Describes payload component loader. */\nexport interface PayloadComponentLoader<\n TProps extends object,\n> extends PayloadDecoderOptions {\n (\n props: TProps,\n context: PayloadComponentLoadContext,\n ): PayloadSource | PromiseLike<PayloadSource>;\n}\n\n/** Describes payload component options. */\nexport interface PayloadComponentOptions<\n TProps extends object,\n> extends PayloadDecoderOptions {\n cacheKey?: (props: TProps) => DataResourceKeyInput;\n key: DataResourceKey;\n load: PayloadComponentLoader<TProps>;\n}\n\n/** Describes payload component. */\nexport interface PayloadComponent<TProps extends object> extends DataResource<\n [TProps],\n AwaitedFigNode\n> {\n (props: TProps & { children?: FigNode }): FigNode;\n}\n\n/**\n * Creates a renderable Payload tree backed by Fig's ordinary data store.\n */\nexport function createPayloadComponent<TProps extends object>(\n options: PayloadComponentOptions<TProps>,\n): PayloadComponent<TProps> {\n const key = (props: TProps): DataResourceKey => {\n const serialized = serializedProps(props);\n return [\n ...options.key,\n options.cacheKey === undefined ? serialized : options.cacheKey(props),\n ];\n };\n const resource = dataResource<[TProps], AwaitedFigNode>({\n debugArgs: options.cacheKey === undefined ? undefined : serializedProps,\n key,\n load: async (props, context) => {\n const source = await options.load(props, {\n key: loadContextCapabilities(context)?.key ?? key(props),\n signal: context.signal,\n });\n const response =\n source instanceof Response\n ? source\n : new Response(source.stream, {\n headers: { \"content-type\": source.contentType },\n });\n return decodePayloadResponse(response, context, {\n prepareAssets: options.prepareAssets ?? options.load.prepareAssets,\n resolveClientReference:\n options.resolveClientReference ?? options.load.resolveClientReference,\n retainAssets: options.retainAssets ?? options.load.retainAssets,\n });\n },\n });\n\n const component: PayloadComponent<TProps> = Object.assign(\n function PayloadComponent(props: TProps & { children?: FigNode }): FigNode {\n rejectChildren(props);\n return readData(component, props);\n },\n resource,\n );\n Object.defineProperty(component, \"displayName\", {\n configurable: true,\n value: `Payload(${options.key[0]})`,\n });\n\n return component;\n}\n\nfunction serializedProps<TProps extends object>(\n props: TProps,\n): DataResourceKeyInput {\n rejectChildren(props);\n return encodePayloadKey(props);\n}\n\nfunction rejectChildren(props: object): void {\n if (Object.hasOwn(props, \"children\")) {\n throw new Error(\"Payload components do not accept children.\");\n }\n}\n","/**\n * Browser DOM rendering APIs for Fig applications.\n *\n * @module\n */\nimport type { FigNode, FigPortal, Key } from \"@bgub/fig\";\nimport { createPortalNode } from \"@bgub/fig/internal\";\nimport type {\n FigRoot,\n FigRootOptions,\n RecoverableErrorInfo,\n} from \"@bgub/fig-reconciler\";\nimport { composeBind } from \"./bind.ts\";\nimport {\n type EventCallback,\n type EventOptions,\n on,\n} from \"./event-descriptor.ts\";\nimport { type Container, registerRoot, unregisterRoot } from \"./events.ts\";\nimport { domRenderer } from \"./renderer.ts\";\n\nexport { insertAssetResources } from \"./asset-resources.ts\";\nexport type { Bind } from \"./bind.ts\";\nexport { composeBind };\nexport { type EventCallback, type EventOptions, on };\nexport type {\n EmptyPropValue,\n HostIntrinsicElements,\n HostProps,\n HostStyle,\n} from \"./jsx.ts\";\nexport {\n createPayloadComponent,\n type PayloadComponent,\n type PayloadComponentLoadContext,\n type PayloadComponentLoader,\n type PayloadComponentOptions,\n type PayloadSource,\n} from \"./payload-component.ts\";\n\nexport type { Container, FigRoot, FigRootOptions, RecoverableErrorInfo };\n\n/** The flush sync. */\nexport const flushSync = domRenderer.flushSync;\n\n/** Creates root. */\nexport function createRoot(\n container: Container,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.createRoot(container, options);\n registerRoot(container, { run: (callback) => root.data.run(callback) });\n return withEventTeardown(root, container);\n}\n\n/** Hydrates root. */\nexport function hydrateRoot(\n container: Container,\n children: FigNode,\n options?: FigRootOptions,\n): FigRoot {\n const root = domRenderer.hydrateRoot(container, children, options);\n registerRoot(container, {\n hydrate: (target, priority) =>\n domRenderer.hydrateTarget(container, target, priority),\n run: (callback) => root.data.run(callback),\n });\n return withEventTeardown(root, container);\n}\n\n/** Creates portal. */\nexport function createPortal(\n children: FigNode,\n container: Container,\n key: Key | null = null,\n): FigPortal<Container> {\n return createPortalNode(children, container, key);\n}\n\n// Event routing lives outside the reconciler, so root teardown owns both.\nfunction withEventTeardown(root: FigRoot, container: Container): FigRoot {\n return {\n ...root,\n unmount: () => {\n root.unmount();\n unregisterRoot(container);\n },\n };\n}\n"],"mappings":"gUAeA,MAAM,MAAmB,IAAA,GAazB,eAAsB,EACpB,EACA,EACA,EAAiC,CAAC,EACT,CACzB,GAAM,CAAE,UAAW,EACnB,GAAI,EAAO,QAET,MADA,MAAM,EAAS,MAAM,OAAO,CAAC,CAAC,MAAM,CAAI,EAClC,EAAY,CAAM,EAE1B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AK,KAAK,IAAI,CAAQ,CAC3C,CAAC,EACM,EAAkB,EAAM,CAAS,CAC1C,CAGA,SAAgB,EACd,EACA,EACA,EAAkB,KACI,CACtB,OAAO,EAAiB,EAAU,EAAW,CAAG,CAClD,CAGA,SAAS,EAAkB,EAAe,EAA+B,CACvE,MAAO,CACL,GAAG,EACH,YAAe,CACb,EAAK,QAAQ,EACb,EAAe,CAAS,CAC1B,CACF,CACF"}
@@ -1,6 +1,8 @@
1
1
  import { FigNode, Key, MixinDescriptor, MixinInput } from "@bgub/fig";
2
2
  //#region src/bind.d.ts
3
+ /** Describes bind. */
3
4
  type Bind<T extends Element = Element> = (node: T, signal: AbortSignal) => undefined;
5
+ /** Compose bind. */
4
6
  declare function composeBind<T extends Element = Element>(...binds: Array<Bind<T> | false | null | undefined>): Bind<T>;
5
7
  //#endregion
6
8
  //#region src/jsx-attributes.generated.d.ts
@@ -183,8 +185,10 @@ interface SvgAttributeNameByTag {
183
185
  }
184
186
  //#endregion
185
187
  //#region src/jsx-attribute-policy.d.ts
188
+ /** Describes empty prop value. */
186
189
  type EmptyPropValue = false | null | undefined;
187
190
  type AttributeValue = string | number | true | EmptyPropValue;
191
+ /** Describes host style. */
188
192
  type HostStyle = Readonly<Record<string, string | EmptyPropValue>>;
189
193
  interface FigHostProps<E extends Element> {
190
194
  bind?: Bind<E> | EmptyPropValue;
@@ -228,6 +232,7 @@ type SvgLegacyAttributeName = "xlink:href" | "xml:space" | "xmlns:xlink";
228
232
  type HostAttributeProps<AttributeName extends string> = { [Name in Exclude<AttributeName, FigOwnedPropName>]?: AttributeValue; };
229
233
  type HtmlAttributes<Tag extends keyof HtmlAttributeNameByTag> = Exclude<HtmlAttributeNameByTag[Tag], FormStatePropName<Tag>> | FigGlobalAttributeName;
230
234
  type SvgAttributes<Tag extends keyof SvgAttributeNameByTag> = SvgAttributeNameByTag[Tag] | FigGlobalAttributeName | SvgLegacyAttributeName;
235
+ /** Describes host props. */
231
236
  type HostProps<E extends Element, AttributeName extends string = never> = FigHostProps<E> & ReactHabitTraps & HostAttributeProps<AttributeName>;
232
237
  type HtmlHostProps<Tag extends string, E extends Element> = HostProps<E, Tag extends keyof HtmlAttributeNameByTag ? HtmlAttributes<Tag> : HtmlGlobalAttributeName | FigGlobalAttributeName> & FormStateProps<Tag>;
233
238
  type SvgHostProps<Tag extends string, E extends Element> = HostProps<E, Tag extends keyof SvgAttributeNameByTag ? SvgAttributes<Tag> : SvgGlobalAttributeName | FigGlobalAttributeName | SvgLegacyAttributeName>;
@@ -240,6 +245,7 @@ interface OpenHostProps<E extends Element> extends FigHostProps<E>, ReactHabitTr
240
245
  type HtmlHostPropsByTag<TagNameMap> = { [Tag in keyof TagNameMap]: Tag extends string ? HtmlHostProps<Tag, TagNameMap[Tag] & Element> : OpenHtmlHostProps<TagNameMap[Tag] & Element>; };
241
246
  type SvgHostPropsByTag<TagNameMap> = { [Tag in keyof TagNameMap]: Tag extends string ? SvgHostProps<Tag, TagNameMap[Tag] & Element> : OpenHostProps<TagNameMap[Tag] & Element>; };
242
247
  type OpenHostPropsByTag<TagNameMap> = { [Tag in keyof TagNameMap]: OpenHostProps<TagNameMap[Tag] & Element>; };
248
+ /** Describes host intrinsic elements. */
243
249
  type HostIntrinsicElements = HtmlHostPropsByTag<HTMLElementTagNameMap> & SvgHostPropsByTag<Omit<SVGElementTagNameMap, keyof HTMLElementTagNameMap>> & OpenHostPropsByTag<Omit<MathMLElementTagNameMap, keyof HTMLElementTagNameMap | keyof SVGElementTagNameMap>> & {
244
250
  [customElement: `${string}-${string}`]: OpenHostProps<HTMLElement>;
245
251
  };
@@ -1,7 +1,8 @@
1
- import { t as HostIntrinsicElements } from "./jsx-C3owhMDw.js";
1
+ import { t as HostIntrinsicElements } from "./jsx-It_Mpx4I.js";
2
2
  import { FigNode, Key } from "@bgub/fig";
3
3
  import { Fragment, jsx, jsxDEV, jsxs } from "@bgub/fig/jsx-runtime";
4
4
  //#region src/jsx-runtime.d.ts
5
+ /** Type definitions for JSX. */
5
6
  declare namespace JSX {
6
7
  type Element = FigNode;
7
8
  interface ElementChildrenAttribute {
@@ -1 +1 @@
1
- {"version":3,"file":"refresh-internal-B05aFp_T.js","names":[],"sources":["../src/refresh-internal.ts"],"sourcesContent":["import type { RefreshUpdate } from \"@bgub/fig-reconciler/refresh\";\n\nlet scheduleDomRefresh: ((update: RefreshUpdate) => void) | null = null;\n\n// Updates that arrive before the @bgub/fig-dom main entry has evaluated (it\n// configures the scheduler as a module side effect). A code-split app can load\n// this entry first, and dropping those updates would silently skip a refresh.\nlet pendingUpdates: RefreshUpdate[] | null = null;\n\nexport function configureDomRefreshScheduler(\n scheduleRefresh: (update: RefreshUpdate) => void,\n): void {\n scheduleDomRefresh = scheduleRefresh;\n\n if (pendingUpdates !== null) {\n const updates = pendingUpdates;\n pendingUpdates = null;\n for (const update of updates) scheduleRefresh(update);\n }\n}\n\nexport function scheduleRefresh(update: RefreshUpdate): void {\n if (scheduleDomRefresh === null) {\n (pendingUpdates ??= []).push(update);\n return;\n }\n\n scheduleDomRefresh(update);\n}\n"],"mappings":"AAEA,IAAI,EAA+D,KAK/D,EAAyC,KAE7C,SAAgB,EACd,EACM,CAGN,GAFA,EAAqB,EAEjB,IAAmB,KAAM,CAC3B,IAAM,EAAU,EAChB,EAAiB,KACjB,IAAK,IAAM,KAAU,EAAS,EAAgB,CAAM,CACtD,CACF,CAEA,SAAgB,EAAgB,EAA6B,CAC3D,GAAI,IAAuB,KAAM,EAC9B,IAAmB,CAAC,EAAA,CAAG,KAAK,CAAM,EACnC,MACF,CAEA,EAAmB,CAAM,CAC3B"}
1
+ {"version":3,"file":"refresh-internal-B05aFp_T.js","names":[],"sources":["../src/refresh-internal.ts"],"sourcesContent":["import type { RefreshUpdate } from \"@bgub/fig-reconciler/refresh\";\n\nlet scheduleDomRefresh: ((update: RefreshUpdate) => void) | null = null;\n\n// Updates that arrive before the @bgub/fig-dom main entry has evaluated (it\n// configures the scheduler as a module side effect). A code-split app can load\n// this entry first, and dropping those updates would silently skip a refresh.\nlet pendingUpdates: RefreshUpdate[] | null = null;\n\nexport function configureDomRefreshScheduler(\n scheduleRefresh: (update: RefreshUpdate) => void,\n): void {\n scheduleDomRefresh = scheduleRefresh;\n\n if (pendingUpdates !== null) {\n const updates = pendingUpdates;\n pendingUpdates = null;\n for (const update of updates) scheduleRefresh(update);\n }\n}\n\n/** Schedules refresh. */\nexport function scheduleRefresh(update: RefreshUpdate): void {\n if (scheduleDomRefresh === null) {\n (pendingUpdates ??= []).push(update);\n return;\n }\n\n scheduleDomRefresh(update);\n}\n"],"mappings":"AAEA,IAAI,EAA+D,KAK/D,EAAyC,KAE7C,SAAgB,EACd,EACM,CAGN,GAFA,EAAqB,EAEjB,IAAmB,KAAM,CAC3B,IAAM,EAAU,EAChB,EAAiB,KACjB,IAAK,IAAM,KAAU,EAAS,EAAgB,CAAM,CACtD,CACF,CAGA,SAAgB,EAAgB,EAA6B,CAC3D,GAAI,IAAuB,KAAM,EAC9B,IAAmB,CAAC,EAAA,CAAG,KAAK,CAAM,EACnC,MACF,CAEA,EAAmB,CAAM,CAC3B"}
package/dist/refresh.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import { RefreshAdapter, RefreshFamily, RefreshUpdate, RefreshUpdate as RefreshUpdate$1 } from "@bgub/fig-reconciler/refresh";
2
2
  //#region src/refresh-internal.d.ts
3
+ /** Schedules refresh. */
3
4
  declare function scheduleRefresh(update: RefreshUpdate$1): void;
4
5
  //#endregion
5
6
  //#region src/refresh.d.ts
7
+ /** The DOM refresh adapter. */
6
8
  declare const domRefreshAdapter: RefreshAdapter;
7
9
  //#endregion
8
10
  export { type RefreshFamily, type RefreshUpdate, domRefreshAdapter, scheduleRefresh };
@@ -1 +1 @@
1
- {"version":3,"file":"refresh.js","names":[],"sources":["../src/refresh.ts"],"sourcesContent":["import {\n type RefreshAdapter,\n type RefreshFamily,\n type RefreshUpdate,\n setRefreshHandler,\n} from \"@bgub/fig-reconciler/refresh\";\nimport { scheduleRefresh } from \"./refresh-internal.ts\";\n\nexport type { RefreshFamily, RefreshUpdate };\nexport { scheduleRefresh };\n\nexport const domRefreshAdapter: RefreshAdapter = {\n scheduleRefresh,\n setRefreshHandler,\n};\n"],"mappings":"oHAWA,MAAa,EAAoC,CAC/C,kBACA,mBACF"}
1
+ {"version":3,"file":"refresh.js","names":[],"sources":["../src/refresh.ts"],"sourcesContent":["/**\n * DOM bindings for the Fig Fast Refresh runtime.\n *\n * @module\n */\nimport {\n type RefreshAdapter,\n type RefreshFamily,\n type RefreshUpdate,\n setRefreshHandler,\n} from \"@bgub/fig-reconciler/refresh\";\nimport { scheduleRefresh } from \"./refresh-internal.ts\";\n\nexport type { RefreshFamily, RefreshUpdate };\nexport { scheduleRefresh };\n\n/** The DOM refresh adapter. */\nexport const domRefreshAdapter: RefreshAdapter = {\n scheduleRefresh,\n setRefreshHandler,\n};\n"],"mappings":"oHAiBA,MAAa,EAAoC,CAC/C,kBACA,mBACF"}