@azrico/global 1.3.80 → 1.3.82
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/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { gstorage, gbasket } from "./packages/storage";
|
|
2
2
|
export { gstorage, gbasket };
|
|
3
|
-
export
|
|
3
|
+
export { GlobalStorage } from "./packages/core";
|
|
4
4
|
export * as gonce from "./packages/once";
|
|
5
5
|
export * as gcache from "./packages/cache";
|
|
6
6
|
export * as gtranslate from "./packages/translation";
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var _gcache=_interopRequireWildcard(require("./packages/cache"));var _gtranslate=_interopRequireWildcard(require("./packages/translation"));var _hooks=require("./packages/hooks");function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),Object.defineProperty(exports,"GlobalStorage",{enumerable:!0,get:function get(){return _core.GlobalStorage}}),Object.defineProperty(exports,"gbasket",{enumerable:!0,get:function get(){return _storage.gbasket}}),exports.gcache=void 0,Object.defineProperty(exports,"gfilter",{enumerable:!0,get:function get(){return _hooks.gfilter}}),Object.defineProperty(exports,"gfunc",{enumerable:!0,get:function get(){return _hooks.gfunc}}),Object.defineProperty(exports,"gholder",{enumerable:!0,get:function get(){return _hooks.gholder}}),exports.gonce=void 0,Object.defineProperty(exports,"gstorage",{enumerable:!0,get:function get(){return _storage.gstorage}}),exports.gtranslate=void 0,Object.defineProperty(exports,"gview",{enumerable:!0,get:function get(){return _hooks.gview}});var _storage=require("./packages/storage"),_core=require("./packages/core"),_gonce=_interopRequireWildcard(require("./packages/once"));exports.gonce=_gonce;exports.gcache=_gcache;exports.gtranslate=_gtranslate;function _getRequireWildcardCache(a){if("function"!=typeof WeakMap)return null;var b=new WeakMap,c=new WeakMap;return(_getRequireWildcardCache=function(a){return a?c:b})(a)}function _interopRequireWildcard(b,c){if(!c&&b&&b.__esModule)return b;if(null===b||"object"!=_typeof(b)&&"function"!=typeof b)return{default:b};var d=_getRequireWildcardCache(c);if(d&&d.has(b))return d.get(b);var e={__proto__:null},f=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in b)if("default"!=a&&{}.hasOwnProperty.call(b,a)){var g=f?Object.getOwnPropertyDescriptor(b,a):null;g&&(g.get||g.set)?Object.defineProperty(e,a,g):e[a]=b[a]}return e["default"]=b,d&&d.set(b,e),e}
|
|
@@ -3,18 +3,18 @@ type MaybeFilterAction = Function | string | number;
|
|
|
3
3
|
* Adds a filter
|
|
4
4
|
* @param key
|
|
5
5
|
* @param action action of the filter. you can also use string and numbers
|
|
6
|
-
* @param
|
|
6
|
+
* @param order filters with lower order are executed first
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function add_filter(key: string, action: MaybeFilterAction,
|
|
9
|
+
export declare function add_filter(key: string, action: MaybeFilterAction, order?: number): any;
|
|
10
10
|
/**
|
|
11
11
|
* `clear_filter` on `key` and then uses `add_filter`
|
|
12
12
|
* @param key
|
|
13
13
|
* @param action action of the filter. you can also use string and numbers
|
|
14
|
-
* @param
|
|
14
|
+
* @param order filters with lower order are executed first
|
|
15
15
|
* @returns
|
|
16
16
|
*/
|
|
17
|
-
export declare function set_filter(key: string, action: MaybeFilterAction,
|
|
17
|
+
export declare function set_filter(key: string, action: MaybeFilterAction, order?: number): any;
|
|
18
18
|
export declare function remove_filter(key: string, action: Function): any;
|
|
19
19
|
export declare function clear_filter(key: string): any;
|
|
20
20
|
export declare function clear_all_filters(): any;
|
|
@@ -36,8 +36,8 @@ export declare function apply_filter_sync(key: string, initialValue?: any): any;
|
|
|
36
36
|
* Adds a filter until the current component unmounts
|
|
37
37
|
* @param key
|
|
38
38
|
* @param action
|
|
39
|
-
* @param
|
|
39
|
+
* @param order
|
|
40
40
|
* @returns
|
|
41
41
|
*/
|
|
42
|
-
export declare function hold_add_filter(key: string, action: (...args: any[]) => any,
|
|
42
|
+
export declare function hold_add_filter(key: string, action: (...args: any[]) => any, order?: number): any;
|
|
43
43
|
export {};
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
* Adds a filter
|
|
3
3
|
* @param key
|
|
4
4
|
* @param action action of the filter. you can also use string and numbers
|
|
5
|
-
* @param
|
|
5
|
+
* @param order filters with lower order are executed first
|
|
6
6
|
* @returns
|
|
7
|
-
*/function add_filter(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:10,d="function"==typeof b?b:function(){return b};return _core["default"].Global_add(lname_filter,a,{key:a,action:d,
|
|
7
|
+
*/function add_filter(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:10,d="function"==typeof b?b:function(){return b};return _core["default"].Global_add(lname_filter,a,{key:a,action:d,order:c})}/**
|
|
8
8
|
* `clear_filter` on `key` and then uses `add_filter`
|
|
9
9
|
* @param key
|
|
10
10
|
* @param action action of the filter. you can also use string and numbers
|
|
11
|
-
* @param
|
|
11
|
+
* @param order filters with lower order are executed first
|
|
12
12
|
* @returns
|
|
13
13
|
*/function set_filter(a,b){var c=2<arguments.length&&void 0!==arguments[2]?arguments[2]:10;return clear_filter(a),add_filter(a,b,c)}function remove_filter(a,b){return _core["default"].Global_remove(lname_filter,a,b)}function clear_filter(a){return _core["default"].Global_set(lname_filter,a,null)}function clear_all_filters(){return _core["default"].Global_set(lname_filter,!0,null)}/**
|
|
14
14
|
* Apply a filter asynchronously
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
* @param key
|
|
21
21
|
* @param initialValue
|
|
22
22
|
* @returns
|
|
23
|
-
*/function _apply_filter(){return _apply_filter=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i=arguments;return _regeneratorRuntime().wrap(function j(b){for(;1;)switch(b.prev=b.next){case 0:if(c=1<i.length&&void 0!==i[1]?i[1]:null,d=_core["default"].Global_get(lname_filter,a),Array.isArray(d)&&0!=d.length){b.next=4;break}return b.abrupt("return",c);case 4:d.sort(function(c,a){return c.
|
|
23
|
+
*/function _apply_filter(){return _apply_filter=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i=arguments;return _regeneratorRuntime().wrap(function j(b){for(;1;)switch(b.prev=b.next){case 0:if(c=1<i.length&&void 0!==i[1]?i[1]:null,d=_core["default"].Global_get(lname_filter,a),Array.isArray(d)&&0!=d.length){b.next=4;break}return b.abrupt("return",c);case 4:d.sort(function(c,a){return c.order>a.order?1:-1}),e=c,f=0;case 7:if(!(f<d.length)){b.next=16;break}return g=d[f],b.next=11,g.action(e);case 11:h=b.sent,e=h;case 13:f++,b.next=7;break;case 16:return b.abrupt("return",e);case 17:case"end":return b.stop()}},b)})),_apply_filter.apply(this,arguments)}function apply_filter_sync(a){var b=1<arguments.length&&arguments[1]!==void 0?arguments[1]:null,c=_core["default"].Global_get(lname_filter,a);if(!Array.isArray(c)||0==c.length)return b;c.sort(function(c,a){return c.order>a.order?1:-1});/* lower order gets executed first */for(var d=b,e=0;e<c.length;e++){var f=c[e],g=f.action(d);//console.log("filtered ", previous_value, " --> ", new_value);
|
|
24
24
|
g!==void 0&&(d=g)}return d}/* -------------------------------------------------------------------------- */ /**
|
|
25
25
|
* Adds a filter until the current component unmounts
|
|
26
26
|
* @param key
|
|
27
27
|
* @param action
|
|
28
|
-
* @param
|
|
28
|
+
* @param order
|
|
29
29
|
* @returns
|
|
30
30
|
*/function hold_add_filter(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:10,d=_react["default"].useCallback(b,[]);_react["default"].useEffect(function(){return add_filter(a,d,c),function(){remove_filter(a,d)}},[])}
|
|
@@ -4,10 +4,10 @@ type viewType = React.ReactNode | ((props: any) => React.ReactNode);
|
|
|
4
4
|
* Adds a view to view list
|
|
5
5
|
* @param key
|
|
6
6
|
* @param action action of the filter
|
|
7
|
-
* @param
|
|
7
|
+
* @param order filters with lower order are executed first
|
|
8
8
|
* @returns
|
|
9
9
|
*/
|
|
10
|
-
export declare function add_view(key: string, view: viewType,
|
|
10
|
+
export declare function add_view(key: string, view: viewType, order?: number): any;
|
|
11
11
|
/**
|
|
12
12
|
*
|
|
13
13
|
* @param view_key
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
* Adds a view to view list
|
|
3
3
|
* @param key
|
|
4
4
|
* @param action action of the filter
|
|
5
|
-
* @param
|
|
5
|
+
* @param order filters with lower order are executed first
|
|
6
6
|
* @returns
|
|
7
|
-
*/function add_view(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:10;return _core["default"].Global_add(lname_views,a,{view_key:a,view:b,
|
|
8
|
-
// const view_object = {key: key, view: view,
|
|
7
|
+
*/function add_view(a,b){var c=2<arguments.length&&arguments[2]!==void 0?arguments[2]:10;return _core["default"].Global_add(lname_views,a,{view_key:a,view:b,order:c})}// export function remove_view(key: string, view: React.ReactNode ): any {
|
|
8
|
+
// const view_object = {key: key, view: view, order: order};
|
|
9
9
|
// return glb.Global_add(lname_filter, key, view);
|
|
10
10
|
// }
|
|
11
11
|
/**
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @param view_key
|
|
14
14
|
* @param initialValue
|
|
15
15
|
* @returns
|
|
16
|
-
*/function load_views(a,b,c){var d=_core["default"].Global_get(lname_views,a);return Array.isArray(d)&&0!=d.length?(d.sort(function(c,a){return c.
|
|
16
|
+
*/function load_views(a,b,c){var d=_core["default"].Global_get(lname_views,a);return Array.isArray(d)&&0!=d.length?(d.sort(function(c,a){return c.order>a.order?1:-1}),d.map(function(a,b){return"function"==typeof a.view?a.view(_objectSpread(_objectSpread({},c),{},{key:b+""})):a.view})):b;/* lower order gets executed first */}/**
|
|
17
17
|
*
|
|
18
18
|
* @param view_key
|
|
19
19
|
* @param initialValue
|