rig-play 0.8.0 → 1.0.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 (44) hide show
  1. package/NOTICE.md +50 -23
  2. package/README.md +354 -461
  3. package/dist/CanvasRenderer.d.ts +139 -0
  4. package/dist/CanvasRenderer.d.ts.map +1 -0
  5. package/dist/{SpineHtmlRenderer.d.ts → DomRenderer.d.ts} +70 -65
  6. package/dist/DomRenderer.d.ts.map +1 -0
  7. package/dist/DomTexture.d.ts +34 -14
  8. package/dist/DomTexture.d.ts.map +1 -1
  9. package/dist/MeshGlBlitter.d.ts +67 -1
  10. package/dist/MeshGlBlitter.d.ts.map +1 -1
  11. package/dist/index.d.ts +6 -4
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +7271 -5
  14. package/dist/index.js.map +1 -1
  15. package/dist/loadModel.d.ts +92 -0
  16. package/dist/loadModel.d.ts.map +1 -0
  17. package/dist/player.d.ts +151 -0
  18. package/dist/player.d.ts.map +1 -0
  19. package/dist/posedFrame.d.ts +99 -0
  20. package/dist/posedFrame.d.ts.map +1 -0
  21. package/package.json +13 -19
  22. package/dist/DomTexture.js +0 -520
  23. package/dist/DomTexture.js.map +0 -1
  24. package/dist/MeshGlBlitter.js +0 -365
  25. package/dist/MeshGlBlitter.js.map +0 -1
  26. package/dist/SpineHtmlRenderer.d.ts.map +0 -1
  27. package/dist/SpineHtmlRenderer.js +0 -1107
  28. package/dist/SpineHtmlRenderer.js.map +0 -1
  29. package/dist/binary.d.ts +0 -48
  30. package/dist/binary.d.ts.map +0 -1
  31. package/dist/binary.js +0 -29
  32. package/dist/binary.js.map +0 -1
  33. package/dist/coreCompat.d.ts +0 -153
  34. package/dist/coreCompat.d.ts.map +0 -1
  35. package/dist/coreCompat.js +0 -136
  36. package/dist/coreCompat.js.map +0 -1
  37. package/dist/loadAtlasAssets.d.ts +0 -73
  38. package/dist/loadAtlasAssets.d.ts.map +0 -1
  39. package/dist/loadAtlasAssets.js +0 -75
  40. package/dist/loadAtlasAssets.js.map +0 -1
  41. package/dist/loadSkeletonAssets.d.ts +0 -88
  42. package/dist/loadSkeletonAssets.d.ts.map +0 -1
  43. package/dist/loadSkeletonAssets.js +0 -79
  44. package/dist/loadSkeletonAssets.js.map +0 -1
