Compare commits

..
20 changed files with 53 additions and 351 deletions
-4
View File
@@ -1,4 +0,0 @@
{
"monorepoCommit": "099bb9f5d64bce50b20b6cb51d5333f009b8d418",
"sourcePath": "quixos-instance/packages/web-studio-canvas-runtime"
}
-1
View File
@@ -1,4 +1,3 @@
# Generated by qx-scaffold-v1
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": 1789444178,
"narHash": "sha256-/a560j65vYLy/gcwa662cJLo09C14Kj6YjvItC+Ugfo=",
"ref": "refs/tags/quixos-reachability/6657af7ca0501454f27032141c57dd09e7ecd79c",
"rev": "6657af7ca0501454f27032141c57dd09e7ecd79c",
"revCount": 27,
"lastModified": 1788543053,
"narHash": "sha256-3YReATWEVxZinYVi/l3cwOz+oFoZUrwj24kUBQTmUpQ=",
"ref": "refs/tags/quixos-reachability/56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"rev": "56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"revCount": 8,
"type": "git",
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
},
"original": {
"ref": "refs/tags/quixos-reachability/6657af7ca0501454f27032141c57dd09e7ecd79c",
"rev": "6657af7ca0501454f27032141c57dd09e7ecd79c",
"ref": "refs/tags/quixos-reachability/56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"rev": "56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a",
"type": "git",
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
}
+1 -2
View File
@@ -6,7 +6,7 @@
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/6657af7ca0501454f27032141c57dd09e7ecd79c&rev=6657af7ca0501454f27032141c57dd09e7ecd79c";
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a&rev=56bbcd22d17f8c7f120b1e0b5bd1d5a86e91a80a";
flake = false;
};
};
@@ -18,7 +18,6 @@
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=d3d050d9cb84421fd8043ebe34fd0cae9132f6a2"
"@quixos/camino-package-runtime": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d"
},
"devDependencies": {
"@types/node": "^24",
+6 -11
View File
@@ -1,4 +1,3 @@
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";
@@ -6,15 +5,11 @@ 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 : 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;
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];
};
}
-16
View File
@@ -1,16 +0,0 @@
{
"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"
}
}
}
}
+1 -5
View File
@@ -1,10 +1,6 @@
quixos-lock version 1 {
quixos source {
repository "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git";
commit "099bb9f5d64bce50b20b6cb51d5333f009b8d418";
}
interface WebStudioCanvasPlacement source {
repository "https://repos.quixos.org/quixos-templates/interface-canvas-placement.git";
commit "025985f6ea9b15aee58aa0270ad43f0df2d97afb";
commit "9c3ab572ecfbc83785038c3d9f174516df15d63f";
}
}
-6
View File
@@ -1,6 +0,0 @@
{
"generatedBy": "qx-scaffold-v1",
"schemaVersion": 1,
"contracts": {},
"migrations": []
}
-4
View File
@@ -1,4 +0,0 @@
{
"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 -16
View File
@@ -1,12 +1,11 @@
import {
objectRef,
type QxObjectRef,
type RuntimeContext,
} from "@quixos/camino-package-runtime";
import type { Contexts } from "./gen/qx.js";
export type PlacementInput = {
canvas_id: QxObjectRef;
subject_id: QxObjectRef;
canvas_id: string;
subject_id: string;
x: number;
y: number;
width: number;
@@ -18,11 +17,10 @@ const finiteNumber = (value: unknown, fallback: number) =>
typeof value === "number" && Number.isFinite(value) ? value : fallback;
const objectId = (value: unknown, field: string) => {
try {
return objectRef(value as QxObjectRef);
} catch {
throw new Error(`${field} must be a managed object reference`);
if (typeof value !== "string" || !value.startsWith("obj:")) {
throw new Error(`${field} must be a Camino object ID`);
}
return value;
};
export const normalizePlacementInput = (
@@ -37,16 +35,19 @@ export const normalizePlacementInput = (
z: Math.trunc(finiteNumber(input.z, 0)),
});
export const createCanvas = ({ objectId }: Contexts["createCanvas"]) => objectId;
export const createCanvas = (context: RuntimeContext) =>
objectRef(context.objectId);
export const createPlacement = async (context: Contexts["createPlacement"]) => {
export const createPlacement = async (context: RuntimeContext) => {
const input = normalizePlacementInput(context.input);
await Promise.all([
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),
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),
]);
await context.ports.placement["subject.connect"](context.input.subject_id);
await context.ports.placement["canvas.connect"](context.input.canvas_id);
return context.objectId;
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);
};
-237
View File
File diff suppressed because one or more lines are too long
-2
View File
@@ -1,2 +0,0 @@
// This adapter keeps the implementation file hand-authored.
export {createCanvas as handler} from "../canvas.impl.js";
-2
View File
@@ -1,2 +0,0 @@
// This adapter keeps the implementation file hand-authored.
export {createPlacement as handler} from "../canvas.impl.js";
-10
View File
@@ -1,10 +0,0 @@
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
@@ -1,3 +0,0 @@
// Generated by qx-scaffold-v1
import {serveMigration} from "@quixos/camino-package-runtime";
await serveMigration({});
+10 -9
View File
@@ -1,9 +1,10 @@
// Generated by qx-scaffold-v1
import {servePackageRuntime} from "@quixos/camino-package-runtime";
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,
}));
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,
},
});
+5 -10
View File
@@ -1,23 +1,19 @@
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: canvas,
subject_id: subject,
canvas_id: "obj:canvas",
subject_id: "obj:subject",
x: 12.5,
y: -30,
width: 12,
height: 80,
z: 3.8,
}), {
canvas_id: canvas,
subject_id: subject,
canvas_id: "obj:canvas",
subject_id: "obj:subject",
x: 12.5,
y: -30,
width: 220,
@@ -29,7 +25,6 @@ test("placement input is bounded and normalized", () => {
test("placement input requires Camino object references", () => {
assert.throws(
() => normalizePlacementInput({ canvas_id: "canvas", subject_id: "obj:subject" }),
/canvas_id must be a managed object reference/,
/canvas_id must be a Camino object ID/,
);
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=d3d050d9cb84421fd8043ebe34fd0cae9132f6a2" = { filename = "@quixos-camino-package-runtime-https-08b8790f1a-5bde059ead.zip"; hash = "sha512-W94Fnq0rn4MyBqRUUhH0ZcTzVv9MfF59dHtwpFLhg+/jK4QG5wi/uNgRR3xEVszpN8yrBWO6uiJGlkGmNnrczA=="; };
"@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=="; };
"@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=d3d050d9cb84421fd8043ebe34fd0cae9132f6a2":
"@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d":
version: 0.1.0
resolution: "@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=d3d050d9cb84421fd8043ebe34fd0cae9132f6a2"
resolution: "@quixos/camino-package-runtime@https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d"
dependencies:
"@bufbuild/protobuf": "npm:^2.12.1"
"@connectrpc/connect": "npm:^2.1.2"
"@connectrpc/connect-node": "npm:^2.1.2"
checksum: 10c0/5bde059ead2b9f833206a4545211f465c4f356ff4c7c5e7d747b70a452e183efe32b8406e708bfb8d811477c4456cce937ccab0563baba22469641a6367adccc
checksum: 10c0/c90d5d5c5311da4fb16e491adabae1b0072b40566524064460cd21ab01b3755e5127e7e14048770448283e22f6cb1af1ba5538ce0fe3b23f014c1151a757deca
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=d3d050d9cb84421fd8043ebe34fd0cae9132f6a2"
"@quixos/camino-package-runtime": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git#commit=a998690446ecf647e3af78e369492c1a3663b66d"
"@types/node": "npm:^24"
typescript: "npm:^7.0.2"
bin: