any2orca 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # any2orca
2
2
 
3
+ ## 0.9.0
4
+
5
+ ### Breaking
6
+
7
+ - **The public API is now the documented one, and from here on it only grows.** This release removes what was never meant to be public and opens the lists of values the library returns, so that adding a slicer, an error code or a conversion step never breaks code built on any2orca again. A check in CI compares the API's shape with a committed report. Everything that changed, and what to use instead:
8
+
9
+ - **Lists of values the library returns can gain values.** `SourceVendor`, `Any2orcaErrorCode`, `ChangeReason`, `ConvertStage`, `MatchSource`, `DiffStatus`, `DiffAttention`, `ValueLayout`, `SourceFormat` and `SupportedNozzleDiameter` are now the known values or any other string. Code that maps every value, such as a `Record<SourceVendor, string>` or an exhaustive `switch`, needs a fallback for a value it doesn't recognize. The known values are exported next to each type: `SOURCE_VENDORS`, `ANY2ORCA_ERROR_CODES`, `CHANGE_REASONS`, `CONVERT_STAGES`, `MATCH_SOURCES`, `DIFF_STATUSES`, `DIFF_ATTENTIONS`, `VALUE_LAYOUTS`, `SOURCE_FORMATS` and `SUPPORTED_NOZZLE_DIAMETERS`, with a `Known...` type for each.
10
+ - **The validation schemas are no longer exported,** so the library's types mention no validation library: `StatsEventSchema` is replaced by `parseStatsEvent()` (what a sender may send, exactly) and `receiveStatsEvent()` (what a collector stores: the same event, with a maker or match source the collector doesn't know yet stored as `"other"` instead of refused, so a collector a few releases behind still counts every conversion); `PresetSchema` and `PresetFileSchema` by `parsePresetFile()`, which already existed; `OutputStampSchema` by `decodeStamp()`, likewise. The types those schemas produced (`OutputStamp`, `ConvertObject`, `HighFlowHotends`, `Shifts`, `ProfileMatch`, `ProfileIndex`, `StatsEvent`) are plain interfaces now, with the same fields.
11
+ - **Internal helpers are no longer exported:** `cleanWarnings`, `detectNozzleDiameter`, `isReleasePath`, `labelOf`, `lookupFilamentColorName`, `parseFilamentType`, `matchFilamentLine`, `normalizeTierName`, `parseTierName`, `pickProfile`, `presetFingerprint`, `recordStatsChoice`, `valueLayout`, and the constants `ABOVE_STOCK_DEFAULTS`, `BOOKKEEPING_KEYS`, `MAX_DIFF_KEYS`, `MAX_INDEX_BYTES`, `MAX_PROFILE_BYTES`, `NEVER_SENT`, `NO_STATS_CHOICE`, `PRESET_KEYS`, `PRESET_EXCLUDED_KEYS`, `REF_PATTERN`, `SETTINGS_CATALOG`, `SETTINGS_CATALOG_SOURCE` and `VALUE_LAYOUT_TEXT`, with the types `PickProfileResult`, `TierAwareProfileCandidate` and `LoadedProfile`. Use `matchProfile()` to pick a profile, as the docs always said. A catalog's `load()` and `prusaBundle()` methods, which the engine used, are no longer reachable either; for Snapmaker's stock settings as a diff side, use the new `stockDiffSide(profileId, catalog)`, the counterpart of `presetDiffSide()`; `listProfiles()`, `get()`, `list()`, `releases()`, `forRelease()`, `retiredSuccessor()` and `prusaBundles()` stay. If you used one of these, open an issue: adding one back is not a breaking change.
12
+ - **A stamp from a newer any2orca still reads.** `decodeStamp()` accepts a source format it doesn't know, instead of reading the file as unstamped. Converted files don't change.
13
+
14
+ ### Fixes
15
+
16
+ - **A partner link whose download stalls stops after 60 seconds, and you can cancel it.** When a site's `?manifest=` link points to a server that stops sending, the web app used to wait forever; it now stops after 60 seconds with nothing received and says so, and a Cancel button stops the download at any time and returns to the start screen. While it downloads, the heading says "Downloading files..." instead of "Inspecting 3MF archive...", and while it waits for a partner site's hand-off, "Waiting for the partner site...". Converted files don't change.
17
+
18
+ ### Other
19
+
20
+ - **The NOTICE says what the settings catalog holds.** It now says plainly that the settings catalog includes Snapmaker Orca's setting labels and the names of its settings pages and sections, alongside facts about each setting. No code or converted file changes.
21
+
3
22
  ## 0.8.0
4
23
 
5
24
  ### Breaking
package/NOTICE CHANGED
@@ -7,11 +7,17 @@ reference data compiled from public sources. This file is not legal advice.
7
7
 
8
8
  The names, settings-page locations, types, limits and choices of Snapmaker
9
9
  Orca's settings, used to label and group settings in comparisons, presets and
10
- "What changed?". They are generated from the setting definitions in
11
- Snapmaker Orca's source
12
- (github.com/Snapmaker/OrcaSlicer, src/libslic3r/PrintConfig.cpp), at the
13
- release named at the top of the generated file. Snapmaker Orca is
14
- AGPL-3.0-or-later; the catalog records facts about its settings, not its code.
10
+ "What changed?". They are generated from Snapmaker Orca's source
11
+ (github.com/Snapmaker/OrcaSlicer: src/libslic3r/PrintConfig.cpp,
12
+ src/libslic3r/Preset.cpp and src/slic3r/GUI/Tab.cpp), at the release named at
13
+ the top of the generated file. Snapmaker Orca is AGPL-3.0-or-later.
14
+
15
+ Besides facts about each setting (its key, value type, limits, choices and the
16
+ preset it belongs to), the catalog includes Snapmaker Orca's short label for
17
+ each setting and the names of its settings pages and sections, in the order
18
+ Snapmaker Orca shows them. They are there so that any2orca names each setting
19
+ the way Snapmaker Orca does. The catalog includes no tooltips or other help
20
+ text, and none of Snapmaker Orca's code.
15
21
 
16
22
  ## Filament color data (src/archive/filamentColorNames.ts)
17
23
 
