@onlive.ai/common-121 0.2.32
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/README.md +151 -0
- package/package.json +39 -0
- package/services/audio.service.cjs +75 -0
- package/services/audio.service.d.cts +14 -0
- package/services/audio.service.d.ts +14 -0
- package/services/audio.service.js +52 -0
- package/services/firebase/firebase-api.cjs +108 -0
- package/services/firebase/firebase-api.d.cts +54 -0
- package/services/firebase/firebase-api.d.ts +54 -0
- package/services/firebase/firebase-api.js +105 -0
- package/services/firebase/firebase.service.cjs +193 -0
- package/services/firebase/firebase.service.d.cts +40 -0
- package/services/firebase/firebase.service.d.ts +40 -0
- package/services/firebase/firebase.service.js +190 -0
- package/services/livekit.service.cjs +353 -0
- package/services/livekit.service.d.cts +131 -0
- package/services/livekit.service.d.ts +131 -0
- package/services/livekit.service.js +329 -0
- package/services/request.provider.cjs +48 -0
- package/services/request.provider.d.cts +27 -0
- package/services/request.provider.d.ts +27 -0
- package/services/request.provider.js +22 -0
- package/themes/dark.cjs +433 -0
- package/themes/dark.d.cts +5 -0
- package/themes/dark.d.ts +5 -0
- package/themes/dark.js +408 -0
- package/themes/light.cjs +433 -0
- package/themes/light.d.cts +5 -0
- package/themes/light.d.ts +5 -0
- package/themes/light.js +408 -0
- package/types/tracking-options.cjs +18 -0
- package/types/tracking-options.d.cts +27 -0
- package/types/tracking-options.d.ts +27 -0
- package/types/tracking-options.js +0 -0
- package/types/window-context.cjs +18 -0
- package/types/window-context.d.cts +8 -0
- package/types/window-context.d.ts +8 -0
- package/types/window-context.js +0 -0
- package/utils/adopt-styles.cjs +66 -0
- package/utils/adopt-styles.d.cts +5 -0
- package/utils/adopt-styles.d.ts +5 -0
- package/utils/adopt-styles.js +41 -0
- package/utils/browser-preferences.cjs +67 -0
- package/utils/browser-preferences.d.cts +18 -0
- package/utils/browser-preferences.d.ts +18 -0
- package/utils/browser-preferences.js +42 -0
- package/utils/classify-media.cjs +38 -0
- package/utils/classify-media.d.cts +9 -0
- package/utils/classify-media.d.ts +9 -0
- package/utils/classify-media.js +13 -0
- package/utils/decorators.cjs +53 -0
- package/utils/decorators.d.cts +34 -0
- package/utils/decorators.d.ts +34 -0
- package/utils/decorators.js +28 -0
- package/utils/detected-lang.cjs +47 -0
- package/utils/detected-lang.d.cts +10 -0
- package/utils/detected-lang.d.ts +10 -0
- package/utils/detected-lang.js +22 -0
- package/utils/fullscreen.cjs +52 -0
- package/utils/fullscreen.d.cts +16 -0
- package/utils/fullscreen.d.ts +16 -0
- package/utils/fullscreen.js +26 -0
- package/utils/insert-script.cjs +55 -0
- package/utils/insert-script.d.cts +29 -0
- package/utils/insert-script.d.ts +29 -0
- package/utils/insert-script.js +30 -0
- package/utils/markdown.cjs +103 -0
- package/utils/markdown.d.cts +12 -0
- package/utils/markdown.d.ts +12 -0
- package/utils/markdown.js +68 -0
- package/utils/merge.cjs +47 -0
- package/utils/merge.d.cts +23 -0
- package/utils/merge.d.ts +23 -0
- package/utils/merge.js +22 -0
- package/utils/multiband-track-volume.cjs +90 -0
- package/utils/multiband-track-volume.d.cts +27 -0
- package/utils/multiband-track-volume.d.ts +27 -0
- package/utils/multiband-track-volume.js +65 -0
- package/utils/onlive-url-params.cjs +38 -0
- package/utils/onlive-url-params.d.cts +14 -0
- package/utils/onlive-url-params.d.ts +14 -0
- package/utils/onlive-url-params.js +13 -0
- package/utils/pretty-distance.cjs +45 -0
- package/utils/pretty-distance.d.cts +46 -0
- package/utils/pretty-distance.d.ts +46 -0
- package/utils/pretty-distance.js +20 -0
- package/utils/random-string.cjs +37 -0
- package/utils/random-string.d.cts +9 -0
- package/utils/random-string.d.ts +9 -0
- package/utils/random-string.js +12 -0
- package/utils/resource-type.cjs +50 -0
- package/utils/resource-type.d.cts +16 -0
- package/utils/resource-type.d.ts +16 -0
- package/utils/resource-type.js +24 -0
- package/utils/safe-html.cjs +112 -0
- package/utils/safe-html.d.cts +12 -0
- package/utils/safe-html.d.ts +12 -0
- package/utils/safe-html.js +77 -0
- package/utils/sanitize.cjs +94 -0
- package/utils/sanitize.d.cts +11 -0
- package/utils/sanitize.d.ts +11 -0
- package/utils/sanitize.js +59 -0
- package/utils/spread.cjs +70 -0
- package/utils/spread.d.cts +14 -0
- package/utils/spread.d.ts +14 -0
- package/utils/spread.js +47 -0
- package/utils/watch.cjs +54 -0
- package/utils/watch.d.cts +28 -0
- package/utils/watch.d.ts +28 -0
- package/utils/watch.js +29 -0
- package/vite-env.d.ts +22 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamically inserts a script element into the document head.
|
|
3
|
+
*
|
|
4
|
+
* @param options - Configuration options for the script element
|
|
5
|
+
* @param options.src - The source URL of the script
|
|
6
|
+
* @param options.async - Whether to load the script asynchronously (default: false)
|
|
7
|
+
* @param options.defer - Whether to defer loading the script (default: false)
|
|
8
|
+
* @param options.module - Whether to set type as "module" (default: false)
|
|
9
|
+
* @param options.system - Whether to set type as "systemjs-module" (default: false)
|
|
10
|
+
*
|
|
11
|
+
* @returns Promise that resolves when the script is loaded or rejects if loading fails
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* await insertScript({
|
|
16
|
+
* src: 'https://example.com/script.js',
|
|
17
|
+
* async: true
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const insertScript: ({ src, async, defer, module, system, }: {
|
|
22
|
+
src?: string | undefined;
|
|
23
|
+
async?: boolean | undefined;
|
|
24
|
+
defer?: boolean | undefined;
|
|
25
|
+
module?: boolean | undefined;
|
|
26
|
+
system?: boolean | undefined;
|
|
27
|
+
}) => Promise<unknown>;
|
|
28
|
+
|
|
29
|
+
export { insertScript };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// utils/insert-script.ts
|
|
2
|
+
var insertScript = async ({
|
|
3
|
+
src = "",
|
|
4
|
+
async = false,
|
|
5
|
+
defer = false,
|
|
6
|
+
module = false,
|
|
7
|
+
system = false
|
|
8
|
+
}) => new Promise((resolve, reject) => {
|
|
9
|
+
const el = document.createElement("script");
|
|
10
|
+
el.src = src;
|
|
11
|
+
if (async) {
|
|
12
|
+
el.async = true;
|
|
13
|
+
}
|
|
14
|
+
if (defer) {
|
|
15
|
+
el.defer = true;
|
|
16
|
+
}
|
|
17
|
+
if (module) {
|
|
18
|
+
el.type = "module";
|
|
19
|
+
} else if (system) {
|
|
20
|
+
el.type = "systemjs-module";
|
|
21
|
+
} else {
|
|
22
|
+
el.type = "text/javascript";
|
|
23
|
+
}
|
|
24
|
+
el.addEventListener("load", resolve);
|
|
25
|
+
el.addEventListener("error", reject);
|
|
26
|
+
document.head.append(el);
|
|
27
|
+
});
|
|
28
|
+
export {
|
|
29
|
+
insertScript
|
|
30
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// utils/markdown.ts
|
|
31
|
+
var markdown_exports = {};
|
|
32
|
+
__export(markdown_exports, {
|
|
33
|
+
markdown: () => markdown
|
|
34
|
+
});
|
|
35
|
+
module.exports = __toCommonJS(markdown_exports);
|
|
36
|
+
var import_marked = require("marked");
|
|
37
|
+
|
|
38
|
+
// utils/sanitize.js
|
|
39
|
+
var import_dompurify = __toESM(require("dompurify"), 1);
|
|
40
|
+
var DEFAULT_PURIFY_CONFIG = {
|
|
41
|
+
ALLOWED_TAGS: [
|
|
42
|
+
// Text formatting
|
|
43
|
+
"p",
|
|
44
|
+
"br",
|
|
45
|
+
"span",
|
|
46
|
+
"b",
|
|
47
|
+
"strong",
|
|
48
|
+
"i",
|
|
49
|
+
"em",
|
|
50
|
+
"u",
|
|
51
|
+
"s",
|
|
52
|
+
"del",
|
|
53
|
+
// Lists
|
|
54
|
+
"ul",
|
|
55
|
+
"ol",
|
|
56
|
+
"li",
|
|
57
|
+
// Code
|
|
58
|
+
"code",
|
|
59
|
+
"pre",
|
|
60
|
+
// Links
|
|
61
|
+
"a",
|
|
62
|
+
// Headers (limited)
|
|
63
|
+
"h1",
|
|
64
|
+
"h2",
|
|
65
|
+
"h3",
|
|
66
|
+
"h4",
|
|
67
|
+
// Tables
|
|
68
|
+
"table",
|
|
69
|
+
"thead",
|
|
70
|
+
"tbody",
|
|
71
|
+
"tr",
|
|
72
|
+
"th",
|
|
73
|
+
"td"
|
|
74
|
+
],
|
|
75
|
+
ALLOWED_ATTR: [
|
|
76
|
+
// Links
|
|
77
|
+
"href",
|
|
78
|
+
"target",
|
|
79
|
+
"rel",
|
|
80
|
+
// Accessibility
|
|
81
|
+
"title",
|
|
82
|
+
"aria-label",
|
|
83
|
+
"role",
|
|
84
|
+
// Tables
|
|
85
|
+
"colspan",
|
|
86
|
+
"rowspan"
|
|
87
|
+
],
|
|
88
|
+
FORCE_HTTPS: true,
|
|
89
|
+
ALLOW_DATA_ATTR: false
|
|
90
|
+
};
|
|
91
|
+
var sanitize = (html, purifyConfig = DEFAULT_PURIFY_CONFIG) => {
|
|
92
|
+
return import_dompurify.default.sanitize(html, purifyConfig);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// utils/markdown.ts
|
|
96
|
+
var import_unsafe_html = require("lit/directives/unsafe-html.js");
|
|
97
|
+
var markdown = (text) => {
|
|
98
|
+
return (0, import_unsafe_html.unsafeHTML)(sanitize(import_marked.marked.parse(text)));
|
|
99
|
+
};
|
|
100
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
101
|
+
0 && (module.exports = {
|
|
102
|
+
markdown
|
|
103
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as lit_directive_js from 'lit/directive.js';
|
|
2
|
+
import * as lit_directives_unsafe_html_js from 'lit/directives/unsafe-html.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parses a given text string into HTML using the Marked markdown parser
|
|
6
|
+
*
|
|
7
|
+
* @param {string} text - The markdown text to be parsed
|
|
8
|
+
* @returns {string} The parsed HTML string
|
|
9
|
+
*/
|
|
10
|
+
declare const markdown: (text: string) => lit_directive_js.DirectiveResult<typeof lit_directives_unsafe_html_js.UnsafeHTMLDirective>;
|
|
11
|
+
|
|
12
|
+
export { markdown };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as lit_directive_js from 'lit/directive.js';
|
|
2
|
+
import * as lit_directives_unsafe_html_js from 'lit/directives/unsafe-html.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Parses a given text string into HTML using the Marked markdown parser
|
|
6
|
+
*
|
|
7
|
+
* @param {string} text - The markdown text to be parsed
|
|
8
|
+
* @returns {string} The parsed HTML string
|
|
9
|
+
*/
|
|
10
|
+
declare const markdown: (text: string) => lit_directive_js.DirectiveResult<typeof lit_directives_unsafe_html_js.UnsafeHTMLDirective>;
|
|
11
|
+
|
|
12
|
+
export { markdown };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// utils/markdown.ts
|
|
2
|
+
import { marked } from "marked";
|
|
3
|
+
|
|
4
|
+
// utils/sanitize.js
|
|
5
|
+
import DOMPurify from "dompurify";
|
|
6
|
+
var DEFAULT_PURIFY_CONFIG = {
|
|
7
|
+
ALLOWED_TAGS: [
|
|
8
|
+
// Text formatting
|
|
9
|
+
"p",
|
|
10
|
+
"br",
|
|
11
|
+
"span",
|
|
12
|
+
"b",
|
|
13
|
+
"strong",
|
|
14
|
+
"i",
|
|
15
|
+
"em",
|
|
16
|
+
"u",
|
|
17
|
+
"s",
|
|
18
|
+
"del",
|
|
19
|
+
// Lists
|
|
20
|
+
"ul",
|
|
21
|
+
"ol",
|
|
22
|
+
"li",
|
|
23
|
+
// Code
|
|
24
|
+
"code",
|
|
25
|
+
"pre",
|
|
26
|
+
// Links
|
|
27
|
+
"a",
|
|
28
|
+
// Headers (limited)
|
|
29
|
+
"h1",
|
|
30
|
+
"h2",
|
|
31
|
+
"h3",
|
|
32
|
+
"h4",
|
|
33
|
+
// Tables
|
|
34
|
+
"table",
|
|
35
|
+
"thead",
|
|
36
|
+
"tbody",
|
|
37
|
+
"tr",
|
|
38
|
+
"th",
|
|
39
|
+
"td"
|
|
40
|
+
],
|
|
41
|
+
ALLOWED_ATTR: [
|
|
42
|
+
// Links
|
|
43
|
+
"href",
|
|
44
|
+
"target",
|
|
45
|
+
"rel",
|
|
46
|
+
// Accessibility
|
|
47
|
+
"title",
|
|
48
|
+
"aria-label",
|
|
49
|
+
"role",
|
|
50
|
+
// Tables
|
|
51
|
+
"colspan",
|
|
52
|
+
"rowspan"
|
|
53
|
+
],
|
|
54
|
+
FORCE_HTTPS: true,
|
|
55
|
+
ALLOW_DATA_ATTR: false
|
|
56
|
+
};
|
|
57
|
+
var sanitize = (html, purifyConfig = DEFAULT_PURIFY_CONFIG) => {
|
|
58
|
+
return DOMPurify.sanitize(html, purifyConfig);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// utils/markdown.ts
|
|
62
|
+
import { unsafeHTML } from "lit/directives/unsafe-html.js";
|
|
63
|
+
var markdown = (text) => {
|
|
64
|
+
return unsafeHTML(sanitize(marked.parse(text)));
|
|
65
|
+
};
|
|
66
|
+
export {
|
|
67
|
+
markdown
|
|
68
|
+
};
|
package/utils/merge.cjs
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// utils/merge.ts
|
|
21
|
+
var merge_exports = {};
|
|
22
|
+
__export(merge_exports, {
|
|
23
|
+
merge: () => merge
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(merge_exports);
|
|
26
|
+
var merge = (object, ...sources) => {
|
|
27
|
+
if (!sources.length) return object;
|
|
28
|
+
const source = sources.shift();
|
|
29
|
+
const isObject = (item) => {
|
|
30
|
+
return Boolean(item) && typeof item === "object" && !Array.isArray(item);
|
|
31
|
+
};
|
|
32
|
+
if (isObject(object) && isObject(source)) {
|
|
33
|
+
for (const key in source) {
|
|
34
|
+
if (isObject(source[key])) {
|
|
35
|
+
if (!object[key]) Object.assign(object, { [key]: {} });
|
|
36
|
+
merge(object[key], source[key]);
|
|
37
|
+
} else {
|
|
38
|
+
Object.assign(object, { [key]: source[key] });
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return merge(object, ...sources);
|
|
43
|
+
};
|
|
44
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
45
|
+
0 && (module.exports = {
|
|
46
|
+
merge
|
|
47
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deeply merges multiple source objects into a target object.
|
|
3
|
+
* Properties from subsequent sources override those from previous ones.
|
|
4
|
+
* Arrays and primitive values are overwritten, while objects are merged recursively.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TObject - Type of the target object
|
|
7
|
+
* @typeParam TSource - Type of the source objects
|
|
8
|
+
*
|
|
9
|
+
* @param object - The target object to merge into
|
|
10
|
+
* @param sources - One or more source objects to merge from
|
|
11
|
+
*
|
|
12
|
+
* @returns A new object containing the merged properties from both the target and source objects
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const target = { a: { b: 1 } };
|
|
17
|
+
* const source = { a: { c: 2 } };
|
|
18
|
+
* merge(target, source); // { a: { b: 1, c: 2 } }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const merge: <TObject extends Record<string, any>, TSource>(object: TObject, ...sources: TSource[]) => TObject & TSource;
|
|
22
|
+
|
|
23
|
+
export { merge };
|
package/utils/merge.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deeply merges multiple source objects into a target object.
|
|
3
|
+
* Properties from subsequent sources override those from previous ones.
|
|
4
|
+
* Arrays and primitive values are overwritten, while objects are merged recursively.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam TObject - Type of the target object
|
|
7
|
+
* @typeParam TSource - Type of the source objects
|
|
8
|
+
*
|
|
9
|
+
* @param object - The target object to merge into
|
|
10
|
+
* @param sources - One or more source objects to merge from
|
|
11
|
+
*
|
|
12
|
+
* @returns A new object containing the merged properties from both the target and source objects
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const target = { a: { b: 1 } };
|
|
17
|
+
* const source = { a: { c: 2 } };
|
|
18
|
+
* merge(target, source); // { a: { b: 1, c: 2 } }
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare const merge: <TObject extends Record<string, any>, TSource>(object: TObject, ...sources: TSource[]) => TObject & TSource;
|
|
22
|
+
|
|
23
|
+
export { merge };
|
package/utils/merge.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// utils/merge.ts
|
|
2
|
+
var merge = (object, ...sources) => {
|
|
3
|
+
if (!sources.length) return object;
|
|
4
|
+
const source = sources.shift();
|
|
5
|
+
const isObject = (item) => {
|
|
6
|
+
return Boolean(item) && typeof item === "object" && !Array.isArray(item);
|
|
7
|
+
};
|
|
8
|
+
if (isObject(object) && isObject(source)) {
|
|
9
|
+
for (const key in source) {
|
|
10
|
+
if (isObject(source[key])) {
|
|
11
|
+
if (!object[key]) Object.assign(object, { [key]: {} });
|
|
12
|
+
merge(object[key], source[key]);
|
|
13
|
+
} else {
|
|
14
|
+
Object.assign(object, { [key]: source[key] });
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return merge(object, ...sources);
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
merge
|
|
22
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// utils/multiband-track-volume.ts
|
|
21
|
+
var multiband_track_volume_exports = {};
|
|
22
|
+
__export(multiband_track_volume_exports, {
|
|
23
|
+
multibandTrackVolume: () => multibandTrackVolume
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(multiband_track_volume_exports);
|
|
26
|
+
var import_livekit_client = require("livekit-client");
|
|
27
|
+
var import_rxjs = require("rxjs");
|
|
28
|
+
var multibandDefaults = {
|
|
29
|
+
bands: 5,
|
|
30
|
+
loPass: 100,
|
|
31
|
+
hiPass: 600,
|
|
32
|
+
updateInterval: 32,
|
|
33
|
+
analyserOptions: { fftSize: 2048 }
|
|
34
|
+
};
|
|
35
|
+
var multibandTrackVolume = (track, options = {}) => {
|
|
36
|
+
const opts = { ...multibandDefaults, ...options };
|
|
37
|
+
const volumesSubject = new import_rxjs.BehaviorSubject(new Array(opts.bands).fill(0));
|
|
38
|
+
const volumesObservable = volumesSubject.asObservable();
|
|
39
|
+
if (!track || !track?.mediaStream) {
|
|
40
|
+
return { cleanup: () => {
|
|
41
|
+
}, volumesObservable };
|
|
42
|
+
}
|
|
43
|
+
const { analyser, cleanup: audioCleanup } = (0, import_livekit_client.createAudioAnalyser)(track, opts.analyserOptions);
|
|
44
|
+
const bufferLength = analyser.frequencyBinCount;
|
|
45
|
+
const dataArray = new Float32Array(bufferLength);
|
|
46
|
+
const updateVolume = () => {
|
|
47
|
+
analyser.getFloatFrequencyData(dataArray);
|
|
48
|
+
let frequencies = new Float32Array(dataArray.length);
|
|
49
|
+
for (let i = 0; i < dataArray.length; i++) {
|
|
50
|
+
frequencies[i] = dataArray[i];
|
|
51
|
+
}
|
|
52
|
+
frequencies = frequencies.slice(options.loPass, options.hiPass);
|
|
53
|
+
const normalizedFrequencies = normalizeFrequencies(frequencies);
|
|
54
|
+
const chunkSize = Math.ceil(normalizedFrequencies.length / opts.bands);
|
|
55
|
+
const chunks = [];
|
|
56
|
+
for (let i = 0; i < opts.bands; i++) {
|
|
57
|
+
const summedVolumes = normalizedFrequencies.slice(i * chunkSize, (i + 1) * chunkSize).reduce((acc, val) => acc += val, 0);
|
|
58
|
+
chunks.push(summedVolumes / chunkSize);
|
|
59
|
+
}
|
|
60
|
+
if (JSON.stringify(chunks) !== JSON.stringify(volumesSubject.getValue())) {
|
|
61
|
+
volumesSubject.next(chunks);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const interval = setInterval(updateVolume, opts.updateInterval);
|
|
65
|
+
const cleanup = () => {
|
|
66
|
+
clearInterval(interval);
|
|
67
|
+
audioCleanup();
|
|
68
|
+
volumesSubject.complete();
|
|
69
|
+
};
|
|
70
|
+
return { cleanup, volumesObservable };
|
|
71
|
+
};
|
|
72
|
+
var normalizeFrequencies = (frequencies) => {
|
|
73
|
+
const normalizeDb = (value) => {
|
|
74
|
+
const minDb = -100;
|
|
75
|
+
const maxDb = -10;
|
|
76
|
+
let db = 1 - Math.max(minDb, Math.min(maxDb, value)) * -1 / 100;
|
|
77
|
+
db = Math.sqrt(db);
|
|
78
|
+
return db;
|
|
79
|
+
};
|
|
80
|
+
return frequencies.map((value) => {
|
|
81
|
+
if (value === -Infinity) {
|
|
82
|
+
return 0;
|
|
83
|
+
}
|
|
84
|
+
return normalizeDb(value);
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
88
|
+
0 && (module.exports = {
|
|
89
|
+
multibandTrackVolume
|
|
90
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RemoteAudioTrack } from 'livekit-client';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
interface MultiBandTrackVolumeOptions {
|
|
5
|
+
bands?: number;
|
|
6
|
+
/**
|
|
7
|
+
* cut off of frequency bins on the lower end
|
|
8
|
+
* Note: this is not a frequency measure, but in relation to analyserOptions.fftSize,
|
|
9
|
+
*/
|
|
10
|
+
loPass?: number;
|
|
11
|
+
/**
|
|
12
|
+
* cut off of frequency bins on the higher end
|
|
13
|
+
* Note: this is not a frequency measure, but in relation to analyserOptions.fftSize,
|
|
14
|
+
*/
|
|
15
|
+
hiPass?: number;
|
|
16
|
+
/**
|
|
17
|
+
* update should run every x ms
|
|
18
|
+
*/
|
|
19
|
+
updateInterval?: number;
|
|
20
|
+
analyserOptions?: AnalyserOptions;
|
|
21
|
+
}
|
|
22
|
+
declare const multibandTrackVolume: (track: RemoteAudioTrack, options?: MultiBandTrackVolumeOptions) => {
|
|
23
|
+
cleanup: () => void;
|
|
24
|
+
volumesObservable: Observable<number[]>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { type MultiBandTrackVolumeOptions, multibandTrackVolume };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { RemoteAudioTrack } from 'livekit-client';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
|
|
4
|
+
interface MultiBandTrackVolumeOptions {
|
|
5
|
+
bands?: number;
|
|
6
|
+
/**
|
|
7
|
+
* cut off of frequency bins on the lower end
|
|
8
|
+
* Note: this is not a frequency measure, but in relation to analyserOptions.fftSize,
|
|
9
|
+
*/
|
|
10
|
+
loPass?: number;
|
|
11
|
+
/**
|
|
12
|
+
* cut off of frequency bins on the higher end
|
|
13
|
+
* Note: this is not a frequency measure, but in relation to analyserOptions.fftSize,
|
|
14
|
+
*/
|
|
15
|
+
hiPass?: number;
|
|
16
|
+
/**
|
|
17
|
+
* update should run every x ms
|
|
18
|
+
*/
|
|
19
|
+
updateInterval?: number;
|
|
20
|
+
analyserOptions?: AnalyserOptions;
|
|
21
|
+
}
|
|
22
|
+
declare const multibandTrackVolume: (track: RemoteAudioTrack, options?: MultiBandTrackVolumeOptions) => {
|
|
23
|
+
cleanup: () => void;
|
|
24
|
+
volumesObservable: Observable<number[]>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { type MultiBandTrackVolumeOptions, multibandTrackVolume };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// utils/multiband-track-volume.ts
|
|
2
|
+
import { createAudioAnalyser } from "livekit-client";
|
|
3
|
+
import { BehaviorSubject } from "rxjs";
|
|
4
|
+
var multibandDefaults = {
|
|
5
|
+
bands: 5,
|
|
6
|
+
loPass: 100,
|
|
7
|
+
hiPass: 600,
|
|
8
|
+
updateInterval: 32,
|
|
9
|
+
analyserOptions: { fftSize: 2048 }
|
|
10
|
+
};
|
|
11
|
+
var multibandTrackVolume = (track, options = {}) => {
|
|
12
|
+
const opts = { ...multibandDefaults, ...options };
|
|
13
|
+
const volumesSubject = new BehaviorSubject(new Array(opts.bands).fill(0));
|
|
14
|
+
const volumesObservable = volumesSubject.asObservable();
|
|
15
|
+
if (!track || !track?.mediaStream) {
|
|
16
|
+
return { cleanup: () => {
|
|
17
|
+
}, volumesObservable };
|
|
18
|
+
}
|
|
19
|
+
const { analyser, cleanup: audioCleanup } = createAudioAnalyser(track, opts.analyserOptions);
|
|
20
|
+
const bufferLength = analyser.frequencyBinCount;
|
|
21
|
+
const dataArray = new Float32Array(bufferLength);
|
|
22
|
+
const updateVolume = () => {
|
|
23
|
+
analyser.getFloatFrequencyData(dataArray);
|
|
24
|
+
let frequencies = new Float32Array(dataArray.length);
|
|
25
|
+
for (let i = 0; i < dataArray.length; i++) {
|
|
26
|
+
frequencies[i] = dataArray[i];
|
|
27
|
+
}
|
|
28
|
+
frequencies = frequencies.slice(options.loPass, options.hiPass);
|
|
29
|
+
const normalizedFrequencies = normalizeFrequencies(frequencies);
|
|
30
|
+
const chunkSize = Math.ceil(normalizedFrequencies.length / opts.bands);
|
|
31
|
+
const chunks = [];
|
|
32
|
+
for (let i = 0; i < opts.bands; i++) {
|
|
33
|
+
const summedVolumes = normalizedFrequencies.slice(i * chunkSize, (i + 1) * chunkSize).reduce((acc, val) => acc += val, 0);
|
|
34
|
+
chunks.push(summedVolumes / chunkSize);
|
|
35
|
+
}
|
|
36
|
+
if (JSON.stringify(chunks) !== JSON.stringify(volumesSubject.getValue())) {
|
|
37
|
+
volumesSubject.next(chunks);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const interval = setInterval(updateVolume, opts.updateInterval);
|
|
41
|
+
const cleanup = () => {
|
|
42
|
+
clearInterval(interval);
|
|
43
|
+
audioCleanup();
|
|
44
|
+
volumesSubject.complete();
|
|
45
|
+
};
|
|
46
|
+
return { cleanup, volumesObservable };
|
|
47
|
+
};
|
|
48
|
+
var normalizeFrequencies = (frequencies) => {
|
|
49
|
+
const normalizeDb = (value) => {
|
|
50
|
+
const minDb = -100;
|
|
51
|
+
const maxDb = -10;
|
|
52
|
+
let db = 1 - Math.max(minDb, Math.min(maxDb, value)) * -1 / 100;
|
|
53
|
+
db = Math.sqrt(db);
|
|
54
|
+
return db;
|
|
55
|
+
};
|
|
56
|
+
return frequencies.map((value) => {
|
|
57
|
+
if (value === -Infinity) {
|
|
58
|
+
return 0;
|
|
59
|
+
}
|
|
60
|
+
return normalizeDb(value);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
export {
|
|
64
|
+
multibandTrackVolume
|
|
65
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// utils/onlive-url-params.ts
|
|
21
|
+
var onlive_url_params_exports = {};
|
|
22
|
+
__export(onlive_url_params_exports, {
|
|
23
|
+
onliveUrlParams: () => onliveUrlParams
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(onlive_url_params_exports);
|
|
26
|
+
var onliveUrlParams = () => {
|
|
27
|
+
const params = {};
|
|
28
|
+
new URLSearchParams(window.location.search).forEach((value, key) => {
|
|
29
|
+
if (key.startsWith("ol")) {
|
|
30
|
+
params[key.substring(2).replace(/^./, (c) => c.toLowerCase())] = value;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
return params;
|
|
34
|
+
};
|
|
35
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
36
|
+
0 && (module.exports = {
|
|
37
|
+
onliveUrlParams
|
|
38
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts Onlive-specific URL parameters from the current URL.
|
|
3
|
+
*
|
|
4
|
+
* This function filters URL parameters that start with "ol" and transforms them:
|
|
5
|
+
* - Removes the "ol" prefix
|
|
6
|
+
* - Converts the first character after the prefix to lowercase
|
|
7
|
+
*
|
|
8
|
+
* For example, "olParameter=value" becomes { parameter: "value" } in the returned object.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Record<string, string>} An object containing the transformed Onlive parameters
|
|
11
|
+
*/
|
|
12
|
+
declare const onliveUrlParams: () => Record<string, string>;
|
|
13
|
+
|
|
14
|
+
export { onliveUrlParams };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extracts Onlive-specific URL parameters from the current URL.
|
|
3
|
+
*
|
|
4
|
+
* This function filters URL parameters that start with "ol" and transforms them:
|
|
5
|
+
* - Removes the "ol" prefix
|
|
6
|
+
* - Converts the first character after the prefix to lowercase
|
|
7
|
+
*
|
|
8
|
+
* For example, "olParameter=value" becomes { parameter: "value" } in the returned object.
|
|
9
|
+
*
|
|
10
|
+
* @returns {Record<string, string>} An object containing the transformed Onlive parameters
|
|
11
|
+
*/
|
|
12
|
+
declare const onliveUrlParams: () => Record<string, string>;
|
|
13
|
+
|
|
14
|
+
export { onliveUrlParams };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// utils/onlive-url-params.ts
|
|
2
|
+
var onliveUrlParams = () => {
|
|
3
|
+
const params = {};
|
|
4
|
+
new URLSearchParams(window.location.search).forEach((value, key) => {
|
|
5
|
+
if (key.startsWith("ol")) {
|
|
6
|
+
params[key.substring(2).replace(/^./, (c) => c.toLowerCase())] = value;
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
return params;
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
onliveUrlParams
|
|
13
|
+
};
|