20240517
This commit is contained in:
268
node_modules/store2/README.md
generated
vendored
Normal file
268
node_modules/store2/README.md
generated
vendored
Normal file
@@ -0,0 +1,268 @@
|
||||
A feature-filled and friendly way to take advantage of localStorage and sessionStorage
|
||||
(JSON, namespacing, extensions, etc).
|
||||
|
||||
Download: [store2.min.js][prod] or [store2.js][dev]
|
||||
[NPM][npm]: `npm install store2`
|
||||
[NuGet][]: `Install-Package store2`
|
||||
|
||||
[NuGet]: http://nuget.org/packages/store2/
|
||||
[prod]: https://raw.github.com/nbubna/store/master/dist/store2.min.js
|
||||
[dev]: https://raw.github.com/nbubna/store/master/dist/store2.js
|
||||
[npm]: https://npmjs.org/package/store2
|
||||
|
||||
[](https://travis-ci.org/nbubna/store)
|
||||
[](https://badge.fury.io/js/store2)
|
||||
[](https://www.npmjs.com/package/store2)
|
||||
|
||||
## Documentation
|
||||
The main store function can handle ```set```, ```get```, ```transact```, ```setAll```, ```getAll```, ```each```, and ```clear```
|
||||
actions directly. Respectively, these are called like so:
|
||||
|
||||
```javascript
|
||||
store(key, data); // sets stringified data under key
|
||||
store(key); // gets and parses data stored under key
|
||||
store(key, fn[, alt]); // run transaction function on/with data stored under key
|
||||
store({key: data, key2: data2}); // sets all key/data pairs in the object
|
||||
store(); // gets all stored key/data pairs as an object
|
||||
store((key, data)=>{ }); // calls function for each key/data in storage, return false to exit
|
||||
store(false); // clears all items from storage
|
||||
```
|
||||
|
||||
Parameters in [brackets] are optional. There are also more explicit and versatile functions available:
|
||||
|
||||
```javascript
|
||||
store.set(key, data[, overwrite]); // === store(key, data);
|
||||
store.setAll(data[, overwrite]); // === store({key: data, key2: data});
|
||||
store.get(key[, alt]); // === store(key);
|
||||
store.getAll([fillObj]); // === store();
|
||||
store.transact(key, fn[, alt]); // === store(key, fn[, alt]);
|
||||
store.clear(); // === store(false);
|
||||
store.has(key); // returns true or false
|
||||
store.remove(key[, alt]); // removes key and its data, then returns the data or alt, if none
|
||||
store.each(fn[, fill]); // === store(fn); optional call arg will be 3rd fn arg (e.g. for gathering values)
|
||||
store.add(key, data[, replacer]); // concats, merges, or adds new value into existing one
|
||||
store.keys([fillList]); // returns array of keys
|
||||
store.size(); // number of keys, not length of data
|
||||
store.clearAll(); // clears *ALL* areas (but still namespace sensitive)
|
||||
```
|
||||
|
||||
Passing in ```false``` for the optional overwrite parameters will cause ```set``` actions to be skipped
|
||||
if the storage already has a value for that key. All ```set``` action methods return the previous value
|
||||
for that key, by default. If overwrite is ```false``` and there is a previous value, the unused new
|
||||
value will be returned.
|
||||
|
||||
Functions passed to ```transact``` will receive the current value for that key as an argument or
|
||||
a passed alternate if there is none. When the passed function is completed, transact will save the returned value
|
||||
under the specified key. If the function returns ```undefined```, the original value will be saved.
|
||||
This makes it easy for transact functions to change internal properties in a persistent way:
|
||||
|
||||
```javascript
|
||||
store.transact(key, function(obj) {
|
||||
obj.changed = 'newValue';// this change will be persisted
|
||||
});
|
||||
```
|
||||
|
||||
Functions passed to ```each``` will receive the key as first argument and current value as the second; if a `fill` parameter is specified, it's value will be the third argument for every call (few should ever
|
||||
need a `fill` parameter). If the function returns ```false``` at any point during the iteration, the
|
||||
loop will exit early and not continue on to the next key/value pair.
|
||||
|
||||
```javascript
|
||||
store.each(function(key, value) {
|
||||
console.log(key, '->', value);
|
||||
if (key === 'stopLoop') {
|
||||
return false;// this will cause each to stop calling this function
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
All retrieval functions which take an optional ```alt``` parameter can also use that parameter to specify a "reviver" function. These receive each key and value (yes, nested ones too) as arguments and allow you to provide an alternate means of parsing that string. This is particularly useful for rich objects like ```Date``` types. See [MDN's JSON.parse docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse) for more information and examples. Alternately, you can set a global reviver to the ```store._.revive``` property to handle all ```get```, ```getAll```, ```remove```, and ```transact``` calls.
|
||||
|
||||
Likewise, setter functions which take an optional ```overwrite``` parameter can also use that parameter to accept a "replacer" function that receives each key and value (yes, nested ones too) as arguments and allow you to provide an alternate means of stringifying the values. This is particularly useful for rich objects like ```Map``` or ```Set```. See [MDN's JSON.stringify docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify) for more information and examples. Alternately, you can set a global replacer to the ```store._.replace``` property to handle all ```set```, ```setAll```, ```add```, and ```transact``` calls.
|
||||
|
||||
For ```getAll``` and ```keys```, there is the option to pass in the object or list, respectively,
|
||||
that you want the results to be added to. This is instead of an empty list.
|
||||
There are only a few special cases where you are likely to need or want this,
|
||||
in general, most users should ignore these optional parameters.
|
||||
These both use the second, optional argument ```each``` function,
|
||||
which is also a niche feature. The ```value``` argument is passed as
|
||||
the second arg to the callback function (in place of the data associated with the current key)
|
||||
and is returned at the end. Again, most users should not need this feature.
|
||||
All of these use the browser's localStorage (aka "local"). Using sessionStorage merely requires
|
||||
calling the same functions on ```store.session```:
|
||||
|
||||
```javascript
|
||||
store.session("addMeTo", "sessionStorage");
|
||||
store.local({lots: 'of', data: 'altogether'});// store.local === store :)
|
||||
```
|
||||
There is also a store API automatically available for keeping non-persistent information,
|
||||
meant only to last until page reload.
|
||||
```javascript
|
||||
store.page("until","reload");
|
||||
```
|
||||
|
||||
All the specific ```get```, ```set```, etc. functions are available on ```store.session```, ```store.local```, and ```store.page```, as well as any other storage facility registered via ```store.area(name, customStorageObject)``` by an extension, where customStorageObject must implement the [Storage interface][storage]. This is how [store.old.js][old] extends store.js to support older versions of IE and Firefox.
|
||||
|
||||
[storage]: http://dev.w3.org/html5/webstorage/#the-storage-interface
|
||||
|
||||
If you want to put stored data from different pages or areas f your site into separate namespaces,
|
||||
the ```store.namespace(ns)``` function is your friend:
|
||||
|
||||
```javascript
|
||||
var cart = store.namespace('cart');
|
||||
cart('total', 23.25);// stores in localStorage as 'cart.total'
|
||||
console.log(store('cart.total') == cart('total'));// logs true
|
||||
console.log(store.cart.getAll());// logs {total: 23.25}
|
||||
cart.session('group', 'toys');// stores in sessionStorage as 'cart.group'
|
||||
```
|
||||
|
||||
The namespace provides the same exact API as ```store``` but silently adds/removes the namespace prefix as needed.
|
||||
It also makes the namespaced API accessible directly via ```store[namespace]``` (e.g. ```store.cart```) as long as it
|
||||
does not conflict with an existing part of the store API.
|
||||
|
||||
The 'namespace' function is one of three "extra" functions that are also part of the "store API":
|
||||
|
||||
```javascript
|
||||
store.namespace(prefix);// returns a new store API that prefixes all key-based functions
|
||||
store.isFake([force]);// test or set whether localStorage/sessionStorage or an in-memory, 'fake' storage is used
|
||||
```
|
||||
|
||||
```store.namespace``` can also take extra params to only create the namespace in the called-on storage area, and
|
||||
to pass in an alternate namespace delimiter for advanced use-cases (e.g. ```store.page.namespace("subpage", true, ":")```).
|
||||
|
||||
If localStorage or sessionStorage are unavailable, they will be faked to prevent errors,
|
||||
but data stored will NOT persist beyond the life of the current document/page. Use the
|
||||
[store.old.js][old] extension to add persistent backing for the store API in ancient browsers.
|
||||
|
||||
```isFake(true|false)``` is particularly useful to force use of a temporary, fake storage in testing situations,
|
||||
to prevent cluttering actual storage.
|
||||
|
||||
## Extensions
|
||||
These mostly could use further documentation and abuse...er...testing.
|
||||
Contributions are welcome!
|
||||
In particular, any ES6 user interested in making these [importable in ES6][es6importissue] would be appreciated.
|
||||
|
||||
[es6importissue]: https://github.com/nbubna/store/issues/31
|
||||
|
||||
#### Beta - Stable and definitely useful
|
||||
* [store.old.js][old] - Add working localStorage and sessionStorage polyfills for ancient browsers
|
||||
* [store.overflow.js][overflow] - Fall back to fake storage on quota errors
|
||||
* [store.cache.js][cache] - To make data expire, pass a number of seconds as the overwrite (third) param on ```set()``` calls
|
||||
* [store.on.js][on] - Superior storage event handling (per key, per namespace, etc in IE9+)
|
||||
* [store.array.js][array] - Easy, powerful array functions for any and all data (e.g. ```store.push(key, v1, v2)```).
|
||||
* [store.dom.js][dom] - Declarative, persistent DOM element content via store.
|
||||
* [store.cookie.js][cookie] - Support for a cookie as a storage area: ```store.cookie('num',1)``` to make sharing with backend easier.
|
||||
|
||||
#### Alpha - Either incomplete or unstable or both
|
||||
* [store.quota.js][quota] - Register callbacks to handle (and even cancel) quota errors
|
||||
* [store.measure.js][measure] - Experimental extension for measuring space used and available (needs work)
|
||||
* [store.onlyreal.js][onlyreal] - When only fake storage is available, silently fail instead of faking it.
|
||||
* [store.dot.js][dot] - Creates accessors for keys (e.g. ```store.foo == store.get('foo')```)
|
||||
* [store.deep.js][deep] - Allow retrieval of properties from within stored objects (e.g. ```store.get('key.property')```)
|
||||
* [store.async.js][async] - Adds ```store.async``` duplicate to each store and namespace that performs functions asynchronously and returns a Promise that resolves when complete.
|
||||
* [store.cookies.js][cookies] - Support managing all cookies as a storage area with the store API (e.g. ```store.cookies.get('user')```)
|
||||
|
||||
[old]: https://raw.github.com/nbubna/store/master/src/store.old.js
|
||||
[overflow]: https://raw.github.com/nbubna/store/master/src/store.overflow.js
|
||||
[cache]: https://raw.github.com/nbubna/store/master/src/store.cache.js
|
||||
[on]: https://raw.github.com/nbubna/store/master/src/store.on.js
|
||||
[quota]: https://raw.github.com/nbubna/store/master/src/store.quota.js
|
||||
[measure]: https://raw.github.com/nbubna/store/master/src/store.measure.js
|
||||
[onlyreal]: https://raw.github.com/nbubna/store/master/src/store.onlyreal.js
|
||||
[array]: https://raw.github.com/nbubna/store/master/src/store.array.js
|
||||
[dot]: https://raw.github.com/nbubna/store/master/src/store.dot.js
|
||||
[deep]: https://raw.github.com/nbubna/store/master/src/store.deep.js
|
||||
[dom]: https://raw.github.com/nbubna/store/master/src/store.dom.js
|
||||
[async]: https://raw.github.com/nbubna/store/master/src/store.async.js
|
||||
[cookie]: https://raw.github.com/nbubna/store/master/src/store.cookie.js
|
||||
[cookies]: https://raw.github.com/nbubna/store/master/src/store.cookies.js
|
||||
|
||||
#### Write Your Own Extension
|
||||
To write your own extension, you can use or carefully override internal functions exposed as ```store._```.
|
||||
In particular, the ```store._.fn(fnName, fn)``` method is available to automatically add your new function
|
||||
to every instance of the ```store``` interface (e.g. ```store```, ```store.session```
|
||||
and all existing and future namespaces). Take care using this, as it will override existing methods.
|
||||
Here is a simple example:
|
||||
|
||||
```javascript
|
||||
(function(_) {
|
||||
_.fn('falsy', function(key) {
|
||||
return !this.get(key);
|
||||
});
|
||||
_.fn('truthy', function(key) {
|
||||
return !this.falsy(key);
|
||||
});
|
||||
})(store._);
|
||||
```
|
||||
This extension would be used like so:
|
||||
```javascript
|
||||
store('foo', 1);
|
||||
store.falsy('foo'); // returns false
|
||||
|
||||
store.session('bar', 'one');
|
||||
store.session.truthy('bar'); // return true;
|
||||
|
||||
const widgetStore = store.namespace('widget');
|
||||
widgetStore.falsy('state'); // returns true
|
||||
```
|
||||
|
||||
## Release History
|
||||
* 2010-02-10 v0.1 (extraction from esha.js)
|
||||
* 2010-05-25 v1.0 (internal release)
|
||||
* 2013-04-09 [v2.0.3][] (public) - First GitHub release
|
||||
* 2013-04-20 [v2.1.0][] (public) - Drops flawed/confusing/unused key(i) method, fixes extension problems.
|
||||
* 2013-04-30 [v2.1.1][] (public) - Browserify (and friends) support (module.exports = store)
|
||||
* 2013-05-30 [v2.1.2][] (public) - Component support (old component.json is now bower.json)
|
||||
* 2014-03-10 [v2.1.6][] (public) - AMD support and Component improvements
|
||||
* 2015-02-02 [v2.2.0][] (public) - Change store.cache.js to use seconds, not minutes.
|
||||
* 2015-05-05 [v2.2.1][] (public) - node.js compatibility
|
||||
* 2015-05-08 [v2.2.2][] (public) - Always expose global to allow extensions to always work.
|
||||
* 2015-05-22 [v2.3.0][] (public) - Use fake storage for Safari private mode (instead of letting quota exceptions go)
|
||||
* 2015-10-27 [v2.3.2][] (public) - Add source map
|
||||
* 2017-01-04 [v2.4.0][] (public) - Add store.transact(key, fn[, alt])
|
||||
* 2017-01-09 [v2.5.0][] (public) - Update for issue #34; new extensions (array, dot, and deep); only expose global in non-AMD/CommonJS environments (PR #35)
|
||||
* 2017-08-09 [v2.5.2][] (public) - Fix `clear()` in fake storage (thx to Martin Kluska)
|
||||
* 2018-01-18 [v2.5.11][] (public) - Add ```index.d.ts``` in root to provide TypeScript support
|
||||
* 2018-01-23 [v2.6.0][] (public) - Support ```each(fn,value)```, ```getAll(fillObj)```, and ```keys(fillList)``` to support some advanced/corner cases
|
||||
* 2018-11-15 [v2.7.1][] (public) - Add ```add(key, data)``` for common case of saving a combination of existing and new data. Fix issue #60.
|
||||
* 2019-07-23 [v2.8.0][] (public) - Add ```store(fn)``` shortcut for ```store.each```, copy properties when inheriting, and make ```store.each(fn, fill)``` always send fill as 3rd arg instead of replacing values.
|
||||
* 2019-08-21 [v2.9.0][] (public) - Add store.remove(key, alt) to match behavior of store.get(key, alt) (Issue #68)
|
||||
* 2019-09-27 [v2.10.0][] (public) - Add ```store.page``` to provide page scope storage to complement local and session scope storage. (Issue #69)
|
||||
* 2020-03-23 [v2.11.0][] (public) - Add ```store.get(key, reviveFn)``` and ```store._.revive`` to support parsing for rich types (e.g. Date)
|
||||
* 2020-04-14 [v2.11.1][] (public) - Fix falsey alt value support in ```store.get(key, alt)```
|
||||
* 2020-05-11 [v2.11.2][] (public) - Fix missing TS declaration of new page scope storage.
|
||||
* 2020-08-12 [v2.12.0][] (public) - PRs for better Storage typing, better testKey, and dev dependency updates.
|
||||
* 2021-12-16 [v2.13.1][] (public) - Add ```store.set(key, value, replacerFn)```, ```store._replace```, and ```isFake([force])``` to support stringifying rich types and easier testing. And cookie-based extensions for using store backed by a single 'store' cookie or store API for all cookies.
|
||||
* 2022-03-14 [v2.13.2][] (public) - Restore missing TS declaration of store.area(id[, area])
|
||||
* 2022-05-11 [v2.14.0][] (public) - Allow namespace delimiter to be changed via store._.nsdelim
|
||||
* 2022-07-14 [v2.14.1][] (public) - Fix change to ```set``` that broke store.cache.js, and allow namespace delimiter to be passed to ```namespace(name, thisAreaOnly, delim)``` for a single namespace, to avoid conflicts.
|
||||
* 2022-07-18 [v2.14.2][] (public) - Fix typo in ```index.d.ts``` typings.
|
||||
* 2024-02-14 [v2.14.3][] (public) - Cut license options to just MIT, also removed Bower and Component support since those are long dead.
|
||||
|
||||
[v2.0.3]: https://github.com/nbubna/store/tree/2.0.3
|
||||
[v2.1.0]: https://github.com/nbubna/store/tree/2.1.0
|
||||
[v2.1.1]: https://github.com/nbubna/store/tree/2.1.1
|
||||
[v2.1.2]: https://github.com/nbubna/store/tree/2.1.2
|
||||
[v2.1.6]: https://github.com/nbubna/store/tree/2.1.6
|
||||
[v2.2.0]: https://github.com/nbubna/store/tree/2.2.0
|
||||
[v2.2.1]: https://github.com/nbubna/store/tree/2.2.1
|
||||
[v2.2.2]: https://github.com/nbubna/store/tree/2.2.2
|
||||
[v2.3.0]: https://github.com/nbubna/store/tree/2.3.0
|
||||
[v2.3.2]: https://github.com/nbubna/store/tree/2.3.2
|
||||
[v2.4.0]: https://github.com/nbubna/store/tree/2.4.0
|
||||
[v2.5.0]: https://github.com/nbubna/store/tree/2.5.0
|
||||
[v2.5.2]: https://github.com/nbubna/store/tree/2.5.2
|
||||
[v2.5.11]: https://github.com/nbubna/store/tree/2.5.11
|
||||
[v2.6.0]: https://github.com/nbubna/store/tree/2.6.0
|
||||
[v2.7.1]: https://github.com/nbubna/store/tree/2.7.1
|
||||
[v2.8.0]: https://github.com/nbubna/store/tree/2.8.0
|
||||
[v2.9.0]: https://github.com/nbubna/store/tree/2.9.0
|
||||
[v2.10.0]: https://github.com/nbubna/store/tree/2.10.0
|
||||
[v2.11.1]: https://github.com/nbubna/store/tree/2.11.1
|
||||
[v2.11.2]: https://github.com/nbubna/store/tree/2.11.2
|
||||
[v2.12.0]: https://github.com/nbubna/store/tree/2.12.0
|
||||
[v2.13.1]: https://github.com/nbubna/store/tree/2.13.1
|
||||
[v2.13.2]: https://github.com/nbubna/store/tree/2.13.2
|
||||
[v2.14.0]: https://github.com/nbubna/store/tree/2.14.0
|
||||
[v2.14.1]: https://github.com/nbubna/store/tree/2.14.1
|
||||
[v2.14.2]: https://github.com/nbubna/store/tree/2.14.2
|
||||
[v2.14.3]: https://github.com/nbubna/store/tree/2.14.3
|
||||
283
node_modules/store2/dist/store2.js
generated
vendored
Normal file
283
node_modules/store2/dist/store2.js
generated
vendored
Normal file
@@ -0,0 +1,283 @@
|
||||
/*! store2 - v2.14.3 - 2024-02-14
|
||||
* Copyright (c) 2024 Nathan Bubna; Licensed MIT */
|
||||
;(function(window, define) {
|
||||
var _ = {
|
||||
version: "2.14.3",
|
||||
areas: {},
|
||||
apis: {},
|
||||
nsdelim: '.',
|
||||
|
||||
// utilities
|
||||
inherit: function(api, o) {
|
||||
for (var p in api) {
|
||||
if (!o.hasOwnProperty(p)) {
|
||||
Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
|
||||
}
|
||||
}
|
||||
return o;
|
||||
},
|
||||
stringify: function(d, fn) {
|
||||
return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d,fn||_.replace);
|
||||
},
|
||||
parse: function(s, fn) {
|
||||
// if it doesn't parse, return as is
|
||||
try{ return JSON.parse(s,fn||_.revive); }catch(e){ return s; }
|
||||
},
|
||||
|
||||
// extension hooks
|
||||
fn: function(name, fn) {
|
||||
_.storeAPI[name] = fn;
|
||||
for (var api in _.apis) {
|
||||
_.apis[api][name] = fn;
|
||||
}
|
||||
},
|
||||
get: function(area, key){ return area.getItem(key); },
|
||||
set: function(area, key, string){ area.setItem(key, string); },
|
||||
remove: function(area, key){ area.removeItem(key); },
|
||||
key: function(area, i){ return area.key(i); },
|
||||
length: function(area){ return area.length; },
|
||||
clear: function(area){ area.clear(); },
|
||||
|
||||
// core functions
|
||||
Store: function(id, area, namespace) {
|
||||
var store = _.inherit(_.storeAPI, function(key, data, overwrite) {
|
||||
if (arguments.length === 0){ return store.getAll(); }
|
||||
if (typeof data === "function"){ return store.transact(key, data, overwrite); }// fn=data, alt=overwrite
|
||||
if (data !== undefined){ return store.set(key, data, overwrite); }
|
||||
if (typeof key === "string" || typeof key === "number"){ return store.get(key); }
|
||||
if (typeof key === "function"){ return store.each(key); }
|
||||
if (!key){ return store.clear(); }
|
||||
return store.setAll(key, data);// overwrite=data, data=key
|
||||
});
|
||||
store._id = id;
|
||||
try {
|
||||
var testKey = '__store2_test';
|
||||
area.setItem(testKey, 'ok');
|
||||
store._area = area;
|
||||
area.removeItem(testKey);
|
||||
} catch (e) {
|
||||
store._area = _.storage('fake');
|
||||
}
|
||||
store._ns = namespace || '';
|
||||
if (!_.areas[id]) {
|
||||
_.areas[id] = store._area;
|
||||
}
|
||||
if (!_.apis[store._ns+store._id]) {
|
||||
_.apis[store._ns+store._id] = store;
|
||||
}
|
||||
return store;
|
||||
},
|
||||
storeAPI: {
|
||||
// admin functions
|
||||
area: function(id, area) {
|
||||
var store = this[id];
|
||||
if (!store || !store.area) {
|
||||
store = _.Store(id, area, this._ns);//new area-specific api in this namespace
|
||||
if (!this[id]){ this[id] = store; }
|
||||
}
|
||||
return store;
|
||||
},
|
||||
namespace: function(namespace, singleArea, delim) {
|
||||
delim = delim || this._delim || _.nsdelim;
|
||||
if (!namespace){
|
||||
return this._ns ? this._ns.substring(0,this._ns.length-delim.length) : '';
|
||||
}
|
||||
var ns = namespace, store = this[ns];
|
||||
if (!store || !store.namespace) {
|
||||
store = _.Store(this._id, this._area, this._ns+ns+delim);//new namespaced api
|
||||
store._delim = delim;
|
||||
if (!this[ns]){ this[ns] = store; }
|
||||
if (!singleArea) {
|
||||
for (var name in _.areas) {
|
||||
store.area(name, _.areas[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return store;
|
||||
},
|
||||
isFake: function(force) {
|
||||
if (force) {
|
||||
this._real = this._area;
|
||||
this._area = _.storage('fake');
|
||||
} else if (force === false) {
|
||||
this._area = this._real || this._area;
|
||||
}
|
||||
return this._area.name === 'fake';
|
||||
},
|
||||
toString: function() {
|
||||
return 'store'+(this._ns?'.'+this.namespace():'')+'['+this._id+']';
|
||||
},
|
||||
|
||||
// storage functions
|
||||
has: function(key) {
|
||||
if (this._area.has) {
|
||||
return this._area.has(this._in(key));//extension hook
|
||||
}
|
||||
return !!(this._in(key) in this._area);
|
||||
},
|
||||
size: function(){ return this.keys().length; },
|
||||
each: function(fn, fill) {// fill is used by keys(fillList) and getAll(fillList))
|
||||
for (var i=0, m=_.length(this._area); i<m; i++) {
|
||||
var key = this._out(_.key(this._area, i));
|
||||
if (key !== undefined) {
|
||||
if (fn.call(this, key, this.get(key), fill) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m > _.length(this._area)) { m--; i--; }// in case of removeItem
|
||||
}
|
||||
return fill || this;
|
||||
},
|
||||
keys: function(fillList) {
|
||||
return this.each(function(k, v, list){ list.push(k); }, fillList || []);
|
||||
},
|
||||
get: function(key, alt) {
|
||||
var s = _.get(this._area, this._in(key)),
|
||||
fn;
|
||||
if (typeof alt === "function") {
|
||||
fn = alt;
|
||||
alt = null;
|
||||
}
|
||||
return s !== null ? _.parse(s, fn) :
|
||||
alt != null ? alt : s;
|
||||
},
|
||||
getAll: function(fillObj) {
|
||||
return this.each(function(k, v, all){ all[k] = v; }, fillObj || {});
|
||||
},
|
||||
transact: function(key, fn, alt) {
|
||||
var val = this.get(key, alt),
|
||||
ret = fn(val);
|
||||
this.set(key, ret === undefined ? val : ret);
|
||||
return this;
|
||||
},
|
||||
set: function(key, data, overwrite) {
|
||||
var d = this.get(key),
|
||||
replacer;
|
||||
if (d != null && overwrite === false) {
|
||||
return data;
|
||||
}
|
||||
if (typeof overwrite === "function") {
|
||||
replacer = overwrite;
|
||||
overwrite = undefined;
|
||||
}
|
||||
return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
|
||||
},
|
||||
setAll: function(data, overwrite) {
|
||||
var changed, val;
|
||||
for (var key in data) {
|
||||
val = data[key];
|
||||
if (this.set(key, val, overwrite) !== val) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
},
|
||||
add: function(key, data, replacer) {
|
||||
var d = this.get(key);
|
||||
if (d instanceof Array) {
|
||||
data = d.concat(data);
|
||||
} else if (d !== null) {
|
||||
var type = typeof d;
|
||||
if (type === typeof data && type === 'object') {
|
||||
for (var k in data) {
|
||||
d[k] = data[k];
|
||||
}
|
||||
data = d;
|
||||
} else {
|
||||
data = d + data;
|
||||
}
|
||||
}
|
||||
_.set(this._area, this._in(key), _.stringify(data, replacer));
|
||||
return data;
|
||||
},
|
||||
remove: function(key, alt) {
|
||||
var d = this.get(key, alt);
|
||||
_.remove(this._area, this._in(key));
|
||||
return d;
|
||||
},
|
||||
clear: function() {
|
||||
if (!this._ns) {
|
||||
_.clear(this._area);
|
||||
} else {
|
||||
this.each(function(k){ _.remove(this._area, this._in(k)); }, 1);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
clearAll: function() {
|
||||
var area = this._area;
|
||||
for (var id in _.areas) {
|
||||
if (_.areas.hasOwnProperty(id)) {
|
||||
this._area = _.areas[id];
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
this._area = area;
|
||||
return this;
|
||||
},
|
||||
|
||||
// internal use functions
|
||||
_in: function(k) {
|
||||
if (typeof k !== "string"){ k = _.stringify(k); }
|
||||
return this._ns ? this._ns + k : k;
|
||||
},
|
||||
_out: function(k) {
|
||||
return this._ns ?
|
||||
k && k.indexOf(this._ns) === 0 ?
|
||||
k.substring(this._ns.length) :
|
||||
undefined : // so each() knows to skip it
|
||||
k;
|
||||
}
|
||||
},// end _.storeAPI
|
||||
storage: function(name) {
|
||||
return _.inherit(_.storageAPI, { items: {}, name: name });
|
||||
},
|
||||
storageAPI: {
|
||||
length: 0,
|
||||
has: function(k){ return this.items.hasOwnProperty(k); },
|
||||
key: function(i) {
|
||||
var c = 0;
|
||||
for (var k in this.items){
|
||||
if (this.has(k) && i === c++) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
},
|
||||
setItem: function(k, v) {
|
||||
if (!this.has(k)) {
|
||||
this.length++;
|
||||
}
|
||||
this.items[k] = v;
|
||||
},
|
||||
removeItem: function(k) {
|
||||
if (this.has(k)) {
|
||||
delete this.items[k];
|
||||
this.length--;
|
||||
}
|
||||
},
|
||||
getItem: function(k){ return this.has(k) ? this.items[k] : null; },
|
||||
clear: function(){ for (var k in this.items){ this.removeItem(k); } }
|
||||
}// end _.storageAPI
|
||||
};
|
||||
|
||||
var store =
|
||||
// safely set this up (throws error in IE10/32bit mode for local files)
|
||||
_.Store("local", (function(){try{ return localStorage; }catch(e){}})());
|
||||
store.local = store;// for completeness
|
||||
store._ = _;// for extenders and debuggers...
|
||||
// safely setup store.session (throws exception in FF for file:/// urls)
|
||||
store.area("session", (function(){try{ return sessionStorage; }catch(e){}})());
|
||||
store.area("page", _.storage("page"));
|
||||
|
||||
if (typeof define === 'function' && define.amd !== undefined) {
|
||||
define('store2', [], function () {
|
||||
return store;
|
||||
});
|
||||
} else if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = store;
|
||||
} else {
|
||||
// expose the primary store fn to the global object and save conflicts
|
||||
if (window.store){ _.conflict = window.store; }
|
||||
window.store = store;
|
||||
}
|
||||
|
||||
})(this, this && this.define);
|
||||
5
node_modules/store2/dist/store2.min.js
generated
vendored
Normal file
5
node_modules/store2/dist/store2.min.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
/*! store2 - v2.14.3 - 2024-02-14
|
||||
* Copyright (c) 2024 Nathan Bubna; Licensed MIT */
|
||||
|
||||
!function(a,b){var c={version:"2.14.3",areas:{},apis:{},nsdelim:".",inherit:function(a,b){for(var c in a)b.hasOwnProperty(c)||Object.defineProperty(b,c,Object.getOwnPropertyDescriptor(a,c));return b},stringify:function(a,b){return void 0===a||"function"==typeof a?a+"":JSON.stringify(a,b||c.replace)},parse:function(a,b){try{return JSON.parse(a,b||c.revive)}catch(b){return a}},fn:function(a,b){c.storeAPI[a]=b;for(var d in c.apis)c.apis[d][a]=b},get:function(a,b){return a.getItem(b)},set:function(a,b,c){a.setItem(b,c)},remove:function(a,b){a.removeItem(b)},key:function(a,b){return a.key(b)},length:function(a){return a.length},clear:function(a){a.clear()},Store:function(a,b,d){var e=c.inherit(c.storeAPI,function(a,b,c){return 0===arguments.length?e.getAll():"function"==typeof b?e.transact(a,b,c):void 0!==b?e.set(a,b,c):"string"==typeof a||"number"==typeof a?e.get(a):"function"==typeof a?e.each(a):a?e.setAll(a,b):e.clear()});e._id=a;try{b.setItem("__store2_test","ok"),e._area=b,b.removeItem("__store2_test")}catch(a){e._area=c.storage("fake")}return e._ns=d||"",c.areas[a]||(c.areas[a]=e._area),c.apis[e._ns+e._id]||(c.apis[e._ns+e._id]=e),e},storeAPI:{area:function(a,b){var d=this[a];return d&&d.area||(d=c.Store(a,b,this._ns),this[a]||(this[a]=d)),d},namespace:function(a,b,d){if(d=d||this._delim||c.nsdelim,!a)return this._ns?this._ns.substring(0,this._ns.length-d.length):"";var e=a,f=this[e];if(!(f&&f.namespace||(f=c.Store(this._id,this._area,this._ns+e+d),f._delim=d,this[e]||(this[e]=f),b)))for(var g in c.areas)f.area(g,c.areas[g]);return f},isFake:function(a){return a?(this._real=this._area,this._area=c.storage("fake")):!1===a&&(this._area=this._real||this._area),"fake"===this._area.name},toString:function(){return"store"+(this._ns?"."+this.namespace():"")+"["+this._id+"]"},has:function(a){return this._area.has?this._area.has(this._in(a)):!!(this._in(a)in this._area)},size:function(){return this.keys().length},each:function(a,b){for(var d=0,e=c.length(this._area);d<e;d++){var f=this._out(c.key(this._area,d));if(void 0!==f&&!1===a.call(this,f,this.get(f),b))break;e>c.length(this._area)&&(e--,d--)}return b||this},keys:function(a){return this.each(function(a,b,c){c.push(a)},a||[])},get:function(a,b){var d,e=c.get(this._area,this._in(a));return"function"==typeof b&&(d=b,b=null),null!==e?c.parse(e,d):null!=b?b:e},getAll:function(a){return this.each(function(a,b,c){c[a]=b},a||{})},transact:function(a,b,c){var d=this.get(a,c),e=b(d);return this.set(a,void 0===e?d:e),this},set:function(a,b,d){var e,f=this.get(a);return null!=f&&!1===d?b:("function"==typeof d&&(e=d,d=void 0),c.set(this._area,this._in(a),c.stringify(b,e),d)||f)},setAll:function(a,b){var c,d;for(var e in a)d=a[e],this.set(e,d,b)!==d&&(c=!0);return c},add:function(a,b,d){var e=this.get(a);if(e instanceof Array)b=e.concat(b);else if(null!==e){var f=typeof e;if(f===typeof b&&"object"===f){for(var g in b)e[g]=b[g];b=e}else b=e+b}return c.set(this._area,this._in(a),c.stringify(b,d)),b},remove:function(a,b){var d=this.get(a,b);return c.remove(this._area,this._in(a)),d},clear:function(){return this._ns?this.each(function(a){c.remove(this._area,this._in(a))},1):c.clear(this._area),this},clearAll:function(){var a=this._area;for(var b in c.areas)c.areas.hasOwnProperty(b)&&(this._area=c.areas[b],this.clear());return this._area=a,this},_in:function(a){return"string"!=typeof a&&(a=c.stringify(a)),this._ns?this._ns+a:a},_out:function(a){return this._ns?a&&0===a.indexOf(this._ns)?a.substring(this._ns.length):void 0:a}},storage:function(a){return c.inherit(c.storageAPI,{items:{},name:a})},storageAPI:{length:0,has:function(a){return this.items.hasOwnProperty(a)},key:function(a){var b=0;for(var c in this.items)if(this.has(c)&&a===b++)return c},setItem:function(a,b){this.has(a)||this.length++,this.items[a]=b},removeItem:function(a){this.has(a)&&(delete this.items[a],this.length--)},getItem:function(a){return this.has(a)?this.items[a]:null},clear:function(){for(var a in this.items)this.removeItem(a)}}},d=c.Store("local",function(){try{return localStorage}catch(a){}}());d.local=d,d._=c,d.area("session",function(){try{return sessionStorage}catch(a){}}()),d.area("page",c.storage("page")),"function"==typeof b&&void 0!==b.amd?b("store2",[],function(){return d}):"undefined"!=typeof module&&module.exports?module.exports=d:(a.store&&(c.conflict=a.store),a.store=d)}(this,this&&this.define);
|
||||
//# sourceMappingURL=store2.min.js.map
|
||||
1
node_modules/store2/dist/store2.min.js.map
generated
vendored
Normal file
1
node_modules/store2/dist/store2.min.js.map
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
68
node_modules/store2/index.d.ts
generated
vendored
Normal file
68
node_modules/store2/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
export interface StoredData {
|
||||
[key: string]: any;
|
||||
}
|
||||
export type Replacer = (key: any, value: any) => string | String[] | number[];
|
||||
export type Reviver = (key: string, value: any) => any;
|
||||
export type EachFn = (key: any, data: any) => false | any;
|
||||
export type TransactFn = (data: any) => any | undefined;
|
||||
|
||||
type BaseSet = (key: any, data: any) => any;
|
||||
type BaseGet = (key: any) => any;
|
||||
type BaseSetAll = (obj: Object) => StoredData;
|
||||
type BaseGetAll = () => StoredData;
|
||||
type BaseTransact = (fn: EachFn, value?: any) => StoredData;
|
||||
type BaseClear = (clear: false) => StoreBase;
|
||||
export type Base = BaseSet & BaseGet & BaseSetAll & BaseGetAll & BaseTransact & BaseClear;
|
||||
|
||||
export interface StoreAPI {
|
||||
clear(): StoreBase;
|
||||
clearAll(): StoreBase;
|
||||
each(callback: EachFn): StoreBase;
|
||||
get(key: any, alt?: any|Reviver): any;
|
||||
getAll(fillObj?: StoredData): StoredData;
|
||||
has(key: any): boolean;
|
||||
isFake(force?: boolean): boolean;
|
||||
keys(fillList?: string[]): string[];
|
||||
namespace(namespace: string, singleArea?: true, delim?: string): StoreType;
|
||||
remove(key: any, alt?: any|Reviver): any;
|
||||
set(key: any, data: any, overwrite?: boolean|Replacer): any;
|
||||
setAll(data: Object, overwrite?: boolean|Replacer): StoredData;
|
||||
add(key: any, data: any): any;
|
||||
size(): number;
|
||||
transact(key: any, fn: TransactFn, alt?: any|Reviver): StoreBase;
|
||||
area(id: string, area: Storage): StoreBase
|
||||
}
|
||||
|
||||
export type StoreBase = StoreAPI & Base;
|
||||
|
||||
// these are not guaranteed to be stable across minor versions
|
||||
// but historically, they have been pretty much so
|
||||
export interface DeveloperTools {
|
||||
readonly version: string;
|
||||
readonly areas: { [name: string]: Storage };
|
||||
readonly apis: { [name: string]: StoreAPI };
|
||||
nsdelim: string;
|
||||
revive: Reviver;
|
||||
replace: Replacer;
|
||||
readonly fn: (name: string, fn: Function) => void;
|
||||
storeAPI: StoreAPI;
|
||||
get: (area: Storage, key: string) => string;
|
||||
set: (area: Storage, key: string, string: string) => void;
|
||||
remove: (area: Storage, key: string) => void;
|
||||
key: (area: Storage, i: number) => string;
|
||||
length: (area: Storage) => number;
|
||||
clear: (area: Storage) => void;
|
||||
parse: (s: string, fn?: Reviver) => any;
|
||||
stringify: (d: any, fn?: Replacer) => string;
|
||||
inherit: (api: StoreAPI, o: object) => object;
|
||||
}
|
||||
|
||||
export type StoreType = StoreBase & {
|
||||
local: StoreBase;
|
||||
session: StoreBase;
|
||||
page: StoreBase;
|
||||
readonly _: DeveloperTools,
|
||||
};
|
||||
|
||||
declare const store: StoreType
|
||||
export default store
|
||||
52
node_modules/store2/package.json
generated
vendored
Normal file
52
node_modules/store2/package.json
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "store2",
|
||||
"version": "2.14.3",
|
||||
"description": "Better localStorage",
|
||||
"keywords": [
|
||||
"localStorage",
|
||||
"sessionStorage",
|
||||
"json",
|
||||
"namespace",
|
||||
"store"
|
||||
],
|
||||
"author": {
|
||||
"name": "Nathan Bubna",
|
||||
"email": "nathan@esha.com",
|
||||
"url": "http://www.esha.com/"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"dist",
|
||||
"index.d.ts"
|
||||
],
|
||||
"main": "dist/store2.js",
|
||||
"types": "index.d.ts",
|
||||
"bugs": {
|
||||
"url": "http://github.com/nbubna/store/issues",
|
||||
"email": "nathan@esha.com"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+ssh://git@github.com/nbubna/store.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "grunt qunit"
|
||||
},
|
||||
"devDependencies": {
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-cli": "^1.2.0",
|
||||
"grunt-component-build": "^0.2.8",
|
||||
"grunt-contrib-clean": "^1.0.0",
|
||||
"grunt-contrib-concat": "^1.0.1",
|
||||
"grunt-contrib-jshint": "^3.2.0",
|
||||
"grunt-contrib-qunit": "^1.0.0",
|
||||
"grunt-contrib-uglify": "^2.2.0",
|
||||
"grunt-contrib-watch": "^1.0.0",
|
||||
"grunt-lib-phantomjs": "^1.1.0",
|
||||
"grunt-nuget": "^0.2.0",
|
||||
"load-grunt-tasks": "^3.5.2",
|
||||
"phantomjs": "^2.1.7",
|
||||
"time-grunt": "^1.4.0"
|
||||
}
|
||||
}
|
||||
18
node_modules/store2/src/.jshintrc
generated
vendored
Normal file
18
node_modules/store2/src/.jshintrc
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
{
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"immed": true,
|
||||
"latedef": true,
|
||||
"newcap": true,
|
||||
"noarg": true,
|
||||
"sub": true,
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
"boss": true,
|
||||
"eqnull": true,
|
||||
"browser": true,
|
||||
"globals": {
|
||||
"module": true
|
||||
},
|
||||
"predef": ["jQuery","require","store","globalThis","Promise"]
|
||||
}
|
||||
52
node_modules/store2/src/store.array.js
generated
vendored
Normal file
52
node_modules/store2/src/store.array.js
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Copyright (c) 2017 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Adds shortcut for safely applying all available Array functions to stored values. If there is no
|
||||
* value, the functions will act as if upon an empty one. If there is a non, array value, it is put
|
||||
* into an array before the function is applied. If the function results in an empty array, the
|
||||
* key/value is removed from the storage, otherwise the array is restored.
|
||||
*
|
||||
* store.push('array', 'a', 1, true);// == store.set('array', (store.get('array')||[]).push('a', 1, true]));
|
||||
* store.indexOf('array', true);// === store.get('array').indexOf(true)
|
||||
*
|
||||
* This will add all functions of Array.prototype that are specific to the Array interface and have no
|
||||
* conflict with existing store functions.
|
||||
*
|
||||
* Status: BETA - useful, but adds more functions than reasonable
|
||||
*/
|
||||
;(function(_, Array) {
|
||||
|
||||
// expose internals on the underscore to allow extensibility
|
||||
_.array = function(fnName, key, args) {
|
||||
var value = this.get(key, []),
|
||||
array = Array.isArray(value) ? value : [value],
|
||||
ret = array[fnName].apply(array, args);
|
||||
if (array.length > 0) {
|
||||
this.set(key, array.length > 1 ? array : array[0]);
|
||||
} else {
|
||||
this.remove(key);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
_.arrayFn = function(fnName) {
|
||||
return function(key) {
|
||||
return this.array(fnName, key,
|
||||
arguments.length > 1 ? Array.prototype.slice.call(arguments, 1) : null);
|
||||
};
|
||||
};
|
||||
|
||||
// add function(s) to the store interface
|
||||
_.fn('array', _.array);
|
||||
Object.getOwnPropertyNames(Array.prototype).forEach(function(name) {
|
||||
// add Array interface functions w/o existing conflicts
|
||||
if (typeof Array.prototype[name] === "function") {
|
||||
if (!(name in _.storeAPI)) {
|
||||
_.fn(name, _.array[name] = _.arrayFn(name));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
})(window.store._, window.Array);
|
||||
63
node_modules/store2/src/store.async.js
generated
vendored
Normal file
63
node_modules/store2/src/store.async.js
generated
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
/**
|
||||
* Copyright (c) 2019 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Adds an 'async' duplicate on all store APIs that
|
||||
* performs storage-related operations asynchronously and returns
|
||||
* a promise.
|
||||
*
|
||||
* Status: BETA - works great, but lacks justification for existence
|
||||
*/
|
||||
;(function(window, _) {
|
||||
|
||||
var dontPromisify = ['async', 'area', 'namespace', 'isFake', 'toString'];
|
||||
_.promisify = function(api) {
|
||||
var async = api.async = _.Store(api._id, api._area, api._ns);
|
||||
async._async = true;
|
||||
Object.keys(api).forEach(function(name) {
|
||||
if (name.charAt(0) !== '_' && dontPromisify.indexOf(name) < 0) {
|
||||
var fn = api[name];
|
||||
if (typeof fn === "function") {
|
||||
async[name] = _.promiseFn(name, fn, api);
|
||||
}
|
||||
}
|
||||
});
|
||||
return async;
|
||||
};
|
||||
_.promiseFn = function(name, fn, self) {
|
||||
return function promised() {
|
||||
var args = arguments;
|
||||
return new Promise(function(resolve, reject) {
|
||||
setTimeout(function() {
|
||||
try {
|
||||
resolve(fn.apply(self, args));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
}, 0);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
// promisify existing apis
|
||||
for (var apiName in _.apis) {
|
||||
_.promisify(_.apis[apiName]);
|
||||
}
|
||||
// ensure future apis are promisified
|
||||
Object.defineProperty(_.storeAPI, 'async', {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
get: function() {
|
||||
var async = _.promisify(this);
|
||||
// overwrite getter to avoid re-promisifying
|
||||
Object.defineProperty(this, 'async', {
|
||||
enumerable: true,
|
||||
value: async
|
||||
});
|
||||
return async;
|
||||
}
|
||||
});
|
||||
|
||||
})(window, window.store._);
|
||||
81
node_modules/store2/src/store.bind.js
generated
vendored
Normal file
81
node_modules/store2/src/store.bind.js
generated
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
/**
|
||||
* Copyright (c) 2013 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Makes it easy to watch for storage events by enhancing the events and
|
||||
* allowing binding to particular keys and/or namespaces.
|
||||
*
|
||||
* // listen to particular key storage events (yes, this is namespace sensitive)
|
||||
* store.on('foo', function listenToFoo(e){ console.log('foo was changed:', e); });
|
||||
* store.off('foo', listenToFoo);
|
||||
*
|
||||
* // listen to all storage events
|
||||
* store.on(function storageEvent(e){ console.log('web storage:', e); });
|
||||
* store.off(storageEvent);
|
||||
*
|
||||
* Status: ALPHA - useful, if you don't mind incomplete browser support for events
|
||||
*/
|
||||
;(function(window, document, _) {
|
||||
_.fn('on', function(key, fn) {
|
||||
if (!fn) { fn = key; key = ''; }// shift args when needed
|
||||
var s = this,
|
||||
bound,
|
||||
id = _.id(this._area);
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("storage", bound = function(e) {
|
||||
var k = s._out(e.key);
|
||||
if (k && (!key || k === key)) {// must match key if listener has one
|
||||
var eid = _.id(e.storageArea);
|
||||
if (!eid || id === eid) {// must match area, if event has a known one
|
||||
return fn.call(s, _.event(k, s, e));
|
||||
}
|
||||
}
|
||||
}, false);
|
||||
} else {
|
||||
document.attachEvent("onstorage", bound = function() {
|
||||
return fn.call(s, window.event);
|
||||
});
|
||||
}
|
||||
fn['_'+key+'listener'] = bound;
|
||||
return s;
|
||||
});
|
||||
_.fn('off', function(key, fn) {
|
||||
if (!fn) { fn = key; key = ''; }// shift args when needed
|
||||
var bound = fn['_'+key+'listener'];
|
||||
if (window.removeEventListener) {
|
||||
window.removeEventListener("storage", bound);
|
||||
} else {
|
||||
document.detachEvent("onstorage", bound);
|
||||
}
|
||||
return this;
|
||||
});
|
||||
_.event = function(k, s, e) {
|
||||
var event = {
|
||||
key: k,
|
||||
namespace: s.namespace(),
|
||||
newValue: _.parse(e.newValue),
|
||||
oldValue: _.parse(e.oldValue),
|
||||
url: e.url || e.uri,
|
||||
storageArea: e.storageArea,
|
||||
source: e.source,
|
||||
timeStamp: e.timeStamp,
|
||||
originalEvent: e
|
||||
};
|
||||
if (_.cache) {
|
||||
var min = _.expires(e.newValue || e.oldValue);
|
||||
if (min) {
|
||||
event.expires = _.when(min);
|
||||
}
|
||||
}
|
||||
return event;
|
||||
};
|
||||
_.id = function(area) {
|
||||
for (var id in _.areas) {
|
||||
if (area === _.areas[id]) {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
};
|
||||
})(window, document, window.store._);
|
||||
67
node_modules/store2/src/store.cache.js
generated
vendored
Normal file
67
node_modules/store2/src/store.cache.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright (c) 2013 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Allows use of a number as 'overwrite' param on set calls to give time in seconds after
|
||||
* which the value should not be retrievable again (an expiration time).
|
||||
*
|
||||
* Status: BETA - useful, needs testing
|
||||
*/
|
||||
;(function(_) {
|
||||
var prefix = 'exp@',
|
||||
suffix = ';',
|
||||
parse = _.parse,
|
||||
_get = _.get,
|
||||
_set = _.set;
|
||||
_.parse = function(s, fn) {
|
||||
if (s && s.indexOf(prefix) === 0) {
|
||||
s = s.substring(s.indexOf(suffix)+1);
|
||||
}
|
||||
return parse(s, fn);
|
||||
};
|
||||
_.expires = function(s) {
|
||||
if (s && s.indexOf(prefix) === 0) {
|
||||
return parseInt(s.substring(prefix.length, s.indexOf(suffix)), 10);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
_.when = function(sec) {// if sec, return sec->date, else date->sec
|
||||
var now = Math.floor((new Date().getTime())/1000);
|
||||
return sec ? new Date((now+sec)*1000) : now;
|
||||
};
|
||||
_.cache = function(area, key) {
|
||||
var s = _get(area, key),
|
||||
sec = _.expires(s);
|
||||
if (sec && _.when() >= sec) {
|
||||
return area.removeItem(key);
|
||||
}
|
||||
return s;
|
||||
};
|
||||
_.get = function(area, key) {
|
||||
var s = _.cache(area, key);
|
||||
return s === undefined ? null : s;
|
||||
};
|
||||
_.set = function(area, key, string, sec) {
|
||||
try {
|
||||
if (sec) {
|
||||
string = prefix + (_.when()+sec) + suffix + string;
|
||||
}
|
||||
_set(area, key, string);
|
||||
} catch (e) {
|
||||
if (e.name === 'QUOTA_EXCEEDED_ERR' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
|
||||
var changed = false;
|
||||
for (var i=0,m=area.length; i<m; i++) {
|
||||
if (_.cache(area, key) === undefined) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
return _.set.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
})(window.store._, undefined);
|
||||
84
node_modules/store2/src/store.cookie.js
generated
vendored
Normal file
84
node_modules/store2/src/store.cookie.js
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
/**
|
||||
* Copyright (c) 2021 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Creates a store area that uses a single cookie as the backing storage.
|
||||
* This gives you the store API for a specific 'store' cookie that your backend
|
||||
* can access too. It could definitely use more testing.
|
||||
*
|
||||
* Status: BETA - unsupported, useful, needs testing
|
||||
*/
|
||||
;(function(window, document, store, _) {
|
||||
|
||||
var C = _.cookie = {// and that's good enough for me
|
||||
name: 'store',
|
||||
maxAge: 60*60*24*365*10,
|
||||
suffix: ';path=/;sameSite=strict',
|
||||
encode: function(state) {
|
||||
return encodeURIComponent(JSON.stringify(state));
|
||||
},
|
||||
decode: function(state) {
|
||||
return JSON.parse(decodeURIComponent(state));
|
||||
}
|
||||
};
|
||||
C.all = function() {
|
||||
return C.read(C.name) || {};
|
||||
};
|
||||
C.read = function(name) {
|
||||
var match = document.cookie.match(new RegExp("(^| )"+(name||C.name)+"=([^;]+)"));
|
||||
return match ? C.decode(match[2]) : null;
|
||||
};
|
||||
C.write = function(state, name) {
|
||||
document.cookie = (name||C.name)+"="+C.encode(state)+";max-age="+C.maxAge+C.suffix;
|
||||
};
|
||||
C.remove = function(name) {
|
||||
document.cookie = (name||C.name)+"=;expires=Thu, 01 Jan 1970 00:00:01 GMT"+C.suffix;
|
||||
};
|
||||
C.area = {
|
||||
key: function(i) {
|
||||
var c = 0,
|
||||
state = C.all();
|
||||
for (var k in state) {
|
||||
if (state.hasOwnProperty(k) && i === c++) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
},
|
||||
setItem: function(k, v) {
|
||||
var state = C.all();
|
||||
state[k] = v;
|
||||
C.write(state);
|
||||
},
|
||||
getItem: function(k) {
|
||||
var state = C.all();
|
||||
return state.hasOwnProperty(k) ? state[k] : null;
|
||||
},
|
||||
has: function(k) {
|
||||
return C.all().hasOwnProperty(k);
|
||||
},
|
||||
removeItem: function(k) {
|
||||
var state = C.read(C.name);
|
||||
delete state[k];
|
||||
C.write(state);
|
||||
},
|
||||
clear: C.remove
|
||||
};
|
||||
Object.defineProperty(C.area, "length", {
|
||||
get: function() {
|
||||
var ln = 0,
|
||||
state = C.all();
|
||||
for (var k in state) {
|
||||
if (state.hasOwnProperty(k)) {
|
||||
ln++;
|
||||
}
|
||||
}
|
||||
return ln;
|
||||
}
|
||||
});
|
||||
|
||||
// create the store api for this storage
|
||||
store.area("cookie", C.area);
|
||||
|
||||
})(window, document, window.store, window.store._);
|
||||
82
node_modules/store2/src/store.cookies.js
generated
vendored
Normal file
82
node_modules/store2/src/store.cookies.js
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
/**
|
||||
* Copyright (c) 2021 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Creates a store area that uses a separate cookies for each key/value as the backing
|
||||
* storage. This effectively gives you the store API for all cookies..
|
||||
* It could definitely use more testing. It also feels like it should better
|
||||
* integrated with the expire plugin before we call it BETA.
|
||||
*
|
||||
* Status: ALPHA - unsupported, useful, needs testing
|
||||
*/
|
||||
;(function(window, document, store, _) {
|
||||
|
||||
var C = _.cookies = {// still good enough for me
|
||||
maxAge: 60*60*24*365*10,
|
||||
suffix: ';path=/;sameSite=strict'
|
||||
};
|
||||
C.all = function() {
|
||||
if (!document.cookie) {
|
||||
return {};
|
||||
}
|
||||
var cookies = document.cookie.split('; '),
|
||||
all = {};
|
||||
for (var i=0, cookie, eq; i<cookies.length; i++) {
|
||||
cookie = cookies[i];
|
||||
eq = cookie.indexOf('=');
|
||||
all[cookie.substring(0, eq)] = decodeURIComponent(cookie.substring(eq+1));
|
||||
}
|
||||
return all;
|
||||
};
|
||||
C.read = function(key) {
|
||||
var match = document.cookie.match(new RegExp('(^| )'+key+'=([^;]+)'));
|
||||
return match ? decodeURIComponent(match[2]) : null;
|
||||
};
|
||||
C.write = function(key, value) {
|
||||
document.cookie = key+'='+encodeURIComponent(value)+';max-age='+C.maxAge+C.suffix;
|
||||
};
|
||||
C.remove = function(key) {
|
||||
document.cookie = key+'=;expires=Thu, 01 Jan 1970 00:00:01 GMT'+C.suffix;
|
||||
};
|
||||
C.area = {
|
||||
key: function(i) {
|
||||
var c = 0,
|
||||
state = C.all();
|
||||
for (var k in state) {
|
||||
if (state.hasOwnProperty(k) && i === c++) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
},
|
||||
setItem: C.write,
|
||||
getItem: C.read,
|
||||
has: function(k) {
|
||||
return C.all().hasOwnProperty(k);
|
||||
},
|
||||
removeItem: C.remove,
|
||||
clear: function() {
|
||||
var state = C.all();
|
||||
for (var k in state) {
|
||||
C.remove(k);
|
||||
}
|
||||
}
|
||||
};
|
||||
Object.defineProperty(C.area, 'length', {
|
||||
get: function() {
|
||||
var ln = 0,
|
||||
state = C.all();
|
||||
for (var k in state) {
|
||||
if (state.hasOwnProperty(k)) {
|
||||
ln++;
|
||||
}
|
||||
}
|
||||
return ln;
|
||||
}
|
||||
});
|
||||
|
||||
// create the store api for this storage
|
||||
store.area('cookies', C.area);
|
||||
|
||||
})(window, document, window.store, window.store._);
|
||||
47
node_modules/store2/src/store.deep.js
generated
vendored
Normal file
47
node_modules/store2/src/store.deep.js
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright (c) 2017 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Allows retrieval of values from within a stored object.
|
||||
*
|
||||
* store.set('foo', { is: { not: { quite: false }}});
|
||||
* console.log(store.get('foo.is.not.quite'));// logs false
|
||||
*
|
||||
* Status: ALPHA - currently only supports get, inefficient, uses eval
|
||||
*/
|
||||
;(function(_) {
|
||||
|
||||
// save original core accessor
|
||||
var _get = _.get;
|
||||
// replace with enhanced version
|
||||
_.get = function(area, key, kid) {
|
||||
var s = _get(area, key);
|
||||
if (s == null) {
|
||||
var parts = _.split(key);
|
||||
if (parts) {
|
||||
key = parts[0];
|
||||
kid = kid ? parts[1] + '.' + kid : parts[1];
|
||||
return _.get(area, parts[0], kid);
|
||||
}
|
||||
} else if (kid) {
|
||||
var val = _.parse(s);
|
||||
/*jshint evil:true */
|
||||
val = eval("val."+kid);
|
||||
s = _.stringify(val);
|
||||
}
|
||||
return s;
|
||||
};
|
||||
|
||||
// expose internals on the underscore to allow extensibility
|
||||
_.split = function(key) {
|
||||
var dot = key.lastIndexOf('.');
|
||||
if (dot > 0) {
|
||||
var kid = key.substring(dot+1, key.length);
|
||||
key = key.substring(0, dot);
|
||||
return [key, kid];
|
||||
}
|
||||
};
|
||||
|
||||
})(window.store._);
|
||||
67
node_modules/store2/src/store.dom.js
generated
vendored
Normal file
67
node_modules/store2/src/store.dom.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* Copyright (c) 2017 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Declarative, persistent DOM content.
|
||||
*
|
||||
* <input store name="whatever">
|
||||
* <div store="somekey" store-area="session" contenteditable>Some content</div>
|
||||
*
|
||||
* Status: BETA - uses store, doesn't extend it, deserves standalone project
|
||||
*/
|
||||
;(function(document, store, _, Array) {
|
||||
|
||||
// expose internal functions on store._.dom for extensibility
|
||||
var DOM = _.dom = function() {
|
||||
var nodes = document.querySelectorAll(DOM.selector),
|
||||
array = Array.prototype.slice.call(nodes);
|
||||
for (var i=0; i<array.length; i++) {
|
||||
DOM.node(array[i], i);
|
||||
}
|
||||
return array;
|
||||
};
|
||||
DOM.selector = '[store],[store-area]';
|
||||
DOM.event = 'input';// beforeunload is tempting
|
||||
DOM.node = function(node, i) {
|
||||
var key = DOM.key(node, i),
|
||||
area = DOM.area(node),
|
||||
value = area(key);
|
||||
if (value == null) {
|
||||
value = DOM.get(node);
|
||||
} else {
|
||||
DOM.set(node, value);
|
||||
}
|
||||
if (!node.storeListener) {
|
||||
node.addEventListener(DOM.event, function() {
|
||||
area(key, DOM.get(node));
|
||||
});
|
||||
node.storeListener = true;
|
||||
}
|
||||
};
|
||||
DOM.area = function(node) {
|
||||
return store[node.getAttribute('store-area') || 'local'];
|
||||
};
|
||||
// prefer store attribute value, then name attribute, use nodeName+index as last resort
|
||||
DOM.key = function(node, i) {
|
||||
return node.getAttribute('store') ||
|
||||
node.getAttribute('name') ||
|
||||
('dom.'+node.nodeName.toLowerCase() + (i||''));
|
||||
};
|
||||
// both get and set should prefer value property to innerHTML
|
||||
DOM.get = function(node) {
|
||||
return node.value || node.innerHTML;
|
||||
};
|
||||
DOM.set = function(node, value) {
|
||||
if ('value' in node) {
|
||||
node.value = value;
|
||||
} else {
|
||||
node.innerHTML = typeof value === "string" ? value : _.stringify(value);
|
||||
}
|
||||
};
|
||||
|
||||
// initialize
|
||||
document.addEventListener('DOMContentLoaded', DOM);
|
||||
|
||||
})(document, window.store, window.store._, Array);
|
||||
43
node_modules/store2/src/store.dot.js
generated
vendored
Normal file
43
node_modules/store2/src/store.dot.js
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Copyright (c) 2017 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Adds getters and setters for existing keys (and newly set() ones) to enable dot access to stored properties.
|
||||
*
|
||||
* store.dot('foo','bar');// makes store aware of keys (could also do store.set('foo',''))
|
||||
* store.foo = { is: true };// == store.set('foo', { is: true });
|
||||
* console.log(store.foo.is);// logs 'true'
|
||||
*
|
||||
* This will not create accessors that conflict with existing properties of the store object.
|
||||
*
|
||||
* Status: ALPHA - good, but ```store.foo.is=false``` won't persist while looking like it would
|
||||
*/
|
||||
;(function(_, Object, Array) {
|
||||
|
||||
// expose internals on the underscore to allow extensibility
|
||||
_.dot = function(key) {
|
||||
var keys = !key ? this.keys() :
|
||||
Array.isArray(key) ? key :
|
||||
Array.prototype.slice.call(arguments),
|
||||
target = this;
|
||||
keys.forEach(function(key) {
|
||||
_.dot.define(target, key);
|
||||
});
|
||||
return this;
|
||||
};
|
||||
_.dot.define = function(target, key) {
|
||||
if (!(key in target)) {
|
||||
Object.defineProperty(target, key, {
|
||||
enumerable: true,
|
||||
get: function(){ return this.get(key); },
|
||||
set: function(value){ this.set(key, value); }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// add function(s) to the store interface
|
||||
_.fn('dot', _.dot);
|
||||
|
||||
})(window.store._, window.Object, window.Array);
|
||||
61
node_modules/store2/src/store.measure.js
generated
vendored
Normal file
61
node_modules/store2/src/store.measure.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* Copyright (c) 2013 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* store.remainingSpace();// returns remainingSpace value (if browser supports it)
|
||||
* store.charsUsed();// returns length of all data when stringified
|
||||
* store.charsLeft([true]);// tests how many more chars we can fit (crash threat!)
|
||||
* store.charsTotal([true]);// charsUsed + charsLeft, duh.
|
||||
*
|
||||
* TODO: byte/string conversions
|
||||
*
|
||||
* Status: ALPHA - changing API *and* crash threats :)
|
||||
*/
|
||||
;(function(store, _) {
|
||||
|
||||
function put(area, s) {
|
||||
try {
|
||||
area.setItem("__test__", s);
|
||||
return true;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
_.fn('remainingSpace', function() {
|
||||
return this._area.remainingSpace;
|
||||
});
|
||||
_.fn('charsUsed', function() {
|
||||
return _.stringify(this.getAll()).length - 2;
|
||||
});
|
||||
_.fn('charsLeft', function(test) {
|
||||
if (this.isFake()){ return; }
|
||||
if (arguments.length === 0) {
|
||||
test = window.confirm('Calling store.charsLeft() may crash some browsers!');
|
||||
}
|
||||
if (test) {
|
||||
var s = 's ', add = s;
|
||||
// grow add for speed
|
||||
while (put(store._area, s)) {
|
||||
s += add;
|
||||
if (add.length < 50000) {
|
||||
add = s;
|
||||
}
|
||||
}
|
||||
// shrink add for accuracy
|
||||
while (add.length > 2) {
|
||||
s = s.substring(0, s.length - (add.length/2));
|
||||
while (put(store._area, s)) {
|
||||
s += add;
|
||||
}
|
||||
add = add.substring(add.length/2);
|
||||
}
|
||||
_.remove(store._area, "__test__");
|
||||
return s.length + 8;
|
||||
}
|
||||
});
|
||||
_.fn('charsTotal', function(test) {
|
||||
return store.charsUsed() + store.charsLeft(test);
|
||||
});
|
||||
|
||||
})(window.store, window.store._);
|
||||
131
node_modules/store2/src/store.old.js
generated
vendored
Normal file
131
node_modules/store2/src/store.old.js
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
/**
|
||||
* Copyright (c) 2013 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* If fake (non-persistent) storage for users stuck in the dark ages
|
||||
* does not satisfy you, this will replace it with the a reasonable imitator for their
|
||||
* pathetic, incompetent browser. Note that the session replacement here is potentially
|
||||
* insecure as it uses window.name without any fancy protections.
|
||||
*
|
||||
* Status: BETA - unsupported, useful, needs testing & refining
|
||||
*/
|
||||
;(function(window, document, store, _) {
|
||||
|
||||
function addUpdateFn(area, name, update) {
|
||||
var old = area[name];
|
||||
area[name] = function() {
|
||||
var ret = old.apply(this, arguments);
|
||||
update.apply(this, arguments);
|
||||
return ret;
|
||||
};
|
||||
}
|
||||
function create(name, items, update) {
|
||||
var length = 0;
|
||||
for (var k in items) {
|
||||
if (items.hasOwnProperty(k)) {
|
||||
length++;
|
||||
}
|
||||
}
|
||||
var area = _.inherit(_.storageAPI, { items:items, length:length, name:name });
|
||||
if (update) {
|
||||
addUpdateFn(area, 'setItem', update);
|
||||
addUpdateFn(area, 'removeItem', update);
|
||||
}
|
||||
return area;
|
||||
}
|
||||
|
||||
if (store.isFake()) {
|
||||
var area;
|
||||
|
||||
if (document.documentElement.addBehavior) {// IE userData
|
||||
var el = document.createElement('div'),
|
||||
sn = 'localStorage',
|
||||
body = document.body,
|
||||
wrap = function wrap(fn) {
|
||||
return function() {
|
||||
body.appendChild(el);
|
||||
el.addBehavior('#default#userData');
|
||||
el.load(sn);
|
||||
var ret = fn.apply(store._area, arguments);
|
||||
el.save(sn);
|
||||
body.removeChild(el);
|
||||
return ret;
|
||||
};
|
||||
},
|
||||
has = function has(key){
|
||||
return el.getAttribute(key) !== null;
|
||||
},
|
||||
UserDataStorage = function UserDataStorage(){};
|
||||
|
||||
UserDataStorage.prototype = {
|
||||
length: (wrap(function(){
|
||||
return el.XMLDocument.documentElement.attributes.length;
|
||||
}))(),
|
||||
has: wrap(has),
|
||||
key: wrap(function(i) {
|
||||
return el.XMLDocument.documentElement.attributes[i];
|
||||
}),
|
||||
setItem: wrap(function(k, v) {
|
||||
if (!has(k)) {
|
||||
this.length++;
|
||||
}
|
||||
el.setAttribute(k, v);
|
||||
}),
|
||||
removeItem: wrap(function(k) {
|
||||
if (has(k)) {
|
||||
el.removeAttribute(k);
|
||||
this.length--;
|
||||
}
|
||||
}),
|
||||
getItem: wrap(function(k){ return el.getAttribute(k); }),
|
||||
clear: wrap(function() {
|
||||
var all = el.XMLDocument.documentElement.attributes;
|
||||
for (var i=0, a; !!(a = all[i]); i++) {
|
||||
el.removeAttribute(a.name);
|
||||
}
|
||||
this.length = 0;
|
||||
})
|
||||
};
|
||||
area = new UserDataStorage();
|
||||
|
||||
} else if ('globalStorage' in window && window.globalStorage) {// FF globalStorage
|
||||
area = create('global', window.globalStorage[window.location.hostname]);
|
||||
|
||||
} else {// cookie
|
||||
var date = new Date(),
|
||||
key = 'store.local',
|
||||
items = {},
|
||||
cookies = document.cookie.split(';');
|
||||
date.setTime(date.getTime()+(5*365*24*60*60*1000));//5 years out
|
||||
date = date.toGMTString();
|
||||
for (var i=0,m=cookies.length; i<m; i++) {
|
||||
var c = cookies[i];
|
||||
while (c.charAt(0) === ' ') {
|
||||
c = c.substring(1, c.length);
|
||||
}
|
||||
if (c.indexOf(key) === 0) {
|
||||
items = JSON.parse(c.substring(key.length+1));
|
||||
}
|
||||
}
|
||||
area = create('cookie', items, function() {
|
||||
document.cookie = key+"="+JSON.stringify(this.items)+"; expires="+date+"; path=/";
|
||||
});
|
||||
}
|
||||
|
||||
// replace local's fake storage
|
||||
store._area = _.areas.local = area;
|
||||
}
|
||||
|
||||
if (store.session.isFake()) {
|
||||
var sItems = window.name ? JSON.parse(window.name)[document.domain]||{} : {};
|
||||
store.session._area = _.areas.session =
|
||||
create('windowName', sItems, function() {
|
||||
var o = {};
|
||||
o[document.domain] = this.items;
|
||||
window.name = JSON.stringify(o);
|
||||
});
|
||||
}
|
||||
|
||||
})(window, document, window.store, window.store._);
|
||||
79
node_modules/store2/src/store.on.js
generated
vendored
Normal file
79
node_modules/store2/src/store.on.js
generated
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* Copyright (c) 2013 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Makes it easy to watch for storage events by enhancing the events and
|
||||
* allowing binding to particular keys and/or namespaces.
|
||||
*
|
||||
* // listen to particular key storage events (yes, this is namespace sensitive)
|
||||
* store.on('foo', function listenToFoo(e){ console.log('foo was changed:', e); });
|
||||
* store.off('foo', listenToFoo);
|
||||
*
|
||||
* // listen to all storage events (also namespace sensitive)
|
||||
* store.on(function storageEvent(e){ console.log('web storage:', e); });
|
||||
* store.off(storageEvent);
|
||||
*
|
||||
* Status: BETA - useful, if you aren't using IE8 or worse
|
||||
*/
|
||||
;(function(window, _) {
|
||||
|
||||
_.on = function(key, fn) {
|
||||
if (!fn) { fn = key; key = ''; }// no key === all keys
|
||||
var s = this,
|
||||
listener = function(e) {
|
||||
var k = s._out(e.key);// undefined if key is not in the namespace
|
||||
if ((k && (k === key ||// match key if listener has one
|
||||
(!key && k !== '_-bad-_'))) &&// match catch-all, except internal test
|
||||
(!e.storageArea || e.storageArea === s._area)) {// match area, if available
|
||||
return fn.call(s, _.event.call(s, k, e));
|
||||
}
|
||||
};
|
||||
window.addEventListener("storage", fn[key+'-listener']=listener, false);
|
||||
return this;
|
||||
};
|
||||
|
||||
_.off = function(key, fn) {
|
||||
if (!fn) { fn = key; key = ''; }// no key === all keys
|
||||
window.removeEventListener("storage", fn[key+'-listener']);
|
||||
return this;
|
||||
};
|
||||
|
||||
_.once = function(key, fn) {
|
||||
if (!fn) { fn = key; key = ''; }
|
||||
var s = this, listener;
|
||||
return s.on(key, listener = function() {
|
||||
s.off(key, listener);
|
||||
return fn.apply(this, arguments);
|
||||
});
|
||||
};
|
||||
|
||||
_.event = function(k, e) {
|
||||
var event = {
|
||||
key: k,
|
||||
namespace: this.namespace(),
|
||||
newValue: _.parse(e.newValue),
|
||||
oldValue: _.parse(e.oldValue),
|
||||
url: e.url || e.uri,
|
||||
storageArea: e.storageArea,
|
||||
source: e.source,
|
||||
timeStamp: e.timeStamp,
|
||||
originalEvent: e
|
||||
};
|
||||
if (_.cache) {
|
||||
var min = _.expires(e.newValue || e.oldValue);
|
||||
if (min) {
|
||||
event.expires = _.when(min);
|
||||
}
|
||||
}
|
||||
return event;
|
||||
};
|
||||
|
||||
// store2 policy is to not throw errors on old browsers
|
||||
var old = !window.addEventListener ? function(){} : null;
|
||||
_.fn('on', old || _.on);
|
||||
_.fn('off', old || _.off);
|
||||
_.fn('once', old || _.once);
|
||||
|
||||
})(window, window.store._);
|
||||
18
node_modules/store2/src/store.onlyreal.js
generated
vendored
Normal file
18
node_modules/store2/src/store.onlyreal.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright (c) 2015 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Store nothing when storage is not supported.
|
||||
*
|
||||
* Status: ALPHA - due to being of doubtful propriety
|
||||
*/
|
||||
;(function(_) {
|
||||
|
||||
var _set = _.set;
|
||||
_.set = function(area) {
|
||||
return area.name === 'fake' ? undefined : _set.apply(this, arguments);
|
||||
};
|
||||
|
||||
})(window.store._);
|
||||
87
node_modules/store2/src/store.overflow.js
generated
vendored
Normal file
87
node_modules/store2/src/store.overflow.js
generated
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/**
|
||||
* Copyright (c) 2013 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* When quota is reached on a storage area, this shifts incoming values to
|
||||
* fake storage, so they last only as long as the page does. This is useful
|
||||
* because it is more burdensome for localStorage to recover from quota errors
|
||||
* than incomplete caches. In other words, it is wiser to rely on store.js
|
||||
* never complaining than never missing data. You should already be checking
|
||||
* the integrity of cached data on every page load.
|
||||
*
|
||||
* Status: BETA
|
||||
*/
|
||||
;(function(store, _) {
|
||||
var _set = _.set,
|
||||
_get = _.get,
|
||||
_remove = _.remove,
|
||||
_key = _.key,
|
||||
_length = _.length,
|
||||
_clear = _.clear;
|
||||
|
||||
_.overflow = function(area, create) {
|
||||
var name = area === _.areas.local ? '+local+' :
|
||||
area === _.areas.session ? '+session+' : false;
|
||||
if (name) {
|
||||
var overflow = _.areas[name];
|
||||
if (create && !overflow) {
|
||||
overflow = store.area(name)._area;// area() copies to _.areas
|
||||
} else if (create === false) {
|
||||
delete _.areas[name];
|
||||
delete store[name];
|
||||
}
|
||||
return overflow;
|
||||
}
|
||||
};
|
||||
_.set = function(area, key, string) {
|
||||
try {
|
||||
_set.apply(this, arguments);
|
||||
} catch (e) {
|
||||
if (e.name === 'QUOTA_EXCEEDED_ERR' ||
|
||||
e.name === 'NS_ERROR_DOM_QUOTA_REACHED' ||
|
||||
e.toString().indexOf("QUOTA_EXCEEDED_ERR") !== -1 ||
|
||||
e.toString().indexOf("QuotaExceededError") !== -1) {
|
||||
// the e.toString is needed for IE9 / IE10, cos name is empty there
|
||||
return _.set(_.overflow(area, true), key, string);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
_.get = function(area, key) {
|
||||
var overflow = _.overflow(area);
|
||||
return (overflow && _get.call(this, overflow, key)) ||
|
||||
_get.apply(this, arguments);
|
||||
};
|
||||
_.remove = function(area, key) {
|
||||
var overflow = _.overflow(area);
|
||||
if (overflow){ _remove.call(this, overflow, key); }
|
||||
_remove.apply(this, arguments);
|
||||
};
|
||||
_.key = function(area, i) {
|
||||
var overflow = _.overflow(area);
|
||||
if (overflow) {
|
||||
var l = _length.call(this, area);
|
||||
if (i >= l) {
|
||||
i = i - l;// make i overflow-relative
|
||||
for (var j=0, m=_length.call(this, overflow); j<m; j++) {
|
||||
if (j === i) {// j is overflow index
|
||||
return _key.call(this, overflow, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return _key.apply(this, arguments);
|
||||
};
|
||||
_.length = function(area) {
|
||||
var length = _length(area),
|
||||
overflow = _.overflow(area);
|
||||
return overflow ? length + _length(overflow) : length;
|
||||
};
|
||||
_.clear = function(area) {
|
||||
_.overflow(area, false);
|
||||
_clear.apply(this, arguments);
|
||||
};
|
||||
|
||||
})(window.store, window.store._);
|
||||
45
node_modules/store2/src/store.quota.js
generated
vendored
Normal file
45
node_modules/store2/src/store.quota.js
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* Copyright (c) 2013 ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
* Bind handlers to quota errors:
|
||||
* store.quota(function(e, area, key, str) {
|
||||
* console.log(e, area, key, str);
|
||||
* });
|
||||
* If a handler returns true other handlers are not called and
|
||||
* the error is suppressed.
|
||||
*
|
||||
* Think quota errors will never happen to you? Think again:
|
||||
* http://spin.atomicobject.com/2013/01/23/ios-private-browsing-localstorage/
|
||||
* (this affects sessionStorage too)
|
||||
*
|
||||
* Status: ALPHA - API could use unbind feature
|
||||
*/
|
||||
;(function(store, _) {
|
||||
|
||||
store.quota = function(fn) {
|
||||
store.quota.fns.push(fn);
|
||||
};
|
||||
store.quota.fns = [];
|
||||
|
||||
var _set = _.set;
|
||||
_.set = function(area, key, str) {
|
||||
try {
|
||||
_set.apply(this, arguments);
|
||||
} catch (e) {
|
||||
if (e.name === 'QUOTA_EXCEEDED_ERR' ||
|
||||
e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
|
||||
var fns = store.quota.fns;
|
||||
for (var i=0,m=fns.length; i<m; i++) {
|
||||
if (true === fns[i].call(this, e, area, key, str)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
|
||||
})(window.store, window.store._);
|
||||
287
node_modules/store2/src/store2.js
generated
vendored
Normal file
287
node_modules/store2/src/store2.js
generated
vendored
Normal file
@@ -0,0 +1,287 @@
|
||||
/**
|
||||
* Copyright (c) 2022, ESHA Research
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*/
|
||||
;(function(window, define) {
|
||||
var _ = {
|
||||
version: "<%= pkg.version %>",
|
||||
areas: {},
|
||||
apis: {},
|
||||
nsdelim: '.',
|
||||
|
||||
// utilities
|
||||
inherit: function(api, o) {
|
||||
for (var p in api) {
|
||||
if (!o.hasOwnProperty(p)) {
|
||||
Object.defineProperty(o, p, Object.getOwnPropertyDescriptor(api, p));
|
||||
}
|
||||
}
|
||||
return o;
|
||||
},
|
||||
stringify: function(d, fn) {
|
||||
return d === undefined || typeof d === "function" ? d+'' : JSON.stringify(d,fn||_.replace);
|
||||
},
|
||||
parse: function(s, fn) {
|
||||
// if it doesn't parse, return as is
|
||||
try{ return JSON.parse(s,fn||_.revive); }catch(e){ return s; }
|
||||
},
|
||||
|
||||
// extension hooks
|
||||
fn: function(name, fn) {
|
||||
_.storeAPI[name] = fn;
|
||||
for (var api in _.apis) {
|
||||
_.apis[api][name] = fn;
|
||||
}
|
||||
},
|
||||
get: function(area, key){ return area.getItem(key); },
|
||||
set: function(area, key, string){ area.setItem(key, string); },
|
||||
remove: function(area, key){ area.removeItem(key); },
|
||||
key: function(area, i){ return area.key(i); },
|
||||
length: function(area){ return area.length; },
|
||||
clear: function(area){ area.clear(); },
|
||||
|
||||
// core functions
|
||||
Store: function(id, area, namespace) {
|
||||
var store = _.inherit(_.storeAPI, function(key, data, overwrite) {
|
||||
if (arguments.length === 0){ return store.getAll(); }
|
||||
if (typeof data === "function"){ return store.transact(key, data, overwrite); }// fn=data, alt=overwrite
|
||||
if (data !== undefined){ return store.set(key, data, overwrite); }
|
||||
if (typeof key === "string" || typeof key === "number"){ return store.get(key); }
|
||||
if (typeof key === "function"){ return store.each(key); }
|
||||
if (!key){ return store.clear(); }
|
||||
return store.setAll(key, data);// overwrite=data, data=key
|
||||
});
|
||||
store._id = id;
|
||||
try {
|
||||
var testKey = '__store2_test';
|
||||
area.setItem(testKey, 'ok');
|
||||
store._area = area;
|
||||
area.removeItem(testKey);
|
||||
} catch (e) {
|
||||
store._area = _.storage('fake');
|
||||
}
|
||||
store._ns = namespace || '';
|
||||
if (!_.areas[id]) {
|
||||
_.areas[id] = store._area;
|
||||
}
|
||||
if (!_.apis[store._ns+store._id]) {
|
||||
_.apis[store._ns+store._id] = store;
|
||||
}
|
||||
return store;
|
||||
},
|
||||
storeAPI: {
|
||||
// admin functions
|
||||
area: function(id, area) {
|
||||
var store = this[id];
|
||||
if (!store || !store.area) {
|
||||
store = _.Store(id, area, this._ns);//new area-specific api in this namespace
|
||||
if (!this[id]){ this[id] = store; }
|
||||
}
|
||||
return store;
|
||||
},
|
||||
namespace: function(namespace, singleArea, delim) {
|
||||
delim = delim || this._delim || _.nsdelim;
|
||||
if (!namespace){
|
||||
return this._ns ? this._ns.substring(0,this._ns.length-delim.length) : '';
|
||||
}
|
||||
var ns = namespace, store = this[ns];
|
||||
if (!store || !store.namespace) {
|
||||
store = _.Store(this._id, this._area, this._ns+ns+delim);//new namespaced api
|
||||
store._delim = delim;
|
||||
if (!this[ns]){ this[ns] = store; }
|
||||
if (!singleArea) {
|
||||
for (var name in _.areas) {
|
||||
store.area(name, _.areas[name]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return store;
|
||||
},
|
||||
isFake: function(force) {
|
||||
if (force) {
|
||||
this._real = this._area;
|
||||
this._area = _.storage('fake');
|
||||
} else if (force === false) {
|
||||
this._area = this._real || this._area;
|
||||
}
|
||||
return this._area.name === 'fake';
|
||||
},
|
||||
toString: function() {
|
||||
return 'store'+(this._ns?'.'+this.namespace():'')+'['+this._id+']';
|
||||
},
|
||||
|
||||
// storage functions
|
||||
has: function(key) {
|
||||
if (this._area.has) {
|
||||
return this._area.has(this._in(key));//extension hook
|
||||
}
|
||||
return !!(this._in(key) in this._area);
|
||||
},
|
||||
size: function(){ return this.keys().length; },
|
||||
each: function(fn, fill) {// fill is used by keys(fillList) and getAll(fillList))
|
||||
for (var i=0, m=_.length(this._area); i<m; i++) {
|
||||
var key = this._out(_.key(this._area, i));
|
||||
if (key !== undefined) {
|
||||
if (fn.call(this, key, this.get(key), fill) === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (m > _.length(this._area)) { m--; i--; }// in case of removeItem
|
||||
}
|
||||
return fill || this;
|
||||
},
|
||||
keys: function(fillList) {
|
||||
return this.each(function(k, v, list){ list.push(k); }, fillList || []);
|
||||
},
|
||||
get: function(key, alt) {
|
||||
var s = _.get(this._area, this._in(key)),
|
||||
fn;
|
||||
if (typeof alt === "function") {
|
||||
fn = alt;
|
||||
alt = null;
|
||||
}
|
||||
return s !== null ? _.parse(s, fn) :
|
||||
alt != null ? alt : s;
|
||||
},
|
||||
getAll: function(fillObj) {
|
||||
return this.each(function(k, v, all){ all[k] = v; }, fillObj || {});
|
||||
},
|
||||
transact: function(key, fn, alt) {
|
||||
var val = this.get(key, alt),
|
||||
ret = fn(val);
|
||||
this.set(key, ret === undefined ? val : ret);
|
||||
return this;
|
||||
},
|
||||
set: function(key, data, overwrite) {
|
||||
var d = this.get(key),
|
||||
replacer;
|
||||
if (d != null && overwrite === false) {
|
||||
return data;
|
||||
}
|
||||
if (typeof overwrite === "function") {
|
||||
replacer = overwrite;
|
||||
overwrite = undefined;
|
||||
}
|
||||
return _.set(this._area, this._in(key), _.stringify(data, replacer), overwrite) || d;
|
||||
},
|
||||
setAll: function(data, overwrite) {
|
||||
var changed, val;
|
||||
for (var key in data) {
|
||||
val = data[key];
|
||||
if (this.set(key, val, overwrite) !== val) {
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
},
|
||||
add: function(key, data, replacer) {
|
||||
var d = this.get(key);
|
||||
if (d instanceof Array) {
|
||||
data = d.concat(data);
|
||||
} else if (d !== null) {
|
||||
var type = typeof d;
|
||||
if (type === typeof data && type === 'object') {
|
||||
for (var k in data) {
|
||||
d[k] = data[k];
|
||||
}
|
||||
data = d;
|
||||
} else {
|
||||
data = d + data;
|
||||
}
|
||||
}
|
||||
_.set(this._area, this._in(key), _.stringify(data, replacer));
|
||||
return data;
|
||||
},
|
||||
remove: function(key, alt) {
|
||||
var d = this.get(key, alt);
|
||||
_.remove(this._area, this._in(key));
|
||||
return d;
|
||||
},
|
||||
clear: function() {
|
||||
if (!this._ns) {
|
||||
_.clear(this._area);
|
||||
} else {
|
||||
this.each(function(k){ _.remove(this._area, this._in(k)); }, 1);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
clearAll: function() {
|
||||
var area = this._area;
|
||||
for (var id in _.areas) {
|
||||
if (_.areas.hasOwnProperty(id)) {
|
||||
this._area = _.areas[id];
|
||||
this.clear();
|
||||
}
|
||||
}
|
||||
this._area = area;
|
||||
return this;
|
||||
},
|
||||
|
||||
// internal use functions
|
||||
_in: function(k) {
|
||||
if (typeof k !== "string"){ k = _.stringify(k); }
|
||||
return this._ns ? this._ns + k : k;
|
||||
},
|
||||
_out: function(k) {
|
||||
return this._ns ?
|
||||
k && k.indexOf(this._ns) === 0 ?
|
||||
k.substring(this._ns.length) :
|
||||
undefined : // so each() knows to skip it
|
||||
k;
|
||||
}
|
||||
},// end _.storeAPI
|
||||
storage: function(name) {
|
||||
return _.inherit(_.storageAPI, { items: {}, name: name });
|
||||
},
|
||||
storageAPI: {
|
||||
length: 0,
|
||||
has: function(k){ return this.items.hasOwnProperty(k); },
|
||||
key: function(i) {
|
||||
var c = 0;
|
||||
for (var k in this.items){
|
||||
if (this.has(k) && i === c++) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
},
|
||||
setItem: function(k, v) {
|
||||
if (!this.has(k)) {
|
||||
this.length++;
|
||||
}
|
||||
this.items[k] = v;
|
||||
},
|
||||
removeItem: function(k) {
|
||||
if (this.has(k)) {
|
||||
delete this.items[k];
|
||||
this.length--;
|
||||
}
|
||||
},
|
||||
getItem: function(k){ return this.has(k) ? this.items[k] : null; },
|
||||
clear: function(){ for (var k in this.items){ this.removeItem(k); } }
|
||||
}// end _.storageAPI
|
||||
};
|
||||
|
||||
var store =
|
||||
// safely set this up (throws error in IE10/32bit mode for local files)
|
||||
_.Store("local", (function(){try{ return localStorage; }catch(e){}})());
|
||||
store.local = store;// for completeness
|
||||
store._ = _;// for extenders and debuggers...
|
||||
// safely setup store.session (throws exception in FF for file:/// urls)
|
||||
store.area("session", (function(){try{ return sessionStorage; }catch(e){}})());
|
||||
store.area("page", _.storage("page"));
|
||||
|
||||
if (typeof define === 'function' && define.amd !== undefined) {
|
||||
define('store2', [], function () {
|
||||
return store;
|
||||
});
|
||||
} else if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = store;
|
||||
} else {
|
||||
// expose the primary store fn to the global object and save conflicts
|
||||
if (window.store){ _.conflict = window.store; }
|
||||
window.store = store;
|
||||
}
|
||||
|
||||
})(this, this && this.define);
|
||||
Reference in New Issue
Block a user