uplot-webgpu 0.1.0 → 0.2.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.
Files changed (42) hide show
  1. package/index.js +0 -17
  2. package/index.ts +5 -0
  3. package/package.json +4 -69
  4. package/paths/ts/bars.ts +253 -0
  5. package/paths/ts/catmullRomCentrip.ts +127 -0
  6. package/paths/ts/index.ts +9 -0
  7. package/paths/ts/linear.ts +172 -0
  8. package/paths/ts/monotoneCubic.ts +70 -0
  9. package/paths/ts/points.ts +70 -0
  10. package/paths/ts/spline.ts +105 -0
  11. package/paths/ts/stepped.ts +126 -0
  12. package/paths/ts/types.ts +143 -0
  13. package/paths/ts/utils.ts +303 -0
  14. package/scripts/ts/uPlot.ts +3732 -0
  15. package/scripts/ts/utils/dom.ts +124 -0
  16. package/scripts/ts/utils/domClasses.ts +22 -0
  17. package/scripts/ts/utils/feats.ts +13 -0
  18. package/scripts/ts/utils/fmtDate.ts +398 -0
  19. package/scripts/ts/utils/opts.ts +844 -0
  20. package/scripts/ts/utils/strings.ts +22 -0
  21. package/scripts/ts/utils/sync.ts +27 -0
  22. package/scripts/ts/utils/utils.ts +692 -0
  23. package/scripts/{webgpu → ts/webgpu}/GPUPath.ts +92 -41
  24. package/scripts/{webgpu → ts/webgpu}/WebGPURenderer.ts +176 -84
  25. package/scripts/ts/webgpu/exporters.ts +221 -0
  26. package/scripts/ts/webgpu/index.ts +31 -0
  27. package/scripts/{webgpu → ts/webgpu}/shaders.ts +0 -1
  28. package/scripts/uPlot.js +0 -2
  29. package/scripts/webgpu/GPUPath.js +513 -606
  30. package/scripts/webgpu/WebGPURenderer.js +3484 -4018
  31. package/scripts/webgpu/exporters.js +191 -201
  32. package/scripts/webgpu/index.js +12 -0
  33. package/scripts/webgpu/shaders.js +6 -3
  34. package/tinybuild.config.js +6 -6
  35. package/tsconfig.json +64 -0
  36. package/scripts/uPlot.d.ts +0 -26
  37. package/scripts/webgpu/GPUPath.d.ts +0 -46
  38. package/scripts/webgpu/WebGPURenderer.d.ts +0 -176
  39. package/scripts/webgpu/exporters.d.ts +0 -8
  40. package/scripts/webgpu/shaders.d.ts +0 -2
  41. package/scripts/webgpu/smokeTest.d.ts +0 -2
  42. package/scripts/webgpu/webgpu-ambient.d.ts +0 -41
