@rulecad/model-link 0.3.1 → 0.3.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/model-link.d.mts +7 -1
- package/model-link.mjs +6 -2
- package/package.json +1 -1
package/model-link.d.mts
CHANGED
|
@@ -120,7 +120,7 @@ export function bambu3mf(objects: {
|
|
|
120
120
|
*/
|
|
121
121
|
export function zip(entries: [string, string][]): Promise<Uint8Array>;
|
|
122
122
|
/** @typedef {[[number, number, number], [number, number, number], [number, number, number]]} Triangle corners in mm, counter-clockwise seen from outside, Z up */
|
|
123
|
-
/** @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][], motion?: any }} Model */
|
|
123
|
+
/** @typedef {{ title?: string, version?: string, src?: string, material?: string, orientation?: string, fab?: { name: string, zip: string }[], rules?: [string, any, string][], q?: number, p?: number[], t?: number[], parts?: any[], shapes?: any[], place?: any[], views?: [string, string][], motion?: any }} Model */
|
|
124
124
|
export const VERSION: 1;
|
|
125
125
|
export namespace LIMITS {
|
|
126
126
|
let vertices: number;
|
|
@@ -130,6 +130,8 @@ export namespace LIMITS {
|
|
|
130
130
|
let views: number;
|
|
131
131
|
let viewSize: number;
|
|
132
132
|
let sheet: number;
|
|
133
|
+
let fab: number;
|
|
134
|
+
let fabSize: number;
|
|
133
135
|
let size: number;
|
|
134
136
|
let text: number;
|
|
135
137
|
let bytes: number;
|
|
@@ -163,6 +165,10 @@ export type Model = {
|
|
|
163
165
|
src?: string;
|
|
164
166
|
material?: string;
|
|
165
167
|
orientation?: string;
|
|
168
|
+
fab?: {
|
|
169
|
+
name: string;
|
|
170
|
+
zip: string;
|
|
171
|
+
}[];
|
|
166
172
|
rules?: [string, any, string][];
|
|
167
173
|
q?: number;
|
|
168
174
|
p?: number[];
|
package/model-link.mjs
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
// these come after the parts they stand in for.
|
|
12
12
|
// views (optional): [[name, svg]], 2D drawings shown beside the 3D model (a board's copper, a schematic); "Group:
|
|
13
13
|
// view" names share a tab. The page shows them as images, so nothing in them runs.
|
|
14
|
+
// fab (optional): [{ name, zip }], a board's files for its fab (Gerbers, drill files, BOM, placement), each a zip
|
|
15
|
+
// file's name and its bytes in base64: the page offers each as a download, as it is.
|
|
14
16
|
// Or placed shapes, for things made of repeated parts (nine keys): each shape once, then where each copy goes:
|
|
15
17
|
// { …, shapes: [{ role, label, slot?, q, p, t }], place: [[shape, a, b, c, d, e, f, g, h, i, j, k, l, name?]] }
|
|
16
18
|
// (a 3 × 4 transform by rows, in mm). decode() expands them, so the rest of the page sees one model.
|
|
@@ -19,10 +21,10 @@
|
|
|
19
21
|
// "1." is the format version: newer pages must keep reading old links.
|
|
20
22
|
|
|
21
23
|
/** @typedef {[[number, number, number], [number, number, number], [number, number, number]]} Triangle corners in mm, counter-clockwise seen from outside, Z up */
|
|
22
|
-
/** @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][], motion?: any }} Model */
|
|
24
|
+
/** @typedef {{ title?: string, version?: string, src?: string, material?: string, orientation?: string, fab?: { name: string, zip: string }[], rules?: [string, any, string][], q?: number, p?: number[], t?: number[], parts?: any[], shapes?: any[], place?: any[], views?: [string, string][], motion?: any }} Model */
|
|
23
25
|
|
|
24
26
|
export const VERSION = 1;
|
|
25
|
-
export const LIMITS = { vertices: 200000, triangles: 400000, shapes: 512, places: 2048, views: 32, viewSize: 4e6, sheet: 5000, // every keycap with its own legend is its own shape
|
|
27
|
+
export const LIMITS = { vertices: 200000, triangles: 400000, shapes: 512, places: 2048, views: 32, viewSize: 4e6, sheet: 5000, fab: 8, fabSize: 8e6, // a fab zip, in base64 characters // every keycap with its own legend is its own shape
|
|
26
28
|
size: 1e5, // mm: no corner further than this from the origin (a link is a part or an assembly, not a map)
|
|
27
29
|
text: 2000, // characters in a title, a name or a label
|
|
28
30
|
bytes: 160e6 }; // of a link once unpacked: its views at their largest, and the biggest model, with room to spare
|
|
@@ -132,6 +134,8 @@ function problems(m) {
|
|
|
132
134
|
if (m.sheet != null && (!Array.isArray(m.sheet) || m.sheet.length > LIMITS.sheet || m.sheet.some((r) => !Array.isArray(r) || r.length > 9 || r.some((c) => typeof c !== 'string')))) return ['broken rules sheet'];
|
|
133
135
|
if (Array.isArray(m.views) && m.views.length > LIMITS.views) return [`${m.views.length} flat views: more than a link can hold (${LIMITS.views})`];
|
|
134
136
|
if (m.views != null && (!Array.isArray(m.views) || m.views.some((v) => !Array.isArray(v) || typeof v[0] !== 'string' || typeof v[1] !== 'string' || v[1].length > LIMITS.viewSize))) return ['broken views'];
|
|
137
|
+
if (m.fab != null && (!Array.isArray(m.fab) || m.fab.length > LIMITS.fab || m.fab.some((f) => !f || typeof f.name !== 'string' || !/^[\w@.+-]{1,200}\.zip$/.test(f.name)
|
|
138
|
+
|| typeof f.zip !== 'string' || f.zip.length > LIMITS.fabSize || !/^[A-Za-z0-9+/]*={0,2}$/.test(f.zip)))) return ['broken fab files'];
|
|
135
139
|
if (m.motion != null && !motionOk(m.motion, m.parts?.length ?? 1)) return ['broken motion'];
|
|
136
140
|
if (m.task != null && !taskOk(m.task)) return ['broken task'];
|
|
137
141
|
if (m.steps != null && !stepsOk(m.steps)) return ['broken step file'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rulecad/model-link",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
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": {
|