@visactor/vrender-core 0.21.14 → 0.21.16

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.
@@ -7,6 +7,7 @@ export declare class AutoRefreshPlugin implements IPlugin {
7
7
  key: string;
8
8
  dpr: number;
9
9
  rafId: number;
10
+ autoRefreshCbs?: (() => void)[];
10
11
  handleChange: (graphic: IGraphic) => void;
11
12
  activate(context: IPluginService): void;
12
13
  refresh(): void;
@@ -31,16 +31,22 @@ class AutoRefreshPlugin {
31
31
  try {
32
32
  const mqString = `(resolution: ${window.devicePixelRatio}dppx)`, updatePixelRatio = () => {
33
33
  window.devicePixelRatio !== this.dpr && (this.dpr = window.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0));
34
- };
35
- matchMedia(mqString).addEventListener("change", updatePixelRatio);
34
+ }, dom = matchMedia(mqString);
35
+ dom && dom.addEventListener("change", updatePixelRatio), this.autoRefreshCbs || (this.autoRefreshCbs = []),
36
+ this.autoRefreshCbs.push((() => {
37
+ dom && dom.removeEventListener("change", updatePixelRatio);
38
+ }));
36
39
  } catch (err) {
37
40
  return !1;
38
41
  }
39
42
  return !0;
40
43
  }
41
44
  deactivate(context) {
45
+ var _a;
42
46
  const craf = application_1.application.global.getCancelAnimationFrame();
43
- craf && this.rafId && craf(this.rafId);
47
+ craf && this.rafId && craf(this.rafId), null === (_a = this.autoRefreshCbs) || void 0 === _a || _a.forEach((cb => {
48
+ cb();
49
+ })), this.autoRefreshCbs = void 0;
44
50
  }
45
51
  }
