@venizia/ignis-boot 0.4.3 → 0.4.5

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 (116) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +17 -4
  3. package/dist/esm/build-info/resolver.d.ts +2 -2
  4. package/dist/esm/build-info/resolver.d.ts.map +1 -1
  5. package/dist/esm/build-info/resolver.js +17 -11
  6. package/dist/esm/build-info/resolver.js.map +1 -1
  7. package/dist/esm/bun/plugin.d.ts +1 -1
  8. package/dist/esm/bun/plugin.d.ts.map +1 -1
  9. package/dist/esm/bun/plugin.js +2 -2
  10. package/dist/esm/bun/plugin.js.map +1 -1
  11. package/dist/esm/clis/artifacts.js +0 -0
  12. package/package.json +19 -33
  13. package/dist/cjs/build-info/common/constants.d.ts +0 -12
  14. package/dist/cjs/build-info/common/constants.d.ts.map +0 -1
  15. package/dist/cjs/build-info/common/constants.js +0 -32
  16. package/dist/cjs/build-info/common/constants.js.map +0 -1
  17. package/dist/cjs/build-info/common/index.d.ts +0 -2
  18. package/dist/cjs/build-info/common/index.d.ts.map +0 -1
  19. package/dist/cjs/build-info/common/index.js +0 -18
  20. package/dist/cjs/build-info/common/index.js.map +0 -1
  21. package/dist/cjs/build-info/index.d.ts +0 -4
  22. package/dist/cjs/build-info/index.d.ts.map +0 -1
  23. package/dist/cjs/build-info/index.js +0 -20
  24. package/dist/cjs/build-info/index.js.map +0 -1
  25. package/dist/cjs/build-info/resolver.d.ts +0 -25
  26. package/dist/cjs/build-info/resolver.d.ts.map +0 -1
  27. package/dist/cjs/build-info/resolver.js +0 -105
  28. package/dist/cjs/build-info/resolver.js.map +0 -1
  29. package/dist/cjs/build-info/stamp.d.ts +0 -22
  30. package/dist/cjs/build-info/stamp.d.ts.map +0 -1
  31. package/dist/cjs/build-info/stamp.js +0 -36
  32. package/dist/cjs/build-info/stamp.js.map +0 -1
  33. package/dist/cjs/bun/auto-group.d.ts +0 -22
  34. package/dist/cjs/bun/auto-group.d.ts.map +0 -1
  35. package/dist/cjs/bun/auto-group.js +0 -51
  36. package/dist/cjs/bun/auto-group.js.map +0 -1
  37. package/dist/cjs/bun/auto-loader.d.ts +0 -13
  38. package/dist/cjs/bun/auto-loader.d.ts.map +0 -1
  39. package/dist/cjs/bun/auto-loader.js +0 -63
  40. package/dist/cjs/bun/auto-loader.js.map +0 -1
  41. package/dist/cjs/bun/auto.d.ts +0 -5
  42. package/dist/cjs/bun/auto.d.ts.map +0 -1
  43. package/dist/cjs/bun/auto.js +0 -11
  44. package/dist/cjs/bun/auto.js.map +0 -1
  45. package/dist/cjs/bun/group-resolver.d.ts +0 -16
  46. package/dist/cjs/bun/group-resolver.d.ts.map +0 -1
  47. package/dist/cjs/bun/group-resolver.js +0 -44
  48. package/dist/cjs/bun/group-resolver.js.map +0 -1
  49. package/dist/cjs/bun/index.d.ts +0 -7
  50. package/dist/cjs/bun/index.d.ts.map +0 -1
  51. package/dist/cjs/bun/index.js +0 -23
  52. package/dist/cjs/bun/index.js.map +0 -1
  53. package/dist/cjs/bun/plugin.d.ts +0 -67
  54. package/dist/cjs/bun/plugin.d.ts.map +0 -1
  55. package/dist/cjs/bun/plugin.js +0 -395
  56. package/dist/cjs/bun/plugin.js.map +0 -1
  57. package/dist/cjs/bun/scan-cache.d.ts +0 -22
  58. package/dist/cjs/bun/scan-cache.d.ts.map +0 -1
  59. package/dist/cjs/bun/scan-cache.js +0 -89
  60. package/dist/cjs/bun/scan-cache.js.map +0 -1
  61. package/dist/cjs/bun/sources.d.ts +0 -49
  62. package/dist/cjs/bun/sources.d.ts.map +0 -1
  63. package/dist/cjs/bun/sources.js +0 -115
  64. package/dist/cjs/bun/sources.js.map +0 -1
  65. package/dist/cjs/clis/artifacts.d.ts +0 -3
  66. package/dist/cjs/clis/artifacts.d.ts.map +0 -1
  67. package/dist/cjs/clis/artifacts.js +0 -62
  68. package/dist/cjs/clis/artifacts.js.map +0 -1
  69. package/dist/cjs/common/install-quiet-logger.d.ts +0 -2
  70. package/dist/cjs/common/install-quiet-logger.d.ts.map +0 -1
  71. package/dist/cjs/common/install-quiet-logger.js +0 -7
  72. package/dist/cjs/common/install-quiet-logger.js.map +0 -1
  73. package/dist/cjs/common/quiet-logger.d.ts +0 -18
  74. package/dist/cjs/common/quiet-logger.d.ts.map +0 -1
  75. package/dist/cjs/common/quiet-logger.js +0 -46
  76. package/dist/cjs/common/quiet-logger.js.map +0 -1
  77. package/dist/cjs/generator/common/constants.d.ts +0 -59
  78. package/dist/cjs/generator/common/constants.d.ts.map +0 -1
  79. package/dist/cjs/generator/common/constants.js +0 -102
  80. package/dist/cjs/generator/common/constants.js.map +0 -1
  81. package/dist/cjs/generator/common/index.d.ts +0 -3
  82. package/dist/cjs/generator/common/index.d.ts.map +0 -1
  83. package/dist/cjs/generator/common/index.js +0 -19
  84. package/dist/cjs/generator/common/index.js.map +0 -1
  85. package/dist/cjs/generator/common/types.d.ts +0 -33
  86. package/dist/cjs/generator/common/types.d.ts.map +0 -1
  87. package/dist/cjs/generator/common/types.js +0 -3
  88. package/dist/cjs/generator/common/types.js.map +0 -1
  89. package/dist/cjs/generator/emitter.d.ts +0 -41
  90. package/dist/cjs/generator/emitter.d.ts.map +0 -1
  91. package/dist/cjs/generator/emitter.js +0 -82
  92. package/dist/cjs/generator/emitter.js.map +0 -1
  93. package/dist/cjs/generator/index.d.ts +0 -26
  94. package/dist/cjs/generator/index.d.ts.map +0 -1
  95. package/dist/cjs/generator/index.js +0 -68
  96. package/dist/cjs/generator/index.js.map +0 -1
  97. package/dist/cjs/generator/reexport.d.ts +0 -28
  98. package/dist/cjs/generator/reexport.d.ts.map +0 -1
  99. package/dist/cjs/generator/reexport.js +0 -131
  100. package/dist/cjs/generator/reexport.js.map +0 -1
  101. package/dist/cjs/generator/scanner.d.ts +0 -26
  102. package/dist/cjs/generator/scanner.d.ts.map +0 -1
  103. package/dist/cjs/generator/scanner.js +0 -258
  104. package/dist/cjs/generator/scanner.js.map +0 -1
  105. package/dist/cjs/index.d.ts +0 -3
  106. package/dist/cjs/index.d.ts.map +0 -1
  107. package/dist/cjs/index.js +0 -19
  108. package/dist/cjs/index.js.map +0 -1
  109. package/dist/cjs/vite/index.d.ts +0 -2
  110. package/dist/cjs/vite/index.d.ts.map +0 -1
  111. package/dist/cjs/vite/index.js +0 -18
  112. package/dist/cjs/vite/index.js.map +0 -1
  113. package/dist/cjs/vite/plugin.d.ts +0 -29
  114. package/dist/cjs/vite/plugin.d.ts.map +0 -1
  115. package/dist/cjs/vite/plugin.js +0 -61
  116. package/dist/cjs/vite/plugin.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"reexport.js","sourceRoot":"","sources":["../../../src/generator/reexport.ts"],"names":[],"mappings":";;;;;;AAAA,0DAAoD;AACpD,qCAAuC;AACvC,yCAAoC;AACpC,4DAA4B;AAC5B,qCAA+C;AAE/C,8OAA8O;AAC9O,MAAa,0BAA2B,SAAQ,0BAAU;aACxC,cAAS,GAAG,EAAE,AAAL,CAAM;IAS/B,YAAY,IAAkD;QAC5D,KAAK,CAAC,EAAE,KAAK,EAAE,0BAA0B,CAAC,IAAI,EAAE,CAAC,CAAC;QANpD,mHAAmH;QAClG,gBAAW,GAAG,IAAI,GAAG,EAA8B,CAAC;QACpD,YAAO,GAAG,IAAI,GAAG,EAAyB,CAAC;QAC3C,YAAO,GAAG,IAAI,GAAG,EAA8B,CAAC;QAI/D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC;QACxC,IAAI,CAAC,OAAO,GAAG,0BAA0B,CAAC,kBAAkB,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IACpF,CAAC;IAED,qGAAqG;IAC7F,MAAM,CAAC,kBAAkB,CAAC,IAAsB;QACtD,MAAM,UAAU,GAAG,oBAAE,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,oBAAE,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;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;gBAC7D,IAAI,aAAa,EAAE,CAAC;oBAClB,OAAO,IAAI,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;gBAC5D,CAAC;gBACD,MAAM,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;gBAC1C,OAAO,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YAC/C,CAAC;QACH,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;;AA3JH,gEA4JC","sourcesContent":["import { BaseHelper } from '@venizia/ignis-helpers';\nimport { readFileSync } from 'node:fs';\nimport { dirname } from 'node:path';\nimport ts from 'typescript';\nimport { ArtifactStereotypes } from './common';\n\n/** Follows a named import through `export *` and renaming re-exports until it reaches a source module, so a framework that re-exports the kernel's decorators is recognised. Reads declarations only; never builds a type-checked program. */\nexport class StereotypeReexportResolver extends BaseHelper {\n static readonly MAX_DEPTH = 10;\n\n private readonly options: ts.CompilerOptions;\n private readonly sourceModules: Set<string>;\n /** One scan reads the same barrels many times: resolutions, parsed files and answers are memoized per resolver. */\n private readonly resolutions = new Map<string, string | undefined>();\n private readonly sources = new Map<string, ts.SourceFile>();\n private readonly origins = new Map<string, string | undefined>();\n\n constructor(opts: { root: string; sourceModules: Set<string> }) {\n super({ scope: StereotypeReexportResolver.name });\n this.sourceModules = opts.sourceModules;\n this.options = StereotypeReexportResolver.compilerOptionsFor({ root: opts.root });\n }\n\n /** The nearest tsconfig's options (for `paths` aliases), with bundler resolution as the fallback. */\n private static compilerOptionsFor(opts: { root: string }): ts.CompilerOptions {\n const configPath = ts.findConfigFile(opts.root, ts.sys.fileExists);\n const fallback: ts.CompilerOptions = {\n module: ts.ModuleKind.ESNext,\n moduleResolution: ts.ModuleResolutionKind.Bundler,\n allowJs: true,\n };\n if (!configPath) {\n return fallback;\n }\n\n const parsed = ts.parseJsonConfigFileContent(\n ts.readConfigFile(configPath, ts.sys.readFile).config,\n ts.sys,\n dirname(configPath),\n );\n return { ...fallback, ...parsed.options };\n }\n\n /** The kernel name `name` (exported by `specifier`, as seen from `fromFile`) originates as, or `undefined` when the chain never reaches a source module. */\n originOf(opts: { fromFile: string; specifier: string; name: string }): string | undefined {\n const key = `${dirname(opts.fromFile)}|${opts.specifier}|${opts.name}`;\n if (!this.origins.has(key)) {\n this.origins.set(key, this.follow({ ...opts, depth: 0, seen: new Set<string>() }));\n }\n return this.origins.get(key);\n }\n\n private resolveFile(opts: { fromFile: string; specifier: string }): string | undefined {\n const key = `${dirname(opts.fromFile)}|${opts.specifier}`;\n if (!this.resolutions.has(key)) {\n this.resolutions.set(\n key,\n ts.resolveModuleName(opts.specifier, opts.fromFile, this.options, ts.sys).resolvedModule\n ?.resolvedFileName,\n );\n }\n return this.resolutions.get(key);\n }\n\n private parse(opts: { file: string }): ts.SourceFile {\n let source = this.sources.get(opts.file);\n if (!source) {\n source = ts.createSourceFile(\n opts.file,\n readFileSync(opts.file, 'utf8'),\n ts.ScriptTarget.Latest,\n true,\n );\n this.sources.set(opts.file, source);\n }\n return source;\n }\n\n private isSourceModule(opts: { specifier: string }): boolean {\n return (\n ArtifactStereotypes.SOURCE_MODULES.test(opts.specifier) ||\n this.sourceModules.has(opts.specifier)\n );\n }\n\n private follow(opts: {\n fromFile: string;\n specifier: string;\n name: string;\n depth: number;\n seen: Set<string>;\n }): string | undefined {\n const { fromFile, specifier, name, depth, seen } = opts;\n if (this.isSourceModule({ specifier })) {\n return name;\n }\n if (depth >= StereotypeReexportResolver.MAX_DEPTH) {\n return undefined;\n }\n\n const resolved = this.resolveFile({ fromFile, specifier });\n const visit = `${resolved}#${name}`;\n if (!resolved || seen.has(visit)) {\n return undefined;\n }\n seen.add(visit);\n\n const source = this.parse({ file: resolved });\n const next = (target: { specifier: string; name: string }): string | undefined =>\n this.follow({ fromFile: resolved, ...target, depth: depth + 1, seen });\n\n const importedBy = new Map<string, { specifier: string; name: string }>();\n for (const statement of source.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {\n continue;\n }\n const bindings = statement.importClause?.namedBindings;\n if (!bindings || !ts.isNamedImports(bindings)) {\n continue;\n }\n for (const element of bindings.elements) {\n importedBy.set(element.name.text, {\n specifier: statement.moduleSpecifier.text,\n name: (element.propertyName ?? element.name).text,\n });\n }\n }\n\n for (const statement of source.statements) {\n if (!ts.isExportDeclaration(statement) || statement.isTypeOnly) {\n continue;\n }\n const fromSpecifier =\n statement.moduleSpecifier && ts.isStringLiteral(statement.moduleSpecifier)\n ? statement.moduleSpecifier.text\n : undefined;\n\n if (!statement.exportClause) {\n const origin = fromSpecifier ? next({ specifier: fromSpecifier, name }) : undefined;\n if (origin) {\n return origin;\n }\n continue;\n }\n if (!ts.isNamedExports(statement.exportClause)) {\n continue;\n }\n\n for (const element of statement.exportClause.elements) {\n if (element.name.text !== name) {\n continue;\n }\n const original = (element.propertyName ?? element.name).text;\n if (fromSpecifier) {\n return next({ specifier: fromSpecifier, name: original });\n }\n const imported = importedBy.get(original);\n return imported ? next(imported) : undefined;\n }\n }\n\n return undefined;\n }\n}\n"]}