package/README.md CHANGED
@@ -35,6 +35,8 @@ The full reference, with exit codes, the state file and `telemetry`, is in [`doc
35
35
 
36
36
  Every exported function and type is in the [API reference](https://docs.any2orca.com). The common paths:
37
37
 
38
+ What stays stable: everything the library exports is supported, and a release only adds to it. A new option is optional, a result can gain fields, and a list of values the library returns (a source maker, an error code, a change reason, a conversion stage, a diff status) can gain values, so handle one you don't recognize; each list's known values are exported next to its type, for example `SOURCE_VENDORS` beside `SourceVendor`. A file format (the output stamp, a presets file, the profile catalog, the stats event) changes shape only with a new version number, and older ones keep being read. Nothing is removed or renamed outside a major release, and only after a deprecation notice. The same holds for the CLI's commands, flags, exit codes and JSON output, and for the partner hand-off. A check in CI compares the API's shape with a committed report, so a change to it is deliberate.
39
+
38
40
  Every filament in the source stays in the output: all of them, with their colors, brands, types and order, however many. The U1 loads four at a time, but a project can use many more, swapped in at the pauses the user plans in Snapmaker Orca, and that planning depends on the file's own order. `report.filaments` lists each slot with the name it had and the name it has. The model's own metadata in `3D/3dmodel.model` (designer, license, copyright, title, description) stays as it was; only `Application` changes, to the Snapmaker Orca release the file is made for.
39
41
 
40
42
  ```js
@@ -82,7 +84,7 @@ const { output } = await convert(bytes, { profiles: catalog, snapmakerOrcaVersio
82
84
 
83
85
  More in [Snapmaker Orca releases](https://github.com/KuzuriAo/any2orca/blob/main/docs/snapmaker-orca-releases.md).
84
86
 
85
- Never re-implement profile matching in a UI: use `matchProfile()` (or `pickProfile()` and `parseTierName()`), so every UI picks the same profile for the same file.
87
+ Never re-implement profile matching in a UI: use `matchProfile()`, so every UI picks the same profile for the same file.
86
88
 
87
89
  Presets (your own tuned print settings, applied to other files; see [`docs/presets.md`](https://github.com/KuzuriAo/any2orca/blob/main/docs/presets.md)):
88
90
 
@@ -6,8 +6,11 @@ export interface FilamentColorEntry {
6
6
  hex: string;
7
7
  name: string;
8
8
  }
9
+ /** The filament makers the color library covers today; a later any2orca release may add one. */
10
+ export type FilamentColorVendor = "bambu" | "polymaker" | (string & {});
11
+ /** The real product color name a slot's preset and hex match. */
9
12
  export interface FilamentColorMatch {
10
- vendor: FilamentColorEntry["vendor"];
13
+ vendor: FilamentColorVendor;
11
14
  name: string;
12
15
  }
13
16
  /**
@@ -2,7 +2,7 @@
2
2
  import { readFileSync, statSync } from "node:fs";
3
3
  import { basename } from "node:path";
4
4
  import { diffSettings } from "../../diff/diffSettings.js";
5
- import { diffReference, presetDiffSide } from "../../diff/reference.js";
5
+ import { diffReference, presetDiffSide, stockDiffSide } from "../../diff/reference.js";
6
6
  import { valueLayoutNotes } from "../../diff/valueLayout.js";
7
7
  import { Project } from "../../project.js";
8
8
  import { formatTable } from "../table.js";
@@ -45,12 +45,13 @@ const ATTENTION_TEXT = {
45
45
  "above-limit": "above the U1's limit (capped)",
46
46
  "above-stock": "above stock",
47
47
  };
48
+ // A kind or status a later release adds sorts with the ones worth a look.
48
49
  const ATTENTION_RANK = { "above-limit": 0, "above-stock": 1 };
49
50
  const STATUS_RANK = { changed: 0, "only-a": 1, "only-b": 2, unmatched: 3, same: 4 };
50
51
  /** Rows in the chosen order. The diff's own order (Snapmaker Orca's page order) breaks ties. */
51
52
  function ordered(rows, sort) {
52
53
  const position = new Map(rows.map((r, i) => [r, i]));
53
- const rank = (r) => (sort === "attention" ? (r.attention ? ATTENTION_RANK[r.attention] : 2) : sort === "status" ? STATUS_RANK[r.status] : 0);
54
+ const rank = (r) => (sort === "attention" ? (r.attention ? (ATTENTION_RANK[r.attention] ?? 1) : 2) : sort === "status" ? (STATUS_RANK[r.status] ?? 0) : 0);
54
55
  return [...rows].sort((x, y) => rank(x) - rank(y) || (position.get(x) ?? 0) - (position.get(y) ?? 0));
55
56
  }
56
57
  /** The text report: a heading per group, then setting, first value, second value, status, and a note on values above stock or the U1's limits. */
@@ -93,8 +94,8 @@ export async function runDiff(options, out) {
93
94
  const [file] = options.files;
94
95
  const project = openFile(file);
95
96
  const profileId = options.againstStock === true ? (await project.matchProfile(options.catalog)).profileId : options.againstStock;
96
- const loaded = await options.catalog.load(profileId);
97
- diff = diffSettings({ label: basename(file), settings: project.settings() }, { label: `Snapmaker's stock ${loaded.summary.displayName} profile`, settings: loaded.convertProfile.profile.baselineProjectSettings },
97
+ const stock = await stockDiffSide(profileId, options.catalog);
98
+ diff = diffSettings({ label: basename(file), settings: project.settings() }, { label: stock.label, settings: stock.settings },
98
99
  // Filament settings come from the creator, not the stock profile, so they're only compared when asked for.
99
100
  { groups: options.groups ?? ["print", "machine"], includeUnchanged: options.all, reference: await diffReference(options.catalog, profileId) });
100
101
  }
@@ -1,14 +1,21 @@
1
1
  import { type SettingGroup } from "./settingsCatalog.js";
2
2
  import { type ValueLayout } from "./valueLayout.js";
3
3
  export type DiffGroupName = SettingGroup | "other";
4
- export type DiffStatus = "same" | "changed" | "only-a" | "only-b" | "unmatched";
4
+ /** How a setting compares between the two sides. */
5
+ export declare const DIFF_STATUSES: readonly ["same", "changed", "only-a", "only-b", "unmatched"];
6
+ export type KnownDiffStatus = (typeof DIFF_STATUSES)[number];
7
+ /** One of {@link DIFF_STATUSES}, or a status a later any2orca release added: show a row you don't recognize as changed. */
8
+ export type DiffStatus = KnownDiffStatus | (string & {});
5
9
  /**
6
10
  * A value worth a look, when the diff was given a reference profile: a speed
7
11
  * or acceleration above the printer's machine limits (it will be capped), or
8
12
  * a speed, acceleration or filament max volumetric speed above Snapmaker's
9
13
  * stock value (22/40 mm³/s for max volumetric speed).
10
14
  */
11
- export type DiffAttention = "above-limit" | "above-stock";
15
+ export declare const DIFF_ATTENTIONS: readonly ["above-limit", "above-stock"];
16
+ export type KnownDiffAttention = (typeof DIFF_ATTENTIONS)[number];
17
+ /** One of {@link DIFF_ATTENTIONS}, or a kind a later any2orca release added: mark a row you don't recognize as worth a look. */
18
+ export type DiffAttention = KnownDiffAttention | (string & {});
12
19
  export interface DiffRow {
13
20
  key: string;
14
21
  /** Where Snapmaker Orca shows the setting, for example "Speed > Acceleration > Outer wall", or the key itself. */
@@ -22,6 +22,15 @@ import { ABOVE_STOCK_DEFAULTS, machineLimitFor } from "../engine/aboveStock.js";
22
22
  import { FILAMENT_FLOW_VARIANT_KEYS, MAX_VOLUMETRIC_SPEED } from "../engine/applyFilamentFlowVariants.js";
23
23
  import { SETTINGS_CATALOG, SETTINGS_CATALOG_SOURCE } from "./settingsCatalog.js";
24
24
  import { isOtherPrinter, valueLayout } from "./valueLayout.js";
25
+ /** How a setting compares between the two sides. */
26
+ export const DIFF_STATUSES = ["same", "changed", "only-a", "only-b", "unmatched"];
27
+ /**
28
+ * A value worth a look, when the diff was given a reference profile: a speed
29
+ * or acceleration above the printer's machine limits (it will be capped), or
30
+ * a speed, acceleration or filament max volumetric speed above Snapmaker's
31
+ * stock value (22/40 mm³/s for max volumetric speed).
32
+ */
33
+ export const DIFF_ATTENTIONS = ["above-limit", "above-stock"];
25
34
  /** Entries that describe how a file was saved rather than how it prints. */
26
35
  export const BOOKKEEPING_KEYS = new Set([
27
36
  "different_settings_to_system",
@@ -1,8 +1,15 @@
1
- import type { ProfileCatalog } from "../profiles.js";
1
+ import { type ProfileCatalog } from "../profiles.js";
2
2
  import { type Preset } from "../presets/preset.js";
3
3
  import type { DiffOptions, SettingsSide } from "./diffSettings.js";
4
4
  /** A profile as a diff's reference: its stock project settings and its printer's machine settings (see DiffOptions.reference). */
5
5
  export declare function diffReference(catalog: ProfileCatalog, profileId: string): Promise<NonNullable<DiffOptions["reference"]>>;
6
+ /**
7
+ * Snapmaker's stock profile as a diff side: its project settings, labeled with its name. Shared by the CLI's
8
+ * `diff --against-stock` and the worker's stock side, so both compare the same thing.
9
+ */
10
+ export declare function stockDiffSide(profileId: string, catalog: ProfileCatalog): Promise<SettingsSide & {
11
+ profileId: string;
12
+ }>;
6
13
  /**
7
14
  * A preset as a diff side, the way it converts: its base profile's stock
8
15
  * settings with its changes written over them. Shared by the CLI's
@@ -1,11 +1,20 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  import { applyPresetChanges } from "../engine/applyPresetChanges.js";
3
+ import { catalogEngine } from "../profiles.js";
3
4
  import { resolvePreset } from "../presets/preset.js";
4
5
  /** A profile as a diff's reference: its stock project settings and its printer's machine settings (see DiffOptions.reference). */
5
6
  export async function diffReference(catalog, profileId) {
6
- const loaded = await catalog.load(profileId);
7
+ const loaded = await catalogEngine(catalog).load(profileId);
7
8
  return { stock: loaded.convertProfile.profile.baselineProjectSettings, machine: loaded.convertProfile.printer.machineSettingsConfig };
8
9
  }
10
+ /**
11
+ * Snapmaker's stock profile as a diff side: its project settings, labeled with its name. Shared by the CLI's
12
+ * `diff --against-stock` and the worker's stock side, so both compare the same thing.
13
+ */
14
+ export async function stockDiffSide(profileId, catalog) {
15
+ const loaded = await catalogEngine(catalog).load(profileId);
16
+ return { label: `Snapmaker's stock ${loaded.summary.displayName} profile`, settings: loaded.convertProfile.profile.baselineProjectSettings, profileId: loaded.summary.id };
17
+ }
9
18
  /**
10
19
  * A preset as a diff side, the way it converts: its base profile's stock
11
20
  * settings with its changes written over them. Shared by the CLI's
@@ -14,7 +23,7 @@ export async function diffReference(catalog, profileId) {
14
23
  */
15
24
  export async function presetDiffSide(preset, catalog) {
16
25
  const resolved = await resolvePreset(preset, catalog);
17
- const loaded = await catalog.load(resolved.profileId);
26
+ const loaded = await catalogEngine(catalog).load(resolved.profileId);
18
27
  const settings = structuredClone(loaded.convertProfile.profile.baselineProjectSettings);
19
28
  applyPresetChanges(settings, resolved.changes, []);
20
29
  const name = typeof preset.name === "string" ? preset.name.slice(0, 40) : "";
@@ -3,9 +3,12 @@
3
3
  * - `flow-variants`: two values, another printer's standard nozzle, then its high-flow nozzle.
4
4
  * - `nozzle-variants`: one value per nozzle of a two-nozzle printer, standard then high flow for each.
5
5
  */
6
- export type ValueLayout = "u1-hotends" | "flow-variants" | "nozzle-variants";
6
+ export declare const VALUE_LAYOUTS: readonly ["u1-hotends", "flow-variants", "nozzle-variants"];
7
+ export type KnownValueLayout = (typeof VALUE_LAYOUTS)[number];
8
+ /** One of {@link VALUE_LAYOUTS}, or a layout a later any2orca release added: show the values of one you don't recognize as they are. */
9
+ export type ValueLayout = KnownValueLayout | (string & {});
7
10
  /** 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>>;
11
+ export declare const VALUE_LAYOUT_TEXT: Readonly<Record<KnownValueLayout, string>>;
9
12
  /** Settings for a printer other than the U1 (a missing model counts as the U1: stock profiles and presets). */
10
13
  export declare function isOtherPrinter(settings: Readonly<Record<string, unknown>>): boolean;
11
14
  /**
@@ -14,13 +14,18 @@
14
14
  */
15
15
  import { FILAMENT_FLOW_VARIANT_KEYS } from "../engine/applyFilamentFlowVariants.js";
16
16
  import { NOZZLE_VARIANT_KEYS } from "../engine/collapseNozzleVariants.js";
17
+ /**
18
+ * - `u1-hotends`: two values, the U1's standard hotend, then the Liber High Flow Hotend.
19
+ * - `flow-variants`: two values, another printer's standard nozzle, then its high-flow nozzle.
20
+ * - `nozzle-variants`: one value per nozzle of a two-nozzle printer, standard then high flow for each.
21
+ */
22
+ export const VALUE_LAYOUTS = ["u1-hotends", "flow-variants", "nozzle-variants"];
17
23
  /** One sentence per layout, for a note above a table of values. The web app and the CLI both use these. */
18
24
  export const VALUE_LAYOUT_TEXT = {
19
25
  "u1-hotends": "Two values: standard hotend, then Liber High Flow Hotend.",
20
26
  "flow-variants": "Two values: the original printer's standard nozzle, then its high-flow nozzle.",
21
27
  "nozzle-variants": "One value per nozzle of the original printer, standard then high flow for each.",
22
28
  };
23
- const LAYOUT_ORDER = ["u1-hotends", "flow-variants", "nozzle-variants"];
24
29
  const FILAMENT_PAIRS = new Set(FILAMENT_FLOW_VARIANT_KEYS);
25
30
  /** Settings for a printer other than the U1 (a missing model counts as the U1: stock profiles and presets). */
26
31
  export function isOtherPrinter(settings) {
@@ -61,5 +66,5 @@ export function valueLayoutNotes(rows) {
61
66
  for (const layout of Object.values(row.layout ?? {}))
62
67
  if (layout)
63
68
  used.add(layout);
64
- return LAYOUT_ORDER.filter((l) => used.has(l)).map((l) => VALUE_LAYOUT_TEXT[l]);
69
+ return VALUE_LAYOUTS.filter((l) => used.has(l)).map((l) => VALUE_LAYOUT_TEXT[l]);
65
70
  }
@@ -1,7 +1,9 @@
1
1
  import type { JsonRecord } from "./types.js";
2
2
  /** Nozzle diameters we carry a Snapmaker U1 profile for, smallest first. */
3
3
  export declare const SUPPORTED_NOZZLE_DIAMETERS: readonly ["0.2", "0.4", "0.6", "0.8"];
4
- export type SupportedNozzleDiameter = (typeof SUPPORTED_NOZZLE_DIAMETERS)[number];
4
+ export type KnownNozzleDiameter = (typeof SUPPORTED_NOZZLE_DIAMETERS)[number];
5
+ /** One of {@link SUPPORTED_NOZZLE_DIAMETERS}, or a size a later catalog added. */
6
+ export type SupportedNozzleDiameter = KnownNozzleDiameter | (string & {});
5
7
  /**
6
8
  * Reads the Bambu source's own `nozzle_diameter` (blocklisted from the
7
9
  * merge itself, but still present in the raw uploaded project settings)
package/dist/errors.d.ts CHANGED
@@ -10,7 +10,10 @@
10
10
  * - `invalid_preset`: a preset or presets file that is malformed, over a limit, or can't be used with the given options.
11
11
  * - `preset_base_unknown`: a file a preset can't be made from, because it isn't set up for a profile in the catalog.
12
12
  */
13
- export type Any2orcaErrorCode = "invalid_file" | "unsupported_slicer" | "too_large" | "invalid_project" | "profile_not_found" | "release_not_found" | "profile_data" | "invalid_preset" | "preset_base_unknown";
13
+ export declare const ANY2ORCA_ERROR_CODES: readonly ["invalid_file", "unsupported_slicer", "too_large", "invalid_project", "profile_not_found", "release_not_found", "profile_data", "invalid_preset", "preset_base_unknown"];
14
+ export type KnownAny2orcaErrorCode = (typeof ANY2ORCA_ERROR_CODES)[number];
15
+ /** One of {@link ANY2ORCA_ERROR_CODES}, or a code a later any2orca release added: treat one you don't recognize as a failure of the same kind as `invalid_file`. */
16
+ export type Any2orcaErrorCode = KnownAny2orcaErrorCode | (string & {});
14
17
  export declare class Any2orcaError extends Error {
15
18
  name: string;
16
19
  readonly code: Any2orcaErrorCode;
package/dist/errors.js CHANGED
@@ -1,4 +1,27 @@
1
1
  // SPDX-License-Identifier: MIT
2
+ /**
3
+ * What went wrong, as a stable code a UI can branch on:
4
+ * - `invalid_file`: not a readable 3MF (corrupt zip, missing project files, unsafe entries).
5
+ * - `unsupported_slicer`: a readable project from a slicer this doesn't convert (SuperSlicer, say, or an older AnycubicSlicer, both built on PrusaSlicer); `slicer` names it.
6
+ * - `too_large`: a project that unpacks to more than the size limit (2 GB by default; `maxUnpackedBytes` changes it).
7
+ * - `invalid_project`: a readable 3MF whose settings or objects are malformed or over a limit.
8
+ * - `profile_not_found`: the requested profile id isn't in the catalog and wasn't retired.
9
+ * - `release_not_found`: the requested Snapmaker Orca release isn't one the profile catalog holds.
10
+ * - `profile_data`: the profile catalog itself is missing or malformed.
11
+ * - `invalid_preset`: a preset or presets file that is malformed, over a limit, or can't be used with the given options.
12
+ * - `preset_base_unknown`: a file a preset can't be made from, because it isn't set up for a profile in the catalog.
13
+ */
14
+ export const ANY2ORCA_ERROR_CODES = [
15
+ "invalid_file",
16
+ "unsupported_slicer",
17
+ "too_large",
18
+ "invalid_project",
19
+ "profile_not_found",
20
+ "release_not_found",
21
+ "profile_data",
22
+ "invalid_preset",
23
+ "preset_base_unknown",
24
+ ];
2
25
  export class Any2orcaError extends Error {
3
26
  name = "Any2orcaError";
4
27
  code;
@@ -15,7 +15,11 @@
15
15
  import { type SettingsDiff } from "../diff/diffSettings.js";
16
16
  import { type ValueLayout } from "../diff/valueLayout.js";
17
17
  import type { JsonRecord } from "../engine/types.js";
18
- export type ChangeReason = "creator" | "stock" | "capped" | "firmware" | "layout" | "yours";
18
+ /** Why a setting changed, in the order the explanation lists them. */
19
+ export declare const CHANGE_REASONS: readonly ["creator", "stock", "capped", "firmware", "layout", "yours"];
20
+ export type KnownChangeReason = (typeof CHANGE_REASONS)[number];
21
+ /** One of {@link CHANGE_REASONS}, or a reason a later any2orca release added: show one you don't recognize as it is. */
22
+ export type ChangeReason = KnownChangeReason | (string & {});
19
23
  export interface ChangeItem {
20
24
  /** The setting's key, or absent for an item that isn't one setting (an object moved, a summary). */
21
25
  key?: string;
@@ -16,6 +16,8 @@
16
16
  import { BOOKKEEPING_KEYS, labelOf, sameSetting } from "../diff/diffSettings.js";
17
17
  import { SETTINGS_CATALOG, SETTINGS_CATALOG_SOURCE } from "../diff/settingsCatalog.js";
18
18
  import { valueLayout, valueLayoutNotes } from "../diff/valueLayout.js";
19
+ /** Why a setting changed, in the order the explanation lists them. */
20
+ export const CHANGE_REASONS = ["creator", "stock", "capped", "firmware", "layout", "yours"];
19
21
  const GROUPS = [
20
22
  { reason: "creator", title: "From the creator's file", description: "Settings the creator changed, carried into the converted file. Before: Snapmaker's stock value. After: the creator's." },
21
23
  { reason: "stock", title: "Kept at Snapmaker's stock value", description: "Settings the creator's file has with another value, which the converted file doesn't use. Before: the creator's file. After: Snapmaker's stock value." },
package/dist/index.d.ts CHANGED
@@ -9,42 +9,41 @@
9
9
  * sources see `any2orca/node`; for a ready-made Web Worker see
10
10
  * `any2orca/worker`.
11
11
  */
12
- export { convert, inspect, openProject, matchProfile, unwrapBundle, cleanWarnings, Project } from "./project.js";
13
- export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, OpenOptions, ProfileChoice, ReportFilament } from "./project.js";
12
+ export { convert, inspect, openProject, matchProfile, unwrapBundle, Project, CONVERT_STAGES } from "./project.js";
13
+ export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, OpenOptions, ProfileChoice, ReportFilament } from "./project.js";
14
14
  export { DEFAULT_MAX_UNPACKED_BYTES, LARGE_PROJECT_BYTES, MAX_UNPACKED_BYTES_LIMIT } from "./archive/safeUnzip.js";
15
- export type { FilamentSlotInfo, Inspection, SourceVendor } from "./inspect.js";
16
- export { fetchProfileSource, isReleasePath, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError, MAX_INDEX_BYTES, MAX_PROFILE_BYTES, } from "./profiles.js";
17
- export type { LoadedProfile, MemoryCatalogData, ProfileIndex, ProfileSource, ProfileSummary, RetiredProfile, SlicerRelease } from "./profiles.js";
18
- export { parseTierName, normalizeTierName } from "./engine/parseTierName.js";
19
- export { pickProfile } from "./engine/pickProfile.js";
20
- export type { PickProfileResult, TierAwareProfileCandidate } from "./engine/pickProfile.js";
21
- export { detectNozzleDiameter, SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
22
- export { matchFilamentLine, resolveFilamentName } from "./engine/filamentComplianceNames.js";
15
+ export { SOURCE_VENDORS } from "./inspect.js";
16
+ export type { FilamentSlotInfo, Inspection, KnownSourceVendor, SourceVendor } from "./inspect.js";
17
+ export { SOURCE_FORMATS } from "./sources/reader.js";
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";
21
+ export { fetchProfileSource, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError } from "./profiles.js";
22
+ export type { MemoryCatalogData, ProfileIndex, ProfileIndexPrinter, ProfileIndexProfile, ProfileIndexRelease, ProfileIndexSource, ProfileSource, ProfileSummary, RetiredProfile, SlicerRelease, } from "./profiles.js";
23
+ export { resolveFilamentName } from "./engine/filamentComplianceNames.js";
23
24
  export type { FilamentComplianceMode, FilamentLine, FilamentNameResult, FilamentNameTable, FilamentPresetEntry, } from "./engine/filamentComplianceNames.js";
24
- export { lookupFilamentColorName, parseFilamentType } from "./archive/lookupFilamentColorName.js";
25
- export type { FilamentColorMatch } from "./archive/lookupFilamentColorName.js";
25
+ export type { FilamentColorMatch, FilamentColorVendor } from "./archive/lookupFilamentColorName.js";
26
26
  export type { BundleEntry } from "./archive/unwrapBundle.js";
27
- export { Any2orcaError } from "./errors.js";
28
- export type { Any2orcaErrorCode } from "./errors.js";
29
- export { decodeStamp, OutputStampSchema, STAMP_PATH } from "./stamp.js";
30
- export { diffSettings, labelOf, BOOKKEEPING_KEYS, MAX_DIFF_KEYS } from "./diff/diffSettings.js";
31
- export { valueLayout, valueLayoutNotes, VALUE_LAYOUT_TEXT } from "./diff/valueLayout.js";
32
- export type { ValueLayout } from "./diff/valueLayout.js";
33
- export type { DiffAttention, DiffGroup, DiffGroupName, DiffOptions, DiffRow, DiffStatus, SettingsDiff, SettingsSide } from "./diff/diffSettings.js";
34
- export { diffReference, presetDiffSide } from "./diff/reference.js";
35
- export { SETTINGS_CATALOG, SETTINGS_CATALOG_SOURCE } from "./diff/settingsCatalog.js";
27
+ export { Any2orcaError, ANY2ORCA_ERROR_CODES } from "./errors.js";
28
+ export type { Any2orcaErrorCode, KnownAny2orcaErrorCode } from "./errors.js";
29
+ export { decodeStamp, STAMP_PATH } from "./stamp.js";
30
+ export type { OutputStampAboveStock, OutputStampPreset } from "./stamp.js";
31
+ export { diffSettings, DIFF_ATTENTIONS, DIFF_STATUSES } from "./diff/diffSettings.js";
32
+ export { valueLayoutNotes, VALUE_LAYOUTS } from "./diff/valueLayout.js";
33
+ export type { KnownValueLayout, ValueLayout } from "./diff/valueLayout.js";
34
+ export type { DiffAttention, DiffGroup, DiffGroupName, DiffOptions, DiffRow, DiffStatus, KnownDiffAttention, KnownDiffStatus, SettingsDiff, SettingsSide, } from "./diff/diffSettings.js";
35
+ export { diffReference, presetDiffSide, stockDiffSide } from "./diff/reference.js";
36
36
  export type { SettingGroup, SettingInfo } from "./diff/settingsCatalog.js";
37
- export { formatWhatChanged } from "./explain/whatChanged.js";
38
- export type { ChangeGroup, ChangeItem, ChangeReason, WhatChanged } from "./explain/whatChanged.js";
37
+ export { formatWhatChanged, CHANGE_REASONS } from "./explain/whatChanged.js";
38
+ export type { ChangeGroup, ChangeItem, ChangeReason, KnownChangeReason, WhatChanged } from "./explain/whatChanged.js";
39
39
  export { extractPreset } from "./presets/extractPreset.js";
40
- export { parsePresetFile, serializePresets, resolvePreset, presetFingerprint, withoutChanges, PresetSchema, PresetFileSchema, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES, } from "./presets/preset.js";
40
+ export { parsePresetFile, serializePresets, resolvePreset, withoutChanges, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES } from "./presets/preset.js";
41
41
  export type { ExtractedPreset, Preset, PresetChange, PresetFile, PresetValue, ResolvedPreset } from "./presets/preset.js";
42
- export { PRESET_KEYS, PRESET_EXCLUDED_KEYS } from "./presets/presetKeys.js";
43
- export { ABOVE_STOCK_DEFAULTS } from "./engine/aboveStock.js";
44
42
  export type { AboveStockChoice, AboveStockDefault } from "./engine/aboveStock.js";
45
43
  export type { OutputStamp } from "./stamp.js";
46
- export { buildStatsEvent, NEVER_SENT, NO_STATS_CHOICE, recordStatsChoice, REF_PATTERN, resolveStatsConsent, StatsEventSchema, } from "./telemetry.js";
47
- export type { StatsConsent, StatsConsentState, StatsEvent, StatsEventInput } from "./telemetry.js";
48
- export type { ConvertObject, HighFlowHotends, MatchSource, ProfileMatch, Shifts } from "./schema.js";
44
+ export { buildStatsEvent, parseStatsEvent, receiveStatsEvent, resolveStatsConsent, STATS_MATCH_SOURCES } from "./telemetry.js";
45
+ export type { KnownStatsMatchSource, StatsConsent, StatsConsentState, StatsEvent, StatsEventInput, StatsMatchSource } from "./telemetry.js";
46
+ export { MATCH_SOURCES } from "./schema.js";
47
+ export type { ConvertObject, HighFlowHotends, KnownMatchSource, MatchSource, ProfileMatch, Shifts } from "./schema.js";
49
48
  export { plainText } from "./plainText.js";
50
49
  export { VERSION } from "./version.js";
package/dist/index.js CHANGED
@@ -10,25 +10,22 @@
10
10
  * sources see `any2orca/node`; for a ready-made Web Worker see
11
11
  * `any2orca/worker`.
12
12
  */
13
- export { convert, inspect, openProject, matchProfile, unwrapBundle, cleanWarnings, Project } from "./project.js";
13
+ export { convert, inspect, openProject, matchProfile, unwrapBundle, Project, CONVERT_STAGES } from "./project.js";
14
14
  export { DEFAULT_MAX_UNPACKED_BYTES, LARGE_PROJECT_BYTES, MAX_UNPACKED_BYTES_LIMIT } from "./archive/safeUnzip.js";
15
- export { fetchProfileSource, isReleasePath, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError, MAX_INDEX_BYTES, MAX_PROFILE_BYTES, } from "./profiles.js";
16
- export { parseTierName, normalizeTierName } from "./engine/parseTierName.js";
17
- export { pickProfile } from "./engine/pickProfile.js";
18
- export { detectNozzleDiameter, SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
19
- export { matchFilamentLine, resolveFilamentName } from "./engine/filamentComplianceNames.js";
20
- export { lookupFilamentColorName, parseFilamentType } from "./archive/lookupFilamentColorName.js";
21
- export { Any2orcaError } from "./errors.js";
22
- export { decodeStamp, OutputStampSchema, STAMP_PATH } from "./stamp.js";
23
- export { diffSettings, labelOf, BOOKKEEPING_KEYS, MAX_DIFF_KEYS } from "./diff/diffSettings.js";
24
- export { valueLayout, valueLayoutNotes, VALUE_LAYOUT_TEXT } from "./diff/valueLayout.js";
25
- export { diffReference, presetDiffSide } from "./diff/reference.js";
26
- export { SETTINGS_CATALOG, SETTINGS_CATALOG_SOURCE } from "./diff/settingsCatalog.js";
27
- export { formatWhatChanged } from "./explain/whatChanged.js";
15
+ export { SOURCE_VENDORS } from "./inspect.js";
16
+ export { SOURCE_FORMATS } from "./sources/reader.js";
17
+ export { SUPPORTED_NOZZLE_DIAMETERS } from "./engine/detectNozzleDiameter.js";
18
+ export { fetchProfileSource, listProfiles, loadCatalog, memoryProfileSource, ProfileCatalog, ProfileDataError } from "./profiles.js";
19
+ export { resolveFilamentName } from "./engine/filamentComplianceNames.js";
20
+ export { Any2orcaError, ANY2ORCA_ERROR_CODES } from "./errors.js";
21
+ export { decodeStamp, STAMP_PATH } from "./stamp.js";
22
+ export { diffSettings, DIFF_ATTENTIONS, DIFF_STATUSES } from "./diff/diffSettings.js";
23
+ export { valueLayoutNotes, VALUE_LAYOUTS } from "./diff/valueLayout.js";
24
+ export { diffReference, presetDiffSide, stockDiffSide } from "./diff/reference.js";
25
+ export { formatWhatChanged, CHANGE_REASONS } from "./explain/whatChanged.js";
28
26
  export { extractPreset } from "./presets/extractPreset.js";
29
- export { parsePresetFile, serializePresets, resolvePreset, presetFingerprint, withoutChanges, PresetSchema, PresetFileSchema, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES, } from "./presets/preset.js";
30
- export { PRESET_KEYS, PRESET_EXCLUDED_KEYS } from "./presets/presetKeys.js";
31
- export { ABOVE_STOCK_DEFAULTS } from "./engine/aboveStock.js";
32
- export { buildStatsEvent, NEVER_SENT, NO_STATS_CHOICE, recordStatsChoice, REF_PATTERN, resolveStatsConsent, StatsEventSchema, } from "./telemetry.js";
27
+ export { parsePresetFile, serializePresets, resolvePreset, withoutChanges, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES } from "./presets/preset.js";
28
+ export { buildStatsEvent, parseStatsEvent, receiveStatsEvent, resolveStatsConsent, STATS_MATCH_SOURCES } from "./telemetry.js";
29
+ export { MATCH_SOURCES } from "./schema.js";
33
30
  export { plainText } from "./plainText.js";
34
31
  export { VERSION } from "./version.js";
package/dist/inspect.d.ts CHANGED
@@ -8,8 +8,14 @@
8
8
  import { type FilamentColorMatch } from "./archive/lookupFilamentColorName.js";
9
9
  import { type SupportedNozzleDiameter } from "./engine/detectNozzleDiameter.js";
10
10
  import type { ConvertObject } from "./schema.js";
11
- /** The printer maker a source file was set up for, from its `printer_model`. */
12
- export type SourceVendor = "bambu" | "creality" | "anycubic" | "snapmaker" | "elegoo" | "prusa" | "flashforge" | "qidi" | "other";
11
+ /** The printer makers any2orca recognizes, from a project's printer and preset names; "other" for any it doesn't. */
12
+ export declare const SOURCE_VENDORS: readonly ["bambu", "creality", "anycubic", "snapmaker", "elegoo", "prusa", "flashforge", "qidi", "other"];
13
+ export type KnownSourceVendor = (typeof SOURCE_VENDORS)[number];
14
+ /**
15
+ * The printer maker a source file was set up for: one of {@link SOURCE_VENDORS}, or a maker a later any2orca
16
+ * release added. Treat a value you don't recognize like "other".
17
+ */
18
+ export type SourceVendor = KnownSourceVendor | (string & {});
13
19
  export interface FilamentSlotInfo {
14
20
  /** 1-based slot number, as slicers show it. */
15
21
  slot: number;
package/dist/inspect.js CHANGED
@@ -10,6 +10,8 @@ import { lookupFilamentColorName } from "./archive/lookupFilamentColorName.js";
10
10
  import { detectNozzleDiameter } from "./engine/detectNozzleDiameter.js";
11
11
  import { parseTierName } from "./engine/parseTierName.js";
12
12
  import { plainText } from "./plainText.js";
13
+ /** The printer makers any2orca recognizes, from a project's printer and preset names; "other" for any it doesn't. */
14
+ export const SOURCE_VENDORS = ["bambu", "creality", "anycubic", "snapmaker", "elegoo", "prusa", "flashforge", "qidi", "other"];
13
15
  const VENDOR_PATTERNS = [
14
16
  { vendor: "bambu", pattern: /^(bambu\s*lab|bbl)\b/i },
15
17
  { vendor: "creality", pattern: /^creality\b/i },
@@ -2,7 +2,7 @@
2
2
  import { sameSetting } from "../diff/diffSettings.js";
3
3
  import { SETTINGS_CATALOG } from "../diff/settingsCatalog.js";
4
4
  import { Any2orcaError } from "../errors.js";
5
- import { loadCatalog } from "../profiles.js";
5
+ import { catalogEngine, loadCatalog } from "../profiles.js";
6
6
  import { Project } from "../project.js";
7
7
  import { checkedChanges, describeChanges, stockValue } from "./preset.js";
8
8
  import { isPresetKey } from "./presetKeys.js";
@@ -56,7 +56,7 @@ export async function extractPreset(input, options) {
56
56
  baseInferred = true;
57
57
  notes.push(`The project doesn't name a U1 profile; it's compared with ${catalog.get(base)?.displayName}, the closest match for its nozzle and layer height.`);
58
58
  }
59
- const loaded = await catalog.load(base);
59
+ const loaded = await catalogEngine(catalog).load(base);
60
60
  const stock = loaded.convertProfile.profile.baselineProjectSettings;
61
61
  const differing = {};
62
62
  for (const key of Object.keys(settings)) {
@@ -17,7 +17,7 @@
17
17
  import "../zodSetup.js";
18
18
  import { z } from "zod";
19
19
  import type { JsonRecord } from "../engine/types.js";
20
- import type { ProfileCatalog } from "../profiles.js";
20
+ import { type ProfileCatalog } from "../profiles.js";
21
21
  export declare const MAX_PRESET_NAME_LENGTH = 40;
22
22
  export declare const MAX_PRESETS_PER_FILE = 100;
23
23
  export declare const MAX_PRESETS_FILE_BYTES: number;
@@ -22,6 +22,7 @@ import { SETTINGS_CATALOG } from "../diff/settingsCatalog.js";
22
22
  import { machineLimitFor } from "../engine/aboveStock.js";
23
23
  import { VARIANT_PROCESS_KEYS } from "../engine/applyHighFlowHotends.js";
24
24
  import { Any2orcaError } from "../errors.js";
25
+ import { catalogEngine } from "../profiles.js";
25
26
  import { isPresetKey, PRESET_EXCLUDED_KEYS, PRESET_KEYS } from "./presetKeys.js";
26
27
  export const MAX_PRESET_NAME_LENGTH = 40;
27
28
  export const MAX_PRESETS_PER_FILE = 100;
@@ -168,7 +169,7 @@ export async function resolvePreset(preset, catalog) {
168
169
  }
169
170
  if (!catalog.get(profileId))
170
171
  throw new Any2orcaError("invalid_preset", `The preset's base profile "${profileId}" isn't in the profile catalog.`);
171
- const loaded = await catalog.load(profileId);
172
+ const loaded = await catalogEngine(catalog).load(profileId);
172
173
  const stock = loaded.convertProfile.profile.baselineProjectSettings;
173
174
  const changes = checkedChanges(parsed.data.changes, stock, notes);
174
175
  return { profileId, changes, described: describeChanges(changes, stock, loaded.convertProfile.printer.machineSettingsConfig), notes };
@@ -262,6 +263,11 @@ export function parsePresetFile(input) {
262
263
  throw new Any2orcaError("invalid_preset", "This isn't a presets file: it isn't valid JSON.");
263
264
  }
264
265
  assertPlainJson(raw, 0);
266
+ // A file this format's later version wrote: say so, rather than "not valid".
267
+ const header = typeof raw === "object" && raw !== null ? raw : {};
268
+ if (header.format === "any2orca-presets" && typeof header.version === "number" && Number.isInteger(header.version) && header.version > 1) {
269
+ throw new Any2orcaError("invalid_preset", `This presets file was saved by a newer any2orca (format version ${header.version}). Update any2orca to open it.`);
270
+ }
265
271
  const parsed = PresetFileSchema.safeParse(raw);
266
272
  if (!parsed.success)
267
273
  throw new Any2orcaError("invalid_preset", `This isn't a valid presets file: ${describeIssues(parsed.error)}`);
@@ -22,6 +22,7 @@ import { z } from "zod";
22
22
  import { type PrusaBundle } from "./sources/prusa/bundle.js";
23
23
  import { Any2orcaError } from "./errors.js";
24
24
  import type { ConvertProfile } from "./engine/runConvertPipeline.js";
25
+ import type { FilamentNameTable } from "./engine/filamentComplianceNames.js";
25
26
  /** Raw access to a catalog. Both methods return parsed JSON; the core validates it. */
26
27
  export interface ProfileSource {
27
28
  /** The catalog index (`index.json`). */
@@ -31,13 +32,13 @@ export interface ProfileSource {
31
32
  /**
32
33
  * The source for an older release this catalog holds, in the folder at
33
34
  * `path` (from index.json `releases`, always `releases/<version>`). Only
34
- * called with a path that passes {@link isReleasePath}. Leave it out for a
35
+ * called with a path of the form `releases/<x.y.z>`. Leave it out for a
35
36
  * catalog with one release.
36
37
  */
37
38
  release?(path: string): ProfileSource;
38
39
  /**
39
40
  * One source-slicer data file (`sources/prusaslicer/<Vendor>.json`). Only
40
- * called with a path the index lists, which passes {@link isSourcePath}.
41
+ * called with a path the index lists (`sources/prusaslicer/<Vendor>-<version>.json`).
41
42
  * Leave it out for a source without such data: a PrusaSlicer project is
42
43
  * then converted with every mapped setting treated as changed.
43
44
  */
@@ -128,7 +129,66 @@ export declare const ProfileIndexSchema: z.ZodObject<{
128
129
  }, z.core.$strip>>;
129
130
  }, z.core.$strip>>;
130
131
  }, z.core.$strip>;
131
- export type ProfileIndex = z.infer<typeof ProfileIndexSchema>;
132
+ /** A printer the catalog has profiles for. */
133
+ export interface ProfileIndexPrinter {
134
+ id: string;
135
+ displayName: string;
136
+ nozzleDiameter: string;
137
+ highFlowSupported: boolean;
138
+ }
139
+ /** A profile as the index lists it. */
140
+ export interface ProfileIndexProfile {
141
+ id: string;
142
+ printerId: string;
143
+ displayName: string;
144
+ nozzleDiameter: string;
145
+ layerHeight: number;
146
+ autoSelectable: boolean;
147
+ highFlowSpeeds: boolean;
148
+ }
149
+ /** A Snapmaker Orca release the catalog holds: this index's own (`path` ".") or an older one's folder. */
150
+ export interface ProfileIndexRelease {
151
+ version: string;
152
+ application: string;
153
+ path: string;
154
+ }
155
+ /** A source-slicer data file the catalog holds (PrusaSlicer's vendor preset bundles). */
156
+ export interface ProfileIndexSource {
157
+ vendor: string;
158
+ name: string;
159
+ path: string;
160
+ slicerVersion: string;
161
+ configVersion: string;
162
+ slicerTag: string;
163
+ }
164
+ /** A catalog's `index.json`, as {@link loadCatalog} checks it. */
165
+ export interface ProfileIndex {
166
+ schema: 1;
167
+ dataVersion: string;
168
+ slicer: {
169
+ name: string;
170
+ version: string;
171
+ application: string;
172
+ };
173
+ /** Where the profiles come from: the target slicer's repository and the release tag and commit they were generated at. */
174
+ source?: {
175
+ repository: string;
176
+ tag: string;
177
+ commit: string;
178
+ };
179
+ defaultProfileId: string;
180
+ printers: ProfileIndexPrinter[];
181
+ profiles: ProfileIndexProfile[];
182
+ retired: RetiredProfile[];
183
+ /** Filament preset names for the Snapmaker/Generic naming options, per printer. */
184
+ filamentNames?: FilamentNameTable;
185
+ /** Every Snapmaker Orca release this catalog holds, newest first. Absent in a catalog with one release. */
186
+ releases?: ProfileIndexRelease[];
187
+ /** Source-slicer data the catalog holds, independent of the Snapmaker Orca release. Absent in older data. */
188
+ sources?: {
189
+ prusaslicer: ProfileIndexSource[];
190
+ };
191
+ }
132
192
  export declare const ProfileFileSchema: z.ZodObject<{
133
193
  schema: z.ZodLiteral<1>;
134
194
  id: z.ZodString;
@@ -186,6 +246,15 @@ export interface LoadedProfile {
186
246
  summary: ProfileSummary;
187
247
  convertProfile: ConvertProfile;
188
248
  }
249
+ /** The engine's side of a catalog: what a conversion runs on. Reached with {@link catalogEngine}; not part of the public API. */
250
+ export interface CatalogEngine {
251
+ load(id: string): Promise<LoadedProfile>;
252
+ prusaBundle(vendor: string, slicerVersion: string): Promise<PrusaBundle | null>;
253
+ }
254
+ /** For tests: gives a stand-in catalog an engine side. */
255
+ export declare function withCatalogEngine<T extends object>(catalog: T, engine: Partial<CatalogEngine>): T;
256
+ /** The engine's access to a catalog. Kept off the class, so the public API holds only what a UI needs. */
257
+ export declare function catalogEngine(catalog: ProfileCatalog): CatalogEngine;
189
258
  /** The catalog itself is missing or malformed (code `profile_data`). */
190
259
  export declare class ProfileDataError extends Any2orcaError {
191
260
  constructor(message: string);
@@ -221,7 +290,7 @@ export declare class ProfileCatalog {
221
290
  * One PrusaSlicer vendor bundle, loaded and checked once, or null when the
222
291
  * catalog doesn't list it or its source can't read source data.
223
292
  */
224
- prusaBundle(vendor: string, slicerVersion: string): Promise<PrusaBundle | null>;
293
+ private prusaBundle;
225
294
  /** The live profile that replaced a retired id, if `id` was retired. */
226
295
  retiredSuccessor(id: string): RetiredProfile | undefined;
227
296
  /** The Snapmaker Orca releases this catalog holds, newest first. The first is the default. */
@@ -234,7 +303,7 @@ export declare class ProfileCatalog {
234
303
  */
235
304
  forRelease(version: string): Promise<ProfileCatalog>;
236
305
  /** Loads and validates one profile. Throws for an id the catalog doesn't list. */
237
- load(id: string): Promise<LoadedProfile>;
306
+ private load;
238
307
  }
239
308
  /** Reads and validates a source's index. Cached per source object. */
240
309
  export declare function loadCatalog(source: ProfileSource | ProfileCatalog): Promise<ProfileCatalog>;
package/dist/profiles.js CHANGED
@@ -141,6 +141,19 @@ export const ProfileFileSchema = z.object({
141
141
  filamentShape: settings,
142
142
  highFlowOverrides: z.record(z.string().max(200), z.string().max(200)),
143
143
  });
144
+ const ENGINES = new WeakMap();
145
+ /** For tests: gives a stand-in catalog an engine side. */
146
+ export function withCatalogEngine(catalog, engine) {
147
+ ENGINES.set(catalog, { load: () => Promise.reject(new ProfileDataError("No profiles in this stand-in.")), prusaBundle: () => Promise.resolve(null), ...engine });
148
+ return catalog;
149
+ }
150
+ /** The engine's access to a catalog. Kept off the class, so the public API holds only what a UI needs. */
151
+ export function catalogEngine(catalog) {
152
+ const engine = ENGINES.get(catalog);
153
+ if (!engine)
154
+ throw new ProfileDataError("Not a profile catalog.");
155
+ return engine;
156
+ }
144
157
  /** The catalog itself is missing or malformed (code `profile_data`). */
145
158
  export class ProfileDataError extends Any2orcaError {
146
159
  constructor(message) {
@@ -167,6 +180,7 @@ export class ProfileCatalog {
167
180
  releaseCatalogs = new Map();
168
181
  bundles = new Map();
169
182
  constructor(index, source) {
183
+ ENGINES.set(this, { load: (id) => this.load(id), prusaBundle: (vendor, slicerVersion) => this.prusaBundle(vendor, slicerVersion) });
170
184
  this.index = index;
171
185
  this.source = source;
172
186
  if (index.releases) {
package/dist/project.d.ts CHANGED
@@ -70,7 +70,11 @@ export interface ConvertOptions {
70
70
  /** Called as the conversion moves through its steps, for a progress display. */
71
71
  onProgress?: (stage: ConvertStage) => void;
72
72
  }
73
- export type ConvertStage = "matching" | "loading-profile" | "merging" | "writing";
73
+ /** The steps of a conversion, in order. */
74
+ export declare const CONVERT_STAGES: readonly ["matching", "loading-profile", "merging", "writing"];
75
+ export type KnownConvertStage = (typeof CONVERT_STAGES)[number];
76
+ /** One of {@link CONVERT_STAGES}, or a step a later any2orca release added: a progress display can show one it doesn't recognize as it is. */
77
+ export type ConvertStage = KnownConvertStage | (string & {});
74
78
  /**
75
79
  * One filament slot of the converted file, in the file's own order. Every
76
80
  * filament is kept, however many: the U1 loads four at a time, but a project,
package/dist/project.js CHANGED
@@ -19,13 +19,15 @@ import { diffSettings } from "./diff/diffSettings.js";
19
19
  import { Any2orcaError } from "./errors.js";
20
20
  import { toWhatChanged } from "./explain/whatChanged.js";
21
21
  import { inspectProject } from "./inspect.js";
22
- import { loadCatalog, ProfileCatalog } from "./profiles.js";
22
+ import { catalogEngine, loadCatalog, ProfileCatalog } from "./profiles.js";
23
23
  import { ConvertRequestSchema, ConvertResponseSchema, HighFlowHotendsSchema, } from "./schema.js";
24
24
  import { resolveAboveStockChoice } from "./engine/aboveStock.js";
25
25
  import { presetFingerprint, resolvePreset } from "./presets/preset.js";
26
26
  import { encodeStamp, STAMP_PATH } from "./stamp.js";
27
27
  import { plainText } from "./plainText.js";
28
28
  import { VERSION } from "./version.js";
29
+ /** The steps of a conversion, in order. */
30
+ export const CONVERT_STAGES = ["matching", "loading-profile", "merging", "writing"];
29
31
  function numericLayerHeight(projectSettings) {
30
32
  const raw = projectSettings.layer_height;
31
33
  const value = typeof raw === "string" ? Number(raw.trim()) : typeof raw === "number" ? raw : NaN;
@@ -242,7 +244,7 @@ export class Project {
242
244
  routeWarnings.push(...choice.notes.map((note) => ` WARN: ${note}`));
243
245
  }
244
246
  progress("loading-profile");
245
- const loaded = await catalog.load(profileId);
247
+ const loaded = await catalogEngine(catalog).load(profileId);
246
248
  progress("merging");
247
249
  if (preset) {
248
250
  const sourceNozzle = detectNozzleDiameter(this.request.projectSettings);
package/dist/schema.d.ts CHANGED
@@ -16,7 +16,19 @@ export declare const ConvertObjectSchema: z.ZodObject<{
16
16
  bbox: z.ZodNullable<z.ZodTuple<[z.ZodNumber, z.ZodNumber, z.ZodNumber, z.ZodNumber], null>>;
17
17
  fallbackXy: z.ZodOptional<z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
18
18
  }, z.core.$strip>;
19
- export type ConvertObject = z.infer<typeof ConvertObjectSchema>;
19
+ /** A single top-level object's plate assignment and computed bounding box. */
20
+ export interface ConvertObject {
21
+ id: string;
22
+ name?: string;
23
+ sequence?: number;
24
+ isAssembly?: boolean;
25
+ /** Omitted for objects with no plate metadata. */
26
+ plate?: number;
27
+ /** [minX, maxX, minY, maxY], or null when no mesh geometry was found for this object. */
28
+ bbox: [number, number, number, number] | null;
29
+ /** The item transform's raw translation, set only when bbox is null. */
30
+ fallbackXy?: [number, number];
31
+ }
20
32
  /**
21
33
  * A parsed Metadata/project_settings.config: hundreds of slicer settings,
22
34
  * so open-shaped by key, with a cap on its serialized size. A real one runs
@@ -33,7 +45,8 @@ export declare const FilamentComplianceModeSchema: z.ZodEnum<{
33
45
  }>;
34
46
  /** `true` for every toolhead, or exactly one entry per U1 toolhead, T1 to T4. */
35
47
  export declare const HighFlowHotendsSchema: z.ZodUnion<readonly [z.ZodBoolean, z.ZodArray<z.ZodBoolean>]>;
36
- export type HighFlowHotends = z.infer<typeof HighFlowHotendsSchema>;
48
+ /** `true` for every toolhead, or exactly one entry per U1 toolhead, T1 to T4. */
49
+ export type HighFlowHotends = boolean | boolean[];
37
50
  export declare const ConvertRequestSchema: z.ZodObject<{
38
51
  projectSettings: z.ZodRecord<z.ZodString, z.ZodUnknown>;
39
52
  objects: z.ZodArray<z.ZodObject<{
@@ -60,14 +73,19 @@ export declare const ConfigFilesSchema: z.ZodRecord<z.ZodString, z.ZodRecord<z.Z
60
73
  export type ConfigFiles = z.infer<typeof ConfigFilesSchema>;
61
74
  /** objectId -> [dx, dy] shift to apply to that object's transform. */
62
75
  export declare const ShiftsSchema: z.ZodRecord<z.ZodString, z.ZodTuple<[z.ZodNumber, z.ZodNumber], null>>;
63
- export type Shifts = z.infer<typeof ShiftsSchema>;
76
+ /** objectId -> [dx, dy] shift to apply to that object's transform. */
77
+ export type Shifts = Record<string, [number, number]>;
78
+ /** How a profile was picked, most confident first. */
79
+ export declare const MATCH_SOURCES: readonly ["auto-tier-name", "auto-exact", "auto-nearest", "default-fallback"];
64
80
  export declare const MatchSourceSchema: z.ZodEnum<{
65
81
  "auto-tier-name": "auto-tier-name";
66
82
  "auto-exact": "auto-exact";
67
83
  "auto-nearest": "auto-nearest";
68
84
  "default-fallback": "default-fallback";
69
85
  }>;
70
- export type MatchSource = z.infer<typeof MatchSourceSchema>;
86
+ export type KnownMatchSource = (typeof MATCH_SOURCES)[number];
87
+ /** One of {@link MATCH_SOURCES}, or a way a later any2orca release added: treat one you don't recognize like "auto-nearest". */
88
+ export type MatchSource = KnownMatchSource | (string & {});
71
89
  export declare const ProfileMatchSchema: z.ZodObject<{
72
90
  profileId: z.ZodString;
73
91
  nozzleDiameter: z.ZodString;
@@ -80,7 +98,16 @@ export declare const ProfileMatchSchema: z.ZodObject<{
80
98
  "default-fallback": "default-fallback";
81
99
  }>;
82
100
  }, z.core.$strip>;
83
- export type ProfileMatch = z.infer<typeof ProfileMatchSchema>;
101
+ /** How the profile for a conversion was chosen. */
102
+ export interface ProfileMatch {
103
+ profileId: string;
104
+ nozzleDiameter: string;
105
+ exact: boolean;
106
+ /** The pick came from the source file's own tier name (e.g. "Extra Fine"), not nearest layer height. */
107
+ matchedByTierName: boolean;
108
+ /** See {@link MatchSource}: "auto-tier-name" and "auto-exact" are confident, "auto-nearest" the closest layer height, "default-fallback" no match at all. */
109
+ matchSource: MatchSource;
110
+ }
84
111
  export declare const ConvertResponseSchema: z.ZodObject<{
85
112
  projectSettings: z.ZodRecord<z.ZodString, z.ZodUnknown>;
86
113
  configFiles: z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodString, z.ZodUnknown>>;
package/dist/schema.js CHANGED
@@ -62,7 +62,9 @@ export const ConvertRequestSchema = z.object({
62
62
  export const ConfigFilesSchema = z.record(z.string(), z.record(z.string(), z.unknown()));
63
63
  /** objectId -> [dx, dy] shift to apply to that object's transform. */
64
64
  export const ShiftsSchema = z.record(z.string(), z.tuple([z.number(), z.number()]));
65
- export const MatchSourceSchema = z.enum(["auto-tier-name", "auto-exact", "auto-nearest", "default-fallback"]);
65
+ /** How a profile was picked, most confident first. */
66
+ export const MATCH_SOURCES = ["auto-tier-name", "auto-exact", "auto-nearest", "default-fallback"];
67
+ export const MatchSourceSchema = z.enum(MATCH_SOURCES);
66
68
  export const ProfileMatchSchema = z.object({
67
69
  profileId: z.string(),
68
70
  nozzleDiameter: z.string(),
@@ -1,4 +1,4 @@
1
- import type { ProfileCatalog } from "../../profiles.js";
1
+ import { type ProfileCatalog } from "../../profiles.js";
2
2
  import type { ProjectSettings } from "../../schema.js";
3
3
  import type { PrusaProjectInfo } from "../reader.js";
4
4
  import type { PrusaBundle } from "./bundle.js";
@@ -10,6 +10,7 @@
10
10
  * side. Filament values are carried whole, as for every source.
11
11
  */
12
12
  import { SETTINGS_CATALOG } from "../../diff/settingsCatalog.js";
13
+ import { catalogEngine } from "../../profiles.js";
13
14
  import { lookupPrintPresetName, resolvePrintPreset } from "./bundle.js";
14
15
  /** PrusaSlicer keys that identify or describe a preset, never a print setting a creator "changes". */
15
16
  const NOT_COMPARED = new Set(["print_settings_id", "inherits", "compatible_printers", "compatible_printers_condition", "renamed_from", "alias", "notes"]);
@@ -124,7 +125,7 @@ export async function applyPolicyB(prusa, catalog, projectSettings) {
124
125
  // the next bundle is tried, and the fallback carries every mapped print setting, with the note saying so.
125
126
  let bundle;
126
127
  try {
127
- bundle = await catalog.prusaBundle(entry.vendor, entry.slicerVersion);
128
+ bundle = await catalogEngine(catalog).prusaBundle(entry.vendor, entry.slicerVersion);
128
129
  }
129
130
  catch {
130
131
  bundle = null;
@@ -10,8 +10,11 @@
10
10
  * Readers are tried in order; the first whose `detect` says yes reads the file.
11
11
  */
12
12
  import type { ConvertRequest } from "../schema.js";
13
- /** The slicer family a project came from. */
14
- export type SourceFormat = "bambu-family" | "prusaslicer";
13
+ /** The file formats any2orca reads: Bambu Studio's and the slicers built on it, and PrusaSlicer's. */
14
+ export declare const SOURCE_FORMATS: readonly ["bambu-family", "prusaslicer"];
15
+ export type KnownSourceFormat = (typeof SOURCE_FORMATS)[number];
16
+ /** One of {@link SOURCE_FORMATS}, or a format a later any2orca release added. */
17
+ export type SourceFormat = KnownSourceFormat | (string & {});
15
18
  /**
16
19
  * What a PrusaSlicer project keeps for the step that needs profile data
17
20
  * (`convert()`, once the catalog is loaded): the project's settings in
@@ -1 +1,2 @@
1
- export {};
1
+ /** The file formats any2orca reads: Bambu Studio's and the slicers built on it, and PrusaSlicer's. */
2
+ export const SOURCE_FORMATS = ["bambu-family", "prusaslicer"];
package/dist/stamp.d.ts CHANGED
@@ -11,6 +11,8 @@
11
11
  */
12
12
  import "./zodSetup.js";
13
13
  import { z } from "zod";
14
+ import { type HighFlowHotends } from "./schema.js";
15
+ import { type SourceFormat } from "./sources/reader.js";
14
16
  export declare const STAMP_PATH = "Metadata/any2orca.json";
15
17
  /** What this version writes: exactly these fields. */
16
18
  export declare const OutputStampSchema: z.ZodObject<{
@@ -47,7 +49,44 @@ export declare const OutputStampSchema: z.ZodObject<{
47
49
  }, z.core.$strict>>;
48
50
  }, z.core.$strict>;
49
51
  }, z.core.$strict>;
50
- export type OutputStamp = z.infer<typeof OutputStampSchema>;
52
+ /** The preset a file was converted with: its base, the settings it set, and a fingerprint of their values. Never its name. */
53
+ export interface OutputStampPreset {
54
+ base: string;
55
+ keys: string[];
56
+ sha256: string;
57
+ }
58
+ /** The user's choices for values above stock: settings kept at the creator's value, and set to stock. */
59
+ export interface OutputStampAboveStock {
60
+ keep: string[];
61
+ stock: string[];
62
+ }
63
+ /** The stamp a converted file carries; `stamp` stays 1 as long as fields are only added. */
64
+ export interface OutputStamp {
65
+ stamp: 1;
66
+ generator: "any2orca";
67
+ /** The `any2orca` package version that converted the file. */
68
+ version: string;
69
+ profiles: {
70
+ /** The profile catalog's version (`any2orca-profiles` for the bundled one). */
71
+ version: string;
72
+ /** The upstream slicer release the catalog tracks, e.g. "Snapmaker Orca 2.4.0". */
73
+ tracks: string;
74
+ };
75
+ profileId: string;
76
+ /** The source project's format and the slicer version that saved it. Absent in files written before this field: the Bambu Studio family. */
77
+ source?: {
78
+ /** One of {@link SOURCE_FORMATS}, or a format a later any2orca release added. */
79
+ format: SourceFormat;
80
+ slicerVersion?: string;
81
+ };
82
+ options: {
83
+ highFlowHotends: HighFlowHotends;
84
+ hardenedNozzles: boolean;
85
+ filamentComplianceMode: "generic" | "snapmaker" | null;
86
+ preset?: OutputStampPreset;
87
+ aboveStock?: OutputStampAboveStock;
88
+ };
89
+ }
51
90
  export declare function encodeStamp(stamp: OutputStamp): Uint8Array;
52
91
  /** Reads the stamp from a converted file's zip entries, or null if it has none (or an unreadable one). */
53
92
  export declare function decodeStamp(bytes: Uint8Array | undefined): OutputStamp | null;
package/dist/stamp.js CHANGED
@@ -13,6 +13,7 @@
13
13
  import "./zodSetup.js";
14
14
  import { z } from "zod";
15
15
  import { HighFlowHotendsSchema } from "./schema.js";
16
+ import { SOURCE_FORMATS } from "./sources/reader.js";
16
17
  export const STAMP_PATH = "Metadata/any2orca.json";
17
18
  const AboveStockStampSchema = z
18
19
  .object({
@@ -46,7 +47,7 @@ export const OutputStampSchema = z
46
47
  /** The source project's format and the slicer version that saved it. Absent in files written before this field: the Bambu Studio family. */
47
48
  source: z
48
49
  .object({
49
- format: z.enum(["bambu-family", "prusaslicer"]),
50
+ format: z.enum(SOURCE_FORMATS),
50
51
  slicerVersion: z.string().max(64).optional(),
51
52
  })
52
53
  .strict()
@@ -77,8 +78,9 @@ const StampReadSchema = z.object({
77
78
  version: noteText(64),
78
79
  profiles: z.object({ version: noteText(64), tracks: noteText(200) }),
79
80
  profileId: noteText(64),
80
- // Added with the PrusaSlicer reader; absent means the Bambu Studio family.
81
- source: z.object({ format: z.enum(["bambu-family", "prusaslicer"]), slicerVersion: noteText(64).optional() }).optional(),
81
+ // Added with the PrusaSlicer reader; absent means the Bambu Studio family. Any short name, so a file from a later
82
+ // release with a format this one doesn't know still reads as stamped.
83
+ source: z.object({ format: z.string().regex(/^[a-z0-9-]{1,32}$/), slicerVersion: noteText(64).optional() }).optional(),
82
84
  options: z.object({
83
85
  highFlowHotends: HighFlowHotendsSchema,
84
86
  // Added after the first stamps were written; absent means the stock stainless nozzles.
@@ -14,9 +14,14 @@
14
14
  */
15
15
  import "./zodSetup.js";
16
16
  import { z } from "zod";
17
- import type { SourceVendor } from "./inspect.js";
18
- import type { ProfileMatch } from "./schema.js";
17
+ import { type SourceVendor } from "./inspect.js";
18
+ import { type ProfileMatch } from "./schema.js";
19
19
  export declare const REF_PATTERN: RegExp;
20
+ /** How the profile was chosen, as the event says it: "explicit" for a profile the user picked, else the match source. */
21
+ export declare const STATS_MATCH_SOURCES: readonly ["explicit", "auto-tier-name", "auto-exact", "auto-nearest", "default-fallback"];
22
+ export type KnownStatsMatchSource = (typeof STATS_MATCH_SOURCES)[number];
23
+ /** One of {@link STATS_MATCH_SOURCES}, or "other" in a collector for a way a later any2orca release added. */
24
+ export type StatsMatchSource = KnownStatsMatchSource | (string & {});
20
25
  export declare const StatsEventSchema: z.ZodObject<{
21
26
  v: z.ZodLiteral<1>;
22
27
  core: z.ZodString;
@@ -45,7 +50,35 @@ export declare const StatsEventSchema: z.ZodObject<{
45
50
  ref: z.ZodOptional<z.ZodString>;
46
51
  day: z.ZodString;
47
52
  }, z.core.$strict>;
48
- export type StatsEvent = z.infer<typeof StatsEventSchema>;
53
+ /** The one event, exactly as sent. `any2orca telemetry show` prints each field's meaning. */
54
+ export interface StatsEvent {
55
+ /** Event format version. */
56
+ v: 1;
57
+ /** The any2orca version that converted the file. */
58
+ core: string;
59
+ /** The profile used, e.g. "snapmaker-u1-0.4-standard". */
60
+ profileId: string;
61
+ matchSource: StatsMatchSource;
62
+ plates: number;
63
+ objects: number;
64
+ filamentSlots: number;
65
+ /** The printer maker the source file was set up for. */
66
+ sourceVendor: SourceVendor;
67
+ /** Which site sent the user, if it said so: a short slug, never free text. */
68
+ ref?: string;
69
+ /** The UTC date of the conversion, no time of day. */
70
+ day: string;
71
+ }
72
+ /** The event a sender may send: exactly the known fields and values, else null. What `any2orca telemetry show` prints. */
73
+ export declare function parseStatsEvent(value: unknown): StatsEvent | null;
74
+ /**
75
+ * The event as a collector should store it, else null. A sender a release or
76
+ * two newer than the collector may name a maker or a way of matching the
77
+ * collector doesn't know yet; those are stored as "other", so the conversion
78
+ * is still counted, and nothing outside the known lists is ever stored.
79
+ * Any other field, and any value that isn't a short lowercase name, is refused.
80
+ */
81
+ export declare function receiveStatsEvent(value: unknown): StatsEvent | null;
49
82
  /** What is never sent, for the "see exactly what's sent" display. */
50
83
  export declare const NEVER_SENT: readonly string[];
51
84
  export interface StatsEventInput {
package/dist/telemetry.js CHANGED
@@ -15,8 +15,14 @@
15
15
  */
16
16
  import "./zodSetup.js";
17
17
  import { z } from "zod";
18
+ import { SOURCE_VENDORS } from "./inspect.js";
19
+ import { MATCH_SOURCES } from "./schema.js";
18
20
  import { VERSION } from "./version.js";
19
21
  export const REF_PATTERN = /^[a-zA-Z0-9_-]{1,64}$/;
22
+ /** How the profile was chosen, as the event says it: "explicit" for a profile the user picked, else the match source. */
23
+ export const STATS_MATCH_SOURCES = ["explicit", ...MATCH_SOURCES];
24
+ /** A maker or match-source name as a collector accepts it: short and lowercase, so it can never carry free text. */
25
+ const SHORT_NAME = /^[a-z0-9-]{1,32}$/;
20
26
  export const StatsEventSchema = z
21
27
  .object({
22
28
  v: z.literal(1).describe("event format version"),
@@ -28,15 +34,11 @@ export const StatsEventSchema = z
28
34
  .string()
29
35
  .regex(/^[a-z0-9][a-z0-9.-]{0,63}$/)
30
36
  .describe('the profile used, e.g. "snapmaker-u1-0.4-standard"'),
31
- matchSource: z
32
- .enum(["explicit", "auto-tier-name", "auto-exact", "auto-nearest", "default-fallback"])
33
- .describe("how the profile was chosen"),
37
+ matchSource: z.enum(STATS_MATCH_SOURCES).describe("how the profile was chosen"),
34
38
  plates: z.number().int().min(0).max(10_000).describe("number of plates"),
35
39
  objects: z.number().int().min(0).max(10_000).describe("number of objects"),
36
40
  filamentSlots: z.number().int().min(0).max(1_000).describe("number of filament slots"),
37
- sourceVendor: z
38
- .enum(["bambu", "creality", "anycubic", "snapmaker", "elegoo", "prusa", "flashforge", "qidi", "other"])
39
- .describe("the printer maker the source file was set up for"),
41
+ sourceVendor: z.enum(SOURCE_VENDORS).describe("the printer maker the source file was set up for"),
40
42
  ref: z.string().regex(REF_PATTERN).optional().describe("which site sent you here, if it said so (a short slug, never free text)"),
41
43
  day: z
42
44
  .string()
@@ -44,6 +46,30 @@ export const StatsEventSchema = z
44
46
  .describe("the UTC date of the conversion (no time of day)"),
45
47
  })
46
48
  .strict();
49
+ /** The event a sender may send: exactly the known fields and values, else null. What `any2orca telemetry show` prints. */
50
+ export function parseStatsEvent(value) {
51
+ const parsed = StatsEventSchema.safeParse(value);
52
+ return parsed.success ? parsed.data : null;
53
+ }
54
+ /** What a collector accepts: the sender's event, with any short lowercase name in the maker and match-source fields. */
55
+ const StatsReceiveSchema = StatsEventSchema.extend({
56
+ matchSource: z.string().regex(SHORT_NAME),
57
+ sourceVendor: z.string().regex(SHORT_NAME),
58
+ }).strict();
59
+ /**
60
+ * The event as a collector should store it, else null. A sender a release or
61
+ * two newer than the collector may name a maker or a way of matching the
62
+ * collector doesn't know yet; those are stored as "other", so the conversion
63
+ * is still counted, and nothing outside the known lists is ever stored.
64
+ * Any other field, and any value that isn't a short lowercase name, is refused.
65
+ */
66
+ export function receiveStatsEvent(value) {
67
+ const parsed = StatsReceiveSchema.safeParse(value);
68
+ if (!parsed.success)
69
+ return null;
70
+ const known = (list, name) => (list.includes(name) ? name : "other");
71
+ return { ...parsed.data, sourceVendor: known(SOURCE_VENDORS, parsed.data.sourceVendor), matchSource: known(STATS_MATCH_SOURCES, parsed.data.matchSource) };
72
+ }
47
73
  /** What is never sent, for the "see exactly what's sent" display. */
48
74
  export const NEVER_SENT = [
49
75
  "your file, or any part of it (no geometry, no settings values)",
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.8.0";
1
+ export declare const VERSION = "0.9.0";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // SPDX-License-Identifier: MIT
2
2
  // Written by scripts/sync-version.mjs from package.json; a test checks they match.
3
- export const VERSION = "0.8.0";
3
+ export const VERSION = "0.9.0";
@@ -12,7 +12,7 @@
12
12
  * MAX_OPEN_PROJECTS are kept; opening more closes the oldest.
13
13
  */
14
14
  import { diffSettings } from "./diff/diffSettings.js";
15
- import { diffReference, presetDiffSide } from "./diff/reference.js";
15
+ import { diffReference, presetDiffSide, stockDiffSide } from "./diff/reference.js";
16
16
  import { Any2orcaError } from "./errors.js";
17
17
  import { extractPreset } from "./presets/extractPreset.js";
18
18
  import { resolvePreset } from "./presets/preset.js";
@@ -100,8 +100,7 @@ async function handle(request) {
100
100
  return presetDiffSide(s.preset, catalog);
101
101
  }
102
102
  if (typeof s === "object" && s !== null && "stock" in s && typeof s.stock === "string") {
103
- const loaded = await catalog.load(s.stock);
104
- return { label: `Snapmaker's stock ${loaded.summary.displayName} profile`, settings: loaded.convertProfile.profile.baselineProjectSettings, profileId: loaded.summary.id };
103
+ return stockDiffSide(s.stock, catalog);
105
104
  }
106
105
  const { handle: h, label } = (s ?? {});
107
106
  const project = requireProject(h);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "any2orca",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio, QIDI Studio and PrusaSlicer 3MF projects for the Snapmaker U1 (Snapmaker Orca), entirely on your own machine. Library, CLI and Web Worker in one package.",
5
5
  "keywords": [
6
6
  "3mf",
@@ -62,7 +62,8 @@
62
62
  "typecheck": "tsc -p tsconfig.json --noEmit",
63
63
  "test": "vitest run",
64
64
  "build": "node scripts/build.mjs",
65
- "docs": "typedoc"
65
+ "docs": "typedoc",
66
+ "api": "node scripts/api-report.mjs"
66
67
  },
67
68
  "dependencies": {
68
69
  "any2orca-profiles": "0.3.1",
@@ -70,6 +71,7 @@
70
71
  "zod": "4.6.7"
71
72
  },
72
73
  "devDependencies": {
74
+ "@microsoft/api-extractor": "7.59.4",
73
75
  "@types/node": "22.20.1",
74
76
  "typedoc": "0.28.20",
75
77
  "typescript": "5.9.3",