@open-slot-ui/core 0.2.4 → 0.3.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.
package/dist/index.cjs CHANGED
@@ -135,6 +135,48 @@ function resolvePlacement(spec, screen) {
135
135
  };
136
136
  }
137
137
 
138
+ // src/layout/defaultLayouts.ts
139
+ var landscapeDefaultLayouts = Object.freeze({
140
+ spin: { anchor: "bottom-center", offset: [0, -140], scale: 0.9 },
141
+ autoplay: { anchor: "bottom-center", offset: [-204, -112] },
142
+ turbo: { anchor: "bottom-center", offset: [204, -112] },
143
+ balance: { anchor: "bottom-left", offset: [135, -104], rotation: -5 },
144
+ bet: { anchor: "bottom-right", offset: [-186, -104], rotation: 5 },
145
+ "bet-plus": { anchor: "bottom-right", offset: [-120, -188], rotation: 5 },
146
+ "bet-minus": { anchor: "bottom-right", offset: [-120, -104], rotation: 5 },
147
+ bonus: { anchor: "bottom-center", offset: [740, -320] },
148
+ settings: { anchor: "bottom-center", offset: [-740, -320], rotation: -5 },
149
+ mute: { anchor: "top-right", offset: [-122, 46] },
150
+ fullscreen: { anchor: "top-right", offset: [-46, 46] },
151
+ rtp: { anchor: "top-left", offset: [20, 18] },
152
+ "session-timer": { anchor: "top-left", offset: [20, 46] },
153
+ "net-position": { anchor: "top-left", offset: [20, 74] }
154
+ });
155
+ var portraitDefaultLayouts = Object.freeze({
156
+ // Mobile sizes run ~1.5× the desktop base (the Figma mobile frame draws the
157
+ // controls larger relative to its width) so the buttons read well on a phone.
158
+ spin: { anchor: "bottom-center", offset: [0, -510], scale: 1.35 },
159
+ autoplay: { anchor: "bottom-center", offset: [-258, -510], scale: 1.5 },
160
+ turbo: { anchor: "bottom-center", offset: [258, -510], scale: 1.5 },
161
+ bonus: { anchor: "bottom-center", offset: [-438, -480], scale: 1.3 },
162
+ settings: { anchor: "bottom-center", offset: [438, -480], scale: 1.5, rotation: -5 },
163
+ "bet-minus": { anchor: "bottom-center", offset: [-105, -267], scale: 1.5 },
164
+ "bet-plus": { anchor: "bottom-center", offset: [105, -267], scale: 1.5 },
165
+ mute: { anchor: "top-right", offset: [-159, 57], scale: 1.5 },
166
+ fullscreen: { anchor: "top-right", offset: [-57, 57], scale: 1.5 },
167
+ // Compliance readouts scale up ~2× on mobile with wider line spacing.
168
+ rtp: { anchor: "top-left", offset: [16, 16], scale: 2 },
169
+ "session-timer": { anchor: "top-left", offset: [16, 66], scale: 2 },
170
+ "net-position": { anchor: "top-left", offset: [16, 116], scale: 2 },
171
+ balance: { anchor: "bottom-left", offset: [36, -110], rotation: -5 },
172
+ bet: { anchor: "bottom-right", offset: [-36, -110], rotation: 5 }
173
+ });
174
+ function defaultLayout(id) {
175
+ const l = landscapeDefaultLayouts[id];
176
+ if (!l) return { anchor: "center" };
177
+ return { anchor: l.anchor, offset: l.offset ? [l.offset[0], l.offset[1]] : void 0, scale: l.scale, rotation: l.rotation };
178
+ }
179
+
138
180
  // src/transition/Transition.ts
139
181
  var Squish = class {
140
182
  constructor(scale = 0.92, ms = 120) {
@@ -1585,24 +1627,24 @@ var OpenUI = class {
1585
1627
  this.bus.emit("localeChanged", loc);
1586
1628
  })
1587
1629
  );
