any2orca 0.10.0 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +2 -2
  3. package/dist/cli/commands/convert.d.ts +2 -1
  4. package/dist/cli/commands/convert.js +1 -0
  5. package/dist/cli/commands/nozzle.d.ts +9 -0
  6. package/dist/cli/commands/nozzle.js +38 -0
  7. package/dist/cli/config.d.ts +4 -0
  8. package/dist/cli/config.js +5 -0
  9. package/dist/cli/main.js +41 -0
  10. package/dist/cli/surface.d.ts +11 -0
  11. package/dist/cli/surface.js +3 -0
  12. package/dist/diff/diffSettings.js +14 -5
  13. package/dist/engine/applyFilamentComplianceMode.d.ts +3 -1
  14. package/dist/engine/applyFilamentComplianceMode.js +5 -1
  15. package/dist/engine/applyFilamentFlowVariants.d.ts +2 -2
  16. package/dist/engine/applyFilamentFlowVariants.js +4 -4
  17. package/dist/engine/applyFilamentPresets.d.ts +50 -5
  18. package/dist/engine/applyFilamentPresets.js +162 -39
  19. package/dist/engine/buildProjectSettings.js +4 -2
  20. package/dist/engine/detectNozzleDiameter.d.ts +28 -0
  21. package/dist/engine/detectNozzleDiameter.js +44 -0
  22. package/dist/engine/detectVariantIndex.d.ts +13 -0
  23. package/dist/engine/detectVariantIndex.js +25 -13
  24. package/dist/engine/extractFilamentSlots.js +7 -1
  25. package/dist/engine/filamentVariantLayout.d.ts +31 -3
  26. package/dist/engine/filamentVariantLayout.js +54 -2
  27. package/dist/engine/fillFilamentSlots.js +2 -1
  28. package/dist/engine/padFilamentsToToolheads.d.ts +20 -0
  29. package/dist/engine/padFilamentsToToolheads.js +82 -0
  30. package/dist/engine/policy.d.ts +17 -0
  31. package/dist/engine/policy.js +45 -0
  32. package/dist/engine/runConvertPipeline.d.ts +15 -0
  33. package/dist/engine/runConvertPipeline.js +136 -9
  34. package/dist/engine/setFilamentDiameter.d.ts +13 -0
  35. package/dist/engine/setFilamentDiameter.js +30 -0
  36. package/dist/explain/whatChanged.js +2 -1
  37. package/dist/index.d.ts +3 -3
  38. package/dist/index.js +1 -1
  39. package/dist/inspect.d.ts +8 -2
  40. package/dist/inspect.js +2 -1
  41. package/dist/profiles.d.ts +9 -0
  42. package/dist/profiles.js +10 -0
  43. package/dist/project.d.ts +42 -8
  44. package/dist/project.js +71 -19
  45. package/dist/stamp.d.ts +12 -0
  46. package/dist/stamp.js +7 -0
  47. package/dist/version.js +1 -1
  48. package/dist/workerProtocol.d.ts +2 -0
  49. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # any2orca
2
2
 
