sprae 6.1.0 → 6.1.1

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 (4) hide show
  1. package/license +7 -0
  2. package/package.json +2 -2
  3. package/readme.md +16 -10
  4. package/todo.md +2 -2
package/license ADDED
@@ -0,0 +1,7 @@
1
+ Copyright 2022 Dmitry Ivanov
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sprae",
3
3
  "description": "DOM microhydration.",
4
- "version": "6.1.0",
4
+ "version": "6.1.1",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
7
7
  "type": "module",
@@ -47,7 +47,7 @@
47
47
  "templating"
48
48
  ],
49
49
  "author": "Dmitry Ivanov <df.creative@gmail.com>",
50
- "license": "ISC",
50
+ "license": "MIT",
51
51
  "bugs": {
52
52
  "url": "https://github.com/dy/sprae/issues"
53
53
  },
package/readme.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # ∴ spræ [![tests](https://github.com/dy/sprae/actions/workflows/node.js.yml/badge.svg)](https://github.com/dy/sprae/actions/workflows/node.js.yml) [![size](https://img.shields.io/bundlephobia/minzip/sprae?label=size)](https://bundlephobia.com/result?p=sprae) [![npm](https://img.shields.io/npm/v/sprae?color=orange)](https://npmjs.org/sprae)
2
2
 
3
- > DOM microhydration with `:` attributes.
3
+ > DOM tree hydration with reactivity.
4
4
 
