@manyducks.co/dolla 1.1.0 → 2.0.0-alpha.0

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 (78) hide show
  1. package/README.md +47 -23
  2. package/build.js +5 -5
  3. package/dist/fragment-s33qZBzz.js +1241 -0
  4. package/dist/fragment-s33qZBzz.js.map +1 -0
  5. package/dist/index.d.ts +42 -0
  6. package/dist/index.js +1308 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/jsx-dev-runtime.d.ts +2 -0
  9. package/dist/jsx-dev-runtime.js +17 -0
  10. package/dist/jsx-dev-runtime.js.map +1 -0
  11. package/{lib/jsx → dist}/jsx-runtime.d.ts +3 -4
  12. package/dist/jsx-runtime.js +20 -0
  13. package/dist/jsx-runtime.js.map +1 -0
  14. package/{lib → dist}/markup.d.ts +12 -13
  15. package/dist/modules/dolla.d.ts +87 -0
  16. package/dist/modules/http.d.ts +57 -0
  17. package/dist/modules/language.d.ts +41 -0
  18. package/{lib/stores → dist/modules}/render.d.ts +5 -6
  19. package/{lib/stores → dist/modules}/router.d.ts +37 -39
  20. package/{lib → dist}/nodes/cond.d.ts +1 -4
  21. package/{lib → dist}/nodes/html.d.ts +2 -5
  22. package/{lib → dist}/nodes/observer.d.ts +2 -5
  23. package/{lib → dist}/nodes/outlet.d.ts +1 -4
  24. package/{lib → dist}/nodes/portal.d.ts +1 -3
  25. package/{lib → dist}/nodes/repeat.d.ts +2 -5
  26. package/{lib → dist}/nodes/text.d.ts +1 -1
  27. package/{lib → dist}/signals.d.ts +35 -46
  28. package/{lib → dist}/types.d.ts +0 -8
  29. package/{lib → dist}/utils.d.ts +10 -0
  30. package/dist/view.d.ts +44 -0
  31. package/dist/views/default-crash-page.d.ts +8 -0
  32. package/notes/scratch.md +120 -0
  33. package/package.json +11 -12
  34. package/vite.config.js +27 -0
  35. package/lib/app.d.ts +0 -83
  36. package/lib/classes/CrashCollector.d.ts +0 -30
  37. package/lib/classes/DebugHub.d.ts +0 -61
  38. package/lib/classes/EventEmitter.d.ts +0 -44
  39. package/lib/index.d.ts +0 -21
  40. package/lib/index.js +0 -4176
  41. package/lib/index.js.map +0 -7
  42. package/lib/jsx/jsx-dev-runtime.d.ts +0 -3
  43. package/lib/jsx/jsx-dev-runtime.js +0 -20
  44. package/lib/jsx/jsx-dev-runtime.js.map +0 -7
  45. package/lib/jsx/jsx-runtime.js +0 -22
  46. package/lib/jsx/jsx-runtime.js.map +0 -7
  47. package/lib/signals.test.d.ts +0 -1
  48. package/lib/spring.d.ts +0 -0
  49. package/lib/state.d.ts +0 -103
  50. package/lib/store.d.ts +0 -59
  51. package/lib/stores/dialog.d.ts +0 -32
  52. package/lib/stores/document.d.ts +0 -11
  53. package/lib/stores/http.d.ts +0 -60
  54. package/lib/stores/language.d.ts +0 -36
  55. package/lib/testing/classes/MockHTTP.d.ts +0 -10
  56. package/lib/testing/index.d.ts +0 -4
  57. package/lib/testing/makeMockDOMNode.d.ts +0 -10
  58. package/lib/testing/makeMockFetch._test.d.ts +0 -1
  59. package/lib/testing/makeMockFetch.d.ts +0 -36
  60. package/lib/testing/makeMockFetch.test.d.ts +0 -1
  61. package/lib/testing/makeMockFetch.test_skip.d.ts +0 -1
  62. package/lib/testing/stores/dialog.d.ts +0 -6
  63. package/lib/testing/stores/http.d.ts +0 -13
  64. package/lib/testing/stores/page.d.ts +0 -7
  65. package/lib/testing/stores/router.d.ts +0 -12
  66. package/lib/testing/wrapStore._test.d.ts +0 -1
  67. package/lib/testing/wrapStore.d.ts +0 -8
  68. package/lib/testing/wrapStore.test.d.ts +0 -1
  69. package/lib/testing/wrapStore.test_skip.d.ts +0 -1
  70. package/lib/testing/wrapView.d.ts +0 -0
  71. package/lib/view.d.ts +0 -88
  72. package/lib/views/default-crash-page.d.ts +0 -7
  73. package/lib/views/store-scope.d.ts +0 -13
  74. /package/{lib → dist}/routing.d.ts +0 -0
  75. /package/{lib → dist}/routing.test.d.ts +0 -0
  76. /package/{lib → dist}/typeChecking.d.ts +0 -0
  77. /package/{lib → dist}/views/default-view.d.ts +0 -0
  78. /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 { dolla, signal } from "@manyducks.co/dolla";
66
+ import Dolla from "@manyducks.co/dolla";
23
67
 
24
68
  function Counter(props, c) {
25
- const [$count, setCount] = signal(0);
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
- // Create a new dolla app...
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: "lib",
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/jsx-runtime.js"],
19
+ entryPoints: ["src/jsx-runtime.js"],
20
20
  bundle: false,
21
21
  minify: false,
22
22
  sourcemap: true,
23
- outdir: "lib/jsx",
23
+ outdir: "dist",
24
24
  format: "esm",
25
25
  });
26
26
 
27
27
  esbuild.build({
28
- entryPoints: ["src/jsx/jsx-dev-runtime.js"],
28
+ entryPoints: ["src/jsx-dev-runtime.js"],
29
29
  bundle: false,
30
30
  minify: false,
31
31
  sourcemap: true,
32
- outdir: "lib/jsx",
32
+ outdir: "dist",
33
33
  format: "esm",
34
34
  });