@plupin/character 0.0.0-stage → 0.3.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.
Files changed (53) hide show
  1. package/dist/anime-face.d.ts +42 -0
  2. package/dist/anime-face.js +14 -0
  3. package/dist/blob.d.ts +32 -0
  4. package/dist/blob.js +18 -0
  5. package/dist/body-presets.d.ts +85 -0
  6. package/dist/canvas.d.ts +79 -0
  7. package/dist/canvas.js +315 -0
  8. package/dist/chunk-09c5tps4.js +337 -0
  9. package/dist/chunk-60p135hw.js +103 -0
  10. package/dist/chunk-aa5nstet.js +39 -0
  11. package/dist/chunk-dpb0rnw9.js +37 -0
  12. package/dist/chunk-g1c0wdcj.js +825 -0
  13. package/dist/chunk-kber92gm.js +415 -0
  14. package/dist/chunk-sa2r1cxz.js +342 -0
  15. package/dist/chunk-yd5zzkkg.js +313 -0
  16. package/dist/clip-bake.d.ts +48 -0
  17. package/dist/clip-bake.js +132 -0
  18. package/dist/clips.d.ts +40 -0
  19. package/dist/dress.d.ts +4 -0
  20. package/dist/emote.d.ts +25 -0
  21. package/dist/faces.d.ts +10 -0
  22. package/dist/faces.js +12 -0
  23. package/dist/gaze.d.ts +81 -0
  24. package/dist/gaze.js +113 -0
  25. package/dist/hair3d.d.ts +3 -0
  26. package/dist/index.d.ts +19 -0
  27. package/dist/index.js +176 -0
  28. package/dist/listing.d.ts +195 -0
  29. package/dist/listing.js +763 -0
  30. package/dist/named-faces.d.ts +22 -0
  31. package/dist/platform-body-data.d.ts +9 -0
  32. package/dist/platform-body.d.ts +91 -0
  33. package/dist/plup2d.d.ts +29 -0
  34. package/dist/plup3d.d.ts +121 -0
  35. package/dist/png.d.ts +78 -0
  36. package/dist/pose.d.ts +49 -0
  37. package/dist/pose.js +18 -0
  38. package/dist/proportions.d.ts +31 -0
  39. package/dist/ragdoll.d.ts +51 -0
  40. package/dist/resolution.d.ts +21 -0
  41. package/dist/rig.d.ts +29 -0
  42. package/dist/skin-map.d.ts +155 -0
  43. package/dist/skin-map.js +55 -0
  44. package/dist/skin-native.d.ts +301 -0
  45. package/dist/skin.d.ts +35 -0
  46. package/dist/texture.d.ts +8 -0
  47. package/dist/three.d.ts +25 -0
  48. package/dist/three.js +2302 -0
  49. package/dist/wear3d.d.ts +99 -0
  50. package/dist/wearables.d.ts +203 -0
  51. package/dist/wearables.js +26 -0
  52. package/package.json +78 -4
  53. package/README.md +0 -3
