@toolpath/dfm 0.5.0 → 1.0.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/dist/index.d.ts CHANGED
@@ -1,389 +1 @@
1
- import * as react from 'react';
2
- import { ReactNode, FC, KeyboardEvent, Ref, ComponentType, ReactElement, HTMLAttributes } from 'react';
3
- import { D as DfmRule, a as DfmCheck, b as DfmFeature, F as FeatureSheets, U as Units, R as RuleVocabulary, c as ReachCurve, d as FeatureProfile, B as BrokenRule, M as Measurement, e as FeatureRecord } from './feature-record-CfjgDCJU.js';
4
- export { f as MILLING_RULES, g as RuleProcess, T as TURNING_RULES } from './feature-record-CfjgDCJU.js';
5
-
6
- /**
7
- * The rules the list shows, and how to change them. The app owns them —
8
- * where they are kept, and what they start as — so the list works on any
9
- * store and ships no rules of its own.
10
- */
11
- interface DfmRules {
12
- rules: readonly DfmRule[];
13
- /** Adds a rule at the end of the list. */
14
- add: (rule: DfmRule) => void;
15
- /** Replaces the rule with the same id. */
16
- update: (rule: DfmRule) => void;
17
- remove: (id: string) => void;
18
- /** Puts an imported set in place of the list. */
19
- replace: (rules: readonly DfmRule[]) => void;
20
- }
21
- /** The feature, or group of holes, the pointer is over in a list; null for none. */
22
- type Hovered = string | readonly string[] | null;
23
- interface RuleListProps {
24
- rules: DfmRules;
25
- /** The part checked against the rules; null while the analysis runs. */
26
- check: DfmCheck | null;
27
- features: readonly DfmFeature[] | null;
28
- sheets: FeatureSheets | null;
29
- units: Units;
30
- /** The feature being inspected, marked in the lists. */
31
- selected: string | null;
32
- /** The group of holes being inspected, if one is. */
33
- selectedGroup: readonly string[] | null;
34
- onInspect: (tag: string, group?: readonly string[]) => void;
35
- onHover: (hovered: Hovered) => void;
36
- /**
37
- * What the rules can say, and how a broken feature is named: `MILLING_RULES`
38
- * where left out, `TURNING_RULES` for a turned part — whose `features` are
39
- * its stretches (`turnedStretches`) and whose `sheets` are `{}`.
40
- */
41
- vocabulary?: RuleVocabulary;
42
- /**
43
- * At the end of the footer's row, after Copy LLM prompt: the app's own
44
- * buttons — a way back to its default rules, say.
45
- */
46
- actions?: ReactNode;
47
- }
48
-
49
- /**
50
- * The rule list's keys: put them on the whole panel that holds the list, so
51
- * the arrow keys work from its header and buttons too.
52
- */
53
- declare const ruleListKeys: (event: react.KeyboardEvent<HTMLElement>) => void;
54
- /**
55
- * The rules, one row each, each written as the sentence it is — "Holes with
56
- * L/D ≥ 8" — whose words are its fields: change the features, the measure,
57
- * the comparison or the number in place, with no form to open. The sentence
58
- * wraps rather than cuts off, so the whole rule always reads.
59
- *
60
- * Beside it, the rule's colour and how many required features break it; the
61
- * count opens to those features, identical holes gathered into one row as
62
- * the quoting app gathers them. Choosing one inspects it.
63
- *
64
- * Up and down walk the rules and the features of any that are open, a
65
- * feature highlighting as it is reached; right opens a rule (or a group of
66
- * holes) and left shuts it, or from a feature goes back up. Tab moves
67
- * through a rule's words.
68
- *
69
- * The rules come from the app, which keeps them and decides what they start as.
70
- */
71
- declare const RuleList: FC<RuleListProps>;
72
-
73
- interface SwatchProps {
74
- color: string;
75
- label?: string;
76
- onClick?: () => void;
77
- onKeyDown?: (event: KeyboardEvent<HTMLButtonElement>) => void;
78
- /** The list the swatch is a row of, for the arrow keys (see `list-keys.ts`). */
79
- listItem?: string;
80
- className?: string;
81
- ref?: Ref<HTMLButtonElement>;
82
- }
83
- /** A rule's colour, as a dot, one that can be clicked where it can be changed. */
84
- declare const Swatch: FC<SwatchProps>;
85
-
86
- /**
87
- * Arrow keys through a list, for every list on the page: the rules, a rule's
88
- * features, a face's candidate features, the colour swatches.
89
- *
90
- * A list's rows are the elements marked `data-list-item` with the list's
91
- * name, found afresh on each key in the order they are drawn, so rows that
92
- * are shut or not mounted are passed over. Up and down (left and right, for
93
- * a row of swatches) move one row, Home and End to either end. A row marked
94
- * `data-follow` is chosen as it is reached, as a click would — for rows
95
- * whose choosing only highlights, so walking the list shows each in turn.
96
- * From outside the rows (a panel's header, its buttons), the first key goes
97
- * to the chosen row (`aria-pressed`) — or on from it, for a followed row,
98
- * which is already showing — else to the end it points toward.
99
- *
100
- * Keys typed into a field are the field's: a select's own arrows, a number
101
- * being edited.
102
- */
103
- declare const listKeys: (name: string, orientation?: "vertical" | "horizontal") => (event: KeyboardEvent<HTMLElement>) => void;
104
- /** A control that uses the arrow keys itself. A colour well does not. */
105
- declare const isField: (target: EventTarget | null) => boolean;
106
-
107
- interface ReachChartProps {
108
- /** The feature's reach curve, whole: the chart trims it past full height itself. */
109
- curve: ReachCurve;
110
- units: Units;
111
- /**
112
- * The feature beside its walls: drawn to its own width where known, though
113
- * the width is not written on the drawing, because the curve is read out
114
- * from the wall and the feature across is no part of it. Its depth is
115
- * marked, being on the same scale as the walls' heights; a through feature
116
- * has no floor.
117
- */
118
- feature: FeatureProfile;
119
- }
120
-
121
- /**
122
- * The section alone, as a panel shows it: dimensioned, as wide as the panel
123
- * gives it.
124
- */
125
- declare const ReachChart: FC<ReachChartProps>;
126
- /** A larger window's contents: the section, large, with what it is and how to read it. */
127
- declare const ReachDrawing: FC<ReachChartProps>;
128
-
129
- /**
130
- * Where the feature panel keeps which of its sections are open, so a section
131
- * put away stays away from one feature to the next, and from one visit to the
132
- * next. The app supplies it: the package stores nothing of its own.
133
- *
134
- * Sections are named by fixed ids — `rules`, `measurements`, `milling`,
135
- * `reach`, `datasheet`, `raw`, `comparison`, `candidates`, and `candidates-A`,
136
- * `candidates-B`… while comparing faces.
137
- */
138
- interface FoldStore {
139
- /** Whether a section was left open; undefined for one never folded, which then opens as it starts. */
140
- read: (id: string) => boolean | undefined;
141
- write: (id: string, open: boolean) => void;
142
- }
143
- /**
144
- * A fold store over a `Storage` — `localStorage`, `sessionStorage` — under a
145
- * key prefix of the app's: `toolpath.fold.` keeps `toolpath.fold.reach` as
146
- * `open` or `shut`. A storage that is missing, or that refuses (a private
147
- * window, say), leaves the sections folding for as long as they are mounted.
148
- */
149
- declare const storageFolds: (storage: Pick<Storage, "getItem" | "setItem"> | null | undefined, prefix: string) => FoldStore;
150
-
151
- /**
152
- * How the feature panel looks where two apps want it to differ. Every field
153
- * left out takes the first value, which is the CAD viewer's look.
154
- */
155
- interface FeaturePanelLook {
156
- /**
157
- * A broken rule: `sentence` — the rule written out, the figure that broke it
158
- * in grey; or `result` — a short label, the figure in the rule's colour, and
159
- * the line it crossed, faded.
160
- */
161
- rules?: 'sentence' | 'result';
162
- /** The chosen candidate: `grey` and bold, or an `info` blue border and tint. */
163
- selected?: 'grey' | 'info';
164
- /** Secondary text: `pale` grey, or a `strong` grey that reads at full contrast. */
165
- muted?: 'pale' | 'strong';
166
- }
167
-
168
- /** What the panel needs to name a feature: its tag, its type, and the way it is machined from. */
169
- type FeatureIdentity = Pick<DfmFeature, 'tag' | 'featureType' | 'machiningDirection'>;
170
- /**
171
- * Something the app reads for the panel, and how far it has got: the panel
172
- * says what it is waiting on, or what went wrong, in place of the section.
173
- */
174
- type Loadable<T> = {
175
- readonly status: 'loading';
176
- } | {
177
- readonly status: 'error';
178
- /** In the app's own words: the API's answer, or that it asked to wait. */
179
- readonly message: string;
180
- /** Reads it again; left out, there is no Retry. */
181
- readonly retry?: () => void;
182
- /** No Retry before this, in `Date.now()` milliseconds: what a 429's `Retry-After` asks. */
183
- readonly retryAt?: number;
184
- } | {
185
- readonly status: 'ready';
186
- readonly value: T;
187
- };
188
- /** Which of a feature's sections pops out into a window of its own. */
189
- type PopOutId = 'reach' | 'datasheet' | 'raw';
190
- /**
191
- * The app's window for a section popped out of the panel. The panel decides
192
- * when one is open and what is in it; the app draws the frame — moved and
193
- * sized as its page allows — and calls `onClose`. Define it once, at module
194
- * level: one written inline remounts the window on every render. Render it
195
- * through a portal to the page's body: the panel blurs what is behind it,
196
- * which makes the panel the box a `fixed` window inside it is placed in.
197
- */
198
- interface PopOutWindowProps {
199
- id: PopOutId;
200
- title: string;
201
- /** Under the title: the feature it is of. */
202
- subtitle: ReactNode;
203
- icon: ReactElement;
204
- /** In the header, before the close button: a copy button, say. */
205
- action?: ReactNode;
206
- onClose: () => void;
207
- children: ReactNode;
208
- }
209
- type PopOutWindow = ComponentType<PopOutWindowProps>;
210
-
211
- interface FeatureDetailsProps {
212
- feature: FeatureIdentity;
213
- /** Lengths in the reach chart; every other figure comes in written. */
214
- units: Units;
215
- /** The colour of the feature's machining direction, as the part shows it: any CSS colour. */
216
- directionColor: string;
217
- /** The feature beside its walls, for the reach chart: `featureProfile` of its sheet. */
218
- profile: FeatureProfile;
219
- /** In place of the feature's type: `Through hole ⌀ 6.35`. */
220
- label?: ReactNode;
221
- /** A feature the plan cannot do without: shows the REQUIRED pill. Left out, no pill. */
222
- required?: boolean;
223
- /** Turns the camera to the feature: shows a "Show this feature" button. */
224
- onFrame?: () => void;
225
- /** Right of the name: the app's own buttons. */
226
- actions?: ReactNode;
227
- /** At the end of the "Machined from" line: a folder badge, say. */
228
- status?: ReactNode;
229
- /** Under the title, before the sections: a sentence of the app's, its own action. */
230
- children?: ReactNode;
231
- /** The rules it breaks, as rows: see `brokenRules`. */
232
- rules: readonly BrokenRule[];
233
- /** Its measurements and milling considerations: `featureMeasurements`. */
234
- measurements: Loadable<readonly Measurement[]>;
235
- /** Its raw report entry and datasheet, for the reach chart. Null where the app has none. */
236
- record: Loadable<FeatureRecord | null>;
237
- /**
238
- * The app's window, to pop the reach, the datasheet fields and the raw
239
- * record out into, larger. Left out, there are no pop-out buttons.
240
- */
241
- PopOut?: PopOutWindow;
242
- look?: FeaturePanelLook;
243
- folds?: FoldStore;
244
- /**
245
- * Which process the feature is read for: how it is named, the way it is cut
246
- * from, and the heading over its considerations. Milling where left out.
247
- */
248
- vocabulary?: RuleVocabulary;
249
- }
250
- /**
251
- * One feature, as the Engine read it: its name and the way it is machined
252
- * from, then the rules it breaks, what was measured of it, what that asks of
253
- * the milling, and its reach.
254
- *
255
- * Then, shut until opened, every field of its datasheet and its raw API record,
256
- * to read or copy.
257
- *
258
- * Each section folds away under its heading. A section waiting on something
259
- * the app reads says so, and one whose read failed says why, with a Retry.
260
- */
261
- declare const FeatureDetails: FC<FeatureDetailsProps>;
262
-
263
- /**
264
- * Up, down, Home and End through the candidates: put them on whatever holds
265
- * the list — the whole panel, or just the list — as `ruleListKeys` is put on
266
- * the rules. Each row is chosen as it is reached.
267
- */
268
- declare const candidateListKeys: (event: react.KeyboardEvent<HTMLElement>) => void;
269
- /** One feature a face could have meant, as its row says it. */
270
- interface CandidateRow {
271
- readonly feature: FeatureIdentity;
272
- /** In place of the feature's type: `Blind hole ⌀ 6.35 × 4`. */
273
- readonly label?: ReactNode;
274
- /** The dot before it: the colour it is painted, or its direction's. Left out, a gap keeps the rows aligned. */
275
- readonly color?: string;
276
- /** How many rules it breaks: `2 rules`. */
277
- readonly ruleCount?: number;
278
- readonly required?: boolean;
279
- /** Right-aligned in the row: the folder it is in, say. */
280
- readonly detail?: ReactNode;
281
- /** A second line under it: a note on how it overlaps another. */
282
- readonly note?: ReactNode;
283
- /** Beside the row, outside its button: the app's own action on it. */
284
- readonly action?: ReactNode;
285
- }
286
- /** When comparing faces, which face this list is: its letter, and how to stop comparing it. */
287
- interface ComparedFaceList {
288
- readonly index: number;
289
- /** The face being read: its letter is filled. */
290
- readonly active: boolean;
291
- readonly onStop?: () => void;
292
- }
293
- interface CandidateListProps {
294
- /** In the app's order: the first is what a click meant first. */
295
- rows: readonly CandidateRow[];
296
- selected: string | null;
297
- onSelect: (tag: string) => void;
298
- /** A row under the pointer, and leaving it: left out, the rows preview nothing. */
299
- onHover?: (tag: string | null) => void;
300
- /** While comparing faces: this list's face. */
301
- face?: ComparedFaceList;
302
- look?: FeaturePanelLook;
303
- folds?: FoldStore;
304
- /** How the rows' features are named: milling where left out. */
305
- vocabulary?: RuleVocabulary;
306
- }
307
- /**
308
- * Every feature a clicked face belongs to, as rows to choose between: its
309
- * colour, its name and the way it is machined from, how many rules it breaks,
310
- * whether it is required, and whatever the app adds. The keys walk them, each
311
- * chosen as it is reached; see {@link candidateListKeys}.
312
- */
313
- declare const CandidateList: FC<CandidateListProps>;
314
-
315
- /** One compared face: the feature it is read as, and what that feature is and measures. */
316
- interface ComparedFace {
317
- /** Null for a face no feature owns. */
318
- readonly feature: FeatureIdentity | null;
319
- /** Its machining direction's colour, as the part shows it. */
320
- readonly directionColor: string;
321
- /** Whether it is required. Left out on every face, the Required row goes. */
322
- readonly required?: boolean;
323
- readonly rules: readonly BrokenRule[];
324
- readonly measurements: readonly Measurement[];
325
- }
326
- interface ComparisonTableProps {
327
- faces: readonly ComparedFace[];
328
- /** The face being read, whose column head is marked. */
329
- active: number;
330
- /** A column head chosen: that face's feature, to read. */
331
- onSelect: (tag: string, face: number) => void;
332
- onHover?: (tag: string | null) => void;
333
- look?: FeaturePanelLook;
334
- folds?: FoldStore;
335
- }
336
- /**
337
- * What each compared face was read as, side by side: a column per face, its
338
- * feature at the head, and a row for each thing any of them has — its type,
339
- * the way it is machined from, whether it is required, the rules it breaks,
340
- * then every measurement. Rows where the readings disagree stand out; the rest
341
- * are greyed.
342
- */
343
- declare const ComparisonTable: FC<ComparisonTableProps>;
344
-
345
- /** One face being inspected: the features it could mean, and the one being read. */
346
- interface InspectedFace {
347
- /** The face clicked; null for a feature chosen from a list, which has no candidates to show. */
348
- readonly region: number | null;
349
- /** In the app's order: see `CandidateList`. */
350
- readonly rows: readonly CandidateRow[];
351
- readonly selected: string | null;
352
- }
353
- interface FeaturePanelProps {
354
- /** One face, or several while comparing. */
355
- faces: readonly InspectedFace[];
356
- /** Which face's feature the details are of. */
357
- active: number;
358
- /** A group of identical holes chosen together: how many, for the title. */
359
- group?: number;
360
- /** What each compared face was read as: the comparison table, while comparing. */
361
- comparison?: readonly ComparedFace[];
362
- onSelect: (tag: string, face: number) => void;
363
- /** Takes a face out of the comparison. */
364
- onDropFace?: (face: number) => void;
365
- onHover?: (tag: string | null) => void;
366
- onClose: () => void;
367
- /** Spread on the header: an app's drag handle, say. */
368
- headerProps?: HTMLAttributes<HTMLElement>;
369
- className?: string;
370
- look?: FeaturePanelLook;
371
- folds?: FoldStore;
372
- /** How the candidates are named: milling where left out (see `FeatureDetails`). */
373
- vocabulary?: RuleVocabulary;
374
- /** The active face's feature: its `<FeatureDetails>`. */
375
- children?: ReactNode;
376
- }
377
- /**
378
- * The feature panel as a card: what a click on the part found — every feature
379
- * the face belongs to, then the details of the one being read — or, with
380
- * several faces shift-clicked, each face's candidates under a letter and a
381
- * comparison of what each was read as.
382
- *
383
- * It fills what it is put in: where the card sits, and whether it moves, is
384
- * the app's. Escape calls `onClose`, and the arrow keys walk the candidates
385
- * from anywhere in it.
386
- */
387
- declare const FeaturePanel: FC<FeaturePanelProps>;
388
-
389
- export { CandidateList, type CandidateListProps, type CandidateRow, type ComparedFace, type ComparedFaceList, ComparisonTable, type ComparisonTableProps, type DfmRules, FeatureDetails, type FeatureDetailsProps, type FeatureIdentity, FeaturePanel, type FeaturePanelLook, type FeaturePanelProps, type FoldStore, type Hovered, type InspectedFace, type Loadable, type PopOutId, type PopOutWindow, type PopOutWindowProps, ReachChart, type ReachChartProps, ReachDrawing, RuleList, type RuleListProps, RuleVocabulary, Swatch, type SwatchProps, candidateListKeys, isField, listKeys, ruleListKeys, storageFolds };
1
+ export { BrokenRule, CRITICAL_COLOR, ClearanceFit, DfmCheck, DfmFeature, DfmHit, DfmMetric, DfmOp, DfmQuantity, DfmRule, DfmSources, DfmSubject, FILE_KIND, FaceTriangles, FactsKind, FeatureAcross, FeaturePinch, FeatureProfile, FeatureRecord, FeatureRow, FeatureSheet, FeatureSheets, FeatureThreading, FeatureUndercut, MAX_DATASHEET_FIELDS, MILLING_RULES, Measurement, OPS, PINCH_TOOL_MM, PRESENCE_METRIC, PinchDisc, PinchMark, PlacedTool, QUICK_SUBJECTS, RANGE_HIGHS, RANGE_LOWS, RULE_COLORS, RangeHigh, RangeLow, ReachCurve, ReportFeature, RuleProcess, RuleResult, RuleSetFile, RuleVocabulary, SurfaceToolKind, TURNING_RULES, TurnedFactsKind, TurnedReportFeature, TurnedStretch, Units, Vec3, WARNING_COLOR, brokenRules, checkPart, checkTurnedPart, compareColors, datasheetFields, describeRule, dfmFeatures, directionLabel, featureColor, featureMeasurements, featureProfile, featureRows, featureSheet, featureTypeLabel, formatMeasured, fromField, highOf, hitFigure, isNoReading, isSurfaceType, lengthValue, llmRulePrompt, lowOf, makeRule, maxBallDiameter, metricInfo, metricsForSubject, opSymbol, parseRuleSetFile, parseRules, peakHeight, pinchLabel, pinchMark, placePinchTool, quantityUnit, readPinch, readReachCurve, runStart, sameDepth, serializeRuleSet, subjectLabel, toField, trimmedCurve, turnedStretches, turnedTypeLabel, unitLabel, upperOf, withMetric, withOp, withSubject, withSurroundedFaces } from './model/index.js';