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