3
+ ## 0.12.0
4
+
5
+ ### Output-affecting
6
+
7
+ - **Snapmaker Orca no longer opens a converted file with its first filament marked as modified.** Each filament's embedded preset (`Metadata/filament_settings_N.config`) held the source file's values as they were before the conversion laid them out for the U1: one value where the U1 keeps a standard and a high-flow value, no parent preset, and the filament's color as its default color. It didn't match the filament it was written for, and Snapmaker Orca marked the first filament modified whenever its name appeared only once in the file. Now each embedded preset holds what the file holds for its filament, with its parent in `inherits`. Only the embedded presets change; the project settings are the same.
8
+ - **Files are converted for the nozzle size your U1 has, 0.4 mm unless you say otherwise, instead of the size the creator used.** A MakerWorld project sliced for a 0.6 mm nozzle used to become a U1 0.6 conversion, which the U1's firmware refuses at print start when 0.4 mm nozzles are installed. Now the profile, its layer heights and the filament values are the U1's for your size, the creator's size is noted when it differs (with a What changed item under Your choices), and a project that mixes nozzle sizes (Bambu Studio's multi-diameter mode, as on the H3C) is converted for your size with a note naming the filaments that were on other sizes. A project that names no nozzle size is converted for your size too, matched by its layer height, where it used to get the catalog's default profile whatever its layer height. A filament the creator tuned for another nozzle size than the file is for keeps its name, color, temperatures and other filament facts, but takes the U1 preset's calibration for its material at your size (flow ratio, max volumetric speed, pressure advance, retraction, cooling), since those described the creator's nozzle; the first note names the filaments, and the color is unchanged so a preset of your own can be chosen in Snapmaker Orca. The size is one for all four toolheads, as Snapmaker Orca allows; a release that allows a different size per toolhead will say so in its profile catalog (`catalog.mixedNozzleSizes`), which is where per-toolhead sizes would start. Library: the `nozzle` option on `convert()` and `matchProfile()` (`"0.2"` to `"0.8"`, or `"match"` for the creator's size, the old behavior); `NOZZLE_CHOICES` and `DEFAULT_NOZZLE`; `report.nozzle` and `ProfileChoice.nozzle` say what was used; `inspection.nozzleDiameters` lists every size a project uses; the version note records `options.nozzle`. CLI: `--nozzle <size|match>` on `convert`, and `any2orca nozzle <size>` saves your size in the config file for every conversion. Refused together with a `--profile` or preset of another size.
9
+ - **A project with fewer than four filaments gets copies of its last filament for the U1's other toolheads, as Snapmaker Orca adds them when a project is switched to the U1.** The creator's filaments stay first, unchanged and in order; each copy has the last filament's preset and settings and a new color, the first of Snapmaker Orca's new-filament colors (teal, cream, red) the project doesn't already use. No object uses the copies, and What changed says how many were added. Snapmaker Orca sets every U1 project up for four toolheads when it opens one, and a file with fewer filaments opened with a "Customized Preset" notice naming no preset, and with one filament, with that filament marked modified.
10
+ - **In a project with exactly two filaments, the second one now gets Snapmaker's standard values for the filament settings the source file doesn't have.** It got Snapmaker's high-flow values instead, because a stock standard and high-flow pair was read as one value for each of the two filaments: a ramming flow of 40 at tool changes instead of 30 in every such file, and, in files without them, a max volumetric speed of 40 (capped to 22, with a note) instead of 20 and a pressure advance of 0.024 instead of 0.02. Projects with one, three or more filaments were right.
11
+ - **A Bambu Studio project mixing filaments with and without a high-flow value keeps the creator's filament settings.** Bambu Studio stores a value only for the nozzle variants each filament's preset has (Generic PLA has a standard value only), so four filaments can have seven values for one setting. Those lists were read as stale, and 20 filament settings, including nozzle temperatures, flow ratio, max volumetric speed, retraction and Z hop, got Snapmaker's stock values for every filament, with a warning: a max volumetric speed of 20 mm³/s for Generic PLA where the file has 12. Now each filament's values, its high-flow value included, are read from where the file says they are, as Bambu Studio reads them. Projects where every filament has the same number of values were right.
12
+ - **A filament the creator's printer took at another diameter is set to a U1 preset for its material, and every filament in a converted file is 1.75 mm.** A Bambu H3C project keeps 2.85 mm for a filament on its 2.85 mm TPU PrintTool, with values tuned for that filament in that tool (a flow ratio of 1.21, for one); left in the file, Snapmaker Orca computed the extrusion for filament nearly three times thicker, and the values would have been wrong for 1.75 mm filament anyway. That filament now takes Snapmaker's preset for its material (Generic's where Snapmaker has none, or when you chose the Generic option) with that preset's settings; its color, material and place in the order stay. The first note of the conversion says so and asks you to load 1.75 mm filament and check the preset's settings, since the creator's filament may print differently; What changed lists it under the firmware group. A filament whose material has no U1 preset keeps the creator's settings with its diameter set to 1.75 mm, with the same note.
13
+
14
+ ### Fixes
15
+
16
+ - **Comparing settings (`any2orca diff`, and the full comparison in What changed) shows a Bambu Studio project's filament settings one filament at a time when its filaments have different numbers of values.** Bambu Studio stores a value only for the nozzle variants each filament's preset has (Generic PLA has a standard value only), and those settings were listed as one row covering every filament.
17
+
18
+ ### Other
19
+
20
+ - **The web app has a "Your U1's nozzle size" setting.** Next to the Liber High Flow Hotend toggle: 0.2, 0.4, 0.6 or 0.8 mm, or "Match the file" for the size the creator used. It's remembered between visits, the profile picker lists the profiles for that size, and every conversion, batch conversion and preset match uses it. The help text says what it changes and that Snapmaker Orca uses one size for all four toolheads.
21
+
22
+ ## 0.11.0
23
+
24
+ ### Output-affecting
25
+
26
+ - **Snapmaker Orca no longer warns about modified G-code when it opens a converted file, and a filament named like another printer's preset stays usable with the U1.** Since 0.10.0 each filament's list of changed settings named every filament setting, its start and end G-code included, and Snapmaker Orca warns about every G-code setting such a list names. Now the list names only the settings that differ from the preset Snapmaker Orca resets the filament to, so the app keeps every value that differs and fills in the rest with the same values. Under Original, a filament whose name isn't one of Snapmaker Orca's U1 presets (a Bambu preset, say) gets the preset the Snapmaker option would choose as its parent (Snapmaker PLA Matte for a matte PLA, Generic where Snapmaker has none): its name and the creator's values stay, and Snapmaker Orca no longer resets it to another printer's preset of the same name, which listed only that maker's printers. A filament whose base is a U1 preset takes that preset's own filament G-code. A filament no U1 preset fits names what the creator changed, what the conversion changed and the printers it can be used with. In the test projects, the Snapmaker and Generic options change only the lists; Original also gains the parents, and its filament G-code changes only where the parent's differs from Snapmaker's stock comment (a comment too).
27
+ - **Snapmaker Orca keeps the nozzle type a converted file records.** The file records the U1's stock stainless steel 0.4 nozzle and the hardened steel 0.6, or hardened steel when you choose hardened nozzles, so Snapmaker Orca can warn when a filament is too abrasive for the nozzle. Snapmaker's own printer presets have the 0.4 and 0.6 swapped, and Snapmaker Orca's app reset the file's nozzle type to the installed preset's when it opened the file, so the warning followed the swapped value there; only the command line used the file's. Now the printer's entry in the list of changed settings names the nozzle type, so the app keeps it. Where the file and the installed preset agree, nothing changes; where they differ, the app shows the printer preset as modified.
28
+
29
+ ### Other
30
+
31
+ - **any2orca needs Node 22 or newer.** Node 20 reached its end of life in April 2026 and no longer gets security fixes, so CI tests Node 22 and 24. Nothing in the library's API or the CLI changes.
32
+ - **The docs say that warning and error messages can be reworded in any release.** Branch on an error's `code`, or on whether `report.warnings` or `inspection.warnings` has any entries, never on the text. The library README, the two fields' doc comments and the publishing ideas say so.
33
+
3
34
  ## 0.10.0
4
35
 
5
36
  ### Output-affecting
package/README.md CHANGED
@@ -37,7 +37,7 @@ Every exported function and type is in the [API reference](https://docs.any2orca
37
37
 
38
38
  What stays stable: everything the library exports is supported, and a release only adds to it. A new option is optional, a result can gain fields, an interface you implement yourself (such as `ProfileSource`) only gains optional members, and a list of values the library returns (a source maker, an error code, a change reason, a conversion stage, a diff status) can gain values, so handle one you don't recognize; each list's known values are exported next to its type, for example `SOURCE_VENDORS` beside `SourceVendor`. A file format (the output stamp, a presets file, the profile catalog, the stats event) changes shape only with a new version number, and older ones keep being read. Nothing is removed or renamed outside a major release, and only after a deprecation notice. The same holds for the CLI's commands, flags, exit codes and JSON output, and for the partner hand-off. Checks in CI compare the API's shape, and the CLI's commands and options, with committed records, so a change to either is deliberate.
39
39
 
40
- Every filament in the source stays in the output: all of them, with their colors, brands, types and order, however many. The U1 loads four at a time, but a project can use many more, swapped in at the pauses the user plans in Snapmaker Orca, and that planning depends on the file's own order. `report.filaments` lists each slot with the name it had and the name it has. The model's own metadata in `3D/3dmodel.model` (designer, license, copyright, title, description) stays as it was; only `Application` changes, to the Snapmaker Orca release the file is made for.
40
+ Every filament in the source stays in the output: all of them, with their colors, brands, types and order, however many. The U1 loads four at a time, but a project can use many more, swapped in at the pauses the user plans in Snapmaker Orca, and that planning depends on the file's own order. A project with fewer filaments than the U1's four toolheads gets copies of its last filament up to four, as Snapmaker Orca adds them when a project is switched to the U1, each in a new color; no object uses them, and What changed says so. `report.filaments` lists each of the source's slots with the name it had and the name it has. The model's own metadata in `3D/3dmodel.model` (designer, license, copyright, title, description) stays as it was; only `Application` changes, to the Snapmaker Orca release the file is made for.
41
41
 
42
42
  ```js
43
43
  import { readFile, writeFile } from "node:fs/promises";
@@ -136,7 +136,7 @@ A call that fails throws `Any2orcaError`. Its `code` is stable, so a UI can bran
136
136
  | `invalid_preset` | A preset or presets file that is malformed, over a limit, or can't be used with the options given |
137
137
  | `preset_base_unknown` | A preset can't be made from this file: it isn't set up for a profile in the catalog |
138
138
 
139
- The error's message, and every entry in `report.warnings`, is written for the person converting and doesn't name the library. Any app can show it as it is.
139
+ The error's message, and every entry in `report.warnings`, is written for the person converting and doesn't name the library. Any app can show it as it is. The wording can change in any release, so branch on the error's `code`, or on whether there are any warnings at all, never on the text.
140
140
 
141
141
  ## Strict content security policies
142
142
 
@@ -12,7 +12,8 @@ export interface ConvertOptions {
12
12
  /** --use-stock / --keep-higher: the choice for values above stock. */
13
13
  aboveStock?: AboveStockChoice;
14
14
  filamentCompliance?: "generic" | "snapmaker";
15
- /** --high-flow: all four toolheads have the Liber High Flow Hotend. */
15
+ /** The nozzle size the user's U1 has ("0.4"), or "match" for the creator's; what every file is converted for. */
16
+ nozzle: string;
16
17
  /** All toolheads have the Liber hotend (true), or exactly these ones, T1 first. */
17
18
  highFlow?: boolean | boolean[];
18
19
  hardenedNozzle?: boolean;
@@ -138,6 +138,7 @@ async function convertOne(entryName, bytes, defaultDir, originalInputPath, optio
138
138
  }
139
139
  const { output, report } = await project.convert({
140
140
  profiles: options.catalog,
141
+ nozzle: options.nozzle,
141
142
  ...(options.profile ? { profileId: options.profile } : {}),
142
143
  ...(options.preset ? { preset: options.preset } : {}),
143
144
  ...(options.aboveStock ? { aboveStock: options.aboveStock } : {}),
@@ -0,0 +1,9 @@
1
+ import { type Env } from "../config.js";
2
+ /** What `convert` is for when it has no `--nozzle`: the saved size, else the U1's stock 0.4. */
3
+ export declare function savedNozzle(env: Env): string;
4
+ /** A `--nozzle` value or a size to save, checked: a size in mm such as "0.4", or "match". */
5
+ export declare function parseNozzleChoice(value: string, where: string): string;
6
+ /** `any2orca nozzle` / `any2orca nozzle show`: the saved size and what it means. */
7
+ export declare function runNozzleShow(env: Env, out: (line: string) => void): void;
8
+ export declare function runNozzleSet(value: string, env: Env, out: (line: string) => void): void;
9
+ export declare function runNozzleClear(env: Env, out: (line: string) => void): void;
@@ -0,0 +1,38 @@
1
+ // SPDX-License-Identifier: MIT
2
+ import { DEFAULT_NOZZLE, NOZZLE_CHOICES } from "../../engine/detectNozzleDiameter.js";
3
+ import { NOZZLE_CHOICE_TEXT, readCliConfig, updateCliConfig } from "../config.js";
4
+ const choices = NOZZLE_CHOICES.join(", ");
5
+ /** What `convert` is for when it has no `--nozzle`: the saved size, else the U1's stock 0.4. */
6
+ export function savedNozzle(env) {
7
+ return readCliConfig(env).nozzle ?? DEFAULT_NOZZLE;
8
+ }
9
+ /** A `--nozzle` value or a size to save, checked: a size in mm such as "0.4", or "match". */
10
+ export function parseNozzleChoice(value, where) {
11
+ const trimmed = value.trim();
12
+ if (!NOZZLE_CHOICE_TEXT.test(trimmed))
13
+ throw new Error(`${where} takes a nozzle size in mm, or "match" for the creator's size: ${choices} (got "${value}")`);
14
+ return trimmed;
15
+ }
16
+ /** `any2orca nozzle` / `any2orca nozzle show`: the saved size and what it means. */
17
+ export function runNozzleShow(env, out) {
18
+ const saved = readCliConfig(env).nozzle;
19
+ if (saved === undefined)
20
+ out(`Nozzle size: ${DEFAULT_NOZZLE} mm (the U1's stock size; nothing saved).`);
21
+ else if (saved === "match")
22
+ out("Nozzle size: match (each file is converted for the size the creator used).");
23
+ else
24
+ out(`Nozzle size: ${saved} mm (saved).`);
25
+ out(` Every "any2orca convert" without --nozzle is for this size. Save another with: any2orca nozzle <size> (${choices}); forget it with: any2orca nozzle clear.`);
26
+ }
27
+ export function runNozzleSet(value, env, out) {
28
+ const choice = parseNozzleChoice(value, "any2orca nozzle");
29
+ updateCliConfig((c) => ({ ...c, nozzle: choice }), env);
30
+ out(choice === "match" ? "Saved: each file is converted for the nozzle size the creator used." : `Saved: conversions are for ${choice} mm nozzles.`);
31
+ }
32
+ export function runNozzleClear(env, out) {
33
+ updateCliConfig((c) => {
34
+ const { nozzle: _, ...rest } = c;
35
+ return rest;
36
+ }, env);
37
+ out(`Cleared: conversions are for ${DEFAULT_NOZZLE} mm nozzles, the U1's stock size.`);
38
+ }
@@ -9,7 +9,11 @@ export interface CliConfig {
9
9
  latest?: string;
10
10
  outputAffecting?: string;
11
11
  };
12
+ /** The nozzle size the user's U1 has, used by every `convert` without `--nozzle`: a size such as "0.6", or "match". */
13
+ nozzle?: string;
12
14
  }
