@chanmeng666/archlang-3d 0.0.0-stage → 0.1.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/dist/node.d.ts ADDED
@@ -0,0 +1,130 @@
1
+ import { World } from '@chanmeng666/archlang';
2
+ import { M as Mesh3D, f as ReplayEvent, j as MeshNode, a as Scene3D, c as Shell } from './strip-BMxWrvYD.js';
3
+ export { R as ReplayFacts, S as StripItem, s as stripAt } from './strip-BMxWrvYD.js';
4
+ import { ReplayOptions } from './replay.js';
5
+ export { PREVIEW_LABEL, replayPayload, viewBoxOf } from './replay.js';
6
+ export { F as FactsOptions, r as replayFacts } from './facts-DMBpeo-q.js';
7
+
8
+ /** The viewer and the parts of three.js it uses, as one minified browser script (read once). */
9
+ declare function viewerScript(): Promise<string>;
10
+ /** A replay of `mesh` as one self-contained HTML document. */
11
+ declare function replayHtml(mesh: Mesh3D, opts: ReplayOptions): Promise<string>;
12
+
13
+ /** The flags that make Chromium render WebGL in software, the same on every machine (plan §6.5). */
14
+ declare const SWIFTSHADER_ARGS: string[];
15
+
16
+ interface KeyFrame {
17
+ label: string;
18
+ t: number;
19
+ /** SHA-256 of the composed frame's RGBA pixels. */
20
+ sha256: string;
21
+ }
22
+ interface VideoReport {
23
+ frames: number;
24
+ fps: number;
25
+ seconds: number;
26
+ width: number;
27
+ height: number;
28
+ keyFrames: KeyFrame[];
29
+ /** The metrics strip's text at each key frame (card G4); absent when the replay carries no facts. */
30
+ strips?: Array<{
31
+ label: string;
32
+ text: string;
33
+ }>;
34
+ /** `__seek(0.5)` twice gave one frame hash. */
35
+ seekRoundTrip: boolean;
36
+ /** Present when an MP4 was written. */
37
+ mp4?: string;
38
+ /** The Chromium that rendered the frames (`browser.version()`): pixel baselines are per build (Q21). */
39
+ browser: string;
40
+ }
41
+ interface VideoOptions {
42
+ html: string;
43
+ events: readonly ReplayEvent[];
44
+ width: number;
45
+ height: number;
46
+ fps?: number;
47
+ seconds?: number;
48
+ /** Where to write the MP4; omit to measure the key frames only. */
49
+ mp4?: string;
50
+ ffmpeg?: string;
51
+ }
52
+ /** Render key frames (and, given `mp4`, every frame) of a replay HTML in headless Chromium. */
53
+ declare function renderReplay(o: VideoOptions): Promise<VideoReport>;
54
+
55
+ /** `asset.generator`: the package and its version, never a time (plan §3.7). */
56
+ declare const GLB_GENERATOR: string;
57
+ /** The glTF node name of a Mesh3D node: its key without the storey prefix (plan §3.6). */
58
+ declare const glbNodeName: (n: MeshNode) => string;
59
+ /** The storey group node's name. */
60
+ declare const levelNodeName: (level: number) => string;
61
+ /** `extras.archlang` of a Mesh3D node: identity first, then the node's own facts, in a fixed key order. */
62
+ declare function nodeExtras(n: MeshNode): Record<string, string | number | boolean>;
63
+ /** The GLB of `mesh`: same Mesh3D and `generator`, same bytes. */
64
+ declare function writeGlb(mesh: Mesh3D, opts?: {
65
+ generator?: string;
66
+ }): Promise<Uint8Array>;
67
+ /** One node read back from a GLB: its global key (`L<n>/<name>`) and its `extras.archlang`. */
68
+ interface GlbNode {
69
+ key: string;
70
+ name: string;
71
+ extras: Record<string, unknown>;
72
+ }
73
+ /**
74
+ * The storey groups (each scene's root nodes) and every node below them at any depth, depth first
75
+ * in file order. This module writes element nodes one level under their group only, so a node
76
+ * nested deeper is reported too (and then named and diffed like any other), never skipped.
77
+ */
78
+ declare function readGlbNodes(glb: Uint8Array): Promise<{
79
+ levels: string[];
80
+ nodes: GlbNode[];
81
+ }>;
82
+
83
+ /**
84
+ * The checks `archlang3d build` and `check` run (archlang-3d plan §8.1), each a named verdict:
85
+ *
86
+ * - V-SCH-01 the Scene3D passes its validator (the schema's verdicts, `scene3d/validate.ts`);
87
+ * - V-GEO-02 every Mesh3D shell is closed, consistently wound and of positive volume;
88
+ * - V-GLTF-01 Khronos glTF-Validator: 0 errors and 0 warnings (infos and hints are reported, not failed);
89
+ * - V-GLTF-02 the GLB's nodes are the Mesh3D's nodes, one for one, named `<kind>:<id>[:<part>]`
90
+ * under `level:L<n>`, each `extras.archlang` naming its own key, kind and id; and nothing in the
91
+ * file carries an absolute path or a time (plan §8.5 L7).
92
+ *
93
+ * Node-only (it loads glTF-Validator, a Dart program compiled to JavaScript, on first use).
94
+ */
95
+
96
+ type CheckId = "V-SCH-01" | "V-GEO-02" | "V-GLTF-01" | "V-GLTF-02";
97
+ interface CheckResult {
98
+ id: CheckId;
99
+ ok: boolean;
100
+ /** What failed, one line each (at most 20, then a count). */
101
+ failures: string[];
102
+ /** Counts the check measured (shells, nodes, issues by severity). */
103
+ facts?: Record<string, number | string>;
104
+ }
105
+ /** Directed edges not matched by exactly one reverse edge: 0 = closed and consistently wound. */
106
+ declare function openEdges(s: Shell): number;
107
+ /** Signed volume (µm³) of a shell: positive when every face points out. */
108
+ declare function signedVolume(s: Shell): number;
109
+ declare function checkScene(scene: Scene3D): CheckResult;
110
+ declare function checkShells(mesh: Mesh3D): CheckResult;
111
+ /**
112
+ * Why a GLB's JSON chunk is not reproducible (plan §8.5 L7); empty when it is. A path is looked
113
+ * for anywhere. A date or time only in `asset` (generator, copyright, version, its extras: what
114
+ * the WRITER stamps), because the scene, node and `extras.archlang` text is the plan's own, and a
115
+ * plan may well be called "Survey 2026-10-28T09:30".
116
+ */
117
+ declare function glbLeaks(json: string): string[];
118
+ /** V-GLTF-02 over nodes read back from a GLB; given `mesh`, its node set must equal the Mesh3D's. */
119
+ declare function checkNaming(nodes: readonly GlbNode[], levels: readonly string[], mesh?: Mesh3D): CheckResult;
120
+ /** The JSON chunk of a GLB, as text. */
121
+ declare function glbJson(glb: Uint8Array): string;
122
+ /** V-GLTF-01: Khronos glTF-Validator over the bytes; fails on any error or warning. */
123
+ declare function checkValidator(glb: Uint8Array): Promise<CheckResult>;
124
+ /** Every check a GLB alone allows (`archlang3d check model.glb`); given its Mesh3D, the node sets are compared. */
125
+ declare function checkGlb(glb: Uint8Array, mesh?: Mesh3D): Promise<CheckResult[]>;
126
+
127
+ /** A World that reads an `import`ed module relative to `baseDir`; a missing file reads as `null`. */
128
+ declare function makeNodeWorld(baseDir: string): World;
129
+
130
+ export { type CheckId, type CheckResult, GLB_GENERATOR, type GlbNode, type KeyFrame, ReplayOptions, SWIFTSHADER_ARGS, type VideoOptions, type VideoReport, checkGlb, checkNaming, checkScene, checkShells, checkValidator, glbJson, glbLeaks, glbNodeName, levelNodeName, makeNodeWorld, nodeExtras, openEdges, readGlbNodes, renderReplay, replayHtml, signedVolume, viewerScript, writeGlb };
package/dist/node.js ADDED
@@ -0,0 +1,60 @@
1
+ import {
2
+ GLB_GENERATOR,
3
+ SWIFTSHADER_ARGS,
4
+ checkGlb,
5
+ checkNaming,
6
+ checkScene,
7
+ checkShells,
8
+ checkValidator,
9
+ glbJson,
10
+ glbLeaks,
11
+ glbNodeName,
12
+ levelNodeName,
13
+ makeNodeWorld,
14
+ nodeExtras,
15
+ openEdges,
16
+ readGlbNodes,
17
+ renderReplay,
18
+ replayHtml,
19
+ signedVolume,
20
+ viewerScript,
21
+ writeGlb
22
+ } from "./chunk-2WKSS3IA.js";
23
+ import {
24
+ replayFacts
25
+ } from "./chunk-IQJQDQSC.js";
26
+ import {
27
+ PREVIEW_LABEL,
28
+ replayPayload,
29
+ viewBoxOf
30
+ } from "./chunk-54YVSAVZ.js";
31
+ import {
32
+ stripAt
33
+ } from "./chunk-CTFMM64C.js";
34
+ export {
35
+ GLB_GENERATOR,
36
+ PREVIEW_LABEL,
37
+ SWIFTSHADER_ARGS,
38
+ checkGlb,
39
+ checkNaming,
40
+ checkScene,
41
+ checkShells,
42
+ checkValidator,
43
+ glbJson,
44
+ glbLeaks,
45
+ glbNodeName,
46
+ levelNodeName,
47
+ makeNodeWorld,
48
+ nodeExtras,
49
+ openEdges,
50
+ readGlbNodes,
51
+ renderReplay,
52
+ replayFacts,
53
+ replayHtml,
54
+ replayPayload,
55
+ signedVolume,
56
+ stripAt,
57
+ viewBoxOf,
58
+ viewerScript,
59
+ writeGlb
60
+ };
@@ -0,0 +1,62 @@
1
+ import { R as ReplayFacts, f as ReplayEvent, M as Mesh3D } from './strip-BMxWrvYD.js';
2
+
3
+ /**
4
+ * The replay's data (card A3), browser-safe: `replayPayload(mesh, opts)` is what a replay carries
5
+ * for `mesh`, whether the single-file HTML inlines it (`html.ts`, Node) or the playground's 3D
6
+ * preview tab builds it in the browser (card A5) and mounts it with `mountReplay`.
7
+ */
8
+
9
+ interface ReplayNode {
10
+ key: string;
11
+ kind: string;
12
+ part?: string;
13
+ /** The combined view's exploded storeys: how far (mm) the node is lifted; absent = 0. */
14
+ lift?: number;
15
+ /** Flat `[x, y, z, …]` in micrometres, exporters' axes (X plan x, Y up, Z plan y). */
16
+ positions: number[];
17
+ indices: number[];
18
+ }
19
+ interface ReplayPayload {
20
+ title: string;
21
+ theme: "light" | "dark";
22
+ width: number;
23
+ height: number;
24
+ seconds: number;
25
+ /** The core's own drawing of the plan (light theme) and its viewBox in plan millimetres. */
26
+ svg: string;
27
+ viewBox: [number, number, number, number];
28
+ /** The end camera's elevation in degrees (`endElevation`). */
29
+ elevation: number;
30
+ /** The metrics strip's numbers (card G4); with none, no strip is painted. */
31
+ facts?: ReplayFacts;
32
+ nodes: ReplayNode[];
33
+ events: ReplayEvent[];
34
+ }
35
+ /** A mounted replay: every frame is `seek(t)`. */
36
+ /** The label every surface that shows the preview carries (decision D5's wording). */
37
+ declare const PREVIEW_LABEL = "Preview \u2014 from the separate archlang-3d package. ArchLang itself draws plans.";
38
+ interface ReplayOptions {
39
+ title: string;
40
+ /**
41
+ * The core's drawing of the storey phase 1 draws, light theme: `compile(source).svg` (page 1) for
42
+ * the combined view, the storey's own `compile(source).pages[i].svg` for a storey view.
43
+ */
44
+ svg: string;
45
+ width?: number;
46
+ height?: number;
47
+ seconds?: number;
48
+ /** Exports only: the sites stay light (D11, ADR 0014). */
49
+ theme?: "light" | "dark";
50
+ /** The metrics strip's numbers (`replayFacts`); omit for a replay without the strip (card G4). */
51
+ facts?: ReplayFacts;
52
+ }
53
+ /** The `viewBox` of an SVG document, in its user units (plan millimetres for the core's drawing). */
54
+ declare function viewBoxOf(svg: string): [number, number, number, number];
55
+ /**
56
+ * The data a replay HTML carries for `mesh`: pass `viewMesh(mesh, view)` for one view. A mesh of
57
+ * more than one storey is the combined view: its storeys are exploded (`explodeLifts`) and the end
58
+ * camera looks down more steeply (`endElevation`).
59
+ */
60
+ declare function replayPayload(mesh: Mesh3D, opts: ReplayOptions): ReplayPayload;
61
+
62
+ export { PREVIEW_LABEL, type ReplayNode, type ReplayOptions, type ReplayPayload, replayPayload, viewBoxOf };