@adia-ai/web-components 0.0.12 → 0.0.13

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/README.md CHANGED
@@ -5,9 +5,9 @@ elements**, a reactive core, a trait system, and a renderer that turns
5
5
  A2UI protocol messages into live DOM.
6
6
 
7
7
  > This package ships UI atoms only. The generation pipeline lives in
8
- > [`@adia-ai/gen-ui`](../gen-ui); the pattern corpus in
9
- > [`@adia-ai/gen-ui-training`](../gen-ui-training); the MCP server in
10
- > [`@adia-ai/gen-ui-mcp`](../gen-ui-mcp).
8
+ > [`@adia-ai/a2ui-compose`](../a2ui/compose); the pattern corpus in
9
+ > [`@adia-ai/a2ui-corpus`](../a2ui/corpus); the MCP server in
10
+ > [`@adia-ai/a2ui-mcp`](../a2ui/mcp).
11
11
 
12
12
  ## Quick start
13
13
 
@@ -80,7 +80,7 @@ web-components/
80
80
  Build + dev utilities (including `build-a2ui-data.mjs`, `qa-training.mjs`,
81
81
  `a2ui-to-html.cjs`, `mcp-call.cjs`, `mcp-pipeline.cjs`, `screenshot.cjs`)
82
82
  live at the repo-root `scripts/` directory rather than inside this
83
- package — they span the monorepo (MCP server, gen-ui-training data,
83
+ package — they span the monorepo (MCP server, a2ui-corpus data,
84
84
  component catalog) and aren't scoped to web-components alone.
85
85
 
86
86
  ## Component contract
@@ -165,7 +165,7 @@ output is robust to name drift.
165
165
  npm run build:components # regenerate all .a2ui.json from YAML
166
166
  ```
167
167
 
168
- The build also writes `packages/gen-ui-training/catalog-a2ui_0_9.json` and
168
+ The build also writes `packages/a2ui/corpus/catalog-a2ui_0_9.json` and
169
169
  `catalog-a2ui_0_9_rules.txt` — the flat-file catalog the MCP server and
170
170
  generation engine consume.
171
171
 
@@ -189,11 +189,11 @@ Each is a CSS-variable override; no class toggles, no re-imports.
189
189
  ## Dependency direction
190
190
 
191
191
  ```
192
- gen-ui ──reads──> gen-ui-training ←─reads── web-components
193
- gen-ui-mcp ──reads──> gen-ui, gen-ui-training
192
+ a2ui-compose ──reads──> a2ui-corpus ←─reads── web-components
193
+ a2ui-mcp ──reads──> a2ui-compose, a2ui-corpus
194
194
  ```
195
195
 
196
- Web-components never imports from gen-ui or gen-ui-mcp. The A2UI renderer
196
+ Web-components never imports from a2ui-compose or a2ui-mcp. The A2UI renderer
197
197
  consumes a protocol, not a generator — anything that emits valid A2UI
198
198
  messages drives it.
199
199
 
@@ -0,0 +1,103 @@
1
+ /**
2
+ * code-editor — CodeMirror 6 runtime bundled for <code-ui>.
3
+ *
4
+ * Single file for the whole integration: CM core re-exports, the AdiaUI
5
+ * base theme + highlight style, the per-language lazy-load map, and the
6
+ * load-timeout helper. `code.js` does `import('./code-editor.js')` once
7
+ * per element mount.
8
+ *
9
+ * Styling contract: `EditorView.theme()` can't emit CSS custom properties
10
+ * (per CodeMirror docs), so the base theme below is structural-only.
11
+ * Every color, padding, border, and syntax-token style lives in
12
+ * `code.css` under `@scope (code-ui)`. See SPEC-CODE-EDITOR-001 §6.
13
+ *
14
+ * In Vite dev, the bare-specifier imports resolve through node_modules.
15
+ * In production, `scripts/build-site.mjs` runs esbuild with
16
+ * `splitting: true` on this file; each `languages[…]()` dynamic import
17
+ * becomes its own chunk, lazy-loaded on first use.
18
+ */
19
+
20
+ import {
21
+ EditorState, EditorSelection, Compartment, StateEffect,
22
+ } from '@codemirror/state';
23
+ import {
24
+ EditorView,
25
+ lineNumbers, highlightActiveLine, highlightActiveLineGutter,
26
+ placeholder, drawSelection, keymap,
27
+ } from '@codemirror/view';
28
+ import {
29
+ defaultKeymap, history, historyKeymap, indentWithTab,
30
+ } from '@codemirror/commands';
31
+ import {
32
+ HighlightStyle, syntaxHighlighting, LanguageSupport, defaultHighlightStyle,
33
+ } from '@codemirror/language';
34
+ import { tags as t } from '@lezer/highlight';
35
+
36
+ // ── Base theme (structural only — colors live in code.css) ───────────
37
+
38
+ export const adiaBaseTheme = EditorView.theme({
39
+ '&': { fontFamily: 'inherit', fontSize: 'inherit', color: 'inherit', backgroundColor: 'transparent' },
40
+ '.cm-content': { padding: '0', caretColor: 'inherit' },
41
+ '.cm-focused': { outline: 'none' },
42
+ });
43
+
44
+ // ── Syntax highlight (class-based so CSS owns the colors) ────────────
45
+
46
+ export const adiaHighlightStyle = HighlightStyle.define([
47
+ { tag: [t.comment, t.lineComment, t.blockComment, t.docComment], class: 'tok-comment' },
48
+ { tag: [t.keyword, t.controlKeyword, t.modifier, t.operatorKeyword], class: 'tok-keyword' },
49
+ { tag: [t.string, t.character, t.regexp, t.escape, t.special(t.string)], class: 'tok-string' },
50
+ { tag: [t.number, t.integer, t.float], class: 'tok-number' },
51
+ { tag: [t.bool, t.null, t.atom], class: 'tok-boolean' },
52
+ { tag: [t.operator, t.logicOperator, t.arithmeticOperator, t.compareOperator,
53
+ t.updateOperator, t.definitionOperator], class: 'tok-operator' },
54
+ { tag: [t.punctuation, t.bracket, t.paren, t.brace, t.squareBracket,
55
+ t.angleBracket, t.separator], class: 'tok-punctuation' },
56
+ { tag: [t.function(t.variableName), t.function(t.propertyName), t.macroName], class: 'tok-function' },
57
+ { tag: [t.variableName, t.local(t.variableName), t.self], class: 'tok-variable' },
58
+ { tag: [t.typeName, t.className, t.namespace], class: 'tok-type' },
59
+ { tag: [t.propertyName, t.labelName, t.definition(t.variableName)], class: 'tok-property' },
60
+ { tag: [t.tagName, t.heading, t.contentSeparator], class: 'tok-tag' },
61
+ { tag: [t.attributeName, t.attributeValue], class: 'tok-attribute' },
62
+ { tag: [t.url, t.link], class: 'tok-url' },
63
+ { tag: [t.invalid, t.deleted], class: 'tok-invalid' },
64
+ ]);
65
+
66
+ // ── Per-language lazy loaders ────────────────────────────────────────
67
+
68
+ export const languages = {
69
+ json: () => import('@codemirror/lang-json').then((m) => ({ extension: m.json() })),
70
+ html: () => import('@codemirror/lang-html').then((m) => ({ extension: m.html() })),
71
+ javascript: () => import('@codemirror/lang-javascript').then((m) => ({ extension: m.javascript({ jsx: false, typescript: false }) })),
72
+ css: () => import('@codemirror/lang-css').then((m) => ({ extension: m.css() })),
73
+ markdown: () => import('@codemirror/lang-markdown').then((m) => ({ extension: m.markdown() })),
74
+ yaml: () => import('@codemirror/lang-yaml').then((m) => ({ extension: m.yaml() })),
75
+ };
76
+
77
+ // ── Load helper ──────────────────────────────────────────────────────
78
+
79
+ /** 10s ceiling on any single dynamic import. Per SPEC-CODE-EDITOR-001 §7.4. */
80
+ export const LOAD_TIMEOUT_MS = 10_000;
81
+
82
+ export function importWithTimeout(loader, label) {
83
+ return Promise.race([
84
+ loader(),
85
+ new Promise((_, reject) =>
86
+ setTimeout(
87
+ () => reject(new Error(`code-editor: ${label} load timed out after ${LOAD_TIMEOUT_MS}ms`)),
88
+ LOAD_TIMEOUT_MS,
89
+ ),
90
+ ),
91
+ ]);
92
+ }
93
+
94
+ // ── Re-exports (so code.js gets everything from one import) ─────────
95
+
96
+ export {
97
+ EditorState, EditorSelection, Compartment, StateEffect,
98
+ EditorView,
99
+ lineNumbers, highlightActiveLine, highlightActiveLineGutter,
100
+ placeholder, drawSelection, keymap,
101
+ defaultKeymap, history, historyKeymap, indentWithTab,
102
+ HighlightStyle, syntaxHighlighting, LanguageSupport, defaultHighlightStyle,
103
+ };
@@ -137,7 +137,7 @@ class AdiaCode extends AdiaElement {
137
137
  this.#pendingMount = true;
138
138
 
139
139
  try {
140
- const bundle = await import('../../core/code-editor-bundle.js');
140
+ const bundle = await import('./code-editor.js');
141
141
 
142
142
  // Load the language pack with a timeout. If it fails, continue with
143
143
  // core-only (editor still renders; no syntax highlight). Emit an
@@ -179,7 +179,7 @@ select-ui [slot="listbox"] {
179
179
  padding: var(--a-space-1);
180
180
  border: 1px solid var(--a-ui-border);
181
181
  border-radius: var(--a-radius);
182
- background: var(--a-bg-subtle);
182
+ background: var(--a-canvas-bright);
183
183
  box-shadow: var(--a-shadow-lg);
184
184
  max-height: 15rem;
185
185
  overflow-y: auto;
@@ -1,9 +1,14 @@
1
1
  /**
2
- * <slider-ui label="Width" value="63" min="0" max="200" step="1" suffix="rem"></slider-ui>
2
+ * <field-ui label="Width">
3
+ * <slider-ui value="63" min="0" max="200" step="1" suffix="rem"></slider-ui>
4
+ * </field-ui>
3
5
  *
4
- * Layout:
5
- * [label] [value] [suffix]
6
+ * Layout inside the field:
7
+ * [field label] [value] [suffix]
6
8
  * [====fill====●─────────────────track──────]
9
+ *
10
+ * Bare `<slider-ui label="…">` still works but logs a deprecation warning
11
+ * asking you to wrap in <field-ui> for proper label association.
7
12
  */
8
13
 
9
14
  import { AdiaFormElement } from '../../core/form.js';
package/core/index.js ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * core barrel — re-exports every public core module.
3
+ *
4
+ * Consumers who want to build on AdiaElement or use the reactive
5
+ * signal system directly do:
6
+ *
7
+ * import { AdiaElement } from '@adia-ai/web-components/core';
8
+ * import { signal, effect } from '@adia-ai/web-components/core';
9
+ *
10
+ * Exports are flat — every symbol from the re-exported files is
11
+ * available at this level. Symbol collisions between files are not
12
+ * allowed (there are none currently; keep it that way).
13
+ */
14
+
15
+ export * from './element.js';
16
+ export * from './form.js';
17
+ export * from './signals.js';
18
+ export * from './template.js';
19
+ export * from './controller.js';
20
+ export * from './provider.js';
21
+ export * from './anchor.js';
22
+ export * from './icons.js';
23
+ export * from './markdown.js';
24
+ export * from './transport.js';
25
+ export * from './polyfills.js';
package/index.css ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @adia-ai/web-components — the opinionated all-in-one stylesheet.
3
+ *
4
+ * <link rel="stylesheet" href="@adia-ai/web-components/css" />
5
+ *
6
+ * Imports, in cascade order: design tokens (primitives + semantics
7
+ * + typography — via the colors tree) → component styles → global
8
+ * resets.
9
+ *
10
+ * Pattern CSS (adia-chat, adia-editor, app-shell, etc.) is NOT
11
+ * bundled here — each page links its own patterns explicitly.
12
+ * Opinionated theme overrides live in `./styles/themes.css`; link
13
+ * them separately when you want the 8 named themes.
14
+ *
15
+ * If you need a subset, skip this file and link the layers directly:
16
+ * @adia-ai/web-components/styles/tokens.css
17
+ * @adia-ai/web-components/styles/components.css
18
+ * @adia-ai/web-components/styles/resets.css
19
+ * @adia-ai/web-components/styles/themes.css (optional)
20
+ * @adia-ai/web-components/styles/prose.css (optional)
21
+ * @adia-ai/web-components/styles/typography.css (standalone)
22
+ */
23
+
24
+ @import "./styles/tokens.css";
25
+ @import "./styles/components.css";
26
+ @import "./styles/resets.css";
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @adia-ai/web-components — main entry.
3
+ *
4
+ * import '@adia-ai/web-components';
5
+ * import { AdiaButton, AdiaAppShell } from '@adia-ai/web-components';
6
+ *
7
+ * Loading this file registers every component + pattern custom
8
+ * element (side effect of each module's `customElements.define(...)`
9
+ * call). Pair with `@adia-ai/web-components/css` (the all-in-one
10
+ * stylesheet) or link tokens/components/resets individually.
11
+ *
12
+ * If you only want a subset, use the subpath imports:
13
+ * import '@adia-ai/web-components/components/button';
14
+ * import { AdiaAppShell } from '@adia-ai/web-components/patterns';
15
+ */
16
+
17
+ export * from './components/index.js';
18
+ export * from './patterns/index.js';
package/package.json CHANGED
@@ -1,14 +1,22 @@
1
1
  {
2
2
  "name": "@adia-ai/web-components",
3
- "version": "0.0.12",
3
+ "version": "0.0.13",
4
4
  "description": "AdiaUI web components — vanilla custom elements. A2UI runtime (renderer, registry, streams, wiring) lives in @adia-ai/a2ui-utils.",
5
5
  "type": "module",
6
6
  "exports": {
7
- ".": "./index.js",
8
- "./css": "./index.css",
9
- "./a2ui": "./a2ui/index.js",
10
- "./core": "./core/index.js",
11
- "./patterns": "./patterns/index.js"
7
+ ".": "./index.js",
8
+ "./css": "./index.css",
9
+ "./a2ui": "./a2ui/index.js",
10
+ "./core": "./core/index.js",
11
+ "./core/*": "./core/*.js",
12
+ "./components": "./components/index.js",
13
+ "./components/*": "./components/*/*.js",
14
+ "./patterns": "./patterns/index.js",
15
+ "./patterns/*": "./patterns/*/*.js",
16
+ "./styles/*": "./styles/*",
17
+ "./traits": "./traits/index.js",
18
+ "./traits/*": "./traits/*.js",
19
+ "./package.json": "./package.json"
12
20
  },
13
21
  "files": [
14
22
  "core/",
@@ -1,6 +1,6 @@
1
1
  import { AdiaElement } from '../../core/element.js';
2
2
  import { renderMarkdown } from '../../core/markdown.js';
3
- import { streamChat } from '../../../gen-ui/llm/adapters/index.js';
3
+ import { streamChat } from '../../../a2ui/compose/llm/adapters/index.js';
4
4
 
5
5
  function escapeHTML(s) {
6
6
  return s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
@@ -464,10 +464,10 @@
464
464
  UI (FIELD) — Form input surfaces
465
465
  ══════════════════════════════════════════════════════════════ */
466
466
 
467
- --a-ui-bg: var(--a-neutral-0-scrim);
468
- --a-ui-bg-hover: var(--a-neutral-2-scrim);
467
+ --a-ui-bg: var(--a-canvas-0-scrim);
468
+ --a-ui-bg-hover: var(--a-canvas-0-scrim);
469
469
  --a-ui-bg-active: var(--a-canvas-0);
470
- --a-ui-bg-selected: var(--a-canvas-0-scrim);
470
+ --a-ui-bg-selected: var(--a-canvas-bright);
471
471
  --a-ui-bg-disabled: var(--a-canvas-1);
472
472
  --a-ui-bg-invalid: var(--a-danger-muted);
473
473
 
@@ -1,5 +1,12 @@
1
1
  /**
2
- * Styles barrel — imports all component CSS + global reset.
2
+ * Components barrel — imports every component's CSS, in stamp order.
3
+ *
4
+ * This file is *only* the `packages/web-components/components/**`
5
+ * stylesheet set. Patterns (adia-chat, adia-editor, app-shell,
6
+ * app-nav, section-nav, gen-ui, etc.) are NOT imported here — each
7
+ * page links its own patterns explicitly. Global resets live in
8
+ * `resets.css` and must be linked separately.
9
+ *
3
10
  * All components use Light DOM — styles target tag names directly.
4
11
  */
5
12
 
@@ -82,113 +89,3 @@
82
89
  @import "../components/agent-suggestions/agent-suggestions.css";
83
90
  @import "../components/agent-questions/agent-questions.css";
84
91
  @import "../components/agent-artifact/agent-artifact.css";
85
- @import "../patterns/gen-ui/gen-ui.css";
86
-
87
- /* ── Reset ── */
88
- *,
89
- *::before,
90
- *::after {
91
- box-sizing: border-box;
92
- scrollbar-width: none;
93
- }
94
-
95
- *::-webkit-scrollbar {
96
- display: none;
97
- }
98
-
99
- /* Kill default focus outline — components manage their own via --a-focus-ring */
100
- *:focus {
101
- outline: none;
102
- }
103
-
104
- /* Prevent text selection on all interactive components */
105
- :is(button-ui, kbd-ui, tag-ui, input-ui, textarea-ui, select-ui, check-ui, radio-ui, switch-ui,
106
- slider-ui, range-ui, segmented-ui, segment-ui) {
107
- user-select: none;
108
- }
109
-
110
- html {
111
- -webkit-text-size-adjust: 100%;
112
- text-size-adjust: 100%;
113
- hanging-punctuation: first last;
114
- color-scheme: light dark;
115
- }
116
-
117
- body {
118
- text-rendering: optimizeLegibility;
119
- -webkit-font-smoothing: antialiased;
120
-
121
- margin: 0;
122
- font-family: var(--a-font-family);
123
- font-size: var(--a-body-size);
124
- font-style: normal;
125
- font-variation-settings: 'slnt' 0, 'ital' 0;
126
- line-height: 1.5;
127
- color: var(--a-fg);
128
- background: var(--a-bg);
129
- min-block-size: 100dvb;
130
- }
131
-
132
- img,
133
- picture,
134
- svg,
135
- video,
136
- canvas {
137
- display: block;
138
- max-inline-size: 100%;
139
- block-size: auto;
140
- }
141
-
142
- ul[role='list'],
143
- ol[role='list'] {
144
- list-style: none;
145
- padding: 0;
146
- }
147
-
148
- /* ── Size-query provider utility ──────────────────────────────────
149
- Opt any element into being a container-query size provider for
150
- its descendants, without the nesting fragility of applying
151
- container-type to every instance of a primitive. Use sparingly —
152
- on panels, split-panes, cards that actually need responsive
153
- children — and descendants query via bare `@container (width < Xrem)`
154
- (matches nearest) or `@container container (...)` for clarity.
155
-
156
- Why inline-size: block-direction height stays content-driven.
157
- Why an attribute: explicit opt-in; avoids accidental containment
158
- collapse when a primitive is composed inside another flex chain. */
159
- [provide-container-inline-size] {
160
- container-type: inline-size;
161
- container-name: container;
162
- }
163
-
164
-
165
- :focus-visible {
166
- outline: var(--ui-focus-width, 2px) solid var(--ui-focus, Highlight);
167
- outline-offset: 2px;
168
- }
169
-
170
- ::selection {
171
- background: var(--a-selection-bg);
172
- color: var(--a-selection-text);
173
- border-radius: var(--a-selection-radius);
174
- }
175
-
176
- h1,
177
- h2,
178
- h3,
179
- h4,
180
- h5,
181
- h6 {
182
- text-wrap: balance;
183
- line-height: 1.1;
184
- }
185
-
186
- p,
187
- li,
188
- figcaption {
189
- text-wrap: pretty;
190
- }
191
-
192
- a:not([class]) {
193
- text-underline-offset: 0.12em;
194
- }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * Global resets — box-sizing, scrollbar hiding, focus management,
3
+ * element defaults, and the size-query provider utility.
4
+ *
5
+ * Imported from styles.css (the barrel). Targets document-level
6
+ * defaults and universal selectors; component-scoped rules live in
7
+ * each component's own CSS under `@scope (component-n)`.
8
+ */
9
+
10
+ *,
11
+ *::before,
12
+ *::after {
13
+ box-sizing: border-box;
14
+ scrollbar-width: none;
15
+ }
16
+
17
+ *::-webkit-scrollbar {
18
+ display: none;
19
+ }
20
+
21
+ /* Kill default focus outline — components manage their own via --a-focus-ring */
22
+ *:focus {
23
+ outline: none;
24
+ }
25
+
26
+ /* Prevent text selection on all interactive components */
27
+ :is(button-ui, kbd-ui, tag-ui, input-ui, textarea-ui, select-ui, check-ui, radio-ui, switch-ui,
28
+ slider-ui, range-ui, segmented-ui, segment-ui) {
29
+ user-select: none;
30
+ }
31
+
32
+ html {
33
+ -webkit-text-size-adjust: 100%;
34
+ text-size-adjust: 100%;
35
+ hanging-punctuation: first last;
36
+ color-scheme: light dark;
37
+ }
38
+
39
+ body {
40
+ text-rendering: optimizeLegibility;
41
+ -webkit-font-smoothing: antialiased;
42
+
43
+ margin: 0;
44
+ font-family: var(--a-font-family);
45
+ font-size: var(--a-body-size);
46
+ font-style: normal;
47
+ font-variation-settings: 'slnt' 0, 'ital' 0;
48
+ line-height: 1.5;
49
+ color: var(--a-fg);
50
+ background: var(--a-bg);
51
+ min-block-size: 100dvb;
52
+ }
53
+
54
+ img,
55
+ picture,
56
+ svg,
57
+ video,
58
+ canvas {
59
+ display: block;
60
+ max-inline-size: 100%;
61
+ block-size: auto;
62
+ }
63
+
64
+ ul[role='list'],
65
+ ol[role='list'] {
66
+ list-style: none;
67
+ padding: 0;
68
+ }
69
+
70
+ /* ── Size-query provider utility ──────────────────────────────────
71
+ Opt any element into being a container-query size provider for
72
+ its descendants, without the nesting fragility of applying
73
+ container-type to every instance of a primitive. Use sparingly —
74
+ on panels, split-panes, cards that actually need responsive
75
+ children — and descendants query via bare `@container (width < Xrem)`
76
+ (matches nearest) or `@container container (...)` for clarity.
77
+
78
+ Why inline-size: block-direction height stays content-driven.
79
+ Why an attribute: explicit opt-in; avoids accidental containment
80
+ collapse when a primitive is composed inside another flex chain. */
81
+ [provide-container-inline-size] {
82
+ container-type: inline-size;
83
+ container-name: container;
84
+ }
85
+
86
+
87
+ :focus-visible {
88
+ outline: var(--ui-focus-width, 2px) solid var(--ui-focus, Highlight);
89
+ outline-offset: 2px;
90
+ }
91
+
92
+ ::selection {
93
+ background: var(--a-selection-bg);
94
+ color: var(--a-selection-text);
95
+ border-radius: var(--a-selection-radius);
96
+ }
97
+
98
+ h1,
99
+ h2,
100
+ h3,
101
+ h4,
102
+ h5,
103
+ h6 {
104
+ text-wrap: balance;
105
+ line-height: 1.1;
106
+ }
107
+
108
+ p,
109
+ li,
110
+ figcaption {
111
+ text-wrap: pretty;
112
+ }
113
+
114
+ a:not([class]) {
115
+ text-underline-offset: 0.12em;
116
+ }
package/styles/tokens.css CHANGED
@@ -16,10 +16,16 @@
16
16
  · Monospace font is the default — data-confident, technical character
17
17
  ═══════════════════════════════════════════════════════════════ */
18
18
 
19
+ /* Color ramps + semantic role aliases + typography scale are
20
+ primitive-layer — every component consumes `--a-fg`, `--a-bg-*`,
21
+ `--a-font-family`, `--a-body-size`, etc. Kept bundled. */
19
22
  @import "./colors/index.css";
20
23
  @import "./typography.css";
21
- @import "./prose.css";
22
- @import "./themes.css";
24
+
25
+ /* NOT imported here:
26
+ - styles/prose.css — opt-in per-page; [prose] attribute only
27
+ - styles/themes.css — opt-in per-page; 8 named themes + schemes
28
+ Link separately from HTML when needed. */
23
29
 
24
30
  /* ═══════════════════════════════════════════════════════════════
25
31
  PARAMETRIC MULTIPLIERS — @property declarations
package/core/_cm-core.js DELETED
@@ -1,38 +0,0 @@
1
- /**
2
- * CodeMirror 6 core re-exports.
3
- *
4
- * Thin shim so the rest of the AdiaUI codebase imports CM symbols from
5
- * `@core/_cm-core.js` and the production build can split them into a
6
- * single minified chunk (see scripts/build-site.mjs:bundleCodeEditor).
7
- */
8
-
9
- export {
10
- EditorState,
11
- EditorSelection,
12
- Compartment,
13
- StateEffect,
14
- } from '@codemirror/state';
15
-
16
- export {
17
- EditorView,
18
- lineNumbers,
19
- highlightActiveLine,
20
- highlightActiveLineGutter,
21
- placeholder,
22
- drawSelection,
23
- keymap,
24
- } from '@codemirror/view';
25
-
26
- export {
27
- defaultKeymap,
28
- history,
29
- historyKeymap,
30
- indentWithTab,
31
- } from '@codemirror/commands';
32
-
33
- export {
34
- HighlightStyle,
35
- syntaxHighlighting,
36
- LanguageSupport,
37
- defaultHighlightStyle,
38
- } from '@codemirror/language';
package/core/_cm-theme.js DELETED
@@ -1,58 +0,0 @@
1
- /**
2
- * AdiaUI base theme + highlight style for CodeMirror 6.
3
- *
4
- * The base theme is deliberately near-empty — it only sets the handful
5
- * of structural rules that MUST live inside `EditorView.theme()`. All
6
- * colors, spacing, font size, radius, and token-span styling live in
7
- * `components/code/code.css` inside `@scope (code-ui)` and consume
8
- * AdiaUI semantic tokens.
9
- *
10
- * CodeMirror injects its CSS-in-JS stylesheets at module load; AdiaUI's
11
- * authored stylesheet loads after that, so `@scope (code-ui) .cm-*`
12
- * overrides win on natural specificity — no `!important` needed.
13
- *
14
- * The highlight style uses `class:` rather than `color:` so CodeMirror
15
- * emits `<span class="tok-keyword">` instead of inline styles — exactly
16
- * what our CSS needs. See spec SPEC-CODE-EDITOR-001 §6.3 for the full
17
- * Lezer tag → class → token mapping.
18
- */
19
-
20
- import { EditorView } from '@codemirror/view';
21
- import { HighlightStyle } from '@codemirror/language';
22
- import { tags as t } from '@lezer/highlight';
23
-
24
- export const adiaBaseTheme = EditorView.theme({
25
- '&': {
26
- fontFamily: 'inherit',
27
- fontSize: 'inherit',
28
- color: 'inherit',
29
- backgroundColor: 'transparent',
30
- },
31
- '.cm-content': {
32
- padding: '0',
33
- caretColor: 'inherit',
34
- },
35
- '.cm-focused': {
36
- outline: 'none',
37
- },
38
- });
39
-
40
- export const adiaHighlightStyle = HighlightStyle.define([
41
- { tag: [t.comment, t.lineComment, t.blockComment, t.docComment], class: 'tok-comment' },
42
- { tag: [t.keyword, t.controlKeyword, t.modifier, t.operatorKeyword], class: 'tok-keyword' },
43
- { tag: [t.string, t.character, t.regexp, t.escape, t.special(t.string)], class: 'tok-string' },
44
- { tag: [t.number, t.integer, t.float], class: 'tok-number' },
45
- { tag: [t.bool, t.null, t.atom], class: 'tok-boolean' },
46
- { tag: [t.operator, t.logicOperator, t.arithmeticOperator, t.compareOperator,
47
- t.updateOperator, t.definitionOperator], class: 'tok-operator' },
48
- { tag: [t.punctuation, t.bracket, t.paren, t.brace, t.squareBracket,
49
- t.angleBracket, t.separator], class: 'tok-punctuation' },
50
- { tag: [t.function(t.variableName), t.function(t.propertyName), t.macroName], class: 'tok-function' },
51
- { tag: [t.variableName, t.local(t.variableName), t.self], class: 'tok-variable' },
52
- { tag: [t.typeName, t.className, t.namespace], class: 'tok-type' },
53
- { tag: [t.propertyName, t.labelName, t.definition(t.variableName)], class: 'tok-property' },
54
- { tag: [t.tagName, t.heading, t.contentSeparator], class: 'tok-tag' },
55
- { tag: [t.attributeName, t.attributeValue], class: 'tok-attribute' },
56
- { tag: [t.url, t.link], class: 'tok-url' },
57
- { tag: [t.invalid, t.deleted], class: 'tok-invalid' },
58
- ]);
package/core/_lang-css.js DELETED
@@ -1,2 +0,0 @@
1
- import { css } from '@codemirror/lang-css';
2
- export const extension = css();
@@ -1,2 +0,0 @@
1
- import { html } from '@codemirror/lang-html';
2
- export const extension = html();
@@ -1,2 +0,0 @@
1
- import { javascript } from '@codemirror/lang-javascript';
2
- export const extension = javascript({ jsx: false, typescript: false });
@@ -1,2 +0,0 @@
1
- import { json } from '@codemirror/lang-json';
2
- export const extension = json();
@@ -1,2 +0,0 @@
1
- import { markdown } from '@codemirror/lang-markdown';
2
- export const extension = markdown();
@@ -1,2 +0,0 @@
1
- import { yaml } from '@codemirror/lang-yaml';
2
- export const extension = yaml();
@@ -1,63 +0,0 @@
1
- /**
2
- * code-editor-bundle — the single entry point `<code-ui>` imports when
3
- * it needs CodeMirror 6. Re-exports core runtime + AdiaUI theme, and
4
- * exposes a lazy-load map of language packs (one dynamic import per
5
- * language, split into its own chunk by esbuild in production).
6
- *
7
- * Vite dev: imports resolve against node_modules naturally.
8
- * Production: scripts/build-site.mjs runs esbuild with
9
- * splitting: true, producing `code-editor-core.js` + one
10
- * `code-editor-lang-<lang>.js` per language.
11
- *
12
- * Spec: docs/specs/code-editor.md §4 (architecture), §7 (bundling).
13
- */
14
-
15
- export {
16
- EditorState,
17
- EditorSelection,
18
- Compartment,
19
- StateEffect,
20
- EditorView,
21
- lineNumbers,
22
- highlightActiveLine,
23
- highlightActiveLineGutter,
24
- placeholder,
25
- drawSelection,
26
- keymap,
27
- defaultKeymap,
28
- history,
29
- historyKeymap,
30
- indentWithTab,
31
- HighlightStyle,
32
- syntaxHighlighting,
33
- LanguageSupport,
34
- defaultHighlightStyle,
35
- } from './_cm-core.js';
36
-
37
- export { adiaBaseTheme, adiaHighlightStyle } from './_cm-theme.js';
38
-
39
- /** Dynamic-import map — one lazy-loaded chunk per supported language. */
40
- export const languages = {
41
- json: () => import('./_lang-json.js'),
42
- html: () => import('./_lang-html.js'),
43
- javascript: () => import('./_lang-javascript.js'),
44
- css: () => import('./_lang-css.js'),
45
- markdown: () => import('./_lang-markdown.js'),
46
- yaml: () => import('./_lang-yaml.js'),
47
- };
48
-
49
- /** 10-second timeout for any single dynamic import. Matches spec §7.4. */
50
- export const LOAD_TIMEOUT_MS = 10_000;
51
-
52
- /**
53
- * Wrap a dynamic-import promise with a timeout. Rejects on timeout;
54
- * propagates the original error on fetch failure.
55
- */
56
- export function importWithTimeout(loader, label) {
57
- return Promise.race([
58
- loader(),
59
- new Promise((_, reject) =>
60
- setTimeout(() => reject(new Error(`code-editor: ${label} load timed out after ${LOAD_TIMEOUT_MS}ms`)), LOAD_TIMEOUT_MS),
61
- ),
62
- ]);
63
- }