@pipelex/mthds-form 0.7.0 → 0.9.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.
Files changed (45) hide show
  1. package/README.md +6 -3
  2. package/dist/chunk-AZZAAGNX.js +194 -0
  3. package/dist/chunk-AZZAAGNX.js.map +1 -0
  4. package/dist/{chunk-IIU3YK4O.js → chunk-DARLDVJM.js} +3 -3
  5. package/dist/{chunk-IIU3YK4O.js.map → chunk-DARLDVJM.js.map} +1 -1
  6. package/dist/{chunk-R7B7ID25.js → chunk-IUWLOSAM.js} +4 -4
  7. package/dist/{chunk-R7B7ID25.js.map → chunk-IUWLOSAM.js.map} +1 -1
  8. package/dist/chunk-KG4IYFWI.js +2721 -0
  9. package/dist/chunk-KG4IYFWI.js.map +1 -0
  10. package/dist/{chunk-J4L32LD6.js → chunk-KIEOLP2L.js} +3 -3
  11. package/dist/{chunk-J4L32LD6.js.map → chunk-KIEOLP2L.js.map} +1 -1
  12. package/dist/{chunk-4BSBBG2T.js → chunk-S4CB423P.js} +3 -3
  13. package/dist/{chunk-4BSBBG2T.js.map → chunk-S4CB423P.js.map} +1 -1
  14. package/dist/{chunk-XYQ7NXQZ.js → chunk-WYH56SOZ.js} +2 -2
  15. package/dist/chunk-WYH56SOZ.js.map +1 -0
  16. package/dist/{chunk-YEVVR6FE.js → chunk-Y2ND6W4W.js} +3 -3
  17. package/dist/{chunk-YEVVR6FE.js.map → chunk-Y2ND6W4W.js.map} +1 -1
  18. package/dist/{chunk-T4NSAGOS.js → chunk-YABRYTQ4.js} +4 -4
  19. package/dist/{chunk-T4NSAGOS.js.map → chunk-YABRYTQ4.js.map} +1 -1
  20. package/dist/core/contracts.d.ts +4 -4
  21. package/dist/core/contracts.js +1 -1
  22. package/dist/core/derive.js +2 -2
  23. package/dist/core/gate.js +3 -3
  24. package/dist/core/gating-fields.js +2 -2
  25. package/dist/core/index.d.ts +1 -1
  26. package/dist/core/index.js +8 -8
  27. package/dist/core/native-content.d.ts +56 -9
  28. package/dist/core/native-content.js +1 -1
  29. package/dist/core/output-form.js +2 -2
  30. package/dist/core/stuff-files.js +2 -2
  31. package/dist/core/values.js +3 -3
  32. package/dist/field-renderer-BSU2hMf6.d.ts +34 -0
  33. package/dist/generative/index.d.ts +2013 -0
  34. package/dist/generative/index.js +3171 -0
  35. package/dist/generative/index.js.map +1 -0
  36. package/dist/react/index.d.ts +42 -36
  37. package/dist/react/index.js +8 -2614
  38. package/dist/react/index.js.map +1 -1
  39. package/dist/styles.css +2 -2
  40. package/dist/theme.css +53 -44
  41. package/dist/ui-designer.mthds +304 -0
  42. package/package.json +24 -10
  43. package/dist/chunk-45C2MKK6.js +0 -94
  44. package/dist/chunk-45C2MKK6.js.map +0 -1
  45. package/dist/chunk-XYQ7NXQZ.js.map +0 -1
