@relu-interactives/spatial-ecs 0.8.0 → 0.10.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 (56) hide show
  1. package/dist/{System-8D-XBDKZ.d.cts → System-BldSHxZV.d.cts} +214 -81
  2. package/dist/{System-DPMAW30g.d.ts → System-CADhPyQs.d.ts} +214 -81
  3. package/dist/{XRHandPose-G0Dl-F0w.d.ts → XRHandPose-BNSwd1y9.d.ts} +145 -2
  4. package/dist/{XRHandPose-VQMT1WXj.d.cts → XRHandPose-D3Ab1Dfs.d.cts} +145 -2
  5. package/dist/{chunk-G4XJ53LS.js → chunk-JEPUCLZX.js} +3 -3
  6. package/dist/{chunk-G4XJ53LS.js.map → chunk-JEPUCLZX.js.map} +1 -1
  7. package/dist/{chunk-NNDUOQ7O.js → chunk-JNYPJB55.js} +250 -3
  8. package/dist/chunk-JNYPJB55.js.map +1 -0
  9. package/dist/{chunk-SGF73YTF.js → chunk-NXASMBDS.js} +4 -4
  10. package/dist/{chunk-SGF73YTF.js.map → chunk-NXASMBDS.js.map} +1 -1
  11. package/dist/{chunk-JIJQFW6P.js → chunk-TY3XCHOR.js} +1390 -485
  12. package/dist/chunk-TY3XCHOR.js.map +1 -0
  13. package/dist/{chunk-U727NTWQ.js → chunk-WWP46AEF.js} +26 -4
  14. package/dist/chunk-WWP46AEF.js.map +1 -0
  15. package/dist/components/index.cjs +151 -0
  16. package/dist/components/index.cjs.map +1 -1
  17. package/dist/components/index.d.cts +3 -3
  18. package/dist/components/index.d.ts +3 -3
  19. package/dist/components/index.js +1 -1
  20. package/dist/docs/guide/bone-attachments-and-ik.md +1 -1
  21. package/dist/docs/guide/multiplayer.md +65 -0
  22. package/dist/docs/guide/spatial-ui.md +83 -7
  23. package/dist/factories/index.cjs +151 -0
  24. package/dist/factories/index.cjs.map +1 -1
  25. package/dist/factories/index.d.cts +2 -2
  26. package/dist/factories/index.d.ts +2 -2
  27. package/dist/factories/index.js +3 -3
  28. package/dist/{index-C61n65PE.d.ts → index-6pZO_gV7.d.ts} +27 -2
  29. package/dist/{index-D9DjrUn3.d.cts → index-BXjwEdNq.d.cts} +6 -3
  30. package/dist/{index-C70N4BYG.d.cts → index-BdghvXKE.d.cts} +27 -2
  31. package/dist/{index-DppafVu4.d.ts → index-CVG-hREM.d.ts} +6 -3
  32. package/dist/index.cjs +1800 -626
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +8 -30
  35. package/dist/index.d.ts +8 -30
  36. package/dist/index.js +10 -10
  37. package/dist/network/index.cjs +858 -8
  38. package/dist/network/index.cjs.map +1 -1
  39. package/dist/network/index.d.cts +126 -5
  40. package/dist/network/index.d.ts +126 -5
  41. package/dist/network/index.js +683 -8
  42. package/dist/network/index.js.map +1 -1
  43. package/dist/systems/index.cjs +1702 -528
  44. package/dist/systems/index.cjs.map +1 -1
  45. package/dist/systems/index.d.cts +2 -2
  46. package/dist/systems/index.d.ts +2 -2
  47. package/dist/systems/index.js +4 -4
  48. package/dist/types.d.cts +1 -1
  49. package/dist/types.d.ts +1 -1
  50. package/dist/webgpu/index.d.ts +2 -2
  51. package/dist/worldSnapshotUtils.d.cts +1 -1
  52. package/dist/worldSnapshotUtils.d.ts +1 -1
  53. package/package.json +1 -1
  54. package/dist/chunk-JIJQFW6P.js.map +0 -1
  55. package/dist/chunk-NNDUOQ7O.js.map +0 -1
  56. package/dist/chunk-U727NTWQ.js.map +0 -1
