@gradio/core 1.0.0-dev.0 → 1.0.0-dev.3
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/CHANGELOG.md +79 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/src/Blocks.svelte +518 -1001
- package/dist/src/Blocks.svelte.d.ts +31 -45
- package/dist/src/Embed.svelte +82 -55
- package/dist/src/Embed.svelte.d.ts +39 -30
- package/dist/src/Login.svelte +33 -29
- package/dist/src/Login.svelte.d.ts +21 -19
- package/dist/src/MountComponents.svelte +19 -25
- package/dist/src/MountComponents.svelte.d.ts +5 -28
- package/dist/src/{init.d.ts → _init.d.ts} +5 -4
- package/dist/src/{init.js → _init.js} +31 -108
- package/dist/src/api_docs/ApiBanner.svelte +12 -8
- package/dist/src/api_docs/ApiBanner.svelte.d.ts +22 -20
- package/dist/src/api_docs/ApiDocs.svelte +337 -245
- package/dist/src/api_docs/ApiDocs.svelte.d.ts +26 -24
- package/dist/src/api_docs/ApiRecorder.svelte +9 -3
- package/dist/src/api_docs/ApiRecorder.svelte.d.ts +19 -17
- package/dist/src/api_docs/CodeSnippet.svelte +60 -30
- package/dist/src/api_docs/CodeSnippet.svelte.d.ts +27 -24
- package/dist/src/api_docs/CopyButton.svelte +69 -13
- package/dist/src/api_docs/CopyButton.svelte.d.ts +18 -16
- package/dist/src/api_docs/CopyMarkdown.svelte +734 -0
- package/dist/src/api_docs/CopyMarkdown.svelte.d.ts +37 -0
- package/dist/src/api_docs/EndpointDetail.svelte +8 -6
- package/dist/src/api_docs/EndpointDetail.svelte.d.ts +20 -18
- package/dist/src/api_docs/IconArrowUpRight.svelte +34 -0
- package/dist/src/api_docs/IconArrowUpRight.svelte.d.ts +20 -0
- package/dist/src/api_docs/IconCaret.svelte +39 -0
- package/dist/src/api_docs/IconCaret.svelte.d.ts +20 -0
- package/dist/src/api_docs/IconHuggingChat.svelte +62 -0
- package/dist/src/api_docs/IconHuggingChat.svelte.d.ts +20 -0
- package/dist/src/api_docs/InputPayload.svelte +17 -11
- package/dist/src/api_docs/InputPayload.svelte.d.ts +25 -23
- package/dist/src/api_docs/InstallSnippet.svelte +9 -6
- package/dist/src/api_docs/InstallSnippet.svelte.d.ts +18 -16
- package/dist/src/api_docs/MCPSnippet.svelte +119 -99
- package/dist/src/api_docs/MCPSnippet.svelte.d.ts +59 -58
- package/dist/src/api_docs/NoApi.svelte +7 -4
- package/dist/src/api_docs/NoApi.svelte.d.ts +20 -18
- package/dist/src/api_docs/ParametersSnippet.svelte +8 -6
- package/dist/src/api_docs/ParametersSnippet.svelte.d.ts +21 -19
- package/dist/src/api_docs/RecordingSnippet.svelte +124 -110
- package/dist/src/api_docs/RecordingSnippet.svelte.d.ts +24 -22
- package/dist/src/api_docs/ResponseSnippet.svelte +7 -5
- package/dist/src/api_docs/ResponseSnippet.svelte.d.ts +21 -19
- package/dist/src/api_docs/Settings.svelte +73 -62
- package/dist/src/api_docs/Settings.svelte.d.ts +25 -23
- package/dist/src/api_docs/SettingsBanner.svelte +11 -8
- package/dist/src/api_docs/SettingsBanner.svelte.d.ts +20 -18
- package/dist/src/api_docs/TryButton.svelte +5 -3
- package/dist/src/api_docs/TryButton.svelte.d.ts +19 -17
- package/dist/src/api_docs/img/IconCheck.svelte +33 -0
- package/dist/src/api_docs/img/IconCheck.svelte.d.ts +26 -0
- package/dist/src/api_docs/img/IconCopy.svelte +40 -0
- package/dist/src/api_docs/img/IconCopy.svelte.d.ts +26 -0
- package/dist/src/api_docs/img/clear.svelte.d.ts +22 -21
- package/dist/src/dependency.d.ts +142 -0
- package/dist/src/dependency.js +653 -0
- package/dist/src/init.svelte.d.ts +78 -0
- package/dist/src/init.svelte.js +469 -0
- package/dist/src/init_utils.d.ts +32 -0
- package/dist/src/init_utils.js +73 -0
- package/dist/src/lang/en.json +10 -1
- package/dist/src/lang/get_lang_names.js +0 -3
- package/dist/src/lang/ru.json +10 -1
- package/dist/src/stores.d.ts +0 -21
- package/dist/src/stories/I18nMultiLanguageTestComponent.svelte +5 -3
- package/dist/src/stories/I18nMultiLanguageTestComponent.svelte.d.ts +16 -14
- package/dist/src/stories/I18nTestSetup.svelte +14 -10
- package/dist/src/stories/I18nTestSetup.svelte.d.ts +18 -16
- package/dist/src/types.d.ts +30 -26
- package/index.ts +1 -1
- package/package.json +59 -59
- package/src/Blocks.svelte +344 -1063
- package/src/MountComponents.svelte +17 -27
- package/src/{init.ts → _init.ts} +49 -126
- package/src/api_docs/ApiDocs.svelte +65 -60
- package/src/api_docs/ApiRecorder.svelte +3 -0
- package/src/api_docs/CodeSnippet.svelte +20 -5
- package/src/api_docs/CopyButton.svelte +61 -7
- package/src/api_docs/CopyMarkdown.svelte +734 -0
- package/src/api_docs/IconArrowUpRight.svelte +34 -0
- package/src/api_docs/IconCaret.svelte +39 -0
- package/src/api_docs/IconHuggingChat.svelte +62 -0
- package/src/api_docs/MCPSnippet.svelte +24 -46
- package/src/api_docs/ParametersSnippet.svelte +1 -1
- package/src/api_docs/ResponseSnippet.svelte +1 -1
- package/src/api_docs/Settings.svelte +11 -11
- package/src/api_docs/img/IconCheck.svelte +33 -0
- package/src/api_docs/img/IconCopy.svelte +40 -0
- package/src/dependency.ts +880 -0
- package/src/init.svelte.ts +717 -0
- package/src/init_utils.ts +99 -0
- package/src/lang/en.json +10 -1
- package/src/lang/get_lang_names.js +0 -3
- package/src/lang/ru.json +10 -1
- package/src/stores.ts +22 -22
- package/src/types.ts +54 -43
- package/dist/src/Render.svelte +0 -105
- package/dist/src/Render.svelte.d.ts +0 -31
- package/dist/src/RenderComponent.svelte +0 -72
- package/dist/src/RenderComponent.svelte.d.ts +0 -33
- package/src/Render.svelte +0 -126
- package/src/RenderComponent.svelte +0 -91
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: Props & {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
6
11
|
};
|
|
7
|
-
|
|
8
|
-
[evt: string]: CustomEvent<any>;
|
|
9
|
-
};
|
|
10
|
-
slots: {};
|
|
11
|
-
exports?: {} | undefined;
|
|
12
|
-
bindings?: string | undefined;
|
|
13
|
-
};
|
|
14
|
-
export type TryButtonProps = typeof __propDef.props;
|
|
15
|
-
export type TryButtonEvents = typeof __propDef.events;
|
|
16
|
-
export type TryButtonSlots = typeof __propDef.slots;
|
|
17
|
-
export default class TryButton extends SvelteComponent<TryButtonProps, TryButtonEvents, TryButtonSlots> {
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
18
13
|
}
|
|
19
|
-
|
|
14
|
+
declare const TryButton: $$__sveltets_2_IsomorphicComponent<{
|
|
15
|
+
dependency_index: number;
|
|
16
|
+
run: (id: number) => Promise<void>;
|
|
17
|
+
}, {
|
|
18
|
+
[evt: string]: CustomEvent<any>;
|
|
19
|
+
}, {}, {}, string>;
|
|
20
|
+
type TryButton = InstanceType<typeof TryButton>;
|
|
21
|
+
export default TryButton;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let classNames = "";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
class={classNames || "icon-size"}
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
height="16"
|
|
10
|
+
viewBox="0 0 16 16"
|
|
11
|
+
version="1.1"
|
|
12
|
+
width="16"
|
|
13
|
+
data-view-component="true"
|
|
14
|
+
><path
|
|
15
|
+
fill-rule="evenodd"
|
|
16
|
+
fill="rgb(255, 124, 1)"
|
|
17
|
+
d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"
|
|
18
|
+
></path></svg
|
|
19
|
+
>
|
|
20
|
+
|
|
21
|
+
<style>
|
|
22
|
+
.icon-size {
|
|
23
|
+
width: 0.75rem;
|
|
24
|
+
height: 0.75rem;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media (max-width: 640px) {
|
|
28
|
+
.icon-size {
|
|
29
|
+
width: 0.625rem;
|
|
30
|
+
height: 0.625rem;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default IconCheck;
|
|
2
|
+
type IconCheck = SvelteComponent<{
|
|
3
|
+
classNames?: string | undefined;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const IconCheck: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
classNames?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: Props & {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
export let classNames = "";
|
|
3
|
+
</script>
|
|
4
|
+
|
|
5
|
+
<svg
|
|
6
|
+
class={classNames}
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
aria-hidden="true"
|
|
9
|
+
fill="currentColor"
|
|
10
|
+
focusable="false"
|
|
11
|
+
role="img"
|
|
12
|
+
width="1em"
|
|
13
|
+
height="1em"
|
|
14
|
+
preserveAspectRatio="xMidYMid meet"
|
|
15
|
+
viewBox="0 0 32 32"
|
|
16
|
+
>
|
|
17
|
+
<path
|
|
18
|
+
d="M28,10V28H10V10H28m0-2H10a2,2,0,0,0-2,2V28a2,2,0,0,0,2,2H28a2,2,0,0,0,2-2V10a2,2,0,0,0-2-2Z"
|
|
19
|
+
transform="translate(0)"
|
|
20
|
+
/>
|
|
21
|
+
<path d="M4,18H2V4A2,2,0,0,1,4,2H18V4H4Z" transform="translate(0)" /><rect
|
|
22
|
+
fill="none"
|
|
23
|
+
width="32"
|
|
24
|
+
height="32"
|
|
25
|
+
/>
|
|
26
|
+
</svg>
|
|
27
|
+
|
|
28
|
+
<style>
|
|
29
|
+
.icon-size {
|
|
30
|
+
width: 0.75rem;
|
|
31
|
+
height: 0.75rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@media (max-width: 640px) {
|
|
35
|
+
.icon-size {
|
|
36
|
+
width: 0.625rem;
|
|
37
|
+
height: 0.625rem;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export default IconCopy;
|
|
2
|
+
type IconCopy = SvelteComponent<{
|
|
3
|
+
classNames?: string | undefined;
|
|
4
|
+
}, {
|
|
5
|
+
[evt: string]: CustomEvent<any>;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
8
|
+
};
|
|
9
|
+
declare const IconCopy: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
classNames?: string | undefined;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: Props & {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** @typedef {typeof __propDef.slots} ClearSlots */
|
|
4
|
-
export default class Clear extends SvelteComponent<{
|
|
1
|
+
export default Clear;
|
|
2
|
+
type Clear = SvelteComponent<{
|
|
5
3
|
[x: string]: never;
|
|
6
4
|
}, {
|
|
7
5
|
[evt: string]: CustomEvent<any>;
|
|
8
|
-
}, {}> {
|
|
9
|
-
|
|
10
|
-
export type ClearProps = typeof __propDef.props;
|
|
11
|
-
export type ClearEvents = typeof __propDef.events;
|
|
12
|
-
export type ClearSlots = typeof __propDef.slots;
|
|
13
|
-
import { SvelteComponent } from "svelte";
|
|
14
|
-
declare const __propDef: {
|
|
15
|
-
props: {
|
|
16
|
-
[x: string]: never;
|
|
17
|
-
};
|
|
18
|
-
events: {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
};
|
|
21
|
-
slots: {};
|
|
22
|
-
exports?: undefined;
|
|
23
|
-
bindings?: undefined;
|
|
6
|
+
}, {}> & {
|
|
7
|
+
$$bindings?: string | undefined;
|
|
24
8
|
};
|
|
25
|
-
|
|
9
|
+
declare const Clear: $$__sveltets_2_IsomorphicComponent<{
|
|
10
|
+
[x: string]: never;
|
|
11
|
+
}, {
|
|
12
|
+
[evt: string]: CustomEvent<any>;
|
|
13
|
+
}, {}, {}, string>;
|
|
14
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
15
|
+
new (options: import("svelte").ComponentConstructorOptions<Props>): import("svelte").SvelteComponent<Props, Events, Slots> & {
|
|
16
|
+
$$bindings?: Bindings;
|
|
17
|
+
} & Exports;
|
|
18
|
+
(internal: unknown, props: {
|
|
19
|
+
$$events?: Events;
|
|
20
|
+
$$slots?: Slots;
|
|
21
|
+
}): Exports & {
|
|
22
|
+
$set?: any;
|
|
23
|
+
$on?: any;
|
|
24
|
+
};
|
|
25
|
+
z_$$bindings?: Bindings;
|
|
26
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ComponentMeta, Dependency as IDependency, LayoutNode, Payload } from "./types.js";
|
|
2
|
+
import { Client, type client_return } from "@gradio/client";
|
|
3
|
+
import { LoadingStatus } from "@gradio/statustracker";
|
|
4
|
+
import type { ToastMessage } from "@gradio/statustracker";
|
|
5
|
+
import type { StatusMessage } from "@gradio/client";
|
|
6
|
+
/**
|
|
7
|
+
* A dependency as used by the frontend
|
|
8
|
+
* This class represents a discrete dependency that can be triggered by an event
|
|
9
|
+
* It is responsible calling the appropriate functions and reporting back results
|
|
10
|
+
*/
|
|
11
|
+
export declare class Dependency {
|
|
12
|
+
id: number;
|
|
13
|
+
inputs: number[];
|
|
14
|
+
outputs: number[];
|
|
15
|
+
cancels: number[];
|
|
16
|
+
pending: boolean;
|
|
17
|
+
trigger_modes: "once" | "multiple" | "always_last";
|
|
18
|
+
event_args: Record<string, unknown>;
|
|
19
|
+
targets: [number, string][];
|
|
20
|
+
connection_type: "stream" | "sse";
|
|
21
|
+
triggers: [number, "success" | "failure" | "all"][];
|
|
22
|
+
original_trigger_id: number | null;
|
|
23
|
+
show_progress_on: number[] | null;
|
|
24
|
+
functions: {
|
|
25
|
+
frontend?: (...args: unknown[]) => Promise<unknown[]>;
|
|
26
|
+
backend: boolean;
|
|
27
|
+
backend_js?: (...args: unknown[]) => Promise<unknown[]>;
|
|
28
|
+
};
|
|
29
|
+
constructor(dep_config: IDependency);
|
|
30
|
+
run(client: client_return, data_payload: unknown[], event_data: unknown, target_id: number | null | undefined): Promise<{
|
|
31
|
+
type: "data";
|
|
32
|
+
data: unknown[];
|
|
33
|
+
} | {
|
|
34
|
+
type: "void";
|
|
35
|
+
data: null;
|
|
36
|
+
} | {
|
|
37
|
+
type: "submit";
|
|
38
|
+
data: ReturnType<client_return["submit"]>;
|
|
39
|
+
}>;
|
|
40
|
+
add_trigger(dep_id: number, condition: "success" | "failure" | "all"): void;
|
|
41
|
+
get_triggers(): {
|
|
42
|
+
success: number[];
|
|
43
|
+
failure: number[];
|
|
44
|
+
all: number[];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
interface DispatchFunction {
|
|
48
|
+
type: "fn";
|
|
49
|
+
event_data: unknown;
|
|
50
|
+
fn_index?: number;
|
|
51
|
+
target_id?: number;
|
|
52
|
+
}
|
|
53
|
+
interface DispatchEvent {
|
|
54
|
+
type: "event";
|
|
55
|
+
event_name?: string;
|
|
56
|
+
target_id?: number;
|
|
57
|
+
event_data: unknown;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Manages all dependencies for an app acting as a bridge between app state and Dependencies
|
|
61
|
+
* Responsible for registering dependencies and dispatching events to them
|
|
62
|
+
* It is also responsible for orchestrating dependencies based on the follwing:
|
|
63
|
+
* - Cancelling dependencies
|
|
64
|
+
* - Ensuring individual dependencies respect `trigger_mode`
|
|
65
|
+
* - Managing then, success and failure events
|
|
66
|
+
* - Ensuring that dependencies bound to the same id are treated a single unit
|
|
67
|
+
* - updating loading states
|
|
68
|
+
* - updating component states
|
|
69
|
+
*/
|
|
70
|
+
export declare class DependencyManager {
|
|
71
|
+
dependencies_by_fn: Map<number, Dependency>;
|
|
72
|
+
dependencies_by_event: Map<string, Dependency[]>;
|
|
73
|
+
render_id_deps: Map<number, Set<number>>;
|
|
74
|
+
submissions: Map<number, ReturnType<Client["submit"]>>;
|
|
75
|
+
client: Client;
|
|
76
|
+
queue: Set<number>;
|
|
77
|
+
add_to_api_calls: (payload: Payload) => void;
|
|
78
|
+
update_state_cb: (id: number, state: Record<string, unknown>, check_visibility?: boolean) => Promise<void>;
|
|
79
|
+
get_state_cb: (id: number) => Promise<Record<string, unknown> | null>;
|
|
80
|
+
rerender_cb: (components: ComponentMeta[], layout: LayoutNode) => void;
|
|
81
|
+
log_cb: (title: string, message: string, fn_index: number, type: ToastMessage["type"], duration?: number | null, visible?: boolean) => void;
|
|
82
|
+
loading_stati: LoadingStatus;
|
|
83
|
+
constructor(dependencies: IDependency[], client: Client, update_state_cb: (id: number, state: Record<string, unknown>, check_visibility?: boolean) => Promise<void>, get_state_cb: (id: number) => Promise<Record<string, unknown> | null>, rerender_cb: (components: ComponentMeta[], layout: LayoutNode) => void, log_cb: (title: string, message: string, fn_index: number, type: ToastMessage["type"], duration?: number | null, visible?: boolean) => void, add_to_api_calls: (payload: Payload) => void);
|
|
84
|
+
reload(dependencies: IDependency[], update_state: any, get_state: any, rerender: any, client: any): void;
|
|
85
|
+
register_loading_stati(deps: Map<number, Dependency>): void;
|
|
86
|
+
clear_loading_status(component_id: number): void;
|
|
87
|
+
update_loading_stati_state(): Promise<void>;
|
|
88
|
+
dispatch_state_change_events(result: StatusMessage): void;
|
|
89
|
+
/** Dispatches an event to the appropriate dependency
|
|
90
|
+
* @param event_name the name of the event
|
|
91
|
+
* @param target_id the id of the component that triggered the event
|
|
92
|
+
* @param event_data any additional data to pass to the dependency
|
|
93
|
+
* @returns a value if there is no backend fn, a 'submission' if there is a backend fn, or null if there is no dependency
|
|
94
|
+
*/
|
|
95
|
+
dispatch(event_meta: DispatchFunction | DispatchEvent): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a map of dependencies for easy lookup
|
|
98
|
+
*
|
|
99
|
+
* @param dependencies the list of dependencies from the backend
|
|
100
|
+
* @returns a map of dependencies keyed by `${event_name}-${target_id}`
|
|
101
|
+
* */
|
|
102
|
+
create(dependencies: IDependency[]): {
|
|
103
|
+
by_id: Map<number, Dependency>;
|
|
104
|
+
by_event: Map<string, Dependency[]>;
|
|
105
|
+
};
|
|
106
|
+
handle_log(msg: LogMessage): void;
|
|
107
|
+
/**
|
|
108
|
+
* Updates the state of the outputs based on the data received from the dependency
|
|
109
|
+
*
|
|
110
|
+
* @param outputs the ids of the output components
|
|
111
|
+
* @param data the data to update the components with
|
|
112
|
+
* */
|
|
113
|
+
handle_data(outputs: number[], data: unknown[]): Promise<void>;
|
|
114
|
+
/**
|
|
115
|
+
* Gathers the current state of the inputs
|
|
116
|
+
*
|
|
117
|
+
* @param ids the ids of the components to gather state from
|
|
118
|
+
* @returns an array of the current state of the components, in the same order as the ids
|
|
119
|
+
*/
|
|
120
|
+
gather_state(ids: number[]): Promise<(unknown | null)[]>;
|
|
121
|
+
/** Sets the event arguments for a specific component
|
|
122
|
+
*
|
|
123
|
+
* @param id the id of the component to set the event arguments for
|
|
124
|
+
* @param args the event arguments to set
|
|
125
|
+
* @returns a function that can be called to reset the event arguments to their previous values
|
|
126
|
+
*/
|
|
127
|
+
set_event_args(id: number, args: Record<string, unknown>): Promise<() => void>;
|
|
128
|
+
cancel(ids: number[] | undefined): Promise<void>;
|
|
129
|
+
dispatch_load_events(): void;
|
|
130
|
+
get_fns_from_targets(target_id: number): number[];
|
|
131
|
+
close_stream(id: number): void;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Takes a string of source code and returns a function that can be called with arguments
|
|
135
|
+
* @param source the source code
|
|
136
|
+
* @param backend_fn if there is also a backend function
|
|
137
|
+
* @param input_length the number of inputs
|
|
138
|
+
* @param output_length the number of outputs
|
|
139
|
+
* @returns The function, or null if the source code is invalid or missing
|
|
140
|
+
*/
|
|
141
|
+
export declare function process_frontend_fn(source: string, backend_fn: boolean, input_length: number, output_length: number): (...args: unknown[]) => Promise<unknown[]>;
|
|
142
|
+
export {};
|