sigpro 2.0.7 → 2.0.10
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 +28 -29
- package/dist/sigpro.calendar.js +1 -0
- package/dist/sigpro.chart.js +20 -0
- package/dist/sigpro.editor.js +1 -1
- package/dist/sigpro.grid.js +58 -55
- package/dist/sigpro.js +1 -1
- package/dist/sigpro.pdf.js +119 -0
- package/dist/sigpro.ui.js +1 -1
- package/dist/sigpro.utils.js +1 -0
- package/dist/sigpro.vite.js +7 -7
- package/package.json +41 -7
- package/sigpro.d.ts +25 -86
package/Readme.md
CHANGED
|
@@ -19,10 +19,10 @@ That extra development time and the cognitive load of "learning the framework" i
|
|
|
19
19
|
* **Atomic Precision:** Powered by an **alien-signals**-class push-pull reactive core. State is bound directly to DOM nodes—when a value changes, **only that specific node updates**. No diffing, no virtual tree, no wasted work.
|
|
20
20
|
* **Zero-Hydration Bottlenecks:** No 100KB bundles or complex build steps. SigPro is pure, optimized JavaScript tailored for the browser's native engine.
|
|
21
21
|
* **Lazy Computation:** `computed()` is lazy and verified with `checkDirty`. Effects don't re-run when a dependency's value didn't actually change.
|
|
22
|
-
* **Build-Tool Agnostic:** Total freedom. Use it with **Vite, Webpack, or Rollup** for enterprise projects, or simply import it via a **`<script>` tag** for rapid prototyping. No tooling required.
|
|
22
|
+
* **Build-Tool Agnostic:** Total freedom. Use it with **Vite, Webpack, or Rollup** for enterprise projects, or simply import it via a **`<script type="module">` tag** for rapid prototyping. No tooling required.
|
|
23
23
|
* **Zero-Scale Bloat:** Unlike other frameworks where the bundle grows exponentially, SigPro's footprint remains **flat and predictable**.
|
|
24
|
-
* **Premium DX:** Forget boilerplate imports. SigPro injects an elegant, functional syntax (`div()`, `button()`, `span()`) directly into your scope for a **"Zero-Import"** workflow.
|
|
25
|
-
* **Fully Loaded:** Built-in Hash Routing, native **`localStorage` persistence**,
|
|
24
|
+
* **Premium DX:** Forget boilerplate imports. SigPro injects an elegant, functional syntax (`div()`, `button()`, `span()`) directly into your scope (via `exposeTags()`) for a **"Zero-Import"** workflow.
|
|
25
|
+
* **Fully Loaded:** Built-in Hash Routing, native **`localStorage` persistence**, **SVG support**, and automatic cleanup of listeners and scopes—all in a single file.
|
|
26
26
|
* **No Memory Leaks:** Scopes cascade idempotently. Event listeners are tracked and removed with the node. Computeds die with their owners.
|
|
27
27
|
|
|
28
28
|
-----
|
|
@@ -36,7 +36,7 @@ Create reactive, persistent components with a syntax that feels like Vanilla JS,
|
|
|
36
36
|
```
|
|
37
37
|
|
|
38
38
|
```javascript
|
|
39
|
-
import { signal, computed, mount, exposeTags } from "sigpro";
|
|
39
|
+
import { signal, computed, local, mount, exposeTags } from "sigpro";
|
|
40
40
|
|
|
41
41
|
exposeTags();
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ const Counter = () => {
|
|
|
44
44
|
// Simple signal
|
|
45
45
|
const value = signal(100);
|
|
46
46
|
// One-line persistence: state survives page reloads automatically
|
|
47
|
-
const count = local("user-counter-pref",0);
|
|
47
|
+
const count = local("user-counter-pref", 0);
|
|
48
48
|
const ref = signal(100);
|
|
49
49
|
const doubleValue = computed(() => value() * ref());
|
|
50
50
|
|
|
@@ -66,8 +66,8 @@ mount(Counter, "#app");
|
|
|
66
66
|
|
|
67
67
|
```javascript
|
|
68
68
|
import {
|
|
69
|
-
signal, computed, effect,
|
|
70
|
-
batch, untrack, watch, local
|
|
69
|
+
signal, computed, effect, onMount, onError,
|
|
70
|
+
batch, untrack, watch, local
|
|
71
71
|
} from "sigpro";
|
|
72
72
|
|
|
73
73
|
const count = signal(0);
|
|
@@ -84,10 +84,10 @@ const stop = effect(() => {
|
|
|
84
84
|
return () => console.log("cleanup");
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
-
//
|
|
88
|
-
const dispose =
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
// Run once on mount (great for 3rd party libs)
|
|
88
|
+
const dispose = onMount(() => {
|
|
89
|
+
const chart = new Chart(el);
|
|
90
|
+
return () => chart.destroy();
|
|
91
91
|
});
|
|
92
92
|
|
|
93
93
|
// Batching: defer flush until the end
|
|
@@ -105,10 +105,6 @@ untrack(() => count());
|
|
|
105
105
|
// Persistent signal (localStorage-backed, JSON)
|
|
106
106
|
const theme = local("theme", "light");
|
|
107
107
|
theme("dark"); // stored, survives reloads
|
|
108
|
-
|
|
109
|
-
// Dependency injection
|
|
110
|
-
provide("theme", signal("dark"));
|
|
111
|
-
const t = inject("theme"); // nearest provider
|
|
112
108
|
```
|
|
113
109
|
|
|
114
110
|
### Rendering
|
|
@@ -124,30 +120,27 @@ div({ class: "card" }, "Hello");
|
|
|
124
120
|
// Reactive props
|
|
125
121
|
div({ class: () => active() ? "card active" : "card" });
|
|
126
122
|
|
|
127
|
-
// Reactive style
|
|
123
|
+
// Reactive style (string or object)
|
|
128
124
|
div({ style: () => open() ? "" : "display:none" });
|
|
129
125
|
|
|
130
126
|
// Reactive children
|
|
131
127
|
div({}, () => items().map(i => li({}, i.name)));
|
|
132
128
|
|
|
133
|
-
// Events
|
|
129
|
+
// Events (tracked and cleaned up automatically)
|
|
134
130
|
button({ onclick: () => count(count() + 1) }, "+1");
|
|
135
131
|
|
|
136
132
|
// ref
|
|
137
133
|
input({ ref: el => el.focus() });
|
|
138
134
|
|
|
139
|
-
// innerHTML (reactive)
|
|
140
|
-
div({ html: () => markdown(run().text) });
|
|
141
|
-
|
|
142
135
|
// Two-way binding
|
|
143
|
-
input({ value: () => username(), oninput: e => username(e.target.value)})
|
|
136
|
+
input({ value: () => username(), oninput: e => username(e.target.value) })
|
|
144
137
|
```
|
|
145
138
|
|
|
146
139
|
### SVG
|
|
147
140
|
|
|
148
141
|
```javascript
|
|
149
|
-
svg
|
|
150
|
-
path
|
|
142
|
+
h('svg', { viewBox: "0 0 24 24" }, [
|
|
143
|
+
h('path', { d: "M9 12l2 2 4-4", stroke: "currentColor", fill: "none" })
|
|
151
144
|
]);
|
|
152
145
|
```
|
|
153
146
|
|
|
@@ -173,7 +166,7 @@ router.path(); // current path
|
|
|
173
166
|
### i18n
|
|
174
167
|
|
|
175
168
|
```javascript
|
|
176
|
-
import { addLang, setLocale, t
|
|
169
|
+
import { addLang, setLocale, t } from "sigpro";
|
|
177
170
|
|
|
178
171
|
addLang({
|
|
179
172
|
en: { hello: "Hello" },
|
|
@@ -181,8 +174,8 @@ addLang({
|
|
|
181
174
|
});
|
|
182
175
|
|
|
183
176
|
setLocale("es");
|
|
184
|
-
|
|
185
|
-
t("hello")
|
|
177
|
+
t("hello")(); // "Hola" (imperative read)
|
|
178
|
+
h1(t("hello")); // "Hola" (reactive, updates when locale changes)
|
|
186
179
|
```
|
|
187
180
|
|
|
188
181
|
### HTTP Helper
|
|
@@ -193,8 +186,11 @@ import { db } from "sigpro";
|
|
|
193
186
|
const loading = signal(false);
|
|
194
187
|
const data = await db("/api/users", null, loading);
|
|
195
188
|
|
|
196
|
-
// POST
|
|
189
|
+
// POST JSON
|
|
197
190
|
await db("/api/save", { name: "Ada" });
|
|
191
|
+
|
|
192
|
+
// Upload files (FormData is supported natively)
|
|
193
|
+
await db("/api/upload", formData);
|
|
198
194
|
```
|
|
199
195
|
|
|
200
196
|
-----
|
|
@@ -227,9 +223,12 @@ cd my-app
|
|
|
227
223
|
npm install sigpro
|
|
228
224
|
```
|
|
229
225
|
|
|
230
|
-
**Or without build tools:**
|
|
226
|
+
**Or without build tools (Native ES Modules):**
|
|
231
227
|
```html
|
|
232
|
-
<script
|
|
228
|
+
<script type="module">
|
|
229
|
+
import { signal, mount, exposeTags } from "https://cdn.jsdelivr.net/npm/sigpro/+esm";
|
|
230
|
+
// ...
|
|
231
|
+
</script>
|
|
233
232
|
```
|
|
234
233
|
|
|
235
234
|
-----
|