node_modules ignore

This commit is contained in:
2025-05-08 23:43:47 +02:00
parent e19d52f172
commit 4574544c9f
65041 changed files with 10593536 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
export declare class CustomElement extends HTMLElement {
static get observedAttributes(): any[];
attributeChangedCallback(attrName: string, // eslint-disable-line
oldValue: string | null, // eslint-disable-line
newValue: string | null): void;
connectedCallback(): void;
disconnectedCallback(): void;
}

View File

@@ -0,0 +1,14 @@
class CustomElement extends HTMLElement {
static get observedAttributes() {
return [];
}
attributeChangedCallback(attrName, oldValue, newValue) {
}
connectedCallback() {
}
disconnectedCallback() {
}
}
export {
CustomElement
};

View File

@@ -0,0 +1,3 @@
export type Entry<T> = {
[K in keyof T]: [K, T[K]];
}[keyof T][];

0
server/node_modules/media-chrome/dist/utils/Entry.js generated vendored Normal file
View File

View File

@@ -0,0 +1,4 @@
export type Point = {
x: number;
y: number;
};

0
server/node_modules/media-chrome/dist/utils/Point.js generated vendored Normal file
View File

View File

@@ -0,0 +1,6 @@
export type Rect = {
x: number;
y: number;
width: number;
height: number;
};

0
server/node_modules/media-chrome/dist/utils/Rect.js generated vendored Normal file
View File

View File

@@ -0,0 +1,31 @@
import { TextTrackKinds } from '../constants.js';
export type TextTrackLike = {
/**
* The id of the track.
*/
id?: string;
/**
* Whether the track is enabled.
*/
enabled?: boolean;
/**
* A required kind for the track.
*/
kind: TextTrackKind | TextTrackKinds;
/**
* An optional label for the track.
*/
language?: string;
/**
* The BCP-47 compliant string representing the language code of the track
*/
label?: string;
/**
* The mode of the track.
*/
mode?: TextTrackMode;
/**
* The cue list for the track.
*/
cues?: TextTrackCueList;
};

View File

View File

@@ -0,0 +1,14 @@
import type { Point } from './Point.js';
import type { Rect } from './Rect.js';
export type PositionElements = {
anchor: HTMLElement;
floating: HTMLElement;
};
export type PositionRects = {
anchor: Rect;
floating: Rect;
};
export type Positions = PositionElements & {
placement: string;
};
export declare function computePosition({ anchor, floating, placement, }: Positions): Point;

View File

@@ -0,0 +1,77 @@
function computePosition({
anchor,
floating,
placement
}) {
const rects = getElementRects({ anchor, floating });
const { x, y } = computeCoordsFromPlacement(rects, placement);
return { x, y };
}
function getElementRects({
anchor,
floating
}) {
return {
anchor: getRectRelativeToOffsetParent(anchor, floating.offsetParent),
floating: {
x: 0,
y: 0,
width: floating.offsetWidth,
height: floating.offsetHeight
}
};
}
function getRectRelativeToOffsetParent(element, offsetParent) {
var _a;
const rect = element.getBoundingClientRect();
const offsetRect = (_a = offsetParent == null ? void 0 : offsetParent.getBoundingClientRect()) != null ? _a : { x: 0, y: 0 };
return {
x: rect.x - offsetRect.x,
y: rect.y - offsetRect.y,
width: rect.width,
height: rect.height
};
}
function computeCoordsFromPlacement({ anchor, floating }, placement) {
const alignmentAxis = getSideAxis(placement) === "x" ? "y" : "x";
const alignLength = alignmentAxis === "y" ? "height" : "width";
const side = getSide(placement);
const commonX = anchor.x + anchor.width / 2 - floating.width / 2;
const commonY = anchor.y + anchor.height / 2 - floating.height / 2;
const commonAlign = anchor[alignLength] / 2 - floating[alignLength] / 2;
let coords;
switch (side) {
case "top":
coords = { x: commonX, y: anchor.y - floating.height };
break;
case "bottom":
coords = { x: commonX, y: anchor.y + anchor.height };
break;
case "right":
coords = { x: anchor.x + anchor.width, y: commonY };
break;
case "left":
coords = { x: anchor.x - floating.width, y: commonY };
break;
default:
coords = { x: anchor.x, y: anchor.y };
}
switch (placement.split("-")[1]) {
case "start":
coords[alignmentAxis] -= commonAlign;
break;
case "end":
coords[alignmentAxis] += commonAlign;
break;
}
return coords;
}
function getSide(placement) {
return placement.split("-")[0];
}
function getSideAxis(placement) {
return ["top", "bottom"].includes(getSide(placement)) ? "y" : "x";
}
export {
computePosition
};

View File

@@ -0,0 +1,19 @@
export declare class AttributeTokenList implements Pick<DOMTokenList, 'length' | 'value' | 'toString' | 'item' | 'add' | 'remove' | 'contains' | 'toggle' | 'replace'> {
#private;
constructor(el?: HTMLElement, attr?: string, { defaultValue }?: {
defaultValue: any;
});
[Symbol.iterator](): IterableIterator<string>;
get length(): number;
get value(): string;
set value(val: string);
toString(): string;
item(index: any): string;
values(): Iterable<string>;
forEach(callback: (value: string, key: string, parent: Set<string>) => void, thisArg?: any): void;
add(...tokens: string[]): void;
remove(...tokens: string[]): void;
contains(token: string): boolean;
toggle(token: string, force: boolean): boolean;
replace(oldToken: string, newToken: string): boolean;
}

View File

@@ -0,0 +1,109 @@
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var _el, _attr, _defaultSet, _tokenSet, _tokens, tokens_get;
class AttributeTokenList {
constructor(el, attr, { defaultValue } = { defaultValue: void 0 }) {
__privateAdd(this, _tokens);
__privateAdd(this, _el, void 0);
__privateAdd(this, _attr, void 0);
__privateAdd(this, _defaultSet, void 0);
__privateAdd(this, _tokenSet, /* @__PURE__ */ new Set());
__privateSet(this, _el, el);
__privateSet(this, _attr, attr);
__privateSet(this, _defaultSet, new Set(defaultValue));
}
[Symbol.iterator]() {
return __privateGet(this, _tokens, tokens_get).values();
}
get length() {
return __privateGet(this, _tokens, tokens_get).size;
}
get value() {
var _a;
return (_a = [...__privateGet(this, _tokens, tokens_get)].join(" ")) != null ? _a : "";
}
set value(val) {
var _a;
if (val === this.value)
return;
__privateSet(this, _tokenSet, /* @__PURE__ */ new Set());
this.add(...(_a = val == null ? void 0 : val.split(" ")) != null ? _a : []);
}
toString() {
return this.value;
}
item(index) {
return [...__privateGet(this, _tokens, tokens_get)][index];
}
values() {
return __privateGet(this, _tokens, tokens_get).values();
}
forEach(callback, thisArg) {
__privateGet(this, _tokens, tokens_get).forEach(callback, thisArg);
}
add(...tokens) {
var _a, _b;
tokens.forEach((t) => __privateGet(this, _tokenSet).add(t));
if (this.value === "" && !((_a = __privateGet(this, _el)) == null ? void 0 : _a.hasAttribute(`${__privateGet(this, _attr)}`))) {
return;
}
(_b = __privateGet(this, _el)) == null ? void 0 : _b.setAttribute(`${__privateGet(this, _attr)}`, `${this.value}`);
}
remove(...tokens) {
var _a;
tokens.forEach((t) => __privateGet(this, _tokenSet).delete(t));
(_a = __privateGet(this, _el)) == null ? void 0 : _a.setAttribute(`${__privateGet(this, _attr)}`, `${this.value}`);
}
contains(token) {
return __privateGet(this, _tokens, tokens_get).has(token);
}
toggle(token, force) {
if (typeof force !== "undefined") {
if (force) {
this.add(token);
return true;
} else {
this.remove(token);
return false;
}
}
if (this.contains(token)) {
this.remove(token);
return false;
}
this.add(token);
return true;
}
replace(oldToken, newToken) {
this.remove(oldToken);
this.add(newToken);
return oldToken === newToken;
}
}
_el = new WeakMap();
_attr = new WeakMap();
_defaultSet = new WeakMap();
_tokenSet = new WeakMap();
_tokens = new WeakSet();
tokens_get = function() {
return __privateGet(this, _tokenSet).size ? __privateGet(this, _tokenSet) : __privateGet(this, _defaultSet);
};
export {
AttributeTokenList
};

View File

@@ -0,0 +1,149 @@
import type { TextTrackLike } from './TextTrackLike.js';
/**
* Splits a string (representing TextTracks) into an array of strings based on whitespace.
* @param textTracksStr - a string of 1+ "items" (representing TextTracks), separated by whitespace
* @returns An array of non-whitesace strings (each representing a single TextTrack).
*/
export declare const splitTextTracksStr: (textTracksStr?: string) => string[];
/**
* Parses a string that represents a TextTrack into a "TextTrack-like object"
* The expected TextTrack string format is:
* "language[:label]"
* where the language *should* conform to BCP 47, just like TextTracks, and the (optional)
* label *must* be URL encoded.
* Note that this format may be expanded to include additional properties, such as
* `id`.
* @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack
* @param textTrackStr - A well-defined TextTrack string representations
* @returns An object that resembles a (partial) TextTrack (`{ language: string; label?: string; }`)
*/
export declare const parseTextTrackStr: (textTrackStr?: string) => TextTrackLike;
/**
* Parses a whitespace-separated string that represents list of TextTracks into an array of TextTrack-like objects,
* where each object will have the properties identified by the corresponding string, plus any properties generically
* provided by the (optional) `textTrackLikeObj` argument.
* @param textTracksStr - a string of 1+ "items" (representing TextTracks), separated by whitespace
* @param textTrackLikeObj An object that resembles a (partial) TextTrack, used to add generic properties to all parsed TextTracks.
* @returns An array of "TextTrack-like objects", each with properties parsed from the string and any properties from `textTrackLikeObj`.
* @example
* ```js
* const tracksStr = 'en-US:English en:English%20%28with%20descriptions%29';
* const tracks = parseTextTracksStr(tracksStr);
* // [{ language: 'en-US', label: 'English' }, { language: 'en', label: 'English (with descriptions)' }];
*
* const tracksData = { kind: 'captions' };
* const tracksWithData = parseTextTracksStr(tracksStr, tracksData);
* // [{ language: 'en-US', label: 'English', kind: 'captions' }, { language: 'en', label: 'English (with descriptions)', kind: 'captions' }];
* ```
*/
export declare const parseTextTracksStr: (textTracksStr?: string, textTrackLikeObj?: Partial<TextTrackLike>) => TextTrackLike[];
export type TrackOrTracks = string[] | TextTrackLike[] | string | TextTrackLike;
export type TextTrackListLike = TextTrackLike[] | TextTrackList;
/**
* Takes a variety of possible representations of TextTrack(s) and "normalizes" them to an Array of 1+ TextTrack-like objects.
* @param trackOrTracks - A value representing 1+ TextTracks
* @returns An array of TextTrack-like objects.
*/
export declare const parseTracks: (trackOrTracks: TrackOrTracks) => TextTrackLike[];
/**
* Translates a TextTrack-like object into a well-defined string representation for the TextTrack
* @param obj - A TextTrack or TextTrack-like object
* @returns {string} A string representing a TextTrack with the format: "language[:label]"
*/
export declare const formatTextTrackObj: ({ kind, label, language }?: TextTrackLike) => string;
/**
* Translates a set of TextTracks into a well-defined, whitespace-separated string representation of the set
* @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrackList
* @param textTracks - A TextTracks object or an Array of TextTracks or TextTrack-like objects.
* @returns A string representing a set of TextTracks, separated by whitespace.
*/
export declare const stringifyTextTrackList: (textTracks?: TextTrackListLike) => string;
/**
* A generic higher-order function that yields a predicate to assert whether or not some value has the provided key/value pair
* @param key - The property key/name against which we'd like to match
* @param value - The value of the key we expect for a match
* @returns A predicate function that yields true if the provided object has the expected key/value pair, otherwise false.
* @example
* ```js
* const hasShowingMode = isMatchingPropOf('mode', 'showing');
* hasShowingMode({ mode: 'showing' }); // true
* hasShowingMode({ mode: 'disabled' }); // false
* hasShowingMode({ no_mode: 'any' }); // false
* ```
*/
export declare const isMatchingPropOf: (key: string | number, value: any) => ((value: any) => boolean);
/**
* A higher-order function that yields a single predicate to assert whether or not some value has *every* key/value pair defined in `filterObj`.
* @param filterObj - An object of key/value pairs that we expect on a given object
* @returns A predicate function that yields true iff the provided object has *every* key/value pair in `filterObj`, otherwise false
* @example
* ```js
* const track1 = { label: 'English', kind: 'captions', language: 'en-US' };
* const track1a = { label: 'English', kind: 'captions', language: 'en-US', id: '1', mode: 'showing' };
* const track2 = { label: 'English (with descriptions)', kind: 'captions', language: 'en-US', id: '2', mode: 'disabled' };
* const track3 = { label: 'Español', kind: 'subtitles', language: 'es-MX', id: '3', mode: 'disabled' };
* const track4 = { label: 'English', language: 'en-US', mode: 'showing' };
*
* const isMatchingTrack = textTrackObjAsPred({ label: 'English', kind: 'captions', language: 'en-US' });
* isMatchingTrack(track1); // true
* isMatchingTrack(track1a); // true
* isMatchingTrack(track2); // false
* isMatchingTrack(track3); // false
* isMatchingTrack(track4); // false
* isMatchingTrack({ no_corresponding_props: 'any' }); // false
* ```
*/
export declare const textTrackObjAsPred: (filterObj: any) => ((textTrack: TextTrackLike) => boolean);
/**
* Updates any `tracks` that match one of the `tracksToUpdate` to be in the provided TextTrack `mode`.
* @see https://developer.mozilla.org/en-US/docs/Web/API/TextTrack/mode
* @see {@link parseTracks}
* @param mode - The desired mode for any matching TextTracks. Should be one of "disabled"|"hidden"|"showing"
* @param tracks - A TextTracks object or array of TextTracks that should contain any matching TextTracks to update
* @param tracksToUpdate - A value representing a set of TextTracks
*/
export declare const updateTracksModeTo: (mode: TextTrackMode, tracks?: TextTrackListLike, tracksToUpdate?: TrackOrTracks) => void;
export type TrackFilter = (track: TextTrackLike) => boolean;
/**
* Takes an `HTMLMediaElement media` and yields an array of `TextTracks` that match the provided `filterPredOrObj` criteria (or all `TextTracks` by default).
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/textTracks
* @see {@link textTrackObjAsPred}
* @param media - An HTMLMediaElement with an expected textTracks value
* (NOTE: This uses "structural polymorphism", so as long as `media` has an Array-like `textTracks` value of TextTrack-like objects, this function will work).
* @param filterPredOrObj - Either a predicate function or an object that can be translated into a predicate function of matching key/value pairs.
* @returns An array of TextTracks that match the given `filterPredOrObj` (or all TextTracks on `media` by default)
* @example
* ```html
* <!DOCTYPE html>
* <html lang="en">
* <head></head>
* <body>
* <video src="https://stream.mux.com/DS00Spx1CV902MCtPj5WknGlR102V5HFkDe/high.mp4">
* <track label="Spanish" kind="subtitles" srclang="es" src="./vtt/en-sub.vtt">
* <track label="English" kind="subtitles" srclang="en" src="./vtt/es-sub.vtt">
* <track label="English" kind="captions" srclang="en" src="./vtt/en-cc.vtt">
</video>
* </body>
* </html>
* ```
* ```js
* // js ...
* const media = document.querySelector('video');
* getTextTracksList(media, { kind: 'subtitles' });
* // [{ label: 'Spanish', kind: 'subtitles', language: 'es' }, { label: 'English', kind: 'subtitles', language: 'en' }]
* getTextTracksList(media, { kind: 'captions' });
* // [{ label: 'English', kind: 'captions', language: 'en' }]
* getTextTracksList(media);
* // [{ label: 'Spanish', kind: 'subtitles', language: 'es' }, { label: 'English', kind: 'subtitles', language: 'en' }, { label: 'English', kind: 'captions', language: 'en' }]
* ```
*/
export declare const getTextTracksList: (media: HTMLVideoElement, filterPredOrObj?: TrackFilter | TextTrackLike) => TextTrackLike[];
/**
* Are captions or subtitles enabled?
*
* @param el - An HTMLElement that has caption related attributes on it.
* @returns Whether captions are enabled or not
*/
export declare const areSubsOn: (el: HTMLElement & {
mediaSubtitlesShowing?: any[];
}) => boolean;

View File

@@ -0,0 +1,86 @@
import { MediaUIAttributes, TextTrackKinds } from "../constants.js";
const splitTextTracksStr = (textTracksStr = "") => textTracksStr.split(/\s+/);
const parseTextTrackStr = (textTrackStr = "") => {
const [kind, language, encodedLabel] = textTrackStr.split(":");
const label = encodedLabel ? decodeURIComponent(encodedLabel) : void 0;
return {
kind: kind === "cc" ? TextTrackKinds.CAPTIONS : TextTrackKinds.SUBTITLES,
language,
label
};
};
const parseTextTracksStr = (textTracksStr = "", textTrackLikeObj = {}) => {
return splitTextTracksStr(textTracksStr).map((textTrackStr) => {
const textTrackObj = parseTextTrackStr(textTrackStr);
return {
...textTrackLikeObj,
...textTrackObj
};
});
};
const parseTracks = (trackOrTracks) => {
if (!trackOrTracks)
return [];
if (Array.isArray(trackOrTracks)) {
return trackOrTracks.map((trackObjOrStr) => {
if (typeof trackObjOrStr === "string") {
return parseTextTrackStr(trackObjOrStr);
}
return trackObjOrStr;
});
}
if (typeof trackOrTracks === "string") {
return parseTextTracksStr(trackOrTracks);
}
return [trackOrTracks];
};
const formatTextTrackObj = ({ kind, label, language } = { kind: "subtitles" }) => {
if (!label)
return language;
return `${kind === "captions" ? "cc" : "sb"}:${language}:${encodeURIComponent(
label
)}`;
};
const stringifyTextTrackList = (textTracks = []) => {
return Array.prototype.map.call(textTracks, formatTextTrackObj).join(" ");
};
const isMatchingPropOf = (key, value) => (obj) => obj[key] === value;
const textTrackObjAsPred = (filterObj) => {
const preds = Object.entries(filterObj).map(([key, value]) => {
return isMatchingPropOf(key, value);
});
return (textTrack) => preds.every((pred) => pred(textTrack));
};
const updateTracksModeTo = (mode, tracks = [], tracksToUpdate = []) => {
const preds = parseTracks(tracksToUpdate).map(textTrackObjAsPred);
const isTrackToUpdate = (textTrack) => {
return preds.some((pred) => pred(textTrack));
};
Array.from(tracks).filter(isTrackToUpdate).forEach((textTrack) => {
textTrack.mode = mode;
});
};
const getTextTracksList = (media, filterPredOrObj = () => true) => {
if (!(media == null ? void 0 : media.textTracks))
return [];
const filterPred = typeof filterPredOrObj === "function" ? filterPredOrObj : textTrackObjAsPred(filterPredOrObj);
return Array.from(media.textTracks).filter(filterPred);
};
const areSubsOn = (el) => {
var _a;
const showingSubtitles = !!((_a = el.mediaSubtitlesShowing) == null ? void 0 : _a.length) || el.hasAttribute(MediaUIAttributes.MEDIA_SUBTITLES_SHOWING);
return showingSubtitles;
};
export {
areSubsOn,
formatTextTrackObj,
getTextTracksList,
isMatchingPropOf,
parseTextTrackStr,
parseTextTracksStr,
parseTracks,
splitTextTracksStr,
stringifyTextTrackList,
textTrackObjAsPred,
updateTracksModeTo
};

