@camera.ui/browser 0.1.12 → 0.1.14
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/index.d.ts +25 -0
- package/dist/index.js +79 -28
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -331,6 +331,7 @@ export declare interface CoreManagerInterface {
|
|
|
331
331
|
getCloudServerId(): Promise<string>;
|
|
332
332
|
getRestoreGeneration(): Promise<string>;
|
|
333
333
|
getInstanceId(): Promise<string>;
|
|
334
|
+
getLanguage(): Promise<string>;
|
|
334
335
|
getPlugin(pluginName: string): Promise<HostPluginInfo | undefined>;
|
|
335
336
|
getPluginsByInterface(interfaceName: PluginInterface): Promise<HostPluginInfo[]>;
|
|
336
337
|
getFloorPlan(): Promise<FloorPlan>;
|
|
@@ -1389,9 +1390,11 @@ export declare type StreamStatus = 'idle' | 'connecting' | 'connected' | 'reconn
|
|
|
1389
1390
|
|
|
1390
1391
|
export declare interface TerminalManagerInterface {
|
|
1391
1392
|
createSession(options?: TerminalOptions): Promise<TerminalSessionInfo>;
|
|
1393
|
+
listSessions(): Promise<TerminalSessionInfo[]>;
|
|
1392
1394
|
generateOutput(sessionId: string): AsyncGenerator<Uint8Array>;
|
|
1393
1395
|
writeInput(sessionId: string, data: string): Promise<void>;
|
|
1394
1396
|
resize(sessionId: string, dimensions: { cols: number; rows: number }): Promise<void>;
|
|
1397
|
+
updateSession(sessionId: string, update: TerminalSessionUpdate): Promise<void>;
|
|
1395
1398
|
closeSession(sessionId: string): Promise<void>;
|
|
1396
1399
|
}
|
|
1397
1400
|
|
|
@@ -1406,12 +1409,21 @@ export declare interface TerminalOptions {
|
|
|
1406
1409
|
cwd?: string;
|
|
1407
1410
|
shell?: string;
|
|
1408
1411
|
env?: Record<string, string>;
|
|
1412
|
+
name?: string;
|
|
1413
|
+
persistent?: boolean;
|
|
1409
1414
|
}
|
|
1410
1415
|
|
|
1411
1416
|
export declare interface TerminalSessionInfo {
|
|
1412
1417
|
sessionId: string;
|
|
1413
1418
|
pid: number;
|
|
1414
1419
|
dimensions: { cols: number; rows: number };
|
|
1420
|
+
name?: string;
|
|
1421
|
+
persistent: boolean;
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
declare interface TerminalSessionUpdate {
|
|
1425
|
+
name?: string;
|
|
1426
|
+
persistent?: boolean;
|
|
1415
1427
|
}
|
|
1416
1428
|
|
|
1417
1429
|
declare type TrainingBoxSource = 'object' | 'static' | 'extra' | 'face' | 'plate' | 'suggestion' | 'drawn' | 'copied';
|
|
@@ -1632,7 +1644,10 @@ export declare interface UseTabVisibilityReturn {
|
|
|
1632
1644
|
export declare function useTerminal(): UseTerminalReturn;
|
|
1633
1645
|
|
|
1634
1646
|
export declare interface UseTerminalOptions extends TerminalOptions {
|
|
1647
|
+
sessionId?: string;
|
|
1635
1648
|
onData?: (data: Uint8Array) => void;
|
|
1649
|
+
onReplay?: () => void;
|
|
1650
|
+
onSession?: (session: TerminalSessionInfo) => void;
|
|
1636
1651
|
onClose?: () => void;
|
|
1637
1652
|
onError?: (error: Error) => void;
|
|
1638
1653
|
}
|
|
@@ -1647,13 +1662,23 @@ export declare interface UseTerminalReturn {
|
|
|
1647
1662
|
cols: number;
|
|
1648
1663
|
rows: number;
|
|
1649
1664
|
}>>;
|
|
1665
|
+
persistent: Readonly<Ref<boolean>>;
|
|
1650
1666
|
connect: (options?: UseTerminalOptions) => Promise<void>;
|
|
1651
1667
|
write: (data: string) => Promise<void>;
|
|
1652
1668
|
resize: (dimensions: {
|
|
1653
1669
|
cols: number;
|
|
1654
1670
|
rows: number;
|
|
1655
1671
|
}) => Promise<void>;
|
|
1672
|
+
setPersistent: (persistent: boolean) => Promise<void>;
|
|
1673
|
+
rename: (name: string) => Promise<void>;
|
|
1656
1674
|
close: () => Promise<void>;
|
|
1675
|
+
terminate: () => Promise<void>;
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
export declare function useTerminalSessions(): UseTerminalSessionsReturn;
|
|
1679
|
+
|
|
1680
|
+
export declare interface UseTerminalSessionsReturn {
|
|
1681
|
+
list: () => Promise<TerminalSessionInfo[]>;
|
|
1657
1682
|
}
|
|
1658
1683
|
|
|
1659
1684
|
export declare function useTopmostFullscreenElement(): ComputedRef<HTMLElement | null>;
|
package/dist/index.js
CHANGED
|
@@ -6722,14 +6722,14 @@ function useCoreManager() {
|
|
|
6722
6722
|
getPluginsByInterface: (interfaceName) => rpcCall(ctx.rpc, (rpc) => proxy(rpc).getPluginsByInterface(interfaceName)),
|
|
6723
6723
|
getCloudServerId: () => rpcCall(ctx.rpc, (rpc) => proxy(rpc).getCloudServerId()),
|
|
6724
6724
|
getRestoreGeneration: () => rpcCall(ctx.rpc, (rpc) => proxy(rpc).getRestoreGeneration()),
|
|
6725
|
-
getInstanceId: () => rpcCall(ctx.rpc, (rpc) => proxy(rpc).getInstanceId())
|
|
6725
|
+
getInstanceId: () => rpcCall(ctx.rpc, (rpc) => proxy(rpc).getInstanceId()),
|
|
6726
|
+
getLanguage: () => rpcCall(ctx.rpc, (rpc) => proxy(rpc).getLanguage())
|
|
6726
6727
|
};
|
|
6727
6728
|
}
|
|
6728
6729
|
// src/composables/useTerminal.ts
|
|
6729
6730
|
function useTerminal() {
|
|
6730
6731
|
const cameraUi = useCameraUi();
|
|
6731
6732
|
const { rpc, isConnected: isClientConnected } = cameraUi;
|
|
6732
|
-
const namespaces = NamespaceManager.terminalManagerNamespaces();
|
|
6733
6733
|
const sessionId = shallowRef();
|
|
6734
6734
|
const isConnected = ref(false);
|
|
6735
6735
|
const isConnecting = ref(false);
|
|
@@ -6738,6 +6738,7 @@ function useTerminal() {
|
|
|
6738
6738
|
cols: 80,
|
|
6739
6739
|
rows: 24
|
|
6740
6740
|
});
|
|
6741
|
+
const persistent = ref(false);
|
|
6741
6742
|
let streamAbortController;
|
|
6742
6743
|
let currentOptions;
|
|
6743
6744
|
let streamGen = 0;
|
|
@@ -6745,28 +6746,28 @@ function useTerminal() {
|
|
|
6745
6746
|
let streamClient;
|
|
6746
6747
|
let wentOffline = false;
|
|
6747
6748
|
let keptAcrossBlip = false;
|
|
6748
|
-
const proxy = (r) => r.createProxy(namespaces.terminalManagerRpc);
|
|
6749
6749
|
async function connect(options) {
|
|
6750
6750
|
if (isConnecting.value || isConnected.value) return;
|
|
6751
6751
|
isConnecting.value = true;
|
|
6752
6752
|
error.value = void 0;
|
|
6753
6753
|
currentOptions = options;
|
|
6754
6754
|
try {
|
|
6755
|
-
const session = await
|
|
6756
|
-
cols: options?.cols ?? 80,
|
|
6757
|
-
rows: options?.rows ?? 24,
|
|
6758
|
-
cwd: options?.cwd,
|
|
6759
|
-
shell: options?.shell,
|
|
6760
|
-
env: options?.env
|
|
6761
|
-
}), { maxRetries: 0 });
|
|
6755
|
+
const { session, attached } = await openSession(options);
|
|
6762
6756
|
sessionId.value = session.sessionId;
|
|
6763
6757
|
dimensions.value = session.dimensions;
|
|
6758
|
+
persistent.value = session.persistent;
|
|
6764
6759
|
isConnected.value = true;
|
|
6760
|
+
options?.onSession?.(session);
|
|
6765
6761
|
streamAbortController = new AbortController();
|
|
6766
6762
|
wentOffline = false;
|
|
6767
6763
|
keptAcrossBlip = false;
|
|
6768
6764
|
const gen = ++streamGen;
|
|
6765
|
+
if (attached) options?.onReplay?.();
|
|
6769
6766
|
consumeOutputStream(session.sessionId, options, gen);
|
|
6767
|
+
if (attached && options?.cols && options.rows) resize({
|
|
6768
|
+
cols: options.cols,
|
|
6769
|
+
rows: options.rows
|
|
6770
|
+
});
|
|
6770
6771
|
} catch (err) {
|
|
6771
6772
|
error.value = err instanceof Error ? err : new Error(String(err));
|
|
6772
6773
|
options?.onError?.(error.value);
|
|
@@ -6774,11 +6775,32 @@ function useTerminal() {
|
|
|
6774
6775
|
isConnecting.value = false;
|
|
6775
6776
|
}
|
|
6776
6777
|
}
|
|
6778
|
+
async function openSession(options) {
|
|
6779
|
+
if (options?.sessionId) {
|
|
6780
|
+
const session = (await rpcCall(rpc, (r) => terminalProxy(r).listSessions())).find((candidate) => candidate.sessionId === options.sessionId);
|
|
6781
|
+
if (session) return {
|
|
6782
|
+
session,
|
|
6783
|
+
attached: true
|
|
6784
|
+
};
|
|
6785
|
+
}
|
|
6786
|
+
return {
|
|
6787
|
+
session: await rpcCall(rpc, (r) => terminalProxy(r).createSession({
|
|
6788
|
+
cols: options?.cols ?? 80,
|
|
6789
|
+
rows: options?.rows ?? 24,
|
|
6790
|
+
cwd: options?.cwd,
|
|
6791
|
+
shell: options?.shell,
|
|
6792
|
+
env: options?.env,
|
|
6793
|
+
name: options?.name,
|
|
6794
|
+
persistent: options?.persistent
|
|
6795
|
+
}), { maxRetries: 0 }),
|
|
6796
|
+
attached: false
|
|
6797
|
+
};
|
|
6798
|
+
}
|
|
6777
6799
|
async function consumeOutputStream(sid, options, gen) {
|
|
6778
6800
|
try {
|
|
6779
6801
|
const current = rpc.value;
|
|
6780
6802
|
if (!current) return;
|
|
6781
|
-
const output =
|
|
6803
|
+
const output = terminalProxy(current).generateOutput(sid);
|
|
6782
6804
|
stream = output;
|
|
6783
6805
|
streamClient = current;
|
|
6784
6806
|
for await (const chunk of output) {
|
|
@@ -6797,37 +6819,50 @@ function useTerminal() {
|
|
|
6797
6819
|
} finally {
|
|
6798
6820
|
if (gen === streamGen && !streamAbortController?.signal.aborted) {
|
|
6799
6821
|
isConnected.value = false;
|
|
6800
|
-
closeRemote(sid);
|
|
6822
|
+
if (!persistent.value) closeRemote(sid);
|
|
6801
6823
|
options?.onClose?.();
|
|
6802
6824
|
}
|
|
6803
6825
|
}
|
|
6804
6826
|
}
|
|
6805
6827
|
async function write(data) {
|
|
6806
|
-
|
|
6807
|
-
try {
|
|
6808
|
-
await rpcCall(rpc, (r) => proxy(r).writeInput(sessionId.value, data));
|
|
6809
|
-
} catch (err) {
|
|
6810
|
-
error.value = err instanceof Error ? err : new Error(String(err));
|
|
6811
|
-
currentOptions?.onError?.(error.value);
|
|
6812
|
-
}
|
|
6828
|
+
await callSession((api, sid) => api.writeInput(sid, data));
|
|
6813
6829
|
}
|
|
6814
6830
|
async function resize(dims) {
|
|
6815
|
-
if (
|
|
6831
|
+
if (await callSession((api, sid) => api.resize(sid, dims))) dimensions.value = dims;
|
|
6832
|
+
}
|
|
6833
|
+
async function setPersistent(value) {
|
|
6834
|
+
persistent.value = value;
|
|
6835
|
+
await update({ persistent: value });
|
|
6836
|
+
}
|
|
6837
|
+
async function rename(name) {
|
|
6838
|
+
await update({ name });
|
|
6839
|
+
}
|
|
6840
|
+
function update(change) {
|
|
6841
|
+
return callSession((api, sid) => api.updateSession(sid, change));
|
|
6842
|
+
}
|
|
6843
|
+
async function callSession(call) {
|
|
6844
|
+
const sid = sessionId.value;
|
|
6845
|
+
if (!sid || !isConnected.value) return false;
|
|
6816
6846
|
try {
|
|
6817
|
-
await rpcCall(rpc, (r) =>
|
|
6818
|
-
|
|
6847
|
+
await rpcCall(rpc, (r) => call(terminalProxy(r), sid));
|
|
6848
|
+
return true;
|
|
6819
6849
|
} catch (err) {
|
|
6820
6850
|
error.value = err instanceof Error ? err : new Error(String(err));
|
|
6821
6851
|
currentOptions?.onError?.(error.value);
|
|
6852
|
+
return false;
|
|
6822
6853
|
}
|
|
6823
6854
|
}
|
|
6824
6855
|
async function close() {
|
|
6825
6856
|
stopStream();
|
|
6826
|
-
if (sessionId.value) await closeRemote(sessionId.value);
|
|
6857
|
+
if (sessionId.value && !persistent.value) await closeRemote(sessionId.value);
|
|
6827
6858
|
sessionId.value = void 0;
|
|
6828
6859
|
isConnected.value = false;
|
|
6829
6860
|
currentOptions = void 0;
|
|
6830
6861
|
}
|
|
6862
|
+
async function terminate() {
|
|
6863
|
+
persistent.value = false;
|
|
6864
|
+
await close();
|
|
6865
|
+
}
|
|
6831
6866
|
function stopStream() {
|
|
6832
6867
|
streamAbortController?.abort();
|
|
6833
6868
|
streamGen++;
|
|
@@ -6837,7 +6872,7 @@ function useTerminal() {
|
|
|
6837
6872
|
keptAcrossBlip = false;
|
|
6838
6873
|
}
|
|
6839
6874
|
function closeRemote(sid) {
|
|
6840
|
-
return rpcCall(rpc, (r) =>
|
|
6875
|
+
return rpcCall(rpc, (r) => terminalProxy(r).closeSession(sid), {
|
|
6841
6876
|
awaitConnect: false,
|
|
6842
6877
|
maxRetries: 0
|
|
6843
6878
|
}).catch(() => void 0);
|
|
@@ -6845,13 +6880,18 @@ function useTerminal() {
|
|
|
6845
6880
|
function restart() {
|
|
6846
6881
|
const savedOptions = currentOptions;
|
|
6847
6882
|
const sid = sessionId.value;
|
|
6883
|
+
const keep = persistent.value;
|
|
6848
6884
|
stopStream();
|
|
6849
|
-
if (sid) closeRemote(sid);
|
|
6885
|
+
if (sid && !keep) closeRemote(sid);
|
|
6850
6886
|
sessionId.value = void 0;
|
|
6851
6887
|
isConnected.value = false;
|
|
6852
6888
|
currentOptions = void 0;
|
|
6853
6889
|
savedOptions?.onClose?.();
|
|
6854
|
-
if (savedOptions) connect(
|
|
6890
|
+
if (savedOptions) connect({
|
|
6891
|
+
...savedOptions,
|
|
6892
|
+
sessionId: keep ? sid : void 0,
|
|
6893
|
+
persistent: keep
|
|
6894
|
+
});
|
|
6855
6895
|
}
|
|
6856
6896
|
function handleReconnected() {
|
|
6857
6897
|
if (!sessionId.value && !isConnected.value) return;
|
|
@@ -6878,10 +6918,21 @@ function useTerminal() {
|
|
|
6878
6918
|
isClientConnected: readonly(isClientConnected),
|
|
6879
6919
|
error: readonly(error),
|
|
6880
6920
|
dimensions: readonly(dimensions),
|
|
6921
|
+
persistent: readonly(persistent),
|
|
6881
6922
|
connect,
|
|
6882
6923
|
write,
|
|
6883
6924
|
resize,
|
|
6884
|
-
|
|
6925
|
+
setPersistent,
|
|
6926
|
+
rename,
|
|
6927
|
+
close,
|
|
6928
|
+
terminate
|
|
6885
6929
|
};
|
|
6886
6930
|
}
|
|
6887
|
-
|
|
6931
|
+
function useTerminalSessions() {
|
|
6932
|
+
const { rpc } = useCameraUi();
|
|
6933
|
+
return { list: () => rpcCall(rpc, (r) => terminalProxy(r).listSessions()) };
|
|
6934
|
+
}
|
|
6935
|
+
function terminalProxy(r) {
|
|
6936
|
+
return r.createProxy(NamespaceManager.terminalManagerNamespaces().terminalManagerRpc);
|
|
6937
|
+
}
|
|
6938
|
+
export { CAMERA_UI_INJECTION_KEY, NamespaceManager, STREAM_CONFIG, acquireSensorManager, clearCameraCache, clearOAuthCache, clearPluginCache, clearSensorCache, clearSnapshotCache, clearStorageCache, createActivityMode, createCameraUiPlugin, createReactiveCameraDevice, createSensorManager, getSnapshotUrl, isReactiveAudioSensor, isReactiveBatteryInfo, isReactiveCarbonDioxideInfo, isReactiveCarbonMonoxideSensor, isReactiveClassifierSensor, isReactiveColdSensor, isReactiveContactSensor, isReactiveDoorbellTrigger, isReactiveFaceSensor, isReactiveGarageControl, isReactiveGasSensor, isReactiveHeatSensor, isReactiveHumidityInfo, isReactiveIlluminanceInfo, isReactiveLeakSensor, isReactiveLicensePlateSensor, isReactiveLightControl, isReactiveLockControl, isReactiveMotionSensor, isReactiveObjectSensor, isReactiveOccupancySensor, isReactivePTZControl, isReactivePowerSensor, isReactiveProblemSensor, isReactiveSecuritySystem, isReactiveSirenControl, isReactiveSmokeSensor, isReactiveSwitchControl, isReactiveTamperSensor, isReactiveTemperatureInfo, isReactiveVibrationSensor, refreshClientSubscriptions, releaseSensorManager, resetClientState, restartConnectedStreams, rpcCall, setFullscreenRoot, useAllSensors, useAudioSensor, useCameraById, useCameraStorage, useCameraStream, useCameraUi, useClassifierSensors, useCoreManager, useCuiFullscreen, useDeviceManager, useFaceSensor, useLicensePlateSensor, useMotionSensor, useOAuth, useObjectSensor, usePTZControl, usePlugin, usePluginStorage, useRpcCall, useRpcSubscription, useSensorById, useSensorByType, useSensorStorage, useSensors, useSensorsByType, useSnapshot, useTabVisibility, useTerminal, useTerminalSessions, useTopmostFullscreenElement };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camera.ui/browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "camera.ui browser client",
|
|
5
5
|
"author": "seydx (https://github.com/cameraui/clients)",
|
|
6
6
|
"type": "module",
|
|
@@ -39,13 +39,13 @@
|
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@camera.ui/logger": "file:../../packages/logger",
|
|
41
41
|
"@camera.ui/rpc": "^1.1.2",
|
|
42
|
-
"@camera.ui/sdk": "~1.4.
|
|
42
|
+
"@camera.ui/sdk": "~1.4.8",
|
|
43
43
|
"@camera.ui/transport": "file:../../packages/transport",
|
|
44
44
|
"@eneris/push-receiver": "^4.4.0",
|
|
45
45
|
"@microsoft/api-extractor": "^7.60.1",
|
|
46
46
|
"@stylistic/eslint-plugin": "^5.10.0",
|
|
47
47
|
"@types/webrtc": "^0.0.47",
|
|
48
|
-
"@typescript-eslint/parser": "^8.72.
|
|
48
|
+
"@typescript-eslint/parser": "^8.72.2",
|
|
49
49
|
"@vitejs/plugin-vue": "^6.0.10",
|
|
50
50
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
51
51
|
"@vue/eslint-config-typescript": "^14.9.0",
|
|
@@ -59,10 +59,10 @@
|
|
|
59
59
|
"prettier": "^3.9.10",
|
|
60
60
|
"rimraf": "^6.1.4",
|
|
61
61
|
"typescript": "5.9.3",
|
|
62
|
-
"typescript-eslint": "^8.72.
|
|
62
|
+
"typescript-eslint": "^8.72.2",
|
|
63
63
|
"unplugin-dts": "^1.1.2",
|
|
64
|
-
"updates": "^20.0.
|
|
65
|
-
"vite": "^8.3.
|
|
64
|
+
"updates": "^20.0.1",
|
|
65
|
+
"vite": "^8.3.7",
|
|
66
66
|
"vitest": "^5.1.0",
|
|
67
67
|
"vue": "^3.5.45",
|
|
68
68
|
"vue-tsc": "3.3.11"
|