@skinhub/viewer 0.1.1

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 (48) hide show
  1. package/EMBED.md +442 -0
  2. package/README.md +153 -0
  3. package/dist/SkinViewer.d.ts +18 -0
  4. package/dist/SkinViewer.d.ts.map +1 -0
  5. package/dist/SkinViewer.js +404 -0
  6. package/dist/SkinViewer.js.map +1 -0
  7. package/dist/index.d.ts +53 -0
  8. package/dist/index.d.ts.map +1 -0
  9. package/dist/index.js +51 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/item.d.ts +118 -0
  12. package/dist/item.d.ts.map +1 -0
  13. package/dist/item.js +319 -0
  14. package/dist/item.js.map +1 -0
  15. package/dist/link.d.ts +30 -0
  16. package/dist/link.d.ts.map +1 -0
  17. package/dist/link.js +18 -0
  18. package/dist/link.js.map +1 -0
  19. package/dist/protocol.d.ts +231 -0
  20. package/dist/protocol.d.ts.map +1 -0
  21. package/dist/protocol.js +128 -0
  22. package/dist/protocol.js.map +1 -0
  23. package/dist/state.d.ts +107 -0
  24. package/dist/state.d.ts.map +1 -0
  25. package/dist/state.js +351 -0
  26. package/dist/state.js.map +1 -0
  27. package/dist/types.d.ts +573 -0
  28. package/dist/types.d.ts.map +1 -0
  29. package/dist/types.js +106 -0
  30. package/dist/types.js.map +1 -0
  31. package/dist/useSkinViewer.d.ts +3 -0
  32. package/dist/useSkinViewer.d.ts.map +1 -0
  33. package/dist/useSkinViewer.js +66 -0
  34. package/dist/useSkinViewer.js.map +1 -0
  35. package/dist/weapons.d.ts +109 -0
  36. package/dist/weapons.d.ts.map +1 -0
  37. package/dist/weapons.js +260 -0
  38. package/dist/weapons.js.map +1 -0
  39. package/package.json +65 -0
  40. package/src/SkinViewer.tsx +465 -0
  41. package/src/index.ts +88 -0
  42. package/src/item.ts +373 -0
  43. package/src/link.ts +33 -0
  44. package/src/protocol.ts +241 -0
  45. package/src/state.ts +389 -0
  46. package/src/types.ts +672 -0
  47. package/src/useSkinViewer.ts +80 -0
  48. package/src/weapons.ts +284 -0
package/dist/state.js ADDED
@@ -0,0 +1,351 @@
1
+ /**
2
+ * *** PROPS → A URL, AND THEN PROPS → PATCHES. ***
3
+ *
4
+ * ═════════════════════════════════════════════════════════════════════════════════════════════
5
+ * *** THE TWO DOORS, AND WHY THIS PACKAGE USES BOTH RATHER THAN PICKING ONE. ***
6
+ *
7
+ * `/frame` can be driven by a query string or by `set` messages, and both go through the same
8
+ * applier on the far side. This package uses the URL for the FIRST render and messages for every
9
+ * render after it, and the split is not an optimisation - it is the only arrangement that gets both
10
+ * properties an integrator will judge us on:
11
+ *
12
+ * THE FIRST PAINT IS THEIR ITEM, not ours swapped a tick later. A frame that booted on our default
13
+ * AK and was corrected by a message would show the wrong gun for one round trip, on a product page.
14
+ *
15
+ * NO LATER PROP CHANGE TOUCHES THE `src`. *** THIS IS THE LOAD-BEARING ONE. *** Rewriting `src`
16
+ * reloads the document, which throws away the GL context, re-downloads the model and re-runs every
17
+ * shader compile - i.e. it turns a float slider into a five-second stall. So the URL is built once,
18
+ * frozen, and everything after it is a patch. See `SkinViewer.tsx`, where the same rule is enforced
19
+ * on the element.
20
+ *
21
+ * ═════════════════════════════════════════════════════════════════════════════════════════════
22
+ * *** AND THE REASON {@link diffState} IS A DIFF RATHER THAN "SEND THE WHOLE STATE EVERY TIME". ***
23
+ *
24
+ * Sending everything would be correct - the frame's merge returns the SAME OBJECT when the values it
25
+ * is handed are the values it already has, so a restated `weaponType` costs nothing and does not
26
+ * reload. It would still be wrong, for one reason: `stickers` is an ARRAY WE REBUILD ON EVERY RENDER.
27
+ * The renderer holds its sticker draft against that array BY IDENTITY, so a fresh six-slot tuple
28
+ * arriving on every tick of somebody's float slider would re-seed the draft sixty times a second and
29
+ * fight the user's own drag. The frame's own protocol file warns about exactly this.
30
+ *
31
+ * So the diff is structural: a field is in the patch only if its VALUE moved.
32
+ */
33
+ import { resolveSubject } from './item.js';
34
+ const HELP_FOR = {
35
+ 'no-item': 'no-item',
36
+ 'bad-inspect-link': 'bad-link',
37
+ 'unknown-weapon': 'unknown-weapon',
38
+ 'render-failed': null,
39
+ 'bad-message': null,
40
+ 'protocol-mismatch': null,
41
+ // There is no help card for an embed that never loaded: the card is drawn BY the frame, and the
42
+ // frame is the thing that did not arrive.
43
+ unreachable: null,
44
+ };
45
+ /**
46
+ * One render's props as {@link DesiredState}. Pure, synchronous, no React - so it can run in a
47
+ * `useState` initialiser during SSR as well as on every subsequent render.
48
+ *
49
+ * *** IT TAKES A `Partial<>` OF ITS OWN PROP TYPE ON PURPOSE. *** The types make a missing item a
50
+ * compile error; this function is what happens when the types were bypassed - plain JavaScript, an
51
+ * `any`, a query that had not resolved - and its whole value is that it has an answer for that case
52
+ * rather than a `TypeError`.
53
+ */
54
+ export const resolveState = (props) => {
55
+ const subject = resolveSubject(props);
56
+ const settings = toFrameSettings(props.settings);
57
+ return {
58
+ item: subject.item,
59
+ inspectPayload: subject.inspectPayload,
60
+ help: subject.error ? HELP_FOR[subject.error.code] : null,
61
+ subjectError: subject.error,
62
+ ...(props.view !== undefined && { view: props.view }),
63
+ ...(props.agent !== undefined && { agent: props.agent }),
64
+ ...(props.gloves !== undefined && { gloves: props.gloves }),
65
+ ...(settings !== undefined && { settings }),
66
+ ...(props.interactions !== undefined && { interactions: { ...props.interactions } }),
67
+ ...(props.editingSlot !== undefined && { editingSlot: props.editingSlot }),
68
+ };
69
+ };
70
+ /**
71
+ * The public settings as the wire's.
72
+ *
73
+ * A STRUCTURAL COPY RATHER THAN A PASS-THROUGH, so the object that goes on the wire is one this
74
+ * package built: a caller who mutates the object they passed us cannot change what a later diff
75
+ * compares against, and a field we do not know about cannot ride along into a `postMessage` where the
76
+ * frame would name it in `problems`.
77
+ */
78
+ const toFrameSettings = (settings) => {
79
+ if (!settings)
80
+ return undefined;
81
+ const out = {};
82
+ if (settings.camera)
83
+ out.camera = { ...settings.camera };
84
+ if (settings.quality)
85
+ out.quality = { ...settings.quality };
86
+ if (settings.environment)
87
+ out.environment = { ...settings.environment };
88
+ if (settings.overlays)
89
+ out.overlays = {
90
+ ...settings.overlays,
91
+ ...(settings.overlays.gizmoStyle && { gizmoStyle: { ...settings.overlays.gizmoStyle } }),
92
+ };
93
+ return out;
94
+ };
95
+ /* ═════════════════════════════════════════════════════════════════════════════════════════════
96
+ * THE URL
97
+ * ═══════════════════════════════════════════════════════════════════════════════════════════ */
98
+ /** `EMBED.md` §8: `0` is off, anything else present is on, absent leaves the field alone. */
99
+ const flag = (params, key, value) => {
100
+ if (value !== undefined)
101
+ params.set(key, value ? '1' : '0');
102
+ };
103
+ const num = (params, key, value) => {
104
+ if (value !== undefined)
105
+ params.set(key, String(value));
106
+ };
107
+ /**
108
+ * The initial `<iframe src>`, and the state that URL actually expressed.
109
+ *
110
+ * *** THE SECOND RETURN VALUE IS NOT BOOKKEEPING - IT IS THE BASELINE EVERY LATER PATCH IS MEASURED
111
+ * AGAINST. *** One field is deliberately NOT encodable: the stickers, which the query string can only
112
+ * carry inside an `?i=` payload. Rather than re-encode a placement into an inspect link here - a
113
+ * second implementation of a codec whose only job would be to disagree with the frame's decoder - the
114
+ * stickers are simply left out of the URL and reported as unsent, so the first diff after the frame
115
+ * announces itself carries them. They are a CHEAP field, so they arrive without a loading card, and
116
+ * in practice they arrive long before the model has finished downloading.
117
+ *
118
+ * When the integrator gave us an inspect link there is nothing to encode: their own payload goes
119
+ * through as `?i=` and carries the stickers with it.
120
+ */
121
+ export const frameUrl = (origin, desired) => {
122
+ const params = new URLSearchParams();
123
+ const item = desired.item;
124
+ if (desired.help)
125
+ params.set('help', desired.help);
126
+ if (item) {
127
+ params.set('weapon', item.weaponType);
128
+ params.set('paint', String(item.paintIndex));
129
+ if (item.legacyModel !== undefined)
130
+ flag(params, 'legacy', item.legacyModel);
131
+ if (desired.inspectPayload)
132
+ params.set('i', desired.inspectPayload);
133
+ /*
134
+ * WRITTEN AFTER `?i=` AND THAT ORDER IS THE CONTRACT: a plain `float=`/`seed=`/`st=`/`nametag=`
135
+ * beats the same field inside `?i=`, because the explicit one is the more specific statement.
136
+ * Here they carry the same values anyway - both came out of the same decode - so the ordering
137
+ * only matters for a host that passes both, and it matters that we agree with the documented rule
138
+ * rather than relying on them not to.
139
+ */
140
+ num(params, 'float', item.float);
141
+ num(params, 'seed', item.seed);
142
+ // `st=0` is a real, freshly-minted counter; `st=-1` removes the module; absent means no module.
143
+ if (item.statTrak !== undefined)
144
+ params.set('st', item.statTrak === false ? '-1' : String(item.statTrak));
145
+ if (item.nameTag !== undefined)
146
+ params.set('nametag', item.nameTag ?? '');
147
+ }
148
+ if (desired.view)
149
+ params.set('view', desired.view);
150
+ if (desired.agent?.id !== undefined)
151
+ params.set('agent', String(desired.agent.id));
152
+ if (desired.agent?.pose)
153
+ params.set('pose', desired.agent.pose);
154
+ if (desired.gloves !== undefined)
155
+ params.set('glove', desired.gloves ? gloveParam(desired.gloves) : 'none');
156
+ const s = desired.settings;
157
+ num(params, 'fov', s?.camera?.fov);
158
+ num(params, 'zoom', s?.camera?.defaultZoom);
159
+ num(params, 'bloom', s?.quality?.bloom);
160
+ num(params, 'spill', s?.quality?.bloomSpill);
161
+ num(params, 'scale', s?.quality?.renderScale);
162
+ flag(params, 'aa', s?.quality?.antialias);
163
+ flag(params, 'shadows', s?.quality?.shadows);
164
+ // `?map=none` is the calibrated reference rig, which is what `map: null` means on the prop.
165
+ if (s?.environment?.map !== undefined)
166
+ params.set('map', s.environment.map ?? 'none');
167
+ if (s?.environment?.timeOfDay)
168
+ params.set('time', s.environment.timeOfDay);
169
+ flag(params, 'rain', s?.environment?.rain);
170
+ if (s?.environment?.background)
171
+ params.set('bg', s.environment.background);
172
+ flag(params, 'stickergizmo', s?.overlays?.stickerGizmo);
173
+ flag(params, 'charmgizmo', s?.overlays?.charmGizmo);
174
+ if (s?.overlays?.gizmoStyle?.color)
175
+ params.set('gizmocolor', s.overlays.gizmoStyle.color);
176
+ if (s?.overlays?.gizmoStyle?.shadowColor)
177
+ params.set('gizmoshadow', s.overlays.gizmoStyle.shadowColor);
178
+ flag(params, 'orbit', desired.interactions?.orbit);
179
+ // The wheel gesture is named after the input that performs it, because `?zoom=` is the camera's.
180
+ flag(params, 'wheel', desired.interactions?.zoom);
181
+ flag(params, 'dragstickers', desired.interactions?.dragStickers);
182
+ flag(params, 'dragcharm', desired.interactions?.dragCharm);
183
+ if (desired.editingSlot !== undefined)
184
+ params.set('slot', String(desired.editingSlot));
185
+ const expressed = item && !desired.inspectPayload && item.stickers ? { ...desired, item: { ...item, stickers: undefined } } : desired;
186
+ return { src: `${origin.replace(/\/+$/, '')}/frame?${params.toString()}`, expressed };
187
+ };
188
+ /** `type:paintIndex[:float[:seed]]` - one param and not four, because they are one item. */
189
+ const gloveParam = (gloves) => [gloves.type, gloves.paintIndex, gloves.float, gloves.seed].filter(part => part !== undefined).join(':');
190
+ /* ═════════════════════════════════════════════════════════════════════════════════════════════
191
+ * THE DIFF
192
+ * ═══════════════════════════════════════════════════════════════════════════════════════════ */
193
+ /**
194
+ * *** WHICH FIELDS RELOAD THE FRAME. *** `EMBED.md`'s cheap-vs-reload table, as a value.
195
+ *
196
+ * The component reads this to decide when to raise a caller's `loading` slot, so the slot is raised
197
+ * on exactly the changes that actually cover the canvas rather than on a guess. `view` and the agent
198
+ * are the same class but are not fields of the item, so they are handled beside it.
199
+ */
200
+ export const IDENTITY_FIELDS = [
201
+ 'weaponType',
202
+ 'paintIndex',
203
+ 'legacyModel',
204
+ ];
205
+ const shallowEqual = (a, b) => {
206
+ if (a === b)
207
+ return true;
208
+ if (!a || !b)
209
+ return false;
210
+ const keys = new Set([...Object.keys(a), ...Object.keys(b)]);
211
+ for (const key of keys)
212
+ if (!Object.is(a[key], b[key]))
213
+ return false;
214
+ return true;
215
+ };
216
+ /** The six slots, field by field. The only deep comparison in this package, and it is fixed-size. */
217
+ const slotsEqual = (a, b) => {
218
+ if (a === b)
219
+ return true;
220
+ if (!a || !b)
221
+ return false;
222
+ for (let i = 0; i < 6; i++)
223
+ if (!shallowEqual(a[i], b[i]))
224
+ return false;
225
+ return true;
226
+ };
227
+ /** `undefined` when nothing moved, which is what lets the component skip the `postMessage` entirely. */
228
+ export const diffState = (previous, next) => {
229
+ const patch = {};
230
+ let changed = false;
231
+ /* ── THE ITEM ─────────────────────────────────────────────────────────────────────────────
232
+ *
233
+ * *** AN ITEM THAT DISAPPEARS DOES NOT BLANK THE VIEWER. *** `next.item === null` means this render
234
+ * had no renderable item - a host whose query briefly returned `undefined`, which in a real app is
235
+ * a re-render blip rather than an instruction. The picture is left alone and the component reports
236
+ * `no-item` through `onError`; there is no way to say "show nothing" over the wire and inventing one
237
+ * would make a transient state destructive.
238
+ */
239
+ if (next.item) {
240
+ const item = {};
241
+ const before = previous.item;
242
+ if (!before) {
243
+ Object.assign(item, next.item);
244
+ changed = true;
245
+ }
246
+ else {
247
+ for (const key of ['weaponType', 'paintIndex', 'legacyModel', 'float', 'seed', 'statTrak', 'nameTag'])
248
+ if (!Object.is(before[key], next.item[key])) {
249
+ // `as never` narrows the union of value types down to the one this key holds; the loop is
250
+ // over a literal tuple so the pairing is checked, but TypeScript cannot see it per key.
251
+ item[key] = next.item[key];
252
+ changed = true;
253
+ }
254
+ if (!slotsEqual(before.stickers, next.item.stickers) && next.item.stickers) {
255
+ item.stickers = next.item.stickers;
256
+ changed = true;
257
+ }
258
+ }
259
+ if (Object.keys(item).length > 0)
260
+ patch.item = item;
261
+ }
262
+ if (next.view !== undefined && next.view !== previous.view) {
263
+ patch.view = next.view;
264
+ changed = true;
265
+ }
266
+ if (next.agent && !shallowEqual(previous.agent, next.agent)) {
267
+ patch.agent = next.agent;
268
+ changed = true;
269
+ }
270
+ /*
271
+ * GLOVES ARE THE ONE FIELD SENT WHOLESALE. `null` there is not an absence - it is "the wearer's own
272
+ * default pair" - and a partial glove patch that left the pair without a `type` is a state the
273
+ * renderer cannot resolve, so the frame rejects it. Sending the whole pair keeps that impossible.
274
+ */
275
+ if (next.gloves !== undefined && !glovesEqual(previous.gloves, next.gloves)) {
276
+ patch.gloves = next.gloves ?? null;
277
+ changed = true;
278
+ }
279
+ const settings = diffSettings(previous.settings, next.settings);
280
+ if (settings) {
281
+ patch.settings = settings;
282
+ changed = true;
283
+ }
284
+ if (next.interactions && !shallowEqual(previous.interactions, next.interactions)) {
285
+ patch.interactions = next.interactions;
286
+ changed = true;
287
+ }
288
+ if (next.editingSlot !== undefined && next.editingSlot !== previous.editingSlot) {
289
+ patch.editingSlot = next.editingSlot;
290
+ changed = true;
291
+ }
292
+ return changed ? patch : undefined;
293
+ };
294
+ const glovesEqual = (a, b) => {
295
+ if (a === b)
296
+ return true;
297
+ if (!a || !b)
298
+ return false;
299
+ return a.type === b.type && a.paintIndex === b.paintIndex && a.float === b.float && a.seed === b.seed;
300
+ };
301
+ /**
302
+ * Per group, per field - which is the same rule the frame merges by, one level in.
303
+ *
304
+ * A GROUP THE CALLER DID NOT MENTION THIS RENDER IS NOT DIFFED AWAY. `settings={{ quality: {…} }}`
305
+ * after `settings={{ quality: {…}, camera: {…} }}` does not reset the camera: there is no way to say
306
+ * "unset" over the wire, and the alternative reading - that dropping a key means restore the default -
307
+ * would make a conditional `settings` object destructive in a way React developers do not expect.
308
+ */
309
+ const diffSettings = (previous, next) => {
310
+ if (!next)
311
+ return undefined;
312
+ const out = {};
313
+ let changed = false;
314
+ if (next.camera && !shallowEqual(previous?.camera, next.camera)) {
315
+ out.camera = next.camera;
316
+ changed = true;
317
+ }
318
+ if (next.quality && !shallowEqual(previous?.quality, next.quality)) {
319
+ out.quality = next.quality;
320
+ changed = true;
321
+ }
322
+ if (next.environment && !shallowEqual(previous?.environment, next.environment)) {
323
+ out.environment = next.environment;
324
+ changed = true;
325
+ }
326
+ if (next.overlays && !overlaysEqual(previous?.overlays, next.overlays)) {
327
+ out.overlays = next.overlays;
328
+ changed = true;
329
+ }
330
+ return changed ? out : undefined;
331
+ };
332
+ const overlaysEqual = (a, b) => {
333
+ if (a === b)
334
+ return true;
335
+ if (!a || !b)
336
+ return false;
337
+ return a.stickerGizmo === b.stickerGizmo && a.charmGizmo === b.charmGizmo && shallowEqual(a.gizmoStyle, b.gizmoStyle);
338
+ };
339
+ /** True when a patch would cover the canvas - see {@link IDENTITY_FIELDS}. */
340
+ export const coversCanvas = (patch, view) => {
341
+ if (patch.view !== undefined)
342
+ return true;
343
+ if (patch.item && IDENTITY_FIELDS.some(field => patch.item?.[field] !== undefined))
344
+ return true;
345
+ // The operator is identity in the `agent` view, where its `<Suspense>` tears the subtree down, and
346
+ // cheap in `hands`, where the arms are already mounted. The asymmetry is the renderer's, not ours.
347
+ if (patch.agent?.id !== undefined && view === 'agent')
348
+ return true;
349
+ return false;
350
+ };
351
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../src/state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAkC1C,MAAM,QAAQ,GAAuD;IACpE,SAAS,EAAE,SAAS;IACpB,kBAAkB,EAAE,UAAU;IAC9B,gBAAgB,EAAE,gBAAgB;IAClC,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,mBAAmB,EAAE,IAAI;IACzB,gGAAgG;IAChG,0CAA0C;IAC1C,WAAW,EAAE,IAAI;CACjB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAA+B,EAAgB,EAAE;IAC7E,MAAM,OAAO,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;IACrC,MAAM,QAAQ,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAA;IAEhD,OAAO;QACN,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,cAAc,EAAE,OAAO,CAAC,cAAc;QACtC,IAAI,EAAE,OAAO,CAAC,KAAK,CA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