@pipelex/mthds-ui 0.56.0 → 0.57.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -319,6 +319,7 @@ See `graphConfig.ts` for the full default palette.
319
319
  | `@pipelex/mthds-ui/shiki` | MTHDS syntax highlighting with shiki |
320
320
  | `@pipelex/mthds-ui/tailwind.css` | Where the kernel's classes are, for a Tailwind 4 host |
321
321
  | `@pipelex/mthds-ui/form-kernel.css` | The kernel's prebuilt stylesheet, for a host without Tailwind |
322
+ | `@pipelex/mthds-ui/pdf-layers.css` | The layers of a PDF the result view draws, for a Tailwind 4 host |
322
323
 
323
324
  ## Pure TypeScript usage
324
325
 
@@ -388,13 +389,15 @@ The controls inside `RunPanel`, and inside the graph's detail panel, are the for
388
389
 
389
390
  `tailwind.css` points Tailwind at the copy of the kernel this package depends on, wherever pnpm or npm put it beside or under this package, so you write no path into `node_modules` and do not declare `@pipelex/mthds-form` yourself. One layout escapes it: when your tree holds two versions of this package, npm can nest one below a kernel hoisted further up, and the controls then render unstyled without a warning; [docs/run-form-panel.md](./docs/run-form-panel.md) gives the one-line remedy. The rest of the kernel's setup stays yours: `tw-animate-css` animates the select popover and the tooltip, without the token mapping a class such as `bg-background` compiles to nothing, and the `@custom-variant` line, which a shadcn/ui codebase already has, keys `dark:` to the `.dark` class the kernel follows rather than to the operating system's preference.
390
391
 
392
+ If you hand the result view a document's bytes, so that it draws a PDF it cannot frame (`loadBytes` and `pdfWorker` on `GraphViewer`), also import the styles of the drawn pages' text and annotation layers, which are plain CSS for pdf.js's own elements and not utilities your build could compile: `@import "@pipelex/mthds-ui/pdf-layers.css";`. Without them a page's selectable text sits visibly out of place over it. Every rule but one is scoped under the renderer's frame; the exception sets two marker properties on `body` and styles nothing.
393
+
391
394
  **A host without Tailwind** imports the prebuilt stylesheet once, from its entry:
392
395
 
393
396
  ```ts
394
397
  import "@pipelex/mthds-ui/form-kernel.css";
395
398
  ```
396
399
 
397
- It carries Tailwind's preflight, which resets the browser's default styles across your whole page (heading sizes, list markers, margins), and a cascade layer that lets every rule you write yourself win a tie against it.
400
+ It carries Tailwind's preflight, which resets the browser's default styles across your whole page (heading sizes, list markers, margins), and a cascade layer that lets every rule you write yourself win a tie against it. It also carries the layer styles of a PDF the result view draws, so such a host imports nothing more for them.
398
401
 
399
402
  Tailwind 3 hosts and Tailwind 4 hosts that configure a prefix are not supported: their builds cannot generate the kernel's unprefixed Tailwind 4 classes, and the prebuilt sheet cannot sit in their cascade, because its preflight must rank below their base styles while its utilities must rank above them.
400
403
 
@@ -3,7 +3,7 @@ import React__default from 'react';
3
3
  import { d as GraphSpec, e as GraphNodeData, f as GraphEdge, g as GraphNode, h as GraphConfig, i as GraphDirection, F as FoldMode, G as GraphThemeMode, T as ToolbarPosition, j as GraphStyleId, a as GraphTheme, k as PipeStatus, l as GraphSpecNodeIoItem, m as ValidationState, V as ValidationIssue, L as LabelDescriptor, n as PipeControllerType, o as FoldToggleOptions, N as NodeValidationSummary, p as PipeCardPayload, C as ConceptInfo, q as GraphSpecNode } from '../../types-CnDJyLYo.js';
4
4
  export { r as PipeOperatorType } from '../../types-CnDJyLYo.js';
5
5
  import { PipeIOContracts, OutputForm, InputForm, LoadText, SaveFiles } from '@pipelex/mthds-form';
6
- import { ResolveUrl, ResolveRendition, ResolveDocumentPdf, ResolveShareUrl, DownloadDisplay } from '@pipelex/mthds-form/react';
6
+ import { ResolveUrl, ResolveRendition, ResolveDocumentPdf, LoadBytes, PdfWorkerConfig, OpenExternal, ResolveShareUrl, DownloadDisplay } from '@pipelex/mthds-form/react';
7
7
  import { Edge, Node, ReactFlowInstance } from '@xyflow/react';
8
8
  import 'mthds/errors';
9
9
 