@@ -1,212 +1,202 @@
1
- export function rgbaImageDataToBmpBytes(imageData) {
2
- let width = Math.max(0, Math.floor(Number(imageData?.width) || 0));
3
- let height = Math.max(0, Math.floor(Number(imageData?.height) || 0));
4
- let data = imageData?.data || new Uint8ClampedArray(0);
5
- let rowStride = Math.ceil((width * 4) / 4) * 4;
6
- let pixelBytes = rowStride * height;
7
- let bytes = new Uint8Array(14 + 40 + pixelBytes);
8
- let view = new DataView(bytes.buffer);
9
-
10
- bytes[0] = 0x42;
11
- bytes[1] = 0x4d;
12
- view.setUint32(2, bytes.length, true);
13
- view.setUint32(10, 54, true);
14
- view.setUint32(14, 40, true);
15
- view.setInt32(18, width, true);
16
- view.setInt32(22, -height, true);
17
- view.setUint16(26, 1, true);
18
- view.setUint16(28, 32, true);
19
- view.setUint32(34, pixelBytes, true);
20
-
21
- let out = 54;
22
- for (let y = 0; y < height; y++) {
23
- let src = y * width * 4;
24
- for (let x = 0; x < width; x++) {
25
- let si = src + x * 4;
26
- let di = out + x * 4;
27
- bytes[di + 0] = data[si + 2] || 0;
28
- bytes[di + 1] = data[si + 1] || 0;
29
- bytes[di + 2] = data[si + 0] || 0;
30
- bytes[di + 3] = data[si + 3] == null ? 255 : data[si + 3];
31
- }
32
- out += rowStride;
33
- }
34
-
35
- return bytes;
36
- }
37
-
38
-
1
+ function rgbaImageDataToBmpBytes(imageData) {
2
+ let width = Math.max(0, Math.floor(Number(imageData?.width) || 0));
3
+ let height = Math.max(0, Math.floor(Number(imageData?.height) || 0));
4
+ let data = imageData?.data || new Uint8ClampedArray(0);
5
+ let rowStride = Math.ceil(width * 4 / 4) * 4;
6
+ let pixelBytes = rowStride * height;
7
+ let bytes = new Uint8Array(14 + 40 + pixelBytes);
8
+ let view = new DataView(bytes.buffer);
9
+ bytes[0] = 66;
10
+ bytes[1] = 77;
11
+ view.setUint32(2, bytes.length, true);
12
+ view.setUint32(10, 54, true);
13
+ view.setUint32(14, 40, true);
14
+ view.setInt32(18, width, true);
15
+ view.setInt32(22, -height, true);
16
+ view.setUint16(26, 1, true);
17
+ view.setUint16(28, 32, true);
18
+ view.setUint32(34, pixelBytes, true);
19
+ let out = 54;
20
+ for (let y = 0; y < height; y++) {
21
+ let src = y * width * 4;
22
+ for (let x = 0; x < width; x++) {
23
+ let si = src + x * 4;
24
+ let di = out + x * 4;
25
+ bytes[di + 0] = data[si + 2] || 0;
26
+ bytes[di + 1] = data[si + 1] || 0;
27
+ bytes[di + 2] = data[si + 0] || 0;
28
+ bytes[di + 3] = data[si + 3] == null ? 255 : data[si + 3];
29
+ }
30
+ out += rowStride;
31
+ }
32
+ return bytes;
33
+ }
39
34
  function makeCrc32Table() {
40
- let table = new Uint32Array(256);
41
- for (let i = 0; i < 256; i++) {
42
- let c = i;
43
- for (let j = 0; j < 8; j++)
44
- c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
45
- table[i] = c >>> 0;
46
- }
47
- return table;
48
- }
49
-
35
+ let table = new Uint32Array(256);
36
+ for (let i = 0; i < 256; i++) {
37
+ let c = i;
38
+ for (let j = 0; j < 8; j++)
39
+ c = c & 1 ? 3988292384 ^ c >>> 1 : c >>> 1;
40
+ table[i] = c >>> 0;
41
+ }
42
+ return table;
43
+ }
50
44
  const CRC32_TABLE = makeCrc32Table();
51
-
52
45
  function crc32(bytes) {
53
- let c = 0xffffffff;
54
- for (let i = 0; i < bytes.length; i++)
55
- c = CRC32_TABLE[(c ^ bytes[i]) & 255] ^ (c >>> 8);
56
- return (c ^ 0xffffffff) >>> 0;
46
+ let c = 4294967295;
47
+ for (let i = 0; i < bytes.length; i++)
48
+ c = CRC32_TABLE[(c ^ bytes[i]) & 255] ^ c >>> 8;
49
+ return (c ^ 4294967295) >>> 0;
57
50
  }
58
-
59
51
  function adler32(bytes) {
60
- let a = 1;
61
- let b = 0;
62
- for (let i = 0; i < bytes.length; i++) {
63
- a = (a + bytes[i]) % 65521;
64
- b = (b + a) % 65521;
65
- }
66
- return ((b << 16) | a) >>> 0;
67
- }
68
-
52
+ let a = 1;
53
+ let b = 0;
54
+ for (let i = 0; i < bytes.length; i++) {
55
+ a = (a + bytes[i]) % 65521;
56
+ b = (b + a) % 65521;
57
+ }
58
+ return (b << 16 | a) >>> 0;
59
+ }
69
60
  function writeU32(bytes, offset, value) {
70
- bytes[offset + 0] = (value >>> 24) & 255;
71
- bytes[offset + 1] = (value >>> 16) & 255;
72
- bytes[offset + 2] = (value >>> 8) & 255;
73
- bytes[offset + 3] = value & 255;
61
+ bytes[offset + 0] = value >>> 24 & 255;
62
+ bytes[offset + 1] = value >>> 16 & 255;
63
+ bytes[offset + 2] = value >>> 8 & 255;
64
+ bytes[offset + 3] = value & 255;
74
65
  }
