@owdproject/core 3.4.0 → 4.0.0-alpha.3

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 (108) hide show
  1. package/README.md +112 -13
  2. package/dist/dom/index.d.mts +65 -0
  3. package/dist/dom/index.d.ts +65 -0
  4. package/dist/dom/index.mjs +224 -0
  5. package/dist/events/index.d.mts +70 -0
  6. package/dist/events/index.d.ts +70 -0
  7. package/dist/events/index.mjs +3 -0
  8. package/dist/index.d.mts +73 -0
  9. package/dist/index.d.ts +73 -0
  10. package/dist/index.mjs +115 -0
  11. package/dist/layout/index.d.mts +41 -0
  12. package/dist/layout/index.d.ts +41 -0
  13. package/dist/layout/index.mjs +64 -0
  14. package/dist/machines/index.d.mts +31 -0
  15. package/dist/machines/index.d.ts +31 -0
  16. package/dist/machines/index.mjs +2 -0
  17. package/dist/managers/index.d.mts +117 -0
  18. package/dist/managers/index.d.ts +117 -0
  19. package/dist/managers/index.mjs +6 -0
  20. package/dist/session/index.d.mts +57 -0
  21. package/dist/session/index.d.ts +57 -0
  22. package/dist/session/index.mjs +65 -0
  23. package/dist/shared/core.B0B0KfVK.mjs +865 -0
  24. package/dist/shared/core.B1XxB289.mjs +239 -0
  25. package/dist/shared/core.B3mp7ztE.mjs +237 -0
  26. package/dist/shared/core.BOvFdEVQ.d.ts +114 -0
  27. package/dist/shared/core.CsDFgGnX.mjs +40 -0
  28. package/dist/shared/core.Di1eFcr_.d.mts +114 -0
  29. package/dist/shared/core.Pd_Ogt4g.mjs +101 -0
  30. package/dist/shared/core.b3Xldzyu.mjs +29 -0
  31. package/dist/types/index.d.mts +266 -0
  32. package/dist/types/index.d.ts +266 -0
  33. package/dist/types/index.mjs +1 -0
  34. package/package.json +56 -112
  35. package/CHANGELOG.md +0 -98
  36. package/DESKTOP_KERNEL.md +0 -232
  37. package/MIGRATION_3.3.2.md +0 -23
  38. package/MIGRATION_3.4.md +0 -126
  39. package/PLAYGROUND.md +0 -91
  40. package/dist/module.d.mts +0 -13
  41. package/dist/module.json +0 -9
  42. package/dist/module.mjs +0 -254
  43. package/dist/types.d.mts +0 -7
  44. package/index.ts +0 -8
  45. package/kit/authoring.ts +0 -340
  46. package/kit/defineDesktopApp.ts +0 -56
  47. package/module.ts +0 -203
  48. package/runtime/components/Application/DesktopCoreApplicationRender.vue +0 -20
  49. package/runtime/components/Application/DesktopCoreApplicationWindowsRender.vue +0 -38
  50. package/runtime/components/background/DesktopCoreBackground.vue +0 -16
  51. package/runtime/components/core/DesktopCore.vue +0 -43
  52. package/runtime/components/time/DesktopCoreTime.vue +0 -56
  53. package/runtime/components/window/DesktopCoreWindow.vue +0 -215
  54. package/runtime/components/window/DesktopCoreWindowContent.vue +0 -28
  55. package/runtime/components/window/DesktopCoreWindowNav.vue +0 -66
  56. package/runtime/components/window/DesktopCoreWindowSnapHintsBase.vue +0 -74
  57. package/runtime/components/workspace/DesktopCoreWorkspaceEdgeHintsBase.vue +0 -84
  58. package/runtime/composables/useApplicationEntries.ts +0 -51
  59. package/runtime/composables/useApplicationManager.ts +0 -285
  60. package/runtime/composables/useBlockNonInputContextMenu.ts +0 -30
  61. package/runtime/composables/useDesktopConfig.ts +0 -8
  62. package/runtime/composables/useDesktopDialogs.ts +0 -16
  63. package/runtime/composables/useDesktopExtension.ts +0 -8
  64. package/runtime/composables/useDesktopManager.ts +0 -51
  65. package/runtime/composables/useDesktopManifest.ts +0 -17
  66. package/runtime/composables/useDesktopSession.ts +0 -27
  67. package/runtime/composables/useDesktopShellIdentity.ts +0 -99
  68. package/runtime/composables/useDesktopShellOptions.ts +0 -36
  69. package/runtime/composables/useDesktopShellReady.ts +0 -7
  70. package/runtime/composables/useDesktopWorkArea.ts +0 -93
  71. package/runtime/composables/useTerminalManager.ts +0 -159
  72. package/runtime/composables/useToggleWindowMaximize.ts +0 -35
  73. package/runtime/composables/useWindowDragHandlers.ts +0 -47
  74. package/runtime/composables/useWindowSnapDrop.ts +0 -112
  75. package/runtime/composables/useWorkspaceEdgeDrop.ts +0 -176
  76. package/runtime/composables/useWorkspaceManager.ts +0 -67
  77. package/runtime/composables/useWorkspaceOverviewCapture.ts +0 -92
  78. package/runtime/composables/useWorkspaceOverviewLiveScale.ts +0 -151
  79. package/runtime/constants/desktopShellKeys.ts +0 -12
  80. package/runtime/constants/shellLayout.ts +0 -5
  81. package/runtime/dialogs/desktopDialogProvider.ts +0 -73
  82. package/runtime/internal/controllers/ApplicationController.ts +0 -351
  83. package/runtime/internal/controllers/WindowController.ts +0 -547
  84. package/runtime/plugins/01.desktop-shell-init.client.ts +0 -28
  85. package/runtime/plugins/02.desktop-register-desktop-apps.client.ts +0 -13
  86. package/runtime/plugins/resize.client.ts +0 -6
  87. package/runtime/stores/storeApplicationMeta.ts +0 -60
  88. package/runtime/stores/storeApplicationWindows.ts +0 -21
  89. package/runtime/stores/storeDesktop.ts +0 -71
  90. package/runtime/stores/storeDesktopDefaultApps.ts +0 -54
  91. package/runtime/stores/storeDesktopVolume.ts +0 -19
  92. package/runtime/stores/storeDesktopWindow.ts +0 -38
  93. package/runtime/stores/storeDesktopWorkspace.ts +0 -105
  94. package/runtime/stores/storeIds.ts +0 -35
  95. package/runtime/types/desktopMenu.ts +0 -10
  96. package/runtime/utils/initDesktopShell.ts +0 -80
  97. package/runtime/utils/migratePersistedStoreIds.ts +0 -57
  98. package/runtime/utils/utilApp.ts +0 -25
  99. package/runtime/utils/utilCaptureElementToCanvas.ts +0 -21
  100. package/runtime/utils/utilCommon.ts +0 -26
  101. package/runtime/utils/utilDebug.ts +0 -30
  102. package/runtime/utils/utilDetectSnapZone.ts +0 -57
  103. package/runtime/utils/utilTerminal.ts +0 -6
  104. package/runtime/utils/utilWindowControllerAdapter.ts +0 -15
  105. package/runtime/utils/utilWindowLayout.ts +0 -82
  106. package/runtime/utils/utilWindowMaximizeLayout.ts +0 -44
  107. package/runtime/utils/utilWorkspaceWindows.ts +0 -33
  108. package/types/index.d.ts +0 -531
