Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3d050d9cb | |||
| e8a175504a | |||
| 62ae43ee40 | |||
| 3dd4e9a1ad | |||
| 110e41b268 | |||
| 2b7035fe81 |
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos",
|
"sourceRepo": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos",
|
||||||
"sourceCommit": "61cb9aa5a580c2846d426464228c7d1082b7021a",
|
"sourceCommit": "a9e94c961430415bcea302c47181d44ec7e2344c",
|
||||||
"sourcePath": "quixos-instance/packages/camino-package-runtime",
|
"sourcePath": "quixos-instance/packages/camino-package-runtime",
|
||||||
"exportName": "camino-package-runtime",
|
"exportName": "camino-package-runtime",
|
||||||
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git"
|
"mirrorRemote": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/camino-package-runtime.git"
|
||||||
|
|||||||
Vendored
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
import { type Value } from "./camino/api_pb.js";
|
import { type Value } from "./camino/api_pb.js";
|
||||||
import { type RuntimeHandler, type DerivedHandler } from "./index.js";
|
import { liveValue, type RuntimeHandler, type DerivedHandler } from "./index.js";
|
||||||
export type { QxObjectRef } from "./references.js";
|
export type { QxObjectRef } from "./references.js";
|
||||||
declare const watchBrand: unique symbol;
|
declare const watchBrand: unique symbol;
|
||||||
export type QxWatchHandle = string & {
|
export type QxWatchHandle = string & {
|
||||||
@@ -9,6 +9,8 @@ export type MessageBinding<T> = {
|
|||||||
encode(value: T): Value;
|
encode(value: T): Value;
|
||||||
decode(value: Value): T;
|
decode(value: Value): T;
|
||||||
};
|
};
|
||||||
|
export type QxLiveValue = ReturnType<typeof liveValue>;
|
||||||
|
export declare const opaqueReactPropsBinding: MessageBinding<Record<string, unknown>>;
|
||||||
export type BindingValue<B> = B extends MessageBinding<infer T> ? T : never;
|
export type BindingValue<B> = B extends MessageBinding<infer T> ? T : never;
|
||||||
export type QxHandler<C, O> = (context: C) => O | Promise<O>;
|
export type QxHandler<C, O> = (context: C) => O | Promise<O>;
|
||||||
export type QxDerived<C, O> = {
|
export type QxDerived<C, O> = {
|
||||||
|
|||||||
Vendored
+1
-1
@@ -1 +1 @@
|
|||||||
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAkC,KAAK,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChF,OAAO,EACgB,KAAK,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AAEpF,YAAY,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,CAAC,MAAM,UAAU,EAAE,OAAO,MAAM,CAAC;AACxC,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,CAAC,UAAU,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AACrE,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI;IAAE,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,KAAK,CAAC;IAAC,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,CAAA;CAAE,CAAC;AACrF,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI,CAAC,SAAS,cAAc,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAC5E,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAC7D,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,IAAI;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,GAAG,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;CAAE,CA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AAE,WAAW,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GAC3E;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,EAAE,CAAA;CAAE,GAClD;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAAE,GAC9E;IAAE,IAAI,EAAE,aAAa,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,WAAW,CAAA;CAAE,CAAC;AAChE,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,WAAW,CAAC;IAAC,UAAU,EAAE,WAAW,CAAC;IAAC,SAAS,CAAC,EAAE,WAAW,CAAC;IACzE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;CACnC,CAAC;AACF,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC;AAG7D,eAAO,MAAM,aAAa,SAAU,WAAW,SAAS,KAAK,GAAG,SAAS,YAAY,UAAU,KAAG,GAqCjG,CAAC;AAOF,eAAO,MAAM,aAAa,SAAU,WAAW,SAAS,GAAG,YAAY,UAAU,KAAG,KAqBnF,CAAC;AAiBF,uFAAuF;AACvF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,CAAC,QAC1B,aAAa,WAAW,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,YAAY,UAAU,KACpF,cAAc,GAAG,cA6CnB,CAAC"}
|
||||||
Vendored
+26
-3
@@ -2,6 +2,21 @@ import { create } from "@bufbuild/protobuf";
|
|||||||
import { ValueSchema, ObjectValueSchema } from "./camino/api_pb.js";
|
import { ValueSchema, ObjectValueSchema } from "./camino/api_pb.js";
|
||||||
import { derived, jsToProtoValue, liveValue, protoValueToJs } from "./index.js";
|
import { derived, jsToProtoValue, liveValue, protoValueToJs } from "./index.js";
|
||||||
import { assertReferenceFree, referenceToWire } from "./references.js";
|
import { assertReferenceFree, referenceToWire } from "./references.js";
|
||||||
|
const reactPropsDescriptor = "org.quixos.web-studio.ReactProps";
|
||||||
|
// Explicit temporary props exception, matching orch's RPC contract. Field shapes
|
||||||
|
// remain unchecked pending generics; ordinary messages and state do not gain it.
|
||||||
|
export const opaqueReactPropsBinding = {
|
||||||
|
encode(value) {
|
||||||
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
||||||
|
throw new Error("React props must be an object");
|
||||||
|
return jsToProtoValue(value);
|
||||||
|
},
|
||||||
|
decode(value) {
|
||||||
|
if (value.kind.case !== "objectValue")
|
||||||
|
throw new Error("React props must be an object");
|
||||||
|
return protoValueToJs(value);
|
||||||
|
},
|
||||||
|
};
|
||||||
export const qxDerived = (get) => ({ kind: "derived", get });
|
export const qxDerived = (get) => ({ kind: "derived", get });
|
||||||
// Conversion belongs at the binding boundary. It does not add orchestrator validation.
|
// Conversion belongs at the binding boundary. It does not add orchestrator validation.
|
||||||
export const decodeQxValue = (type, value, messages) => {
|
export const decodeQxValue = (type, value, messages) => {
|
||||||
@@ -27,8 +42,10 @@ export const decodeQxValue = (type, value, messages) => {
|
|||||||
return value.kind.value.values.map((entry) => decodeQxValue(type.value, entry, messages));
|
return value.kind.value.values.map((entry) => decodeQxValue(type.value, entry, messages));
|
||||||
}
|
}
|
||||||
if (type.kind === "message") {
|
if (type.kind === "message") {
|
||||||
|
if (type.descriptorId !== reactPropsDescriptor)
|
||||||
assertReferenceFree(protoValueToJs(value));
|
assertReferenceFree(protoValueToJs(value));
|
||||||
const decoded = requireMessage(messages, type.descriptorId).decode(value);
|
const decoded = requireMessage(messages, type.descriptorId).decode(value);
|
||||||
|
if (type.descriptorId !== reactPropsDescriptor)
|
||||||
assertReferenceFree(decoded);
|
assertReferenceFree(decoded);
|
||||||
return decoded;
|
return decoded;
|
||||||
}
|
}
|
||||||
@@ -82,9 +99,11 @@ export const encodeQxValue = (type, value, messages) => {
|
|||||||
referenceToWire(value);
|
referenceToWire(value);
|
||||||
return jsToProtoValue(value);
|
return jsToProtoValue(value);
|
||||||
}
|
}
|
||||||
|
if (type.kind !== "message" || type.descriptorId !== reactPropsDescriptor)
|
||||||
assertReferenceFree(value);
|
assertReferenceFree(value);
|
||||||
if (type.kind === "message") {
|
if (type.kind === "message") {
|
||||||
const encoded = requireMessage(messages, type.descriptorId).encode(value);
|
const encoded = requireMessage(messages, type.descriptorId).encode(value);
|
||||||
|
if (type.descriptorId !== reactPropsDescriptor)
|
||||||
assertReferenceFree(protoValueToJs(encoded));
|
assertReferenceFree(protoValueToJs(encoded));
|
||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
@@ -115,7 +134,7 @@ export const bindQxHandler = (spec, handler, messages) => {
|
|||||||
case "state": {
|
case "state": {
|
||||||
const state = raw.state(port.id);
|
const state = raw.state(port.id);
|
||||||
return [name, {
|
return [name, {
|
||||||
...(port.primitives.includes("read") ? { get: async () => decodeQxValue(port.valueType, (await state.live()).$quixosValue, messages) } : {}),
|
...(port.primitives.includes("read") ? { get: async () => decodeQxValue(port.valueType, (await state.live()).$quixosValue, messages), live: () => state.live() } : {}),
|
||||||
...(port.primitives.includes("write") ? { set: async (value) => state.set(liveValue(encodeQxValue(port.valueType, value, messages))) } : {}),
|
...(port.primitives.includes("write") ? { set: async (value) => state.set(liveValue(encodeQxValue(port.valueType, value, messages))) } : {}),
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -127,9 +146,13 @@ export const bindQxHandler = (spec, handler, messages) => {
|
|||||||
}
|
}
|
||||||
case "interface": {
|
case "interface": {
|
||||||
const target = raw.interface(port.id);
|
const target = raw.interface(port.id);
|
||||||
return [name, Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [name,
|
return [name, { objectId: target.objectId,
|
||||||
|
live: Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [name,
|
||||||
|
(input) => target.live(operation.id, inputFields(operation.inputType, input, messages)),
|
||||||
|
])),
|
||||||
|
...Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [name,
|
||||||
async (input) => decodeQxValue(operation.outputType, (await target.live(operation.id, inputFields(operation.inputType, input, messages))).$quixosValue, messages),
|
async (input) => decodeQxValue(operation.outputType, (await target.live(operation.id, inputFields(operation.inputType, input, messages))).$quixosValue, messages),
|
||||||
]))];
|
])) }];
|
||||||
}
|
}
|
||||||
case "constructor": return [name, { construct: (input) => raw.constructor(port.id).construct(inputFields(port.inputType, input, messages)) }];
|
case "constructor": return [name, { construct: (input) => raw.constructor(port.id).construct(inputFields(port.inputType, input, messages)) }];
|
||||||
}
|
}
|
||||||
|
|||||||
Vendored
+55
@@ -234,12 +234,67 @@ export type GetWorkspaceResponse = Message<"quixos.orch.GetWorkspaceResponse"> &
|
|||||||
* @generated from field: string source_root_commit = 3;
|
* @generated from field: string source_root_commit = 3;
|
||||||
*/
|
*/
|
||||||
sourceRootCommit: string;
|
sourceRootCommit: string;
|
||||||
|
/**
|
||||||
|
* Checked constructors whose wire input can be empty. Web Studio intersects
|
||||||
|
* this with its temporary Createable marker; the marker is not a factory.
|
||||||
|
*
|
||||||
|
* @generated from field: repeated string empty_input_constructible_atom_ids = 4;
|
||||||
|
*/
|
||||||
|
emptyInputConstructibleAtomIds: string[];
|
||||||
|
/**
|
||||||
|
* @generated from field: repeated quixos.orch.CapabilityInputContract capability_inputs = 5;
|
||||||
|
*/
|
||||||
|
capabilityInputs: CapabilityInputContract[];
|
||||||
|
/**
|
||||||
|
* @generated from field: repeated quixos.orch.ConstructorInputContract constructor_inputs = 6;
|
||||||
|
*/
|
||||||
|
constructorInputs: ConstructorInputContract[];
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* Describes the message quixos.orch.GetWorkspaceResponse.
|
* Describes the message quixos.orch.GetWorkspaceResponse.
|
||||||
* Use `create(GetWorkspaceResponseSchema)` to create a new message.
|
* Use `create(GetWorkspaceResponseSchema)` to create a new message.
|
||||||
*/
|
*/
|
||||||
export declare const GetWorkspaceResponseSchema: GenMessage<GetWorkspaceResponse>;
|
export declare const GetWorkspaceResponseSchema: GenMessage<GetWorkspaceResponse>;
|
||||||
|
/**
|
||||||
|
* @generated from message quixos.orch.CapabilityInputContract
|
||||||
|
*/
|
||||||
|
export type CapabilityInputContract = Message<"quixos.orch.CapabilityInputContract"> & {
|
||||||
|
/**
|
||||||
|
* @generated from field: string interface_revision_id = 1;
|
||||||
|
*/
|
||||||
|
interfaceRevisionId: string;
|
||||||
|
/**
|
||||||
|
* @generated from field: string operation_id = 2;
|
||||||
|
*/
|
||||||
|
operationId: string;
|
||||||
|
/**
|
||||||
|
* @generated from field: string type_json = 3;
|
||||||
|
*/
|
||||||
|
typeJson: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Describes the message quixos.orch.CapabilityInputContract.
|
||||||
|
* Use `create(CapabilityInputContractSchema)` to create a new message.
|
||||||
|
*/
|
||||||
|
export declare const CapabilityInputContractSchema: GenMessage<CapabilityInputContract>;
|
||||||
|
/**
|
||||||
|
* @generated from message quixos.orch.ConstructorInputContract
|
||||||
|
*/
|
||||||
|
export type ConstructorInputContract = Message<"quixos.orch.ConstructorInputContract"> & {
|
||||||
|
/**
|
||||||
|
* @generated from field: string atom_id = 1;
|
||||||
|
*/
|
||||||
|
atomId: string;
|
||||||
|
/**
|
||||||
|
* @generated from field: string type_json = 2;
|
||||||
|
*/
|
||||||
|
typeJson: string;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Describes the message quixos.orch.ConstructorInputContract.
|
||||||
|
* Use `create(ConstructorInputContractSchema)` to create a new message.
|
||||||
|
*/
|
||||||
|
export declare const ConstructorInputContractSchema: GenMessage<ConstructorInputContract>;
|
||||||
/**
|
/**
|
||||||
* @generated from message quixos.orch.ListActivationsRequest
|
* @generated from message quixos.orch.ListActivationsRequest
|
||||||
*/
|
*/
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+21
-11
File diff suppressed because one or more lines are too long
Generated
+7
-7
@@ -74,17 +74,17 @@
|
|||||||
"nixpkgs": "nixpkgs_2"
|
"nixpkgs": "nixpkgs_2"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1789328055,
|
"lastModified": 1789426470,
|
||||||
"narHash": "sha256-tZVGOpDnT80j3roNQXpCxw8BxNZxqVutclxr49Vhg4w=",
|
"narHash": "sha256-THZZ+S5Uxi2yRw5NwIfyGNn5IUJiVe9qb4271e4loD4=",
|
||||||
"ref": "refs/tags/quixos-reachability/9867bf4552c09ee71ebeefe08e652fd870894130",
|
"ref": "refs/tags/quixos-reachability/c16271510afaab9b3972b82e6936aa4c5edf790f",
|
||||||
"rev": "9867bf4552c09ee71ebeefe08e652fd870894130",
|
"rev": "c16271510afaab9b3972b82e6936aa4c5edf790f",
|
||||||
"revCount": 45,
|
"revCount": 57,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"ref": "refs/tags/quixos-reachability/9867bf4552c09ee71ebeefe08e652fd870894130",
|
"ref": "refs/tags/quixos-reachability/c16271510afaab9b3972b82e6936aa4c5edf790f",
|
||||||
"rev": "9867bf4552c09ee71ebeefe08e652fd870894130",
|
"rev": "c16271510afaab9b3972b82e6936aa4c5edf790f",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||||
flake-utils.url = "github:numtide/flake-utils";
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
quixos-protocol.url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git?ref=refs/tags/quixos-reachability/9867bf4552c09ee71ebeefe08e652fd870894130&rev=9867bf4552c09ee71ebeefe08e652fd870894130";
|
quixos-protocol.url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git?ref=refs/tags/quixos-reachability/c16271510afaab9b3972b82e6936aa4c5edf790f&rev=c16271510afaab9b3972b82e6936aa4c5edf790f";
|
||||||
quixosNixHelpers = {
|
quixosNixHelpers = {
|
||||||
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/7177130c0365f2fa58ea4877366e1c5d17db4c01&rev=7177130c0365f2fa58ea4877366e1c5d17db4c01";
|
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/7177130c0365f2fa58ea4877366e1c5d17db4c01&rev=7177130c0365f2fa58ea4877366e1c5d17db4c01";
|
||||||
flake = false;
|
flake = false;
|
||||||
|
|||||||
+25
-7
@@ -8,6 +8,20 @@ import { assertReferenceFree, referenceToWire } from "./references.js";
|
|||||||
declare const watchBrand: unique symbol;
|
declare const watchBrand: unique symbol;
|
||||||
export type QxWatchHandle = string & { readonly [watchBrand]: true };
|
export type QxWatchHandle = string & { readonly [watchBrand]: true };
|
||||||
export type MessageBinding<T> = { encode(value: T): Value; decode(value: Value): T };
|
export type MessageBinding<T> = { encode(value: T): Value; decode(value: Value): T };
|
||||||
|
export type QxLiveValue = ReturnType<typeof liveValue>;
|
||||||
|
const reactPropsDescriptor = "org.quixos.web-studio.ReactProps";
|
||||||
|
// Explicit temporary props exception, matching orch's RPC contract. Field shapes
|
||||||
|
// remain unchecked pending generics; ordinary messages and state do not gain it.
|
||||||
|
export const opaqueReactPropsBinding: MessageBinding<Record<string, unknown>> = {
|
||||||
|
encode(value) {
|
||||||
|
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("React props must be an object");
|
||||||
|
return jsToProtoValue(value);
|
||||||
|
},
|
||||||
|
decode(value) {
|
||||||
|
if (value.kind.case !== "objectValue") throw new Error("React props must be an object");
|
||||||
|
return protoValueToJs(value) as Record<string, unknown>;
|
||||||
|
},
|
||||||
|
};
|
||||||
export type BindingValue<B> = B extends MessageBinding<infer T> ? T : never;
|
export type BindingValue<B> = B extends MessageBinding<infer T> ? T : never;
|
||||||
export type QxHandler<C, O> = (context: C) => O | Promise<O>;
|
export type QxHandler<C, O> = (context: C) => O | Promise<O>;
|
||||||
export type QxDerived<C, O> = { kind: "derived"; get: QxHandler<C, O> };
|
export type QxDerived<C, O> = { kind: "derived"; get: QxHandler<C, O> };
|
||||||
@@ -52,9 +66,9 @@ export const decodeQxValue = (type: QxValueType, value: Value | undefined, messa
|
|||||||
return value.kind.value.values.map((entry) => decodeQxValue(type.value, entry, messages));
|
return value.kind.value.values.map((entry) => decodeQxValue(type.value, entry, messages));
|
||||||
}
|
}
|
||||||
if (type.kind === "message") {
|
if (type.kind === "message") {
|
||||||
assertReferenceFree(protoValueToJs(value));
|
if (type.descriptorId !== reactPropsDescriptor) assertReferenceFree(protoValueToJs(value));
|
||||||
const decoded = requireMessage(messages, type.descriptorId).decode(value);
|
const decoded = requireMessage(messages, type.descriptorId).decode(value);
|
||||||
assertReferenceFree(decoded);
|
if (type.descriptorId !== reactPropsDescriptor) assertReferenceFree(decoded);
|
||||||
return decoded;
|
return decoded;
|
||||||
}
|
}
|
||||||
if (type.kind === "object-ref") {
|
if (type.kind === "object-ref") {
|
||||||
@@ -94,10 +108,10 @@ export const encodeQxValue = (type: QxValueType, value: any, messages: QxMessage
|
|||||||
if (type.kind === "optional") return value === null ? jsToProtoValue(null) : encodeQxValue(type.value, value, messages);
|
if (type.kind === "optional") return value === null ? jsToProtoValue(null) : encodeQxValue(type.value, value, messages);
|
||||||
if (type.kind === "list") return jsToProtoValue(value.map((entry: unknown) => liveValue(encodeQxValue(type.value, entry, messages))));
|
if (type.kind === "list") return jsToProtoValue(value.map((entry: unknown) => liveValue(encodeQxValue(type.value, entry, messages))));
|
||||||
if (type.kind === "object-ref") { referenceToWire(value); return jsToProtoValue(value); }
|
if (type.kind === "object-ref") { referenceToWire(value); return jsToProtoValue(value); }
|
||||||
assertReferenceFree(value);
|
if (type.kind !== "message" || type.descriptorId !== reactPropsDescriptor) assertReferenceFree(value);
|
||||||
if (type.kind === "message") {
|
if (type.kind === "message") {
|
||||||
const encoded = requireMessage(messages, type.descriptorId).encode(value);
|
const encoded = requireMessage(messages, type.descriptorId).encode(value);
|
||||||
assertReferenceFree(protoValueToJs(encoded));
|
if (type.descriptorId !== reactPropsDescriptor) assertReferenceFree(protoValueToJs(encoded));
|
||||||
return encoded;
|
return encoded;
|
||||||
}
|
}
|
||||||
return jsToProtoValue(value);
|
return jsToProtoValue(value);
|
||||||
@@ -128,7 +142,7 @@ export const bindQxHandler = <C, O>(
|
|||||||
case "state": {
|
case "state": {
|
||||||
const state = raw.state(port.id);
|
const state = raw.state(port.id);
|
||||||
return [name, {
|
return [name, {
|
||||||
...(port.primitives.includes("read") ? { get: async () => decodeQxValue(port.valueType, (await state.live()).$quixosValue, messages) } : {}),
|
...(port.primitives.includes("read") ? { get: async () => decodeQxValue(port.valueType, (await state.live()).$quixosValue, messages), live: () => state.live() } : {}),
|
||||||
...(port.primitives.includes("write") ? { set: async (value: unknown) => state.set(liveValue(encodeQxValue(port.valueType, value, messages))) } : {}),
|
...(port.primitives.includes("write") ? { set: async (value: unknown) => state.set(liveValue(encodeQxValue(port.valueType, value, messages))) } : {}),
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
@@ -140,10 +154,14 @@ export const bindQxHandler = <C, O>(
|
|||||||
}
|
}
|
||||||
case "interface": {
|
case "interface": {
|
||||||
const target = raw.interface(port.id);
|
const target = raw.interface(port.id);
|
||||||
return [name, Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [name,
|
return [name, {objectId: target.objectId,
|
||||||
|
live: Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [name,
|
||||||
|
(input: unknown) => target.live(operation.id, inputFields(operation.inputType, input, messages)),
|
||||||
|
])),
|
||||||
|
...Object.fromEntries(Object.entries(port.operations).map(([name, operation]) => [name,
|
||||||
async (input: unknown) => decodeQxValue(operation.outputType,
|
async (input: unknown) => decodeQxValue(operation.outputType,
|
||||||
(await target.live(operation.id, inputFields(operation.inputType, input, messages))).$quixosValue, messages),
|
(await target.live(operation.id, inputFields(operation.inputType, input, messages))).$quixosValue, messages),
|
||||||
]))];
|
]))}];
|
||||||
}
|
}
|
||||||
case "constructor": return [name, { construct: (input: unknown) => raw.constructor(port.id).construct(inputFields(port.inputType, input, messages)) }];
|
case "constructor": return [name, { construct: (input: unknown) => raw.constructor(port.id).construct(inputFields(port.inputType, input, messages)) }];
|
||||||
}
|
}
|
||||||
|
|||||||
+78
-11
File diff suppressed because one or more lines are too long
+18
-2
@@ -1,9 +1,22 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
import test from "node:test";
|
import test from "node:test";
|
||||||
import { referenceFromWire } from "../dist/references.js";
|
import { referenceFromWire } from "../dist/references.js";
|
||||||
import { bindQxHandler, decodeQxValue, encodeQxValue, jsToProtoValue, liveValue, protoValueToJs } from "../dist/index.js";
|
import { bindQxHandler, decodeQxValue, encodeQxValue, jsToProtoValue, liveValue, protoValueToJs, opaqueReactPropsBinding } from "../dist/index.js";
|
||||||
const scalar = (name) => ({ kind: "scalar", name });
|
const scalar = (name) => ({ kind: "scalar", name });
|
||||||
const unit = { kind: "builtin", name: "unit" };
|
const unit = { kind: "builtin", name: "unit" };
|
||||||
|
test("opaque React props retain managed references while ordinary messages remain closed", () => {
|
||||||
|
const descriptorId = "org.quixos.web-studio.ReactProps";
|
||||||
|
const reference = referenceFromWire("obj:task");
|
||||||
|
const type = {kind: "message", descriptorId};
|
||||||
|
const messages = {[descriptorId]: opaqueReactPropsBinding};
|
||||||
|
const decoded = decodeQxValue(type, encodeQxValue(type, {subject: reference, title: "Task"}, messages), messages);
|
||||||
|
assert.ok(decoded.subject.equals(reference));
|
||||||
|
assert.equal(decoded.title, "Task");
|
||||||
|
assert.throws(() => opaqueReactPropsBinding.encode(null), /object/);
|
||||||
|
assert.throws(() => opaqueReactPropsBinding.encode([]), /object/);
|
||||||
|
assert.throws(() => encodeQxValue({kind: "message", descriptorId: "Ordinary"}, {subject: reference},
|
||||||
|
{Ordinary: opaqueReactPropsBinding}), /Managed references/);
|
||||||
|
});
|
||||||
test("declared record inputs preserve opaque references without opening message codecs", async () => {
|
test("declared record inputs preserve opaque references without opening message codecs", async () => {
|
||||||
const target = referenceFromWire("obj:board");
|
const target = referenceFromWire("obj:board");
|
||||||
const type = {kind: "record", fields: {
|
const type = {kind: "record", fields: {
|
||||||
@@ -77,6 +90,9 @@ test("typed state and interface ports preserve declared values and exact operati
|
|||||||
const handler = bindQxHandler(spec, async ({ input, ports }) => {
|
const handler = bindQxHandler(spec, async ({ input, ports }) => {
|
||||||
assert.equal(input, 2n ** 60n);
|
assert.equal(input, 2n ** 60n);
|
||||||
assert.equal(await ports.data.get(), 9n);
|
assert.equal(await ports.data.get(), 9n);
|
||||||
|
assert.deepEqual((await ports.data.live()).$quixosValue, jsToProtoValue(9n));
|
||||||
|
assert.ok(ports.reader.objectId.equals(referenceFromWire("obj:reader")));
|
||||||
|
assert.deepEqual((await ports.reader.live["payload.get"]()).$quixosValue, jsToProtoValue(new Uint8Array([7])));
|
||||||
await ports.data.set(input);
|
await ports.data.set(input);
|
||||||
return ports.reader["payload.get"]();
|
return ports.reader["payload.get"]();
|
||||||
}, {});
|
}, {});
|
||||||
@@ -84,7 +100,7 @@ test("typed state and interface ports preserve declared values and exact operati
|
|||||||
state: (id) => { assert.equal(id, "state-id"); return {
|
state: (id) => { assert.equal(id, "state-id"); return {
|
||||||
live: async () => liveValue(jsToProtoValue(9n)), set: async (value) => { written = value; },
|
live: async () => liveValue(jsToProtoValue(9n)), set: async (value) => { written = value; },
|
||||||
}; },
|
}; },
|
||||||
interface: (id) => { assert.equal(id, "interface-id"); return { live: async (operation, input) => {
|
interface: (id) => { assert.equal(id, "interface-id"); return { objectId: referenceFromWire("obj:reader"), live: async (operation, input) => {
|
||||||
assert.equal(operation, "get-id"); assert.deepEqual(input, {}); return liveValue(jsToProtoValue(new Uint8Array([7])));
|
assert.equal(operation, "get-id"); assert.deepEqual(input, {}); return liveValue(jsToProtoValue(new Uint8Array([7])));
|
||||||
} }; },
|
} }; },
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user