@jbrowse/core 2.0.1 → 2.1.0
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 +6 -0
- package/BaseFeatureWidget/BaseFeatureDetail.js +313 -592
- package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -479
- package/BaseFeatureWidget/index.js +88 -126
- package/BaseFeatureWidget/types.js +1 -4
- package/BaseFeatureWidget/util.js +40 -75
- package/CorePlugin.js +55 -94
- package/Plugin.js +9 -34
- package/PluginLoader.js +153 -422
- package/PluginManager.d.ts +17 -14
- package/PluginManager.js +377 -666
- package/ReExports/Attributes.js +3 -10
- package/ReExports/BaseCard.js +3 -10
- package/ReExports/DataGrid.js +5 -12
- package/ReExports/FeatureDetails.js +3 -10
- package/ReExports/index.js +6 -12
- package/ReExports/list.d.ts +5 -0
- package/ReExports/list.js +271 -7
- package/ReExports/material-ui-colors.js +15 -16
- package/ReExports/modules.d.ts +0 -1
- package/ReExports/modules.js +453 -798
- package/TextSearch/BaseResults.js +51 -123
- package/TextSearch/TextSearchManager.js +66 -144
- package/assemblyManager/assembly.js +280 -555
- package/assemblyManager/assemblyConfigSchema.js +47 -64
- package/assemblyManager/assemblyManager.js +126 -272
- package/assemblyManager/index.js +9 -22
- package/configuration/configurationSchema.js +167 -203
- package/configuration/configurationSlot.js +248 -326
- package/configuration/index.js +19 -35
- package/configuration/util.js +131 -173
- package/data_adapters/BaseAdapter.d.ts +2 -2
- package/data_adapters/BaseAdapter.js +132 -521
- package/data_adapters/CytobandAdapter.js +40 -126
- package/data_adapters/dataAdapterCache.js +77 -158
- package/package.json +4 -5
- package/pluggableElementTypes/AdapterType.js +24 -79
- package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
- package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
- package/pluggableElementTypes/ConnectionType.js +22 -65
- package/pluggableElementTypes/DisplayType.js +35 -82
- package/pluggableElementTypes/InternetAccountType.js +23 -64
- package/pluggableElementTypes/PluggableElementBase.js +8 -20
- package/pluggableElementTypes/RpcMethodType.js +85 -427
- package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
- package/pluggableElementTypes/TrackType.js +26 -70
- package/pluggableElementTypes/ViewType.js +21 -63
- package/pluggableElementTypes/WidgetType.js +21 -64
- package/pluggableElementTypes/index.d.ts +4 -3
- package/pluggableElementTypes/index.js +42 -125
- package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
- package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
- package/pluggableElementTypes/models/BaseTrackModel.js +139 -199
- package/pluggableElementTypes/models/BaseViewModel.js +24 -40
- package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
- package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
- package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
- package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
- package/pluggableElementTypes/models/index.js +21 -70
- package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
- package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
- package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
- package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -264
- package/pluggableElementTypes/renderers/RendererType.js +31 -105
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
- package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
- package/pluggableElementTypes/renderers/index.js +19 -62
- package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
- package/rpc/BaseRpcDriver.js +169 -405
- package/rpc/MainThreadRpcDriver.js +27 -150
- package/rpc/RpcManager.js +58 -159
- package/rpc/WebWorkerRpcDriver.js +54 -171
- package/rpc/configSchema.js +25 -49
- package/rpc/coreRpcMethods.js +221 -959
- package/rpc/remoteAbortSignals.js +46 -70
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/AboutDialog.js +106 -162
- package/ui/App.js +157 -242
- package/ui/AssemblySelector.js +59 -120
- package/ui/CascadingMenu.js +101 -196
- package/ui/ColorPicker.d.ts +16 -0
- package/ui/ColorPicker.js +97 -0
- package/ui/Drawer.js +28 -61
- package/ui/DrawerWidget.js +108 -202
- package/ui/DropDownMenu.js +60 -91
- package/ui/EditableTypography.js +87 -149
- package/ui/ErrorMessage.js +41 -56
- package/ui/FactoryResetDialog.js +24 -57
- package/ui/FatalErrorDialog.js +59 -91
- package/ui/FileSelector/FileSelector.js +123 -189
- package/ui/FileSelector/LocalFileChooser.js +44 -75
- package/ui/FileSelector/UrlChooser.js +17 -38
- package/ui/FileSelector/index.js +6 -12
- package/ui/Icons.js +45 -69
- package/ui/Logo.js +57 -110
- package/ui/Menu.js +232 -354
- package/ui/PrerenderedCanvas.js +63 -87
- package/ui/ResizeHandle.js +87 -116
- package/ui/ReturnToImportFormDialog.js +32 -63
- package/ui/SanitizedHTML.js +64 -47
- package/ui/Snackbar.js +74 -101
- package/ui/SnackbarModel.js +37 -51
- package/ui/Tooltip.js +49 -76
- package/ui/ViewContainer.js +113 -196
- package/ui/colors.d.ts +10 -0
- package/ui/colors.js +78 -0
- package/ui/index.js +51 -181
- package/ui/react-colorful.d.ts +17 -0
- package/ui/react-colorful.js +455 -0
- package/ui/theme.js +199 -247
- package/util/Base1DUtils.js +163 -202
- package/util/Base1DViewModel.js +121 -168
- package/util/QuickLRU.js +84 -332
- package/util/TimeTraveller.d.ts +19 -0
- package/util/TimeTraveller.js +86 -0
- package/util/aborting.js +49 -127
- package/util/analytics.js +91 -154
- package/util/blockTypes.js +106 -240
- package/util/calculateDynamicBlocks.js +98 -128
- package/util/calculateStaticBlocks.js +105 -125
- package/util/color/cssColorsLevel4.js +156 -160
- package/util/color/index.js +33 -55
- package/util/compositeMap.js +49 -333
- package/util/formatFastaStrings.js +9 -14
- package/util/idMaker.js +18 -31
- package/util/index.d.ts +7 -20
- package/util/index.js +742 -1188
- package/util/io/RemoteFileWithRangeCache.js +88 -257
- package/util/io/index.js +95 -169
- package/util/jexl.js +60 -115
- package/util/jexlStrings.js +24 -29
- package/util/layouts/BaseLayout.js +1 -4
- package/util/layouts/GranularRectLayout.js +388 -555
- package/util/layouts/MultiLayout.js +41 -109
- package/util/layouts/PrecomputedLayout.js +56 -112
- package/util/layouts/PrecomputedMultiLayout.js +22 -59
- package/util/layouts/SceneGraph.js +127 -197
- package/util/layouts/index.js +29 -66
- package/util/mst-reflection.js +55 -71
- package/util/offscreenCanvasPonyfill.js +66 -134
- package/util/offscreenCanvasUtils.d.ts +2 -7
- package/util/offscreenCanvasUtils.js +49 -146
- package/util/range.js +29 -40
- package/util/rxjs.js +20 -27
- package/util/simpleFeature.js +88 -152
- package/util/stats.js +91 -151
- package/util/tracks.js +130 -173
- package/util/types/index.js +110 -179
- package/util/types/mst.js +91 -146
- package/util/types/util.js +1 -4
- package/util/when.js +54 -101
- package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
- package/BaseFeatureWidget/index.test.js +0 -69
- package/TextSearch/BaseResults.test.js +0 -42
- package/configuration/configurationSchema.test.js +0 -266
- package/configuration/configurationSlot.test.js +0 -69
- package/configuration/util.test.js +0 -39
- package/data_adapters/BaseAdapter.test.js +0 -200
- package/declare.d.js +0 -1
- package/pluggableElementTypes/RpcMethodType.test.js +0 -118
- package/pluggableElementTypes/renderers/declare.d.js +0 -1
- package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
- package/rpc/BaseRpcDriver.test.js +0 -540
- package/rpc/declaration.d.js +0 -1
- package/ui/FatalErrorDialog.test.js +0 -82
- package/ui/SanitizedHTML.test.js +0 -36
- package/ui/theme.test.js +0 -92
- package/util/Base1DViewModel.test.js +0 -130
- package/util/calculateDynamicBlocks.test.js +0 -74
- package/util/calculateStaticBlocks.test.js +0 -297
- package/util/declare.d.js +0 -1
- package/util/formatFastaStrings.test.js +0 -40
- package/util/index.test.js +0 -213
- package/util/jexlStrings.test.js +0 -48
- package/util/layouts/GranularRectLayout.test.js +0 -99
- package/util/range.test.js +0 -64
- package/util/simpleFeature.test.js +0 -34
- package/util/stats.test.js +0 -172
|
@@ -1,144 +1,76 @@
|
|
|
1
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 _canvasSequencer = require("canvas-sequencer");
|
|
18
|
-
|
|
19
2
|
// This file is a ponyfill for the HTML5 OffscreenCanvas API.
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function drawImageOntoCanvasContext( // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.drawImageOntoCanvasContext = exports.ImageBitmapType = exports.createImageBitmap = exports.createCanvas = void 0;
|
|
8
|
+
const detect_node_1 = __importDefault(require("detect-node"));
|
|
9
|
+
const canvas_sequencer_1 = require("canvas-sequencer");
|
|
10
|
+
function drawImageOntoCanvasContext(
|
|
11
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
30
12
|
imageData, context) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
13
|
+
if (imageData.serializedCommands) {
|
|
14
|
+
const seq = new canvas_sequencer_1.CanvasSequence(imageData.serializedCommands);
|
|
15
|
+
seq.execute(context);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
context.drawImage(imageData, 0, 0);
|
|
19
|
+
}
|
|
37
20
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
21
|
+
exports.drawImageOntoCanvasContext = drawImageOntoCanvasContext;
|
|
22
|
+
const weHave = {
|
|
23
|
+
realOffscreenCanvas: typeof OffscreenCanvas === 'function',
|
|
24
|
+
node: detect_node_1.default,
|
|
42
25
|
};
|
|
43
|
-
|
|
44
26
|
if (weHave.realOffscreenCanvas) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
exports.createImageBitmap = createImageBitmap = /*#__PURE__*/function () {
|
|
62
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(canvas) {
|
|
63
|
-
var dataUri,
|
|
64
|
-
img,
|
|
65
|
-
_args = arguments;
|
|
66
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
67
|
-
while (1) {
|
|
68
|
-
switch (_context.prev = _context.next) {
|
|
69
|
-
case 0:
|
|
70
|
-
if (!(_args.length <= 1 ? 0 : _args.length - 1)) {
|
|
71
|
-
_context.next = 2;
|
|
72
|
-
break;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
throw new Error('only one-argument uses of createImageBitmap are supported by the node offscreencanvas ponyfill');
|
|
76
|
-
|
|
77
|
-
case 2:
|
|
78
|
-
dataUri = canvas.toDataURL(); // @ts-ignore
|
|
79
|
-
// eslint-disable-next-line no-undef
|
|
80
|
-
|
|
81
|
-
img = new nodeImage();
|
|
82
|
-
return _context.abrupt("return", new Promise(function (resolve, reject) {
|
|
83
|
-
img.onload = function () {
|
|
84
|
-
return resolve(img);
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
img.onerror = reject;
|
|
88
|
-
img.src = dataUri;
|
|
89
|
-
}));
|
|
90
|
-
|
|
91
|
-
case 5:
|
|
92
|
-
case "end":
|
|
93
|
-
return _context.stop();
|
|
94
|
-
}
|
|
27
|
+
exports.createCanvas = (width, height) => new OffscreenCanvas(width, height);
|
|
28
|
+
// eslint-disable-next-line no-restricted-globals
|
|
29
|
+
exports.createImageBitmap = window.createImageBitmap || self.createImageBitmap;
|
|
30
|
+
// eslint-disable-next-line no-restricted-globals
|
|
31
|
+
exports.ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
|
|
32
|
+
}
|
|
33
|
+
else if (weHave.node) {
|
|
34
|
+
// use node-canvas if we are running in node (i.e. automated tests)
|
|
35
|
+
exports.createCanvas = (...args) => {
|
|
36
|
+
// @ts-ignore
|
|
37
|
+
// eslint-disable-next-line no-undef
|
|
38
|
+
return nodeCreateCanvas(...args);
|
|
39
|
+
};
|
|
40
|
+
exports.createImageBitmap = async (canvas, ...otherargs) => {
|
|
41
|
+
if (otherargs.length) {
|
|
42
|
+
throw new Error('only one-argument uses of createImageBitmap are supported by the node offscreencanvas ponyfill');
|
|
95
43
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
44
|
+
const dataUri = canvas.toDataURL();
|
|
45
|
+
// @ts-ignore
|
|
46
|
+
// eslint-disable-next-line no-undef
|
|
47
|
+
const img = new nodeImage();
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
img.onload = () => resolve(img);
|
|
50
|
+
img.onerror = reject;
|
|
51
|
+
img.src = dataUri;
|
|
52
|
+
});
|
|
101
53
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
exports.createCanvas = (width, height) => {
|
|
57
|
+
const context = new canvas_sequencer_1.CanvasSequence();
|
|
58
|
+
return {
|
|
59
|
+
width,
|
|
60
|
+
height,
|
|
61
|
+
getContext() {
|
|
62
|
+
return context;
|
|
63
|
+
},
|
|
64
|
+
};
|
|
112
65
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
case 0:
|
|
122
|
-
ctx = canvas.getContext('2d');
|
|
123
|
-
return _context2.abrupt("return", {
|
|
124
|
-
height: canvas.height,
|
|
125
|
-
width: canvas.width,
|
|
126
|
-
serializedCommands: ctx.toJSON(),
|
|
127
|
-
containsNoTransferables: true
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
case 2:
|
|
131
|
-
case "end":
|
|
132
|
-
return _context2.stop();
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
}, _callee2);
|
|
136
|
-
}));
|
|
137
|
-
|
|
138
|
-
return function createImageBitmap(_x2) {
|
|
139
|
-
return _ref2.apply(this, arguments);
|
|
66
|
+
exports.createImageBitmap = async (canvas) => {
|
|
67
|
+
const ctx = canvas.getContext('2d');
|
|
68
|
+
return {
|
|
69
|
+
height: canvas.height,
|
|
70
|
+
width: canvas.width,
|
|
71
|
+
serializedCommands: ctx.toJSON(),
|
|
72
|
+
containsNoTransferables: true,
|
|
73
|
+
};
|
|
140
74
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
exports.ImageBitmapType = ImageBitmapType = String;
|
|
144
|
-
}
|
|
75
|
+
exports.ImageBitmapType = String;
|
|
76
|
+
}
|
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
+
export declare type RenderReturn = Record<string, unknown>;
|
|
2
3
|
export declare function renderToAbstractCanvas(width: number, height: number, opts: {
|
|
3
4
|
exportSVG?: {
|
|
4
5
|
rasterizeLayers?: boolean;
|
|
5
6
|
};
|
|
6
7
|
highResolutionScaling: number;
|
|
7
|
-
}, cb:
|
|
8
|
+
}, cb: (ctx: CanvasRenderingContext2D) => Promise<RenderReturn | void> | RenderReturn | void): Promise<{
|
|
8
9
|
canvasRecordedData: any;
|
|
9
|
-
reactElement?: undefined;
|
|
10
|
-
imageData?: undefined;
|
|
11
10
|
} | {
|
|
12
11
|
reactElement: JSX.Element;
|
|
13
|
-
canvasRecordedData?: undefined;
|
|
14
|
-
imageData?: undefined;
|
|
15
12
|
} | {
|
|
16
13
|
imageData: any;
|
|
17
|
-
canvasRecordedData?: undefined;
|
|
18
|
-
reactElement?: undefined;
|
|
19
14
|
}>;
|
|
@@ -1,152 +1,55 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
31
|
-
while (1) {
|
|
32
|
-
switch (_context.prev = _context.next) {
|
|
33
|
-
case 0:
|
|
34
|
-
exportSVG = opts.exportSVG, _opts$highResolutionS = opts.highResolutionScaling, highResolutionScaling = _opts$highResolutionS === void 0 ? 1 : _opts$highResolutionS;
|
|
35
|
-
|
|
36
|
-
if (!exportSVG) {
|
|
37
|
-
_context.next = 37;
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
if (exportSVG.rasterizeLayers) {
|
|
42
|
-
_context.next = 9;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
fakeCtx = new _canvasSequencer.CanvasSequence();
|
|
47
|
-
_context.next = 6;
|
|
48
|
-
return cb(fakeCtx);
|
|
49
|
-
|
|
50
|
-
case 6:
|
|
51
|
-
return _context.abrupt("return", {
|
|
52
|
-
canvasRecordedData: fakeCtx.toJSON()
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
case 9:
|
|
56
|
-
scale = 4;
|
|
57
|
-
canvas = (0, _offscreenCanvasPonyfill.createCanvas)(Math.ceil(width * scale), height * scale);
|
|
58
|
-
ctx = canvas.getContext('2d');
|
|
59
|
-
|
|
60
|
-
if (ctx) {
|
|
61
|
-
_context.next = 14;
|
|
62
|
-
break;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.renderToAbstractCanvas = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const canvas_sequencer_1 = require("canvas-sequencer");
|
|
9
|
+
// locals
|
|
10
|
+
const offscreenCanvasPonyfill_1 = require("./offscreenCanvasPonyfill");
|
|
11
|
+
const index_1 = require("./index");
|
|
12
|
+
async function renderToAbstractCanvas(width, height, opts, cb) {
|
|
13
|
+
const { exportSVG, highResolutionScaling: scaling = 1 } = opts;
|
|
14
|
+
if (exportSVG) {
|
|
15
|
+
if (!exportSVG.rasterizeLayers) {
|
|
16
|
+
const fakeCtx = new canvas_sequencer_1.CanvasSequence();
|
|
17
|
+
const result = await cb(fakeCtx);
|
|
18
|
+
return {
|
|
19
|
+
...result,
|
|
20
|
+
canvasRecordedData: fakeCtx.toJSON(),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const scale = 4;
|
|
25
|
+
const canvas = (0, offscreenCanvasPonyfill_1.createCanvas)(Math.ceil(width * scale), height * scale);
|
|
26
|
+
const ctx = canvas.getContext('2d');
|
|
27
|
+
if (!ctx) {
|
|
28
|
+
throw new Error('2d canvas rendering not supported on this platform');
|
|
63
29
|
}
|
|
64
|
-
|
|
65
|
-
throw new Error('2d canvas rendering not supported on this platform');
|
|
66
|
-
|
|
67
|
-
case 14:
|
|
68
30
|
ctx.scale(scale, scale);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
break;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
_context.t4 = _index.blobToDataURL;
|
|
83
|
-
_context.next = 24;
|
|
84
|
-
return canvas.convertToBlob({
|
|
85
|
-
type: 'image/png'
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
case 24:
|
|
89
|
-
_context.t5 = _context.sent;
|
|
90
|
-
_context.next = 27;
|
|
91
|
-
return (0, _context.t4)(_context.t5);
|
|
92
|
-
|
|
93
|
-
case 27:
|
|
94
|
-
_context.t3 = _context.sent;
|
|
95
|
-
_context.next = 31;
|
|
96
|
-
break;
|
|
97
|
-
|
|
98
|
-
case 30:
|
|
99
|
-
_context.t3 = canvas.toDataURL();
|
|
100
|
-
|
|
101
|
-
case 31:
|
|
102
|
-
_context.t6 = _context.t3;
|
|
103
|
-
_context.t7 = {
|
|
104
|
-
width: _context.t1,
|
|
105
|
-
height: _context.t2,
|
|
106
|
-
xlinkHref: _context.t6
|
|
31
|
+
const result = await cb(ctx);
|
|
32
|
+
// two methods needed for converting canvas to PNG, one for webworker
|
|
33
|
+
// offscreen canvas, one for main thread
|
|
34
|
+
return {
|
|
35
|
+
...result,
|
|
36
|
+
reactElement: (react_1.default.createElement("image", { width: width, height: height, xlinkHref: 'convertToBlob' in canvas
|
|
37
|
+
? await (0, index_1.blobToDataURL)(await canvas.convertToBlob({
|
|
38
|
+
type: 'image/png',
|
|
39
|
+
}))
|
|
40
|
+
: canvas.toDataURL() })),
|
|
107
41
|
};
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
_context.next = 48;
|
|
115
|
-
break;
|
|
116
|
-
|
|
117
|
-
case 37:
|
|
118
|
-
_canvas = (0, _offscreenCanvasPonyfill.createCanvas)(Math.ceil(width * highResolutionScaling), height * highResolutionScaling);
|
|
119
|
-
_ctx = _canvas.getContext('2d');
|
|
120
|
-
|
|
121
|
-
if (_ctx) {
|
|
122
|
-
_context.next = 41;
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
const canvas = (0, offscreenCanvasPonyfill_1.createCanvas)(Math.ceil(width * scaling), height * scaling);
|
|
46
|
+
const ctx = canvas.getContext('2d');
|
|
47
|
+
if (!ctx) {
|
|
126
48
|
throw new Error('2d canvas rendering not supported on this platform');
|
|
127
|
-
|
|
128
|
-
case 41:
|
|
129
|
-
_ctx.scale(highResolutionScaling, highResolutionScaling);
|
|
130
|
-
|
|
131
|
-
_context.next = 44;
|
|
132
|
-
return cb(_ctx);
|
|
133
|
-
|
|
134
|
-
case 44:
|
|
135
|
-
_context.next = 46;
|
|
136
|
-
return (0, _offscreenCanvasPonyfill.createImageBitmap)(_canvas);
|
|
137
|
-
|
|
138
|
-
case 46:
|
|
139
|
-
_context.t9 = _context.sent;
|
|
140
|
-
return _context.abrupt("return", {
|
|
141
|
-
imageData: _context.t9
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
case 48:
|
|
145
|
-
case "end":
|
|
146
|
-
return _context.stop();
|
|
147
49
|
}
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
50
|
+
ctx.scale(scaling, scaling);
|
|
51
|
+
const result = await cb(ctx);
|
|
52
|
+
return { ...result, imageData: await (0, offscreenCanvasPonyfill_1.createImageBitmap)(canvas) };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.renderToAbstractCanvas = renderToAbstractCanvas;
|
package/util/range.js
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.doesIntersect2 = doesIntersect2;
|
|
7
|
-
exports.intersection2 = intersection2;
|
|
8
|
-
exports.isContainedWithin = isContainedWithin;
|
|
9
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isContainedWithin = exports.doesIntersect2 = exports.intersection2 = void 0;
|
|
10
4
|
/**
|
|
11
5
|
* fast low-level intersection of 2 coordinate ranges. assumes interbase coordinates.
|
|
12
6
|
*
|
|
@@ -15,33 +9,30 @@ exports.isContainedWithin = isContainedWithin;
|
|
|
15
9
|
* @returns array of [left, right], or [] if the ranges do not intersect. the choice of [] is because it allows destructuring array assignment without check for undefined return
|
|
16
10
|
*/
|
|
17
11
|
function intersection2(left1, right1, left2, right2) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
// this code is verbose because "if" statements are faster than Math.min and Math.max
|
|
13
|
+
if (right1 > left2 && left1 < right2 && right2 - left2 && right1 - left1) {
|
|
14
|
+
if (left1 > left2) {
|
|
15
|
+
if (right1 < right2) {
|
|
16
|
+
// 1 |-------|
|
|
17
|
+
// |------------|
|
|
18
|
+
return [left1, right1];
|
|
19
|
+
}
|
|
20
|
+
// 2 |----|
|
|
21
|
+
// |------|
|
|
22
|
+
return [left1, right2];
|
|
23
|
+
}
|
|
24
|
+
if (right1 < right2) {
|
|
25
|
+
// 3 |-----|
|
|
26
|
+
// |------|
|
|
27
|
+
return [left2, right1];
|
|
28
|
+
}
|
|
29
|
+
// 4 |------------|
|
|
30
|
+
// |-------|
|
|
31
|
+
return [left2, right2];
|
|
30
32
|
}
|
|
31
|
-
|
|
32
|
-
if (right1 < right2) {
|
|
33
|
-
// 3 |-----|
|
|
34
|
-
// |------|
|
|
35
|
-
return [left2, right1];
|
|
36
|
-
} // 4 |------------|
|
|
37
|
-
// |-------|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
return [left2, right2];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return [];
|
|
33
|
+
return [];
|
|
44
34
|
}
|
|
35
|
+
exports.intersection2 = intersection2;
|
|
45
36
|
/**
|
|
46
37
|
* Return whether 2 interbase coordinate ranges intersect.
|
|
47
38
|
*
|
|
@@ -52,11 +43,10 @@ function intersection2(left1, right1, left2, right2) {
|
|
|
52
43
|
*
|
|
53
44
|
* @returns true if the two ranges intersect
|
|
54
45
|
*/
|
|
55
|
-
|
|
56
|
-
|
|
57
46
|
function doesIntersect2(left1, right1, left2, right2) {
|
|
58
|
-
|
|
47
|
+
return right1 > left2 && left1 < right2;
|
|
59
48
|
}
|
|
49
|
+
exports.doesIntersect2 = doesIntersect2;
|
|
60
50
|
/**
|
|
61
51
|
* Return whether the first region is completely contained within the second region
|
|
62
52
|
*
|
|
@@ -65,8 +55,7 @@ function doesIntersect2(left1, right1, left2, right2) {
|
|
|
65
55
|
* @param left2 - candidate outer region left
|
|
66
56
|
* @param right2 - candidate outer region right
|
|
67
57
|
*/
|
|
68
|
-
|
|
69
|
-
|
|
70
58
|
function isContainedWithin(left1, right1, left2, right2) {
|
|
71
|
-
|
|
72
|
-
}
|
|
59
|
+
return left2 <= left1 && right2 >= right1;
|
|
60
|
+
}
|
|
61
|
+
exports.isContainedWithin = isContainedWithin;
|
package/util/rxjs.js
CHANGED
|
@@ -1,34 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _rxjs = require("rxjs");
|
|
9
|
-
|
|
10
|
-
var _operators = require("rxjs/operators");
|
|
11
|
-
|
|
12
|
-
var _ = require(".");
|
|
13
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ObservableCreate = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
5
|
+
const operators_1 = require("rxjs/operators");
|
|
6
|
+
const _1 = require(".");
|
|
14
7
|
/**
|
|
15
8
|
* Wrapper for rxjs Observable.create with improved error handling and
|
|
16
9
|
* aborting support
|
|
17
10
|
* @param func - observer function, could be async
|
|
18
11
|
*/
|
|
19
12
|
function ObservableCreate(func, signal) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
13
|
+
return rxjs_1.Observable.create((observer) => {
|
|
14
|
+
try {
|
|
15
|
+
const ret = func(observer);
|
|
16
|
+
// catch async errors
|
|
17
|
+
if (ret && ret.catch) {
|
|
18
|
+
ret.catch(error => observer.error(error));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
// catch sync errors
|
|
23
|
+
observer.error(error);
|
|
24
|
+
}
|
|
25
|
+
}).pipe((0, operators_1.takeUntil)((0, _1.observeAbortSignal)(signal)));
|
|
26
|
+
}
|
|
27
|
+
exports.ObservableCreate = ObservableCreate;
|