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.
- package/lib/settings.ts +19 -12
- 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(
|
|
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
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
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.
|
|
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.
|
|
35
|
+
"browser-extension-utils": "^0.3.4"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/chrome": "^0.1.32",
|