odant-work 1.0.104 → 1.0.105

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 (43) hide show
  1. package/$server/$folder/$class/$ai/handlers/pages/form/system/ai/$handler/class.js +15 -12
  2. package/$server/$folder/$class/$module/$mcp/handlers/pages/form/system/mcp/$handler/class.js +17 -24
  3. package/$server/$folder/$class/$module/$provider/handlers/pages/form/system/ai/$handler/class.js +15 -12
  4. package/$server/$folder/$class/$structure/$project/class.js +39 -5
  5. package/$server/$folder/$class/$structure/$project/handlers/pages/form/system/modules/$handler/class.js +40 -25
  6. package/$server/$folder/$class/$structure/$project/handlers/pages/form/system/requisites/$handler/class.js +1 -0
  7. package/$server/$folder/$class/$structure/$server/handlers/pages/form/system/license/$handler/class.js +13 -12
  8. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/profile/$handler/class.js +1 -0
  9. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/requisites/$handler/class.js +3 -0
  10. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/settings/$handler/class.js +6 -37
  11. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/tokens/$handler/class.js +2 -0
  12. package/$server/$folder/$class/$structure/$user/handlers/pages/form/system/users/$handler/class.js +1 -0
  13. package/$server/$folder/$class/$structure/class.js +15 -0
  14. package/$server/$folder/$class/$structure/handlers/pages/form/chat/$handler/class.js +17 -4
  15. package/$server/$folder/$class/$structure/handlers/pages/form/system/agent/$handler/class.js +5 -29
  16. package/$server/$folder/$class/$structure/handlers/pages/form/system/database/$handler/class.js +1 -0
  17. package/$server/$folder/$class/$structure/handlers/pages/form/system/messengers/$handler/class.js +1 -0
  18. package/$server/$folder/$class/$structure/handlers/pages/form/system/skills/$handler/class.js +276 -179
  19. package/$server/$folder/$class/$structure/handlers/pages/form/system/staff/$handler/class.js +1 -0
  20. package/$server/$folder/$class/ai/system.md +2 -2
  21. package/$server/$folder/$class/class.js +5 -1
  22. package/$server/$folder/$class/handlers/pages/form/system/requisites/$handler/class.js +39 -45
  23. package/$server/$folder/handlers/pages/form/$handler/class.js +177 -1
  24. package/$server/$folder/handlers/pages/form/folder/$handler/class.js +2 -611
  25. package/$server/$folder/lib/folder-browser/folder-browser.js +793 -0
  26. package/$server/$folder/lib/folder-browser/readme.md +5 -0
  27. package/$server/$folder/lib/tree/tree.js +16 -6
  28. package/AGENTS.md +2 -2
  29. package/MODULES/$domain/handlers/pages/form/system/mcp/$handler/class.js +10 -21
  30. package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/engine/$handler/class.js +1 -0
  31. package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/models/$handler/class.js +5 -10
  32. package/MODULES//320/234/320/276/320/264/320/265/320/273/320/270/Local/$provider/handlers/pages/form/system/training/$handler/class.js +1 -0
  33. package/MODULES//320/243/321/207/321/221/321/202 /320/270 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/321/213/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/241/321/207/321/221/321/202 /320/275/320/260 /320/276/320/277/320/273/320/260/321/202/321/203.html" +5 -1
  34. package/MODULES//320/243/321/207/321/221/321/202 /320/270 /320/277/321/200/320/276/321/206/320/265/321/201/321/201/321/213/Register/OPERATIONS//320/240/320/265/320/260/320/273/320/270/320/267/320/260/321/206/320/270/321/217//320/237/320/276/320/272/321/203/320/277/320/260/321/202/320/265/320/273/321/216/$operation/print//320/242/320/276/320/262/320/260/321/200/320/275/320/260/321/217 /320/275/320/260/320/272/320/273/320/260/320/264/320/275/320/260/321/217.html" +1 -1
  35. package/oda/components/layouts/editor-form/editor-form.js +54 -9
  36. package/package.json +1 -1
  37. package/sources/data/print.js +27 -3
  38. package/sources/host/websocket.js +11 -1
  39. package/sources/modules/user-profile/user-tokens.js +0 -46
  40. package/sources/server/access/gateway.js +31 -5
  41. package/sources/server/class/base-template.js +18 -18
  42. package/sources/server/class.js +9 -0
  43. package/sources/server/handler.js +6 -0
