any2orca 0.0.1 → 0.1.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 +70 -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 +14 -0
  142. package/dist/engine/policy.js +266 -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 +197 -0
  161. package/dist/index.d.ts +49 -0
  162. package/dist/index.js +33 -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 +314 -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 +78 -12
  194. package/index.js +0 -3
@@ -0,0 +1,266 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Conversion policy: which source settings are dropped, which are always
4
+ * kept, which are forced, and which filament keys never transfer. These are
5
+ * the project's own decisions, applied the same way to every profile, so they live in the
6
+ * core rather than in the profile data.
7
+ */
8
+ export const BLOCKLIST = [
9
+ "version",
10
+ "printer_model",
11
+ "print_settings_id",
12
+ "printer_settings_id",
13
+ "exclude_object",
14
+ "filename_format",
15
+ "different_settings_to_system",
16
+ "standby_temperature_delta",
17
+ "preheat_time",
18
+ "printable_area",
19
+ "bed_exclude_area",
20
+ "printable_height",
21
+ "extruder_clearance_height_to_lid",
22
+ "extruder_clearance_height_to_rod",
23
+ "extruder_clearance_radius",
24
+ "gcode_flavor",
25
+ "bed_custom_model",
26
+ "bed_custom_texture",
27
+ "nozzle_type",
28
+ "nozzle_volume",
29
+ "nozzle_diameter",
30
+ "max_layer_height",
31
+ "min_layer_height",
32
+ "machine_max_acceleration_e",
33
+ "machine_max_acceleration_extruding",
34
+ "machine_max_acceleration_retracting",
35
+ "machine_max_acceleration_travel",
36
+ "machine_max_acceleration_x",
37
+ "machine_max_acceleration_y",
38
+ "machine_max_acceleration_z",
39
+ "machine_max_jerk_e",
40
+ "machine_max_jerk_x",
41
+ "machine_max_jerk_y",
42
+ "machine_max_jerk_z",
43
+ "machine_max_speed_e",
44
+ "machine_max_speed_x",
45
+ "machine_max_speed_y",
46
+ "machine_max_speed_z",
47
+ "machine_min_extruding_rate",
48
+ "machine_min_travel_rate",
49
+ "accel_to_decel_enable",
50
+ "travel_jerk",
51
+ "default_jerk",
52
+ "infill_jerk",
53
+ "initial_layer_jerk",
54
+ "inner_wall_jerk",
55
+ "outer_wall_jerk",
56
+ "top_surface_jerk",
57
+ ];
58
+ // The customization gate: unless the source's own
59
+ // different_settings_to_system flags a key as something the creator
60
+ // actually customized in Bambu Studio -- not just any transferable
61
+ // difference, which is often just Bambu's own printer/preset default
62
+ // reported incidentally -- the selected U1 tier's own tuned value wins.
63
+ // BLOCKLIST and MIN_COMPARISON_KEYS are handled separately/take
64
+ // precedence; every other key goes through this gate in
65
+ // buildProjectSettings.ts. Without it, a real conversion had wipe_speed, seam_gap, min_width_top_surface, and
66
+ // bridge_flow/bridge_density all diverged from the selected U1 tier's own
67
+ // values even though the creator never touched any of them in Bambu Studio.
68
+ //
69
+ // MIN_COMPARISON_KEYS: travel_speed and every feature-level *_acceleration
70
+ // setting describe what's mechanically safe/appropriate on the U1
71
+ // specifically, not a portable creator preference -- so instead of the
72
+ // customization gate above, Bambu's value is honored only when it's LOWER
73
+ // (more conservative) than the U1 tier's own default, regardless of
74
+ // whether the creator explicitly customized it; a HIGHER Bambu value is
75
+ // always ignored, since it could exceed what's actually safe/intended on
76
+ // this different printer. Deliberately excludes machine_max_*/*_jerk
77
+ // (BLOCKLIST, above) -- those have no meaningful "creator preference vs.
78
+ // mechanical limit" spectrum at all, so they stay a hard block rather than
79
+ // a comparison.
80
+ export const MIN_COMPARISON_KEYS = [
81
+ "travel_speed",
82
+ "bridge_acceleration",
83
+ "default_acceleration",
84
+ "initial_layer_acceleration",
85
+ "inner_wall_acceleration",
86
+ "internal_solid_infill_acceleration",
87
+ "outer_wall_acceleration",
88
+ "sparse_infill_acceleration",
89
+ "top_surface_acceleration",
90
+ "travel_acceleration",
91
+ ];
92
+ // Keys that must always
93
+ // track Bambu's real value, regardless of the customization-flag gate
94
+ // every other key goes through. Two distinct reasons land a key here:
95
+ //
96
+ // 1. print_sequence: not a quality/taste preference at all -- it's
97
+ // coupled to the object LAYOUT that computeShifts already relies on.
98
+ // "By Object" needs real XY clearance between every object's full
99
+ // height; "By Layer" needs none. Bambu Studio's own object placement/
100
+ // spacing in the source file was computed assuming whichever mode
101
+ // Bambu actually used. A real conversion caught this directly: the
102
+ // source used "by layer" (unflagged, since it's Bambu's own default,
103
+ // not something the creator toggled) but the U1 templates default to
104
+ // "by object", producing real bounding-box overlaps once printed with
105
+ // clearance the source layout never accounted for.
106
+ //
107
+ // 2. sparse_infill_density/skin_infill_density/skeleton_infill_density:
108
+ // a genuine, deliberate creator strength/print-time choice -- but
109
+ // Bambu's different_settings_to_system only flags a DEVIATION FROM
110
+ // BAMBU'S OWN preset, not "did the creator ever think about this
111
+ // setting." A creator who saved/selected a custom Bambu preset with
112
+ // 15% infill baked in never "customizes" it away from that preset's
113
+ // own default, so Bambu never flags it -- even though 15% vs. the U1
114
+ // tier's own 10% is exactly the kind of thing the customization gate
115
+ // was meant to catch. A real conversion caught this directly: all
116
+ // three showed the U1 tier's own (lower) density instead of the
117
+ // source's real, unflagged 15%.
118
+ //
119
+ // 3. initial_layer_print_height: same underlying reason as #2 (Bambu's
120
+ // flag doesn't cover a custom-preset's own baked-in value). Unlike
121
+ // layer_height (NOT in this set: it's tier-defining and stays gated).
122
+ //
123
+ // 4. brim_type: not a cosmetic/taste preference like most gated keys --
124
+ // it's a bed-adhesion decision, and losing it silently can mean the
125
+ // difference between a print succeeding and failing outright, not
126
+ // just looking slightly different. Same root cause as #2/#3: a
127
+ // source printer's own un-customized default (e.g. a Bambu H2D
128
+ // profile defaulting to "auto_brim") never gets flagged in
129
+ // different_settings_to_system, so the ordinary gated path silently
130
+ // replaced it with the U1 tier's own "no_brim" default, as seen
131
+ // in a real conversion.
132
+ export const ALWAYS_TRANSFER_KEYS = [
133
+ "print_sequence",
134
+ "sparse_infill_density",
135
+ "skin_infill_density",
136
+ "skeleton_infill_density",
137
+ "initial_layer_print_height",
138
+ "brim_type",
139
+ ];
140
+ // Settings that always keep the U1 profile's own value, whatever the source
141
+ // file says. The profile is Snapmaker's stock profile for the pinned
142
+ // release, so these follow Snapmaker's updates; nothing here is a number of
143
+ // ours. They never transfer for one of two reasons:
144
+ //
145
+ // - The source's value doesn't suit the U1's Klipper firmware:
146
+ // enable_arc_fitting (arc moves are a Marlin-style feature).
147
+ // - The value is specific to the source printer or file layout and has no
148
+ // safe meaning on the U1: ensure_vertical_shell_thickness (Bambu Studio
149
+ // uses different options), ooze_prevention and tree_support_wall_count
150
+ // (tuned for the U1's toolchanger), and the filament slot used for walls
151
+ // and infill (wall_filament, sparse_infill_filament,
152
+ // solid_infill_filament).
153
+ //
154
+ // Tuning values (raft first-layer expansion, single-extruder priming,
155
+ // prime tower values) are not here: they follow the ordinary rule,
156
+ // Snapmaker's stock value unless the creator changed it.
157
+ export const U1_VALUE_KEYS = [
158
+ "enable_arc_fitting",
159
+ "ensure_vertical_shell_thickness",
160
+ "ooze_prevention",
161
+ "tree_support_wall_count",
162
+ "wall_filament",
163
+ "sparse_infill_filament",
164
+ "solid_infill_filament",
165
+ ];
166
+ // Printer (machine) settings never transfer from a source file: they belong
167
+ // to the U1 printer profile. This is the key set of Snapmaker's U1 machine
168
+ // preset (packages/profiles/templates/machine_settings_1.config; a test keeps
169
+ // the two in step). Together with every machine G-code key (see
170
+ // isMachineGcodeKey) and `from`, these always keep the U1 profile's value.
171
+ export const MACHINE_SETTINGS_KEYS = [
172
+ "auxiliary_fan",
173
+ "bed_exclude_area",
174
+ "bed_model",
175
+ "bed_texture",
176
+ "before_layer_change_gcode",
177
+ "change_filament_gcode",
178
+ "default_bed_type",
179
+ "default_filament_profile",
180
+ "default_print_profile",
181
+ "deretraction_speed",
182
+ "enable_filament_ramming",
183
+ "extruder_clearance_height_to_lid",
184
+ "extruder_clearance_height_to_rod",
185
+ "extruder_clearance_radius",
186
+ "extruder_colour",
187
+ "extruder_offset",
188
+ "gcode_flavor",
189
+ "host_type",
190
+ "is_custom_defined",
191
+ "layer_change_gcode",
192
+ "long_retractions_when_cut",
193
+ "machine_end_gcode",
194
+ "machine_load_filament_time",
195
+ "machine_max_acceleration_e",
196
+ "machine_max_acceleration_extruding",
197
+ "machine_max_acceleration_retracting",
198
+ "machine_max_acceleration_travel",
199
+ "machine_max_acceleration_x",
200
+ "machine_max_acceleration_y",
201
+ "machine_max_acceleration_z",
202
+ "machine_max_jerk_e",
203
+ "machine_max_jerk_x",
204
+ "machine_max_jerk_y",
205
+ "machine_max_jerk_z",
206
+ "machine_max_speed_e",
207
+ "machine_max_speed_x",
208
+ "machine_max_speed_y",
209
+ "machine_max_speed_z",
210
+ "machine_min_extruding_rate",
211
+ "machine_min_travel_rate",
212
+ "machine_pause_gcode",
213
+ "machine_start_gcode",
214
+ "machine_tool_change_time",
215
+ "machine_unload_filament_time",
216
+ "max_layer_height",
217
+ "min_layer_height",
218
+ "name",
219
+ "nozzle_diameter",
220
+ "nozzle_type",
221
+ "nozzle_volume",
222
+ "printable_area",
223
+ "printable_height",
224
+ "printer_flow_support",
225
+ "printer_model",
226
+ "printer_notes",
227
+ "printer_settings_id",
228
+ "printer_technology",
229
+ "printer_variant",
230
+ "purge_in_prime_tower",
231
+ "ramming_pressure_advance_value",
232
+ "retract_before_wipe",
233
+ "retract_length_toolchange",
234
+ "retract_lift_above",
235
+ "retract_lift_below",
236
+ "retract_lift_enforce",
237
+ "retract_restart_extra",
238
+ "retract_restart_extra_toolchange",
239
+ "retract_when_changing_layer",
240
+ "retraction_distances_when_cut",
241
+ "retraction_length",
242
+ "retraction_minimum_travel",
243
+ "retraction_speed",
244
+ "scan_first_layer",
245
+ "silent_mode",
246
+ "single_extruder_multi_material",
247
+ "thumbnails",
248
+ "tool_change_temprature_wait",
249
+ "travel_slope",
250
+ "wipe",
251
+ "wipe_distance",
252
+ "z_hop",
253
+ "z_hop_types",
254
+ "z_hop_when_prime",
255
+ "from",
256
+ ];
257
+ /** Start, end, layer-change, filament-change and other machine G-code. A filament's own `filament_*_gcode` stays with the filament. */
258
+ export function isMachineGcodeKey(key) {
259
+ return key.endsWith("_gcode") && !key.startsWith("filament_");
260
+ }
261
+ export const FILAMENT_KEY_BLOCKLIST = [
262
+ "compatible_printers",
263
+ "compatible_printers_condition",
264
+ "compatible_prints",
265
+ "compatible_prints_condition",
266
+ ];
@@ -0,0 +1,30 @@
1
+ import type { JsonRecord } from "./types.js";
2
+ /**
3
+ * `brim_type` has a genuine cross-slicer semantic mismatch on one value:
4
+ * Bambu Studio's "Painted" brim mode (paint brim only at sharp corners of
5
+ * the model) is persisted as the literal string `"brim_ears"` -- not
6
+ * `"painted"` -- seen in real files, including a
7
+ * fresh re-save in a current Bambu Studio build (toggled to "No-brim",
8
+ * saved, toggled back to "Painted", saved again -- still wrote
9
+ * "brim_ears", so this isn't a stale/legacy value, it's Bambu Studio's
10
+ * permanent representation for that mode). OrcaSlicer (and therefore
11
+ * Snapmaker Orca) assigns that same string to a DIFFERENT, unrelated
12
+ * feature it added itself: "Mouse ear," fully automatic corner-brim
13
+ * detection with no painting involved at all. Orca has its own separate
14
+ * `"painted"` value for the manual-paint concept Bambu's UI actually
15
+ * means.
16
+ *
17
+ * A plain passthrough is byte-faithful to the source but semantically
18
+ * wrong the moment the output is opened in Orca -- the creator's real,
19
+ * deliberately-painted brim shows up mislabeled as (and conceptually
20
+ * replaced by) an unrelated automatic feature. Every source this tool
21
+ * converts from is Bambu-Studio-lineage (Bambu Studio itself, Creality
22
+ * Print, Anycubic Slicer Next -- all forks of the same codebase, none of
23
+ * them Orca-lineage), and the output always targets Orca-lineage
24
+ * (Snapmaker Orca/OrcaSlicer) -- so `"brim_ears"` arriving from any
25
+ * supported source always means "Painted" in Orca's own vocabulary,
26
+ * never genuinely "Mouse ear" (that value doesn't exist in Bambu
27
+ * Studio's own UI at all, confirmed against OrcaSlicer's PrintConfig.cpp,
28
+ * where it's marked as an Orca-only addition).
29
+ */
30
+ export declare function remapBrimType(settings: JsonRecord, warnings: string[]): JsonRecord;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * `brim_type` has a genuine cross-slicer semantic mismatch on one value:
3
+ * Bambu Studio's "Painted" brim mode (paint brim only at sharp corners of
4
+ * the model) is persisted as the literal string `"brim_ears"` -- not
5
+ * `"painted"` -- seen in real files, including a
6
+ * fresh re-save in a current Bambu Studio build (toggled to "No-brim",
7
+ * saved, toggled back to "Painted", saved again -- still wrote
8
+ * "brim_ears", so this isn't a stale/legacy value, it's Bambu Studio's
9
+ * permanent representation for that mode). OrcaSlicer (and therefore
10
+ * Snapmaker Orca) assigns that same string to a DIFFERENT, unrelated
11
+ * feature it added itself: "Mouse ear," fully automatic corner-brim
12
+ * detection with no painting involved at all. Orca has its own separate
13
+ * `"painted"` value for the manual-paint concept Bambu's UI actually
14
+ * means.
15
+ *
16
+ * A plain passthrough is byte-faithful to the source but semantically
17
+ * wrong the moment the output is opened in Orca -- the creator's real,
18
+ * deliberately-painted brim shows up mislabeled as (and conceptually
19
+ * replaced by) an unrelated automatic feature. Every source this tool
20
+ * converts from is Bambu-Studio-lineage (Bambu Studio itself, Creality
21
+ * Print, Anycubic Slicer Next -- all forks of the same codebase, none of
22
+ * them Orca-lineage), and the output always targets Orca-lineage
23
+ * (Snapmaker Orca/OrcaSlicer) -- so `"brim_ears"` arriving from any
24
+ * supported source always means "Painted" in Orca's own vocabulary,
25
+ * never genuinely "Mouse ear" (that value doesn't exist in Bambu
26
+ * Studio's own UI at all, confirmed against OrcaSlicer's PrintConfig.cpp,
27
+ * where it's marked as an Orca-only addition).
28
+ */
29
+ export function remapBrimType(settings, warnings) {
30
+ if (settings.brim_type !== "brim_ears")
31
+ return settings;
32
+ warnings.push(' Remapped brim_type "brim_ears" (Bambu Studio\'s own value for "Painted") to "painted": Orca and Snapmaker Orca use "brim_ears" for an unrelated automatic feature ("Mouse ear").');
33
+ return { ...settings, brim_type: "painted" };
34
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Reduce a Bambu per-(filament x nozzle-variant) array down to one value
3
+ * per filament slot. Bambu sometimes stores k values per filament (e.g.
4
+ * one per nozzle variant) as a flat array of length count*k; this takes
5
+ * one value from each filament's group of k, per `variantIndex`.
6
+ *
7
+ * @param variantIndex which of the k values within each filament's group
8
+ * to keep (see detectVariantIndex.ts) -- defaults to 0 (the first/
9
+ * Standard value), same as before that mechanism existed. Clamped to
10
+ * the group's own bounds so an out-of-range index can't produce
11
+ * `undefined` entries.
12
+ * @returns the reshaped array, or `null` if `values.length` isn't a clean
13
+ * multiple of `count` (can't safely reshape).
14
+ */
15
+ export declare function reshapeToCount<T>(values: T[], count: number, variantIndex?: number): T[] | null;
@@ -0,0 +1,27 @@
1
+ // SPDX-License-Identifier: MIT
2
+ /**
3
+ * Reduce a Bambu per-(filament x nozzle-variant) array down to one value
4
+ * per filament slot. Bambu sometimes stores k values per filament (e.g.
5
+ * one per nozzle variant) as a flat array of length count*k; this takes
6
+ * one value from each filament's group of k, per `variantIndex`.
7
+ *
8
+ * @param variantIndex which of the k values within each filament's group
9
+ * to keep (see detectVariantIndex.ts) -- defaults to 0 (the first/
10
+ * Standard value), same as before that mechanism existed. Clamped to
11
+ * the group's own bounds so an out-of-range index can't produce
12
+ * `undefined` entries.
13
+ * @returns the reshaped array, or `null` if `values.length` isn't a clean
14
+ * multiple of `count` (can't safely reshape).
15
+ */
16
+ export function reshapeToCount(values, count, variantIndex = 0) {
17
+ const n = values.length;
18
+ if (n === count) {
19
+ return [...values];
20
+ }
21
+ if (count > 0 && n % count === 0 && n > count) {
22
+ const group = n / count;
23
+ const offset = variantIndex >= 0 && variantIndex < group ? variantIndex : 0;
24
+ return Array.from({ length: count }, (_, i) => values[i * group + offset]);
25
+ }
26
+ return null;
27
+ }
@@ -0,0 +1,27 @@
1
+ import type { JsonRecord } from "./types.js";
2
+ export interface ResizedFlushVolumes {
3
+ flush_volumes_matrix: string[];
4
+ flush_volumes_vector: string[];
5
+ }
6
+ /**
7
+ * Sizes `flush_volumes_matrix` (n x n) and `flush_volumes_vector` (2n) for
8
+ * the output's n filaments, as strings, which is the only form Snapmaker
9
+ * Orca reads ("invalid json array" otherwise).
10
+ *
11
+ * Source files often don't match their own filament count: Bambu Studio
12
+ * doesn't always shrink the arrays when a filament is removed, and a
13
+ * two-nozzle printer (H2D, H2C) stores one n x n block per nozzle. Snapmaker
14
+ * Orca refuses a file whose matrix doesn't match ("Flush volumes matrix do
15
+ * not match to the correct size!") or crashes slicing it.
16
+ *
17
+ * Only the size matters on the U1: it isn't a single-extruder
18
+ * multi-material printer, so Snapmaker Orca zeroes the matrix before use
19
+ * (`WipeTower2.cpp::extract_wipe_volumes`) and purges by
20
+ * `filament_minimal_purge_on_wipe_tower` instead, while
21
+ * `number_of_extruders = sqrt(matrix.size())` still sizes its internal
22
+ * structures. So the top-left block is kept (a two-nozzle source's first
23
+ * nozzle) and anything missing is 0.
24
+ *
25
+ * @returns `null` when the source has no flush-volume arrays at all.
26
+ */
27
+ export declare function resizeFlushVolumes(bambuSettings: JsonRecord, filamentCount: number, warnings: string[]): ResizedFlushVolumes | null;
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Sizes `flush_volumes_matrix` (n x n) and `flush_volumes_vector` (2n) for
3
+ * the output's n filaments, as strings, which is the only form Snapmaker
4
+ * Orca reads ("invalid json array" otherwise).
5
+ *
6
+ * Source files often don't match their own filament count: Bambu Studio
7
+ * doesn't always shrink the arrays when a filament is removed, and a
8
+ * two-nozzle printer (H2D, H2C) stores one n x n block per nozzle. Snapmaker
9
+ * Orca refuses a file whose matrix doesn't match ("Flush volumes matrix do
10
+ * not match to the correct size!") or crashes slicing it.
11
+ *
12
+ * Only the size matters on the U1: it isn't a single-extruder
13
+ * multi-material printer, so Snapmaker Orca zeroes the matrix before use
14
+ * (`WipeTower2.cpp::extract_wipe_volumes`) and purges by
15
+ * `filament_minimal_purge_on_wipe_tower` instead, while
16
+ * `number_of_extruders = sqrt(matrix.size())` still sizes its internal
17
+ * structures. So the top-left block is kept (a two-nozzle source's first
18
+ * nozzle) and anything missing is 0.
19
+ *
20
+ * @returns `null` when the source has no flush-volume arrays at all.
21
+ */
22
+ export function resizeFlushVolumes(bambuSettings, filamentCount, warnings) {
23
+ const matrix = bambuSettings.flush_volumes_matrix;
24
+ const vector = bambuSettings.flush_volumes_vector;
25
+ if (!Array.isArray(matrix) || !Array.isArray(vector))
26
+ return null;
27
+ const n = filamentCount;
28
+ if (n < 1)
29
+ return null;
30
+ // The source's own filament count: the matrix's side, or, for a per-nozzle matrix, the vector's half.
31
+ const square = Math.sqrt(matrix.length);
32
+ const fromVector = vector.length / 2;
33
+ const sourceDim = Number.isInteger(square)
34
+ ? square
35
+ : Number.isInteger(fromVector) && fromVector > 0 && matrix.length % (fromVector * fromVector) === 0
36
+ ? fromVector
37
+ : 0;
38
+ const text = (v) => (typeof v === "string" ? v : typeof v === "number" && Number.isFinite(v) ? String(v) : "0");
39
+ const newMatrix = [];
40
+ for (let row = 0; row < n; row++) {
41
+ for (let col = 0; col < n; col++) {
42
+ // Both within the source's own bounds, so a flat index never reads another row's data.
43
+ newMatrix.push(row < sourceDim && col < sourceDim ? text(matrix[row * sourceDim + col]) : "0");
44
+ }
45
+ }
46
+ const newVector = Array.from({ length: n * 2 }, (_, i) => (i < vector.length ? text(vector[i]) : "0"));
47
+ if (sourceDim === 0) {
48
+ warnings.push(` WARN: flush_volumes_matrix has ${matrix.length} entries, which doesn't fit any filament count; it's set to 0 for this project's ${n} filaments (the U1 purges by its own minimum, not by this matrix).`);
49
+ }
50
+ else if (n > sourceDim) {
51
+ warnings.push(` WARN: flush_volumes_matrix/vector were sized for ${sourceDim} filament(s), fewer than this project's ${n}; the missing entries are 0 (the U1 purges by its own minimum, not by this matrix).`);
52
+ }
53
+ else if (n < sourceDim || matrix.length !== sourceDim * sourceDim) {
54
+ warnings.push(` Resized flush_volumes_matrix/vector from ${matrix.length}/${vector.length} entries to ${n} filament(s).`);
55
+ }
56
+ return { flush_volumes_matrix: newMatrix, flush_volumes_vector: newVector };
57
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * For MIN_COMPARISON_KEYS (travel_speed, `*_acceleration`): these
3
+ * describe a printer-motion safety ceiling, not a portable creator
4
+ * preference (see MIN_COMPARISON_KEYS's own doc comment), so Bambu's
5
+ * source value is only honored when it's LOWER (more conservative) than
6
+ * the U1 profile's own tuned default -- a HIGHER Bambu value is always
7
+ * ignored, since it could exceed what's actually safe on this different
8
+ * printer.
9
+ *
10
+ * `0` is never a real value here (Bambu Studio uses it as a sentinel
11
+ * meaning "not overridden, inherit default_acceleration" for the
12
+ * per-feature acceleration keys); read as a lower value, it would
13
+ * clobber the U1's real default. Treated as "no signal" the same as an unparseable value.
14
+ *
15
+ * Resolves a per-nozzle-variant paired array in the SOURCE (see
16
+ * detectVariantIndex.ts) to a scalar first, same as coerceValue's array
17
+ * handling. A U1 value stored per variant is compared entry by entry.
18
+ *
19
+ * @returns `[newValue, changed]`, same contract as coerceValue.
20
+ */
21
+ export declare function resolveMinIfLower(baselineVal: unknown, bambuVal: unknown, variantIndex: number | null): [unknown, boolean];
@@ -0,0 +1,59 @@
1
+ // SPDX-License-Identifier: MIT
2
+ import { jsonEqual } from "./internal/jsonEqual.js";
3
+ /** Parses a plain number or a percentage string ("50%" -> 50) for the min-comparison below. `null` if unrecognizable -- "can't compare, keep the U1 default." */
4
+ function parseNumeric(value) {
5
+ if (typeof value === "number")
6
+ return Number.isFinite(value) ? value : null;
7
+ if (typeof value !== "string")
8
+ return null;
9
+ const trimmed = value.trim();
10
+ const cleaned = trimmed.endsWith("%") ? trimmed.slice(0, -1) : trimmed;
11
+ const n = Number(cleaned);
12
+ return Number.isFinite(n) ? n : null;
13
+ }
14
+ /**
15
+ * For MIN_COMPARISON_KEYS (travel_speed, `*_acceleration`): these
16
+ * describe a printer-motion safety ceiling, not a portable creator
17
+ * preference (see MIN_COMPARISON_KEYS's own doc comment), so Bambu's
18
+ * source value is only honored when it's LOWER (more conservative) than
19
+ * the U1 profile's own tuned default -- a HIGHER Bambu value is always
20
+ * ignored, since it could exceed what's actually safe on this different
21
+ * printer.
22
+ *
23
+ * `0` is never a real value here (Bambu Studio uses it as a sentinel
24
+ * meaning "not overridden, inherit default_acceleration" for the
25
+ * per-feature acceleration keys); read as a lower value, it would
26
+ * clobber the U1's real default. Treated as "no signal" the same as an unparseable value.
27
+ *
28
+ * Resolves a per-nozzle-variant paired array in the SOURCE (see
29
+ * detectVariantIndex.ts) to a scalar first, same as coerceValue's array
30
+ * handling. A U1 value stored per variant is compared entry by entry.
31
+ *
32
+ * @returns `[newValue, changed]`, same contract as coerceValue.
33
+ */
34
+ export function resolveMinIfLower(baselineVal, bambuVal, variantIndex) {
35
+ let bambuScalar = bambuVal;
36
+ if (Array.isArray(bambuVal)) {
37
+ if (bambuVal.length === 0)
38
+ return [baselineVal, false];
39
+ const idx = variantIndex !== null && variantIndex < bambuVal.length ? variantIndex : 0;
40
+ bambuScalar = bambuVal[idx];
41
+ }
42
+ const bambuNum = parseNumeric(bambuScalar);
43
+ if (bambuNum === null || bambuNum <= 0)
44
+ return [baselineVal, false];
45
+ // Snapmaker Orca stores these per variant (standard, high flow), so the
46
+ // U1 value can be a list: each entry becomes the lower of the two.
47
+ if (Array.isArray(baselineVal)) {
48
+ const lowered = baselineVal.map((entry) => {
49
+ const n = parseNumeric(entry);
50
+ return n !== null && bambuNum < n ? bambuScalar : entry;
51
+ });
52
+ return [lowered, !jsonEqual(lowered, baselineVal)];
53
+ }
54
+ const baselineNum = parseNumeric(baselineVal);
55
+ if (baselineNum === null || bambuNum >= baselineNum) {
56
+ return [baselineVal, false];
57
+ }
58
+ return [bambuScalar, !jsonEqual(bambuScalar, baselineVal)];
59
+ }
@@ -0,0 +1,79 @@
1
+ import type { ConvertRequest, ConvertResponse } from "../schema.js";
2
+ import type { FilamentNameTable } from "./filamentComplianceNames.js";
3
+ import { type ResolvedAboveStockChoice } from "./aboveStock.js";
4
+ import type { JsonRecord } from "./types.js";
5
+ import { type ChangeItem, type ChangeReason } from "../explain/whatChanged.js";
6
+ /**
7
+ * Everything the pipeline needs to know about a printer + profile,
8
+ * independent of where it came from (the profile catalog, or a fixture
9
+ * built from the profile templates in tests).
10
+ */
11
+ export interface ConvertProfile {
12
+ printer: {
13
+ id: string;
14
+ printableArea: string[];
15
+ extruderClearanceRadius: number;
16
+ machineSettingsConfig: JsonRecord;
17
+ /** This nozzle supports the Liber High Flow Hotend (the profile templates' high_flow.json). Absent = false. */
18
+ highFlowSupported?: boolean;
19
+ /** 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
+ filamentNames?: FilamentNameTable;
21
+ };
22
+ profile: {
23
+ id: string;
24
+ baselineProjectSettings: JsonRecord;
25
+ filamentShapeConfig: JsonRecord;
26
+ blocklist: ReadonlySet<string>;
27
+ minComparisonKeys: ReadonlySet<string>;
28
+ alwaysTransferKeys: ReadonlySet<string>;
29
+ filamentKeyBlocklist: ReadonlySet<string>;
30
+ /** This tier's own high-flow values (the profile templates' high_flow.json), empty/absent for a tier without high-flow tuning. */
31
+ highFlowOverrides?: Record<string, string>;
32
+ };
33
+ }
34
+ export interface RunConvertPipelineOptions {
35
+ /**
36
+ * Keep the source file's own layer height instead of the tier's. The
37
+ * caller sets this only when it auto-matched a tier that isn't an exact
38
+ * layer-height match -- see carrySourceLayerHeight. Off by default.
39
+ */
40
+ carrySourceLayerHeight?: boolean;
41
+ /**
42
+ * A preset's checked values (see resolvePreset), written over the merged
43
+ * settings before the safety steps run, so the user's values win over the
44
+ * creator's and are still capped at the machine limits.
45
+ */
46
+ presetChanges?: Readonly<Record<string, string | string[]>>;
47
+ /**
48
+ * The user's choice for values above Snapmaker's stock,
49
+ * already checked by resolveAboveStockChoice. Absent: the defaults.
50
+ */
51
+ aboveStock?: ResolvedAboveStockChoice;
52
+ }
53
+ export interface RunConvertPipelineResult {
54
+ response: ConvertResponse;
55
+ warnings: string[];
56
+ /** What the conversion changed, grouped by why (see explain/whatChanged.ts). */
57
+ changes: ReadonlyMap<ChangeReason, ChangeItem[]>;
58
+ }
59
+ /**
60
+ * The full conversion merge + centering pipeline, given an already
61
+ * resolved profile. Pure function: no network or file access. `Project.convert()`
62
+ * loads a ConvertProfile from the catalog and calls this; tests build one
63
+ * straight from the profile templates.
64
+ *
65
+ * Orchestrates the engine functions: extract filament slots -> build
66
+ * filament configs -> build the merged project settings -> cap speeds at
67
+ * the U1's machine limits -> compute the centering shifts.
68
+ *
69
+ * The print and printer are Snapmaker's stock presets, which Snapmaker Orca
70
+ * already has, so like Snapmaker Orca's own stock projects the output
71
+ * carries no embedded print or machine preset; the source's embedded
72
+ * presets are dropped (shouldDropFromBambu). Filament presets are embedded,
73
+ * as Snapmaker Orca does for filaments that aren't its own presets.
74
+ *
75
+ * @param application the target slicer's Application value at the pinned
76
+ * release (the catalog index's `slicer.application`), passed straight
77
+ * through to the response's `application` field.
78
+ */
79
+ export declare function runConvertPipeline(profile: ConvertProfile, request: ConvertRequest, application: string, options?: RunConvertPipelineOptions): RunConvertPipelineResult;