@assistant-ui/react 0.15.15 → 0.15.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/devtools/DevToolsHooks.d.ts +0 -2
- package/dist/devtools/DevToolsHooks.d.ts.map +1 -1
- package/dist/devtools/DevToolsHooks.js +10 -12
- package/dist/devtools/DevToolsHooks.js.map +1 -1
- package/dist/mcp-apps/McpAppRenderer.js +1 -1
- package/dist/mcp-apps/bridge.d.ts.map +1 -1
- package/dist/mcp-apps/bridge.js +2 -8
- package/dist/mcp-apps/bridge.js.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts.map +1 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js +4 -1
- package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerRoot.js +20 -15
- package/dist/primitives/branchPicker/BranchPickerRoot.js.map +1 -1
- package/dist/primitives/composer/ComposerDictationTranscript.d.ts +2 -2
- package/dist/primitives/composer/ComposerDictationTranscript.js +2 -2
- package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
- package/dist/primitives/composer/trigger/triggerSelectionResource.js +24 -20
- package/dist/primitives/composer/trigger/triggerSelectionResource.js.map +1 -1
- package/dist/primitives/message.js +1 -1
- package/dist/primitives/thread/ThreadRoot.d.ts +3 -0
- package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
- package/dist/primitives/thread/ThreadRoot.js +3 -0
- package/dist/primitives/thread/ThreadRoot.js.map +1 -1
- package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
- package/dist/sandbox-host/SandboxHost.js +4 -1
- package/dist/sandbox-host/SandboxHost.js.map +1 -1
- package/dist/unstable/useComposerInputHistory.js +1 -1
- package/dist/utils/invokeCallbackSafely.d.ts +5 -0
- package/dist/utils/invokeCallbackSafely.d.ts.map +1 -0
- package/dist/utils/invokeCallbackSafely.js +15 -0
- package/dist/utils/invokeCallbackSafely.js.map +1 -0
- package/dist/utils/smooth/SmoothContext.d.ts +6 -6
- package/dist/utils/smooth/useSmooth.d.ts +3 -0
- package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
- package/dist/utils/smooth/useSmooth.js +16 -1
- package/dist/utils/smooth/useSmooth.js.map +1 -1
- package/package.json +5 -5
- package/src/devtools/DevToolsHooks.test.ts +40 -0
- package/src/devtools/DevToolsHooks.ts +10 -15
- package/src/mcp-apps/bridge.test.ts +21 -0
- package/src/mcp-apps/bridge.ts +2 -14
- package/src/model-context/frame/SPEC_AssistantFrame.md +1 -1
- package/src/primitives/actionBar/ActionBarExportMarkdown.test.tsx +67 -0
- package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +3 -1
- package/src/primitives/branchPicker/BranchPickerRoot.tsx +5 -3
- package/src/primitives/composer/ComposerDictationTranscript.tsx +2 -2
- package/src/primitives/composer/trigger/triggerSelectionResource.test.ts +135 -0
- package/src/primitives/composer/trigger/triggerSelectionResource.ts +2 -0
- package/src/primitives/thread/ThreadRoot.tsx +3 -0
- package/src/sandbox-host/SandboxHost.test.tsx +61 -0
- package/src/sandbox-host/SandboxHost.tsx +6 -2
- package/src/unstable/useLiveCompletionAdapter.test.tsx +57 -0
- package/src/utils/invokeCallbackSafely.ts +11 -0
- package/src/utils/smooth/useSmooth.test.tsx +110 -0
- package/src/utils/smooth/useSmooth.ts +20 -6
- package/dist/context/react/utils/ensureBinding.d.ts +0 -5
- package/dist/context/react/utils/ensureBinding.d.ts.map +0 -1
- package/dist/context/react/utils/ensureBinding.js +0 -24
- package/dist/context/react/utils/ensureBinding.js.map +0 -1
- package/dist/context/react/utils/useRuntimeState.d.ts +0 -13
- package/dist/context/react/utils/useRuntimeState.d.ts.map +0 -1
- package/dist/context/react/utils/useRuntimeState.js +0 -33
- package/dist/context/react/utils/useRuntimeState.js.map +0 -1
- package/src/context/react/utils/ensureBinding.ts +0 -46
- package/src/context/react/utils/useRuntimeState.ts +0 -46
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
type Bindable = {
|
|
2
|
-
__internal_bindMethods?: () => void;
|
|
3
|
-
__isBound?: boolean;
|
|
4
|
-
};
|
|
5
|
-
const debugVerifyPrototype = (
|
|
6
|
-
runtime: Record<string, unknown>,
|
|
7
|
-
prototype: any,
|
|
8
|
-
) => {
|
|
9
|
-
const unboundMethods = Object.getOwnPropertyNames(prototype).filter(
|
|
10
|
-
(methodStr) => {
|
|
11
|
-
const descriptor = Object.getOwnPropertyDescriptor(prototype, methodStr);
|
|
12
|
-
const isMethod = descriptor && typeof descriptor.value === "function";
|
|
13
|
-
if (!isMethod) return false;
|
|
14
|
-
|
|
15
|
-
const methodName = methodStr as keyof typeof runtime | "constructor";
|
|
16
|
-
return (
|
|
17
|
-
isMethod &&
|
|
18
|
-
!methodName.startsWith("_") &&
|
|
19
|
-
methodName !== "constructor" &&
|
|
20
|
-
prototype[methodName] === runtime[methodName]
|
|
21
|
-
);
|
|
22
|
-
},
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
if (unboundMethods.length > 0) {
|
|
26
|
-
throw new Error(
|
|
27
|
-
`The following methods are not bound: ${JSON.stringify(unboundMethods)}`,
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const prototypePrototype = Object.getPrototypeOf(prototype);
|
|
32
|
-
if (prototypePrototype && prototypePrototype !== Object.prototype) {
|
|
33
|
-
debugVerifyPrototype(runtime, prototypePrototype);
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
export const ensureBinding = (r: unknown) => {
|
|
37
|
-
const runtime = r as Bindable;
|
|
38
|
-
if (runtime.__isBound) return;
|
|
39
|
-
|
|
40
|
-
runtime.__internal_bindMethods?.();
|
|
41
|
-
runtime.__isBound = true;
|
|
42
|
-
|
|
43
|
-
if (process.env.NODE_ENV !== "production") {
|
|
44
|
-
debugVerifyPrototype(runtime, Object.getPrototypeOf(runtime));
|
|
45
|
-
}
|
|
46
|
-
};
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Unsubscribe } from "@assistant-ui/core";
|
|
2
|
-
import { useDebugValue, useSyncExternalStore } from "react";
|
|
3
|
-
import { ensureBinding } from "./ensureBinding";
|
|
4
|
-
|
|
5
|
-
export type SubscribableRuntime<TState> = {
|
|
6
|
-
getState: () => TState;
|
|
7
|
-
subscribe: (callback: () => void) => Unsubscribe;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function useRuntimeStateInternal<TState, TSelected>(
|
|
11
|
-
runtime: SubscribableRuntime<TState>,
|
|
12
|
-
selector: ((state: TState) => TSelected | TState) | undefined = identity,
|
|
13
|
-
): TSelected | TState {
|
|
14
|
-
// TODO move to useRuntimeState
|
|
15
|
-
ensureBinding(runtime);
|
|
16
|
-
|
|
17
|
-
const slice = useSyncExternalStore(
|
|
18
|
-
runtime.subscribe,
|
|
19
|
-
() => selector(runtime.getState()),
|
|
20
|
-
() => selector(runtime.getState()),
|
|
21
|
-
);
|
|
22
|
-
useDebugValue(slice);
|
|
23
|
-
return slice;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const identity = <T>(arg: T): T => arg;
|
|
27
|
-
export function useRuntimeState<TState>(
|
|
28
|
-
runtime: SubscribableRuntime<TState>,
|
|
29
|
-
): TState;
|
|
30
|
-
export function useRuntimeState<TState, TSelected>(
|
|
31
|
-
runtime: SubscribableRuntime<TState>,
|
|
32
|
-
selector: (state: TState) => TSelected,
|
|
33
|
-
): TSelected;
|
|
34
|
-
export function useRuntimeState<TState, TSelected>(
|
|
35
|
-
runtime: SubscribableRuntime<TState>,
|
|
36
|
-
selector: ((state: TState) => TSelected) | undefined,
|
|
37
|
-
): TSelected | TState;
|
|
38
|
-
export function useRuntimeState<TState, TSelected>(
|
|
39
|
-
runtime: SubscribableRuntime<TState>,
|
|
40
|
-
selector?: ((state: TState) => TSelected) | undefined,
|
|
41
|
-
): TSelected | TState {
|
|
42
|
-
// ensure that the runtime is bound
|
|
43
|
-
// ensureBinding(runtime);
|
|
44
|
-
|
|
45
|
-
return useRuntimeStateInternal(runtime, selector);
|
|
46
|
-
}
|