any2orca 0.0.1 → 0.2.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 (194) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE +28 -0
  4. package/README.md +96 -3
  5. package/dist/archive/adaptModelSettings.d.ts +1 -0
  6. package/dist/archive/adaptModelSettings.js +50 -0
  7. package/dist/archive/filamentColorNames.d.ts +8 -0
  8. package/dist/archive/filamentColorNames.js +760 -0
  9. package/dist/archive/fmtNum.d.ts +14 -0
  10. package/dist/archive/fmtNum.js +21 -0
  11. package/dist/archive/internal/escapeRegExp.d.ts +2 -0
  12. package/dist/archive/internal/escapeRegExp.js +5 -0
  13. package/dist/archive/lookupFilamentColorName.d.ts +45 -0
  14. package/dist/archive/lookupFilamentColorName.js +57 -0
  15. package/dist/archive/objectWorldBboxXY.d.ts +2 -0
  16. package/dist/archive/objectWorldBboxXY.js +123 -0
  17. package/dist/archive/parseItemPositions.d.ts +6 -0
  18. package/dist/archive/parseItemPositions.js +17 -0
  19. package/dist/archive/parseObjectMetadata.d.ts +10 -0
  20. package/dist/archive/parseObjectMetadata.js +97 -0
  21. package/dist/archive/parsePlateAssignments.d.ts +6 -0
  22. package/dist/archive/parsePlateAssignments.js +18 -0
  23. package/dist/archive/parseVertices.d.ts +7 -0
  24. package/dist/archive/parseVertices.js +12 -0
  25. package/dist/archive/paths.d.ts +5 -0
  26. package/dist/archive/paths.js +6 -0
  27. package/dist/archive/recenterAssembleItems.d.ts +9 -0
  28. package/dist/archive/recenterAssembleItems.js +53 -0
  29. package/dist/archive/recenterBuildItems.d.ts +15 -0
  30. package/dist/archive/recenterBuildItems.js +51 -0
  31. package/dist/archive/safeUnzip.d.ts +26 -0
  32. package/dist/archive/safeUnzip.js +126 -0
  33. package/dist/archive/setApplicationMetadata.d.ts +13 -0
  34. package/dist/archive/setApplicationMetadata.js +18 -0
  35. package/dist/archive/shouldDropFromBambu.d.ts +29 -0
  36. package/dist/archive/shouldDropFromBambu.js +39 -0
  37. package/dist/archive/streamObjectVertices.d.ts +19 -0
  38. package/dist/archive/streamObjectVertices.js +57 -0
  39. package/dist/archive/tolerantJsonParse.d.ts +20 -0
  40. package/dist/archive/tolerantJsonParse.js +71 -0
  41. package/dist/archive/transform.d.ts +21 -0
  42. package/dist/archive/transform.js +39 -0
  43. package/dist/archive/unwrapBundle.d.ts +24 -0
  44. package/dist/archive/unwrapBundle.js +41 -0
  45. package/dist/archive/xmlBlocks.d.ts +10 -0
  46. package/dist/archive/xmlBlocks.js +31 -0
  47. package/dist/archive/zip.d.ts +29 -0
  48. package/dist/archive/zip.js +141 -0
  49. package/dist/cli/archiveMove.d.ts +15 -0
  50. package/dist/cli/archiveMove.js +41 -0
  51. package/dist/cli/commands/convert.d.ts +89 -0
  52. package/dist/cli/commands/convert.js +311 -0
  53. package/dist/cli/commands/diff.d.ts +21 -0
  54. package/dist/cli/commands/diff.js +112 -0
  55. package/dist/cli/commands/presets.d.ts +51 -0
  56. package/dist/cli/commands/presets.js +280 -0
  57. package/dist/cli/commands/profiles.d.ts +5 -0
  58. package/dist/cli/commands/profiles.js +26 -0
  59. package/dist/cli/commands/telemetry.d.ts +6 -0
  60. package/dist/cli/commands/telemetry.js +45 -0
  61. package/dist/cli/config.d.ts +18 -0
  62. package/dist/cli/config.js +50 -0
  63. package/dist/cli/expandWildcards.d.ts +17 -0
  64. package/dist/cli/expandWildcards.js +81 -0
  65. package/dist/cli/logger.d.ts +17 -0
  66. package/dist/cli/logger.js +36 -0
  67. package/dist/cli/main.d.ts +24 -0
  68. package/dist/cli/main.js +598 -0
  69. package/dist/cli/sameFile.d.ts +9 -0
  70. package/dist/cli/sameFile.js +40 -0
  71. package/dist/cli/stats.d.ts +34 -0
  72. package/dist/cli/stats.js +137 -0
  73. package/dist/cli/table.d.ts +8 -0
  74. package/dist/cli/table.js +18 -0
  75. package/dist/cli/terminalText.d.ts +7 -0
  76. package/dist/cli/terminalText.js +22 -0
  77. package/dist/cli/updateCheck.d.ts +14 -0
  78. package/dist/cli/updateCheck.js +78 -0
  79. package/dist/cli/watchState.d.ts +18 -0
  80. package/dist/cli/watchState.js +33 -0
  81. package/dist/cli.d.ts +1 -0
  82. package/dist/cli.js +10 -0
  83. package/dist/diff/diffSettings.d.ts +81 -0
  84. package/dist/diff/diffSettings.js +259 -0
  85. package/dist/diff/reference.d.ts +14 -0
  86. package/dist/diff/reference.js +22 -0
  87. package/dist/diff/settingsCatalog.d.ts +28 -0
  88. package/dist/diff/settingsCatalog.js +605 -0
  89. package/dist/diff/valueLayout.d.ts +20 -0
  90. package/dist/diff/valueLayout.js +65 -0
  91. package/dist/engine/aboveStock.d.ts +20 -0
  92. package/dist/engine/aboveStock.js +89 -0
  93. package/dist/engine/applyFilamentComplianceMode.d.ts +40 -0
  94. package/dist/engine/applyFilamentComplianceMode.js +68 -0
  95. package/dist/engine/applyFilamentFlowVariants.d.ts +42 -0
  96. package/dist/engine/applyFilamentFlowVariants.js +109 -0
  97. package/dist/engine/applyHighFlowHotends.d.ts +52 -0
  98. package/dist/engine/applyHighFlowHotends.js +115 -0
  99. package/dist/engine/applyPresetChanges.d.ts +12 -0
  100. package/dist/engine/applyPresetChanges.js +23 -0
  101. package/dist/engine/bedCenter.d.ts +19 -0
  102. package/dist/engine/bedCenter.js +34 -0
  103. package/dist/engine/buildFilamentConfigs.d.ts +18 -0
  104. package/dist/engine/buildFilamentConfigs.js +49 -0
  105. package/dist/engine/buildProjectSettings.d.ts +24 -0
  106. package/dist/engine/buildProjectSettings.js +164 -0
  107. package/dist/engine/carrySourceLayerHeight.d.ts +15 -0
  108. package/dist/engine/carrySourceLayerHeight.js +41 -0
  109. package/dist/engine/clampColorPenetration.d.ts +12 -0
  110. package/dist/engine/clampColorPenetration.js +28 -0
  111. package/dist/engine/clampToMachineLimits.d.ts +21 -0
  112. package/dist/engine/clampToMachineLimits.js +84 -0
  113. package/dist/engine/coerceValue.d.ts +15 -0
  114. package/dist/engine/coerceValue.js +56 -0
  115. package/dist/engine/collapseNozzleVariants.d.ts +31 -0
  116. package/dist/engine/collapseNozzleVariants.js +63 -0
  117. package/dist/engine/computeShifts.d.ts +12 -0
  118. package/dist/engine/computeShifts.js +339 -0
  119. package/dist/engine/constants.d.ts +11 -0
  120. package/dist/engine/constants.js +12 -0
  121. package/dist/engine/detectNozzleDiameter.d.ts +15 -0
  122. package/dist/engine/detectNozzleDiameter.js +29 -0
  123. package/dist/engine/detectVariantIndex.d.ts +39 -0
  124. package/dist/engine/detectVariantIndex.js +80 -0
  125. package/dist/engine/extractFilamentSlots.d.ts +18 -0
  126. package/dist/engine/extractFilamentSlots.js +88 -0
  127. package/dist/engine/filamentComplianceNames.d.ts +84 -0
  128. package/dist/engine/filamentComplianceNames.js +87 -0
  129. package/dist/engine/filamentVariantLayout.d.ts +29 -0
  130. package/dist/engine/filamentVariantLayout.js +38 -0
  131. package/dist/engine/fillFilamentSlots.d.ts +16 -0
  132. package/dist/engine/fillFilamentSlots.js +26 -0
  133. package/dist/engine/internal/jsonEqual.d.ts +2 -0
  134. package/dist/engine/internal/jsonEqual.js +5 -0
  135. package/dist/engine/parseTierName.d.ts +15 -0
  136. package/dist/engine/parseTierName.js +21 -0
  137. package/dist/engine/pickNearestProfile.d.ts +21 -0
  138. package/dist/engine/pickNearestProfile.js +24 -0
  139. package/dist/engine/pickProfile.d.ts +49 -0
  140. package/dist/engine/pickProfile.js +67 -0
  141. package/dist/engine/policy.d.ts +22 -0
  142. package/dist/engine/policy.js +274 -0
  143. package/dist/engine/remapBrimType.d.ts +30 -0
  144. package/dist/engine/remapBrimType.js +34 -0
  145. package/dist/engine/reshapeToCount.d.ts +15 -0
  146. package/dist/engine/reshapeToCount.js +27 -0
  147. package/dist/engine/resizeFlushVolumes.d.ts +27 -0
  148. package/dist/engine/resizeFlushVolumes.js +57 -0
  149. package/dist/engine/resolveMinIfLower.d.ts +21 -0
  150. package/dist/engine/resolveMinIfLower.js +59 -0
  151. package/dist/engine/runConvertPipeline.d.ts +79 -0
  152. package/dist/engine/runConvertPipeline.js +281 -0
  153. package/dist/engine/stripBambuOnlyNozzleVariantKeys.d.ts +2 -0
  154. package/dist/engine/stripBambuOnlyNozzleVariantKeys.js +35 -0
  155. package/dist/engine/types.d.ts +2 -0
  156. package/dist/engine/types.js +1 -0
  157. package/dist/errors.d.ts +18 -0
  158. package/dist/errors.js +9 -0
  159. package/dist/explain/whatChanged.d.ts +102 -0
  160. package/dist/explain/whatChanged.js +199 -0
  161. package/dist/index.d.ts +50 -0
  162. package/dist/index.js +34 -0
  163. package/dist/inspect.d.ts +63 -0
  164. package/dist/inspect.js +103 -0
  165. package/dist/node.d.ts +11 -0
  166. package/dist/node.js +50 -0
  167. package/dist/plainText.d.ts +10 -0
  168. package/dist/plainText.js +14 -0
  169. package/dist/presets/extractPreset.d.ts +13 -0
  170. package/dist/presets/extractPreset.js +87 -0
  171. package/dist/presets/preset.d.ts +124 -0
  172. package/dist/presets/preset.js +289 -0
  173. package/dist/presets/presetKeys.d.ts +5 -0
  174. package/dist/presets/presetKeys.js +42 -0
  175. package/dist/profiles.d.ts +184 -0
  176. package/dist/profiles.js +318 -0
  177. package/dist/project.d.ts +146 -0
  178. package/dist/project.js +342 -0
  179. package/dist/schema.d.ts +103 -0
  180. package/dist/schema.js +87 -0
  181. package/dist/stamp.d.ts +45 -0
  182. package/dist/stamp.js +111 -0
  183. package/dist/telemetry.d.ts +101 -0
  184. package/dist/telemetry.js +94 -0
  185. package/dist/version.d.ts +1 -0
  186. package/dist/version.js +3 -0
  187. package/dist/worker-entry.d.ts +1 -0
  188. package/dist/worker-entry.js +142 -0
  189. package/dist/worker.d.ts +86 -0
  190. package/dist/worker.js +97 -0
  191. package/dist/workerProtocol.d.ts +91 -0
  192. package/dist/workerProtocol.js +1 -0
  193. package/package.json +80 -12
  194. package/index.js +0 -3
@@ -0,0 +1,20 @@
1
+ /**
2
+ * - `u1-hotends`: two values, the U1's standard hotend, then the Liber High Flow Hotend.
3
+ * - `flow-variants`: two values, another printer's standard nozzle, then its high-flow nozzle.
4
+ * - `nozzle-variants`: one value per nozzle of a two-nozzle printer, standard then high flow for each.
5
+ */
6
+ export type ValueLayout = "u1-hotends" | "flow-variants" | "nozzle-variants";
7
+ /** One sentence per layout, for a note above a table of values. The web app and the CLI both use these. */
8
+ export declare const VALUE_LAYOUT_TEXT: Readonly<Record<ValueLayout, string>>;
9
+ /** Settings for a printer other than the U1 (a missing model counts as the U1: stock profiles and presets). */
10
+ export declare function isOtherPrinter(settings: Readonly<Record<string, unknown>>): boolean;
11
+ /**
12
+ * The layout of one value of `key`, as stored in `settings`. `count` is how
13
+ * many entries the value shows: the whole list for a print setting, or one
14
+ * filament slot's entries for a filament setting (`perSlot`).
15
+ */
16
+ export declare function valueLayout(key: string, count: number, settings: Readonly<Record<string, unknown>>, perSlot?: boolean): ValueLayout | undefined;
17
+ /** The notes a table needs: one per layout its values use, in a fixed order. Takes Compare rows or "What changed" items. */
18
+ export declare function valueLayoutNotes(rows: Iterable<{
19
+ layout?: Partial<Record<string, ValueLayout>>;
20
+ }>): string[];
@@ -0,0 +1,65 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * What a setting's several values mean. Some settings hold more than one
4
+ * value, and "200, 500" reads as noise unless it's clear what each one is
5
+ * for: the U1 stores some speeds and filament flow values once for the
6
+ * standard hotend and once for the Liber High Flow Hotend, other Bambu-lineage
7
+ * printers store them once per flow variant of their own nozzle, and a
8
+ * two-nozzle printer such as the H2D stores them per nozzle and flow variant.
9
+ *
10
+ * The layout comes from the settings themselves (which keys are paired, the
11
+ * printer model, a two-nozzle file's extruder columns), never from the text
12
+ * of a value or a file's name. A value of one setting that merely lists
13
+ * several filaments has no layout.
14
+ */
15
+ import { FILAMENT_FLOW_VARIANT_KEYS } from "../engine/applyFilamentFlowVariants.js";
16
+ import { NOZZLE_VARIANT_KEYS } from "../engine/collapseNozzleVariants.js";
17
+ /** One sentence per layout, for a note above a table of values. The web app and the CLI both use these. */
18
+ export const VALUE_LAYOUT_TEXT = {
19
+ "u1-hotends": "Two values: standard hotend, then Liber High Flow Hotend.",
20
+ "flow-variants": "Two values: the original printer's standard nozzle, then its high-flow nozzle.",
21
+ "nozzle-variants": "One value per nozzle of the original printer, standard then high flow for each.",
22
+ };
23
+ const LAYOUT_ORDER = ["u1-hotends", "flow-variants", "nozzle-variants"];
24
+ const FILAMENT_PAIRS = new Set(FILAMENT_FLOW_VARIANT_KEYS);
25
+ /** Settings for a printer other than the U1 (a missing model counts as the U1: stock profiles and presets). */
26
+ export function isOtherPrinter(settings) {
27
+ const model = settings.printer_model;
28
+ return typeof model === "string" && model.length > 0 && !model.includes("Snapmaker U1");
29
+ }
30
+ /** The number of nozzle columns of a two-nozzle file's per-nozzle settings, or 0 when it isn't one. */
31
+ function nozzleColumns(settings) {
32
+ const ids = settings.print_extruder_id;
33
+ return Array.isArray(ids) && new Set(ids.map(String)).size >= 2 ? ids.length : 0;
34
+ }
35
+ /**
36
+ * The layout of one value of `key`, as stored in `settings`. `count` is how
37
+ * many entries the value shows: the whole list for a print setting, or one
38
+ * filament slot's entries for a filament setting (`perSlot`).
39
+ */
40
+ export function valueLayout(key, count, settings, perSlot = false) {
41
+ if (count < 2)
42
+ return undefined;
43
+ if (perSlot) {
44
+ if (!FILAMENT_PAIRS.has(key) || count !== 2)
45
+ return undefined;
46
+ return isOtherPrinter(settings) ? "flow-variants" : "u1-hotends";
47
+ }
48
+ if (!NOZZLE_VARIANT_KEYS.has(key))
49
+ return undefined;
50
+ const columns = nozzleColumns(settings);
51
+ if (columns > 0)
52
+ return count === columns ? "nozzle-variants" : undefined;
53
+ if (count !== 2)
54
+ return undefined;
55
+ return isOtherPrinter(settings) ? "flow-variants" : "u1-hotends";
56
+ }
57
+ /** The notes a table needs: one per layout its values use, in a fixed order. Takes Compare rows or "What changed" items. */
58
+ export function valueLayoutNotes(rows) {
59
+ const used = new Set();
60
+ for (const row of rows)
61
+ for (const layout of Object.values(row.layout ?? {}))
62
+ if (layout)
63
+ used.add(layout);
64
+ return LAYOUT_ORDER.filter((l) => used.has(l)).map((l) => VALUE_LAYOUT_TEXT[l]);
65
+ }
@@ -0,0 +1,20 @@
1
+ export type AboveStockDefault = "keep" | "stock" | "capped";
2
+ /** What each covered setting does when nobody chooses. */
3
+ export declare const ABOVE_STOCK_DEFAULTS: Readonly<Record<string, AboveStockDefault>>;
4
+ /** A caller's choice for values above stock: settings to keep at the creator's value, and settings to set to Snapmaker's stock value. */
5
+ export interface AboveStockChoice {
6
+ keep?: readonly string[];
7
+ stock?: readonly string[];
8
+ }
9
+ export interface ResolvedAboveStockChoice {
10
+ keep: ReadonlySet<string>;
11
+ stock: ReadonlySet<string>;
12
+ }
13
+ /** Checks a choice; throws TypeError for anything that isn't one (unknown keys, a key in both lists, stock for max volumetric speed). */
14
+ export declare function resolveAboveStockChoice(choice: AboveStockChoice | undefined): ResolvedAboveStockChoice;
15
+ /** The U1's machine limit for a speed or acceleration setting, from the printer's machine settings, or null if it has none. */
16
+ export declare function machineLimitFor(key: string, machine: Readonly<Record<string, unknown>>): number | null;
17
+ /** The first number in a value (the standard entry of a per-variant list), or null. */
18
+ export declare function firstNumber(value: unknown): number | null;
19
+ /** The largest number in a value (for per-slot lists like max volumetric speed), or null. */
20
+ export declare function largestNumber(value: unknown): number | null;
@@ -0,0 +1,89 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Values above Snapmaker's stock: which settings the user can choose for,
4
+ * what happens when nobody chooses, and checking a choice from a caller
5
+ *. The U1's machine limits are not part of the choice:
6
+ * clampToMachineLimits caps every value at them afterwards, whatever is
7
+ * chosen.
8
+ *
9
+ * - Print speeds carry the creator's value by default; the alternative is
10
+ * Snapmaker's stock value.
11
+ * - Accelerations and travel speed keep Snapmaker's stock value when the
12
+ * creator's is higher (MIN_COMPARISON_KEYS); the alternative is the
13
+ * creator's value.
14
+ * - Filament max volumetric speed is capped at 22/40 mm³/s by default; the
15
+ * alternative is the creator's value, uncapped.
16
+ *
17
+ * Settings the converter never takes from a source file (BLOCKLIST) aren't
18
+ * offered.
19
+ */
20
+ import { EXTRUDING_ACCELERATION_KEYS, SPEED_KEYS } from "./clampToMachineLimits.js";
21
+ import { BLOCKLIST, MIN_COMPARISON_KEYS } from "./policy.js";
22
+ /** What each covered setting does when nobody chooses. */
23
+ export const ABOVE_STOCK_DEFAULTS = Object.freeze(Object.fromEntries([
24
+ ...[...SPEED_KEYS, ...EXTRUDING_ACCELERATION_KEYS, "travel_acceleration"]
25
+ .filter((key) => !BLOCKLIST.includes(key))
26
+ .map((key) => [key, MIN_COMPARISON_KEYS.includes(key) ? "stock" : "keep"]),
27
+ ["filament_max_volumetric_speed", "capped"],
28
+ ]));
29
+ const MAX_CHOICE_KEYS = 100;
30
+ /** Checks a choice; throws TypeError for anything that isn't one (unknown keys, a key in both lists, stock for max volumetric speed). */
31
+ export function resolveAboveStockChoice(choice) {
32
+ const empty = { keep: new Set(), stock: new Set() };
33
+ if (choice === undefined)
34
+ return empty;
35
+ if (choice === null || typeof choice !== "object" || Array.isArray(choice))
36
+ throw new TypeError("aboveStock must be an object with keep and stock lists.");
37
+ const list = (value, name) => {
38
+ if (value === undefined)
39
+ return new Set();
40
+ if (!Array.isArray(value) || value.length > MAX_CHOICE_KEYS || !value.every((k) => typeof k === "string")) {
41
+ throw new TypeError(`aboveStock.${name} must be a list of at most ${MAX_CHOICE_KEYS} setting keys.`);
42
+ }
43
+ for (const key of value) {
44
+ if (!Object.hasOwn(ABOVE_STOCK_DEFAULTS, key))
45
+ throw new TypeError(`aboveStock.${name}: "${key.slice(0, 60)}" isn't a speed, acceleration or max volumetric speed you can choose for.`);
46
+ }
47
+ return new Set(value);
48
+ };
49
+ const keep = list(choice.keep, "keep");
50
+ const stock = list(choice.stock, "stock");
51
+ for (const key of keep)
52
+ if (stock.has(key))
53
+ throw new TypeError(`aboveStock: "${key}" is in both keep and stock.`);
54
+ if (stock.has("filament_max_volumetric_speed")) {
55
+ throw new TypeError("aboveStock.stock can't include filament_max_volumetric_speed: filament values are the creator's; it's capped by default, or kept.");
56
+ }
57
+ return { keep, stock };
58
+ }
59
+ function positiveNumber(value) {
60
+ const raw = Array.isArray(value) ? value[0] : value;
61
+ const n = typeof raw === "string" || typeof raw === "number" ? Number(raw) : NaN;
62
+ return Number.isFinite(n) && n > 0 ? n : null;
63
+ }
64
+ /** The U1's machine limit for a speed or acceleration setting, from the printer's machine settings, or null if it has none. */
65
+ export function machineLimitFor(key, machine) {
66
+ if (SPEED_KEYS.includes(key)) {
67
+ const x = positiveNumber(machine.machine_max_speed_x);
68
+ const y = positiveNumber(machine.machine_max_speed_y);
69
+ return x === null && y === null ? null : Math.min(x ?? Infinity, y ?? Infinity);
70
+ }
71
+ if (EXTRUDING_ACCELERATION_KEYS.includes(key))
72
+ return positiveNumber(machine.machine_max_acceleration_extruding);
73
+ if (key === "travel_acceleration")
74
+ return positiveNumber(machine.machine_max_acceleration_travel);
75
+ return null;
76
+ }
77
+ /** The first number in a value (the standard entry of a per-variant list), or null. */
78
+ export function firstNumber(value) {
79
+ const raw = Array.isArray(value) ? value[0] : value;
80
+ if (typeof raw === "string" && raw.endsWith("%"))
81
+ return null;
82
+ const n = typeof raw === "string" || typeof raw === "number" ? Number(raw) : NaN;
83
+ return Number.isFinite(n) ? n : null;
84
+ }
85
+ /** The largest number in a value (for per-slot lists like max volumetric speed), or null. */
86
+ export function largestNumber(value) {
87
+ const values = (Array.isArray(value) ? value : [value]).map((v) => (typeof v === "string" || typeof v === "number" ? Number(v) : NaN)).filter(Number.isFinite);
88
+ return values.length > 0 ? Math.max(...values) : null;
89
+ }
@@ -0,0 +1,40 @@
1
+ import type { FilamentSlot } from "./extractFilamentSlots.js";
2
+ import { type FilamentComplianceMode, type FilamentNameTable } from "./filamentComplianceNames.js";
3
+ export interface RenamedFilament {
4
+ /** 0-based slot index. */
5
+ slot: number;
6
+ before: string;
7
+ after: string;
8
+ }
9
+ export interface ApplyFilamentComplianceModeResult {
10
+ slots: FilamentSlot[];
11
+ filamentKeyArrays: Record<string, unknown[]> | null;
12
+ /** Product lines that use Generic because Snapmaker has no preset for them at this nozzle size, deduped, in first-seen order. */
13
+ fellBackToGenericMaterials: string[];
14
+ /** Filaments left as the creator named them because no Snapmaker or Generic preset fits (their line, or material when no line), deduped. */
15
+ unchangedMaterials: string[];
16
+ /** Each slot whose name changed. */
17
+ renamed: RenamedFilament[];
18
+ }
19
+ /**
20
+ * Overrides each filament slot's identity with a real Generic/Snapmaker
21
+ * preset's, for marketplace-compliance purposes -- e.g. Snapmaker Space
22
+ * (space.snapmaker.com), Snapmaker's own model platform, requiring uploads
23
+ * to declare Generic or Snapmaker filament rather than a third-party brand
24
+ * like Bambu's own. The identity is what Snapmaker Orca itself records when
25
+ * someone picks that preset: `filament_settings_id` (the name),
26
+ * `filament_ids` and `filament_vendor`, all three together, so the file
27
+ * never says "Snapmaker PLA..." next to Bambu's vendor or id. Written to
28
+ * the slot and to the matching entries in `filamentKeyArrays`, which is
29
+ * what reaches the merged `project_settings.config`.
30
+ *
31
+ * Identity-only: never touches the slot's actual physical properties
32
+ * (temps, retraction, flow, etc.) -- those came from the real filament the
33
+ * creator used and stay exactly as tuned. A slot no preset fits (unknown
34
+ * material, or none at this nozzle size) is left completely untouched
35
+ * rather than guessed at, and reported.
36
+ *
37
+ * @param table the profile catalog's `filamentNames`; without it every slot is left as it is and reported.
38
+ * @param printerId the target printer: names exist per nozzle size, so they follow the printer converted to, not the source.
39
+ */
40
+ export declare function applyFilamentComplianceMode(slots: FilamentSlot[], filamentKeyArrays: Record<string, unknown[]> | null, mode: FilamentComplianceMode, table: FilamentNameTable | undefined, printerId: string): ApplyFilamentComplianceModeResult;
@@ -0,0 +1,68 @@
1
+ import { resolveFilamentName } from "./filamentComplianceNames.js";
2
+ /** The keys a saved project records a filament preset's identity in, one entry per slot. */
3
+ const IDENTITY_KEYS = ["filament_settings_id", "filament_ids", "filament_vendor"];
4
+ /**
5
+ * Overrides each filament slot's identity with a real Generic/Snapmaker
6
+ * preset's, for marketplace-compliance purposes -- e.g. Snapmaker Space
7
+ * (space.snapmaker.com), Snapmaker's own model platform, requiring uploads
8
+ * to declare Generic or Snapmaker filament rather than a third-party brand
9
+ * like Bambu's own. The identity is what Snapmaker Orca itself records when
10
+ * someone picks that preset: `filament_settings_id` (the name),
11
+ * `filament_ids` and `filament_vendor`, all three together, so the file
12
+ * never says "Snapmaker PLA..." next to Bambu's vendor or id. Written to
13
+ * the slot and to the matching entries in `filamentKeyArrays`, which is
14
+ * what reaches the merged `project_settings.config`.
15
+ *
16
+ * Identity-only: never touches the slot's actual physical properties
17
+ * (temps, retraction, flow, etc.) -- those came from the real filament the
18
+ * creator used and stay exactly as tuned. A slot no preset fits (unknown
19
+ * material, or none at this nozzle size) is left completely untouched
20
+ * rather than guessed at, and reported.
21
+ *
22
+ * @param table the profile catalog's `filamentNames`; without it every slot is left as it is and reported.
23
+ * @param printerId the target printer: names exist per nozzle size, so they follow the printer converted to, not the source.
24
+ */
25
+ export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, table, printerId) {
26
+ const fellBackToGeneric = new Set();
27
+ const unchanged = new Set();
28
+ const renamed = [];
29
+ const arrays = {};
30
+ for (const key of IDENTITY_KEYS)
31
+ if (filamentKeyArrays?.[key])
32
+ arrays[key] = [...filamentKeyArrays[key]];
33
+ const newSlots = slots.map((slot, i) => {
34
+ const filamentType = typeof slot.filament_type === "string" ? slot.filament_type : "";
35
+ const filamentSettingsId = typeof slot.filament_settings_id === "string" ? slot.filament_settings_id : "";
36
+ if (!table) {
37
+ unchanged.add(filamentType || "unknown material");
38
+ return slot;
39
+ }
40
+ const result = resolveFilamentName(table, printerId, filamentType, filamentSettingsId, mode);
41
+ if (!result.preset) {
42
+ unchanged.add(result.line?.label ?? (filamentType || "unknown material"));
43
+ return slot;
44
+ }
45
+ if (result.outcome === "generic")
46
+ fellBackToGeneric.add(result.line?.label ?? filamentType);
47
+ if (result.preset.name !== filamentSettingsId)
48
+ 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 };
50
+ for (const key of IDENTITY_KEYS) {
51
+ const list = arrays[key];
52
+ if (list && i < list.length)
53
+ list[i] = values[key];
54
+ }
55
+ const next = { ...slot, filament_settings_id: values.filament_settings_id, filament_vendor: values.filament_vendor };
56
+ if (Object.hasOwn(slot, "filament_ids"))
57
+ next.filament_ids = values.filament_ids;
58
+ return next;
59
+ });
60
+ const newFilamentKeyArrays = filamentKeyArrays && Object.keys(arrays).length > 0 ? { ...filamentKeyArrays, ...arrays } : filamentKeyArrays;
61
+ return {
62
+ slots: newSlots,
63
+ filamentKeyArrays: newFilamentKeyArrays,
64
+ fellBackToGenericMaterials: [...fellBackToGeneric],
65
+ unchangedMaterials: [...unchanged],
66
+ renamed,
67
+ };
68
+ }
@@ -0,0 +1,42 @@
1
+ import type { JsonRecord } from "./types.js";
2
+ /**
3
+ * Filament settings that Snapmaker Orca 2.4 stores once per flow variant
4
+ * (standard, high flow) on a nozzle with a high-flow option. Mirrors
5
+ * `filament_flow_variant_options()` in Snapmaker Orca's PrintConfig.cpp.
6
+ */
7
+ export declare const FILAMENT_FLOW_VARIANT_KEYS: readonly ["filament_flow_ratio", "enable_pressure_advance", "pressure_advance", "nozzle_temperature_initial_layer", "nozzle_temperature", "filament_max_volumetric_speed", "fan_min_speed", "fan_max_speed", "additional_cooling_fan_speed", "filament_retraction_length", "filament_retraction_speed", "filament_deretraction_speed", "filament_z_hop_types", "filament_wipe_distance", "filament_retract_length_toolchange", "filament_multitool_ramming", "filament_multitool_ramming_volume", "filament_multitool_ramming_flow", "filament_minimal_purge_on_wipe_tower"];
8
+ /**
9
+ * The most plastic per second a converted file asks for, mm³/s. These are
10
+ * Snapmaker's own numbers for its fastest stock U1 filament (Snapmaker PLA
11
+ * Matte @U1: 22 standard, 40 high flow). A creator's lower value is kept.
12
+ */
13
+ export declare const MAX_VOLUMETRIC_SPEED: {
14
+ readonly standard: 22;
15
+ readonly highFlow: 40;
16
+ };
17
+ /**
18
+ * Lays out the per-variant filament settings the way Snapmaker Orca does
19
+ * and caps each filament's max volumetric speed.
20
+ *
21
+ * On a nozzle with a high-flow option (the U1's 0.4), every per-variant
22
+ * setting gets two values per filament, standard then high flow, with
23
+ * `filament_flow_step_size` 2 and the matching `filament_flow_support`
24
+ * declarations; which one a filament prints with is chosen in Snapmaker
25
+ * Orca when it's assigned to a toolhead (`filament_volume_type`, standard
26
+ * until then). The standard value is what the converter already has for
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
30
+ * filamentVariantLayout.ts), otherwise Snapmaker's stock high-flow value
31
+ * for settings the source doesn't carry, otherwise the standard value.
32
+ *
33
+ * Other nozzle sizes keep one value per filament.
34
+ *
35
+ * Max volumetric speed is then capped at 22 mm³/s for a standard toolhead
36
+ * and 40 mm³/s for a high-flow one (`MAX_VOLUMETRIC_SPEED`).
37
+ *
38
+ * @param fromSource filament keys whose per-slot values came from the source.
39
+ */
40
+ export declare function applyFilamentFlowVariants(settings: JsonRecord, source: JsonRecord, baseline: JsonRecord, highFlowSupported: boolean, fromSource: ReadonlySet<string>, slotCount: number, warnings: string[], options?: {
41
+ capVolumetricSpeed?: boolean;
42
+ }): void;
@@ -0,0 +1,109 @@
1
+ // SPDX-License-Identifier: MIT
2
+ import { detectHighFlowVariantIndex } from "./detectVariantIndex.js";
3
+ import { filamentVariantLayout } from "./filamentVariantLayout.js";
4
+ /**
5
+ * Filament settings that Snapmaker Orca 2.4 stores once per flow variant
6
+ * (standard, high flow) on a nozzle with a high-flow option. Mirrors
7
+ * `filament_flow_variant_options()` in Snapmaker Orca's PrintConfig.cpp.
8
+ */
9
+ export const FILAMENT_FLOW_VARIANT_KEYS = [
10
+ "filament_flow_ratio",
11
+ "enable_pressure_advance",
12
+ "pressure_advance",
13
+ "nozzle_temperature_initial_layer",
14
+ "nozzle_temperature",
15
+ "filament_max_volumetric_speed",
16
+ "fan_min_speed",
17
+ "fan_max_speed",
18
+ "additional_cooling_fan_speed",
19
+ "filament_retraction_length",
20
+ "filament_retraction_speed",
21
+ "filament_deretraction_speed",
22
+ "filament_z_hop_types",
23
+ "filament_wipe_distance",
24
+ "filament_retract_length_toolchange",
25
+ "filament_multitool_ramming",
26
+ "filament_multitool_ramming_volume",
27
+ "filament_multitool_ramming_flow",
28
+ "filament_minimal_purge_on_wipe_tower",
29
+ ];
30
+ /**
31
+ * The most plastic per second a converted file asks for, mm³/s. These are
32
+ * Snapmaker's own numbers for its fastest stock U1 filament (Snapmaker PLA
33
+ * Matte @U1: 22 standard, 40 high flow). A creator's lower value is kept.
34
+ */
35
+ export const MAX_VOLUMETRIC_SPEED = { standard: 22, highFlow: 40 };
36
+ const cap = (value, limit) => {
37
+ if (typeof value !== "string" || value === "nil")
38
+ return value;
39
+ const n = Number(value);
40
+ return Number.isFinite(n) && n > limit ? String(limit) : value;
41
+ };
42
+ /**
43
+ * Lays out the per-variant filament settings the way Snapmaker Orca does
44
+ * and caps each filament's max volumetric speed.
45
+ *
46
+ * On a nozzle with a high-flow option (the U1's 0.4), every per-variant
47
+ * setting gets two values per filament, standard then high flow, with
48
+ * `filament_flow_step_size` 2 and the matching `filament_flow_support`
49
+ * declarations; which one a filament prints with is chosen in Snapmaker
50
+ * Orca when it's assigned to a toolhead (`filament_volume_type`, standard
51
+ * until then). The standard value is what the converter already has for
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
55
+ * filamentVariantLayout.ts), otherwise Snapmaker's stock high-flow value
56
+ * for settings the source doesn't carry, otherwise the standard value.
57
+ *
58
+ * Other nozzle sizes keep one value per filament.
59
+ *
60
+ * Max volumetric speed is then capped at 22 mm³/s for a standard toolhead
61
+ * and 40 mm³/s for a high-flow one (`MAX_VOLUMETRIC_SPEED`).
62
+ *
63
+ * @param fromSource filament keys whose per-slot values came from the source.
64
+ */
65
+ export function applyFilamentFlowVariants(settings, source, baseline, highFlowSupported, fromSource, slotCount, warnings, options = {}) {
66
+ if (slotCount < 1)
67
+ return;
68
+ const perSlot = (value) => Array.from({ length: slotCount }, () => value);
69
+ if (!highFlowSupported) {
70
+ settings.filament_flow_step_size = perSlot("1");
71
+ settings.filament_flow_support = perSlot("standard");
72
+ settings.filament_volume_type = perSlot("standard");
73
+ }
74
+ else {
75
+ const sourceHighFlow = detectHighFlowVariantIndex(source);
76
+ const layout = filamentVariantLayout(source, slotCount);
77
+ for (const key of FILAMENT_FLOW_VARIANT_KEYS) {
78
+ const standard = settings[key];
79
+ if (!Array.isArray(standard) || standard.length !== slotCount)
80
+ continue;
81
+ const fromSourceValues = source[key];
82
+ const group = Array.isArray(fromSourceValues) && fromSourceValues.length % slotCount === 0 ? fromSourceValues.length / slotCount : 0;
83
+ const stock = baseline[key];
84
+ const highFlowFor = (i) => {
85
+ if (fromSource.has(key)) {
86
+ if (layout && Array.isArray(fromSourceValues) && fromSourceValues.length === layout.length) {
87
+ const position = layout.slots[i].highFlow;
88
+ return position === null ? standard[i] : fromSourceValues[position];
89
+ }
90
+ return sourceHighFlow !== null && group > sourceHighFlow ? fromSourceValues[i * group + sourceHighFlow] : standard[i];
91
+ }
92
+ return Array.isArray(stock) && stock.length >= 2 ? stock[1] : standard[i];
93
+ };
94
+ settings[key] = standard.flatMap((value, i) => [value, highFlowFor(i)]);
95
+ }
96
+ settings.filament_flow_step_size = perSlot("2");
97
+ settings.filament_flow_support = Array.from({ length: slotCount }, () => ["standard", "high_flow"]).flat();
98
+ settings.filament_volume_type = perSlot("standard");
99
+ }
100
+ const speeds = settings.filament_max_volumetric_speed;
101
+ if (!Array.isArray(speeds) || options.capVolumetricSpeed === false)
102
+ return;
103
+ const step = highFlowSupported ? 2 : 1;
104
+ const capped = speeds.map((value, i) => cap(value, step === 2 && i % 2 === 1 ? MAX_VOLUMETRIC_SPEED.highFlow : MAX_VOLUMETRIC_SPEED.standard));
105
+ if (JSON.stringify(capped) !== JSON.stringify(speeds)) {
106
+ settings.filament_max_volumetric_speed = capped;
107
+ warnings.push(` WARN: Filament max volumetric speed lowered to at most ${MAX_VOLUMETRIC_SPEED.standard} mm³/s${highFlowSupported ? ` (${MAX_VOLUMETRIC_SPEED.highFlow} mm³/s on a high-flow toolhead)` : ""}, Snapmaker's value for its fastest U1 filament. Raise it in Snapmaker Orca if your filament can melt faster.`);
108
+ }
109
+ }
@@ -0,0 +1,52 @@
1
+ import type { JsonRecord } from "./types.js";
2
+ /**
3
+ * Process keys Snapmaker Orca 2.4.0 stores per flow variant, as `[standard,
4
+ * high_flow]`, on a tier that has high-flow tuning. Taken from projects
5
+ * Snapmaker Orca itself saved on "0.20mm Standard @Snapmaker U1 (0.4 nozzle)"
6
+ * (keys it writes as two-entry lists that a converted file carries as one
7
+ * value). Snapmaker Orca then picks each toolhead's values from its entry in
8
+ * `nozzle_volume_type`, so one print can run a high-flow toolhead and a
9
+ * standard one at their own speeds; verified in sliced G-code.
10
+ */
11
+ export declare const VARIANT_PROCESS_KEYS: readonly ["accel_to_decel_enable", "accel_to_decel_factor", "bridge_acceleration", "bridge_speed", "default_acceleration", "default_jerk", "default_junction_deviation", "enable_overhang_speed", "extrusion_rate_smoothing_external_perimeter_only", "gap_infill_speed", "infill_jerk", "initial_layer_acceleration", "initial_layer_infill_speed", "initial_layer_jerk", "initial_layer_speed", "initial_layer_travel_speed", "inner_wall_acceleration", "inner_wall_jerk", "inner_wall_speed", "internal_bridge_speed", "internal_solid_infill_acceleration", "internal_solid_infill_speed", "ironing_speed", "max_volumetric_extrusion_rate_slope", "max_volumetric_extrusion_rate_slope_segment_length", "outer_wall_acceleration", "outer_wall_jerk", "outer_wall_speed", "overhang_1_4_speed", "overhang_2_4_speed", "overhang_3_4_speed", "overhang_4_4_speed", "slow_down_layers", "slowdown_for_curled_perimeters", "small_perimeter_speed", "small_perimeter_threshold", "sparse_infill_acceleration", "sparse_infill_speed", "support_interface_speed", "support_speed", "top_surface_acceleration", "top_surface_jerk", "top_surface_speed", "travel_acceleration", "travel_jerk", "travel_speed"];
12
+ /**
13
+ * Which toolheads have the Liber High Flow Hotend, one entry per toolhead,
14
+ * or null for none. `true` means all of them. A list must name every
15
+ * toolhead (the U1 has four), so a short or long list is a caller error,
16
+ * not something to guess about.
17
+ */
18
+ export declare function resolveHighFlowSelection(value: boolean | readonly boolean[] | undefined, toolheads: number): boolean[] | null;
19
+ /** The tier's own high-flow values, and the standard values they replace, for the keys Snapmaker tunes. */
20
+ export interface HighFlowTuning {
21
+ standard: Record<string, string>;
22
+ highFlow: Record<string, string>;
23
+ }
24
+ /**
25
+ * Sets a converted project up for the Snapmaker Liber High Flow
26
+ * Hotend on the selected toolheads, the way Snapmaker Orca saves it:
27
+ *
28
+ * - `nozzle_volume_type` lists every toolhead, "high_flow" or "standard",
29
+ * so the file matches the printer. Without it Snapmaker Orca opens the project
30
+ * with all toolheads on standard.
31
+ * - On a tier with its own high-flow tuning, the process carries both
32
+ * variants: `process_flow_support`/`printer_flow_support` are
33
+ * `["standard", "high_flow"]` and every VARIANT_PROCESS_KEYS key becomes
34
+ * `[standard, high_flow]`. The tuned keys get Snapmaker's high-flow value
35
+ * in the second slot, unless the creator changed that value from the
36
+ * tier's standard one, in which case their value is used in both slots
37
+ * (a creator's tuning always wins, as it does for standard speeds).
38
+ * - `filament_volume_type` says, per filament, whether it slices with its
39
+ * standard or its high-flow filament values (temperature, max volumetric
40
+ * speed, pressure advance...); Snapmaker Orca uses this, not the toolhead's own
41
+ * type, verified in sliced G-code. A filament takes the type of the
42
+ * toolhead it prints on: filament N prints as tool T(N-1), so filaments 1
43
+ * to 4 follow toolheads 1 to 4. Filaments beyond the toolhead count are
44
+ * swapped onto a toolhead chosen when printing, so they take the type all
45
+ * toolheads share, or standard (with a note) when the toolheads differ.
46
+ * - A tier without high-flow tuning keeps its normal speeds, as it does in
47
+ * Snapmaker Orca, and gets a note saying so.
48
+ *
49
+ * Every key written is added to different_settings_to_system so Snapmaker Orca keeps
50
+ * it instead of falling back to the system preset. Mutates `settings`.
51
+ */
52
+ export declare function applyHighFlowHotends(settings: JsonRecord, selection: readonly boolean[], tuning: HighFlowTuning | null, warnings: string[]): void;
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Process keys Snapmaker Orca 2.4.0 stores per flow variant, as `[standard,
3
+ * high_flow]`, on a tier that has high-flow tuning. Taken from projects
4
+ * Snapmaker Orca itself saved on "0.20mm Standard @Snapmaker U1 (0.4 nozzle)"
5
+ * (keys it writes as two-entry lists that a converted file carries as one
6
+ * value). Snapmaker Orca then picks each toolhead's values from its entry in
7
+ * `nozzle_volume_type`, so one print can run a high-flow toolhead and a
8
+ * standard one at their own speeds; verified in sliced G-code.
9
+ */
10
+ export const VARIANT_PROCESS_KEYS = [
11
+ "accel_to_decel_enable", "accel_to_decel_factor", "bridge_acceleration", "bridge_speed", "default_acceleration",
12
+ "default_jerk", "default_junction_deviation", "enable_overhang_speed", "extrusion_rate_smoothing_external_perimeter_only",
13
+ "gap_infill_speed", "infill_jerk", "initial_layer_acceleration", "initial_layer_infill_speed", "initial_layer_jerk",
14
+ "initial_layer_speed", "initial_layer_travel_speed", "inner_wall_acceleration", "inner_wall_jerk", "inner_wall_speed",
15
+ "internal_bridge_speed", "internal_solid_infill_acceleration", "internal_solid_infill_speed", "ironing_speed",
16
+ "max_volumetric_extrusion_rate_slope", "max_volumetric_extrusion_rate_slope_segment_length", "outer_wall_acceleration",
17
+ "outer_wall_jerk", "outer_wall_speed", "overhang_1_4_speed", "overhang_2_4_speed", "overhang_3_4_speed",
18
+ "overhang_4_4_speed", "slow_down_layers", "slowdown_for_curled_perimeters", "small_perimeter_speed",
19
+ "small_perimeter_threshold", "sparse_infill_acceleration", "sparse_infill_speed", "support_interface_speed",
20
+ "support_speed", "top_surface_acceleration", "top_surface_jerk", "top_surface_speed", "travel_acceleration",
21
+ "travel_jerk", "travel_speed",
22
+ ];
23
+ const FLOW_VARIANTS = ["standard", "high_flow"];
24
+ /**
25
+ * Which toolheads have the Liber High Flow Hotend, one entry per toolhead,
26
+ * or null for none. `true` means all of them. A list must name every
27
+ * toolhead (the U1 has four), so a short or long list is a caller error,
28
+ * not something to guess about.
29
+ */
30
+ export function resolveHighFlowSelection(value, toolheads) {
31
+ if (value === undefined || value === false)
32
+ return null;
33
+ if (value === true)
34
+ return new Array(toolheads).fill(true);
35
+ if (value.length !== toolheads) {
36
+ throw new Error(`highFlowHotends lists ${value.length} toolhead(s), but this printer has ${toolheads}.`);
37
+ }
38
+ return value.some(Boolean) ? value.map(Boolean) : null;
39
+ }
40
+ /**
41
+ * Sets a converted project up for the Snapmaker Liber High Flow
42
+ * Hotend on the selected toolheads, the way Snapmaker Orca saves it:
43
+ *
44
+ * - `nozzle_volume_type` lists every toolhead, "high_flow" or "standard",
45
+ * so the file matches the printer. Without it Snapmaker Orca opens the project
46
+ * with all toolheads on standard.
47
+ * - On a tier with its own high-flow tuning, the process carries both
48
+ * variants: `process_flow_support`/`printer_flow_support` are
49
+ * `["standard", "high_flow"]` and every VARIANT_PROCESS_KEYS key becomes
50
+ * `[standard, high_flow]`. The tuned keys get Snapmaker's high-flow value
51
+ * in the second slot, unless the creator changed that value from the
52
+ * tier's standard one, in which case their value is used in both slots
53
+ * (a creator's tuning always wins, as it does for standard speeds).
54
+ * - `filament_volume_type` says, per filament, whether it slices with its
55
+ * standard or its high-flow filament values (temperature, max volumetric
56
+ * speed, pressure advance...); Snapmaker Orca uses this, not the toolhead's own
57
+ * type, verified in sliced G-code. A filament takes the type of the
58
+ * toolhead it prints on: filament N prints as tool T(N-1), so filaments 1
59
+ * to 4 follow toolheads 1 to 4. Filaments beyond the toolhead count are
60
+ * swapped onto a toolhead chosen when printing, so they take the type all
61
+ * toolheads share, or standard (with a note) when the toolheads differ.
62
+ * - A tier without high-flow tuning keeps its normal speeds, as it does in
63
+ * Snapmaker Orca, and gets a note saying so.
64
+ *
65
+ * Every key written is added to different_settings_to_system so Snapmaker Orca keeps
66
+ * it instead of falling back to the system preset. Mutates `settings`.
67
+ */
68
+ export function applyHighFlowHotends(settings, selection, tuning, warnings) {
69
+ const written = new Set(["nozzle_volume_type"]);
70
+ settings.nozzle_volume_type = selection.map((hasHighFlow) => (hasHighFlow ? "high_flow" : "standard"));
71
+ // Project state like filament_colour, not a preset setting, so it isn't flagged in different_settings_to_system.
72
+ const filamentTypes = settings.filament_volume_type;
73
+ if (Array.isArray(filamentTypes)) {
74
+ const shared = selection.every(Boolean) ? "high_flow" : selection.some(Boolean) ? null : "standard";
75
+ settings.filament_volume_type = filamentTypes.map((_, i) => (i < selection.length ? (selection[i] ? "high_flow" : "standard") : (shared ?? "standard")));
76
+ if (filamentTypes.length > selection.length && shared === null) {
77
+ warnings.push(` WARN: filaments ${selection.length + 1} and up share a toolhead chosen when printing, and only some toolheads have the Liber High Flow Hotend, so they use their standard filament values. In Snapmaker Orca, switch any that will print on a high-flow toolhead to high flow.`);
78
+ }
79
+ }
80
+ if (tuning) {
81
+ for (const key of VARIANT_PROCESS_KEYS) {
82
+ if (!(key in settings))
83
+ continue;
84
+ const value = settings[key];
85
+ if (Array.isArray(value) && value.length !== 1)
86
+ continue;
87
+ const single = Array.isArray(value) ? value[0] : value;
88
+ settings[key] = [single, single];
89
+ written.add(key);
90
+ }
91
+ for (const [key, highFlowValue] of Object.entries(tuning.highFlow)) {
92
+ const current = settings[key];
93
+ const standardValue = Array.isArray(current) ? current[0] : current;
94
+ if (standardValue === undefined)
95
+ continue;
96
+ const creatorChanged = String(standardValue) !== String(tuning.standard[key]);
97
+ settings[key] = [standardValue, creatorChanged ? standardValue : highFlowValue];
98
+ written.add(key);
99
+ }
100
+ settings.process_flow_support = [...FLOW_VARIANTS];
101
+ settings.printer_flow_support = [...FLOW_VARIANTS];
102
+ written.add("process_flow_support");
103
+ written.add("printer_flow_support");
104
+ }
105
+ else {
106
+ warnings.push(" WARN: this profile has no separate high-flow speeds in Snapmaker's presets, so it uses its normal speeds; the selected toolheads are still set to the Liber High Flow Hotend.");
107
+ }
108
+ const diffs = settings.different_settings_to_system;
109
+ if (Array.isArray(diffs) && typeof diffs[0] === "string") {
110
+ const flagged = new Set(diffs[0].split(";").filter(Boolean));
111
+ for (const key of written)
112
+ flagged.add(key);
113
+ settings.different_settings_to_system = [[...flagged].sort().join(";"), ...diffs.slice(1)];
114
+ }
115
+ }
@@ -0,0 +1,12 @@
1
+ import type { JsonRecord } from "./types.js";
2
+ /**
3
+ * Writes a preset's values over the merged settings, so the user's own
4
+ * values win over the creator's. The caller has already checked every key
5
+ * and value (resolvePreset); only keys the profile has are written, so each
6
+ * one is already flagged in different_settings_to_system.
7
+ *
8
+ * A setting stored per hotend type (`[standard, high_flow]`) gets the
9
+ * preset's value as its standard entry; the high-flow entry is left to the
10
+ * profile and the high-flow option, which run after this.
11
+ */
12
+ export declare function applyPresetChanges(settings: JsonRecord, changes: Readonly<Record<string, string | string[]>>, warnings: string[]): void;