@@ -12,6 +12,7 @@ import { copy, emptyDir, move, outputFile, outputJSON, readJSON, writeJson } fro
1212import styleText from "node-style-text" ;
1313import { glob } from "tinyglobby" ;
1414import { generateHash } from "../utils/crypto.js" ;
15+ import { is32BitNumber } from "../utils/number.js" ;
1516import { PrefsManager , renderPluginPrefsDts } from "../utils/prefs-manager.js" ;
1617import { dateFormat , replaceInFile , toArray } from "../utils/string.js" ;
1718import { Base } from "./base.js" ;
@@ -268,6 +269,22 @@ export default class Build extends Base {
268269 const prefsWithPrefix = prefsManager . getPrefsWithPrefix ( prefix ) ;
269270 const prefsWithoutPrefix = prefsManager . getPrefsWithoutPrefix ( prefix ) ;
270271
272+ // Checks if the preference value for the number type is less than 32 bits.
273+ // Since the underlying Preference is implemented in C++,
274+ // although firefox specifies the preference value for the number type as long int,
275+ // the length of long int is different on each operating system.
276+ // e.g. on Windows x64:
277+ // Zotero Prefs.set("extensions.test.number" 22222222222222222)
278+ // zotero.Prefs.get("extensions.test.number") // return 1383176888 but expected 22222222222222222
279+ const prefs = prefsManager . getPrefs ( ) ;
280+ Object . entries ( prefs ) . forEach ( ( [ key , value ] ) => {
281+ if ( typeof value === "number" ) {
282+ if ( ! is32BitNumber ( value ) ) {
283+ this . logger . warn ( `Pref key '${ styleText . blue ( key ) } ' is a number, but is more than 4 bytes, which can be problematic on some OS.` ) ;
284+ }
285+ }
286+ } ) ;
287+
271288 // Generate prefs.d.ts
272289 if ( dts ) {
273290 const dtsContent = renderPluginPrefsDts ( prefsWithoutPrefix ) ;
0 commit comments