@protobase/ui 0.110.2 → 0.110.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/messages.d.ts +2 -2
- package/dist/app/change-confirm/messages.d.ts +2 -2
- package/dist/app/charts/messages.d.ts +2 -2
- package/dist/app/comments/messages.d.ts +2 -2
- package/dist/app/confirm-sign-in-messages.d.ts +2 -2
- package/dist/app/create/messages.d.ts +2 -2
- package/dist/app/delete/messages.d.ts +2 -2
- package/dist/app/displays/messages.d.ts +2 -2
- package/dist/app/embedded-list/messages.d.ts +2 -2
- package/dist/app/export/messages.d.ts +2 -2
- package/dist/app/field-messages.d.ts +2 -2
- package/dist/app/field-types/custom-step-container/messages.d.ts +2 -2
- package/dist/app/field-types/runner-install/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/definition.d.ts +1 -1
- package/dist/app/field-types/workflow/messages.d.ts +2 -2
- package/dist/app/field-types/workflow/pins/pin-text.d.ts +1 -1
- package/dist/app/field-types/workflow-page/messages.d.ts +2 -2
- package/dist/app/field-types/workflow-run/messages.d.ts +2 -2
- package/dist/app/file-viewers/messages.d.ts +2 -2
- package/dist/app/focus/messages.d.ts +2 -2
- package/dist/app/gallery/gallery-layout.d.ts +2 -2
- package/dist/app/gallery/messages.d.ts +2 -2
- package/dist/app/hand-order/messages.d.ts +2 -2
- package/dist/app/history/messages.d.ts +2 -2
- package/dist/app/import/messages.d.ts +2 -2
- package/dist/app/list-edit/messages.d.ts +2 -2
- package/dist/app/list-messages.d.ts +2 -2
- package/dist/app/messages.d.ts +2 -2
- package/dist/app/meta-gate-messages.d.ts +2 -2
- package/dist/app/new-version/messages.d.ts +2 -2
- package/dist/app/pages/messages.d.ts +2 -2
- package/dist/app/record-chart/messages.d.ts +2 -2
- package/dist/app/record-messages.d.ts +2 -2
- package/dist/app/record-mode/shown-layout.d.ts +1 -1
- package/dist/app/record-row/messages.d.ts +2 -2
- package/dist/app/related-cards/messages.d.ts +2 -2
- package/dist/app/runtime/messages.d.ts +2 -2
- package/dist/app/search/messages.d.ts +2 -2
- package/dist/app/searches/messages.d.ts +2 -2
- package/dist/app-shell/messages.d.ts +2 -2
- package/dist/assistant-dock/messages.d.ts +2 -2
- package/dist/auth/messages.d.ts +2 -2
- package/dist/calls/messages.d.ts +2 -2
- package/dist/chat/messages.d.ts +2 -2
- package/dist/data-grid/column-spec.d.ts +1 -1
- package/dist/data-grid/messages.d.ts +2 -2
- package/dist/filter-panel/messages.d.ts +2 -2
- package/dist/format/messages.d.ts +2 -2
- package/dist/inline-child-table/messages.d.ts +2 -2
- package/dist/invitations/messages.d.ts +2 -2
- package/dist/mailbox/messages.d.ts +2 -2
- package/dist/markdown/messages.d.ts +2 -2
- package/dist/mentions/messages.d.ts +2 -2
- package/dist/mocks/customers.d.ts +2 -2
- package/dist/mocks/invoices.d.ts +3 -3
- package/dist/mocks/orders.d.ts +3 -3
- package/dist/notifications/bell/messages.d.ts +2 -2
- package/dist/organizations/messages.d.ts +2 -2
- package/dist/package.js +1 -1
- package/dist/plugins/messages.d.ts +2 -2
- package/dist/primitives/messages.d.ts +2 -2
- package/dist/record-view/messages.d.ts +2 -2
- package/dist/shell/assets/{app-CJ_u4OIL.js → app-D4-5F6lc.js} +7 -7
- package/dist/shell/assets/{graph-view-BxsGyeAL.js → graph-view-BRWlmoUI.js} +2 -2
- package/dist/shell/assets/{html-viewer-CXAGqYhH.js → html-viewer-DE8OmxLk.js} +2 -2
- package/dist/shell/assets/{in-place-form-BZGOMivv.js → in-place-form-DPXE3cvR.js} +2 -2
- package/dist/shell/assets/{index-BqlPqvgs.js → index-B5wvQwgy.js} +2 -2
- package/dist/shell/assets/{maplibre-DNbz-uBO.js → maplibre-HMwq6ObW.js} +2 -2
- package/dist/shell/assets/{markdown-content-Cotge8LR.js → markdown-content-CobQrDkP.js} +2 -2
- package/dist/shell/assets/{record-map-D2SXzNwq.js → record-map-BiWOCwIZ.js} +2 -2
- package/dist/shell/assets/{records-map-WKMebIMv.js → records-map-BMf4VhXp.js} +2 -2
- package/dist/shell/assets/{run-trace-view-CX_rI2ve.js → run-trace-view-BHWG3fvd.js} +2 -2
- package/dist/shell/assets/{search-picker-Jp13g0bD.js → search-picker-BI3OVHwO.js} +2 -2
- package/dist/shell/assets/{shared-protobase-ui-CFZrjVaZ.js → shared-protobase-ui-Dcf-4_Zb.js} +2 -2
- package/dist/shell/assets/{step-catalog-CKtYOK23.js → step-catalog-BFlUuoVA.js} +2 -2
- package/dist/shell/assets/{step-panel-CZ106BKz.js → step-panel-DlWb3DTs.js} +2 -2
- package/dist/shell/assets/{use-sibling-page-BFxjcXYB.js → use-sibling-page-CLxIRXkS.js} +2 -2
- package/dist/shell/assets/{workflow-canvas-ret7Edvp.js → workflow-canvas-haWih003.js} +2 -2
- package/dist/shell/assets/{workflow-graph-editor-BGl3k608.js → workflow-graph-editor-Bxx34Tbe.js} +2 -2
- package/dist/shell/assets/{workflow-workbench-B7Pa06BI.js → workflow-workbench-CJYNS-r9.js} +2 -2
- package/dist/shell/index.html +3 -3
- package/dist/shell/protobase.shell.json +3 -3
- package/dist/shell/protobase.sw.js +2 -2
- package/dist/shell-source-maps/assets/{app-CJ_u4OIL.js.map → app-D4-5F6lc.js.map} +1 -1
- package/dist/shell-source-maps/assets/{graph-view-BxsGyeAL.js.map → graph-view-BRWlmoUI.js.map} +1 -1
- package/dist/shell-source-maps/assets/{html-viewer-CXAGqYhH.js.map → html-viewer-DE8OmxLk.js.map} +1 -1
- package/dist/shell-source-maps/assets/{in-place-form-BZGOMivv.js.map → in-place-form-DPXE3cvR.js.map} +1 -1
- package/dist/shell-source-maps/assets/{index-BqlPqvgs.js.map → index-B5wvQwgy.js.map} +1 -1
- package/dist/shell-source-maps/assets/{maplibre-DNbz-uBO.js.map → maplibre-HMwq6ObW.js.map} +1 -1
- package/dist/shell-source-maps/assets/{markdown-content-Cotge8LR.js.map → markdown-content-CobQrDkP.js.map} +1 -1
- package/dist/shell-source-maps/assets/{record-map-D2SXzNwq.js.map → record-map-BiWOCwIZ.js.map} +1 -1
- package/dist/shell-source-maps/assets/{records-map-WKMebIMv.js.map → records-map-BMf4VhXp.js.map} +1 -1
- package/dist/shell-source-maps/assets/{run-trace-view-CX_rI2ve.js.map → run-trace-view-BHWG3fvd.js.map} +1 -1
- package/dist/shell-source-maps/assets/{search-picker-Jp13g0bD.js.map → search-picker-BI3OVHwO.js.map} +1 -1
- package/dist/shell-source-maps/assets/{shared-protobase-ui-CFZrjVaZ.js.map → shared-protobase-ui-Dcf-4_Zb.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-catalog-CKtYOK23.js.map → step-catalog-BFlUuoVA.js.map} +1 -1
- package/dist/shell-source-maps/assets/{step-panel-CZ106BKz.js.map → step-panel-DlWb3DTs.js.map} +1 -1
- package/dist/shell-source-maps/assets/{use-sibling-page-BFxjcXYB.js.map → use-sibling-page-CLxIRXkS.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-canvas-ret7Edvp.js.map → workflow-canvas-haWih003.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-graph-editor-BGl3k608.js.map → workflow-graph-editor-Bxx34Tbe.js.map} +1 -1
- package/dist/shell-source-maps/assets/{workflow-workbench-B7Pa06BI.js.map → workflow-workbench-CJYNS-r9.js.map} +1 -1
- package/dist/status/messages.d.ts +2 -2
- package/dist/users/messages.d.ts +2 -2
- package/package.json +5 -5
package/dist/shell-source-maps/assets/{step-panel-CZ106BKz.js.map → step-panel-DlWb3DTs.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"step-panel-CZ106BKz.js","names":["useState","_Fragment","n","a","t","__toESM","require_react","require_jsx_runtime","useAdminMeta","AppLink","Button","buttonClass","useRunSteps","JsonBlock","formatDateTime","messages","formatTag","cn","stateAt","splitPath","nodeStatusLabel","triggerLabel","nodeTones","stateLabel","Badge","customStepOf","import_react","scopeItems","scope","match","part","statePath","item","state","weight","nodeTraces","placed","within","counts","lastOfState","lastOfScope","step","steps","path","statuses","mark","known","status","inProgress","startAt","text","import_jsx_runtime","Part","title","children","logTime","at","Logs","logs","line","index","StepCard","meta","jobs","\"workflow_custom_step_jobs\"","heldBack","items","output","valueActions","runId","Heading","kind","name","StateSteps","trace","run","shown","setShown","blockRun","block","StepPanel","selected","definition","types"],"sources":["../../../src/app/field-types/workflow-run/run-trace.ts","../../../src/app/field-types/workflow-run/messages.ts","../../../src/app/field-types/workflow-run/step-card.tsx","../../../src/app/field-types/workflow-run/step-panel.tsx"],"sourcesContent":["import type { NodeStatus, NodeTrace } from '../workflow/node-trace'\n\n/** What the graph reads of a run's step. */\nexport type TraceStep = { scope: string; state: string; status: Exclude<NodeStatus, 'current'>; next: string | null }\n\n/** A Map item a step ran in: the Map's name and the item's index from 0. */\nexport type ScopeItem = { map: string; index: number }\n\n/** The Map items of a step's scope, outermost first: `Each.3[0]` is item 0 of the Map `Each`. */\nexport const scopeItems = (scope: string): ScopeItem[] =>\n scope === ''\n ? []\n : scope.split('/').map((part) => {\n const match = /^(.*)\\.\\d+\\[(\\d+)\\]$/.exec(part)\n if (!match) throw new Error(`\"${scope}\" is not a step's scope`)\n return { map: decodeURIComponent(match[1]!), index: Number(match[2]) }\n })\n\n/** The graph's path of the state a step ran in its scope: the Maps it is inside, then its name. */\nexport const statePath = (scope: string, state: string) => [...scopeItems(scope).map((item) => item.map), state].join('/')\n\n// When a state's scopes disagree, such as a Map's items, the mark that most needs a look wins.\nconst weight: Record<NodeStatus, number> = { succeeded: 0, caught: 1, retrying: 2, failed: 3, current: 4 }\n\n/**\n * Each state's mark from the run's steps in the order they ran: how its last step in each scope ended, the worst of them\n * for a Map's items, and while the run goes on, `current` on the state each scope goes on to, or on the first state when\n * nothing ran yet. A block's run marks the states inside its Block, whose path is `within`.\n */\nexport const nodeTraces = (steps: readonly TraceStep[], { inProgress, startAt, within = [] }: { inProgress: boolean; startAt?: string | undefined; within?: readonly string[] }) => {\n const placed = (scope: string, state: string) => [...within, statePath(scope, state)].join('/')\n const counts = new Map<string, number>()\n const lastOfState = new Map<string, TraceStep>()\n const lastOfScope = new Map<string, TraceStep>()\n for (const step of steps) {\n const path = placed(step.scope, step.state)\n counts.set(path, (counts.get(path) ?? 0) + 1)\n lastOfState.set(`${step.scope}\\n${step.state}`, step)\n lastOfScope.set(step.scope, step)\n }\n const statuses = new Map<string, NodeStatus>()\n const mark = (path: string, status: NodeStatus) => {\n const known = statuses.get(path)\n if (known === undefined || weight[status] > weight[known]) statuses.set(path, status)\n }\n for (const step of lastOfState.values()) mark(placed(step.scope, step.state), step.status)\n if (inProgress) {\n if (!lastOfScope.has('') && startAt) mark([...within, startAt].join('/'), 'current')\n for (const step of lastOfScope.values()) if (step.status !== 'retrying' && step.next !== null) mark(placed(step.scope, step.next), 'current')\n }\n return new Map<string, NodeTrace>([...statuses].map(([path, status]) => [path, { status, steps: counts.get(path) ?? 0 }]))\n}\n","import { messages } from '../../../locale/messages'\n\nexport const text = messages('app/field-types/workflow-run')\n","import type { ReactNode } from 'react'\nimport { customStepOf, heldBackLog } from '@protobase/workflows'\nimport { formatDateTime } from '../../../format/date'\nimport { formatTag } from '../../../locale/active-locale'\nimport { cn } from '../../../lib/cn'\nimport { Badge } from '../../../primitives/badge'\nimport { buttonClass } from '../../../primitives/button'\nimport { useAdminMeta } from '../../meta-gate'\nimport { AppLink } from '../../use-app-address'\nimport { JsonBlock } from '../json/json-block'\nimport { nodeStatusLabel } from '../workflow/labels'\nimport { nodeTones, type NodeStatus } from '../workflow/node-trace'\nimport { scopeItems } from './run-trace'\nimport { text } from './messages'\n\n/** A step as the run's page shows it from the run's trace, keyed by its scope and number. */\nexport type StepRow = Record<string, unknown> & { id: string; scope: string; state: string; next: string | null; attempt: number; status: Exclude<NodeStatus, 'current'>; started_at: string; finished_at: string; logs: { at: string; message: string }[] | null }\n\n/** What can be done with a step's input or output where it shows, such as using it as a new run's input. */\nexport type ValueActions = (value: unknown, part: 'input' | 'output') => ReactNode\n\nexport const Part = ({ title, children }: { title: string; children: ReactNode }) => (\n <div className=\"grid gap-1\">\n <h5 className=\"text-xs font-medium text-muted-foreground\">{title}</h5>\n {children}\n </div>\n)\n\n\n// A log line's time to the second, on the viewer's clock: a step's lines are often within the same minute\nconst logTime = (at: string) => new Intl.DateTimeFormat(formatTag(), { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).format(Date.parse(at))\n\nconst Logs = ({ logs }: { logs: NonNullable<StepRow['logs']> }) => (\n <ol className=\"grid gap-0.5 rounded-md bg-muted/60 px-3 py-2 font-mono text-xs\">\n {logs.map((line, index) => (\n <li key={index} className=\"whitespace-pre-wrap break-words\">\n <time dateTime={line.at} className=\"text-muted-foreground\">{logTime(line.at)}</time> {line.message}\n </li>\n ))}\n </ol>\n)\n\n/** The resource of custom steps' jobs, which a custom step's step links to. */\nexport const jobsResource = 'workflow_custom_step_jobs'\n\n/**\n * One step of a run: its try, item, status and timing, then its error, input, output, variables and logs, as the run's\n * trace keeps them, secrets blanked out. A step a replay did not send says so, a Block's step links to the block's\n * own run, which gave its result, and a custom step's step to the run's jobs, with the logs its container wrote, for\n * whoever may read them.\n */\nexport const StepCard = ({ step, runId, valueActions }: { step: StepRow; runId: string; valueActions?: ValueActions }) => {\n const meta = useAdminMeta()\n const jobs = typeof step.type === 'string' && customStepOf(step.type) !== undefined && meta.resources[jobsResource] !== undefined && meta.permissions[jobsResource]?.read !== false\n const heldBack = step.logs?.some((line) => line.message === heldBackLog) ?? false\n const items = scopeItems(step.scope)\n const output = step.output !== undefined && step.output !== null && <Part title={text('output')}><JsonBlock value={step.output} />{valueActions?.(step.output, 'output')}</Part>\n return (\n <article aria-label={text('stepTry', { attempt: step.attempt })} className=\"grid gap-3 rounded-lg border bg-background p-3\">\n <header className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-body\">\n <span className=\"font-medium text-foreground\">{text('stepTry', { attempt: step.attempt })}</span>\n {items.map((item, index) => (\n <span key={index} className=\"text-muted-foreground\">\n {text('itemOf', { index: item.index + 1, map: item.map })}\n </span>\n ))}\n <Badge tone={nodeTones[step.status]}>{nodeStatusLabel(step.status)}</Badge>\n {heldBack && <Badge tone=\"violet\">{text('notSent')}</Badge>}\n {step.reused === true && <Badge tone=\"blue\">{text('reused')}</Badge>}\n {step.joined === true && <Badge tone=\"blue\">{text('joined')}</Badge>}\n <time dateTime={step.started_at} className=\"text-muted-foreground\">{formatDateTime(Date.parse(step.started_at))}</time>\n <span className=\"tabular-nums text-muted-foreground\">{text('duration', { ms: Number(step.duration_ms ?? 0) })}</span>\n </header>\n {step.error != null && (\n <Part title={text('error')}>\n <p className=\"text-body text-danger-text\">\n <span className=\"font-mono\">{String(step.error)}</span>\n {step.cause != null && <span>: {String(step.cause)}</span>}\n </p>\n </Part>\n )}\n {typeof step.run === 'string' && (\n <div className=\"grid gap-1\">\n {step.reused === true && <p className=\"text-body text-muted-foreground\">{text('reusedResult')}</p>}\n {step.joined === true && <p className=\"text-body text-muted-foreground\">{text('joinedResult')}</p>}\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: step.run }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {step.reused === true ? text('openEarlierBlockRun') : text('openBlockRun')}\n </AppLink>\n </div>\n )}\n {jobs && (\n <AppLink to={{ kind: 'list', resource: jobsResource, filter: `run_id = \"${runId}\"` }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {text('openJobs')}\n </AppLink>\n )}\n {step.status !== 'failed' && output}\n {step.input !== undefined && step.input !== null && <Part title={text('input')}><JsonBlock value={step.input} />{valueActions?.(step.input, 'input')}</Part>}\n {step.status === 'failed' && output}\n {step.assigned != null && <Part title={text('variables')}><JsonBlock value={step.assigned} /></Part>}\n {step.logs && step.logs.length > 0 && <Part title={text('logs')}><Logs logs={step.logs} /></Part>}\n </article>\n )\n}\n","import type { WorkflowTypeList } from '@protobase/client'\nimport type { Definition } from '@protobase/workflows'\nimport { useState } from 'react'\nimport { Button, buttonClass } from '../../../primitives/button'\nimport { AppLink } from '../../use-app-address'\nimport { splitPath, stateAt, triggerId } from '../workflow/definition'\nimport { stateLabel, triggerLabel } from '../workflow/labels'\nimport { JsonBlock } from '../json/json-block'\nimport { Part, StepCard, type ValueActions } from './step-card'\nimport { text } from './messages'\nimport { useRunSteps } from './use-run-steps'\n\n/** How many of a state's steps show at first, and with each Show more. */\nexport const stepPageSize = 20\n\n/** The run whose steps a panel shows. */\nexport type StepsRun = Record<string, unknown> & { id: string; created_at: string }\n\nconst Heading = ({ kind, name }: { kind: string; name: string }) => (\n <div>\n <div className=\"text-xs text-muted-foreground\">{kind}</div>\n <h4 className=\"truncate font-semibold text-foreground\">{name}</h4>\n </div>\n)\n\n/**\n * The steps a state took in the run, every try and item, in the order they ran: the trace the graph read, so no second\n * read. A state inside a Block, which `block` names, ran in the block's own run: the way there instead.\n */\nexport const StateSteps = ({ run, name, block, valueActions }: { run: StepsRun; name: string; block?: string; valueActions?: ValueActions }) => {\n const trace = useRunSteps(run.id, false)\n const [shown, setShown] = useState(stepPageSize)\n if (trace.isPending) return null\n const steps = (trace.data ?? []).filter((step) => step.state === name)\n const blockRun = block === undefined ? undefined : (trace.data ?? []).filter((step) => step.state === block && typeof step.run === 'string').at(-1)?.run\n if (steps.length === 0 && typeof blockRun === 'string') {\n return (\n <div className=\"grid gap-2 text-body text-muted-foreground\">\n <p>{text('ranInBlockRun', { block: block! })}</p>\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: blockRun }} className={buttonClass({ size: 'sm' }) + ' justify-self-start'}>\n {text('openBlockRun')}\n </AppLink>\n </div>\n )\n }\n if (steps.length === 0) return <p className=\"text-body text-muted-foreground\">{text('notRun')}</p>\n return (\n <div className=\"grid gap-3\">\n {steps.slice(0, shown).map((step) => (\n <StepCard key={String(step.id)} step={step} runId={run.id} {...(valueActions && { valueActions })} />\n ))}\n {steps.length > shown && (\n <Button size=\"sm\" className=\"justify-self-start\" onClick={() => setShown(shown + stepPageSize)}>\n {text('showMore')}\n </Button>\n )}\n </div>\n )\n}\n\n/**\n * What the chosen node did in the run, in the side panel: the trigger's input, or each step of the state with its input,\n * output, logs, timing, try and error.\n */\nexport const StepPanel = ({ definition, run, selected, types }: { definition: Definition; run: StepsRun; selected: string; types?: WorkflowTypeList }) => {\n const state = selected === triggerId ? undefined : stateAt(definition, selected)\n return (\n <section aria-label={text('chosenStep')} className=\"grid gap-3 rounded-lg border bg-surface p-4\">\n {state ? (\n <>\n <Heading kind={stateLabel(state, types)} name={splitPath(selected).name} />\n <StateSteps run={run} name={splitPath(selected).name} />\n </>\n ) : (\n <>\n <Heading kind={text('trigger')} name={triggerLabel(definition.trigger, types)} />\n <Part title={text('runInput')}>\n <JsonBlock value={run.input ?? null} />\n </Part>\n </>\n )}\n </section>\n )\n}\n"],"mappings":"gmCASa2B,EAAc,GACzBC,IAAU,GACN,CAAC,EACDA,EAAM,MAAM,GAAG,CAAC,CAAC,IAAK,GAAS,CAC7B,IAAMC,EAAQ,uBAAuB,KAAKC,CAAI,EAC9C,GAAI,CAACD,EAAO,MAAU,MAAM,IAAID,EAAM,wBAAwB,EAC9D,MAAO,CAAE,IAAK,mBAAmBC,EAAM,EAAG,EAAG,MAAO,OAAOA,EAAM,EAAE,CAAE,CACvE,CAAC,EAGME,GAAa,EAAe,IAAkB,CAAC,GAAGJ,EAAWC,CAAK,CAAC,CAAC,IAAK,GAASI,EAAK,GAAG,EAAGC,CAAK,CAAC,CAAC,KAAK,GAAG,EAGnHC,EAAqC,CAAE,UAAW,EAAG,OAAQ,EAAG,SAAU,EAAG,OAAQ,EAAG,QAAS,CAAE,EAO5FC,GAAc,EAA6B,CAAE,aAAY,UAAS,SAAS,CAAC,KAA2F,CAClL,IAAMC,GAAU,EAAe,IAAkB,CAAC,GAAGC,EAAQN,EAAUH,EAAOK,CAAK,CAAC,CAAC,CAAC,KAAK,GAAG,EACxFK,EAAS,IAAI,IACbC,EAAc,IAAI,IAClBC,EAAc,IAAI,IACxB,IAAK,I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ACsB,EAAD,CAAiB,MAAK,KAAMtD,EAAU8D,CAAQ,CAAC,CAAC,IAAO,CAAA,CACvD,CAAA,CAAA,GAEF,EAAA9B,EAAA,KAAA,CAAAlD,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAkD,EAAA,IAAA,CAACmB,EAAD,CAAS,KAAMpB,EAAK,SAAS,EAAG,KAAM7B,EAAa6D,EAAW,QAASC,CAAK,CAAI,CAAA,GAChF,EAAAhC,EAAA,IAAA,CAACC,EAAD,CAAM,MAAOF,EAAK,UAAU,EAC1B,UAAA,EAAAC,EAAA,IAAA,CAACtC,EAAD,CAAW,MAAO8D,EAAI,OAAS,IAAO,CAAA,CAClC,CAAA,CACN,CAAA,CAAA,CAEG,CAAA,CAEb","debugId":"99d74e81-2b3b-4ee4-873f-3a44fcb1d31d"}
|
|
1
|
+
{"version":3,"file":"step-panel-DlWb3DTs.js","names":["useState","_Fragment","n","a","t","__toESM","require_react","require_jsx_runtime","useAdminMeta","AppLink","Button","buttonClass","useRunSteps","JsonBlock","formatDateTime","messages","formatTag","cn","stateAt","splitPath","nodeStatusLabel","triggerLabel","nodeTones","stateLabel","Badge","customStepOf","import_react","scopeItems","scope","match","part","statePath","item","state","weight","nodeTraces","placed","within","counts","lastOfState","lastOfScope","step","steps","path","statuses","mark","known","status","inProgress","startAt","text","import_jsx_runtime","Part","title","children","logTime","at","Logs","logs","line","index","StepCard","meta","jobs","\"workflow_custom_step_jobs\"","heldBack","items","output","valueActions","runId","Heading","kind","name","StateSteps","trace","run","shown","setShown","blockRun","block","StepPanel","selected","definition","types"],"sources":["../../../src/app/field-types/workflow-run/run-trace.ts","../../../src/app/field-types/workflow-run/messages.ts","../../../src/app/field-types/workflow-run/step-card.tsx","../../../src/app/field-types/workflow-run/step-panel.tsx"],"sourcesContent":["import type { NodeStatus, NodeTrace } from '../workflow/node-trace'\n\n/** What the graph reads of a run's step. */\nexport type TraceStep = { scope: string; state: string; status: Exclude<NodeStatus, 'current'>; next: string | null }\n\n/** A Map item a step ran in: the Map's name and the item's index from 0. */\nexport type ScopeItem = { map: string; index: number }\n\n/** The Map items of a step's scope, outermost first: `Each.3[0]` is item 0 of the Map `Each`. */\nexport const scopeItems = (scope: string): ScopeItem[] =>\n scope === ''\n ? []\n : scope.split('/').map((part) => {\n const match = /^(.*)\\.\\d+\\[(\\d+)\\]$/.exec(part)\n if (!match) throw new Error(`\"${scope}\" is not a step's scope`)\n return { map: decodeURIComponent(match[1]!), index: Number(match[2]) }\n })\n\n/** The graph's path of the state a step ran in its scope: the Maps it is inside, then its name. */\nexport const statePath = (scope: string, state: string) => [...scopeItems(scope).map((item) => item.map), state].join('/')\n\n// When a state's scopes disagree, such as a Map's items, the mark that most needs a look wins.\nconst weight: Record<NodeStatus, number> = { succeeded: 0, caught: 1, retrying: 2, failed: 3, current: 4 }\n\n/**\n * Each state's mark from the run's steps in the order they ran: how its last step in each scope ended, the worst of them\n * for a Map's items, and while the run goes on, `current` on the state each scope goes on to, or on the first state when\n * nothing ran yet. A block's run marks the states inside its Block, whose path is `within`.\n */\nexport const nodeTraces = (steps: readonly TraceStep[], { inProgress, startAt, within = [] }: { inProgress: boolean; startAt?: string | undefined; within?: readonly string[] }) => {\n const placed = (scope: string, state: string) => [...within, statePath(scope, state)].join('/')\n const counts = new Map<string, number>()\n const lastOfState = new Map<string, TraceStep>()\n const lastOfScope = new Map<string, TraceStep>()\n for (const step of steps) {\n const path = placed(step.scope, step.state)\n counts.set(path, (counts.get(path) ?? 0) + 1)\n lastOfState.set(`${step.scope}\\n${step.state}`, step)\n lastOfScope.set(step.scope, step)\n }\n const statuses = new Map<string, NodeStatus>()\n const mark = (path: string, status: NodeStatus) => {\n const known = statuses.get(path)\n if (known === undefined || weight[status] > weight[known]) statuses.set(path, status)\n }\n for (const step of lastOfState.values()) mark(placed(step.scope, step.state), step.status)\n if (inProgress) {\n if (!lastOfScope.has('') && startAt) mark([...within, startAt].join('/'), 'current')\n for (const step of lastOfScope.values()) if (step.status !== 'retrying' && step.next !== null) mark(placed(step.scope, step.next), 'current')\n }\n return new Map<string, NodeTrace>([...statuses].map(([path, status]) => [path, { status, steps: counts.get(path) ?? 0 }]))\n}\n","import { messages } from '../../../locale/messages'\n\nexport const text = messages('app/field-types/workflow-run')\n","import type { ReactNode } from 'react'\nimport { customStepOf, heldBackLog } from '@protobase/workflows'\nimport { formatDateTime } from '../../../format/date'\nimport { formatTag } from '../../../locale/active-locale'\nimport { cn } from '../../../lib/cn'\nimport { Badge } from '../../../primitives/badge'\nimport { buttonClass } from '../../../primitives/button'\nimport { useAdminMeta } from '../../meta-gate'\nimport { AppLink } from '../../use-app-address'\nimport { JsonBlock } from '../json/json-block'\nimport { nodeStatusLabel } from '../workflow/labels'\nimport { nodeTones, type NodeStatus } from '../workflow/node-trace'\nimport { scopeItems } from './run-trace'\nimport { text } from './messages'\n\n/** A step as the run's page shows it from the run's trace, keyed by its scope and number. */\nexport type StepRow = Record<string, unknown> & { id: string; scope: string; state: string; next: string | null; attempt: number; status: Exclude<NodeStatus, 'current'>; started_at: string; finished_at: string; logs: { at: string; message: string }[] | null }\n\n/** What can be done with a step's input or output where it shows, such as using it as a new run's input. */\nexport type ValueActions = (value: unknown, part: 'input' | 'output') => ReactNode\n\nexport const Part = ({ title, children }: { title: string; children: ReactNode }) => (\n <div className=\"grid gap-1\">\n <h5 className=\"text-xs font-medium text-muted-foreground\">{title}</h5>\n {children}\n </div>\n)\n\n\n// A log line's time to the second, on the viewer's clock: a step's lines are often within the same minute\nconst logTime = (at: string) => new Intl.DateTimeFormat(formatTag(), { hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false }).format(Date.parse(at))\n\nconst Logs = ({ logs }: { logs: NonNullable<StepRow['logs']> }) => (\n <ol className=\"grid gap-0.5 rounded-md bg-muted/60 px-3 py-2 font-mono text-xs\">\n {logs.map((line, index) => (\n <li key={index} className=\"whitespace-pre-wrap break-words\">\n <time dateTime={line.at} className=\"text-muted-foreground\">{logTime(line.at)}</time> {line.message}\n </li>\n ))}\n </ol>\n)\n\n/** The resource of custom steps' jobs, which a custom step's step links to. */\nexport const jobsResource = 'workflow_custom_step_jobs'\n\n/**\n * One step of a run: its try, item, status and timing, then its error, input, output, variables and logs, as the run's\n * trace keeps them, secrets blanked out. A step a replay did not send says so, a Block's step links to the block's\n * own run, which gave its result, and a custom step's step to the run's jobs, with the logs its container wrote, for\n * whoever may read them.\n */\nexport const StepCard = ({ step, runId, valueActions }: { step: StepRow; runId: string; valueActions?: ValueActions }) => {\n const meta = useAdminMeta()\n const jobs = typeof step.type === 'string' && customStepOf(step.type) !== undefined && meta.resources[jobsResource] !== undefined && meta.permissions[jobsResource]?.read !== false\n const heldBack = step.logs?.some((line) => line.message === heldBackLog) ?? false\n const items = scopeItems(step.scope)\n const output = step.output !== undefined && step.output !== null && <Part title={text('output')}><JsonBlock value={step.output} />{valueActions?.(step.output, 'output')}</Part>\n return (\n <article aria-label={text('stepTry', { attempt: step.attempt })} className=\"grid gap-3 rounded-lg border bg-background p-3\">\n <header className=\"flex flex-wrap items-center gap-x-3 gap-y-1 text-body\">\n <span className=\"font-medium text-foreground\">{text('stepTry', { attempt: step.attempt })}</span>\n {items.map((item, index) => (\n <span key={index} className=\"text-muted-foreground\">\n {text('itemOf', { index: item.index + 1, map: item.map })}\n </span>\n ))}\n <Badge tone={nodeTones[step.status]}>{nodeStatusLabel(step.status)}</Badge>\n {heldBack && <Badge tone=\"violet\">{text('notSent')}</Badge>}\n {step.reused === true && <Badge tone=\"blue\">{text('reused')}</Badge>}\n {step.joined === true && <Badge tone=\"blue\">{text('joined')}</Badge>}\n <time dateTime={step.started_at} className=\"text-muted-foreground\">{formatDateTime(Date.parse(step.started_at))}</time>\n <span className=\"tabular-nums text-muted-foreground\">{text('duration', { ms: Number(step.duration_ms ?? 0) })}</span>\n </header>\n {step.error != null && (\n <Part title={text('error')}>\n <p className=\"text-body text-danger-text\">\n <span className=\"font-mono\">{String(step.error)}</span>\n {step.cause != null && <span>: {String(step.cause)}</span>}\n </p>\n </Part>\n )}\n {typeof step.run === 'string' && (\n <div className=\"grid gap-1\">\n {step.reused === true && <p className=\"text-body text-muted-foreground\">{text('reusedResult')}</p>}\n {step.joined === true && <p className=\"text-body text-muted-foreground\">{text('joinedResult')}</p>}\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: step.run }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {step.reused === true ? text('openEarlierBlockRun') : text('openBlockRun')}\n </AppLink>\n </div>\n )}\n {jobs && (\n <AppLink to={{ kind: 'list', resource: jobsResource, filter: `run_id = \"${runId}\"` }} className={cn(buttonClass({ size: 'sm' }), 'justify-self-start')}>\n {text('openJobs')}\n </AppLink>\n )}\n {step.status !== 'failed' && output}\n {step.input !== undefined && step.input !== null && <Part title={text('input')}><JsonBlock value={step.input} />{valueActions?.(step.input, 'input')}</Part>}\n {step.status === 'failed' && output}\n {step.assigned != null && <Part title={text('variables')}><JsonBlock value={step.assigned} /></Part>}\n {step.logs && step.logs.length > 0 && <Part title={text('logs')}><Logs logs={step.logs} /></Part>}\n </article>\n )\n}\n","import type { WorkflowTypeList } from '@protobase/client'\nimport type { Definition } from '@protobase/workflows'\nimport { useState } from 'react'\nimport { Button, buttonClass } from '../../../primitives/button'\nimport { AppLink } from '../../use-app-address'\nimport { splitPath, stateAt, triggerId } from '../workflow/definition'\nimport { stateLabel, triggerLabel } from '../workflow/labels'\nimport { JsonBlock } from '../json/json-block'\nimport { Part, StepCard, type ValueActions } from './step-card'\nimport { text } from './messages'\nimport { useRunSteps } from './use-run-steps'\n\n/** How many of a state's steps show at first, and with each Show more. */\nexport const stepPageSize = 20\n\n/** The run whose steps a panel shows. */\nexport type StepsRun = Record<string, unknown> & { id: string; created_at: string }\n\nconst Heading = ({ kind, name }: { kind: string; name: string }) => (\n <div>\n <div className=\"text-xs text-muted-foreground\">{kind}</div>\n <h4 className=\"truncate font-semibold text-foreground\">{name}</h4>\n </div>\n)\n\n/**\n * The steps a state took in the run, every try and item, in the order they ran: the trace the graph read, so no second\n * read. A state inside a Block, which `block` names, ran in the block's own run: the way there instead.\n */\nexport const StateSteps = ({ run, name, block, valueActions }: { run: StepsRun; name: string; block?: string; valueActions?: ValueActions }) => {\n const trace = useRunSteps(run.id, false)\n const [shown, setShown] = useState(stepPageSize)\n if (trace.isPending) return null\n const steps = (trace.data ?? []).filter((step) => step.state === name)\n const blockRun = block === undefined ? undefined : (trace.data ?? []).filter((step) => step.state === block && typeof step.run === 'string').at(-1)?.run\n if (steps.length === 0 && typeof blockRun === 'string') {\n return (\n <div className=\"grid gap-2 text-body text-muted-foreground\">\n <p>{text('ranInBlockRun', { block: block! })}</p>\n <AppLink to={{ kind: 'record', resource: 'workflow_runs', key: blockRun }} className={buttonClass({ size: 'sm' }) + ' justify-self-start'}>\n {text('openBlockRun')}\n </AppLink>\n </div>\n )\n }\n if (steps.length === 0) return <p className=\"text-body text-muted-foreground\">{text('notRun')}</p>\n return (\n <div className=\"grid gap-3\">\n {steps.slice(0, shown).map((step) => (\n <StepCard key={String(step.id)} step={step} runId={run.id} {...(valueActions && { valueActions })} />\n ))}\n {steps.length > shown && (\n <Button size=\"sm\" className=\"justify-self-start\" onClick={() => setShown(shown + stepPageSize)}>\n {text('showMore')}\n </Button>\n )}\n </div>\n )\n}\n\n/**\n * What the chosen node did in the run, in the side panel: the trigger's input, or each step of the state with its input,\n * output, logs, timing, try and error.\n */\nexport const StepPanel = ({ definition, run, selected, types }: { definition: Definition; run: StepsRun; selected: string; types?: WorkflowTypeList }) => {\n const state = selected === triggerId ? undefined : stateAt(definition, selected)\n return (\n <section aria-label={text('chosenStep')} className=\"grid gap-3 rounded-lg border bg-surface p-4\">\n {state ? (\n <>\n <Heading kind={stateLabel(state, types)} name={splitPath(selected).name} />\n <StateSteps run={run} name={splitPath(selected).name} />\n </>\n ) : (\n <>\n <Heading kind={text('trigger')} name={triggerLabel(definition.trigger, types)} />\n <Part title={text('runInput')}>\n <JsonBlock value={run.input ?? null} />\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debugId":"e559bdc3-4ec6-46a6-b485-ba3e88509d74"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-sibling-page-BFxjcXYB.js","names":["useState","useCallback","useRef","useMemo","useMemo","n","a","t","__toESM","require_react","require_jsx_runtime","useQueries","useQuery","useResourceClient","fileNamed","useViewedResource","cn","import_react","ofDocument","state","nonce","initial","useDocumentState","setState","update","next","linkAttribute","frameBridge","frameSandbox","frameCsp","scripts","frameNonce","byte","removed","frameDocument","page","html","element","policy","referrer","bridge","rounding","nextFrameHeight","previous","viewport","height","frameBox","size","maxHeight","frameMessage","frame","event","data","links","import_jsx_runtime","noLinks","scrollToPlace","bars","top","HtmlFrame","shown","setHeight","shownAgain","setShownAgain","key","loads","receive","message","onLink","loaded","times","box","className","climbs","value","siblingReference","reference","unescaped","decoded","siblings","error","rewriteSrcset","parts","candidate","resolved","resolve","rewriteCssUrls","text","whole","externalUrl","url","sources","rewriteResources","set","attribute","resource","parse","referencedSiblings","found","sibling","siblingPage","contents","link","href","target","address","siblingsKey","FileReadError","status","useFileText","client","file","response","dataUrl","reader","reject","bytes","useSiblingContents","reads","files","read","index","useSiblingPage","siblingKey","contentsKey","ready"],"sources":["../../../src/app/file-viewers/document-state.ts","../../../src/app/file-viewers/frame-bridge.ts","../../../src/app/file-viewers/frame-policy.ts","../../../src/app/file-viewers/frame-document.ts","../../../src/app/file-viewers/frame-height.ts","../../../src/app/file-viewers/frame-messages.ts","../../../src/app/file-viewers/html-frame.tsx","../../../src/app/file-viewers/sibling-references.ts","../../../src/app/file-viewers/sibling-page.ts","../../../src/app/file-viewers/siblings-key.ts","../../../src/app/file-viewers/use-file-text.ts","../../../src/app/file-viewers/use-sibling-contents.ts","../../../src/app/file-viewers/use-sibling-page.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\n\n/** A value of an `HtmlFrame` that belongs to the document it shows, by that document's `nonce`. */\nexport type DocumentState<T> = { nonce: string; value: T }\n\n/** `state`'s value for the document `nonce`; `initial` for another document, which starts again. */\nexport const ofDocument = <T>(state: DocumentState<T> | undefined, nonce: string, initial: T) => (state?.nonce === nonce ? state.value : initial)\n\n/** State that starts again at `initial` (a constant) each time the frame shows another document, `nonce`. */\nexport const useDocumentState = <T>(nonce: string, initial: T) => {\n const [state, setState] = useState<DocumentState<T>>()\n const update = useCallback((next: (value: T) => T) => setState((state) => ({ nonce, value: next(ofDocument(state, nonce, initial)) })), [nonce, initial])\n return [ofDocument(state, nonce, initial), update] as const\n}\n","/** The attribute an `HtmlFrame` page's link carries, the index of its target in the frame's `links`. */\nexport const linkAttribute = 'data-protobase-link'\n\n/**\n * The script an `HtmlFrame` runs in its page, the only one a page it does not trust runs. A click on a link carrying\n * `linkAttribute` posts its index to the app, with whether it asks for a new tab. A click on a link to a place on the\n * page (`#results`) moves the focus there and posts how far down the page it is, since the app's page scrolls rather\n * than the frame. A\n * click on any other link does nothing, so the page never leaves the frame. It also posts the page's height, so the\n * frame grows with it.\n */\nexport const frameBridge = `(() => {\n const post = (message) => parent.postMessage({ protobase: 'html-frame', ...message }, '*')\n const place = (hash) => {\n const name = decodeURIComponent(hash.slice(1))\n const target = name === '' || name === 'top' ? null : document.getElementById(name) ?? document.getElementsByName(name)[0]\n if (!target) return 0\n if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) target.setAttribute('tabindex', '-1')\n target.focus({ preventScroll: true })\n return target.getBoundingClientRect().top + window.scrollY\n }\n const follow = (event) => {\n const link = event.target instanceof Element ? event.target.closest('a, area') : null\n if (!link) return\n event.preventDefault()\n const index = link.getAttribute('${linkAttribute}')\n const href = link.getAttribute('href') ?? ''\n if (index !== null) post({ link: Number(index), newTab: event.button === 1 || event.ctrlKey || event.metaKey || event.shiftKey })\n else if (href.startsWith('#') && event.button === 0) post({ scroll: place(href) })\n }\n document.addEventListener('click', follow, true)\n document.addEventListener('auxclick', (event) => event.button === 1 && follow(event), true)\n const height = () => post({ height: document.documentElement.getBoundingClientRect().height })\n new ResizeObserver(height).observe(document.documentElement)\n})()`\n","/**\n * What an `HtmlFrame`'s page may run: `'bridge'`, only the frame's own link script, for a page it does not trust, such\n * as an uploaded file; `'trusted-page'`, also the page's own inline scripts, for a page an app generates itself.\n */\nexport type FrameScripts = 'bridge' | 'trusted-page'\n\n/**\n * The frame's sandbox: scripts, so the link script runs, and nothing else. Never `allow-same-origin`, so the page has an\n * opaque origin and cannot reach the app's cookies, storage or DOM; no top navigation, forms or popups.\n */\nexport const frameSandbox = 'allow-scripts'\n\n/**\n * The page's Content-Security-Policy. With `'bridge'` only the script carrying `nonce` runs: the page's own scripts,\n * inline handlers and `javascript:` links do not. `'trusted-page'` runs inline scripts and so carries no nonce, which\n * would turn `'unsafe-inline'` off. Either way nothing loads from the network: images, media, styles and fonts come\n * from `data:` URLs, and nothing is fetched, framed or submitted.\n */\nexport const frameCsp = (scripts: FrameScripts, nonce: string) =>\n [\n \"default-src 'none'\",\n scripts === 'bridge' ? `script-src 'nonce-${nonce}'` : \"script-src 'unsafe-inline'\",\n 'img-src data:',\n 'media-src data:',\n \"style-src 'unsafe-inline' data:\",\n 'font-src data:',\n \"base-uri 'none'\",\n \"form-action 'none'\",\n ].join('; ')\n\n/** A fresh 128-bit nonce, as hex. */\nexport const frameNonce = () => Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, '0')).join('')\n","import { frameBridge } from './frame-bridge'\nimport { frameCsp, type FrameScripts } from './frame-policy'\n\n// What a page could use to leave its policy or the frame: its own `http-equiv` (a refresh, another policy), a `<base>`,\n// and `<noscript>`, read as markup here but as text in the frame, where scripts run, so markup hidden in it would come\n// out after these were removed.\nconst removed = 'meta[http-equiv], base, noscript'\n\n/**\n * `html` as the page an `HtmlFrame` shows: parsed, cleared of `removed`, and opened with the frame's own policy, a\n * referrer policy that sends no address on, and the frame's link script carrying `nonce`. They are the first nodes of\n * `<head>`, put there in the parsed document, so the policy covers everything of the page, even a script written before\n * its `<html>`.\n */\nexport const frameDocument = (html: string, scripts: FrameScripts, nonce: string) => {\n const page = new DOMParser().parseFromString(html, 'text/html')\n for (const element of page.querySelectorAll(removed)) element.remove()\n\n const policy = page.createElement('meta')\n policy.httpEquiv = 'Content-Security-Policy'\n policy.content = frameCsp(scripts, nonce)\n const referrer = page.createElement('meta')\n referrer.name = 'referrer'\n referrer.content = 'no-referrer'\n const bridge = page.createElement('script')\n if (scripts === 'bridge') bridge.setAttribute('nonce', nonce)\n bridge.textContent = frameBridge\n page.head.prepend(policy, referrer, bridge)\n\n return `<!doctype html>${page.documentElement.outerHTML}`\n}\n","/**\n * How tall an `HtmlFrame` is for its page: `measured`, the height its page last reported, with the frame's own height\n * when it did, or `fixed`, for a page sized by the frame's viewport, such as one `100vh` tall or `height: 100%` with a\n * margin, which reports a taller page each time the frame takes its last height.\n */\nexport type FrameHeight = { kind: 'measured'; height: number; viewport: number } | { kind: 'fixed' }\n\n// Reported heights are rounded up to whole pixels.\nconst rounding = 1\n\n/**\n * The frame's height after its page reports `height` while the frame is `viewport` tall. A page whose height changed by\n * as much as the frame did since its last report is sized by the frame, and the frame stays fixed for it.\n */\nexport const nextFrameHeight = (previous: FrameHeight | undefined, height: number, viewport: number): FrameHeight => {\n if (previous?.kind === 'fixed') return previous\n if (previous && viewport !== previous.viewport && Math.abs(height - previous.height - (viewport - previous.viewport)) <= rounding) return { kind: 'fixed' }\n return { kind: 'measured', height, viewport }\n}\n\n/**\n * The frame's box: as tall as its page's measured height, or a fixed minimum while nothing is measured, for a page\n * measured 0 tall, and for a page sized by the frame. That page scrolls inside the frame, the one inner scroll box here:\n * the app's page cannot scroll content whose height depends on the frame's own.\n */\nexport const frameBox = (size: FrameHeight | undefined) =>\n size?.kind === 'measured' && size.height > 0 ? { style: { height: size.height } } : { className: 'min-h-[60vh]' }\n","/**\n * What an `HtmlFrame`'s page asks of the app: follow its link `index`, be as tall as `height` CSS pixels, or scroll to\n * the place `top` CSS pixels down the page.\n */\nexport type FrameMessage = { kind: 'link'; index: number; newTab: boolean } | { kind: 'height'; height: number } | { kind: 'scroll'; top: number }\n\n// Tall enough for a long report, short enough that a page cannot make the app's page endless.\nconst maxHeight = 100_000\n\n/**\n * The request a message event carries from the frame's own window `frame`, with a link index below `links`; `undefined`\n * for any other source or shape. Every sandboxed page's origin is `\"null\"`, so only the window itself tells them apart.\n */\nexport const frameMessage = (event: Pick<MessageEvent, 'source' | 'data'>, frame: Window | null | undefined, links: number): FrameMessage | undefined => {\n if (!frame || event.source !== frame) return\n const data: unknown = event.data\n if (typeof data !== 'object' || data === null || !('protobase' in data) || data.protobase !== 'html-frame') return\n if ('link' in data && Number.isInteger(data.link) && (data.link as number) >= 0 && (data.link as number) < links) {\n return { kind: 'link', index: data.link as number, newTab: 'newTab' in data && data.newTab === true }\n }\n if ('height' in data && typeof data.height === 'number' && Number.isFinite(data.height) && data.height >= 0) {\n return { kind: 'height', height: Math.min(Math.ceil(data.height), maxHeight) }\n }\n if ('scroll' in data && typeof data.scroll === 'number' && Number.isFinite(data.scroll)) {\n return { kind: 'scroll', top: Math.min(Math.max(Math.round(data.scroll), 0), maxHeight) }\n }\n return\n}\n","import { useEffect, useMemo, useRef } from 'react'\nimport { cn } from '../../lib/cn'\nimport { useDocumentState } from './document-state'\nimport type { ViewedFile } from './file-viewer'\nimport { frameDocument } from './frame-document'\nimport { frameBox, nextFrameHeight, type FrameHeight } from './frame-height'\nimport { frameMessage } from './frame-messages'\nimport { frameNonce, frameSandbox, type FrameScripts } from './frame-policy'\nimport type { FrameLink } from './sibling-page'\n\nconst noLinks: readonly never[] = []\n\n// Scrolls the app's page to the place `top` pixels down the page in `frame`, below the bars that stay at the top.\nconst scrollToPlace = (frame: HTMLIFrameElement, top: number) => {\n const bars = Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0\n window.scrollTo({ top: frame.getBoundingClientRect().top + window.scrollY + top - bars })\n}\n\ntype HtmlFrameProps<File extends ViewedFile> = {\n /** The page, a whole HTML document or a fragment. */\n html: string\n /** The frame's accessible name, such as the file's name. */\n title: string\n /** The targets of the page's links, by the index each carries (`useSiblingPage`). */\n links?: readonly FrameLink<File>[]\n /** Follows a link of the page; `newTab` when it was a middle or modified click. */\n onLink?: (link: FrameLink<File>, options: { newTab: boolean }) => void\n /**\n * `'bridge'` (the default) runs none of the page's own scripts, for a page you do not trust, such as an uploaded file;\n * `'trusted-page'` runs them, for a page your viewer generates itself. Either way the page cannot reach the app.\n */\n scripts?: FrameScripts\n className?: string\n}\n\n/**\n * A whole HTML page drawn in a sandboxed frame with an opaque origin: it cannot read the app's cookies, storage or DOM,\n * call its API as the user, load anything from the network or navigate the app's window. Its links reach the app only\n * as the index of one of `links`, which `onLink` follows. The frame is as tall as its page, so the app's page scrolls,\n * unless the page is sized by the frame (`FrameHeight`).\n */\nexport const HtmlFrame = <File extends ViewedFile>({ html, title, links = noLinks, onLink, scripts = 'bridge', className }: HtmlFrameProps<File>) => {\n const frame = useRef<HTMLIFrameElement>(null)\n const shown = useMemo(() => {\n const nonce = frameNonce()\n return { nonce, srcDoc: frameDocument(html, scripts, nonce) }\n }, [html, scripts])\n const [height, setHeight] = useDocumentState<FrameHeight | undefined>(shown.nonce, undefined)\n // A page that navigated its frame anyway is shown again once; doing so again leaves the frame empty, until another\n // document is shown.\n const [shownAgain, setShownAgain] = useDocumentState(shown.nonce, 0)\n const key = `${shown.nonce}:${shownAgain}`\n // The loads of the frame shown as `key`: its first is its page, any later one the page leaving it.\n const loads = useRef({ key, count: 0 })\n\n useEffect(() => {\n const receive = (event: MessageEvent) => {\n const message = frameMessage(event, frame.current?.contentWindow, links.length)\n const viewport = frame.current?.clientHeight\n if (message?.kind === 'height' && viewport !== undefined) setHeight((size) => nextFrameHeight(size, message.height, viewport))\n if (message?.kind === 'link') onLink?.(links[message.index]!, { newTab: message.newTab })\n if (message?.kind === 'scroll' && frame.current) scrollToPlace(frame.current, message.top)\n }\n window.addEventListener('message', receive)\n return () => window.removeEventListener('message', receive)\n }, [links, onLink, setHeight])\n\n const loaded = () => {\n if (loads.current.key !== key) loads.current = { key, count: 0 }\n loads.current.count += 1\n if (loads.current.count > 1) setShownAgain((times) => times + 1)\n }\n\n const box = frameBox(height)\n return (\n <iframe\n key={key}\n ref={frame}\n title={title}\n sandbox={frameSandbox}\n referrerPolicy=\"no-referrer\"\n // A video's own fullscreen control; a page that does not run its scripts can ask for nothing else.\n allow={scripts === 'bridge' ? 'fullscreen' : undefined}\n srcDoc={shownAgain > 1 ? '' : shown.srcDoc}\n onLoad={loaded}\n className={cn('block w-full border-0 bg-white', box.className, className)}\n style={box.style}\n />\n )\n}\n","import { fileNamed, type ViewedFile } from './file-viewer'\n\n// Whether a reference's path climbs out of its folder with a `..` segment.\nconst climbs = (value: string) => value.split(/[?#]/, 1)[0]!.split('/').includes('..')\n\n/**\n * The sibling a page's relative reference names, such as `shots/before.png` or `my%20chart.png`, by its file name\n * (`fileNamed`), as written or with its escapes read; none for an absolute or protocol-relative address, a path from\n * the root, a fragment, or a path that climbs out with `..`, written or escaped.\n */\nexport const siblingReference = <File extends ViewedFile>(siblings: readonly File[], reference: string) => {\n const value = reference.trim()\n const unescaped = decoded(value)\n if (climbs(value) || climbs(unescaped)) return\n return fileNamed(siblings, value) ?? fileNamed(siblings, unescaped)\n}\n\n// A reference with its escapes, such as `%20`, read; as it is when one is malformed.\nconst decoded = (value: string) => {\n try {\n return decodeURI(value)\n } catch (error) {\n if (error instanceof URIError) return value\n throw error\n }\n}\n\n/** `value` of a `srcset`, each candidate's address resolved on its own; a candidate `resolve` gives nothing for stays as written. */\nexport const rewriteSrcset = (value: string, resolve: (reference: string) => string | undefined) =>\n value\n .split(',')\n .map((candidate) => {\n const parts = /^(\\s*)(\\S+)([\\s\\S]*)$/.exec(candidate)\n const resolved = parts && resolve(parts[2]!)\n return parts && resolved ? `${parts[1]}${resolved}${parts[3]}` : candidate\n })\n .join(',')\n\n/** CSS `text` with each `url(...)` resolved; one `resolve` gives nothing for stays as written. */\nexport const rewriteCssUrls = (text: string, resolve: (reference: string) => string | undefined) =>\n text.replace(/url\\(\\s*(['\"]?)([^'\")]*)\\1\\s*\\)/gi, (whole, _quote: string, reference: string) => {\n const resolved = resolve(reference.trim())\n return resolved ? `url(\"${resolved}\")` : whole\n })\n\n/** An absolute `http:` or `https:` address as the URL parser reads it, else `undefined`, such as for `javascript:` or a relative path. */\nexport const externalUrl = (reference: string) => {\n if (!URL.canParse(reference)) return\n const url = new URL(reference)\n return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : undefined\n}\n","import type { ViewedFile } from './file-viewer'\nimport { linkAttribute } from './frame-bridge'\nimport { externalUrl, rewriteCssUrls, rewriteSrcset, siblingReference } from './sibling-references'\n\n/** Where a link of a page in an `HtmlFrame` leads: a sibling file, or an outside `http`/`https` address. */\nexport type FrameLink<File extends ViewedFile = ViewedFile> = { kind: 'file'; file: File } | { kind: 'external'; url: string }\n\n/** A page with its references to siblings resolved, and the targets of its links, which carry their index. */\nexport type SiblingPage<File extends ViewedFile = ViewedFile> = { html: string; links: FrameLink<File>[] }\n\n// The attributes that load a file into the page, by the elements they are on.\nconst sources = ['img[src]', 'source[src]', 'video[src]', 'audio[src]', 'track[src]', 'input[src]'].join(', ')\n\n// Each reference of `page` that loads a file, set to what `resource` gives for it; one it gives nothing for stays.\nconst rewriteResources = (page: Document, resource: (reference: string) => string | undefined) => {\n const set = (element: Element, attribute: string, value: string | undefined) => value !== undefined && element.setAttribute(attribute, value)\n for (const element of page.querySelectorAll(sources)) set(element, 'src', resource(element.getAttribute('src')!))\n for (const element of page.querySelectorAll('video[poster]')) set(element, 'poster', resource(element.getAttribute('poster')!))\n for (const element of page.querySelectorAll('img[srcset], source[srcset]')) set(element, 'srcset', rewriteSrcset(element.getAttribute('srcset')!, resource))\n for (const element of page.querySelectorAll('link[href]')) set(element, 'href', resource(element.getAttribute('href')!))\n for (const element of page.querySelectorAll('image[href]')) set(element, 'href', resource(element.getAttribute('href')!))\n for (const element of page.querySelectorAll('[style]')) set(element, 'style', rewriteCssUrls(element.getAttribute('style')!, resource))\n for (const element of page.querySelectorAll('style')) element.textContent = rewriteCssUrls(element.textContent, resource)\n}\n\nconst parse = (html: string) => new DOMParser().parseFromString(html, 'text/html')\n\n/** The siblings `html` loads as images, videos, sounds, styles or fonts, each once: those a page needs read to show. */\nexport const referencedSiblings = <File extends ViewedFile>(html: string, siblings: readonly File[]) => {\n const found = new Set<File>()\n rewriteResources(parse(html), (reference) => {\n const sibling = siblingReference(siblings, reference)\n if (sibling) found.add(sibling)\n return\n })\n return [...found]\n}\n\n/** The address a page's link shows for where it leads, for the browser's link preview and copy link; `undefined` keeps its own. */\nexport type LinkAddress<File extends ViewedFile = ViewedFile> = (link: FrameLink<File>) => string | undefined\n\n/**\n * `html` with each relative reference to a sibling resolved: one that loads a file to the `data:` URL `contents` holds\n * by its stored `uri`, a link to a sibling or to an outside `http`/`https` address to an entry of `links`, showing the\n * address `address` gives it. A reference to no sibling, or to one `contents` lacks, stays as written; a link to\n * anywhere else, such as `javascript:`, loses its address. A link to a place on the page (`#top`) stays.\n */\nexport const siblingPage = <File extends ViewedFile>(html: string, siblings: readonly File[], contents: ReadonlyMap<string, string>, address?: LinkAddress<File>): SiblingPage<File> => {\n const page = parse(html)\n for (const element of page.querySelectorAll(`[${linkAttribute}]`)) element.removeAttribute(linkAttribute)\n rewriteResources(page, (reference) => {\n const sibling = siblingReference(siblings, reference)\n return sibling && contents.get(sibling.uri)\n })\n\n const links: FrameLink<File>[] = []\n for (const link of page.querySelectorAll('a[href], area[href]')) {\n const href = link.getAttribute('href')!\n if (href.startsWith('#')) continue\n link.removeAttribute('target')\n const sibling = siblingReference(siblings, href)\n const url = sibling ? undefined : externalUrl(href)\n if (!sibling && !url) {\n link.removeAttribute('href')\n continue\n }\n const target: FrameLink<File> = sibling ? { kind: 'file', file: sibling } : { kind: 'external', url: url! }\n const shown = address?.(target)\n if (shown !== undefined) link.setAttribute('href', shown)\n link.setAttribute(linkAttribute, String(links.length))\n links.push(target)\n }\n return { html: `<!doctype html>${page.documentElement.outerHTML}`, links }\n}\n","import type { ViewedFile } from './file-viewer'\n\n/**\n * A key that changes when any of `siblings` does: its stored uri, and the record key and file field a sibling carries\n * (`SiblingFile`), which its link's address names. A missing key or field is `null`.\n */\nexport const siblingsKey = <File extends ViewedFile>(siblings: readonly File[]) =>\n JSON.stringify(siblings.map((sibling) => [sibling.uri, 'key' in sibling ? sibling.key : null, 'field' in sibling ? sibling.field : null]))\n","import { useQuery } from '@tanstack/react-query'\nimport { useResourceClient } from '../../data/api-provider'\nimport type { ViewedFile } from './file-viewer'\nimport { useViewedResource } from './viewed-resource'\n\n/** A file that could not be read, with the status its link answered. */\nexport class FileReadError extends Error {\n override name = 'FileReadError'\n constructor(readonly status: number) {\n super(`The file could not be read: its link answered ${status}`)\n }\n}\n\n/**\n * The text of a file a viewer shows, read once and kept while the file is the same: a TanStack Query result keyed by\n * its resource and stored `uri`, as the link changes each time it is signed. Parse JSON from `data` yourself. It reads\n * from the API that serves the record, which sends the bytes itself whatever store holds them or wherever the file's\n * link points, up to 10 MB; a larger file fails with a 403.\n */\nexport const useFileText = (file: ViewedFile) => {\n const resource = useViewedResource()\n const client = useResourceClient(resource)\n return useQuery({\n queryKey: ['file-text', resource, file.uri],\n staleTime: Infinity,\n queryFn: async () => {\n const response = await fetch(client.fileReadUrl(resource, file))\n if (!response.ok) throw new FileReadError(response.status)\n return response.text()\n },\n })\n}\n","import { useQueries } from '@tanstack/react-query'\nimport { useResourceClient } from '../../data/api-provider'\nimport type { ViewedFile } from './file-viewer'\nimport { FileReadError } from './use-file-text'\nimport { useViewedResource } from './viewed-resource'\n\n// The bytes as a `data:` URL of the file's own type: a sandboxed page cannot load the app's `blob:` URLs, and the URL\n// holds the bytes alone, no signed link that would open the file elsewhere.\nconst dataUrl = (bytes: Blob) =>\n new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => resolve(reader.result as string)\n reader.onerror = () => reject(reader.error)\n reader.readAsDataURL(bytes)\n })\n\n/**\n * The contents of `files` as `data:` URLs by their stored `uri`, each read once from the API that serves the viewed\n * record, with the user's own rights, as `useFileText` reads, up to 10 MB each; `ready` once every read has answered. A\n * file that could not be read is left out, so what refers to it stays as written.\n */\nexport const useSiblingContents = (files: readonly ViewedFile[]) => {\n const resource = useViewedResource()\n const client = useResourceClient(resource)\n const reads = useQueries({\n queries: files.map((file) => ({\n queryKey: ['file-data-url', resource, file.uri],\n staleTime: Infinity,\n retry: false,\n queryFn: async () => {\n const response = await fetch(client.fileReadUrl(resource, file))\n if (!response.ok) throw new FileReadError(response.status)\n return dataUrl(new Blob([await response.arrayBuffer()], { type: file.type }))\n },\n })),\n })\n const contents = new Map<string, string>()\n reads.forEach((read, index) => read.data !== undefined && contents.set(files[index]!.uri, read.data))\n return { contents, ready: reads.every((read) => !read.isPending) }\n}\n","import { useMemo } from 'react'\nimport type { ViewedFile } from './file-viewer'\nimport { referencedSiblings, siblingPage, type LinkAddress, type SiblingPage } from './sibling-page'\nimport { siblingsKey } from './siblings-key'\nimport { useSiblingContents } from './use-sibling-contents'\n\n/**\n * `html`, a page a file viewer shows, with its relative references resolved to `siblings` (`siblingPage`), for an\n * `HtmlFrame`: the images, videos and styles it names read as `data:` URLs, its links to siblings and outside addresses\n * in `links`, each showing the address `address` gives it. `undefined` while `html` or those reads are pending. Use it\n * inside a file viewer, which reads them from the API that serves the viewed record.\n */\nexport const useSiblingPage = <File extends ViewedFile>(html: string | undefined, siblings: readonly File[], address?: LinkAddress<File>): SiblingPage<File> | undefined => {\n // A viewer's siblings are a new list each render: their key, and the contents read, say when they changed.\n const siblingKey = siblingsKey(siblings)\n const named = useMemo(() => (html === undefined ? [] : referencedSiblings(html, siblings)), [html, siblingKey])\n const { contents, ready } = useSiblingContents(named)\n const contentsKey = [...contents.keys()].join('\\n')\n return useMemo(() => (html === undefined || !ready ? undefined : siblingPage(html, siblings, contents, address)), [html, siblingKey, ready, contentsKey, address])\n}\n"],"mappings":"2vBAMakB,GAAiB,EAAqC,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AC5B,SAAU,CAAC,gBAAiBxB,EAAUgB,EAAK,GAAG,EAC9C,UAAW,IACX,MAAO,GACP,QAAS,SAAY,CACnB,IAAMC,EAAW,MAAM,MAAMF,EAAO,YAAYf,EAAUgB,CAAI,CAAC,EAC/D,GAAI,CAACC,EAAS,GAAI,MAAM,IAAIL,EAAcK,EAAS,MAAM,EACzD,OAAOC,EAAQ,IAAI,KAAK,CAAC,MAAMD,EAAS,YAAY,CAAC,EAAG,CAAE,KAAMD,EAAK,IAAK,CAAC,CAAC,CAC9E,CACF,EAAE,CACJ,CAAC,EACKV,EAAW,IAAI,IAErB,OADAiB,EAAM,SAAS,EAAM,IAAUE,EAAK,OAAS,IAAA,IAAanB,EAAS,IAAIkB,EAAME,EAAM,CAAE,IAAKD,EAAK,IAAI,CAAC,EAC7F,CAAE,WAAU,MAAOF,EAAM,MAAO,GAAS,CAACE,EAAK,SAAS,CAAE,CACnE,EC3BaE,GAA2C,EAA0B,EAA2B,IAA+D,CAE1K,IAAMC,EAAajB,EAAY3B,CAAQ,EAEjC,CAAE,WAAU,SAAUsC,GADtB,EAAQjH,EAAAA,QAAAA,KAAegC,IAAS,IAAA,GAAY,CAAC,EAAI6D,EAAmB7D,EAAM2C,CAAQ,EAAI,CAAC3C,EAAMuF,CAAU,CAC9D,CAAK,EAC9CC,EAAc,CAAC,GAAGvB,EAAS,KAAK,CAAC,CAAC,CAAC,KAAK;CAAI,EAClD,OAAA,EAAOjG,EAAAA,QAAAA,KAAegC,IAAS,IAAA,IAAa,CAACyF,EAAQ,IAAA,GAAYzB,EAAYhE,EAAM2C,EAAUsB,EAAUI,CAAO,EAAI,CAACrE,EAAMuF,EAAYE,EAAOD,EAAanB,CAAO,CAAC,CACnK","debugId":"45c63717-6019-4146-9c89-3dbade524df6"}
|
|
1
|
+
{"version":3,"file":"use-sibling-page-CLxIRXkS.js","names":["useState","useCallback","useRef","useMemo","useMemo","n","a","t","__toESM","require_react","require_jsx_runtime","useQueries","useQuery","useResourceClient","fileNamed","useViewedResource","cn","import_react","ofDocument","state","nonce","initial","useDocumentState","setState","update","next","linkAttribute","frameBridge","frameSandbox","frameCsp","scripts","frameNonce","byte","removed","frameDocument","page","html","element","policy","referrer","bridge","rounding","nextFrameHeight","previous","viewport","height","frameBox","size","maxHeight","frameMessage","frame","event","data","links","import_jsx_runtime","noLinks","scrollToPlace","bars","top","HtmlFrame","shown","setHeight","shownAgain","setShownAgain","key","loads","receive","message","onLink","loaded","times","box","className","climbs","value","siblingReference","reference","unescaped","decoded","siblings","error","rewriteSrcset","parts","candidate","resolved","resolve","rewriteCssUrls","text","whole","externalUrl","url","sources","rewriteResources","set","attribute","resource","parse","referencedSiblings","found","sibling","siblingPage","contents","link","href","target","address","siblingsKey","FileReadError","status","useFileText","client","file","response","dataUrl","reader","reject","bytes","useSiblingContents","reads","files","read","index","useSiblingPage","siblingKey","contentsKey","ready"],"sources":["../../../src/app/file-viewers/document-state.ts","../../../src/app/file-viewers/frame-bridge.ts","../../../src/app/file-viewers/frame-policy.ts","../../../src/app/file-viewers/frame-document.ts","../../../src/app/file-viewers/frame-height.ts","../../../src/app/file-viewers/frame-messages.ts","../../../src/app/file-viewers/html-frame.tsx","../../../src/app/file-viewers/sibling-references.ts","../../../src/app/file-viewers/sibling-page.ts","../../../src/app/file-viewers/siblings-key.ts","../../../src/app/file-viewers/use-file-text.ts","../../../src/app/file-viewers/use-sibling-contents.ts","../../../src/app/file-viewers/use-sibling-page.ts"],"sourcesContent":["import { useCallback, useState } from 'react'\n\n/** A value of an `HtmlFrame` that belongs to the document it shows, by that document's `nonce`. */\nexport type DocumentState<T> = { nonce: string; value: T }\n\n/** `state`'s value for the document `nonce`; `initial` for another document, which starts again. */\nexport const ofDocument = <T>(state: DocumentState<T> | undefined, nonce: string, initial: T) => (state?.nonce === nonce ? state.value : initial)\n\n/** State that starts again at `initial` (a constant) each time the frame shows another document, `nonce`. */\nexport const useDocumentState = <T>(nonce: string, initial: T) => {\n const [state, setState] = useState<DocumentState<T>>()\n const update = useCallback((next: (value: T) => T) => setState((state) => ({ nonce, value: next(ofDocument(state, nonce, initial)) })), [nonce, initial])\n return [ofDocument(state, nonce, initial), update] as const\n}\n","/** The attribute an `HtmlFrame` page's link carries, the index of its target in the frame's `links`. */\nexport const linkAttribute = 'data-protobase-link'\n\n/**\n * The script an `HtmlFrame` runs in its page, the only one a page it does not trust runs. A click on a link carrying\n * `linkAttribute` posts its index to the app, with whether it asks for a new tab. A click on a link to a place on the\n * page (`#results`) moves the focus there and posts how far down the page it is, since the app's page scrolls rather\n * than the frame. A\n * click on any other link does nothing, so the page never leaves the frame. It also posts the page's height, so the\n * frame grows with it.\n */\nexport const frameBridge = `(() => {\n const post = (message) => parent.postMessage({ protobase: 'html-frame', ...message }, '*')\n const place = (hash) => {\n const name = decodeURIComponent(hash.slice(1))\n const target = name === '' || name === 'top' ? null : document.getElementById(name) ?? document.getElementsByName(name)[0]\n if (!target) return 0\n if (target.tabIndex < 0 && !target.hasAttribute('tabindex')) target.setAttribute('tabindex', '-1')\n target.focus({ preventScroll: true })\n return target.getBoundingClientRect().top + window.scrollY\n }\n const follow = (event) => {\n const link = event.target instanceof Element ? event.target.closest('a, area') : null\n if (!link) return\n event.preventDefault()\n const index = link.getAttribute('${linkAttribute}')\n const href = link.getAttribute('href') ?? ''\n if (index !== null) post({ link: Number(index), newTab: event.button === 1 || event.ctrlKey || event.metaKey || event.shiftKey })\n else if (href.startsWith('#') && event.button === 0) post({ scroll: place(href) })\n }\n document.addEventListener('click', follow, true)\n document.addEventListener('auxclick', (event) => event.button === 1 && follow(event), true)\n const height = () => post({ height: document.documentElement.getBoundingClientRect().height })\n new ResizeObserver(height).observe(document.documentElement)\n})()`\n","/**\n * What an `HtmlFrame`'s page may run: `'bridge'`, only the frame's own link script, for a page it does not trust, such\n * as an uploaded file; `'trusted-page'`, also the page's own inline scripts, for a page an app generates itself.\n */\nexport type FrameScripts = 'bridge' | 'trusted-page'\n\n/**\n * The frame's sandbox: scripts, so the link script runs, and nothing else. Never `allow-same-origin`, so the page has an\n * opaque origin and cannot reach the app's cookies, storage or DOM; no top navigation, forms or popups.\n */\nexport const frameSandbox = 'allow-scripts'\n\n/**\n * The page's Content-Security-Policy. With `'bridge'` only the script carrying `nonce` runs: the page's own scripts,\n * inline handlers and `javascript:` links do not. `'trusted-page'` runs inline scripts and so carries no nonce, which\n * would turn `'unsafe-inline'` off. Either way nothing loads from the network: images, media, styles and fonts come\n * from `data:` URLs, and nothing is fetched, framed or submitted.\n */\nexport const frameCsp = (scripts: FrameScripts, nonce: string) =>\n [\n \"default-src 'none'\",\n scripts === 'bridge' ? `script-src 'nonce-${nonce}'` : \"script-src 'unsafe-inline'\",\n 'img-src data:',\n 'media-src data:',\n \"style-src 'unsafe-inline' data:\",\n 'font-src data:',\n \"base-uri 'none'\",\n \"form-action 'none'\",\n ].join('; ')\n\n/** A fresh 128-bit nonce, as hex. */\nexport const frameNonce = () => Array.from(crypto.getRandomValues(new Uint8Array(16)), (byte) => byte.toString(16).padStart(2, '0')).join('')\n","import { frameBridge } from './frame-bridge'\nimport { frameCsp, type FrameScripts } from './frame-policy'\n\n// What a page could use to leave its policy or the frame: its own `http-equiv` (a refresh, another policy), a `<base>`,\n// and `<noscript>`, read as markup here but as text in the frame, where scripts run, so markup hidden in it would come\n// out after these were removed.\nconst removed = 'meta[http-equiv], base, noscript'\n\n/**\n * `html` as the page an `HtmlFrame` shows: parsed, cleared of `removed`, and opened with the frame's own policy, a\n * referrer policy that sends no address on, and the frame's link script carrying `nonce`. They are the first nodes of\n * `<head>`, put there in the parsed document, so the policy covers everything of the page, even a script written before\n * its `<html>`.\n */\nexport const frameDocument = (html: string, scripts: FrameScripts, nonce: string) => {\n const page = new DOMParser().parseFromString(html, 'text/html')\n for (const element of page.querySelectorAll(removed)) element.remove()\n\n const policy = page.createElement('meta')\n policy.httpEquiv = 'Content-Security-Policy'\n policy.content = frameCsp(scripts, nonce)\n const referrer = page.createElement('meta')\n referrer.name = 'referrer'\n referrer.content = 'no-referrer'\n const bridge = page.createElement('script')\n if (scripts === 'bridge') bridge.setAttribute('nonce', nonce)\n bridge.textContent = frameBridge\n page.head.prepend(policy, referrer, bridge)\n\n return `<!doctype html>${page.documentElement.outerHTML}`\n}\n","/**\n * How tall an `HtmlFrame` is for its page: `measured`, the height its page last reported, with the frame's own height\n * when it did, or `fixed`, for a page sized by the frame's viewport, such as one `100vh` tall or `height: 100%` with a\n * margin, which reports a taller page each time the frame takes its last height.\n */\nexport type FrameHeight = { kind: 'measured'; height: number; viewport: number } | { kind: 'fixed' }\n\n// Reported heights are rounded up to whole pixels.\nconst rounding = 1\n\n/**\n * The frame's height after its page reports `height` while the frame is `viewport` tall. A page whose height changed by\n * as much as the frame did since its last report is sized by the frame, and the frame stays fixed for it.\n */\nexport const nextFrameHeight = (previous: FrameHeight | undefined, height: number, viewport: number): FrameHeight => {\n if (previous?.kind === 'fixed') return previous\n if (previous && viewport !== previous.viewport && Math.abs(height - previous.height - (viewport - previous.viewport)) <= rounding) return { kind: 'fixed' }\n return { kind: 'measured', height, viewport }\n}\n\n/**\n * The frame's box: as tall as its page's measured height, or a fixed minimum while nothing is measured, for a page\n * measured 0 tall, and for a page sized by the frame. That page scrolls inside the frame, the one inner scroll box here:\n * the app's page cannot scroll content whose height depends on the frame's own.\n */\nexport const frameBox = (size: FrameHeight | undefined) =>\n size?.kind === 'measured' && size.height > 0 ? { style: { height: size.height } } : { className: 'min-h-[60vh]' }\n","/**\n * What an `HtmlFrame`'s page asks of the app: follow its link `index`, be as tall as `height` CSS pixels, or scroll to\n * the place `top` CSS pixels down the page.\n */\nexport type FrameMessage = { kind: 'link'; index: number; newTab: boolean } | { kind: 'height'; height: number } | { kind: 'scroll'; top: number }\n\n// Tall enough for a long report, short enough that a page cannot make the app's page endless.\nconst maxHeight = 100_000\n\n/**\n * The request a message event carries from the frame's own window `frame`, with a link index below `links`; `undefined`\n * for any other source or shape. Every sandboxed page's origin is `\"null\"`, so only the window itself tells them apart.\n */\nexport const frameMessage = (event: Pick<MessageEvent, 'source' | 'data'>, frame: Window | null | undefined, links: number): FrameMessage | undefined => {\n if (!frame || event.source !== frame) return\n const data: unknown = event.data\n if (typeof data !== 'object' || data === null || !('protobase' in data) || data.protobase !== 'html-frame') return\n if ('link' in data && Number.isInteger(data.link) && (data.link as number) >= 0 && (data.link as number) < links) {\n return { kind: 'link', index: data.link as number, newTab: 'newTab' in data && data.newTab === true }\n }\n if ('height' in data && typeof data.height === 'number' && Number.isFinite(data.height) && data.height >= 0) {\n return { kind: 'height', height: Math.min(Math.ceil(data.height), maxHeight) }\n }\n if ('scroll' in data && typeof data.scroll === 'number' && Number.isFinite(data.scroll)) {\n return { kind: 'scroll', top: Math.min(Math.max(Math.round(data.scroll), 0), maxHeight) }\n }\n return\n}\n","import { useEffect, useMemo, useRef } from 'react'\nimport { cn } from '../../lib/cn'\nimport { useDocumentState } from './document-state'\nimport type { ViewedFile } from './file-viewer'\nimport { frameDocument } from './frame-document'\nimport { frameBox, nextFrameHeight, type FrameHeight } from './frame-height'\nimport { frameMessage } from './frame-messages'\nimport { frameNonce, frameSandbox, type FrameScripts } from './frame-policy'\nimport type { FrameLink } from './sibling-page'\n\nconst noLinks: readonly never[] = []\n\n// Scrolls the app's page to the place `top` pixels down the page in `frame`, below the bars that stay at the top.\nconst scrollToPlace = (frame: HTMLIFrameElement, top: number) => {\n const bars = Number.parseFloat(getComputedStyle(document.documentElement).scrollPaddingTop) || 0\n window.scrollTo({ top: frame.getBoundingClientRect().top + window.scrollY + top - bars })\n}\n\ntype HtmlFrameProps<File extends ViewedFile> = {\n /** The page, a whole HTML document or a fragment. */\n html: string\n /** The frame's accessible name, such as the file's name. */\n title: string\n /** The targets of the page's links, by the index each carries (`useSiblingPage`). */\n links?: readonly FrameLink<File>[]\n /** Follows a link of the page; `newTab` when it was a middle or modified click. */\n onLink?: (link: FrameLink<File>, options: { newTab: boolean }) => void\n /**\n * `'bridge'` (the default) runs none of the page's own scripts, for a page you do not trust, such as an uploaded file;\n * `'trusted-page'` runs them, for a page your viewer generates itself. Either way the page cannot reach the app.\n */\n scripts?: FrameScripts\n className?: string\n}\n\n/**\n * A whole HTML page drawn in a sandboxed frame with an opaque origin: it cannot read the app's cookies, storage or DOM,\n * call its API as the user, load anything from the network or navigate the app's window. Its links reach the app only\n * as the index of one of `links`, which `onLink` follows. The frame is as tall as its page, so the app's page scrolls,\n * unless the page is sized by the frame (`FrameHeight`).\n */\nexport const HtmlFrame = <File extends ViewedFile>({ html, title, links = noLinks, onLink, scripts = 'bridge', className }: HtmlFrameProps<File>) => {\n const frame = useRef<HTMLIFrameElement>(null)\n const shown = useMemo(() => {\n const nonce = frameNonce()\n return { nonce, srcDoc: frameDocument(html, scripts, nonce) }\n }, [html, scripts])\n const [height, setHeight] = useDocumentState<FrameHeight | undefined>(shown.nonce, undefined)\n // A page that navigated its frame anyway is shown again once; doing so again leaves the frame empty, until another\n // document is shown.\n const [shownAgain, setShownAgain] = useDocumentState(shown.nonce, 0)\n const key = `${shown.nonce}:${shownAgain}`\n // The loads of the frame shown as `key`: its first is its page, any later one the page leaving it.\n const loads = useRef({ key, count: 0 })\n\n useEffect(() => {\n const receive = (event: MessageEvent) => {\n const message = frameMessage(event, frame.current?.contentWindow, links.length)\n const viewport = frame.current?.clientHeight\n if (message?.kind === 'height' && viewport !== undefined) setHeight((size) => nextFrameHeight(size, message.height, viewport))\n if (message?.kind === 'link') onLink?.(links[message.index]!, { newTab: message.newTab })\n if (message?.kind === 'scroll' && frame.current) scrollToPlace(frame.current, message.top)\n }\n window.addEventListener('message', receive)\n return () => window.removeEventListener('message', receive)\n }, [links, onLink, setHeight])\n\n const loaded = () => {\n if (loads.current.key !== key) loads.current = { key, count: 0 }\n loads.current.count += 1\n if (loads.current.count > 1) setShownAgain((times) => times + 1)\n }\n\n const box = frameBox(height)\n return (\n <iframe\n key={key}\n ref={frame}\n title={title}\n sandbox={frameSandbox}\n referrerPolicy=\"no-referrer\"\n // A video's own fullscreen control; a page that does not run its scripts can ask for nothing else.\n allow={scripts === 'bridge' ? 'fullscreen' : undefined}\n srcDoc={shownAgain > 1 ? '' : shown.srcDoc}\n onLoad={loaded}\n className={cn('block w-full border-0 bg-white', box.className, className)}\n style={box.style}\n />\n )\n}\n","import { fileNamed, type ViewedFile } from './file-viewer'\n\n// Whether a reference's path climbs out of its folder with a `..` segment.\nconst climbs = (value: string) => value.split(/[?#]/, 1)[0]!.split('/').includes('..')\n\n/**\n * The sibling a page's relative reference names, such as `shots/before.png` or `my%20chart.png`, by its file name\n * (`fileNamed`), as written or with its escapes read; none for an absolute or protocol-relative address, a path from\n * the root, a fragment, or a path that climbs out with `..`, written or escaped.\n */\nexport const siblingReference = <File extends ViewedFile>(siblings: readonly File[], reference: string) => {\n const value = reference.trim()\n const unescaped = decoded(value)\n if (climbs(value) || climbs(unescaped)) return\n return fileNamed(siblings, value) ?? fileNamed(siblings, unescaped)\n}\n\n// A reference with its escapes, such as `%20`, read; as it is when one is malformed.\nconst decoded = (value: string) => {\n try {\n return decodeURI(value)\n } catch (error) {\n if (error instanceof URIError) return value\n throw error\n }\n}\n\n/** `value` of a `srcset`, each candidate's address resolved on its own; a candidate `resolve` gives nothing for stays as written. */\nexport const rewriteSrcset = (value: string, resolve: (reference: string) => string | undefined) =>\n value\n .split(',')\n .map((candidate) => {\n const parts = /^(\\s*)(\\S+)([\\s\\S]*)$/.exec(candidate)\n const resolved = parts && resolve(parts[2]!)\n return parts && resolved ? `${parts[1]}${resolved}${parts[3]}` : candidate\n })\n .join(',')\n\n/** CSS `text` with each `url(...)` resolved; one `resolve` gives nothing for stays as written. */\nexport const rewriteCssUrls = (text: string, resolve: (reference: string) => string | undefined) =>\n text.replace(/url\\(\\s*(['\"]?)([^'\")]*)\\1\\s*\\)/gi, (whole, _quote: string, reference: string) => {\n const resolved = resolve(reference.trim())\n return resolved ? `url(\"${resolved}\")` : whole\n })\n\n/** An absolute `http:` or `https:` address as the URL parser reads it, else `undefined`, such as for `javascript:` or a relative path. */\nexport const externalUrl = (reference: string) => {\n if (!URL.canParse(reference)) return\n const url = new URL(reference)\n return url.protocol === 'http:' || url.protocol === 'https:' ? url.href : undefined\n}\n","import type { ViewedFile } from './file-viewer'\nimport { linkAttribute } from './frame-bridge'\nimport { externalUrl, rewriteCssUrls, rewriteSrcset, siblingReference } from './sibling-references'\n\n/** Where a link of a page in an `HtmlFrame` leads: a sibling file, or an outside `http`/`https` address. */\nexport type FrameLink<File extends ViewedFile = ViewedFile> = { kind: 'file'; file: File } | { kind: 'external'; url: string }\n\n/** A page with its references to siblings resolved, and the targets of its links, which carry their index. */\nexport type SiblingPage<File extends ViewedFile = ViewedFile> = { html: string; links: FrameLink<File>[] }\n\n// The attributes that load a file into the page, by the elements they are on.\nconst sources = ['img[src]', 'source[src]', 'video[src]', 'audio[src]', 'track[src]', 'input[src]'].join(', ')\n\n// Each reference of `page` that loads a file, set to what `resource` gives for it; one it gives nothing for stays.\nconst rewriteResources = (page: Document, resource: (reference: string) => string | undefined) => {\n const set = (element: Element, attribute: string, value: string | undefined) => value !== undefined && element.setAttribute(attribute, value)\n for (const element of page.querySelectorAll(sources)) set(element, 'src', resource(element.getAttribute('src')!))\n for (const element of page.querySelectorAll('video[poster]')) set(element, 'poster', resource(element.getAttribute('poster')!))\n for (const element of page.querySelectorAll('img[srcset], source[srcset]')) set(element, 'srcset', rewriteSrcset(element.getAttribute('srcset')!, resource))\n for (const element of page.querySelectorAll('link[href]')) set(element, 'href', resource(element.getAttribute('href')!))\n for (const element of page.querySelectorAll('image[href]')) set(element, 'href', resource(element.getAttribute('href')!))\n for (const element of page.querySelectorAll('[style]')) set(element, 'style', rewriteCssUrls(element.getAttribute('style')!, resource))\n for (const element of page.querySelectorAll('style')) element.textContent = rewriteCssUrls(element.textContent, resource)\n}\n\nconst parse = (html: string) => new DOMParser().parseFromString(html, 'text/html')\n\n/** The siblings `html` loads as images, videos, sounds, styles or fonts, each once: those a page needs read to show. */\nexport const referencedSiblings = <File extends ViewedFile>(html: string, siblings: readonly File[]) => {\n const found = new Set<File>()\n rewriteResources(parse(html), (reference) => {\n const sibling = siblingReference(siblings, reference)\n if (sibling) found.add(sibling)\n return\n })\n return [...found]\n}\n\n/** The address a page's link shows for where it leads, for the browser's link preview and copy link; `undefined` keeps its own. */\nexport type LinkAddress<File extends ViewedFile = ViewedFile> = (link: FrameLink<File>) => string | undefined\n\n/**\n * `html` with each relative reference to a sibling resolved: one that loads a file to the `data:` URL `contents` holds\n * by its stored `uri`, a link to a sibling or to an outside `http`/`https` address to an entry of `links`, showing the\n * address `address` gives it. A reference to no sibling, or to one `contents` lacks, stays as written; a link to\n * anywhere else, such as `javascript:`, loses its address. A link to a place on the page (`#top`) stays.\n */\nexport const siblingPage = <File extends ViewedFile>(html: string, siblings: readonly File[], contents: ReadonlyMap<string, string>, address?: LinkAddress<File>): SiblingPage<File> => {\n const page = parse(html)\n for (const element of page.querySelectorAll(`[${linkAttribute}]`)) element.removeAttribute(linkAttribute)\n rewriteResources(page, (reference) => {\n const sibling = siblingReference(siblings, reference)\n return sibling && contents.get(sibling.uri)\n })\n\n const links: FrameLink<File>[] = []\n for (const link of page.querySelectorAll('a[href], area[href]')) {\n const href = link.getAttribute('href')!\n if (href.startsWith('#')) continue\n link.removeAttribute('target')\n const sibling = siblingReference(siblings, href)\n const url = sibling ? undefined : externalUrl(href)\n if (!sibling && !url) {\n link.removeAttribute('href')\n continue\n }\n const target: FrameLink<File> = sibling ? { kind: 'file', file: sibling } : { kind: 'external', url: url! }\n const shown = address?.(target)\n if (shown !== undefined) link.setAttribute('href', shown)\n link.setAttribute(linkAttribute, String(links.length))\n links.push(target)\n }\n return { html: `<!doctype html>${page.documentElement.outerHTML}`, links }\n}\n","import type { ViewedFile } from './file-viewer'\n\n/**\n * A key that changes when any of `siblings` does: its stored uri, and the record key and file field a sibling carries\n * (`SiblingFile`), which its link's address names. A missing key or field is `null`.\n */\nexport const siblingsKey = <File extends ViewedFile>(siblings: readonly File[]) =>\n JSON.stringify(siblings.map((sibling) => [sibling.uri, 'key' in sibling ? sibling.key : null, 'field' in sibling ? sibling.field : null]))\n","import { useQuery } from '@tanstack/react-query'\nimport { useResourceClient } from '../../data/api-provider'\nimport type { ViewedFile } from './file-viewer'\nimport { useViewedResource } from './viewed-resource'\n\n/** A file that could not be read, with the status its link answered. */\nexport class FileReadError extends Error {\n override name = 'FileReadError'\n constructor(readonly status: number) {\n super(`The file could not be read: its link answered ${status}`)\n }\n}\n\n/**\n * The text of a file a viewer shows, read once and kept while the file is the same: a TanStack Query result keyed by\n * its resource and stored `uri`, as the link changes each time it is signed. Parse JSON from `data` yourself. It reads\n * from the API that serves the record, which sends the bytes itself whatever store holds them or wherever the file's\n * link points, up to 10 MB; a larger file fails with a 403.\n */\nexport const useFileText = (file: ViewedFile) => {\n const resource = useViewedResource()\n const client = useResourceClient(resource)\n return useQuery({\n queryKey: ['file-text', resource, file.uri],\n staleTime: Infinity,\n queryFn: async () => {\n const response = await fetch(client.fileReadUrl(resource, file))\n if (!response.ok) throw new FileReadError(response.status)\n return response.text()\n },\n })\n}\n","import { useQueries } from '@tanstack/react-query'\nimport { useResourceClient } from '../../data/api-provider'\nimport type { ViewedFile } from './file-viewer'\nimport { FileReadError } from './use-file-text'\nimport { useViewedResource } from './viewed-resource'\n\n// The bytes as a `data:` URL of the file's own type: a sandboxed page cannot load the app's `blob:` URLs, and the URL\n// holds the bytes alone, no signed link that would open the file elsewhere.\nconst dataUrl = (bytes: Blob) =>\n new Promise<string>((resolve, reject) => {\n const reader = new FileReader()\n reader.onload = () => resolve(reader.result as string)\n reader.onerror = () => reject(reader.error)\n reader.readAsDataURL(bytes)\n })\n\n/**\n * The contents of `files` as `data:` URLs by their stored `uri`, each read once from the API that serves the viewed\n * record, with the user's own rights, as `useFileText` reads, up to 10 MB each; `ready` once every read has answered. A\n * file that could not be read is left out, so what refers to it stays as written.\n */\nexport const useSiblingContents = (files: readonly ViewedFile[]) => {\n const resource = useViewedResource()\n const client = useResourceClient(resource)\n const reads = useQueries({\n queries: files.map((file) => ({\n queryKey: ['file-data-url', resource, file.uri],\n staleTime: Infinity,\n retry: false,\n queryFn: async () => {\n const response = await fetch(client.fileReadUrl(resource, file))\n if (!response.ok) throw new FileReadError(response.status)\n return dataUrl(new Blob([await response.arrayBuffer()], { type: file.type }))\n },\n })),\n })\n const contents = new Map<string, string>()\n reads.forEach((read, index) => read.data !== undefined && contents.set(files[index]!.uri, read.data))\n return { contents, ready: reads.every((read) => !read.isPending) }\n}\n","import { useMemo } from 'react'\nimport type { ViewedFile } from './file-viewer'\nimport { referencedSiblings, siblingPage, type LinkAddress, type SiblingPage } from './sibling-page'\nimport { siblingsKey } from './siblings-key'\nimport { useSiblingContents } from './use-sibling-contents'\n\n/**\n * `html`, a page a file viewer shows, with its relative references resolved to `siblings` (`siblingPage`), for an\n * `HtmlFrame`: the images, videos and styles it names read as `data:` URLs, its links to siblings and outside addresses\n * in `links`, each showing the address `address` gives it. `undefined` while `html` or those reads are pending. Use it\n * inside a file viewer, which reads them from the API that serves the viewed record.\n */\nexport const useSiblingPage = <File extends ViewedFile>(html: string | undefined, siblings: readonly File[], address?: LinkAddress<File>): SiblingPage<File> | undefined => {\n // A viewer's siblings are a new list each render: their key, and the contents read, say when they changed.\n const siblingKey = siblingsKey(siblings)\n const named = useMemo(() => (html === undefined ? [] : referencedSiblings(html, siblings)), [html, siblingKey])\n const { contents, ready } = useSiblingContents(named)\n const contentsKey = [...contents.keys()].join('\\n')\n return useMemo(() => (html === undefined || !ready ? undefined : siblingPage(html, siblings, contents, address)), [html, siblingKey, ready, contentsKey, address])\n}\n"],"mappings":"2vBAMakB,GAAiB,EAAqC,EAAe,IAAgBC,GAAO,QAAUC,EAAQD,EAAM,MAAQE,EAG5HC,GAAuB,EAAe,IAAe,CAChE,GAAM,CAACH,EAAOI,IAAA,EAAYvB,EAAAA,SAAAA,CAA2B,EAC/CwB,GAAA,EAASvB,EAAAA,YAAAA,CAAa,GAA0BsB,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