Skip to content

Commit 4c450ae

Browse files
authored
⚡ 🐛 🔤 v0.9.4-alpha (#42)
* 🐛 fixes #41 * ⚡ adjust package size limits * 🔤 * 📺 requestIdleCallback doesn need to be global * 🔤 corrects irland page headers * 📺 version * ⚡ Signal ← SignalReadonly * 🐛 ensures only one disconncetd listener …for cleanup * ⚡ 🔤 Better build and improve texting * 🐛 logo alignemt (due to gh) * 🔤 md enhancements * 🔤 ⚡ products
1 parent 04f9334 commit 4c450ae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+854
-339
lines changed

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,14 @@ where everyone feels comfortable participating.
7575

7676
…see [BS folder](./bs/README.md) for more info.
7777

78+
## Categorizing [![git3moji](https://img.shields.io/badge/git3moji%E2%80%93v1-%E2%9A%A1%EF%B8%8F%F0%9F%90%9B%F0%9F%93%BA%F0%9F%91%AE%F0%9F%94%A4-fffad8.svg?style=flat-square)](https://robinpokorny.github.io/git3moji/) <!-- editorconfig-checker-disable-line -->
79+
We use [git3moji](https://git3moji.netlify.app/) for commit messages, issue titles, pull request titles and in other
80+
areas. To make categorizing quick and consistent.
81+
7882
## Commit Guidelines
7983

80-
We use
81-
[![git3moji](https://img.shields.io/badge/git3moji%E2%80%93v1-%E2%9A%A1%EF%B8%8F%F0%9F%90%9B%F0%9F%93%BA%F0%9F%91%AE%F0%9F%94%A4-fffad8.svg?style=flat-square)](https://robinpokorny.github.io/git3moji/) <!-- editorconfig-checker-disable-line -->
82-
for commit messages. This helps keep the commit history clear and consistent.
84+
We use [git3moji](https://git3moji.netlify.app/) for commit messages. This helps keep the commit history clear and
85+
consistent.
8386

8487
```
8588
:emoji: Short summary of the change

README.md

Lines changed: 29 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,35 @@
11
**Alpha**
2-
| [source code on GitHub](https://github.com/jaandrle/deka-dom-el)
3-
| [*mirrored* on Gitea](https://gitea.jaandrle.cz/jaandrle/deka-dom-el)
4-
| [![git3moji](https://img.shields.io/badge/git3moji%E2%80%93v1-%E2%9A%A1%EF%B8%8F%F0%9F%90%9B%F0%9F%93%BA%F0%9F%91%AE%F0%9F%94%A4-fffad8.svg?style=flat-square)](https://robinpokorny.github.io/git3moji/) <!-- editorconfig-checker-disable-line -->
5-
6-
<p align="center">
7-
<img src="docs/assets/logo.svg" alt="Deka DOM Elements Logo" width="180" height="180">
8-
</p>
9-
10-
# Deka DOM Elements (dd\<el\> or DDE)
2+
| [Docs](https://jaandrle.github.io/deka-dom-el "Official documentation and guide site")
3+
| [NPM](https://www.npmjs.com/package/deka-dom-el "Official NPM package page")
4+
| [GitHub](https://github.com/jaandrle/deka-dom-el "Official GitHub repository")
5+
([*Gitea*](https://gitea.jaandrle.cz/jaandrle/deka-dom-el "GitHub repository mirror on my own Gitea instance"))
116

127
***Vanilla for flavouring — a full-fledged feast for large projects***
138

14-
*…use simple DOM API by default and library tools and logic when you need them*
15-
169
```javascript
1710
// 🌟 Reactive component with clear separation of concerns
1811
document.body.append(
1912
el(EmojiCounter, { initial: "🚀" })
2013
);
2114

2215
function EmojiCounter({ initial }) {
23-
//State - Define reactive data
16+
// ✨ - Define reactive data
2417
const count = S(0);
2518
const emoji = S(initial);
19+
const textContent = S(() => `Hello World ${emoji.get().repeat(count.get())}`);
2620

27-
/** @param {HTMLOptionElement} el */
28-
const isSelected= el=> (el.selected= el.value===initial);
29-
30-
// 🔄 View - UI updates automatically when signals change
21+
// 🔄 - UI updates automatically when signals change
3122
return el().append(
32-
el("p", {
33-
className: "output",
34-
textContent: S(() =>
35-
`Hello World ${emoji.get().repeat(count.get())}`),
36-
}),
23+
el("p", { textContent, className: "output" }),
3724

38-
// 🎮 Controls - Update state on events
25+
// 🎮 - Update state on events
3926
el("button", { textContent: "Add Emoji" },
40-
on("click", () => count.set(count.get() + 1))
27+
on("click", () => count.set(count.get() + 1)),
4128
),
4229

43-
el("select", null, on.defer(el=> el.value= initial),
44-
on("change", e => emoji.set(e.target.value))
30+
el("select", null,
31+
on.defer(el=> el.value= initial),
32+
on("change", e => emoji.set(e.target.value)),
4533
).append(
4634
el(Option, "🎉"),
4735
el(Option, "🚀"),
@@ -53,6 +41,13 @@ function Option({ textContent }){
5341
return el("option", { value: textContent, textContent });
5442
}
5543
```
44+
*…use simple DOM API by default and library tools and logic when you need them*
45+
46+
<p align="center">
47+
<img src="docs/assets/logo.svg" alt="Deka DOM Elements Logo" width="180" height="180">
48+
</p>
49+
50+
# Deka DOM Elements (dd\<el\> or DDE)
5651

5752
Creating reactive elements, components, and Web Components using the native
5853
[IDL](https://developer.mozilla.org/en-US/docs/Glossary/IDL)/JavaScript DOM API enhanced with
@@ -64,19 +59,21 @@ Creating reactive elements, components, and Web Components using the native
6459
- ☑️ **Lightweight**~10-15kB minified (original goal 10kB) with **zero**/minimal dependencies
6560
-**Declarative & functional approach** for clean, maintainable code
6661
-**Signals and events** for reactive UI
62+
-**Auto-releasing resources** for memory management but nice development experience
6763
-**Memoization for performance** — optimize rendering with intelligent caching
68-
- **Optional build-in signals** with support for custom reactive implementations (#39)
69-
- **Server-side rendering** support via [jsdom](https://github.com/jsdom/jsdom)
64+
- ☑️ **Optional build-in signals** with support for custom reactive implementations (#39)
65+
- ☑️ **Server-side rendering** support via [jsdom](https://github.com/jsdom/jsdom)
7066
-**TypeScript support**
71-
- ☑️ **Support for debugging with browser DevTools** without extensions
67+
- **Support for debugging with browser DevTools** without extensions
7268
- ☑️ **Enhanced Web Components** support
7369

7470
## Getting Started
7571

76-
### Documentation
72+
### Quick Links
7773

7874
- [**Documentation and Guide**](https://jaandrle.github.io/deka-dom-el)
7975
- [**Examples**](https://jaandrle.github.io/deka-dom-el/p15-examples.html)
76+
- [**Changelog**](https://github.com/jaandrle/deka-dom-el/releases)
8077

8178
### Installation
8279

@@ -87,7 +84,7 @@ npm install deka-dom-el --save
8784
…or via CDN / Direct Script:
8885

8986
For CDN links and various build formats (ESM/IIFE, with/without signals, minified/unminified), see the [interactive
90-
format selector](https://jaandrle.github.io/deka-dom-el/) on the documentation site.
87+
format selector](https://jaandrle.github.io/deka-dom-el/#h-getting-started) on the documentation site.
9188

9289
```html
9390
<!-- Example with IIFE build (creates a global DDE object) -->
@@ -141,9 +138,9 @@ get started, coding standards, commit guidelines, and the pull request process.
141138
interfaces or HTML code.
142139
- [pota](https://pota.quack.uy/) — small and pluggable Reactive Web Renderer. It's compiler-less, includes an html
143140
function, and a optimized babel preset in case you fancy JSX.
144-
- [jaandrle/dollar_dom_component](https://github.com/jaandrle/dollar_dom_component)
145-
Functional DOM components without JSX/virtual DOM
146141
- [TarekRaafat/eleva](https://github.com/TarekRaafat/eleva) — A minimalist, lightweight, pure vanilla JavaScript
147142
frontend runtime framework.
148143
- [didi/mpx](https://github.com/didi/mpx) — Mpx,一款具有优秀开发体验和深度性能优化的增强型跨端小程序框架
149144
- [mxjp/rvx](https://github.com/mxjp/rvx) — A signal based frontend framework
145+
- [jaandrle/dollar_dom_component](https://github.com/jaandrle/dollar_dom_component)
146+
Functional DOM components without JSX/virtual DOM (my old library)

bs/docs.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/* jshint esversion: 11,-W097, -W040, module: true, node: true, expr: true, undef: true *//* global echo, $, pipe, s, fetch, cyclicLoop */// editorconfig-checker-disable-line
33
echo("Building static documentation files…");
44
echo("Preparing…");
5-
import { path_target, pages as pages_registered, styles, dispatchEvent, t } from "../docs/ssr.js";
5+
import { path_target, pages as pages_registered, styles, currentPageId, dispatchEvent, t } from "../docs/ssr.js";
66
import { createHTMl } from "./docs/jsdom.js";
77
import { register, queue } from "../jsdom.js";
88
const pkg= s.cat("package.json").xargs(JSON.parse);
@@ -28,6 +28,7 @@ for(const { id, info } of pages){
2828
);
2929
const { el }= await register(serverDOM.dom);
3030
const { page }= await import(`../docs/${id}.html.js`);
31+
currentPageId(id)
3132
serverDOM.document.body.append(
3233
el(page, { pkg, info }),
3334
);

dist/esm-with-signals.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ function observedAttributes(instance, observedAttribute2) {
4141
function kebabToCamel(name) {
4242
return name.replace(/-./g, (x) => x[1].toUpperCase());
4343
}
44+
function requestIdle() {
45+
return new Promise(function(resolve) {
46+
(globalThis.requestIdleCallback || requestAnimationFrame)(resolve);
47+
});
48+
}
4449

4550
// src/dom-lib/common.js
4651
var enviroment = {
@@ -179,11 +184,6 @@ function connectionsChangesObserverConstructor() {
179184
is_observing = false;
180185
observer.disconnect();
181186
}
182-
function requestIdle() {
183-
return new Promise(function(resolve) {
184-
(requestIdleCallback || requestAnimationFrame)(resolve);
185-
});
186-
}
187187
async function collectChildren(element) {
188188
if (store.size > 30)
189189
await requestIdle();
@@ -696,23 +696,20 @@ var queueSignalWrite = /* @__PURE__ */ (() => {
696696
})();
697697

698698
// src/signals-lib/signals-lib.js
699-
var Signal = oCreate(null, {
699+
var SignalReadOnly = oCreate(null, {
700700
get: { value() {
701701
return read(this);
702702
} },
703-
set: { value(...v) {
704-
return write(this, ...v);
705-
} },
706703
toJSON: { value() {
707704
return read(this);
708705
} },
709706
valueOf: { value() {
710707
return this[mark] && this[mark].value;
711708
} }
712709
});
713-
var SignalReadOnly = oCreate(Signal, {
714-
set: { value() {
715-
return;
710+
var Signal = oCreate(SignalReadOnly, {
711+
set: { value(...v) {
712+
return write(this, ...v);
716713
} }
717714
});
718715
function isSignal(candidate) {
@@ -824,7 +821,7 @@ signal.el = function(s, map) {
824821
};
825822
function requestCleanUpReactives(host) {
826823
if (!host || !host[key_reactive]) return;
827-
(requestIdleCallback || setTimeout)(function() {
824+
requestIdle().then(function() {
828825
host[key_reactive] = host[key_reactive].filter(([s, el]) => el.isConnected ? true : (removeSignalListener(...s), false));
829826
});
830827
}
@@ -889,9 +886,10 @@ var signals_config = {
889886
function removeSignalsFromElements(s, listener, ...notes) {
890887
const { current } = scope;
891888
current.host(function(element) {
892-
if (!element[key_reactive]) element[key_reactive] = [];
889+
const is_first = !element[key_reactive];
890+
if (is_first) element[key_reactive] = [];
893891
element[key_reactive].push([[s, listener], ...notes]);
894-
if (current.prevent) return;
892+
if (!is_first || current.prevent) return;
895893
on.disconnected(
896894
() => (
897895
/*! Clears all Signals listeners added in the current scope/host (`S.el`, `assign`, …?).
@@ -906,7 +904,7 @@ var cleanUpRegistry = new FinalizationRegistry(function(s) {
906904
});
907905
function create(is_readonly, value, actions) {
908906
const varS = oCreate(is_readonly ? SignalReadOnly : Signal);
909-
const SI = toSignal(varS, value, actions, is_readonly);
907+
const SI = toSignal(varS, value, actions);
910908
cleanUpRegistry.register(SI, SI[mark]);
911909
return SI;
912910
}
@@ -918,7 +916,7 @@ var protoSigal = oAssign(oCreate(), {
918916
this.skip = true;
919917
}
920918
});
921-
function toSignal(s, value, actions, readonly = false) {
919+
function toSignal(s, value, actions) {
922920
const onclear = [];
923921
if (typeOf(actions) !== "[object Object]")
924922
actions = {};
@@ -934,8 +932,7 @@ function toSignal(s, value, actions, readonly = false) {
934932
actions,
935933
onclear,
936934
host,
937-
listeners: /* @__PURE__ */ new Set(),
938-
readonly
935+
listeners: /* @__PURE__ */ new Set()
939936
}),
940937
enumerable: false,
941938
writable: false,

0 commit comments

Comments
 (0)