@converse/skeletor 0.0.4 → 0.0.7
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 +70 -7
- package/dist/skeletor.js +163 -161
- package/dist/skeletor.js.map +1 -1
- package/dist/skeletor.min.js +2 -2
- package/dist/skeletor.min.js.map +1 -1
- package/package.json +7 -6
- package/src/collection.js +1 -1
- package/src/drivers/indexeddb-getitems.js~ +1116 -0
- package/src/drivers/indexeddb.js~ +1115 -0
- package/src/storage.js +11 -8
- package/src/storage.js~ +13 -9
- package/CHANGES.md +0 -31
- package/src/.events.js.swp +0 -0
- package/src/.helpers.js.swp +0 -0
- package/src/.history.js.swp +0 -0
- package/src/.model.js.swp +0 -0
- package/src/.overview.js.swp +0 -0
- package/src/.router.js.swp +0 -0
- package/src/.view.js.swp +0 -0
- package/src/collection.js~ +0 -737
- package/src/drivers/.sessionStorage.js.swp +0 -0
- package/src/drivers/sessionStorage.js~ +0 -316
- package/src/element-overview.js~ +0 -4
- package/src/element.js~ +0 -188
- package/src/events.js~ +0 -334
- package/src/helpers.js~ +0 -151
- package/src/history.js~ +0 -301
- package/src/htmlview.js~ +0 -14
- package/src/model.js~ +0 -439
- package/src/orderedlist.js~ +0 -88
- package/src/overview.js~ +0 -111
- package/src/router.js~ +0 -119
- package/src/vdomview.js~ +0 -15
- package/src/view.js~ +0 -267
package/src/history.js~
DELETED
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
// Backbone.js 1.4.0
|
|
2
|
-
// (c) 2010-2019 Jeremy Ashkenas and DocumentCloud
|
|
3
|
-
// Backbone may be freely distributed under the MIT license.
|
|
4
|
-
|
|
5
|
-
import extend from 'lodash-es/extend';
|
|
6
|
-
import some from 'lodash-es/some';
|
|
7
|
-
import { Events } from './events.js';
|
|
8
|
-
import { inherits } from './helpers.js';
|
|
9
|
-
|
|
10
|
-
// History
|
|
11
|
-
// -------
|
|
12
|
-
|
|
13
|
-
// Handles cross-browser history management, based on either
|
|
14
|
-
// [pushState](http://diveintohtml5.info/history.html) and real URLs, or
|
|
15
|
-
// [onhashchange](https://developer.mozilla.org/en-US/docs/DOM/window.onhashchange)
|
|
16
|
-
// and URL fragments. If the browser supports neither (old IE, natch),
|
|
17
|
-
// falls back to polling.
|
|
18
|
-
const History = function() {
|
|
19
|
-
this.handlers = [];
|
|
20
|
-
this.checkUrl = this.checkUrl.bind(this);
|
|
21
|
-
|
|
22
|
-
// Ensure that `History` can be used outside of the browser.
|
|
23
|
-
if (typeof window !== 'undefined') {
|
|
24
|
-
this.location = window.location;
|
|
25
|
-
this.history = window.history;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
History.extend = inherits;
|
|
30
|
-
|
|
31
|
-
// Cached regex for stripping a leading hash/slash and trailing space.
|
|
32
|
-
const routeStripper = /^[#\/]|\s+$/g;
|
|
33
|
-
// Cached regex for stripping leading and trailing slashes.
|
|
34
|
-
const rootStripper = /^\/+|\/+$/g;
|
|
35
|
-
// Cached regex for stripping urls of hash.
|
|
36
|
-
const pathStripper = /#.*$/;
|
|
37
|
-
|
|
38
|
-
// Has the history handling already been started?
|
|
39
|
-
History.started = false;
|
|
40
|
-
|
|
41
|
-
// Set up all inheritable **History** properties and methods.
|
|
42
|
-
Object.assign(History.prototype, Events, {
|
|
43
|
-
|
|
44
|
-
// The default interval to poll for hash changes, if necessary, is
|
|
45
|
-
// twenty times a second.
|
|
46
|
-
interval: 50,
|
|
47
|
-
|
|
48
|
-
// Are we at the app root?
|
|
49
|
-
atRoot: function() {
|
|
50
|
-
const path = this.location.pathname.replace(/[^\/]$/, '$&/');
|
|
51
|
-
return path === this.root && !this.getSearch();
|
|
52
|
-
},
|
|
53
|
-
|
|
54
|
-
// Does the pathname match the root?
|
|
55
|
-
matchRoot: function() {
|
|
56
|
-
const path = this.decodeFragment(this.location.pathname);
|
|
57
|
-
const rootPath = path.slice(0, this.root.length - 1) + '/';
|
|
58
|
-
return rootPath === this.root;
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
// Unicode characters in `location.pathname` are percent encoded so they're
|
|
62
|
-
// decoded for comparison. `%25` should not be decoded since it may be part
|
|
63
|
-
// of an encoded parameter.
|
|
64
|
-
decodeFragment: function(fragment) {
|
|
65
|
-
return decodeURI(fragment.replace(/%25/g, '%2525'));
|
|
66
|
-
},
|
|
67
|
-
|
|
68
|
-
// In IE6, the hash fragment and search params are incorrect if the
|
|
69
|
-
// fragment contains `?`.
|
|
70
|
-
getSearch: function() {
|
|
71
|
-
const match = this.location.href.replace(/#.*/, '').match(/\?.+/);
|
|
72
|
-
return match ? match[0] : '';
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// Gets the true hash value. Cannot use location.hash directly due to bug
|
|
76
|
-
// in Firefox where location.hash will always be decoded.
|
|
77
|
-
getHash: function(window) {
|
|
78
|
-
const match = (window || this).location.href.match(/#(.*)$/);
|
|
79
|
-
return match ? match[1] : '';
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
// Get the pathname and search params, without the root.
|
|
83
|
-
getPath: function() {
|
|
84
|
-
const path = this.decodeFragment(
|
|
85
|
-
this.location.pathname + this.getSearch()
|
|
86
|
-
).slice(this.root.length - 1);
|
|
87
|
-
return path.charAt(0) === '/' ? path.slice(1) : path;
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
// Get the cross-browser normalized URL fragment from the path or hash.
|
|
91
|
-
getFragment: function(fragment) {
|
|
92
|
-
if (fragment == null) {
|
|
93
|
-
if (this._usePushState || !this._wantsHashChange) {
|
|
94
|
-
fragment = this.getPath();
|
|
95
|
-
} else {
|
|
96
|
-
fragment = this.getHash();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return fragment.replace(routeStripper, '');
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
// Start the hash change handling, returning `true` if the current URL matches
|
|
103
|
-
// an existing route, and `false` otherwise.
|
|
104
|
-
start: function(options) {
|
|
105
|
-
if (History.started) throw new Error('history has already been started');
|
|
106
|
-
History.started = true;
|
|
107
|
-
|
|
108
|
-
// Figure out the initial configuration. Do we need an iframe?
|
|
109
|
-
// Is pushState desired ... is it available?
|
|
110
|
-
this.options = extend({root: '/'}, this.options, options);
|
|
111
|
-
this.root = this.options.root;
|
|
112
|
-
this._wantsHashChange = this.options.hashChange !== false;
|
|
113
|
-
this._hasHashChange = 'onhashchange' in window && (document.documentMode === undefined|| document.documentMode > 7);
|
|
114
|
-
this._useHashChange = this._wantsHashChange && this._hasHashChange;
|
|
115
|
-
this._wantsPushState = !!this.options.pushState;
|
|
116
|
-
this._hasPushState = !!(this.history && this.history.pushState);
|
|
117
|
-
this._usePushState = this._wantsPushState && this._hasPushState;
|
|
118
|
-
this.fragment = this.getFragment();
|
|
119
|
-
|
|
120
|
-
// Normalize root to always include a leading and trailing slash.
|
|
121
|
-
this.root = ('/' + this.root + '/').replace(rootStripper, '/');
|
|
122
|
-
|
|
123
|
-
// Transition from hashChange to pushState or vice versa if both are
|
|
124
|
-
// requested.
|
|
125
|
-
if (this._wantsHashChange && this._wantsPushState) {
|
|
126
|
-
|
|
127
|
-
// If we've started off with a route from a `pushState`-enabled
|
|
128
|
-
// browser, but we're currently in a browser that doesn't support it...
|
|
129
|
-
if (!this._hasPushState && !this.atRoot()) {
|
|
130
|
-
const rootPath = this.root.slice(0, -1) || '/';
|
|
131
|
-
this.location.replace(rootPath + '#' + this.getPath());
|
|
132
|
-
// Return immediately as browser will do redirect to new url
|
|
133
|
-
return true;
|
|
134
|
-
|
|
135
|
-
// Or if we've started out with a hash-based route, but we're currently
|
|
136
|
-
// in a browser where it could be `pushState`-based instead...
|
|
137
|
-
} else if (this._hasPushState && this.atRoot()) {
|
|
138
|
-
this.navigate(this.getHash(), {replace: true});
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Proxy an iframe to handle location events if the browser doesn't
|
|
144
|
-
// support the `hashchange` event, HTML5 history, or the user wants
|
|
145
|
-
// `hashChange` but not `pushState`.
|
|
146
|
-
if (!this._hasHashChange && this._wantsHashChange && !this._usePushState) {
|
|
147
|
-
this.iframe = document.createElement('iframe');
|
|
148
|
-
this.iframe.src = 'javascript:0';
|
|
149
|
-
this.iframe.style.display = 'none';
|
|
150
|
-
this.iframe.tabIndex = -1;
|
|
151
|
-
const body = document.body;
|
|
152
|
-
// Using `appendChild` will throw on IE < 9 if the document is not ready.
|
|
153
|
-
const iWindow = body.insertBefore(this.iframe, body.firstChild).contentWindow;
|
|
154
|
-
iWindow.document.open();
|
|
155
|
-
iWindow.document.close();
|
|
156
|
-
iWindow.location.hash = '#' + this.fragment;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
// Depending on whether we're using pushState or hashes, and whether
|
|
160
|
-
// 'onhashchange' is supported, determine how we check the URL state.
|
|
161
|
-
if (this._usePushState) {
|
|
162
|
-
addEventListener('popstate', this.checkUrl, false);
|
|
163
|
-
} else if (this._useHashChange && !this.iframe) {
|
|
164
|
-
addEventListener('hashchange', this.checkUrl, false);
|
|
165
|
-
} else if (this._wantsHashChange) {
|
|
166
|
-
this._checkUrlInterval = setInterval(this.checkUrl, this.interval);
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
if (!this.options.silent) return this.loadUrl();
|
|
170
|
-
},
|
|
171
|
-
|
|
172
|
-
// Disable history, perhaps temporarily. Not useful in a real app,
|
|
173
|
-
// but possibly useful for unit testing Routers.
|
|
174
|
-
stop: function() {
|
|
175
|
-
// Remove window listeners.
|
|
176
|
-
if (this._usePushState) {
|
|
177
|
-
removeEventListener('popstate', this.checkUrl, false);
|
|
178
|
-
} else if (this._useHashChange && !this.iframe) {
|
|
179
|
-
removeEventListener('hashchange', this.checkUrl, false);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// Clean up the iframe if necessary.
|
|
183
|
-
if (this.iframe) {
|
|
184
|
-
document.body.removeChild(this.iframe);
|
|
185
|
-
this.iframe = null;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
// Some environments will throw when clearing an undefined interval.
|
|
189
|
-
if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
|
|
190
|
-
History.started = false;
|
|
191
|
-
},
|
|
192
|
-
|
|
193
|
-
// Add a route to be tested when the fragment changes. Routes added later
|
|
194
|
-
// may override previous routes.
|
|
195
|
-
route: function(route, callback) {
|
|
196
|
-
this.handlers.unshift({route: route, callback: callback});
|
|
197
|
-
},
|
|
198
|
-
|
|
199
|
-
// Checks the current URL to see if it has changed, and if it has,
|
|
200
|
-
// calls `loadUrl`, normalizing across the hidden iframe.
|
|
201
|
-
checkUrl: function(e) {
|
|
202
|
-
let current = this.getFragment();
|
|
203
|
-
|
|
204
|
-
// If the user pressed the back button, the iframe's hash will have
|
|
205
|
-
// changed and we should use that for comparison.
|
|
206
|
-
if (current === this.fragment && this.iframe) {
|
|
207
|
-
current = this.getHash(this.iframe.contentWindow);
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
if (current === this.fragment) return false;
|
|
211
|
-
if (this.iframe) this.navigate(current);
|
|
212
|
-
this.loadUrl();
|
|
213
|
-
},
|
|
214
|
-
|
|
215
|
-
// Attempt to load the current URL fragment. If a route succeeds with a
|
|
216
|
-
// match, returns `true`. If no defined routes matches the fragment,
|
|
217
|
-
// returns `false`.
|
|
218
|
-
loadUrl: function(fragment) {
|
|
219
|
-
// If the root doesn't match, no routes can match either.
|
|
220
|
-
if (!this.matchRoot()) return false;
|
|
221
|
-
fragment = this.fragment = this.getFragment(fragment);
|
|
222
|
-
return some(this.handlers, function(handler) {
|
|
223
|
-
if (handler.route.test(fragment)) {
|
|
224
|
-
handler.callback(fragment);
|
|
225
|
-
return true;
|
|
226
|
-
}
|
|
227
|
-
});
|
|
228
|
-
},
|
|
229
|
-
|
|
230
|
-
// Save a fragment into the hash history, or replace the URL state if the
|
|
231
|
-
// 'replace' option is passed. You are responsible for properly URL-encoding
|
|
232
|
-
// the fragment in advance.
|
|
233
|
-
//
|
|
234
|
-
// The options object can contain `trigger: true` if you wish to have the
|
|
235
|
-
// route callback be fired (not usually desirable), or `replace: true`, if
|
|
236
|
-
// you wish to modify the current URL without adding an entry to the history.
|
|
237
|
-
navigate: function(fragment, options) {
|
|
238
|
-
if (!History.started) return false;
|
|
239
|
-
if (!options || options === true) options = {trigger: !!options};
|
|
240
|
-
|
|
241
|
-
// Normalize the fragment.
|
|
242
|
-
fragment = this.getFragment(fragment || '');
|
|
243
|
-
|
|
244
|
-
// Don't include a trailing slash on the root.
|
|
245
|
-
let rootPath = this.root;
|
|
246
|
-
if (fragment === '' || fragment.charAt(0) === '?') {
|
|
247
|
-
rootPath = rootPath.slice(0, -1) || '/';
|
|
248
|
-
}
|
|
249
|
-
const url = rootPath + fragment;
|
|
250
|
-
|
|
251
|
-
// Strip the fragment of the query and hash for matching.
|
|
252
|
-
fragment = fragment.replace(pathStripper, '');
|
|
253
|
-
|
|
254
|
-
// Decode for matching.
|
|
255
|
-
const decodedFragment = this.decodeFragment(fragment);
|
|
256
|
-
|
|
257
|
-
if (this.fragment === decodedFragment) return;
|
|
258
|
-
this.fragment = decodedFragment;
|
|
259
|
-
|
|
260
|
-
// If pushState is available, we use it to set the fragment as a real URL.
|
|
261
|
-
if (this._usePushState) {
|
|
262
|
-
this.history[options.replace ? 'replaceState' : 'pushState']({}, document.title, url);
|
|
263
|
-
|
|
264
|
-
// If hash changes haven't been explicitly disabled, update the hash
|
|
265
|
-
// fragment to store history.
|
|
266
|
-
} else if (this._wantsHashChange) {
|
|
267
|
-
this._updateHash(this.location, fragment, options.replace);
|
|
268
|
-
if (this.iframe && fragment !== this.getHash(this.iframe.contentWindow)) {
|
|
269
|
-
const iWindow = this.iframe.contentWindow;
|
|
270
|
-
|
|
271
|
-
// Opening and closing the iframe tricks IE7 and earlier to push a
|
|
272
|
-
// history entry on hash-tag change. When replace is true, we don't
|
|
273
|
-
// want this.
|
|
274
|
-
if (!options.replace) {
|
|
275
|
-
iWindow.document.open();
|
|
276
|
-
iWindow.document.close();
|
|
277
|
-
}
|
|
278
|
-
this._updateHash(iWindow.location, fragment, options.replace);
|
|
279
|
-
}
|
|
280
|
-
// If you've told us that you explicitly don't want fallback hashchange-
|
|
281
|
-
// based history, then `navigate` becomes a page refresh.
|
|
282
|
-
} else {
|
|
283
|
-
return this.location.assign(url);
|
|
284
|
-
}
|
|
285
|
-
if (options.trigger) return this.loadUrl(fragment);
|
|
286
|
-
},
|
|
287
|
-
|
|
288
|
-
// Update the hash location, either replacing the current entry, or adding
|
|
289
|
-
// a new one to the browser history.
|
|
290
|
-
_updateHash: function(location, fragment, replace) {
|
|
291
|
-
if (replace) {
|
|
292
|
-
const href = location.href.replace(/(javascript:|#).*$/, '');
|
|
293
|
-
location.replace(href + '#' + fragment);
|
|
294
|
-
} else {
|
|
295
|
-
// Some browsers require that `hash` contains a leading #.
|
|
296
|
-
location.hash = '#' + fragment;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
export default History;
|
package/src/htmlview.js~
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { isFunction } from "lodash";
|
|
2
|
-
import { View } from "./view";
|
|
3
|
-
import { render } from 'lit-html';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export const HTMLView = View.extend({
|
|
7
|
-
|
|
8
|
-
render () {
|
|
9
|
-
isFunction(this.beforeRender) && this.beforeRender();
|
|
10
|
-
render(this.toHTML(), this.el);
|
|
11
|
-
isFunction(this.afterRender) && this.afterRender();
|
|
12
|
-
return this;
|
|
13
|
-
}
|
|
14
|
-
});
|