@travetto/registry 3.3.3 → 3.4.0-rc.0
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/README.md +1 -1
- package/package.json +4 -4
- package/src/decorator.ts +4 -1
- package/src/source/class-source.ts +9 -15
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ The registry is a [MetadataRegistry](https://github.com/travetto/travetto/tree/m
|
|
|
74
74
|
### Live Flow
|
|
75
75
|
At runtime, the registry is designed to listen for changes and to propagate the changes as necessary. In many cases the same file is handled by multiple registries.
|
|
76
76
|
|
|
77
|
-
As the [DynamicFileLoader](https://github.com/travetto/travetto/tree/main/module/base/src/internal/file-loader.ts#
|
|
77
|
+
As the [DynamicFileLoader](https://github.com/travetto/travetto/tree/main/module/base/src/internal/file-loader.ts#L28) notifies that a file has been changed, the [RootRegistry](https://github.com/travetto/travetto/tree/main/module/registry/src/service/root.ts#L10) will pick it up, and process it accordingly.
|
|
78
78
|
|
|
79
79
|
## Supporting Metadata
|
|
80
80
|
As mentioned in [Manifest](https://github.com/travetto/travetto/tree/main/module/manifest#readme "Support for project indexing, manifesting, along with file watching")'s readme, the framework produces hashes of methods, classes, and functions, to allow for detecting changes to individual parts of the codebase. During the live flow, various registries will inspect this information to determine if action should be taken.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/registry",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0-rc.0",
|
|
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,11 +27,11 @@
|
|
|
27
27
|
"directory": "module/registry"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@travetto/base": "^3.
|
|
30
|
+
"@travetto/base": "^3.4.0-rc.0"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@travetto/cli": "^3.
|
|
34
|
-
"@travetto/transformer": "^3.
|
|
33
|
+
"@travetto/cli": "^3.4.0-rc.0",
|
|
34
|
+
"@travetto/transformer": "^3.4.0-rc.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@travetto/transformer": {
|
package/src/decorator.ts
CHANGED
|
@@ -24,7 +24,10 @@ class $PendingRegister {
|
|
|
24
24
|
/**
|
|
25
25
|
* Clear pending classes
|
|
26
26
|
*/
|
|
27
|
-
flush(): [string, Class[]][] {
|
|
27
|
+
flush(log?: boolean): [string, Class[]][] {
|
|
28
|
+
if (log) {
|
|
29
|
+
console.debug('Pending changes', { changes: this.ordered.map(([, x]) => x.map(y => y.Ⲑid)) });
|
|
30
|
+
}
|
|
28
31
|
const out = this.ordered.slice(0);
|
|
29
32
|
this.map.clear();
|
|
30
33
|
this.ordered = [];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { RootIndex } from '@travetto/manifest';
|
|
4
4
|
import { Class, GlobalEnv } from '@travetto/base';
|
|
5
5
|
import { DynamicFileLoader } from '@travetto/base/src/internal/file-loader';
|
|
6
6
|
|
|
@@ -81,19 +81,6 @@ export class ClassSource implements ChangeSource<Class> {
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
-
/**
|
|
85
|
-
* Handle when a file watch event happens
|
|
86
|
-
*/
|
|
87
|
-
async onLoadEvent(ev: WatchEvent): Promise<void> {
|
|
88
|
-
console.debug('Pending changes', { changes: PendingRegister.ordered.map(([, x]) => x.map(y => y.Ⲑid)) });
|
|
89
|
-
for (const [file, classes] of PendingRegister.flush()) {
|
|
90
|
-
this.#handleFileChanges(file, classes);
|
|
91
|
-
}
|
|
92
|
-
if (ev.action === 'create') {
|
|
93
|
-
this.#flush();
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
84
|
/**
|
|
98
85
|
* Emit a change event
|
|
99
86
|
*/
|
|
@@ -107,7 +94,14 @@ export class ClassSource implements ChangeSource<Class> {
|
|
|
107
94
|
*/
|
|
108
95
|
async init(): Promise<void> {
|
|
109
96
|
if (GlobalEnv.dynamic) {
|
|
110
|
-
DynamicFileLoader.onLoadEvent(ev =>
|
|
97
|
+
DynamicFileLoader.onLoadEvent(ev => {
|
|
98
|
+
for (const [file, classes] of PendingRegister.flush(true)) {
|
|
99
|
+
this.#handleFileChanges(file, classes);
|
|
100
|
+
}
|
|
101
|
+
if (ev.action === 'create') {
|
|
102
|
+
this.#flush();
|
|
103
|
+
}
|
|
104
|
+
});
|
|
111
105
|
await DynamicFileLoader.init();
|
|
112
106
|
}
|
|
113
107
|
|