@xsynaptic/plazmoid-player 0.0.0-stage → 0.1.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/CHANGELOG.md +22 -0
- package/LICENSE +21 -0
- package/README.md +57 -2
- package/dist/astro.d.ts +4 -0
- package/dist/astro.js +33 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +7 -0
- package/dist/define/artist-line.d.ts +1 -0
- package/dist/define/artist-line.js +6 -0
- package/dist/define/artwork.d.ts +1 -0
- package/dist/define/artwork.js +5 -0
- package/dist/define/bar.d.ts +1 -0
- package/dist/define/bar.js +5 -0
- package/dist/define/cue-list.d.ts +1 -0
- package/dist/define/cue-list.js +5 -0
- package/dist/define/mute-button.d.ts +1 -0
- package/dist/define/mute-button.js +6 -0
- package/dist/define/overlay-content.d.ts +1 -0
- package/dist/define/overlay-content.js +6 -0
- package/dist/define/overlay-toggle.d.ts +1 -0
- package/dist/define/overlay-toggle.js +6 -0
- package/dist/define/overlay.d.ts +1 -0
- package/dist/define/overlay.js +5 -0
- package/dist/define/panel-toggle.d.ts +1 -0
- package/dist/define/panel-toggle.js +6 -0
- package/dist/define/panel-zoom.d.ts +1 -0
- package/dist/define/panel-zoom.js +6 -0
- package/dist/define/panel.d.ts +1 -0
- package/dist/define/panel.js +5 -0
- package/dist/define/play-button.d.ts +1 -0
- package/dist/define/play-button.js +6 -0
- package/dist/define/progress.d.ts +1 -0
- package/dist/define/progress.js +6 -0
- package/dist/define/queue-actions.d.ts +1 -0
- package/dist/define/queue-actions.js +6 -0
- package/dist/define/queue-button.d.ts +1 -0
- package/dist/define/queue-button.js +6 -0
- package/dist/define/root.d.ts +1 -0
- package/dist/define/root.js +5 -0
- package/dist/define/scope.d.ts +1 -0
- package/dist/define/scope.js +5 -0
- package/dist/define/scrub-readout.d.ts +1 -0
- package/dist/define/scrub-readout.js +5 -0
- package/dist/define/seek-button.d.ts +1 -0
- package/dist/define/seek-button.js +6 -0
- package/dist/define/status.d.ts +1 -0
- package/dist/define/status.js +5 -0
- package/dist/define/step-button.d.ts +1 -0
- package/dist/define/step-button.js +6 -0
- package/dist/define/time-slider.d.ts +1 -0
- package/dist/define/time-slider.js +6 -0
- package/dist/define/time.d.ts +1 -0
- package/dist/define/time.js +5 -0
- package/dist/define/title.d.ts +1 -0
- package/dist/define/title.js +6 -0
- package/dist/define/tray.d.ts +1 -0
- package/dist/define/tray.js +6 -0
- package/dist/define/volume.d.ts +1 -0
- package/dist/define/volume.js +6 -0
- package/dist/define.d.ts +1 -0
- package/dist/define.js +4 -0
- package/dist/elements/artist-line.js +30 -0
- package/dist/elements/artwork.js +40 -0
- package/dist/elements/bind-buffered.js +20 -0
- package/dist/elements/bind-player.js +22 -0
- package/dist/elements/bind-scrub-preview.js +13 -0
- package/dist/elements/button-part.js +32 -0
- package/dist/elements/create-player.d.ts +16 -0
- package/dist/elements/create-player.js +22 -0
- package/dist/elements/define-once.js +6 -0
- package/dist/elements/define.js +60 -0
- package/dist/elements/mute-button.js +25 -0
- package/dist/elements/overlay/overlay-body.js +172 -0
- package/dist/elements/overlay/overlay-content.js +23 -0
- package/dist/elements/overlay/overlay-grab.js +69 -0
- package/dist/elements/overlay/overlay-module.js +12 -0
- package/dist/elements/overlay/overlay-sheets.js +38 -0
- package/dist/elements/overlay/overlay-tabs.js +95 -0
- package/dist/elements/overlay/overlay.js +54 -0
- package/dist/elements/overlay/tracklist.js +76 -0
- package/dist/elements/overlay-toggle.js +39 -0
- package/dist/elements/panel/panel-module.js +9 -0
- package/dist/elements/panel/panel-surface.js +92 -0
- package/dist/elements/panel/panel-zoom.js +55 -0
- package/dist/elements/panel/panel.js +45 -0
- package/dist/elements/panel-toggle.js +43 -0
- package/dist/elements/place-seek-buttons.js +11 -0
- package/dist/elements/play-button.js +32 -0
- package/dist/elements/player-bar.js +54 -0
- package/dist/elements/player-context.js +19 -0
- package/dist/elements/player-element.d.ts +9 -0
- package/dist/elements/player-element.js +36 -0
- package/dist/elements/player-root.d.ts +27 -0
- package/dist/elements/player-root.js +96 -0
- package/dist/elements/progress.js +50 -0
- package/dist/elements/queue-button.js +92 -0
- package/dist/elements/scope/scope-module.js +9 -0
- package/dist/elements/scope/scope-surface.js +26 -0
- package/dist/elements/scope/scope.js +61 -0
- package/dist/elements/scrub-readout.js +63 -0
- package/dist/elements/seek-button.js +42 -0
- package/dist/elements/status.js +37 -0
- package/dist/elements/step-button.js +36 -0
- package/dist/elements/time-slider/label-placement.js +11 -0
- package/dist/elements/time-slider/spoken-time.js +39 -0
- package/dist/elements/time-slider/time-slider.js +139 -0
- package/dist/elements/time.js +47 -0
- package/dist/elements/title.js +46 -0
- package/dist/elements/tray/drop-index.js +8 -0
- package/dist/elements/tray/queue-actions.js +58 -0
- package/dist/elements/tray/row-drag.js +123 -0
- package/dist/elements/tray/tray-module.js +11 -0
- package/dist/elements/tray/tray-rows.js +85 -0
- package/dist/elements/tray/tray.js +102 -0
- package/dist/elements/volume-level.js +23 -0
- package/dist/elements/volume.js +41 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +5 -0
- package/dist/labels.d.ts +36 -0
- package/dist/labels.js +39 -0
- package/dist/lib/bind-button.js +12 -0
- package/dist/lib/bind-preload.js +11 -0
- package/dist/lib/can-set-volume.js +15 -0
- package/dist/lib/dialog-exit.js +50 -0
- package/dist/lib/dismiss.js +15 -0
- package/dist/lib/format.js +12 -0
- package/dist/lib/icons.js +106 -0
- package/dist/lib/keyed-children.js +34 -0
- package/dist/lib/lazy-module.d.ts +5 -0
- package/dist/lib/lazy-module.js +41 -0
- package/dist/lib/observe-resize.js +10 -0
- package/dist/lib/preload-when-queued.js +29 -0
- package/dist/lib/read-px-property.js +7 -0
- package/dist/lib/render.js +22 -0
- package/dist/lib/sonic-button.js +22 -0
- package/dist/lib/supersede.js +19 -0
- package/dist/player.css +33 -0
- package/dist/styles/bar.css +253 -0
- package/dist/styles/coarse.css +47 -0
- package/dist/styles/controls.css +220 -0
- package/dist/styles/cue.css +53 -0
- package/dist/styles/focus.css +12 -0
- package/dist/styles/host.css +34 -0
- package/dist/styles/overlay-layout.css +258 -0
- package/dist/styles/overlay.css +282 -0
- package/dist/styles/panel.css +94 -0
- package/dist/styles/primitives.css +176 -0
- package/dist/styles/reset.css +21 -0
- package/dist/styles/status.css +42 -0
- package/dist/styles/tokens.css +142 -0
- package/dist/styles/track.css +150 -0
- package/dist/styles/tray.css +151 -0
- package/dist/types.d.ts +37 -0
- package/dist/view/view-persistence.js +33 -0
- package/dist/view/view-store.d.ts +30 -0
- package/dist/view/view-store.js +64 -0
- package/dist/view/zoom-levels.js +21 -0
- package/dist/waveform/bind-loaded-waveform.js +36 -0
- package/dist/waveform/cue-markers.js +31 -0
- package/dist/waveform/known-peaks.js +9 -0
- package/dist/waveform/overview-values.js +13 -0
- package/dist/waveform/retry-delay.js +8 -0
- package/dist/waveform/tint-cell.js +15 -0
- package/dist/waveform/waveform-peaks.js +144 -0
- package/package.json +80 -3
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { overviewFullScale } from "@xsynaptic/plazmoid-wavedata";
|
|
2
|
+
|
|
3
|
+
// src/waveform/overview-values.ts
|
|
4
|
+
function decodeOverview(encoded) {
|
|
5
|
+
try {
|
|
6
|
+
const bytes = atob(encoded);
|
|
7
|
+
return Float32Array.from(bytes, (byte) => (byte.codePointAt(0) ?? 0) / overviewFullScale);
|
|
8
|
+
} catch {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { decodeOverview };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/waveform/tint-cell.ts
|
|
2
|
+
const cellTokens = [["tint-hue", "--pzm-tint-hue"], ["tint-dynamics", "--pzm-tint-dynamics"]];
|
|
3
|
+
function applyTintCell(control) {
|
|
4
|
+
const styles = getComputedStyle(control);
|
|
5
|
+
for (const [attribute, token] of cellTokens) {
|
|
6
|
+
const value = styles.getPropertyValue(token).trim();
|
|
7
|
+
if (value === "" || value === "none") {
|
|
8
|
+
control.removeAttribute(attribute);
|
|
9
|
+
continue;
|
|
10
|
+
}
|
|
11
|
+
control.setAttribute(attribute, value);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { applyTintCell };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { framesByteRange, pairsByteRange, splitPairs } from "@xsynaptic/plazmoid-wavedata";
|
|
2
|
+
import { retryDelayMs } from "./retry-delay.js";
|
|
3
|
+
|
|
4
|
+
// src/waveform/waveform-peaks.ts
|
|
5
|
+
const chunkPairs = 8192;
|
|
6
|
+
const cacheLimit = 2;
|
|
7
|
+
const cache = /* @__PURE__ */ new Map();
|
|
8
|
+
function openPeaks(source) {
|
|
9
|
+
const cached = cache.get(source.url);
|
|
10
|
+
if (cached) return cached;
|
|
11
|
+
const reader = createReader(source);
|
|
12
|
+
if (cache.size >= cacheLimit) {
|
|
13
|
+
const oldest = cache.keys().next().value;
|
|
14
|
+
if (oldest !== void 0) cache.delete(oldest);
|
|
15
|
+
}
|
|
16
|
+
cache.set(source.url, reader);
|
|
17
|
+
return reader;
|
|
18
|
+
}
|
|
19
|
+
async function fetchRange(url, [start, end]) {
|
|
20
|
+
try {
|
|
21
|
+
const response = await fetch(url, { headers: { Range: `bytes=${String(start)}-${String(end - 1)}` } });
|
|
22
|
+
if (response.status !== 206) {
|
|
23
|
+
await response.body?.cancel();
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
return await response.arrayBuffer();
|
|
27
|
+
} catch {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function createBandsTwin(source, pairsPerSecond) {
|
|
32
|
+
const { bandCount, frameCount, framesPerSecond, medians, minDecibels } = source;
|
|
33
|
+
return {
|
|
34
|
+
bandCount,
|
|
35
|
+
chunkFrames: Math.round(chunkPairs * framesPerSecond / pairsPerSecond),
|
|
36
|
+
framesPerSecond,
|
|
37
|
+
landed: /* @__PURE__ */ new Set(),
|
|
38
|
+
levels: new Uint8Array(frameCount * bandCount),
|
|
39
|
+
medians,
|
|
40
|
+
minDecibels,
|
|
41
|
+
source
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function levelsRange(twin, chunk) {
|
|
45
|
+
return framesByteRange(twin.source, chunk * twin.chunkFrames, (chunk + 1) * twin.chunkFrames);
|
|
46
|
+
}
|
|
47
|
+
async function fetchLevels(twin, chunk) {
|
|
48
|
+
if (twin.landed.has(chunk)) return void 0;
|
|
49
|
+
const range = levelsRange(twin, chunk);
|
|
50
|
+
if (!range) return void 0;
|
|
51
|
+
const bytes = await fetchRange(twin.source.url, range);
|
|
52
|
+
return bytes && (() => {
|
|
53
|
+
twin.levels.set(new Uint8Array(bytes), range[0] - twin.source.byteOffset);
|
|
54
|
+
twin.landed.add(chunk);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function createReader(source) {
|
|
58
|
+
const { bands: bandsSource, pairCount, pairsPerSecond, rmsRange, url } = source;
|
|
59
|
+
const samples = new Int8Array(pairCount * 2);
|
|
60
|
+
const rms = new Int8Array(pairCount);
|
|
61
|
+
const bands = bandsSource && createBandsTwin(bandsSource, pairsPerSecond);
|
|
62
|
+
const chunkCount = Math.ceil(pairCount / chunkPairs);
|
|
63
|
+
const landed = /* @__PURE__ */ new Set();
|
|
64
|
+
const requests = /* @__PURE__ */ new Map();
|
|
65
|
+
let announce;
|
|
66
|
+
let changed;
|
|
67
|
+
function awaitChange() {
|
|
68
|
+
changed = new Promise((resolve) => {
|
|
69
|
+
announce = () => {
|
|
70
|
+
awaitChange();
|
|
71
|
+
resolve();
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
awaitChange();
|
|
76
|
+
function chunksIn(fromSeconds, toSeconds) {
|
|
77
|
+
const first = Math.floor(Math.max(0, fromSeconds * pairsPerSecond) / chunkPairs);
|
|
78
|
+
const last = Math.min(chunkCount - 1, Math.floor(Math.max(0, toSeconds * pairsPerSecond) / chunkPairs));
|
|
79
|
+
const chunks = [];
|
|
80
|
+
for (let chunk = first; chunk <= last; chunk += 1) chunks.push(chunk);
|
|
81
|
+
return chunks;
|
|
82
|
+
}
|
|
83
|
+
function isComplete(chunk) {
|
|
84
|
+
if (!landed.has(chunk)) return false;
|
|
85
|
+
return !bands || bands.landed.has(chunk) || !levelsRange(bands, chunk);
|
|
86
|
+
}
|
|
87
|
+
async function fetchPeaks(chunk) {
|
|
88
|
+
if (landed.has(chunk)) return void 0;
|
|
89
|
+
const range = pairsByteRange(source, chunk * chunkPairs, (chunk + 1) * chunkPairs);
|
|
90
|
+
if (!range) return void 0;
|
|
91
|
+
const bytes = await fetchRange(url, range);
|
|
92
|
+
return bytes && (() => {
|
|
93
|
+
splitPairs(new Uint8Array(bytes), {
|
|
94
|
+
rms,
|
|
95
|
+
samples
|
|
96
|
+
}, chunk * chunkPairs);
|
|
97
|
+
landed.add(chunk);
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
async function load(chunk, request) {
|
|
101
|
+
const landings = await Promise.all([bands && fetchLevels(bands, chunk), fetchPeaks(chunk)]);
|
|
102
|
+
for (const land of landings) land?.();
|
|
103
|
+
if (landings.some(Boolean)) announce();
|
|
104
|
+
if (isComplete(chunk)) return;
|
|
105
|
+
request.failures += 1;
|
|
106
|
+
setTimeout(() => {
|
|
107
|
+
request.isHeld = false;
|
|
108
|
+
announce();
|
|
109
|
+
}, retryDelayMs(request.failures));
|
|
110
|
+
}
|
|
111
|
+
return {
|
|
112
|
+
bands,
|
|
113
|
+
durationSeconds: pairCount / pairsPerSecond,
|
|
114
|
+
peaks: {
|
|
115
|
+
pairsPerSecond,
|
|
116
|
+
rms,
|
|
117
|
+
rmsRange,
|
|
118
|
+
samples
|
|
119
|
+
},
|
|
120
|
+
peaksWithoutBody: {
|
|
121
|
+
pairsPerSecond,
|
|
122
|
+
samples
|
|
123
|
+
},
|
|
124
|
+
pending: (fromSeconds, toSeconds) => chunksIn(fromSeconds, toSeconds).filter((chunk) => !landed.has(chunk)).map((chunk) => [chunk * chunkPairs / pairsPerSecond, Math.min(pairCount, (chunk + 1) * chunkPairs) / pairsPerSecond]),
|
|
125
|
+
request: (fromSeconds, toSeconds) => {
|
|
126
|
+
let hasGap = false;
|
|
127
|
+
for (const chunk of chunksIn(fromSeconds, toSeconds)) {
|
|
128
|
+
if (isComplete(chunk)) continue;
|
|
129
|
+
hasGap = true;
|
|
130
|
+
const held = requests.get(chunk) ?? {
|
|
131
|
+
failures: 0,
|
|
132
|
+
isHeld: false
|
|
133
|
+
};
|
|
134
|
+
if (held.isHeld) continue;
|
|
135
|
+
held.isHeld = true;
|
|
136
|
+
requests.set(chunk, held);
|
|
137
|
+
load(chunk, held);
|
|
138
|
+
}
|
|
139
|
+
return hasGap ? changed : void 0;
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export { openPeaks };
|
package/package.json
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xsynaptic/plazmoid-player",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "The interface for the Plazmoid audio player",
|
|
5
|
+
"homepage": "https://github.com/xsynaptic/plazmoid#readme",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/xsynaptic/plazmoid/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/xsynaptic/plazmoid.git",
|
|
12
|
+
"directory": "packages/plazmoid-player"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Alexander Synaptic <x@synapticism.com>",
|
|
16
|
+
"type": "module",
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=24.0.0"
|
|
19
|
+
},
|
|
20
|
+
"sideEffects": [
|
|
21
|
+
"*.css",
|
|
22
|
+
"./dist/define.js",
|
|
23
|
+
"./dist/define/*.js"
|
|
24
|
+
],
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js"
|
|
29
|
+
},
|
|
30
|
+
"./astro": {
|
|
31
|
+
"types": "./dist/astro.d.ts",
|
|
32
|
+
"import": "./dist/astro.js"
|
|
33
|
+
},
|
|
34
|
+
"./constants": {
|
|
35
|
+
"types": "./dist/constants.d.ts",
|
|
36
|
+
"import": "./dist/constants.js"
|
|
37
|
+
},
|
|
38
|
+
"./define": {
|
|
39
|
+
"types": "./dist/define.d.ts",
|
|
40
|
+
"import": "./dist/define.js"
|
|
41
|
+
},
|
|
42
|
+
"./define/*": {
|
|
43
|
+
"types": "./dist/define/*.d.ts",
|
|
44
|
+
"import": "./dist/define/*.js"
|
|
45
|
+
},
|
|
46
|
+
"./labels": {
|
|
47
|
+
"types": "./dist/labels.d.ts",
|
|
48
|
+
"import": "./dist/labels.js"
|
|
49
|
+
},
|
|
50
|
+
"./player.css": "./dist/player.css"
|
|
51
|
+
},
|
|
52
|
+
"imports": {},
|
|
53
|
+
"files": [
|
|
54
|
+
"dist",
|
|
55
|
+
"CHANGELOG.md"
|
|
56
|
+
],
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"@xsynaptic/plazmoid-wavedata": "^0.1.1",
|
|
59
|
+
"zustand": "^5.1.0"
|
|
60
|
+
},
|
|
61
|
+
"peerDependencies": {
|
|
62
|
+
"@xsynaptic/plazmoid-core": "^0.1.1",
|
|
63
|
+
"@xsynaptic/sonic-ui": "~0.31.0"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@fast-check/vitest": "^0.5.0",
|
|
67
|
+
"@playwright/test": "^1.65.1",
|
|
68
|
+
"@testing-library/dom": "^10.4.2",
|
|
69
|
+
"@xsynaptic/plazmoid-core": "^0.1.1",
|
|
70
|
+
"@xsynaptic/sonic-ui": "~0.31.0",
|
|
71
|
+
"publint": "^0.3.25",
|
|
72
|
+
"tsdown": "^0.23.7",
|
|
73
|
+
"typescript": "^6.0.3",
|
|
74
|
+
"vite": "^8.3.8"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "tsdown",
|
|
78
|
+
"check-types": "tsc --noEmit && tsc --noEmit -p tsconfig.shipped.json",
|
|
79
|
+
"cut-fixtures": "node verify/e2e/cut-fixtures.ts",
|
|
80
|
+
"playground": "node verify/e2e/playground.ts",
|
|
81
|
+
"test-e2e": "pnpm cut-fixtures && playwright test"
|
|
82
|
+
}
|
|
6
83
|
}
|