@supersoniks/concorde 4.5.2 → 4.7.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 (185) hide show
  1. package/.gitlab-ci.yml +23 -0
  2. package/README.md +106 -55
  3. package/ai/AGENTS.md +52 -0
  4. package/ai/README.md +30 -0
  5. package/ai/cursor/rules/concorde-menu.mdc +15 -0
  6. package/ai/cursor/rules/concorde-scope.mdc +14 -0
  7. package/ai/cursor/rules/concorde-theme.mdc +13 -0
  8. package/ai/cursor/rules/concorde.mdc +49 -0
  9. package/ai/jetbrains/rules/concorde.md +39 -0
  10. package/ai/skills/concorde/SKILL.md +220 -0
  11. package/ai/skills/concorde-get-set-dp/SKILL.md +194 -0
  12. package/ai/skills/concorde-imports/SKILL.md +78 -0
  13. package/ai/skills/concorde-menu/SKILL.md +74 -0
  14. package/ai/skills/concorde-scope/SKILL.md +70 -0
  15. package/ai/skills/concorde-theme/SKILL.md +46 -0
  16. package/build-infos.json +1 -1
  17. package/concorde-core.bundle.js +159 -159
  18. package/concorde-core.es.js +1915 -1809
  19. package/dist/altcha-widget.js +2662 -0
  20. package/dist/concorde-core.bundle.js +159 -159
  21. package/dist/concorde-core.es.js +1915 -1809
  22. package/dist/docs-mock-api-sw.js +589 -0
  23. package/dist/docs-mock-api-sw.js.map +7 -0
  24. package/docs/altcha-widget.js +2662 -0
  25. package/docs/assets/index-D9pxaQYK.js +7508 -0
  26. package/docs/assets/index-t0-i22oI.css +1 -0
  27. package/docs/docs-mock-api-sw.js +589 -0
  28. package/docs/docs-mock-api-sw.js.map +7 -0
  29. package/docs/index.html +2 -2
  30. package/docs/src/core/components/functional/fetch/fetch.md +13 -11
  31. package/docs/src/core/components/functional/if/if.md +4 -11
  32. package/docs/src/core/components/functional/list/list.md +60 -194
  33. package/docs/src/core/components/functional/queue/queue.md +70 -85
  34. package/docs/src/core/components/functional/router/router.md +62 -97
  35. package/docs/src/core/components/functional/states/states.md +2 -2
  36. package/docs/src/core/components/functional/submit/submit.md +86 -55
  37. package/docs/src/core/components/ui/captcha/captcha.md +2 -2
  38. package/docs/src/core/components/ui/card/card.md +1 -1
  39. package/docs/src/core/components/ui/form/checkbox/checkbox.md +5 -32
  40. package/docs/src/core/components/ui/form/input/input.md +5 -30
  41. package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
  42. package/docs/src/core/components/ui/form/radio/radio.md +5 -32
  43. package/docs/src/core/components/ui/form/select/select.md +5 -31
  44. package/docs/src/core/components/ui/form/switch/switch.md +5 -32
  45. package/docs/src/core/components/ui/loader/loader.md +1 -13
  46. package/docs/src/core/components/ui/table/table.md +3 -3
  47. package/docs/src/docs/_core-concept/dataFlow.md +73 -0
  48. package/docs/src/docs/_core-concept/subscriber.md +9 -10
  49. package/docs/src/docs/_decorators/ancestor-attribute.md +4 -3
  50. package/docs/src/docs/_decorators/auto-subscribe.md +19 -16
  51. package/docs/src/docs/_decorators/bind.md +20 -17
  52. package/docs/src/docs/_decorators/get.md +7 -4
  53. package/docs/src/docs/_decorators/handle.md +171 -0
  54. package/docs/src/docs/_decorators/on-assign.md +99 -73
  55. package/docs/src/docs/_decorators/publish.md +2 -1
  56. package/docs/src/docs/_decorators/subscribe.md +70 -9
  57. package/docs/src/docs/_decorators/wait-for-ancestors.md +13 -10
  58. package/docs/src/docs/_directives/sub.md +91 -0
  59. package/docs/src/docs/_getting-started/ai-agents.md +56 -0
  60. package/docs/src/docs/_getting-started/concorde-manual-install.md +133 -0
  61. package/docs/src/docs/_getting-started/concorde-outside.md +13 -123
  62. package/docs/src/docs/_getting-started/create-a-component.md +2 -0
  63. package/docs/src/docs/_getting-started/my-first-component.md +236 -0
  64. package/docs/src/docs/_getting-started/my-first-subscriber.md +29 -83
  65. package/docs/src/docs/_getting-started/pubsub.md +21 -134
  66. package/docs/src/docs/_getting-started/start.md +26 -18
  67. package/docs/src/docs/_misc/api-configuration.md +79 -0
  68. package/docs/src/docs/_misc/dataProviderKey.md +38 -5
  69. package/docs/src/docs/_misc/docs-mock-api.md +60 -0
  70. package/docs/src/docs/_misc/endpoint.md +2 -1
  71. package/docs/src/docs/_misc/html-integration.md +13 -0
  72. package/docs/src/docs/search/docs-search.json +4163 -873
  73. package/docs/src/tsconfig.json +380 -317
  74. package/gitlab/job_tests.sh +55 -0
  75. package/package.json +37 -3
  76. package/public/altcha-widget.js +2662 -0
  77. package/public/docs-mock-api-sw.js +589 -0
  78. package/public/docs-mock-api-sw.js.map +7 -0
  79. package/scripts/ai-init.mjs +167 -0
  80. package/scripts/docs-mock-api-vite-plugin.ts +116 -0
  81. package/scripts/docs-open-in-editor-plugin.ts +130 -0
  82. package/scripts/pre-publish.mjs +2 -1
  83. package/src/core/components/functional/example/example.ts +1 -1
  84. package/src/core/components/functional/fetch/fetch.md +13 -11
  85. package/src/core/components/functional/if/if.md +4 -11
  86. package/src/core/components/functional/list/list.demo.ts +4 -4
  87. package/src/core/components/functional/list/list.md +60 -194
  88. package/src/core/components/functional/list/list.ts +8 -7
  89. package/src/core/components/functional/queue/queue.demo.ts +1 -1
  90. package/src/core/components/functional/queue/queue.md +70 -85
  91. package/src/core/components/functional/queue/queue.ts +4 -4
  92. package/src/core/components/functional/router/router.md +62 -97
  93. package/src/core/components/functional/router/router.ts +1 -1
  94. package/src/core/components/functional/states/states.md +2 -2
  95. package/src/core/components/functional/submit/submit.md +86 -55
  96. package/src/core/components/functional/submit/submit.ts +10 -3
  97. package/src/core/components/ui/captcha/captcha.md +2 -2
  98. package/src/core/components/ui/card/card.md +1 -1
  99. package/src/core/components/ui/form/checkbox/checkbox.md +5 -32
  100. package/src/core/components/ui/form/input/input.md +5 -30
  101. package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
  102. package/src/core/components/ui/form/radio/radio.md +5 -32
  103. package/src/core/components/ui/form/select/select.md +5 -31
  104. package/src/core/components/ui/form/switch/switch.md +5 -32
  105. package/src/core/components/ui/loader/loader.md +1 -13
  106. package/src/core/components/ui/table/table.md +3 -3
  107. package/src/core/decorators/Subscriber.ts +2 -0
  108. package/src/core/decorators/subscriber/handle.disambig.spec.ts +20 -0
  109. package/src/core/decorators/subscriber/handle.skip.spec.ts +37 -0
  110. package/src/core/decorators/subscriber/handle.ts +128 -0
  111. package/src/core/decorators/subscriber/onAssign.ts +94 -4
  112. package/src/core/directives/DataProvider.sub.spec.ts +96 -0
  113. package/src/core/directives/DataProvider.ts +109 -40
  114. package/src/core/utils/PublisherProxy.ts +33 -18
  115. package/src/core/utils/dataProviderKey.ts +23 -0
  116. package/src/core/utils/publisherPathKey.spec.ts +58 -0
  117. package/src/decorators.ts +6 -0
  118. package/src/docs/_core-concept/dataFlow.md +73 -0
  119. package/src/docs/_core-concept/subscriber.md +9 -10
  120. package/src/docs/_decorators/ancestor-attribute.md +4 -3
  121. package/src/docs/_decorators/auto-subscribe.md +19 -16
  122. package/src/docs/_decorators/bind.md +20 -17
  123. package/src/docs/_decorators/get.md +7 -4
  124. package/src/docs/_decorators/handle.md +171 -0
  125. package/src/docs/_decorators/on-assign.md +99 -47
  126. package/src/docs/_decorators/publish.md +2 -1
  127. package/src/docs/_decorators/subscribe.md +70 -9
  128. package/src/docs/_decorators/wait-for-ancestors.md +13 -10
  129. package/src/docs/_directives/sub.md +91 -0
  130. package/src/docs/_getting-started/ai-agents.md +56 -0
  131. package/src/docs/_getting-started/concorde-manual-install.md +133 -0
  132. package/src/docs/_getting-started/concorde-outside.md +13 -123
  133. package/src/docs/_getting-started/create-a-component.md +2 -0
  134. package/src/docs/_getting-started/my-first-component.md +236 -0
  135. package/src/docs/_getting-started/my-first-subscriber.md +29 -83
  136. package/src/docs/_getting-started/pubsub.md +21 -134
  137. package/src/docs/_getting-started/start.md +26 -18
  138. package/src/docs/_misc/api-configuration.md +79 -0
  139. package/src/docs/_misc/dataProviderKey.md +38 -5
  140. package/src/docs/_misc/docs-mock-api.md +60 -0
  141. package/src/docs/_misc/endpoint.md +2 -1
  142. package/src/docs/_misc/html-integration.md +13 -0
  143. package/src/docs/code.ts +58 -12
  144. package/src/docs/components/docs-demo-sources.ts +397 -0
  145. package/src/docs/components/docs-lit-demo-raw.ts +28 -0
  146. package/src/docs/components/docs-lit-demo.ts +166 -0
  147. package/src/docs/components/docs-source-link.ts +72 -0
  148. package/src/docs/docs-location.ts +54 -0
  149. package/src/docs/docs.ts +12 -0
  150. package/src/docs/example/decorators-demo-bind-demos.ts +41 -46
  151. package/src/docs/example/decorators-demo-geo.ts +16 -11
  152. package/src/docs/example/decorators-demo-init.ts +2 -228
  153. package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +142 -12
  154. package/src/docs/example/decorators-demo.ts +71 -70
  155. package/src/docs/example/docs-api-config-demos.ts +234 -0
  156. package/src/docs/example/docs-joke-demos.ts +297 -0
  157. package/src/docs/example/docs-list-demos.ts +179 -0
  158. package/src/docs/example/docs-provider-keys.ts +315 -0
  159. package/src/docs/example/docs-queue-demos.ts +114 -0
  160. package/src/docs/example/docs-router-demos.ts +89 -0
  161. package/src/docs/example/docs-submit-demos.ts +455 -0
  162. package/src/docs/example/docs-toggle-demos.ts +73 -0
  163. package/src/docs/example/docs-user-two-scopes.ts +37 -0
  164. package/src/docs/example/docs-users-list.ts +71 -0
  165. package/src/docs/example/users.ts +41 -24
  166. package/src/docs/mock-api/api-config-mock.ts +152 -0
  167. package/src/docs/mock-api/fixtures.ts +377 -0
  168. package/src/docs/mock-api/register.ts +25 -0
  169. package/src/docs/mock-api/router.ts +234 -0
  170. package/src/docs/mock-api/service-worker.ts +23 -0
  171. package/src/docs/mock-api/urls.ts +11 -0
  172. package/src/docs/navigation/navigation.ts +43 -7
  173. package/src/docs/search/docs-search.json +4193 -858
  174. package/src/docs/search/markdown-renderer.ts +7 -3
  175. package/src/docs/search/page.ts +11 -14
  176. package/src/docs/search/sonic-code-markdown.spec.ts +29 -0
  177. package/src/docs/search/sonic-code-markdown.ts +28 -0
  178. package/src/docs.ts +4 -0
  179. package/src/tsconfig.json +96 -0
  180. package/src/tsconfig.tsbuildinfo +1 -1
  181. package/vite.config.mts +8 -0
  182. package/docs/assets/index-CaysOMFz.js +0 -5046
  183. package/docs/assets/index-D8mGoXzF.css +0 -1
  184. package/docs/src/docs/_misc/templates-demo.md +0 -19
  185. package/src/docs/_misc/templates-demo.md +0 -19