@@ -0,0 +1,195 @@
1
+ import { type ClipName, type CustomClip } from "./pose";
2
+ import type { CanonicalBone } from "./rig";
3
+ import { type FaceName } from "./skin";
4
+ import { type BodyScale } from "./skin-native";
5
+ /**
6
+ * A listing is a composition, not a file: an emote is `{ glyph, face, clip }` and an item is
7
+ * `{ color }` on a slot the character already has. This module is that composition — the words for
8
+ * it, the one validator every writer uses, and the one renderer that draws the headshot.
9
+ *
10
+ * It lives in the shared character package for a reason the emote slice had to learn: three
11
+ * surfaces now author an emote (the CLI, the hosted MCP tool, the Studio) and two of them must show
12
+ * the creator what will be reviewed *before* the upload. A second copy of the drawing code would
13
+ * make "this is what the moderator will see" a claim instead of an identity, and the preview a
14
+ * creator approves would drift from the bytes the shop sells. `apps/server` and `packages/api` call
15
+ * this file; so does `packages/cli`. Nothing here touches a database, a network or a DOM.
16
+ */
17
+ /** The slots a creator may list. A face is drawn by the platform, never uploaded. */
18
+ export declare const LISTABLE_SLOTS: readonly ["outfit", "hair", "accessory", "emote"];
19
+ export type ListingSlot = (typeof LISTABLE_SLOTS)[number];
20
+ /**
21
+ * What an uploaded animation is measured against, the way Roblox caps an animation: short, bounded
22
+ * and small. One home, so the CLI, the MCP tool and the server refuse with the same numbers.
23
+ */
24
+ export declare const ANIM_CAPS: {
25
+ readonly maxFps: 30;
26
+ readonly maxFrames: 240;
27
+ readonly maxSeconds: 8;
28
+ /** Radians a bone may be turned: a little over half a turn, so nothing spins through itself. */
29
+ readonly maxRotation: 3.2;
30
+ /** Straight legs cannot crouch: a negative lift would sink the feet into the floor. */
31
+ readonly minLift: 0;
32
+ readonly maxLift: 3;
33
+ /** The animation as JSON. */
34
+ readonly maxBytes: number;
35
+ };
36
+ /**
37
+ * The item kinds this module now understands, named the way the epic names them (#909 section 2).
38
+ * The manifest field that carries each one is in the map, so a refusal can say both words:
39
+ *
40
+ * - `sheet` -> `assetConfig.sheet`, a shirt or pants PNG on the Roblox classic template.
41
+ * - `bodyVariant`-> `assetConfig.variant`, a per-part sprite sheet on the Plupin-native grid.
42
+ * - `accessory` -> `assetConfig.sprite`, a small accessory image for the hair/accessory slots.
43
+ * - `color` -> `assetConfig.color`, the one-field item the marketplace shipped with.
44
+ */
45
+ export declare const ITEM_ASSET_KINDS: {
46
+ readonly color: "color";
47
+ readonly sheet: "sheet";
48
+ readonly bodyVariant: "variant";
49
+ readonly accessory: "sprite";
50
+ };
51
+ export type ItemAssetKind = keyof typeof ITEM_ASSET_KINDS;
52
+ /**
53
+ * The caps every uploaded image is measured against before it can be listed. One home, next to the
54
+ * validator and the renderer, so `plupin emote preview`, the MCP tool and the server refuse with the
55
+ * same numbers.
56
+ *
57
+ * - A classic `sheet` is exactly the Roblox template `skin.ts` maps (585 x 559) and at most 160 KiB:
58
+ * the same 4 bits per pixel the native cap asks for (327375 px / 2). Flat pixel art clears it by a
59
+ * wide margin; the cap only bites on photographic art, which is the point.
60
+ * - A `bodyVariant` is the native grid itself, imported rather than restated: `NATIVE_SHEET_CAPS`
61
+ * owns 512 x 256 and 64 KiB.
62
+ * - An `accessory` sprite is drawn on one face rect of that grid, so it is at most 64 x 64 px (the
63
+ * largest face, the torso's front), at least 1 x 1, and at most 8 KiB.
64
+ *
65
+ * All three are PNG-24: 8-bit truecolour with optional 8-bit alpha, no palette, not interlaced.
66
+ * `png.ts` enforces the format; these numbers bound the work.
67
+ */
68
+ export declare const LISTING_ASSET_CAPS: {
69
+ readonly sheet: {
70
+ readonly width: 585;
71
+ readonly height: 559;
72
+ readonly maxBytes: number;
73
+ };
74
+ readonly bodyVariant: {
75
+ readonly width: 512;
76
+ readonly height: 256;
77
+ readonly maxBytes: number;
78
+ };
79
+ readonly accessory: {
80
+ readonly maxWidth: 64;
81
+ readonly maxHeight: 64;
82
+ readonly maxBytes: number;
83
+ };
84
+ };
85
+ /** The six canonical bones a variant may redraw, in the order a refusal lists them. */
86
+ export declare const VARIANT_PARTS: readonly ["torso", "head", "armL", "armR", "legL", "legR"];
87
+ /** The six faces of a part, in the order the classic and native maps list them. */
88
+ export declare const VARIANT_FACES: readonly FaceName[];
89
+ /** A classic-template shirt or pants PNG, as one listing kind. */
90
+ export type SheetAssetConfig = {
91
+ /** `data:image/png;base64,...`: the bytes the moderator reviews, unchanged. */
92
+ sheet: string;
93
+ layer: "shirt" | "pants";
94
+ };
95
+ /** One part a variant redraws, and which of its faces the sheet actually carries art for. */
96
+ export type VariantPartEntry = {
97
+ part: CanonicalBone;
98
+ faces: FaceName[];
99
+ };
100
+ /** A per-part sprite sheet on the native grid, with an optional clamped proportion profile. */
101
+ export type BodyVariantAssetConfig = {
102
+ /** `data:image/png;base64,...`, exactly the native grid. */
103
+ variant: string;
104
+ parts: VariantPartEntry[];
105
+ scale?: BodyScale;
106
+ };
107
+ /** A small accessory sprite for the hair or accessory slot. */
108
+ export type SpriteAssetConfig = {
109
+ sprite: string;
110
+ };
111
+ /** A validated emote: `glyph` and `clip` are required, a face is either named or drawn. */
112
+ export type EmoteAssetConfig = {
113
+ glyph: string;
114
+ clip: ClipName;
115
+ /** Keyframes that play instead of `clip`; `clip` stays as what an older renderer shows. */
116
+ anim?: CustomClip;
117
+ face?: string;
118
+ /** Four rows of eight palette keys: the creator's own 8 x 4 stamp. */
119
+ faceStamp?: string[];
120
+ };
121
+ /** A validated item: one hex colour on an existing cosmetic slot. */
122
+ export type ItemAssetConfig = {
123
+ color: string;
124
+ };
125
+ export type ListingAssetConfig = EmoteAssetConfig | ItemAssetConfig | SheetAssetConfig | BodyVariantAssetConfig | SpriteAssetConfig;
126
+ /** The manifest as the platform stores it: normalised, with any asset digest it earned. */
127
+ export type ValidatedListing = {
128
+ assetConfig: ListingAssetConfig;
129
+ /** SHA-256 of every non-manifest asset: a creator-drawn face is one. */
130
+ assets: string[];
131
+ };
132
+ /**
133
+ * What a validator answers. A refusal is a sentence, not a code: the CLI prints it and an agent
134
+ * acts on it, and both need the field and the values that would have been accepted.
135
+ */
136
+ export type ListingCheck = {
137
+ ok: true;
138
+ manifest: ValidatedListing;
139
+ } | {
140
+ ok: false;
141
+ message: string;
142
+ };
143
+ /** SHA-256 over a drawn face, so the asset behaves like every other asset of the listing. */
144
+ export declare function faceStampDigest(rows: readonly string[]): Promise<string>;
145
+ /** The digest an animation contributes to the content hash, like a drawn face does. */
146
+ export declare function animDigest(anim: CustomClip): Promise<string>;
147
+ /**
148
+ * The one validator: every writer of a listing manifest goes through it, so the stored
149
+ * `asset_config` is always something this package can render.
150
+ */
151
+ export declare function checkListingManifest(input: {
152
+ slot: string;
153
+ assetConfig: unknown;
154
+ }): Promise<ListingCheck>;
155
+ /**
156
+ * The starter composition `emote new` writes and the hosted MCP tool hands back. One default for
157
+ * every surface: an agency that scaffolds in the CLI and then tweaks it through MCP edits the same
158
+ * manifest it started from.
159
+ */
160
+ export declare function starterManifest(input: {
161
+ id: string;
162
+ name: string;
163
+ slot?: ListingSlot;
164
+ sigmaPrice?: number;
165
+ glyph?: string;
166
+ face?: string;
167
+ /** Free text on purpose: `checkListingManifest` refuses an unknown clip by naming the ones that exist. */
168
+ clip?: string;
169
+ color?: string;
170
+ }): {
171
+ id: string;
172
+ slot: ListingSlot;
173
+ name: string;
174
+ sigmaPrice: number;
175
+ assetConfig: Record<string, unknown>;
176
+ };
177
+ /** Which extended item kind a stored manifest carries; null for an emote or a colour-only item. */
178
+ export declare function itemAssetKindOf(assetConfig: unknown): ItemAssetKind | null;
179
+ /**
180
+ * One listing, as the picture a reviewer decides on. Pure: the same subject always renders the
181
+ * same bytes, so storing it is the same as re-rendering it, and a hash of it can be compared.
182
+ *
183
+ * It reads the manifest defensively because platform-seeded rows (migration 0058) are also a
184
+ * `{glyph, face, clip}` or `{color}` config, and the same renderer explains them.
185
+ */
186
+ export declare function renderListingPreview(input: {
187
+ slot: ListingSlot | "face" | "hat";
188
+ name: string;
189
+ assetConfig: unknown;
190
+ }): string;
191
+ /**
192
+ * A `data:` URL, so the queue, the shop and a terminal transcript can render the stored bytes with
193
+ * no second round trip and no route that could serve a different picture.
194
+ */
195
+ export declare function previewDataUrl(svg: string): string;