@@ -305,6 +305,42 @@ interface GraphViewerProps {
305
305
  * reads as `unavailable`.
306
306
  */
307
307
  resolveDocumentPdf?: ResolveDocumentPdf;
308
+ /**
309
+ * Reads a document's bytes, so the result panel can draw a PDF it cannot
310
+ * frame (one `resolveUrl` answers on another origin, such as a presigned
311
+ * storage URL) page by page with pdf.js. It takes effect only with
312
+ * `pdfWorker`.
313
+ *
314
+ * Called with the document's own `url` member, as `resolveUrl` is, and a
315
+ * `{ maxBytes, signal }` request; resolve to the file's bytes as a
316
+ * `Uint8Array` or an `ArrayBuffer`, pass `signal` to your `fetch`, and reject
317
+ * for anything that is not a reference you store yourself: the method chose
318
+ * the URL, so never fetch an arbitrary one with credentials or through your
319
+ * own server. It goes on the panel's provider beside `resolveUrl`, which
320
+ * replaces an outer provider rather than merging with it, so a `loadBytes`
321
+ * set around the graph does not reach the panel.
322
+ */
323
+ loadBytes?: LoadBytes;
324
+ /**
325
+ * Names pdf.js's worker for the PDFs the result panel draws from `loadBytes`:
326
+ * a `workerSrc` URL of `pdf.worker.min.mjs` from the same `pdfjs-dist` the
327
+ * kernel's `react-pdf` resolves, or a `workerPort` the host started, with an
328
+ * optional `version` checked against pdf.js's and the optional data-file
329
+ * directories. Unset, no PDF is drawn and each keeps its link. Keep its
330
+ * identity stable (a constant or a memoized object). It goes on the panel's
331
+ * provider beside `resolveUrl`, so one set around the graph does not reach
332
+ * the panel.
333
+ */
334
+ pdfWorker?: PdfWorkerConfig;
335
+ /**
336
+ * Opens an external link in a PDF the result panel draws, for a host whose
337
+ * view cannot open a tab itself (a sandboxed frame). Called with the link's
338
+ * `http:`, `https:` or `mailto:` URL on a click or a middle click. Unset,
339
+ * such a link opens in a new tab with `noopener noreferrer`. It goes on the
340
+ * panel's provider beside `resolveUrl`, so one set around the graph does
341
+ * not reach the panel.
342
+ */
343
+ openExternal?: OpenExternal;
308
344
  /**
309
345
  * Mints a URL that works OUTSIDE this page, for the copy control.
310
346
  *
@@ -528,7 +564,11 @@ declare function PipeCardBase({ data, children }: PipeCardBaseProps): react_jsx_
528
564
  * other use of a picture keeps the whole one. A host that can make a PDF of a
529
565
  * document the browser cannot render, such as a Word, Excel or PowerPoint file,
530
566
  * passes `resolveDocumentPdf` there too, and that document's preview shows the
531
- * PDF's pages.
567
+ * PDF's pages. A host whose documents the panel cannot frame, because they are
568
+ * served from another origin such as a presigned storage URL, passes
569
+ * `loadBytes` and `pdfWorker` there as well, and the kernel draws such a PDF's
570
+ * pages itself with pdf.js; `openExternal` is how the links inside those pages
571
+ * leave a view that cannot open a tab.
532
572
  *
533
573
  * ## Stored texts
534
574
  *
@@ -635,6 +675,28 @@ interface StuffResultPanelProps extends StuffResultRendererOptions {
635
675
  * page's own origin; an answer on another origin reads as `unavailable`.
636
676
  */
637
677
  resolveDocumentPdf?: ResolveDocumentPdf;
678
+ /**
679
+ * Reads a document's bytes, for a PDF the panel cannot frame because the
680
+ * frame rule refused it (another origin, such as a presigned storage URL):
681
+ * called with the document's own `url` member and `{ maxBytes, signal }`, it
682
+ * resolves to the file as a `Uint8Array` or an `ArrayBuffer`, and the kernel
683
+ * draws its pages with pdf.js. It takes effect only with `pdfWorker`. The
684
+ * method chose the URL, so it reads only references the host stores itself
685
+ * and rejects every other.
686
+ */
687
+ loadBytes?: LoadBytes;
688
+ /**
689
+ * pdf.js's worker for the PDFs drawn from `loadBytes`: a `workerSrc` URL or a
690
+ * host-started `workerPort`, with an optional `version` and data-file
691
+ * directories. Unset, no PDF is drawn and each keeps its link.
692
+ */
693
+ pdfWorker?: PdfWorkerConfig;
694
+ /**
695
+ * Opens an external link inside a drawn PDF, for a view that cannot open a
696
+ * tab itself. Unset, such a link opens in a new tab with
697
+ * `noopener noreferrer`.
698
+ */
699
+ openExternal?: OpenExternal;
638
700
  /**
639
701
  * Reads a stored text: called with the reference's `url` when the panel
640
702
  * shows a `Text`, `Markdown`, `Html` or `JSON` value the runtime stored
@@ -663,7 +725,7 @@ interface StuffResultPanelProps extends StuffResultRendererOptions {
663
725
  */
664
726
  downloads?: DownloadDisplay;
665
727
  }