View File

@@ -0,0 +1,122 @@
import type MediaController from '../media-controller.js';
/**
* Get the media controller element from the `mediacontroller` attribute or closest ancestor.
* @param host - The element to search for the media controller.
*/
export declare function getMediaController(host: HTMLElement): MediaController | undefined;
/**
* Get the media controller element from the `mediacontroller` attribute.
* @param host - The element to search for the media controller.
* @return
*/
export declare function getAttributeMediaController(host: HTMLElement): MediaController | undefined;
export declare const updateIconText: (svg: HTMLElement, value: string, selector?: string) => void;
export declare const getAllSlotted: (el: HTMLElement, name: string) => HTMLCollection | HTMLElement[];
export declare const getSlotted: (el: HTMLElement, name: string) => HTMLElement;
/**
*
* @param {{ contains?: Node['contains'] }} [rootNode]
* @param {Node} [childNode]
* @returns boolean
*/
export declare const containsComposedNode: (rootNode: Node, childNode: Node) => boolean;
export declare const closestComposedNode: <T extends Element = Element>(childNode: Element, selector: string) => T;
/**
* Get the active element, accounting for Shadow DOM subtrees.
* @param root - The root node to search for the active element.
*/
export declare function getActiveElement(root?: Document | ShadowRoot): HTMLElement;
/**
* Gets the document or shadow root of a node, not the node itself which can lead to bugs.
* https://developer.mozilla.org/en-US/docs/Web/API/Node/getRootNode#return_value
* @param node - The node to get the root node from.
*/
export declare function getDocumentOrShadowRoot(node: Node): Document | ShadowRoot | null;
/**
* Checks if the element is visible includes opacity: 0 and visibility: hidden.
* @param element - The element to check for visibility.
*/
export declare function isElementVisible(element: HTMLElement, { depth, checkOpacity, checkVisibilityCSS }?: {
depth?: number;
checkOpacity?: boolean;
checkVisibilityCSS?: boolean;
}): boolean;
export type Point = {
x: number;
y: number;
};
/**
* Get progress ratio of a point on a line segment.
* @param x - The x coordinate of the point.
* @param y - The y coordinate of the point.
* @param p1 - The first point of the line segment.
* @param p2 - The second point of the line segment.
*/
export declare function getPointProgressOnLine(x: number, y: number, p1: Point, p2: Point): number;
export declare function distance(p1: Point, p2: Point): number;
/**
* Get or insert a CSSStyleRule with a selector in an element containing <style> tags.
* @param styleParent - The parent element containing <style> tags.
* @param selectorText - The selector text of the CSS rule.
* @return {CSSStyleRule | {
* style: {
* setProperty: () => void,
* removeProperty: () => void,
* width?: string,
* height?: string,
* display?: string,
* transform?: string,
* },
* selectorText: string,
* }}
*/
export declare function getOrInsertCSSRule(styleParent: Element | ShadowRoot, selectorText: string): CSSStyleRule;
/**
* Get a CSSStyleRule with a selector in an element containing <style> tags.
* @param styleParent - The parent element containing <style> tags.
* @param predicate - A function that returns true for the desired CSSStyleRule.
*/
export declare function getCSSRule(styleParent: Element | ShadowRoot, predicate: (selectorText: string) => boolean): CSSStyleRule | undefined;
/**
* Insert a CSSStyleRule with a selector in an element containing <style> tags.
* @param styleParent - The parent element containing <style> tags.
* @param selectorText - The selector text of the CSS rule.
*/
export declare function insertCSSRule(styleParent: Element | ShadowRoot, selectorText: string): CSSStyleRule | undefined;
/**
* Gets the number represented by the attribute
* @param el - (Should be an HTMLElement, but need any for SSR cases)
* @param attrName - The name of the attribute to get
* @param defaultValue - The default value to return if the attribute is not set
* @returns Will return undefined if no attribute set
*/
export declare function getNumericAttr(el: HTMLElement, attrName: string, defaultValue?: number): number | undefined;
/**
* @param el - (Should be an HTMLElement, but need any for SSR cases)
* @param attrName - The name of the attribute to set
* @param value - The value to set
*/
export declare function setNumericAttr(el: HTMLElement, attrName: string, value: number): void;
/**
* @param el - (Should be an HTMLElement, but need any for SSR cases)
* @param attrName - The name of the attribute to get
*/
export declare function getBooleanAttr(el: HTMLElement, attrName: string): boolean;
/**
* @param el - (Should be an HTMLElement, but need any for SSR cases)
* @param attrName - The name of the attribute to set
* @param value - The value to set
*/
export declare function setBooleanAttr(el: HTMLElement, attrName: string, value: boolean): void;
/**
* @param el - (Should be an HTMLElement, but need any for SSR cases)
* @param attrName - The name of the attribute to get
* @param defaultValue - The default value to return if the attribute is not set
*/
export declare function getStringAttr(el: HTMLElement, attrName: string, defaultValue?: any): any;
/**
* @param el - (Should be an HTMLElement, but need any for SSR cases)
* @param attrName - The name of the attribute to get
* @param value - The value to set
*/
export declare function setStringAttr(el: HTMLElement, attrName: string, value: string): void;

View File

