Skip to content

Commit 134cc48

Browse files
committed
Fixes for firefox94
Add comments for manifest versions
1 parent ca6e780 commit 134cc48

File tree

3 files changed

+33
-5
lines changed

3 files changed

+33
-5
lines changed

src/converter.ts

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ function commentFromSchema(schema: TypeSchema | NamespaceSchema | NameDesc) {
152152
} else if (type.unsupported) {
153153
doclines.push(`@deprecated Unsupported on Firefox at this time.`);
154154
}
155+
if (type.min_manifest_version) {
156+
doclines.push(`Needs at least manifest version ${type.min_manifest_version}.`);
157+
}
158+
if (type.max_manifest_version) {
159+
doclines.push(`Not supported on manifest versions above ${type.max_manifest_version}.`);
160+
}
155161
if (type.returns && type.returns.description) {
156162
doclines.push(`@returns ${descToMarkdown(type.returns.description)}`);
157163
}
@@ -225,6 +231,8 @@ export default class Converter {
225231
description: namespace.description,
226232
permissions: [],
227233
allowedContexts: [],
234+
min_manifest_version: namespace.min_manifest_version,
235+
max_manifest_version: namespace.max_manifest_version,
228236
};
229237
this.namespaces[namespace.namespace] = resNamespace;
230238
} else {
@@ -351,7 +359,9 @@ export default class Converter {
351359
convertedProperties.push(
352360
`${commentFromSchema(propertyType)}${name}${
353361
type.properties[name].optional ? '?' : ''
354-
}: ${this.convertType(propertyType)}`
362+
}: ${this.convertType(propertyType)}${
363+
type.properties[name].optional ? ' | undefined' : ''
364+
}`
355365
);
356366
}
357367
}
@@ -981,9 +991,15 @@ export default class Converter {
981991
let out = '';
982992

983993
if (data.$import) {
984-
let skipKeys = ['namespace', 'description', 'permissions'];
994+
let skipKeys = [
995+
'namespace',
996+
'description',
997+
'permissions',
998+
'max_manifest_version',
999+
'min_manifest_version',
1000+
];
9851001
_.mergeWith(data, this.namespaces[data.$import], (objValue, srcValue, key) => {
986-
if (skipKeys.includes(key)) return objValue;
1002+
if (skipKeys.includes(key)) return objValue === undefined ? null : objValue;
9871003
if (_.isArray(objValue)) {
9881004
return _.uniqWith(objValue.concat(srcValue), (arrVal, othVal) => {
9891005
return (
@@ -1031,6 +1047,14 @@ export default class Converter {
10311047
doclines.push(`Manifest keys: ${manifestKeys.map((p) => `\`${p}\``).join(', ')}`);
10321048
}
10331049
}
1050+
// Manifest version
1051+
if (data.min_manifest_version) {
1052+
doclines.push(`Needs at least manifest version ${data.min_manifest_version}.`);
1053+
}
1054+
if (data.max_manifest_version) {
1055+
doclines.push(`Not supported on manifest versions above ${data.max_manifest_version}.`);
1056+
}
1057+
10341058
// Allowed contexts
10351059
let contexts = formatContexts(data.allowedContexts, true);
10361060
if (contexts) {

src/overrides.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default function override(converter: Converter) {
107107
],
108108
],
109109
[
110-
'browserAction',
110+
'action',
111111
[
112112
['openPopup', 'void'],
113113
['openPopup', 'boolean'],

src/types/converter.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ interface NamespaceSchema {
88
properties?: Indexable<TypeSchema>;
99
events?: TypeSchema[];
1010
permissions?: string[];
11+
min_manifest_version: number;
12+
max_manifest_version: number;
1113
}
1214

1315
interface NameDesc {
@@ -47,7 +49,9 @@ interface TypeSchema {
4749
converterTypeOverride?: string;
4850
converterAdditionalType?: string;
4951
converterPromiseOptional?: boolean;
50-
converterPromiseOptionalNull?: boolean
52+
converterPromiseOptionalNull?: boolean;
53+
min_manifest_version?: number;
54+
max_manifest_version?: number;
5155
}
5256
interface Indexable<V> {
5357
[k: string]: V;

0 commit comments

Comments
 (0)