aboutsummaryrefslogtreecommitdiff
path: root/content-system/registry/singleton.ts
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-04-22 14:32:03 +0530
committerBobby <[email protected]>2026-04-22 14:32:03 +0530
commitbbe9d34700995ba1644d726743dbb61144052bd1 (patch)
treebee0455edb7023d08b348022672ec2c294f2579c /content-system/registry/singleton.ts
parent87f4e51a2804d0788c8cd1fcde56923d19d0e06c (diff)
downloadhollowdark-main.tar.xz
hollowdark-main.zip
Load the content manifest and cache every chunk to IndexedDB on initial loadHEADmain
Diffstat (limited to 'content-system/registry/singleton.ts')
-rw-r--r--content-system/registry/singleton.ts25
1 files changed, 25 insertions, 0 deletions
diff --git a/content-system/registry/singleton.ts b/content-system/registry/singleton.ts
new file mode 100644
index 0000000..d8a556e
--- /dev/null
+++ b/content-system/registry/singleton.ts
@@ -0,0 +1,25 @@
+import type { ContentRegistry } from '@hollowdark/content-system/registry/registry'
+
+let instance: ContentRegistry | null = null
+
+/** Record the registry populated during session startup. */
+export function setContentRegistry(registry: ContentRegistry): void {
+ instance = registry
+}
+
+/**
+ * Access the shared content registry. Throws if called before the
+ * loading pipeline has populated it — simulation code should never run
+ * until initial load is complete.
+ */
+export function getContentRegistry(): ContentRegistry {
+ if (instance === null) {
+ throw new Error('Content registry not initialised. Initial load must complete first.')
+ }
+ return instance
+}
+
+/** True once the registry has been populated. */
+export function hasContentRegistry(): boolean {
+ return instance !== null
+}