@atlaspack/transformer-svg 2.14.5-canary.33 → 2.14.5-canary.330

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,290 @@
1
1
  # @atlaspack/transformer-svg
2
2
 
3
+ ## 2.14.44
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`362a85d`](https://github.com/atlassian-labs/atlaspack/commit/362a85deb9722f769eeb5099bae915f8b858a126), [`c81b368`](https://github.com/atlassian-labs/atlaspack/commit/c81b368db20af701d9e019a11272b138f9cfe080)]:
8
+ - @atlaspack/rust@3.15.0
9
+ - @atlaspack/plugin@2.14.44
10
+
11
+ ## 2.14.43
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies []:
16
+ - @atlaspack/plugin@2.14.43
17
+
18
+ ## 2.14.42
19
+
20
+ ### Patch Changes
21
+
22
+ - Updated dependencies [[`787290a`](https://github.com/atlassian-labs/atlaspack/commit/787290a63b3f781e7af86097201dfdb5a36c8551), [`cbb66a5`](https://github.com/atlassian-labs/atlaspack/commit/cbb66a554f7ad679fd4dfc9e2bf2d5abb859f846), [`7815a93`](https://github.com/atlassian-labs/atlaspack/commit/7815a931b18983c3f34a39990b2f4b8b86855cc6), [`25aa273`](https://github.com/atlassian-labs/atlaspack/commit/25aa2735f4db920960de3d65d3a427775086b7d5), [`9468e16`](https://github.com/atlassian-labs/atlaspack/commit/9468e164e8ca20a5e8f552f5dc203aa3716cb154), [`e55c80c`](https://github.com/atlassian-labs/atlaspack/commit/e55c80cd0ae3cc40356fe063cb7d45fbb9095356)]:
23
+ - @atlaspack/rust@3.14.0
24
+ - @atlaspack/plugin@2.14.42
25
+
26
+ ## 2.14.41
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies [[`96f1d7f`](https://github.com/atlassian-labs/atlaspack/commit/96f1d7f3efef12ce4f5966e34d00b299fcefb4dd), [`91738fd`](https://github.com/atlassian-labs/atlaspack/commit/91738fd77cb6b3b7acc93e799327ec283d27f7c0), [`38f3569`](https://github.com/atlassian-labs/atlaspack/commit/38f3569a7024357c43274666312bc6d024bfe5f9), [`3f6a3b8`](https://github.com/atlassian-labs/atlaspack/commit/3f6a3b8df4589fd4d65c072281c7f33bd37341d6), [`96f1d7f`](https://github.com/atlassian-labs/atlaspack/commit/96f1d7f3efef12ce4f5966e34d00b299fcefb4dd), [`d8024ce`](https://github.com/atlassian-labs/atlaspack/commit/d8024ce5c9ced1a9bc39144c979138be3a12b2fb), [`308e7ff`](https://github.com/atlassian-labs/atlaspack/commit/308e7ff979c05c1ae97fe6b08a65666b53d86cc7), [`d98c992`](https://github.com/atlassian-labs/atlaspack/commit/d98c992a56121a4f9f6a011ced5e103f96fe3999)]:
31
+ - @atlaspack/rust@3.13.0
32
+ - @atlaspack/plugin@2.14.41
33
+
34
+ ## 2.14.40
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies [[`a884bd2`](https://github.com/atlassian-labs/atlaspack/commit/a884bd2a6bd6f37d088fb886dd9b88e85328501b), [`25fee72`](https://github.com/atlassian-labs/atlaspack/commit/25fee723d2228d0482ec8a8f1b8379ccd2977ce7), [`6fac01d`](https://github.com/atlassian-labs/atlaspack/commit/6fac01dbb1bfc5b971176c1a1c008297bf4b8f91), [`432d571`](https://github.com/atlassian-labs/atlaspack/commit/432d571ea4e9fc67be12304fcafe8c445e844174), [`042cd95`](https://github.com/atlassian-labs/atlaspack/commit/042cd95a32ad38cd02d57aa3344c36d4e7ab8f9c), [`28f5424`](https://github.com/atlassian-labs/atlaspack/commit/28f5424f7e2080dd4fbbeb1bc5314a530197a23e), [`a884bd2`](https://github.com/atlassian-labs/atlaspack/commit/a884bd2a6bd6f37d088fb886dd9b88e85328501b), [`5710532`](https://github.com/atlassian-labs/atlaspack/commit/57105322b26ce42af2cbfcc0506cff929e50b630), [`44eb8c3`](https://github.com/atlassian-labs/atlaspack/commit/44eb8c388d3e63f1ef5d835aee7aee5d1bb0620f)]:
39
+ - @atlaspack/rust@3.12.0
40
+ - @atlaspack/plugin@2.14.40
41
+
42
+ ## 2.14.39
43
+
44
+ ### Patch Changes
45
+
46
+ - Updated dependencies [[`7dd5bd8`](https://github.com/atlassian-labs/atlaspack/commit/7dd5bd89ff60c7b324347d772729eb4c3314f01e), [`c8a0e51`](https://github.com/atlassian-labs/atlaspack/commit/c8a0e51b1096d038a64644ad02fe68383f58682a), [`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)]:
47
+ - @atlaspack/rust@3.11.0
48
+ - @atlaspack/plugin@2.14.39
49
+
50
+ ## 2.14.38
51
+
52
+ ### Patch Changes
53
+
54
+ - 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)]:
55
+ - @atlaspack/rust@3.10.0
56
+ - @atlaspack/plugin@2.14.38
57
+
58
+ ## 2.14.37
59
+
60
+ ### Patch Changes
61
+
62
+ - Updated dependencies [[`339b600`](https://github.com/atlassian-labs/atlaspack/commit/339b60095d755742cea50f811d08ccc44a4ae521), [`373ee2d`](https://github.com/atlassian-labs/atlaspack/commit/373ee2d3b5cc315df1e90e647619f915892e2b87)]:
63
+ - @atlaspack/rust@3.9.1
64
+ - @atlaspack/plugin@2.14.37
65
+
66
+ ## 2.14.36
67
+
68
+ ### Patch Changes
69
+
70
+ - 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)]:
71
+ - @atlaspack/rust@3.9.0
72
+ - @atlaspack/plugin@2.14.36
73
+
74
+ ## 2.14.35
75
+
76
+ ### Patch Changes
77
+
78
+ - Updated dependencies [[`79a7e22`](https://github.com/atlassian-labs/atlaspack/commit/79a7e22ef119891a2f4180a9d3cc66b38dd52092), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10), [`27fd73f`](https://github.com/atlassian-labs/atlaspack/commit/27fd73fa07d358653f1be6f2d15d72dc5d8fc2fd), [`3091fa3`](https://github.com/atlassian-labs/atlaspack/commit/3091fa36425ecffe3938e55247a035b08cda37a2)]:
79
+ - @atlaspack/rust@3.8.3
80
+ - @atlaspack/plugin@2.14.35
81
+
82
+ ## 2.14.34
83
+
84
+ ### Patch Changes
85
+
86
+ - Updated dependencies []:
87
+ - @atlaspack/plugin@2.14.34
88
+
89
+ ## 2.14.33
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies []:
94
+ - @atlaspack/plugin@2.14.33
95
+
96
+ ## 2.14.32
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies [[`0207171`](https://github.com/atlassian-labs/atlaspack/commit/0207171e59e985c51e105aec2e0a99de174374bd), [`bbe4e28`](https://github.com/atlassian-labs/atlaspack/commit/bbe4e28c89e5e9284bd730075d4d6f2a3cb37b21)]:
101
+ - @atlaspack/rust@3.8.2
102
+ - @atlaspack/plugin@2.14.32
103
+
104
+ ## 2.14.31
105
+
106
+ ### Patch Changes
107
+
108
+ - [#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.
109
+
110
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922), [`686a398`](https://github.com/atlassian-labs/atlaspack/commit/686a398faa1f9e19cbf9274add2c46e246bafba8)]:
111
+ - @atlaspack/diagnostic@2.14.4
112
+ - @atlaspack/plugin@2.14.31
113
+ - @atlaspack/rust@3.8.1
114
+
115
+ ## 2.14.30
116
+
117
+ ### Patch Changes
118
+
119
+ - Updated dependencies [[`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)]:
120
+ - @atlaspack/rust@3.8.0
121
+ - @atlaspack/plugin@2.14.30
122
+
123
+ ## 2.14.29
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies [[`53dd47b`](https://github.com/atlassian-labs/atlaspack/commit/53dd47bd6d23cd47f87297347f03a609ab38a03d)]:
128
+ - @atlaspack/rust@3.7.0
129
+ - @atlaspack/plugin@2.14.29
130
+
131
+ ## 2.14.28
132
+
133
+ ### Patch Changes
134
+
135
+ - Updated dependencies []:
136
+ - @atlaspack/plugin@2.14.28
137
+
138
+ ## 2.14.27
139
+
140
+ ### Patch Changes
141
+
142
+ - Updated dependencies [[`3cfb7cf`](https://github.com/atlassian-labs/atlaspack/commit/3cfb7cfd90b78a5c48ce717e779ff789769825a3)]:
143
+ - @atlaspack/rust@3.6.2
144
+ - @atlaspack/plugin@2.14.27
145
+
146
+ ## 2.14.26
147
+
148
+ ### Patch Changes
149
+
150
+ - [#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
151
+
152
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
153
+ - @atlaspack/diagnostic@2.14.3
154
+ - @atlaspack/plugin@2.14.26
155
+ - @atlaspack/rust@3.6.1
156
+
157
+ ## 2.14.25
158
+
159
+ ### Patch Changes
160
+
161
+ - Updated dependencies []:
162
+ - @atlaspack/plugin@2.14.25
163
+
164
+ ## 2.14.24
165
+
166
+ ### Patch Changes
167
+
168
+ - 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)]:
169
+ - @atlaspack/rust@3.6.0
170
+ - @atlaspack/plugin@2.14.24
171
+
172
+ ## 2.14.23
173
+
174
+ ### Patch Changes
175
+
176
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
177
+ - @atlaspack/rust@3.5.0
178
+ - @atlaspack/plugin@2.14.23
179
+
180
+ ## 2.14.22
181
+
182
+ ### Patch Changes
183
+
184
+ - [#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
185
+
186
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
187
+ - @atlaspack/diagnostic@2.14.2
188
+ - @atlaspack/plugin@2.14.22
189
+ - @atlaspack/rust@3.4.2
190
+
191
+ ## 2.14.21
192
+
193
+ ### Patch Changes
194
+
195
+ - Updated dependencies []:
196
+ - @atlaspack/plugin@2.14.21
197
+
198
+ ## 2.14.20
199
+
200
+ ### Patch Changes
201
+
202
+ - [#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
203
+
204
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
205
+ - @atlaspack/plugin@2.14.20
206
+
207
+ ## 2.14.19
208
+
209
+ ### Patch Changes
210
+
211
+ - Updated dependencies []:
212
+ - @atlaspack/plugin@2.14.19
213
+
214
+ ## 2.14.18
215
+
216
+ ### Patch Changes
217
+
218
+ - Updated dependencies [[`becf977`](https://github.com/atlassian-labs/atlaspack/commit/becf977f625d5ee46dae3d4c679f173bf5f40cc0), [`f0f7c71`](https://github.com/atlassian-labs/atlaspack/commit/f0f7c7168a1d3d18c6f30d2daed611275692b7c5)]:
219
+ - @atlaspack/rust@3.4.1
220
+ - @atlaspack/plugin@2.14.18
221
+
222
+ ## 2.14.17
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies [[`c75bf55`](https://github.com/atlassian-labs/atlaspack/commit/c75bf553fff4decc285b5fd499a275853b18f8f2)]:
227
+ - @atlaspack/rust@3.4.0
228
+ - @atlaspack/plugin@2.14.17
229
+
230
+ ## 2.14.16
231
+
232
+ ### Patch Changes
233
+
234
+ - Updated dependencies []:
235
+ - @atlaspack/plugin@2.14.16
236
+
237
+ ## 2.14.15
238
+
239
+ ### Patch Changes
240
+
241
+ - Updated dependencies []:
242
+ - @atlaspack/plugin@2.14.15
243
+
244
+ ## 2.14.14
245
+
246
+ ### Patch Changes
247
+
248
+ - Updated dependencies []:
249
+ - @atlaspack/plugin@2.14.14
250
+
251
+ ## 2.14.13
252
+
253
+ ### Patch Changes
254
+
255
+ - Updated dependencies []:
256
+ - @atlaspack/plugin@2.14.13
257
+
258
+ ## 2.14.12
259
+
260
+ ### Patch Changes
261
+
262
+ - Updated dependencies []:
263
+ - @atlaspack/plugin@2.14.12
264
+
265
+ ## 2.14.11
266
+
267
+ ### Patch Changes
268
+
269
+ - Updated dependencies []:
270
+ - @atlaspack/plugin@2.14.11
271
+
272
+ ## 2.14.10
273
+
274
+ ### Patch Changes
275
+
276
+ - Updated dependencies [[`35fdd4b`](https://github.com/atlassian-labs/atlaspack/commit/35fdd4b52da0af20f74667f7b8adfb2f90279b7c), [`6dd4ccb`](https://github.com/atlassian-labs/atlaspack/commit/6dd4ccb753541de32322d881f973d571dd57e4ca)]:
277
+ - @atlaspack/rust@3.3.5
278
+ - @atlaspack/plugin@2.14.10
279
+
280
+ ## 2.14.9
281
+
282
+ ### Patch Changes
283
+
284
+ - 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)]:
285
+ - @atlaspack/rust@3.3.4
286
+ - @atlaspack/plugin@2.14.9
287
+
3
288
  ## 2.14.8
4
289
 
5
290
  ### Patch Changes
@@ -0,0 +1,65 @@
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
+ const plugin_1 = require("@atlaspack/plugin");
7
+ const nullthrows_1 = __importDefault(require("nullthrows"));
8
+ const semver_1 = __importDefault(require("semver"));
9
+ const posthtml_parser_1 = require("posthtml-parser");
10
+ const posthtml_render_1 = require("posthtml-render");
11
+ const dependencies_1 = __importDefault(require("./dependencies"));
12
+ const inline_1 = __importDefault(require("./inline"));
13
+ const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
14
+ exports.default = new plugin_1.Transformer({
15
+ canReuseAST({ ast }) {
16
+ return ast.type === 'posthtml' && semver_1.default.satisfies(ast.version, '^0.4.0');
17
+ },
18
+ async parse({ asset }) {
19
+ return {
20
+ type: 'posthtml',
21
+ version: '0.4.1',
22
+ program: (0, posthtml_parser_1.parser)(await asset.getCode(), {
23
+ directives: [
24
+ {
25
+ name: /^\?/,
26
+ start: '<',
27
+ end: '>',
28
+ },
29
+ ],
30
+ sourceLocations: true,
31
+ xmlMode: true,
32
+ }),
33
+ };
34
+ },
35
+ async transform({ asset }) {
36
+ asset.bundleBehavior = 'isolated';
37
+ const ast = (0, nullthrows_1.default)(await asset.getAST());
38
+ try {
39
+ (0, dependencies_1.default)(asset, ast);
40
+ }
41
+ catch (errors) {
42
+ throw new diagnostic_1.default({
43
+ // @ts-expect-error TS7006
44
+ diagnostic: errors.map((error) => ({
45
+ message: error.message,
46
+ origin: '@atlaspack/transformer-svg',
47
+ codeFrames: [
48
+ {
49
+ filePath: error.filePath,
50
+ language: 'svg',
51
+ codeHighlights: [error.loc],
52
+ },
53
+ ],
54
+ })),
55
+ });
56
+ }
57
+ const inlineAssets = (0, inline_1.default)(asset, ast);
58
+ return [asset, ...inlineAssets];
59
+ },
60
+ generate({ ast }) {
61
+ return {
62
+ content: (0, posthtml_render_1.render)(ast.program),
63
+ };
64
+ },
65
+ });
@@ -0,0 +1,155 @@
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.parseFuncIRI = parseFuncIRI;
7
+ exports.default = collectDependencies;
8
+ const posthtml_1 = __importDefault(require("posthtml"));
9
+ // A list of all attributes that may produce a dependency
10
+ // Based on https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
11
+ // See also https://www.w3.org/TR/SVG/attindex.html and https://www.w3.org/TR/SVG11/attindex.html
12
+ // SVG animation elements are excluded because they may only reference elements in the same document: https://www.w3.org/TR/SVG/linking.html#processingURL-fetch
13
+ const HREF_ATTRS = [
14
+ 'a',
15
+ 'use',
16
+ 'feImage',
17
+ 'image',
18
+ 'linearGradient',
19
+ 'radialGradient',
20
+ 'pattern',
21
+ 'mpath',
22
+ 'textPath',
23
+ 'script',
24
+ ];
25
+ const ATTRS = {
26
+ href: HREF_ATTRS,
27
+ 'xlink:href': [
28
+ ...HREF_ATTRS,
29
+ 'altGlyph',
30
+ 'cursor',
31
+ 'filter',
32
+ 'font-face-uri',
33
+ 'glyphRef',
34
+ 'tref',
35
+ 'color-profile',
36
+ ],
37
+ };
38
+ // Attributes that allow url() to reference another element, either in the same document or a different one.
39
+ // https://www.w3.org/TR/SVG11/linking.html#processingIRI
40
+ const FUNC_IRI_ATTRS = new Set([
41
+ 'fill',
42
+ 'stroke',
43
+ 'clip-path',
44
+ 'color-profile',
45
+ 'cursor',
46
+ 'filter',
47
+ 'marker',
48
+ 'marker-start',
49
+ 'marker-mid',
50
+ 'marker-end',
51
+ 'mask',
52
+ // SVG2 - https://www.w3.org/TR/SVG/linking.html#processingURL-validity
53
+ 'shape-inside',
54
+ 'shape-subtract',
55
+ 'mask-image',
56
+ ]);
57
+ // https://www.w3.org/TR/css3-values/#urls
58
+ const FUNC_IRI_RE = /^url\((?:((['"])(.*?)\2(\s+.*)?)|((?:\\[\s'"]|[^\s'"])+))\)$/;
59
+ const ESCAPE_RE = /\\(.|\n|\r|\u2028|\u2029)/;
60
+ function parseFuncIRI(value) {
61
+ let m = value.match(FUNC_IRI_RE);
62
+ if (m) {
63
+ let url = (m[3] || m[5]).replace(ESCAPE_RE, '$1');
64
+ let modifier = m[4] ?? '';
65
+ return [url, modifier];
66
+ }
67
+ }
68
+ // Options to be passed to `addDependency` for certain tags + attributes
69
+ const OPTIONS = {
70
+ a: {
71
+ href: { needsStableName: true },
72
+ 'xlink:href': { needsStableName: true },
73
+ },
74
+ };
75
+ function collectDependencies(asset, ast) {
76
+ let isDirty = false;
77
+ // @ts-expect-error TS7034
78
+ const errors = [];
79
+ // @ts-expect-error TS2339
80
+ (0, posthtml_1.default)().walk.call(ast.program, (node) => {
81
+ // Ideally we'd have location information for specific attributes...
82
+ let getLoc = () => node.location
83
+ ? {
84
+ filePath: asset.filePath,
85
+ start: node.location.start,
86
+ end: node.location.end,
87
+ }
88
+ : undefined;
89
+ if (typeof node === 'string' && node.startsWith('<?xml-stylesheet')) {
90
+ return node.replace(/(?<=(?:^|\s)href\s*=\s*")(.+?)(?=")/i, (href) => {
91
+ isDirty = true;
92
+ return asset.addURLDependency(href, { priority: 'parallel' });
93
+ });
94
+ }
95
+ const { tag, attrs } = node;
96
+ if (!attrs) {
97
+ return node;
98
+ }
99
+ for (const attr in attrs) {
100
+ // Check for id references
101
+ if (attrs[attr][0] === '#') {
102
+ continue;
103
+ }
104
+ // @ts-expect-error TS7053
105
+ const elements = ATTRS[attr];
106
+ if (elements && elements.includes(node.tag)) {
107
+ // Check for empty string
108
+ if (attrs[attr].length === 0) {
109
+ errors.push({
110
+ message: `'${attr}' should not be empty string`,
111
+ filePath: asset.filePath,
112
+ loc: node.location,
113
+ });
114
+ }
115
+ // @ts-expect-error TS7053
116
+ let options = OPTIONS[tag]?.[attr];
117
+ if (node.tag === 'script') {
118
+ options = {
119
+ priority: 'parallel',
120
+ env: {
121
+ sourceType: attrs.type === 'module' ? 'module' : 'script',
122
+ // SVG script elements do not support type="module" natively yet.
123
+ outputFormat: 'global',
124
+ loc: getLoc(),
125
+ },
126
+ };
127
+ delete attrs.type;
128
+ }
129
+ attrs[attr] = asset.addURLDependency(attrs[attr], {
130
+ ...options,
131
+ loc: getLoc(),
132
+ });
133
+ isDirty = true;
134
+ }
135
+ if (FUNC_IRI_ATTRS.has(attr)) {
136
+ let parsed = parseFuncIRI(attrs[attr]);
137
+ if (parsed) {
138
+ let depId = asset.addURLDependency(parsed[0], {
139
+ loc: getLoc(),
140
+ });
141
+ attrs[attr] = `url('${depId}'${parsed[1]})`;
142
+ isDirty = true;
143
+ }
144
+ }
145
+ }
146
+ return node;
147
+ });
148
+ if (errors.length > 0) {
149
+ // @ts-expect-error TS7005
150
+ throw errors;
151
+ }
152
+ if (isDirty) {
153
+ asset.setAST(ast);
154
+ }
155
+ }
package/dist/inline.js ADDED
@@ -0,0 +1,124 @@
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.default = extractInlineAssets;
7
+ const rust_1 = require("@atlaspack/rust");
8
+ const posthtml_1 = __importDefault(require("posthtml"));
9
+ const SCRIPT_TYPES = {
10
+ 'application/ecmascript': 'js',
11
+ 'application/javascript': 'js',
12
+ 'text/javascript': 'js',
13
+ module: 'js',
14
+ };
15
+ function extractInlineAssets(asset, ast) {
16
+ const program = ast.program;
17
+ let key = 0;
18
+ // Extract <style> elements for processing.
19
+ const parts = [];
20
+ // @ts-expect-error TS2339
21
+ (0, posthtml_1.default)().walk.call(program, (node) => {
22
+ if (node.tag === 'style' || node.tag === 'script') {
23
+ const value = node.content && node.content.join('');
24
+ if (!value) {
25
+ return node;
26
+ }
27
+ let type, env;
28
+ if (node.tag === 'style') {
29
+ if (node.attrs && node.attrs.type != null) {
30
+ type = node.attrs.type.split('/')[1];
31
+ }
32
+ else {
33
+ type = 'css';
34
+ }
35
+ }
36
+ else if (node.tag === 'script') {
37
+ // @ts-expect-error TS7053
38
+ if (node.attrs && SCRIPT_TYPES[node.attrs.type]) {
39
+ // @ts-expect-error TS7053
40
+ type = SCRIPT_TYPES[node.attrs.type];
41
+ }
42
+ else if (node.attrs) {
43
+ type = node.attrs.type.split('/')[1];
44
+ }
45
+ else {
46
+ type = 'js';
47
+ }
48
+ env = {
49
+ sourceType: node.attrs && node.attrs.type === 'module' ? 'module' : 'script',
50
+ // SVG script elements do not support type="module" natively yet.
51
+ outputFormat: 'global',
52
+ loc: node.location
53
+ ? {
54
+ filePath: asset.filePath,
55
+ start: node.location.start,
56
+ end: node.location.end,
57
+ }
58
+ : undefined,
59
+ };
60
+ }
61
+ if (!type) {
62
+ return node;
63
+ }
64
+ let attrs = node.attrs;
65
+ if (!attrs) {
66
+ attrs = {};
67
+ node.attrs = attrs;
68
+ }
69
+ // Inform packager to remove type, since CSS and JS are the defaults.
70
+ delete attrs.type;
71
+ let parcelKey;
72
+ // allow a script/style tag to declare its key
73
+ if (attrs['data-parcel-key']) {
74
+ parcelKey = attrs['data-parcel-key'];
75
+ }
76
+ else {
77
+ parcelKey = (0, rust_1.hashString)(`${asset.id}:${key++}`);
78
+ }
79
+ // insert parcelId to allow us to retrieve node during packaging
80
+ attrs['data-parcel-key'] = parcelKey;
81
+ asset.setAST(ast); // mark dirty
82
+ asset.addDependency({
83
+ specifier: parcelKey,
84
+ specifierType: 'esm',
85
+ });
86
+ parts.push({
87
+ type,
88
+ content: value,
89
+ uniqueKey: parcelKey,
90
+ bundleBehavior: 'inline',
91
+ // @ts-expect-error TS2322
92
+ env,
93
+ meta: {
94
+ type: 'tag',
95
+ node,
96
+ startLine: node.location?.start.line,
97
+ },
98
+ });
99
+ }
100
+ // Process inline style attributes.
101
+ let attrs = node.attrs;
102
+ let style = attrs?.style;
103
+ if (attrs != null && style != null) {
104
+ let parcelKey = (0, rust_1.hashString)(`${asset.id}:${key++}`);
105
+ attrs.style = asset.addDependency({
106
+ specifier: parcelKey,
107
+ specifierType: 'esm',
108
+ });
109
+ asset.setAST(ast); // mark dirty
110
+ parts.push({
111
+ type: 'css',
112
+ content: style,
113
+ uniqueKey: parcelKey,
114
+ bundleBehavior: 'inline',
115
+ meta: {
116
+ type: 'attr',
117
+ node,
118
+ },
119
+ });
120
+ }
121
+ return node;
122
+ });
123
+ return parts;
124
+ }
@@ -81,6 +81,7 @@ var _default = exports.default = new (_plugin().Transformer)({
81
81
  (0, _dependencies.default)(asset, ast);
82
82
  } catch (errors) {
83
83
  throw new (_diagnostic().default)({
84
+ // @ts-expect-error TS7006
84
85
  diagnostic: errors.map(error => ({
85
86
  message: error.message,
86
87
  origin: '@atlaspack/transformer-svg',
@@ -54,7 +54,9 @@ const OPTIONS = {
54
54
  };
55
55
  function collectDependencies(asset, ast) {
56
56
  let isDirty = false;
57
+ // @ts-expect-error TS7034
57
58
  const errors = [];
59
+ // @ts-expect-error TS2339
58
60
  (0, _posthtml().default)().walk.call(ast.program, node => {
59
61
  // Ideally we'd have location information for specific attributes...
60
62
  let getLoc = () => node.location ? {
@@ -82,6 +84,8 @@ function collectDependencies(asset, ast) {
82
84
  if (attrs[attr][0] === '#') {
83
85
  continue;
84
86
  }
87
+
88
+ // @ts-expect-error TS7053
85
89
  const elements = ATTRS[attr];
86
90
  if (elements && elements.includes(node.tag)) {
87
91
  var _OPTIONS$tag;
@@ -93,6 +97,8 @@ function collectDependencies(asset, ast) {
93
97
  loc: node.location
94
98
  });
95
99
  }
100
+
101
+ // @ts-expect-error TS7053
96
102
  let options = (_OPTIONS$tag = OPTIONS[tag]) === null || _OPTIONS$tag === void 0 ? void 0 : _OPTIONS$tag[attr];
97
103
  if (node.tag === 'script') {
98
104
  options = {
@@ -126,6 +132,7 @@ function collectDependencies(asset, ast) {
126
132
  return node;
127
133
  });
128
134
  if (errors.length > 0) {
135
+ // @ts-expect-error TS7005
129
136
  throw errors;
130
137
  }
131
138
  if (isDirty) {