@betorigami/game-ui-shared 8.3.0 → 9.1.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 (69) hide show
  1. package/README.md +26 -2
  2. package/dist/components/shared/BetDetailsComponent/BetDetailsComponent.d.ts +0 -2
  3. package/dist/components/shared/BetResultModal/BetResultModal.d.ts +2 -4
  4. package/dist/components/shared/Button/Button.d.ts +0 -1
  5. package/dist/components/shared/Button/LinkButton.d.ts +0 -1
  6. package/dist/components/shared/CurrencySymbol/CurrencySymbol.d.ts +11 -0
  7. package/dist/components/shared/CurrencySymbol/CurrencySymbol.styles.d.ts +1 -0
  8. package/dist/components/shared/FairnessDetails/FairnessContent.d.ts +0 -1
  9. package/dist/components/shared/FairnessDetails/HistoryTable.d.ts +0 -2
  10. package/dist/components/shared/Footer/Footer.d.ts +0 -1
  11. package/dist/components/shared/GameInfo/GameInfoModal.d.ts +0 -3
  12. package/dist/components/shared/GameInfo/gameInfoConfig.d.ts +4 -20
  13. package/dist/components/shared/GameLayout/GameLayout.d.ts +0 -1
  14. package/dist/components/shared/GameOutcomeDisplay/GameOutcomeDisplay.d.ts +0 -1
  15. package/dist/components/shared/GameProviderWrapper.d.ts +1 -1
  16. package/dist/components/shared/GameSidebar/GameSidebar.d.ts +0 -1
  17. package/dist/components/shared/GameWinPopup/GameWinPopup.d.ts +0 -1
  18. package/dist/components/shared/GenericAutobet/BetCountInput.d.ts +0 -1
  19. package/dist/components/shared/GenericAutobet/GenericAutobet.d.ts +0 -1
  20. package/dist/components/shared/HotkeysModal/HotkeysModal.d.ts +0 -1
  21. package/dist/components/shared/Inputs/Input/Input.d.ts +1 -0
  22. package/dist/components/shared/Select/Select.d.ts +0 -1
  23. package/dist/components/shared/UiLock/UiLockContent.d.ts +3 -4
  24. package/dist/components/shared/context/slices/locale.context.d.ts +0 -2
  25. package/dist/controllers/bet-result-cache.controller.d.ts +2 -2
  26. package/dist/index.d.ts +3 -4
  27. package/dist/index.mjs +6271 -7034
  28. package/dist/locales/ar.js +308 -2
  29. package/dist/locales/de.js +308 -2
  30. package/dist/locales/en-soc.js +308 -2
  31. package/dist/locales/es.js +308 -2
  32. package/dist/locales/fi.js +307 -1
  33. package/dist/locales/fr.js +308 -2
  34. package/dist/locales/hi.js +308 -2
  35. package/dist/locales/id.js +308 -2
  36. package/dist/locales/ja.js +308 -2
  37. package/dist/locales/ko.js +308 -2
  38. package/dist/locales/pl.js +308 -2
  39. package/dist/locales/pt.js +308 -2
  40. package/dist/locales/ru.js +308 -2
  41. package/dist/locales/tr.js +308 -2
  42. package/dist/locales/vi.js +308 -2
  43. package/dist/locales/zh.js +308 -2
  44. package/dist/localization/localization.d.ts +4 -3
  45. package/dist/shared/bet.types.d.ts +3 -0
  46. package/dist/shared/game-ui-module.d.ts +1 -3
  47. package/dist/shared/provider-api/error-message.d.ts +1 -2
  48. package/package.json +4 -2
  49. package/dist/translations/ar.json.d.ts +0 -409
  50. package/dist/translations/de.json.d.ts +0 -409
  51. package/dist/translations/dynamic-loader.d.ts +0 -15
  52. package/dist/translations/en-soc.json.d.ts +0 -409
  53. package/dist/translations/en.json.d.ts +0 -412
  54. package/dist/translations/es.json.d.ts +0 -409
  55. package/dist/translations/fi.json.d.ts +0 -409
  56. package/dist/translations/fr.json.d.ts +0 -409
  57. package/dist/translations/hi.json.d.ts +0 -409
  58. package/dist/translations/id.json.d.ts +0 -409
  59. package/dist/translations/index.d.ts +0 -6924
  60. package/dist/translations/ja.json.d.ts +0 -409
  61. package/dist/translations/ko.json.d.ts +0 -409
  62. package/dist/translations/language.context.d.ts +0 -2
  63. package/dist/translations/pl.json.d.ts +0 -409
  64. package/dist/translations/pt.json.d.ts +0 -409
  65. package/dist/translations/ru.json.d.ts +0 -409
  66. package/dist/translations/tr.json.d.ts +0 -409
  67. package/dist/translations/utils.d.ts +0 -22
  68. package/dist/translations/vi.json.d.ts +0 -409
  69. package/dist/translations/zh.json.d.ts +0 -409
