@rulecad/model-link 0.1.1 → 0.1.3
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/README.md +2 -1
- package/model-link.d.mts +6 -0
- package/model-link.mjs +6 -2
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Share a printable model as a link. The model is compressed into the URL's `#fragment`, which browsers never send to
|
|
4
4
|
the server, so a public web page can open a private design and nothing is uploaded. It also writes STL files, and 3MF
|
|
5
5
|
files in Bambu Studio's project layout with each part on its own filament (AMS) slot. No dependencies: it uses the
|
|
6
|
-
browser's own `CompressionStream`, which Node
|
|
6
|
+
browser's own `CompressionStream`, which Node 20+ has too.
|
|
7
7
|
|
|
8
8
|
```js
|
|
9
9
|
import { fromParts, encode, decode, stl, threemf } from '@rulecad/model-link';
|
|
@@ -35,3 +35,4 @@ const zip = await threemf(back); // Uint8Array, a .3mf (one object, two
|
|
|
35
35
|
the same model gives the same bytes.
|
|
36
36
|
- `bambu3mf([{ name, parts: [{ name, triangles, slot }] }])` writes a 3MF from triangles directly. It has been
|
|
37
37
|
checked by loading the files back into Bambu Studio; other slicers read the same file as plain objects.
|
|
38
|
+
- `zip([[name, text], …])` writes a ZIP of text files, with the platform's own compression (no library).
|
package/model-link.d.mts
CHANGED
|
@@ -72,6 +72,12 @@ export function bambu3mf(objects: {
|
|
|
72
72
|
date?: string;
|
|
73
73
|
title?: string;
|
|
74
74
|
}): Promise<Uint8Array>;
|
|
75
|
+
/**
|
|
76
|
+
* A ZIP file, each file deflated with the browser's (or Node's) own CompressionStream: no library needed.
|
|
77
|
+
* @param {[string, string][]} entries [name, text] pairs
|
|
78
|
+
* @returns {Promise<Uint8Array>}
|
|
79
|
+
*/
|
|
80
|
+
export function zip(entries: [string, string][]): Promise<Uint8Array>;
|
|
75
81
|
/** @typedef {[[number, number, number], [number, number, number], [number, number, number]]} Triangle corners in mm, counter-clockwise seen from outside, Z up */
|
|
76
82
|
/** @typedef {{ title?: string, version?: string, src?: string, material?: string, orientation?: string, rules?: [string, any, string][], q?: number, p?: number[], t?: number[], parts?: any[], shapes?: any[], place?: any[], views?: [string, string][] }} Model */
|
|
77
83
|
export const VERSION: 1;
|
package/model-link.mjs
CHANGED
|
@@ -341,8 +341,12 @@ export async function bambu3mf(objects, { centre = [128, 128], generator = 'rule
|
|
|
341
341
|
const CRC = Array.from({ length: 256 }, (_, n) => { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; return c >>> 0; });
|
|
342
342
|
const crc32 = (b) => { let c = 0xffffffff; for (const x of b) c = CRC[(c ^ x) & 255] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; };
|
|
343
343
|
|
|
344
|
-
|
|
345
|
-
|
|
344
|
+
/**
|
|
345
|
+
* A ZIP file, each file deflated with the browser's (or Node's) own CompressionStream: no library needed.
|
|
346
|
+
* @param {[string, string][]} entries [name, text] pairs
|
|
347
|
+
* @returns {Promise<Uint8Array>}
|
|
348
|
+
*/
|
|
349
|
+
export async function zip(entries) {
|
|
346
350
|
const enc = new TextEncoder(), parts = [], dir = [];
|
|
347
351
|
let offset = 0;
|
|
348
352
|
for (const [name, text] of entries) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/model-link",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Share a printable model as a link (the model lives in the URL), and write STL or multi-colour Bambu Studio 3MF files, in the browser or Node.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"url"
|
|
24
24
|
],
|
|
25
25
|
"engines": {
|
|
26
|
-
"node": ">=
|
|
26
|
+
"node": ">=20"
|
|
27
27
|
},
|
|
28
28
|
"sideEffects": false,
|
|
29
29
|
"repository": {
|