any2orca 0.9.2 → 0.10.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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # any2orca
2
2
 
3
+ ## 0.10.0
4
+
5
+ ### Output-affecting
6
+
7
+ - **The Snapmaker and Generic filament options set each filament to its preset's own settings, and every option keeps what the file says when Snapmaker Orca opens it.** Snapmaker Orca's app resets a filament whose name matches one of its presets to that preset's settings when it opens a project, while its command line uses the file's own values, so a relabeled file printed differently depending on how it was sliced (the creator's 225 °C in the file, Snapmaker's 220 °C in the app). Now a slot set to a Snapmaker or Generic preset takes that preset's own settings, standard and high-flow values and its start and end G-code included, from the profile catalog, so the file, the app and the command line agree; colors and order stay. `report.filamentPresets` lists each such slot and the creator's values it replaced, and the new `filamentNotes(report)` says it in words, the same sentences the web app and the CLI show. Original keeps the creator's filaments exactly, and every filament's list of changed settings now names every filament setting, so Snapmaker Orca keeps the creator's values even for a filament named like one of its presets. In the quick corpus, Original changes only that list (no setting's value); the Snapmaker option changes the filament settings of every project with a filament it renames. With a profile catalog that has no preset settings, the options change names only and say so.
8
+
9
+ ### Other
10
+
11
+ - Pins any2orca-profiles 0.4.0.
12
+
3
13
  ## 0.9.2
4
14
 
5
15
  ### Fixes
package/README.md CHANGED
@@ -21,7 +21,7 @@ Useful options:
21
21
  | `--snapmaker-orca-version <x.y.z>` | Convert for the Snapmaker Orca release you slice with (default: the newest) |
22
22
  | `--high-flow`, `--high-flow-toolheads 1,3` | All toolheads, or only these, have the Liber High Flow Hotend |
23
23
  | `--hardened-nozzle` | Your nozzles are hardened steel instead of the stock stainless 0.4 |
24
- | `--filament-compliance generic\|snapmaker` | Rename filaments for Snapmaker Space |
24
+ | `--filament-compliance generic\|snapmaker` | Set filaments to Snapmaker or Generic presets, with their own settings, for Snapmaker Space |
25
25
  | `--dry-run` | Show what would happen, without writing files |
26
26
  | `--watch <folder>` | Convert each new file that appears in a folder |
27
27
  | `--archive-dir <dir>`, `--skip-existing` | For batches: move finished originals away, or skip files already converted |
@@ -2,6 +2,7 @@
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";
5
6
  import { formatWhatChanged } from "../../explain/whatChanged.js";
6
7
  import { openProject, unwrapBundle } from "../../project.js";
7
8
  import { archiveOriginal } from "../archiveMove.js";
@@ -69,14 +70,9 @@ function logReport(report, verbose, logger) {
69
70
  for (const c of report.preset.changes)
70
71
  logger.log(` preset: ${c.key} ${c.stock} -> ${c.yours}${c.aboveStock ? " (above stock)" : ""}`);
71
72
  }
72
- const fallback = report.filamentComplianceFallback ?? [];
73
- if (fallback.length > 0) {
74
- logger.log(` note: Snapmaker makes no preset for ${fallback.join(", ")} at this nozzle size, so ${fallback.length === 1 ? "it uses" : "those use"} Generic.`);
75
- }
76
- const unchanged = report.filamentComplianceUnchanged ?? [];
77
- if (unchanged.length > 0) {
78
- logger.log(` note: no Snapmaker or Generic preset fits ${unchanged.join(", ")} at this nozzle size, so ${unchanged.length === 1 ? "its name stays" : "those names stay"} as the creator had ${unchanged.length === 1 ? "it" : "them"}.`);
79
- }
73
+ // The same sentences the web app shows (filamentNotes).
74
+ for (const note of filamentNotes(report))
75
+ logger.log(` note: ${note}`);
80
76
  for (const w of report.warnings)
81
77
  logger.log(` warning: ${w}`);
82
78
  if (report.retiredProfile)