@@ -0,0 +1,211 @@
import { MediaStateReceiverAttributes } from "../constants.js";
function getMediaController(host) {
var _a;
return (_a = getAttributeMediaController(host)) != null ? _a : closestComposedNode(host, "media-controller");
}
function getAttributeMediaController(host) {
var _a;
const { MEDIA_CONTROLLER } = MediaStateReceiverAttributes;
const mediaControllerId = host.getAttribute(MEDIA_CONTROLLER);
if (mediaControllerId) {
return (_a = getDocumentOrShadowRoot(host)) == null ? void 0 : _a.getElementById(
mediaControllerId
);
}
}
const updateIconText = (svg, value, selector = ".value") => {
const node = svg.querySelector(selector);
if (!node)
return;
node.textContent = value;
};
const getAllSlotted = (el, name) => {
const slotSelector = `slot[name="${name}"]`;
const slot = el.shadowRoot.querySelector(slotSelector);
if (!slot)
return [];
return slot.children;
};
const getSlotted = (el, name) => getAllSlotted(el, name)[0];
const containsComposedNode = (rootNode, childNode) => {
if (!rootNode || !childNode)
return false;
if (rootNode == null ? void 0 : rootNode.contains(childNode))
return true;
return containsComposedNode(
rootNode,
childNode.getRootNode().host
);
};
const closestComposedNode = (childNode, selector) => {
if (!childNode)
return null;
const closest = childNode.closest(selector);
if (closest)
return closest;
return closestComposedNode(
childNode.getRootNode().host,
selector
);
};
function getActiveElement(root = document) {
var _a;
const activeEl = root == null ? void 0 : root.activeElement;
if (!activeEl)
return null;
return (_a = getActiveElement(activeEl.shadowRoot)) != null ? _a : activeEl;
}
function getDocumentOrShadowRoot(node) {
var _a;
const rootNode = (_a = node == null ? void 0 : node.getRootNode) == null ? void 0 : _a.call(node);
if (rootNode instanceof ShadowRoot || rootNode instanceof Document) {
return rootNode;
}
return null;
}
function isElementVisible(element, { depth = 3, checkOpacity = true, checkVisibilityCSS = true } = {}) {
if (element.checkVisibility) {
return element.checkVisibility({
checkOpacity,
checkVisibilityCSS
});
}
let el = element;
while (el && depth > 0) {
const style = getComputedStyle(el);
if (checkOpacity && style.opacity === "0" || checkVisibilityCSS && style.visibility === "hidden" || style.display === "none") {
return false;
}
el = el.parentElement;
depth--;
}
return true;
}
function getPointProgressOnLine(x, y, p1, p2) {
const segment = distance(p1, p2);
const toStart = distance(p1, { x, y });
const toEnd = distance(p2, { x, y });
if (toStart > segment || toEnd > segment) {
return toStart > toEnd ? 1 : 0;
}
return toStart / segment;
}
function distance(p1, p2) {
return Math.sqrt(Math.pow(p2.x - p1.x, 2) + Math.pow(p2.y - p1.y, 2));
}
function getOrInsertCSSRule(styleParent, selectorText) {
const cssRule = getCSSRule(styleParent, (st) => st === selectorText);
if (cssRule)
return cssRule;
return insertCSSRule(styleParent, selectorText);
}
function getCSSRule(styleParent, predicate) {
var _a, _b;
let style;
for (style of (_a = styleParent.querySelectorAll("style:not([media])")) != null ? _a : []) {
let cssRules;
try {
cssRules = (_b = style.sheet) == null ? void 0 : _b.cssRules;
} catch {
continue;
}
for (const rule of cssRules != null ? cssRules : []) {
if (predicate(rule.selectorText))
return rule;
}
}
}
function insertCSSRule(styleParent, selectorText) {
var _a, _b;
const styles = (_a = styleParent.querySelectorAll("style:not([media])")) != null ? _a : [];
const style = styles == null ? void 0 : styles[styles.length - 1];
if (!(style == null ? void 0 : style.sheet)) {
console.warn(
"Media Chrome: No style sheet found on style tag of",
styleParent
);
return {
// @ts-ignore
style: {
setProperty: () => {
},
removeProperty: () => "",
getPropertyValue: () => ""
}
};
}
style == null ? void 0 : style.sheet.insertRule(`${selectorText}{}`, style.sheet.cssRules.length);
return (
/** @type {CSSStyleRule} */
(_b = style.sheet.cssRules) == null ? void 0 : _b[style.sheet.cssRules.length - 1]
);
}
function getNumericAttr(el, attrName, defaultValue = Number.NaN) {
const attrVal = el.getAttribute(attrName);
return attrVal != null ? +attrVal : defaultValue;
}
function setNumericAttr(el, attrName, value) {
const nextNumericValue = +value;
if (value == null || Number.isNaN(nextNumericValue)) {
if (el.hasAttribute(attrName)) {
el.removeAttribute(attrName);
}
return;
}
if (getNumericAttr(el, attrName, void 0) === nextNumericValue)
return;
el.setAttribute(attrName, `${nextNumericValue}`);
}
function getBooleanAttr(el, attrName) {
return el.hasAttribute(attrName);
}
function setBooleanAttr(el, attrName, value) {
if (value == null) {
if (el.hasAttribute(attrName)) {
el.removeAttribute(attrName);
}
return;
}
if (getBooleanAttr(el, attrName) == value)
return;
el.toggleAttribute(attrName, value);
}
function getStringAttr(el, attrName, defaultValue = null) {
var _a;
return (_a = el.getAttribute(attrName)) != null ? _a : defaultValue;
}
function setStringAttr(el, attrName, value) {
if (value == null) {
if (el.hasAttribute(attrName)) {
el.removeAttribute(attrName);
}
return;
}
const nextValue = `${value}`;
if (getStringAttr(el, attrName, void 0) === nextValue)
return;
el.setAttribute(attrName, nextValue);
}
export {
closestComposedNode,
containsComposedNode,
distance,
getActiveElement,
getAllSlotted,
getAttributeMediaController,
getBooleanAttr,
getCSSRule,
getDocumentOrShadowRoot,
getMediaController,
getNumericAttr,
getOrInsertCSSRule,
getPointProgressOnLine,
getSlotted,
getStringAttr,
insertCSSRule,
isElementVisible,
setBooleanAttr,
setNumericAttr,
setStringAttr,
updateIconText
};

View File

@@ -0,0 +1,34 @@
export type InvokeEventInit = EventInit & {
action?: string;
relatedTarget: Element;
};
/**
* Dispatch an InvokeEvent on the target element to perform an action.
* The default action is auto, which is determined by the target element.
* In our case it's only used for toggling a menu.
*/
export declare class InvokeEvent extends Event {
action: string;
relatedTarget: Element;
/**
* @param init - The event options.
*/
constructor({ action, relatedTarget, ...options }: InvokeEventInit);
}
export type ToggleState = 'open' | 'closed';
export type ToggleEventInit = EventInit & {
newState: ToggleState;
oldState: ToggleState;
};
/**
* Similar to the popover toggle event.
* https://developer.mozilla.org/en-US/docs/Web/API/ToggleEvent
*/
export declare class ToggleEvent extends Event {
newState: ToggleState;
oldState: ToggleState;
/**
* @param init - The event options.
*/
constructor({ newState, oldState, ...options }: ToggleEventInit);
}

24
server/node_modules/media-chrome/dist/utils/events.js generated vendored Normal file
View File

@@ -0,0 +1,24 @@
class InvokeEvent extends Event {
/**
* @param init - The event options.
*/
constructor({ action = "auto", relatedTarget, ...options }) {
super("invoke", options);
this.action = action;
this.relatedTarget = relatedTarget;
}
}
class ToggleEvent extends Event {
/**
* @param init - The event options.
*/
constructor({ newState, oldState, ...options }) {
super("toggle", options);
this.newState = newState;
this.oldState = oldState;
}
}
export {
InvokeEvent,
ToggleEvent
};

View File

@@ -0,0 +1,29 @@
/**
* @typedef {Partial<HTMLVideoElement> & {
* webkitDisplayingFullscreen?: boolean;
* webkitPresentationMode?: 'fullscreen'|'picture-in-picture';
* webkitEnterFullscreen?: () => any;
* }} MediaStateOwner
*/
/**
* @typedef {Partial<Document|ShadowRoot>} RootNodeStateOwner
*/
/**
* @typedef {Partial<HTMLElement>} FullScreenElementStateOwner
*/
/**
* @typedef {object} StateOwners
* @property {MediaStateOwner} [media]
* @property {RootNodeStateOwner} [documentElement]
* @property {FullScreenElementStateOwner} [fullscreenElement]
*/
/** @type {(stateOwners: StateOwners) => Promise<undefined> | undefined} */
export declare const enterFullscreen: (stateOwners: any) => Promise<any>;
/** @type {(stateOwners: StateOwners) => Promise<undefined> | undefined} */
export declare const exitFullscreen: (stateOwners: any) => Promise<any>;
/** @type {(stateOwners: StateOwners) => FullScreenElementStateOwner | null | undefined} */
export declare const getFullscreenElement: (stateOwners: any) => any;
/** @type {(stateOwners: StateOwners) => boolean} */
export declare const isFullscreen: (stateOwners: any) => boolean;
/** @type {(stateOwners: StateOwners) => boolean} */
export declare const isFullscreenEnabled: (stateOwners: any) => boolean;

View File

@@ -0,0 +1,81 @@
import { WebkitPresentationModes } from "../constants.js";
import { containsComposedNode } from "./element-utils.js";
import { document } from "./server-safe-globals.js";
const enterFullscreen = (stateOwners) => {
var _a;
const { media, fullscreenElement } = stateOwners;
const enterFullscreenKey = fullscreenElement && "requestFullscreen" in fullscreenElement ? "requestFullscreen" : fullscreenElement && "webkitRequestFullScreen" in fullscreenElement ? "webkitRequestFullScreen" : void 0;
if (enterFullscreenKey) {
const maybePromise = (_a = fullscreenElement[enterFullscreenKey]) == null ? void 0 : _a.call(fullscreenElement);
if (maybePromise instanceof Promise) {
return maybePromise.catch(() => {
});
}
} else if (media == null ? void 0 : media.webkitEnterFullscreen) {
media.webkitEnterFullscreen();
} else if (media == null ? void 0 : media.requestFullscreen) {
media.requestFullscreen();
}
};
const exitFullscreenKey = "exitFullscreen" in document ? "exitFullscreen" : "webkitExitFullscreen" in document ? "webkitExitFullscreen" : "webkitCancelFullScreen" in document ? "webkitCancelFullScreen" : void 0;
const exitFullscreen = (stateOwners) => {
var _a;
const { documentElement } = stateOwners;
if (exitFullscreenKey) {
const maybePromise = (_a = documentElement == null ? void 0 : documentElement[exitFullscreenKey]) == null ? void 0 : _a.call(documentElement);
if (maybePromise instanceof Promise) {
return maybePromise.catch(() => {
});
}
}
};
const fullscreenElementKey = "fullscreenElement" in document ? "fullscreenElement" : "webkitFullscreenElement" in document ? "webkitFullscreenElement" : void 0;
const getFullscreenElement = (stateOwners) => {
const { documentElement, media } = stateOwners;
const docFullscreenElement = documentElement == null ? void 0 : documentElement[fullscreenElementKey];
if (!docFullscreenElement && "webkitDisplayingFullscreen" in media && "webkitPresentationMode" in media && media.webkitDisplayingFullscreen && media.webkitPresentationMode === WebkitPresentationModes.FULLSCREEN) {
return media;
}
return docFullscreenElement;
};
const isFullscreen = (stateOwners) => {
var _a;
const { media, documentElement, fullscreenElement = media } = stateOwners;
if (!media || !documentElement)
return false;
const currentFullscreenElement = getFullscreenElement(stateOwners);
if (!currentFullscreenElement)
return false;
if (currentFullscreenElement === fullscreenElement || currentFullscreenElement === media) {
return true;
}
if (currentFullscreenElement.localName.includes("-")) {
let currentRoot = currentFullscreenElement.shadowRoot;
if (!(fullscreenElementKey in currentRoot)) {
return containsComposedNode(
currentFullscreenElement,
/** @TODO clean up type assumptions (e.g. Node) (CJP) */
// @ts-ignore
fullscreenElement
);
}
while (currentRoot == null ? void 0 : currentRoot[fullscreenElementKey]) {
if (currentRoot[fullscreenElementKey] === fullscreenElement)
return true;
currentRoot = (_a = currentRoot[fullscreenElementKey]) == null ? void 0 : _a.shadowRoot;
}
}
return false;
};
const fullscreenEnabledKey = "fullscreenEnabled" in document ? "fullscreenEnabled" : "webkitFullscreenEnabled" in document ? "webkitFullscreenEnabled" : void 0;
const isFullscreenEnabled = (stateOwners) => {
const { documentElement, media } = stateOwners;
return !!(documentElement == null ? void 0 : documentElement[fullscreenEnabledKey]) || media && "webkitSupportsFullscreen" in media;
};
export {
enterFullscreen,
exitFullscreen,
getFullscreenElement,
isFullscreen,
isFullscreenEnabled
};

