@travetto/manifest 5.0.0-rc.0 → 5.0.0-rc.1

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 CHANGED
@@ -35,7 +35,7 @@ During the compilation process, it is helpful to know how the output content dif
35
35
  ## Class and Function Metadata
36
36
  For the framework to work properly, metadata needs to be collected about files, classes and functions to uniquely identify them, with support for detecting changes during live reloads. To achieve this, every `class` is decorated with an additional field of `Ⲑid`. `Ⲑid` represents a computed id that is tied to the file/class combination.
37
37
 
38
- `Ⲑid` is used heavily throughout the framework for determining which classes are owned by the framework, and being able to lookup the needed data from the [RuntimeIndex](https://github.com/travetto/travetto/tree/main/module/manifest/src/runtime.ts#L14) using the `getFunctionMetadata` method.
38
+ `Ⲑid` is used heavily throughout the framework for determining which classes are owned by the framework, and being able to lookup the needed data from the [RuntimeIndex](https://github.com/travetto/travetto/tree/main/module/manifest/src/runtime.ts#L12) using the `getFunctionMetadata` method.
39
39
 
40
40
  **Code: Test Class**
41
41
  ```typescript
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/manifest",
3
- "version": "5.0.0-rc.0",
3
+ "version": "5.0.0-rc.1",
4
4
  "description": "Support for project indexing, manifesting, along with file watching",
5
5
  "keywords": [
6
6
  "path",
package/src/runtime.ts CHANGED
@@ -1,9 +1,7 @@
1
1
  import { path } from './path';
2
2
  import { ManifestIndex } from './manifest-index';
3
-
4
3
  import type { FunctionMetadata, FunctionMetadataTag } from './types/common';
5
4
  import type { IndexedModule, ManifestModule } from './types/manifest';
6
- import type { ManifestContext } from './types/context';
7
5
 
8
6
  const METADATA = Symbol.for('@travetto/manifest:metadata');
9
7
  type Metadated = { [METADATA]: FunctionMetadata };
@@ -40,9 +38,9 @@ class $RuntimeIndex extends ManifestIndex {
40
38
  }
41
39
 
42
40
  /**
43
- * Get source file from import location
44
- * @param outputFile
45
- */
41
+ * Get source file from import location
42
+ * @param outputFile
43
+ */
46
44
  getSourceFile(importFile: string): string {
47
45
  return this.getFromImport(importFile)?.sourceFile ?? importFile;
48
46
  }
@@ -56,6 +54,7 @@ class $RuntimeIndex extends ManifestIndex {
56
54
  * @param `methods` Methods and their hashes
57
55
  * @param `abstract` Is the class abstract
58
56
  * @param `synthetic` Is this code generated at build time
57
+ * @private
59
58
  */
60
59
  registerFunction(
61
60
  cls: Function, fileOrImport: string, tag: FunctionMetadataTag,
@@ -81,7 +80,7 @@ class $RuntimeIndex extends ManifestIndex {
81
80
  /**
82
81
  * Retrieve function metadata by function, or function id
83
82
  */
84
- getFunctionMetadata(clsId: string | Function): FunctionMetadata | undefined {
83
+ getFunctionMetadata(clsId?: string | Function): FunctionMetadata | undefined {
85
84
  const id = clsId === undefined ? '' : typeof clsId === 'string' ? clsId : clsId.Ⲑid;
86
85
  return this.#metadata.get(id);
87
86
  }
@@ -113,43 +112,4 @@ class $RuntimeIndex extends ManifestIndex {
113
112
  }
114
113
  }
115
114
 
116
- export const RuntimeIndex = new $RuntimeIndex(process.env.TRV_MANIFEST!);
117
-
118
- const build = <T extends object, K extends keyof ManifestContext>(inp: T, props: K[]): T & Pick<ManifestContext, K> => {
119
- for (const prop of props) {
120
- Object.defineProperty(inp, prop, { configurable: false, get: () => RuntimeIndex.manifest[prop] });
121
- }
122
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
123
- return inp as T & ManifestContext;
124
- };
125
-
126
- export const RuntimeContext = build({
127
- /**
128
- * Produce a workspace relative path
129
- * @param rel The relative path
130
- */
131
- workspaceRelative(...rel: string[]): string {
132
- return path.resolve(RuntimeIndex.manifest.workspace.path, ...rel);
133
- },
134
- /**
135
- * Strip off the workspace path from a file
136
- * @param full A full path
137
- */
138
- stripWorkspacePath(full: string): string {
139
- return full === RuntimeIndex.manifest.workspace.path ? '' : full.replace(`${RuntimeIndex.manifest.workspace.path}/`, '');
140
- },
141
- /**
142
- * Produce a workspace path for tooling, with '@' being replaced by node_module/name folder
143
- * @param rel The relative path
144
- */
145
- toolPath(...rel: string[]): string {
146
- rel = rel.flatMap(x => x === '@' ? ['node_modules', RuntimeIndex.manifest.main.name] : [x]);
147
- return path.resolve(RuntimeIndex.manifest.workspace.path, RuntimeIndex.manifest.build.toolFolder, ...rel);
148
- },
149
- /**
150
- * Are we running from a mono-root?
151
- */
152
- get monoRoot(): boolean {
153
- return !!RuntimeIndex.manifest.workspace.mono && !RuntimeIndex.manifest.main.folder;
154
- }
155
- }, ['main', 'workspace']);
115
+ export const RuntimeIndex = new $RuntimeIndex(process.env.TRV_MANIFEST!);