any2orca 0.9.1 → 0.10.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 +16 -0
- package/README.md +2 -2
- package/dist/cli/commands/convert.js +4 -8
- package/dist/cli/main.js +6 -49
- package/dist/cli/surface.d.ts +353 -0
- package/dist/cli/surface.js +73 -0
- package/dist/diff/settingLimits.d.ts +12 -0
- package/dist/diff/settingLimits.js +37 -0
- package/dist/diff/settingsCatalog.d.ts +12 -2
- package/dist/diff/settingsCatalog.js +18 -4
- package/dist/engine/applyFilamentComplianceMode.d.ts +9 -1
- package/dist/engine/applyFilamentComplianceMode.js +17 -5
- package/dist/engine/applyFilamentPresets.d.ts +29 -0
- package/dist/engine/applyFilamentPresets.js +84 -0
- package/dist/engine/buildProjectSettings.d.ts +3 -1
- package/dist/engine/buildProjectSettings.js +10 -6
- package/dist/engine/runConvertPipeline.d.ts +5 -0
- package/dist/engine/runConvertPipeline.js +32 -3
- package/dist/explain/filamentNotes.d.ts +7 -0
- package/dist/explain/filamentNotes.js +60 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/node.js +2 -1
- package/dist/presets/extractPreset.js +1 -1
- package/dist/presets/preset.d.ts +1 -1
- package/dist/presets/preset.js +15 -13
- package/dist/profiles.d.ts +32 -0
- package/dist/profiles.js +42 -4
- package/dist/project.d.ts +19 -0
- package/dist/project.js +5 -1
- package/dist/schema.d.ts +9 -0
- package/dist/schema.js +3 -0
- package/dist/sources/prusa/convertSettings.js +3 -1
- package/dist/version.js +1 -1
- package/package.json +4 -3
|
@@ -11,10 +11,10 @@ export interface SettingInfo {
|
|
|
11
11
|
readonly order: number | null;
|
|
12
12
|
/** Snapmaker Orca's value type, for example "coFloat", "coFloats", "coPercent", "coBool", "coEnum", "coString". */
|
|
13
13
|
readonly type: string | null;
|
|
14
|
-
/** The smallest and largest value
|
|
14
|
+
/** The smallest and largest value the newest supported release accepts, where it declares one (settingLimits gives another release's). */
|
|
15
15
|
readonly min: number | null;
|
|
16
16
|
readonly max: number | null;
|
|
17
|
-
/** The values
|
|
17
|
+
/** The values the newest supported release accepts for a setting with a fixed set of choices. */
|
|
18
18
|
readonly choices: readonly string[] | null;
|
|
19
19
|
}
|
|
20
20
|
/** Every setting in Snapmaker Orca's print, filament and printer presets, by key. */
|
|
@@ -26,3 +26,13 @@ export declare const SETTINGS_CATALOG_SOURCE: {
|
|
|
26
26
|
readonly tag: "v2.4.1";
|
|
27
27
|
readonly commit: "bac6fd5c1e1c23ddf057cf6471ba4ed7ed621c4c";
|
|
28
28
|
};
|
|
29
|
+
/** For each older supported release, the limits and choice lists it accepts differently from the newest. */
|
|
30
|
+
export declare const OLDER_RELEASE_LIMITS: {
|
|
31
|
+
readonly [release: string]: {
|
|
32
|
+
readonly [key: string]: {
|
|
33
|
+
readonly min?: number | null;
|
|
34
|
+
readonly max?: number | null;
|
|
35
|
+
readonly choices?: readonly string[] | null;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
|
-
// Generated from Snapmaker/OrcaSlicer v2.4.1 (bac6fd5c1e1c23ddf057cf6471ba4ed7ed621c4c)
|
|
3
|
-
//
|
|
2
|
+
// Generated from Snapmaker/OrcaSlicer v2.4.1 (bac6fd5c1e1c23ddf057cf6471ba4ed7ed621c4c), the newest supported release;
|
|
3
|
+
// OLDER_RELEASE_LIMITS holds what each older supported release (2.4.0) accepts differently.
|
|
4
4
|
// Generated by the maintainers from that release; please open an issue instead of editing it by hand.
|
|
5
5
|
/** Every setting in Snapmaker Orca's print, filament and printer presets, by key. */
|
|
6
6
|
export const SETTINGS_CATALOG = Object.freeze({
|
|
@@ -36,7 +36,7 @@ export const SETTINGS_CATALOG = Object.freeze({
|
|
|
36
36
|
"bottom_surface_pattern": { group: "print", label: "Bottom surface pattern", page: "Strength", section: "Top/bottom shells", order: 92, type: "coEnum", min: null, max: null, choices: null },
|
|
37
37
|
"bridge_acceleration": { group: "print", label: "Bridge", page: "Speed", section: "Acceleration", order: 157, type: "coFloatsOrPercents", min: 0, max: null, choices: null },
|
|
38
38
|
"bridge_angle": { group: "print", label: "External bridge infill direction", page: "Strength", section: "Advanced", order: 123, type: "coFloat", min: 0, max: null, choices: null },
|
|
39
|
-
"bridge_density": { group: "print", label: "External bridge density", page: "Quality", section: "Bridging", order: 70, type: "coPercent", min: 10, max:
|
|
39
|
+
"bridge_density": { group: "print", label: "External bridge density", page: "Quality", section: "Bridging", order: 70, type: "coPercent", min: 10, max: 120, choices: null },
|
|
40
40
|
"bridge_flow": { group: "print", label: "Bridge flow ratio", page: "Quality", section: "Bridging", order: 68, type: "coFloat", min: 0, max: 2, choices: null },
|
|
41
41
|
"bridge_no_support": { group: "print", label: "Don't support bridges", page: "Support", section: "Advanced", order: 214, type: "coBool", min: null, max: null, choices: null },
|
|
42
42
|
"bridge_speed": { group: "print", label: "External", page: "Speed", section: "Overhang speed", order: 151, type: "coFloats", min: 1, max: null, choices: null },
|
|
@@ -394,7 +394,7 @@ export const SETTINGS_CATALOG = Object.freeze({
|
|
|
394
394
|
"raft_contact_distance": { group: "print", label: "Raft contact Z distance", page: "Support", section: "Raft", order: 190, type: "coFloat", min: 0, max: null, choices: null },
|
|
395
395
|
"raft_expansion": { group: "print", label: "Raft expansion", page: "Support", section: null, order: null, type: "coFloat", min: 0, max: null, choices: null },
|
|
396
396
|
"raft_first_layer_density": { group: "print", label: "Initial layer density", page: "Support", section: "Support", order: 183, type: "coPercent", min: 10, max: 100, choices: null },
|
|
397
|
-
"raft_first_layer_expansion": { group: "print", label: "Initial layer expansion", page: "Support", section: "Support", order: 184, type: "coFloat", min:
|
|
397
|
+
"raft_first_layer_expansion": { group: "print", label: "Initial layer expansion", page: "Support", section: "Support", order: 184, type: "coFloat", min: -1, max: null, choices: null },
|
|
398
398
|
"raft_layers": { group: "print", label: "Raft layers", page: "Support", section: "Raft", order: 189, type: "coInt", min: 0, max: 100, choices: null },
|
|
399
399
|
"ramming_line_width_ratio": { group: "machine", label: "Ramming line width ratio", page: "Multimaterial", section: "Wipe tower", order: 459, type: "coFloat", min: null, max: null, choices: null },
|
|
400
400
|
"ramming_pressure_advance_value": { group: "machine", label: "Pressure advance value when ramming", page: "Multimaterial", section: "Wipe tower", order: 461, type: "coFloat", min: null, max: null, choices: null },
|
|
@@ -620,3 +620,17 @@ export const SETTINGS_CATALOG = Object.freeze({
|
|
|
620
620
|
});
|
|
621
621
|
/** The Snapmaker Orca release the catalog was generated from. */
|
|
622
622
|
export const SETTINGS_CATALOG_SOURCE = { "tag": "v2.4.1", "commit": "bac6fd5c1e1c23ddf057cf6471ba4ed7ed621c4c" };
|
|
623
|
+
/** For each older supported release, the limits and choice lists it accepts differently from the newest. */
|
|
624
|
+
export const OLDER_RELEASE_LIMITS = Object.freeze({
|
|
625
|
+
"2.4.0": {
|
|
626
|
+
"bridge_density": {
|
|
627
|
+
"max": 100
|
|
628
|
+
},
|
|
629
|
+
"raft_first_layer_expansion": {
|
|
630
|
+
"min": 0
|
|
631
|
+
},
|
|
632
|
+
"support_threshold_angle": {
|
|
633
|
+
"min": 0
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { FilamentSlot } from "./extractFilamentSlots.js";
|
|
2
|
+
import type { PrinterFilamentPresets } from "../profiles.js";
|
|
3
|
+
import { type AppliedFilamentPreset } from "./applyFilamentPresets.js";
|
|
2
4
|
import { type FilamentComplianceMode, type FilamentNameTable } from "./filamentComplianceNames.js";
|
|
3
5
|
export interface RenamedFilament {
|
|
4
6
|
/** 0-based slot index. */
|
|
@@ -15,6 +17,10 @@ export interface ApplyFilamentComplianceModeResult {
|
|
|
15
17
|
unchangedMaterials: string[];
|
|
16
18
|
/** Each slot whose name changed. */
|
|
17
19
|
renamed: RenamedFilament[];
|
|
20
|
+
/** Each slot that takes its preset's settings (every slot a preset fits, renamed or already so named), with what that replaces. */
|
|
21
|
+
presets: AppliedFilamentPreset[];
|
|
22
|
+
/** Presets named whose settings the catalog's presets file doesn't have (with a file at all): those slots changed names only. */
|
|
23
|
+
missingPresets: string[];
|
|
18
24
|
}
|
|
19
25
|
/**
|
|
20
26
|
* Overrides each filament slot's identity with a real Generic/Snapmaker
|
|
@@ -37,4 +43,6 @@ export interface ApplyFilamentComplianceModeResult {
|
|
|
37
43
|
* @param table the profile catalog's `filamentNames`; without it every slot is left as it is and reported.
|
|
38
44
|
* @param printerId the target printer: names exist per nozzle size, so they follow the printer converted to, not the source.
|
|
39
45
|
*/
|
|
40
|
-
export declare function applyFilamentComplianceMode(slots: FilamentSlot[], filamentKeyArrays: Record<string, unknown[]> | null, mode: FilamentComplianceMode, table: FilamentNameTable | undefined, printerId: string
|
|
46
|
+
export declare function applyFilamentComplianceMode(slots: FilamentSlot[], filamentKeyArrays: Record<string, unknown[]> | null, mode: FilamentComplianceMode, table: FilamentNameTable | undefined, printerId: string,
|
|
47
|
+
/** The printer's presets' settings; without them only the names change. */
|
|
48
|
+
presets?: PrinterFilamentPresets): ApplyFilamentComplianceModeResult;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { presetChanges, presetSettingsFor } from "./applyFilamentPresets.js";
|
|
1
2
|
import { resolveFilamentName } from "./filamentComplianceNames.js";
|
|
2
3
|
/** The keys a saved project records a filament preset's identity in, one entry per slot. */
|
|
3
4
|
const IDENTITY_KEYS = ["filament_settings_id", "filament_ids", "filament_vendor"];
|
|
@@ -22,10 +23,14 @@ const IDENTITY_KEYS = ["filament_settings_id", "filament_ids", "filament_vendor"
|
|
|
22
23
|
* @param table the profile catalog's `filamentNames`; without it every slot is left as it is and reported.
|
|
23
24
|
* @param printerId the target printer: names exist per nozzle size, so they follow the printer converted to, not the source.
|
|
24
25
|
*/
|
|
25
|
-
export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, table, printerId
|
|
26
|
+
export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, table, printerId,
|
|
27
|
+
/** The printer's presets' settings; without them only the names change. */
|
|
28
|
+
presets) {
|
|
26
29
|
const fellBackToGeneric = new Set();
|
|
27
30
|
const unchanged = new Set();
|
|
28
31
|
const renamed = [];
|
|
32
|
+
const applied = [];
|
|
33
|
+
const missing = new Set();
|
|
29
34
|
const arrays = {};
|
|
30
35
|
for (const key of IDENTITY_KEYS)
|
|
31
36
|
if (filamentKeyArrays?.[key])
|
|
@@ -46,15 +51,20 @@ export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, tabl
|
|
|
46
51
|
fellBackToGeneric.add(result.line?.label ?? filamentType);
|
|
47
52
|
if (result.preset.name !== filamentSettingsId)
|
|
48
53
|
renamed.push({ slot: i, before: filamentSettingsId, after: result.preset.name });
|
|
49
|
-
const values =
|
|
54
|
+
const values = presetSettingsFor(presets, result.preset.name);
|
|
55
|
+
if (values)
|
|
56
|
+
applied.push({ slot: i, preset: result.preset.name, changed: presetChanges(values, (key) => filamentKeyArrays?.[key]?.[i] ?? slot[key]) });
|
|
57
|
+
else if (presets)
|
|
58
|
+
missing.add(result.preset.name);
|
|
59
|
+
const identity = { filament_settings_id: result.preset.name, filament_ids: result.preset.id, filament_vendor: result.preset.vendor };
|
|
50
60
|
for (const key of IDENTITY_KEYS) {
|
|
51
61
|
const list = arrays[key];
|
|
52
62
|
if (list && i < list.length)
|
|
53
|
-
list[i] =
|
|
63
|
+
list[i] = identity[key];
|
|
54
64
|
}
|
|
55
|
-
const next = { ...slot, filament_settings_id:
|
|
65
|
+
const next = { ...slot, filament_settings_id: identity.filament_settings_id, filament_vendor: identity.filament_vendor };
|
|
56
66
|
if (Object.hasOwn(slot, "filament_ids"))
|
|
57
|
-
next.filament_ids =
|
|
67
|
+
next.filament_ids = identity.filament_ids;
|
|
58
68
|
return next;
|
|
59
69
|
});
|
|
60
70
|
const newFilamentKeyArrays = filamentKeyArrays && Object.keys(arrays).length > 0 ? { ...filamentKeyArrays, ...arrays } : filamentKeyArrays;
|
|
@@ -64,5 +74,7 @@ export function applyFilamentComplianceMode(slots, filamentKeyArrays, mode, tabl
|
|
|
64
74
|
fellBackToGenericMaterials: [...fellBackToGeneric],
|
|
65
75
|
unchangedMaterials: [...unchanged],
|
|
66
76
|
renamed,
|
|
77
|
+
presets: applied,
|
|
78
|
+
missingPresets: [...missing],
|
|
67
79
|
};
|
|
68
80
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { PrinterFilamentPresets } from "../profiles.js";
|
|
2
|
+
import type { JsonRecord } from "./types.js";
|
|
3
|
+
/** A slot that takes a preset's settings: its 0-based index, the preset, and the creator's values it replaces. */
|
|
4
|
+
export interface AppliedFilamentPreset {
|
|
5
|
+
slot: number;
|
|
6
|
+
preset: string;
|
|
7
|
+
changed: Array<{
|
|
8
|
+
key: string;
|
|
9
|
+
before: string;
|
|
10
|
+
after: string;
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/** One preset's settings: the values the printer's presets share, with its own over them. Undefined when there are none. */
|
|
14
|
+
export declare function presetSettingsFor(presets: PrinterFilamentPresets | undefined, name: string): Record<string, string[]> | undefined;
|
|
15
|
+
/** What a slot's preset replaces: each setting whose standard value differs from the creator's. */
|
|
16
|
+
export declare function presetChanges(values: Record<string, string[]>, creator: (key: string) => unknown): AppliedFilamentPreset["changed"];
|
|
17
|
+
/**
|
|
18
|
+
* Writes each applied preset's settings into its slot: the project's per-filament lists (both values of a
|
|
19
|
+
* per-variant setting where the nozzle has a high-flow option) and the slot's embedded preset file. Runs after
|
|
20
|
+
* every other filament step, so nothing later overwrites it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function writeFilamentPresets(settings: JsonRecord, files: Record<string, JsonRecord>, applied: readonly AppliedFilamentPreset[], presets: PrinterFilamentPresets | undefined, slotCount: number): void;
|
|
23
|
+
/**
|
|
24
|
+
* Every filament's entry in `different_settings_to_system` lists every filament setting the project holds.
|
|
25
|
+
* Snapmaker Orca resets a filament whose name matches one of its presets to that preset's values for every
|
|
26
|
+
* setting its entry doesn't list (PresetBundle.cpp adds a few bookkeeping keys to each entry, so the reset
|
|
27
|
+
* always runs); listing them all keeps the file's values, the creator's or the chosen preset's.
|
|
28
|
+
*/
|
|
29
|
+
export declare function listFilamentSettings(settings: JsonRecord, filamentCount: number): void;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* The Snapmaker and Generic filament options: a slot renamed to a preset Snapmaker Orca ships takes that
|
|
4
|
+
* preset's own settings, standard and high-flow values and its G-code included, so the file, Snapmaker Orca's
|
|
5
|
+
* app (which resets a filament whose name matches a shipped preset) and its command line (which uses the file's
|
|
6
|
+
* values) all agree. And every filament's entry in `different_settings_to_system` lists every filament setting,
|
|
7
|
+
* so Snapmaker Orca keeps what the file says when it opens it, the creator's values under Original included.
|
|
8
|
+
*/
|
|
9
|
+
import { SETTINGS_CATALOG } from "../diff/settingsCatalog.js";
|
|
10
|
+
import { FILAMENT_FLOW_VARIANT_KEYS } from "./applyFilamentFlowVariants.js";
|
|
11
|
+
const VARIANT_KEYS = new Set(FILAMENT_FLOW_VARIANT_KEYS);
|
|
12
|
+
/** One preset's settings: the values the printer's presets share, with its own over them. Undefined when there are none. */
|
|
13
|
+
export function presetSettingsFor(presets, name) {
|
|
14
|
+
if (!presets || !Object.hasOwn(presets.presets, name))
|
|
15
|
+
return undefined;
|
|
16
|
+
return { ...presets.shared, ...presets.presets[name] };
|
|
17
|
+
}
|
|
18
|
+
const first = (value) => (Array.isArray(value) ? (value[0] === undefined ? undefined : String(value[0])) : value === undefined ? undefined : String(value));
|
|
19
|
+
/** What a slot's preset replaces: each setting whose standard value differs from the creator's. */
|
|
20
|
+
export function presetChanges(values, creator) {
|
|
21
|
+
const out = [];
|
|
22
|
+
for (const key of Object.keys(values).sort()) {
|
|
23
|
+
const before = first(creator(key));
|
|
24
|
+
const after = values[key][0];
|
|
25
|
+
if (before !== undefined && after !== undefined && before !== after)
|
|
26
|
+
out.push({ key, before, after });
|
|
27
|
+
}
|
|
28
|
+
return out;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Writes each applied preset's settings into its slot: the project's per-filament lists (both values of a
|
|
32
|
+
* per-variant setting where the nozzle has a high-flow option) and the slot's embedded preset file. Runs after
|
|
33
|
+
* every other filament step, so nothing later overwrites it.
|
|
34
|
+
*/
|
|
35
|
+
export function writeFilamentPresets(settings, files, applied, presets, slotCount) {
|
|
36
|
+
for (const { slot, preset } of applied) {
|
|
37
|
+
const values = presetSettingsFor(presets, preset);
|
|
38
|
+
if (!values)
|
|
39
|
+
continue;
|
|
40
|
+
for (const [key, value] of Object.entries(values)) {
|
|
41
|
+
const list = settings[key];
|
|
42
|
+
if (!Array.isArray(list))
|
|
43
|
+
continue;
|
|
44
|
+
const next = [...list];
|
|
45
|
+
if (VARIANT_KEYS.has(key) && next.length === slotCount * 2) {
|
|
46
|
+
next[slot * 2] = value[0];
|
|
47
|
+
next[slot * 2 + 1] = value[1] ?? value[0];
|
|
48
|
+
}
|
|
49
|
+
else if (next.length === slotCount) {
|
|
50
|
+
next[slot] = value[0];
|
|
51
|
+
}
|
|
52
|
+
else
|
|
53
|
+
continue;
|
|
54
|
+
settings[key] = next;
|
|
55
|
+
}
|
|
56
|
+
for (const cfg of Object.values(files)) {
|
|
57
|
+
if (cfg.name !== preset)
|
|
58
|
+
continue;
|
|
59
|
+
for (const [key, value] of Object.entries(values)) {
|
|
60
|
+
const own = cfg[key];
|
|
61
|
+
// The embedded preset keeps its layout: one value where it holds one, the preset's own list otherwise.
|
|
62
|
+
cfg[key] = Array.isArray(own) && own.length === 1 ? [value[0]] : [...value];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Every filament's entry in `different_settings_to_system` lists every filament setting the project holds.
|
|
69
|
+
* Snapmaker Orca resets a filament whose name matches one of its presets to that preset's values for every
|
|
70
|
+
* setting its entry doesn't list (PresetBundle.cpp adds a few bookkeeping keys to each entry, so the reset
|
|
71
|
+
* always runs); listing them all keeps the file's values, the creator's or the chosen preset's.
|
|
72
|
+
*/
|
|
73
|
+
export function listFilamentSettings(settings, filamentCount) {
|
|
74
|
+
if (filamentCount < 1)
|
|
75
|
+
return;
|
|
76
|
+
const keys = Object.keys(settings)
|
|
77
|
+
.filter((k) => Object.hasOwn(SETTINGS_CATALOG, k) && SETTINGS_CATALOG[k].group === "filament")
|
|
78
|
+
.sort()
|
|
79
|
+
.join(";");
|
|
80
|
+
const current = Array.isArray(settings.different_settings_to_system) ? settings.different_settings_to_system : [];
|
|
81
|
+
const print = typeof current[0] === "string" ? current[0] : "";
|
|
82
|
+
const printer = current.length === filamentCount + 2 && typeof current[filamentCount + 1] === "string" ? current[filamentCount + 1] : "";
|
|
83
|
+
settings.different_settings_to_system = [print, ...Array.from({ length: filamentCount }, () => keys), printer];
|
|
84
|
+
}
|
|
@@ -21,4 +21,6 @@ export interface BuildProjectSettingsResult {
|
|
|
21
21
|
* @param minComparisonKeys travel_speed/`*_acceleration`-style motion-safety keys: honored only when Bambu's value is LOWER than the U1 profile's own default, unconditionally (not gated on customization) -- see that constant's own doc comment.
|
|
22
22
|
* @param alwaysTransferKeys keys that always track Bambu's real value, unconditionally (not gated on customization, no min-comparison either) -- e.g. print_sequence (layout-coupled) and the infill-density family (Bambu's customization flag doesn't reliably cover them) -- see that constant's own doc comment.
|
|
23
23
|
*/
|
|
24
|
-
export declare function buildProjectSettings(baselineSettings: JsonRecord, bambuSettings: JsonRecord, filamentKeyArrays: Record<string, unknown[]> | null, blocklist: ReadonlySet<string>, minComparisonKeys: ReadonlySet<string>, alwaysTransferKeys: ReadonlySet<string>, warnings: string[]
|
|
24
|
+
export declare function buildProjectSettings(baselineSettings: JsonRecord, bambuSettings: JsonRecord, filamentKeyArrays: Record<string, unknown[]> | null, blocklist: ReadonlySet<string>, minComparisonKeys: ReadonlySet<string>, alwaysTransferKeys: ReadonlySet<string>, warnings: string[],
|
|
25
|
+
/** The Snapmaker Orca release the file is for: a choice is checked against what it offers. Absent: the newest. */
|
|
26
|
+
release?: string): BuildProjectSettingsResult;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// SPDX-License-Identifier: MIT
|
|
2
2
|
import { FLOW_LAYOUT_KEYS } from "./applyFilamentFlowVariants.js";
|
|
3
|
+
import { settingLimits } from "../diff/settingLimits.js";
|
|
3
4
|
import { SETTINGS_CATALOG } from "../diff/settingsCatalog.js";
|
|
4
5
|
import { coerceValue } from "./coerceValue.js";
|
|
5
6
|
import { collapseNozzleVariants } from "./collapseNozzleVariants.js";
|
|
@@ -18,13 +19,14 @@ function parseDifferentSettingsToSystem(value) {
|
|
|
18
19
|
// Older option names Snapmaker Orca still reads and translates itself (Bambu Studio's infill and ironing "zig-zag").
|
|
19
20
|
const LEGACY_CHOICES = new Set(["zig-zag"]);
|
|
20
21
|
/** For a setting with a fixed set of choices, the first value that isn't one Snapmaker Orca offers, if any. */
|
|
21
|
-
function unknownChoice(key, value) {
|
|
22
|
+
function unknownChoice(key, value, release) {
|
|
22
23
|
const info = Object.hasOwn(SETTINGS_CATALOG, key) ? SETTINGS_CATALOG[key] : undefined;
|
|
23
|
-
|
|
24
|
+
const choices = settingLimits(key, release)?.choices;
|
|
25
|
+
if (!info || info.type !== "coEnum" || !choices)
|
|
24
26
|
return null;
|
|
25
27
|
for (const entry of Array.isArray(value) ? value : [value]) {
|
|
26
28
|
const text = String(entry);
|
|
27
|
-
if (!
|
|
29
|
+
if (!choices.includes(text) && !LEGACY_CHOICES.has(text))
|
|
28
30
|
return text;
|
|
29
31
|
}
|
|
30
32
|
return null;
|
|
@@ -42,7 +44,9 @@ function unknownChoice(key, value) {
|
|
|
42
44
|
* @param minComparisonKeys travel_speed/`*_acceleration`-style motion-safety keys: honored only when Bambu's value is LOWER than the U1 profile's own default, unconditionally (not gated on customization) -- see that constant's own doc comment.
|
|
43
45
|
* @param alwaysTransferKeys keys that always track Bambu's real value, unconditionally (not gated on customization, no min-comparison either) -- e.g. print_sequence (layout-coupled) and the infill-density family (Bambu's customization flag doesn't reliably cover them) -- see that constant's own doc comment.
|
|
44
46
|
*/
|
|
45
|
-
export function buildProjectSettings(baselineSettings, bambuSettings, filamentKeyArrays, blocklist, minComparisonKeys, alwaysTransferKeys, warnings
|
|
47
|
+
export function buildProjectSettings(baselineSettings, bambuSettings, filamentKeyArrays, blocklist, minComparisonKeys, alwaysTransferKeys, warnings,
|
|
48
|
+
/** The Snapmaker Orca release the file is for: a choice is checked against what it offers. Absent: the newest. */
|
|
49
|
+
release) {
|
|
46
50
|
// Bambu's OWN customized-keys signal (from the source file, before any
|
|
47
51
|
// of our merging) -- the creator explicitly touched these in Bambu
|
|
48
52
|
// Studio, as opposed to Bambu's file just incidentally reporting its
|
|
@@ -69,7 +73,7 @@ export function buildProjectSettings(baselineSettings, bambuSettings, filamentKe
|
|
|
69
73
|
const notCarried = [];
|
|
70
74
|
for (const key of transferable) {
|
|
71
75
|
const [newVal, changed, didNotFit] = coerceValue(baselineSettings[key], source[key], key, warnings, variantIndex);
|
|
72
|
-
const unknown = didNotFit ? null : unknownChoice(key, newVal);
|
|
76
|
+
const unknown = didNotFit ? null : unknownChoice(key, newVal, release);
|
|
73
77
|
if (unknown !== null) {
|
|
74
78
|
notCarried.push(key);
|
|
75
79
|
warnings.push(` WARN: the creator's ${key} ("${unknown.slice(0, 40)}") isn't one of Snapmaker Orca's choices, so Snapmaker's stock value is used.`);
|
|
@@ -101,7 +105,7 @@ export function buildProjectSettings(baselineSettings, bambuSettings, filamentKe
|
|
|
101
105
|
const alwaysTransferApplicable = sharedKeys.filter((k) => alwaysTransferKeys.has(k) && !blocklist.has(k)).sort();
|
|
102
106
|
for (const key of alwaysTransferApplicable) {
|
|
103
107
|
const [newVal, changed] = coerceValue(baselineSettings[key], source[key], key, warnings, variantIndex);
|
|
104
|
-
const unknown = unknownChoice(key, newVal);
|
|
108
|
+
const unknown = unknownChoice(key, newVal, release);
|
|
105
109
|
if (unknown !== null) {
|
|
106
110
|
notCarried.push(key);
|
|
107
111
|
warnings.push(` WARN: the source file's ${key} ("${unknown.slice(0, 40)}") isn't one of Snapmaker Orca's choices, so Snapmaker's stock value is used.`);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ConvertRequest, ConvertResponse } from "../schema.js";
|
|
2
2
|
import type { FilamentNameTable } from "./filamentComplianceNames.js";
|
|
3
|
+
import type { PrinterFilamentPresets } from "../profiles.js";
|
|
3
4
|
import { type ResolvedAboveStockChoice } from "./aboveStock.js";
|
|
4
5
|
import type { JsonRecord } from "./types.js";
|
|
5
6
|
import { type ChangeItem, type ChangeReason } from "../explain/whatChanged.js";
|
|
@@ -18,8 +19,12 @@ export interface ConvertProfile {
|
|
|
18
19
|
highFlowSupported?: boolean;
|
|
19
20
|
/** The catalog's filament names for the Snapmaker/Generic naming options (index.json `filamentNames`). Absent: those options leave names as they are and say so. */
|
|
20
21
|
filamentNames?: FilamentNameTable;
|
|
22
|
+
/** The settings of this printer's filament presets, for the Snapmaker/Generic naming options; loaded only when one is used. Absent: those options change names only. */
|
|
23
|
+
filamentPresets?: PrinterFilamentPresets;
|
|
21
24
|
};
|
|
22
25
|
profile: {
|
|
26
|
+
/** The Snapmaker Orca release the profile is for, e.g. "2.4.1": what a value is checked against. Absent: the newest. */
|
|
27
|
+
release?: string;
|
|
23
28
|
id: string;
|
|
24
29
|
baselineProjectSettings: JsonRecord;
|
|
25
30
|
filamentShapeConfig: JsonRecord;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { applyFilamentComplianceMode } from "./applyFilamentComplianceMode.js";
|
|
2
|
+
import { labelOf } from "../diff/diffSettings.js";
|
|
3
|
+
import { listFilamentSettings, writeFilamentPresets } from "./applyFilamentPresets.js";
|
|
2
4
|
import { EXTRA_PROJECT_LEVEL_FILAMENT_KEYS } from "./constants.js";
|
|
3
5
|
import { buildFilamentConfigs } from "./buildFilamentConfigs.js";
|
|
4
6
|
import { clampColorPenetration } from "./clampColorPenetration.js";
|
|
@@ -64,12 +66,17 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
64
66
|
let filamentComplianceFallback;
|
|
65
67
|
let filamentComplianceUnchanged;
|
|
66
68
|
let renamedFilaments = [];
|
|
69
|
+
let appliedPresets = [];
|
|
67
70
|
if (request.filamentComplianceMode) {
|
|
68
71
|
// Preset names exist per nozzle size, so they follow the target printer, not the source's nozzle.
|
|
69
|
-
const applied = applyFilamentComplianceMode(slots, filamentKeyArrays, request.filamentComplianceMode, printer.filamentNames, printer.id);
|
|
72
|
+
const applied = applyFilamentComplianceMode(slots, filamentKeyArrays, request.filamentComplianceMode, printer.filamentNames, printer.id, printer.filamentPresets);
|
|
70
73
|
slots = applied.slots;
|
|
71
74
|
filamentKeyArrays = applied.filamentKeyArrays;
|
|
72
75
|
renamedFilaments = applied.renamed;
|
|
76
|
+
appliedPresets = applied.presets;
|
|
77
|
+
if (applied.missingPresets.length > 0) {
|
|
78
|
+
warnings.push(` WARN: the profile catalog has no settings for ${applied.missingPresets.join(", ")}, so only ${applied.missingPresets.length === 1 ? "its name" : "their names"} changed. Update the profile catalog.`);
|
|
79
|
+
}
|
|
73
80
|
if (applied.fellBackToGenericMaterials.length > 0)
|
|
74
81
|
filamentComplianceFallback = applied.fellBackToGenericMaterials;
|
|
75
82
|
if (applied.unchangedMaterials.length > 0)
|
|
@@ -77,6 +84,9 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
77
84
|
if (!printer.filamentNames) {
|
|
78
85
|
warnings.push(" WARN: this profile catalog has no filament names, so filament names were left as they are. Update the profile catalog.");
|
|
79
86
|
}
|
|
87
|
+
else if (!printer.filamentPresets) {
|
|
88
|
+
warnings.push(" WARN: this profile catalog has no filament preset settings, so only the filament names changed; Snapmaker Orca uses the presets' own settings when it opens the file. Update the profile catalog.");
|
|
89
|
+
}
|
|
80
90
|
}
|
|
81
91
|
const { files: filamentFiles } = buildFilamentConfigs(slots, p.filamentShapeConfig, p.filamentKeyBlocklist);
|
|
82
92
|
// High-flow hotends (request.highFlowHotends): which toolheads have the
|
|
@@ -107,7 +117,7 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
107
117
|
const useStock = options.aboveStock?.stock ?? new Set();
|
|
108
118
|
// Keeping the creator's acceleration or travel speed above stock: take it as it is, instead of only when lower.
|
|
109
119
|
const keptHigher = [...keep].filter((key) => p.minComparisonKeys.has(key));
|
|
110
|
-
const { newSettings: mergedSettings, notCarried } = buildProjectSettings(p.baselineProjectSettings, request.projectSettings, filamentKeyArrays, p.blocklist, keptHigher.length > 0 ? new Set([...p.minComparisonKeys].filter((key) => !keep.has(key))) : p.minComparisonKeys, keptHigher.length > 0 ? new Set([...p.alwaysTransferKeys, ...keptHigher]) : p.alwaysTransferKeys, warnings);
|
|
120
|
+
const { newSettings: mergedSettings, notCarried } = buildProjectSettings(p.baselineProjectSettings, request.projectSettings, filamentKeyArrays, p.blocklist, keptHigher.length > 0 ? new Set([...p.minComparisonKeys].filter((key) => !keep.has(key))) : p.minComparisonKeys, keptHigher.length > 0 ? new Set([...p.alwaysTransferKeys, ...keptHigher]) : p.alwaysTransferKeys, warnings, p.release);
|
|
111
121
|
// Filament settings are the creator's, carried as a whole; they're summarized in one line below.
|
|
112
122
|
tracker.compare(p.baselineProjectSettings, mergedSettings, (key) => {
|
|
113
123
|
if (filamentKeyArrays && Object.hasOwn(filamentKeyArrays, key))
|
|
@@ -132,14 +142,28 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
132
142
|
...(filamentComplianceFallback ? [`Generic for ${filamentComplianceFallback.join(", ")}`] : []),
|
|
133
143
|
...(filamentComplianceUnchanged ? [`kept the creator's name for ${filamentComplianceUnchanged.join(", ")} (no Snapmaker or Generic preset for this nozzle size)`] : []),
|
|
134
144
|
];
|
|
145
|
+
const kind = request.filamentComplianceMode === "generic" ? "Generic" : "Snapmaker";
|
|
135
146
|
tracker.add("yours", {
|
|
136
|
-
label:
|
|
147
|
+
label: printer.filamentPresets
|
|
148
|
+
? `Filaments set to ${kind} presets Snapmaker Orca ships, with those presets' own settings; colors and order kept`
|
|
149
|
+
: `Filament names relabeled to ${kind} presets (names only: this catalog has no preset settings)`,
|
|
137
150
|
before: null,
|
|
138
151
|
after: null,
|
|
139
152
|
...(notes.length > 0 ? { note: notes.join("; ") } : {}),
|
|
140
153
|
});
|
|
141
154
|
for (const r of renamedFilaments)
|
|
142
155
|
tracker.add("yours", { label: `Filament ${r.slot + 1} name`, before: r.before || null, after: r.after });
|
|
156
|
+
for (const a of appliedPresets) {
|
|
157
|
+
if (a.changed.length === 0)
|
|
158
|
+
continue;
|
|
159
|
+
const shown = a.changed.slice(0, 3).map((c) => `${labelOf(c.key)} ${c.before} -> ${c.after}`).join(", ");
|
|
160
|
+
tracker.add("yours", {
|
|
161
|
+
label: `Filament ${a.slot + 1} uses ${a.preset}'s settings`,
|
|
162
|
+
before: null,
|
|
163
|
+
after: null,
|
|
164
|
+
note: `instead of the creator's: ${shown}${a.changed.length > 3 ? ` and ${a.changed.length - 3} more` : ""}`,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
143
167
|
}
|
|
144
168
|
if (useStock.size > 0) {
|
|
145
169
|
tracker.step(mergedSettings, because("yours", "you chose Snapmaker's stock value"), () => {
|
|
@@ -202,6 +226,10 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
202
226
|
const { shifts, plateOrigins, warnings: shiftWarnings } = computeShifts(request.objects, printer.printableArea, Number.isFinite(bambuClearanceRadius) ? bambuClearanceRadius : null, printer.extruderClearanceRadius, request.plateCount);
|
|
203
227
|
warnings.push(...shiftWarnings);
|
|
204
228
|
addShiftItems(tracker, request.objects, shifts);
|
|
229
|
+
// Last of the filament steps: the chosen presets' settings, then every filament setting listed, so Snapmaker
|
|
230
|
+
// Orca keeps what the file says.
|
|
231
|
+
writeFilamentPresets(newSettings, filamentFiles, appliedPresets, printer.filamentPresets, slotCount);
|
|
232
|
+
listFilamentSettings(newSettings, slotCount);
|
|
205
233
|
const configFiles = { ...filamentFiles };
|
|
206
234
|
// `warnings` mixes routine per-conversion bookkeeping (e.g. computeShifts'
|
|
207
235
|
// "true geometric center -> target" line, which fires on every plate
|
|
@@ -220,6 +248,7 @@ export function runConvertPipeline(profile, request, application, options = {})
|
|
|
220
248
|
application,
|
|
221
249
|
...(filamentComplianceFallback ? { filamentComplianceFallback } : {}),
|
|
222
250
|
...(filamentComplianceUnchanged ? { filamentComplianceUnchanged } : {}),
|
|
251
|
+
...(appliedPresets.length > 0 ? { filamentPresets: appliedPresets.map((a) => ({ slot: a.slot + 1, preset: a.preset, changed: a.changed })) } : {}),
|
|
223
252
|
...(userFacingWarnings.length > 0 ? { warnings: userFacingWarnings } : {}),
|
|
224
253
|
},
|
|
225
254
|
warnings,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConvertReport } from "../project.js";
|
|
2
|
+
/**
|
|
3
|
+
* What the Snapmaker or Generic filament option did, one sentence per note: which filaments use a preset's own
|
|
4
|
+
* settings and what that replaced, which use Generic because Snapmaker makes no preset for them, and which kept
|
|
5
|
+
* the creator's name and settings because no preset fits. Empty when the option wasn't used or changed nothing.
|
|
6
|
+
*/
|
|
7
|
+
export declare function filamentNotes(report: Pick<ConvertReport, "filamentPresets" | "filamentComplianceFallback" | "filamentComplianceUnchanged">): string[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT
|
|
2
|
+
/**
|
|
3
|
+
* The filament naming options' notes for a conversion, in words: the one wording the web app, the command line
|
|
4
|
+
* and any other UI show, so they always say the same thing.
|
|
5
|
+
*/
|
|
6
|
+
import { plainText } from "../plainText.js";
|
|
7
|
+
/** A value quoted from someone's file: no control or direction codes, and short, whatever the file held. */
|
|
8
|
+
const quoted = (value) => {
|
|
9
|
+
const clean = plainText(value);
|
|
10
|
+
return clean.length > 24 ? `${clean.slice(0, 23)}…` : clean;
|
|
11
|
+
};
|
|
12
|
+
/** The settings a note names first, in this order, with how people say them and their unit. */
|
|
13
|
+
const NAMED = [
|
|
14
|
+
["nozzle_temperature", "nozzle temperature", " °C"],
|
|
15
|
+
["nozzle_temperature_initial_layer", "first-layer nozzle temperature", " °C"],
|
|
16
|
+
["filament_flow_ratio", "flow ratio", ""],
|
|
17
|
+
["filament_max_volumetric_speed", "max volumetric speed", " mm³/s"],
|
|
18
|
+
["pressure_advance", "pressure advance", ""],
|
|
19
|
+
["filament_retraction_length", "retraction length", " mm"],
|
|
20
|
+
["hot_plate_temp", "bed temperature (smooth PEI)", " °C"],
|
|
21
|
+
["textured_plate_temp", "bed temperature (textured PEI)", " °C"],
|
|
22
|
+
["fan_max_speed", "max fan speed", "%"],
|
|
23
|
+
];
|
|
24
|
+
const list = (items) => (items.length <= 1 ? items.join("") : `${items.slice(0, -1).join(", ")} and ${items.at(-1)}`);
|
|
25
|
+
/**
|
|
26
|
+
* What the Snapmaker or Generic filament option did, one sentence per note: which filaments use a preset's own
|
|
27
|
+
* settings and what that replaced, which use Generic because Snapmaker makes no preset for them, and which kept
|
|
28
|
+
* the creator's name and settings because no preset fits. Empty when the option wasn't used or changed nothing.
|
|
29
|
+
*/
|
|
30
|
+
export function filamentNotes(report) {
|
|
31
|
+
const notes = [];
|
|
32
|
+
const byPreset = new Map();
|
|
33
|
+
for (const p of report.filamentPresets ?? [])
|
|
34
|
+
byPreset.set(p.preset, [...(byPreset.get(p.preset) ?? []), p]);
|
|
35
|
+
for (const [preset, slots] of byPreset) {
|
|
36
|
+
const changed = slots.find((s) => s.changed.length > 0)?.changed ?? [];
|
|
37
|
+
const which = `${slots.length === 1 ? "Filament" : "Filaments"} ${list(slots.map((s) => String(s.slot)))}`;
|
|
38
|
+
if (changed.length === 0) {
|
|
39
|
+
notes.push(`${which} ${slots.length === 1 ? "uses" : "use"} ${preset}'s own settings, which match the creator's.`);
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
// The settings people know by name first; the rest as a count.
|
|
43
|
+
const named = NAMED.flatMap(([key, name, unit]) => {
|
|
44
|
+
const c = changed.find((x) => x.key === key);
|
|
45
|
+
return c && c.before !== "nil" && c.after !== "nil" ? [`${name} ${quoted(c.before)}${unit} → ${quoted(c.after)}${unit}`] : [];
|
|
46
|
+
}).slice(0, 3);
|
|
47
|
+
const rest = changed.length - named.length;
|
|
48
|
+
const others = `${rest} other setting${rest === 1 ? "" : "s"}`;
|
|
49
|
+
const what = named.length === 0 ? others : rest > 0 ? `${named.join(", ")}, and ${others}` : list(named);
|
|
50
|
+
notes.push(`${which} ${slots.length === 1 ? "uses" : "use"} ${preset}'s own settings instead of the creator's: ${what}.`);
|
|
51
|
+
}
|
|
52
|
+
const fallback = report.filamentComplianceFallback ?? [];
|
|
53
|
+
if (fallback.length > 0)
|
|
54
|
+
notes.push(`Snapmaker makes no preset for ${list(fallback)} at this nozzle size, so ${fallback.length === 1 ? "it uses" : "those use"} Generic.`);
|
|
55
|
+
const unchanged = report.filamentComplianceUnchanged ?? [];
|
|
56
|
+
if (unchanged.length > 0) {
|
|
57
|
+
notes.push(`No Snapmaker or Generic preset fits ${list(unchanged)} at this nozzle size, so ${unchanged.length === 1 ? "its name and settings stay" : "their names and settings stay"} as the creator had them. Snapmaker Space may refuse this file.`);
|
|
58
|
+
}
|
|
59
|
+
return notes;
|
|
60
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
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 } from "./project.js";
|
|
13
|
+
export type { ConvertOptions, ConvertReport, ConvertResult, ConvertStage, KnownConvertStage, 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";
|
|
@@ -35,6 +35,7 @@ export type { DiffAttention, DiffGroup, DiffGroupName, DiffOptions, DiffRow, Dif
|
|
|
35
35
|
export { diffReference, presetDiffSide, stockDiffSide } from "./diff/reference.js";
|
|
36
36
|
export type { SettingGroup, SettingInfo } from "./diff/settingsCatalog.js";
|
|
37
37
|
export { formatWhatChanged, CHANGE_REASONS } from "./explain/whatChanged.js";
|
|
38
|
+
export { filamentNotes } from "./explain/filamentNotes.js";
|
|
38
39
|
export type { ChangeGroup, ChangeItem, ChangeReason, KnownChangeReason, WhatChanged } from "./explain/whatChanged.js";
|
|
39
40
|
export { extractPreset } from "./presets/extractPreset.js";
|
|
40
41
|
export { parsePresetFile, serializePresets, resolvePreset, withoutChanges, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES } from "./presets/preset.js";
|
package/dist/index.js
CHANGED
|
@@ -23,6 +23,7 @@ export { diffSettings, DIFF_ATTENTIONS, DIFF_STATUSES } from "./diff/diffSetting
|
|
|
23
23
|
export { valueLayoutNotes, VALUE_LAYOUTS } from "./diff/valueLayout.js";
|
|
24
24
|
export { diffReference, presetDiffSide, stockDiffSide } from "./diff/reference.js";
|
|
25
25
|
export { formatWhatChanged, CHANGE_REASONS } from "./explain/whatChanged.js";
|
|
26
|
+
export { filamentNotes } from "./explain/filamentNotes.js";
|
|
26
27
|
export { extractPreset } from "./presets/extractPreset.js";
|
|
27
28
|
export { parsePresetFile, serializePresets, resolvePreset, withoutChanges, MAX_PRESET_NAME_LENGTH, MAX_PRESETS_PER_FILE, MAX_PRESETS_FILE_BYTES } from "./presets/preset.js";
|
|
28
29
|
export { buildStatsEvent, parseStatsEvent, receiveStatsEvent, resolveStatsConsent, STATS_MATCH_SOURCES } from "./telemetry.js";
|
package/dist/node.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { readFile, stat } from "node:fs/promises";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
12
12
|
import { dirname, join, resolve } from "node:path";
|
|
13
|
-
import { isReleasePath, isSourcePath, MAX_INDEX_BYTES, MAX_PROFILE_BYTES, MAX_SOURCE_BYTES, parseCatalogJson, ProfileDataError } from "./profiles.js";
|
|
13
|
+
import { FILAMENT_PRESETS_PATH, isReleasePath, isSourcePath, MAX_FILAMENT_PRESETS_BYTES, MAX_INDEX_BYTES, MAX_PROFILE_BYTES, MAX_SOURCE_BYTES, parseCatalogJson, ProfileDataError } from "./profiles.js";
|
|
14
14
|
async function readCapped(path, maxBytes) {
|
|
15
15
|
let size;
|
|
16
16
|
try {
|
|
@@ -42,6 +42,7 @@ export function dirProfileSource(dir) {
|
|
|
42
42
|
throw new ProfileDataError(`Not a source data file: ${JSON.stringify(path.slice(0, 60))}.`);
|
|
43
43
|
return readCapped(join(root, ...path.split("/")), MAX_SOURCE_BYTES);
|
|
44
44
|
},
|
|
45
|
+
readFilamentPresets: () => readCapped(join(root, FILAMENT_PRESETS_PATH), MAX_FILAMENT_PRESETS_BYTES),
|
|
45
46
|
release: (path) => {
|
|
46
47
|
// releases/<digits.digits.digits> only, so this stays in root too.
|
|
47
48
|
if (!isReleasePath(path))
|
|
@@ -72,7 +72,7 @@ export async function extractPreset(input, options) {
|
|
|
72
72
|
continue;
|
|
73
73
|
Object.defineProperty(differing, key, { value: settings[key], enumerable: true });
|
|
74
74
|
}
|
|
75
|
-
const changes = checkedChanges(differing, stock, notes);
|
|
75
|
+
const changes = checkedChanges(differing, stock, notes, loaded.convertProfile.profile.release);
|
|
76
76
|
return {
|
|
77
77
|
preset: {
|
|
78
78
|
base,
|
package/dist/presets/preset.d.ts
CHANGED
|
@@ -65,7 +65,7 @@ export declare function stockValue(key: string, stock: unknown): unknown;
|
|
|
65
65
|
/** Describes each change: its label, stock and new value, and whether it's above stock or above the machine limit. */
|
|
66
66
|
export declare function describeChanges(changes: Readonly<Record<string, PresetValue>>, stock: JsonRecord, machine: JsonRecord): PresetChange[];
|
|
67
67
|
/** The changes a preset can apply on a base profile: allowed keys the profile has, with valid values. Notes say what was left out. */
|
|
68
|
-
export declare function checkedChanges(changes: Readonly<Record<string, unknown>>, stock: JsonRecord, notes: string[]): Record<string, PresetValue>;
|
|
68
|
+
export declare function checkedChanges(changes: Readonly<Record<string, unknown>>, stock: JsonRecord, notes: string[], release?: string): Record<string, PresetValue>;
|
|
69
69
|
/** A preset ready to apply: its profile (a retired base is replaced by its successor) and the changes that are valid for it. */
|
|
70
70
|
export interface ResolvedPreset {
|
|
71
71
|
profileId: string;
|