@@ -1,618 +1,9 @@
1
- const TEXT_PREVIEW_EXTS = new Set([
2
- 'js', 'mjs', 'cjs', 'ts', 'tsx', 'jsx', 'json', 'json5',
3
- 'css', 'scss', 'less', 'xml', 'yml', 'yaml', 'toml', 'ini',
4
- 'conf', 'env', 'sh', 'bash', 'ps1', 'cmd', 'bat', 'py', 'rb',
5
- 'go', 'rs', 'java', 'c', 'cpp', 'h', 'hpp', 'sql', 'log',
6
- 'csv', 'tsv', 'txt', 'md', 'gitignore', 'editorconfig', 'npmrc', 'lock',
7
- ]);
8
- const TEXT_PREVIEW_NAMES = new Set(['dockerfile', 'makefile', 'license', 'readme', 'changelog']);
9
- const MAX_TEXT_PREVIEW_CHARS = 512 * 1024;
1
+ import { FOLDER_BROWSER_COMPONENT } from '/~/lib/folder-browser/folder-browser.js';
10
2
 
11
3
  export default {
12
4
  icon: 'fontawesome:r-folder-open',
13
5
  label: 'Файлы',
14
6
  order: 10,
15
7
  default: true,
16
- component: {
17
- imports: '~/lib//tree.js, oda//splitter, oda//button, oda//icon',
18
- template: /* html */`
19
- <style>
20
- :host {
21
- @apply --vertical;
22
- overflow: hidden;
23
- @apply --content;
24
- min-height: 0;
25
- min-width: 0;
26
- }
27
- .folder-bar {
28
- @apply --horizontal;
29
- align-items: center;
30
- gap: 10px;
31
- padding: 6px 10px;
32
- flex-shrink: 0;
33
- box-sizing: border-box;
34
- }
35
- .search-wrap {
36
- @apply --horizontal;
37
- align-items: center;
38
- gap: 4px;
39
- flex: 1;
40
- min-width: 0;
41
- max-width: 560px;
42
- background: color-mix(in oklch, var(--content-background) 94%, transparent);
43
- color: var(--content-color);
44
- border-radius: 6px;
45
- padding: 2px 8px;
46
- border: 1px solid color-mix(in oklch, var(--content-color) 18%, transparent);
47
- }
48
- .search-wrap:focus-within {
49
- background: var(--content-background);
50
- box-shadow: 0 0 0 2px color-mix(in oklch, var(--accent-back, #fff) 35%, transparent);
51
- }
52
- .search-input {
53
- flex: 1;
54
- min-width: 0;
55
- border: none;
56
- outline: none;
57
- background: transparent;
58
- color: var(--content-color);
59
- font: inherit;
60
- font-size: 13px;
61
- padding: 3px 2px;
62
- }
63
- .search-action {
64
- cursor: pointer;
65
- opacity: 0.72;
66
- color: var(--content-color);
67
- flex-shrink: 0;
68
- }
69
- .search-action:hover {
70
- opacity: 1;
71
- }
72
- .sys-toggle {
73
- @apply --horizontal;
74
- align-items: center;
75
- gap: 6px;
76
- font-size: 12.5px;
77
- color: inherit;
78
- cursor: pointer;
79
- user-select: none;
80
- white-space: nowrap;
81
- flex-shrink: 0;
82
- margin-left: auto;
83
- }
84
- .sys-toggle input {
85
- margin: 0;
86
- cursor: pointer;
87
- accent-color: var(--content-background);
88
- }
89
- .folder-body {
90
- @apply --horizontal;
91
- flex: 1;
92
- min-height: 0;
93
- min-width: 0;
94
- overflow: hidden;
95
- }
96
- .tree-pane {
97
- @apply --vertical;
98
- flex: 1;
99
- min-width: 220px;
100
- min-height: 0;
101
- overflow: hidden;
102
- }
103
- oda-splitter {
104
- background: var(--subtle-border, var(--border-color));
105
- flex-shrink: 0;
106
- }
107
- .preview-pane {
108
- @apply --vertical;
109
- flex-shrink: 0;
110
- min-width: 240px;
111
- min-height: 0;
112
- overflow: hidden;
113
- background: var(--content-background);
114
- color: var(--content-color);
115
- }
116
- .preview-head {
117
- @apply --horizontal;
118
- align-items: center;
119
- gap: 8px;
120
- padding: 6px 10px;
121
- border-bottom: 1px solid var(--subtle-border, var(--border-color));
122
- background: var(--subtle-background, var(--content-background));
123
- flex-shrink: 0;
124
- min-width: 0;
125
- }
126
- .preview-title-wrap {
127
- @apply --vertical;
128
- min-width: 0;
129
- overflow: hidden;
130
- }
131
- .preview-title {
132
- font-size: 13px;
133
- font-weight: 600;
134
- white-space: nowrap;
135
- overflow: hidden;
136
- text-overflow: ellipsis;
137
- }
138
- .preview-sub {
139
- font-size: 11px;
140
- color: var(--muted-color);
141
- white-space: nowrap;
142
- overflow: hidden;
143
- text-overflow: ellipsis;
144
- }
145
- .preview-size {
146
- font-size: 11.5px;
147
- color: var(--muted-color);
148
- white-space: nowrap;
149
- flex-shrink: 0;
150
- }
151
- .preview-head oda-button {
152
- flex-shrink: 0;
153
- border-radius: 6px;
154
- padding: 3px 8px;
155
- font-size: 12px;
156
- border: 1px solid var(--subtle-border, var(--border-color));
157
- }
158
- .preview-stage {
159
- @apply --vertical;
160
- flex: 1;
161
- min-height: 0;
162
- min-width: 0;
163
- overflow: hidden;
164
- position: relative;
165
- }
166
- .preview-comp-wrap {
167
- @apply --vertical;
168
- flex: 1;
169
- min-height: 0;
170
- min-width: 0;
171
- overflow: auto;
172
- }
173
- .preview-code {
174
- margin: 0;
175
- padding: 12px 14px;
176
- flex: 1;
177
- min-height: 0;
178
- overflow: auto;
179
- font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
180
- font-size: 12.5px;
181
- line-height: 1.5;
182
- tab-size: 4;
183
- white-space: pre;
184
- user-select: text;
185
- background: var(--content-background);
186
- color: var(--content-color);
187
- }
188
- .preview-trunc {
189
- padding: 6px 12px;
190
- font-size: 12px;
191
- color: var(--muted-color);
192
- background: var(--subtle-background);
193
- border-bottom: 1px solid var(--subtle-border, var(--border-color));
194
- flex-shrink: 0;
195
- }
196
- .preview-pdf {
197
- flex: 1;
198
- width: 100%;
199
- height: 100%;
200
- border: none;
201
- min-height: 0;
202
- background: #fff;
203
- }
204
- .preview-empty {
205
- @apply --vertical;
206
- align-items: center;
207
- justify-content: center;
208
- text-align: center;
209
- gap: 8px;
210
- flex: 1;
211
- padding: 24px;
212
- min-height: 0;
213
- overflow: auto;
214
- }
215
- .empty-title {
216
- font-size: 14px;
217
- font-weight: 600;
218
- word-break: break-word;
219
- }
220
- .empty-sub {
221
- font-size: 12.5px;
222
- color: var(--muted-color);
223
- }
224
- .empty-hint {
225
- font-size: 12.5px;
226
- color: var(--muted-color);
227
- max-width: 360px;
228
- line-height: 1.45;
229
- }
230
- @media (max-width: 560px) {
231
- .folder-bar {
232
- flex-wrap: wrap;
233
- gap: 6px;
234
- }
235
- .search-wrap {
236
- max-width: none;
237
- }
238
- .folder-body {
239
- flex-direction: column;
240
- }
241
- .tree-pane {
242
- min-width: 0;
243
- min-height: 140px;
244
- }
245
- .preview-pane {
246
- width: 100% !important;
247
- max-width: 100% !important;
248
- min-width: 0;
249
- height: 55%;
250
- border-top: 1px solid var(--subtle-border, var(--border-color));
251
- }
252
- }
253
- </style>
254
- <div class="folder-bar" accent-invert>
255
- <div class="search-wrap">
256
- <input class="search-input" type="search"
257
- placeholder="Поиск в дереве (Enter — глобальный)…"
258
- :value="searchFilter"
259
- @input="onSearchInput($event)"
260
- @keydown="onSearchKey($event)">
261
- <oda-icon ~if="searchFilter" icon="icons:close" :icon-size="15" class="search-action" title="Сбросить фильтр" @tap="clearSearch()"></oda-icon>
262
- <oda-icon icon="icons:search" :icon-size="17" class="search-action" title="Глобальный поиск (Enter)" @tap="runGlobalSearch()"></oda-icon>
263
- </div>
264
- <label ~if="isBoss" class="sys-toggle">
265
- <input type="checkbox" :checked="showSystem" @change="onShowSystemChange($event)">
266
- <span>Показать системные</span>
267
- </label>
268
- </div>
269
- <div class="folder-body">
270
- <div class="tree-pane">
271
- <item-tree id="folderTree" flex
272
- :$item="storage"
273
- :filter="searchFilter"
274
- :hide-system="!effectiveShowSystem"
275
- :restore-state="false"
276
- :auto-run="false"
277
- show-size
278
- allow-focus
279
- show-tools
280
- menu-mode="both"
281
- items-selector="entries"
282
- hide-tops="1"
283
- hide-roots="1"
284
- :execute="openEntry"
285
- @focused-item-changed="onTreeFocusChanged($event)">
286
- </item-tree>
287
- </div>
288
- <oda-splitter ~if="showPreviewPane && !isMobile" left ::width="previewWidth" :min="240" :size="4"></oda-splitter>
289
- <div ~if="showPreviewPane" class="preview-pane" :style="previewPaneStyle">
290
- <div class="preview-head" ~if="previewTarget">
291
- <oda-icon :icon="previewTarget.icon || (isPreviewFile ? 'files:document' : 'fontawesome:r-folder')" :icon-size="18"></oda-icon>
292
- <div class="preview-title-wrap" flex>
293
- <div class="preview-title" :title="previewTitle">{{previewTitle}}</div>
294
- <div class="preview-sub" ~if="previewRelPath" :title="previewRelPath">{{previewRelPath}}</div>
295
- </div>
296
- <span class="preview-size" ~if="previewSizeText">{{previewSizeText}}</span>
297
- <oda-button ~if="canOpenPreviewTarget" icon="icons:open-in-new" :icon-size="15" label="Открыть" title="Открыть в отдельной вкладке" @tap="openPreviewTarget()"></oda-button>
298
- <oda-button ~if="isPreviewFile" icon="icons:file-download" :icon-size="15" label="Скачать" title="Скачать файл" @tap="downloadPreviewTarget()"></oda-button>
299
- <oda-button ~if="isMobile" icon="icons:close" :icon-size="16" title="Закрыть предпросмотр" @tap="closeMobilePreview()"></oda-button>
300
- </div>
301
- <div class="preview-stage">
302
- <div ~if="!previewTarget" class="preview-empty">
303
- <oda-icon icon="fontawesome:r-folder-open" :icon-size="40" style="opacity: 0.35;"></oda-icon>
304
- <div class="empty-title">{{storageTitle}}</div>
305
- <div class="empty-hint">Выберите файл в дереве слева для предпросмотра. Двойной клик или Enter открывает элемент в отдельной вкладке.</div>
306
- </div>
307
- <div ~if="previewTarget && !isPreviewFile" class="preview-empty">
308
- <oda-icon :icon="previewTarget.icon || 'fontawesome:r-folder'" :icon-size="40" style="opacity: 0.45;"></oda-icon>
309
- <div class="empty-title">{{previewTitle}}</div>
310
- <div class="empty-sub" ~if="previewSizeText">Размер: {{previewSizeText}}</div>
311
- <div class="empty-hint">Это папка. Выберите файл внутри для предпросмотра или откройте двойным кликом.</div>
312
- </div>
313
- <div ~if="isPreviewFile && previewMode === 'loading'" class="preview-empty">
314
- <oda-icon icon="spinners:8-dots-rotate" :icon-size="28"></oda-icon>
315
- <div class="empty-hint">Загрузка предпросмотра…</div>
316
- </div>
317
- <div ~if="isPreviewFile && previewMode === 'component' && previewTag" class="preview-comp-wrap">
318
- <div ~is="previewTag" full-height flex :$item="previewTarget"></div>
319
- </div>
320
- <div ~if="isPreviewFile && previewMode === 'text' && previewTruncated" class="preview-trunc">
321
- Показаны первые 512 КБ файла. Нажмите «Открыть» или «Скачать» для полного просмотра.
322
- </div>
323
- <pre ~if="isPreviewFile && previewMode === 'text'" class="preview-code">{{previewText}}</pre>
324
- <iframe ~if="isPreviewFile && previewMode === 'pdf'" class="preview-pdf" :src="previewPdfUrl"></iframe>
325
- <div ~if="isPreviewFile && previewMode === 'error'" class="preview-empty">
326
- <oda-icon icon="icons:warning" :icon-size="32" style="color: var(--error-color);"></oda-icon>
327
- <div class="empty-title">Не удалось загрузить предпросмотр</div>
328
- <div class="empty-hint">{{previewError}}</div>
329
- </div>
330
- <div ~if="isPreviewFile && previewMode === 'binary'" class="preview-empty">
331
- <oda-icon :icon="previewTarget.icon || 'files:document'" :icon-size="40" style="opacity: 0.45;"></oda-icon>
332
- <div class="empty-title">{{previewTitle}}</div>
333
- <div class="empty-sub" ~if="previewExt">Формат: .{{previewExt}}<span ~if="previewSizeText"> · {{previewSizeText}}</span></div>
334
- <div class="empty-hint">Предпросмотр для этого типа файлов недоступен. Используйте кнопки «Открыть» или «Скачать» выше.</div>
335
- </div>
336
- </div>
337
- </div>
338
- </div>
339
- `,
340
- showSystem: false,
341
- searchFilter: '',
342
- _isBoss: false,
343
- focusedItem: null,
344
- previewWidth: {
345
- $def: 480,
346
- $save: true,
347
- },
348
- previewMode: 'empty',
349
- previewTag: '',
350
- previewText: '',
351
- previewTruncated: false,
352
- previewPdfUrl: '',
353
- previewError: '',
354
- previewSizeText: '',
355
- $item: {
356
- $def: null,
357
- set(n) {
358
- this.focusedItem = null;
359
- this._clearPreview();
360
- this._syncIsBoss(n);
361
- },
362
- },
363
- attached() {
364
- if (this.$item)
365
- this._syncIsBoss(this.$item);
366
- },
367
- _syncIsBoss(it = this.$item) {
368
- if (!it) {
369
- this._isBoss = false;
370
- return;
371
- }
372
- if (WORK?.DEV_MODE) {
373
- this._isBoss = true;
374
- return;
375
- }
376
- const seq = (this._bossSeq = (this._bossSeq || 0) + 1);
377
- Promise.resolve(it.isBoss)
378
- .then(v => {
379
- if (seq === this._bossSeq)
380
- this._isBoss = Boolean(v);
381
- })
382
- .catch(() => {
383
- if (seq === this._bossSeq)
384
- this._isBoss = false;
385
- });
386
- },
387
- get isBoss() {
388
- return Boolean(this._isBoss);
389
- },
390
- get effectiveShowSystem() {
391
- return Boolean(this._isBoss && this.showSystem);
392
- },
393
- get isMobile() {
394
- const topW = typeof top !== 'undefined' ? top.innerWidth : (typeof window !== 'undefined' ? window.innerWidth : 1280);
395
- const selfW = this.clientWidth || (typeof window !== 'undefined' ? window.innerWidth : 1280);
396
- return Boolean((ODA.states?.mobileMode && topW <= 768) || selfW < 560);
397
- },
398
- get storage() {
399
- return this.$item?.storage_folder;
400
- },
401
- get storageTitle() {
402
- return this.$item?.DATA?.label || this.$item?.label || this.$item?.id || 'Файлы';
403
- },
404
- get previewTarget() {
405
- return this.focusedItem || null;
406
- },
407
- get isPreviewFile() {
408
- const it = this.previewTarget;
409
- if (!it)
410
- return false;
411
- return (typeof CORE !== 'undefined' && CORE.$file && it instanceof CORE.$file) || it.type === '$file';
412
- },
413
- get previewTitle() {
414
- const it = this.previewTarget;
415
- return it?.label || it?.DATA?.label || it?.id || '';
416
- },
417
- get previewExt() {
418
- const it = this.previewTarget;
419
- if (!it)
420
- return '';
421
- const id = String(it.id || it.path || '');
422
- const idx = id.lastIndexOf('.');
423
- return idx > -1 ? id.slice(idx + 1).toLowerCase() : '';
424
- },
425
- get previewRelPath() {
426
- const it = this.previewTarget;
427
- if (!it)
428
- return '';
429
- const full = String(it.path || it.short || '');
430
- const root = String(this.storage?.path || '');
431
- if (root && full.startsWith(root + '/'))
432
- return full.slice(root.length + 1);
433
- return full;
434
- },
435
- get canOpenPreviewTarget() {
436
- const it = this.previewTarget;
437
- if (!it)
438
- return false;
439
- return this.isPreviewFile || it.type !== '$folder';
440
- },
441
- get showPreviewPane() {
442
- if (this.isMobile)
443
- return this.isPreviewFile;
444
- return true;
445
- },
446
- get previewPaneStyle() {
447
- if (this.isMobile)
448
- return '';
449
- const w = Math.max(240, Number(this.previewWidth) || 480);
450
- return `width: ${w}px; max-width: 72%;`;
451
- },
452
- onSearchInput(e) {
453
- this.searchFilter = e?.target?.value ?? '';
454
- },
455
- onSearchKey(e) {
456
- if (e.key === 'Enter') {
457
- e.preventDefault();
458
- e.stopPropagation();
459
- this.runGlobalSearch();
460
- }
461
- else if (e.key === 'Escape' && this.searchFilter) {
462
- e.preventDefault();
463
- e.stopPropagation();
464
- this.clearSearch();
465
- }
466
- },
467
- clearSearch() {
468
- this.searchFilter = '';
469
- },
470
- runGlobalSearch() {
471
- this.$('#folderTree')?.runGlobalSearch?.();
472
- },
473
- onShowSystemChange(e) {
474
- const next = Boolean(e?.target?.checked);
475
- if (next) {
476
- const entries = this.storage?.[R]?.cache?.entries;
477
- if (Array.isArray(entries)) {
478
- for (const ent of entries) {
479
- const id = String(ent?.id || '');
480
- if (id.startsWith('$') || id.startsWith('#'))
481
- ent.expanded = false;
482
- }
483
- }
484
- }
485
- this.showSystem = next;
486
- if (!next && this.focusedItem) {
487
- const id = String(this.focusedItem.id || '');
488
- const p = String(this.focusedItem.path || '');
489
- if (id.startsWith('$') || id.startsWith('#') || p.includes('/$') || p.includes('/#')) {
490
- const tree = this.$('#folderTree');
491
- if (tree)
492
- tree.focusedItem = null;
493
- this.focusedItem = null;
494
- this._clearPreview();
495
- }
496
- }
497
- },
498
- onTreeFocusChanged(e) {
499
- const next = (e?.detail && 'value' in e.detail) ? e.detail.value : this.$('#folderTree')?.focusedItem;
500
- const item = next || null;
501
- this.focusedItem = item;
502
- this._syncPreview(item);
503
- },
504
- closeMobilePreview() {
505
- const tree = this.$('#folderTree');
506
- if (tree)
507
- tree.focusedItem = null;
508
- this.focusedItem = null;
509
- this._clearPreview();
510
- },
511
- openPreviewTarget() {
512
- if (this.previewTarget)
513
- this.openEntry(this.previewTarget);
514
- },
515
- downloadPreviewTarget() {
516
- this.previewTarget?.download?.();
517
- },
518
- _clearPreview() {
519
- this._previewSeq = (this._previewSeq || 0) + 1;
520
- this.previewMode = 'empty';
521
- this.previewTag = '';
522
- this.previewText = '';
523
- this.previewTruncated = false;
524
- this.previewPdfUrl = '';
525
- this.previewError = '';
526
- this.previewSizeText = '';
527
- },
528
- async _syncPreview(item) {
529
- const seq = (this._previewSeq = (this._previewSeq || 0) + 1);
530
- this.previewTag = '';
531
- this.previewText = '';
532
- this.previewTruncated = false;
533
- this.previewPdfUrl = '';
534
- this.previewError = '';
535
- this.previewSizeText = '';
536
- if (!item) {
537
- this.previewMode = 'empty';
538
- return;
539
- }
540
- if (item.size !== undefined) {
541
- Promise.resolve(item.size).then(sz => {
542
- if (seq === this._previewSeq && sz)
543
- this.previewSizeText = String(sz);
544
- }).catch(() => {});
545
- }
546
- const isFile = (typeof CORE !== 'undefined' && CORE.$file && item instanceof CORE.$file) || item.type === '$file';
547
- if (!isFile) {
548
- this.previewMode = 'folder';
549
- return;
550
- }
551
- this.previewMode = 'loading';
552
- try {
553
- const hasPreview = typeof CORE?.$file?.loadPreview === 'function'
554
- ? await CORE.$file.loadPreview(item)
555
- : false;
556
- if (seq !== this._previewSeq)
557
- return;
558
- if (hasPreview && item.ext) {
559
- this.previewTag = item.ext + '-preview';
560
- this.previewMode = 'component';
561
- return;
562
- }
563
- const ext = this.previewExt;
564
- if (ext === 'pdf' && item.url) {
565
- this.previewPdfUrl = item.url;
566
- this.previewMode = 'pdf';
567
- return;
568
- }
569
- const nameLower = String(item.id || '').toLowerCase();
570
- if ((TEXT_PREVIEW_EXTS.has(ext) || TEXT_PREVIEW_NAMES.has(nameLower)) && typeof item.load === 'function') {
571
- const raw = await item.load();
572
- if (seq !== this._previewSeq)
573
- return;
574
- let txt;
575
- if (raw?.DATA instanceof Blob)
576
- txt = await raw.DATA.text();
577
- else if (raw instanceof Blob)
578
- txt = await raw.text();
579
- else if (raw && typeof raw === 'object')
580
- txt = JSON.stringify(raw, null, 2);
581
- else
582
- txt = String(raw ?? '');
583
- if (seq !== this._previewSeq)
584
- return;
585
- if (txt.length > MAX_TEXT_PREVIEW_CHARS) {
586
- this.previewTruncated = true;
587
- this.previewText = txt.slice(0, MAX_TEXT_PREVIEW_CHARS);
588
- }
589
- else {
590
- this.previewText = txt;
591
- }
592
- this.previewMode = 'text';
593
- return;
594
- }
595
- this.previewMode = 'binary';
596
- }
597
- catch (err) {
598
- if (seq !== this._previewSeq)
599
- return;
600
- this.previewError = String(err?.message || err || 'Ошибка загрузки');
601
- this.previewMode = 'error';
602
- }
603
- },
604
- openEntry(item) {
605
- if (!item)
606
- return;
607
- if (item.type === '$handler') {
608
- item.execute?.();
609
- return;
610
- }
611
- if (typeof window?.execute === 'function') {
612
- window.execute(item);
613
- return;
614
- }
615
- item.execute?.();
616
- },
617
- },
8
+ component: FOLDER_BROWSER_COMPONENT,
618
9
  };