@pc-nexus/bridge 0.5.0-next.8 → 0.5.0
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SUPPORTED_LOCALE_CODES } from '@pc-nexus/models';
|
|
2
|
-
export { HistoryAction, NavigationTarget
|
|
2
|
+
export { HistoryAction, NavigationTarget } from '@pc-nexus/models';
|
|
3
3
|
|
|
4
4
|
function attachObjectToWindow(key, value) {
|
|
5
5
|
window[key] = value;
|
|
@@ -66,21 +66,21 @@ if (typeof window !== "undefined") {
|
|
|
66
66
|
|
|
67
67
|
function validateOpenOptions(options) {
|
|
68
68
|
if (typeof options !== "object" || options === null) {
|
|
69
|
-
throw new BridgeAPIError('"options" must be an object in dialog
|
|
69
|
+
throw new BridgeAPIError('Parameter "options" must be an object in "dialog.open".');
|
|
70
70
|
}
|
|
71
71
|
if (!options.resource) {
|
|
72
|
-
throw new BridgeAPIError('"resource" is required in dialog
|
|
72
|
+
throw new BridgeAPIError('Parameter "resource" is required in "dialog.open" options.');
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
function validateConfirmOptions(options) {
|
|
76
76
|
if (typeof options !== "object" || options === null) {
|
|
77
|
-
throw new BridgeAPIError('"options" must be an object in dialog
|
|
77
|
+
throw new BridgeAPIError('Parameter "options" must be an object in "dialog.confirm".');
|
|
78
78
|
}
|
|
79
79
|
if (!options.content) {
|
|
80
|
-
throw new BridgeAPIError('"content" is required in dialog
|
|
80
|
+
throw new BridgeAPIError('Parameter "content" is required in "dialog.confirm" options.');
|
|
81
81
|
}
|
|
82
82
|
if (typeof options.onConfirm !== "function") {
|
|
83
|
-
throw new BridgeAPIError('"onConfirm" must be a function in dialog
|
|
83
|
+
throw new BridgeAPIError('Parameter "onConfirm" must be a function in "dialog.confirm" options.');
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
class NexusDialog {
|
|
@@ -100,12 +100,12 @@ function validatePayload(payload) {
|
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
102
|
if (Object.values(payload).some((value) => typeof value === "function")) {
|
|
103
|
-
throw new BridgeAPIError("
|
|
103
|
+
throw new BridgeAPIError('Parameter "payload" must not include functions in "invoke".');
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
async function invoke(functionKey, payload) {
|
|
107
107
|
if (typeof functionKey !== "string") {
|
|
108
|
-
throw new BridgeAPIError('"functionKey" must be a string in invoke.');
|
|
108
|
+
throw new BridgeAPIError('Parameter "functionKey" must be a string in "invoke".');
|
|
109
109
|
}
|
|
110
110
|
validatePayload(payload);
|
|
111
111
|
const params = {
|
|
@@ -117,16 +117,21 @@ async function invoke(functionKey, payload) {
|
|
|
117
117
|
return result;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
function validateNavigationLocation(location, apiName) {
|
|
121
|
+
if (!location?.target) {
|
|
122
|
+
throw new BridgeAPIError(`Parameter "target" is required in "${apiName}" location.`);
|
|
123
|
+
}
|
|
124
|
+
if (!location?.id) {
|
|
125
|
+
throw new BridgeAPIError(`Parameter "id" is required in "${apiName}" location.`);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
120
128
|
class NexusRouter {
|
|
121
129
|
async navigate(urlOrLocation) {
|
|
122
130
|
if (typeof urlOrLocation === "string") {
|
|
123
131
|
await NexusBridge.call("routerNavigate", { urlOrLocation });
|
|
124
132
|
}
|
|
125
133
|
else {
|
|
126
|
-
|
|
127
|
-
const errorMessage = '"target" is required in router navigate.';
|
|
128
|
-
throw new BridgeAPIError(errorMessage);
|
|
129
|
-
}
|
|
134
|
+
validateNavigationLocation(urlOrLocation, "router.navigate");
|
|
130
135
|
await NexusBridge.call("routerNavigate", { urlOrLocation });
|
|
131
136
|
}
|
|
132
137
|
}
|
|
@@ -135,19 +140,14 @@ class NexusRouter {
|
|
|
135
140
|
await NexusBridge.call("routerOpen", { urlOrLocation });
|
|
136
141
|
}
|
|
137
142
|
else {
|
|
138
|
-
|
|
139
|
-
const errorMessage = '"target" is required in router open.';
|
|
140
|
-
throw new BridgeAPIError(errorMessage);
|
|
141
|
-
}
|
|
143
|
+
validateNavigationLocation(urlOrLocation, "router.open");
|
|
142
144
|
await NexusBridge.call("routerOpen", { urlOrLocation });
|
|
143
145
|
}
|
|
144
146
|
}
|
|
145
147
|
async generateUrl(location) {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
return await NexusBridge.call("routerGenerateUrl", { location });
|
|
148
|
+
validateNavigationLocation(location, "router.generateUrl");
|
|
149
|
+
const urlString = await NexusBridge.call("routerGenerateUrl", { location });
|
|
150
|
+
return new URL(urlString);
|
|
151
151
|
}
|
|
152
152
|
async reload() {
|
|
153
153
|
await NexusBridge.call("routerReload", {});
|
|
@@ -161,23 +161,26 @@ class NexusView {
|
|
|
161
161
|
}
|
|
162
162
|
async setWindowTitle(title) {
|
|
163
163
|
if (!title) {
|
|
164
|
-
throw new BridgeAPIError('"title" is required in view
|
|
164
|
+
throw new BridgeAPIError('Parameter "title" is required in "view.setWindowTitle".');
|
|
165
165
|
}
|
|
166
166
|
if (typeof title !== "string") {
|
|
167
|
-
throw new BridgeAPIError('"title" must be a string in view
|
|
167
|
+
throw new BridgeAPIError('Parameter "title" must be a string in "view.setWindowTitle".');
|
|
168
|
+
}
|
|
169
|
+
const success = await NexusBridge.call("setWindowTitle", { title });
|
|
170
|
+
if (!success) {
|
|
171
|
+
throw new BridgeAPIError('API "setWindowTitle" is not available within this module.');
|
|
168
172
|
}
|
|
169
|
-
await NexusBridge.call("setWindowTitle", { title });
|
|
170
173
|
}
|
|
171
|
-
async
|
|
172
|
-
const success = await NexusBridge.call("
|
|
174
|
+
async refresh() {
|
|
175
|
+
const success = await NexusBridge.call("viewRefresh");
|
|
173
176
|
if (success === false) {
|
|
174
|
-
throw new BridgeAPIError("
|
|
177
|
+
throw new BridgeAPIError("This resource's view is not refreshable.");
|
|
175
178
|
}
|
|
176
179
|
}
|
|
177
180
|
async close(payload) {
|
|
178
181
|
const success = await NexusBridge.call("viewClose", payload);
|
|
179
182
|
if (!success) {
|
|
180
|
-
const errorMessage = "
|
|
183
|
+
const errorMessage = "This resource's view is not closable.";
|
|
181
184
|
throw new BridgeAPIError(errorMessage);
|
|
182
185
|
}
|
|
183
186
|
}
|
|
@@ -186,12 +189,12 @@ class NexusView {
|
|
|
186
189
|
*/
|
|
187
190
|
async onClose(payload) {
|
|
188
191
|
if (typeof payload !== "function") {
|
|
189
|
-
const errorMessage = '"payload" must be a function in view
|
|
192
|
+
const errorMessage = 'Parameter "payload" must be a function in "view.onClose".';
|
|
190
193
|
throw new BridgeAPIError(errorMessage);
|
|
191
194
|
}
|
|
192
195
|
const success = await NexusBridge.call("viewOnClose", { payload });
|
|
193
196
|
if (!success) {
|
|
194
|
-
throw new BridgeAPIError("
|
|
197
|
+
throw new BridgeAPIError("This resource's view is not closable.");
|
|
195
198
|
}
|
|
196
199
|
}
|
|
197
200
|
async isDialog() {
|
|
@@ -199,16 +202,19 @@ class NexusView {
|
|
|
199
202
|
}
|
|
200
203
|
async createHistory() {
|
|
201
204
|
const history = await NexusBridge.call("createHistory");
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
+
if (!history) {
|
|
206
|
+
throw new BridgeAPIError('API "createHistory" is not available within this module.');
|
|
207
|
+
}
|
|
208
|
+
await history.listen((update) => {
|
|
209
|
+
history.action = update.action;
|
|
210
|
+
history.location = update.location;
|
|
205
211
|
});
|
|
206
212
|
return history;
|
|
207
213
|
}
|
|
208
214
|
async submit(payload) {
|
|
209
215
|
const result = await NexusBridge.call("viewSubmit", payload);
|
|
210
216
|
if (!result) {
|
|
211
|
-
throw new BridgeAPIError("
|
|
217
|
+
throw new BridgeAPIError("This resource's view is not submittable.");
|
|
212
218
|
}
|
|
213
219
|
return result;
|
|
214
220
|
}
|
|
@@ -254,12 +260,23 @@ const blobToBase64 = (blob) => {
|
|
|
254
260
|
reader.readAsDataURL(blob);
|
|
255
261
|
});
|
|
256
262
|
};
|
|
263
|
+
const blobToArrayBuffer = (blob) => {
|
|
264
|
+
return new Promise((resolve, reject) => {
|
|
265
|
+
const reader = new FileReader();
|
|
266
|
+
reader.onloadend = () => {
|
|
267
|
+
resolve(reader.result);
|
|
268
|
+
};
|
|
269
|
+
reader.onerror = reject;
|
|
270
|
+
reader.readAsArrayBuffer(blob);
|
|
271
|
+
});
|
|
272
|
+
};
|
|
257
273
|
const serialiseBlobsInPayload = async (payload) => {
|
|
258
274
|
if (payload instanceof Blob) {
|
|
259
275
|
const base64Data = await blobToBase64(payload);
|
|
260
276
|
return {
|
|
261
277
|
data: base64Data,
|
|
262
278
|
type: payload.type,
|
|
279
|
+
name: payload instanceof File ? payload.name : undefined,
|
|
263
280
|
__isBlobData: true,
|
|
264
281
|
};
|
|
265
282
|
}
|
|
@@ -316,24 +333,24 @@ const containsSerialisedBlobs = (payload) => {
|
|
|
316
333
|
|
|
317
334
|
function validateOnPayload(eventName, callback) {
|
|
318
335
|
if (!eventName) {
|
|
319
|
-
throw new BridgeAPIError('"eventName" is required in events
|
|
336
|
+
throw new BridgeAPIError('Parameter "eventName" is required in "events.on".');
|
|
320
337
|
}
|
|
321
338
|
if (typeof eventName !== "string") {
|
|
322
|
-
throw new BridgeAPIError('"eventName" must be a string in events
|
|
339
|
+
throw new BridgeAPIError('Parameter "eventName" must be a string in "events.on".');
|
|
323
340
|
}
|
|
324
341
|
if (!callback) {
|
|
325
|
-
throw new BridgeAPIError('"callback" is required in events
|
|
342
|
+
throw new BridgeAPIError('Parameter "callback" is required in "events.on".');
|
|
326
343
|
}
|
|
327
344
|
if (typeof callback !== "function") {
|
|
328
|
-
throw new BridgeAPIError('"callback" must be a function in events
|
|
345
|
+
throw new BridgeAPIError('Parameter "callback" must be a function in "events.on".');
|
|
329
346
|
}
|
|
330
347
|
}
|
|
331
348
|
function validateEmitPayload(eventName) {
|
|
332
349
|
if (!eventName) {
|
|
333
|
-
throw new BridgeAPIError('"eventName" is required in events
|
|
350
|
+
throw new BridgeAPIError('Parameter "eventName" is required in "events.emit".');
|
|
334
351
|
}
|
|
335
352
|
if (typeof eventName !== "string") {
|
|
336
|
-
throw new BridgeAPIError('"eventName" must be a string in events
|
|
353
|
+
throw new BridgeAPIError('Parameter "eventName" must be a string in "events.emit".');
|
|
337
354
|
}
|
|
338
355
|
}
|
|
339
356
|
async function on(eventName, callback) {
|
|
@@ -369,7 +386,7 @@ class NexusI18n {
|
|
|
369
386
|
}
|
|
370
387
|
else {
|
|
371
388
|
if (!SUPPORTED_LOCALE_CODES.includes(locale)) {
|
|
372
|
-
throw new BridgeAPIError(`"locale" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(", ")}.`);
|
|
389
|
+
throw new BridgeAPIError(`Parameter "locale" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(", ")} in "i18n.getTranslations".`);
|
|
373
390
|
}
|
|
374
391
|
}
|
|
375
392
|
const translations = await this.loadTranslations(locale);
|
|
@@ -381,7 +398,7 @@ class NexusI18n {
|
|
|
381
398
|
}
|
|
382
399
|
else {
|
|
383
400
|
if (!SUPPORTED_LOCALE_CODES.includes(locale)) {
|
|
384
|
-
throw new BridgeAPIError(`"locale" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(", ")}.`);
|
|
401
|
+
throw new BridgeAPIError(`Parameter "locale" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(", ")} in "i18n.createTranslator".`);
|
|
385
402
|
}
|
|
386
403
|
}
|
|
387
404
|
const translations = await this.loadTranslations(locale);
|
|
@@ -393,11 +410,21 @@ class NexusI18n {
|
|
|
393
410
|
const url = `../${this.i18nFolderName}/${locale}.json`;
|
|
394
411
|
if (!this.translationsCache[locale]) {
|
|
395
412
|
this.translationsCache[locale] = fetch(url)
|
|
396
|
-
.then((response) =>
|
|
413
|
+
.then((response) => {
|
|
414
|
+
if (!response.ok) {
|
|
415
|
+
throw new BridgeAPIError(`Failed to load translations for locale ${locale}. HTTP ${response.status}: ${response.statusText}`);
|
|
416
|
+
}
|
|
417
|
+
return response.json();
|
|
418
|
+
})
|
|
397
419
|
.catch((error) => {
|
|
398
420
|
// 请求失败要清理缓存
|
|
399
421
|
delete this.translationsCache[locale];
|
|
400
|
-
|
|
422
|
+
if (error instanceof BridgeAPIError) {
|
|
423
|
+
throw error;
|
|
424
|
+
}
|
|
425
|
+
else {
|
|
426
|
+
throw new BridgeAPIError(`Failed to load translations for locale ${locale}. ${error}`);
|
|
427
|
+
}
|
|
401
428
|
});
|
|
402
429
|
}
|
|
403
430
|
return this.translationsCache[locale];
|
|
@@ -407,7 +434,7 @@ class NexusI18n {
|
|
|
407
434
|
}
|
|
408
435
|
translate(key, translations, params) {
|
|
409
436
|
if (!key) {
|
|
410
|
-
throw new BridgeAPIError('"key" is required in i18n
|
|
437
|
+
throw new BridgeAPIError('Parameter "key" is required in "i18n.translate".');
|
|
411
438
|
}
|
|
412
439
|
// 获取值(扁平或嵌套)
|
|
413
440
|
let value = translations[key] ?? this.getValue(translations, key);
|
|
@@ -432,6 +459,17 @@ class NexusI18n {
|
|
|
432
459
|
}
|
|
433
460
|
const i18n = new NexusI18n();
|
|
434
461
|
|
|
462
|
+
const validateFetchOptions = (init) => {
|
|
463
|
+
if (!init) {
|
|
464
|
+
return init;
|
|
465
|
+
}
|
|
466
|
+
if ("signal" in init) {
|
|
467
|
+
const { signal: _signal, ...rest } = init;
|
|
468
|
+
console.error("Signal is not supported in @pc-nexus/bridge and was removed from fetch options.");
|
|
469
|
+
return rest;
|
|
470
|
+
}
|
|
471
|
+
return init;
|
|
472
|
+
};
|
|
435
473
|
async function buildPayloadByRequestInit(init) {
|
|
436
474
|
const requestBody = init === null || init === void 0 ? void 0 : init.body;
|
|
437
475
|
const requestMethod = init === null || init === void 0 ? void 0 : init.method;
|
|
@@ -457,60 +495,354 @@ async function parseToResponseData(res) {
|
|
|
457
495
|
});
|
|
458
496
|
return response;
|
|
459
497
|
}
|
|
460
|
-
|
|
461
|
-
const
|
|
462
|
-
|
|
463
|
-
|
|
498
|
+
async function parseFormData(formData) {
|
|
499
|
+
const entries = [];
|
|
500
|
+
for (const [name, value] of formData.entries()) {
|
|
501
|
+
entries.push({
|
|
502
|
+
name,
|
|
503
|
+
value: typeof value === "string" ? value : await serialiseBlobsInPayload(value),
|
|
504
|
+
});
|
|
464
505
|
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
506
|
+
return entries;
|
|
507
|
+
}
|
|
508
|
+
async function buildRemoteRequestPayload(remoteKey, options) {
|
|
509
|
+
const { path = "", ...requestOptions } = options;
|
|
510
|
+
const isMultipartFormData = requestOptions.body instanceof FormData;
|
|
511
|
+
const request = new Request("", {
|
|
512
|
+
body: requestOptions.body,
|
|
513
|
+
method: requestOptions.method,
|
|
514
|
+
headers: requestOptions.headers,
|
|
515
|
+
});
|
|
516
|
+
const headers = Object.fromEntries(request.headers.entries());
|
|
517
|
+
let body;
|
|
518
|
+
if (isMultipartFormData) {
|
|
519
|
+
body = await parseFormData(requestOptions.body);
|
|
469
520
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
521
|
+
else if (request.method !== "GET") {
|
|
522
|
+
body = await request.text();
|
|
523
|
+
}
|
|
524
|
+
return {
|
|
525
|
+
remoteKey,
|
|
526
|
+
path,
|
|
527
|
+
isMultipartFormData,
|
|
528
|
+
requestInit: {
|
|
529
|
+
...requestOptions,
|
|
530
|
+
body,
|
|
531
|
+
method: requestOptions.method ?? "GET",
|
|
532
|
+
headers,
|
|
533
|
+
},
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
async function parseRemoteResponseData(res) {
|
|
537
|
+
const headers = new Headers(res.headers);
|
|
538
|
+
const blob = res.isBinaryContent && res.body ? base64ToBlob(res.body, headers.get("content-type") ?? "") : undefined;
|
|
539
|
+
const responseBody = blob ? await blobToArrayBuffer(blob) : res.body;
|
|
540
|
+
return new Response(responseBody ?? null, {
|
|
541
|
+
status: res.status,
|
|
542
|
+
statusText: res.statusText,
|
|
543
|
+
headers,
|
|
544
|
+
});
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
async function callInvokeBridge(handlerName, payload) {
|
|
473
548
|
const postPayload = await buildPayloadByRequestInit(payload);
|
|
474
549
|
const { status, headers, body } = await NexusBridge.call(handlerName, postPayload);
|
|
475
550
|
return parseToResponseData({ status, headers, body });
|
|
476
551
|
}
|
|
477
552
|
class NexusRestApi {
|
|
478
|
-
async
|
|
553
|
+
async invoke(path, options) {
|
|
479
554
|
if (typeof path !== "string") {
|
|
480
|
-
throw new BridgeAPIError('"path" must be a string in api.
|
|
555
|
+
throw new BridgeAPIError('Parameter "path" must be a string in "api.invoke".');
|
|
481
556
|
}
|
|
482
557
|
const validatedOptions = validateFetchOptions(options);
|
|
483
|
-
return
|
|
558
|
+
return callInvokeBridge("apiInvoke", { path, ...validatedOptions });
|
|
484
559
|
}
|
|
485
560
|
}
|
|
486
561
|
const api = new NexusRestApi();
|
|
487
562
|
|
|
488
|
-
|
|
563
|
+
async function buildObjectMetadata(file) {
|
|
564
|
+
const size = file.size;
|
|
565
|
+
const arrayBuffer = await file.arrayBuffer();
|
|
566
|
+
let checksum;
|
|
567
|
+
const checksum_type = "SHA256";
|
|
568
|
+
// crypto.subtle 只能在安全上下文(HTTPS 或 localhost)中使用
|
|
569
|
+
// sha256 兼容模拟器非安全上下文
|
|
570
|
+
if (typeof crypto !== "undefined" && crypto.subtle) {
|
|
571
|
+
const hashBuffer = await crypto.subtle.digest("SHA-256", arrayBuffer);
|
|
572
|
+
const hashArray = new Uint8Array(hashBuffer);
|
|
573
|
+
checksum = btoa(String.fromCharCode(...hashArray));
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
const jsHash = await sha256(arrayBuffer);
|
|
577
|
+
checksum = btoa(String.fromCharCode(...new Uint8Array(jsHash)));
|
|
578
|
+
}
|
|
579
|
+
return {
|
|
580
|
+
size,
|
|
581
|
+
checksum,
|
|
582
|
+
checksum_type,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
function buildChecksumToFileMap(files, metadata) {
|
|
586
|
+
const map = new Map();
|
|
587
|
+
files.forEach((file, index) => {
|
|
588
|
+
map.set(metadata[index].checksum, {
|
|
589
|
+
file,
|
|
590
|
+
index,
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
return map;
|
|
594
|
+
}
|
|
595
|
+
function uploadFile(url, file, key) {
|
|
596
|
+
const formData = new FormData();
|
|
597
|
+
const fileName = file.name || key;
|
|
598
|
+
formData.append("file", file, fileName);
|
|
599
|
+
return fetch(url, {
|
|
600
|
+
method: "PUT",
|
|
601
|
+
body: formData,
|
|
602
|
+
})
|
|
603
|
+
.then((response) => ({
|
|
604
|
+
success: response.ok,
|
|
605
|
+
key,
|
|
606
|
+
status: response.status,
|
|
607
|
+
error: response.ok ? undefined : `Upload failed with status ${response.status}`,
|
|
608
|
+
}))
|
|
609
|
+
.catch((error) => ({
|
|
610
|
+
success: false,
|
|
611
|
+
key,
|
|
612
|
+
status: 503,
|
|
613
|
+
error: error instanceof Error ? error.message : "Upload failed",
|
|
614
|
+
}));
|
|
615
|
+
}
|
|
616
|
+
class NexusObjectStore {
|
|
489
617
|
async upload(functionKey, objects) {
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
618
|
+
if (!functionKey || functionKey.length === 0) {
|
|
619
|
+
throw new BridgeAPIError('Parameter "functionKey" is required in "store.upload".');
|
|
620
|
+
}
|
|
621
|
+
if (!Array.isArray(objects) || objects.length === 0) {
|
|
622
|
+
throw new BridgeAPIError('Parameter "objects" is required and cannot be empty in "store.upload".');
|
|
623
|
+
}
|
|
624
|
+
const files = objects.map((obj, index) => {
|
|
625
|
+
if (obj instanceof File || obj instanceof Blob)
|
|
626
|
+
return obj;
|
|
627
|
+
throw new BridgeAPIError(`Parameter "objects" at index ${index} must be a Blob or File in "store.upload".`);
|
|
628
|
+
});
|
|
629
|
+
const allObjectMetadata = await Promise.all(files.map((file) => buildObjectMetadata(file)));
|
|
630
|
+
const presignedURLsToObjectMetadata = await invoke(functionKey, allObjectMetadata);
|
|
631
|
+
if (!presignedURLsToObjectMetadata || typeof presignedURLsToObjectMetadata !== "object") {
|
|
632
|
+
throw new BridgeAPIError('Failed to get a valid response from "invoke".');
|
|
633
|
+
}
|
|
634
|
+
const checksumMap = buildChecksumToFileMap(files, allObjectMetadata);
|
|
635
|
+
const uploadPromises = Object.entries(presignedURLsToObjectMetadata).map(([presignedUrl, { key, checksum }]) => {
|
|
636
|
+
const fileInfo = checksumMap.get(checksum);
|
|
637
|
+
if (!fileInfo) {
|
|
638
|
+
return {
|
|
639
|
+
promise: Promise.resolve({
|
|
640
|
+
success: false,
|
|
641
|
+
key,
|
|
642
|
+
error: `File not found for checksum ${checksum}`,
|
|
643
|
+
}),
|
|
644
|
+
index: -1,
|
|
645
|
+
};
|
|
646
|
+
}
|
|
647
|
+
const { file, index } = fileInfo;
|
|
648
|
+
const promise = uploadFile(presignedUrl, file, key);
|
|
649
|
+
return {
|
|
650
|
+
promise,
|
|
651
|
+
index,
|
|
652
|
+
objectType: file.type,
|
|
653
|
+
objectSize: file.size,
|
|
654
|
+
};
|
|
655
|
+
});
|
|
656
|
+
return await Promise.all(uploadPromises.map((t) => t.promise));
|
|
493
657
|
}
|
|
494
658
|
async download(functionKey, keys) {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
659
|
+
if (!functionKey || functionKey.length === 0) {
|
|
660
|
+
throw new BridgeAPIError('Parameter "functionKey" is required in "store.download".');
|
|
661
|
+
}
|
|
662
|
+
if (!Array.isArray(keys) || keys.length === 0) {
|
|
663
|
+
throw new BridgeAPIError('Parameter "keys" is required and cannot be empty in "store.download".');
|
|
664
|
+
}
|
|
665
|
+
const downloadUrlsTokeys = await invoke(functionKey, keys);
|
|
666
|
+
if (!downloadUrlsTokeys || typeof downloadUrlsTokeys !== "object") {
|
|
667
|
+
throw new BridgeAPIError('Failed to get a valid response from "invoke".');
|
|
668
|
+
}
|
|
669
|
+
const downloadPromises = Object.entries(downloadUrlsTokeys).map(async ([downloadUrl, key]) => {
|
|
670
|
+
try {
|
|
671
|
+
const response = await fetch(downloadUrl, {
|
|
672
|
+
method: "GET",
|
|
673
|
+
});
|
|
674
|
+
if (!response.ok) {
|
|
675
|
+
return {
|
|
676
|
+
success: false,
|
|
677
|
+
key: key,
|
|
678
|
+
status: response.status,
|
|
679
|
+
error: `Download failed with status ${response.status}`,
|
|
680
|
+
};
|
|
681
|
+
}
|
|
682
|
+
const blob = await response.blob();
|
|
683
|
+
const disposition = response.headers.get("Content-Disposition") ?? "";
|
|
684
|
+
const name = disposition.match(/filename\*=UTF-8''([^;]+)/)?.[1] ?? disposition.match(/filename="?([^"]+)"?/)?.[1] ?? "";
|
|
685
|
+
return {
|
|
686
|
+
success: true,
|
|
687
|
+
key: key,
|
|
688
|
+
blob,
|
|
689
|
+
name,
|
|
690
|
+
status: response.status,
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
catch (error) {
|
|
694
|
+
return {
|
|
695
|
+
success: false,
|
|
696
|
+
key: key,
|
|
697
|
+
status: 503,
|
|
698
|
+
error: error instanceof Error ? error.message : "Download failed",
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
});
|
|
702
|
+
return await Promise.all(downloadPromises);
|
|
498
703
|
}
|
|
499
|
-
async
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
704
|
+
async getMetadata(functionKey, keys) {
|
|
705
|
+
if (!functionKey || functionKey.length === 0) {
|
|
706
|
+
throw new BridgeAPIError('Parameter "functionKey" is required in "store.getMetadata".');
|
|
707
|
+
}
|
|
708
|
+
if (!Array.isArray(keys) || keys.length === 0) {
|
|
709
|
+
throw new BridgeAPIError('Parameter "keys" is required and cannot be empty in "store.getMetadata".');
|
|
710
|
+
}
|
|
711
|
+
const results = await Promise.all(keys.map(async (key) => {
|
|
712
|
+
const result = await invoke(functionKey, key);
|
|
713
|
+
if (!result || typeof result !== "object") {
|
|
714
|
+
return {
|
|
715
|
+
key,
|
|
716
|
+
error: 'Failed to get a valid response from "invoke".',
|
|
717
|
+
};
|
|
718
|
+
}
|
|
719
|
+
return result;
|
|
720
|
+
}));
|
|
721
|
+
return results;
|
|
503
722
|
}
|
|
504
723
|
async delete(functionKey, keys) {
|
|
505
|
-
|
|
506
|
-
|
|
724
|
+
if (!functionKey || functionKey.length === 0) {
|
|
725
|
+
throw new BridgeAPIError('Parameter "functionKey" is required in "store.delete".');
|
|
726
|
+
}
|
|
727
|
+
if (!Array.isArray(keys) || keys.length === 0) {
|
|
728
|
+
throw new BridgeAPIError('Parameter "keys" is required and cannot be empty in "store.delete".');
|
|
729
|
+
}
|
|
730
|
+
await Promise.all(keys.map(async (key) => {
|
|
731
|
+
await invoke(functionKey, key);
|
|
732
|
+
}));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
const store = new NexusObjectStore();
|
|
736
|
+
function sha256(buffer) {
|
|
737
|
+
const bytes = new Uint8Array(buffer);
|
|
738
|
+
const len = bytes.length;
|
|
739
|
+
const blockSize = 64;
|
|
740
|
+
const hashSize = 32;
|
|
741
|
+
const K = new Uint32Array([
|
|
742
|
+
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be,
|
|
743
|
+
0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa,
|
|
744
|
+
0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85,
|
|
745
|
+
0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
|
|
746
|
+
0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,
|
|
747
|
+
0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,
|
|
748
|
+
]);
|
|
749
|
+
let h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a;
|
|
750
|
+
let h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
|
|
751
|
+
const totalBits = BigInt(len) * 8n;
|
|
752
|
+
const paddingLen = len % blockSize < 56 ? 56 - (len % blockSize) : 120 - (len % blockSize);
|
|
753
|
+
const paddedLen = len + paddingLen + 8;
|
|
754
|
+
const padded = new Uint8Array(paddedLen);
|
|
755
|
+
padded.set(bytes);
|
|
756
|
+
padded[len] = 0x80;
|
|
757
|
+
const view = new DataView(padded.buffer, padded.byteOffset);
|
|
758
|
+
view.setUint32(paddedLen - 4, Number((totalBits >> 32n) & 0xffffffffn));
|
|
759
|
+
view.setUint32(paddedLen - 8, Number(totalBits & 0xffffffffn));
|
|
760
|
+
for (let i = 0; i < paddedLen; i += blockSize) {
|
|
761
|
+
const w = new Uint32Array(64);
|
|
762
|
+
for (let j = 0; j < 16; j++) {
|
|
763
|
+
w[j] = view.getUint32(i + j * 4);
|
|
764
|
+
}
|
|
765
|
+
for (let j = 16; j < 64; j++) {
|
|
766
|
+
const s0 = ((w[j - 15] >>> 7) | (w[j - 15] << 25)) ^ ((w[j - 15] >>> 18) | (w[j - 15] << 14)) ^ (w[j - 15] >>> 3);
|
|
767
|
+
const s1 = ((w[j - 2] >>> 17) | (w[j - 2] << 15)) ^ ((w[j - 2] >>> 19) | (w[j - 2] << 13)) ^ (w[j - 2] >>> 10);
|
|
768
|
+
w[j] = (w[j - 16] + s0 + w[j - 7] + s1) >>> 0;
|
|
769
|
+
}
|
|
770
|
+
let a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7;
|
|
771
|
+
for (let j = 0; j < 64; j++) {
|
|
772
|
+
const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));
|
|
773
|
+
const ch = (e & f) ^ (~e & g);
|
|
774
|
+
const temp1 = (h + S1 + ch + K[j] + w[j]) >>> 0;
|
|
775
|
+
const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));
|
|
776
|
+
const maj = (a & b) ^ (a & c) ^ (b & c);
|
|
777
|
+
const temp2 = (S0 + maj) >>> 0;
|
|
778
|
+
h = g;
|
|
779
|
+
g = f;
|
|
780
|
+
f = e;
|
|
781
|
+
e = (d + temp1) >>> 0;
|
|
782
|
+
d = c;
|
|
783
|
+
c = b;
|
|
784
|
+
b = a;
|
|
785
|
+
a = (temp1 + temp2) >>> 0;
|
|
786
|
+
}
|
|
787
|
+
h0 = (h0 + a) >>> 0;
|
|
788
|
+
h1 = (h1 + b) >>> 0;
|
|
789
|
+
h2 = (h2 + c) >>> 0;
|
|
790
|
+
h3 = (h3 + d) >>> 0;
|
|
791
|
+
h4 = (h4 + e) >>> 0;
|
|
792
|
+
h5 = (h5 + f) >>> 0;
|
|
793
|
+
h6 = (h6 + g) >>> 0;
|
|
794
|
+
h7 = (h7 + h) >>> 0;
|
|
795
|
+
}
|
|
796
|
+
const result = new ArrayBuffer(hashSize);
|
|
797
|
+
const resultView = new DataView(result);
|
|
798
|
+
resultView.setUint32(0, h0);
|
|
799
|
+
resultView.setUint32(4, h1);
|
|
800
|
+
resultView.setUint32(8, h2);
|
|
801
|
+
resultView.setUint32(12, h3);
|
|
802
|
+
resultView.setUint32(16, h4);
|
|
803
|
+
resultView.setUint32(20, h5);
|
|
804
|
+
resultView.setUint32(24, h6);
|
|
805
|
+
resultView.setUint32(28, h7);
|
|
806
|
+
return result;
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
class NexusRemote {
|
|
810
|
+
async invoke(options) {
|
|
811
|
+
if (!options || typeof options !== "object") {
|
|
812
|
+
throw new BridgeAPIError('Parameter "options" must be an object in "remote.invoke".');
|
|
813
|
+
}
|
|
814
|
+
if (typeof options.path !== "string" || options.path.trim().length === 0) {
|
|
815
|
+
throw new BridgeAPIError('Parameter "path" is required and cannot be empty in "remote.invoke" options.');
|
|
816
|
+
}
|
|
817
|
+
const payload = await buildPayloadByRequestInit(options);
|
|
818
|
+
const { status, headers, body } = await NexusBridge.call("remoteInvoke", payload);
|
|
819
|
+
return parseToResponseData({ status, headers, body });
|
|
820
|
+
}
|
|
821
|
+
async request(remoteKey, options) {
|
|
822
|
+
if (typeof remoteKey !== "string" || remoteKey.trim().length === 0) {
|
|
823
|
+
throw new BridgeAPIError('Parameter "remoteKey" is required and cannot be empty in "remote.request".');
|
|
824
|
+
}
|
|
825
|
+
if (options !== undefined && (!options || typeof options !== "object")) {
|
|
826
|
+
throw new BridgeAPIError('Parameter "options" must be an object in "remote.request".');
|
|
827
|
+
}
|
|
828
|
+
const requestOptions = {
|
|
829
|
+
path: "",
|
|
830
|
+
...validateFetchOptions(options),
|
|
831
|
+
};
|
|
832
|
+
const { path } = requestOptions;
|
|
833
|
+
if (options !== undefined && (typeof path !== "string" || path.trim().length === 0)) {
|
|
834
|
+
throw new BridgeAPIError('Parameter "path" is required and cannot be empty in "remote.request" options.');
|
|
835
|
+
}
|
|
836
|
+
const payload = await buildRemoteRequestPayload(remoteKey, requestOptions);
|
|
837
|
+
const response = await NexusBridge.call("remoteRequest", payload);
|
|
838
|
+
return parseRemoteResponseData(response);
|
|
507
839
|
}
|
|
508
840
|
}
|
|
509
|
-
const
|
|
841
|
+
const remote = new NexusRemote();
|
|
510
842
|
|
|
511
843
|
/**
|
|
512
844
|
* Generated bundle index. Do not edit.
|
|
513
845
|
*/
|
|
514
846
|
|
|
515
|
-
export { api, dialog, events, i18n, invoke, router, store, view, BridgeAPIError as ɵBridgeAPIError, NexusBridge as ɵNexusBridge };
|
|
847
|
+
export { api, dialog, events, i18n, invoke, remote, router, store, view, BridgeAPIError as ɵBridgeAPIError, NexusBridge as ɵNexusBridge };
|
|
516
848
|
//# sourceMappingURL=pc-nexus-bridge.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pc-nexus-bridge.mjs","sources":["../../../../web/bridge/src/window.ts","../../../../web/bridge/src/bridge.ts","../../../../web/bridge/src/error.ts","../../../../web/bridge/src/dialog.ts","../../../../web/bridge/src/invoke.ts","../../../../web/bridge/src/router.ts","../../../../web/bridge/src/view.ts","../../../../web/bridge/src/utils/blob-parser.ts","../../../../web/bridge/src/events.ts","../../../../web/bridge/src/i18n.ts","../../../../web/bridge/src/utils/request.ts","../../../../web/bridge/src/api.ts","../../../../web/bridge/src/store.ts","../../../../web/bridge/src/pc-nexus-bridge.ts"],"sourcesContent":["export type SafeAny = any;\n\nexport function attachObjectToWindow<T>(key: string, value: T) {\n (window as SafeAny)[key] = value;\n}\n\nexport function getObjectFromWindow<T>(key: string) {\n return (window as SafeAny)[key];\n}\n","import { getObjectFromWindow } from \"./window\";\n\ninterface HostMessageEvent<T = unknown> {\n source: Window | null;\n origin: string;\n data: T;\n}\n\ninterface Cancelable {\n cancel: () => void;\n}\n\ninterface GlobalBridge {\n call<T>(name: string, payload?: object | undefined): Promise<T>;\n on<T>(name: string, handler: (event: HostMessageEvent<T>) => void): Cancelable;\n}\n\nfunction getBridge() {\n const bridge = getObjectFromWindow<GlobalBridge>(\"__pc_nexus_bridge__\");\n return bridge;\n}\n\nexport class NexusBridge {\n static getBridgeCall<T>(): (name: string, payload?: object) => Promise<T> {\n if (!getBridge()) {\n throw new Error(`\n Unable to establish a connection with the PingCode nexus bridge.\n If you are trying to run your app locally, Nexus apps only work in the context of PingCode products. Refer to https://developer.pingcode.com for how to tunnel when using a local development server.\n `);\n }\n return getBridge().call;\n }\n\n static async call<T>(name: string, payload?: any): Promise<T> {\n const result = await NexusBridge.getBridgeCall<T>()(name, payload);\n return result as T;\n }\n\n /**\n * 订阅宿主 host 发来的消息。\n * @param name 消息名称\n * @param handler 收到消息时的回调,event 包含 source、origin、data\n * @returns 返回带 cancel() 的对象,调用可取消订阅\n */\n static on<T>(name: string, handler: (event: HostMessageEvent<T>) => void): Cancelable {\n const bridge = getBridge();\n if (!bridge) {\n throw new Error(`\n Unable to establish a connection with the PingCode nexus bridge.\n If you are trying to run your app locally, Nexus apps only work in the context of PingCode products. Refer to https://developer.pingcode.com for how to tunnel when using a local development server.\n `);\n }\n return bridge.on(name, handler);\n }\n}\n","export class BridgeAPIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BridgeAPIError\";\n Object.setPrototypeOf(this, BridgeAPIError.prototype);\n }\n}\n\n// 自动注册:所有未 catch 的 Promise rejection 均以 \"Uncaught (in promise)\" 格式输出,无需用户配置\nif (typeof window !== \"undefined\") {\n window.addEventListener(\n \"unhandledrejection\",\n (event: PromiseRejectionEvent) => {\n const reason = event.reason;\n const error = reason instanceof Error ? reason : new Error(String(reason));\n const firstLine = `Uncaught (in promise) ${error.name}: ${error.message}`;\n const stack = error.stack?.replace(/^[^\\n]*\\n?/, \"\").trim() || \"\";\n console.error(stack ? `${firstLine}\\n${stack}` : firstLine);\n event.preventDefault();\n event.stopImmediatePropagation();\n },\n true,\n );\n}\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { DialogConfirmOptions, DialogOptions, DialogRef } from \"./models\";\n\nfunction validateOpenOptions(options: DialogOptions) {\n if (typeof options !== \"object\" || options === null) {\n throw new BridgeAPIError('\"options\" must be an object in dialog open.');\n }\n if (!options.resource) {\n throw new BridgeAPIError('\"resource\" is required in dialog open options.');\n }\n}\n\nfunction validateConfirmOptions(options: DialogConfirmOptions) {\n if (typeof options !== \"object\" || options === null) {\n throw new BridgeAPIError('\"options\" must be an object in dialog confirm.');\n }\n if (!options.content) {\n throw new BridgeAPIError('\"content\" is required in dialog confirm options.');\n }\n if (typeof options.onConfirm !== \"function\") {\n throw new BridgeAPIError('\"onConfirm\" must be a function in dialog confirm options.');\n }\n}\n\nclass NexusDialog {\n async open<T>(options: DialogOptions): Promise<DialogRef<T>> {\n validateOpenOptions(options);\n return await NexusBridge.call<DialogRef<T>>(\"openDialog\", options);\n }\n\n async confirm<T>(options: DialogConfirmOptions): Promise<void> {\n validateConfirmOptions(options);\n return await NexusBridge.call<void>(\"confirm\", options);\n }\n}\n\nexport const dialog = new NexusDialog();\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { InvokeFunctionParams } from \"./models\";\nimport { getObjectFromWindow } from \"./window\";\n\nfunction validatePayload<TPayload>(payload?: TPayload) {\n if (!payload) {\n return;\n }\n if (Object.values(payload).some((value) => typeof value === \"function\")) {\n throw new BridgeAPIError(\"Passing functions as part of the payload in invoke is not supported.\");\n }\n}\n\nexport async function invoke<TPayload = any, TResult = any>(functionKey: string, payload?: TPayload): Promise<TResult> {\n if (typeof functionKey !== \"string\") {\n throw new BridgeAPIError('\"functionKey\" must be a string in invoke.');\n }\n validatePayload(payload);\n\n const params: InvokeFunctionParams = {\n function: functionKey,\n payload: payload,\n tunnel_token: getObjectFromWindow(\"__TUNNEL_TOKEN__\"),\n } as InvokeFunctionParams;\n const result = await NexusBridge.call(\"invokeFunction\", params);\n return result as TResult;\n}\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { NavigationLocation } from \"./models\";\n\nclass NexusRouter {\n async navigate(urlOrLocation: string | NavigationLocation): Promise<void> {\n if (typeof urlOrLocation === \"string\") {\n await NexusBridge.call<void>(\"routerNavigate\", { urlOrLocation });\n } else {\n if (!urlOrLocation.target) {\n const errorMessage = '\"target\" is required in router navigate.';\n throw new BridgeAPIError(errorMessage);\n }\n await NexusBridge.call<void>(\"routerNavigate\", { urlOrLocation });\n }\n }\n\n async open(urlOrLocation: string | NavigationLocation): Promise<void> {\n if (typeof urlOrLocation === \"string\") {\n await NexusBridge.call<void>(\"routerOpen\", { urlOrLocation });\n } else {\n if (!urlOrLocation.target) {\n const errorMessage = '\"target\" is required in router open.';\n throw new BridgeAPIError(errorMessage);\n }\n await NexusBridge.call<void>(\"routerOpen\", { urlOrLocation });\n }\n }\n\n async generateUrl(location: NavigationLocation): Promise<URL> {\n if (!(location === null || location === void 0 ? void 0 : location.target)) {\n const errorMessage = '\"target\" is required in router generateUrl.';\n throw new BridgeAPIError(errorMessage);\n }\n return await NexusBridge.call<URL>(\"routerGenerateUrl\", { location });\n }\n\n async reload(): Promise<void> {\n await NexusBridge.call<void>(\"routerReload\", {});\n }\n}\n\nexport const router = new NexusRouter();\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { ExtensionData, NexusFullContext, NexusHistory } from \"./models\";\n\nclass NexusView {\n async getContext<T = ExtensionData>(): Promise<NexusFullContext<T>> {\n return await NexusBridge.call(\"getContext\");\n }\n\n async setWindowTitle(title: string): Promise<void> {\n if (!title) {\n throw new BridgeAPIError('\"title\" is required in view setWindowTitle.');\n }\n if (typeof title !== \"string\") {\n throw new BridgeAPIError('\"title\" must be a string in view setWindowTitle.');\n }\n\n await NexusBridge.call<void>(\"setWindowTitle\", { title });\n }\n\n async reload(): Promise<void> {\n const success = await NexusBridge.call<boolean>(\"viewReload\");\n if (success === false) {\n throw new BridgeAPIError(\"this resource's view is not reloadable.\");\n }\n }\n\n async close(payload?: unknown): Promise<void> {\n const success = await NexusBridge.call<boolean>(\"viewClose\", payload);\n if (!success) {\n const errorMessage = \"this resource's view is not closable.\";\n throw new BridgeAPIError(errorMessage);\n }\n }\n\n /**\n * 非弹窗场景调用无效。\n */\n async onClose(payload: () => Promise<void>): Promise<void> {\n if (typeof payload !== \"function\") {\n const errorMessage = '\"payload\" must be a function in view onClose.';\n throw new BridgeAPIError(errorMessage);\n }\n const success = await NexusBridge.call<boolean>(\"viewOnClose\", { payload });\n if (!success) {\n throw new BridgeAPIError(\"`onClose` failed because this resource's view is not closable.\");\n }\n }\n\n async isDialog(): Promise<boolean> {\n return await NexusBridge.call<boolean>(\"viewIsDialog\");\n }\n\n async createHistory(): Promise<NexusHistory> {\n const history = await NexusBridge.call<NexusHistory>(\"createHistory\");\n await history.listen((location, action) => {\n history.action = action;\n history.location = location;\n });\n return history;\n }\n\n async submit<T = any>(payload?: T): Promise<boolean> {\n const result = await NexusBridge.call<boolean>(\"viewSubmit\", payload);\n if (!result) {\n throw new BridgeAPIError(\"this resource's view is not submittable.\");\n }\n return result;\n }\n}\n\nexport const view = new NexusView();\n","const isPlainObject = (value: any) => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n if (Object.prototype.toString.call(value) !== \"[object Object]\") {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n if (proto === null) {\n return true;\n }\n const constructor = Object.prototype.hasOwnProperty.call(proto, \"constructor\") && proto.constructor;\n return (\n typeof constructor === \"function\" &&\n constructor instanceof constructor &&\n Function.prototype.call(constructor) === Function.prototype.call(value)\n );\n};\n\nconst base64ToBlob = (b64string: string, mimeType: string) => {\n if (!b64string) {\n return null;\n }\n const base64String = b64string.includes(\",\") ? b64string.split(\",\")[1] : b64string;\n const byteCharacters = atob(base64String);\n const byteNumbers = new Array(byteCharacters.length);\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i);\n }\n\n const byteArray = new Uint8Array(byteNumbers);\n return new Blob([byteArray], { type: mimeType });\n};\n\nconst blobToBase64 = (blob: Blob) => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n resolve(reader.result);\n };\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n};\n\nexport const serialiseBlobsInPayload = async (payload: any): Promise<any> => {\n if (payload instanceof Blob) {\n const base64Data = await blobToBase64(payload);\n return {\n data: base64Data,\n type: payload.type,\n __isBlobData: true,\n };\n }\n if (Array.isArray(payload)) {\n return Promise.all(payload.map((item) => serialiseBlobsInPayload(item)));\n }\n if (payload && isPlainObject(payload)) {\n const entries = await Promise.all(Object.entries(payload).map(async ([key, value]) => [key, await serialiseBlobsInPayload(value)]));\n return Object.fromEntries(entries);\n }\n return payload;\n};\n\nexport const deserialiseBlobsInPayload = (payload: any): any => {\n if (payload && isPlainObject(payload) && \"__isBlobData\" in payload) {\n const typedData = payload;\n return base64ToBlob(typedData.data, typedData.type);\n }\n if (Array.isArray(payload)) {\n return payload.map((item) => deserialiseBlobsInPayload(item));\n }\n if (payload && isPlainObject(payload)) {\n const result = {};\n for (const [key, value] of Object.entries(payload)) {\n (result as any)[key] = deserialiseBlobsInPayload(value);\n }\n return result;\n }\n return payload;\n};\n\nexport const containsBlobs = (payload: any): boolean => {\n if (payload instanceof Blob) {\n return true;\n }\n if (Array.isArray(payload)) {\n return payload.some((item) => containsBlobs(item));\n }\n if (payload && isPlainObject(payload)) {\n return Object.values(payload).some((value) => containsBlobs(value));\n }\n return false;\n};\n\nexport const containsSerialisedBlobs = (payload: any): boolean => {\n if (payload && isPlainObject(payload) && \"__isBlobData\" in payload) {\n return true;\n }\n if (Array.isArray(payload)) {\n return payload.some((item) => containsSerialisedBlobs(item));\n }\n if (payload && isPlainObject(payload)) {\n return Object.values(payload).some((value) => containsSerialisedBlobs(value));\n }\n return false;\n};\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { Subscription } from \"./models\";\nimport { containsBlobs, serialiseBlobsInPayload, containsSerialisedBlobs, deserialiseBlobsInPayload } from \"./utils\";\n\nfunction validateOnPayload<T>(eventName: string, callback: (payload?: T) => any) {\n if (!eventName) {\n throw new BridgeAPIError('\"eventName\" is required in events on.');\n }\n if (typeof eventName !== \"string\") {\n throw new BridgeAPIError('\"eventName\" must be a string in events on.');\n }\n if (!callback) {\n throw new BridgeAPIError('\"callback\" is required in events on.');\n }\n if (typeof callback !== \"function\") {\n throw new BridgeAPIError('\"callback\" must be a function in events on.');\n }\n}\n\nfunction validateEmitPayload<T>(eventName: string) {\n if (!eventName) {\n throw new BridgeAPIError('\"eventName\" is required in events emit.');\n }\n if (typeof eventName !== \"string\") {\n throw new BridgeAPIError('\"eventName\" must be a string in events emit.');\n }\n}\n\nasync function on<T = any>(eventName: string, callback: (payload?: T) => any): Promise<Subscription> {\n validateOnPayload<T>(eventName, callback);\n\n const wrappedCallback = (payload: T) => {\n let newPayload = payload;\n if (containsSerialisedBlobs(payload)) {\n newPayload = deserialiseBlobsInPayload(payload);\n }\n return callback(newPayload);\n };\n return NexusBridge.call(\"on\", { eventName, callback: wrappedCallback });\n}\n\nasync function emit<T = any>(eventName: string, payload?: T): Promise<void> {\n validateEmitPayload<T>(eventName);\n\n let newPayload = payload;\n if (containsBlobs(payload)) {\n newPayload = await serialiseBlobsInPayload(payload);\n }\n return NexusBridge.call(\"emit\", { eventName, payload: newPayload });\n}\n\nexport const events = {\n on,\n emit,\n};\n","import { Translator, GetTranslationsResult, NexusSupportedLocaleCode, TranslationResourceContent, SUPPORTED_LOCALE_CODES } from \"./models\";\nimport { view } from \"./view\";\nimport { BridgeAPIError } from \"./error\";\n\nclass NexusI18n {\n private translationsCache: Partial<Record<NexusSupportedLocaleCode, Promise<TranslationResourceContent>>> = {};\n\n private i18nFolderName = \"__LOCALES__\";\n\n async getTranslations(locale?: NexusSupportedLocaleCode): Promise<GetTranslationsResult> {\n if (!locale) {\n locale = (await view.getContext()).user.locale;\n } else {\n if (!SUPPORTED_LOCALE_CODES.includes(locale)) {\n throw new BridgeAPIError(`\"locale\" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(\", \")}.`);\n }\n }\n const translations = await this.loadTranslations(locale!);\n return { locale: locale!, translations };\n }\n\n async createTranslator(locale?: NexusSupportedLocaleCode): Promise<Translator> {\n if (!locale) {\n locale = (await view.getContext()).user.locale;\n } else {\n if (!SUPPORTED_LOCALE_CODES.includes(locale)) {\n throw new BridgeAPIError(`\"locale\" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(\", \")}.`);\n }\n }\n const translations = await this.loadTranslations(locale!);\n return {\n translate: (key: string, params: Record<string, any> = {}) => this.translate(key, translations, params),\n };\n }\n\n private loadTranslations(locale: NexusSupportedLocaleCode): Promise<TranslationResourceContent> {\n const url = `../${this.i18nFolderName}/${locale}.json`;\n if (!this.translationsCache[locale]) {\n this.translationsCache[locale] = fetch(url)\n .then((response) => response.json())\n .catch((error) => {\n // 请求失败要清理缓存\n delete this.translationsCache[locale];\n throw new BridgeAPIError(`Failed to load translations for locale ${locale}, cause: ${error}`);\n });\n }\n\n return this.translationsCache[locale]!;\n }\n\n private getValue(obj: any, path: string): any {\n return path.split(\".\").reduce((o, k) => (o != null && typeof o === \"object\" ? o[k] : undefined), obj);\n }\n\n private translate(\n key: string,\n translations: TranslationResourceContent,\n params?: Record<string, any>,\n ): TranslationResourceContent | string {\n if (!key) {\n throw new BridgeAPIError('\"key\" is required in i18n translate.');\n }\n // 获取值(扁平或嵌套)\n let value: any = translations[key] ?? this.getValue(translations, key);\n\n // key 不存在 → 返回 key\n if (value == null) return key;\n\n // 如果 value 是对象 → 直接返回\n if (typeof value === \"object\") return value;\n\n // 确保 value 是字符串\n if (typeof value !== \"string\") value = String(value);\n\n // 无参数 → 直接返回\n if (!params) return value;\n\n // 参数替换\n return value.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_: string, k: string) => {\n const paramValue = this.getValue(params, k.trim());\n return paramValue != null ? String(paramValue) : `{{${k}}}`;\n });\n }\n}\n\nexport const i18n = new NexusI18n();\n","import { RequestApiResponseData } from \"../models\";\n\nexport async function buildPayloadByRequestInit<TPayload extends RequestInit = RequestInit>(init?: TPayload) {\n const requestBody = init === null || init === void 0 ? void 0 : init.body;\n const requestMethod = init === null || init === void 0 ? void 0 : init.method;\n const requestHeaders = init === null || init === void 0 ? void 0 : init.headers;\n const req = new Request(\"\", {\n body: requestBody,\n method: requestMethod,\n headers: requestHeaders,\n });\n const headers = Object.fromEntries(req.headers.entries());\n const body = req.method !== \"GET\" ? await req.text() : undefined;\n return {\n ...init,\n body: body,\n headers,\n method: requestMethod ?? \"GET\",\n };\n}\n\nexport async function parseToResponseData(res: RequestApiResponseData): Promise<Response> {\n const response = new Response(\n res.body == null ? undefined : typeof res.body === \"object\" ? JSON.stringify(res.body) : (res.body as BodyInit),\n {\n status: res.status,\n headers: new Headers(res.headers),\n },\n );\n\n return response;\n}\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { NexusRequestInit, RequestApiResponseData } from \"./models\";\nimport { buildPayloadByRequestInit, parseToResponseData } from \"./utils/request\";\n\ninterface RequestApiParams extends NexusRequestInit {\n path: string;\n}\n\nconst validateFetchOptions = (init?: NexusRequestInit) => {\n if (!init) {\n return init;\n }\n if (\"signal\" in init) {\n const { signal: _signal, ...rest } = init;\n console.error(\"Signal is not supported in @pc-nexus/bridge and was removed from fetch options.\");\n return rest;\n }\n return init;\n};\n\nasync function callRequestBridge<TPayload extends NexusRequestInit = NexusRequestInit>(\n handlerName: string,\n payload: TPayload,\n): Promise<Response> {\n const postPayload = await buildPayloadByRequestInit<TPayload>(payload);\n const { status, headers, body } = await NexusBridge.call<RequestApiResponseData>(handlerName, postPayload);\n return parseToResponseData({ status, headers, body });\n}\n\nclass NexusRestApi {\n async request(path: string, options?: NexusRequestInit): Promise<Response> {\n if (typeof path !== \"string\") {\n throw new BridgeAPIError('\"path\" must be a string in api.request.');\n }\n\n const validatedOptions = validateFetchOptions(options);\n return callRequestBridge<RequestApiParams>(\"apiRequest\", { path, ...validatedOptions });\n }\n}\n\nexport const api = new NexusRestApi();\n","import { invoke } from \"./invoke\";\nimport { DownloadResult, GetMetadataResult, UploadResult } from \"./models\";\n\nclass NexusStore {\n async upload(functionKey: string, objects: Blob[]): Promise<UploadResult[]> {\n const presignedURLsToObjectMetadata = await invoke(functionKey, { objects });\n console.log(functionKey, objects, presignedURLsToObjectMetadata);\n\n return [];\n }\n\n async download(functionKey: string, keys: string[]): Promise<DownloadResult[]> {\n const downloadUrlsTokeys = await invoke(functionKey, { keys });\n console.log(functionKey, keys, downloadUrlsTokeys);\n\n return [];\n }\n\n async getMetaData(functionKey: string, keys: string[]): Promise<GetMetadataResult[]> {\n const result = await invoke(functionKey, { keys });\n console.log(functionKey, keys, result);\n\n return [];\n }\n\n async delete(functionKey: string, keys: string[]): Promise<void> {\n await invoke(functionKey, { keys });\n console.log(functionKey, keys);\n }\n}\n\nexport const store = new NexusStore();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEM,SAAU,oBAAoB,CAAI,GAAW,EAAE,KAAQ,EAAA;AACxD,IAAA,MAAkB,CAAC,GAAG,CAAC,GAAG,KAAK;AACpC;AAEM,SAAU,mBAAmB,CAAI,GAAW,EAAA;AAC9C,IAAA,OAAQ,MAAkB,CAAC,GAAG,CAAC;AACnC;;ACSA,SAAS,SAAS,GAAA;AACd,IAAA,MAAM,MAAM,GAAG,mBAAmB,CAAe,qBAAqB,CAAC;AACvE,IAAA,OAAO,MAAM;AACjB;MAEa,WAAW,CAAA;AACpB,IAAA,OAAO,aAAa,GAAA;AAChB,QAAA,IAAI,CAAC,SAAS,EAAE,EAAE;YACd,MAAM,IAAI,KAAK,CAAC;;;AAGnB,QAAA,CAAA,CAAC;QACF;AACA,QAAA,OAAO,SAAS,EAAE,CAAC,IAAI;IAC3B;AAEA,IAAA,aAAa,IAAI,CAAI,IAAY,EAAE,OAAa,EAAA;AAC5C,QAAA,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC,aAAa,EAAK,CAAC,IAAI,EAAE,OAAO,CAAC;AAClE,QAAA,OAAO,MAAW;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O,iBAAiB,CAAmB,YAAY,EAAE,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAE,CAAC;IAC3F;AACH;AAEM,MAAM,GAAG,GAAG,IAAI,YAAY;;ACtCnC,MAAM,UAAU,CAAA;AACZ,IAAA,MAAM,MAAM,CAAC,WAAmB,EAAE,OAAe,EAAA;QAC7C,MAAM,6BAA6B,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,6BAA6B,CAAC;AAEhE,QAAA,OAAO,EAAE;IACb;AAEA,IAAA,MAAM,QAAQ,CAAC,WAAmB,EAAE,IAAc,EAAA;QAC9C,MAAM,kBAAkB,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC;QAC9D,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,kBAAkB,CAAC;AAElD,QAAA,OAAO,EAAE;IACb;AAEA,IAAA,MAAM,WAAW,CAAC,WAAmB,EAAE,IAAc,EAAA;QACjD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,CAAC;AAEtC,QAAA,OAAO,EAAE;IACb;AAEA,IAAA,MAAM,MAAM,CAAC,WAAmB,EAAE,IAAc,EAAA;QAC5C,MAAM,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,CAAC;AACnC,QAAA,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC;IAClC;AACH;AAEM,MAAM,KAAK,GAAG,IAAI,UAAU;;AC/BnC;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"pc-nexus-bridge.mjs","sources":["../../../../web/bridge/src/window.ts","../../../../web/bridge/src/bridge.ts","../../../../web/bridge/src/error.ts","../../../../web/bridge/src/dialog.ts","../../../../web/bridge/src/invoke.ts","../../../../web/bridge/src/router.ts","../../../../web/bridge/src/view.ts","../../../../web/bridge/src/utils/blob-parser.ts","../../../../web/bridge/src/events.ts","../../../../web/bridge/src/i18n.ts","../../../../web/bridge/src/utils/request.ts","../../../../web/bridge/src/api.ts","../../../../web/bridge/src/store.ts","../../../../web/bridge/src/remote.ts","../../../../web/bridge/src/pc-nexus-bridge.ts"],"sourcesContent":["export type SafeAny = any;\n\nexport function attachObjectToWindow<T>(key: string, value: T) {\n (window as SafeAny)[key] = value;\n}\n\nexport function getObjectFromWindow<T>(key: string) {\n return (window as SafeAny)[key];\n}\n","import { getObjectFromWindow } from \"./window\";\n\ninterface HostMessageEvent<T = unknown> {\n source: Window | null;\n origin: string;\n data: T;\n}\n\ninterface Cancelable {\n cancel: () => void;\n}\n\ninterface GlobalBridge {\n call<T>(name: string, payload?: object | undefined): Promise<T>;\n on<T>(name: string, handler: (event: HostMessageEvent<T>) => void): Cancelable;\n}\n\nfunction getBridge() {\n const bridge = getObjectFromWindow<GlobalBridge>(\"__pc_nexus_bridge__\");\n return bridge;\n}\n\nexport class NexusBridge {\n static getBridgeCall<T>(): (name: string, payload?: object) => Promise<T> {\n if (!getBridge()) {\n throw new Error(`\n Unable to establish a connection with the PingCode nexus bridge.\n If you are trying to run your app locally, Nexus apps only work in the context of PingCode products. Refer to https://developer.pingcode.com for how to tunnel when using a local development server.\n `);\n }\n return getBridge().call;\n }\n\n static async call<T>(name: string, payload?: any): Promise<T> {\n const result = await NexusBridge.getBridgeCall<T>()(name, payload);\n return result as T;\n }\n\n /**\n * 订阅宿主 host 发来的消息。\n * @param name 消息名称\n * @param handler 收到消息时的回调,event 包含 source、origin、data\n * @returns 返回带 cancel() 的对象,调用可取消订阅\n */\n static on<T>(name: string, handler: (event: HostMessageEvent<T>) => void): Cancelable {\n const bridge = getBridge();\n if (!bridge) {\n throw new Error(`\n Unable to establish a connection with the PingCode nexus bridge.\n If you are trying to run your app locally, Nexus apps only work in the context of PingCode products. Refer to https://developer.pingcode.com for how to tunnel when using a local development server.\n `);\n }\n return bridge.on(name, handler);\n }\n}\n","export class BridgeAPIError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"BridgeAPIError\";\n Object.setPrototypeOf(this, BridgeAPIError.prototype);\n }\n}\n\n// 自动注册:所有未 catch 的 Promise rejection 均以 \"Uncaught (in promise)\" 格式输出,无需用户配置\nif (typeof window !== \"undefined\") {\n window.addEventListener(\n \"unhandledrejection\",\n (event: PromiseRejectionEvent) => {\n const reason = event.reason;\n const error = reason instanceof Error ? reason : new Error(String(reason));\n const firstLine = `Uncaught (in promise) ${error.name}: ${error.message}`;\n const stack = error.stack?.replace(/^[^\\n]*\\n?/, \"\").trim() || \"\";\n console.error(stack ? `${firstLine}\\n${stack}` : firstLine);\n event.preventDefault();\n event.stopImmediatePropagation();\n },\n true,\n );\n}\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { DialogConfirmOptions, DialogOpenOptions, DialogRef } from \"./models\";\n\nfunction validateOpenOptions(options: DialogOpenOptions) {\n if (typeof options !== \"object\" || options === null) {\n throw new BridgeAPIError('Parameter \"options\" must be an object in \"dialog.open\".');\n }\n if (!options.resource) {\n throw new BridgeAPIError('Parameter \"resource\" is required in \"dialog.open\" options.');\n }\n}\n\nfunction validateConfirmOptions(options: DialogConfirmOptions) {\n if (typeof options !== \"object\" || options === null) {\n throw new BridgeAPIError('Parameter \"options\" must be an object in \"dialog.confirm\".');\n }\n if (!options.content) {\n throw new BridgeAPIError('Parameter \"content\" is required in \"dialog.confirm\" options.');\n }\n if (typeof options.onConfirm !== \"function\") {\n throw new BridgeAPIError('Parameter \"onConfirm\" must be a function in \"dialog.confirm\" options.');\n }\n}\n\nclass NexusDialog {\n async open<T>(options: DialogOpenOptions): Promise<DialogRef<T>> {\n validateOpenOptions(options);\n return await NexusBridge.call<DialogRef<T>>(\"openDialog\", options);\n }\n\n async confirm<T>(options: DialogConfirmOptions): Promise<void> {\n validateConfirmOptions(options);\n return await NexusBridge.call<void>(\"confirm\", options);\n }\n}\n\nexport const dialog = new NexusDialog();\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { InvokeFunctionParams } from \"./models\";\nimport { getObjectFromWindow } from \"./window\";\n\nfunction validatePayload<TPayload>(payload?: TPayload) {\n if (!payload) {\n return;\n }\n if (Object.values(payload).some((value) => typeof value === \"function\")) {\n throw new BridgeAPIError('Parameter \"payload\" must not include functions in \"invoke\".');\n }\n}\n\nexport async function invoke<TPayload = any, TResult = any>(functionKey: string, payload?: TPayload): Promise<TResult> {\n if (typeof functionKey !== \"string\") {\n throw new BridgeAPIError('Parameter \"functionKey\" must be a string in \"invoke\".');\n }\n validatePayload(payload);\n\n const params: InvokeFunctionParams = {\n function: functionKey,\n payload: payload,\n tunnel_token: getObjectFromWindow(\"__TUNNEL_TOKEN__\"),\n } as InvokeFunctionParams;\n const result = await NexusBridge.call(\"invokeFunction\", params);\n return result as TResult;\n}\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { NavigationLocation } from \"./models\";\n\nfunction validateNavigationLocation(location: NavigationLocation, apiName: string): void {\n if (!location?.target) {\n throw new BridgeAPIError(`Parameter \"target\" is required in \"${apiName}\" location.`);\n }\n if (!location?.id) {\n throw new BridgeAPIError(`Parameter \"id\" is required in \"${apiName}\" location.`);\n }\n}\n\nclass NexusRouter {\n async navigate(urlOrLocation: string | NavigationLocation): Promise<void> {\n if (typeof urlOrLocation === \"string\") {\n await NexusBridge.call<void>(\"routerNavigate\", { urlOrLocation });\n } else {\n validateNavigationLocation(urlOrLocation, \"router.navigate\");\n await NexusBridge.call<void>(\"routerNavigate\", { urlOrLocation });\n }\n }\n\n async open(urlOrLocation: string | NavigationLocation): Promise<void> {\n if (typeof urlOrLocation === \"string\") {\n await NexusBridge.call<void>(\"routerOpen\", { urlOrLocation });\n } else {\n validateNavigationLocation(urlOrLocation, \"router.open\");\n await NexusBridge.call<void>(\"routerOpen\", { urlOrLocation });\n }\n }\n\n async generateUrl(location: NavigationLocation): Promise<URL> {\n validateNavigationLocation(location, \"router.generateUrl\");\n const urlString = await NexusBridge.call<string>(\"routerGenerateUrl\", { location });\n return new URL(urlString);\n }\n\n async reload(): Promise<void> {\n await NexusBridge.call<void>(\"routerReload\", {});\n }\n}\n\nexport const router = new NexusRouter();\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { ExtensionData, NexusAppContext, NexusHistory, HistoryUpdate } from \"./models\";\n\nclass NexusView {\n async getContext<T = ExtensionData>(): Promise<NexusAppContext<T>> {\n return await NexusBridge.call(\"getContext\");\n }\n\n async setWindowTitle(title: string): Promise<void> {\n if (!title) {\n throw new BridgeAPIError('Parameter \"title\" is required in \"view.setWindowTitle\".');\n }\n if (typeof title !== \"string\") {\n throw new BridgeAPIError('Parameter \"title\" must be a string in \"view.setWindowTitle\".');\n }\n\n const success = await NexusBridge.call<boolean>(\"setWindowTitle\", { title });\n if (!success) {\n throw new BridgeAPIError('API \"setWindowTitle\" is not available within this module.');\n }\n }\n\n async refresh(): Promise<void> {\n const success = await NexusBridge.call<boolean>(\"viewRefresh\");\n if (success === false) {\n throw new BridgeAPIError(\"This resource's view is not refreshable.\");\n }\n }\n\n async close(payload?: unknown): Promise<void> {\n const success = await NexusBridge.call<boolean>(\"viewClose\", payload);\n if (!success) {\n const errorMessage = \"This resource's view is not closable.\";\n throw new BridgeAPIError(errorMessage);\n }\n }\n\n /**\n * 非弹窗场景调用无效。\n */\n async onClose(payload: () => Promise<void>): Promise<void> {\n if (typeof payload !== \"function\") {\n const errorMessage = 'Parameter \"payload\" must be a function in \"view.onClose\".';\n throw new BridgeAPIError(errorMessage);\n }\n const success = await NexusBridge.call<boolean>(\"viewOnClose\", { payload });\n if (!success) {\n throw new BridgeAPIError(\"This resource's view is not closable.\");\n }\n }\n\n async isDialog(): Promise<boolean> {\n return await NexusBridge.call<boolean>(\"viewIsDialog\");\n }\n\n async createHistory(): Promise<NexusHistory> {\n const history = await NexusBridge.call<NexusHistory>(\"createHistory\");\n if (!history) {\n throw new BridgeAPIError('API \"createHistory\" is not available within this module.');\n }\n await history.listen((update: HistoryUpdate) => {\n history.action = update.action;\n history.location = update.location;\n });\n return history;\n }\n\n async submit<T = any>(payload?: T): Promise<boolean> {\n const result = await NexusBridge.call<boolean>(\"viewSubmit\", payload);\n if (!result) {\n throw new BridgeAPIError(\"This resource's view is not submittable.\");\n }\n return result;\n }\n}\n\nexport const view = new NexusView();\n","const isPlainObject = (value: any) => {\n if (typeof value !== \"object\" || value === null) {\n return false;\n }\n if (Object.prototype.toString.call(value) !== \"[object Object]\") {\n return false;\n }\n const proto = Object.getPrototypeOf(value);\n if (proto === null) {\n return true;\n }\n const constructor = Object.prototype.hasOwnProperty.call(proto, \"constructor\") && proto.constructor;\n return (\n typeof constructor === \"function\" &&\n constructor instanceof constructor &&\n Function.prototype.call(constructor) === Function.prototype.call(value)\n );\n};\n\nexport const base64ToBlob = (b64string: string, mimeType: string) => {\n if (!b64string) {\n return null;\n }\n const base64String = b64string.includes(\",\") ? b64string.split(\",\")[1] : b64string;\n const byteCharacters = atob(base64String);\n const byteNumbers = new Array(byteCharacters.length);\n for (let i = 0; i < byteCharacters.length; i++) {\n byteNumbers[i] = byteCharacters.charCodeAt(i);\n }\n\n const byteArray = new Uint8Array(byteNumbers);\n return new Blob([byteArray], { type: mimeType });\n};\n\nexport const blobToBase64 = (blob: Blob): Promise<string> => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n resolve(reader.result as string);\n };\n reader.onerror = reject;\n reader.readAsDataURL(blob);\n });\n};\n\nexport const blobToArrayBuffer = (blob: Blob): Promise<ArrayBuffer> => {\n return new Promise((resolve, reject) => {\n const reader = new FileReader();\n reader.onloadend = () => {\n resolve(reader.result as ArrayBuffer);\n };\n reader.onerror = reject;\n reader.readAsArrayBuffer(blob);\n });\n};\n\nexport const serialiseBlobsInPayload = async (payload: any): Promise<any> => {\n if (payload instanceof Blob) {\n const base64Data = await blobToBase64(payload);\n return {\n data: base64Data,\n type: payload.type,\n name: payload instanceof File ? payload.name : undefined,\n __isBlobData: true,\n };\n }\n if (Array.isArray(payload)) {\n return Promise.all(payload.map((item) => serialiseBlobsInPayload(item)));\n }\n if (payload && isPlainObject(payload)) {\n const entries = await Promise.all(Object.entries(payload).map(async ([key, value]) => [key, await serialiseBlobsInPayload(value)]));\n return Object.fromEntries(entries);\n }\n return payload;\n};\n\nexport const deserialiseBlobsInPayload = (payload: any): any => {\n if (payload && isPlainObject(payload) && \"__isBlobData\" in payload) {\n const typedData = payload;\n return base64ToBlob(typedData.data, typedData.type);\n }\n if (Array.isArray(payload)) {\n return payload.map((item) => deserialiseBlobsInPayload(item));\n }\n if (payload && isPlainObject(payload)) {\n const result = {};\n for (const [key, value] of Object.entries(payload)) {\n (result as any)[key] = deserialiseBlobsInPayload(value);\n }\n return result;\n }\n return payload;\n};\n\nexport const containsBlobs = (payload: any): boolean => {\n if (payload instanceof Blob) {\n return true;\n }\n if (Array.isArray(payload)) {\n return payload.some((item) => containsBlobs(item));\n }\n if (payload && isPlainObject(payload)) {\n return Object.values(payload).some((value) => containsBlobs(value));\n }\n return false;\n};\n\nexport const containsSerialisedBlobs = (payload: any): boolean => {\n if (payload && isPlainObject(payload) && \"__isBlobData\" in payload) {\n return true;\n }\n if (Array.isArray(payload)) {\n return payload.some((item) => containsSerialisedBlobs(item));\n }\n if (payload && isPlainObject(payload)) {\n return Object.values(payload).some((value) => containsSerialisedBlobs(value));\n }\n return false;\n};\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { Subscription } from \"./models\";\nimport { containsBlobs, serialiseBlobsInPayload, containsSerialisedBlobs, deserialiseBlobsInPayload } from \"./utils\";\n\nfunction validateOnPayload<T>(eventName: string, callback: (payload?: T) => any) {\n if (!eventName) {\n throw new BridgeAPIError('Parameter \"eventName\" is required in \"events.on\".');\n }\n if (typeof eventName !== \"string\") {\n throw new BridgeAPIError('Parameter \"eventName\" must be a string in \"events.on\".');\n }\n if (!callback) {\n throw new BridgeAPIError('Parameter \"callback\" is required in \"events.on\".');\n }\n if (typeof callback !== \"function\") {\n throw new BridgeAPIError('Parameter \"callback\" must be a function in \"events.on\".');\n }\n}\n\nfunction validateEmitPayload<T>(eventName: string) {\n if (!eventName) {\n throw new BridgeAPIError('Parameter \"eventName\" is required in \"events.emit\".');\n }\n if (typeof eventName !== \"string\") {\n throw new BridgeAPIError('Parameter \"eventName\" must be a string in \"events.emit\".');\n }\n}\n\nasync function on<T = any>(eventName: string, callback: (payload?: T) => any): Promise<Subscription> {\n validateOnPayload<T>(eventName, callback);\n\n const wrappedCallback = (payload: T) => {\n let newPayload = payload;\n if (containsSerialisedBlobs(payload)) {\n newPayload = deserialiseBlobsInPayload(payload);\n }\n return callback(newPayload);\n };\n return NexusBridge.call(\"on\", { eventName, callback: wrappedCallback });\n}\n\nasync function emit<T = any>(eventName: string, payload?: T): Promise<void> {\n validateEmitPayload<T>(eventName);\n\n let newPayload = payload;\n if (containsBlobs(payload)) {\n newPayload = await serialiseBlobsInPayload(payload);\n }\n return NexusBridge.call(\"emit\", { eventName, payload: newPayload });\n}\n\nexport const events = {\n on,\n emit,\n};\n","import { Translator, GetTranslationsResult, SupportedLocaleCode, TranslationsResourceContent, SUPPORTED_LOCALE_CODES } from \"./models\";\nimport { view } from \"./view\";\nimport { BridgeAPIError } from \"./error\";\n\nclass NexusI18n {\n private translationsCache: Partial<Record<SupportedLocaleCode, Promise<TranslationsResourceContent>>> = {};\n\n private i18nFolderName = \"__LOCALES__\";\n\n async getTranslations(locale?: SupportedLocaleCode): Promise<GetTranslationsResult> {\n if (!locale) {\n locale = (await view.getContext()).user.locale;\n } else {\n if (!SUPPORTED_LOCALE_CODES.includes(locale)) {\n throw new BridgeAPIError(\n `Parameter \"locale\" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(\", \")} in \"i18n.getTranslations\".`,\n );\n }\n }\n const translations = await this.loadTranslations(locale!);\n return { locale: locale!, translations };\n }\n\n async createTranslator(locale?: SupportedLocaleCode): Promise<Translator> {\n if (!locale) {\n locale = (await view.getContext()).user.locale;\n } else {\n if (!SUPPORTED_LOCALE_CODES.includes(locale)) {\n throw new BridgeAPIError(\n `Parameter \"locale\" must be a valid locale code, supported codes: ${SUPPORTED_LOCALE_CODES.join(\", \")} in \"i18n.createTranslator\".`,\n );\n }\n }\n const translations = await this.loadTranslations(locale!);\n return {\n translate: (key: string, params: Record<string, any> = {}) => this.translate(key, translations, params),\n };\n }\n\n private loadTranslations(locale: SupportedLocaleCode): Promise<TranslationsResourceContent> {\n const url = `../${this.i18nFolderName}/${locale}.json`;\n if (!this.translationsCache[locale]) {\n this.translationsCache[locale] = fetch(url)\n .then((response) => {\n if (!response.ok) {\n throw new BridgeAPIError(\n `Failed to load translations for locale ${locale}. HTTP ${response.status}: ${response.statusText}`,\n );\n }\n return response.json();\n })\n .catch((error) => {\n // 请求失败要清理缓存\n delete this.translationsCache[locale];\n if (error instanceof BridgeAPIError) {\n throw error;\n } else {\n throw new BridgeAPIError(`Failed to load translations for locale ${locale}. ${error}`);\n }\n });\n }\n\n return this.translationsCache[locale]!;\n }\n\n private getValue(obj: any, path: string): any {\n return path.split(\".\").reduce((o, k) => (o != null && typeof o === \"object\" ? o[k] : undefined), obj);\n }\n\n private translate(\n key: string,\n translations: TranslationsResourceContent,\n params?: Record<string, any>,\n ): TranslationsResourceContent | string {\n if (!key) {\n throw new BridgeAPIError('Parameter \"key\" is required in \"i18n.translate\".');\n }\n // 获取值(扁平或嵌套)\n let value: any = translations[key] ?? this.getValue(translations, key);\n\n // key 不存在 → 返回 key\n if (value == null) return key;\n\n // 如果 value 是对象 → 直接返回\n if (typeof value === \"object\") return value;\n\n // 确保 value 是字符串\n if (typeof value !== \"string\") value = String(value);\n\n // 无参数 → 直接返回\n if (!params) return value;\n\n // 参数替换\n return value.replace(/\\{\\{\\s*(.*?)\\s*\\}\\}/g, (_: string, k: string) => {\n const paramValue = this.getValue(params, k.trim());\n return paramValue != null ? String(paramValue) : `{{${k}}}`;\n });\n }\n}\n\nexport const i18n = new NexusI18n();\n","import {\n RemoteRequestOptions,\n RemoteRequestPayload,\n RemoteRequestResponseData,\n RemoteSerializedFormDataEntry,\n InvokeResponseData,\n ApiInvokeOptions,\n} from \"../models\";\nimport { base64ToBlob, blobToArrayBuffer, serialiseBlobsInPayload } from \"./blob-parser\";\n\nexport const validateFetchOptions = (init?: ApiInvokeOptions) => {\n if (!init) {\n return init;\n }\n if (\"signal\" in init) {\n const { signal: _signal, ...rest } = init;\n console.error(\"Signal is not supported in @pc-nexus/bridge and was removed from fetch options.\");\n return rest;\n }\n return init;\n};\n\nexport async function buildPayloadByRequestInit<TPayload extends RequestInit = RequestInit>(init?: TPayload) {\n const requestBody = init === null || init === void 0 ? void 0 : init.body;\n const requestMethod = init === null || init === void 0 ? void 0 : init.method;\n const requestHeaders = init === null || init === void 0 ? void 0 : init.headers;\n const req = new Request(\"\", {\n body: requestBody,\n method: requestMethod,\n headers: requestHeaders,\n });\n const headers = Object.fromEntries(req.headers.entries());\n const body = req.method !== \"GET\" ? await req.text() : undefined;\n return {\n ...init,\n body: body,\n headers,\n method: requestMethod ?? \"GET\",\n };\n}\n\nexport async function parseToResponseData(res: InvokeResponseData): Promise<Response> {\n const response = new Response(\n res.body == null ? undefined : typeof res.body === \"object\" ? JSON.stringify(res.body) : (res.body as BodyInit),\n {\n status: res.status,\n headers: new Headers(res.headers),\n },\n );\n\n return response;\n}\n\nasync function parseFormData(formData: FormData): Promise<RemoteSerializedFormDataEntry[]> {\n const entries: RemoteSerializedFormDataEntry[] = [];\n for (const [name, value] of formData.entries()) {\n entries.push({\n name,\n value: typeof value === \"string\" ? value : await serialiseBlobsInPayload(value),\n });\n }\n return entries;\n}\n\nexport async function buildRemoteRequestPayload(remoteKey: string, options: RemoteRequestOptions): Promise<RemoteRequestPayload> {\n const { path = \"\", ...requestOptions } = options;\n const isMultipartFormData = requestOptions.body instanceof FormData;\n const request = new Request(\"\", {\n body: requestOptions.body,\n method: requestOptions.method,\n headers: requestOptions.headers,\n });\n const headers = Object.fromEntries(request.headers.entries());\n let body: RemoteRequestPayload[\"requestInit\"][\"body\"];\n if (isMultipartFormData) {\n body = await parseFormData(requestOptions.body as FormData);\n } else if (request.method !== \"GET\") {\n body = await request.text();\n }\n\n return {\n remoteKey,\n path,\n isMultipartFormData,\n requestInit: {\n ...requestOptions,\n body,\n method: requestOptions.method ?? \"GET\",\n headers,\n },\n };\n}\n\nexport async function parseRemoteResponseData(res: RemoteRequestResponseData): Promise<Response> {\n const headers = new Headers(res.headers);\n const blob = res.isBinaryContent && res.body ? base64ToBlob(res.body, headers.get(\"content-type\") ?? \"\") : undefined;\n const responseBody = blob ? await blobToArrayBuffer(blob) : res.body;\n\n return new Response((responseBody as BodyInit) ?? null, {\n status: res.status,\n statusText: res.statusText,\n headers,\n });\n}\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { InvokeResponseData, ApiInvokeOptions } from \"./models\";\nimport { buildPayloadByRequestInit, parseToResponseData, validateFetchOptions } from \"./utils/request\";\n\ninterface InvokeApiParams extends ApiInvokeOptions {\n path: string;\n}\n\nasync function callInvokeBridge<TPayload extends ApiInvokeOptions = ApiInvokeOptions>(\n handlerName: string,\n payload: TPayload,\n): Promise<Response> {\n const postPayload = await buildPayloadByRequestInit<TPayload>(payload);\n const { status, headers, body } = await NexusBridge.call<InvokeResponseData>(handlerName, postPayload);\n return parseToResponseData({ status, headers, body });\n}\n\nclass NexusRestApi {\n async invoke(path: string, options?: ApiInvokeOptions): Promise<Response> {\n if (typeof path !== \"string\") {\n throw new BridgeAPIError('Parameter \"path\" must be a string in \"api.invoke\".');\n }\n\n const validatedOptions = validateFetchOptions(options);\n return callInvokeBridge<InvokeApiParams>(\"apiInvoke\", { path, ...validatedOptions });\n }\n}\n\nexport const api = new NexusRestApi();\n","import { BridgeAPIError } from \"./error\";\nimport { invoke } from \"./invoke\";\nimport { DownloadResult, GetMetadataResult, UploadResult } from \"./models\";\n\ntype UploadInput = File | Blob;\n\ninterface GeneratedMetadata {\n size: number;\n checksum: string;\n checksum_type: \"SHA1\" | \"SHA256\" | \"CRC32\" | \"CRC32C\";\n}\n\ninterface FileMetadata extends GeneratedMetadata {\n key: string;\n overwrite?: boolean;\n}\n\ntype PresignedURLMapping = Record<string, FileMetadata>;\n\nasync function buildObjectMetadata(file: UploadInput): Promise<GeneratedMetadata> {\n const size = file.size;\n const arrayBuffer = await file.arrayBuffer();\n let checksum: string;\n const checksum_type = \"SHA256\";\n\n // crypto.subtle 只能在安全上下文(HTTPS 或 localhost)中使用\n // sha256 兼容模拟器非安全上下文\n if (typeof crypto !== \"undefined\" && crypto.subtle) {\n const hashBuffer = await crypto.subtle.digest(\"SHA-256\", arrayBuffer);\n const hashArray = new Uint8Array(hashBuffer);\n checksum = btoa(String.fromCharCode(...hashArray));\n } else {\n const jsHash = await sha256(arrayBuffer);\n checksum = btoa(String.fromCharCode(...new Uint8Array(jsHash)));\n }\n\n return {\n size,\n checksum,\n checksum_type,\n };\n}\n\nfunction buildChecksumToFileMap(files: UploadInput[], metadata: GeneratedMetadata[]) {\n const map = new Map<string, { file: UploadInput; index: number }>();\n\n files.forEach((file, index) => {\n map.set(metadata[index].checksum, {\n file,\n index,\n });\n });\n\n return map;\n}\n\nfunction uploadFile(url: string, file: UploadInput, key: string) {\n const formData = new FormData();\n const fileName = (file as File).name || key;\n formData.append(\"file\", file, fileName);\n\n return fetch(url, {\n method: \"PUT\",\n body: formData,\n })\n .then((response) => ({\n success: response.ok,\n key,\n status: response.status,\n error: response.ok ? undefined : `Upload failed with status ${response.status}`,\n }))\n .catch((error) => ({\n success: false,\n key,\n status: 503,\n error: error instanceof Error ? error.message : \"Upload failed\",\n }));\n}\n\nclass NexusObjectStore {\n async upload(functionKey: string, objects: UploadInput[]): Promise<UploadResult[]> {\n if (!functionKey || functionKey.length === 0) {\n throw new BridgeAPIError('Parameter \"functionKey\" is required in \"store.upload\".');\n }\n if (!Array.isArray(objects) || objects.length === 0) {\n throw new BridgeAPIError('Parameter \"objects\" is required and cannot be empty in \"store.upload\".');\n }\n\n const files = objects.map((obj, index) => {\n if (obj instanceof File || obj instanceof Blob) return obj;\n throw new BridgeAPIError(`Parameter \"objects\" at index ${index} must be a Blob or File in \"store.upload\".`);\n });\n\n const allObjectMetadata: GeneratedMetadata[] = await Promise.all(files.map((file) => buildObjectMetadata(file)));\n\n const presignedURLsToObjectMetadata: PresignedURLMapping = await invoke(functionKey, allObjectMetadata);\n\n if (!presignedURLsToObjectMetadata || typeof presignedURLsToObjectMetadata !== \"object\") {\n throw new BridgeAPIError('Failed to get a valid response from \"invoke\".');\n }\n\n const checksumMap: Map<string, { file: UploadInput; index: number }> = buildChecksumToFileMap(files, allObjectMetadata);\n\n const uploadPromises = Object.entries(presignedURLsToObjectMetadata).map(([presignedUrl, { key, checksum }]) => {\n const fileInfo = checksumMap.get(checksum);\n\n if (!fileInfo) {\n return {\n promise: Promise.resolve({\n success: false,\n key,\n error: `File not found for checksum ${checksum}`,\n }),\n index: -1,\n };\n }\n\n const { file, index } = fileInfo;\n\n const promise = uploadFile(presignedUrl, file, key);\n\n return {\n promise,\n index,\n objectType: file.type,\n objectSize: file.size,\n };\n });\n\n return await Promise.all(uploadPromises.map((t) => t.promise));\n }\n\n async download(functionKey: string, keys: string[]): Promise<DownloadResult[]> {\n if (!functionKey || functionKey.length === 0) {\n throw new BridgeAPIError('Parameter \"functionKey\" is required in \"store.download\".');\n }\n if (!Array.isArray(keys) || keys.length === 0) {\n throw new BridgeAPIError('Parameter \"keys\" is required and cannot be empty in \"store.download\".');\n }\n\n const downloadUrlsTokeys: Record<string, string> = await invoke(functionKey, keys);\n\n if (!downloadUrlsTokeys || typeof downloadUrlsTokeys !== \"object\") {\n throw new BridgeAPIError('Failed to get a valid response from \"invoke\".');\n }\n\n const downloadPromises = Object.entries(downloadUrlsTokeys).map(async ([downloadUrl, key]) => {\n try {\n const response = await fetch(downloadUrl, {\n method: \"GET\",\n });\n if (!response.ok) {\n return {\n success: false,\n key: key,\n status: response.status,\n error: `Download failed with status ${response.status}`,\n };\n }\n const blob = await response.blob();\n const disposition = response.headers.get(\"Content-Disposition\") ?? \"\";\n const name = disposition.match(/filename\\*=UTF-8''([^;]+)/)?.[1] ?? disposition.match(/filename=\"?([^\"]+)\"?/)?.[1] ?? \"\";\n\n return {\n success: true,\n key: key,\n blob,\n name,\n status: response.status,\n };\n } catch (error) {\n return {\n success: false,\n key: key,\n status: 503,\n error: error instanceof Error ? error.message : \"Download failed\",\n };\n }\n });\n\n return await Promise.all(downloadPromises);\n }\n\n async getMetadata(functionKey: string, keys: string[]): Promise<GetMetadataResult[]> {\n if (!functionKey || functionKey.length === 0) {\n throw new BridgeAPIError('Parameter \"functionKey\" is required in \"store.getMetadata\".');\n }\n if (!Array.isArray(keys) || keys.length === 0) {\n throw new BridgeAPIError('Parameter \"keys\" is required and cannot be empty in \"store.getMetadata\".');\n }\n const results = await Promise.all(\n keys.map(async (key) => {\n const result = await invoke(functionKey, key);\n if (!result || typeof result !== \"object\") {\n return {\n key,\n error: 'Failed to get a valid response from \"invoke\".',\n };\n }\n return result;\n }),\n );\n\n return results;\n }\n\n async delete(functionKey: string, keys: string[]): Promise<void> {\n if (!functionKey || functionKey.length === 0) {\n throw new BridgeAPIError('Parameter \"functionKey\" is required in \"store.delete\".');\n }\n if (!Array.isArray(keys) || keys.length === 0) {\n throw new BridgeAPIError('Parameter \"keys\" is required and cannot be empty in \"store.delete\".');\n }\n await Promise.all(\n keys.map(async (key) => {\n await invoke(functionKey, key);\n }),\n );\n }\n}\n\nexport const store = new NexusObjectStore();\n\nexport function sha256(buffer: ArrayBuffer): ArrayBuffer {\n const bytes = new Uint8Array(buffer);\n const len = bytes.length;\n const blockSize = 64;\n const hashSize = 32;\n\n const K = new Uint32Array([\n 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be,\n 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa,\n 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85,\n 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\n 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f,\n 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\n ]);\n\n let h0 = 0x6a09e667,\n h1 = 0xbb67ae85,\n h2 = 0x3c6ef372,\n h3 = 0xa54ff53a;\n let h4 = 0x510e527f,\n h5 = 0x9b05688c,\n h6 = 0x1f83d9ab,\n h7 = 0x5be0cd19;\n\n const totalBits = BigInt(len) * 8n;\n const paddingLen = len % blockSize < 56 ? 56 - (len % blockSize) : 120 - (len % blockSize);\n const paddedLen = len + paddingLen + 8;\n const padded = new Uint8Array(paddedLen);\n padded.set(bytes);\n padded[len] = 0x80;\n\n const view = new DataView(padded.buffer, padded.byteOffset);\n view.setUint32(paddedLen - 4, Number((totalBits >> 32n) & 0xffffffffn));\n view.setUint32(paddedLen - 8, Number(totalBits & 0xffffffffn));\n\n for (let i = 0; i < paddedLen; i += blockSize) {\n const w = new Uint32Array(64);\n for (let j = 0; j < 16; j++) {\n w[j] = view.getUint32(i + j * 4);\n }\n\n for (let j = 16; j < 64; j++) {\n const s0 = ((w[j - 15] >>> 7) | (w[j - 15] << 25)) ^ ((w[j - 15] >>> 18) | (w[j - 15] << 14)) ^ (w[j - 15] >>> 3);\n const s1 = ((w[j - 2] >>> 17) | (w[j - 2] << 15)) ^ ((w[j - 2] >>> 19) | (w[j - 2] << 13)) ^ (w[j - 2] >>> 10);\n w[j] = (w[j - 16] + s0 + w[j - 7] + s1) >>> 0;\n }\n\n let a = h0,\n b = h1,\n c = h2,\n d = h3,\n e = h4,\n f = h5,\n g = h6,\n h = h7;\n\n for (let j = 0; j < 64; j++) {\n const S1 = ((e >>> 6) | (e << 26)) ^ ((e >>> 11) | (e << 21)) ^ ((e >>> 25) | (e << 7));\n const ch = (e & f) ^ (~e & g);\n const temp1 = (h + S1 + ch + K[j] + w[j]) >>> 0;\n const S0 = ((a >>> 2) | (a << 30)) ^ ((a >>> 13) | (a << 19)) ^ ((a >>> 22) | (a << 10));\n const maj = (a & b) ^ (a & c) ^ (b & c);\n const temp2 = (S0 + maj) >>> 0;\n\n h = g;\n g = f;\n f = e;\n e = (d + temp1) >>> 0;\n d = c;\n c = b;\n b = a;\n a = (temp1 + temp2) >>> 0;\n }\n\n h0 = (h0 + a) >>> 0;\n h1 = (h1 + b) >>> 0;\n h2 = (h2 + c) >>> 0;\n h3 = (h3 + d) >>> 0;\n h4 = (h4 + e) >>> 0;\n h5 = (h5 + f) >>> 0;\n h6 = (h6 + g) >>> 0;\n h7 = (h7 + h) >>> 0;\n }\n\n const result = new ArrayBuffer(hashSize);\n const resultView = new DataView(result);\n resultView.setUint32(0, h0);\n resultView.setUint32(4, h1);\n resultView.setUint32(8, h2);\n resultView.setUint32(12, h3);\n resultView.setUint32(16, h4);\n resultView.setUint32(20, h5);\n resultView.setUint32(24, h6);\n resultView.setUint32(28, h7);\n return result;\n}\n","import { NexusBridge } from \"./bridge\";\nimport { BridgeAPIError } from \"./error\";\nimport { InvokeResponseData, RemoteInvokeOptions, RemoteRequestOptions, RemoteRequestResponseData } from \"./models\";\nimport {\n buildPayloadByRequestInit,\n buildRemoteRequestPayload,\n parseRemoteResponseData,\n parseToResponseData,\n validateFetchOptions,\n} from \"./utils/request\";\n\nclass NexusRemote {\n async invoke(options: RemoteInvokeOptions): Promise<Response> {\n if (!options || typeof options !== \"object\") {\n throw new BridgeAPIError('Parameter \"options\" must be an object in \"remote.invoke\".');\n }\n if (typeof options.path !== \"string\" || options.path.trim().length === 0) {\n throw new BridgeAPIError('Parameter \"path\" is required and cannot be empty in \"remote.invoke\" options.');\n }\n\n const payload = await buildPayloadByRequestInit(options);\n const { status, headers, body } = await NexusBridge.call<InvokeResponseData>(\"remoteInvoke\", payload);\n return parseToResponseData({ status, headers, body });\n }\n\n async request(remoteKey: string, options?: RemoteRequestOptions): Promise<Response> {\n if (typeof remoteKey !== \"string\" || remoteKey.trim().length === 0) {\n throw new BridgeAPIError('Parameter \"remoteKey\" is required and cannot be empty in \"remote.request\".');\n }\n if (options !== undefined && (!options || typeof options !== \"object\")) {\n throw new BridgeAPIError('Parameter \"options\" must be an object in \"remote.request\".');\n }\n\n const requestOptions = {\n path: \"\",\n ...validateFetchOptions(options),\n };\n const { path } = requestOptions;\n if (options !== undefined && (typeof path !== \"string\" || path.trim().length === 0)) {\n throw new BridgeAPIError('Parameter \"path\" is required and cannot be empty in \"remote.request\" options.');\n }\n\n const payload = await buildRemoteRequestPayload(remoteKey, requestOptions);\n const response = await NexusBridge.call<RemoteRequestResponseData>(\"remoteRequest\", payload);\n return parseRemoteResponseData(response);\n }\n}\n\nexport const remote = new NexusRemote();\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;AAEM,SAAU,oBAAoB,CAAI,GAAW,EAAE,KAAQ,EAAA;AACxD,IAAA,MAAkB,CAAC,GAAG,CAAC,GAAG,KAAK;AACpC;AAEM,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CAAC;QAC1F;AAEA,QAAA,MAAM,cAAc,GAAG;AACnB,YAAA,IAAI,EAAE,EAAE;YACR,GAAG,oBAAoB,CAAC,OAAO,CAAC;SACnC;AACD,QAAA,MAAM,EAAE,IAAI,EAAE,GAAG,cAAc;QAC/B,IAAI,OAAO,KAAK,SAAS,KAAK,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,CAAC,EAAE;AACjF,YAAA,MAAM,IAAI,cAAc,CAAC,+EAA+E,CAAC;QAC7G;QAEA,MAAM,OAAO,GAAG,MAAM,yBAAyB,CAAC,SAAS,EAAE,cAAc,CAAC;QAC1E,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,IAAI,CAA4B,eAAe,EAAE,OAAO,CAAC;AAC5F,QAAA,OAAO,uBAAuB,CAAC,QAAQ,CAAC;IAC5C;AACH;AAEM,MAAM,MAAM,GAAG,IAAI,WAAW;;AChDrC;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { DialogConfirmOptions,
|
|
1
|
+
import { DialogOpenOptions, DialogRef, DialogConfirmOptions, NavigationLocation, ExtensionData, NexusAppContext, NexusHistory, Subscription, SupportedLocaleCode, GetTranslationsResult, Translator, ApiInvokeOptions, UploadResult, DownloadResult, GetMetadataResult, RemoteInvokeOptions, RemoteRequestOptions } from '@pc-nexus/models';
|
|
2
|
+
export { ApiInvokeOptions, DialogConfirmOptions, DialogOpenOptions, DialogRef, DownloadResult, ExtensionData, GetMetadataResult, GetTranslationsResult, HistoryAction, HistoryListener, HistoryLocation, HistoryState, HistoryTo, HistoryUpdate, NavigationLocation, NavigationTarget, NexusAppContext, NexusHistory, RemoteInvokeOptions, RemoteRequestOptions, Subscription, SupportedLocaleCode, TranslationsResourceContent, Translator, UnlistenCallback, UploadResult, ViewportSize } from '@pc-nexus/models';
|
|
3
3
|
|
|
4
4
|
interface HostMessageEvent<T = unknown> {
|
|
5
5
|
source: Window | null;
|
|
@@ -26,7 +26,7 @@ declare class BridgeAPIError extends Error {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
declare class NexusDialog {
|
|
29
|
-
open<T>(options:
|
|
29
|
+
open<T>(options: DialogOpenOptions): Promise<DialogRef<T>>;
|
|
30
30
|
confirm<T>(options: DialogConfirmOptions): Promise<void>;
|
|
31
31
|
}
|
|
32
32
|
declare const dialog: NexusDialog;
|
|
@@ -42,9 +42,9 @@ declare class NexusRouter {
|
|
|
42
42
|
declare const router: NexusRouter;
|
|
43
43
|
|
|
44
44
|
declare class NexusView {
|
|
45
|
-
getContext<T = ExtensionData>(): Promise<
|
|
45
|
+
getContext<T = ExtensionData>(): Promise<NexusAppContext<T>>;
|
|
46
46
|
setWindowTitle(title: string): Promise<void>;
|
|
47
|
-
|
|
47
|
+
refresh(): Promise<void>;
|
|
48
48
|
close(payload?: unknown): Promise<void>;
|
|
49
49
|
/**
|
|
50
50
|
* 非弹窗场景调用无效。
|
|
@@ -66,8 +66,8 @@ declare const events: {
|
|
|
66
66
|
declare class NexusI18n {
|
|
67
67
|
private translationsCache;
|
|
68
68
|
private i18nFolderName;
|
|
69
|
-
getTranslations(locale?:
|
|
70
|
-
createTranslator(locale?:
|
|
69
|
+
getTranslations(locale?: SupportedLocaleCode): Promise<GetTranslationsResult>;
|
|
70
|
+
createTranslator(locale?: SupportedLocaleCode): Promise<Translator>;
|
|
71
71
|
private loadTranslations;
|
|
72
72
|
private getValue;
|
|
73
73
|
private translate;
|
|
@@ -75,16 +75,23 @@ declare class NexusI18n {
|
|
|
75
75
|
declare const i18n: NexusI18n;
|
|
76
76
|
|
|
77
77
|
declare class NexusRestApi {
|
|
78
|
-
|
|
78
|
+
invoke(path: string, options?: ApiInvokeOptions): Promise<Response>;
|
|
79
79
|
}
|
|
80
80
|
declare const api: NexusRestApi;
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
type UploadInput = File | Blob;
|
|
83
|
+
declare class NexusObjectStore {
|
|
84
|
+
upload(functionKey: string, objects: UploadInput[]): Promise<UploadResult[]>;
|
|
84
85
|
download(functionKey: string, keys: string[]): Promise<DownloadResult[]>;
|
|
85
|
-
|
|
86
|
+
getMetadata(functionKey: string, keys: string[]): Promise<GetMetadataResult[]>;
|
|
86
87
|
delete(functionKey: string, keys: string[]): Promise<void>;
|
|
87
88
|
}
|
|
88
|
-
declare const store:
|
|
89
|
+
declare const store: NexusObjectStore;
|
|
90
|
+
|
|
91
|
+
declare class NexusRemote {
|
|
92
|
+
invoke(options: RemoteInvokeOptions): Promise<Response>;
|
|
93
|
+
request(remoteKey: string, options?: RemoteRequestOptions): Promise<Response>;
|
|
94
|
+
}
|
|
95
|
+
declare const remote: NexusRemote;
|
|
89
96
|
|
|
90
|
-
export { api, dialog, events, i18n, invoke, router, store, view, BridgeAPIError as ɵBridgeAPIError, NexusBridge as ɵNexusBridge };
|
|
97
|
+
export { api, dialog, events, i18n, invoke, remote, router, store, view, BridgeAPIError as ɵBridgeAPIError, NexusBridge as ɵNexusBridge };
|