@things-factory/figure-library 10.1.314 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/figure-library",
3
- "version": "10.1.314",
3
+ "version": "10.1.315",
4
4
  "main": "dist-server/index.js",
5
5
  "browser": "dist-client/index.js",
6
6
  "files": [
@@ -41,7 +41,7 @@
41
41
  "test": "node --import ./test/resolve-ts-siblings.mjs --test test/*.test.ts"
42
42
  },
43
43
  "dependencies": {
44
- "@hatiolab/figure-model": "^0.12.31",
44
+ "@hatiolab/figure-model": "^0.12.32",
45
45
  "@hatiolab/things-scene": "^10.1.123",
46
46
  "@material/web": "^2.0.0",
47
47
  "@operato/data-grist": "^10.29.69",
@@ -59,7 +59,7 @@
59
59
  "@things-factory/auth-base": "^10.1.314",
60
60
  "@things-factory/board-service": "^10.1.314",
61
61
  "@things-factory/env": "^10.1.298",
62
- "@things-factory/figure-viewer": "^10.1.314",
62
+ "@things-factory/figure-viewer": "^10.1.315",
63
63
  "@things-factory/setting-base": "^10.1.314",
64
64
  "@things-factory/shell": "^10.1.304",
65
65
  "graphql-scalars": "^1.22.4",
@@ -69,5 +69,5 @@
69
69
  "koa-router": "^7.4.0",
70
70
  "lit": "^3.1.2"
71
71
  },
72
- "gitHead": "8d74df0a0618131ff17309638a6aa0affbd4c77d"
72
+ "gitHead": "69d8495a54f4c1f91276b66cb50fe7d7cdda8f3f"
73
73
  }
