9cd59bfc28
- A step opened from History brings what it works on into view (only when some of it is off screen, never zooming in). - On a phone, History and Items close when any tool opens (they covered the step's arrow and value box; before, only a sketch closed History). - Cancel after changing an early step's value is instant: the engine keeps the saved project's results while a step is previewed (10.7 s rebuild before). - Freeform's "tap a plane" step has XY / XZ / YZ and the project's planes as buttons, like Sketch. - A tool waiting for a body (Repair Body, Split...) takes a tapped corner too: on an STL a tap lands on a triangle corner almost everywhere. - Text: after placing it, the hint says to type in the card. - Typed variables kept in the remaining value boxes (feature numbers, Rotate, Tilt); hints for the control-point spline and Join. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.8 KiB
TypeScript
36 lines
1.8 KiB
TypeScript
// Run: npx tsx tests/savedcache.test.ts
|
|
// A step opened from History, a value changed, then Cancel: the project as
|
|
// saved comes back from what was already built, not from a rebuild of every
|
|
// step after the one that was open (seconds on a phone with threads in it).
|
|
import opencascade from "replicad-opencascadejs";
|
|
import { setOC } from "replicad";
|
|
import { debugBodies, regenerate } from "../src/kernel/engine";
|
|
import type { Feature } from "../src/doc/types";
|
|
|
|
setOC(await (opencascade as unknown as () => Promise<any>)());
|
|
|
|
const saved: Feature[] = [
|
|
{ id: "sk", name: "Sketch 01", type: "sketch", plane: { origin: [0, 0, 0], xDir: [1, 0, 0], normal: [0, 0, 1] }, entities: [{ id: "r", kind: "rect", center: [0, 0], w: 40, h: 30, rotation: 0 }], constraints: [] },
|
|
{ id: "ex", name: "Extrude 01", type: "extrude", source: { kind: "profile", sketch: "sk", regions: [{ c: [0, 0], a: 1200 }] }, distance: 20, mode: "new" },
|
|
{ id: "sh", name: "Shell 01", type: "shell", body: "ex", faces: [{ body: "ex", center: [0, 0, 20], normal: [0, 0, 1], area: 1200 }], thickness: 2 },
|
|
] as Feature[];
|
|
|
|
let failed = 0;
|
|
const check = (name: string, ok: boolean) => {
|
|
if (!ok) failed++;
|
|
console.log(ok ? "ok " : "FAIL", name);
|
|
};
|
|
|
|
const r0 = await regenerate(saved, true);
|
|
check("the saved project builds", !r0.errors.length);
|
|
const built = debugBodies().get("ex");
|
|
// A preview of the extrude at another height: every step from it on is rebuilt.
|
|
const preview = saved.map((f) => (f.id === "ex" ? { ...f, distance: 30 } : f)) as Feature[];
|
|
await regenerate(preview);
|
|
check("the preview is a different body", debugBodies().get("ex") !== built);
|
|
// Cancel: the saved project again - the very same body, not a rebuilt one.
|
|
await regenerate(saved, true);
|
|
check("Cancel brings back what was built, without a rebuild", debugBodies().get("ex") === built);
|
|
|
|
process.exit(failed ? 1 : 0);
|