@linear_non/stellar-libs 1.0.13 → 1.0.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linear_non/stellar-libs",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Reusable JavaScript libraries for Non-Linear Studio projects.",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -101,10 +101,20 @@ export default class SpritePlayer {
101
101
  const onProgress = e => emitter.emit("sprite:progress", { instance: this, ...e })
102
102
  emitter.on(ImageLoader.events.PROGRESS, onProgress)
103
103
 
104
+ const wantAlphaUrls = Array.isArray(alpha_urls) && alpha_urls.length > 0
105
+ const wantAlphaPath = !!(originAlpha && fileAlpha)
106
+
104
107
  const [images, alphaImages] = await Promise.all([
108
+ // base: urls[] wins; otherwise origin+file_name pattern
105
109
  make({ origin: originBase, fileName: file_name, list: urls }),
106
- originAlpha && (fileAlpha || (alpha_urls && alpha_urls.length))
107
- ? make({ origin: originAlpha, fileName: fileAlpha, list: alpha_urls })
110
+
111
+ // alpha: load if EITHER urls[] OR path+file is provided
112
+ wantAlphaUrls || wantAlphaPath
113
+ ? make({
114
+ origin: wantAlphaUrls ? null : originAlpha,
115
+ fileName: wantAlphaUrls ? null : fileAlpha,
116
+ list: wantAlphaUrls ? alpha_urls : null,
117
+ })
108
118
  : Promise.resolve([]),
109
119
  ])
110
120
 
@@ -144,6 +154,7 @@ export default class SpritePlayer {
144
154
  Object.assign(this.canvas, { width: rect.width, height: rect.height, rect, area, offset })
145
155
  }
146
156
 
157
+ // grayscale → alpha (returns a canvas)
147
158
  toAlphaFromLuma(img) {
148
159
  const w = img.naturalWidth || img.width
149
160
  const h = img.naturalHeight || img.height