@kymoscope/sdk 0.10.0 → 0.11.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/dist/assets/{importer.worker-CLBGjz4d.js → importer.worker-Cgz__4KO.js} +1 -1
- package/dist/assets/liveIngestWorker-BLPTEEc7.js +1 -0
- package/dist/assets/offscreenLineWorker-C-_uNa_H.js +80 -0
- package/dist/{importers-2iwVi4cq.js → importers-D_M42sqZ.js} +1 -1
- package/dist/{keys-DmtCD10T.js → keys-CkI2qrI-.js} +1 -1
- package/dist/kymoscope-embed.js +66 -66
- package/dist/kymoscope-sdk.js +62 -62
- package/dist/types/analysis/ai.d.ts +50 -0
- package/dist/types/analysis/aiCheck.d.ts +54 -0
- package/dist/types/analysis/alertsBefore.d.ts +7 -0
- package/dist/types/analysis/better.d.ts +6 -0
- package/dist/types/analysis/capability.d.ts +10 -0
- package/dist/types/analysis/changes.d.ts +10 -0
- package/dist/types/analysis/containment.d.ts +10 -0
- package/dist/types/analysis/context.d.ts +131 -0
- package/dist/types/analysis/control.d.ts +13 -0
- package/dist/types/analysis/energy.d.ts +4 -0
- package/dist/types/analysis/gap.d.ts +8 -0
- package/dist/types/analysis/golden.d.ts +20 -0
- package/dist/types/analysis/health.d.ts +73 -0
- package/dist/types/analysis/index.d.ts +12 -0
- package/dist/types/analysis/infer.d.ts +68 -0
- package/dist/types/analysis/lines.d.ts +6 -0
- package/dist/types/analysis/losses.d.ts +41 -0
- package/dist/types/analysis/maintenance.d.ts +8 -0
- package/dist/types/analysis/oee.d.ts +30 -0
- package/dist/types/analysis/parts.d.ts +13 -0
- package/dist/types/analysis/presets.d.ts +35 -0
- package/dist/types/analysis/reliability.d.ts +103 -0
- package/dist/types/analysis/report.d.ts +15 -0
- package/dist/types/analysis/shifts.d.ts +7 -0
- package/dist/types/analysis/sinceLast.d.ts +8 -0
- package/dist/types/analysis/stats.d.ts +110 -0
- package/dist/types/analysis/stops.d.ts +34 -0
- package/dist/types/analysis/strip.d.ts +14 -0
- package/dist/types/analysis/text.d.ts +56 -0
- package/dist/types/analysis/types.d.ts +407 -0
- package/dist/types/components/liveWindow.d.ts +6 -2
- package/dist/types/engine/createEngine.d.ts +1 -0
- package/dist/types/engine/liveController.d.ts +7 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/lib/live/liveIngest.d.ts +47 -0
- package/dist/types/lib/live/liveIngestClient.d.ts +9 -0
- package/dist/types/lib/live/liveIngestWorker.d.ts +1 -0
- package/dist/types/lib/live/publisher.d.ts +10 -0
- package/dist/types/lib/live/stream.d.ts +8 -0
- package/dist/types/lib/live/types.d.ts +12 -0
- package/dist/types/lib/render/frames.d.ts +10 -0
- package/dist/types/lib/render/glPoints.d.ts +18 -0
- package/dist/types/lib/render/offscreenLineRenderer.d.ts +15 -1
- package/dist/types/lib/render/sharedGl.d.ts +12 -3
- package/package.json +1 -1
- package/dist/assets/offscreenLineWorker-BQwts3O3.js +0 -80
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type GpuSeriesStyle } from './glSeries';
|
|
2
|
+
import { type GlHolder } from './sharedGl';
|
|
2
3
|
/**
|
|
3
4
|
* Main-thread handle to the OffscreenCanvas line worker. The worker owns the GL
|
|
4
5
|
* context and keeps the data on the GPU (projected in the shader); the main
|
|
@@ -36,6 +37,8 @@ export interface OffscreenLayerData extends OffscreenLayerFrame {
|
|
|
36
37
|
columns: Float32Array[];
|
|
37
38
|
}
|
|
38
39
|
export interface OffscreenChartRenderer {
|
|
40
|
+
/** Draws in a worker with a context of its own (one of the few a page gets); absent: through the shared one. */
|
|
41
|
+
own?: boolean;
|
|
39
42
|
resize(w: number, h: number, dpr: number): void;
|
|
40
43
|
/** New points for a layer (uploaded to the GPU). The worker draws every layer it holds. */
|
|
41
44
|
setData(layer: number, data: OffscreenLayerData): void;
|
|
@@ -45,9 +48,20 @@ export interface OffscreenChartRenderer {
|
|
|
45
48
|
setView(xmin: number, xmax: number, cut?: number): void;
|
|
46
49
|
dispose(): void;
|
|
47
50
|
}
|
|
51
|
+
/** Whether charts can draw in a worker here (false once starting one failed). */
|
|
52
|
+
export declare function glWorkersAvailable(): boolean;
|
|
53
|
+
/** Name of the performance mark made when a worker has drawn a canvas's first picture. */
|
|
54
|
+
export declare const GL_FIRST_FRAME_MARK = "kymoscope-gl-first-frame";
|
|
48
55
|
export declare function createOffscreenChartRenderer(canvas: HTMLCanvasElement, lineWidth?: number,
|
|
49
56
|
/** Its context was lost (Chrome dropped it): the caller makes a new canvas and renderer. */
|
|
50
|
-
onLost?: () => void
|
|
57
|
+
onLost?: () => void,
|
|
58
|
+
/** Lets a chart in view take this one's context while it is hidden (see sharedGl canOwnGl). */
|
|
59
|
+
holder?: GlHolder,
|
|
60
|
+
/**
|
|
61
|
+
* A second canvas over the same plot: until the worker has drawn its first picture (a new context: 60-130 ms),
|
|
62
|
+
* the lines are drawn here through the shared context, so a chart shown again never shows axes without lines.
|
|
63
|
+
*/
|
|
64
|
+
bridge?: HTMLCanvasElement): OffscreenChartRenderer | null;
|
|
51
65
|
/**
|
|
52
66
|
* The same renderer on the main thread through the page's shared WebGL
|
|
53
67
|
* context (see sharedGl): for charts past the contexts a page may own. Each
|
|
@@ -18,10 +18,19 @@ export interface GlLease {
|
|
|
18
18
|
lost(): boolean;
|
|
19
19
|
release(): void;
|
|
20
20
|
}
|
|
21
|
-
/**
|
|
21
|
+
/** A chart that can give its own context up while it is hidden (`evict` releases it before returning). */
|
|
22
|
+
export interface GlHolder {
|
|
23
|
+
hidden(): boolean;
|
|
24
|
+
evict(): void;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether a chart may still own a context (a worker of its own, say). With none left, a chart that is hidden (a
|
|
28
|
+
* worksheet kept mounted) gives its own up: the charts of the first worksheets visited held all of them for good,
|
|
29
|
+
* and every chart shown after drew on the main thread through the shared context.
|
|
30
|
+
*/
|
|
22
31
|
export declare function canOwnGl(): boolean;
|
|
23
|
-
/** Count a context a chart owns outside `leaseGl` (a worker's); returns its release. */
|
|
24
|
-
export declare function ownGl(): () => void;
|
|
32
|
+
/** Count a context a chart owns outside `leaseGl` (a worker's); returns its release. `holder`: see GlHolder. */
|
|
33
|
+
export declare function ownGl(holder?: GlHolder): () => void;
|
|
25
34
|
/**
|
|
26
35
|
* A context for the chart canvas `visible`: the shared one (the chart's canvas shows copies through 2D), which comes
|
|
27
36
|
* back when Chrome drops it; with `own`, its own while the budget lasts (lost for good if Chrome drops it: the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kymoscope/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "The Kymoscope data engine and charts for the browser: import large measurement files, plot them, stream live data end-to-end encrypted.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"homepage": "https://kymoscope.com/docs/introduction",
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
function e(e,t,n){let r=e.createShader(t);return r?(e.shaderSource(r,n),e.compileShader(r),e.getShaderParameter(r,e.COMPILE_STATUS)?r:(console.error(`glLines shader compile failed:`,e.getShaderInfoLog(r)),e.deleteShader(r),null)):null}const t=1024,n=`#version 300 es
|
|
2
|
-
in vec2 a_corner; // static quad corner: (±1, ±1)
|
|
3
|
-
in float a_ax; // per instance: segment start/end X (relative to the layer origin)
|
|
4
|
-
in float a_bx;
|
|
5
|
-
in float a_ay; // per instance: segment start/end value
|
|
6
|
-
in float a_by;
|
|
7
|
-
in float a_bstart; // 1 where the END point starts a new trace (or a new series)
|
|
8
|
-
in float a_sid; // series of the START point
|
|
9
|
-
uniform highp sampler2D u_styles;
|
|
10
|
-
uniform vec2 u_resolution;
|
|
11
|
-
uniform float u_left; // plot left edge (CSS px)
|
|
12
|
-
uniform float u_plotW;
|
|
13
|
-
uniform float u_xoff; // view xmin - origin
|
|
14
|
-
uniform float u_xscale; // plot width px / view X range
|
|
15
|
-
uniform float u_xR; // view X range
|
|
16
|
-
uniform float u_minGap; // floor of the gap threshold (resampled: buckets apart)
|
|
17
|
-
uniform float u_cutPx; // nothing right of this (CSS px): a live trace's display edge
|
|
18
|
-
flat out vec2 v_a;
|
|
19
|
-
flat out vec2 v_b;
|
|
20
|
-
flat out vec4 v_color;
|
|
21
|
-
flat out float v_halfWidth;
|
|
22
|
-
flat out vec4 v_clip; // left, top, right, bottom (CSS px)
|
|
23
|
-
out vec2 v_pos;
|
|
24
|
-
vec4 style(int sid, int k) {
|
|
25
|
-
return texelFetch(u_styles, ivec2((sid % ${t}) * 3 + k, sid / ${t}), 0);
|
|
26
|
-
}
|
|
27
|
-
void main() {
|
|
28
|
-
int sid = int(a_sid + 0.5);
|
|
29
|
-
vec4 s0 = style(sid, 0); // scale lo, scale hi, band top, band bottom
|
|
30
|
-
vec4 s1 = style(sid, 1); // colour
|
|
31
|
-
vec4 s2 = style(sid, 2); // mean step, half width, quad extension, visible
|
|
32
|
-
// Same threshold as the on-main path (joinGapThreshold over the mean step).
|
|
33
|
-
float gap = max(u_minGap, s2.x > 0.0 ? max(s2.x * 4.0, u_xR * 1e-9) : max(u_xR * 1e-6, 1e-12));
|
|
34
|
-
if (s2.w < 0.5 || a_bstart > 0.5 || abs(a_bx - a_ax) > gap) {
|
|
35
|
-
// Not a segment (a gap, a trace or series start, a hidden series): collapse off-screen.
|
|
36
|
-
gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
|
|
37
|
-
v_a = vec2(0.0); v_b = vec2(0.0); v_pos = vec2(0.0);
|
|
38
|
-
v_color = vec4(0.0); v_halfWidth = 0.0; v_clip = vec4(0.0);
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
float lo = s0.x, hi = s0.y, top = s0.z, bottom = s0.w;
|
|
42
|
-
float ta = hi == lo ? 0.5 : clamp((a_ay - lo) / (hi - lo), 0.0, 1.0);
|
|
43
|
-
float tb = hi == lo ? 0.5 : clamp((a_by - lo) / (hi - lo), 0.0, 1.0);
|
|
44
|
-
vec2 a = vec2(u_left + (a_ax - u_xoff) * u_xscale, top + (1.0 - ta) * (bottom - top));
|
|
45
|
-
vec2 b = vec2(u_left + (a_bx - u_xoff) * u_xscale, top + (1.0 - tb) * (bottom - top));
|
|
46
|
-
vec2 ab = b - a;
|
|
47
|
-
float len = length(ab);
|
|
48
|
-
vec2 dir = len > 1e-6 ? ab / len : vec2(1.0, 0.0);
|
|
49
|
-
vec2 n = vec2(-dir.y, dir.x);
|
|
50
|
-
vec2 base = mix(a, b, step(0.0, a_corner.x));
|
|
51
|
-
vec2 pos = base + dir * (a_corner.x * s2.z) + n * (a_corner.y * s2.z);
|
|
52
|
-
v_a = a;
|
|
53
|
-
v_b = b;
|
|
54
|
-
v_pos = pos;
|
|
55
|
-
v_color = s1;
|
|
56
|
-
v_halfWidth = s2.y;
|
|
57
|
-
v_clip = vec4(u_left, top, min(u_left + u_plotW, u_cutPx), bottom);
|
|
58
|
-
vec2 clip = pos / u_resolution * 2.0 - 1.0;
|
|
59
|
-
gl_Position = vec4(clip.x, -clip.y, 0.0, 1.0);
|
|
60
|
-
}`;function r(e,t,n,r){let i=e.length,a=0;for(let t=0;t<i;t++)Number.isFinite(r[t])&&Number.isFinite(e[t])&&a++;if(a===i)return null;let o=new Float32Array(a),s=new Float32Array(a),c=new Uint8Array(a),l=0,u=!1;for(let a=0;a<i;a++)n[a]&&(u=!0),Number.isFinite(r[a])&&Number.isFinite(e[a])&&(o[l]=t[a],s[l]=r[a],u&&=(c[l]=255,!1),l++);return{x:o,y:s,starts:c}}function i(e,t,n){let i=e.length,a=0;for(let t=0;t<i;t++)if(Number.isFinite(e[t])){a=e[t];break}let o=new Float32Array(i);for(let t=0;t<i;t++)o[t]=e[t]-a;let s=new Uint8Array(i);if(t)for(let e=0;e<i;e++)t[e]&&(s[e]=255);let c=n.map(t=>r(e,o,s,t)??{x:o,y:t,starts:s}),l=c.map(e=>e.y.length),u=l.reduce((e,t)=>e+t,0),d=new Float32Array(u),f=new Float32Array(u),p=new Uint8Array(u),m=new Float32Array(u),h=0;return c.forEach((e,t)=>{d.set(e.x,h),f.set(e.y,h),p.set(e.starts,h),e.y.length>0&&(p[h]=255),m.fill(t,h,h+e.y.length),h+=e.y.length}),{origin:a,x:d,y:f,starts:p,sid:m,counts:l}}function a(e,t,n,r,i,a){let o=(i-r)/a,s=(t,n)=>{let r=0,i=e.length;for(;r<i;){let a=r+i>>>1;(n?e[a]<=t:e[a]<t)?r=a+1:i=a}return r},c=s(r,!1),l=s(i,!0),u=t.length*(2*a+2),d=new Float32Array(u),f=new Float32Array(u),p=new Uint8Array(u),m=new Float32Array(u),h=0,g=(e,t,r)=>{d[h]=e-n,f[h]=t,m[h]=r,h++};return t.forEach((t,n)=>{let i=h;for(let r=c-1;r>=Math.max(0,c-64);r--)if(t[r]===t[r]){g(e[r],t[r],n);break}let s=c;for(let i=0;i<a&&s<l;i++){let c=i===a-1?1/0:r+(i+1)*o,u=1/0,d=-1/0,f=-1,p=-1;for(;s<l&&e[s]<c;s++){let e=t[s];e<u&&(u=e,f=s),e>d&&(d=e,p=s)}f<0||(f===p?g(e[f],u,n):f<p?(g(e[f],u,n),g(e[p],d,n)):(g(e[p],d,n),g(e[f],u,n)))}for(let r=l;r<Math.min(e.length,l+64);r++)if(t[r]===t[r]){g(e[r],t[r],n);break}h>i&&(p[i]=255)}),{x:d.subarray(0,h),y:f.subarray(0,h),starts:p.subarray(0,h),sid:m.subarray(0,h),bucket:o}}function o(e){for(let t=1;t<e.length;t++)if(!(e[t]>=e[t-1]))return!1;return e.length===0||e[0]===e[0]}function s(r,s=1){let c=r.getContext(`webgl2`,{antialias:!1,alpha:!0,premultipliedAlpha:!0}),l=typeof HTMLCanvasElement<`u`&&r instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&r instanceof OffscreenCanvas;if(!c)return null;let u=e(c,c.VERTEX_SHADER,n),d=e(c,c.FRAGMENT_SHADER,`#version 300 es
|
|
61
|
-
precision highp float;
|
|
62
|
-
flat in vec2 v_a;
|
|
63
|
-
flat in vec2 v_b;
|
|
64
|
-
flat in vec4 v_color;
|
|
65
|
-
flat in float v_halfWidth;
|
|
66
|
-
flat in vec4 v_clip;
|
|
67
|
-
in vec2 v_pos;
|
|
68
|
-
out vec4 outColor;
|
|
69
|
-
void main() {
|
|
70
|
-
if (v_pos.x < v_clip.x || v_pos.x > v_clip.z || v_pos.y < v_clip.y || v_pos.y > v_clip.w) discard;
|
|
71
|
-
vec2 ab = v_b - v_a;
|
|
72
|
-
float t = clamp(dot(v_pos - v_a, ab) / max(dot(ab, ab), 1e-12), 0.0, 1.0);
|
|
73
|
-
float d = distance(v_pos, v_a + ab * t);
|
|
74
|
-
float aa = max(fwidth(d), 1e-4);
|
|
75
|
-
float e = clamp((v_halfWidth - d) / aa + 0.5, 0.0, 1.0);
|
|
76
|
-
float cov = e * e * (3.0 - 2.0 * e);
|
|
77
|
-
if (cov <= 0.0) discard;
|
|
78
|
-
float alpha = v_color.a * cov;
|
|
79
|
-
outColor = vec4(v_color.rgb * alpha, alpha);
|
|
80
|
-
}`);if(!u||!d)return null;let f=c.createProgram();if(!f)return null;if(c.attachShader(f,u),c.attachShader(f,d),c.linkProgram(f),!c.getProgramParameter(f,c.LINK_STATUS))return console.error(`glSeries program link failed:`,c.getProgramInfoLog(f)),null;let p=e=>c.getAttribLocation(f,e),m=p(`a_corner`),h=p(`a_ax`),g=p(`a_bx`),_=p(`a_ay`),v=p(`a_by`),y=p(`a_bstart`),b=p(`a_sid`),x=[h,g,_,v,y,b],S=e=>c.getUniformLocation(f,e),C={res:S(`u_resolution`),styles:S(`u_styles`),left:S(`u_left`),plotW:S(`u_plotW`),xoff:S(`u_xoff`),xscale:S(`u_xscale`),xR:S(`u_xR`),minGap:S(`u_minGap`),cutPx:S(`u_cutPx`)},w=c.createBuffer();c.bindBuffer(c.ARRAY_BUFFER,w),c.bufferData(c.ARRAY_BUFFER,Float32Array.from([-1,-1,1,-1,-1,1,1,1]),c.STATIC_DRAW);let T=c.createFramebuffer(),E=c.createRenderbuffer(),D=1,O=1,k=(`clientWidth`in r?r.clientWidth:0)||1,A=(`clientHeight`in r?r.clientHeight:0)||1,j=[],M=0,N=1,P=1/0,F=e=>{let t=c.createBuffer();return c.bindBuffer(c.ARRAY_BUFFER,t),c.bufferData(c.ARRAY_BUFFER,e,c.STATIC_DRAW),t},I=e=>{if(e)for(let t of[e.x,e.y,e.starts,e.sid])c.deleteBuffer(t)},L=e=>{e&&(I(e.full),I(e.res),c.deleteTexture(e.styles))},R=e=>({x:F(e.x),y:F(e.y),starts:F(e.starts),sid:F(e.sid),total:e.x.length}),z=e=>{let t=e.full;if(t&&t.version===e.version)return t;if(t&&e.valuesOnly&&t.whole&&e.counts.every(t=>t===e.xs.length)){let n=e.xs.length,r=e.columns.length===1?e.columns[0]:new Float32Array(n*e.columns.length);return e.columns.length>1&&e.columns.forEach((e,t)=>r.set(e,t*n)),c.bindBuffer(c.ARRAY_BUFFER,t.y),c.bufferSubData(c.ARRAY_BUFFER,0,r),t.version=e.version,t}I(t);let n=i(e.xs,e.breaks,e.columns);return e.full={...R(n),version:e.version,whole:n.counts.every(t=>t===e.xs.length)},e.full},B=e=>{let t=Math.max(1,Math.round(e.plotW*(r.width/k)));if(e.resamplable&&N>M){let n=e.xs,r=0,i=n.length;for(;r<i;){let e=r+i>>>1;n[e]<M?r=e+1:i=e}let o=r;for(i=n.length;r<i;){let e=r+i>>>1;n[e]<=N?r=e+1:i=e}if(r-o>t*4){let r=`${e.version}|${M}|${N}|${t}`;if(e.res?.key!==r){I(e.res);let i=a(n,e.columns,e.origin,M,N,t);e.res={...R(i),key:r,bucket:i.bucket}}return{d:e.res,minGap:e.res.bucket*2.5}}}return{d:z(e),minGap:0}},V=(e,n)=>{let r=e.counts.length,i=Math.max(1,Math.ceil(r/t)),a=3*Math.min(Math.max(r,1),t),o=new Float32Array(a*i*4);for(let i=0;i<r;i++){let r=n[i],c=(Math.floor(i/t)*a+i%t*3)*4;if(!r)continue;let l=r.width??s;o.set([Math.min(r.scaleMin,r.scaleMax),Math.max(r.scaleMin,r.scaleMax),r.bandTop,r.bandBottom],c),o.set(r.color,c+4),o.set([r.gapMedian,l/2,l/2+2.5,+(e.counts[i]>=2)],c+8)}c.bindTexture(c.TEXTURE_2D,e.styles),c.texImage2D(c.TEXTURE_2D,0,c.RGBA32F,a,i,0,c.RGBA,c.FLOAT,o),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,c.NEAREST)};return{resize(e,t,n){k=Math.max(1,e),A=Math.max(1,t),r.width=Math.round(k*n),r.height=Math.round(A*n),D=r.width*2,O=r.height*2,T&&E&&(c.bindRenderbuffer(c.RENDERBUFFER,E),c.renderbufferStorage(c.RENDERBUFFER,c.RGBA8,D,O),c.bindFramebuffer(c.FRAMEBUFFER,T),c.framebufferRenderbuffer(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.RENDERBUFFER,E),c.bindFramebuffer(c.FRAMEBUFFER,null))},setData(e,t,n,r){let i=j[e],a=!t&&!!i&&r.length===i.columns.length;if(!t){if(!i)return;t=i.xs,n=i.breaks}let s=0;for(let e=0;e<t.length;e++)if(Number.isFinite(t[e])){s=t[e];break}let l=r.map(e=>{let t=0;for(let n=0;n<e.length;n++)e[n]===e[n]&&t++;return t});if(i&&(a||i.xs===t)){i.columns=r,i.counts=l,i.valuesOnly=a,i.version++,a||(I(i.full),i.full=null);return}let u={xs:t,breaks:n,columns:r,origin:s,counts:l,resamplable:!n?.some(e=>e)&&o(t),version:0,valuesOnly:!1,full:null,res:null,styles:c.createTexture(),left:i?.left??0,plotW:i?.plotW??0};V(u,[]),j[e]=u,L(i)},setStyles(e,t,n,r){let i=j[e];i&&(V(i,t),i.left=n,i.plotW=r)},clearLayer(e){L(j[e]),j[e]=null},setView(e,t,n=1/0){M=e,N=t,P=n},render(){c.bindFramebuffer(c.FRAMEBUFFER,T),c.viewport(0,0,T?D:r.width,T?O:r.height),c.disable(c.SCISSOR_TEST),c.clearColor(0,0,0,0),c.clear(c.COLOR_BUFFER_BIT),c.useProgram(f),c.uniform2f(C.res,k,A),c.uniform1i(C.styles,0),c.activeTexture(c.TEXTURE0),c.enable(c.BLEND),c.blendFunc(c.ONE,c.ONE_MINUS_SRC_ALPHA),c.bindBuffer(c.ARRAY_BUFFER,w),c.enableVertexAttribArray(m),c.vertexAttribPointer(m,2,c.FLOAT,!1,0,0),c.vertexAttribDivisor(m,0);for(let e of x)c.enableVertexAttribArray(e),c.vertexAttribDivisor(e,1);let e=N-M||1;for(let t of j){if(!t)continue;c.uniform1f(C.left,t.left),c.uniform1f(C.plotW,t.plotW),c.uniform1f(C.xoff,M-t.origin),c.uniform1f(C.xscale,t.plotW/e),c.uniform1f(C.xR,e),c.uniform1f(C.cutPx,Number.isFinite(P)?t.left+(P-M)*(t.plotW/e):1e9);let{d:n,minGap:r}=B(t);n.total<2||(c.uniform1f(C.minGap,r),c.bindTexture(c.TEXTURE_2D,t.styles),c.bindBuffer(c.ARRAY_BUFFER,n.x),c.vertexAttribPointer(h,1,c.FLOAT,!1,4,0),c.vertexAttribPointer(g,1,c.FLOAT,!1,4,4),c.bindBuffer(c.ARRAY_BUFFER,n.y),c.vertexAttribPointer(_,1,c.FLOAT,!1,4,0),c.vertexAttribPointer(v,1,c.FLOAT,!1,4,4),c.bindBuffer(c.ARRAY_BUFFER,n.starts),c.vertexAttribPointer(y,1,c.UNSIGNED_BYTE,!0,1,1),c.bindBuffer(c.ARRAY_BUFFER,n.sid),c.vertexAttribPointer(b,1,c.FLOAT,!1,4,0),c.drawArraysInstanced(c.TRIANGLE_STRIP,0,4,n.total-1))}for(let e of x)c.vertexAttribDivisor(e,0);T&&(c.bindFramebuffer(c.READ_FRAMEBUFFER,T),c.bindFramebuffer(c.DRAW_FRAMEBUFFER,null),c.blitFramebuffer(0,0,D,O,0,0,r.width,r.height,c.COLOR_BUFFER_BIT,c.LINEAR),c.bindFramebuffer(c.FRAMEBUFFER,null))},dispose(){for(let e of j)L(e);j.length=0,c.deleteBuffer(w),c.deleteFramebuffer(T),c.deleteRenderbuffer(E),c.deleteProgram(f),c.deleteShader(u),c.deleteShader(d),l&&c.getExtension(`WEBGL_lose_context`)?.loseContext()}}}let c=null,l=0,u=1,d;function f(e){c?.setStyles(e.layer,e.styles,e.left,e.plotW),l=e.xmin,u=e.xmax,d=e.cut,c?.setView(l,u,d),c?.render()}self.onmessage=e=>{let t=e.data;switch(t.type){case`init`:c=s(t.canvas,t.lineWidth),t.canvas.addEventListener?.(`webglcontextlost`,e=>{e.preventDefault(),self.postMessage({type:`lost`})});break;case`resize`:c?.resize(t.w,t.h,t.dpr),c?.render();break;case`data`:c?.setData(t.layer,t.xs,t.breaks,t.columns),f(t);break;case`style`:f(t);break;case`clear`:c?.clearLayer(t.layer),c?.render();break;case`view`:if(t.xmin===l&&t.xmax===u&&t.cut===d)break;l=t.xmin,u=t.xmax,d=t.cut,c?.setView(l,u,d),c?.render();break;case`dispose`:c?.dispose(),c=null,self.close();break}};
|