brumate 0.5.2 → 0.6.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 (71) hide show
  1. package/dist/{boot-Difa0qdg.d.ts → boot-CMvhoWRu.d.ts} +2 -2
  2. package/dist/cli.js +2 -2
  3. package/dist/{client-DvsU9qxG.d.ts → client-C4kNKGwH.d.ts} +18 -5
  4. package/dist/{client-De-7aGlO.js → client-eVI8Wc95.js} +171 -29
  5. package/dist/client-eVI8Wc95.js.map +1 -0
  6. package/dist/{defer-DlFYiAuK.js → defer-pKO0S6UT.js} +2 -2
  7. package/dist/{defer-DlFYiAuK.js.map → defer-pKO0S6UT.js.map} +1 -1
  8. package/dist/{devtools-Di_dI9tS.js → devtools-DqqqdI4b.js} +4 -4
  9. package/dist/{devtools-Di_dI9tS.js.map → devtools-DqqqdI4b.js.map} +1 -1
  10. package/dist/{devtools-panel-BvIKX1LY.js → devtools-panel--GYjFZ35.js} +2 -2
  11. package/dist/{devtools-panel-BvIKX1LY.js.map → devtools-panel--GYjFZ35.js.map} +1 -1
  12. package/dist/{features-D5kLyihb.js → features-CbgII-o7.js} +4 -2
  13. package/dist/features-CbgII-o7.js.map +1 -0
  14. package/dist/{files-s4wmjcZV.js → files-CR-V05xd.js} +2 -2
  15. package/dist/{files-s4wmjcZV.js.map → files-CR-V05xd.js.map} +1 -1
  16. package/dist/index.d.ts +8 -4
  17. package/dist/index.js +2 -7
  18. package/dist/index.js.map +1 -1
  19. package/dist/{inspect-BLPt-dZZ.js → inspect-ddfGeww0.js} +236 -57
  20. package/dist/inspect-ddfGeww0.js.map +1 -0
  21. package/dist/{loader-krRrJuIv.js → loader-CQkAXO0g.js} +11 -3
  22. package/dist/loader-CQkAXO0g.js.map +1 -0
  23. package/dist/routes-D21FQyGF.js +51 -0
  24. package/dist/routes-D21FQyGF.js.map +1 -0
  25. package/dist/{rpc-BYYAj1vV.js → rpc-BgYnfg_a.js} +3 -3
  26. package/dist/{rpc-BYYAj1vV.js.map → rpc-BgYnfg_a.js.map} +1 -1
  27. package/dist/runtime/bundles.d.ts +1 -1
  28. package/dist/runtime/client.d.ts +2 -2
  29. package/dist/runtime/client.js +3 -3
  30. package/dist/runtime/devtools.d.ts +1 -1
  31. package/dist/runtime/devtools.js +1 -1
  32. package/dist/runtime/hot.d.ts +1 -1
  33. package/dist/runtime/loader.d.ts +2 -2
  34. package/dist/runtime/loader.js +2 -2
  35. package/dist/runtime/routes.js +1 -51
  36. package/dist/runtime/server.d.ts +2 -2
  37. package/dist/runtime/server.js +3 -3
  38. package/dist/runtime/signals.d.ts +2 -140
  39. package/dist/runtime/signals.js +4 -1
  40. package/dist/runtime/signals.js.map +1 -1
  41. package/dist/runtime/static-loader.d.ts +2 -2
  42. package/dist/runtime/static-loader.js +1 -1
  43. package/dist/runtime/testing.d.ts +24 -4
  44. package/dist/runtime/testing.js +66 -2
  45. package/dist/runtime/testing.js.map +1 -1
  46. package/dist/{produce-Cq6KKi7b.js → search-params-CM1RWR2P.js} +25 -3
  47. package/dist/search-params-CM1RWR2P.js.map +1 -0
  48. package/dist/{server-Doy5HR7r.js → server-BcT9icQ4.js} +107 -40
  49. package/dist/server-BcT9icQ4.js.map +1 -0
  50. package/dist/{server-CAwIqrXl.d.ts → server-dP_ucRiJ.d.ts} +42 -3
  51. package/dist/signals-BwD4u22K.d.ts +165 -0
  52. package/dist/{static-loader-9Nc1GvF0.d.ts → static-loader-CGthkX0s.d.ts} +2 -2
  53. package/dist/{static-loader-DoHWsf9t.js → static-loader-DCxASuzA.js} +3 -3
  54. package/dist/{static-loader-DoHWsf9t.js.map → static-loader-DCxASuzA.js.map} +1 -1
  55. package/dist/{stream-BdhzvPQO.js → stream-DRjx0keF.js} +2 -2
  56. package/dist/{stream-BdhzvPQO.js.map → stream-DRjx0keF.js.map} +1 -1
  57. package/dist/vite.d.ts +1 -1
  58. package/dist/vite.js +17 -12
  59. package/dist/vite.js.map +1 -1
  60. package/elements.d.ts +231 -35
  61. package/package.json +6 -1
  62. package/skills/brumate/references/errors.md +32 -12
  63. package/skills/brumate/references/signals.md +27 -25
  64. package/skills/brumate/references/syntax.md +1 -1
  65. package/dist/client-De-7aGlO.js.map +0 -1
  66. package/dist/features-D5kLyihb.js.map +0 -1
  67. package/dist/inspect-BLPt-dZZ.js.map +0 -1
  68. package/dist/loader-krRrJuIv.js.map +0 -1
  69. package/dist/produce-Cq6KKi7b.js.map +0 -1
  70. package/dist/runtime/routes.js.map +0 -1
  71. package/dist/server-Doy5HR7r.js.map +0 -1
