any2orca 0.11.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 (47) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/README.md +1 -1
  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 +10 -0
  18. package/dist/engine/applyFilamentPresets.js +31 -4
  19. package/dist/engine/detectNozzleDiameter.d.ts +28 -0
  20. package/dist/engine/detectNozzleDiameter.js +44 -0
  21. package/dist/engine/detectVariantIndex.d.ts +13 -0
  22. package/dist/engine/detectVariantIndex.js +25 -13
  23. package/dist/engine/extractFilamentSlots.js +7 -1
  24. package/dist/engine/filamentVariantLayout.d.ts +31 -3
  25. package/dist/engine/filamentVariantLayout.js +54 -2
  26. package/dist/engine/fillFilamentSlots.js +2 -1
  27. package/dist/engine/padFilamentsToToolheads.d.ts +20 -0
  28. package/dist/engine/padFilamentsToToolheads.js +82 -0
  29. package/dist/engine/policy.d.ts +9 -0
  30. package/dist/engine/policy.js +37 -0
  31. package/dist/engine/runConvertPipeline.d.ts +15 -0
  32. package/dist/engine/runConvertPipeline.js +132 -7
  33. package/dist/engine/setFilamentDiameter.d.ts +13 -0
  34. package/dist/engine/setFilamentDiameter.js +30 -0
  35. package/dist/index.d.ts +3 -3
  36. package/dist/index.js +1 -1
  37. package/dist/inspect.d.ts +7 -1
  38. package/dist/inspect.js +2 -1
  39. package/dist/profiles.d.ts +9 -0
  40. package/dist/profiles.js +10 -0
  41. package/dist/project.d.ts +41 -7
  42. package/dist/project.js +68 -17
  43. package/dist/stamp.d.ts +12 -0
  44. package/dist/stamp.js +7 -0
  45. package/dist/version.js +1 -1
  46. package/dist/workerProtocol.d.ts +2 -0
  47. package/package.json +2 -2
@@ -0,0 +1,13 @@
1
+ import type { JsonRecord } from "./types.js";
2
+ /** The filament the U1 takes, in mm. */
3
+ export declare const U1_FILAMENT_DIAMETER = "1.75";
4
+ /** A filament diameter that isn't the U1's, as a number (2.85 for "2.85"), or null for 1.75 or nothing readable. */
5
+ export declare function offSizeDiameter(value: unknown): number | null;
6
+ /**
7
+ * Sets every slot's `filament_diameter` to the U1's 1.75 mm, with a note for each filament the creator's file had
8
+ * at another size, except the slots in `announced`, which the pipeline has already explained (it set them to a U1
9
+ * preset for their material). Bambu's H3C has a 2.85 mm PrintTool for soft TPU, and its project keeps 2.85 for that
10
+ * filament; left in the file, Snapmaker Orca would compute the extrusion for filament nearly three times thicker and
11
+ * the U1 would badly under-extrude it.
12
+ */
13
+ export declare function setFilamentDiameter(settings: JsonRecord, slotCount: number, warnings: string[], announced?: ReadonlySet<number>): void;
@@ -0,0 +1,30 @@
1
+ /** The filament the U1 takes, in mm. */
2
+ export const U1_FILAMENT_DIAMETER = "1.75";
3
+ /** A filament diameter that isn't the U1's, as a number (2.85 for "2.85"), or null for 1.75 or nothing readable. */
4
+ export function offSizeDiameter(value) {
5
+ const n = typeof value === "string" ? Number.parseFloat(value) : typeof value === "number" ? value : NaN;
6
+ return Number.isFinite(n) && Math.abs(n - Number(U1_FILAMENT_DIAMETER)) > 1e-6 ? n : null;
7
+ }
8
+ /**
9
+ * Sets every slot's `filament_diameter` to the U1's 1.75 mm, with a note for each filament the creator's file had
10
+ * at another size, except the slots in `announced`, which the pipeline has already explained (it set them to a U1
11
+ * preset for their material). Bambu's H3C has a 2.85 mm PrintTool for soft TPU, and its project keeps 2.85 for that
12
+ * filament; left in the file, Snapmaker Orca would compute the extrusion for filament nearly three times thicker and
13
+ * the U1 would badly under-extrude it.
14
+ */
15
+ export function setFilamentDiameter(settings, slotCount, warnings, announced = new Set()) {
16
+ if (slotCount < 1)
17
+ return;
18
+ const raw = settings.filament_diameter;
19
+ const current = Array.isArray(raw) ? raw : raw === undefined ? [] : [raw];
20
+ const changed = [];
21
+ for (let i = 0; i < Math.min(slotCount, current.length); i += 1) {
22
+ const n = offSizeDiameter(current[i]);
23
+ if (n !== null && !announced.has(i))
24
+ changed.push(`filament ${i + 1} (${n} mm)`);
25
+ }
26
+ settings.filament_diameter = Array.from({ length: slotCount }, () => U1_FILAMENT_DIAMETER);
27
+ if (changed.length > 0) {
28
+ warnings.push(` WARN: the U1 takes ${U1_FILAMENT_DIAMETER} mm filament, so ${changed.join(", ")} ${changed.length === 1 ? "is" : "are"} set to ${U1_FILAMENT_DIAMETER} mm; load ${U1_FILAMENT_DIAMETER} mm filament of the same material.`);
29
+ }
30
+ }
package/dist/index.d.ts CHANGED
@@ -10,14 +10,14 @@
10
10
  * `any2orca/worker`.
11
11
  */
12
12
  export { convert, inspect, openProject, matchProfile, unwrapBundle, Project, CONVERT_STAGES } from "./project.js";
13
- export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, OpenOptions, ProfileChoice, ReportFilament, ReportFilamentPreset } from "./project.js";
13
+ export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, NozzleUsed, OpenOptions, ProfileChoice, ReportFilament, ReportFilamentPreset } from "./project.js";
14
14
  export { DEFAULT_MAX_UNPACKED_BYTES, LARGE_PROJECT_BYTES, MAX_UNPACKED_BYTES_LIMIT } from "./archive/safeUnzip.js";
15
15
  export { SOURCE_VENDORS } from "./inspect.js";
16
16
  export type { FilamentSlotInfo, Inspection, KnownSourceVendor, SourceVendor } from "./inspect.js";
17
17
  export { SOURCE_FORMATS } from "./sources/reader.js";
18
18
  export type { KnownSourceFormat, SourceFormat } from "./sources/reader.js";
19
- export { SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
20
- export type { KnownNozzleDiameter, SupportedNozzleDiameter } from "./engine/detectNozzleDiameter.js";
19
+ export { DEFAULT_NOZZLE, NOZZLE_CHOICES, SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
20
+ export type { KnownNozzleChoice, KnownNozzleDiameter, NozzleChoice, SupportedNozzleDiameter } from "./engine/detectNozzleDiameter.js";
21
21
  export { fetchProfileSource, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError } from "./profiles.js";
22
22
  export type { MemoryCatalogData, ProfileIndex, ProfileIndexPrinter, ProfileIndexProfile, ProfileIndexRelease, ProfileIndexSource, ProfileSource, ProfileSummary, RetiredProfile, SlicerRelease, } from "./profiles.js";
23
23
  export { resolveFilamentName } from "./engine/filamentComplianceNames.js";
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ export { convert, inspect, openProject, matchProfile, unwrapBundle, Project, CON
14
14
  export { DEFAULT_MAX_UNPACKED_BYTES, LARGE_PROJECT_BYTES, MAX_UNPACKED_BYTES_LIMIT } from "./archive/safeUnzip.js";
15
15
  export { SOURCE_VENDORS } from "./inspect.js";
16
16
  export { SOURCE_FORMATS } from "./sources/reader.js";
17
- export { SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
17
+ export { DEFAULT_NOZZLE, NOZZLE_CHOICES, SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
18
18
  export { fetchProfileSource, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError } from "./profiles.js";
19
19
  export { resolveFilamentName } from "./engine/filamentComplianceNames.js";
20
20
  export { Any2orcaError, ANY2ORCA_ERROR_CODES } from "./errors.js";
package/dist/inspect.d.ts CHANGED
@@ -41,7 +41,13 @@ export interface Inspection {
41
41
  filaments: FilamentSlotInfo[];
42
42
  /** The file's first nozzle_diameter as written, e.g. "0.4". */
43
43
  nozzleDiameter: string | null;
44
- /** The supported nozzle size profile matching uses, or null if none could be read. */
44
+ /**
45
+ * Every nozzle size the project uses, as written, smallest first: one entry for most files, several for a project
46
+ * from Bambu Studio's multi-diameter mode (an H3C with a 0.2 PrintTool among 0.4 ones). Empty if the file gives none.
47
+ * Always set by `inspect()`; optional so code that builds an Inspection itself (a test's mock) needn't.
48
+ */
49
+ nozzleDiameters?: string[];
50
+ /** The creator's nozzle size snapped to a U1 size: what converting with `nozzle: "match"` is for. Null if none could be read. */
45
51
  matchNozzleDiameter: SupportedNozzleDiameter | null;
46
52
  layerHeight: number | null;
47
53
  /** The source's process preset, e.g. `"0.20mm Standard @BBL X1C"`. */
package/dist/inspect.js CHANGED
@@ -7,7 +7,7 @@
7
7
  * type-checked rather than cast.
8
8
  */
9
9
  import { lookupFilamentColorName } from "./archive/lookupFilamentColorName.js";
10
- import { detectNozzleDiameter } from "./engine/detectNozzleDiameter.js";
10
+ import { detectNozzleDiameter, sourceNozzleSizes } from "./engine/detectNozzleDiameter.js";
11
11
  import { parseTierName } from "./engine/parseTierName.js";
12
12
  import { plainText } from "./plainText.js";
13
13
  /** The printer makers any2orca recognizes, from a project's printer and preset names; "other" for any it doesn't. */
@@ -100,6 +100,7 @@ export function inspectProject(projectSettings, objects, warnings, unpackedBytes
100
100
  objects: objects.map((o) => ({ ...o })),
101
101
  filaments,
102
102
  nozzleDiameter: asDisplayString(rawNozzle),
103
+ nozzleDiameters: sourceNozzleSizes(projectSettings).sizes,
103
104
  matchNozzleDiameter: detectNozzleDiameter(projectSettings),
104
105
  layerHeight: Number.isFinite(layerHeightValue) ? layerHeightValue : null,
105
106
  sourcePresetName,
@@ -129,6 +129,7 @@ export declare const ProfileIndexSchema: z.ZodObject<{
129
129
  version: z.ZodString;
130
130
  application: z.ZodString;
131
131
  path: z.ZodUnion<readonly [z.ZodLiteral<".">, z.ZodString]>;
132
+ mixedNozzleSizes: z.ZodOptional<z.ZodBoolean>;
132
133
  }, z.core.$strip>>>;
133
134
  sources: z.ZodOptional<z.ZodObject<{
134
135
  prusaslicer: z.ZodArray<z.ZodObject<{
@@ -174,6 +175,8 @@ export interface ProfileIndexRelease {
174
175
  version: string;
175
176
  application: string;
176
177
  path: string;
178
+ /** This release's U1 presets allow a different nozzle size per toolhead. Absent means no: one size for all four. */
179
+ mixedNozzleSizes?: boolean;
177
180
  }
178
181
  /** A source-slicer data file the catalog holds (PrusaSlicer's vendor preset bundles). */
179
182
  export interface ProfileIndexSource {
@@ -302,6 +305,12 @@ export declare class ProfileCatalog {
302
305
  private filamentPresetsPending;
303
306
  constructor(index: ProfileIndex, source: ProfileSource);
304
307
  /** Every profile, or only one nozzle size's, sorted by nozzle size and then layer height (finest first). */
308
+ /**
309
+ * Whether this catalog's Snapmaker Orca release allows a different nozzle size per toolhead. False for every
310
+ * release so far: Snapmaker Orca takes one size for all four, so a conversion is for one size (`nozzle`). A
311
+ * release that allows mixed sizes says so in its catalog entry, which is where per-toolhead sizes would start.
312
+ */
313
+ get mixedNozzleSizes(): boolean;
305
314
  list(filter?: {
306
315
  nozzleDiameter?: string;
307
316
  }): ProfileSummary[];
package/dist/profiles.js CHANGED
@@ -115,6 +115,8 @@ export const ProfileIndexSchema = z.object({
115
115
  version: VERSION,
116
116
  application: z.string().regex(APPLICATION_VALUE),
117
117
  path: z.union([z.literal("."), z.string().regex(RELEASE_PATH)]),
118
+ /** This release's U1 presets allow a different nozzle size per toolhead. Absent means no: one size for all four. */
119
+ mixedNozzleSizes: z.boolean().optional(),
118
120
  }))
119
121
  .min(1)
120
122
  .max(50)
@@ -248,6 +250,14 @@ export class ProfileCatalog {
248
250
  this.retired = new Map(index.retired.map((r) => [r.id, r]));
249
251
  }
250
252
  /** Every profile, or only one nozzle size's, sorted by nozzle size and then layer height (finest first). */
253
+ /**
254
+ * Whether this catalog's Snapmaker Orca release allows a different nozzle size per toolhead. False for every
255
+ * release so far: Snapmaker Orca takes one size for all four, so a conversion is for one size (`nozzle`). A
256
+ * release that allows mixed sizes says so in its catalog entry, which is where per-toolhead sizes would start.
257
+ */
258
+ get mixedNozzleSizes() {
259
+ return this.index.releases?.find((r) => r.path === ".")?.mixedNozzleSizes === true;
260
+ }
251
261
  list(filter = {}) {
252
262
  const { nozzleDiameter } = filter;
253
263
  return this.summaries.filter((s) => nozzleDiameter === undefined || s.nozzleDiameter === nozzleDiameter).map((s) => ({ ...s }));
package/dist/project.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { type BundleEntry } from "./archive/unwrapBundle.js";
2
+ import { type NozzleChoice } from "./engine/detectNozzleDiameter.js";
2
3
  import { type WhatChanged } from "./explain/whatChanged.js";
3
4
  import { type Inspection } from "./inspect.js";
4
5
  import { ProfileCatalog, type ProfileSource, type ProfileSummary, type RetiredProfile } from "./profiles.js";
@@ -26,6 +27,14 @@ export interface ConvertOptions {
26
27
  * hold throws {@link Any2orcaError} `release_not_found`.
27
28
  */
28
29
  snapmakerOrcaVersion?: string;
30
+ /**
31
+ * The nozzle size the user's U1 has, which the converted file is for: "0.2", "0.4", "0.6" or "0.8" (one size for
32
+ * all four toolheads, as Snapmaker Orca allows), or "match" for the creator's own size. Default "0.4", the stock
33
+ * nozzle most U1s run. A creator's size that differs gets a note and a What changed item; a project that mixes
34
+ * sizes (Bambu Studio's multi-diameter mode) gets a note naming the filaments on other sizes. Can't contradict
35
+ * `profileId` or a preset, whose profile names its own size.
36
+ */
37
+ nozzle?: NozzleChoice;
29
38
  /** Use this profile instead of matching one. A retired id converts with its successor, with a warning. */
30
39
  profileId?: string;
31
40
  /**
@@ -96,6 +105,11 @@ export interface ReportFilament {
96
105
  export interface ConvertReport {
97
106
  /** The profile the file was converted with. */
98
107
  profile: ProfileSummary;
108
+ /**
109
+ * The nozzle size the file is for, how it was chosen, and the sizes the creator's project uses. Always set by
110
+ * `convert()`; optional so code that builds a report itself (a test's mock) needn't.
111
+ */
112
+ nozzle?: NozzleUsed;
99
113
  /** How the profile was matched; absent when `profileId` was given. */
100
114
  profileMatch?: ProfileMatch;
101
115
  /**
@@ -130,7 +144,11 @@ export interface ConvertReport {
130
144
  plates: number;
131
145
  objects: number;
132
146
  filamentSlots: number;
133
- /** Every filament slot, in the file's order, with the name each has in the source and in the output. */
147
+ /**
148
+ * Every filament slot of the source, in the file's order, with the name each has in the source and in the output.
149
+ * The copies of the last filament that pad a project to one filament per toolhead aren't listed; What changed says
150
+ * how many were added.
151
+ */
134
152
  filaments: ReportFilament[];
135
153
  /** The stamp written into the output, or null if `stamp: false`. */
136
154
  stamp: OutputStamp | null;
@@ -161,9 +179,20 @@ export interface ConvertResult {
161
179
  output: Uint8Array;
162
180
  report: ConvertReport;
163
181
  }
182
+ /** The nozzle size a conversion is for, and how it was chosen. */
183
+ export interface NozzleUsed {
184
+ /** What was asked for: a size such as "0.4", or "match" for the creator's. */
185
+ choice: NozzleChoice;
186
+ /** The size the file is converted for, e.g. "0.4". */
187
+ size: string;
188
+ /** The nozzle sizes the creator's project uses, as written, smallest first; empty when the file gives none. */
189
+ sourceSizes: string[];
190
+ }
164
191
  export interface ProfileChoice {
165
192
  profileId: string;
166
193
  profileMatch: ProfileMatch;
194
+ /** The nozzle size the choice is for. Always set by `matchProfile()`; optional so a mock built by hand needn't. */
195
+ nozzle?: NozzleUsed;
167
196
  /** Keep the source file's own layer height (auto-matched to a tier that isn't an exact layer height match). */
168
197
  carrySourceLayerHeight: boolean;
169
198
  /** Why the match may not be what the file asked for (an unusable layer height or a nozzle size with no U1 profile), as sentences. */
@@ -171,11 +200,14 @@ export interface ProfileChoice {
171
200
  }
172
201
  /**
173
202
  * Picks a profile for a file's settings, the same way every UI should (never
174
- * re-implement this): the source's own tier name first (from its
175
- * print_settings_id, e.g. "Extra Fine"), then the nearest layer height for
176
- * its nozzle size, then the catalog default.
203
+ * re-implement this): among the profiles for the nozzle size the user's U1
204
+ * has (`options.nozzle`, default 0.4; "match" for the creator's own size),
205
+ * the source's own tier name first (from its print_settings_id, e.g. "Extra
206
+ * Fine"), then the nearest layer height, then the catalog default.
177
207
  */
178
- export declare function matchProfile(projectSettings: Record<string, unknown>, profiles: ProfileSource | ProfileCatalog): Promise<ProfileChoice>;
208
+ export declare function matchProfile(projectSettings: Record<string, unknown>, profiles: ProfileSource | ProfileCatalog, options?: {
209
+ nozzle?: NozzleChoice;
210
+ }): Promise<ProfileChoice>;
179
211
  /**
180
212
  * Same cleanup every UI applies before showing warnings: drop routine
181
213
  * bookkeeping lines, strip the internal "WARN" prefix and internal file
@@ -192,8 +224,10 @@ export declare class Project {
192
224
  /** The project's own settings (Metadata/project_settings.config), as a copy: for a settings diff. */
193
225
  settings(): Record<string, unknown>;
194
226
  inspect(): Inspection;
195
- /** The profile auto-matching would pick for this file. */
196
- matchProfile(profiles: ProfileSource | ProfileCatalog): Promise<ProfileChoice>;
227
+ /** The profile auto-matching would pick for this file, for the user's nozzle size (`options.nozzle`, default 0.4). */
228
+ matchProfile(profiles: ProfileSource | ProfileCatalog, options?: {
229
+ nozzle?: NozzleChoice;
230
+ }): Promise<ProfileChoice>;
197
231
  convert(options: ConvertOptions): Promise<ConvertResult>;
198
232
  }
199
233
  /** Opens a .3mf; see {@link Project}. */
package/dist/project.js CHANGED
@@ -11,7 +11,7 @@
11
11
  import { applyPolicyB, policyBFallbackNote } from "./sources/prusa/policyB.js";
12
12
  import { applyConvertResponse, prepareConvertRequest } from "./archive/zip.js";
13
13
  import { unwrapIfBundle } from "./archive/unwrapBundle.js";
14
- import { detectNozzleDiameter } from "./engine/detectNozzleDiameter.js";
14
+ import { DEFAULT_NOZZLE, detectNozzleDiameter, NOZZLE_CHOICES, sourceNozzleSizes } from "./engine/detectNozzleDiameter.js";
15
15
  import { parseTierName } from "./engine/parseTierName.js";
16
16
  import { pickProfile } from "./engine/pickProfile.js";
17
17
  import { runConvertPipeline } from "./engine/runConvertPipeline.js";
@@ -39,40 +39,69 @@ function rawNozzleDiameter(projectSettings) {
39
39
  const value = typeof first === "string" ? Number(first.trim()) : typeof first === "number" ? first : NaN;
40
40
  return Number.isFinite(value) ? value : null;
41
41
  }
42
+ /** "0.2 and 0.4 mm" for ["0.2", "0.4"]; "0.4 mm" for one. */
43
+ function sizesText(sizes) {
44
+ return sizes.length <= 1 ? `${sizes[0] ?? "?"} mm` : `${sizes.slice(0, -1).join(", ")} and ${sizes[sizes.length - 1]} mm`;
45
+ }
42
46
  /**
43
47
  * Picks a profile for a file's settings, the same way every UI should (never
44
- * re-implement this): the source's own tier name first (from its
45
- * print_settings_id, e.g. "Extra Fine"), then the nearest layer height for
46
- * its nozzle size, then the catalog default.
48
+ * re-implement this): among the profiles for the nozzle size the user's U1
49
+ * has (`options.nozzle`, default 0.4; "match" for the creator's own size),
50
+ * the source's own tier name first (from its print_settings_id, e.g. "Extra
51
+ * Fine"), then the nearest layer height, then the catalog default.
47
52
  */
48
- export async function matchProfile(projectSettings, profiles) {
53
+ export async function matchProfile(projectSettings, profiles, options = {}) {
49
54
  const catalog = await loadCatalog(profiles);
55
+ const choice = options.nozzle ?? DEFAULT_NOZZLE;
50
56
  const detectedDiameter = detectNozzleDiameter(projectSettings);
57
+ const source = sourceNozzleSizes(projectSettings);
58
+ const size = choice === "match" ? detectedDiameter : choice;
59
+ if (size !== null && catalog.list({ nozzleDiameter: size }).length === 0) {
60
+ const sizes = [...new Set(catalog.list().map((s) => s.nozzleDiameter))].sort((a, b) => Number(a) - Number(b));
61
+ throw new Any2orcaError("profile_not_found", `There is no U1 profile for a ${size} mm nozzle; the catalog has ${sizesText(sizes)}.`);
62
+ }
51
63
  const sourceLayerHeight = numericLayerHeight(projectSettings);
52
64
  const printSettingsId = projectSettings.print_settings_id;
53
- const picked = detectedDiameter
54
- ? pickProfile(catalog.list({ nozzleDiameter: detectedDiameter }), {
65
+ const picked = size
66
+ ? pickProfile(catalog.list({ nozzleDiameter: size }), {
55
67
  layerHeight: sourceLayerHeight,
56
68
  tierName: typeof printSettingsId === "string" ? parseTierName(printSettingsId) : null,
57
69
  })
58
70
  : null;
59
71
  const profileId = picked?.profileId ?? catalog.index.defaultProfileId;
72
+ const used = catalog.get(profileId)?.nozzleDiameter ?? size ?? "";
60
73
  const notes = [];
61
74
  const sourceNozzle = rawNozzleDiameter(projectSettings);
62
- if (sourceNozzle === null) {
63
- notes.push("the source file doesn't give a usable nozzle size, so the default profile is used");
75
+ if (choice === "match") {
76
+ if (sourceNozzle === null) {
77
+ notes.push("the source file doesn't give a usable nozzle size, so the default profile is used");
78
+ }
79
+ else if (detectedDiameter && Math.abs(sourceNozzle - Number(detectedDiameter)) > 1e-6) {
80
+ notes.push(`the source file is set up for a ${sourceNozzle}mm nozzle, which has no U1 profile; the ${detectedDiameter}mm profile is used`);
81
+ }
82
+ if (source.mixed) {
83
+ notes.push(`the creator's project uses ${sizesText(source.sizes)} nozzles; Snapmaker Orca allows one size for all four toolheads, so the whole file is for ${used} mm`);
84
+ }
64
85
  }
65
- else if (detectedDiameter && Math.abs(sourceNozzle - Number(detectedDiameter)) > 1e-6) {
66
- notes.push(`the source file is set up for a ${sourceNozzle}mm nozzle, which has no U1 profile; the ${detectedDiameter}mm profile is used`);
86
+ else if (source.mixed) {
87
+ const others = source.filamentSizes.flatMap((s, i) => (s !== null && s !== used ? [`filament ${i + 1} on ${s} mm`] : []));
88
+ notes.push(`the creator's project uses ${sizesText(source.sizes)} nozzles${others.length > 0 ? ` (${others.join(", ")})` : ""}; converted for your ${used} mm nozzles, since Snapmaker Orca allows one size for all four toolheads`);
89
+ }
90
+ else if (sourceNozzle === null) {
91
+ notes.push(`the source file doesn't give a usable nozzle size; converted for your ${used} mm nozzles`);
92
+ }
93
+ else if (Math.abs(sourceNozzle - Number(used)) > 1e-6) {
94
+ notes.push(`the creator's project is set up for a ${sourceNozzle} mm nozzle; converted for your ${used} mm nozzles (choose ${sourceNozzle} mm if your U1 has them)`);
67
95
  }
68
96
  if (Object.hasOwn(projectSettings, "layer_height") && sourceLayerHeight === null) {
69
97
  notes.push(`the source file's layer height (${plainText(String(projectSettings.layer_height)).slice(0, 40)}) isn't a usable number, so it isn't used to choose the profile`);
70
98
  }
71
99
  return {
72
100
  profileId,
101
+ nozzle: { choice, size: used, sourceSizes: source.sizes },
73
102
  profileMatch: {
74
103
  profileId,
75
- nozzleDiameter: detectedDiameter ?? "",
104
+ nozzleDiameter: used,
76
105
  exact: picked?.exact ?? false,
77
106
  matchedByTierName: picked?.matchedByTierName ?? false,
78
107
  matchSource: picked ? (picked.matchedByTierName ? "auto-tier-name" : picked.exact ? "auto-exact" : "auto-nearest") : "default-fallback",
@@ -133,6 +162,9 @@ function checkConvertOptions(options) {
133
162
  if (o[key] !== undefined && typeof o[key] !== "boolean")
134
163
  throw new TypeError(`The \`${key}\` option must be true or false.`);
135
164
  }
165
+ if (o.nozzle !== undefined && (typeof o.nozzle !== "string" || !/^(\d{1,2}(\.\d{1,3})?|match)$/.test(o.nozzle))) {
166
+ throw new TypeError(`The \`nozzle\` option must be a nozzle size such as "0.4", or "match" for the creator's size (${NOZZLE_CHOICES.join(", ")}).`);
167
+ }
136
168
  if (o.profileId !== undefined && typeof o.profileId !== "string")
137
169
  throw new TypeError("The `profileId` option must be a string.");
138
170
  if (o.snapmakerOrcaVersion !== undefined && typeof o.snapmakerOrcaVersion !== "string") {
@@ -195,9 +227,9 @@ export class Project {
195
227
  inspect() {
196
228
  return inspectProject(this.request.projectSettings, this.request.objects, this.parsed.warnings, this.parsed.unpackedBytes, this.parsed.sourcePlateOrigins, this.request.plateCount);
197
229
  }
198
- /** The profile auto-matching would pick for this file. */
199
- matchProfile(profiles) {
200
- return matchProfile(this.request.projectSettings, profiles);
230
+ /** The profile auto-matching would pick for this file, for the user's nozzle size (`options.nozzle`, default 0.4). */
231
+ matchProfile(profiles, options = {}) {
232
+ return matchProfile(this.request.projectSettings, profiles, options);
201
233
  }
202
234
  async convert(options) {
203
235
  checkConvertOptions(options);
@@ -218,6 +250,7 @@ export class Project {
218
250
  let profileNotes = [];
219
251
  let carrySourceLayerHeight = false;
220
252
  let retiredProfile;
253
+ let matchedNozzle;
221
254
  if (options.preset && options.profileId) {
222
255
  throw new Any2orcaError("invalid_preset", "A preset sets its own profile, so it can't be combined with a profile id.");
223
256
  }
@@ -236,15 +269,28 @@ export class Project {
236
269
  }
237
270
  }
238
271
  else {
239
- const choice = await matchProfile(this.request.projectSettings, catalog);
272
+ const choice = await matchProfile(this.request.projectSettings, catalog, { nozzle: options.nozzle });
240
273
  profileId = choice.profileId;
241
274
  profileMatch = choice.profileMatch;
242
275
  profileNotes = [...choice.notes];
243
276
  carrySourceLayerHeight = choice.carrySourceLayerHeight;
277
+ matchedNozzle = choice.nozzle;
244
278
  routeWarnings.push(...choice.notes.map((note) => ` WARN: ${note}`));
245
279
  }
246
280
  progress("loading-profile");
247
281
  const loaded = await catalogEngine(catalog).load(profileId);
282
+ // A given profile or preset names its own nozzle size; a `nozzle` that says otherwise is a contradiction, not a choice.
283
+ if (options.nozzle !== undefined && options.nozzle !== "match" && options.nozzle !== loaded.summary.nozzleDiameter) {
284
+ const message = `"${loaded.summary.id}" is a ${loaded.summary.nozzleDiameter} mm nozzle profile, but the nozzle option says ${options.nozzle} mm.`;
285
+ if (preset)
286
+ throw new Any2orcaError("invalid_preset", `This preset was made for ${loaded.summary.nozzleDiameter} mm nozzles: ${message} Convert with that size, or without a nozzle option.`);
287
+ throw new TypeError(`${message} Pass one or the other.`);
288
+ }
289
+ const nozzle = matchedNozzle ?? {
290
+ choice: options.nozzle ?? loaded.summary.nozzleDiameter,
291
+ size: loaded.summary.nozzleDiameter,
292
+ sourceSizes: sourceNozzleSizes(this.request.projectSettings).sizes,
293
+ };
248
294
  // The Snapmaker and Generic filament options write the chosen presets' own settings; every option compares each
249
295
  // filament with the preset Snapmaker Orca resets it to.
250
296
  const filamentPresets = (await catalogEngine(catalog).filamentPresets())?.[loaded.convertProfile.printer.id];
@@ -266,6 +312,8 @@ export class Project {
266
312
  const convertProfile = filamentPresets ? { ...loaded.convertProfile, printer: { ...loaded.convertProfile.printer, filamentPresets } } : loaded.convertProfile;
267
313
  const pipeline = runConvertPipeline(convertProfile, request, catalog.index.slicer.application, {
268
314
  carrySourceLayerHeight,
315
+ targetNozzleDiameter: loaded.summary.nozzleDiameter,
316
+ ...(matchedNozzle ? { nozzle: { size: matchedNozzle.size, sourceSizes: matchedNozzle.sourceSizes } } : {}),
269
317
  ...(preset ? { presetChanges: preset.changes } : {}),
270
318
  ...(aboveStock.keep.size + aboveStock.stock.size > 0 ? { aboveStock } : {}),
271
319
  });
@@ -292,6 +340,7 @@ export class Project {
292
340
  profileId,
293
341
  source: { format: this.parsed.source, ...(sourceVersion !== null ? { slicerVersion: sourceVersion } : {}) },
294
342
  options: {
343
+ nozzle: { choice: nozzle.choice, size: nozzle.size },
295
344
  highFlowHotends,
296
345
  hardenedNozzles: options.hardenedNozzles === true,
297
346
  filamentComplianceMode: options.filamentComplianceMode ?? null,
@@ -317,10 +366,12 @@ export class Project {
317
366
  output,
318
367
  report: {
319
368
  profile: loaded.summary,
369
+ nozzle,
320
370
  ...(profileMatch ? { profileMatch } : {}),
321
371
  profileNotes,
322
372
  ...(retiredProfile ? { retiredProfile } : {}),
323
- warnings: cleanWarnings([...this.parsed.warnings, ...(response.warnings ?? []), ...applyWarnings.filter((w) => w.includes("WARN"))]),
373
+ // A filament set to a U1 preset because of its diameter comes first: the user has to load other filament.
374
+ warnings: cleanWarnings([...pipeline.leadWarnings, ...this.parsed.warnings, ...(response.warnings ?? []), ...applyWarnings.filter((w) => w.includes("WARN"))]),
324
375
  log: [...this.parsed.warnings, ...routeWarnings, ...pipeline.warnings, ...applyWarnings].map((w) => w.trim()).filter(Boolean),
325
376
  ...(response.filamentComplianceFallback ? { filamentComplianceFallback: response.filamentComplianceFallback } : {}),
326
377
  ...(response.filamentComplianceUnchanged ? { filamentComplianceUnchanged: response.filamentComplianceUnchanged } : {}),
package/dist/stamp.d.ts CHANGED
@@ -32,6 +32,10 @@ export declare const OutputStampSchema: z.ZodObject<{
32
32
  slicerVersion: z.ZodOptional<z.ZodString>;
33
33
  }, z.core.$strict>>;
34
34
  options: z.ZodObject<{
35
+ nozzle: z.ZodOptional<z.ZodObject<{
36
+ choice: z.ZodString;
37
+ size: z.ZodString;
38
+ }, z.core.$strict>>;
35
39
  highFlowHotends: z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodBoolean>]>;
36
40
  hardenedNozzles: z.ZodBoolean;
37
41
  filamentComplianceMode: z.ZodNullable<z.ZodEnum<{
@@ -80,6 +84,14 @@ export interface OutputStamp {
80
84
  slicerVersion?: string;
81
85
  };
82
86
  options: {
87
+ /**
88
+ * The nozzle size the file is for: `choice` is what was asked ("0.4", or "match" for the creator's size),
89
+ * `size` the size used. Absent in files written before the option; those are for the creator's size.
90
+ */
91
+ nozzle?: {
92
+ choice: string;
93
+ size: string;
94
+ };
83
95
  highFlowHotends: HighFlowHotends;
84
96
  hardenedNozzles: boolean;
85
97
  filamentComplianceMode: "generic" | "snapmaker" | null;
package/dist/stamp.js CHANGED
@@ -13,6 +13,8 @@
13
13
  import "./zodSetup.js";
14
14
  import { z } from "zod";
15
15
  import { HighFlowHotendsSchema } from "./schema.js";
16
+ /** The nozzle size the file is for: what was asked (a size, or "match" for the creator's) and the size used. */
17
+ const NozzleStampSchema = z.object({ choice: z.string().max(16), size: z.string().max(16) }).strict();
16
18
  import { SOURCE_FORMATS } from "./sources/reader.js";
17
19
  export const STAMP_PATH = "Metadata/any2orca.json";
18
20
  const AboveStockStampSchema = z
@@ -54,6 +56,8 @@ export const OutputStampSchema = z
54
56
  .optional(),
55
57
  options: z
56
58
  .object({
59
+ /** The nozzle size the file is for; files written before the option have none. */
60
+ nozzle: NozzleStampSchema.optional(),
57
61
  highFlowHotends: HighFlowHotendsSchema,
58
62
  hardenedNozzles: z.boolean(),
59
63
  filamentComplianceMode: z.enum(["generic", "snapmaker"]).nullable(),
@@ -82,6 +86,8 @@ const StampReadSchema = z.object({
82
86
  // release with a format this one doesn't know still reads as stamped.
83
87
  source: z.object({ format: z.string().regex(/^[a-z0-9-]{1,32}$/), slicerVersion: noteText(64).optional() }).optional(),
84
88
  options: z.object({
89
+ // Added with the nozzle option; absent means the file is for the creator's nozzle size.
90
+ nozzle: z.object({ choice: noteText(16), size: noteText(16) }).optional(),
85
91
  highFlowHotends: HighFlowHotendsSchema,
86
92
  // Added after the first stamps were written; absent means the stock stainless nozzles.
87
93
  hardenedNozzles: z.boolean().default(false),
@@ -111,6 +117,7 @@ export function decodeStamp(bytes) {
111
117
  profiles: { version: profiles.version, tracks: profiles.tracks },
112
118
  profileId,
113
119
  options: {
120
+ ...(options.nozzle ? { nozzle: { choice: options.nozzle.choice, size: options.nozzle.size } } : {}),
114
121
  highFlowHotends: options.highFlowHotends,
115
122
  hardenedNozzles: options.hardenedNozzles,
116
123
  filamentComplianceMode: options.filamentComplianceMode,
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Written by scripts/sync-version.mjs from package.json; a test checks they match.
3
3
  // Typed as string, so a release doesn't change the public API's shape.
4
- export const VERSION = "0.11.0";
4
+ export const VERSION = "0.12.0";
@@ -10,6 +10,8 @@ export type WorkerReleaseOption = {
10
10
  export type WorkerConvertOptions = {
11
11
  /** The Snapmaker Orca release to convert for (default: the newest the catalog holds). */
12
12
  snapmakerOrcaVersion?: string;
13
+ /** The nozzle size the user's U1 has ("0.2" to "0.8"), or "match" for the creator's; default "0.4". */
14
+ nozzle?: string;
13
15
  profileId?: string;
14
16
  highFlowHotends?: boolean | readonly boolean[];
15
17
  hardenedNozzles?: boolean;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "any2orca",
3
- "version": "0.11.0",
4
- "outputAffecting": "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; Snapmaker Orca keeps the nozzle type a converted file records",
3
+ "version": "0.12.0",
4
+ "outputAffecting": "Snapmaker Orca no longer opens a converted file with its first filament marked as modified; files are converted for the nozzle size your U1 has, 0.4 mm unless you say otherwise, instead of the size the creator used; and 4 more",
5
5
  "description": "Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer 3MF projects for the Snapmaker U1 (Snapmaker Orca), entirely on your own machine. Library, CLI and Web Worker in one package.",
6
6
  "keywords": [
7
7
  "3mf",