@converse/skeletor 3.1.0 → 3.1.2

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.
package/CHANGES.md ADDED
@@ -0,0 +1,124 @@
1
+ # Changelog
2
+
3
+ ## 3.1.2 (2026-06-22)
4
+
5
+ - Fix the published package missing its `dist/` directory. `dist/` is gitignored and nothing built
6
+ it during the publish lifecycle, so `npm publish` could ship a tarball without the compiled
7
+ bundles that `main`/`module`/`exports` point at (3.1.1 was published this way and is unusable).
8
+ Add a `prepack` script that runs the build, so `npm pack` and `npm publish` always include a
9
+ freshly built `dist/`.
10
+
11
+ ## 3.1.1 (2026-06-22)
12
+
13
+ - Fix browser builds failing to resolve `./drivers/nodeSQLiteStorage`. The node-only SQLite
14
+ storage driver is now registered by the `@converse/skeletor/node` entry point instead of
15
+ being pulled in via a dynamic `import()` from the shared storage module. The browser bundles
16
+ (`skeletor.esm.js`, `skeletor.js`, `skeletor.min.js`) no longer contain a reference to a file
17
+ that isn't published, which broke downstream bundlers.
18
+
19
+ ## 3.1.0 (2026-06-22)
20
+
21
+ - Add an ESM build
22
+ - **Rename `browserStorage` → `storage`** on `Model` and `Collection`
23
+ - Add `BrowserStorage` as a deprecated export alias for `PersistentStorage`
24
+ - Add `autoSync` opt-in for transparent local persistence:
25
+ - Declare `get autoSync() { return true; }` on a model or collection to enable.
26
+ - **Auto-hydrate**: the model/collection loads its stored state on construction. `await model.initialized` resolves when done.
27
+ - **Auto-save** (models only): any `set()` (including `attrs.x = y`) that produces changes schedules a debounced save. Pass `{ noAutoSave: true }` to opt out per-call
28
+ - **Flush on unload**: when `autoSync` is used in a browser, Skeletor lazily registers `pagehide`/`visibilitychange` listeners that make a best-effort flush of pending writes when the tab is hidden/closing.
29
+ - **Destroy/save ordering**: `destroy()` now sequences its delete after any auto-save that has already fired and is still in flight, so a late write can no longer land after the delete and resurrect the record.
30
+ - **Error reporting**: a failed auto-save emits an `error` event on the model. Storage-layer failures surface through `sync`'s `error` callback (as before), and rejections that bypass it are emitted on the same event.
31
+ - Override `get autoSyncDelay()` to tune the debounce window (default: 100 ms).
32
+ - Complete the `fetch({ promise: true })` contract: `Model.fetch` now supports the `promise` option (previously ignored), and the promise returned by both `Model.fetch` and `Collection.fetch` now **rejects** on error instead of hanging forever.
33
+ - Add `PersistentStorage.flushAll()` static method to flush all registered storage instances.
34
+ - Add `getStorage(obj)` helper export — returns the configured storage for a model/collection, checking both `storage` and `browserStorage` (preserves compat with subclasses that still override `get browserStorage()`).
35
+ - Add computed properties to `Model`. Declare a `computed` getter returning `{ key: { deps, fn } }` definitions.
36
+ Values are cached, recalculated when deps change, and fire `change:key` events.
37
+ Accessible via `model.get('key')` and `model.attrs.key`.
38
+ - Add `attrs` proxy property on `Model` for ergonomic reactive attribute access:
39
+ `model.attrs.name` reads, `model.attrs.name = 'Bob'` writes (fires change events).
40
+ - Add `subscribe()` method to `EventEmitter`, `Model`, and `Collection`, returning an unsubscribe function.
41
+ Compatible with React's `useSyncExternalStore` and other store-style APIs.
42
+ `Model.subscribe(callback)` receives `(model, changed)` on any attribute change.
43
+ `Collection.subscribe(callback)` fires once per operation (on `update`, `reset`, or `sort` events).
44
+
45
+ ## 3.0.0 (2025-12-13)
46
+
47
+ - `Collection.prototype.create` no longer returns a boolean (but `null` instead)
48
+ - `Storage` is now exported as `BrowserStorage`
49
+
50
+ ## 2.0.0 (2025-12-13)
51
+
52
+ ### Breaking changes
53
+
54
+ - `Model.prototype.set` no longer returns a boolean when validation fails (but `null` instead)
55
+ - Loosened the `reduce` and `reduceRight` type signatures on the `Collection`
56
+
57
+ ## 1.0.0 (2025-12-13)
58
+
59
+ - Rewrite as TypeScript
60
+
61
+ ### Breaking changes:
62
+
63
+ - Removed the `clone()` method on `Model`.
64
+ - Removed the old `View` type
65
+ - Removed `ElementView`
66
+ - Removed the old `Events` constructor function and instead added the `EventsEmitter` mixin class.
67
+ - Removed the `Router` and `History` classes.
68
+ - All other types (`Model`, `Collection`) are now ES6 classes.
69
+
70
+ ## 0.0.9 (2025-03-04)
71
+
72
+ - Fix a race condition when setting a localForage driver
73
+ - Refactor the sync method to properly call the `fetch` API
74
+
75
+ ## 0.0.8 (2023-02-14)
76
+
77
+ - Use the released version of `@converse/localforage-getitems`
78
+ - Update 3rd party dependencies
79
+
80
+ ## 0.0.7 (2022-04-08)
81
+
82
+ - Move code that needs to be bundled to `dependencies` from `devDependencies`
83
+ - Update localForage-getItems to fix a build issue on Windows
84
+
85
+ ## 0.0.6 (2022-04-08)
86
+
87
+ - Use the `getAll` IndexedDB function, which should result in a significant speedup
88
+ - Update various 3rd party dependencies.
89
+
90
+ ## 0.0.5 (2021-07-08)
91
+
92
+ - #13 Import the default export of localforage
93
+ - Don't expect a collection's `model` attribute to have a `prototype`. It might be an arrow function, in which case it doesn't.
94
+ - Update to mergebounce 0.1.0
95
+
96
+ ## 0.0.4 (2021-05-12)
97
+
98
+ - Upgrade to lit 2.0.0-rc.2
99
+
100
+ ## 0.0.3 (2021-04-28)
101
+
102
+ - Create the `ElementView`, which is like a Backbone View but extends
103
+ `HTMLElement` and is therefore also a custom element or web component.
104
+ /home/kalie/src/converse.prosody/src/converse.js/src/headless/core.js: \* @property {object} converse.env.\_ - The instance of [lodash-es](http://lodash.com) used by Converse.
105
+ - Allow writes to the client-side store to be batched (via [mergebounce](https://github.com/conversejs/mergebounce)).
106
+ This is particularly useful for IndexedDB, which has a very slow writing speed.
107
+ To enabled batched writes, pass in `true` for the 3rd parameter of the
108
+ `Storage` constructor.
109
+
110
+ ## 0.0.2 (2020-09-18)
111
+
112
+ Initial fork from Backbone
113
+
114
+ - Removes the dependency on jQuery
115
+ - Instead of the `render` method Views can have a `toHTML` method which must return a
116
+ [lit-html](https://lit-html.polymer-project.org/) `TemplateResult`.
117
+ - Replaces [underscore](http://underscorejs.org) with [lodash](https://lodash.com)
118
+ - Imports lodash methods individually to allow for tree-shaking
119
+ - Uses the native browser API instead of lodash
120
+ - Drops support for older browsers (including IE) and uses ES6+ language features
121
+ - Splits models, views and collections into separate modules
122
+ - Adds a new `ElementView` class, which is a like a Backbone View, but doubles
123
+ as an instance of HTMLElement and can be used to register a custom element or
124
+ web-component.
@@ -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