@supersoniks/concorde 4.6.0 → 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.
- package/.gitlab-ci.yml +23 -0
- package/README.md +106 -55
- package/ai/AGENTS.md +52 -0
- package/ai/README.md +30 -0
- package/ai/cursor/rules/concorde-menu.mdc +15 -0
- package/ai/cursor/rules/concorde-scope.mdc +14 -0
- package/ai/cursor/rules/concorde-theme.mdc +13 -0
- package/ai/cursor/rules/concorde.mdc +49 -0
- package/ai/jetbrains/rules/concorde.md +39 -0
- package/ai/skills/concorde/SKILL.md +220 -0
- package/ai/skills/concorde-get-set-dp/SKILL.md +194 -0
- package/ai/skills/concorde-imports/SKILL.md +78 -0
- package/ai/skills/concorde-menu/SKILL.md +74 -0
- package/ai/skills/concorde-scope/SKILL.md +70 -0
- package/ai/skills/concorde-theme/SKILL.md +46 -0
- package/build-infos.json +1 -1
- package/concorde-core.bundle.js +127 -127
- package/concorde-core.es.js +1435 -1364
- package/dist/altcha-widget.js +2662 -0
- package/dist/concorde-core.bundle.js +127 -127
- package/dist/concorde-core.es.js +1435 -1364
- package/dist/docs-mock-api-sw.js +589 -0
- package/dist/docs-mock-api-sw.js.map +7 -0
- package/docs/altcha-widget.js +2662 -0
- package/docs/assets/index-D9pxaQYK.js +7508 -0
- package/docs/assets/index-t0-i22oI.css +1 -0
- package/docs/docs-mock-api-sw.js +589 -0
- package/docs/docs-mock-api-sw.js.map +7 -0
- package/docs/index.html +2 -2
- package/docs/src/core/components/functional/fetch/fetch.md +13 -11
- package/docs/src/core/components/functional/if/if.md +4 -11
- package/docs/src/core/components/functional/list/list.md +60 -194
- package/docs/src/core/components/functional/queue/queue.md +70 -85
- package/docs/src/core/components/functional/router/router.md +62 -97
- package/docs/src/core/components/functional/states/states.md +2 -2
- package/docs/src/core/components/functional/submit/submit.md +86 -55
- package/docs/src/core/components/ui/captcha/captcha.md +2 -2
- package/docs/src/core/components/ui/card/card.md +1 -1
- package/docs/src/core/components/ui/form/checkbox/checkbox.md +5 -32
- package/docs/src/core/components/ui/form/input/input.md +5 -30
- package/docs/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
- package/docs/src/core/components/ui/form/radio/radio.md +5 -32
- package/docs/src/core/components/ui/form/select/select.md +5 -31
- package/docs/src/core/components/ui/form/switch/switch.md +5 -32
- package/docs/src/core/components/ui/loader/loader.md +1 -13
- package/docs/src/core/components/ui/table/table.md +3 -3
- package/docs/src/docs/_core-concept/dataFlow.md +73 -0
- package/docs/src/docs/_core-concept/subscriber.md +9 -10
- package/docs/src/docs/_decorators/ancestor-attribute.md +4 -3
- package/docs/src/docs/_decorators/auto-subscribe.md +19 -16
- package/docs/src/docs/_decorators/bind.md +20 -17
- package/docs/src/docs/_decorators/get.md +7 -4
- package/docs/src/docs/_decorators/handle.md +171 -0
- package/docs/src/docs/_decorators/on-assign.md +99 -73
- package/docs/src/docs/_decorators/publish.md +2 -1
- package/docs/src/docs/_decorators/subscribe.md +70 -9
- package/docs/src/docs/_decorators/wait-for-ancestors.md +13 -10
- package/docs/src/docs/_directives/sub.md +91 -0
- package/docs/src/docs/_getting-started/ai-agents.md +56 -0
- package/docs/src/docs/_getting-started/concorde-manual-install.md +133 -0
- package/docs/src/docs/_getting-started/concorde-outside.md +13 -123
- package/docs/src/docs/_getting-started/create-a-component.md +2 -0
- package/docs/src/docs/_getting-started/my-first-component.md +236 -0
- package/docs/src/docs/_getting-started/my-first-subscriber.md +29 -83
- package/docs/src/docs/_getting-started/pubsub.md +21 -134
- package/docs/src/docs/_getting-started/start.md +26 -18
- package/docs/src/docs/_misc/api-configuration.md +79 -0
- package/docs/src/docs/_misc/dataProviderKey.md +38 -5
- package/docs/src/docs/_misc/docs-mock-api.md +60 -0
- package/docs/src/docs/_misc/endpoint.md +2 -1
- package/docs/src/docs/_misc/html-integration.md +13 -0
- package/docs/src/docs/search/docs-search.json +4163 -873
- package/docs/src/tsconfig.json +380 -317
- package/gitlab/job_tests.sh +55 -0
- package/package.json +34 -3
- package/public/altcha-widget.js +2662 -0
- package/public/docs-mock-api-sw.js +589 -0
- package/public/docs-mock-api-sw.js.map +7 -0
- package/scripts/ai-init.mjs +167 -0
- package/scripts/docs-mock-api-vite-plugin.ts +116 -0
- package/scripts/docs-open-in-editor-plugin.ts +130 -0
- package/scripts/pre-publish.mjs +2 -1
- package/src/core/components/functional/example/example.ts +1 -1
- package/src/core/components/functional/fetch/fetch.md +13 -11
- package/src/core/components/functional/if/if.md +4 -11
- package/src/core/components/functional/list/list.demo.ts +4 -4
- package/src/core/components/functional/list/list.md +60 -194
- package/src/core/components/functional/list/list.ts +8 -7
- package/src/core/components/functional/queue/queue.demo.ts +1 -1
- package/src/core/components/functional/queue/queue.md +70 -85
- package/src/core/components/functional/queue/queue.ts +4 -4
- package/src/core/components/functional/router/router.md +62 -97
- package/src/core/components/functional/router/router.ts +1 -1
- package/src/core/components/functional/states/states.md +2 -2
- package/src/core/components/functional/submit/submit.md +86 -55
- package/src/core/components/functional/submit/submit.ts +10 -3
- package/src/core/components/ui/captcha/captcha.md +2 -2
- package/src/core/components/ui/card/card.md +1 -1
- package/src/core/components/ui/form/checkbox/checkbox.md +5 -32
- package/src/core/components/ui/form/input/input.md +5 -30
- package/src/core/components/ui/form/input-autocomplete/input-autocomplete.md +6 -4
- package/src/core/components/ui/form/radio/radio.md +5 -32
- package/src/core/components/ui/form/select/select.md +5 -31
- package/src/core/components/ui/form/switch/switch.md +5 -32
- package/src/core/components/ui/loader/loader.md +1 -13
- package/src/core/components/ui/table/table.md +3 -3
- package/src/core/directives/DataProvider.sub.spec.ts +96 -0
- package/src/core/directives/DataProvider.ts +109 -40
- package/src/core/utils/PublisherProxy.ts +33 -18
- package/src/core/utils/dataProviderKey.ts +23 -0
- package/src/core/utils/publisherPathKey.spec.ts +58 -0
- package/src/docs/_core-concept/dataFlow.md +73 -0
- package/src/docs/_core-concept/subscriber.md +9 -10
- package/src/docs/_decorators/ancestor-attribute.md +4 -3
- package/src/docs/_decorators/auto-subscribe.md +19 -16
- package/src/docs/_decorators/bind.md +19 -16
- package/src/docs/_decorators/get.md +7 -4
- package/src/docs/_decorators/handle.md +15 -13
- package/src/docs/_decorators/on-assign.md +53 -53
- package/src/docs/_decorators/publish.md +2 -1
- package/src/docs/_decorators/subscribe.md +70 -9
- package/src/docs/_decorators/wait-for-ancestors.md +13 -10
- package/src/docs/_directives/sub.md +91 -0
- package/src/docs/_getting-started/ai-agents.md +56 -0
- package/src/docs/_getting-started/concorde-manual-install.md +133 -0
- package/src/docs/_getting-started/concorde-outside.md +13 -123
- package/src/docs/_getting-started/create-a-component.md +2 -0
- package/src/docs/_getting-started/my-first-component.md +236 -0
- package/src/docs/_getting-started/my-first-subscriber.md +29 -83
- package/src/docs/_getting-started/pubsub.md +21 -134
- package/src/docs/_getting-started/start.md +26 -18
- package/src/docs/_misc/api-configuration.md +79 -0
- package/src/docs/_misc/dataProviderKey.md +34 -1
- package/src/docs/_misc/docs-mock-api.md +60 -0
- package/src/docs/_misc/endpoint.md +2 -1
- package/src/docs/_misc/html-integration.md +13 -0
- package/src/docs/code.ts +58 -12
- package/src/docs/components/docs-demo-sources.ts +397 -0
- package/src/docs/components/docs-lit-demo-raw.ts +28 -0
- package/src/docs/components/docs-lit-demo.ts +166 -0
- package/src/docs/components/docs-source-link.ts +72 -0
- package/src/docs/docs-location.ts +54 -0
- package/src/docs/docs.ts +12 -0
- package/src/docs/example/decorators-demo-bind-demos.ts +41 -46
- package/src/docs/example/decorators-demo-geo.ts +16 -11
- package/src/docs/example/decorators-demo-init.ts +2 -228
- package/src/docs/example/decorators-demo-subscribe-publish-get-demos.ts +54 -14
- package/src/docs/example/decorators-demo.ts +71 -70
- package/src/docs/example/docs-api-config-demos.ts +234 -0
- package/src/docs/example/docs-joke-demos.ts +297 -0
- package/src/docs/example/docs-list-demos.ts +179 -0
- package/src/docs/example/docs-provider-keys.ts +315 -0
- package/src/docs/example/docs-queue-demos.ts +114 -0
- package/src/docs/example/docs-router-demos.ts +89 -0
- package/src/docs/example/docs-submit-demos.ts +455 -0
- package/src/docs/example/docs-toggle-demos.ts +73 -0
- package/src/docs/example/docs-user-two-scopes.ts +37 -0
- package/src/docs/example/docs-users-list.ts +71 -0
- package/src/docs/example/users.ts +41 -24
- package/src/docs/mock-api/api-config-mock.ts +152 -0
- package/src/docs/mock-api/fixtures.ts +377 -0
- package/src/docs/mock-api/register.ts +25 -0
- package/src/docs/mock-api/router.ts +234 -0
- package/src/docs/mock-api/service-worker.ts +23 -0
- package/src/docs/mock-api/urls.ts +11 -0
- package/src/docs/navigation/navigation.ts +39 -7
- package/src/docs/search/docs-search.json +4021 -936
- package/src/docs/search/markdown-renderer.ts +7 -3
- package/src/docs/search/page.ts +11 -14
- package/src/docs/search/sonic-code-markdown.spec.ts +29 -0
- package/src/docs/search/sonic-code-markdown.ts +28 -0
- package/src/docs.ts +4 -0
- package/src/tsconfig.json +87 -0
- package/src/tsconfig.tsbuildinfo +1 -1
- package/vite.config.mts +8 -0
- package/docs/assets/index-CaysOMFz.js +0 -5046
- package/docs/assets/index-D8mGoXzF.css +0 -1
- package/docs/src/docs/_misc/templates-demo.md +0 -19
- 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
|
|
6
|
-
|
|
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
|
|
11
|
-
|
|
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
|
-
*
|
|
16
|
+
* TypeScript
|
|
18
17
|
* Vite
|
|
19
|
-
* Tailwind, not in the core
|
|
18
|
+
* Tailwind (starter kit, not required in the core package)
|
|
20
19
|
|
|
21
|
-
###
|
|
20
|
+
### Functional features
|
|
22
21
|
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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<{ email: string }>("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<{ count: number }>("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 @
|
|
137
|
+
## Integration with @subscribe, @publish and @handle
|
|
105
138
|
|
|
106
|
-
Use `DataProviderKey` with `@subscribe` (read-only)
|
|
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
|
-
|
|
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<User[]>("users?limit=10");
|
|
20
20
|
users.path; // "users?limit=10"
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
const one = new Endpoint<User, { userId: string }>("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<User, { userId: string }>("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`.
|