puvox-library 1.0.78 → 1.0.80
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/library_standard.d.ts +10 -5
- package/library_standard.d.ts.map +1 -1
- package/library_standard.js +57 -47
- package/package.json +1 -1
package/library_standard.d.ts
CHANGED
@@ -137,7 +137,8 @@ declare class PuvoxLibrary {
|
|
137
137
|
animationClick(element: any, animation: any, removeOrNot: any): void;
|
138
138
|
animationClickTarget(element: any, target: any, animation: any, removeOrNot: any): void;
|
139
139
|
datetime: {
|
140
|
-
|
140
|
+
parentClass: null;
|
141
|
+
mainClass(): null;
|
141
142
|
isBetweenHMS(target: any, start: any, end: any, equality: any): void;
|
142
143
|
equalDays(d1: any, d2: any): boolean;
|
143
144
|
IsTodayStart(dt: any): void;
|
@@ -372,7 +373,8 @@ declare class PuvoxLibrary {
|
|
372
373
|
setAppName(name: any): void;
|
373
374
|
getAppName(): never;
|
374
375
|
Cookies: {
|
375
|
-
|
376
|
+
parentClass: null;
|
377
|
+
mainClass(): null;
|
376
378
|
get(a: any, b: any): any;
|
377
379
|
set(a: any, b: any, c: any): any;
|
378
380
|
remove(a: any, b: any): any;
|
@@ -389,7 +391,8 @@ declare class PuvoxLibrary {
|
|
389
391
|
cookies: () => any;
|
390
392
|
};
|
391
393
|
cache: {
|
392
|
-
|
394
|
+
parentClass: null;
|
395
|
+
mainClass(): null;
|
393
396
|
helper_read(groupName: any, storageType: any, expireSeconds?: number): any;
|
394
397
|
helper_write(groupName: any, content: any, storageType: any): true | undefined;
|
395
398
|
helper_delete(groupName: any, storageType: any): true | undefined;
|
@@ -400,7 +403,8 @@ declare class PuvoxLibrary {
|
|
400
403
|
setChild(groupName: any, optName: any, val: any, storageType?: string): void;
|
401
404
|
deleteChild(groupName: any, optName: any, storageType?: string): void;
|
402
405
|
file: {
|
403
|
-
|
406
|
+
parentClass: null;
|
407
|
+
mainClass(): any;
|
404
408
|
customCacheDir: null;
|
405
409
|
get_dir(): any;
|
406
410
|
set_dir(dir: any, auto_clear_seconds?: null): any;
|
@@ -418,7 +422,8 @@ declare class PuvoxLibrary {
|
|
418
422
|
};
|
419
423
|
};
|
420
424
|
file: {
|
421
|
-
|
425
|
+
parentClass: null;
|
426
|
+
mainClass(): null;
|
422
427
|
set_module(module: any): void;
|
423
428
|
module_fs: any;
|
424
429
|
module_path: any;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"library_standard.d.ts","sourceRoot":"","sources":["library_standard.js"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;EAeE;AAEF;IAGC,0BAEC;IAJD,uBAAgB;IAQhB,uDAEC;IACD,4DAGC;IACD,4DAGC;IACD,6CAIC;IACD,8CAIC;
|
1
|
+
{"version":3,"file":"library_standard.d.ts","sourceRoot":"","sources":["library_standard.js"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;EAeE;AAEF;IAGC,0BAEC;IAJD,uBAAgB;IAQhB,uDAEC;IACD,4DAGC;IACD,4DAGC;IACD,6CAIC;IACD,8CAIC;IAskDE,uCAGC;IAxkDJ,iDAMC;IACD,oCAEC;IACD,6DAYC;IACD,kCAA8D;IAC9D,+BAAkD;IAClD,6BAAuD;IACvD,uCAOC;IACD,6CAOC;IACD,6CAEC;IACD,kDAEC;IACD,uCAsDC;IACD,+BAKI;IACJ,0DAEC;IACD,yCAMC;IACD,2CAEC;IAED,0BAEC;IAEE,uCAEC;IAED,yCAIC;IACD,2DASC;IACJ,0EAWI;IAKJ,uEAiBC;IAKD,kCAMC;IAED,yCAKC;IAQD,qDAkBC;IACD,oDAmCC;IAED,6DAOC;IACD,8BAKC;IAED,qBAIC;IAED,qCAGC;IAGD,0DAYC;IAGD,wBAAqE;IAErE,2CAA+I;IAE/I,mCAAmF;IAEnF,sCAAkF;IAElF,iDAAyG;IAGzG,8BAA0D;IAE1D,wCAAkE;IAE/D,qEAIC;IAIJ,qJAQC;IAw/FE,+BAA4B;IAt/F/B,2BAA2C;IAC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GC;IACD,4BAEC;IAED,mBAAwC;IACxC,oBAA0I;IAC1I,qBAA6F;IAC7F,mBAA0E;IAE1E,gBAA4H;IAC5H,2BAAmB;IAEnB,kBAAgI;IAChI,wBAAmF;IAChF,mBAAgD;IAEnD,kBAAe;IACf,2BAAsB;IACtB,kBAAoD;CAEpD"}
|
package/library_standard.js
CHANGED
@@ -877,11 +877,13 @@ class PuvoxLibrary {
|
|
877
877
|
}
|
878
878
|
|
879
879
|
|
880
|
-
datetime = new (class{
|
881
|
-
|
882
|
-
constructor(
|
883
|
-
this.
|
880
|
+
datetime = new (class {
|
881
|
+
parentClass = null;
|
882
|
+
constructor(parentClass){
|
883
|
+
this.parentClass = parentClass;
|
884
884
|
}
|
885
|
+
mainClass() { return this.parentClass; }
|
886
|
+
|
885
887
|
// 0940 type time-ints
|
886
888
|
isBetweenHMS(target, start, end, equality) { } // datetime, int/datetime, int/datetime, bool
|
887
889
|
equalDays(d1,d2) {
|
@@ -1012,20 +1014,20 @@ class PuvoxLibrary {
|
|
1012
1014
|
return curr_dt.getYear() ==target_dt.getYear() && curr_dt.getMonth() ==target_dt.getMonth() && curr_dt.getDate() ==target_dt.getDate() && curr_dt.getHours() ==target_dt.getHours() && curr_dt.getMinutes() ==target_dt.getMinutes() && curr_dt.getSeconds() ==target_dt.getSeconds();
|
1013
1015
|
}
|
1014
1016
|
dateCompare(date1, date2){
|
1015
|
-
var date1 = this.
|
1017
|
+
var date1 = this.mainClass().isString(date1) ? Date.parse(date1) : date1;
|
1016
1018
|
date1 = new Date( date1 );
|
1017
1019
|
var date2 = date2 || new Date(Date.now());
|
1018
1020
|
return (+date1 > +date2 ? 1 : +date1 < +date2 ? -1 : 0);
|
1019
1021
|
}
|
1020
1022
|
dateTill(date1, date2){
|
1021
|
-
var date1 = this.
|
1023
|
+
var date1 = this.mainClass().isString(date1) ? Date.parse(date1) : date1;
|
1022
1024
|
date1 = new Date( date1 );
|
1023
1025
|
var date2 = date2 || new Date(Date.now());
|
1024
1026
|
var diff = new Date(date1.getTime()-date2.getTime());
|
1025
1027
|
return diff;
|
1026
1028
|
}
|
1027
1029
|
secondsTill(date1, date2){
|
1028
|
-
var date1 = this.
|
1030
|
+
var date1 = this.mainClass().isString(date1) ? Date.parse(date1) : date1;
|
1029
1031
|
date1 = new Date( date1 );
|
1030
1032
|
var date2 = date2 || new Date(Date.now());
|
1031
1033
|
var diffS = date1.getTime()-date2.getTime();
|
@@ -2875,11 +2877,13 @@ class PuvoxLibrary {
|
|
2875
2877
|
|
2876
2878
|
|
2877
2879
|
// ######## Cookies: https://github.com/ttodua/useful-javascript/blob/master/cookies-library.js ######## //
|
2878
|
-
Cookies = new (class{
|
2879
|
-
|
2880
|
-
constructor(
|
2881
|
-
this.
|
2880
|
+
Cookies = new (class {
|
2881
|
+
parentClass = null;
|
2882
|
+
constructor(parentClass){
|
2883
|
+
this.parentClass = parentClass;
|
2882
2884
|
}
|
2885
|
+
mainClass() { return this.parentClass; }
|
2886
|
+
|
2883
2887
|
get(a,b) { return this.cookies_instance().get(a,b); }
|
2884
2888
|
set(a,b,c) { return this.cookies_instance().set(a,b); }
|
2885
2889
|
remove(a, b) {return this.cookies_instance().remove(a,b); }
|
@@ -2936,7 +2940,7 @@ class PuvoxLibrary {
|
|
2936
2940
|
}
|
2937
2941
|
else if(!Add_or_remove && existing.includes(subValue) )
|
2938
2942
|
{
|
2939
|
-
existing = this.
|
2943
|
+
existing = this.mainClass().removeItem(existing, subValue);
|
2940
2944
|
}
|
2941
2945
|
this.setOption(cookieName, key, JSON.stringify(existing));
|
2942
2946
|
}
|
@@ -2948,18 +2952,20 @@ class PuvoxLibrary {
|
|
2948
2952
|
})(this);
|
2949
2953
|
|
2950
2954
|
|
2951
|
-
cache = new (class{
|
2952
|
-
|
2953
|
-
constructor(
|
2954
|
-
this.
|
2955
|
+
cache = new (class {
|
2956
|
+
parentClass = null;
|
2957
|
+
constructor(parentClass){
|
2958
|
+
this.parentClass = parentClass;
|
2955
2959
|
}
|
2960
|
+
mainClass() { return this.parentClass; }
|
2961
|
+
|
2956
2962
|
helper_read(groupName, storageType, expireSeconds = 0){
|
2957
|
-
const appName = this.
|
2963
|
+
const appName = this.mainClass().getAppName();
|
2958
2964
|
if (storageType === 'file'){
|
2959
|
-
const dir = this.
|
2965
|
+
const dir = this.mainClass().file.tempDir() + appName + '/';
|
2960
2966
|
const filepath = dir + groupName + '.json';
|
2961
2967
|
// todo: add expiration
|
2962
|
-
return this.
|
2968
|
+
return this.mainClass().file.read(filepath);
|
2963
2969
|
} else if (storageType === 'localStorage') {
|
2964
2970
|
const storage = window.localStorage;
|
2965
2971
|
let val = storage.getItem(appName + '_' + groupName);
|
@@ -2978,14 +2984,14 @@ class PuvoxLibrary {
|
|
2978
2984
|
}
|
2979
2985
|
}
|
2980
2986
|
helper_write(groupName, content, storageType){
|
2981
|
-
content = this.
|
2982
|
-
const appName = this.
|
2987
|
+
content = this.mainClass().isString (content) ? content : (this.mainClass().isArray(content) || this.mainClass().isObject(content) ? JSON.stringify(content) : content);
|
2988
|
+
const appName = this.mainClass().getAppName();
|
2983
2989
|
if (storageType === 'file'){
|
2984
|
-
const dir = this.
|
2985
|
-
this.
|
2990
|
+
const dir = this.mainClass().file.tempDir() + appName + '/';
|
2991
|
+
this.mainClass().file.createDirectory(dir);
|
2986
2992
|
const filepath = dir + groupName + '.json';
|
2987
2993
|
// todo: add expiration
|
2988
|
-
this.
|
2994
|
+
this.mainClass().file.write(filepath, content);
|
2989
2995
|
return true;
|
2990
2996
|
} else if (storageType === 'localStorage') {
|
2991
2997
|
try{
|
@@ -3001,11 +3007,11 @@ class PuvoxLibrary {
|
|
3001
3007
|
}
|
3002
3008
|
}
|
3003
3009
|
helper_delete(groupName, storageType){
|
3004
|
-
const appName = this.
|
3010
|
+
const appName = this.mainClass().getAppName();
|
3005
3011
|
if (storageType === 'file'){
|
3006
|
-
const filepath = this.
|
3012
|
+
const filepath = this.mainClass().file.tempDir() + appName + '/' + groupName + '.json';
|
3007
3013
|
// todo: better delete
|
3008
|
-
this.
|
3014
|
+
this.mainClass().file.delete(filepath);
|
3009
3015
|
return true;
|
3010
3016
|
} else if (storageType === 'localStorage') {
|
3011
3017
|
try{
|
@@ -3054,22 +3060,24 @@ class PuvoxLibrary {
|
|
3054
3060
|
|
3055
3061
|
|
3056
3062
|
file = new (class {
|
3057
|
-
|
3058
|
-
constructor(
|
3059
|
-
this.
|
3063
|
+
parentClass = null;
|
3064
|
+
constructor(parentClass){
|
3065
|
+
this.parentClass = parentClass;
|
3060
3066
|
}
|
3067
|
+
mainClass() { return this.parentClass.parentClass; }
|
3068
|
+
|
3061
3069
|
// ########## CACHE DIRS (server-side JS) ##########
|
3062
3070
|
customCacheDir = null;
|
3063
3071
|
get_dir(){
|
3064
3072
|
if (!this.customCacheDir){
|
3065
|
-
this.customCacheDir = this.
|
3073
|
+
this.customCacheDir = this.mainClass().file.tempDir();
|
3066
3074
|
}
|
3067
|
-
let finaldir = this.
|
3075
|
+
let finaldir = this.mainClass().trailingSlash(this.customCacheDir + this.mainClass().getAppName() + '_cache_');
|
3068
3076
|
return finaldir;
|
3069
3077
|
}
|
3070
3078
|
set_dir(dir, auto_clear_seconds=null){
|
3071
3079
|
if(dir) this.customCacheDir = dir;
|
3072
|
-
const res = this.
|
3080
|
+
const res = this.mainClass().file.createDirectory(this.customCacheDir);
|
3073
3081
|
if( !is_null(auto_clear_seconds))
|
3074
3082
|
{
|
3075
3083
|
throw new Error("Not implemented yet! 345346");
|
@@ -3078,7 +3086,7 @@ class PuvoxLibrary {
|
|
3078
3086
|
return res;
|
3079
3087
|
}
|
3080
3088
|
filePath(uniqFileName){
|
3081
|
-
const parent = this.
|
3089
|
+
const parent = this.mainClass();
|
3082
3090
|
uniqFileName = parent.isString(uniqFileName) || parent.isNumeric(uniqFileName) ? uniqFileName : JSON.stringify(uniqFileName);
|
3083
3091
|
uniqFileName = parent.sanitize_key_dashed(parent.getCharsFromStart(uniqFileName, 15)) + "_"+ parent.md5(uniqFileName);
|
3084
3092
|
filePath= this.get_dir() + uniqFileName + "_tmp"; //"/".
|
@@ -3087,7 +3095,7 @@ class PuvoxLibrary {
|
|
3087
3095
|
//
|
3088
3096
|
get(uniqFileName, defaultContent ='', expire_seconds=8640000, decode = true)
|
3089
3097
|
{
|
3090
|
-
const parent = this.
|
3098
|
+
const parent = this.mainClass();
|
3091
3099
|
let filePath = this.filePath(uniqFileName);
|
3092
3100
|
if ( parent.file.exists(filePath) ){
|
3093
3101
|
if ( parent.file.mtime(filePath) + expire_seconds *1000 < (new Date()).getTime() ){
|
@@ -3120,7 +3128,7 @@ class PuvoxLibrary {
|
|
3120
3128
|
}
|
3121
3129
|
set(uniqFileName, content)
|
3122
3130
|
{
|
3123
|
-
const parent = this.
|
3131
|
+
const parent = this.mainClass();
|
3124
3132
|
let filePath= this.filePath(uniqFileName);
|
3125
3133
|
let contentFinal = parent.isString(content) ? content : ((parent.isArray(content) || parent.isObject(content)) ? JSON.stringify(content) : content);
|
3126
3134
|
return parent.file.write(filePath, contentFinal);
|
@@ -3132,14 +3140,14 @@ class PuvoxLibrary {
|
|
3132
3140
|
// try{
|
3133
3141
|
// var callback = callback || function(){};
|
3134
3142
|
// var self = this;
|
3135
|
-
// this.
|
3143
|
+
// this.mainClass().modules('fs').readFile(filePath, 'utf8', function(err,data) {
|
3136
3144
|
// let json = {};
|
3137
3145
|
// if (typeof data !="undefined" && data!=''){
|
3138
3146
|
// json=JSON.parse(data);
|
3139
3147
|
// }
|
3140
3148
|
// let jsonNew = self.jsonConcat(json, jsonContent);
|
3141
3149
|
// let content = JSON.stringify(jsonNew);
|
3142
|
-
// this.
|
3150
|
+
// this.mainClass().modules('fs').writeFile(filePath, content, 'utf8', function(callback_) {
|
3143
3151
|
// });
|
3144
3152
|
// });
|
3145
3153
|
// }
|
@@ -3150,21 +3158,21 @@ class PuvoxLibrary {
|
|
3150
3158
|
containerDefaultPrefix = "_cached_ids_";
|
3151
3159
|
tempIds = {};
|
3152
3160
|
idForContent(slugOrContent){
|
3153
|
-
return this.
|
3161
|
+
return this.mainClass().md5(this.mainClass().isSimpleVariableType(slugOrContent) ? slugOrContent : JSON.stringify(slugOrContent));
|
3154
3162
|
}
|
3155
3163
|
existsId(containerSlug, id){
|
3156
3164
|
return (id in this.getIds(containerSlug));
|
3157
3165
|
}
|
3158
3166
|
getIds(containerSlug) {
|
3159
3167
|
if (! (containerSlug in this.tempIds)) {
|
3160
|
-
const content = this.
|
3168
|
+
const content = this.mainClass().file.read(this.get_dir() + this.containerDefaultPrefix + containerSlug, '{}');
|
3161
3169
|
this.tempIds[containerSlug] = JSON.parse(content);
|
3162
3170
|
}
|
3163
3171
|
return this.tempIds[containerSlug];
|
3164
3172
|
}
|
3165
3173
|
setIds(containerSlug, idsDict) {
|
3166
3174
|
this.tempIds[containerSlug] = idsDict;
|
3167
|
-
return this.
|
3175
|
+
return this.mainClass().file.write(this.get_dir() + this.containerDefaultPrefix + containerSlug, JSON.stringify(this.tempIds[containerSlug]));
|
3168
3176
|
}
|
3169
3177
|
addId(containerSlug, id){
|
3170
3178
|
const ids = this.getIds(containerSlug);
|
@@ -3178,7 +3186,7 @@ class PuvoxLibrary {
|
|
3178
3186
|
}
|
3179
3187
|
return false;
|
3180
3188
|
}
|
3181
|
-
})(this
|
3189
|
+
})(this);
|
3182
3190
|
})(this);
|
3183
3191
|
|
3184
3192
|
// ################################################
|
@@ -3193,10 +3201,12 @@ class PuvoxLibrary {
|
|
3193
3201
|
// }
|
3194
3202
|
// },
|
3195
3203
|
file = new (class {
|
3196
|
-
|
3197
|
-
constructor(
|
3198
|
-
this.
|
3204
|
+
parentClass = null;
|
3205
|
+
constructor(parentClass){
|
3206
|
+
this.parentClass = parentClass;
|
3199
3207
|
}
|
3208
|
+
mainClass() { return this.parentClass; }
|
3209
|
+
|
3200
3210
|
// support for several native modules
|
3201
3211
|
set_module(module) {
|
3202
3212
|
// 'fs'
|
@@ -3231,7 +3241,7 @@ class PuvoxLibrary {
|
|
3231
3241
|
return this.module_path;
|
3232
3242
|
}
|
3233
3243
|
// ends with slash
|
3234
|
-
tempDir(){ return this.
|
3244
|
+
tempDir(){ return this.mainClass().trailingSlash(this.os().tmpdir()); }
|
3235
3245
|
|
3236
3246
|
exists(filePath){
|
3237
3247
|
return this.fs().existsSync(filePath);
|
@@ -3259,7 +3269,7 @@ class PuvoxLibrary {
|
|
3259
3269
|
if (!this.exists(filePath)){
|
3260
3270
|
return defaultContent;
|
3261
3271
|
}
|
3262
|
-
return this.fs().readFileSync(filePath);
|
3272
|
+
return this.fs().readFileSync(filePath, 'utf8');
|
3263
3273
|
}
|
3264
3274
|
write(filePath, content){
|
3265
3275
|
const dir = this.path().dirname(filePath);
|