@visactor/vrender 0.12.3 → 0.13.0-alpha.6
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/modules.d.ts +1 -1
- package/cjs/canvas/contributions/modules.js +2 -2
- package/cjs/canvas/contributions/modules.js.map +1 -1
- package/cjs/canvas/contributions/wx/canvas.d.ts +48 -0
- package/cjs/canvas/contributions/wx/canvas.js +102 -0
- package/cjs/canvas/contributions/wx/canvas.js.map +1 -0
- package/cjs/canvas/contributions/wx/context.d.ts +6 -0
- package/cjs/canvas/contributions/wx/context.js +21 -0
- package/cjs/canvas/contributions/wx/context.js.map +1 -0
- package/cjs/canvas/contributions/wx/index.d.ts +2 -0
- package/cjs/canvas/contributions/wx/index.js +21 -0
- package/cjs/canvas/contributions/wx/index.js.map +1 -0
- package/cjs/canvas/contributions/wx/modules.d.ts +3 -0
- package/cjs/canvas/contributions/wx/modules.js +13 -0
- package/cjs/canvas/contributions/wx/modules.js.map +1 -0
- package/cjs/core/contributions/env/modules.js +2 -1
- package/cjs/core/contributions/env/modules.js.map +1 -1
- package/cjs/core/contributions/env/wx-contribution.d.ts +39 -0
- package/cjs/core/contributions/env/wx-contribution.js +131 -0
- package/cjs/core/contributions/env/wx-contribution.js.map +1 -0
- package/cjs/core/contributions/window/modules.js +2 -1
- package/cjs/core/contributions/window/modules.js.map +1 -1
- package/cjs/core/contributions/window/wx-contribution.d.ts +46 -0
- package/cjs/core/contributions/window/wx-contribution.js +159 -0
- package/cjs/core/contributions/window/wx-contribution.js.map +1 -0
- package/cjs/core/global.d.ts +3 -3
- package/cjs/core/global.js +13 -6
- package/cjs/core/global.js.map +1 -1
- package/cjs/index.d.ts +1 -1
- package/cjs/index.js +18 -18
- package/cjs/index.js.map +1 -1
- package/cjs/interface/global.d.ts +2 -1
- package/cjs/interface/global.js.map +1 -1
- package/dist/index.js +500 -27
- package/dist/index.min.js +1 -1
- package/es/canvas/contributions/modules.d.ts +1 -1
- package/es/canvas/contributions/modules.js +3 -1
- package/es/canvas/contributions/modules.js.map +1 -1
- package/es/canvas/contributions/wx/canvas.d.ts +48 -0
- package/es/canvas/contributions/wx/canvas.js +101 -0
- package/es/canvas/contributions/wx/canvas.js.map +1 -0
- package/es/canvas/contributions/wx/context.d.ts +6 -0
- package/es/canvas/contributions/wx/context.js +18 -0
- package/es/canvas/contributions/wx/context.js.map +1 -0
- package/es/canvas/contributions/wx/index.d.ts +2 -0
- package/es/canvas/contributions/wx/index.js +4 -0
- package/es/canvas/contributions/wx/index.js.map +1 -0
- package/es/canvas/contributions/wx/modules.d.ts +3 -0
- package/es/canvas/contributions/wx/modules.js +13 -0
- package/es/canvas/contributions/wx/modules.js.map +1 -0
- package/es/core/contributions/env/modules.js +3 -0
- package/es/core/contributions/env/modules.js.map +1 -1
- package/es/core/contributions/env/wx-contribution.d.ts +39 -0
- package/es/core/contributions/env/wx-contribution.js +130 -0
- package/es/core/contributions/env/wx-contribution.js.map +1 -0
- package/es/core/contributions/window/modules.js +3 -0
- package/es/core/contributions/window/modules.js.map +1 -1
- package/es/core/contributions/window/wx-contribution.d.ts +46 -0
- package/es/core/contributions/window/wx-contribution.js +161 -0
- package/es/core/contributions/window/wx-contribution.js.map +1 -0
- package/es/core/global.d.ts +3 -3
- package/es/core/global.js +13 -6
- package/es/core/global.js.map +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/index.js.map +1 -1
- package/es/interface/global.d.ts +2 -1
- package/es/interface/global.js.map +1 -1
- package/es/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Container } from 'inversify';
|
|
1
|
+
import type { Container } from 'inversify';
|
|
2
2
|
export default function load(container: Container): void;
|
|
@@ -10,11 +10,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
10
10
|
value: !0
|
|
11
11
|
});
|
|
12
12
|
|
|
13
|
-
const modules_1 = __importDefault(require("./browser/modules")), modules_2 = __importDefault(require("./taro/modules")), modules_3 = __importDefault(require("./feishu/modules")), modules_4 = __importDefault(require("./lynx/modules")), modules_5 = __importDefault(require("./node/modules"));
|
|
13
|
+
const modules_1 = __importDefault(require("./browser/modules")), modules_2 = __importDefault(require("./taro/modules")), modules_3 = __importDefault(require("./feishu/modules")), modules_4 = __importDefault(require("./lynx/modules")), modules_5 = __importDefault(require("./wx/modules")), modules_6 = __importDefault(require("./node/modules"));
|
|
14
14
|
|
|
15
15
|
function load(container) {
|
|
16
16
|
container.load(modules_1.default), container.load(modules_3.default), container.load(modules_2.default),
|
|
17
|
-
container.load(modules_4.default), container.load(modules_5.default);
|
|
17
|
+
container.load(modules_4.default), container.load(modules_5.default), container.load(modules_6.default);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
exports.default = load;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/canvas/contributions/modules.ts"],"names":[],"mappings":";;;;;AACA,gEAA8C;AAC9C,6DAAwC;AACxC,+DAA4C;AAC5C,6DAAwC;AACxC,6DAAwC;AAExC,SAAwB,IAAI,CAAC,SAAoB;IAC/C,SAAS,CAAC,IAAI,CAAC,iBAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,IAAI,CAAC,iBAAY,CAAC,CAAC;IAC7B,SAAS,CAAC,IAAI,CAAC,iBAAU,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,CAAC,iBAAU,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,CAAC,iBAAU,CAAC,CAAC;AAC7B,CAAC;
|
|
1
|
+
{"version":3,"sources":["../../src/canvas/contributions/modules.ts"],"names":[],"mappings":";;;;;AACA,gEAA8C;AAC9C,6DAAwC;AACxC,+DAA4C;AAC5C,6DAAwC;AACxC,2DAAoC;AACpC,6DAAwC;AAExC,SAAwB,IAAI,CAAC,SAAoB;IAC/C,SAAS,CAAC,IAAI,CAAC,iBAAa,CAAC,CAAC;IAC9B,SAAS,CAAC,IAAI,CAAC,iBAAY,CAAC,CAAC;IAC7B,SAAS,CAAC,IAAI,CAAC,iBAAU,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,CAAC,iBAAU,CAAC,CAAC;IAC3B,SAAS,CAAC,IAAI,CAAC,iBAAQ,CAAC,CAAC;IACzB,SAAS,CAAC,IAAI,CAAC,iBAAU,CAAC,CAAC;AAC7B,CAAC;AAPD,uBAOC","file":"modules.js","sourcesContent":["import type { Container } from 'inversify';\nimport browserModule from './browser/modules';\nimport taroModule from './taro/modules';\nimport feishuModule from './feishu/modules';\nimport lynxModule from './lynx/modules';\nimport wxModule from './wx/modules';\nimport nodeModule from './node/modules';\n\nexport default function load(container: Container) {\n container.load(browserModule);\n container.load(feishuModule);\n container.load(taroModule);\n container.load(lynxModule);\n container.load(wxModule);\n container.load(nodeModule);\n}\n"]}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ICanvas, IContext2d, CanvasConfigType, EnvType } from '../../../interface';
|
|
2
|
+
export declare class WxCanvas implements ICanvas {
|
|
3
|
+
static env: EnvType;
|
|
4
|
+
private _displayWidth;
|
|
5
|
+
private _displayHeight;
|
|
6
|
+
private _id;
|
|
7
|
+
private _pixelWidth;
|
|
8
|
+
private _pixelHeight;
|
|
9
|
+
private _x;
|
|
10
|
+
private _y;
|
|
11
|
+
private _dpr;
|
|
12
|
+
private _container?;
|
|
13
|
+
private _nativeCanvas;
|
|
14
|
+
private _context;
|
|
15
|
+
private _visiable;
|
|
16
|
+
get id(): number | string;
|
|
17
|
+
get x(): number;
|
|
18
|
+
get y(): number;
|
|
19
|
+
get nativeCanvas(): HTMLCanvasElement;
|
|
20
|
+
get width(): number;
|
|
21
|
+
set width(width: number);
|
|
22
|
+
get height(): number;
|
|
23
|
+
set height(height: number);
|
|
24
|
+
get displayWidth(): number;
|
|
25
|
+
get displayHeight(): number;
|
|
26
|
+
getContext(str?: string): IContext2d;
|
|
27
|
+
get visiable(): boolean;
|
|
28
|
+
set visiable(visiable: boolean);
|
|
29
|
+
get dpr(): number;
|
|
30
|
+
set dpr(dpr: number);
|
|
31
|
+
constructor(params: CanvasConfigType);
|
|
32
|
+
getNativeCanvas(): HTMLCanvasElement;
|
|
33
|
+
resetStyle(params: Partial<CanvasConfigType>): void;
|
|
34
|
+
applyPosition(): void;
|
|
35
|
+
hide(): void;
|
|
36
|
+
show(): void;
|
|
37
|
+
resize(width: number, height: number): void;
|
|
38
|
+
toDataURL(): string;
|
|
39
|
+
toDataURL(mimeType: 'image/png'): string;
|
|
40
|
+
toDataURL(mimeType: 'image/jpeg', quality: number): string;
|
|
41
|
+
readPixels(x: number, y: number, w: number, h: number): ImageData | Promise<ImageData>;
|
|
42
|
+
convertToBlob(options?: {
|
|
43
|
+
type?: string | undefined;
|
|
44
|
+
quality?: number | undefined;
|
|
45
|
+
} | undefined): Promise<Blob>;
|
|
46
|
+
transferToImageBitmap(): ImageBitmap;
|
|
47
|
+
release(...params: any): void;
|
|
48
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
+
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);
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}, __metadata = this && this.__metadata || function(k, v) {
|
|
8
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
Object.defineProperty(exports, "__esModule", {
|
|
12
|
+
value: !0
|
|
13
|
+
}), exports.WxCanvas = void 0;
|
|
14
|
+
|
|
15
|
+
const inversify_1 = require("inversify"), context_1 = require("./context"), DefaultConfig = {
|
|
16
|
+
WIDTH: 500,
|
|
17
|
+
HEIGHT: 500,
|
|
18
|
+
DPR: 1
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
let WxCanvas = class {
|
|
22
|
+
get id() {
|
|
23
|
+
return this._id;
|
|
24
|
+
}
|
|
25
|
+
get x() {
|
|
26
|
+
return this._x;
|
|
27
|
+
}
|
|
28
|
+
get y() {
|
|
29
|
+
return this._y;
|
|
30
|
+
}
|
|
31
|
+
get nativeCanvas() {
|
|
32
|
+
return this._nativeCanvas;
|
|
33
|
+
}
|
|
34
|
+
get width() {
|
|
35
|
+
return this._pixelWidth;
|
|
36
|
+
}
|
|
37
|
+
set width(width) {
|
|
38
|
+
this._pixelWidth = width, this._displayWidth = width / (this._dpr || 1);
|
|
39
|
+
}
|
|
40
|
+
get height() {
|
|
41
|
+
return this._pixelHeight;
|
|
42
|
+
}
|
|
43
|
+
set height(height) {
|
|
44
|
+
this._pixelHeight = height, this._displayHeight = height / (this._dpr || 1);
|
|
45
|
+
}
|
|
46
|
+
get displayWidth() {
|
|
47
|
+
return this._displayWidth;
|
|
48
|
+
}
|
|
49
|
+
get displayHeight() {
|
|
50
|
+
return this._displayHeight;
|
|
51
|
+
}
|
|
52
|
+
getContext(str) {
|
|
53
|
+
return this._context;
|
|
54
|
+
}
|
|
55
|
+
get visiable() {
|
|
56
|
+
return this._visiable;
|
|
57
|
+
}
|
|
58
|
+
set visiable(visiable) {
|
|
59
|
+
this._visiable = visiable, visiable ? this.show() : this.hide();
|
|
60
|
+
}
|
|
61
|
+
get dpr() {
|
|
62
|
+
return this._dpr;
|
|
63
|
+
}
|
|
64
|
+
set dpr(dpr) {
|
|
65
|
+
this._dpr = dpr;
|
|
66
|
+
}
|
|
67
|
+
constructor(params) {
|
|
68
|
+
const {nativeCanvas: nativeCanvas, width: width = DefaultConfig.WIDTH, height: height = DefaultConfig.HEIGHT, dpr: dpr = DefaultConfig.DPR} = params, {x: x, y: y} = nativeCanvas.getBoundingClientRect ? nativeCanvas.getBoundingClientRect() : {
|
|
69
|
+
x: 0,
|
|
70
|
+
y: 0
|
|
71
|
+
};
|
|
72
|
+
this._x = x, this._y = y, this._pixelWidth = width * dpr, this._pixelHeight = height * dpr,
|
|
73
|
+
this._visiable = !1 !== params.visiable, this._displayWidth = width, this._displayHeight = height,
|
|
74
|
+
this._dpr = dpr, this._nativeCanvas = nativeCanvas, this._context = new context_1.WxContext2d(this, this._dpr),
|
|
75
|
+
this._id = nativeCanvas.id;
|
|
76
|
+
}
|
|
77
|
+
getNativeCanvas() {
|
|
78
|
+
return this._nativeCanvas;
|
|
79
|
+
}
|
|
80
|
+
resetStyle(params) {}
|
|
81
|
+
applyPosition() {}
|
|
82
|
+
hide() {}
|
|
83
|
+
show() {}
|
|
84
|
+
resize(width, height) {}
|
|
85
|
+
toDataURL(mimeType, quality) {
|
|
86
|
+
return "";
|
|
87
|
+
}
|
|
88
|
+
readPixels(x, y, w, h) {
|
|
89
|
+
throw new Error("暂未实现");
|
|
90
|
+
}
|
|
91
|
+
convertToBlob(options) {
|
|
92
|
+
throw new Error("暂未实现");
|
|
93
|
+
}
|
|
94
|
+
transferToImageBitmap() {
|
|
95
|
+
throw new Error("暂未实现");
|
|
96
|
+
}
|
|
97
|
+
release(...params) {}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
WxCanvas.env = "wx", WxCanvas = __decorate([ (0, inversify_1.injectable)(), __metadata("design:paramtypes", [ Object ]) ], WxCanvas),
|
|
101
|
+
exports.WxCanvas = WxCanvas;
|
|
102
|
+
//# sourceMappingURL=canvas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/canvas/contributions/wx/canvas.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAuC;AAEvC,uCAAwC;AAExC,MAAM,aAAa,GAAG;IACpB,KAAK,EAAE,GAAG;IACV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,UAAU,CAAC,MAAiC;QAC1C,OAAO;IACT,CAAC;IAED,aAAa;QACX,OAAO;IACT,CAAC;IAED,IAAI;QACF,OAAO;IACT,CAAC;IACD,IAAI;QACF,OAAO;IACT,CAAC;IAOD,MAAM,CAAC,KAAa,EAAE,MAAc;QAClC,OAAO;IACT,CAAC;IAKD,SAAS,CAAC,QAAiB,EAAE,OAAgB;QAC3C,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,UAAU,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;QACnD,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,aAAa,CAAC,OAAiF;QAC7F,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,qBAAqB;QACnB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IAC1B,CAAC;IAED,OAAO,CAAC,GAAG,MAAW;QACpB,OAAO;IACT,CAAC;;AArJM,YAAG,GAAY,IAAI,CAAC;AADhB,QAAQ;IADpB,IAAA,sBAAU,GAAE;;GACA,QAAQ,CAuJpB;AAvJY,4BAAQ","file":"canvas.js","sourcesContent":["import { injectable } from 'inversify';\nimport type { ICanvas, IContext2d, CanvasConfigType, EnvType } from '../../../interface';\nimport { WxContext2d } from './context';\n\nconst DefaultConfig = {\n WIDTH: 500,\n HEIGHT: 500,\n DPR: 1\n};\n\n@injectable()\nexport class WxCanvas implements ICanvas {\n static env: EnvType = 'wx';\n // 显示的宽高,如果是离屏canvas,就是pixelWidth / pixelRatio\n private _displayWidth: number; // 显示的宽度\n private _displayHeight: number; // 显示的高度\n private _id: number | string;\n // 像素宽高\n private _pixelWidth: number; // 像素宽度\n private _pixelHeight: number; // 像素高度\n\n private _x: number;\n private _y: number;\n private _dpr: number;\n\n private _container?: HTMLElement | null;\n private _nativeCanvas: HTMLCanvasElement;\n private _context: IContext2d;\n private _visiable: boolean;\n\n get id(): number | string {\n return this._id;\n }\n get x(): number {\n return this._x;\n }\n get y(): number {\n return this._y;\n }\n get nativeCanvas(): HTMLCanvasElement {\n return this._nativeCanvas;\n }\n\n get width(): number {\n return this._pixelWidth;\n }\n set width(width: number) {\n this._pixelWidth = width;\n this._displayWidth = width / (this._dpr || 1);\n }\n\n get height(): number {\n return this._pixelHeight;\n }\n set height(height: number) {\n this._pixelHeight = height;\n this._displayHeight = height / (this._dpr || 1);\n }\n get displayWidth(): number {\n return this._displayWidth;\n }\n get displayHeight(): number {\n return this._displayHeight;\n }\n getContext(str?: string): IContext2d {\n return this._context;\n }\n\n get visiable(): boolean {\n return this._visiable;\n }\n set visiable(visiable: boolean) {\n this._visiable = visiable;\n visiable ? this.show() : this.hide();\n }\n\n get dpr(): number {\n return this._dpr;\n }\n set dpr(dpr: number) {\n // this._lastPixelRatio = this._pixelRatio;\n this._dpr = dpr;\n }\n\n /**\n * 通过canvas生成一个wrap对象,初始化时不会再设置canvas的属性\n * @param params\n */\n constructor(params: CanvasConfigType) {\n const {\n nativeCanvas,\n width = DefaultConfig.WIDTH,\n height = DefaultConfig.HEIGHT,\n dpr = DefaultConfig.DPR\n } = params;\n // 不会修改到位置的\n const { x, y } = nativeCanvas.getBoundingClientRect ? nativeCanvas.getBoundingClientRect() : { x: 0, y: 0 };\n this._x = x;\n this._y = y;\n this._pixelWidth = width * dpr;\n this._pixelHeight = height * dpr;\n this._visiable = params.visiable !== false;\n\n // 离屏canvas\n this._displayWidth = width;\n this._displayHeight = height;\n this._dpr = dpr;\n this._nativeCanvas = nativeCanvas;\n this._context = new WxContext2d(this, this._dpr);\n this._id = nativeCanvas.id;\n }\n\n getNativeCanvas(): HTMLCanvasElement {\n return this._nativeCanvas;\n }\n\n resetStyle(params: Partial<CanvasConfigType>) {\n return;\n }\n\n applyPosition() {\n return;\n }\n\n hide() {\n return;\n }\n show() {\n return;\n }\n\n /**\n * 设置canvas的size大小,设置context的scale\n * @param width\n * @param height\n */\n resize(width: number, height: number) {\n return;\n }\n\n toDataURL(): string;\n toDataURL(mimeType: 'image/png'): string;\n toDataURL(mimeType: 'image/jpeg', quality: number): string;\n toDataURL(mimeType?: string, quality?: number) {\n return '';\n }\n\n readPixels(x: number, y: number, w: number, h: number): ImageData | Promise<ImageData> {\n throw new Error('暂未实现');\n }\n\n convertToBlob(options?: { type?: string | undefined; quality?: number | undefined } | undefined): Promise<Blob> {\n throw new Error('暂未实现');\n }\n\n transferToImageBitmap(): ImageBitmap {\n throw new Error('暂未实现');\n }\n\n release(...params: any): void {\n return;\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
+
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);
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: !0
|
|
11
|
+
}), exports.WxContext2d = void 0;
|
|
12
|
+
|
|
13
|
+
const inversify_1 = require("inversify"), browser_1 = require("../browser");
|
|
14
|
+
|
|
15
|
+
let WxContext2d = class extends browser_1.BrowserContext2d {
|
|
16
|
+
draw() {}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
WxContext2d.env = "wx", WxContext2d = __decorate([ (0, inversify_1.injectable)() ], WxContext2d),
|
|
20
|
+
exports.WxContext2d = WxContext2d;
|
|
21
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/canvas/contributions/wx/context.ts"],"names":[],"mappings":";;;;;;;;;AACA,yCAAuC;AAEvC,wCAA8C;AAGvC,IAAM,WAAW,GAAjB,MAAM,WAAY,SAAQ,0BAAgB;IAG/C,IAAI;QACF,OAAO;IACT,CAAC;;AAJM,eAAG,GAAY,IAAI,CAAC;AADhB,WAAW;IADvB,IAAA,sBAAU,GAAE;GACA,WAAW,CAMvB;AANY,kCAAW","file":"context.js","sourcesContent":["// 参考konva\nimport { injectable } from 'inversify';\nimport type { IContext2d, EnvType } from '../../../interface';\nimport { BrowserContext2d } from '../browser';\n\n@injectable()\nexport class WxContext2d extends BrowserContext2d implements IContext2d {\n static env: EnvType = 'wx';\n\n draw() {\n return;\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __exportStar = this && this.__exportStar || function(m, exports) {
|
|
15
|
+
for (var p in m) "default" === p || Object.prototype.hasOwnProperty.call(exports, p) || __createBinding(exports, m, p);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Object.defineProperty(exports, "__esModule", {
|
|
19
|
+
value: !0
|
|
20
|
+
}), __exportStar(require("./canvas"), exports), __exportStar(require("./context"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/canvas/contributions/wx/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,2CAAyB;AACzB,4CAA0B","file":"index.js","sourcesContent":["// 依然导出canvas和context,便于指定环境直接使用\nexport * from './canvas';\nexport * from './context';\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: !0
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const inversify_1 = require("inversify"), canvas_1 = require("./canvas"), context_1 = require("./context"), constants_1 = require("../../constants");
|
|
8
|
+
|
|
9
|
+
exports.default = new inversify_1.ContainerModule((bind => {
|
|
10
|
+
bind(constants_1.CanvasFactory).toDynamicValue((() => params => new canvas_1.WxCanvas(params))).whenTargetNamed(canvas_1.WxCanvas.env),
|
|
11
|
+
bind(constants_1.Context2dFactory).toDynamicValue((() => (params, dpr) => new context_1.WxContext2d(params, dpr))).whenTargetNamed(context_1.WxContext2d.env);
|
|
12
|
+
}));
|
|
13
|
+
//# sourceMappingURL=modules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/canvas/contributions/wx/modules.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAC5C,qCAAoC;AACpC,uCAAwC;AACxC,+CAAkE;AAGlE,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IACxC,IAAI,CAAC,yBAAa,CAAC;SAChB,cAAc,CAAC,GAAG,EAAE;QACnB,OAAO,CAAC,MAAwB,EAAE,EAAE,CAAC,IAAI,iBAAQ,CAAC,MAAM,CAAC,CAAC;IAC5D,CAAC,CAAC;SACD,eAAe,CAAC,iBAAQ,CAAC,GAAG,CAAC,CAAC;IAEjC,IAAI,CAAC,4BAAgB,CAAC;SACnB,cAAc,CAAC,GAAG,EAAE;QACnB,OAAO,CAAC,MAAe,EAAE,GAAW,EAAE,EAAE,CAAC,IAAI,qBAAW,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACxE,CAAC,CAAC;SACD,eAAe,CAAC,qBAAW,CAAC,GAAG,CAAC,CAAC;AACtC,CAAC,CAAC,CAAC","file":"modules.js","sourcesContent":["import { ContainerModule } from 'inversify';\nimport { WxCanvas } from './canvas';\nimport { WxContext2d } from './context';\nimport { CanvasFactory, Context2dFactory } from '../../constants';\nimport type { CanvasConfigType, ICanvas } from '../../../interface';\n\nexport default new ContainerModule(bind => {\n bind(CanvasFactory)\n .toDynamicValue(() => {\n return (params: CanvasConfigType) => new WxCanvas(params);\n })\n .whenTargetNamed(WxCanvas.env);\n\n bind(Context2dFactory)\n .toDynamicValue(() => {\n return (params: ICanvas, dpr: number) => new WxContext2d(params, dpr);\n })\n .whenTargetNamed(WxContext2d.env);\n});\n"]}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
const inversify_1 = require("inversify"), contribution_provider_1 = require("../../../common/contribution-provider"), constants_1 = require("../../../constants"), browser_contribution_1 = require("./browser-contribution"), feishu_contribution_1 = require("./feishu-contribution"), taro_contribution_1 = require("./taro-contribution"), lynx_contribution_1 = require("./lynx-contribution"), node_contribution_1 = require("./node-contribution");
|
|
7
|
+
const inversify_1 = require("inversify"), contribution_provider_1 = require("../../../common/contribution-provider"), constants_1 = require("../../../constants"), browser_contribution_1 = require("./browser-contribution"), feishu_contribution_1 = require("./feishu-contribution"), taro_contribution_1 = require("./taro-contribution"), lynx_contribution_1 = require("./lynx-contribution"), node_contribution_1 = require("./node-contribution"), wx_contribution_1 = require("./wx-contribution");
|
|
8
8
|
|
|
9
9
|
exports.default = new inversify_1.ContainerModule((bind => {
|
|
10
10
|
bind(browser_contribution_1.BrowserEnvContribution).toSelf().inSingletonScope(),
|
|
@@ -12,6 +12,7 @@ exports.default = new inversify_1.ContainerModule((bind => {
|
|
|
12
12
|
bind(feishu_contribution_1.FeishuEnvContribution).toSelf().inSingletonScope(), bind(constants_1.EnvContribution).toService(feishu_contribution_1.FeishuEnvContribution),
|
|
13
13
|
bind(taro_contribution_1.TaroEnvContribution).toSelf().inSingletonScope(), bind(constants_1.EnvContribution).toService(taro_contribution_1.TaroEnvContribution),
|
|
14
14
|
bind(lynx_contribution_1.LynxEnvContribution).toSelf().inSingletonScope(), bind(constants_1.EnvContribution).toService(lynx_contribution_1.LynxEnvContribution),
|
|
15
|
+
bind(wx_contribution_1.WxEnvContribution).toSelf().inSingletonScope(), bind(constants_1.EnvContribution).toService(wx_contribution_1.WxEnvContribution),
|
|
15
16
|
bind(node_contribution_1.NodeEnvContribution).toSelf().inSingletonScope(), bind(constants_1.EnvContribution).toService(node_contribution_1.NodeEnvContribution),
|
|
16
17
|
(0, contribution_provider_1.bindContributionProvider)(bind, constants_1.EnvContribution);
|
|
17
18
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/contributions/env/modules.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAC5C,iFAAiF;AACjF,kDAAqD;AACrD,iEAAgE;AAChE,+DAA8D;AAC9D,2DAA0D;AAC1D,2DAA0D;AAC1D,2DAA0D;
|
|
1
|
+
{"version":3,"sources":["../../src/core/contributions/env/modules.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAC5C,iFAAiF;AACjF,kDAAqD;AACrD,iEAAgE;AAChE,+DAA8D;AAC9D,2DAA0D;AAC1D,2DAA0D;AAC1D,2DAA0D;AAC1D,uDAAsD;AAEtD,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IAExC,IAAI,CAAC,6CAAsB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACzD,IAAI,CAAC,2BAAe,CAAC,CAAC,SAAS,CAAC,6CAAsB,CAAC,CAAC;IAGxD,IAAI,CAAC,2CAAqB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACxD,IAAI,CAAC,2BAAe,CAAC,CAAC,SAAS,CAAC,2CAAqB,CAAC,CAAC;IAGvD,IAAI,CAAC,uCAAmB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACtD,IAAI,CAAC,2BAAe,CAAC,CAAC,SAAS,CAAC,uCAAmB,CAAC,CAAC;IAGrD,IAAI,CAAC,uCAAmB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACtD,IAAI,CAAC,2BAAe,CAAC,CAAC,SAAS,CAAC,uCAAmB,CAAC,CAAC;IAGrD,IAAI,CAAC,mCAAiB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACpD,IAAI,CAAC,2BAAe,CAAC,CAAC,SAAS,CAAC,mCAAiB,CAAC,CAAC;IAGnD,IAAI,CAAC,uCAAmB,CAAC,CAAC,MAAM,EAAE,CAAC,gBAAgB,EAAE,CAAC;IACtD,IAAI,CAAC,2BAAe,CAAC,CAAC,SAAS,CAAC,uCAAmB,CAAC,CAAC;IAErD,IAAA,gDAAwB,EAAC,IAAI,EAAE,2BAAe,CAAC,CAAC;AAClD,CAAC,CAAC,CAAC","file":"modules.js","sourcesContent":["import { ContainerModule } from 'inversify';\nimport { bindContributionProvider } from '../../../common/contribution-provider';\nimport { EnvContribution } from '../../../constants';\nimport { BrowserEnvContribution } from './browser-contribution';\nimport { FeishuEnvContribution } from './feishu-contribution';\nimport { TaroEnvContribution } from './taro-contribution';\nimport { LynxEnvContribution } from './lynx-contribution';\nimport { NodeEnvContribution } from './node-contribution';\nimport { WxEnvContribution } from './wx-contribution';\n\nexport default new ContainerModule(bind => {\n // browser\n bind(BrowserEnvContribution).toSelf().inSingletonScope();\n bind(EnvContribution).toService(BrowserEnvContribution);\n\n // feishu\n bind(FeishuEnvContribution).toSelf().inSingletonScope();\n bind(EnvContribution).toService(FeishuEnvContribution);\n\n // taro\n bind(TaroEnvContribution).toSelf().inSingletonScope();\n bind(EnvContribution).toService(TaroEnvContribution);\n\n // lynx\n bind(LynxEnvContribution).toSelf().inSingletonScope();\n bind(EnvContribution).toService(LynxEnvContribution);\n\n // wx\n bind(WxEnvContribution).toSelf().inSingletonScope();\n bind(EnvContribution).toService(WxEnvContribution);\n\n // node\n bind(NodeEnvContribution).toSelf().inSingletonScope();\n bind(EnvContribution).toService(NodeEnvContribution);\n\n bindContributionProvider(bind, EnvContribution);\n});\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ICanvasLike, EnvType, ICreateCanvasParams, IEnvContribution, IGlobal, ITTCanvas } from '../../../interface';
|
|
2
|
+
import { BaseEnvContribution } from './base-contribution';
|
|
3
|
+
export declare class WxEnvContribution extends BaseEnvContribution implements IEnvContribution {
|
|
4
|
+
type: EnvType;
|
|
5
|
+
supportEvent: boolean;
|
|
6
|
+
canvasMap: Map<string, ITTCanvas>;
|
|
7
|
+
freeCanvasList: ITTCanvas[];
|
|
8
|
+
canvasIdx: number;
|
|
9
|
+
constructor();
|
|
10
|
+
configure(service: IGlobal, params: {
|
|
11
|
+
domref: any;
|
|
12
|
+
canvasIdLists: string[];
|
|
13
|
+
freeCanvasIdx: number;
|
|
14
|
+
}): Promise<void>;
|
|
15
|
+
loadImage(url: string): Promise<{
|
|
16
|
+
loadState: 'success' | 'fail';
|
|
17
|
+
data: HTMLImageElement | ImageData | null;
|
|
18
|
+
}>;
|
|
19
|
+
loadSvg(url: string): Promise<{
|
|
20
|
+
loadState: 'success' | 'fail';
|
|
21
|
+
data: HTMLImageElement | ImageData | null;
|
|
22
|
+
}>;
|
|
23
|
+
createCanvas(params: ICreateCanvasParams): ITTCanvas;
|
|
24
|
+
createOffscreenCanvas(params: ICreateCanvasParams): void;
|
|
25
|
+
releaseCanvas(canvas: ICanvasLike | string): void;
|
|
26
|
+
getDevicePixelRatio(): number;
|
|
27
|
+
getRequestAnimationFrame(): (callback: FrameRequestCallback) => number;
|
|
28
|
+
getCancelAnimationFrame(): (h: number) => void;
|
|
29
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
30
|
+
addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions | undefined): void;
|
|
31
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions | undefined): void;
|
|
32
|
+
removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions | undefined): void;
|
|
33
|
+
dispatchEvent(event: any): boolean;
|
|
34
|
+
getElementById(str: string): any | null;
|
|
35
|
+
getRootElement(): HTMLElement | null;
|
|
36
|
+
getDocument(): Document | null;
|
|
37
|
+
release(...params: any): void;
|
|
38
|
+
mapToCanvasPoint(event: any): any;
|
|
39
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __decorate = this && this.__decorate || function(decorators, target, key, desc) {
|
|
4
|
+
var d, c = arguments.length, r = c < 3 ? target : null === desc ? desc = Object.getOwnPropertyDescriptor(target, key) : desc;
|
|
5
|
+
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);
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
}, __metadata = this && this.__metadata || function(k, v) {
|
|
8
|
+
if ("object" == typeof Reflect && "function" == typeof Reflect.metadata) return Reflect.metadata(k, v);
|
|
9
|
+
}, __awaiter = this && this.__awaiter || function(thisArg, _arguments, P, generator) {
|
|
10
|
+
return new (P || (P = Promise))((function(resolve, reject) {
|
|
11
|
+
function fulfilled(value) {
|
|
12
|
+
try {
|
|
13
|
+
step(generator.next(value));
|
|
14
|
+
} catch (e) {
|
|
15
|
+
reject(e);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function rejected(value) {
|
|
19
|
+
try {
|
|
20
|
+
step(generator.throw(value));
|
|
21
|
+
} catch (e) {
|
|
22
|
+
reject(e);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function step(result) {
|
|
26
|
+
var value;
|
|
27
|
+
result.done ? resolve(result.value) : (value = result.value, value instanceof P ? value : new P((function(resolve) {
|
|
28
|
+
resolve(value);
|
|
29
|
+
}))).then(fulfilled, rejected);
|
|
30
|
+
}
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
}));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
Object.defineProperty(exports, "__esModule", {
|
|
36
|
+
value: !0
|
|
37
|
+
}), exports.WxEnvContribution = void 0;
|
|
38
|
+
|
|
39
|
+
const inversify_1 = require("inversify"), kits_1 = require("../../../kits"), base_contribution_1 = require("./base-contribution");
|
|
40
|
+
|
|
41
|
+
function makeUpCanvas(domref, canvasIdLists, canvasMap, freeCanvasIdx, freeCanvasList) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, (function*() {
|
|
43
|
+
const dpr = wx.getSystemInfoSync().pixelRatio;
|
|
44
|
+
for (let i = 0; i < canvasIdLists.length; i++) {
|
|
45
|
+
const id = canvasIdLists[i];
|
|
46
|
+
yield new Promise((resolve => {
|
|
47
|
+
wx.createSelectorQuery().select(`#${id}`).fields({
|
|
48
|
+
node: !0,
|
|
49
|
+
size: !0
|
|
50
|
+
}).exec((res => {
|
|
51
|
+
const canvas = res[0].node, width = res[0].width, height = res[0].height;
|
|
52
|
+
canvas.width = width * dpr, canvas.height = height * dpr, canvasMap.set(id, canvas),
|
|
53
|
+
i >= freeCanvasIdx && freeCanvasList.push(canvas), resolve(null);
|
|
54
|
+
}));
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
let WxEnvContribution = class extends base_contribution_1.BaseEnvContribution {
|
|
61
|
+
constructor() {
|
|
62
|
+
super(), this.type = "wx", this.supportEvent = !0, this.canvasMap = new Map, this.freeCanvasList = [],
|
|
63
|
+
this.canvasIdx = 0, this.supportsTouchEvents = !0;
|
|
64
|
+
try {
|
|
65
|
+
this.supportsPointerEvents = !!globalThis.PointerEvent, this.supportsMouseEvents = !!globalThis.MouseEvent;
|
|
66
|
+
} catch (err) {
|
|
67
|
+
this.supportsPointerEvents = !1, this.supportsMouseEvents = !1;
|
|
68
|
+
}
|
|
69
|
+
this.applyStyles = !0;
|
|
70
|
+
}
|
|
71
|
+
configure(service, params) {
|
|
72
|
+
if (service.env === this.type) return service.setActiveEnvContribution(this), makeUpCanvas(params.domref, params.canvasIdLists, this.canvasMap, params.freeCanvasIdx, this.freeCanvasList).then((() => {
|
|
73
|
+
(0, kits_1.loadFeishuContributions)();
|
|
74
|
+
}));
|
|
75
|
+
}
|
|
76
|
+
loadImage(url) {
|
|
77
|
+
return Promise.resolve({
|
|
78
|
+
data: url,
|
|
79
|
+
loadState: "success"
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
loadSvg(url) {
|
|
83
|
+
return Promise.reject();
|
|
84
|
+
}
|
|
85
|
+
createCanvas(params) {
|
|
86
|
+
const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];
|
|
87
|
+
return this.canvasIdx++, result;
|
|
88
|
+
}
|
|
89
|
+
createOffscreenCanvas(params) {}
|
|
90
|
+
releaseCanvas(canvas) {}
|
|
91
|
+
getDevicePixelRatio() {
|
|
92
|
+
return wx.getSystemInfoSync().pixelRatio;
|
|
93
|
+
}
|
|
94
|
+
getRequestAnimationFrame() {
|
|
95
|
+
return function(callback) {
|
|
96
|
+
return setTimeout(callback, 1e3 / 60, !0);
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
getCancelAnimationFrame() {
|
|
100
|
+
return h => {
|
|
101
|
+
clearTimeout(h);
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
addEventListener(type, listener, options) {
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
removeEventListener(type, listener, options) {
|
|
108
|
+
return null;
|
|
109
|
+
}
|
|
110
|
+
dispatchEvent(event) {
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
getElementById(str) {
|
|
114
|
+
return this.canvasMap.get(str);
|
|
115
|
+
}
|
|
116
|
+
getRootElement() {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
getDocument() {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
release(...params) {}
|
|
123
|
+
mapToCanvasPoint(event) {
|
|
124
|
+
var _a;
|
|
125
|
+
return (null === (_a = null == event ? void 0 : event.type) || void 0 === _a ? void 0 : _a.startsWith("mouse")) ? event : null;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
WxEnvContribution = __decorate([ (0, inversify_1.injectable)(), __metadata("design:paramtypes", []) ], WxEnvContribution),
|
|
130
|
+
exports.WxEnvContribution = WxEnvContribution;
|
|
131
|
+
//# sourceMappingURL=wx-contribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/contributions/env/wx-contribution.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,yCAAuC;AACvC,wCAAwD;AASxD,2DAA0D;AAS1D,SAAe,YAAY,CACzB,MAAW,EACX,aAAuB,EACvB,SAAiC,EACjC,aAAqB,EACrB,cAA2B;;QAE3B,MAAM,GAAG,GAAG,EAAE,CAAC,iBAAiB,EAAE,CAAC,UAAU,CAAC;QAE9C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC7C,MAAM,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;YAC5B,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;gBAC1B,E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B;QAMtB,OAAO,UAAU,QAA8B;YAC7C,OAAO,UAAU,CAAC,QAAQ,EAAE,IAAI,GAAG,EAAE,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAQ,CAAC;IACX,CAAC;IAED,uBAAuB;QACrB,OAAO,CAAC,CAAS,EAAE,EAAE;YACnB,YAAY,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC,CAAC;IACJ,CAAC;IAYD,gBAAgB,CAAC,IAAa,EAAE,QAAiB,EAAE,OAAiB;QAClE,OAAO,IAAI,CAAC;IACd,CAAC;IAYD,mBAAmB,CAAC,IAAa,EAAE,QAAiB,EAAE,OAAiB;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,aAAa,CAAC,KAAU;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAGD,cAAc,CAAC,GAAW;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,cAAc;QACZ,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CAAC,GAAG,MAAW;QACpB,OAAO;IACT,CAAC;IAED,gBAAgB,CAAC,KAAU;;QACzB,IAAI,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,0CAAE,UAAU,CAAC,OAAO,CAAC,EAAE;YACpC,OAAO,KAAK,CAAC;SACd;QACD,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAA;AAnJY,iBAAiB;IAD7B,IAAA,sBAAU,GAAE;;GACA,iBAAiB,CAmJ7B;AAnJY,8CAAiB","file":"wx-contribution.js","sourcesContent":["import { injectable } from 'inversify';\nimport { loadFeishuContributions } from '../../../kits';\nimport type {\n ICanvasLike,\n EnvType,\n ICreateCanvasParams,\n IEnvContribution,\n IGlobal,\n ITTCanvas\n} from '../../../interface';\nimport { BaseEnvContribution } from './base-contribution';\n\ndeclare const wx: {\n getSystemInfoSync: () => { pixelRatio: number };\n createCanvasContext: (id: string) => any;\n createSelectorQuery: () => any;\n};\n\n// 飞书小程序canvas的wrap\nasync function makeUpCanvas(\n domref: any,\n canvasIdLists: string[],\n canvasMap: Map<string, ITTCanvas>,\n freeCanvasIdx: number,\n freeCanvasList: ITTCanvas[]\n) {\n const dpr = wx.getSystemInfoSync().pixelRatio;\n\n for (let i = 0; i < canvasIdLists.length; i++) {\n const id = canvasIdLists[i];\n await new Promise(resolve => {\n wx.createSelectorQuery()\n .select(`#${id}`) // 在 WXML 中填入的 id\n .fields({ node: true, size: true })\n .exec((res: any) => {\n const canvas = res[0].node;\n const width = res[0].width;\n const height = res[0].height;\n canvas.width = width * dpr;\n canvas.height = height * dpr;\n canvasMap.set(id, canvas);\n if (i >= freeCanvasIdx) {\n freeCanvasList.push(canvas);\n }\n resolve(null);\n });\n });\n }\n\n // canvasIdLists.forEach((id, i) => {\n // const ctx = wx.createCanvasContext(id);\n // // TODO: 这里是一个临时方案,向 ctx 内部构造一个 canvas,传递宽高\n // ctx.canvas = {\n // width: domref.width * dpr,\n // height: domref.height * dpr\n // };\n\n // // 放到内容里\n // // // TODO: 这里是一个临时方案,兼容 createCircularGradient 方法\n // // ctx.createRadialGradient = (...cc) => ctx.createCircularGradient(...cc);\n\n // // // 封装 getImageData 为 promise\n // // ctx.getImageData = (x, y, width, height) =>\n // // new Promise((resolve, reject) => {\n // // try {\n // // tt.canvasGetImageData({\n // // canvasId: item.id,\n // // x,\n // // y,\n // // width,\n // // height,\n // // success(res) {\n // // resolve(res);\n // // },\n // // });\n // // } catch (err) {\n // // reject(err);\n // // }\n // // });\n\n // const canvas = {\n // width: domref.width,\n // height: domref.height,\n // offsetWidth: domref.width,\n // offsetHeight: domref.height,\n // id: id ?? '',\n // getContext: () => ctx,\n // // 构造 getBoundingClientRect 方法\n // getBoundingClientRect: () => ({\n // height: domref.height,\n // width: domref.width\n // })\n // };\n\n // canvasMap.set(id, canvas);\n // if (i >= freeCanvasIdx) {\n // freeCanvasList.push(canvas);\n // }\n // });\n}\n\n@injectable()\nexport class WxEnvContribution extends BaseEnvContribution implements IEnvContribution {\n type: EnvType = 'wx';\n supportEvent: boolean = true;\n // 所有添加进来的canvas\n canvasMap: Map<string, ITTCanvas> = new Map();\n // 所有可用的canvasList\n freeCanvasList: ITTCanvas[] = [];\n canvasIdx: number = 0;\n\n constructor() {\n super();\n this.supportsTouchEvents = true;\n try {\n this.supportsPointerEvents = !!globalThis.PointerEvent;\n this.supportsMouseEvents = !!globalThis.MouseEvent;\n } catch (err) {\n this.supportsPointerEvents = false;\n this.supportsMouseEvents = false;\n }\n this.applyStyles = true;\n }\n\n // TODO:VGrammar在小程序环境会重复调用setEnv传入canvas,所以每次configure并不会释放\n // 这里等待后续和VGrammar沟通\n configure(service: IGlobal, params: { domref: any; canvasIdLists: string[]; freeCanvasIdx: number }) {\n if (service.env === this.type) {\n service.setActiveEnvContribution(this);\n return makeUpCanvas(\n params.domref,\n params.canvasIdLists,\n this.canvasMap,\n params.freeCanvasIdx,\n this.freeCanvasList\n ).then(() => {\n loadFeishuContributions();\n });\n }\n }\n\n loadImage(url: string): Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }> {\n return Promise.resolve({\n data: url as unknown as HTMLImageElement,\n loadState: 'success'\n });\n }\n\n loadSvg(url: string): Promise<{\n loadState: 'success' | 'fail';\n data: HTMLImageElement | ImageData | null;\n }> {\n // 飞书小组件不支持DOMParser和URL.createObjectURL,无法解析svg字符串,可以通过url使用svg资源\n return Promise.reject();\n }\n\n createCanvas(params: ICreateCanvasParams): ITTCanvas {\n const result = this.freeCanvasList[this.canvasIdx] || this.freeCanvasList[this.freeCanvasList.length - 1];\n this.canvasIdx++;\n return result;\n }\n\n createOffscreenCanvas(params: ICreateCanvasParams) {\n return;\n }\n\n releaseCanvas(canvas: ICanvasLike | string) {\n return;\n }\n\n getDevicePixelRatio(): number {\n return wx.getSystemInfoSync().pixelRatio;\n }\n\n getRequestAnimationFrame(): (callback: FrameRequestCallback) => number {\n // return requestAnimationFrame;\n\n // 飞书小组件,在云文档浏览器环境中,没有requestAnimationFrame\n // 但是在小组件工作台环境和模拟器中正常\n // 反馈飞书修改,目前先使用setTimeout模拟,进行测试,飞书修复后替换回requestAnimationFrame\n return function (callback: FrameRequestCallback) {\n return setTimeout(callback, 1000 / 60, true);\n } as any;\n }\n\n getCancelAnimationFrame(): (h: number) => void {\n return (h: number) => {\n clearTimeout(h);\n };\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 null;\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 null;\n }\n\n dispatchEvent(event: any): boolean {\n return null;\n }\n\n // 只能索引canvas\n getElementById(str: string): any | null {\n return this.canvasMap.get(str);\n }\n\n getRootElement(): HTMLElement | null {\n return null;\n }\n\n getDocument(): Document | null {\n return null;\n }\n\n release(...params: any): void {\n return;\n }\n\n mapToCanvasPoint(event: any) {\n if (event?.type?.startsWith('mouse')) {\n return event;\n }\n return null;\n }\n}\n"]}
|
|
@@ -4,13 +4,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: !0
|
|
5
5
|
});
|
|
6
6
|
|
|
7
|
-
const inversify_1 = require("inversify"), window_1 = require("../../window"), browser_contribution_1 = require("./browser-contribution"), feishu_contribution_1 = require("./feishu-contribution"), taro_contribution_1 = require("./taro-contribution"), lynx_contribution_1 = require("./lynx-contribution"), node_contribution_1 = require("./node-contribution");
|
|
7
|
+
const inversify_1 = require("inversify"), window_1 = require("../../window"), browser_contribution_1 = require("./browser-contribution"), feishu_contribution_1 = require("./feishu-contribution"), taro_contribution_1 = require("./taro-contribution"), lynx_contribution_1 = require("./lynx-contribution"), node_contribution_1 = require("./node-contribution"), wx_contribution_1 = require("./wx-contribution");
|
|
8
8
|
|
|
9
9
|
exports.default = new inversify_1.ContainerModule((bind => {
|
|
10
10
|
bind(browser_contribution_1.BrowserWindowHandlerContribution).toSelf(), bind(window_1.WindowHandlerContribution).toDynamicValue((ctx => ctx.container.get(browser_contribution_1.BrowserWindowHandlerContribution))).whenTargetNamed(browser_contribution_1.BrowserWindowHandlerContribution.env),
|
|
11
11
|
bind(feishu_contribution_1.FeishuWindowHandlerContribution).toSelf(), bind(window_1.WindowHandlerContribution).toDynamicValue((ctx => ctx.container.get(feishu_contribution_1.FeishuWindowHandlerContribution))).whenTargetNamed(feishu_contribution_1.FeishuWindowHandlerContribution.env),
|
|
12
12
|
bind(taro_contribution_1.TaroWindowHandlerContribution).toSelf(), bind(window_1.WindowHandlerContribution).toDynamicValue((ctx => ctx.container.get(taro_contribution_1.TaroWindowHandlerContribution))).whenTargetNamed(taro_contribution_1.TaroWindowHandlerContribution.env),
|
|
13
13
|
bind(lynx_contribution_1.LynxWindowHandlerContribution).toSelf(), bind(window_1.WindowHandlerContribution).toDynamicValue((ctx => ctx.container.get(lynx_contribution_1.LynxWindowHandlerContribution))).whenTargetNamed(lynx_contribution_1.LynxWindowHandlerContribution.env),
|
|
14
|
+
bind(wx_contribution_1.WxWindowHandlerContribution).toSelf(), bind(window_1.WindowHandlerContribution).toDynamicValue((ctx => ctx.container.get(wx_contribution_1.WxWindowHandlerContribution))).whenTargetNamed(wx_contribution_1.WxWindowHandlerContribution.env),
|
|
14
15
|
bind(node_contribution_1.NodeWindowHandlerContribution).toSelf(), bind(window_1.WindowHandlerContribution).toDynamicValue((ctx => ctx.container.get(node_contribution_1.NodeWindowHandlerContribution))).whenTargetNamed(node_contribution_1.NodeWindowHandlerContribution.env);
|
|
15
16
|
}));
|
|
16
17
|
//# sourceMappingURL=modules.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/contributions/window/modules.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAC5C,yCAAyD;AACzD,iEAA0E;AAC1E,+DAAwE;AACxE,2DAAoE;AACpE,2DAAoE;AACpE,2DAAoE;
|
|
1
|
+
{"version":3,"sources":["../../src/core/contributions/window/modules.ts"],"names":[],"mappings":";;AAAA,yCAA4C;AAC5C,yCAAyD;AACzD,iEAA0E;AAC1E,+DAAwE;AACxE,2DAAoE;AACpE,2DAAoE;AACpE,2DAAoE;AACpE,uDAAgE;AAGhE,kBAAe,IAAI,2BAAe,CAAC,IAAI,CAAC,EAAE;IAExC,IAAI,CAAC,uDAAgC,CAAC,CAAC,MAAM,EAAE,CAAC;IAChD,IAAI,CAAC,kCAAyB,CAAC;SAC5B,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,uDAAgC,CAAC,CAAC;SAC1E,eAAe,CAAC,uDAAgC,CAAC,GAAG,CAAC,CAAC;IAGzD,IAAI,CAAC,qDAA+B,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/C,IAAI,CAAC,kCAAyB,CAAC;SAC5B,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,qDAA+B,CAAC,CAAC;SACzE,eAAe,CAAC,qDAA+B,CAAC,GAAG,CAAC,CAAC;IAGxD,IAAI,CAAC,iDAA6B,CAAC,CAAC,MAAM,EAAE,CAAC;IAE7C,IAAI,CAAC,kCAAyB,CAAC;SAC5B,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,iDAA6B,CAAC,CAAC;SACvE,eAAe,CAAC,iDAA6B,CAAC,GAAG,CAAC,CAAC;IAGtD,IAAI,CAAC,iDAA6B,CAAC,CAAC,MAAM,EAAE,CAAC;IAE7C,IAAI,CAAC,kCAAyB,CAAC;SAC5B,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,iDAA6B,CAAC,CAAC;SACvE,eAAe,CAAC,iDAA6B,CAAC,GAAG,CAAC,CAAC;IAGtD,IAAI,CAAC,6CAA2B,CAAC,CAAC,MAAM,EAAE,CAAC;IAE3C,IAAI,CAAC,kCAAyB,CAAC;SAC5B,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,6CAA2B,CAAC,CAAC;SACrE,eAAe,CAAC,6CAA2B,CAAC,GAAG,CAAC,CAAC;IAGpD,IAAI,CAAC,iDAA6B,CAAC,CAAC,MAAM,EAAE,CAAC;IAE7C,IAAI,CAAC,kCAAyB,CAAC;SAC5B,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,iDAA6B,CAAC,CAAC;SACvE,eAAe,CAAC,iDAA6B,CAAC,GAAG,CAAC,CAAC;AAIxD,CAAC,CAAC,CAAC","file":"modules.js","sourcesContent":["import { ContainerModule } from 'inversify';\nimport { WindowHandlerContribution } from '../../window';\nimport { BrowserWindowHandlerContribution } from './browser-contribution';\nimport { FeishuWindowHandlerContribution } from './feishu-contribution';\nimport { TaroWindowHandlerContribution } from './taro-contribution';\nimport { LynxWindowHandlerContribution } from './lynx-contribution';\nimport { NodeWindowHandlerContribution } from './node-contribution';\nimport { WxWindowHandlerContribution } from './wx-contribution';\n// import { NodeWindowHandlerContribution } from './node-contribution';\n\nexport default new ContainerModule(bind => {\n // browser\n bind(BrowserWindowHandlerContribution).toSelf();\n bind(WindowHandlerContribution)\n .toDynamicValue(ctx => ctx.container.get(BrowserWindowHandlerContribution))\n .whenTargetNamed(BrowserWindowHandlerContribution.env);\n\n // feishu\n bind(FeishuWindowHandlerContribution).toSelf();\n bind(WindowHandlerContribution)\n .toDynamicValue(ctx => ctx.container.get(FeishuWindowHandlerContribution))\n .whenTargetNamed(FeishuWindowHandlerContribution.env);\n\n // taro\n bind(TaroWindowHandlerContribution).toSelf();\n\n bind(WindowHandlerContribution)\n .toDynamicValue(ctx => ctx.container.get(TaroWindowHandlerContribution))\n .whenTargetNamed(TaroWindowHandlerContribution.env);\n\n // lynx\n bind(LynxWindowHandlerContribution).toSelf();\n\n bind(WindowHandlerContribution)\n .toDynamicValue(ctx => ctx.container.get(LynxWindowHandlerContribution))\n .whenTargetNamed(LynxWindowHandlerContribution.env);\n\n // wx\n bind(WxWindowHandlerContribution).toSelf();\n\n bind(WindowHandlerContribution)\n .toDynamicValue(ctx => ctx.container.get(WxWindowHandlerContribution))\n .whenTargetNamed(WxWindowHandlerContribution.env);\n\n // node\n bind(NodeWindowHandlerContribution).toSelf();\n\n bind(WindowHandlerContribution)\n .toDynamicValue(ctx => ctx.container.get(NodeWindowHandlerContribution))\n .whenTargetNamed(NodeWindowHandlerContribution.env);\n // bind(NodeWindowHandlerContribution).toSelf().inSingletonScope();\n // bind(WindowHandlerContribution).toService(NodeWindowHandlerContribution);\n // bindContributionProvider(bind, WindowHandlerContribution);\n});\n"]}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { BaseWindowHandlerContribution } from './base-contribution';
|
|
2
|
+
import type { EnvType, IGlobal, IContext2d, ICanvas, IDomRectLike, IWindowHandlerContribution, IWindowParams } from '../../../interface';
|
|
3
|
+
import type { IBoundsLike } from '@visactor/vutils';
|
|
4
|
+
declare class MiniAppEventManager {
|
|
5
|
+
addEventListener(type: string, func: EventListenerOrEventListenerObject): void;
|
|
6
|
+
removeEventListener(type: string, func: EventListenerOrEventListenerObject): void;
|
|
7
|
+
cleanEvent(): void;
|
|
8
|
+
cache: Record<string, {
|
|
9
|
+
listener: EventListenerOrEventListenerObject[];
|
|
10
|
+
}>;
|
|
11
|
+
}
|
|
12
|
+
export declare class WxWindowHandlerContribution extends BaseWindowHandlerContribution implements IWindowHandlerContribution {
|
|
13
|
+
private readonly global;
|
|
14
|
+
static env: EnvType;
|
|
15
|
+
type: EnvType;
|
|
16
|
+
protected eventManager: MiniAppEventManager;
|
|
17
|
+
canvas: ICanvas;
|
|
18
|
+
get container(): HTMLElement | null;
|
|
19
|
+
constructor(global: IGlobal);
|
|
20
|
+
getTitle(): string;
|
|
21
|
+
getWH(): {
|
|
22
|
+
width: number;
|
|
23
|
+
height: number;
|
|
24
|
+
};
|
|
25
|
+
getXY(): {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
};
|
|
29
|
+
createWindow(params: IWindowParams): void;
|
|
30
|
+
private createWindowByConfig;
|
|
31
|
+
private createWindowByCanvas;
|
|
32
|
+
releaseWindow(): void;
|
|
33
|
+
resizeWindow(width: number, height: number): void;
|
|
34
|
+
setDpr(dpr: number): void;
|
|
35
|
+
getContext(): IContext2d;
|
|
36
|
+
getNativeHandler(): ICanvas;
|
|
37
|
+
getDpr(): number;
|
|
38
|
+
addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
|
|
39
|
+
removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
|
|
40
|
+
dispatchEvent(event: any): boolean;
|
|
41
|
+
getStyle(): CSSStyleDeclaration | Record<string, any>;
|
|
42
|
+
setStyle(style: CSSStyleDeclaration | Record<string, any>): void;
|
|
43
|
+
getBoundingClientRect(): IDomRectLike;
|
|
44
|
+
clearViewBox(vb: IBoundsLike, color?: string): void;
|
|
45
|
+
}
|
|
46
|
+
export {};
|