@laplace.live/persona-sdk 1.19.0 → 1.20.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
@@ -17,6 +17,7 @@ export * from './values/limits.ts';
17
17
  export * from './values/lipsync.ts';
18
18
  export * from './values/locale.ts';
19
19
  export * from './values/model-info.ts';
20
+ export * from './values/model-movement.ts';
20
21
  export * from './values/mouse.ts';
21
22
  export * from './values/scene-transition.ts';
22
23
  export * from './values/stage-info.ts';
package/dist/index.js CHANGED
@@ -19,6 +19,7 @@ export * from "./values/limits.js";
19
19
  export * from "./values/lipsync.js";
20
20
  export * from "./values/locale.js";
21
21
  export * from "./values/model-info.js";
22
+ export * from "./values/model-movement.js";
22
23
  export * from "./values/mouse.js";
23
24
  export * from "./values/scene-transition.js";
24
25
  export * from "./values/stage-info.js";
@@ -0,0 +1,29 @@
1
+ /**
2
+ * VTube Studio's Movement Config: how far tracked face position slides (`x`, `y`) and scales (`z`)
3
+ * a whole Live2D model. It moves the model itself and never writes a parameter, so it stacks with
4
+ * a rig that binds `FacePositionZ` to a parameter of its own. Amounts are signed — a negative one
5
+ * inverts its axis, 0 switches it off.
6
+ */
7
+ export interface ModelMovementConfig {
8
+ enabled: boolean;
9
+ x: number;
10
+ y: number;
11
+ z: number;
12
+ /** Smoothing levels 0–100, read once when the model loads; file-only, as in VTS. */
13
+ smoothingX: number;
14
+ smoothingY: number;
15
+ smoothingZ: number;
16
+ }
17
+ /** VTS's slider limit (`MAX_MOVEMENT`): an edited amount is a whole number within ±20. */
18
+ export declare const MODEL_MOVEMENT_MAX = 20;
19
+ /** VTS's `ModelPositionMovement` field initializers — a model nobody configured moves by default. */
20
+ export declare const DEFAULT_MODEL_MOVEMENT: Readonly<ModelMovementConfig>;
21
+ /**
22
+ * A stored or relayed configuration, read per field over the defaults. Amounts are taken as
23
+ * written: VTS clamps its sliders to ±20, never what a file holds.
24
+ */
25
+ export declare function healModelMovement(raw: unknown): ModelMovementConfig;
26
+ /** What the Movement Config editor changes; a file's smoothing levels are left as they are. */
27
+ export type ModelMovementEdit = Partial<Pick<ModelMovementConfig, 'enabled' | 'x' | 'y' | 'z'>>;
28
+ /** An edit healed to the editor's limits; an absent or unusable field is dropped, not defaulted. */
29
+ export declare function healModelMovementEdit(raw: unknown): ModelMovementEdit;
@@ -0,0 +1,44 @@
1
+ import { finiteOr, isFiniteNumber, isRecord } from "./guards.js";
2
+ import { clamp } from "./limits.js";
3
+ /** VTS's slider limit (`MAX_MOVEMENT`): an edited amount is a whole number within ±20. */
4
+ export const MODEL_MOVEMENT_MAX = 20;
5
+ /** VTS's `ModelPositionMovement` field initializers — a model nobody configured moves by default. */
6
+ export const DEFAULT_MODEL_MOVEMENT = {
7
+ enabled: true,
8
+ x: 6,
9
+ y: 8,
10
+ z: 11,
11
+ smoothingX: 10,
12
+ smoothingY: 10,
13
+ smoothingZ: 10,
14
+ };
15
+ /**
16
+ * A stored or relayed configuration, read per field over the defaults. Amounts are taken as
17
+ * written: VTS clamps its sliders to ±20, never what a file holds.
18
+ */
19
+ export function healModelMovement(raw) {
20
+ const r = isRecord(raw) ? raw : {};
21
+ const d = DEFAULT_MODEL_MOVEMENT;
22
+ return {
23
+ enabled: typeof r.enabled === 'boolean' ? r.enabled : d.enabled,
24
+ x: finiteOr(r.x, d.x),
25
+ y: finiteOr(r.y, d.y),
26
+ z: finiteOr(r.z, d.z),
27
+ smoothingX: finiteOr(r.smoothingX, d.smoothingX),
28
+ smoothingY: finiteOr(r.smoothingY, d.smoothingY),
29
+ smoothingZ: finiteOr(r.smoothingZ, d.smoothingZ),
30
+ };
31
+ }
32
+ /** An edit healed to the editor's limits; an absent or unusable field is dropped, not defaulted. */
33
+ export function healModelMovementEdit(raw) {
34
+ const r = isRecord(raw) ? raw : {};
35
+ const edit = {};
36
+ if (typeof r.enabled === 'boolean')
37
+ edit.enabled = r.enabled;
38
+ for (const axis of ['x', 'y', 'z']) {
39
+ const v = r[axis];
40
+ if (isFiniteNumber(v))
41
+ edit[axis] = clamp(Math.round(v), -MODEL_MOVEMENT_MAX, MODEL_MOVEMENT_MAX);
42
+ }
43
+ return edit;
44
+ }
@@ -1,3 +1,4 @@
1
+ import type { ModelMovementConfig } from '../values/model-movement.ts';
1
2
  import type { AutomationInfo, ExpressionPersistence, HotkeyState, ModelFormat, PoseStatus, SceneState, Settings, TrackingStatus } from './types.ts';
