@wireweave/language-data 1.6.0-beta.0 → 1.6.0-beta.10
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 +15 -80
- package/dist/codemirror/index.cjs +7 -0
- package/dist/codemirror/index.cjs.map +1 -1
- package/dist/codemirror/index.js +7 -0
- package/dist/codemirror/index.js.map +1 -1
- package/dist/index.cjs +7 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/monaco/index.cjs +7 -0
- package/dist/monaco/index.cjs.map +1 -1
- package/dist/monaco/index.js +7 -0
- package/dist/monaco/index.js.map +1 -1
- package/package.json +18 -21
package/README.md
CHANGED
|
@@ -1,94 +1,29 @@
|
|
|
1
1
|
# @wireweave/language-data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Language catalogs and editor adapters for Wireweave.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
The [public tool contract](../../docs/spec/TOOLING.md#editor-integrations) defines this package's APIs, behavior, configuration and compatibility. The [language contract](../../docs/spec/LANGUAGE.md) defines the DSL. [Package metadata](package.json) owns package versions, exports, dependencies and scripts.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Installation
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
Runtime output depends on the `./spec` subpath only, so no parser or renderer code reaches a bundle. The tests reach further, into core as a whole: `./spec` is a copy of what the grammar, AST types, and renderer actually do, and checking a copy against itself proves nothing. Runtime dependency and test oracle are separate axes, and the oracle is the wider of the two by design.
|
|
12
|
-
|
|
13
|
-
Optional subpath entries provide ready-made editor integrations:
|
|
14
|
-
|
|
15
|
-
- `@wireweave/language-data/monaco` — register the Wireweave language with Monaco Editor.
|
|
16
|
-
- `@wireweave/language-data/codemirror` — tokenizer, completion, hover, and linting sources for CodeMirror 6.
|
|
17
|
-
|
|
18
|
-
The editor adapters rely on optional peer dependencies (`monaco-editor`, `@codemirror/*`) — install only the ones for the integration you use.
|
|
19
|
-
|
|
20
|
-
## Install
|
|
9
|
+
Use Node.js >=22.13.0. Replace `<pinned-version>` with the release selected for your toolchain.
|
|
21
10
|
|
|
22
11
|
```bash
|
|
23
|
-
|
|
12
|
+
pnpm add --save-exact '@wireweave/language-data@<pinned-version>'
|
|
24
13
|
```
|
|
25
14
|
|
|
26
|
-
|
|
15
|
+
The optional Monaco and CodeMirror adapters use their declared peer dependencies; install the editor peers for the adapter you select.
|
|
27
16
|
|
|
28
|
-
|
|
29
|
-
import {
|
|
30
|
-
ALL_COMPONENTS,
|
|
31
|
-
ATTRIBUTES,
|
|
32
|
-
getComponent,
|
|
33
|
-
getAttribute,
|
|
34
|
-
getValidChildren,
|
|
35
|
-
getComponentAttributes,
|
|
36
|
-
isValidChild,
|
|
37
|
-
} from '@wireweave/language-data'
|
|
38
|
-
|
|
39
|
-
// Component definition
|
|
40
|
-
const card = getComponent('card')
|
|
41
|
-
console.log(card?.description)
|
|
42
|
-
|
|
43
|
-
// Attributes allowed on a component
|
|
44
|
-
const cardAttrs = getComponentAttributes('card')
|
|
45
|
-
|
|
46
|
-
// Validity checks for the editor
|
|
47
|
-
isValidChild('page', 'card') // true / false
|
|
48
|
-
getValidChildren('grid') // valid child component names
|
|
49
|
-
|
|
50
|
-
// Full vocabulary
|
|
51
|
-
console.log(ALL_COMPONENTS.length, ATTRIBUTES.length)
|
|
52
|
-
```
|
|
17
|
+
## Development
|
|
53
18
|
|
|
54
|
-
|
|
19
|
+
Run from the monorepo root after the [workspace setup](../../README.md).
|
|
55
20
|
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
### CodeMirror 6 integration
|
|
64
|
-
|
|
65
|
-
```typescript
|
|
66
|
-
import {
|
|
67
|
-
createTokenizer,
|
|
68
|
-
getLanguageConfig,
|
|
69
|
-
createCompletionSource,
|
|
70
|
-
createHoverTooltipSource,
|
|
71
|
-
createLinter,
|
|
72
|
-
} from '@wireweave/language-data/codemirror'
|
|
21
|
+
```bash
|
|
22
|
+
pnpm --filter @wireweave/language-data run build
|
|
23
|
+
pnpm --filter @wireweave/language-data run typecheck
|
|
24
|
+
pnpm --filter @wireweave/language-data run lint
|
|
25
|
+
pnpm --filter @wireweave/language-data run test
|
|
26
|
+
pnpm --filter @wireweave/language-data run format:check
|
|
73
27
|
```
|
|
74
28
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
| Export | Description |
|
|
78
|
-
| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
79
|
-
| `ALL_COMPONENTS`, `COMPONENT_MAP`, `NODE_TYPE_MAP`, `VALID_COMPONENT_NAMES` | Component definitions and lookup maps. |
|
|
80
|
-
| `ATTRIBUTES`, `ATTRIBUTE_MAP`, `COMMON_ATTRIBUTES`, `VALID_ATTRIBUTE_NAMES` | Attribute definitions and lookup maps. |
|
|
81
|
-
| `CATEGORY_LABELS`, `VALUE_KEYWORDS`, `COMMON_NUMBERS`, `SPACING_SCALE` | Categories, value keywords, and numeric scales for completion. |
|
|
82
|
-
| `getComponent`, `getComponentByNodeType`, `getComponentAttributes`, `getComponentsByCategory` | Component lookups. |
|
|
83
|
-
| `getAttribute`, `getAttributeTypeLabel`, `formatAttributeValues` | Attribute lookups and formatting. |
|
|
84
|
-
| `getValidChildren`, `isValidChild` | Containment rules for validation. |
|
|
85
|
-
| `isComponent`, `isAttribute`, `getComponentNames`, `getAttributeNames`, `getCategories` | Membership checks and name listings. |
|
|
86
|
-
| `ComponentDef`, `AttributeDef`, `ComponentCategory`, `AttributeValueType` | Type definitions. |
|
|
87
|
-
| `registerWireframeLanguage` (`/monaco`) | Register the language with Monaco Editor. |
|
|
88
|
-
| `createTokenizer`, `getLanguageConfig`, `createCompletionSource`, `createHoverTooltipSource`, `createLinter`, `validateCode` (`/codemirror`) | CodeMirror 6 language sources. |
|
|
89
|
-
|
|
90
|
-
Part of the [Wireweave monorepo](https://github.com/wireweave/wireweave).
|
|
91
|
-
|
|
92
|
-
## License
|
|
93
|
-
|
|
94
|
-
MIT
|
|
29
|
+
License: MIT.
|
|
@@ -60,6 +60,11 @@ var EDITOR_METADATA = {
|
|
|
60
60
|
use: {
|
|
61
61
|
example: 'use userbadge(name="Ada") { ... }'
|
|
62
62
|
},
|
|
63
|
+
repeat: {
|
|
64
|
+
// No `validParents`: `repeat` is a fold, so it belongs wherever its body
|
|
65
|
+
// would have been written out by hand — which is anywhere children go.
|
|
66
|
+
example: "row gap=4 { repeat 6 { use skeletonCard() } }"
|
|
67
|
+
},
|
|
63
68
|
// Grid
|
|
64
69
|
row: { example: "row flex gap=4 justify=between { ... }" },
|
|
65
70
|
col: { example: "col span=6 md=4 { ... }" },
|
|
@@ -295,6 +300,8 @@ var ATTRIBUTE_EXAMPLES = {
|
|
|
295
300
|
device: 'device="iphone14"',
|
|
296
301
|
// Reuse
|
|
297
302
|
uses: 'uses="app-shell"',
|
|
303
|
+
variants: "variants=[loading, empty, ready]",
|
|
304
|
+
when: "when=[loading, empty]",
|
|
298
305
|
// Interaction
|
|
299
306
|
navigate: 'navigate="Dashboard"',
|
|
300
307
|
opens: 'opens="settings-modal"',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/codemirror/index.ts","../../src/components.ts","../../src/attributes.ts","../../src/core-spec-gaps.ts","../../src/keywords.ts","../../src/utils.ts","../../src/codemirror/language.ts","../../src/codemirror/completion.ts","../../src/codemirror/hover.ts","../../src/codemirror/linting.ts"],"sourcesContent":["/**\n * CodeMirror Integration for Wireframe DSL\n *\n * Provides language definition, auto-completion, hover tooltips, and linting.\n *\n * Usage:\n * ```typescript\n * import { StreamLanguage } from '@codemirror/language';\n * import { autocompletion } from '@codemirror/autocomplete';\n * import { hoverTooltip } from '@codemirror/view';\n * import { linter } from '@codemirror/lint';\n * import {\n * createTokenizer,\n * createCompletionSource,\n * createHoverTooltipSource,\n * createLinter,\n * } from '@wireweave/language-data/codemirror';\n *\n * // Create language\n * const wireframeLanguage = StreamLanguage.define(createTokenizer());\n *\n * // Setup editor extensions\n * const extensions = [\n * wireframeLanguage,\n * autocompletion({ override: [createCompletionSource()] }),\n * hoverTooltip(createHoverTooltipSource()),\n * linter(createLinter()),\n * ];\n * ```\n */\n\n// Language definition\nexport { createTokenizer, getLanguageConfig } from './language.js'\n\n// Auto-completion\nexport { createCompletionSource } from './completion.js'\n\n// Hover tooltips\nexport { createHoverTooltipSource } from './hover.js'\n\n// Linting\nexport { validateCode, createLinter, type Diagnostic, type DiagnosticSeverity } from './linting.js'\n","/**\n * Component definitions for Wireweave DSL editors\n *\n * The element set and its core metadata (category, attributes, hasChildren,\n * description) come from `@wireweave/core/spec`, which derives them from the\n * grammar. This module only adds what editors need on top — an example snippet\n * and the parent/child hints used for autocomplete and validation.\n *\n * Nothing here re-declares which elements exist: the `Record<GrammarElementName,\n * …>` key type means a new grammar element fails to typecheck until its editor\n * metadata is filled in, and an entry for a non-element is rejected.\n */\n\nimport {\n COMPONENT_SPEC_BY_NAME,\n COMPONENT_NAMES,\n type GrammarElementName,\n} from '@wireweave/core/spec'\nimport type { ComponentDef } from './types.js'\n\n/** Editor-only metadata: everything the core spec does not already state. */\ninterface EditorComponentMeta {\n /** Code example for documentation and hover cards */\n example: string\n /** Valid child components (for autocomplete) */\n validChildren?: string[]\n /** Valid parent components (for validation hints) */\n validParents?: string[]\n /**\n * Attributes accepted by editors but not part of the core spec's attribute\n * list — currently the `at(x, y)` placement shorthand, which the grammar\n * parses as a functional attribute rather than a `name=value` pair.\n */\n extraAttributes?: string[]\n}\n\nconst EDITOR_METADATA: Readonly<Record<GrammarElementName, EditorComponentMeta>> = {\n // Layout\n page: {\n example: 'page \"Login\" at(0, 0) viewport=\"1280x800\" { ... }',\n validChildren: ['header', 'main', 'footer', 'sidebar', 'section', 'nav', 'row', 'col', 'card'],\n validParents: [],\n extraAttributes: ['at'],\n },\n header: { example: 'header h=56 border { ... }', validParents: ['page'] },\n main: { example: 'main p=6 scroll { ... }', validParents: ['page'] },\n footer: { example: 'footer h=48 border { ... }', validParents: ['page'] },\n sidebar: { example: 'sidebar w=240 border { ... }', validParents: ['page'] },\n section: { example: 'section \"Settings\" expanded { ... }' },\n\n // Structure (reuse definitions — top level only)\n layout: {\n example: 'layout app { header { ... } slot footer { ... } }',\n validParents: [],\n },\n component: {\n example: 'component userbadge { avatar \"SW\" text \"Seungwoo\" }',\n validParents: [],\n },\n slot: {\n example: 'slot',\n validParents: ['layout'],\n },\n use: {\n example: 'use userbadge(name=\"Ada\") { ... }',\n },\n\n // Grid\n row: { example: 'row flex gap=4 justify=between { ... }' },\n col: { example: 'col span=6 md=4 { ... }' },\n stack: { example: 'stack gap=4 align=center { ... }' },\n relative: { example: 'relative { button \"Submit\" marker 1 anchor=top-right }' },\n\n // Container\n card: { example: 'card \"Settings\" p=4 shadow=md { ... }' },\n modal: { example: 'modal \"Confirm\" w=400 { ... }' },\n drawer: { example: 'drawer \"Menu\" position=left { ... }' },\n accordion: { example: 'accordion { section \"FAQ 1\" { ... } }' },\n\n // Text\n text: { example: 'text \"Hello World\" size=lg weight=bold' },\n title: { example: 'title \"Welcome\" level=2' },\n link: { example: 'link \"Learn more\" href=\"/docs\" external' },\n\n // Input\n input: { example: 'input \"Email\" inputType=email placeholder=\"user@example.com\" required' },\n textarea: { example: 'textarea \"Description\" rows=4 placeholder=\"Enter description...\"' },\n select: { example: 'select \"Country\" [\"USA\", \"Canada\", \"UK\"] placeholder=\"Select...\"' },\n checkbox: { example: 'checkbox \"I agree to terms\" checked' },\n radio: { example: 'radio \"Option A\" name=\"choice\" checked' },\n switch: { example: 'switch \"Dark mode\" checked' },\n slider: { example: 'slider \"Volume\" min=0 max=100 value=50' },\n button: { example: 'button \"Submit\" primary icon=send' },\n\n // Display\n image: { example: 'image w=200 h=150' },\n placeholder: { example: 'placeholder \"Banner Image\" w=full h=200 { ... }' },\n avatar: { example: 'avatar \"John Doe\" size=lg' },\n badge: { example: 'badge \"New\" variant=success pill' },\n icon: { example: 'icon \"settings\" size=lg' },\n\n // Data\n table: {\n example:\n 'table striped bordered { columns [\"Name\", \"Email\"] row [\"John\", \"john@example.com\"] }',\n },\n list: { example: 'list ordered [\"First\", \"Second\", \"Third\"]' },\n\n // Feedback\n alert: { example: 'alert \"Changes saved!\" variant=success' },\n toast: { example: 'toast \"Item deleted\" position=bottom-right variant=danger' },\n progress: { example: 'progress value=75 label=\"Uploading...\"' },\n spinner: { example: 'spinner size=lg' },\n\n // Overlay\n tooltip: { example: 'tooltip \"More info\" position=top { icon \"circle-question-mark\" }' },\n popover: { example: 'popover \"Details\" { ... }' },\n dropdown: { example: 'dropdown { item \"Edit\" icon=pencil item \"Delete\" icon=trash danger }' },\n\n // Navigation\n nav: {\n example:\n 'nav [{ label=\"Home\" icon=house active }, { label=\"Settings\" icon=settings }] vertical',\n },\n tabs: { example: 'tabs { tab \"General\" active { ... } tab \"Advanced\" { ... } }' },\n breadcrumb: {\n example: 'breadcrumb [{ label=\"Home\" href=\"/\" }, { label=\"Products\" }, { label=\"Details\" }]',\n },\n\n // Divider\n divider: { example: 'divider my=4' },\n\n // Annotation\n marker: { example: 'marker 1 anchor=top-right color=blue' },\n annotations: {\n example: 'annotations title=\"화면 설명\" { item 1 \"제목\" { text \"설명\" } }',\n validChildren: ['item'],\n },\n item: {\n example: 'item 1 \"로그인 버튼\" { text \"OAuth 연동 예정\" }',\n validParents: ['annotations'],\n },\n}\n\nfunction toComponentDef(name: GrammarElementName): ComponentDef {\n const spec = COMPONENT_SPEC_BY_NAME[name]\n const { example, validChildren, validParents, extraAttributes } = EDITOR_METADATA[name]\n\n return {\n name: spec.name,\n nodeType: spec.nodeType,\n category: spec.category,\n attributes: [...spec.attributes, ...(extraAttributes ?? [])],\n hasChildren: spec.hasChildren,\n description: spec.description,\n example,\n ...(validChildren ? { validChildren } : {}),\n ...(validParents ? { validParents } : {}),\n }\n}\n\n/**\n * All components in Wireweave DSL\n */\nexport const ALL_COMPONENTS: ComponentDef[] = COMPONENT_NAMES.map(toComponentDef)\n\n/**\n * Map of component name to definition for quick lookup\n */\nexport const COMPONENT_MAP: Map<string, ComponentDef> = new Map(\n ALL_COMPONENTS.map((comp) => [comp.name, comp]),\n)\n\n/**\n * Map of AST node type to definition for quick lookup\n */\nexport const NODE_TYPE_MAP: Map<string, ComponentDef> = new Map(\n ALL_COMPONENTS.map((comp) => [comp.nodeType, comp]),\n)\n\n/**\n * Set of all valid component names\n */\nexport const VALID_COMPONENT_NAMES: ReadonlySet<string> = new Set(\n ALL_COMPONENTS.map((comp) => comp.name),\n)\n","/**\n * Attribute definitions for Wireweave DSL editors\n *\n * The attribute vocabulary — every name, its value type, enum values, and\n * description — comes from `@wireweave/core/spec`, which is the DSL's\n * specification. This module adds only what editors need on top: a code example\n * per attribute. Nothing here re-declares which attributes exist, so an\n * attribute can be introduced in exactly one place.\n *\n * The two exceptions are quarantined in `core-spec-gaps.ts`, which documents why\n * each one cannot be derived.\n */\n\nimport {\n ATTRIBUTE_SPECS,\n BOX_ATTRIBUTES as SPEC_BOX_ATTRIBUTES,\n CONTAINER_ATTRIBUTES as SPEC_CONTAINER_ATTRIBUTES,\n} from '@wireweave/core/spec'\nimport type { AttributeSpec } from '@wireweave/core/spec'\n\nimport { EDITOR_ONLY_ATTRIBUTES, PENDING_CORE_ATTRIBUTES } from './core-spec-gaps.js'\nimport type { AttributeDef } from './types.js'\n\n/**\n * Attributes every element honours, because each renderer turns them into that\n * element's own box.\n */\nexport const BOX_ATTRIBUTES: readonly string[] = SPEC_BOX_ATTRIBUTES\n\n/**\n * Attributes only the elements that render a flex container honour.\n *\n * Kept separate from {@link BOX_ATTRIBUTES} rather than merged into one \"common\"\n * list, which is the shape core replaced. The merged list said every element\n * accepts `direction` and `bg`; leaf controls build their own markup and read\n * neither, so offering them there completed attributes that render nothing.\n * Re-forming the union here would restore exactly that, one layer further out.\n */\nexport const CONTAINER_ATTRIBUTES: readonly string[] = SPEC_CONTAINER_ATTRIBUTES\n\n/**\n * Editor-only metadata: a usage example per spec attribute.\n *\n * Deliberately a total map. `toAttributeDef` throws when an attribute has no\n * example, so a new attribute in the core spec cannot reach an editor without\n * one — the same forcing function the element layer gets from its key type.\n */\nconst ATTRIBUTE_EXAMPLES: Readonly<Record<string, string>> = {\n // Spacing\n p: 'p=4',\n px: 'px=4',\n py: 'py=4',\n pt: 'pt=4',\n pr: 'pr=4',\n pb: 'pb=4',\n pl: 'pl=4',\n m: 'm=4',\n mx: 'mx=auto',\n my: 'my=4',\n mt: 'mt=4',\n mr: 'mr=4',\n mb: 'mb=4',\n ml: 'ml=4',\n gap: 'gap=4',\n\n // Size\n w: 'w=full',\n h: 'h=full',\n width: 'width=400',\n height: 'height=300',\n minW: 'minW=200',\n maxW: 'maxW=600',\n minH: 'minH=100',\n maxH: 'maxH=400',\n\n // Flex / Grid\n flex: 'flex',\n direction: 'direction=column',\n justify: 'justify=center',\n align: 'align=center',\n wrap: 'wrap',\n span: 'span=6',\n sm: 'sm=6',\n md: 'md=4',\n lg: 'lg=3',\n xl: 'xl=2',\n order: 'order=1',\n\n // Position\n x: 'x=100',\n y: 'y=50',\n position: 'position=left',\n\n // Visual\n border: 'border',\n rounded: 'rounded',\n shadow: 'shadow=md',\n bg: 'bg=muted',\n\n // Text\n size: 'size=lg',\n weight: 'weight=bold',\n level: 'level=2',\n muted: 'muted',\n bold: 'bold',\n\n // Button variants\n primary: 'primary',\n secondary: 'secondary',\n outline: 'outline',\n ghost: 'ghost',\n danger: 'danger',\n\n // Status variant\n variant: 'variant=success',\n\n // Form\n inputType: 'inputType=email',\n placeholder: 'placeholder=\"Enter text\"',\n value: 'value=\"default\"',\n label: 'label=\"Name\"',\n name: 'name=\"field\"',\n required: 'required',\n disabled: 'disabled',\n readonly: 'readonly',\n checked: 'checked',\n loading: 'loading',\n rows: 'rows=4',\n min: 'min=0',\n max: 'max=100',\n step: 'step=1',\n\n // Content\n title: 'title=\"Title\"',\n src: 'src=\"/image.png\"',\n alt: 'alt=\"Image\"',\n href: 'href=\"/path\"',\n icon: 'icon=\"home\"',\n external: 'external',\n\n // Accessibility\n aria: 'aria=\"Close dialog\"',\n 'aria-label': 'aria-label=\"Close dialog\"',\n\n // State\n active: 'active=0',\n expanded: 'expanded',\n centered: 'centered',\n vertical: 'vertical',\n scroll: 'scroll',\n\n // Feedback\n dismissible: 'dismissible',\n indeterminate: 'indeterminate',\n pill: 'pill',\n\n // Data\n striped: 'striped',\n bordered: 'bordered',\n hover: 'hover',\n ordered: 'ordered',\n none: 'none',\n\n // Page / viewport\n id: 'id=\"dashboard\"',\n viewport: 'viewport=\"1440x900\"',\n device: 'device=\"iphone14\"',\n\n // Reuse\n uses: 'uses=\"app-shell\"',\n\n // Interaction\n navigate: 'navigate=\"Dashboard\"',\n opens: 'opens=\"settings-modal\"',\n toggles: 'toggles=\"filter-drawer\"',\n action: 'action=back',\n\n // Typed state and events\n states: 'states=[{ name=allowed, valueType=boolean, initial=false }]',\n on: 'on={ event=click, effects=[{ kind=toggle, state=allowed }] }',\n visibleWhen: 'visibleWhen={ state=allowed, equals=true }',\n enabledWhen: 'enabledWhen={ state=allowed, equals=true }',\n\n // Annotation\n anchor: 'anchor=top-right',\n color: 'color=blue',\n}\n\nfunction toAttributeDef(spec: AttributeSpec): AttributeDef {\n const example = ATTRIBUTE_EXAMPLES[spec.name]\n if (example === undefined) {\n throw new Error(\n `[@wireweave/language-data] No editor example for attribute \"${spec.name}\". ` +\n `Add one to ATTRIBUTE_EXAMPLES in src/attributes.ts.`,\n )\n }\n if (spec.description === undefined) {\n throw new Error(\n `[@wireweave/language-data] Attribute \"${spec.name}\" has no description in the core spec.`,\n )\n }\n return {\n name: spec.name,\n type: spec.type,\n ...(spec.values ? { values: [...spec.values] } : {}),\n description: spec.description,\n example,\n }\n}\n\n/**\n * All attributes editors offer: the DSL specification, plus the two documented\n * gap categories in `core-spec-gaps.ts`.\n */\nexport const ATTRIBUTES: AttributeDef[] = [\n ...ATTRIBUTE_SPECS.map(toAttributeDef),\n ...EDITOR_ONLY_ATTRIBUTES,\n ...PENDING_CORE_ATTRIBUTES,\n]\n\n/**\n * Map of attribute name to definition for quick lookup\n */\nexport const ATTRIBUTE_MAP: Map<string, AttributeDef> = new Map(\n ATTRIBUTES.map((attr) => [attr.name, attr]),\n)\n\n/**\n * Set of all valid attribute names\n */\nexport const VALID_ATTRIBUTE_NAMES: ReadonlySet<string> = new Set(\n ATTRIBUTES.map((attr) => attr.name),\n)\n","/**\n * Vocabulary the editors need that `@wireweave/core/spec` does not state.\n *\n * Every other name in this package is derived from the core spec, which derives\n * the element set from the grammar. Two kinds of entry cannot be derived, and\n * they are different in kind — keeping them apart is the point of this module:\n *\n * - **`EDITOR_ONLY_*` is permanent and correct.** These are things an author\n * types that the grammar desugars into a *different* AST key, so they never\n * become attribute keys and correctly have no `AttributeSpec`. `ATTRIBUTE_SPECS`\n * is keyed by the AST alphabet — `validate()` reads node keys — while editors\n * complete the source alphabet. Where the two differ, the source spelling lives\n * here. Entries must never be \"fixed\" by adding them to core.\n *\n * - **`PENDING_CORE_ATTRIBUTES` is a defect list.** Each entry is real DSL —\n * parsed, rendered, and consumed by core itself — that core's spec omits.\n * Because `validate()` derives its known-attribute set from `ATTRIBUTE_SPECS`,\n * every entry there is reported as an unknown attribute. They belong in\n * `packages/core/src/spec/attributes.ts`; until they land, dropping them would\n * silently delete working vocabulary from autocomplete and hover.\n *\n * `core-spec-sync.test.ts` asserts this list stays disjoint from core, so the\n * moment core adopts an entry the build fails until the entry is deleted here.\n * The list can only shrink.\n *\n * Neither kind may restate a value core already declares. A desugared spelling\n * shares one value space with the AST key it becomes, so it reads that space out\n * of `ATTRIBUTE_SPECS` rather than repeating it — a second copy would drift the\n * moment core adds a value, and no gate would notice.\n */\n\nimport { ATTRIBUTE_SPECS } from '@wireweave/core/spec'\n\nimport type { AttributeDef } from './types.js'\n\n/**\n * The value space core declares for `name`, read out of the attribute registry.\n *\n * Returns `undefined` when core declares no such attribute, which the sync test\n * turns into a failure — a silent `undefined` here would empty an editor-only\n * entry's completions without breaking anything else.\n */\nfunction coreValuesOf(name: string): string[] | undefined {\n const values = ATTRIBUTE_SPECS.find((spec) => spec.name === name)?.values\n return values ? [...values] : undefined\n}\n\n/**\n * Surface syntax editors complete, which is deliberately not an attribute.\n */\nexport const EDITOR_ONLY_ATTRIBUTES: readonly AttributeDef[] = [\n {\n name: 'at',\n type: 'function',\n description:\n 'Place page on the multi-page canvas at (x, y) — pages without at() auto-flow horizontally',\n example: 'at(0, 0)',\n },\n {\n // Desugared, not missing. `wireframe.peggy` (Input rule) reads the authored\n // `type`, deletes it, and re-emits it as `inputType`; the renderer then reads\n // `node.inputType` for the HTML type attribute. The rename is forced, not\n // incidental: `type` is every AST node's kind discriminant, which is why\n // `validation/index.ts` lists it among the structural keys it skips. Adding\n // `type` to `ATTRIBUTE_SPECS` would put the same name in `validate()`'s\n // known-attribute set and its structural-skip set at once, so core is right\n // to declare only `inputType` and this is the source spelling's only home.\n name: 'type',\n type: 'string',\n // One attribute, two spellings — so one value space. Copying core's list\n // would let `inputType` gain a value that `type=` never completes.\n values: coreValuesOf('inputType'),\n description: 'Input type — written as `type` and stored on the node as `inputType`',\n example: 'type=email',\n },\n]\n\n/**\n * Real attributes missing from `ATTRIBUTE_SPECS`.\n *\n * Empty: core's attribute registry states every attribute the editors need.\n *\n * An entry belongs here only while core omits an attribute that the DSL already\n * parses, renders, and consumes — dropping such a name instead would silently\n * delete working vocabulary from autocomplete and hover. Each entry carries the\n * evidence (the types, renderer, and consumers that prove the attribute is real)\n * so the core-side fix is actionable rather than a bare list of names.\n */\nexport const PENDING_CORE_ATTRIBUTES: readonly AttributeDef[] = []\n","/**\n * Keywords and labels for Wireweave DSL\n *\n * `VALUE_KEYWORDS` is derived from the attribute specification: an enum value is\n * a value keyword because some attribute accepts it, so listing them separately\n * could only ever drift. Categories come from `@wireweave/core/spec` too — this\n * module supplies their display labels, nothing more.\n */\n\nimport { ATTRIBUTE_SPECS } from '@wireweave/core/spec'\n\nimport { PENDING_CORE_ATTRIBUTES } from './core-spec-gaps.js'\nimport type { ComponentCategory } from './types.js'\n\n// Category labels for display\nexport const CATEGORY_LABELS: Record<ComponentCategory, string> = {\n structure: 'Structure',\n layout: 'Layout',\n container: 'Container',\n grid: 'Grid',\n text: 'Text',\n input: 'Input',\n display: 'Display',\n data: 'Data',\n feedback: 'Feedback',\n overlay: 'Overlay',\n navigation: 'Navigation',\n annotation: 'Annotation',\n}\n\n/**\n * Literals owned by the grammar rather than by any attribute: the `Boolean` rule\n * in `wireframe.peggy` accepts exactly these two as a bare attribute value.\n */\nconst BOOLEAN_LITERALS: readonly string[] = ['true', 'false']\n\n/**\n * Value keywords used in the language — every value an attribute enumerates,\n * plus the grammar's boolean literals.\n *\n * Built from the core registry, deliberately not from this package's own\n * `ATTRIBUTES`. `core-spec-sync.test.ts` computes the same set from `ATTRIBUTES`\n * and asserts the two agree, which only means something while the two sides are\n * different expressions. Collapsing them onto one source would turn that\n * assertion into a restatement of this line and stop it catching anything.\n */\nexport const VALUE_KEYWORDS: string[] = [\n ...new Set([\n ...BOOLEAN_LITERALS,\n ...ATTRIBUTE_SPECS.flatMap((attr) => attr.values ?? []),\n ...PENDING_CORE_ATTRIBUTES.flatMap((attr) => attr.values ?? []),\n ]),\n]\n\n// Common number suggestions for attributes\nexport const COMMON_NUMBERS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 48, 64]\n\n// Spacing scale (4px base)\nexport const SPACING_SCALE: Record<number, string> = {\n 0: '0px',\n 1: '4px',\n 2: '8px',\n 3: '12px',\n 4: '16px',\n 5: '20px',\n 6: '24px',\n 8: '32px',\n 10: '40px',\n 12: '48px',\n 16: '64px',\n 20: '80px',\n 24: '96px',\n}\n","/**\n * Utility functions for Wireweave language data\n */\n\nimport type { ComponentDef, AttributeDef } from './types.js'\nimport { ALL_COMPONENTS, COMPONENT_MAP, NODE_TYPE_MAP } from './components.js'\nimport { ATTRIBUTES, ATTRIBUTE_MAP } from './attributes.js'\n\n/**\n * Get component definition by name\n */\nexport function getComponent(name: string): ComponentDef | undefined {\n return COMPONENT_MAP.get(name.toLowerCase())\n}\n\n/**\n * Get component definition by AST node type\n */\nexport function getComponentByNodeType(nodeType: string): ComponentDef | undefined {\n return NODE_TYPE_MAP.get(nodeType)\n}\n\n/**\n * Get attribute definition by name\n */\nexport function getAttribute(name: string): AttributeDef | undefined {\n return ATTRIBUTE_MAP.get(name)\n}\n\n/**\n * Get valid child components for a parent component\n */\nexport function getValidChildren(componentName: string): ComponentDef[] {\n const component = getComponent(componentName)\n if (!component || !component.hasChildren) return []\n\n if (component.validChildren === undefined) {\n // All components except page are valid children\n return ALL_COMPONENTS.filter((c) => c.name !== 'page')\n }\n\n return component.validChildren\n .map((name) => getComponent(name))\n .filter((c): c is ComponentDef => c !== undefined)\n}\n\n/**\n * Check if a component is a valid child of another\n */\nexport function isValidChild(childName: string, parentName: string): boolean {\n const parent = getComponent(parentName)\n if (!parent || !parent.hasChildren) return false\n\n if (parent.validChildren === undefined) return true\n return parent.validChildren.includes(childName.toLowerCase())\n}\n\n/**\n * Get attribute definitions for a specific component\n */\nexport function getComponentAttributes(componentName: string): AttributeDef[] {\n const component = getComponent(componentName)\n if (!component) return ATTRIBUTES\n\n return ATTRIBUTES.filter((attr) => component.attributes.includes(attr.name))\n}\n\n/**\n * Get all components in a category\n */\nexport function getComponentsByCategory(category: string): ComponentDef[] {\n return ALL_COMPONENTS.filter((c) => c.category === category)\n}\n\n/**\n * Get attribute type label for display\n */\nexport function getAttributeTypeLabel(attr: AttributeDef): string {\n if (attr.type === 'boolean') return 'boolean'\n if (attr.type === 'number') return 'number'\n if (attr.type === 'string' || attr.type === 'string[]') return 'string'\n if (attr.type === 'enum' && attr.values) {\n const preview = attr.values.slice(0, 3).join(' | ')\n return attr.values.length > 3 ? `${preview}...` : preview\n }\n if (attr.type === 'function') return `function (${attr.example})`\n return attr.type\n}\n\n/**\n * Format attribute values for display\n */\nexport function formatAttributeValues(attr: AttributeDef): string {\n if (attr.type === 'number') return 'Type: number'\n if (attr.type === 'string') return 'Type: string'\n if (attr.type === 'boolean') return 'Type: boolean (can be omitted)'\n if (attr.type === 'enum' && attr.values) {\n return `Values: ${attr.values.join(' | ')}`\n }\n if (attr.type === 'function') return `Functional shorthand. Example: ${attr.example}`\n return `Type: ${attr.type}`\n}\n\n/**\n * Check if a word is a known component\n */\nexport function isComponent(word: string): boolean {\n return COMPONENT_MAP.has(word.toLowerCase())\n}\n\n/**\n * Check if a word is a known attribute\n */\nexport function isAttribute(word: string): boolean {\n return ATTRIBUTE_MAP.has(word)\n}\n\n/**\n * Get all component names\n */\nexport function getComponentNames(): string[] {\n return ALL_COMPONENTS.map((c) => c.name)\n}\n\n/**\n * Get all attribute names\n */\nexport function getAttributeNames(): string[] {\n return ATTRIBUTES.map((a) => a.name)\n}\n\n/**\n * Get all unique categories\n */\nexport function getCategories(): string[] {\n return [...new Set(ALL_COMPONENTS.map((c) => c.category))]\n}\n","/**\n * CodeMirror Language Definition for Wireframe DSL\n *\n * Provides syntax highlighting using StreamLanguage\n */\n\nimport type { StringStream } from '@codemirror/language'\nimport { ALL_COMPONENTS, ATTRIBUTES, VALUE_KEYWORDS } from '../index.js'\n\n// Component names for highlighting\nconst COMPONENT_NAMES = ALL_COMPONENTS.map((c) => c.name)\n\n// Attribute names for highlighting\nconst ATTRIBUTE_NAMES = ATTRIBUTES.map((a) => a.name)\n\n/**\n * StreamLanguage token function for CodeMirror\n * Use with StreamLanguage.define()\n */\nexport function createTokenizer() {\n return {\n token(stream: StringStream): string | null {\n // Skip whitespace\n if (stream.eatSpace()) return null\n\n // Comments\n if (stream.match('//')) {\n stream.skipToEnd()\n return 'comment'\n }\n\n // Strings\n if (stream.match(/\"[^\"]*\"/)) {\n return 'string'\n }\n\n // Numbers\n if (stream.match(/\\d+/)) {\n return 'number'\n }\n\n // Check for component keywords\n for (const kw of COMPONENT_NAMES) {\n if (stream.match(new RegExp(`^${kw}\\\\b`))) {\n return 'keyword'\n }\n }\n\n // Check for attribute names\n for (const attr of ATTRIBUTE_NAMES) {\n if (stream.match(new RegExp(`^${attr}\\\\b`))) {\n return 'propertyName'\n }\n }\n\n // Check for value keywords\n for (const val of VALUE_KEYWORDS) {\n if (stream.match(new RegExp(`^${val}\\\\b`))) {\n return 'atom'\n }\n }\n\n // Operators\n if (stream.match(/[=]/)) {\n return 'operator'\n }\n\n // Braces\n if (stream.match(/[{}[\\]()]/)) {\n return 'bracket'\n }\n\n // Skip other characters\n stream.next()\n return null\n },\n }\n}\n\n/**\n * Get language configuration for CodeMirror\n * Returns configuration for auto-closing brackets, comments, etc.\n */\nexport function getLanguageConfig() {\n return {\n commentTokens: { line: '//' },\n closeBrackets: { brackets: ['(', '[', '{', '\"'] },\n indentOnInput: /^\\s*\\}$/,\n }\n}\n","/**\n * CodeMirror Completion Provider for Wireframe DSL\n *\n * Provides auto-completion for components, attributes, and values\n */\n\nimport type { CompletionContext, CompletionResult } from '@codemirror/autocomplete'\nimport {\n ALL_COMPONENTS,\n ATTRIBUTES,\n getComponent,\n getAttribute,\n getComponentAttributes,\n getValidChildren,\n} from '../index.js'\nimport { CATEGORY_LABELS } from '../keywords.js'\n\n/**\n * Get category label for display\n */\nfunction getCategoryLabel(category: string): string {\n return CATEGORY_LABELS[category as keyof typeof CATEGORY_LABELS] || category\n}\n\n/**\n * Find parent component from cursor position\n */\nfunction findParentComponent(text: string, pos: number): string | null {\n let braceCount = 0\n\n for (let i = pos - 1; i >= 0; i--) {\n if (text[i] === '}') braceCount++\n if (text[i] === '{') {\n braceCount--\n if (braceCount < 0) {\n // Find component name before this brace\n const beforeBrace = text.substring(0, i)\n const match = beforeBrace.match(/(\\w+)(?:\\s+\"[^\"]*\")?\\s*$/)\n return match ? match[1] : null\n }\n }\n }\n\n return null\n}\n\n/**\n * Completion option type for CodeMirror\n */\ninterface CompletionOption {\n label: string\n type: string\n detail?: string\n info?: string\n boost?: number\n apply?: string\n}\n\n/**\n * Create completion source for CodeMirror\n *\n * Usage:\n * ```typescript\n * import { autocompletion } from '@codemirror/autocomplete';\n * import { createCompletionSource } from '@wireweave/language-data/codemirror';\n *\n * const extensions = [\n * autocompletion({ override: [createCompletionSource()] })\n * ];\n * ```\n */\nexport function createCompletionSource() {\n return (context: CompletionContext): CompletionResult | null => {\n const { state, pos } = context\n const line = state.doc.lineAt(pos)\n const textBefore = state.doc.sliceString(line.from, pos)\n const fullText = state.doc.toString()\n\n // Get word at cursor\n const wordMatch = textBefore.match(/(\\w*)$/)\n const word = wordMatch ? wordMatch[1] : ''\n const from = pos - word.length\n\n const options: CompletionOption[] = []\n\n // After '=' - suggest values\n const attrMatch = textBefore.match(/(\\w+)\\s*=\\s*$/)\n if (attrMatch) {\n const attrName = attrMatch[1]\n const attr = getAttribute(attrName)\n\n if (attr && attr.type === 'enum' && attr.values) {\n attr.values.forEach((value: string) => {\n options.push({\n label: value,\n type: 'enum',\n detail: `value for ${attrName}`,\n })\n })\n } else if (attr?.type === 'number') {\n ;[1, 2, 3, 4, 5, 6, 8, 10, 12, 16].forEach((n) => {\n options.push({\n label: String(n),\n type: 'constant',\n detail: 'number',\n })\n })\n }\n\n if (options.length > 0) {\n return { from, options }\n }\n }\n\n // At start of line or after { - suggest components\n if (textBefore.match(/^\\s*\\w*$/) || textBefore.match(/\\{\\s*\\w*$/)) {\n const parentComponent = findParentComponent(fullText, pos)\n const validChildren = parentComponent ? getValidChildren(parentComponent) : []\n const validChildNames = new Set(validChildren.map((c) => c.name))\n const isRootLevel = !parentComponent\n\n ALL_COMPONENTS.forEach((comp) => {\n const isValidInContext = isRootLevel\n ? comp.name === 'page'\n : validChildNames.size === 0 || validChildNames.has(comp.name)\n\n options.push({\n label: comp.name,\n type: isValidInContext ? 'class' : 'type',\n detail: isValidInContext\n ? `${getCategoryLabel(comp.category)} (recommended)`\n : getCategoryLabel(comp.category),\n info: comp.description,\n boost: isValidInContext ? 10 : 0,\n apply: comp.hasChildren ? `${comp.name} {\\n\\t\\n}` : comp.name,\n })\n })\n\n return { from, options }\n }\n\n // After component name - suggest attributes\n const componentMatch = textBefore.match(/(\\w+)(?:\\s+\"[^\"]*\")?\\s+(\\w*)$/)\n if (componentMatch) {\n const compName = componentMatch[1]\n const component = getComponent(compName)\n\n if (component) {\n const attrs = getComponentAttributes(compName)\n attrs.forEach((attr) => {\n let apply = attr.name\n if (attr.type === 'string') {\n apply = `${attr.name}=\"\"`\n } else if (attr.type === 'number' || attr.type === 'enum') {\n apply = `${attr.name}=`\n } else if (attr.type === 'function') {\n apply = `${attr.name}(`\n }\n\n options.push({\n label: attr.name,\n type: 'property',\n detail: attr.type,\n info: attr.description,\n apply,\n })\n })\n } else {\n // Unknown component, suggest all attributes\n ATTRIBUTES.forEach((attr) => {\n let apply = attr.name\n if (attr.type === 'string') {\n apply = `${attr.name}=\"\"`\n } else if (attr.type === 'number' || attr.type === 'enum') {\n apply = `${attr.name}=`\n } else if (attr.type === 'function') {\n apply = `${attr.name}(`\n }\n\n options.push({\n label: attr.name,\n type: 'property',\n detail: attr.type,\n info: attr.description,\n apply,\n })\n })\n }\n\n return { from, options }\n }\n\n // Default: suggest components\n ALL_COMPONENTS.forEach((comp) => {\n options.push({\n label: comp.name,\n type: 'class',\n detail: getCategoryLabel(comp.category),\n info: comp.description,\n apply: comp.hasChildren ? `${comp.name} {\\n\\t\\n}` : comp.name,\n })\n })\n\n return { from, options }\n }\n}\n","/**\n * CodeMirror Hover Provider for Wireframe DSL\n *\n * Provides hover tooltips for components, attributes, and values\n */\n\nimport type { EditorView } from '@codemirror/view'\nimport { ATTRIBUTES, getComponent, getAttribute, VALUE_KEYWORDS } from '../index.js'\nimport { CATEGORY_LABELS } from '../keywords.js'\n\n/**\n * Get category label for display\n */\nfunction getCategoryLabel(category: string): string {\n return CATEGORY_LABELS[category as keyof typeof CATEGORY_LABELS] || category\n}\n\n/**\n * Get word at position in text\n */\nfunction getWordAt(text: string, pos: number): { word: string; from: number; to: number } | null {\n // Find word boundaries\n let from = pos\n let to = pos\n\n while (from > 0 && /\\w/.test(text[from - 1])) from--\n while (to < text.length && /\\w/.test(text[to])) to++\n\n if (from === to) return null\n\n return {\n word: text.slice(from, to),\n from,\n to,\n }\n}\n\n/**\n * Create hover tooltip extension for CodeMirror\n *\n * Usage:\n * ```typescript\n * import { hoverTooltip } from '@codemirror/view';\n * import { createHoverTooltipSource } from '@wireweave/language-data/codemirror';\n *\n * const extensions = [\n * hoverTooltip(createHoverTooltipSource())\n * ];\n * ```\n */\nexport function createHoverTooltipSource() {\n return (view: EditorView, pos: number, _side: -1 | 1) => {\n const { state } = view\n const text = state.doc.toString()\n const wordInfo = getWordAt(text, pos)\n\n if (!wordInfo) return null\n\n const { word, from, to } = wordInfo\n\n // Check if it's a component\n const component = getComponent(word)\n if (component) {\n return {\n pos: from,\n end: to,\n above: true,\n create() {\n const dom = document.createElement('div')\n dom.className = 'cm-tooltip-hover'\n dom.innerHTML = `\n <div style=\"padding: 8px 12px; max-width: 400px;\">\n <div style=\"font-weight: bold; margin-bottom: 4px;\">\n ${component.name}\n <span style=\"opacity: 0.7; font-weight: normal; font-size: 0.9em;\">\n (${getCategoryLabel(component.category)})\n </span>\n </div>\n <div style=\"margin-bottom: 8px; opacity: 0.9;\">${component.description}</div>\n ${component.example ? `<code style=\"display: block; padding: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; font-size: 0.85em; white-space: pre;\">${component.example}</code>` : ''}\n <div style=\"margin-top: 8px; font-size: 0.85em; opacity: 0.7;\">\n Attributes: ${component.attributes.join(', ')}\n </div>\n </div>\n `\n return { dom }\n },\n }\n }\n\n // Check if it's an attribute\n const attribute = getAttribute(word)\n if (attribute) {\n let valueInfo = ''\n if (attribute.type === 'number') {\n valueInfo = 'Type: number'\n } else if (attribute.type === 'string') {\n valueInfo = 'Type: string'\n } else if (attribute.type === 'boolean') {\n valueInfo = 'Type: boolean'\n } else if (attribute.type === 'enum' && attribute.values) {\n valueInfo = `Values: ${attribute.values.join(' | ')}`\n } else if (attribute.type === 'function') {\n valueInfo = `Functional shorthand. Example: ${attribute.example}`\n }\n\n return {\n pos: from,\n end: to,\n above: true,\n create() {\n const dom = document.createElement('div')\n dom.className = 'cm-tooltip-hover'\n dom.innerHTML = `\n <div style=\"padding: 8px 12px; max-width: 400px;\">\n <div style=\"font-weight: bold; margin-bottom: 4px;\">\n ${attribute.name}\n <span style=\"opacity: 0.7; font-weight: normal; font-size: 0.9em;\">(attribute)</span>\n </div>\n <div style=\"margin-bottom: 4px; opacity: 0.9;\">${attribute.description}</div>\n ${valueInfo ? `<div style=\"font-size: 0.85em; opacity: 0.8; font-family: monospace;\">${valueInfo}</div>` : ''}\n ${attribute.example ? `<div style=\"margin-top: 4px; font-size: 0.85em; opacity: 0.7;\">Example: <code>${attribute.example}</code></div>` : ''}\n </div>\n `\n return { dom }\n },\n }\n }\n\n // Check if it's a value keyword\n if (VALUE_KEYWORDS.includes(word)) {\n const relatedAttrs = ATTRIBUTES.filter((a) => a.type === 'enum' && a.values?.includes(word))\n\n if (relatedAttrs.length > 0) {\n return {\n pos: from,\n end: to,\n above: true,\n create() {\n const dom = document.createElement('div')\n dom.className = 'cm-tooltip-hover'\n dom.innerHTML = `\n <div style=\"padding: 8px 12px; max-width: 300px;\">\n <div style=\"font-weight: bold; margin-bottom: 4px;\">\n ${word}\n <span style=\"opacity: 0.7; font-weight: normal; font-size: 0.9em;\">(value)</span>\n </div>\n <div style=\"font-size: 0.9em; opacity: 0.8;\">\n Used in: ${relatedAttrs.map((a) => a.name).join(', ')}\n </div>\n </div>\n `\n return { dom }\n },\n }\n }\n }\n\n return null\n }\n}\n","/**\n * CodeMirror Linting Provider for Wireframe DSL\n *\n * Provides diagnostics for syntax errors, unknown components, etc.\n */\n\nimport type { Diagnostic as CMDiagnostic } from '@codemirror/lint'\nimport type { EditorView } from '@codemirror/view'\nimport { getComponent, getAttribute } from '../index.js'\n\n/**\n * Diagnostic severity levels\n */\nexport type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint'\n\n/**\n * Diagnostic interface\n */\nexport interface Diagnostic {\n from: number\n to: number\n severity: DiagnosticSeverity\n message: string\n}\n\n/**\n * Validate wireframe code and return diagnostics\n */\nexport function validateCode(text: string): Diagnostic[] {\n const diagnostics: Diagnostic[] = []\n const lines = text.split('\\n')\n\n const braceStack: { line: number; col: number; pos: number; component?: string }[] = []\n let hasPage = false\n let currentPos = 0\n\n for (let lineNum = 0; lineNum < lines.length; lineNum++) {\n const line = lines[lineNum]\n const lineStart = currentPos\n\n // Skip comments\n if (line.trim().startsWith('//')) {\n currentPos += line.length + 1\n continue\n }\n\n // Check for page component\n const pageMatch = line.match(/^\\s*page\\b/)\n if (pageMatch) {\n if (hasPage) {\n const matchStart = lineStart + line.indexOf('page')\n diagnostics.push({\n from: matchStart,\n to: matchStart + 4,\n severity: 'error',\n message: 'Only one page component is allowed.',\n })\n }\n hasPage = true\n }\n\n // Check for unknown components (at start of line, not after =)\n const componentMatch = line.match(/^\\s*(\\w+)(?:\\s|{|\")/)\n if (componentMatch) {\n const compName = componentMatch[1]\n if (!getComponent(compName) && !['true', 'false'].includes(compName)) {\n // Make sure it's not a value after =\n const beforeMatch = line.substring(0, componentMatch.index)\n if (!beforeMatch.match(/=\\s*$/)) {\n const matchStart = lineStart + (componentMatch.index || 0)\n diagnostics.push({\n from: matchStart,\n to: matchStart + compName.length,\n severity: 'warning',\n message: `Unknown component: \"${compName}\"`,\n })\n }\n }\n }\n\n // Check for unknown attributes\n const attrRegex = /\\b(\\w+)\\s*=/g\n let attrMatch\n while ((attrMatch = attrRegex.exec(line)) !== null) {\n const attrName = attrMatch[1]\n if (!getAttribute(attrName) && !getComponent(attrName)) {\n const matchStart = lineStart + attrMatch.index\n diagnostics.push({\n from: matchStart,\n to: matchStart + attrName.length,\n severity: 'warning',\n message: `Unknown attribute: \"${attrName}\"`,\n })\n }\n }\n\n // Track braces for matching\n for (let col = 0; col < line.length; col++) {\n if (line[col] === '{') {\n const beforeBrace = line.substring(0, col)\n const compMatch = beforeBrace.match(/(\\w+)(?:\\s+\"[^\"]*\")?\\s*$/)\n braceStack.push({\n line: lineNum,\n col,\n pos: lineStart + col,\n component: compMatch ? compMatch[1] : undefined,\n })\n } else if (line[col] === '}') {\n if (braceStack.length === 0) {\n diagnostics.push({\n from: lineStart + col,\n to: lineStart + col + 1,\n severity: 'error',\n message: 'Unmatched closing brace',\n })\n } else {\n braceStack.pop()\n }\n }\n }\n\n // Check for unclosed strings\n const quotes = line.match(/\"/g)\n if (quotes && quotes.length % 2 !== 0) {\n diagnostics.push({\n from: lineStart,\n to: lineStart + line.length,\n severity: 'error',\n message: 'Unclosed string',\n })\n }\n\n currentPos += line.length + 1\n }\n\n // Check for unclosed braces\n for (const brace of braceStack) {\n diagnostics.push({\n from: brace.pos,\n to: brace.pos + 1,\n severity: 'error',\n message: `Unclosed brace${brace.component ? ` (${brace.component})` : ''}`,\n })\n }\n\n // Info if no page component\n if (!hasPage && text.trim()) {\n diagnostics.push({\n from: 0,\n to: 0,\n severity: 'info',\n message: 'Consider starting with a page component.',\n })\n }\n\n return diagnostics\n}\n\n/**\n * Create linter extension for CodeMirror\n *\n * Usage:\n * ```typescript\n * import { linter } from '@codemirror/lint';\n * import { createLinter } from '@wireweave/language-data/codemirror';\n *\n * const extensions = [\n * linter(createLinter())\n * ];\n * ```\n */\nexport function createLinter() {\n return (view: EditorView): CMDiagnostic[] => {\n const text = view.state.doc.toString()\n const diagnostics = validateCode(text)\n\n return diagnostics.map((d) => ({\n from: d.from,\n to: d.to,\n severity: d.severity,\n message: d.message,\n }))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,kBAIO;AAmBP,IAAM,kBAA6E;AAAA;AAAA,EAEjF,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,eAAe,CAAC,UA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A,IAC1E,CAAC;AAAA,EACH;AAGA,MAAI,CAAC,WAAW,KAAK,KAAK,GAAG;AAC3B,gBAAY,KAAK;AAAA,MACf,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAeO,SAAS,eAAe;AAC7B,SAAO,CAAC,SAAqC;AAC3C,UAAM,OAAO,KAAK,MAAM,IAAI,SAAS;AACrC,UAAM,cAAc,aAAa,IAAI;AAErC,WAAO,YAAY,IAAI,CAAC,OAAO;AAAA,MAC7B,MAAM,EAAE;AAAA,MACR,IAAI,EAAE;AAAA,MACN,UAAU,EAAE;AAAA,MACZ,SAAS,EAAE;AAAA,IACb,EAAE;AAAA,EACJ;AACF;","names":["import_spec","import_spec","import_spec","COMPONENT_NAMES","getCategoryLabel"]}
|
|
1
|
+
{"version":3,"sources":["../../src/codemirror/index.ts","../../src/components.ts","../../src/attributes.ts","../../src/core-spec-gaps.ts","../../src/keywords.ts","../../src/utils.ts","../../src/codemirror/language.ts","../../src/codemirror/completion.ts","../../src/codemirror/hover.ts","../../src/codemirror/linting.ts"],"sourcesContent":["/**\n * CodeMirror Integration for Wireframe DSL\n *\n * Provides language definition, auto-completion, hover tooltips, and linting.\n *\n * Usage:\n * ```typescript\n * import { StreamLanguage } from '@codemirror/language';\n * import { autocompletion } from '@codemirror/autocomplete';\n * import { hoverTooltip } from '@codemirror/view';\n * import { linter } from '@codemirror/lint';\n * import {\n * createTokenizer,\n * createCompletionSource,\n * createHoverTooltipSource,\n * createLinter,\n * } from '@wireweave/language-data/codemirror';\n *\n * // Create language\n * const wireframeLanguage = StreamLanguage.define(createTokenizer());\n *\n * // Setup editor extensions\n * const extensions = [\n * wireframeLanguage,\n * autocompletion({ override: [createCompletionSource()] }),\n * hoverTooltip(createHoverTooltipSource()),\n * linter(createLinter()),\n * ];\n * ```\n */\n\n// Language definition\nexport { createTokenizer, getLanguageConfig } from './language.js'\n\n// Auto-completion\nexport { createCompletionSource } from './completion.js'\n\n// Hover tooltips\nexport { createHoverTooltipSource } from './hover.js'\n\n// Linting\nexport { validateCode, createLinter, type Diagnostic, type DiagnosticSeverity } from './linting.js'\n","/**\n * Component definitions for Wireweave DSL editors\n *\n * The element set and its core metadata (category, attributes, hasChildren,\n * description) come from `@wireweave/core/spec`, which derives them from the\n * grammar. This module only adds what editors need on top — an example snippet\n * and the parent/child hints used for autocomplete and validation.\n *\n * Nothing here re-declares which elements exist: the `Record<GrammarElementName,\n * …>` key type means a new grammar element fails to typecheck until its editor\n * metadata is filled in, and an entry for a non-element is rejected.\n */\n\nimport {\n COMPONENT_SPEC_BY_NAME,\n COMPONENT_NAMES,\n type GrammarElementName,\n} from '@wireweave/core/spec'\nimport type { ComponentDef } from './types.js'\n\n/** Editor-only metadata: everything the core spec does not already state. */\ninterface EditorComponentMeta {\n /** Code example for documentation and hover cards */\n example: string\n /** Valid child components (for autocomplete) */\n validChildren?: string[]\n /** Valid parent components (for validation hints) */\n validParents?: string[]\n /**\n * Attributes accepted by editors but not part of the core spec's attribute\n * list — currently the `at(x, y)` placement shorthand, which the grammar\n * parses as a functional attribute rather than a `name=value` pair.\n */\n extraAttributes?: string[]\n}\n\nconst EDITOR_METADATA: Readonly<Record<GrammarElementName, EditorComponentMeta>> = {\n // Layout\n page: {\n example: 'page \"Login\" at(0, 0) viewport=\"1280x800\" { ... }',\n validChildren: ['header', 'main', 'footer', 'sidebar', 'section', 'nav', 'row', 'col', 'card'],\n validParents: [],\n extraAttributes: ['at'],\n },\n header: { example: 'header h=56 border { ... }', validParents: ['page'] },\n main: { example: 'main p=6 scroll { ... }', validParents: ['page'] },\n footer: { example: 'footer h=48 border { ... }', validParents: ['page'] },\n sidebar: { example: 'sidebar w=240 border { ... }', validParents: ['page'] },\n section: { example: 'section \"Settings\" expanded { ... }' },\n\n // Structure (reuse definitions — top level only)\n layout: {\n example: 'layout app { header { ... } slot footer { ... } }',\n validParents: [],\n },\n component: {\n example: 'component userbadge { avatar \"SW\" text \"Seungwoo\" }',\n validParents: [],\n },\n slot: {\n example: 'slot',\n validParents: ['layout'],\n },\n use: {\n example: 'use userbadge(name=\"Ada\") { ... }',\n },\n repeat: {\n // No `validParents`: `repeat` is a fold, so it belongs wherever its body\n // would have been written out by hand — which is anywhere children go.\n example: 'row gap=4 { repeat 6 { use skeletonCard() } }',\n },\n\n // Grid\n row: { example: 'row flex gap=4 justify=between { ... }' },\n col: { example: 'col span=6 md=4 { ... }' },\n stack: { example: 'stack gap=4 align=center { ... }' },\n relative: { example: 'relative { button \"Submit\" marker 1 anchor=top-right }' },\n\n // Container\n card: { example: 'card \"Settings\" p=4 shadow=md { ... }' },\n modal: { example: 'modal \"Confirm\" w=400 { ... }' },\n drawer: { example: 'drawer \"Menu\" position=left { ... }' },\n accordion: { example: 'accordion { section \"FAQ 1\" { ... } }' },\n\n // Text\n text: { example: 'text \"Hello World\" size=lg weight=bold' },\n title: { example: 'title \"Welcome\" level=2' },\n link: { example: 'link \"Learn more\" href=\"/docs\" external' },\n\n // Input\n input: { example: 'input \"Email\" inputType=email placeholder=\"user@example.com\" required' },\n textarea: { example: 'textarea \"Description\" rows=4 placeholder=\"Enter description...\"' },\n select: { example: 'select \"Country\" [\"USA\", \"Canada\", \"UK\"] placeholder=\"Select...\"' },\n checkbox: { example: 'checkbox \"I agree to terms\" checked' },\n radio: { example: 'radio \"Option A\" name=\"choice\" checked' },\n switch: { example: 'switch \"Dark mode\" checked' },\n slider: { example: 'slider \"Volume\" min=0 max=100 value=50' },\n button: { example: 'button \"Submit\" primary icon=send' },\n\n // Display\n image: { example: 'image w=200 h=150' },\n placeholder: { example: 'placeholder \"Banner Image\" w=full h=200 { ... }' },\n avatar: { example: 'avatar \"John Doe\" size=lg' },\n badge: { example: 'badge \"New\" variant=success pill' },\n icon: { example: 'icon \"settings\" size=lg' },\n\n // Data\n table: {\n example:\n 'table striped bordered { columns [\"Name\", \"Email\"] row [\"John\", \"john@example.com\"] }',\n },\n list: { example: 'list ordered [\"First\", \"Second\", \"Third\"]' },\n\n // Feedback\n alert: { example: 'alert \"Changes saved!\" variant=success' },\n toast: { example: 'toast \"Item deleted\" position=bottom-right variant=danger' },\n progress: { example: 'progress value=75 label=\"Uploading...\"' },\n spinner: { example: 'spinner size=lg' },\n\n // Overlay\n tooltip: { example: 'tooltip \"More info\" position=top { icon \"circle-question-mark\" }' },\n popover: { example: 'popover \"Details\" { ... }' },\n dropdown: { example: 'dropdown { item \"Edit\" icon=pencil item \"Delete\" icon=trash danger }' },\n\n // Navigation\n nav: {\n example:\n 'nav [{ label=\"Home\" icon=house active }, { label=\"Settings\" icon=settings }] vertical',\n },\n tabs: { example: 'tabs { tab \"General\" active { ... } tab \"Advanced\" { ... } }' },\n breadcrumb: {\n example: 'breadcrumb [{ label=\"Home\" href=\"/\" }, { label=\"Products\" }, { label=\"Details\" }]',\n },\n\n // Divider\n divider: { example: 'divider my=4' },\n\n // Annotation\n marker: { example: 'marker 1 anchor=top-right color=blue' },\n annotations: {\n example: 'annotations title=\"화면 설명\" { item 1 \"제목\" { text \"설명\" } }',\n validChildren: ['item'],\n },\n item: {\n example: 'item 1 \"로그인 버튼\" { text \"OAuth 연동 예정\" }',\n validParents: ['annotations'],\n },\n}\n\nfunction toComponentDef(name: GrammarElementName): ComponentDef {\n const spec = COMPONENT_SPEC_BY_NAME[name]\n const { example, validChildren, validParents, extraAttributes } = EDITOR_METADATA[name]\n\n return {\n name: spec.name,\n nodeType: spec.nodeType,\n category: spec.category,\n attributes: [...spec.attributes, ...(extraAttributes ?? [])],\n hasChildren: spec.hasChildren,\n description: spec.description,\n example,\n ...(validChildren ? { validChildren } : {}),\n ...(validParents ? { validParents } : {}),\n }\n}\n\n/**\n * All components in Wireweave DSL\n */\nexport const ALL_COMPONENTS: ComponentDef[] = COMPONENT_NAMES.map(toComponentDef)\n\n/**\n * Map of component name to definition for quick lookup\n */\nexport const COMPONENT_MAP: Map<string, ComponentDef> = new Map(\n ALL_COMPONENTS.map((comp) => [comp.name, comp]),\n)\n\n/**\n * Map of AST node type to definition for quick lookup\n */\nexport const NODE_TYPE_MAP: Map<string, ComponentDef> = new Map(\n ALL_COMPONENTS.map((comp) => [comp.nodeType, comp]),\n)\n\n/**\n * Set of all valid component names\n */\nexport const VALID_COMPONENT_NAMES: ReadonlySet<string> = new Set(\n ALL_COMPONENTS.map((comp) => comp.name),\n)\n","/**\n * Attribute definitions for Wireweave DSL editors\n *\n * The attribute vocabulary — every name, its value type, enum values, and\n * description — comes from `@wireweave/core/spec`, which is the DSL's\n * specification. This module adds only what editors need on top: a code example\n * per attribute. Nothing here re-declares which attributes exist, so an\n * attribute can be introduced in exactly one place.\n *\n * The two exceptions are quarantined in `core-spec-gaps.ts`, which documents why\n * each one cannot be derived.\n */\n\nimport {\n ATTRIBUTE_SPECS,\n BOX_ATTRIBUTES as SPEC_BOX_ATTRIBUTES,\n CONTAINER_ATTRIBUTES as SPEC_CONTAINER_ATTRIBUTES,\n} from '@wireweave/core/spec'\nimport type { AttributeSpec } from '@wireweave/core/spec'\n\nimport { EDITOR_ONLY_ATTRIBUTES, PENDING_CORE_ATTRIBUTES } from './core-spec-gaps.js'\nimport type { AttributeDef } from './types.js'\n\n/**\n * Attributes every element honours, because each renderer turns them into that\n * element's own box.\n */\nexport const BOX_ATTRIBUTES: readonly string[] = SPEC_BOX_ATTRIBUTES\n\n/**\n * Attributes only the elements that render a flex container honour.\n *\n * Kept separate from {@link BOX_ATTRIBUTES} rather than merged into one \"common\"\n * list, which is the shape core replaced. The merged list said every element\n * accepts `direction` and `bg`; leaf controls build their own markup and read\n * neither, so offering them there completed attributes that render nothing.\n * Re-forming the union here would restore exactly that, one layer further out.\n */\nexport const CONTAINER_ATTRIBUTES: readonly string[] = SPEC_CONTAINER_ATTRIBUTES\n\n/**\n * Editor-only metadata: a usage example per spec attribute.\n *\n * Deliberately a total map. `toAttributeDef` throws when an attribute has no\n * example, so a new attribute in the core spec cannot reach an editor without\n * one — the same forcing function the element layer gets from its key type.\n */\nconst ATTRIBUTE_EXAMPLES: Readonly<Record<string, string>> = {\n // Spacing\n p: 'p=4',\n px: 'px=4',\n py: 'py=4',\n pt: 'pt=4',\n pr: 'pr=4',\n pb: 'pb=4',\n pl: 'pl=4',\n m: 'm=4',\n mx: 'mx=auto',\n my: 'my=4',\n mt: 'mt=4',\n mr: 'mr=4',\n mb: 'mb=4',\n ml: 'ml=4',\n gap: 'gap=4',\n\n // Size\n w: 'w=full',\n h: 'h=full',\n width: 'width=400',\n height: 'height=300',\n minW: 'minW=200',\n maxW: 'maxW=600',\n minH: 'minH=100',\n maxH: 'maxH=400',\n\n // Flex / Grid\n flex: 'flex',\n direction: 'direction=column',\n justify: 'justify=center',\n align: 'align=center',\n wrap: 'wrap',\n span: 'span=6',\n sm: 'sm=6',\n md: 'md=4',\n lg: 'lg=3',\n xl: 'xl=2',\n order: 'order=1',\n\n // Position\n x: 'x=100',\n y: 'y=50',\n position: 'position=left',\n\n // Visual\n border: 'border',\n rounded: 'rounded',\n shadow: 'shadow=md',\n bg: 'bg=muted',\n\n // Text\n size: 'size=lg',\n weight: 'weight=bold',\n level: 'level=2',\n muted: 'muted',\n bold: 'bold',\n\n // Button variants\n primary: 'primary',\n secondary: 'secondary',\n outline: 'outline',\n ghost: 'ghost',\n danger: 'danger',\n\n // Status variant\n variant: 'variant=success',\n\n // Form\n inputType: 'inputType=email',\n placeholder: 'placeholder=\"Enter text\"',\n value: 'value=\"default\"',\n label: 'label=\"Name\"',\n name: 'name=\"field\"',\n required: 'required',\n disabled: 'disabled',\n readonly: 'readonly',\n checked: 'checked',\n loading: 'loading',\n rows: 'rows=4',\n min: 'min=0',\n max: 'max=100',\n step: 'step=1',\n\n // Content\n title: 'title=\"Title\"',\n src: 'src=\"/image.png\"',\n alt: 'alt=\"Image\"',\n href: 'href=\"/path\"',\n icon: 'icon=\"home\"',\n external: 'external',\n\n // Accessibility\n aria: 'aria=\"Close dialog\"',\n 'aria-label': 'aria-label=\"Close dialog\"',\n\n // State\n active: 'active=0',\n expanded: 'expanded',\n centered: 'centered',\n vertical: 'vertical',\n scroll: 'scroll',\n\n // Feedback\n dismissible: 'dismissible',\n indeterminate: 'indeterminate',\n pill: 'pill',\n\n // Data\n striped: 'striped',\n bordered: 'bordered',\n hover: 'hover',\n ordered: 'ordered',\n none: 'none',\n\n // Page / viewport\n id: 'id=\"dashboard\"',\n viewport: 'viewport=\"1440x900\"',\n device: 'device=\"iphone14\"',\n\n // Reuse\n uses: 'uses=\"app-shell\"',\n variants: 'variants=[loading, empty, ready]',\n when: 'when=[loading, empty]',\n\n // Interaction\n navigate: 'navigate=\"Dashboard\"',\n opens: 'opens=\"settings-modal\"',\n toggles: 'toggles=\"filter-drawer\"',\n action: 'action=back',\n\n // Typed state and events\n states: 'states=[{ name=allowed, valueType=boolean, initial=false }]',\n on: 'on={ event=click, effects=[{ kind=toggle, state=allowed }] }',\n visibleWhen: 'visibleWhen={ state=allowed, equals=true }',\n enabledWhen: 'enabledWhen={ state=allowed, equals=true }',\n\n // Annotation\n anchor: 'anchor=top-right',\n color: 'color=blue',\n}\n\nfunction toAttributeDef(spec: AttributeSpec): AttributeDef {\n const example = ATTRIBUTE_EXAMPLES[spec.name]\n if (example === undefined) {\n throw new Error(\n `[@wireweave/language-data] No editor example for attribute \"${spec.name}\". ` +\n `Add one to ATTRIBUTE_EXAMPLES in src/attributes.ts.`,\n )\n }\n if (spec.description === undefined) {\n throw new Error(\n `[@wireweave/language-data] Attribute \"${spec.name}\" has no description in the core spec.`,\n )\n }\n return {\n name: spec.name,\n type: spec.type,\n ...(spec.values ? { values: [...spec.values] } : {}),\n description: spec.description,\n example,\n }\n}\n\n/**\n * All attributes editors offer: the DSL specification, plus the two documented\n * gap categories in `core-spec-gaps.ts`.\n */\nexport const ATTRIBUTES: AttributeDef[] = [\n ...ATTRIBUTE_SPECS.map(toAttributeDef),\n ...EDITOR_ONLY_ATTRIBUTES,\n ...PENDING_CORE_ATTRIBUTES,\n]\n\n/**\n * Map of attribute name to definition for quick lookup\n */\nexport const ATTRIBUTE_MAP: Map<string, AttributeDef> = new Map(\n ATTRIBUTES.map((attr) => [attr.name, attr]),\n)\n\n/**\n * Set of all valid attribute names\n */\nexport const VALID_ATTRIBUTE_NAMES: ReadonlySet<string> = new Set(\n ATTRIBUTES.map((attr) => attr.name),\n)\n","/**\n * Vocabulary the editors need that `@wireweave/core/spec` does not state.\n *\n * Every other name in this package is derived from the core spec, which derives\n * the element set from the grammar. Two kinds of entry cannot be derived, and\n * they are different in kind — keeping them apart is the point of this module:\n *\n * - **`EDITOR_ONLY_*` is permanent and correct.** These are things an author\n * types that the grammar desugars into a *different* AST key, so they never\n * become attribute keys and correctly have no `AttributeSpec`. `ATTRIBUTE_SPECS`\n * is keyed by the AST alphabet — `validate()` reads node keys — while editors\n * complete the source alphabet. Where the two differ, the source spelling lives\n * here. Entries must never be \"fixed\" by adding them to core.\n *\n * - **`PENDING_CORE_ATTRIBUTES` is a defect list.** Each entry is real DSL —\n * parsed, rendered, and consumed by core itself — that core's spec omits.\n * Because `validate()` derives its known-attribute set from `ATTRIBUTE_SPECS`,\n * every entry there is reported as an unknown attribute. They belong in\n * `packages/core/src/spec/attributes.ts`; until they land, dropping them would\n * silently delete working vocabulary from autocomplete and hover.\n *\n * `core-spec-sync.test.ts` asserts this list stays disjoint from core, so the\n * moment core adopts an entry the build fails until the entry is deleted here.\n * The list can only shrink.\n *\n * Neither kind may restate a value core already declares. A desugared spelling\n * shares one value space with the AST key it becomes, so it reads that space out\n * of `ATTRIBUTE_SPECS` rather than repeating it — a second copy would drift the\n * moment core adds a value, and no gate would notice.\n */\n\nimport { ATTRIBUTE_SPECS } from '@wireweave/core/spec'\n\nimport type { AttributeDef } from './types.js'\n\n/**\n * The value space core declares for `name`, read out of the attribute registry.\n *\n * Returns `undefined` when core declares no such attribute, which the sync test\n * turns into a failure — a silent `undefined` here would empty an editor-only\n * entry's completions without breaking anything else.\n */\nfunction coreValuesOf(name: string): string[] | undefined {\n const values = ATTRIBUTE_SPECS.find((spec) => spec.name === name)?.values\n return values ? [...values] : undefined\n}\n\n/**\n * Surface syntax editors complete, which is deliberately not an attribute.\n */\nexport const EDITOR_ONLY_ATTRIBUTES: readonly AttributeDef[] = [\n {\n name: 'at',\n type: 'function',\n description:\n 'Place page on the multi-page canvas at (x, y) — pages without at() auto-flow horizontally',\n example: 'at(0, 0)',\n },\n {\n // Desugared, not missing. `wireframe.peggy` (Input rule) reads the authored\n // `type`, deletes it, and re-emits it as `inputType`; the renderer then reads\n // `node.inputType` for the HTML type attribute. The rename is forced, not\n // incidental: `type` is every AST node's kind discriminant, which is why\n // `validation/index.ts` lists it among the structural keys it skips. Adding\n // `type` to `ATTRIBUTE_SPECS` would put the same name in `validate()`'s\n // known-attribute set and its structural-skip set at once, so core is right\n // to declare only `inputType` and this is the source spelling's only home.\n name: 'type',\n type: 'string',\n // One attribute, two spellings — so one value space. Copying core's list\n // would let `inputType` gain a value that `type=` never completes.\n values: coreValuesOf('inputType'),\n description: 'Input type — written as `type` and stored on the node as `inputType`',\n example: 'type=email',\n },\n]\n\n/**\n * Real attributes missing from `ATTRIBUTE_SPECS`.\n *\n * Empty: core's attribute registry states every attribute the editors need.\n *\n * An entry belongs here only while core omits an attribute that the DSL already\n * parses, renders, and consumes — dropping such a name instead would silently\n * delete working vocabulary from autocomplete and hover. Each entry carries the\n * evidence (the types, renderer, and consumers that prove the attribute is real)\n * so the core-side fix is actionable rather than a bare list of names.\n */\nexport const PENDING_CORE_ATTRIBUTES: readonly AttributeDef[] = []\n","/**\n * Keywords and labels for Wireweave DSL\n *\n * `VALUE_KEYWORDS` is derived from the attribute specification: an enum value is\n * a value keyword because some attribute accepts it, so listing them separately\n * could only ever drift. Categories come from `@wireweave/core/spec` too — this\n * module supplies their display labels, nothing more.\n */\n\nimport { ATTRIBUTE_SPECS } from '@wireweave/core/spec'\n\nimport { PENDING_CORE_ATTRIBUTES } from './core-spec-gaps.js'\nimport type { ComponentCategory } from './types.js'\n\n// Category labels for display\nexport const CATEGORY_LABELS: Record<ComponentCategory, string> = {\n structure: 'Structure',\n layout: 'Layout',\n container: 'Container',\n grid: 'Grid',\n text: 'Text',\n input: 'Input',\n display: 'Display',\n data: 'Data',\n feedback: 'Feedback',\n overlay: 'Overlay',\n navigation: 'Navigation',\n annotation: 'Annotation',\n}\n\n/**\n * Literals owned by the grammar rather than by any attribute: the `Boolean` rule\n * in `wireframe.peggy` accepts exactly these two as a bare attribute value.\n */\nconst BOOLEAN_LITERALS: readonly string[] = ['true', 'false']\n\n/**\n * Value keywords used in the language — every value an attribute enumerates,\n * plus the grammar's boolean literals.\n *\n * Built from the core registry, deliberately not from this package's own\n * `ATTRIBUTES`. `core-spec-sync.test.ts` computes the same set from `ATTRIBUTES`\n * and asserts the two agree, which only means something while the two sides are\n * different expressions. Collapsing them onto one source would turn that\n * assertion into a restatement of this line and stop it catching anything.\n */\nexport const VALUE_KEYWORDS: string[] = [\n ...new Set([\n ...BOOLEAN_LITERALS,\n ...ATTRIBUTE_SPECS.flatMap((attr) => attr.values ?? []),\n ...PENDING_CORE_ATTRIBUTES.flatMap((attr) => attr.values ?? []),\n ]),\n]\n\n// Common number suggestions for attributes\nexport const COMMON_NUMBERS = [0, 1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32, 48, 64]\n\n// Spacing scale (4px base)\nexport const SPACING_SCALE: Record<number, string> = {\n 0: '0px',\n 1: '4px',\n 2: '8px',\n 3: '12px',\n 4: '16px',\n 5: '20px',\n 6: '24px',\n 8: '32px',\n 10: '40px',\n 12: '48px',\n 16: '64px',\n 20: '80px',\n 24: '96px',\n}\n","/**\n * Utility functions for Wireweave language data\n */\n\nimport type { ComponentDef, AttributeDef } from './types.js'\nimport { ALL_COMPONENTS, COMPONENT_MAP, NODE_TYPE_MAP } from './components.js'\nimport { ATTRIBUTES, ATTRIBUTE_MAP } from './attributes.js'\n\n/**\n * Get component definition by name\n */\nexport function getComponent(name: string): ComponentDef | undefined {\n return COMPONENT_MAP.get(name.toLowerCase())\n}\n\n/**\n * Get component definition by AST node type\n */\nexport function getComponentByNodeType(nodeType: string): ComponentDef | undefined {\n return NODE_TYPE_MAP.get(nodeType)\n}\n\n/**\n * Get attribute definition by name\n */\nexport function getAttribute(name: string): AttributeDef | undefined {\n return ATTRIBUTE_MAP.get(name)\n}\n\n/**\n * Get valid child components for a parent component\n */\nexport function getValidChildren(componentName: string): ComponentDef[] {\n const component = getComponent(componentName)\n if (!component || !component.hasChildren) return []\n\n if (component.validChildren === undefined) {\n // All components except page are valid children\n return ALL_COMPONENTS.filter((c) => c.name !== 'page')\n }\n\n return component.validChildren\n .map((name) => getComponent(name))\n .filter((c): c is ComponentDef => c !== undefined)\n}\n\n/**\n * Check if a component is a valid child of another\n */\nexport function isValidChild(childName: string, parentName: string): boolean {\n const parent = getComponent(parentName)\n if (!parent || !parent.hasChildren) return false\n\n if (parent.validChildren === undefined) return true\n return parent.validChildren.includes(childName.toLowerCase())\n}\n\n/**\n * Get attribute definitions for a specific component\n */\nexport function getComponentAttributes(componentName: string): AttributeDef[] {\n const component = getComponent(componentName)\n if (!component) return ATTRIBUTES\n\n return ATTRIBUTES.filter((attr) => component.attributes.includes(attr.name))\n}\n\n/**\n * Get all components in a category\n */\nexport function getComponentsByCategory(category: string): ComponentDef[] {\n return ALL_COMPONENTS.filter((c) => c.category === category)\n}\n\n/**\n * Get attribute type label for display\n */\nexport function getAttributeTypeLabel(attr: AttributeDef): string {\n if (attr.type === 'boolean') return 'boolean'\n if (attr.type === 'number') return 'number'\n if (attr.type === 'string' || attr.type === 'string[]') return 'string'\n if (attr.type === 'enum' && attr.values) {\n const preview = attr.values.slice(0, 3).join(' | ')\n return attr.values.length > 3 ? `${preview}...` : preview\n }\n if (attr.type === 'function') return `function (${attr.example})`\n return attr.type\n}\n\n/**\n * Format attribute values for display\n */\nexport function formatAttributeValues(attr: AttributeDef): string {\n if (attr.type === 'number') return 'Type: number'\n if (attr.type === 'string') return 'Type: string'\n if (attr.type === 'boolean') return 'Type: boolean (can be omitted)'\n if (attr.type === 'enum' && attr.values) {\n return `Values: ${attr.values.join(' | ')}`\n }\n if (attr.type === 'function') return `Functional shorthand. Example: ${attr.example}`\n return `Type: ${attr.type}`\n}\n\n/**\n * Check if a word is a known component\n */\nexport function isComponent(word: string): boolean {\n return COMPONENT_MAP.has(word.toLowerCase())\n}\n\n/**\n * Check if a word is a known attribute\n */\nexport function isAttribute(word: string): boolean {\n return ATTRIBUTE_MAP.has(word)\n}\n\n/**\n * Get all component names\n */\nexport function getComponentNames(): string[] {\n return ALL_COMPONENTS.map((c) => c.name)\n}\n\n/**\n * Get all attribute names\n */\nexport function getAttributeNames(): string[] {\n return ATTRIBUTES.map((a) => a.name)\n}\n\n/**\n * Get all unique categories\n */\nexport function getCategories(): string[] {\n return [...new Set(ALL_COMPONENTS.map((c) => c.category))]\n}\n","/**\n * CodeMirror Language Definition for Wireframe DSL\n *\n * Provides syntax highlighting using StreamLanguage\n */\n\nimport type { StringStream } from '@codemirror/language'\nimport { ALL_COMPONENTS, ATTRIBUTES, VALUE_KEYWORDS } from '../index.js'\n\n// Component names for highlighting\nconst COMPONENT_NAMES = ALL_COMPONENTS.map((c) => c.name)\n\n// Attribute names for highlighting\nconst ATTRIBUTE_NAMES = ATTRIBUTES.map((a) => a.name)\n\n/**\n * StreamLanguage token function for CodeMirror\n * Use with StreamLanguage.define()\n */\nexport function createTokenizer() {\n return {\n token(stream: StringStream): string | null {\n // Skip whitespace\n if (stream.eatSpace()) return null\n\n // Comments\n if (stream.match('//')) {\n stream.skipToEnd()\n return 'comment'\n }\n\n // Strings\n if (stream.match(/\"[^\"]*\"/)) {\n return 'string'\n }\n\n // Numbers\n if (stream.match(/\\d+/)) {\n return 'number'\n }\n\n // Check for component keywords\n for (const kw of COMPONENT_NAMES) {\n if (stream.match(new RegExp(`^${kw}\\\\b`))) {\n return 'keyword'\n }\n }\n\n // Check for attribute names\n for (const attr of ATTRIBUTE_NAMES) {\n if (stream.match(new RegExp(`^${attr}\\\\b`))) {\n return 'propertyName'\n }\n }\n\n // Check for value keywords\n for (const val of VALUE_KEYWORDS) {\n if (stream.match(new RegExp(`^${val}\\\\b`))) {\n return 'atom'\n }\n }\n\n // Operators\n if (stream.match(/[=]/)) {\n return 'operator'\n }\n\n // Braces\n if (stream.match(/[{}[\\]()]/)) {\n return 'bracket'\n }\n\n // Skip other characters\n stream.next()\n return null\n },\n }\n}\n\n/**\n * Get language configuration for CodeMirror\n * Returns configuration for auto-closing brackets, comments, etc.\n */\nexport function getLanguageConfig() {\n return {\n commentTokens: { line: '//' },\n closeBrackets: { brackets: ['(', '[', '{', '\"'] },\n indentOnInput: /^\\s*\\}$/,\n }\n}\n","/**\n * CodeMirror Completion Provider for Wireframe DSL\n *\n * Provides auto-completion for components, attributes, and values\n */\n\nimport type { CompletionContext, CompletionResult } from '@codemirror/autocomplete'\nimport {\n ALL_COMPONENTS,\n ATTRIBUTES,\n getComponent,\n getAttribute,\n getComponentAttributes,\n getValidChildren,\n} from '../index.js'\nimport { CATEGORY_LABELS } from '../keywords.js'\n\n/**\n * Get category label for display\n */\nfunction getCategoryLabel(category: string): string {\n return CATEGORY_LABELS[category as keyof typeof CATEGORY_LABELS] || category\n}\n\n/**\n * Find parent component from cursor position\n */\nfunction findParentComponent(text: string, pos: number): string | null {\n let braceCount = 0\n\n for (let i = pos - 1; i >= 0; i--) {\n if (text[i] === '}') braceCount++\n if (text[i] === '{') {\n braceCount--\n if (braceCount < 0) {\n // Find component name before this brace\n const beforeBrace = text.substring(0, i)\n const match = beforeBrace.match(/(\\w+)(?:\\s+\"[^\"]*\")?\\s*$/)\n return match ? match[1] : null\n }\n }\n }\n\n return null\n}\n\n/**\n * Completion option type for CodeMirror\n */\ninterface CompletionOption {\n label: string\n type: string\n detail?: string\n info?: string\n boost?: number\n apply?: string\n}\n\n/**\n * Create completion source for CodeMirror\n *\n * Usage:\n * ```typescript\n * import { autocompletion } from '@codemirror/autocomplete';\n * import { createCompletionSource } from '@wireweave/language-data/codemirror';\n *\n * const extensions = [\n * autocompletion({ override: [createCompletionSource()] })\n * ];\n * ```\n */\nexport function createCompletionSource() {\n return (context: CompletionContext): CompletionResult | null => {\n const { state, pos } = context\n const line = state.doc.lineAt(pos)\n const textBefore = state.doc.sliceString(line.from, pos)\n const fullText = state.doc.toString()\n\n // Get word at cursor\n const wordMatch = textBefore.match(/(\\w*)$/)\n const word = wordMatch ? wordMatch[1] : ''\n const from = pos - word.length\n\n const options: CompletionOption[] = []\n\n // After '=' - suggest values\n const attrMatch = textBefore.match(/(\\w+)\\s*=\\s*$/)\n if (attrMatch) {\n const attrName = attrMatch[1]\n const attr = getAttribute(attrName)\n\n if (attr && attr.type === 'enum' && attr.values) {\n attr.values.forEach((value: string) => {\n options.push({\n label: value,\n type: 'enum',\n detail: `value for ${attrName}`,\n })\n })\n } else if (attr?.type === 'number') {\n ;[1, 2, 3, 4, 5, 6, 8, 10, 12, 16].forEach((n) => {\n options.push({\n label: String(n),\n type: 'constant',\n detail: 'number',\n })\n })\n }\n\n if (options.length > 0) {\n return { from, options }\n }\n }\n\n // At start of line or after { - suggest components\n if (textBefore.match(/^\\s*\\w*$/) || textBefore.match(/\\{\\s*\\w*$/)) {\n const parentComponent = findParentComponent(fullText, pos)\n const validChildren = parentComponent ? getValidChildren(parentComponent) : []\n const validChildNames = new Set(validChildren.map((c) => c.name))\n const isRootLevel = !parentComponent\n\n ALL_COMPONENTS.forEach((comp) => {\n const isValidInContext = isRootLevel\n ? comp.name === 'page'\n : validChildNames.size === 0 || validChildNames.has(comp.name)\n\n options.push({\n label: comp.name,\n type: isValidInContext ? 'class' : 'type',\n detail: isValidInContext\n ? `${getCategoryLabel(comp.category)} (recommended)`\n : getCategoryLabel(comp.category),\n info: comp.description,\n boost: isValidInContext ? 10 : 0,\n apply: comp.hasChildren ? `${comp.name} {\\n\\t\\n}` : comp.name,\n })\n })\n\n return { from, options }\n }\n\n // After component name - suggest attributes\n const componentMatch = textBefore.match(/(\\w+)(?:\\s+\"[^\"]*\")?\\s+(\\w*)$/)\n if (componentMatch) {\n const compName = componentMatch[1]\n const component = getComponent(compName)\n\n if (component) {\n const attrs = getComponentAttributes(compName)\n attrs.forEach((attr) => {\n let apply = attr.name\n if (attr.type === 'string') {\n apply = `${attr.name}=\"\"`\n } else if (attr.type === 'number' || attr.type === 'enum') {\n apply = `${attr.name}=`\n } else if (attr.type === 'function') {\n apply = `${attr.name}(`\n }\n\n options.push({\n label: attr.name,\n type: 'property',\n detail: attr.type,\n info: attr.description,\n apply,\n })\n })\n } else {\n // Unknown component, suggest all attributes\n ATTRIBUTES.forEach((attr) => {\n let apply = attr.name\n if (attr.type === 'string') {\n apply = `${attr.name}=\"\"`\n } else if (attr.type === 'number' || attr.type === 'enum') {\n apply = `${attr.name}=`\n } else if (attr.type === 'function') {\n apply = `${attr.name}(`\n }\n\n options.push({\n label: attr.name,\n type: 'property',\n detail: attr.type,\n info: attr.description,\n apply,\n })\n })\n }\n\n return { from, options }\n }\n\n // Default: suggest components\n ALL_COMPONENTS.forEach((comp) => {\n options.push({\n label: comp.name,\n type: 'class',\n detail: getCategoryLabel(comp.category),\n info: comp.description,\n apply: comp.hasChildren ? `${comp.name} {\\n\\t\\n}` : comp.name,\n })\n })\n\n return { from, options }\n }\n}\n","/**\n * CodeMirror Hover Provider for Wireframe DSL\n *\n * Provides hover tooltips for components, attributes, and values\n */\n\nimport type { EditorView } from '@codemirror/view'\nimport { ATTRIBUTES, getComponent, getAttribute, VALUE_KEYWORDS } from '../index.js'\nimport { CATEGORY_LABELS } from '../keywords.js'\n\n/**\n * Get category label for display\n */\nfunction getCategoryLabel(category: string): string {\n return CATEGORY_LABELS[category as keyof typeof CATEGORY_LABELS] || category\n}\n\n/**\n * Get word at position in text\n */\nfunction getWordAt(text: string, pos: number): { word: string; from: number; to: number } | null {\n // Find word boundaries\n let from = pos\n let to = pos\n\n while (from > 0 && /\\w/.test(text[from - 1])) from--\n while (to < text.length && /\\w/.test(text[to])) to++\n\n if (from === to) return null\n\n return {\n word: text.slice(from, to),\n from,\n to,\n }\n}\n\n/**\n * Create hover tooltip extension for CodeMirror\n *\n * Usage:\n * ```typescript\n * import { hoverTooltip } from '@codemirror/view';\n * import { createHoverTooltipSource } from '@wireweave/language-data/codemirror';\n *\n * const extensions = [\n * hoverTooltip(createHoverTooltipSource())\n * ];\n * ```\n */\nexport function createHoverTooltipSource() {\n return (view: EditorView, pos: number, _side: -1 | 1) => {\n const { state } = view\n const text = state.doc.toString()\n const wordInfo = getWordAt(text, pos)\n\n if (!wordInfo) return null\n\n const { word, from, to } = wordInfo\n\n // Check if it's a component\n const component = getComponent(word)\n if (component) {\n return {\n pos: from,\n end: to,\n above: true,\n create() {\n const dom = document.createElement('div')\n dom.className = 'cm-tooltip-hover'\n dom.innerHTML = `\n <div style=\"padding: 8px 12px; max-width: 400px;\">\n <div style=\"font-weight: bold; margin-bottom: 4px;\">\n ${component.name}\n <span style=\"opacity: 0.7; font-weight: normal; font-size: 0.9em;\">\n (${getCategoryLabel(component.category)})\n </span>\n </div>\n <div style=\"margin-bottom: 8px; opacity: 0.9;\">${component.description}</div>\n ${component.example ? `<code style=\"display: block; padding: 8px; background: rgba(0,0,0,0.1); border-radius: 4px; font-size: 0.85em; white-space: pre;\">${component.example}</code>` : ''}\n <div style=\"margin-top: 8px; font-size: 0.85em; opacity: 0.7;\">\n Attributes: ${component.attributes.join(', ')}\n </div>\n </div>\n `\n return { dom }\n },\n }\n }\n\n // Check if it's an attribute\n const attribute = getAttribute(word)\n if (attribute) {\n let valueInfo = ''\n if (attribute.type === 'number') {\n valueInfo = 'Type: number'\n } else if (attribute.type === 'string') {\n valueInfo = 'Type: string'\n } else if (attribute.type === 'boolean') {\n valueInfo = 'Type: boolean'\n } else if (attribute.type === 'enum' && attribute.values) {\n valueInfo = `Values: ${attribute.values.join(' | ')}`\n } else if (attribute.type === 'function') {\n valueInfo = `Functional shorthand. Example: ${attribute.example}`\n }\n\n return {\n pos: from,\n end: to,\n above: true,\n create() {\n const dom = document.createElement('div')\n dom.className = 'cm-tooltip-hover'\n dom.innerHTML = `\n <div style=\"padding: 8px 12px; max-width: 400px;\">\n <div style=\"font-weight: bold; margin-bottom: 4px;\">\n ${attribute.name}\n <span style=\"opacity: 0.7; font-weight: normal; font-size: 0.9em;\">(attribute)</span>\n </div>\n <div style=\"margin-bottom: 4px; opacity: 0.9;\">${attribute.description}</div>\n ${valueInfo ? `<div style=\"font-size: 0.85em; opacity: 0.8; font-family: monospace;\">${valueInfo}</div>` : ''}\n ${attribute.example ? `<div style=\"margin-top: 4px; font-size: 0.85em; opacity: 0.7;\">Example: <code>${attribute.example}</code></div>` : ''}\n </div>\n `\n return { dom }\n },\n }\n }\n\n // Check if it's a value keyword\n if (VALUE_KEYWORDS.includes(word)) {\n const relatedAttrs = ATTRIBUTES.filter((a) => a.type === 'enum' && a.values?.includes(word))\n\n if (relatedAttrs.length > 0) {\n return {\n pos: from,\n end: to,\n above: true,\n create() {\n const dom = document.createElement('div')\n dom.className = 'cm-tooltip-hover'\n dom.innerHTML = `\n <div style=\"padding: 8px 12px; max-width: 300px;\">\n <div style=\"font-weight: bold; margin-bottom: 4px;\">\n ${word}\n <span style=\"opacity: 0.7; font-weight: normal; font-size: 0.9em;\">(value)</span>\n </div>\n <div style=\"font-size: 0.9em; opacity: 0.8;\">\n Used in: ${relatedAttrs.map((a) => a.name).join(', ')}\n </div>\n </div>\n `\n return { dom }\n },\n }\n }\n }\n\n return null\n }\n}\n","/**\n * CodeMirror Linting Provider for Wireframe DSL\n *\n * Provides diagnostics for syntax errors, unknown components, etc.\n */\n\nimport type { Diagnostic as CMDiagnostic } from '@codemirror/lint'\nimport type { EditorView } from '@codemirror/view'\nimport { getComponent, getAttribute } from '../index.js'\n\n/**\n * Diagnostic severity levels\n */\nexport type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint'\n\n/**\n * Diagnostic interface\n */\nexport interface Diagnostic {\n from: number\n to: number\n severity: DiagnosticSeverity\n message: string\n}\n\n/**\n * Validate wireframe code and return diagnostics\n */\nexport function validateCode(text: string): Diagnostic[] {\n const diagnostics: Diagnostic[] = []\n const lines = text.split('\\n')\n\n const braceStack: { line: number; col: number; pos: number; component?: string }[] = []\n let hasPage = false\n let currentPos = 0\n\n for (let lineNum = 0; lineNum < lines.length; lineNum++) {\n const line = lines[lineNum]\n const lineStart = currentPos\n\n // Skip comments\n if (line.trim().startsWith('//')) {\n currentPos += line.length + 1\n continue\n }\n\n // Check for page component\n const pageMatch = line.match(/^\\s*page\\b/)\n if (pageMatch) {\n if (hasPage) {\n const matchStart = lineStart + line.indexOf('page')\n diagnostics.push({\n from: matchStart,\n to: matchStart + 4,\n severity: 'error',\n message: 'Only one page component is allowed.',\n })\n }\n hasPage = true\n }\n\n // Check for unknown components (at start of line, not after =)\n const componentMatch = line.match(/^\\s*(\\w+)(?:\\s|{|\")/)\n if (componentMatch) {\n const compName = componentMatch[1]\n if (!getComponent(compName) && !['true', 'false'].includes(compName)) {\n // Make sure it's not a value after =\n const beforeMatch = line.substring(0, componentMatch.index)\n if (!beforeMatch.match(/=\\s*$/)) {\n const matchStart = lineStart + (componentMatch.index || 0)\n diagnostics.push({\n from: matchStart,\n to: matchStart + compName.length,\n severity: 'warning',\n message: `Unknown component: \"${compName}\"`,\n })\n }\n }\n }\n\n // Check for unknown attributes\n const attrRegex = /\\b(\\w+)\\s*=/g\n let attrMatch\n while ((attrMatch = attrRegex.exec(line)) !== null) {\n const attrName = attrMatch[1]\n if (!getAttribute(attrName) && !getComponent(attrName)) {\n const matchStart = lineStart + attrMatch.index\n diagnostics.push({\n from: matchStart,\n to: matchStart + attrName.length,\n severity: 'warning',\n message: `Unknown attribute: \"${attrName}\"`,\n })\n }\n }\n\n // Track braces for matching\n for (let col = 0; col < line.length; col++) {\n if (line[col] === '{') {\n const beforeBrace = line.substring(0, col)\n const compMatch = beforeBrace.match(/(\\w+)(?:\\s+\"[^\"]*\")?\\s*$/)\n braceStack.push({\n line: lineNum,\n col,\n pos: lineStart + col,\n component: compMatch ? compMatch[1] : undefined,\n })\n } else if (line[col] === '}') {\n if (braceStack.length === 0) {\n diagnostics.push({\n from: lineStart + col,\n to: lineStart + col + 1,\n severity: 'error',\n message: 'Unmatched closing brace',\n })\n } else {\n braceStack.pop()\n }\n }\n }\n\n // Check for unclosed strings\n const quotes = line.match(/\"/g)\n if (quotes && quotes.length % 2 !== 0) {\n diagnostics.push({\n from: lineStart,\n to: lineStart + line.length,\n severity: 'error',\n message: 'Unclosed string',\n })\n }\n\n currentPos += line.length + 1\n }\n\n // Check for unclosed braces\n for (const brace of braceStack) {\n diagnostics.push({\n from: brace.pos,\n to: brace.pos + 1,\n severity: 'error',\n message: `Unclosed brace${brace.component ? ` (${brace.component})` : ''}`,\n })\n }\n\n // Info if no page component\n if (!hasPage && text.trim()) {\n diagnostics.push({\n from: 0,\n to: 0,\n severity: 'info',\n message: 'Consider starting with a page component.',\n })\n }\n\n return diagnostics\n}\n\n/**\n * Create linter extension for CodeMirror\n *\n * Usage:\n * ```typescript\n * import { linter } from '@codemirror/lint';\n * import { createLinter } from '@wireweave/language-data/codemirror';\n *\n * const extensions = [\n * linter(createLinter())\n * ];\n * ```\n */\nexport function createLinter() {\n return (view: EditorView): CMDiagnostic[] => {\n const text = view.state.doc.toString()\n const diagnostics = validateCode(text)\n\n return diagnostics.map((d) => ({\n from: d.from,\n to: d.to,\n severity: d.severity,\n message: d.message,\n }))\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACaA,kBAIO;AAmBP,IAAM,kBAA6E;AAAA;AAAA,EAEjF,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,eAAe,CAAC,UAAU,QAAQ,UAAU,WAAW,WAAW,OAAO,OAAO,OAAO,MAAM;AAAA,IAC7F,cAAc,CAAC;AAAA,IACf,iBAAiB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AC1E,CAAC;AAAA,EACH;AAGA,MAAI,CAAC,WAAW,KAAK,KAAK,GAAG;AAC3B,gBAAY,KAAK;AAAA,MACf,MAAM;AAAA,MACN,IAAI;AAAA,MACJ,UAAU;AAAA,MACV,SAAS;AAAA,IACX,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAeO,SAAS,eAAe;AAC7B,SAAO,CAAC,SAAqC;AAC3C,UAAM,OAAO,KAAK,MAAM,IAAI,SAAS;AACrC,UAAM,cAAc,aAAa,IAAI;AAErC,WAAO,YAAY,IAAI,CAAC,OAAO;AAAA,MAC7B,MAAM,EAAE;AAAA,MACR,IAAI,EAAE;AAAA,MACN,UAAU,EAAE;AAAA,MACZ,SAAS,EAAE;AAAA,IACb,EAAE;AAAA,EACJ;AACF;","names":["import_spec","import_spec","import_spec","COMPONENT_NAMES","getCategoryLabel"]}
|
package/dist/codemirror/index.js
CHANGED
|
@@ -32,6 +32,11 @@ var EDITOR_METADATA = {
|
|
|
32
32
|
use: {
|
|
33
33
|
example: 'use userbadge(name="Ada") { ... }'
|
|
34
34
|
},
|
|
35
|
+
repeat: {
|
|
36
|
+
// No `validParents`: `repeat` is a fold, so it belongs wherever its body
|
|
37
|
+
// would have been written out by hand — which is anywhere children go.
|
|
38
|
+
example: "row gap=4 { repeat 6 { use skeletonCard() } }"
|
|
39
|
+
},
|
|
35
40
|
// Grid
|
|
36
41
|
row: { example: "row flex gap=4 justify=between { ... }" },
|
|
37
42
|
col: { example: "col span=6 md=4 { ... }" },
|
|
@@ -271,6 +276,8 @@ var ATTRIBUTE_EXAMPLES = {
|
|
|
271
276
|
device: 'device="iphone14"',
|
|
272
277
|
// Reuse
|
|
273
278
|
uses: 'uses="app-shell"',
|
|
279
|
+
variants: "variants=[loading, empty, ready]",
|
|
280
|
+
when: "when=[loading, empty]",
|
|
274
281
|
// Interaction
|
|
275
282
|
navigate: 'navigate="Dashboard"',
|
|
276
283
|
opens: 'opens="settings-modal"',
|