@wix/legends-platform-sdk 1.23.0 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/hooks/useClientContext/index.js +10 -0
- package/dist/cjs/hooks/useClientContext/index.js.map +1 -0
- package/dist/cjs/hooks/useClientContext/useClientContext.js +36 -0
- package/dist/cjs/hooks/useClientContext/useClientContext.js.map +1 -0
- package/dist/cjs/livekit/sdk.js +6 -0
- package/dist/cjs/livekit/sdk.js.map +1 -1
- package/dist/esm/hooks/useClientContext/index.js +2 -0
- package/dist/esm/hooks/useClientContext/index.js.map +1 -0
- package/dist/esm/hooks/useClientContext/useClientContext.js +38 -0
- package/dist/esm/hooks/useClientContext/useClientContext.js.map +1 -0
- package/dist/esm/livekit/sdk.js +1 -0
- package/dist/esm/livekit/sdk.js.map +1 -1
- package/dist/types/hooks/useClientContext/index.d.ts +2 -0
- package/dist/types/hooks/useClientContext/index.d.ts.map +1 -0
- package/dist/types/hooks/useClientContext/useClientContext.d.ts +17 -0
- package/dist/types/hooks/useClientContext/useClientContext.d.ts.map +1 -0
- package/dist/types/livekit/sdk.d.ts +1 -0
- package/dist/types/livekit/sdk.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
var _useClientContext = require("./useClientContext");
|
|
5
|
+
Object.keys(_useClientContext).forEach(function (key) {
|
|
6
|
+
if (key === "default" || key === "__esModule") return;
|
|
7
|
+
if (key in exports && exports[key] === _useClientContext[key]) return;
|
|
8
|
+
exports[key] = _useClientContext[key];
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_useClientContext","require","Object","keys","forEach","key","exports"],"sources":["../../../../src/hooks/useClientContext/index.ts"],"sourcesContent":["export * from './useClientContext';\n"],"mappings":";;;AAAA,IAAAA,iBAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,iBAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,iBAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,iBAAA,CAAAK,GAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useClientContext = useClientContext;
|
|
5
|
+
var _react = require("react");
|
|
6
|
+
var _livekitClient = require("livekit-client");
|
|
7
|
+
var _componentsReact = require("@livekit/components-react");
|
|
8
|
+
const LIVEKIT_INTERNAL_ATTR_PREFIX = 'lk.';
|
|
9
|
+
/**
|
|
10
|
+
* Reads and updates client context stored in LiveKit local participant attributes.
|
|
11
|
+
* Must be used within a LiveKit room context.
|
|
12
|
+
*/
|
|
13
|
+
function useClientContext() {
|
|
14
|
+
const room = (0, _componentsReact.useEnsureRoom)();
|
|
15
|
+
const [context, setContext] = (0, _react.useState)({});
|
|
16
|
+
(0, _react.useEffect)(() => {
|
|
17
|
+
const readAttributes = () => {
|
|
18
|
+
setContext(Object.fromEntries(Object.entries(room.localParticipant.attributes ?? {}).filter(([key, value]) => value && !key.startsWith(LIVEKIT_INTERNAL_ATTR_PREFIX))));
|
|
19
|
+
};
|
|
20
|
+
readAttributes();
|
|
21
|
+
room.localParticipant.on(_livekitClient.ParticipantEvent.AttributesChanged, readAttributes);
|
|
22
|
+
return () => {
|
|
23
|
+
room.localParticipant.off(_livekitClient.ParticipantEvent.AttributesChanged, readAttributes);
|
|
24
|
+
};
|
|
25
|
+
}, [room]);
|
|
26
|
+
const updateContext = (0, _react.useCallback)(async attributes => {
|
|
27
|
+
await room.localParticipant.setAttributes(attributes);
|
|
28
|
+
}, [room]);
|
|
29
|
+
const removeContext = (0, _react.useCallback)(keys => updateContext(Object.fromEntries(keys.map(key => [key, '']))), [updateContext]);
|
|
30
|
+
return {
|
|
31
|
+
context,
|
|
32
|
+
updateContext,
|
|
33
|
+
removeContext
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=useClientContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_livekitClient","_componentsReact","LIVEKIT_INTERNAL_ATTR_PREFIX","useClientContext","room","useEnsureRoom","context","setContext","useState","useEffect","readAttributes","Object","fromEntries","entries","localParticipant","attributes","filter","key","value","startsWith","on","ParticipantEvent","AttributesChanged","off","updateContext","useCallback","setAttributes","removeContext","keys","map"],"sources":["../../../../src/hooks/useClientContext/useClientContext.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { ParticipantEvent } from 'livekit-client';\nimport { useEnsureRoom } from '@livekit/components-react';\n\nconst LIVEKIT_INTERNAL_ATTR_PREFIX = 'lk.';\n\nexport type UseClientContextResult = {\n /** Local participant attributes, excluding empty values and `lk.*` keys. */\n context: Record<string, string>;\n /**\n * Merges string values into the participant attributes; empty strings delete keys.\n * Requires `canUpdateOwnMetadata` permission. Update failures reject the promise.\n */\n updateContext(attributes: Record<string, string>): Promise<void>;\n /** Deletes keys. Requires `canUpdateOwnMetadata` permission and rejects on failure. */\n removeContext(keys: string[]): Promise<void>;\n};\n\n/**\n * Reads and updates client context stored in LiveKit local participant attributes.\n * Must be used within a LiveKit room context.\n */\nexport function useClientContext(): UseClientContextResult {\n const room = useEnsureRoom();\n const [context, setContext] = useState<Record<string, string>>({});\n\n useEffect(() => {\n const readAttributes = () => {\n setContext(\n Object.fromEntries(\n Object.entries(room.localParticipant.attributes ?? {}).filter(\n ([key, value]) =>\n value && !key.startsWith(LIVEKIT_INTERNAL_ATTR_PREFIX),\n ),\n ),\n );\n };\n\n readAttributes();\n\n room.localParticipant.on(\n ParticipantEvent.AttributesChanged,\n readAttributes,\n );\n return () => {\n room.localParticipant.off(\n ParticipantEvent.AttributesChanged,\n readAttributes,\n );\n };\n }, [room]);\n\n const updateContext = useCallback(\n async (attributes: Record<string, string>) => {\n await room.localParticipant.setAttributes(attributes);\n },\n [room],\n );\n\n const removeContext = useCallback(\n (keys: string[]) =>\n updateContext(Object.fromEntries(keys.map((key) => [key, '']))),\n [updateContext],\n );\n\n return {\n context,\n updateContext,\n removeContext,\n };\n}\n"],"mappings":";;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AAEA,MAAMG,4BAA4B,GAAG,KAAK;AAc1C;AACA;AACA;AACA;AACO,SAASC,gBAAgBA,CAAA,EAA2B;EACzD,MAAMC,IAAI,GAAG,IAAAC,8BAAa,EAAC,CAAC;EAC5B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAG,IAAAC,eAAQ,EAAyB,CAAC,CAAC,CAAC;EAElE,IAAAC,gBAAS,EAAC,MAAM;IACd,MAAMC,cAAc,GAAGA,CAAA,KAAM;MAC3BH,UAAU,CACRI,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACT,IAAI,CAACU,gBAAgB,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CAC3D,CAAC,CAACC,GAAG,EAAEC,KAAK,CAAC,KACXA,KAAK,IAAI,CAACD,GAAG,CAACE,UAAU,CAACjB,4BAA4B,CACzD,CACF,CACF,CAAC;IACH,CAAC;IAEDQ,cAAc,CAAC,CAAC;IAEhBN,IAAI,CAACU,gBAAgB,CAACM,EAAE,CACtBC,+BAAgB,CAACC,iBAAiB,EAClCZ,cACF,CAAC;IACD,OAAO,MAAM;MACXN,IAAI,CAACU,gBAAgB,CAACS,GAAG,CACvBF,+BAAgB,CAACC,iBAAiB,EAClCZ,cACF,CAAC;IACH,CAAC;EACH,CAAC,EAAE,CAACN,IAAI,CAAC,CAAC;EAEV,MAAMoB,aAAa,GAAG,IAAAC,kBAAW,EAC/B,MAAOV,UAAkC,IAAK;IAC5C,MAAMX,IAAI,CAACU,gBAAgB,CAACY,aAAa,CAACX,UAAU,CAAC;EACvD,CAAC,EACD,CAACX,IAAI,CACP,CAAC;EAED,MAAMuB,aAAa,GAAG,IAAAF,kBAAW,EAC9BG,IAAc,IACbJ,aAAa,CAACb,MAAM,CAACC,WAAW,CAACgB,IAAI,CAACC,GAAG,CAAEZ,GAAG,IAAK,CAACA,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACjE,CAACO,aAAa,CAChB,CAAC;EAED,OAAO;IACLlB,OAAO;IACPkB,aAAa;IACbG;EACF,CAAC;AACH","ignoreList":[]}
|
package/dist/cjs/livekit/sdk.js
CHANGED
|
@@ -25,6 +25,12 @@ Object.keys(_useAudioLevel).forEach(function (key) {
|
|
|
25
25
|
if (key in exports && exports[key] === _useAudioLevel[key]) return;
|
|
26
26
|
exports[key] = _useAudioLevel[key];
|
|
27
27
|
});
|
|
28
|
+
var _useClientContext = require("../hooks/useClientContext");
|
|
29
|
+
Object.keys(_useClientContext).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _useClientContext[key]) return;
|
|
32
|
+
exports[key] = _useClientContext[key];
|
|
33
|
+
});
|
|
28
34
|
var _useConversation = require("../hooks/useConversation");
|
|
29
35
|
Object.keys(_useConversation).forEach(function (key) {
|
|
30
36
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_sdk","require","Object","keys","forEach","key","exports","_LegendsPlatform","_LegendsPlatformQLess","_useAudioLevel","_useConversation","_useScreenShare","_useParticipantTrack","_useSpeechActivityDetector"],"sources":["../../../src/livekit/sdk.ts"],"sourcesContent":["export * from '../sdk';\n\n// Livekit-dependent exports — available from this subpath only, not from the main entry.\n// This keeps the main '@wix/legends-platform-sdk' entry free of ESM-only livekit dependencies.\nexport * from '../components/LegendsPlatform';\nexport * from '../components/LegendsPlatformQLess';\nexport * from '../hooks/useAudioLevel';\nexport * from '../hooks/useConversation';\nexport * from '../hooks/useScreenShare';\nexport * from '../hooks/useParticipantTrack';\nexport * from '../hooks/useSpeechActivityDetector';\n"],"mappings":";;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,IAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,IAAA,CAAAK,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAL,IAAA,CAAAK,GAAA;AAAA;AAIA,IAAAE,gBAAA,GAAAN,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAI,gBAAA,EAAAH,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAE,gBAAA,CAAAF,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAE,gBAAA,CAAAF,GAAA;AAAA;AACA,IAAAG,qBAAA,GAAAP,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAK,qBAAA,EAAAJ,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAG,qBAAA,CAAAH,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAG,qBAAA,CAAAH,GAAA;AAAA;AACA,IAAAI,cAAA,GAAAR,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAM,cAAA,EAAAL,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAI,cAAA,CAAAJ,GAAA;EAAAC,OAAA,CAAAD,GAAA,IAAAI,cAAA,CAAAJ,GAAA;AAAA;AACA,IAAAK,
|
|
1
|
+
{"version":3,"names":["_sdk","require","Object","keys","forEach","key","exports","_LegendsPlatform","_LegendsPlatformQLess","_useAudioLevel","_useClientContext","_useConversation","_useScreenShare","_useParticipantTrack","_useSpeechActivityDetector"],"sources":["../../../src/livekit/sdk.ts"],"sourcesContent":["export * from '../sdk';\n\n// Livekit-dependent exports — available from this subpath only, not from the main entry.\n// This keeps the main '@wix/legends-platform-sdk' entry free of ESM-only livekit dependencies.\nexport * from '../components/LegendsPlatform';\nexport * from '../components/LegendsPlatformQLess';\nexport * from '../hooks/useAudioLevel';\nexport * from '../hooks/useClientContext';\nexport * from '../hooks/useConversation';\nexport * from '../hooks/useScreenShare';\nexport * from '../hooks/useParticipantTrack';\nexport * from '../hooks/useSpeechActivityDetector';\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../../src/hooks/useClientContext/index.ts"],"sourcesContent":["export * from './useClientContext';\n"],"mappings":"AAAA,cAAc,oBAAoB","ignoreList":[]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { ParticipantEvent } from 'livekit-client';
|
|
3
|
+
import { useEnsureRoom } from '@livekit/components-react';
|
|
4
|
+
const LIVEKIT_INTERNAL_ATTR_PREFIX = 'lk.';
|
|
5
|
+
/**
|
|
6
|
+
* Reads and updates client context stored in LiveKit local participant attributes.
|
|
7
|
+
* Must be used within a LiveKit room context.
|
|
8
|
+
*/
|
|
9
|
+
export function useClientContext() {
|
|
10
|
+
const room = useEnsureRoom();
|
|
11
|
+
const _useState = useState({}),
|
|
12
|
+
context = _useState[0],
|
|
13
|
+
setContext = _useState[1];
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const readAttributes = () => {
|
|
16
|
+
setContext(Object.fromEntries(Object.entries(room.localParticipant.attributes ?? {}).filter(_ref => {
|
|
17
|
+
let key = _ref[0],
|
|
18
|
+
value = _ref[1];
|
|
19
|
+
return value && !key.startsWith(LIVEKIT_INTERNAL_ATTR_PREFIX);
|
|
20
|
+
})));
|
|
21
|
+
};
|
|
22
|
+
readAttributes();
|
|
23
|
+
room.localParticipant.on(ParticipantEvent.AttributesChanged, readAttributes);
|
|
24
|
+
return () => {
|
|
25
|
+
room.localParticipant.off(ParticipantEvent.AttributesChanged, readAttributes);
|
|
26
|
+
};
|
|
27
|
+
}, [room]);
|
|
28
|
+
const updateContext = useCallback(async attributes => {
|
|
29
|
+
await room.localParticipant.setAttributes(attributes);
|
|
30
|
+
}, [room]);
|
|
31
|
+
const removeContext = useCallback(keys => updateContext(Object.fromEntries(keys.map(key => [key, '']))), [updateContext]);
|
|
32
|
+
return {
|
|
33
|
+
context,
|
|
34
|
+
updateContext,
|
|
35
|
+
removeContext
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=useClientContext.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useCallback","useEffect","useState","ParticipantEvent","useEnsureRoom","LIVEKIT_INTERNAL_ATTR_PREFIX","useClientContext","room","_useState","context","setContext","readAttributes","Object","fromEntries","entries","localParticipant","attributes","filter","_ref","key","value","startsWith","on","AttributesChanged","off","updateContext","setAttributes","removeContext","keys","map"],"sources":["../../../../src/hooks/useClientContext/useClientContext.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from 'react';\nimport { ParticipantEvent } from 'livekit-client';\nimport { useEnsureRoom } from '@livekit/components-react';\n\nconst LIVEKIT_INTERNAL_ATTR_PREFIX = 'lk.';\n\nexport type UseClientContextResult = {\n /** Local participant attributes, excluding empty values and `lk.*` keys. */\n context: Record<string, string>;\n /**\n * Merges string values into the participant attributes; empty strings delete keys.\n * Requires `canUpdateOwnMetadata` permission. Update failures reject the promise.\n */\n updateContext(attributes: Record<string, string>): Promise<void>;\n /** Deletes keys. Requires `canUpdateOwnMetadata` permission and rejects on failure. */\n removeContext(keys: string[]): Promise<void>;\n};\n\n/**\n * Reads and updates client context stored in LiveKit local participant attributes.\n * Must be used within a LiveKit room context.\n */\nexport function useClientContext(): UseClientContextResult {\n const room = useEnsureRoom();\n const [context, setContext] = useState<Record<string, string>>({});\n\n useEffect(() => {\n const readAttributes = () => {\n setContext(\n Object.fromEntries(\n Object.entries(room.localParticipant.attributes ?? {}).filter(\n ([key, value]) =>\n value && !key.startsWith(LIVEKIT_INTERNAL_ATTR_PREFIX),\n ),\n ),\n );\n };\n\n readAttributes();\n\n room.localParticipant.on(\n ParticipantEvent.AttributesChanged,\n readAttributes,\n );\n return () => {\n room.localParticipant.off(\n ParticipantEvent.AttributesChanged,\n readAttributes,\n );\n };\n }, [room]);\n\n const updateContext = useCallback(\n async (attributes: Record<string, string>) => {\n await room.localParticipant.setAttributes(attributes);\n },\n [room],\n );\n\n const removeContext = useCallback(\n (keys: string[]) =>\n updateContext(Object.fromEntries(keys.map((key) => [key, '']))),\n [updateContext],\n );\n\n return {\n context,\n updateContext,\n removeContext,\n };\n}\n"],"mappings":"AAAA,SAASA,WAAW,EAAEC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AACxD,SAASC,gBAAgB,QAAQ,gBAAgB;AACjD,SAASC,aAAa,QAAQ,2BAA2B;AAEzD,MAAMC,4BAA4B,GAAG,KAAK;AAc1C;AACA;AACA;AACA;AACA,OAAO,SAASC,gBAAgBA,CAAA,EAA2B;EACzD,MAAMC,IAAI,GAAGH,aAAa,CAAC,CAAC;EAC5B,MAAAI,SAAA,GAA8BN,QAAQ,CAAyB,CAAC,CAAC,CAAC;IAA3DO,OAAO,GAAAD,SAAA;IAAEE,UAAU,GAAAF,SAAA;EAE1BP,SAAS,CAAC,MAAM;IACd,MAAMU,cAAc,GAAGA,CAAA,KAAM;MAC3BD,UAAU,CACRE,MAAM,CAACC,WAAW,CAChBD,MAAM,CAACE,OAAO,CAACP,IAAI,CAACQ,gBAAgB,CAACC,UAAU,IAAI,CAAC,CAAC,CAAC,CAACC,MAAM,CAC3DC,IAAA;QAAA,IAAEC,GAAG,GAAAD,IAAA;UAAEE,KAAK,GAAAF,IAAA;QAAA,OACVE,KAAK,IAAI,CAACD,GAAG,CAACE,UAAU,CAAChB,4BAA4B,CAAC;MAAA,CAC1D,CACF,CACF,CAAC;IACH,CAAC;IAEDM,cAAc,CAAC,CAAC;IAEhBJ,IAAI,CAACQ,gBAAgB,CAACO,EAAE,CACtBnB,gBAAgB,CAACoB,iBAAiB,EAClCZ,cACF,CAAC;IACD,OAAO,MAAM;MACXJ,IAAI,CAACQ,gBAAgB,CAACS,GAAG,CACvBrB,gBAAgB,CAACoB,iBAAiB,EAClCZ,cACF,CAAC;IACH,CAAC;EACH,CAAC,EAAE,CAACJ,IAAI,CAAC,CAAC;EAEV,MAAMkB,aAAa,GAAGzB,WAAW,CAC/B,MAAOgB,UAAkC,IAAK;IAC5C,MAAMT,IAAI,CAACQ,gBAAgB,CAACW,aAAa,CAACV,UAAU,CAAC;EACvD,CAAC,EACD,CAACT,IAAI,CACP,CAAC;EAED,MAAMoB,aAAa,GAAG3B,WAAW,CAC9B4B,IAAc,IACbH,aAAa,CAACb,MAAM,CAACC,WAAW,CAACe,IAAI,CAACC,GAAG,CAAEV,GAAG,IAAK,CAACA,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EACjE,CAACM,aAAa,CAChB,CAAC;EAED,OAAO;IACLhB,OAAO;IACPgB,aAAa;IACbE;EACF,CAAC;AACH","ignoreList":[]}
|
package/dist/esm/livekit/sdk.js
CHANGED
|
@@ -5,6 +5,7 @@ export * from '../sdk';
|
|
|
5
5
|
export * from '../components/LegendsPlatform';
|
|
6
6
|
export * from '../components/LegendsPlatformQLess';
|
|
7
7
|
export * from '../hooks/useAudioLevel';
|
|
8
|
+
export * from '../hooks/useClientContext';
|
|
8
9
|
export * from '../hooks/useConversation';
|
|
9
10
|
export * from '../hooks/useScreenShare';
|
|
10
11
|
export * from '../hooks/useParticipantTrack';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["../../../src/livekit/sdk.ts"],"sourcesContent":["export * from '../sdk';\n\n// Livekit-dependent exports — available from this subpath only, not from the main entry.\n// This keeps the main '@wix/legends-platform-sdk' entry free of ESM-only livekit dependencies.\nexport * from '../components/LegendsPlatform';\nexport * from '../components/LegendsPlatformQLess';\nexport * from '../hooks/useAudioLevel';\nexport * from '../hooks/useConversation';\nexport * from '../hooks/useScreenShare';\nexport * from '../hooks/useParticipantTrack';\nexport * from '../hooks/useSpeechActivityDetector';\n"],"mappings":"AAAA,cAAc,QAAQ;;AAEtB;AACA;AACA,cAAc,+BAA+B;AAC7C,cAAc,oCAAoC;AAClD,cAAc,wBAAwB;AACtC,cAAc,0BAA0B;AACxC,cAAc,yBAAyB;AACvC,cAAc,8BAA8B;AAC5C,cAAc,oCAAoC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["../../../src/livekit/sdk.ts"],"sourcesContent":["export * from '../sdk';\n\n// Livekit-dependent exports — available from this subpath only, not from the main entry.\n// This keeps the main '@wix/legends-platform-sdk' entry free of ESM-only livekit dependencies.\nexport * from '../components/LegendsPlatform';\nexport * from '../components/LegendsPlatformQLess';\nexport * from '../hooks/useAudioLevel';\nexport * from '../hooks/useClientContext';\nexport * from '../hooks/useConversation';\nexport * from '../hooks/useScreenShare';\nexport * from '../hooks/useParticipantTrack';\nexport * from '../hooks/useSpeechActivityDetector';\n"],"mappings":"AAAA,cAAc,QAAQ;;AAEtB;AACA;AACA,cAAc,+BAA+B;AAC7C,cAAc,oCAAoC;AAClD,cAAc,wBAAwB;AACtC,cAAc,2BAA2B;AACzC,cAAc,0BAA0B;AACxC,cAAc,yBAAyB;AACvC,cAAc,8BAA8B;AAC5C,cAAc,oCAAoC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useClientContext/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type UseClientContextResult = {
|
|
2
|
+
/** Local participant attributes, excluding empty values and `lk.*` keys. */
|
|
3
|
+
context: Record<string, string>;
|
|
4
|
+
/**
|
|
5
|
+
* Merges string values into the participant attributes; empty strings delete keys.
|
|
6
|
+
* Requires `canUpdateOwnMetadata` permission. Update failures reject the promise.
|
|
7
|
+
*/
|
|
8
|
+
updateContext(attributes: Record<string, string>): Promise<void>;
|
|
9
|
+
/** Deletes keys. Requires `canUpdateOwnMetadata` permission and rejects on failure. */
|
|
10
|
+
removeContext(keys: string[]): Promise<void>;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Reads and updates client context stored in LiveKit local participant attributes.
|
|
14
|
+
* Must be used within a LiveKit room context.
|
|
15
|
+
*/
|
|
16
|
+
export declare function useClientContext(): UseClientContextResult;
|
|
17
|
+
//# sourceMappingURL=useClientContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useClientContext.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useClientContext/useClientContext.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,sBAAsB,GAAG;IACnC,4EAA4E;IAC5E,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;OAGG;IACH,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,uFAAuF;IACvF,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAgDzD"}
|
|
@@ -2,6 +2,7 @@ export * from '../sdk';
|
|
|
2
2
|
export * from '../components/LegendsPlatform';
|
|
3
3
|
export * from '../components/LegendsPlatformQLess';
|
|
4
4
|
export * from '../hooks/useAudioLevel';
|
|
5
|
+
export * from '../hooks/useClientContext';
|
|
5
6
|
export * from '../hooks/useConversation';
|
|
6
7
|
export * from '../hooks/useScreenShare';
|
|
7
8
|
export * from '../hooks/useParticipantTrack';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/livekit/sdk.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AAIvB,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC"}
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/livekit/sdk.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AAIvB,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,wBAAwB,CAAC;AACvC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,oCAAoC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.24.0",
|
|
3
3
|
"name": "@wix/legends-platform-sdk",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": {
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"@types/jest": "^27.4.0",
|
|
62
62
|
"@types/react": "^18.2.15",
|
|
63
63
|
"@types/react-dom": "^18.2.7",
|
|
64
|
-
"@wix/eslint-config-yoshi": "^6.
|
|
65
|
-
"@wix/jest-yoshi-preset": "^6.
|
|
66
|
-
"@wix/yoshi-flow-library": "^6.
|
|
67
|
-
"@wix/yoshi-style-dependencies": "^6.
|
|
64
|
+
"@wix/eslint-config-yoshi": "^6.193.0",
|
|
65
|
+
"@wix/jest-yoshi-preset": "^6.193.0",
|
|
66
|
+
"@wix/yoshi-flow-library": "^6.193.0",
|
|
67
|
+
"@wix/yoshi-style-dependencies": "^6.193.0",
|
|
68
68
|
"express": "^4.17.2",
|
|
69
69
|
"lodash": "^4.18.1",
|
|
70
70
|
"react": "^19.0.0",
|
|
@@ -103,5 +103,5 @@
|
|
|
103
103
|
"wallaby": {
|
|
104
104
|
"autoDetect": true
|
|
105
105
|
},
|
|
106
|
-
"falconPackageHash": "
|
|
106
|
+
"falconPackageHash": "f2a22c8ce3066f461fc611d59056d3368619658bb0aaaff74a6bd311"
|
|
107
107
|
}
|