@everymatrix/mini-games-lobby 1.14.0 → 1.15.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/cjs/{index-787a0452.js → index-90b83e7e.js} +42 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/mini-games-lobby.cjs.entry.js +216 -16
- package/dist/cjs/mini-games-lobby.cjs.js +2 -2
- package/dist/collection/components/mini-games-lobby/mini-games-lobby.js +137 -12
- package/dist/collection/decorators/base.decorator.js +12 -0
- package/dist/collection/decorators/locale.decorator.js +40 -0
- package/dist/collection/decorators/style.decorator.js +28 -0
- package/dist/collection/decorators/style.util.js +36 -0
- package/dist/collection/utils/fetch.js +5 -5
- package/dist/collection/utils/translation.js +8 -0
- package/dist/components/mini-games-lobby.js +221 -16
- package/dist/esm/{index-c397d449.js → index-ced8f413.js} +42 -0
- package/dist/esm/loader.js +2 -2
- package/dist/esm/mini-games-lobby.entry.js +216 -16
- package/dist/esm/mini-games-lobby.js +2 -2
- package/dist/mini-games-lobby/mini-games-lobby.esm.js +1 -1
- package/dist/mini-games-lobby/p-3d148f41.entry.js +1 -0
- package/dist/mini-games-lobby/p-e3451601.js +1 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/widgets-stencil/packages/mini-games-lobby/.stencil/packages/mini-games-lobby/stencil.config.d.ts +2 -0
- package/dist/types/components/mini-games-lobby/mini-games-lobby.d.ts +32 -2
- package/dist/types/components.d.ts +32 -0
- package/dist/types/decorators/base.decorator.d.ts +2 -0
- package/dist/types/decorators/locale.decorator.d.ts +2 -0
- package/dist/types/decorators/style.decorator.d.ts +2 -0
- package/dist/types/decorators/style.util.d.ts +3 -0
- package/dist/types/utils/fetch.d.ts +1 -1
- package/dist/types/utils/translation.d.ts +9 -0
- package/package.json +6 -2
- package/dist/collection/utils/utils.js +0 -3
- package/dist/mini-games-lobby/p-6b4efa39.js +0 -1
- package/dist/mini-games-lobby/p-8e2c292a.entry.js +0 -1
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/mini-games-lobby/.stencil/packages/mini-games-lobby/stencil.config.d.ts +0 -2
- package/dist/types/utils/utils.d.ts +0 -1
|
@@ -678,6 +678,11 @@ const dispatchHooks = (hostRef, isInitialLoad) => {
|
|
|
678
678
|
const endSchedule = createTime('scheduleUpdate', hostRef.$cmpMeta$.$tagName$);
|
|
679
679
|
const instance = hostRef.$lazyInstance$ ;
|
|
680
680
|
let promise;
|
|
681
|
+
if (isInitialLoad) {
|
|
682
|
+
{
|
|
683
|
+
promise = safeCall(instance, 'componentWillLoad');
|
|
684
|
+
}
|
|
685
|
+
}
|
|
681
686
|
endSchedule();
|
|
682
687
|
return then(promise, () => updateComponent(hostRef, instance, isInitialLoad));
|
|
683
688
|
};
|
|
@@ -849,6 +854,7 @@ const getValue = (ref, propName) => getHostRef(ref).$instanceValues$.get(propNam
|
|
|
849
854
|
const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
850
855
|
// check our new property value against our internal value
|
|
851
856
|
const hostRef = getHostRef(ref);
|
|
857
|
+
const elm = hostRef.$hostElement$ ;
|
|
852
858
|
const oldVal = hostRef.$instanceValues$.get(propName);
|
|
853
859
|
const flags = hostRef.$flags$;
|
|
854
860
|
const instance = hostRef.$lazyInstance$ ;
|
|
@@ -861,7 +867,28 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
861
867
|
// set our new value!
|
|
862
868
|
hostRef.$instanceValues$.set(propName, newVal);
|
|
863
869
|
if (instance) {
|
|
870
|
+
// get an array of method names of watch functions to call
|
|
871
|
+
if (cmpMeta.$watchers$ && flags & 128 /* isWatchReady */) {
|
|
872
|
+
const watchMethods = cmpMeta.$watchers$[propName];
|
|
873
|
+
if (watchMethods) {
|
|
874
|
+
// this instance is watching for when this property changed
|
|
875
|
+
watchMethods.map((watchMethodName) => {
|
|
876
|
+
try {
|
|
877
|
+
// fire off each of the watch methods that are watching this property
|
|
878
|
+
instance[watchMethodName](newVal, oldVal, propName);
|
|
879
|
+
}
|
|
880
|
+
catch (e) {
|
|
881
|
+
consoleError(e, elm);
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
}
|
|
864
886
|
if ((flags & (2 /* hasRendered */ | 16 /* isQueuedForUpdate */)) === 2 /* hasRendered */) {
|
|
887
|
+
if (instance.componentShouldUpdate) {
|
|
888
|
+
if (instance.componentShouldUpdate(newVal, oldVal, propName) === false) {
|
|
889
|
+
return;
|
|
890
|
+
}
|
|
891
|
+
}
|
|
865
892
|
// looks like this value actually changed, so we've got work to do!
|
|
866
893
|
// but only if we've already rendered, otherwise just chill out
|
|
867
894
|
// queue that we need to do an update, but don't worry about queuing
|
|
@@ -873,6 +900,9 @@ const setValue = (ref, propName, newVal, cmpMeta) => {
|
|
|
873
900
|
};
|
|
874
901
|
const proxyComponent = (Cstr, cmpMeta, flags) => {
|
|
875
902
|
if (cmpMeta.$members$) {
|
|
903
|
+
if (Cstr.watchers) {
|
|
904
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
905
|
+
}
|
|
876
906
|
// It's better to have a const than two Object.entries()
|
|
877
907
|
const members = Object.entries(cmpMeta.$members$);
|
|
878
908
|
const prototype = Cstr.prototype;
|
|
@@ -977,6 +1007,12 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
977
1007
|
endLoad();
|
|
978
1008
|
}
|
|
979
1009
|
if (!Cstr.isProxied) {
|
|
1010
|
+
// we've never proxied this Constructor before
|
|
1011
|
+
// let's add the getters/setters to its prototype before
|
|
1012
|
+
// the first time we create an instance of the implementation
|
|
1013
|
+
{
|
|
1014
|
+
cmpMeta.$watchers$ = Cstr.watchers;
|
|
1015
|
+
}
|
|
980
1016
|
proxyComponent(Cstr, cmpMeta, 2 /* proxyState */);
|
|
981
1017
|
Cstr.isProxied = true;
|
|
982
1018
|
}
|
|
@@ -1000,6 +1036,9 @@ const initializeComponent = async (elm, hostRef, cmpMeta, hmrVersionId, Cstr) =>
|
|
|
1000
1036
|
{
|
|
1001
1037
|
hostRef.$flags$ &= ~8 /* isConstructingInstance */;
|
|
1002
1038
|
}
|
|
1039
|
+
{
|
|
1040
|
+
hostRef.$flags$ |= 128 /* isWatchReady */;
|
|
1041
|
+
}
|
|
1003
1042
|
endNewInstance();
|
|
1004
1043
|
}
|
|
1005
1044
|
if (Cstr.style) {
|
|
@@ -1099,6 +1138,9 @@ const bootstrapLazy = (lazyBundles, options = {}) => {
|
|
|
1099
1138
|
{
|
|
1100
1139
|
cmpMeta.$members$ = compactMeta[2];
|
|
1101
1140
|
}
|
|
1141
|
+
{
|
|
1142
|
+
cmpMeta.$watchers$ = {};
|
|
1143
|
+
}
|
|
1102
1144
|
const tagName = cmpMeta.$tagName$;
|
|
1103
1145
|
const HostElement = class extends HTMLElement {
|
|
1104
1146
|
// StencilLazyHost
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-90b83e7e.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
8
|
Stencil Client Patch Esm v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["mini-games-lobby.cjs",[[1,"mini-games-lobby",{"session":[1],"endpoint":[1],"language":[1],"launchUrl":[32],"games":[32]}]]]], options);
|
|
17
|
+
return index.bootstrapLazy([["mini-games-lobby.cjs",[[1,"mini-games-lobby",{"filter":[1],"session":[1],"endpoint":[1],"language":[1],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"translationUrl":[1,"translation-url"],"locale":[32],"launchUrl":[32],"games":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -2,7 +2,38 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-90b83e7e.js');
|
|
6
|
+
|
|
7
|
+
/******************************************************************************
|
|
8
|
+
Copyright (c) Microsoft Corporation.
|
|
9
|
+
|
|
10
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
11
|
+
purpose with or without fee is hereby granted.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
14
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
15
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
16
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
17
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
18
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
19
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
20
|
+
***************************************************************************** */
|
|
21
|
+
|
|
22
|
+
function __decorate(decorators, target, key, desc) {
|
|
23
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
24
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
25
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function __metadata(metadataKey, metadataValue) {
|
|
30
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
34
|
+
var e = new Error(message);
|
|
35
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
36
|
+
};
|
|
6
37
|
|
|
7
38
|
const fetcher = async (url) => {
|
|
8
39
|
let res;
|
|
@@ -18,14 +49,14 @@ const fetcher = async (url) => {
|
|
|
18
49
|
const getUrl = (path, params = {}) => {
|
|
19
50
|
return path + '?' + Object.keys(params).map(key => `${key}=${params[key]}`).join('&');
|
|
20
51
|
};
|
|
21
|
-
|
|
22
|
-
const url = getUrl(`${endpoint}/casino/games`, {
|
|
23
|
-
language,
|
|
24
|
-
filter:
|
|
52
|
+
async function fetchGames() {
|
|
53
|
+
const url = getUrl(`${this.endpoint}/casino/games`, {
|
|
54
|
+
language: this.language,
|
|
55
|
+
filter: this.filter || `categories(id=MINIGAMES),vendor(name=PragmaticPlay)`,
|
|
25
56
|
});
|
|
26
57
|
const res = await fetcher(url);
|
|
27
58
|
return res.items;
|
|
28
|
-
}
|
|
59
|
+
}
|
|
29
60
|
|
|
30
61
|
const crossIconSvg = 'data:image/svg+xml;base64,ICA8c3ZnIGNsYXNzPSJpY29uIHN2Zy13aXRoLXN0cm9rZSBudWxsIiB3aWR0aD0iMTJweCIgaGVpZ2h0PSIxMnB4IiB2aWV3Qm94PSIwIDAgMTAuMyAxMC4zIgogICAgdmVyc2lvbj0iMS4xIgogICAgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIgogID4KICAgIDxnIGNsYXNzPSJzdmdfX2ZpbGwiIGZpbGwtcnVsZT0iZXZlbm9kZCIgc3Ryb2tlPSIjMjIyMjIyIiBzdHJva2Utd2lkdGg9IjIiPgogICAgICA8cGF0aCBkPSJNMTAsMC40TDAuNCwxMCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiAvPgogICAgICA8cGF0aCBkPSJNMTAsMTBMMC40LDAuNCIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiAvPgogICAgPC9nPgogIDwvc3ZnPg==';
|
|
31
62
|
|
|
@@ -61,35 +92,204 @@ const Games = ({ text, games, onClickGame }) => (index.h("div", { class: "GamesC
|
|
|
61
92
|
index.h("div", { id: "Games" }, games.map((game) => index.h("div", { class: "Game" },
|
|
62
93
|
index.h("div", Object.assign({ class: "GameImg" }, getProps(game, onClickGame))))))));
|
|
63
94
|
|
|
95
|
+
const apply = (proto, lifecycle, run) => {
|
|
96
|
+
const existLifeCycle = proto[lifecycle];
|
|
97
|
+
if (!existLifeCycle) {
|
|
98
|
+
throw new Error('lifecycle ' + lifecycle + ' not defined');
|
|
99
|
+
}
|
|
100
|
+
proto[lifecycle] = function (...args) {
|
|
101
|
+
run.bind(this, ...args).call();
|
|
102
|
+
if (existLifeCycle) {
|
|
103
|
+
return existLifeCycle.bind(this, ...args).call();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const translation = {
|
|
109
|
+
en: {
|
|
110
|
+
MiniGames: 'Mini Games',
|
|
111
|
+
},
|
|
112
|
+
'zh-hk': {
|
|
113
|
+
MiniGames: '小游戲',
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const getLocale = (_translations, language) => {
|
|
118
|
+
return _translations[language] || _translations['en'];
|
|
119
|
+
};
|
|
120
|
+
function setLocale() {
|
|
121
|
+
this.locale = getLocale(this.translation, this.language);
|
|
122
|
+
}
|
|
123
|
+
async function setLocaleByUrl(isInit = true) {
|
|
124
|
+
if (this.translationUrl) {
|
|
125
|
+
this.translation = await fetcher(this.translationUrl);
|
|
126
|
+
setLocale.bind(this).call();
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
if (!isInit) {
|
|
130
|
+
this.translation = translation;
|
|
131
|
+
setLocale.bind(this).call();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
const Locale = () => {
|
|
136
|
+
// @ts-ignore
|
|
137
|
+
return (proto, prop) => {
|
|
138
|
+
apply(proto, 'componentWillLoad', async function () {
|
|
139
|
+
this.translation = translation;
|
|
140
|
+
setLocale.bind(this).call();
|
|
141
|
+
setLocaleByUrl.bind(this, true).call();
|
|
142
|
+
});
|
|
143
|
+
// @ts-ignore
|
|
144
|
+
apply(proto, 'componentShouldUpdate', async function (newValue, oldValue, key) {
|
|
145
|
+
if (key === 'language') {
|
|
146
|
+
setLocale.bind(this).call();
|
|
147
|
+
}
|
|
148
|
+
if (key === 'translationUrl') {
|
|
149
|
+
setLocaleByUrl.bind(this, false).call();
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const fetchText = async (url) => {
|
|
156
|
+
let styleCode;
|
|
157
|
+
try {
|
|
158
|
+
let res = await fetch(url);
|
|
159
|
+
styleCode = await res.text();
|
|
160
|
+
}
|
|
161
|
+
catch (err) {
|
|
162
|
+
console.error('error ', err);
|
|
163
|
+
}
|
|
164
|
+
return styleCode;
|
|
165
|
+
};
|
|
166
|
+
const setStyle = (container, index, styleCode) => {
|
|
167
|
+
const sheet = new CSSStyleSheet();
|
|
168
|
+
styleCode && sheet.insertRule(styleCode);
|
|
169
|
+
try {
|
|
170
|
+
container.adoptedStyleSheets[index] = sheet;
|
|
171
|
+
}
|
|
172
|
+
catch (err) { }
|
|
173
|
+
};
|
|
174
|
+
const getCode = async (url) => {
|
|
175
|
+
let styleCode;
|
|
176
|
+
if (url) {
|
|
177
|
+
styleCode = await fetchText(url);
|
|
178
|
+
}
|
|
179
|
+
return styleCode;
|
|
180
|
+
};
|
|
181
|
+
const setClientStyling = (root, styleCode) => {
|
|
182
|
+
if (!root)
|
|
183
|
+
return;
|
|
184
|
+
setStyle(root, 1, styleCode);
|
|
185
|
+
};
|
|
186
|
+
const setClientStylingUrl = async (root, url) => {
|
|
187
|
+
if (!root)
|
|
188
|
+
return;
|
|
189
|
+
setStyle(root, 2, await getCode(url));
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
const matchStyleProcess = (root, value, key) => {
|
|
193
|
+
switch (key) {
|
|
194
|
+
case 'clientStyling':
|
|
195
|
+
setClientStyling(root, value);
|
|
196
|
+
break;
|
|
197
|
+
case 'clientStylingUrl':
|
|
198
|
+
setClientStylingUrl(root, value);
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
const Style = () => {
|
|
203
|
+
return (proto, prop) => {
|
|
204
|
+
apply(proto, 'componentDidLoad', function () {
|
|
205
|
+
const root = index.getElement(this).shadowRoot;
|
|
206
|
+
matchStyleProcess(root, this[prop], prop);
|
|
207
|
+
});
|
|
208
|
+
// @ts-ignore
|
|
209
|
+
apply(proto, 'componentShouldUpdate', function (newValue, oldValue, key) {
|
|
210
|
+
if (key !== prop)
|
|
211
|
+
return;
|
|
212
|
+
const root = index.getElement(this).shadowRoot;
|
|
213
|
+
matchStyleProcess(root, this[prop], prop);
|
|
214
|
+
});
|
|
215
|
+
};
|
|
216
|
+
};
|
|
217
|
+
|
|
64
218
|
const miniGamesLobbyCss = ":host{display:block}*{box-sizing:border-box}#LobbyContainer{display:flex;flex-direction:column;flex-grow:1;position:relative}#GameLaunchHeader{align-items:center;display:flex;background:var(--mini-games-header-bg, var(--base-bg, #fff));height:40px;justify-content:space-between;padding:0 15px}#GameLaunchHeader button{border:none;color:inherit;cursor:pointer;outline:0}#GameLaunchHeader .GameIcon--full-screen{margin:0 10px 0 auto}#GameLaunchHeader .GameIcon{background:var(--mini-game-icon-bg, transparent);padding:0}#GamesHeader{align-items:center;display:flex;background:var(--mini-games-header-bg, var(--base-bg, #fff));height:40px;justify-content:space-between;padding:0 15px;color:var(--mini-games-header-color, var(--text, #000))}#GamesHeader button{border:none;color:inherit;cursor:pointer;outline:0}#GamesHeader>div{align-items:center;display:flex}#GamesHeader p{font-weight:600;margin:0 5px}@media (min-width: 340px){#Games{gap:15px;justify-content:center}}#Games{display:inline-flex;flex-wrap:wrap;justify-content:space-between;gap:4px;padding:15px 15px 54px}.Game{width:68px;height:68px;border-radius:50%;box-shadow:0 4px 12px 0 rgba(13, 19, 29, 0.3);cursor:pointer}.GameImg{width:68px;height:68px;background-position:center center;background-size:cover;transition:0.3s}.GameImg:hover{transform:scale(1.5)}";
|
|
65
219
|
|
|
66
220
|
const MiniGamesLobby = class {
|
|
67
221
|
constructor(hostRef) {
|
|
68
222
|
index.registerInstance(this, hostRef);
|
|
223
|
+
/**
|
|
224
|
+
* Language of the widget
|
|
225
|
+
*/
|
|
226
|
+
this.language = 'en';
|
|
227
|
+
/**
|
|
228
|
+
* Client custom styling via string
|
|
229
|
+
*/
|
|
230
|
+
this.clientStyling = '';
|
|
231
|
+
/**
|
|
232
|
+
* Client custom styling via url
|
|
233
|
+
*/
|
|
234
|
+
this.clientStylingUrl = '';
|
|
235
|
+
/**
|
|
236
|
+
* translation via url
|
|
237
|
+
*/
|
|
238
|
+
this.translationUrl = '';
|
|
69
239
|
this.launchUrl = undefined;
|
|
70
240
|
this.games = [];
|
|
71
241
|
}
|
|
72
|
-
async componentDidLoad() {
|
|
73
|
-
this.games = await fetchGames(this.endpoint, this.language);
|
|
74
|
-
}
|
|
75
|
-
onClickGame(launchUrl_raw) {
|
|
76
|
-
this.launchUrl = getUrl(launchUrl_raw, {
|
|
77
|
-
language: this.language,
|
|
78
|
-
_sid: this.session,
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
242
|
render() {
|
|
82
243
|
return (index.h("div", { id: "LobbyContainer" }, index.h(GameLauncher, Object.assign({}, {
|
|
83
244
|
src: this.launchUrl,
|
|
84
245
|
host: this.host
|
|
85
246
|
})), index.h(Games, Object.assign({}, {
|
|
86
|
-
text:
|
|
247
|
+
text: this.locale.MiniGames,
|
|
87
248
|
games: this.games,
|
|
88
249
|
onClickGame: this.onClickGame.bind(this)
|
|
89
250
|
}))));
|
|
90
251
|
}
|
|
252
|
+
async updateGames() {
|
|
253
|
+
this.games = await fetchGames.bind(this).call();
|
|
254
|
+
}
|
|
255
|
+
onClickGame(launchUrl_raw) {
|
|
256
|
+
this.launchUrl = getUrl(launchUrl_raw, {
|
|
257
|
+
language: this.language,
|
|
258
|
+
_sid: this.session,
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* define for @Style Decorator
|
|
263
|
+
*/
|
|
264
|
+
async componentDidLoad() {
|
|
265
|
+
this.updateGames();
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* define for @Locale and @Style
|
|
269
|
+
*/
|
|
270
|
+
componentShouldUpdate() { }
|
|
271
|
+
/**
|
|
272
|
+
* define for @Locale
|
|
273
|
+
*/
|
|
274
|
+
componentWillLoad() { }
|
|
91
275
|
get host() { return index.getElement(this); }
|
|
276
|
+
static get watchers() { return {
|
|
277
|
+
"endpoint": ["updateGames"],
|
|
278
|
+
"language": ["updateGames"]
|
|
279
|
+
}; }
|
|
92
280
|
};
|
|
281
|
+
__decorate([
|
|
282
|
+
Locale(),
|
|
283
|
+
__metadata("design:type", String)
|
|
284
|
+
], MiniGamesLobby.prototype, "language", void 0);
|
|
285
|
+
__decorate([
|
|
286
|
+
Style(),
|
|
287
|
+
__metadata("design:type", String)
|
|
288
|
+
], MiniGamesLobby.prototype, "clientStyling", void 0);
|
|
289
|
+
__decorate([
|
|
290
|
+
Style(),
|
|
291
|
+
__metadata("design:type", String)
|
|
292
|
+
], MiniGamesLobby.prototype, "clientStylingUrl", void 0);
|
|
93
293
|
MiniGamesLobby.style = miniGamesLobbyCss;
|
|
94
294
|
|
|
95
295
|
exports.mini_games_lobby = MiniGamesLobby;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const index = require('./index-
|
|
3
|
+
const index = require('./index-90b83e7e.js');
|
|
4
4
|
|
|
5
5
|
/*
|
|
6
6
|
Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
@@ -15,5 +15,5 @@ const patchBrowser = () => {
|
|
|
15
15
|
};
|
|
16
16
|
|
|
17
17
|
patchBrowser().then(options => {
|
|
18
|
-
return index.bootstrapLazy([["mini-games-lobby.cjs",[[1,"mini-games-lobby",{"session":[1],"endpoint":[1],"language":[1],"launchUrl":[32],"games":[32]}]]]], options);
|
|
18
|
+
return index.bootstrapLazy([["mini-games-lobby.cjs",[[1,"mini-games-lobby",{"filter":[1],"session":[1],"endpoint":[1],"language":[1],"clientStyling":[1,"client-styling"],"clientStylingUrl":[1,"client-styling-url"],"translationUrl":[1,"translation-url"],"locale":[32],"launchUrl":[32],"games":[32]}]]]], options);
|
|
19
19
|
});
|
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { Component, Element, Prop, State, Watch, h } from '@stencil/core';
|
|
2
3
|
import { fetchGames, getUrl } from '../../utils/fetch';
|
|
3
4
|
import { Games, GameLauncher } from '../../renders';
|
|
5
|
+
import { Locale } from '../../decorators/locale.decorator';
|
|
6
|
+
import { Style } from '../../decorators/style.decorator';
|
|
4
7
|
export class MiniGamesLobby {
|
|
5
8
|
constructor() {
|
|
9
|
+
/**
|
|
10
|
+
* Language of the widget
|
|
11
|
+
*/
|
|
12
|
+
this.language = 'en';
|
|
13
|
+
/**
|
|
14
|
+
* Client custom styling via string
|
|
15
|
+
*/
|
|
16
|
+
this.clientStyling = '';
|
|
17
|
+
/**
|
|
18
|
+
* Client custom styling via url
|
|
19
|
+
*/
|
|
20
|
+
this.clientStylingUrl = '';
|
|
21
|
+
/**
|
|
22
|
+
* translation via url
|
|
23
|
+
*/
|
|
24
|
+
this.translationUrl = '';
|
|
6
25
|
this.launchUrl = undefined;
|
|
7
26
|
this.games = [];
|
|
8
27
|
}
|
|
9
|
-
async componentDidLoad() {
|
|
10
|
-
this.games = await fetchGames(this.endpoint, this.language);
|
|
11
|
-
}
|
|
12
|
-
onClickGame(launchUrl_raw) {
|
|
13
|
-
this.launchUrl = getUrl(launchUrl_raw, {
|
|
14
|
-
language: this.language,
|
|
15
|
-
_sid: this.session,
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
28
|
render() {
|
|
19
29
|
return (h("div", { id: "LobbyContainer" },
|
|
20
30
|
h(GameLauncher, Object.assign({}, {
|
|
@@ -22,11 +32,34 @@ export class MiniGamesLobby {
|
|
|
22
32
|
host: this.host
|
|
23
33
|
})),
|
|
24
34
|
h(Games, Object.assign({}, {
|
|
25
|
-
text:
|
|
35
|
+
text: this.locale.MiniGames,
|
|
26
36
|
games: this.games,
|
|
27
37
|
onClickGame: this.onClickGame.bind(this)
|
|
28
38
|
}))));
|
|
29
39
|
}
|
|
40
|
+
async updateGames() {
|
|
41
|
+
this.games = await fetchGames.bind(this).call();
|
|
42
|
+
}
|
|
43
|
+
onClickGame(launchUrl_raw) {
|
|
44
|
+
this.launchUrl = getUrl(launchUrl_raw, {
|
|
45
|
+
language: this.language,
|
|
46
|
+
_sid: this.session,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* define for @Style Decorator
|
|
51
|
+
*/
|
|
52
|
+
async componentDidLoad() {
|
|
53
|
+
this.updateGames();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* define for @Locale and @Style
|
|
57
|
+
*/
|
|
58
|
+
componentShouldUpdate() { }
|
|
59
|
+
/**
|
|
60
|
+
* define for @Locale
|
|
61
|
+
*/
|
|
62
|
+
componentWillLoad() { }
|
|
30
63
|
static get is() { return "mini-games-lobby"; }
|
|
31
64
|
static get encapsulation() { return "shadow"; }
|
|
32
65
|
static get originalStyleUrls() { return {
|
|
@@ -36,6 +69,23 @@ export class MiniGamesLobby {
|
|
|
36
69
|
"$": ["mini-games-lobby.css"]
|
|
37
70
|
}; }
|
|
38
71
|
static get properties() { return {
|
|
72
|
+
"filter": {
|
|
73
|
+
"type": "string",
|
|
74
|
+
"mutable": false,
|
|
75
|
+
"complexType": {
|
|
76
|
+
"original": "string",
|
|
77
|
+
"resolved": "string",
|
|
78
|
+
"references": {}
|
|
79
|
+
},
|
|
80
|
+
"required": false,
|
|
81
|
+
"optional": false,
|
|
82
|
+
"docs": {
|
|
83
|
+
"tags": [],
|
|
84
|
+
"text": "filter for interface /casino/games"
|
|
85
|
+
},
|
|
86
|
+
"attribute": "filter",
|
|
87
|
+
"reflect": false
|
|
88
|
+
},
|
|
39
89
|
"session": {
|
|
40
90
|
"type": "string",
|
|
41
91
|
"mutable": false,
|
|
@@ -85,12 +135,87 @@ export class MiniGamesLobby {
|
|
|
85
135
|
"text": "Language of the widget"
|
|
86
136
|
},
|
|
87
137
|
"attribute": "language",
|
|
88
|
-
"reflect": false
|
|
138
|
+
"reflect": false,
|
|
139
|
+
"defaultValue": "'en'"
|
|
140
|
+
},
|
|
141
|
+
"clientStyling": {
|
|
142
|
+
"type": "string",
|
|
143
|
+
"mutable": false,
|
|
144
|
+
"complexType": {
|
|
145
|
+
"original": "string",
|
|
146
|
+
"resolved": "string",
|
|
147
|
+
"references": {}
|
|
148
|
+
},
|
|
149
|
+
"required": false,
|
|
150
|
+
"optional": false,
|
|
151
|
+
"docs": {
|
|
152
|
+
"tags": [],
|
|
153
|
+
"text": "Client custom styling via string"
|
|
154
|
+
},
|
|
155
|
+
"attribute": "client-styling",
|
|
156
|
+
"reflect": false,
|
|
157
|
+
"defaultValue": "''"
|
|
158
|
+
},
|
|
159
|
+
"clientStylingUrl": {
|
|
160
|
+
"type": "string",
|
|
161
|
+
"mutable": false,
|
|
162
|
+
"complexType": {
|
|
163
|
+
"original": "string",
|
|
164
|
+
"resolved": "string",
|
|
165
|
+
"references": {}
|
|
166
|
+
},
|
|
167
|
+
"required": false,
|
|
168
|
+
"optional": false,
|
|
169
|
+
"docs": {
|
|
170
|
+
"tags": [],
|
|
171
|
+
"text": "Client custom styling via url"
|
|
172
|
+
},
|
|
173
|
+
"attribute": "client-styling-url",
|
|
174
|
+
"reflect": false,
|
|
175
|
+
"defaultValue": "''"
|
|
176
|
+
},
|
|
177
|
+
"translationUrl": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"mutable": false,
|
|
180
|
+
"complexType": {
|
|
181
|
+
"original": "string",
|
|
182
|
+
"resolved": "string",
|
|
183
|
+
"references": {}
|
|
184
|
+
},
|
|
185
|
+
"required": false,
|
|
186
|
+
"optional": false,
|
|
187
|
+
"docs": {
|
|
188
|
+
"tags": [],
|
|
189
|
+
"text": "translation via url"
|
|
190
|
+
},
|
|
191
|
+
"attribute": "translation-url",
|
|
192
|
+
"reflect": false,
|
|
193
|
+
"defaultValue": "''"
|
|
89
194
|
}
|
|
90
195
|
}; }
|
|
91
196
|
static get states() { return {
|
|
197
|
+
"locale": {},
|
|
92
198
|
"launchUrl": {},
|
|
93
199
|
"games": {}
|
|
94
200
|
}; }
|
|
95
201
|
static get elementRef() { return "host"; }
|
|
202
|
+
static get watchers() { return [{
|
|
203
|
+
"propName": "endpoint",
|
|
204
|
+
"methodName": "updateGames"
|
|
205
|
+
}, {
|
|
206
|
+
"propName": "language",
|
|
207
|
+
"methodName": "updateGames"
|
|
208
|
+
}]; }
|
|
96
209
|
}
|
|
210
|
+
__decorate([
|
|
211
|
+
Locale(),
|
|
212
|
+
__metadata("design:type", String)
|
|
213
|
+
], MiniGamesLobby.prototype, "language", void 0);
|
|
214
|
+
__decorate([
|
|
215
|
+
Style(),
|
|
216
|
+
__metadata("design:type", String)
|
|
217
|
+
], MiniGamesLobby.prototype, "clientStyling", void 0);
|
|
218
|
+
__decorate([
|
|
219
|
+
Style(),
|
|
220
|
+
__metadata("design:type", String)
|
|
221
|
+
], MiniGamesLobby.prototype, "clientStylingUrl", void 0);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const apply = (proto, lifecycle, run) => {
|
|
2
|
+
const existLifeCycle = proto[lifecycle];
|
|
3
|
+
if (!existLifeCycle) {
|
|
4
|
+
throw new Error('lifecycle ' + lifecycle + ' not defined');
|
|
5
|
+
}
|
|
6
|
+
proto[lifecycle] = function (...args) {
|
|
7
|
+
run.bind(this, ...args).call();
|
|
8
|
+
if (existLifeCycle) {
|
|
9
|
+
return existLifeCycle.bind(this, ...args).call();
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { apply } from "./base.decorator";
|
|
2
|
+
import { translation } from "../utils/translation";
|
|
3
|
+
import { fetcher } from "../utils/fetch";
|
|
4
|
+
const getLocale = (_translations, language) => {
|
|
5
|
+
return _translations[language] || _translations['en'];
|
|
6
|
+
};
|
|
7
|
+
function setLocale() {
|
|
8
|
+
this.locale = getLocale(this.translation, this.language);
|
|
9
|
+
}
|
|
10
|
+
async function setLocaleByUrl(isInit = true) {
|
|
11
|
+
if (this.translationUrl) {
|
|
12
|
+
this.translation = await fetcher(this.translationUrl);
|
|
13
|
+
setLocale.bind(this).call();
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
if (!isInit) {
|
|
17
|
+
this.translation = translation;
|
|
18
|
+
setLocale.bind(this).call();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export const Locale = () => {
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
return (proto, prop) => {
|
|
25
|
+
apply(proto, 'componentWillLoad', async function () {
|
|
26
|
+
this.translation = translation;
|
|
27
|
+
setLocale.bind(this).call();
|
|
28
|
+
setLocaleByUrl.bind(this, true).call();
|
|
29
|
+
});
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
apply(proto, 'componentShouldUpdate', async function (newValue, oldValue, key) {
|
|
32
|
+
if (key === 'language') {
|
|
33
|
+
setLocale.bind(this).call();
|
|
34
|
+
}
|
|
35
|
+
if (key === 'translationUrl') {
|
|
36
|
+
setLocaleByUrl.bind(this, false).call();
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { getElement } from "@stencil/core";
|
|
2
|
+
import { apply } from "./base.decorator";
|
|
3
|
+
import { setClientStyling, setClientStylingUrl } from "./style.util";
|
|
4
|
+
const matchStyleProcess = (root, value, key) => {
|
|
5
|
+
switch (key) {
|
|
6
|
+
case 'clientStyling':
|
|
7
|
+
setClientStyling(root, value);
|
|
8
|
+
break;
|
|
9
|
+
case 'clientStylingUrl':
|
|
10
|
+
setClientStylingUrl(root, value);
|
|
11
|
+
break;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
export const Style = () => {
|
|
15
|
+
return (proto, prop) => {
|
|
16
|
+
apply(proto, 'componentDidLoad', function () {
|
|
17
|
+
const root = getElement(this).shadowRoot;
|
|
18
|
+
matchStyleProcess(root, this[prop], prop);
|
|
19
|
+
});
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
apply(proto, 'componentShouldUpdate', function (newValue, oldValue, key) {
|
|
22
|
+
if (key !== prop)
|
|
23
|
+
return;
|
|
24
|
+
const root = getElement(this).shadowRoot;
|
|
25
|
+
matchStyleProcess(root, this[prop], prop);
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
};
|