@fumari/stf 0.0.2 → 0.0.3

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.
Files changed (2) hide show
  1. package/dist/index.js +7 -7
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -118,12 +118,12 @@ function getDefaultValue(defaultValue) {
118
118
  }
119
119
  var ListenerManager = class {
120
120
  constructor() {
121
- this.listeners = /* @__PURE__ */ new Set();
121
+ this.unindexed = /* @__PURE__ */ new Set();
122
122
  this.indexed = /* @__PURE__ */ new Map();
123
123
  }
124
124
  add(listener) {
125
125
  if (!listener.field) {
126
- this.listeners.add(listener);
126
+ this.unindexed.add(listener);
127
127
  return;
128
128
  }
129
129
  const key = stringifyFieldKey(listener.field);
@@ -132,27 +132,27 @@ var ListenerManager = class {
132
132
  this.indexed.set(key, set);
133
133
  }
134
134
  remove(listener) {
135
- if (!listener.field) this.listeners.delete(listener);
135
+ if (!listener.field) this.unindexed.delete(listener);
136
136
  else this.indexed.get(stringifyFieldKey(listener.field))?.delete(listener);
137
137
  }
138
138
  onUpdate(field, ctx) {
139
- for (const v of this.listeners) v.onUpdate?.(field, ctx);
139
+ for (const v of this.unindexed) v.onUpdate?.(field, ctx);
140
140
  const updatedKey = stringifyFieldKey(field);
141
141
  if (ctx.swallow) {
142
142
  const set = this.indexed.get(updatedKey);
143
143
  if (set) for (const v of set) v.onUpdate?.(field, ctx);
144
144
  } else for (const [k, listeners] of this.indexed.entries()) {
145
- if (k !== updatedKey && !k.startsWith(updatedKey + ".")) continue;
145
+ if (updatedKey.length !== 0 && k !== updatedKey && !k.startsWith(updatedKey + ".")) continue;
146
146
  for (const v of listeners) v.onUpdate?.(field, ctx);
147
147
  }
148
148
  }
149
149
  onInit(field) {
150
- for (const v of this.listeners) v.onInit?.(field);
150
+ for (const v of this.unindexed) v.onInit?.(field);
151
151
  const set = this.indexed.get(stringifyFieldKey(field));
152
152
  if (set) for (const v of set) v.onInit?.(field);
153
153
  }
154
154
  onDelete(field) {
155
- for (const v of this.listeners) v.onDelete?.(field);
155
+ for (const v of this.unindexed) v.onDelete?.(field);
156
156
  const set = this.indexed.get(stringifyFieldKey(field));
157
157
  if (set) for (const v of set) v.onDelete?.(field);
158
158
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fumari/stf",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Schema to Form.",
5
5
  "keywords": [],
6
6
  "license": "MIT",