diff --git a/.idea/Editor.iml b/.idea/Editor.iml
deleted file mode 100644
index 24643cc..0000000
--- a/.idea/Editor.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 6b8b04c..d19124e 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,8 +3,6 @@
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index a2a0116..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -2,7 +2,5 @@
-
-
\ No newline at end of file
diff --git a/src/lib/client/ecs/asset/asset-manager.ts b/src/lib/client/ecs/asset/asset-manager.ts
index 323bbcd..cc2b076 100644
--- a/src/lib/client/ecs/asset/asset-manager.ts
+++ b/src/lib/client/ecs/asset/asset-manager.ts
@@ -14,8 +14,8 @@ const _subscriptions = writable>({});
export class AssetManager {
static reset() {
- _storage.set([]);
resetSubscriptions(_subscriptions);
+ _storage.set([]);
}
constructor(assets: Asset[]) {
diff --git a/src/lib/client/ecs/component/component-manager.ts b/src/lib/client/ecs/component/component-manager.ts
index aa7db66..57127b0 100644
--- a/src/lib/client/ecs/component/component-manager.ts
+++ b/src/lib/client/ecs/component/component-manager.ts
@@ -14,8 +14,8 @@ const _subscriptions = writable>({});
export class ComponentManager {
static reset() {
- _storage.set([]);
resetSubscriptions(_subscriptions);
+ _storage.set([]);
}
constructor(components: Component[]) {
diff --git a/src/lib/client/ecs/ecs-handler.ts b/src/lib/client/ecs/ecs-handler.ts
index d69604c..b5f566c 100644
--- a/src/lib/client/ecs/ecs-handler.ts
+++ b/src/lib/client/ecs/ecs-handler.ts
@@ -34,6 +34,13 @@ export class ECSHandler {
private _libraryManager: LibraryManager | undefined;
static reset() {
+ // * Child must be reset before parents
+ ComponentParamHandle.reset();
+ ComponentParamManager.reset();
+ EntityComponentManager.reset();
+ SceneSystemManager.reset();
+ SceneEntityHandle.reset();
+ SceneEntityManager.reset();
AssetHandle.reset();
AssetManager.reset();
ComponentHandle.reset();
@@ -44,12 +51,6 @@ export class ECSHandler {
LibraryHandle.reset();
SceneHandle.reset();
SceneManager.reset();
- SceneSystemManager.reset();
- SceneEntityHandle.reset();
- SceneEntityManager.reset();
- EntityComponentManager.reset();
- ComponentParamHandle.reset();
- ComponentParamManager.reset();
}
constructor(project: Project) {
diff --git a/src/lib/client/ecs/library/library-manager.ts b/src/lib/client/ecs/library/library-manager.ts
index ef7599c..862d024 100644
--- a/src/lib/client/ecs/library/library-manager.ts
+++ b/src/lib/client/ecs/library/library-manager.ts
@@ -9,8 +9,8 @@ const _subscriptions = writable>({});
export class LibraryManager {
static reset() {
- _storage.set([]);
resetSubscriptions(_subscriptions);
+ _storage.set([]);
}
constructor(libraries: Library[]) {
diff --git a/src/lib/client/ecs/scene/entity/component/component-manager.ts b/src/lib/client/ecs/scene/entity/component/component-manager.ts
index 65e32392..4ba59a7 100644
--- a/src/lib/client/ecs/scene/entity/component/component-manager.ts
+++ b/src/lib/client/ecs/scene/entity/component/component-manager.ts
@@ -18,9 +18,9 @@ export class EntityComponentManager {
private readonly _storageResolvable: string;
static reset() {
- _storage.set({});
resetSubscriptions(_subscriptions);
resetListener(_listener);
+ _storage.set({});
}
constructor(entity: SceneEntityHandle, components: Record>) {
diff --git a/src/lib/client/ecs/scene/entity/component/component-param-handle.ts b/src/lib/client/ecs/scene/entity/component/component-param-handle.ts
index 8947b35..3beb490 100644
--- a/src/lib/client/ecs/scene/entity/component/component-param-handle.ts
+++ b/src/lib/client/ecs/scene/entity/component/component-param-handle.ts
@@ -17,9 +17,9 @@ export class ComponentParamHandle {
private readonly _valueStore: Writable;
static reset() {
+ resetListeners(_listeners);
_storage.set({});
_valueStorage.set({});
- resetListeners(_listeners);
}
constructor(manager: ComponentParamManager, param: ComponentParam, value: any | undefined) {
diff --git a/src/lib/client/ecs/scene/entity/component/component-param-manager.ts b/src/lib/client/ecs/scene/entity/component/component-param-manager.ts
index ded35ac..b30729f 100644
--- a/src/lib/client/ecs/scene/entity/component/component-param-manager.ts
+++ b/src/lib/client/ecs/scene/entity/component/component-param-manager.ts
@@ -21,10 +21,10 @@ export class ComponentParamManager {
private readonly _storageResolvable: string;
static reset() {
- _storage.set({});
- _valueStorage.set({});
resetSubscriptions(_subscriptions);
resetListener(_listener);
+ _storage.set({});
+ _valueStorage.set({});
}
constructor(component: EntityComponentHandle, params: Record) {
diff --git a/src/lib/client/ecs/scene/entity/entity-handle.ts b/src/lib/client/ecs/scene/entity/entity-handle.ts
index 5ca7e6d..c61d37e 100644
--- a/src/lib/client/ecs/scene/entity/entity-handle.ts
+++ b/src/lib/client/ecs/scene/entity/entity-handle.ts
@@ -17,8 +17,8 @@ export class SceneEntityHandle {
private readonly _components: EntityComponentManager;
static reset() {
- _storage.set({});
resetListeners(_listeners);
+ _storage.set({});
}
constructor(manager: SceneEntityManager, entity: Entity) {
diff --git a/src/lib/client/ecs/scene/entity/entity-manager.ts b/src/lib/client/ecs/scene/entity/entity-manager.ts
index 527f046..0761386 100644
--- a/src/lib/client/ecs/scene/entity/entity-manager.ts
+++ b/src/lib/client/ecs/scene/entity/entity-manager.ts
@@ -17,8 +17,8 @@ export class SceneEntityManager {
private readonly _store: Writable;
static reset() {
- _storage.set({});
resetSubscriptions(_subscriptions);
+ _storage.set({});
}
constructor(scene: SceneHandle, entities: Entity[]) {
diff --git a/src/lib/client/ecs/scene/scene-handle.ts b/src/lib/client/ecs/scene/scene-handle.ts
index 8936224..a1729e2 100644
--- a/src/lib/client/ecs/scene/scene-handle.ts
+++ b/src/lib/client/ecs/scene/scene-handle.ts
@@ -18,8 +18,8 @@ export class SceneHandle {
private readonly _systems: SceneSystemManager;
static reset() {
- _storage.set({});
resetListeners(_listeners);
+ _storage.set({});
}
constructor(manager: SceneManager, scene: Scene) {
diff --git a/src/lib/client/ecs/scene/scene-manager.ts b/src/lib/client/ecs/scene/scene-manager.ts
index 99b5914..aa7e099 100644
--- a/src/lib/client/ecs/scene/scene-manager.ts
+++ b/src/lib/client/ecs/scene/scene-manager.ts
@@ -16,11 +16,11 @@ export class SceneManager {
public readonly ecs: ECSHandler;
static reset() {
+ resetSubscriptions(_subscriptions);
_storage.set([]);
_rootScenesStorage.set([]);
_activeSceneStorage.set(undefined as any);
_defaultSceneStorage.set(undefined as any);
- resetSubscriptions(_subscriptions);
}
constructor(ecs: ECSHandler, scenes: Scene[], rootScenes: string[], defaultSceneId: string) {
diff --git a/src/lib/client/ecs/scene/system/system-manager.ts b/src/lib/client/ecs/scene/system/system-manager.ts
index b66930f..382f07b 100644
--- a/src/lib/client/ecs/scene/system/system-manager.ts
+++ b/src/lib/client/ecs/scene/system/system-manager.ts
@@ -13,8 +13,8 @@ export class SceneSystemManager {
private readonly _store: Writable;
static reset() {
- _storage.set({});
resetListener(_listener);
+ _storage.set({});
}
constructor(scene: SceneHandle, systems: string[]) {
diff --git a/src/lib/client/ecs/system/system-manager.ts b/src/lib/client/ecs/system/system-manager.ts
index 4a81cb4..9f97fdb 100644
--- a/src/lib/client/ecs/system/system-manager.ts
+++ b/src/lib/client/ecs/system/system-manager.ts
@@ -13,8 +13,8 @@ const _subscriptions = writable>({});
export class SystemManager {
static reset() {
- _storage.set([]);
resetSubscriptions(_subscriptions);
+ _storage.set([]);
}
constructor(systems: System[]) {
diff --git a/src/lib/client/project/index.ts b/src/lib/client/project/index.ts
index 0f0852c..81ca00b 100644
--- a/src/lib/client/project/index.ts
+++ b/src/lib/client/project/index.ts
@@ -1,4 +1,9 @@
export { Project } from './project';
export { ProjectCache, type ProjectDataCache } from './project-loader/project-cache';
-export { ProjectLoader, useProject, getProject } from './project-loader/project-loader';
+export {
+ ProjectLoader,
+ useProject,
+ getProject,
+ getProjectStore,
+} from './project-loader/project-loader';
export { PLErrors, PLException } from './project-loader/exceptions';
diff --git a/src/lib/client/project/project-loader/init-functions.ts b/src/lib/client/project/project-loader/init-functions.ts
new file mode 100644
index 0000000..24e9cad
--- /dev/null
+++ b/src/lib/client/project/project-loader/init-functions.ts
@@ -0,0 +1,6 @@
+import type { Project } from '$lib/client/project';
+import { updateTabsStore } from '$lib/components/Tabs/store';
+
+export const initTabs = (project: Project) => {
+ updateTabsStore(project.id);
+};
diff --git a/src/lib/client/project/project-loader/project-loader.ts b/src/lib/client/project/project-loader/project-loader.ts
index a289735..7f8a404 100644
--- a/src/lib/client/project/project-loader/project-loader.ts
+++ b/src/lib/client/project/project-loader/project-loader.ts
@@ -6,13 +6,15 @@ import {
type CreateProjectActionInput,
noProjectActions,
} from '$lib/client/action';
-import { getConfig } from '$lib/client/config/config';
+import { getConfig } from '$lib/client/config';
import { Project, ProjectCache, type ProjectDataCache } from '$lib/client/project';
-import { PLErrors, PLException, runPLSafe } from '$lib/client/project/project-loader/exceptions';
import { SfsTreeCache } from '$lib/client/sync-file-system';
import { FileSystemManager } from '@utils-client/file-system';
+import { PLErrors, PLException, runPLSafe } from './exceptions';
+import { initTabs } from './init-functions';
+
type ProjectCacheResolvable = ActionProject;
const projectStore = writable(null);
@@ -112,9 +114,16 @@ export class ProjectLoader {
name: infos.name,
lastOpened: Date.now(),
});
+
+ await this.initFunctions(project);
+
return project;
}
+ static async initFunctions(project: Project): Promise {
+ initTabs(project);
+ }
+
static unload() {
projectStore.set(null);
Project.reset();
@@ -139,3 +148,5 @@ export const useProject = () => {
};
export const getProject = () => get(projectStore);
+
+export const getProjectStore = () => projectStore;
diff --git a/src/lib/client/project/project.ts b/src/lib/client/project/project.ts
index e42ad27..6d267a4 100644
--- a/src/lib/client/project/project.ts
+++ b/src/lib/client/project/project.ts
@@ -22,6 +22,7 @@ export class Project {
static reset(): void {
InfoHandler.reset();
EventHandler.reset();
+ ECSHandler.reset();
}
constructor(public id: string) {
diff --git a/src/lib/components/Tabs/store.ts b/src/lib/components/Tabs/store.ts
index afd0388..302ea56 100644
--- a/src/lib/components/Tabs/store.ts
+++ b/src/lib/components/Tabs/store.ts
@@ -16,8 +16,11 @@ const initialState: TabsState = {
selectedTabId: 'tab-main',
};
-function createTabsStore() {
- const { subscribe, update, set } = persistedWritable('editor.tabs', initialState);
+function createTabsStore(projectId: string) {
+ const { subscribe, update, set } = persistedWritable(
+ `editor.tabs.${projectId}`,
+ initialState,
+ );
async function openTab(tab: Omit & { id?: string }) {
const existing = await findExistingTab(tab);
@@ -124,4 +127,8 @@ function createTabsStore() {
};
}
-export const tabsStore = createTabsStore();
+export const updateTabsStore = (projectId: string) => {
+ tabsStore = createTabsStore(projectId);
+};
+
+export let tabsStore = createTabsStore('default');
diff --git a/src/routes/dashboard/+page.svelte b/src/routes/dashboard/+page.svelte
index d337290..5051b27 100644
--- a/src/routes/dashboard/+page.svelte
+++ b/src/routes/dashboard/+page.svelte
@@ -16,6 +16,9 @@
import { runSafe } from '@utils-client/error';
import { FullPageProjectSpinner } from '$lib/components/project-loader';
import { MarketplaceDialog, setMarketplaceContext } from '$lib/components/marketplace';
+ import { getProjectStore } from '$lib/client/project/project-loader/project-loader';
+
+ const projectStore = getProjectStore();
let marketplaceOpen = $state(false);
setMarketplaceContext({ open: () => (marketplaceOpen = true) });
@@ -74,7 +77,7 @@
});
-{#if loaded}
+{#if loaded && $projectStore}