666
- declare function StuffResultPanel({ pipeIoContracts, outputForm, inputForm, stuff, producerPipeRef, consumer, resolveUrl, loadText, resolveRendition, resolveDocumentPdf, resolveShareUrl, saveFiles, downloads, }: StuffResultPanelProps): react_jsx_runtime.JSX.Element | null;
728
+ declare function StuffResultPanel({ pipeIoContracts, outputForm, inputForm, stuff, producerPipeRef, consumer, resolveUrl, loadText, resolveRendition, resolveDocumentPdf, loadBytes, pdfWorker, openExternal, resolveShareUrl, saveFiles, downloads, }: StuffResultPanelProps): react_jsx_runtime.JSX.Element | null;
667
729
 
668
730
  interface DetailPanelProps {
669
731
  isOpen: boolean;
@@ -450,6 +450,9 @@ function StuffResultPanel({
450
450
  loadText,
451
451
  resolveRendition,
452
452
  resolveDocumentPdf,
453
+ loadBytes,
454
+ pdfWorker,
455
+ openExternal,
453
456
  resolveShareUrl,
454
457
  saveFiles,
455
458
  downloads
@@ -477,13 +480,16 @@ function StuffResultPanel({
477
480
  ].join("\0");
478
481
  if (field) {
479
482
  const panel = /* @__PURE__ */ jsx3(LoadedStuffViewer, { field, nodeKey, value: stuff.data, name: stuff.name });
480
- return resolveUrl || loadText || resolveRendition || resolveDocumentPdf || resolveShareUrl || saveFiles || downloads ? /* @__PURE__ */ jsx3(
483
+ return resolveUrl || loadText || resolveRendition || resolveDocumentPdf || loadBytes || pdfWorker || openExternal || resolveShareUrl || saveFiles || downloads ? /* @__PURE__ */ jsx3(
481
484
  ResultEnvProvider,
482
485
  {
483
486
  resolveUrl,
484
487
  loadText,
485
488
  resolveRendition,
486
489
  resolveDocumentPdf,
490
+ loadBytes,
491
+ pdfWorker,
492
+ openExternal,
487
493
  resolveShareUrl,
488
494
  saveFiles,
489
495
  downloads,
@@ -2417,15 +2423,18 @@ function ResultView({
2417
2423
  loadText,
2418
2424
  resolveRendition,
2419
2425
  resolveDocumentPdf,
2426
+ loadBytes,
2427
+ pdfWorker,
2428
+ openExternal,
2420
2429
  resolveShareUrl,
2421
2430
  saveFiles,
2422
2431
  downloads
2423
2432
  } = valueOptions;
2424
2433
  return /* @__PURE__ */ jsx22(
2425
2434
  StuffResultPanel,
2426
- __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, descriptors), {
2435
+ __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadProps(__spreadValues({}, descriptors), {
2427
2436
  stuff
2428
- }), concept ? { concept } : {}), producerPipeRef ? { producerPipeRef } : {}), consumer ? { consumer } : {}), resolveUrl ? { resolveUrl } : {}), loadText ? { loadText } : {}), resolveRendition ? { resolveRendition } : {}), resolveDocumentPdf ? { resolveDocumentPdf } : {}), resolveShareUrl ? { resolveShareUrl } : {}), saveFiles ? { saveFiles } : {}), downloads ? { downloads } : {}), {
2437
+ }), concept ? { concept } : {}), producerPipeRef ? { producerPipeRef } : {}), consumer ? { consumer } : {}), resolveUrl ? { resolveUrl } : {}), loadText ? { loadText } : {}), resolveRendition ? { resolveRendition } : {}), resolveDocumentPdf ? { resolveDocumentPdf } : {}), loadBytes ? { loadBytes } : {}), pdfWorker ? { pdfWorker } : {}), openExternal ? { openExternal } : {}), resolveShareUrl ? { resolveShareUrl } : {}), saveFiles ? { saveFiles } : {}), downloads ? { downloads } : {}), {
2429
2438
  theme
2430
2439
  })
2431
2440
  );
@@ -4155,6 +4164,9 @@ function GraphViewerCanvas(props) {
4155
4164
  loadText,
4156
4165
  resolveRendition,
4157
4166
  resolveDocumentPdf,
4167
+ loadBytes,
4168
+ pdfWorker,
4169
+ openExternal,
4158
4170
  resolveShareUrl,
4159
4171
  saveFiles,
4160
4172
  downloads,
@@ -4886,6 +4898,9 @@ function GraphViewerCanvas(props) {
4886
4898
  loadText,
4887
4899
  resolveRendition,
4888
4900
  resolveDocumentPdf,
4901
+ loadBytes,
4902
+ pdfWorker,
4903
+ openExternal,
4889
4904
  resolveShareUrl,
4890
4905
  saveFiles,
4891
4906
  downloads
@@ -4895,6 +4910,9 @@ function GraphViewerCanvas(props) {
4895
4910
  loadText,
4896
4911
  resolveRendition,
4897
4912
  resolveDocumentPdf,
4913
+ loadBytes,
4914
+ pdfWorker,
4915
+ openExternal,
4898
4916
  resolveShareUrl,
4899
4917
  saveFiles,
4900
4918
  downloads