55 lines
1.6 KiB
TypeScript
55 lines
1.6 KiB
TypeScript
declare module "@quixos/web-studio-react-runtime" {
|
|
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?: unknown;
|
|
className?: string;
|
|
style?: Record<string, string | number | undefined>;
|
|
onError?: (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,
|
|
) => Promise<Result>;
|
|
export const h: (...args: any[]) => any;
|
|
export const useLiveField: <T>(
|
|
field: LiveFieldProp<T>,
|
|
options?: {
|
|
reconcileRegister?: (state: {
|
|
confirmed: T;
|
|
optimistic: T;
|
|
pending: boolean;
|
|
}) => T;
|
|
},
|
|
) => [T, (value: T) => void | Promise<void>];
|
|
}
|