@assistant-ui/react 0.7.23 → 0.7.25
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/api/AssistantRuntime.d.ts +1 -1
- package/dist/api/AssistantRuntime.d.ts.map +1 -1
- package/dist/api/AssistantRuntime.js +1 -1
- package/dist/api/AssistantRuntime.js.map +1 -1
- package/dist/api/AssistantRuntime.mjs +1 -1
- package/dist/api/AssistantRuntime.mjs.map +1 -1
- package/dist/api/ComposerRuntime.d.ts +4 -2
- package/dist/api/ComposerRuntime.d.ts.map +1 -1
- package/dist/api/ComposerRuntime.js +6 -1
- package/dist/api/ComposerRuntime.js.map +1 -1
- package/dist/api/ComposerRuntime.mjs +6 -1
- package/dist/api/ComposerRuntime.mjs.map +1 -1
- package/dist/api/ThreadListItemRuntime.d.ts +3 -1
- package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListItemRuntime.js.map +1 -1
- package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
- package/dist/api/ThreadListRuntime.d.ts +8 -8
- package/dist/api/ThreadListRuntime.d.ts.map +1 -1
- package/dist/api/ThreadListRuntime.js +7 -5
- package/dist/api/ThreadListRuntime.js.map +1 -1
- package/dist/api/ThreadListRuntime.mjs +7 -5
- package/dist/api/ThreadListRuntime.mjs.map +1 -1
- package/dist/api/ThreadRuntime.d.ts +59 -32
- package/dist/api/ThreadRuntime.d.ts.map +1 -1
- package/dist/api/ThreadRuntime.js +2 -2
- package/dist/api/ThreadRuntime.js.map +1 -1
- package/dist/api/ThreadRuntime.mjs +2 -2
- package/dist/api/ThreadRuntime.mjs.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.js +8 -3
- package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
- package/dist/context/providers/AssistantRuntimeProvider.mjs +8 -3
- package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.js +2 -4
- package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
- package/dist/primitives/threadList/ThreadListItems.mjs +2 -4
- package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +6 -6
- package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js +29 -20
- package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +29 -20
- package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +2 -3
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +2 -3
- package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs +1 -1
- package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts +2 -0
- package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts +2 -1
- package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +4 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +1 -0
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +5 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs +5 -1
- package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/index.d.ts +5 -4
- package/dist/runtimes/index.d.ts.map +1 -1
- package/dist/runtimes/index.js +11 -9
- package/dist/runtimes/index.js.map +1 -1
- package/dist/runtimes/index.mjs +5 -4
- package/dist/runtimes/index.mjs.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +2 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js +12 -8
- package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +12 -8
- package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
- package/dist/runtimes/remote-thread-list/BaseSubscribable.d.ts +8 -0
- package/dist/runtimes/remote-thread-list/BaseSubscribable.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/BaseSubscribable.js +62 -0
- package/dist/runtimes/remote-thread-list/BaseSubscribable.js.map +1 -0
- package/dist/runtimes/remote-thread-list/BaseSubscribable.mjs +37 -0
- package/dist/runtimes/remote-thread-list/BaseSubscribable.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.d.ts +3 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js +150 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.mjs +125 -0
- package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/OptimisticState.d.ts +23 -0
- package/dist/runtimes/remote-thread-list/OptimisticState.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/OptimisticState.js +83 -0
- package/dist/runtimes/remote-thread-list/OptimisticState.js.map +1 -0
- package/dist/runtimes/remote-thread-list/OptimisticState.mjs +58 -0
- package/dist/runtimes/remote-thread-list/OptimisticState.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +75 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +127 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +102 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +76 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +396 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +371 -0
- package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts +7 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js +39 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs +14 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts +19 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js +79 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs +57 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts +20 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js +95 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs +69 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.d.ts +46 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.js +50 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.mjs +25 -0
- package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts +10 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.js +32 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs +7 -0
- package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/index.d.ts +4 -0
- package/dist/runtimes/remote-thread-list/cloud/index.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/index.js +37 -0
- package/dist/runtimes/remote-thread-list/cloud/index.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/index.mjs +10 -0
- package/dist/runtimes/remote-thread-list/cloud/index.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts +4 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js +46 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs +22 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts +14 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js +103 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js.map +1 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs +79 -0
- package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/index.d.ts +2 -0
- package/dist/runtimes/remote-thread-list/index.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/index.js +25 -0
- package/dist/runtimes/remote-thread-list/index.js.map +1 -0
- package/dist/runtimes/remote-thread-list/index.mjs +3 -0
- package/dist/runtimes/remote-thread-list/index.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/types.d.ts +25 -0
- package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/types.js +19 -0
- package/dist/runtimes/remote-thread-list/types.js.map +1 -0
- package/dist/runtimes/remote-thread-list/types.mjs +1 -0
- package/dist/runtimes/remote-thread-list/types.mjs.map +1 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts +3 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +51 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +26 -0
- package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -0
- package/dist/styles/index.css +2 -0
- package/dist/styles/index.css.map +1 -1
- package/dist/styles/tailwindcss/thread.css +5 -1
- package/dist/styles/tailwindcss/thread.css.json +4 -1
- package/dist/ui/attachment-ui.d.ts.map +1 -1
- package/dist/ui/attachment-ui.js +12 -7
- package/dist/ui/attachment-ui.js.map +1 -1
- package/dist/ui/attachment-ui.mjs +12 -7
- package/dist/ui/attachment-ui.mjs.map +1 -1
- package/dist/utils/createActionButton.d.ts +2 -2
- package/dist/utils/createActionButton.d.ts.map +1 -1
- package/dist/utils/createActionButton.js +2 -4
- package/dist/utils/createActionButton.js.map +1 -1
- package/dist/utils/createActionButton.mjs +5 -5
- package/dist/utils/createActionButton.mjs.map +1 -1
- package/package.json +3 -3
- package/src/api/AssistantRuntime.ts +2 -6
- package/src/api/ComposerRuntime.ts +10 -2
- package/src/api/ThreadListItemRuntime.ts +3 -1
- package/src/api/ThreadListRuntime.ts +11 -9
- package/src/api/ThreadRuntime.ts +3 -3
- package/src/context/providers/AssistantRuntimeProvider.tsx +21 -6
- package/src/primitives/threadList/ThreadListItems.tsx +3 -5
- package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +43 -25
- package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +2 -3
- package/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx +1 -1
- package/src/runtimes/core/AssistantRuntimeCore.tsx +3 -0
- package/src/runtimes/core/ComposerRuntimeCore.tsx +2 -1
- package/src/runtimes/core/ThreadListRuntimeCore.tsx +5 -2
- package/src/runtimes/external-store/ExternalStoreAdapter.tsx +1 -1
- package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +6 -1
- package/src/runtimes/index.ts +5 -4
- package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +14 -9
- package/src/runtimes/remote-thread-list/BaseSubscribable.tsx +38 -0
- package/src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx +158 -0
- package/src/runtimes/remote-thread-list/OptimisticState.ts +82 -0
- package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +132 -0
- package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +486 -0
- package/src/runtimes/remote-thread-list/cloud/AssistantCloud.tsx +11 -0
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudAPI.tsx +81 -0
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.tsx +95 -0
- package/src/runtimes/remote-thread-list/cloud/AssistantCloudThreads.tsx +72 -0
- package/src/runtimes/remote-thread-list/cloud/CloudContext.tsx +12 -0
- package/src/runtimes/remote-thread-list/cloud/index.ts +3 -0
- package/src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx +19 -0
- package/src/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.tsx +100 -0
- package/src/runtimes/remote-thread-list/index.ts +2 -0
- package/src/runtimes/remote-thread-list/types.tsx +34 -0
- package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +28 -0
- package/src/styles/tailwindcss/thread.css +5 -1
- package/src/ui/attachment-ui.tsx +20 -14
- package/src/utils/createActionButton.tsx +11 -6
|
@@ -29,7 +29,7 @@ export type AssistantRuntime = {
|
|
|
29
29
|
*/
|
|
30
30
|
registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;
|
|
31
31
|
};
|
|
32
|
-
export declare class AssistantRuntimeImpl implements
|
|
32
|
+
export declare class AssistantRuntimeImpl implements AssistantRuntime {
|
|
33
33
|
private readonly _core;
|
|
34
34
|
readonly threadList: ThreadListRuntimeImpl;
|
|
35
35
|
readonly _thread: ThreadRuntime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantRuntime.d.ts","sourceRoot":"","sources":["../../src/api/AssistantRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAE7E,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EACL,4BAA4B,EAC5B,aAAa,EACb,wBAAwB,EAEzB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAE/E,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,UAAU,EAAE,iBAAiB,CAAC;IAEvC;;OAEG;IACH,iBAAiB,IAAI,IAAI,CAAC;IAE1B;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAEvC;;;;OAIG;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MAAM,CAClB,KAAK,EAAE,oBAAoB,EAC3B,cAAc,GAAE,KACd,OAAO,EAAE,wBAAwB,EACjC,qBAAqB,EAAE,4BAA4B,KAChD,aAAiC,GACrC,gBAAgB;CAGpB"}
|
|
@@ -39,7 +39,7 @@ var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
|
|
|
39
39
|
getState: () => _core.threadList.getMainThreadRuntimeCore(),
|
|
40
40
|
subscribe: (callback) => _core.threadList.subscribe(callback)
|
|
41
41
|
}),
|
|
42
|
-
this.threadList.
|
|
42
|
+
this.threadList.mainItem
|
|
43
43
|
// TODO capture "main" threadListItem from context around useLocalRuntime / useExternalStoreRuntime
|
|
44
44
|
);
|
|
45
45
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadListItemRuntimeBinding,\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n readonly threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl
|
|
1
|
+
{"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadListItemRuntimeBinding,\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n readonly threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl implements AssistantRuntime {\n public readonly threadList;\n public readonly _thread: ThreadRuntime;\n\n protected constructor(\n private readonly _core: AssistantRuntimeCore,\n runtimeFactory: new (\n binding: ThreadRuntimeCoreBinding,\n threadListItemBinding: ThreadListItemRuntimeBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n this.threadList = new ThreadListRuntimeImpl(_core.threadList);\n this._thread = new runtimeFactory(\n new NestedSubscriptionSubject({\n path: {\n ref: \"threads.main\",\n threadSelector: { type: \"main\" },\n },\n getState: () => _core.threadList.getMainThreadRuntimeCore(),\n subscribe: (callback) => _core.threadList.subscribe(callback),\n }),\n this.threadList.mainItem, // TODO capture \"main\" threadListItem from context around useLocalRuntime / useExternalStoreRuntime\n );\n }\n\n public get thread() {\n return this._thread;\n }\n\n public switchToNewThread() {\n return this._core.threadList.switchToNewThread();\n }\n\n public switchToThread(threadId: string) {\n return this._core.threadList.switchToThread(threadId);\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._core.registerModelConfigProvider(provider);\n }\n\n public static create(\n _core: AssistantRuntimeCore,\n runtimeFactory: new (\n binding: ThreadRuntimeCoreBinding,\n threadListItemBinding: ThreadListItemRuntimeBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ): AssistantRuntime {\n return new AssistantRuntimeImpl(_core, runtimeFactory);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,uCAA0C;AAE1C,2BAKO;AAEP,+BAAyD;AAiClD,IAAM,uBAAN,MAAM,sBAAiD;AAAA,EAIlD,YACS,OACjB,iBAGqB,wCACrB;AALiB;AAMjB,SAAK,aAAa,IAAI,+CAAsB,MAAM,UAAU;AAC5D,SAAK,UAAU,IAAI;AAAA,MACjB,IAAI,2DAA0B;AAAA,QAC5B,MAAM;AAAA,UACJ,KAAK;AAAA,UACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QACjC;AAAA,QACA,UAAU,MAAM,MAAM,WAAW,yBAAyB;AAAA,QAC1D,WAAW,CAAC,aAAa,MAAM,WAAW,UAAU,QAAQ;AAAA,MAC9D,CAAC;AAAA,MACD,KAAK,WAAW;AAAA;AAAA,IAClB;AAAA,EACF;AAAA,EAtBgB;AAAA,EACA;AAAA,EAuBhB,IAAW,SAAS;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,MAAM,WAAW,kBAAkB;AAAA,EACjD;AAAA,EAEO,eAAe,UAAkB;AACtC,WAAO,KAAK,MAAM,WAAW,eAAe,QAAQ;AAAA,EACtD;AAAA,EAEO,4BAA4B,UAA+B;AAChE,WAAO,KAAK,MAAM,4BAA4B,QAAQ;AAAA,EACxD;AAAA,EAEA,OAAc,OACZ,OACA,iBAGqB,wCACH;AAClB,WAAO,IAAI,sBAAqB,OAAO,cAAc;AAAA,EACvD;AACF;","names":[]}
|
|
@@ -17,7 +17,7 @@ var AssistantRuntimeImpl = class _AssistantRuntimeImpl {
|
|
|
17
17
|
getState: () => _core.threadList.getMainThreadRuntimeCore(),
|
|
18
18
|
subscribe: (callback) => _core.threadList.subscribe(callback)
|
|
19
19
|
}),
|
|
20
|
-
this.threadList.
|
|
20
|
+
this.threadList.mainItem
|
|
21
21
|
// TODO capture "main" threadListItem from context around useLocalRuntime / useExternalStoreRuntime
|
|
22
22
|
);
|
|
23
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadListItemRuntimeBinding,\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n readonly threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl
|
|
1
|
+
{"version":3,"sources":["../../src/api/AssistantRuntime.ts"],"sourcesContent":["import { AssistantRuntimeCore } from \"../runtimes/core/AssistantRuntimeCore\";\nimport { NestedSubscriptionSubject } from \"./subscribable/NestedSubscriptionSubject\";\nimport { ModelConfigProvider } from \"../types/ModelConfigTypes\";\nimport {\n ThreadListItemRuntimeBinding,\n ThreadRuntime,\n ThreadRuntimeCoreBinding,\n ThreadRuntimeImpl,\n} from \"./ThreadRuntime\";\nimport { Unsubscribe } from \"../types\";\nimport { ThreadListRuntime, ThreadListRuntimeImpl } from \"./ThreadListRuntime\";\n\nexport type AssistantRuntime = {\n /**\n * The currently selected main thread.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * The thread manager, to rename, archive and delete threads.\n */\n readonly threadList: ThreadListRuntime;\n\n /**\n * Switch to a new thread.\n */\n switchToNewThread(): void;\n\n /**\n * Switch to a thread.\n *\n * @param threadId The thread ID to switch to.\n */\n switchToThread(threadId: string): void;\n\n /**\n * Register a model config provider. Model config providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model config provider to register.\n */\n registerModelConfigProvider(provider: ModelConfigProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl implements AssistantRuntime {\n public readonly threadList;\n public readonly _thread: ThreadRuntime;\n\n protected constructor(\n private readonly _core: AssistantRuntimeCore,\n runtimeFactory: new (\n binding: ThreadRuntimeCoreBinding,\n threadListItemBinding: ThreadListItemRuntimeBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ) {\n this.threadList = new ThreadListRuntimeImpl(_core.threadList);\n this._thread = new runtimeFactory(\n new NestedSubscriptionSubject({\n path: {\n ref: \"threads.main\",\n threadSelector: { type: \"main\" },\n },\n getState: () => _core.threadList.getMainThreadRuntimeCore(),\n subscribe: (callback) => _core.threadList.subscribe(callback),\n }),\n this.threadList.mainItem, // TODO capture \"main\" threadListItem from context around useLocalRuntime / useExternalStoreRuntime\n );\n }\n\n public get thread() {\n return this._thread;\n }\n\n public switchToNewThread() {\n return this._core.threadList.switchToNewThread();\n }\n\n public switchToThread(threadId: string) {\n return this._core.threadList.switchToThread(threadId);\n }\n\n public registerModelConfigProvider(provider: ModelConfigProvider) {\n return this._core.registerModelConfigProvider(provider);\n }\n\n public static create(\n _core: AssistantRuntimeCore,\n runtimeFactory: new (\n binding: ThreadRuntimeCoreBinding,\n threadListItemBinding: ThreadListItemRuntimeBinding,\n ) => ThreadRuntime = ThreadRuntimeImpl,\n ): AssistantRuntime {\n return new AssistantRuntimeImpl(_core, runtimeFactory);\n }\n}\n"],"mappings":";AACA,SAAS,iCAAiC;AAE1C;AAAA,EAIE;AAAA,OACK;AAEP,SAA4B,6BAA6B;AAiClD,IAAM,uBAAN,MAAM,sBAAiD;AAAA,EAIlD,YACS,OACjB,iBAGqB,mBACrB;AALiB;AAMjB,SAAK,aAAa,IAAI,sBAAsB,MAAM,UAAU;AAC5D,SAAK,UAAU,IAAI;AAAA,MACjB,IAAI,0BAA0B;AAAA,QAC5B,MAAM;AAAA,UACJ,KAAK;AAAA,UACL,gBAAgB,EAAE,MAAM,OAAO;AAAA,QACjC;AAAA,QACA,UAAU,MAAM,MAAM,WAAW,yBAAyB;AAAA,QAC1D,WAAW,CAAC,aAAa,MAAM,WAAW,UAAU,QAAQ;AAAA,MAC9D,CAAC;AAAA,MACD,KAAK,WAAW;AAAA;AAAA,IAClB;AAAA,EACF;AAAA,EAtBgB;AAAA,EACA;AAAA,EAuBhB,IAAW,SAAS;AAClB,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,oBAAoB;AACzB,WAAO,KAAK,MAAM,WAAW,kBAAkB;AAAA,EACjD;AAAA,EAEO,eAAe,UAAkB;AACtC,WAAO,KAAK,MAAM,WAAW,eAAe,QAAQ;AAAA,EACtD;AAAA,EAEO,4BAA4B,UAA+B;AAChE,WAAO,KAAK,MAAM,4BAA4B,QAAQ;AAAA,EACxD;AAAA,EAEA,OAAc,OACZ,OACA,iBAGqB,mBACH;AAClB,WAAO,IAAI,sBAAqB,OAAO,cAAc;AAAA,EACvD;AACF;","names":[]}
|
|
@@ -38,7 +38,8 @@ export type ComposerRuntime = {
|
|
|
38
38
|
setText(text: string): void;
|
|
39
39
|
setRole(role: MessageRole): void;
|
|
40
40
|
setRunConfig(runConfig: RunConfig): void;
|
|
41
|
-
reset(): void
|
|
41
|
+
reset(): Promise<void>;
|
|
42
|
+
clearAttachments(): Promise<void>;
|
|
42
43
|
send(): void;
|
|
43
44
|
cancel(): void;
|
|
44
45
|
subscribe(callback: () => void): Unsubscribe;
|
|
@@ -53,7 +54,8 @@ export declare abstract class ComposerRuntimeImpl implements ComposerRuntime {
|
|
|
53
54
|
setText(text: string): void;
|
|
54
55
|
setRunConfig(runConfig: RunConfig): void;
|
|
55
56
|
addAttachment(file: File): Promise<void>;
|
|
56
|
-
reset(): void
|
|
57
|
+
reset(): Promise<void>;
|
|
58
|
+
clearAttachments(): Promise<void>;
|
|
57
59
|
send(): void;
|
|
58
60
|
cancel(): void;
|
|
59
61
|
setRole(role: MessageRole): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComposerRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ComposerRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AACzE,OAAO,EACL,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EAC1B,MAAM,sCAAsC,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EACL,iBAAiB,EAEjB,iCAAiC,EACjC,mCAAmC,EACpC,MAAM,qBAAqB,CAAC;AAG7B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEjE,MAAM,MAAM,gCAAgC,GAAG,qBAAqB,CAClE,yBAAyB,GAAG,SAAS,EACrC,mBAAmB,GAAG;IAAE,cAAc,EA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AAI,EAAE,gCAAgC;IAclC,QAAQ,IAAI,mBAAmB;IAIxC,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAwBxC;AAED,MAAM,MAAM,mBAAmB,GAAG,IAAI,CACpC,eAAe,EACf,UAAU,GAAG,sBAAsB,CACpC,GAAG;IACF,QAAQ,CAAC,IAAI,EAAE,mBAAmB,GAAG;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,QAAQ,IAAI,iBAAiB,CAAC;IAC9B,SAAS,IAAI,IAAI,CAAC;IAElB,oBAAoB,CAClB,GAAG,EAAE,MAAM,GACV,iBAAiB,GAAG;QAAE,MAAM,EAAE,eAAe,CAAA;KAAE,CAAC;CACpD,CAAC;AAEF,qBAAa,uBACX,SAAQ,mBACR,YAAW,mBAAmB;IAa5B,OAAO,CAAC,UAAU;IAXpB,IAAoB,IAAI,IACI,mBAAmB,GAAG;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE,CAC3E;IAED,IAAW,IAAI,IACN,MAAM,CACd;IAED,OAAO,CAAC,SAAS,CAAC;gBAEhB,IAAI,EAAE,8BAA8B,EAC5B,UAAU,EAAE,MAAM,IAAI;IAiBhB,QAAQ,IAAI,iBAAiB;IAItC,SAAS;IAIT,oBAAoB,CAAC,GAAG,EAAE,MAAM;CAwBxC"}
|
|
@@ -82,7 +82,12 @@ var ComposerRuntimeImpl = class {
|
|
|
82
82
|
reset() {
|
|
83
83
|
const core = this._core.getState();
|
|
84
84
|
if (!core) throw new Error("Composer is not available");
|
|
85
|
-
core.reset();
|
|
85
|
+
return core.reset();
|
|
86
|
+
}
|
|
87
|
+
clearAttachments() {
|
|
88
|
+
const core = this._core.getState();
|
|
89
|
+
if (!core) throw new Error("Composer is not available");
|
|
90
|
+
return core.clearAttachments();
|
|
86
91
|
}
|
|
87
92
|
send() {
|
|
88
93
|
const core = this._core.getState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole, RunConfig } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n readonly canCancel: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n readonly runConfig: RunConfig;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n\n readonly attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst EMPTY_OBJECT = Object.freeze({});\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n setText(text: string): void;\n setRole(role: MessageRole): void;\n setRunConfig(runConfig: RunConfig): void;\n\n reset(): void;\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setRunConfig(runConfig: RunConfig) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRunConfig(runConfig);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.reset();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n\n return core.unstable_on(event, callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAAmC;AACnC,+BAKO;AACP,mCAAsC;AACtC,yBAA4B;AA0C5B,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,eAAe,OAAO,OAAO,CAAC,CAAC;AACrC,IAAM,yBAAyB,CAC7B,YACwB;AACxB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAE7B,aAAa,SAAS,eAAe;AAAA,IACrC,MAAM,SAAS,QAAQ;AAAA,IACvB,MAAM,SAAS,QAAQ;AAAA,IACvB,WAAW,SAAS,aAAa;AAAA,IAEjC,OAAO,SAAS,QAAQ;AAAA,EAC1B,CAAC;AACH;AAEA,IAAM,uBAAuB,CAC3B,YACsB;AACtB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAE7B,MAAM,SAAS,QAAQ;AAAA,IACvB,MAAM,SAAS,QAAQ;AAAA,IACvB,aAAa,SAAS,eAAe;AAAA,IACrC,WAAW,SAAS,aAAa;AAAA,IAEjC,OAAO,SAAS,QAAQ;AAAA,EAC1B,CAAC;AACH;AAqBO,IAAe,sBAAf,MAA8D;AAAA,EAOnE,YAAsB,OAAmC;AAAnC;AAAA,EAAoC;AAAA,EAN1D,IAAW,OAAO;AAChB,WA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YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole, RunConfig } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n readonly canCancel: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n readonly runConfig: RunConfig;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n\n readonly attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst EMPTY_OBJECT = Object.freeze({});\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n setText(text: string): void;\n setRole(role: MessageRole): void;\n setRunConfig(runConfig: RunConfig): void;\n\n reset(): Promise<void>;\n clearAttachments(): Promise<void>;\n\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setRunConfig(runConfig: RunConfig) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRunConfig(runConfig);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.reset();\n }\n\n public clearAttachments() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.clearAttachments();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n\n return core.unstable_on(event, callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,gCAAmC;AACnC,+BAKO;AACP,mCAAsC;AACtC,yBAA4B;AA0C5B,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,eAAe,OAAO,OAAO,CAAC,CAAC;AACrC,IAAM,yBAAyB,CAC7B,YACwB;AACxB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAE7B,aAAa,SAAS,eAAe;AAAA,IACrC,MAAM,SAAS,QAAQ;AAAA,IACvB,MAAM,SAAS,QAAQ;AAAA,IACvB,WAAW,SAAS,aAAa;AAAA,IAEjC,OAAO,SAAS,QAAQ;AAAA,EAC1B,CAAC;AACH;AAEA,IAAM,uBAAuB,CAC3B,YACsB;AACtB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAE7B,MAAM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AAAA,EAEO,qBAAqB,KAAa;AACvC,WAAO,IAAI;AAAA,MACT,IAAI,mDAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,GAAG,KAAK;AAAA,UACR,kBAAkB;AAAA,UAClB,oBAAoB,EAAE,MAAM,SAAS,OAAO,IAAI;AAAA,UAChD,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,GAAG,gBAAgB,GAAG;AAAA,QAC1D;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,cAAc,KAAK,SAAS,EAAE;AACpC,gBAAM,aAAa,YAAY,GAAG;AAClC,cAAI,CAAC,WAAY,QAAO;AAExB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -59,7 +59,12 @@ var ComposerRuntimeImpl = class {
|
|
|
59
59
|
reset() {
|
|
60
60
|
const core = this._core.getState();
|
|
61
61
|
if (!core) throw new Error("Composer is not available");
|
|
62
|
-
core.reset();
|
|
62
|
+
return core.reset();
|
|
63
|
+
}
|
|
64
|
+
clearAttachments() {
|
|
65
|
+
const core = this._core.getState();
|
|
66
|
+
if (!core) throw new Error("Composer is not available");
|
|
67
|
+
return core.clearAttachments();
|
|
63
68
|
}
|
|
64
69
|
send() {
|
|
65
70
|
const core = this._core.getState();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole, RunConfig } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n readonly canCancel: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n readonly runConfig: RunConfig;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n\n readonly attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst EMPTY_OBJECT = Object.freeze({});\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n setText(text: string): void;\n setRole(role: MessageRole): void;\n setRunConfig(runConfig: RunConfig): void;\n\n reset(): void;\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setRunConfig(runConfig: RunConfig) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRunConfig(runConfig);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.reset();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n\n return core.unstable_on(event, callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";AAQA,SAAS,0BAA0B;AACnC;AAAA,EAGE;AAAA,EACA;AA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,SAAS,CAAC;AAAA,MACpD,WAAW,CAAC,aAAa,KAAK,UAAU,QAAQ;AAAA,IAClD,CAAC;AAED,UAAM;AAAA,MACJ,MAAM,KAAK;AAAA,MACX,UAAU,MAAM,KAAK,SAAS;AAAA,MAC9B,WAAW,CAAC,aAAa,aAAa,UAAU,QAAQ;AAAA,IAC1D,CAAC;AAZO;AAcR,SAAK,YAAY,aAAa,SAAS,KAAK,YAAY;AAAA,EAC1D;AAAA,EA1BA,IAAoB,OAAO;AACzB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAEA,IAAW,OAAO;AAChB,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAoBQ,WAA8B;AAC5C,WAAO,KAAK,UAAU;AAAA,EACxB;AAAA,EAEO,YAAY;AACjB,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,qBAAqB,KAAa;AACvC,WAAO,IAAI;AAAA,MACT,IAAI,sBAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,GAAG,KAAK;AAAA,UACR,kBAAkB;AAAA,UAClB,oBAAoB,EAAE,MAAM,SAAS,OAAO,IAAI;AAAA,UAChD,KAAK,KAAK,KAAK,MAAM,GAAG,KAAK,KAAK,GAAG,gBAAgB,GAAG;AAAA,QAC1D;AAAA,QACA,UAAU,MAAM;AACd,gBAAM,cAAc,KAAK,SAAS,EAAE;AACpC,gBAAM,aAAa,YAAY,GAAG;AAClC,cAAI,CAAC,WAAY,QAAO;AAExB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/api/ComposerRuntime.ts"],"sourcesContent":["import { Attachment, PendingAttachment } from \"../types/AttachmentTypes\";\nimport {\n ComposerRuntimeCore,\n ComposerRuntimeEventType,\n ThreadComposerRuntimeCore,\n} from \"../runtimes/core/ComposerRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport {\n AttachmentRuntime,\n AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./AttachmentRuntime\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ComposerRuntimePath } from \"./RuntimePathTypes\";\nimport { MessageRole, RunConfig } from \"../types/AssistantTypes\";\n\nexport type ThreadComposerRuntimeCoreBinding = SubscribableWithState<\n ThreadComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"thread\" }\n>;\n\nexport type EditComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath & { composerSource: \"edit\" }\n>;\n\nexport type ComposerRuntimeCoreBinding = SubscribableWithState<\n ComposerRuntimeCore | undefined,\n ComposerRuntimePath\n>;\n\ntype BaseComposerState = {\n readonly canCancel: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n readonly runConfig: RunConfig;\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n\n readonly attachments: readonly PendingAttachment[];\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst EMPTY_OBJECT = Object.freeze({});\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: ComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n getState(): ComposerState;\n\n getAttachmentAccept(): string;\n addAttachment(file: File): Promise<void>;\n\n setText(text: string): void;\n setRole(role: MessageRole): void;\n setRunConfig(runConfig: RunConfig): void;\n\n reset(): Promise<void>;\n clearAttachments(): Promise<void>;\n\n send(): void;\n cancel(): void;\n subscribe(callback: () => void): Unsubscribe;\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setRunConfig(runConfig: RunConfig) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRunConfig(runConfig);\n }\n\n public addAttachment(file: File) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(file);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.reset();\n }\n\n public clearAttachments() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.clearAttachments();\n }\n\n public send() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send();\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n public unstable_on(event: ComposerRuntimeEventType, callback: () => void) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n\n return core.unstable_on(event, callback);\n }\n\n public getAttachmentAccept(): string {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.getAttachmentAccept();\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: this.path.ref + `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";AAQA,SAAS,0BAA0B;AACnC;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAS,6BAA6B;AACtC,SAAS,mBAAmB;AA0C5B,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,eAAe,OAAO,OAAO,CAAC,CAAC;AACrC,IAAM,yBAAyB,CAC7B,YACwB;AACxB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAE7B,aAAa,SAAS,eAAe;AAAA,IACrC,MAAM,SAAS,QAAQ;AAAA,IACvB,MAAM,SAAS,QAAQ;AAAA,IACvB,WAAW,SAAS,aAAa;AAAA,IAEjC,OAAO,SAAS,QAAQ;AAAA,EAC1B,CAAC;AACH;AAEA,IAAM,uBAAuB,CAC3B,YACsB;AACtB,SAAO,OAAO,OAAO;AAAA,IACnB,MAAM;AAAA,IAEN,WAAW,SAAS,aAAa;AAAA,IACjC,WAAW,SAAS,aAAa;AAAA,IACjC,SAAS,SAAS,WAAW;AAAA,IAE7B,MAAM,SAAS,QAAQ;AAAA,IACvB,MAAM,SAAS,QAAQ;AAAA,IACvB,aAAa,SAAS,eAAe;AAAA,IACrC,WAAW,SAAS,aAAa;AAAA,IAEjC,OAAO,SAAS,QAAQ;AAAA,EAC1B,CAAC;AACH;AAuBO,IAAe,sBAAf,MAA8D;AAAA,EAOnE,YAAsB,OAAmC;AAAnC;AAAA,EAAoC;AAAA,EAN1D,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAQO,QAA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,SAAS,EAAE;AACpC,gBAAM,aAAa,YAAY,GAAG;AAClC,cAAI,CAAC,WAAY,QAAO;AAExB,iBAAO;AAAA,YACL,GAAG;AAAA,YACH,QAAQ;AAAA,UACV;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -6,11 +6,13 @@ export type ThreadListItemEventType = "switched-to" | "switched-away";
|
|
|
6
6
|
export type ThreadListItemState = {
|
|
7
7
|
readonly isMain: boolean;
|
|
8
8
|
readonly id: string;
|
|
9
|
+
readonly remoteId: string | undefined;
|
|
10
|
+
readonly externalId: string | undefined;
|
|
9
11
|
/**
|
|
10
12
|
* @deprecated This field was renamed to `id`. This field will be removed in 0.8.0.
|
|
11
13
|
*/
|
|
12
14
|
readonly threadId: string;
|
|
13
|
-
readonly
|
|
15
|
+
readonly status: "archived" | "regular" | "new" | "deleted";
|
|
14
16
|
readonly title?: string | undefined;
|
|
15
17
|
};
|
|
16
18
|
export type ThreadListItemRuntime = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListItemRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ThreadListItemRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,qBAAqB,CAAC;AAEnE,MAAM,MAAM,uBAAuB,GAAG,aAAa,GAAG,eAAe,CAAC;AAEtE,MAAM,MAAM,mBAAmB,GAAG;IAChC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file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;IAE7C,WAAW,CACT,KAAK,EAAE,uBAAuB,EAC9B,QAAQ,EAAE,MAAM,IAAI,GACnB,WAAW,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,qBAAqB,CAC5D,mBAAmB,EACnB,yBAAyB,CAC1B,CAAC;AAEF,qBAAa,yBAA0B,YAAW,qBAAqB;IAMnE,OAAO,CAAC,KAAK;IACb,OAAO,CAAC,kBAAkB;IAN5B,IAAW,IAAI,8BAEd;gBAGS,KAAK,EAAE,0BAA0B,EACjC,kBAAkB,EAAE,4BAA4B;IAGnD,QAAQ,IAAI,mBAAmB;IAI/B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAKzB,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAMxB,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAM1B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvB,WAAW,CAAC,KAAK,EAAE,uBAAuB,EAAE,QAAQ,EAAE,MAAM,IAAI;IAahE,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;CAGpD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemEventType = \"switched-to\" | \"switched-away\";\n\nexport type ThreadListItemState = {\n readonly isMain: boolean;\n\n readonly id: string;\n\n /**\n * @deprecated This field was renamed to `id`. This field will be removed in 0.8.0.\n */\n readonly threadId: string;\n\n readonly
|
|
1
|
+
{"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemEventType = \"switched-to\" | \"switched-away\";\n\nexport type ThreadListItemState = {\n readonly isMain: boolean;\n\n readonly id: string;\n readonly remoteId: string | undefined;\n readonly externalId: string | undefined;\n\n /**\n * @deprecated This field was renamed to `id`. This field will be removed in 0.8.0.\n */\n readonly threadId: string;\n\n readonly status: \"archived\" | \"regular\" | \"new\" | \"deleted\";\n readonly title?: string | undefined;\n};\n\nexport type ThreadListItemRuntime = {\n readonly path: ThreadListItemRuntimePath;\n getState(): ThreadListItemState;\n\n switchTo(): Promise<void>;\n rename(newTitle: string): Promise<void>;\n archive(): Promise<void>;\n unarchive(): Promise<void>;\n delete(): Promise<void>;\n\n subscribe(callback: () => void): Unsubscribe;\n\n unstable_on(\n event: ThreadListItemEventType,\n callback: () => void,\n ): Unsubscribe;\n};\n\nexport type ThreadListItemStateBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\n>;\n\nexport class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: ThreadListItemStateBinding,\n private _threadListBinding: ThreadListRuntimeCoreBinding,\n ) {}\n\n public getState(): ThreadListItemState {\n return this._core.getState();\n }\n\n public switchTo(): Promise<void> {\n const state = this._core.getState();\n return this._threadListBinding.switchToThread(state.id);\n }\n\n public rename(newTitle: string): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.rename(state.id, newTitle);\n }\n\n public archive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.archive(state.id);\n }\n\n public unarchive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.unarchive(state.id);\n }\n\n public delete(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.delete(state.id);\n }\n\n public unstable_on(event: ThreadListItemEventType, callback: () => void) {\n let prevIsMain = this._core.getState().isMain;\n return this.subscribe(() => {\n const newIsMain = this._core.getState().isMain;\n if (prevIsMain === newIsMain) return;\n prevIsMain = newIsMain;\n\n if (event === \"switched-to\" && !newIsMain) return;\n if (event === \"switched-away\" && newIsMain) return;\n callback();\n });\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA8CO,IAAM,4BAAN,MAAiE;AAAA,EAKtE,YACU,OACA,oBACR;AAFQ;AACA;AAAA,EACP;AAAA,EAPH,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAOO,WAAgC;AACrC,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAEO,WAA0B;AAC/B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAClC,WAAO,KAAK,mBAAmB,eAAe,MAAM,EAAE;AAAA,EACxD;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,IAAI,QAAQ;AAAA,EAC1D;AAAA,EAEO,UAAyB;AAC9B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,QAAQ,MAAM,EAAE;AAAA,EACjD;AAAA,EAEO,YAA2B;AAChC,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,UAAU,MAAM,EAAE;AAAA,EACnD;AAAA,EAEO,SAAwB;AAC7B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,EAAE;AAAA,EAChD;AAAA,EAEO,YAAY,OAAgC,UAAsB;AACvE,QAAI,aAAa,KAAK,MAAM,SAAS,EAAE;AACvC,WAAO,KAAK,UAAU,MAAM;AAC1B,YAAM,YAAY,KAAK,MAAM,SAAS,EAAE;AACxC,UAAI,eAAe,UAAW;AAC9B,mBAAa;AAEb,UAAI,UAAU,iBAAiB,CAAC,UAAW;AAC3C,UAAI,UAAU,mBAAmB,UAAW;AAC5C,eAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAmC;AAClD,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemEventType = \"switched-to\" | \"switched-away\";\n\nexport type ThreadListItemState = {\n readonly isMain: boolean;\n\n readonly id: string;\n\n /**\n * @deprecated This field was renamed to `id`. This field will be removed in 0.8.0.\n */\n readonly threadId: string;\n\n readonly
|
|
1
|
+
{"version":3,"sources":["../../src/api/ThreadListItemRuntime.ts"],"sourcesContent":["import { Unsubscribe } from \"../types\";\nimport { ThreadListItemRuntimePath } from \"./RuntimePathTypes\";\nimport { SubscribableWithState } from \"./subscribable/Subscribable\";\nimport { ThreadListRuntimeCoreBinding } from \"./ThreadListRuntime\";\n\nexport type ThreadListItemEventType = \"switched-to\" | \"switched-away\";\n\nexport type ThreadListItemState = {\n readonly isMain: boolean;\n\n readonly id: string;\n readonly remoteId: string | undefined;\n readonly externalId: string | undefined;\n\n /**\n * @deprecated This field was renamed to `id`. This field will be removed in 0.8.0.\n */\n readonly threadId: string;\n\n readonly status: \"archived\" | \"regular\" | \"new\" | \"deleted\";\n readonly title?: string | undefined;\n};\n\nexport type ThreadListItemRuntime = {\n readonly path: ThreadListItemRuntimePath;\n getState(): ThreadListItemState;\n\n switchTo(): Promise<void>;\n rename(newTitle: string): Promise<void>;\n archive(): Promise<void>;\n unarchive(): Promise<void>;\n delete(): Promise<void>;\n\n subscribe(callback: () => void): Unsubscribe;\n\n unstable_on(\n event: ThreadListItemEventType,\n callback: () => void,\n ): Unsubscribe;\n};\n\nexport type ThreadListItemStateBinding = SubscribableWithState<\n ThreadListItemState,\n ThreadListItemRuntimePath\n>;\n\nexport class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {\n public get path() {\n return this._core.path;\n }\n\n constructor(\n private _core: ThreadListItemStateBinding,\n private _threadListBinding: ThreadListRuntimeCoreBinding,\n ) {}\n\n public getState(): ThreadListItemState {\n return this._core.getState();\n }\n\n public switchTo(): Promise<void> {\n const state = this._core.getState();\n return this._threadListBinding.switchToThread(state.id);\n }\n\n public rename(newTitle: string): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.rename(state.id, newTitle);\n }\n\n public archive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.archive(state.id);\n }\n\n public unarchive(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.unarchive(state.id);\n }\n\n public delete(): Promise<void> {\n const state = this._core.getState();\n\n return this._threadListBinding.delete(state.id);\n }\n\n public unstable_on(event: ThreadListItemEventType, callback: () => void) {\n let prevIsMain = this._core.getState().isMain;\n return this.subscribe(() => {\n const newIsMain = this._core.getState().isMain;\n if (prevIsMain === newIsMain) return;\n prevIsMain = newIsMain;\n\n if (event === \"switched-to\" && !newIsMain) return;\n if (event === \"switched-away\" && newIsMain) return;\n callback();\n });\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n}\n"],"mappings":";AA8CO,IAAM,4BAAN,MAAiE;AAAA,EAKtE,YACU,OACA,oBACR;AAFQ;AACA;AAAA,EACP;AAAA,EAPH,IAAW,OAAO;AAChB,WAAO,KAAK,MAAM;AAAA,EACpB;AAAA,EAOO,WAAgC;AACrC,WAAO,KAAK,MAAM,SAAS;AAAA,EAC7B;AAAA,EAEO,WAA0B;AAC/B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAClC,WAAO,KAAK,mBAAmB,eAAe,MAAM,EAAE;AAAA,EACxD;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,IAAI,QAAQ;AAAA,EAC1D;AAAA,EAEO,UAAyB;AAC9B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,QAAQ,MAAM,EAAE;AAAA,EACjD;AAAA,EAEO,YAA2B;AAChC,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,UAAU,MAAM,EAAE;AAAA,EACnD;AAAA,EAEO,SAAwB;AAC7B,UAAM,QAAQ,KAAK,MAAM,SAAS;AAElC,WAAO,KAAK,mBAAmB,OAAO,MAAM,EAAE;AAAA,EAChD;AAAA,EAEO,YAAY,OAAgC,UAAsB;AACvE,QAAI,aAAa,KAAK,MAAM,SAAS,EAAE;AACvC,WAAO,KAAK,UAAU,MAAM;AAC1B,YAAM,YAAY,KAAK,MAAM,SAAS,EAAE;AACxC,UAAI,eAAe,UAAW;AAC9B,mBAAa;AAEb,UAAI,UAAU,iBAAiB,CAAC,UAAW;AAC3C,UAAI,UAAU,mBAAmB,UAAW;AAC5C,eAAS;AAAA,IACX,CAAC;AAAA,EACH;AAAA,EAEO,UAAU,UAAmC;AAClD,WAAO,KAAK,MAAM,UAAU,QAAQ;AAAA,EACtC;AACF;","names":[]}
|
|
@@ -10,10 +10,10 @@ export type ThreadListState = {
|
|
|
10
10
|
export type ThreadListRuntime = {
|
|
11
11
|
getState(): ThreadListState;
|
|
12
12
|
subscribe(callback: () => void): Unsubscribe;
|
|
13
|
-
readonly
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
13
|
+
readonly mainItem: ThreadListItemRuntime;
|
|
14
|
+
getItemById(threadId: string): ThreadListItemRuntime;
|
|
15
|
+
getItemByIndex(idx: number): ThreadListItemRuntime;
|
|
16
|
+
getArchivedItemByIndex(idx: number): ThreadListItemRuntime;
|
|
17
17
|
};
|
|
18
18
|
export type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;
|
|
19
19
|
export declare class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
@@ -23,9 +23,9 @@ export declare class ThreadListRuntimeImpl implements ThreadListRuntime {
|
|
|
23
23
|
getState(): ThreadListState;
|
|
24
24
|
subscribe(callback: () => void): Unsubscribe;
|
|
25
25
|
private _mainThreadListItemRuntime;
|
|
26
|
-
get
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
get mainItem(): ThreadListItemRuntimeImpl;
|
|
27
|
+
getItemByIndex(idx: number): ThreadListItemRuntimeImpl;
|
|
28
|
+
getArchivedItemByIndex(idx: number): ThreadListItemRuntimeImpl;
|
|
29
|
+
getItemById(threadId: string): ThreadListItemRuntimeImpl;
|
|
30
30
|
}
|
|
31
31
|
//# sourceMappingURL=ThreadListRuntime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThreadListRuntime.d.ts","sourceRoot":"","sources":["../../src/api/ThreadListRuntime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EAE1B,MAAM,yBAAyB,CAAC;AAIjC,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,IAAI,eAAe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AAO,CAAC,0BAA0B,CAAC;IAEnC,IAAW,QAAQ,8BAElB;IAEM,cAAc,CAAC,GAAG,EAAE,MAAM;IAgB1B,sBAAsB,CAAC,GAAG,EAAE,MAAM;IAmBlC,WAAW,CAAC,QAAQ,EAAE,MAAM;CAepC"}
|
|
@@ -43,8 +43,10 @@ var getThreadListItemState = (threadList, threadId) => {
|
|
|
43
43
|
id: threadData.threadId,
|
|
44
44
|
threadId: threadData.threadId,
|
|
45
45
|
// TODO remove in 0.8.0
|
|
46
|
+
remoteId: threadData.remoteId,
|
|
47
|
+
externalId: threadData.externalId,
|
|
46
48
|
title: threadData.title,
|
|
47
|
-
|
|
49
|
+
status: threadData.status,
|
|
48
50
|
isMain: threadData.threadId === threadList.mainThreadId
|
|
49
51
|
};
|
|
50
52
|
};
|
|
@@ -79,10 +81,10 @@ var ThreadListRuntimeImpl = class {
|
|
|
79
81
|
return this._core.subscribe(callback);
|
|
80
82
|
}
|
|
81
83
|
_mainThreadListItemRuntime;
|
|
82
|
-
get
|
|
84
|
+
get mainItem() {
|
|
83
85
|
return this._mainThreadListItemRuntime;
|
|
84
86
|
}
|
|
85
|
-
|
|
87
|
+
getItemByIndex(idx) {
|
|
86
88
|
return new import_ThreadListItemRuntime.ThreadListItemRuntimeImpl(
|
|
87
89
|
new import_ShallowMemoizeSubject.ShallowMemoizeSubject({
|
|
88
90
|
path: {
|
|
@@ -97,7 +99,7 @@ var ThreadListRuntimeImpl = class {
|
|
|
97
99
|
this._core
|
|
98
100
|
);
|
|
99
101
|
}
|
|
100
|
-
|
|
102
|
+
getArchivedItemByIndex(idx) {
|
|
101
103
|
return new import_ThreadListItemRuntime.ThreadListItemRuntimeImpl(
|
|
102
104
|
new import_ShallowMemoizeSubject.ShallowMemoizeSubject({
|
|
103
105
|
path: {
|
|
@@ -115,7 +117,7 @@ var ThreadListRuntimeImpl = class {
|
|
|
115
117
|
this._core
|
|
116
118
|
);
|
|
117
119
|
}
|
|
118
|
-
|
|
120
|
+
getItemById(threadId) {
|
|
119
121
|
return new import_ThreadListItemRuntime.ThreadListItemRuntimeImpl(
|
|
120
122
|
new import_ShallowMemoizeSubject.ShallowMemoizeSubject({
|
|
121
123
|
path: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n readonly
|
|
1
|
+
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n readonly mainItem: ThreadListItemRuntime;\n getItemById(threadId: string): ThreadListItemRuntime;\n getItemByIndex(idx: number): ThreadListItemRuntime;\n getArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n};\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThreadId,\n newThread: threadList.newThreadId,\n threads: threadList.threadIds,\n archivedThreads: threadList.archivedThreadIds,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getItemById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n id: threadData.threadId,\n threadId: threadData.threadId, // TODO remove in 0.8.0\n remoteId: threadData.remoteId,\n externalId: threadData.externalId,\n title: threadData.title,\n status: threadData.status,\n isMain: threadData.threadId === threadList.mainThreadId,\n };\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: {},\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n\n this._mainThreadListItemRuntime = new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[main]`,\n threadSelector: { type: \"main\" },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.mainThreadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n private _mainThreadListItemRuntime;\n\n public get mainItem() {\n return this._mainThreadListItemRuntime;\n }\n\n public getItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threadIds[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreadIds[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gCAAmC;AAGnC,mCAIO;AACP,yBAA4B;AAC5B,mCAAsC;AAoBtC,IAAM,qBAAqB,CACzB,eACoB;AACpB,SAAO;AAAA,IACL,cAAc,WAAW;AAAA,IACzB,WAAW,WAAW;AAAA,IACtB,SAAS,WAAW;AAAA,IACpB,iBAAiB,WAAW;AAAA,EAC9B;AACF;AAEA,IAAM,yBAAyB,CAC7B,YACA,aACsC;AACtC,MAAI,aAAa,OAAW,QAAO;AAEnC,QAAM,aAAa,WAAW,YAAY,QAAQ;AAClD,MAAI,CAAC,WAAY,QAAO;AACxB,SAAO;AAAA,IACL,IAAI,WAAW;AAAA,IACf,UAAU,WAAW;AAAA;AAAA,IACrB,UAAU,WAAW;AAAA,IACrB,YAAY,WAAW;AAAA,IACvB,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW;AAAA,IACnB,QAAQ,WAAW,aAAa,WAAW;AAAA,E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;AACzC,WAAO,IAAI;AAAA,MACT,IAAI,mDAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,KAAK,uBAAuB,GAAG;AAAA,UAC/B,gBAAgB,EAAE,MAAM,gBAAgB,OAAO,IAAI;AAAA,QACrD;AAAA,QACA,UAAU,MAAM;AACd,iBAAO;AAAA,YACL,KAAK;AAAA,YACL,KAAK,MAAM,kBAAkB,GAAG;AAAA,UAClC;AAAA,QACF;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AAAA,EAEO,YAAY,UAAkB;AACnC,WAAO,IAAI;AAAA,MACT,IAAI,mDAAsB;AAAA,QACxB,MAAM;AAAA,UACJ,KAAK,wBAAwB,QAAQ;AAAA,UACrC,gBAAgB,EAAE,MAAM,YAAY,SAAS;AAAA,QAC/C;AAAA,QACA,UAAU,MAAM;AACd,iBAAO,uBAAuB,KAAK,OAAO,QAAQ;AAAA,QACpD;AAAA,QACA,WAAW,CAAC,aAAa,KAAK,MAAM,UAAU,QAAQ;AAAA,MACxD,CAAC;AAAA,MACD,KAAK;AAAA,IACP;AAAA,EACF;AACF;","names":[]}
|
|
@@ -21,8 +21,10 @@ var getThreadListItemState = (threadList, threadId) => {
|
|
|
21
21
|
id: threadData.threadId,
|
|
22
22
|
threadId: threadData.threadId,
|
|
23
23
|
// TODO remove in 0.8.0
|
|
24
|
+
remoteId: threadData.remoteId,
|
|
25
|
+
externalId: threadData.externalId,
|
|
24
26
|
title: threadData.title,
|
|
25
|
-
|
|
27
|
+
status: threadData.status,
|
|
26
28
|
isMain: threadData.threadId === threadList.mainThreadId
|
|
27
29
|
};
|
|
28
30
|
};
|
|
@@ -57,10 +59,10 @@ var ThreadListRuntimeImpl = class {
|
|
|
57
59
|
return this._core.subscribe(callback);
|
|
58
60
|
}
|
|
59
61
|
_mainThreadListItemRuntime;
|
|
60
|
-
get
|
|
62
|
+
get mainItem() {
|
|
61
63
|
return this._mainThreadListItemRuntime;
|
|
62
64
|
}
|
|
63
|
-
|
|
65
|
+
getItemByIndex(idx) {
|
|
64
66
|
return new ThreadListItemRuntimeImpl(
|
|
65
67
|
new ShallowMemoizeSubject({
|
|
66
68
|
path: {
|
|
@@ -75,7 +77,7 @@ var ThreadListRuntimeImpl = class {
|
|
|
75
77
|
this._core
|
|
76
78
|
);
|
|
77
79
|
}
|
|
78
|
-
|
|
80
|
+
getArchivedItemByIndex(idx) {
|
|
79
81
|
return new ThreadListItemRuntimeImpl(
|
|
80
82
|
new ShallowMemoizeSubject({
|
|
81
83
|
path: {
|
|
@@ -93,7 +95,7 @@ var ThreadListRuntimeImpl = class {
|
|
|
93
95
|
this._core
|
|
94
96
|
);
|
|
95
97
|
}
|
|
96
|
-
|
|
98
|
+
getItemById(threadId) {
|
|
97
99
|
return new ThreadListItemRuntimeImpl(
|
|
98
100
|
new ShallowMemoizeSubject({
|
|
99
101
|
path: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n readonly
|
|
1
|
+
{"version":3,"sources":["../../src/api/ThreadListRuntime.ts"],"sourcesContent":["import { LazyMemoizeSubject } from \"./subscribable/LazyMemoizeSubject\";\nimport { ThreadListRuntimeCore } from \"../runtimes/core/ThreadListRuntimeCore\";\nimport { Unsubscribe } from \"../types\";\nimport {\n ThreadListItemRuntime,\n ThreadListItemRuntimeImpl,\n ThreadListItemState,\n} from \"./ThreadListItemRuntime\";\nimport { SKIP_UPDATE } from \"./subscribable/SKIP_UPDATE\";\nimport { ShallowMemoizeSubject } from \"./subscribable/ShallowMemoizeSubject\";\n\nexport type ThreadListState = {\n readonly mainThreadId: string;\n readonly newThread: string | undefined;\n readonly threads: readonly string[];\n readonly archivedThreads: readonly string[];\n};\n\nexport type ThreadListRuntime = {\n getState(): ThreadListState;\n\n subscribe(callback: () => void): Unsubscribe;\n\n readonly mainItem: ThreadListItemRuntime;\n getItemById(threadId: string): ThreadListItemRuntime;\n getItemByIndex(idx: number): ThreadListItemRuntime;\n getArchivedItemByIndex(idx: number): ThreadListItemRuntime;\n};\n\nconst getThreadListState = (\n threadList: ThreadListRuntimeCore,\n): ThreadListState => {\n return {\n mainThreadId: threadList.mainThreadId,\n newThread: threadList.newThreadId,\n threads: threadList.threadIds,\n archivedThreads: threadList.archivedThreadIds,\n };\n};\n\nconst getThreadListItemState = (\n threadList: ThreadListRuntimeCore,\n threadId: string | undefined,\n): ThreadListItemState | SKIP_UPDATE => {\n if (threadId === undefined) return SKIP_UPDATE;\n\n const threadData = threadList.getItemById(threadId);\n if (!threadData) return SKIP_UPDATE;\n return {\n id: threadData.threadId,\n threadId: threadData.threadId, // TODO remove in 0.8.0\n remoteId: threadData.remoteId,\n externalId: threadData.externalId,\n title: threadData.title,\n status: threadData.status,\n isMain: threadData.threadId === threadList.mainThreadId,\n };\n};\n\nexport type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;\n\nexport class ThreadListRuntimeImpl implements ThreadListRuntime {\n private _getState;\n constructor(private _core: ThreadListRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: {},\n getState: () => getThreadListState(_core),\n subscribe: (callback) => _core.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n\n this._mainThreadListItemRuntime = new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[main]`,\n threadSelector: { type: \"main\" },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.mainThreadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getState(): ThreadListState {\n return this._getState();\n }\n\n public subscribe(callback: () => void): Unsubscribe {\n return this._core.subscribe(callback);\n }\n\n private _mainThreadListItemRuntime;\n\n public get mainItem() {\n return this._mainThreadListItemRuntime;\n }\n\n public getItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[${idx}]`,\n threadSelector: { type: \"index\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(this._core, this._core.threadIds[idx]);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getArchivedItemByIndex(idx: number) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `archivedThreadItems[${idx}]`,\n threadSelector: { type: \"archiveIndex\", index: idx },\n },\n getState: () => {\n return getThreadListItemState(\n this._core,\n this._core.archivedThreadIds[idx],\n );\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n\n public getItemById(threadId: string) {\n return new ThreadListItemRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ref: `threadItems[threadId=${threadId}]`,\n threadSelector: { type: \"threadId\", threadId },\n },\n getState: () => {\n return getThreadListItemState(this._core, threadId);\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";AAAA,SAAS,0BAA0B;AAGnC;AAAA,EAEE;AAAA,OAEK;AACP,SAAS,mBAAmB;AAC5B,SAAS,6BAA6B;AAoBtC,IAAM,qBAAqB,CACzB,eACoB;AACpB,SAAO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