@laplace.live/persona-sdk 0.2.0 → 0.4.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/README.md +13 -0
- package/dist/methods.d.ts +10 -0
- package/dist/schemas.d.ts +4 -0
- package/dist/schemas.js +1 -0
- package/dist/types.d.ts +59 -15
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -67,3 +67,16 @@ in Persona). The client reports them via `onWarning` and goes `closed`.
|
|
|
67
67
|
Treat the token like a password: it grants control of the app, including loading registered
|
|
68
68
|
models and web overlays. The server listens on loopback unless LAN access is enabled in
|
|
69
69
|
Persona's settings.
|
|
70
|
+
|
|
71
|
+
## Registry and catalog metadata
|
|
72
|
+
|
|
73
|
+
`model.list` / `asset.list` return refs with provenance and attribution: assets carry
|
|
74
|
+
`origin` (`'bundled'` shipped with the app, `'user'` registered by the user; models carry
|
|
75
|
+
the same as `kind`), and both may carry optional `author` / `url` credits sourced from the
|
|
76
|
+
app's content manifest.
|
|
77
|
+
|
|
78
|
+
`CatalogItem` is the transport-agnostic content-metadata shape behind pickers: a stable
|
|
79
|
+
`id` (scene refs key off it), an `InventoryKind`, display `name`, and optional
|
|
80
|
+
`thumbnailUrl`, `version`, `author`, `url`, and `download` (payload location + integrity
|
|
81
|
+
for items not yet on disk — Persona will use this to ship bundled content as
|
|
82
|
+
metadata-only rows downloaded from its CDN on demand).
|
package/dist/methods.d.ts
CHANGED
|
@@ -59,6 +59,11 @@ export interface InstanceAddRequest {
|
|
|
59
59
|
export interface InstanceAddResponse {
|
|
60
60
|
instanceId: string;
|
|
61
61
|
}
|
|
62
|
+
export interface InstanceSetModelRequest {
|
|
63
|
+
instanceId: string;
|
|
64
|
+
modelId: string;
|
|
65
|
+
}
|
|
66
|
+
export type InstanceSetModelResponse = EmptyResponse;
|
|
62
67
|
export interface InstanceRemoveRequest {
|
|
63
68
|
instanceId: string;
|
|
64
69
|
}
|
|
@@ -394,6 +399,11 @@ export interface MethodMap {
|
|
|
394
399
|
request: InstanceAddRequest;
|
|
395
400
|
response: InstanceAddResponse;
|
|
396
401
|
};
|
|
402
|
+
/** Swap a model layer's model in place; placement, primary status, and identity carry over. */
|
|
403
|
+
'instance.setModel': {
|
|
404
|
+
request: InstanceSetModelRequest;
|
|
405
|
+
response: InstanceSetModelResponse;
|
|
406
|
+
};
|
|
397
407
|
/** Removes any scene item — model or object. */
|
|
398
408
|
'instance.remove': {
|
|
399
409
|
request: InstanceRemoveRequest;
|
package/dist/schemas.d.ts
CHANGED
|
@@ -64,6 +64,10 @@ export declare const requestSchemas: {
|
|
|
64
64
|
'instance.add': z.ZodObject<{
|
|
65
65
|
modelId: z.ZodString;
|
|
66
66
|
}, z.core.$strip>;
|
|
67
|
+
'instance.setModel': z.ZodObject<{
|
|
68
|
+
instanceId: z.ZodString;
|
|
69
|
+
modelId: z.ZodString;
|
|
70
|
+
}, z.core.$strip>;
|
|
67
71
|
'object.add': z.ZodObject<{
|
|
68
72
|
content: z.ZodCustom<ObjectContent, ObjectContent>;
|
|
69
73
|
name: z.ZodOptional<z.ZodString>;
|
package/dist/schemas.js
CHANGED
|
@@ -40,6 +40,7 @@ export const requestSchemas = {
|
|
|
40
40
|
'scene.delete': z.object({ sceneId: nonEmpty }),
|
|
41
41
|
'scene.setShortcut': z.object({ sceneId: nonEmpty, accelerator: nonEmpty.nullable() }),
|
|
42
42
|
'instance.add': z.object({ modelId: nonEmpty }),
|
|
43
|
+
'instance.setModel': z.object({ instanceId: nonEmpty, modelId: nonEmpty }),
|
|
43
44
|
'object.add': z.object({
|
|
44
45
|
content: z.custom(isRecord, 'content must be an object'),
|
|
45
46
|
name: nonEmpty.optional(),
|
package/dist/types.d.ts
CHANGED
|
@@ -1,23 +1,63 @@
|
|
|
1
1
|
export type ModelFormat = 'live2d' | 'vrm';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/** Where an item came from: shipped with the app, or added by the user. */
|
|
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 type AssetKind = 'image' | 'video' | 'prop' | 'ibl' | 'lut' | 'animation';
|
|
6
|
+
/** Every content kind the Inventory can list. `pngtuber` is schema-ready before any producer exists. */
|
|
7
|
+
export type InventoryKind = ModelFormat | 'pngtuber' | AssetKind;
|
|
8
|
+
/**
|
|
9
|
+
* What every registry entry carries, model or asset alike. `kind` is always *what
|
|
10
|
+
* the thing is* and `origin` always *where it came from* — the two were once
|
|
11
|
+
* `format`/`kind` on models and `kind`/`origin` on assets, which made `kind` mean
|
|
12
|
+
* opposite things on the two types.
|
|
13
|
+
*
|
|
14
|
+
* Paths deliberately never cross the wire; the registries keep those private.
|
|
15
|
+
*/
|
|
16
|
+
export interface ContentRef {
|
|
17
|
+
/** Stable slug, unique per installed item. Scene refs key off it. */
|
|
6
18
|
id: string;
|
|
7
19
|
name: string;
|
|
8
|
-
kind:
|
|
9
|
-
|
|
20
|
+
kind: InventoryKind;
|
|
21
|
+
origin: ContentOrigin;
|
|
22
|
+
/** Creator credit, for attribution in pickers. */
|
|
23
|
+
author?: string;
|
|
24
|
+
/** Creator or content homepage (https). */
|
|
25
|
+
url?: string;
|
|
26
|
+
}
|
|
27
|
+
/** A model as the registry lists it. */
|
|
28
|
+
export interface ModelRef extends ContentRef {
|
|
29
|
+
kind: ModelFormat;
|
|
10
30
|
}
|
|
11
|
-
/** How a registered file is labelled. Wider than an object's content kinds: `.hdr` is only ever an environment map. */
|
|
12
|
-
export type AssetKind = 'image' | 'video' | 'prop' | 'ibl' | 'lut';
|
|
13
31
|
/** A registered object-source file. `exists` is false once the file is gone from disk. */
|
|
14
|
-
export interface AssetRef {
|
|
15
|
-
id: string;
|
|
16
|
-
name: string;
|
|
32
|
+
export interface AssetRef extends ContentRef {
|
|
17
33
|
/** What the extension makes it — an object created from it starts on this kind. */
|
|
18
34
|
kind: AssetKind;
|
|
19
35
|
exists: boolean;
|
|
20
36
|
}
|
|
37
|
+
/**
|
|
38
|
+
* Content metadata decoupled from any on-disk file — local registry entries and
|
|
39
|
+
* remote catalog rows both map into it. `id` is stable forever: scene refs key
|
|
40
|
+
* off it, and it must survive a ship-in-app → download-from-CDN migration.
|
|
41
|
+
*
|
|
42
|
+
* A {@link ContentRef} minus `origin`, which a remote row has no answer for until
|
|
43
|
+
* it is installed, plus what only a catalog knows (thumbnail, payload, revision).
|
|
44
|
+
*/
|
|
45
|
+
export interface CatalogItem extends Omit<ContentRef, 'origin'> {
|
|
46
|
+
/** `persona://` for local items; CDN https for metadata-only rows. */
|
|
47
|
+
thumbnailUrl?: string;
|
|
48
|
+
/** Payload location + integrity when not on disk; absent = already local. */
|
|
49
|
+
download?: {
|
|
50
|
+
url: string;
|
|
51
|
+
size: number;
|
|
52
|
+
sha256: string;
|
|
53
|
+
};
|
|
54
|
+
/** Content revision, for CDN-side updates of an installed item. */
|
|
55
|
+
version?: string;
|
|
56
|
+
/** Creator credit, for attribution in the Inventory row/detail. */
|
|
57
|
+
author?: string;
|
|
58
|
+
/** Creator or content homepage (https). */
|
|
59
|
+
url?: string;
|
|
60
|
+
}
|
|
21
61
|
/** Screen-space placement: pixels from the stage centre, rotation in radians. */
|
|
22
62
|
export interface ScreenPlacement {
|
|
23
63
|
x: number;
|
|
@@ -172,11 +212,11 @@ export interface SceneObjectItem {
|
|
|
172
212
|
/** Anything the stage renders. Array order in {@link Scene.items} is z-order within each space. */
|
|
173
213
|
export type SceneItem = SceneModelItem | SceneObjectItem;
|
|
174
214
|
export type BackgroundMode = 'transparent' | 'color' | 'image';
|
|
175
|
-
/** `
|
|
215
|
+
/** `imageAssetId` names a registered asset; an id this app cannot resolve renders transparent. */
|
|
176
216
|
export interface SceneBackground {
|
|
177
217
|
mode: BackgroundMode;
|
|
178
218
|
color: string;
|
|
179
|
-
|
|
219
|
+
imageAssetId: string | null;
|
|
180
220
|
}
|
|
181
221
|
export interface SceneBehavior {
|
|
182
222
|
lookAtCursor: boolean;
|
|
@@ -368,11 +408,15 @@ export interface AnchorOption {
|
|
|
368
408
|
anchor: AttachAnchor;
|
|
369
409
|
label: string;
|
|
370
410
|
}
|
|
371
|
-
/**
|
|
411
|
+
/**
|
|
412
|
+
* Panel-style model info block. Format-specific fields mirror the app's `ModelInfo`.
|
|
413
|
+
* `format` stays the union's discriminant here — this is a runtime diagnostic, not
|
|
414
|
+
* content metadata, so it does not follow {@link ContentRef}'s `kind`.
|
|
415
|
+
*/
|
|
372
416
|
export interface ModelInfo {
|
|
373
417
|
format: ModelFormat;
|
|
374
418
|
name: string;
|
|
375
|
-
|
|
419
|
+
origin: ContentOrigin;
|
|
376
420
|
file: string;
|
|
377
421
|
loadMs: number;
|
|
378
422
|
/** Format-specific details (canvas/params/textures for Live2D, spec/bones for VRM). */
|