@laplace.live/persona-sdk 1.18.0 → 1.19.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/values/hotkeys.d.ts +33 -0
- package/dist/values/hotkeys.js +36 -0
- package/dist/wire/events.d.ts +4 -0
- package/dist/wire/methods.d.ts +2 -0
- package/dist/wire/schemas/requests.d.ts +1 -0
- package/dist/wire/schemas/requests.js +1 -1
- package/dist/wire/types.d.ts +10 -2
- package/package.json +1 -1
package/dist/values/hotkeys.d.ts
CHANGED
|
@@ -9,6 +9,17 @@ export declare function hasCommandModifier(accelerator: string | null): boolean;
|
|
|
9
9
|
export declare function canRunInBackground(accelerator: string | null): boolean;
|
|
10
10
|
/** True when a model hotkey is meant to fire while Persona sits in the background — what main registers on, and what the globe shows. */
|
|
11
11
|
export declare function hotkeyRunsInBackground(h: Hotkey): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Why a `hold` hotkey toggles instead of holding, or null when it can hold. A combo registered with
|
|
14
|
+
* the OS reaches Persona as a press alone — Electron reports no key-up for it — and one registration
|
|
15
|
+
* serves every hotkey on the combo: `'own'` when this hotkey asks for the background itself,
|
|
16
|
+
* `'shared'` when only another one on its combo does, which `registered` (main's list) alone can tell.
|
|
17
|
+
*/
|
|
18
|
+
export declare function holdBlockedBy(h: Pick<Hotkey, 'hold' | 'global' | 'accelerator'>, registered: boolean): 'own' | 'shared' | null;
|
|
19
|
+
/** VTS's editor limits for a hotkey's fade and auto-off times, in seconds; healing clamps API input to them. */
|
|
20
|
+
export declare const HOTKEY_FADE_SECONDS_MAX = 2;
|
|
21
|
+
export declare const HOTKEY_DEACTIVATE_SECONDS_MIN = 0.1;
|
|
22
|
+
export declare const HOTKEY_DEACTIVATE_SECONDS_MAX = 3600;
|
|
12
23
|
/** Automations are enabled unless explicitly paused. */
|
|
13
24
|
export declare function automationEnabled(s: {
|
|
14
25
|
enabled?: boolean;
|
|
@@ -27,3 +38,25 @@ export declare function automationBindable<T extends {
|
|
|
27
38
|
export declare function duplicateAccelerators(bindings: readonly {
|
|
28
39
|
accelerator: string | null;
|
|
29
40
|
}[]): Set<string>;
|
|
41
|
+
/** The slice of a scene model item the ordering reads; a full `SceneModelItem` comes back as itself. */
|
|
42
|
+
interface HotkeyModelLike {
|
|
43
|
+
kind: 'model';
|
|
44
|
+
instanceId: string;
|
|
45
|
+
ref: {
|
|
46
|
+
id: string;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* The models whose hotkeys are live — every model in the scene, the primary first, one per model id
|
|
51
|
+
* (a model on two layers lists once). The desktop fires all of them, VTS-style, and every shortcut
|
|
52
|
+
* list shows them in this order; `hotkey.list`/`hotkey.trigger` take each one's `ref.id` as `modelId`.
|
|
53
|
+
* Generic over the item union so a scene document and the desktop's loaded runtimes both infer.
|
|
54
|
+
*/
|
|
55
|
+
export declare function hotkeyModels<T extends HotkeyModelLike | {
|
|
56
|
+
kind: 'object';
|
|
57
|
+
instanceId: string;
|
|
58
|
+
}>(scene: {
|
|
59
|
+
items: readonly T[];
|
|
60
|
+
primaryInstanceId: string | null;
|
|
61
|
+
}): Extract<T, HotkeyModelLike>[];
|
|
62
|
+
export {};
|
package/dist/values/hotkeys.js
CHANGED
|
@@ -25,6 +25,23 @@ export function canRunInBackground(accelerator) {
|
|
|
25
25
|
export function hotkeyRunsInBackground(h) {
|
|
26
26
|
return h.global && h.active && h.action !== null && canRunInBackground(h.accelerator);
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Why a `hold` hotkey toggles instead of holding, or null when it can hold. A combo registered with
|
|
30
|
+
* the OS reaches Persona as a press alone — Electron reports no key-up for it — and one registration
|
|
31
|
+
* serves every hotkey on the combo: `'own'` when this hotkey asks for the background itself,
|
|
32
|
+
* `'shared'` when only another one on its combo does, which `registered` (main's list) alone can tell.
|
|
33
|
+
*/
|
|
34
|
+
export function holdBlockedBy(h, registered) {
|
|
35
|
+
if (h.hold !== true)
|
|
36
|
+
return null;
|
|
37
|
+
if (h.global && hasCommandModifier(h.accelerator))
|
|
38
|
+
return 'own';
|
|
39
|
+
return registered ? 'shared' : null;
|
|
40
|
+
}
|
|
41
|
+
/** VTS's editor limits for a hotkey's fade and auto-off times, in seconds; healing clamps API input to them. */
|
|
42
|
+
export const HOTKEY_FADE_SECONDS_MAX = 2;
|
|
43
|
+
export const HOTKEY_DEACTIVATE_SECONDS_MIN = 0.1;
|
|
44
|
+
export const HOTKEY_DEACTIVATE_SECONDS_MAX = 3600;
|
|
28
45
|
/** Automations are enabled unless explicitly paused. */
|
|
29
46
|
export function automationEnabled(s) {
|
|
30
47
|
return s.enabled !== false;
|
|
@@ -49,3 +66,22 @@ export function duplicateAccelerators(bindings) {
|
|
|
49
66
|
}
|
|
50
67
|
return dupes;
|
|
51
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* The models whose hotkeys are live — every model in the scene, the primary first, one per model id
|
|
71
|
+
* (a model on two layers lists once). The desktop fires all of them, VTS-style, and every shortcut
|
|
72
|
+
* list shows them in this order; `hotkey.list`/`hotkey.trigger` take each one's `ref.id` as `modelId`.
|
|
73
|
+
* Generic over the item union so a scene document and the desktop's loaded runtimes both infer.
|
|
74
|
+
*/
|
|
75
|
+
export function hotkeyModels(scene) {
|
|
76
|
+
const models = scene.items.filter((i) => i.kind === 'model');
|
|
77
|
+
const primary = models.find(i => i.instanceId === scene.primaryInstanceId);
|
|
78
|
+
const out = [];
|
|
79
|
+
const seen = new Set();
|
|
80
|
+
for (const item of primary ? [primary, ...models] : models) {
|
|
81
|
+
if (seen.has(item.ref.id))
|
|
82
|
+
continue;
|
|
83
|
+
seen.add(item.ref.id);
|
|
84
|
+
out.push(item);
|
|
85
|
+
}
|
|
86
|
+
return out;
|
|
87
|
+
}
|
package/dist/wire/events.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ export interface EventMap {
|
|
|
6
6
|
'settings.changed': {
|
|
7
7
|
settings: Settings;
|
|
8
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* One model's live hotkey set changed — every model on stage has one, and a model that just left the
|
|
11
|
+
* stage arrives empty. Older hosts sent `modelId: null` for an empty stage instead.
|
|
12
|
+
*/
|
|
9
13
|
'hotkey.state': {
|
|
10
14
|
modelId: string | null;
|
|
11
15
|
config: HotkeyState;
|
package/dist/wire/methods.d.ts
CHANGED
|
@@ -340,6 +340,8 @@ export interface HotkeySetRequest {
|
|
|
340
340
|
export type HotkeySetResponse = HotkeyState;
|
|
341
341
|
export interface HotkeyTriggerRequest {
|
|
342
342
|
hotkeyId: string;
|
|
343
|
+
/** The model that owns the hotkey — every model on stage has a live set; defaults to the primary. */
|
|
344
|
+
modelId?: string;
|
|
343
345
|
}
|
|
344
346
|
export type HotkeyTriggerResponse = EmptyResponse;
|
|
345
347
|
export type AutomationListRequest = EmptyRequest;
|
|
@@ -163,6 +163,7 @@ export declare const requestSchemas: {
|
|
|
163
163
|
}, z.core.$strip>;
|
|
164
164
|
'hotkey.trigger': z.ZodObject<{
|
|
165
165
|
hotkeyId: z.ZodString;
|
|
166
|
+
modelId: z.ZodOptional<z.ZodString>;
|
|
166
167
|
}, z.core.$strip>;
|
|
167
168
|
'automation.run': z.ZodObject<{
|
|
168
169
|
automationId: z.ZodString;
|
|
@@ -107,7 +107,7 @@ export const requestSchemas = {
|
|
|
107
107
|
modelId: nonEmpty.optional(),
|
|
108
108
|
config: z.custom(isRecord, 'config must be a hotkey config'),
|
|
109
109
|
}),
|
|
110
|
-
'hotkey.trigger': z.object({ hotkeyId: nonEmpty }),
|
|
110
|
+
'hotkey.trigger': z.object({ hotkeyId: nonEmpty, modelId: nonEmpty.optional() }),
|
|
111
111
|
'automation.run': z.object({ automationId: nonEmpty }),
|
|
112
112
|
'tracking.addSource': z.object({
|
|
113
113
|
// Straight off the kind registry, for the same reason as ASSET_KINDS below: a schema
|
package/dist/wire/types.d.ts
CHANGED
|
@@ -1011,7 +1011,7 @@ export interface Scene {
|
|
|
1011
1011
|
name: string;
|
|
1012
1012
|
/** Models and objects in one list; array order = z-order (bottom to top) within each space. */
|
|
1013
1013
|
items: SceneItem[];
|
|
1014
|
-
/**
|
|
1014
|
+
/** The default hotkey target and the default instance for model-scoped methods. null only when `items` holds no model. */
|
|
1015
1015
|
primaryInstanceId: string | null;
|
|
1016
1016
|
background: SceneBackground;
|
|
1017
1017
|
vrmCamera: SceneCamera;
|
|
@@ -1115,13 +1115,21 @@ export interface Hotkey {
|
|
|
1115
1115
|
accelerator: string | null;
|
|
1116
1116
|
global: boolean;
|
|
1117
1117
|
active: boolean;
|
|
1118
|
+
/** Expression: on only while the combo is held down (VTS `DeactivateAfterKeyUp`). Default false. */
|
|
1119
|
+
hold?: boolean;
|
|
1120
|
+
/** Fade time in seconds, in and out, of the expression or motion; null uses the file's own. 0–2. */
|
|
1121
|
+
fadeSeconds?: number | null;
|
|
1122
|
+
/** Expression: switches itself off after this many seconds. Motion: plays at most this long. null is off. 0.1–3600. */
|
|
1123
|
+
deactivateAfterSeconds?: number | null;
|
|
1124
|
+
/** Motion: holds its last frame until the hotkey fires again (VTS `StopsOnLastFrame`). Default false. */
|
|
1125
|
+
stopsOnLastFrame?: boolean;
|
|
1118
1126
|
}
|
|
1119
1127
|
export interface HotkeyConfig {
|
|
1120
1128
|
keyboardEnabled: boolean;
|
|
1121
1129
|
hotkeys: Hotkey[];
|
|
1122
1130
|
}
|
|
1123
1131
|
export interface HotkeyState extends HotkeyConfig {
|
|
1124
|
-
/** Hotkey ids currently registered with the OS (
|
|
1132
|
+
/** Hotkey ids currently registered with the OS (models on stage only). */
|
|
1125
1133
|
registered: string[];
|
|
1126
1134
|
}
|
|
1127
1135
|
/** Action kinds an app automation can carry today; servers may send kinds newer than this list. */
|