@travetto/manifest
Advanced tools
Comparing version 5.0.0-rc.1 to 5.0.0-rc.2
@@ -1,2 +0,2 @@ | ||
/// <reference path="./src/global.d.ts" /> | ||
/// <reference path="../runtime/src/global.d.ts" /> | ||
@@ -6,3 +6,2 @@ export * from './src/module'; | ||
export * from './src/manifest-index'; | ||
export * from './src/runtime'; | ||
export * from './src/package'; | ||
@@ -9,0 +8,0 @@ export * from './src/util'; |
{ | ||
"name": "@travetto/manifest", | ||
"version": "5.0.0-rc.1", | ||
"version": "5.0.0-rc.2", | ||
"description": "Support for project indexing, manifesting, along with file watching", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -38,3 +38,3 @@ <!-- This file was generated by @travetto/doc and should not be modified directly --> | ||
`Ⲑ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. | ||
`Ⲑid` is used heavily throughout the framework for determining which classes are owned by the framework, and being able to lookup associated data by the id. | ||
@@ -54,7 +54,7 @@ **Code: Test Class** | ||
const tslib_1 = require("tslib"); | ||
const Ⲑ_runtime_1 = tslib_1.__importStar(require("@travetto/manifest/src/runtime.js")); | ||
const Ⲑ_decorator_1 = tslib_1.__importStar(require("@travetto/registry/src/decorator.js")); | ||
var ᚕf = "@travetto/manifest/doc/test-class.js"; | ||
const Ⲑ_function_1 = tslib_1.__importStar(require("@travetto/runtime/src/function.js")); | ||
var ᚕm = ["@travetto/manifest", "doc/test-class"]; | ||
let TestClass = class TestClass { | ||
static Ⲑinit = Ⲑ_runtime_1.RuntimeIndex.registerFunction(TestClass, ᚕf, { hash: 197152026, lines: [1, 3] }, { doStuff: { hash: 51337554, lines: [2, 2] } }, false, false); | ||
static Ⲑinit = Ⲑ_function_1.register(TestClass, ᚕm, { hash: 197152026, lines: [1, 3] }, { doStuff: { hash: 51337554, lines: [2, 2] } }, false, false); | ||
async doStuff() { } | ||
@@ -68,17 +68,2 @@ }; | ||
**Terminal: Index Lookup at Runtime** | ||
```bash | ||
$ trv main ./doc/lookup.ts | ||
{ | ||
id: '@travetto/manifest:doc/test-class○TestClass', | ||
source: './doc/test-class.ts', | ||
hash: 197152026, | ||
lines: [ 1, 3 ], | ||
methods: { doStuff: { hash: 51337554, lines: [ 2, 2 ] } }, | ||
abstract: false, | ||
synthetic: false | ||
} | ||
``` | ||
## Module Indexing | ||
@@ -97,4 +82,2 @@ Once the manifest is created, the application runtime can now read this manifest, which allows for influencing runtime behavior. The most common patterns include: | ||
Imports pointing at $`node:path` and $`path` are rewritten at compile time to point to the implementation provided by the module. This allows for seamless import/usage patterns with the reliability needed for cross platform support. | ||
## Anatomy of a Manifest | ||
@@ -147,3 +130,2 @@ | ||
[ "DOC.tsx", "ts", 1868155200000, "doc" ], | ||
[ "doc/lookup.ts", "ts", 1868155200000, "doc" ], | ||
[ "doc/test-class.ts", "ts", 1868155200000, "doc" ] | ||
@@ -158,4 +140,3 @@ ], | ||
"test": [ | ||
[ "test/path.ts", "ts", 1868155200000, "test" ], | ||
[ "test/runtime.ts", "ts", 1868155200000, "test" ] | ||
[ "test/path.ts", "ts", 1868155200000, "test" ] | ||
], | ||
@@ -165,6 +146,2 @@ "test/fixtures": [ | ||
], | ||
"$transformer": [ | ||
[ "support/transformer.function-metadata.ts", "ts", 1868155200000, "compile" ], | ||
[ "support/transformer.rewrite-path-import.ts", "ts", 1868155200000, "compile" ] | ||
], | ||
"src": [ | ||
@@ -174,3 +151,2 @@ [ "src/delta.ts", "ts", 1868155200000 ], | ||
[ "src/file.ts", "ts", 1868155200000 ], | ||
[ "src/global.d.ts", "typings", 1868155200000 ], | ||
[ "src/manifest-index.ts", "ts", 1868155200000 ], | ||
@@ -180,3 +156,2 @@ [ "src/module.ts", "ts", 1868155200000 ], | ||
[ "src/path.ts", "ts", 1868155200000 ], | ||
[ "src/runtime.ts", "ts", 1868155200000 ], | ||
[ "src/util.ts", "ts", 1868155200000 ], | ||
@@ -183,0 +158,0 @@ [ "src/types/common.ts", "ts", 1868155200000 ], |
@@ -25,3 +25,2 @@ import { existsSync } from 'node:fs'; | ||
#modulesByName: Record<string, IndexedModule> = {}; | ||
#modulesByFolder: Record<string, IndexedModule> = {}; | ||
#outputRoot: string; | ||
@@ -32,3 +31,3 @@ #outputToEntry = new Map<string, IndexedFile>(); | ||
constructor(manifest: string) { | ||
constructor(manifest: string = process.env.TRV_MANIFEST!) { | ||
this.init(manifest); | ||
@@ -55,2 +54,10 @@ } | ||
/** | ||
* **WARNING**: This is a destructive operation, and should only be called before loading any code | ||
* @private | ||
*/ | ||
reinitForModule(module: string): void { | ||
this.init(`${this.outputRoot}/node_modules/${module}`); | ||
} | ||
#moduleFiles(m: ManifestModule, files: ManifestModuleFile[]): IndexedFile[] { | ||
@@ -104,3 +111,2 @@ return files.map(([f, type, ts, role = 'std']) => { | ||
this.#modulesByName = Object.fromEntries(this.#modules.map(x => [x.name, x])); | ||
this.#modulesByFolder = Object.fromEntries(this.#modules.map(x => [x.sourceFolder, x])); | ||
@@ -170,9 +176,2 @@ // Store child information | ||
/** | ||
* Get module by folder | ||
*/ | ||
getModuleByFolder(folder: string): IndexedModule | undefined { | ||
return this.#modulesByFolder[folder]; | ||
} | ||
/** | ||
* Resolve import | ||
@@ -212,11 +211,2 @@ */ | ||
/** | ||
* Get module from import name | ||
* @param importName | ||
*/ | ||
getModuleFromImport(importName: string): IndexedModule | undefined { | ||
const name = this.getFromImport(importName)?.module; | ||
return name ? this.getModule(name) : undefined; | ||
} | ||
/** | ||
* Build module list from an expression list (e.g. `@travetto/rest,-@travetto/log) | ||
@@ -275,2 +265,32 @@ */ | ||
} | ||
/** | ||
* Get manifest module by name | ||
*/ | ||
getManifestModule(mod: string): ManifestModule { | ||
return this.manifest.modules[mod]; | ||
} | ||
/** | ||
* Get manifest modules | ||
*/ | ||
getManifestModules(): ManifestModule[] { | ||
return Object.values(this.manifest.modules); | ||
} | ||
/** | ||
* Get main module for manifest | ||
*/ | ||
get mainModule(): IndexedModule { | ||
return this.getModule(this.manifest.main.name)!; | ||
} | ||
/** | ||
* Get source file from import location | ||
* @param importFile | ||
*/ | ||
getSourceFile(importFile: string | [string, string]): string { | ||
importFile = Array.isArray(importFile) ? importFile.join('/') : importFile; | ||
return this.getFromImport(importFile)?.sourceFile ?? importFile; | ||
} | ||
} |
@@ -11,11 +11,2 @@ export type NodeModuleType = 'module' | 'commonjs'; | ||
export type ManifestModuleRole = 'std' | 'test' | 'doc' | 'compile' | 'build'; | ||
export type FunctionMetadataTag = { hash: number, lines: [number, number] }; | ||
export type FunctionMetadata = FunctionMetadataTag & { | ||
id: string; | ||
source: string; | ||
methods?: Record<string, FunctionMetadataTag>; | ||
synthetic?: boolean; | ||
abstract?: boolean; | ||
}; | ||
export type ManifestModuleRole = 'std' | 'test' | 'doc' | 'compile' | 'build'; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61901
18
1379
219