@converse/skeletor 3.1.3 → 3.1.4

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.
@@ -11055,18 +11055,18 @@ class Model extends EventEmitterObject {
11055
11055
  this.initialize.apply(this, arguments);
11056
11056
  // Reset changed after initial set
11057
11057
  this.changed = {};
11058
- // When autoSync is on, `initialized` is always a Promise so callers can
11059
- // uniformly `await model.initialized`. It only hydrates from storage when
11058
+ // When autoSync is on, `hydrated` is always a Promise so callers can
11059
+ // uniformly `await model.hydrated`. It only hydrates from storage when
11060
11060
  // there's something to load (storage configured and the model isn't new);
11061
11061
  // otherwise it's already ready and resolves immediately.
11062
11062
  if (this.autoSync) {
11063
11063
  if (getStorage(this) && !this.isNew()) {
11064
11064
  __classPrivateFieldSet(this, _Model_state, 'hydrating', "f");
11065
- this.initialized = __classPrivateFieldGet(this, _Model_instances, "m", _Model_hydrate).call(this);
11065
+ this.hydrated = __classPrivateFieldGet(this, _Model_instances, "m", _Model_hydrate).call(this);
11066
11066
  }
11067
11067
  else {
11068
11068
  __classPrivateFieldSet(this, _Model_state, 'ready', "f");
11069
- this.initialized = Promise.resolve();
11069
+ this.hydrated = Promise.resolve();
11070
11070
  }
11071
11071
  }
11072
11072
  else {
@@ -11239,7 +11239,7 @@ class Model extends EventEmitterObject {
11239
11239
  // Guard must come after arg normalization: when called as set(obj, opts),
11240
11240
  // fromStorage lives in `val` (second arg), not `options` (third arg).
11241
11241
  if (this.autoSync && __classPrivateFieldGet(this, _Model_state, "f") === 'hydrating' && !options.fromStorage) {
11242
- throw new Error(`Skeletor: set() called on an autoSync model before initialized resolved. Await model.initialized first.`);
11242
+ throw new Error(`Skeletor: set() called on an autoSync model before hydration resolved. Await model.hydrated first.`);
11243
11243
  }
11244
11244
  // Run validation.
11245
11245
  if (!this._validate(attrs, options))
@@ -11679,11 +11679,11 @@ class Collection extends EventEmitterObject {
11679
11679
  if (models)
11680
11680
  this.reset(models, Object.assign({ silent: true }, options));
11681
11681
  this[Symbol.iterator] = this.values;
11682
- // When autoSync is on, `initialized` is always a Promise so callers can
11683
- // uniformly `await collection.initialized`; it resolves immediately when
11682
+ // When autoSync is on, `hydrated` is always a Promise so callers can
11683
+ // uniformly `await collection.hydrated`; it resolves immediately when
11684
11684
  // there's no storage to hydrate from.
11685
11685
  if (this.autoSync) {
11686
- this.initialized = getStorage(this) ? __classPrivateFieldGet(this, _Collection_instances, "m", _Collection_hydrate).call(this) : Promise.resolve();
11686
+ this.hydrated = getStorage(this) ? __classPrivateFieldGet(this, _Collection_instances, "m", _Collection_hydrate).call(this) : Promise.resolve();
11687
11687
  }
11688
11688
  }
11689
11689
  get comparator() {
@@ -11715,7 +11715,7 @@ class Collection extends EventEmitterObject {
11715
11715
  }
11716
11716
  /**
11717
11717
  * Override to return `true` to automatically load the collection from
11718
- * storage on construction. Await `initialized` to know when hydration
11718
+ * storage on construction. Await `hydrated` to know when hydration
11719
11719
  * is complete.
11720
11720
  *
11721
11721
  * Note: collection `autoSync` is hydrate-only. Unlike `Model`, it does
package/package.json CHANGED
@@ -36,7 +36,7 @@
36
36
  "contributors": [
37
37
  "JC Brand"
38
38
  ],
39
- "version": "3.1.3",
39
+ "version": "3.1.4",
40
40
  "engines": {
41
41
  "node": ">=22.0.0"
42
42
  },
package/src/collection.ts CHANGED
@@ -40,7 +40,7 @@ export class Collection<T extends Model = Model> extends EventEmitterObject {
40
40
  _storage?: PersistentStorage;
41
41
  _comparator?: Comparator<T>;
42
42
  _url: string = '';
43
- initialized?: Promise<void>;
43
+ hydrated?: Promise<void>;
44
44
  models: T[];
45
45
  protected _byId: Record<string, T>;
46
46
  protected _model?: new (attributes?: Partial<ModelAttributes>, options?: ModelOptions) => T;
@@ -61,11 +61,11 @@ export class Collection<T extends Model = Model> extends EventEmitterObject {
61
61
  if (models) this.reset(models, Object.assign({ silent: true }, options));
62
62
 
63
63
  this[Symbol.iterator] = this.values;
64
- // When autoSync is on, `initialized` is always a Promise so callers can
65
- // uniformly `await collection.initialized`; it resolves immediately when
64
+ // When autoSync is on, `hydrated` is always a Promise so callers can
65
+ // uniformly `await collection.hydrated`; it resolves immediately when
66
66
  // there's no storage to hydrate from.
67
67
  if (this.autoSync) {
68
- this.initialized = getStorage(this) ? this.#hydrate() : Promise.resolve();
68
+ this.hydrated = getStorage(this) ? this.#hydrate() : Promise.resolve();
69
69
  }
70
70
  }
71
71
 
@@ -104,7 +104,7 @@ export class Collection<T extends Model = Model> extends EventEmitterObject {
104
104
 
105
105
  /**
106
106
  * Override to return `true` to automatically load the collection from
107
- * storage on construction. Await `initialized` to know when hydration
107
+ * storage on construction. Await `hydrated` to know when hydration
108
108
  * is complete.
109
109
  *
110
110
  * Note: collection `autoSync` is hydrate-only. Unlike `Model`, it does
package/src/model.ts CHANGED
@@ -58,7 +58,7 @@ export class Model<T extends ModelAttributes = ModelAttributes> extends EventEmi
58
58
  cid: string;
59
59
  collection?: Collection;
60
60
  id: string | number;
61
- initialized?: Promise<void>;
61
+ hydrated?: Promise<void>;
62
62
  validationError: string | number | null = null;
63
63
 
64
64
  /**
@@ -102,17 +102,17 @@ export class Model<T extends ModelAttributes = ModelAttributes> extends EventEmi
102
102
  // Reset changed after initial set
103
103
  this.changed = {};
104
104
 
105
- // When autoSync is on, `initialized` is always a Promise so callers can
106
- // uniformly `await model.initialized`. It only hydrates from storage when
105
+ // When autoSync is on, `hydrated` is always a Promise so callers can
106
+ // uniformly `await model.hydrated`. It only hydrates from storage when
107
107
  // there's something to load (storage configured and the model isn't new);
108
108
  // otherwise it's already ready and resolves immediately.
109
109
  if (this.autoSync) {
110
110
  if (getStorage(this) && !this.isNew()) {
111
111
  this.#state = 'hydrating';
112
- this.initialized = this.#hydrate();
112
+ this.hydrated = this.#hydrate();
113
113
  } else {
114
114
  this.#state = 'ready';
115
- this.initialized = Promise.resolve();
115
+ this.hydrated = Promise.resolve();
116
116
  }
117
117
  } else {
118
118
  this.#state = 'ready';
@@ -347,7 +347,7 @@ export class Model<T extends ModelAttributes = ModelAttributes> extends EventEmi
347
347
  // fromStorage lives in `val` (second arg), not `options` (third arg).
348
348
  if (this.autoSync && this.#state === 'hydrating' && !options.fromStorage) {
349
349
  throw new Error(
350
- `Skeletor: set() called on an autoSync model before initialized resolved. Await model.initialized first.`,
350
+ `Skeletor: set() called on an autoSync model before hydration resolved. Await model.hydrated first.`,
351
351
  );
352
352
  }
353
353