package/dist/cli/main.js CHANGED
@@ -186,7 +186,7 @@ ${formatOptions([
186
186
  ["--keep <setting,...>", "A --preset file: keep only these settings above stock; the rest use stock"],
187
187
  ["--use-stock <setting,...>", "Use Snapmaker's stock value for these settings instead of the creator's faster one (print speeds, e.g. outer_wall_speed)"],
188
188
  ["--keep-higher <setting,...>", "Keep the creator's value for these settings even when higher than stock (accelerations, travel speed, filament_max_volumetric_speed). The U1's machine limits still apply"],
189
- ["--filament-compliance <mode>", '"generic" or "snapmaker": relabel filament identity for marketplace uploads (e.g. Snapmaker Space). Identity only: never changes temperatures, retraction, flow or other tuning. Omit to keep the source file\'s filament names'],
189
+ ["--filament-compliance <mode>", '"generic" or "snapmaker": set each filament to a preset Snapmaker Orca ships, with that preset\'s own settings, for marketplace uploads (e.g. Snapmaker Space); colors and order stay. Omit to keep the creator\'s filaments, names and settings'],
190
190
  ["--high-flow", "All four toolheads have the Snapmaker Liber High Flow Hotend. The converted file records it, so Snapmaker Orca matches your printer; colors you put on a high-flow nozzle when slicing use Snapmaker's high-flow speeds on profiles that have them (today only 0.20mm Standard, 0.4mm nozzle). Gains are largest on big prints with long, continuous paths. Ignored, with a note, on nozzle sizes with no high-flow option"],
191
191
  ["--high-flow-toolheads <list>", "Only these toolheads have the Liber hotend, numbered 1 to 4, e.g. 1 or 1,3. Otherwise the same as --high-flow; use one or the other"],
192
192
  ["--hardened-nozzle", "Your U1 has hardened steel nozzles instead of the stock stainless steel 0.4. The file records it, so Snapmaker Orca warns about abrasive filaments correctly. Only changes 0.4 nozzle conversions; Snapmaker's other sizes are hardened steel already"],
@@ -1,4 +1,6 @@
1
1
  import type { FilamentSlot } from "./extractFilamentSlots.js";
2
+ import type { PrinterFilamentPresets } from "../profiles.js";
3
+ import { type AppliedFilamentPreset } from "./applyFilamentPresets.js";
2
4
  import { type FilamentComplianceMode, type FilamentNameTable } from "./filamentComplianceNames.js";
3
5
  export interface RenamedFilament {
4
6
  /** 0-based slot index. */
@@ -15,6 +17,10 @@ export interface ApplyFilamentComplianceModeResult {
15
17
  unchangedMaterials: string[];
16
18
  /** Each slot whose name changed. */
17
19
  renamed: RenamedFilament[];
20
+ /** Each slot that takes its preset's settings (every slot a preset fits, renamed or already so named), with what that replaces. */
21
+ presets: AppliedFilamentPreset[];
22
+ /** Presets named whose settings the catalog's presets file doesn't have (with a file at all): those slots changed names only. */
23
+ missingPresets: string[];
18
24
  }
19
25
  /**
20
26
  * Overrides each filament slot's identity with a real Generic/Snapmaker
@@ -37,4 +43,6 @@ export interface ApplyFilamentComplianceModeResult {
37
43
  * @param table the profile catalog's `filamentNames`; without it every slot is left as it is and reported.
38
44
  * @param printerId the target printer: names exist per nozzle size, so they follow the printer converted to, not the source.
39
45
  */
40
- export declare function applyFilamentComplianceMode(slots: FilamentSlot[], filamentKeyArrays: Record<string, unknown[]> | null, mode: FilamentComplianceMode, table: FilamentNameTable | undefined, printerId: string): ApplyFilamentComplianceModeResult;
46
+ export declare function applyFilamentComplianceMode(slots: FilamentSlot[], filamentKeyArrays: Record<string, unknown[]> | null, mode: FilamentComplianceMode, table: FilamentNameTable | undefined, printerId: string,
47
+ /** The printer's presets' settings; without them only the names change. */
48
+ presets?: PrinterFilamentPresets): ApplyFilamentComplianceModeResult;
@@ -1,3 +1,4 @@
1
+ import { presetChanges, presetSettingsFor } from "./applyFilamentPresets.js";
1
2
  import { resolveFilamentName } from "./filamentComplianceNames.js";
2
3
  /** The keys a saved project records a filament preset's identity in, one entry per slot. */
3
4
  const IDENTITY_KEYS = ["filament_settings_id", "filament_ids", "filament_vendor"];
@@ -22,10 +23,14 @@ const IDENTITY_KEYS = ["filament_settings_id", "filament_ids", "filament_vendor"
22
23
  * @param table the profile catalog's `filamentNames`; without it every slot is left as it is and reported.
23
24
  * @param printerId the target printer: names exist per nozzle size, so they follow the printer converted to, not the source.
24
25
  */
25
- export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, table, printerId) {
26
+ export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, table, printerId,
27
+ /** The printer's presets' settings; without them only the names change. */
28
+ presets) {
26
29
  const fellBackToGeneric = new Set();
27
30
  const unchanged = new Set();
28
31
  const renamed = [];
32
+ const applied = [];
33
+ const missing = new Set();
29
34
  const arrays = {};
30
35
  for (const key of IDENTITY_KEYS)
31
36
  if (filamentKeyArrays?.[key])
@@ -46,15 +51,20 @@ export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, tabl
46
51
  fellBackToGeneric.add(result.line?.label ?? filamentType);
47
52
  if (result.preset.name !== filamentSettingsId)
48
53
  renamed.push({ slot: i, before: filamentSettingsId, after: result.preset.name });
49
- const values = { filament_settings_id: result.preset.name, filament_ids: result.preset.id, filament_vendor: result.preset.vendor };
54
+ const values = presetSettingsFor(presets, result.preset.name);
55
+ if (values)
56
+ applied.push({ slot: i, preset: result.preset.name, changed: presetChanges(values, (key) => filamentKeyArrays?.[key]?.[i] ?? slot[key]) });
57
+ else if (presets)
58
+ missing.add(result.preset.name);
59
+ const identity = { filament_settings_id: result.preset.name, filament_ids: result.preset.id, filament_vendor: result.preset.vendor };
50
60
  for (const key of IDENTITY_KEYS) {
51
61
  const list = arrays[key];
52
62
  if (list && i < list.length)
53
- list[i] = values[key];
63
+ list[i] = identity[key];
54
64
  }
55
- const next = { ...slot, filament_settings_id: values.filament_settings_id, filament_vendor: values.filament_vendor };
65
+ const next = { ...slot, filament_settings_id: identity.filament_settings_id, filament_vendor: identity.filament_vendor };
56
66
  if (Object.hasOwn(slot, "filament_ids"))
57
- next.filament_ids = values.filament_ids;
67
+ next.filament_ids = identity.filament_ids;
58
68
  return next;
59
69
  });
60
70
  const newFilamentKeyArrays = filamentKeyArrays && Object.keys(arrays).length > 0 ? { ...filamentKeyArrays, ...arrays } : filamentKeyArrays;
@@ -64,5 +74,7 @@ export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, tabl
64
74
  fellBackToGenericMaterials: [...fellBackToGeneric],
65
75
  unchangedMaterials: [...unchanged],
66
76
  renamed,
77
+ presets: applied,
78
+ missingPresets: [...missing],
67
79
  };
68
80
  }
@@ -0,0 +1,29 @@
1
+ import type { PrinterFilamentPresets } from "../profiles.js";
2
+ import type { JsonRecord } from "./types.js";
3
+ /** A slot that takes a preset's settings: its 0-based index, the preset, and the creator's values it replaces. */
4
+ export interface AppliedFilamentPreset {
5
+ slot: number;
6
+ preset: string;
7
+ changed: Array<{
8
+ key: string;
9
+ before: string;
10
+ after: string;
11
+ }>;
12
+ }
13
+ /** One preset's settings: the values the printer's presets share, with its own over them. Undefined when there are none. */
14
+ export declare function presetSettingsFor(presets: PrinterFilamentPresets | undefined, name: string): Record<string, string[]> | undefined;
15
+ /** What a slot's preset replaces: each setting whose standard value differs from the creator's. */
16
+ export declare function presetChanges(values: Record<string, string[]>, creator: (key: string) => unknown): AppliedFilamentPreset["changed"];
17
+ /**
18
+ * Writes each applied preset's settings into its slot: the project's per-filament lists (both values of a
19
+ * per-variant setting where the nozzle has a high-flow option) and the slot's embedded preset file. Runs after
20
+ * every other filament step, so nothing later overwrites it.
21
+ */
22
+ export declare function writeFilamentPresets(settings: JsonRecord, files: Record<string, JsonRecord>, applied: readonly AppliedFilamentPreset[], presets: PrinterFilamentPresets | undefined, slotCount: number): void;
23
+ /**
24
+ * Every filament's entry in `different_settings_to_system` lists every filament setting the project holds.
25
+ * Snapmaker Orca resets a filament whose name matches one of its presets to that preset's values for every
26
+ * setting its entry doesn't list (PresetBundle.cpp adds a few bookkeeping keys to each entry, so the reset
27
+ * always runs); listing them all keeps the file's values, the creator's or the chosen preset's.
28
+ */
29
+ export declare function listFilamentSettings(settings: JsonRecord, filamentCount: number): void;
@@ -0,0 +1,84 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * The Snapmaker and Generic filament options: a slot renamed to a preset Snapmaker Orca ships takes that
4
+ * preset's own settings, standard and high-flow values and its G-code included, so the file, Snapmaker Orca's
5
+ * app (which resets a filament whose name matches a shipped preset) and its command line (which uses the file's
6
+ * values) all agree. And every filament's entry in `different_settings_to_system` lists every filament setting,
7
+ * so Snapmaker Orca keeps what the file says when it opens it, the creator's values under Original included.
8
+ */
9
+ import { SETTINGS_CATALOG } from "../diff/settingsCatalog.js";
10
+ import { FILAMENT_FLOW_VARIANT_KEYS } from "./applyFilamentFlowVariants.js";
11
+ const VARIANT_KEYS = new Set(FILAMENT_FLOW_VARIANT_KEYS);
12
+ /** One preset's settings: the values the printer's presets share, with its own over them. Undefined when there are none. */
13
+ export function presetSettingsFor(presets, name) {
14
+ if (!presets || !Object.hasOwn(presets.presets, name))
15
+ return undefined;
16
+ return { ...presets.shared, ...presets.presets[name] };
17
+ }
18
+ const first = (value) => (Array.isArray(value) ? (value[0] === undefined ? undefined : String(value[0])) : value === undefined ? undefined : String(value));
19
+ /** What a slot's preset replaces: each setting whose standard value differs from the creator's. */
20
+ export function presetChanges(values, creator) {
21
+ const out = [];
22
+ for (const key of Object.keys(values).sort()) {
23
+ const before = first(creator(key));
24
+ const after = values[key][0];
25
+ if (before !== undefined && after !== undefined && before !== after)
26
+ out.push({ key, before, after });
27
+ }
28
+ return out;
29
+ }
30
+ /**
31
+ * Writes each applied preset's settings into its slot: the project's per-filament lists (both values of a
32
+ * per-variant setting where the nozzle has a high-flow option) and the slot's embedded preset file. Runs after
33
+ * every other filament step, so nothing later overwrites it.
34
+ */
35
+ export function writeFilamentPresets(settings, files, applied, presets, slotCount) {
36
+ for (const { slot, preset } of applied) {
37
+ const values = presetSettingsFor(presets, preset);
38
+ if (!values)
39
+ continue;
40
+ for (const [key, value] of Object.entries(values)) {
41
+ const list = settings[key];
42
+ if (!Array.isArray(list))
43
+ continue;
44
+ const next = [...list];
45
+ if (VARIANT_KEYS.has(key) && next.length === slotCount * 2) {
46
+ next[slot * 2] = value[0];
47
+ next[slot * 2 + 1] = value[1] ?? value[0];
48
+ }
49
+ else if (next.length === slotCount) {
50
+ next[slot] = value[0];
51
+ }
52
+ else
53
+ continue;
54
+ settings[key] = next;
55
+ }
56
+ for (const cfg of Object.values(files)) {
57
+ if (cfg.name !== preset)
58
+ continue;
59
+ for (const [key, value] of Object.entries(values)) {
60
+ const own = cfg[key];
61
+ // The embedded preset keeps its layout: one value where it holds one, the preset's own list otherwise.
62
+ cfg[key] = Array.isArray(own) && own.length === 1 ? [value[0]] : [...value];
63
+ }
64
+ }
65
+ }
66
+ }
67
+ /**
68
+ * Every filament's entry in `different_settings_to_system` lists every filament setting the project holds.
69
+ * Snapmaker Orca resets a filament whose name matches one of its presets to that preset's values for every
70
+ * setting its entry doesn't list (PresetBundle.cpp adds a few bookkeeping keys to each entry, so the reset
71
+ * always runs); listing them all keeps the file's values, the creator's or the chosen preset's.
72
+ */
73
+ export function listFilamentSettings(settings, filamentCount) {
74
+ if (filamentCount < 1)
75
+ return;
76
+ const keys = Object.keys(settings)
77
+ .filter((k) => Object.hasOwn(SETTINGS_CATALOG, k) && SETTINGS_CATALOG[k].group === "filament")
78
+ .sort()
79
+ .join(";");
80
+ const current = Array.isArray(settings.different_settings_to_system) ? settings.different_settings_to_system : [];
81
+ const print = typeof current[0] === "string" ? current[0] : "";
82
+ const printer = current.length === filamentCount + 2 && typeof current[filamentCount + 1] === "string" ? current[filamentCount + 1] : "";
83
+ settings.different_settings_to_system = [print, ...Array.from({ length: filamentCount }, () => keys), printer];
84
+ }
@@ -1,5 +1,6 @@
1
1
  import type { ConvertRequest, ConvertResponse } from "../schema.js";
2
2
  import type { FilamentNameTable } from "./filamentComplianceNames.js";
3
+ import type { PrinterFilamentPresets } from "../profiles.js";
3
4
  import { type ResolvedAboveStockChoice } from "./aboveStock.js";
4
5
  import type { JsonRecord } from "./types.js";
5
6
  import { type ChangeItem, type ChangeReason } from "../explain/whatChanged.js";
@@ -18,6 +19,8 @@ export interface ConvertProfile {
18
19
  highFlowSupported?: boolean;
19
20
  /** The catalog's filament names for the Snapmaker/Generic naming options (index.json `filamentNames`). Absent: those options leave names as they are and say so. */
20
21
  filamentNames?: FilamentNameTable;
22
+ /** The settings of this printer's filament presets, for the Snapmaker/Generic naming options; loaded only when one is used. Absent: those options change names only. */
23
+ filamentPresets?: PrinterFilamentPresets;
21
24
  };
22
25
  profile: {
23
26
  /** The Snapmaker Orca release the profile is for, e.g. "2.4.1": what a value is checked against. Absent: the newest. */
@@ -1,4 +1,6 @@
1
1
  import { applyFilamentComplianceMode } from "./applyFilamentComplianceMode.js";
2
+ import { labelOf } from "../diff/diffSettings.js";
3
+ import { listFilamentSettings, writeFilamentPresets } from "./applyFilamentPresets.js";
2
4
  import { EXTRA_PROJECT_LEVEL_FILAMENT_KEYS } from "./constants.js";
3
5
  import { buildFilamentConfigs } from "./buildFilamentConfigs.js";
4
6
  import { clampColorPenetration } from "./clampColorPenetration.js";
@@ -64,12 +66,17 @@ export function runConvertPipeline(profile, request, application, options = {})
64
66
  let filamentComplianceFallback;
65
67
  let filamentComplianceUnchanged;
66
68
  let renamedFilaments = [];
69
+ let appliedPresets = [];
67
70
  if (request.filamentComplianceMode) {
68
71
  // Preset names exist per nozzle size, so they follow the target printer, not the source's nozzle.
69
- const applied = applyFilamentComplianceMode(slots, filamentKeyArrays, request.filamentComplianceMode, printer.filamentNames, printer.id);
72
+ const applied = applyFilamentComplianceMode(slots, filamentKeyArrays, request.filamentComplianceMode, printer.filamentNames, printer.id, printer.filamentPresets);
70
73
  slots = applied.slots;
71
74
  filamentKeyArrays = applied.filamentKeyArrays;
72
75
  renamedFilaments = applied.renamed;
76
+ appliedPresets = applied.presets;
77
+ if (applied.missingPresets.length > 0) {
78
+ warnings.push(` WARN: the profile catalog has no settings for ${applied.missingPresets.join(", ")}, so only ${applied.missingPresets.length === 1 ? "its name" : "their names"} changed. Update the profile catalog.`);
79
+ }
73
80
  if (applied.fellBackToGenericMaterials.length > 0)
74
81
  filamentComplianceFallback = applied.fellBackToGenericMaterials;
75
82
  if (applied.unchangedMaterials.length > 0)
@@ -77,6 +84,9 @@ export function runConvertPipeline(profile, request, application, options = {})
77
84
  if (!printer.filamentNames) {
78
85
  warnings.push(" WARN: this profile catalog has no filament names, so filament names were left as they are. Update the profile catalog.");
79
86
  }
87
+ else if (!printer.filamentPresets) {
88
+ warnings.push(" WARN: this profile catalog has no filament preset settings, so only the filament names changed; Snapmaker Orca uses the presets' own settings when it opens the file. Update the profile catalog.");
89
+ }
80
90
  }
81
91
  const { files: filamentFiles } = buildFilamentConfigs(slots, p.filamentShapeConfig, p.filamentKeyBlocklist);
82
92
  // High-flow hotends (request.highFlowHotends): which toolheads have the
@@ -132,14 +142,28 @@ export function runConvertPipeline(profile, request, application, options = {})
132
142
  ...(filamentComplianceFallback ? [`Generic for ${filamentComplianceFallback.join(", ")}`] : []),
133
143
  ...(filamentComplianceUnchanged ? [`kept the creator's name for ${filamentComplianceUnchanged.join(", ")} (no Snapmaker or Generic preset for this nozzle size)`] : []),
134
144
  ];
145
+ const kind = request.filamentComplianceMode === "generic" ? "Generic" : "Snapmaker";
135
146
  tracker.add("yours", {
136
- label: `Filament names relabeled to ${request.filamentComplianceMode === "generic" ? "Generic" : "Snapmaker"} presets (names only, never temperatures or flow)`,
147
+ label: printer.filamentPresets
148
+ ? `Filaments set to ${kind} presets Snapmaker Orca ships, with those presets' own settings; colors and order kept`
149
+ : `Filament names relabeled to ${kind} presets (names only: this catalog has no preset settings)`,
137
150
  before: null,
138
151
  after: null,
139
152
  ...(notes.length > 0 ? { note: notes.join("; ") } : {}),
140
153
  });
141
154
  for (const r of renamedFilaments)
142
155
  tracker.add("yours", { label: `Filament ${r.slot + 1} name`, before: r.before || null, after: r.after });
156
+ for (const a of appliedPresets) {
157
+ if (a.changed.length === 0)
158
+ continue;
159
+ const shown = a.changed.slice(0, 3).map((c) => `${labelOf(c.key)} ${c.before} -> ${c.after}`).join(", ");
160
+ tracker.add("yours", {
161
+ label: `Filament ${a.slot + 1} uses ${a.preset}'s settings`,
162
+ before: null,
163
+ after: null,
164
+ note: `instead of the creator's: ${shown}${a.changed.length > 3 ? ` and ${a.changed.length - 3} more` : ""}`,
165
+ });
166
+ }
143
167
  }
144
168
  if (useStock.size > 0) {
145
169
  tracker.step(mergedSettings, because("yours", "you chose Snapmaker's stock value"), () => {
@@ -202,6 +226,10 @@ export function runConvertPipeline(profile, request, application, options = {})
202
226
  const { shifts, plateOrigins, warnings: shiftWarnings } = computeShifts(request.objects, printer.printableArea, Number.isFinite(bambuClearanceRadius) ? bambuClearanceRadius : null, printer.extruderClearanceRadius, request.plateCount);
203
227
  warnings.push(...shiftWarnings);
204
228
  addShiftItems(tracker, request.objects, shifts);
229
+ // Last of the filament steps: the chosen presets' settings, then every filament setting listed, so Snapmaker
230
+ // Orca keeps what the file says.
231
+ writeFilamentPresets(newSettings, filamentFiles, appliedPresets, printer.filamentPresets, slotCount);
232
+ listFilamentSettings(newSettings, slotCount);
205
233
  const configFiles = { ...filamentFiles };
206
234
  // `warnings` mixes routine per-conversion bookkeeping (e.g. computeShifts'
207
235
  // "true geometric center -> target" line, which fires on every plate
@@ -220,6 +248,7 @@ export function runConvertPipeline(profile, request, application, options = {})
220
248
  application,
221
249
  ...(filamentComplianceFallback ? { filamentComplianceFallback } : {}),
222
250
  ...(filamentComplianceUnchanged ? { filamentComplianceUnchanged } : {}),
251
+ ...(appliedPresets.length > 0 ? { filamentPresets: appliedPresets.map((a) => ({ slot: a.slot + 1, preset: a.preset, changed: a.changed })) } : {}),
223
252
  ...(userFacingWarnings.length > 0 ? { warnings: userFacingWarnings } : {}),
224
253
  },
225
254
  warnings,
@@ -0,0 +1,7 @@
1
+ import type { ConvertReport } from "../project.js";
2
+ /**
3
+ * What the Snapmaker or Generic filament option did, one sentence per note: which filaments use a preset's own
4
+ * settings and what that replaced, which use Generic because Snapmaker makes no preset for them, and which kept
5
+ * the creator's name and settings because no preset fits. Empty when the option wasn't used or changed nothing.
6
+ */
7
+ export declare function filamentNotes(report: Pick<ConvertReport, "filamentPresets" | "filamentComplianceFallback" | "filamentComplianceUnchanged">): string[];
@@ -0,0 +1,60 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * The filament naming options' notes for a conversion, in words: the one wording the web app, the command line
4
+ * and any other UI show, so they always say the same thing.
5
+ */
6
+ import { plainText } from "../plainText.js";
7
+ /** A value quoted from someone's file: no control or direction codes, and short, whatever the file held. */
8
+ const quoted = (value) => {
9
+ const clean = plainText(value);
10
+ return clean.length > 24 ? `${clean.slice(0, 23)}…` : clean;
11
+ };
12
+ /** The settings a note names first, in this order, with how people say them and their unit. */
13
+ const NAMED = [
14
+ ["nozzle_temperature", "nozzle temperature", " °C"],
15
+ ["nozzle_temperature_initial_layer", "first-layer nozzle temperature", " °C"],
16
+ ["filament_flow_ratio", "flow ratio", ""],
17
+ ["filament_max_volumetric_speed", "max volumetric speed", " mm³/s"],
18
+ ["pressure_advance", "pressure advance", ""],
19
+ ["filament_retraction_length", "retraction length", " mm"],
20
+ ["hot_plate_temp", "bed temperature (smooth PEI)", " °C"],
21
+ ["textured_plate_temp", "bed temperature (textured PEI)", " °C"],
22
+ ["fan_max_speed", "max fan speed", "%"],
23
+ ];
24
+ const list = (items) => (items.length <= 1 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`);
25
+ /**
26
+ * What the Snapmaker or Generic filament option did, one sentence per note: which filaments use a preset's own
27
+ * settings and what that replaced, which use Generic because Snapmaker makes no preset for them, and which kept
28
+ * the creator's name and settings because no preset fits. Empty when the option wasn't used or changed nothing.
29
+ */
30
+ export function filamentNotes(report) {
31
+ const notes = [];
32
+ const byPreset = new Map();
33
+ for (const p of report.filamentPresets ?? [])
34
+ byPreset.set(p.preset, [...(byPreset.get(p.preset) ?? []), p]);
35
+ for (const [preset, slots] of byPreset) {
36
+ const changed = slots.find((s) => s.changed.length > 0)?.changed ?? [];
37
+ const which = `${slots.length === 1 ? "Filament" : "Filaments"} ${list(slots.map((s) => String(s.slot)))}`;
38
+ if (changed.length === 0) {
39
+ notes.push(`${which} ${slots.length === 1 ? "uses" : "use"} ${preset}'s own settings, which match the creator's.`);
40
+ continue;
41
+ }
42
+ // The settings people know by name first; the rest as a count.
43
+ const named = NAMED.flatMap(([key, name, unit]) => {
44
+ const c = changed.find((x) => x.key === key);
45
+ return c && c.before !== "nil" && c.after !== "nil" ? [`${name} ${quoted(c.before)}${unit} → ${quoted(c.after)}${unit}`] : [];
46
+ }).slice(0, 3);
47
+ const rest = changed.length - named.length;
48
+ const others = `${rest} other setting${rest === 1 ? "" : "s"}`;
49
+ 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}.`);
51
+ }
52
+ const fallback = report.filamentComplianceFallback ?? [];
53
+ 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.`);
55
+ const unchanged = report.filamentComplianceUnchanged ?? [];
56
+ if (unchanged.length > 0) {
57
+ notes.push(`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.`);
58
+ }
59
+ return notes;
60
+ }
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@
10
10
  * `any2orca/worker`.
11
11
  */
12
12
  export { convert, inspect, openProject, matchProfile, unwrapBundle, Project, CONVERT_STAGES } from "./project.js";
13
- export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, OpenOptions, ProfileChoice, ReportFilament } from "./project.js";
13
+ export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, OpenOptions, ProfileChoice, ReportFilament, ReportFilamentPreset } from "./project.js";
14
14
  export { DEFAULT_MAX_UNPACKED_BYTES, LARGE_PROJECT_BYTES, MAX_UNPACKED_BYTES_LIMIT } from "./archive/safeUnzip.js";
15
15
  export { SOURCE_VENDORS } from "./inspect.js";
16
16
  export type { FilamentSlotInfo, Inspection, KnownSourceVendor, SourceVendor } from "./inspect.js";
@@ -35,6 +35,7 @@ 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
39
  export type { ChangeGroup, ChangeItem, ChangeReason, KnownChangeReason, WhatChanged } from "./explain/whatChanged.js";
39
40
  export { extractPreset } from "./presets/extractPreset.js";
40
41
  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,6 +23,7 @@ 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
27
  export { extractPreset } from "./presets/extractPreset.js";
27
28
  export { parsePresetFile, serializePresets, resolvePreset, withoutChanges, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES } from "./presets/preset.js";
28
29
  export { buildStatsEvent, parseStatsEvent, receiveStatsEvent, resolveStatsConsent, STATS_MATCH_SOURCES } from "./telemetry.js";
package/dist/node.js CHANGED
@@ -10,7 +10,7 @@
10
10
  import { readFile, stat } from "node:fs/promises";
11
11
  import { createRequire } from "node:module";
12
12
  import { dirname, join, resolve } from "node:path";
13
- import { isReleasePath, isSourcePath, MAX_INDEX_BYTES, MAX_PROFILE_BYTES, MAX_SOURCE_BYTES, parseCatalogJson, ProfileDataError } from "./profiles.js";
13
+ import { FILAMENT_PRESETS_PATH, isReleasePath, isSourcePath, MAX_FILAMENT_PRESETS_BYTES, MAX_INDEX_BYTES, MAX_PROFILE_BYTES, MAX_SOURCE_BYTES, parseCatalogJson, ProfileDataError } from "./profiles.js";
14
14
  async function readCapped(path, maxBytes) {
15
15
  let size;
16
16
  try {
@@ -42,6 +42,7 @@ export function dirProfileSource(dir) {
42
42
  throw new ProfileDataError(`Not a source data file: ${JSON.stringify(path.slice(0, 60))}.`);
43
43
  return readCapped(join(root, ...path.split("/")), MAX_SOURCE_BYTES);
44
44
  },
45
+ readFilamentPresets: () => readCapped(join(root, FILAMENT_PRESETS_PATH), MAX_FILAMENT_PRESETS_BYTES),
45
46
  release: (path) => {
46
47
  // releases/<digits.digits.digits> only, so this stays in root too.
47
48
  if (!isReleasePath(path))
@@ -43,6 +43,13 @@ export interface ProfileSource {
43
43
  * then converted with every mapped setting treated as changed.
44
44
  */
45
45
  readSource?(path: string): Promise<unknown>;
46
+ /**
47
+ * The catalog's filament presets file (`filament-presets.json`, named by the index): the settings of every
48
+ * filament preset Snapmaker Orca installs for each printer, which the Snapmaker and Generic filament options
49
+ * write. Only called when a conversion uses one of those options. Leave it out for a source without the file:
50
+ * those options then change filament names only.
51
+ */
52
+ readFilamentPresets?(): Promise<unknown>;
46
53
  }
47
54
  /** True for a path a {@link ProfileSource.release} may be asked for. */
48
55
  export declare function isReleasePath(path: string): boolean;
@@ -52,6 +59,10 @@ export declare const MAX_INDEX_BYTES: number;
52
59
  export declare const MAX_PROFILE_BYTES: number;
53
60
  /** A source-slicer bundle file (a vendor's print presets, unresolved) is a few hundred KB; this bounds a hostile one. */
54
61
  export declare const MAX_SOURCE_BYTES: number;
62
+ /** A filament presets file is a few hundred KB; this bounds a hostile one. */
63
+ export declare const MAX_FILAMENT_PRESETS_BYTES: number;
64
+ /** The only name the index may give the filament presets file. */
65
+ export declare const FILAMENT_PRESETS_PATH = "filament-presets.json";
55
66
  /** Where the index may point for source-slicer data: `sources/prusaslicer/<Vendor>.json` only. */
56
67
  export declare const SOURCE_PATH: RegExp;
57
68
  export declare function isSourcePath(path: string): boolean;
@@ -113,6 +124,7 @@ export declare const ProfileIndexSchema: z.ZodObject<{
113
124
  }, z.core.$strip>>;
114
125
  }, z.core.$strip>>;
115
126
  }, z.core.$strip>>;
127
+ filamentPresets: z.ZodOptional<z.ZodLiteral<"filament-presets.json">>;
116
128
  releases: z.ZodOptional<z.ZodArray<z.ZodObject<{
117
129
  version: z.ZodString;
118
130
  application: z.ZodString;
@@ -129,6 +141,17 @@ export declare const ProfileIndexSchema: z.ZodObject<{
129
141
  }, z.core.$strip>>;
130
142
  }, z.core.$strip>>;
131
143
  }, z.core.$strip>;
144
+ export declare const FilamentPresetsSchema: z.ZodObject<{
145
+ printers: z.ZodRecord<z.ZodString, z.ZodObject<{
146
+ shared: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>;
147
+ presets: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString>>>;
148
+ }, z.core.$strip>>;
149
+ }, z.core.$strip>;
150
+ /** One printer's filament presets: the values they share, and each preset's own, by preset name. */
151
+ export interface PrinterFilamentPresets {
152
+ shared: Record<string, string[]>;
153
+ presets: Record<string, Record<string, string[]>>;
154
+ }
132
155
  /** A printer the catalog has profiles for. */
133
156
  export interface ProfileIndexPrinter {
134
157
  id: string;
@@ -182,6 +205,8 @@ export interface ProfileIndex {
182
205
  retired: RetiredProfile[];
183
206
  /** Filament preset names for the Snapmaker/Generic naming options, per printer. */
184
207
  filamentNames?: FilamentNameTable;
208
+ /** The filament presets file, when the catalog has one: always `filament-presets.json`. */
209
+ filamentPresets?: "filament-presets.json";
185
210
  /** Every Snapmaker Orca release this catalog holds, newest first. Absent in a catalog with one release. */
186
211
  releases?: ProfileIndexRelease[];
187
212
  /** Source-slicer data the catalog holds, independent of the Snapmaker Orca release. Absent in older data. */
@@ -250,6 +275,8 @@ export interface LoadedProfile {
250
275
  export interface CatalogEngine {
251
276
  load(id: string): Promise<LoadedProfile>;
252
277
  prusaBundle(vendor: string, slicerVersion: string): Promise<PrusaBundle | null>;
278
+ /** The filament presets, by printer id; null when the catalog or its source has none. */
279
+ filamentPresets(): Promise<Record<string, PrinterFilamentPresets> | null>;
253
280
  }
254
281
  /** For tests: gives a stand-in catalog an engine side. */
255
282
  export declare function withCatalogEngine<T extends object>(catalog: T, engine: Partial<CatalogEngine>): T;
@@ -272,6 +299,7 @@ export declare class ProfileCatalog {
272
299
  private readonly cache;
273
300
  private readonly releaseCatalogs;
274
301
  private readonly bundles;
302
+ private filamentPresetsPending;
275
303
  constructor(index: ProfileIndex, source: ProfileSource);
276
304
  /** Every profile, or only one nozzle size's, sorted by nozzle size and then layer height (finest first). */
277
305
  list(filter?: {
@@ -291,6 +319,8 @@ export declare class ProfileCatalog {
291
319
  * catalog doesn't list it or its source can't read source data.
292
320
  */
293
321
  private prusaBundle;
322
+ /** The filament presets, loaded and checked once; null when the index names none or the source can't read it. */
323
+ private filamentPresets;
294
324
  /** The live profile that replaced a retired id, if `id` was retired. */
295
325
  retiredSuccessor(id: string): RetiredProfile | undefined;
296
326
  /** The Snapmaker Orca releases this catalog holds, newest first. The first is the default. */
@@ -330,6 +360,8 @@ export interface MemoryCatalogData {
330
360
  releases?: Record<string, MemoryCatalogData>;
331
361
  /** Source-slicer data files by their index path (`sources/prusaslicer/<Vendor>.json`). */
332
362
  sources?: Record<string, unknown>;
363
+ /** The filament presets file's contents, when the index names one. */
364
+ filamentPresets?: unknown;
333
365
  }
334
366
  /** A catalog already in memory, e.g. for tests or a bundler that inlines the JSON. */
335
367
  export declare function memoryProfileSource(data: MemoryCatalogData): ProfileSource;
package/dist/profiles.js CHANGED
@@ -37,6 +37,10 @@ export const MAX_INDEX_BYTES = 1024 * 1024;
37
37
  export const MAX_PROFILE_BYTES = 8 * 1024 * 1024;
38
38
  /** A source-slicer bundle file (a vendor's print presets, unresolved) is a few hundred KB; this bounds a hostile one. */
39
39
  export const MAX_SOURCE_BYTES = 8 * 1024 * 1024;
40
+ /** A filament presets file is a few hundred KB; this bounds a hostile one. */
41
+ export const MAX_FILAMENT_PRESETS_BYTES = 8 * 1024 * 1024;
42
+ /** The only name the index may give the filament presets file. */
43
+ export const FILAMENT_PRESETS_PATH = "filament-presets.json";
40
44
  /** Where the index may point for source-slicer data: `sources/prusaslicer/<Vendor>.json` only. */
41
45
  export const SOURCE_PATH = /^sources\/prusaslicer\/[A-Za-z0-9]{1,64}-\d+\.\d+\.\d+\.json$/;
42
46
  export function isSourcePath(path) {
@@ -99,6 +103,8 @@ export const ProfileIndexSchema = z.object({
99
103
  retired: z.array(z.object({ id: ID, successorId: ID, displayName: NAME })).max(5000),
100
104
  /** Filament preset names for the Snapmaker/Generic naming options, per printer. */
101
105
  filamentNames: FilamentNamesSchema.optional(),
106
+ /** The filament presets file, when the catalog has one: always `filament-presets.json`. */
107
+ filamentPresets: z.literal(FILAMENT_PRESETS_PATH).optional(),
102
108
  /**
103
109
  * Every Snapmaker Orca release this catalog holds, newest first: this
104
110
  * index's own (`path` ".") and each older one's folder. Absent in a
@@ -126,6 +132,20 @@ export const ProfileIndexSchema = z.object({
126
132
  })
127
133
  .optional(),
128
134
  });
135
+ /** Keys that could reach an object's prototype when the shared values are merged into a preset. */
136
+ const UNSAFE_KEYS = new Set(["__proto__", "constructor", "prototype"]);
137
+ const safeKey = (max, pattern) => z.string().max(max).regex(pattern).refine((k) => !UNSAFE_KEYS.has(k), "not a usable key");
138
+ const presetSettings = z
139
+ .record(safeKey(100, /^[A-Za-z0-9_]{1,100}$/), z.array(z.string().max(20_000)).max(64))
140
+ .refine((r) => Object.keys(r).length <= 1000, "too many settings");
141
+ export const FilamentPresetsSchema = z.object({
142
+ printers: z
143
+ .record(ID.refine((k) => !UNSAFE_KEYS.has(k), "not a usable key"), z.object({
144
+ shared: presetSettings,
145
+ presets: z.record(presetText(200).refine((k) => !UNSAFE_KEYS.has(k), "not a usable key"), presetSettings).refine((r) => Object.keys(r).length <= 2000, "too many presets"),
146
+ }))
147
+ .refine((r) => Object.keys(r).length <= 500, "too many printers"),
148
+ });
129
149
  export const ProfileFileSchema = z.object({
130
150
  schema: z.literal(1),
131
151
  id: ID,
@@ -144,7 +164,7 @@ export const ProfileFileSchema = z.object({
144
164
  const ENGINES = new WeakMap();
145
165
  /** For tests: gives a stand-in catalog an engine side. */
146
166
  export function withCatalogEngine(catalog, engine) {
147
- ENGINES.set(catalog, { load: () => Promise.reject(new ProfileDataError("No profiles in this stand-in.")), prusaBundle: () => Promise.resolve(null), ...engine });
167
+ ENGINES.set(catalog, { load: () => Promise.reject(new ProfileDataError("No profiles in this stand-in.")), prusaBundle: () => Promise.resolve(null), filamentPresets: () => Promise.resolve(null), ...engine });
148
168
  return catalog;
149
169
  }
150
170
  /** The engine's access to a catalog. Kept off the class, so the public API holds only what a UI needs. */
@@ -179,8 +199,9 @@ export class ProfileCatalog {
179
199
  cache = new Map();
180
200
  releaseCatalogs = new Map();
181
201
  bundles = new Map();
202
+ filamentPresetsPending;
182
203
  constructor(index, source) {
183
- ENGINES.set(this, { load: (id) => this.load(id), prusaBundle: (vendor, slicerVersion) => this.prusaBundle(vendor, slicerVersion) });
204
+ ENGINES.set(this, { load: (id) => this.load(id), prusaBundle: (vendor, slicerVersion) => this.prusaBundle(vendor, slicerVersion), filamentPresets: () => this.filamentPresets() });
184
205
  this.index = index;
185
206
  this.source = source;
186
207
  if (index.releases) {
@@ -263,6 +284,20 @@ export class ProfileCatalog {
263
284
  }
264
285
  return pending;
265
286
  }
287
+ /** The filament presets, loaded and checked once; null when the index names none or the source can't read it. */
288
+ filamentPresets() {
289
+ if (this.index.filamentPresets !== FILAMENT_PRESETS_PATH || !this.source.readFilamentPresets)
290
+ return Promise.resolve(null);
291
+ this.filamentPresetsPending ??= this.source.readFilamentPresets().then((raw) => {
292
+ const parsed = FilamentPresetsSchema.safeParse(raw);
293
+ if (!parsed.success)
294
+ throw new ProfileDataError(`Profile catalog's ${FILAMENT_PRESETS_PATH} is malformed: ${describeIssues(parsed.error)}`);
295
+ return parsed.data.printers;
296
+ });
297
+ // A failed read isn't kept, so a transient fetch error can be retried.
298
+ this.filamentPresetsPending.catch(() => (this.filamentPresetsPending = undefined));
299
+ return this.filamentPresetsPending;
300
+ }
266
301
  /** The live profile that replaced a retired id, if `id` was retired. */
