@atlaspack/packager-svg 2.14.5-canary.20 → 2.14.5-canary.200

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,229 @@
1
1
  # @atlaspack/packager-svg
2
2
 
3
+ ## 2.14.31
4
+
5
+ ### Patch Changes
6
+
7
+ - [#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.
8
+
9
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
10
+ - @atlaspack/plugin@2.14.31
11
+ - @atlaspack/types@2.15.21
12
+ - @atlaspack/utils@2.19.3
13
+
14
+ ## 2.14.30
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies []:
19
+ - @atlaspack/utils@2.19.2
20
+ - @atlaspack/plugin@2.14.30
21
+ - @atlaspack/types@2.15.20
22
+
23
+ ## 2.14.29
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies []:
28
+ - @atlaspack/utils@2.19.1
29
+ - @atlaspack/plugin@2.14.29
30
+ - @atlaspack/types@2.15.19
31
+
32
+ ## 2.14.28
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
37
+ - @atlaspack/utils@2.19.0
38
+ - @atlaspack/plugin@2.14.28
39
+ - @atlaspack/types@2.15.18
40
+
41
+ ## 2.14.27
42
+
43
+ ### Patch Changes
44
+
45
+ - Updated dependencies []:
46
+ - @atlaspack/utils@2.18.4
47
+ - @atlaspack/plugin@2.14.27
48
+ - @atlaspack/types@2.15.17
49
+
50
+ ## 2.14.26
51
+
52
+ ### Patch Changes
53
+
54
+ - [#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
55
+
56
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
57
+ - @atlaspack/plugin@2.14.26
58
+ - @atlaspack/types@2.15.16
59
+ - @atlaspack/utils@2.18.3
60
+
61
+ ## 2.14.25
62
+
63
+ ### Patch Changes
64
+
65
+ - Updated dependencies []:
66
+ - @atlaspack/utils@2.18.2
67
+ - @atlaspack/plugin@2.14.25
68
+ - @atlaspack/types@2.15.15
69
+
70
+ ## 2.14.24
71
+
72
+ ### Patch Changes
73
+
74
+ - Updated dependencies []:
75
+ - @atlaspack/utils@2.18.1
76
+ - @atlaspack/plugin@2.14.24
77
+ - @atlaspack/types@2.15.14
78
+
79
+ ## 2.14.23
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
84
+ - @atlaspack/utils@2.18.0
85
+ - @atlaspack/types@2.15.13
86
+ - @atlaspack/plugin@2.14.23
87
+
88
+ ## 2.14.22
89
+
90
+ ### Patch Changes
91
+
92
+ - [#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
93
+
94
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
95
+ - @atlaspack/plugin@2.14.22
96
+ - @atlaspack/types@2.15.12
97
+ - @atlaspack/utils@2.17.4
98
+
99
+ ## 2.14.21
100
+
101
+ ### Patch Changes
102
+
103
+ - Updated dependencies []:
104
+ - @atlaspack/types@2.15.11
105
+ - @atlaspack/utils@2.17.3
106
+ - @atlaspack/plugin@2.14.21
107
+
108
+ ## 2.14.20
109
+
110
+ ### Patch Changes
111
+
112
+ - [#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
113
+
114
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
115
+ - @atlaspack/plugin@2.14.20
116
+ - @atlaspack/utils@2.17.2
117
+ - @atlaspack/types@2.15.10
118
+
119
+ ## 2.14.19
120
+
121
+ ### Patch Changes
122
+
123
+ - Updated dependencies []:
124
+ - @atlaspack/utils@2.17.1
125
+ - @atlaspack/types@2.15.9
126
+ - @atlaspack/plugin@2.14.19
127
+
128
+ ## 2.14.18
129
+
130
+ ### Patch Changes
131
+
132
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
133
+ - @atlaspack/utils@2.17.0
134
+ - @atlaspack/types@2.15.8
135
+ - @atlaspack/plugin@2.14.18
136
+
137
+ ## 2.14.17
138
+
139
+ ### Patch Changes
140
+
141
+ - Updated dependencies []:
142
+ - @atlaspack/utils@2.16.1
143
+ - @atlaspack/types@2.15.7
144
+ - @atlaspack/plugin@2.14.17
145
+
146
+ ## 2.14.16
147
+
148
+ ### Patch Changes
149
+
150
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
151
+ - @atlaspack/utils@2.16.0
152
+ - @atlaspack/types@2.15.6
153
+ - @atlaspack/plugin@2.14.16
154
+
155
+ ## 2.14.15
156
+
157
+ ### Patch Changes
158
+
159
+ - Updated dependencies []:
160
+ - @atlaspack/utils@2.15.3
161
+ - @atlaspack/types@2.15.5
162
+ - @atlaspack/plugin@2.14.15
163
+
164
+ ## 2.14.14
165
+
166
+ ### Patch Changes
167
+
168
+ - Updated dependencies []:
169
+ - @atlaspack/utils@2.15.2
170
+ - @atlaspack/types@2.15.4
171
+ - @atlaspack/plugin@2.14.14
172
+
173
+ ## 2.14.13
174
+
175
+ ### Patch Changes
176
+
177
+ - Updated dependencies []:
178
+ - @atlaspack/types@2.15.3
179
+ - @atlaspack/utils@2.15.1
180
+ - @atlaspack/plugin@2.14.13
181
+
182
+ ## 2.14.12
183
+
184
+ ### Patch Changes
185
+
186
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
187
+ - @atlaspack/utils@2.15.0
188
+ - @atlaspack/types@2.15.2
189
+ - @atlaspack/plugin@2.14.12
190
+
191
+ ## 2.14.11
192
+
193
+ ### Patch Changes
194
+
195
+ - Updated dependencies []:
196
+ - @atlaspack/utils@2.14.11
197
+ - @atlaspack/types@2.15.1
198
+ - @atlaspack/plugin@2.14.11
199
+
200
+ ## 2.14.10
201
+
202
+ ### Patch Changes
203
+
204
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b), [`1e32d4e`](https://github.com/atlassian-labs/atlaspack/commit/1e32d4eae6b3af3968e8a0ef97d35b4347fd4196)]:
205
+ - @atlaspack/types@2.15.0
206
+ - @atlaspack/plugin@2.14.10
207
+ - @atlaspack/utils@2.14.10
208
+
209
+ ## 2.14.9
210
+
211
+ ### Patch Changes
212
+
213
+ - Updated dependencies []:
214
+ - @atlaspack/utils@2.14.9
215
+ - @atlaspack/types@2.14.9
216
+ - @atlaspack/plugin@2.14.9
217
+
218
+ ## 2.14.8
219
+
220
+ ### Patch Changes
221
+
222
+ - Updated dependencies []:
223
+ - @atlaspack/utils@2.14.8
224
+ - @atlaspack/types@2.14.8
225
+ - @atlaspack/plugin@2.14.8
226
+
3
227
  ## 2.14.7
4
228
 
5
229
  ### Patch Changes
@@ -39,6 +39,7 @@ var _default = exports.default = new (_plugin().Packager)({
39
39
  bundleGraph,
40
40
  getInlineBundleContents
41
41
  }) {
42
+ // @ts-expect-error TS2552
42
43
  const assets = [];
43
44
  bundle.traverseAssets(asset => {
44
45
  assets.push(asset);
@@ -52,16 +53,19 @@ var _default = exports.default = new (_plugin().Packager)({
52
53
  })))];
53
54
  const asset = assets[0];
54
55
  const code = await asset.getCode();
55
- let {
56
- html: svg
57
- } = await (0, _posthtml().default)([tree => insertBundleReferences(referencedBundles, tree), tree => replaceInlineAssetContent(bundleGraph, getInlineBundleContents, tree)]).process(code, {
56
+ const options = {
58
57
  directives: [{
59
58
  name: /^\?/,
60
59
  start: '<',
61
60
  end: '>'
62
61
  }],
63
62
  xmlMode: true
64
- });
63
+ };
64
+ let {
65
+ html: svg
66
+ } = await (0, _posthtml().default)([tree => insertBundleReferences(referencedBundles, tree), tree => replaceInlineAssetContent(bundleGraph, getInlineBundleContents, tree)
67
+ // @ts-expect-error TS2559
68
+ ]).process(code, options);
65
69
  const {
66
70
  contents,
67
71
  map
@@ -87,6 +91,7 @@ var _default = exports.default = new (_plugin().Packager)({
87
91
  });
88
92
  async function replaceInlineAssetContent(bundleGraph, getInlineBundleContents, tree) {
89
93
  const inlineNodes = [];
94
+ // @ts-expect-error TS7006
90
95
  tree.walk(node => {
91
96
  if (node.attrs && node.attrs['data-parcel-key']) {
92
97
  inlineNodes.push(node);
@@ -150,6 +155,7 @@ function insertBundleReferences(siblingBundles, tree) {
150
155
  }
151
156
  tree.unshift(...stylesheets);
152
157
  if (scripts.length > 0) {
158
+ // @ts-expect-error TS7006
153
159
  tree.match({
154
160
  tag: 'svg'
155
161
  }, node => {
@@ -0,0 +1,3 @@
1
+ import { Packager } from '@atlaspack/plugin';
2
+ declare const _default: Packager<unknown, unknown>;
3
+ export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-svg",
3
- "version": "2.14.5-canary.20+30f60175b",
3
+ "version": "2.14.5-canary.200+10ee3fa5b",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,17 +9,22 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/SVGPackager.js",
13
- "source": "src/SVGPackager.js",
12
+ "main": "./lib/SVGPackager.js",
13
+ "source": "./src/SVGPackager.ts",
14
+ "types": "./lib/types/SVGPackager.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/plugin": "2.14.5-canary.20+30f60175b",
19
- "@atlaspack/types": "2.14.5-canary.20+30f60175b",
20
- "@atlaspack/utils": "2.14.5-canary.20+30f60175b",
19
+ "@atlaspack/plugin": "2.14.5-canary.200+10ee3fa5b",
20
+ "@atlaspack/types": "2.14.5-canary.200+10ee3fa5b",
21
+ "@atlaspack/utils": "2.14.5-canary.200+10ee3fa5b",
21
22
  "posthtml": "^0.16.4"
22
23
  },
23
24
  "type": "commonjs",
24
- "gitHead": "30f60175ba4d272c5fc193973c63bc298584775b"
25
- }
25
+ "scripts": {
26
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
27
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
28
+ },
29
+ "gitHead": "10ee3fa5b75a92acde8973673d9b3c5b6f3958e5"
30
+ }
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  import type {Bundle, BundleGraph, NamedBundle} from '@atlaspack/types';
4
2
  import assert from 'assert';
5
3
  import {Packager} from '@atlaspack/plugin';
@@ -12,9 +10,10 @@ import {
12
10
  setSymmetricDifference,
13
11
  } from '@atlaspack/utils';
14
12
 
15
- export default (new Packager({
13
+ export default new Packager({
16
14
  async package({bundle, bundleGraph, getInlineBundleContents}) {
17
- const assets = [];
15
+ // @ts-expect-error TS2552
16
+ const assets: Array<Asset> = [];
18
17
  bundle.traverseAssets((asset) => {
19
18
  assets.push(asset);
20
19
  });
@@ -45,12 +44,13 @@ export default (new Packager({
45
44
  },
46
45
  ],
47
46
  xmlMode: true,
48
- };
47
+ } as const;
49
48
 
50
49
  let {html: svg} = await posthtml([
51
- (tree) => insertBundleReferences(referencedBundles, tree),
52
- (tree) =>
50
+ (tree: any) => insertBundleReferences(referencedBundles, tree),
51
+ (tree: any) =>
53
52
  replaceInlineAssetContent(bundleGraph, getInlineBundleContents, tree),
53
+ // @ts-expect-error TS2559
54
54
  ]).process(code, options);
55
55
 
56
56
  const {contents, map} = replaceURLReferences({
@@ -73,14 +73,21 @@ export default (new Packager({
73
73
  map,
74
74
  });
75
75
  },
76
- }): Packager);
76
+ }) as Packager<unknown, unknown>;
77
77
 
78
78
  async function replaceInlineAssetContent(
79
79
  bundleGraph: BundleGraph<NamedBundle>,
80
- getInlineBundleContents,
81
- tree,
80
+ getInlineBundleContents: (
81
+ arg1: Bundle,
82
+ arg2: BundleGraph<NamedBundle>,
83
+ // @ts-expect-error TS2304
84
+ ) => Async<{
85
+ contents: Blob;
86
+ }>,
87
+ tree: any,
82
88
  ) {
83
- const inlineNodes = [];
89
+ const inlineNodes: Array<any> = [];
90
+ // @ts-expect-error TS7006
84
91
  tree.walk((node) => {
85
92
  if (node.attrs && node.attrs['data-parcel-key']) {
86
93
  inlineNodes.push(node);
@@ -118,10 +125,16 @@ async function replaceInlineAssetContent(
118
125
 
119
126
  async function getAssetContent(
120
127
  bundleGraph: BundleGraph<NamedBundle>,
121
- getInlineBundleContents,
122
- assetId,
128
+ getInlineBundleContents: (
129
+ arg1: Bundle,
130
+ arg2: BundleGraph<NamedBundle>,
131
+ // @ts-expect-error TS2304
132
+ ) => Async<{
133
+ contents: Blob;
134
+ }>,
135
+ assetId: any,
123
136
  ) {
124
- let inlineBundle: ?Bundle;
137
+ let inlineBundle: Bundle | null | undefined;
125
138
  bundleGraph.traverseBundles((bundle, context, {stop}) => {
126
139
  const entryAssets = bundle.getEntryAssets();
127
140
  if (entryAssets.some((a) => a.uniqueKey === assetId)) {
@@ -139,9 +152,17 @@ async function getAssetContent(
139
152
  return {bundle: inlineBundle, contents: bundleResult.contents};
140
153
  }
141
154
 
142
- function insertBundleReferences(siblingBundles, tree) {
143
- let scripts = [];
144
- let stylesheets = [];
155
+ function insertBundleReferences(siblingBundles: Array<NamedBundle>, tree: any) {
156
+ let scripts: Array<
157
+ | any
158
+ | {
159
+ attrs: {
160
+ href: string;
161
+ };
162
+ tag: string;
163
+ }
164
+ > = [];
165
+ let stylesheets: Array<any | string> = [];
145
166
 
146
167
  for (let bundle of siblingBundles) {
147
168
  if (bundle.type === 'css') {
@@ -162,6 +183,7 @@ function insertBundleReferences(siblingBundles, tree) {
162
183
 
163
184
  tree.unshift(...stylesheets);
164
185
  if (scripts.length > 0) {
186
+ // @ts-expect-error TS7006
165
187
  tree.match({tag: 'svg'}, (node) => {
166
188
  node.content.unshift(...scripts);
167
189
  });
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }