partforge 0.133.3 → 0.134.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/types/index.d.ts CHANGED
@@ -25,8 +25,49 @@ export type HostRailLayout =
25
25
  | { mode: "overlay" }
26
26
  | null;
27
27
 
28
- /** An export file format. STEP is routed to OCCT automatically. */
29
- export type ExportFormat = "stl" | "step" | "3mf";
28
+ /** An export file format. STEP is routed to OCCT automatically; `"bundle"` is the cut & print kit (a ZIP). */
29
+ export type ExportFormat = "stl" | "step" | "3mf" | "bundle";
30
+
31
+ /** One entry of `runtime.listExportFormats()` / `EXPORT_FORMATS`. `needsSheet` marks a format that needs a sheet part checked. */
32
+ export interface ExportFormatInfo {
33
+ id: ExportFormat;
34
+ label: string;
35
+ ext: string;
36
+ mime: string;
37
+ needsSheet: boolean;
38
+ }
39
+
40
+ /** A sheet part's stock, as `listExportableParts()` reports it. `group` is the kit's stock-group key, e.g. `"birch plywood|3.00"`. */
41
+ export interface ExportableSheetInfo {
42
+ process: string;
43
+ material: string;
44
+ thickness: number;
45
+ group: string;
46
+ }
47
+
48
+ /**
49
+ * The cut & print kit's download options — `exportParts({ format: "bundle", options })`.
50
+ * Every key is optional; `validateKitOptions` fills the defaults and throws an error
51
+ * starting `"cut kit options:"` for anything it cannot honour.
52
+ */
53
+ export interface KitOptions {
54
+ /** `"own-laser"` (default): SVG, laid out on sheets. `"service"`: DXF, one cut-only file per piece. */
55
+ destination?: "own-laser" | "service";
56
+ /** Derived from `destination`; when given it must match. */
57
+ cutFormat?: "svg" | "dxf";
58
+ /** mm, 0–0.5: the cut lines move out by half of it. Default 0 (nominal geometry). */
59
+ kerf?: number;
60
+ colors?: "lightburn";
61
+ /** Sheet size in mm per stock group; `"*"` is an explicit default. `null` (default) is 300 × 300 mm for every group. */
62
+ stock?: Array<{ group: string; size: [number, number] }> | null;
63
+ /** mm, 0–50. Default 5. */
64
+ margin?: number;
65
+ /** mm, 1–50. Default 3. */
66
+ spacing?: number;
67
+ printFormat?: "stl" | "3mf";
68
+ /** Whole number, 1–20. Default 1. */
69
+ sets?: number;
70
+ }
30
71
 
31
72
  /**
32
73
  * A semantic click result: which sub-part was hit, where (in the sub-part's own
@@ -346,9 +387,11 @@ export interface ExportPartsOptions {
346
387
  /** Sub-part names, as `listExportableParts()` reports them. */
347
388
  parts: string[];
348
389
  format: ExportFormat;
349
- /** Mesh quality for STL/3MF. Defaults to `"print"`. */
390
+ /** Mesh quality for STL/3MF (and a kit's printed parts). Defaults to `"print"`. */
350
391
  quality?: "preview" | "print";
351
392
  onProgress?: (phase: string) => void;
393
+ /** The cut & print kit's download options (`format: "bundle"`; the other formats ignore them). */
394
+ options?: KitOptions;
352
395
  }
353
396
 
354
397
  export interface CaptureCurrentOptions {
@@ -581,9 +624,12 @@ export interface PartRuntime {
581
624
  onContextLost(listener: () => void): () => void;
582
625
  /**
583
626
  * Every exportable sub-part — excludes any `exportable: false` part, respects
584
- * each part's `enabled(params)` — INDEPENDENT of the active view.
627
+ * each part's `enabled(params)` — INDEPENDENT of the active view. A sheet
628
+ * part's row adds `sheet`, evaluated at the current params (omitted when that throws).
585
629
  */
586
- listExportableParts(): Array<{ name: string; label: string }>;
630
+ listExportableParts(): Array<{ name: string; label: string; sheet?: ExportableSheetInfo }>;
631
+ /** The formats `exportParts` writes in this version — fresh copies of `EXPORT_FORMATS`. */
632
+ listExportFormats(): ExportFormatInfo[];
587
633
  /**
588
634
  * Headless export of a chosen subset. Resolves once the file is written
589
635
  * (handed to your `onDownload` sink, or downloaded directly); rejects on
@@ -648,6 +694,27 @@ export interface PartRuntime {
648
694
  /** Mount a full parametric-part app from a `PartDefinition`. */
649
695
  export function mount(part: PartDefinition, options: MountOptions): PartRuntime;
650
696
 
697
+ /** Every format `exportParts` can write in this version (`runtime.listExportFormats()` returns copies). */
698
+ export const EXPORT_FORMATS: ReadonlyArray<ExportFormatInfo>;
699
+
700
+ /** The prefix every cut & print kit options error starts with. */
701
+ export const KIT_OPTIONS_ERROR: "cut kit options:";
702
+
703
+ /** The kit's option defaults; `stock: null` is 300 × 300 mm for every stock group. */
704
+ export const KIT_DEFAULTS: Readonly<{
705
+ destination: "own-laser";
706
+ kerf: number;
707
+ colors: "lightburn";
708
+ stock: null;
709
+ margin: number;
710
+ spacing: number;
711
+ printFormat: "stl";
712
+ sets: number;
713
+ }>;
714
+
715
+ /** Normalise kit options — defaults filled, `cutFormat` derived — or throw a `"cut kit options: …"` error. */
716
+ export function validateKitOptions(options: unknown): Required<KitOptions>;
717
+
651
718
  /**
652
719
  * The sub-parts a view shows: declared in the view and `enabled` for these
653
720
  * params, in `Object.keys(part.parts)` order. Handy for app-side view logic.
@@ -8,6 +8,7 @@
8
8
 
9
9
  import type { GeometryKernel, Mesh, Point3, Solid } from "./kernel.js";
10
10
  import type { Derived, FontSource, PartDefinition, ResolvedParams } from "./part.js";
11
+ import type { KitOptions } from "./index.js";
11
12
 
12
13
  export type { Derived, GeometryKernel, Mesh, PartDefinition, ResolvedParams, Solid };
13
14
 
@@ -46,7 +47,8 @@ export type MatchTarget =
46
47
 
47
48
  /** A job the worker loop accepts. */
48
49
  export interface WorkerJob {
49
- type: "generate" | "export-stl" | "export-step" | "export-3mf" | "inspect";
50
+ /** `export-bundle` builds the cut & print kit (a ZIP) from `parts`, as `exportParts({ format: "bundle" })` does. */
51
+ type: "generate" | "export-stl" | "export-step" | "export-3mf" | "export-bundle" | "inspect";
50
52
  view?: string;
51
53
  params?: ResolvedParams;
52
54
  /** `generate`: which sub-parts to build. */
@@ -55,10 +57,12 @@ export interface WorkerJob {
55
57
  parts?: string[];
56
58
  quality?: "preview" | "print";
57
59
  cache?: boolean;
58
- /** Correlation id echoed on every reply. */
59
- jobId?: number;
60
+ /** Correlation id echoed on every reply (the export controller mints strings). */
61
+ jobId?: number | string;
60
62
  /** Single-file export name base. */
61
63
  name?: string;
64
+ /** `export-bundle` only: the kit's download options; absent means every default. */
65
+ options?: KitOptions;
62
66
  /**
63
67
  * `inspect`: score the part's six canonical silhouettes against these. Absent or
64
68
  * empty leaves `match` off the report entirely.