267
302
  retiredSuccessor(id) {
268
303
  if (this.byId.has(id))
@@ -461,6 +496,7 @@ export function fetchProfileSource(baseUrl, options = {}) {
461
496
  throw new ProfileDataError(`Not a source data file: ${JSON.stringify(path.slice(0, 60))}.`);
462
497
  return read(path, MAX_SOURCE_BYTES);
463
498
  },
499
+ readFilamentPresets: () => read(FILAMENT_PRESETS_PATH, MAX_FILAMENT_PRESETS_BYTES),
464
500
  };
465
501
  }
466
502
  /** A catalog already in memory, e.g. for tests or a bundler that inlines the JSON. */
@@ -481,6 +517,7 @@ export function memoryProfileSource(data) {
481
517
  },
482
518
  }
483
519
  : {}),
520
+ ...(data.filamentPresets !== undefined ? { readFilamentPresets: async () => data.filamentPresets } : {}),
484
521
  release: (path) => {
485
522
  if (!isReleasePath(path) || !data.releases || !Object.hasOwn(data.releases, path))
486
523
  throw new ProfileDataError(`No catalog data for ${plainVersion(path)}.`);
package/dist/project.d.ts CHANGED
@@ -113,6 +113,12 @@ export interface ConvertReport {
113
113
  filamentComplianceFallback?: string[];
114
114
  /** Product lines (or materials) whose names stayed as the creator had them under `filamentComplianceMode`, because no Snapmaker or Generic preset fits. */
115
115
  filamentComplianceUnchanged?: string[];
116
+ /**
117
+ * Under `filamentComplianceMode`: each filament slot (1-based) set to a preset Snapmaker Orca ships, with that
118
+ * preset's own settings, and the creator's values it replaced (each setting's standard value, before and after).
119
+ * {@link filamentNotes} says it in words.
120
+ */
121
+ filamentPresets?: ReportFilamentPreset[];
116
122
  /** How far each object was moved, by object id. */
117
123
  shifts: Shifts;
118
124
  /**
@@ -137,6 +143,19 @@ export interface ConvertReport {
137
143
  notes: string[];
138
144
  };
139
145
  }
146
+ /** A filament slot set to a preset Snapmaker Orca ships, and the creator's values the preset replaced. */
147
+ export interface ReportFilamentPreset {
148
+ /** The slot, counting from 1 as slicers show them. */
149
+ slot: number;
150
+ /** The preset, e.g. "Snapmaker PLA SnapSpeed @U1". */
151
+ preset: string;
152
+ /** Each setting whose standard value differs from the creator's: the key, the creator's value, the preset's. */
153
+ changed: Array<{
154
+ key: string;
155
+ before: string;
156
+ after: string;
157
+ }>;
158
+ }
140
159
  export interface ConvertResult {
141
160
  /** The converted .3mf. */
142
161
  output: Uint8Array;
package/dist/project.js CHANGED
@@ -245,6 +245,8 @@ export class Project {
245
245
  }
246
246
  progress("loading-profile");
247
247
  const loaded = await catalogEngine(catalog).load(profileId);
248
+ // The Snapmaker and Generic filament options write the chosen presets' own settings, loaded only for them.
249
+ const filamentPresets = options.filamentComplianceMode ? (await catalogEngine(catalog).filamentPresets())?.[loaded.convertProfile.printer.id] : undefined;
248
250
  progress("merging");
249
251
  if (preset) {
250
252
  const sourceNozzle = detectNozzleDiameter(this.request.projectSettings);
@@ -260,7 +262,8 @@ export class Project {
260
262
  ...(highFlowHotends !== false ? { highFlowHotends } : {}),
261
263
  ...(options.hardenedNozzles === true ? { hardenedNozzles: true } : {}),
262
264
  };
263
- const pipeline = runConvertPipeline(loaded.convertProfile, request, catalog.index.slicer.application, {
265
+ const convertProfile = filamentPresets ? { ...loaded.convertProfile, printer: { ...loaded.convertProfile.printer, filamentPresets } } : loaded.convertProfile;
266
+ const pipeline = runConvertPipeline(convertProfile, request, catalog.index.slicer.application, {
264
267
  carrySourceLayerHeight,
265
268
  ...(preset ? { presetChanges: preset.changes } : {}),
266
269
  ...(aboveStock.keep.size + aboveStock.stock.size > 0 ? { aboveStock } : {}),
@@ -320,6 +323,7 @@ export class Project {
320
323
  log: [...this.parsed.warnings, ...routeWarnings, ...pipeline.warnings, ...applyWarnings].map((w) => w.trim()).filter(Boolean),
321
324
  ...(response.filamentComplianceFallback ? { filamentComplianceFallback: response.filamentComplianceFallback } : {}),
322
325
  ...(response.filamentComplianceUnchanged ? { filamentComplianceUnchanged: response.filamentComplianceUnchanged } : {}),
326
+ ...(response.filamentPresets ? { filamentPresets: response.filamentPresets } : {}),
323
327
  shifts: response.shifts,
324
328
  ...(response.plateOrigins ? { plateOrigins: Object.fromEntries(Object.entries(response.plateOrigins).map(([plate, origin]) => [Number(plate), origin])) } : {}),
325
329
  plates: Math.max(1, this.request.plateCount ?? 0, ...inspection.plates),
package/dist/schema.d.ts CHANGED
@@ -128,6 +128,15 @@ export declare const ConvertResponseSchema: z.ZodObject<{
128
128
  }, z.core.$strip>>;
129
129
  filamentComplianceFallback: z.ZodOptional<z.ZodArray<z.ZodString>>;
130
130
  filamentComplianceUnchanged: z.ZodOptional<z.ZodArray<z.ZodString>>;
131
+ filamentPresets: z.ZodOptional<z.ZodArray<z.ZodObject<{
132
+ slot: z.ZodNumber;
133
+ preset: z.ZodString;
134
+ changed: z.ZodArray<z.ZodObject<{
135
+ key: z.ZodString;
136
+ before: z.ZodString;
137
+ after: z.ZodString;
138
+ }, z.core.$strip>>;
139
+ }, z.core.$strip>>>;
131
140
  warnings: z.ZodOptional<z.ZodArray<z.ZodString>>;
132
141
  }, z.core.$strip>;
133
142
  export type ConvertResponse = z.infer<typeof ConvertResponseSchema>;
package/dist/schema.js CHANGED
@@ -92,6 +92,9 @@ export const ConvertResponseSchema = z.object({
92
92
  filamentComplianceFallback: z.array(z.string()).optional(),
93
93
  /** Product lines (or materials) whose names stayed as the creator had them under `filamentComplianceMode`, because no Snapmaker or Generic preset fits at this nozzle size. */
94
94
  filamentComplianceUnchanged: z.array(z.string()).optional(),
95
+ filamentPresets: z
96
+ .array(z.object({ slot: z.number().int().min(1), preset: z.string(), changed: z.array(z.object({ key: z.string(), before: z.string(), after: z.string() })) }))
97
+ .optional(),
95
98
  /** Notes worth showing the user (each contains "WARN"). */
96
99
  warnings: z.array(z.string()).optional(),
97
100
  });
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Written by scripts/sync-version.mjs from package.json; a test checks they match.
3
3
  // Typed as string, so a release doesn't change the public API's shape.
4
- export const VERSION = "0.9.2";
4
+ export const VERSION = "0.10.0";
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "any2orca",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
+ "outputAffecting": "The Snapmaker and Generic filament options set each filament to its preset's own settings, and every option keeps what the file says when Snapmaker Orca opens it",
4
5
  "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
6
  "keywords": [
6
7
  "3mf",
@@ -66,7 +67,7 @@
66
67
  "api": "node scripts/api-report.mjs"
67
68
  },
68
69
  "dependencies": {
69
- "any2orca-profiles": "0.3.1",
70
+ "any2orca-profiles": "0.4.0",
70
71
  "fflate": "0.8.3",
71
72
  "zod": "4.6.7"
72
73
  },