package/README.md CHANGED
@@ -4,10 +4,10 @@ The Lit components, controllers, translations, wire types and game-module regist
4
4
 
5
5
  ## Consuming
6
6
 
7
- `lit`, `@lit/context` and `big.js` are peer dependencies so that one copy of each is bundled by the host. Importing the package registers every shared custom element.
7
+ `lit`, `@lit/context`, `@lit/localize` and `big.js` are peer dependencies so that one copy of each is bundled by the host. Importing the package registers every shared custom element.
8
8
 
9
9
  ```ts
10
- import { GameComponent, RequiredContext, localeContext, getTranslation } from '@betorigami/game-ui-shared';
10
+ import { GameComponent, RequiredContext, localeContext } from '@betorigami/game-ui-shared';
11
11
  ```
12
12
 
13
13
  Elements read the game context through `RequiredContext`, one per slice they need (`localeContext`, `sessionContext`, `limitsContext`, `servicesContext`, `skinContext`, `preferencesContext`, `layoutContext`, `walletContext`), all provided by `<origami-game-provider-wrapper>`. Reading a slice outside the wrapper throws. Desktop and mobile styles go in `${desktopContainerQuery} { … }` and `${mobileContainerQuery} { … }` blocks, after the base rules they override; both query the `game-layout` container the wrapper provides. Tests give an element its slices with `provideTestContexts` and change them with `updateTestContexts`.
