@vaadin/hilla-generator-utils 24.7.0-alpha8 → 24.7.0-beta1

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 (54) hide show
  1. package/LoggerFactory.d.ts +7 -8
  2. package/LoggerFactory.js +24 -32
  3. package/LoggerFactory.js.map +1 -7
  4. package/PluginError.d.ts +1 -2
  5. package/PluginError.js +5 -8
  6. package/PluginError.js.map +1 -7
  7. package/ast.d.ts +1 -2
  8. package/ast.js +30 -39
  9. package/ast.js.map +1 -7
  10. package/createFullyUniqueIdentifier.d.ts +1 -2
  11. package/createFullyUniqueIdentifier.js +8 -11
  12. package/createFullyUniqueIdentifier.js.map +1 -7
  13. package/createSourceFile.d.ts +1 -2
  14. package/createSourceFile.js +5 -8
  15. package/createSourceFile.js.map +1 -7
  16. package/dependencies/CodeConvertable.d.ts +2 -2
  17. package/dependencies/DependencyManager.d.ts +7 -8
  18. package/dependencies/DependencyManager.js +10 -13
  19. package/dependencies/DependencyManager.js.map +1 -7
  20. package/dependencies/ExportManager.d.ts +33 -34
  21. package/dependencies/ExportManager.js +115 -136
  22. package/dependencies/ExportManager.js.map +1 -7
  23. package/dependencies/ImportManager.d.ts +45 -46
  24. package/dependencies/ImportManager.js +202 -232
  25. package/dependencies/ImportManager.js.map +1 -7
  26. package/dependencies/PathManager.d.ts +9 -10
  27. package/dependencies/PathManager.js +37 -43
  28. package/dependencies/PathManager.js.map +1 -7
  29. package/dependencies/StatementRecordManager.d.ts +9 -10
  30. package/dependencies/StatementRecordManager.js +22 -25
  31. package/dependencies/StatementRecordManager.js.map +1 -7
  32. package/dependencies/utils.d.ts +3 -4
  33. package/dependencies/utils.js +6 -9
  34. package/dependencies/utils.js.map +1 -7
  35. package/memoize.d.ts +0 -1
  36. package/memoize.js +11 -14
  37. package/memoize.js.map +1 -7
  38. package/package.json +7 -26
  39. package/testing/snapshotMatcher.d.ts +5 -6
  40. package/testing/snapshotMatcher.js +23 -29
  41. package/testing/snapshotMatcher.js.map +1 -7
  42. package/LoggerFactory.d.ts.map +0 -1
  43. package/PluginError.d.ts.map +0 -1
  44. package/ast.d.ts.map +0 -1
  45. package/createFullyUniqueIdentifier.d.ts.map +0 -1
  46. package/createSourceFile.d.ts.map +0 -1
  47. package/dependencies/DependencyManager.d.ts.map +0 -1
  48. package/dependencies/ExportManager.d.ts.map +0 -1
  49. package/dependencies/ImportManager.d.ts.map +0 -1
  50. package/dependencies/PathManager.d.ts.map +0 -1
  51. package/dependencies/StatementRecordManager.d.ts.map +0 -1
  52. package/dependencies/utils.d.ts.map +0 -1
  53. package/memoize.d.ts.map +0 -1
  54. package/testing/snapshotMatcher.d.ts.map +0 -1
@@ -1,142 +1,121 @@
1
- import ts, {} from "typescript";
1
+ import ts from "typescript";
2
2
  import createFullyUniqueIdentifier from "../createFullyUniqueIdentifier.js";
3
- import StatementRecordManager, {} from "./StatementRecordManager.js";
3
+ import StatementRecordManager from "./StatementRecordManager.js";
4
4
  import { createDependencyRecord } from "./utils.js";
