@burojs/react 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -6
- package/dist/flows-runtime.cjs +1162 -0
- package/dist/flows-runtime.cjs.map +1 -0
- package/dist/flows-runtime.d.cts +153 -0
- package/dist/flows-runtime.d.ts +153 -0
- package/dist/flows-runtime.js +1157 -0
- package/dist/flows-runtime.js.map +1 -0
- package/dist/index.cjs +1629 -3862
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2259 -723
- package/dist/index.d.ts +2259 -723
- package/dist/index.js +1412 -3692
- package/dist/index.js.map +1 -1
- package/dist/present-flow-BM8vaiZX.cjs +10152 -0
- package/dist/present-flow-BM8vaiZX.cjs.map +1 -0
- package/dist/present-flow-pFzbn0cZ.js +9015 -0
- package/dist/present-flow-pFzbn0cZ.js.map +1 -0
- package/dist/types-DH3beUOO.d.cts +488 -0
- package/dist/types-DH3beUOO.d.ts +488 -0
- package/package.json +24 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flows-runtime.js","names":["isObject"],"sources":["../src/flows/source-reader.ts","../src/flows/ports.ts","../src/flows/use-flow-run.ts","../src/hooks/use-action.ts","../src/flows/use-flow-form.ts","../src/flows/use-flow-host.ts","../src/flows/forget-each.ts"],"sourcesContent":["import {\n createCustomQueryDescriptor,\n type DataError,\n type DataSessionSnapshot,\n dtoFields,\n type EntityRef,\n type ErasedQueryDescriptor,\n formatEntityRef,\n isDataError,\n LIST_SOURCE_DEFAULT_LIMIT,\n lowerVia,\n normalizeDataError,\n normalizeEntityRef,\n type PortableFieldValueSource,\n type PortableValue,\n relationAmbiguousError,\n type ScreenSource,\n snapshotResourceFields,\n} from '@burojs/core';\nimport { resolveCountExecution } from '../data/count-policy.js';\nimport { executeQuery } from '../data/query-execution.js';\nimport type { DataRuntimeContextValue } from '../data/runtime.js';\nimport {\n EMPTY_COUNTED,\n EMPTY_ROWS,\n hopId,\n type ListFilter,\n listValue,\n projectRow,\n projectRows,\n whereValueUsable,\n withRowId,\n} from '../forms/controller/use-source-resolver.js';\nimport { buildStandardQueryDescriptor } from '../hooks/data/use-standard-query-descriptor.js';\n\n/** What a flow's `with` read resolves refs over: its record, `args` and the app scope. */\nexport interface FlowSourceInputs {\n readonly record: unknown;\n readonly args: unknown;\n readonly scope: unknown;\n readonly locale: string;\n}\n\nconst resource = (target: EntityRef) => ({ kind: 'resource', ref: target }) as never;\n\nfunction ownData(value: unknown, key: string): unknown {\n if (value === null || typeof value !== 'object') return undefined;\n const descriptor = Object.getOwnPropertyDescriptor(value, key);\n return descriptor !== undefined && 'value' in descriptor ? descriptor.value : undefined;\n}\n\n/** A literal, or a ref over the flow's own sources (`record`, `args`, `scope`). */\nfunction operand(value: PortableFieldValueSource, sources: Readonly<Record<string, unknown>>) {\n if (value.kind !== 'ref') return value.value;\n let current: unknown = sources[value.source];\n for (const segment of value.path) {\n current = ownData(current, segment);\n if (current === undefined) return undefined;\n }\n return current;\n}\n\n/** Whether a row read answered `not-found` or `forbidden`: both read `null` (spec 4.1). */\nconst isMissing = (error: DataError) => error.kind === 'not-found' || error.kind === 'forbidden';\n\nfunction configuration(code: string, message: string): DataError {\n return normalizeDataError(Object.assign(new Error(message), { kind: 'configuration', code }));\n}\n\n/**\n * A flow's `with` sources read outside React (P4-B review I5): the same descriptors the record\n * form's source resolver builds (`use-source-resolver.ts`) — `one` by id or by `by`, `list` with\n * `where` / `sort` / `limit` / `count`, `query`, and `via` hop by hop from the record — each run\n * with `executeQuery` under the run's signal. Refs read the flow's record, `args` and scope; a\n * value that cannot key a read sends nothing (`null`, or no rows), and a missing or forbidden row\n * reads `null`. The flow's gate decides before any of this is asked (4.17).\n */\nexport function createFlowSourceReader(input: {\n readonly runtime: DataRuntimeContextValue;\n /** The flow's own resource (a `via` path starts at its record); `null` for an app flow. */\n readonly owner: string | null;\n readonly inputs: () => FlowSourceInputs;\n}): (source: ScreenSource, signal: AbortSignal) => Promise<unknown> {\n const { runtime } = input;\n const app = runtime.app;\n const registryDef = (target: EntityRef) => app.registry.get(resource(target));\n const idFieldOf = (target: EntityRef): string | undefined => {\n const idField = (registryDef(target) as { readonly data?: { readonly idField?: unknown } })\n ?.data?.idField;\n return typeof idField === 'string' && idField !== '' ? idField : undefined;\n };\n const recordDto = (target: EntityRef) => {\n const def = registryDef(target);\n return def === undefined ? undefined : dtoFields(def, 'record');\n };\n const listDto = (target: EntityRef) => {\n const def = registryDef(target);\n return def === undefined ? undefined : dtoFields(def, 'list');\n };\n\n const context = async (): Promise<{\n readonly runtime: DataRuntimeContextValue;\n readonly snapshot: ReturnType<typeof app.runtime.getSnapshot>;\n readonly session: DataSessionSnapshot;\n readonly locale: string;\n }> => ({\n runtime,\n snapshot: app.runtime.getSnapshot(),\n session: await runtime.waitUntilReady(),\n locale: input.inputs().locale,\n });\n\n const run = async (descriptor: ErasedQueryDescriptor | DataError, signal: AbortSignal) => {\n if (isDataError(descriptor)) throw descriptor;\n return (await executeQuery({ descriptor, runtime, signal })) as unknown;\n };\n\n /** One row of `target` by id, or by its `by` field (two rows read: a duplicate fails closed). */\n const row = async (\n target: EntityRef,\n key: string | number,\n by: string | undefined,\n signal: AbortSignal,\n ): Promise<unknown> => {\n const ctx = await context();\n const projection = recordDto(target);\n const idField = idFieldOf(target) ?? 'id';\n const dto =\n projection === undefined || projection.includes(idField)\n ? projection\n : [...projection, idField];\n try {\n if (by === undefined) {\n const answer = (await run(\n buildStandardQueryDescriptor<never, ErasedQueryDescriptor>(ctx, resource(target), {\n kind: 'one',\n id: key,\n ...(projection === undefined ? {} : { projection }),\n }),\n signal,\n )) as { readonly data?: unknown } | null;\n return withRowId(projectRow(answer?.data ?? null, dto), idField, key);\n }\n const answer = (await run(\n buildStandardQueryDescriptor<never, ErasedQueryDescriptor>(ctx, resource(target), {\n kind: 'list',\n filter: { field: by, op: 'eq', value: key },\n pagination: { kind: 'offset', page: 1, pageSize: 2 },\n ...(projection === undefined ? {} : { projection }),\n }),\n signal,\n )) as { readonly data?: unknown } | null;\n const rows = Array.isArray(answer?.data) ? answer.data : [];\n if (rows.length === 0) return null;\n if (rows.length === 1) return projectRow(rows[0], dto);\n throw relationAmbiguousError(formatEntityRef(target), by, String(key));\n } catch (error) {\n const failure = normalizeDataError(error);\n if (isMissing(failure)) return null;\n throw failure;\n }\n };\n\n const list = async (\n entry: Extract<ScreenSource, { kind: 'list' }>,\n sources: Readonly<Record<string, unknown>>,\n signal: AbortSignal,\n ): Promise<unknown> => {\n const fieldKind = (field: string) => {\n const found = snapshotResourceFields(app.runtime.getSnapshot())(entry.target)?.find(\n (candidate) => candidate.name === field,\n ) as { readonly kind?: unknown } | undefined;\n return typeof found?.kind === 'string' ? found.kind : undefined;\n };\n const conditions: { field: string; op: string; value: PortableValue }[] = [];\n for (const condition of entry.where) {\n const value = operand(condition.value, sources);\n // A value that cannot key its field reads no rows and sends nothing (never `eq null`).\n if (!whereValueUsable(value, fieldKind(condition.field)))\n return entry.count === true ? EMPTY_COUNTED : EMPTY_ROWS;\n conditions.push({ field: condition.field, op: condition.op, value: value as PortableValue });\n }\n const filter: ListFilter | undefined =\n conditions.length === 0\n ? undefined\n : conditions.length === 1\n ? conditions[0]\n : { and: conditions };\n const ctx = await context();\n const projection = listDto(entry.target);\n const answer = (await run(\n buildStandardQueryDescriptor<never, ErasedQueryDescriptor>(ctx, resource(entry.target), {\n kind: 'list',\n ...(filter === undefined ? {} : { filter }),\n ...(entry.sort === undefined ? {} : { sort: entry.sort }),\n pagination: {\n kind: 'offset',\n page: 1,\n pageSize: entry.limit ?? LIST_SOURCE_DEFAULT_LIMIT,\n },\n ...(projection === undefined ? {} : { projection }),\n }),\n signal,\n )) as { readonly data?: unknown; readonly total?: unknown } | null;\n const rows = projectRows(answer?.data, projection);\n if (entry.count !== true) return listValue(rows);\n const inline = typeof answer?.total === 'number' ? answer.total : undefined;\n const execution = resolveCountExecution('auto', inline, { query: true, live: false });\n if (isDataError(execution)) throw execution;\n if (execution.kind === 'inline') return listValue(rows, execution.total);\n const counted = (await run(\n buildStandardQueryDescriptor<never, ErasedQueryDescriptor>(ctx, resource(entry.target), {\n kind: 'count',\n ...(filter === undefined ? {} : { filter }),\n }),\n signal,\n )) as { readonly total?: unknown } | null;\n if (typeof counted?.total !== 'number')\n throw configuration('count-missing', 'The count read returned no total.');\n return listValue(rows, counted.total);\n };\n\n const query = async (\n entry: Extract<ScreenSource, { kind: 'query' }>,\n sources: Readonly<Record<string, unknown>>,\n signal: AbortSignal,\n ): Promise<unknown> => {\n const values: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(entry.input)) {\n const resolved = operand(value, sources);\n values[key] = resolved === undefined ? null : resolved;\n }\n const ctx = await context();\n return run(\n createCustomQueryDescriptor({\n snapshot: ctx.snapshot,\n session: ctx.session,\n locale: ctx.locale,\n ref: entry.query,\n input: values as PortableValue,\n }) as ErasedQueryDescriptor | DataError,\n signal,\n );\n };\n\n const via = async (\n entry: Extract<ScreenSource, { kind: 'via' }>,\n sources: Readonly<Record<string, unknown>>,\n signal: AbortSignal,\n ): Promise<unknown> => {\n if (input.owner === null)\n throw configuration('via-invalid', \"An app flow has no record for a 'via' source.\");\n let hops: ReturnType<typeof lowerVia>;\n try {\n hops = lowerVia(\n normalizeEntityRef(input.owner),\n {\n path: entry.path,\n ...(entry.to === undefined ? {} : { to: entry.to }),\n ...(entry.by === undefined ? {} : { by: entry.by }),\n },\n snapshotResourceFields(app.runtime.getSnapshot()),\n idFieldOf,\n );\n } catch (error) {\n const code = (error as { readonly code?: unknown }).code;\n throw configuration(\n typeof code === 'string' ? code : 'via-invalid',\n error instanceof Error ? error.message : String(error),\n );\n }\n let current: unknown = sources.record ?? null;\n for (const hop of hops) {\n const key = hopId(ownData(current, hop.field));\n // No key: nothing to read for this hop or any later one (spec 4.1).\n if (key === null) return null;\n current = await row(hop.target, key, hop.by, signal);\n if (current === null) return null;\n }\n return current;\n };\n\n return async (source, signal) => {\n const { record, args, scope } = input.inputs();\n const sources = { record, args, scope };\n switch (source.kind) {\n case 'one': {\n const key = hopId(operand(source.key, sources));\n // Known finding 1: a source with no key reads nothing; it is `null`.\n if (key === null) return null;\n return row(source.target, key, source.by, signal);\n }\n case 'list':\n return list(source, sources, signal);\n case 'query':\n return query(source, sources, signal);\n case 'via':\n return via(source, sources, signal);\n }\n };\n}\n","import {\n type AppContext,\n type AppRuntime,\n type Audit,\n type CompiledFlow,\n createIdempotencyKey,\n createMutationDescriptor,\n createQueryDescriptor,\n dtoFields,\n type EntityRef,\n type ErasedMutationDescriptor,\n FLOW_SETTLE_MS,\n formatEntityRef,\n type FlowAttemptsPort,\n type FlowFormPort,\n type FlowMutationCall,\n type FlowPorts,\n lowerVia,\n normalizeEntityRef,\n type PermissionMap,\n projectSource,\n type ReadDataAccess,\n type Row,\n resolveDataCapability,\n resolveFieldAccess,\n resolveFlowGate,\n ruleContextFor,\n type ScreenSource,\n snapshotResourceFields,\n trustedFlowAttachments,\n} from '@burojs/core';\nimport { hashCanonical } from '@burojs/core/flows';\nimport { customMutationDescriptor, resourceDescriptorBase } from '../data/action-data-access.js';\nimport { executeMutation } from '../data/mutation-options.js';\nimport { executeQuery } from '../data/query-execution.js';\nimport { createFlowSourceReader } from './source-reader.js';\nimport type { DataRuntimeContextValue } from '../data/runtime.js';\n\n/** What the ports read at the moment they are asked (the latest render's values). */\nexport interface FlowPortsContext {\n readonly user: unknown;\n readonly scope: unknown;\n readonly permissions: PermissionMap | undefined;\n readonly visibility: AppContext;\n readonly t: (key: string, params?: Record<string, unknown>, defaultValue?: string) => string;\n readonly audit: Audit | null;\n /** The active locale (a custom query's descriptor carries it). */\n readonly locale: string;\n}\n\nexport interface CreateRuntimeFlowPortsInput {\n readonly runtime: DataRuntimeContextValue;\n readonly app: AppRuntime;\n readonly flow: CompiledFlow;\n readonly record?: Row;\n readonly args?: Row;\n readonly attempts: FlowAttemptsPort;\n readonly form: FlowFormPort;\n readonly user: string | null;\n readonly data: ReadDataAccess;\n /** The latest render's context, read when a port is asked. */\n readonly context: () => FlowPortsContext;\n}\n\nconst resourceHandle = (resource: string | EntityRef) =>\n ({ kind: 'resource', ref: normalizeEntityRef(resource) }) as const;\n\n/** An id a read may address (Known finding 1): a non-empty string or a finite number. */\nfunction validKey(value: unknown): string | number | undefined {\n if (typeof value === 'string') return value === '' ? undefined : value;\n if (typeof value === 'number' && Number.isFinite(value)) return value;\n return undefined;\n}\n\n/**\n * Waits for the mutation's effects to refetch the live queries they hit (plan ruling 12): until\n * the query client fetches nothing, checked after one microtask and then on every cache change,\n * or `FLOW_SETTLE_MS`, whichever comes first.\n */\nexport function settleQueries(runtime: DataRuntimeContextValue): Promise<void> {\n const client = runtime.queryClient;\n return new Promise<void>((resolve) => {\n let done = false;\n let unsubscribe: (() => void) | undefined;\n const finish = () => {\n if (done) return;\n done = true;\n clearTimeout(timer);\n unsubscribe?.();\n resolve();\n };\n const timer = setTimeout(finish, FLOW_SETTLE_MS);\n void Promise.resolve().then(() => {\n if (client.isFetching() === 0) {\n finish();\n return;\n }\n unsubscribe = client.getQueryCache().subscribe(() => {\n if (client.isFetching() === 0) finish();\n });\n });\n });\n}\n\n/**\n * The flow ports over the data runtime (P4 B.5): the gate over the provider's permission\n * status; `with` reads and the re-read through the runtime's queries; the one mutation through\n * `executeMutation` with the run's intent key; the attempts store; the internal audit emitter.\n */\nexport function createRuntimeFlowPorts(input: CreateRuntimeFlowPortsInput): FlowPorts {\n const { runtime, app, flow } = input;\n\n /**\n * A source as the flow's UI may render it (P4 4.24 C2, P5 spec 3.6): every field its user may\n * not view is left out, and a decision still pending counts as hidden. The `record` is the\n * flow's resource's; a `with` source is its target's (`one`, `via`) or its rows' (`list`); a\n * custom query's output is the host's. Checks, `submit.input`, `id` and `reread.expect` do not\n * come through here: they read the sources as read.\n */\n const projectSourceValue = (name: string, value: unknown): unknown => {\n if (value === null || typeof value !== 'object') return value;\n const owner = flow.resource === null ? undefined : normalizeEntityRef(flow.resource);\n let target: EntityRef | undefined;\n let shape: 'row' | 'rows' = 'row';\n if (name === 'record') target = owner;\n else {\n const withs = flow.flow.with ?? {};\n const entry = Object.hasOwn(withs, name) ? withs[name] : undefined;\n if (entry?.kind === 'one') target = entry.target;\n else if (entry?.kind === 'list') {\n target = entry.target;\n shape = 'rows';\n } else if (entry?.kind === 'via' && owner !== undefined) {\n try {\n const fieldsOf = snapshotResourceFields(app.runtime.getSnapshot());\n target = lowerVia(\n owner,\n {\n path: entry.path,\n ...(entry.to === undefined ? {} : { to: entry.to }),\n ...(entry.by === undefined ? {} : { by: entry.by }),\n },\n fieldsOf,\n ).at(-1)?.target;\n } catch {\n return null;\n }\n }\n }\n if (target === undefined) return value;\n const def = app.registry.get({ kind: 'resource', ref: target } as never) as\n | { readonly data?: { readonly idField?: unknown } }\n | undefined;\n // A resource the registry lacks declares no field to hide.\n if (def === undefined) return value;\n const context = input.context();\n const resource = formatEntityRef(target);\n const decisions = resolveFieldAccess({\n rules: app.ruleSource.rules(resource),\n fields: dtoFields(def as never, shape === 'row' ? 'record' : 'list'),\n context: ruleContextFor({\n user: context.user as never,\n scope: context.scope as never,\n ...(context.permissions === undefined ? {} : { permissions: context.permissions }),\n ...(shape === 'row' ? { record: value } : {}),\n mode: shape === 'row' ? 'show' : 'list',\n resource,\n }),\n permissions: context.permissions,\n reach: shape === 'row' ? 'record' : 'every',\n });\n // Pending (and failed) is hidden: nothing is drawn before the decision is made.\n const closed = Object.fromEntries(\n Object.entries(decisions).map(([field, decision]) => [\n field,\n decision.view === 'visible' ? decision : { ...decision, view: 'hidden' as const },\n ]),\n );\n const idField = def.data?.idField;\n const projected = projectSource(\n { status: 'ready', value, refreshing: false },\n closed as never,\n shape,\n typeof idField === 'string' && idField !== '' ? idField : 'id',\n );\n return projected.status === 'ready' ? projected.value : value;\n };\n\n /** The descriptor of the call's mutation, under the current lease. */\n const describe = async (call: FlowMutationCall): Promise<ErasedMutationDescriptor> => {\n if (call.op === 'custom')\n return customMutationDescriptor(runtime, normalizeEntityRef(call.target), call.input);\n const base = await resourceDescriptorBase(runtime, resourceHandle(call.target));\n const kind =\n call.op === 'create' ? 'createOne' : call.op === 'update' ? 'updateOne' : 'deleteOne';\n return createMutationDescriptor({\n ...base,\n kind,\n ...(call.id === undefined ? {} : { id: call.id }),\n ...(call.op === 'delete' || call.input === undefined ? {} : { input: call.input }),\n } as never) as ErasedMutationDescriptor;\n };\n\n const queryOne = async (\n resource: string | EntityRef,\n id: string | number,\n signal: AbortSignal,\n ) => {\n const base = await resourceDescriptorBase(runtime, resourceHandle(resource));\n const result = (await executeQuery({\n descriptor: createQueryDescriptor({ ...base, kind: 'one', id } as never),\n runtime,\n signal,\n })) as { readonly data?: unknown };\n return result.data;\n };\n\n /** Whether the resource's provider declares a single-record read (M7). */\n const hasOne = (resource: string): boolean => {\n try {\n const binding = app.resolveDataBinding(resourceHandle(resource) as never);\n const service = runtime.providers.resolve(binding.providerId);\n return (\n typeof resolveDataCapability(service.provider, {\n lifecycle: 'query',\n kind: 'one',\n }) === 'function'\n );\n } catch {\n return false;\n }\n };\n\n const replaySafe = (): boolean => {\n if (flow.op !== 'custom') return false;\n try {\n const projection = app.runtime\n .getSnapshot()\n .getProjection({ kind: 'custom-mutation', ref: normalizeEntityRef(flow.target) } as never);\n const value = projection?.value as\n | { binding?: { provider?: string }; replay?: { capability?: unknown; id?: unknown } }\n | undefined;\n const replay = value?.replay;\n const policy =\n replay?.capability === 'mutation-replay-policy' && typeof replay.id === 'string'\n ? app.getPluginCapability('mutation-replay-policy', replay.id)\n : undefined;\n if (policy !== 'once-after-auth-refresh' || value?.binding?.provider === undefined)\n return false;\n const service = runtime.providers.resolve(value.binding.provider);\n const handler = resolveDataCapability(service.provider, {\n lifecycle: 'mutation',\n kind: 'custom',\n }) as { readonly replay?: unknown };\n return (\n (handler.replay as { readonly idempotency?: unknown } | undefined)?.idempotency ===\n 'keyed-replay-once'\n );\n } catch {\n return false;\n }\n };\n\n // Every `with` kind, built as the record form's resolver builds it (review I5).\n const readSource = createFlowSourceReader({\n runtime,\n owner: flow.resource,\n inputs: () => {\n const context = input.context();\n return {\n record: input.record,\n args: input.args ?? {},\n scope: context.scope,\n locale: context.locale,\n };\n },\n });\n\n return {\n gate() {\n const context = input.context();\n return resolveFlowGate({\n app,\n resource: flow.resource,\n flow,\n ctx: ruleContextFor({\n ...(input.record === undefined ? {} : { record: input.record }),\n ...(flow.resource === null ? {} : { resource: flow.resource }),\n mode: input.record === undefined ? 'list' : 'show',\n user: context.user as never,\n scope: context.scope as never,\n ...(context.permissions === undefined ? {} : { permissions: context.permissions }),\n }),\n permissionsStatus: context.permissions?.status as 'loading' | 'ready' | 'error' | undefined,\n });\n },\n read(_name: string, source: ScreenSource, signal: AbortSignal) {\n return readSource(source, signal);\n },\n async reread(resource: string, ids: readonly string[], signal: AbortSignal) {\n const clean = ids.filter((id) => validKey(id) !== undefined);\n if (clean.length === 0) return [];\n if (clean.length === 1 && hasOne(resource)) {\n const row = await queryOne(resource, clean[0] as string, signal);\n return row === null || row === undefined ? [] : [row as Row];\n }\n const base = await resourceDescriptorBase(runtime, resourceHandle(resource));\n const result = (await executeQuery({\n descriptor: createQueryDescriptor({ ...base, kind: 'many', ids: clean } as never),\n runtime,\n signal,\n })) as { readonly data?: readonly Row[] };\n return result.data ?? [];\n },\n async mutate(call: FlowMutationCall) {\n const descriptor = await describe(call);\n const output = await executeMutation({\n descriptor,\n runtime,\n idempotencyKey: call.key,\n ...(call.replay === 'never' ? { replay: 'never' as const } : {}),\n });\n await settleQueries(runtime);\n return output;\n },\n attempts: input.attempts,\n audit(event) {\n input.context().audit?.emit(event, { initiates: true });\n },\n checks: {\n source: (resource) => app.checkSource.checks(resource),\n data: input.data,\n get ctx() {\n return input.context().visibility;\n },\n t: (key, params, defaultValue) => input.context().t(key, params, defaultValue),\n },\n form: input.form,\n project: projectSourceValue,\n // The flow's provenance registry (P4-A review C1): only the trusted attachments of the layers\n // that wrote the flow; never a value's own shape.\n attachment: trustedFlowAttachments(app.runtime, flow),\n clock: {\n now: () => Date.now(),\n uuid: () => createIdempotencyKey(),\n wait: (ms, signal) =>\n new Promise<void>((resolve, reject) => {\n const timer = setTimeout(resolve, ms);\n signal.addEventListener(\n 'abort',\n () => {\n clearTimeout(timer);\n reject(signal.reason);\n },\n { once: true },\n );\n }),\n },\n hash: hashCanonical,\n user: input.user,\n get replaySafe() {\n return replaySafe();\n },\n };\n}\n","import {\n type CompiledFlow,\n compileFlow,\n type DispatcherEffects,\n type FlowAttemptsPort,\n type FlowRef,\n type FlowRun,\n type FlowSnapshot,\n type FlowTarget,\n isFlowRef,\n attemptKey,\n attemptSlot,\n fnv1a,\n type FlowOpenEffect,\n type FlowThenEffects,\n type ReadDataAccess,\n type RouteDescriptor,\n type Row,\n runThenEffects,\n} from '@burojs/core';\nimport { createFlowFormPort, createFlowRun, createMemoryAttempts } from '@burojs/core/flows';\nimport { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport { useFrameworkAudit } from '../audit/internal.js';\nimport {\n createRuntimeActionDataAccess,\n createUnavailableActionDataAccess,\n} from '../data/action-data-access.js';\nimport { useOptionalDataRuntime } from '../data/context.js';\nimport {\n isSignedOut,\n readPermissions,\n useContextSnapshot,\n} from '../forms/controller/use-source-resolver.js';\nimport { useApp } from '../hooks/use-app.js';\nimport { useCurrentUserId } from '../hooks/use-current-user-id.js';\nimport { useOptionalVisibilityCtx } from '../hooks/use-permissions.js';\nimport { useLocale, useTranslate } from '../hooks/use-t.js';\nimport { useDismissPending } from '../navigation/dismiss-scope.js';\nimport { useNavigationHold } from '../navigation/navigation-guard.js';\nimport { useApplicationSnapshot } from '../runtime.js';\nimport { useDispatcherEffects } from '../dispatch/dispatcher-context.js';\nimport { useFlowAttemptsStore } from './attempts-binding.js';\nimport { createRuntimeFlowPorts, type FlowPortsContext } from './ports.js';\nimport { disposeWhenIdle, type InlineLease } from './inline-holder.js';\nimport { registerFlowRun } from './run-registry.js';\n\n// Bundlers fold the development branch out of a production build.\ndeclare const process: { readonly env: { readonly NODE_ENV?: string } };\n\nexport interface UseFlowRunOptions {\n readonly record?: Row;\n readonly args?: Row;\n readonly selection?: { readonly ids: readonly string[]; readonly count: number };\n /** Where the flow was started (`'button'`, `'menu'`, `'code'`): for development messages. */\n readonly surface?: string;\n /**\n * The effects `then` runs through: the dispatcher scope the flow was started in, when the run\n * is held elsewhere (the host owns it, P4-C review I1). Default: the nearest scope.\n */\n readonly thenEffects?: () => DispatcherEffects;\n /**\n * An inline placement's lease (P6 3.12): the run is kept in the lease, built once per what it\n * was built for and reused by every node that takes the lease, so unmounting the node (a tab\n * switch) neither disposes it nor starts a second attempt.\n */\n readonly lease?: InlineLease;\n /**\n * The caller only needs the flow's link, never its run: a page-hosted flow builds no run (the\n * route runs it), so nothing is read to decide. `run` stays `null` for such a flow.\n */\n readonly linkOnly?: boolean;\n}\n\nexport interface UseFlowRunResult {\n /** `null` while the flow cannot run here (no data runtime, unknown flow, the store pending). */\n readonly run: FlowRun | null;\n readonly snapshot: FlowSnapshot;\n readonly compiled: CompiledFlow | null;\n /**\n * Starts a fresh run in place of this one (the host closed): the gate and sources are asked\n * again, a stored attempt is adopted again, and the form opens on its initial values (a draft\n * is offered). Nothing of the previous run's values is carried.\n */\n reset(): void;\n /**\n * While a host draws the run, `then` waits (`holdThen(true)`); once the host closed, the\n * opener runs it (`runThen()`) — the host is gone before a redirect or a quick open, and the\n * guard asks nothing about its form (4.13, 4.19). Runs once per outcome.\n */\n holdThen(hold: boolean): void;\n runThen(): void;\n}\n\nconst IDLE: FlowSnapshot = Object.freeze({\n step: 'gate',\n history: Object.freeze([]),\n control: 'undecided',\n values: Object.freeze({}),\n issues: Object.freeze([]),\n warnings: Object.freeze([]),\n key: null,\n attempt: null,\n canResend: false,\n formStep: null,\n});\nconst ABSENT: FlowSnapshot = Object.freeze({ ...IDLE, control: 'absent' });\nconst NO_SUBSCRIBE = () => () => {};\n\n/** The flow a target names, compiled; `null` when the app does not declare it. */\nfunction compileTarget(\n app: ReturnType<typeof useApp>,\n target: FlowRef | FlowTarget,\n): CompiledFlow | null {\n const named = isFlowRef(target) ? target.target : target;\n try {\n if ('appAction' in named) {\n const def = app.registry.appActions.get(named.appAction);\n return def === undefined ? null : compileFlow(def as never, named.appAction);\n }\n const def = app.registry.get(named.resource);\n return def === undefined ? null : compileFlow(def as never, named.action);\n } catch {\n return null;\n }\n}\n\nconst keyOfTarget = (target: FlowRef | FlowTarget) => {\n const named = isFlowRef(target) ? target.target : target;\n return 'appAction' in named ? `app:${named.appAction}` : `r:${named.resource}/${named.action}`;\n};\n\nlet warnedNoUser = false;\n\nconst isObject = (value: unknown): value is Readonly<Record<string, unknown>> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\nconst idOf = (value: unknown): string | undefined =>\n typeof value === 'string' && value !== ''\n ? value\n : typeof value === 'number' && Number.isFinite(value)\n ? String(value)\n : undefined;\n\n/**\n * The attempt key a run of `compiled` uses (4.10): `attemptKey({ user, flow, slot })` with the\n * machine's slot — the record's id, the args hash, the selection hash (a single-mutation bulk\n * flow).\n * @internal\n */\nexport function flowAttemptKey(\n compiled: CompiledFlow,\n user: string | null,\n record: Row | undefined,\n args: Row | undefined,\n selection: readonly string[] | undefined,\n): string {\n const recordId = idOf(record?.[compiled.idField] ?? record?.id);\n return attemptKey({\n user,\n flow: compiled.flowId,\n slot: attemptSlot({\n ...(recordId === undefined ? {} : { record: recordId }),\n ...(args === undefined || Object.keys(args).length === 0 ? {} : { argsHash: fnv1a(args) }),\n ...(selection === undefined || compiled.each\n ? {}\n : { selectionHash: fnv1a([...selection].sort()) }),\n }),\n });\n}\n\n/**\n * The machine's resolved `then` as the dispatcher's effects take it (4.13): the notification\n * text, the route, and a record to open (default: the flow's own record). A block to open stays\n * with the host. `null` when there is nothing for the effects.\n */\nfunction thenFor(\n compiled: CompiledFlow,\n effects: NonNullable<FlowSnapshot['effects']>,\n record: Row | undefined,\n): FlowThenEffects | null {\n let open: FlowOpenEffect | undefined;\n const target = effects.open;\n if (isObject(target) && !Object.hasOwn(target, 'block')) {\n const resource =\n typeof target.resource === 'string' ? target.resource : (compiled.resource ?? undefined);\n const id = idOf(target.id) ?? idOf(record?.[compiled.idField] ?? record?.id);\n if (resource !== undefined && id !== undefined)\n open = {\n kind: 'record',\n resource,\n id,\n mode: target.mode === 'edit' ? 'edit' : 'show',\n quick: target.quick === true,\n };\n }\n const then: FlowThenEffects = {\n ...(effects.notify === undefined ? {} : { notify: effects.notify }),\n ...(effects.redirect === undefined ? {} : { redirect: effects.redirect as RouteDescriptor }),\n ...(open === undefined ? {} : { open }),\n };\n return Object.keys(then).length === 0 ? null : then;\n}\n\n/**\n * Runs a flow on the data runtime (P4 B.5): the core machine (`createFlowRun`) over ports that\n * read and write through the runtime with the run's intent key, keep attempts in the tab's\n * attempts store (a per-run memory store without a signed-in user, ruling 13), and audit through\n * the framework's emitter. While the write is in flight the host's dismissal is locked\n * (`useDismissPending`) and every route change is held (`useNavigationHold`, `beforeunload`\n * armed). A back/forward-cache restore re-syncs the run from the attempts store (M9).\n * @internal\n */\nexport function useFlowRun(\n target: FlowRef | FlowTarget,\n opts: UseFlowRunOptions = {},\n): UseFlowRunResult {\n const app = useApp();\n const runtime = useOptionalDataRuntime();\n const appSnapshot = useApplicationSnapshot();\n const targetKey = keyOfTarget(target);\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the target's identity and the published snapshot\n const compiled = useMemo(() => compileTarget(app, target), [app, targetKey, appSnapshot]);\n\n const userId = useCurrentUserId();\n const store = useFlowAttemptsStore();\n const context = useContextSnapshot();\n const signedOut = isSignedOut(context);\n const visibility = useOptionalVisibilityCtx();\n const translate = useTranslate();\n const locale = useLocale();\n const audit = useFrameworkAudit();\n const latest = useRef<FlowPortsContext>(null as never);\n latest.current = {\n user: context.user,\n scope: context.scope,\n permissions: readPermissions(context),\n visibility,\n t: (key, params, defaultValue) => {\n const text = translate(key, params === undefined ? undefined : { params });\n return text === key ? (defaultValue ?? key) : text;\n },\n audit,\n locale,\n };\n\n const data = useMemo<ReadDataAccess>(\n () =>\n runtime === null\n ? createUnavailableActionDataAccess('A flow needs a data runtime; none is mounted.')\n : createRuntimeActionDataAccess(runtime),\n [runtime],\n );\n\n // While the write runs, the run is not rebuilt for a fresher record (a refetch, a realtime\n // update): its outcome and its `then` belong to the run that sent (P4-C review M1).\n const liveRecordKey = opts.record === undefined ? '' : JSON.stringify(opts.record);\n const heldRecordKey = useRef(liveRecordKey);\n const writing = useRef(false);\n if (!writing.current) heldRecordKey.current = liveRecordKey;\n const recordKey = heldRecordKey.current;\n const argsKey = opts.args === undefined ? '' : JSON.stringify(opts.args);\n const selectionKey =\n opts.selection === undefined ? '' : [...opts.selection.ids].sort().join('\\u0000');\n const latestOpts = useRef(opts);\n latestOpts.current = opts;\n\n // A back/forward-cache restore (M9): the run is built again over the store, keeping values.\n const [generation, setGeneration] = useState(0);\n const carried = useRef<Row | undefined>(undefined);\n\n // The generation is component-local, so a leased run (which outlives the component) cannot key\n // on it: a restart drops the lease's run explicitly and the next build replaces it (3.12).\n const restart = useCallback(() => {\n const lease = latestOpts.current.lease;\n if (lease?.run != null) {\n disposeWhenIdle(lease.run);\n lease.run = null;\n lease.deps = null;\n }\n setGeneration((value) => value + 1);\n }, []);\n\n const attempts = useMemo<FlowAttemptsPort | null>(() => {\n if (compiled === null) return null;\n // A memory store only when the user is signed out for certain (ruling 13). While the user\n // slot is pending or failed, the user may be signed in with an unresolved attempt in the\n // tab's store: there is no run (the control stays undecided), never a store that cannot see\n // that attempt (P4-B review C1).\n if (userId === null) return signedOut ? createMemoryAttempts() : null;\n return store === null || store.user !== userId ? null : store.port;\n // A new memory store per run generation: nothing outlives the run without a user.\n // biome-ignore lint/correctness/useExhaustiveDependencies: a fresh memory store per generation\n }, [compiled, userId, signedOut, store, generation]);\n\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the record, args and selection values\n const run = useMemo<FlowRun | null>(() => {\n if (compiled === null || runtime === null || attempts === null) return null;\n // A page-hosted flow builds no run for a link: the route (or the host page) runs it.\n if (\n latestOpts.current.linkOnly === true &&\n (compiled.flow.host === 'page' ||\n (compiled.flow.host !== undefined && typeof compiled.flow.host === 'object'))\n )\n return null;\n const { record, args, selection, lease } = latestOpts.current;\n const leaseDeps =\n lease === undefined\n ? null\n : // The record's identity, not its values: a refetch must not reseed typed input (3.12).\n [compiled.flowId, userId, lease.record, argsKey].join('\\u0000');\n if (lease?.run != null && lease.deps === leaseDeps) return lease.run;\n const ports = createRuntimeFlowPorts({\n runtime,\n app,\n flow: compiled,\n ...(record === undefined ? {} : { record }),\n ...(args === undefined ? {} : { args }),\n attempts,\n form: createFlowFormPort(compiled.flow, app, { i18nPrefix: compiled.formId }),\n user: userId,\n data,\n context: () => latest.current,\n });\n const created = createFlowRun({\n flow: compiled,\n ...(record === undefined ? {} : { record }),\n ...(args === undefined ? {} : { args }),\n ...(selection === undefined ? {} : { selection }),\n ports,\n });\n registerFlowRun(created, compiled.formId);\n if (carried.current !== undefined) created.setValues(carried.current);\n carried.current = undefined;\n if (lease !== undefined) {\n // A rebuilt run replaces the lease's (`restart` already disposed a superseded one).\n lease.run = created;\n lease.deps = leaseDeps;\n lease.opened = false;\n }\n return created;\n }, [\n compiled,\n runtime,\n attempts,\n app,\n userId,\n data,\n recordKey,\n argsKey,\n selectionKey,\n generation,\n ]);\n\n useEffect(() => {\n if (!signedOut || compiled === null || warnedNoUser) return;\n if (process.env.NODE_ENV === 'production') return;\n warnedNoUser = true;\n console.warn(\n `[burojs] ${compiled.flowId} runs without a signed-in user: its attempts are kept in memory for this run only, and its form keeps no draft.`,\n );\n }, [signedOut, compiled]);\n\n // Opened in an effect, disposed in its cleanup: a StrictMode remount re-opens the run.\n useEffect(() => {\n if (run === null) return;\n const lease = latestOpts.current.lease;\n // A leased run outlives its node: the holder disposes it, and it opens once.\n if (lease === undefined) {\n void run.open();\n return () => run.dispose();\n }\n if (lease.opened) return;\n lease.opened = true;\n void run.open();\n }, [run]);\n\n // A gate that answered `undecided` (permissions loading) decides again once they settle.\n const permissionsStatus = readPermissions(context)?.status;\n useEffect(() => {\n if (run === null || permissionsStatus === 'loading') return;\n if (run.getSnapshot().control === 'undecided') void run.open();\n }, [run, permissionsStatus]);\n\n const snapshot = useSyncExternalStore(\n run?.subscribe ?? NO_SUBSCRIBE,\n () => run?.getSnapshot() ?? (compiled === null ? ABSENT : IDLE),\n () => run?.getSnapshot() ?? (compiled === null ? ABSENT : IDLE),\n );\n\n // The pending lock (4.19): from the re-read to the persisted outcome nothing closes the host\n // and no route change leaves the page.\n const locked = snapshot.control === 'running';\n writing.current = locked;\n useDismissPending(locked);\n useNavigationHold(locked);\n\n // `then` (4.13, I12): after success, through the effects of the nearest dispatcher scope where\n // the flow was started — once per outcome. A block is the host's; it never reaches `open`.\n const scopeEffects = useDispatcherEffects();\n const effectsOf = opts.thenEffects ?? scopeEffects;\n const ranThen = useRef<unknown>(null);\n const outcome = snapshot.outcome;\n const thenEffects = snapshot.effects;\n /** A host is drawing the run: `then` waits until it closed (4.13: close, then redirect/open). */\n const thenHeld = useRef(false);\n const thenOf = useRef({ run, compiled });\n thenOf.current = { run, compiled };\n const runThen = useCallback(() => {\n const { run: current, compiled: flow } = thenOf.current;\n if (current === null || flow === null) return;\n const now = current.getSnapshot();\n if (now.outcome?.outcome !== 'success' || now.effects === undefined) return;\n if (ranThen.current === now.outcome) return;\n ranThen.current = now.outcome;\n const then = thenFor(flow, now.effects, latestOpts.current.record);\n if (then === null) return;\n void runThenEffects(effectsOf(), then).catch((error: unknown) => {\n if (process.env.NODE_ENV !== 'production')\n console.error(`[burojs] ${flow.flowId}: a then effect threw.`, error);\n });\n }, [effectsOf]);\n const holdThen = useCallback((hold: boolean) => {\n thenHeld.current = hold;\n }, []);\n // biome-ignore lint/correctness/useExhaustiveDependencies: runs once per outcome of the run\n useEffect(() => {\n if (thenHeld.current) return;\n runThen();\n }, [run, compiled, outcome, thenEffects, runThen]);\n\n const lockedRef = useRef(locked);\n lockedRef.current = locked;\n // The run follows the tab's attempts store (4.10, P4-B review M2): another tab's outcome\n // broadcast, or a back/forward-cache restore's resync (M9), that changes this run's attempt\n // rebuilds the run over the store (keeping the typed values), so it adopts a new unknown\n // attempt or leaves one another tab resolved. Never while the run itself is writing.\n useEffect(() => {\n if (run === null || store === null || compiled === null || compiled.each) return;\n const { record, args, selection } = latestOpts.current;\n const key = flowAttemptKey(compiled, userId, record, args, selection?.ids);\n return store.subscribe(() => {\n if (lockedRef.current) return;\n const now = run.getSnapshot();\n const held = now.outcome?.outcome === 'unknown' ? now.key : null;\n if ((store.port.read(key)?.key ?? null) === held) return;\n carried.current = now.values;\n restart();\n });\n }, [run, store, compiled, userId, restart]);\n\n const reset = useCallback(() => {\n if (lockedRef.current) return;\n carried.current = undefined;\n restart();\n }, [restart]);\n\n return useMemo(\n () => ({ run, snapshot, compiled, reset, holdThen, runThen }),\n [run, snapshot, compiled, reset, holdThen, runThen],\n );\n}\n","import {\n type CompiledFlow,\n type FlowControlState,\n type FlowRef,\n type FlowResult,\n type FlowTarget,\n type Row,\n type StandardSchemaV1,\n hrefFor,\n humanizeKey,\n isFlowRef,\n trustedFlowAttachments,\n} from '@burojs/core';\nimport { useCallback, useMemo, useRef } from 'react';\nimport { usePageFlowGate } from '../flows/page-flow-gate.js';\nimport { conjoinHostPage, hostPageRef, useHostPage } from '../flows/page-host.js';\nimport { useRouteNavigate } from '../navigation/use-route-navigate.js';\nimport { usePresentFlow } from '../flows/present-flow.js';\nimport { useFlowRowResolver } from '../flows/row-batch.js';\nimport { useFlowRun } from '../flows/use-flow-run.js';\nimport { useApp } from './use-app.js';\nimport { useProjectedTitle } from './use-projected-record.js';\n\n// Bundlers fold the development branch out of a production build.\ndeclare const process: { readonly env: { readonly NODE_ENV?: string } };\n\nexport interface UseActionOptions<Args = Readonly<Record<string, unknown>>> {\n /** The record an item flow runs on. */\n readonly record?: Row;\n /** The flow's `args`, type-checked against a typed handle's declaration (M11). */\n readonly args?: Args;\n}\n\nexport interface UseActionResult {\n /** The control's state (4.14): the same gate, sources and pre-click checks as the button. */\n readonly state: FlowControlState;\n /** Why the flow is disabled, when it is. */\n readonly reason?: string;\n /**\n * Runs the flow. While its state is `undecided` or `absent` it resolves\n * `{ outcome: 'unavailable', state }` at once and queues nothing; two calls while one runs\n * share one promise (one send).\n */\n run(): Promise<FlowResult>;\n}\n\ntype ArgsOf<T> = T extends FlowRef<infer A, unknown> ? A : Readonly<Record<string, unknown>>;\n\nconst isObject = (value: unknown): value is Readonly<Record<string, unknown>> =>\n value !== null && typeof value === 'object' && !Array.isArray(value);\nconst isStandard = (value: unknown): value is StandardSchemaV1 =>\n isObject(value) &&\n isObject(value['~standard']) &&\n typeof (value['~standard'] as { validate?: unknown }).validate === 'function';\n\n/** A declared arg's Standard Schema: a `prop(schema)`, or a trusted attachment of one. */\nfunction schemaOf(\n declared: unknown,\n attachment: (capability: string, id: string) => unknown,\n): StandardSchemaV1 | undefined {\n if (isStandard(declared)) return declared;\n if (!isObject(declared)) return undefined;\n const schema = declared.schema;\n if (isStandard(schema)) return schema;\n if (isObject(schema) && typeof schema.capability === 'string' && typeof schema.id === 'string') {\n const resolved = attachment(schema.capability, schema.id);\n if (isStandard(resolved)) return resolved;\n if (isObject(resolved) && isStandard(resolved.schema)) return resolved.schema;\n }\n return undefined;\n}\n\n/** The first declared arg whose value its schema refuses (4.14, M11); `null` when all pass. */\nasync function invalidArg(\n compiled: CompiledFlow,\n args: Readonly<Record<string, unknown>>,\n attachment: (capability: string, id: string) => unknown,\n): Promise<string | null> {\n const declared = (compiled.flow as { readonly args?: Readonly<Record<string, unknown>> }).args;\n for (const [name, entry] of Object.entries(declared ?? {})) {\n // A compiled arg says `optional` (the lowering maps `prop().optional()` to it); a raw prop\n // says `isOptional` (P4-B review I3).\n const optional = isObject(entry) && (entry.optional === true || entry.isOptional === true);\n if (args[name] === undefined && optional) continue;\n const schema = schemaOf(entry, attachment);\n if (schema === undefined) continue;\n const outcome = await schema['~standard'].validate(args[name]);\n if ((outcome as { readonly issues?: unknown }).issues !== undefined) return name;\n }\n return null;\n}\n\n/**\n * Starts a flow from code (P4 spec 4.14, Q11): `useAction(flowsOf(orders).cancel, { record })`,\n * or an app flow's definition with its typed `args`, or an untyped `{ resource, action }` pair.\n * It runs the same gate, sources and pre-click checks as the flow's button. A flow without a\n * host is submitted by `run()`; a flow with a form or review opens the UI kit's flow host\n * (`buro:flow`) and `run()` resolves when the host closes, with the outcome; without the kit's\n * screen in `presentationHosts` (a development error names it) it resolves the run's halt on its\n * first screen.\n */\nexport function useAction<T extends FlowRef | FlowTarget>(\n target: T,\n opts: UseActionOptions<ArgsOf<T>> = {},\n): UseActionResult {\n const app = useApp();\n const navigate = useRouteNavigate();\n const flow = useFlowRun(target, {\n ...(opts.record === undefined ? {} : { record: opts.record }),\n ...(opts.args === undefined ? {} : { args: opts.args as Row }),\n surface: 'code',\n linkOnly: true,\n });\n const { run, snapshot, compiled } = flow;\n // A page-hosted flow is a link: its control comes from the row resolver, with no run built and\n // no read made in the caller (the route's own run does that).\n const named = isFlowRef(target) ? target.target : target;\n const resolveRow = useFlowRowResolver('resource' in named ? named.resource : '');\n const pageHosted = compiled?.flow.host === 'page';\n // A flow hosted on a custom page (P7 3.15): a link to the page's own path, gated by the flow's\n // gate conjoined with the page's access. No record, no run built here.\n const hostPage = useHostPage(compiled?.flow.host);\n const hosted = hostPageRef(compiled?.flow.host) !== undefined;\n const hostGate = usePageFlowGate(named as FlowTarget);\n const pageControl = pageHosted ? resolveRow(compiled.name, opts.record) : undefined;\n // The heading titles over the projected record: a display field its user may not view never\n // reaches the flow host (P5 spec 3.6).\n const title = useProjectedTitle(\n compiled?.resource ?? undefined,\n compiled === null ? undefined : (opts.record?.[compiled.idField] ?? opts.record?.id),\n opts.record,\n );\n const present = usePresentFlow();\n const presentInput = {\n label:\n compiled === null\n ? ''\n : typeof compiled.flow.label === 'string'\n ? compiled.flow.label\n : humanizeKey(compiled.name),\n ...(opts.record === undefined || title === '' ? {} : { title }),\n ...(opts.record === undefined ? {} : { record: opts.record }),\n ...(opts.args === undefined ? {} : { args: opts.args as Row }),\n };\n const hostRef = useRef({ present, presentInput, target });\n hostRef.current = { present, presentInput, target };\n const inflight = useRef<Promise<FlowResult> | null>(null);\n // The control of a flow hosted on a custom page: the flow's gate conjoined with the page's access.\n const hostState: FlowControlState | undefined = hosted\n ? conjoinHostPage(\n hostGate.answer.state === 'available'\n ? 'ready'\n : hostGate.answer.state === 'hidden'\n ? 'absent'\n : hostGate.answer.state,\n hostPage,\n )\n : undefined;\n const hostLink =\n hostState === undefined ? undefined : { state: hostState, href: hostPage?.href ?? '' };\n const latest = useRef({\n run,\n snapshot,\n compiled,\n args: opts.args as Row | undefined,\n pageControl,\n hostLink,\n });\n latest.current = {\n run,\n snapshot,\n compiled,\n args: opts.args as Row | undefined,\n pageControl,\n hostLink,\n };\n const pageOf = useRef({ navigate, app, record: opts.record });\n pageOf.current = { navigate, app, record: opts.record };\n const attachments = useMemo(\n () => (compiled === null ? () => undefined : trustedFlowAttachments(app.runtime, compiled)),\n [app, compiled],\n );\n\n const runNow = useCallback((): Promise<FlowResult> => {\n if (inflight.current !== null) return inflight.current;\n const {\n run: current,\n snapshot: now,\n compiled: flow,\n args,\n pageControl: link,\n hostLink: pageLink,\n } = latest.current;\n // A flow hosted on a custom page (P7 3.15) lives on that page: `run()` goes there, through\n // the guard. Only an available control goes; anything else answers as unavailable.\n if (pageLink !== undefined) {\n if (pageLink.state !== 'ready' || pageLink.href === '')\n return Promise.resolve(\n Object.freeze({ outcome: 'unavailable', state: pageLink.state as FlowControlState }),\n );\n pageOf.current.navigate(pageLink.href);\n return Promise.resolve(Object.freeze({ outcome: 'navigated' }));\n }\n // A page-hosted flow lives on its own route (P6): `run()` goes there, through the guard, and\n // the page runs the flow. Only an available control goes: a disabled, absent or undecided\n // one answers as unavailable, as every other flow does.\n if (flow !== null && link !== undefined) {\n if (link.state !== 'ready')\n return Promise.resolve(Object.freeze({ outcome: 'unavailable', state: link.state }));\n const { navigate: go, app: owner, record } = pageOf.current;\n const id = record?.[flow.idField] ?? record?.id;\n if (\n (typeof id !== 'string' && typeof id !== 'number') ||\n String(id) === '' ||\n flow.resource === null\n ) {\n if (process.env.NODE_ENV !== 'production')\n console.error(\n `[burojs] useAction(${flow.flowId}): a page-hosted flow needs the record it runs on; nothing was opened.`,\n );\n return Promise.resolve(Object.freeze({ outcome: 'failed' }));\n }\n go(\n hrefFor(owner.registry, flow.resource, { action: 'flow', id: String(id), flow: flow.name }),\n );\n return Promise.resolve(Object.freeze({ outcome: 'navigated' }));\n }\n // Undecided or absent: nothing runs, now or later (P3-20).\n if (\n current === null ||\n flow === null ||\n now.control === 'undecided' ||\n now.control === 'absent'\n )\n return Promise.resolve(\n Object.freeze({\n outcome: 'unavailable',\n state: current === null && flow !== null ? 'undecided' : now.control,\n }),\n );\n const started = (async (): Promise<FlowResult> => {\n const invalid = await invalidArg(flow, args ?? {}, attachments);\n if (invalid !== null) {\n if (process.env.NODE_ENV !== 'production')\n console.error(\n `[burojs] useAction(${flow.flowId}): args.${invalid} does not match the flow's declared args; nothing was run.`,\n );\n return Object.freeze({ outcome: 'failed' });\n }\n // A flow with a form or a review opens the UI kit's host and resolves when it closes,\n // with the run's outcome then; without the kit's screen it stops on the first screen.\n if (flow.hasHost) {\n // The host owns its own run (P4-C review I1): it outlives this hook's component.\n const { present: open, presentInput: given, target: what } = hostRef.current;\n const closed = open({\n ...given,\n target: what,\n host: flow.flow.host === 'sheet' ? 'sheet' : 'dialog',\n });\n if (closed !== null) return closed;\n }\n return current.submit();\n })();\n inflight.current = started;\n void started.finally(() => {\n if (inflight.current === started) inflight.current = null;\n });\n return started;\n }, [attachments]);\n\n const state = hostState ?? (pageControl === undefined ? snapshot.control : pageControl.state);\n const reason = hosted\n ? hostGate.answer.state === 'disabled'\n ? hostGate.answer.reason\n : undefined\n : pageControl === undefined\n ? snapshot.reason\n : pageControl.reason;\n return useMemo(\n () =>\n Object.freeze({\n state,\n ...(reason === undefined ? {} : { reason }),\n run: runNow,\n }),\n [state, reason, runNow],\n );\n}\n","import { type CompiledFlow, type FlowRun, type FlowSnapshot, fnv1a, type Row } from '@burojs/core';\nimport { fieldEntriesToMap } from '@burojs/core/internal';\nimport { useCallback, useEffect, useMemo, useRef } from 'react';\nimport type { FormController } from '../forms/controller/types.js';\nimport { useFormController } from '../forms/controller/use-form-controller.js';\nimport { useFlowFormCatalog } from '../runtime.js';\nimport { useCurrentUserId } from '../hooks/use-current-user-id.js';\nimport { flowAttemptKey } from './use-flow-run.js';\nimport type { FormValues } from '../forms/types.js';\n\nconst NO_FIELDS = Object.freeze({});\n\n/**\n * The flow's form as the host draws it (P4 spec 4.4, plan ruling 6): the resource-less form\n * controller over the flow's fields and tree, controlled by the run — the run's values are the\n * form's, every edit reaches the run — with the run as its claim (no `form.submit`; the draft in\n * mode `flow`, keyed by the record, the args and the selection). The draft is cleared on\n * `success` only; a Leave keeps it (4.19). The run's own validation and payload come from core's\n * `createFlowFormPort` over the same fields, which a parity test holds to this controller.\n * @internal\n */\nexport function useFlowForm(\n run: FlowRun | null,\n compiled: CompiledFlow | null,\n snapshot: FlowSnapshot,\n opts: { readonly record?: Row; readonly args?: Row; readonly selection?: readonly string[] } = {},\n): FormController {\n const form = compiled?.flow.form;\n const userId = useCurrentUserId();\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the compiled flow\n const fields = useMemo(\n () => (form === undefined ? NO_FIELDS : fieldEntriesToMap(form.fields)),\n [compiled],\n );\n const tree = form?.body as readonly unknown[] | undefined;\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by the compiled flow\n const body = useMemo(() => (tree === undefined ? undefined : () => tree as never), [compiled]);\n const recordId =\n opts.record === undefined || compiled === null\n ? undefined\n : (opts.record[compiled.idField] ?? opts.record.id);\n const flowDraft = useMemo(\n () => ({\n ...(typeof recordId === 'string' || typeof recordId === 'number'\n ? { recordId: String(recordId) }\n : {}),\n ...(opts.args === undefined || Object.keys(opts.args).length === 0\n ? {}\n : { argsHash: fnv1a(opts.args) }),\n ...(opts.selection === undefined || compiled?.each === true\n ? {}\n : { selectionHash: fnv1a([...opts.selection].sort()) }),\n ...(compiled === null\n ? {}\n : {\n attempt: flowAttemptKey(compiled, userId, opts.record, opts.args, opts.selection),\n }),\n }),\n // biome-ignore lint/correctness/useExhaustiveDependencies: keyed by values\n [\n String(recordId),\n JSON.stringify(opts.args ?? null),\n (opts.selection ?? []).join('\\u0000'),\n compiled,\n userId,\n ],\n );\n const onChange = useCallback((values: FormValues) => run?.setValues(values), [run]);\n // The app's blocks: a flow's form body may place them (P4-D, spec 3.6).\n const blocks = useFlowFormCatalog();\n // What a form field's `meta` reads beside the form (P7 3.2): the record the flow runs on\n // (`null` for a flow with none) and its args.\n const metaSources = useMemo(\n () =>\n Object.freeze({\n record: Object.freeze({\n status: 'ready' as const,\n value: opts.record ?? null,\n refreshing: false,\n }),\n args: Object.freeze({\n status: 'ready' as const,\n value: opts.args ?? {},\n refreshing: false,\n }),\n }),\n [opts.record, opts.args],\n );\n const controller = useFormController({\n blocks,\n metaSources,\n fields: fields as never,\n ...(body === undefined ? {} : { body }),\n mode: 'create',\n surface: 'create',\n ...(compiled === null\n ? {}\n : {\n formId: compiled.formId,\n // Text slots key as `resources.<r>.actions.<name>.…` (an app flow: `appActions.<name>`).\n i18nPrefix:\n compiled.resource === null\n ? `appActions.${compiled.name}`\n : `${compiled.resource}.actions.${compiled.name}`,\n }),\n ...(form?.draft === undefined || run === null ? {} : { draft: form.draft }),\n ...(run === null ? {} : { flowRun: run }),\n flowDraft,\n flowIssues: snapshot.issues,\n value: snapshot.values as FormValues,\n onChange,\n });\n // The form opens on the run's initial values: they are its baseline, not an edit.\n const seeded = useRef<FlowRun | null>(null);\n const opened = snapshot.history.includes('open');\n useEffect(() => {\n if (run === null || !opened || seeded.current === run) return;\n seeded.current = run;\n controller.reset(run.getSnapshot().values as FormValues);\n }, [run, opened, controller]);\n // The draft is cleared on success only (4.11): rejected, failed and unknown keep it, and stay\n // dirty for correction.\n const succeeded = snapshot.outcome?.outcome === 'success';\n const outcome = snapshot.outcome;\n const cleared = useRef<unknown>(null);\n useEffect(() => {\n if (!succeeded || cleared.current === outcome) return;\n cleared.current = outcome;\n // Saved: nothing unsaved remains, so the guard asks nothing (4.19), and the draft goes.\n controller.reset(snapshot.values as FormValues);\n controller.draft.discard();\n }, [succeeded, outcome, snapshot.values, controller]);\n return controller;\n}\n","'use client';\nimport type { FlowResult, Row } from '@burojs/core';\nimport { useCallback, useContext, useEffect, useMemo, useRef, useState } from 'react';\nimport { DismissRegistryContext, DismissScopeContext } from '../navigation/dismiss-scope.js';\nimport { useUIPresentationRuntime } from '../ui/context.js';\nimport { useOptionalPresentationMount } from '../ui/mount.js';\nimport { FLOW_COMPONENT, FlowScreenEntry, type FlowScreenProps } from '../ui/ui-presentations.js';\nimport { useCurrentUIActivation } from '../ui/use-ui-present.js';\nimport { reportMissingFlowHost } from './present-flow.js';\nimport type { UseFlowRunResult } from './use-flow-run.js';\n\nexport interface UseFlowHostOptions {\n /** The action's label: the host's header and the submit button. */\n readonly label: string;\n /** The record's title, for an item flow's header. */\n readonly title?: string;\n readonly record?: Row;\n readonly args?: Row;\n readonly selection?: { readonly ids: readonly string[]; readonly count: number };\n}\n\nexport interface FlowHostControl {\n /**\n * Presents the flow's host (`buro:flow`) over the run, in the flow's `host` unless one is\n * given (a hostless flow's outcome shows in a dialog). Resolves when the host closes, with the\n * run's outcome then (`halted` when it closed without one); `null` when nothing could be\n * presented (no run yet, or the hosts lack the screen — one development error names it).\n */\n open(host?: 'dialog' | 'sheet'): Promise<FlowResult> | null;\n /** Whether this opener's host is on screen. */\n readonly isOpen: boolean;\n}\n\n/**\n * @internal The opener's side of a flow's host (P4 spec 4.15, 4.19): presents the UI kit's\n * `buro:flow` screen through the presentation runtime with the opener's dismiss scope as its\n * parent (closing a quick sheet asks about a dirty flow above it, P3 criterion 39), and, once\n * the host has gone, starts a fresh run in place of the one it drew — so reopening asks the\n * gate again, adopts a stored attempt again and offers the draft. The host closes with its\n * opener.\n */\nexport function useFlowHost(flow: UseFlowRunResult, opts: UseFlowHostOptions): FlowHostControl {\n const runtime = useUIPresentationRuntime();\n const mount = useOptionalPresentationMount();\n const registry = useContext(DismissRegistryContext);\n const enclosing = useContext(DismissScopeContext);\n const activation = useCurrentUIActivation();\n const [openId, setOpenId] = useState<string | null>(null);\n /** Counts the host's closes: each one runs `then` and resets the run, after its commit. */\n const [closed, setClosed] = useState(0);\n const current = useRef<{\n readonly id: string;\n readonly settle: (result: FlowResult) => void;\n readonly run: NonNullable<UseFlowRunResult['run']>;\n } | null>(null);\n const latest = useRef({ flow, opts });\n latest.current = { flow, opts };\n\n const open = useCallback(\n (hostOverride?: 'dialog' | 'sheet'): Promise<FlowResult> | null => {\n const { flow: now, opts: given } = latest.current;\n const { run, compiled } = now;\n if (run === null || compiled === null || mount === null) return null;\n if (current.current !== null) return null;\n // A page-hosted flow has its own route and never opens an overlay host (P6).\n const host = hostOverride ?? (compiled.flow.host === 'sheet' ? 'sheet' : 'dialog');\n if (mount.mode === 'app' && !mount.registry.isMounted()) {\n console.error(\n `[burojs] ${compiled.flowId} opened nothing: BuroProvider is in presentations=\"app\" mode but no <BuroPresentationOutlet/> is mounted.`,\n );\n return null;\n }\n if (mount.hosts[host] === undefined) {\n reportMissingFlowHost(mount.registry, host);\n return null;\n }\n if (mount.hosts.screens?.flow === undefined) {\n reportMissingFlowHost(mount.registry, 'screens.flow');\n return null;\n }\n const props: FlowScreenProps = {\n run,\n host,\n label: given.label,\n compiled,\n ...(given.title === undefined ? {} : { title: given.title }),\n ...(given.record === undefined ? {} : { record: given.record }),\n ...(given.args === undefined ? {} : { args: given.args }),\n ...(given.selection === undefined ? {} : { selection: given.selection }),\n };\n const result = runtime.present({\n component: FLOW_COMPONENT,\n host,\n // By reference: the run's identity is the form's claim (see `FlowScreenEntry`).\n props: { entry: new FlowScreenEntry(props) },\n options: { ownTitle: true, wrapper: false },\n activation,\n });\n if (!result.ok) return null;\n if (registry !== null && enclosing !== null)\n registry.recordParent(result.instance.id, enclosing.id);\n let settle: (result: FlowResult) => void = () => undefined;\n const closed = new Promise<FlowResult>((resolve) => {\n settle = resolve;\n });\n current.current = { id: result.instance.id, settle, run };\n // `then` waits for the host to close (4.13).\n now.holdThen(true);\n setOpenId(result.instance.id);\n return closed;\n },\n [runtime, mount, registry, enclosing, activation],\n );\n\n // The host has gone (whoever closed it): settle the opener's promise with the run's outcome,\n // then start a fresh run in place of the one it drew.\n useEffect(() => {\n if (openId === null) return;\n const check = () => {\n const open = current.current;\n if (open === null || open.id !== openId) return;\n if (runtime.getSnapshot().some((descriptor) => descriptor.id === openId)) return;\n current.current = null;\n const snapshot = open.run.getSnapshot();\n open.settle(snapshot.outcome ?? Object.freeze({ outcome: 'halted', step: snapshot.step }));\n setOpenId(null);\n setClosed((value) => value + 1);\n };\n check();\n return runtime.subscribe(check);\n }, [runtime, openId]);\n\n // The host is gone — unmounted with its form, after the commit that removed it: `then` runs now\n // (its redirect or quick open finds no host and no dirty form of the flow's to ask about),\n // then a fresh run takes the drawn one's place.\n useEffect(() => {\n if (closed === 0) return;\n latest.current.flow.holdThen(false);\n latest.current.flow.runThen();\n latest.current.flow.reset();\n }, [closed]);\n\n // The host closes with its opener (a row that went away, a page left).\n useEffect(\n () => () => {\n const open = current.current;\n if (open === null) return;\n current.current = null;\n runtime.dismiss(open.id);\n const snapshot = open.run.getSnapshot();\n open.settle(snapshot.outcome ?? Object.freeze({ outcome: 'halted', step: snapshot.step }));\n },\n [runtime],\n );\n\n return useMemo(() => ({ open, isOpen: openId !== null }), [open, openId]);\n}\n","'use client';\nimport {\n attemptKey,\n attemptSlot,\n compileFlow,\n type FlowRef,\n type FlowTarget,\n isFlowRef,\n} from '@burojs/core';\nimport { useCallback, useRef } from 'react';\nimport { useFrameworkAudit } from '../audit/internal.js';\nimport { useApp } from '../hooks/use-app.js';\nimport { useCurrentUserId } from '../hooks/use-current-user-id.js';\nimport { useFlowAttemptsStore } from './attempts-binding.js';\n\n/**\n * @internal \"I've checked — forget it\" for one id of a bulk flow (P4-C review I3): the exit of\n * an id a bulk run left `unknown` or found unresolved, which no Check again can reach (`each`\n * declares no `onUnknown`) and which every later run skips. It drops that id's attempt without\n * sending and audits `flow.submit` with `outcome: 'unknown'`, `resolvedBy: 'user'` — the\n * `start over` of one id. Resolves whether there was an attempt to forget.\n */\nexport function useForgetEachAttempt(\n target: FlowRef | FlowTarget,\n): (id: string) => Promise<boolean> {\n const app = useApp();\n const userId = useCurrentUserId();\n const store = useFlowAttemptsStore();\n const audit = useFrameworkAudit();\n const latest = useRef({ app, userId, store, audit, target });\n latest.current = { app, userId, store, audit, target };\n return useCallback(async (id: string): Promise<boolean> => {\n const { app: now, userId: user, store: tab, audit: sink, target: what } = latest.current;\n if (user === null || tab === null || tab.user !== user || id === '') return false;\n const named = isFlowRef(what) ? what.target : what;\n if ('appAction' in named) return false;\n const def = now.registry.get(named.resource);\n if (def === undefined) return false;\n const compiled = compileFlow(def as never, named.action);\n const key = attemptKey({ user, flow: compiled.flowId, slot: attemptSlot({ record: id }) });\n const stored = tab.port.read(key) ?? (await tab.port.ask(key));\n if (stored === null || stored.flow !== compiled.flowId) return false;\n tab.port.drop(key);\n sink?.emit(\n Object.freeze({\n type: 'flow.submit',\n flow: compiled.flowId,\n ...(compiled.resource === null ? {} : { resource: compiled.resource }),\n recordId: id,\n mutation: compiled.mutationRef,\n idempotencyKey: stored.key,\n attempt: 1,\n outcome: 'unknown',\n resolvedBy: 'user',\n acceptedWarnings: Object.freeze([]),\n diff: Object.freeze({}),\n }) as never,\n { initiates: true },\n );\n return true;\n }, []);\n}\n"],"mappings":";;;;;;;;AA2CA,MAAM,YAAY,YAAuB;CAAE,MAAM;CAAY,KAAK;AAAO;AAEzE,SAAS,QAAQ,OAAgB,KAAsB;CACrD,IAAI,UAAU,QAAQ,OAAO,UAAU,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