@converse/skeletor 0.0.8 → 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 +21 -92
- package/dist/skeletor.d.ts +764 -0
- package/dist/skeletor.js +10206 -6249
- package/dist/skeletor.min.js +72 -6
- package/package.json +59 -33
- package/src/collection.ts +846 -0
- package/src/drivers/sessionStorage.ts +297 -0
- package/src/eventemitter.ts +172 -0
- package/src/helpers.ts +179 -0
- package/src/index.ts +84 -0
- package/src/listening.ts +86 -0
- package/src/model.ts +520 -0
- package/src/storage.ts +293 -0
- package/src/types.ts +189 -0
- package/src/utils/events.ts +224 -0
- package/dist/skeletor.js.map +0 -1
- package/dist/skeletor.min.js.map +0 -1
- package/src/collection.js +0 -740
- package/src/drivers/sessionStorage.js +0 -306
- package/src/drivers/sessionStorage.js~ +0 -307
- package/src/element.js +0 -188
- package/src/events.js +0 -328
- package/src/helpers.js +0 -167
- package/src/history.js +0 -301
- package/src/main.js +0 -43
- package/src/model.js +0 -437
- package/src/overview.js +0 -191
- package/src/router.js +0 -119
- package/src/storage.js +0 -258
- package/src/view.js +0 -267
package/README.md
CHANGED
|
@@ -1,66 +1,47 @@
|
|
|
1
1
|
# Skeletor
|
|
2
2
|
|
|
3
3
|
[](https://inverse.chat/#converse/room?jid=discuss@conference.conversejs.org)
|
|
4
|
-
[](https://github.com/conversejs/skeletor/actions/workflows/karma-tests.yml)
|
|
5
5
|
|
|
6
|
-
Skeletor is a [Backbone](http://backbonejs.org)
|
|
6
|
+
Skeletor is a modernization of [Backbone](http://backbonejs.org)'s Models and Collections, which are used for managing state.
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Installation
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
updates only the changed parts of the DOM, similarly to basically all modern
|
|
14
|
-
JavaScript frameworks.
|
|
15
|
-
|
|
16
|
-
The original Backbone Views aren't components can't be rendered in a nested and
|
|
17
|
-
declarative way. Instead, it's up to you to manually make sure that these views
|
|
18
|
-
are rendered in the correct place in the DOM. This approach becomes unwieldy,
|
|
19
|
-
difficult and fragile as your site becomes larger and more complex.
|
|
20
|
-
|
|
21
|
-
Skeletor solves this by creating a new type of View, called `ElementView`,
|
|
22
|
-
which is very similar to the original Backbone `View` but which is also a web
|
|
23
|
-
component that gets instantiated automatically as soon as its rendered in the
|
|
24
|
-
DOM.
|
|
25
|
-
|
|
26
|
-
## Why bother?
|
|
27
|
-
|
|
28
|
-
The goal of this fork is to allow the Converse team to gradually update the [Converse](https://conversejs.org)
|
|
29
|
-
XMPP webchat client to use web components (using [LitElement](https://lit-element.polymer-project.org/))
|
|
30
|
-
without requiring us to put everything on hold in order to do a massive rewrite.
|
|
10
|
+
```
|
|
11
|
+
npm install @converse/skeletor
|
|
12
|
+
```
|
|
31
13
|
|
|
32
|
-
|
|
14
|
+
## Changes from Backbone
|
|
33
15
|
|
|
34
|
-
We
|
|
35
|
-
(more accurately, "custom elements"), this allows us to declaratively render the
|
|
36
|
-
UI, while we're progressively getting rid of the views.
|
|
16
|
+
We've made big, backwards incompatible changes in version 1.0.0:
|
|
37
17
|
|
|
38
|
-
|
|
18
|
+
- Removed the old `View`
|
|
19
|
+
- Removed the old `Events` constructor function and instead added the `EventsEmitter` mixin class.
|
|
20
|
+
- Removed the `Router` and `History` classes.
|
|
21
|
+
- All other types (e.g. `Model`, `Collection`) are now ES6 classes.
|
|
39
22
|
|
|
40
|
-
|
|
23
|
+
### Sekeletor adds the following changes to Backbone
|
|
41
24
|
|
|
25
|
+
* Rewritten in TypeScript
|
|
42
26
|
* Removes the dependency on jQuery
|
|
43
|
-
* Instead of the `render` method Views can have a `toHTML` method which must return a [lit-html](https://lit-html.polymer-project.org/) `TemplateResult`.
|
|
44
27
|
* Replaces [underscore](http://underscorejs.org) with [lodash](https://lodash.com)
|
|
45
28
|
* Imports lodash methods individually to allow for tree-shaking
|
|
46
29
|
* Uses the native browser API instead of lodash whereever possible
|
|
47
30
|
* Drops support for older browsers (including IE) and uses ES6+ language features
|
|
48
|
-
* Splits models
|
|
31
|
+
* Splits models and collections into separate modules
|
|
49
32
|
* Adds the possibility to returns promises for asynchronous operations
|
|
50
|
-
* Adds a new `ElementView` class, which is a like a Backbone View, but doubles
|
|
51
|
-
as an instance of HTMLElement and can be used to register a custom element or
|
|
52
|
-
web-component.
|
|
53
33
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
### Backwards incompatible changes
|
|
34
|
+
### Other backwards incompatible changes
|
|
57
35
|
|
|
58
36
|
* Collection.prototype.forEach no longer returns the items being iterated over.
|
|
59
37
|
If you need that, use `map` instead.
|
|
60
|
-
* The `chain`
|
|
38
|
+
* The `chain`, `clone` and `escape` methods on Models have been removed.
|
|
39
|
+
* The `clone` method has also been removed from Collections
|
|
61
40
|
* The `inject`, `foldl` and `foldr` methods on Collections has been removed. You can use `reduce` instead.
|
|
62
41
|
* Removed the `sample`, `take`, `tail` and `initial` method on Collections.
|
|
63
42
|
* Removed the `without`, `reject` and `select` methods on Collections, use `filter`.
|
|
43
|
+
* Removed the `.extend()` method on `Model` and `Collection`.
|
|
44
|
+
* Models and Collections should be defined via `class .. extends` syntax.
|
|
64
45
|
|
|
65
46
|
#### Changes due to using Lodash instead of Underscore
|
|
66
47
|
|
|
@@ -70,56 +51,4 @@ UI, while we're progressively getting rid of the views.
|
|
|
70
51
|
4. Use `includes` instead of `contains`
|
|
71
52
|
5. The `partition` and `invokeMap` methods have been removed.
|
|
72
53
|
|
|
73
|
-
 {
|
|
100
|
-
this.model = new Model({ count: 0 });
|
|
101
|
-
this.listenTo(this.model, 'change', this.render)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
render () {
|
|
105
|
-
return render(html`<button class="button">I've been clicked ${model.get('count')} times!</button>`, this);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
onButtonClicked () {
|
|
109
|
-
this.model.save('count', this.model.get('count')+1);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
CustomElementRegistry.define('my-custom-button', MyCustomButton);
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
You can now put your custom element in the DOM, and once the DOM is loaded by
|
|
117
|
-
the browser, your ElementView will automatically be instantiated and
|
|
118
|
-
`initialize` will be called.
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
```html
|
|
122
|
-
<div>
|
|
123
|
-
<my-custom-button></my-custom-button>
|
|
124
|
-
</div>
|
|
125
|
-
```
|
|
54
|
+

|