@vaadin/hilla-generator-utils 25.0.0-alpha9 → 25.0.0-beta2

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.
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,gBAAkC;AACzC,OAAO,6BAA8B;AASrC,eAAe,MAAM,cAAc;CACjC,AAASA,YAAY,IAAI;CACzB,AAASC;CAET,YAAY,EAAE,MAAM,SAAwB,EAAE;EAC5C,MAAM,SAAS,WAAW,EACxB,QAAQ,OACT,EAAC;AAEF,OAAKA,UAAU,KACb;GACE,MAAM;GACN,OAAO,UAAU,UAAU;GAC3B,MAAM,QAAQ;EACf,GACD,OACD;CACF;CAED,IAAI,SAAiB;AACnB,SAAO,KAAKA;CACb;CAED,IAAIC,QAAwB;AAC1B,MAAI,KAAKF,UAAU,IAAI,OAAO,EAAE;AAC9B,UAAO,KAAKA,UAAU,IAAI,OAAO;EAClC;EAED,MAAM,QAAQ,KAAKC,QAAQ,MAAM,EAAE,OAAQ,EAAC;AAC5C,OAAKD,UAAU,IAAI,QAAQ,MAAM;AACjC,SAAO;CACR;AACF","names":["#children","#logger","caller: string"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/LoggerFactory.ts"],"sourcesContent":["import Pino, { type Logger } from 'pino';\nimport PinoPretty from 'pino-pretty';\n\nexport { type Logger };\n\nexport type LoggerOptions = Readonly<{\n name?: string;\n verbose?: boolean;\n}>;\n\nexport default class LoggerFactory {\n readonly #children = new Map<string, Logger>();\n readonly #logger: Logger;\n\n constructor({ name, verbose }: LoggerOptions) {\n const pretty = PinoPretty({\n ignore: 'time',\n });\n\n this.#logger = Pino(\n {\n base: undefined,\n level: verbose ? 'debug' : 'info',\n name: name ?? 'tsgen',\n },\n pretty,\n );\n }\n\n get global(): Logger {\n return this.#logger;\n }\n\n for(caller: string): Logger {\n if (this.#children.has(caller)) {\n return this.#children.get(caller)!;\n }\n\n const child = this.#logger.child({ caller });\n this.#children.set(caller, child);\n return child;\n }\n}\n"],"version":3}
1
+ {"mappings":"AAAA,OAAO,gBAAkC;AACzC,OAAO,6BAA8B;AASrC,eAAe,MAAM,cAAc;CACjC,AAASA,YAAY,IAAI;CACzB,AAASC;CAET,YAAY,EAAE,MAAM,SAAwB,EAAE;EAC5C,MAAM,SAAS,WAAW,EACxB,QAAQ,OACT,EAAC;AAEF,OAAKA,UAAU,KACb;GACE,MAAM;GACN,OAAO,UAAU,UAAU;GAC3B,MAAM,QAAQ;EACf,GACD,OACD;CACF;CAED,IAAI,SAAiB;AACnB,SAAO,KAAKA;CACb;CAED,IAAIC,QAAwB;AAC1B,MAAI,KAAKF,UAAU,IAAI,OAAO,EAAE;AAC9B,UAAO,KAAKA,UAAU,IAAI,OAAO;EAClC;EAED,MAAM,QAAQ,KAAKC,QAAQ,MAAM,EAAE,OAAQ,EAAC;AAC5C,OAAKD,UAAU,IAAI,QAAQ,MAAM;AACjC,SAAO;CACR;AACF","names":["#children","#logger","caller: string"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/LoggerFactory.ts"],"sourcesContent":["import Pino, { type Logger } from 'pino';\nimport PinoPretty from 'pino-pretty';\n\nexport { type Logger };\n\nexport type LoggerOptions = Readonly<{\n name?: string;\n verbose?: boolean;\n}>;\n\nexport default class LoggerFactory {\n readonly #children = new Map<string, Logger>();\n readonly #logger: Logger;\n\n constructor({ name, verbose }: LoggerOptions) {\n const pretty = PinoPretty({\n ignore: 'time',\n });\n\n this.#logger = Pino(\n {\n base: undefined,\n level: verbose ? 'debug' : 'info',\n name: name ?? 'tsgen',\n },\n pretty,\n );\n }\n\n get global(): Logger {\n return this.#logger;\n }\n\n for(caller: string): Logger {\n if (this.#children.has(caller)) {\n return this.#children.get(caller)!;\n }\n\n const child = this.#logger.child({ caller });\n this.#children.set(caller, child);\n return child;\n }\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,eAAe,MAAM,oBAAoB,MAAM;CAC7C,YAAYA,SAAiB,aAAa,4BAA4B;AACpE,SAAO,GAAG,WAAW,KAAK,QAAQ,EAAE;CACrC;AACF","names":["message: string"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/PluginError.ts"],"sourcesContent":["export default class PluginError extends Error {\n constructor(message: string, pluginName = 'Unknown Generator Plugin') {\n super(`[${pluginName}]: ${message}`);\n }\n}\n"],"version":3}
1
+ {"mappings":"AAAA,eAAe,MAAM,oBAAoB,MAAM;CAC7C,YAAYA,SAAiB,aAAa,4BAA4B;AACpE,SAAO,GAAG,WAAW,KAAK,QAAQ,EAAE;CACrC;AACF","names":["message: string"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/PluginError.ts"],"sourcesContent":["export default class PluginError extends Error {\n constructor(message: string, pluginName = 'Unknown Generator Plugin') {\n super(`[${pluginName}]: ${message}`);\n }\n}\n"],"version":3}
package/ast.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,oBAOa;AAapB,OAAO,SAAS,SACdA,MACAC,wBACAC,cAC0B;CAC1B,IAAIC;AAEJ,KAAI,MAAM,QAAQ,uBAAuB,EAAE;AAEzC,iBAAe;CAChB,OAAM;AACL,aAAW;CACZ;CAED,IAAI,aAAa,GAAG,iBAAiB,QAAQ,MAAM,GAAG,aAAa,QAAQ,MAAM;AAEjF,KAAI,cAAc;AAChB,GAAC,WAAW,GAAG,GAAG,UAChB,YACA,aACD,CAAC;CACH;AAED,QAAO,WAAW,WAAW,WAAW,IAAI,WAAW;AACxD;AAED,OAAO,SAAS,UACdC,aACuB;AACvB,QAAO,CAACC,YAAmC,CAACC,SAAY;EACtD,MAAM,UAAU,CAACC,SAA8C;GAC7D,MAAM,cAAc,YAAY,KAAK;AAErC,OAAI,gBAAgB,MAAM;AACxB,WAAO;GACR;AAED,UAAO,GAAG,eAAe,aAAa,SAAS,QAAQ;EACxD;AACD,SAAO,GAAG,eAAe,MAAM,SAAS,QAAQ;CACjD;AACF;AAED,OAAO,SAAS,SAAYA,MAAYC,SAAuD;CAC7F,SAAS,SAASC,GAAwB;AACxC,SAAO,QAAQ,EAAE,IAAI,GAAG,aAAa,GAAG,SAAS;CAClD;AAED,QAAO,SAAS,KAAK;AACtB","names":["code: string","selectorOrTransformers?: ReadonlyArray<TransformerFactory<SourceFile>> | TemplateSelector<T>","transformers?: ReadonlyArray<TransformerFactory<SourceFile>>","selector: TemplateSelector<T> | undefined","transformer: (node: Node) => VisitResult<Node | undefined>","context: TransformationContext","root: T","node: Node","visitor: (node: Node) => T | undefined","n: Node"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/ast.ts"],"sourcesContent":["import ts, {\n type Node,\n type VisitResult,\n type SourceFile,\n type Statement,\n type TransformationContext,\n type TransformerFactory,\n} from 'typescript';\n\nexport type TemplateSelector<T> = (statements: readonly Statement[]) => T;\n\nexport function template(\n code: string,\n transformers?: ReadonlyArray<TransformerFactory<SourceFile>>,\n): readonly Statement[];\nexport function template<T>(\n code: string,\n selector: TemplateSelector<T>,\n transformers?: ReadonlyArray<TransformerFactory<SourceFile>>,\n): T;\nexport function template<T>(\n code: string,\n selectorOrTransformers?: ReadonlyArray<TransformerFactory<SourceFile>> | TemplateSelector<T>,\n transformers?: ReadonlyArray<TransformerFactory<SourceFile>>,\n): T | readonly Statement[] {\n let selector: TemplateSelector<T> | undefined;\n\n if (Array.isArray(selectorOrTransformers)) {\n // eslint-disable-next-line no-param-reassign\n transformers = selectorOrTransformers;\n } else {\n selector = selectorOrTransformers as TemplateSelector<T>;\n }\n\n let sourceFile = ts.createSourceFile('f.ts', code, ts.ScriptTarget.Latest, false);\n\n if (transformers) {\n [sourceFile] = ts.transform<SourceFile>(\n sourceFile,\n transformers as Array<TransformerFactory<SourceFile>>,\n ).transformed;\n }\n\n return selector?.(sourceFile.statements) ?? sourceFile.statements;\n}\n\nexport function transform<T extends Node>(\n transformer: (node: Node) => VisitResult<Node | undefined>,\n): TransformerFactory<T> {\n return (context: TransformationContext) => (root: T) => {\n const visitor = (node: Node): VisitResult<Node | undefined> => {\n const transformed = transformer(node);\n\n if (transformed !== node) {\n return transformed;\n }\n\n return ts.visitEachChild(transformed, visitor, context);\n };\n return ts.visitEachChild(root, visitor, context);\n };\n}\n\nexport function traverse<T>(node: Node, visitor: (node: Node) => T | undefined): T | undefined {\n function _visitor(n: Node): T | undefined {\n return visitor(n) ?? ts.forEachChild(n, _visitor);\n }\n\n return _visitor(node);\n}\n"],"version":3}
1
+ {"mappings":"AAAA,OAAO,oBAOa;AAapB,OAAO,SAAS,SACdA,MACAC,wBACAC,cAC0B;CAC1B,IAAIC;AAEJ,KAAI,MAAM,QAAQ,uBAAuB,EAAE;AAEzC,iBAAe;CAChB,OAAM;AACL,aAAW;CACZ;CAED,IAAI,aAAa,GAAG,iBAAiB,QAAQ,MAAM,GAAG,aAAa,QAAQ,MAAM;AAEjF,KAAI,cAAc;AAChB,GAAC,WAAW,GAAG,GAAG,UAChB,YACA,aACD,CAAC;CACH;AAED,QAAO,WAAW,WAAW,WAAW,IAAI,WAAW;AACxD;AAED,OAAO,SAAS,UACdC,aACuB;AACvB,QAAO,CAACC,YAAmC,CAACC,SAAY;EACtD,MAAM,UAAU,CAACC,SAA8C;GAC7D,MAAM,cAAc,YAAY,KAAK;AAErC,OAAI,gBAAgB,MAAM;AACxB,WAAO;GACR;AAED,UAAO,GAAG,eAAe,aAAa,SAAS,QAAQ;EACxD;AACD,SAAO,GAAG,eAAe,MAAM,SAAS,QAAQ;CACjD;AACF;AAED,OAAO,SAAS,SAAYA,MAAYC,SAAuD;CAC7F,SAAS,SAASC,GAAwB;AACxC,SAAO,QAAQ,EAAE,IAAI,GAAG,aAAa,GAAG,SAAS;CAClD;AAED,QAAO,SAAS,KAAK;AACtB","names":["code: string","selectorOrTransformers?: ReadonlyArray<TransformerFactory<SourceFile>> | TemplateSelector<T>","transformers?: ReadonlyArray<TransformerFactory<SourceFile>>","selector: TemplateSelector<T> | undefined","transformer: (node: Node) => VisitResult<Node | undefined>","context: TransformationContext","root: T","node: Node","visitor: (node: Node) => T | undefined","n: Node"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/ast.ts"],"sourcesContent":["import ts, {\n type Node,\n type VisitResult,\n type SourceFile,\n type Statement,\n type TransformationContext,\n type TransformerFactory,\n} from 'typescript';\n\nexport type TemplateSelector<T> = (statements: readonly Statement[]) => T;\n\nexport function template(\n code: string,\n transformers?: ReadonlyArray<TransformerFactory<SourceFile>>,\n): readonly Statement[];\nexport function template<T>(\n code: string,\n selector: TemplateSelector<T>,\n transformers?: ReadonlyArray<TransformerFactory<SourceFile>>,\n): T;\nexport function template<T>(\n code: string,\n selectorOrTransformers?: ReadonlyArray<TransformerFactory<SourceFile>> | TemplateSelector<T>,\n transformers?: ReadonlyArray<TransformerFactory<SourceFile>>,\n): T | readonly Statement[] {\n let selector: TemplateSelector<T> | undefined;\n\n if (Array.isArray(selectorOrTransformers)) {\n // eslint-disable-next-line no-param-reassign\n transformers = selectorOrTransformers;\n } else {\n selector = selectorOrTransformers as TemplateSelector<T>;\n }\n\n let sourceFile = ts.createSourceFile('f.ts', code, ts.ScriptTarget.Latest, false);\n\n if (transformers) {\n [sourceFile] = ts.transform<SourceFile>(\n sourceFile,\n transformers as Array<TransformerFactory<SourceFile>>,\n ).transformed;\n }\n\n return selector?.(sourceFile.statements) ?? sourceFile.statements;\n}\n\nexport function transform<T extends Node>(\n transformer: (node: Node) => VisitResult<Node | undefined>,\n): TransformerFactory<T> {\n return (context: TransformationContext) => (root: T) => {\n const visitor = (node: Node): VisitResult<Node | undefined> => {\n const transformed = transformer(node);\n\n if (transformed !== node) {\n return transformed;\n }\n\n return ts.visitEachChild(transformed, visitor, context);\n };\n return ts.visitEachChild(root, visitor, context);\n };\n}\n\nexport function traverse<T>(node: Node, visitor: (node: Node) => T | undefined): T | undefined {\n function _visitor(n: Node): T | undefined {\n return visitor(n) ?? ts.forEachChild(n, _visitor);\n }\n\n return _visitor(node);\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,oBAAyE;AAEhF,eAAe,SAAS,4BAA4BA,MAAcC,OAA8C;AAC9G,QAAO,GAAG,QAAQ;EAChB;;EAEA,SAAS,GAAG,yBAAyB,aAAa,GAAG,yBAAyB;CAC/E;AACF","names":["name: string","flags?: GeneratedIdentifierFlags"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/createFullyUniqueIdentifier.ts"],"sourcesContent":["import ts, { type GeneratedIdentifierFlags, type Identifier } from 'typescript';\n\nexport default function createFullyUniqueIdentifier(name: string, flags?: GeneratedIdentifierFlags): Identifier {\n return ts.factory.createUniqueName(\n name,\n // eslint-disable-next-line no-bitwise\n flags ?? ts.GeneratedIdentifierFlags.Optimistic & ts.GeneratedIdentifierFlags.FileLevel,\n );\n}\n"],"version":3}
1
+ {"mappings":"AAAA,OAAO,oBAAyE;AAEhF,eAAe,SAAS,4BAA4BA,MAAcC,OAA8C;AAC9G,QAAO,GAAG,QAAQ;EAChB;;EAEA,SAAS,GAAG,yBAAyB,aAAa,GAAG,yBAAyB;CAC/E;AACF","names":["name: string","flags?: GeneratedIdentifierFlags"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/createFullyUniqueIdentifier.ts"],"sourcesContent":["import ts, { type GeneratedIdentifierFlags, type Identifier } from 'typescript';\n\nexport default function createFullyUniqueIdentifier(name: string, flags?: GeneratedIdentifierFlags): Identifier {\n return ts.factory.createUniqueName(\n name,\n // eslint-disable-next-line no-bitwise\n flags ?? ts.GeneratedIdentifierFlags.Optimistic & ts.GeneratedIdentifierFlags.FileLevel,\n );\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,oBAA0D;AAEjE,eAAe,SAAS,iBAAiBA,YAAkCC,UAA8B;CACvG,MAAM,aAAa,GAAG,iBAAiB,UAAU,IAAI,GAAG,aAAa,QAAQ,WAAW,GAAG,WAAW,GAAG;AACzG,QAAO,GAAG,QAAQ,iBAAiB,YAAY,WAAW;AAC3D","names":["statements: readonly Statement[]","fileName: string"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/createSourceFile.ts"],"sourcesContent":["import ts, { type SourceFile, type Statement } from 'typescript';\n\nexport default function createSourceFile(statements: readonly Statement[], fileName: string): SourceFile {\n const sourceFile = ts.createSourceFile(fileName, '', ts.ScriptTarget.ES2021, undefined, ts.ScriptKind.TS);\n return ts.factory.updateSourceFile(sourceFile, statements);\n}\n"],"version":3}
1
+ {"mappings":"AAAA,OAAO,oBAA0D;AAEjE,eAAe,SAAS,iBAAiBA,YAAkCC,UAA8B;CACvG,MAAM,aAAa,GAAG,iBAAiB,UAAU,IAAI,GAAG,aAAa,QAAQ,WAAW,GAAG,WAAW,GAAG;AACzG,QAAO,GAAG,QAAQ,iBAAiB,YAAY,WAAW;AAC3D","names":["statements: readonly Statement[]","fileName: string"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/createSourceFile.ts"],"sourcesContent":["import ts, { type SourceFile, type Statement } from 'typescript';\n\nexport default function createSourceFile(statements: readonly Statement[], fileName: string): SourceFile {\n const sourceFile = ts.createSourceFile(fileName, '', ts.ScriptTarget.ES2021, undefined, ts.ScriptKind.TS);\n return ts.factory.updateSourceFile(sourceFile, statements);\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,uCAAwC;AAC/C,OAAO,uCAAwC;AAG/C,eAAe,MAAM,kBAAkB;CACrC,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAYA,OAAoBC,WAA0B,IAAI,KAAK,SAAS,MAAM,EAAE,aAAa,OAAQ,IAAG;AAC1G,OAAK,UAAU,IAAI,cAAc;AACjC,OAAK,UAAU,IAAI,cAAc;AACjC,OAAK,QAAQ;CACd;AACF","names":["paths: PathManager","collator: Intl.Collator"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/dependencies/DependencyManager.ts"],"sourcesContent":["import ExportManager from './ExportManager.js';\nimport ImportManager from './ImportManager.js';\nimport type PathManager from './PathManager.js';\n\nexport default class DependencyManager {\n readonly exports: ExportManager;\n readonly imports: ImportManager;\n readonly paths: PathManager;\n\n constructor(paths: PathManager, collator: Intl.Collator = new Intl.Collator('en', { sensitivity: 'case' })) {\n this.exports = new ExportManager(collator);\n this.imports = new ImportManager(collator);\n this.paths = paths;\n }\n}\n"],"version":3}
1
+ {"mappings":"AAAA,OAAO,uCAAwC;AAC/C,OAAO,uCAAwC;AAG/C,eAAe,MAAM,kBAAkB;CACrC,AAAS;CACT,AAAS;CACT,AAAS;CAET,YAAYA,OAAoBC,WAA0B,IAAI,KAAK,SAAS,MAAM,EAAE,aAAa,OAAQ,IAAG;AAC1G,OAAK,UAAU,IAAI,cAAc;AACjC,OAAK,UAAU,IAAI,cAAc;AACjC,OAAK,QAAQ;CACd;AACF","names":["paths: PathManager","collator: Intl.Collator"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/dependencies/DependencyManager.ts"],"sourcesContent":["import ExportManager from './ExportManager.js';\nimport ImportManager from './ImportManager.js';\nimport type PathManager from './PathManager.js';\n\nexport default class DependencyManager {\n readonly exports: ExportManager;\n readonly imports: ImportManager;\n readonly paths: PathManager;\n\n constructor(paths: PathManager, collator: Intl.Collator = new Intl.Collator('en', { sensitivity: 'case' })) {\n this.exports = new ExportManager(collator);\n this.imports = new ImportManager(collator);\n this.paths = paths;\n }\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,oBAAyG;AAChH,OAAO,oEAAqE;AAE5E,OAAO,yDAAoF;AAC3F,SAAS,0CAAkE;AAE3E,OAAO,MAAM,mBAA6E;CACxF,AAAS;CACT,AAASA,OAAO,IAAI;CAEpB,IAAI,OAAe;AACjB,SAAO,KAAKA,KAAK;CAClB;CAED,YAAYC,UAAyB;AACnC,OAAK,WAAW;CACjB;CA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,MAAM,iBAAiB,KAAK,MAAM,QAAQ;EAC1C,MAAM,sBAAsB,KAAK,UAAU,QAAQ;EAEnD,MAAMO,SAAsB,CAAE;AAE9B,MAAI,gBAAgB;AAClB,UAAO,KAAK,eAAe;EAC5B;AAED,SAAO,KAAK,GAAG,oBAAoB;AAEnC,MAAI,kBAAkB;AACpB,UAAO,KAAK,iBAAiB;EAC9B;AAED,SAAO;CACR;AACF","names":["#map","collator: Intl.Collator","name: string","isType?: boolean","uniqueId?: Identifier","path: string","#id","id: Identifier | string","result: Statement[]"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/dependencies/ExportManager.ts"],"sourcesContent":["import ts, { type ExportAssignment, type ExportDeclaration, type Identifier, type Statement } from 'typescript';\nimport createFullyUniqueIdentifier from '../createFullyUniqueIdentifier.js';\nimport type CodeConvertable from './CodeConvertable.js';\nimport StatementRecordManager, { type StatementRecord } from './StatementRecordManager.js';\nimport { createDependencyRecord, type DependencyRecord } from './utils.js';\n\nexport class NamedExportManager implements CodeConvertable<ExportDeclaration | undefined> {\n readonly collator: Intl.Collator;\n readonly #map = new Map<string, DependencyRecord>();\n\n get size(): number {\n return this.#map.size;\n }\n\n constructor(collator: Intl.Collator) {\n this.collator = collator;\n }\n\n add(name: string, isType?: boolean, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(name, createDependencyRecord(id, isType));\n return id;\n }\n\n getIdentifier(name: string): Identifier | undefined {\n return this.#map.get(name)?.id;\n }\n\n *identifiers(): IterableIterator<readonly [id: Identifier, isType: boolean]> {\n for (const { id, isType } of this.#map.values()) {\n yield [id, isType];\n }\n }\n\n isType(name: string): boolean | undefined {\n return this.#map.get(name)?.isType;\n }\n\n names(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n toCode(): ExportDeclaration | undefined {\n if (this.#map.size === 0) {\n return undefined;\n }\n\n const names = [...this.#map.keys()];\n // eslint-disable-next-line @typescript-eslint/unbound-method\n names.sort(this.collator.compare);\n\n return ts.factory.createExportDeclaration(\n undefined,\n false,\n ts.factory.createNamedExports(\n names.map((name) => {\n const { id, isType } = this.#map.get(name)!;\n return ts.factory.createExportSpecifier(isType, id, ts.factory.createIdentifier(name));\n }),\n ),\n undefined,\n );\n }\n}\n\nexport class NamespaceExportManager extends StatementRecordManager<ExportDeclaration> {\n readonly #map = new Map<string, Identifier | null>();\n\n get size(): number {\n return this.#map.size;\n }\n\n addCombined(path: string, name: string, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(path, id);\n return id;\n }\n\n addSpread(path: string): void {\n this.#map.set(path, null);\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n getIdentifier(path: string): Identifier | null | undefined {\n return this.#map.get(path);\n }\n\n identifiers(): IterableIterator<Identifier | null> {\n return this.#map.values();\n }\n\n isCombined(path: string): boolean | undefined {\n return this.#map.has(path) ? this.#map.get(path) !== null : undefined;\n }\n\n isSpread(path: string): boolean | undefined {\n return this.#map.has(path) ? this.#map.get(path) === null : undefined;\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ExportDeclaration>> {\n for (const [path, id] of this.#map) {\n yield [\n path,\n ts.factory.createExportDeclaration(\n undefined,\n false,\n id !== null ? ts.factory.createNamespaceExport(id) : undefined,\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n}\n\nexport class DefaultExportManager implements CodeConvertable<ExportAssignment | undefined> {\n #id?: Identifier;\n\n get isEmpty(): boolean {\n return !this.#id;\n }\n\n set(id: Identifier | string): Identifier {\n this.#id = typeof id === 'string' ? ts.factory.createIdentifier(id) : id;\n return this.#id;\n }\n\n toCode(): ExportAssignment | undefined {\n return this.#id ? ts.factory.createExportAssignment(undefined, undefined, this.#id) : undefined;\n }\n}\n\nexport default class ExportManager implements CodeConvertable<readonly Statement[]> {\n readonly default: DefaultExportManager = new DefaultExportManager();\n readonly named: NamedExportManager;\n readonly namespace: NamespaceExportManager;\n\n get size(): number {\n return (this.default.isEmpty ? 0 : 1) + this.named.size + this.namespace.size;\n }\n\n constructor(collator: Intl.Collator) {\n this.named = new NamedExportManager(collator);\n this.namespace = new NamespaceExportManager(collator);\n }\n\n toCode(): readonly Statement[] {\n const defaultStatement = this.default.toCode();\n const namedStatement = this.named.toCode();\n const namespaceStatements = this.namespace.toCode();\n\n const result: Statement[] = [];\n\n if (namedStatement) {\n result.push(namedStatement);\n }\n\n result.push(...namespaceStatements);\n\n if (defaultStatement) {\n result.push(defaultStatement);\n }\n\n return result;\n }\n}\n"],"version":3}
1
+ {"mappings":"AAAA,OAAO,oBAAyG;AAChH,OAAO,oEAAqE;AAE5E,OAAO,yDAAoF;AAC3F,SAAS,0CAAkE;AAE3E,OAAO,MAAM,mBAA6E;CACxF,AAAS;CACT,AAASA,OAAO,IAAI;CAEpB,IAAI,OAAe;AACjB,SAAO,KAAKA,KAAK;CAClB;CAED,YAAYC,UAAyB;AACnC,OAAK,WAAW;CACjB;CAED,IAAIC,MAAcC,QAAkBC,UAAmC;EACrE,MAAM,KAAK,YAAY,4BAA4B,KAAK;AACxD,OAAKJ,KAAK,IAAI,MAAM,uBAAuB,IAAI,OAAO,CAAC;AACvD,SAAO;CACR;CAED,cAAcE,MAAsC;AAClD,SAAO,KAAKF,KAAK,IAAI,KAAK,EAAE;CAC7B;CAED,CAAC,cAA4E;AAC3E,OAAK,MAAM,EAAE,IAAI,QAAQ,IAAI,KAAKA,KAAK,QAAQ,EAAE;AAC/C,SAAM,CAAC,IAAI,MAAO;EACnB;CACF;CAED,OAAOE,MAAmC;AACxC,SAAO,KAAKF,KAAK,IAAI,KAAK,EAAE;CAC7B;CAED,QAAkC;AAChC,SAAO,KAAKA,KAAK,MAAM;CACxB;CAED,SAAwC;AACtC,MAAI,KAAKA,KAAK,SAAS,GAAG;AACxB,UAAO;EACR;EAED,MAAM,QAAQ,CAAC,GAAG,KAAKA,KAA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,QAAQ,oBAAoB,KAAK,CACrC,AACF;EACF;CACF;AACF;AAED,OAAO,MAAM,qBAA8E;CACzF;CAEA,IAAI,UAAmB;AACrB,UAAQ,KAAKM;CACd;CAED,IAAIC,IAAqC;AACvC,OAAKD,aAAa,OAAO,WAAW,GAAG,QAAQ,iBAAiB,GAAG,GAAG;AACtE,SAAO,KAAKA;CACb;CAED,SAAuC;AACrC,SAAO,KAAKA,MAAM,GAAG,QAAQ,uBAAuB,WAAW,WAAW,KAAKA,IAAI,GAAG;CACvF;AACF;AAED,eAAe,MAAM,cAA+D;CAClF,AAAS,UAAgC,IAAI;CAC7C,AAAS;CACT,AAAS;CAET,IAAI,OAAe;AACjB,UAAQ,KAAK,QAAQ,UAAU,IAAI,KAAK,KAAK,MAAM,OAAO,KAAK,UAAU;CAC1E;CAED,YAAYL,UAAyB;AACnC,OAAK,QAAQ,IAAI,mBAAmB;AACpC,OAAK,YAAY,IAAI,uBAAuB;CAC7C;CAED,SAA+B;EAC7B,MAAM,mBAAmB,KAAK,QAAQ,QAAQ;EAC9C,MAAM,iBAAiB,KAAK,MAAM,QAAQ;EAC1C,MAAM,sBAAsB,KAAK,UAAU,QAAQ;EAEnD,MAAMO,SAAsB,CAAE;AAE9B,MAAI,gBAAgB;AAClB,UAAO,KAAK,eAAe;EAC5B;AAED,SAAO,KAAK,GAAG,oBAAoB;AAEnC,MAAI,kBAAkB;AACpB,UAAO,KAAK,iBAAiB;EAC9B;AAED,SAAO;CACR;AACF","names":["#map","collator: Intl.Collator","name: string","isType?: boolean","uniqueId?: Identifier","path: string","#id","id: Identifier | string","result: Statement[]"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/dependencies/ExportManager.ts"],"sourcesContent":["import ts, { type ExportAssignment, type ExportDeclaration, type Identifier, type Statement } from 'typescript';\nimport createFullyUniqueIdentifier from '../createFullyUniqueIdentifier.js';\nimport type CodeConvertable from './CodeConvertable.js';\nimport StatementRecordManager, { type StatementRecord } from './StatementRecordManager.js';\nimport { createDependencyRecord, type DependencyRecord } from './utils.js';\n\nexport class NamedExportManager implements CodeConvertable<ExportDeclaration | undefined> {\n readonly collator: Intl.Collator;\n readonly #map = new Map<string, DependencyRecord>();\n\n get size(): number {\n return this.#map.size;\n }\n\n constructor(collator: Intl.Collator) {\n this.collator = collator;\n }\n\n add(name: string, isType?: boolean, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(name, createDependencyRecord(id, isType));\n return id;\n }\n\n getIdentifier(name: string): Identifier | undefined {\n return this.#map.get(name)?.id;\n }\n\n *identifiers(): IterableIterator<readonly [id: Identifier, isType: boolean]> {\n for (const { id, isType } of this.#map.values()) {\n yield [id, isType];\n }\n }\n\n isType(name: string): boolean | undefined {\n return this.#map.get(name)?.isType;\n }\n\n names(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n toCode(): ExportDeclaration | undefined {\n if (this.#map.size === 0) {\n return undefined;\n }\n\n const names = [...this.#map.keys()];\n // eslint-disable-next-line @typescript-eslint/unbound-method\n names.sort(this.collator.compare);\n\n return ts.factory.createExportDeclaration(\n undefined,\n false,\n ts.factory.createNamedExports(\n names.map((name) => {\n const { id, isType } = this.#map.get(name)!;\n return ts.factory.createExportSpecifier(isType, id, ts.factory.createIdentifier(name));\n }),\n ),\n undefined,\n );\n }\n}\n\nexport class NamespaceExportManager extends StatementRecordManager<ExportDeclaration> {\n readonly #map = new Map<string, Identifier | null>();\n\n get size(): number {\n return this.#map.size;\n }\n\n addCombined(path: string, name: string, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(path, id);\n return id;\n }\n\n addSpread(path: string): void {\n this.#map.set(path, null);\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n getIdentifier(path: string): Identifier | null | undefined {\n return this.#map.get(path);\n }\n\n identifiers(): IterableIterator<Identifier | null> {\n return this.#map.values();\n }\n\n isCombined(path: string): boolean | undefined {\n return this.#map.has(path) ? this.#map.get(path) !== null : undefined;\n }\n\n isSpread(path: string): boolean | undefined {\n return this.#map.has(path) ? this.#map.get(path) === null : undefined;\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ExportDeclaration>> {\n for (const [path, id] of this.#map) {\n yield [\n path,\n ts.factory.createExportDeclaration(\n undefined,\n false,\n id !== null ? ts.factory.createNamespaceExport(id) : undefined,\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n}\n\nexport class DefaultExportManager implements CodeConvertable<ExportAssignment | undefined> {\n #id?: Identifier;\n\n get isEmpty(): boolean {\n return !this.#id;\n }\n\n set(id: Identifier | string): Identifier {\n this.#id = typeof id === 'string' ? ts.factory.createIdentifier(id) : id;\n return this.#id;\n }\n\n toCode(): ExportAssignment | undefined {\n return this.#id ? ts.factory.createExportAssignment(undefined, undefined, this.#id) : undefined;\n }\n}\n\nexport default class ExportManager implements CodeConvertable<readonly Statement[]> {\n readonly default: DefaultExportManager = new DefaultExportManager();\n readonly named: NamedExportManager;\n readonly namespace: NamespaceExportManager;\n\n get size(): number {\n return (this.default.isEmpty ? 0 : 1) + this.named.size + this.namespace.size;\n }\n\n constructor(collator: Intl.Collator) {\n this.named = new NamedExportManager(collator);\n this.namespace = new NamespaceExportManager(collator);\n }\n\n toCode(): readonly Statement[] {\n const defaultStatement = this.default.toCode();\n const namedStatement = this.named.toCode();\n const namespaceStatements = this.namespace.toCode();\n\n const result: Statement[] = [];\n\n if (namedStatement) {\n result.push(namedStatement);\n }\n\n result.push(...namespaceStatements);\n\n if (defaultStatement) {\n result.push(defaultStatement);\n }\n\n return result;\n }\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,OAAO,oBAAkF;AACzF,OAAO,oEAAqE;AAE5E,OAAO,0BAA0B,qDAA4E;AAC7G,SAAS,0CAAkE;AAE3E,OAAO,MAAM,2BAA2B,uBAA0C;CAChF,AAASA,OAAO,IAAI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,MAAM,aAAa,YAAY,KAAK;GACjE;EACF;CACF;AACF","names":["#map","path: string","specifier: string","isType?: boolean","uniqueId?: Identifier","name: string","collator: Intl.Collator","source: ts.SourceFile"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/dependencies/ImportManager.ts"],"sourcesContent":["import ts, { type Identifier, type ImportDeclaration, type Statement } from 'typescript';\nimport createFullyUniqueIdentifier from '../createFullyUniqueIdentifier.js';\nimport type CodeConvertable from './CodeConvertable.js';\nimport StatementRecordManager, { createComparator, type StatementRecord } from './StatementRecordManager.js';\nimport { createDependencyRecord, type DependencyRecord } from './utils.js';\n\nexport class NamedImportManager extends StatementRecordManager<ImportDeclaration> {\n readonly #map = new Map<string, Map<string, DependencyRecord>>();\n\n get size(): number {\n return this.#map.size;\n }\n\n add(path: string, specifier: string, isType?: boolean, uniqueId?: Identifier): Identifier {\n const record = createDependencyRecord(uniqueId ?? createFullyUniqueIdentifier(specifier), isType);\n\n if (this.#map.has(path)) {\n this.#map.get(path)!.set(specifier, record);\n } else {\n this.#map.set(path, new Map([[specifier, record]]));\n }\n\n return record.id;\n }\n\n remove(path: string, specifier: string): void {\n const specifiers = this.#map.get(path);\n\n if (specifiers) {\n specifiers.delete(specifier);\n\n if (specifiers.size === 0) {\n this.#map.delete(path);\n }\n }\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n getIdentifier(path: string, specifier: string): Identifier | undefined {\n return this.#map.get(path)?.get(specifier)?.id;\n }\n\n iter(): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]> {\n return this[Symbol.iterator]();\n }\n\n isType(path: string, specifier: string): boolean | undefined {\n return this.#map.get(path)?.get(specifier)?.isType;\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n *specifiers(): IterableIterator<readonly [path: string, specifier: string]> {\n for (const [path, specifiers] of this.#map) {\n for (const specifier of specifiers.keys()) {\n yield [path, specifier];\n }\n }\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>> {\n for (const [path, specifiers] of this.#map) {\n const names = [...specifiers.keys()];\n // eslint-disable-next-line @typescript-eslint/unbound-method\n names.sort(this.collator.compare);\n\n const isTypeOnly = names.every((name) => specifiers.get(name)!.isType);\n\n yield [\n path,\n ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(\n isTypeOnly,\n undefined,\n ts.factory.createNamedImports(\n names.map((name) => {\n const { id, isType } = specifiers.get(name)!;\n return ts.factory.createImportSpecifier(\n isTypeOnly ? false : isType,\n ts.factory.createIdentifier(name),\n id,\n );\n }),\n ),\n ),\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n\n *[Symbol.iterator](): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]> {\n for (const [path, specifiers] of this.#map) {\n for (const [specifier, { id, isType }] of specifiers) {\n yield [path, specifier, id, isType];\n }\n }\n }\n}\n\nexport class NamespaceImportManager extends StatementRecordManager<ImportDeclaration> {\n readonly #map = new Map<string, Identifier>();\n\n get size(): number {\n return this.#map.size;\n }\n\n add(path: string, name: string, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(path, id);\n return id;\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n getIdentifier(path: string): Identifier | undefined {\n return this.#map.get(path);\n }\n\n iter(): IterableIterator<readonly [path: string, id: Identifier]> {\n return this[Symbol.iterator]();\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>> {\n for (const [path, id] of this.#map) {\n yield [\n path,\n ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(false, undefined, ts.factory.createNamespaceImport(id)),\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n\n remove(path: string): void {\n this.#map.delete(path);\n }\n\n *[Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier]> {\n for (const [path, id] of this.#map) {\n yield [path, id];\n }\n }\n}\n\nexport class DefaultImportManager extends StatementRecordManager<ImportDeclaration> {\n readonly #map = new Map<string, DependencyRecord>();\n\n get size(): number {\n return this.#map.size;\n }\n\n add(path: string, name: string, isType?: boolean, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(path, createDependencyRecord(id, isType));\n return id;\n }\n\n getIdentifier(path: string): Identifier | undefined {\n return this.#map.get(path)?.id;\n }\n\n remove(path: string): void {\n if (this.#map.has(path)) {\n this.#map.delete(path);\n }\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n iter(): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]> {\n return this[Symbol.iterator]();\n }\n\n isType(path: string): boolean | undefined {\n return this.#map.get(path)?.isType;\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>> {\n for (const [path, { id, isType }] of this.#map) {\n yield [\n path,\n ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(isType, id, undefined),\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n\n *[Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]> {\n for (const [path, { id, isType }] of this.#map) {\n yield [path, id, isType];\n }\n }\n}\n\nexport default class ImportManager implements CodeConvertable<readonly Statement[]> {\n readonly collator: Intl.Collator;\n readonly default: DefaultImportManager;\n readonly named: NamedImportManager;\n readonly namespace: NamespaceImportManager;\n\n constructor(collator: Intl.Collator) {\n this.default = new DefaultImportManager(collator);\n this.named = new NamedImportManager(collator);\n this.namespace = new NamespaceImportManager(collator);\n this.collator = collator;\n }\n\n get size(): number {\n return this.default.size + this.named.size + this.namespace.size;\n }\n\n toCode(): readonly Statement[] {\n const records = [\n ...this.default.statementRecords(),\n ...this.named.statementRecords(),\n ...this.namespace.statementRecords(),\n ];\n records.sort(createComparator(this.collator));\n\n return records.map(([, statement]) => statement);\n }\n\n fromCode(source: ts.SourceFile): void {\n this.default.clear();\n this.named.clear();\n this.namespace.clear();\n\n const imports = source.statements.filter((statement): statement is ImportDeclaration =>\n ts.isImportDeclaration(statement),\n );\n\n for (const { importClause, moduleSpecifier } of imports) {\n if (!importClause) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const { name, namedBindings } = importClause;\n const path = (moduleSpecifier as ts.StringLiteral).text;\n\n if (namedBindings) {\n if (ts.isNamespaceImport(namedBindings)) {\n this.namespace.add(path, namedBindings.name.text, namedBindings.name);\n } else {\n for (const { isTypeOnly, name: specifier } of namedBindings.elements) {\n this.named.add(path, specifier.text, isTypeOnly, specifier);\n }\n }\n } else if (name) {\n this.default.add(path, name.text, importClause.isTypeOnly, name);\n }\n }\n }\n}\n"],"version":3}
1
+ {"mappings":"AAAA,OAAO,oBAAkF;AACzF,OAAO,oEAAqE;AAE5E,OAAO,0BAA0B,qDAA4E;AAC7G,SAAS,0CAAkE;AAE3E,OAAO,MAAM,2BAA2B,uBAA0C;CAChF,AAASA,OAAO,IAAI;CAEpB,IAAI,OAAe;AACjB,SAAO,KAAKA,KAAK;CAClB;CAED,IAAIC,MAAcC,WAAmBC,QAAkBC,UAAmC;EACxF,MAAM,SAAS,uBAAuB,YAAY,4BAA4B,UAAU,EAAE,OAAO;AAEjG,MAAI,KAAKJ,KAAK,IAAI,KAAK,EAAE;AACvB,QAAKA,KAAK,IAAI,KAAK,CAAE,IAAI,WAAW,OAAO;EAC5C,OAAM;AACL,QAAKA,KAAK,IAAI,MAAM,IAAI,IAAI,CAAC,CAAC,WAAW,MAAO,CAAC,GAAE;EACpD;AAED,SAAO,OAAO;CACf;CAED,OAAOC,MAAcC,WAAyB;EAC5C,MAAM,aAAa,KAAKF,KAAK,IAAI,KAAK;AAEtC,MAAI,YAAY;AACd,cAAW,OAAO,UAAU;AAE5B,OAAI,WAAW,SAAS,GAAG;AACzB,SAAKA,KAAK,OAAO,KAAK;GACvB;EACF;CACF;CAED,AAAS,QAAc;AACrB,OAAK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AAU,KAAK,UAAU;CACjD;CAED,SAASC,QAA6B;AACpC,OAAK,QAAQ,OAAO;AACpB,OAAK,MAAM,OAAO;AAClB,OAAK,UAAU,OAAO;EAEtB,MAAM,UAAU,OAAO,WAAW,OAAO,CAAC,cACxC,GAAG,oBAAoB,UAAU,CAClC;AAED,OAAK,MAAM,EAAE,cAAc,iBAAiB,IAAI,SAAS;AACvD,QAAK,cAAc;AAEjB;GACD;GAED,MAAM,EAAE,MAAM,eAAe,GAAG;GAChC,MAAM,OAAQ,gBAAqC;AAEnD,OAAI,eAAe;AACjB,QAAI,GAAG,kBAAkB,cAAc,EAAE;AACvC,UAAK,UAAU,IAAI,MAAM,cAAc,KAAK,MAAM,cAAc,KAAK;IACtE,OAAM;AACL,UAAK,MAAM,EAAE,YAAY,MAAM,WAAW,IAAI,cAAc,UAAU;AACpE,WAAK,MAAM,IAAI,MAAM,UAAU,MAAM,YAAY,UAAU;KAC5D;IACF;GACF,WAAU,MAAM;AACf,SAAK,QAAQ,IAAI,MAAM,KAAK,MAAM,aAAa,YAAY,KAAK;GACjE;EACF;CACF;AACF","names":["#map","path: string","specifier: string","isType?: boolean","uniqueId?: Identifier","name: string","collator: Intl.Collator","source: ts.SourceFile"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/dependencies/ImportManager.ts"],"sourcesContent":["import ts, { type Identifier, type ImportDeclaration, type Statement } from 'typescript';\nimport createFullyUniqueIdentifier from '../createFullyUniqueIdentifier.js';\nimport type CodeConvertable from './CodeConvertable.js';\nimport StatementRecordManager, { createComparator, type StatementRecord } from './StatementRecordManager.js';\nimport { createDependencyRecord, type DependencyRecord } from './utils.js';\n\nexport class NamedImportManager extends StatementRecordManager<ImportDeclaration> {\n readonly #map = new Map<string, Map<string, DependencyRecord>>();\n\n get size(): number {\n return this.#map.size;\n }\n\n add(path: string, specifier: string, isType?: boolean, uniqueId?: Identifier): Identifier {\n const record = createDependencyRecord(uniqueId ?? createFullyUniqueIdentifier(specifier), isType);\n\n if (this.#map.has(path)) {\n this.#map.get(path)!.set(specifier, record);\n } else {\n this.#map.set(path, new Map([[specifier, record]]));\n }\n\n return record.id;\n }\n\n remove(path: string, specifier: string): void {\n const specifiers = this.#map.get(path);\n\n if (specifiers) {\n specifiers.delete(specifier);\n\n if (specifiers.size === 0) {\n this.#map.delete(path);\n }\n }\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n getIdentifier(path: string, specifier: string): Identifier | undefined {\n return this.#map.get(path)?.get(specifier)?.id;\n }\n\n iter(): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]> {\n return this[Symbol.iterator]();\n }\n\n isType(path: string, specifier: string): boolean | undefined {\n return this.#map.get(path)?.get(specifier)?.isType;\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n *specifiers(): IterableIterator<readonly [path: string, specifier: string]> {\n for (const [path, specifiers] of this.#map) {\n for (const specifier of specifiers.keys()) {\n yield [path, specifier];\n }\n }\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>> {\n for (const [path, specifiers] of this.#map) {\n const names = [...specifiers.keys()];\n // eslint-disable-next-line @typescript-eslint/unbound-method\n names.sort(this.collator.compare);\n\n const isTypeOnly = names.every((name) => specifiers.get(name)!.isType);\n\n yield [\n path,\n ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(\n isTypeOnly,\n undefined,\n ts.factory.createNamedImports(\n names.map((name) => {\n const { id, isType } = specifiers.get(name)!;\n return ts.factory.createImportSpecifier(\n isTypeOnly ? false : isType,\n ts.factory.createIdentifier(name),\n id,\n );\n }),\n ),\n ),\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n\n *[Symbol.iterator](): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]> {\n for (const [path, specifiers] of this.#map) {\n for (const [specifier, { id, isType }] of specifiers) {\n yield [path, specifier, id, isType];\n }\n }\n }\n}\n\nexport class NamespaceImportManager extends StatementRecordManager<ImportDeclaration> {\n readonly #map = new Map<string, Identifier>();\n\n get size(): number {\n return this.#map.size;\n }\n\n add(path: string, name: string, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(path, id);\n return id;\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n getIdentifier(path: string): Identifier | undefined {\n return this.#map.get(path);\n }\n\n iter(): IterableIterator<readonly [path: string, id: Identifier]> {\n return this[Symbol.iterator]();\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>> {\n for (const [path, id] of this.#map) {\n yield [\n path,\n ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(false, undefined, ts.factory.createNamespaceImport(id)),\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n\n remove(path: string): void {\n this.#map.delete(path);\n }\n\n *[Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier]> {\n for (const [path, id] of this.#map) {\n yield [path, id];\n }\n }\n}\n\nexport class DefaultImportManager extends StatementRecordManager<ImportDeclaration> {\n readonly #map = new Map<string, DependencyRecord>();\n\n get size(): number {\n return this.#map.size;\n }\n\n add(path: string, name: string, isType?: boolean, uniqueId?: Identifier): Identifier {\n const id = uniqueId ?? createFullyUniqueIdentifier(name);\n this.#map.set(path, createDependencyRecord(id, isType));\n return id;\n }\n\n getIdentifier(path: string): Identifier | undefined {\n return this.#map.get(path)?.id;\n }\n\n remove(path: string): void {\n if (this.#map.has(path)) {\n this.#map.delete(path);\n }\n }\n\n override clear(): void {\n this.#map.clear();\n }\n\n iter(): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]> {\n return this[Symbol.iterator]();\n }\n\n isType(path: string): boolean | undefined {\n return this.#map.get(path)?.isType;\n }\n\n paths(): IterableIterator<string> {\n return this.#map.keys();\n }\n\n override *statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>> {\n for (const [path, { id, isType }] of this.#map) {\n yield [\n path,\n ts.factory.createImportDeclaration(\n undefined,\n ts.factory.createImportClause(isType, id, undefined),\n ts.factory.createStringLiteral(path),\n ),\n ];\n }\n }\n\n *[Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]> {\n for (const [path, { id, isType }] of this.#map) {\n yield [path, id, isType];\n }\n }\n}\n\nexport default class ImportManager implements CodeConvertable<readonly Statement[]> {\n readonly collator: Intl.Collator;\n readonly default: DefaultImportManager;\n readonly named: NamedImportManager;\n readonly namespace: NamespaceImportManager;\n\n constructor(collator: Intl.Collator) {\n this.default = new DefaultImportManager(collator);\n this.named = new NamedImportManager(collator);\n this.namespace = new NamespaceImportManager(collator);\n this.collator = collator;\n }\n\n get size(): number {\n return this.default.size + this.named.size + this.namespace.size;\n }\n\n toCode(): readonly Statement[] {\n const records = [\n ...this.default.statementRecords(),\n ...this.named.statementRecords(),\n ...this.namespace.statementRecords(),\n ];\n records.sort(createComparator(this.collator));\n\n return records.map(([, statement]) => statement);\n }\n\n fromCode(source: ts.SourceFile): void {\n this.default.clear();\n this.named.clear();\n this.namespace.clear();\n\n const imports = source.statements.filter((statement): statement is ImportDeclaration =>\n ts.isImportDeclaration(statement),\n );\n\n for (const { importClause, moduleSpecifier } of imports) {\n if (!importClause) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n const { name, namedBindings } = importClause;\n const path = (moduleSpecifier as ts.StringLiteral).text;\n\n if (namedBindings) {\n if (ts.isNamespaceImport(namedBindings)) {\n this.namespace.add(path, namedBindings.name.text, namedBindings.name);\n } else {\n for (const { isTypeOnly, name: specifier } of namedBindings.elements) {\n this.named.add(path, specifier.text, isTypeOnly, specifier);\n }\n }\n } else if (name) {\n this.default.add(path, name.text, importClause.isTypeOnly, name);\n }\n }\n }\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAAA,SAAS,UAAU,SAAS,OAAO,UAAU,sBAAuB;AACpE,SAAS,+BAAgC;AASzC,eAAe,MAAM,YAAY;CAC/B,AAASA;CAET,YAAYC,SAA8B;EACxC,IAAIC;AAEJ,MAAI,SAAS,WAAW;AACtB,eAAY,QAAQ,UAAU,WAAW,IAAI,GAAG,QAAQ,aAAa,GAAG,QAAQ,UAAU;EAC3F;AAED,OAAKF,WAAW;GACd,GAAG;GACH;GACA,YAAY,SAAS,cAAc;EACpC;CACF;CAED,IAAI,YAAgC;AAClC,SAAO,KAAKA,SAAS;CACtB;CAED,qBAAqBG,MAAc,SAAS,OAAe;EACzD,MAAM,EAAE,WAAW,GAAG,KAAKH;AAE3B,MAAI,aAAa,QAAQ;AACvB,WAAQ,EAAE,KAAK,GAAG,UAAU;EAC7B;AAED,SAAO;CACR;CAED,mBACEI,MACAC,eACAC,aAA2B,KAAKN,SAAS,YACjC;EACR,MAAM,EAAE,WAAW,GAAG,KAAKA;EAC3B,MAAM,QAAQ,gBAAgB,MAAM,cAAc,KAAK,GAAG;EAC1D,IAAI,SAAS;AAEb,MAAI,cAAc,MAAM,SAAS,UAAU,EAAE;AAC3C,aAAU,EAAE,QAAQ,OAAO,CAAC,GAAG,SAAS,QAAQ,cAAc,CAAC,EAAE,UAAU;EAC5E;AAED,WAAS,SAAS,sBAAsB,MAAM,cAAc,WAAW,GAAG,YAAY,OAAO,CAAC,WAC5F,KACA,MAAM,IACP;AACD,SAAO,OAAO,WAAW,IAAI,GAAG,UAAU,IAAI,OAAO;CACtD;CAED,wBAAwBG,MAAcI,OAA2B,KAAKP,SAAS,WAAmB;AAChG,SAAO,QAAQ,EAAE,KAAK,GAAG,KAAK,IAAI;CACnC;AACF","names":["#options","options?: PathManagerOptions","extension: string | undefined","path: string","path: URL | string","fileExtension?: string","relativeTo: string | URL","root: string | undefined"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/dependencies/PathManager.ts"],"sourcesContent":["import { basename, dirname, posix, relative, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { SetRequired } from 'type-fest';\n\nexport type PathManagerOptions = Readonly<{\n aliasRoot?: string;\n extension?: string;\n relativeTo?: URL | string;\n}>;\n\nexport default class PathManager {\n readonly #options: SetRequired<PathManagerOptions, 'relativeTo'>;\n\n constructor(options?: PathManagerOptions) {\n let extension: string | undefined;\n\n if (options?.extension) {\n extension = options.extension.startsWith('.') ? options.extension : `.${options.extension}`;\n }\n\n this.#options = {\n ...options,\n extension,\n relativeTo: options?.relativeTo ?? '.',\n };\n }\n\n get aliasRoot(): string | undefined {\n return this.#options.aliasRoot;\n }\n\n createBareModulePath(path: string, isFile = false): string {\n const { extension } = this.#options;\n\n if (extension && isFile) {\n return `${path}.${extension}`;\n }\n\n return path;\n }\n\n createRelativePath(\n path: URL | string,\n fileExtension?: string,\n relativeTo: string | URL = this.#options.relativeTo,\n ): string {\n const { extension } = this.#options;\n const _path = path instanceof URL ? fileURLToPath(path) : path;\n let result = _path;\n\n if (extension && !_path.endsWith(extension)) {\n result = `${dirname(result)}/${basename(result, fileExtension)}${extension}`;\n }\n\n result = relative(relativeTo instanceof URL ? fileURLToPath(relativeTo) : relativeTo, result).replaceAll(\n sep,\n posix.sep,\n );\n return result.startsWith('.') ? result : `./${result}`;\n }\n\n createTSAliasModulePath(path: string, root: string | undefined = this.#options.aliasRoot): string {\n return root ? `${root}/${path}` : path;\n }\n}\n"],"version":3}
1
+ {"mappings":"AAAA,SAAS,UAAU,SAAS,OAAO,UAAU,sBAAuB;AACpE,SAAS,+BAAgC;AASzC,eAAe,MAAM,YAAY;CAC/B,AAASA;CAET,YAAYC,SAA8B;EACxC,IAAIC;AAEJ,MAAI,SAAS,WAAW;AACtB,eAAY,QAAQ,UAAU,WAAW,IAAI,GAAG,QAAQ,aAAa,GAAG,QAAQ,UAAU;EAC3F;AAED,OAAKF,WAAW;GACd,GAAG;GACH;GACA,YAAY,SAAS,cAAc;EACpC;CACF;CAED,IAAI,YAAgC;AAClC,SAAO,KAAKA,SAAS;CACtB;CAED,qBAAqBG,MAAc,SAAS,OAAe;EACzD,MAAM,EAAE,WAAW,GAAG,KAAKH;AAE3B,MAAI,aAAa,QAAQ;AACvB,WAAQ,EAAE,KAAK,GAAG,UAAU;EAC7B;AAED,SAAO;CACR;CAED,mBACEI,MACAC,eACAC,aAA2B,KAAKN,SAAS,YACjC;EACR,MAAM,EAAE,WAAW,GAAG,KAAKA;EAC3B,MAAM,QAAQ,gBAAgB,MAAM,cAAc,KAAK,GAAG;EAC1D,IAAI,SAAS;AAEb,MAAI,cAAc,MAAM,SAAS,UAAU,EAAE;AAC3C,aAAU,EAAE,QAAQ,OAAO,CAAC,GAAG,SAAS,QAAQ,cAAc,CAAC,EAAE,UAAU;EAC5E;AAED,WAAS,SAAS,sBAAsB,MAAM,cAAc,WAAW,GAAG,YAAY,OAAO,CAAC,WAC5F,KACA,MAAM,IACP;AACD,SAAO,OAAO,WAAW,IAAI,GAAG,UAAU,IAAI,OAAO;CACtD;CAED,wBAAwBG,MAAcI,OAA2B,KAAKP,SAAS,WAAmB;AAChG,SAAO,QAAQ,EAAE,KAAK,GAAG,KAAK,IAAI;CACnC;AACF","names":["#options","options?: PathManagerOptions","extension: string | undefined","path: string","path: URL | string","fileExtension?: string","relativeTo: string | URL","root: string | undefined"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/dependencies/PathManager.ts"],"sourcesContent":["import { basename, dirname, posix, relative, sep } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { SetRequired } from 'type-fest';\n\nexport type PathManagerOptions = Readonly<{\n aliasRoot?: string;\n extension?: string;\n relativeTo?: URL | string;\n}>;\n\nexport default class PathManager {\n readonly #options: SetRequired<PathManagerOptions, 'relativeTo'>;\n\n constructor(options?: PathManagerOptions) {\n let extension: string | undefined;\n\n if (options?.extension) {\n extension = options.extension.startsWith('.') ? options.extension : `.${options.extension}`;\n }\n\n this.#options = {\n ...options,\n extension,\n relativeTo: options?.relativeTo ?? '.',\n };\n }\n\n get aliasRoot(): string | undefined {\n return this.#options.aliasRoot;\n }\n\n createBareModulePath(path: string, isFile = false): string {\n const { extension } = this.#options;\n\n if (extension && isFile) {\n return `${path}.${extension}`;\n }\n\n return path;\n }\n\n createRelativePath(\n path: URL | string,\n fileExtension?: string,\n relativeTo: string | URL = this.#options.relativeTo,\n ): string {\n const { extension } = this.#options;\n const _path = path instanceof URL ? fileURLToPath(path) : path;\n let result = _path;\n\n if (extension && !_path.endsWith(extension)) {\n result = `${dirname(result)}/${basename(result, fileExtension)}${extension}`;\n }\n\n result = relative(relativeTo instanceof URL ? fileURLToPath(relativeTo) : relativeTo, result).replaceAll(\n sep,\n posix.sep,\n );\n return result.startsWith('.') ? result : `./${result}`;\n }\n\n createTSAliasModulePath(path: string, root: string | undefined = this.#options.aliasRoot): string {\n return root ? `${root}/${path}` : path;\n }\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAKA,OAAO,SAAS,iBACdA,UACsE;AACtE,QAAO,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,KAAK;AAC3B,MAAI,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW,IAAI,EAAE;AACnD,UAAO;EACR;AAED,OAAK,MAAM,WAAW,IAAI,IAAI,MAAM,WAAW,IAAI,EAAE;AACnD,WAAQ;EACT;AAED,SAAO,SAAS,QAAQ,OAAO,MAAM;CACtC;AACF;AAED,eAAe,MAAe,uBAAqF;CACjH,AAAS;CAET,YAAYA,UAAyB;AACnC,OAAK,WAAW;CACjB;CAID,SAAuB;EACrB,MAAM,UAAU,CAAC,GAAG,KAAK,kBAAkB,AAAC;AAC5C,UAAQ,KAAK,iBAAiB,KAAK,SAAS,CAAC;AAE7C,SAAO,QAAQ,IAAI,CAAC,GAAG,UAAU,KAAK,UAAU;CACjD;AAGF","names":["collator: Intl.Collator"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/dependencies/StatementRecordManager.ts"],"sourcesContent":["import type { Statement } from 'typescript';\nimport type CodeConvertable from './CodeConvertable.js';\n\nexport type StatementRecord<T extends Statement> = readonly [path: string, declaration: T];\n\nexport function createComparator<T extends Statement>(\n collator: Intl.Collator,\n): (recordA: StatementRecord<T>, recordB: StatementRecord<T>) => number {\n return ([pathA], [pathB]) => {\n if (pathA.startsWith('.') && !pathB.startsWith('.')) {\n return 1;\n }\n\n if (!pathA.startsWith('.') && pathB.startsWith('.')) {\n return -1;\n }\n\n return collator.compare(pathA, pathB);\n };\n}\n\nexport default abstract class StatementRecordManager<T extends Statement> implements CodeConvertable<readonly T[]> {\n readonly collator: Intl.Collator;\n\n constructor(collator: Intl.Collator) {\n this.collator = collator;\n }\n\n abstract statementRecords(): IterableIterator<StatementRecord<T>>;\n\n toCode(): readonly T[] {\n const records = [...this.statementRecords()];\n records.sort(createComparator(this.collator));\n\n return records.map(([, statement]) => statement);\n }\n\n abstract clear(): void;\n}\n"],"version":3}
1
+ {"mappings":"AAKA,OAAO,SAAS,iBACdA,UACsE;AACtE,QAAO,CAAC,CAAC,MAAM,EAAE,CAAC,MAAM,KAAK;AAC3B,MAAI,MAAM,WAAW,IAAI,KAAK,MAAM,WAAW,IAAI,EAAE;AACnD,UAAO;EACR;AAED,OAAK,MAAM,WAAW,IAAI,IAAI,MAAM,WAAW,IAAI,EAAE;AACnD,WAAQ;EACT;AAED,SAAO,SAAS,QAAQ,OAAO,MAAM;CACtC;AACF;AAED,eAAe,MAAe,uBAAqF;CACjH,AAAS;CAET,YAAYA,UAAyB;AACnC,OAAK,WAAW;CACjB;CAID,SAAuB;EACrB,MAAM,UAAU,CAAC,GAAG,KAAK,kBAAkB,AAAC;AAC5C,UAAQ,KAAK,iBAAiB,KAAK,SAAS,CAAC;AAE7C,SAAO,QAAQ,IAAI,CAAC,GAAG,UAAU,KAAK,UAAU;CACjD;AAGF","names":["collator: Intl.Collator"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/dependencies/StatementRecordManager.ts"],"sourcesContent":["import type { Statement } from 'typescript';\nimport type CodeConvertable from './CodeConvertable.js';\n\nexport type StatementRecord<T extends Statement> = readonly [path: string, declaration: T];\n\nexport function createComparator<T extends Statement>(\n collator: Intl.Collator,\n): (recordA: StatementRecord<T>, recordB: StatementRecord<T>) => number {\n return ([pathA], [pathB]) => {\n if (pathA.startsWith('.') && !pathB.startsWith('.')) {\n return 1;\n }\n\n if (!pathA.startsWith('.') && pathB.startsWith('.')) {\n return -1;\n }\n\n return collator.compare(pathA, pathB);\n };\n}\n\nexport default abstract class StatementRecordManager<T extends Statement> implements CodeConvertable<readonly T[]> {\n readonly collator: Intl.Collator;\n\n constructor(collator: Intl.Collator) {\n this.collator = collator;\n }\n\n abstract statementRecords(): IterableIterator<StatementRecord<T>>;\n\n toCode(): readonly T[] {\n const records = [...this.statementRecords()];\n records.sort(createComparator(this.collator));\n\n return records.map(([, statement]) => statement);\n }\n\n abstract clear(): void;\n}\n"],"version":3}
@@ -1 +1 @@
1
- {"mappings":"AAOA,OAAO,SAAS,uBAAuBA,IAAgB,SAAS,OAAyB;AACvF,QAAO;EACL;EACA;CACD;AACF","names":["id: Identifier"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/dependencies/utils.ts"],"sourcesContent":["import type { Identifier } from 'typescript';\n\nexport type DependencyRecord = Readonly<{\n id: Identifier;\n isType: boolean;\n}>;\n\nexport function createDependencyRecord(id: Identifier, isType = false): DependencyRecord {\n return {\n id,\n isType,\n };\n}\n"],"version":3}
1
+ {"mappings":"AAOA,OAAO,SAAS,uBAAuBA,IAAgB,SAAS,OAAyB;AACvF,QAAO;EACL;EACA;CACD;AACF","names":["id: Identifier"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/dependencies/utils.ts"],"sourcesContent":["import type { Identifier } from 'typescript';\n\nexport type DependencyRecord = Readonly<{\n id: Identifier;\n isType: boolean;\n}>;\n\nexport function createDependencyRecord(id: Identifier, isType = false): DependencyRecord {\n return {\n id,\n isType,\n };\n}\n"],"version":3}
package/memoize.js.map CHANGED
@@ -1 +1 @@
1
- {"mappings":"AAAA,eAAe,SAAS,QAAWA,MAAwB;CACzD,IAAIC;CACJ,IAAI,YAAY;AAEhB,QAAO,MAAM;AACX,OAAK,WAAW;AACd,YAAS,MAAM;AACf,eAAY;EACb;AACD,SAAO;CACR;AACF","names":["func: () => T","result: T | undefined"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/memoize.ts"],"sourcesContent":["export default function memoize<T>(func: () => T): () => T {\n let result: T | undefined;\n let hasResult = false;\n\n return () => {\n if (!hasResult) {\n result = func();\n hasResult = true;\n }\n return result!;\n };\n}\n"],"version":3}
1
+ {"mappings":"AAAA,eAAe,SAAS,QAAWA,MAAwB;CACzD,IAAIC;CACJ,IAAI,YAAY;AAEhB,QAAO,MAAM;AACX,OAAK,WAAW;AACd,YAAS,MAAM;AACf,eAAY;EACb;AACD,SAAO;CACR;AACF","names":["func: () => T","result: T | undefined"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/memoize.ts"],"sourcesContent":["export default function memoize<T>(func: () => T): () => T {\n let result: T | undefined;\n let hasResult = false;\n\n return () => {\n if (!hasResult) {\n result = func();\n hasResult = true;\n }\n return result!;\n };\n}\n"],"version":3}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vaadin/hilla-generator-utils",
3
- "version": "25.0.0-alpha9",
3
+ "version": "25.0.0-beta2",
4
4
  "description": "A set of utils for developing Hilla generator plugins",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -58,6 +58,6 @@
58
58
  "dependencies": {
59
59
  "pino": "9.6.0",
60
60
  "pino-pretty": "10.3.1",
61
- "typescript": "5.9.2"
61
+ "typescript": "5.9.3"
62
62
  }
63
63
  }
@@ -1 +1 @@
1
- {"mappings":"AAAA,SAAS,UAAU,mCAAoC;AACvD,SAAS,+BAAgC;AAEzC,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;AAClC,MAAM,eAAe,KAAK,SAAS,KAAK,IAAI,KAAK,SAAS,WAAW;AAWrE,eAAe,SAAS,gBAAgBA,MAAuBC,OAA6B;AAC1F,OAAM;EACJ,KAAK,UAAU;EACf;;EAEA,eAAe,gBAA8BC,cAAsBC,eAAsC;GACvG,MAAM,MAAM,MAAM,KAAK,MAAM,SAAS;GACtC,MAAM,cAAc,IAAI,KAAK,aAAa,aAAa,GAAG;GAC1D,MAAM,eAAe,cAAc,YAAY;AAE/C,OAAI,cAAc;AAChB,UAAM,UAAU,cAAc,KAAK,OAAO;GAC3C,OAAM;IACL,IAAI;AACJ,QAAI;AACF,gBAAW,MAAM,SAAS,cAAc,OAAO;IAChD,QAAO;AACN,WAAM,IAAI,OACP,+BAA+B,YAAY,UAAU,CAAC;IAE1D;AAED,SAAK,OAAO,MAAM,KAAK,SAAS;GACjC;EACF;CACF;AACF","names":["chai: Chai.ChaiStatic","utils: Chai.ChaiUtils","snapshotName: string","importMetaUrl: string"],"sources":["/opt/agent/work/1af72d8adc613024/hilla/packages/ts/generator-utils/src/testing/snapshotMatcher.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { fileURLToPath } from 'node:url';\n\nconst argv = process.argv.slice(2);\nconst shouldUpdate = argv.includes('-u') || argv.includes('--update');\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace Chai {\n interface Assertion {\n toMatchSnapshot(snapshotName: string, importMetaUrl: string): Promise<void>;\n }\n }\n}\n\nexport default function snapshotMatcher(chai: Chai.ChaiStatic, utils: Chai.ChaiUtils): void {\n utils.addMethod(\n chai.Assertion.prototype,\n 'toMatchSnapshot',\n // eslint-disable-next-line prefer-arrow-callback\n async function toMatchSnapshot(this: object, snapshotName: string, importMetaUrl: string): Promise<void> {\n const obj = utils.flag(this, 'object');\n const snapshotURL = new URL(`./fixtures/${snapshotName}`, importMetaUrl);\n const snapshotPath = fileURLToPath(snapshotURL);\n\n if (shouldUpdate) {\n await writeFile(snapshotPath, obj, 'utf8');\n } else {\n let snapshot;\n try {\n snapshot = await readFile(snapshotPath, 'utf8');\n } catch {\n throw new Error(\n `Snapshot does not exist yet: ${snapshotURL.toString()}.\\nConsider running tests with --update flag.`,\n );\n }\n\n chai.assert.equal(obj, snapshot);\n }\n },\n );\n}\n"],"version":3}
1
+ {"mappings":"AAAA,SAAS,UAAU,mCAAoC;AACvD,SAAS,+BAAgC;AAEzC,MAAM,OAAO,QAAQ,KAAK,MAAM,EAAE;AAClC,MAAM,eAAe,KAAK,SAAS,KAAK,IAAI,KAAK,SAAS,WAAW;AAWrE,eAAe,SAAS,gBAAgBA,MAAuBC,OAA6B;AAC1F,OAAM;EACJ,KAAK,UAAU;EACf;;EAEA,eAAe,gBAA8BC,cAAsBC,eAAsC;GACvG,MAAM,MAAM,MAAM,KAAK,MAAM,SAAS;GACtC,MAAM,cAAc,IAAI,KAAK,aAAa,aAAa,GAAG;GAC1D,MAAM,eAAe,cAAc,YAAY;AAE/C,OAAI,cAAc;AAChB,UAAM,UAAU,cAAc,KAAK,OAAO;GAC3C,OAAM;IACL,IAAI;AACJ,QAAI;AACF,gBAAW,MAAM,SAAS,cAAc,OAAO;IAChD,QAAO;AACN,WAAM,IAAI,OACP,+BAA+B,YAAY,UAAU,CAAC;IAE1D;AAED,SAAK,OAAO,MAAM,KAAK,SAAS;GACjC;EACF;CACF;AACF","names":["chai: Chai.ChaiStatic","utils: Chai.ChaiUtils","snapshotName: string","importMetaUrl: string"],"sources":["/opt/agent/work/649c11185a3798db/packages/ts/generator-utils/src/testing/snapshotMatcher.ts"],"sourcesContent":["import { readFile, writeFile } from 'node:fs/promises';\nimport { fileURLToPath } from 'node:url';\n\nconst argv = process.argv.slice(2);\nconst shouldUpdate = argv.includes('-u') || argv.includes('--update');\n\ndeclare global {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n export namespace Chai {\n interface Assertion {\n toMatchSnapshot(snapshotName: string, importMetaUrl: string): Promise<void>;\n }\n }\n}\n\nexport default function snapshotMatcher(chai: Chai.ChaiStatic, utils: Chai.ChaiUtils): void {\n utils.addMethod(\n chai.Assertion.prototype,\n 'toMatchSnapshot',\n // eslint-disable-next-line prefer-arrow-callback\n async function toMatchSnapshot(this: object, snapshotName: string, importMetaUrl: string): Promise<void> {\n const obj = utils.flag(this, 'object');\n const snapshotURL = new URL(`./fixtures/${snapshotName}`, importMetaUrl);\n const snapshotPath = fileURLToPath(snapshotURL);\n\n if (shouldUpdate) {\n await writeFile(snapshotPath, obj, 'utf8');\n } else {\n let snapshot;\n try {\n snapshot = await readFile(snapshotPath, 'utf8');\n } catch {\n throw new Error(\n `Snapshot does not exist yet: ${snapshotURL.toString()}.\\nConsider running tests with --update flag.`,\n );\n }\n\n chai.assert.equal(obj, snapshot);\n }\n },\n );\n}\n"],"version":3}