@converse/skeletor 0.0.9 → 2.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.
Files changed (39) hide show
  1. package/README.md +5 -89
  2. package/dist/skeletor.d.ts +764 -0
  3. package/dist/skeletor.js +7568 -7747
  4. package/dist/skeletor.min.js +6 -11
  5. package/package.json +46 -30
  6. package/src/{collection.js → collection.ts} +232 -271
  7. package/src/drivers/{sessionStorage.js → sessionStorage.ts} +81 -93
  8. package/src/{eventemitter.js → eventemitter.ts} +44 -59
  9. package/src/{helpers.js → helpers.ts} +56 -69
  10. package/src/index.ts +84 -0
  11. package/src/{listening.js → listening.ts} +32 -27
  12. package/src/{model.js → model.ts} +143 -162
  13. package/src/{storage.js → storage.ts} +92 -49
  14. package/src/types.ts +189 -0
  15. package/src/utils/{events.js → events.ts} +98 -48
  16. package/dist/skeletor.js.map +0 -1
  17. package/dist/skeletor.min.js.map +0 -1
  18. package/src/element.js +0 -238
  19. package/src/index.js +0 -47
  20. package/src/types/collection.d.ts +0 -366
  21. package/src/types/collection.d.ts.map +0 -1
  22. package/src/types/drivers/sessionStorage.d.ts +0 -37
  23. package/src/types/drivers/sessionStorage.d.ts.map +0 -1
  24. package/src/types/element.d.ts +0 -115
  25. package/src/types/element.d.ts.map +0 -1
  26. package/src/types/eventemitter.d.ts +0 -93
  27. package/src/types/eventemitter.d.ts.map +0 -1
  28. package/src/types/helpers.d.ts +0 -62
  29. package/src/types/helpers.d.ts.map +0 -1
  30. package/src/types/index.d.ts +0 -19
  31. package/src/types/index.d.ts.map +0 -1
  32. package/src/types/listening.d.ts +0 -40
  33. package/src/types/listening.d.ts.map +0 -1
  34. package/src/types/model.d.ts +0 -230
  35. package/src/types/model.d.ts.map +0 -1
  36. package/src/types/storage.d.ts +0 -35
  37. package/src/types/storage.d.ts.map +0 -1
  38. package/src/types/utils/events.d.ts +0 -28
  39. package/src/types/utils/events.d.ts.map +0 -1