@@ -184,14 +184,50 @@ declare function isNativeCompositeNode(node: {
184
184
  declare function readDateContent(value: unknown): DateContentView | undefined;
185
185
  /** `{date}` / `{date, time}` as one line, which is how both are read aloud. */
186
186
  declare function formatDateContent(content: DateContentView): string;
187
+ /** What a `data:` URL says about the bytes it carries. */
188
+ interface DataUrlView {
189
+ /** Lowercased, without its parameters; `text/plain` when the URL declares none. */
190
+ mediaType: string;
191
+ /** The size of the DECODED payload, in bytes. */
192
+ bytes: number;
193
+ }
194
+ /**
195
+ * A `data:` URL's media type and decoded size, or `undefined` for any other URL.
196
+ *
197
+ * A host that encodes a picked file in the browser writes the file itself into
198
+ * the value's `url`, so a thirty-kilobyte PDF is a forty-thousand-character
199
+ * string, and printed where a reference would be it tells a person nothing. Its
200
+ * type and its size are what they can read.
201
+ *
202
+ * The size is COUNTED rather than decoded. A base64 payload's size follows from
203
+ * how many symbols it holds, and decoding a megabyte to measure it would be the
204
+ * frozen main thread {@link stripUrlWhitespace} is written to avoid. This is a
205
+ * reading for display, not a gate: whether the URL may be painted is still
206
+ * {@link viewableUrl}'s answer alone.
207
+ */
208
+ declare function readDataUrl(candidate: string): DataUrlView | undefined;
187
209
  /**
188
- * Whether a browser can paint this URL as-is.
210
+ * The URL a browser can paint, normalised — or `undefined` when there is none.
189
211
  *
190
- * A `pipelex-storage://` reference cannot be resolved client-side — that is the
191
- * upload seam's job (see [../../docs/upload-seam.md]) — so a renderer with no
192
- * resolver must show the reference rather than a broken `<img>`. `file:` is
193
- * deliberately NOT viewable: a run on a developer's machine writes one, and a
194
- * browser refuses to load it from a page served over http.
212
+ * **The string this returns is the string a sink must use.** That is the whole
213
+ * point of returning one rather than answering yes or no: the gate judges a
214
+ * normalised URL, so handing the caller back the raw member would let the two
215
+ * diverge again on exactly the whitespace the parser strips.
216
+ *
217
+ * The gate parses rather than prefix-matches, and branches on the protocol the
218
+ * parser reports:
219
+ *
220
+ * - `http:` and `https:` are viewable.
221
+ * - `blob:` is viewable. A blob URL is bound to the origin that minted it, so a
222
+ * payload cannot forge one that points anywhere else.
223
+ * - `data:` is viewable only for a media type in {@link VIEWABLE_DATA_MEDIA_TYPES}.
224
+ * `data:text/html` is a document at the EMBEDDING page's own origin, which is
225
+ * what made an unsandboxed frame over a payload URL a real hole.
226
+ * - Everything else is not: `javascript:`, `file:` (a run on a developer's
227
+ * machine writes one, and a browser refuses to load it from an http page) and
228
+ * `pipelex-storage://`, which cannot be resolved client-side at all — that is
229
+ * the upload seam's job (see [../../docs/upload-seam.md]), and a renderer with
230
+ * no resolver must show the reference rather than a broken `<img>`.
195
231
  *
196
232
  * **A root-relative path counts**, and leaving it out was a real bug rather
197
233
  * than an omission. A host's URL resolver naturally hands back a path on its
@@ -201,8 +237,19 @@ declare function formatDateContent(content: DateContentView): string;
201
237
  * away and the arms fell back to the payload's `public_url`: a presigned URL
202
238
  * that had already expired. The image stayed broken with the fix in place.
203
239
  *
204
- * `//host/path` is deliberately excluded. It is protocol-relative, so it points
205
- * at another origin while looking like a path.
240
+ * A path is rejected when it is protocol-relative — `//host/x`, and the two
241
+ * backslash spellings the parser reads the same way (`\\host\x`, `/\host/x`) —
242
+ * and then checked against the sentinel as well. An accepted path is returned
243
+ * relative, because making it absolute against a sentinel would point it at
244
+ * nowhere.
245
+ */
246
+ declare function viewableUrl(candidate: string | undefined): string | undefined;
247
+ /**
248
+ * Whether a browser can paint this URL as-is — {@link viewableUrl} as a guard.
249
+ *
250
+ * Prefer `viewableUrl` wherever the URL is then USED: this answers the question
251
+ * without handing back the normalised string, so a caller that acts on the raw
252
+ * candidate acts on a string the gate did not judge.
206
253
  */
207
254
  declare function isViewableUrl(url: string | undefined): url is string;
208
255
  /**
@@ -216,4 +263,4 @@ declare const TYPED_SCALAR_MARKERS: readonly ["__class__", "__module__"];
216
263
  /** Whether a record carries the typed-scalar markers. Informational. */
217
264
  declare function hasTypedScalarMarkers(value: unknown): boolean;
218
265
 
219
- export { type CompositeMember, type DateContentView, type DocumentContentView, type HtmlContentView, type ImageContentView, NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDateContent, readDocumentContent, readHtmlContent, readImageContent };
266
+ export { type CompositeMember, type DataUrlView, type DateContentView, type DocumentContentView, type HtmlContentView, type ImageContentView, NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl };
@@ -1,4 +1,4 @@
1
- export { NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDateContent, readDocumentContent, readHtmlContent, readImageContent } from '../chunk-45C2MKK6.js';
1
+ export { NATIVE_COMPOSITE_CONCEPT_REF, NATIVE_DATE_CONCEPT_REF, NATIVE_HTML_CONCEPT_REF, TYPED_SCALAR_MARKERS, formatDateContent, hasTypedScalarMarkers, isNativeCompositeNode, isNativeDateNode, isNativeHtmlNode, isViewableUrl, readCompositeContent, readDataUrl, readDateContent, readDocumentContent, readHtmlContent, readImageContent, viewableUrl } from '../chunk-AZZAAGNX.js';
2
2
  import '../chunk-V3OV2XQT.js';
3
3
  //# sourceMappingURL=native-content.js.map
4
4
  //# sourceMappingURL=native-content.js.map
@@ -1,5 +1,5 @@
1
- export { getPipeOutputForm } from '../chunk-IIU3YK4O.js';
2
- import '../chunk-XYQ7NXQZ.js';
1
+ export { getPipeOutputForm } from '../chunk-DARLDVJM.js';
2
+ import '../chunk-WYH56SOZ.js';
3
3
  import '../chunk-V3OV2XQT.js';
4
4
  //# sourceMappingURL=output-form.js.map
5
5
  //# sourceMappingURL=output-form.js.map
@@ -1,5 +1,5 @@
1
- export { collectStuffFiles } from '../chunk-4BSBBG2T.js';
2
- import '../chunk-45C2MKK6.js';
1
+ export { collectStuffFiles } from '../chunk-S4CB423P.js';
2
+ import '../chunk-AZZAAGNX.js';
3
3
  import '../chunk-V3OV2XQT.js';
4
4
  //# sourceMappingURL=stuff-files.js.map
5
5
  //# sourceMappingURL=stuff-files.js.map
@@ -1,11 +1,11 @@
1
- export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-T4NSAGOS.js';
2
- import '../chunk-J4L32LD6.js';
1
+ export { apiInputsFromRunValues, fieldsForContract, inputDataFromWorkingMemory, outputsFromPipeOutput, rjsfDataFromRunValues, runValuesFromStore, setValueAtPath, storeInputDataFromRunValues } from '../chunk-YABRYTQ4.js';
2
+ import '../chunk-KIEOLP2L.js';
3
3
  import '../chunk-2JWRG53S.js';
4
4
  import '../chunk-GCXV76WU.js';
5
5
  import '../chunk-PM55AHRO.js';
6
6
  import '../chunk-GKV77RAS.js';
7
7
  import '../chunk-OD3VYXUY.js';
8
- import '../chunk-XYQ7NXQZ.js';
8
+ import '../chunk-WYH56SOZ.js';
9
9
  import '../chunk-V3OV2XQT.js';
10
10
  //# sourceMappingURL=values.js.map
11
11
  //# sourceMappingURL=values.js.map
@@ -0,0 +1,34 @@
1
+ import * as react from 'react';
2
+ import { RunField } from './core/descriptor.js';
3
+
4
+ /**
5
+ * Ambient state that any field in the tree may need, threaded unchanged through
6
+ * the recursion so containers don't have to re-plumb it for every child.
7
+ */
8
+ interface FieldEnv {
9
+ disabled?: boolean;
10
+ /** A file field asks its parent to upload; the parent sets the value later. */
11
+ onDropFile?: (id: string, file: File) => void;
12
+ /** Ids currently mid-upload. */
13
+ uploadingIds?: ReadonlySet<string>;
14
+ /** Resolve a `pipelex-storage://` URI to a browser-viewable URL (for previews
15
+ * of already-stored files). */
16
+ resolveUrl?: (uri: string) => Promise<string | null>;
17
+ }
18
+ interface FieldRendererProps {
19
+ field: RunField;
20
+ value: unknown;
21
+ onChange: (value: unknown) => void;
22
+ /** Unique, stable id used for label linkage and upload tracking. */
23
+ id: string;
24
+ error?: string;
25
+ env?: FieldEnv;
26
+ }
27
+ /**
28
+ * The single dispatch point: a normalized `RunField` → the matching control.
29
+ * Object and list fields recurse back through here, so the whole form is one
30
+ * data-driven tree with no per-type branching anywhere else.
31
+ */
32
+ declare function FieldRenderer({ field, value, onChange, id, error, env }: FieldRendererProps): react.JSX.Element;
33
+
34
+ export { type FieldEnv as F, FieldRenderer as a, type FieldRendererProps as b };