@atlaspack/transformer-webextension 2.14.5-canary.16 → 2.14.5-canary.161

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,162 @@
1
1
  # @atlaspack/transformer-webextension
2
2
 
3
+ ## 2.14.25
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/utils@2.18.2
9
+ - @atlaspack/plugin@2.14.25
10
+
11
+ ## 2.14.24
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies []:
16
+ - @atlaspack/utils@2.18.1
17
+ - @atlaspack/plugin@2.14.24
18
+
19
+ ## 2.14.23
20
+
21
+ ### Patch Changes
22
+
23
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
24
+ - @atlaspack/utils@2.18.0
25
+ - @atlaspack/plugin@2.14.23
26
+
27
+ ## 2.14.22
28
+
29
+ ### Patch Changes
30
+
31
+ - [#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
32
+
33
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94)]:
34
+ - @atlaspack/diagnostic@2.14.2
35
+ - @atlaspack/plugin@2.14.22
36
+ - @atlaspack/utils@2.17.4
37
+
38
+ ## 2.14.21
39
+
40
+ ### Patch Changes
41
+
42
+ - Updated dependencies []:
43
+ - @atlaspack/utils@2.17.3
44
+ - @atlaspack/plugin@2.14.21
45
+
46
+ ## 2.14.20
47
+
48
+ ### Patch Changes
49
+
50
+ - [#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
51
+
52
+ - Updated dependencies [[`daaa768`](https://github.com/atlassian-labs/atlaspack/commit/daaa7688786772d7e3713b71c5bba6b89ec704aa)]:
53
+ - @atlaspack/plugin@2.14.20
54
+ - @atlaspack/utils@2.17.2
55
+
56
+ ## 2.14.19
57
+
58
+ ### Patch Changes
59
+
60
+ - Updated dependencies []:
61
+ - @atlaspack/utils@2.17.1
62
+ - @atlaspack/plugin@2.14.19
63
+
64
+ ## 2.14.18
65
+
66
+ ### Patch Changes
67
+
68
+ - 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)]:
69
+ - @atlaspack/utils@2.17.0
70
+ - @atlaspack/plugin@2.14.18
71
+
72
+ ## 2.14.17
73
+
74
+ ### Patch Changes
75
+
76
+ - Updated dependencies []:
77
+ - @atlaspack/utils@2.16.1
78
+ - @atlaspack/plugin@2.14.17
79
+
80
+ ## 2.14.16
81
+
82
+ ### Patch Changes
83
+
84
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
85
+ - @atlaspack/utils@2.16.0
86
+ - @atlaspack/plugin@2.14.16
87
+
88
+ ## 2.14.15
89
+
90
+ ### Patch Changes
91
+
92
+ - Updated dependencies []:
93
+ - @atlaspack/utils@2.15.3
94
+ - @atlaspack/plugin@2.14.15
95
+
96
+ ## 2.14.14
97
+
98
+ ### Patch Changes
99
+
100
+ - Updated dependencies []:
101
+ - @atlaspack/utils@2.15.2
102
+ - @atlaspack/plugin@2.14.14
103
+
104
+ ## 2.14.13
105
+
106
+ ### Patch Changes
107
+
108
+ - Updated dependencies []:
109
+ - @atlaspack/utils@2.15.1
110
+ - @atlaspack/plugin@2.14.13
111
+
112
+ ## 2.14.12
113
+
114
+ ### Patch Changes
115
+
116
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
117
+ - @atlaspack/utils@2.15.0
118
+ - @atlaspack/plugin@2.14.12
119
+
120
+ ## 2.14.11
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies []:
125
+ - @atlaspack/utils@2.14.11
126
+ - @atlaspack/plugin@2.14.11
127
+
128
+ ## 2.14.10
129
+
130
+ ### Patch Changes
131
+
132
+ - Updated dependencies []:
133
+ - @atlaspack/plugin@2.14.10
134
+ - @atlaspack/utils@2.14.10
135
+
136
+ ## 2.14.9
137
+
138
+ ### Patch Changes
139
+
140
+ - Updated dependencies []:
141
+ - @atlaspack/utils@2.14.9
142
+ - @atlaspack/plugin@2.14.9
143
+
144
+ ## 2.14.8
145
+
146
+ ### Patch Changes
147
+
148
+ - Updated dependencies []:
149
+ - @atlaspack/utils@2.14.8
150
+ - @atlaspack/plugin@2.14.8
151
+
152
+ ## 2.14.7
153
+
154
+ ### Patch Changes
155
+
156
+ - Updated dependencies []:
157
+ - @atlaspack/utils@2.14.7
158
+ - @atlaspack/plugin@2.14.7
159
+
3
160
  ## 2.14.6
4
161
 
5
162
  ### Patch Changes
@@ -70,6 +70,7 @@ async function collectDependencies(asset, program, ptrs, hmrOptions) {
70
70
  codeFrames: [{
71
71
  filePath,
72
72
  codeHighlights: [{
73
+ // @ts-expect-error TS2345
73
74
  ...(0, _diagnostic().getJSONHighlightLocation)(ptrs['/default_locale'], err),
74
75
  message: (0, _diagnostic().md)`Localization ${err == 'value' ? 'file for ' + program.default_locale : 'directory'} does not exist: ${_path().default.relative(assetDir, _path().default.join(locales, program.default_locale))}`
75
76
  }]
@@ -0,0 +1,3 @@
1
+ import { Transformer } from '@atlaspack/plugin';
2
+ declare const _default: Transformer<unknown>;
3
+ export default _default;
@@ -0,0 +1,4 @@
1
+ import type { SchemaEntity } from '@atlaspack/utils';
2
+ export declare const MV3Schema: SchemaEntity;
3
+ export declare const MV2Schema: SchemaEntity;
4
+ export declare const VersionSchema: SchemaEntity;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/transformer-webextension",
3
- "version": "2.14.5-canary.16+4b2b575b9",
3
+ "version": "2.14.5-canary.161+ee040bb64",
4
4
  "license": "(MIT OR Apache-2.0)",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -9,16 +9,21 @@
9
9
  "type": "git",
10
10
  "url": "https://github.com/atlassian-labs/atlaspack.git"
11
11
  },
12
- "main": "lib/WebExtensionTransformer.js",
13
- "source": "src/WebExtensionTransformer.js",
12
+ "main": "./lib/WebExtensionTransformer.js",
13
+ "source": "./src/WebExtensionTransformer.ts",
14
+ "types": "./lib/types/WebExtensionTransformer.d.ts",
14
15
  "engines": {},
15
16
  "dependencies": {
16
- "@atlaspack/diagnostic": "2.14.1-canary.84+4b2b575b9",
17
- "@atlaspack/plugin": "2.14.5-canary.16+4b2b575b9",
18
- "@atlaspack/utils": "2.14.5-canary.16+4b2b575b9",
17
+ "@atlaspack/diagnostic": "2.14.1-canary.229+ee040bb64",
18
+ "@atlaspack/plugin": "2.14.5-canary.161+ee040bb64",
19
+ "@atlaspack/utils": "2.14.5-canary.161+ee040bb64",
19
20
  "@mischnic/json-sourcemap": "^0.1.0",
20
21
  "content-security-policy-parser": "^0.3.0"
21
22
  },
22
23
  "type": "commonjs",
23
- "gitHead": "4b2b575b98951f2dcf0c45ed8e94359b23b43815"
24
+ "scripts": {
25
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src",
26
+ "build:lib": "gulp build --gulpfile ../../../gulpfile.js --cwd ."
27
+ },
28
+ "gitHead": "ee040bb6428f29b57d892ddd8107e29077d08ffd"
24
29
  }
@@ -1,4 +1,3 @@
1
- // @flow
2
1
  import type {MutableAsset, HMROptions} from '@atlaspack/types';
3
2
 
4
3
  import {Transformer} from '@atlaspack/plugin';
@@ -39,8 +38,10 @@ const DEP_LOCS = [
39
38
  async function collectDependencies(
40
39
  asset: MutableAsset,
41
40
  program: any,
42
- ptrs: {[key: string]: any, ...},
43
- hmrOptions: ?HMROptions,
41
+ ptrs: {
42
+ [key: string]: any;
43
+ },
44
+ hmrOptions?: HMROptions | null,
44
45
  ) {
45
46
  const hot = Boolean(hmrOptions);
46
47
  const fs = asset.fs;
@@ -53,10 +54,10 @@ async function collectDependencies(
53
54
  let err = !(await fs.exists(locales))
54
55
  ? 'key'
55
56
  : !(await fs.exists(
56
- path.join(locales, program.default_locale, 'messages.json'),
57
- ))
58
- ? 'value'
59
- : null;
57
+ path.join(locales, program.default_locale, 'messages.json'),
58
+ ))
59
+ ? 'value'
60
+ : null;
60
61
  if (err) {
61
62
  throw new ThrowableDiagnostic({
62
63
  diagnostic: [
@@ -68,6 +69,7 @@ async function collectDependencies(
68
69
  filePath,
69
70
  codeHighlights: [
70
71
  {
72
+ // @ts-expect-error TS2345
71
73
  ...getJSONHighlightLocation(ptrs['/default_locale'], err),
72
74
  message: md`Localization ${
73
75
  err == 'value'
@@ -151,7 +153,7 @@ async function collectDependencies(
151
153
  const loc = {
152
154
  filePath,
153
155
  ...getJSONSourceLocation(ptrs[`/dictionaries/${dict}`], 'value'),
154
- };
156
+ } as const;
155
157
  program.dictionaries[dict] = asset.addURLDependency(dictFile, {
156
158
  needsStableName: true,
157
159
  loc,
@@ -181,12 +183,12 @@ async function collectDependencies(
181
183
  }
182
184
  }
183
185
  if (program.web_accessible_resources) {
184
- let war = [];
186
+ let war: Array<any> | Array<any | string> = [];
185
187
  for (let i = 0; i < program.web_accessible_resources.length; ++i) {
186
188
  // TODO: this doesn't support Atlaspack resolution
187
189
  const currentEntry = program.web_accessible_resources[i];
188
190
  const files = isMV2 ? [currentEntry] : currentEntry.resources;
189
- let currentFiles = [];
191
+ let currentFiles: Array<any> | Array<any | string> = [];
190
192
  for (let j = 0; j < files.length; ++j) {
191
193
  const globFiles = (
192
194
  await glob(path.join(assetDir, files[j]), fs, {})
@@ -218,8 +220,11 @@ async function collectDependencies(
218
220
  program.web_accessible_resources = war;
219
221
  }
220
222
  if (program.declarative_net_request) {
221
- const rrs: {|path: string, id: string, enabled: boolean|}[] =
222
- program.declarative_net_request?.rule_resources ?? [];
223
+ const rrs: {
224
+ path: string;
225
+ id: string;
226
+ enabled: boolean;
227
+ }[] = program.declarative_net_request?.rule_resources ?? [];
223
228
  rrs.forEach((resources, i) => {
224
229
  resources.path = asset.addURLDependency(resources.path, {
225
230
  pipeline: 'raw',
@@ -344,7 +349,7 @@ async function collectDependencies(
344
349
  program.permissions.push('scripting');
345
350
  }
346
351
  const hostPerms = [
347
- ...new Set(program.content_scripts?.flatMap((sc) => sc.matches)),
352
+ ...new Set(program.content_scripts?.flatMap((sc: any) => sc.matches)),
348
353
  ];
349
354
  if (isMV2) program.permissions = program.permissions.concat(hostPerms);
350
355
  else {
@@ -354,7 +359,7 @@ async function collectDependencies(
354
359
  }
355
360
  }
356
361
 
357
- function cspPatchHMR(policy: ?string, insert?: string) {
362
+ function cspPatchHMR(policy?: string | null, insert?: string) {
358
363
  let defaultSrc = "'self'";
359
364
  if (insert == null) {
360
365
  insert = "'unsafe-eval'";
@@ -381,7 +386,7 @@ function cspPatchHMR(policy: ?string, insert?: string) {
381
386
  }
382
387
  }
383
388
 
384
- export default (new Transformer({
389
+ export default new Transformer({
385
390
  async transform({asset, options}) {
386
391
  // Set environment to browser, since web extensions are always used in
387
392
  // browsers, and because it avoids delegating extra config to the user
@@ -433,4 +438,4 @@ export default (new Transformer({
433
438
  asset.meta.webextEntry = true;
434
439
  return [asset];
435
440
  },
436
- }): Transformer);
441
+ }) as Transformer<unknown>;
@@ -1,7 +1,6 @@
1
- // @flow strict-local
2
1
  import type {SchemaEntity} from '@atlaspack/utils';
3
2
 
4
- const validateVersion = (ver: string): ?string => {
3
+ const validateVersion = (ver: string): string | null | undefined => {
5
4
  const parts = ver.split('.', 5);
6
5
  if (parts.length == 5) return 'Extension versions to have at most three dots';
7
6
  if (
@@ -33,12 +32,12 @@ const actionProps = {
33
32
  },
34
33
  default_popup: string,
35
34
  default_title: string,
36
- };
35
+ } as const;
37
36
 
38
37
  const arrStr = {
39
38
  type: 'array',
40
39
  items: string,
41
- };
40
+ } as const;
42
41
 
43
42
  const browserAction = {
44
43
  type: 'object',
@@ -64,7 +63,7 @@ const browserAction = {
64
63
  },
65
64
  },
66
65
  additionalProperties: false,
67
- };
66
+ } as const;
68
67
 
69
68
  const warBase = {
70
69
  type: 'object',
@@ -75,7 +74,7 @@ const warBase = {
75
74
  use_dynamic_url: boolean,
76
75
  },
77
76
  additionalProperties: false,
78
- };
77
+ } as const;
79
78
 
80
79
  const mv2Background = {
81
80
  type: 'object',
@@ -85,7 +84,7 @@ const mv2Background = {
85
84
  persistent: boolean,
86
85
  },
87
86
  additionalProperties: false,
88
- };
87
+ } as const;
89
88
 
90
89
  const commonProps = {
91
90
  $schema: string,
@@ -145,7 +144,7 @@ const commonProps = {
145
144
  },
146
145
  additionalProperties: false,
147
146
  },
148
- commands: ({
147
+ commands: {
149
148
  type: 'object',
150
149
  properties: {},
151
150
  additionalProperties: {
@@ -168,7 +167,7 @@ const commonProps = {
168
167
  },
169
168
  additionalProperties: false,
170
169
  },
171
- }: SchemaEntity),
170
+ } as SchemaEntity,
172
171
  content_scripts: {
173
172
  type: 'array',
174
173
  items: {
@@ -195,7 +194,7 @@ const commonProps = {
195
194
  required: ['matches'],
196
195
  },
197
196
  },
198
- declarative_net_request: ({
197
+ declarative_net_request: {
199
198
  type: 'object',
200
199
  properties: {
201
200
  rule_resources: {
@@ -214,14 +213,14 @@ const commonProps = {
214
213
  },
215
214
  additionalProperties: false,
216
215
  required: ['rule_resources'],
217
- }: SchemaEntity),
216
+ } as SchemaEntity,
218
217
  devtools_page: string,
219
218
  // looks to be FF only
220
- dictionaries: ({
219
+ dictionaries: {
221
220
  type: 'object',
222
221
  properties: {},
223
222
  additionalProperties: string,
224
- }: SchemaEntity),
223
+ } as SchemaEntity,
225
224
  externally_connectable: {
226
225
  type: 'object',
227
226
  properties: {
@@ -280,11 +279,11 @@ const commonProps = {
280
279
  additionalProperties: false,
281
280
  },
282
281
  offline_enabled: boolean,
283
- omnibox: ({
282
+ omnibox: {
284
283
  type: 'object',
285
284
  properties: {},
286
285
  additionalProperties: string,
287
- }: SchemaEntity),
286
+ } as SchemaEntity,
288
287
  optional_host_permissions: arrStr,
289
288
  optional_permissions: arrStr,
290
289
  // options_page is deprecated
@@ -453,9 +452,9 @@ const commonProps = {
453
452
  additionalProperties: false,
454
453
  },
455
454
  version_name: string,
456
- };
455
+ } as const;
457
456
 
458
- export const MV3Schema = ({
457
+ export const MV3Schema = {
459
458
  type: 'object',
460
459
  properties: {
461
460
  ...commonProps,
@@ -525,9 +524,9 @@ export const MV3Schema = ({
525
524
  },
526
525
  },
527
526
  required: ['manifest_version', 'name', 'version'],
528
- }: SchemaEntity);
527
+ } as SchemaEntity;
529
528
 
530
- export const MV2Schema = ({
529
+ export const MV2Schema = {
531
530
  type: 'object',
532
531
  properties: {
533
532
  ...commonProps,
@@ -560,9 +559,9 @@ export const MV2Schema = ({
560
559
  web_accessible_resources: arrStr,
561
560
  },
562
561
  required: ['manifest_version', 'name', 'version'],
563
- }: SchemaEntity);
562
+ } as SchemaEntity;
564
563
 
565
- export const VersionSchema = ({
564
+ export const VersionSchema = {
566
565
  type: 'object',
567
566
  properties: {
568
567
  $schema: string,
@@ -572,4 +571,4 @@ export const VersionSchema = ({
572
571
  },
573
572
  },
574
573
  required: ['manifest_version'],
575
- }: SchemaEntity);
574
+ } as SchemaEntity;
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }