@jbrowse/core 1.7.8 → 1.7.9

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.
Files changed (35) hide show
  1. package/assemblyManager/assemblyManager.d.ts +1 -1
  2. package/package.json +4 -2
  3. package/pluggableElementTypes/models/InternetAccountModel.d.ts +2 -2
  4. package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +6 -14
  5. package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +6 -0
  6. package/pluggableElementTypes/renderers/ServerSideRendererType.js +44 -2
  7. package/pluggableElementTypes/renderers/declare.d.js +1 -0
  8. package/tsconfig.build.tsbuildinfo +1 -1
  9. package/ui/SanitizedHTML.js +26 -4
  10. package/ui/SnackbarModel.d.ts +2 -2
  11. package/util/declare.d.js +1 -0
  12. package/util/offscreenCanvasPonyfill.d.ts +8 -1
  13. package/util/offscreenCanvasPonyfill.js +140 -12
  14. package/util/offscreenCanvasUtils.d.ts +19 -1
  15. package/util/offscreenCanvasUtils.js +146 -12
  16. package/util/types/mst.d.ts +9 -9
  17. package/util/offscreenCanvas/Canvas2DContextShim/Canvas2DContextShim.test.js +0 -15
  18. package/util/offscreenCanvas/Canvas2DContextShim/context.d.ts +0 -56
  19. package/util/offscreenCanvas/Canvas2DContextShim/context.js +0 -356
  20. package/util/offscreenCanvas/Canvas2DContextShim/index.d.ts +0 -2
  21. package/util/offscreenCanvas/Canvas2DContextShim/index.js +0 -13
  22. package/util/offscreenCanvas/Canvas2DContextShim/svg.d.ts +0 -3
  23. package/util/offscreenCanvas/Canvas2DContextShim/svg.js +0 -210
  24. package/util/offscreenCanvas/Canvas2DContextShim/types.d.ts +0 -50
  25. package/util/offscreenCanvas/Canvas2DContextShim/types.js +0 -59
  26. package/util/offscreenCanvas/Canvas2DContextShim/util.d.ts +0 -12
  27. package/util/offscreenCanvas/Canvas2DContextShim/util.js +0 -91
  28. package/util/offscreenCanvas/CanvasShim.d.ts +0 -11
  29. package/util/offscreenCanvas/CanvasShim.js +0 -54
  30. package/util/offscreenCanvas/index.d.ts +0 -14
  31. package/util/offscreenCanvas/index.js +0 -170
  32. package/util/offscreenCanvas/ponyfill.d.ts +0 -6
  33. package/util/offscreenCanvas/ponyfill.js +0 -145
  34. package/util/offscreenCanvas/types.d.ts +0 -16
  35. package/util/offscreenCanvas/types.js +0 -14
@@ -2,24 +2,32 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
+ var _typeof = require("@babel/runtime/helpers/typeof");
6
+
5
7
  Object.defineProperty(exports, "__esModule", {
6
8
  value: true
7
9
  });
8
10
  exports.default = SanitizedHTML;
9
11
  exports.isHTML = isHTML;
10
12
 
11
- var _react = _interopRequireDefault(require("react"));
13
+ var _react = _interopRequireWildcard(require("react"));
12
14
 
13
15
  var _escapeHtml = _interopRequireDefault(require("escape-html"));
14
16
 
15
17
  var _dompurify = _interopRequireDefault(require("dompurify"));
16
18
 
19
+ 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); }
20
+
21
+ 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; }
22
+
17
23
  // source https://github.com/sindresorhus/html-tags/blob/master/html-tags.json
18
24
  // with some random uncommon ones removed. note: we just use this to run the content
19
25
  // through dompurify without escaping if we see an htmlTag from this list
20
26
  // otherwise we escape angle brackets and things prematurely because it might be
21
27
  // something like <TRA> in VCF. Ref #657
