64 lines
2.2 KiB
TypeScript
64 lines
2.2 KiB
TypeScript
/** 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;
|
|
};
|
|
export type LiveFieldProp<T> = {
|
|
value: T;
|
|
source: {
|
|
objectId: string;
|
|
slotId: string;
|
|
valueType?: string;
|
|
storagePolicy?: string;
|
|
revision?: string | number | bigint;
|
|
crdtSnapshot?: {
|
|
type: string;
|
|
encoding: string;
|
|
payload: string;
|
|
};
|
|
};
|
|
};
|
|
export type ReactComponentHostProps<Action> = {
|
|
onAction?: (action: Action) => void;
|
|
fallback?: React.ReactNode;
|
|
className?: string;
|
|
style?: React.CSSProperties;
|
|
/** Optional extra action. The host still displays and reports errors by default. */
|
|
extraErrorAction?: (error: Error) => void;
|
|
};
|
|
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,
|
|
options?: {clientMutationId?: string; signal?: AbortSignal},
|
|
) => Promise<Result>;
|
|
export const h: typeof React.createElement;
|
|
export const useLiveField: <T>(
|
|
field: LiveFieldProp<T>,
|
|
options?: {
|
|
reconcileRegister?: (state: {
|
|
confirmed: T;
|
|
optimistic: T;
|
|
pending: boolean;
|
|
}) => T;
|
|
},
|
|
) => readonly [T, (value: T) => Promise<void>];
|
|
}
|
|
`;
|