any2orca 0.7.0 → 0.7.2
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 +32 -0
- package/dist/archive/lookupFilamentColorName.js +15 -4
- package/dist/archive/objectWorldBboxXY.js +80 -58
- package/dist/archive/parseObjectMetadata.js +33 -9
- package/dist/archive/recenterAssembleItems.js +9 -1
- package/dist/archive/recenterBuildItems.js +9 -1
- package/dist/archive/xmlBlocks.d.ts +52 -3
- package/dist/archive/xmlBlocks.js +106 -4
- package/dist/cli/config.js +32 -2
- package/dist/cli/main.js +1 -1
- package/dist/cli/watchState.js +22 -1
- package/dist/engine/buildFilamentConfigs.js +8 -5
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/inspect.d.ts +8 -1
- package/dist/inspect.js +4 -1
- package/dist/project.js +1 -1
- package/dist/sources/prusa/bundle.js +17 -3
- package/dist/sources/prusa/convertSettings.js +55 -0
- package/dist/sources/prusa/keyMap.js +2 -0
- package/dist/sources/prusa/modelConfig.js +8 -5
- package/dist/sources/prusa/policyB.d.ts +10 -0
- package/dist/sources/prusa/policyB.js +21 -2
- package/dist/sources/prusa/prusa.js +12 -2
- package/dist/sources/prusa/splitParts.d.ts +0 -13
- package/dist/sources/prusa/splitParts.js +107 -42
- package/dist/sources/reader.d.ts +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/worker-entry.js +4 -3
- package/dist/worker.d.ts +7 -2
- package/dist/worker.js +22 -8
- package/package.json +4 -4
package/dist/worker-entry.js
CHANGED
|
@@ -133,9 +133,10 @@ async function handle(request) {
|
|
|
133
133
|
const entries = unwrapBundle(toBytes(request.bytes));
|
|
134
134
|
if (!entries)
|
|
135
135
|
return { result: null, transfer: [] };
|
|
136
|
-
//
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
// The unzip gives each entry a buffer of its own, so each is handed over as it is; one that shares its buffer
|
|
137
|
+
// with something else (a reader of another kind, say) is copied first, so the transfer takes only its bytes.
|
|
138
|
+
const owned = entries.map((e) => ({ name: e.name, bytes: e.bytes.byteOffset === 0 && e.bytes.byteLength === e.bytes.buffer.byteLength ? e.bytes : e.bytes.slice() }));
|
|
139
|
+
return { result: owned, transfer: owned.map((c) => c.bytes.buffer) };
|
|
139
140
|
}
|
|
140
141
|
default:
|
|
141
142
|
throw new Any2orcaError("invalid_file", "Unknown worker request.");
|
package/dist/worker.d.ts
CHANGED
|
@@ -82,8 +82,13 @@ export interface ConverterWorker {
|
|
|
82
82
|
* stock marked, for a badge) and notes on anything it would leave out.
|
|
83
83
|
*/
|
|
84
84
|
resolvePreset(preset: Preset, options?: WorkerReleaseOption): Promise<ResolvedPreset>;
|
|
85
|
-
/**
|
|
86
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Each .3mf inside a bundle zip, or null for a plain .3mf. Pass `transfer: true`
|
|
87
|
+
* to move the bytes instead of copying them, as for `open`.
|
|
88
|
+
*/
|
|
89
|
+
unwrapBundle(bytes: Uint8Array, options?: {
|
|
90
|
+
transfer?: boolean;
|
|
91
|
+
}): Promise<Array<{
|
|
87
92
|
name: string;
|
|
88
93
|
bytes: Uint8Array;
|
|
89
94
|
}> | null>;
|
package/dist/worker.js
CHANGED
|
@@ -45,12 +45,16 @@ export function createConverterWorker(worker, options) {
|
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
pending.delete(message.id);
|
|
48
|
-
if (message.ok)
|
|
48
|
+
if (message.ok === true) {
|
|
49
49
|
entry.resolve(message.result);
|
|
50
|
-
|
|
51
|
-
const slicer = message.error.slicer;
|
|
52
|
-
entry.reject(new Any2orcaError(message.error.code, message.error.message, typeof slicer === "string" ? { slicer } : undefined));
|
|
50
|
+
return;
|
|
53
51
|
}
|
|
52
|
+
// Read defensively: a reply without a usable error would otherwise throw here, after the entry is gone, and the
|
|
53
|
+
// call would never settle.
|
|
54
|
+
const error = message.error;
|
|
55
|
+
const code = typeof error?.code === "string" ? error.code : "invalid_file";
|
|
56
|
+
const text = typeof error?.message === "string" ? error.message : "The converter's worker sent a reply it couldn't read.";
|
|
57
|
+
entry.reject(new Any2orcaError(code, text, typeof error?.slicer === "string" ? { slicer: error.slicer } : undefined));
|
|
54
58
|
});
|
|
55
59
|
function call(body, transfer = [], onProgress) {
|
|
56
60
|
if (terminated)
|
|
@@ -95,9 +99,7 @@ export function createConverterWorker(worker, options) {
|
|
|
95
99
|
}
|
|
96
100
|
return {
|
|
97
101
|
async open(bytes, openOptions = {}) {
|
|
98
|
-
|
|
99
|
-
const ownsWholeBuffer = bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength;
|
|
100
|
-
const payload = openOptions.transfer && ownsWholeBuffer ? bytes : bytes.slice();
|
|
102
|
+
const payload = outgoing(bytes, openOptions.transfer);
|
|
101
103
|
const { handle, inspection } = await call({ op: "open", bytes: payload }, [payload.buffer]);
|
|
102
104
|
return { project: project(handle, inspection), inspection };
|
|
103
105
|
},
|
|
@@ -107,7 +109,10 @@ export function createConverterWorker(worker, options) {
|
|
|
107
109
|
},
|
|
108
110
|
resolvePreset: (preset, release) => call({ op: "resolvePreset", preset, ...releaseField(release) }),
|
|
109
111
|
listProfiles: (filter) => call({ op: "listProfiles", ...(filter ? { filter } : {}) }),
|
|
110
|
-
unwrapBundle
|
|
112
|
+
unwrapBundle(bytes, bundleOptions = {}) {
|
|
113
|
+
const payload = outgoing(bytes, bundleOptions.transfer);
|
|
114
|
+
return call({ op: "unwrapBundle", bytes: payload }, [payload.buffer]);
|
|
115
|
+
},
|
|
111
116
|
terminate() {
|
|
112
117
|
terminated = true;
|
|
113
118
|
worker.terminate();
|
|
@@ -117,6 +122,15 @@ export function createConverterWorker(worker, options) {
|
|
|
117
122
|
},
|
|
118
123
|
};
|
|
119
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* The bytes to post: the caller's own buffer when it may be moved and the
|
|
127
|
+
* view covers all of it, otherwise a fresh copy. Either way only one buffer
|
|
128
|
+
* crosses to the worker.
|
|
129
|
+
*/
|
|
130
|
+
function outgoing(bytes, transfer) {
|
|
131
|
+
const ownsWholeBuffer = bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength;
|
|
132
|
+
return transfer && ownsWholeBuffer ? bytes : bytes.slice();
|
|
133
|
+
}
|
|
120
134
|
/** The release field for a request, left out when no release is named. */
|
|
121
135
|
function releaseField(release) {
|
|
122
136
|
return release?.snapmakerOrcaVersion === undefined ? {} : { release: { snapmakerOrcaVersion: release.snapmakerOrcaVersion } };
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "any2orca",
|
|
3
|
-
"version": "0.7.
|
|
4
|
-
"
|
|
5
|
-
"description": "Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer and Flash Studio 3MF projects for the Snapmaker U1 (Snapmaker Orca), entirely on your own machine. Library, CLI and Web Worker in one package.",
|
|
3
|
+
"version": "0.7.2",
|
|
4
|
+
"description": "Convert Bambu Studio, Creality Print, Anycubic Slicer Next, ElegooSlicer, Flash Studio and PrusaSlicer 3MF projects for the Snapmaker U1 (Snapmaker Orca), entirely on your own machine. Library, CLI and Web Worker in one package.",
|
|
6
5
|
"keywords": [
|
|
7
6
|
"3mf",
|
|
8
7
|
"snapmaker",
|
|
@@ -14,6 +13,7 @@
|
|
|
14
13
|
"anycubic",
|
|
15
14
|
"elegoo",
|
|
16
15
|
"flashforge",
|
|
16
|
+
"prusaslicer",
|
|
17
17
|
"3d-printing",
|
|
18
18
|
"slicer",
|
|
19
19
|
"converter",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"docs": "typedoc"
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"any2orca-profiles": "0.3.
|
|
68
|
+
"any2orca-profiles": "0.3.1",
|
|
69
69
|
"fflate": "0.8.3",
|
|
70
70
|
"zod": "4.6.7"
|
|
71
71
|
},
|