@kubohiroya/turbowarp-plus-editor-workbench 0.28.1 → 0.29.1
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/README.ja.md +14 -0
- package/README.md +10 -0
- package/dist/extension-file-menu.d.ts +1 -0
- package/dist/extension-file-menu.js +1 -0
- package/dist/project-catalog-dialog.d.ts +3 -0
- package/dist/project-catalog-dialog.js +247 -0
- package/dist/project-catalog-host.d.ts +50 -0
- package/dist/project-catalog-host.js +330 -0
- package/dist/project-catalog-migration.d.ts +3 -0
- package/dist/project-catalog-migration.js +47 -0
- package/dist/project-catalog.d.ts +58 -0
- package/dist/project-catalog.js +150 -0
- package/dist/project-file-menu.d.ts +2 -0
- package/dist/project-file-menu.js +7 -6
- package/dist/project-tools/integration.d.ts +10 -1
- package/dist/project-tools/integration.js +15 -3
- package/dist/workspace-layout-store.js +2 -1
- package/package.json +17 -3
- package/src/extension-file-menu.ts +1 -0
- package/src/project-catalog-dialog.ts +206 -0
- package/src/project-catalog-host.ts +298 -0
- package/src/project-catalog-migration.ts +38 -0
- package/src/project-catalog.css +27 -0
- package/src/project-catalog.ts +172 -0
- package/src/project-file-menu.tsx +6 -3
- package/src/project-tools/integration.ts +22 -3
- package/src/workspace-layout-store.ts +2 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
.tw-project-catalog {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
width: min(60rem, calc(100vw - 2rem));
|
|
4
|
+
max-height: calc(100vh - 2rem);
|
|
5
|
+
overflow: auto;
|
|
6
|
+
padding: 1.25rem;
|
|
7
|
+
background: Canvas;
|
|
8
|
+
color: CanvasText;
|
|
9
|
+
border: 1px solid GrayText;
|
|
10
|
+
border-radius: .5rem;
|
|
11
|
+
font: .875rem/1.5 system-ui, sans-serif;
|
|
12
|
+
}
|
|
13
|
+
.tw-project-catalog h2 {margin-top: 0; font-size: 1.25rem;}
|
|
14
|
+
.tw-project-catalog__header {display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem;}
|
|
15
|
+
.tw-project-catalog__header h2 {margin: 0;}
|
|
16
|
+
.tw-project-catalog ul {list-style: none; padding: 0; display: grid; gap: .75rem;}
|
|
17
|
+
.tw-project-catalog li {border: 1px solid GrayText; border-radius: .375rem; padding: .75rem; overflow-wrap: anywhere;}
|
|
18
|
+
.tw-project-catalog li p {margin: .25rem 0;}
|
|
19
|
+
.tw-project-catalog button, .tw-project-catalog input, .tw-project-catalog select {font: inherit; max-width: 100%;}
|
|
20
|
+
.tw-project-catalog button {padding: .25rem .5rem; cursor: pointer;}
|
|
21
|
+
.tw-project-catalog button:disabled {cursor: default; opacity: .55;}
|
|
22
|
+
.tw-project-catalog small {display: block; margin-top: .5rem;}
|
|
23
|
+
.tw-project-catalog__actions {display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem;}
|
|
24
|
+
.tw-project-catalog__rename {border-top: 1px solid GrayText; padding-top: .75rem;}
|
|
25
|
+
.tw-project-catalog__rename > label {display: block; margin-block: .75rem;}
|
|
26
|
+
.tw-project-catalog__rename button {margin-inline-end: .5rem;}
|
|
27
|
+
.tw-project-catalog [role=alert] {border-inline-start: .25rem solid #c64c14; padding-inline-start: .75rem;}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MPL-2.0
|
|
2
|
+
/** A catalog entry identifies a saved resource; its title never serves as its identity. */
|
|
3
|
+
export interface CatalogProject {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
storageName: string;
|
|
7
|
+
location: 'file' | 'folder' | 'browser' | 'remote';
|
|
8
|
+
handle?: FileSystemFileHandle | FileSystemDirectoryHandle;
|
|
9
|
+
repositoryRoot?: FileSystemDirectoryHandle;
|
|
10
|
+
browserId?: string;
|
|
11
|
+
remote?: string;
|
|
12
|
+
legacyLayoutId?: number;
|
|
13
|
+
lastOpenedAt: number | null;
|
|
14
|
+
hidden?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export type CatalogSource = Omit<CatalogProject, 'id' | 'lastOpenedAt' | 'hidden'> & {lastOpenedAt?: number | null};
|
|
17
|
+
export type CatalogSort = {by: 'title' | 'lastOpenedAt' | 'location'; direction: 'asc' | 'desc'};
|
|
18
|
+
export interface ProjectCatalogStore {
|
|
19
|
+
list(includeHidden?: boolean): Promise<CatalogProject[]>;
|
|
20
|
+
register(source: CatalogSource, opened?: boolean, entryId?: string): Promise<CatalogProject>;
|
|
21
|
+
update(id: string, changes: Partial<Pick<CatalogProject, 'title' | 'storageName' | 'handle' | 'remote'>>): Promise<void>;
|
|
22
|
+
forget(id: string): Promise<void>;
|
|
23
|
+
remove(id: string): Promise<void>;
|
|
24
|
+
sort(value?: CatalogSort): Promise<CatalogSort>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const projectCatalogDatabase = 'twPlusProjectCatalog';
|
|
28
|
+
const defaultSort: CatalogSort = {by: 'lastOpenedAt', direction: 'desc'};
|
|
29
|
+
const queues = new WeakMap<IDBFactory, Promise<unknown>>();
|
|
30
|
+
const result = <T>(request: IDBRequest<T>) => new Promise<T>((resolve, reject) => {
|
|
31
|
+
request.onsuccess = () => resolve(request.result);
|
|
32
|
+
request.onerror = () => reject(request.error);
|
|
33
|
+
});
|
|
34
|
+
const finished = (transaction: IDBTransaction) => new Promise<void>((resolve, reject) => {
|
|
35
|
+
transaction.oncomplete = () => resolve();
|
|
36
|
+
transaction.onabort = transaction.onerror = () => reject(transaction.error ?? new Error('Catalog write failed'));
|
|
37
|
+
});
|
|
38
|
+
const isSort = (value: any): value is CatalogSort => value &&
|
|
39
|
+
['title', 'lastOpenedAt', 'location'].includes(value.by) && ['asc', 'desc'].includes(value.direction);
|
|
40
|
+
|
|
41
|
+
/** Sorting never changes a caller's array; missing usage times stay last in either direction. */
|
|
42
|
+
export function sortCatalog(projects: readonly CatalogProject[], order: CatalogSort, locale = 'en') {
|
|
43
|
+
const compare = new Intl.Collator(locale, {numeric: true, sensitivity: 'base'}).compare;
|
|
44
|
+
return [...projects].sort((a, b) => {
|
|
45
|
+
if (order.by === 'lastOpenedAt' && (a.lastOpenedAt === null || b.lastOpenedAt === null)) {
|
|
46
|
+
if (a.lastOpenedAt !== b.lastOpenedAt) return a.lastOpenedAt === null ? 1 : -1;
|
|
47
|
+
}
|
|
48
|
+
const primary = order.by === 'lastOpenedAt' ? (a.lastOpenedAt ?? 0) - (b.lastOpenedAt ?? 0) :
|
|
49
|
+
compare(a[order.by], b[order.by]);
|
|
50
|
+
return primary * (order.direction === 'asc' ? 1 : -1) || compare(a.title, b.title) || a.id.localeCompare(b.id);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** Persist handles by structured clone. The lock covers async handle comparisons outside IDB transactions. */
|
|
55
|
+
export function createProjectCatalogStore({indexedDB = globalThis.indexedDB, locks = globalThis.navigator?.locks,
|
|
56
|
+
now = Date.now, id = () => globalThis.crypto.randomUUID()}: {
|
|
57
|
+
indexedDB?: IDBFactory; locks?: LockManager; now?(): number; id?(): string;
|
|
58
|
+
} = {}): ProjectCatalogStore {
|
|
59
|
+
let opened: Promise<IDBDatabase> | undefined;
|
|
60
|
+
const database = () => opened ??= new Promise((resolve, reject) => {
|
|
61
|
+
if (!indexedDB) return reject(new Error('IndexedDB is unavailable'));
|
|
62
|
+
const request = indexedDB.open(projectCatalogDatabase, 1);
|
|
63
|
+
request.onupgradeneeded = () => {
|
|
64
|
+
request.result.createObjectStore('projects', {keyPath: 'id'});
|
|
65
|
+
request.result.createObjectStore('preferences');
|
|
66
|
+
};
|
|
67
|
+
request.onerror = () => {opened = undefined; reject(request.error);};
|
|
68
|
+
request.onsuccess = () => {
|
|
69
|
+
request.result.onversionchange = () => {request.result.close(); opened = undefined;};
|
|
70
|
+
resolve(request.result);
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
const all = async () => {
|
|
74
|
+
const tx = (await database()).transaction('projects');
|
|
75
|
+
const done = finished(tx);
|
|
76
|
+
const records = await result(tx.objectStore('projects').getAll()) as CatalogProject[];
|
|
77
|
+
await done;
|
|
78
|
+
return records;
|
|
79
|
+
};
|
|
80
|
+
const write = async (record: CatalogProject | string) => {
|
|
81
|
+
const tx = (await database()).transaction('projects', 'readwrite');
|
|
82
|
+
const done = finished(tx);
|
|
83
|
+
const table = tx.objectStore('projects');
|
|
84
|
+
if (typeof record === 'string') table.delete(record); else table.put(record);
|
|
85
|
+
await done;
|
|
86
|
+
};
|
|
87
|
+
const serial = <T>(run: () => Promise<T>): Promise<T> => {
|
|
88
|
+
if (!indexedDB) return Promise.reject(new Error('IndexedDB is unavailable'));
|
|
89
|
+
const pending = (queues.get(indexedDB) ?? Promise.resolve()).catch(() => {}).then(() =>
|
|
90
|
+
locks ? locks.request('tw-plus-project-catalog', run) : run()) as Promise<T>;
|
|
91
|
+
queues.set(indexedDB, pending.catch(() => {}));
|
|
92
|
+
return pending;
|
|
93
|
+
};
|
|
94
|
+
const change = (key: string, update: (record: CatalogProject) => CatalogProject) => serial(async () => {
|
|
95
|
+
const record = (await all()).find(record => record.id === key);
|
|
96
|
+
if (!record) throw new Error('The project is no longer in the catalog');
|
|
97
|
+
await write(update(record));
|
|
98
|
+
});
|
|
99
|
+
return {
|
|
100
|
+
async list(includeHidden = false) {return (await all()).filter(record => includeHidden || !record.hidden);},
|
|
101
|
+
register(source, opened = true, entryId) {return serial(async () => {
|
|
102
|
+
const records = await all();
|
|
103
|
+
let existing = entryId ? records.find(record => record.id === entryId) : undefined;
|
|
104
|
+
for (const record of existing ? [] : records) {
|
|
105
|
+
if (source.legacyLayoutId !== undefined && record.legacyLayoutId === source.legacyLayoutId) {existing = record; break;}
|
|
106
|
+
if (source.browserId && record.browserId === source.browserId) {existing = record; break;}
|
|
107
|
+
if (source.handle && record.handle) {
|
|
108
|
+
try {if (await source.handle.isSameEntry(record.handle)) {existing = record; break;}} catch { /* Stale handle. */ }
|
|
109
|
+
}
|
|
110
|
+
// A remote-only entry has no worktree yet. Distinct worktrees of one remote stay distinct.
|
|
111
|
+
if (source.location === 'remote' && record.location === 'remote' && record.remote === source.remote) {
|
|
112
|
+
existing = record; break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const record: CatalogProject = {...existing, ...source, id: existing?.id ?? id(),
|
|
116
|
+
hidden: opened ? false : existing?.hidden ?? false,
|
|
117
|
+
lastOpenedAt: opened ? now() : existing?.lastOpenedAt ?? source.lastOpenedAt ?? null};
|
|
118
|
+
await write(record);
|
|
119
|
+
return record;
|
|
120
|
+
});},
|
|
121
|
+
update(key, changes) {return change(key, record => ({...record, ...changes}));},
|
|
122
|
+
forget(key) {return change(key, record => ({...record, hidden: true}));},
|
|
123
|
+
remove(key) {return serial(() => write(key));},
|
|
124
|
+
async sort(value) {
|
|
125
|
+
if (value && !isSort(value)) throw new Error('Invalid catalog order');
|
|
126
|
+
const tx = (await database()).transaction('preferences', value ? 'readwrite' : 'readonly');
|
|
127
|
+
const done = finished(tx);
|
|
128
|
+
const table = tx.objectStore('preferences');
|
|
129
|
+
const saved = value ? (table.put(value, 'sort'), value) : await result(table.get('sort'));
|
|
130
|
+
await done;
|
|
131
|
+
return isSort(saved) ? saved : {...defaultSort};
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export interface CatalogOperations {
|
|
137
|
+
open(): Promise<CatalogSource | null>;
|
|
138
|
+
renameProject?(title: string): Promise<void>;
|
|
139
|
+
renameStorage?(name: string): Promise<Partial<Pick<CatalogProject, 'storageName' | 'handle' | 'remote'>>>;
|
|
140
|
+
deleteData?(): Promise<void>;
|
|
141
|
+
unavailable?: Partial<Record<'renameProject' | 'renameStorage' | 'deleteData', string>>;
|
|
142
|
+
}
|
|
143
|
+
export interface CatalogHost {
|
|
144
|
+
store: ProjectCatalogStore;
|
|
145
|
+
/** Opens the host's existing new-project flow after the catalog is dismissed. */
|
|
146
|
+
createProject?(): void;
|
|
147
|
+
refresh(): Promise<void>;
|
|
148
|
+
operations(project: CatalogProject): CatalogOperations;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Persist each successful step immediately, so a later failure cannot invent an atomic rename. */
|
|
152
|
+
export async function renameCatalogProject(host: CatalogHost, project: CatalogProject,
|
|
153
|
+
names: {title?: string; storageName?: string}) {
|
|
154
|
+
if (names.title !== undefined && (!names.title.trim() || names.title.length > 100)) throw new Error('Invalid project name');
|
|
155
|
+
if (names.storageName !== undefined && (!names.storageName.trim() || names.storageName.length > 200)) throw new Error('Invalid storage name');
|
|
156
|
+
const actions = host.operations(project);
|
|
157
|
+
if (names.title !== undefined && !actions.renameProject || names.storageName !== undefined && !actions.renameStorage) {
|
|
158
|
+
throw new Error('This rename is unavailable');
|
|
159
|
+
}
|
|
160
|
+
if (names.title !== undefined) {
|
|
161
|
+
await actions.renameProject!(names.title);
|
|
162
|
+
await host.store.update(project.id, {title: names.title});
|
|
163
|
+
}
|
|
164
|
+
if (names.storageName !== undefined) {
|
|
165
|
+
const current = (await host.store.list(true)).find(entry => entry.id === project.id);
|
|
166
|
+
if (!current) throw new Error('The project is no longer in the catalog');
|
|
167
|
+
const rename = host.operations(current).renameStorage;
|
|
168
|
+
if (!rename) throw new Error('This storage rename is unavailable');
|
|
169
|
+
const changes = await rename(names.storageName);
|
|
170
|
+
await host.store.update(project.id, changes);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
@@ -87,6 +87,8 @@ export default function ProjectFileMenu({locale, MenuItem, MenuSection, close, e
|
|
|
87
87
|
newProject?: NewProjectChoices;
|
|
88
88
|
newWindow?: Action;
|
|
89
89
|
open: Action;
|
|
90
|
+
/** Receives the same creation command as Create New Project, including its destination choices. */
|
|
91
|
+
catalog?: (createProject: Action) => void;
|
|
90
92
|
externalYaml?: React.ReactNode;
|
|
91
93
|
folder?: FolderActions;
|
|
92
94
|
openRemote?: Action;
|
|
@@ -129,14 +131,15 @@ export default function ProjectFileMenu({locale, MenuItem, MenuSection, close, e
|
|
|
129
131
|
};
|
|
130
132
|
const e = entries;
|
|
131
133
|
const createIn = e.createIn;
|
|
132
|
-
const createNew:
|
|
134
|
+
const createNew: Action = createIn ? () => {
|
|
133
135
|
if (typeof document === 'undefined') return;
|
|
134
136
|
void openNewProjectDialog(document, locale, {...e.newProject, create: e.create, createIn});
|
|
135
|
-
}
|
|
137
|
+
} : e.create;
|
|
136
138
|
return <>
|
|
137
|
-
{item(createNew)}
|
|
139
|
+
{item(['new', ja ? `新しいプロジェクトを作成${createIn ? '…' : ''}` : `Create New Project${createIn ? '…' : ''}`, createNew])}
|
|
138
140
|
{e.newWindow && item(['window', ja ? '新しいウィンドウ' : 'New Window', e.newWindow])}
|
|
139
141
|
<MenuSection>
|
|
142
|
+
{e.catalog && item(['projects', ja ? 'プロジェクト一覧…' : 'Projects…', () => e.catalog!(createNew)])}
|
|
140
143
|
{item(['open', ja ? 'SB3ファイルを開く…' : 'Open SB3 File…', e.open])}
|
|
141
144
|
{/* Safari and Firefox cannot pick folders on the device; the browser's folders have their own item. */}
|
|
142
145
|
{e.folder && item(['project-folder-open', ja ? 'フォルダを開く…' : 'Open Folder…',
|
|
@@ -24,6 +24,8 @@ import type {ExtensionSpec} from '@kubohiroya/turbowarp-extension-loader';
|
|
|
24
24
|
import JSZip from '@turbowarp/jszip';
|
|
25
25
|
import {installProjectScreenState} from '../project-screen-state.js';
|
|
26
26
|
import type {ProjectScreenState} from '../project-screen-state.js';
|
|
27
|
+
import {createProjectCatalogRuntime} from '../project-catalog-host.js';
|
|
28
|
+
import type {CatalogFolderPorts} from '../project-catalog-host.js';
|
|
27
29
|
|
|
28
30
|
export interface ProjectToolsPorts {
|
|
29
31
|
installEditorExtensionHost(vm: any, settings: any): any;
|
|
@@ -36,11 +38,16 @@ export interface ProjectToolsPorts {
|
|
|
36
38
|
projectLoadState(document: Document | undefined): {
|
|
37
39
|
current(): string; isShown(): boolean; subscribe(listener: () => void): () => void;
|
|
38
40
|
} | undefined;
|
|
41
|
+
catalogEnvironment?(document: Document): {
|
|
42
|
+
readFile(): FileSystemFileHandle | null;
|
|
43
|
+
isDirty(): boolean;
|
|
44
|
+
subscribeLocation(listener: () => void): () => void;
|
|
45
|
+
} | undefined;
|
|
39
46
|
}
|
|
40
47
|
/** Feature state and workflows are local to one host integration. */
|
|
41
48
|
export function createProjectTools({installEditorExtensionHost, installProjectProperties, createProjectDialogs,
|
|
42
49
|
editorProjectArchives, projectToolsEnabled: PROJECT_TOOLS_ENABLED, manualProjectURIEnabled: MANUAL_PROJECT_URI_ENABLED,
|
|
43
|
-
readStartupFlags: readWebStartupFeatureFlags, projectLoadState}: ProjectToolsPorts) {
|
|
50
|
+
readStartupFlags: readWebStartupFeatureFlags, projectLoadState, catalogEnvironment}: ProjectToolsPorts) {
|
|
44
51
|
const projects = new WeakMap();
|
|
45
52
|
const screenStates = new WeakMap<object, ProjectScreenState>();
|
|
46
53
|
const storageFor = document => {
|
|
@@ -73,7 +80,13 @@ export function createProjectTools({installEditorExtensionHost, installProjectPr
|
|
|
73
80
|
const dialogs = document?.body ? createProjectDialogs(document, properties, history, diagnostics,
|
|
74
81
|
{locale: settings.locale, getLocale: settings.getLocale}) : null;
|
|
75
82
|
const tools = {dialogs, payloads: 'payloads' in host ? host.payloads : undefined, propertiesEnabled: enabled,
|
|
76
|
-
projectURIEnabled: MANUAL_PROJECT_URI_ENABLED && host.enabled, properties, projectState: settings.projectState
|
|
83
|
+
projectURIEnabled: MANUAL_PROJECT_URI_ENABLED && host.enabled, properties, projectState: settings.projectState,
|
|
84
|
+
catalog: undefined as ReturnType<typeof createProjectCatalogRuntime> | undefined};
|
|
85
|
+
const environment = document && catalogEnvironment?.(document);
|
|
86
|
+
if (environment) tools.catalog = createProjectCatalogRuntime({document, vm, properties, ...environment,
|
|
87
|
+
report: error => showNotice(document, (settings.getLocale?.() ?? settings.locale ?? 'en').startsWith('ja') ?
|
|
88
|
+
'プロジェクト履歴を保存できませんでした。' : 'The project history could not be saved.',
|
|
89
|
+
{locale: settings.getLocale?.() ?? settings.locale ?? 'en'})});
|
|
77
90
|
let lastPhase;
|
|
78
91
|
const unsubscribe = properties.subscribe(() => {
|
|
79
92
|
const state = properties.loadState();
|
|
@@ -91,6 +104,7 @@ export function createProjectTools({installEditorExtensionHost, installProjectPr
|
|
|
91
104
|
disposal ??= (async () => {
|
|
92
105
|
vm.off?.('ASSET_PROGRESS', reportAssets);
|
|
93
106
|
vm.runtime?.off?.('PROJECT_LOADED', finishProject);
|
|
107
|
+
tools.catalog?.dispose();
|
|
94
108
|
unsubscribe(); dialogs?.dispose(); properties.dispose(); diagnostics.dispose(); projects.delete(vm);
|
|
95
109
|
screenStates.delete(vm);
|
|
96
110
|
screenState.dispose();
|
|
@@ -363,5 +377,10 @@ export function createProjectTools({installEditorExtensionHost, installProjectPr
|
|
|
363
377
|
|
|
364
378
|
const projectToolsOwnKeyEvent = event => Boolean(event.target?.closest?.('[data-project-tools]'));
|
|
365
379
|
|
|
366
|
-
|
|
380
|
+
const bindProjectCatalogFolder = (vm: object, ports: CatalogFolderPorts) => projects.get(vm)?.catalog?.bindFolder(ports);
|
|
381
|
+
const projectCatalog = (vm: object, locale: string, storage: ProjectFileStorage, createProject?: () => void) =>
|
|
382
|
+
projects.get(vm)?.catalog?.show(locale, storage, createProject);
|
|
383
|
+
const projectFileOpened = (vm: object, file: File | null) => projects.get(vm)?.catalog?.fileOpened(file);
|
|
384
|
+
return {installProjectToolsHost, projectScreenState, loadedProjectTitle, restoreProjectTitle, isProjectLoading, subscribeProjectLoad, projectSaveName, setProjectSaveName, createFolderFromCurrentProject, projectFileActions, projectCreation, renderFileMenu, projectToolsOwnKeyEvent,
|
|
385
|
+
bindProjectCatalogFolder, projectCatalog, projectFileOpened};
|
|
367
386
|
}
|
|
@@ -110,7 +110,8 @@ async function find(database: IDBDatabase, identity: WorkspaceProjectIdentity, s
|
|
|
110
110
|
const store = transaction.objectStore(layoutsStore);
|
|
111
111
|
const records = identity.kind === 'desktop' ?
|
|
112
112
|
await result(store.index('desktopKey').getAll(identity.key)) as LayoutRecord[] :
|
|
113
|
-
await result(store.index('name').getAll(identity.name)) as LayoutRecord[]
|
|
113
|
+
identity.kind === 'anonymous' ? await result(store.index('name').getAll(identity.name)) as LayoutRecord[] :
|
|
114
|
+
await result(store.getAll()) as LayoutRecord[];
|
|
114
115
|
await finished;
|
|
115
116
|
const candidates = recent(records.filter(record => record.kind === identity.kind));
|
|
116
117
|
if (identity.kind === 'desktop') return candidates[0];
|