any2orca 0.7.0 → 0.7.1

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/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
- else {
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
- // Either way only one buffer crosses: the caller's own (transfer) or a fresh copy.
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: (bytes) => call({ op: "unwrapBundle", bytes }),
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,7 +1,7 @@
1
1
  {
2
2
  "name": "any2orca",
3
- "version": "0.7.0",
4
- "outputAffecting": "a PrusaSlicer conversion carries only the print settings the creator changed; converted PrusaSlicer files change, Bambu-family files don't",
3
+ "version": "0.7.1",
4
+ "outputAffecting": "PrusaSlicer files: an unchecked Brim box is no brim and supports convert as PrusaSlicer shows them; a placement that isn't a number is kept as written. Bambu-family files are otherwise unchanged",
5
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.",
6
6
  "keywords": [
7
7
  "3mf",
@@ -65,7 +65,7 @@
65
65
  "docs": "typedoc"
66
66
  },
67
67
  "dependencies": {
68
- "any2orca-profiles": "0.3.0",
68
+ "any2orca-profiles": "0.3.1",
69
69
  "fflate": "0.8.3",
70
70
  "zod": "4.6.7"
71
71
  },