@visactor/vrender-kits 0.10.2 → 0.11.0-alpha.1
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/cjs/canvas/contributions/canvas-module.d.ts +1 -2
- package/cjs/canvas/contributions/canvas-module.js +1 -20
- package/cjs/canvas/contributions/canvas-module.js.map +1 -1
- package/cjs/canvas/contributions/node/canvas.d.ts +1 -47
- package/cjs/canvas/contributions/node/canvas.js +1 -105
- package/cjs/canvas/contributions/node/canvas.js.map +1 -1
- package/cjs/canvas/contributions/node/context.d.ts +1 -7
- package/cjs/canvas/contributions/node/context.js +1 -30
- package/cjs/canvas/contributions/node/context.js.map +1 -1
- package/cjs/canvas/contributions/node/index.d.ts +1 -2
- package/cjs/canvas/contributions/node/index.js +1 -21
- package/cjs/canvas/contributions/node/index.js.map +1 -1
- package/cjs/canvas/contributions/node/modules.d.ts +1 -3
- package/cjs/canvas/contributions/node/modules.js +1 -13
- package/cjs/canvas/contributions/node/modules.js.map +1 -1
- package/cjs/canvas/index.d.ts +1 -1
- package/cjs/canvas/index.js +1 -6
- package/cjs/canvas/index.js.map +1 -1
- package/cjs/env/contributions/module.d.ts +1 -3
- package/cjs/env/contributions/module.js +1 -12
- package/cjs/env/contributions/module.js.map +1 -1
- package/cjs/env/contributions/node-contribution.d.ts +1 -47
- package/cjs/env/contributions/node-contribution.js +1 -118
- package/cjs/env/contributions/node-contribution.js.map +1 -1
- package/cjs/index-node.d.ts +0 -3
- package/cjs/index-node.js +3 -13
- package/cjs/index-node.js.map +1 -1
- package/cjs/index.d.ts +0 -2
- package/cjs/index.js +3 -3
- package/cjs/index.js.map +1 -1
- package/cjs/node-bind.d.ts +1 -2
- package/cjs/node-bind.js +1 -20
- package/cjs/node-bind.js.map +1 -1
- package/cjs/window/contributions/modules.d.ts +1 -3
- package/cjs/window/contributions/modules.js +1 -13
- package/cjs/window/contributions/modules.js.map +1 -1
- package/cjs/window/contributions/node-contribution.d.ts +1 -38
- package/cjs/window/contributions/node-contribution.js +1 -109
- package/cjs/window/contributions/node-contribution.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.min.js +1 -1
- package/es/canvas/contributions/canvas-module.d.ts +1 -2
- package/es/canvas/contributions/canvas-module.js +1 -6
- package/es/canvas/contributions/canvas-module.js.map +1 -1
- package/es/canvas/contributions/node/canvas.d.ts +1 -47
- package/es/canvas/contributions/node/canvas.js +1 -104
- package/es/canvas/contributions/node/canvas.js.map +1 -1
- package/es/canvas/contributions/node/context.d.ts +1 -7
- package/es/canvas/contributions/node/context.js +1 -31
- package/es/canvas/contributions/node/context.js.map +1 -1
- package/es/canvas/contributions/node/index.d.ts +1 -2
- package/es/canvas/contributions/node/index.js +1 -4
- package/es/canvas/contributions/node/index.js.map +1 -1
- package/es/canvas/contributions/node/modules.d.ts +1 -3
- package/es/canvas/contributions/node/modules.js +1 -13
- package/es/canvas/contributions/node/modules.js.map +1 -1
- package/es/canvas/index.d.ts +1 -1
- package/es/canvas/index.js +1 -2
- package/es/canvas/index.js.map +1 -1
- package/es/env/contributions/module.d.ts +1 -3
- package/es/env/contributions/module.js +1 -10
- package/es/env/contributions/module.js.map +1 -1
- package/es/env/contributions/node-contribution.d.ts +1 -47
- package/es/env/contributions/node-contribution.js +1 -94
- package/es/env/contributions/node-contribution.js.map +1 -1
- package/es/index-node.d.ts +0 -3
- package/es/index-node.js +1 -7
- package/es/index-node.js.map +1 -1
- package/es/index.d.ts +0 -2
- package/es/index.js +0 -4
- package/es/index.js.map +1 -1
- package/es/node-bind.d.ts +1 -2
- package/es/node-bind.js +1 -10
- package/es/node-bind.js.map +1 -1
- package/es/window/contributions/modules.d.ts +1 -3
- package/es/window/contributions/modules.js +1 -10
- package/es/window/contributions/modules.js.map +1 -1
- package/es/window/contributions/node-contribution.d.ts +1 -38
- package/es/window/contributions/node-contribution.js +1 -107
- package/es/window/contributions/node-contribution.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,47 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import * as NodePkg from 'canvas';
|
|
3
|
-
import type { EnvType, IEnvContribution, IGlobal, ICreateCanvasParams } from '@visactor/vrender';
|
|
4
|
-
import { BaseEnvContribution } from '@visactor/vrender';
|
|
5
|
-
type NodePkg = {
|
|
6
|
-
createCanvas: typeof createCanvas;
|
|
7
|
-
createImageData: typeof createImageData;
|
|
8
|
-
loadImage: typeof loadImage;
|
|
9
|
-
};
|
|
10
|
-
export declare class NodeEnvContribution extends BaseEnvContribution implements IEnvContribution {
|
|
11
|
-
type: EnvType;
|
|
12
|
-
pkg: NodePkg;
|
|
13
|
-
_lastTime: number;
|
|
14
|
-
supportEvent: boolean;
|
|
15
|
-
configure(service: IGlobal, pkg?: NodePkg): void;
|
|
16
|
-
loadJson(url: string): Promise<{
|
|
17
|
-
loadState: 'success' | 'fail';
|
|
18
|
-
data: Record<string, unknown> | null;
|
|
19
|
-
}>;
|
|
20
|
-
loadArrayBuffer(url: string): Promise<{
|
|
21
|
-
loadState: 'success' | 'fail';
|
|
22
|
-
data: ArrayBuffer | null;
|
|
23
|
-
}>;
|
|
24
|
-
loadImage(url: string): Promise<{
|
|
25
|
-
loadState: 'success' | 'fail';
|
|
26
|
-
data: HTMLImageElement | null;
|
|
27
|
-
}>;
|
|
28
|
-
loadSvg(svgStr: string): Promise<{
|
|
29
|
-
loadState: 'success' | 'fail';
|
|
30
|
-
data: HTMLImageElement | null;
|
|
31
|
-
}>;
|
|
32
|
-
createCanvas(params: any): Canvas;
|
|
33
|
-
releaseCanvas(canvas: Canvas | any): void;
|
|
34
|
-
getDevicePixelRatio(): number;
|
|
35
|
-
getRequestAnimationFrame(): (callback: FrameRequestCallback) => number;
|
|
36
|
-
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
37
|
-
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
38
|
-
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
39
|
-
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
40
|
-
getElementById(str: string): HTMLElement | null;
|
|
41
|
-
getRootElement(): HTMLElement | null;
|
|
42
|
-
dispatchEvent(event: any): boolean;
|
|
43
|
-
getCancelAnimationFrame(): (h: number) => void;
|
|
44
|
-
release(...params: any): void;
|
|
45
|
-
createOffscreenCanvas(params: ICreateCanvasParams): void;
|
|
46
|
-
}
|
|
47
|
-
export {};
|
|
1
|
+
|
|
@@ -1,94 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
4
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
import { injectable } from "inversify";
|
|
8
|
-
|
|
9
|
-
import * as NodePkg from "canvas";
|
|
10
|
-
|
|
11
|
-
import { Resvg } from "@resvg/resvg-js";
|
|
12
|
-
|
|
13
|
-
import { BaseEnvContribution } from "@visactor/vrender";
|
|
14
|
-
|
|
15
|
-
import fetch from "node-fetch";
|
|
16
|
-
|
|
17
|
-
let last = 0;
|
|
18
|
-
|
|
19
|
-
function nodeRequestAnimationFrame(callback) {
|
|
20
|
-
const now = Date.now(), timeLeft = Math.max(0, 16 - (now - last)), id = setTimeout((function() {
|
|
21
|
-
callback(now + timeLeft);
|
|
22
|
-
}), timeLeft);
|
|
23
|
-
return last = now + timeLeft, id;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let NodeEnvContribution = class extends BaseEnvContribution {
|
|
27
|
-
constructor() {
|
|
28
|
-
super(...arguments), this.type = "node", this._lastTime = 0, this.supportEvent = !1;
|
|
29
|
-
}
|
|
30
|
-
configure(service, pkg = NodePkg) {
|
|
31
|
-
service.env === this.type && (service.setActiveEnvContribution(this), this.pkg = pkg);
|
|
32
|
-
}
|
|
33
|
-
loadJson(url) {
|
|
34
|
-
const jsonPromise = fetch(url).then((data => data.json()));
|
|
35
|
-
return jsonPromise.then((json => ({
|
|
36
|
-
data: json,
|
|
37
|
-
state: "success"
|
|
38
|
-
}))).catch((() => ({
|
|
39
|
-
data: null,
|
|
40
|
-
state: "fail"
|
|
41
|
-
}))), jsonPromise;
|
|
42
|
-
}
|
|
43
|
-
loadArrayBuffer(url) {
|
|
44
|
-
return fetch(url).then((data => data.arrayBuffer())).then((arrayBuffer => ({
|
|
45
|
-
data: arrayBuffer,
|
|
46
|
-
loadState: "success"
|
|
47
|
-
}))).catch((() => ({
|
|
48
|
-
data: null,
|
|
49
|
-
loadState: "fail"
|
|
50
|
-
})));
|
|
51
|
-
}
|
|
52
|
-
loadImage(url) {
|
|
53
|
-
const {loadImage: loadImage} = this.pkg;
|
|
54
|
-
return loadImage ? loadImage(url).then((image => ({
|
|
55
|
-
loadState: image ? "success" : "fail",
|
|
56
|
-
data: image
|
|
57
|
-
}))).catch((() => ({
|
|
58
|
-
loadState: "fail",
|
|
59
|
-
data: null
|
|
60
|
-
}))) : Promise.reject(new Error("node-canvas loadImage could not be found!"));
|
|
61
|
-
}
|
|
62
|
-
loadSvg(svgStr) {
|
|
63
|
-
if (!Resvg) return Promise.reject(new Error("@resvg/resvg-js svgParser could not be found!"));
|
|
64
|
-
const pngData = new Resvg(svgStr).render().asPng();
|
|
65
|
-
return this.loadImage(pngData);
|
|
66
|
-
}
|
|
67
|
-
createCanvas(params) {
|
|
68
|
-
return this.pkg.createCanvas(params.width, params.height);
|
|
69
|
-
}
|
|
70
|
-
releaseCanvas(canvas) {}
|
|
71
|
-
getDevicePixelRatio() {
|
|
72
|
-
return 0;
|
|
73
|
-
}
|
|
74
|
-
getRequestAnimationFrame() {
|
|
75
|
-
return nodeRequestAnimationFrame;
|
|
76
|
-
}
|
|
77
|
-
addEventListener(type, listener, options) {}
|
|
78
|
-
removeEventListener(type, listener, options) {}
|
|
79
|
-
getElementById(str) {
|
|
80
|
-
return null;
|
|
81
|
-
}
|
|
82
|
-
getRootElement() {
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
dispatchEvent(event) {}
|
|
86
|
-
getCancelAnimationFrame() {}
|
|
87
|
-
release(...params) {}
|
|
88
|
-
createOffscreenCanvas(params) {}
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
NodeEnvContribution = __decorate([ injectable() ], NodeEnvContribution);
|
|
92
|
-
|
|
93
|
-
export { NodeEnvContribution };
|
|
94
|
-
//# sourceMappingURL=node-contribution.js.map
|
|
1
|
+
//# sourceMappingURL=node-contribution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/env/contributions/node-contribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/env/contributions/node-contribution.ts"],"names":[],"mappings":"","file":"node-contribution.js","sourcesContent":["// import { injectable } from 'inversify';\n// import type { createCanvas, createImageData, loadImage, Canvas } from 'canvas';\n// import * as NodePkg from 'canvas';\n// import { Resvg } from '@resvg/resvg-js';\n// import type { EnvType, IEnvContribution, IGlobal, ICreateCanvasParams } from '@visactor/vrender';\n// import { BaseEnvContribution } from '@visactor/vrender';\n// import fetch from 'node-fetch';\n\n// type NodePkg = {\n// createCanvas: typeof createCanvas;\n// createImageData: typeof createImageData;\n// loadImage: typeof loadImage;\n// };\n\n// let last = 0;\n// function nodeRequestAnimationFrame(callback: FrameRequestCallback) {\n// const now = Date.now();\n// const timeLeft = Math.max(0, 16 - (now - last));\n// const id = setTimeout(function () {\n// callback(now + timeLeft);\n// }, timeLeft);\n// last = now + timeLeft;\n// return id;\n// }\n\n// @injectable()\n// export class NodeEnvContribution extends BaseEnvContribution implements IEnvContribution {\n// type: EnvType = 'node';\n// pkg: NodePkg;\n// _lastTime: number = 0;\n// supportEvent: boolean = false;\n\n// configure(service: IGlobal, pkg: NodePkg = NodePkg) {\n// if (service.env === this.type) {\n// service.setActiveEnvContribution(this);\n// this.pkg = pkg;\n// }\n// }\n\n// loadJson(url: string): Promise<{\n// loadState: 'success' | 'fail';\n// data: Record<string, unknown> | null;\n// }> {\n// const jsonPromise = fetch(url).then(data => data.json()) as Promise<any>; // ignore_security_alert\n// jsonPromise\n// .then(json => {\n// return {\n// data: json,\n// state: 'success'\n// };\n// })\n// .catch(() => {\n// return {\n// data: null,\n// state: 'fail'\n// };\n// });\n// return jsonPromise;\n// }\n\n// loadArrayBuffer(url: string): Promise<{\n// loadState: 'success' | 'fail';\n// data: ArrayBuffer | null;\n// }> {\n// const arrayBufferPromise = fetch(url).then(data => data.arrayBuffer()); // ignore_security_alert\n// return arrayBufferPromise\n// .then((arrayBuffer: ArrayBuffer) => {\n// return {\n// data: arrayBuffer,\n// loadState: 'success' as const\n// };\n// })\n// .catch(() => {\n// return {\n// data: null,\n// loadState: 'fail'\n// };\n// });\n// }\n\n// loadImage(url: string): Promise<{\n// loadState: 'success' | 'fail';\n// data: HTMLImageElement | null;\n// }> {\n// const { loadImage } = this.pkg;\n// if (loadImage) {\n// return loadImage(url)\n// .then((image: any) => {\n// const loadState: 'success' | 'fail' = image ? 'success' : 'fail';\n// return {\n// loadState,\n// data: image as HTMLImageElement\n// };\n// })\n// .catch(() => {\n// return {\n// loadState: 'fail',\n// data: null\n// } as any;\n// });\n// }\n// return Promise.reject(new Error('node-canvas loadImage could not be found!'));\n// }\n\n// // 此处的\n// loadSvg(svgStr: string): Promise<{\n// loadState: 'success' | 'fail';\n// data: HTMLImageElement | null;\n// }> {\n// // // eslint-disable-next-line @typescript-eslint/no-var-requires\n// // const { Resvg } = require('@resvg/resvg-js');\n// if (!Resvg) {\n// return Promise.reject(new Error('@resvg/resvg-js svgParser could not be found!'));\n// }\n// const resvg = new Resvg(svgStr);\n// const pngData = resvg.render().asPng();\n// return this.loadImage(pngData as unknown as string);\n// }\n\n// createCanvas(params: any): Canvas {\n// const canvas = this.pkg.createCanvas(params.width, params.height);\n// return canvas;\n// }\n\n// releaseCanvas(canvas: Canvas | any) {\n// return;\n// }\n\n// getDevicePixelRatio(): number {\n// return 0;\n// }\n\n// getRequestAnimationFrame(): (callback: FrameRequestCallback) => number {\n// // return requestAnimationFrame;\n// return nodeRequestAnimationFrame as any;\n// }\n\n// addEventListener<K extends keyof DocumentEventMap>(\n// type: K,\n// listener: (this: Document, ev: DocumentEventMap[K]) => any,\n// options?: boolean | AddEventListenerOptions | undefined\n// ): void;\n// addEventListener(\n// type: string,\n// listener: EventListenerOrEventListenerObject,\n// options?: boolean | AddEventListenerOptions | undefined\n// ): void;\n// addEventListener(type: unknown, listener: unknown, options?: unknown): void {\n// return;\n// }\n\n// removeEventListener<K extends keyof DocumentEventMap>(\n// type: K,\n// listener: (this: Document, ev: DocumentEventMap[K]) => any,\n// options?: boolean | EventListenerOptions | undefined\n// ): void;\n// removeEventListener(\n// type: string,\n// listener: EventListenerOrEventListenerObject,\n// options?: boolean | EventListenerOptions | undefined\n// ): void;\n// removeEventListener(type: unknown, listener: unknown, options?: unknown): void {\n// return;\n// }\n\n// getElementById(str: string): HTMLElement | null {\n// return null;\n// }\n\n// getRootElement(): HTMLElement | null {\n// return null;\n// }\n\n// dispatchEvent(event: any): boolean {\n// return;\n// }\n\n// getCancelAnimationFrame(): (h: number) => void {\n// return;\n// }\n\n// release(...params: any): void {\n// return;\n// }\n\n// createOffscreenCanvas(params: ICreateCanvasParams) {\n// return;\n// }\n// }\n"]}
|
package/es/index-node.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
-
import _canvasModuleLoader from './canvas/contributions/canvas-module';
|
|
3
2
|
export declare const roughModule: import("inversify").ContainerModule;
|
|
4
|
-
export declare const canvasModuleLoader: typeof _canvasModuleLoader;
|
|
5
|
-
export { nodeLoader } from './node-bind';
|
package/es/index-node.js
CHANGED
|
@@ -2,10 +2,4 @@ import "reflect-metadata";
|
|
|
2
2
|
|
|
3
3
|
import _roughModule from "./render/contributions/rough/module";
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export const roughModule = _roughModule;
|
|
8
|
-
|
|
9
|
-
export const canvasModuleLoader = _canvasModuleLoader;
|
|
10
|
-
|
|
11
|
-
export { nodeLoader } from "./node-bind";
|
|
5
|
+
export const roughModule = _roughModule;
|
package/es/index-node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,YAAY,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/index-node.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,YAAY,MAAM,qCAAqC,CAAC;AAG/D,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC","file":"index-node.js","sourcesContent":["import 'reflect-metadata';\nimport _roughModule from './render/contributions/rough/module';\n// import _canvasModuleLoader from './canvas/contributions/canvas-module';\n\nexport const roughModule = _roughModule;\n// export const canvasModuleLoader = _canvasModuleLoader;\n// export { nodeLoader } from './node-bind';\n"]}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -2,9 +2,5 @@ import "reflect-metadata";
|
|
|
2
2
|
|
|
3
3
|
import _roughModule from "./render/contributions/rough/module";
|
|
4
4
|
|
|
5
|
-
import _canvasModuleLoader from "./canvas/contributions/canvas-module";
|
|
6
|
-
|
|
7
5
|
export const roughModule = _roughModule;
|
|
8
|
-
|
|
9
|
-
export const canvasModuleLoader = _canvasModuleLoader;
|
|
10
6
|
//# sourceMappingURL=index.js.map
|
package/es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,YAAY,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,YAAY,MAAM,qCAAqC,CAAC;AAG/D,MAAM,CAAC,MAAM,WAAW,GAAG,YAAY,CAAC","file":"index.js","sourcesContent":["import 'reflect-metadata';\nimport _roughModule from './render/contributions/rough/module';\n// import _canvasModuleLoader from './canvas/contributions/canvas-module';\n\nexport const roughModule = _roughModule;\n// export const canvasModuleLoader = _canvasModuleLoader;\n// export { nodeLoader } from './node-bind'; // nodeLoader只在node入口暴露\n"]}
|
package/es/node-bind.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function nodeLoader(container: Container): void;
|
|
1
|
+
|
package/es/node-bind.js
CHANGED
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import nodeWindow from "./window/contributions/modules";
|
|
4
|
-
|
|
5
|
-
import nodeCanvas from "./canvas/contributions/node/modules";
|
|
6
|
-
|
|
7
|
-
export function nodeLoader(container) {
|
|
8
|
-
container.load(nodeEnv), container.load(nodeWindow), container.load(nodeCanvas);
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=node-bind.js.map
|
|
1
|
+
//# sourceMappingURL=node-bind.js.map
|
package/es/node-bind.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/node-bind.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/node-bind.ts"],"names":[],"mappings":"","file":"node-bind.js","sourcesContent":["// import type { Container } from 'inversify';\n// import nodeEnv from './env/contributions/module';\n// import nodeWindow from './window/contributions/modules';\n// import nodeCanvas from './canvas/contributions/node/modules';\n\n// // 直接绑定node环境\n// export function nodeLoader(container: Container) {\n// container.load(nodeEnv);\n// container.load(nodeWindow);\n// container.load(nodeCanvas);\n// }\n"]}
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { WindowHandlerContribution } from "@visactor/vrender";
|
|
4
|
-
|
|
5
|
-
import { NodeWindowHandlerContribution } from "./node-contribution";
|
|
6
|
-
|
|
7
|
-
export default new ContainerModule((bind => {
|
|
8
|
-
bind(NodeWindowHandlerContribution).toSelf().inSingletonScope(), bind(WindowHandlerContribution).toService(NodeWindowHandlerContribution);
|
|
9
|
-
}));
|
|
10
|
-
//# sourceMappingURL=modules.js.map
|
|
1
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/window/contributions/modules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/window/contributions/modules.ts"],"names":[],"mappings":"","file":"modules.js","sourcesContent":["// import { ContainerModule } from 'inversify';\n// import { bindContributionProvider, WindowHandlerContribution } from '@visactor/vrender';\n// import { NodeWindowHandlerContribution } from './node-contribution';\n\n// export default new ContainerModule(bind => {\n// bind(NodeWindowHandlerContribution).toSelf().inSingletonScope();\n// bind(WindowHandlerContribution).toService(NodeWindowHandlerContribution);\n// // bindContributionProvider(bind, WindowHandlerContribution);\n// });\n"]}
|
|
@@ -1,38 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { BaseWindowHandlerContribution } from '@visactor/vrender';
|
|
3
|
-
import type { IBoundsLike } from '@visactor/vutils';
|
|
4
|
-
export declare class NodeWindowHandlerContribution extends BaseWindowHandlerContribution implements IWindowHandlerContribution {
|
|
5
|
-
private readonly global;
|
|
6
|
-
type: EnvType;
|
|
7
|
-
canvas: ICanvas;
|
|
8
|
-
get container(): HTMLElement | null;
|
|
9
|
-
constructor(global: IGlobal);
|
|
10
|
-
getTitle(): string;
|
|
11
|
-
getWH(): {
|
|
12
|
-
width: number;
|
|
13
|
-
height: number;
|
|
14
|
-
};
|
|
15
|
-
getXY(): {
|
|
16
|
-
x: number;
|
|
17
|
-
y: number;
|
|
18
|
-
};
|
|
19
|
-
createWindow(params: IWindowParams): void;
|
|
20
|
-
private createWindowByConfig;
|
|
21
|
-
private createWindowByCanvas;
|
|
22
|
-
releaseWindow(): void;
|
|
23
|
-
resizeWindow(width: number, height: number): void;
|
|
24
|
-
setDpr(dpr: number): void;
|
|
25
|
-
getContext(): IContext2d;
|
|
26
|
-
getNativeHandler(): ICanvas;
|
|
27
|
-
getDpr(): number;
|
|
28
|
-
getImageBuffer(type?: string): any;
|
|
29
|
-
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
30
|
-
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
|
|
31
|
-
dispatchEvent(event: any): boolean;
|
|
32
|
-
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
33
|
-
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
|
|
34
|
-
getStyle(): CSSStyleDeclaration | Record<string, any>;
|
|
35
|
-
setStyle(style: CSSStyleDeclaration | Record<string, any>): void;
|
|
36
|
-
getBoundingClientRect(): IDomRectLike;
|
|
37
|
-
clearViewBox(vb: IBoundsLike, color?: string): void;
|
|
38
|
-
}
|
|
1
|
+
|
|
@@ -1,107 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
3
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) (d = decorators[i]) && (r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r);
|
|
4
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
5
|
-
}, __metadata = this && this.__metadata || function(k, v) {
|
|
6
|
-
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
7
|
-
}, __param = this && this.__param || function(paramIndex, decorator) {
|
|
8
|
-
return function(target, key) {
|
|
9
|
-
decorator(target, key, paramIndex);
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
import { inject, injectable } from "inversify";
|
|
14
|
-
|
|
15
|
-
import { Generator, Global, BaseWindowHandlerContribution } from "@visactor/vrender";
|
|
16
|
-
|
|
17
|
-
import { NodeCanvas } from "../../canvas/contributions/node/canvas";
|
|
18
|
-
|
|
19
|
-
let NodeWindowHandlerContribution = class extends BaseWindowHandlerContribution {
|
|
20
|
-
get container() {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
constructor(global) {
|
|
24
|
-
super(), this.global = global, this.type = "node";
|
|
25
|
-
}
|
|
26
|
-
getTitle() {
|
|
27
|
-
return "";
|
|
28
|
-
}
|
|
29
|
-
getWH() {
|
|
30
|
-
return {
|
|
31
|
-
width: this.canvas.displayWidth,
|
|
32
|
-
height: this.canvas.displayHeight
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
getXY() {
|
|
36
|
-
return {
|
|
37
|
-
x: 0,
|
|
38
|
-
y: 0
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
createWindow(params) {
|
|
42
|
-
params.canvas ? this.createWindowByCanvas(params) : this.createWindowByConfig(params);
|
|
43
|
-
}
|
|
44
|
-
createWindowByConfig(params) {
|
|
45
|
-
const nativeCanvas = this.global.createCanvas({
|
|
46
|
-
width: params.width,
|
|
47
|
-
height: params.height
|
|
48
|
-
}), options = {
|
|
49
|
-
width: params.width,
|
|
50
|
-
height: params.height,
|
|
51
|
-
dpr: params.dpr,
|
|
52
|
-
nativeCanvas: nativeCanvas,
|
|
53
|
-
id: Generator.GenAutoIncrementId().toString(),
|
|
54
|
-
canvasControled: !0
|
|
55
|
-
};
|
|
56
|
-
this.canvas = new NodeCanvas(options);
|
|
57
|
-
}
|
|
58
|
-
createWindowByCanvas(params) {
|
|
59
|
-
const canvas = params.canvas;
|
|
60
|
-
let width = params.width, height = params.height;
|
|
61
|
-
null != width && null != height && params.canvasControled || (width = canvas.width,
|
|
62
|
-
height = canvas.height), this.canvas = new NodeCanvas({
|
|
63
|
-
width: width,
|
|
64
|
-
height: height,
|
|
65
|
-
dpr: 1,
|
|
66
|
-
nativeCanvas: canvas,
|
|
67
|
-
canvasControled: params.canvasControled
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
releaseWindow() {
|
|
71
|
-
this.canvas.release();
|
|
72
|
-
}
|
|
73
|
-
resizeWindow(width, height) {
|
|
74
|
-
this.canvas.resize(width, height);
|
|
75
|
-
}
|
|
76
|
-
setDpr(dpr) {
|
|
77
|
-
this.canvas.dpr = dpr;
|
|
78
|
-
}
|
|
79
|
-
getContext() {
|
|
80
|
-
return this.canvas.getContext();
|
|
81
|
-
}
|
|
82
|
-
getNativeHandler() {
|
|
83
|
-
return this.canvas;
|
|
84
|
-
}
|
|
85
|
-
getDpr() {
|
|
86
|
-
return this.canvas.dpr;
|
|
87
|
-
}
|
|
88
|
-
getImageBuffer(type = "image/png") {
|
|
89
|
-
return this.canvas.nativeCanvas.toBuffer(type);
|
|
90
|
-
}
|
|
91
|
-
addEventListener(type, listener, options) {}
|
|
92
|
-
dispatchEvent(event) {
|
|
93
|
-
return !0;
|
|
94
|
-
}
|
|
95
|
-
removeEventListener(type, listener, options) {}
|
|
96
|
-
getStyle() {}
|
|
97
|
-
setStyle(style) {}
|
|
98
|
-
getBoundingClientRect() {
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
clearViewBox(vb, color) {}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
NodeWindowHandlerContribution = __decorate([ injectable(), __param(0, inject(Global)), __metadata("design:paramtypes", [ Object ]) ], NodeWindowHandlerContribution);
|
|
105
|
-
|
|
106
|
-
export { NodeWindowHandlerContribution };
|
|
107
|
-
//# sourceMappingURL=node-contribution.js.map
|
|
1
|
+
//# sourceMappingURL=node-contribution.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/window/contributions/node-contribution.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../src/window/contributions/node-contribution.ts"],"names":[],"mappings":"","file":"node-contribution.js","sourcesContent":["// import { inject, injectable } from 'inversify';\n// import type {\n// EnvType,\n// IGlobal,\n// IWindowHandlerContribution,\n// IWindowParams,\n// IContext2d,\n// ICanvas,\n// IDomRectLike\n// } from '@visactor/vrender';\n// import { Generator, Global, BaseWindowHandlerContribution } from '@visactor/vrender';\n// import { NodeCanvas } from '../../canvas/contributions/node/canvas';\n// import type { IBoundsLike } from '@visactor/vutils';\n\n// @injectable()\n// export class NodeWindowHandlerContribution extends BaseWindowHandlerContribution implements IWindowHandlerContribution {\n// type: EnvType = 'node';\n\n// canvas: ICanvas;\n// get container(): HTMLElement | null {\n// return null;\n// }\n\n// constructor(@inject(Global) private readonly global: IGlobal) {\n// super();\n// }\n\n// getTitle(): string {\n// return '';\n// }\n\n// getWH(): { width: number; height: number } {\n// return {\n// width: this.canvas.displayWidth,\n// height: this.canvas.displayHeight\n// };\n// }\n\n// getXY(): { x: number; y: number } {\n// return { x: 0, y: 0 };\n// }\n\n// createWindow(params: IWindowParams): void {\n// // 如果没有传入canvas,那么就创建一个canvas\n// if (!params.canvas) {\n// this.createWindowByConfig(params);\n// } else {\n// this.createWindowByCanvas(params);\n// }\n// }\n// private createWindowByConfig(params: IWindowParams) {\n// // 创建canvas\n// const nativeCanvas = this.global.createCanvas({ width: params.width, height: params.height });\n\n// // 绑定\n// const options = {\n// width: params.width,\n// height: params.height,\n// dpr: params.dpr,\n// nativeCanvas,\n// id: Generator.GenAutoIncrementId().toString(),\n// canvasControled: true\n// };\n// this.canvas = new NodeCanvas(options);\n// }\n// private createWindowByCanvas(params: IWindowParams) {\n// // 获取canvas\n// const canvas = params!.canvas as HTMLCanvasElement | null;\n\n// // 如果没有传入wh,或者是不受控制的canvas,那就用canvas的原始wh\n// let width = params.width;\n// let height = params.height;\n// if (width == null || height == null || !params.canvasControled) {\n// width = canvas.width;\n// height = canvas.height;\n// }\n\n// this.canvas = new NodeCanvas({\n// width: width,\n// height: height,\n// dpr: 1,\n// nativeCanvas: canvas,\n// canvasControled: params.canvasControled\n// });\n// }\n// releaseWindow(): void {\n// this.canvas.release();\n// }\n// resizeWindow(width: number, height: number): void {\n// this.canvas.resize(width, height);\n// }\n// setDpr(dpr: number): void {\n// this.canvas.dpr = dpr;\n// }\n\n// getContext(): IContext2d {\n// return this.canvas.getContext();\n// }\n// getNativeHandler(): ICanvas {\n// return this.canvas;\n// }\n// getDpr(): number {\n// return this.canvas.dpr;\n// }\n\n// getImageBuffer(type: string = 'image/png'): any {\n// const canvas = this.canvas.nativeCanvas;\n// return canvas.toBuffer(type);\n// }\n\n// addEventListener<K extends keyof DocumentEventMap>(\n// type: K,\n// listener: (this: Document, ev: DocumentEventMap[K]) => any,\n// options?: boolean | AddEventListenerOptions\n// ): void;\n// addEventListener(\n// type: string,\n// listener: EventListenerOrEventListenerObject,\n// options?: boolean | AddEventListenerOptions\n// ): void;\n// addEventListener(type: unknown, listener: unknown, options?: unknown): void {\n// return;\n// }\n\n// dispatchEvent(event: any): boolean {\n// return true;\n// }\n\n// removeEventListener<K extends keyof DocumentEventMap>(\n// type: K,\n// listener: (this: Document, ev: DocumentEventMap[K]) => any,\n// options?: boolean | EventListenerOptions\n// ): void;\n// removeEventListener(\n// type: string,\n// listener: EventListenerOrEventListenerObject,\n// options?: boolean | EventListenerOptions\n// ): void;\n// removeEventListener(type: unknown, listener: unknown, options?: unknown): void {\n// return;\n// }\n\n// getStyle(): CSSStyleDeclaration | Record<string, any> {\n// return;\n// }\n// setStyle(style: CSSStyleDeclaration | Record<string, any>): void {\n// return;\n// }\n\n// getBoundingClientRect(): IDomRectLike {\n// return null;\n// }\n\n// clearViewBox(vb: IBoundsLike, color?: string): void {\n// return;\n// }\n// }\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@visactor/vrender-kits",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0-alpha.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "cjs/index.js",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"dist"
|
|
13
13
|
],
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@visactor/vrender": "0.
|
|
16
|
-
"@visactor/vutils": "0.9.
|
|
15
|
+
"@visactor/vrender": "0.11.0-alpha.1",
|
|
16
|
+
"@visactor/vutils": "~0.9.2-alpha.5",
|
|
17
17
|
"@resvg/resvg-js": "2.4.1",
|
|
18
18
|
"canvas": "2.11.2",
|
|
19
19
|
"inversify": "6.0.1",
|