@sbb-esta/lyne-elements-experimental 5.3.0 → 5.4.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/custom-elements.json +865 -4
- package/development/easter-egg/easter-egg.component.d.ts +80 -0
- package/development/easter-egg/i18n.d.ts +10 -0
- package/development/easter-egg/svgs.d.ts +10 -0
- package/development/easter-egg.d.ts +1 -0
- package/development/easter-egg.js +9 -0
- package/development/easter-egg.pure.d.ts +2 -0
- package/development/easter-egg.pure.js +758 -0
- package/development/seat-reservation.pure.js +6 -6
- package/easter-egg.js +1 -0
- package/easter-egg.pure.js +567 -0
- package/index.d.ts +2 -0
- package/index.js +2 -0
- package/package.json +12 -2
- package/seat-reservation.pure.js +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type SbbElementType } from '@sbb-esta/lyne-elements/core.js';
|
|
2
|
+
import { SbbDialogElement } from '@sbb-esta/lyne-elements/dialog.pure.js';
|
|
3
|
+
import { type CSSResultGroup, type TemplateResult } from 'lit';
|
|
4
|
+
/**
|
|
5
|
+
* A hidden easter egg dialog rendering a canvas-based Snake game.
|
|
6
|
+
*
|
|
7
|
+
* Use the inherited `open()`, `close()` methods and the `isOpen` getter
|
|
8
|
+
* to control the dialog. The dialog can also be triggered from any element
|
|
9
|
+
* via the inherited `trigger` id-reference attribute. Score is exposed via
|
|
10
|
+
* the readonly `score` getter.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SbbEasterEggElement extends SbbDialogElement {
|
|
13
|
+
static readonly elementName: string;
|
|
14
|
+
static elementDependencies: SbbElementType[];
|
|
15
|
+
static styles: CSSResultGroup;
|
|
16
|
+
/** The current game score (number of food items eaten in the current run). */
|
|
17
|
+
get score(): number;
|
|
18
|
+
/** The highest score reached in the current dialog session. Reset on close. */
|
|
19
|
+
get highScore(): number;
|
|
20
|
+
private accessor _score;
|
|
21
|
+
private accessor _highScore;
|
|
22
|
+
private accessor _gameOver;
|
|
23
|
+
private accessor _started;
|
|
24
|
+
private _canvas;
|
|
25
|
+
private _ctx;
|
|
26
|
+
private _cellSize;
|
|
27
|
+
private _snake;
|
|
28
|
+
private _currentDir;
|
|
29
|
+
private _nextDir;
|
|
30
|
+
private _snakePresence;
|
|
31
|
+
private _foodPixel;
|
|
32
|
+
private _currentFoodIndex;
|
|
33
|
+
private _currentSpeed;
|
|
34
|
+
private _timerId;
|
|
35
|
+
private _touchStart;
|
|
36
|
+
private _touchEnd;
|
|
37
|
+
private _trainImages;
|
|
38
|
+
private _foodImages;
|
|
39
|
+
private _gridImage;
|
|
40
|
+
private _imagesReady;
|
|
41
|
+
private _openAbortController;
|
|
42
|
+
private _prevTailCell;
|
|
43
|
+
private _ateFoodThisFrame;
|
|
44
|
+
private _needsFullRedraw;
|
|
45
|
+
constructor();
|
|
46
|
+
disconnectedCallback(): void;
|
|
47
|
+
protected handleOpening(): void;
|
|
48
|
+
protected handleClosing(): void;
|
|
49
|
+
private _initGame;
|
|
50
|
+
private _loadImage;
|
|
51
|
+
private _attachInputListeners;
|
|
52
|
+
private _onTouchStart;
|
|
53
|
+
private _onTouchEnd;
|
|
54
|
+
private _handleSwipe;
|
|
55
|
+
private _onKeydown;
|
|
56
|
+
private _applyDirectionKey;
|
|
57
|
+
private _resetGame;
|
|
58
|
+
private _handleStartClick;
|
|
59
|
+
private _startGame;
|
|
60
|
+
private _stopGame;
|
|
61
|
+
private _setGameOver;
|
|
62
|
+
private _focusStartButton;
|
|
63
|
+
private _updatePoints;
|
|
64
|
+
private _hasCollided;
|
|
65
|
+
private _placeFood;
|
|
66
|
+
private _isReverse;
|
|
67
|
+
private _idx;
|
|
68
|
+
private _getSecondSnakeCellDir;
|
|
69
|
+
private _update;
|
|
70
|
+
private _clearTile;
|
|
71
|
+
private _draw;
|
|
72
|
+
private _getTrainHeadDir;
|
|
73
|
+
private _getTrainTailDir;
|
|
74
|
+
protected render(): TemplateResult;
|
|
75
|
+
}
|
|
76
|
+
declare global {
|
|
77
|
+
interface HTMLElementTagNameMap {
|
|
78
|
+
'sbb-easter-egg': SbbEasterEggElement;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Localized dialog title. */
|
|
2
|
+
export declare const i18nSnakeTitle: Record<string, string>;
|
|
3
|
+
/** Localized label shown next to the current score value. */
|
|
4
|
+
export declare const i18nSnakeScore: Record<string, string>;
|
|
5
|
+
/** Localized label shown next to the current session's high score value. */
|
|
6
|
+
export declare const i18nSnakeHighScore: Record<string, string>;
|
|
7
|
+
/** Localized label for the button that starts the game. */
|
|
8
|
+
export declare const i18nSnakeStart: Record<string, string>;
|
|
9
|
+
/** Localized label for the button that restarts the game after game-over. */
|
|
10
|
+
export declare const i18nSnakeRestart: Record<string, string>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The game board (grid) background image. */
|
|
2
|
+
export declare const gridSvgUrl: string;
|
|
3
|
+
/**
|
|
4
|
+
* The 14 train sprite images, indexed the same way as the original snake.js
|
|
5
|
+
* spritesheet: 0/1 straight body segments, 2..5 corner pieces, 6..9 heads,
|
|
6
|
+
* 10..13 tails.
|
|
7
|
+
*/
|
|
8
|
+
export declare const trainSvgUrls: readonly string[];
|
|
9
|
+
/** The 8 food sprite images. */
|
|
10
|
+
export declare const foodSvgUrls: readonly string[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './easter-egg.pure.ts';
|