spine-html 0.7.1 → 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 -411
  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 -1100
  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 -130
  34. package/dist/coreCompat.d.ts.map +0 -1
  35. package/dist/coreCompat.js +0 -87
  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,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,C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