@kitware/vtk.js 20.1.2 → 20.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Common/Core/Base64.d.ts +14 -2
- package/Common/Core/Base64.js +31 -2
- package/Common/Core/Math/index.js +3 -3
- package/Common/Core/Math.d.ts +128 -128
- package/Common/Core/Math.js +1 -1
- package/Common/Core/MatrixBuilder.js +39 -41
- package/Common/DataModel/ImageData.js +12 -14
- package/Common/Transform/LandmarkTransform.js +6 -7
- package/Filters/General/PaintFilter/PaintFilter.worker.js +8 -8
- package/Filters/General/PaintFilter.js +11 -11
- package/Filters/Sources/PlaneSource.js +12 -13
- package/IO/Core/BinaryHelper.js +2 -4
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +1 -1
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +1 -1
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +2 -2
- package/IO/Core/ZipMultiDataSetReader.js +1 -1
- package/IO/Core/ZipMultiDataSetWriter.js +1 -1
- package/IO/Geometry/STLWriter.js +4 -4
- package/IO/Misc/SkyboxReader.js +1 -1
- package/IO/XML/XMLReader.js +3 -4
- package/IO/XML/XMLWriter.js +5 -6
- package/Imaging/Core/ImageReslice.js +18 -19
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +27 -28
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +8 -9
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +14 -15
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +12 -13
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +5 -6
- package/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +1 -1
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +2 -2
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +8 -9
- package/Rendering/Core/Actor.js +3 -4
- package/Rendering/Core/Camera.js +81 -84
- package/Rendering/Core/CellPicker.js +2 -2
- package/Rendering/Core/CubeAxesActor.js +32 -33
- package/Rendering/Core/Follower.js +20 -21
- package/Rendering/Core/Glyph3DMapper.js +30 -32
- package/Rendering/Core/ImageMapper.js +2 -2
- package/Rendering/Core/ImageSlice.js +5 -6
- package/Rendering/Core/Picker.js +5 -6
- package/Rendering/Core/PixelSpaceCallbackMapper.js +3 -4
- package/Rendering/Core/Prop3D.js +24 -25
- package/Rendering/Core/Renderer.js +11 -12
- package/Rendering/Core/ScalarBarActor.js +32 -33
- package/Rendering/Core/Volume.js +3 -4
- package/Rendering/OpenGL/Actor.js +9 -10
- package/Rendering/OpenGL/Camera.js +8 -9
- package/Rendering/OpenGL/CellArrayBufferObject.js +6 -8
- package/Rendering/OpenGL/Glyph3DMapper.js +8 -9
- package/Rendering/OpenGL/ImageMapper.js +7 -7
- package/Rendering/OpenGL/ImageSlice.js +4 -4
- package/Rendering/OpenGL/PolyDataMapper.js +11 -13
- package/Rendering/OpenGL/RenderWindow.d.ts +37 -1
- package/Rendering/OpenGL/ShaderCache.js +1 -1
- package/Rendering/OpenGL/Skybox.js +4 -5
- package/Rendering/OpenGL/SphereMapper.js +2 -2
- package/Rendering/OpenGL/StickMapper.js +3 -4
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +1 -1
- package/Rendering/OpenGL/Volume.js +6 -7
- package/Rendering/OpenGL/VolumeMapper.js +47 -49
- package/Rendering/OpenGL/glsl/vtkPolyDataFS.glsl.js +1 -1
- package/Rendering/WebGPU/Actor.js +8 -8
- package/Rendering/WebGPU/Camera.js +8 -8
- package/Rendering/WebGPU/ImageMapper.js +18 -19
- package/Rendering/WebGPU/ImageSlice.js +9 -9
- package/Rendering/WebGPU/PolyDataMapper.js +3 -4
- package/Rendering/WebGPU/Renderer.js +6 -7
- package/Rendering/WebGPU/Texture.js +10 -9
- package/Rendering/WebGPU/Volume.js +3 -3
- package/Rendering/WebGPU/VolumePassFSQ.js +10 -10
- package/ThirdParty/index.js +2 -2
- package/Widgets/Manipulators/TrackballManipulator.js +5 -6
- package/Widgets/Representations/ArrowHandleRepresentation.js +10 -12
- package/Widgets/Representations/CircleContextRepresentation.js +4 -5
- package/Widgets/Representations/RectangleContextRepresentation.js +3 -3
- package/Widgets/Widgets3D/EllipseWidget/behavior.js +5 -5
- package/Widgets/Widgets3D/ImageCroppingWidget/helpers.js +6 -8
- package/Widgets/Widgets3D/PaintWidget/behavior.js +2 -2
- package/Widgets/Widgets3D/ResliceCursorWidget.js +6 -7
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +10 -10
- package/Widgets/Widgets3D/SplineWidget/behavior.js +5 -5
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Filters/General/PaintFilter/PaintFilter.worker.js +1 -1
- package/_virtual/rollup-plugin-worker-loader__module_Sources/Interaction/Widgets/PiecewiseGaussianWidget/ComputeHistogram.worker.js +1 -1
- package/package.json +2 -2
- package/vtk.js +2 -2
- package/_vendor/base64-js/index.js_commonjs-exports.js +0 -1
- package/_vendor/blueimp-md5/js/md5.js_commonjs-module.js +0 -3
- package/_vendor/define-properties/index.js_commonjs-proxy.js +0 -1
- package/_vendor/globalthis/implementation.browser.js_commonjs-module.js +0 -3
- package/_vendor/globalthis/implementation.browser.js_commonjs-proxy.js +0 -1
- package/_vendor/globalthis/polyfill.js_commonjs-proxy.js +0 -1
- package/_vendor/globalthis/shim.js_commonjs-proxy.js +0 -2
- package/_vendor/jszip/dist/jszip.min.js_commonjs-module.js +0 -3
- package/_vendor/object-keys/implementation.js_commonjs-proxy.js +0 -1
- package/_vendor/object-keys/index.js_commonjs-proxy.js +0 -1
- package/_vendor/object-keys/isArguments.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/alea.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/alea.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/tychei.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/tychei.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xor128.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xor128.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xor4096.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xor4096.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xorshift7.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xorshift7.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/lib/xorwow.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/lib/xorwow.js_commonjs-proxy.js +0 -1
- package/_vendor/seedrandom/seedrandom.js_commonjs-module.js +0 -3
- package/_vendor/seedrandom/seedrandom.js_commonjs-proxy.js +0 -1
- package/_vendor/webworker-promise/lib/register.js_commonjs-module.js +0 -3
- package/_vendor/webworker-promise/lib/tiny-emitter.js_commonjs-proxy.js +0 -1
- package/_vendor/webworker-promise/src/tiny-emitter.js_commonjs-proxy.js +0 -1
- package/_vendor/xmlbuilder2/lib/xmlbuilder2.min.js_commonjs-module.js +0 -3
- package/_virtual/_rollup_plugin_ignore_empty_module_placeholder_commonjs-proxy.js +0 -6
- package/_virtual/commonjsHelpers.js +0 -22
- package/_virtual/polyfill-node.buffer.js +0 -1971
- package/_virtual/polyfill-node.global.js +0 -5
- package/_virtual/rollup_plugin_ignore_empty_module_placeholder.js +0 -8
- package/vendor/base64-js/index.js +0 -72
- package/vendor/blueimp-md5/js/md5.js +0 -402
- package/vendor/d3-array/src/array.js +0 -1
- package/vendor/d3-array/src/ascending.js +0 -5
- package/vendor/d3-array/src/bin.js +0 -1
- package/vendor/d3-array/src/bisect.js +0 -10
- package/vendor/d3-array/src/bisector.js +0 -46
- package/vendor/d3-array/src/constant.js +0 -1
- package/vendor/d3-array/src/count.js +0 -1
- package/vendor/d3-array/src/cross.js +0 -1
- package/vendor/d3-array/src/cumsum.js +0 -1
- package/vendor/d3-array/src/descending.js +0 -1
- package/vendor/d3-array/src/deviation.js +0 -1
- package/vendor/d3-array/src/difference.js +0 -1
- package/vendor/d3-array/src/disjoint.js +0 -1
- package/vendor/d3-array/src/every.js +0 -1
- package/vendor/d3-array/src/extent.js +0 -1
- package/vendor/d3-array/src/filter.js +0 -1
- package/vendor/d3-array/src/fsum.js +0 -1
- package/vendor/d3-array/src/greatest.js +0 -1
- package/vendor/d3-array/src/greatestIndex.js +0 -1
- package/vendor/d3-array/src/group.js +0 -1
- package/vendor/d3-array/src/groupSort.js +0 -1
- package/vendor/d3-array/src/identity.js +0 -1
- package/vendor/d3-array/src/index.js +0 -1
- package/vendor/d3-array/src/intersection.js +0 -1
- package/vendor/d3-array/src/least.js +0 -1
- package/vendor/d3-array/src/leastIndex.js +0 -1
- package/vendor/d3-array/src/map.js +0 -1
- package/vendor/d3-array/src/max.js +0 -1
- package/vendor/d3-array/src/maxIndex.js +0 -1
- package/vendor/d3-array/src/mean.js +0 -1
- package/vendor/d3-array/src/median.js +0 -1
- package/vendor/d3-array/src/merge.js +0 -1
- package/vendor/d3-array/src/min.js +0 -1
- package/vendor/d3-array/src/minIndex.js +0 -1
- package/vendor/d3-array/src/mode.js +0 -1
- package/vendor/d3-array/src/nice.js +0 -1
- package/vendor/d3-array/src/number.js +0 -5
- package/vendor/d3-array/src/pairs.js +0 -1
- package/vendor/d3-array/src/permute.js +0 -1
- package/vendor/d3-array/src/quantile.js +0 -1
- package/vendor/d3-array/src/quickselect.js +0 -1
- package/vendor/d3-array/src/range.js +0 -1
- package/vendor/d3-array/src/reduce.js +0 -1
- package/vendor/d3-array/src/reverse.js +0 -1
- package/vendor/d3-array/src/scan.js +0 -1
- package/vendor/d3-array/src/set.js +0 -1
- package/vendor/d3-array/src/shuffle.js +0 -1
- package/vendor/d3-array/src/some.js +0 -1
- package/vendor/d3-array/src/sort.js +0 -1
- package/vendor/d3-array/src/subset.js +0 -1
- package/vendor/d3-array/src/sum.js +0 -1
- package/vendor/d3-array/src/superset.js +0 -1
- package/vendor/d3-array/src/threshold/freedmanDiaconis.js +0 -1
- package/vendor/d3-array/src/threshold/scott.js +0 -1
- package/vendor/d3-array/src/threshold/sturges.js +0 -1
- package/vendor/d3-array/src/ticks.js +0 -56
- package/vendor/d3-array/src/transpose.js +0 -1
- package/vendor/d3-array/src/union.js +0 -1
- package/vendor/d3-array/src/variance.js +0 -1
- package/vendor/d3-array/src/zip.js +0 -1
- package/vendor/d3-color/src/color.js +0 -373
- package/vendor/d3-color/src/cubehelix.js +0 -1
- package/vendor/d3-color/src/define.js +0 -12
- package/vendor/d3-color/src/index.js +0 -1
- package/vendor/d3-color/src/lab.js +0 -1
- package/vendor/d3-color/src/math.js +0 -1
- package/vendor/d3-format/src/defaultLocale.js +0 -20
- package/vendor/d3-format/src/exponent.js +0 -7
- package/vendor/d3-format/src/formatDecimal.js +0 -22
- package/vendor/d3-format/src/formatGroup.js +0 -20
- package/vendor/d3-format/src/formatNumerals.js +0 -9
- package/vendor/d3-format/src/formatPrefixAuto.js +0 -18
- package/vendor/d3-format/src/formatRounded.js +0 -13
- package/vendor/d3-format/src/formatSpecifier.js +0 -49
- package/vendor/d3-format/src/formatTrim.js +0 -13
- package/vendor/d3-format/src/formatTypes.js +0 -21
- package/vendor/d3-format/src/identity.js +0 -5
- package/vendor/d3-format/src/index.js +0 -1
- package/vendor/d3-format/src/locale.js +0 -150
- package/vendor/d3-format/src/precisionFixed.js +0 -7
- package/vendor/d3-format/src/precisionPrefix.js +0 -7
- package/vendor/d3-format/src/precisionRound.js +0 -8
- package/vendor/d3-interpolate/src/array.js +0 -19
- package/vendor/d3-interpolate/src/basis.js +0 -1
- package/vendor/d3-interpolate/src/basisClosed.js +0 -1
- package/vendor/d3-interpolate/src/color.js +0 -26
- package/vendor/d3-interpolate/src/constant.js +0 -3
- package/vendor/d3-interpolate/src/cubehelix.js +0 -1
- package/vendor/d3-interpolate/src/date.js +0 -8
- package/vendor/d3-interpolate/src/discrete.js +0 -1
- package/vendor/d3-interpolate/src/hcl.js +0 -1
- package/vendor/d3-interpolate/src/hsl.js +0 -1
- package/vendor/d3-interpolate/src/hue.js +0 -1
- package/vendor/d3-interpolate/src/index.js +0 -1
- package/vendor/d3-interpolate/src/lab.js +0 -1
- package/vendor/d3-interpolate/src/number.js +0 -7
- package/vendor/d3-interpolate/src/numberArray.js +0 -16
- package/vendor/d3-interpolate/src/object.js +0 -25
- package/vendor/d3-interpolate/src/piecewise.js +0 -1
- package/vendor/d3-interpolate/src/quantize.js +0 -1
- package/vendor/d3-interpolate/src/rgb.js +0 -26
- package/vendor/d3-interpolate/src/round.js +0 -7
- package/vendor/d3-interpolate/src/string.js +0 -66
- package/vendor/d3-interpolate/src/transform/decompose.js +0 -1
- package/vendor/d3-interpolate/src/transform/index.js +0 -1
- package/vendor/d3-interpolate/src/transform/parse.js +0 -1
- package/vendor/d3-interpolate/src/value.js +0 -24
- package/vendor/d3-interpolate/src/zoom.js +0 -1
- package/vendor/d3-scale/src/band.js +0 -1
- package/vendor/d3-scale/src/constant.js +0 -7
- package/vendor/d3-scale/src/continuous.js +0 -129
- package/vendor/d3-scale/src/diverging.js +0 -1
- package/vendor/d3-scale/src/identity.js +0 -1
- package/vendor/d3-scale/src/index.js +0 -1
- package/vendor/d3-scale/src/init.js +0 -10
- package/vendor/d3-scale/src/linear.js +0 -72
- package/vendor/d3-scale/src/log.js +0 -1
- package/vendor/d3-scale/src/nice.js +0 -1
- package/vendor/d3-scale/src/number.js +0 -5
- package/vendor/d3-scale/src/ordinal.js +0 -1
- package/vendor/d3-scale/src/pow.js +0 -1
- package/vendor/d3-scale/src/quantile.js +0 -1
- package/vendor/d3-scale/src/quantize.js +0 -1
- package/vendor/d3-scale/src/radial.js +0 -1
- package/vendor/d3-scale/src/sequential.js +0 -1
- package/vendor/d3-scale/src/sequentialQuantile.js +0 -1
- package/vendor/d3-scale/src/symlog.js +0 -1
- package/vendor/d3-scale/src/threshold.js +0 -1
- package/vendor/d3-scale/src/tickFormat.js +0 -35
- package/vendor/d3-scale/src/time.js +0 -1
- package/vendor/d3-scale/src/utcTime.js +0 -1
- package/vendor/d3-time/src/day.js +0 -1
- package/vendor/d3-time/src/duration.js +0 -1
- package/vendor/d3-time/src/hour.js +0 -1
- package/vendor/d3-time/src/index.js +0 -1
- package/vendor/d3-time/src/interval.js +0 -1
- package/vendor/d3-time/src/millisecond.js +0 -1
- package/vendor/d3-time/src/minute.js +0 -1
- package/vendor/d3-time/src/month.js +0 -1
- package/vendor/d3-time/src/second.js +0 -1
- package/vendor/d3-time/src/ticks.js +0 -1
- package/vendor/d3-time/src/utcDay.js +0 -1
- package/vendor/d3-time/src/utcHour.js +0 -1
- package/vendor/d3-time/src/utcMinute.js +0 -1
- package/vendor/d3-time/src/utcMonth.js +0 -1
- package/vendor/d3-time/src/utcWeek.js +0 -1
- package/vendor/d3-time/src/utcYear.js +0 -1
- package/vendor/d3-time/src/week.js +0 -1
- package/vendor/d3-time/src/year.js +0 -1
- package/vendor/d3-time-format/src/defaultLocale.js +0 -1
- package/vendor/d3-time-format/src/index.js +0 -1
- package/vendor/d3-time-format/src/isoFormat.js +0 -1
- package/vendor/d3-time-format/src/isoParse.js +0 -1
- package/vendor/d3-time-format/src/locale.js +0 -1
- package/vendor/define-properties/index.js +0 -60
- package/vendor/gl-matrix/esm/common.js +0 -30
- package/vendor/gl-matrix/esm/index.js +0 -1
- package/vendor/gl-matrix/esm/mat2.js +0 -1
- package/vendor/gl-matrix/esm/mat2d.js +0 -1
- package/vendor/gl-matrix/esm/mat3.js +0 -817
- package/vendor/gl-matrix/esm/mat4.js +0 -1868
- package/vendor/gl-matrix/esm/quat.js +0 -330
- package/vendor/gl-matrix/esm/quat2.js +0 -1
- package/vendor/gl-matrix/esm/vec2.js +0 -1
- package/vendor/gl-matrix/esm/vec3.js +0 -842
- package/vendor/gl-matrix/esm/vec4.js +0 -153
- package/vendor/globalthis/implementation.browser.js +0 -11
- package/vendor/globalthis/index.js +0 -25
- package/vendor/globalthis/polyfill.js +0 -14
- package/vendor/globalthis/shim.js +0 -25
- package/vendor/internmap/src/index.js +0 -1
- package/vendor/jszip/dist/jszip.min.js +0 -11
- package/vendor/object-keys/implementation.js +0 -124
- package/vendor/object-keys/index.js +0 -35
- package/vendor/object-keys/isArguments.js +0 -17
- package/vendor/pako/dist/pako.esm.mjs.js +0 -6707
- package/vendor/seedrandom/index.js +0 -77
- package/vendor/seedrandom/lib/alea.js +0 -117
- package/vendor/seedrandom/lib/tychei.js +0 -105
- package/vendor/seedrandom/lib/xor128.js +0 -84
- package/vendor/seedrandom/lib/xor4096.js +0 -150
- package/vendor/seedrandom/lib/xorshift7.js +0 -101
- package/vendor/seedrandom/lib/xorwow.js +0 -89
- package/vendor/seedrandom/seedrandom.js +0 -256
- package/vendor/webworker-promise/lib/register.js +0 -158
- package/vendor/webworker-promise/lib/tiny-emitter.js +0 -89
- package/vendor/webworker-promise/src/index.js +0 -110
- package/vendor/webworker-promise/src/tiny-emitter.js +0 -51
- package/vendor/xmlbuilder2/lib/xmlbuilder2.min.js +0 -13
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { c as commonjsGlobal } from '../../../_virtual/commonjsHelpers.js';
|
|
2
|
-
import { x as xorwow } from '../../../_vendor/seedrandom/lib/xorwow.js_commonjs-module.js';
|
|
3
|
-
|
|
4
|
-
(function (module) {
|
|
5
|
-
// A Javascript implementaion of the "xorwow" prng algorithm by
|
|
6
|
-
// George Marsaglia. See http://www.jstatsoft.org/v08/i14/paper
|
|
7
|
-
|
|
8
|
-
(function(global, module, define) {
|
|
9
|
-
|
|
10
|
-
function XorGen(seed) {
|
|
11
|
-
var me = this, strseed = '';
|
|
12
|
-
|
|
13
|
-
// Set up generator function.
|
|
14
|
-
me.next = function() {
|
|
15
|
-
var t = (me.x ^ (me.x >>> 2));
|
|
16
|
-
me.x = me.y; me.y = me.z; me.z = me.w; me.w = me.v;
|
|
17
|
-
return (me.d = (me.d + 362437 | 0)) +
|
|
18
|
-
(me.v = (me.v ^ (me.v << 4)) ^ (t ^ (t << 1))) | 0;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
me.x = 0;
|
|
22
|
-
me.y = 0;
|
|
23
|
-
me.z = 0;
|
|
24
|
-
me.w = 0;
|
|
25
|
-
me.v = 0;
|
|
26
|
-
|
|
27
|
-
if (seed === (seed | 0)) {
|
|
28
|
-
// Integer seed.
|
|
29
|
-
me.x = seed;
|
|
30
|
-
} else {
|
|
31
|
-
// String seed.
|
|
32
|
-
strseed += seed;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Mix in string seed, then discard an initial batch of 64 values.
|
|
36
|
-
for (var k = 0; k < strseed.length + 64; k++) {
|
|
37
|
-
me.x ^= strseed.charCodeAt(k) | 0;
|
|
38
|
-
if (k == strseed.length) {
|
|
39
|
-
me.d = me.x << 10 ^ me.x >>> 4;
|
|
40
|
-
}
|
|
41
|
-
me.next();
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function copy(f, t) {
|
|
46
|
-
t.x = f.x;
|
|
47
|
-
t.y = f.y;
|
|
48
|
-
t.z = f.z;
|
|
49
|
-
t.w = f.w;
|
|
50
|
-
t.v = f.v;
|
|
51
|
-
t.d = f.d;
|
|
52
|
-
return t;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function impl(seed, opts) {
|
|
56
|
-
var xg = new XorGen(seed),
|
|
57
|
-
state = opts && opts.state,
|
|
58
|
-
prng = function() { return (xg.next() >>> 0) / 0x100000000; };
|
|
59
|
-
prng.double = function() {
|
|
60
|
-
do {
|
|
61
|
-
var top = xg.next() >>> 11,
|
|
62
|
-
bot = (xg.next() >>> 0) / 0x100000000,
|
|
63
|
-
result = (top + bot) / (1 << 21);
|
|
64
|
-
} while (result === 0);
|
|
65
|
-
return result;
|
|
66
|
-
};
|
|
67
|
-
prng.int32 = xg.next;
|
|
68
|
-
prng.quick = prng;
|
|
69
|
-
if (state) {
|
|
70
|
-
if (typeof(state) == 'object') copy(state, xg);
|
|
71
|
-
prng.state = function() { return copy(xg, {}); };
|
|
72
|
-
}
|
|
73
|
-
return prng;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (module && module.exports) {
|
|
77
|
-
module.exports = impl;
|
|
78
|
-
} else if (define && define.amd) {
|
|
79
|
-
define(function() { return impl; });
|
|
80
|
-
} else {
|
|
81
|
-
this.xorwow = impl;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
})(
|
|
85
|
-
commonjsGlobal,
|
|
86
|
-
module, // present in node.js
|
|
87
|
-
(typeof undefined) == 'function' // present with an AMD loader
|
|
88
|
-
);
|
|
89
|
-
}(xorwow));
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
import { c as commonjsGlobal } from '../../_virtual/commonjsHelpers.js';
|
|
2
|
-
import { s as seedrandom } from '../../_vendor/seedrandom/seedrandom.js_commonjs-module.js';
|
|
3
|
-
import { r as require$$0 } from '../../_virtual/_rollup_plugin_ignore_empty_module_placeholder_commonjs-proxy.js';
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
Copyright 2019 David Bau.
|
|
7
|
-
|
|
8
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
9
|
-
a copy of this software and associated documentation files (the
|
|
10
|
-
"Software"), to deal in the Software without restriction, including
|
|
11
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
12
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
13
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
14
|
-
the following conditions:
|
|
15
|
-
|
|
16
|
-
The above copyright notice and this permission notice shall be
|
|
17
|
-
included in all copies or substantial portions of the Software.
|
|
18
|
-
|
|
19
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
20
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
21
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
22
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
23
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
24
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
25
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
26
|
-
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
(function (module) {
|
|
30
|
-
(function (global, pool, math) {
|
|
31
|
-
//
|
|
32
|
-
// The following constants are related to IEEE 754 limits.
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
var width = 256, // each RC4 output is 0 <= x < 256
|
|
36
|
-
chunks = 6, // at least six RC4 outputs for each double
|
|
37
|
-
digits = 52, // there are 52 significant digits in a double
|
|
38
|
-
rngname = 'random', // rngname: name for Math.random and Math.seedrandom
|
|
39
|
-
startdenom = math.pow(width, chunks),
|
|
40
|
-
significance = math.pow(2, digits),
|
|
41
|
-
overflow = significance * 2,
|
|
42
|
-
mask = width - 1,
|
|
43
|
-
nodecrypto; // node.js crypto module, initialized at the bottom.
|
|
44
|
-
|
|
45
|
-
//
|
|
46
|
-
// seedrandom()
|
|
47
|
-
// This is the seedrandom function described above.
|
|
48
|
-
//
|
|
49
|
-
function seedrandom(seed, options, callback) {
|
|
50
|
-
var key = [];
|
|
51
|
-
options = (options == true) ? { entropy: true } : (options || {});
|
|
52
|
-
|
|
53
|
-
// Flatten the seed string or build one from local entropy if needed.
|
|
54
|
-
var shortseed = mixkey(flatten(
|
|
55
|
-
options.entropy ? [seed, tostring(pool)] :
|
|
56
|
-
(seed == null) ? autoseed() : seed, 3), key);
|
|
57
|
-
|
|
58
|
-
// Use the seed to initialize an ARC4 generator.
|
|
59
|
-
var arc4 = new ARC4(key);
|
|
60
|
-
|
|
61
|
-
// This function returns a random double in [0, 1) that contains
|
|
62
|
-
// randomness in every bit of the mantissa of the IEEE 754 value.
|
|
63
|
-
var prng = function() {
|
|
64
|
-
var n = arc4.g(chunks), // Start with a numerator n < 2 ^ 48
|
|
65
|
-
d = startdenom, // and denominator d = 2 ^ 48.
|
|
66
|
-
x = 0; // and no 'extra last byte'.
|
|
67
|
-
while (n < significance) { // Fill up all significant digits by
|
|
68
|
-
n = (n + x) * width; // shifting numerator and
|
|
69
|
-
d *= width; // denominator and generating a
|
|
70
|
-
x = arc4.g(1); // new least-significant-byte.
|
|
71
|
-
}
|
|
72
|
-
while (n >= overflow) { // To avoid rounding up, before adding
|
|
73
|
-
n /= 2; // last byte, shift everything
|
|
74
|
-
d /= 2; // right using integer math until
|
|
75
|
-
x >>>= 1; // we have exactly the desired bits.
|
|
76
|
-
}
|
|
77
|
-
return (n + x) / d; // Form the number within [0, 1).
|
|
78
|
-
};
|
|
79
|
-
|
|
80
|
-
prng.int32 = function() { return arc4.g(4) | 0; };
|
|
81
|
-
prng.quick = function() { return arc4.g(4) / 0x100000000; };
|
|
82
|
-
prng.double = prng;
|
|
83
|
-
|
|
84
|
-
// Mix the randomness into accumulated entropy.
|
|
85
|
-
mixkey(tostring(arc4.S), pool);
|
|
86
|
-
|
|
87
|
-
// Calling convention: what to return as a function of prng, seed, is_math.
|
|
88
|
-
return (options.pass || callback ||
|
|
89
|
-
function(prng, seed, is_math_call, state) {
|
|
90
|
-
if (state) {
|
|
91
|
-
// Load the arc4 state from the given state if it has an S array.
|
|
92
|
-
if (state.S) { copy(state, arc4); }
|
|
93
|
-
// Only provide the .state method if requested via options.state.
|
|
94
|
-
prng.state = function() { return copy(arc4, {}); };
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// If called as a method of Math (Math.seedrandom()), mutate
|
|
98
|
-
// Math.random because that is how seedrandom.js has worked since v1.0.
|
|
99
|
-
if (is_math_call) { math[rngname] = prng; return seed; }
|
|
100
|
-
|
|
101
|
-
// Otherwise, it is a newer calling convention, so return the
|
|
102
|
-
// prng directly.
|
|
103
|
-
else return prng;
|
|
104
|
-
})(
|
|
105
|
-
prng,
|
|
106
|
-
shortseed,
|
|
107
|
-
'global' in options ? options.global : (this == math),
|
|
108
|
-
options.state);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
//
|
|
112
|
-
// ARC4
|
|
113
|
-
//
|
|
114
|
-
// An ARC4 implementation. The constructor takes a key in the form of
|
|
115
|
-
// an array of at most (width) integers that should be 0 <= x < (width).
|
|
116
|
-
//
|
|
117
|
-
// The g(count) method returns a pseudorandom integer that concatenates
|
|
118
|
-
// the next (count) outputs from ARC4. Its return value is a number x
|
|
119
|
-
// that is in the range 0 <= x < (width ^ count).
|
|
120
|
-
//
|
|
121
|
-
function ARC4(key) {
|
|
122
|
-
var t, keylen = key.length,
|
|
123
|
-
me = this, i = 0, j = me.i = me.j = 0, s = me.S = [];
|
|
124
|
-
|
|
125
|
-
// The empty key [] is treated as [0].
|
|
126
|
-
if (!keylen) { key = [keylen++]; }
|
|
127
|
-
|
|
128
|
-
// Set up S using the standard key scheduling algorithm.
|
|
129
|
-
while (i < width) {
|
|
130
|
-
s[i] = i++;
|
|
131
|
-
}
|
|
132
|
-
for (i = 0; i < width; i++) {
|
|
133
|
-
s[i] = s[j = mask & (j + key[i % keylen] + (t = s[i]))];
|
|
134
|
-
s[j] = t;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// The "g" method returns the next (count) outputs as one number.
|
|
138
|
-
(me.g = function(count) {
|
|
139
|
-
// Using instance members instead of closure state nearly doubles speed.
|
|
140
|
-
var t, r = 0,
|
|
141
|
-
i = me.i, j = me.j, s = me.S;
|
|
142
|
-
while (count--) {
|
|
143
|
-
t = s[i = mask & (i + 1)];
|
|
144
|
-
r = r * width + s[mask & ((s[i] = s[j = mask & (j + t)]) + (s[j] = t))];
|
|
145
|
-
}
|
|
146
|
-
me.i = i; me.j = j;
|
|
147
|
-
return r;
|
|
148
|
-
// For robust unpredictability, the function call below automatically
|
|
149
|
-
// discards an initial batch of values. This is called RC4-drop[256].
|
|
150
|
-
// See http://google.com/search?q=rsa+fluhrer+response&btnI
|
|
151
|
-
})(width);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
//
|
|
155
|
-
// copy()
|
|
156
|
-
// Copies internal state of ARC4 to or from a plain object.
|
|
157
|
-
//
|
|
158
|
-
function copy(f, t) {
|
|
159
|
-
t.i = f.i;
|
|
160
|
-
t.j = f.j;
|
|
161
|
-
t.S = f.S.slice();
|
|
162
|
-
return t;
|
|
163
|
-
}
|
|
164
|
-
//
|
|
165
|
-
// flatten()
|
|
166
|
-
// Converts an object tree to nested arrays of strings.
|
|
167
|
-
//
|
|
168
|
-
function flatten(obj, depth) {
|
|
169
|
-
var result = [], typ = (typeof obj), prop;
|
|
170
|
-
if (depth && typ == 'object') {
|
|
171
|
-
for (prop in obj) {
|
|
172
|
-
try { result.push(flatten(obj[prop], depth - 1)); } catch (e) {}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
return (result.length ? result : typ == 'string' ? obj : obj + '\0');
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
// mixkey()
|
|
180
|
-
// Mixes a string seed into a key that is an array of integers, and
|
|
181
|
-
// returns a shortened string seed that is equivalent to the result key.
|
|
182
|
-
//
|
|
183
|
-
function mixkey(seed, key) {
|
|
184
|
-
var stringseed = seed + '', smear, j = 0;
|
|
185
|
-
while (j < stringseed.length) {
|
|
186
|
-
key[mask & j] =
|
|
187
|
-
mask & ((smear ^= key[mask & j] * 19) + stringseed.charCodeAt(j++));
|
|
188
|
-
}
|
|
189
|
-
return tostring(key);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
//
|
|
193
|
-
// autoseed()
|
|
194
|
-
// Returns an object for autoseeding, using window.crypto and Node crypto
|
|
195
|
-
// module if available.
|
|
196
|
-
//
|
|
197
|
-
function autoseed() {
|
|
198
|
-
try {
|
|
199
|
-
var out;
|
|
200
|
-
if (nodecrypto && (out = nodecrypto.randomBytes)) {
|
|
201
|
-
// The use of 'out' to remember randomBytes makes tight minified code.
|
|
202
|
-
out = out(width);
|
|
203
|
-
} else {
|
|
204
|
-
out = new Uint8Array(width);
|
|
205
|
-
(global.crypto || global.msCrypto).getRandomValues(out);
|
|
206
|
-
}
|
|
207
|
-
return tostring(out);
|
|
208
|
-
} catch (e) {
|
|
209
|
-
var browser = global.navigator,
|
|
210
|
-
plugins = browser && browser.plugins;
|
|
211
|
-
return [+new Date, global, plugins, global.screen, tostring(pool)];
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
//
|
|
216
|
-
// tostring()
|
|
217
|
-
// Converts an array of charcodes to a string
|
|
218
|
-
//
|
|
219
|
-
function tostring(a) {
|
|
220
|
-
return String.fromCharCode.apply(0, a);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
//
|
|
224
|
-
// When seedrandom.js is loaded, we immediately mix a few bits
|
|
225
|
-
// from the built-in RNG into the entropy pool. Because we do
|
|
226
|
-
// not want to interfere with deterministic PRNG state later,
|
|
227
|
-
// seedrandom will not call math.random on its own again after
|
|
228
|
-
// initialization.
|
|
229
|
-
//
|
|
230
|
-
mixkey(math.random(), pool);
|
|
231
|
-
|
|
232
|
-
//
|
|
233
|
-
// Nodejs and AMD support: export the implementation as a module using
|
|
234
|
-
// either convention.
|
|
235
|
-
//
|
|
236
|
-
if (module.exports) {
|
|
237
|
-
module.exports = seedrandom;
|
|
238
|
-
// When in node.js, try using crypto package for autoseeding.
|
|
239
|
-
try {
|
|
240
|
-
nodecrypto = require$$0;
|
|
241
|
-
} catch (ex) {}
|
|
242
|
-
} else {
|
|
243
|
-
// When included as a plain script, set up Math.seedrandom global.
|
|
244
|
-
math['seed' + rngname] = seedrandom;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
// End anonymous scope, and pass initial values.
|
|
249
|
-
})(
|
|
250
|
-
// global: `self` in browsers (including strict mode and web workers),
|
|
251
|
-
// otherwise `this` in Node and other environments
|
|
252
|
-
(typeof self !== 'undefined') ? self : commonjsGlobal,
|
|
253
|
-
[], // pool: entropy pool starts empty
|
|
254
|
-
Math // math: package containing random, pow, and seedrandom
|
|
255
|
-
);
|
|
256
|
-
}(seedrandom));
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
import { r as register } from '../../../_vendor/webworker-promise/lib/register.js_commonjs-module.js';
|
|
2
|
-
import { t as tinyEmitter } from './tiny-emitter.js';
|
|
3
|
-
|
|
4
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
5
|
-
|
|
6
|
-
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
|
7
|
-
|
|
8
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
|
|
9
|
-
|
|
10
|
-
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
11
|
-
|
|
12
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
|
|
14
|
-
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
|
15
|
-
|
|
16
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
17
|
-
|
|
18
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
|
|
20
|
-
var TinyEmitter = tinyEmitter;
|
|
21
|
-
|
|
22
|
-
var MESSAGE_RESULT = 0;
|
|
23
|
-
var MESSAGE_EVENT = 1;
|
|
24
|
-
|
|
25
|
-
var RESULT_ERROR = 0;
|
|
26
|
-
var RESULT_SUCCESS = 1;
|
|
27
|
-
|
|
28
|
-
var DEFAULT_HANDLER = 'main';
|
|
29
|
-
|
|
30
|
-
var isPromise = function isPromise(o) {
|
|
31
|
-
return (typeof o === 'undefined' ? 'undefined' : _typeof(o)) === 'object' && o !== null && typeof o.then === 'function' && typeof o.catch === 'function';
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
function RegisterPromise(fn) {
|
|
35
|
-
var handlers = _defineProperty({}, DEFAULT_HANDLER, fn);
|
|
36
|
-
var sendPostMessage = self.postMessage.bind(self);
|
|
37
|
-
|
|
38
|
-
var server = new (function (_TinyEmitter) {
|
|
39
|
-
_inherits(WorkerRegister, _TinyEmitter);
|
|
40
|
-
|
|
41
|
-
function WorkerRegister() {
|
|
42
|
-
_classCallCheck(this, WorkerRegister);
|
|
43
|
-
|
|
44
|
-
return _possibleConstructorReturn(this, (WorkerRegister.__proto__ || Object.getPrototypeOf(WorkerRegister)).apply(this, arguments));
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
_createClass(WorkerRegister, [{
|
|
48
|
-
key: 'emit',
|
|
49
|
-
value: function emit(eventName) {
|
|
50
|
-
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
51
|
-
args[_key - 1] = arguments[_key];
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (args.length == 1 && args[0] instanceof TransferableResponse) {
|
|
55
|
-
sendPostMessage({ eventName: eventName, args: args }, args[0].transferable);
|
|
56
|
-
} else {
|
|
57
|
-
sendPostMessage({ eventName: eventName, args: args });
|
|
58
|
-
}
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
}, {
|
|
62
|
-
key: 'emitLocally',
|
|
63
|
-
value: function emitLocally(eventName) {
|
|
64
|
-
var _get2;
|
|
65
|
-
|
|
66
|
-
for (var _len2 = arguments.length, args = Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
67
|
-
args[_key2 - 1] = arguments[_key2];
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
(_get2 = _get(WorkerRegister.prototype.__proto__ || Object.getPrototypeOf(WorkerRegister.prototype), 'emit', this)).call.apply(_get2, [this, eventName].concat(args));
|
|
71
|
-
}
|
|
72
|
-
}, {
|
|
73
|
-
key: 'operation',
|
|
74
|
-
value: function operation(name, handler) {
|
|
75
|
-
handlers[name] = handler;
|
|
76
|
-
return this;
|
|
77
|
-
}
|
|
78
|
-
}]);
|
|
79
|
-
|
|
80
|
-
return WorkerRegister;
|
|
81
|
-
}(TinyEmitter))();
|
|
82
|
-
|
|
83
|
-
var run = function run(messageId, payload, handlerName) {
|
|
84
|
-
|
|
85
|
-
var onSuccess = function onSuccess(result) {
|
|
86
|
-
if (result && result instanceof TransferableResponse) {
|
|
87
|
-
sendResult(messageId, RESULT_SUCCESS, result.payload, result.transferable);
|
|
88
|
-
} else {
|
|
89
|
-
sendResult(messageId, RESULT_SUCCESS, result);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
var onError = function onError(e) {
|
|
94
|
-
sendResult(messageId, RESULT_ERROR, {
|
|
95
|
-
message: e.message,
|
|
96
|
-
stack: e.stack
|
|
97
|
-
});
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
try {
|
|
101
|
-
var result = runFn(messageId, payload, handlerName);
|
|
102
|
-
if (isPromise(result)) {
|
|
103
|
-
result.then(onSuccess).catch(onError);
|
|
104
|
-
} else {
|
|
105
|
-
onSuccess(result);
|
|
106
|
-
}
|
|
107
|
-
} catch (e) {
|
|
108
|
-
onError(e);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
var runFn = function runFn(messageId, payload, handlerName) {
|
|
113
|
-
var handler = handlers[handlerName || DEFAULT_HANDLER];
|
|
114
|
-
if (!handler) throw new Error('Not found handler for this request');
|
|
115
|
-
|
|
116
|
-
return handler(payload, sendEvent.bind(null, messageId));
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
var sendResult = function sendResult(messageId, success, payload) {
|
|
120
|
-
var transferable = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
|
|
121
|
-
|
|
122
|
-
sendPostMessage([MESSAGE_RESULT, messageId, success, payload], transferable);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
var sendEvent = function sendEvent(messageId, eventName, payload) {
|
|
126
|
-
if (!eventName) throw new Error('eventName is required');
|
|
127
|
-
|
|
128
|
-
if (typeof eventName !== 'string') throw new Error('eventName should be string');
|
|
129
|
-
|
|
130
|
-
sendPostMessage([MESSAGE_EVENT, messageId, eventName, payload]);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
self.addEventListener('message', function (_ref) {
|
|
134
|
-
var data = _ref.data;
|
|
135
|
-
|
|
136
|
-
if (Array.isArray(data)) {
|
|
137
|
-
run.apply(undefined, _toConsumableArray(data));
|
|
138
|
-
} else if (data && data.eventName) {
|
|
139
|
-
server.emitLocally.apply(server, [data.eventName].concat(_toConsumableArray(data.args)));
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
return server;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
var TransferableResponse = function TransferableResponse(payload, transferable) {
|
|
147
|
-
_classCallCheck(this, TransferableResponse);
|
|
148
|
-
|
|
149
|
-
this.payload = payload;
|
|
150
|
-
this.transferable = transferable;
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
register.exports = RegisterPromise;
|
|
154
|
-
register.exports.TransferableResponse = TransferableResponse;
|
|
155
|
-
|
|
156
|
-
var registerWebworker = register.exports;
|
|
157
|
-
|
|
158
|
-
export { registerWebworker as r };
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
|
2
|
-
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
|
|
5
|
-
var TinyEmitter = function () {
|
|
6
|
-
function TinyEmitter() {
|
|
7
|
-
_classCallCheck(this, TinyEmitter);
|
|
8
|
-
|
|
9
|
-
Object.defineProperty(this, '__listeners', {
|
|
10
|
-
value: {},
|
|
11
|
-
enumerable: false,
|
|
12
|
-
writable: false
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
_createClass(TinyEmitter, [{
|
|
17
|
-
key: 'emit',
|
|
18
|
-
value: function emit(eventName) {
|
|
19
|
-
if (!this.__listeners[eventName]) return this;
|
|
20
|
-
|
|
21
|
-
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
22
|
-
args[_key - 1] = arguments[_key];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var _iteratorNormalCompletion = true;
|
|
26
|
-
var _didIteratorError = false;
|
|
27
|
-
var _iteratorError = undefined;
|
|
28
|
-
|
|
29
|
-
try {
|
|
30
|
-
for (var _iterator = this.__listeners[eventName][Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
|
31
|
-
var handler = _step.value;
|
|
32
|
-
|
|
33
|
-
handler.apply(undefined, args);
|
|
34
|
-
}
|
|
35
|
-
} catch (err) {
|
|
36
|
-
_didIteratorError = true;
|
|
37
|
-
_iteratorError = err;
|
|
38
|
-
} finally {
|
|
39
|
-
try {
|
|
40
|
-
if (!_iteratorNormalCompletion && _iterator.return) {
|
|
41
|
-
_iterator.return();
|
|
42
|
-
}
|
|
43
|
-
} finally {
|
|
44
|
-
if (_didIteratorError) {
|
|
45
|
-
throw _iteratorError;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return this;
|
|
51
|
-
}
|
|
52
|
-
}, {
|
|
53
|
-
key: 'once',
|
|
54
|
-
value: function once(eventName, handler) {
|
|
55
|
-
var _this = this;
|
|
56
|
-
|
|
57
|
-
var once = function once() {
|
|
58
|
-
_this.off(eventName, once);
|
|
59
|
-
handler.apply(undefined, arguments);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
return this.on(eventName, once);
|
|
63
|
-
}
|
|
64
|
-
}, {
|
|
65
|
-
key: 'on',
|
|
66
|
-
value: function on(eventName, handler) {
|
|
67
|
-
if (!this.__listeners[eventName]) this.__listeners[eventName] = [];
|
|
68
|
-
|
|
69
|
-
this.__listeners[eventName].push(handler);
|
|
70
|
-
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: 'off',
|
|
75
|
-
value: function off(eventName, handler) {
|
|
76
|
-
if (handler) this.__listeners[eventName] = this.__listeners[eventName].filter(function (h) {
|
|
77
|
-
return h !== handler;
|
|
78
|
-
});else this.__listeners[eventName] = [];
|
|
79
|
-
|
|
80
|
-
return this;
|
|
81
|
-
}
|
|
82
|
-
}]);
|
|
83
|
-
|
|
84
|
-
return TinyEmitter;
|
|
85
|
-
}();
|
|
86
|
-
|
|
87
|
-
var tinyEmitter = TinyEmitter;
|
|
88
|
-
|
|
89
|
-
export { tinyEmitter as t };
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import { t as tinyEmitter } from './tiny-emitter.js';
|
|
2
|
-
|
|
3
|
-
const TinyEmitter = tinyEmitter;
|
|
4
|
-
|
|
5
|
-
const MESSAGE_RESULT = 0;
|
|
6
|
-
const MESSAGE_EVENT = 1;
|
|
7
|
-
const RESULT_SUCCESS = 1;
|
|
8
|
-
|
|
9
|
-
class Worker extends TinyEmitter {
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param worker {Worker}
|
|
13
|
-
*/
|
|
14
|
-
constructor(worker) {
|
|
15
|
-
super();
|
|
16
|
-
|
|
17
|
-
this._messageId = 1;
|
|
18
|
-
this._messages = new Map();
|
|
19
|
-
|
|
20
|
-
this._worker = worker;
|
|
21
|
-
this._worker.onmessage = this._onMessage.bind(this);
|
|
22
|
-
this._id = Math.ceil(Math.random() * 10000000);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
terminate() {
|
|
26
|
-
this._worker.terminate();
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* return true if there is no unresolved jobs
|
|
31
|
-
* @returns {boolean}
|
|
32
|
-
*/
|
|
33
|
-
isFree() {
|
|
34
|
-
return this._messages.size === 0;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
jobsLength() {
|
|
38
|
-
return this._messages.size;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* @param operationName string
|
|
43
|
-
* @param data any
|
|
44
|
-
* @param transferable array
|
|
45
|
-
* @param onEvent function
|
|
46
|
-
* @returns {Promise}
|
|
47
|
-
*/
|
|
48
|
-
exec(operationName, data = null, transferable = [], onEvent) {
|
|
49
|
-
return new Promise((res, rej) => {
|
|
50
|
-
const messageId = this._messageId++;
|
|
51
|
-
this._messages.set(messageId, [res, rej, onEvent]);
|
|
52
|
-
this._worker.postMessage([messageId, data, operationName], transferable || []);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
*
|
|
58
|
-
* @param data any
|
|
59
|
-
* @param transferable array
|
|
60
|
-
* @param onEvent function
|
|
61
|
-
* @returns {Promise}
|
|
62
|
-
*/
|
|
63
|
-
postMessage(data = null, transferable = [], onEvent) {
|
|
64
|
-
return new Promise((res, rej) => {
|
|
65
|
-
const messageId = this._messageId++;
|
|
66
|
-
this._messages.set(messageId, [res, rej, onEvent]);
|
|
67
|
-
this._worker.postMessage([messageId, data], transferable || []);
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
emit(eventName, ...args) {
|
|
72
|
-
this._worker.postMessage({eventName, args});
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
_onMessage(e) {
|
|
76
|
-
//if we got usual event, just emit it locally
|
|
77
|
-
if(!Array.isArray(e.data) && e.data.eventName) {
|
|
78
|
-
return super.emit(e.data.eventName, ...e.data.args);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const [type, ...args] = e.data;
|
|
82
|
-
|
|
83
|
-
if(type === MESSAGE_EVENT)
|
|
84
|
-
this._onEvent(...args);
|
|
85
|
-
else if(type === MESSAGE_RESULT)
|
|
86
|
-
this._onResult(...args);
|
|
87
|
-
else
|
|
88
|
-
throw new Error(`Wrong message type '${type}'`);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
_onResult(messageId, success, payload) {
|
|
92
|
-
const [res, rej] = this._messages.get(messageId);
|
|
93
|
-
this._messages.delete(messageId);
|
|
94
|
-
|
|
95
|
-
return success === RESULT_SUCCESS ? res(payload) : rej(payload);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
_onEvent(messageId, eventName, data) {
|
|
99
|
-
const [,,onEvent] = this._messages.get(messageId);
|
|
100
|
-
|
|
101
|
-
if(onEvent) {
|
|
102
|
-
onEvent(eventName, data);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
var src = Worker;
|
|
109
|
-
|
|
110
|
-
export { src as s };
|