15
+ /** A nozzle choice as the config file or `--nozzle` may give it: a size in mm, or "match" for the creator's. */
16
+ export declare const NOZZLE_CHOICE_TEXT: RegExp;
13
17
  export type Env = Record<string, string | undefined>;
14
18
  export declare function configDir(env?: Env): string;
15
19
  export declare function readCliConfig(env?: Env): CliConfig;
@@ -10,6 +10,8 @@
10
10
  import { existsSync, mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
11
11
  import { homedir } from "node:os";
12
12
  import { join } from "node:path";
13
+ /** A nozzle choice as the config file or `--nozzle` may give it: a size in mm, or "match" for the creator's. */
14
+ export const NOZZLE_CHOICE_TEXT = /^(\d{1,2}(\.\d{1,3})?|match)$/;
13
15
  export function configDir(env = process.env) {
14
16
  if (env.ANY2ORCA_CONFIG_DIR)
15
17
  return env.ANY2ORCA_CONFIG_DIR;
@@ -64,6 +66,9 @@ function checkedConfig(value) {
64
66
  checked.outputAffecting = updateCheck.outputAffecting.slice(0, 300);
65
67
  config.updateCheck = checked;
66
68
  }
69
+ const { nozzle } = value;
70
+ if (typeof nozzle === "string" && NOZZLE_CHOICE_TEXT.test(nozzle))
71
+ config.nozzle = nozzle;
67
72
  return config;
68
73
  }
69
74
  /** Writes atomically (temp file + rename), so a crash never leaves a half-written config. */
package/dist/cli/main.js CHANGED
@@ -13,6 +13,7 @@ import { runDiff } from "./commands/diff.js";
13
13
  import { presetForConvert, presetForDiff, runPresetsAdd, runPresetsExport, runPresetsImport, runPresetsList, runPresetsRemove, runPresetsShow, } from "./commands/presets.js";
14
14
  import { resolveAboveStockChoice } from "../engine/aboveStock.js";
15
15
  import { runProfiles } from "./commands/profiles.js";
16
+ import { parseNozzleChoice, runNozzleClear, runNozzleSet, runNozzleShow, savedNozzle } from "./commands/nozzle.js";
16
17
  import { runTelemetryClear, runTelemetrySet, runTelemetryShow, runUpdateCheckSet } from "./commands/telemetry.js";
17
18
  import { readCliConfig } from "./config.js";
18
19
  import { expandInputPatterns } from "./expandWildcards.js";
@@ -56,6 +57,7 @@ ${formatOptions([
56
57
  ["diff <a.3mf> <b.3mf>", "Compare the settings of two projects, or one with Snapmaker's stock profile"],
57
58
  ["presets add | list | show | ...", "Save your own tuned print settings from a 3MF and convert with them"],
58
59
  ["profiles", "List the profiles convert can use"],
60
+ ["nozzle [<size> | match | clear]", "Say which nozzle size your U1 has (default 0.4 mm), for every conversion"],
59
61
  ["telemetry show | on | off | clear", "Show or change usage stats and the update check"],
60
62
  ["--version", "Print the version"],
61
63
  ])}
@@ -150,6 +152,25 @@ ${formatOptions([
150
152
  ["-h, --help", "Show this help"],
151
153
  ])}
152
154
  `;
155
+ const NOZZLE_HELP = `Usage: any2orca nozzle
156
+ any2orca nozzle <size> | match
157
+ any2orca nozzle clear
158
+
159
+ Says which nozzle size your U1 has. Every "any2orca convert" without --nozzle
160
+ converts for it: the profile, layer heights and filament values are the U1's
161
+ for that size, and a creator's project made for another size is noted. The
162
+ U1's stock nozzles are 0.4 mm, so that's the default; Snapmaker Orca takes one
163
+ size for all four toolheads.
164
+
165
+ ${formatOptions([
166
+ ["(no argument) | show", "The saved size, or the default"],
167
+ ["<size>", "Save the size your U1 has: 0.2, 0.4, 0.6 or 0.8 (mm)"],
168
+ ["match", "Convert each file for the size its creator used, as any2orca did before 0.12"],
169
+ ["clear", "Forget the saved size (back to 0.4)"],
170
+ ])}
171
+
172
+ Saved in config.json in the config folder (see "any2orca telemetry --help").
173
+ `;
153
174
  const TELEMETRY_HELP = `Usage: any2orca telemetry show
154
175
  any2orca telemetry on | off
155
176
  any2orca telemetry clear
@@ -190,6 +211,7 @@ ${formatOptions([
190
211
  ["--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
212
  ["--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
213
  ["--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"],
214
+ ["--nozzle <size|match>", 'The nozzle size your U1 has, which the file is converted for: 0.2, 0.4, 0.6 or 0.8 (one size for all four toolheads, as Snapmaker Orca allows), or "match" for the size the creator used. Default: the size saved with "any2orca nozzle", else 0.4. A creator\'s size that differs is noted; a project mixing sizes gets a note naming the filaments on other sizes'],
193
215
  ["--explain", "After each file, list what the conversion changed, grouped by why: from the creator's file, kept at Snapmaker's stock value, capped for the U1, set for the firmware, layout, and your choices"],
194
216
  ["--explain-json", "Also write that, with every settings difference, to <output>.what-changed.json next to each output (format any2orca-what-changed)"],
195
217
  ["--max-unpacked <size>", "The most a project may unpack to, e.g. 4GB or 3000MB (default 2GB, at most 16GB). For a very large project; it needs about twice that much memory"],
@@ -358,6 +380,22 @@ async function runCommand(command, rest, io) {
358
380
  runProfiles(await top.forRelease(values["snapmaker-orca-version"] ?? top.index.slicer.version), values.nozzle, io.out, top.releases());
359
381
  return 0;
360
382
  }
383
+ case "nozzle": {
384
+ const [sub, extra] = rest;
385
+ if (hasHelpFlag(rest)) {
386
+ io.out(NOZZLE_HELP);
387
+ return 0;
388
+ }
389
+ if (extra !== undefined)
390
+ throw new Error("Usage: any2orca nozzle [<size> | match | show | clear] (see: any2orca nozzle --help)");
391
+ if (sub === undefined || sub === "show")
392
+ runNozzleShow(io.env, io.out);
393
+ else if (sub === "clear")
394
+ runNozzleClear(io.env, io.out);
395
+ else
396
+ runNozzleSet(sub, io.env, io.out);
397
+ return 0;
398
+ }
361
399
  case "telemetry": {
362
400
  const [sub, arg] = rest;
363
401
  if (!sub || hasHelpFlag(rest)) {
@@ -402,6 +440,8 @@ async function runCommand(command, rest, io) {
402
440
  throw new Error("Use --high-flow (all four toolheads) or --high-flow-toolheads <list>, not both (see: any2orca convert --help)");
403
441
  }
404
442
  const highFlow = values["high-flow-toolheads"] !== undefined ? parseHighFlowToolheads(values["high-flow-toolheads"]) : Boolean(values["high-flow"]);
443
+ // The size the user's U1 has: --nozzle for this run, else the size saved with "any2orca nozzle", else 0.4.
444
+ const nozzle = values.nozzle !== undefined ? parseNozzleChoice(values.nozzle, "--nozzle") : savedNozzle(io.env);
405
445
  if (values.quiet && !values["log-file"])
406
446
  throw new Error("--quiet requires --log-file, otherwise errors would have nowhere to go (see: any2orca convert --help)");
407
447
  if (values["out-dir"]) {
@@ -436,6 +476,7 @@ async function runCommand(command, rest, io) {
436
476
  const logger = createLogger({ logFile: values["log-file"], quiet: Boolean(values.quiet) });
437
477
  const options = {
438
478
  catalog,
479
+ nozzle,
439
480
  profile: values.profile,
440
481
  ...(preset ? { preset } : {}),
441
482
  ...(aboveStock ? { aboveStock } : {}),
@@ -83,6 +83,9 @@ export declare const CONVERT_OPTIONS: {
83
83
  readonly "snapmaker-orca-version": {
84
84
  readonly type: "string";
85
85
  };
86
+ readonly nozzle: {
87
+ readonly type: "string";
88
+ };
86
89
  readonly profile: {
87
90
  readonly type: "string";
88
91
  };
@@ -186,6 +189,9 @@ export declare const CLI_SURFACE: {
186
189
  readonly "snapmaker-orca-version": {
187
190
  readonly type: "string";
188
191
  };
192
+ readonly nozzle: {
193
+ readonly type: "string";
194
+ };
189
195
  readonly profile: {
190
196
  readonly type: "string";
191
197
  };
@@ -345,6 +351,11 @@ export declare const CLI_SURFACE: {
345
351
  };
346
352
  };
347
353
  };
354
+ readonly nozzle: {
355
+ readonly positionals: "[<size> | match | show | clear]";
356
+ readonly subcommands: readonly ["show", "clear"];
357
+ readonly options: {};
358
+ };
348
359
  readonly telemetry: {
349
360
  readonly subcommands: readonly ["show", "on", "off", "clear", "update-check on", "update-check off"];
350
361
  readonly options: {};
@@ -32,6 +32,7 @@ export const PROFILES_OPTIONS = {
32
32
  ...PROFILE_OPTIONS,
33
33
  };
34
34
  export const CONVERT_OPTIONS = {
35
+ nozzle: { type: "string" },
35
36
  profile: { type: "string" },
36
37
  preset: { type: "string" },
37
38
  "above-stock": { type: "string" },
@@ -68,6 +69,8 @@ export const CLI_SURFACE = {
68
69
  diff: { positionals: "<a.3mf> [<b.3mf>]", options: { ...DIFF_OPTIONS, "against-stock": { type: "string", optionalValue: true } } },
69
70
  presets: { subcommands: ["add", "list", "show", "remove", "export", "import"], options: PRESETS_OPTIONS },
70
71
  profiles: { options: PROFILES_OPTIONS },
72
+ // `any2orca nozzle 0.6` saves the size; a size is a value, not a subcommand, so it isn't listed as one.
73
+ nozzle: { positionals: "[<size> | match | show | clear]", subcommands: ["show", "clear"], options: {} },
71
74
  telemetry: { subcommands: ["show", "on", "off", "clear", "update-check on", "update-check off"], options: {} },
72
75
  },
73
76
  };
@@ -20,6 +20,7 @@
20
20
  import { Any2orcaError } from "../errors.js";
21
21
  import { ABOVE_STOCK_DEFAULTS, machineLimitFor } from "../engine/aboveStock.js";
22
22
  import { FILAMENT_FLOW_VARIANT_KEYS, MAX_VOLUMETRIC_SPEED } from "../engine/applyFilamentFlowVariants.js";
23
+ import { bambuFilamentEntries } from "../engine/filamentVariantLayout.js";
23
24
  import { SETTINGS_CATALOG, SETTINGS_CATALOG_SOURCE } from "./settingsCatalog.js";
24
25
  import { isOtherPrinter, valueLayout } from "./valueLayout.js";
25
26
  /** How a setting compares between the two sides. */
@@ -122,8 +123,12 @@ function slotCount(settings) {
122
123
  }
123
124
  return 1;
124
125
  }
125
- /** The entries of each filament slot for one setting, or null if the setting isn't laid out per slot. */
126
- function splitSlots(settings, key, slots) {
126
+ /**
127
+ * The entries of each filament slot for one setting, or null if the setting isn't laid out per slot.
128
+ *
129
+ * @param bambu the side's bambuFilamentEntries, found once per side: a Bambu Studio file's filaments can have different numbers of values.
130
+ */
131
+ function splitSlots(settings, key, slots, bambu) {
127
132
  const value = settings[key];
128
133
  if (!Array.isArray(value))
129
134
  return null;
@@ -143,6 +148,8 @@ function splitSlots(settings, key, slots) {
143
148
  }
144
149
  }
145
150
  }
151
+ if (bambu && list.length === bambu.length)
152
+ return bambu.entries.map((own) => own.map((index) => list[index]));
146
153
  if (list.length % slots !== 0 || list.length === 0)
147
154
  return null;
148
155
  const per = list.length / slots;
@@ -223,6 +230,8 @@ export function diffSettings(a, b, options = {}) {
223
230
  const otherPrinter = [isOtherPrinter(a.settings), isOtherPrinter(b.settings)];
224
231
  const slotsA = slotCount(a.settings);
225
232
  const slotsB = slotCount(b.settings);
233
+ const bambuA = bambuFilamentEntries(a.settings, slotsA);
234
+ const bambuB = bambuFilamentEntries(b.settings, slotsB);
226
235
  const byGroup = new Map();
227
236
  const groupFor = (group, slot) => {
228
237
  const id = slot === undefined ? group : `${group}:${slot}`;
@@ -240,9 +249,9 @@ export function diffSettings(a, b, options = {}) {
240
249
  const hasA = Object.hasOwn(a.settings, key);
241
250
  const hasB = Object.hasOwn(b.settings, key);
242
251
  if (group === "filament") {
243
- const split = (side, has, slots) => (has ? splitSlots(side.settings, key, slots) : null);
244
- const sa = split(a, hasA, slotsA);
245
- const sb = split(b, hasB, slotsB);
252
+ const split = (side, has, slots, bambu) => (has ? splitSlots(side.settings, key, slots, bambu) : null);
253
+ const sa = split(a, hasA, slotsA, bambuA);
254
+ const sb = split(b, hasB, slotsB, bambuB);
246
255
  if ((hasA ? sa : true) && (hasB ? sb : true)) {
247
256
  const slots = Math.max(hasA ? slotsA : 0, hasB ? slotsB : 0);
248
257
  for (let i = 0; i < slots; i++) {
@@ -45,4 +45,6 @@ export interface ApplyFilamentComplianceModeResult {
45
45
  */
46
46
  export declare function applyFilamentComplianceMode(slots: FilamentSlot[], filamentKeyArrays: Record<string, unknown[]> | null, mode: FilamentComplianceMode, table: FilamentNameTable | undefined, printerId: string,
47
47
  /** The printer's presets' settings; without them only the names change. */
48
- presets?: PrinterFilamentPresets): ApplyFilamentComplianceModeResult;
48
+ presets?: PrinterFilamentPresets,
49
+ /** Only these slots (0-based); the rest are returned as they are and not reported. Default: every slot. */
50
+ only?: ReadonlySet<number>): ApplyFilamentComplianceModeResult;
@@ -25,7 +25,9 @@ const IDENTITY_KEYS = ["filament_settings_id", "filament_ids", "filament_vendor"
25
25
  */
26
26
  export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, table, printerId,
27
27
  /** The printer's presets' settings; without them only the names change. */
28
- presets) {
28
+ presets,
29
+ /** Only these slots (0-based); the rest are returned as they are and not reported. Default: every slot. */
30
+ only) {
29
31
  const fellBackToGeneric = new Set();
30
32
  const unchanged = new Set();
31
33
  const renamed = [];
@@ -36,6 +38,8 @@ presets) {
36
38
  if (filamentKeyArrays?.[key])
37
39
  arrays[key] = [...filamentKeyArrays[key]];
38
40
  const newSlots = slots.map((slot, i) => {
41
+ if (only && !only.has(i))
42
+ return slot;
39
43
  const filamentType = typeof slot.filament_type === "string" ? slot.filament_type : "";
40
44
  const filamentSettingsId = typeof slot.filament_settings_id === "string" ? slot.filament_settings_id : "";
41
45
  if (!table) {
@@ -25,8 +25,8 @@ export declare const MAX_VOLUMETRIC_SPEED: {
25
25
  * Orca when it's assigned to a toolhead (`filament_volume_type`, standard
26
26
  * until then). The standard value is what the converter already has for
27
27
  * each slot. The high-flow value is the source's own high-flow value when
28
- * the source has one (Bambu Studio stores both, named by variant; Snapmaker
29
- * Orca stores both, tagged by filament_flow_support, see
28
+ * the source has one (Bambu Studio stores both, named by variant and
29
+ * filament; Snapmaker Orca stores both, tagged by filament_flow_support; see
30
30
  * filamentVariantLayout.ts), otherwise Snapmaker's stock high-flow value
31
31
  * for settings the source doesn't carry, otherwise the standard value.
32
32
  *
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  import { detectHighFlowVariantIndex } from "./detectVariantIndex.js";
3
- import { filamentVariantLayout } from "./filamentVariantLayout.js";
3
+ import { bambuFilamentVariantLayout, filamentVariantLayout } from "./filamentVariantLayout.js";
4
4
  /**
5
5
  * Filament settings that Snapmaker Orca 2.4 stores once per flow variant
6
6
  * (standard, high flow) on a nozzle with a high-flow option. Mirrors
@@ -50,8 +50,8 @@ const cap = (value, limit) => {
50
50
  * Orca when it's assigned to a toolhead (`filament_volume_type`, standard
51
51
  * until then). The standard value is what the converter already has for
52
52
  * each slot. The high-flow value is the source's own high-flow value when
53
- * the source has one (Bambu Studio stores both, named by variant; Snapmaker
54
- * Orca stores both, tagged by filament_flow_support, see
53
+ * the source has one (Bambu Studio stores both, named by variant and
54
+ * filament; Snapmaker Orca stores both, tagged by filament_flow_support; see
55
55
  * filamentVariantLayout.ts), otherwise Snapmaker's stock high-flow value
56
56
  * for settings the source doesn't carry, otherwise the standard value.
57
57
  *
@@ -78,7 +78,7 @@ export function applyFilamentFlowVariants(settings, source, baseline, highFlowSu
78
78
  }
79
79
  else {
80
80
  const sourceHighFlow = detectHighFlowVariantIndex(source);
81
- const layout = filamentVariantLayout(source, slotCount);
81
+ const layout = filamentVariantLayout(source, slotCount) ?? bambuFilamentVariantLayout(source, slotCount);
82
82
  for (const key of FILAMENT_FLOW_VARIANT_KEYS) {
83
83
  const standard = settings[key];
84
84
  if (!Array.isArray(standard) || standard.length !== slotCount)
@@ -1,4 +1,5 @@
1
1
  import type { PrinterFilamentPresets } from "../profiles.js";
2
+ import { type FilamentNameTable } from "./filamentComplianceNames.js";
2
3
  import type { JsonRecord } from "./types.js";
3
4
  /** A slot that takes a preset's settings: its 0-based index, the preset, and the creator's values it replaces. */
4
5
  export interface AppliedFilamentPreset {
@@ -9,6 +10,8 @@ export interface AppliedFilamentPreset {
9
10
  before: string;
10
11
  after: string;
11
12
  }>;
13
+ /** Only these of the preset's settings are written (a filament tuned for another nozzle size takes the calibration, not the spool facts). Absent: all. */
14
+ keys?: readonly string[];
12
15
  }
13
16
  /** One preset's settings: the values the printer's presets share, with its own over them. Undefined when there are none. */
14
17
  export declare function presetSettingsFor(presets: PrinterFilamentPresets | undefined, name: string): Record<string, string[]> | undefined;
@@ -21,9 +24,51 @@ export declare function presetChanges(values: Record<string, string[]>, creator:
21
24
  */
22
25
  export declare function writeFilamentPresets(settings: JsonRecord, files: Record<string, JsonRecord>, applied: readonly AppliedFilamentPreset[], presets: PrinterFilamentPresets | undefined, slotCount: number): void;
23
26
  /**
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.
27
+ * What Snapmaker Orca's app resets a filament's unnamed settings to when it opens the file: the parent the file
28
+ * names for it, or else the installed preset of the same name (Preset.cpp, load_external_preset).
29
+ * - `preset`: a U1 preset whose settings the catalog holds: the slot's own, or the `parent` written for it.
30
+ * - `named`: a preset the Snapmaker or Generic option named whose settings the catalog lacks; the app uses its own.
31
+ * - `source`: no U1 preset fits, so the app resets to whatever preset of that name is installed, if any.
28
32
  */
29
- export declare function listFilamentSettings(settings: JsonRecord, filamentCount: number): void;
33
+ export type FilamentBase = {
34
+ kind: "preset";
35
+ values: Record<string, string[]>;
36
+ parent?: string;
37
+ } | {
38
+ kind: "named";
39
+ } | {
40
+ kind: "source";
41
+ };
42
+ /**
43
+ * Each slot's base. Under Original, a filament whose name isn't a U1 preset gets a U1 parent, the preset the
44
+ * Snapmaker option would choose (Snapmaker's own for the product line, or Generic where Snapmaker has none): the
45
+ * creator's name and values stay, and what the file doesn't name resets to a preset made for the U1 rather than
46
+ * to another printer's preset of the same name.
47
+ */
48
+ export declare function filamentBases(settings: JsonRecord, slotCount: number, presets: PrinterFilamentPresets | undefined, table: FilamentNameTable | undefined, printerId: string,
49
+ /** The Snapmaker or Generic option was chosen. */
50
+ option: boolean): FilamentBase[];
51
+ /**
52
+ * A slot whose base is a U1 preset, its own or its parent, takes that preset's G-code, the U1's own, so the app
53
+ * (which resets unnamed settings to the base's) and the command line (which uses the file's) run the same
54
+ * G-code, and neither calls it modified.
55
+ */
56
+ export declare function writeBaseGcode(settings: JsonRecord, files: Record<string, JsonRecord>, bases: readonly FilamentBase[], slotCount: number): void;
57
+ /**
58
+ * Each filament's entry in `different_settings_to_system` names the settings that differ from its base, and
59
+ * a parent goes in `inherits_group`. The app resets every setting an entry doesn't name to the base's value,
60
+ * which is the file's anyway, and warns about every G-code setting one names (PresetBundle.cpp,
61
+ * validate_presets), so an entry naming more than differs warns about G-code nobody changed. A filament no
62
+ * U1 preset fits names what the source file says the creator changed, what the conversion changed (its
63
+ * G-code, the U1's own, among them) and the printers it suits; every filament setting when the source's list
64
+ * can't be read.
65
+ */
66
+ export declare function listFilamentSettings(settings: JsonRecord, bases: readonly FilamentBase[], source: JsonRecord, slotCount: number): void;
67
+ /**
68
+ * Each embedded preset holds what the project holds for the first filament of its name, in the project's layout
69
+ * (standard and high-flow values where the project keeps two), with that filament's parent in `inherits`. The app
70
+ * builds a project preset from each embedded one and compares the file's filament with it, marking the first
71
+ * filament modified when they differ (Preset.cpp, load_external_preset). The presets were built from the source's
72
+ * values, before the steps that lay out, cap or replace them, so they're brought in line last.
73
+ */
74
+ export declare function syncEmbeddedPresets(settings: JsonRecord, files: Record<string, JsonRecord>, bases: readonly FilamentBase[], slotCount: number): void;