any2orca 0.12.1 → 0.13.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/CHANGELOG.md +6 -0
- package/README.md +2 -2
- package/dist/cli/commands/convert.js +3 -6
- package/dist/engine/carrySourceLayerHeight.js +2 -2
- package/dist/engine/runConvertPipeline.d.ts +9 -2
- package/dist/engine/runConvertPipeline.js +24 -6
- package/dist/explain/filamentNotes.d.ts +17 -1
- package/dist/explain/filamentNotes.js +28 -12
- package/dist/explain/notes.d.ts +39 -0
- package/dist/explain/notes.js +73 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +2 -1
- package/dist/project.d.ts +16 -8
- package/dist/project.js +54 -45
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# any2orca
|
|
2
2
|
|
|
3
|
+
## 0.13.0
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
- `report.notes`, every note of a conversion in one list sorted by topic (`NOTE_TOPICS`: filament diameter, nozzle size, profile, filament presets, reading the file, settings, plates), each topic's headline first, each note once with the filament slots it names, in one style (a capital at the start, a period at the end, "0.4 mm"). It holds the sentences of `report.warnings`, `report.profileNotes` and `filamentNotes()`, which stay as they are, with their overlap now documented. The command line prints the notes with their topics (`note [nozzle]: ...`). Under `--nozzle match`, a filament tuned for another nozzle size now says it was converted with the U1's closest profile rather than "your nozzles". `filamentPresetNotes()` gives the filament naming option's sentences with their slots.
|
|
8
|
+
|
|
3
9
|
## 0.12.1
|
|
4
10
|
|
|
5
11
|
### Features
|
package/README.md
CHANGED
|
@@ -47,7 +47,7 @@ import { bundledProfileSource } from "any2orca/node";
|
|
|
47
47
|
|
|
48
48
|
const { output, report } = await convert(await readFile("model.3mf"), { profiles: bundledProfileSource() });
|
|
49
49
|
await writeFile("model_U1.3mf", output);
|
|
50
|
-
console.log(report.profile.displayName, report.
|
|
50
|
+
console.log(report.profile.displayName, report.notes);
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
In a UI, open once and convert as often as the user changes options:
|
|
@@ -137,7 +137,7 @@ A call that fails throws `Any2orcaError`. Its `code` is stable, so a UI can bran
|
|
|
137
137
|
| `invalid_preset` | A preset or presets file that is malformed, over a limit, or can't be used with the options given |
|
|
138
138
|
| `preset_base_unknown` | A preset can't be made from this file: it isn't set up for a profile in the catalog |
|
|
139
139
|
|
|
140
|
-
The error's message, and every entry in `report.
|
|
140
|
+
The error's message, and every entry in `report.notes`, is written for the person converting and doesn't name the library. Any app can show it as it is. `notes` is one list sorted by topic (`NOTE_TOPICS`: `filament-diameter`, `nozzle`, `profile`, `filament-presets`, `source`, `settings`, `plates`), each topic's headline first, every note once, with the filament slots it names (`slots`, 1-based); `report.warnings`, `report.profileNotes` and `filamentNotes(report)` hold the same sentences in older shapes, so an app shows `notes` or those, not both. The wording can change in any release, so branch on the error's `code`, or on whether there are any notes at all, never on the text.
|
|
141
141
|
|
|
142
142
|
## Strict content security policies
|
|
143
143
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
import { existsSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
3
|
import { basename, dirname, extname, join, resolve } from "node:path";
|
|
4
4
|
import { Any2orcaError } from "../../errors.js";
|
|
5
|
-
import { filamentNotes } from "../../explain/filamentNotes.js";
|
|
6
5
|
import { formatWhatChanged } from "../../explain/whatChanged.js";
|
|
7
6
|
import { openProject, unwrapBundle } from "../../project.js";
|
|
8
7
|
import { archiveOriginal } from "../archiveMove.js";
|
|
@@ -70,11 +69,9 @@ function logReport(report, verbose, logger) {
|
|
|
70
69
|
for (const c of report.preset.changes)
|
|
71
70
|
logger.log(` preset: ${c.key} ${c.stock} -> ${c.yours}${c.aboveStock ? " (above stock)" : ""}`);
|
|
72
71
|
}
|
|
73
|
-
// The same sentences the web app shows
|
|
74
|
-
for (const note of
|
|
75
|
-
logger.log(` note: ${note}`);
|
|
76
|
-
for (const w of report.warnings)
|
|
77
|
-
logger.log(` warning: ${w}`);
|
|
72
|
+
// The same sentences the web app shows, in the same order, each with its topic.
|
|
73
|
+
for (const note of report.notes)
|
|
74
|
+
logger.log(` note [${note.topic}]: ${note.text}`);
|
|
78
75
|
if (report.retiredProfile)
|
|
79
76
|
logger.log(' note: run "any2orca profiles" for the current list.');
|
|
80
77
|
if (verbose) {
|
|
@@ -36,6 +36,6 @@ export function carrySourceLayerHeight(settings, sourceSettings, machineSettings
|
|
|
36
36
|
return;
|
|
37
37
|
settings.layer_height = String(kept);
|
|
38
38
|
warnings.push(kept === source
|
|
39
|
-
? ` WARN: the U1 has no ${source}mm profile for this nozzle size, so your file's ${source}mm layer height was kept, on the closest profile (${tier}mm).`
|
|
40
|
-
: ` WARN: your file's ${source}mm layer height is outside what the U1 supports for this nozzle size, so it was set to ${kept}mm, on the closest profile (${tier}mm).`);
|
|
39
|
+
? ` WARN: the U1 has no ${source} mm profile for this nozzle size, so your file's ${source} mm layer height was kept, on the closest profile (${tier} mm).`
|
|
40
|
+
: ` WARN: your file's ${source} mm layer height is outside what the U1 supports for this nozzle size, so it was set to ${kept} mm, on the closest profile (${tier} mm).`);
|
|
41
41
|
}
|
|
@@ -4,6 +4,7 @@ import type { PrinterFilamentPresets } from "../profiles.js";
|
|
|
4
4
|
import { type ResolvedAboveStockChoice } from "./aboveStock.js";
|
|
5
5
|
import type { JsonRecord } from "./types.js";
|
|
6
6
|
import { type ChangeItem, type ChangeReason } from "../explain/whatChanged.js";
|
|
7
|
+
import { type ConvertNote } from "../explain/notes.js";
|
|
7
8
|
/**
|
|
8
9
|
* Everything the pipeline needs to know about a printer + profile,
|
|
9
10
|
* independent of where it came from (the profile catalog, or a fixture
|
|
@@ -55,10 +56,12 @@ export interface RunConvertPipelineOptions {
|
|
|
55
56
|
*/
|
|
56
57
|
aboveStock?: ResolvedAboveStockChoice;
|
|
57
58
|
/**
|
|
58
|
-
* The nozzle size the file is for
|
|
59
|
-
* item when they differ. Absent when
|
|
59
|
+
* The nozzle size the file is for, how it was chosen ("match" for the creator's size) and the sizes the creator's
|
|
60
|
+
* project uses (see matchProfile), for a What changed item and the notes' wording when they differ. Absent when
|
|
61
|
+
* the profile was given outright.
|
|
60
62
|
*/
|
|
61
63
|
nozzle?: {
|
|
64
|
+
choice?: string;
|
|
62
65
|
size: string;
|
|
63
66
|
sourceSizes: readonly string[];
|
|
64
67
|
};
|
|
@@ -73,6 +76,10 @@ export interface RunConvertPipelineResult {
|
|
|
73
76
|
warnings: string[];
|
|
74
77
|
/** Notes to show before every other: a filament the creator's printer took at another diameter. Also in `warnings`. */
|
|
75
78
|
leadWarnings: string[];
|
|
79
|
+
/** The lead warnings with their topic and slots (1-based), for `report.notes`. */
|
|
80
|
+
leadNotes: ConvertNote[];
|
|
81
|
+
/** The warnings about placing objects on the U1's plates (in `warnings` too), for `report.notes`. */
|
|
82
|
+
plateWarnings: string[];
|
|
76
83
|
/** What the conversion changed, grouped by why (see explain/whatChanged.ts). */
|
|
77
84
|
changes: ReadonlyMap<ChangeReason, ChangeItem[]>;
|
|
78
85
|
}
|
|
@@ -21,6 +21,7 @@ import { offSizeDiameter, setFilamentDiameter, U1_FILAMENT_DIAMETER } from "./se
|
|
|
21
21
|
import { remapBrimType } from "./remapBrimType.js";
|
|
22
22
|
import { resizeFlushVolumes } from "./resizeFlushVolumes.js";
|
|
23
23
|
import { ChangeTracker, valueText } from "../explain/whatChanged.js";
|
|
24
|
+
import { noteFrom } from "../explain/notes.js";
|
|
24
25
|
import { isGcodeKey, isSpoolKey, U1_VALUE_KEYS } from "./policy.js";
|
|
25
26
|
const U1_VALUE_KEY_SET = new Set(U1_VALUE_KEYS);
|
|
26
27
|
function numbers(value) {
|
|
@@ -78,6 +79,7 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
78
79
|
const sourceSlots = slots;
|
|
79
80
|
const offSizeSlots = new Set(slots.flatMap((slot, i) => (offSizeDiameter(slot.filament_diameter ?? filamentKeyArrays?.filament_diameter?.[i]) === null ? [] : [i])));
|
|
80
81
|
const leadWarnings = [];
|
|
82
|
+
const leadNotes = [];
|
|
81
83
|
// What changed items for those slots, added under the firmware group once the tracker exists.
|
|
82
84
|
const offSizeItems = [];
|
|
83
85
|
const missingPresetsWarning = (missing) => warnings.push(` WARN: the profile catalog has no settings for ${missing.join(", ")}, so only ${missing.length === 1 ? "its name" : "their names"} changed. Update the profile catalog.`);
|
|
@@ -118,12 +120,18 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
118
120
|
const renamedTo = renamedFilaments.find((r) => r.slot === i)?.after ?? (typeof slots[i]?.filament_settings_id === "string" && slots[i].filament_settings_id !== name ? String(slots[i].filament_settings_id) : null);
|
|
119
121
|
const withSettings = appliedPresets.some((a) => a.slot === i);
|
|
120
122
|
const was = `Filament ${i + 1} was ${name} (${diameter} mm) on the creator's printer. The U1 takes ${U1_FILAMENT_DIAMETER} mm filament, so`;
|
|
123
|
+
const lead = (text) => {
|
|
124
|
+
leadWarnings.push(text);
|
|
125
|
+
const note = noteFrom("filament-diameter", text, [i + 1]);
|
|
126
|
+
if (note)
|
|
127
|
+
leadNotes.push(note);
|
|
128
|
+
};
|
|
121
129
|
if (renamedTo) {
|
|
122
|
-
|
|
130
|
+
lead(` WARN: ${was} it's set to ${renamedTo}${withSettings ? " with that preset's settings" : ""}. Load ${U1_FILAMENT_DIAMETER} mm ${type}; the creator's filament may print differently from the preset's, so check its settings before printing.`);
|
|
123
131
|
offSizeItems.push({ label: `Filament ${i + 1} set to ${renamedTo}`, before: `${name} (${diameter} mm)`, after: renamedTo, note: `the U1 takes ${U1_FILAMENT_DIAMETER} mm filament; the creator's values were for ${diameter} mm${withSettings ? "; the preset's settings are used" : ""}` });
|
|
124
132
|
}
|
|
125
133
|
else {
|
|
126
|
-
|
|
134
|
+
lead(` WARN: ${was} its diameter is set to ${U1_FILAMENT_DIAMETER} mm. No U1 preset fits its material, so its other settings are the creator's, tuned for ${diameter} mm; load ${U1_FILAMENT_DIAMETER} mm ${type} and check them before printing.`);
|
|
127
135
|
}
|
|
128
136
|
}
|
|
129
137
|
// A filament tuned for another nozzle size than the file is for: its flow, max volumetric speed, pressure
|
|
@@ -166,13 +174,21 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
166
174
|
const n = nums.map((i) => String(i + 1));
|
|
167
175
|
return n.length === 1 ? `Filament ${n[0]} was` : `Filaments ${n.slice(0, -1).join(", ")} and ${n[n.length - 1]} were`;
|
|
168
176
|
};
|
|
177
|
+
// Under "match" the size is the closest U1 profile's, not the user's choice.
|
|
178
|
+
const forSize = options.nozzle?.choice === "match" ? `converted with the U1's ${options.targetNozzleDiameter} mm profile` : `converted for your ${options.targetNozzleDiameter} mm nozzles`;
|
|
179
|
+
const lead = (text, slots) => {
|
|
180
|
+
leadWarnings.push(text);
|
|
181
|
+
const note = noteFrom("nozzle", text, slots.map((i) => i + 1));
|
|
182
|
+
if (note)
|
|
183
|
+
leadNotes.push(note);
|
|
184
|
+
};
|
|
169
185
|
for (const [size, group] of [...bySize].sort((a, b) => Number(a[0]) - Number(b[0]))) {
|
|
170
186
|
const taken = group.slots.filter((i) => !group.unmatched.includes(i));
|
|
171
187
|
if (taken.length > 0) {
|
|
172
|
-
|
|
188
|
+
lead(` WARN: ${listed(taken)} tuned for a ${size} mm nozzle on the creator's printer; ${forSize}, ${taken.length === 1 ? "it takes" : "they take"} the U1's calibration for ${taken.length === 1 ? "its material" : "their materials"} from ${[...group.presets].join(", ")} (flow, max volumetric speed, pressure advance, retraction, cooling) and ${taken.length === 1 ? "keeps" : "keep"} the creator's temperatures and other filament facts. The colors are unchanged, so a preset of your own can be chosen in Snapmaker Orca.`, taken);
|
|
173
189
|
}
|
|
174
190
|
if (group.unmatched.length > 0) {
|
|
175
|
-
|
|
191
|
+
lead(` WARN: ${listed(group.unmatched)} tuned for a ${size} mm nozzle on the creator's printer, and no U1 preset fits ${group.unmatched.length === 1 ? "its" : "their"} material, so the settings are the creator's; check them before printing on ${options.nozzle?.choice === "match" ? "" : "your "}${options.targetNozzleDiameter} mm nozzles.`, group.unmatched);
|
|
176
192
|
}
|
|
177
193
|
}
|
|
178
194
|
}
|
|
@@ -196,7 +212,7 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
196
212
|
const highFlowSelection = resolveHighFlowSelection(request.highFlowHotends, toolheads);
|
|
197
213
|
const highFlowApplies = highFlowSelection !== null && printer.highFlowSupported === true;
|
|
198
214
|
if (highFlowSelection !== null && !highFlowApplies) {
|
|
199
|
-
warnings.push(" WARN: high-flow hotends were requested, but Snapmaker has no high-flow option for this nozzle size (only 0.
|
|
215
|
+
warnings.push(" WARN: high-flow hotends were requested, but Snapmaker has no high-flow option for this nozzle size (only 0.4 mm), so the project is set up for standard hotends.");
|
|
200
216
|
}
|
|
201
217
|
const highFlowValues = highFlowApplies ? (p.highFlowOverrides ?? {}) : {};
|
|
202
218
|
const highFlowTuning = Object.keys(highFlowValues).length > 0
|
|
@@ -313,7 +329,7 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
313
329
|
if (options.nozzle && options.nozzle.sourceSizes.some((s) => s !== options.nozzle.size)) {
|
|
314
330
|
const sizes = options.nozzle.sourceSizes;
|
|
315
331
|
tracker.add("yours", {
|
|
316
|
-
label: `Converted for your ${options.nozzle.size} mm nozzles`,
|
|
332
|
+
label: options.nozzle.choice === "match" ? `Converted for ${options.nozzle.size} mm nozzles` : `Converted for your ${options.nozzle.size} mm nozzles`,
|
|
317
333
|
before: sizes.length > 0 ? `${sizes.join(", ")} mm` : null,
|
|
318
334
|
after: `${options.nozzle.size} mm`,
|
|
319
335
|
note: sizes.length > 1 ? "the creator's project mixes nozzle sizes; Snapmaker Orca allows one for all four toolheads" : "the creator's project is set up for another nozzle size",
|
|
@@ -379,6 +395,8 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
379
395
|
},
|
|
380
396
|
warnings,
|
|
381
397
|
leadWarnings,
|
|
398
|
+
leadNotes,
|
|
399
|
+
plateWarnings: shiftWarnings.filter((w) => w.includes("WARN")),
|
|
382
400
|
changes: tracker.build(request.projectSettings, p.baselineProjectSettings, newSettings, (key) => {
|
|
383
401
|
if (U1_VALUE_KEY_SET.has(key))
|
|
384
402
|
return "always the U1's own value";
|
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
import type { ConvertReport } from "../project.js";
|
|
2
|
+
/** The parts of a report the filament naming option's notes are made from. */
|
|
3
|
+
export type NotesReport = Pick<ConvertReport, "filamentPresets" | "filamentComplianceFallback" | "filamentComplianceUnchanged">;
|
|
4
|
+
/** A sentence of {@link filamentNotes} and the filaments it's about. */
|
|
5
|
+
export interface FilamentPresetNote {
|
|
6
|
+
/** The filament slots the sentence names, counting from 1 as slicers show them; none when it's about product lines rather than slots. */
|
|
7
|
+
slots: number[];
|
|
8
|
+
/** The sentence, with its final period. */
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* The sentences of {@link filamentNotes}, each with the slots it names. `group` splits the filaments of one preset
|
|
13
|
+
* into separate sentences when they're there for different reasons (one tuned for another nozzle size, one the
|
|
14
|
+
* naming option chose): filaments with the same preset and the same group share a sentence.
|
|
15
|
+
*/
|
|
16
|
+
export declare function filamentPresetNotes(report: NotesReport, group?: (slot: number) => string): FilamentPresetNote[];
|
|
2
17
|
/**
|
|
3
18
|
* What the Snapmaker or Generic filament option did, one sentence per note: which filaments use a preset's own
|
|
4
19
|
* settings and what that replaced, which use Generic because Snapmaker makes no preset for them, and which kept
|
|
5
20
|
* the creator's name and settings because no preset fits. Empty when the option wasn't used or changed nothing.
|
|
21
|
+
* The same sentences are in `report.notes`, with their slots and topic.
|
|
6
22
|
*/
|
|
7
|
-
export declare function filamentNotes(report:
|
|
23
|
+
export declare function filamentNotes(report: NotesReport): string[];
|
|
@@ -23,20 +23,24 @@ const NAMED = [
|
|
|
23
23
|
];
|
|
24
24
|
const list = (items) => (items.length <= 1 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`);
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* The sentences of {@link filamentNotes}, each with the slots it names. `group` splits the filaments of one preset
|
|
27
|
+
* into separate sentences when they're there for different reasons (one tuned for another nozzle size, one the
|
|
28
|
+
* naming option chose): filaments with the same preset and the same group share a sentence.
|
|
29
29
|
*/
|
|
30
|
-
export function
|
|
30
|
+
export function filamentPresetNotes(report, group = () => "") {
|
|
31
31
|
const notes = [];
|
|
32
32
|
const byPreset = new Map();
|
|
33
|
-
for (const p of report.filamentPresets ?? [])
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
for (const p of report.filamentPresets ?? []) {
|
|
34
|
+
const key = `${group(p.slot)}\u0000${p.preset}`;
|
|
35
|
+
byPreset.set(key, [...(byPreset.get(key) ?? []), p]);
|
|
36
|
+
}
|
|
37
|
+
for (const [key, slots] of byPreset) {
|
|
38
|
+
const preset = key.slice(key.indexOf("\u0000") + 1);
|
|
36
39
|
const changed = slots.find((s) => s.changed.length > 0)?.changed ?? [];
|
|
37
|
-
const
|
|
40
|
+
const numbers = slots.map((s) => s.slot);
|
|
41
|
+
const which = `${slots.length === 1 ? "Filament" : "Filaments"} ${list(numbers.map(String))}`;
|
|
38
42
|
if (changed.length === 0) {
|
|
39
|
-
notes.push(`${which} ${slots.length === 1 ? "uses" : "use"} ${preset}'s own settings, which match the creator's.`);
|
|
43
|
+
notes.push({ slots: numbers, text: `${which} ${slots.length === 1 ? "uses" : "use"} ${preset}'s own settings, which match the creator's.` });
|
|
40
44
|
continue;
|
|
41
45
|
}
|
|
42
46
|
// The settings people know by name first; the rest as a count.
|
|
@@ -47,14 +51,26 @@ export function filamentNotes(report) {
|
|
|
47
51
|
const rest = changed.length - named.length;
|
|
48
52
|
const others = `${rest} other setting${rest === 1 ? "" : "s"}`;
|
|
49
53
|
const what = named.length === 0 ? others : rest > 0 ? `${named.join(", ")}, and ${others}` : list(named);
|
|
50
|
-
notes.push(`${which} ${slots.length === 1 ? "uses" : "use"} ${preset}'s own settings instead of the creator's: ${what}.`);
|
|
54
|
+
notes.push({ slots: numbers, text: `${which} ${slots.length === 1 ? "uses" : "use"} ${preset}'s own settings instead of the creator's: ${what}.` });
|
|
51
55
|
}
|
|
52
56
|
const fallback = report.filamentComplianceFallback ?? [];
|
|
53
57
|
if (fallback.length > 0)
|
|
54
|
-
notes.push(`Snapmaker makes no preset for ${list(fallback)} at this nozzle size, so ${fallback.length === 1 ? "it uses" : "those use"} Generic.`);
|
|
58
|
+
notes.push({ slots: [], text: `Snapmaker makes no preset for ${list(fallback)} at this nozzle size, so ${fallback.length === 1 ? "it uses" : "those use"} Generic.` });
|
|
55
59
|
const unchanged = report.filamentComplianceUnchanged ?? [];
|
|
56
60
|
if (unchanged.length > 0) {
|
|
57
|
-
notes.push(
|
|
61
|
+
notes.push({
|
|
62
|
+
slots: [],
|
|
63
|
+
text: `No Snapmaker or Generic preset fits ${list(unchanged)} at this nozzle size, so ${unchanged.length === 1 ? "its name and settings stay" : "their names and settings stay"} as the creator had them. Snapmaker Space may refuse this file.`,
|
|
64
|
+
});
|
|
58
65
|
}
|
|
59
66
|
return notes;
|
|
60
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* What the Snapmaker or Generic filament option did, one sentence per note: which filaments use a preset's own
|
|
70
|
+
* settings and what that replaced, which use Generic because Snapmaker makes no preset for them, and which kept
|
|
71
|
+
* the creator's name and settings because no preset fits. Empty when the option wasn't used or changed nothing.
|
|
72
|
+
* The same sentences are in `report.notes`, with their slots and topic.
|
|
73
|
+
*/
|
|
74
|
+
export function filamentNotes(report) {
|
|
75
|
+
return filamentPresetNotes(report).map((note) => note.text);
|
|
76
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The topics a note can have, in the order the notes come. First what the user has to act on before printing (other
|
|
3
|
+
* filament to load), then why the file is for this nozzle size and profile, then the filament naming option, then
|
|
4
|
+
* what reading the file and converting its settings and plates had to say.
|
|
5
|
+
*/
|
|
6
|
+
export declare const NOTE_TOPICS: readonly ["filament-diameter", "nozzle", "profile", "filament-presets", "source", "settings", "plates"];
|
|
7
|
+
/** The topics this release of the library gives its notes. */
|
|
8
|
+
export type KnownNoteTopic = (typeof NOTE_TOPICS)[number];
|
|
9
|
+
/** A note's topic: one of `NOTE_TOPICS`, or a value a newer library adds; show an unknown one as it is, after the known ones. */
|
|
10
|
+
export type NoteTopic = KnownNoteTopic | (string & {});
|
|
11
|
+
/** One note for the user, in the result's own words. */
|
|
12
|
+
export interface ConvertNote {
|
|
13
|
+
/** What the note is about; `NOTE_TOPICS` lists the values and their order. */
|
|
14
|
+
topic: NoteTopic;
|
|
15
|
+
/** The filament slots the note is about, counting from 1 as slicers show them. Absent when it's about the whole file. */
|
|
16
|
+
slots?: number[];
|
|
17
|
+
/** One or more sentences: a capital at the start, a period at the end, "0.4 mm" with a space. */
|
|
18
|
+
text: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Same cleanup every UI applies before showing warnings: drop routine
|
|
22
|
+
* bookkeeping lines, strip the internal "WARN" and "note" markers and
|
|
23
|
+
* internal file names.
|
|
24
|
+
*/
|
|
25
|
+
export declare function cleanWarnings(warnings: readonly string[]): string[];
|
|
26
|
+
/**
|
|
27
|
+
* The one sentence style: `cleanWarnings`' cleanup (no "WARN:" marker, no file names, plain text), then a capital
|
|
28
|
+
* at the start unless the first word is a setting key, and a final period. The source strings write "0.4 mm" with a
|
|
29
|
+
* space themselves (a name quoted from the file, "0.20mm QUALITY", stays as it is). Returns null for a routine line
|
|
30
|
+
* `cleanWarnings` drops.
|
|
31
|
+
*/
|
|
32
|
+
export declare function styleNote(text: string): string | null;
|
|
33
|
+
/** A note from a raw warning line; null when the line is routine. */
|
|
34
|
+
export declare function noteFrom(topic: NoteTopic, text: string, slots?: readonly number[]): ConvertNote | null;
|
|
35
|
+
/**
|
|
36
|
+
* Sorted by topic in `NOTE_TOPICS`' order, unknown topics last in the order given; within a topic the order given
|
|
37
|
+
* stays, so a caller puts each topic's headline first.
|
|
38
|
+
*/
|
|
39
|
+
export declare function sortNotes(notes: readonly ConvertNote[]): ConvertNote[];
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* A result's notes as one list a UI can show in its given order: every sentence `warnings`, `profileNotes` and
|
|
4
|
+
* `filamentNotes()` hold, each once, with the topic it's about and the filaments it names, sorted by topic with
|
|
5
|
+
* each topic's headline first.
|
|
6
|
+
*/
|
|
7
|
+
import { plainText } from "../plainText.js";
|
|
8
|
+
/**
|
|
9
|
+
* The topics a note can have, in the order the notes come. First what the user has to act on before printing (other
|
|
10
|
+
* filament to load), then why the file is for this nozzle size and profile, then the filament naming option, then
|
|
11
|
+
* what reading the file and converting its settings and plates had to say.
|
|
12
|
+
*/
|
|
13
|
+
export const NOTE_TOPICS = ["filament-diameter", "nozzle", "profile", "filament-presets", "source", "settings", "plates"];
|
|
14
|
+
/**
|
|
15
|
+
* Same cleanup every UI applies before showing warnings: drop routine
|
|
16
|
+
* bookkeeping lines, strip the internal "WARN" and "note" markers and
|
|
17
|
+
* internal file names.
|
|
18
|
+
*/
|
|
19
|
+
export function cleanWarnings(warnings) {
|
|
20
|
+
return warnings
|
|
21
|
+
.map((w) => w.trim())
|
|
22
|
+
.filter((w) => {
|
|
23
|
+
if (!w)
|
|
24
|
+
return false;
|
|
25
|
+
if (w.includes("SKIP filament_colour: list length mismatch"))
|
|
26
|
+
return false;
|
|
27
|
+
if (w.includes("left unchanged"))
|
|
28
|
+
return false;
|
|
29
|
+
if (w.includes("ignored") && w.includes("trailing non-JSON"))
|
|
30
|
+
return false;
|
|
31
|
+
return true;
|
|
32
|
+
})
|
|
33
|
+
.map((w) => w
|
|
34
|
+
.replace(/^WARN:\s*/i, "")
|
|
35
|
+
.replace(/^WARN\s+/i, "")
|
|
36
|
+
.replace(/^note:\s*/i, "")
|
|
37
|
+
.replace(/\s+in\s+model_settings\.config\.?/i, "")
|
|
38
|
+
.replace(/\s+in\s+3D\/3dmodel\.model\.?/i, "")
|
|
39
|
+
.replace(/\s+in\s+[A-Za-z0-9_./-]+\.(config|model|xml)\.?/i, "")
|
|
40
|
+
.replace(/\.$/, ""))
|
|
41
|
+
// Warnings can quote names from the file; they're prose for people, so they never carry control characters.
|
|
42
|
+
.map(plainText);
|
|
43
|
+
}
|
|
44
|
+
const TOPIC_ORDER = new Map(NOTE_TOPICS.map((topic, i) => [topic, i]));
|
|
45
|
+
/**
|
|
46
|
+
* The one sentence style: `cleanWarnings`' cleanup (no "WARN:" marker, no file names, plain text), then a capital
|
|
47
|
+
* at the start unless the first word is a setting key, and a final period. The source strings write "0.4 mm" with a
|
|
48
|
+
* space themselves (a name quoted from the file, "0.20mm QUALITY", stays as it is). Returns null for a routine line
|
|
49
|
+
* `cleanWarnings` drops.
|
|
50
|
+
*/
|
|
51
|
+
export function styleNote(text) {
|
|
52
|
+
const [clean] = cleanWarnings([text]);
|
|
53
|
+
if (clean === undefined)
|
|
54
|
+
return null;
|
|
55
|
+
const firstWord = clean.split(/\s/, 1)[0] ?? "";
|
|
56
|
+
const capitalized = /^[a-z]/.test(clean) && !firstWord.includes("_") ? clean[0].toUpperCase() + clean.slice(1) : clean;
|
|
57
|
+
return /[.!?]$/.test(capitalized) ? capitalized : `${capitalized}.`;
|
|
58
|
+
}
|
|
59
|
+
/** A note from a raw warning line; null when the line is routine. */
|
|
60
|
+
export function noteFrom(topic, text, slots) {
|
|
61
|
+
const styled = styleNote(text);
|
|
62
|
+
if (styled === null)
|
|
63
|
+
return null;
|
|
64
|
+
return { topic, ...(slots && slots.length > 0 ? { slots: [...slots] } : {}), text: styled };
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Sorted by topic in `NOTE_TOPICS`' order, unknown topics last in the order given; within a topic the order given
|
|
68
|
+
* stays, so a caller puts each topic's headline first.
|
|
69
|
+
*/
|
|
70
|
+
export function sortNotes(notes) {
|
|
71
|
+
const rank = (topic) => TOPIC_ORDER.get(topic) ?? NOTE_TOPICS.length;
|
|
72
|
+
return notes.map((note, i) => ({ note, i })).sort((a, b) => rank(a.note.topic) - rank(b.note.topic) || a.i - b.i).map(({ note }) => note);
|
|
73
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -35,7 +35,10 @@ export type { DiffAttention, DiffGroup, DiffGroupName, DiffOptions, DiffRow, Dif
|
|
|
35
35
|
export { diffReference, presetDiffSide, stockDiffSide } from "./diff/reference.js";
|
|
36
36
|
export type { SettingGroup, SettingInfo } from "./diff/settingsCatalog.js";
|
|
37
37
|
export { formatWhatChanged, CHANGE_REASONS } from "./explain/whatChanged.js";
|
|
38
|
-
export { filamentNotes } from "./explain/filamentNotes.js";
|
|
38
|
+
export { filamentNotes, filamentPresetNotes } from "./explain/filamentNotes.js";
|
|
39
|
+
export type { FilamentPresetNote, NotesReport } from "./explain/filamentNotes.js";
|
|
40
|
+
export { NOTE_TOPICS } from "./explain/notes.js";
|
|
41
|
+
export type { ConvertNote, KnownNoteTopic, NoteTopic } from "./explain/notes.js";
|
|
39
42
|
export type { ChangeGroup, ChangeItem, ChangeReason, KnownChangeReason, WhatChanged } from "./explain/whatChanged.js";
|
|
40
43
|
export { extractPreset } from "./presets/extractPreset.js";
|
|
41
44
|
export { parsePresetFile, serializePresets, resolvePreset, withoutChanges, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES } from "./presets/preset.js";
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,8 @@ export { diffSettings, DIFF_ATTENTIONS, DIFF_STATUSES } from "./diff/diffSetting
|
|
|
23
23
|
export { valueLayoutNotes, VALUE_LAYOUTS } from "./diff/valueLayout.js";
|
|
24
24
|
export { diffReference, presetDiffSide, stockDiffSide } from "./diff/reference.js";
|
|
25
25
|
export { formatWhatChanged, CHANGE_REASONS } from "./explain/whatChanged.js";
|
|
26
|
-
export { filamentNotes } from "./explain/filamentNotes.js";
|
|
26
|
+
export { filamentNotes, filamentPresetNotes } from "./explain/filamentNotes.js";
|
|
27
|
+
export { NOTE_TOPICS } from "./explain/notes.js";
|
|
27
28
|
export { extractPreset } from "./presets/extractPreset.js";
|
|
28
29
|
export { parsePresetFile, serializePresets, resolvePreset, withoutChanges, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES } from "./presets/preset.js";
|
|
29
30
|
export { buildStatsEvent, parseStatsEvent, receiveStatsEvent, resolveStatsConsent, STATS_MATCH_SOURCES } from "./telemetry.js";
|
package/dist/project.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { type BundleEntry } from "./archive/unwrapBundle.js";
|
|
2
2
|
import { type NozzleChoice } from "./engine/detectNozzleDiameter.js";
|
|
3
3
|
import { type WhatChanged } from "./explain/whatChanged.js";
|
|
4
|
+
import { cleanWarnings, type ConvertNote } from "./explain/notes.js";
|
|
5
|
+
export { cleanWarnings };
|
|
4
6
|
import { type Inspection } from "./inspect.js";
|
|
5
7
|
import { ProfileCatalog, type ProfileSource, type ProfileSummary, type RetiredProfile } from "./profiles.js";
|
|
6
8
|
import { type ProfileMatch, type Shifts } from "./schema.js";
|
|
@@ -114,13 +116,25 @@ export interface ConvertReport {
|
|
|
114
116
|
profileMatch?: ProfileMatch;
|
|
115
117
|
/**
|
|
116
118
|
* Why the profile was chosen, in sentences for the user, when it was auto-matched and the match wasn't plain
|
|
117
|
-
* (the source nozzle has no U1 profile, say). Empty for an exact match, a `profileId` or a preset.
|
|
119
|
+
* (the source nozzle has no U1 profile, say). Empty for an exact match, a `profileId` or a preset. Each is also
|
|
120
|
+
* in `warnings` and in `notes`: show one of the three lists, not two.
|
|
118
121
|
*/
|
|
119
122
|
profileNotes: string[];
|
|
120
123
|
/** Set when `profileId` named a retired profile and its successor was used. */
|
|
121
124
|
retiredProfile?: RetiredProfile;
|
|
122
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* Notes worth showing the user, cleaned up for display, in the conversion's order; `notes` has the same sentences
|
|
127
|
+
* sorted by topic, with the filaments each names. Their wording can change in any release: check whether there
|
|
128
|
+
* are any, not what they say.
|
|
129
|
+
*/
|
|
123
130
|
warnings: string[];
|
|
131
|
+
/**
|
|
132
|
+
* Every note for the user, once, in one list sorted by topic (the order of `NOTE_TOPICS`) with each topic's
|
|
133
|
+
* headline first: the sentences of `warnings`, `profileNotes` and {@link filamentNotes}, in one style (a capital
|
|
134
|
+
* at the start, a period at the end, "0.4 mm"), each with the filament slots it names. A UI that shows this list
|
|
135
|
+
* in its order, grouped by topic if it likes, needs none of the other three.
|
|
136
|
+
*/
|
|
137
|
+
notes: ConvertNote[];
|
|
124
138
|
/** Every note the conversion produced, including routine ones, for logs and bug reports. */
|
|
125
139
|
log: string[];
|
|
126
140
|
/** Product lines that use Generic under `filamentComplianceMode: "snapmaker"`, because Snapmaker makes no preset for them at this nozzle size. */
|
|
@@ -208,12 +222,6 @@ export interface ProfileChoice {
|
|
|
208
222
|
export declare function matchProfile(projectSettings: Record<string, unknown>, profiles: ProfileSource | ProfileCatalog, options?: {
|
|
209
223
|
nozzle?: NozzleChoice;
|
|
210
224
|
}): Promise<ProfileChoice>;
|
|
211
|
-
/**
|
|
212
|
-
* Same cleanup every UI applies before showing warnings: drop routine
|
|
213
|
-
* bookkeeping lines, strip the internal "WARN" prefix and internal file
|
|
214
|
-
* names.
|
|
215
|
-
*/
|
|
216
|
-
export declare function cleanWarnings(warnings: readonly string[]): string[];
|
|
217
225
|
/** An opened source file. Reading it again is the expensive part, so keep one per file. */
|
|
218
226
|
export declare class Project {
|
|
219
227
|
private readonly parsed;
|
package/dist/project.js
CHANGED
|
@@ -18,6 +18,9 @@ import { runConvertPipeline } from "./engine/runConvertPipeline.js";
|
|
|
18
18
|
import { diffSettings } from "./diff/diffSettings.js";
|
|
19
19
|
import { Any2orcaError } from "./errors.js";
|
|
20
20
|
import { toWhatChanged } from "./explain/whatChanged.js";
|
|
21
|
+
import { cleanWarnings, noteFrom, sortNotes } from "./explain/notes.js";
|
|
22
|
+
export { cleanWarnings };
|
|
23
|
+
import { filamentPresetNotes } from "./explain/filamentNotes.js";
|
|
21
24
|
import { inspectProject } from "./inspect.js";
|
|
22
25
|
import { catalogEngine, loadCatalog, ProfileCatalog } from "./profiles.js";
|
|
23
26
|
import { ConvertRequestSchema, ConvertResponseSchema, HighFlowHotendsSchema, } from "./schema.js";
|
|
@@ -43,14 +46,8 @@ function rawNozzleDiameter(projectSettings) {
|
|
|
43
46
|
function sizesText(sizes) {
|
|
44
47
|
return sizes.length <= 1 ? `${sizes[0] ?? "?"} mm` : `${sizes.slice(0, -1).join(", ")} and ${sizes[sizes.length - 1]} mm`;
|
|
45
48
|
}
|
|
46
|
-
/**
|
|
47
|
-
|
|
48
|
-
* re-implement this): among the profiles for the nozzle size the user's U1
|
|
49
|
-
* has (`options.nozzle`, default 0.4; "match" for the creator's own size),
|
|
50
|
-
* the source's own tier name first (from its print_settings_id, e.g. "Extra
|
|
51
|
-
* Fine"), then the nearest layer height, then the catalog default.
|
|
52
|
-
*/
|
|
53
|
-
export async function matchProfile(projectSettings, profiles, options = {}) {
|
|
49
|
+
/** {@link matchProfile}, with each note's topic for `convert()`'s `report.notes`. */
|
|
50
|
+
async function matchProfileDetailed(projectSettings, profiles, options = {}) {
|
|
54
51
|
const catalog = await loadCatalog(profiles);
|
|
55
52
|
const choice = options.nozzle ?? DEFAULT_NOZZLE;
|
|
56
53
|
const detectedDiameter = detectNozzleDiameter(projectSettings);
|
|
@@ -70,14 +67,15 @@ export async function matchProfile(projectSettings, profiles, options = {}) {
|
|
|
70
67
|
: null;
|
|
71
68
|
const profileId = picked?.profileId ?? catalog.index.defaultProfileId;
|
|
72
69
|
const used = catalog.get(profileId)?.nozzleDiameter ?? size ?? "";
|
|
73
|
-
const
|
|
70
|
+
const topics = [];
|
|
71
|
+
const notes = { push: (text, topic = "nozzle") => topics.push({ topic, text }) };
|
|
74
72
|
const sourceNozzle = rawNozzleDiameter(projectSettings);
|
|
75
73
|
if (choice === "match") {
|
|
76
74
|
if (sourceNozzle === null) {
|
|
77
75
|
notes.push("the source file doesn't give a usable nozzle size, so the default profile is used");
|
|
78
76
|
}
|
|
79
77
|
else if (detectedDiameter && Math.abs(sourceNozzle - Number(detectedDiameter)) > 1e-6) {
|
|
80
|
-
notes.push(`the source file is set up for a ${sourceNozzle}mm nozzle, which has no U1 profile; the ${detectedDiameter}mm profile is used`);
|
|
78
|
+
notes.push(`the source file is set up for a ${sourceNozzle} mm nozzle, which has no U1 profile; the ${detectedDiameter} mm profile is used`);
|
|
81
79
|
}
|
|
82
80
|
if (source.mixed) {
|
|
83
81
|
notes.push(`the creator's project uses ${sizesText(source.sizes)} nozzles; Snapmaker Orca allows one size for all four toolheads, so the whole file is for ${used} mm`);
|
|
@@ -94,7 +92,7 @@ export async function matchProfile(projectSettings, profiles, options = {}) {
|
|
|
94
92
|
notes.push(`the creator's project is set up for a ${sourceNozzle} mm nozzle; converted for your ${used} mm nozzles (choose ${sourceNozzle} mm if your U1 has them)`);
|
|
95
93
|
}
|
|
96
94
|
if (Object.hasOwn(projectSettings, "layer_height") && sourceLayerHeight === null) {
|
|
97
|
-
notes.push(`the source file's layer height (${plainText(String(projectSettings.layer_height)).slice(0, 40)}) isn't a usable number, so it isn't used to choose the profile
|
|
95
|
+
notes.push(`the source file's layer height (${plainText(String(projectSettings.layer_height)).slice(0, 40)}) isn't a usable number, so it isn't used to choose the profile`, "profile");
|
|
98
96
|
}
|
|
99
97
|
return {
|
|
100
98
|
profileId,
|
|
@@ -107,37 +105,20 @@ export async function matchProfile(projectSettings, profiles, options = {}) {
|
|
|
107
105
|
matchSource: picked ? (picked.matchedByTierName ? "auto-tier-name" : picked.exact ? "auto-exact" : "auto-nearest") : "default-fallback",
|
|
108
106
|
},
|
|
109
107
|
carrySourceLayerHeight: Boolean(picked && !picked.exact && sourceLayerHeight !== null),
|
|
110
|
-
notes,
|
|
108
|
+
notes: topics.map((note) => note.text),
|
|
109
|
+
topics,
|
|
111
110
|
};
|
|
112
111
|
}
|
|
113
112
|
/**
|
|
114
|
-
*
|
|
115
|
-
*
|
|
116
|
-
*
|
|
113
|
+
* Picks a profile for a file's settings, the same way every UI should (never
|
|
114
|
+
* re-implement this): among the profiles for the nozzle size the user's U1
|
|
115
|
+
* has (`options.nozzle`, default 0.4; "match" for the creator's own size),
|
|
116
|
+
* the source's own tier name first (from its print_settings_id, e.g. "Extra
|
|
117
|
+
* Fine"), then the nearest layer height, then the catalog default.
|
|
117
118
|
*/
|
|
118
|
-
export function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
.filter((w) => {
|
|
122
|
-
if (!w)
|
|
123
|
-
return false;
|
|
124
|
-
if (w.includes("SKIP filament_colour: list length mismatch"))
|
|
125
|
-
return false;
|
|
126
|
-
if (w.includes("left unchanged"))
|
|
127
|
-
return false;
|
|
128
|
-
if (w.includes("ignored") && w.includes("trailing non-JSON"))
|
|
129
|
-
return false;
|
|
130
|
-
return true;
|
|
131
|
-
})
|
|
132
|
-
.map((w) => w
|
|
133
|
-
.replace(/^WARN:\s*/i, "")
|
|
134
|
-
.replace(/^WARN\s+/i, "")
|
|
135
|
-
.replace(/\s+in\s+model_settings\.config\.?/i, "")
|
|
136
|
-
.replace(/\s+in\s+3D\/3dmodel\.model\.?/i, "")
|
|
137
|
-
.replace(/\s+in\s+[A-Za-z0-9_./-]+\.(config|model|xml)\.?/i, "")
|
|
138
|
-
.replace(/\.$/, ""))
|
|
139
|
-
// Warnings can quote names from the file; they're prose for people, so they never carry control characters.
|
|
140
|
-
.map(plainText);
|
|
119
|
+
export async function matchProfile(projectSettings, profiles, options = {}) {
|
|
120
|
+
const { topics: _topics, ...choice } = await matchProfileDetailed(projectSettings, profiles, options);
|
|
121
|
+
return choice;
|
|
141
122
|
}
|
|
142
123
|
/** JSON round trip, as the request and response took over HTTP. */
|
|
143
124
|
function viaJson(value) {
|
|
@@ -238,12 +219,20 @@ export class Project {
|
|
|
238
219
|
const top = await loadCatalog(options.profiles);
|
|
239
220
|
const catalog = options.snapmakerOrcaVersion === undefined ? top : await top.forRelease(options.snapmakerOrcaVersion);
|
|
240
221
|
const routeWarnings = [];
|
|
222
|
+
const routeNotes = [];
|
|
223
|
+
const route = (topic, text) => {
|
|
224
|
+
routeWarnings.push(text);
|
|
225
|
+
const note = noteFrom(topic, text);
|
|
226
|
+
if (note)
|
|
227
|
+
routeNotes.push(note);
|
|
228
|
+
};
|
|
241
229
|
// A PrusaSlicer project records no list of what its creator changed; with the vendor's presets at hand, the
|
|
242
230
|
// list is the diff against the project's print preset (policy B), as a Bambu Studio family project's own list is.
|
|
243
231
|
let policyB = null;
|
|
244
232
|
if (this.parsed.prusa) {
|
|
245
233
|
policyB = await applyPolicyB(this.parsed.prusa, top, this.request.projectSettings);
|
|
246
|
-
|
|
234
|
+
for (const note of policyB ? policyB.notes : [policyBFallbackNote(this.parsed.prusa, top)])
|
|
235
|
+
route("source", note);
|
|
247
236
|
}
|
|
248
237
|
let profileId;
|
|
249
238
|
let profileMatch;
|
|
@@ -258,24 +247,26 @@ export class Project {
|
|
|
258
247
|
const aboveStock = resolveAboveStockChoice(options.aboveStock);
|
|
259
248
|
if (preset) {
|
|
260
249
|
profileId = preset.profileId;
|
|
261
|
-
|
|
250
|
+
for (const note of preset.notes)
|
|
251
|
+
route("profile", ` WARN: ${note}`);
|
|
262
252
|
}
|
|
263
253
|
else if (options.profileId) {
|
|
264
254
|
profileId = options.profileId;
|
|
265
255
|
retiredProfile = catalog.retiredSuccessor(profileId);
|
|
266
256
|
if (retiredProfile) {
|
|
267
|
-
|
|
257
|
+
route("profile", ` WARN: profile "${profileId}" (${retiredProfile.displayName}) has been retired; converted with "${retiredProfile.successorId}" instead.`);
|
|
268
258
|
profileId = retiredProfile.successorId;
|
|
269
259
|
}
|
|
270
260
|
}
|
|
271
261
|
else {
|
|
272
|
-
const choice = await
|
|
262
|
+
const choice = await matchProfileDetailed(this.request.projectSettings, catalog, { nozzle: options.nozzle });
|
|
273
263
|
profileId = choice.profileId;
|
|
274
264
|
profileMatch = choice.profileMatch;
|
|
275
265
|
profileNotes = [...choice.notes];
|
|
276
266
|
carrySourceLayerHeight = choice.carrySourceLayerHeight;
|
|
277
267
|
matchedNozzle = choice.nozzle;
|
|
278
|
-
|
|
268
|
+
for (const note of choice.topics)
|
|
269
|
+
route(note.topic, ` WARN: ${note.text}`);
|
|
279
270
|
}
|
|
280
271
|
progress("loading-profile");
|
|
281
272
|
const loaded = await catalogEngine(catalog).load(profileId);
|
|
@@ -298,7 +289,7 @@ export class Project {
|
|
|
298
289
|
if (preset) {
|
|
299
290
|
const sourceNozzle = detectNozzleDiameter(this.request.projectSettings);
|
|
300
291
|
if (sourceNozzle && sourceNozzle !== loaded.summary.nozzleDiameter) {
|
|
301
|
-
|
|
292
|
+
route("nozzle", ` WARN: converted with your ${loaded.summary.nozzleDiameter} mm nozzle preset; the original project was set up for a ${sourceNozzle} mm nozzle.`);
|
|
302
293
|
}
|
|
303
294
|
}
|
|
304
295
|
const highFlowHotends = normalizeHighFlowOption(options.highFlowHotends);
|
|
@@ -313,7 +304,7 @@ export class Project {
|
|
|
313
304
|
const pipeline = runConvertPipeline(convertProfile, request, catalog.index.slicer.application, {
|
|
314
305
|
carrySourceLayerHeight,
|
|
315
306
|
targetNozzleDiameter: loaded.summary.nozzleDiameter,
|
|
316
|
-
...(matchedNozzle ? { nozzle: { size: matchedNozzle.size, sourceSizes: matchedNozzle.sourceSizes } } : {}),
|
|
307
|
+
...(matchedNozzle ? { nozzle: { choice: matchedNozzle.choice, size: matchedNozzle.size, sourceSizes: matchedNozzle.sourceSizes } } : {}),
|
|
317
308
|
...(preset ? { presetChanges: preset.changes } : {}),
|
|
318
309
|
...(aboveStock.keep.size + aboveStock.stock.size > 0 ? { aboveStock } : {}),
|
|
319
310
|
});
|
|
@@ -353,6 +344,23 @@ export class Project {
|
|
|
353
344
|
progress("writing");
|
|
354
345
|
const applyWarnings = [];
|
|
355
346
|
const output = applyConvertResponse({ ...this.parsed, warnings: applyWarnings }, response, stamp ? { [STAMP_PATH]: encodeStamp(stamp) } : {});
|
|
347
|
+
// One list of every note, by topic, each topic's headline first (explain/notes.ts): the profile's own note, then
|
|
348
|
+
// the pipeline's lead note, then each filament's preset detail, which goes with whatever explains why it has one.
|
|
349
|
+
const leadSlots = (topic) => new Set(pipeline.leadNotes.filter((n) => n.topic === topic).flatMap((n) => n.slots ?? []));
|
|
350
|
+
const diameterSlots = leadSlots("filament-diameter");
|
|
351
|
+
const nozzleSlots = leadSlots("nozzle");
|
|
352
|
+
const presetTopic = (slot) => (diameterSlots.has(slot) ? "filament-diameter" : nozzleSlots.has(slot) ? "nozzle" : "filament-presets");
|
|
353
|
+
const presetNotes = filamentPresetNotes(response, presetTopic).map((n) => ({ topic: n.slots.length > 0 ? presetTopic(n.slots[0]) : "filament-presets", ...(n.slots.length > 0 ? { slots: n.slots } : {}), text: n.text }));
|
|
354
|
+
const from = (topic, lines) => lines.flatMap((line) => noteFrom(topic, line) ?? []);
|
|
355
|
+
const plateWarnings = new Set(pipeline.plateWarnings);
|
|
356
|
+
const notes = sortNotes([
|
|
357
|
+
...routeNotes,
|
|
358
|
+
...pipeline.leadNotes,
|
|
359
|
+
...presetNotes,
|
|
360
|
+
...from("source", this.parsed.warnings),
|
|
361
|
+
...from("settings", (pipeline.response.warnings ?? []).filter((w) => !plateWarnings.has(w))),
|
|
362
|
+
...from("plates", [...pipeline.plateWarnings, ...applyWarnings.filter((w) => w.includes("WARN"))]),
|
|
363
|
+
]);
|
|
356
364
|
const inspection = this.inspect();
|
|
357
365
|
const outputNames = Array.isArray(response.projectSettings.filament_settings_id) ? response.projectSettings.filament_settings_id : [];
|
|
358
366
|
const filaments = inspection.filaments.map((f) => ({
|
|
@@ -372,6 +380,7 @@ export class Project {
|
|
|
372
380
|
...(retiredProfile ? { retiredProfile } : {}),
|
|
373
381
|
// A filament set to a U1 preset because of its diameter comes first: the user has to load other filament.
|
|
374
382
|
warnings: cleanWarnings([...pipeline.leadWarnings, ...this.parsed.warnings, ...(response.warnings ?? []), ...applyWarnings.filter((w) => w.includes("WARN"))]),
|
|
383
|
+
notes,
|
|
375
384
|
log: [...this.parsed.warnings, ...routeWarnings, ...pipeline.warnings, ...applyWarnings].map((w) => w.trim()).filter(Boolean),
|
|
376
385
|
...(response.filamentComplianceFallback ? { filamentComplianceFallback: response.filamentComplianceFallback } : {}),
|
|
377
386
|
...(response.filamentComplianceUnchanged ? { filamentComplianceUnchanged: response.filamentComplianceUnchanged } : {}),
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "any2orca",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer 3MF projects for the Snapmaker U1 (Snapmaker Orca), entirely on your own machine. Library, CLI and Web Worker in one package.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"3mf",
|