5
- class NamedExportManager {
6
- #collator;
7
- #map = /* @__PURE__ */ new Map();
8
- get size() {
9
- return this.#map.size;
10
- }
11
- constructor(collator) {
12
- this.#collator = collator;
13
- }
14
- add(name, isType, uniqueId) {
15
- const id = uniqueId ?? createFullyUniqueIdentifier(name);
16
- this.#map.set(name, createDependencyRecord(id, isType));
17
- return id;
18
- }
19
- getIdentifier(name) {
20
- return this.#map.get(name)?.id;
21
- }
22
- *identifiers() {
23
- for (const { id, isType } of this.#map.values()) {
24
- yield [id, isType];
25
- }
26
- }
27
- isType(name) {
28
- return this.#map.get(name)?.isType;
29
- }
30
- names() {
31
- return this.#map.keys();
32
- }
33
- toCode() {
34
- if (this.#map.size === 0) {
35
- return void 0;
36
- }
37
- const names = [...this.#map.keys()];
38
- names.sort(this.#collator.compare);
39
- return ts.factory.createExportDeclaration(
40
- void 0,
41
- false,
42
- ts.factory.createNamedExports(
43
- names.map((name) => {
44
- const { id, isType } = this.#map.get(name);
45
- return ts.factory.createExportSpecifier(isType, id, ts.factory.createIdentifier(name));
46
- })
47
- ),
48
- void 0
49
- );
50
- }
5
+ export class NamedExportManager {
6
+ #collator;
7
+ #map = new Map();
8
+ get size() {
9
+ return this.#map.size;
10
+ }
11
+ constructor(collator) {
12
+ this.#collator = collator;
13
+ }
14
+ add(name, isType, uniqueId) {
15
+ const id = uniqueId ?? createFullyUniqueIdentifier(name);
16
+ this.#map.set(name, createDependencyRecord(id, isType));
17
+ return id;
18
+ }
19
+ getIdentifier(name) {
20
+ return this.#map.get(name)?.id;
21
+ }
22
+ *identifiers() {
23
+ for (const { id, isType } of this.#map.values()) {
24
+ yield [id, isType];
25
+ }
26
+ }
27
+ isType(name) {
28
+ return this.#map.get(name)?.isType;
29
+ }
30
+ names() {
31
+ return this.#map.keys();
32
+ }
33
+ toCode() {
34
+ if (this.#map.size === 0) {
35
+ return undefined;
36
+ }
37
+ const names = [...this.#map.keys()];
38
+ names.sort(this.#collator.compare);
39
+ return ts.factory.createExportDeclaration(undefined, false, ts.factory.createNamedExports(names.map((name) => {
40
+ const { id, isType } = this.#map.get(name);
41
+ return ts.factory.createExportSpecifier(isType, id, ts.factory.createIdentifier(name));
42
+ })), undefined);
43
+ }
51
44
  }
52
- class NamespaceExportManager extends StatementRecordManager {
53
- #map = /* @__PURE__ */ new Map();
54
- get size() {
55
- return this.#map.size;
56
- }
57
- addCombined(path, name, uniqueId) {
58
- const id = uniqueId ?? createFullyUniqueIdentifier(name);
59
- this.#map.set(path, id);
60
- return id;
61
- }
62
- addSpread(path) {
63
- this.#map.set(path, null);
64
- }
65
- clear() {
66
- this.#map.clear();
67
- }
68
- getIdentifier(path) {
69
- return this.#map.get(path);
70
- }
71
- identifiers() {
72
- return this.#map.values();
73
- }
74
- isCombined(path) {
75
- return this.#map.has(path) ? this.#map.get(path) !== null : void 0;
76
- }
77
- isSpread(path) {
78
- return this.#map.has(path) ? this.#map.get(path) === null : void 0;
79
- }
80
- paths() {
81
- return this.#map.keys();
82
- }
83
- *statementRecords() {
84
- for (const [path, id] of this.#map) {
85
- yield [
86
- path,
87
- ts.factory.createExportDeclaration(
88
- void 0,
89
- false,
90
- id !== null ? ts.factory.createNamespaceExport(id) : void 0,
91
- ts.factory.createStringLiteral(path)
92
- )
93
- ];
94
- }
95
- }
45
+ export class NamespaceExportManager extends StatementRecordManager {
46
+ #map = new Map();
47
+ get size() {
48
+ return this.#map.size;
49
+ }
50
+ addCombined(path, name, uniqueId) {
51
+ const id = uniqueId ?? createFullyUniqueIdentifier(name);
52
+ this.#map.set(path, id);
53
+ return id;
54
+ }
55
+ addSpread(path) {
56
+ this.#map.set(path, null);
57
+ }
58
+ clear() {
59
+ this.#map.clear();
60
+ }
61
+ getIdentifier(path) {
62
+ return this.#map.get(path);
63
+ }
64
+ identifiers() {
65
+ return this.#map.values();
66
+ }
67
+ isCombined(path) {
68
+ return this.#map.has(path) ? this.#map.get(path) !== null : undefined;
69
+ }
70
+ isSpread(path) {
71
+ return this.#map.has(path) ? this.#map.get(path) === null : undefined;
72
+ }
73
+ paths() {
74
+ return this.#map.keys();
75
+ }
76
+ *statementRecords() {
77
+ for (const [path, id] of this.#map) {
78
+ yield [path, ts.factory.createExportDeclaration(undefined, false, id !== null ? ts.factory.createNamespaceExport(id) : undefined, ts.factory.createStringLiteral(path))];
79
+ }
80
+ }
96
81
  }
97
- class DefaultExportManager {
98
- #id;
99
- get isEmpty() {
100
- return !this.#id;
101
- }
102
- set(id) {
103
- this.#id = typeof id === "string" ? ts.factory.createIdentifier(id) : id;
104
- return this.#id;
105
- }
106
- toCode() {
107
- return this.#id ? ts.factory.createExportAssignment(void 0, void 0, this.#id) : void 0;
108
- }
82
+ export class DefaultExportManager {
83
+ #id;
84
+ get isEmpty() {
85
+ return !this.#id;
86
+ }
87
+ set(id) {
88
+ this.#id = typeof id === "string" ? ts.factory.createIdentifier(id) : id;
89
+ return this.#id;
90
+ }
91
+ toCode() {
92
+ return this.#id ? ts.factory.createExportAssignment(undefined, undefined, this.#id) : undefined;
93
+ }
109
94
  }
110
- class ExportManager {
111
- default = new DefaultExportManager();
112
- named;
113
- namespace;
114
- get size() {
115
- return (this.default.isEmpty ? 0 : 1) + this.named.size + this.namespace.size;
116
- }
117
- constructor(collator) {
118
- this.named = new NamedExportManager(collator);
119
- this.namespace = new NamespaceExportManager(collator);
120
- }
121
- toCode() {
122
- const defaultStatement = this.default.toCode();
123
- const namedStatement = this.named.toCode();
124
- const namespaceStatements = this.namespace.toCode();
125
- const result = [];
126
- if (namedStatement) {
127
- result.push(namedStatement);
128
- }
129
- result.push(...namespaceStatements);
130
- if (defaultStatement) {
131
- result.push(defaultStatement);
132
- }
133
- return result;
134
- }
95
+ export default class ExportManager {
96
+ default = new DefaultExportManager();
97
+ named;
98
+ namespace;
99
+ get size() {
100
+ return (this.default.isEmpty ? 0 : 1) + this.named.size + this.namespace.size;
101
+ }
102
+ constructor(collator) {
103
+ this.named = new NamedExportManager(collator);
104
+ this.namespace = new NamespaceExportManager(collator);
105
+ }
106
+ toCode() {
107
+ const defaultStatement = this.default.toCode();
108
+ const namedStatement = this.named.toCode();
109
+ const namespaceStatements = this.namespace.toCode();
110
+ const result = [];
111
+ if (namedStatement) {
112
+ result.push(namedStatement);
113
+ }
114
+ result.push(...namespaceStatements);
115
+ if (defaultStatement) {
116
+ result.push(defaultStatement);
117
+ }
118
+ return result;
119
+ }
135
120
  }
136
- export {
137
- DefaultExportManager,
138
- NamedExportManager,
139
- NamespaceExportManager,
140
- ExportManager as default
141
- };
142
- //# sourceMappingURL=ExportManager.js.map
121
+ //# sourceMappingURL=./ExportManager.js.map
@@ -1,7 +1 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/dependencies/ExportManager.ts"],
4
- "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 = 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"],
5
- "mappings": "AAAA,OAAO,YAA4F;AACnG,OAAO,iCAAiC;AAExC,OAAO,gCAAsD;AAC7D,SAAS,8BAAqD;AAEvD,MAAM,mBAA6E;AAAA,EAC/E;AAAA,EACA,OAAO,oBAAI,IAA8B;AAAA,EAEl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,KAAK,iBAAiB;EAC9B;AAED,SAAO;CACR;AACF","names":["#collator","#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,54 +1,53 @@
1
- import ts, { type Identifier, type ImportDeclaration, type Statement } from 'typescript';
2
- import type CodeConvertable from './CodeConvertable.js';
3
- import StatementRecordManager, { type StatementRecord } from './StatementRecordManager.js';
1
+ import ts, { type Identifier, type ImportDeclaration, type Statement } from "typescript";
2
+ import type CodeConvertable from "./CodeConvertable.js";
3
+ import StatementRecordManager, { type StatementRecord } from "./StatementRecordManager.js";
4
4
  export declare class NamedImportManager extends StatementRecordManager<ImportDeclaration> {
5
- #private;
6
- constructor(collator: Intl.Collator);
7
- get size(): number;
8
- add(path: string, specifier: string, isType?: boolean, uniqueId?: Identifier): Identifier;
9
- remove(path: string, specifier: string): void;
10
- clear(): void;
11
- getIdentifier(path: string, specifier: string): Identifier | undefined;
12
- iter(): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]>;
13
- isType(path: string, specifier: string): boolean | undefined;
14
- paths(): IterableIterator<string>;
15
- specifiers(): IterableIterator<readonly [path: string, specifier: string]>;
16
- statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>>;
17
- [Symbol.iterator](): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]>;
5
+ #private;
6
+ constructor(collator: Intl.Collator);
7
+ get size(): number;
8
+ add(path: string, specifier: string, isType?: boolean, uniqueId?: Identifier): Identifier;
9
+ remove(path: string, specifier: string): void;
10
+ clear(): void;
11
+ getIdentifier(path: string, specifier: string): Identifier | undefined;
12
+ iter(): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]>;
13
+ isType(path: string, specifier: string): boolean | undefined;
14
+ paths(): IterableIterator<string>;
15
+ specifiers(): IterableIterator<readonly [path: string, specifier: string]>;
16
+ statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>>;
17
+ [Symbol.iterator](): IterableIterator<readonly [path: string, specifier: string, id: Identifier, isType: boolean]>;
18
18
  }
19
19
  export declare class NamespaceImportManager extends StatementRecordManager<ImportDeclaration> {
20
- #private;
21
- get size(): number;
22
- add(path: string, name: string, uniqueId?: Identifier): Identifier;
23
- clear(): void;
24
- getIdentifier(path: string): Identifier | undefined;
25
- iter(): IterableIterator<readonly [path: string, id: Identifier]>;
26
- paths(): IterableIterator<string>;
27
- statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>>;
28
- remove(path: string): void;
29
- [Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier]>;
20
+ #private;
21
+ get size(): number;
22
+ add(path: string, name: string, uniqueId?: Identifier): Identifier;
23
+ clear(): void;
24
+ getIdentifier(path: string): Identifier | undefined;
25
+ iter(): IterableIterator<readonly [path: string, id: Identifier]>;
26
+ paths(): IterableIterator<string>;
27
+ statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>>;
28
+ remove(path: string): void;
29
+ [Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier]>;
30
30
  }
31
31
  export declare class DefaultImportManager extends StatementRecordManager<ImportDeclaration> {
32
- #private;
33
- get size(): number;
34
- add(path: string, name: string, isType?: boolean, uniqueId?: Identifier): Identifier;
35
- getIdentifier(path: string): Identifier | undefined;
36
- remove(path: string): void;
37
- clear(): void;
38
- iter(): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]>;
39
- isType(path: string): boolean | undefined;
40
- paths(): IterableIterator<string>;
41
- statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>>;
42
- [Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]>;
32
+ #private;
33
+ get size(): number;
34
+ add(path: string, name: string, isType?: boolean, uniqueId?: Identifier): Identifier;
35
+ getIdentifier(path: string): Identifier | undefined;
36
+ remove(path: string): void;
37
+ clear(): void;
38
+ iter(): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]>;
39
+ isType(path: string): boolean | undefined;
40
+ paths(): IterableIterator<string>;
41
+ statementRecords(): IterableIterator<StatementRecord<ImportDeclaration>>;
42
+ [Symbol.iterator](): IterableIterator<readonly [path: string, id: Identifier, isType: boolean]>;
43
43
  }
44
44
  export default class ImportManager implements CodeConvertable<readonly Statement[]> {
45
- #private;
46
- readonly default: DefaultImportManager;
47
- readonly named: NamedImportManager;
48
- readonly namespace: NamespaceImportManager;
49
- constructor(collator: Intl.Collator);
50
- get size(): number;
51
- toCode(): readonly Statement[];
52
- fromCode(source: ts.SourceFile): void;
45
+ #private;
46
+ readonly default: DefaultImportManager;
47
+ readonly named: NamedImportManager;
48
+ readonly namespace: NamespaceImportManager;
49
+ constructor(collator: Intl.Collator);
50
+ get size(): number;
51
+ toCode(): readonly Statement[];
52
+ fromCode(source: ts.SourceFile): void;
53
53
  }
54
- //# sourceMappingURL=ImportManager.d.ts.map