browser-extension-settings 0.8.4 → 0.8.6

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.
Files changed (2) hide show
  1. package/lib/settings.ts +19 -12
  2. package/package.json +2 -2
package/lib/settings.ts CHANGED
@@ -549,7 +549,10 @@ function createSettingsElement() {
549
549
  return settingsMain
550
550
  }
551
551
 
552
- function addCommonSettings(settingsTable: SettingsTable) {
552
+ function addCommonSettings(
553
+ settingsTable: SettingsTable,
554
+ options: { locale?: boolean }
555
+ ) {
553
556
  let maxGroup = 0
554
557
  for (const key in settingsTable) {
555
558
  if (Object.hasOwn(settingsTable, key)) {
@@ -561,15 +564,17 @@ function addCommonSettings(settingsTable: SettingsTable) {
561
564
  }
562
565
  }
563
566
 
564
- // Switch locale
565
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
566
- settingsTable.locale = {
567
- title: i("settings.locale"),
568
- type: "select",
569
- defaultValue: "",
570
- options: {},
571
- group: ++maxGroup,
572
- } as SettingsSelectItem
567
+ if (options.locale) {
568
+ // Switch locale
569
+ // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
570
+ settingsTable.locale = {
571
+ title: i("settings.locale"),
572
+ type: "select",
573
+ defaultValue: "",
574
+ options: {},
575
+ group: ++maxGroup,
576
+ } as SettingsSelectItem
577
+ }
573
578
 
574
579
  // // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
575
580
  // settingsTable.displaySettingsButtonInSideMenu = {
@@ -635,9 +640,11 @@ const resetSettingsUI = (optionsProvider: () => SettingsOptions) => {
635
640
 
636
641
  const options = optionsProvider()
637
642
  settingsOptions = options
638
- settingsTable = options.settingsTable || {}
639
- addCommonSettings(settingsTable)
643
+ settingsTable = structuredClone(options.settingsTable || {})
640
644
  const availableLocales = options.availableLocales
645
+ addCommonSettings(settingsTable, {
646
+ locale: Boolean(availableLocales?.length),
647
+ })
641
648
  if (availableLocales?.length) {
642
649
  initAvailableLocales(availableLocales)
643
650
  const localeSelect = settingsTable.locale as SettingsSelectItem
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "browser-extension-settings",
3
- "version": "0.8.4",
3
+ "version": "0.8.6",
4
4
  "description": "Settings module for developing browser extensions and userscripts",
5
5
  "type": "module",
6
6
  "main": "./lib/index.ts",
@@ -32,7 +32,7 @@
32
32
  "dependencies": {
33
33
  "browser-extension-i18n": "^0.1.3",
34
34
  "browser-extension-storage": "^0.2.8",
35
- "browser-extension-utils": "^0.3.3"
35
+ "browser-extension-utils": "^0.3.4"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/chrome": "^0.1.32",