@@ -34,6 +34,30 @@ declare module '@betorigami/game-ui-shared' {
34
34
 
35
35
  The package does not read environment variables. A host that wants a different provably-fair verifier calls `setVerifierBaseUrl` with that URL at startup; a host that does not leaves the built-in default in place.
36
36
 
37
+ ## Translations
38
+
39
+ Text is translated with [`@lit/localize`](https://lit.dev/docs/localization/overview/) in runtime mode. The kit holds the one setup for itself and every game: `<origami-game-provider-wrapper>` loads the locale for its `language` attribute and renders the game once it has loaded. English needs no file, and each other locale is its own chunk.
40
+
41
+ Write the English text where it is used, with a dotted id:
42
+
43
+ ```ts
44
+ import { msg, str } from '@lit/localize';
45
+
46
+ msg('Place Bet', { id: 'common.placeBet' });
47
+ msg(str`Maximum bet is ${value}`, { id: 'alerts.betAmountAboveMaxBet' });
48
+ ```
49
+
50
+ The text and the id must be written out at the call, because they are read from the source. To choose between messages at runtime, use a `switch` with one `msg()` call per case. Pass `str` a named value, not an expression: the name is what a translator sees for that placeholder in the XLIFF file, so `${max}` reads better than a function call, and the files don't change when the expression does. Call `msg()` when rendering, never at module scope, where the locale has not loaded yet.
51
+
52
+ The translations are the XLIFF files in `src/localization/translations/`, one per locale. After adding, changing or removing a `msg()` call in the kit, `games` or Wheel:
53
+
54
+ 1. Run `pnpm run extract:locales` in this package. It rewrites the XLIFF files to match the `msg()` calls and keeps the translations that are already there.
55
+ 2. Add a `<target>` for each new message in each XLIFF file. A message with no `<target>` shows in English.
56
+ 3. If you changed the English text of an existing message, keep its id and check its `<target>` in each XLIFF file against the new English. `extract` keeps the old translation and gives no warning. Where a target no longer says what the English says, update it, or delete it if you can't translate it: a message with no `<target>` shows in English, and the build lists it as missing until someone translates it.
57
+ 4. Run `pnpm run build:locales` and commit the XLIFF files with the modules under `src/localization/generated/`. Don't edit the generated files by hand.
58
+
59
+ CI runs both commands and fails if either changes a file.
60
+
37
61
  ## Provider API client
38
62
 
39
63
  `ProviderApi` is a client for provider-api, generated with [hey-api](https://heyapi.dev) from provider-api's OpenAPI spec. Every response is parsed with zod/mini before the caller sees it. Schemas the spec marks `"x-origami-type": "Money"` arrive as `Money` and those marked `"x-origami-type": "MoneyMultiplier"` arrive as `MoneyMultiplier`.
@@ -1,11 +1,9 @@
1
1
  import { default as OrigamiElement } from '../../../shared/origami-element';
2
- import { Language } from '../../../translations/language.context';
3
2
  import { TemplateResult } from 'lit';
4
3
  export declare class BetDetailsComponent extends OrigamiElement {
5
4
  static styles: import('lit').CSSResult[];
6
5
  baseUrl: string;
7
6
  betId: string;
8
- language: Language;
9
7
  private _betDetails;
10
8
  private get _gameName();
11
9
  private get _roundId();
@@ -1,12 +1,11 @@
1
- import { BetResult } from '../../../shared/bet.types';
1
+ import { BetInfo } from '../../../shared/bet.types';
2
2
  import { OrigamiGame } from '../../../shared/constants';
3
3
  import { default as OrigamiElement } from '../../../shared/origami-element';
4
4
  export declare class BetResultModal extends OrigamiElement {
5
- private readonly locale;
6
5
  private readonly session;
7
6
  static styles: import('lit').CSSResult[];
8
7
  betId: string;
9
- betData: Omit<BetResult, 'afterBalance'> | null;
8
+ betData: BetInfo | null;
10
9
  private _copiedId;
11
10
  private _copyTimeout;
12
11
  private betResultCache;
@@ -19,7 +18,6 @@ export declare class BetResultModal extends OrigamiElement {
19
18
  private _formatMonetaryAmount;
20
19
  private _calculateMultiplier;
21
20
  private _calculatePayout;
22
- private _getCurrencyDisplay;
23
21
  private openVerifyOutcomeModal;
24
22
  triggerVerify(): void;
25
23
  get gameType(): OrigamiGame;
@@ -1,7 +1,6 @@
1
1
  import { default as OrigamiElement } from '../../../shared/origami-element';
2
2
  export type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'icon' | 'icon-secondary';
3
3
  export declare class Button extends OrigamiElement {
4
- private readonly locale;
5
4
  private readonly services;
6
5
  private readonly preferences;
7
6
  static styles: import('lit').CSSResult[];
@@ -2,7 +2,6 @@ import { ButtonVariant } from './Button';
2
2
  import { default as OrigamiElement } from '../../../shared/origami-element';
3
3
  export type LinkButtonTarget = '_self' | '_top' | '_blank';
4
4
  export declare class LinkButton extends OrigamiElement {
5
- private readonly locale;
6
5
  private readonly services;
7
6
  static styles: import('lit').CSSResult[];
8
7
  static shadowRootOptions: {
@@ -0,0 +1,11 @@
1
+ import { nothing } from 'lit';
2
+ import { Currency } from '../../../shared/constants';
3
+ import { default as OrigamiElement } from '../../../shared/origami-element';
4
+ import { TooltipPosition } from '../Tooltip/Tooltip';
5
+ export declare class CurrencySymbol extends OrigamiElement {
6
+ static styles: import('lit').CSSResult[];
7
+ private readonly locale;
8
+ currency?: Currency;
9
+ tooltipPosition?: TooltipPosition;
10
+ render(): import('lit').TemplateResult<1> | typeof nothing;
11
+ }
@@ -0,0 +1 @@
1
+ export declare const currencySymbolStyles: import('lit').CSSResult;
@@ -10,7 +10,6 @@ export interface ProvablyFairData {
10
10
  verifierOptions?: VerifierGameOptions;
11
11
  }
12
12
  export declare class FairnessContent extends OrigamiElement {
13
- private readonly locale;
14
13
  private readonly session;
15
14
  private readonly services;
16
15
  static styles: import('lit').CSSResult[];
@@ -1,6 +1,5 @@
1
1
  import { default as OrigamiElement } from '../../../shared/origami-element';
2
2
  export declare class HistoryTable extends OrigamiElement {
3
- private readonly locale;
4
3
  private readonly session;
5
4
  private readonly services;
6
5
  private readonly layout;
@@ -23,7 +22,6 @@ export declare class HistoryTable extends OrigamiElement {
23
22
  private loadHistoryData;
24
23
  private _handleRowHover;
25
24
  private _formatMonetaryAmount;
26
- private _getCurrencyDisplay;
27
25
  private _formatTimestamp;
28
26
  private _calculateMultiplier;
29
27
  private _calculatePayout;
@@ -1,6 +1,5 @@
1
1
  import { default as OrigamiElement } from '../../../shared/origami-element';
2
2
  export declare class Footer extends OrigamiElement {
3
- private readonly locale;
4
3
  private readonly session;
5
4
  private readonly skin;
6
5
  private readonly preferences;
@@ -8,9 +8,6 @@ export declare class GameInfoModal extends OrigamiElement {
8
8
  gameType: OrigamiGame;
9
9
  get rtpValue(): number;
10
10
  private renderAccordionSection;
11
- private renderAccordionSectionWithCustomContent;
12
- private renderAccordionSectionWithInterpolation;
13
- private getOverviewText;
14
11
  private renderAccordionSections;
15
12
  render(): TemplateResult<1>;
16
13
  }
@@ -1,26 +1,10 @@
1
- import { TranslationKey } from '../../../translations';
2
1
  import { OrigamiGame } from '../../../shared/constants';
3
2
  import { LimitsContextType } from '../context/slices/limits.context';
4
- export interface TranslationInfo {
5
- key: TranslationKey;
6
- fallback: string;
7
- }
8
3
  export interface GameInfoConfig {
9
- overview: {
10
- translation: TranslationInfo;
11
- };
12
- tutorial: {
13
- translation: TranslationInfo;
14
- steps: Array<TranslationInfo>;
15
- };
16
- strategy: TranslationInfo;
17
- provablyFair: TranslationInfo;
18
- rtp: {
19
- translation: TranslationInfo;
20
- };
21
- limit: {
22
- translation: TranslationInfo;
23
- };
4
+ overview: () => string;
5
+ tutorialSteps: ReadonlyArray<() => string>;
6
+ strategy: () => string;
7
+ provablyFair: () => string;
24
8
  }
25
9
  export declare const getGameInfoConfig: (game: OrigamiGame) => GameInfoConfig | undefined;
26
10
  export declare const calculateMaxMultiplier: (game: OrigamiGame, limits: LimitsContextType) => string;
@@ -2,7 +2,6 @@ import { AlertManager } from '../AlertManager/AlertManager';
2
2
  import { OrigamiGame } from '../../../shared/constants';
3
3
  import { default as OrigamiElement } from '../../../shared/origami-element';
4
4
  export declare class GameLayout extends OrigamiElement {
5
- private readonly locale;
6
5
  private readonly session;
7
6
  private readonly limits;
8
7
  private readonly services;
@@ -2,7 +2,6 @@ import { nothing } from 'lit';
2
2
  import { OrigamiGame } from '../../../shared/constants';
3
3
  import { default as OrigamiElement } from '../../../shared/origami-element';
4
4
  export declare class GameOutcomeDisplay extends OrigamiElement {
5
- private readonly locale;
6
5
  static styles: import('lit').CSSResult[];
7
6
  gameType: OrigamiGame | 'INVALID_GAME';
8
7
  inBetResultModal: boolean;
@@ -1,8 +1,8 @@
1
1
  import { Currency, OrigamiGame } from '../../shared/constants';
2
2
  import { default as OrigamiElement } from '../../shared/origami-element';
3
- import { Language } from '../../translations/language.context';
4
3
  import { PropertyValues } from 'lit';
5
4
  import { default as Big } from 'big.js';
5
+ import { Language } from '../../localization/localization';
6
6
  export declare class GameProviderWrapper extends OrigamiElement {
7
7
  static styles: import('lit').CSSResult[];
8
8
  currency: Currency;
@@ -1,7 +1,6 @@
1
1
  import { default as OrigamiElement } from '../../../shared/origami-element';
2
2
  export type BetMode = 'Manual' | 'Auto';
3
3
  export declare class GameSidebar extends OrigamiElement {
4
- private readonly locale;
5
4
  static styles: import('lit').CSSResult[];
6
5
  mode: BetMode;
7
6
  toggleDisabled: boolean;
@@ -3,7 +3,6 @@ import { default as Big } from 'big.js';
3
3
  import { default as OrigamiElement } from '../../../shared/origami-element';
4
4
  type GameType = 'Keno' | 'Mines' | 'Roulette';
5
5
  export declare class GameWinPopup extends OrigamiElement {
6
- private readonly locale;
7
6
  private readonly session;
8
7
  private readonly skin;
9
8
  static styles: import('lit').CSSResult[];
@@ -1,6 +1,5 @@
1
1
  import { default as OrigamiElement } from '../../../shared/origami-element';
2
2
  export declare class BetCountInput extends OrigamiElement {
3
- private readonly locale;
4
3
  private readonly wallet;
5
4
  disabled: boolean;
6
5
  static styles: import('lit').CSSResult[];
@@ -11,7 +11,6 @@ export type AutobetValues = {
11
11
  export declare const defaultAutobetValues: AutobetValues;
12
12
  export type AutobetEventPayload = AutobetValues;
13
13
  export declare class GenericAutobet extends OrigamiElement {
14
- private readonly locale;
15
14
  private readonly wallet;
16
15
  private readonly services;
17
16
  inputsDisabled: boolean;
@@ -1,7 +1,6 @@
1
1
  import { OrigamiGame } from '../../../shared/constants';
2
2
  import { default as OrigamiElement } from '../../../shared/origami-element';
3
3
  export declare class HotkeysModal extends OrigamiElement {
4
- private readonly locale;
5
4
  static styles: import('lit').CSSResult[];
6
5
  gameType: OrigamiGame;
7
6
  private getRows;
@@ -40,6 +40,7 @@ export declare class Input extends OrigamiElement {
40
40
  validationPattern: string | null;
41
41
  validationMessage: string | null;
42
42
  hideRightLabel: boolean;
43
+ hideRightIcon: boolean;
43
44
  clickable: boolean;
44
45
  forceActiveBorder: boolean;
45
46
  keepLabelEnabled: boolean;
@@ -6,7 +6,6 @@ export interface SelectOption<T extends string = string> {
6
6
  group?: string;
7
7
  }
8
8
  export declare class Select extends OrigamiElement {
9
- private readonly locale;
10
9
  static styles: import('lit').CSSResult[];
11
10
  dir: string;
12
11
  label: string;
@@ -1,10 +1,9 @@
1
1
  import { TemplateResult } from 'lit';
2
- import { Language } from '../../../translations';
3
2
  export type UiLockContent = {
4
3
  title: string;
5
4
  description: string;
6
5
  button?: TemplateResult;
7
6
  };
8
- export declare const createLobbyLockButton: (lobbyUrl: string | null, language: Language) => TemplateResult | undefined;
9
- export declare const createSessionExpiredLock: (lobbyUrl: string | null, language: Language) => UiLockContent;
10
- export declare const createOutOfSyncLock: (lobbyUrl: string | null, language: Language) => UiLockContent;
7
+ export declare const createLobbyLockButton: (lobbyUrl: string | null) => TemplateResult | undefined;
8
+ export declare const createSessionExpiredLock: (lobbyUrl: string | null) => UiLockContent;
9
+ export declare const createOutOfSyncLock: (lobbyUrl: string | null) => UiLockContent;
@@ -1,7 +1,5 @@
1
1
  import { Currency } from '../../../../shared/constants';
2
- import { Language } from '../../../../translations';
3
2
  export type LocaleContextType = {
4
- language: Language;
5
3
  currency: Currency;
6
4
  currencyDecimals: number;
7
5
  payoutDecimals: number;
@@ -1,4 +1,4 @@
1
- import { BetResult } from '../shared/bet.types';
1
+ import { BetInfo } from '../shared/bet.types';
2
2
  export declare class BetResultCacheController {
3
3
  private static instance;
4
4
  private cache;
@@ -6,7 +6,7 @@ export declare class BetResultCacheController {
6
6
  private readonly maxCacheSize;
7
7
  private readonly cacheExpirationMs;
8
8
  static getInstance(): BetResultCacheController;
9
- fetchBetResult(betId: string, baseUrl: string): Promise<BetResult | null>;
9
+ fetchBetResult(betId: string, baseUrl: string): Promise<BetInfo | null>;
10
10
  private performFetch;
11
11
  private getFromCache;
12
12
  private addToCache;
package/dist/index.d.ts CHANGED
@@ -11,6 +11,8 @@ export * from './components/shared/Button/ButtonGroup.styles';
11
11
  export * from './components/shared/Button/ButtonGroup';
12
12
  export * from './components/shared/ChipStack/ChipStack.styles';
13
13
  export * from './components/shared/ChipStack/ChipStack';
14
+ export * from './components/shared/CurrencySymbol/CurrencySymbol.styles';
15
+ export * from './components/shared/CurrencySymbol/CurrencySymbol';
14
16
  export * from './components/shared/ChipTableGameComponent';
15
17
  export * from './components/shared/DepositButton/DepositButton';
16
18
  export * from './components/shared/Drawer/Drawer.styles';
@@ -182,10 +184,7 @@ export * from './shared/utils/format-autobet-settings';
182
184
  export * from './shared/utils/prevent-non-numeric-input';
183
185
  export * from './shared/wait-for-event';
184
186
  export * from './shared/watch';
185
- export * from './translations/dynamic-loader';
186
- export * from './translations/index';
187
- export * from './translations/language.context';
188
- export * from './translations/utils';
187
+ export type { Language } from './localization/localization';
189
188
  export * from './utils/active-elements';
190
189
  export * from './utils/animate';
191
190
  export * from './utils/animation-registry';