@@ -1,88 +0,0 @@
1
- import { type SkeletonData, TextureAtlas } from '@esotericsoftware/spine-core';
2
- import type { RegionImage } from './DomTexture.js';
3
- import { type LoadAtlasAssetsOptions } from './loadAtlasAssets.js';
4
- /**
5
- * Optional convenience loader: fetch a skeleton export and its atlas, attach
6
- * the page images, unpack the regions.
7
- *
8
- * It exists because every consumer was copying the same twenty lines. It is
9
- * deliberately the *only* thing this module does — it owns no frame loop, no
10
- * AnimationState, no layout, and it is not on the renderer's path, so the
11
- * low-level route (TextureAtlas + DomTexture + unpackRegions by hand) stays
12
- * the way to do anything this does not cover: images that come from somewhere
13
- * other than a URL, an atlas that is not fetched at all. Binary (.skel) exports
14
- * are read by `loadSkeletonBinary`, from the separate `spine-html/binary` entry,
15
- * on the same seam. Sharing one atlas across several
16
- * skeletons has its own seam: `loadAtlasAssets` (loadAtlasAssets.ts) plus one
17
- * `loadSkeletonJson` per skeleton, which is what this function is built on.
18
- * Nothing else in the package imports this file, so a bundler drops it when it
19
- * is unused.
20
- */
21
- export interface LoadSkeletonAssetsOptions extends LoadAtlasAssetsOptions {
22
- /** URL of the skeleton JSON (.json) export. */
23
- skeletonUrl: string;
24
- /** SkeletonJson.scale — scales the skeleton as it is read. */
25
- scale?: number;
26
- }
27
- export interface LoadSkeletonJsonOptions {
28
- /** SkeletonJson.scale — scales the skeleton as it is read. */
29
- scale?: number;
30
- /** fetch implementation, for custom headers or a test double. */
31
- fetch?: typeof globalThis.fetch;
32
- }
33
- export interface SkeletonAssets {
34
- /** Parsed skeleton data — construct one `new Skeleton(data)` per instance. */
35
- data: SkeletonData;
36
- /** Unpacked per-region bitmaps, ready for `new SpineHtmlRenderer(root, …)`. */
37
- regionImages: Map<string, RegionImage>;
38
- /** The parsed atlas, page textures attached. */
39
- atlas: TextureAtlas;
40
- /**
41
- * Frees the blob URLs this load created (see revokeRegions). Idempotent.
42
- * Call it after the renderers using these images are disposed — a live
43
- * <img> would be left pointing at a dead URL.
44
- */
45
- dispose(): void;
46
- }
47
- /**
48
- * Reads one skeleton JSON export against already-loaded atlas assets — the
49
- * second step of the shared-atlas path.
50
- *
51
- * ```ts
52
- * const shared = await loadAtlasAssets({ atlasUrl: '/spineboy/spineboy.atlas' });
53
- * const [ess, pro] = await Promise.all([
54
- * loadSkeletonJson(shared, '/spineboy/spineboy-ess.json'),
55
- * loadSkeletonJson(shared, '/spineboy/spineboy-pro.json'),
56
- * ]);
57
- * ```
58
- *
59
- * `assets` needs nothing but a parsed atlas with its page textures attached,
60
- * so a caller on the low-level path can pass its own `{ atlas }`. Ownership
61
- * stays with the caller: this never disposes `assets`, whether it succeeds or
62
- * throws, because the same assets normally back several skeletons.
63
- */
64
- export declare function loadSkeletonJson(assets: {
65
- atlas: TextureAtlas;
66
- }, skeletonUrl: string, options?: LoadSkeletonJsonOptions): Promise<SkeletonData>;
67
- /**
68
- * Loads everything the renderer needs from two URLs.
69
- *
70
- * ```ts
71
- * const assets = await loadSkeletonAssets({
72
- * atlasUrl: '/spineboy/spineboy.atlas',
73
- * skeletonUrl: '/spineboy/spineboy-pro.json',
74
- * });
75
- * const skeleton = new Skeleton(assets.data);
76
- * const renderer = new SpineHtmlRenderer(root, assets.regionImages);
77
- * // …later: renderer.dispose(); assets.dispose();
78
- * ```
79
- *
80
- * One atlas, one skeleton. Several skeletons sharing one atlas is the two-step
81
- * path instead (`loadAtlasAssets` + `loadSkeletonJson`), which this is built
82
- * on — calling this once per skeleton would refetch and re-unpack the atlas.
83
- *
84
- * Page images load in parallel, and the skeleton export downloads alongside
85
- * the atlas half. If anything fails part-way, no blob URL is left behind.
86
- */
87
- export declare function loadSkeletonAssets(options: LoadSkeletonAssetsOptions): Promise<SkeletonAssets>;
88
- //# sourceMappingURL=loadSkeletonAssets.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadSkeletonAssets.d.ts","sourceRoot":"","sources":["../src/loadSkeletonAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,YAAY,EAEjB,YAAY,EACb,MAAM,8BAA8B,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAa,KAAK,sBAAsB,EAAmB,MAAM,sBAAsB,CAAC;AAE/F;;;;;;;;;;;;;;;;GAgBG;AAEH,MAAM,WAAW,yBAA0B,SAAQ,sBAAsB;IACvE,+CAA+C;IAC/C,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,uBAAuB;IACtC,8DAA8D;IAC9D,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,iEAAiE;IACjE,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,IAAI,EAAE,YAAY,CAAC;IACnB,+EAA+E;IAC/E,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACvC,gDAAgD;IAChD,KAAK,EAAE,YAAY,CAAC;IACpB;;;;OAIG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAQD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE;IAAE,KAAK,EAAE,YAAY,CAAA;CAAE,EAC/B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,YAAY,CAAC,CAIvB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAsB,kBAAkB,CACtC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,cAAc,CAAC,CA6BzB"}
@@ -1,79 +0,0 @@
1
- import { AtlasAttachmentLoader, SkeletonJson, } from '@esotericsoftware/spine-core';
2
- import { fetchText, loadAtlasAssets } from './loadAtlasAssets.js';
3
- function readSkeletonData(atlas, text, scale) {
4
- const json = new SkeletonJson(new AtlasAttachmentLoader(atlas));
5
- if (scale !== undefined)
6
- json.scale = scale;
7
- return json.readSkeletonData(text);
8
- }
9
- /**
10
- * Reads one skeleton JSON export against already-loaded atlas assets — the
11
- * second step of the shared-atlas path.
12
- *
13
- * ```ts
14
- * const shared = await loadAtlasAssets({ atlasUrl: '/spineboy/spineboy.atlas' });
15
- * const [ess, pro] = await Promise.all([
16
- * loadSkeletonJson(shared, '/spineboy/spineboy-ess.json'),
17
- * loadSkeletonJson(shared, '/spineboy/spineboy-pro.json'),
18
- * ]);
19
- * ```
20
- *
21
- * `assets` needs nothing but a parsed atlas with its page textures attached,
22
- * so a caller on the low-level path can pass its own `{ atlas }`. Ownership
23
- * stays with the caller: this never disposes `assets`, whether it succeeds or
24
- * throws, because the same assets normally back several skeletons.
25
- */
26
- export async function loadSkeletonJson(assets, skeletonUrl, options = {}) {
27
- const fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);
28
- const text = await fetchText(fetchImpl, skeletonUrl);
29
- return readSkeletonData(assets.atlas, text, options.scale);
30
- }
31
- /**
32
- * Loads everything the renderer needs from two URLs.
33
- *
34
- * ```ts
35
- * const assets = await loadSkeletonAssets({
36
- * atlasUrl: '/spineboy/spineboy.atlas',
37
- * skeletonUrl: '/spineboy/spineboy-pro.json',
38
- * });
39
- * const skeleton = new Skeleton(assets.data);
40
- * const renderer = new SpineHtmlRenderer(root, assets.regionImages);
41
- * // …later: renderer.dispose(); assets.dispose();
42
- * ```
43
- *
44
- * One atlas, one skeleton. Several skeletons sharing one atlas is the two-step
45
- * path instead (`loadAtlasAssets` + `loadSkeletonJson`), which this is built
46
- * on — calling this once per skeleton would refetch and re-unpack the atlas.
47
- *
48
- * Page images load in parallel, and the skeleton export downloads alongside
49
- * the atlas half. If anything fails part-way, no blob URL is left behind.
50
- */
51
- export async function loadSkeletonAssets(options) {
52
- const fetchImpl = options.fetch ?? globalThis.fetch.bind(globalThis);
53
- // Started before the atlas half is awaited, so the two downloads overlap.
54
- const skeletonText = fetchText(fetchImpl, options.skeletonUrl);
55
- // The atlas half can throw first and leave this rejection unobserved until
56
- // the catch below, which is an unhandled rejection in between. A no-op
57
- // handler marks it observed; the value/error is still read from the promise.
58
- skeletonText.catch(() => { });
59
- const assets = await loadAtlasAssets(options);
60
- let data;
61
- try {
62
- data = readSkeletonData(assets.atlas, await skeletonText, options.scale);
63
- }
64
- catch (error) {
65
- // The regions exist by now, so the skeleton half is the one step that
66
- // could strand them — whether the fetch failed or the read did.
67
- assets.dispose();
68
- throw error;
69
- }
70
- return {
71
- atlas: assets.atlas,
72
- data,
73
- regionImages: assets.regionImages,
74
- dispose() {
75
- assets.dispose();
76
- },
77
- };
78
- }
79
- //# sourceMappingURL=loadSkeletonAssets.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"loadSkeletonAssets.js","sourceRoot":"","sources":["../src/loadSkeletonAssets.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EAErB,YAAY,GAEb,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,SAAS,EAA+B,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAiD/F,SAAS,gBAAgB,CAAC,KAAmB,EAAE,IAAY,EAAE,KAAc;IACzE,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,IAAI,qBAAqB,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,IAAI,KAAK,KAAK,SAAS;QAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IAC5C,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;AACrC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,MAA+B,EAC/B,WAAmB,EACnB,U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