2
3
  /** Every push event a session can subscribe to, with its payload. */
3
4
  export interface EventMap {
@@ -70,6 +71,11 @@ export interface EventMap {
70
71
  modelId: string;
71
72
  persistence: ExpressionPersistence;
72
73
  };
74
+ /** A model's Movement Config changed, from any editor; every instance of the model follows it. */
75
+ 'model.movement': {
76
+ modelId: string;
77
+ movement: ModelMovementConfig;
78
+ };
73
79
  }
74
80
  export type EventName = keyof EventMap;
75
81
  export type EventData<E extends EventName = EventName> = EventMap[E];
@@ -17,6 +17,7 @@ export const EVENT_NAMES = Object.keys({
17
17
  'selection.changed': true,
18
18
  'registry.changed': true,
19
19
  'expression.persistence': true,
20
+ 'model.movement': true,
20
21
  });
21
22
  export function isEventName(v) {
22
23
  return isOneOf(v, EVENT_NAMES);
@@ -2,6 +2,7 @@ import type { Binding, BindingEditorData, BindingLiveValues } from '../values/bi
2
2
  import type { ControllerMovementConfig, ControllerState } from '../values/controller.ts';
3
3
  import type { SpawnTransition } from '../values/item-transition.ts';
4
4
  import type { LipSyncCalibrationCommand, LipSyncConfig, LipSyncMode, LipSyncState } from '../values/lipsync.ts';
5
+ import type { ModelMovementConfig, ModelMovementEdit } from '../values/model-movement.ts';
5
6
  import type { SceneInspection } from '../values/stage-info.ts';
6
7
  import type { EventName } from './events.ts';
7
8
  import type { AnchorOption, AppCapability, AssetKind, AssetRef, Attach, AttachHeadAngle, AutomationInfo, BindingInput, Expression, ExpressionPersistence, HandTrackingMode, HotkeyConfig, HotkeyState, InjectEntry, InjectTarget, InstanceRuntime, JsonValue, LayerEffectKey, LayerEffects, LayerEffectsPatch, MediaPipeConfig, ModelInfo, ModelRef, MotionGroup, MToonTuning, ObjectContent, ObjectLightOverride, ObjectSpace, Place2D, Place3D, PlayingMotion, PoseSourceId, PoseStatus, Scene, SceneItem, SceneLight, SceneLightCameraFollowOptions, ScenePatch, SceneState, ScreenPlacement, Settings, SettingsPatch, TrackingLostBehavior, TrackingSourceConfig, TrackingSourceId, TrackingSourceKind, TrackingStatus, VrmPlacement } from './types.ts';
@@ -633,6 +634,23 @@ export interface BindingOverrideRequest extends BindingTarget {
633
634
  value: number | null;
634
635
  }
635
636
  export type BindingOverrideResponse = EmptyResponse;
637
+ /** `modelId` defaults to the primary model's; movement is Live2D-only. */
638
+ export interface ModelGetMovementRequest {
639
+ modelId?: string;
640
+ }
641
+ export interface ModelGetMovementResponse {
642
+ movement: ModelMovementConfig;
643
+ }
644
+ export interface ModelSetMovementRequest {
645
+ modelId?: string;
646
+ movement: ModelMovementEdit;
647
+ }
648
+ export interface ModelSetMovementResponse {
649
+ /** The configuration now moving the model, whether or not it reached the file. */
650
+ movement: ModelMovementConfig;
651
+ /** False when nothing reached the file: a refused write (read-only, unreadable), or no usable field. */
652
+ saved: boolean;
653
+ }
636
654
  export interface InstanceSetBreathRequest {
637
655
  instanceId: string;
638
656
  breath?: boolean;
@@ -974,6 +992,14 @@ export interface MethodMap {
974
992
  request: ModelRegisterRequest;
975
993
  response: ModelRegisterResponse;
976
994
  };
995
+ 'model.getMovement': {
996
+ request: ModelGetMovementRequest;
997
+ response: ModelGetMovementResponse;
998
+ };
999
+ 'model.setMovement': {
1000
+ request: ModelSetMovementRequest;
1001
+ response: ModelSetMovementResponse;
1002
+ };
977
1003
  'asset.register': {
978
1004
  request: AssetRegisterRequest;
979
1005
  response: AssetRegisterResponse;
@@ -60,6 +60,8 @@ export const METHOD_NAMES = Object.keys({
60
60
  'automation.run': true,
61
61
  'model.list': true,
62
62
  'model.register': true,
63
+ 'model.getMovement': true,
64
+ 'model.setMovement': true,
63
65
  'asset.list': true,
64
66
  'asset.register': true,
65
67
  'registry.thumbnail': true,
@@ -216,6 +216,13 @@ export declare const requestSchemas: {
216
216
  'model.register': z.ZodObject<{
217
217
  path: z.ZodString;
218
218
  }, z.core.$strip>;
219
+ 'model.getMovement': z.ZodObject<{
220
+ modelId: z.ZodOptional<z.ZodString>;
221
+ }, z.core.$strip>;
222
+ 'model.setMovement': z.ZodObject<{
223
+ modelId: z.ZodOptional<z.ZodString>;
224
+ movement: z.ZodCustom<Partial<Pick<import("../../index.ts").ModelMovementConfig, "enabled" | "x" | "y" | "z">>, Partial<Pick<import("../../index.ts").ModelMovementConfig, "enabled" | "x" | "y" | "z">>>;
225
+ }, z.core.$strip>;
219
226
  'asset.register': z.ZodObject<{
220
227
  path: z.ZodString;
221
228
  want: z.ZodOptional<z.ZodEnum<{
@@ -128,6 +128,12 @@ export const requestSchemas = {
128
128
  }),
129
129
  'tracking.removeSource': z.object({ id: nonEmpty }),
130
130
  'model.register': z.object({ path: nonEmpty }),
131
+ 'model.getMovement': z.object({ modelId: nonEmpty.optional() }),
132
+ // Healed by the host like the desktop editor's own edits, so only the shape is checked here.
133
+ 'model.setMovement': z.object({
134
+ modelId: nonEmpty.optional(),
135
+ movement: z.custom(isRecord, 'movement must be an object'),
136
+ }),
131
137
  // Straight off ASSET_KINDS: a kind added there has to reach the wire gate too, or
132
138
  // `want` answers invalid-params for a kind the registry already knows how to take.
133
139
  'asset.register': z.object({ path: nonEmpty, want: z.enum(ASSET_KINDS).optional() }),
@@ -1041,7 +1041,7 @@ export interface ScenePatch {
1041
1041
  * App-level features a client gates on (never version-sniff): `hello` and
1042
1042
  * `app.info` report them — the per-app mirror of {@link InstanceRuntime.capabilities}.
1043
1043
  */
1044
- export declare const APP_CAPABILITIES: readonly ["storage", "speech", "automations", "controllers", "model-editing", "asset-inspection", "layer-effects", "scene-transitions", "area-lights", "spot-lights", "camera-follow-lights", "shadow-filters", "environment-map-model", "spawn", "tracking-lost", "motion-stop", "stage-capture"];
1044
+ export declare const APP_CAPABILITIES: readonly ["storage", "speech", "automations", "controllers", "model-editing", "asset-inspection", "layer-effects", "scene-transitions", "area-lights", "spot-lights", "camera-follow-lights", "shadow-filters", "environment-map-model", "spawn", "tracking-lost", "motion-stop", "stage-capture", "model-movement"];
1045
1045
  export type AppCapability = (typeof APP_CAPABILITIES)[number];
1046
1046
  export declare function isAppCapability(v: unknown): v is AppCapability;
1047
1047
  /** What a loaded model instance can do; absent capabilities answer `unsupported-for-format`. */
@@ -53,6 +53,8 @@ export const APP_CAPABILITIES = [
53
53
  'motion-stop',
54
54
  /** `stage.capture`. */
55
55
  'stage-capture',
56
+ /** `model.getMovement` / `model.setMovement` and the `model.movement` event. */
57
+ 'model-movement',
56
58
  ];
57
59
  export function isAppCapability(v) {
58
60
  return isOneOf(v, APP_CAPABILITIES);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@laplace.live/persona-sdk",
3
- "version": "1.19.0",
3
+ "version": "1.20.0",
4
4
  "description": "TypeScript SDK and wire schema for the LAPLACE Persona plugin API",
5
5
  "license": "MIT",
6
6
  "type": "module",