@laplace.live/persona-sdk 0.14.0 → 0.16.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/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export * from './client/client.ts';
3
3
  export * from './values/custom-effect.ts';
4
4
  export * from './values/effect-schema.ts';
5
5
  export * from './values/guards.ts';
6
+ export * from './values/hotkeys.ts';
6
7
  export * from './values/labels.ts';
7
8
  export * from './values/limits.ts';
8
9
  export * from './values/locale.ts';
package/dist/index.js CHANGED
@@ -5,6 +5,7 @@ export * from "./client/client.js";
5
5
  export * from "./values/custom-effect.js";
6
6
  export * from "./values/effect-schema.js";
7
7
  export * from "./values/guards.js";
8
+ export * from "./values/hotkeys.js";
8
9
  export * from "./values/labels.js";
9
10
  export * from "./values/limits.js";
10
11
  export * from "./values/locale.js";
@@ -0,0 +1,2 @@
1
+ /** True when the combo carries a command modifier and so may be registered globally. */
2
+ export declare function hasCommandModifier(accelerator: string | null): boolean;
@@ -0,0 +1,11 @@
1
+ // Hotkey rules every consumer must agree on: main decides OS registration by them, and a
2
+ // client reading `Hotkey.global` off the wire needs the same rule to know the flag can apply.
3
+ // Shift is deliberately absent: Shift+letter is how text is typed, and a global
4
+ // registration consumes the combo system-wide (VTS can allow it because it observes).
5
+ const COMMAND_MODIFIERS = ['Control', 'Alt', 'Super'];
6
+ /** True when the combo carries a command modifier and so may be registered globally. */
7
+ export function hasCommandModifier(accelerator) {
8
+ if (accelerator === null)
9
+ return false;
10
+ return accelerator.split('+').some(t => COMMAND_MODIFIERS.includes(t));
11
+ }
@@ -25,9 +25,11 @@ export interface EventMap {
25
25
  instanceId: string;
26
26
  format: ModelFormat;
27
27
  };
28
+ /** `weights` rides along on instances with `expression-weights`; a drag is not echoed (see `expression.setWeight`). */
28
29
  'expression.changed': {
29
30
  instanceId: string;
30
31
  active: string[];
32
+ weights?: Record<string, number>;
31
33
  };
