@tinywork/glass 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/index.ts +119 -119
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -291,10 +291,6 @@ declare global {
|
|
|
291
291
|
response?: any;
|
|
292
292
|
rule?: RuleSchema;
|
|
293
293
|
};
|
|
294
|
-
interface IProgress {
|
|
295
|
-
update: (option: { percent: number; text?: string }) => Promise<void>;
|
|
296
|
-
destroy: () => Promise<void>;
|
|
297
|
-
}
|
|
298
294
|
|
|
299
295
|
interface IGlassExtension {
|
|
300
296
|
install?: IGlassExtensionEvent<void>;
|
|
@@ -304,7 +300,8 @@ declare global {
|
|
|
304
300
|
/** 要修改url时,直接在params.url = new URL方式修改 */
|
|
305
301
|
onRequest?: IGlassExtensionEvent<{
|
|
306
302
|
/** url为null时表示break了请求 */
|
|
307
|
-
url:
|
|
303
|
+
url: string | null;
|
|
304
|
+
originUrl?: string | null;
|
|
308
305
|
isLocal?: boolean;
|
|
309
306
|
}>;
|
|
310
307
|
/** 在执行请求用例时触发,用于修改config */
|
|
@@ -333,7 +330,6 @@ declare global {
|
|
|
333
330
|
|
|
334
331
|
/** 在postMessage到页面之前 */
|
|
335
332
|
onMessagePost?: IGlassExtensionEvent<{ log: Partial<NetLog> }>;
|
|
336
|
-
onResponse?: IGlassExtensionEvent<{ url: URL }>;
|
|
337
333
|
deactivate?: IGlassExtensionEvent<void>;
|
|
338
334
|
uninstall?: IGlassExtensionEvent<void>;
|
|
339
335
|
|
|
@@ -375,118 +371,122 @@ declare global {
|
|
|
375
371
|
}>;
|
|
376
372
|
}
|
|
377
373
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
374
|
+
interface IGlassBridge {
|
|
375
|
+
writeText(text: string): IGlassExtensionInvokeResponse<void>;
|
|
376
|
+
openExternal(url: string): IGlassExtensionInvokeResponse<void>;
|
|
377
|
+
|
|
378
|
+
getItem<T>(key: string): IGlassExtensionInvokeResponse<T>;
|
|
379
|
+
setItem<T>(key: string, value: T): IGlassExtensionInvokeResponse<void>;
|
|
380
|
+
|
|
381
|
+
/** 保存cookie */
|
|
382
|
+
setCookie(params: {
|
|
383
|
+
name: string;
|
|
384
|
+
origin?: string;
|
|
385
|
+
path?: string;
|
|
386
|
+
value: string;
|
|
387
|
+
}): IGlassExtensionInvokeResponse<void>;
|
|
388
|
+
|
|
389
|
+
/** 获取cookie */
|
|
390
|
+
getCookie(params: {
|
|
391
|
+
name: string;
|
|
392
|
+
origin?: string;
|
|
393
|
+
path?: string;
|
|
394
|
+
}): IGlassExtensionInvokeResponse<string>;
|
|
395
|
+
/** 保存文档组 */
|
|
396
|
+
saveGroup(group: GroupSchema): IGlassExtensionInvokeResponse<void>;
|
|
397
|
+
/** 批量保存文档组 */
|
|
398
|
+
saveGroups(groups: GroupSchema[]): IGlassExtensionInvokeResponse<void>;
|
|
399
|
+
/** 保存文档 */
|
|
400
|
+
saveDoc(
|
|
401
|
+
doc: DocSchema,
|
|
402
|
+
options?: {
|
|
403
|
+
/** 是否触发缓存更新 */
|
|
404
|
+
hooks?: boolean;
|
|
405
|
+
/** 是否根据文档自动生成rule规则 */
|
|
406
|
+
defaultRule?: Partial<{
|
|
407
|
+
name: string;
|
|
408
|
+
origin: string;
|
|
409
|
+
pathname: string;
|
|
410
|
+
params: { key: string; value?: string }[];
|
|
411
|
+
}>;
|
|
412
|
+
}
|
|
413
|
+
): IGlassExtensionInvokeResponse<{
|
|
414
|
+
apiId: string;
|
|
415
|
+
ruleId?: string;
|
|
416
|
+
}>;
|
|
417
|
+
/** 批量保存文档 */
|
|
418
|
+
saveDocs(
|
|
419
|
+
docs: DocSchema[],
|
|
420
|
+
options?: {
|
|
421
|
+
/** 是否根据文档自动生成rule规则 */
|
|
422
|
+
defaultRules?: {
|
|
423
|
+
name: string;
|
|
424
|
+
origin: string;
|
|
425
|
+
pathname: string;
|
|
426
|
+
apiId: string;
|
|
427
|
+
params?: { key: string; value?: string }[] | null;
|
|
428
|
+
}[];
|
|
429
|
+
}
|
|
430
|
+
): IGlassExtensionInvokeResponse<void>;
|
|
431
|
+
/** 批量更新rule的本地数据 */
|
|
432
|
+
saveExamples(
|
|
433
|
+
ruleId: string,
|
|
434
|
+
examples: {
|
|
435
|
+
id: string;
|
|
436
|
+
contentType?: string;
|
|
437
|
+
example?: string;
|
|
438
|
+
name?: string;
|
|
439
|
+
statusCode?: number;
|
|
440
|
+
status?: boolean;
|
|
441
|
+
}[]
|
|
442
|
+
): IGlassExtensionInvokeResponse<void>;
|
|
443
|
+
/** 注册菜单项 */
|
|
444
|
+
registerMenu(
|
|
445
|
+
id: string,
|
|
446
|
+
options: MenuItem
|
|
447
|
+
): IGlassExtensionInvokeResponse<void>;
|
|
448
|
+
/** 移除菜单 */
|
|
449
|
+
unregisterMenu(id: string): IGlassExtensionInvokeResponse<void>;
|
|
450
|
+
|
|
451
|
+
showInputBox(option: {
|
|
452
|
+
title?: string;
|
|
453
|
+
placeholder?: string;
|
|
454
|
+
value?: string;
|
|
455
|
+
}): IGlassExtensionInvokeResponse<string>;
|
|
456
|
+
showMessage(options: {
|
|
457
|
+
message: string;
|
|
458
|
+
title?: string;
|
|
459
|
+
type?: "success" | "info" | "error";
|
|
460
|
+
}): IGlassExtensionInvokeResponse<void>;
|
|
461
|
+
showProgress(option: {
|
|
462
|
+
percent: number;
|
|
463
|
+
text?: string;
|
|
464
|
+
}): IGlassExtensionInvokeResponse<void>;
|
|
465
|
+
|
|
466
|
+
transformDocToJsonSchema(
|
|
467
|
+
doc: DocFullSchema
|
|
468
|
+
): IGlassExtensionInvokeResponse<JSONSchema>;
|
|
469
|
+
genDataFromDocSchema(
|
|
470
|
+
doc: DocFullSchema
|
|
471
|
+
): IGlassExtensionInvokeResponse<Record<string, any>>;
|
|
472
|
+
|
|
473
|
+
postMessage(
|
|
474
|
+
message: Partial<NetLog>
|
|
475
|
+
): IGlassExtensionInvokeResponse<void>;
|
|
476
|
+
openBrowserWindow(browserWindowOptions: {
|
|
477
|
+
width?: number;
|
|
478
|
+
height?: number;
|
|
479
|
+
minHeight?: number;
|
|
480
|
+
minWidth?: number;
|
|
481
|
+
show?: boolean;
|
|
482
|
+
alwaysOnTop?: boolean;
|
|
483
|
+
url: string;
|
|
484
|
+
until?: {
|
|
485
|
+
mode: "cookie";
|
|
486
|
+
type: "added" | "removed";
|
|
487
|
+
info: Glass.Cookie;
|
|
488
|
+
};
|
|
489
|
+
}): IGlassExtensionInvokeResponse<Glass.Cookie>;
|
|
490
|
+
}
|
|
491
491
|
}
|
|
492
492
|
}
|