@zvndev/darkmown 0.10.0 → 0.11.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.
@@ -0,0 +1,70 @@
1
+ tokens
2
+ ink #171717
3
+ paper #faf8f3
4
+ panel #ffffff
5
+ line #dedbd3
6
+ accent #16645a
7
+ warm #a83f2a
8
+ radius 8px
9
+
10
+ page
11
+ margin 0
12
+ font ui-serif, Georgia, Cambria, serif
13
+ color $ink
14
+ bg $paper
15
+ line-height 1.7
16
+
17
+ main
18
+ max-width 820px
19
+ margin 0 auto
20
+ padding 3rem 2rem 5rem
21
+
22
+ h1
23
+ font-size 3rem
24
+ line-height 1
25
+
26
+ h2
27
+ margin-top 2.4rem
28
+ border-top 1px solid $line
29
+ padding-top 1.2rem
30
+
31
+ a
32
+ color $accent
33
+
34
+ button
35
+ border 1px solid $ink
36
+ bg $ink
37
+ color white
38
+ padding .72rem 1rem
39
+ margin .3rem .5rem .3rem 0
40
+ radius $radius
41
+ font inherit
42
+ cursor pointer
43
+
44
+ button:hover
45
+ bg $accent
46
+ border-color $accent
47
+
48
+ input
49
+ padding .7rem .9rem
50
+ border 1px solid $line
51
+ radius $radius
52
+ font inherit
53
+ bg $panel
54
+ width 100%
55
+ max-width 360px
56
+ margin 1rem 0
57
+
58
+ #shop
59
+ border 1px solid $line
60
+ bg $panel
61
+ padding .4rem 1.4rem 1.4rem
62
+ margin 1.5rem 0
63
+ radius $radius
64
+
65
+ .line
66
+ border 1px solid $line
67
+ bg $paper
68
+ padding .55rem 1.1rem
69
+ margin .45rem 0
70
+ radius $radius
@@ -0,0 +1,53 @@
1
+ ---
2
+ title: Global store
3
+ ---
4
+
5
+ @include /nav.wd
6
+
7
+ <main>
8
+
9
+ # Global store
10
+
11
+ `:store` is durable, page-global state. It persists to `localStorage` under the
12
+ `wd:store:` prefix, rehydrates on load, and syncs across tabs through the
13
+ `storage` event — no backend, no wiring. Add `ephemeral` to opt a store out of
14
+ persistence entirely.
15
+
16
+ ::: section #shop
17
+ :store cart = []
18
+
19
+ ## A durable cart
20
+
21
+ This cart is a `:store`, so it survives a full reload and mirrors into every open
22
+ tab. Add a couple of items, refresh the page, and the count holds.
23
+
24
+ Cart: { cart.length }
25
+
26
+ :button "Add to cart" -> cart append {"id": "sticker", "name": "Sticker", "price": 4}
27
+ :button "Reset cart" -> cart reset
28
+
29
+ @loop cart into line
30
+ ::: card .line
31
+ { line.name } — ${ line.price }
32
+ :::
33
+ @empty
34
+ The cart is empty. Add something, then reload — it stays.
35
+ @endloop
36
+
37
+ `Reset cart` runs `-> cart reset`, which restores the **declared** seed (`[]`),
38
+ not the last persisted value — and writes that seed back to storage.
39
+ :::
40
+
41
+ ## An ephemeral draft
42
+
43
+ `:store draft = "" ephemeral` is in-memory only. It is bound two-way to the
44
+ input and echoed below, but nothing reaches `localStorage`, so a reload wipes it
45
+ clean.
46
+
47
+ :store draft = "" ephemeral
48
+
49
+ :bind draft placeholder="Type a draft note…"
50
+
51
+ Draft says: **{ draft }**
52
+
53
+ </main>
package/src/builder.js CHANGED
@@ -66,21 +66,26 @@ export function buildSite(cwd = process.cwd()) {
66
66
  }
67
67
 
68
68
  /**
69
- * Strip JSDoc `/** ... *\/` blocks from the runtime before it ships.
70
- * The source keeps full type annotations (for `checkJs` + `.d.ts`), but the
71
- * browser never needs to download them — this keeps the shipped runtime lean
72
- * and the gzip budget honest (measured against what users actually receive).
73
- * Only `/** ... *\/` blocks are removed; code and string literals are untouched.
69
+ * Strip developer comments from the runtime before it ships. The source keeps
70
+ * full JSDoc type annotations (for `checkJs` + `.d.ts`) and explanatory comments
71
+ * so it stays readable; the browser downloads neither. This keeps the shipped
72
+ * runtime lean and the gzip budget honest (measured against what users receive),
73
+ * WITHOUT minifying — identifiers, structure, and whitespace are all preserved.
74
+ *
75
+ * Two passes, each conservative: `/** ... *\/` JSDoc blocks, then whole-line
76
+ * `//` comments (a line that is nothing but a comment). Trailing `//` after code
77
+ * and `//` inside strings/URLs are deliberately left untouched, so no string
78
+ * literal is ever harmed.
74
79
  * @param {string} source
75
80
  * @returns {string}
76
81
  */
77
82
  export function stripRuntimeComments(source) {
78
83
  return source
79
- // Remove the JSDoc block text only — never the surrounding newlines, so an
80
- // inline `/** @type {x} */ code` keeps its line and never glues onto a
81
- // preceding `//` comment.
84
+ // JSDoc blocks — type annotations the browser never needs.
82
85
  .replace(/\/\*\*[\s\S]*?\*\//g, "")
83
- // Drop the now blank/whitespace-only lines the removed blocks leave behind.
86
+ // Whole-line `//` comments — developer notes that don't belong in the download.
87
+ .replace(/^[ \t]*\/\/.*$/gm, "")
88
+ // Drop the now blank/whitespace-only lines the removals leave behind.
84
89
  .replace(/^[ \t]*\n/gm, "");
85
90
  }
86
91