@gradio/client 0.20.1 → 1.1.1
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 +201 -0
- package/README.md +21 -36
- package/dist/client.d.ts +6 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/helpers/data.d.ts +15 -1
- package/dist/helpers/data.d.ts.map +1 -1
- package/dist/helpers/spaces.d.ts.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +490 -114
- package/dist/test/handlers.d.ts +1 -0
- package/dist/test/handlers.d.ts.map +1 -1
- package/dist/test/test_data.d.ts.map +1 -1
- package/dist/types.d.ts +94 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/handle_blob.d.ts +2 -1
- package/dist/utils/handle_blob.d.ts.map +1 -1
- package/dist/utils/predict.d.ts +2 -2
- package/dist/utils/predict.d.ts.map +1 -1
- package/dist/utils/stream.d.ts +2 -1
- package/dist/utils/stream.d.ts.map +1 -1
- package/dist/utils/submit.d.ts +2 -2
- package/dist/utils/submit.d.ts.map +1 -1
- package/index.html +39 -0
- package/package.json +5 -2
- package/src/client.ts +40 -35
- package/src/constants.ts +4 -0
- package/src/helpers/api_info.ts +1 -1
- package/src/helpers/data.ts +124 -10
- package/src/helpers/spaces.ts +2 -1
- package/src/index.ts +6 -1
- package/src/test/api_info.test.ts +0 -1
- package/src/test/data.test.ts +201 -26
- package/src/test/handlers.ts +9 -1
- package/src/test/stream.test.ts +12 -10
- package/src/test/test_data.ts +8 -5
- package/src/test/upload_files.test.ts +1 -1
- package/src/types.ts +111 -26
- package/src/utils/handle_blob.ts +91 -1
- package/src/utils/predict.ts +15 -16
- package/src/utils/stream.ts +66 -13
- package/src/utils/submit.ts +156 -63
- package/src/utils/upload_files.ts +1 -1
- package/vite.config.js +37 -24
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,206 @@
|
|
1
1
|
# @gradio/client
|
2
2
|
|
3
|
+
## 1.1.1
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- [#8499](https://github.com/gradio-app/gradio/pull/8499) [`c5f6e77`](https://github.com/gradio-app/gradio/commit/c5f6e7722a197d4706419ade14276ddecf3196f8) - Cache break themes on change. Thanks @aliabid94!
|
8
|
+
|
9
|
+
## 1.1.0
|
10
|
+
|
11
|
+
### Features
|
12
|
+
|
13
|
+
- [#8483](https://github.com/gradio-app/gradio/pull/8483) [`e2271e2`](https://github.com/gradio-app/gradio/commit/e2271e207d98074bf39b02ae3c5443b2f097627d) - documentation for @gradio/client. Thanks @pngwn!
|
14
|
+
- [#8485](https://github.com/gradio-app/gradio/pull/8485) [`f8ebace`](https://github.com/gradio-app/gradio/commit/f8ebaceccef60a112603d290d10072ef4e938a6a) - Ensure all status are reported internally when calling `predict`. Thanks @pngwn!
|
15
|
+
|
16
|
+
## 1.0.0
|
17
|
+
|
18
|
+
### Highlights
|
19
|
+
|
20
|
+
#### Clients 1.0 Launch! ([#8468](https://github.com/gradio-app/gradio/pull/8468) [`7cc0a0c`](https://github.com/gradio-app/gradio/commit/7cc0a0c1abea585c3f50ffb1ff78d2b08ddbdd92))
|
21
|
+
|
22
|
+
We're excited to unveil the first major release of the Gradio clients.
|
23
|
+
We've made it even easier to turn any Gradio application into a production endpoint thanks to the clients' **ergonomic**, **transparent**, and **portable** design.
|
24
|
+
|
25
|
+
#### Ergonomic API 💆
|
26
|
+
|
27
|
+
**Stream From a Gradio app in 5 lines**
|
28
|
+
|
29
|
+
Use the `submit` method to get a job you can iterate over:
|
30
|
+
|
31
|
+
```python
|
32
|
+
from gradio_client import Client
|
33
|
+
|
34
|
+
client = Client("gradio/llm_stream")
|
35
|
+
|
36
|
+
for result in client.submit("What's the best UI framework in Python?"):
|
37
|
+
print(result)
|
38
|
+
```
|
39
|
+
|
40
|
+
```ts
|
41
|
+
import { Client } from "@gradio/client";
|
42
|
+
|
43
|
+
const client = await Client.connect("gradio/llm_stream")
|
44
|
+
const job = client.submit("/predict", {"text": "What's the best UI framework in Python?"})
|
45
|
+
|
46
|
+
for await (const msg of job) console.log(msg.data)
|
47
|
+
```
|
48
|
+
|
49
|
+
**Use the same keyword arguments as the app**
|
50
|
+
|
51
|
+
|
52
|
+
```python
|
53
|
+
from gradio_client import Client
|
54
|
+
|
55
|
+
client = Client("http://127.0.0.1:7860/")
|
56
|
+
result = client.predict(
|
57
|
+
message="Hello!!",
|
58
|
+
system_prompt="You are helpful AI.",
|
59
|
+
tokens=10,
|
60
|
+
api_name="/chat"
|
61
|
+
)
|
62
|
+
print(result)
|
63
|
+
```
|
64
|
+
|
65
|
+
```ts
|
66
|
+
import { Client } from "@gradio/client";
|
67
|
+
|
68
|
+
const client = await Client.connect("http://127.0.0.1:7860/");
|
69
|
+
const result = await client.predict("/chat", {
|
70
|
+
message: "Hello!!",
|
71
|
+
system_prompt: "Hello!!",
|
72
|
+
tokens: 10,
|
73
|
+
});
|
74
|
+
|
75
|
+
console.log(result.data);
|
76
|
+
```
|
77
|
+
|
78
|
+
**Better Error Messages**
|
79
|
+
|
80
|
+
If something goes wrong in the upstream app, the client will raise the same exception as the app provided that `show_error=True` in the original app's `launch()` function, or it's a `gr.Error` exception.
|
81
|
+
|
82
|
+
#### Transparent Design 🪟
|
83
|
+
|
84
|
+
Anything you can do in the UI, you can do with the client:
|
85
|
+
* 🔒 Authentication
|
86
|
+
* 🛑 Job Cancelling
|
87
|
+
* ℹ️ Access Queue Position and API
|
88
|
+
* 📕 View the API information
|
89
|
+
|
90
|
+
Here's an example showing how to display the queue position of a pending job:
|
91
|
+
|
92
|
+
```python
|
93
|
+
from gradio_client import Client
|
94
|
+
|
95
|
+
client = Client("gradio/diffusion_model")
|
96
|
+
|
97
|
+
job = client.submit("A cute cat")
|
98
|
+
while not job.done():
|
99
|
+
status = job.status()
|
100
|
+
print(f"Current in position {status.rank} out of {status.queue_size}")
|
101
|
+
```
|
102
|
+
|
103
|
+
#### Portable Design ⛺️
|
104
|
+
|
105
|
+
The client can run from pretty much any python and javascript environment (node, deno, the browser, Service Workers).
|
106
|
+
|
107
|
+
Here's an example using the client from a Flask server using gevent:
|
108
|
+
|
109
|
+
```python
|
110
|
+
from gevent import monkey
|
111
|
+
monkey.patch_all()
|
112
|
+
|
113
|
+
from gradio_client import Client
|
114
|
+
from flask import Flask, send_file
|
115
|
+
import time
|
116
|
+
|
117
|
+
app = Flask(__name__)
|
118
|
+
|
119
|
+
imageclient = Client("gradio/diffusion_model")
|
120
|
+
|
121
|
+
@app.route("/gen")
|
122
|
+
def gen():
|
123
|
+
result = imageclient.predict(
|
124
|
+
"A cute cat",
|
125
|
+
api_name="/predict"
|
126
|
+
)
|
127
|
+
return send_file(result)
|
128
|
+
|
129
|
+
if __name__ == "__main__":
|
130
|
+
app.run(host="0.0.0.0", port=5000)
|
131
|
+
```
|
132
|
+
|
133
|
+
#### 1.0 Migration Guide and Breaking Changes
|
134
|
+
|
135
|
+
**Python**
|
136
|
+
- The `serialize` argument of the `Client` class was removed. Has no effect.
|
137
|
+
- The `upload_files` argument of the `Client` was removed.
|
138
|
+
- All filepaths must be wrapped in the `handle_file` method. Example:
|
139
|
+
```python
|
140
|
+
from gradio_client import Client, handle_file
|
141
|
+
|
142
|
+
client = Client("gradio/image_captioner")
|
143
|
+
client.predict(handle_file("cute_cat.jpg"))
|
144
|
+
```
|
145
|
+
- The `output_dir` argument was removed. It is not specified in the `download_files` argument.
|
146
|
+
|
147
|
+
|
148
|
+
**Javascript**
|
149
|
+
The client has been redesigned entirely. It was refactored from a function into a class. An instance can now be constructed by awaiting the `connect` method.
|
150
|
+
|
151
|
+
```js
|
152
|
+
const app = await Client.connect("gradio/whisper")
|
153
|
+
```
|
154
|
+
The app variable has the same methods as the python class (`submit`, `predict`, `view_api`, `duplicate`).
|
155
|
+
|
156
|
+
|
157
|
+
|
158
|
+
#### Additional Changes
|
159
|
+
|
160
|
+
- [#8243](https://github.com/gradio-app/gradio/pull/8243) - Set orig_name in python client file uploads.
|
161
|
+
- [#8264](https://github.com/gradio-app/gradio/pull/8264) - Make exceptions in the Client more specific.
|
162
|
+
- [#8247](https://github.com/gradio-app/gradio/pull/8247) - Fix api recorder.
|
163
|
+
- [#8276](https://github.com/gradio-app/gradio/pull/8276) - Fix bug where client could not connect to apps that had self signed certificates.
|
164
|
+
- [#8245](https://github.com/gradio-app/gradio/pull/8245) - Cancel server progress from the python client.
|
165
|
+
- [#8200](https://github.com/gradio-app/gradio/pull/8200) - Support custom components in gr.load
|
166
|
+
- [#8182](https://github.com/gradio-app/gradio/pull/8182) - Convert sse calls in client from async to sync.
|
167
|
+
- [#7732](https://github.com/gradio-app/gradio/pull/7732) - Adds support for kwargs and default arguments in the python client, and improves how parameter information is displayed in the "view API" page.
|
168
|
+
- [#7888](https://github.com/gradio-app/gradio/pull/7888) - Cache view_api info in server and python client.
|
169
|
+
- [#7575](https://github.com/gradio-app/gradio/pull/7575) - Files should now be supplied as `file(...)` in the Client, and some fixes to `gr.load()` as well.
|
170
|
+
- [#8401](https://github.com/gradio-app/gradio/pull/8401) - Add CDN installation to JS docs.
|
171
|
+
- [#8299](https://github.com/gradio-app/gradio/pull/8299) - Allow JS Client to work with authenticated spaces 🍪.
|
172
|
+
- [#8408](https://github.com/gradio-app/gradio/pull/8408) - Connect heartbeat if state created in render. Also fix config cleanup bug #8407.
|
173
|
+
- [#8258](https://github.com/gradio-app/gradio/pull/8258) - Improve URL handling in JS Client.
|
174
|
+
- [#8322](https://github.com/gradio-app/gradio/pull/8322) - ensure the client correctly handles all binary data.
|
175
|
+
- [#8296](https://github.com/gradio-app/gradio/pull/8296) - always create a jwt when connecting to a space if a hf_token is present.
|
176
|
+
- [#8285](https://github.com/gradio-app/gradio/pull/8285) - use the correct query param to pass the jwt to the heartbeat event.
|
177
|
+
- [#8272](https://github.com/gradio-app/gradio/pull/8272) - ensure client works for private spaces.
|
178
|
+
- [#8197](https://github.com/gradio-app/gradio/pull/8197) - Add support for passing keyword args to `data` in JS client.
|
179
|
+
- [#8252](https://github.com/gradio-app/gradio/pull/8252) - Client node fix.
|
180
|
+
- [#8209](https://github.com/gradio-app/gradio/pull/8209) - Rename `eventSource_Factory` and `fetch_implementation`.
|
181
|
+
- [#8109](https://github.com/gradio-app/gradio/pull/8109) - Implement JS Client tests.
|
182
|
+
- [#8211](https://github.com/gradio-app/gradio/pull/8211) - remove redundant event source logic.
|
183
|
+
- [#8179](https://github.com/gradio-app/gradio/pull/8179) - rework upload to be a class method + pass client into each component.
|
184
|
+
- [#8181](https://github.com/gradio-app/gradio/pull/8181) - Ensure connectivity to private HF spaces with SSE protocol.
|
185
|
+
- [#8169](https://github.com/gradio-app/gradio/pull/8169) - Only connect to heartbeat if needed.
|
186
|
+
- [#8118](https://github.com/gradio-app/gradio/pull/8118) - Add eventsource polyfill for Node.js and browser environments.
|
187
|
+
- [#7646](https://github.com/gradio-app/gradio/pull/7646) - Refactor JS Client.
|
188
|
+
- [#7974](https://github.com/gradio-app/gradio/pull/7974) - Fix heartbeat in the js client to be Lite compatible.
|
189
|
+
- [#7926](https://github.com/gradio-app/gradio/pull/7926) - Fixes streaming event race condition.
|
190
|
+
|
191
|
+
Thanks @freddyaboulton!
|
192
|
+
|
193
|
+
### Features
|
194
|
+
|
195
|
+
- [#8370](https://github.com/gradio-app/gradio/pull/8370) [`48eeea4`](https://github.com/gradio-app/gradio/commit/48eeea4eaab7e24168688e3c3fbafb30e4e78d51) - Refactor Cancelling Logic To Use /cancel. Thanks @freddyaboulton!
|
196
|
+
|
197
|
+
### Fixes
|
198
|
+
|
199
|
+
- [#8477](https://github.com/gradio-app/gradio/pull/8477) [`d5a9604`](https://github.com/gradio-app/gradio/commit/d5a960493017a4890685af61d78ce7d3b3b12e6b) - Fix js client bundle. Thanks @pngwn!
|
200
|
+
- [#8451](https://github.com/gradio-app/gradio/pull/8451) [`9d2d605`](https://github.com/gradio-app/gradio/commit/9d2d6051caed5c8749a26a6fa7480a5ae6e6c4f3) - Change client submit API to be an AsyncIterable and support more platforms. Thanks @pngwn!
|
201
|
+
- [#8462](https://github.com/gradio-app/gradio/pull/8462) [`6447dfa`](https://github.com/gradio-app/gradio/commit/6447dface4d46db1c69460e8325a1928d0476a46) - Improve file handling in JS Client. Thanks @hannahblair!
|
202
|
+
- [#8439](https://github.com/gradio-app/gradio/pull/8439) [`63d36fb`](https://github.com/gradio-app/gradio/commit/63d36fbbf4bf6dc909be9a0ffc7b6bf6621d83e8) - Handle gradio apps using `state` in the JS Client. Thanks @hannahblair!
|
203
|
+
|
3
204
|
## 0.20.1
|
4
205
|
|
5
206
|
### Features
|
package/README.md
CHANGED
@@ -154,11 +154,19 @@ const submission = app.submit("/predict", { name: "Chewbacca" });
|
|
154
154
|
|
155
155
|
The `submit` method accepts the same [`endpoint`](#endpoint) and [`payload`](#payload) arguments as `predict`.
|
156
156
|
|
157
|
-
The `submit` method does not return a promise and should not be awaited, instead it returns an
|
157
|
+
The `submit` method does not return a promise and should not be awaited, instead it returns an async iterator with a `cancel` method.
|
158
158
|
|
159
|
-
#####
|
159
|
+
##### Accessing values
|
160
160
|
|
161
|
-
|
161
|
+
Iterating the submission allows you to access the events related to the submitted API request. There are two types of events that can be listened for: `"data"` updates and `"status"` updates. By default only the `"data"` event is reported, but you can listen for the `"status"` event by manually passing the events you care about when instantiating the client:
|
162
|
+
|
163
|
+
```ts
|
164
|
+
import { Client } from "@gradio/client";
|
165
|
+
|
166
|
+
const app = await Client.connect("user/space-name", {
|
167
|
+
events: ["data", "status"]
|
168
|
+
});
|
169
|
+
```
|
162
170
|
|
163
171
|
`"data"` updates are issued when the API computes a value, the callback provided as the second argument will be called when such a value is sent to the client. The shape of the data depends on the way the API itself is constructed. This event may fire more than once if that endpoint supports emmitting new values over time.
|
164
172
|
|
@@ -187,7 +195,7 @@ interface Status {
|
|
187
195
|
}
|
188
196
|
```
|
189
197
|
|
190
|
-
Usage
|
198
|
+
Usage looks like this:
|
191
199
|
|
192
200
|
```ts
|
193
201
|
import { Client } from "@gradio/client";
|
@@ -195,41 +203,18 @@ import { Client } from "@gradio/client";
|
|
195
203
|
const app = await Client.connect("user/space-name");
|
196
204
|
const submission = app
|
197
205
|
.submit("/predict", { name: "Chewbacca" })
|
198
|
-
.on("data", (data) => console.log(data))
|
199
|
-
.on("status", (status: Status) => console.log(status));
|
200
|
-
```
|
201
|
-
|
202
|
-
##### `off`
|
203
|
-
|
204
|
-
The `off` method unsubscribes from a specific event of the submitted job and works similarly to `document.removeEventListener`; both the event name and the original callback must be passed in to successfully unsubscribe:
|
205
|
-
|
206
|
-
```ts
|
207
|
-
import { Client } from "@gradio/client";
|
208
206
|
|
209
|
-
const
|
210
|
-
|
211
|
-
|
212
|
-
|
207
|
+
for await (const msg of submission) {
|
208
|
+
if (msg.type === "data") {
|
209
|
+
console.log(msg.data);
|
210
|
+
}
|
213
211
|
|
214
|
-
|
215
|
-
|
212
|
+
if (msg.type === "status") {
|
213
|
+
console.log(msg);
|
214
|
+
}
|
215
|
+
}
|
216
216
|
```
|
217
217
|
|
218
|
-
##### `destroy`
|
219
|
-
|
220
|
-
The `destroy` method will remove all subscriptions to a job, regardless of whether or not they are `"data"` or `"status"` events. This is a convenience method for when you do not want to unsubscribe use the `off` method.
|
221
|
-
|
222
|
-
```js
|
223
|
-
import { Client } from "@gradio/client";
|
224
|
-
|
225
|
-
const app = await Client.connect("user/space-name");
|
226
|
-
const handle_data = (data) => console.log(data);
|
227
|
-
|
228
|
-
const submission = app.submit("/predict", { name: "Chewbacca" }).on("data", handle_data);
|
229
|
-
|
230
|
-
// later
|
231
|
-
submission.destroy();
|
232
|
-
```
|
233
218
|
|
234
219
|
##### `cancel`
|
235
220
|
|
@@ -241,7 +226,7 @@ import { Client } from "@gradio/client";
|
|
241
226
|
const app = await Client.connect("user/space-name");
|
242
227
|
const submission = app
|
243
228
|
.submit("/predict", { name: "Chewbacca" })
|
244
|
-
|
229
|
+
|
245
230
|
|
246
231
|
// later
|
247
232
|
|
package/dist/client.d.ts
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
import type { ApiData, ApiInfo, ClientOptions, Config, DuplicateOptions, EndpointInfo, JsApiData, SpaceStatus, Status,
|
1
|
+
import type { ApiData, ApiInfo, ClientOptions, Config, DuplicateOptions, EndpointInfo, JsApiData, PredictReturn, SpaceStatus, Status, UploadResponse, SubmitIterable, GradioEvent } from "./types";
|
2
2
|
import { FileData } from "./upload";
|
3
|
-
export declare class NodeBlob extends Blob {
|
4
|
-
constructor(blobParts?: BlobPart[], options?: BlobPropertyBag);
|
5
|
-
}
|
6
3
|
export declare class Client {
|
7
4
|
app_reference: string;
|
8
5
|
options: ClientOptions;
|
@@ -21,15 +18,17 @@ export declare class Client {
|
|
21
18
|
event_callbacks: Record<string, (data?: unknown) => Promise<void>>;
|
22
19
|
unclosed_events: Set<string>;
|
23
20
|
heartbeat_event: EventSource | null;
|
21
|
+
abort_controller: AbortController | null;
|
22
|
+
stream_instance: EventSource | null;
|
24
23
|
fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response>;
|
25
|
-
stream(url: URL):
|
24
|
+
stream(url: URL): EventSource;
|
26
25
|
view_api: () => Promise<ApiInfo<JsApiData>>;
|
27
26
|
upload_files: (root_url: string, files: (Blob | File)[], upload_id?: string) => Promise<UploadResponse>;
|
28
27
|
upload: (file_data: FileData[], root_url: string, upload_id?: string, max_file_size?: number) => Promise<(FileData | null)[] | null>;
|
29
28
|
handle_blob: (endpoint: string, data: unknown[], endpoint_info: EndpointInfo<ApiData | JsApiData>) => Promise<unknown[]>;
|
30
29
|
post_data: (url: string, body: unknown, additional_headers?: any) => Promise<unknown[]>;
|
31
|
-
submit: (endpoint: string | number, data: unknown[] | Record<string, unknown>, event_data?: unknown, trigger_id?: number | null) =>
|
32
|
-
predict: (endpoint: string | number, data: unknown[] | Record<string, unknown>, event_data?: unknown) => Promise<
|
30
|
+
submit: (endpoint: string | number, data: unknown[] | Record<string, unknown>, event_data?: unknown, trigger_id?: number | null, all_events?: boolean) => SubmitIterable<GradioEvent>;
|
31
|
+
predict: (endpoint: string | number, data: unknown[] | Record<string, unknown>, event_data?: unknown) => Promise<PredictReturn>;
|
33
32
|
open_stream: () => Promise<void>;
|
34
33
|
private resolve_config;
|
35
34
|
private resolve_cookies;
|
package/dist/client.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,WAAW,EACX,MAAM,EACN,
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,OAAO,EACP,OAAO,EACP,aAAa,EACb,MAAM,EACN,gBAAgB,EAChB,YAAY,EACZ,SAAS,EACT,aAAa,EACb,WAAW,EACX,MAAM,EACN,cAAc,EAEd,cAAc,EACd,WAAW,EACX,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAU,QAAQ,EAAE,MAAM,UAAU,CAAC;AAkB5C,qBAAa,MAAM;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,aAAa,CAAC;IAEvB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,SAAS,CAAC;IACzC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IACrC,YAAY,EAAE,MAAM,CAA2C;IAC/D,GAAG,EAAE,MAAM,GAAG,KAAK,CAAS;IAC5B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC,CAAM;IAElD,OAAO,CAAC,OAAO,CAAuB;IAGtC,aAAa;;MAAmB;IAChC,uBAAuB,EAAE,MAAM,CAAC,M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MAAM,EAAE,OAAO,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAC9D,OAAO,CAAC,OAAO,CAAC;IA0EZ,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAI7C,OAAO,CAAC,kBAAkB;CAS1B;AAED;;;;;;;GAOG;AACH,wBAAsB,MAAM,CAC3B,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE,aAER,GACC,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED;;;;;;;GAOG;AACH,wBAAsB,eAAe,CACpC,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,gBAAgB,GACvB,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC"}
|
package/dist/constants.d.ts
CHANGED
@@ -24,4 +24,7 @@ export declare const INVALID_URL_MSG = "Invalid URL. A full URL path is required
|
|
24
24
|
export declare const UNAUTHORIZED_MSG = "Not authorized to access this space. ";
|
25
25
|
export declare const INVALID_CREDENTIALS_MSG = "Invalid credentials. Could not login. ";
|
26
26
|
export declare const MISSING_CREDENTIALS_MSG = "Login credentials are required to access this space.";
|
27
|
+
export declare const NODEJS_FS_ERROR_MSG = "File system access is only available in Node.js environments";
|
28
|
+
export declare const ROOT_URL_ERROR_MSG = "Root URL not found in client config";
|
29
|
+
export declare const FILE_PROCESSING_ERROR_MSG = "Error uploading file";
|
27
30
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,OAAO,iBAAiB,CAAC;AACtC,eAAO,MAAM,UAAU,eAAe,CAAC;AACvC,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,OAAO,eAAe,CAAC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O,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,aAAa,cAAc,CAAC;AACzC,eAAO,MAAM,gBAAgB,yBAAyB,CAAC;AACvD,eAAO,MAAM,iBAAiB,qDACqB,CAAC;AACpD,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,SAAS,wBAAwB,CAAC;AAG/C,eAAO,MAAM,cAAc,2DAC8B,CAAC;AAC1D,eAAO,MAAM,qBAAqB,6BAA6B,CAAC;AAChE,eAAO,MAAM,gBAAgB,mCAAmC,CAAC;AACjE,eAAO,MAAM,sBAAsB,iCAAiC,CAAC;AACrE,eAAO,MAAM,kBAAkB,6BAA6B,CAAC;AAC7D,eAAO,MAAM,wBAAwB,yCAAyC,CAAC;AAC/E,eAAO,MAAM,eAAe,8CAA8C,CAAC;AAC3E,eAAO,MAAM,gBAAgB,0CAA0C,CAAC;AACxE,eAAO,MAAM,uBAAuB,2CAA2C,CAAC;AAChF,eAAO,MAAM,uBAAuB,yDACmB,CAAC;AACxD,eAAO,MAAM,mBAAmB,iEAC+B,CAAC;AAChE,eAAO,MAAM,kBAAkB,wCAAwC,CAAC;AACxE,eAAO,MAAM,yBAAyB,yBAAyB,CAAC"}
|
package/dist/helpers/data.d.ts
CHANGED
@@ -1,8 +1,22 @@
|
|
1
|
-
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { type ApiData, type BlobRef, type Config, type EndpointInfo, type JsApiData, type DataType, Command, type Dependency, type ComponentMeta } from "../types";
|
3
|
+
import { FileData } from "../upload";
|
2
4
|
export declare function update_object(object: {
|
3
5
|
[x: string]: any;
|
4
6
|
}, newValue: any, stack: (string | number)[]): void;
|
5
7
|
export declare function walk_and_store_blobs(data: DataType, type?: string | undefined, path?: string[], root?: boolean, endpoint_info?: EndpointInfo<ApiData | JsApiData> | undefined): Promise<BlobRef[]>;
|
6
8
|
export declare function skip_queue(id: number, config: Config): boolean;
|
7
9
|
export declare function post_message<Res = any>(message: any, origin: string): Promise<Res>;
|
10
|
+
export declare function handle_file(file_or_url: File | string | Blob | Buffer): FileData | Blob | Command;
|
11
|
+
/**
|
12
|
+
* Handles the payload by filtering out state inputs and returning an array of resolved payload values.
|
13
|
+
* We send null values for state inputs to the server, but we don't want to include them in the resolved payload.
|
14
|
+
*
|
15
|
+
* @param resolved_payload - The resolved payload values received from the client or the server
|
16
|
+
* @param dependency - The dependency object.
|
17
|
+
* @param components - The array of component metadata.
|
18
|
+
* @param with_null_state - Optional. Specifies whether to include null values for state inputs. Default is false.
|
19
|
+
* @returns An array of resolved payload values, filtered based on the dependency and component metadata.
|
20
|
+
*/
|
21
|
+
export declare function handle_payload(resolved_payload: unknown[], dependency: Dependency, components: ComponentMeta[], type: "input" | "output", with_null_state?: boolean): unknown[];
|
8
22
|
//# sourceMappingURL=data.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/helpers/data.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../../src/helpers/data.ts"],"names":[],"mappings":";AAAA,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,QAAQ,EACb,OAAO,EACP,KAAK,UAAU,EACf,KAAK,aAAa,EAClB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAKrC,wBAAgB,aAAa,CAC5B,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,EAC5B,QAAQ,EAAE,GAAG,EACb,KAAK,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,GACxB,IAAI,CAgBN;AAED,wBAAsB,oBAAoB,CACzC,IAAI,EAAE,QAAQ,EACd,IAAI,GAAE,MAAM,GAAG,SAAqB,EACpC,IAAI,GAAE,MAAM,EAAO,EACnB,IAAI,UAAQ,EACZ,aAAa,GAAE,YAAY,CAAC,OAAO,GAAG,SAAS,CAAC,GAAG,SAAqB,GACtE,OAAO,CAAC,OAAO,EAAE,CAAC,CAwDpB;AAED,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAM9D;AAID,wBAAgB,YAAY,CAAC,GAAG,GAAG,GAAG,EACrC,OAAO,EAAE,GAAG,EACZ,MAAM,EAAE,MAAM,GACZ,OAAO,CAAC,GAAG,CAAC,CASd;AAED,wBAAgB,WAAW,CAC1B,WAAW,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI,GAAG,MAAM,GACxC,QAAQ,GAAG,IAAI,GAAG,OAAO,CA8C3B;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC7B,gBAAgB,EAAE,OAAO,EAAE,EAC3B,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,aAAa,EAAE,EAC3B,IAAI,EAAE,OAAO,GAAG,QAAQ,EACxB,eAAe,UAAQ,GACrB,OAAO,EAAE,CAyCX"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"spaces.d.ts","sourceRoot":"","sources":["../../src/helpers/spaces.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAsB,kBAAkB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,WAAW,GAAG,YAAY,EAChC,eAAe,EAAE,mBAAmB,GAClC,OAAO,CAAC,IAAI,CAAC,CAqFf;AAID,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,
|
1
|
+
{"version":3,"file":"spaces.d.ts","sourceRoot":"","sources":["../../src/helpers/spaces.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAEpD,wBAAsB,kBAAkB,CACvC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,WAAW,GAAG,YAAY,EAChC,eAAe,EAAE,mBAAmB,GAClC,OAAO,CAAC,IAAI,CAAC,CAqFf;AAID,wBAAsB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAgB5E;AAED,wBAAsB,kBAAkB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,CAAC,EAAE,MAAM,MAAM,EAAE,GAAG,SAAS,GACnC,OAAO,CAAC,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,CAqB1C;AAED,wBAAsB,iBAAiB,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,QAAQ,CAAC,EAAE,MAAM,MAAM,EAAE,GACvB,OAAO,CAAC,GAAG,CAAC,CAiCd;AAED,eAAO,MAAM,cAAc,mLAcjB,CAAC"}
|
package/dist/index.d.ts
CHANGED
@@ -3,7 +3,8 @@ export { predict } from "./utils/predict";
|
|
3
3
|
export { submit } from "./utils/submit";
|
4
4
|
export { upload_files } from "./utils/upload_files";
|
5
5
|
export { FileData, upload, prepare_files } from "./upload";
|
6
|
-
export
|
6
|
+
export { handle_file } from "./helpers/data";
|
7
|
+
export type { SpaceStatus, StatusMessage, Status, client_return, UploadResponse, RenderMessage, LogMessage, Payload } from "./types";
|
7
8
|
export { client } from "./client";
|
8
9
|
export { duplicate_space as duplicate } from "./client";
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,YAAY,EACX,WAAW,EACX,aAAa,EACb,MAAM,EACN,aAAa,EACb,cAAc,EACd,aAAa,EACb,UAAU,EACV,OAAO,EACP,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,eAAe,IAAI,SAAS,EAAE,MAAM,UAAU,CAAC"}
|