22
- var htmlTags = ['a', 'b', 'br', 'code', 'div', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'img', 'li', 'p', 'pre', 'span', 'small', 'strong', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'u', 'ul']; // adapted from is-html https://github.com/sindresorhus/is-html/blob/master/index.js
28
+ var htmlTags = ['a', 'b', 'br', 'code', 'div', 'em', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'i', 'img', 'li', 'p', 'pre', 'span', 'small', 'strong', 'table', 'tbody', 'td', 'tfoot', 'th', 'thead', 'tr', 'u', 'ul'];
29
+ var added = false; // adapted from is-html
30
+ // https://github.com/sindresorhus/is-html/blob/master/index.js
23
31
 
24
32
  var full = new RegExp(htmlTags.map(function (tag) {
25
33
  return "<".concat(tag, "\\b[^>]*>");
@@ -31,9 +39,23 @@ function isHTML(str) {
31
39
 
32
40
  function SanitizedHTML(_ref) {
33
41
  var html = _ref.html;
34
- var value = isHTML(html) ? html : (0, _escapeHtml.default)(html); // eslint-disable-next-line react/no-danger
35
-
42
+ var value = isHTML(html) ? html : (0, _escapeHtml.default)(html);
43
+ (0, _react.useEffect)(function () {
44
+ if (!added) {
45
+ added = true; // see https://github.com/cure53/DOMPurify/issues/317
46
+ // only have to add this once, and can't do it globally because dompurify
47
+ // not yet initialized at global scope
48
+
49
+ _dompurify.default.addHook('afterSanitizeAttributes', function (node) {
50
+ if (node.tagName === 'A') {
51
+ node.setAttribute('rel', 'noopener noreferrer');
52
+ node.setAttribute('target', '_blank');
53
+ }
54
+ });
55
+ }
56
+ }, []);
36
57
  return /*#__PURE__*/_react.default.createElement("div", {
58
+ // eslint-disable-next-line react/no-danger
37
59
  dangerouslySetInnerHTML: {
38
60
  __html: _dompurify.default.sanitize(value)
39
61
  }
@@ -6,8 +6,8 @@ declare function makeExtension(snackbarMessages: IObservableArray<any>): {
6
6
  readonly snackbarMessages: IObservableArray<any>;
7
7
  };
8
8
  actions: {
9
- notify(message: string, level?: NotificationLevel | undefined, action?: SnackAction | undefined): void;
10
- pushSnackbarMessage(message: string, level?: NotificationLevel | undefined, action?: SnackAction | undefined): number;
9
+ notify(message: string, level?: NotificationLevel, action?: SnackAction): void;
10
+ pushSnackbarMessage(message: string, level?: NotificationLevel, action?: SnackAction): number;
11
11
  popSnackbarMessage(): any;
12
12
  removeSnackbarMessage(message: string): void;
13
13
  };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -1 +1,8 @@
1
- export * from "./offscreenCanvas/ponyfill";
1
+ declare type AbstractCanvas = any;
2
+ declare type AbstractImageBitmap = any;
3
+ export declare let createCanvas: (width: number, height: number) => AbstractCanvas;
4
+ export declare let createImageBitmap: (canvas: AbstractCanvas) => Promise<AbstractImageBitmap>;
5
+ /** the JS class (constructor) for offscreen-generated image bitmap data */
6
+ export declare let ImageBitmapType: Function;
7
+ export declare function drawImageOntoCanvasContext(imageData: any, context: CanvasRenderingContext2D): void;
8
+ export {};
@@ -1,18 +1,146 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
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
+ // This file is a ponyfill for the HTML5 OffscreenCanvas API.
20
+ var createCanvas;
21
+ exports.createCanvas = createCanvas;
22
+ var createImageBitmap;
23
+ /** the JS class (constructor) for offscreen-generated image bitmap data */
24
+
25
+ exports.createImageBitmap = createImageBitmap;
26
+ var ImageBitmapType;
27
+ exports.ImageBitmapType = ImageBitmapType;
28
+
29
+ function drawImageOntoCanvasContext( // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ imageData, context) {
31
+ if (imageData.serializedCommands) {
32
+ var seq = new _canvasSequencer.CanvasSequence(imageData.serializedCommands);
33
+ seq.execute(context);
34
+ } else if (imageData instanceof ImageBitmapType) {
35
+ context.drawImage(imageData, 0, 0);
36
+ } else if (imageData.dataURL) {
37
+ throw new Error('dataURL deserialization no longer supported');
38
+ }
39
+ }
40
+
41
+ var weHave = {
42
+ realOffscreenCanvas: typeof OffscreenCanvas === 'function',
43
+ node: _detectNode.default
44
+ };
45
+
46
+ if (weHave.realOffscreenCanvas) {
47
+ exports.createCanvas = createCanvas = function createCanvas(width, height) {
48
+ return new OffscreenCanvas(width, height);
49
+ }; // eslint-disable-next-line no-restricted-globals
50
+
51
+
52
+ exports.createImageBitmap = createImageBitmap = window.createImageBitmap || self.createImageBitmap; // eslint-disable-next-line no-restricted-globals
53
+
54
+ exports.ImageBitmapType = ImageBitmapType = window.ImageBitmap || self.ImageBitmap;
55
+ } else if (weHave.node) {
56
+ // use node-canvas if we are running in node (i.e. automated tests)
57
+ var _require = require('canvas'),
58
+ nodeCreateCanvas = _require.createCanvas,
59
+ Image = _require.Image;
60
+
61
+ exports.createCanvas = createCanvas = nodeCreateCanvas;
62
+
63
+ exports.createImageBitmap = createImageBitmap = /*#__PURE__*/function () {
64
+ var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(canvas) {
65
+ var dataUri,
66
+ img,
67
+ _args = arguments;
68
+ return _regenerator.default.wrap(function _callee$(_context) {
69
+ while (1) {
70
+ switch (_context.prev = _context.next) {
71
+ case 0:
72
+ if (!(_args.length <= 1 ? 0 : _args.length - 1)) {
73
+ _context.next = 2;
74
+ break;
75
+ }
76
+
77
+ throw new Error('only one-argument uses of createImageBitmap are supported by the node offscreencanvas ponyfill');
78
+
79
+ case 2:
80
+ dataUri = canvas.toDataURL();
81
+ img = new Image();
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
+ }
95
+ }
96
+ }, _callee);
97
+ }));
98
+
99
+ return function createImageBitmap(_x) {
100
+ return _ref.apply(this, arguments);
101
+ };
102
+ }();
103
+
104
+ exports.ImageBitmapType = ImageBitmapType = Image;
105
+ } else {
106
+ exports.createCanvas = createCanvas = function createCanvas(width, height) {
107
+ var context = new _canvasSequencer.CanvasSequence();
108
+ return {
109
+ width: width,
110
+ height: height,
111
+ getContext: function getContext() {
112
+ return context;
113
+ }
114
+ };
115
+ };
116
+
117
+ exports.createImageBitmap = createImageBitmap = /*#__PURE__*/function () {
118
+ var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(canvas) {
119
+ var ctx;
120
+ return _regenerator.default.wrap(function _callee2$(_context2) {
121
+ while (1) {
122
+ switch (_context2.prev = _context2.next) {
123
+ case 0:
124
+ ctx = canvas.getContext('2d');
125
+ return _context2.abrupt("return", {
126
+ height: canvas.height,
127
+ width: canvas.width,
128
+ serializedCommands: ctx.toJSON(),
129
+ containsNoTransferables: true
130
+ });
131
+
132
+ case 2:
133
+ case "end":
134
+ return _context2.stop();
135
+ }
136
+ }
137
+ }, _callee2);
138
+ }));
139
+
140
+ return function createImageBitmap(_x2) {
141
+ return _ref2.apply(this, arguments);
142
+ };
143
+ }();
6
144
 
7
- var _ponyfill = require("./offscreenCanvas/ponyfill");
8
-
9
- Object.keys(_ponyfill).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _ponyfill[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function get() {
15
- return _ponyfill[key];
16
- }
17
- });
18
- });
145
+ exports.ImageBitmapType = ImageBitmapType = String;
146
+ }
@@ -1 +1,19 @@
1
- export * from './offscreenCanvas';
1
+ /// <reference types="react" />
2
+ export declare function renderToAbstractCanvas(width: number, height: number, opts: {
3
+ exportSVG?: {
4
+ rasterizeLayers?: boolean;
5
+ };
6
+ highResolutionScaling: number;
7
+ }, cb: Function): Promise<{
8
+ canvasRecordedData: any;
9
+ reactElement?: undefined;
10
+ imageData?: undefined;
11
+ } | {
12
+ reactElement: JSX.Element;
13
+ canvasRecordedData?: undefined;
14
+ imageData?: undefined;
15
+ } | {
16
+ imageData: any;
17
+ canvasRecordedData?: undefined;
18
+ reactElement?: undefined;
19
+ }>;
@@ -1,18 +1,152 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
8
+ exports.renderToAbstractCanvas = renderToAbstractCanvas;
9
+
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _offscreenCanvasPonyfill = require("./offscreenCanvasPonyfill");
17
+
18
+ var _canvasSequencer = require("canvas-sequencer");
19
+
20
+ var _index = require("./index");
21
+
22
+ function renderToAbstractCanvas(_x, _x2, _x3, _x4) {
23
+ return _renderToAbstractCanvas.apply(this, arguments);
24
+ }
25
+
26
+ function _renderToAbstractCanvas() {
27
+ _renderToAbstractCanvas = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(width, height, opts, cb) {
28
+ var exportSVG, _opts$highResolutionS, highResolutionScaling, fakeCtx, scale, canvas, ctx, _canvas, _ctx;
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;
63
+ }
64
+
65
+ throw new Error('2d canvas rendering not supported on this platform');
66
+
67
+ case 14:
68
+ ctx.scale(scale, scale);
69
+ _context.next = 17;
70
+ return cb(ctx);
71
+
72
+ case 17:
73
+ _context.t0 = _react.default;
74
+ _context.t1 = width;
75
+ _context.t2 = height;
76
+
77
+ if (!('convertToBlob' in canvas)) {
78
+ _context.next = 30;
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
107
+ };
108
+ _context.t8 = _context.t0.createElement.call(_context.t0, "image", _context.t7);
109
+ return _context.abrupt("return", {
110
+ reactElement: _context.t8
111
+ });
112
+
113
+ case 35:
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
+
126
+ 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
+ });
6
143
 