46
52
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins/builtin-plugin/auto-refresh-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AACnD,mDAAgD;AAGhD,MAAa,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,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,CAAC;YAEhE,MAAM,gBAAgB,GAAG,GAAG,EAAE;gBAC5B,IAAI,MAAM,CAAC,gBAAgB,KAAK,IAAI,CAAC,GAAG,EAAE;oBACxC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC;oBACnC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;iBACjD;YACH,CAAC,CAAC;YAEF,UAAU,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;SACnE;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,MAAM,IAAI,GAAG,yBAAW,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC;QAC1D,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF;AA5DD,8CA4DC","file":"auto-refresh-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { IGraphic, IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRefreshPlugin implements IPlugin {\n name: 'AutoRefreshPlugin' = 'AutoRefreshPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n dpr: number;\n rafId: number;\n\n handleChange = (graphic: IGraphic) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === this.pluginService.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n };\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n this.dpr = application.global.devicePixelRatio;\n this.refresh();\n }\n\n refresh() {\n if (!this._refreshByMediaQuery()) {\n this._refreshByRaf();\n }\n }\n protected _refreshByRaf() {\n const raf = application.global.getRequestAnimationFrame();\n this.rafId = raf(() => {\n if (application.global.devicePixelRatio !== this.dpr) {\n this.dpr = application.global.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n this.refresh();\n });\n }\n protected _refreshByMediaQuery() {\n try {\n const mqString = `(resolution: ${window.devicePixelRatio}dppx)`;\n\n const updatePixelRatio = () => {\n if (window.devicePixelRatio !== this.dpr) {\n this.dpr = window.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n };\n\n matchMedia(mqString).addEventListener('change', updatePixelRatio);\n } catch (err) {\n return false;\n }\n return true;\n }\n deactivate(context: IPluginService): void {\n const craf = application.global.getCancelAnimationFrame();\n craf && this.rafId && craf(this.rafId);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/auto-refresh-plugin.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AACnD,mDAAgD;AAGhD,MAAa,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,qBAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAKpC,iBAAY,GAAG,CAAC,OAAiB,EAAE,EAAE;YACnC,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBACvE,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC;IAsDJ,CAAC;IApDC,QAAQ,CAAC,OAAuB;QAC9B,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,yBAAW,CAAC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E,CAAC;aAC1B;YACD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC5B,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;SACJ;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,UAAU,CAAC,OAAuB;;QAChC,MAAM,IAAI,GAAG,yBAAW,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC;QAC1D,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,MAAA,IAAI,CAAC,cAAc,0CAAE,OAAO,CAAC,EAAE,CAAC,EAAE;YAChC,EAAE,EAAE,CAAC;QACP,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;IAClC,CAAC;CACF;AAvED,8CAuEC","file":"auto-refresh-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { IGraphic, IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRefreshPlugin implements IPlugin {\n name: 'AutoRefreshPlugin' = 'AutoRefreshPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n dpr: number;\n rafId: number;\n autoRefreshCbs?: (() => void)[];\n\n handleChange = (graphic: IGraphic) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === this.pluginService.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n };\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n this.dpr = application.global.devicePixelRatio;\n this.refresh();\n }\n\n refresh() {\n if (!this._refreshByMediaQuery()) {\n this._refreshByRaf();\n }\n }\n protected _refreshByRaf() {\n const raf = application.global.getRequestAnimationFrame();\n this.rafId = raf(() => {\n if (application.global.devicePixelRatio !== this.dpr) {\n this.dpr = application.global.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n this.refresh();\n });\n }\n protected _refreshByMediaQuery() {\n try {\n const mqString = `(resolution: ${window.devicePixelRatio}dppx)`;\n\n const updatePixelRatio = () => {\n if (window.devicePixelRatio !== this.dpr) {\n this.dpr = window.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n };\n const dom = matchMedia(mqString);\n dom && dom.addEventListener('change', updatePixelRatio);\n if (!this.autoRefreshCbs) {\n this.autoRefreshCbs = [];\n }\n this.autoRefreshCbs.push(() => {\n dom && dom.removeEventListener('change', updatePixelRatio);\n });\n } catch (err) {\n return false;\n }\n return true;\n }\n deactivate(context: IPluginService): void {\n const craf = application.global.getCancelAnimationFrame();\n craf && this.rafId && craf(this.rafId);\n this.autoRefreshCbs?.forEach(cb => {\n cb();\n });\n this.autoRefreshCbs = undefined;\n }\n}\n"]}
package/dist/index.es.js CHANGED
@@ -24203,7 +24203,14 @@ class AutoRefreshPlugin {
24203
24203
  this.pluginService.stage.setDpr(this.dpr, true);
24204
24204
  }
24205
24205
  };
24206
- matchMedia(mqString).addEventListener('change', updatePixelRatio);
24206
+ const dom = matchMedia(mqString);
24207
+ dom && dom.addEventListener('change', updatePixelRatio);
24208
+ if (!this.autoRefreshCbs) {
24209
+ this.autoRefreshCbs = [];
24210
+ }
24211
+ this.autoRefreshCbs.push(() => {
24212
+ dom && dom.removeEventListener('change', updatePixelRatio);
24213
+ });
24207
24214
  }
24208
24215
  catch (err) {
24209
24216
  return false;
@@ -24211,8 +24218,13 @@ class AutoRefreshPlugin {
24211
24218
  return true;
24212
24219
  }
24213
24220
  deactivate(context) {
24221
+ var _a;
24214
24222
  const craf = application.global.getCancelAnimationFrame();
24215
24223
  craf && this.rafId && craf(this.rafId);
24224
+ (_a = this.autoRefreshCbs) === null || _a === void 0 ? void 0 : _a.forEach(cb => {
24225
+ cb();
24226
+ });
24227
+ this.autoRefreshCbs = undefined;
24216
24228
  }
24217
24229
  }
24218
24230
 
