@rulecad/cad 0.8.0 → 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/AGENTS.md +45 -16
- package/CHANGELOG.md +724 -0
- package/EXAMPLES.md +61 -54
- package/README.md +376 -98
- package/TUTORIAL.md +2 -2
- package/bin/cad.mjs +2664 -541
- package/lib/animate.mjs +173 -49
- package/lib/assembly.mjs +1883 -435
- package/lib/beams.mjs +256 -52
- package/lib/belts.mjs +66 -15
- package/lib/board-work.mjs +12 -0
- package/lib/bought.mjs +309 -53
- package/lib/buildpage.mjs +179 -29
- package/lib/cache-file.mjs +105 -0
- package/lib/carried.mjs +201 -0
- package/lib/clone.mjs +194 -42
- package/lib/code-text.mjs +28 -0
- package/lib/design-imports.mjs +127 -0
- package/lib/design.mjs +871 -147
- package/lib/designshapes.mjs +142 -0
- package/lib/drive.mjs +187 -63
- package/lib/edit.mjs +922 -192
- package/lib/errors.mjs +16 -3
- package/lib/estimates.mjs +51 -0
- package/lib/explain.mjs +62 -13
- package/lib/fasten.mjs +2708 -507
- package/lib/fe-key.mjs +29 -0
- package/lib/fittings.mjs +721 -122
- package/lib/fixings.mjs +38 -13
- package/lib/framebuild.mjs +790 -175
- package/lib/framecheck.mjs +1901 -368
- package/lib/framegen.mjs +108 -22
- package/lib/frameheat.mjs +225 -42
- package/lib/frameprint.mjs +513 -108
- package/lib/frames.mjs +86 -18
- package/lib/framesize.mjs +719 -120
- package/lib/frametip.mjs +235 -0
- package/lib/gait.mjs +135 -23
- package/lib/grip.mjs +62 -13
- package/lib/guides.mjs +1403 -230
- package/lib/host.mjs +129 -23
- package/lib/inplace.mjs +171 -36
- package/lib/jigs.mjs +360 -78
- package/lib/joins.mjs +697 -118
- package/lib/jsonedit.mjs +88 -26
- package/lib/kept.mjs +84 -0
- package/lib/kit.mjs +439 -69
- package/lib/layout.mjs +2 -1
- package/lib/links.mjs +149 -42
- package/lib/list.mjs +334 -64
- package/lib/live-guard.mjs +68 -0
- package/lib/live-shape.mjs +96 -24
- package/lib/live.mjs +189 -59
- package/lib/loads.mjs +597 -136
- package/lib/machine.mjs +372 -74
- package/lib/magnets.mjs +162 -44
- package/lib/measured.mjs +1080 -117
- package/lib/mesh.mjs +526 -119
- package/lib/meshcmd.mjs +215 -60
- package/lib/motors.mjs +1002 -214
- package/lib/motorsvg.mjs +114 -32
- package/lib/names.mjs +18 -1
- package/lib/optimise.mjs +991 -287
- package/lib/order.mjs +515 -114
- package/lib/panels.mjs +482 -94
- package/lib/parts.mjs +81 -23
- package/lib/pins.mjs +163 -44
- package/lib/plates.mjs +223 -35
- package/lib/player.mjs +37 -9
- package/lib/power.mjs +64 -13
- package/lib/preview.mjs +83 -16
- package/lib/profilemeasure.mjs +572 -129
- package/lib/rules.mjs +17 -6
- package/lib/sandbox-hooks.mjs +179 -27
- package/lib/sandbox-lock.mjs +225 -0
- package/lib/sandbox-preload.mjs +2 -2
- package/lib/sandbox-run.mjs +122 -25
- package/lib/sandbox.mjs +667 -75
- package/lib/schema.mjs +42 -11
- package/lib/seats.mjs +227 -49
- package/lib/services.mjs +261 -52
- package/lib/sheet.mjs +963 -179
- package/lib/slotnuts.mjs +213 -34
- package/lib/targets/gist.mjs +4 -1
- package/lib/targets.mjs +22 -4
- package/lib/task.mjs +376 -79
- package/lib/versions.mjs +285 -39
- package/lib/wires.mjs +228 -45
- package/lib/workspace.mjs +200 -14
- package/package.json +19 -19
- package/schemas/assembly.schema.json +2 -2
- package/schemas/project.schema.json +6 -0
- package/templates/coupons/MEASURE.md +109 -0
- package/templates/coupons/assemblies/fixings-test.json +20 -0
- package/templates/coupons/assemblies/slot-test.json +11 -0
- package/templates/coupons/objects/fixings-coupon.js +88 -0
- package/templates/coupons/objects/fixings-coupon.json +26 -0
- package/templates/coupons/objects/holds-coupon.js +130 -0
- package/templates/coupons/objects/holds-coupon.json +42 -0
- package/templates/coupons/objects/slot-coupon.js +89 -0
- package/templates/coupons/objects/slot-coupon.json +29 -0
- package/templates/coupons/project.json +10 -0
package/lib/fe-key.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// The names under which cad keeps its finite-element (FE) results in .cache: a printed clip's stress (loads.mjs
|
|
2
|
+
// clipStress), a bent link's (loads.mjs linkFE) and a motor mount's (motors.mjs mountFE). Each is slow to work out, so
|
|
3
|
+
// it is kept and used again while everything it was worked out from reads the same. The name is a hash of all of it:
|
|
4
|
+
// every triangle of the part (not a count and the first few, which an edit to a neck or a tip leaves as they were),
|
|
5
|
+
// the material (stiffness and Poisson's ratio), the loads, the cell size, and the version below.
|
|
6
|
+
//
|
|
7
|
+
// Raise a kind's version when the way its result is worked out changes (another stress read, another way of holding
|
|
8
|
+
// the part): results kept by the older code are then worked out again rather than read.
|
|
9
|
+
import crypto from 'node:crypto';
|
|
10
|
+
|
|
11
|
+
/** Each FE cache's version: raise one when its sum changes, so that results kept by the older code are not read. */
|
|
12
|
+
export const FE_CACHE_VERSIONS = Object.freeze({ clip: 2, link: 2, mount: 5 });
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The name of a kept FE result: a hash of the kind, its version and every input given (the whole mesh among them).
|
|
16
|
+
* @param {keyof typeof FE_CACHE_VERSIONS} kind which result: 'clip', 'link' or 'mount'
|
|
17
|
+
* @param {unknown[]} inputs everything the result is worked out from, as JSON
|
|
18
|
+
* @param {number} [length] how many hexadecimal characters of the hash to keep
|
|
19
|
+
* @returns {string}
|
|
20
|
+
*/
|
|
21
|
+
export function feKey(kind, inputs, length = 24) {
|
|
22
|
+
const version = FE_CACHE_VERSIONS[kind];
|
|
23
|
+
if (version == null) throw new Error(`feKey: no FE cache called "${kind}"`);
|
|
24
|
+
return crypto
|
|
25
|
+
.createHash('sha256')
|
|
26
|
+
.update(JSON.stringify([kind, version, ...inputs]))
|
|
27
|
+
.digest('hex')
|
|
28
|
+
.slice(0, length);
|
|
29
|
+
}
|