@venizia/ignis-boot 0.4.0 → 0.4.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.
Files changed (39) hide show
  1. package/dist/cjs/bun/auto-loader.js +3 -3
  2. package/dist/cjs/bun/auto-loader.js.map +1 -1
  3. package/dist/cjs/bun/group-resolver.js +1 -1
  4. package/dist/cjs/bun/group-resolver.js.map +1 -1
  5. package/dist/cjs/bun/plugin.js +10 -10
  6. package/dist/cjs/bun/plugin.js.map +1 -1
  7. package/dist/cjs/bun/scan-cache.js +1 -1
  8. package/dist/cjs/bun/scan-cache.js.map +1 -1
  9. package/dist/cjs/bun/sources.js +4 -4
  10. package/dist/cjs/bun/sources.js.map +1 -1
  11. package/dist/cjs/clis/artifacts.js +1 -1
  12. package/dist/cjs/clis/artifacts.js.map +1 -1
  13. package/dist/cjs/generator/emitter.js +6 -6
  14. package/dist/cjs/generator/emitter.js.map +1 -1
  15. package/dist/cjs/generator/scanner.d.ts.map +1 -1
  16. package/dist/cjs/generator/scanner.js +10 -8
  17. package/dist/cjs/generator/scanner.js.map +1 -1
  18. package/dist/cjs/vite/plugin.js +3 -3
  19. package/dist/cjs/vite/plugin.js.map +1 -1
  20. package/dist/esm/bun/auto-loader.js +3 -3
  21. package/dist/esm/bun/auto-loader.js.map +1 -1
  22. package/dist/esm/bun/group-resolver.js +1 -1
  23. package/dist/esm/bun/group-resolver.js.map +1 -1
  24. package/dist/esm/bun/plugin.js +10 -10
  25. package/dist/esm/bun/plugin.js.map +1 -1
  26. package/dist/esm/bun/scan-cache.js +1 -1
  27. package/dist/esm/bun/scan-cache.js.map +1 -1
  28. package/dist/esm/bun/sources.js +4 -4
  29. package/dist/esm/bun/sources.js.map +1 -1
  30. package/dist/esm/clis/artifacts.js +1 -1
  31. package/dist/esm/clis/artifacts.js.map +1 -1
  32. package/dist/esm/generator/emitter.js +6 -6
  33. package/dist/esm/generator/emitter.js.map +1 -1
  34. package/dist/esm/generator/scanner.d.ts.map +1 -1
  35. package/dist/esm/generator/scanner.js +10 -8
  36. package/dist/esm/generator/scanner.js.map +1 -1
  37. package/dist/esm/vite/plugin.js +3 -3
  38. package/dist/esm/vite/plugin.js.map +1 -1
  39. package/package.json +5 -5