View File

@@ -0,0 +1,23 @@
export declare const getTestMediaEl: () => HTMLVideoElement;
/**
* Test for volume support
*
* @param mediaEl - The media element to test
*/
export declare const hasVolumeSupportAsync: (mediaEl?: HTMLVideoElement) => Promise<boolean>;
/**
* Test for PIP support
*
* @param mediaEl - The media element to test
*/
export declare const hasPipSupport: (mediaEl?: HTMLVideoElement) => boolean;
/**
* Test for Fullscreen support
*
* @param mediaEl - The media element to test
*/
export declare const hasFullscreenSupport: (mediaEl?: HTMLVideoElement) => boolean;
export declare const fullscreenSupported: boolean;
export declare const pipSupported: boolean;
export declare const airplaySupported: boolean;
export declare const castSupported: boolean;

View File

@@ -0,0 +1,62 @@
import { globalThis, document } from "./server-safe-globals.js";
import { delay } from "./utils.js";
import { isFullscreenEnabled } from "./fullscreen-api.js";
let testMediaEl;
const getTestMediaEl = () => {
var _a, _b;
if (testMediaEl)
return testMediaEl;
testMediaEl = (_b = (_a = document) == null ? void 0 : _a.createElement) == null ? void 0 : _b.call(_a, "video");
return testMediaEl;
};
const hasVolumeSupportAsync = async (mediaEl = getTestMediaEl()) => {
if (!mediaEl)
return false;
const prevVolume = mediaEl.volume;
mediaEl.volume = prevVolume / 2 + 0.1;
const abortController = new AbortController();
const volumeSupported = await Promise.race([
dispatchedVolumeChange(mediaEl, abortController.signal),
volumeChanged(mediaEl, prevVolume)
]);
abortController.abort();
return volumeSupported;
};
const dispatchedVolumeChange = (mediaEl, signal) => {
return new Promise((resolve) => {
mediaEl.addEventListener("volumechange", () => resolve(true), { signal });
});
};
const volumeChanged = async (mediaEl, prevVolume) => {
for (let i = 0; i < 10; i++) {
if (mediaEl.volume === prevVolume)
return false;
await delay(10);
}
return mediaEl.volume !== prevVolume;
};
const isSafari = /.*Version\/.*Safari\/.*/.test(
globalThis.navigator.userAgent
);
const hasPipSupport = (mediaEl = getTestMediaEl()) => {
if (globalThis.matchMedia("(display-mode: standalone)").matches && isSafari)
return false;
return typeof (mediaEl == null ? void 0 : mediaEl.requestPictureInPicture) === "function";
};
const hasFullscreenSupport = (mediaEl = getTestMediaEl()) => {
return isFullscreenEnabled({ documentElement: document, media: mediaEl });
};
const fullscreenSupported = hasFullscreenSupport();
const pipSupported = hasPipSupport();
const airplaySupported = !!globalThis.WebKitPlaybackTargetAvailabilityEvent;
const castSupported = !!globalThis.chrome;
export {
airplaySupported,
castSupported,
fullscreenSupported,
getTestMediaEl,
hasFullscreenSupport,
hasPipSupport,
hasVolumeSupportAsync,
pipSupported
};

View File

@@ -0,0 +1,22 @@
type Range = {
valueAsNumber: number;
};
/**
* Smoothly animate a range input accounting for hiccups and diverging playback.
*/
export declare class RangeAnimation {
#private;
fps: number;
callback: (value: number) => void;
duration: number;
playbackRate: number;
constructor(range: Range, callback: (value: number) => void, fps: number);
start(): void;
stop(): void;
update({ start, duration, playbackRate }: {
start: any;
duration: any;
playbackRate: any;
}): void;
}
export {};

View File

@@ -0,0 +1,100 @@
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var __privateWrapper = (obj, member, setter, getter) => ({
set _(value) {
__privateSet(obj, member, value, setter);
},
get _() {
return __privateGet(obj, member, getter);
}
});
var _range, _startTime, _previousTime, _deltaTime, _frameCount, _updateTimestamp, _updateStartValue, _lastRangeIncrease, _id, _animate;
class RangeAnimation {
constructor(range, callback, fps) {
__privateAdd(this, _range, void 0);
__privateAdd(this, _startTime, void 0);
__privateAdd(this, _previousTime, void 0);
__privateAdd(this, _deltaTime, void 0);
__privateAdd(this, _frameCount, void 0);
__privateAdd(this, _updateTimestamp, void 0);
__privateAdd(this, _updateStartValue, void 0);
__privateAdd(this, _lastRangeIncrease, void 0);
__privateAdd(this, _id, 0);
__privateAdd(this, _animate, (now = performance.now()) => {
__privateSet(this, _id, requestAnimationFrame(__privateGet(this, _animate)));
__privateSet(this, _deltaTime, performance.now() - __privateGet(this, _previousTime));
const fpsInterval = 1e3 / this.fps;
if (__privateGet(this, _deltaTime) > fpsInterval) {
__privateSet(this, _previousTime, now - __privateGet(this, _deltaTime) % fpsInterval);
const fps = 1e3 / ((now - __privateGet(this, _startTime)) / ++__privateWrapper(this, _frameCount)._);
const delta = (now - __privateGet(this, _updateTimestamp)) / 1e3 / this.duration;
let value = __privateGet(this, _updateStartValue) + delta * this.playbackRate;
const increase = value - __privateGet(this, _range).valueAsNumber;
if (increase > 0) {
__privateSet(this, _lastRangeIncrease, this.playbackRate / this.duration / fps);
} else {
__privateSet(this, _lastRangeIncrease, 0.995 * __privateGet(this, _lastRangeIncrease));
value = __privateGet(this, _range).valueAsNumber + __privateGet(this, _lastRangeIncrease);
}
this.callback(value);
}
});
__privateSet(this, _range, range);
this.callback = callback;
this.fps = fps;
}
start() {
if (__privateGet(this, _id) !== 0)
return;
__privateSet(this, _previousTime, performance.now());
__privateSet(this, _startTime, __privateGet(this, _previousTime));
__privateSet(this, _frameCount, 0);
__privateGet(this, _animate).call(this);
}
stop() {
if (__privateGet(this, _id) === 0)
return;
cancelAnimationFrame(__privateGet(this, _id));
__privateSet(this, _id, 0);
}
update({ start, duration, playbackRate }) {
const increase = start - __privateGet(this, _range).valueAsNumber;
const durationDelta = Math.abs(duration - this.duration);
if (increase > 0 || increase < -0.03 || durationDelta >= 0.5) {
this.callback(start);
}
__privateSet(this, _updateStartValue, start);
__privateSet(this, _updateTimestamp, performance.now());
this.duration = duration;
this.playbackRate = playbackRate;
}
}
_range = new WeakMap();
_startTime = new WeakMap();
_previousTime = new WeakMap();
_deltaTime = new WeakMap();
_frameCount = new WeakMap();
_updateTimestamp = new WeakMap();
_updateStartValue = new WeakMap();
_lastRangeIncrease = new WeakMap();
_id = new WeakMap();
_animate = new WeakMap();
export {
RangeAnimation
};

View File

@@ -0,0 +1,4 @@
type ResizeCallback = (entry: ResizeObserverEntry) => void;
export declare function observeResize(element: Element, callback: ResizeCallback): void;
export declare function unobserveResize(element: Element, callback: ResizeCallback): void;
export {};

View File

@@ -0,0 +1,32 @@
import { globalThis } from "./server-safe-globals.js";
const callbacksMap = /* @__PURE__ */ new WeakMap();
const getCallbacks = (element) => {
let callbacks = callbacksMap.get(element);
if (!callbacks)
callbacksMap.set(element, callbacks = /* @__PURE__ */ new Set());
return callbacks;
};
const observer = new globalThis.ResizeObserver(
(entries) => {
for (const entry of entries) {
for (const callback of getCallbacks(entry.target)) {
callback(entry);
}
}
}
);
function observeResize(element, callback) {
getCallbacks(element).add(callback);
observer.observe(element);
}
function unobserveResize(element, callback) {
const callbacks = getCallbacks(element);
callbacks.delete(callback);
if (!callbacks.size) {
observer.unobserve(element);
}
}
export {
observeResize,
unobserveResize
};

View File

@@ -0,0 +1,6 @@
export declare const isServer: boolean;
export declare const GlobalThis: typeof globalThis;
export declare const Document: typeof globalThis['document'] & Partial<{
webkitExitFullscreen: typeof globalThis['document']['exitFullscreen'];
}>;
export { GlobalThis as globalThis, Document as document };