@@ -2167,6 +2167,127 @@ var _IKComponent = class _IKComponent extends Component {
2167
2167
  __name(_IKComponent, "IKComponent");
2168
2168
  var IKComponent = _IKComponent;
2169
2169
 
2170
+ // core/ui/uiStyle.ts
2171
+ var isRecord = /* @__PURE__ */ __name((value) => typeof value === "object" && value !== null && !Array.isArray(value), "isRecord");
2172
+ var finite = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value), "finite");
2173
+ var nonEmpty = /* @__PURE__ */ __name((value) => typeof value === "string" && value.length > 0, "nonEmpty");
2174
+ function normalizeStops(value) {
2175
+ if (!Array.isArray(value)) return null;
2176
+ const stops = [];
2177
+ for (const stop of value) {
2178
+ if (isRecord(stop) && finite(stop.at) && nonEmpty(stop.color)) {
2179
+ stops.push({ at: Math.min(1, Math.max(0, stop.at)), color: stop.color });
2180
+ }
2181
+ }
2182
+ return stops.length >= 2 ? stops : null;
2183
+ }
2184
+ __name(normalizeStops, "normalizeStops");
2185
+ function normalizePaint(value) {
2186
+ if (!isRecord(value)) return void 0;
2187
+ if (value.kind === "solid" && nonEmpty(value.color)) {
2188
+ return { kind: "solid", color: value.color };
2189
+ }
2190
+ if (value.kind === "linear") {
2191
+ const stops = normalizeStops(value.stops);
2192
+ if (stops) {
2193
+ return {
2194
+ kind: "linear",
2195
+ angle: finite(value.angle) ? value.angle : 180,
2196
+ stops
2197
+ };
2198
+ }
2199
+ }
2200
+ if (value.kind === "radial") {
2201
+ const stops = normalizeStops(value.stops);
2202
+ if (stops) return { kind: "radial", stops };
2203
+ }
2204
+ if (value.kind === "image" && nonEmpty(value.src)) {
2205
+ const fit = value.fit === "contain" || value.fit === "fill" ? value.fit : "cover";
2206
+ return {
2207
+ kind: "image",
2208
+ src: value.src,
2209
+ fit,
2210
+ ...nonEmpty(value.tint) ? { tint: value.tint } : {}
2211
+ };
2212
+ }
2213
+ return void 0;
2214
+ }
2215
+ __name(normalizePaint, "normalizePaint");
2216
+ function normalizeShadow(value) {
2217
+ if (!isRecord(value) || !nonEmpty(value.color)) return void 0;
2218
+ return {
2219
+ x: finite(value.x) ? value.x : 0,
2220
+ y: finite(value.y) ? value.y : 0,
2221
+ blur: finite(value.blur) ? Math.max(0, value.blur) : 0,
2222
+ color: value.color
2223
+ };
2224
+ }
2225
+ __name(normalizeShadow, "normalizeShadow");
2226
+ function normalizeText(value) {
2227
+ if (!isRecord(value)) return void 0;
2228
+ const text = {};
2229
+ if (nonEmpty(value.font)) text.font = value.font;
2230
+ if (finite(value.weight)) text.weight = value.weight;
2231
+ if (finite(value.tracking)) text.tracking = value.tracking;
2232
+ if (value.transform === "upper" || value.transform === "lower") {
2233
+ text.transform = value.transform;
2234
+ }
2235
+ const paint = normalizePaint(value.paint);
2236
+ if (paint) text.paint = paint;
2237
+ if (finite(value.maxLines) && value.maxLines >= 1) {
2238
+ text.maxLines = Math.floor(value.maxLines);
2239
+ }
2240
+ const shadow = normalizeShadow(value.shadow);
2241
+ if (shadow) text.shadow = shadow;
2242
+ return Object.keys(text).length > 0 ? text : void 0;
2243
+ }
2244
+ __name(normalizeText, "normalizeText");
2245
+ function normalizeUiStyle(value) {
2246
+ if (!isRecord(value)) return void 0;
2247
+ const style = {};
2248
+ const fill = normalizePaint(value.fill);
2249
+ if (fill) style.fill = fill;
2250
+ if (isRecord(value.border) && finite(value.border.width)) {
2251
+ const paint = normalizePaint(value.border.paint);
2252
+ if (paint) {
2253
+ style.border = { width: Math.max(0, value.border.width), paint };
2254
+ }
2255
+ }
2256
+ if (finite(value.radius)) {
2257
+ style.radius = Math.max(0, value.radius);
2258
+ } else if (Array.isArray(value.radius) && value.radius.length === 4 && value.radius.every(finite)) {
2259
+ style.radius = value.radius.map((r) => Math.max(0, r));
2260
+ }
2261
+ if (Array.isArray(value.shadows)) {
2262
+ const shadows = value.shadows.map(normalizeShadow).filter((s) => !!s);
2263
+ if (shadows.length > 0) style.shadows = shadows;
2264
+ }
2265
+ if (isRecord(value.edge) && finite(value.edge.width) && nonEmpty(value.edge.color)) {
2266
+ style.edge = {
2267
+ width: Math.max(0, value.edge.width),
2268
+ color: value.edge.color
2269
+ };
2270
+ }
2271
+ if (finite(value.opacity)) {
2272
+ style.opacity = Math.min(1, Math.max(0, value.opacity));
2273
+ }
2274
+ const text = normalizeText(value.text);
2275
+ if (text) style.text = text;
2276
+ return Object.keys(style).length > 0 ? style : void 0;
2277
+ }
2278
+ __name(normalizeUiStyle, "normalizeUiStyle");
2279
+ function normalizeUiTokens(value) {
2280
+ if (!isRecord(value)) return void 0;
2281
+ const tokens = {};
2282
+ for (const [key, token] of Object.entries(value)) {
2283
+ if (nonEmpty(token) && key.length > 0 && !key.includes("/")) {
2284
+ tokens[key] = token;
2285
+ }
2286
+ }
2287
+ return Object.keys(tokens).length > 0 ? tokens : void 0;
2288
+ }
2289
+ __name(normalizeUiTokens, "normalizeUiTokens");
2290
+
2170
2291
  // core/components/UIPanel.ts