@@ -1,547 +0,0 @@
1
- import { useApplicationManager } from '../../composables/useApplicationManager'
2
- import { useDesktopWindowStore } from '../../stores/storeDesktopWindow'
3
- import { deepClone } from '../../utils/utilCommon'
4
- import { markRaw, reactive } from '@vue/reactivity'
5
- import { defineAsyncComponent } from 'vue'
6
-
7
- export class WindowController implements IWindowController {
8
- public readonly application: IApplicationController
9
-
10
- public readonly instanced: boolean = true
11
- public readonly model: string
12
-
13
- public config: WindowConfig = {
14
- title: '',
15
- category: '',
16
-
17
- component: undefined,
18
-
19
- // position
20
- position: {
21
- x: 0,
22
- y: 0,
23
- z: 0,
24
- },
25
-
26
- // sizes
27
- size: {
28
- width: undefined,
29
- height: undefined,
30
- },
31
-
32
- // minimize
33
- minimizable: true,
34
-
35
- // maximize
36
- maximized: false,
37
- maximizable: false,
38
-
39
- // destroy
40
- destroyable: true,
41
-
42
- // draggable
43
- draggable: true,
44
-
45
- // resizable
46
- resizable: true,
47
- }
48
-
49
- public override: WindowOverride = reactive({})
50
-
51
- private storedState: WindowStoredState
52
-
53
- constructor(
54
- application: IApplicationController,
55
- model: string,
56
- windowConfig: WindowConfig,
57
- windowStoredState: WindowStoredState,
58
- ) {
59
- this.application = application
60
- this.model = model
61
-
62
- this.storedState = windowStoredState
63
-
64
- this.setConfig(windowConfig)
65
-
66
- this.restoreState()
67
- }
68
-
69
- private setConfig(config: WindowConfig) {
70
- // component
71
- if (config.component) {
72
- this.config.component = markRaw(defineAsyncComponent(config.component))
73
- }
74
-
75
- // title
76
- if (config.title) this.config.title = config.title
77
- if (config.icon) this.config.icon = config.icon
78
-
79
- // position
80
- if (!this.config.position) this.config.position = { x: 0, y: 0, z: 0 }
81
- if (config.position?.x) this.config.position.x = config.position.x
82
- if (config.position?.y) this.config.position.y = config.position.y
83
- if (config.position?.z) this.config.position.z = config.position.z
84
-
85
- // sizes
86
- if (config.size?.width) this.config.size.width = config.size.width
87
- if (config.size?.height) this.config.size.height = config.size.height
88
- if (config.size?.minWidth) this.config.size.minWidth = config.size.minWidth
89
- if (config.size?.minHeight)
90
- this.config.size.minHeight = config.size.minHeight
91
- if (config.size?.maxWidth) this.config.size.maxWidth = config.size.maxWidth
92
- if (config.size?.maxHeight)
93
- this.config.size.maxHeight = config.size.maxHeight
94
-
95
- // minimize
96
- if (typeof config.minimizable !== 'undefined') {
97
- this.config.minimizable = config.minimizable
98
- }
99
- if (typeof config.maximizable !== 'undefined') {
100
- this.config.maximizable = config.maximizable
101
- }
102
-
103
- // maximize
104
- if (typeof config.maximized !== 'undefined') {
105
- this.config.maximized = config.maximized
106
- }
107
-
108
- // draggable
109
- if (typeof config.draggable !== 'undefined') {
110
- this.config.draggable = config.draggable
111
- }
112
-
113
- // resizable
114
- if (typeof config.resizable !== 'undefined') {
115
- this.config.resizable = config.resizable
116
- }
117
-
118
- // destroy
119
- if (typeof config.destroyable !== 'undefined') {
120
- this.config.destroyable = config.destroyable
121
- }
122
-
123
- const DEFAULT_OVERRIDABLE = {
124
- draggable: true,
125
- resizable: false,
126
- position: false,
127
- size: false,
128
- maximized: false,
129
- destroyable: false,
130
- minimizable: false,
131
- maximizable: false,
132
- }
133
-
134
- DEFAULT_OVERRIDABLE.position = DEFAULT_OVERRIDABLE.draggable
135
- DEFAULT_OVERRIDABLE.size = DEFAULT_OVERRIDABLE.resizable
136
- DEFAULT_OVERRIDABLE.maximized = DEFAULT_OVERRIDABLE.maximizable
137
-
138
- this.config.overridable = {
139
- ...DEFAULT_OVERRIDABLE,
140
- ...(config.overridable || {}),
141
- }
142
- }
143
-
144
- // state
145
-
146
- get state() {
147
- return this.storedState.state
148
- }
149
-
150
- private restoreState() {
151
- const overridable = this.config.overridable || {}
152
-
153
- for (const key in overridable) {
154
- if (overridable[key as keyof typeof overridable]) {
155
- const stateKey = key as keyof WindowState
156
-
157
- if (typeof this.state[stateKey] === 'undefined') {
158
- if (typeof this.config[stateKey] === 'object') {
159
- this.state[stateKey] = deepClone(this.config[stateKey])
160
- } else {
161
- this.state[stateKey] = !!this.config[stateKey]
162
- }
163
- }
164
- }
165
- }
166
- }
167
-
168
- private setState(state: WindowState) {
169
- this.storedState.state = state
170
- }
171
-
172
- // meta
173
-
174
- get meta() {
175
- return this.storedState.meta
176
- }
177
-
178
- // position
179
-
180
- public setPosition(data: { x: number; y: number }) {
181
- if (!this.state.position) {
182
- this.state.position = { x: 0, y: 0 }
183
- }
184
-
185
- this.state.position.x = data.x
186
- this.state.position.y = data.y
187
- }
188
-
189
- public setActive(value: boolean) {
190
- this.state.active = value
191
- }
192
-
193
- public setFocus(value: boolean) {
194
- this.state.focused = value
195
- }
196
-
197
- public focus() {
198
- const applicationManager = useApplicationManager()
199
- const desktopWindowStore = useDesktopWindowStore()
200
-
201
- if (!this.state.position) {
202
- this.state.position = { x: 0, y: 0, z: 0 }
203
- }
204
-
205
- for (const window of applicationManager.windowsOpened.value.values()) {
206
- if (window !== this) {
207
- window.setFocus(false)
208
- }
209
- }
210
-
211
- this.setFocus(true)
212
- this.state.position.z = desktopWindowStore.incrementPositionZ()
213
- }
214
-
215
- // common
216
-
217
- get title(): string {
218
- if (typeof this.override.title !== 'undefined') {
219
- return this.override.title
220
- }
221
-
222
- if (this.config.title) {
223
- return this.config.title
224
- }
225
-
226
- return this.application.config.title
227
- }
228
-
229
- get windowTitle(): string {
230
- if (typeof this.override.windowTitle !== 'undefined') {
231
- return this.override.windowTitle
232
- }
233
-
234
- return this.title
235
- }
236
-
237
- get icon() {
238
- if (typeof this.override.icon !== 'undefined') {
239
- return this.override.icon
240
- }
241
-
242
- if (this.config.icon) {
243
- return this.config.icon
244
- }
245
-
246
- return this.application.config.icon
247
- }
248
-
249
- // position
250
-
251
- get position() {
252
- if (typeof this.state.position === 'undefined') {
253
- return this.config.position
254
- }
255
-
256
- return this.state.position
257
- }
258
-
259
- // sizes
260
-
261
- get size() {
262
- const stateSize = this.state.size || {}
263
- const configSize = this.config.size || {}
264
-
265
- return {
266
- width:
267
- typeof stateSize.width !== 'undefined'
268
- ? stateSize.width
269
- : configSize.width,
270
- height:
271
- typeof stateSize.height !== 'undefined'
272
- ? stateSize.height
273
- : configSize.height,
274
- minWidth:
275
- typeof stateSize.minWidth !== 'undefined'
276
- ? stateSize.minWidth
277
- : configSize.minWidth,
278
- maxWidth:
279
- typeof stateSize.maxWidth !== 'undefined'
280
- ? stateSize.maxWidth
281
- : configSize.maxWidth,
282
- minHeight:
283
- typeof stateSize.minHeight !== 'undefined'
284
- ? stateSize.minHeight
285
- : configSize.minHeight,
286
- maxHeight:
287
- typeof stateSize.maxHeight !== 'undefined'
288
- ? stateSize.maxHeight
289
- : configSize.maxHeight,
290
- }
291
- }
292
-
293
- public setSize(data: { width: number; height: number }) {
294
- if (!this.state.size) {
295
- this.state.size = { width: undefined, height: undefined }
296
- }
297
-
298
- this.state.size.width = data.width
299
- this.state.size.height = data.height
300
- }
301
-
302
- // minimize
303
-
304
- get isMinimizable() {
305
- if (this.config.overridable?.minimizable) {
306
- return !!this.state.minimizable
307
- }
308
-
309
- return !!this.config.minimizable
310
- }
311
-
312
- public minimize() {
313
- if (!this.isMinimizable) {
314
- return false
315
- }
316
-
317
- this.state.active = false
318
- return true
319
- }
320
-
321
- public unminimize() {
322
- this.state.active = true
323
- return true
324
- }
325
-
326
- public toggleMinimize() {
327
- this.state.active = !this.state.active
328
- this.focus()
329
- }
330
-
331
- // maximize
332
-
333
- get isMaximizable() {
334
- if (typeof this.state.maximizable === 'undefined') {
335
- return !!this.config.maximizable
336
- }
337
-
338
- return this.state.maximizable
339
- }
340
-
341
- get isMaximized() {
342
- if (this.state.layout === 'maximize') {
343
- return true
344
- }
345
-
346
- if (this.config.overridable?.maximized) {
347
- return !!this.state.maximized
348
- }
349
-
350
- return !!this.config.maximized
351
- }
352
-
353
- private parseSizeValue(value: WindowSizeValue | undefined, fallback: number): number {
354
- if (typeof value === 'number') {
355
- return value
356
- }
357
- if (typeof value === 'string') {
358
- const parsed = Number.parseFloat(value)
359
- if (!Number.isNaN(parsed)) {
360
- return parsed
361
- }
362
- }
363
- return fallback
364
- }
365
-
366
- public saveBoundsBeforeLayout() {
367
- if (this.state.layout && this.state.layout !== 'normal') {
368
- return
369
- }
370
-
371
- const pos = this.position
372
- const size = this.size
373
-
374
- this.state.boundsBeforeLayout = {
375
- x: pos?.x ?? 0,
376
- y: pos?.y ?? 0,
377
- width: this.parseSizeValue(size.width, 400),
378
- height: this.parseSizeValue(size.height, 300),
379
- }
380
- }
381
-
382
- public setLayout(layout: WindowLayout) {
383
- if (layout === 'normal') {
384
- return this.clearLayout()
385
- }
386
-
387
- if (!this.isMaximizable) {
388
- return false
389
- }
390
-
391
- this.saveBoundsBeforeLayout()
392
- this.state.layout = layout
393
- this.state.maximized = layout === 'maximize'
394
- return true
395
- }
396
-
397
- public clearLayout() {
398
- const bounds = this.state.boundsBeforeLayout
399
- if (bounds) {
400
- this.setPosition({ x: bounds.x, y: bounds.y })
401
- this.setSize({ width: bounds.width, height: bounds.height })
402
- delete this.state.boundsBeforeLayout
403
- }
404
-
405
- this.state.layout = 'normal'
406
- this.state.maximized = false
407
- return true
408
- }
409
-
410
- public toggleMaximize() {
411
- if (!this.isMaximizable) {
412
- return false
413
- }
414
-
415
- if (this.isMaximized) {
416
- return this.clearLayout()
417
- }
418
-
419
- return this.setLayout('maximize')
420
- }
421
-
422
- public maximize() {
423
- if (!this.isMaximizable) {
424
- return false
425
- }
426
-
427
- return this.setLayout('maximize')
428
- }
429
-
430
- public unmaximize() {
431
- if (!this.isMaximizable) {
432
- return false
433
- }
434
-
435
- return this.clearLayout()
436
- }
437
-
438
- // destroy
439
-
440
- get isDestroyable() {
441
- if (this.config.overridable?.destroyable) {
442
- return !!this.state.destroyable
443
- }
444
-
445
- return !!this.config.destroyable
446
- }
447
-
448
- public destroy() {
449
- if (!this.isDestroyable) {
450
- return false
451
- }
452
-
453
- this.application.closeWindow(this.state.id)
454
-
455
- return true
456
- }
457
-
458
- // draggable
459
- get isDraggable() {
460
- if (this.config.overridable?.draggable) {
461
- return !!this.state.draggable
462
- }
463
-
464
- return !!this.config.draggable
465
- }
466
-
467
- // resizable
468
- get isResizable() {
469
- if (this.config.overridable?.resizable) {
470
- return !!this.state.resizable
471
- }
472
-
473
- return !!this.config.resizable
474
- }
475
-
476
- // workspace
477
- public setWorkspace(workspaceId: string) {
478
- this.state.workspace = workspaceId
479
- }
480
-
481
- // override
482
-
483
- public setTitleOverride(value: undefined | string) {
484
- this.override.title = value
485
- }
486
-
487
- public resetTitleOverride() {
488
- this.override.title = undefined
489
- }
490
-
491
- public setWindowTitleOverride(value: undefined | string) {
492
- this.override.windowTitle = value
493
- }
494
-
495
- public resetWindowTitleOverride() {
496
- this.override.windowTitle = undefined
497
- }
498
-
499
- // menu
500
-
501
- public menu: any[] = []
502
-
503
- public setMenu(menu: any[]) {
504
- this.menu = menu
505
- }
506
-
507
- // deprecated ?
508
- get actions() {
509
- return {
510
- // position
511
- setActive: this.setActive.bind(this),
512
- setFocus: this.setFocus.bind(this),
513
- bringToFront: this.focus.bind(this),
514
- focus: this.focus.bind(this),
515
- setPosition: this.setPosition.bind(this),
516
-
517
- // size
518
- setSize: this.setSize.bind(this),
519
-
520
- // minimize
521
- minimize: this.minimize.bind(this),
522
- toggleMinimize: this.toggleMinimize.bind(this),
523
-
524
- // maximize
525
- toggleMaximize: this.toggleMaximize.bind(this),
526
- maximize: this.maximize.bind(this),
527
- unmaximize: this.unmaximize.bind(this),
528
-
529
- // layout
530
- setLayout: this.setLayout.bind(this),
531
- clearLayout: this.clearLayout.bind(this),
532
- saveBoundsBeforeLayout: this.saveBoundsBeforeLayout.bind(this),
533
-
534
- // destroy
535
- destroy: this.destroy.bind(this),
536
-
537
- // workspace
538
- setWorkspace: this.setWorkspace.bind(this),
539
-
540
- // override
541
- setTitleOverride: this.setTitleOverride.bind(this),
542
- resetTitleOverride: this.resetTitleOverride.bind(this),
543
- setWindowTitleOverride: this.setWindowTitleOverride.bind(this),
544
- resetWindowTitleOverride: this.resetWindowTitleOverride.bind(this),
545
- }
546
- }
547
- }
@@ -1,28 +0,0 @@
1
- import { defineNuxtPlugin } from 'nuxt/app'
2
- import {
3
- bindDesktopPinia,
4
- initDesktopShell,
5
- syncDesktopShellAppConfig,
6
- } from '../utils/initDesktopShell'
7
- import { migratePersistedStoreIds } from '../utils/migratePersistedStoreIds'
8
-
9
- export default defineNuxtPlugin({
10
- name: 'desktop-shell-init',
11
- dependsOn: ['pinia'],
12
- enforce: 'pre',
13
- setup(nuxtApp) {
14
- migratePersistedStoreIds()
15
- bindDesktopPinia(nuxtApp.$pinia)
16
- initDesktopShell()
17
-
18
- nuxtApp.hook('app:created', () => {
19
- syncDesktopShellAppConfig()
20
- })
21
-
22
- return {
23
- provide: {
24
- desktopShellReady: true,
25
- },
26
- }
27
- },
28
- })
@@ -1,13 +0,0 @@
1
- import { defineNuxtPlugin } from 'nuxt/app'
2
- import { flushPendingDesktopApps } from '../../kit/defineDesktopApp'
3
-
4
- export default defineNuxtPlugin({
5
- name: 'desktop-register-desktop-apps',
6
- dependsOn: ['pinia', 'desktop-shell-init'],
7
- enforce: 'post',
8
- setup(nuxtApp) {
9
- nuxtApp.hook('app:created', async () => {
10
- await flushPendingDesktopApps()
11
- })
12
- },
13
- })
@@ -1,6 +0,0 @@
1
- import VueResizable from 'vue-resizable/src/components/vue-resizable.vue'
2
- import { defineNuxtPlugin } from 'nuxt/app'
3
-
4
- export default defineNuxtPlugin((nuxtApp) => {
5
- nuxtApp.vueApp.component('vue-resizable', VueResizable)
6
- })
@@ -1,60 +0,0 @@
1
- import { defineStore } from 'pinia'
2
- import { ref } from 'vue'
3
- import { applicationMetaStoreId } from './storeIds'
4
-
5
- const metaStoreRegistry = new Map<string, ReturnType<typeof defineStore>>()
6
- /** Store ids created by the generic fallback (only `meta`), replaceable when an app registers real state. */
7
- const fallbackMetaStoreIds = new Set<string>()
8
-
9
- type MetaStoreSetup = (() => Record<string, unknown>) | Record<string, unknown>
10
-
11
- function resolveSetup(states: MetaStoreSetup) {
12
- return typeof states === 'function' ? states : () => states
13
- }
14
-
15
- /**
16
- * Per-app Pinia meta store factory. The first registration for an app id wins so
17
- * app modules should call this from their store module (imported in the app plugin
18
- * before `defineDesktopApp`).
19
- */
20
- export const useApplicationMetaStore = (
21
- appId: string,
22
- states?: MetaStoreSetup,
23
- ) => {
24
- const id = applicationMetaStoreId(appId)
25
-
26
- if (
27
- states !== undefined &&
28
- (!metaStoreRegistry.has(id) || fallbackMetaStoreIds.has(id))
29
- ) {
30
- fallbackMetaStoreIds.delete(id)
31
- metaStoreRegistry.set(
32
- id,
33
- defineStore(id, resolveSetup(states), {
34
- persistedState: {
35
- persist: true,
36
- },
37
- }),
38
- )
39
- }
40
-
41
- if (!metaStoreRegistry.has(id)) {
42
- fallbackMetaStoreIds.add(id)
43
- metaStoreRegistry.set(
44
- id,
45
- defineStore(
46
- id,
47
- () => ({
48
- meta: ref<Record<string, unknown>>({}),
49
- }),
50
- {
51
- persistedState: {
52
- persist: true,
53
- },
54
- },
55
- ),
56
- )
57
- }
58
-
59
- return metaStoreRegistry.get(id)!
60
- }
@@ -1,21 +0,0 @@
1
- import { defineStore } from 'pinia'
2
- import { ref } from 'vue'
3
- import { applicationWindowsStoreId } from './storeIds'
4
-
5
- export const useApplicationWindowsStore = (appId: string) => {
6
- return defineStore(
7
- applicationWindowsStoreId(appId),
8
- () => {
9
- const windows: Ref<{ [windowId: string]: WindowStoredState }> = ref({})
10
-
11
- return {
12
- windows,
13
- }
14
- },
15
- {
16
- persistedState: {
17
- persist: true,
18
- },
19
- },
20
- )()
21
- }