@converse/skeletor 0.0.9 → 1.0.0
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/README.md +5 -89
- package/dist/skeletor.d.ts +764 -0
- package/dist/skeletor.js +7564 -7743
- package/dist/skeletor.min.js +6 -11
- package/package.json +46 -30
- package/src/{collection.js → collection.ts} +232 -271
- package/src/drivers/{sessionStorage.js → sessionStorage.ts} +81 -93
- package/src/{eventemitter.js → eventemitter.ts} +44 -59
- package/src/{helpers.js → helpers.ts} +56 -69
- package/src/index.ts +84 -0
- package/src/{listening.js → listening.ts} +32 -27
- package/src/{model.js → model.ts} +143 -162
- package/src/{storage.js → storage.ts} +92 -49
- package/src/types.ts +189 -0
- package/src/utils/{events.js → events.ts} +98 -48
- package/dist/skeletor.js.map +0 -1
- package/dist/skeletor.min.js.map +0 -1
- package/src/element.js +0 -238
- package/src/index.js +0 -47
- package/src/types/collection.d.ts +0 -366
- package/src/types/collection.d.ts.map +0 -1
- package/src/types/drivers/sessionStorage.d.ts +0 -37
- package/src/types/drivers/sessionStorage.d.ts.map +0 -1
- package/src/types/element.d.ts +0 -115
- package/src/types/element.d.ts.map +0 -1
- package/src/types/eventemitter.d.ts +0 -93
- package/src/types/eventemitter.d.ts.map +0 -1
- package/src/types/helpers.d.ts +0 -62
- package/src/types/helpers.d.ts.map +0 -1
- package/src/types/index.d.ts +0 -19
- package/src/types/index.d.ts.map +0 -1
- package/src/types/listening.d.ts +0 -40
- package/src/types/listening.d.ts.map +0 -1
- package/src/types/model.d.ts +0 -230
- package/src/types/model.d.ts.map +0 -1
- package/src/types/storage.d.ts +0 -35
- package/src/types/storage.d.ts.map +0 -1
- package/src/types/utils/events.d.ts +0 -28
- package/src/types/utils/events.d.ts.map +0 -1
package/src/element.js
DELETED
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @typedef {import('lit-html').TemplateResult} TemplateResult
|
|
4
|
-
*/
|
|
5
|
-
import uniqueId from 'lodash-es/uniqueId.js';
|
|
6
|
-
import { render } from 'lit-html';
|
|
7
|
-
import EventEmitter from './eventemitter.js';
|
|
8
|
-
|
|
9
|
-
// Cached regex to split keys for `delegate`.
|
|
10
|
-
const delegateEventSplitter = /^(\S+)\s*(.*)$/;
|
|
11
|
-
|
|
12
|
-
class ElementView extends EventEmitter(HTMLElement) {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* @typedef {import('./model.js').Model} Model
|
|
16
|
-
* @typedef {import('./collection.js').Collection} Collection
|
|
17
|
-
* @typedef {Record.<string, any>} Options
|
|
18
|
-
*
|
|
19
|
-
* @callback EventCallback
|
|
20
|
-
* @param {any} event
|
|
21
|
-
* @param {Model} model
|
|
22
|
-
* @param {Collection} collection
|
|
23
|
-
* @param {Options} [options]
|
|
24
|
-
*/
|
|
25
|
-
|
|
26
|
-
set events (events) {
|
|
27
|
-
this._declarativeEvents = events;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
get events() {
|
|
31
|
-
return this._declarativeEvents;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* @param {Options} options
|
|
36
|
-
*/
|
|
37
|
-
constructor(options={}) {
|
|
38
|
-
super();
|
|
39
|
-
|
|
40
|
-
// Will be assigned to from Events
|
|
41
|
-
this.stopListening = null;
|
|
42
|
-
|
|
43
|
-
// Creating a View creates its initial element outside of the DOM,
|
|
44
|
-
// if an existing element is not provided...
|
|
45
|
-
this.cid = uniqueId('view');
|
|
46
|
-
this._declarativeEvents = {};
|
|
47
|
-
this._domEvents = [];
|
|
48
|
-
|
|
49
|
-
const { model, collection, events } = options;
|
|
50
|
-
|
|
51
|
-
Object.assign(this, { model: model, collection, events });
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
createRenderRoot() {
|
|
55
|
-
// Render without the shadow DOM
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
connectedCallback() {
|
|
60
|
-
if (!this._initialized) {
|
|
61
|
-
this.preinitialize.apply(this, arguments);
|
|
62
|
-
this.initialize.apply(this, arguments);
|
|
63
|
-
this._initialized = true;
|
|
64
|
-
}
|
|
65
|
-
this.delegateEvents();
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
disconnectedCallback() {
|
|
69
|
-
this.undelegateEvents();
|
|
70
|
-
this.stopListening?.();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* preinitialize is an empty function by default. You can override it with a function
|
|
75
|
-
* or object. preinitialize will run before any instantiation logic is run in the View
|
|
76
|
-
* eslint-disable-next-line class-methods-use-this
|
|
77
|
-
*/
|
|
78
|
-
preinitialize() {}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Initialize is an empty function by default. Override it with your own
|
|
82
|
-
* initialization logic.
|
|
83
|
-
*/
|
|
84
|
-
initialize() {}
|
|
85
|
-
|
|
86
|
-
beforeRender() {}
|
|
87
|
-
afterRender() {}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* **render** is the core function that your view should override, in order
|
|
91
|
-
* to populate its element (`this.el`), with the appropriate HTML. The
|
|
92
|
-
* convention is for **render** to always return `this`.
|
|
93
|
-
*/
|
|
94
|
-
render() {
|
|
95
|
-
this.beforeRender();
|
|
96
|
-
render(this.toHTML(), this);
|
|
97
|
-
this.afterRender();
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* @returns {string|TemplateResult}
|
|
103
|
-
*/
|
|
104
|
-
toHTML() {
|
|
105
|
-
return '';
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/**
|
|
109
|
-
* Set callbacks, where `this.events` is a hash of
|
|
110
|
-
*
|
|
111
|
-
* *{"event selector": "callback"}*
|
|
112
|
-
*
|
|
113
|
-
* {
|
|
114
|
-
* 'mousedown .title': 'edit',
|
|
115
|
-
* 'click .button': 'save',
|
|
116
|
-
* 'click .open': function(e) { ... }
|
|
117
|
-
* }
|
|
118
|
-
*
|
|
119
|
-
* pairs. Callbacks will be bound to the view, with `this` set properly.
|
|
120
|
-
* Uses event delegation for efficiency.
|
|
121
|
-
* Omitting the selector binds the event to `this.el`.
|
|
122
|
-
*/
|
|
123
|
-
delegateEvents() {
|
|
124
|
-
if (!this.events) {
|
|
125
|
-
return this;
|
|
126
|
-
}
|
|
127
|
-
this.undelegateEvents();
|
|
128
|
-
for (const key in this.events) {
|
|
129
|
-
let method = this.events[key];
|
|
130
|
-
if (typeof method !== 'function') method = this[method];
|
|
131
|
-
if (!method) continue;
|
|
132
|
-
const match = key.match(delegateEventSplitter);
|
|
133
|
-
this.delegate(match[1], match[2], method.bind(this));
|
|
134
|
-
}
|
|
135
|
-
return this;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Make a event delegation handler for the given `eventName` and `selector`
|
|
140
|
-
* and attach it to `this.el`.
|
|
141
|
-
* If selector is empty, the listener will be bound to `this.el`. If not, a
|
|
142
|
-
* new handler that will recursively traverse up the event target's DOM
|
|
143
|
-
* hierarchy looking for a node that matches the selector. If one is found,
|
|
144
|
-
* the event's `delegateTarget` property is set to it and the return the
|
|
145
|
-
* result of calling bound `listener` with the parameters given to the
|
|
146
|
-
* handler.
|
|
147
|
-
* @param {string} eventName
|
|
148
|
-
* @param {string} selector
|
|
149
|
-
* @param {(ev: Event) => any} listener
|
|
150
|
-
*/
|
|
151
|
-
delegate(eventName, selector, listener) {
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
153
|
-
const root = this;
|
|
154
|
-
if (!root) {
|
|
155
|
-
return this;
|
|
156
|
-
}
|
|
157
|
-
if (typeof selector === 'function') {
|
|
158
|
-
listener = selector;
|
|
159
|
-
selector = null;
|
|
160
|
-
}
|
|
161
|
-
// Given that `focus` and `blur` events do not bubble, do not delegate these events
|
|
162
|
-
if (['focus', 'blur'].indexOf(eventName) !== -1) {
|
|
163
|
-
const els = this.querySelectorAll(selector);
|
|
164
|
-
for (let i = 0, len = els.length; i < len; i++) {
|
|
165
|
-
const item = els[i];
|
|
166
|
-
item.addEventListener(eventName, listener, false);
|
|
167
|
-
this._domEvents.push({ el: item, eventName: eventName, handler: listener });
|
|
168
|
-
}
|
|
169
|
-
return listener;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
const handler = selector
|
|
173
|
-
? function (e) {
|
|
174
|
-
let node = e.target || e.srcElement;
|
|
175
|
-
for (; node && node != root; node = node.parentNode) {
|
|
176
|
-
if (node.matches(selector)) {
|
|
177
|
-
e.delegateTarget = node;
|
|
178
|
-
listener(e);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
: listener;
|
|
183
|
-
|
|
184
|
-
this.addEventListener(eventName, handler, false);
|
|
185
|
-
this._domEvents.push({ el: this, eventName: eventName, handler: handler, listener: listener, selector: selector });
|
|
186
|
-
return this;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Clears all callbacks previously bound to the view by `delegateEvents`.
|
|
191
|
-
* You usually don't need to use this, but may wish to if you have multiple
|
|
192
|
-
* Backbone views attached to the same DOM element.
|
|
193
|
-
*/
|
|
194
|
-
undelegateEvents() {
|
|
195
|
-
if (this) {
|
|
196
|
-
for (let i = 0, len = this._domEvents.length; i < len; i++) {
|
|
197
|
-
const item = this._domEvents[i];
|
|
198
|
-
item.el.removeEventListener(item.eventName, item.handler, false);
|
|
199
|
-
}
|
|
200
|
-
this._domEvents.length = 0;
|
|
201
|
-
}
|
|
202
|
-
return this;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* A finer-grained `undelegateEvents` for removing a single delegated event.
|
|
207
|
-
* `selector` and `listener` are both optional.
|
|
208
|
-
* @param {string} eventName
|
|
209
|
-
* @param {string} selector
|
|
210
|
-
* @param {(ev: Event) => any} listener
|
|
211
|
-
*/
|
|
212
|
-
undelegate(eventName, selector, listener) {
|
|
213
|
-
if (typeof selector === 'function') {
|
|
214
|
-
listener = selector;
|
|
215
|
-
selector = null;
|
|
216
|
-
}
|
|
217
|
-
if (this) {
|
|
218
|
-
const handlers = this._domEvents.slice();
|
|
219
|
-
let i = handlers.length;
|
|
220
|
-
while (i--) {
|
|
221
|
-
const item = handlers[i];
|
|
222
|
-
const match =
|
|
223
|
-
item.eventName === eventName &&
|
|
224
|
-
(listener ? item.listener === listener : true) &&
|
|
225
|
-
(selector ? item.selector === selector : true);
|
|
226
|
-
|
|
227
|
-
if (!match) {
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
item.el.removeEventListener(item.eventName, item.handler, false);
|
|
231
|
-
this._domEvents.splice(i, 1);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return this;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
export default ElementView;
|
package/src/index.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/* global global */
|
|
2
|
-
import ElementView from './element.js';
|
|
3
|
-
import EventEmitter from './eventemitter.js';
|
|
4
|
-
import Storage from './storage.js';
|
|
5
|
-
import { Collection } from './collection.js';
|
|
6
|
-
import { Model } from './model.js';
|
|
7
|
-
import { sync } from './helpers.js';
|
|
8
|
-
|
|
9
|
-
const skeletor = {
|
|
10
|
-
Collection,
|
|
11
|
-
ElementView,
|
|
12
|
-
EventEmitter,
|
|
13
|
-
Model,
|
|
14
|
-
sync,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
// Establish the root object, `window` (`self`) in the browser, or `global` on the server.
|
|
18
|
-
// We use `self` instead of `window` for `WebWorker` support.
|
|
19
|
-
const root =
|
|
20
|
-
(typeof self == 'object' && self.self === self && self) ||
|
|
21
|
-
(typeof global == 'object' && global.global === global && global);
|
|
22
|
-
|
|
23
|
-
// Current version of the library. Keep in sync with `package.json`.
|
|
24
|
-
skeletor.VERSION = '0.0.1';
|
|
25
|
-
|
|
26
|
-
// Save the previous value of the `Skeletor` variable, so that it can be
|
|
27
|
-
// restored later on, if `noConflict` is used.
|
|
28
|
-
const previousSkeletor = root.Skeletor;
|
|
29
|
-
|
|
30
|
-
// Runs Skeletor.js in *noConflict* mode, returning the `Skeletor` variable
|
|
31
|
-
// to its previous owner. Returns a reference to this Skeletor object.
|
|
32
|
-
skeletor.noConflict = function () {
|
|
33
|
-
root.Skeletor = previousSkeletor;
|
|
34
|
-
return this;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
root.Skeletor = skeletor;
|
|
38
|
-
export default skeletor;
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
Collection,
|
|
42
|
-
ElementView,
|
|
43
|
-
EventEmitter,
|
|
44
|
-
Model,
|
|
45
|
-
Storage,
|
|
46
|
-
sync,
|
|
47
|
-
}
|
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
export type Options = Record<string, any>;
|
|
2
|
-
export type Attributes = Record<string, any>;
|
|
3
|
-
export type Storage = import("./storage.js").default;
|
|
4
|
-
export type CollectionOptions = Record<string, any>;
|
|
5
|
-
declare const Collection_base: {
|
|
6
|
-
new (...args: any[]): {
|
|
7
|
-
on(name: string, callback: (event: any, model: Model, collection: Collection, options: Record<string, any>) => any, context: any): /*elided*/ any;
|
|
8
|
-
_events: any;
|
|
9
|
-
_listeners: {};
|
|
10
|
-
listenTo(obj: any, name: string, callback?: (event: any, model: Model, collection: Collection, options: Record<string, any>) => any): /*elided*/ any;
|
|
11
|
-
_listeningTo: {};
|
|
12
|
-
_listenId: any;
|
|
13
|
-
off(name: string, callback: (event: any, model: Model, collection: Collection, options: Record<string, any>) => any, context?: any): /*elided*/ any;
|
|
14
|
-
stopListening(obj?: any, name?: string, callback?: (event: any, model: Model, collection: Collection, options: Record<string, any>) => any): /*elided*/ any;
|
|
15
|
-
once(name: string, callback: (event: any, model: Model, collection: Collection, options: Record<string, any>) => any, context: any): /*elided*/ any;
|
|
16
|
-
listenToOnce(obj: any, name: string, callback?: (event: any, model: Model, collection: Collection, options: Record<string, any>) => any): /*elided*/ any;
|
|
17
|
-
trigger(name: string, ...args: any[]): /*elided*/ any;
|
|
18
|
-
};
|
|
19
|
-
} & ObjectConstructor;
|
|
20
|
-
/**
|
|
21
|
-
* @typedef {Record.<string, any>} Options
|
|
22
|
-
* @typedef {Record.<string, any>} Attributes
|
|
23
|
-
*
|
|
24
|
-
* @typedef {import('./storage.js').default} Storage
|
|
25
|
-
*
|
|
26
|
-
* @typedef {Record.<string, any>} CollectionOptions
|
|
27
|
-
* @property {Model} [model]
|
|
28
|
-
* @property {Function} [comparator]
|
|
29
|
-
*/
|
|
30
|
-
/**
|
|
31
|
-
* If models tend to represent a single row of data, a Collection is
|
|
32
|
-
* more analogous to a table full of data ... or a small slice or page of that
|
|
33
|
-
* table, or a collection of rows that belong together for a particular reason
|
|
34
|
-
* -- all of the messages in this particular folder, all of the documents
|
|
35
|
-
* belonging to this particular author, and so on. Collections maintain
|
|
36
|
-
* indexes of their models, both in order, and for lookup by `id`.
|
|
37
|
-
*/
|
|
38
|
-
export class Collection extends Collection_base {
|
|
39
|
-
/**
|
|
40
|
-
* Create a new **Collection**, perhaps to contain a specific type of `model`.
|
|
41
|
-
* If a `comparator` is specified, the Collection will maintain
|
|
42
|
-
* its models in sort order, as they're added and removed.
|
|
43
|
-
* @param {Model[]} [models]
|
|
44
|
-
* @param {CollectionOptions} [options]
|
|
45
|
-
*/
|
|
46
|
-
constructor(models?: Model[], options?: CollectionOptions, ...args: any[]);
|
|
47
|
-
_model: any;
|
|
48
|
-
comparator: any;
|
|
49
|
-
/**
|
|
50
|
-
* @param {Storage} storage
|
|
51
|
-
*/
|
|
52
|
-
set browserStorage(storage: Storage);
|
|
53
|
-
/**
|
|
54
|
-
* @returns {Storage} storage
|
|
55
|
-
*/
|
|
56
|
-
get browserStorage(): Storage;
|
|
57
|
-
_browserStorage: import("./storage.js").default;
|
|
58
|
-
/**
|
|
59
|
-
* @param {Model} model
|
|
60
|
-
*/
|
|
61
|
-
set model(model: Model);
|
|
62
|
-
/**
|
|
63
|
-
* The default model for a collection is just a **Model**.
|
|
64
|
-
* This should be overridden in most cases.
|
|
65
|
-
* @returns {typeof Model}
|
|
66
|
-
*/
|
|
67
|
-
get model(): typeof Model;
|
|
68
|
-
get length(): any;
|
|
69
|
-
/**
|
|
70
|
-
* preinitialize is an empty function by default. You can override it with a function
|
|
71
|
-
* or object. preinitialize will run before any instantiation logic is run in the Collection.
|
|
72
|
-
*/
|
|
73
|
-
preinitialize(): void;
|
|
74
|
-
/**
|
|
75
|
-
* Initialize is an empty function by default. Override it with your own
|
|
76
|
-
* initialization logic.
|
|
77
|
-
*/
|
|
78
|
-
initialize(): void;
|
|
79
|
-
/**
|
|
80
|
-
* The JSON representation of a Collection is an array of the
|
|
81
|
-
* models' attributes.
|
|
82
|
-
*@param {Options} options
|
|
83
|
-
*/
|
|
84
|
-
toJSON(options: Options): any;
|
|
85
|
-
/**
|
|
86
|
-
*@param {string} method
|
|
87
|
-
*@param {Model|Collection} model
|
|
88
|
-
*@param {Options} options
|
|
89
|
-
*/
|
|
90
|
-
sync(method: string, model: Model | Collection, options: Options): any;
|
|
91
|
-
/**
|
|
92
|
-
* Add a model, or list of models to the set. `models` may be
|
|
93
|
-
* Models or raw JavaScript objects to be converted to Models, or any
|
|
94
|
-
* combination of the two.
|
|
95
|
-
*@param {Model[]|Model|Attributes|Attributes[]} models
|
|
96
|
-
*@param {Options} options
|
|
97
|
-
*/
|
|
98
|
-
add(models: Model[] | Model | Attributes | Attributes[], options: Options): any;
|
|
99
|
-
/**
|
|
100
|
-
* Remove a model, or a list of models from the set.
|
|
101
|
-
* @param {Model|Model[]} models
|
|
102
|
-
* @param {Options} options
|
|
103
|
-
*/
|
|
104
|
-
remove(models: Model | Model[], options: Options): any;
|
|
105
|
-
/**
|
|
106
|
-
* Update a collection by `set`-ing a new list of models, adding new ones,
|
|
107
|
-
* removing models that are no longer present, and merging models that
|
|
108
|
-
* already exist in the collection, as necessary. Similar to **Model#set**,
|
|
109
|
-
* the core operation for updating the data contained by the collection.
|
|
110
|
-
*@param {Model[]|Model|Attributes|Attributes[]} models
|
|
111
|
-
* @param {Options} options
|
|
112
|
-
*/
|
|
113
|
-
set(models: Model[] | Model | Attributes | Attributes[], options: Options): any;
|
|
114
|
-
clearStore(options?: {}, filter?: (o: any) => any): Promise<void>;
|
|
115
|
-
/**
|
|
116
|
-
* When you have more items than you want to add or remove individually,
|
|
117
|
-
* you can reset the entire set with a new list of models, without firing
|
|
118
|
-
* any granular `add` or `remove` events. Fires `reset` when finished.
|
|
119
|
-
* Useful for bulk operations and optimizations.
|
|
120
|
-
* @param {Model|Model[]} [models]
|
|
121
|
-
* @param {Options} [options]
|
|
122
|
-
*/
|
|
123
|
-
reset(models?: Model | Model[], options?: Options): Model | Model[];
|
|
124
|
-
/**
|
|
125
|
-
* Add a model to the end of the collection.
|
|
126
|
-
* @param {Model} model
|
|
127
|
-
* @param {Options} [options]
|
|
128
|
-
*/
|
|
129
|
-
push(model: Model, options?: Options): any;
|
|
130
|
-
/**
|
|
131
|
-
* Remove a model from the end of the collection.
|
|
132
|
-
* @param {Options} [options]
|
|
133
|
-
*/
|
|
134
|
-
pop(options?: Options): any;
|
|
135
|
-
/**
|
|
136
|
-
* Add a model to the beginning of the collection.
|
|
137
|
-
* @param {Model} model
|
|
138
|
-
* @param {Options} [options]
|
|
139
|
-
*/
|
|
140
|
-
unshift(model: Model, options?: Options): any;
|
|
141
|
-
/**
|
|
142
|
-
* Remove a model from the beginning of the collection.
|
|
143
|
-
* @param {Options} [options]
|
|
144
|
-
*/
|
|
145
|
-
shift(options?: Options): any;
|
|
146
|
-
/** Slice out a sub-array of models from the collection. */
|
|
147
|
-
slice(...args: any[]): any;
|
|
148
|
-
/**
|
|
149
|
-
* @param {Function|Object} callback
|
|
150
|
-
* @param {any} thisArg
|
|
151
|
-
*/
|
|
152
|
-
filter(callback: Function | any, thisArg: any): any;
|
|
153
|
-
/**
|
|
154
|
-
* @param {Function} pred
|
|
155
|
-
*/
|
|
156
|
-
every(pred: Function): any;
|
|
157
|
-
/**
|
|
158
|
-
* @param {Model[]} values
|
|
159
|
-
*/
|
|
160
|
-
difference(values: Model[]): any;
|
|
161
|
-
max(): any;
|
|
162
|
-
min(): any;
|
|
163
|
-
drop(n?: number): any;
|
|
164
|
-
/**
|
|
165
|
-
* @param {Function|Object} pred
|
|
166
|
-
*/
|
|
167
|
-
some(pred: Function | any): any;
|
|
168
|
-
sortBy(iteratee: any): any;
|
|
169
|
-
isEmpty(): boolean;
|
|
170
|
-
keyBy(iteratee: any): any;
|
|
171
|
-
each(callback: any, thisArg: any): any;
|
|
172
|
-
forEach(callback: any, thisArg: any): any;
|
|
173
|
-
includes(item: any): any;
|
|
174
|
-
size(): any;
|
|
175
|
-
countBy(f: any): any;
|
|
176
|
-
groupBy(pred: any): any;
|
|
177
|
-
/**
|
|
178
|
-
* @param {number} fromIndex
|
|
179
|
-
*/
|
|
180
|
-
indexOf(fromIndex: number): any;
|
|
181
|
-
/**
|
|
182
|
-
* @param {Function|string|RegExp} pred
|
|
183
|
-
* @param {number} fromIndex
|
|
184
|
-
*/
|
|
185
|
-
findLastIndex(pred: Function | string | RegExp, fromIndex: number): any;
|
|
186
|
-
/**
|
|
187
|
-
* @param {number} fromIndex
|
|
188
|
-
*/
|
|
189
|
-
lastIndexOf(fromIndex: number): any;
|
|
190
|
-
/**
|
|
191
|
-
* @param {Function|string|RegExp} pred
|
|
192
|
-
*/
|
|
193
|
-
findIndex(pred: Function | string | RegExp): any;
|
|
194
|
-
last(): any;
|
|
195
|
-
head(): any;
|
|
196
|
-
first(): any;
|
|
197
|
-
map(cb: any, thisArg: any): any;
|
|
198
|
-
reduce(callback: any, initialValue: any): any;
|
|
199
|
-
reduceRight(callback: any, initialValue: any): any;
|
|
200
|
-
toArray(): any[];
|
|
201
|
-
/**
|
|
202
|
-
* Get a model from the set by id, cid, model object with id or cid
|
|
203
|
-
* properties, or an attributes object that is transformed through modelId.
|
|
204
|
-
* @param {string|number|Object|Model} obj
|
|
205
|
-
*/
|
|
206
|
-
get(obj: string | number | any | Model): any;
|
|
207
|
-
/**
|
|
208
|
-
* Returns `true` if the model is in the collection.
|
|
209
|
-
* @param {string|number|Object|Model} obj
|
|
210
|
-
*/
|
|
211
|
-
has(obj: string | number | any | Model): boolean;
|
|
212
|
-
/**
|
|
213
|
-
* Get the model at the given index.
|
|
214
|
-
* @param {number} index
|
|
215
|
-
*/
|
|
216
|
-
at(index: number): any;
|
|
217
|
-
/**
|
|
218
|
-
* Return models with matching attributes. Useful for simple cases of
|
|
219
|
-
* `filter`.
|
|
220
|
-
* @param {Attributes} attrs
|
|
221
|
-
* @param {boolean} [first]
|
|
222
|
-
*/
|
|
223
|
-
where(attrs: Attributes, first?: boolean): any;
|
|
224
|
-
/**
|
|
225
|
-
* Return the first model with matching attributes. Useful for simple cases
|
|
226
|
-
* of `find`.
|
|
227
|
-
* @param {Attributes} attrs
|
|
228
|
-
*/
|
|
229
|
-
findWhere(attrs: Attributes): any;
|
|
230
|
-
/**
|
|
231
|
-
* @param {Attributes} predicate
|
|
232
|
-
* @param {number} [fromIndex]
|
|
233
|
-
*/
|
|
234
|
-
find(predicate: Attributes, fromIndex?: number): any;
|
|
235
|
-
/**
|
|
236
|
-
* Force the collection to re-sort itself. You don't need to call this under
|
|
237
|
-
* normal circumstances, as the set will maintain sort order as each item
|
|
238
|
-
* is added.
|
|
239
|
-
* @param {Options} [options]
|
|
240
|
-
*/
|
|
241
|
-
sort(options?: Options): this;
|
|
242
|
-
models: any;
|
|
243
|
-
/**
|
|
244
|
-
* Pluck an attribute from each model in the collection.
|
|
245
|
-
* @param {string} attr
|
|
246
|
-
*/
|
|
247
|
-
pluck(attr: string): any;
|
|
248
|
-
/**
|
|
249
|
-
* Fetch the default set of models for this collection, resetting the
|
|
250
|
-
* collection when they arrive. If `reset: true` is passed, the response
|
|
251
|
-
* data will be passed through the `reset` method instead of `set`.
|
|
252
|
-
* @param {Options} options
|
|
253
|
-
*/
|
|
254
|
-
fetch(options: Options): any;
|
|
255
|
-
/**
|
|
256
|
-
* Create a new instance of a model in this collection. Add the model to the
|
|
257
|
-
* collection immediately, unless `wait: true` is passed, in which case we
|
|
258
|
-
* wait for the server to agree.
|
|
259
|
-
* @param {Model|Attributes} model
|
|
260
|
-
* @param {Options} [options]
|
|
261
|
-
*/
|
|
262
|
-
create(model: Model | Attributes, options?: Options): false | Model | (Promise<any> & {
|
|
263
|
-
isResolved: boolean;
|
|
264
|
-
isPending: boolean;
|
|
265
|
-
isRejected: boolean;
|
|
266
|
-
resolve: Function;
|
|
267
|
-
reject: Function;
|
|
268
|
-
}) | Attributes;
|
|
269
|
-
/**
|
|
270
|
-
* **parse** converts a response into a list of models to be added to the
|
|
271
|
-
* collection. The default implementation is just to pass it through.
|
|
272
|
-
* @param {Object} resp
|
|
273
|
-
* @param {Options} [options]
|
|
274
|
-
*/
|
|
275
|
-
parse(resp: any, options?: Options): any;
|
|
276
|
-
/**
|
|
277
|
-
* Define how to uniquely identify models in the collection.
|
|
278
|
-
* @param {Attributes} attrs
|
|
279
|
-
*/
|
|
280
|
-
modelId(attrs: Attributes): any;
|
|
281
|
-
/** Get an iterator of all models in this collection. */
|
|
282
|
-
values(): CollectionIterator;
|
|
283
|
-
/** Get an iterator of all model IDs in this collection. */
|
|
284
|
-
keys(): CollectionIterator;
|
|
285
|
-
/** Get an iterator of all [ID, model] tuples in this collection. */
|
|
286
|
-
entries(): CollectionIterator;
|
|
287
|
-
/**
|
|
288
|
-
* Private method to reset all internal state. Called when the collection
|
|
289
|
-
* is first initialized or reset.
|
|
290
|
-
*/
|
|
291
|
-
_reset(): void;
|
|
292
|
-
_byId: {};
|
|
293
|
-
/**
|
|
294
|
-
* @param {Attributes} attrs
|
|
295
|
-
* @param {Options} [options]
|
|
296
|
-
*/
|
|
297
|
-
createModel(attrs: Attributes, options?: Options): Model;
|
|
298
|
-
/**
|
|
299
|
-
* Prepare a hash of attributes (or other model) to be added to this
|
|
300
|
-
* collection.
|
|
301
|
-
* @param {Attributes|Model} attrs
|
|
302
|
-
* @param {Options} [options]
|
|
303
|
-
* @return {Model}
|
|
304
|
-
*/
|
|
305
|
-
_prepareModel(attrs: Attributes | Model, options?: Options): Model;
|
|
306
|
-
/**
|
|
307
|
-
* Internal method called by both remove and set.
|
|
308
|
-
* @param {Model[]} models
|
|
309
|
-
* @param {Options} [options]
|
|
310
|
-
*/
|
|
311
|
-
_removeModels(models: Model[], options?: Options): any[];
|
|
312
|
-
/**
|
|
313
|
-
* Method for checking whether an object should be considered a model for
|
|
314
|
-
* the purposes of adding to the collection.
|
|
315
|
-
* @param {any} model
|
|
316
|
-
*/
|
|
317
|
-
_isModel(model: any): model is Model;
|
|
318
|
-
/**
|
|
319
|
-
* Internal method to create a model's ties to a collection.
|
|
320
|
-
* @param {Model} model
|
|
321
|
-
* @param {Options} [options]
|
|
322
|
-
*/
|
|
323
|
-
_addReference(model: Model, options?: Options): void;
|
|
324
|
-
/**
|
|
325
|
-
* Internal method to sever a model's ties to a collection.
|
|
326
|
-
* @private
|
|
327
|
-
* @param {Model} model
|
|
328
|
-
* @param {Options} [options]
|
|
329
|
-
*/
|
|
330
|
-
private _removeReference;
|
|
331
|
-
/**
|
|
332
|
-
* Internal method called every time a model in the set fires an event.
|
|
333
|
-
* Sets need to update their indexes when models change ids. All other
|
|
334
|
-
* events simply proxy through. "add" and "remove" events that originate
|
|
335
|
-
* in other collections are ignored.
|
|
336
|
-
* @private
|
|
337
|
-
* @param {any} event
|
|
338
|
-
* @param {Model} model
|
|
339
|
-
* @param {Collection} collection
|
|
340
|
-
* @param {Options} [options]
|
|
341
|
-
*/
|
|
342
|
-
private _onModelEvent;
|
|
343
|
-
[Symbol.iterator]: () => CollectionIterator;
|
|
344
|
-
}
|
|
345
|
-
import { Model } from './model.js';
|
|
346
|
-
declare class CollectionIterator {
|
|
347
|
-
/**
|
|
348
|
-
* A CollectionIterator implements JavaScript's Iterator protocol, allowing the
|
|
349
|
-
* use of `for of` loops in modern browsers and interoperation between
|
|
350
|
-
* Collection and other JavaScript functions and third-party libraries
|
|
351
|
-
* which can operate on Iterables.
|
|
352
|
-
* @param {Collection} collection
|
|
353
|
-
* @param {Number} kind
|
|
354
|
-
*/
|
|
355
|
-
constructor(collection: Collection, kind: number);
|
|
356
|
-
_collection: Collection;
|
|
357
|
-
_kind: number;
|
|
358
|
-
_index: number;
|
|
359
|
-
next(): {
|
|
360
|
-
value: any;
|
|
361
|
-
done: boolean;
|
|
362
|
-
};
|
|
363
|
-
[Symbol.iterator](): this;
|
|
364
|
-
}
|
|
365
|
-
export {};
|
|
366
|
-
//# sourceMappingURL=collection.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../collection.js"],"names":[],"mappings":"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"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export default sessionStorageWrapper;
|
|
2
|
-
declare namespace sessionStorageWrapper {
|
|
3
|
-
export let _driver: string;
|
|
4
|
-
export { _initStorage };
|
|
5
|
-
export let _support: boolean;
|
|
6
|
-
export { iterate };
|
|
7
|
-
export { getItem };
|
|
8
|
-
export { setItem };
|
|
9
|
-
export { removeItem };
|
|
10
|
-
export { clear };
|
|
11
|
-
export { length };
|
|
12
|
-
export { key };
|
|
13
|
-
export { keys };
|
|
14
|
-
export { dropInstance };
|
|
15
|
-
}
|
|
16
|
-
declare function _initStorage(options: any): void;
|
|
17
|
-
declare function iterate(iterator: any, callback: any): any;
|
|
18
|
-
declare function getItem(key: any, callback: any): any;
|
|
19
|
-
/**
|
|
20
|
-
* Set a key's value and run an optional callback once the value is set.
|
|
21
|
-
* Unlike Gaia's implementation, the callback function is passed the value,
|
|
22
|
-
* in case you want to operate on that value only after you're sure it
|
|
23
|
-
* saved, or something like that.
|
|
24
|
-
* @template T
|
|
25
|
-
* @param {string} key - The key under which the value is stored.
|
|
26
|
-
* @param {T} value - The value to be stored, can be of any type.
|
|
27
|
-
* @param {(err: any, value: T) => void} [callback] - Optional callback function to be called after the value is set.
|
|
28
|
-
* @returns {Promise<T>}
|
|
29
|
-
*/
|
|
30
|
-
declare function setItem<T>(key: string, value: T, callback?: (err: any, value: T) => void): Promise<T>;
|
|
31
|
-
declare function removeItem(key: any, callback: any): any;
|
|
32
|
-
declare function clear(callback: any): any;
|
|
33
|
-
declare function length(callback: any): any;
|
|
34
|
-
declare function key(n: any, callback: any): any;
|
|
35
|
-
declare function keys(callback: any): any;
|
|
36
|
-
declare function dropInstance(options: any, callback: any, ...args: any[]): Promise<void>;
|
|
37
|
-
//# sourceMappingURL=sessionStorage.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sessionStorage.d.ts","sourceRoot":"","sources":["../../drivers/sessionStorage.js"],"names":[],"mappings":";;;;;;;;;;;;;;;AA0DA,kDAQC;AA2CD,4DA0CC;AA7DD,uDAgBC;AA8GD;;;;;;;;;;GAUG;AACH,yBANa,CAAC,OACH,MAAM,SACN,CAAC,aACD,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI,GAC1B,OAAO,CAAC,CAAC,CAAC,CA+BtB;AAjDD,0DAOC;AAhJD,2CAeC;AA+GD,4CAQC;AAlDD,iDAoBC;AAED,0CAiBC;AAiED,0FAiCC"}
|