@@ -7,6 +7,7 @@ export declare class AutoRefreshPlugin implements IPlugin {
7
7
  key: string;
8
8
  dpr: number;
9
9
  rafId: number;
10
+ autoRefreshCbs?: (() => void)[];
10
11
  handleChange: (graphic: IGraphic) => void;
11
12
  activate(context: IPluginService): void;
12
13
  refresh(): void;
@@ -26,16 +26,22 @@ export class AutoRefreshPlugin {
26
26
  try {
27
27
  const mqString = `(resolution: ${window.devicePixelRatio}dppx)`, updatePixelRatio = () => {
28
28
  window.devicePixelRatio !== this.dpr && (this.dpr = window.devicePixelRatio, this.pluginService.stage.setDpr(this.dpr, !0));
29
- };
30
- matchMedia(mqString).addEventListener("change", updatePixelRatio);
29
+ }, dom = matchMedia(mqString);
30
+ dom && dom.addEventListener("change", updatePixelRatio), this.autoRefreshCbs || (this.autoRefreshCbs = []),
31
+ this.autoRefreshCbs.push((() => {
32
+ dom && dom.removeEventListener("change", updatePixelRatio);
33
+ }));
31
34
  } catch (err) {
32
35
  return !1;
33
36
  }
34
37
  return !0;
35
38
  }
36
39
  deactivate(context) {
40
+ var _a;
37
41
  const craf = application.global.getCancelAnimationFrame();
38
- craf && this.rafId && craf(this.rafId);
42
+ craf && this.rafId && craf(this.rafId), null === (_a = this.autoRefreshCbs) || void 0 === _a || _a.forEach((cb => {
43
+ cb();
44
+ })), this.autoRefreshCbs = void 0;
39
45
  }
40
46
  }
41
47
  //# sourceMappingURL=auto-refresh-plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/plugins/builtin-plugin/auto-refresh-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,OAAO,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YA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IAAI;YACF,MAAM,QAAQ,GAAG,gBAAgB,MAAM,CAAC,gBAAgB,OAAO,CAAC;YAEhE,MAAM,gBAAgB,GAAG,GAAG,EAAE;gBAC5B,IAAI,MAAM,CAAC,gBAAgB,KAAK,IAAI,CAAC,GAAG,EAAE;oBACxC,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,gBAAgB,CAAC;oBACnC,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;iBACjD;YACH,CAAC,CAAC;YAEF,UAAU,CAAC,QAAQ,CAAC,CAAC,gBAAgB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;SACnE;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,UAAU,CAAC,OAAuB;QAChC,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC;QAC1D,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACzC,CAAC;CACF","file":"auto-refresh-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { IGraphic, IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRefreshPlugin implements IPlugin {\n name: 'AutoRefreshPlugin' = 'AutoRefreshPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n dpr: number;\n rafId: number;\n\n handleChange = (graphic: IGraphic) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === this.pluginService.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n };\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n this.dpr = application.global.devicePixelRatio;\n this.refresh();\n }\n\n refresh() {\n if (!this._refreshByMediaQuery()) {\n this._refreshByRaf();\n }\n }\n protected _refreshByRaf() {\n const raf = application.global.getRequestAnimationFrame();\n this.rafId = raf(() => {\n if (application.global.devicePixelRatio !== this.dpr) {\n this.dpr = application.global.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n this.refresh();\n });\n }\n protected _refreshByMediaQuery() {\n try {\n const mqString = `(resolution: ${window.devicePixelRatio}dppx)`;\n\n const updatePixelRatio = () => {\n if (window.devicePixelRatio !== this.dpr) {\n this.dpr = window.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n };\n\n matchMedia(mqString).addEventListener('change', updatePixelRatio);\n } catch (err) {\n return false;\n }\n return true;\n }\n deactivate(context: IPluginService): void {\n const craf = application.global.getCancelAnimationFrame();\n craf && this.rafId && craf(this.rafId);\n }\n}\n"]}
