@travetto/registry 3.0.0-rc.12 → 3.0.0-rc.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/registry",
3
- "version": "3.0.0-rc.12",
3
+ "version": "3.0.0-rc.14",
4
4
  "description": "Patterns and utilities for handling registration of metadata and functionality for run-time use",
5
5
  "keywords": [
6
6
  "ast-transformations",
@@ -27,10 +27,10 @@
27
27
  "directory": "module/registry"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/base": "^3.0.0-rc.9"
30
+ "@travetto/base": "^3.0.0-rc.11"
31
31
  },
32
32
  "peerDependencies": {
33
- "@travetto/transformer": "^3.0.0-rc.11"
33
+ "@travetto/transformer": "^3.0.0-rc.13"
34
34
  },
35
35
  "peerDependenciesMeta": {
36
36
  "@travetto/transformer": {
@@ -19,6 +19,14 @@ class $RootRegistry extends Registry {
19
19
  await super.onEvent(e); // Process event, and
20
20
  this.emit(e); // Send to children
21
21
  }
22
+
23
+ /**
24
+ * Registers a listener to be notified when a file changes, but no
25
+ * classes are modified
26
+ */
27
+ onNonClassChanges(handler: (file: string) => void): void {
28
+ this.parent(ClassSource)!.onNonClassChanges(handler);
29
+ }
22
30
  }
23
31
 
24
32
  export const RootRegistry = new $RootRegistry();
@@ -51,26 +51,34 @@ export class ClassSource implements ChangeSource<Class> {
51
51
  this.#classes.set(file, new Map());
52
52
  }
53
53
 
54
+ let changes = 0;
55
+
54
56
  /**
55
57
  * Determine delta based on the various classes (if being added, removed or updated)
56
58
  */
57
59
  for (const k of keys) {
58
60
  if (!next.has(k)) {
61
+ changes += 1;
59
62
  this.emit({ type: 'removing', prev: prev.get(k)! });
60
63
  this.#classes.get(file)!.delete(k);
61
64
  } else {
62
65
  this.#classes.get(file)!.set(k, next.get(k)!);
63
66
  if (!prev.has(k)) {
67
+ changes += 1;
64
68
  this.emit({ type: 'added', curr: next.get(k)! });
65
69
  } else {
66
70
  const prevMeta = RootIndex.getFunctionMetadataFromClass(prev.get(k));
67
71
  const nextMeta = RootIndex.getFunctionMetadataFromClass(next.get(k));
68
72
  if (prevMeta?.hash !== nextMeta?.hash) {
73
+ changes += 1;
69
74
  this.emit({ type: 'changed', curr: next.get(k)!, prev: prev.get(k) });
70
75
  }
71
76
  }
72
77
  }
73
78
  }
79
+ if (!changes) {
80
+ this.#emitter.emit('unchanged-file', file);
81
+ }
74
82
  }
75
83
 
76
84
  /**
@@ -116,4 +124,11 @@ export class ClassSource implements ChangeSource<Class> {
116
124
  on(callback: ChangeHandler<Class>): void {
117
125
  this.#emitter.on('change', callback);
118
126
  }
127
+
128
+ /**
129
+ * Add callback for when a file is changed, but emits no class changes
130
+ */
131
+ onNonClassChanges(callback: (file: string) => void): void {
132
+ this.#emitter.on('unchanged-file', callback);
133
+ }
119
134
  }