@converse/skeletor 3.1.0 → 3.1.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.
@@ -759,6 +759,12 @@ export declare type ModelOptions = Options & {
759
759
  */
760
760
  export declare function noConflict(): any;
761
761
 
762
+ /**
763
+ * Constructor for a Node.js-only storage driver. Registered by the
764
+ * `@converse/skeletor/node` entry point via {@link PersistentStorage.nodeStorage}.
765
+ */
766
+ declare type NodeStorageConstructor = new (name: string) => StorageDriver;
767
+
762
768
  /**
763
769
  * @public
764
770
  */
@@ -788,6 +794,7 @@ export declare class PersistentStorage {
788
794
  name: string;
789
795
  static sessionStorageInitialized: Promise<void>;
790
796
  static localForage: typeof localForage;
797
+ static nodeStorage: NodeStorageConstructor | null;
791
798
  /** Register a storage instance with a weak reference. @public */
792
799
  static register(instance: PersistentStorage): void;
793
800
  /**
@@ -8665,7 +8665,11 @@ class PersistentStorage {
8665
8665
  await localForage.config({ 'driver': IN_MEMORY });
8666
8666
  }
8667
8667
  else if (type === 'node') {
8668
- const { NodeSQLiteStorage } = await import('./drivers/nodeSQLiteStorage');
8668
+ const NodeSQLiteStorage = PersistentStorage.nodeStorage;
8669
+ if (!NodeSQLiteStorage) {
8670
+ throw new Error("Skeletor.storage: the 'node' storage type is only available in Node.js builds. " +
8671
+ "Import from '@converse/skeletor/node' instead of '@converse/skeletor'.");
8672
+ }
8669
8673
  this.store = new NodeSQLiteStorage(this.name);
8670
8674
  if (batchedWrites) {
8671
8675
  this.store.debouncedSetItems = mergebounce((items) => this.store.setItems(items), 50, {
@@ -8869,6 +8873,10 @@ class PersistentStorage {
8869
8873
  return this.name + '-' + id;
8870
8874
  }
8871
8875
  }
8876
+ // The Node.js SQLite storage driver. Left null in browser builds so the
8877
+ // node-only driver (and its `node:sqlite` import) never enters the browser
8878
+ // bundle; the `@converse/skeletor/node` entry sets it.
8879
+ PersistentStorage.nodeStorage = null;
8872
8880
  PersistentStorage.sessionStorageInitialized = localForage.defineDriver(sessionStorageWrapper);
8873
8881
  PersistentStorage.localForage = localForage;
8874
8882