@vaadin/hilla-generator-utils 24.4.0-alpha1
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.
- package/.lintstagedrc.js +6 -0
- package/LICENSE +201 -0
- package/LoggerFactory.d.ts +13 -0
- package/LoggerFactory.d.ts.map +1 -0
- package/LoggerFactory.js +34 -0
- package/LoggerFactory.js.map +7 -0
- package/PluginError.d.ts +4 -0
- package/PluginError.d.ts.map +1 -0
- package/PluginError.js +9 -0
- package/PluginError.js.map +7 -0
- package/README.md +1 -0
- package/ast.d.ts +6 -0
- package/ast.d.ts.map +1 -0
- package/ast.js +29 -0
- package/ast.js.map +7 -0
- package/createFullyUniqueIdentifier.d.ts +3 -0
- package/createFullyUniqueIdentifier.d.ts.map +1 -0
- package/createFullyUniqueIdentifier.js +12 -0
- package/createFullyUniqueIdentifier.js.map +7 -0
- package/createSourceFile.d.ts +3 -0
- package/createSourceFile.d.ts.map +1 -0
- package/createSourceFile.js +9 -0
- package/createSourceFile.js.map +7 -0
- package/dependencies/CodeConvertable.d.js +1 -0
- package/dependencies/CodeConvertable.d.js.map +7 -0
- package/dependencies/CodeConvertable.d.ts +3 -0
- package/dependencies/DependencyManager.d.ts +10 -0
- package/dependencies/DependencyManager.d.ts.map +1 -0
- package/dependencies/DependencyManager.js +16 -0
- package/dependencies/DependencyManager.js.map +7 -0
- package/dependencies/ExportManager.d.ts +38 -0
- package/dependencies/ExportManager.d.ts.map +1 -0
- package/dependencies/ExportManager.js +130 -0
- package/dependencies/ExportManager.js.map +7 -0
- package/dependencies/ImportManager.d.ts +44 -0
- package/dependencies/ImportManager.d.ts.map +1 -0
- package/dependencies/ImportManager.js +195 -0
- package/dependencies/ImportManager.js.map +7 -0
- package/dependencies/PathManager.d.ts +14 -0
- package/dependencies/PathManager.d.ts.map +1 -0
- package/dependencies/PathManager.js +41 -0
- package/dependencies/PathManager.js.map +7 -0
- package/dependencies/StatementRecordManager.d.ts +13 -0
- package/dependencies/StatementRecordManager.d.ts.map +1 -0
- package/dependencies/StatementRecordManager.js +26 -0
- package/dependencies/StatementRecordManager.js.map +7 -0
- package/dependencies/utils.d.ts +7 -0
- package/dependencies/utils.d.ts.map +1 -0
- package/dependencies/utils.js +10 -0
- package/dependencies/utils.js.map +7 -0
- package/memoize.d.ts +2 -0
- package/memoize.d.ts.map +1 -0
- package/memoize.js +15 -0
- package/memoize.js.map +7 -0
- package/package.json +102 -0
- package/testing/snapshotMatcher.d.ts +10 -0
- package/testing/snapshotMatcher.d.ts.map +1 -0
- package/testing/snapshotMatcher.js +34 -0
- package/testing/snapshotMatcher.js.map +7 -0
package/.lintstagedrc.js
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Logger } from 'pino';
|
|
2
|
+
export { type Logger };
|
|
3
|
+
export type LoggerOptions = Readonly<{
|
|
4
|
+
name?: string;
|
|
5
|
+
verbose?: boolean;
|
|
6
|
+
}>;
|
|
7
|
+
export default class LoggerFactory {
|
|
8
|
+
#private;
|
|
9
|
+
constructor({ name, verbose }: LoggerOptions);
|
|
10
|
+
get global(): Logger;
|
|
11
|
+
for(caller: string): Logger;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=LoggerFactory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoggerFactory.d.ts","sourceRoot":"","sources":["src/LoggerFactory.ts"],"names":[],"mappings":"AAAA,OAAa,EAAE,KAAK,MAAM,EAAE,MAAM,MAAM,CAAC;AAGzC,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;AAEvB,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC,CAAC;AAEH,MAAM,CAAC,OAAO,OAAO,aAAa;;gBAIpB,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,aAAa;IAe5C,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAS5B"}
|
package/LoggerFactory.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import Pino, {} from "pino";
|
|
2
|
+
import PinoPretty from "pino-pretty";
|
|
3
|
+
class LoggerFactory {
|
|
4
|
+
#children = /* @__PURE__ */ new Map();
|
|
5
|
+
#logger;
|
|
6
|
+
constructor({ name, verbose }) {
|
|
7
|
+
const pretty = PinoPretty({
|
|
8
|
+
ignore: "time"
|
|
9
|
+
});
|
|
10
|
+
this.#logger = Pino(
|
|
11
|
+
{
|
|
12
|
+
base: void 0,
|
|
13
|
+
level: verbose ? "debug" : "info",
|
|
14
|
+
name: name ?? "tsgen"
|
|
15
|
+
},
|
|
16
|
+
pretty
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
get global() {
|
|
20
|
+
return this.#logger;
|
|
21
|
+
}
|
|
22
|
+
for(caller) {
|
|
23
|
+
if (this.#children.has(caller)) {
|
|
24
|
+
return this.#children.get(caller);
|
|
25
|
+
}
|
|
26
|
+
const child = this.#logger.child({ caller });
|
|
27
|
+
this.#children.set(caller, child);
|
|
28
|
+
return child;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
LoggerFactory as default
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=LoggerFactory.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/LoggerFactory.ts"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": "AAAA,OAAO,cAA2B;AAClC,OAAO,gBAAgB;AASvB,MAAO,cAA4B;AAAA,EACxB,YAAY,oBAAI,IAAoB;AAAA,EACpC;AAAA,EAET,YAAY,EAAE,MAAM,QAAQ,GAAkB;AAC5C,UAAM,SAAS,WAAW;AAAA,MACxB,QAAQ;AAAA,IACV,CAAC;AAED,SAAK,UAAU;AAAA,MACb;AAAA,QACE,MAAM;AAAA,QACN,OAAO,UAAU,UAAU;AAAA,QAC3B,MAAM,QAAQ;AAAA,MAChB;AAAA,MACA;AAAA,IACF;AAAA,EACF;AAAA,EAEA,IAAI,SAAiB;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAI,QAAwB;AAC1B,QAAI,KAAK,UAAU,IAAI,MAAM,GAAG;AAC9B,aAAO,KAAK,UAAU,IAAI,MAAM;AAAA,IAClC;AAEA,UAAM,QAAQ,KAAK,QAAQ,MAAM,EAAE,OAAO,CAAC;AAC3C,SAAK,UAAU,IAAI,QAAQ,KAAK;AAChC,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/PluginError.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PluginError.d.ts","sourceRoot":"","sources":["src/PluginError.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,WAAY,SAAQ,KAAK;gBAChC,OAAO,EAAE,MAAM,EAAE,UAAU,SAA6B;CAGrE"}
|
package/PluginError.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/PluginError.ts"],
|
|
4
|
+
"sourcesContent": ["export default class PluginError extends Error {\n constructor(message: string, pluginName = 'Unknown Generator Plugin') {\n super(`[${pluginName}]: ${message}`);\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,MAAO,oBAAkC,MAAM;AAAA,EAC7C,YAAY,SAAiB,aAAa,4BAA4B;AACpE,UAAM,IAAI,UAAU,MAAM,OAAO,EAAE;AAAA,EACrC;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Hilla TypeScript Plugin utils
|
package/ast.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Node, type SourceFile, type Statement, type TransformerFactory } from 'typescript';
|
|
2
|
+
export type TemplateSelector<T> = (statements: readonly Statement[]) => T;
|
|
3
|
+
export declare function template(code: string, transformers?: ReadonlyArray<TransformerFactory<SourceFile>>): readonly Statement[];
|
|
4
|
+
export declare function template<T>(code: string, selector: TemplateSelector<T>, transformers?: ReadonlyArray<TransformerFactory<SourceFile>>): T;
|
|
5
|
+
export declare function transform<T extends Node>(transformer: (node: Node) => Node): TransformerFactory<T>;
|
|
6
|
+
//# sourceMappingURL=ast.d.ts.map
|
package/ast.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["src/ast.ts"],"names":[],"mappings":"AAAA,OAAW,EACT,KAAK,IAAI,EACT,KAAK,UAAU,EACf,KAAK,SAAS,EAEd,KAAK,kBAAkB,EACxB,MAAM,YAAY,CAAC;AAEpB,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,KAAK,CAAC,CAAC;AAE1E,wBAAgB,QAAQ,CACtB,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,GAC3D,SAAS,SAAS,EAAE,CAAC;AACxB,wBAAgB,QAAQ,CAAC,CAAC,EACxB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC7B,YAAY,CAAC,EAAE,aAAa,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC,GAC3D,CAAC,CAAC;AA2BL,wBAAgB,SAAS,CAAC,CAAC,SAAS,IAAI,EAAE,WAAW,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAKlG"}
|
package/ast.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import ts, {
|
|
2
|
+
} from "typescript";
|
|
3
|
+
function template(code, selectorOrTransformers, transformers) {
|
|
4
|
+
let selector;
|
|
5
|
+
if (Array.isArray(selectorOrTransformers)) {
|
|
6
|
+
transformers = selectorOrTransformers;
|
|
7
|
+
} else {
|
|
8
|
+
selector = selectorOrTransformers;
|
|
9
|
+
}
|
|
10
|
+
let sourceFile = ts.createSourceFile("f.ts", code, ts.ScriptTarget.Latest, false);
|
|
11
|
+
if (transformers) {
|
|
12
|
+
[sourceFile] = ts.transform(
|
|
13
|
+
sourceFile,
|
|
14
|
+
transformers
|
|
15
|
+
).transformed;
|
|
16
|
+
}
|
|
17
|
+
return selector?.(sourceFile.statements) ?? sourceFile.statements;
|
|
18
|
+
}
|
|
19
|
+
function transform(transformer) {
|
|
20
|
+
return (context) => (root) => {
|
|
21
|
+
const visitor = (node) => ts.visitEachChild(transformer(node), visitor, context);
|
|
22
|
+
return ts.visitEachChild(root, visitor, context);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export {
|
|
26
|
+
template,
|
|
27
|
+
transform
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=ast.js.map
|
package/ast.js.map
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/ast.ts"],
|
|
4
|
+
"sourcesContent": ["import ts, {\n type Node,\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>(transformer: (node: Node) => Node): TransformerFactory<T> {\n return (context: TransformationContext) => (root: T) => {\n const visitor = (node: Node): Node => ts.visitEachChild(transformer(node), visitor, context);\n return ts.visitEachChild(root, visitor, context);\n };\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO;AAAA,OAMA;AAaA,SAAS,SACd,MACA,wBACA,cAC0B;AAC1B,MAAI;AAEJ,MAAI,MAAM,QAAQ,sBAAsB,GAAG;AAEzC,mBAAe;AAAA,EACjB,OAAO;AACL,eAAW;AAAA,EACb;AAEA,MAAI,aAAa,GAAG,iBAAiB,QAAQ,MAAM,GAAG,aAAa,QAAQ,KAAK;AAEhF,MAAI,cAAc;AAChB,KAAC,UAAU,IAAI,GAAG;AAAA,MAChB;AAAA,MACA;AAAA,IACF,EAAE;AAAA,EACJ;AAEA,SAAO,WAAW,WAAW,UAAU,KAAK,WAAW;AACzD;AAEO,SAAS,UAA0B,aAA0D;AAClG,SAAO,CAAC,YAAmC,CAAC,SAAY;AACtD,UAAM,UAAU,CAAC,SAAqB,GAAG,eAAe,YAAY,IAAI,GAAG,SAAS,OAAO;AAC3F,WAAO,GAAG,eAAe,MAAM,SAAS,OAAO;AAAA,EACjD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFullyUniqueIdentifier.d.ts","sourceRoot":"","sources":["src/createFullyUniqueIdentifier.ts"],"names":[],"mappings":"AAAA,OAAW,EAAE,KAAK,wBAAwB,EAAE,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAEhF,MAAM,CAAC,OAAO,UAAU,2BAA2B,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,wBAAwB,GAAG,UAAU,CAM9G"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import ts, {} from "typescript";
|
|
2
|
+
function createFullyUniqueIdentifier(name, flags) {
|
|
3
|
+
return ts.factory.createUniqueName(
|
|
4
|
+
name,
|
|
5
|
+
// eslint-disable-next-line no-bitwise
|
|
6
|
+
flags ?? ts.GeneratedIdentifierFlags.Optimistic & ts.GeneratedIdentifierFlags.FileLevel
|
|
7
|
+
);
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
createFullyUniqueIdentifier as default
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=createFullyUniqueIdentifier.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/createFullyUniqueIdentifier.ts"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": "AAAA,OAAO,YAA4D;AAEpD,SAAR,4BAA6C,MAAc,OAA8C;AAC9G,SAAO,GAAG,QAAQ;AAAA,IAChB;AAAA;AAAA,IAEA,SAAS,GAAG,yBAAyB,aAAa,GAAG,yBAAyB;AAAA,EAChF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createSourceFile.d.ts","sourceRoot":"","sources":["src/createSourceFile.ts"],"names":[],"mappings":"AAAA,OAAW,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAC,UAAU,EAAE,SAAS,SAAS,EAAE,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAGvG"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import ts, {} from "typescript";
|
|
2
|
+
function createSourceFile(statements, fileName) {
|
|
3
|
+
const sourceFile = ts.createSourceFile(fileName, "", ts.ScriptTarget.ES2019, void 0, ts.ScriptKind.TS);
|
|
4
|
+
return ts.factory.updateSourceFile(sourceFile, statements);
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
createSourceFile as default
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=createSourceFile.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["src/createSourceFile.ts"],
|
|
4
|
+
"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.ES2019, undefined, ts.ScriptKind.TS);\n return ts.factory.updateSourceFile(sourceFile, statements);\n}\n"],
|
|
5
|
+
"mappings": "AAAA,OAAO,YAA6C;AAErC,SAAR,iBAAkC,YAAkC,UAA8B;AACvG,QAAM,aAAa,GAAG,iBAAiB,UAAU,IAAI,GAAG,aAAa,QAAQ,QAAW,GAAG,WAAW,EAAE;AACxG,SAAO,GAAG,QAAQ,iBAAiB,YAAY,UAAU;AAC3D;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=CodeConvertable.d.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import ExportManager from './ExportManager.js';
|
|
2
|
+
import ImportManager from './ImportManager.js';
|
|
3
|
+
import type PathManager from './PathManager.js';
|
|
4
|
+
export default class DependencyManager {
|
|
5
|
+
readonly exports: ExportManager;
|
|
6
|
+
readonly imports: ImportManager;
|
|
7
|
+
readonly paths: PathManager;
|
|
8
|
+
constructor(paths: PathManager, collator?: Intl.Collator);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DependencyManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DependencyManager.d.ts","sourceRoot":"","sources":["../src/dependencies/DependencyManager.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAEhD,MAAM,CAAC,OAAO,OAAO,iBAAiB;IACpC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;gBAEhB,KAAK,EAAE,WAAW,EAAE,QAAQ,GAAE,IAAI,CAAC,QAA2D;CAK3G"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import ExportManager from "./ExportManager.js";
|
|
2
|
+
import ImportManager from "./ImportManager.js";
|
|
3
|
+
class DependencyManager {
|
|
4
|
+
exports;
|
|
5
|
+
imports;
|
|
6
|
+
paths;
|
|
7
|
+
constructor(paths, collator = new Intl.Collator("en", { sensitivity: "case" })) {
|
|
8
|
+
this.exports = new ExportManager(collator);
|
|
9
|
+
this.imports = new ImportManager(collator);
|
|
10
|
+
this.paths = paths;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
DependencyManager as default
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=DependencyManager.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/dependencies/DependencyManager.ts"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": "AAAA,OAAO,mBAAmB;AAC1B,OAAO,mBAAmB;AAG1B,MAAO,kBAAgC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EAET,YAAY,OAAoB,WAA0B,IAAI,KAAK,SAAS,MAAM,EAAE,aAAa,OAAO,CAAC,GAAG;AAC1G,SAAK,UAAU,IAAI,cAAc,QAAQ;AACzC,SAAK,UAAU,IAAI,cAAc,QAAQ;AACzC,SAAK,QAAQ;AAAA,EACf;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { type ExportAssignment, type ExportDeclaration, type Identifier, type Statement } from 'typescript';
|
|
2
|
+
import type CodeConvertable from './CodeConvertable.js';
|
|
3
|
+
import StatementRecordManager, { type StatementRecord } from './StatementRecordManager.js';
|
|
4
|
+
export declare class NamedExportManager implements CodeConvertable<ExportDeclaration | undefined> {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(collator: Intl.Collator);
|
|
7
|
+
add(name: string, isType?: boolean, uniqueId?: Identifier): Identifier;
|
|
8
|
+
getIdentifier(name: string): Identifier | undefined;
|
|
9
|
+
identifiers(): IterableIterator<readonly [id: Identifier, isType: boolean]>;
|
|
10
|
+
isType(name: string): boolean | undefined;
|
|
11
|
+
names(): IterableIterator<string>;
|
|
12
|
+
toCode(): ExportDeclaration | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class NamespaceExportManager extends StatementRecordManager<ExportDeclaration> {
|
|
15
|
+
#private;
|
|
16
|
+
addCombined(path: string, name: string, uniqueId?: Identifier): Identifier;
|
|
17
|
+
addSpread(path: string): void;
|
|
18
|
+
clear(): void;
|
|
19
|
+
getIdentifier(path: string): Identifier | null | undefined;
|
|
20
|
+
identifiers(): IterableIterator<Identifier | null>;
|
|
21
|
+
isCombined(path: string): boolean | undefined;
|
|
22
|
+
isSpread(path: string): boolean | undefined;
|
|
23
|
+
paths(): IterableIterator<string>;
|
|
24
|
+
statementRecords(): IterableIterator<StatementRecord<ExportDeclaration>>;
|
|
25
|
+
}
|
|
26
|
+
export declare class DefaultExportManager implements CodeConvertable<ExportAssignment | undefined> {
|
|
27
|
+
#private;
|
|
28
|
+
set(id: Identifier | string): Identifier;
|
|
29
|
+
toCode(): ExportAssignment | undefined;
|
|
30
|
+
}
|
|
31
|
+
export default class ExportManager implements CodeConvertable<readonly Statement[]> {
|
|
32
|
+
readonly default: DefaultExportManager;
|
|
33
|
+
readonly named: NamedExportManager;
|
|
34
|
+
readonly namespace: NamespaceExportManager;
|
|
35
|
+
constructor(collator: Intl.Collator);
|
|
36
|
+
toCode(): readonly Statement[];
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ExportManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExportManager.d.ts","sourceRoot":"","sources":["../src/dependencies/ExportManager.ts"],"names":[],"mappings":"AAAA,OAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,iBAAiB,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAEhH,OAAO,KAAK,eAAe,MAAM,sBAAsB,CAAC;AACxD,OAAO,sBAAsB,EAAE,EAAE,KAAK,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAG3F,qBAAa,kBAAmB,YAAW,eAAe,CAAC,iBAAiB,GAAG,SAAS,CAAC;;gBAI3E,QAAQ,EAAE,IAAI,CAAC,QAAQ;IAInC,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU;IAMtE,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAIlD,WAAW,IAAI,gBAAgB,CAAC,SAAS,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,CAAC;IAM5E,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIzC,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIjC,MAAM,IAAI,iBAAiB,GAAG,SAAS;CAqBxC;AAED,qBAAa,sBAAuB,SAAQ,sBAAsB,CAAC,iBAAiB,CAAC;;IAGnF,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,GAAG,UAAU;IAM1E,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAIpB,KAAK,IAAI,IAAI;IAItB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI,GAAG,SAAS;IAI1D,WAAW,IAAI,gBAAgB,CAAC,UAAU,GAAG,IAAI,CAAC;IAIlD,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI7C,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAI3C,KAAK,IAAI,gBAAgB,CAAC,MAAM,CAAC;IAIvB,gBAAgB,IAAI,gBAAgB,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC;CAanF;AAED,qBAAa,oBAAqB,YAAW,eAAe,CAAC,gBAAgB,GAAG,SAAS,CAAC;;IAGxF,GAAG,CAAC,EAAE,EAAE,UAAU,GAAG,MAAM,GAAG,UAAU;IAKxC,MAAM,IAAI,gBAAgB,GAAG,SAAS;CAGvC;AAED,MAAM,CAAC,OAAO,OAAO,aAAc,YAAW,eAAe,CAAC,SAAS,SAAS,EAAE,CAAC;IACjF,QAAQ,CAAC,OAAO,uBAA8B;IAC9C,QAAQ,CAAC,KAAK,EAAE,kBAAkB,CAAC;IACnC,QAAQ,CAAC,SAAS,EAAE,sBAAsB,CAAC;gBAE/B,QAAQ,EAAE,IAAI,CAAC,QAAQ;IAKnC,MAAM,IAAI,SAAS,SAAS,EAAE;CAmB/B"}
|