summaryrefslogtreecommitdiff
path: root/public/SomhairlesDream.Shared/Domain.js
diff options
context:
space:
mode:
authorSomhairle H. Marisol <[email protected]>2026-09-21 00:58:15 +0800
committerSomhairle H. Marisol <[email protected]>2026-09-21 00:58:15 +0800
commit7b29dbff7e43e87741476f47df17ad1582b16546 (patch)
tree4c9d0832b4e4edd77e59e9cb0a88abf5e729a9f9 /public/SomhairlesDream.Shared/Domain.js
parent47add3088d50f12c5f48591f26c53cdb59d8283b (diff)
downloadsomhairles-dream-fsharp-7b29dbff7e43e87741476f47df17ad1582b16546.tar.gz
feat(pipeline): add runnable artifact pipeline increment
[Change Nature] - This commit adds the first runnable increment of the F# artifact pipeline: CLI, server, frontend bundle, stage fixture, and tests. It is feature work, not a bug fix. [New Capability] - CLI `run` executes the three-step Blender fixture through the process bridge and writes GLBs, step logs, events, and a manifest; `verify` validates a manifest without Blender. - Server exposes run start, run-scoped SSE, artifact manifest/file routes, and serves the Fable frontend from its build output. - Frontend starts runs, follows run-scoped SSE progress, and links the artifact manifest on completion. [Implementation] - Shared layer holds domain, run state, replay, and artifact contracts; Modeling holds the pipeline, 120s bridge timeout, and result-file protocol; stage/blender/fixture.py owns geometry in Python (bpy owns geometry, F# owns orchestration). - Fable bundle is regenerated into public/ and copied by the server project; solution includes all projects with warnings-as-errors. - README documents build, Fable, server, interpreter/env, fixture limitations, and current verification status. [Impact] - Verified: 40/40 solution tests pass; Release build 0 warnings/errors; real CLI run with bpy 5.0.1 produced 3 GLBs, 3 logs, and a verify-clean manifest; isolated-port server smoke flow succeeded. - Not yet verified: browser end-to-end behavior and production fidelity. Artifacts and caches are gitignored.
Diffstat (limited to 'public/SomhairlesDream.Shared/Domain.js')
-rw-r--r--public/SomhairlesDream.Shared/Domain.js114
1 files changed, 114 insertions, 0 deletions
diff --git a/public/SomhairlesDream.Shared/Domain.js b/public/SomhairlesDream.Shared/Domain.js
new file mode 100644
index 0000000..5384715
--- /dev/null
+++ b/public/SomhairlesDream.Shared/Domain.js
@@ -0,0 +1,114 @@
+import { Record } from "../fable_modules/fable-library-js.4.24.0/Types.js";
+import { bool_type, option_type, class_type, enum_type, array_type, string_type, int32_type, record_type, float64_type } from "../fable_modules/fable-library-js.4.24.0/Reflection.js";
+import { item, collect } from "../fable_modules/fable-library-js.4.24.0/Array.js";
+import { singleton, append, collect as collect_1, delay, toArray } from "../fable_modules/fable-library-js.4.24.0/Seq.js";
+import { rangeDouble } from "../fable_modules/fable-library-js.4.24.0/Range.js";
+import { op_Subtraction } from "../fable_modules/fable-library-js.4.24.0/DateOffset.js";
+
+export class Vector3 extends Record {
+ constructor(X, Y, Z) {
+ super();
+ this.X = X;
+ this.Y = Y;
+ this.Z = Z;
+ }
+}
+
+export function Vector3_$reflection() {
+ return record_type("SomhairlesDream.Shared.Vector3", [], Vector3, () => [["X", float64_type], ["Y", float64_type], ["Z", float64_type]]);
+}
+
+export class MeshSnapshot extends Record {
+ constructor(Version, Label, Vertices, Faces) {
+ super();
+ this.Version = (Version | 0);
+ this.Label = Label;
+ this.Vertices = Vertices;
+ this.Faces = Faces;
+ }
+}
+
+export function MeshSnapshot_$reflection() {
+ return record_type("SomhairlesDream.Shared.MeshSnapshot", [], MeshSnapshot, () => [["Version", int32_type], ["Label", string_type], ["Vertices", array_type(Vector3_$reflection())], ["Faces", array_type(array_type(int32_type))]]);
+}
+
+export class LiveSnapshot extends Record {
+ constructor(ProjectId, RunId, Status, CurrentVersion, TargetVersion, HeartbeatAt, UpdatedAt, Message, Mesh, NextDesignRunScheduled) {
+ super();
+ this.ProjectId = ProjectId;
+ this.RunId = RunId;
+ this.Status = (Status | 0);
+ this.CurrentVersion = (CurrentVersion | 0);
+ this.TargetVersion = (TargetVersion | 0);
+ this.HeartbeatAt = HeartbeatAt;
+ this.UpdatedAt = UpdatedAt;
+ this.Message = Message;
+ this.Mesh = Mesh;
+ this.NextDesignRunScheduled = NextDesignRunScheduled;
+ }
+}
+
+export function LiveSnapshot_$reflection() {
+ return record_type("SomhairlesDream.Shared.LiveSnapshot", [], LiveSnapshot, () => [["ProjectId", string_type], ["RunId", string_type], ["Status", enum_type("SomhairlesDream.Shared.RunStatus", int32_type, [["Idle", 0], ["Queued", 1], ["Running", 2], ["Succeeded", 3], ["Failed", 4], ["Stale", 5]])], ["CurrentVersion", int32_type], ["TargetVersion", int32_type], ["HeartbeatAt", option_type(class_type("System.DateTimeOffset"))], ["UpdatedAt", class_type("System.DateTimeOffset")], ["Message", string_type], ["Mesh", option_type(MeshSnapshot_$reflection())], ["NextDesignRunScheduled", bool_type]]);
+}
+
+export function MeshData_positionData(mesh) {
+ return collect((vertex) => (new Float64Array([vertex.X, vertex.Y, vertex.Z])), mesh.Vertices, Float64Array);
+}
+
+export function MeshData_triangleIndices(mesh) {
+ return collect((face) => {
+ if (face.length < 3) {
+ return new Int32Array([]);
+ }
+ else {
+ return toArray(delay(() => collect_1((index) => append(singleton(item(0, face)), delay(() => append(singleton(item(index, face)), delay(() => singleton(item(index + 1, face)))))), rangeDouble(1, 1, face.length - 2))));
+ }
+ }, mesh.Faces, Int32Array);
+}
+
+export function RunState_initial(projectId, runId, now) {
+ return new LiveSnapshot(projectId, runId, 0, 0, 0, undefined, now, "等待设计运行", undefined, false);
+}
+
+export function RunState_start(now, state) {
+ const targetVersion = (state.TargetVersion + 1) | 0;
+ return new LiveSnapshot(state.ProjectId, state.RunId, 2, state.CurrentVersion, targetVersion, now, now, `正在生成第 ${targetVersion} 版几何`, state.Mesh, false);
+}
+
+export function RunState_heartbeat(now, state) {
+ if (state.Status === 2) {
+ return new LiveSnapshot(state.ProjectId, state.RunId, state.Status, state.CurrentVersion, state.TargetVersion, now, now, state.Message, state.Mesh, state.NextDesignRunScheduled);
+ }
+ else {
+ return state;
+ }
+}
+
+export function RunState_statusAt(timeout, now, state) {
+ const matchValue = state.HeartbeatAt;
+ let matchResult, heartbeatAt_1;
+ if (matchValue != null) {
+ if ((state.Status === 2) && (op_Subtraction(now, matchValue) > timeout)) {
+ matchResult = 0;
+ heartbeatAt_1 = matchValue;
+ }
+ else {
+ matchResult = 1;
+ }
+ }
+ else {
+ matchResult = 1;
+ }
+ switch (matchResult) {
+ case 0:
+ return new LiveSnapshot(state.ProjectId, state.RunId, 5, state.CurrentVersion, state.TargetVersion, state.HeartbeatAt, now, "心跳超时,等待重连", state.Mesh, state.NextDesignRunScheduled);
+ default:
+ return state;
+ }
+}
+
+export function RunState_publish(now, mesh, state) {
+ return new LiveSnapshot(state.ProjectId, state.RunId, 3, mesh.Version, state.TargetVersion, now, now, `已发布${mesh.Label}`, mesh, false);
+}
+