5
- _Sprae_ is tiny progressive enhancement framework, a minimal essential alternative to [alpine](https://github.com/alpinejs/alpine)/[lucia](https://github.com/aidenybai/lucia), [petite-vue](https://github.com/vuejs/petite-vue) or [template-parts](https://github.com/github/template-parts) with improved ergonomics[*](#justification--alternatives). It enables simple markup logic without external scripts. Perfect for small websites, prototypes or UI logic.
5
+ _Sprae_ is progressive enhancement framework, a tiny essential alternative to [alpine](https://github.com/alpinejs/alpine), [petite-vue](https://github.com/vuejs/petite-vue) or [template-parts](https://github.com/github/template-parts) with improved ergonomics[*](#justification--alternatives). It enables simple markup logic without external scripts. Perfect for small websites, prototypes or UI logic.
6
6
 
7
7
  ## Use
8
8
 
@@ -19,7 +19,7 @@ To autoinit document, include [`sprae.auto.js`](./sprae.auto.js):
19
19
 
20
20
  ### Manual init
21
21
 
22
- To use as module, import [`sprae.js`](./sprae.js):
22
+ To init manually as module, import [`sprae.js`](./sprae.js):
23
23
 
24
24
  ```html
25
25
  <div id="container" :if="user">
@@ -35,8 +35,7 @@ To use as module, import [`sprae.js`](./sprae.js):
35
35
  </script>
36
36
  ```
37
37
 
38
- Sprae evaluates `:`-attributes and evaporates them. Reactive `state` reflects current values, can be updated directly.
39
-
38
+ Sprae evaluates `:`-attributes and evaporates them. Reactive `state` reflects current values, can be updated directly (batches multiple updates internally for efficiency).
40
39
 
41
40
  ## Attributes
42
41
 
@@ -218,14 +217,15 @@ Attach event(s) listener with possible modifiers. `event` variable holds current
218
217
 
219
218
  ## Sandbox
220
219
 
221
- Expressions are sandboxed, ie. have no access to global or window (since sprae can be run in server environment).
220
+ Expressions are sandboxed, ie. don't access global/window scope by default (since sprae can be run in server environment).
222
221
 
223
222
  ```html
224
- <div :x="global.x"></div>
225
- <!-- global is undefined -->
223
+ <div :x="scrollY"></div>
224
+ <!-- scrollY is undefined -->
226
225
  ```
227
226
 
228
- Default sandbox provides: _window_, _document_, _console_, _history_, _location_, _Array_, _Object_, _Number_, _String_, _Boolean_, _Date_, _Set_, _Map_.<br/>
227
+ Default sandbox provides: _window_, _document_, _console_, _history_, _location_, _Array_, _Object_, _Number_, _String_, _Boolean_, _Date_, _Set_, _Map_.
228
+
229
229
  Sandbox can be extended as `Object.assign(sprae.globals, { BigInt })`.
230
230
 
231
231
  ## FOUC
@@ -246,7 +246,7 @@ To avoid _flash of unstyled content_, you can hide sprae attribute or add a cust
246
246
  ## Justification & alternatives
247
247
 
248
248
  * [Template-parts](https://github.com/dy/template-parts) / [templize](https://github.com/dy/templize) is progressive, but is stuck with native HTML quirks ([parsing table](https://github.com/github/template-parts/issues/24), [SVG attributes](https://github.com/github/template-parts/issues/25), [liquid syntax](https://shopify.github.io/liquid/tags/template/#raw) conflict etc). Also ergonomics of `attr="{{}}"` is inferior to `:attr=""` since it creates flash of uninitialized values. Also it's just nice to keep `{{}}` generic, regardless of markup, and attributes as part of markup.
249
- * [Alpine](https://github.com/alpinejs/alpine) / [vue](https://github.com/vuejs/petite-vue) / [lit](https://github.com/lit/lit/tree/main/packages/lit-html) / [lucia](https://github.com/aidenybai/lucia) escape native HTML quirks, but the syntax space (`:attr`, `v-*`,`x-*`, `l-*` `@evt`, `{{}}`) is too broad, as well as functionality. Perfection is when there's nothing to take away, not add (c). Also they tend to [self-encapsulate](https://github.com/alpinejs/alpine/discussions/3223) making interop hard, invent own tooling or complex reactivity.
249
+ * [Alpine](https://github.com/alpinejs/alpine) / [vue](https://github.com/vuejs/petite-vue) / [lit](https://github.com/lit/lit/tree/main/packages/lit-html) escape native HTML quirks, but the syntax space (`:attr`, `v-*`,`x-*`, `l-*` `@evt`, `{{}}`) is too broad, as well as functionality. Perfection is when there's nothing to take away, not add (c). Also they tend to [self-encapsulate](https://github.com/alpinejs/alpine/discussions/3223) making interop hard, invent own tooling or complex reactivity.
250
250
  * React/[preact](https://ghub.io/preact) does the job wiring up JS to HTML, but with an extreme of migrating HTML to JSX and enforcing SPA, which is not organic for HTML. Also it doesn't support reactive fields (needs render call).
251
251
 
252
252
  _Sprae_ takes idea of _templize directives_/_alpine_/_vue_ attrs and builds upon <del>[_@preact/signals_](https://ghub.io/@preact/signals)</del> simple reactive state.
@@ -261,5 +261,11 @@ _Sprae_ takes idea of _templize directives_/_alpine_/_vue_ attrs and builds upon
261
261
 
262
262
  It is reminiscent of [XSLT](https://www.w3schools.com/xml/xsl_intro.asp), considered a [buried treasure](https://github.com/bahrus/be-restated) by web-connoisseurs.
263
263
 
264
+ ## Alternatives
265
+
266
+ * [Alpine](https://github.com/alpinejs/alpine)
267
+ * [Lucia](https://github.com/aidenybai/lucia)
268
+ * [Petite-vue](https://github.com/vuejs/petite-vue)
269
+ * [Reken](https://github.com/hbroek/reken)
264
270
 
265
271
  <p align="center"><a href="https://github.com/krsnzd/license/">🕉</a></p>
package/todo.md CHANGED
@@ -38,7 +38,6 @@
38
38
  * [x] :if :ref, :if :with -> context setters must come first always
39
39
  * [x] :style="{'--x':value}"
40
40
  * [x] :onkeydown.ctrl-alt-D
41
- * [ ] frameworks benchmark
42
41
  * [x] examples
43
42
  * [x] todomvc
44
43
  * [x] waveplay
@@ -51,4 +50,5 @@
51
50
  * [x] There's some bug with prostogreen not triggering effect. (caused by special array.length case)
52
51
  * [x] Getters must become evaluable
53
52
  * [x] `<li :each="item in items" :with="{collapsed:true}"><button :onclick='e=>collapsed=false'></li>`
54
- * [ ] `:with="{likes:[], like(){ /* likes should not be undefined here */ }}"`
53
+ * [ ] `:with="{likes:[], like(){ /* likes should not be undefined here */ }}"`
54
+ * [ ] frameworks benchmark