75
-
76
66
  function asciiBytes(text) {
77
- let out = new Uint8Array(text.length);
78
- for (let i = 0; i < text.length; i++)
79
- out[i] = text.charCodeAt(i) & 255;
80
- return out;
67
+ let out = new Uint8Array(text.length);
68
+ for (let i = 0; i < text.length; i++)
69
+ out[i] = text.charCodeAt(i) & 255;
70
+ return out;
81
71
  }
82
-
83
72
  function pngChunk(type, data) {
84
- let name = asciiBytes(type);
85
- let out = new Uint8Array(12 + data.length);
86
- writeU32(out, 0, data.length);
87
- out.set(name, 4);
88
- out.set(data, 8);
89
- let crcInput = new Uint8Array(name.length + data.length);
90
- crcInput.set(name, 0);
91
- crcInput.set(data, name.length);
92
- writeU32(out, out.length - 4, crc32(crcInput));
93
- return out;
94
- }
95
-
73
+ let name = asciiBytes(type);
74
+ let out = new Uint8Array(12 + data.length);
75
+ writeU32(out, 0, data.length);
76
+ out.set(name, 4);
77
+ out.set(data, 8);
78
+ let crcInput = new Uint8Array(name.length + data.length);
79
+ crcInput.set(name, 0);
80
+ crcInput.set(data, name.length);
81
+ writeU32(out, out.length - 4, crc32(crcInput));
82
+ return out;
83
+ }
96
84
  function zlibStore(bytes) {
97
- let blocks = [];
98
- let total = 2 + 4;
99
- for (let pos = 0; pos < bytes.length; pos += 65535) {
100
- let len = Math.min(65535, bytes.length - pos);
101
- let block = new Uint8Array(5 + len);
102
- block[0] = pos + len >= bytes.length ? 1 : 0;
103
- block[1] = len & 255;
104
- block[2] = (len >>> 8) & 255;
105
- let nlen = (~len) & 65535;
106
- block[3] = nlen & 255;
107
- block[4] = (nlen >>> 8) & 255;
108
- block.set(bytes.subarray(pos, pos + len), 5);
109
- blocks.push(block);
110
- total += block.length;
111
- }
112
-
113
- let out = new Uint8Array(total);
114
- out[0] = 0x78;
115
- out[1] = 0x01;
116
- let o = 2;
117
- for (let block of blocks) {
118
- out.set(block, o);
119
- o += block.length;
120
- }
121
- writeU32(out, o, adler32(bytes));
122
- return out;
123
- }
124
-
125
- export function rgbaImageDataToPngBytes(imageData) {
126
- let width = Math.max(0, Math.floor(Number(imageData?.width) || 0));
127
- let height = Math.max(0, Math.floor(Number(imageData?.height) || 0));
128
- let data = imageData?.data || new Uint8ClampedArray(0);
129
- let raw = new Uint8Array((width * 4 + 1) * height);
130
- let dst = 0;
131
- let src = 0;
132
- for (let y = 0; y < height; y++) {
133
- raw[dst++] = 0;
134
- for (let x = 0; x < width; x++) {
135
- raw[dst++] = data[src++] || 0;
136
- raw[dst++] = data[src++] || 0;
137
- raw[dst++] = data[src++] || 0;
138
- let a = data[src++];
139
- raw[dst++] = a == null ? 255 : a;
140
- }
141
- }
142
-
143
- let ihdr = new Uint8Array(13);
144
- writeU32(ihdr, 0, width);
145
- writeU32(ihdr, 4, height);
146
- ihdr[8] = 8;
147
- ihdr[9] = 6;
148
- ihdr[10] = 0;
149
- ihdr[11] = 0;
150
- ihdr[12] = 0;
151
-
152
- let signature = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
153
- let chunks = [signature, pngChunk('IHDR', ihdr), pngChunk('IDAT', zlibStore(raw)), pngChunk('IEND', new Uint8Array(0))];
154
- let total = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
155
- let out = new Uint8Array(total);
156
- let offset = 0;
157
- for (let chunk of chunks) {
158
- out.set(chunk, offset);
159
- offset += chunk.length;
160
- }
161
- return out;
162
- }
163
-
164
- export function normalizeExportType(type) {
165
- type = String(type || 'image/png').toLowerCase();
166
- return type == 'image/bmp' || type == 'image/x-ms-bmp' ? 'image/bmp' : 'image/png';
167
- }
168
-
169
- export function bytesToBase64(bytes) {
170
- if (typeof Buffer != 'undefined')
171
- return Buffer.from(bytes).toString('base64');
172
-
173
- let s = '';
174
- let chunk = 0x8000;
175
- for (let i = 0; i < bytes.length; i += chunk)
176
- s += String.fromCharCode(...bytes.subarray(i, i + chunk));
177
- return btoa(s);
178
- }
179
-
180
- export function bytesToBlob(bytes, type) {
181
- if (typeof Blob != 'undefined')
182
- return new Blob([bytes], {type});
183
-
184
- return {
185
- type,
186
- size: bytes.byteLength,
187
- async arrayBuffer() {
188
- return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
189
- },
190
- };
191
- }
192
-
193
- export function textToBlob(text, type) {
194
- if (typeof Blob != 'undefined')
195
- return new Blob([text], {type});
196
-
197
- let bytes = new TextEncoder().encode(text);
198
- return bytesToBlob(bytes, type);
199
- }
200
-
201
- export function escapeXmlAttr(value) {
202
- return String(value).replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
203
- }
204
-
205
- export function encodeTextBase64(text) {
206
- if (typeof Buffer != 'undefined')
207
- return Buffer.from(text, 'utf8').toString('base64');
208
-
209
- let bytes = new TextEncoder().encode(text);
210
- return bytesToBase64(bytes);
211
- }
212
-
85
+ let blocks = [];
86
+ let total = 2 + 4;
87
+ for (let pos = 0; pos < bytes.length; pos += 65535) {
88
+ let len = Math.min(65535, bytes.length - pos);
89
+ let block = new Uint8Array(5 + len);
90
+ block[0] = pos + len >= bytes.length ? 1 : 0;
91
+ block[1] = len & 255;
92
+ block[2] = len >>> 8 & 255;
93
+ let nlen = ~len & 65535;
94
+ block[3] = nlen & 255;
95
+ block[4] = nlen >>> 8 & 255;
96
+ block.set(bytes.subarray(pos, pos + len), 5);
97
+ blocks.push(block);
98
+ total += block.length;
99
+ }
100
+ let out = new Uint8Array(total);
101
+ out[0] = 120;
102
+ out[1] = 1;
103
+ let o = 2;
104
+ for (let block of blocks) {
105
+ out.set(block, o);
106
+ o += block.length;
107
+ }
108
+ writeU32(out, o, adler32(bytes));
109
+ return out;
110
+ }
111
+ function rgbaImageDataToPngBytes(imageData) {
112
+ let width = Math.max(0, Math.floor(Number(imageData?.width) || 0));
113
+ let height = Math.max(0, Math.floor(Number(imageData?.height) || 0));
114
+ let data = imageData?.data || new Uint8ClampedArray(0);
115
+ let raw = new Uint8Array((width * 4 + 1) * height);
116
+ let dst = 0;
117
+ let src = 0;
118
+ for (let y = 0; y < height; y++) {
119
+ raw[dst++] = 0;
120
+ for (let x = 0; x < width; x++) {
121
+ raw[dst++] = data[src++] || 0;
122
+ raw[dst++] = data[src++] || 0;
123
+ raw[dst++] = data[src++] || 0;
124
+ let a = data[src++];
125
+ raw[dst++] = a == null ? 255 : a;
126
+ }
127
+ }
128
+ let ihdr = new Uint8Array(13);
129
+ writeU32(ihdr, 0, width);
130
+ writeU32(ihdr, 4, height);
131
+ ihdr[8] = 8;
132
+ ihdr[9] = 6;
133
+ ihdr[10] = 0;
134
+ ihdr[11] = 0;
135
+ ihdr[12] = 0;
136
+ let signature = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]);
137
+ let chunks = [signature, pngChunk("IHDR", ihdr), pngChunk("IDAT", zlibStore(raw)), pngChunk("IEND", new Uint8Array(0))];
138
+ let total = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
139
+ let out = new Uint8Array(total);
140
+ let offset = 0;
141
+ for (let chunk of chunks) {
142
+ out.set(chunk, offset);
143
+ offset += chunk.length;
144
+ }
145
+ return out;
146
+ }
147
+ function normalizeExportType(type) {
148
+ type = String(type || "image/png").toLowerCase();
149
+ return type == "image/bmp" || type == "image/x-ms-bmp" ? "image/bmp" : "image/png";
150
+ }
151
+ function bytesToBase64(bytes) {
152
+ if (typeof Buffer != "undefined")
153
+ return Buffer.from(bytes).toString("base64");
154
+ let s = "";
155
+ let chunk = 32768;
156
+ for (let i = 0; i < bytes.length; i += chunk)
157
+ s += String.fromCharCode(...bytes.subarray(i, i + chunk));
158
+ return btoa(s);
159
+ }
160
+ function bytesToArrayBuffer(bytes) {
161
+ let out = new ArrayBuffer(bytes.byteLength);
162
+ new Uint8Array(out).set(bytes);
163
+ return out;
164
+ }
165
+ function bytesToBlob(bytes, type) {
166
+ let buffer = bytesToArrayBuffer(bytes);
167
+ if (typeof Blob != "undefined")
168
+ return new Blob([buffer], { type });
169
+ return {
170
+ type,
171
+ size: bytes.byteLength,
172
+ async arrayBuffer() {
173
+ return buffer.slice(0);
174
+ }
175
+ };
176
+ }
177
+ function textToBlob(text, type) {
178
+ if (typeof Blob != "undefined")
179
+ return new Blob([text], { type });
180
+ let bytes = new TextEncoder().encode(text);
181
+ return bytesToBlob(bytes, type);
182
+ }
183
+ function escapeXmlAttr(value) {
184
+ return String(value).replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
185
+ }
186
+ function encodeTextBase64(text) {
187
+ if (typeof Buffer != "undefined")
188
+ return Buffer.from(text, "utf8").toString("base64");
189
+ let bytes = new TextEncoder().encode(text);
190
+ return bytesToBase64(bytes);
191
+ }
192
+ export {
193
+ bytesToArrayBuffer,
194
+ bytesToBase64,
195
+ bytesToBlob,
196
+ encodeTextBase64,
197
+ escapeXmlAttr,
198
+ normalizeExportType,
199
+ rgbaImageDataToBmpBytes,
200
+ rgbaImageDataToPngBytes,
201
+ textToBlob
202
+ };
@@ -0,0 +1,12 @@
1
+ import { GPUPath } from "./GPUPath.js";
2
+ import { default as default2, WebGPURenderer, WebGPURendererInternals } from "./WebGPURenderer.js";
3
+ import { CHART_WGSL, IMAGE_WGSL } from "./shaders.js";
4
+ export * from "./exporters.js";
5
+ export {
6
+ CHART_WGSL,
7
+ GPUPath,
8
+ IMAGE_WGSL,
9
+ WebGPURenderer,
10
+ WebGPURendererInternals,
11
+ default2 as default
12
+ };
@@ -1,4 +1,4 @@
1
- export const CHART_WGSL = `
1
+ const CHART_WGSL = `
2
2
  struct Uniforms {
3
3
  resolution: vec2<f32>,
4
4
  };