1
+ {"version":3,"sources":["../src/plugins/builtin-plugin/auto-refresh-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,MAAM,OAAO,iBAAiB;IAA9B;QACE,SAAI,GAAwB,mBAAmB,CAAC;QAChD,gBAAW,GAAiB,YAAY,CAAC;QAEzC,SAAI,GAAW,SAAS,CAAC,kBAAkB,EAAE,CAAC;QAC9C,QAAG,GAAW,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QAKpC,iBAAY,GAAG,CAAC,OAAiB,EAAE,EAAE;YACnC,IAAI,OAAO,CAAC,SAAS,EAAE;gBACrB,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC;aAC7B;YACD,IAAI,OAAO,CAAC,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,EAAE;gBACvE,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;aACjC;QACH,CAAC,CAAC;IAsDJ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CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YACxD,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;gBACxB,IAAI,CAAC,cAAc,GAAG,EAAE,CAAC;aAC1B;YACD,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE;gBAC5B,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;YAC7D,CAAC,CAAC,CAAC;SACJ;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,UAAU,CAAC,OAAuB;;QAChC,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,uBAAuB,EAAE,CAAC;QAC1D,IAAI,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvC,MAAA,IAAI,CAAC,cAAc,0CAAE,OAAO,CAAC,EAAE,CAAC,EAAE;YAChC,EAAE,EAAE,CAAC;QACP,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;IAClC,CAAC;CACF","file":"auto-refresh-plugin.js","sourcesContent":["import { Generator } from '../../common/generator';\nimport { application } from '../../application';\nimport type { IGraphic, IPlugin, IPluginService } from '../../interface';\n\nexport class AutoRefreshPlugin implements IPlugin {\n name: 'AutoRefreshPlugin' = 'AutoRefreshPlugin';\n activeEvent: 'onRegister' = 'onRegister';\n pluginService: IPluginService;\n _uid: number = Generator.GenAutoIncrementId();\n key: string = this.name + this._uid;\n dpr: number;\n rafId: number;\n autoRefreshCbs?: (() => void)[];\n\n handleChange = (graphic: IGraphic) => {\n if (graphic.glyphHost) {\n graphic = graphic.glyphHost;\n }\n if (graphic.stage === this.pluginService.stage && graphic.stage != null) {\n graphic.stage.renderNextFrame();\n }\n };\n\n activate(context: IPluginService): void {\n this.pluginService = context;\n this.dpr = application.global.devicePixelRatio;\n this.refresh();\n }\n\n refresh() {\n if (!this._refreshByMediaQuery()) {\n this._refreshByRaf();\n }\n }\n protected _refreshByRaf() {\n const raf = application.global.getRequestAnimationFrame();\n this.rafId = raf(() => {\n if (application.global.devicePixelRatio !== this.dpr) {\n this.dpr = application.global.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n this.refresh();\n });\n }\n protected _refreshByMediaQuery() {\n try {\n const mqString = `(resolution: ${window.devicePixelRatio}dppx)`;\n\n const updatePixelRatio = () => {\n if (window.devicePixelRatio !== this.dpr) {\n this.dpr = window.devicePixelRatio;\n this.pluginService.stage.setDpr(this.dpr, true);\n }\n };\n const dom = matchMedia(mqString);\n dom && dom.addEventListener('change', updatePixelRatio);\n if (!this.autoRefreshCbs) {\n this.autoRefreshCbs = [];\n }\n this.autoRefreshCbs.push(() => {\n dom && dom.removeEventListener('change', updatePixelRatio);\n });\n } catch (err) {\n return false;\n }\n return true;\n }\n deactivate(context: IPluginService): void {\n const craf = application.global.getCancelAnimationFrame();\n craf && this.rafId && craf(this.rafId);\n this.autoRefreshCbs?.forEach(cb => {\n cb();\n });\n this.autoRefreshCbs = undefined;\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visactor/vrender-core",
3
- "version": "0.21.14",
3
+ "version": "0.21.16",
4
4
  "description": "",
5
5
  "sideEffects": [
6
6
  "./src/modules.ts",
@@ -36,8 +36,8 @@
36
36
  "typescript": "4.9.5",
37
37
  "cross-env": "^7.0.3",
38
38
  "@internal/bundler": "0.0.1",
39
- "@internal/eslint-config": "0.0.1",
40
- "@internal/ts-config": "0.0.1"
39
+ "@internal/ts-config": "0.0.1",
40
+ "@internal/eslint-config": "0.0.1"
41
41
  },
42
42
  "keywords": [
43
43
  "VisActor",