@atlaspack/transformer-html 2.14.5-canary.3 → 2.14.5-canary.300

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/CHANGELOG.md CHANGED
@@ -1,5 +1,306 @@
1
1
  # @atlaspack/transformer-html
2
2
 
3
+ ## 2.15.16
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`7dd5bd8`](https://github.com/atlassian-labs/atlaspack/commit/7dd5bd89ff60c7b324347d772729eb4c3314f01e), [`c8a0e51`](https://github.com/atlassian-labs/atlaspack/commit/c8a0e51b1096d038a64644ad02fe68383f58682a), [`8eb84ee`](https://github.com/atlassian-labs/atlaspack/commit/8eb84ee61a42bfe87c58079b610802b07a6a13e4), [`71900f3`](https://github.com/atlassian-labs/atlaspack/commit/71900f3508d53c3882ca8ea71501ba3069687d4e), [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`2c4953e`](https://github.com/atlassian-labs/atlaspack/commit/2c4953e20dc1a6b012792081667aefeb9340505e), [`3fe7d4e`](https://github.com/atlassian-labs/atlaspack/commit/3fe7d4e821bee162fcbbaf9278b107a5eead944f)]:
8
+ - @atlaspack/rust@3.11.0
9
+ - @atlaspack/feature-flags@2.27.0
10
+ - @atlaspack/plugin@2.14.39
11
+
12
+ ## 2.15.15
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [[`ec3abe4`](https://github.com/atlassian-labs/atlaspack/commit/ec3abe4dffc98560a850fd2f71fb566577e6c99c), [`c7fe3f7`](https://github.com/atlassian-labs/atlaspack/commit/c7fe3f76f247e9e20299e205e2df0a16c418eaf2), [`cfb4707`](https://github.com/atlassian-labs/atlaspack/commit/cfb4707087498e4fa4dcf10753fe984a248d196b), [`1468695`](https://github.com/atlassian-labs/atlaspack/commit/1468695fc0c9d06f060a6da9e9b0e154f11dff34), [`f31b041`](https://github.com/atlassian-labs/atlaspack/commit/f31b04107e9077c9946aadb99f6f91bb69703bb7), [`8180981`](https://github.com/atlassian-labs/atlaspack/commit/8180981be14c00f9570adb70d3f350bd91d6ec0a), [`ae77e74`](https://github.com/atlassian-labs/atlaspack/commit/ae77e7452a466b43b3fa5bed24d4ba26345ed765), [`f0a496f`](https://github.com/atlassian-labs/atlaspack/commit/f0a496f70fc8652e090cf1b3f6260e8cfbb796e2), [`540f253`](https://github.com/atlassian-labs/atlaspack/commit/540f253dfdcd1a5caebbdc0b197319d439404aae)]:
17
+ - @atlaspack/feature-flags@2.26.2
18
+ - @atlaspack/rust@3.10.0
19
+ - @atlaspack/plugin@2.14.38
20
+
21
+ ## 2.15.14
22
+
23
+ ### Patch Changes
24
+
25
+ - Updated dependencies [[`339b600`](https://github.com/atlassian-labs/atlaspack/commit/339b60095d755742cea50f811d08ccc44a4ae521), [`373ee2d`](https://github.com/atlassian-labs/atlaspack/commit/373ee2d3b5cc315df1e90e647619f915892e2b87)]:
26
+ - @atlaspack/rust@3.9.1
27
+ - @atlaspack/feature-flags@2.26.1
28
+ - @atlaspack/plugin@2.14.37
29
+
30
+ ## 2.15.13
31
+
32
+ ### Patch Changes
33
+
34
+ - Updated dependencies [[`02f6aa1`](https://github.com/atlassian-labs/atlaspack/commit/02f6aa1906953fc184d2b49c905c2ef815cb878d), [`58527ee`](https://github.com/atlassian-labs/atlaspack/commit/58527eec15c1aebaaadbeb63586f3082c16beae3), [`525898e`](https://github.com/atlassian-labs/atlaspack/commit/525898e33cc229a4bc938ae853732be36d20c01a), [`cfb39a0`](https://github.com/atlassian-labs/atlaspack/commit/cfb39a0d729eb620cf2ca1611750a2bf7a080d08), [`d0c7bea`](https://github.com/atlassian-labs/atlaspack/commit/d0c7bea04458255b4c5d4299600e734b5f919fe1), [`1086c6a`](https://github.com/atlassian-labs/atlaspack/commit/1086c6a2c59271b63b3fb78e6acdb9d3a0dbf354), [`9cd9521`](https://github.com/atlassian-labs/atlaspack/commit/9cd9521978f783046e2ae4ce78f2de7aeb07d073), [`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
35
+ - @atlaspack/rust@3.9.0
36
+ - @atlaspack/feature-flags@2.26.0
37
+ - @atlaspack/plugin@2.14.36
38
+
39
+ ## 2.15.12
40
+
41
+ ### Patch Changes
42
+
43
+ - Updated dependencies [[`79a7e22`](https://github.com/atlassian-labs/atlaspack/commit/79a7e22ef119891a2f4180a9d3cc66b38dd52092), [`3da8e69`](https://github.com/atlassian-labs/atlaspack/commit/3da8e690605472d81c531366b65fa9844f8ca337), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10), [`f1070ec`](https://github.com/atlassian-labs/atlaspack/commit/f1070ec48e99b4ec111a03179c5ab5b74163fab1), [`27fd73f`](https://github.com/atlassian-labs/atlaspack/commit/27fd73fa07d358653f1be6f2d15d72dc5d8fc2fd), [`3091fa3`](https://github.com/atlassian-labs/atlaspack/commit/3091fa36425ecffe3938e55247a035b08cda37a2)]:
44
+ - @atlaspack/feature-flags@2.25.5
45
+ - @atlaspack/rust@3.8.3
46
+ - @atlaspack/plugin@2.14.35
47
+
48
+ ## 2.15.11
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies [[`662d3c6`](https://github.com/atlassian-labs/atlaspack/commit/662d3c627888b16bf27df15cfac5a9094509e93d)]:
53
+ - @atlaspack/feature-flags@2.25.4
54
+ - @atlaspack/plugin@2.14.34
55
+
56
+ ## 2.15.10
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies [[`f07351a`](https://github.com/atlassian-labs/atlaspack/commit/f07351a2398b6a8e5155a2daad77e69b7dcb2b4b)]:
61
+ - @atlaspack/feature-flags@2.25.3
62
+ - @atlaspack/plugin@2.14.33
63
+
64
+ ## 2.15.9
65
+
66
+ ### Patch Changes
67
+
68
+ - Updated dependencies [[`0207171`](https://github.com/atlassian-labs/atlaspack/commit/0207171e59e985c51e105aec2e0a99de174374bd), [`10ee3fa`](https://github.com/atlassian-labs/atlaspack/commit/10ee3fa5b75a92acde8973673d9b3c5b6f3958e5), [`bbe4e28`](https://github.com/atlassian-labs/atlaspack/commit/bbe4e28c89e5e9284bd730075d4d6f2a3cb37b21), [`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933), [`2bc93b1`](https://github.com/atlassian-labs/atlaspack/commit/2bc93b17cea07fd7cbb68acec84d8471345a22b4)]:
69
+ - @atlaspack/feature-flags@2.25.2
70
+ - @atlaspack/rust@3.8.2
71
+ - @atlaspack/plugin@2.14.32
72
+
73
+ ## 2.15.8
74
+
75
+ ### Patch Changes
76
+
77
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
78
+
79
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922), [`686a398`](https://github.com/atlassian-labs/atlaspack/commit/686a398faa1f9e19cbf9274add2c46e246bafba8)]:
80
+ - @atlaspack/diagnostic@2.14.4
81
+ - @atlaspack/feature-flags@2.25.1
82
+ - @atlaspack/plugin@2.14.31
83
+ - @atlaspack/rust@3.8.1
84
+
85
+ ## 2.15.7
86
+
87
+ ### Patch Changes
88
+
89
+ - Updated dependencies [[`7a52bab`](https://github.com/atlassian-labs/atlaspack/commit/7a52bab6281e8edbfa66af248eb6f872c6b4b7bd), [`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`5a0363f`](https://github.com/atlassian-labs/atlaspack/commit/5a0363f1086e81068959b87e92064bed5a11a9b4), [`038e87a`](https://github.com/atlassian-labs/atlaspack/commit/038e87a7858d39556d59d3a2d17db534d45f62c6), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572), [`0684997`](https://github.com/atlassian-labs/atlaspack/commit/0684997c127a6204af1376b36e556fddd1ba5557), [`602f8ed`](https://github.com/atlassian-labs/atlaspack/commit/602f8ed9d8381301df8b2cc82c1d5cf6f2f94fec)]:
90
+ - @atlaspack/feature-flags@2.25.0
91
+ - @atlaspack/rust@3.8.0
92
+ - @atlaspack/plugin@2.14.30
93
+
94
+ ## 2.15.6
95
+
96
+ ### Patch Changes
97
+
98
+ - Updated dependencies [[`830261d`](https://github.com/atlassian-labs/atlaspack/commit/830261dcf4a40293090b61cab52fd75d5683c73f), [`53dd47b`](https://github.com/atlassian-labs/atlaspack/commit/53dd47bd6d23cd47f87297347f03a609ab38a03d)]:
99
+ - @atlaspack/feature-flags@2.24.1
100
+ - @atlaspack/rust@3.7.0
101
+ - @atlaspack/plugin@2.14.29
102
+
103
+ ## 2.15.5
104
+
105
+ ### Patch Changes
106
+
107
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767), [`a5081c3`](https://github.com/atlassian-labs/atlaspack/commit/a5081c3f9207d28716ee4edd3841de1830ea4b80), [`f930003`](https://github.com/atlassian-labs/atlaspack/commit/f930003364fdc31e5487520ebe256f1a9389f579), [`f930003`](https://github.com/atlassian-labs/atlaspack/commit/f930003364fdc31e5487520ebe256f1a9389f579), [`8843980`](https://github.com/atlassian-labs/atlaspack/commit/88439807be20025fd3433380204ff1205079729e)]:
108
+ - @atlaspack/feature-flags@2.24.0
109
+ - @atlaspack/plugin@2.14.28
110
+
111
+ ## 2.15.4
112
+
113
+ ### Patch Changes
114
+
115
+ - [#757](https://github.com/atlassian-labs/atlaspack/pull/757) [`3cfb7cf`](https://github.com/atlassian-labs/atlaspack/commit/3cfb7cfd90b78a5c48ce717e779ff789769825a3) Thanks [@marcins](https://github.com/marcins)! - Clean up the `inlineIsolatedScripts` feature flag
116
+
117
+ - Updated dependencies [[`3cfb7cf`](https://github.com/atlassian-labs/atlaspack/commit/3cfb7cfd90b78a5c48ce717e779ff789769825a3)]:
118
+ - @atlaspack/feature-flags@2.23.2
119
+ - @atlaspack/rust@3.6.2
120
+ - @atlaspack/plugin@2.14.27
121
+
122
+ ## 2.15.3
123
+
124
+ ### Patch Changes
125
+
126
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
127
+
128
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
129
+ - @atlaspack/feature-flags@2.23.1
130
+ - @atlaspack/diagnostic@2.14.3
131
+ - @atlaspack/plugin@2.14.26
132
+ - @atlaspack/rust@3.6.1
133
+
134
+ ## 2.15.2
135
+
136
+ ### Patch Changes
137
+
138
+ - Updated dependencies [[`f6b3f22`](https://github.com/atlassian-labs/atlaspack/commit/f6b3f2276c7e417580b49c4879563aab51f156b1)]:
139
+ - @atlaspack/feature-flags@2.23.0
140
+ - @atlaspack/plugin@2.14.25
141
+
142
+ ## 2.15.1
143
+
144
+ ### Patch Changes
145
+
146
+ - Updated dependencies [[`ad26146`](https://github.com/atlassian-labs/atlaspack/commit/ad26146f13b4c1cc65d4a0f9c67060b90ef14ff3), [`f1b48e7`](https://github.com/atlassian-labs/atlaspack/commit/f1b48e7a04e005cef0f36a3e692087a9ecdb6f7a), [`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45), [`73dd7ba`](https://github.com/atlassian-labs/atlaspack/commit/73dd7baab69456ef2f6e4a0cc7dbb04f407eb148)]:
147
+ - @atlaspack/rust@3.6.0
148
+ - @atlaspack/feature-flags@2.22.0
149
+ - @atlaspack/plugin@2.14.24
150
+
151
+ ## 2.15.0
152
+
153
+ ### Minor Changes
154
+
155
+ - [#731](https://github.com/atlassian-labs/atlaspack/pull/731) [`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2) Thanks [@marcins](https://github.com/marcins)! - Implement "inline isolated" scripts
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
160
+ - @atlaspack/feature-flags@2.21.0
161
+ - @atlaspack/rust@3.5.0
162
+ - @atlaspack/plugin@2.14.23
163
+
164
+ ## 2.14.22
165
+
166
+ ### Patch Changes
167
+
168
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
169
+
170
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
171
+ - @atlaspack/diagnostic@2.14.2
172
+ - @atlaspack/plugin@2.14.22
173
+ - @atlaspack/rust@3.4.2
174
+
175
+ ## 2.14.21
176
+
177
+ ### Patch Changes
178
+
179
+ - Updated dependencies []:
180
+ - @atlaspack/plugin@2.14.21
181
+
182
+ ## 2.14.20
183
+
184
+ ### Patch Changes
185
+
186
+ - [#702](https://github.com/atlassian-labs/atlaspack/pull/702) [`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa) Thanks [@alshdavid](https://github.com/alshdavid)! - Fixes to Flow types
187
+
188
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
189
+ - @atlaspack/plugin@2.14.20
190
+
191
+ ## 2.14.19
192
+
193
+ ### Patch Changes
194
+
195
+ - Updated dependencies []:
196
+ - @atlaspack/plugin@2.14.19
197
+
198
+ ## 2.14.18
199
+
200
+ ### Patch Changes
201
+
202
+ - Updated dependencies [[`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5)]:
203
+ - @atlaspack/rust@3.4.1
204
+ - @atlaspack/plugin@2.14.18
205
+
206
+ ## 2.14.17
207
+
208
+ ### Patch Changes
209
+
210
+ - Updated dependencies [[`c75bf55`](https://github.com/atlassian-labs/atlaspack/commit/c75bf553fff4decc285b5fd499a275853b18f8f2)]:
211
+ - @atlaspack/rust@3.4.0
212
+ - @atlaspack/plugin@2.14.17
213
+
214
+ ## 2.14.16
215
+
216
+ ### Patch Changes
217
+
218
+ - Updated dependencies []:
219
+ - @atlaspack/plugin@2.14.16
220
+
221
+ ## 2.14.15
222
+
223
+ ### Patch Changes
224
+
225
+ - Updated dependencies []:
226
+ - @atlaspack/plugin@2.14.15
227
+
228
+ ## 2.14.14
229
+
230
+ ### Patch Changes
231
+
232
+ - Updated dependencies []:
233
+ - @atlaspack/plugin@2.14.14
234
+
235
+ ## 2.14.13
236
+
237
+ ### Patch Changes
238
+
239
+ - Updated dependencies []:
240
+ - @atlaspack/plugin@2.14.13
241
+
242
+ ## 2.14.12
243
+
244
+ ### Patch Changes
245
+
246
+ - Updated dependencies []:
247
+ - @atlaspack/plugin@2.14.12
248
+
249
+ ## 2.14.11
250
+
251
+ ### Patch Changes
252
+
253
+ - Updated dependencies []:
254
+ - @atlaspack/plugin@2.14.11
255
+
256
+ ## 2.14.10
257
+
258
+ ### Patch Changes
259
+
260
+ - Updated dependencies [[`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
261
+ - @atlaspack/rust@3.3.5
262
+ - @atlaspack/plugin@2.14.10
263
+
264
+ ## 2.14.9
265
+
266
+ ### Patch Changes
267
+
268
+ - Updated dependencies [[`124b7ff`](https://github.com/atlassian-labs/atlaspack/commit/124b7fff44f71aac9fbad289a9a9509b3dfc9aaa), [`e052521`](https://github.com/atlassian-labs/atlaspack/commit/e0525210850ed1606146eb86991049cf567c5dec), [`15c6d70`](https://github.com/atlassian-labs/atlaspack/commit/15c6d7000bd89da876bc590aa75b17a619a41896), [`e4d966c`](https://github.com/atlassian-labs/atlaspack/commit/e4d966c3c9c4292c5013372ae65b10d19d4bacc6), [`42a775d`](https://github.com/atlassian-labs/atlaspack/commit/42a775de8eec638ad188f3271964170d8c04d84b), [`29c2f10`](https://github.com/atlassian-labs/atlaspack/commit/29c2f106de9679adfb5afa04e1910471dc65a427), [`1ef91fc`](https://github.com/atlassian-labs/atlaspack/commit/1ef91fcc863fdd2831511937083dbbc1263b3d9d)]:
269
+ - @atlaspack/rust@3.3.4
270
+ - @atlaspack/plugin@2.14.9
271
+
272
+ ## 2.14.8
273
+
274
+ ### Patch Changes
275
+
276
+ - Updated dependencies [[`1ab0a27`](https://github.com/atlassian-labs/atlaspack/commit/1ab0a275aeca40350415e2b03e7440d1dddc6228), [`b8a4ae8`](https://github.com/atlassian-labs/atlaspack/commit/b8a4ae8f83dc0a83d8b145c5f729936ce52080a3)]:
277
+ - @atlaspack/rust@3.3.3
278
+ - @atlaspack/plugin@2.14.8
279
+
280
+ ## 2.14.7
281
+
282
+ ### Patch Changes
283
+
284
+ - Updated dependencies [[`556d6ab`](https://github.com/atlassian-labs/atlaspack/commit/556d6ab8ede759fa7f37fcd3f4da336ef1c55e8f)]:
285
+ - @atlaspack/rust@3.3.2
286
+ - @atlaspack/plugin@2.14.7
287
+
288
+ ## 2.14.6
289
+
290
+ ### Patch Changes
291
+
292
+ - Updated dependencies [[`e0f5337`](https://github.com/atlassian-labs/atlaspack/commit/e0f533757bd1019dbd108a04952c87da15286e09)]:
293
+ - @atlaspack/rust@3.3.1
294
+ - @atlaspack/plugin@2.14.6
295
+
296
+ ## 2.14.5
297
+
298
+ ### Patch Changes
299
+
300
+ - Updated dependencies [[`e2ba0f6`](https://github.com/atlassian-labs/atlaspack/commit/e2ba0f69702656f3d1ce95ab1454e35062b13b39), [`d2c50c2`](https://github.com/atlassian-labs/atlaspack/commit/d2c50c2c020888b33bb25b8690d9320c2b69e2a6), [`46a90dc`](https://github.com/atlassian-labs/atlaspack/commit/46a90dccd019a26b222c878a92d23acc75dc67c5)]:
301
+ - @atlaspack/rust@3.3.0
302
+ - @atlaspack/plugin@2.14.5
303
+
3
304
  ## 2.14.4
4
305
 
5
306
  ### Patch Changes
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.transformerOpts = void 0;
7
+ exports.parseHTML = parseHTML;
8
+ const plugin_1 = require("@atlaspack/plugin");
9
+ const posthtml_parser_1 = require("posthtml-parser");
10
+ const nullthrows_1 = __importDefault(require("nullthrows"));
11
+ const posthtml_1 = __importDefault(require("posthtml"));
12
+ const posthtml_render_1 = require("posthtml-render");
13
+ const semver_1 = __importDefault(require("semver"));
14
+ const dependencies_1 = __importDefault(require("./dependencies"));
15
+ const inline_1 = __importDefault(require("./inline"));
16
+ const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
17
+ function parseHTML(code, xmlMode) {
18
+ return {
19
+ type: 'posthtml',
20
+ version: '0.4.1',
21
+ program: (0, posthtml_parser_1.parser)(code, {
22
+ lowerCaseTags: true,
23
+ lowerCaseAttributeNames: true,
24
+ sourceLocations: true,
25
+ xmlMode,
26
+ }),
27
+ };
28
+ }
29
+ exports.transformerOpts = {
30
+ canReuseAST({ ast }) {
31
+ return ast.type === 'posthtml' && semver_1.default.satisfies(ast.version, '^0.4.0');
32
+ },
33
+ async parse({ asset }) {
34
+ const code = await asset.getCode();
35
+ const xmlMode = asset.type === 'xhtml';
36
+ return parseHTML(code, xmlMode);
37
+ },
38
+ async transform({ asset, options }) {
39
+ if (asset.type === 'htm') {
40
+ asset.type = 'html';
41
+ }
42
+ asset.bundleBehavior = 'isolated';
43
+ let ast = (0, nullthrows_1.default)(await asset.getAST());
44
+ let hasModuleScripts;
45
+ try {
46
+ hasModuleScripts = (0, dependencies_1.default)(asset, ast);
47
+ }
48
+ catch (errors) {
49
+ if (Array.isArray(errors)) {
50
+ throw new diagnostic_1.default({
51
+ diagnostic: errors.map((error) => ({
52
+ message: error.message,
53
+ origin: '@atlaspack/transformer-html',
54
+ codeFrames: [
55
+ {
56
+ filePath: error.filePath,
57
+ language: 'html',
58
+ codeHighlights: [error.loc],
59
+ },
60
+ ],
61
+ })),
62
+ });
63
+ }
64
+ throw errors;
65
+ }
66
+ const { assets: inlineAssets, hasModuleScripts: hasInlineModuleScripts } = (0, inline_1.default)(asset, ast);
67
+ const result = [asset, ...inlineAssets];
68
+ // empty <script></script> is added to make sure HMR is working even if user
69
+ // didn't add any.
70
+ if (options.hmrOptions && !(hasModuleScripts || hasInlineModuleScripts)) {
71
+ const script = {
72
+ tag: 'script',
73
+ attrs: {
74
+ src: asset.addURLDependency('hmr.js', {
75
+ priority: 'parallel',
76
+ }),
77
+ },
78
+ content: [],
79
+ };
80
+ const found = findFirstMatch(ast, [{ tag: 'body' }, { tag: 'html' }]);
81
+ if (found) {
82
+ found.content = found.content || [];
83
+ found.content.push(script);
84
+ }
85
+ else {
86
+ // Insert at the very end.
87
+ ast.program.push(script);
88
+ }
89
+ asset.setAST(ast);
90
+ result.push({
91
+ type: 'js',
92
+ content: '',
93
+ uniqueKey: 'hmr.js',
94
+ });
95
+ }
96
+ return result;
97
+ },
98
+ generate({ ast, asset }) {
99
+ return {
100
+ content: (0, posthtml_render_1.render)(ast.program, {
101
+ // @ts-expect-error TS2322
102
+ closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined,
103
+ }),
104
+ };
105
+ },
106
+ };
107
+ exports.default = new plugin_1.Transformer(exports.transformerOpts);
108
+ function findFirstMatch(ast, expressions) {
109
+ let found;
110
+ for (const expression of expressions) {
111
+ // @ts-expect-error TS2339
112
+ (0, posthtml_1.default)().match.call(ast.program, expression, (node) => {
113
+ found = node;
114
+ return node;
115
+ });
116
+ if (found) {
117
+ return found;
118
+ }
119
+ }
120
+ }