1588
- this.spin = new SpinControl({ layout: { anchor: "bottom-center", offset: [0, -440] } }, this.bus);
1630
+ this.spin = new SpinControl({ layout: defaultLayout("spin") }, this.bus);
1589
1631
  this.balance = new ValueDisplay({
1590
1632
  id: "balance",
1591
1633
  label: "openui.balance",
1592
1634
  // i18n key → localizes + swaps in social mode
1593
- layout: { anchor: "bottom-left", offset: [220, -96] },
1635
+ layout: defaultLayout("balance"),
1594
1636
  currency: { code: "USD", decimals: 2 },
1595
1637
  initial: 1e3
1596
1638
  });
1597
1639
  this.bet = new ValueDisplay({
1598
1640
  id: "bet",
1599
1641
  label: "openui.bet",
1600
- layout: { anchor: "bottom-right", offset: [-220, -96] },
1642
+ layout: defaultLayout("bet"),
1601
1643
  currency: { code: "USD", decimals: 2 },
1602
1644
  initial: 1
1603
1645
  });
1604
1646
  this.settingsButton = new ButtonControl(
1605
- { id: "settings", layout: { anchor: "bottom-center", offset: [400, -440] } },
1647
+ { id: "settings", layout: defaultLayout("settings") },
1606
1648
  this.bus
1607
1649
  );