View File

@@ -0,0 +1,122 @@
class EventTarget {
addEventListener() {
}
removeEventListener() {
}
dispatchEvent() {
return true;
}
}
class Node extends EventTarget {
}
class Element extends Node {
constructor() {
super(...arguments);
this.role = null;
}
}
class ResizeObserver {
observe() {
}
unobserve() {
}
disconnect() {
}
}
const documentShim = {
createElement: function() {
return new globalThisShim.HTMLElement();
},
createElementNS: function() {
return new globalThisShim.HTMLElement();
},
addEventListener() {
},
removeEventListener() {
},
/**
*
* @param {Event} event
* @returns {boolean}
*/
dispatchEvent(event) {
return false;
}
};
const globalThisShim = {
ResizeObserver,
document: documentShim,
Node,
Element,
HTMLElement: class HTMLElement extends Element {
constructor() {
super(...arguments);
this.innerHTML = "";
}
get content() {
return new globalThisShim.DocumentFragment();
}
},
DocumentFragment: class DocumentFragment extends EventTarget {
},
customElements: {
get: function() {
},
define: function() {
},
whenDefined: function() {
}
},
localStorage: {
/**
* @param {string} key
* @returns {string|null}
*/
getItem(key) {
return null;
},
/**
* @param {string} key
* @param {string} value
*/
setItem(key, value) {
},
// eslint-disable-line @typescript-eslint/no-unused-vars
/**
* @param {string} key
*/
removeItem(key) {
}
// eslint-disable-line @typescript-eslint/no-unused-vars
},
CustomEvent: function CustomEvent() {
},
getComputedStyle: function() {
},
navigator: {
languages: [],
get userAgent() {
return "";
}
},
/**
* @param {string} media
*/
matchMedia(media) {
return {
matches: false,
media
};
}
};
const isServer = typeof window === "undefined" || typeof window.customElements === "undefined";
const isShimmed = Object.keys(globalThisShim).every((key) => key in globalThis);
const GlobalThis = isServer && !isShimmed ? globalThisShim : globalThis;
const Document = isServer && !isShimmed ? documentShim : globalThis.document;
export {
Document,
GlobalThis,
Document as document,
GlobalThis as globalThis,
isServer
};

View File

@@ -0,0 +1,61 @@
import { globalThis } from '../utils/server-safe-globals.js';
export type State = Record<string, any>;
export type Parts = [string, Part][];
export type Processor = {
createCallback?: (instance: TemplateInstance, parts: Parts, state: State) => void;
processCallback: (instance: TemplateInstance, parts: Parts, state: State) => void;
};
export declare const defaultProcessor: Processor;
/**
*
*/
export declare class TemplateInstance extends globalThis.DocumentFragment {
#private;
constructor(template: HTMLTemplateElement, state?: State | null, processor?: Processor);
update(state?: State): void;
}
export declare const parse: (element: Element, parts?: Parts) => Parts;
export declare const tokenize: (text: string) => [number, string][];
export declare class Part {
get value(): string;
set value(val: string);
toString(): string;
}
type AttrPiece = AttrPart | string;
export declare class AttrPartList {
#private;
[Symbol.iterator](): IterableIterator<AttrPiece>;
get length(): number;
item(index: number): AttrPiece;
append(...items: AttrPiece[]): void;
toString(): string;
}
export declare class AttrPart extends Part {
#private;
constructor(element: Element, attributeName: string, namespaceURI: string | null);
get attributeName(): string;
get attributeNamespace(): string;
get element(): Element;
get value(): string;
set value(newValue: string);
get booleanValue(): boolean;
set booleanValue(value: boolean);
}
export declare class ChildNodePart extends Part {
#private;
constructor(parentNode: Element, nodes?: ChildNode[]);
get replacementNodes(): any;
get parentNode(): any;
get nextSibling(): any;
get previousSibling(): any;
get value(): any;
set value(newValue: any);
replace(...nodes: any[]): void;
}
export declare class InnerTemplatePart extends ChildNodePart {
directive: string;
expression: string;
template: HTMLTemplateElement;
constructor(parentNode: Element, template: HTMLTemplateElement);
}
export {};

View File

@@ -0,0 +1,331 @@
var __accessCheck = (obj, member, msg) => {
if (!member.has(obj))
throw TypeError("Cannot " + msg);
};
var __privateGet = (obj, member, getter) => {
__accessCheck(obj, member, "read from private field");
return getter ? getter.call(obj) : member.get(obj);
};
var __privateAdd = (obj, member, value) => {
if (member.has(obj))
throw TypeError("Cannot add the same private member more than once");
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
};
var __privateSet = (obj, member, value, setter) => {
__accessCheck(obj, member, "write to private field");
setter ? setter.call(obj, value) : member.set(obj, value);
return value;
};
var _parts, _processor, _items, _value, _element, _attributeName, _namespaceURI, _list, list_get, _parentNode, _nodes;
import { globalThis } from "../utils/server-safe-globals.js";
const ELEMENT = 1;
const STRING = 0;
const PART = 1;
const defaultProcessor = {
processCallback(instance, parts, state) {
if (!state)
return;
for (const [expression, part] of parts) {
if (expression in state) {
const value = state[expression];
if (typeof value === "boolean" && part instanceof AttrPart && typeof part.element[part.attributeName] === "boolean") {
part.booleanValue = value;
} else if (typeof value === "function" && part instanceof AttrPart) {
part.element[part.attributeName] = value;
} else {
part.value = value;
}
}
}
}
};
class TemplateInstance extends globalThis.DocumentFragment {
constructor(template, state, processor = defaultProcessor) {
var _a;
super();
__privateAdd(this, _parts, void 0);
__privateAdd(this, _processor, void 0);
this.append(template.content.cloneNode(true));
__privateSet(this, _parts, parse(this));
__privateSet(this, _processor, processor);
(_a = processor.createCallback) == null ? void 0 : _a.call(processor, this, __privateGet(this, _parts), state);
processor.processCallback(this, __privateGet(this, _parts), state);
}
update(state) {
__privateGet(this, _processor).processCallback(this, __privateGet(this, _parts), state);
}
}
_parts = new WeakMap();
_processor = new WeakMap();
const parse = (element, parts = []) => {
let type, value;
for (const attr of element.attributes || []) {
if (attr.value.includes("{{")) {
const list = new AttrPartList();
for ([type, value] of tokenize(attr.value)) {
if (!type)
list.append(value);
else {
const part = new AttrPart(element, attr.name, attr.namespaceURI);
list.append(part);
parts.push([value, part]);
}
}
attr.value = list.toString();
}
}
for (const node of element.childNodes) {
if (node.nodeType === ELEMENT && !(node instanceof HTMLTemplateElement)) {
parse(node, parts);
} else {
const data = node.data;
if (node.nodeType === ELEMENT || data.includes("{{")) {
const items = [];
if (data) {
for ([type, value] of tokenize(data))
if (!type)
items.push(new Text(value));
else {
const part = new ChildNodePart(element);
items.push(part);
parts.push([value, part]);
}
} else if (node instanceof HTMLTemplateElement) {
const part = new InnerTemplatePart(element, node);
items.push(part);
parts.push([part.expression, part]);
}
node.replaceWith(
...items.flatMap((part) => part.replacementNodes || [part])
);
}
}
}
return parts;
};
const mem = {};
const tokenize = (text) => {
let value = "", open = 0, tokens = mem[text], i = 0, c;
if (tokens)
return tokens;
else
tokens = [];
for (; c = text[i]; i++) {
if (c === "{" && text[i + 1] === "{" && text[i - 1] !== "\\" && text[i + 2] && ++open == 1) {
if (value)
tokens.push([STRING, value]);
value = "";
i++;
} else if (c === "}" && text[i + 1] === "}" && text[i - 1] !== "\\" && !--open) {
tokens.push([PART, value.trim()]);
value = "";
i++;
} else
value += c || "";
}
if (value)
tokens.push([STRING, (open > 0 ? "{{" : "") + value]);
return mem[text] = tokens;
};
const FRAGMENT = 11;
class Part {
get value() {
return "";
}
set value(val) {
}
toString() {
return this.value;
}
}
const attrPartToList = /* @__PURE__ */ new WeakMap();
class AttrPartList {
constructor() {
__privateAdd(this, _items, []);
}
[Symbol.iterator]() {
return __privateGet(this, _items).values();
}
get length() {
return __privateGet(this, _items).length;
}
item(index) {
return __privateGet(this, _items)[index];
}
append(...items) {
for (const item of items) {
if (item instanceof AttrPart) {
attrPartToList.set(item, this);
}
__privateGet(this, _items).push(item);
}
}
toString() {
return __privateGet(this, _items).join("");
}
}
_items = new WeakMap();
class AttrPart extends Part {
constructor(element, attributeName, namespaceURI) {
super();
__privateAdd(this, _list);
__privateAdd(this, _value, "");
__privateAdd(this, _element, void 0);
__privateAdd(this, _attributeName, void 0);
__privateAdd(this, _namespaceURI, void 0);
__privateSet(this, _element, element);
__privateSet(this, _attributeName, attributeName);
__privateSet(this, _namespaceURI, namespaceURI);
}
get attributeName() {
return __privateGet(this, _attributeName);
}
get attributeNamespace() {
return __privateGet(this, _namespaceURI);
}
get element() {
return __privateGet(this, _element);
}
get value() {
return __privateGet(this, _value);
}
set value(newValue) {
if (__privateGet(this, _value) === newValue)
return;
__privateSet(this, _value, newValue);
if (!__privateGet(this, _list, list_get) || __privateGet(this, _list, list_get).length === 1) {
if (newValue == null) {
__privateGet(this, _element).removeAttributeNS(
__privateGet(this, _namespaceURI),
__privateGet(this, _attributeName)
);
} else {
__privateGet(this, _element).setAttributeNS(
__privateGet(this, _namespaceURI),
__privateGet(this, _attributeName),
newValue
);
}
} else {
__privateGet(this, _element).setAttributeNS(
__privateGet(this, _namespaceURI),
__privateGet(this, _attributeName),
__privateGet(this, _list, list_get).toString()
);
}
}
get booleanValue() {
return __privateGet(this, _element).hasAttributeNS(
__privateGet(this, _namespaceURI),
__privateGet(this, _attributeName)
);
}
set booleanValue(value) {
if (!__privateGet(this, _list, list_get) || __privateGet(this, _list, list_get).length === 1)
this.value = value ? "" : null;
else
throw new DOMException("Value is not fully templatized");
}
}
_value = new WeakMap();
_element = new WeakMap();
_attributeName = new WeakMap();
_namespaceURI = new WeakMap();
_list = new WeakSet();
list_get = function() {
return attrPartToList.get(this);
};
class ChildNodePart extends Part {
constructor(parentNode, nodes) {
super();
__privateAdd(this, _parentNode, void 0);
__privateAdd(this, _nodes, void 0);
__privateSet(this, _parentNode, parentNode);
__privateSet(this, _nodes, nodes ? [...nodes] : [new Text()]);
}
get replacementNodes() {
return __privateGet(this, _nodes);
}
get parentNode() {
return __privateGet(this, _parentNode);
}
get nextSibling() {
return __privateGet(this, _nodes)[__privateGet(this, _nodes).length - 1].nextSibling;
}
get previousSibling() {
return __privateGet(this, _nodes)[0].previousSibling;
}
// FIXME: not sure why do we need string serialization here? Just because parent class has type DOMString?
get value() {
return __privateGet(this, _nodes).map((node) => node.textContent).join("");
}
set value(newValue) {
this.replace(newValue);
}
replace(...nodes) {
const normalisedNodes = nodes.flat().flatMap(
(node) => node == null ? [new Text()] : node.forEach ? [...node] : node.nodeType === FRAGMENT ? [...node.childNodes] : node.nodeType ? [node] : [new Text(node)]
);
if (!normalisedNodes.length)
normalisedNodes.push(new Text());
__privateSet(this, _nodes, swapdom(
__privateGet(this, _nodes)[0].parentNode,
__privateGet(this, _nodes),
normalisedNodes,
this.nextSibling
));
}
}
_parentNode = new WeakMap();
_nodes = new WeakMap();
class InnerTemplatePart extends ChildNodePart {
constructor(parentNode, template) {
const directive = template.getAttribute("directive") || template.getAttribute("type");
let expression = template.getAttribute("expression") || template.getAttribute(directive) || "";
if (expression.startsWith("{{"))
expression = expression.trim().slice(2, -2).trim();
super(parentNode);
this.expression = expression;
this.template = template;
this.directive = directive;
}
}
function swapdom(parent, a, b, end = null) {
let i = 0, cur, next, bi, n = b.length, m = a.length;
while (i < n && i < m && a[i] == b[i])
i++;
while (i < n && i < m && b[n - 1] == a[m - 1])
end = b[--m, --n];
if (i == m)
while (i < n)
parent.insertBefore(b[i++], end);
if (i == n)
while (i < m)
parent.removeChild(a[i++]);
else {
cur = a[i];
while (i < n) {
bi = b[i++], next = cur ? cur.nextSibling : end;
if (cur == bi)
cur = next;
else if (i < n && b[i] == next)
parent.replaceChild(bi, cur), cur = next;
else
parent.insertBefore(bi, cur);
}
while (cur != end)
next = cur.nextSibling, parent.removeChild(cur), cur = next;
}
return b;
}
export {
AttrPart,
AttrPartList,
ChildNodePart,
InnerTemplatePart,
Part,
TemplateInstance,
defaultProcessor,
parse,
tokenize
};

