@onlive.ai/common-121 0.2.32 → 0.2.40

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.
Files changed (58) hide show
  1. package/package.json +2 -4
  2. package/services/audio.service.cjs +2 -75
  3. package/services/audio.service.js +2 -52
  4. package/services/firebase/firebase-api.cjs +2 -108
  5. package/services/firebase/firebase-api.js +2 -105
  6. package/services/firebase/firebase.service.cjs +2 -193
  7. package/services/firebase/firebase.service.js +2 -190
  8. package/services/livekit.service.cjs +2 -353
  9. package/services/livekit.service.d.cts +1 -1
  10. package/services/livekit.service.d.ts +1 -1
  11. package/services/livekit.service.js +2 -329
  12. package/services/request.provider.cjs +2 -48
  13. package/services/request.provider.js +2 -22
  14. package/themes/dark.cjs +3 -32
  15. package/themes/dark.js +3 -7
  16. package/themes/light.cjs +3 -32
  17. package/themes/light.js +3 -7
  18. package/types/tracking-options.cjs +2 -18
  19. package/types/tracking-options.js +1 -0
  20. package/types/window-context.cjs +2 -18
  21. package/types/window-context.js +1 -0
  22. package/utils/adopt-styles.cjs +2 -66
  23. package/utils/adopt-styles.js +2 -41
  24. package/utils/browser-preferences.cjs +2 -67
  25. package/utils/browser-preferences.js +2 -42
  26. package/utils/classify-media.cjs +2 -38
  27. package/utils/classify-media.js +2 -13
  28. package/utils/decorators.cjs +2 -53
  29. package/utils/decorators.js +2 -28
  30. package/utils/detected-lang.cjs +2 -47
  31. package/utils/detected-lang.js +2 -22
  32. package/utils/fullscreen.cjs +2 -52
  33. package/utils/fullscreen.js +2 -26
  34. package/utils/insert-script.cjs +2 -55
  35. package/utils/insert-script.js +2 -30
  36. package/utils/markdown.cjs +2 -103
  37. package/utils/markdown.js +2 -68
  38. package/utils/merge.cjs +2 -47
  39. package/utils/merge.js +2 -22
  40. package/utils/multiband-track-volume.cjs +2 -90
  41. package/utils/multiband-track-volume.js +2 -65
  42. package/utils/onlive-url-params.cjs +2 -38
  43. package/utils/onlive-url-params.js +2 -13
  44. package/utils/pretty-distance.cjs +2 -45
  45. package/utils/pretty-distance.js +2 -20
  46. package/utils/random-string.cjs +2 -37
  47. package/utils/random-string.js +2 -12
  48. package/utils/resource-type.cjs +2 -50
  49. package/utils/resource-type.js +2 -24
  50. package/utils/safe-html.cjs +2 -112
  51. package/utils/safe-html.js +2 -77
  52. package/utils/sanitize.cjs +2 -94
  53. package/utils/sanitize.js +2 -59
  54. package/utils/spread.cjs +2 -70
  55. package/utils/spread.js +2 -47
  56. package/utils/watch.cjs +2 -54
  57. package/utils/watch.js +2 -29
  58. package/vite-env.d.ts +0 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlive.ai/common-121",
3
- "version": "0.2.32",
3
+ "version": "0.2.40",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "**/*.js",
@@ -20,7 +20,7 @@
20
20
  "dependencies": {
21
21
  "@formatjs/intl-localematcher": "^0.5.10",
22
22
  "@livekit/components-core": "^0.12.5",
23
- "@onlive.ai/tracker": "^1.0.7",
23
+ "@onlive.ai/tracker": "^1.0.9",
24
24
  "dompurify": "^3.2.5",
25
25
  "firebase": "^11.7.3",
26
26
  "lit": "^3.3.0",
@@ -32,8 +32,6 @@
32
32
  },
33
33
  "scripts": {
34
34
  "build:package": "tsup",
35
- "test": "vitest",
36
- "test:coverage": "vitest --coverage",
37
35
  "clean": "find . \\( -iname \"*.js\" -o -iname \"*.cjs\" -o -iname \"*.d.ts\" -o -iname \"*.d.cts\" \\) -type f -not -path \"./node_modules/*\" -delete"
38
36
  }
39
37
  }
@@ -1,75 +1,2 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
-
22
- // services/audio.service.ts
23
- var audio_service_exports = {};
24
- __export(audio_service_exports, {
25
- AudioService: () => AudioService
26
- });
27
- module.exports = __toCommonJS(audio_service_exports);
28
- var _AudioService = class _AudioService {
29
- constructor() {
30
- __publicField(this, "sounds", /* @__PURE__ */ new Map());
31
- __publicField(this, "currentSound", null);
32
- this.loadSound("ringing", "https://a.slack-edge.com/bv1-13/flitterbug-77334dc.mp3");
33
- this.loadSound("incoming", "https://cdn.onlive.ai/widget-assets/call_phone_ring_tone.mp3");
34
- }
35
- static getInstance() {
36
- if (!_AudioService.instance) {
37
- _AudioService.instance = new _AudioService();
38
- }
39
- return _AudioService.instance;
40
- }
41
- loadSound(name, url) {
42
- const audio = new Audio(url);
43
- audio.preload = "auto";
44
- this.sounds.set(name, audio);
45
- }
46
- playSound(name, loop = false) {
47
- this.stopCurrentSound();
48
- const sound = this.sounds.get(name);
49
- if (sound) {
50
- sound.loop = loop;
51
- sound.currentTime = 0;
52
- sound.play().catch((error) => console.warn("Error playing sound:", error));
53
- this.currentSound = sound;
54
- }
55
- }
56
- stopCurrentSound() {
57
- if (this.currentSound) {
58
- this.currentSound.pause();
59
- this.currentSound.currentTime = 0;
60
- this.currentSound = null;
61
- }
62
- }
63
- playRinging(loop = true) {
64
- this.playSound("ringing", loop);
65
- }
66
- playIncoming(loop = true) {
67
- this.playSound("incoming", loop);
68
- }
69
- };
70
- __publicField(_AudioService, "instance");
71
- var AudioService = _AudioService;
72
- // Annotate the CommonJS export names for ESM import in node:
73
- 0 && (module.exports = {
74
- AudioService
75
- });
1
+ /*! @onlive.ai/common-121 v0.2.40 | © 2025 Onlive.ai */
2
+ "use strict";var u=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var l=Object.prototype.hasOwnProperty;var p=(t,n,i)=>n in t?u(t,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[n]=i;var g=(t,n)=>{for(var i in n)u(t,i,{get:n[i],enumerable:!0})},h=(t,n,i,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of d(n))!l.call(t,e)&&e!==i&&u(t,e,{get:()=>n[e],enumerable:!(o=c(n,e))||o.enumerable});return t};var S=t=>h(u({},"__esModule",{value:!0}),t);var r=(t,n,i)=>p(t,typeof n!="symbol"?n+"":n,i);var v={};g(v,{AudioService:()=>a});module.exports=S(v);var s=class s{constructor(){r(this,"sounds",new Map);r(this,"currentSound",null);this.loadSound("ringing","https://a.slack-edge.com/bv1-13/flitterbug-77334dc.mp3"),this.loadSound("incoming","https://cdn.onlive.site/widget-assets/call_phone_ring_tone.mp3")}static getInstance(){return s.instance||(s.instance=new s),s.instance}loadSound(n,i){let o=new Audio(i);o.preload="auto",this.sounds.set(n,o)}playSound(n,i=!1){this.stopCurrentSound();let o=this.sounds.get(n);o&&(o.loop=i,o.currentTime=0,o.play().catch(e=>console.warn("Error playing sound:",e)),this.currentSound=o)}stopCurrentSound(){this.currentSound&&(this.currentSound.pause(),this.currentSound.currentTime=0,this.currentSound=null)}playRinging(n=!0){this.playSound("ringing",n)}playIncoming(n=!0){this.playSound("incoming",n)}};r(s,"instance");var a=s;0&&(module.exports={AudioService});
@@ -1,52 +1,2 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
-
5
- // services/audio.service.ts
6
- var _AudioService = class _AudioService {
7
- constructor() {
8
- __publicField(this, "sounds", /* @__PURE__ */ new Map());
9
- __publicField(this, "currentSound", null);
10
- this.loadSound("ringing", "https://a.slack-edge.com/bv1-13/flitterbug-77334dc.mp3");
11
- this.loadSound("incoming", "https://cdn.onlive.ai/widget-assets/call_phone_ring_tone.mp3");
12
- }
13
- static getInstance() {
14
- if (!_AudioService.instance) {
15
- _AudioService.instance = new _AudioService();
16
- }
17
- return _AudioService.instance;
18
- }
19
- loadSound(name, url) {
20
- const audio = new Audio(url);
21
- audio.preload = "auto";
22
- this.sounds.set(name, audio);
23
- }
24
- playSound(name, loop = false) {
25
- this.stopCurrentSound();
26
- const sound = this.sounds.get(name);
27
- if (sound) {
28
- sound.loop = loop;
29
- sound.currentTime = 0;
30
- sound.play().catch((error) => console.warn("Error playing sound:", error));
31
- this.currentSound = sound;
32
- }
33
- }
34
- stopCurrentSound() {
35
- if (this.currentSound) {
36
- this.currentSound.pause();
37
- this.currentSound.currentTime = 0;
38
- this.currentSound = null;
39
- }
40
- }
41
- playRinging(loop = true) {
42
- this.playSound("ringing", loop);
43
- }
44
- playIncoming(loop = true) {
45
- this.playSound("incoming", loop);
46
- }
47
- };
48
- __publicField(_AudioService, "instance");
49
- var AudioService = _AudioService;
50
- export {
51
- AudioService
52
- };
1
+ /*! @onlive.ai/common-121 v0.2.40 | © 2025 Onlive.ai */
2
+ var a=Object.defineProperty;var c=(e,n,t)=>n in e?a(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t;var s=(e,n,t)=>c(e,typeof n!="symbol"?n+"":n,t);var o=class o{constructor(){s(this,"sounds",new Map);s(this,"currentSound",null);this.loadSound("ringing","https://a.slack-edge.com/bv1-13/flitterbug-77334dc.mp3"),this.loadSound("incoming","https://cdn.onlive.site/widget-assets/call_phone_ring_tone.mp3")}static getInstance(){return o.instance||(o.instance=new o),o.instance}loadSound(n,t){let i=new Audio(t);i.preload="auto",this.sounds.set(n,i)}playSound(n,t=!1){this.stopCurrentSound();let i=this.sounds.get(n);i&&(i.loop=t,i.currentTime=0,i.play().catch(r=>console.warn("Error playing sound:",r)),this.currentSound=i)}stopCurrentSound(){this.currentSound&&(this.currentSound.pause(),this.currentSound.currentTime=0,this.currentSound=null)}playRinging(n=!0){this.playSound("ringing",n)}playIncoming(n=!0){this.playSound("incoming",n)}};s(o,"instance");var u=o;export{u as AudioService};
@@ -1,108 +1,2 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
-
22
- // services/firebase/firebase-api.ts
23
- var firebase_api_exports = {};
24
- __export(firebase_api_exports, {
25
- FirebaseApi: () => FirebaseApi
26
- });
27
- module.exports = __toCommonJS(firebase_api_exports);
28
- var import_app = require("firebase/app");
29
- var import_database = require("firebase/database");
30
- var FirebaseApi = class {
31
- constructor(options) {
32
- __publicField(this, "db");
33
- /** Other listeners... */
34
- __publicField(this, "onChildChanged", (path, cb) => (0, import_database.onChildChanged)(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
35
- __publicField(this, "onChildRemoved", (path, cb) => (0, import_database.onChildRemoved)(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
36
- const app = (0, import_app.initializeApp)(options.config);
37
- this.db = (0, import_database.getDatabase)(app);
38
- }
39
- /** Get a DatabaseReference */
40
- ref(path) {
41
- return (0, import_database.ref)(this.db, path);
42
- }
43
- /** Read once */
44
- async getOnce(path) {
45
- const snap = await (0, import_database.get)(this.ref(path));
46
- return snap.exists() ? snap.val() : null;
47
- }
48
- /** Listen to value changes */
49
- onValue(path, cb) {
50
- return (0, import_database.onValue)(
51
- this.ref(path),
52
- (snap) => cb(snap.key ?? "", snap.val(), snap),
53
- (err) => console.error("onValue error", err)
54
- );
55
- }
56
- /** Listen to child-added */
57
- onChildAdded(path, cb) {
58
- return (0, import_database.onChildAdded)(
59
- this.ref(path),
60
- (snap) => cb(snap.key, snap.val(), snap),
61
- (err) => console.error("onChildAdded error", err)
62
- );
63
- }
64
- /** Write/overwrite a node */
65
- write(path, data) {
66
- return (0, import_database.set)(this.ref(path), data);
67
- }
68
- /** Update (merge) a node */
69
- update(path, data) {
70
- return (0, import_database.update)(this.ref(path), data);
71
- }
72
- /** Remove a node */
73
- remove(path) {
74
- return (0, import_database.remove)(this.ref(path));
75
- }
76
- /** Push a child with generated key */
77
- async push(path, data) {
78
- const newRef = (0, import_database.push)(this.ref(path));
79
- await (0, import_database.set)(newRef, data);
80
- return newRef.key;
81
- }
82
- /** onDisconnect write */
83
- onDisconnectUpdate(path, data) {
84
- return (0, import_database.onDisconnect)(this.ref(path)).update(data);
85
- }
86
- /** Cancel onDisconnect operations */
87
- cancelOnDisconnect(path) {
88
- return (0, import_database.onDisconnect)(this.ref(path)).cancel();
89
- }
90
- /** Run a transaction */
91
- transaction(path, updateFn) {
92
- return (0, import_database.runTransaction)(this.ref(path), (cur) => updateFn(cur));
93
- }
94
- /** Build a query */
95
- query(path, opts = {}) {
96
- let q = this.ref(path);
97
- if (opts.orderBy === "child" && opts.childKey) q = (0, import_database.query)(q, (0, import_database.orderByChild)(opts.childKey));
98
- if (opts.orderBy === "key") q = (0, import_database.query)(q, (0, import_database.orderByKey)());
99
- if (opts.orderBy === "value") q = (0, import_database.query)(q, (0, import_database.orderByValue)());
100
- if (opts.limitFirst != null) q = (0, import_database.query)(q, (0, import_database.limitToFirst)(opts.limitFirst));
101
- if (opts.limitLast != null) q = (0, import_database.query)(q, (0, import_database.limitToLast)(opts.limitLast));
102
- return q;
103
- }
104
- };
105
- // Annotate the CommonJS export names for ESM import in node:
106
- 0 && (module.exports = {
107
- FirebaseApi
108
- });
1
+ /*! @onlive.ai/common-121 v0.2.40 | © 2025 Onlive.ai */
2
+ "use strict";var a=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var y=Object.prototype.hasOwnProperty;var g=(n,e,i)=>e in n?a(n,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):n[e]=i;var h=(n,e)=>{for(var i in e)a(n,i,{get:e[i],enumerable:!0})},m=(n,e,i,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of c(e))!y.call(n,s)&&s!==i&&a(n,s,{get:()=>e[s],enumerable:!(t=u(e,s))||t.enumerable});return n};var f=n=>m(a({},"__esModule",{value:!0}),n);var o=(n,e,i)=>g(n,typeof e!="symbol"?e+"":e,i);var T={};h(T,{FirebaseApi:()=>l});module.exports=f(T);var d=require("firebase/app"),r=require("firebase/database");var l=class{constructor(e){o(this,"db");o(this,"onChildChanged",(e,i)=>(0,r.onChildChanged)(this.ref(e),t=>i(t.key,t.val(),t)));o(this,"onChildRemoved",(e,i)=>(0,r.onChildRemoved)(this.ref(e),t=>i(t.key,t.val(),t)));let i=(0,d.initializeApp)(e.config);this.db=(0,r.getDatabase)(i)}ref(e){return(0,r.ref)(this.db,e)}async getOnce(e){let i=await(0,r.get)(this.ref(e));return i.exists()?i.val():null}onValue(e,i){return(0,r.onValue)(this.ref(e),t=>i(t.key??"",t.val(),t),t=>console.error("onValue error",t))}onChildAdded(e,i){return(0,r.onChildAdded)(this.ref(e),t=>i(t.key,t.val(),t),t=>console.error("onChildAdded error",t))}write(e,i){return(0,r.set)(this.ref(e),i)}update(e,i){return(0,r.update)(this.ref(e),i)}remove(e){return(0,r.remove)(this.ref(e))}async push(e,i){let t=(0,r.push)(this.ref(e));return await(0,r.set)(t,i),t.key}onDisconnectUpdate(e,i){return(0,r.onDisconnect)(this.ref(e)).update(i)}cancelOnDisconnect(e){return(0,r.onDisconnect)(this.ref(e)).cancel()}transaction(e,i){return(0,r.runTransaction)(this.ref(e),t=>i(t))}query(e,i={}){let t=this.ref(e);return i.orderBy==="child"&&i.childKey&&(t=(0,r.query)(t,(0,r.orderByChild)(i.childKey))),i.orderBy==="key"&&(t=(0,r.query)(t,(0,r.orderByKey)())),i.orderBy==="value"&&(t=(0,r.query)(t,(0,r.orderByValue)())),i.limitFirst!=null&&(t=(0,r.query)(t,(0,r.limitToFirst)(i.limitFirst))),i.limitLast!=null&&(t=(0,r.query)(t,(0,r.limitToLast)(i.limitLast))),t}};0&&(module.exports={FirebaseApi});
@@ -1,105 +1,2 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
-
5
- // services/firebase/firebase-api.ts
6
- import { initializeApp } from "firebase/app";
7
- import {
8
- query as dbQuery,
9
- get,
10
- getDatabase,
11
- limitToFirst,
12
- limitToLast,
13
- onChildAdded,
14
- onChildChanged,
15
- onChildRemoved,
16
- onDisconnect,
17
- onValue,
18
- orderByChild,
19
- orderByKey,
20
- orderByValue,
21
- push,
22
- ref,
23
- remove,
24
- runTransaction,
25
- set,
26
- update
27
- } from "firebase/database";
28
- var FirebaseApi = class {
29
- constructor(options) {
30
- __publicField(this, "db");
31
- /** Other listeners... */
32
- __publicField(this, "onChildChanged", (path, cb) => onChildChanged(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
33
- __publicField(this, "onChildRemoved", (path, cb) => onChildRemoved(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
34
- const app = initializeApp(options.config);
35
- this.db = getDatabase(app);
36
- }
37
- /** Get a DatabaseReference */
38
- ref(path) {
39
- return ref(this.db, path);
40
- }
41
- /** Read once */
42
- async getOnce(path) {
43
- const snap = await get(this.ref(path));
44
- return snap.exists() ? snap.val() : null;
45
- }
46
- /** Listen to value changes */
47
- onValue(path, cb) {
48
- return onValue(
49
- this.ref(path),
50
- (snap) => cb(snap.key ?? "", snap.val(), snap),
51
- (err) => console.error("onValue error", err)
52
- );
53
- }
54
- /** Listen to child-added */
55
- onChildAdded(path, cb) {
56
- return onChildAdded(
57
- this.ref(path),
58
- (snap) => cb(snap.key, snap.val(), snap),
59
- (err) => console.error("onChildAdded error", err)
60
- );
61
- }
62
- /** Write/overwrite a node */
63
- write(path, data) {
64
- return set(this.ref(path), data);
65
- }
66
- /** Update (merge) a node */
67
- update(path, data) {
68
- return update(this.ref(path), data);
69
- }
70
- /** Remove a node */
71
- remove(path) {
72
- return remove(this.ref(path));
73
- }
74
- /** Push a child with generated key */
75
- async push(path, data) {
76
- const newRef = push(this.ref(path));
77
- await set(newRef, data);
78
- return newRef.key;
79
- }
80
- /** onDisconnect write */
81
- onDisconnectUpdate(path, data) {
82
- return onDisconnect(this.ref(path)).update(data);
83
- }
84
- /** Cancel onDisconnect operations */
85
- cancelOnDisconnect(path) {
86
- return onDisconnect(this.ref(path)).cancel();
87
- }
88
- /** Run a transaction */
89
- transaction(path, updateFn) {
90
- return runTransaction(this.ref(path), (cur) => updateFn(cur));
91
- }
92
- /** Build a query */
93
- query(path, opts = {}) {
94
- let q = this.ref(path);
95
- if (opts.orderBy === "child" && opts.childKey) q = dbQuery(q, orderByChild(opts.childKey));
96
- if (opts.orderBy === "key") q = dbQuery(q, orderByKey());
97
- if (opts.orderBy === "value") q = dbQuery(q, orderByValue());
98
- if (opts.limitFirst != null) q = dbQuery(q, limitToFirst(opts.limitFirst));
99
- if (opts.limitLast != null) q = dbQuery(q, limitToLast(opts.limitLast));
100
- return q;
101
- }
102
- };
103
- export {
104
- FirebaseApi
105
- };
1
+ /*! @onlive.ai/common-121 v0.2.40 | © 2025 Onlive.ai */
2
+ var d=Object.defineProperty;var u=(t,e,r)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var s=(t,e,r)=>u(t,typeof e!="symbol"?e+"":e,r);import{initializeApp as c}from"firebase/app";import{query as n,get as y,getDatabase as g,limitToFirst as h,limitToLast as m,onChildAdded as f,onChildChanged as T,onChildRemoved as b,onDisconnect as a,onValue as v,orderByChild as C,orderByKey as k,orderByValue as p,push as D,ref as P,remove as B,runTransaction as R,set as o,update as F}from"firebase/database";var l=class{constructor(e){s(this,"db");s(this,"onChildChanged",(e,r)=>T(this.ref(e),i=>r(i.key,i.val(),i)));s(this,"onChildRemoved",(e,r)=>b(this.ref(e),i=>r(i.key,i.val(),i)));let r=c(e.config);this.db=g(r)}ref(e){return P(this.db,e)}async getOnce(e){let r=await y(this.ref(e));return r.exists()?r.val():null}onValue(e,r){return v(this.ref(e),i=>r(i.key??"",i.val(),i),i=>console.error("onValue error",i))}onChildAdded(e,r){return f(this.ref(e),i=>r(i.key,i.val(),i),i=>console.error("onChildAdded error",i))}write(e,r){return o(this.ref(e),r)}update(e,r){return F(this.ref(e),r)}remove(e){return B(this.ref(e))}async push(e,r){let i=D(this.ref(e));return await o(i,r),i.key}onDisconnectUpdate(e,r){return a(this.ref(e)).update(r)}cancelOnDisconnect(e){return a(this.ref(e)).cancel()}transaction(e,r){return R(this.ref(e),i=>r(i))}query(e,r={}){let i=this.ref(e);return r.orderBy==="child"&&r.childKey&&(i=n(i,C(r.childKey))),r.orderBy==="key"&&(i=n(i,k())),r.orderBy==="value"&&(i=n(i,p())),r.limitFirst!=null&&(i=n(i,h(r.limitFirst))),r.limitLast!=null&&(i=n(i,m(r.limitLast))),i}};export{l as FirebaseApi};
@@ -1,193 +1,2 @@
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 __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
- var __copyProps = (to, from, except, desc) => {
12
- if (from && typeof from === "object" || typeof from === "function") {
13
- for (let key of __getOwnPropNames(from))
14
- if (!__hasOwnProp.call(to, key) && key !== except)
15
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
- }
17
- return to;
18
- };
19
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
-
22
- // services/firebase/firebase.service.ts
23
- var firebase_service_exports = {};
24
- __export(firebase_service_exports, {
25
- FirebaseService: () => FirebaseService
26
- });
27
- module.exports = __toCommonJS(firebase_service_exports);
28
- var import_tracker = require("@onlive.ai/tracker");
29
-
30
- // services/firebase/firebase-api.ts
31
- var import_app = require("firebase/app");
32
- var import_database = require("firebase/database");
33
- var FirebaseApi = class {
34
- constructor(options) {
35
- __publicField(this, "db");
36
- /** Other listeners... */
37
- __publicField(this, "onChildChanged", (path, cb) => (0, import_database.onChildChanged)(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
38
- __publicField(this, "onChildRemoved", (path, cb) => (0, import_database.onChildRemoved)(this.ref(path), (snap) => cb(snap.key, snap.val(), snap)));
39
- const app = (0, import_app.initializeApp)(options.config);
40
- this.db = (0, import_database.getDatabase)(app);
41
- }
42
- /** Get a DatabaseReference */
43
- ref(path) {
44
- return (0, import_database.ref)(this.db, path);
45
- }
46
- /** Read once */
47
- async getOnce(path) {
48
- const snap = await (0, import_database.get)(this.ref(path));
49
- return snap.exists() ? snap.val() : null;
50
- }
51
- /** Listen to value changes */
52
- onValue(path, cb) {
53
- return (0, import_database.onValue)(
54
- this.ref(path),
55
- (snap) => cb(snap.key ?? "", snap.val(), snap),
56
- (err) => console.error("onValue error", err)
57
- );
58
- }
59
- /** Listen to child-added */
60
- onChildAdded(path, cb) {
61
- return (0, import_database.onChildAdded)(
62
- this.ref(path),
63
- (snap) => cb(snap.key, snap.val(), snap),
64
- (err) => console.error("onChildAdded error", err)
65
- );
66
- }
67
- /** Write/overwrite a node */
68
- write(path, data) {
69
- return (0, import_database.set)(this.ref(path), data);
70
- }
71
- /** Update (merge) a node */
72
- update(path, data) {
73
- return (0, import_database.update)(this.ref(path), data);
74
- }
75
- /** Remove a node */
76
- remove(path) {
77
- return (0, import_database.remove)(this.ref(path));
78
- }
79
- /** Push a child with generated key */
80
- async push(path, data) {
81
- const newRef = (0, import_database.push)(this.ref(path));
82
- await (0, import_database.set)(newRef, data);
83
- return newRef.key;
84
- }
85
- /** onDisconnect write */
86
- onDisconnectUpdate(path, data) {
87
- return (0, import_database.onDisconnect)(this.ref(path)).update(data);
88
- }
89
- /** Cancel onDisconnect operations */
90
- cancelOnDisconnect(path) {
91
- return (0, import_database.onDisconnect)(this.ref(path)).cancel();
92
- }
93
- /** Run a transaction */
94
- transaction(path, updateFn) {
95
- return (0, import_database.runTransaction)(this.ref(path), (cur) => updateFn(cur));
96
- }
97
- /** Build a query */
98
- query(path, opts = {}) {
99
- let q = this.ref(path);
100
- if (opts.orderBy === "child" && opts.childKey) q = (0, import_database.query)(q, (0, import_database.orderByChild)(opts.childKey));
101
- if (opts.orderBy === "key") q = (0, import_database.query)(q, (0, import_database.orderByKey)());
102
- if (opts.orderBy === "value") q = (0, import_database.query)(q, (0, import_database.orderByValue)());
103
- if (opts.limitFirst != null) q = (0, import_database.query)(q, (0, import_database.limitToFirst)(opts.limitFirst));
104
- if (opts.limitLast != null) q = (0, import_database.query)(q, (0, import_database.limitToLast)(opts.limitLast));
105
- return q;
106
- }
107
- };
108
-
109
- // services/firebase/firebase.service.ts
110
- var FirebaseService = class {
111
- constructor(firebaseOptions, orgId) {
112
- this.firebaseOptions = firebaseOptions;
113
- this.orgId = orgId;
114
- __publicField(this, "presencePath");
115
- __publicField(this, "callsPath");
116
- __publicField(this, "api");
117
- this.api = new FirebaseApi({ config: this.firebaseOptions });
118
- this.presencePath = `orgs/${this.orgId}/presence`;
119
- this.callsPath = `orgs/${this.orgId}/calls`;
120
- }
121
- // Presence methods
122
- getPresencePath(agentId) {
123
- return `${this.presencePath}/${agentId}`;
124
- }
125
- async setAgentOnline(agentId, displayName) {
126
- await this.api.write(this.getPresencePath(agentId), {
127
- status: "online",
128
- lastSeen: (/* @__PURE__ */ new Date()).toISOString(),
129
- displayName
130
- });
131
- await this.api.onDisconnectUpdate(this.getPresencePath(agentId), {
132
- status: "offline",
133
- lastSeen: (/* @__PURE__ */ new Date()).toISOString()
134
- });
135
- }
136
- onPresenceChange(cb) {
137
- return this.api.onChildChanged(this.presencePath, (key, data) => cb(key, data));
138
- }
139
- onPresenceAgentChange(agentId, cb) {
140
- return this.api.onValue(
141
- this.getPresencePath(agentId),
142
- (key, data) => cb(key, data)
143
- );
144
- }
145
- // Requests methods
146
- async createRequest(request) {
147
- const id = import_tracker.Generator.uuid();
148
- await this.api.write(`${this.callsPath}/${id}`, {
149
- ...request,
150
- createdAt: (/* @__PURE__ */ new Date()).toISOString(),
151
- status: "pending",
152
- assignedAgentId: null
153
- });
154
- this.api.onDisconnectUpdate(`${this.callsPath}/${id}`, {
155
- status: "disconnected"
156
- });
157
- return id;
158
- }
159
- onNewRequest(cb) {
160
- return this.api.onChildAdded(
161
- this.callsPath,
162
- (key, data) => cb(key, { ...data, id: key })
163
- );
164
- }
165
- onRequestChange(cb) {
166
- return this.api.onChildChanged(
167
- this.callsPath,
168
- (key, data) => cb(key, { ...data, id: key })
169
- );
170
- }
171
- onRequestRemoved(cb) {
172
- return this.api.onChildRemoved(this.callsPath, (key) => cb(key));
173
- }
174
- async acceptRequest(requestId) {
175
- await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
176
- return this.api.update(`${this.callsPath}/${requestId}`, {
177
- status: "accepted"
178
- });
179
- }
180
- async cancelOnDisconnect(requestId) {
181
- await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
182
- }
183
- async cancelRequest(requestId) {
184
- await this.api.cancelOnDisconnect(`${this.callsPath}/${requestId}`);
185
- return this.api.update(`${this.callsPath}/${requestId}`, {
186
- status: "cancelled"
187
- });
188
- }
189
- };
190
- // Annotate the CommonJS export names for ESM import in node:
191
- 0 && (module.exports = {
192
- FirebaseService
193
- });
1
+ /*! @onlive.ai/common-121 v0.2.40 | © 2025 Onlive.ai */
2
+ "use strict";var o=Object.defineProperty;var h=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var y=(n,e,t)=>e in n?o(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var m=(n,e)=>{for(var t in e)o(n,t,{get:e[t],enumerable:!0})},f=(n,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of u(e))!p.call(n,a)&&a!==t&&o(n,a,{get:()=>e[a],enumerable:!(i=h(e,a))||i.enumerable});return n};var P=n=>f(o({},"__esModule",{value:!0}),n);var r=(n,e,t)=>y(n,typeof e!="symbol"?e+"":e,t);var b={};m(b,{FirebaseService:()=>l});module.exports=P(b);var g=require("@onlive.ai/tracker");var d=require("firebase/app"),s=require("firebase/database");var c=class{constructor(e){r(this,"db");r(this,"onChildChanged",(e,t)=>(0,s.onChildChanged)(this.ref(e),i=>t(i.key,i.val(),i)));r(this,"onChildRemoved",(e,t)=>(0,s.onChildRemoved)(this.ref(e),i=>t(i.key,i.val(),i)));let t=(0,d.initializeApp)(e.config);this.db=(0,s.getDatabase)(t)}ref(e){return(0,s.ref)(this.db,e)}async getOnce(e){let t=await(0,s.get)(this.ref(e));return t.exists()?t.val():null}onValue(e,t){return(0,s.onValue)(this.ref(e),i=>t(i.key??"",i.val(),i),i=>console.error("onValue error",i))}onChildAdded(e,t){return(0,s.onChildAdded)(this.ref(e),i=>t(i.key,i.val(),i),i=>console.error("onChildAdded error",i))}write(e,t){return(0,s.set)(this.ref(e),t)}update(e,t){return(0,s.update)(this.ref(e),t)}remove(e){return(0,s.remove)(this.ref(e))}async push(e,t){let i=(0,s.push)(this.ref(e));return await(0,s.set)(i,t),i.key}onDisconnectUpdate(e,t){return(0,s.onDisconnect)(this.ref(e)).update(t)}cancelOnDisconnect(e){return(0,s.onDisconnect)(this.ref(e)).cancel()}transaction(e,t){return(0,s.runTransaction)(this.ref(e),i=>t(i))}query(e,t={}){let i=this.ref(e);return t.orderBy==="child"&&t.childKey&&(i=(0,s.query)(i,(0,s.orderByChild)(t.childKey))),t.orderBy==="key"&&(i=(0,s.query)(i,(0,s.orderByKey)())),t.orderBy==="value"&&(i=(0,s.query)(i,(0,s.orderByValue)())),t.limitFirst!=null&&(i=(0,s.query)(i,(0,s.limitToFirst)(t.limitFirst))),t.limitLast!=null&&(i=(0,s.query)(i,(0,s.limitToLast)(t.limitLast))),i}};var l=class{constructor(e,t){this.firebaseOptions=e;this.orgId=t;r(this,"presencePath");r(this,"callsPath");r(this,"api");this.api=new c({config:this.firebaseOptions}),this.presencePath=`orgs/${this.orgId}/presence`,this.callsPath=`orgs/${this.orgId}/calls`}getPresencePath(e){return`${this.presencePath}/${e}`}async setAgentOnline(e,t){await this.api.write(this.getPresencePath(e),{status:"online",lastSeen:new Date().toISOString(),displayName:t}),await this.api.onDisconnectUpdate(this.getPresencePath(e),{status:"offline",lastSeen:new Date().toISOString()})}onPresenceChange(e){return this.api.onChildChanged(this.presencePath,(t,i)=>e(t,i))}onPresenceAgentChange(e,t){return this.api.onValue(this.getPresencePath(e),(i,a)=>t(i,a))}async createRequest(e){let t=g.Generator.uuid();return await this.api.write(`${this.callsPath}/${t}`,{...e,createdAt:new Date().toISOString(),status:"pending",assignedAgentId:null}),this.api.onDisconnectUpdate(`${this.callsPath}/${t}`,{status:"disconnected"}),t}onNewRequest(e){return this.api.onChildAdded(this.callsPath,(t,i)=>e(t,{...i,id:t}))}onRequestChange(e){return this.api.onChildChanged(this.callsPath,(t,i)=>e(t,{...i,id:t}))}onRequestRemoved(e){return this.api.onChildRemoved(this.callsPath,t=>e(t))}async acceptRequest(e){return await this.api.cancelOnDisconnect(`${this.callsPath}/${e}`),this.api.update(`${this.callsPath}/${e}`,{status:"accepted"})}async cancelOnDisconnect(e){await this.api.cancelOnDisconnect(`${this.callsPath}/${e}`)}async cancelRequest(e){return await this.api.cancelOnDisconnect(`${this.callsPath}/${e}`),this.api.update(`${this.callsPath}/${e}`,{status:"cancelled"})}};0&&(module.exports={FirebaseService});