7
- var _offscreenCanvas = require("./offscreenCanvas");
8
-
9
- Object.keys(_offscreenCanvas).forEach(function (key) {
10
- if (key === "default" || key === "__esModule") return;
11
- if (key in exports && exports[key] === _offscreenCanvas[key]) return;
12
- Object.defineProperty(exports, key, {
13
- enumerable: true,
14
- get: function get() {
15
- return _offscreenCanvas[key];
16
- }
17
- });
18
- });
144
+ case 48:
145
+ case "end":
146
+ return _context.stop();
147
+ }
148
+ }
149
+ }, _callee);
150
+ }));
151
+ return _renderToAbstractCanvas.apply(this, arguments);
152
+ }
@@ -77,13 +77,13 @@ export declare const FileLocation: import("mobx-state-tree").ISnapshotProcessor<
77
77
  internetAccountType: import("mobx-state-tree").ISimpleType<string>;
78
78
  authInfo: import("mobx-state-tree").IType<any, any, any>;
79
79
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
80
- }>> | import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<{
81
- locationType: import("mobx-state-tree").ISimpleType<"LocalPathLocation">;
82
- localPath: import("mobx-state-tree").ISimpleType<string>;
83
80
  }>> | import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<{
84
81
  locationType: import("mobx-state-tree").ISimpleType<"BlobLocation">;
85
82
  name: import("mobx-state-tree").ISimpleType<string>;
86
83
  blobId: import("mobx-state-tree").ISimpleType<string>;
84
+ }>> | import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<{
85
+ locationType: import("mobx-state-tree").ISimpleType<"LocalPathLocation">;
86
+ localPath: import("mobx-state-tree").ISimpleType<string>;
87
87
  }>>, {
88
88
  locationType: "UriLocation";
89
89
  uri: string;
@@ -93,12 +93,12 @@ export declare const FileLocation: import("mobx-state-tree").ISnapshotProcessor<
93
93
  authInfo: import("mobx-state-tree").IType<any, any, any>;
94
94
  }> | undefined;
