@assistant-ui/react 0.11.19 → 0.11.21
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/augmentations.d.ts +12 -0
- package/dist/augmentations.d.ts.map +1 -0
- package/dist/augmentations.js +1 -0
- package/dist/augmentations.js.map +1 -0
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts +1 -1
- package/dist/legacy-runtime/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.js +6 -2
- package/dist/legacy-runtime/runtime-cores/assistant-transport/index.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +2 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts +2 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +25 -1
- package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts +1 -0
- package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js +6 -0
- package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts +1 -0
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js +1 -0
- package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +1 -1
- package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js +1 -0
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js +1 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts +3 -3
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts +2 -2
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -1
- package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerNext.js +7 -3
- package/dist/primitives/branchPicker/BranchPickerNext.js.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
- package/dist/primitives/branchPicker/BranchPickerPrevious.js +7 -3
- package/dist/primitives/branchPicker/BranchPickerPrevious.js.map +1 -1
- package/dist/tests/setup.js +8 -8
- package/dist/tests/setup.js.map +1 -1
- package/package.json +9 -9
- package/src/augmentations.ts +26 -0
- package/src/legacy-runtime/runtime-cores/assistant-transport/index.ts +4 -1
- package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +3 -1
- package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.tsx +39 -0
- package/src/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.tsx +1 -0
- package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.tsx +7 -0
- package/src/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.tsx +1 -0
- package/src/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.tsx +1 -0
- package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +1 -4
- package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +3 -3
- package/src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx +2 -1
- package/src/primitives/branchPicker/BranchPickerNext.tsx +11 -3
- package/src/primitives/branchPicker/BranchPickerPrevious.tsx +11 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\n\"use client\";\n\nimport {\n FC,\n useCallback,\n useRef,\n useEffect,\n memo,\n PropsWithChildren,\n ComponentType,\n} from \"react\";\nimport { UseBoundStore, StoreApi, create } from \"zustand\";\nimport { useAssistantApi, ThreadListItemByIdProvider } from \"../../../context\";\nimport { ThreadRuntimeCore, ThreadRuntimeImpl } from \"../../../internal\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport { AssistantRuntime } from \"../../runtime\";\n\ntype RemoteThreadListHook = () => AssistantRuntime;\n\ntype RemoteThreadListHookInstance = {\n runtime?: ThreadRuntimeCore;\n};\nexport class RemoteThreadListHookInstanceManager extends BaseSubscribable {\n private useRuntimeHook: UseBoundStore<\n StoreApi<{ useRuntime: RemoteThreadListHook }>\n >;\n private instances = new Map<string, RemoteThreadListHookInstance>();\n private useAliveThreadsKeysChanged = create(() => ({}));\n\n constructor(runtimeHook: RemoteThreadListHook) {\n super();\n this.useRuntimeHook = create(() => ({ useRuntime: runtimeHook }));\n }\n\n public startThreadRuntime(threadId: string) {\n if (!this.instances.has(threadId)) {\n this.instances.set(threadId, {});\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n return new Promise<ThreadRuntimeCore>((resolve, reject) => {\n const callback = () => {\n const instance = this.instances.get(threadId);\n if (!instance) {\n dispose();\n reject(new Error(\"Thread was deleted before runtime was started\"));\n } else if (!instance.runtime) {\n return; // misc update\n } else {\n dispose();\n resolve(instance.runtime);\n }\n };\n const dispose = this.subscribe(callback);\n callback();\n });\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance) return undefined;\n return instance.runtime;\n }\n\n public stopThreadRuntime(threadId: string) {\n this.instances.delete(threadId);\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n public setRuntimeHook(newRuntimeHook: RemoteThreadListHook) {\n const prevRuntimeHook = this.useRuntimeHook.getState().useRuntime;\n if (prevRuntimeHook !== newRuntimeHook) {\n this.useRuntimeHook.setState({ useRuntime: newRuntimeHook }, true);\n }\n }\n\n private _InnerActiveThreadProvider: FC<{\n threadId: string;\n }> = ({ threadId }) => {\n const { useRuntime } = this.useRuntimeHook();\n const runtime = useRuntime();\n\n const threadBinding = (runtime.thread as ThreadRuntimeImpl)\n .__internal_threadBinding;\n\n const updateRuntime = useCallback(() => {\n const aliveThread = this.instances.get(threadId);\n if (!aliveThread)\n throw new Error(\"Thread not found. This is a bug in assistant-ui.\");\n\n aliveThread.runtime = threadBinding.getState();\n
|
1
|
+
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.tsx"],"sourcesContent":["/* eslint-disable react-hooks/rules-of-hooks */\n\"use client\";\n\nimport {\n FC,\n useCallback,\n useRef,\n useEffect,\n memo,\n PropsWithChildren,\n ComponentType,\n} from \"react\";\nimport { UseBoundStore, StoreApi, create } from \"zustand\";\nimport { useAssistantApi, ThreadListItemByIdProvider } from \"../../../context\";\nimport { ThreadRuntimeCore, ThreadRuntimeImpl } from \"../../../internal\";\nimport { BaseSubscribable } from \"./BaseSubscribable\";\nimport { AssistantRuntime } from \"../../runtime\";\n\ntype RemoteThreadListHook = () => AssistantRuntime;\n\ntype RemoteThreadListHookInstance = {\n runtime?: ThreadRuntimeCore;\n};\nexport class RemoteThreadListHookInstanceManager extends BaseSubscribable {\n private useRuntimeHook: UseBoundStore<\n StoreApi<{ useRuntime: RemoteThreadListHook }>\n >;\n private instances = new Map<string, RemoteThreadListHookInstance>();\n private useAliveThreadsKeysChanged = create(() => ({}));\n\n constructor(runtimeHook: RemoteThreadListHook) {\n super();\n this.useRuntimeHook = create(() => ({ useRuntime: runtimeHook }));\n }\n\n public startThreadRuntime(threadId: string) {\n if (!this.instances.has(threadId)) {\n this.instances.set(threadId, {});\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n return new Promise<ThreadRuntimeCore>((resolve, reject) => {\n const callback = () => {\n const instance = this.instances.get(threadId);\n if (!instance) {\n dispose();\n reject(new Error(\"Thread was deleted before runtime was started\"));\n } else if (!instance.runtime) {\n return; // misc update\n } else {\n dispose();\n resolve(instance.runtime);\n }\n };\n const dispose = this.subscribe(callback);\n callback();\n });\n }\n\n public getThreadRuntimeCore(threadId: string) {\n const instance = this.instances.get(threadId);\n if (!instance) return undefined;\n return instance.runtime;\n }\n\n public stopThreadRuntime(threadId: string) {\n this.instances.delete(threadId);\n this.useAliveThreadsKeysChanged.setState({}, true);\n }\n\n public setRuntimeHook(newRuntimeHook: RemoteThreadListHook) {\n const prevRuntimeHook = this.useRuntimeHook.getState().useRuntime;\n if (prevRuntimeHook !== newRuntimeHook) {\n this.useRuntimeHook.setState({ useRuntime: newRuntimeHook }, true);\n }\n }\n\n private _InnerActiveThreadProvider: FC<{\n threadId: string;\n }> = ({ threadId }) => {\n const { useRuntime } = this.useRuntimeHook();\n const runtime = useRuntime();\n\n const threadBinding = (runtime.thread as ThreadRuntimeImpl)\n .__internal_threadBinding;\n\n const updateRuntime = useCallback(() => {\n const aliveThread = this.instances.get(threadId);\n if (!aliveThread)\n throw new Error(\"Thread not found. This is a bug in assistant-ui.\");\n\n aliveThread.runtime = threadBinding.getState();\n this._notifySubscribers();\n }, [threadId, threadBinding]);\n\n const isMounted = useRef(false);\n if (!isMounted.current) {\n updateRuntime();\n }\n\n useEffect(() => {\n isMounted.current = true;\n updateRuntime();\n return threadBinding.outerSubscribe(updateRuntime);\n }, [threadBinding, updateRuntime]);\n\n // auto initialize thread\n const api = useAssistantApi();\n useEffect(() => {\n return runtime.threads.main.unstable_on(\"initialize\", () => {\n const state = api.threadListItem().getState();\n if (state.status === \"new\") {\n api.threadListItem().initialize();\n\n // auto generate a title after first run\n const dispose = runtime.thread.unstable_on(\"run-end\", () => {\n dispose();\n\n api.threadListItem().generateTitle();\n });\n }\n });\n }, [runtime, api]);\n\n return null;\n };\n\n private _OuterActiveThreadProvider: FC<{\n threadId: string;\n provider: ComponentType<PropsWithChildren>;\n // eslint-disable-next-line react/display-name\n }> = memo(({ threadId, provider: Provider }) => {\n // Runtime is provided by ThreadListItemByIdProvider\n\n return (\n <ThreadListItemByIdProvider id={threadId}>\n <Provider>\n <this._InnerActiveThreadProvider threadId={threadId} />\n </Provider>\n </ThreadListItemByIdProvider>\n );\n });\n\n public __internal_RenderThreadRuntimes: FC<{\n provider: ComponentType<PropsWithChildren>;\n }> = ({ provider }) => {\n this.useAliveThreadsKeysChanged(); // trigger re-render on alive threads change\n\n return Array.from(this.instances.keys()).map((threadId) => (\n <this._OuterActiveThreadProvider\n key={threadId}\n threadId={threadId}\n provider={provider}\n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C,8BAA2B,IAAI,UAC9B,8BAAC,YACC,8BAAC,KAAK,4BAAL,EAAgC,UAAoB,GACvD,GACF;AAAA,EAEJ,CAAC;AAAA,EAEM,kCAEF,CAAC,EAAE,SAAS,MAAM;AACrB,SAAK,2BAA2B;AAEhC,WAAO,MAAM,KAAK,KAAK,UAAU,KAAK,CAAC,EAAE,IAAI,CAAC,aAC5C;AAAA,MAAC,KAAK;AAAA,MAAL;AAAA,QAEC;AAAA,QACA;AAAA;AAAA,MAFK;AAAA,IAGP,CACD;AAAA,EACH;AACF;","names":[]}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import { AssistantCloud } from "assistant-cloud";
|
2
2
|
import { RemoteThreadListAdapter } from "../types";
|
3
3
|
type ThreadData = {
|
4
|
-
externalId: string;
|
4
|
+
externalId: string | undefined;
|
5
5
|
};
|
6
6
|
type CloudThreadListAdapterOptions = {
|
7
7
|
cloud?: AssistantCloud | undefined;
|
8
|
-
create
|
9
|
-
delete
|
8
|
+
create?: (() => Promise<ThreadData>) | undefined;
|
9
|
+
delete?: ((threadId: string) => Promise<void>) | undefined;
|
10
10
|
};
|
11
11
|
export declare const useCloudThreadListAdapter: (adapter: CloudThreadListAdapterOptions) => RemoteThreadListAdapter;
|
12
12
|
export {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../../../../src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAMnD,KAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"cloud.d.ts","sourceRoot":"","sources":["../../../../../src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx"],"names":[],"mappings":"AAUA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAC;AAMnD,KAAK,UAAU,GAAG;IAChB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC,CAAC;AAEF,KAAK,6BAA6B,GAAG;IACnC,KAAK,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC;IAEnC,MAAM,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,SAAS,CAAC;IACjD,MAAM,CAAC,EAAE,CAAC,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,SAAS,CAAC;CAC5D,CAAC;AASF,eAAO,MAAM,yBAAyB,GACpC,SAAS,6BAA6B,KACrC,uBAwFF,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../../src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n FC,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport { RemoteThreadListAdapter } from \"../types\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"../../../cloud/AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../../adapters/RuntimeAdapterProvider\";\nimport { InMemoryThreadListAdapter } from \"./in-memory\";\nimport { CloudFileAttachmentAdapter } from \"../../adapters\";\n\ntype ThreadData = {\n externalId: string;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create
|
1
|
+
{"version":3,"sources":["../../../../../src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n FC,\n PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport { RemoteThreadListAdapter } from \"../types\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"../../../cloud/AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../../adapters/RuntimeAdapterProvider\";\nimport { InMemoryThreadListAdapter } from \"./in-memory\";\nimport { CloudFileAttachmentAdapter } from \"../../adapters\";\n\ntype ThreadData = {\n externalId: string | undefined;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?: (() => Promise<ThreadData>) | undefined;\n delete?: ((threadId: string) => Promise<void>) | undefined;\n};\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.[\"NEXT_PUBLIC_ASSISTANT_BASE_URL\"];\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n function Provider({ children }) {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const cloudInstance = adapterRef.current.cloud ?? autoCloud!;\n const attachments = useMemo(\n () => new CloudFileAttachmentAdapter(cloudInstance),\n [cloudInstance],\n );\n\n const adapters = useMemo(\n () => ({\n history,\n attachments,\n }),\n [history, attachments],\n );\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) return new InMemoryThreadListAdapter();\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: messages, // TODO serialize these to a more efficient format\n });\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,sBAAsB;AAE/B,SAAS,6CAA6C;AACtD,SAAS,8BAA8B;AACvC,SAAS,iCAAiC;AAC1C,SAAS,kCAAkC;AAkDnC;AArCR,IAAM,UACJ,OAAO,YAAY,eACnB,SAAS,MAAM,gCAAgC;AACjD,IAAM,YAAY,UACd,IAAI,eAAe,EAAE,SAAS,WAAW,KAAK,CAAC,IAC/C;AAEG,IAAM,4BAA4B,CACvC,YAC4B;AAC5B,QAAM,aAAa,OAAO,OAAO;AACjC,YAAU,MAAM;AACd,eAAW,UAAU;AAAA,EACvB,GAAG,CAAC,OAAO,CAAC;AAEZ,QAAM,oBAAoB;AAAA,IACxB,SAAS,SAAS,EAAE,SAAS,GAAG;AAC9B,YAAM,UAAU,sCAAsC;AAAA,QACpD,IAAI,UAAU;AACZ,iBAAO,WAAW,QAAQ,SAAS;AAAA,QACrC;AAAA,MACF,CAAC;AACD,YAAM,gBAAgB,WAAW,QAAQ,SAAS;AAClD,YAAM,cAAc;AAAA,QAClB,MAAM,IAAI,2BAA2B,aAAa;AAAA,QAClD,CAAC,aAAa;AAAA,MAChB;AAEA,YAAM,WAA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Q,SAAS,QAAQ;AAC/B,aAAO,MAAM,QAAQ,OAAO,QAAQ;AAAA,IACtC;AAAA,IAEA,eAAe,OAAO,UAAU,aAAa;AAC3C,aAAO,MAAM,KAAK,OAAO;AAAA,QACvB,WAAW;AAAA,QACX,cAAc;AAAA,QACd;AAAA;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IAEA;AAAA,EACF;AACF;","names":[]}
|
package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
1
|
import { RemoteThreadListOptions } from "./types";
|
2
|
-
import {
|
3
|
-
export declare const useRemoteThreadListRuntime: (options: RemoteThreadListOptions) =>
|
2
|
+
import { AssistantRuntime } from "../../runtime/AssistantRuntime";
|
3
|
+
export declare const useRemoteThreadListRuntime: (options: RemoteThreadListOptions) => AssistantRuntime;
|
4
4
|
//# sourceMappingURL=useRemoteThreadListRuntime.d.ts.map
|
package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"useRemoteThreadListRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;
|
1
|
+
{"version":3,"file":"useRemoteThreadListRuntime.d.ts","sourceRoot":"","sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAGlD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAqBlE,eAAO,MAAM,0BAA0B,GACrC,SAAS,uBAAuB,KAC/B,gBAOF,CAAC"}
|
package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useEffect, useMemo } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { RemoteThreadListOptions } from \"./types\";\nimport { AssistantRuntimeImpl } from \"../../../internal\";\nimport { AssistantRuntimeCore } from \"../core/AssistantRuntimeCore\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\nexport const useRemoteThreadListRuntime = (\n options: RemoteThreadListOptions,\n) => {\n const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));\n useEffect(() => {\n runtime.threads.__internal_setOptions(options);\n runtime.threads.__internal_load();\n }, [runtime, options]);\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n"],"mappings":";;;AAEA,SAAS,UAAU,WAAW,eAAe;AAC7C,SAAS,gCAAgC;AACzC,SAAS,6CAA6C;AAEtD,SAAS,4BAA4B;
|
1
|
+
{"version":3,"sources":["../../../../src/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, useEffect, useMemo } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../core/BaseAssistantRuntimeCore\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { RemoteThreadListOptions } from \"./types\";\nimport { AssistantRuntimeImpl } from \"../../../internal\";\nimport { AssistantRuntimeCore } from \"../core/AssistantRuntimeCore\";\nimport { AssistantRuntime } from \"../../runtime/AssistantRuntime\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\nexport const useRemoteThreadListRuntime = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));\n useEffect(() => {\n runtime.threads.__internal_setOptions(options);\n runtime.threads.__internal_load();\n }, [runtime, options]);\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n"],"mappings":";;;AAEA,SAAS,UAAU,WAAW,eAAe;AAC7C,SAAS,gCAAgC;AACzC,SAAS,6CAA6C;AAEtD,SAAS,4BAA4B;AAIrC,IAAM,8BAAN,cACU,yBAEV;AAAA,EACkB;AAAA,EAEhB,YAAY,SAAkC;AAC5C,UAAM;AACN,SAAK,UAAU,IAAI;AAAA,MACjB;AAAA,MACA,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK,QAAQ;AAAA,EACtB;AACF;AAEO,IAAM,6BAA6B,CACxC,YACqB;AACrB,QAAM,CAAC,OAAO,IAAI,SAAS,MAAM,IAAI,4BAA4B,OAAO,CAAC;AACzE,YAAU,MAAM;AACd,YAAQ,QAAQ,sBAAsB,OAAO;AAC7C,YAAQ,QAAQ,gBAAgB;AAAA,EAClC,GAAG,CAAC,SAAS,OAAO,CAAC;AACrB,SAAO,QAAQ,MAAM,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BranchPickerNext.d.ts","sourceRoot":"","sources":["../../../src/primitives/branchPicker/BranchPickerNext.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAIxC,QAAA,MAAM,mBAAmB,
|
1
|
+
{"version":3,"file":"BranchPickerNext.d.ts","sourceRoot":"","sources":["../../../src/primitives/branchPicker/BranchPickerNext.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAIxC,QAAA,MAAM,mBAAmB,2BAoBxB,CAAC;AAEF,yBAAiB,yBAAyB,CAAC;IACzC,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,mBAAmB,CAAC,CAAC;CACnE;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,yBAAyB;;6DAGrC,CAAC"}
|
@@ -8,9 +8,13 @@ import { useCallback } from "react";
|
|
8
8
|
import { useAssistantState, useAssistantApi } from "../../context/index.js";
|
9
9
|
var useBranchPickerNext = () => {
|
10
10
|
const api = useAssistantApi();
|
11
|
-
const disabled = useAssistantState(
|
12
|
-
(
|
13
|
-
|
11
|
+
const disabled = useAssistantState(({ thread, message }) => {
|
12
|
+
if (message.branchNumber >= message.branchCount) return true;
|
13
|
+
if (thread.isRunning && !thread.capabilities.switchBranchDuringRun) {
|
14
|
+
return true;
|
15
|
+
}
|
16
|
+
return false;
|
17
|
+
});
|
14
18
|
const callback = useCallback(() => {
|
15
19
|
api.message().switchToBranch({ position: "next" });
|
16
20
|
}, [api]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/branchPicker/BranchPickerNext.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useAssistantState, useAssistantApi } from \"../../context\";\n\nconst useBranchPickerNext = () => {\n const api = useAssistantApi();\n const disabled = useAssistantState(
|
1
|
+
{"version":3,"sources":["../../../src/primitives/branchPicker/BranchPickerNext.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useAssistantState, useAssistantApi } from \"../../context\";\n\nconst useBranchPickerNext = () => {\n const api = useAssistantApi();\n const disabled = useAssistantState(({ thread, message }) => {\n // Disabled if no next branch\n if (message.branchNumber >= message.branchCount) return true;\n\n // Disabled if running and capability not supported\n if (thread.isRunning && !thread.capabilities.switchBranchDuringRun) {\n return true;\n }\n\n return false;\n });\n\n const callback = useCallback(() => {\n api.message().switchToBranch({ position: \"next\" });\n }, [api]);\n\n if (disabled) return null;\n return callback;\n};\n\nexport namespace BranchPickerPrimitiveNext {\n export type Element = ActionButtonElement;\n /**\n * Props for the BranchPickerPrimitive.Next component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useBranchPickerNext>;\n}\n\n/**\n * A button component that navigates to the next branch in the message tree.\n *\n * This component automatically handles switching to the next available branch\n * and is disabled when there are no more branches to navigate to.\n *\n * @example\n * ```tsx\n * <BranchPickerPrimitive.Next>\n * Next →\n * </BranchPickerPrimitive.Next>\n * ```\n */\nexport const BranchPickerPrimitiveNext = createActionButton(\n \"BranchPickerPrimitive.Next\",\n useBranchPickerNext,\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,uBAAuB;AAEnD,IAAM,sBAAsB,MAAM;AAChC,QAAM,MAAM,gBAAgB;AAC5B,QAAM,WAAW,kBAAkB,CAAC,EAAE,QAAQ,QAAQ,MAAM;AAE1D,QAAI,QAAQ,gBAAgB,QAAQ,YAAa,QAAO;AAGxD,QAAI,OAAO,aAAa,CAAC,OAAO,aAAa,uBAAuB;AAClE,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,CAAC;AAED,QAAM,WAAW,YAAY,MAAM;AACjC,QAAI,QAAQ,EAAE,eAAe,EAAE,UAAU,OAAO,CAAC;AAAA,EACnD,GAAG,CAAC,GAAG,CAAC;AAER,MAAI,SAAU,QAAO;AACrB,SAAO;AACT;AAwBO,IAAM,4BAA4B;AAAA,EACvC;AAAA,EACA;AACF;","names":[]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"BranchPickerPrevious.d.ts","sourceRoot":"","sources":["../../../src/primitives/branchPicker/BranchPickerPrevious.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAIxC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,uBAAuB,
|
1
|
+
{"version":3,"file":"BranchPickerPrevious.d.ts","sourceRoot":"","sources":["../../../src/primitives/branchPicker/BranchPickerPrevious.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EAElB,MAAM,gCAAgC,CAAC;AAIxC;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,QAAA,MAAM,uBAAuB,2BAoB5B,CAAC;AAEF,yBAAiB,6BAA6B,CAAC;IAC7C,KAAY,OAAO,GAAG,mBAAmB,CAAC;IAC1C;;;OAGG;IACH,KAAY,KAAK,GAAG,iBAAiB,CAAC,OAAO,uBAAuB,CAAC,CAAC;CACvE;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,6BAA6B;;6DAGzC,CAAC"}
|
@@ -8,9 +8,13 @@ import { useCallback } from "react";
|
|
8
8
|
import { useAssistantState, useAssistantApi } from "../../context/index.js";
|
9
9
|
var useBranchPickerPrevious = () => {
|
10
10
|
const api = useAssistantApi();
|
11
|
-
const disabled = useAssistantState(
|
12
|
-
(
|
13
|
-
|
11
|
+
const disabled = useAssistantState(({ thread, message }) => {
|
12
|
+
if (message.branchNumber <= 1) return true;
|
13
|
+
if (thread.isRunning && !thread.capabilities.switchBranchDuringRun) {
|
14
|
+
return true;
|
15
|
+
}
|
16
|
+
return false;
|
17
|
+
});
|
14
18
|
const callback = useCallback(() => {
|
15
19
|
api.message().switchToBranch({ position: "previous" });
|
16
20
|
}, [api]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../../src/primitives/branchPicker/BranchPickerPrevious.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useAssistantState, useAssistantApi } from \"../../context\";\n\n/**\n * Hook that provides navigation to the previous branch functionality.\n *\n * This hook returns a callback function that switches to the previous branch\n * in the message branch tree, or null if there is no previous branch available.\n *\n * @returns A previous branch callback function, or null if navigation is disabled\n *\n * @example\n * ```tsx\n * function CustomPreviousButton() {\n * const previous = useBranchPickerPrevious();\n *\n * return (\n * <button onClick={previous} disabled={!previous}>\n * {previous ? \"Previous Branch\" : \"No Previous Branch\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useBranchPickerPrevious = () => {\n const api = useAssistantApi();\n const disabled = useAssistantState(
|
1
|
+
{"version":3,"sources":["../../../src/primitives/branchPicker/BranchPickerPrevious.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ActionButtonElement,\n ActionButtonProps,\n createActionButton,\n} from \"../../utils/createActionButton\";\nimport { useCallback } from \"react\";\nimport { useAssistantState, useAssistantApi } from \"../../context\";\n\n/**\n * Hook that provides navigation to the previous branch functionality.\n *\n * This hook returns a callback function that switches to the previous branch\n * in the message branch tree, or null if there is no previous branch available.\n *\n * @returns A previous branch callback function, or null if navigation is disabled\n *\n * @example\n * ```tsx\n * function CustomPreviousButton() {\n * const previous = useBranchPickerPrevious();\n *\n * return (\n * <button onClick={previous} disabled={!previous}>\n * {previous ? \"Previous Branch\" : \"No Previous Branch\"}\n * </button>\n * );\n * }\n * ```\n */\nconst useBranchPickerPrevious = () => {\n const api = useAssistantApi();\n const disabled = useAssistantState(({ thread, message }) => {\n // Disabled if no previous branch\n if (message.branchNumber <= 1) return true;\n\n // Disabled if running and capability not supported\n if (thread.isRunning && !thread.capabilities.switchBranchDuringRun) {\n return true;\n }\n\n return false;\n });\n\n const callback = useCallback(() => {\n api.message().switchToBranch({ position: \"previous\" });\n }, [api]);\n\n if (disabled) return null;\n return callback;\n};\n\nexport namespace BranchPickerPrimitivePrevious {\n export type Element = ActionButtonElement;\n /**\n * Props for the BranchPickerPrimitive.Previous component.\n * Inherits all button element props and action button functionality.\n */\n export type Props = ActionButtonProps<typeof useBranchPickerPrevious>;\n}\n\n/**\n * A button component that navigates to the previous branch in the message tree.\n *\n * This component automatically handles switching to the previous available branch\n * and is disabled when there are no previous branches to navigate to.\n *\n * @example\n * ```tsx\n * <BranchPickerPrimitive.Previous>\n * ← Previous\n * </BranchPickerPrimitive.Previous>\n * ```\n */\nexport const BranchPickerPrimitivePrevious = createActionButton(\n \"BranchPickerPrimitive.Previous\",\n useBranchPickerPrevious,\n);\n"],"mappings":";;;AAEA;AAAA,EAGE;AAAA,OACK;AACP,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB,uBAAuB;AAuBnD,IAAM,0BAA0B,MAAM;AACpC,QAAM,MAAM,gBAAgB;AAC5B,QAAM,WAAW,kBAAkB,CAAC,EAAE,QAAQ,QAAQ,MAAM;AAE1D,QAAI,QAAQ,gBAAgB,EAAG,QAAO;AAGtC,QAAI,OAAO,aAAa,CAAC,OAAO,aAAa,uBAAuB;AAClE,aAAO;AAAA,IACT;AAEA,WAAO;AAAA,EACT,CAAC;AAED,QAAM,WAAW,YAAY,MAAM;AACjC,QAAI,QAAQ,EAAE,eAAe,EAAE,UAAU,WAAW,CAAC;AAAA,EACvD,GAAG,CAAC,GAAG,CAAC;AAER,MAAI,SAAU,QAAO;AACrB,SAAO;AACT;AAwBO,IAAM,gCAAgC;AAAA,EAC3C;AAAA,EACA;AACF;","names":[]}
|
package/dist/tests/setup.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
1
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
2
2
|
import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from "@vitest/expect.js";
|
3
3
|
import { getCurrentTest } from "@vitest/runner.js";
|
4
4
|
import { getNames, getTestName } from "@vitest/runner/utils.js";
|
5
5
|
import * as chai$1 from "chai.js";
|
6
6
|
|
7
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
7
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js
|
8
8
|
import { getSafeTimers } from "@vitest/utils.js";
|
9
9
|
var NAME_WORKER_STATE = "__vitest_worker__";
|
10
10
|
function getWorkerState() {
|
@@ -53,22 +53,22 @@ async function waitForImportsToResolve() {
|
|
53
53
|
await waitForImportsToResolve();
|
54
54
|
}
|
55
55
|
|
56
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
56
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
57
57
|
import { getSafeTimers as getSafeTimers2, assertTypes, createSimpleStackTrace } from "@vitest/utils.js";
|
58
58
|
|
59
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
59
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
|
60
60
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
61
61
|
function getDefaultExportFromCjs(x) {
|
62
62
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
63
63
|
}
|
64
64
|
|
65
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
65
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
66
66
|
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from "@vitest/snapshot.js";
|
67
67
|
import "@vitest/utils/error.js";
|
68
68
|
import { fn, spyOn, mocks, isMockFunction } from "@vitest/spy.js";
|
69
69
|
import { parseSingleStack } from "@vitest/utils/source-map.js";
|
70
70
|
|
71
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
71
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
|
72
72
|
var RealDate = Date;
|
73
73
|
var now = null;
|
74
74
|
var MockDate = class _MockDate extends RealDate {
|
@@ -116,7 +116,7 @@ function resetDate() {
|
|
116
116
|
globalThis.Date = RealDate;
|
117
117
|
}
|
118
118
|
|
119
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
119
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
120
120
|
var unsupported = [
|
121
121
|
"matchSnapshot",
|
122
122
|
"toMatchSnapshot",
|
@@ -2800,7 +2800,7 @@ function getImporter(name) {
|
|
2800
2800
|
return stack?.file || "";
|
2801
2801
|
}
|
2802
2802
|
|
2803
|
-
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.
|
2803
|
+
// ../../node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@24.5.2_@vitest+ui@3.2.4_jiti@2.6.0_jsdom@2_688234ac2804d6d71aa9eebd3ba7952f/node_modules/vitest/dist/index.js
|
2804
2804
|
import { expectTypeOf } from "expect-type.js";
|
2805
2805
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from "@vitest/runner.js";
|
2806
2806
|
import * as chai2 from "chai.js";
|