@atlaspack/optimizer-htmlnano 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,181 @@
1
1
  # @atlaspack/optimizer-htmlnano
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
+
12
+ ## 2.14.30
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies []:
17
+ - @atlaspack/plugin@2.14.30
18
+
19
+ ## 2.14.29
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies []:
24
+ - @atlaspack/plugin@2.14.29
25
+
26
+ ## 2.14.28
27
+
28
+ ### Patch Changes
29
+
30
+ - Updated dependencies []:
31
+ - @atlaspack/plugin@2.14.28
32
+
33
+ ## 2.14.27
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies []:
38
+ - @atlaspack/plugin@2.14.27
39
+
40
+ ## 2.14.26
41
+
42
+ ### Patch Changes
43
+
44
+ - [#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
45
+
46
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd)]:
47
+ - @atlaspack/plugin@2.14.26
48
+
49
+ ## 2.14.25
50
+
51
+ ### Patch Changes
52
+
53
+ - Updated dependencies []:
54
+ - @atlaspack/plugin@2.14.25
55
+
56
+ ## 2.14.24
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies []:
61
+ - @atlaspack/plugin@2.14.24
62
+
63
+ ## 2.14.23
64
+
65
+ ### Patch Changes
66
+
67
+ - Updated dependencies []:
68
+ - @atlaspack/plugin@2.14.23
69
+
70
+ ## 2.14.22
71
+
72
+ ### Patch Changes
73
+
74
+ - [#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
75
+
76
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
77
+ - @atlaspack/plugin@2.14.22
78
+
79
+ ## 2.14.21
80
+
81
+ ### Patch Changes
82
+
83
+ - Updated dependencies []:
84
+ - @atlaspack/plugin@2.14.21
85
+
86
+ ## 2.14.20
87
+
88
+ ### Patch Changes
89
+
90
+ - [#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
91
+
92
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
93
+ - @atlaspack/plugin@2.14.20
94
+
95
+ ## 2.14.19
96
+
97
+ ### Patch Changes
98
+
99
+ - Updated dependencies []:
100
+ - @atlaspack/plugin@2.14.19
101
+
102
+ ## 2.14.18
103
+
104
+ ### Patch Changes
105
+
106
+ - Updated dependencies []:
107
+ - @atlaspack/plugin@2.14.18
108
+
109
+ ## 2.14.17
110
+
111
+ ### Patch Changes
112
+
113
+ - Updated dependencies []:
114
+ - @atlaspack/plugin@2.14.17
115
+
116
+ ## 2.14.16
117
+
118
+ ### Patch Changes
119
+
120
+ - Updated dependencies []:
121
+ - @atlaspack/plugin@2.14.16
122
+
123
+ ## 2.14.15
124
+
125
+ ### Patch Changes
126
+
127
+ - Updated dependencies []:
128
+ - @atlaspack/plugin@2.14.15
129
+
130
+ ## 2.14.14
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies []:
135
+ - @atlaspack/plugin@2.14.14
136
+
137
+ ## 2.14.13
138
+
139
+ ### Patch Changes
140
+
141
+ - Updated dependencies []:
142
+ - @atlaspack/plugin@2.14.13
143
+
144
+ ## 2.14.12
145
+
146
+ ### Patch Changes
147
+
148
+ - Updated dependencies []:
149
+ - @atlaspack/plugin@2.14.12
150
+
151
+ ## 2.14.11
152
+
153
+ ### Patch Changes
154
+
155
+ - Updated dependencies []:
156
+ - @atlaspack/plugin@2.14.11
157
+
158
+ ## 2.14.10
159
+
160
+ ### Patch Changes
161
+
162
+ - Updated dependencies []:
163
+ - @atlaspack/plugin@2.14.10
164
+
165
+ ## 2.14.9
166
+
167
+ ### Patch Changes
168
+
169
+ - Updated dependencies []:
170
+ - @atlaspack/plugin@2.14.9
171
+
172
+ ## 2.14.8
173
+
174
+ ### Patch Changes
175
+
176
+ - Updated dependencies []:
177
+ - @atlaspack/plugin@2.14.8
178
+
3
179
  ## 2.14.7
4
180
 
5
181
  ### Patch Changes
@@ -34,6 +34,8 @@ function _path() {
34
34
  }
35
35
  var _svgMappings = require("./svgMappings");
36
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
37
+ // @ts-expect-error TS2724
38
+ // @ts-expect-error TS7016
37
39
  var _default = exports.default = new (_plugin().Optimizer)({
38
40
  async loadConfig({
39
41
  config,
@@ -60,8 +62,6 @@ var _default = exports.default = new (_plugin().Optimizer)({
60
62
  throw new Error('HTMLNanoOptimizer: Only string contents are currently supported');
61
63
  }
62
64
  const clonedConfig = config || {};
63
-
64
- // $FlowFixMe
65
65
  const presets = _htmlnano().default.presets;
66
66
  const preset = typeof clonedConfig.preset === 'string' ? presets[clonedConfig.preset] : {};
67
67
  delete clonedConfig.preset;
@@ -103,12 +103,13 @@ var _default = exports.default = new (_plugin().Optimizer)({
103
103
 
104
104
  let plugins = [(0, _htmlnano().default)(htmlNanoConfig)];
105
105
 
106
- // $FlowFixMe
106
+ // @ts-expect-error TS18046
107
107
  if (htmlNanoConfig.minifySvg !== false) {
108
108
  plugins.unshift(mapSVG);
109
109
  }
110
110
  return {
111
111
  contents: (await (0, _posthtml().default)(plugins).process(contents, {
112
+ // @ts-expect-error TS2353
112
113
  xmlMode: bundle.type === 'xhtml',
113
114
  closingSingleTag: bundle.type === 'xhtml' ? 'slash' : undefined
114
115
  })).html
@@ -120,7 +121,6 @@ var _default = exports.default = new (_plugin().Optimizer)({
120
121
  function mapSVG(node, inSVG = false) {
121
122
  if (Array.isArray(node)) {
122
123
  for (let i = 0; i < node.length; i++) {
123
- // $FlowFixMe
124
124
  node[i] = mapSVG(node[i], inSVG);
125
125
  }
126
126
  } else if (node && typeof node === 'object') {
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.SVG_TAG_NAMES = exports.SVG_ATTRS = void 0;
7
7
  // Based on parse5: https://github.com/inikulin/parse5/blob/252819607421a5741cf745bb60c404f023531b0d/packages/parse5/lib/common/foreign-content.js#L54
8
+
8
9
  const SVG_TAG_NAMES = exports.SVG_TAG_NAMES = {
9
10
  altglyph: 'altGlyph',
10
11
  altglyphdef: 'altGlyphDef',
@@ -0,0 +1,3 @@
1
+ import { Optimizer } from '@atlaspack/plugin';
2
+ declare const _default: Optimizer<unknown, unknown>;
3
+ export default _default;
@@ -0,0 +1,6 @@
1
+ export declare const SVG_TAG_NAMES: {
2
+ [key: string]: string;
3
+ };
4
+ export declare const SVG_ATTRS: {
5
+ [key: string]: string;
6
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/optimizer-htmlnano",
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,18 +9,23 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/HTMLNanoOptimizer.js",
13
- "source": "src/HTMLNanoOptimizer.js",
12
+ "main": "./lib/HTMLNanoOptimizer.js",
13
+ "source": "./src/HTMLNanoOptimizer.ts",
14
+ "types": "./lib/types/HTMLNanoOptimizer.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/plugin": "2.14.5-canary.200+10ee3fa5b",
19
20
  "htmlnano": "^2.0.0",
20
21
  "nullthrows": "^1.1.1",
21
22
  "posthtml": "^0.16.5",
22
23
  "svgo": "^2.4.0"
23
24
  },
24
25
  "type": "commonjs",
25
- "gitHead": "30f60175ba4d272c5fc193973c63bc298584775b"
26
- }
26
+ "scripts": {
27
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
28
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
29
+ },
30
+ "gitHead": "10ee3fa5b75a92acde8973673d9b3c5b6f3958e5"
31
+ }
@@ -1,13 +1,14 @@
1
- // @flow strict-local
1
+ // @ts-expect-error TS2724
2
2
  import type {PostHTMLNode} from 'posthtml';
3
3
 
4
+ // @ts-expect-error TS7016
4
5
  import htmlnano from 'htmlnano';
5
6
  import {Optimizer} from '@atlaspack/plugin';
6
7
  import posthtml from 'posthtml';
7
8
  import path from 'path';
8
9
  import {SVG_ATTRS, SVG_TAG_NAMES} from './svgMappings';
9
10
 
10
- export default (new Optimizer({
11
+ export default new Optimizer({
11
12
  async loadConfig({config, options}) {
12
13
  let userConfig = await config.getConfigFrom(
13
14
  path.join(options.projectRoot, 'index.html'),
@@ -39,17 +40,16 @@ export default (new Optimizer({
39
40
  );
40
41
  }
41
42
 
42
- const clonedConfig = config || {};
43
+ const clonedConfig: Record<any, any> = config || {};
43
44
 
44
- // $FlowFixMe
45
45
  const presets = htmlnano.presets;
46
- const preset =
46
+ const preset: Record<any, any> =
47
47
  typeof clonedConfig.preset === 'string'
48
48
  ? presets[clonedConfig.preset]
49
49
  : {};
50
50
  delete clonedConfig.preset;
51
51
 
52
- const htmlNanoConfig = {
52
+ const htmlNanoConfig: unknown = {
53
53
  // Inline <script> and <style> elements, and style attributes are already
54
54
  // minified before they are re-inserted by the packager.
55
55
  minifyJs: false,
@@ -89,7 +89,7 @@ export default (new Optimizer({
89
89
 
90
90
  let plugins = [htmlnano(htmlNanoConfig)];
91
91
 
92
- // $FlowFixMe
92
+ // @ts-expect-error TS18046
93
93
  if (htmlNanoConfig.minifySvg !== false) {
94
94
  plugins.unshift(mapSVG);
95
95
  }
@@ -97,13 +97,14 @@ export default (new Optimizer({
97
97
  return {
98
98
  contents: (
99
99
  await posthtml(plugins).process(contents, {
100
+ // @ts-expect-error TS2353
100
101
  xmlMode: bundle.type === 'xhtml',
101
102
  closingSingleTag: bundle.type === 'xhtml' ? 'slash' : undefined,
102
103
  })
103
104
  ).html,
104
105
  };
105
106
  },
106
- }): Optimizer);
107
+ }) as Optimizer<unknown, unknown>;
107
108
 
108
109
  // HTML tags and attributes are case insensitive. The HTML transformer normalizes them so it can
109
110
  // more easily process any case. But SVGO requires case sensitive tags and attributes to work correctly.
@@ -114,7 +115,6 @@ function mapSVG(
114
115
  ) {
115
116
  if (Array.isArray(node)) {
116
117
  for (let i = 0; i < node.length; i++) {
117
- // $FlowFixMe
118
118
  node[i] = mapSVG(node[i], inSVG);
119
119
  }
120
120
  } else if (node && typeof node === 'object') {
@@ -1,7 +1,8 @@
1
- // @flow
2
1
  // Based on parse5: https://github.com/inikulin/parse5/blob/252819607421a5741cf745bb60c404f023531b0d/packages/parse5/lib/common/foreign-content.js#L54
3
2
 
4
- export const SVG_TAG_NAMES: {|[string]: string|} = {
3
+ export const SVG_TAG_NAMES: {
4
+ [key: string]: string;
5
+ } = {
5
6
  altglyph: 'altGlyph',
6
7
  altglyphdef: 'altGlyphDef',
7
8
  altglyphitem: 'altGlyphItem',
@@ -40,7 +41,9 @@ export const SVG_TAG_NAMES: {|[string]: string|} = {
40
41
  textpath: 'textPath',
41
42
  };
42
43
 
43
- export const SVG_ATTRS: {|[string]: string|} = {
44
+ export const SVG_ATTRS: {
45
+ [key: string]: string;
46
+ } = {
44
47
  attributename: 'attributeName',
45
48
  attributetype: 'attributeType',
46
49
  basefrequency: 'baseFrequency',
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }