create-spark-html-app 0.5.3 → 0.5.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-spark-html-app",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "Scaffold a Vite + spark-html",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,7 +1,7 @@
1
1
  <section class="card">
2
2
  <header class="card-header">
3
3
  <h2>Todos <span class="tag">bind:value + each + $:</span></h2>
4
- <span class="badge">{doneCount}/{todos.length}</span>
4
+ <span class="badge">{doneCount}/{todos.length} {pluralize(todos.length, 'item')}</span>
5
5
  </header>
6
6
  <p class="hint">Two-way binding, keyed reconciliation, and reactive statements in action.</p>
7
7
 
@@ -26,6 +26,8 @@
26
26
  </section>
27
27
 
28
28
  <script>
29
+ import { pluralize } from '../lib/format.js';
30
+
29
31
  let draft = '';
30
32
  let todos = [
31
33
  { id: 1, text: 'Learn Spark', done: true },
@@ -11,18 +11,20 @@
11
11
  <button class="round" onclick="{count = Math.max(0, count - 1)}" :disabled="count <= 0" aria-label="decrement">–</button>
12
12
  <div class="readout">
13
13
  <span class="num">{count}</span>
14
- <span class="sub">doubled is {doubled} · {mood}</span>
14
+ <span class="sub">doubled is {doubled} · {capitalize(mood)}</span>
15
15
  </div>
16
16
  <button class="round plus" onclick="{count++}" aria-label="increment">+</button>
17
17
  </div>
18
18
 
19
19
  <p class="store-line">
20
20
  You've struck the bolt <strong>{app.sparks}</strong>
21
- time{app.sparks === 1 ? '' : 's'} — that lives in a shared store.
21
+ {pluralize(app.sparks, 'time')} — that lives in a shared store.
22
22
  </p>
23
23
  </header>
24
24
 
25
25
  <script>
26
+ import { capitalize, pluralize } from '../lib/format.js';
27
+
26
28
  let count = 0;
27
29
  let igniting = false;
28
30
 
@@ -0,0 +1,13 @@
1
+ export function capitalize(str) {
2
+ return str.charAt(0).toUpperCase() + str.slice(1);
3
+ }
4
+
5
+ export function pluralize(count, singular, plural) {
6
+ return count === 1 ? singular : (plural || singular + 's');
7
+ }
8
+
9
+ export function formatDate(date) {
10
+ return date.toLocaleDateString('en-US', {
11
+ year: 'numeric', month: 'short', day: 'numeric',
12
+ });
13
+ }
@@ -12,6 +12,11 @@ import prerender from 'spark-prerender/vite';
12
12
  // tools read real content; the browser still hydrates over it). Remove it
13
13
  // if you don't need SEO. List every page you ship in `pages`.
14
14
  export default defineConfig({
15
+ optimizeDeps: {
16
+ // Ensure spark-html is pre-bundled so all modules share the same stores Map.
17
+ // Without this, file: references can create duplicate runtime instances.
18
+ include: ['spark-html'],
19
+ },
15
20
  plugins: [
16
21
  spark(),
17
22
  prerender({ pages: ['index.html'] }),