2171
2292
  var _UIPanelComponent = class _UIPanelComponent extends Component {
2172
2293
  constructor(options) {
@@ -2180,6 +2301,10 @@ var _UIPanelComponent = class _UIPanelComponent extends Component {
2180
2301
  this.borderColor = options?.borderColor ?? "#333333";
2181
2302
  this.pixelDensity = options?.pixelDensity ?? 1024;
2182
2303
  this.follow = options?.follow ?? "world";
2304
+ const style = normalizeUiStyle(options?.style);
2305
+ if (style) this.style = style;
2306
+ const tokens = normalizeUiTokens(options?.tokens);
2307
+ if (tokens) this.tokens = tokens;
2183
2308
  }
2184
2309
  };
2185
2310
  __name(_UIPanelComponent, "UIPanelComponent");
@@ -2199,6 +2324,11 @@ var _UITextComponent = class _UITextComponent extends Component {
2199
2324
  this.valign = options?.valign ?? "middle";
2200
2325
  this.lineHeight = options?.lineHeight ?? 1.25;
2201
2326
  this.padding = options?.padding ?? 0.01;
2327
+ if (options?.pixelDensity !== void 0) {
2328
+ this.pixelDensity = options.pixelDensity;
2329
+ }
2330
+ const style = normalizeUiStyle(options?.style);
2331
+ if (style) this.style = style;
2202
2332
  }
2203
2333
  };
2204
2334
  __name(_UITextComponent, "UITextComponent");
@@ -2220,6 +2350,13 @@ var _UIButtonComponent = class _UIButtonComponent extends Component {
2220
2350
  this.cornerRadius = options?.cornerRadius ?? 0.02;
2221
2351
  this.borderWidth = options?.borderWidth ?? 2e-3;
2222
2352
  this.borderColor = options?.borderColor ?? "#3a3a3a";
2353
+ if (options?.pixelDensity !== void 0) {
2354
+ this.pixelDensity = options.pixelDensity;
2355
+ }
2356
+ const style = normalizeUiStyle(options?.style);
2357
+ if (style) this.style = style;
2358
+ if (options?.icon) this.icon = options.icon;
2359
+ if (options?.iconPosition) this.iconPosition = options.iconPosition;
2223
2360
  }
2224
2361
  };
2225
2362
  __name(_UIButtonComponent, "UIButtonComponent");
@@ -2236,6 +2373,12 @@ var _UIToggleComponent = class _UIToggleComponent extends Component {
2236
2373
  this.trackColor = options?.trackColor ?? "#2a2a2a";
2237
2374
  this.accentColor = options?.accentColor ?? "#ff6b35";
2238
2375
  this.knobColor = options?.knobColor ?? "#ffffff";
2376
+ if (options?.pixelDensity !== void 0) {
2377
+ this.pixelDensity = options.pixelDensity;
2378
+ }
2379
+ const style = normalizeUiStyle(options?.style);
2380
+ if (style) this.style = style;
2381
+ if (options?.variant) this.variant = options.variant;
2239
2382
  }
2240
2383
  };
2241
2384
  __name(_UIToggleComponent, "UIToggleComponent");
@@ -2256,6 +2399,14 @@ var _UISliderComponent = class _UISliderComponent extends Component {
2256
2399
  this.trackColor = options?.trackColor ?? "#2a2a2a";
2257
2400
  this.accentColor = options?.accentColor ?? "#ff6b35";
2258
2401
  this.knobColor = options?.knobColor ?? "#ffffff";
2402
+ if (options?.pixelDensity !== void 0) {
2403
+ this.pixelDensity = options.pixelDensity;
2404
+ }
2405
+ const style = normalizeUiStyle(options?.style);
2406
+ if (style) this.style = style;
2407
+ if (options?.variant) this.variant = options.variant;
2408
+ if (options?.step !== void 0) this.step = options.step;
2409
+ if (options?.readOnly !== void 0) this.readOnly = options.readOnly;
2259
2410
  }
2260
2411
  };
2261
2412
  __name(_UISliderComponent, "UISliderComponent");