@@ -32,8 +32,7 @@ fn fsMain(input: VertexOut) -> @location(0) vec4<f32> {
32
32
  return input.color;
33
33
  }
34
34
  `;
35
-
36
- export const IMAGE_WGSL = `
35
+ const IMAGE_WGSL = `
37
36
  struct Uniforms {
38
37
  resolution: vec2<f32>,
39
38
  };
@@ -74,3 +73,7 @@ fn fsImage(input: VertexOut) -> @location(0) vec4<f32> {
74
73
  return vec4<f32>(tex.rgb * a, a);
75
74
  }
76
75
  `;
76
+ export {
77
+ CHART_WGSL,
78
+ IMAGE_WGSL
79
+ };
@@ -3,16 +3,16 @@ const config = {
3
3
  //serve:true //or enable this to skip build step (same as cli)
4
4
  bundler: { //esbuild settings, set false to skip build step or add bundle:true to config object to only bundle (alt methods)
5
5
  entryPoints: [ //entry point file(s). These can include .js, .mjs, .ts, .jsx, .tsx, or other javascript files. Make sure your entry point is a ts file if you want to generate types
6
- // "./scripts/build/bench_demo.js"
7
- "./index.js"
6
+ "./scripts/build/bench_demo.js"
7
+ // "./index.ts"
8
8
  ],
9
- outfile: "dist/uPlot", //"dist/demo.js" //exit point file, will append .js as well as indicators like .esm.js, .node.js for other build flags
9
+ outfile: "dist/demo", //exit point file, will append .js as well as indicators like .esm.js, .node.js for other build flags
10
10
  //outdir:'dist', //exit point folder, define for multiple entryPoints
11
11
 
12
12
  //we can run multiple esbuild configs separately, set to true to target different outputs, we'll put it all in the dist in a way that keeps the files separate (e.g. index.js for the browser, index.esm.js for esm, index.node.js for node, or if only 1 bundler specified just index.js for any, it's the most general) when using multiple bundlers, additionally when specifying an outdir instead of outfile.
13
13
  bundleBrowser: true, //create plain js build? Can include globals and init scripts
14
14
  bundleESM: true, //create esm module js files
15
- bundleTypes: false, //create .d.ts files, //you need a .tsconfig for this to work
15
+ bundleTypes: true, //create .d.ts files, //you need a .tsconfig for this to work
16
16
  bundleNode: false, //create node platform plain js build, specify platform:'node' to do the rest of the files
17
17
  bundleHTML: false, //wrap the first entry point file as a plain js script in a boilerplate html file, frontend scripts can be run standalone like a .exe! Server serves this as start page if set to true.
18
18
  //bundleIIFE:false, //create an iife build, this is compiled temporarily to create the types files and only saved with bundleIIFE:true
@@ -23,7 +23,7 @@ const config = {
23
23
  //includeDefaultPlugins:true //true by default, includes the presets for the streaming imports, worker bundling, and auto npm install
24
24
  //blobWorkers:true, //package workers as blobs or files? blobs are faster but inflate the main package size
25
25
  //workerBundler:{minifyWhitespace:true} //bundler settings specific to the worker. e.g. apply platform:'node' when bundling node workers,
26
- globalThis:'uPlot' //'mymodule'
26
+ globalThis:"uPlot" //'mymodule'
27
27
  //globals:{'index.js':['Graph']}
28
28
  //init:{'index.js':function(bundle) { console.log('prepackaged bundle script!', bundle); }.toString(); }
29
29
  // outputs:{ //overwrites main config settings for specific use cases, you can also just use objects instead of booleans on the above toggles for bundler modes
@@ -85,7 +85,7 @@ const config = {
85
85
  //delay: 50, //millisecond delay on the watch command for hot reloading
86
86
  //pwa: "service-worker.js", //pwa mode? Injects service worker webpage code to live site, will create a service worker and webmanifest for you if not existent
87
87
  //watch: ['../'], //watch additional directories other than the current working directory
88
- //ignore:['./assets'], //ignore these paths
88
+ ignore:['.d.ts'], //ignore these paths
89
89
  //extensions:['pdf'], //custom file extensions to watch
90
90
  errpage: 'node_modules/tinybuild/tinybuild/node_server/other/404.html', //default error page, etc.
91
91
  certpath: 'node_modules/tinybuild/tinybuild/node_server/ssl/server.crt',//if using https, this is required. See cert.pfx.md for instructions
package/tsconfig.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "include": ["index.ts"],
3
+ "compilerOptions": {
4
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
5
+ /* Basic Options */
6
+ // "incremental": true, /* Enable incremental compilation */
7
+ "target": "ESNEXT" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */,
8
+ "module": "ESNEXT" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */,
9
+ "declaration": true, /* Generates corresponding '.d.ts' file. */
10
+ "allowJs": true, /* Allow javascript files to be compiled. */
11
+ "skipLibCheck": true /* Skip type checking of declaration files. */,
12
+ "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
13
+ "outDir": "./dist" /* Redirect output structure to the directory. */,
14
+ "strict": false /* Enable all strict type-checking options. */,
15
+ "esModuleInterop": true /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */,
16
+ // "checkJs": true, /* Report errors in .js files. */
17
+ // "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
18
+ // "lib": [], /* Specify library files to be included in the compilation. */
19
+ // "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
20
+ // "sourceMap": true, /* Generates corresponding '.map' file. */
21
+ // "outFile": "./", /* Concatenate and emit output to single file. */
22
+ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
23
+ // "composite": true, /* Enable project compilation */
24
+ // "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
25
+ // "removeComments": true, /* Do not emit comments to output. */
26
+ // "noEmit": true, /* Do not emit outputs. */
27
+ // "importHelpers": true, /* Import emit helpers from 'tslib'. */
28
+ // "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
29
+ // "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
30
+ /* Strict Type-Checking Options */
31
+ // "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
32
+ // "strictNullChecks": true, /* Enable strict null checks. */
33
+ // "strictFunctionTypes": true, /* Enable strict checking of function types. */
34
+ // "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
35
+ // "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
36
+ // "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
37
+ // "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
38
+ /* Additional Checks */
39
+ // "noUnusedLocals": true, /* Report errors on unused locals. */
40
+ // "noUnusedParameters": true, /* Report errors on unused parameters. */
41
+ // "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
42
+ // "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
43
+ /* Module Resolution Options */
44
+ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
45
+ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
46
+ // "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
47
+ // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
48
+ // "typeRoots": [], /* List of folders to include type definitions from. */
49
+ "types": ["@webgpu/types"], /* Type declaration files to be included in compilation. */
50
+ // "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
51
+ // "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
52
+ // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
53
+ /* Source Map Options */
54
+ // "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
55
+ // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
56
+ // "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
57
+ // "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
58
+ /* Experimental Options */
59
+ // "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
60
+ // "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
61
+ /* Advanced Options */
62
+ //"resolveJsonModule": true
63
+ }
64
+ }
@@ -1,26 +0,0 @@
1
- export interface UPlotLike {
2
- root: HTMLElement;
3
- ctx?: unknown;
4
- series: unknown[];
5
- scales: Record<string, unknown>;
6
- destroy(): void;
7
- setData(data: unknown[], resetScales?: boolean): void;
8
- setSize(size: {width: number; height: number}): void;
9
- redraw(rebuildPaths?: boolean, recalcAxes?: boolean): void;
10
- setScale(key: string, range: {min?: number; max?: number}): void;
11
- setSelect(select: {left: number; top: number; width: number; height: number}, fireHook?: boolean): void;
12
- addSeries(series: unknown, index?: number): void;
13
- delSeries(index: number): void;
14
- }
15
-
16
- export interface UPlotConstructor {
17
- new (opts: unknown, data: unknown[], then?: HTMLElement | ((u: UPlotLike) => void)): UPlotLike;
18
- configure?(opts: Record<string, unknown>): UPlotConstructor;
19
- destroyDetached?(): number;
20
- destroyAll?(): number;
21
- getLivePlots?(): UPlotLike[];
22
- [key: string]: unknown;
23
- }
24
-
25
- declare const uPlot: UPlotConstructor;
26
- export default uPlot;
@@ -1,46 +0,0 @@
1
- export type GPUPathCommand =
2
- | ['M', number, number]
3
- | ['L', number, number]
4
- | ['Q', number, number, number, number]
5
- | ['C', number, number, number, number, number, number]
6
- | ['A', number, number, number, number, number, boolean]
7
- | ['Z'];
8
-
9
- export interface GPUPathBounds {
10
- minX: number;
11
- minY: number;
12
- maxX: number;
13
- maxY: number;
14
- width: number;
15
- height: number;
16
- }
17
-
18
- export class GPUPath {
19
- constructor(path?: GPUPath | Path2D | GPUPathCommand[] | string);
20
- cmds: GPUPathCommand[];
21
- commands?: GPUPathCommand[];
22
- currentX: number;
23
- currentY: number;
24
- startX: number;
25
- startY: number;
26
- moveTo(x: number, y: number): void;
27
- lineTo(x: number, y: number): void;
28
- quadraticCurveTo(cpx: number, cpy: number, x: number, y: number): void;
29
- bezierCurveTo(cp1x: number, cp1y: number, cp2x: number, cp2y: number, x: number, y: number): void;
30
- arc(cx: number, cy: number, radius: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
31
- arcTo(x1: number, y1: number, x2: number, y2: number, radius: number): void;
32
- ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
33
- roundRect(x: number, y: number, w: number, h: number, radii?: number | number[] | DOMPointInit | DOMPointInit[]): void;
34
- rect(x: number, y: number, w: number, h: number): void;
35
- closePath(): void;
36
- addPath(path: GPUPath, transform?: DOMMatrix | number[]): void;
37
- clone(): GPUPath;
38
- clear(): this;
39
- isEmpty(): boolean;
40
- clear(): void;
41
- toPolygons(transform?: number[], tolerance?: number): number[][][];
42
- toSubpaths(transform?: number[], tolerance?: number): number[][][];
43
- getBounds(transform?: number[]): GPUPathBounds | null;
44
- }
45
-
46
- export default GPUPath;