@@ -1,26 +0,0 @@
1
- import { BaseHelper } from '@venizia/ignis-helpers';
2
- import { type IScanOptions, type IScanReport, type IScannedArtifact } from './common';
3
- /** Finds exported classes carrying a stereotype decorator by reading the source, never by running it. */
4
- export declare class ArtifactScanner extends BaseHelper {
5
- private static instance?;
6
- private constructor();
7
- static getInstance(): ArtifactScanner;
8
- scan(opts: IScanOptions): IScannedArtifact[];
9
- /** `scan` plus the decorated classes a caller's own `ignore` pattern hid - the generator prints them so a stale pattern cannot drop an artifact in silence. */
10
- scanWithReport(opts: IScanOptions): IScanReport;
11
- /** A hidden file is only reported on, never a reason to fail: a scan error becomes one warning and the file contributes nothing. */
12
- private scanHiddenFile;
13
- private sortArtifacts;
14
- /** `kept` feeds the index; `hidden` is what only a user pattern excluded (a default pattern wins, so tests and generated files are never reported). */
15
- private partitionSourceFiles;
16
- private scanFile;
17
- /** local identifier -> stereotype name, for named imports from an IGNIS module or a caller-named source module (aliases resolved). */
18
- private collectStereotypeImports;
19
- /** The identifiers called as decorators on the file's top-level classes (`@service()`, `@kit.service()` is not followed). */
20
- private collectClassDecoratorNames;
21
- private collectExportClauseNames;
22
- private artifactTypesOf;
23
- private typeOfInjectableCall;
24
- private asArtifactType;
25
- }
26
- //# sourceMappingURL=scanner.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../../../src/generator/scanner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAY,MAAM,wBAAwB,CAAC;AAI9D,OAAO,EAIL,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,KAAK,gBAAgB,EAEtB,MAAM,UAAU,CAAC;AAGlB,yGAAyG;AACzG,qBAAa,eAAgB,SAAQ,UAAU;IAC7C,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAkB;IAE1C,OAAO;IAIP,MAAM,CAAC,WAAW,IAAI,eAAe;IAIrC,IAAI,CAAC,IAAI,EAAE,YAAY,GAAG,gBAAgB,EAAE;IAI5C,+JAA+J;IAC/J,cAAc,CAAC,IAAI,EAAE,YAAY,GAAG,WAAW;IA8B/C,oIAAoI;IACpI,OAAO,CAAC,cAAc;IActB,OAAO,CAAC,aAAa;IAMrB,uJAAuJ;IACvJ,OAAO,CAAC,oBAAoB;IAyB5B,OAAO,CAAC,QAAQ;IAgFhB,sIAAsI;IACtI,OAAO,CAAC,wBAAwB;IAkDhC,6HAA6H;IAC7H,OAAO,CAAC,0BAA0B;IAgBlC,OAAO,CAAC,wBAAwB;IAkBhC,OAAO,CAAC,eAAe;IA0CvB,OAAO,CAAC,oBAAoB;IA6B5B,OAAO,CAAC,cAAc;CAMvB"}
@@ -1,258 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ArtifactScanner = void 0;
7
- const ignis_helpers_1 = require("@venizia/ignis-helpers");
8
- const node_fs_1 = require("node:fs");
9
- const node_path_1 = require("node:path");
10
- const typescript_1 = __importDefault(require("typescript"));
11
- const common_1 = require("./common");
12
- const reexport_1 = require("./reexport");
13
- /** Finds exported classes carrying a stereotype decorator by reading the source, never by running it. */
14
- class ArtifactScanner extends ignis_helpers_1.BaseHelper {
15
- constructor() {
16
- super({ scope: ArtifactScanner.name });
17
- }
18
- static getInstance() {
19
- return (this.instance ??= new ArtifactScanner());
20
- }
21
- scan(opts) {
22
- return this.scanWithReport(opts).artifacts;
23
- }
24
- /** `scan` plus the decorated classes a caller's own `ignore` pattern hid - the generator prints them so a stale pattern cannot drop an artifact in silence. */
25
- scanWithReport(opts) {
26
- const root = (0, node_path_1.resolve)(opts.root);
27
- const { kept, hidden } = this.partitionSourceFiles({
28
- root,
29
- defaultGlobs: common_1.ArtifactStereotypes.DEFAULT_IGNORE,
30
- userGlobs: opts.ignore ?? [],
31
- });
32
- const sourceModules = new Set(opts.sourceModules);
33
- const resolver = opts.followReexports
34
- ? new reexport_1.StereotypeReexportResolver({ root, sourceModules })
35
- : undefined;
36
- const skipped = [];
37
- const artifacts = this.sortArtifacts(kept.flatMap((filePath) => this.scanFile({ filePath, sourceModules, resolver, skipped })));
38
- const ignored = this.sortArtifacts(hidden.flatMap((filePath) => this.scanHiddenFile({ filePath, sourceModules, resolver })));
39
- for (const artifact of ignored) {
40
- skipped.push({
41
- className: artifact.className,
42
- filePath: artifact.filePath,
43
- reason: common_1.ScanSkipReasons.IGNORED,
44
- });
45
- }
46
- return { artifacts, ignored, skipped };
47
- }
48
- /** A hidden file is only reported on, never a reason to fail: a scan error becomes one warning and the file contributes nothing. */
49
- scanHiddenFile(opts) {
50
- try {
51
- return this.scanFile({ ...opts, isHidden: true });
52
- }
53
- catch (error) {
54
- const reason = error instanceof Error ? error.message : String(error);
55
- this.logger.for('scanHiddenFile').warn('Skipped hidden file %s | %s', opts.filePath, reason);
56
- return [];
57
- }
58
- }
59
- sortArtifacts(artifacts) {
60
- return artifacts.sort((a, b) => a.type.localeCompare(b.type) || a.className.localeCompare(b.className));
61
- }
62
- /** `kept` feeds the index; `hidden` is what only a user pattern excluded (a default pattern wins, so tests and generated files are never reported). */
63
- partitionSourceFiles(opts) {
64
- const kept = [];
65
- const hidden = [];
66
- const sources = (0, node_fs_1.globSync)(common_1.ArtifactStereotypes.SOURCE_GLOB, { cwd: opts.root });
67
- for (const relative of sources) {
68
- if (relative.endsWith('.d.ts') ||
69
- opts.defaultGlobs.some((pattern) => (0, node_path_1.matchesGlob)(relative, pattern))) {
70
- continue;
71
- }
72
- const target = opts.userGlobs.some((pattern) => (0, node_path_1.matchesGlob)(relative, pattern))
73
- ? hidden
74
- : kept;
75
- target.push((0, node_path_1.join)(opts.root, relative));
76
- }
77
- return { kept: kept.sort(), hidden: hidden.sort() };
78
- }
79
- scanFile(opts) {
80
- const { filePath, sourceModules, resolver, skipped, isHidden = false } = opts;
81
- const source = typescript_1.default.createSourceFile(filePath, (0, node_fs_1.readFileSync)(filePath, 'utf8'), typescript_1.default.ScriptTarget.Latest, true);
82
- const stereotypeByLocalName = this.collectStereotypeImports({
83
- source,
84
- sourceModules,
85
- resolver,
86
- });
87
- if (stereotypeByLocalName.size === 0) {
88
- return [];
89
- }
90
- const exportedNames = this.collectExportClauseNames({ source });
91
- const found = [];
92
- typescript_1.default.forEachChild(source, (node) => {
93
- if (!typescript_1.default.isClassDeclaration(node) || !node.name) {
94
- return;
95
- }
96
- const className = node.name.text;
97
- const types = this.artifactTypesOf({
98
- node,
99
- stereotypeByLocalName,
100
- filePath,
101
- className,
102
- });
103
- if (types.length === 0) {
104
- return;
105
- }
106
- if (types.length > 1) {
107
- throw (0, ignis_helpers_1.getError)({
108
- message: `[ArtifactScanner] ${filePath} | class ${className} carries ${types.length} stereotypes (${types.join(', ')}) - one class is one artifact`,
109
- });
110
- }
111
- const modifiers = typescript_1.default.getModifiers(node) ?? [];
112
- const has = (kind) => modifiers.some((m) => m.kind === kind);
113
- const isNamedExport = (has(typescript_1.default.SyntaxKind.ExportKeyword) && !has(typescript_1.default.SyntaxKind.DefaultKeyword)) ||
114
- exportedNames.has(className);
115
- const isAbstract = has(typescript_1.default.SyntaxKind.AbstractKeyword);
116
- if (!isNamedExport || isAbstract) {
117
- if (!isHidden) {
118
- skipped?.push({
119
- className,
120
- filePath,
121
- reason: isAbstract ? common_1.ScanSkipReasons.ABSTRACT : common_1.ScanSkipReasons.NOT_EXPORTED,
122
- });
123
- this.logger
124
- .for('scanFile')
125
- .warn('Skipped %s in %s | %s', className, filePath, isAbstract ? 'abstract' : 'not a named export');
126
- }
127
- return;
128
- }
129
- found.push({ className, filePath, type: types[0] });
130
- });
131
- return found;
132
- }
133
- /** local identifier -> stereotype name, for named imports from an IGNIS module or a caller-named source module (aliases resolved). */
134
- collectStereotypeImports(opts) {
135
- const result = new Map();
136
- // Only a name a class actually wears as a decorator is worth following through re-exports.
137
- const decoratorNames = opts.resolver
138
- ? this.collectClassDecoratorNames({ source: opts.source })
139
- : new Set();
140
- for (const statement of opts.source.statements) {
141
- if (!typescript_1.default.isImportDeclaration(statement) || !typescript_1.default.isStringLiteral(statement.moduleSpecifier)) {
142
- continue;
143
- }
144
- const specifier = statement.moduleSpecifier.text;
145
- const isSourceModule = common_1.ArtifactStereotypes.SOURCE_MODULES.test(specifier) || opts.sourceModules.has(specifier);
146
- if (!isSourceModule && !opts.resolver) {
147
- continue;
148
- }
149
- const bindings = statement.importClause?.namedBindings;
150
- if (!bindings || !typescript_1.default.isNamedImports(bindings)) {
151
- continue;
152
- }
153
- for (const element of bindings.elements) {
154
- const name = (element.propertyName ?? element.name).text;
155
- if (!isSourceModule && !decoratorNames.has(element.name.text)) {
156
- continue;
157
- }
158
- const imported = isSourceModule
159
- ? name
160
- : opts.resolver?.originOf({ fromFile: opts.source.fileName, specifier, name });
161
- if (!imported) {
162
- continue;
163
- }
164
- const isStereotype = imported in common_1.ArtifactStereotypes.BY_DECORATOR ||
165
- imported === common_1.ArtifactStereotypes.ROOT_DECORATOR;
166
- if (isStereotype) {
167
- result.set(element.name.text, imported);
168
- }
169
- }
170
- }
171
- return result;
172
- }
173
- /** The identifiers called as decorators on the file's top-level classes (`@service()`, `@kit.service()` is not followed). */
174
- collectClassDecoratorNames(opts) {
175
- const names = new Set();
176
- for (const statement of opts.source.statements) {
177
- if (!typescript_1.default.isClassDeclaration(statement)) {
178
- continue;
179
- }
180
- for (const decorator of typescript_1.default.getDecorators(statement) ?? []) {
181
- const expression = decorator.expression;
182
- if (typescript_1.default.isCallExpression(expression) && typescript_1.default.isIdentifier(expression.expression)) {
183
- names.add(expression.expression.text);
184
- }
185
- }
186
- }
187
- return names;
188
- }
189
- collectExportClauseNames(opts) {
190
- const names = new Set();
191
- for (const statement of opts.source.statements) {
192
- if (typescript_1.default.isExportDeclaration(statement) &&
193
- statement.exportClause &&
194
- typescript_1.default.isNamedExports(statement.exportClause)) {
195
- for (const element of statement.exportClause.elements) {
196
- names.add((element.propertyName ?? element.name).text);
197
- }
198
- }
199
- }
200
- return names;
201
- }
202
- artifactTypesOf(opts) {
203
- const { node, stereotypeByLocalName, filePath, className } = opts;
204
- const types = [];
205
- const decorators = typescript_1.default.getDecorators(node) ?? [];
206
- for (const decorator of decorators) {
207
- const expression = decorator.expression;
208
- if (!typescript_1.default.isCallExpression(expression) || !typescript_1.default.isIdentifier(expression.expression)) {
209
- continue;
210
- }
211
- const stereotype = stereotypeByLocalName.get(expression.expression.text);
212
- if (!stereotype) {
213
- continue;
214
- }
215
- if (stereotype !== common_1.ArtifactStereotypes.ROOT_DECORATOR) {
216
- types.push(common_1.ArtifactStereotypes.BY_DECORATOR[stereotype]);
217
- continue;
218
- }
219
- const type = this.typeOfInjectableCall({ call: expression });
220
- if (!type) {
221
- this.logger
222
- .for('artifactTypesOf')
223
- .warn('Skipped %s in %s | @injectable type is not a literal or ArtifactTypes.<NAME>', className, filePath);
224
- continue;
225
- }
226
- types.push(type);
227
- }
228
- return types;
229
- }
230
- typeOfInjectableCall(opts) {
231
- const [argument] = opts.call.arguments;
232
- if (!argument || !typescript_1.default.isObjectLiteralExpression(argument)) {
233
- return undefined;
234
- }
235
- const property = argument.properties.find((entry) => typescript_1.default.isPropertyAssignment(entry) && typescript_1.default.isIdentifier(entry.name) && entry.name.text === 'type');
236
- if (!property) {
237
- return undefined;
238
- }
239
- const value = property.initializer;
240
- if (typescript_1.default.isStringLiteral(value)) {
241
- return this.asArtifactType({ raw: value.text });
242
- }
243
- if (typescript_1.default.isPropertyAccessExpression(value) &&
244
- typescript_1.default.isIdentifier(value.expression) &&
245
- value.expression.text === 'ArtifactTypes') {
246
- return this.asArtifactType({ raw: value.name.text.toLowerCase() });
247
- }
248
- return undefined;
249
- }
250
- asArtifactType(opts) {
251
- const { raw } = opts;
252
- return common_1.ArtifactStereotypes.EMIT_ORDER.map((entry) => entry.type)
253
- .concat(common_1.ArtifactTypes.MODEL)
254
- .find((type) => type === raw);
255
- }
256
- }
257
- exports.ArtifactScanner = ArtifactScanner;
258
- //# sourceMappingURL=scanner.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scanner.js","sourceRoot":"","sources":["../../../src/generator/scanner.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA8D;AAC9D,qCAAiD;AACjD,yCAAuD;AACvD,4DAA4B;AAC5B,qCASkB;AAClB,yCAAwD;AAExD,yGAAyG;AACzG,MAAa,eAAgB,SAAQ,0BAAU;IAG7C;QACE,KAAK,CAAC,EAAE,KAAK,EAAE,eAAe,CAAC,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IAED,MAAM,CAAC,WAAW;QAChB,OAAO,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,eAAe,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,CAAC,IAAkB;QACrB,OA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ClC,CAAC;CACF;AAhVD,0CAgVC","sourcesContent":["import { BaseHelper, getError } from '@venizia/ignis-helpers';\nimport { globSync, readFileSync } from 'node:fs';\nimport { join, matchesGlob, resolve } from 'node:path';\nimport ts from 'typescript';\nimport {\n ArtifactStereotypes,\n ArtifactTypes,\n ScanSkipReasons,\n type IScanOptions,\n type IScanReport,\n type IScanSkipped,\n type IScannedArtifact,\n type TArtifactType,\n} from './common';\nimport { StereotypeReexportResolver } from './reexport';\n\n/** Finds exported classes carrying a stereotype decorator by reading the source, never by running it. */\nexport class ArtifactScanner extends BaseHelper {\n private static instance?: ArtifactScanner;\n\n private constructor() {\n super({ scope: ArtifactScanner.name });\n }\n\n static getInstance(): ArtifactScanner {\n return (this.instance ??= new ArtifactScanner());\n }\n\n scan(opts: IScanOptions): IScannedArtifact[] {\n return this.scanWithReport(opts).artifacts;\n }\n\n /** `scan` plus the decorated classes a caller's own `ignore` pattern hid - the generator prints them so a stale pattern cannot drop an artifact in silence. */\n scanWithReport(opts: IScanOptions): IScanReport {\n const root = resolve(opts.root);\n const { kept, hidden } = this.partitionSourceFiles({\n root,\n defaultGlobs: ArtifactStereotypes.DEFAULT_IGNORE,\n userGlobs: opts.ignore ?? [],\n });\n const sourceModules = new Set(opts.sourceModules);\n const resolver = opts.followReexports\n ? new StereotypeReexportResolver({ root, sourceModules })\n : undefined;\n const skipped: IScanSkipped[] = [];\n\n const artifacts = this.sortArtifacts(\n kept.flatMap((filePath) => this.scanFile({ filePath, sourceModules, resolver, skipped })),\n );\n const ignored = this.sortArtifacts(\n hidden.flatMap((filePath) => this.scanHiddenFile({ filePath, sourceModules, resolver })),\n );\n for (const artifact of ignored) {\n skipped.push({\n className: artifact.className,\n filePath: artifact.filePath,\n reason: ScanSkipReasons.IGNORED,\n });\n }\n\n return { artifacts, ignored, skipped };\n }\n\n /** A hidden file is only reported on, never a reason to fail: a scan error becomes one warning and the file contributes nothing. */\n private scanHiddenFile(opts: {\n filePath: string;\n sourceModules: Set<string>;\n resolver?: StereotypeReexportResolver;\n }): IScannedArtifact[] {\n try {\n return this.scanFile({ ...opts, isHidden: true });\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n this.logger.for('scanHiddenFile').warn('Skipped hidden file %s | %s', opts.filePath, reason);\n return [];\n }\n }\n\n private sortArtifacts(artifacts: IScannedArtifact[]): IScannedArtifact[] {\n return artifacts.sort(\n (a, b) => a.type.localeCompare(b.type) || a.className.localeCompare(b.className),\n );\n }\n\n /** `kept` feeds the index; `hidden` is what only a user pattern excluded (a default pattern wins, so tests and generated files are never reported). */\n private partitionSourceFiles(opts: {\n root: string;\n defaultGlobs: ReadonlyArray<string>;\n userGlobs: ReadonlyArray<string>;\n }): { kept: string[]; hidden: string[] } {\n const kept: string[] = [];\n const hidden: string[] = [];\n\n const sources = globSync(ArtifactStereotypes.SOURCE_GLOB, { cwd: opts.root });\n for (const relative of sources) {\n if (\n relative.endsWith('.d.ts') ||\n opts.defaultGlobs.some((pattern) => matchesGlob(relative, pattern))\n ) {\n continue;\n }\n const target = opts.userGlobs.some((pattern) => matchesGlob(relative, pattern))\n ? hidden\n : kept;\n target.push(join(opts.root, relative));\n }\n\n return { kept: kept.sort(), hidden: hidden.sort() };\n }\n\n private scanFile(opts: {\n filePath: string;\n sourceModules: Set<string>;\n resolver?: StereotypeReexportResolver;\n skipped?: IScanSkipped[];\n isHidden?: boolean;\n }): IScannedArtifact[] {\n const { filePath, sourceModules, resolver, skipped, isHidden = false } = opts;\n const source = ts.createSourceFile(\n filePath,\n readFileSync(filePath, 'utf8'),\n ts.ScriptTarget.Latest,\n true,\n );\n\n const stereotypeByLocalName = this.collectStereotypeImports({\n source,\n sourceModules,\n resolver,\n });\n if (stereotypeByLocalName.size === 0) {\n return [];\n }\n\n const exportedNames = this.collectExportClauseNames({ source });\n const found: IScannedArtifact[] = [];\n\n ts.forEachChild(source, (node) => {\n if (!ts.isClassDeclaration(node) || !node.name) {\n return;\n }\n\n const className = node.name.text;\n const types = this.artifactTypesOf({\n node,\n stereotypeByLocalName,\n filePath,\n className,\n });\n if (types.length === 0) {\n return;\n }\n if (types.length > 1) {\n throw getError({\n message: `[ArtifactScanner] ${filePath} | class ${className} carries ${types.length} stereotypes (${types.join(', ')}) - one class is one artifact`,\n });\n }\n\n const modifiers = ts.getModifiers(node) ?? [];\n const has = (kind: ts.SyntaxKind): boolean => modifiers.some((m) => m.kind === kind);\n const isNamedExport =\n (has(ts.SyntaxKind.ExportKeyword) && !has(ts.SyntaxKind.DefaultKeyword)) ||\n exportedNames.has(className);\n const isAbstract = has(ts.SyntaxKind.AbstractKeyword);\n\n if (!isNamedExport || isAbstract) {\n if (!isHidden) {\n skipped?.push({\n className,\n filePath,\n reason: isAbstract ? ScanSkipReasons.ABSTRACT : ScanSkipReasons.NOT_EXPORTED,\n });\n this.logger\n .for('scanFile')\n .warn(\n 'Skipped %s in %s | %s',\n className,\n filePath,\n isAbstract ? 'abstract' : 'not a named export',\n );\n }\n return;\n }\n\n found.push({ className, filePath, type: types[0] });\n });\n\n return found;\n }\n\n /** local identifier -> stereotype name, for named imports from an IGNIS module or a caller-named source module (aliases resolved). */\n private collectStereotypeImports(opts: {\n source: ts.SourceFile;\n sourceModules: Set<string>;\n resolver?: StereotypeReexportResolver;\n }): Map<string, string> {\n const result = new Map<string, string>();\n // Only a name a class actually wears as a decorator is worth following through re-exports.\n const decoratorNames = opts.resolver\n ? this.collectClassDecoratorNames({ source: opts.source })\n : new Set<string>();\n\n for (const statement of opts.source.statements) {\n if (!ts.isImportDeclaration(statement) || !ts.isStringLiteral(statement.moduleSpecifier)) {\n continue;\n }\n const specifier = statement.moduleSpecifier.text;\n const isSourceModule =\n ArtifactStereotypes.SOURCE_MODULES.test(specifier) || opts.sourceModules.has(specifier);\n if (!isSourceModule && !opts.resolver) {\n continue;\n }\n\n const bindings = statement.importClause?.namedBindings;\n if (!bindings || !ts.isNamedImports(bindings)) {\n continue;\n }\n\n for (const element of bindings.elements) {\n const name = (element.propertyName ?? element.name).text;\n if (!isSourceModule && !decoratorNames.has(element.name.text)) {\n continue;\n }\n const imported = isSourceModule\n ? name\n : opts.resolver?.originOf({ fromFile: opts.source.fileName, specifier, name });\n if (!imported) {\n continue;\n }\n const isStereotype =\n imported in ArtifactStereotypes.BY_DECORATOR ||\n imported === ArtifactStereotypes.ROOT_DECORATOR;\n if (isStereotype) {\n result.set(element.name.text, imported);\n }\n }\n }\n\n return result;\n }\n\n /** The identifiers called as decorators on the file's top-level classes (`@service()`, `@kit.service()` is not followed). */\n private collectClassDecoratorNames(opts: { source: ts.SourceFile }): Set<string> {\n const names = new Set<string>();\n for (const statement of opts.source.statements) {\n if (!ts.isClassDeclaration(statement)) {\n continue;\n }\n for (const decorator of ts.getDecorators(statement) ?? []) {\n const expression = decorator.expression;\n if (ts.isCallExpression(expression) && ts.isIdentifier(expression.expression)) {\n names.add(expression.expression.text);\n }\n }\n }\n return names;\n }\n\n private collectExportClauseNames(opts: { source: ts.SourceFile }): Set<string> {\n const names = new Set<string>();\n\n for (const statement of opts.source.statements) {\n if (\n ts.isExportDeclaration(statement) &&\n statement.exportClause &&\n ts.isNamedExports(statement.exportClause)\n ) {\n for (const element of statement.exportClause.elements) {\n names.add((element.propertyName ?? element.name).text);\n }\n }\n }\n\n return names;\n }\n\n private artifactTypesOf(opts: {\n node: ts.ClassDeclaration;\n stereotypeByLocalName: Map<string, string>;\n filePath: string;\n className: string;\n }): TArtifactType[] {\n const { node, stereotypeByLocalName, filePath, className } = opts;\n const types: TArtifactType[] = [];\n\n const decorators = ts.getDecorators(node) ?? [];\n for (const decorator of decorators) {\n const expression = decorator.expression;\n if (!ts.isCallExpression(expression) || !ts.isIdentifier(expression.expression)) {\n continue;\n }\n\n const stereotype = stereotypeByLocalName.get(expression.expression.text);\n if (!stereotype) {\n continue;\n }\n if (stereotype !== ArtifactStereotypes.ROOT_DECORATOR) {\n types.push(ArtifactStereotypes.BY_DECORATOR[stereotype]);\n continue;\n }\n\n const type = this.typeOfInjectableCall({ call: expression });\n if (!type) {\n this.logger\n .for('artifactTypesOf')\n .warn(\n 'Skipped %s in %s | @injectable type is not a literal or ArtifactTypes.<NAME>',\n className,\n filePath,\n );\n continue;\n }\n types.push(type);\n }\n\n return types;\n }\n\n private typeOfInjectableCall(opts: { call: ts.CallExpression }): TArtifactType | undefined {\n const [argument] = opts.call.arguments;\n if (!argument || !ts.isObjectLiteralExpression(argument)) {\n return undefined;\n }\n\n const property = argument.properties.find(\n (entry): entry is ts.PropertyAssignment =>\n ts.isPropertyAssignment(entry) && ts.isIdentifier(entry.name) && entry.name.text === 'type',\n );\n if (!property) {\n return undefined;\n }\n\n const value = property.initializer;\n if (ts.isStringLiteral(value)) {\n return this.asArtifactType({ raw: value.text });\n }\n if (\n ts.isPropertyAccessExpression(value) &&\n ts.isIdentifier(value.expression) &&\n value.expression.text === 'ArtifactTypes'\n ) {\n return this.asArtifactType({ raw: value.name.text.toLowerCase() });\n }\n\n return undefined;\n }\n\n private asArtifactType(opts: { raw: string }): TArtifactType | undefined {\n const { raw } = opts;\n return ArtifactStereotypes.EMIT_ORDER.map((entry) => entry.type)\n .concat(ArtifactTypes.MODEL)\n .find((type) => type === raw);\n }\n}\n"]}
@@ -1,3 +0,0 @@
1
- export * from './build-info';
2
- export * from './generator';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC"}
package/dist/cjs/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./build-info"), exports);
18
- __exportStar(require("./generator"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,8CAA4B","sourcesContent":["export * from './build-info';\nexport * from './generator';\n"]}
@@ -1,2 +0,0 @@
1
- export * from './plugin';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./plugin"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/vite/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB","sourcesContent":["export * from './plugin';\n"]}
@@ -1,29 +0,0 @@
1
- /** The slice of Vite's plugin contract this plugin uses - typed here so `@venizia/ignis-boot` does not depend on `vite`. */
2
- export interface IIgnisVitePlugin {
3
- name: string;
4
- enforce: 'pre';
5
- config: () => {
6
- optimizeDeps: {
7
- exclude: string[];
8
- };
9
- };
10
- configResolved: (config: {
11
- root: string;
12
- }) => void;
13
- resolveId: (id: string) => string | undefined;
14
- load: (id: string) => string | undefined;
15
- transform: (code: string, id: string) => string | undefined;
16
- }
17
- /** `IgnisArtifactsPlugin` for Vite: serves `ignis:artifacts`, replaces `@venizia/ignis-boot/auto` with an eager import of it (a browser bundle is tree-shaken only when eager), inlines every `ArtifactGroup.define` / `application` call, and pins the name of every scanned class - binding keys are built from `Class.name`, and a minifier renames classes. */
18
- export declare class IgnisArtifactsVitePlugin {
19
- static readonly RESOLVED_VIRTUAL: string;
20
- /** `root`: the `src` to scan (default: the one beside the `package.json` of Vite's root). */
21
- /** The file a module id names: vite dev adds a query (`?v=<hash>`) to the id of a node_modules file. */
22
- static filePathOf(opts: {
23
- id: string;
24
- }): string;
25
- static create(opts?: {
26
- root?: string;
27
- }): IIgnisVitePlugin;
28
- }
29
- //# sourceMappingURL=plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/vite/plugin.ts"],"names":[],"mappings":"AAKA,4HAA4H;AAC5H,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM;QAAE,YAAY,EAAE;YAAE,OAAO,EAAE,MAAM,EAAE,CAAA;SAAE,CAAA;KAAE,CAAC;IACtD,cAAc,EAAE,CAAC,MAAM,EAAE;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC;IACnD,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IAC9C,IAAI,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;IACzC,SAAS,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAC7D;AAED,mWAAmW;AACnW,qBAAa,wBAAwB;IACnC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAAuC;IAMvE,6FAA6F;IAC7F,wGAAwG;IACxG,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IAK/C,MAAM,CAAC,MAAM,CAAC,IAAI,GAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,gBAAgB;CAyC9D"}
@@ -1,61 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IgnisArtifactsVitePlugin = void 0;
4
- const node_path_1 = require("node:path");
5
- const generator_1 = require("../generator");
6
- const plugin_1 = require("../bun/plugin");
7
- const sources_1 = require("../bun/sources");
8
- /** `IgnisArtifactsPlugin` for Vite: serves `ignis:artifacts`, replaces `@venizia/ignis-boot/auto` with an eager import of it (a browser bundle is tree-shaken only when eager), inlines every `ArtifactGroup.define` / `application` call, and pins the name of every scanned class - binding keys are built from `Class.name`, and a minifier renames classes. */
9
- class IgnisArtifactsVitePlugin {
10
- static { this.RESOLVED_VIRTUAL = `\0${plugin_1.IgnisArtifactsPlugin.VIRTUAL}`; }
11
- static {
12
- sources_1.ArtifactSources.useScanner({ scanner: generator_1.ArtifactScanner.getInstance() });
13
- }
14
- /** `root`: the `src` to scan (default: the one beside the `package.json` of Vite's root). */
15
- /** The file a module id names: vite dev adds a query (`?v=<hash>`) to the id of a node_modules file. */
16
- static filePathOf(opts) {
17
- const queryAt = opts.id.indexOf('?');
18
- return queryAt === -1 ? opts.id : opts.id.slice(0, queryAt);
19
- }
20
- static create(opts = {}) {
21
- let root = opts.root ? (0, node_path_1.resolve)(opts.root) : '';
22
- let groupFiles = new Set();
23
- let classesByFile = new Map();
24
- const autoModule = `import { ${plugin_1.IgnisArtifactsPlugin.EXPORT_NAME} } from '${plugin_1.IgnisArtifactsPlugin.VIRTUAL}';\nimport { AutoArtifactGroup } from './auto-group';\nexport default new AutoArtifactGroup({ content: ${plugin_1.IgnisArtifactsPlugin.EXPORT_NAME} });\n`;
25
- return {
26
- name: plugin_1.IgnisArtifactsPlugin.NAME,
27
- enforce: 'pre',
28
- // Pre-bundling would hide `auto` inside a dependency chunk, out of reach of `load`.
29
- config: () => ({ optimizeDeps: { exclude: ['@venizia/ignis-boot'] } }),
30
- configResolved: (config) => {
31
- root ||= sources_1.ArtifactSources.packageSource({ from: config.root });
32
- groupFiles = new Set(plugin_1.IgnisArtifactsPlugin.groupDefinitionFiles({ root }));
33
- classesByFile = plugin_1.IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles: [...groupFiles] });
34
- },
35
- resolveId: (id) => id === plugin_1.IgnisArtifactsPlugin.VIRTUAL ? IgnisArtifactsVitePlugin.RESOLVED_VIRTUAL : undefined,
36
- load: (id) => {
37
- if (id === IgnisArtifactsVitePlugin.RESOLVED_VIRTUAL) {
38
- return plugin_1.IgnisArtifactsPlugin.render({ root });
39
- }
40
- return plugin_1.IgnisArtifactsPlugin.AUTO_MODULE.test(IgnisArtifactsVitePlugin.filePathOf({ id }))
41
- ? autoModule
42
- : undefined;
43
- },
44
- transform: (code, moduleId) => {
45
- const id = IgnisArtifactsVitePlugin.filePathOf({ id: moduleId });
46
- const classNames = classesByFile.get(id);
47
- if (!groupFiles.has(id) && !classNames) {
48
- return undefined;
49
- }
50
- const grouped = groupFiles.has(id)
51
- ? plugin_1.IgnisArtifactsPlugin.rewriteGroups({ filePath: id, source: code })
52
- : code;
53
- return classNames
54
- ? plugin_1.IgnisArtifactsPlugin.pinClassNames({ filePath: id, source: grouped, classNames })
55
- : grouped;
56
- },
57
- };
58
- }
59
- }
60
- exports.IgnisArtifactsVitePlugin = IgnisArtifactsVitePlugin;
61
- //# sourceMappingURL=plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/vite/plugin.ts"],"names":[],"mappings":";;;AAAA,yCAAoC;AACpC,4CAA+C;AAC/C,0CAAqD;AACrD,4CAAiD;AAajD,mWAAmW;AACnW,MAAa,wBAAwB;aACnB,qBAAgB,GAAG,KAAK,6BAAoB,CAAC,OAAO,EAAE,CAAC;IAEvE;QACE,yBAAe,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,2BAAe,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,6FAA6F;IAC7F,wGAAwG;IACxG,MAAM,CAAC,UAAU,CAAC,IAAoB;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,OAAO,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,OAA0B,EAAE;QACxC,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,IAAI,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;QACnC,IAAI,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;QACnD,MAAM,UAAU,GAAG,YAAY,6BAAoB,CAAC,WAAW,YAAY,6BAAoB,CAAC,OAAO,0GAA0G,6BAAoB,CAAC,WAAW,QAAQ,CAAC;QAE1P,OAAO;YACL,IAAI,EAAE,6BAAoB,CAAC,IAAI;YAC/B,OA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E,CAAC,CAAC;gBACzC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;oBACvC,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;oBAChC,CAAC,CAAC,6BAAoB,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;oBACpE,CAAC,CAAC,IAAI,CAAC;gBACT,OAAO,UAAU;oBACf,CAAC,CAAC,6BAAoB,CAAC,aAAa,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;oBACnF,CAAC,CAAC,OAAO,CAAC;YACd,CAAC;SACF,CAAC;IACJ,CAAC;;AAtDH,4DAuDC","sourcesContent":["import { resolve } from 'node:path';\nimport { ArtifactScanner } from '../generator';\nimport { IgnisArtifactsPlugin } from '../bun/plugin';\nimport { ArtifactSources } from '../bun/sources';\n\n/** The slice of Vite's plugin contract this plugin uses - typed here so `@venizia/ignis-boot` does not depend on `vite`. */\nexport interface IIgnisVitePlugin {\n name: string;\n enforce: 'pre';\n config: () => { optimizeDeps: { exclude: string[] } };\n configResolved: (config: { root: string }) => void;\n resolveId: (id: string) => string | undefined;\n load: (id: string) => string | undefined;\n transform: (code: string, id: string) => string | undefined;\n}\n\n/** `IgnisArtifactsPlugin` for Vite: serves `ignis:artifacts`, replaces `@venizia/ignis-boot/auto` with an eager import of it (a browser bundle is tree-shaken only when eager), inlines every `ArtifactGroup.define` / `application` call, and pins the name of every scanned class - binding keys are built from `Class.name`, and a minifier renames classes. */\nexport class IgnisArtifactsVitePlugin {\n static readonly RESOLVED_VIRTUAL = `\\0${IgnisArtifactsPlugin.VIRTUAL}`;\n\n static {\n ArtifactSources.useScanner({ scanner: ArtifactScanner.getInstance() });\n }\n\n /** `root`: the `src` to scan (default: the one beside the `package.json` of Vite's root). */\n /** The file a module id names: vite dev adds a query (`?v=<hash>`) to the id of a node_modules file. */\n static filePathOf(opts: { id: string }): string {\n const queryAt = opts.id.indexOf('?');\n return queryAt === -1 ? opts.id : opts.id.slice(0, queryAt);\n }\n\n static create(opts: { root?: string } = {}): IIgnisVitePlugin {\n let root = opts.root ? resolve(opts.root) : '';\n let groupFiles = new Set<string>();\n let classesByFile = new Map<string, Set<string>>();\n const autoModule = `import { ${IgnisArtifactsPlugin.EXPORT_NAME} } from '${IgnisArtifactsPlugin.VIRTUAL}';\\nimport { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ content: ${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`;\n\n return {\n name: IgnisArtifactsPlugin.NAME,\n enforce: 'pre',\n // Pre-bundling would hide `auto` inside a dependency chunk, out of reach of `load`.\n config: () => ({ optimizeDeps: { exclude: ['@venizia/ignis-boot'] } }),\n configResolved: (config) => {\n root ||= ArtifactSources.packageSource({ from: config.root });\n groupFiles = new Set(IgnisArtifactsPlugin.groupDefinitionFiles({ root }));\n classesByFile = IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles: [...groupFiles] });\n },\n resolveId: (id) =>\n id === IgnisArtifactsPlugin.VIRTUAL ? IgnisArtifactsVitePlugin.RESOLVED_VIRTUAL : undefined,\n load: (id) => {\n if (id === IgnisArtifactsVitePlugin.RESOLVED_VIRTUAL) {\n return IgnisArtifactsPlugin.render({ root });\n }\n return IgnisArtifactsPlugin.AUTO_MODULE.test(IgnisArtifactsVitePlugin.filePathOf({ id }))\n ? autoModule\n : undefined;\n },\n transform: (code, moduleId) => {\n const id = IgnisArtifactsVitePlugin.filePathOf({ id: moduleId });\n const classNames = classesByFile.get(id);\n if (!groupFiles.has(id) && !classNames) {\n return undefined;\n }\n const grouped = groupFiles.has(id)\n ? IgnisArtifactsPlugin.rewriteGroups({ filePath: id, source: code })\n : code;\n return classNames\n ? IgnisArtifactsPlugin.pinClassNames({ filePath: id, source: grouped, classNames })\n : grouped;\n },\n };\n }\n}\n"]}