@@ -1,31 +0,0 @@
1
- import '@material/web/button/text-button.js';
2
- import '@material/web/button/filled-button.js';
3
- import '@operato/popup/ox-popup-actions.js';
4
- import './figure-import-result.js';
5
- import '../settings/figure-source-setting-let.js';
6
- import { LitElement } from 'lit';
7
- declare const FigureSourceInstall_base: (new (...args: any[]) => LitElement) & typeof LitElement;
8
- export declare class FigureSourceInstall extends FigureSourceInstall_base {
9
- static styles: import("lit").CSSResult[];
10
- private search;
11
- private items;
12
- private total;
13
- private reading;
14
- private installing;
15
- private failure;
16
- private chosen;
17
- private result?;
18
- /** The connection, when this window holds it (setFigureSourceOnLibrary). */
19
- private source?;
20
- private connecting;
21
- connectedCallback(): void;
22
- private get connected();
23
- private readSource;
24
- private renderConnection;
25
- render(): import("lit-html").TemplateResult<1>;
26
- private renderItem;
27
- private choose;
28
- private read;
29
- private install;
30
- }
31
- export {};
@@ -1,393 +0,0 @@
1
- import { __decorate, __metadata } from "tslib";
2
- import '@material/web/button/text-button.js';
3
- import '@material/web/button/filled-button.js';
4
- import '@operato/popup/ox-popup-actions.js';
5
- import './figure-import-result.js';
6
- import '../settings/figure-source-setting-let.js';
7
- import gql from 'graphql-tag';
8
- import { css, html, LitElement, nothing } from 'lit';
9
- import { customElement, state } from 'lit/decorators.js';
10
- import { client } from '@operato/graphql';
11
- import { i18next, localize } from '@operato/i18n';
12
- import { CommonPopupStyles, FormFieldStyles, PopupBodyStyles, PopupFieldStyles } from '@operato/styles';
13
- import { announceLibraryChanged } from '../figure-library-changed.js';
14
- import { figureSourceOnLibrary, figureSourceThumbnailUrl } from '../figure-library-file.js';
15
- const SOURCE = gql `
16
- query {
17
- figureLibrarySource {
18
- url
19
- domain
20
- tokenSet
21
- }
22
- }
23
- `;
24
- /** How many figures one read brings; 「더 보기」 reads the next. */
25
- const PAGE = 50;
26
- const CATALOG = gql `
27
- query ($search: String, $pagination: Pagination) {
28
- figureSourceCatalog(search: $search, pagination: $pagination) {
29
- items {
30
- figureId
31
- fullName
32
- ref
33
- version
34
- name
35
- names
36
- category
37
- deprecated
38
- thumbnailHash
39
- installedVersion
40
- status
41
- }
42
- total
43
- }
44
- }
45
- `;
46
- const INSTALL = gql `
47
- mutation ($refs: [String!]!) {
48
- installFigures(refs: $refs) {
49
- problems {
50
- code
51
- path
52
- }
53
- outcomes {
54
- ref
55
- outcome
56
- code
57
- differs
58
- archived
59
- }
60
- }
61
- }
62
- `;
63
- /** The status chip of a row: its words and how loud it is. */
64
- const STATUS_TONE = {
65
- 'not-installed': 'plain',
66
- installed: 'muted',
67
- newer: 'warn',
68
- archived: 'muted',
69
- 'format-unsupported': 'crit'
70
- };
71
- /*
72
- * Installing figures straight from the figure server set in Settings (ADR-0114 amendment 2026-11-14). The board server
73
- * reads the figure server's catalog and installs the chosen releases through the same import a package file goes
74
- * through, so the result reads as a file import's does. The browser never talks to the figure server: the catalog, the
75
- * pictures and the install are this server's doors.
76
- *
77
- * In an app with no Settings screen (`setFigureSourceOnLibrary`) the window also holds the connection: the connection
78
- * card while none is set, and the server it installs from with 「연결 바꾸기」 once it is.
79
- */
80
- let FigureSourceInstall = class FigureSourceInstall extends localize(i18next)(LitElement) {
81
- constructor() {
82
- super(...arguments);
83
- this.search = '';
84
- this.items = [];
85
- this.total = 0;
86
- this.reading = false;
87
- this.installing = false;
88
- this.failure = '';
89
- this.chosen = new Set();
90
- this.connecting = false;
91
- }
92
- static { this.styles = [
93
- CommonPopupStyles,
94
- PopupBodyStyles,
95
- FormFieldStyles,
96
- PopupFieldStyles,
97
- css `
98
- ul[figures] {
99
- list-style: none;
100
- margin: 0;
101
- padding: 0;
102
- display: flex;
103
- flex-direction: column;
104
- }
105
- ul[figures] li {
106
- display: grid;
107
- grid-template-columns: auto 48px minmax(0, 1fr) auto;
108
- align-items: center;
109
- gap: var(--spacing-medium, 8px);
110
- padding: var(--spacing-small, 4px) 0;
111
- border-bottom: 1px solid var(--ui-line-soft, var(--md-sys-color-surface-container));
112
- }
113
- [thumb] {
114
- width: 48px;
115
- height: 36px;
116
- object-fit: contain;
117
- border-radius: var(--border-radius, 4px);
118
- background: var(--ui-line-soft, var(--md-sys-color-surface-container));
119
- }
120
- [title] {
121
- display: flex;
122
- flex-direction: column;
123
- min-width: 0;
124
- }
125
- [title] strong,
126
- [title] small {
127
- overflow: hidden;
128
- text-overflow: ellipsis;
129
- white-space: nowrap;
130
- }
131
- [title] small {
132
- color: var(--ui-muted);
133
- font-family: var(--ui-mono, monospace);
134
- font-size: var(--ui-t-small, 11.5px);
135
- }
136
- [chips] {
137
- display: flex;
138
- gap: var(--spacing-small, 4px);
139
- justify-content: flex-end;
140
- flex-wrap: wrap;
141
- }
142
- [chip] {
143
- padding: 1px 6px;
144
- border-radius: 999px;
145
- font-size: var(--ui-t-small, 11.5px);
146
- white-space: nowrap;
147
- border: 1px solid currentColor;
148
- }
149
- [chip='plain'] {
150
- color: var(--ui-ink, var(--md-sys-color-on-surface));
151
- }
152
- [chip='muted'] {
153
- color: var(--ui-muted);
154
- }
155
- [chip='warn'] {
156
- color: var(--ui-warn, #b26b00);
157
- }
158
- [chip='crit'] {
159
- color: var(--ui-crit, var(--md-sys-color-error));
160
- }
161
- [refused] {
162
- color: var(--ui-crit, var(--md-sys-color-error));
163
- margin: 0;
164
- }
165
- [more] {
166
- align-self: center;
167
- }
168
- [connection] {
169
- display: flex;
170
- align-items: center;
171
- gap: var(--spacing-small, 4px);
172
- color: var(--ui-muted);
173
- font-size: var(--ui-t-small, 11.5px);
174
- }
175
- [connection] md-text-button {
176
- margin-left: auto;
177
- }
178
- `
179
- ]; }
180
- connectedCallback() {
181
- super.connectedCallback();
182
- figureSourceOnLibrary() ? this.readSource() : this.read(true);
183
- }
184
- get connected() {
185
- return !!(this.source?.url && this.source?.domain && this.source?.tokenSet);
186
- }
187
- /* The connection this window holds: the catalog is read once it is complete. */
188
- async readSource() {
189
- try {
190
- const response = await client.query({ query: SOURCE, fetchPolicy: 'no-cache' });
191
- this.source = response.data?.figureLibrarySource ?? { tokenSet: false };
192
- }
193
- catch {
194
- this.source = { tokenSet: false };
195
- }
196
- this.connecting = !this.connected;
197
- if (this.connected)
198
- await this.read(true);
199
- }
200
- renderConnection() {
201
- if (!figureSourceOnLibrary() || !this.source)
202
- return nothing;
203
- const host = this.source.url ? this.source.url.replace(/^https?:\/\//, '') : '';
204
- return html `
205
- ${this.connected
206
- ? html `<div connection>
207
- <span>${host} · ${this.source.domain}</span>
208
- <md-text-button @click=${() => (this.connecting = !this.connecting)}>${i18next.t('figure-library.button.change-source')}</md-text-button>
209
- </div>`
210
- : nothing}
211
- ${this.connecting
212
- ? html `<figure-source-setting-let
213
- editable
214
- @saved=${(e) => {
215
- e.stopPropagation();
216
- this.readSource();
217
- }}
218
- ></figure-source-setting-let>`
219
- : nothing}
220
- `;
221
- }
222
- render() {
223
- const count = this.chosen.size;
224
- if (figureSourceOnLibrary() && !this.connected) {
225
- return html `
226
- <div class="body">${this.renderConnection()}</div>
227
- <ox-popup-actions>
228
- <md-text-button slot="cancel" @click=${() => this.dispatchEvent(new CustomEvent('close'))}>${i18next.t('figure-library.button.close')}</md-text-button>
229
- </ox-popup-actions>
230
- `;
231
- }
232
- return html `
233
- <div class="body">
234
- ${this.renderConnection()}
235
- <label class="field">
236
- <span>${i18next.t('figure-library.label.search-source')}</span>
237
- <input
238
- type="search"
239
- .value=${this.search}
240
- placeholder=${i18next.t('figure-library.text.search')}
241
- @change=${(e) => {
242
- this.search = e.target.value.trim();
243
- this.read(true);
244
- }}
245
- />
246
- </label>
247
-
248
- ${this.failure ? html `<p refused role="alert">${this.failure}</p>` : nothing}
249
- ${!this.failure && !this.reading && !this.items.length ? html `<div class="note">${i18next.t('figure-library.text.source-empty')}</div>` : nothing}
250
-
251
- <ul figures>
252
- ${this.items.map(item => this.renderItem(item))}
253
- </ul>
254
- ${this.items.length < this.total
255
- ? html `<md-text-button more ?disabled=${this.reading} @click=${() => this.read(false)}>${i18next.t('figure-library.button.more')}</md-text-button>`
256
- : nothing}
257
-
258
- <figure-import-result .result=${this.result}></figure-import-result>
259
- </div>
260
-
261
- <ox-popup-actions>
262
- <md-text-button slot="cancel" @click=${() => this.dispatchEvent(new CustomEvent('close'))}>${i18next.t('figure-library.button.close')}</md-text-button>
263
- <md-filled-button slot="confirm" ?disabled=${!count || this.installing} @click=${() => this.install()}>
264
- ${i18next.t('figure-library.button.install', { count })}
265
- </md-filled-button>
266
- </ox-popup-actions>
267
- `;
268
- }
269
- renderItem(item) {
270
- const name = item.names?.[i18next.language] ?? item.name ?? item.fullName;
271
- const picture = item.thumbnailHash ? figureSourceThumbnailUrl(item.figureId, item.thumbnailHash) : null;
272
- const version = item.installedVersion && item.installedVersion !== item.version
273
- ? i18next.t('figure-library.text.source-version-here', { version: item.version, here: item.installedVersion })
274
- : i18next.t('figure-library.text.source-version', { version: item.version });
275
- return html `<li>
276
- <input
277
- type="checkbox"
278
- aria-label=${name}
279
- .checked=${this.chosen.has(item.ref)}
280
- ?disabled=${this.installing}
281
- @change=${(e) => this.choose(item.ref, e.target.checked)}
282
- />
283
- ${picture ? html `<img thumb src=${picture} alt="" loading="lazy" />` : html `<span thumb></span>`}
284
- <span title>
285
- <strong>${name}</strong>
286
- <small>${item.fullName} · ${version}</small>
287
- </span>
288
- <span chips>
289
- ${item.deprecated ? html `<span chip="muted">${i18next.t('figure-library.text.deprecated')}</span>` : nothing}
290
- <span chip=${STATUS_TONE[item.status]}>${i18next.t(`figure-library.source-status.${item.status}`)}</span>
291
- </span>
292
- </li>`;
293
- }
294
- choose(ref, on) {
295
- const next = new Set(this.chosen);
296
- on ? next.add(ref) : next.delete(ref);
297
- this.chosen = next;
298
- }
299
- async read(fresh) {
300
- this.reading = true;
301
- this.failure = '';
302
- const page = fresh ? 1 : Math.floor(this.items.length / PAGE) + 1;
303
- try {
304
- const response = await client.query({
305
- query: CATALOG,
306
- fetchPolicy: 'no-cache',
307
- variables: {
308
- search: this.search || null,
309
- pagination: { page, limit: PAGE }
310
- }
311
- });
312
- if (response.errors?.length)
313
- throw new Error(response.errors[0].message);
314
- const { items, total } = response.data.figureSourceCatalog;
315
- this.items = fresh ? items : [...this.items, ...items];
316
- this.total = total;
317
- }
318
- catch (e) {
319
- this.failure = e?.message ?? String(e);
320
- if (fresh)
321
- this.items = [];
322
- }
323
- finally {
324
- this.reading = false;
325
- }
326
- }
327
- async install() {
328
- this.installing = true;
329
- this.result = undefined;
330
- try {
331
- const response = await client.mutate({ mutation: INSTALL, variables: { refs: [...this.chosen] } });
332
- if (response.errors?.length)
333
- throw new Error(response.errors[0].message);
334
- this.result = response.data.installFigures;
335
- if (this.result.outcomes.some(one => one.outcome === 'added'))
336
- announceLibraryChanged();
337
- this.chosen = new Set();
338
- this.dispatchEvent(new CustomEvent('imported', { detail: this.result }));
339
- await this.read(true);
340
- }
341
- catch (e) {
342
- this.result = { problems: [{ code: e?.message ?? 'error' }], outcomes: [] };
343
- }
344
- finally {
345
- this.installing = false;
346
- }
347
- }
348
- };
349
- __decorate([
350
- state(),
351
- __metadata("design:type", Object)
352
- ], FigureSourceInstall.prototype, "search", void 0);
353
- __decorate([
354
- state(),
355
- __metadata("design:type", Array)
356
- ], FigureSourceInstall.prototype, "items", void 0);
357
- __decorate([
358
- state(),
359
- __metadata("design:type", Object)
360
- ], FigureSourceInstall.prototype, "total", void 0);
361
- __decorate([
362
- state(),
363
- __metadata("design:type", Object)
364
- ], FigureSourceInstall.prototype, "reading", void 0);
365
- __decorate([
366
- state(),
367
- __metadata("design:type", Object)
368
- ], FigureSourceInstall.prototype, "installing", void 0);
369
- __decorate([
370
- state(),
371
- __metadata("design:type", Object)
372
- ], FigureSourceInstall.prototype, "failure", void 0);
373
- __decorate([
374
- state(),
375
- __metadata("design:type", Object)
376
- ], FigureSourceInstall.prototype, "chosen", void 0);
377
- __decorate([
378
- state(),
379
- __metadata("design:type", Object)
380
- ], FigureSourceInstall.prototype, "result", void 0);
381
- __decorate([
382
- state(),
383
- __metadata("design:type", Object)
384
- ], FigureSourceInstall.prototype, "source", void 0);
385
- __decorate([
386
- state(),
387
- __metadata("design:type", Object)
388
- ], FigureSourceInstall.prototype, "connecting", void 0);
389
- FigureSourceInstall = __decorate([
390
- customElement('figure-source-install')
391
- ], FigureSourceInstall);
392
- export { FigureSourceInstall };
393
- //# sourceMappingURL=figure-source-install.js.map