2026-09-14 23:38:07 -07:00
|
|
|
/** One authoring contract, distributed by scaffolding and immutable codegen.
|
|
|
|
|
* Web Studio checks its concrete exports against this contract during its build. */
|
|
|
|
|
export const reactPlatformTypes = `// Generated by the Quixos React platform contract. Do not edit.
|
|
|
|
|
declare module "@quixos/web-studio-react-runtime" {
|
|
|
|
|
import type * as React from "react";
|
|
|
|
|
export function useComponentOverlayContainer(): HTMLElement;
|
|
|
|
|
export function useComponentStyleRoot(): ShadowRoot;
|
|
|
|
|
export type ObjectRef<AtomId extends string> = string & {
|
|
|
|
|
readonly $quixosAtom: AtomId;
|
|
|
|
|
};
|
2026-09-16 11:25:20 -07:00
|
|
|
export type FieldCapability = {objectId: string; interfaceRevisionId: string; getOperationId: string; watchOperationId?: string; setOperationId?: string; inputKind?: "fields" | "value"};
|
|
|
|
|
export type ReadableField<T> = {readonly value?: T; readonly capability: FieldCapability};
|
|
|
|
|
/** set(T) uses the resolved capability: native CRDT fields send incremental edits;
|
|
|
|
|
* custom/manual setters receive semantic values. Storage provenance grants no authority. */
|
|
|
|
|
export type WritableField<T> = ReadableField<T> & {readonly $writeType?: (value: T) => T; readonly writable: true; readonly capability: FieldCapability & {setOperationId: string}};
|
|
|
|
|
export type LiveFieldProp<T> = ReadableField<T>;
|
|
|
|
|
export type InterfaceReference<I extends string, Fields> = {readonly $quixosRef: string; readonly interfaceRevisionId: I; readonly fields: Fields};
|
2026-09-17 11:29:56 -07:00
|
|
|
const conformanceView: unique symbol;
|
|
|
|
|
export type ReactInterfaceContract<View> = {readonly interfaceRevisionId: string; readonly [conformanceView]: (view: View) => View};
|
|
|
|
|
export function defineReactInterfaceContract<View>(interfaceRevisionId: string, interfaces: unknown): ReactInterfaceContract<View>;
|
|
|
|
|
export function tryConform<View>(object: string | {readonly $quixosRef: string}, contract: ReactInterfaceContract<View>, options?: {signal?: AbortSignal}): Promise<View | undefined>;
|
|
|
|
|
export type ConformanceResult<View> = {status: "loading"} | {status: "absent"} | {status: "available"; view: View} | {status: "error"; error: Error};
|
|
|
|
|
export function useTryConform<View>(object: string | {readonly $quixosRef: string}, contract: ReactInterfaceContract<View>): ConformanceResult<View>;
|
2026-09-14 23:38:07 -07:00
|
|
|
export type ReactComponentHostProps<Action> = {
|
|
|
|
|
onAction?: (action: Action) => void;
|
|
|
|
|
fallback?: React.ReactNode;
|
|
|
|
|
className?: string;
|
|
|
|
|
style?: React.CSSProperties;
|
2026-09-15 17:27:38 -07:00
|
|
|
/** Optional extra action. The host still displays and reports errors by default. */
|
|
|
|
|
extraErrorAction?: (error: Error) => void;
|
2026-09-14 23:38:07 -07:00
|
|
|
};
|
|
|
|
|
export type ReactComponentImplementationProps<CaminoProps, RenderProps, Action> = {
|
|
|
|
|
camino: CaminoProps;
|
|
|
|
|
render: RenderProps;
|
|
|
|
|
dispatch: (action: Action) => void;
|
|
|
|
|
};
|
|
|
|
|
export const createWebStudioComponent: <
|
|
|
|
|
ForObject extends ObjectRef<string>, RenderProps extends object, Action,
|
|
|
|
|
>(config: { expectedAtomId: string }) => (props: {
|
|
|
|
|
forObject: ForObject;
|
|
|
|
|
} & RenderProps & ReactComponentHostProps<Action>) => any;
|
|
|
|
|
export const invokeCapability: <Result = unknown>(
|
|
|
|
|
objectId: string,
|
|
|
|
|
interfaceRevisionId: string,
|
|
|
|
|
operationId: string,
|
|
|
|
|
value?: unknown,
|
2026-09-15 17:27:38 -07:00
|
|
|
options?: {clientMutationId?: string; signal?: AbortSignal},
|
2026-09-14 23:38:07 -07:00
|
|
|
) => Promise<Result>;
|
|
|
|
|
export const h: typeof React.createElement;
|
2026-09-16 11:25:20 -07:00
|
|
|
export function useLiveField<T>(field: ReadableField<T>, options: {write: (value: T) => Promise<void>}): readonly [T, (value: T) => Promise<void>];
|
|
|
|
|
export function useLiveField<T>(field: WritableField<T>): readonly [T, (value: T) => Promise<void>];
|
|
|
|
|
export function useLiveField<T>(field: ReadableField<T>): readonly [T];
|
2026-09-14 23:38:07 -07:00
|
|
|
}
|
|
|
|
|
`;
|