@penabt/pixi-expo 0.3.0 → 0.3.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 +19 -2
- package/dist/index.js +3 -1
- package/dist/index.mjs +3 -1
- package/package.json +1 -1
- package/src/index.ts +5 -1
package/README.md
CHANGED
|
@@ -160,11 +160,28 @@ const sprite = new Sprite(bunny);
|
|
|
160
160
|
|
|
161
161
|
// Remote asset via URL
|
|
162
162
|
const remote = await Assets.load('https://example.com/sprite.png');
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Array Loading — `Assets.load([])`
|
|
166
|
+
|
|
167
|
+
Load multiple assets at once with array destructuring:
|
|
168
|
+
|
|
169
|
+
```tsx
|
|
170
|
+
import { Assets, Sprite } from '@penabt/pixi-expo';
|
|
163
171
|
|
|
164
|
-
//
|
|
165
|
-
const [
|
|
172
|
+
// Mix require() and remote URLs in a single call
|
|
173
|
+
const [frame1, frame2, enemy] = await Assets.load([
|
|
174
|
+
require('./assets/frame-1.png'),
|
|
175
|
+
require('./assets/frame-2.png'),
|
|
176
|
+
'https://example.com/enemy.png',
|
|
177
|
+
]);
|
|
178
|
+
|
|
179
|
+
const sprite1 = new Sprite(frame1);
|
|
180
|
+
const sprite2 = new Sprite(frame2);
|
|
166
181
|
```
|
|
167
182
|
|
|
183
|
+
> **Note:** Unlike standard PixiJS (which returns a `Record<string, Texture>` for arrays), `@penabt/pixi-expo` returns an array in the same order as the input — enabling convenient destructuring.
|
|
184
|
+
|
|
168
185
|
### Manifest & Bundles — `createExpoManifest()`
|
|
169
186
|
|
|
170
187
|
For larger projects, group assets into bundles and load them on demand:
|
package/dist/index.js
CHANGED
|
@@ -1707,7 +1707,9 @@ import_pixi4.Assets.load = function patchedLoad(urls, onProgress) {
|
|
|
1707
1707
|
}
|
|
1708
1708
|
if (Array.isArray(urls)) {
|
|
1709
1709
|
const resolved = urls.map((u) => typeof u === "number" ? registerModuleId(u) : u);
|
|
1710
|
-
return _originalLoad(resolved, onProgress)
|
|
1710
|
+
return _originalLoad(resolved, onProgress).then((record) => {
|
|
1711
|
+
return resolved.map((key) => record[key]);
|
|
1712
|
+
});
|
|
1711
1713
|
}
|
|
1712
1714
|
return _originalLoad(urls, onProgress);
|
|
1713
1715
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1661,7 +1661,9 @@ Assets.load = function patchedLoad(urls, onProgress) {
|
|
|
1661
1661
|
}
|
|
1662
1662
|
if (Array.isArray(urls)) {
|
|
1663
1663
|
const resolved = urls.map((u) => typeof u === "number" ? registerModuleId(u) : u);
|
|
1664
|
-
return _originalLoad(resolved, onProgress)
|
|
1664
|
+
return _originalLoad(resolved, onProgress).then((record) => {
|
|
1665
|
+
return resolved.map((key) => record[key]);
|
|
1666
|
+
});
|
|
1665
1667
|
}
|
|
1666
1668
|
return _originalLoad(urls, onProgress);
|
|
1667
1669
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@penabt/pixi-expo",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "PixiJS v8 adapter for React Native Expo. Enables hardware-accelerated 2D graphics using expo-gl WebGL context.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
package/src/index.ts
CHANGED
|
@@ -108,7 +108,11 @@ const _originalLoad = Assets.load.bind(Assets);
|
|
|
108
108
|
}
|
|
109
109
|
if (Array.isArray(urls)) {
|
|
110
110
|
const resolved = urls.map((u: any) => (typeof u === 'number' ? registerModuleId(u) : u));
|
|
111
|
-
|
|
111
|
+
// Assets.load returns Record<string, T> for arrays. Convert to array so
|
|
112
|
+
// callers can destructure: const [a, b] = await Assets.load([url1, url2])
|
|
113
|
+
return _originalLoad(resolved, onProgress).then((record: any) => {
|
|
114
|
+
return resolved.map((key: string) => record[key]);
|
|
115
|
+
});
|
|
112
116
|
}
|
|
113
117
|
return _originalLoad(urls, onProgress);
|
|
114
118
|
};
|