spine-expo-usedom 0.1.0 → 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.
- package/README.md +52 -2
- package/lib/commonjs/index.js +15 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +15 -2
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +3 -2
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/index.tsx +19 -2
package/README.md
CHANGED
|
@@ -12,8 +12,36 @@ Run **Spine Web Components** in React Native (iOS/Android) using Expo's **DOM Co
|
|
|
12
12
|
|
|
13
13
|
## 📦 Installation
|
|
14
14
|
|
|
15
|
+
### 1. Install dependencies
|
|
16
|
+
|
|
15
17
|
```bash
|
|
16
|
-
npm install spine-expo-usedom
|
|
18
|
+
npm install spine-expo-usedom @esotericsoftware/spine-webcomponents
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### 2. Configure `postinstall` script
|
|
22
|
+
|
|
23
|
+
Add a `postinstall` script to your `package.json` to copy the Spine Web Components library to your `public` folder. This is required for the component to load the necessary scripts dynamically.
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"scripts": {
|
|
28
|
+
"postinstall": "cp node_modules/@esotericsoftware/spine-webcomponents/dist/iife/spine-webcomponents.min.js public/"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Run the script manually to copy the file:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm run postinstall
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 3. Update `.gitignore`
|
|
40
|
+
|
|
41
|
+
Add the copied spine script to your `.gitignore` to avoid committing it.
|
|
42
|
+
|
|
43
|
+
```
|
|
44
|
+
public/spine-webcomponents.min.js
|
|
17
45
|
```
|
|
18
46
|
|
|
19
47
|
## 💻 Usage
|
|
@@ -68,6 +96,28 @@ export default function App() {
|
|
|
68
96
|
| `preserveDrawingBuffer` | `boolean` | `true` | Whether to preserve the drawing buffer. |
|
|
69
97
|
| `dom` | `DOMProps` | `undefined` | Props passed to the underlying Expo DOM Component container. |
|
|
70
98
|
|
|
71
|
-
##
|
|
99
|
+
## �️ Development & Publishing
|
|
100
|
+
|
|
101
|
+
### Build
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
npm run build
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
### Publish to npm
|
|
108
|
+
|
|
109
|
+
1. Update version:
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
npm version patch # or minor, major
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
2. Publish (build runs automatically):
|
|
116
|
+
|
|
117
|
+
```bash
|
|
118
|
+
npm publish
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## �📝 License
|
|
72
122
|
|
|
73
123
|
This project is licensed under the MIT License.
|
package/lib/commonjs/index.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.default = SpineView;
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
require("@esotericsoftware/spine-webcomponents");
|
|
10
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
10
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
12
11
|
function SpineView({
|
|
@@ -15,6 +14,7 @@ function SpineView({
|
|
|
15
14
|
atlas,
|
|
16
15
|
skin,
|
|
17
16
|
preserveDrawingBuffer = true,
|
|
17
|
+
spineWebComponentSrc = '/spine-webcomponents.min.js',
|
|
18
18
|
...rest
|
|
19
19
|
}) {
|
|
20
20
|
// window.location.origin を使って絶対パスを生成
|
|
@@ -30,13 +30,26 @@ function SpineView({
|
|
|
30
30
|
};
|
|
31
31
|
const absoluteSkeleton = getAbsolutePath(skeleton);
|
|
32
32
|
const absoluteAtlas = getAbsolutePath(atlas);
|
|
33
|
+
const absoluteSpineWebComponentSrc = getAbsolutePath(spineWebComponentSrc);
|
|
33
34
|
(0, _react.useEffect)(() => {
|
|
34
35
|
console.log('Current URL:', window.location.href);
|
|
35
36
|
console.log('Spine assets paths (absolute):', {
|
|
36
37
|
skeleton: absoluteSkeleton,
|
|
37
38
|
atlas: absoluteAtlas
|
|
38
39
|
});
|
|
39
|
-
|
|
40
|
+
if (window.spine) return;
|
|
41
|
+
|
|
42
|
+
// Prevent duplicate script loading
|
|
43
|
+
if (document.querySelector(`script[src="${absoluteSpineWebComponentSrc}"]`)) return;
|
|
44
|
+
const script = document.createElement('script');
|
|
45
|
+
script.src = absoluteSpineWebComponentSrc;
|
|
46
|
+
script.async = true;
|
|
47
|
+
script.onload = () => {
|
|
48
|
+
console.log('Spine Web Components loaded');
|
|
49
|
+
};
|
|
50
|
+
script.onerror = e => console.error('Failed to load Spine script', e);
|
|
51
|
+
document.head.appendChild(script);
|
|
52
|
+
}, [absoluteSpineWebComponentSrc]);
|
|
40
53
|
|
|
41
54
|
// skin="default" の場合、Spine Web Components でエラーになる場合があるため除外する
|
|
42
55
|
// また、React 19以降ではCustom Elementのプロパティとして渡される際、文字列のままだと
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Object","defineProperty","exports","value","default","SpineView","_react","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","dom","skeleton","atlas","skin","preserveDrawingBuffer","rest","origin","window","location","getAbsolutePath","path","startsWith","absoluteSkeleton","absoluteAtlas","useEffect","console","log","href","skinProp","undefined","split","jsx","style","width","height","display","justifyContent","alignItems","overflow","children"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,SAAS;;AAACA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAC,SAAA;AAEV,IAAAC,MAAA,GAAAC,uBAAA,CAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["Object","defineProperty","exports","value","default","SpineView","_react","_interopRequireWildcard","require","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","has","get","set","hasOwnProperty","call","getOwnPropertyDescriptor","dom","skeleton","atlas","skin","preserveDrawingBuffer","spineWebComponentSrc","rest","origin","window","location","getAbsolutePath","path","startsWith","absoluteSkeleton","absoluteAtlas","absoluteSpineWebComponentSrc","useEffect","console","log","href","spine","document","querySelector","script","createElement","src","async","onload","onerror","error","head","appendChild","skinProp","undefined","split","jsx","style","width","height","display","justifyContent","alignItems","overflow","children"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,SAAS;;AAACA,MAAA,CAAAC,cAAA,CAAAC,OAAA;EAAAC,KAAA;AAAA;AAAAD,OAAA,CAAAE,OAAA,GAAAC,SAAA;AAEV,IAAAC,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAAyC,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAf,OAAA,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C,OAAO,EAAE,MAAM;MAAEC,cAAc,EAAE,QAAQ;MAAEC,UAAU,EAAE,QAAQ;MAAEC,QAAQ,EAAE;IAAS,CAAE;IAAAC,QAAA,eAEhI,IAAA5D,WAAA,CAAAoD,GAAA;MACIlC,QAAQ,EAAEY,gBAAiB;MAC3BX,KAAK,EAAEY,aAAc;MACrBX,IAAI,EAAE6B,QAAS;MACf,2BAAyB5B,qBAAsB;MAC/CgC,KAAK,EAAE;QAAEC,KAAK,EAAE,MAAM;QAAEC,MAAM,EAAE;MAAO,CAAE;MAAA,GACrChC;IAAI,CACX;EAAC,CACD,CAAC;AAEd","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
'use dom';
|
|
3
3
|
|
|
4
4
|
import React, { useEffect } from 'react';
|
|
5
|
-
import '@esotericsoftware/spine-webcomponents';
|
|
6
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
6
|
export default function SpineView({
|
|
8
7
|
dom,
|
|
@@ -10,6 +9,7 @@ export default function SpineView({
|
|
|
10
9
|
atlas,
|
|
11
10
|
skin,
|
|
12
11
|
preserveDrawingBuffer = true,
|
|
12
|
+
spineWebComponentSrc = '/spine-webcomponents.min.js',
|
|
13
13
|
...rest
|
|
14
14
|
}) {
|
|
15
15
|
// window.location.origin を使って絶対パスを生成
|
|
@@ -25,13 +25,26 @@ export default function SpineView({
|
|
|
25
25
|
};
|
|
26
26
|
const absoluteSkeleton = getAbsolutePath(skeleton);
|
|
27
27
|
const absoluteAtlas = getAbsolutePath(atlas);
|
|
28
|
+
const absoluteSpineWebComponentSrc = getAbsolutePath(spineWebComponentSrc);
|
|
28
29
|
useEffect(() => {
|
|
29
30
|
console.log('Current URL:', window.location.href);
|
|
30
31
|
console.log('Spine assets paths (absolute):', {
|
|
31
32
|
skeleton: absoluteSkeleton,
|
|
32
33
|
atlas: absoluteAtlas
|
|
33
34
|
});
|
|
34
|
-
|
|
35
|
+
if (window.spine) return;
|
|
36
|
+
|
|
37
|
+
// Prevent duplicate script loading
|
|
38
|
+
if (document.querySelector(`script[src="${absoluteSpineWebComponentSrc}"]`)) return;
|
|
39
|
+
const script = document.createElement('script');
|
|
40
|
+
script.src = absoluteSpineWebComponentSrc;
|
|
41
|
+
script.async = true;
|
|
42
|
+
script.onload = () => {
|
|
43
|
+
console.log('Spine Web Components loaded');
|
|
44
|
+
};
|
|
45
|
+
script.onerror = e => console.error('Failed to load Spine script', e);
|
|
46
|
+
document.head.appendChild(script);
|
|
47
|
+
}, [absoluteSpineWebComponentSrc]);
|
|
35
48
|
|
|
36
49
|
// skin="default" の場合、Spine Web Components でエラーになる場合があるため除外する
|
|
37
50
|
// また、React 19以降ではCustom Elementのプロパティとして渡される際、文字列のままだと
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["React","useEffect","jsx","_jsx","SpineView","dom","skeleton","atlas","skin","preserveDrawingBuffer","rest","origin","window","location","getAbsolutePath","path","startsWith","absoluteSkeleton","absoluteAtlas","console","log","href","skinProp","undefined","split","style","width","height","display","justifyContent","alignItems","overflow","children"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,SAAS;;AAET,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;
|
|
1
|
+
{"version":3,"names":["React","useEffect","jsx","_jsx","SpineView","dom","skeleton","atlas","skin","preserveDrawingBuffer","spineWebComponentSrc","rest","origin","window","location","getAbsolutePath","path","startsWith","absoluteSkeleton","absoluteAtlas","absoluteSpineWebComponentSrc","console","log","href","spine","document","querySelector","script","createElement","src","async","onload","onerror","e","error","head","appendChild","skinProp","undefined","split","style","width","height","display","justifyContent","alignItems","overflow","children"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";AAAA,SAAS;;AAET,OAAOA,KAAK,IAAIC,SAAS,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AA0BzC,eAAe,SAASC,SAASA,CAAC;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AG,MAAM;MAClBV,OAAO,CAACC,GAAG,CAAC,6BAA6B,CAAC;IAC9C,CAAC;IACDK,MAAM,CAACK,OAAO,GAAIC,CAAC,IAAKZ,OAAO,CAACa,KAAK,CAAC,6BAA6B,EAAED,CAAC,CAAC;IACvER,QAAQ,CAACU,IAAI,CAACC,WAAW,CAACT,MAAM,CAAC;EACrC,CAAC,EAAE,CAACP,4BAA4B,CAAC,CAAC;;EAElC;EACA;EACA;EACA,MAAMiB,QAAQ,GAAI,CAAC7B,IAAI,IAAIA,IAAI,KAAK,SAAS,GAAI8B,SAAS,GAAG9B,IAAI,CAAC+B,KAAK,CAAC,GAAG,CAAC;EAE5E,oBACIpC,IAAA;IAAKqC,KAAK,EAAE;MAAEC,KAAK,EAAE,MAAM;MAAEC,MAAM,EAAE,OAAO;MAAEC,OAAO,EAAE,MAAM;MAAEC,cAAc,EAAE,QAAQ;MAAEC,UAAU,EAAE,QAAQ;MAAEC,QAAQ,EAAE;IAAS,CAAE;IAAAC,QAAA,eAEhI5C,IAAA;MACIG,QAAQ,EAAEY,gBAAiB;MAC3BX,KAAK,EAAEY,aAAc;MACrBX,IAAI,EAAE6B,QAAS;MACf,2BAAyB5B,qBAAsB;MAC/C+B,KAAK,EAAE;QAAEC,KAAK,EAAE,MAAM;QAAEC,MAAM,EAAE;MAAO,CAAE;MAAA,GACrC/B;IAAI,CACX;EAAC,CACD,CAAC;AAEd","ignoreList":[]}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import '@esotericsoftware/spine-webcomponents';
|
|
3
2
|
export interface SpineViewProps {
|
|
4
3
|
dom?: import('expo/dom').DOMProps;
|
|
5
4
|
/** Path to the skeleton data file (.json or .skel) */
|
|
@@ -18,8 +17,10 @@ export interface SpineViewProps {
|
|
|
18
17
|
preserveDrawingBuffer?: boolean;
|
|
19
18
|
/** Raw assets data for embedding */
|
|
20
19
|
rawData?: string;
|
|
20
|
+
/** Path to the spine-webcomponents.min.js file */
|
|
21
|
+
spineWebComponentSrc?: string;
|
|
21
22
|
/** Any other attributes for spine-skeleton */
|
|
22
23
|
[key: string]: any;
|
|
23
24
|
}
|
|
24
|
-
export default function SpineView({ dom, skeleton, atlas, skin, preserveDrawingBuffer, ...rest }: SpineViewProps): React.JSX.Element;
|
|
25
|
+
export default function SpineView({ dom, skeleton, atlas, skin, preserveDrawingBuffer, spineWebComponentSrc, ...rest }: SpineViewProps): React.JSX.Element;
|
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAoB,MAAM,OAAO,CAAC;AAEzC,MAAM,WAAW,cAAc;IAC3B,GAAG,CAAC,EAAE,OAAO,UAAU,EAAE,QAAQ,CAAC;IAClC,sDAAsD;IACtD,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,GAAG,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;IAC/C,wCAAwC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,6CAA6C;IAC7C,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,oCAAoC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,kDAAkD;IAClD,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,8CAA8C;IAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAC9B,GAAG,EACH,QAAQ,EACR,KAAK,EACL,IAAI,EACJ,qBAA4B,EAC5B,oBAAoD,EACpD,GAAG,IAAI,EACV,EAAE,cAAc,qBAsDhB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spine-expo-usedom",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Spine player for Expo",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -94,4 +94,4 @@
|
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@esotericsoftware/spine-webcomponents": "^4.2.96"
|
|
96
96
|
}
|
|
97
|
-
}
|
|
97
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use dom';
|
|
2
2
|
|
|
3
3
|
import React, { useEffect } from 'react';
|
|
4
|
-
import '@esotericsoftware/spine-webcomponents';
|
|
5
4
|
|
|
6
5
|
export interface SpineViewProps {
|
|
7
6
|
dom?: import('expo/dom').DOMProps;
|
|
@@ -21,6 +20,8 @@ export interface SpineViewProps {
|
|
|
21
20
|
preserveDrawingBuffer?: boolean;
|
|
22
21
|
/** Raw assets data for embedding */
|
|
23
22
|
rawData?: string;
|
|
23
|
+
/** Path to the spine-webcomponents.min.js file */
|
|
24
|
+
spineWebComponentSrc?: string;
|
|
24
25
|
/** Any other attributes for spine-skeleton */
|
|
25
26
|
[key: string]: any;
|
|
26
27
|
}
|
|
@@ -31,6 +32,7 @@ export default function SpineView({
|
|
|
31
32
|
atlas,
|
|
32
33
|
skin,
|
|
33
34
|
preserveDrawingBuffer = true,
|
|
35
|
+
spineWebComponentSrc = '/spine-webcomponents.min.js',
|
|
34
36
|
...rest
|
|
35
37
|
}: SpineViewProps) {
|
|
36
38
|
// window.location.origin を使って絶対パスを生成
|
|
@@ -47,11 +49,26 @@ export default function SpineView({
|
|
|
47
49
|
|
|
48
50
|
const absoluteSkeleton = getAbsolutePath(skeleton);
|
|
49
51
|
const absoluteAtlas = getAbsolutePath(atlas);
|
|
52
|
+
const absoluteSpineWebComponentSrc = getAbsolutePath(spineWebComponentSrc);
|
|
50
53
|
|
|
51
54
|
useEffect(() => {
|
|
52
55
|
console.log('Current URL:', window.location.href);
|
|
53
56
|
console.log('Spine assets paths (absolute):', { skeleton: absoluteSkeleton, atlas: absoluteAtlas });
|
|
54
|
-
|
|
57
|
+
|
|
58
|
+
if ((window as any).spine) return;
|
|
59
|
+
|
|
60
|
+
// Prevent duplicate script loading
|
|
61
|
+
if (document.querySelector(`script[src="${absoluteSpineWebComponentSrc}"]`)) return;
|
|
62
|
+
|
|
63
|
+
const script = document.createElement('script');
|
|
64
|
+
script.src = absoluteSpineWebComponentSrc;
|
|
65
|
+
script.async = true;
|
|
66
|
+
script.onload = () => {
|
|
67
|
+
console.log('Spine Web Components loaded');
|
|
68
|
+
};
|
|
69
|
+
script.onerror = (e) => console.error('Failed to load Spine script', e);
|
|
70
|
+
document.head.appendChild(script);
|
|
71
|
+
}, [absoluteSpineWebComponentSrc]);
|
|
55
72
|
|
|
56
73
|
// skin="default" の場合、Spine Web Components でエラーになる場合があるため除外する
|
|
57
74
|
// また、React 19以降ではCustom Elementのプロパティとして渡される際、文字列のままだと
|