package/README.md CHANGED
@@ -3,35 +3,7 @@
3
3
  [![XMPP Chat](https://conference.conversejs.org/muc_badge/discuss@conference.conversejs.org)](https://inverse.chat/#converse/room?jid=discuss@conference.conversejs.org)
4
4
  [![CI Tests](https://github.com/conversejs/skeletor/actions/workflows/karma-tests.yml/badge.svg)](https://github.com/conversejs/skeletor/actions/workflows/karma-tests.yml)
5
5
 
6
- Skeletor is a modernization of [Backbone](http://backbonejs.org)'s Models and Collections,
7
- while getting rid of the old Views.
8
-
9
- It provides you with a more modern Backbone-like way to manage state.
10
-
11
- ## Introduction
12
-
13
- The original goal of Skeletor was to modernize Backbone to allow writing
14
- declarative view code instead of the imperative code (e.g. manually adding and
15
- removing DOM nodes). In other words, to allow for component-based code that
16
- automatically updates only the changed parts of the DOM, similarly to basically
17
- all modern JavaScript frameworks.
18
-
19
- The original Backbone Views aren't components and can't be rendered in a nested and
20
- declarative way. Instead, it's up to you to manually make sure that these views
21
- are rendered in the correct place in the DOM. This approach becomes unwieldy,
22
- difficult and fragile as your site becomes larger and more complex.
23
-
24
- Skeletor solves this by creating a new type of View, called `ElementView`,
25
- which is very similar to the original Backbone `View` but which is also a web
26
- component that gets instantiated automatically as soon as its rendered in the
27
- DOM.
28
-
29
- The thing is, [Lit](https://lit.dev) Elements already provide anything one
30
- might need for a modern Backbone-line application. There's not really a need
31
- for the `ElementView` anymore, except to provide an upgrade path from a
32
- Backbone app to one that uses web components. It'll therefore likely be removed
33
- entirely in a future version, thereby leaving only Models and Collections, for
34
- managing state.
6
+ Skeletor is a modernization of [Backbone](http://backbonejs.org)'s Models and Collections, which are used for managing state.
35
7
 
36
8
  ## Installation
37
9
 
@@ -41,16 +13,16 @@ npm install @converse/skeletor
41
13
 
42
14
  ## Changes from Backbone
43
15
 
44
- We've made big, backwards incompatible changes in version 2:
16
+ We've made big, backwards incompatible changes in version 1.0.0:
45
17
 
46
- - Removed the old `View` type
18
+ - Removed the old `View`
47
19
  - Removed the old `Events` constructor function and instead added the `EventsEmitter` mixin class.
48
20
  - Removed the `Router` and `History` classes.
49
- - All other types (`Model`, `Collection`, `ElementView`) are now ES6 classes.
21
+ - All other types (e.g. `Model`, `Collection`) are now ES6 classes.
50
22
 
51
23
  ### Sekeletor adds the following changes to Backbone
52
24
 
53
- * Added TypeScript type declarations (generated from typed JSDoc comments)
25
+ * Rewritten in TypeScript
54
26
  * Removes the dependency on jQuery
55
27
  * Replaces [underscore](http://underscorejs.org) with [lodash](https://lodash.com)
56
28
  * Imports lodash methods individually to allow for tree-shaking
@@ -58,9 +30,6 @@ We've made big, backwards incompatible changes in version 2:
58
30
  * Drops support for older browsers (including IE) and uses ES6+ language features
59
31
  * Splits models and collections into separate modules
60
32
  * Adds the possibility to returns promises for asynchronous operations
61
- * Adds a new `ElementView` class, which is a like a Backbone View, but doubles
62
- as an instance of HTMLElement and can be used to register a custom element or
63
- web-component.
64
33
 
65
34
  ### Other backwards incompatible changes
66
35
 
@@ -82,57 +51,4 @@ We've made big, backwards incompatible changes in version 2:
82
51
  4. Use `includes` instead of `contains`
83
52
  5. The `partition` and `invokeMap` methods have been removed.
84
53
 
85
- ### ElementView example
86
-
87
- The ElementView looks very similar to a normal Backbone View.
88
-
89
- Since it's a web component, you need to call `CustomElementRegistry.define` to
90
- register it.
91
-
92
- The `this` variable for the ElementView is the custom DOM element itself,
93
- in this case, `<my-custom-button>`.
94
-
95
- So there is no `el` attribute and `this.el` will be undefined. Whereever in a
96
- Backbone View you'd use `this.el`, with an ElementView you'd just use `this`.
97
-
98
-
99
- ```javascript
100
-
101
- import { ElementView } from '@converse/skeletor/src/element.js';
102
- import { render } from 'lit';
103
- import { html } from 'lit';
104
-
105
- export default class MyCustomButton extends ElementView {
106
- events = {
107
- 'click .button': 'onButtonClicked'
108
- }
109
-
110
- async initialize () {
111
- this.model = new Model({ count: 0 });
112
- this.listenTo(this.model, 'change', this.render)
113
- }
114
-
115
- render () {
116
- return render(html`<button class="button">I've been clicked ${model.get('count')} times!</button>`, this);
117
- }
118
-
119
- onButtonClicked () {
120
- this.model.save('count', this.model.get('count')+1);
121
- }
122
- }
123
-
124
- CustomElementRegistry.define('my-custom-button', MyCustomButton);
125
- ```
126
-
127
- You can now put your custom element in the DOM, and once the DOM is loaded by
128
- the browser, your ElementView will automatically be instantiated and
129
- `initialize` will be called.
130
-
131
-
132
- ```html
133
- <div>
134
- <my-custom-button></my-custom-button>
135
- </div>
136
- ```
137
-
138
54
  ![](https://raw.githubusercontent.com/conversejs/skeletor/master/images/skeletor2.jpg)