@tokshare/pick 0.0.0-stage → 0.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/LICENSE +21 -0
- package/README.md +177 -2
- package/dist/index.cjs +2449 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +231 -0
- package/dist/index.d.ts +231 -0
- package/dist/index.js +2415 -0
- package/dist/index.js.map +1 -0
- package/dist/picker.global.js +250 -0
- package/dist/react.cjs +157 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +65 -0
- package/dist/react.d.ts +65 -0
- package/dist/react.js +140 -0
- package/dist/react.js.map +1 -0
- package/package.json +80 -4
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
type ErrorCode = "bad_request" | "key_invalid" | "origin_not_allowed" | "rate_limited" | "quota_exceeded" | "not_found" | "unauthorized" | "already_claimed" | "expired" | "closed" | "limit_reached" | "file_too_large" | "session_too_large" | "type_rejected" | "size_mismatch" | "upload_incomplete" | "download_limit" | "network" | "internal";
|
|
2
|
+
declare class PickError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
constructor(code: ErrorCode, message?: string, status?: number);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type CloseReason = "desktop_closed" | "expired" | "limit_reached" | "phone_rejected" | "completed" | "error";
|
|
9
|
+
type Locale = "en" | "ar";
|
|
10
|
+
/** What a website may ask for. The relay clamps every number to the plan's limits. */
|
|
11
|
+
interface SessionOptions {
|
|
12
|
+
/** Like <input accept>: "image/*,.pdf,application/zip". Empty means any file. */
|
|
13
|
+
accept?: string;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
maxFiles?: number;
|
|
16
|
+
maxFileBytes?: number;
|
|
17
|
+
/** Phone shrinks photos before sending: longest side in pixels, JPEG quality 0–1. */
|
|
18
|
+
resizeImages?: {
|
|
19
|
+
maxDimension: number;
|
|
20
|
+
quality?: number;
|
|
21
|
+
} | false;
|
|
22
|
+
/** The phone waits until someone at the computer approves it. */
|
|
23
|
+
confirmPhone?: boolean;
|
|
24
|
+
locale?: Locale;
|
|
25
|
+
/** Shown on the phone: "<siteName> is asking for files". Defaults to the website's host. */
|
|
26
|
+
siteName?: string;
|
|
27
|
+
/** Send files straight from the phone to this page over the local network (WebRTC) when both are
|
|
28
|
+
* on the same Wi-Fi, falling back to the cloud otherwise. Default true. */
|
|
29
|
+
direct?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface PhoneInfo {
|
|
32
|
+
/** Coarse: "iPhone · Safari", "Android · Chrome". */
|
|
33
|
+
label: string;
|
|
34
|
+
}
|
|
35
|
+
interface FileMeta {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
size: number;
|
|
39
|
+
type: string;
|
|
40
|
+
lastModified: number;
|
|
41
|
+
/** The type found in the file's first bytes, when it could be recognized. */
|
|
42
|
+
sniffed?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const en: {
|
|
46
|
+
title: string;
|
|
47
|
+
titleOne: string;
|
|
48
|
+
scan: string;
|
|
49
|
+
orType: string;
|
|
50
|
+
loading: string;
|
|
51
|
+
waiting: string;
|
|
52
|
+
connected: string;
|
|
53
|
+
connectedDirect: string;
|
|
54
|
+
disconnect: string;
|
|
55
|
+
phoneLeft: string;
|
|
56
|
+
approveTitle: string;
|
|
57
|
+
approveMatch: string;
|
|
58
|
+
approve: string;
|
|
59
|
+
reject: string;
|
|
60
|
+
sending: string;
|
|
61
|
+
receiving: string;
|
|
62
|
+
received: string;
|
|
63
|
+
failed: string;
|
|
64
|
+
cancel: string;
|
|
65
|
+
done: string;
|
|
66
|
+
useFiles: string;
|
|
67
|
+
useFile: string;
|
|
68
|
+
expired: string;
|
|
69
|
+
newCode: string;
|
|
70
|
+
error: string;
|
|
71
|
+
tryAgain: string;
|
|
72
|
+
close: string;
|
|
73
|
+
privacy: string;
|
|
74
|
+
dropTitle: string;
|
|
75
|
+
dropTitleOne: string;
|
|
76
|
+
dropActive: string;
|
|
77
|
+
or: string;
|
|
78
|
+
browse: string;
|
|
79
|
+
usePhone: string;
|
|
80
|
+
hintTypes: string;
|
|
81
|
+
hintAny: string;
|
|
82
|
+
hintCount: string;
|
|
83
|
+
phoneTitle: string;
|
|
84
|
+
phoneStep1: string;
|
|
85
|
+
phoneStep2: string;
|
|
86
|
+
phoneStep3: string;
|
|
87
|
+
phoneCode: string;
|
|
88
|
+
back: string;
|
|
89
|
+
doneWithPhone: string;
|
|
90
|
+
sourcePhone: string;
|
|
91
|
+
sourceDevice: string;
|
|
92
|
+
remove: string;
|
|
93
|
+
tooLarge: string;
|
|
94
|
+
wrongType: string;
|
|
95
|
+
tooMany: string;
|
|
96
|
+
fileCount: string;
|
|
97
|
+
clearAll: string;
|
|
98
|
+
announceText: string;
|
|
99
|
+
announceLink: string;
|
|
100
|
+
announceHide: string;
|
|
101
|
+
};
|
|
102
|
+
type Strings = typeof en;
|
|
103
|
+
type StringKey = keyof Strings;
|
|
104
|
+
|
|
105
|
+
interface PickOptions extends Omit<SessionOptions, "locale"> {
|
|
106
|
+
/** Your publishable key (pk_live_… or pk_test_…). */
|
|
107
|
+
key: string;
|
|
108
|
+
/** Relay URL. Defaults to the hosted relay. */
|
|
109
|
+
relay?: string;
|
|
110
|
+
/** "auto" follows the page's lang attribute, then the browser. */
|
|
111
|
+
locale?: Locale | "auto";
|
|
112
|
+
/** false: no modal; use the controller's events, claimUrl and code to build your own UI. */
|
|
113
|
+
ui?: boolean;
|
|
114
|
+
theme?: "light" | "dark" | "auto";
|
|
115
|
+
/** Replace any of the modal's strings. */
|
|
116
|
+
strings?: Partial<Record<StringKey, string>>;
|
|
117
|
+
/** A small, dismissible line about TokShare for desktop in the modal and the field. Default true. */
|
|
118
|
+
announce?: boolean;
|
|
119
|
+
signal?: AbortSignal;
|
|
120
|
+
}
|
|
121
|
+
interface ProgressInfo {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
sent: number;
|
|
125
|
+
total: number;
|
|
126
|
+
/** "upload": phone → relay (or straight to this page over Wi-Fi). "download": relay → this page. */
|
|
127
|
+
phase: "upload" | "download";
|
|
128
|
+
}
|
|
129
|
+
interface PickEvents {
|
|
130
|
+
ready: {
|
|
131
|
+
claimUrl: string;
|
|
132
|
+
code: string;
|
|
133
|
+
};
|
|
134
|
+
phone: {
|
|
135
|
+
phone: PhoneInfo;
|
|
136
|
+
needsApproval: boolean;
|
|
137
|
+
match?: string;
|
|
138
|
+
};
|
|
139
|
+
phone_left: undefined;
|
|
140
|
+
/** The phone is on the same network and files come straight to this page (true), or not any more. */
|
|
141
|
+
direct: {
|
|
142
|
+
connected: boolean;
|
|
143
|
+
};
|
|
144
|
+
file_started: FileMeta;
|
|
145
|
+
progress: ProgressInfo;
|
|
146
|
+
file: File;
|
|
147
|
+
/** The same file, with the relay id its progress events used. */
|
|
148
|
+
received: {
|
|
149
|
+
id: string;
|
|
150
|
+
file: File;
|
|
151
|
+
};
|
|
152
|
+
file_failed: {
|
|
153
|
+
id: string;
|
|
154
|
+
code: string;
|
|
155
|
+
};
|
|
156
|
+
error: PickError;
|
|
157
|
+
close: CloseReason | "canceled" | "finished";
|
|
158
|
+
}
|
|
159
|
+
interface PickController {
|
|
160
|
+
/** Resolves with the received files when the person finishes; [] if canceled before any arrived. */
|
|
161
|
+
readonly done: Promise<File[]>;
|
|
162
|
+
/** Files received so far. */
|
|
163
|
+
readonly files: readonly File[];
|
|
164
|
+
readonly claimUrl: string | null;
|
|
165
|
+
readonly code: string | null;
|
|
166
|
+
on<E extends keyof PickEvents>(event: E, handler: (detail: PickEvents[E]) => void): () => void;
|
|
167
|
+
/** Use the files received so far. */
|
|
168
|
+
finish(): void;
|
|
169
|
+
/** Close without files. */
|
|
170
|
+
cancel(): void;
|
|
171
|
+
approve(): void;
|
|
172
|
+
reject(): void;
|
|
173
|
+
/** Forget the connected phone and show a new code. */
|
|
174
|
+
disconnect(): Promise<void>;
|
|
175
|
+
/** Start over with a new session (after an expiry or error). */
|
|
176
|
+
restart(): void;
|
|
177
|
+
}
|
|
178
|
+
declare function open(options: PickOptions): PickController;
|
|
179
|
+
/** Opens the picker and resolves with the files the person sent ([] if they canceled). */
|
|
180
|
+
declare function pick(options: PickOptions): Promise<File[]>;
|
|
181
|
+
interface AttachOptions extends Omit<PickOptions, "accept" | "multiple"> {
|
|
182
|
+
/** "replace" (default) sets the input's files; "append" adds to what it already has. */
|
|
183
|
+
mode?: "replace" | "append";
|
|
184
|
+
}
|
|
185
|
+
/** Fills an existing <input type="file"> with files from the phone, firing input and change events,
|
|
186
|
+
* so forms and frameworks that listen to the input keep working. Returns a function that does it. */
|
|
187
|
+
declare function attach(input: HTMLInputElement, options: AttachOptions): () => Promise<File[]>;
|
|
188
|
+
|
|
189
|
+
interface FieldOptions extends Omit<PickOptions, "ui"> {
|
|
190
|
+
/** Form field name: the files go into a hidden <input type="file" name> inside the target. */
|
|
191
|
+
name?: string;
|
|
192
|
+
/** "inline" (default): the phone flow opens inside the field. "modal": in a window. false: no phone. */
|
|
193
|
+
phone?: "inline" | "modal" | false;
|
|
194
|
+
/** Show "Use your phone" even when this page itself is open on a phone. */
|
|
195
|
+
phoneOnMobile?: boolean;
|
|
196
|
+
/** Replaces the drop zone's title. */
|
|
197
|
+
label?: string;
|
|
198
|
+
}
|
|
199
|
+
interface FieldController {
|
|
200
|
+
readonly files: readonly File[];
|
|
201
|
+
/** The hidden input the files are kept in (for forms and frameworks). */
|
|
202
|
+
readonly input: HTMLInputElement;
|
|
203
|
+
on(event: "change", handler: (files: File[]) => void): () => void;
|
|
204
|
+
remove(file: File): void;
|
|
205
|
+
clear(): void;
|
|
206
|
+
destroy(): void;
|
|
207
|
+
}
|
|
208
|
+
/** "5MB", "500 KB", "2e6" → bytes. */
|
|
209
|
+
declare function parseSize(value: string | number | null | undefined): number | undefined;
|
|
210
|
+
declare function mountField(target: HTMLElement | string, options: FieldOptions): FieldController;
|
|
211
|
+
/** <tokshare-pick-field key name accept multiple max-files max-size phone locale theme relay label direct announce>.
|
|
212
|
+
* direct="off" sends everything through the cloud; announce="off" hides the TokShare for desktop line. */
|
|
213
|
+
declare function defineFieldElement(defaults?: Partial<FieldOptions>, tag?: string): void;
|
|
214
|
+
|
|
215
|
+
/** The hosted relay. Override with the `relay` option or a script tag's data-relay attribute
|
|
216
|
+
* (local development: "http://localhost:8788").
|
|
217
|
+
* 0.1.x uses the relay's workers.dev address; a later version moves to the TokShare domain. That
|
|
218
|
+
* address must stay up for sites still on 0.1.x (wrangler.jsonc keeps workers_dev on). */
|
|
219
|
+
declare const DEFAULT_RELAY = "https://tokshare-pick.pjturki.workers.dev";
|
|
220
|
+
declare const SDK_VERSION = "0.1.1";
|
|
221
|
+
|
|
222
|
+
/** The same functions as one object: TokSharePick.pick({ key }). */
|
|
223
|
+
declare const TokSharePick: {
|
|
224
|
+
pick: typeof pick;
|
|
225
|
+
open: typeof open;
|
|
226
|
+
attach: typeof attach;
|
|
227
|
+
mountField: typeof mountField;
|
|
228
|
+
defineFieldElement: typeof defineFieldElement;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export { type AttachOptions, DEFAULT_RELAY, type ErrorCode, type FieldController, type FieldOptions, type FileMeta, type PhoneInfo, type PickController, PickError, type PickEvents, type PickOptions, type ProgressInfo, SDK_VERSION, TokSharePick, attach, defineFieldElement, mountField, open, parseSize, pick };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
type ErrorCode = "bad_request" | "key_invalid" | "origin_not_allowed" | "rate_limited" | "quota_exceeded" | "not_found" | "unauthorized" | "already_claimed" | "expired" | "closed" | "limit_reached" | "file_too_large" | "session_too_large" | "type_rejected" | "size_mismatch" | "upload_incomplete" | "download_limit" | "network" | "internal";
|
|
2
|
+
declare class PickError extends Error {
|
|
3
|
+
readonly code: ErrorCode;
|
|
4
|
+
readonly status: number;
|
|
5
|
+
constructor(code: ErrorCode, message?: string, status?: number);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
type CloseReason = "desktop_closed" | "expired" | "limit_reached" | "phone_rejected" | "completed" | "error";
|
|
9
|
+
type Locale = "en" | "ar";
|
|
10
|
+
/** What a website may ask for. The relay clamps every number to the plan's limits. */
|
|
11
|
+
interface SessionOptions {
|
|
12
|
+
/** Like <input accept>: "image/*,.pdf,application/zip". Empty means any file. */
|
|
13
|
+
accept?: string;
|
|
14
|
+
multiple?: boolean;
|
|
15
|
+
maxFiles?: number;
|
|
16
|
+
maxFileBytes?: number;
|
|
17
|
+
/** Phone shrinks photos before sending: longest side in pixels, JPEG quality 0–1. */
|
|
18
|
+
resizeImages?: {
|
|
19
|
+
maxDimension: number;
|
|
20
|
+
quality?: number;
|
|
21
|
+
} | false;
|
|
22
|
+
/** The phone waits until someone at the computer approves it. */
|
|
23
|
+
confirmPhone?: boolean;
|
|
24
|
+
locale?: Locale;
|
|
25
|
+
/** Shown on the phone: "<siteName> is asking for files". Defaults to the website's host. */
|
|
26
|
+
siteName?: string;
|
|
27
|
+
/** Send files straight from the phone to this page over the local network (WebRTC) when both are
|
|
28
|
+
* on the same Wi-Fi, falling back to the cloud otherwise. Default true. */
|
|
29
|
+
direct?: boolean;
|
|
30
|
+
}
|
|
31
|
+
interface PhoneInfo {
|
|
32
|
+
/** Coarse: "iPhone · Safari", "Android · Chrome". */
|
|
33
|
+
label: string;
|
|
34
|
+
}
|
|
35
|
+
interface FileMeta {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
size: number;
|
|
39
|
+
type: string;
|
|
40
|
+
lastModified: number;
|
|
41
|
+
/** The type found in the file's first bytes, when it could be recognized. */
|
|
42
|
+
sniffed?: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
declare const en: {
|
|
46
|
+
title: string;
|
|
47
|
+
titleOne: string;
|
|
48
|
+
scan: string;
|
|
49
|
+
orType: string;
|
|
50
|
+
loading: string;
|
|
51
|
+
waiting: string;
|
|
52
|
+
connected: string;
|
|
53
|
+
connectedDirect: string;
|
|
54
|
+
disconnect: string;
|
|
55
|
+
phoneLeft: string;
|
|
56
|
+
approveTitle: string;
|
|
57
|
+
approveMatch: string;
|
|
58
|
+
approve: string;
|
|
59
|
+
reject: string;
|
|
60
|
+
sending: string;
|
|
61
|
+
receiving: string;
|
|
62
|
+
received: string;
|
|
63
|
+
failed: string;
|
|
64
|
+
cancel: string;
|
|
65
|
+
done: string;
|
|
66
|
+
useFiles: string;
|
|
67
|
+
useFile: string;
|
|
68
|
+
expired: string;
|
|
69
|
+
newCode: string;
|
|
70
|
+
error: string;
|
|
71
|
+
tryAgain: string;
|
|
72
|
+
close: string;
|
|
73
|
+
privacy: string;
|
|
74
|
+
dropTitle: string;
|
|
75
|
+
dropTitleOne: string;
|
|
76
|
+
dropActive: string;
|
|
77
|
+
or: string;
|
|
78
|
+
browse: string;
|
|
79
|
+
usePhone: string;
|
|
80
|
+
hintTypes: string;
|
|
81
|
+
hintAny: string;
|
|
82
|
+
hintCount: string;
|
|
83
|
+
phoneTitle: string;
|
|
84
|
+
phoneStep1: string;
|
|
85
|
+
phoneStep2: string;
|
|
86
|
+
phoneStep3: string;
|
|
87
|
+
phoneCode: string;
|
|
88
|
+
back: string;
|
|
89
|
+
doneWithPhone: string;
|
|
90
|
+
sourcePhone: string;
|
|
91
|
+
sourceDevice: string;
|
|
92
|
+
remove: string;
|
|
93
|
+
tooLarge: string;
|
|
94
|
+
wrongType: string;
|
|
95
|
+
tooMany: string;
|
|
96
|
+
fileCount: string;
|
|
97
|
+
clearAll: string;
|
|
98
|
+
announceText: string;
|
|
99
|
+
announceLink: string;
|
|
100
|
+
announceHide: string;
|
|
101
|
+
};
|
|
102
|
+
type Strings = typeof en;
|
|
103
|
+
type StringKey = keyof Strings;
|
|
104
|
+
|
|
105
|
+
interface PickOptions extends Omit<SessionOptions, "locale"> {
|
|
106
|
+
/** Your publishable key (pk_live_… or pk_test_…). */
|
|
107
|
+
key: string;
|
|
108
|
+
/** Relay URL. Defaults to the hosted relay. */
|
|
109
|
+
relay?: string;
|
|
110
|
+
/** "auto" follows the page's lang attribute, then the browser. */
|
|
111
|
+
locale?: Locale | "auto";
|
|
112
|
+
/** false: no modal; use the controller's events, claimUrl and code to build your own UI. */
|
|
113
|
+
ui?: boolean;
|
|
114
|
+
theme?: "light" | "dark" | "auto";
|
|
115
|
+
/** Replace any of the modal's strings. */
|
|
116
|
+
strings?: Partial<Record<StringKey, string>>;
|
|
117
|
+
/** A small, dismissible line about TokShare for desktop in the modal and the field. Default true. */
|
|
118
|
+
announce?: boolean;
|
|
119
|
+
signal?: AbortSignal;
|
|
120
|
+
}
|
|
121
|
+
interface ProgressInfo {
|
|
122
|
+
id: string;
|
|
123
|
+
name: string;
|
|
124
|
+
sent: number;
|
|
125
|
+
total: number;
|
|
126
|
+
/** "upload": phone → relay (or straight to this page over Wi-Fi). "download": relay → this page. */
|
|
127
|
+
phase: "upload" | "download";
|
|
128
|
+
}
|
|
129
|
+
interface PickEvents {
|
|
130
|
+
ready: {
|
|
131
|
+
claimUrl: string;
|
|
132
|
+
code: string;
|
|
133
|
+
};
|
|
134
|
+
phone: {
|
|
135
|
+
phone: PhoneInfo;
|
|
136
|
+
needsApproval: boolean;
|
|
137
|
+
match?: string;
|
|
138
|
+
};
|
|
139
|
+
phone_left: undefined;
|
|
140
|
+
/** The phone is on the same network and files come straight to this page (true), or not any more. */
|
|
141
|
+
direct: {
|
|
142
|
+
connected: boolean;
|
|
143
|
+
};
|
|
144
|
+
file_started: FileMeta;
|
|
145
|
+
progress: ProgressInfo;
|
|
146
|
+
file: File;
|
|
147
|
+
/** The same file, with the relay id its progress events used. */
|
|
148
|
+
received: {
|
|
149
|
+
id: string;
|
|
150
|
+
file: File;
|
|
151
|
+
};
|
|
152
|
+
file_failed: {
|
|
153
|
+
id: string;
|
|
154
|
+
code: string;
|
|
155
|
+
};
|
|
156
|
+
error: PickError;
|
|
157
|
+
close: CloseReason | "canceled" | "finished";
|
|
158
|
+
}
|
|
159
|
+
interface PickController {
|
|
160
|
+
/** Resolves with the received files when the person finishes; [] if canceled before any arrived. */
|
|
161
|
+
readonly done: Promise<File[]>;
|
|
162
|
+
/** Files received so far. */
|
|
163
|
+
readonly files: readonly File[];
|
|
164
|
+
readonly claimUrl: string | null;
|
|
165
|
+
readonly code: string | null;
|
|
166
|
+
on<E extends keyof PickEvents>(event: E, handler: (detail: PickEvents[E]) => void): () => void;
|
|
167
|
+
/** Use the files received so far. */
|
|
168
|
+
finish(): void;
|
|
169
|
+
/** Close without files. */
|
|
170
|
+
cancel(): void;
|
|
171
|
+
approve(): void;
|
|
172
|
+
reject(): void;
|
|
173
|
+
/** Forget the connected phone and show a new code. */
|
|
174
|
+
disconnect(): Promise<void>;
|
|
175
|
+
/** Start over with a new session (after an expiry or error). */
|
|
176
|
+
restart(): void;
|
|
177
|
+
}
|
|
178
|
+
declare function open(options: PickOptions): PickController;
|
|
179
|
+
/** Opens the picker and resolves with the files the person sent ([] if they canceled). */
|
|
180
|
+
declare function pick(options: PickOptions): Promise<File[]>;
|
|
181
|
+
interface AttachOptions extends Omit<PickOptions, "accept" | "multiple"> {
|
|
182
|
+
/** "replace" (default) sets the input's files; "append" adds to what it already has. */
|
|
183
|
+
mode?: "replace" | "append";
|
|
184
|
+
}
|
|
185
|
+
/** Fills an existing <input type="file"> with files from the phone, firing input and change events,
|
|
186
|
+
* so forms and frameworks that listen to the input keep working. Returns a function that does it. */
|
|
187
|
+
declare function attach(input: HTMLInputElement, options: AttachOptions): () => Promise<File[]>;
|
|
188
|
+
|
|
189
|
+
interface FieldOptions extends Omit<PickOptions, "ui"> {
|
|
190
|
+
/** Form field name: the files go into a hidden <input type="file" name> inside the target. */
|
|
191
|
+
name?: string;
|
|
192
|
+
/** "inline" (default): the phone flow opens inside the field. "modal": in a window. false: no phone. */
|
|
193
|
+
phone?: "inline" | "modal" | false;
|
|
194
|
+
/** Show "Use your phone" even when this page itself is open on a phone. */
|
|
195
|
+
phoneOnMobile?: boolean;
|
|
196
|
+
/** Replaces the drop zone's title. */
|
|
197
|
+
label?: string;
|
|
198
|
+
}
|
|
199
|
+
interface FieldController {
|
|
200
|
+
readonly files: readonly File[];
|
|
201
|
+
/** The hidden input the files are kept in (for forms and frameworks). */
|
|
202
|
+
readonly input: HTMLInputElement;
|
|
203
|
+
on(event: "change", handler: (files: File[]) => void): () => void;
|
|
204
|
+
remove(file: File): void;
|
|
205
|
+
clear(): void;
|
|
206
|
+
destroy(): void;
|
|
207
|
+
}
|
|
208
|
+
/** "5MB", "500 KB", "2e6" → bytes. */
|
|
209
|
+
declare function parseSize(value: string | number | null | undefined): number | undefined;
|
|
210
|
+
declare function mountField(target: HTMLElement | string, options: FieldOptions): FieldController;
|
|
211
|
+
/** <tokshare-pick-field key name accept multiple max-files max-size phone locale theme relay label direct announce>.
|
|
212
|
+
* direct="off" sends everything through the cloud; announce="off" hides the TokShare for desktop line. */
|
|
213
|
+
declare function defineFieldElement(defaults?: Partial<FieldOptions>, tag?: string): void;
|
|
214
|
+
|
|
215
|
+
/** The hosted relay. Override with the `relay` option or a script tag's data-relay attribute
|
|
216
|
+
* (local development: "http://localhost:8788").
|
|
217
|
+
* 0.1.x uses the relay's workers.dev address; a later version moves to the TokShare domain. That
|
|
218
|
+
* address must stay up for sites still on 0.1.x (wrangler.jsonc keeps workers_dev on). */
|
|
219
|
+
declare const DEFAULT_RELAY = "https://tokshare-pick.pjturki.workers.dev";
|
|
220
|
+
declare const SDK_VERSION = "0.1.1";
|
|
221
|
+
|
|
222
|
+
/** The same functions as one object: TokSharePick.pick({ key }). */
|
|
223
|
+
declare const TokSharePick: {
|
|
224
|
+
pick: typeof pick;
|
|
225
|
+
open: typeof open;
|
|
226
|
+
attach: typeof attach;
|
|
227
|
+
mountField: typeof mountField;
|
|
228
|
+
defineFieldElement: typeof defineFieldElement;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
export { type AttachOptions, DEFAULT_RELAY, type ErrorCode, type FieldController, type FieldOptions, type FileMeta, type PhoneInfo, type PickController, PickError, type PickEvents, type PickOptions, type ProgressInfo, SDK_VERSION, TokSharePick, attach, defineFieldElement, mountField, open, parseSize, pick };
|