32
34
  'motion.started': {
33
35
  instanceId: string;
@@ -190,6 +190,17 @@ export interface ExpressionToggleRequest {
190
190
  export interface ExpressionToggleResponse {
191
191
  active: string[];
192
192
  }
193
+ /** Reweight an expression that is already active — a weight on an inactive one would be invisible. */
194
+ export interface ExpressionSetWeightRequest {
195
+ instanceId?: string;
196
+ name: string;
197
+ /** 0..1. */
198
+ weight: number;
199
+ }
200
+ export interface ExpressionSetWeightResponse {
201
+ /** Every active expression's weight, in activation order. */
202
+ weights: Record<string, number>;
203
+ }
193
204
  export interface ExpressionGetPersistenceRequest {
194
205
  modelId?: string;
195
206
  }
@@ -580,6 +591,10 @@ export interface MethodMap {
580
591
  request: ExpressionToggleRequest;
581
592
  response: ExpressionToggleResponse;
582
593
  };
594
+ 'expression.setWeight': {
595
+ request: ExpressionSetWeightRequest;
596
+ response: ExpressionSetWeightResponse;
597
+ };
583
598
  'expression.getPersistence': {
584
599
  request: ExpressionGetPersistenceRequest;
585
600
  response: ExpressionGetPersistenceResponse;
@@ -127,6 +127,8 @@ export declare const requestSchemas: {
127
127
  prop: "prop";
128
128
  ibl: "ibl";
129
129
  lut: "lut";
130
+ animation: "animation";
131
+ cameraMotion: "cameraMotion";
130
132
  }>>;
131
133
  }, z.core.$strip>;
132
134
  'settings.patch': z.ZodObject<{
@@ -1,6 +1,7 @@
1
1
  import * as z from 'zod';
2
2
  import { isRecord } from "../values/guards.js";
3
3
  import { SPEECH_URL_MAX_LENGTH, STORAGE_KEY_MAX_LENGTH, STORAGE_VALUE_MAX_LENGTH } from "../values/limits.js";
4
+ import { ASSET_KINDS } from "./types.js";
4
5
  // Runtime validation for the request side of the wire. Schemas exist for the
5
6
  // methods whose params the app's main process consumes directly; methods without
6
7
  // one are stage-owned — the renderer validates and heals them (same rules as the
@@ -91,7 +92,9 @@ export const requestSchemas = {
91
92
  }),
92
93
  'tracking.removeSource': z.object({ id: nonEmpty }),
93
94
  'model.register': z.object({ path: nonEmpty }),
94
- 'asset.register': z.object({ path: nonEmpty, want: z.enum(['image', 'video', 'prop', 'ibl', 'lut']).optional() }),
95
+ // Straight off ASSET_KINDS: a kind added there has to reach the wire gate too, or
96
+ // `want` answers invalid-params for a kind the registry already knows how to take.
97
+ 'asset.register': z.object({ path: nonEmpty, want: z.enum(ASSET_KINDS).optional() }),
95
98
  'settings.patch': z.object({ settings: SettingsPatchSchema }),
96
99
  'tracking.setEnabled': z.object({ enabled: z.boolean() }),
97
100
  'tracking.setSource': z.object({ source: z.enum(['vts-ios', 'vts-ios-native', 'ifacialmocap']) }),
@@ -1,8 +1,12 @@
1
1
  export type ModelFormat = 'live2d' | 'vrm';
2
2
  /** Where an item came from: shipped with the app, or added by the user. */
3
3
  export type ContentOrigin = 'bundled' | 'user';
4
- /** How a registered file is labelled. Wider than an object's content kinds: `.hdr` is only ever an environment map. */
5
- export declare const ASSET_KINDS: readonly ["image", "video", "prop", "ibl", "lut", "animation"];
4
+ /**
5
+ * How a registered file is labelled. Wider than an object's content kinds: `.hdr` is only
6
+ * ever an environment map, and a `.vmd` splits by content — `cameraMotion` for one that
7
+ * frames a shot, `animation` for one that drives a rig.
8
+ */
9
+ export declare const ASSET_KINDS: readonly ["image", "video", "prop", "ibl", "lut", "animation", "cameraMotion"];
6
10
  export type AssetKind = (typeof ASSET_KINDS)[number];
7
11
  /** Narrow a kind string to the set the asset registry owns — models and effects have their own. */
8
12
  export declare function isAssetKind(v: unknown): v is AssetKind;
@@ -266,6 +270,11 @@ export interface OrbitTransform {
266
270
  export interface SceneCamera {
267
271
  orbit: OrbitTransform | null;
268
272
  fov: number;
273
+ /**
274
+ * A `cameraMotion` asset driving the camera, or null for the user's own orbit. While one
275
+ * is set it overrides `orbit` and `fov` every frame; neither field is written back.
276
+ */
277
+ clipAssetId: string | null;
269
278
  }
270
279
  export type SceneLightType = 'directional' | 'point' | 'ambient';
271
280
  /**
@@ -706,8 +715,16 @@ export type AppCapability = (typeof APP_CAPABILITIES)[number];
706
715
  export declare function isAppCapability(v: unknown): v is AppCapability;
707
716
  /** What a loaded model instance can do; absent capabilities answer `unsupported-for-format`. */
708
717
  export type InstanceCapability = 'motions' | 'expressions' | 'placement-2d' | 'placement-3d' | 'mtoon' | 'idle-clips' | 'pose' | 'live2d-params'
718
+ /** `expression.setWeight`; Cubism expressions carry no user-settable weight, so Live2D lacks it. */
719
+ | 'expression-weights'
709
720
  /** `speech.play` lip-sync; engine-dependent, so gate on the runtime, not the format. */
710
- | 'speech';
721
+ | 'speech'
722
+ /**
723
+ * Draws through the 3D post chain, so the scene's look rows (tone mapping, exposure, LUT)
724
+ * reach it. Always on VRM; on Live2D only under the `three` renderer, so read it off the
725
+ * runtime rather than the format.
726
+ */
727
+ | 'post-fx';
711
728
  export interface InstanceRuntime {
712
729
  instanceId: string;
713
730
  kind: 'model' | 'object';
@@ -724,6 +741,14 @@ export interface Expression {
724
741
  name: string;
725
742
  file: string | null;
726
743
  active: boolean;
744
+ /**
745
+ * A wardrobe piece (`LAPLACE_outfit`), not a face. Group these apart: "Jacket Off"
746
+ * listed between `blinkLeft` and `happy` reads as an expression when it is not one.
747
+ * Absent on formats with no wardrobe.
748
+ */
749
+ outfit?: boolean;
750
+ /** Blend weight (0..1) while active; absent unless the instance has `expression-weights`. */
751
+ weight?: number;
727
752
  }
728
753
  export interface PlayingMotion {
729
754
  group: string;
@@ -1,8 +1,12 @@
1
1
  // The API's data model: the entity shapes that requests, responses, and events
2
2
  // carry. Structural mirrors of the app's scene/settings models, minus anything
3
3
  // filesystem-shaped — model refs are sanitized to ids, never directories.
4
- /** How a registered file is labelled. Wider than an object's content kinds: `.hdr` is only ever an environment map. */
5
- export const ASSET_KINDS = ['image', 'video', 'prop', 'ibl', 'lut', 'animation'];
4
+ /**
5
+ * How a registered file is labelled. Wider than an object's content kinds: `.hdr` is only
6
+ * ever an environment map, and a `.vmd` splits by content — `cameraMotion` for one that
7
+ * frames a shot, `animation` for one that drives a rig.
8
+ */
9
+ export const ASSET_KINDS = ['image', 'video', 'prop', 'ibl', 'lut', 'animation', 'cameraMotion'];
6
10
  /** Narrow a kind string to the set the asset registry owns — models and effects have their own. */
7
11
  export function isAssetKind(v) {
8
12
  return typeof v === 'string' && ASSET_KINDS.includes(v);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laplace.live/persona-sdk",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "description": "TypeScript SDK and wire schema for the LAPLACE Persona plugin API",
5
5
  "license": "MIT",
6
6
  "type": "module",