package/elements.d.ts CHANGED
@@ -258,45 +258,241 @@ export type Handlers<E> = {
258
258
  [K in keyof ElementEvents & string as `on${EventWord<K>}`]?: Handler<ElementEvents[K], E>;
259
259
  };
260
260
 
261
+ /** A value of an ARIA attribute that is `true` or `false`. The runtime writes both as words. */
262
+ type AriaBool = boolean | 'true' | 'false';
263
+
264
+ /** The tokens of `aria-relevant`: `all`, or one to three of the others in any order. */
265
+ type AriaRelevantToken = 'additions' | 'removals' | 'text';
266
+ type AriaRelevant =
267
+ | 'all'
268
+ | AriaRelevantToken
269
+ | `${AriaRelevantToken} ${AriaRelevantToken}`
270
+ | `${AriaRelevantToken} ${AriaRelevantToken} ${AriaRelevantToken}`;
271
+
272
+ /** The roles of WAI-ARIA 1.2 and of the Digital Publishing module (`doc-*`). */
273
+ export type AriaRole =
274
+ | 'alert'
275
+ | 'alertdialog'
276
+ | 'application'
277
+ | 'article'
278
+ | 'banner'
279
+ | 'blockquote'
280
+ | 'button'
281
+ | 'caption'
282
+ | 'cell'
283
+ | 'checkbox'
284
+ | 'code'
285
+ | 'columnheader'
286
+ | 'combobox'
287
+ | 'complementary'
288
+ | 'contentinfo'
289
+ | 'definition'
290
+ | 'deletion'
291
+ | 'dialog'
292
+ | 'directory'
293
+ | 'document'
294
+ | 'emphasis'
295
+ | 'feed'
296
+ | 'figure'
297
+ | 'form'
298
+ | 'generic'
299
+ | 'grid'
300
+ | 'gridcell'
301
+ | 'group'
302
+ | 'heading'
303
+ | 'img'
304
+ | 'insertion'
305
+ | 'link'
306
+ | 'list'
307
+ | 'listbox'
308
+ | 'listitem'
309
+ | 'log'
310
+ | 'main'
311
+ | 'mark'
312
+ | 'marquee'
313
+ | 'math'
314
+ | 'menu'
315
+ | 'menubar'
316
+ | 'menuitem'
317
+ | 'menuitemcheckbox'
318
+ | 'menuitemradio'
319
+ | 'meter'
320
+ | 'navigation'
321
+ | 'none'
322
+ | 'note'
323
+ | 'option'
324
+ | 'paragraph'
325
+ | 'presentation'
326
+ | 'progressbar'
327
+ | 'radio'
328
+ | 'radiogroup'
329
+ | 'region'
330
+ | 'row'
331
+ | 'rowgroup'
332
+ | 'rowheader'
333
+ | 'scrollbar'
334
+ | 'search'
335
+ | 'searchbox'
336
+ | 'separator'
337
+ | 'slider'
338
+ | 'spinbutton'
339
+ | 'status'
340
+ | 'strong'
341
+ | 'subscript'
342
+ | 'superscript'
343
+ | 'switch'
344
+ | 'tab'
345
+ | 'table'
346
+ | 'tablist'
347
+ | 'tabpanel'
348
+ | 'term'
349
+ | 'textbox'
350
+ | 'time'
351
+ | 'timer'
352
+ | 'toolbar'
353
+ | 'tooltip'
354
+ | 'tree'
355
+ | 'treegrid'
356
+ | 'treeitem'
357
+ | 'doc-abstract'
358
+ | 'doc-acknowledgments'
359
+ | 'doc-afterword'
360
+ | 'doc-appendix'
361
+ | 'doc-backlink'
362
+ | 'doc-biblioentry'
363
+ | 'doc-bibliography'
364
+ | 'doc-biblioref'
365
+ | 'doc-chapter'
366
+ | 'doc-colophon'
367
+ | 'doc-conclusion'
368
+ | 'doc-cover'
369
+ | 'doc-credit'
370
+ | 'doc-credits'
371
+ | 'doc-dedication'
372
+ | 'doc-endnote'
373
+ | 'doc-endnotes'
374
+ | 'doc-epigraph'
375
+ | 'doc-epilogue'
376
+ | 'doc-errata'
377
+ | 'doc-example'
378
+ | 'doc-footnote'
379
+ | 'doc-foreword'
380
+ | 'doc-glossary'
381
+ | 'doc-glossref'
382
+ | 'doc-index'
383
+ | 'doc-introduction'
384
+ | 'doc-noteref'
385
+ | 'doc-notice'
386
+ | 'doc-pagebreak'
387
+ | 'doc-pagefooter'
388
+ | 'doc-pageheader'
389
+ | 'doc-pagelist'
390
+ | 'doc-part'
391
+ | 'doc-preface'
392
+ | 'doc-prologue'
393
+ | 'doc-pullquote'
394
+ | 'doc-qna'
395
+ | 'doc-subtitle'
396
+ | 'doc-tip'
397
+ | 'doc-toc';
398
+
399
+ /** The ARIA attributes of WAI-ARIA 1.2 and the value of each. */
400
+ export interface AriaAttributes {
401
+ 'aria-activedescendant'?: Attr<string>;
402
+ 'aria-atomic'?: Attr<AriaBool>;
403
+ 'aria-autocomplete'?: Attr<'none' | 'inline' | 'list' | 'both'>;
404
+ 'aria-braillelabel'?: Attr<string>;
405
+ 'aria-brailleroledescription'?: Attr<string>;
406
+ 'aria-busy'?: Attr<AriaBool>;
407
+ 'aria-checked'?: Attr<AriaBool | 'mixed'>;
408
+ 'aria-colcount'?: Attr<Num>;
409
+ 'aria-colindex'?: Attr<Num>;
410
+ 'aria-colindextext'?: Attr<string>;
411
+ 'aria-colspan'?: Attr<Num>;
412
+ /** A list of IDs, separated by spaces. */
413
+ 'aria-controls'?: Attr<string>;
414
+ 'aria-current'?: Attr<AriaBool | 'page' | 'step' | 'location' | 'date' | 'time'>;
415
+ 'aria-describedby'?: Attr<string>;
416
+ 'aria-description'?: Attr<string>;
417
+ 'aria-details'?: Attr<string>;
418
+ 'aria-disabled'?: Attr<AriaBool>;
419
+ 'aria-errormessage'?: Attr<string>;
420
+ 'aria-expanded'?: Attr<AriaBool>;
421
+ 'aria-flowto'?: Attr<string>;
422
+ 'aria-haspopup'?: Attr<AriaBool | 'menu' | 'listbox' | 'tree' | 'grid' | 'dialog'>;
423
+ 'aria-hidden'?: Attr<AriaBool>;
424
+ 'aria-invalid'?: Attr<AriaBool | 'grammar' | 'spelling'>;
425
+ 'aria-keyshortcuts'?: Attr<string>;
426
+ 'aria-label'?: Attr<string>;
427
+ 'aria-labelledby'?: Attr<string>;
428
+ 'aria-level'?: Attr<Num>;
429
+ 'aria-live'?: Attr<'off' | 'assertive' | 'polite'>;
430
+ 'aria-modal'?: Attr<AriaBool>;
431
+ 'aria-multiline'?: Attr<AriaBool>;
432
+ 'aria-multiselectable'?: Attr<AriaBool>;
433
+ 'aria-orientation'?: Attr<'horizontal' | 'vertical'>;
434
+ 'aria-owns'?: Attr<string>;
435
+ 'aria-placeholder'?: Attr<string>;
436
+ 'aria-posinset'?: Attr<Num>;
437
+ 'aria-pressed'?: Attr<AriaBool | 'mixed'>;
438
+ 'aria-readonly'?: Attr<AriaBool>;
439
+ 'aria-relevant'?: Attr<AriaRelevant>;
440
+ 'aria-required'?: Attr<AriaBool>;
441
+ 'aria-roledescription'?: Attr<string>;
442
+ 'aria-rowcount'?: Attr<Num>;
443
+ 'aria-rowindex'?: Attr<Num>;
444
+ 'aria-rowindextext'?: Attr<string>;
445
+ 'aria-rowspan'?: Attr<Num>;
446
+ 'aria-selected'?: Attr<AriaBool>;
447
+ 'aria-setsize'?: Attr<Num>;
448
+ 'aria-sort'?: Attr<'none' | 'ascending' | 'descending' | 'other'>;
449
+ 'aria-valuemax'?: Attr<Num>;
450
+ 'aria-valuemin'?: Attr<Num>;
451
+ 'aria-valuenow'?: Attr<Num>;
452
+ 'aria-valuetext'?: Attr<string>;
453
+ }
454
+
261
455
  /**
262
456
  * The attributes that every element takes: `class`, `style`, the handlers, `ref`, `data-*` and
263
457
  * `aria-*`. `E` is the element, for the handlers and `ref`.
264
458
  */
