@atlaspack/transformer-posthtml 2.14.5-canary.137 → 2.14.5-canary.139

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,13 @@
1
1
  # @atlaspack/transformer-posthtml
2
2
 
3
+ ## 2.14.21
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/utils@2.17.3
9
+ - @atlaspack/plugin@2.14.21
10
+
3
11
  ## 2.14.20
4
12
 
5
13
  ### Patch Changes
@@ -0,0 +1,3 @@
1
+ import { Transformer } from '@atlaspack/plugin';
2
+ declare const _default: Transformer<unknown>;
3
+ export default _default;
@@ -78,10 +78,17 @@ var _default = exports.default = new (_plugin().Transformer)({
78
78
  }
79
79
 
80
80
  // Load plugins. This must be done before adding dev dependencies so we auto install.
81
- let plugins = await (0, _loadPlugins.default)(configFile.contents.plugins, config.searchPath, options);
81
+ let plugins = await (0, _loadPlugins.default)(
82
+ // @ts-expect-error TS18046
83
+ configFile.contents.plugins, config.searchPath, options);
82
84
 
83
85
  // Now add dev dependencies so we invalidate when they change.
84
- let pluginArray = Array.isArray(configFile.contents.plugins) ? configFile.contents.plugins : Object.keys(configFile.contents.plugins);
86
+ // @ts-expect-error TS18046
87
+ let pluginArray = Array.isArray(configFile.contents.plugins) ?
88
+ // @ts-expect-error TS18046
89
+ configFile.contents.plugins :
90
+ // @ts-expect-error TS18046
91
+ Object.keys(configFile.contents.plugins);
85
92
  for (let p of pluginArray) {
86
93
  if (typeof p === 'string') {
87
94
  config.addDevDependency({
@@ -90,10 +97,14 @@ var _default = exports.default = new (_plugin().Transformer)({
90
97
  });
91
98
  }
92
99
  }
100
+
101
+ // @ts-expect-error TS18046
93
102
  configFile.contents.plugins = plugins;
94
103
 
95
104
  // tells posthtml that we have already called parse
105
+ // @ts-expect-error TS18046
96
106
  configFile.contents.skipParse = true;
107
+ // @ts-expect-error TS18046
97
108
  delete configFile.contents.render;
98
109
  return configFile.contents;
99
110
  }
@@ -129,13 +140,14 @@ var _default = exports.default = new (_plugin().Transformer)({
129
140
  return [asset];
130
141
  }
131
142
  let ast = (0, _nullthrows().default)(await asset.getAST());
132
- // $FlowFixMe
143
+ // @ts-expect-error TS2339
133
144
  let res = await (0, _posthtml().default)(config.plugins).process(ast.program, {
134
145
  ...config,
135
- // $FlowFixMe
146
+ // @ts-expect-error TS2353
136
147
  plugins: config.plugins
137
148
  });
138
149
  if (res.messages) {
150
+ // @ts-expect-error TS2339
139
151
  for (let {
140
152
  type,
141
153
  file: filePath
@@ -159,6 +171,7 @@ var _default = exports.default = new (_plugin().Transformer)({
159
171
  }) {
160
172
  return {
161
173
  content: (0, _posthtmlRender().render)(ast.program, {
174
+ // @ts-expect-error TS2322
162
175
  closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined
163
176
  })
164
177
  };
@@ -0,0 +1,4 @@
1
+ import type { FilePath, PluginOptions } from '@atlaspack/types';
2
+ export default function loadExternalPlugins(plugins: Array<string> | {
3
+ readonly [pluginName: string]: unknown;
4
+ }, relative: FilePath, options: PluginOptions): Promise<Array<unknown>>;
@@ -15,7 +15,9 @@ async function loadExternalPlugins(plugins, relative, options) {
15
15
  return [];
16
16
  }
17
17
  }
18
- async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall) {
18
+ async function loadPlugin(pluginArg, relative, options = {}, packageManager, shouldAutoInstall
19
+ // @ts-expect-error TS1064
20
+ ) {
19
21
  if (typeof pluginArg !== 'string') {
20
22
  return pluginArg;
21
23
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-posthtml",
3
- "version": "2.14.5-canary.137+069de478e",
3
+ "version": "2.14.5-canary.139+d2fd84977",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,14 +9,15 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/PostHTMLTransformer.js",
13
- "source": "src/PostHTMLTransformer.js",
12
+ "main": "./lib/PostHTMLTransformer.js",
13
+ "source": "./src/PostHTMLTransformer.ts",
14
+ "types": "./lib/PostHTMLTransformer.d.ts",
14
15
  "engines": {
15
16
  "node": ">= 16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/plugin": "2.14.5-canary.137+069de478e",
19
- "@atlaspack/utils": "2.14.5-canary.137+069de478e",
19
+ "@atlaspack/plugin": "2.14.5-canary.139+d2fd84977",
20
+ "@atlaspack/utils": "2.14.5-canary.139+d2fd84977",
20
21
  "nullthrows": "^1.1.1",
21
22
  "posthtml": "^0.16.5",
22
23
  "posthtml-parser": "^0.10.1",
@@ -24,5 +25,8 @@
24
25
  "semver": "^7.5.2"
25
26
  },
26
27
  "type": "commonjs",
27
- "gitHead": "069de478e64fb5889f6f2ce023eb510782767fbd"
28
- }
28
+ "scripts": {
29
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src"
30
+ },
31
+ "gitHead": "d2fd849770fe6305e9c694bd97b1bd905abd9d94"
32
+ }
@@ -1,5 +1,3 @@
1
- // @flow
2
-
3
1
  import {Transformer} from '@atlaspack/plugin';
4
2
 
5
3
  import path from 'path';
@@ -10,7 +8,7 @@ import nullthrows from 'nullthrows';
10
8
  import semver from 'semver';
11
9
  import loadPlugins from './loadPlugins';
12
10
 
13
- export default (new Transformer({
11
+ export default new Transformer({
14
12
  async loadConfig({config, options, logger}) {
15
13
  if (!config.isSource) {
16
14
  return;
@@ -44,15 +42,19 @@ export default (new Transformer({
44
42
 
45
43
  // Load plugins. This must be done before adding dev dependencies so we auto install.
46
44
  let plugins = await loadPlugins(
45
+ // @ts-expect-error TS18046
47
46
  configFile.contents.plugins,
48
47
  config.searchPath,
49
48
  options,
50
49
  );
51
50
 
52
51
  // Now add dev dependencies so we invalidate when they change.
52
+ // @ts-expect-error TS18046
53
53
  let pluginArray = Array.isArray(configFile.contents.plugins)
54
- ? configFile.contents.plugins
55
- : Object.keys(configFile.contents.plugins);
54
+ ? // @ts-expect-error TS18046
55
+ configFile.contents.plugins
56
+ : // @ts-expect-error TS18046
57
+ Object.keys(configFile.contents.plugins);
56
58
  for (let p of pluginArray) {
57
59
  if (typeof p === 'string') {
58
60
  config.addDevDependency({
@@ -62,10 +64,13 @@ export default (new Transformer({
62
64
  }
63
65
  }
64
66
 
67
+ // @ts-expect-error TS18046
65
68
  configFile.contents.plugins = plugins;
66
69
 
67
70
  // tells posthtml that we have already called parse
71
+ // @ts-expect-error TS18046
68
72
  configFile.contents.skipParse = true;
73
+ // @ts-expect-error TS18046
69
74
  delete configFile.contents.render;
70
75
 
71
76
  return configFile.contents;
@@ -99,14 +104,15 @@ export default (new Transformer({
99
104
  }
100
105
 
101
106
  let ast = nullthrows(await asset.getAST());
102
- // $FlowFixMe
107
+ // @ts-expect-error TS2339
103
108
  let res = await posthtml(config.plugins).process(ast.program, {
104
109
  ...config,
105
- // $FlowFixMe
110
+ // @ts-expect-error TS2353
106
111
  plugins: config.plugins,
107
112
  });
108
113
 
109
114
  if (res.messages) {
115
+ // @ts-expect-error TS2339
110
116
  for (let {type, file: filePath} of res.messages) {
111
117
  if (type === 'dependency') {
112
118
  asset.invalidateOnFileChange(filePath);
@@ -126,8 +132,9 @@ export default (new Transformer({
126
132
  generate({ast, asset}) {
127
133
  return {
128
134
  content: render(ast.program, {
135
+ // @ts-expect-error TS2322
129
136
  closingSingleTag: asset.type === 'xhtml' ? 'slash' : undefined,
130
137
  }),
131
138
  };
132
139
  },
133
- }): Transformer<mixed>);
140
+ }) as Transformer<unknown>;
@@ -1,13 +1,15 @@
1
- // @flow
2
-
3
1
  import type {FilePath, PluginOptions} from '@atlaspack/types';
4
2
  import type {PackageManager} from '@atlaspack/package-manager';
5
3
 
6
4
  export default async function loadExternalPlugins(
7
- plugins: Array<string> | {+[pluginName: string]: mixed, ...},
5
+ plugins:
6
+ | Array<string>
7
+ | {
8
+ readonly [pluginName: string]: unknown;
9
+ },
8
10
  relative: FilePath,
9
11
  options: PluginOptions,
10
- ): Promise<Array<mixed>> {
12
+ ): Promise<Array<unknown>> {
11
13
  if (Array.isArray(plugins)) {
12
14
  return Promise.all(
13
15
  plugins
@@ -42,12 +44,13 @@ export default async function loadExternalPlugins(
42
44
  }
43
45
 
44
46
  async function loadPlugin(
45
- pluginArg: string | Function,
47
+ pluginArg: string | any,
46
48
  relative: FilePath,
47
- options: mixed = {},
49
+ options: unknown | null | undefined = {},
48
50
  packageManager: PackageManager,
49
51
  shouldAutoInstall: boolean,
50
- ): mixed {
52
+ // @ts-expect-error TS1064
53
+ ): unknown {
51
54
  if (typeof pluginArg !== 'string') {
52
55
  return pluginArg;
53
56
  }
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }