@genesislcap/foundation-ui 14.406.0-workspaces.6 → 14.406.0-workspaces.7

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 (56) hide show
  1. package/dist/custom-elements.json +1136 -3030
  2. package/dist/dts/index.d.ts +0 -2
  3. package/dist/dts/index.d.ts.map +1 -1
  4. package/dist/esm/index.js +0 -2
  5. package/package.json +19 -19
  6. package/dist/dts/workspace/filter-registry.d.ts +0 -34
  7. package/dist/dts/workspace/filter-registry.d.ts.map +0 -1
  8. package/dist/dts/workspace/grid-register/grid-register.d.ts +0 -19
  9. package/dist/dts/workspace/grid-register/grid-register.d.ts.map +0 -1
  10. package/dist/dts/workspace/grid-register/grid-register.template.d.ts +0 -4
  11. package/dist/dts/workspace/grid-register/grid-register.template.d.ts.map +0 -1
  12. package/dist/dts/workspace/grid-register/index.d.ts +0 -2
  13. package/dist/dts/workspace/grid-register/index.d.ts.map +0 -1
  14. package/dist/dts/workspace/grid-registry.d.ts +0 -47
  15. package/dist/dts/workspace/grid-registry.d.ts.map +0 -1
  16. package/dist/dts/workspace/index.d.ts +0 -9
  17. package/dist/dts/workspace/index.d.ts.map +0 -1
  18. package/dist/dts/workspace/layout-registry.d.ts +0 -27
  19. package/dist/dts/workspace/layout-registry.d.ts.map +0 -1
  20. package/dist/dts/workspace/layout-wrapper/index.d.ts +0 -2
  21. package/dist/dts/workspace/layout-wrapper/index.d.ts.map +0 -1
  22. package/dist/dts/workspace/layout-wrapper/layout-wrapper.d.ts +0 -10
  23. package/dist/dts/workspace/layout-wrapper/layout-wrapper.d.ts.map +0 -1
  24. package/dist/dts/workspace/layout-wrapper/layout-wrapper.template.d.ts +0 -4
  25. package/dist/dts/workspace/layout-wrapper/layout-wrapper.template.d.ts.map +0 -1
  26. package/dist/dts/workspace/workspace-state.d.ts +0 -45
  27. package/dist/dts/workspace/workspace-state.d.ts.map +0 -1
  28. package/dist/dts/workspace/workspace-state.types.d.ts +0 -26
  29. package/dist/dts/workspace/workspace-state.types.d.ts.map +0 -1
  30. package/dist/dts/workspace/workspace.types.d.ts +0 -25
  31. package/dist/dts/workspace/workspace.types.d.ts.map +0 -1
  32. package/dist/dts/workspace-manager/index.d.ts +0 -2
  33. package/dist/dts/workspace-manager/index.d.ts.map +0 -1
  34. package/dist/dts/workspace-manager/workspace-manager.d.ts +0 -62
  35. package/dist/dts/workspace-manager/workspace-manager.d.ts.map +0 -1
  36. package/dist/dts/workspace-manager/workspace-manager.styles.d.ts +0 -2
  37. package/dist/dts/workspace-manager/workspace-manager.styles.d.ts.map +0 -1
  38. package/dist/dts/workspace-manager/workspace-manager.template.d.ts +0 -4
  39. package/dist/dts/workspace-manager/workspace-manager.template.d.ts.map +0 -1
  40. package/dist/esm/workspace/filter-registry.js +0 -47
  41. package/dist/esm/workspace/grid-register/grid-register.js +0 -132
  42. package/dist/esm/workspace/grid-register/grid-register.template.js +0 -4
  43. package/dist/esm/workspace/grid-register/index.js +0 -1
  44. package/dist/esm/workspace/grid-registry.js +0 -113
  45. package/dist/esm/workspace/index.js +0 -8
  46. package/dist/esm/workspace/layout-registry.js +0 -46
  47. package/dist/esm/workspace/layout-wrapper/index.js +0 -1
  48. package/dist/esm/workspace/layout-wrapper/layout-wrapper.js +0 -60
  49. package/dist/esm/workspace/layout-wrapper/layout-wrapper.template.js +0 -4
  50. package/dist/esm/workspace/workspace-state.js +0 -193
  51. package/dist/esm/workspace/workspace-state.types.js +0 -1
  52. package/dist/esm/workspace/workspace.types.js +0 -1
  53. package/dist/esm/workspace-manager/index.js +0 -1
  54. package/dist/esm/workspace-manager/workspace-manager.js +0 -432
  55. package/dist/esm/workspace-manager/workspace-manager.styles.js +0 -138
  56. package/dist/esm/workspace-manager/workspace-manager.template.js +0 -259
@@ -1,132 +0,0 @@
1
- import { __awaiter, __decorate } from "tslib";
2
- import { attr, customElement } from '@microsoft/fast-element';
3
- import { GridRegistry, WorkspaceState } from '..';
4
- import { GridRegisterTemplate as template } from './grid-register.template';
5
- const name = 'grid-register';
6
- let GridRegister = class GridRegister extends HTMLElement {
7
- constructor() {
8
- super(...arguments);
9
- this.gridElement = null;
10
- this.gridApi = null;
11
- this.columnApi = null;
12
- this.workspaceSettingsApplied = false;
13
- this.handleGridReady = () => {
14
- this.attachToGridApis();
15
- };
16
- }
17
- connectedCallback() {
18
- this.findAndRegisterGrid();
19
- }
20
- disconnectedCallback() {
21
- if (this.gridKey) {
22
- this.gridRegistry.unregisterGrid(this.gridKey);
23
- }
24
- this.detachFromGridApis();
25
- }
26
- findAndRegisterGrid() {
27
- this.gridElement = this.querySelector('rapid-grid-pro');
28
- if (this.gridElement) {
29
- this.gridElement.addEventListener('gridReady', this.handleGridReady);
30
- this.attachToGridApis();
31
- }
32
- else {
33
- setTimeout(() => {
34
- this.gridElement = this.querySelector('rapid-grid-pro');
35
- if (this.gridElement) {
36
- this.gridElement.addEventListener('gridReady', this.handleGridReady);
37
- this.attachToGridApis();
38
- }
39
- else {
40
- console.warn(`grid-register: rapid-grid-pro element not found`);
41
- }
42
- }, 100);
43
- }
44
- }
45
- attachToGridApis() {
46
- var _a;
47
- if (!this.gridElement) {
48
- return;
49
- }
50
- const anyGrid = this.gridElement;
51
- const gridApi = anyGrid.gridApi || null;
52
- const columnApi = anyGrid.columnApi || null;
53
- const persistKey = ((_a = anyGrid === null || anyGrid === void 0 ? void 0 : anyGrid.getAttribute) === null || _a === void 0 ? void 0 : _a.call(anyGrid, 'persist-column-state-key')) || this.gridKey;
54
- if (!gridApi || this.gridApi === gridApi) {
55
- return;
56
- }
57
- this.gridApi = gridApi;
58
- this.columnApi = columnApi;
59
- const effectiveGridKey = persistKey;
60
- if (!effectiveGridKey) {
61
- console.warn('grid-register: missing persist-column-state-key; grid state will not be saved');
62
- }
63
- else {
64
- this.gridRegistry.registerGrid(effectiveGridKey, gridApi, columnApi);
65
- this.gridKey = effectiveGridKey;
66
- }
67
- if (!this.workspaceSettingsApplied && this.gridApi) {
68
- this.loadWorkspaceColumnState().catch((error) => {
69
- console.warn(`Failed to apply column state for ${this.gridKey} on gridReady:`, error);
70
- });
71
- }
72
- }
73
- detachFromGridApis() {
74
- if (this.gridElement && this.handleGridReady) {
75
- this.gridElement.removeEventListener('gridReady', this.handleGridReady);
76
- }
77
- this.gridElement = null;
78
- this.gridApi = null;
79
- this.columnApi = null;
80
- }
81
- loadWorkspaceSettings(options) {
82
- return __awaiter(this, void 0, void 0, function* () {
83
- if (!this.gridKey || !this.columnApi || !this.gridApi) {
84
- return;
85
- }
86
- try {
87
- const currentWorkspace = this.workspaceState.getCurrentWorkspace();
88
- if (currentWorkspace && currentWorkspace.grids) {
89
- const gridSetting = currentWorkspace.grids.find((g) => g.gridKey === this.gridKey);
90
- if (gridSetting) {
91
- const currentColumnState = this.columnApi.getColumnState() || [];
92
- const targetColumnState = gridSetting.columnState || [];
93
- const columnsEqual = JSON.stringify(currentColumnState) === JSON.stringify(targetColumnState);
94
- const applyColumns = !options || options.applyColumns !== false;
95
- const columnsOk = !applyColumns || columnsEqual;
96
- if (columnsOk) {
97
- return;
98
- }
99
- const applied = yield this.gridRegistry.applyGridSettings(gridSetting, options);
100
- if (!applied) {
101
- console.warn(`Failed to apply grid settings for ${this.gridKey}`);
102
- }
103
- }
104
- }
105
- }
106
- catch (error) {
107
- console.warn(`Failed to load workspace settings for grid ${this.gridKey}:`, error);
108
- }
109
- });
110
- }
111
- loadWorkspaceColumnState() {
112
- return __awaiter(this, void 0, void 0, function* () {
113
- return this.loadWorkspaceSettings({ applyColumns: true });
114
- });
115
- }
116
- };
117
- __decorate([
118
- attr({ attribute: 'grid-key' })
119
- ], GridRegister.prototype, "gridKey", void 0);
120
- __decorate([
121
- GridRegistry
122
- ], GridRegister.prototype, "gridRegistry", void 0);
123
- __decorate([
124
- WorkspaceState
125
- ], GridRegister.prototype, "workspaceState", void 0);
126
- GridRegister = __decorate([
127
- customElement({
128
- name,
129
- template,
130
- })
131
- ], GridRegister);
132
- export { GridRegister };
@@ -1,4 +0,0 @@
1
- import { html } from '@microsoft/fast-element';
2
- export const GridRegisterTemplate = html `
3
- <slot></slot>
4
- `;
@@ -1 +0,0 @@
1
- export * from './grid-register';
@@ -1,113 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { DI } from '@microsoft/fast-foundation';
3
- /**
4
- * @public
5
- */
6
- export class DefaultGridRegistry {
7
- constructor() {
8
- this.grids = new Map();
9
- this.cachedSettings = new Map();
10
- }
11
- // Note: StatePersistence is not wired here to avoid a hard dependency on grid-pro.
12
- registerGrid(gridKey, gridApi, columnApi) {
13
- this.grids.set(gridKey, {
14
- gridKey,
15
- gridApi: gridApi,
16
- columnApi: columnApi,
17
- });
18
- }
19
- getGrid(gridKey) {
20
- return this.grids.get(gridKey) || null;
21
- }
22
- unregisterGrid(gridKey) {
23
- const grid = this.grids.get(gridKey);
24
- if (grid) {
25
- const settings = this.getGridSettings(gridKey, grid);
26
- if (settings) {
27
- this.cachedSettings.set(gridKey, settings);
28
- }
29
- }
30
- this.grids.delete(gridKey);
31
- }
32
- getAllGridsSettings() {
33
- Array.from(this.grids).forEach(([key, grid]) => {
34
- const settings = this.getGridSettings(key, grid);
35
- if (settings) {
36
- this.cachedSettings.set(key, settings);
37
- }
38
- });
39
- return Array.from(this.cachedSettings.values()).filter((s) => !!s);
40
- }
41
- applyGridSettings(gridSetting, options) {
42
- return __awaiter(this, void 0, void 0, function* () {
43
- const gridRegistration = this.grids.get(gridSetting.gridKey);
44
- if (!gridRegistration || !gridRegistration.columnApi || !gridRegistration.gridApi) {
45
- return false;
46
- }
47
- const hasColumnState = gridSetting.columnState && gridSetting.columnState.length > 0;
48
- const applyColumns = !options || options.applyColumns !== false;
49
- const shouldApplyColumns = applyColumns && !!hasColumnState;
50
- if (!shouldApplyColumns) {
51
- // No column state to apply; treat as a no-op.
52
- return false;
53
- }
54
- try {
55
- if (shouldApplyColumns) {
56
- gridRegistration.columnApi.applyColumnState({
57
- state: gridSetting.columnState,
58
- applyOrder: true,
59
- });
60
- }
61
- return true;
62
- }
63
- catch (error) {
64
- // eslint-disable-next-line no-console
65
- console.warn(`Failed to apply settings for grid ${gridSetting.gridKey}:`, error);
66
- return false;
67
- }
68
- });
69
- }
70
- applyAllGridsSettings(gridSettings_1) {
71
- return __awaiter(this, arguments, void 0, function* (gridSettings, maxRetries = 3, delayMs = 200) {
72
- // eslint-disable-next-line no-plusplus
73
- for (let attempt = 0; attempt < maxRetries; attempt++) {
74
- const remainingSettings = [];
75
- for (const gridSetting of gridSettings) {
76
- // eslint-disable-next-line no-await-in-loop
77
- const applied = yield this.applyGridSettings(gridSetting);
78
- if (!applied) {
79
- remainingSettings.push(gridSetting);
80
- }
81
- }
82
- if (remainingSettings.length === 0 || attempt >= maxRetries - 1) {
83
- break;
84
- }
85
- // eslint-disable-next-line no-await-in-loop
86
- // await new Promise((resolve) => setTimeout(resolve, delayMs));
87
- gridSettings = remainingSettings;
88
- }
89
- });
90
- }
91
- getGridSettings(gridKey, grid) {
92
- var _a;
93
- if (grid) {
94
- const columnState = (_a = grid.columnApi) === null || _a === void 0 ? void 0 : _a.getColumnState();
95
- const columnCount = (columnState === null || columnState === void 0 ? void 0 : columnState.length) || 0;
96
- // eslint-disable-next-line no-console
97
- console.log(`Saved grid settings for ${gridKey}: ${columnCount} columns`);
98
- return {
99
- gridKey: grid.gridKey,
100
- columnState: columnState || [],
101
- savedAt: new Date().toISOString(),
102
- };
103
- }
104
- // eslint-disable-next-line no-console
105
- console.warn(`No grid found for ${gridKey}`);
106
- return null;
107
- }
108
- }
109
- /**
110
- * DI token for grid registry.
111
- * @public
112
- */
113
- export const GridRegistry = DI.createInterface((x) => x.singleton(DefaultGridRegistry));
@@ -1,8 +0,0 @@
1
- export * from './workspace.types';
2
- export * from './workspace-state.types';
3
- export * from './workspace-state';
4
- export * from './layout-registry';
5
- export * from './grid-registry';
6
- export * from './filter-registry';
7
- export * from './grid-register';
8
- export * from './layout-wrapper';
@@ -1,46 +0,0 @@
1
- import { __awaiter } from "tslib";
2
- import { DI } from '@microsoft/fast-foundation';
3
- /**
4
- * Default layout registry implementation.
5
- * @public
6
- */
7
- export class DefaultLayoutRegistry {
8
- constructor() {
9
- this.layouts = new Map();
10
- }
11
- registerLayout(layoutKey, layout) {
12
- if (!layoutKey) {
13
- return;
14
- }
15
- this.layouts.set(layoutKey, layout);
16
- }
17
- unregisterLayout(layoutKey) {
18
- this.layouts.delete(layoutKey);
19
- }
20
- getLayoutsConfigs() {
21
- return Array.from(this.layouts).map(([key, layout]) => ({
22
- layoutKey: key,
23
- layout: layout.getLayout(),
24
- }));
25
- }
26
- applySavedLayouts(savedLayouts) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- savedLayouts.forEach((s) => {
29
- const layout = this.layouts.get(s.layoutKey);
30
- if (layout) {
31
- layout.loadLayout(s.layout, 'placeholder', true);
32
- }
33
- else {
34
- // eslint-disable-next-line no-console
35
- console.warn(`layout for ${s.layoutKey} not found`);
36
- }
37
- });
38
- // await new Promise((resolve) => setTimeout(resolve, 300));
39
- });
40
- }
41
- }
42
- /**
43
- * DI token for layout registry.
44
- * @public
45
- */
46
- export const LayoutRegistry = DI.createInterface((x) => x.singleton(DefaultLayoutRegistry));
@@ -1 +0,0 @@
1
- export * from './layout-wrapper';
@@ -1,60 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { attr, customElement } from '@microsoft/fast-element';
3
- import { LayoutRegistry } from '..';
4
- import { LayoutWrapperTemplate as template } from './layout-wrapper.template';
5
- const name = 'layout-register';
6
- let LayoutWrapper = class LayoutWrapper extends HTMLElement {
7
- constructor() {
8
- super(...arguments);
9
- this.layoutElement = null;
10
- }
11
- connectedCallback() {
12
- this.findAndRegisterLayout();
13
- }
14
- disconnectedCallback() {
15
- var _a, _b, _c, _d, _e;
16
- const layoutKey = (_e = (_b = (_a = this.layoutElement) === null || _a === void 0 ? void 0 : _a.autoSaveKey) !== null && _b !== void 0 ? _b : (_d = (_c = this.layoutElement) === null || _c === void 0 ? void 0 : _c.getAttribute) === null || _d === void 0 ? void 0 : _d.call(_c, 'auto-save-key')) !== null && _e !== void 0 ? _e : this.layoutKey;
17
- if (layoutKey) {
18
- this.layoutRegistry.unregisterLayout(layoutKey);
19
- }
20
- }
21
- findAndRegisterLayout() {
22
- let layoutElement = this.querySelector('rapid-layout');
23
- const registerLayout = (layout) => {
24
- var _a, _b, _c;
25
- if (!layout) {
26
- console.warn(`layout-register: rapid-layout element not found`);
27
- return;
28
- }
29
- this.layoutElement = layout;
30
- const layoutKeyFromLayout = (_c = (_a = layout.autoSaveKey) !== null && _a !== void 0 ? _a : (_b = layout.getAttribute) === null || _b === void 0 ? void 0 : _b.call(layout, 'auto-save-key')) !== null && _c !== void 0 ? _c : this.layoutKey;
31
- if (!layoutKeyFromLayout) {
32
- console.warn('layout-register: missing layout key (auto-save-key/layout-key)');
33
- return;
34
- }
35
- this.layoutRegistry.registerLayout(layoutKeyFromLayout, layout);
36
- };
37
- if (layoutElement) {
38
- registerLayout(layoutElement);
39
- }
40
- else {
41
- setTimeout(() => {
42
- layoutElement = this.querySelector('rapid-layout');
43
- registerLayout(layoutElement);
44
- }, 100);
45
- }
46
- }
47
- };
48
- __decorate([
49
- attr({ attribute: 'layout-key' })
50
- ], LayoutWrapper.prototype, "layoutKey", void 0);
51
- __decorate([
52
- LayoutRegistry
53
- ], LayoutWrapper.prototype, "layoutRegistry", void 0);
54
- LayoutWrapper = __decorate([
55
- customElement({
56
- name,
57
- template,
58
- })
59
- ], LayoutWrapper);
60
- export { LayoutWrapper };
@@ -1,4 +0,0 @@
1
- import { html } from '@microsoft/fast-element';
2
- export const LayoutWrapperTemplate = html `
3
- <slot></slot>
4
- `;
@@ -1,193 +0,0 @@
1
- import { __awaiter, __decorate, __param } from "tslib";
2
- import { Auth, KVStorage, } from '@genesislcap/foundation-comms';
3
- import { DI } from '@microsoft/fast-foundation';
4
- /**
5
- * Default workspace persistence implementation backed by KVStorage.
6
- *
7
- * @public
8
- */
9
- let DefaultWorkspaceState = class DefaultWorkspaceState {
10
- constructor(kvStorage, auth) {
11
- this.kvStorage = kvStorage;
12
- this.auth = auth;
13
- this.STORAGE_PREFIX = 'workspace_';
14
- this.WORKSPACES_LIST_KEY = 'workspaces_list';
15
- this.currentWorkspace = null;
16
- }
17
- getCurrentUsername() {
18
- var _a, _b;
19
- return ((_b = (_a = this.auth) === null || _a === void 0 ? void 0 : _a.loggedUserResult) === null || _b === void 0 ? void 0 : _b.username) || 'anonymous';
20
- }
21
- getWorkspaceStorageKey(workspaceName) {
22
- const username = this.getCurrentUsername();
23
- return `${this.STORAGE_PREFIX}${username}_${workspaceName}`;
24
- }
25
- getWorkspacesListKey() {
26
- const username = this.getCurrentUsername();
27
- return `${this.STORAGE_PREFIX}${username}_${this.WORKSPACES_LIST_KEY}`;
28
- }
29
- saveWorkspace(workspaceName, layouts, grids, filters, description) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const storageKey = this.getWorkspaceStorageKey(workspaceName);
32
- const username = this.getCurrentUsername();
33
- const workspace = {
34
- name: workspaceName,
35
- username,
36
- description: (description === null || description === void 0 ? void 0 : description.trim()) || undefined,
37
- layouts,
38
- grids,
39
- filters,
40
- savedAt: new Date().toISOString(),
41
- };
42
- yield this.kvStorage.put([
43
- {
44
- key: storageKey,
45
- value: JSON.stringify(workspace),
46
- },
47
- ]);
48
- yield this.updateWorkspacesList(workspaceName);
49
- });
50
- }
51
- loadWorkspace(workspaceName) {
52
- return __awaiter(this, void 0, void 0, function* () {
53
- const workspace = yield this.getWorkspace(workspaceName);
54
- this.currentWorkspace = workspace !== null && workspace !== void 0 ? workspace : null;
55
- return this.currentWorkspace;
56
- });
57
- }
58
- getWorkspace(workspaceName) {
59
- return __awaiter(this, void 0, void 0, function* () {
60
- var _a;
61
- const storageKey = this.getWorkspaceStorageKey(workspaceName);
62
- const existing = yield this.kvStorage.get(storageKey);
63
- if (!((_a = existing === null || existing === void 0 ? void 0 : existing.kv) === null || _a === void 0 ? void 0 : _a.value)) {
64
- return null;
65
- }
66
- try {
67
- const workspace = typeof existing.kv.value === 'string' ? JSON.parse(existing.kv.value) : existing.kv.value;
68
- const currentUsername = this.getCurrentUsername();
69
- if (workspace.username && workspace.username !== currentUsername) {
70
- console.warn(`Workspace ${workspaceName} does not belong to current user`);
71
- return null;
72
- }
73
- if (!workspace.username) {
74
- workspace.username = currentUsername;
75
- }
76
- return workspace || null;
77
- }
78
- catch (e) {
79
- console.warn('Failed to parse saved workspace', e);
80
- return null;
81
- }
82
- });
83
- }
84
- getCurrentWorkspace() {
85
- return this.currentWorkspace;
86
- }
87
- setCurrentWorkspace(workspace) {
88
- this.currentWorkspace = workspace;
89
- }
90
- getSavedWorkspaces() {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- var _a;
93
- const listKey = this.getWorkspaceStorageKey(this.WORKSPACES_LIST_KEY);
94
- const existing = yield this.kvStorage.get(listKey);
95
- if (!((_a = existing === null || existing === void 0 ? void 0 : existing.kv) === null || _a === void 0 ? void 0 : _a.value)) {
96
- return [];
97
- }
98
- try {
99
- const workspaceNames = typeof existing.kv.value === 'string' ? JSON.parse(existing.kv.value) : existing.kv.value;
100
- if (!Array.isArray(workspaceNames)) {
101
- return [];
102
- }
103
- const workspaces = [];
104
- const currentUsername = this.getCurrentUsername();
105
- for (const name of workspaceNames) {
106
- // eslint-disable-next-line no-await-in-loop
107
- const workspace = yield this.getWorkspace(name);
108
- if (workspace && (!workspace.username || workspace.username === currentUsername)) {
109
- workspaces.push(workspace);
110
- }
111
- }
112
- return workspaces;
113
- }
114
- catch (e) {
115
- console.warn('Failed to parse saved workspaces list', e);
116
- return [];
117
- }
118
- });
119
- }
120
- deleteWorkspace(workspaceName) {
121
- return __awaiter(this, void 0, void 0, function* () {
122
- const storageKey = this.getWorkspaceStorageKey(workspaceName);
123
- yield this.kvStorage.delete([storageKey]);
124
- yield this.removeFromWorkspacesList(workspaceName);
125
- });
126
- }
127
- updateWorkspacesList(workspaceName) {
128
- return __awaiter(this, void 0, void 0, function* () {
129
- var _a;
130
- const listKey = this.getWorkspacesListKey();
131
- const existing = yield this.kvStorage.get(listKey);
132
- let workspaceNames = [];
133
- if ((_a = existing === null || existing === void 0 ? void 0 : existing.kv) === null || _a === void 0 ? void 0 : _a.value) {
134
- try {
135
- workspaceNames =
136
- typeof existing.kv.value === 'string' ? JSON.parse(existing.kv.value) : existing.kv.value;
137
- }
138
- catch (e) {
139
- console.warn('Failed to parse workspaces list', e);
140
- }
141
- }
142
- workspaceNames = workspaceNames.filter((name) => name !== workspaceName);
143
- workspaceNames.push(workspaceName);
144
- yield this.kvStorage.put([
145
- {
146
- key: listKey,
147
- value: JSON.stringify(workspaceNames),
148
- },
149
- ]);
150
- });
151
- }
152
- removeFromWorkspacesList(workspaceName) {
153
- return __awaiter(this, void 0, void 0, function* () {
154
- var _a;
155
- const listKey = this.getWorkspacesListKey();
156
- const existing = yield this.kvStorage.get(listKey);
157
- if (!((_a = existing === null || existing === void 0 ? void 0 : existing.kv) === null || _a === void 0 ? void 0 : _a.value)) {
158
- return;
159
- }
160
- let workspaceNames = [];
161
- try {
162
- workspaceNames =
163
- typeof existing.kv.value === 'string' ? JSON.parse(existing.kv.value) : existing.kv.value;
164
- }
165
- catch (e) {
166
- console.warn('Failed to parse workspaces list for deletion', e);
167
- return;
168
- }
169
- workspaceNames = workspaceNames.filter((name) => name !== workspaceName);
170
- if (workspaceNames.length === 0) {
171
- yield this.kvStorage.delete([listKey]);
172
- }
173
- else {
174
- yield this.kvStorage.put([
175
- {
176
- key: listKey,
177
- value: JSON.stringify(workspaceNames),
178
- },
179
- ]);
180
- }
181
- });
182
- }
183
- };
184
- DefaultWorkspaceState = __decorate([
185
- __param(0, KVStorage),
186
- __param(1, Auth)
187
- ], DefaultWorkspaceState);
188
- export { DefaultWorkspaceState };
189
- /**
190
- * DI token for workspace state.
191
- * @public
192
- */
193
- export const WorkspaceState = DI.createInterface((x) => x.singleton(DefaultWorkspaceState));
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * from './workspace-manager';