265
- export type GlobalAttributes<E> = Handlers<E> & {
266
- /**
267
- * Binds the element to a name: `ref=$bind(name)`. The signal can hold the element, a supertype
268
- * of it such as `HTMLElement | undefined`, or `null`. A signal of another element is an error.
269
- */
270
- ref?: BindableMark<unknown> & WritableMark<E>;
271
- class?: Attr<ClassValue>;
272
- style?: Attr<string | StyleObject>;
273
- id?: Attr<string>;
274
- slot?: Attr<string>;
275
- part?: Attr<string>;
276
- is?: Attr<string>;
277
- role?: Attr<string>;
278
- title?: Attr<string>;
279
- lang?: Attr<string>;
280
- dir?: Attr<'ltr' | 'rtl' | 'auto'>;
281
- nonce?: Attr<string>;
282
- accesskey?: Attr<string>;
283
- autocapitalize?: Attr<'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters'>;
284
- autofocus?: Attr<boolean>;
285
- contenteditable?: Attr<boolean | 'true' | 'false' | 'plaintext-only'>;
286
- draggable?: Attr<boolean | 'true' | 'false'>;
287
- enterkeyhint?: Attr<'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'>;
288
- hidden?: Attr<boolean | 'hidden' | 'until-found'>;
289
- inert?: Attr<boolean>;
290
- inputmode?: Attr<'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'>;
291
- popover?: Attr<boolean | 'auto' | 'manual' | 'hint'>;
292
- spellcheck?: Attr<boolean | 'true' | 'false'>;
293
- tabindex?: Attr<Num>;
294
- translate?: Attr<'yes' | 'no'>;
295
- writingsuggestions?: Attr<boolean | 'true' | 'false'>;
296
- autocorrect?: Attr<boolean | 'on' | 'off'>;
297
- [attribute: `data-${string}`]: unknown;
298
- [attribute: `aria-${string}`]: Attr<string | number | boolean>;
299
- };
459
+ export type GlobalAttributes<E> = Handlers<E> &
460
+ AriaAttributes & {
461
+ /**
462
+ * Binds the element to a name: `ref=$bind(name)`. The signal can hold the element, a supertype
463
+ * of it such as `HTMLElement | undefined`, or `null`. A signal of another element is an error.
464
+ */
465
+ ref?: BindableMark<unknown> & WritableMark<E>;
466
+ class?: Attr<ClassValue>;
467
+ style?: Attr<string | StyleObject>;
468
+ id?: Attr<string>;
469
+ slot?: Attr<string>;
470
+ part?: Attr<string>;
471
+ is?: Attr<string>;
472
+ /** A role, or a list of fallback roles: `doc-footnote listitem`. */
473
+ role?: Attr<AriaRole | `${AriaRole} ${string}`>;
474
+ title?: Attr<string>;
475
+ lang?: Attr<string>;
476
+ dir?: Attr<'ltr' | 'rtl' | 'auto'>;
477
+ nonce?: Attr<string>;
478
+ accesskey?: Attr<string>;
479
+ autocapitalize?: Attr<'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters'>;
480
+ autofocus?: Attr<boolean>;
481
+ contenteditable?: Attr<boolean | 'true' | 'false' | 'plaintext-only'>;
482
+ draggable?: Attr<boolean | 'true' | 'false'>;
483
+ enterkeyhint?: Attr<'enter' | 'done' | 'go' | 'next' | 'previous' | 'search' | 'send'>;
484
+ hidden?: Attr<boolean | 'hidden' | 'until-found'>;
485
+ inert?: Attr<boolean>;
486
+ inputmode?: Attr<'none' | 'text' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'>;
487
+ popover?: Attr<boolean | 'auto' | 'manual' | 'hint'>;
488
+ spellcheck?: Attr<boolean | 'true' | 'false'>;
489
+ tabindex?: Attr<Num>;
490
+ translate?: Attr<'yes' | 'no'>;
491
+ writingsuggestions?: Attr<boolean | 'true' | 'false'>;
492
+ autocorrect?: Attr<boolean | 'on' | 'off'>;
493
+ [attribute: `data-${string}`]: unknown;
494
+ [attribute: `aria-${string}`]: Attr<string | number | boolean>;
495
+ };
300
496
 