@@ -34,8 +34,8 @@ class ArtifactScanner extends ignis_helpers_1.BaseHelper {
34
34
  ? new reexport_1.StereotypeReexportResolver({ root, sourceModules })
35
35
  : undefined;
36
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 })));
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
39
  for (const artifact of ignored) {
40
40
  skipped.push({
41
41
  className: artifact.className,
@@ -66,10 +66,12 @@ class ArtifactScanner extends ignis_helpers_1.BaseHelper {
66
66
  const sources = (0, node_fs_1.globSync)(common_1.ArtifactStereotypes.SOURCE_GLOB, { cwd: opts.root });
67
67
  for (const relative of sources) {
68
68
  if (relative.endsWith('.d.ts') ||
69
- opts.defaultGlobs.some(pattern => (0, node_path_1.matchesGlob)(relative, pattern))) {
69
+ opts.defaultGlobs.some((pattern) => (0, node_path_1.matchesGlob)(relative, pattern))) {
70
70
  continue;
71
71
  }
72
- const target = opts.userGlobs.some(pattern => (0, node_path_1.matchesGlob)(relative, pattern)) ? hidden : kept;
72
+ const target = opts.userGlobs.some((pattern) => (0, node_path_1.matchesGlob)(relative, pattern))
73
+ ? hidden
74
+ : kept;
73
75
  target.push((0, node_path_1.join)(opts.root, relative));
74
76
  }
75
77
  return { kept: kept.sort(), hidden: hidden.sort() };
@@ -87,7 +89,7 @@ class ArtifactScanner extends ignis_helpers_1.BaseHelper {
87
89
  }
88
90
  const exportedNames = this.collectExportClauseNames({ source });
89
91
  const found = [];
90
- typescript_1.default.forEachChild(source, node => {
92
+ typescript_1.default.forEachChild(source, (node) => {
91
93
  if (!typescript_1.default.isClassDeclaration(node) || !node.name) {
92
94
  return;
93
95
  }
@@ -107,7 +109,7 @@ class ArtifactScanner extends ignis_helpers_1.BaseHelper {
107
109
  });
108
110
  }
109
111
  const modifiers = typescript_1.default.getModifiers(node) ?? [];
110
- const has = (kind) => modifiers.some(m => m.kind === kind);
112
+ const has = (kind) => modifiers.some((m) => m.kind === kind);
111
113
  const isNamedExport = (has(typescript_1.default.SyntaxKind.ExportKeyword) && !has(typescript_1.default.SyntaxKind.DefaultKeyword)) ||
112
114
  exportedNames.has(className);
113
115
  const isAbstract = has(typescript_1.default.SyntaxKind.AbstractKeyword);
@@ -247,9 +249,9 @@ class ArtifactScanner extends ignis_helpers_1.BaseHelper {
247
249
  }
248
250
  asArtifactType(opts) {
249
251
  const { raw } = opts;
250
- return common_1.ArtifactStereotypes.EMIT_ORDER.map(entry => entry.type)
252
+ return common_1.ArtifactStereotypes.EMIT_ORDER.map((entry) => entry.type)
251
253
  .concat(common_1.ArtifactTypes.MODEL)
252
- .find(type => type === raw);
254
+ .find((type) => type === raw);
253
255
  }
254
256
  }
255
257
  exports.ArtifactScanner = ArtifactScanner;
@@ -1 +1 @@
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,CA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C,CAAC;CACF;AA9UD,0CA8UC","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)) ? hidden : 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
+ {"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,OAAO,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC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@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"]}
@@ -27,13 +27,13 @@ class IgnisArtifactsVitePlugin {
27
27
  enforce: 'pre',
28
28
  // Pre-bundling would hide `auto` inside a dependency chunk, out of reach of `load`.
29
29
  config: () => ({ optimizeDeps: { exclude: ['@venizia/ignis-boot'] } }),
30
- configResolved: config => {
30
+ configResolved: (config) => {
31
31
  root ||= sources_1.ArtifactSources.packageSource({ from: config.root });
32
32
  groupFiles = new Set(plugin_1.IgnisArtifactsPlugin.groupDefinitionFiles({ root }));
33
33
  classesByFile = plugin_1.IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles: [...groupFiles] });
34
34
  },
35
- resolveId: id => id === plugin_1.IgnisArtifactsPlugin.VIRTUAL ? IgnisArtifactsVitePlugin.RESOLVED_VIRTUAL : undefined,
36
- load: id => {
35
+ resolveId: (id) => id === plugin_1.IgnisArtifactsPlugin.VIRTUAL ? IgnisArtifactsVitePlugin.RESOLVED_VIRTUAL : undefined,
36
+ load: (id) => {
37
37
  if (id === IgnisArtifactsVitePlugin.RESOLVED_VIRTUAL) {
38
38
  return plugin_1.IgnisArtifactsPlugin.render({ root });
39
39
  }
@@ -1 +1 @@
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,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,CAAC,EAAE,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"]}
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,OAAO,EAAE,KAAK;YACd,oFAAoF;YACpF,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,EAA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,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"]}
@@ -35,7 +35,7 @@ export class AutoArtifactsLoader {
35
35
  /** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */
36
36
  static async importIndex(opts) {
37
37
  const emitted = opts.artifacts
38
- .filter(artifact => artifact.type !== ArtifactTypes.MODEL)
38
+ .filter((artifact) => artifact.type !== ArtifactTypes.MODEL)
39
39
  .sort((left, right) => left.filePath.localeCompare(right.filePath) ||
40
40
  left.className.localeCompare(right.className));
41
41
  const loaded = new Map();
@@ -46,9 +46,9 @@ export class AutoArtifactsLoader {
46
46
  const index = {};
47
47
  for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {
48
48
  const classes = emitted
49
- .filter(artifact => artifact.type === type)
49
+ .filter((artifact) => artifact.type === type)
50
50
  .sort((left, right) => left.className.localeCompare(right.className))
51
- .flatMap(artifact => loaded.get(artifact) ?? []);
51
+ .flatMap((artifact) => loaded.get(artifact) ?? []);
52
52
  if (classes.length > 0) {
53
53
  index[field] = classes;
54
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"auto-loader.js","sourceRoot":"","sources":["../../../src/bun/auto-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,0MAA0M;AAC1M,MAAM,OAAO,mBAAmB;IAC9B,MAAM,CAAC,aAAa,CAAC,IAAyB;QAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,sNAAsN;aACzN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI;QACf,mBAAmB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,WAAW,EAAE,CAAC,CAA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;YAC3C,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAChD,CAAC;QAEJ,MAAM,MAAM,GAAG,IAAI,GAAG,EAAqC,CAAC;QAC5D,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;YAC/B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC/C,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,KAAK,GAA2C,EAAE,CAAC;QACzD,KAAK,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,mBAAmB,CAAC,UAAU,EAAE,CAAC;YAC7D,MAAM,OAAO,GAAG,OAAO;iBACpB,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC;iBAC1C,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;iBACpE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YACnD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { dirname } from 'node:path';\nimport {\n ArtifactStereotypes,\n ArtifactTypes,\n type IScannedArtifact,\n type TGeneratedArtifactIndex,\n} from '../generator/common';\nimport { ArtifactSources } from './sources';\n\n/** Loads the application's index for `@venizia/ignis-boot/auto` from source: registers the run-time plugin, then imports the virtual module. A binary never runs this - the build replaces the module. */\nexport class AutoArtifactsLoader {\n static assertRuntime(opts: { hasBun: boolean }): void {\n if (!opts.hasBun) {\n throw getError({\n message:\n '[@venizia/ignis-boot/auto] Auto artifacts need Bun (a Bun plugin builds the index) | On Node, generate the index with `ignis-artifacts generate --root src --out src/_artifacts.ts` and pass it to configs.artifacts',\n });\n }\n }\n\n static async load(): Promise<TGeneratedArtifactIndex> {\n AutoArtifactsLoader.assertRuntime({ hasBun: typeof Bun !== 'undefined' });\n\n // A warm scan cache needs neither the plugin nor TypeScript: import the listed classes directly.\n const entry = ArtifactSources.entry();\n const packageSource = ArtifactSources.packageSource({\n from: entry ? dirname(entry) : process.cwd(),\n });\n if (ArtifactSources.isCached({ packageSource })) {\n const artifacts = ArtifactSources.scan({ packageSource });\n return AutoArtifactsLoader.importIndex({\n artifacts: entry ? ArtifactSources.runningArtifacts({ artifacts, from: entry }) : artifacts,\n });\n }\n\n // A non-static specifier: a bundler must not pull the scanner (and TypeScript) into a binary.\n const pluginModule = './plugin';\n const { IgnisArtifactsPlugin } = await import(pluginModule);\n await IgnisArtifactsPlugin.registerRuntime();\n\n // A static specifier on purpose: a build without IgnisArtifactsPlugin then fails to resolve it, instead of shipping a binary with no classes.\n const { GeneratedArtifacts } = await import('ignis:artifacts');\n return GeneratedArtifacts;\n }\n\n /** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */\n static async importIndex(opts: {\n artifacts: IScannedArtifact[];\n }): Promise<TGeneratedArtifactIndex> {\n const emitted = opts.artifacts\n .filter(artifact => artifact.type !== ArtifactTypes.MODEL)\n .sort(\n (left, right) =>\n left.filePath.localeCompare(right.filePath) ||\n left.className.localeCompare(right.className),\n );\n\n const loaded = new Map<IScannedArtifact, TClass<AnyType>>();\n for (const artifact of emitted) {\n const module = await import(artifact.filePath);\n loaded.set(artifact, module[artifact.className]);\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const classes = emitted\n .filter(artifact => artifact.type === type)\n .sort((left, right) => left.className.localeCompare(right.className))\n .flatMap(artifact => loaded.get(artifact) ?? []);\n if (classes.length > 0) {\n index[field] = classes;\n }\n }\n return index;\n }\n}\n"]}
1
+ {"version":3,"file":"auto-loader.js","sourceRoot":"","sources":["../../../src/bun/auto-loader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,mBAAmB,EACnB,aAAa,GAGd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,0MAA0M;AAC1M,MAAM,OAAO,mBAAmB;IAC9B,MAAM,CAAC,aAAa,CAAC,IAAyB;QAC5C,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;YACjB,MAAM,QAAQ,CAAC;gBACb,OAAO,EACL,sNAAsN;aACzN,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,IAAI;QACf,mBAAmB,CAAC,aAAa,CAAC,EAAE,MAAM,EAAE,OAAO,GAAG,KAAK,WAAW,EAAE,CAAC,CAAC;QAE1E,iGAAiG;QACjG,MAAM,KAAK,GAAG,eAAe,CAAC,KAAK,EAAE,CAAC;QACtC,MAAM,aAAa,GAAG,eAAe,CAAC,aAAa,CAAC;YAClD,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE;SAC7C,CAAC,CAAC;QACH,IAAI,eAAe,CAAC,QAAQ,CAAC,EAAE,aAAa,EAAE,CAAC,EAAE,CAAC;YAChD,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,EAAE,aAAa,EAAE,CAAC,CAAC;YAC1D,OAAO,mBAAmB,CAA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,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,mBAAmB,CAAC,UAAU,EAAE,CAAC;YAC7D,MAAM,OAAO,GAAG,OAAO;iBACpB,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,IAAI,CAAC;iBAC5C,IAAI,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;iBACpE,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;YACrD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACvB,KAAK,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { dirname } from 'node:path';\nimport {\n ArtifactStereotypes,\n ArtifactTypes,\n type IScannedArtifact,\n type TGeneratedArtifactIndex,\n} from '../generator/common';\nimport { ArtifactSources } from './sources';\n\n/** Loads the application's index for `@venizia/ignis-boot/auto` from source: registers the run-time plugin, then imports the virtual module. A binary never runs this - the build replaces the module. */\nexport class AutoArtifactsLoader {\n static assertRuntime(opts: { hasBun: boolean }): void {\n if (!opts.hasBun) {\n throw getError({\n message:\n '[@venizia/ignis-boot/auto] Auto artifacts need Bun (a Bun plugin builds the index) | On Node, generate the index with `ignis-artifacts generate --root src --out src/_artifacts.ts` and pass it to configs.artifacts',\n });\n }\n }\n\n static async load(): Promise<TGeneratedArtifactIndex> {\n AutoArtifactsLoader.assertRuntime({ hasBun: typeof Bun !== 'undefined' });\n\n // A warm scan cache needs neither the plugin nor TypeScript: import the listed classes directly.\n const entry = ArtifactSources.entry();\n const packageSource = ArtifactSources.packageSource({\n from: entry ? dirname(entry) : process.cwd(),\n });\n if (ArtifactSources.isCached({ packageSource })) {\n const artifacts = ArtifactSources.scan({ packageSource });\n return AutoArtifactsLoader.importIndex({\n artifacts: entry ? ArtifactSources.runningArtifacts({ artifacts, from: entry }) : artifacts,\n });\n }\n\n // A non-static specifier: a bundler must not pull the scanner (and TypeScript) into a binary.\n const pluginModule = './plugin';\n const { IgnisArtifactsPlugin } = await import(pluginModule);\n await IgnisArtifactsPlugin.registerRuntime();\n\n // A static specifier on purpose: a build without IgnisArtifactsPlugin then fails to resolve it, instead of shipping a binary with no classes.\n const { GeneratedArtifacts } = await import('ignis:artifacts');\n return GeneratedArtifacts;\n }\n\n /** The index the emitter would render for `artifacts`: modules imported in path order, each field sorted by class name. */\n static async importIndex(opts: {\n artifacts: IScannedArtifact[];\n }): Promise<TGeneratedArtifactIndex> {\n const emitted = opts.artifacts\n .filter((artifact) => artifact.type !== ArtifactTypes.MODEL)\n .sort(\n (left, right) =>\n left.filePath.localeCompare(right.filePath) ||\n left.className.localeCompare(right.className),\n );\n\n const loaded = new Map<IScannedArtifact, TClass<AnyType>>();\n for (const artifact of emitted) {\n const module = await import(artifact.filePath);\n loaded.set(artifact, module[artifact.className]);\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const classes = emitted\n .filter((artifact) => artifact.type === type)\n .sort((left, right) => left.className.localeCompare(right.className))\n .flatMap((artifact) => loaded.get(artifact) ?? []);\n if (classes.length > 0) {\n index[field] = classes;\n }\n }\n return index;\n }\n}\n"]}
@@ -20,7 +20,7 @@ export class GroupArtifactsResolver {
20
20
  }
21
21
  const index = {};
22
22
  for (const artifact of ArtifactSources.folderArtifacts({ folder, site, ignore })) {
23
- const field = ArtifactStereotypes.EMIT_ORDER.find(entry => entry.type === artifact.type)?.field;
23
+ const field = ArtifactStereotypes.EMIT_ORDER.find((entry) => entry.type === artifact.type)?.field;
24
24
  if (!field) {
25
25
  continue;
26
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"group-resolver.js","sourceRoot":"","sources":["../../../src/bun/group-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAgC,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,2OAA2O;AAC3O,MAAM,OAAO,sBAAsB;IACjC,uGAAuG;aACvF,eAAU,GAAG,MAAM,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;IAEzF,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAMpB;QACC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAC5C,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,QAAQ,CAAC;gBACb,OAAO,EAAE,oBAAoB,MAAM,IAAI,eAAe,6GAA6G;aACpK,CAAC,CAAC;QACL,CAAC;QAED,IACE,CAAC,eAAe,CAAC,QAAQ,CAAC;YACxB,aAAa,EAAE,eAAe,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;SACtE,CAAC,EACF,CAAC;YACD,MAAM,eAAe,CAAC,WAAW,EAAE,CAAC;QACtC,CAAC;QAED,MAAM,KAAK,GAA2C,EAAE,CAAC;QACzD,KAAK,MAAM,QAAQ,IAAI,eAAe,CAAC,eAAe,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACjF,MAAM,KAAK,GAAG,mBAAmB,CAAC,UAAU,CAAC,IAAI,CAC/C,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,IAAI,CACtC,EAAE,KAAK,CAAC;YACT,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,SAAS;YACX,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC/C,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;QACvE,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,mIAAmI;IACnI,MAAM,CAAC,OAAO;QACZ,MAAM,QAAQ,GAAY,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;QACrF,MAAM,MAAM,GACV,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,OAAO,GAAG,CAAC,WAMjB,EAAE,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { ArtifactStereotypes, type TGeneratedArtifactIndex } from '../generator/common';\nimport { dirname } from 'node:path';\nimport { ArtifactSources } from './sources';\n\n/** Fills an `ArtifactGroup` defined without content, from source: the defining package is the nearest `package.json` above the group's call site, and the group is every decorated class under a directory named `folder` in its `src`. */\nexport class GroupArtifactsResolver {\n /** The kernel's `SingletonRealm` slot for the group resolver (`ArtifactGroup.SINGLETON_REALM_KEY`). */\n static readonly REALM_SLOT = Symbol.for('@venizia/ignis-kernel:artifact-group-resolver');\n\n static async resolve(opts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }): Promise<TGeneratedArtifactIndex> {\n const { folder, site, ignore } = opts.group;\n if (!site) {\n throw getError({\n message: `[ArtifactGroup] '${folder ?? '<application>'}' has no call site to resolve from | Define it with ArtifactGroup.define in the shared package's own source`,\n });\n }\n\n if (\n !ArtifactSources.isCached({\n packageSource: ArtifactSources.packageSource({ from: dirname(site) }),\n })\n ) {\n await ArtifactSources.loadScanner();\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const artifact of ArtifactSources.folderArtifacts({ folder, site, ignore })) {\n const field = ArtifactStereotypes.EMIT_ORDER.find(\n entry => entry.type === artifact.type,\n )?.field;\n if (!field) {\n continue;\n }\n const loaded = await import(artifact.filePath);\n index[field] = [...(index[field] ?? []), loaded[artifact.className]];\n }\n return index;\n }\n\n /** Fills the kernel's realm slot; the holder may already exist (the kernel created it empty), so it is mutated, never replaced. */\n static install(): void {\n const existing: unknown = Reflect.get(globalThis, GroupArtifactsResolver.REALM_SLOT);\n const holder: { resolve?: unknown } =\n typeof existing === 'object' && existing !== null ? existing : {};\n holder.resolve = (resolveOpts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }) => GroupArtifactsResolver.resolve(resolveOpts);\n Reflect.set(globalThis, GroupArtifactsResolver.REALM_SLOT, holder);\n }\n}\n"]}
1
+ {"version":3,"file":"group-resolver.js","sourceRoot":"","sources":["../../../src/bun/group-resolver.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAE,mBAAmB,EAAgC,MAAM,qBAAqB,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,2OAA2O;AAC3O,MAAM,OAAO,sBAAsB;IACjC,uGAAuG;aACvF,eAAU,GAAG,MAAM,CAAC,GAAG,CA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AAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,CAAC,CAAC;QACrF,MAAM,MAAM,GACV,OAAO,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QACpE,MAAM,CAAC,OAAO,GAAG,CAAC,WAMjB,EAAE,EAAE,CAAC,sBAAsB,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,sBAAsB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IACrE,CAAC","sourcesContent":["import { getError } from '@venizia/ignis-helpers';\nimport type { AnyType, TClass } from '@venizia/ignis-helpers';\nimport { ArtifactStereotypes, type TGeneratedArtifactIndex } from '../generator/common';\nimport { dirname } from 'node:path';\nimport { ArtifactSources } from './sources';\n\n/** Fills an `ArtifactGroup` defined without content, from source: the defining package is the nearest `package.json` above the group's call site, and the group is every decorated class under a directory named `folder` in its `src`. */\nexport class GroupArtifactsResolver {\n /** The kernel's `SingletonRealm` slot for the group resolver (`ArtifactGroup.SINGLETON_REALM_KEY`). */\n static readonly REALM_SLOT = Symbol.for('@venizia/ignis-kernel:artifact-group-resolver');\n\n static async resolve(opts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }): Promise<TGeneratedArtifactIndex> {\n const { folder, site, ignore } = opts.group;\n if (!site) {\n throw getError({\n message: `[ArtifactGroup] '${folder ?? '<application>'}' has no call site to resolve from | Define it with ArtifactGroup.define in the shared package's own source`,\n });\n }\n\n if (\n !ArtifactSources.isCached({\n packageSource: ArtifactSources.packageSource({ from: dirname(site) }),\n })\n ) {\n await ArtifactSources.loadScanner();\n }\n\n const index: Record<string, Array<TClass<AnyType>>> = {};\n for (const artifact of ArtifactSources.folderArtifacts({ folder, site, ignore })) {\n const field = ArtifactStereotypes.EMIT_ORDER.find(\n (entry) => entry.type === artifact.type,\n )?.field;\n if (!field) {\n continue;\n }\n const loaded = await import(artifact.filePath);\n index[field] = [...(index[field] ?? []), loaded[artifact.className]];\n }\n return index;\n }\n\n /** Fills the kernel's realm slot; the holder may already exist (the kernel created it empty), so it is mutated, never replaced. */\n static install(): void {\n const existing: unknown = Reflect.get(globalThis, GroupArtifactsResolver.REALM_SLOT);\n const holder: { resolve?: unknown } =\n typeof existing === 'object' && existing !== null ? existing : {};\n holder.resolve = (resolveOpts: {\n group: {\n folder: string | undefined;\n site: string | undefined;\n ignore?: ReadonlyArray<string>;\n };\n }) => GroupArtifactsResolver.resolve(resolveOpts);\n Reflect.set(globalThis, GroupArtifactsResolver.REALM_SLOT, holder);\n }\n}\n"]}
@@ -84,8 +84,8 @@ export class IgnisArtifactsPlugin {
84
84
  const fields = [];
85
85
  for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {
86
86
  const locals = artifacts
87
- .filter(artifact => artifact.type === type)
88
- .map(artifact => {
87
+ .filter((artifact) => artifact.type === type)
88
+ .map((artifact) => {
89
89
  if (isCompiled) {
90
90
  return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;
91
91
  }
@@ -137,7 +137,7 @@ export class IgnisArtifactsPlugin {
137
137
  refuse(call, 'the argument is not an object literal');
138
138
  }
139
139
  const literal = argument;
140
- const named = (name) => literal.properties.find(entry => entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name);
140
+ const named = (name) => literal.properties.find((entry) => entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name);
141
141
  if (named('content')) {
142
142
  return;
143
143
  }
@@ -157,8 +157,8 @@ export class IgnisArtifactsPlugin {
157
157
  const ignoreList = ignoreProperty &&
158
158
  ts.isPropertyAssignment(ignoreProperty) &&
159
159
  ts.isArrayLiteralExpression(ignoreProperty.initializer) &&
160
- ignoreProperty.initializer.elements.every(element => ts.isStringLiteral(element))
161
- ? ignoreProperty.initializer.elements.map(element => element.text)
160
+ ignoreProperty.initializer.elements.every((element) => ts.isStringLiteral(element))
161
+ ? ignoreProperty.initializer.elements.map((element) => element.text)
162
162
  : undefined;
163
163
  if (ignoreProperty && ignoreList === undefined) {
164
164
  refuse(call, 'ignore is not an array of string literals');
@@ -188,7 +188,7 @@ export class IgnisArtifactsPlugin {
188
188
  const found = [];
189
189
  const visit = (node) => {
190
190
  if (ts.isClassDeclaration(node) && node.name) {
191
- const isDecorated = (ts.getDecorators(node) ?? []).some(decorator => {
191
+ const isDecorated = (ts.getDecorators(node) ?? []).some((decorator) => {
192
192
  const expression = ts.isCallExpression(decorator.expression)
193
193
  ? decorator.expression.expression
194
194
  : decorator.expression;
@@ -240,7 +240,7 @@ export class IgnisArtifactsPlugin {
240
240
  if (!IgnisArtifactsPlugin.DECORATED.test(source)) {
241
241
  continue;
242
242
  }
243
- add(IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map(className => ({
243
+ add(IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map((className) => ({
244
244
  filePath: file,
245
245
  className,
246
246
  })));
@@ -259,7 +259,7 @@ export class IgnisArtifactsPlugin {
259
259
  }
260
260
  /** The source files that define groups: the application's own `src` and the `src` of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does. */
261
261
  static groupDefinitionFiles(opts) {
262
- return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter(file => IgnisArtifactsPlugin.DEFINE_CALL.test(readFileSync(file, 'utf8')));
262
+ return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter((file) => IgnisArtifactsPlugin.DEFINE_CALL.test(readFileSync(file, 'utf8')));
263
263
  }
264
264
  /** The source files of the application and of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does - plus the compiled trees beside each `src`, for a package that runs from `dist`. Tests excluded. */
265
265
  static workspaceSourceFiles(opts) {
@@ -345,8 +345,8 @@ export class IgnisArtifactsPlugin {
345
345
  const pinned = IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles, entry });
346
346
  const loaded = [...new Set([...groupFiles, ...pinned.keys()])];
347
347
  if (loaded.length > 0) {
348
- const escaped = loaded.map(file => file.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&'));
349
- build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, args => {
348
+ const escaped = loaded.map((file) => file.replace(/[.*+?^${}()|[\]\\/]/g, '\\$&'));
349
+ build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, (args) => {
350
350
  const source = readFileSync(args.path, 'utf8');
351
351
  const grouped = groupFileSet.has(args.path)
352
352
  ? IgnisArtifactsPlugin.rewriteGroups({ filePath: args.path, source })
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/bun/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,6QAA6Q;AAC7Q,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,iBAAiB,CAAC;aACzB,YAAO,GAAG,iBAAiB,CAAC;aAC5B,gBAAW,GAAG,oBAAoB,CAAC;IAEnD,+IAA+I;aAC/H,gBAAW,GACzB,kHAAkH,CAAC;IAErH,oHAAoH;aACpG,gBAAW,GAAG,kDAAkD,CAAC;aAEzD,gBAAW,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAEjG;QACE,eAAe,CAAC,U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;gBACL,CAAC;gBACD,sRAAsR;gBACtR,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,KAAK,SAAS,CAAC;gBACnE,MAAM,UAAU,GAAG,MAAM;oBACvB,CAAC,CAAC,iIAAiI,oBAAoB,CAAC,OAAO,OAAO,oBAAoB,CAAC,WAAW,QAAQ;oBAC9M,CAAC,CAAC,YAAY,oBAAoB,CAAC,WAAW,YAAY,oBAAoB,CAAC,OAAO,0GAA0G,oBAAoB,CAAC,WAAW,QAAQ,CAAC;gBAC3O,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;oBAChE,QAAQ,EAAE,UAAU;oBACpB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC,CAAC;YACN,CAAC;SACF,CAAC;IACJ,CAAC;IAED,gFAAgF;IAChF,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAA0B,EAAE;QACvD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC;YACvE,OAAO;QACT,CAAC;QACD,MAAM,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC","sourcesContent":["import type { BunPlugin } from 'bun';\nimport { getError } from '@venizia/ignis-helpers';\nimport { existsSync, globSync, readdirSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join, resolve, sep } from 'node:path';\nimport ts from 'typescript';\nimport { ArtifactIndexEmitter, ArtifactScanner, ArtifactStereotypes } from '../generator';\nimport { ArtifactSources } from './sources';\n\n/** Serves `ignis:artifacts` - the application's generated index, rendered in memory from the scanner. At run time it is a virtual module (`build.module`); in `Bun.build` it is resolved and loaded (`onResolve`/`onLoad`), so a binary carries the list and never scans. */\nexport class IgnisArtifactsPlugin {\n static readonly NAME = 'ignis-artifacts';\n static readonly VIRTUAL = 'ignis:artifacts';\n static readonly EXPORT_NAME = 'GeneratedArtifacts';\n\n /** `@venizia/ignis-boot/auto`, from source or from either dist format - replaced at build time by a static re-export of the virtual module. */\n static readonly AUTO_MODULE =\n /[\\\\/](?:@venizia[\\\\/]ignis-boot|packages[\\\\/]boot)[\\\\/](?:dist[\\\\/](?:esm|cjs)|src)[\\\\/]bun[\\\\/]auto\\.(?:ts|js)$/;\n\n /** A text test for a file worth parsing: `ArtifactGroup.define(`, with any spacing or line break around the dot. */\n static readonly DEFINE_CALL = /ArtifactGroup\\s*\\.\\s*(?:define|application)\\s*\\(/;\n\n private static readonly RUNTIME_KEY = Symbol.for('@venizia/ignis-boot:artifacts-runtime-plugin');\n\n static {\n ArtifactSources.useScanner({ scanner: ArtifactScanner.getInstance() });\n }\n\n /** The `src` beside the nearest `package.json` at or above `from` (default: the entry module's directory). */\n static defaultRoot(opts: { from?: string } = {}): string {\n return ArtifactSources.packageSource({\n from: opts.from ?? IgnisArtifactsPlugin.entryDirectory(),\n });\n }\n\n /** The entry module's directory (`Bun.main`), so the root never depends on where the process was started; the working directory only when there is no entry file (`bun -e`, a REPL). */\n static entryDirectory(): string {\n const entry = ArtifactSources.entry();\n return entry ? dirname(entry) : process.cwd();\n }\n\n /** The index as module source: every import absolute, since a virtual module has no directory to resolve from. With `entry` in a compiled tree, each class is imported from that tree (`ArtifactSources.runningArtifacts`). */\n static render(opts: { root: string; entry?: string }): string {\n const root = resolve(opts.root);\n if (!existsSync(root)) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ${dirname(root)} has no src directory (${root}) | Auto artifacts scan the src beside the package.json of the entry module; pass IgnisArtifactsPlugin.create({ root }), or use ArtifactGroup.application() in the application's own source`,\n });\n }\n const outFile = join(root, '__ignis_artifacts__.ts');\n const artifacts = ArtifactSources.scan({ packageSource: root });\n return ArtifactIndexEmitter.render({\n artifacts: opts.entry\n ? ArtifactSources.runningArtifacts({ artifacts, from: opts.entry })\n : artifacts,\n outFile,\n exportName: IgnisArtifactsPlugin.EXPORT_NAME,\n command: { root, out: outFile },\n absoluteImports: true,\n });\n }\n\n /** Rewrites every `ArtifactGroup.define({ folder: '<literal>' })` and `ArtifactGroup.application()` in a source file to carry its classes as `content`, imported by absolute path - a binary then holds each group's list and never scans. A group with no decorated class, or a call the plugin cannot read (an aliased `ArtifactGroup`, a folder that is not a string literal), fails the build. */\n static rewriteGroups(opts: { filePath: string; source: string }): string {\n const { filePath, source } = opts;\n const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);\n const aliases = new Set<string>();\n for (const statement of sourceFile.statements) {\n const bindings = ts.isImportDeclaration(statement)\n ? statement.importClause?.namedBindings\n : undefined;\n for (const element of bindings && ts.isNamedImports(bindings) ? bindings.elements : []) {\n if (\n (element.propertyName ?? element.name).text === 'ArtifactGroup' &&\n element.name.text !== 'ArtifactGroup'\n ) {\n aliases.add(element.name.text);\n }\n }\n }\n\n const edits: Array<{ at: number; text: string }> = [];\n const imports: string[] = [];\n let counter = 0;\n\n const refuse = (node: ts.Node, reason: string): never => {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n throw getError({\n message: `[IgnisArtifactsPlugin] An ArtifactGroup call at ${filePath}:${line + 1} cannot be rewritten | ${reason} - write ArtifactGroup.define({ folder: '<name>' }) or ArtifactGroup.application() with the class imported under its own name`,\n });\n };\n\n const isCompiled = !ArtifactStereotypes.SOURCE_EXTENSION.test(filePath);\n const contentLiteral = (folder: string | undefined, ignore?: string[]): string => {\n const artifacts = ArtifactSources.folderArtifacts({ folder, site: filePath, ignore });\n if (artifacts.length === 0) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ArtifactGroup '${folder ?? '<application>'}' resolved to no class | ${filePath} - check the folder name and that its classes carry a stereotype decorator`,\n });\n }\n\n const fields: string[] = [];\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const locals = artifacts\n .filter(artifact => artifact.type === type)\n .map(artifact => {\n if (isCompiled) {\n return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;\n }\n counter += 1;\n const local = `__ignis_group_${counter}`;\n const path = artifact.filePath\n .split(sep)\n .join('/')\n .replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n imports.push(`import { ${artifact.className} as ${local} } from '${path}';`);\n return local;\n });\n if (locals.length > 0) {\n fields.push(`${field}: [${locals.join(', ')}]`);\n }\n }\n return `{ ${fields.join(', ')} }`;\n };\n\n const visit = (node: ts.Node): void => {\n const isGroupCall =\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n (ts.isIdentifier(node.expression.expression) ||\n ts.isPropertyAccessExpression(node.expression.expression)) &&\n (node.expression.name.text === 'define' || node.expression.name.text === 'application');\n if (!isGroupCall) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const call = node as ts.CallExpression;\n const access = call.expression as ts.PropertyAccessExpression;\n const target = access.expression;\n const callee = ts.isIdentifier(target)\n ? target.text\n : (target as ts.PropertyAccessExpression).name.text;\n const isApplication = access.name.text === 'application';\n if (ts.isIdentifier(target) && aliases.has(callee)) {\n refuse(call, `ArtifactGroup is imported as ${callee}`);\n }\n if (callee !== 'ArtifactGroup') {\n ts.forEachChild(node, visit);\n return;\n }\n\n const [argument] = call.arguments;\n if (isApplication && !argument) {\n edits.push({ at: call.arguments.pos, text: `{ content: ${contentLiteral(undefined)} }` });\n return;\n }\n if (!argument || !ts.isObjectLiteralExpression(argument)) {\n refuse(call, 'the argument is not an object literal');\n }\n\n const literal = argument as ts.ObjectLiteralExpression;\n const named = (name: string): ts.ObjectLiteralElementLike | undefined =>\n literal.properties.find(\n entry =>\n entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name,\n );\n if (named('content')) {\n return;\n }\n\n const folderProperty = named('folder');\n if (isApplication && folderProperty) {\n refuse(call, 'ArtifactGroup.application() takes no folder');\n }\n const folderLiteral =\n folderProperty &&\n ts.isPropertyAssignment(folderProperty) &&\n ts.isStringLiteral(folderProperty.initializer)\n ? folderProperty.initializer.text\n : undefined;\n if (!isApplication && folderLiteral === undefined) {\n refuse(call, 'folder is not a string literal');\n }\n\n const ignoreProperty = named('ignore');\n const ignoreList =\n ignoreProperty &&\n ts.isPropertyAssignment(ignoreProperty) &&\n ts.isArrayLiteralExpression(ignoreProperty.initializer) &&\n ignoreProperty.initializer.elements.every(element => ts.isStringLiteral(element))\n ? ignoreProperty.initializer.elements.map(element => (element as ts.StringLiteral).text)\n : undefined;\n if (ignoreProperty && ignoreList === undefined) {\n refuse(call, 'ignore is not an array of string literals');\n }\n\n const last = literal.properties[literal.properties.length - 1];\n edits.push({\n at: last ? last.getEnd() : literal.getStart() + 1,\n text: `${last ? ', ' : ''}content: ${contentLiteral(folderLiteral, ignoreList)}`,\n });\n };\n visit(sourceFile);\n\n let rewritten = source;\n for (const edit of [...edits].sort((left, right) => right.at - left.at)) {\n rewritten = rewritten.slice(0, edit.at) + edit.text + rewritten.slice(edit.at);\n }\n return imports.length > 0 ? `${imports.join('\\n')}\\n${rewritten}` : rewritten;\n }\n\n /** A text test for a file worth parsing for decorated classes: an IGNIS stereotype decorator call. */\n static readonly DECORATED =\n /@(?:configuration|component|controller|service|repository|datasource|model|injectable)\\s*\\(/;\n\n /** The classes of a source file that carry an IGNIS stereotype decorator (`@service()`, `@repository(...)`, `@injectable(...)`...). */\n static decoratedClasses(opts: { filePath: string; source: string }): string[] {\n const names = new Set([\n ...Object.keys(ArtifactStereotypes.BY_DECORATOR),\n ArtifactStereotypes.ROOT_DECORATOR,\n ]);\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const found: string[] = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name) {\n const isDecorated = (ts.getDecorators(node) ?? []).some(decorator => {\n const expression = ts.isCallExpression(decorator.expression)\n ? decorator.expression.expression\n : decorator.expression;\n return ts.isIdentifier(expression) && names.has(expression.text);\n });\n if (isDecorated) {\n found.push(node.name.text);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n }\n\n /** Opens each named class with `static { Object.defineProperty(this, 'name', ...) }`. Binding keys are built from `Class.name`, and a bundler renames classes - a minifier, or Bun's scope hoisting when a registered class shadows a same-name class it extends (`StockService` becomes `StockService2`). A string literal survives both, and a static block runs before the class's decorators. Only these classes are touched; the rest of the bundle is left alone. */\n static pinClassNames(opts: {\n filePath: string;\n source: string;\n classNames: ReadonlySet<string>;\n }): string {\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const positions: Array<{ at: number; name: string }> = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name && opts.classNames.has(node.name.text)) {\n positions.push({ at: node.members.pos, name: node.name.text });\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n\n let pinned = opts.source;\n for (const { at, name } of positions.sort((left, right) => right.at - left.at)) {\n const block = ` static { Object.defineProperty(this, 'name', { value: ${JSON.stringify(name)} }); }`;\n pinned = pinned.slice(0, at) + block + pinned.slice(at);\n }\n return pinned;\n }\n\n /** The classes whose names a build must pin, by the file the build loads: the app's own (from the tree `entry` runs, see `runningArtifacts`) and those of every package that defines a group the app can borrow (from the tree the group file sits in). */\n static pinnedClasses(opts: {\n root: string;\n groupFiles?: ReadonlyArray<string>;\n entry?: string;\n }): Map<string, Set<string>> {\n const byFile = new Map<string, Set<string>>();\n const add = (artifacts: ReadonlyArray<{ filePath: string; className: string }>): void => {\n for (const { filePath, className } of artifacts) {\n byFile.set(filePath, (byFile.get(filePath) ?? new Set()).add(className));\n }\n };\n const own = ArtifactSources.scan({ packageSource: opts.root });\n add(opts.entry ? ArtifactSources.runningArtifacts({ artifacts: own, from: opts.entry }) : own);\n // Every class carrying an IGNIS decorator in the workspace sources: a class nothing scans (a library that defines no group) is still an injection target, and still renamed by a bundler when its name collides.\n for (const file of IgnisArtifactsPlugin.workspaceSourceFiles({ root: opts.root })) {\n if (!ArtifactStereotypes.SOURCE_EXTENSION.test(file)) {\n continue;\n }\n const source = readFileSync(file, 'utf8');\n if (!IgnisArtifactsPlugin.DECORATED.test(source)) {\n continue;\n }\n add(\n IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map(className => ({\n filePath: file,\n className,\n })),\n );\n }\n for (const groupFile of opts.groupFiles ?? []) {\n const packageSource = ArtifactSources.packageSource({ from: dirname(groupFile) });\n if (packageSource === opts.root || !existsSync(packageSource)) {\n continue;\n }\n add(\n ArtifactSources.runningArtifacts({\n artifacts: ArtifactSources.scan({ packageSource }),\n from: groupFile,\n }),\n );\n }\n return byFile;\n }\n\n /** The source files that define groups: the application's own `src` and the `src` of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does. */\n static groupDefinitionFiles(opts: { root: string }): string[] {\n return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter(file =>\n IgnisArtifactsPlugin.DEFINE_CALL.test(readFileSync(file, 'utf8')),\n );\n }\n\n /** The source files of the application and of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does - plus the compiled trees beside each `src`, for a package that runs from `dist`. Tests excluded. */\n static workspaceSourceFiles(opts: { root: string }): string[] {\n const root = resolve(opts.root);\n const packageDirectory = dirname(root);\n const manifestPath = join(packageDirectory, 'package.json');\n const manifest = existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, 'utf8')) : {};\n const names = Object.keys({\n ...manifest.dependencies,\n ...manifest.devDependencies,\n ...manifest.peerDependencies,\n });\n\n const sources = new Set<string>([root]);\n for (const name of names) {\n let directory = packageDirectory;\n while (true) {\n const linked = join(directory, 'node_modules', name);\n if (existsSync(linked)) {\n const real = realpathSync(linked);\n if (!real.split(sep).includes('node_modules') && existsSync(join(real, 'src'))) {\n sources.add(join(real, 'src'));\n }\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n break;\n }\n directory = parent;\n }\n }\n\n // A package that runs from its compiled tree (`main` in dist) defines its groups there too.\n const trees: Array<{ directory: string; pattern: string }> = [];\n for (const source of sources) {\n if (!existsSync(source)) {\n continue;\n }\n trees.push({ directory: source, pattern: ArtifactStereotypes.SOURCE_GLOB });\n for (const entry of readdirSync(dirname(source), { withFileTypes: true })) {\n if (\n entry.isDirectory() &&\n !['src', 'node_modules'].includes(entry.name) &&\n !entry.name.startsWith('.')\n ) {\n trees.push({ directory: join(dirname(source), entry.name), pattern: '**/*.js' });\n }\n }\n }\n\n const files: string[] = [];\n for (const { directory, pattern } of trees) {\n for (const relativePath of globSync(pattern, { cwd: directory })) {\n if (!relativePath.includes('__tests__')) {\n files.push(join(directory, relativePath));\n }\n }\n }\n return files;\n }\n\n /** For `Bun.build({ plugins: [IgnisArtifactsPlugin.create()] })`; `isRuntime` is set by `registerRuntime`, which serves a virtual module instead. `entry` (default: the build's first entrypoint, or `Bun.main` at run time) decides which tree the classes are imported from. */\n static create(\n opts: { root?: string; entry?: string; isRuntime?: boolean; lazyIndex?: boolean } = {},\n ): BunPlugin {\n const isRuntime = opts.isRuntime ?? false;\n\n return {\n name: IgnisArtifactsPlugin.NAME,\n setup(build) {\n const [entrypoint] = isRuntime ? [] : build.config.entrypoints;\n const entry = opts.entry ?? (entrypoint ? resolve(entrypoint) : ArtifactSources.entry());\n const root =\n opts.root ??\n ArtifactSources.packageSource({ from: entry ? dirname(entry) : process.cwd() });\n const contents = (): string => IgnisArtifactsPlugin.render({ root, entry });\n\n if (isRuntime) {\n build.module(IgnisArtifactsPlugin.VIRTUAL, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n return;\n }\n\n const virtualPath = join(resolve(root), '__ignis_artifacts__.ts');\n build.onResolve({ filter: /^ignis:artifacts$/ }, () => ({ path: virtualPath }));\n build.onLoad({ filter: /__ignis_artifacts__\\.ts$/ }, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n const groupFiles = IgnisArtifactsPlugin.groupDefinitionFiles({ root });\n const groupFileSet = new Set(groupFiles);\n const pinned = IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles, entry });\n const loaded = [...new Set([...groupFiles, ...pinned.keys()])];\n if (loaded.length > 0) {\n const escaped = loaded.map(file => file.replace(/[.*+?^${}()|[\\]\\\\/]/g, '\\\\$&'));\n build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, args => {\n const source = readFileSync(args.path, 'utf8');\n const grouped = groupFileSet.has(args.path)\n ? IgnisArtifactsPlugin.rewriteGroups({ filePath: args.path, source })\n : source;\n const classNames = pinned.get(args.path);\n return {\n contents: classNames\n ? IgnisArtifactsPlugin.pinClassNames({\n filePath: args.path,\n source: grouped,\n classNames,\n })\n : grouped,\n loader: args.path.endsWith('.tsx') ? 'tsx' : args.path.endsWith('.ts') ? 'ts' : 'js',\n };\n });\n }\n // Lazy (a dynamic import on the first resolve) for a server: a library importing this module must not evaluate the app's classes inside its own half-loaded graph. Eager for a browser bundle: a lazily evaluated graph is not tree-shaken, which doubled a measured frontend bundle.\n const isLazy = opts.lazyIndex ?? build.config.target !== 'browser';\n const autoModule = isLazy\n ? `import { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ resolve: async () => (await import('${IgnisArtifactsPlugin.VIRTUAL}')).${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`\n : `import { ${IgnisArtifactsPlugin.EXPORT_NAME} } from '${IgnisArtifactsPlugin.VIRTUAL}';\\nimport { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ content: ${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`;\n build.onLoad({ filter: IgnisArtifactsPlugin.AUTO_MODULE }, () => ({\n contents: autoModule,\n loader: 'ts',\n }));\n },\n };\n }\n\n /** Registers the run-time plugin once per process; a second call is a no-op. */\n static async registerRuntime(opts: { root?: string } = {}): Promise<void> {\n if (Reflect.get(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY) === true) {\n return;\n }\n await Bun.plugin(IgnisArtifactsPlugin.create({ ...opts, isRuntime: true }));\n Reflect.set(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY, true);\n }\n}\n"]}
1
+ {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/bun/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACxF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,EAAE,MAAM,YAAY,CAAC;AAC5B,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAC1F,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAE5C,6QAA6Q;AAC7Q,MAAM,OAAO,oBAAoB;aACf,SAAI,GAAG,iBAAiB,CAAC;aACzB,YAAO,GAAG,iBAAiB,CAAC;aAC5B,gBAAW,GAAG,oBAAoB,CAAC;IAEnD,+IAA+I;aAC/H,gBAAW,GACzB,kHAAkH,CAAC;IAErH,oHAAoH;aACpG,gBAAW,GAAG,kDAAkD,CAAC;aAEzD,gBAAW,GAAG,MAAM,CAAC,GAAG,CAAC,8CAA8C,CAAC,CAAC;IAEjG;QACE,eAAe,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,eAAe,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IACzE,CAAC;IAED,8GAA8G;IAC9G,MAAM,CAAC,WAAW,CAAC,OAA0B,EAAE;QAC7C,OAAO,eAAe,CAAC,aAAa,CAAC;YACnC,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AC;gBACnE,MAAM,UAAU,GAAG,MAAM;oBACvB,CAAC,CAAC,iIAAiI,oBAAoB,CAAC,OAAO,OAAO,oBAAoB,CAAC,WAAW,QAAQ;oBAC9M,CAAC,CAAC,YAAY,oBAAoB,CAAC,WAAW,YAAY,oBAAoB,CAAC,OAAO,0GAA0G,oBAAoB,CAAC,WAAW,QAAQ,CAAC;gBAC3O,KAAK,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,oBAAoB,CAAC,WAAW,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;oBAChE,QAAQ,EAAE,UAAU;oBACpB,MAAM,EAAE,IAAI;iBACb,CAAC,CAAC,CAAC;YACN,CAAC;SACF,CAAC;IACJ,CAAC;IAED,gFAAgF;IAChF,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,OAA0B,EAAE;QACvD,IAAI,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,CAAC,KAAK,IAAI,EAAE,CAAC;YACvE,OAAO;QACT,CAAC;QACD,MAAM,GAAG,CAAC,MAAM,CAAC,oBAAoB,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAC5E,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,oBAAoB,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;IAClE,CAAC","sourcesContent":["import type { BunPlugin } from 'bun';\nimport { getError } from '@venizia/ignis-helpers';\nimport { existsSync, globSync, readdirSync, readFileSync, realpathSync } from 'node:fs';\nimport { dirname, join, resolve, sep } from 'node:path';\nimport ts from 'typescript';\nimport { ArtifactIndexEmitter, ArtifactScanner, ArtifactStereotypes } from '../generator';\nimport { ArtifactSources } from './sources';\n\n/** Serves `ignis:artifacts` - the application's generated index, rendered in memory from the scanner. At run time it is a virtual module (`build.module`); in `Bun.build` it is resolved and loaded (`onResolve`/`onLoad`), so a binary carries the list and never scans. */\nexport class IgnisArtifactsPlugin {\n static readonly NAME = 'ignis-artifacts';\n static readonly VIRTUAL = 'ignis:artifacts';\n static readonly EXPORT_NAME = 'GeneratedArtifacts';\n\n /** `@venizia/ignis-boot/auto`, from source or from either dist format - replaced at build time by a static re-export of the virtual module. */\n static readonly AUTO_MODULE =\n /[\\\\/](?:@venizia[\\\\/]ignis-boot|packages[\\\\/]boot)[\\\\/](?:dist[\\\\/](?:esm|cjs)|src)[\\\\/]bun[\\\\/]auto\\.(?:ts|js)$/;\n\n /** A text test for a file worth parsing: `ArtifactGroup.define(`, with any spacing or line break around the dot. */\n static readonly DEFINE_CALL = /ArtifactGroup\\s*\\.\\s*(?:define|application)\\s*\\(/;\n\n private static readonly RUNTIME_KEY = Symbol.for('@venizia/ignis-boot:artifacts-runtime-plugin');\n\n static {\n ArtifactSources.useScanner({ scanner: ArtifactScanner.getInstance() });\n }\n\n /** The `src` beside the nearest `package.json` at or above `from` (default: the entry module's directory). */\n static defaultRoot(opts: { from?: string } = {}): string {\n return ArtifactSources.packageSource({\n from: opts.from ?? IgnisArtifactsPlugin.entryDirectory(),\n });\n }\n\n /** The entry module's directory (`Bun.main`), so the root never depends on where the process was started; the working directory only when there is no entry file (`bun -e`, a REPL). */\n static entryDirectory(): string {\n const entry = ArtifactSources.entry();\n return entry ? dirname(entry) : process.cwd();\n }\n\n /** The index as module source: every import absolute, since a virtual module has no directory to resolve from. With `entry` in a compiled tree, each class is imported from that tree (`ArtifactSources.runningArtifacts`). */\n static render(opts: { root: string; entry?: string }): string {\n const root = resolve(opts.root);\n if (!existsSync(root)) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ${dirname(root)} has no src directory (${root}) | Auto artifacts scan the src beside the package.json of the entry module; pass IgnisArtifactsPlugin.create({ root }), or use ArtifactGroup.application() in the application's own source`,\n });\n }\n const outFile = join(root, '__ignis_artifacts__.ts');\n const artifacts = ArtifactSources.scan({ packageSource: root });\n return ArtifactIndexEmitter.render({\n artifacts: opts.entry\n ? ArtifactSources.runningArtifacts({ artifacts, from: opts.entry })\n : artifacts,\n outFile,\n exportName: IgnisArtifactsPlugin.EXPORT_NAME,\n command: { root, out: outFile },\n absoluteImports: true,\n });\n }\n\n /** Rewrites every `ArtifactGroup.define({ folder: '<literal>' })` and `ArtifactGroup.application()` in a source file to carry its classes as `content`, imported by absolute path - a binary then holds each group's list and never scans. A group with no decorated class, or a call the plugin cannot read (an aliased `ArtifactGroup`, a folder that is not a string literal), fails the build. */\n static rewriteGroups(opts: { filePath: string; source: string }): string {\n const { filePath, source } = opts;\n const sourceFile = ts.createSourceFile(filePath, source, ts.ScriptTarget.Latest, true);\n const aliases = new Set<string>();\n for (const statement of sourceFile.statements) {\n const bindings = ts.isImportDeclaration(statement)\n ? statement.importClause?.namedBindings\n : undefined;\n for (const element of bindings && ts.isNamedImports(bindings) ? bindings.elements : []) {\n if (\n (element.propertyName ?? element.name).text === 'ArtifactGroup' &&\n element.name.text !== 'ArtifactGroup'\n ) {\n aliases.add(element.name.text);\n }\n }\n }\n\n const edits: Array<{ at: number; text: string }> = [];\n const imports: string[] = [];\n let counter = 0;\n\n const refuse = (node: ts.Node, reason: string): never => {\n const { line } = sourceFile.getLineAndCharacterOfPosition(node.getStart());\n throw getError({\n message: `[IgnisArtifactsPlugin] An ArtifactGroup call at ${filePath}:${line + 1} cannot be rewritten | ${reason} - write ArtifactGroup.define({ folder: '<name>' }) or ArtifactGroup.application() with the class imported under its own name`,\n });\n };\n\n const isCompiled = !ArtifactStereotypes.SOURCE_EXTENSION.test(filePath);\n const contentLiteral = (folder: string | undefined, ignore?: string[]): string => {\n const artifacts = ArtifactSources.folderArtifacts({ folder, site: filePath, ignore });\n if (artifacts.length === 0) {\n throw getError({\n message: `[IgnisArtifactsPlugin] ArtifactGroup '${folder ?? '<application>'}' resolved to no class | ${filePath} - check the folder name and that its classes carry a stereotype decorator`,\n });\n }\n\n const fields: string[] = [];\n for (const { type, field } of ArtifactStereotypes.EMIT_ORDER) {\n const locals = artifacts\n .filter((artifact) => artifact.type === type)\n .map((artifact) => {\n if (isCompiled) {\n return `require(${JSON.stringify(artifact.filePath)}).${artifact.className}`;\n }\n counter += 1;\n const local = `__ignis_group_${counter}`;\n const path = artifact.filePath\n .split(sep)\n .join('/')\n .replace(ArtifactStereotypes.SOURCE_EXTENSION, '');\n imports.push(`import { ${artifact.className} as ${local} } from '${path}';`);\n return local;\n });\n if (locals.length > 0) {\n fields.push(`${field}: [${locals.join(', ')}]`);\n }\n }\n return `{ ${fields.join(', ')} }`;\n };\n\n const visit = (node: ts.Node): void => {\n const isGroupCall =\n ts.isCallExpression(node) &&\n ts.isPropertyAccessExpression(node.expression) &&\n (ts.isIdentifier(node.expression.expression) ||\n ts.isPropertyAccessExpression(node.expression.expression)) &&\n (node.expression.name.text === 'define' || node.expression.name.text === 'application');\n if (!isGroupCall) {\n ts.forEachChild(node, visit);\n return;\n }\n\n const call = node as ts.CallExpression;\n const access = call.expression as ts.PropertyAccessExpression;\n const target = access.expression;\n const callee = ts.isIdentifier(target)\n ? target.text\n : (target as ts.PropertyAccessExpression).name.text;\n const isApplication = access.name.text === 'application';\n if (ts.isIdentifier(target) && aliases.has(callee)) {\n refuse(call, `ArtifactGroup is imported as ${callee}`);\n }\n if (callee !== 'ArtifactGroup') {\n ts.forEachChild(node, visit);\n return;\n }\n\n const [argument] = call.arguments;\n if (isApplication && !argument) {\n edits.push({ at: call.arguments.pos, text: `{ content: ${contentLiteral(undefined)} }` });\n return;\n }\n if (!argument || !ts.isObjectLiteralExpression(argument)) {\n refuse(call, 'the argument is not an object literal');\n }\n\n const literal = argument as ts.ObjectLiteralExpression;\n const named = (name: string): ts.ObjectLiteralElementLike | undefined =>\n literal.properties.find(\n (entry) =>\n entry.name !== undefined && ts.isIdentifier(entry.name) && entry.name.text === name,\n );\n if (named('content')) {\n return;\n }\n\n const folderProperty = named('folder');\n if (isApplication && folderProperty) {\n refuse(call, 'ArtifactGroup.application() takes no folder');\n }\n const folderLiteral =\n folderProperty &&\n ts.isPropertyAssignment(folderProperty) &&\n ts.isStringLiteral(folderProperty.initializer)\n ? folderProperty.initializer.text\n : undefined;\n if (!isApplication && folderLiteral === undefined) {\n refuse(call, 'folder is not a string literal');\n }\n\n const ignoreProperty = named('ignore');\n const ignoreList =\n ignoreProperty &&\n ts.isPropertyAssignment(ignoreProperty) &&\n ts.isArrayLiteralExpression(ignoreProperty.initializer) &&\n ignoreProperty.initializer.elements.every((element) => ts.isStringLiteral(element))\n ? ignoreProperty.initializer.elements.map((element) => (element as ts.StringLiteral).text)\n : undefined;\n if (ignoreProperty && ignoreList === undefined) {\n refuse(call, 'ignore is not an array of string literals');\n }\n\n const last = literal.properties[literal.properties.length - 1];\n edits.push({\n at: last ? last.getEnd() : literal.getStart() + 1,\n text: `${last ? ', ' : ''}content: ${contentLiteral(folderLiteral, ignoreList)}`,\n });\n };\n visit(sourceFile);\n\n let rewritten = source;\n for (const edit of [...edits].sort((left, right) => right.at - left.at)) {\n rewritten = rewritten.slice(0, edit.at) + edit.text + rewritten.slice(edit.at);\n }\n return imports.length > 0 ? `${imports.join('\\n')}\\n${rewritten}` : rewritten;\n }\n\n /** A text test for a file worth parsing for decorated classes: an IGNIS stereotype decorator call. */\n static readonly DECORATED =\n /@(?:configuration|component|controller|service|repository|datasource|model|injectable)\\s*\\(/;\n\n /** The classes of a source file that carry an IGNIS stereotype decorator (`@service()`, `@repository(...)`, `@injectable(...)`...). */\n static decoratedClasses(opts: { filePath: string; source: string }): string[] {\n const names = new Set([\n ...Object.keys(ArtifactStereotypes.BY_DECORATOR),\n ArtifactStereotypes.ROOT_DECORATOR,\n ]);\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const found: string[] = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name) {\n const isDecorated = (ts.getDecorators(node) ?? []).some((decorator) => {\n const expression = ts.isCallExpression(decorator.expression)\n ? decorator.expression.expression\n : decorator.expression;\n return ts.isIdentifier(expression) && names.has(expression.text);\n });\n if (isDecorated) {\n found.push(node.name.text);\n }\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n return found;\n }\n\n /** Opens each named class with `static { Object.defineProperty(this, 'name', ...) }`. Binding keys are built from `Class.name`, and a bundler renames classes - a minifier, or Bun's scope hoisting when a registered class shadows a same-name class it extends (`StockService` becomes `StockService2`). A string literal survives both, and a static block runs before the class's decorators. Only these classes are touched; the rest of the bundle is left alone. */\n static pinClassNames(opts: {\n filePath: string;\n source: string;\n classNames: ReadonlySet<string>;\n }): string {\n const sourceFile = ts.createSourceFile(\n opts.filePath,\n opts.source,\n ts.ScriptTarget.Latest,\n true,\n );\n const positions: Array<{ at: number; name: string }> = [];\n const visit = (node: ts.Node): void => {\n if (ts.isClassDeclaration(node) && node.name && opts.classNames.has(node.name.text)) {\n positions.push({ at: node.members.pos, name: node.name.text });\n }\n ts.forEachChild(node, visit);\n };\n visit(sourceFile);\n\n let pinned = opts.source;\n for (const { at, name } of positions.sort((left, right) => right.at - left.at)) {\n const block = ` static { Object.defineProperty(this, 'name', { value: ${JSON.stringify(name)} }); }`;\n pinned = pinned.slice(0, at) + block + pinned.slice(at);\n }\n return pinned;\n }\n\n /** The classes whose names a build must pin, by the file the build loads: the app's own (from the tree `entry` runs, see `runningArtifacts`) and those of every package that defines a group the app can borrow (from the tree the group file sits in). */\n static pinnedClasses(opts: {\n root: string;\n groupFiles?: ReadonlyArray<string>;\n entry?: string;\n }): Map<string, Set<string>> {\n const byFile = new Map<string, Set<string>>();\n const add = (artifacts: ReadonlyArray<{ filePath: string; className: string }>): void => {\n for (const { filePath, className } of artifacts) {\n byFile.set(filePath, (byFile.get(filePath) ?? new Set()).add(className));\n }\n };\n const own = ArtifactSources.scan({ packageSource: opts.root });\n add(opts.entry ? ArtifactSources.runningArtifacts({ artifacts: own, from: opts.entry }) : own);\n // Every class carrying an IGNIS decorator in the workspace sources: a class nothing scans (a library that defines no group) is still an injection target, and still renamed by a bundler when its name collides.\n for (const file of IgnisArtifactsPlugin.workspaceSourceFiles({ root: opts.root })) {\n if (!ArtifactStereotypes.SOURCE_EXTENSION.test(file)) {\n continue;\n }\n const source = readFileSync(file, 'utf8');\n if (!IgnisArtifactsPlugin.DECORATED.test(source)) {\n continue;\n }\n add(\n IgnisArtifactsPlugin.decoratedClasses({ filePath: file, source }).map((className) => ({\n filePath: file,\n className,\n })),\n );\n }\n for (const groupFile of opts.groupFiles ?? []) {\n const packageSource = ArtifactSources.packageSource({ from: dirname(groupFile) });\n if (packageSource === opts.root || !existsSync(packageSource)) {\n continue;\n }\n add(\n ArtifactSources.runningArtifacts({\n artifacts: ArtifactSources.scan({ packageSource }),\n from: groupFile,\n }),\n );\n }\n return byFile;\n }\n\n /** The source files that define groups: the application's own `src` and the `src` of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does. */\n static groupDefinitionFiles(opts: { root: string }): string[] {\n return IgnisArtifactsPlugin.workspaceSourceFiles(opts).filter((file) =>\n IgnisArtifactsPlugin.DEFINE_CALL.test(readFileSync(file, 'utf8')),\n );\n }\n\n /** The source files of the application and of each workspace dependency (a dependency whose real path is outside every `node_modules`), found by walking up the `node_modules` chain as Node resolution does - plus the compiled trees beside each `src`, for a package that runs from `dist`. Tests excluded. */\n static workspaceSourceFiles(opts: { root: string }): string[] {\n const root = resolve(opts.root);\n const packageDirectory = dirname(root);\n const manifestPath = join(packageDirectory, 'package.json');\n const manifest = existsSync(manifestPath) ? JSON.parse(readFileSync(manifestPath, 'utf8')) : {};\n const names = Object.keys({\n ...manifest.dependencies,\n ...manifest.devDependencies,\n ...manifest.peerDependencies,\n });\n\n const sources = new Set<string>([root]);\n for (const name of names) {\n let directory = packageDirectory;\n while (true) {\n const linked = join(directory, 'node_modules', name);\n if (existsSync(linked)) {\n const real = realpathSync(linked);\n if (!real.split(sep).includes('node_modules') && existsSync(join(real, 'src'))) {\n sources.add(join(real, 'src'));\n }\n break;\n }\n const parent = dirname(directory);\n if (parent === directory) {\n break;\n }\n directory = parent;\n }\n }\n\n // A package that runs from its compiled tree (`main` in dist) defines its groups there too.\n const trees: Array<{ directory: string; pattern: string }> = [];\n for (const source of sources) {\n if (!existsSync(source)) {\n continue;\n }\n trees.push({ directory: source, pattern: ArtifactStereotypes.SOURCE_GLOB });\n for (const entry of readdirSync(dirname(source), { withFileTypes: true })) {\n if (\n entry.isDirectory() &&\n !['src', 'node_modules'].includes(entry.name) &&\n !entry.name.startsWith('.')\n ) {\n trees.push({ directory: join(dirname(source), entry.name), pattern: '**/*.js' });\n }\n }\n }\n\n const files: string[] = [];\n for (const { directory, pattern } of trees) {\n for (const relativePath of globSync(pattern, { cwd: directory })) {\n if (!relativePath.includes('__tests__')) {\n files.push(join(directory, relativePath));\n }\n }\n }\n return files;\n }\n\n /** For `Bun.build({ plugins: [IgnisArtifactsPlugin.create()] })`; `isRuntime` is set by `registerRuntime`, which serves a virtual module instead. `entry` (default: the build's first entrypoint, or `Bun.main` at run time) decides which tree the classes are imported from. */\n static create(\n opts: { root?: string; entry?: string; isRuntime?: boolean; lazyIndex?: boolean } = {},\n ): BunPlugin {\n const isRuntime = opts.isRuntime ?? false;\n\n return {\n name: IgnisArtifactsPlugin.NAME,\n setup(build) {\n const [entrypoint] = isRuntime ? [] : build.config.entrypoints;\n const entry = opts.entry ?? (entrypoint ? resolve(entrypoint) : ArtifactSources.entry());\n const root =\n opts.root ??\n ArtifactSources.packageSource({ from: entry ? dirname(entry) : process.cwd() });\n const contents = (): string => IgnisArtifactsPlugin.render({ root, entry });\n\n if (isRuntime) {\n build.module(IgnisArtifactsPlugin.VIRTUAL, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n return;\n }\n\n const virtualPath = join(resolve(root), '__ignis_artifacts__.ts');\n build.onResolve({ filter: /^ignis:artifacts$/ }, () => ({ path: virtualPath }));\n build.onLoad({ filter: /__ignis_artifacts__\\.ts$/ }, () => ({\n contents: contents(),\n loader: 'ts',\n }));\n const groupFiles = IgnisArtifactsPlugin.groupDefinitionFiles({ root });\n const groupFileSet = new Set(groupFiles);\n const pinned = IgnisArtifactsPlugin.pinnedClasses({ root, groupFiles, entry });\n const loaded = [...new Set([...groupFiles, ...pinned.keys()])];\n if (loaded.length > 0) {\n const escaped = loaded.map((file) => file.replace(/[.*+?^${}()|[\\]\\\\/]/g, '\\\\$&'));\n build.onLoad({ filter: new RegExp(`^(?:${escaped.join('|')})$`) }, (args) => {\n const source = readFileSync(args.path, 'utf8');\n const grouped = groupFileSet.has(args.path)\n ? IgnisArtifactsPlugin.rewriteGroups({ filePath: args.path, source })\n : source;\n const classNames = pinned.get(args.path);\n return {\n contents: classNames\n ? IgnisArtifactsPlugin.pinClassNames({\n filePath: args.path,\n source: grouped,\n classNames,\n })\n : grouped,\n loader: args.path.endsWith('.tsx') ? 'tsx' : args.path.endsWith('.ts') ? 'ts' : 'js',\n };\n });\n }\n // Lazy (a dynamic import on the first resolve) for a server: a library importing this module must not evaluate the app's classes inside its own half-loaded graph. Eager for a browser bundle: a lazily evaluated graph is not tree-shaken, which doubled a measured frontend bundle.\n const isLazy = opts.lazyIndex ?? build.config.target !== 'browser';\n const autoModule = isLazy\n ? `import { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ resolve: async () => (await import('${IgnisArtifactsPlugin.VIRTUAL}')).${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`\n : `import { ${IgnisArtifactsPlugin.EXPORT_NAME} } from '${IgnisArtifactsPlugin.VIRTUAL}';\\nimport { AutoArtifactGroup } from './auto-group';\\nexport default new AutoArtifactGroup({ content: ${IgnisArtifactsPlugin.EXPORT_NAME} });\\n`;\n build.onLoad({ filter: IgnisArtifactsPlugin.AUTO_MODULE }, () => ({\n contents: autoModule,\n loader: 'ts',\n }));\n },\n };\n }\n\n /** Registers the run-time plugin once per process; a second call is a no-op. */\n static async registerRuntime(opts: { root?: string } = {}): Promise<void> {\n if (Reflect.get(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY) === true) {\n return;\n }\n await Bun.plugin(IgnisArtifactsPlugin.create({ ...opts, isRuntime: true }));\n Reflect.set(globalThis, IgnisArtifactsPlugin.RUNTIME_KEY, true);\n }\n}\n"]}
@@ -23,7 +23,7 @@ export class ArtifactScanCache {
23
23
  let directory = dirname(root);
24
24
  while (true) {
25
25
  const lockfile = ['bun.lock', 'bun.lockb', 'package-lock.json']
26
- .map(name => join(directory, name))
26
+ .map((name) => join(directory, name))
27
27
  .find(existsSync);
28
28
  if (lockfile) {
29
29
  extras.push(lockfile);