@editframe/elements 0.15.0-beta.7 → 0.15.0-beta.9
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/elements/EFMedia.d.ts +1 -0
- package/dist/elements/EFMedia.js +88 -0
- package/dist/elements/EFWaveform.d.ts +2 -1
- package/dist/elements/EFWaveform.js +33 -3
- package/dist/gui/TWMixin.css.js +1 -1
- package/dist/style.css +3 -0
- package/package.json +7 -3
- package/src/elements/EFMedia.ts +117 -0
- package/src/elements/EFWaveform.ts +55 -6
- package/types.json +1 -1
|
@@ -70,6 +70,7 @@ export declare class EFMedia extends EFMedia_base {
|
|
|
70
70
|
private static readonly MAX_DB;
|
|
71
71
|
private static readonly DECAY_WEIGHT;
|
|
72
72
|
get FREQ_WEIGHTS(): Float32Array;
|
|
73
|
+
byteTimeDomainTask: Task<readonly [import('@lit/task').TaskStatus, number, number, number], Uint8Array | null>;
|
|
73
74
|
frequencyDataTask: Task<readonly [import('@lit/task').TaskStatus, number, number, number], Uint8Array | null>;
|
|
74
75
|
}
|
|
75
76
|
export {};
|
package/dist/elements/EFMedia.js
CHANGED
|
@@ -244,6 +244,93 @@ const _EFMedia = class _EFMedia2 extends EFTargetable(
|
|
|
244
244
|
});
|
|
245
245
|
this.fftSize = 512;
|
|
246
246
|
this.fftDecay = 8;
|
|
247
|
+
this.#byteTimeDomainCache = new LRUCache(100);
|
|
248
|
+
this.byteTimeDomainTask = new Task(this, {
|
|
249
|
+
autoRun: EF_INTERACTIVE,
|
|
250
|
+
args: () => [
|
|
251
|
+
this.audioBufferTask.status,
|
|
252
|
+
this.currentSourceTimeMs,
|
|
253
|
+
this.fftSize,
|
|
254
|
+
this.fftDecay
|
|
255
|
+
],
|
|
256
|
+
task: async () => {
|
|
257
|
+
await this.audioBufferTask.taskComplete;
|
|
258
|
+
if (!this.audioBufferTask.value) return null;
|
|
259
|
+
if (this.currentSourceTimeMs <= 0) return null;
|
|
260
|
+
const currentTimeMs = this.currentSourceTimeMs;
|
|
261
|
+
const startOffsetMs = this.audioBufferTask.value.startOffsetMs;
|
|
262
|
+
const audioBuffer = this.audioBufferTask.value.buffer;
|
|
263
|
+
const smoothedKey = `${this.fftSize}:${this.fftDecay}:${startOffsetMs}:${currentTimeMs}`;
|
|
264
|
+
const cachedSmoothedData = this.#byteTimeDomainCache.get(smoothedKey);
|
|
265
|
+
if (cachedSmoothedData) {
|
|
266
|
+
return cachedSmoothedData;
|
|
267
|
+
}
|
|
268
|
+
const framesData = await Promise.all(
|
|
269
|
+
Array.from({ length: this.fftDecay }, async (_, i) => {
|
|
270
|
+
const frameOffset = i * (1e3 / 30);
|
|
271
|
+
const startTime = Math.max(
|
|
272
|
+
0,
|
|
273
|
+
(currentTimeMs - frameOffset - startOffsetMs) / 1e3
|
|
274
|
+
);
|
|
275
|
+
const cacheKey = `${this.fftSize}:${startOffsetMs}:${startTime}`;
|
|
276
|
+
const cachedFrame = this.#byteTimeDomainCache.get(cacheKey);
|
|
277
|
+
if (cachedFrame) {
|
|
278
|
+
return cachedFrame;
|
|
279
|
+
}
|
|
280
|
+
const audioContext = new OfflineAudioContext(
|
|
281
|
+
2,
|
|
282
|
+
48e3 * (1 / 30),
|
|
283
|
+
48e3
|
|
284
|
+
);
|
|
285
|
+
const analyser = audioContext.createAnalyser();
|
|
286
|
+
analyser.fftSize = this.fftSize;
|
|
287
|
+
const gainNode = audioContext.createGain();
|
|
288
|
+
gainNode.gain.value = 10;
|
|
289
|
+
analyser.smoothingTimeConstant = 0.4;
|
|
290
|
+
analyser.minDecibels = -90;
|
|
291
|
+
analyser.maxDecibels = -10;
|
|
292
|
+
const audioBufferSource = audioContext.createBufferSource();
|
|
293
|
+
audioBufferSource.buffer = audioBuffer;
|
|
294
|
+
const filter = audioContext.createBiquadFilter();
|
|
295
|
+
filter.type = "bandpass";
|
|
296
|
+
filter.frequency.value = 1e3;
|
|
297
|
+
filter.Q.value = 0.5;
|
|
298
|
+
audioBufferSource.connect(gainNode);
|
|
299
|
+
gainNode.connect(filter);
|
|
300
|
+
filter.connect(analyser);
|
|
301
|
+
analyser.connect(audioContext.destination);
|
|
302
|
+
audioBufferSource.start(0, startTime, 1 / 30);
|
|
303
|
+
try {
|
|
304
|
+
await audioContext.startRendering();
|
|
305
|
+
const frameData = new Uint8Array(analyser.fftSize);
|
|
306
|
+
analyser.getByteTimeDomainData(frameData);
|
|
307
|
+
this.#byteTimeDomainCache.set(cacheKey, frameData);
|
|
308
|
+
return frameData;
|
|
309
|
+
} finally {
|
|
310
|
+
audioBufferSource.disconnect();
|
|
311
|
+
analyser.disconnect();
|
|
312
|
+
}
|
|
313
|
+
})
|
|
314
|
+
);
|
|
315
|
+
const frameLength = framesData[0]?.length ?? 0;
|
|
316
|
+
const smoothedData = new Uint8Array(frameLength);
|
|
317
|
+
for (let i = 0; i < frameLength; i++) {
|
|
318
|
+
let weightedSum = 0;
|
|
319
|
+
let weightSum = 0;
|
|
320
|
+
framesData.forEach((frame, frameIndex) => {
|
|
321
|
+
const decayWeight = _EFMedia2.DECAY_WEIGHT ** frameIndex;
|
|
322
|
+
weightedSum += frame[i] * decayWeight;
|
|
323
|
+
weightSum += decayWeight;
|
|
324
|
+
});
|
|
325
|
+
smoothedData[i] = Math.min(255, Math.round(weightedSum / weightSum));
|
|
326
|
+
}
|
|
327
|
+
this.#byteTimeDomainCache.set(
|
|
328
|
+
smoothedKey,
|
|
329
|
+
smoothedData.slice(0, Math.floor(smoothedData.length * 0.8))
|
|
330
|
+
);
|
|
331
|
+
return smoothedData;
|
|
332
|
+
}
|
|
333
|
+
});
|
|
247
334
|
this.#frequencyDataCache = new LRUCache(100);
|
|
248
335
|
this.frequencyDataTask = new Task(this, {
|
|
249
336
|
autoRun: EF_INTERACTIVE,
|
|
@@ -568,6 +655,7 @@ const _EFMedia = class _EFMedia2 extends EFTargetable(
|
|
|
568
655
|
freqWeightsCache.set(this.fftSize, weights);
|
|
569
656
|
return weights;
|
|
570
657
|
}
|
|
658
|
+
#byteTimeDomainCache;
|
|
571
659
|
#frequencyDataCache;
|
|
572
660
|
};
|
|
573
661
|
__decorateClass([
|
|
@@ -13,7 +13,7 @@ export declare class EFWaveform extends EFWaveform_base {
|
|
|
13
13
|
private resizeObserver?;
|
|
14
14
|
private mutationObserver?;
|
|
15
15
|
render(): import('lit-html').TemplateResult<1>;
|
|
16
|
-
mode: "roundBars" | "bars" | "bricks" | "line" | "pixel" | "wave" | "spikes";
|
|
16
|
+
mode: "roundBars" | "bars" | "bricks" | "line" | "curve" | "pixel" | "wave" | "spikes";
|
|
17
17
|
color: string;
|
|
18
18
|
target: string;
|
|
19
19
|
targetElement: EFAudio | EFVideo | null;
|
|
@@ -28,6 +28,7 @@ export declare class EFWaveform extends EFWaveform_base {
|
|
|
28
28
|
protected drawRoundBars(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array): void;
|
|
29
29
|
protected drawEqualizer(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array): void;
|
|
30
30
|
protected drawLine(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array): void;
|
|
31
|
+
protected drawCurve(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array): void;
|
|
31
32
|
protected drawPixel(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array): void;
|
|
32
33
|
protected drawWave(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array): void;
|
|
33
34
|
protected drawSpikes(ctx: CanvasRenderingContext2D, frequencyData: Uint8Array): void;
|
|
@@ -46,7 +46,8 @@ let EFWaveform = class extends EFTemporal(TWMixin(LitElement)) {
|
|
|
46
46
|
const ctx = this.ctx;
|
|
47
47
|
if (!ctx) return;
|
|
48
48
|
const frequencyData = this.targetElement.frequencyDataTask.value;
|
|
49
|
-
|
|
49
|
+
const byteTimeData = this.targetElement.byteTimeDomainTask.value;
|
|
50
|
+
if (!frequencyData || !byteTimeData) return;
|
|
50
51
|
ctx.save();
|
|
51
52
|
if (this.color === "currentColor") {
|
|
52
53
|
const computedStyle = getComputedStyle(this);
|
|
@@ -65,7 +66,10 @@ let EFWaveform = class extends EFTemporal(TWMixin(LitElement)) {
|
|
|
65
66
|
this.drawBricks(ctx, frequencyData);
|
|
66
67
|
break;
|
|
67
68
|
case "line":
|
|
68
|
-
this.drawLine(ctx,
|
|
69
|
+
this.drawLine(ctx, byteTimeData);
|
|
70
|
+
break;
|
|
71
|
+
case "curve":
|
|
72
|
+
this.drawCurve(ctx, byteTimeData);
|
|
69
73
|
break;
|
|
70
74
|
case "pixel":
|
|
71
75
|
this.drawPixel(ctx, frequencyData);
|
|
@@ -226,6 +230,28 @@ let EFWaveform = class extends EFTemporal(TWMixin(LitElement)) {
|
|
|
226
230
|
ctx.fill(barsPath);
|
|
227
231
|
}
|
|
228
232
|
drawLine(ctx, frequencyData) {
|
|
233
|
+
const canvas = ctx.canvas;
|
|
234
|
+
const waveWidth = canvas.width;
|
|
235
|
+
const waveHeight = canvas.height;
|
|
236
|
+
ctx.clearRect(0, 0, waveWidth, waveHeight);
|
|
237
|
+
const path = new Path2D();
|
|
238
|
+
const sampleRate = 4;
|
|
239
|
+
for (let i = 0; i < frequencyData.length; i += sampleRate) {
|
|
240
|
+
const x = i / frequencyData.length * waveWidth;
|
|
241
|
+
const y = (1 - (frequencyData[i] ?? 0) / 255) * waveHeight;
|
|
242
|
+
if (i === 0) {
|
|
243
|
+
path.moveTo(x, y);
|
|
244
|
+
} else {
|
|
245
|
+
path.lineTo(x, y);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const lastX = waveWidth;
|
|
249
|
+
const lastY = (1 - (frequencyData[frequencyData.length - 1] ?? 0) / 255) * waveHeight;
|
|
250
|
+
path.lineTo(lastX, lastY);
|
|
251
|
+
ctx.lineWidth = this.lineWidth;
|
|
252
|
+
ctx.stroke(path);
|
|
253
|
+
}
|
|
254
|
+
drawCurve(ctx, frequencyData) {
|
|
229
255
|
const canvas = ctx.canvas;
|
|
230
256
|
const waveWidth = canvas.width;
|
|
231
257
|
const waveHeight = canvas.height;
|
|
@@ -237,7 +263,11 @@ let EFWaveform = class extends EFTemporal(TWMixin(LitElement)) {
|
|
|
237
263
|
if (i === 0) {
|
|
238
264
|
path.moveTo(x, y);
|
|
239
265
|
} else {
|
|
240
|
-
|
|
266
|
+
const prevX = (i - 1) / frequencyData.length * waveWidth;
|
|
267
|
+
const prevY = (1 - (frequencyData[i - 1] ?? 0) / 255) * waveHeight;
|
|
268
|
+
const xc = (prevX + x) / 2;
|
|
269
|
+
const yc = (prevY + y) / 2;
|
|
270
|
+
path.quadraticCurveTo(prevX, prevY, xc, yc);
|
|
241
271
|
}
|
|
242
272
|
});
|
|
243
273
|
ctx.lineWidth = this.lineWidth;
|
package/dist/gui/TWMixin.css.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const twStyle = "/*\n! tailwindcss v3.4.4 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n7. Disable tap highlights on iOS\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font-family by default.\n2. Use the user's configured `mono` font-feature-settings by default.\n3. Use the user's configured `mono` font-variation-settings by default.\n4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-feature-settings: normal; /* 2 */\n font-variation-settings: normal; /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\ninput:where([type='button']),\ninput:where([type='reset']),\ninput:where([type='submit']) {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nReset default styling for dialogs.\n*/\ndialog {\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 640px) {\n\n .container {\n max-width: 640px;\n }\n}\n@media (min-width: 768px) {\n\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n\n .container {\n max-width: 1536px;\n }\n}\n.pointer-events-none {\n pointer-events: none;\n}\n.static {\n position: static;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.inset-0 {\n inset: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-10 {\n z-index: 10;\n}\n.z-20 {\n z-index: 20;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.mx-2 {\n margin-left: 0.5rem;\n margin-right: 0.5rem;\n}\n.mb-\\[1px\\] {\n margin-bottom: 1px;\n}\n.block {\n display: block;\n}\n.inline-block {\n display: inline-block;\n}\n.inline {\n display: inline;\n}\n.flex {\n display: flex;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-\\[1\\.1rem\\] {\n height: 1.1rem;\n}\n.h-\\[5px\\] {\n height: 5px;\n}\n.h-full {\n height: 100%;\n}\n.w-1 {\n width: 0.25rem;\n}\n.w-\\[2px\\] {\n width: 2px;\n}\n.w-full {\n width: 100%;\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-crosshair {\n cursor: crosshair;\n}\n.resize {\n resize: both;\n}\n.flex-wrap {\n flex-wrap: wrap;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.border {\n border-width: 1px;\n}\n.border-r-2 {\n border-right-width: 2px;\n}\n.border-blue-500 {\n --tw-border-opacity: 1;\n border-color: rgb(59 130 246 / var(--tw-border-opacity));\n}\n.border-red-700 {\n --tw-border-opacity: 1;\n border-color: rgb(185 28 28 / var(--tw-border-opacity));\n}\n.border-slate-500 {\n --tw-border-opacity: 1;\n border-color: rgb(100 116 139 / var(--tw-border-opacity));\n}\n.border-b-slate-600 {\n --tw-border-opacity: 1;\n border-bottom-color: rgb(71 85 105 / var(--tw-border-opacity));\n}\n.bg-blue-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(191 219 254 / var(--tw-bg-opacity));\n}\n.bg-blue-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(59 130 246 / var(--tw-bg-opacity));\n}\n.bg-red-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(239 68 68 / var(--tw-bg-opacity));\n}\n.bg-slate-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(241 245 249 / var(--tw-bg-opacity));\n}\n.bg-slate-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(226 232 240 / var(--tw-bg-opacity));\n}\n.bg-slate-300 {\n --tw-bg-opacity: 1;\n background-color: rgb(203 213 225 / var(--tw-bg-opacity));\n}\n.bg-slate-800 {\n --tw-bg-opacity: 1;\n background-color: rgb(30 41 59 / var(--tw-bg-opacity));\n}\n.bg-opacity-20 {\n --tw-bg-opacity: 0.2;\n}\n.p-\\[1px\\] {\n padding: 1px;\n}\n.pb-0 {\n padding-bottom: 0px;\n}\n.pl-1 {\n padding-left: 0.25rem;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pr-0 {\n padding-right: 0px;\n}\n.pr-1 {\n padding-right: 0.25rem;\n}\n.pt-\\[8px\\] {\n padding-top: 8px;\n}\n.font-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.line-through {\n text-decoration-line: line-through;\n}\n.opacity-50 {\n opacity: 0.5;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-slate-300 {\n --tw-shadow-color: #cbd5e1;\n --tw-shadow: var(--tw-shadow-colored);\n}\n.shadow-slate-600 {\n --tw-shadow-color: #475569;\n --tw-shadow: var(--tw-shadow-colored);\n}\n.outline {\n outline-style: solid;\n}\n.filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n.hover\\:bg-slate-400:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(148 163 184 / var(--tw-bg-opacity));\n}\n.peer:hover ~ .peer-hover\\:border-slate-400 {\n --tw-border-opacity: 1;\n border-color: rgb(148 163 184 / var(--tw-border-opacity));\n}\n.peer:hover ~ .peer-hover\\:bg-slate-300 {\n --tw-bg-opacity: 1;\n background-color: rgb(203 213 225 / var(--tw-bg-opacity));\n}\n.data-\\[focused\\]\\:bg-slate-400[data-focused] {\n --tw-bg-opacity: 1;\n background-color: rgb(148 163 184 / var(--tw-bg-opacity));\n}\n.peer[data-focused] ~ .peer-data-\\[focused\\]\\:border-slate-400 {\n --tw-border-opacity: 1;\n border-color: rgb(148 163 184 / var(--tw-border-opacity));\n}\n.peer[data-focused] ~ .peer-data-\\[focused\\]\\:bg-slate-300 {\n --tw-bg-opacity: 1;\n background-color: rgb(203 213 225 / var(--tw-bg-opacity));\n}\n";
|
|
1
|
+
const twStyle = "/*\n! tailwindcss v3.4.4 | MIT License | https://tailwindcss.com\n*//*\n1. Prevent padding and border from affecting element width. (https://github.com/mozdevs/cssremedy/issues/4)\n2. Allow adding a border to an element by just adding a border-width. (https://github.com/tailwindcss/tailwindcss/pull/116)\n*/\n\n*,\n::before,\n::after {\n box-sizing: border-box; /* 1 */\n border-width: 0; /* 2 */\n border-style: solid; /* 2 */\n border-color: #e5e7eb; /* 2 */\n}\n\n::before,\n::after {\n --tw-content: '';\n}\n\n/*\n1. Use a consistent sensible line-height in all browsers.\n2. Prevent adjustments of font size after orientation changes in iOS.\n3. Use a more readable tab size.\n4. Use the user's configured `sans` font-family by default.\n5. Use the user's configured `sans` font-feature-settings by default.\n6. Use the user's configured `sans` font-variation-settings by default.\n7. Disable tap highlights on iOS\n*/\n\nhtml,\n:host {\n line-height: 1.5; /* 1 */\n -webkit-text-size-adjust: 100%; /* 2 */\n -moz-tab-size: 4; /* 3 */\n -o-tab-size: 4;\n tab-size: 4; /* 3 */\n font-family: ui-sans-serif, system-ui, sans-serif, \"Apple Color Emoji\", \"Segoe UI Emoji\", \"Segoe UI Symbol\", \"Noto Color Emoji\"; /* 4 */\n font-feature-settings: normal; /* 5 */\n font-variation-settings: normal; /* 6 */\n -webkit-tap-highlight-color: transparent; /* 7 */\n}\n\n/*\n1. Remove the margin in all browsers.\n2. Inherit line-height from `html` so users can set them as a class directly on the `html` element.\n*/\n\nbody {\n margin: 0; /* 1 */\n line-height: inherit; /* 2 */\n}\n\n/*\n1. Add the correct height in Firefox.\n2. Correct the inheritance of border color in Firefox. (https://bugzilla.mozilla.org/show_bug.cgi?id=190655)\n3. Ensure horizontal rules are visible by default.\n*/\n\nhr {\n height: 0; /* 1 */\n color: inherit; /* 2 */\n border-top-width: 1px; /* 3 */\n}\n\n/*\nAdd the correct text decoration in Chrome, Edge, and Safari.\n*/\n\nabbr:where([title]) {\n -webkit-text-decoration: underline dotted;\n text-decoration: underline dotted;\n}\n\n/*\nRemove the default font size and weight for headings.\n*/\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-size: inherit;\n font-weight: inherit;\n}\n\n/*\nReset links to optimize for opt-in styling instead of opt-out.\n*/\n\na {\n color: inherit;\n text-decoration: inherit;\n}\n\n/*\nAdd the correct font weight in Edge and Safari.\n*/\n\nb,\nstrong {\n font-weight: bolder;\n}\n\n/*\n1. Use the user's configured `mono` font-family by default.\n2. Use the user's configured `mono` font-feature-settings by default.\n3. Use the user's configured `mono` font-variation-settings by default.\n4. Correct the odd `em` font sizing in all browsers.\n*/\n\ncode,\nkbd,\nsamp,\npre {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace; /* 1 */\n font-feature-settings: normal; /* 2 */\n font-variation-settings: normal; /* 3 */\n font-size: 1em; /* 4 */\n}\n\n/*\nAdd the correct font size in all browsers.\n*/\n\nsmall {\n font-size: 80%;\n}\n\n/*\nPrevent `sub` and `sup` elements from affecting the line height in all browsers.\n*/\n\nsub,\nsup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n}\n\nsub {\n bottom: -0.25em;\n}\n\nsup {\n top: -0.5em;\n}\n\n/*\n1. Remove text indentation from table contents in Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=999088, https://bugs.webkit.org/show_bug.cgi?id=201297)\n2. Correct table border color inheritance in all Chrome and Safari. (https://bugs.chromium.org/p/chromium/issues/detail?id=935729, https://bugs.webkit.org/show_bug.cgi?id=195016)\n3. Remove gaps between table borders by default.\n*/\n\ntable {\n text-indent: 0; /* 1 */\n border-color: inherit; /* 2 */\n border-collapse: collapse; /* 3 */\n}\n\n/*\n1. Change the font styles in all browsers.\n2. Remove the margin in Firefox and Safari.\n3. Remove default padding in all browsers.\n*/\n\nbutton,\ninput,\noptgroup,\nselect,\ntextarea {\n font-family: inherit; /* 1 */\n font-feature-settings: inherit; /* 1 */\n font-variation-settings: inherit; /* 1 */\n font-size: 100%; /* 1 */\n font-weight: inherit; /* 1 */\n line-height: inherit; /* 1 */\n letter-spacing: inherit; /* 1 */\n color: inherit; /* 1 */\n margin: 0; /* 2 */\n padding: 0; /* 3 */\n}\n\n/*\nRemove the inheritance of text transform in Edge and Firefox.\n*/\n\nbutton,\nselect {\n text-transform: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Remove default button styles.\n*/\n\nbutton,\ninput:where([type='button']),\ninput:where([type='reset']),\ninput:where([type='submit']) {\n -webkit-appearance: button; /* 1 */\n background-color: transparent; /* 2 */\n background-image: none; /* 2 */\n}\n\n/*\nUse the modern Firefox focus style for all focusable elements.\n*/\n\n:-moz-focusring {\n outline: auto;\n}\n\n/*\nRemove the additional `:invalid` styles in Firefox. (https://github.com/mozilla/gecko-dev/blob/2f9eacd9d3d995c937b4251a5557d95d494c9be1/layout/style/res/forms.css#L728-L737)\n*/\n\n:-moz-ui-invalid {\n box-shadow: none;\n}\n\n/*\nAdd the correct vertical alignment in Chrome and Firefox.\n*/\n\nprogress {\n vertical-align: baseline;\n}\n\n/*\nCorrect the cursor style of increment and decrement buttons in Safari.\n*/\n\n::-webkit-inner-spin-button,\n::-webkit-outer-spin-button {\n height: auto;\n}\n\n/*\n1. Correct the odd appearance in Chrome and Safari.\n2. Correct the outline style in Safari.\n*/\n\n[type='search'] {\n -webkit-appearance: textfield; /* 1 */\n outline-offset: -2px; /* 2 */\n}\n\n/*\nRemove the inner padding in Chrome and Safari on macOS.\n*/\n\n::-webkit-search-decoration {\n -webkit-appearance: none;\n}\n\n/*\n1. Correct the inability to style clickable types in iOS and Safari.\n2. Change font properties to `inherit` in Safari.\n*/\n\n::-webkit-file-upload-button {\n -webkit-appearance: button; /* 1 */\n font: inherit; /* 2 */\n}\n\n/*\nAdd the correct display in Chrome and Safari.\n*/\n\nsummary {\n display: list-item;\n}\n\n/*\nRemoves the default spacing and border for appropriate elements.\n*/\n\nblockquote,\ndl,\ndd,\nh1,\nh2,\nh3,\nh4,\nh5,\nh6,\nhr,\nfigure,\np,\npre {\n margin: 0;\n}\n\nfieldset {\n margin: 0;\n padding: 0;\n}\n\nlegend {\n padding: 0;\n}\n\nol,\nul,\nmenu {\n list-style: none;\n margin: 0;\n padding: 0;\n}\n\n/*\nReset default styling for dialogs.\n*/\ndialog {\n padding: 0;\n}\n\n/*\nPrevent resizing textareas horizontally by default.\n*/\n\ntextarea {\n resize: vertical;\n}\n\n/*\n1. Reset the default placeholder opacity in Firefox. (https://github.com/tailwindlabs/tailwindcss/issues/3300)\n2. Set the default placeholder color to the user's configured gray 400 color.\n*/\n\ninput::-moz-placeholder, textarea::-moz-placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\ninput::placeholder,\ntextarea::placeholder {\n opacity: 1; /* 1 */\n color: #9ca3af; /* 2 */\n}\n\n/*\nSet the default cursor for buttons.\n*/\n\nbutton,\n[role=\"button\"] {\n cursor: pointer;\n}\n\n/*\nMake sure disabled buttons don't get the pointer cursor.\n*/\n:disabled {\n cursor: default;\n}\n\n/*\n1. Make replaced elements `display: block` by default. (https://github.com/mozdevs/cssremedy/issues/14)\n2. Add `vertical-align: middle` to align replaced elements more sensibly by default. (https://github.com/jensimmons/cssremedy/issues/14#issuecomment-634934210)\n This can trigger a poorly considered lint error in some tools but is included by design.\n*/\n\nimg,\nsvg,\nvideo,\ncanvas,\naudio,\niframe,\nembed,\nobject {\n display: block; /* 1 */\n vertical-align: middle; /* 2 */\n}\n\n/*\nConstrain images and videos to the parent width and preserve their intrinsic aspect ratio. (https://github.com/mozdevs/cssremedy/issues/14)\n*/\n\nimg,\nvideo {\n max-width: 100%;\n height: auto;\n}\n\n/* Make elements with the HTML hidden attribute stay hidden by default */\n[hidden] {\n display: none;\n}\n\n*, ::before, ::after {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n\n::backdrop {\n --tw-border-spacing-x: 0;\n --tw-border-spacing-y: 0;\n --tw-translate-x: 0;\n --tw-translate-y: 0;\n --tw-rotate: 0;\n --tw-skew-x: 0;\n --tw-skew-y: 0;\n --tw-scale-x: 1;\n --tw-scale-y: 1;\n --tw-pan-x: ;\n --tw-pan-y: ;\n --tw-pinch-zoom: ;\n --tw-scroll-snap-strictness: proximity;\n --tw-gradient-from-position: ;\n --tw-gradient-via-position: ;\n --tw-gradient-to-position: ;\n --tw-ordinal: ;\n --tw-slashed-zero: ;\n --tw-numeric-figure: ;\n --tw-numeric-spacing: ;\n --tw-numeric-fraction: ;\n --tw-ring-inset: ;\n --tw-ring-offset-width: 0px;\n --tw-ring-offset-color: #fff;\n --tw-ring-color: rgb(59 130 246 / 0.5);\n --tw-ring-offset-shadow: 0 0 #0000;\n --tw-ring-shadow: 0 0 #0000;\n --tw-shadow: 0 0 #0000;\n --tw-shadow-colored: 0 0 #0000;\n --tw-blur: ;\n --tw-brightness: ;\n --tw-contrast: ;\n --tw-grayscale: ;\n --tw-hue-rotate: ;\n --tw-invert: ;\n --tw-saturate: ;\n --tw-sepia: ;\n --tw-drop-shadow: ;\n --tw-backdrop-blur: ;\n --tw-backdrop-brightness: ;\n --tw-backdrop-contrast: ;\n --tw-backdrop-grayscale: ;\n --tw-backdrop-hue-rotate: ;\n --tw-backdrop-invert: ;\n --tw-backdrop-opacity: ;\n --tw-backdrop-saturate: ;\n --tw-backdrop-sepia: ;\n --tw-contain-size: ;\n --tw-contain-layout: ;\n --tw-contain-paint: ;\n --tw-contain-style: ;\n}\n.container {\n width: 100%;\n}\n@media (min-width: 640px) {\n\n .container {\n max-width: 640px;\n }\n}\n@media (min-width: 768px) {\n\n .container {\n max-width: 768px;\n }\n}\n@media (min-width: 1024px) {\n\n .container {\n max-width: 1024px;\n }\n}\n@media (min-width: 1280px) {\n\n .container {\n max-width: 1280px;\n }\n}\n@media (min-width: 1536px) {\n\n .container {\n max-width: 1536px;\n }\n}\n.pointer-events-none {\n pointer-events: none;\n}\n.visible {\n visibility: visible;\n}\n.static {\n position: static;\n}\n.fixed {\n position: fixed;\n}\n.absolute {\n position: absolute;\n}\n.relative {\n position: relative;\n}\n.inset-0 {\n inset: 0px;\n}\n.top-0 {\n top: 0px;\n}\n.z-10 {\n z-index: 10;\n}\n.z-20 {\n z-index: 20;\n}\n.col-span-2 {\n grid-column: span 2 / span 2;\n}\n.mx-2 {\n margin-left: 0.5rem;\n margin-right: 0.5rem;\n}\n.mb-\\[1px\\] {\n margin-bottom: 1px;\n}\n.block {\n display: block;\n}\n.inline-block {\n display: inline-block;\n}\n.inline {\n display: inline;\n}\n.flex {\n display: flex;\n}\n.grid {\n display: grid;\n}\n.contents {\n display: contents;\n}\n.hidden {\n display: none;\n}\n.h-\\[1\\.1rem\\] {\n height: 1.1rem;\n}\n.h-\\[5px\\] {\n height: 5px;\n}\n.h-full {\n height: 100%;\n}\n.w-1 {\n width: 0.25rem;\n}\n.w-\\[2px\\] {\n width: 2px;\n}\n.w-full {\n width: 100%;\n}\n.transform {\n transform: translate(var(--tw-translate-x), var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y));\n}\n.cursor-crosshair {\n cursor: crosshair;\n}\n.resize {\n resize: both;\n}\n.flex-wrap {\n flex-wrap: wrap;\n}\n.items-center {\n align-items: center;\n}\n.justify-center {\n justify-content: center;\n}\n.overflow-auto {\n overflow: auto;\n}\n.overflow-hidden {\n overflow: hidden;\n}\n.text-nowrap {\n text-wrap: nowrap;\n}\n.rounded {\n border-radius: 0.25rem;\n}\n.border {\n border-width: 1px;\n}\n.border-r-2 {\n border-right-width: 2px;\n}\n.border-blue-500 {\n --tw-border-opacity: 1;\n border-color: rgb(59 130 246 / var(--tw-border-opacity));\n}\n.border-red-700 {\n --tw-border-opacity: 1;\n border-color: rgb(185 28 28 / var(--tw-border-opacity));\n}\n.border-slate-500 {\n --tw-border-opacity: 1;\n border-color: rgb(100 116 139 / var(--tw-border-opacity));\n}\n.border-b-slate-600 {\n --tw-border-opacity: 1;\n border-bottom-color: rgb(71 85 105 / var(--tw-border-opacity));\n}\n.bg-blue-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(191 219 254 / var(--tw-bg-opacity));\n}\n.bg-blue-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(59 130 246 / var(--tw-bg-opacity));\n}\n.bg-red-500 {\n --tw-bg-opacity: 1;\n background-color: rgb(239 68 68 / var(--tw-bg-opacity));\n}\n.bg-slate-100 {\n --tw-bg-opacity: 1;\n background-color: rgb(241 245 249 / var(--tw-bg-opacity));\n}\n.bg-slate-200 {\n --tw-bg-opacity: 1;\n background-color: rgb(226 232 240 / var(--tw-bg-opacity));\n}\n.bg-slate-300 {\n --tw-bg-opacity: 1;\n background-color: rgb(203 213 225 / var(--tw-bg-opacity));\n}\n.bg-slate-800 {\n --tw-bg-opacity: 1;\n background-color: rgb(30 41 59 / var(--tw-bg-opacity));\n}\n.bg-opacity-20 {\n --tw-bg-opacity: 0.2;\n}\n.p-\\[1px\\] {\n padding: 1px;\n}\n.pb-0 {\n padding-bottom: 0px;\n}\n.pl-1 {\n padding-left: 0.25rem;\n}\n.pl-2 {\n padding-left: 0.5rem;\n}\n.pr-0 {\n padding-right: 0px;\n}\n.pr-1 {\n padding-right: 0.25rem;\n}\n.pt-\\[8px\\] {\n padding-top: 8px;\n}\n.font-mono {\n font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace;\n}\n.text-sm {\n font-size: 0.875rem;\n line-height: 1.25rem;\n}\n.text-xs {\n font-size: 0.75rem;\n line-height: 1rem;\n}\n.line-through {\n text-decoration-line: line-through;\n}\n.opacity-50 {\n opacity: 0.5;\n}\n.shadow {\n --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);\n --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color);\n box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);\n}\n.shadow-slate-300 {\n --tw-shadow-color: #cbd5e1;\n --tw-shadow: var(--tw-shadow-colored);\n}\n.shadow-slate-600 {\n --tw-shadow-color: #475569;\n --tw-shadow: var(--tw-shadow-colored);\n}\n.outline {\n outline-style: solid;\n}\n.filter {\n filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);\n}\n.hover\\:bg-slate-400:hover {\n --tw-bg-opacity: 1;\n background-color: rgb(148 163 184 / var(--tw-bg-opacity));\n}\n.peer:hover ~ .peer-hover\\:border-slate-400 {\n --tw-border-opacity: 1;\n border-color: rgb(148 163 184 / var(--tw-border-opacity));\n}\n.peer:hover ~ .peer-hover\\:bg-slate-300 {\n --tw-bg-opacity: 1;\n background-color: rgb(203 213 225 / var(--tw-bg-opacity));\n}\n.data-\\[focused\\]\\:bg-slate-400[data-focused] {\n --tw-bg-opacity: 1;\n background-color: rgb(148 163 184 / var(--tw-bg-opacity));\n}\n.peer[data-focused] ~ .peer-data-\\[focused\\]\\:border-slate-400 {\n --tw-border-opacity: 1;\n border-color: rgb(148 163 184 / var(--tw-border-opacity));\n}\n.peer[data-focused] ~ .peer-data-\\[focused\\]\\:bg-slate-300 {\n --tw-bg-opacity: 1;\n background-color: rgb(203 213 225 / var(--tw-bg-opacity));\n}\n";
|
|
2
2
|
export {
|
|
3
3
|
twStyle as default
|
|
4
4
|
};
|
package/dist/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editframe/elements",
|
|
3
|
-
"version": "0.15.0-beta.
|
|
3
|
+
"version": "0.15.0-beta.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
}
|
|
11
11
|
},
|
|
12
12
|
"./styles.css": "./dist/style.css",
|
|
13
|
-
"./types.json":
|
|
13
|
+
"./types.json": {
|
|
14
|
+
"import": {
|
|
15
|
+
"default": "./types.json"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
14
18
|
},
|
|
15
19
|
"type": "module",
|
|
16
20
|
"scripts": {
|
|
@@ -23,7 +27,7 @@
|
|
|
23
27
|
"license": "UNLICENSED",
|
|
24
28
|
"dependencies": {
|
|
25
29
|
"@bramus/style-observer": "^1.3.0",
|
|
26
|
-
"@editframe/assets": "0.15.0-beta.
|
|
30
|
+
"@editframe/assets": "0.15.0-beta.9",
|
|
27
31
|
"@lit/context": "^1.1.2",
|
|
28
32
|
"@lit/task": "^1.0.1",
|
|
29
33
|
"d3": "^7.9.0",
|
package/src/elements/EFMedia.ts
CHANGED
|
@@ -616,6 +616,123 @@ export class EFMedia extends EFTargetable(
|
|
|
616
616
|
return weights;
|
|
617
617
|
}
|
|
618
618
|
|
|
619
|
+
#byteTimeDomainCache = new LRUCache<string, Uint8Array>(100);
|
|
620
|
+
|
|
621
|
+
byteTimeDomainTask = new Task(this, {
|
|
622
|
+
autoRun: EF_INTERACTIVE,
|
|
623
|
+
args: () =>
|
|
624
|
+
[
|
|
625
|
+
this.audioBufferTask.status,
|
|
626
|
+
this.currentSourceTimeMs,
|
|
627
|
+
this.fftSize,
|
|
628
|
+
this.fftDecay,
|
|
629
|
+
] as const,
|
|
630
|
+
task: async () => {
|
|
631
|
+
await this.audioBufferTask.taskComplete;
|
|
632
|
+
if (!this.audioBufferTask.value) return null;
|
|
633
|
+
if (this.currentSourceTimeMs <= 0) return null;
|
|
634
|
+
|
|
635
|
+
const currentTimeMs = this.currentSourceTimeMs;
|
|
636
|
+
const startOffsetMs = this.audioBufferTask.value.startOffsetMs;
|
|
637
|
+
const audioBuffer = this.audioBufferTask.value.buffer;
|
|
638
|
+
const smoothedKey = `${this.fftSize}:${this.fftDecay}:${startOffsetMs}:${currentTimeMs}`;
|
|
639
|
+
|
|
640
|
+
const cachedSmoothedData = this.#byteTimeDomainCache.get(smoothedKey);
|
|
641
|
+
if (cachedSmoothedData) {
|
|
642
|
+
return cachedSmoothedData;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const framesData = await Promise.all(
|
|
646
|
+
Array.from({ length: this.fftDecay }, async (_, i) => {
|
|
647
|
+
const frameOffset = i * (1000 / 30);
|
|
648
|
+
const startTime = Math.max(
|
|
649
|
+
0,
|
|
650
|
+
(currentTimeMs - frameOffset - startOffsetMs) / 1000,
|
|
651
|
+
);
|
|
652
|
+
|
|
653
|
+
const cacheKey = `${this.fftSize}:${startOffsetMs}:${startTime}`;
|
|
654
|
+
const cachedFrame = this.#byteTimeDomainCache.get(cacheKey);
|
|
655
|
+
if (cachedFrame) {
|
|
656
|
+
return cachedFrame;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
const audioContext = new OfflineAudioContext(
|
|
660
|
+
2,
|
|
661
|
+
48000 * (1 / 30),
|
|
662
|
+
48000,
|
|
663
|
+
);
|
|
664
|
+
const analyser = audioContext.createAnalyser();
|
|
665
|
+
analyser.fftSize = this.fftSize;
|
|
666
|
+
|
|
667
|
+
// Increase gain even more for better signal
|
|
668
|
+
const gainNode = audioContext.createGain();
|
|
669
|
+
gainNode.gain.value = 10.0; // Try a higher gain
|
|
670
|
+
|
|
671
|
+
// More aggressive settings for the analyzer
|
|
672
|
+
analyser.smoothingTimeConstant = 0.4;
|
|
673
|
+
analyser.minDecibels = -90;
|
|
674
|
+
analyser.maxDecibels = -10;
|
|
675
|
+
|
|
676
|
+
const audioBufferSource = audioContext.createBufferSource();
|
|
677
|
+
audioBufferSource.buffer = audioBuffer;
|
|
678
|
+
|
|
679
|
+
// Add a bandpass filter to focus on the most active frequency ranges
|
|
680
|
+
const filter = audioContext.createBiquadFilter();
|
|
681
|
+
filter.type = "bandpass";
|
|
682
|
+
filter.frequency.value = 1000; // Center frequency in Hz
|
|
683
|
+
filter.Q.value = 0.5; // Width of the band
|
|
684
|
+
|
|
685
|
+
audioBufferSource.connect(gainNode);
|
|
686
|
+
gainNode.connect(filter);
|
|
687
|
+
filter.connect(analyser);
|
|
688
|
+
analyser.connect(audioContext.destination);
|
|
689
|
+
|
|
690
|
+
audioBufferSource.start(0, startTime, 1 / 30);
|
|
691
|
+
|
|
692
|
+
try {
|
|
693
|
+
await audioContext.startRendering();
|
|
694
|
+
// Change to time domain data
|
|
695
|
+
const frameData = new Uint8Array(analyser.fftSize);
|
|
696
|
+
analyser.getByteTimeDomainData(frameData);
|
|
697
|
+
|
|
698
|
+
this.#byteTimeDomainCache.set(cacheKey, frameData);
|
|
699
|
+
return frameData;
|
|
700
|
+
} finally {
|
|
701
|
+
audioBufferSource.disconnect();
|
|
702
|
+
analyser.disconnect();
|
|
703
|
+
}
|
|
704
|
+
}),
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
const frameLength = framesData[0]?.length ?? 0;
|
|
708
|
+
const smoothedData = new Uint8Array(frameLength);
|
|
709
|
+
|
|
710
|
+
// Combine frames with decay
|
|
711
|
+
for (let i = 0; i < frameLength; i++) {
|
|
712
|
+
let weightedSum = 0;
|
|
713
|
+
let weightSum = 0;
|
|
714
|
+
|
|
715
|
+
framesData.forEach((frame, frameIndex) => {
|
|
716
|
+
const decayWeight = EFMedia.DECAY_WEIGHT ** frameIndex;
|
|
717
|
+
// biome-ignore lint/style/noNonNullAssertion: Will exist due to forEach
|
|
718
|
+
weightedSum += frame[i]! * decayWeight;
|
|
719
|
+
weightSum += decayWeight;
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
smoothedData[i] = Math.min(255, Math.round(weightedSum / weightSum));
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
// Remove frequency weighting since we're using time domain data
|
|
726
|
+
// No need to slice the data either since we want the full waveform
|
|
727
|
+
|
|
728
|
+
this.#byteTimeDomainCache.set(
|
|
729
|
+
smoothedKey,
|
|
730
|
+
smoothedData.slice(0, Math.floor(smoothedData.length * 0.8)),
|
|
731
|
+
);
|
|
732
|
+
return smoothedData;
|
|
733
|
+
},
|
|
734
|
+
});
|
|
735
|
+
|
|
619
736
|
#frequencyDataCache = new LRUCache<string, Uint8Array>(100);
|
|
620
737
|
|
|
621
738
|
frequencyDataTask = new Task(this, {
|
|
@@ -45,8 +45,15 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
45
45
|
type: String,
|
|
46
46
|
attribute: "mode",
|
|
47
47
|
})
|
|
48
|
-
mode:
|
|
49
|
-
"
|
|
48
|
+
mode:
|
|
49
|
+
| "roundBars"
|
|
50
|
+
| "bars"
|
|
51
|
+
| "bricks"
|
|
52
|
+
| "line"
|
|
53
|
+
| "curve"
|
|
54
|
+
| "pixel"
|
|
55
|
+
| "wave"
|
|
56
|
+
| "spikes" = "bars";
|
|
50
57
|
|
|
51
58
|
@property({ type: String })
|
|
52
59
|
color = "currentColor";
|
|
@@ -273,10 +280,44 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
273
280
|
const waveHeight = canvas.height;
|
|
274
281
|
|
|
275
282
|
ctx.clearRect(0, 0, waveWidth, waveHeight);
|
|
283
|
+
const path = new Path2D();
|
|
284
|
+
|
|
285
|
+
// Sample fewer points to make sharp angles more visible
|
|
286
|
+
const sampleRate = 4; // Only use every 4th point
|
|
287
|
+
|
|
288
|
+
for (let i = 0; i < frequencyData.length; i += sampleRate) {
|
|
289
|
+
const x = (i / frequencyData.length) * waveWidth;
|
|
290
|
+
const y = (1 - (frequencyData[i] ?? 0) / 255) * waveHeight;
|
|
276
291
|
|
|
277
|
-
|
|
292
|
+
if (i === 0) {
|
|
293
|
+
path.moveTo(x, y);
|
|
294
|
+
} else {
|
|
295
|
+
path.lineTo(x, y);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Ensure we draw to the end
|
|
300
|
+
const lastX = waveWidth;
|
|
301
|
+
const lastY =
|
|
302
|
+
(1 - (frequencyData[frequencyData.length - 1] ?? 0) / 255) * waveHeight;
|
|
303
|
+
path.lineTo(lastX, lastY);
|
|
304
|
+
|
|
305
|
+
ctx.lineWidth = this.lineWidth;
|
|
306
|
+
ctx.stroke(path);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
protected drawCurve(
|
|
310
|
+
ctx: CanvasRenderingContext2D,
|
|
311
|
+
frequencyData: Uint8Array,
|
|
312
|
+
) {
|
|
313
|
+
const canvas = ctx.canvas;
|
|
314
|
+
const waveWidth = canvas.width;
|
|
315
|
+
const waveHeight = canvas.height;
|
|
316
|
+
|
|
317
|
+
ctx.clearRect(0, 0, waveWidth, waveHeight);
|
|
278
318
|
const path = new Path2D();
|
|
279
319
|
|
|
320
|
+
// Draw smooth curves between points using quadratic curves
|
|
280
321
|
frequencyData.forEach((value, i) => {
|
|
281
322
|
const x = (i / frequencyData.length) * waveWidth;
|
|
282
323
|
const y = (1 - value / 255) * waveHeight;
|
|
@@ -284,7 +325,11 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
284
325
|
if (i === 0) {
|
|
285
326
|
path.moveTo(x, y);
|
|
286
327
|
} else {
|
|
287
|
-
|
|
328
|
+
const prevX = ((i - 1) / frequencyData.length) * waveWidth;
|
|
329
|
+
const prevY = (1 - (frequencyData[i - 1] ?? 0) / 255) * waveHeight;
|
|
330
|
+
const xc = (prevX + x) / 2;
|
|
331
|
+
const yc = (prevY + y) / 2;
|
|
332
|
+
path.quadraticCurveTo(prevX, prevY, xc, yc);
|
|
288
333
|
}
|
|
289
334
|
});
|
|
290
335
|
|
|
@@ -469,7 +514,8 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
469
514
|
if (!ctx) return;
|
|
470
515
|
|
|
471
516
|
const frequencyData = this.targetElement.frequencyDataTask.value;
|
|
472
|
-
|
|
517
|
+
const byteTimeData = this.targetElement.byteTimeDomainTask.value;
|
|
518
|
+
if (!frequencyData || !byteTimeData) return;
|
|
473
519
|
|
|
474
520
|
ctx.save();
|
|
475
521
|
if (this.color === "currentColor") {
|
|
@@ -490,7 +536,10 @@ export class EFWaveform extends EFTemporal(TWMixin(LitElement)) {
|
|
|
490
536
|
this.drawBricks(ctx, frequencyData);
|
|
491
537
|
break;
|
|
492
538
|
case "line":
|
|
493
|
-
this.drawLine(ctx,
|
|
539
|
+
this.drawLine(ctx, byteTimeData);
|
|
540
|
+
break;
|
|
541
|
+
case "curve":
|
|
542
|
+
this.drawCurve(ctx, byteTimeData);
|
|
494
543
|
break;
|
|
495
544
|
case "pixel":
|
|
496
545
|
this.drawPixel(ctx, frequencyData);
|