sprae 10.10.4 → 10.10.6
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/directive/value.js +9 -2
- package/dist/sprae.js +7 -1
- package/dist/sprae.js.map +3 -3
- package/dist/sprae.min.js +2 -2
- package/dist/sprae.min.js.map +3 -3
- package/dist/sprae.umd.js +13 -6
- package/dist/sprae.umd.js.map +3 -3
- package/dist/sprae.umd.min.js +2 -2
- package/dist/sprae.umd.min.js.map +3 -3
- package/package.json +9 -9
- package/readme.md +12 -10
- package/sprae.js +1 -1
package/readme.md
CHANGED
|
@@ -10,18 +10,18 @@ A light alternative to alpine, petite-vue etc.
|
|
|
10
10
|
|
|
11
11
|
```html
|
|
12
12
|
<div id="container" :if="user">
|
|
13
|
-
Hello <span :text="user.name">
|
|
13
|
+
Hello <span :text="user.name">there</span>.
|
|
14
14
|
</div>
|
|
15
15
|
|
|
16
16
|
<script type="module">
|
|
17
|
-
import sprae from 'sprae'
|
|
17
|
+
import sprae from './sprae.js'
|
|
18
18
|
|
|
19
19
|
// init
|
|
20
20
|
const container = document.querySelector('#container');
|
|
21
|
-
const state = sprae(container, { user: { name: '
|
|
21
|
+
const state = sprae(container, { user: { name: 'friend' } })
|
|
22
22
|
|
|
23
23
|
// update
|
|
24
|
-
state.user.name = '
|
|
24
|
+
state.user.name = 'love'
|
|
25
25
|
</script>
|
|
26
26
|
```
|
|
27
27
|
|
|
@@ -32,8 +32,8 @@ Sprae evaluates `:`-directives and evaporates them, returning reactive state for
|
|
|
32
32
|
UMD version enables sprae via CDN, as CJS, AMD etc.
|
|
33
33
|
|
|
34
34
|
```html
|
|
35
|
-
<!-- `init` attribute autoinits sprae on document -->
|
|
36
|
-
<script src="https://cdn.jsdelivr.net/npm/sprae/dist/sprae.umd.js" init></script>
|
|
35
|
+
<!-- `init` attribute autoinits sprae on document with initial state (optional) -->
|
|
36
|
+
<script src="https://cdn.jsdelivr.net/npm/sprae/dist/sprae.umd.js" init="{ user: 'buddy' }"></script>
|
|
37
37
|
|
|
38
38
|
<script>
|
|
39
39
|
window.sprae(el); // global standalone
|
|
@@ -283,15 +283,15 @@ Trigger when element is connected / disconnected from DOM.
|
|
|
283
283
|
|
|
284
284
|
## Signals
|
|
285
285
|
|
|
286
|
-
Sprae uses
|
|
287
|
-
Signals
|
|
286
|
+
Sprae uses _preact-flavored signals_ for reactivity and can take _signal_ values as inputs.<br/>
|
|
287
|
+
Signals can be switched to any preact/compatible implementation:
|
|
288
288
|
|
|
289
289
|
```js
|
|
290
290
|
import sprae from 'sprae';
|
|
291
291
|
import { signal, computed, effect, batch, untracked } from 'sprae/signal';
|
|
292
292
|
import * as signals from '@preact/signals-core';
|
|
293
293
|
|
|
294
|
-
// switch
|
|
294
|
+
// switch sprae signals to @preact/signals-core
|
|
295
295
|
sprae.use(signals);
|
|
296
296
|
|
|
297
297
|
// use signal as state value
|
|
@@ -308,7 +308,7 @@ Provider | Size | Feature
|
|
|
308
308
|
[`@webreflection/signal`](https://ghub.io/@webreflection/signal) | 531b | Class-based, better performance, good for small-medium states.
|
|
309
309
|
[`usignal`](https://ghub.io/usignal) | 850b | Class-based with optimizations, good for medium states.
|
|
310
310
|
[`@preact/signals-core`](https://ghub.io/@preact/signals-core) | 1.47kb | Best performance, good for any states, industry standard.
|
|
311
|
-
[`signal-polyfill`](https://ghub.
|
|
311
|
+
[`signal-polyfill`](https://ghub.io/signal-polyfill) | 2.5kb | Proposal signals. Use via [adapter](https://gist.github.com/dy/bbac687464ccf5322ab0e2fd0680dc4d).
|
|
312
312
|
|
|
313
313
|
|
|
314
314
|
## Evaluator
|
|
@@ -378,6 +378,8 @@ sprae.use({ compile })
|
|
|
378
378
|
|
|
379
379
|
## Justification
|
|
380
380
|
|
|
381
|
+
Modern frontend stack is unhealthy like non-organic / processed food. There are few resorts, but:
|
|
382
|
+
|
|
381
383
|
* [Template-parts](https://github.com/dy/template-parts) 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).
|
|
382
384
|
* [Alpine](https://github.com/alpinejs/alpine) / [petite-vue](https://github.com/vuejs/petite-vue) / [lucia](https://github.com/aidenyabi/lucia) escape native HTML quirks, but have excessive API (`:`, `x-`, `{}`, `@`, `$`), tend to [self-encapsulate](https://github.com/alpinejs/alpine/discussions/3223) and not care about size/performance.
|
|
383
385
|
|
package/sprae.js
CHANGED