95
95
  } | import("mobx-state-tree").ModelSnapshotType<{
96
- locationType: import("mobx-state-tree").ISimpleType<"LocalPathLocation">;
97
- localPath: import("mobx-state-tree").ISimpleType<string>;
98
- }> | import("mobx-state-tree").ModelSnapshotType<{
99
96
  locationType: import("mobx-state-tree").ISimpleType<"BlobLocation">;
100
97
  name: import("mobx-state-tree").ISimpleType<string>;
101
98
  blobId: import("mobx-state-tree").ISimpleType<string>;
99
+ }> | import("mobx-state-tree").ModelSnapshotType<{
100
+ locationType: import("mobx-state-tree").ISimpleType<"LocalPathLocation">;
101
+ localPath: import("mobx-state-tree").ISimpleType<string>;
102
102
  }>, import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<{
103
103
  locationType: import("mobx-state-tree").ISimpleType<"UriLocation">;
104
104
  uri: import("mobx-state-tree").ISimpleType<string>;
@@ -109,10 +109,10 @@ export declare const FileLocation: import("mobx-state-tree").ISnapshotProcessor<
109
109
  authInfo: import("mobx-state-tree").IType<any, any, any>;
110
110
  }, {}, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
111
111
  }>> | import("mobx-state-tree").ModelInstanceTypeProps<{
112
- locationType: import("mobx-state-tree").ISimpleType<"LocalPathLocation">;
113
- localPath: import("mobx-state-tree").ISimpleType<string>;
114
- }> | import("mobx-state-tree").ModelInstanceTypeProps<{
115
112
  locationType: import("mobx-state-tree").ISimpleType<"BlobLocation">;
116
113
  name: import("mobx-state-tree").ISimpleType<string>;
117
114
  blobId: import("mobx-state-tree").ISimpleType<string>;
115
+ }> | import("mobx-state-tree").ModelInstanceTypeProps<{
116
+ locationType: import("mobx-state-tree").ISimpleType<"LocalPathLocation">;
117
+ localPath: import("mobx-state-tree").ISimpleType<string>;
118
118
  }>>, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _ = _interopRequireDefault(require("."));
