@onyx-p/imlib-web 1.9.4 → 1.9.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/index.esm.js +66 -20
- package/index.umd.js +66 -20
- package/package.json +1 -1
package/index.esm.js
CHANGED
@@ -7737,33 +7737,71 @@ const throttle = (fn, delay = 200) => {
|
|
7737
7737
|
|
7738
7738
|
const AesKey = CryptoJS.enc.Utf8.parse('skdjhfgc9829kslf');
|
7739
7739
|
const AesIv = CryptoJS.enc.Utf8.parse('qwdkshjf9838jsdf');
|
7740
|
+
const isElectron = () => {
|
7741
|
+
return typeof process !== 'undefined' && typeof process.versions !== 'undefined' && !!process.versions.electron;
|
7742
|
+
};
|
7743
|
+
let electronStore = null;
|
7744
|
+
if (isElectron()) {
|
7745
|
+
try {
|
7746
|
+
const Store = require('electron-store');
|
7747
|
+
electronStore = new Store();
|
7748
|
+
} catch (e) {
|
7749
|
+
console.error('Failed to initialize electron-store:', e);
|
7750
|
+
}
|
7751
|
+
}
|
7740
7752
|
const LocalStorageService = {
|
7741
7753
|
get: function (key) {
|
7742
|
-
|
7743
|
-
|
7754
|
+
if (isElectron() && electronStore) {
|
7755
|
+
const value = electronStore.get(key);
|
7744
7756
|
return value;
|
7745
7757
|
}
|
7746
|
-
|
7747
|
-
value =
|
7748
|
-
|
7749
|
-
|
7750
|
-
|
7758
|
+
if (typeof localStorage !== 'undefined') {
|
7759
|
+
let value = localStorage.getItem(key);
|
7760
|
+
if (!isDef(value)) {
|
7761
|
+
return value;
|
7762
|
+
}
|
7763
|
+
try {
|
7764
|
+
value = JSON.parse(value);
|
7765
|
+
return value;
|
7766
|
+
} catch {
|
7767
|
+
return value;
|
7768
|
+
}
|
7751
7769
|
}
|
7770
|
+
return null;
|
7752
7771
|
},
|
7753
7772
|
set: function (key, value) {
|
7754
|
-
if (isDef(value)) {
|
7755
|
-
localStorage.setItem(key, JSON.stringify(value));
|
7756
|
-
} else {
|
7773
|
+
if (!isDef(value)) {
|
7757
7774
|
this.remove(key);
|
7775
|
+
return;
|
7776
|
+
}
|
7777
|
+
if (isElectron() && electronStore) {
|
7778
|
+
electronStore.set(key, value);
|
7779
|
+
return;
|
7780
|
+
}
|
7781
|
+
if (typeof localStorage !== 'undefined') {
|
7782
|
+
localStorage.setItem(key, JSON.stringify(value));
|
7758
7783
|
}
|
7759
7784
|
},
|
7760
7785
|
remove: function (key) {
|
7761
|
-
|
7786
|
+
if (isElectron() && electronStore) {
|
7787
|
+
electronStore.delete(key);
|
7788
|
+
return;
|
7789
|
+
}
|
7790
|
+
if (typeof localStorage !== 'undefined') {
|
7791
|
+
localStorage.removeItem(key);
|
7792
|
+
}
|
7762
7793
|
}
|
7763
7794
|
};
|
7764
7795
|
const SecureStorageService = {
|
7765
7796
|
get: function (key) {
|
7766
|
-
let value
|
7797
|
+
let value;
|
7798
|
+
if (isElectron() && electronStore) {
|
7799
|
+
value = electronStore.get(key);
|
7800
|
+
} else if (typeof localStorage !== 'undefined') {
|
7801
|
+
value = localStorage.getItem(key);
|
7802
|
+
} else {
|
7803
|
+
return null;
|
7804
|
+
}
|
7767
7805
|
if (isDef(value)) {
|
7768
7806
|
const encryptedHexStr = CryptoJS.enc.Hex.parse(value);
|
7769
7807
|
const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
|
@@ -7783,18 +7821,26 @@ const SecureStorageService = {
|
|
7783
7821
|
}
|
7784
7822
|
},
|
7785
7823
|
set: function (key, value) {
|
7786
|
-
if (isDef(value)) {
|
7787
|
-
const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(value), AesKey, {
|
7788
|
-
iv: AesIv
|
7789
|
-
});
|
7790
|
-
const encrytedStr = encryptedData.ciphertext.toString();
|
7791
|
-
localStorage.setItem(key, encrytedStr);
|
7792
|
-
} else {
|
7824
|
+
if (!isDef(value)) {
|
7793
7825
|
this.remove(key);
|
7826
|
+
return;
|
7827
|
+
}
|
7828
|
+
const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(value), AesKey, {
|
7829
|
+
iv: AesIv
|
7830
|
+
});
|
7831
|
+
const encrytedStr = encryptedData.ciphertext.toString();
|
7832
|
+
if (isElectron() && electronStore) {
|
7833
|
+
electronStore.set(key, encrytedStr);
|
7834
|
+
} else if (typeof localStorage !== 'undefined') {
|
7835
|
+
localStorage.setItem(key, encrytedStr);
|
7794
7836
|
}
|
7795
7837
|
},
|
7796
7838
|
remove: function (key) {
|
7797
|
-
|
7839
|
+
if (isElectron() && electronStore) {
|
7840
|
+
electronStore.delete(key);
|
7841
|
+
} else if (typeof localStorage !== 'undefined') {
|
7842
|
+
localStorage.removeItem(key);
|
7843
|
+
}
|
7798
7844
|
}
|
7799
7845
|
};
|
7800
7846
|
const STORAGE_ROOT_KEY = 'ACIM-';
|
package/index.umd.js
CHANGED
@@ -7743,33 +7743,71 @@
|
|
7743
7743
|
|
7744
7744
|
const AesKey = CryptoJS.enc.Utf8.parse('skdjhfgc9829kslf');
|
7745
7745
|
const AesIv = CryptoJS.enc.Utf8.parse('qwdkshjf9838jsdf');
|
7746
|
+
const isElectron = () => {
|
7747
|
+
return typeof process !== 'undefined' && typeof process.versions !== 'undefined' && !!process.versions.electron;
|
7748
|
+
};
|
7749
|
+
let electronStore = null;
|
7750
|
+
if (isElectron()) {
|
7751
|
+
try {
|
7752
|
+
const Store = require('electron-store');
|
7753
|
+
electronStore = new Store();
|
7754
|
+
} catch (e) {
|
7755
|
+
console.error('Failed to initialize electron-store:', e);
|
7756
|
+
}
|
7757
|
+
}
|
7746
7758
|
const LocalStorageService = {
|
7747
7759
|
get: function (key) {
|
7748
|
-
|
7749
|
-
|
7760
|
+
if (isElectron() && electronStore) {
|
7761
|
+
const value = electronStore.get(key);
|
7750
7762
|
return value;
|
7751
7763
|
}
|
7752
|
-
|
7753
|
-
value =
|
7754
|
-
|
7755
|
-
|
7756
|
-
|
7764
|
+
if (typeof localStorage !== 'undefined') {
|
7765
|
+
let value = localStorage.getItem(key);
|
7766
|
+
if (!isDef(value)) {
|
7767
|
+
return value;
|
7768
|
+
}
|
7769
|
+
try {
|
7770
|
+
value = JSON.parse(value);
|
7771
|
+
return value;
|
7772
|
+
} catch {
|
7773
|
+
return value;
|
7774
|
+
}
|
7757
7775
|
}
|
7776
|
+
return null;
|
7758
7777
|
},
|
7759
7778
|
set: function (key, value) {
|
7760
|
-
if (isDef(value)) {
|
7761
|
-
localStorage.setItem(key, JSON.stringify(value));
|
7762
|
-
} else {
|
7779
|
+
if (!isDef(value)) {
|
7763
7780
|
this.remove(key);
|
7781
|
+
return;
|
7782
|
+
}
|
7783
|
+
if (isElectron() && electronStore) {
|
7784
|
+
electronStore.set(key, value);
|
7785
|
+
return;
|
7786
|
+
}
|
7787
|
+
if (typeof localStorage !== 'undefined') {
|
7788
|
+
localStorage.setItem(key, JSON.stringify(value));
|
7764
7789
|
}
|
7765
7790
|
},
|
7766
7791
|
remove: function (key) {
|
7767
|
-
|
7792
|
+
if (isElectron() && electronStore) {
|
7793
|
+
electronStore.delete(key);
|
7794
|
+
return;
|
7795
|
+
}
|
7796
|
+
if (typeof localStorage !== 'undefined') {
|
7797
|
+
localStorage.removeItem(key);
|
7798
|
+
}
|
7768
7799
|
}
|
7769
7800
|
};
|
7770
7801
|
const SecureStorageService = {
|
7771
7802
|
get: function (key) {
|
7772
|
-
let value
|
7803
|
+
let value;
|
7804
|
+
if (isElectron() && electronStore) {
|
7805
|
+
value = electronStore.get(key);
|
7806
|
+
} else if (typeof localStorage !== 'undefined') {
|
7807
|
+
value = localStorage.getItem(key);
|
7808
|
+
} else {
|
7809
|
+
return null;
|
7810
|
+
}
|
7773
7811
|
if (isDef(value)) {
|
7774
7812
|
const encryptedHexStr = CryptoJS.enc.Hex.parse(value);
|
7775
7813
|
const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
|
@@ -7789,18 +7827,26 @@
|
|
7789
7827
|
}
|
7790
7828
|
},
|
7791
7829
|
set: function (key, value) {
|
7792
|
-
if (isDef(value)) {
|
7793
|
-
const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(value), AesKey, {
|
7794
|
-
iv: AesIv
|
7795
|
-
});
|
7796
|
-
const encrytedStr = encryptedData.ciphertext.toString();
|
7797
|
-
localStorage.setItem(key, encrytedStr);
|
7798
|
-
} else {
|
7830
|
+
if (!isDef(value)) {
|
7799
7831
|
this.remove(key);
|
7832
|
+
return;
|
7833
|
+
}
|
7834
|
+
const encryptedData = CryptoJS.AES.encrypt(JSON.stringify(value), AesKey, {
|
7835
|
+
iv: AesIv
|
7836
|
+
});
|
7837
|
+
const encrytedStr = encryptedData.ciphertext.toString();
|
7838
|
+
if (isElectron() && electronStore) {
|
7839
|
+
electronStore.set(key, encrytedStr);
|
7840
|
+
} else if (typeof localStorage !== 'undefined') {
|
7841
|
+
localStorage.setItem(key, encrytedStr);
|
7800
7842
|
}
|
7801
7843
|
},
|
7802
7844
|
remove: function (key) {
|
7803
|
-
|
7845
|
+
if (isElectron() && electronStore) {
|
7846
|
+
electronStore.delete(key);
|
7847
|
+
} else if (typeof localStorage !== 'undefined') {
|
7848
|
+
localStorage.removeItem(key);
|
7849
|
+
}
|
7804
7850
|
}
|
7805
7851
|
};
|
7806
7852
|
const STORAGE_ROOT_KEY = 'ACIM-';
|