Compare commits

..
20 changed files with 397 additions and 72 deletions
+4
View File
@@ -0,0 +1,4 @@
{
"monorepoCommit": "4c88728f144add3457b4273d4b9a04ee53c53be3",
"sourcePath": "quixos-instance/packages/web-studio-canvas-runtime"
}
+1
View File
@@ -1,3 +1,4 @@
# Generated from the checked package contract
package_id: "package:org.quixos.web-studio:canvas-runtime"
package_revision_id: "package:org.quixos.web-studio:canvas-runtime@1"
runtime_protocol_version: "quixos-capabilities-v1"
Generated
+7 -7
View File
@@ -37,17 +37,17 @@
"quixosNixHelpers": {
"flake": false,
"locked": {
"lastModified": 1788543053,
"narHash": "sha256-3YReATWEVxZinYVi/l3cwOz+oFoZUrwj24kUBQTmUpQ=",
"ref": "refs/tags/quixos-reachability/56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"rev": "56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"revCount": 8,
"lastModified": 1789602549,
"narHash": "sha256-DD66dQ3dzEvG13Zju/4sVSV4pnktSUkJ/Rbr1KkHMdg=",
"ref": "refs/tags/quixos-reachability/e2747066ca7d9d001dcb5dd936e17969ed88fc5f",
"rev": "e2747066ca7d9d001dcb5dd936e17969ed88fc5f",
"revCount": 32,
"type": "git",
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
},
"original": {
"ref": "refs/tags/quixos-reachability/56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"rev": "56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"ref": "refs/tags/quixos-reachability/e2747066ca7d9d001dcb5dd936e17969ed88fc5f",
"rev": "e2747066ca7d9d001dcb5dd936e17969ed88fc5f",
"type": "git",
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
}
+9 -2
View File
@@ -6,18 +6,25 @@
flake-utils.url = "github:numtide/flake-utils";
quixosNixHelpers = {
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a&rev=56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a";
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/e2747066ca7d9d001dcb5dd936e17969ed88fc5f&rev=e2747066ca7d9d001dcb5dd936e17969ed88fc5f";
flake = false;
};
};
outputs = inputs@{ nixpkgs, flake-utils, quixosNixHelpers, ... }:
outputs =
inputs@{
nixpkgs,
flake-utils,
quixosNixHelpers,
...
}:
let
quixosHelpers = import "${quixosNixHelpers}/quixos-package-helpers.nix";
in
quixosHelpers.mkCaminoTsYarnNixifyFlake {
inherit inputs nixpkgs flake-utils;
packageRoot = ./.;
migrationEntrypoint = "dist/migrate.js";
promptName = "web-studio-canvas-runtime";
bundle = {
entry = "dist/server.js";
+1 -1
View File
@@ -13,7 +13,7 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"@quixos/camino-package-runtime": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d"
"@quixos/camino-package-runtime": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=446fd4e36e9700cf27ce20b472a8d512133e9370"
},
"devDependencies": {
"@types/node": "^24",
+11 -6
View File
@@ -1,3 +1,4 @@
import interface WebStudioCanvasPlacement;
external atom WebStudioCanvas id "atom:org.quixos.web-studio:canvas";
external atom WebStudioCanvasPlacement id "atom:org.quixos.web-studio:canvas-placement";
external interface WebStudioCanvasInterface revision "interface:org.quixos.web-studio.canvas@1";
@@ -5,11 +6,15 @@ external interface WebStudioPlaceable revision "interface:org.quixos.web-studio.
package WebStudioCanvasRuntime id "package:org.quixos.web-studio:canvas-runtime" revision "package:org.quixos.web-studio:canvas-runtime@1" {
constructor createCanvas id "export:org.quixos.web-studio.canvas-runtime:create-canvas" constructs WebStudioCanvas : unit;
constructor createPlacement id "export:org.quixos.web-studio.canvas-runtime:create-placement" constructs WebStudioCanvasPlacement : message "org.quixos.web-studio.CreateCanvasPlacement" requires {
state position id "port:web-studio-placement-constructor:position" : message "org.quixos.web-studio.CanvasPosition" [write];
state size id "port:web-studio-placement-constructor:size" : message "org.quixos.web-studio.CanvasSize" [write];
state z id "port:web-studio-placement-constructor:z" : int32 [write];
edge canvas id "port:web-studio-placement-constructor:canvas" : exactly-one interface WebStudioCanvasInterface [connect];
edge subject id "port:web-studio-placement-constructor:subject" : exactly-one interface WebStudioPlaceable [connect];
constructor createPlacement id "export:org.quixos.web-studio.canvas-runtime:create-placement" constructs WebStudioCanvasPlacement : record {
canvas_id: interface-ref<WebStudioCanvasInterface>;
subject_id: interface-ref<WebStudioPlaceable>;
x: double;
y: double;
width: double;
height: double;
z: int32;
} requires {
interface placement id "port:web-studio-placement-constructor:placement" : WebStudioCanvasPlacement;
};
}
+16
View File
@@ -0,0 +1,16 @@
{
"backend": "typescript",
"bindingOutput": "src/gen/qx.ts",
"options": {
"messages": {
"org.quixos.web-studio.CanvasPosition": {
"module": "../messages.js",
"export": "positionBinding"
},
"org.quixos.web-studio.CanvasSize": {
"module": "../messages.js",
"export": "sizeBinding"
}
}
}
}
+5 -1
View File
@@ -1,6 +1,10 @@
quixos-lock version 1 {
quixos source {
repository "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git";
commit "9c3ab572ecfbc83785038c3d9f174516df15d63f";
commit "4c88728f144add3457b4273d4b9a04ee53c53be3";
}
interface WebStudioCanvasPlacement source {
repository "https://repos.quixos.org/quixos-templates/interface-canvas-placement.git";
commit "5785ced8b4f6220b50d6c1a5ccfc4f7a14bcb911";
}
}
+6
View File
@@ -0,0 +1,6 @@
{
"generatedBy": "qx-scaffold-v1",
"schemaVersion": 1,
"contracts": {},
"migrations": []
}
+4
View File
@@ -0,0 +1,4 @@
{
"generatedBy": "qx-scaffold-v1",
"nixifyPluginUrl": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/yarn-plugin-nixify-patched/raw/commit/4528fdd20b30d869262443b3f044549810e75fb8/dist/yarn-plugin-nixify.js"
}
+17 -23
View File
@@ -1,11 +1,9 @@
import {
objectRef,
type RuntimeContext,
} from "@quixos/camino-package-runtime";
import { objectRef, type QxObjectRef } from "@quixos/camino-package-runtime";
import type { Contexts } from "./gen/qx.js";
export type PlacementInput = {
canvas_id: string;
subject_id: string;
canvas_id: QxObjectRef;
subject_id: QxObjectRef;
x: number;
y: number;
width: number;
@@ -17,15 +15,14 @@ const finiteNumber = (value: unknown, fallback: number) =>
typeof value === "number" && Number.isFinite(value) ? value : fallback;
const objectId = (value: unknown, field: string) => {
if (typeof value !== "string" || !value.startsWith("obj:")) {
throw new Error(`${field} must be a Camino object ID`);
try {
return objectRef(value as QxObjectRef);
} catch {
throw new Error(`${field} must be a managed object reference`);
}
return value;
};
export const normalizePlacementInput = (
input: Record<string, unknown>,
): PlacementInput => ({
export const normalizePlacementInput = (input: Record<string, unknown>): PlacementInput => ({
canvas_id: objectId(input.canvas_id, "canvas_id"),
subject_id: objectId(input.subject_id, "subject_id"),
x: finiteNumber(input.x, 0),
@@ -35,19 +32,16 @@ export const normalizePlacementInput = (
z: Math.trunc(finiteNumber(input.z, 0)),
});
export const createCanvas = (context: RuntimeContext) =>
objectRef(context.objectId);
export const createCanvas = ({ objectId }: Contexts["createCanvas"]) => objectId;
export const createPlacement = async (context: RuntimeContext) => {
export const createPlacement = async (context: Contexts["createPlacement"]) => {
const input = normalizePlacementInput(context.input);
await Promise.all([
context.state<{ x: number; y: number }>("port:web-studio-placement-constructor:position")
.set({ x: input.x, y: input.y }),
context.state<{ width: number; height: number }>("port:web-studio-placement-constructor:size")
.set({ width: input.width, height: input.height }),
context.state<number>("port:web-studio-placement-constructor:z").set(input.z),
context.ports.placement["position.set"]({ x: input.x, y: input.y }),
context.ports.placement["size.set"]({ width: input.width, height: input.height }),
context.ports.placement["z.set"](input.z),
]);
await context.edge("port:web-studio-placement-constructor:subject").connect(input.subject_id);
await context.edge("port:web-studio-placement-constructor:canvas").connect(input.canvas_id);
return objectRef(context.objectId);
await context.ports.placement["subject.connect"](context.input.subject_id);
await context.ports.placement["canvas.connect"](context.input.canvas_id);
return context.objectId;
};
+246
View File
File diff suppressed because one or more lines are too long
+2
View File
@@ -0,0 +1,2 @@
// This adapter keeps the implementation file hand-authored.
export { createCanvas as handler } from "../canvas.impl.js";
+2
View File
@@ -0,0 +1,2 @@
// This adapter keeps the implementation file hand-authored.
export { createPlacement as handler } from "../canvas.impl.js";
+18
View File
@@ -0,0 +1,18 @@
import { encodeQxValue, decodeQxValue, type MessageBinding, type QxValueType } from "@quixos/camino-package-runtime";
const position: QxValueType = {
kind: "record",
fields: { x: { kind: "scalar", name: "double" }, y: { kind: "scalar", name: "double" } },
};
const size: QxValueType = {
kind: "record",
fields: { width: { kind: "scalar", name: "double" }, height: { kind: "scalar", name: "double" } },
};
export const positionBinding: MessageBinding<{ x: number; y: number }> = {
encode: (value) => encodeQxValue(position, value, {}),
decode: (value) => decodeQxValue(position, value, {}),
};
export const sizeBinding: MessageBinding<{ width: number; height: number }> = {
encode: (value) => encodeQxValue(size, value, {}),
decode: (value) => decodeQxValue(size, value, {}),
};
+3
View File
@@ -0,0 +1,3 @@
// Generated by qx-scaffold-v1
import { serveMigration } from "@quixos/camino-package-runtime";
await serveMigration({});
+10 -9
View File
@@ -1,10 +1,11 @@
// Generated by qx-scaffold-v1
import { servePackageRuntime } from "@quixos/camino-package-runtime";
import { createCanvas, createPlacement } from "./canvas.impl.js";
servePackageRuntime({
packageRevisionId: "package:org.quixos.web-studio:canvas-runtime@1",
exports: {
"export:org.quixos.web-studio.canvas-runtime:create-canvas": createCanvas,
"export:org.quixos.web-studio.canvas-runtime:create-placement": createPlacement,
},
});
import { createRuntime } from "./gen/qx.js";
import { handler as impl0 } from "./impl/createCanvas.js";
import { handler as impl1 } from "./impl/createPlacement.js";
servePackageRuntime(
createRuntime({
createCanvas: impl0,
createPlacement: impl1,
}),
);
+30 -18
View File
@@ -1,30 +1,42 @@
import assert from "node:assert/strict";
import test from "node:test";
import { normalizePlacementInput } from "../dist/canvas.impl.js";
import { protoValueToJs } from "@quixos/camino-package-runtime";
const reference = (objectId) => protoValueToJs({ kind: { case: "refValue", value: { objectId } } });
const canvas = reference("obj:canvas"),
subject = reference("obj:subject");
test("placement input is bounded and normalized", () => {
assert.deepEqual(normalizePlacementInput({
canvas_id: "obj:canvas",
subject_id: "obj:subject",
x: 12.5,
y: -30,
width: 12,
height: 80,
z: 3.8,
}), {
canvas_id: "obj:canvas",
subject_id: "obj:subject",
x: 12.5,
y: -30,
width: 220,
height: 150,
z: 3,
});
assert.deepEqual(
normalizePlacementInput({
canvas_id: canvas,
subject_id: subject,
x: 12.5,
y: -30,
width: 12,
height: 80,
z: 3.8,
}),
{
canvas_id: canvas,
subject_id: subject,
x: 12.5,
y: -30,
width: 220,
height: 150,
z: 3,
},
);
});
test("placement input requires Camino object references", () => {
assert.throws(
() => normalizePlacementInput({ canvas_id: "canvas", subject_id: "obj:subject" }),
/canvas_id must be a Camino object ID/,
/canvas_id must be a managed object reference/,
);
assert.throws(
() => normalizePlacementInput({ canvas_id: "obj:canvas", subject_id: subject }),
/managed object reference/,
);
});
+1 -1
View File
@@ -159,7 +159,7 @@ cacheEntries = {
"@bufbuild/protobuf@npm:2.14.1" = { filename = "@bufbuild-protobuf-npm-2.14.1-78e9ea56a2-3f913aca03.zip"; hash = "sha512-P5E6ygPfhBnEsh2ADqVNf2yDalND5l1vaGJ57DVmxJB3KZOO8vlKXifZLo0/StzW4CcRi6Kbp2TSHhxjfN3HAg=="; };
"@connectrpc/connect-node@npm:2.1.2" = { filename = "@connectrpc-connect-node-npm-2.1.2-021434d5d5-ba8b0c9384.zip"; hash = "sha512-uosMk4TDgps3eqeoJtwM1Qpgk1J9LscBRgSRKDYzbqlgSitazqQrEEd/i+RWnknd7WbKD8d/X1sCcDXgKeE+qQ=="; };
"@connectrpc/connect@npm:2.1.2" = { filename = "@connectrpc-connect-npm-2.1.2-ab34825de3-4e15000890.zip"; hash = "sha512-ThUACJAjt1Lv1E+pQKWuHh+gDhvrxLoM7ScruTWSDYw7hbd0UOZErUQruMqaJ1sMFxNviWuo7/A2F4Ex2wHWFQ=="; };
"@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d" = { filename = "@quixos-camino-package-runtime-https-683bcbf33c-c90d5d5c53.zip"; hash = "sha512-yQ1dXFMR2k+xbkka2rrhsAcrQFZlJAZEYM0hqwGzdV5RJ+fhQEh3BEgoPiL2yxrxulU4zg/jsj8BTBFRp1feyg=="; };
"@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=446fd4e36e9700cf27ce20b472a8d512133e9370" = { filename = "@quixos-camino-package-runtime-https-84d8fd5109-6d173f9220.zip"; hash = "sha512-bRc/kiD/ODsJqBNX4+RTqdsczILibHLhB+X8MckDCoK+j32c4Hszh87obb1Rwjb5o35aI0fzArQqCwK270zzlw=="; };
"@types/node@npm:24.13.3" = { filename = "@types-node-npm-24.13.3-b512a0bbeb-a5bc08f49b.zip"; hash = "sha512-pbwI9JuVgdzcqQ4CzXcZejx5mECAdmSULlzVFhpVPU0q6AZPfjKUQQ10jX0Ji1wYSL5/pQwG8pxBk6sWvk5Z6w=="; };
"@typescript/typescript-linux-arm64@npm:7.0.2" = { filename = "@typescript-typescript-linux-arm64-npm-7.0.2-9cacfc53a0-10c0.zip"; hash = "sha512-s4c7nGT/lQIw6x0IfrL0b3ECy/D0g7UoDLdiIWJoM6EGXk5N/dmXdxUdA8Cr3hV/3nO2BYKTQ6Ai8/zGhiSQ3A=="; };
"@typescript/typescript-linux-x64@npm:7.0.2" = { filename = "@typescript-typescript-linux-x64-npm-7.0.2-8dd7ff8d24-10c0.zip"; hash = "sha512-k9EUK5CZ3OOPnyslp8SAAonHJpnpPmlaulppI/NmFyCzNs3UN/TLPUkyQia3KIxgbyTzKoXI5L5fl8Uj9bJ7Cg=="; };
+4 -4
View File
@@ -31,14 +31,14 @@ __metadata:
languageName: node
linkType: hard
"@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d":
"@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=446fd4e36e9700cf27ce20b472a8d512133e9370":
version: 0.1.0
resolution: "@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d"
resolution: "@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=446fd4e36e9700cf27ce20b472a8d512133e9370"
dependencies:
"@bufbuild/protobuf": "npm:^2.12.1"
"@connectrpc/connect": "npm:^2.1.2"
"@connectrpc/connect-node": "npm:^2.1.2"
checksum: 10c0/c90d5d5c5311da4fb16e491adabae1b0072b40566524064460cd21ab01b3755e5127e7e14048770448283e22f6cb1af1ba5538ce0fe3b23f014c1151a757deca
checksum: 10c0/6d173f9220ff383b09a81357e3e453a9db1ccc82e26c72e107e5fc31c9030a82be8f7d9ce07b3387cee86dbd51c236f9a37e5a2347f302b42a0b02b6ef4cf397
languageName: node
linkType: hard
@@ -46,7 +46,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@quixos/web-studio-canvas-runtime@workspace:."
dependencies:
"@quixos/camino-package-runtime": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d"
"@quixos/camino-package-runtime": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=446fd4e36e9700cf27ce20b472a8d512133e9370"
"@types/node": "npm:^24"
typescript: "npm:^7.0.2"
bin: