@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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +119 -119
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinywork/glass",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
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: URL | null;
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
- type writeText = (text: string) => Promise<void>;
379
- type openExternal = (url: string) => Promise<void>;
380
- type getItem = <T>(key: string) => Promise<T>;
381
- type setItem = <T>(key: string, value: T) => Promise<void>;
382
- /** 保存cookie */
383
- type setCookie = (params: {
384
- name: string;
385
- origin?: string;
386
- path?: string;
387
- value: string;
388
- }) => IGlassExtensionInvokeResponse<void>;
389
- /** 获取cookie */
390
- type getCookie = (params: {
391
- name: string;
392
- origin?: string;
393
- path?: string;
394
- }) => IGlassExtensionInvokeResponse<string>;
395
- /** 保存文档组 */
396
- type saveGroup = (
397
- group: GroupSchema
398
- ) => IGlassExtensionInvokeResponse<void>;
399
- /** 批量保存文档组 */
400
- type saveGroups = (
401
- groups: GroupSchema[]
402
- ) => IGlassExtensionInvokeResponse<void>;
403
- /** 保存文档 */
404
- type saveDoc = (
405
- doc: DocSchema,
406
- options?: {
407
- /** 是否触发缓存更新 */
408
- hooks?: boolean;
409
- /** 是否根据文档自动生成rule规则 */
410
- defaultRule?: Partial<{
411
- name: string;
412
- origin: string;
413
- pathname: string;
414
- params: { key: string; value?: string }[];
415
- }>;
416
- }
417
- ) => IGlassExtensionInvokeResponse<{
418
- apiId: string;
419
- ruleId?: string;
420
- }>;
421
- /** 批量保存文档 */
422
- type saveDocs = (
423
- docs: DocSchema[],
424
- options?: {
425
- /** 是否根据文档自动生成rule规则 */
426
- defaultRules?: {
427
- name: string;
428
- origin: string;
429
- pathname: string;
430
- apiId: string;
431
- params?: { key: string; value?: string }[] | null;
432
- }[];
433
- }
434
- ) => IGlassExtensionInvokeResponse<void>;
435
- /** 批量更新rule的本地数据 */
436
- type saveExamples = (
437
- ruleId: string,
438
- examples: {
439
- id: string;
440
- contentType?: string;
441
- example?: string;
442
- name?: string;
443
- statusCode?: number;
444
- status?: boolean;
445
- }[]
446
- ) => IGlassExtensionInvokeResponse<void>;
447
- /** 注册菜单项 */
448
- type registerMenu = (
449
- id: string,
450
- options: MenuItem
451
- ) => IGlassExtensionInvokeResponse<void>;
452
- /** 移除菜单 */
453
- type unregisterMenu = (id: string) => IGlassExtensionInvokeResponse<void>;
454
-
455
- type showInputBox = (option: {
456
- title?: string;
457
- placeholder?: string;
458
- value?: string;
459
- }) => IGlassExtensionInvokeResponse<string>;
460
- type showMessage = (options: {
461
- message: string;
462
- title?: string;
463
- type?: "success" | "info" | "error";
464
- }) => IGlassExtensionInvokeResponse<void>;
465
- type showProgress = () => IProgress;
466
-
467
- type transformDocToJsonSchema = (
468
- doc: DocFullSchema
469
- ) => IGlassExtensionInvokeResponse<JSONSchema>;
470
- type genDataFromDocSchema = (
471
- doc: DocFullSchema
472
- ) => IGlassExtensionInvokeResponse<Record<string, any>>;
473
-
474
- type postMessage = (
475
- message: Partial<NetLog>
476
- ) => IGlassExtensionInvokeResponse<void>;
477
- type openBrowserWindow = (browserWindowOptions: {
478
- width?: number;
479
- height?: number;
480
- minHeight?: number;
481
- minWidth?: number;
482
- show?: boolean;
483
- alwaysOnTop?: boolean;
484
- url: string;
485
- until?: {
486
- mode: "cookie";
487
- type: "added" | "removed";
488
- info: Glass.Cookie;
489
- };
490
- }) => IGlassExtensionInvokeResponse<Glass.Cookie>;
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
  }