View File

@@ -0,0 +1,11 @@
import { Processor } from './template-parts.js';
export declare const processor: Processor;
export declare function tokenizeExpression(expr: string): Token[];
export declare function evaluateExpression(expr: string, state?: Record<string, any>): any;
export declare function getParamValue(raw: string, state?: Record<string, any>): any;
type Token = {
token: string;
type: string;
matches?: string[];
};
export {};

View File

@@ -0,0 +1,237 @@
import {
AttrPart,
InnerTemplatePart,
TemplateInstance
} from "./template-parts.js";
import { isNumericString } from "./utils.js";
const pipeModifiers = {
string: (value) => String(value)
};
class PartialTemplate {
constructor(template) {
this.template = template;
this.state = void 0;
}
}
const templates = /* @__PURE__ */ new WeakMap();
const templateInstances = /* @__PURE__ */ new WeakMap();
const Directives = {
partial: (part, state) => {
state[part.expression] = new PartialTemplate(part.template);
},
if: (part, state) => {
var _a;
if (evaluateExpression(part.expression, state)) {
if (templates.get(part) !== part.template) {
templates.set(part, part.template);
const tpl = new TemplateInstance(part.template, state, processor);
part.replace(tpl);
templateInstances.set(part, tpl);
} else {
(_a = templateInstances.get(part)) == null ? void 0 : _a.update(state);
}
} else {
part.replace("");
templates.delete(part);
templateInstances.delete(part);
}
}
};
const DirectiveNames = Object.keys(Directives);
const processor = {
processCallback(instance, parts, state) {
var _a, _b;
if (!state)
return;
for (const [expression, part] of parts) {
if (part instanceof InnerTemplatePart) {
if (!part.directive) {
const directive = DirectiveNames.find(
(n) => part.template.hasAttribute(n)
);
if (directive) {
part.directive = directive;
part.expression = part.template.getAttribute(directive);
}
}
(_a = Directives[part.directive]) == null ? void 0 : _a.call(Directives, part, state);
continue;
}
let value = evaluateExpression(expression, state);
if (value instanceof PartialTemplate) {
if (templates.get(part) !== value.template) {
templates.set(part, value.template);
value = new TemplateInstance(value.template, value.state, processor);
part.value = value;
templateInstances.set(part, value);
} else {
(_b = templateInstances.get(part)) == null ? void 0 : _b.update(value.state);
}
continue;
}
if (value) {
if (part instanceof AttrPart) {
if (part.attributeName.startsWith("aria-")) {
value = String(value);
}
}
if (part instanceof AttrPart) {
if (typeof value === "boolean") {
part.booleanValue = value;
} else if (typeof value === "function") {
part.element[part.attributeName] = value;
} else {
part.value = value;
}
} else {
part.value = value;
templates.delete(part);
templateInstances.delete(part);
}
} else {
if (part instanceof AttrPart) {
part.value = void 0;
} else {
part.value = void 0;
templates.delete(part);
templateInstances.delete(part);
}
}
}
}
};
const operators = {
"!": (a) => !a,
"!!": (a) => !!a,
"==": (a, b) => a == b,
"!=": (a, b) => a != b,
">": (a, b) => a > b,
">=": (a, b) => a >= b,
"<": (a, b) => a < b,
"<=": (a, b) => a <= b,
"??": (a, b) => a != null ? a : b,
"|": (a, b) => {
var _a;
return (_a = pipeModifiers[b]) == null ? void 0 : _a.call(pipeModifiers, a);
}
};
function tokenizeExpression(expr) {
return tokenize(expr, {
boolean: /true|false/,
number: /-?\d+\.?\d*/,
string: /(["'])((?:\\.|[^\\])*?)\1/,
operator: /[!=><][=!]?|\?\?|\|/,
ws: /\s+/,
param: /[$a-z_][$\w]*/i
}).filter(({ type }) => type !== "ws");
}
function evaluateExpression(expr, state = {}) {
var _a, _b, _c, _d, _e, _f, _g;
const tokens = tokenizeExpression(expr);
if (tokens.length === 0 || tokens.some(({ type }) => !type)) {
return invalidExpression(expr);
}
if (((_a = tokens[0]) == null ? void 0 : _a.token) === ">") {
const partial = state[(_b = tokens[1]) == null ? void 0 : _b.token];
if (!partial) {
return invalidExpression(expr);
}
const partialState = { ...state };
partial.state = partialState;
const args = tokens.slice(2);
for (let i = 0; i < args.length; i += 3) {
const name = (_c = args[i]) == null ? void 0 : _c.token;
const operator = (_d = args[i + 1]) == null ? void 0 : _d.token;
const value = (_e = args[i + 2]) == null ? void 0 : _e.token;
if (name && operator === "=") {
partialState[name] = getParamValue(value, state);
}
}
return partial;
}
if (tokens.length === 1) {
if (!isValidParam(tokens[0])) {
return invalidExpression(expr);
}
return getParamValue(tokens[0].token, state);
}
if (tokens.length === 2) {
const operator = (_f = tokens[0]) == null ? void 0 : _f.token;
const run = operators[operator];
if (!run || !isValidParam(tokens[1])) {
return invalidExpression(expr);
}
const a = getParamValue(tokens[1].token, state);
return run(a);
}
if (tokens.length === 3) {
const operator = (_g = tokens[1]) == null ? void 0 : _g.token;
const run = operators[operator];
if (!run || !isValidParam(tokens[0]) || !isValidParam(tokens[2])) {
return invalidExpression(expr);
}
const a = getParamValue(tokens[0].token, state);
if (operator === "|") {
return run(a, tokens[2].token);
}
const b = getParamValue(tokens[2].token, state);
return run(a, b);
}
}
function invalidExpression(expr) {
console.warn(`Warning: invalid expression \`${expr}\``);
return false;
}
function isValidParam({ type }) {
return ["number", "boolean", "string", "param"].includes(type);
}
function getParamValue(raw, state) {
const firstChar = raw[0];
const lastChar = raw.slice(-1);
if (raw === "true" || raw === "false") {
return raw === "true";
}
if (firstChar === lastChar && [`'`, `"`].includes(firstChar)) {
return raw.slice(1, -1);
}
if (isNumericString(raw)) {
return parseFloat(raw);
}
return state[raw];
}
function tokenize(str, parsers) {
let len, match, token;
const tokens = [];
while (str) {
token = null;
len = str.length;
for (const key in parsers) {
match = parsers[key].exec(str);
if (match && match.index < len) {
token = {
token: match[0],
type: key,
matches: match.slice(1)
};
len = match.index;
}
}
if (len) {
tokens.push({
token: str.substr(0, len),
type: void 0
});
}
if (token) {
tokens.push(token);
}
str = str.substr(len + (token ? token.token.length : 0));
}
return tokens;
}
export {
evaluateExpression,
getParamValue,
processor,
tokenizeExpression
};

19
server/node_modules/media-chrome/dist/utils/time.d.ts generated vendored Normal file
View File

@@ -0,0 +1,19 @@
/**
* This function converts numeric seconds into a phrase
* @param {number} seconds - a (positive or negative) time, represented as seconds
* @returns {string} The time, represented as a phrase of hours, minutes, and seconds
*/
export declare const formatAsTimePhrase: (seconds: any) => string;
/**
* Converts a time, in numeric seconds, to a formatted string representation of the form [HH:[MM:]]SS, where hours and minutes
* are optional, either based on the value of `seconds` or (optionally) based on the value of `guide`.
*
* @param seconds - The total time you'd like formatted, in seconds
* @param guide - A number in seconds that represents how many units you'd want to show. This ensures consistent formatting between e.g. 35s and 4834s.
* @returns A string representation of the time, with expected units
*/
export declare function formatTime(seconds: number, guide?: number): string;
export declare const emptyTimeRanges: TimeRanges;
/**
*/
export declare function serializeTimeRanges(timeRanges?: TimeRanges): string;

91
server/node_modules/media-chrome/dist/utils/time.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
import { isValidNumber } from "./utils.js";
const UnitLabels = [
{
singular: "hour",
plural: "hours"
},
{
singular: "minute",
plural: "minutes"
},
{
singular: "second",
plural: "seconds"
}
];
const toTimeUnitPhrase = (timeUnitValue, unitIndex) => {
const unitLabel = timeUnitValue === 1 ? UnitLabels[unitIndex].singular : UnitLabels[unitIndex].plural;
return `${timeUnitValue} ${unitLabel}`;
};
const formatAsTimePhrase = (seconds) => {
if (!isValidNumber(seconds))
return "";
const positiveSeconds = Math.abs(seconds);
const negative = positiveSeconds !== seconds;
const secondsDateTime = new Date(0, 0, 0, 0, 0, positiveSeconds, 0);
const timeParts = [
secondsDateTime.getHours(),
secondsDateTime.getMinutes(),
secondsDateTime.getSeconds()
];
const timeString = timeParts.map(
(timeUnitValue, index) => timeUnitValue && toTimeUnitPhrase(timeUnitValue, index)
).filter((x) => x).join(", ");
const negativeSuffix = negative ? " remaining" : "";
return `${timeString}${negativeSuffix}`;
};
function formatTime(seconds, guide) {
let negative = false;
if (seconds < 0) {
negative = true;
seconds = 0 - seconds;
}
seconds = seconds < 0 ? 0 : seconds;
let s = Math.floor(seconds % 60);
let m = Math.floor(seconds / 60 % 60);
let h = Math.floor(seconds / 3600);
const gm = Math.floor(guide / 60 % 60);
const gh = Math.floor(guide / 3600);
if (isNaN(seconds) || seconds === Infinity) {
h = m = s = "0";
}
h = h > 0 || gh > 0 ? h + ":" : "";
m = ((h || gm >= 10) && m < 10 ? "0" + m : m) + ":";
s = s < 10 ? "0" + s : s;
return (negative ? "-" : "") + h + m + s;
}
const emptyTimeRanges = Object.freeze({
length: 0,
start(index) {
const unsignedIdx = index >>> 0;
if (unsignedIdx >= this.length) {
throw new DOMException(
`Failed to execute 'start' on 'TimeRanges': The index provided (${unsignedIdx}) is greater than or equal to the maximum bound (${this.length}).`
);
}
return 0;
},
end(index) {
const unsignedIdx = index >>> 0;
if (unsignedIdx >= this.length) {
throw new DOMException(
`Failed to execute 'end' on 'TimeRanges': The index provided (${unsignedIdx}) is greater than or equal to the maximum bound (${this.length}).`
);
}
return 0;
}
});
function serializeTimeRanges(timeRanges = emptyTimeRanges) {
return Array.from(timeRanges).map(
(_, i) => [
Number(timeRanges.start(i).toFixed(3)),
Number(timeRanges.end(i).toFixed(3))
].join(":")
).join(" ");
}
export {
emptyTimeRanges,
formatAsTimePhrase,
formatTime,
serializeTimeRanges
};

22
server/node_modules/media-chrome/dist/utils/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,22 @@
import type { Rendition } from '../media-store/state-mediator';
import type { TextTrackLike } from './TextTrackLike.js';
export declare function stringifyRenditionList(renditions: Rendition[]): string;
export declare function parseRenditionList(renditions: string): Rendition[];
export declare function stringifyRendition(rendition: Rendition): string;
export declare function parseRendition(rendition: string): Rendition;
export declare function stringifyAudioTrackList(audioTracks: any[]): string;
export declare function parseAudioTrackList(audioTracks: string): TextTrackLike[];
export declare function stringifyAudioTrack(audioTrack: any): string;
export declare function parseAudioTrack(audioTrack: string): TextTrackLike;
export declare function dashedToCamel(word: string): string;
export declare function constToCamel(word: string, upperFirst?: boolean): string;
export declare function camelCase(name: string): string;
export declare function isValidNumber(x: any): boolean;
export declare function isNumericString(str: any): boolean;
/**
* Returns a promise that will resolve after passed ms.
* @param {number} ms
* @return {Promise}
*/
export declare const delay: (ms: number) => Promise<void>;
export declare const capitalize: (str: string) => string;

81
server/node_modules/media-chrome/dist/utils/utils.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
function stringifyRenditionList(renditions) {
return renditions == null ? void 0 : renditions.map(stringifyRendition).join(" ");
}
function parseRenditionList(renditions) {
return renditions == null ? void 0 : renditions.split(/\s+/).map(parseRendition);
}
function stringifyRendition(rendition) {
if (rendition) {
const { id, width, height } = rendition;
return [id, width, height].filter((a) => a != null).join(":");
}
}
function parseRendition(rendition) {
if (rendition) {
const [id, width, height] = rendition.split(":");
return { id, width: +width, height: +height };
}
}
function stringifyAudioTrackList(audioTracks) {
return audioTracks == null ? void 0 : audioTracks.map(stringifyAudioTrack).join(" ");
}
function parseAudioTrackList(audioTracks) {
return audioTracks == null ? void 0 : audioTracks.split(/\s+/).map(parseAudioTrack);
}
function stringifyAudioTrack(audioTrack) {
if (audioTrack) {
const { id, kind, language, label } = audioTrack;
return [id, kind, language, label].filter((a) => a != null).join(":");
}
}
function parseAudioTrack(audioTrack) {
if (audioTrack) {
const [id, kind, language, label] = audioTrack.split(":");
return {
id,
kind,
language,
label
};
}
}
function dashedToCamel(word) {
return word.split("-").map(function(x, i) {
return (i ? x[0].toUpperCase() : x[0].toLowerCase()) + x.slice(1).toLowerCase();
}).join("");
}
function constToCamel(word, upperFirst = false) {
return word.split("_").map(function(x, i) {
return (i || upperFirst ? x[0].toUpperCase() : x[0].toLowerCase()) + x.slice(1).toLowerCase();
}).join("");
}
function camelCase(name) {
return name.replace(/[-_]([a-z])/g, ($0, $1) => $1.toUpperCase());
}
function isValidNumber(x) {
return typeof x === "number" && !Number.isNaN(x) && Number.isFinite(x);
}
function isNumericString(str) {
if (typeof str != "string")
return false;
return !isNaN(str) && !isNaN(parseFloat(str));
}
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
const capitalize = (str) => str && str[0].toUpperCase() + str.slice(1);
export {
camelCase,
capitalize,
constToCamel,
dashedToCamel,
delay,
isNumericString,
isValidNumber,
parseAudioTrack,
parseAudioTrackList,
parseRendition,
parseRenditionList,
stringifyAudioTrack,
stringifyAudioTrackList,
stringifyRendition,
stringifyRenditionList
};