301
497
  type Referrer =
302
498
  | 'no-referrer'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "brumate",
3
- "version": "0.5.2",
3
+ "version": "0.6.0",
4
4
  "description": "A component language and compiler for resumable web apps",
5
5
  "homepage": "https://github.com/lxsmnsyc/brumate",
6
6
  "bugs": "https://github.com/lxsmnsyc/brumate/issues",
@@ -140,6 +140,7 @@
140
140
  "devDependencies": {
141
141
  "@oxc-project/types": "^0.154.0",
142
142
  "@types/node": "^24.0.0",
143
+ "axe-core": "^4.14.0",
143
144
  "happy-dom": "^20.14.6",
144
145
  "less": "^4.9.1",
145
146
  "sass": "^1.105.2",
@@ -150,11 +151,15 @@
150
151
  "vitest": "^5.0.4"
151
152
  },
152
153
  "peerDependencies": {
154
+ "axe-core": ">=4.8",
153
155
  "less": ">=4",
154
156
  "sass": ">=1.70",
155
157
  "vite": "^8.0.0"
156
158
  },
157
159
  "peerDependenciesMeta": {
160
+ "axe-core": {
161
+ "optional": true
162
+ },
158
163
  "vite": {
159
164
  "optional": true
160
165
  },
@@ -237,13 +237,15 @@ https://brumate-docs.vercel.app/docs/errors#brm021
237
237
  <input disabled>
238
238
  ```
239
239
 
240
- ## BRM022: Unknown event modifier ":{modifier}"
240
+ ## BRM022: Event modifiers in the attribute name were removed. Write {fix}
241
241
 
242
- The modifier after an event name is not one of the known ones.
242
+ A modifier follows the event name, as in `onSubmit:prevent=send`. Wrappers of `brumate/events` write modifiers now, and `:passive` is the default, since listeners are passive unless a handler prevents.
243
243
 
244
244
  https://brumate-docs.vercel.app/docs/errors#brm022
245
245
 
246
246
  ```brm fragment
247
+ import { prevent } from 'brumate/events';
248
+
247
249
  <form onSubmit=(prevent(send))></form>
248
250
  ```
249
251
 
@@ -358,16 +360,6 @@ https://brumate-docs.vercel.app/docs/errors#brm188
358
360
  }
359
361
  ```
360
362
 
361
- ## BRM023: Modifiers apply to elements. Put ":{modifier}" on the element that the component renders
362
-
363
- An event modifier is on a component, which only passes the handler on.
364
-
365
- https://brumate-docs.vercel.app/docs/errors#brm023
366
-
367
- ```brm fragment
368
- <form onSubmit=(prevent(send))></form>
369
- ```
370
-
371
363
  ## BRM024: Expected an event handler
372
364
 
373
365
  An event attribute has no `=` and no value.
@@ -538,6 +530,34 @@ https://brumate-docs.vercel.app/docs/errors#brm038
538
530
  </style>
539
531
  ```
540
532
 
533
+ ## BRM189: Unknown <style> attribute "{name}"
534
+
535
+ A `<style>` has an attribute other than `lang` and `global`.
536
+
537
+ https://brumate-docs.vercel.app/docs/errors#brm189
538
+
539
+ ```brm fragment
540
+ <style scoped>
541
+ p {
542
+ color: red;
543
+ }
544
+ </style>
545
+ ```
546
+
547
+ ## BRM190: global takes no value, as in <style global>
548
+
549
+ A `<style global>` gives `global` a value.
550
+
551
+ https://brumate-docs.vercel.app/docs/errors#brm190
552
+
553
+ ```brm fragment
554
+ <style global="true">
555
+ p {
556
+ color: red;
557
+ }
558
+ </style>
559
+ ```
560
+
541
561
  ## BRM039: #reveal takes an order, 'sequential', 'backwards', 'together' or 'natural', and collapsed, such as #reveal ('sequential', collapsed)
542
562
 
543
563
  `#reveal` has an option that it does not know.
@@ -4,31 +4,32 @@ The compiler replaces each call and removes the import, so none of them ship. Im
4
4
 
5
5
  "Top level of a script" means a statement of the component's `<script>`, or of a `<script>` at the start of a block body. It is not inside a function or another statement.
6
6
 
7
- | Function | Returns | Where |
8
- | ----------------------------- | -------------------------- | ----------------------------------------------------- |
9
- | `$props<T>()` | `T` | `const` or `let` in the component script |
10
- | `$signal<T>(value?)` | `T` | `let` at the top level of a script |
11
- | `$memo<T>(value)` | the value, never a promise | `const` at the top level of a script |
12
- | `$debounced(value, ms)` | the value, as a memo | `const` at the top level of a script |
13
- | `$throttled(value, ms)` | the value, as a memo | `const` at the top level of a script |
14
- | `$isPending(memo)` | `boolean` | Any expression |
15
- | `$resolve(memo, options?)` | `Promise<T>` | A handler, an effect or a `$client` callback |
16
- | `$isPassed(prop)` | `boolean` | `const` in the component script |
17
- | `$isBound(prop)` | `boolean` | Any expression |
18
- | `$effect(callback)` | `void` | Statement at the top level of a script |
19
- | `$client(callback, trigger?)` | `void` | Statement at the top level of a script |
20
- | `$untrack(value)` | the value | Any expression |
21
- | `$produce(signal, recipe)` | `void` | Where a signal can be written |
22
- | `$setContext(context, value)` | `void` | Statement at the top level of a script |
23
- | `$getContext(context)` | the value | `const` at the top level of a script |
24
- | `$route(path?)` | `{ url, search, params }` | `const` at the top level of a script |
25
- | `$navigation()` | `{ pending, from, to }` | `const` at the top level of a script |
26
- | `$id()` | `string` | `const` at the top level of a script |
27
- | `$title(value)` | `void` | Statement at the top level of a script |
28
- | `$action(fn)` | the result, or `undefined` | `const` at the top level of a script |
29
- | `$optimistic(source)` | the value of `source` | `let` at the top level of a script |
30
- | `$handler(fn, ...args)` | a handler | Any expression of a script or a module function |
31
- | `$bind(value, set?)` | a binding | The whole value of a prop, or of `value` or `checked` |
7
+ | Function | Returns | Where |
8
+ | ------------------------------ | -------------------------- | ----------------------------------------------------- |
9
+ | `$props<T>()` | `T` | `const` or `let` in the component script |
10
+ | `$signal<T>(value?)` | `T` | `let` at the top level of a script |
11
+ | `$memo<T>(value)` | the value, never a promise | `const` at the top level of a script |
12
+ | `$debounced(value, ms)` | the value, as a memo | `const` at the top level of a script |
13
+ | `$throttled(value, ms)` | the value, as a memo | `const` at the top level of a script |
14
+ | `$isPending(memo)` | `boolean` | Any expression |
15
+ | `$resolve(memo, options?)` | `Promise<T>` | A handler, an effect or a `$client` callback |
16
+ | `$isPassed(prop)` | `boolean` | `const` in the component script |
17
+ | `$isBound(prop)` | `boolean` | Any expression |
18
+ | `$effect(callback)` | `void` | Statement at the top level of a script |
19
+ | `$client(callback, trigger?)` | `void` | Statement at the top level of a script |
20
+ | `$untrack(value)` | the value | Any expression |
21
+ | `$produce(signal, recipe)` | `void` | Where a signal can be written |
22
+ | `$setContext(context, value)` | `void` | Statement at the top level of a script |
23
+ | `$getContext(context)` | the value | `const` at the top level of a script |
24
+ | `$route(path?)` | `{ url, search, params }` | `const` at the top level of a script |
25
+ | `$searchParam(name, options?)` | the value of the parameter | `let` at the top level of a script |
26
+ | `$navigation()` | `{ pending, from, to }` | `const` at the top level of a script |
27
+ | `$id()` | `string` | `const` at the top level of a script |
28
+ | `$title(value)` | `void` | Statement at the top level of a script |
29
+ | `$action(fn)` | the result, or `undefined` | `const` at the top level of a script |
30
+ | `$optimistic(source)` | the value of `source` | `let` at the top level of a script |
31
+ | `$handler(fn, ...args)` | a handler | Any expression of a script or a module function |
32
+ | `$bind(value, set?)` | a binding | The whole value of a prop, or of `value` or `checked` |
32
33
 
33
34
  ## What each one does
34
35
 
@@ -48,6 +49,7 @@ The compiler replaces each call and removes the import, so none of them ship. Im
48
49
  - `$setContext(context, value)`: gives a value of a context to the components inside. Create the context with `createContext` from `brumate/context`.
49
50
  - `$getContext(context)`: reads a context from the nearest component above that provides it, or its default.
50
51
  - `$route(path?)`: the current route, as `{ url, search, params }`. The path is the route, such as `'/posts/[id]'`, and takes at most one argument.
52
+ - `$searchParam(name, options?)`: a signal bound to one parameter of the query string. The server reads the URL, and a write in the browser changes it with `replaceState` (`{ history: 'push' }` for `pushState`) and asks the server nothing. Back and forward write the signal. Options: `default` (left out of the URL), `parse`, `serialize`, `history`, `server` (a write navigates). The name is a string literal.
51
53
  - `$navigation()`: the state of a navigation, as `{ pending, from, to }`. It takes no arguments.
52
54
  - `$id()`: an ID that is unique in the page and the same on the server and in the browser. It takes no arguments.
53
55
  - `$title(value)`: sets the title of the page. The compiler warns about it, and it will be removed: use `<title>` in `#head`. It takes one argument.
@@ -23,7 +23,7 @@
23
23
  ```
24
24
 
25
25
  - `<script>` runs once for each instance, on the server. `<script module>` runs once per module, and its exports can be imported.
26
- - `<style>` is scoped to the component. `lang="scss"` and `lang="less"` work.
26
+ - `<style>` is scoped to the component. `<style global>` is not: its rules apply to the whole page, such as `body` or `.toolbar button`, with no `:global(…)` around them. `lang="scss"` and `lang="less"` work in both. Both are top level only.
27
27
  - A file has at most one of each script. Markup can come before or after them.
28
28
  - Markup in a script, an expression or an attribute value is an error. Use a `#template`.
29
29