@@ -1,39 +1,47 @@
1
1
  # Introduction
2
2
 
3
- ## What is Concorde ?
3
+ ## What is Concorde?
4
4
 
5
- Based on **[lit.dev](https://lit.dev)**, Concorde is a collection of webcomponents made to build shared apps or websites.
6
- Develop user interfaces without thinking about the implementation context, where everything is scoped, but preserving graphic consistency by setting the strict minimum of css variables.
5
+ Based on **[lit.dev](https://lit.dev)**, Concorde is a collection of web components for shared apps and websites.
6
+ Build UIs without tying components to a specific host stack, while keeping visual consistency through a small set of CSS variables.
7
7
 
8
8
  ## Why and use case
9
9
 
10
- In 2022, Supersoniks wanted to create a new version of his ticketing app, in production un nearly 100 websites. We needed shared components which could be implemented in mobile apps, modern websites, and also old ones made in php, without bundlers or whatever.
11
- Instead of building a new app for each type of project, which would become impossible to maintain, we've decided to create one app, composed by a few webcomponents wich could easily be recomposed on any website.
12
- Webcomponents appeared to be a the perfect solution to guarantee that compatibility with all past, present and futures environment, and lit seemed to be the best choice to build them.
10
+ In 2022, Supersoniks needed a new ticketing stack for nearly 100 sites mobile apps, modern sites, and legacy PHP without bundlers.
11
+ One composable web-component library replaced many one-off apps. Lit was chosen for broad runtime compatibility.
13
12
 
14
13
  ### Stack
15
14
 
16
15
  * Lit
17
- * Typescript
16
+ * TypeScript
18
17
  * Vite
19
- * Tailwind, not in the core, but in the starter kit
18
+ * Tailwind (starter kit, not required in the core package)
20
19
 
21
- ### Functionnal features and components
20
+ ### Functional features
22
21
 
23
- * Data management with Publisher / Subscriber pattern
24
- * Form management
25
- * Fetching data, lists, queue with lazyload
26
- * Data binding
27
- * Simple router, state component, ...
28
- * And all ui component, with status variants to build an app with a consistent design
22
+ * **DataProvider** store (decorators, `get` / `set`)
23
+ * Forms (`formDataProvider`)
24
+ * Lists, queues, lazy loading
25
+ * Router, states, UI kit with status variants
29
26
 
27
+ ## Learn Concorde
30
28
 
31
- ## Start a new project easily
29
+ | Step | Page |
30
+ |------|------|
31
+ | 1 | [My first component](#docs/_getting-started/my-first-component.md/my-first-component) — Lit card, `@ancestorAttribute`, `@bind`, mock API |
32
+ | 2 | [Data flow](#docs/_core-concept/dataFlow.md/dataFlow) — Core concepts: decorators and APIs |
33
+ | 3 | [Local API demos](#docs/_misc/docs-mock-api.md/docs-mock-api) — offline `serviceURL` for this site (Misc) |
34
+ | 4 | [create-concorde-ts-starter](https://www.npmjs.com/package/@supersoniks/create-concorde-ts-starter) — **recommended** project kit (Vite, Tailwind, `yarn ai:sync`) |
35
+ | 5 | [AI agents (skills)](#docs/_getting-started/ai-agents.md/ai-agents) — `AGENTS.md`, Cursor / JetBrains rules |
32
36
 
33
- A new project with Vite, Typescript and Tailwind already configured and a simple example of a subscriber component :
37
+ Legacy (Subscriber mixin, Publisher API): **Legacy** section at the bottom of the sidebar.
38
+
39
+ ## Start a new project
34
40
 
35
41
  <sonic-code language="bash">
36
42
  <template>
37
- npx @supersoniks/create-concorde-ts-starter "project_name"
43
+ npx @supersoniks/create-concorde-ts-starter "project_name"
38
44
  </template>
39
45
  </sonic-code>
46
+
47
+ The starter runs **`yarn ai:sync`** for you. Details: [AI agents (skills)](#docs/_getting-started/ai-agents.md/ai-agents). Manual Vite setup: [Legacy: Manual installation](#docs/_getting-started/concorde-manual-install.md/concorde-manual-install).
@@ -0,0 +1,79 @@
1
+ # API configuration
2
+
3
+ `APIConfiguration` is the object built by [`HTML.getApiConfiguration`](../../core/utils/HTML.ts) from **ancestor attributes** on the DOM (or from a typed publisher — see [@get configuration key](#docs/_decorators/get.md/get)). It is passed to [`API`](../../core/utils/api.ts) by fetchers, **sonic-submit**, the **`wording()`** directive, and **`@get`**.
4
+
5
+ > **Mock service:** same [Local API demos](#docs/_misc/docs-mock-api.md/docs-mock-api) Service Worker / Vite middleware. Routes used on this page are listed in the [API config routes](#api-config-routes) section below.
6
+
7
+ ## Attribute map
8
+
9
+ | Attribute (ancestor) | `APIConfiguration` field | Role |
10
+ |---------------------|---------------------------|------|
11
+ | `serviceURL` | `serviceURL` | Base URL (e.g. `/docs-mock-api`) |
12
+ | `token` | `token` | Static Bearer sent on REST calls |
13
+ | `userName` / `password` | `userName` / `password` | Basic auth for **tokenProvider** fetch only |
14
+ | `eventsApiToken` | `authToken` | Bearer for **tokenProvider** when no Basic |
15
+ | `tokenProvider` | `tokenProvider` | Path to GET a new token (`{ token }` JSON) |
16
+ | `wordingProvider` | — (read by `wording()`) | Base path + query for label batch GET |
17
+ | `wordingVersionProvider` | — | Publisher id; bump version → reload wordings |
18
+ | `credentials` | `credentials` | `fetch` credentials mode |
19
+ | `addHTTPResponse` | `addHTTPResponse` | Attach `_sonic_http_response_` on result |
20
+ | `cache` | `cache` | `fetch` cache mode |
21
+ | `blockUntilDone` | `blockUntilDone` | Serialize calls per `serviceURL` |
22
+ | `keepAlive` | `keepAlive` | `fetch` keepalive |
23
+
24
+ **Lit / TypeScript:** store the same shape in a publisher and pass `DataProviderKey<APIConfiguration>` as the second argument of `@get` (see [DataProviderKey](#docs/_misc/dataProviderKey.md/dataProviderKey)).
25
+
26
+ ## Bearer token (static)
27
+
28
+ Publisher `docsApiConfBearerKey` (`set(docsApiConfBearerKey, { token: "docs-mock-valid-token", … })`) — mock returns the protected payload.
29
+
30
+ <docs-lit-demo for="docs-api-config-bearer-demo"></docs-lit-demo>
31
+
32
+ ## tokenProvider + Basic auth
33
+
34
+ No static `token`: `API.auth()` calls `GET /docs-mock-api/auth/token` with Basic **demo** / **secret**, stores `token`, then calls the protected route.
35
+
36
+ <docs-lit-demo for="docs-api-config-token-provider-demo"></docs-lit-demo>
37
+
38
+ ## HTTP 498 — stale token refresh
39
+
40
+ Initial `token="docs-mock-stale-token"` → mock responds **498** → Concorde invalidates the token, runs `auth()` again (same `tokenProvider` + Basic), retries with `docs-mock-fresh-token`.
41
+
42
+ <docs-lit-demo for="docs-api-config-stale-token-demo"></docs-lit-demo>
43
+
44
+ ## eventsApiToken
45
+
46
+ Attribute **`eventsApiToken`** on an ancestor maps to **`authToken`** in config (used as Bearer when calling `tokenProvider`, instead of Basic).
47
+
48
+ <docs-lit-demo for="docs-api-config-events-token-demo"></docs-lit-demo>
49
+
50
+ ## Wording API
51
+
52
+ `wordingProvider="wording/labels?lang=fr"` + `wording('api-config.greeting')` in Lit. Mock returns label map from `labels[]` query params.
53
+
54
+ <docs-lit-demo for="docs-api-config-wording-demo"></docs-lit-demo>
55
+
56
+ ## Scoped attributes (HTML / sonic-scope)
57
+
58
+ Attributes on **`sonic-scope`** (or any ancestor) are visible to descendants via `getAncestorAttributeValue`.
59
+
60
+ <docs-lit-demo for="docs-api-config-scoped-attrs-demo"></docs-lit-demo>
61
+
62
+ ## API config routes
63
+
64
+ | Route | Demo |
65
+ |-------|------|
66
+ | `GET /docs-mock-api/auth/token` | tokenProvider, eventsApiToken |
67
+ | `GET /docs-mock-api/api/config/protected` | Bearer / Basic / 498 |
68
+ | `GET /docs-mock-api/wording/labels?labels[]=…&lang=fr` | `wording()` |
69
+
70
+ Mock tokens (doc only): `docs-mock-valid-token`, `docs-mock-stale-token` (498), `docs-mock-fresh-token` (after refresh). Basic: **demo** / **secret**. Events token: `docs-mock-events-token`.
71
+
72
+ Implementation: `src/docs/mock-api/api-config-mock.ts` (bundled in the Service Worker with `router.ts`).
73
+
74
+ ## See also
75
+
76
+ - [@get](#docs/_decorators/get.md/get) — `APIConfiguration` + `Endpoint`
77
+ - [Endpoint](#docs/_misc/endpoint.md/endpoint) — typed path
78
+ - [Local API demos](#docs/_misc/docs-mock-api.md/docs-mock-api) — offline `serviceURL`
79
+ - [Fetch](#core/components/functional/fetch/fetch.md/fetch) — attribute table (legacy sonic-fetch)
@@ -2,12 +2,26 @@
2
2
 
3
3
  The `DataProviderKey<T>` utility provides type-safe navigation through composite data structures. Each property or index access extends the path, and the final key can be retrieved via `toString()` or the `path` property.
4
4
 
5
- For a **single HTTP path string** (no dot-syntax), see [Endpoint](#docs/_misc/endpoint.md/endpoint).
5
+ For a **single HTTP path string** (no dot-syntax), see [Endpoint](#docs/_misc/endpoint.md/endpoint). For **`DataProviderKey<APIConfiguration>`**, see [API configuration](#docs/_misc/api-configuration.md/api-configuration).
6
6
 
7
7
  ## Principle
8
8
 
9
9
  `DataProviderKey` uses a Proxy to intercept property access and build a cumulative path string. TypeScript infers the nested type at each level, so `myKey.items[0]` is correctly typed as `DataProviderKey<Item>` when `items` is `Item[]`.
10
10
 
11
+ In Lit demos, bind HTML attributes from a key’s **`.path`** (single source of truth), and use **`get` / `set` / `dp`** instead of `PublisherManager.get("…")`:
12
+
13
+ <sonic-code language="typescript">
14
+ <template>
15
+ import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
16
+ import { get, set } from "@supersoniks/concorde/utils";
17
+
18
+ export const myFormKey = new DataProviderKey&lt;{ email: string }&gt;("myForm");
19
+ set(myFormKey, { email: "a@b.c" });
20
+
21
+ // template: formDataProvider=${myFormKey.path}
22
+ </template>
23
+ </sonic-code>
24
+
11
25
  ## Usage
12
26
 
13
27
  ### Import
@@ -77,6 +91,25 @@ user: User | null = null;
77
91
  </template>
78
92
  </sonic-code>
79
93
 
94
+ Dynamic keys are **not** supported by `get`, `set`, or `dp` — those APIs take a snapshot at call time with no component context. For dynamic paths use decorators (`@subscribe`, `@publish`, `@handle`) or **`sub(key)`** in Lit templates (resolves `${…}` from the host component). See [sub()](#docs/_directives/sub.md/sub).
95
+
96
+ ### get / set / dp with static keys
97
+
98
+ For programmatic access, pass a `DataProviderKey` or a static path string. Dynamic placeholders are rejected:
99
+
100
+ <sonic-code language="typescript">
101
+ <template>
102
+ import { dp, get, set } from "@supersoniks/concorde/utils";
103
+ import { DataProviderKey } from "@supersoniks/concorde/dataProviderKey";
104
+ //
105
+ const counterKey = new DataProviderKey&lt;{ count: number }&gt;("myCounter");
106
+ //
107
+ set(counterKey, { count: 0 });
108
+ dp(counterKey.count).set(1);
109
+ get(counterKey); // snapshot: { count: 1 }
110
+ </template>
111
+ </sonic-code>
112
+
80
113
  ## Path retrieval
81
114
 
82
115
  The final path is built by concatenating each accessed property with a dot:
@@ -97,13 +130,13 @@ const pathProp = key.path; // "data.count"
97
130
 
98
131
  ## Use cases
99
132
 
100
- - **Type-safe bindings**: paths for `@bind`, `@subscribe`, `@publish`
133
+ - **Type-safe bindings**: paths for `@bind`, `@subscribe`, `@publish`, `@handle`
101
134
  - **Dynamic paths**: reusable keys with `${...}` placeholders
102
135
  - **Form fields**: form data paths with compile-time checking
103
136
 
104
- ## Integration with @subscribe and @publish
137
+ ## Integration with @subscribe, @publish and @handle
105
138
 
106
- Use `DataProviderKey` with `@subscribe` (read-only) or `@publish` (write-only). The decorated property **must** match the key’s value type:
139
+ Use `DataProviderKey` with `@subscribe` (read-only), `@publish` (write-only), or `@handle` (method callback on assign). With `@subscribe` / `@publish`, the decorated property **must** match the key’s value type. With `@handle`, the method receives `(value: T)`.
107
140
 
108
141
  <sonic-code language="typescript">
109
142
  <template>
@@ -126,7 +159,7 @@ export class UserForm extends LitElement {
126
159
  </template>
127
160
  </sonic-code>
128
161
 
129
- Both decorators support dynamic paths: `"base.${prop}"` in the constructor. A wrong property type (e.g. `number` for `DataProviderKey<string>`) is a TypeScript error.
162
+ These decorators support dynamic paths: `"base.${prop}"` in the constructor. A wrong property type (e.g. `number` for `DataProviderKey<string>`) is a TypeScript error. See [@handle](#docs/_decorators/handle.md/handle) for method callbacks.
130
163
 
131
164
  ## Notes
132
165
 
@@ -0,0 +1,60 @@
1
+ # Local API demos (offline)
2
+
3
+ The Concorde doc site does not call fragile third-party APIs during `yarn dev`. A **Service Worker** and the Vite dev middleware serve **`/docs-mock-api/*`** on the same origin.
4
+
5
+ ## How it works
6
+
7
+ 1. On load, `registerDocsMockApiServiceWorker()` registers `/docs-mock-api-sw.js`.
8
+ 2. Requests to `/docs-mock-api/...` are handled by the SW (production build) or Vite middleware (dev).
9
+ 3. Live examples use `serviceURL="/docs-mock-api"` and relative paths.
10
+
11
+ TypeScript constants: `src/docs/mock-api/urls.ts` (`DOCS_MOCK_REQRES_SERVICE`, `DOCS_MOCK_GEO_SERVICE`, …).
12
+
13
+ ## Routes
14
+
15
+ | Path | Used in |
16
+ |------|---------|
17
+ | `/docs-mock-api/api/users` | `sonic-list`, `sonic-fetch`, `sonic-queue` (users) |
18
+ | `/docs-mock-api/api/users/:id` | Single user, `docs-user` |
19
+ | `POST /docs-mock-api/api/register` | **sonic-submit** — JSON, `multipart/form-data` (`sendAsFormData`), or `application/x-www-form-urlencoded` (native `<form>`); response includes parsed `email` + `token` |
20
+ | `POST /docs-mock-api/api/register/nested` | Wrapped body `{ data: { id, token } }` for `submit-result-key` demo |
21
+ | `GET /docs-mock-api/api/register/echo` | Echoes query string (`method="get"` on submit) |
22
+ | `GET /docs-mock-api/auth/token` | [API configuration](#docs/_misc/api-configuration.md/api-configuration) — tokenProvider (Basic or `eventsApiToken`) |
23
+ | `GET /docs-mock-api/api/config/protected` | Bearer / Basic; `docs-mock-stale-token` → **498** |
24
+ | `GET /docs-mock-api/wording/labels` | Wording batch (`labels[]`, `lang`) |
25
+ | `/docs-mock-api/geo/communes` | Geo list, `@get` demos |
26
+ | `/docs-mock-api/jokes/joke/:category` | JokeAPI-shaped list (`key="jokes"` on queue/list) |
27
+
28
+ ### Filtres `GET /jokes/joke/…`
29
+
30
+ | Query | Meaning |
31
+ |-------|---------|
32
+ | `amount` | Max jokes per request when not using `offset` |
33
+ | `offset` + `limit` / `per_page` | Pagination for **sonic-queue** lazy load |
34
+ | `contains` | Substring on joke text, setup/delivery, categories (**input** demo, `name="contains"`) |
35
+ | `lang` | `fr` or `en` — filters the local dataset (**select** demo, `name="lang"`) |
36
+ | `blacklistFlags` | Comma-separated flags to **exclude** (`nsfw`, `religious`, `political`, `racist`, `sexist`, `explicit`) — checkbox/radio/switch « Remove following jokes » demos; each joke has matching `flags` in fixtures |
37
+
38
+ ### Pagination `GET /api/users`
39
+
40
+ | Query | Meaning |
41
+ |-------|---------|
42
+ | `offset` + `per_page` | Index-based slice on the filtered set — **sonic-queue** (`offset=$offset&per_page=$limit`) |
43
+ | `page` + `per_page` | 1-based page — static fetch examples (`?page=2`) |
44
+ | `limit` | Alias of `per_page` |
45
+ | `q` | Search on first name, last name, email (optional; **sonic-queue** + `dataFilterProvider`, field `name="q"`) |
46
+
47
+ **ALTCHA** (`sonic-captcha`) is **not** mocked — it still uses the Supersoniks service.
48
+
49
+ In TypeScript demos, import from `src/docs/mock-api/urls.ts` (e.g. `DOCS_MOCK_REQRES_SERVICE` on `serviceURL`).
50
+
51
+ ## Source files
52
+
53
+ - `src/docs/mock-api/` — router, fixtures, service worker, `urls.ts`
54
+ - `scripts/docs-mock-api-vite-plugin.ts` — SW build + middleware
55
+ - `public/docs-mock-api-sw.js` — generated on `yarn dev` / `yarn build-docs`
56
+
57
+ ```bash
58
+ yarn dev # mock API on by default
59
+ yarn build-docs # includes SW bundle
60
+ ```
@@ -18,7 +18,7 @@ import { Endpoint } from "@supersoniks/concorde/utils/endpoint";
18
18
  <template>
19
19
  const users = new Endpoint&lt;User[]&gt;("users?limit=10");
20
20
  users.path; // "users?limit=10"
21
- //
21
+
22
22
  const one = new Endpoint&lt;User, { userId: string }&gt;("users/${userId}");
23
23
  // `userId` on the host class is observed when used with @get
24
24
  </template>
@@ -38,5 +38,6 @@ const one = new Endpoint&lt;User, { userId: string }&gt;("users/${userId}");
38
38
 
39
39
  ## See also
40
40
 
41
+ - [API configuration](#docs/_misc/api-configuration.md/api-configuration) — `serviceURL`, token, wording (mock demos)
41
42
  - [@get](#docs/_decorators/get.md/get) — decorator that uses `Endpoint<T>`
42
43
  - [DataProviderKey](#docs/_misc/dataProviderKey.md/dataProviderKey) — typed publisher paths (dot notation)
@@ -0,0 +1,13 @@
1
+ # HTML integration (no Lit)
2
+
3
+ Some hosts (legacy PHP pages, static HTML) embed Concorde components **without** a Lit build step. They can use HTML attributes such as **`data-bind`**, **`dataProvider`**, and **`formDataProvider`** on tags directly in the page.
4
+
5
+ That style is **not** what we demonstrate in this doc site: live examples are **Lit components** under `src/docs/example/`, registered once and reused from Markdown via tags like `<docs-joke-search-demo>`.
6
+
7
+ | Goal | Use |
8
+ |------|-----|
9
+ | Learn modern patterns | [My first component](#docs/_getting-started/my-first-component.md/my-first-component), [Data flow](#docs/_core-concept/dataFlow.md/dataFlow) |
10
+ | Author doc examples | `<docs-lit-demo>` + `src/docs/example/*.ts` — see [My first component](#docs/_getting-started/my-first-component.md/my-first-component) |
11
+ | Embed in plain HTML only | `data-bind` / Subscriber docs in **Legacy** — [Subscriber mixin](#docs/_core-concept/subscriber.md/subscriber) |
12
+
13
+ New application code in TypeScript should use **`@subscribe`**, **`formDataProvider` + `name`**, and Lit templates — not HTML `data-bind`.
package/src/docs/code.ts CHANGED
@@ -27,7 +27,7 @@ export class DocsCode extends LitElement {
27
27
  css`
28
28
  :host(:not([inline])) {
29
29
  display: block;
30
- margin: 1rem 0;
30
+ margin: 1.1rem 0;
31
31
  }
32
32
 
33
33
  :host([inline]) {
@@ -84,6 +84,11 @@ export class DocsCode extends LitElement {
84
84
  //States
85
85
  @state() codeEdited = false;
86
86
 
87
+ /** Aperçu live uniquement pour les blocs markup (évite d’injecter du HTML depuis des exemples JS). */
88
+ private get rendersLiveOutput(): boolean {
89
+ return this.language === "markup" && !this.noOutput;
90
+ }
91
+
87
92
  // createRenderRoot() {
88
93
  // return this;
89
94
  // }
@@ -95,10 +100,7 @@ export class DocsCode extends LitElement {
95
100
  }
96
101
 
97
102
  this.templateEl = this.querySelector("template");
98
- this.defaultCode = this.templateEl?.innerHTML
99
- .toString()
100
- .replace(/&lt;/g, "<")
101
- .replace(/&gt;/g, ">");
103
+ this.defaultCode = this.readTemplateSourceCode();
102
104
 
103
105
  if (this.defaultCode) {
104
106
  Prism.plugins.NormalizeWhitespace.setDefaults({
@@ -120,11 +122,40 @@ export class DocsCode extends LitElement {
120
122
  this.currentCode = Prism.highlight(
121
123
  normalizedCode,
122
124
  Prism.languages[this.language],
123
- this.language
125
+ this.language,
124
126
  );
125
127
  }
126
128
 
127
- this.codeOutput = this.defaultCode;
129
+ if (this.rendersLiveOutput) {
130
+ this.codeOutput = this.defaultCode;
131
+ } else {
132
+ this.removeOutputSlot();
133
+ }
134
+ }
135
+
136
+ private decodeTemplateEntities(html: string): string {
137
+ return html
138
+ .replace(/&lt;/g, "<")
139
+ .replace(/&gt;/g, ">")
140
+ .replace(/&amp;/g, "&");
141
+ }
142
+
143
+ /**
144
+ * Markup demos: serialized HTML for the live preview.
145
+ * TS/JS with Lit `html\`…\``: browser parses tags in &lt;template&gt; — use innerHTML
146
+ * when the fragment has elements; otherwise textContent (imports, types, etc.).
147
+ */
148
+ private readTemplateSourceCode(): string {
149
+ const template = this.templateEl;
150
+ if (!template) return "";
151
+
152
+ if (this.language === "markup") {
153
+ return this.decodeTemplateEntities(template.innerHTML);
154
+ }
155
+
156
+ // TS/JS/bash/json: never use innerHTML — the browser parses tags in <template>
157
+ // (e.g. <sonic-button> in Lit examples) and the source would be truncated.
158
+ return template.content.textContent ?? "";
128
159
  }
129
160
 
130
161
  updateCodeRender() {
@@ -143,11 +174,13 @@ export class DocsCode extends LitElement {
143
174
  this.currentCode = Prism.highlight(
144
175
  this.defaultCode || "",
145
176
  Prism.languages[this.language],
146
- this.language
177
+ this.language,
147
178
  );
148
179
  });
149
180
  }
150
- this.codeOutput = this.defaultCode;
181
+ if (this.rendersLiveOutput) {
182
+ this.codeOutput = this.defaultCode;
183
+ }
151
184
  }
152
185
 
153
186
  handleToggleCode() {
@@ -155,8 +188,9 @@ export class DocsCode extends LitElement {
155
188
  }
156
189
 
157
190
  handleCopyCode(e: Event) {
158
- if (this.codeOutput) {
159
- navigator.clipboard.writeText(this.codeOutput);
191
+ const text = this.codeOutput ?? this.defaultCode;
192
+ if (text) {
193
+ navigator.clipboard.writeText(text);
160
194
  const button = e.currentTarget as HTMLButtonElement;
161
195
  button?.setAttribute("active", "");
162
196
  setTimeout(() => {
@@ -167,12 +201,24 @@ export class DocsCode extends LitElement {
167
201
 
168
202
  updated(changedProperties: PropertyValues) {
169
203
  super.updated(changedProperties);
170
- if (changedProperties.has("codeOutput")) {
204
+ if (
205
+ changedProperties.has("codeOutput") ||
206
+ changedProperties.has("language") ||
207
+ changedProperties.has("noOutput")
208
+ ) {
171
209
  this.appendOutput();
172
210
  }
173
211
  }
174
212
 
213
+ removeOutputSlot() {
214
+ this.querySelector("[slot=output]")?.remove();
215
+ }
216
+
175
217
  appendOutput() {
218
+ if (!this.rendersLiveOutput) {
219
+ this.removeOutputSlot();
220
+ return;
221
+ }
176
222
  let output = this.querySelector("[slot=output]") as HTMLElement;
177
223
  if (!output) {
178
224
  output = document.createElement("div");