1608
1650
  this.settingsPanel = new PanelControl(
@@ -1611,20 +1653,20 @@ var OpenUI = class {
1611
1653
  );
1612
1654
  this.musicSlider = new SliderControl({ id: "music", label: "Music", layout: { anchor: "center" }, initial: 0.7 }, this.bus);
1613
1655
  this.sfxSlider = new SliderControl({ id: "sfx", label: "Sound", layout: { anchor: "center" }, initial: 0.5 }, this.bus);
1614
- this.bonusButton = new ButtonControl({ id: "bonus", layout: { anchor: "bottom-center", offset: [-400, -440] } }, this.bus);
1656
+ this.bonusButton = new ButtonControl({ id: "bonus", layout: defaultLayout("bonus") }, this.bus);
1615
1657
  this.autoplay = new AutoplayControl(
1616
- { id: "autoplay", layout: { anchor: "bottom-center", offset: [-225, -440] }, options: [5, 10, 25, 50, 100, Infinity] },
1658
+ { id: "autoplay", layout: defaultLayout("autoplay"), options: [5, 10, 25, 50, 100, Infinity] },
1617
1659
  this.bus
1618
1660
  );
1619
- this.turbo = new TurboControl({ id: "turbo", layout: { anchor: "bottom-center", offset: [225, -440] } }, this.bus);
1620
- this.betMinus = new ButtonControl({ id: "bet-minus", layout: { anchor: "bottom-center", offset: [-150, -270] } }, this.bus);
1621
- this.betPlus = new ButtonControl({ id: "bet-plus", layout: { anchor: "bottom-center", offset: [150, -270] } }, this.bus);
1661
+ this.turbo = new TurboControl({ id: "turbo", layout: defaultLayout("turbo") }, this.bus);
1662
+ this.betMinus = new ButtonControl({ id: "bet-minus", layout: defaultLayout("bet-minus") }, this.bus);
1663
+ this.betPlus = new ButtonControl({ id: "bet-plus", layout: defaultLayout("bet-plus") }, this.bus);
1622
1664
  this.betStepper = new StepperControl({ id: "bet-stepper", layout: { anchor: "center" }, levels: [0.5, 1, 2, 5, 10, 20], index: 1 }, this.bus);
1623
- this.muteButton = new ButtonControl({ id: "mute", layout: { anchor: "top-right", offset: [-122, 46] } }, this.bus);
1624
- this.fullscreenButton = new ButtonControl({ id: "fullscreen", layout: { anchor: "top-right", offset: [-46, 46] } }, this.bus);
1625
- this.rtp = new ReadoutControl({ id: "rtp", kind: "percent", label: "RTP", layout: { anchor: "top-left", offset: [20, 18] } });
1626
- this.sessionTimer = new ReadoutControl({ id: "session-timer", kind: "duration", label: "Session Time", layout: { anchor: "top-left", offset: [20, 46] } });
1627
- this.netPosition = new ReadoutControl({ id: "net-position", kind: "currency", label: "Net", currency: { code: "USD", symbol: "$", display: "symbol", position: "prefix", decimals: 2 }, layout: { anchor: "top-left", offset: [20, 74] } });
1665
+ this.muteButton = new ButtonControl({ id: "mute", layout: defaultLayout("mute") }, this.bus);
1666
+ this.fullscreenButton = new ButtonControl({ id: "fullscreen", layout: defaultLayout("fullscreen") }, this.bus);
1667
+ this.rtp = new ReadoutControl({ id: "rtp", kind: "percent", label: "RTP", layout: defaultLayout("rtp") });
1668
+ this.sessionTimer = new ReadoutControl({ id: "session-timer", kind: "duration", label: "Session Time", layout: defaultLayout("session-timer") });
1669
+ this.netPosition = new ReadoutControl({ id: "net-position", kind: "currency", label: "Net", currency: { code: "USD", symbol: "$", display: "symbol", position: "prefix", decimals: 2 }, layout: defaultLayout("net-position") });
1628
1670
  this.noticePanel = new PanelControl({ id: "notice-panel", variant: "modal", layout: { anchor: "center" } }, this.bus);
1629
1671
  for (const c of [
1630
1672
  this.spin,
@@ -2064,9 +2106,16 @@ function createUI(spec = {}, hooks = {}) {
2064
2106
  }
2065
2107
  }
2066
2108
  if (spec.jurisdiction) ui.applyJurisdiction(spec.jurisdiction);
2067
- if (spec.responsive) {
2068
- installResponsive(ui, spec.responsive);
2069
- }
2109
+ const portraitControls = {};
2110
+ for (const [id, layout] of Object.entries(portraitDefaultLayouts)) {
2111
+ if (spec.controls?.[id]?.layout) continue;
2112
+ portraitControls[id] = { layout };
2113
+ }
2114
+ Object.assign(portraitControls, spec.responsive?.portrait?.controls);
2115
+ installResponsive(ui, {
2116
+ ...spec.responsive,
2117
+ portrait: { ...spec.responsive?.portrait, controls: portraitControls }
2118
+ });
2070
2119
  if (spec.lockDuringSpin !== false) {
2071
2120
  let wasSpinning = false;
2072
2121
  ui.spin.state.subscribe((s) => {
@@ -2290,6 +2339,7 @@ exports.composeMenu = composeMenu;
2290
2339
  exports.computeScreen = computeScreen;
2291
2340
  exports.createUI = createUI;
2292
2341
  exports.defaultHudSpec = defaultHudSpec;
2342
+ exports.defaultLayout = defaultLayout;
2293
2343
  exports.defaultLayoutConfig = defaultLayoutConfig;
2294
2344
  exports.defaultTheme = defaultTheme;
2295
2345
  exports.defineUI = defineUI;
@@ -2303,8 +2353,10 @@ exports.installResponsive = installResponsive;
2303
2353
  exports.integerDigits = integerDigits;
2304
2354
  exports.isSafeColor = isSafeColor;
2305
2355
  exports.isSocialCurrency = isSocialCurrency;
2356
+ exports.landscapeDefaultLayouts = landscapeDefaultLayouts;
2306
2357
  exports.openuiDefaults = openuiDefaults;
2307
2358
  exports.openuiSocialDefaults = openuiSocialDefaults;
2359
+ exports.portraitDefaultLayouts = portraitDefaultLayouts;
2308
2360
  exports.resolveCurrency = resolveCurrency;
2309
2361
  exports.resolvePlacement = resolvePlacement;
2310
2362
  exports.resolveTheme = resolveTheme;