1+ import _ from "lodash" ;
2+
13import { mergeWebAccessibleResources } from "./utils" ;
24
35import {
46 CoreManifest ,
5- FirefoxManifest ,
67 Manifest ,
78 ManifestAccessibleResource ,
89 ManifestAccessibleResources ,
@@ -14,13 +15,13 @@ import {
1415 ManifestHostPermissions ,
1516 ManifestIcons ,
1617 ManifestIncognito ,
17- ManifestPermissions ,
1818 ManifestOptionalPermissions ,
19+ ManifestPermissions ,
1920 ManifestPopup ,
2021 ManifestSidebar ,
2122 ManifestVersion ,
2223} from "@typing/manifest" ;
23- import { Browser } from "@typing/browser" ;
24+ import { Browser , BrowserSpecific } from "@typing/browser" ;
2425import { Language } from "@typing/locale" ;
2526import { CommandExecuteActionName } from "@typing/command" ;
2627import { DefaultIconGroupName } from "@typing/icon" ;
@@ -40,7 +41,6 @@ export class ManifestError extends Error {
4041
4142export default abstract class < T extends CoreManifest > implements ManifestBuilder < T > {
4243 protected name : string = "__MSG_app_name__" ;
43- protected email ?: string ;
4444 protected author ?: string ;
4545 protected homepage ?: string ;
4646 protected shortName ?: string ;
@@ -49,6 +49,7 @@ export default abstract class<T extends CoreManifest> implements ManifestBuilder
4949 protected version : string = "0.0.0" ;
5050 protected icon ?: string ;
5151 protected incognito ?: ManifestIncognito ;
52+ protected specific ?: BrowserSpecific ;
5253 protected locale ?: Language ;
5354 protected icons : ManifestIcons = new Map ( ) ;
5455 protected background ?: ManifestBackground ;
@@ -91,12 +92,6 @@ export default abstract class<T extends CoreManifest> implements ManifestBuilder
9192 return this ;
9293 }
9394
94- public setEmail ( email ?: string ) : this {
95- this . email = email ;
96-
97- return this ;
98- }
99-
10095 public setName ( name : string ) : this {
10196 this . name = name ;
10297
@@ -139,6 +134,12 @@ export default abstract class<T extends CoreManifest> implements ManifestBuilder
139134 return this ;
140135 }
141136
137+ public setSpecific ( settings ?: BrowserSpecific ) : this {
138+ this . specific = settings ;
139+
140+ return this ;
141+ }
142+
142143 public setIcons ( icons ?: ManifestIcons ) : this {
143144 this . icons = icons || new Map ( ) ;
144145
@@ -464,13 +465,52 @@ export default abstract class<T extends CoreManifest> implements ManifestBuilder
464465 }
465466 }
466467
467- protected buildBrowserSpecificSettings ( ) : Partial < FirefoxManifest > | undefined {
468- if ( this . browser === Browser . Firefox && this . email && this . permissions . has ( "storage" ) ) {
468+ protected buildBrowserSpecificSettings ( ) : Partial < Manifest > | undefined {
469+ const settings = this . specific || { } ;
470+ const { safari, gecko, geckoAndroid} = settings ;
471+
472+ if ( this . browser === Browser . Firefox ) {
473+ const emptyGecko =
474+ _ . isEmpty ( gecko ?. id ) &&
475+ _ . isEmpty ( gecko ?. strictMinVersion ) &&
476+ _ . isEmpty ( gecko ?. strictMaxVersion ) &&
477+ _ . isEmpty ( gecko ?. updateUrl ) ;
478+
479+ const emptyGeckoAndroid =
480+ _ . isEmpty ( geckoAndroid ?. strictMinVersion ) && _ . isEmpty ( geckoAndroid ?. strictMaxVersion ) ;
481+
482+ if ( emptyGecko && emptyGeckoAndroid ) {
483+ return ;
484+ }
485+
486+ return {
487+ browser_specific_settings : {
488+ gecko : emptyGecko
489+ ? undefined
490+ : {
491+ id : gecko ?. id ,
492+ strict_min_version : gecko ?. strictMinVersion ,
493+ strict_max_version : gecko ?. strictMaxVersion ,
494+ update_url : gecko ?. updateUrl ,
495+ } ,
496+ gecko_android : emptyGeckoAndroid
497+ ? undefined
498+ : {
499+ strict_min_version : geckoAndroid ?. strictMinVersion ,
500+ strict_max_version : geckoAndroid ?. strictMaxVersion ,
501+ } ,
502+ } ,
503+ } ;
504+ } else if ( this . browser === Browser . Safari ) {
505+ if ( _ . isEmpty ( safari ?. strictMinVersion ) && _ . isEmpty ( safari ?. strictMaxVersion ) ) {
506+ return ;
507+ }
508+
469509 return {
470510 browser_specific_settings : {
471- gecko : {
472- id : this . email ,
473- // strict_min_version: this.minimumVersion ,
511+ safari : {
512+ strict_min_version : safari ?. strictMinVersion ,
513+ strict_max_version : safari ?. strictMaxVersion ,
474514 } ,
475515 } ,
476516 } ;
0 commit comments