@atlaspack/packager-webextension 2.14.5-canary.138 → 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.
@@ -0,0 +1,3 @@
1
+ import { Packager } from '@atlaspack/plugin';
2
+ declare const _default: Packager<unknown, unknown>;
3
+ export default _default;
@@ -39,6 +39,7 @@ var _default = exports.default = new (_plugin().Packager)({
39
39
  bundleGraph
40
40
  }) {
41
41
  var _manifest$background;
42
+ // @ts-expect-error TS2552
42
43
  let assets = [];
43
44
  bundle.traverseAssets(asset => {
44
45
  assets.push(asset);
@@ -46,6 +47,8 @@ var _default = exports.default = new (_plugin().Packager)({
46
47
  const manifestAssets = assets.filter(a => a.meta.webextEntry === true);
47
48
  (0, _assert().default)(assets.length == 2 && manifestAssets.length == 1, 'Web extension bundles must contain exactly one manifest asset and one runtime asset');
48
49
  const asset = manifestAssets[0];
50
+
51
+ // @ts-expect-error TS2304
49
52
  const relPath = b => (0, _utils().relativeBundlePath)(bundle, b, {
50
53
  leadingDotSlash: false
51
54
  });
@@ -58,13 +61,28 @@ var _default = exports.default = new (_plugin().Packager)({
58
61
  const deps = asset.getDependencies();
59
62
  const war = [];
60
63
  for (const contentScript of manifest.content_scripts || []) {
61
- const srcBundles = deps.filter(d => {
64
+ const srcBundles = deps.filter(
65
+ // @ts-expect-error TS7006
66
+ d => {
62
67
  var _contentScript$js, _contentScript$css;
63
68
  return ((_contentScript$js = contentScript.js) === null || _contentScript$js === void 0 ? void 0 : _contentScript$js.includes(d.id)) || ((_contentScript$css = contentScript.css) === null || _contentScript$css === void 0 ? void 0 : _contentScript$css.includes(d.id));
64
- }).map(d => (0, _nullthrows().default)(bundleGraph.getReferencedBundle(d, bundle)));
65
- contentScript.css = [...new Set(srcBundles.flatMap(b => bundleGraph.getReferencedBundles(b)).filter(b => b.type == 'css').map(relPath).concat(contentScript.css || []))];
66
- contentScript.js = [...new Set(srcBundles.flatMap(b => bundleGraph.getReferencedBundles(b)).filter(b => b.type == 'js').map(relPath).concat(contentScript.js || []))];
67
- const resources = srcBundles.flatMap(b => {
69
+ })
70
+ // @ts-expect-error TS7006
71
+ .map(d => (0, _nullthrows().default)(bundleGraph.getReferencedBundle(d, bundle)));
72
+ contentScript.css = [...new Set(srcBundles
73
+ // @ts-expect-error TS7006
74
+ .flatMap(b => bundleGraph.getReferencedBundles(b))
75
+ // @ts-expect-error TS7006
76
+ .filter(b => b.type == 'css').map(relPath).concat(contentScript.css || []))];
77
+ contentScript.js = [...new Set(srcBundles
78
+ // @ts-expect-error TS7006
79
+ .flatMap(b => bundleGraph.getReferencedBundles(b))
80
+ // @ts-expect-error TS7006
81
+ .filter(b => b.type == 'js').map(relPath).concat(contentScript.js || []))];
82
+ const resources = srcBundles
83
+ // @ts-expect-error TS7006
84
+ .flatMap(b => {
85
+ // @ts-expect-error TS2304
68
86
  const children = [];
69
87
  const siblings = bundleGraph.getReferencedBundles(b);
70
88
  bundleGraph.traverseBundles(child => {
@@ -76,6 +94,7 @@ var _default = exports.default = new (_plugin().Packager)({
76
94
  }).map(relPath);
77
95
  if (resources.length > 0) {
78
96
  war.push({
97
+ // @ts-expect-error TS7006
79
98
  matches: contentScript.matches.map(match => {
80
99
  if (/^(((http|ws)s?)|ftp|\*):\/\//.test(match)) {
81
100
  let pathIndex = match.indexOf('/', match.indexOf('://') + 3);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/packager-webextension",
3
- "version": "2.14.5-canary.138+eda07caaf",
3
+ "version": "2.14.5-canary.139+d2fd84977",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,16 +9,20 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/WebExtensionPackager.js",
13
- "source": "src/WebExtensionPackager.js",
12
+ "main": "./lib/WebExtensionPackager.js",
13
+ "source": "./src/WebExtensionPackager.ts",
14
+ "types": "./lib/WebExtensionPackager.d.ts",
14
15
  "engines": {
15
16
  "node": ">=16.0.0"
16
17
  },
17
18
  "dependencies": {
18
- "@atlaspack/plugin": "2.14.5-canary.138+eda07caaf",
19
- "@atlaspack/utils": "2.14.5-canary.138+eda07caaf",
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
  },
22
23
  "type": "commonjs",
23
- "gitHead": "eda07caafd2ebb814bbdbfd0ec12fa63124e213f"
24
- }
24
+ "scripts": {
25
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src"
26
+ },
27
+ "gitHead": "d2fd849770fe6305e9c694bd97b1bd905abd9d94"
28
+ }
@@ -1,13 +1,12 @@
1
- // @flow strict-local
2
-
3
1
  import assert from 'assert';
4
2
  import nullthrows from 'nullthrows';
5
3
  import {Packager} from '@atlaspack/plugin';
6
4
  import {replaceURLReferences, relativeBundlePath} from '@atlaspack/utils';
7
5
 
8
- export default (new Packager({
6
+ export default new Packager({
9
7
  async package({bundle, bundleGraph}) {
10
- let assets = [];
8
+ // @ts-expect-error TS2552
9
+ let assets: Array<Asset> = [];
11
10
  bundle.traverseAssets((asset) => {
12
11
  assets.push(asset);
13
12
  });
@@ -19,7 +18,8 @@ export default (new Packager({
19
18
  );
20
19
  const asset = manifestAssets[0];
21
20
 
22
- const relPath = (b) =>
21
+ // @ts-expect-error TS2304
22
+ const relPath = (b: NamedBundle) =>
23
23
  relativeBundlePath(bundle, b, {leadingDotSlash: false});
24
24
 
25
25
  const manifest = JSON.parse(await asset.getCode());
@@ -31,20 +31,31 @@ export default (new Packager({
31
31
  }
32
32
 
33
33
  const deps = asset.getDependencies();
34
- const war = [];
34
+ const war: Array<
35
+ | any
36
+ | {
37
+ matches: never;
38
+ // @ts-expect-error TS2304
39
+ resources: Array<FilePath>;
40
+ }
41
+ > = [];
35
42
  for (const contentScript of manifest.content_scripts || []) {
36
43
  const srcBundles = deps
37
44
  .filter(
45
+ // @ts-expect-error TS7006
38
46
  (d) =>
39
47
  contentScript.js?.includes(d.id) ||
40
48
  contentScript.css?.includes(d.id),
41
49
  )
50
+ // @ts-expect-error TS7006
42
51
  .map((d) => nullthrows(bundleGraph.getReferencedBundle(d, bundle)));
43
52
 
44
53
  contentScript.css = [
45
54
  ...new Set(
46
55
  srcBundles
56
+ // @ts-expect-error TS7006
47
57
  .flatMap((b) => bundleGraph.getReferencedBundles(b))
58
+ // @ts-expect-error TS7006
48
59
  .filter((b) => b.type == 'css')
49
60
  .map(relPath)
50
61
  .concat(contentScript.css || []),
@@ -54,7 +65,9 @@ export default (new Packager({
54
65
  contentScript.js = [
55
66
  ...new Set(
56
67
  srcBundles
68
+ // @ts-expect-error TS7006
57
69
  .flatMap((b) => bundleGraph.getReferencedBundles(b))
70
+ // @ts-expect-error TS7006
58
71
  .filter((b) => b.type == 'js')
59
72
  .map(relPath)
60
73
  .concat(contentScript.js || []),
@@ -62,8 +75,10 @@ export default (new Packager({
62
75
  ];
63
76
 
64
77
  const resources = srcBundles
78
+ // @ts-expect-error TS7006
65
79
  .flatMap((b) => {
66
- const children = [];
80
+ // @ts-expect-error TS2304
81
+ const children: Array<NamedBundle> = [];
67
82
  const siblings = bundleGraph.getReferencedBundles(b);
68
83
  bundleGraph.traverseBundles((child) => {
69
84
  if (b !== child && !siblings.includes(child)) {
@@ -76,6 +91,7 @@ export default (new Packager({
76
91
 
77
92
  if (resources.length > 0) {
78
93
  war.push({
94
+ // @ts-expect-error TS7006
79
95
  matches: contentScript.matches.map((match) => {
80
96
  if (/^(((http|ws)s?)|ftp|\*):\/\//.test(match)) {
81
97
  let pathIndex = match.indexOf('/', match.indexOf('://') + 3);
@@ -105,4 +121,4 @@ export default (new Packager({
105
121
  });
106
122
  return {contents};
107
123
  },
108
- }): Packager<mixed, mixed>);
124
+ }) as Packager<unknown, unknown>;
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }