@nomercy-entertainment/nomercy-player-core 2.2.7 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/CONTRIBUTING.md +6 -5
- package/MIGRATION.md +1 -1
- package/RELEASING.md +2 -2
- package/THIRD-PARTY-NOTICES.md +29 -0
- package/dist/adapters/cue-parser/ICueParser.d.ts +1 -1
- package/dist/core/kit-version.js +1 -1
- package/dist/core/mixins/i18n.js +2 -2
- package/dist/core/mixins/i18n.js.map +1 -1
- package/dist/core/plugin/base.d.ts +1 -1
- package/dist/core/plugin/base.d.ts.map +1 -1
- package/dist/core/plugin/base.js +1 -1
- package/dist/core/plugin/base.js.map +1 -1
- package/dist/core/plugin-translations.d.ts +2 -0
- package/dist/core/plugin-translations.d.ts.map +1 -1
- package/dist/core/plugin-translations.js +8 -1
- package/dist/core/plugin-translations.js.map +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/errors/player.d.ts +1 -1
- package/dist/errors/player.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/plugins/equalizer/index.js +2 -2
- package/dist/plugins/equalizer/index.js.map +1 -1
- package/dist/plugins/equalizer/presets.d.ts +3 -3
- package/dist/plugins/equalizer/presets.js +1 -1
- package/dist/plugins/visualization/frame-texture.d.ts +26 -0
- package/dist/plugins/visualization/frame-texture.d.ts.map +1 -0
- package/dist/plugins/visualization/frame-texture.js +84 -0
- package/dist/plugins/visualization/frame-texture.js.map +1 -0
- package/dist/plugins/visualization/gpu-surface.d.ts +50 -0
- package/dist/plugins/visualization/gpu-surface.d.ts.map +1 -0
- package/dist/plugins/visualization/gpu-surface.js +103 -0
- package/dist/plugins/visualization/gpu-surface.js.map +1 -0
- package/dist/plugins/visualization/index.d.ts +31 -5
- package/dist/plugins/visualization/index.d.ts.map +1 -1
- package/dist/plugins/visualization/index.js +57 -4
- package/dist/plugins/visualization/index.js.map +1 -1
- package/dist/types/plugin.d.ts +1 -1
- package/dist/types/translations.d.ts +1 -1
- package/package.json +5 -3
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A `width x rows` single-channel byte texture (R8) for per-frame data such as
|
|
3
|
+
* the frequency row and the waveform row. Each uploaded row is resampled to
|
|
4
|
+
* `width`, so the shader samples a fixed width whatever the analyser size.
|
|
5
|
+
*
|
|
6
|
+
* Knows nothing about shaders. Sampling row `n` at v = (n + 0.5) / rows gives
|
|
7
|
+
* its value as `texture(...).r` in 0..1.
|
|
8
|
+
*/
|
|
9
|
+
export declare class FrameDataTexture {
|
|
10
|
+
private readonly gl;
|
|
11
|
+
readonly width: number;
|
|
12
|
+
readonly rows: number;
|
|
13
|
+
readonly texture: WebGLTexture | null;
|
|
14
|
+
private readonly _pixels;
|
|
15
|
+
private _disposed;
|
|
16
|
+
constructor(gl: WebGL2RenderingContext, width: number, rows: number);
|
|
17
|
+
/**
|
|
18
|
+
* Writes `data[n]` into row `n` (resampled to `width`) and uploads the whole
|
|
19
|
+
* texture. Rows beyond `data.length` keep their last values. Leaves the
|
|
20
|
+
* texture bound to `TEXTURE_2D` on the active unit.
|
|
21
|
+
*/
|
|
22
|
+
upload(data: ReadonlyArray<ArrayLike<number>>): void;
|
|
23
|
+
/** Deletes the GL texture. Idempotent. */
|
|
24
|
+
dispose(): void;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=frame-texture.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-texture.d.ts","sourceRoot":"","sources":["../../../src/plugins/visualization/frame-texture.ts"],"names":[],"mappings":"AA+BA;;;;;;;GAOG;AACH,qBAAa,gBAAgB;IAKhB,OAAO,CAAC,QAAQ,CAAC,EAAE;IAA0B,QAAQ,CAAC,KAAK,EAAE,MAAM;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM;IAJtG,QAAQ,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;IACtC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAa;IACrC,OAAO,CAAC,SAAS,CAAS;gBAEG,EAAE,EAAE,sBAAsB,EAAW,KAAK,EAAE,MAAM,EAAW,IAAI,EAAE,MAAM;IAYtG;;;;OAIG;IACH,MAAM,CAAC,IAAI,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI;IAapD,0CAA0C;IAC1C,OAAO,IAAI,IAAI;CAOf"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) NoMercy Entertainment
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0. See LICENSE for details.
|
|
5
|
+
//
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
// -----------------------------------------------------------------------------
|
|
8
|
+
/** Linear resample of `source` into `target`, end points included. */
|
|
9
|
+
function resampleRow(source, target) {
|
|
10
|
+
const width = target.length;
|
|
11
|
+
const count = source.length;
|
|
12
|
+
if (count === 0) {
|
|
13
|
+
target.fill(0);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (width === 1 || count === 1) {
|
|
17
|
+
target.fill(source[0] ?? 0);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const step = (count - 1) / (width - 1);
|
|
21
|
+
for (let i = 0; i < width; i++) {
|
|
22
|
+
const position = i * step;
|
|
23
|
+
const index = Math.min(Math.floor(position), count - 2);
|
|
24
|
+
const fraction = position - index;
|
|
25
|
+
const from = source[index] ?? 0;
|
|
26
|
+
const to = source[index + 1] ?? 0;
|
|
27
|
+
target[i] = Math.round(from + (to - from) * fraction);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A `width x rows` single-channel byte texture (R8) for per-frame data such as
|
|
32
|
+
* the frequency row and the waveform row. Each uploaded row is resampled to
|
|
33
|
+
* `width`, so the shader samples a fixed width whatever the analyser size.
|
|
34
|
+
*
|
|
35
|
+
* Knows nothing about shaders. Sampling row `n` at v = (n + 0.5) / rows gives
|
|
36
|
+
* its value as `texture(...).r` in 0..1.
|
|
37
|
+
*/
|
|
38
|
+
export class FrameDataTexture {
|
|
39
|
+
gl;
|
|
40
|
+
width;
|
|
41
|
+
rows;
|
|
42
|
+
texture;
|
|
43
|
+
_pixels;
|
|
44
|
+
_disposed = false;
|
|
45
|
+
constructor(gl, width, rows) {
|
|
46
|
+
this.gl = gl;
|
|
47
|
+
this.width = width;
|
|
48
|
+
this.rows = rows;
|
|
49
|
+
this._pixels = new Uint8Array(width * rows);
|
|
50
|
+
this.texture = gl.createTexture();
|
|
51
|
+
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
52
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
|
|
53
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
|
|
54
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
|
|
55
|
+
gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
|
|
56
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
|
|
57
|
+
gl.texImage2D(gl.TEXTURE_2D, 0, gl.R8, width, rows, 0, gl.RED, gl.UNSIGNED_BYTE, this._pixels);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Writes `data[n]` into row `n` (resampled to `width`) and uploads the whole
|
|
61
|
+
* texture. Rows beyond `data.length` keep their last values. Leaves the
|
|
62
|
+
* texture bound to `TEXTURE_2D` on the active unit.
|
|
63
|
+
*/
|
|
64
|
+
upload(data) {
|
|
65
|
+
if (this._disposed || !this.texture)
|
|
66
|
+
return;
|
|
67
|
+
const count = Math.min(data.length, this.rows);
|
|
68
|
+
for (let row = 0; row < count; row++)
|
|
69
|
+
resampleRow(data[row], this._pixels.subarray(row * this.width, (row + 1) * this.width));
|
|
70
|
+
const gl = this.gl;
|
|
71
|
+
gl.bindTexture(gl.TEXTURE_2D, this.texture);
|
|
72
|
+
gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
|
|
73
|
+
gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, this.width, this.rows, gl.RED, gl.UNSIGNED_BYTE, this._pixels);
|
|
74
|
+
}
|
|
75
|
+
/** Deletes the GL texture. Idempotent. */
|
|
76
|
+
dispose() {
|
|
77
|
+
if (this._disposed)
|
|
78
|
+
return;
|
|
79
|
+
this._disposed = true;
|
|
80
|
+
if (this.texture)
|
|
81
|
+
this.gl.deleteTexture(this.texture);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=frame-texture.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frame-texture.js","sourceRoot":"","sources":["../../../src/plugins/visualization/frame-texture.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uCAAuC;AACvC,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,uCAAuC;AACvC,gFAAgF;AAEhF,sEAAsE;AACtE,SAAS,WAAW,CAAC,MAAyB,EAAE,MAAkB;IACjE,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QACjB,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACf,OAAO;IACR,CAAC;IACD,IAAI,KAAK,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;QAChC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC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IAAI,CAAC,EAAE,CAAC;QACnB,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QAC5C,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC;QACvC,EAAE,CAAC,aAAa,CAAC,EAAE,CAAC,UAAU,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACzG,CAAC;IAED,0CAA0C;IAC1C,OAAO;QACN,IAAI,IAAI,CAAC,SAAS;YACjB,OAAO;QACR,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,IAAI,CAAC,OAAO;YACf,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;CACD"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** Options for {@link GpuSurface}. */
|
|
2
|
+
export interface GpuSurfaceOptions {
|
|
3
|
+
/** Backing-store pixels per CSS pixel. Default `1`. */
|
|
4
|
+
scale?: number;
|
|
5
|
+
/** Passed to `getContext('webgl2', ...)`. */
|
|
6
|
+
contextAttributes?: WebGLContextAttributes;
|
|
7
|
+
/** Called once when no WebGL2 context could be created. */
|
|
8
|
+
onUnsupported?: (reason: string) => void;
|
|
9
|
+
onContextLost?: () => void;
|
|
10
|
+
onContextRestored?: () => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A WebGL2 canvas that owns its own element under a caller-given parent.
|
|
14
|
+
*
|
|
15
|
+
* It is a separate element on purpose: a canvas that already holds a 2D
|
|
16
|
+
* context returns `null` for `webgl2`, and `CanvasPlugin` takes the 2D context
|
|
17
|
+
* of its own canvas on the first tick. The surface never throws; when WebGL2
|
|
18
|
+
* is missing `context()` returns `null` and `onUnsupported` fires once.
|
|
19
|
+
*
|
|
20
|
+
* The caller decides the scale (the backing store is `round(css * scale)`) and
|
|
21
|
+
* recreates its GL resources when `onContextRestored` fires.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GpuSurface {
|
|
24
|
+
private readonly opts;
|
|
25
|
+
private readonly _canvas;
|
|
26
|
+
private _gl;
|
|
27
|
+
private _scale;
|
|
28
|
+
private _cssWidth;
|
|
29
|
+
private _cssHeight;
|
|
30
|
+
private _lost;
|
|
31
|
+
private _disposed;
|
|
32
|
+
private readonly _onLost;
|
|
33
|
+
private readonly _onRestored;
|
|
34
|
+
constructor(parent: HTMLElement, opts?: GpuSurfaceOptions);
|
|
35
|
+
canvas(): HTMLCanvasElement;
|
|
36
|
+
/** The WebGL2 context, or `null` when unsupported or after `dispose()`. */
|
|
37
|
+
context(): WebGL2RenderingContext | null;
|
|
38
|
+
isLost(): boolean;
|
|
39
|
+
scale(): number;
|
|
40
|
+
setScale(scale: number): void;
|
|
41
|
+
/** Sets the backing store to `round(css * scale)` for the given CSS size. */
|
|
42
|
+
resize(cssWidth: number, cssHeight: number): void;
|
|
43
|
+
/**
|
|
44
|
+
* Releases the GL context through `WEBGL_lose_context` and removes the
|
|
45
|
+
* canvas. Browsers cap live contexts, so repeated mounts need this.
|
|
46
|
+
* Idempotent.
|
|
47
|
+
*/
|
|
48
|
+
dispose(): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=gpu-surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-surface.d.ts","sourceRoot":"","sources":["../../../src/plugins/visualization/gpu-surface.ts"],"names":[],"mappings":"AAQA,sCAAsC;AACtC,MAAM,WAAW,iBAAiB;IACjC,uDAAuD;IACvD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,6CAA6C;IAC7C,iBAAiB,CAAC,EAAE,sBAAsB,CAAC;IAC3C,2DAA2D;IAC3D,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,qBAAa,UAAU;IAoBW,OAAO,CAAC,QAAQ,CAAC,IAAI;IAnBtD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoB;IAC5C,OAAO,CAAC,GAAG,CAAuC;IAClD,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,SAAS,CAAK;IACtB,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAS;IAE1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAItB;IAEF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAG1B;gBAEU,MAAM,EAAE,WAAW,EAAmB,IAAI,GAAE,iBAAsB;IA0B9E,MAAM,IAAI,iBAAiB;IAI3B,2EAA2E;IAC3E,OAAO,IAAI,sBAAsB,GAAG,IAAI;IAIxC,MAAM,IAAI,OAAO;IAIjB,KAAK,IAAI,MAAM;IAIf,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK7B,6EAA6E;IAC7E,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAOjD;;;;OAIG;IACH,OAAO,IAAI,IAAI;CAcf"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// -----------------------------------------------------------------------------
|
|
2
|
+
// Copyright (c) NoMercy Entertainment
|
|
3
|
+
//
|
|
4
|
+
// Licensed under the Apache License, Version 2.0. See LICENSE for details.
|
|
5
|
+
//
|
|
6
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
// -----------------------------------------------------------------------------
|
|
8
|
+
/**
|
|
9
|
+
* A WebGL2 canvas that owns its own element under a caller-given parent.
|
|
10
|
+
*
|
|
11
|
+
* It is a separate element on purpose: a canvas that already holds a 2D
|
|
12
|
+
* context returns `null` for `webgl2`, and `CanvasPlugin` takes the 2D context
|
|
13
|
+
* of its own canvas on the first tick. The surface never throws; when WebGL2
|
|
14
|
+
* is missing `context()` returns `null` and `onUnsupported` fires once.
|
|
15
|
+
*
|
|
16
|
+
* The caller decides the scale (the backing store is `round(css * scale)`) and
|
|
17
|
+
* recreates its GL resources when `onContextRestored` fires.
|
|
18
|
+
*/
|
|
19
|
+
export class GpuSurface {
|
|
20
|
+
opts;
|
|
21
|
+
_canvas;
|
|
22
|
+
_gl = null;
|
|
23
|
+
_scale;
|
|
24
|
+
_cssWidth = 0;
|
|
25
|
+
_cssHeight = 0;
|
|
26
|
+
_lost = false;
|
|
27
|
+
_disposed = false;
|
|
28
|
+
_onLost = (event) => {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
this._lost = true;
|
|
31
|
+
this.opts.onContextLost?.();
|
|
32
|
+
};
|
|
33
|
+
_onRestored = () => {
|
|
34
|
+
this._lost = false;
|
|
35
|
+
this.opts.onContextRestored?.();
|
|
36
|
+
};
|
|
37
|
+
constructor(parent, opts = {}) {
|
|
38
|
+
this.opts = opts;
|
|
39
|
+
this._scale = opts.scale ?? 1;
|
|
40
|
+
this._canvas = document.createElement('canvas');
|
|
41
|
+
this._canvas.className = 'nmplayer-gpu-surface';
|
|
42
|
+
this._canvas.style.position = 'absolute';
|
|
43
|
+
this._canvas.style.left = '0';
|
|
44
|
+
this._canvas.style.top = '0';
|
|
45
|
+
this._canvas.style.width = '100%';
|
|
46
|
+
this._canvas.style.height = '100%';
|
|
47
|
+
this._canvas.style.pointerEvents = 'none';
|
|
48
|
+
try {
|
|
49
|
+
this._gl = this._canvas.getContext('webgl2', opts.contextAttributes);
|
|
50
|
+
}
|
|
51
|
+
catch { /* a blocked context is the same as an unsupported one */ }
|
|
52
|
+
if (!this._gl) {
|
|
53
|
+
opts.onUnsupported?.('webgl2-unavailable');
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
this._canvas.addEventListener('webglcontextlost', this._onLost);
|
|
57
|
+
this._canvas.addEventListener('webglcontextrestored', this._onRestored);
|
|
58
|
+
parent.appendChild(this._canvas);
|
|
59
|
+
}
|
|
60
|
+
canvas() {
|
|
61
|
+
return this._canvas;
|
|
62
|
+
}
|
|
63
|
+
/** The WebGL2 context, or `null` when unsupported or after `dispose()`. */
|
|
64
|
+
context() {
|
|
65
|
+
return this._gl;
|
|
66
|
+
}
|
|
67
|
+
isLost() {
|
|
68
|
+
return this._lost;
|
|
69
|
+
}
|
|
70
|
+
scale() {
|
|
71
|
+
return this._scale;
|
|
72
|
+
}
|
|
73
|
+
setScale(scale) {
|
|
74
|
+
this._scale = scale;
|
|
75
|
+
this.resize(this._cssWidth, this._cssHeight);
|
|
76
|
+
}
|
|
77
|
+
/** Sets the backing store to `round(css * scale)` for the given CSS size. */
|
|
78
|
+
resize(cssWidth, cssHeight) {
|
|
79
|
+
this._cssWidth = cssWidth;
|
|
80
|
+
this._cssHeight = cssHeight;
|
|
81
|
+
this._canvas.width = Math.max(0, Math.round(cssWidth * this._scale));
|
|
82
|
+
this._canvas.height = Math.max(0, Math.round(cssHeight * this._scale));
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Releases the GL context through `WEBGL_lose_context` and removes the
|
|
86
|
+
* canvas. Browsers cap live contexts, so repeated mounts need this.
|
|
87
|
+
* Idempotent.
|
|
88
|
+
*/
|
|
89
|
+
dispose() {
|
|
90
|
+
if (this._disposed)
|
|
91
|
+
return;
|
|
92
|
+
this._disposed = true;
|
|
93
|
+
this._canvas.removeEventListener('webglcontextlost', this._onLost);
|
|
94
|
+
this._canvas.removeEventListener('webglcontextrestored', this._onRestored);
|
|
95
|
+
try {
|
|
96
|
+
this._gl?.getExtension('WEBGL_lose_context')?.loseContext();
|
|
97
|
+
}
|
|
98
|
+
catch { /* the context is already gone */ }
|
|
99
|
+
this._gl = null;
|
|
100
|
+
this._canvas.remove();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=gpu-surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gpu-surface.js","sourceRoot":"","sources":["../../../src/plugins/visualization/gpu-surface.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uCAAuC;AACvC,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,uCAAuC;AACvC,gFAAgF;AAchF;;;;;;;;;;GAUG;AACH,MAAM,OAAO,UAAU;IAoB4B;IAnBjC,OAAO,CAAoB;IACpC,GAAG,GAAkC,IAAI,CAAC;IAC1C,MAAM,CAAS;IACf,SAAS,GAAG,CAAC,CAAC;IACd,UAAU,GAAG,CAAC,CAAC;IACf,KAAK,GAAG,KAAK,CAAC;IACd,SAAS,GAAG,KAAK,CAAC;IAET,OAAO,GAAG,CAAC,KAAY,EAAQ,EAAE;QACjD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;IAC7B,CAAC,CAAC;IAEe,WAAW,GAAG,GAAS,EAAE;QACzC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;IACjC,CAAC,CAAC;IAEF,YAAY,MAAmB,EAAmB,OAA0B,EAAE;QAA5B,SAAI,GAAJ,IAAI,CAAwB;QAC7E,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,sBAAsB,CAAC;QAChD,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC;QACzC,IAAI,CAAC,O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AC,SAAS,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,CAAC;IAED,6EAA6E;IAC7E,MAAM,CAAC,QAAgB,EAAE,SAAiB;QACzC,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IACxE,CAAC;IAED;;;;OAIG;IACH,OAAO;QACN,IAAI,IAAI,CAAC,SAAS;YACjB,OAAO;QACR,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QAEtB,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,kBAAkB,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAC3E,IAAI,CAAC;YACJ,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,oBAAoB,CAAC,EAAE,WAAW,EAAE,CAAC;QAC7D,CAAC;QACD,MAAM,CAAC,CAAC,iCAAiC,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACD"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { BaseEventMap, IPlayer, RequireSpec } from '../../types/index.js';
|
|
2
|
+
import type { GpuSurfaceOptions } from './gpu-surface.js';
|
|
2
3
|
import { Plugin } from '../../core/plugin/index.js';
|
|
4
|
+
import { GpuSurface } from './gpu-surface.js';
|
|
5
|
+
export { FrameDataTexture } from './frame-texture.js';
|
|
6
|
+
export { GpuSurface } from './gpu-surface.js';
|
|
7
|
+
export type { GpuSurfaceOptions } from './gpu-surface.js';
|
|
3
8
|
/**
|
|
4
9
|
* Per-frame data delivered to a VisualizationPlugin's `render()`. Includes
|
|
5
10
|
* spectrum, waveform, current time, BPM/beat (when a provider has supplied
|
|
@@ -115,17 +120,24 @@ export interface VisualizationOptions {
|
|
|
115
120
|
* Reserved for future use; currently only `'frame'` is active.
|
|
116
121
|
*/
|
|
117
122
|
tick?: 'frame' | 'time';
|
|
123
|
+
/** Go inactive while `document.hidden` is true. Default `false`. */
|
|
124
|
+
pauseWhenHidden?: boolean;
|
|
125
|
+
/** Go inactive while an `IntersectionObserver` reports the canvas off-screen. Default `false`. */
|
|
126
|
+
pauseWhenOffscreen?: boolean;
|
|
118
127
|
}
|
|
119
128
|
/** Events emitted by {@link VisualizationPlugin} subclasses. */
|
|
120
129
|
export interface VisualizationEvents {
|
|
121
|
-
/** Emitted
|
|
122
|
-
unsupported: {
|
|
130
|
+
/** Emitted when AudioContext / spectrum is unavailable, or a GPU surface gets no WebGL2. */
|
|
131
|
+
'unsupported': {
|
|
123
132
|
reason: string;
|
|
124
133
|
};
|
|
125
134
|
/** Emitted each render tick after `render()` completes. */
|
|
126
|
-
rendered: {
|
|
135
|
+
'rendered': {
|
|
127
136
|
frame: VisualizationFrame;
|
|
128
137
|
};
|
|
138
|
+
/** The GPU surface lost its WebGL2 context. Recreate GL resources on `gpu:contextrestored`. */
|
|
139
|
+
'gpu:contextlost': Record<string, never>;
|
|
140
|
+
'gpu:contextrestored': Record<string, never>;
|
|
129
141
|
}
|
|
130
142
|
/**
|
|
131
143
|
* Base class for canvas-based visualization plugins. Layered composition:
|
|
@@ -143,11 +155,11 @@ export interface VisualizationEvents {
|
|
|
143
155
|
* Bridges to p5.js, three.js, shader-based viz live in separate optional
|
|
144
156
|
* packages and build ON TOP of this — never use kit internals.
|
|
145
157
|
*
|
|
146
|
-
*
|
|
158
|
+
* Usage:
|
|
147
159
|
*
|
|
148
160
|
* ```ts
|
|
149
161
|
* class WinampClassic extends VisualizationPlugin {
|
|
150
|
-
* static readonly id = '
|
|
162
|
+
* static readonly id = 'winamp-classic';
|
|
151
163
|
*
|
|
152
164
|
* render(ctx: CanvasRenderingContext2D, frame: VisualizationFrame) {
|
|
153
165
|
* for (let i = 0; i < frame.frequency.length; i++) {
|
|
@@ -189,6 +201,10 @@ export declare abstract class VisualizationPlugin<P extends IPlayer<BaseEventMap
|
|
|
189
201
|
private _spectrumFrameHandler;
|
|
190
202
|
protected _latestFrame: VisualizationFrame | undefined;
|
|
191
203
|
private _setupCalled;
|
|
204
|
+
private _gpuSurface;
|
|
205
|
+
private _manualActive;
|
|
206
|
+
private _documentHidden;
|
|
207
|
+
private _offscreen;
|
|
192
208
|
/**
|
|
193
209
|
* Resolves the `CanvasPlugin` and `SpectrumPlugin` dependencies, registers
|
|
194
210
|
* the render callback with the canvas RAF loop, and subscribes to `frame`
|
|
@@ -212,6 +228,14 @@ export declare abstract class VisualizationPlugin<P extends IPlayer<BaseEventMap
|
|
|
212
228
|
* render loop for snapshot reads.
|
|
213
229
|
*/
|
|
214
230
|
currentFrame(): VisualizationFrame | undefined;
|
|
231
|
+
/** True unless set inactive by `setActive(false)` or paused by an opted-in source. */
|
|
232
|
+
isActive(): boolean;
|
|
233
|
+
/** Stops (`false`) or resumes (`true`) all render work for this instance. Idempotent. */
|
|
234
|
+
setActive(active: boolean): void;
|
|
235
|
+
/** Opt-in WebGL2 canvas under `parent`. Never throws; without WebGL2 it emits `unsupported`. */
|
|
236
|
+
protected createGpuSurface(parent: HTMLElement, opts?: Pick<GpuSurfaceOptions, 'scale' | 'contextAttributes'>): GpuSurface;
|
|
237
|
+
/** The surface made by `createGpuSurface()`, or `null` before it or after `dispose()`. */
|
|
238
|
+
protected gpuSurface(): GpuSurface | null;
|
|
215
239
|
/**
|
|
216
240
|
* Override this. Called once per frame at the canvas plugin's configured
|
|
217
241
|
* FPS, with a fully-populated VisualizationFrame and the shared 2D context.
|
|
@@ -238,6 +262,8 @@ export declare abstract class VisualizationPlugin<P extends IPlayer<BaseEventMap
|
|
|
238
262
|
beat?: boolean;
|
|
239
263
|
bpm?: number;
|
|
240
264
|
}): void;
|
|
265
|
+
private _watchDocumentVisibility;
|
|
266
|
+
private _watchViewport;
|
|
241
267
|
/**
|
|
242
268
|
* Per-canvas-RAF tick. Reads the latest spectrum frame, builds the
|
|
243
269
|
* VisualizationFrame payload (overlaying the canvas-supplied deltaMs unless
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/visualization/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/plugins/visualization/index.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAG3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAClC,4EAA4E;IAC5E,SAAS,EAAE,UAAU,CAAC;IACtB,0EAA0E;IAC1E,QAAQ,EAAE,UAA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,EAAE,KAAK,EAAE,kBAAkB,GAAG,IAAI;CAwBzF;AAED,oGAAoG;AACpG,eAAO,MAAM,qBAAqB,8BAAwB,CAAC"}
|
|
@@ -8,6 +8,9 @@
|
|
|
8
8
|
import { Plugin } from '../../core/plugin/index.js';
|
|
9
9
|
import { CanvasPlugin } from '../canvas/index.js';
|
|
10
10
|
import { SpectrumPlugin } from '../spectrum/index.js';
|
|
11
|
+
import { GpuSurface } from './gpu-surface.js';
|
|
12
|
+
export { FrameDataTexture } from './frame-texture.js';
|
|
13
|
+
export { GpuSurface } from './gpu-surface.js';
|
|
11
14
|
/**
|
|
12
15
|
* Base class for canvas-based visualization plugins. Layered composition:
|
|
13
16
|
*
|
|
@@ -24,11 +27,11 @@ import { SpectrumPlugin } from '../spectrum/index.js';
|
|
|
24
27
|
* Bridges to p5.js, three.js, shader-based viz live in separate optional
|
|
25
28
|
* packages and build ON TOP of this — never use kit internals.
|
|
26
29
|
*
|
|
27
|
-
*
|
|
30
|
+
* Usage:
|
|
28
31
|
*
|
|
29
32
|
* ```ts
|
|
30
33
|
* class WinampClassic extends VisualizationPlugin {
|
|
31
|
-
* static readonly id = '
|
|
34
|
+
* static readonly id = 'winamp-classic';
|
|
32
35
|
*
|
|
33
36
|
* render(ctx: CanvasRenderingContext2D, frame: VisualizationFrame) {
|
|
34
37
|
* for (let i = 0; i < frame.frequency.length; i++) {
|
|
@@ -70,6 +73,10 @@ export class VisualizationPlugin extends Plugin {
|
|
|
70
73
|
_spectrumFrameHandler = null;
|
|
71
74
|
_latestFrame;
|
|
72
75
|
_setupCalled = false;
|
|
76
|
+
_gpuSurface = null;
|
|
77
|
+
_manualActive = true;
|
|
78
|
+
_documentHidden = false;
|
|
79
|
+
_offscreen = false;
|
|
73
80
|
/**
|
|
74
81
|
* Resolves the `CanvasPlugin` and `SpectrumPlugin` dependencies, registers
|
|
75
82
|
* the render callback with the canvas RAF loop, and subscribes to `frame`
|
|
@@ -101,6 +108,10 @@ export class VisualizationPlugin extends Plugin {
|
|
|
101
108
|
this.on(SpectrumPlugin, 'frame', this._spectrumFrameHandler);
|
|
102
109
|
this._renderTickBound = this._renderTick.bind(this);
|
|
103
110
|
canvas.addRenderer(this._renderTickBound);
|
|
111
|
+
if (this.opts?.pauseWhenHidden)
|
|
112
|
+
this._watchDocumentVisibility();
|
|
113
|
+
if (this.opts?.pauseWhenOffscreen)
|
|
114
|
+
this._watchViewport(canvas);
|
|
104
115
|
}
|
|
105
116
|
/**
|
|
106
117
|
* Unregisters the render callback from the canvas plugin's RAF loop and
|
|
@@ -114,6 +125,8 @@ export class VisualizationPlugin extends Plugin {
|
|
|
114
125
|
}
|
|
115
126
|
catch { /* swallow */ }
|
|
116
127
|
}
|
|
128
|
+
this._gpuSurface?.dispose();
|
|
129
|
+
this._gpuSurface = null;
|
|
117
130
|
// Spectrum subscription is auto-cleaned by the lifecycle registry via `on()`.
|
|
118
131
|
this._renderTickBound = null;
|
|
119
132
|
this._spectrumFrameHandler = null;
|
|
@@ -131,6 +144,30 @@ export class VisualizationPlugin extends Plugin {
|
|
|
131
144
|
currentFrame() {
|
|
132
145
|
return this._latestFrame;
|
|
133
146
|
}
|
|
147
|
+
/** True unless set inactive by `setActive(false)` or paused by an opted-in source. */
|
|
148
|
+
isActive() {
|
|
149
|
+
return this._manualActive && !this._documentHidden && !this._offscreen;
|
|
150
|
+
}
|
|
151
|
+
/** Stops (`false`) or resumes (`true`) all render work for this instance. Idempotent. */
|
|
152
|
+
setActive(active) {
|
|
153
|
+
this._manualActive = active;
|
|
154
|
+
}
|
|
155
|
+
/** Opt-in WebGL2 canvas under `parent`. Never throws; without WebGL2 it emits `unsupported`. */
|
|
156
|
+
createGpuSurface(parent, opts = {}) {
|
|
157
|
+
this._gpuSurface?.dispose();
|
|
158
|
+
const surface = new GpuSurface(parent, {
|
|
159
|
+
...opts,
|
|
160
|
+
onUnsupported: reason => this.emit('unsupported', { reason }),
|
|
161
|
+
onContextLost: () => this.emit('gpu:contextlost', {}),
|
|
162
|
+
onContextRestored: () => this.emit('gpu:contextrestored', {}),
|
|
163
|
+
});
|
|
164
|
+
this._gpuSurface = surface;
|
|
165
|
+
return surface;
|
|
166
|
+
}
|
|
167
|
+
/** The surface made by `createGpuSurface()`, or `null` before it or after `dispose()`. */
|
|
168
|
+
gpuSurface() {
|
|
169
|
+
return this._gpuSurface;
|
|
170
|
+
}
|
|
134
171
|
/**
|
|
135
172
|
* Optional: override to do one-time setup after `use()` has resolved deps.
|
|
136
173
|
* Called once before the first `render()`.
|
|
@@ -149,13 +186,29 @@ export class VisualizationPlugin extends Plugin {
|
|
|
149
186
|
* from raw FFT data.
|
|
150
187
|
*/
|
|
151
188
|
onBeat(_beat) { }
|
|
189
|
+
_watchDocumentVisibility() {
|
|
190
|
+
this._documentHidden = document.hidden;
|
|
191
|
+
this.lifecycle.listen(document, 'visibilitychange', () => {
|
|
192
|
+
this._documentHidden = document.hidden;
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
_watchViewport(canvas) {
|
|
196
|
+
if (typeof IntersectionObserver === 'undefined')
|
|
197
|
+
return;
|
|
198
|
+
const observer = this.lifecycle.observe(new IntersectionObserver((entries) => {
|
|
199
|
+
const latest = entries[entries.length - 1];
|
|
200
|
+
if (latest)
|
|
201
|
+
this._offscreen = !latest.isIntersecting;
|
|
202
|
+
}));
|
|
203
|
+
observer.observe(canvas.canvas());
|
|
204
|
+
}
|
|
152
205
|
/**
|
|
153
206
|
* Per-canvas-RAF tick. Reads the latest spectrum frame, builds the
|
|
154
207
|
* VisualizationFrame payload (overlaying the canvas-supplied deltaMs unless
|
|
155
208
|
* the frame is synthetic), and dispatches to `render()`.
|
|
156
209
|
*/
|
|
157
210
|
_renderTick(ctx, deltaMs, _rafTime) {
|
|
158
|
-
if (!this.enabled())
|
|
211
|
+
if (!this.enabled() || !this.isActive())
|
|
159
212
|
return;
|
|
160
213
|
const spectrum = this._spectrumPlugin;
|
|
161
214
|
if (!spectrum)
|
|
@@ -226,7 +279,7 @@ export class VisualizationPlugin extends Plugin {
|
|
|
226
279
|
* ```
|
|
227
280
|
*/
|
|
228
281
|
export class WaveformVisualization extends VisualizationPlugin {
|
|
229
|
-
static id = '
|
|
282
|
+
static id = 'waveform';
|
|
230
283
|
static version = '2.0.0';
|
|
231
284
|
static description = 'Oscilloscope-style waveform stroke visualizer';
|
|
232
285
|
render(ctx, frame) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/visualization/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uCAAuC;AACvC,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,uCAAuC;AACvC,gFAAgF;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/visualization/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,uCAAuC;AACvC,EAAE;AACF,4EAA4E;AAC5E,EAAE;AACF,uCAAuC;AACvC,gFAAgF;AAKhF,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AA0I3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,OAAgB,mBAA+D,SAAQ,MAAoD;IAChJ,MAAM,CAAmB,EAAE,GAAW,eAAe,CAAC;IACtD,MAAM,CAAmB,OAAO,GAAW,OAAO,CAAC;IACnD,MAAM,CAAmB,WAAW,GAAW,+CAA+C,CAAC;IAE/F;;;OAGG;IACH,MAAM,CAAmB,QAAQ,GAA+B,CAAC,YAAY,EAAE,cAAc,CAAC,CAAC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AC,MAAM,CAAC;QAC7C,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YACtC,MAAM,WAAW,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,GAAG,KAAK,CAAC;YAC7C,MAAM,CAAC,GAAG,CAAC,WAAW,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;YAC3C,IAAI,CAAC,KAAK,CAAC;gBACV,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;gBACb,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YACtB,CAAC,IAAI,UAAU,CAAC;QACjB,CAAC;QACD,GAAG,CAAC,MAAM,EAAE,CAAC;IACd,CAAC;;AAGF,oGAAoG;AACpG,MAAM,CAAC,MAAM,qBAAqB,GAAG,qBAAqB,CAAC"}
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -102,7 +102,7 @@ export interface PluginAdvisory {
|
|
|
102
102
|
* Use this to advise specifically inside a `before*` handler — works for
|
|
103
103
|
* core events AND plugin-defined custom events.
|
|
104
104
|
*
|
|
105
|
-
*
|
|
105
|
+
* E.g. `duringEvent: 'beforePlay'` matches mutations inside a beforePlay
|
|
106
106
|
* handler. `duringEvent: 'plugin:my-plugin:beforeFoo'` matches mutations
|
|
107
107
|
* inside another plugin's custom before-event handler.
|
|
108
108
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Translation bundle map. Outer key is a BCP-47 language tag; inner map is
|
|
3
|
-
* key → translated string.
|
|
3
|
+
* key → translated string. E.g. `{ en: { 'core.network.timeout': 'Connection timed out' }, nl: { ... } }`.
|
|
4
4
|
*/
|
|
5
5
|
export type Translations = Record<string, Record<string, string>>;
|
|
6
6
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nomercy-entertainment/nomercy-player-core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.0",
|
|
5
|
+
"packageManager": "yarn@4.18.1",
|
|
5
6
|
"description": "NoMercy player core — shared spine for nomercy-music-player and nomercy-video-player. Plugin runtime, event system, lifecycle helpers, streams, cues, errors, auth.",
|
|
6
7
|
"author": {
|
|
7
8
|
"name": "NoMercy Entertainment",
|
|
@@ -205,6 +206,7 @@
|
|
|
205
206
|
"MIGRATION.md",
|
|
206
207
|
"RELEASING.md",
|
|
207
208
|
"SECURITY.md",
|
|
209
|
+
"THIRD-PARTY-NOTICES.md",
|
|
208
210
|
"dist",
|
|
209
211
|
"scripts"
|
|
210
212
|
],
|
|
@@ -222,7 +224,7 @@
|
|
|
222
224
|
"lint:fix": "eslint . --fix --max-warnings 0",
|
|
223
225
|
"test": "vitest run",
|
|
224
226
|
"test:watch": "vitest",
|
|
225
|
-
"prepublishOnly": "
|
|
227
|
+
"prepublishOnly": "yarn build"
|
|
226
228
|
},
|
|
227
229
|
"dependencies": {
|
|
228
230
|
"hls.js": "^1.6.0"
|
|
@@ -240,7 +242,7 @@
|
|
|
240
242
|
"vite": "^8.0.13",
|
|
241
243
|
"vitest": "^4.1.11"
|
|
242
244
|
},
|
|
243
|
-
"
|
|
245
|
+
"resolutions": {
|
|
244
246
|
"katex": "^0.18.2"
|
|
245
247
|
}
|
|
246
248
|
}
|