6
-
7
- test('serialize a single command and read back out', function () {
8
- var ctx = new _.default(100, 100);
9
- ctx.arc(20, 21, 22, 23, 24);
10
- var cmds = Array.from(ctx.getCommands());
11
- expect(cmds).toEqual([{
12
- name: 'arc',
13
- args: [20, 21, 22, 23, 24]
14
- }]);
15
- });
@@ -1,56 +0,0 @@
1
- /// <reference types="react" />
2
- /// <reference types="offscreencanvas" />
3
- import { Command } from './types';
4
- /** get the params type of real method in OffscreenCanvasRenderingContext2D */
5
- declare type RealP<METHODNAME extends keyof OffscreenCanvasRenderingContext2D> = OffscreenCanvasRenderingContext2D[METHODNAME] extends (...arg0: any[]) => any ? Parameters<OffscreenCanvasRenderingContext2D[METHODNAME]> : never;
6
- /** get the return type of real method in OffscreenCanvasRenderingContext2D */
7
- declare type RealRet<METHODNAME extends keyof OffscreenCanvasRenderingContext2D> = OffscreenCanvasRenderingContext2D[METHODNAME] extends (...arg0: any[]) => any ? ReturnType<OffscreenCanvasRenderingContext2D[METHODNAME]> : never;
8
- /** get the type of the params of a method of the canvas shim */
9
- export declare type ShimP<METHODNAME extends keyof OffscreenCanvasRenderingContext2DShim> = OffscreenCanvasRenderingContext2DShim[METHODNAME] extends (...arg0: any[]) => any ? Parameters<OffscreenCanvasRenderingContext2DShim[METHODNAME]> : never;
10
- /** decode all the commands in the given buffer and replay them onto the given context */
11
- export declare function replayCommandsOntoContext(targetContext: CanvasRenderingContext2D, encodedCommands: Iterable<Command>): void;
12
- export default class OffscreenCanvasRenderingContext2DShim {
13
- width: number;
14
- height: number;
15
- currentFont: string;
16
- currentStrokeStyle: string;
17
- currentFillStyle: string;
18
- recordedCommands: Command[];
19
- constructor(width: number, height: number);
20
- private pushMethodCall;
21
- private pushSetterCall;
22
- getSerializedCommands(): Command[];
23
- getSerializedSvg(): JSX.Element;
24
- getCommands(): Command[];
25
- set strokeStyle(style: string);
26
- set fillStyle(style: string);
27
- set font(style: string);
28
- arc(...args: RealP<'arc'>): RealRet<'arc'>;
29
- arcTo(...args: RealP<'arcTo'>): RealRet<'arcTo'>;
30
- beginPath(...args: RealP<'beginPath'>): RealRet<'beginPath'>;
31
- clearRect(...args: RealP<'clearRect'>): RealRet<'clearRect'>;
32
- closePath(...args: RealP<'closePath'>): RealRet<'closePath'>;
33
- ellipse(...args: RealP<'ellipse'>): RealRet<'ellipse'>;
34
- fill(...args: RealP<'fill'>): RealRet<'fill'>;
35
- fillRect(...args: RealP<'fillRect'>): RealRet<'fillRect'>;
36
- fillText(...args: RealP<'fillText'>): RealRet<'fillText'>;
37
- lineTo(...args: RealP<'lineTo'>): RealRet<'lineTo'>;
38
- measureText(...args: RealP<'measureText'>): {
39
- width: number;
40
- height: number;
41
- };
42
- moveTo(...args: RealP<'moveTo'>): RealRet<'moveTo'>;
43
- quadraticCurveTo(...args: RealP<'quadraticCurveTo'>): RealRet<'quadraticCurveTo'>;
44
- rect(...args: RealP<'rect'>): RealRet<'rect'>;
45
- restore(...args: RealP<'restore'>): RealRet<'restore'>;
46
- rotate(...args: RealP<'rotate'>): RealRet<'rotate'>;
47
- save(...args: RealP<'save'>): RealRet<'save'>;
48
- setTransform(...args: RealP<'setTransform'>): RealRet<'setTransform'>;
49
- scale(...args: RealP<'scale'>): RealRet<'scale'>;
50
- stroke(): RealRet<'stroke'>;
51
- strokeRect(...args: RealP<'strokeRect'>): RealRet<'strokeRect'>;
52
- strokeText(...args: RealP<'strokeText'>): RealRet<'strokeText'>;
53
- transform(...args: RealP<'transform'>): RealRet<'transform'>;
54
- translate(...args: RealP<'translate'>): RealRet<'translate'>;
55
- }
56
- export {};