@manyducks.co/dolla 1.1.0 → 2.0.0-alpha.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.
- package/README.md +47 -23
- package/build.js +5 -5
- package/dist/fragment-DHJiX0-a.js +1241 -0
- package/dist/fragment-DHJiX0-a.js.map +1 -0
- package/dist/index.d.ts +44 -0
- package/dist/index.js +1331 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +2 -0
- package/dist/jsx-dev-runtime.js +17 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/{lib/jsx → dist}/jsx-runtime.d.ts +3 -4
- package/dist/jsx-runtime.js +20 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/{lib → dist}/markup.d.ts +18 -13
- package/dist/modules/dolla.d.ts +87 -0
- package/dist/modules/http.d.ts +57 -0
- package/dist/modules/language.d.ts +41 -0
- package/{lib/stores → dist/modules}/render.d.ts +5 -6
- package/{lib/stores → dist/modules}/router.d.ts +37 -39
- package/{lib → dist}/nodes/cond.d.ts +1 -4
- package/{lib → dist}/nodes/html.d.ts +2 -5
- package/{lib → dist}/nodes/observer.d.ts +2 -5
- package/{lib → dist}/nodes/outlet.d.ts +1 -4
- package/{lib → dist}/nodes/portal.d.ts +1 -3
- package/{lib → dist}/nodes/repeat.d.ts +2 -5
- package/{lib → dist}/nodes/text.d.ts +1 -1
- package/{lib → dist}/signals.d.ts +35 -46
- package/{lib → dist}/types.d.ts +0 -8
- package/{lib → dist}/utils.d.ts +10 -0
- package/dist/view.d.ts +44 -0
- package/dist/views/default-crash-page.d.ts +8 -0
- package/notes/scratch.md +120 -0
- package/package.json +12 -12
- package/vite.config.js +27 -0
- package/lib/app.d.ts +0 -83
- package/lib/classes/CrashCollector.d.ts +0 -30
- package/lib/classes/DebugHub.d.ts +0 -61
- package/lib/classes/EventEmitter.d.ts +0 -44
- package/lib/index.d.ts +0 -21
- package/lib/index.js +0 -4176
- package/lib/index.js.map +0 -7
- package/lib/jsx/jsx-dev-runtime.d.ts +0 -3
- package/lib/jsx/jsx-dev-runtime.js +0 -20
- package/lib/jsx/jsx-dev-runtime.js.map +0 -7
- package/lib/jsx/jsx-runtime.js +0 -22
- package/lib/jsx/jsx-runtime.js.map +0 -7
- package/lib/signals.test.d.ts +0 -1
- package/lib/spring.d.ts +0 -0
- package/lib/state.d.ts +0 -103
- package/lib/store.d.ts +0 -59
- package/lib/stores/dialog.d.ts +0 -32
- package/lib/stores/document.d.ts +0 -11
- package/lib/stores/http.d.ts +0 -60
- package/lib/stores/language.d.ts +0 -36
- package/lib/testing/classes/MockHTTP.d.ts +0 -10
- package/lib/testing/index.d.ts +0 -4
- package/lib/testing/makeMockDOMNode.d.ts +0 -10
- package/lib/testing/makeMockFetch._test.d.ts +0 -1
- package/lib/testing/makeMockFetch.d.ts +0 -36
- package/lib/testing/makeMockFetch.test.d.ts +0 -1
- package/lib/testing/makeMockFetch.test_skip.d.ts +0 -1
- package/lib/testing/stores/dialog.d.ts +0 -6
- package/lib/testing/stores/http.d.ts +0 -13
- package/lib/testing/stores/page.d.ts +0 -7
- package/lib/testing/stores/router.d.ts +0 -12
- package/lib/testing/wrapStore._test.d.ts +0 -1
- package/lib/testing/wrapStore.d.ts +0 -8
- package/lib/testing/wrapStore.test.d.ts +0 -1
- package/lib/testing/wrapStore.test_skip.d.ts +0 -1
- package/lib/testing/wrapView.d.ts +0 -0
- package/lib/view.d.ts +0 -88
- package/lib/views/default-crash-page.d.ts +0 -7
- package/lib/views/store-scope.d.ts +0 -13
- /package/{lib → dist}/routing.d.ts +0 -0
- /package/{lib → dist}/routing.test.d.ts +0 -0
- /package/{lib → dist}/typeChecking.d.ts +0 -0
- /package/{lib → dist}/views/default-view.d.ts +0 -0
- /package/{lib → dist}/views/fragment.d.ts +0 -0
package/README.md
CHANGED
|
@@ -16,13 +16,57 @@ Dolla is a batteries-included JavaScript frontend framework covering the needs o
|
|
|
16
16
|
|
|
17
17
|
Let's first get into some examples.
|
|
18
18
|
|
|
19
|
+
## Signals
|
|
20
|
+
|
|
21
|
+
### Signals API
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
import { createSignal, derive } from "@manyducks.co/dolla";
|
|
25
|
+
|
|
26
|
+
// Create a readable state and setter.
|
|
27
|
+
const [$count, setCount] = createSignal(0);
|
|
28
|
+
|
|
29
|
+
// Derive a new state from one or more states.
|
|
30
|
+
const $doubled = derive([$$count], (count) => count * 2);
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Basic State
|
|
34
|
+
|
|
35
|
+
```jsx
|
|
36
|
+
import { createSignal } from "@manyducks.co/dolla";
|
|
37
|
+
|
|
38
|
+
const [$count, setCount] = createSignal(0);
|
|
39
|
+
|
|
40
|
+
// Set Style 1: Set value explicitly.
|
|
41
|
+
setCount(1); // $count = 1
|
|
42
|
+
|
|
43
|
+
// Set Style 2: Set value based on the current value using a callback.
|
|
44
|
+
const increment = () => setCount((current) => current + 1);
|
|
45
|
+
const decrement = () => setCount((current) => current - 1);
|
|
46
|
+
|
|
47
|
+
increment(); // $count = 2
|
|
48
|
+
increment(); // $count = 3
|
|
49
|
+
decrement(); // $count = 2
|
|
50
|
+
|
|
51
|
+
console.log($count.get()); // 2
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Derived State
|
|
55
|
+
|
|
56
|
+
```jsx
|
|
57
|
+
import { createSignal, derive } from "@manyducks.co/dolla";
|
|
58
|
+
|
|
59
|
+
const [$count, setCount] = createSignal(0);
|
|
60
|
+
const $doubled = derive([$count], (count) => count * 2);
|
|
61
|
+
```
|
|
62
|
+
|
|
19
63
|
## A Basic Component
|
|
20
64
|
|
|
21
65
|
```tsx
|
|
22
|
-
import
|
|
66
|
+
import Dolla from "@manyducks.co/dolla";
|
|
23
67
|
|
|
24
68
|
function Counter(props, c) {
|
|
25
|
-
const [$count, setCount] =
|
|
69
|
+
const [$count, setCount] = Dolla.createSignal(0);
|
|
26
70
|
|
|
27
71
|
function increment() {
|
|
28
72
|
setCount((count) => count + 1);
|
|
@@ -34,29 +78,9 @@ function Counter(props, c) {
|
|
|
34
78
|
<button onClick={increment}>Click Me</button>
|
|
35
79
|
</div>
|
|
36
80
|
);
|
|
37
|
-
|
|
38
|
-
// return html`
|
|
39
|
-
// <div>
|
|
40
|
-
// <p>Clicks: ${$count}</p>
|
|
41
|
-
// <button onclick=${increment}>Click Me</button>
|
|
42
|
-
// </div>
|
|
43
|
-
// `;
|
|
44
81
|
}
|
|
45
82
|
|
|
46
|
-
|
|
47
|
-
const app = dolla();
|
|
48
|
-
|
|
49
|
-
// Mount this counter component at the root...
|
|
50
|
-
app.route("/", Counter);
|
|
51
|
-
|
|
52
|
-
app.route({
|
|
53
|
-
path: "/{#projectId}",
|
|
54
|
-
component: Counter,
|
|
55
|
-
routes: [{ path: "/", redirect: "../" }],
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
// And mount the app to the page.
|
|
59
|
-
app.mount("body");
|
|
83
|
+
Dolla.mount(document.body, Counter);
|
|
60
84
|
```
|
|
61
85
|
|
|
62
86
|
If you've ever used React before (and chances are you have if you're interested in obscure frameworks like this one) this should look very familiar to you.
|
package/build.js
CHANGED
|
@@ -8,7 +8,7 @@ esbuild
|
|
|
8
8
|
metafile: true,
|
|
9
9
|
sourcemap: true,
|
|
10
10
|
// minify: process.env.NODE_ENV === "production",
|
|
11
|
-
outdir: "
|
|
11
|
+
outdir: "dist",
|
|
12
12
|
format: "esm",
|
|
13
13
|
})
|
|
14
14
|
.then((result) => {
|
|
@@ -16,19 +16,19 @@ esbuild
|
|
|
16
16
|
});
|
|
17
17
|
|
|
18
18
|
esbuild.build({
|
|
19
|
-
entryPoints: ["src/jsx
|
|
19
|
+
entryPoints: ["src/jsx-runtime.js"],
|
|
20
20
|
bundle: false,
|
|
21
21
|
minify: false,
|
|
22
22
|
sourcemap: true,
|
|
23
|
-
outdir: "
|
|
23
|
+
outdir: "dist",
|
|
24
24
|
format: "esm",
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
esbuild.build({
|
|
28
|
-
entryPoints: ["src/jsx
|
|
28
|
+
entryPoints: ["src/jsx-dev-runtime.js"],
|
|
29
29
|
bundle: false,
|
|
30
30
|
minify: false,
|
|
31
31
|
sourcemap: true,
|
|
32
|
-
outdir: "
|
|
32
|
+
outdir: "dist",
|
|
33
33
|
format: "esm",
|
|
34
34
|
});
|