@things-factory/guild-overlay 10.1.313 → 10.1.315
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-client/components/guild-coin-layer.d.ts +20 -0
- package/dist-client/components/guild-coin-layer.js +403 -0
- package/dist-client/components/guild-overlay-setting-let.d.ts +11 -0
- package/dist-client/components/guild-overlay-setting-let.js +63 -0
- package/dist-client/index.d.ts +2 -0
- package/dist-client/index.js +3 -0
- package/dist-client/overlay-state.d.ts +42 -0
- package/dist-client/overlay-state.js +83 -0
- package/dist-client/setup-guild-overlay.d.ts +3 -0
- package/dist-client/setup-guild-overlay.js +29 -0
- package/dist-server/committed.d.ts +7 -0
- package/dist-server/committed.js +48 -0
- package/dist-server/hub-route.d.ts +49 -2
- package/dist-server/index.d.ts +13 -2
- package/dist-server/index.js +12 -3
- package/dist-server/opportunities.d.ts +23 -0
- package/dist-server/opportunities.js +37 -0
- package/dist-server/overlay-resolver.d.ts +58 -0
- package/dist-server/overlay-resolver.js +274 -0
- package/dist-server/prospect.d.ts +21 -0
- package/dist-server/prospect.js +35 -0
- package/dist-server/pulse.d.ts +36 -0
- package/dist-server/pulse.js +27 -0
- package/package.json +14 -10
- package/translations/en.json +14 -5
- package/translations/es.json +14 -5
- package/translations/ja.json +14 -5
- package/translations/ko.json +14 -5
- package/translations/ms.json +14 -5
- package/translations/zh.json +14 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
declare const GuildCoinLayer_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
3
|
+
export declare class GuildCoinLayer extends GuildCoinLayer_base {
|
|
4
|
+
static styles: import("lit").CSSResult;
|
|
5
|
+
private note?;
|
|
6
|
+
private leaving;
|
|
7
|
+
private queue;
|
|
8
|
+
private playing;
|
|
9
|
+
private timers;
|
|
10
|
+
private onPulse;
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
render(): import("lit-html/directive.js").DirectiveResult<{
|
|
14
|
+
new (_partInfo: import("lit-html/directive.js").PartInfo): import("lit-html/directives/keyed.js").Keyed<import("lit-html").TemplateResult<1>>;
|
|
15
|
+
}>;
|
|
16
|
+
private play;
|
|
17
|
+
/** The small note opens, stays a moment, and closes. */
|
|
18
|
+
private showNote;
|
|
19
|
+
}
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { __decorate, __metadata } from "tslib";
|
|
2
|
+
import { css, html, LitElement, nothing } from 'lit';
|
|
3
|
+
import { customElement, state } from 'lit/decorators.js';
|
|
4
|
+
import { keyed } from 'lit/directives/keyed.js';
|
|
5
|
+
import { i18next, localize } from '@operato/i18n';
|
|
6
|
+
import { overlayState, wordOf } from '../overlay-state.js';
|
|
7
|
+
/*
|
|
8
|
+
* **The coins** (operato-guild design §14-1) - nothing on the screen until one's own work is confirmed. Then a small note
|
|
9
|
+
* opens at the top corner for a moment and closes: a coin drops in, turns twice and bounces; a ring spreads, sparks fly and
|
|
10
|
+
* light sweeps its face - a little game - and the work it was for opens beside it (「주간보고 승인」); a star when someone
|
|
11
|
+
* reused one's work; once a month three coins for the GT that came in.
|
|
12
|
+
*
|
|
13
|
+
* The coins must not become the goal (사용자 2026-11-27): no price before or during the work, no points, no running total,
|
|
14
|
+
* nothing to open. A maturing, a skip or a revert says nothing. It never stands in the way (사용자 2026-11-27): it takes no
|
|
15
|
+
* press, no key and no focus, lays out apart from the page, and moves only by transform and opacity. With 「움직임 줄이기」
|
|
16
|
+
* or the system's reduced motion the note does not move. Only the person sees it.
|
|
17
|
+
*/
|
|
18
|
+
const STEP_MS = 450;
|
|
19
|
+
const NOTE_MS = 4000;
|
|
20
|
+
const ISSUED_MS = 5200;
|
|
21
|
+
const PILE_AFTER = 2;
|
|
22
|
+
const fmt = (value) => (Math.round(value * 100) / 100).toLocaleString();
|
|
23
|
+
let GuildCoinLayer = class GuildCoinLayer extends localize(i18next)(LitElement) {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.leaving = false;
|
|
27
|
+
this.queue = [];
|
|
28
|
+
this.playing = false;
|
|
29
|
+
this.timers = [];
|
|
30
|
+
this.onPulse = (event) => {
|
|
31
|
+
if (!overlayState.choices.show)
|
|
32
|
+
return;
|
|
33
|
+
const pulse = event.detail;
|
|
34
|
+
if (!['verified', 'impact', 'issued'].includes(pulse.kind))
|
|
35
|
+
return;
|
|
36
|
+
this.queue.push(pulse);
|
|
37
|
+
if (!this.playing)
|
|
38
|
+
this.play();
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
static { this.styles = css `
|
|
42
|
+
:host {
|
|
43
|
+
position: fixed;
|
|
44
|
+
inset: 0;
|
|
45
|
+
z-index: 2147483000;
|
|
46
|
+
pointer-events: none;
|
|
47
|
+
overflow: hidden;
|
|
48
|
+
contain: strict;
|
|
49
|
+
font-family: var(--theme-font, inherit);
|
|
50
|
+
}
|
|
51
|
+
/* The note - the coin drops in and turns, then the work's name opens beside it; both go together. */
|
|
52
|
+
.note {
|
|
53
|
+
position: absolute;
|
|
54
|
+
top: 72px;
|
|
55
|
+
right: 16px;
|
|
56
|
+
max-width: calc(100vw - 32px);
|
|
57
|
+
display: flex;
|
|
58
|
+
align-items: center;
|
|
59
|
+
height: 26px;
|
|
60
|
+
padding: 0 6px;
|
|
61
|
+
border-radius: 13px;
|
|
62
|
+
/* Warm like the coin - a soft gold tint and glow, not a gray box. */
|
|
63
|
+
background: color-mix(in srgb, #ffe9a8 38%, var(--md-sys-color-surface, #fff));
|
|
64
|
+
box-shadow:
|
|
65
|
+
0 0 0 1px rgba(240, 196, 76, 0.28),
|
|
66
|
+
0 3px 10px rgba(200, 147, 15, 0.16);
|
|
67
|
+
font-size: 12.5px;
|
|
68
|
+
font-weight: 600;
|
|
69
|
+
letter-spacing: 0.01em;
|
|
70
|
+
perspective: 200px;
|
|
71
|
+
}
|
|
72
|
+
.note-star .text {
|
|
73
|
+
background-image: linear-gradient(100deg, #2f5fc4, #5b8def 55%, #3a6ad0);
|
|
74
|
+
}
|
|
75
|
+
.note-star {
|
|
76
|
+
background: color-mix(in srgb, #d6e4ff 45%, var(--md-sys-color-surface, #fff));
|
|
77
|
+
box-shadow:
|
|
78
|
+
0 0 0 1px rgba(138, 180, 248, 0.3),
|
|
79
|
+
0 3px 10px rgba(91, 141, 239, 0.16);
|
|
80
|
+
}
|
|
81
|
+
/* The room for the name widens to the name's own width, and the name slides in with it - the coin is pushed gently. */
|
|
82
|
+
.reveal {
|
|
83
|
+
display: grid;
|
|
84
|
+
grid-template-columns: 0fr;
|
|
85
|
+
animation: open 0.8s 1.2s cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
|
86
|
+
}
|
|
87
|
+
.clip {
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
min-width: 0;
|
|
90
|
+
}
|
|
91
|
+
.text {
|
|
92
|
+
display: inline-block;
|
|
93
|
+
padding: 3px 4px 3px 7px;
|
|
94
|
+
white-space: nowrap;
|
|
95
|
+
background: linear-gradient(100deg, #a8650a, #d4920f 55%, #b97510);
|
|
96
|
+
-webkit-background-clip: text;
|
|
97
|
+
background-clip: text;
|
|
98
|
+
color: transparent;
|
|
99
|
+
opacity: 0;
|
|
100
|
+
transform: translateX(-10px);
|
|
101
|
+
animation: slide 0.7s 1.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
|
|
102
|
+
}
|
|
103
|
+
.note.leaving {
|
|
104
|
+
opacity: 0;
|
|
105
|
+
transition: opacity 0.5s ease;
|
|
106
|
+
}
|
|
107
|
+
.coin {
|
|
108
|
+
display: inline-block;
|
|
109
|
+
flex: none;
|
|
110
|
+
width: 16px;
|
|
111
|
+
height: 16px;
|
|
112
|
+
border-radius: 50%;
|
|
113
|
+
background: radial-gradient(circle at 35% 30%, #fff6c8 0, #f0c44c 45%, #c8930f 100%);
|
|
114
|
+
position: relative;
|
|
115
|
+
overflow: hidden;
|
|
116
|
+
box-shadow: inset 0 0 0 1px rgba(150, 100, 0, 0.35);
|
|
117
|
+
will-change: transform, opacity;
|
|
118
|
+
animation: drop 1.3s cubic-bezier(0.25, 0.9, 0.35, 1) both;
|
|
119
|
+
}
|
|
120
|
+
/* A streak of light across the face once it has landed. */
|
|
121
|
+
.coin::after {
|
|
122
|
+
content: '';
|
|
123
|
+
position: absolute;
|
|
124
|
+
inset: -2px;
|
|
125
|
+
background: linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, 0.95) 50%, transparent 65%);
|
|
126
|
+
transform: translateX(-120%);
|
|
127
|
+
animation: shine 0.6s 1.3s ease-in-out forwards;
|
|
128
|
+
}
|
|
129
|
+
@keyframes shine {
|
|
130
|
+
to {
|
|
131
|
+
transform: translateX(120%);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
.star {
|
|
135
|
+
display: inline-block;
|
|
136
|
+
flex: none;
|
|
137
|
+
width: 16px;
|
|
138
|
+
text-align: center;
|
|
139
|
+
font-size: 14px;
|
|
140
|
+
line-height: 16px;
|
|
141
|
+
color: #5b8def;
|
|
142
|
+
animation: drop 1.3s cubic-bezier(0.25, 0.9, 0.35, 1) both;
|
|
143
|
+
}
|
|
144
|
+
@keyframes drop {
|
|
145
|
+
0% {
|
|
146
|
+
opacity: 0;
|
|
147
|
+
transform: translateY(-40px) rotateY(0deg);
|
|
148
|
+
}
|
|
149
|
+
20% {
|
|
150
|
+
opacity: 1;
|
|
151
|
+
}
|
|
152
|
+
68% {
|
|
153
|
+
transform: translateY(2px) rotateY(620deg) scale(1.08, 0.9);
|
|
154
|
+
}
|
|
155
|
+
84% {
|
|
156
|
+
transform: translateY(-3px) rotateY(700deg) scale(0.97, 1.04);
|
|
157
|
+
}
|
|
158
|
+
100% {
|
|
159
|
+
opacity: 1;
|
|
160
|
+
transform: translateY(0) rotateY(720deg);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/* Where the coin lands - a ring spreads and sparks fly, a pickup as in a game. */
|
|
164
|
+
.landing {
|
|
165
|
+
position: relative;
|
|
166
|
+
display: inline-flex;
|
|
167
|
+
flex: none;
|
|
168
|
+
}
|
|
169
|
+
.landing::before {
|
|
170
|
+
content: '';
|
|
171
|
+
position: absolute;
|
|
172
|
+
left: 50%;
|
|
173
|
+
top: 50%;
|
|
174
|
+
width: 16px;
|
|
175
|
+
height: 16px;
|
|
176
|
+
margin: -8px;
|
|
177
|
+
border-radius: 50%;
|
|
178
|
+
border: 2px solid rgba(240, 196, 76, 0.85);
|
|
179
|
+
opacity: 0;
|
|
180
|
+
will-change: transform, opacity;
|
|
181
|
+
animation: ring 0.7s 0.9s ease-out forwards;
|
|
182
|
+
}
|
|
183
|
+
.landing-star::before {
|
|
184
|
+
border-color: rgba(138, 180, 248, 0.85);
|
|
185
|
+
}
|
|
186
|
+
@keyframes ring {
|
|
187
|
+
0% {
|
|
188
|
+
opacity: 0.9;
|
|
189
|
+
transform: scale(0.6);
|
|
190
|
+
}
|
|
191
|
+
100% {
|
|
192
|
+
opacity: 0;
|
|
193
|
+
transform: scale(2.4);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
.spark {
|
|
197
|
+
position: absolute;
|
|
198
|
+
left: 50%;
|
|
199
|
+
top: 50%;
|
|
200
|
+
width: 3px;
|
|
201
|
+
height: 3px;
|
|
202
|
+
margin: -1.5px;
|
|
203
|
+
border-radius: 50%;
|
|
204
|
+
background: #f0c44c;
|
|
205
|
+
opacity: 0;
|
|
206
|
+
will-change: transform, opacity;
|
|
207
|
+
animation: spark 0.7s 0.9s ease-out forwards;
|
|
208
|
+
}
|
|
209
|
+
.spark:nth-of-type(even) {
|
|
210
|
+
background: #fffbe8;
|
|
211
|
+
box-shadow: 0 0 2px rgba(240, 196, 76, 0.9);
|
|
212
|
+
}
|
|
213
|
+
.landing-star .spark:nth-of-type(odd) {
|
|
214
|
+
background: #8ab4f8;
|
|
215
|
+
}
|
|
216
|
+
.spark:nth-of-type(1) {
|
|
217
|
+
--to: translate(-14px, -11px);
|
|
218
|
+
}
|
|
219
|
+
.spark:nth-of-type(2) {
|
|
220
|
+
--to: translate(14px, -12px);
|
|
221
|
+
}
|
|
222
|
+
.spark:nth-of-type(3) {
|
|
223
|
+
--to: translate(0, -18px);
|
|
224
|
+
}
|
|
225
|
+
.spark:nth-of-type(4) {
|
|
226
|
+
--to: translate(-12px, 9px);
|
|
227
|
+
}
|
|
228
|
+
.spark:nth-of-type(5) {
|
|
229
|
+
--to: translate(13px, 8px);
|
|
230
|
+
}
|
|
231
|
+
.spark:nth-of-type(6) {
|
|
232
|
+
--to: translate(-18px, -1px);
|
|
233
|
+
}
|
|
234
|
+
@keyframes spark {
|
|
235
|
+
0% {
|
|
236
|
+
opacity: 1;
|
|
237
|
+
transform: none;
|
|
238
|
+
}
|
|
239
|
+
100% {
|
|
240
|
+
opacity: 0;
|
|
241
|
+
transform: var(--to) scale(0.4);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
.purse .coin + .coin {
|
|
245
|
+
margin-left: -7px;
|
|
246
|
+
}
|
|
247
|
+
.purse .coin:nth-child(2) {
|
|
248
|
+
animation-delay: 0.2s;
|
|
249
|
+
}
|
|
250
|
+
.purse .coin:nth-child(3) {
|
|
251
|
+
animation-delay: 0.4s;
|
|
252
|
+
}
|
|
253
|
+
.purse .coin:nth-child(2)::after {
|
|
254
|
+
animation-delay: 1.5s;
|
|
255
|
+
}
|
|
256
|
+
.purse .coin:nth-child(3)::after {
|
|
257
|
+
animation-delay: 1.7s;
|
|
258
|
+
}
|
|
259
|
+
@keyframes open {
|
|
260
|
+
to {
|
|
261
|
+
grid-template-columns: 1fr;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
@keyframes slide {
|
|
265
|
+
to {
|
|
266
|
+
opacity: 1;
|
|
267
|
+
transform: none;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
:host(.still) .coin,
|
|
271
|
+
:host(.still) .star,
|
|
272
|
+
:host(.still) .reveal,
|
|
273
|
+
:host(.still) .text {
|
|
274
|
+
animation: none;
|
|
275
|
+
}
|
|
276
|
+
:host(.still) .spark,
|
|
277
|
+
:host(.still) .landing::before,
|
|
278
|
+
:host(.still) .coin::after {
|
|
279
|
+
display: none;
|
|
280
|
+
}
|
|
281
|
+
:host(.still) .reveal {
|
|
282
|
+
grid-template-columns: 1fr;
|
|
283
|
+
}
|
|
284
|
+
:host(.still) .text {
|
|
285
|
+
opacity: 1;
|
|
286
|
+
transform: none;
|
|
287
|
+
}
|
|
288
|
+
@media (prefers-reduced-motion: reduce) {
|
|
289
|
+
.coin,
|
|
290
|
+
.star,
|
|
291
|
+
.reveal,
|
|
292
|
+
.text {
|
|
293
|
+
animation: none;
|
|
294
|
+
}
|
|
295
|
+
.spark,
|
|
296
|
+
.landing::before,
|
|
297
|
+
.coin::after {
|
|
298
|
+
display: none;
|
|
299
|
+
}
|
|
300
|
+
.reveal {
|
|
301
|
+
grid-template-columns: 1fr;
|
|
302
|
+
}
|
|
303
|
+
.text {
|
|
304
|
+
opacity: 1;
|
|
305
|
+
transform: none;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
`; }
|
|
309
|
+
connectedCallback() {
|
|
310
|
+
super.connectedCallback();
|
|
311
|
+
overlayState.addEventListener('pulse', this.onPulse);
|
|
312
|
+
}
|
|
313
|
+
disconnectedCallback() {
|
|
314
|
+
overlayState.removeEventListener('pulse', this.onPulse);
|
|
315
|
+
this.timers.forEach(clearTimeout);
|
|
316
|
+
super.disconnectedCallback();
|
|
317
|
+
}
|
|
318
|
+
render() {
|
|
319
|
+
const note = this.note;
|
|
320
|
+
if (!note)
|
|
321
|
+
return nothing;
|
|
322
|
+
const sparks = html `<i class="spark"></i><i class="spark"></i><i class="spark"></i><i class="spark"></i><i class="spark"></i><i class="spark"></i>`;
|
|
323
|
+
const mark = note.mark === 'star'
|
|
324
|
+
? html `<span class="star">✦</span>`
|
|
325
|
+
: note.mark === 'purse'
|
|
326
|
+
? html `<span class="purse landing"><span class="coin"></span><span class="coin"></span><span class="coin"></span></span>`
|
|
327
|
+
: html `<span class="coin"></span>`;
|
|
328
|
+
/* A new note is a new element - its coin drops again. */
|
|
329
|
+
return keyed(note.key, html `<div class="note note-${note.mark} ${this.leaving ? 'leaving' : ''}" role="status" aria-live="polite">
|
|
330
|
+
<span class="landing landing-${note.mark}" aria-hidden="true">${mark}${sparks}</span>
|
|
331
|
+
<span class="reveal"><span class="clip"><span class="text">${note.text}</span></span></span>
|
|
332
|
+
</div>`);
|
|
333
|
+
}
|
|
334
|
+
async play() {
|
|
335
|
+
this.playing = true;
|
|
336
|
+
this.classList.toggle('still', overlayState.choices.reduceMotion || !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches);
|
|
337
|
+
while (this.queue.length) {
|
|
338
|
+
/* Several confirmed at once - one note: the first work and how many more. */
|
|
339
|
+
const confirmed = this.queue.filter(one => one.kind === 'verified');
|
|
340
|
+
if (confirmed.length > PILE_AFTER) {
|
|
341
|
+
this.queue = this.queue.filter(one => one.kind !== 'verified');
|
|
342
|
+
tick();
|
|
343
|
+
this.showNote('coin', i18next.t('text.guild-overlay-confirmed-more', { label: labelOf(confirmed[0]), count: confirmed.length - 1 }), NOTE_MS);
|
|
344
|
+
await new Promise(resolve => setTimeout(resolve, NOTE_MS));
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
const pulse = this.queue.shift();
|
|
348
|
+
tick();
|
|
349
|
+
if (pulse.kind === 'issued')
|
|
350
|
+
this.showNote('purse', i18next.t('text.guild-overlay-issued', { gt: fmt(pulse.gt ?? 0) }), ISSUED_MS);
|
|
351
|
+
else if (pulse.kind === 'impact')
|
|
352
|
+
this.showNote('star', i18next.t('text.guild-overlay-impact'), NOTE_MS);
|
|
353
|
+
else
|
|
354
|
+
this.showNote('coin', labelOf(pulse), NOTE_MS);
|
|
355
|
+
await new Promise(resolve => setTimeout(resolve, STEP_MS));
|
|
356
|
+
}
|
|
357
|
+
this.playing = false;
|
|
358
|
+
}
|
|
359
|
+
/** The small note opens, stays a moment, and closes. */
|
|
360
|
+
showNote(mark, text, ms) {
|
|
361
|
+
this.timers.forEach(clearTimeout);
|
|
362
|
+
this.leaving = false;
|
|
363
|
+
this.note = { mark, text, key: Date.now() };
|
|
364
|
+
this.timers.push(setTimeout(() => (this.leaving = true), ms));
|
|
365
|
+
this.timers.push(setTimeout(() => (this.note = undefined), ms + 500));
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
__decorate([
|
|
369
|
+
state(),
|
|
370
|
+
__metadata("design:type", Object)
|
|
371
|
+
], GuildCoinLayer.prototype, "note", void 0);
|
|
372
|
+
__decorate([
|
|
373
|
+
state(),
|
|
374
|
+
__metadata("design:type", Object)
|
|
375
|
+
], GuildCoinLayer.prototype, "leaving", void 0);
|
|
376
|
+
GuildCoinLayer = __decorate([
|
|
377
|
+
customElement('guild-coin-layer')
|
|
378
|
+
], GuildCoinLayer);
|
|
379
|
+
export { GuildCoinLayer };
|
|
380
|
+
const labelOf = (pulse) => wordOf(pulse.label) || pulse.title || i18next.t('text.guild-overlay-confirmed');
|
|
381
|
+
/* A soft tick, when one turned the sound on - off by default (design §14-1). */
|
|
382
|
+
let audio;
|
|
383
|
+
function tick() {
|
|
384
|
+
if (!overlayState.choices.sound)
|
|
385
|
+
return;
|
|
386
|
+
const hz = 820;
|
|
387
|
+
try {
|
|
388
|
+
audio ??= new AudioContext();
|
|
389
|
+
const tone = audio.createOscillator();
|
|
390
|
+
const gain = audio.createGain();
|
|
391
|
+
tone.type = 'sine';
|
|
392
|
+
tone.frequency.value = hz;
|
|
393
|
+
gain.gain.setValueAtTime(0.04, audio.currentTime);
|
|
394
|
+
gain.gain.exponentialRampToValueAtTime(0.0001, audio.currentTime + 0.12);
|
|
395
|
+
tone.connect(gain).connect(audio.destination);
|
|
396
|
+
tone.start();
|
|
397
|
+
tone.stop(audio.currentTime + 0.14);
|
|
398
|
+
}
|
|
399
|
+
catch {
|
|
400
|
+
/* No sound on this device. */
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
//# sourceMappingURL=guild-coin-layer.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '@material/web/switch/switch.js';
|
|
2
|
+
import { LitElement } from 'lit';
|
|
3
|
+
declare const GuildOverlaySettingLet_base: (new (...args: any[]) => LitElement) & typeof LitElement;
|
|
4
|
+
export declare class GuildOverlaySettingLet extends GuildOverlaySettingLet_base {
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
private refresh;
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
disconnectedCallback(): void;
|
|
9
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import '@material/web/switch/switch.js';
|
|
3
|
+
import { css, html, LitElement } from 'lit';
|
|
4
|
+
import { customElement } from 'lit/decorators.js';
|
|
5
|
+
import { i18next, localize } from '@operato/i18n';
|
|
6
|
+
import { overlayState } from '../overlay-state.js';
|
|
7
|
+
/*
|
|
8
|
+
* Settings › the guild game on this device (operato-guild design §14-1): drawn or not, without flying coins, with sound.
|
|
9
|
+
* Kept on the device - the coins and the balance are the person's alone either way.
|
|
10
|
+
*/
|
|
11
|
+
let GuildOverlaySettingLet = class GuildOverlaySettingLet extends localize(i18next)(LitElement) {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.refresh = () => this.requestUpdate();
|
|
15
|
+
}
|
|
16
|
+
static { this.styles = css `
|
|
17
|
+
div[slot='content'] {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: var(--spacing-medium, 8px);
|
|
21
|
+
}
|
|
22
|
+
label {
|
|
23
|
+
display: flex;
|
|
24
|
+
gap: 10px;
|
|
25
|
+
align-items: center;
|
|
26
|
+
font: var(--label-font);
|
|
27
|
+
color: var(--md-sys-color-on-surface);
|
|
28
|
+
}
|
|
29
|
+
.note {
|
|
30
|
+
margin: 0;
|
|
31
|
+
font-size: var(--ui-t-small, 12px);
|
|
32
|
+
color: var(--ui-muted, var(--md-sys-color-on-surface-variant));
|
|
33
|
+
}
|
|
34
|
+
`; }
|
|
35
|
+
connectedCallback() {
|
|
36
|
+
super.connectedCallback();
|
|
37
|
+
overlayState.addEventListener('choices', this.refresh);
|
|
38
|
+
}
|
|
39
|
+
disconnectedCallback() {
|
|
40
|
+
overlayState.removeEventListener('choices', this.refresh);
|
|
41
|
+
super.disconnectedCallback();
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
const choices = overlayState.choices;
|
|
45
|
+
const toggle = (key, label) => html `<label>
|
|
46
|
+
<md-switch ?selected=${choices[key]} @change=${(event) => overlayState.choose({ [key]: event.target.selected })}></md-switch>
|
|
47
|
+
${label}
|
|
48
|
+
</label>`;
|
|
49
|
+
return html `<setting-let>
|
|
50
|
+
<span slot="title">${i18next.t('title.guild-overlay-setting')}</span>
|
|
51
|
+
<div slot="content">
|
|
52
|
+
${toggle('show', i18next.t('label.guild-overlay-show'))} ${toggle('reduceMotion', i18next.t('label.guild-overlay-reduce-motion'))}
|
|
53
|
+
${toggle('sound', i18next.t('label.guild-overlay-sound'))}
|
|
54
|
+
<p class="note">${i18next.t('text.guild-overlay-setting-note')}</p>
|
|
55
|
+
</div>
|
|
56
|
+
</setting-let>`;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
GuildOverlaySettingLet = __decorate([
|
|
60
|
+
customElement('guild-overlay-setting-let')
|
|
61
|
+
], GuildOverlaySettingLet);
|
|
62
|
+
export { GuildOverlaySettingLet };
|
|
63
|
+
//# sourceMappingURL=guild-overlay-setting-let.js.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export type Label = string | Record<string, string> | null | undefined;
|
|
2
|
+
export interface Overlay {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface Pulse {
|
|
6
|
+
kind: 'prospect' | 'verified' | 'matured' | 'issued' | 'impact' | 'skipped' | 'voided';
|
|
7
|
+
contributionKind?: string;
|
|
8
|
+
label?: Label;
|
|
9
|
+
title?: string;
|
|
10
|
+
path?: string;
|
|
11
|
+
gp?: number;
|
|
12
|
+
gpLow?: number;
|
|
13
|
+
gpHigh?: number;
|
|
14
|
+
gt?: number;
|
|
15
|
+
count?: number;
|
|
16
|
+
reason?: string;
|
|
17
|
+
hint?: Label;
|
|
18
|
+
at: string;
|
|
19
|
+
}
|
|
20
|
+
export interface OverlayChoices {
|
|
21
|
+
/** Draw the game at all. */
|
|
22
|
+
show: boolean;
|
|
23
|
+
/** No moving coins - the small tally only. */
|
|
24
|
+
reduceMotion: boolean;
|
|
25
|
+
/** A soft tick when a coin comes. Off by default. */
|
|
26
|
+
sound: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** A label in the reader's language - a plain string is every language's. */
|
|
29
|
+
export declare function wordOf(label: Label): string;
|
|
30
|
+
declare class OverlayState extends EventTarget {
|
|
31
|
+
overlay: Overlay;
|
|
32
|
+
choices: OverlayChoices;
|
|
33
|
+
private subscription?;
|
|
34
|
+
load(): Promise<Overlay>;
|
|
35
|
+
loadChoices(): Promise<OverlayChoices>;
|
|
36
|
+
choose(change: Partial<OverlayChoices>): Promise<void>;
|
|
37
|
+
/** Listen for this person's coins. A pulse that moves money reloads the overlay read. */
|
|
38
|
+
listen(): Promise<void>;
|
|
39
|
+
stop(): void;
|
|
40
|
+
}
|
|
41
|
+
export declare const overlayState: OverlayState;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import gql from 'graphql-tag';
|
|
2
|
+
import { client, subscribe } from '@operato/graphql';
|
|
3
|
+
import { i18next } from '@operato/i18n';
|
|
4
|
+
import { clientSettingStore } from '@operato/shell';
|
|
5
|
+
const CHOICES_KEY = 'guild-overlay';
|
|
6
|
+
const DEFAULT_CHOICES = { show: true, reduceMotion: false, sound: false };
|
|
7
|
+
/** A label in the reader's language - a plain string is every language's. */
|
|
8
|
+
export function wordOf(label) {
|
|
9
|
+
if (!label)
|
|
10
|
+
return '';
|
|
11
|
+
if (typeof label === 'string')
|
|
12
|
+
return label;
|
|
13
|
+
const language = (i18next.language || 'en').slice(0, 2);
|
|
14
|
+
return label[language] ?? label.en ?? label.ko ?? Object.values(label)[0] ?? '';
|
|
15
|
+
}
|
|
16
|
+
class OverlayState extends EventTarget {
|
|
17
|
+
constructor() {
|
|
18
|
+
super(...arguments);
|
|
19
|
+
this.overlay = { enabled: false };
|
|
20
|
+
this.choices = { ...DEFAULT_CHOICES };
|
|
21
|
+
}
|
|
22
|
+
async load() {
|
|
23
|
+
try {
|
|
24
|
+
const response = await client.query({
|
|
25
|
+
query: gql `
|
|
26
|
+
query {
|
|
27
|
+
guildOverlay {
|
|
28
|
+
enabled
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
`,
|
|
32
|
+
fetchPolicy: 'network-only'
|
|
33
|
+
});
|
|
34
|
+
this.overlay = response.data?.guildOverlay ?? { enabled: false };
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
/* No guild right, or no guild here - the overlay draws nothing. */
|
|
38
|
+
this.overlay = { enabled: false };
|
|
39
|
+
}
|
|
40
|
+
this.dispatchEvent(new Event('overlay'));
|
|
41
|
+
return this.overlay;
|
|
42
|
+
}
|
|
43
|
+
async loadChoices() {
|
|
44
|
+
try {
|
|
45
|
+
this.choices = { ...DEFAULT_CHOICES, ...((await clientSettingStore.get(CHOICES_KEY))?.value ?? {}) };
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
this.choices = { ...DEFAULT_CHOICES };
|
|
49
|
+
}
|
|
50
|
+
this.dispatchEvent(new Event('choices'));
|
|
51
|
+
return this.choices;
|
|
52
|
+
}
|
|
53
|
+
async choose(change) {
|
|
54
|
+
this.choices = { ...this.choices, ...change };
|
|
55
|
+
await clientSettingStore.put({ key: CHOICES_KEY, value: this.choices });
|
|
56
|
+
this.dispatchEvent(new Event('choices'));
|
|
57
|
+
}
|
|
58
|
+
/** Listen for this person's coins. A pulse that moves money reloads the overlay read. */
|
|
59
|
+
async listen() {
|
|
60
|
+
if (this.subscription)
|
|
61
|
+
return;
|
|
62
|
+
this.subscription = await subscribe({
|
|
63
|
+
query: gql `
|
|
64
|
+
subscription {
|
|
65
|
+
guildPulse { kind contributionKind label title path gp gpLow gpHigh gt count reason hint at }
|
|
66
|
+
}
|
|
67
|
+
`
|
|
68
|
+
}, {
|
|
69
|
+
next: ({ data }) => {
|
|
70
|
+
const pulse = data?.guildPulse;
|
|
71
|
+
if (!pulse)
|
|
72
|
+
return;
|
|
73
|
+
this.dispatchEvent(new CustomEvent('pulse', { detail: pulse }));
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
stop() {
|
|
78
|
+
this.subscription?.unsubscribe();
|
|
79
|
+
this.subscription = undefined;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
export const overlayState = new OverlayState();
|
|
83
|
+
//# sourceMappingURL=overlay-state.js.map
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import './components/guild-coin-layer.js';
|
|
2
|
+
import './components/guild-overlay-setting-let.js';
|
|
3
|
+
import { html } from 'lit';
|
|
4
|
+
import { store } from '@operato/shell';
|
|
5
|
+
import { ADD_SETTING } from '@things-factory/setting-base/dist-client/index.js';
|
|
6
|
+
import { overlayState } from './overlay-state.js';
|
|
7
|
+
/*
|
|
8
|
+
* **One line in a product's client boot** (operato-guild design §14-1) - `await setupGuildOverlay()` once the person is
|
|
9
|
+
* known. It reads `Guild::enabled` through the person's own overlay read; off, or no guild right, nothing is attached and
|
|
10
|
+
* the product's screens are as they were. On: a layer that shows nothing until one's own work earns, and the setting.
|
|
11
|
+
*/
|
|
12
|
+
let attached = false;
|
|
13
|
+
export async function setupGuildOverlay() {
|
|
14
|
+
await overlayState.loadChoices();
|
|
15
|
+
const overlay = await overlayState.load();
|
|
16
|
+
if (!overlay.enabled)
|
|
17
|
+
return false;
|
|
18
|
+
if (attached)
|
|
19
|
+
return true;
|
|
20
|
+
attached = true;
|
|
21
|
+
store.dispatch({
|
|
22
|
+
type: ADD_SETTING,
|
|
23
|
+
setting: { seq: 40, template: html `<guild-overlay-setting-let></guild-overlay-setting-let>` }
|
|
24
|
+
});
|
|
25
|
+
document.body.appendChild(document.createElement('guild-coin-layer'));
|
|
26
|
+
await overlayState.listen();
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=setup-guild-overlay.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type EntityManager, type EntitySubscriberInterface, type TransactionCommitEvent, type TransactionRollbackEvent } from 'typeorm';
|
|
2
|
+
/** Run `job` when `tx` commits - at once when it is not in a transaction. */
|
|
3
|
+
export declare function afterCommitOf(tx: EntityManager | undefined, job: () => unknown): void;
|
|
4
|
+
export declare class GuildCommitSubscriber implements EntitySubscriberInterface {
|
|
5
|
+
afterTransactionCommit(event: TransactionCommitEvent): void;
|
|
6
|
+
afterTransactionRollback(event: TransactionRollbackEvent): void;
|
|
7
|
+
}
|