@jbrowse/core 1.7.7 → 1.7.10
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/BaseFeatureWidget/BaseFeatureDetail.d.ts +3 -6
- package/BaseFeatureWidget/BaseFeatureDetail.js +158 -103
- package/BaseFeatureWidget/index.d.ts +23 -2
- package/BaseFeatureWidget/index.js +98 -3
- package/assemblyManager/assemblyManager.d.ts +1 -1
- package/assemblyManager/assemblyManager.js +21 -27
- package/package.json +6 -2
- package/pluggableElementTypes/models/InternetAccountModel.d.ts +2 -2
- package/pluggableElementTypes/models/baseTrackConfig.js +20 -13
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +6 -14
- package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +6 -0
- package/pluggableElementTypes/renderers/ServerSideRendererType.js +44 -2
- package/pluggableElementTypes/renderers/declare.d.js +1 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/AboutDialog.d.ts +1 -1
- package/ui/AboutDialog.js +24 -7
- package/ui/CascadingMenu.d.ts +9 -0
- package/ui/CascadingMenu.js +211 -0
- package/ui/Menu.d.ts +10 -0
- package/ui/Menu.js +9 -14
- package/ui/SanitizedHTML.js +26 -4
- package/ui/SnackbarModel.d.ts +2 -2
- package/ui/index.d.ts +1 -0
- package/ui/index.js +9 -0
- package/util/declare.d.js +1 -0
- package/util/index.d.ts +3 -0
- package/util/index.js +35 -1
- package/util/jexl.js +42 -43
- package/util/offscreenCanvasPonyfill.d.ts +8 -1
- package/util/offscreenCanvasPonyfill.js +140 -12
- package/util/offscreenCanvasUtils.d.ts +19 -1
- package/util/offscreenCanvasUtils.js +146 -12
- package/util/types/index.d.ts +1 -1
- package/util/types/mst.d.ts +9 -9
- package/util/offscreenCanvas/Canvas2DContextShim/Canvas2DContextShim.test.js +0 -15
- package/util/offscreenCanvas/Canvas2DContextShim/context.d.ts +0 -56
- package/util/offscreenCanvas/Canvas2DContextShim/context.js +0 -356
- package/util/offscreenCanvas/Canvas2DContextShim/index.d.ts +0 -2
- package/util/offscreenCanvas/Canvas2DContextShim/index.js +0 -13
- package/util/offscreenCanvas/Canvas2DContextShim/svg.d.ts +0 -3
- package/util/offscreenCanvas/Canvas2DContextShim/svg.js +0 -210
- package/util/offscreenCanvas/Canvas2DContextShim/types.d.ts +0 -50
- package/util/offscreenCanvas/Canvas2DContextShim/types.js +0 -59
- package/util/offscreenCanvas/Canvas2DContextShim/util.d.ts +0 -12
- package/util/offscreenCanvas/Canvas2DContextShim/util.js +0 -91
- package/util/offscreenCanvas/CanvasShim.d.ts +0 -11
- package/util/offscreenCanvas/CanvasShim.js +0 -54
- package/util/offscreenCanvas/index.d.ts +0 -14
- package/util/offscreenCanvas/index.js +0 -170
- package/util/offscreenCanvas/ponyfill.d.ts +0 -6
- package/util/offscreenCanvas/ponyfill.js +0 -145
- package/util/offscreenCanvas/types.d.ts +0 -16
- package/util/offscreenCanvas/types.js +0 -14
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export declare function splitColor(color?: string): {
|
|
2
|
-
hex: string;
|
|
3
|
-
opacity: number;
|
|
4
|
-
};
|
|
5
|
-
export declare function parseFont(font: string): {
|
|
6
|
-
fontStyle: string;
|
|
7
|
-
fontVariant: string;
|
|
8
|
-
fontWeight: string;
|
|
9
|
-
fontSize: string | undefined;
|
|
10
|
-
lineHeight: string;
|
|
11
|
-
fontFamily: string | undefined;
|
|
12
|
-
};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.parseFont = parseFont;
|
|
9
|
-
exports.splitColor = splitColor;
|
|
10
|
-
|
|
11
|
-
var _color = _interopRequireDefault(require("color"));
|
|
12
|
-
|
|
13
|
-
function splitColor(color) {
|
|
14
|
-
var fill = (0, _color.default)(color);
|
|
15
|
-
return {
|
|
16
|
-
hex: fill.hex(),
|
|
17
|
-
opacity: fill.alpha()
|
|
18
|
-
};
|
|
19
|
-
} // https://stackoverflow.com/a/5620441/2129219
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
function parseFont(font) {
|
|
23
|
-
var fontFamily = undefined;
|
|
24
|
-
var fontSize = undefined;
|
|
25
|
-
var fontStyle = 'normal';
|
|
26
|
-
var fontWeight = 'normal';
|
|
27
|
-
var fontVariant = 'normal';
|
|
28
|
-
var lineHeight = 'normal';
|
|
29
|
-
var elements = font.split(/\s+/);
|
|
30
|
-
var element;
|
|
31
|
-
|
|
32
|
-
outer: while (element = elements.shift()) {
|
|
33
|
-
switch (element) {
|
|
34
|
-
case 'normal':
|
|
35
|
-
break;
|
|
36
|
-
|
|
37
|
-
case 'italic':
|
|
38
|
-
case 'oblique':
|
|
39
|
-
fontStyle = element;
|
|
40
|
-
break;
|
|
41
|
-
|
|
42
|
-
case 'small-caps':
|
|
43
|
-
fontVariant = element;
|
|
44
|
-
break;
|
|
45
|
-
|
|
46
|
-
case 'bold':
|
|
47
|
-
case 'bolder':
|
|
48
|
-
case 'lighter':
|
|
49
|
-
case '100':
|
|
50
|
-
case '200':
|
|
51
|
-
case '300':
|
|
52
|
-
case '400':
|
|
53
|
-
case '500':
|
|
54
|
-
case '600':
|
|
55
|
-
case '700':
|
|
56
|
-
case '800':
|
|
57
|
-
case '900':
|
|
58
|
-
fontWeight = element;
|
|
59
|
-
break;
|
|
60
|
-
|
|
61
|
-
default:
|
|
62
|
-
if (!fontSize) {
|
|
63
|
-
var parts = element.split('/');
|
|
64
|
-
fontSize = parts[0];
|
|
65
|
-
|
|
66
|
-
if (parts.length > 1) {
|
|
67
|
-
lineHeight = parts[1];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
break;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
fontFamily = element;
|
|
74
|
-
|
|
75
|
-
if (elements.length) {
|
|
76
|
-
fontFamily += " ".concat(elements.join(' '));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
break outer;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
return {
|
|
84
|
-
fontStyle: fontStyle,
|
|
85
|
-
fontVariant: fontVariant,
|
|
86
|
-
fontWeight: fontWeight,
|
|
87
|
-
fontSize: fontSize,
|
|
88
|
-
lineHeight: lineHeight,
|
|
89
|
-
fontFamily: fontFamily
|
|
90
|
-
};
|
|
91
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import OffscreenCanvasRenderingContext2DShim from './Canvas2DContextShim';
|
|
3
|
-
export default class OffscreenCanvasShim {
|
|
4
|
-
width: number;
|
|
5
|
-
height: number;
|
|
6
|
-
context: OffscreenCanvasRenderingContext2DShim;
|
|
7
|
-
constructor(width: number, height: number);
|
|
8
|
-
getContext(type: '2d'): OffscreenCanvasRenderingContext2DShim;
|
|
9
|
-
toDataURL(): string;
|
|
10
|
-
getSerializedSvg(): JSX.Element;
|
|
11
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _Canvas2DContextShim = _interopRequireDefault(require("./Canvas2DContextShim"));
|
|
17
|
-
|
|
18
|
-
var OffscreenCanvasShim = /*#__PURE__*/function () {
|
|
19
|
-
function OffscreenCanvasShim(width, height) {
|
|
20
|
-
(0, _classCallCheck2.default)(this, OffscreenCanvasShim);
|
|
21
|
-
(0, _defineProperty2.default)(this, "width", void 0);
|
|
22
|
-
(0, _defineProperty2.default)(this, "height", void 0);
|
|
23
|
-
(0, _defineProperty2.default)(this, "context", void 0);
|
|
24
|
-
this.width = width;
|
|
25
|
-
this.height = height;
|
|
26
|
-
this.context = new _Canvas2DContextShim.default(this.width, this.height);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
(0, _createClass2.default)(OffscreenCanvasShim, [{
|
|
30
|
-
key: "getContext",
|
|
31
|
-
value: function getContext(type) {
|
|
32
|
-
if (type !== '2d') {
|
|
33
|
-
throw new Error("unknown type ".concat(type));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return this.context;
|
|
37
|
-
}
|
|
38
|
-
}, {
|
|
39
|
-
key: "toDataURL",
|
|
40
|
-
value: function toDataURL() {
|
|
41
|
-
throw new Error('not supported');
|
|
42
|
-
}
|
|
43
|
-
}, {
|
|
44
|
-
key: "getSerializedSvg",
|
|
45
|
-
value: function getSerializedSvg() {
|
|
46
|
-
var _this$context;
|
|
47
|
-
|
|
48
|
-
return (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.getSerializedSvg();
|
|
49
|
-
}
|
|
50
|
-
}]);
|
|
51
|
-
return OffscreenCanvasShim;
|
|
52
|
-
}();
|
|
53
|
-
|
|
54
|
-
exports.default = OffscreenCanvasShim;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
export * from './CanvasShim';
|
|
3
|
-
export declare function renderToAbstractCanvas(width: number, height: number, opts: {
|
|
4
|
-
exportSVG?: {
|
|
5
|
-
rasterizeLayers?: boolean;
|
|
6
|
-
};
|
|
7
|
-
highResolutionScaling: number;
|
|
8
|
-
}, cb: Function): Promise<{
|
|
9
|
-
reactElement: JSX.Element;
|
|
10
|
-
imageData?: undefined;
|
|
11
|
-
} | {
|
|
12
|
-
imageData: import("./types").AbstractImageBitmap;
|
|
13
|
-
reactElement?: undefined;
|
|
14
|
-
}>;
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "__esModule", {
|
|
8
|
-
value: true
|
|
9
|
-
});
|
|
10
|
-
var _exportNames = {
|
|
11
|
-
renderToAbstractCanvas: true
|
|
12
|
-
};
|
|
13
|
-
exports.renderToAbstractCanvas = renderToAbstractCanvas;
|
|
14
|
-
|
|
15
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
16
|
-
|
|
17
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
18
|
-
|
|
19
|
-
var _react = _interopRequireDefault(require("react"));
|
|
20
|
-
|
|
21
|
-
var _ponyfill = require("./ponyfill");
|
|
22
|
-
|
|
23
|
-
var _CanvasShim = _interopRequireWildcard(require("./CanvasShim"));
|
|
24
|
-
|
|
25
|
-
Object.keys(_CanvasShim).forEach(function (key) {
|
|
26
|
-
if (key === "default" || key === "__esModule") return;
|
|
27
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
28
|
-
if (key in exports && exports[key] === _CanvasShim[key]) return;
|
|
29
|
-
Object.defineProperty(exports, key, {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function get() {
|
|
32
|
-
return _CanvasShim[key];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var _ = require("..");
|
|
38
|
-
|
|
39
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
40
|
-
|
|
41
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
42
|
-
|
|
43
|
-
function renderToAbstractCanvas(_x, _x2, _x3, _x4) {
|
|
44
|
-
return _renderToAbstractCanvas.apply(this, arguments);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function _renderToAbstractCanvas() {
|
|
48
|
-
_renderToAbstractCanvas = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(width, height, opts, cb) {
|
|
49
|
-
var exportSVG, _opts$highResolutionS, highResolutionScaling, fakeCanvas, fakeCtx, scale, _canvas, _ctx, canvas, ctx;
|
|
50
|
-
|
|
51
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
52
|
-
while (1) {
|
|
53
|
-
switch (_context.prev = _context.next) {
|
|
54
|
-
case 0:
|
|
55
|
-
exportSVG = opts.exportSVG, _opts$highResolutionS = opts.highResolutionScaling, highResolutionScaling = _opts$highResolutionS === void 0 ? 1 : _opts$highResolutionS;
|
|
56
|
-
|
|
57
|
-
if (!(exportSVG && !exportSVG.rasterizeLayers)) {
|
|
58
|
-
_context.next = 7;
|
|
59
|
-
break;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
fakeCanvas = new _CanvasShim.default(width, height);
|
|
63
|
-
fakeCtx = fakeCanvas.getContext('2d');
|
|
64
|
-
_context.next = 6;
|
|
65
|
-
return cb(fakeCtx);
|
|
66
|
-
|
|
67
|
-
case 6:
|
|
68
|
-
return _context.abrupt("return", {
|
|
69
|
-
reactElement: fakeCanvas.getSerializedSvg()
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
case 7:
|
|
73
|
-
if (!(exportSVG && exportSVG.rasterizeLayers)) {
|
|
74
|
-
_context.next = 34;
|
|
75
|
-
break;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
scale = 4;
|
|
79
|
-
_canvas = (0, _ponyfill.createCanvas)(Math.ceil(width * scale), height * scale);
|
|
80
|
-
_ctx = _canvas.getContext('2d');
|
|
81
|
-
|
|
82
|
-
if (_ctx) {
|
|
83
|
-
_context.next = 13;
|
|
84
|
-
break;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
throw new Error('2d canvas rendering not supported on this platform');
|
|
88
|
-
|
|
89
|
-
case 13:
|
|
90
|
-
_ctx.scale(scale, scale);
|
|
91
|
-
|
|
92
|
-
_context.next = 16;
|
|
93
|
-
return cb(_ctx);
|
|
94
|
-
|
|
95
|
-
case 16:
|
|
96
|
-
_context.t0 = _react.default;
|
|
97
|
-
_context.t1 = width;
|
|
98
|
-
_context.t2 = height;
|
|
99
|
-
|
|
100
|
-
if (!('convertToBlob' in _canvas)) {
|
|
101
|
-
_context.next = 29;
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
_context.t4 = _.blobToDataURL;
|
|
106
|
-
_context.next = 23;
|
|
107
|
-
return _canvas.convertToBlob({
|
|
108
|
-
type: 'image/png'
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
case 23:
|
|
112
|
-
_context.t5 = _context.sent;
|
|
113
|
-
_context.next = 26;
|
|
114
|
-
return (0, _context.t4)(_context.t5);
|
|
115
|
-
|
|
116
|
-
case 26:
|
|
117
|
-
_context.t3 = _context.sent;
|
|
118
|
-
_context.next = 30;
|
|
119
|
-
break;
|
|
120
|
-
|
|
121
|
-
case 29:
|
|
122
|
-
_context.t3 = _canvas.toDataURL();
|
|
123
|
-
|
|
124
|
-
case 30:
|
|
125
|
-
_context.t6 = _context.t3;
|
|
126
|
-
_context.t7 = {
|
|
127
|
-
width: _context.t1,
|
|
128
|
-
height: _context.t2,
|
|
129
|
-
xlinkHref: _context.t6
|
|
130
|
-
};
|
|
131
|
-
_context.t8 = _context.t0.createElement.call(_context.t0, "image", _context.t7);
|
|
132
|
-
return _context.abrupt("return", {
|
|
133
|
-
reactElement: _context.t8
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
case 34:
|
|
137
|
-
canvas = (0, _ponyfill.createCanvas)(Math.ceil(width * highResolutionScaling), height * highResolutionScaling);
|
|
138
|
-
ctx = canvas.getContext('2d');
|
|
139
|
-
|
|
140
|
-
if (ctx) {
|
|
141
|
-
_context.next = 38;
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
throw new Error('2d canvas rendering not supported on this platform');
|
|
146
|
-
|
|
147
|
-
case 38:
|
|
148
|
-
ctx.scale(highResolutionScaling, highResolutionScaling);
|
|
149
|
-
_context.next = 41;
|
|
150
|
-
return cb(ctx);
|
|
151
|
-
|
|
152
|
-
case 41:
|
|
153
|
-
_context.next = 43;
|
|
154
|
-
return (0, _ponyfill.createImageBitmap)(canvas);
|
|
155
|
-
|
|
156
|
-
case 43:
|
|
157
|
-
_context.t9 = _context.sent;
|
|
158
|
-
return _context.abrupt("return", {
|
|
159
|
-
imageData: _context.t9
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
case 45:
|
|
163
|
-
case "end":
|
|
164
|
-
return _context.stop();
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
}, _callee);
|
|
168
|
-
}));
|
|
169
|
-
return _renderToAbstractCanvas.apply(this, arguments);
|
|
170
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { AbstractCanvas, AbstractImageBitmap } from './types';
|
|
2
|
-
export declare let createCanvas: (width: number, height: number) => AbstractCanvas;
|
|
3
|
-
export declare let createImageBitmap: (canvas: AbstractCanvas) => Promise<AbstractImageBitmap>;
|
|
4
|
-
/** the JS class (constructor) for offscreen-generated image bitmap data */
|
|
5
|
-
export declare let ImageBitmapType: Function;
|
|
6
|
-
export declare function drawImageOntoCanvasContext(imageData: AbstractImageBitmap, context: CanvasRenderingContext2D): void;
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createImageBitmap = exports.createCanvas = exports.ImageBitmapType = void 0;
|
|
9
|
-
exports.drawImageOntoCanvasContext = drawImageOntoCanvasContext;
|
|
10
|
-
|
|
11
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
12
|
-
|
|
13
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
14
|
-
|
|
15
|
-
var _detectNode = _interopRequireDefault(require("detect-node"));
|
|
16
|
-
|
|
17
|
-
var _CanvasShim = _interopRequireDefault(require("./CanvasShim"));
|
|
18
|
-
|
|
19
|
-
var _types = require("./types");
|
|
20
|
-
|
|
21
|
-
var _context3 = require("./Canvas2DContextShim/context");
|
|
22
|
-
|
|
23
|
-
// This file is a ponyfill for the HTML5 OffscreenCanvas API.
|
|
24
|
-
var createCanvas;
|
|
25
|
-
exports.createCanvas = createCanvas;
|
|
26
|
-
var createImageBitmap;
|
|
27
|
-
/** the JS class (constructor) for offscreen-generated image bitmap data */
|
|
28
|
-
|
|
29
|
-
exports.createImageBitmap = createImageBitmap;
|
|
30
|
-
var ImageBitmapType;
|
|
31
|
-
exports.ImageBitmapType = ImageBitmapType;
|
|
32
|
-
|
|
33
|
-
function drawImageOntoCanvasContext(imageData, context) {
|
|
34
|
-
if ((0, _types.isCanvasImageDataShim)(imageData)) {
|
|
35
|
-
(0, _context3.replayCommandsOntoContext)(context, imageData.serializedCommands);
|
|
36
|
-
} else if (imageData instanceof ImageBitmapType) {
|
|
37
|
-
context.drawImage(imageData, 0, 0); // @ts-ignore
|
|
38
|
-
} else if (imageData.dataURL) {
|
|
39
|
-
throw new Error('dataURL deserialization no longer supported'); // const img = new Image()
|
|
40
|
-
// img.onload = () => context.drawImage(img, 0, 0)
|
|
41
|
-
// img.src = imageData.dataURL
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
var weHave = {
|
|
46
|
-
realOffscreenCanvas: typeof OffscreenCanvas === 'function',
|
|
47
|
-
node: _detectNode.default
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
if (weHave.realOffscreenCanvas) {
|
|
51
|
-
exports.createCanvas = createCanvas = function createCanvas(width, height) {
|
|
52
|
-
return new OffscreenCanvas(width, height);
|
|
53
|
-
}; // @ts-ignore
|
|
54
|
-
// eslint-disable-next-line no-restricted-globals
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
exports.createImageBitmap = createImageBitmap = window.createImageBitmap || self.createImageBitmap; // eslint-disable-next-line no-restricted-globals
|
|
58
|
-
|
|
59
|
-
exports.ImageBitmapType = ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
|
|
60
|
-
} else if (weHave.node) {
|
|
61
|
-
// use node-canvas if we are running in node (i.e. automated tests)
|
|
62
|
-
var _require = require('canvas'),
|
|
63
|
-
nodeCreateCanvas = _require.createCanvas,
|
|
64
|
-
Image = _require.Image;
|
|
65
|
-
|
|
66
|
-
exports.createCanvas = createCanvas = nodeCreateCanvas;
|
|
67
|
-
|
|
68
|
-
exports.createImageBitmap = createImageBitmap = /*#__PURE__*/function () {
|
|
69
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(canvas) {
|
|
70
|
-
var dataUri,
|
|
71
|
-
img,
|
|
72
|
-
_args = arguments;
|
|
73
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
74
|
-
while (1) {
|
|
75
|
-
switch (_context.prev = _context.next) {
|
|
76
|
-
case 0:
|
|
77
|
-
if (!(_args.length <= 1 ? 0 : _args.length - 1)) {
|
|
78
|
-
_context.next = 2;
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
throw new Error('only one-argument uses of createImageBitmap are supported by the node offscreencanvas ponyfill');
|
|
83
|
-
|
|
84
|
-
case 2:
|
|
85
|
-
dataUri = canvas.toDataURL();
|
|
86
|
-
img = new Image();
|
|
87
|
-
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
88
|
-
img.onload = function () {
|
|
89
|
-
return resolve(img);
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
img.onerror = reject;
|
|
93
|
-
img.src = dataUri;
|
|
94
|
-
}));
|
|
95
|
-
|
|
96
|
-
case 5:
|
|
97
|
-
case "end":
|
|
98
|
-
return _context.stop();
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
}, _callee);
|
|
102
|
-
}));
|
|
103
|
-
|
|
104
|
-
return function createImageBitmap(_x) {
|
|
105
|
-
return _ref.apply(this, arguments);
|
|
106
|
-
};
|
|
107
|
-
}();
|
|
108
|
-
|
|
109
|
-
exports.ImageBitmapType = ImageBitmapType = Image;
|
|
110
|
-
} else {
|
|
111
|
-
exports.createCanvas = createCanvas = function createCanvas(width, height) {
|
|
112
|
-
return new _CanvasShim.default(width, height);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
exports.createImageBitmap = createImageBitmap = /*#__PURE__*/function () {
|
|
116
|
-
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(canvas) {
|
|
117
|
-
var ctx, d;
|
|
118
|
-
return _regenerator.default.wrap(function _callee2$(_context2) {
|
|
119
|
-
while (1) {
|
|
120
|
-
switch (_context2.prev = _context2.next) {
|
|
121
|
-
case 0:
|
|
122
|
-
ctx = canvas.getContext('2d');
|
|
123
|
-
d = {
|
|
124
|
-
height: ctx.height,
|
|
125
|
-
width: ctx.width,
|
|
126
|
-
serializedCommands: ctx.getSerializedCommands(),
|
|
127
|
-
containsNoTransferables: true
|
|
128
|
-
};
|
|
129
|
-
return _context2.abrupt("return", d);
|
|
130
|
-
|
|
131
|
-
case 3:
|
|
132
|
-
case "end":
|
|
133
|
-
return _context2.stop();
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}, _callee2);
|
|
137
|
-
}));
|
|
138
|
-
|
|
139
|
-
return function createImageBitmap(_x2) {
|
|
140
|
-
return _ref2.apply(this, arguments);
|
|
141
|
-
};
|
|
142
|
-
}();
|
|
143
|
-
|
|
144
|
-
exports.ImageBitmapType = ImageBitmapType = String;
|
|
145
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="offscreencanvas" />
|
|
2
|
-
import OffscreenCanvasShim from './CanvasShim';
|
|
3
|
-
import OffscreenCanvasRenderingContext2DShim from './Canvas2DContextShim';
|
|
4
|
-
import type * as NodeCanvas from 'canvas';
|
|
5
|
-
import { Command } from './Canvas2DContextShim/types';
|
|
6
|
-
export declare type AbstractCanvas = OffscreenCanvas | OffscreenCanvasShim | NodeCanvas.Canvas;
|
|
7
|
-
export declare type Abstract2DCanvasContext = OffscreenCanvasRenderingContext2D | OffscreenCanvasRenderingContext2DShim;
|
|
8
|
-
export declare type AbstractImageBitmap = Pick<ImageBitmap, 'height' | 'width'>;
|
|
9
|
-
/** a plain-object (JSON) serialization of a OffscreenCanvasRenderingContext2DShim */
|
|
10
|
-
export interface CanvasImageDataShim {
|
|
11
|
-
serializedCommands: Command[];
|
|
12
|
-
containsNoTransferables: true;
|
|
13
|
-
height: number;
|
|
14
|
-
width: number;
|
|
15
|
-
}
|
|
16
|
-
export declare function isCanvasImageDataShim(thing: unknown): thing is CanvasImageDataShim;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.isCanvasImageDataShim = isCanvasImageDataShim;
|
|
9
|
-
|
|
10
|
-
var _isObject = _interopRequireDefault(require("is-object"));
|
|
11
|
-
|
|
12
|
-
function isCanvasImageDataShim(thing) {
|
|
13
|
-
return (0, _isObject.default)(thing) && 'height' in thing && 'serializedCommands' in thing && Array.isArray(thing.serializedCommands);
|
|
14
|
-
}
|