@zenithbuild/language 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/extension.ts DELETED
@@ -1,147 +0,0 @@
1
- import * as path from 'path';
2
- import * as vscode from 'vscode';
3
- import {
4
- LanguageClient,
5
- LanguageClientOptions,
6
- ServerOptions,
7
- TransportKind
8
- } from 'vscode-languageclient/node';
9
-
10
- let client: LanguageClient | undefined;
11
-
12
- function getConfiguredServerPath(context: vscode.ExtensionContext): string {
13
- const configured = vscode.workspace.getConfiguration('zenith').get<string>('languageServer.path', '').trim();
14
- if (!configured) {
15
- return context.asAbsolutePath(path.join('out', 'server.js'));
16
- }
17
-
18
- if (path.isAbsolute(configured)) {
19
- return configured;
20
- }
21
-
22
- const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
23
- if (workspaceFolder) {
24
- return path.resolve(workspaceFolder.uri.fsPath, configured);
25
- }
26
-
27
- return context.asAbsolutePath(configured);
28
- }
29
-
30
- async function startLanguageClient(context: vscode.ExtensionContext): Promise<void> {
31
- const serverModule = getConfiguredServerPath(context);
32
- console.log('Zenith: Starting language server from:', serverModule);
33
-
34
- const serverOptions: ServerOptions = {
35
- run: { module: serverModule, transport: TransportKind.ipc },
36
- debug: { module: serverModule, transport: TransportKind.ipc }
37
- };
38
-
39
- const clientOptions: LanguageClientOptions = {
40
- documentSelector: [{ scheme: 'file', language: 'zenith' }],
41
- synchronize: {
42
- configurationSection: 'zenith',
43
- fileEvents: vscode.workspace.createFileSystemWatcher('**/*.{zen,zen.html,zenx}')
44
- },
45
- // Disable pull diagnostics - server uses push diagnostics only
46
- middleware: {
47
- provideDiagnostics: () => undefined
48
- }
49
- };
50
-
51
- client = new LanguageClient(
52
- 'zenithLanguageServer',
53
- 'Zenith Language Server',
54
- serverOptions,
55
- clientOptions
56
- );
57
-
58
- context.subscriptions.push(client.start());
59
- }
60
-
61
- async function restartLanguageClient(context: vscode.ExtensionContext): Promise<void> {
62
- if (client) {
63
- await client.stop();
64
- client = undefined;
65
- }
66
- await startLanguageClient(context);
67
- }
68
-
69
- async function selectWorkspaceFolder(): Promise<vscode.WorkspaceFolder | undefined> {
70
- const folders = vscode.workspace.workspaceFolders || [];
71
- if (folders.length === 0) {
72
- vscode.window.showErrorMessage('Zenith: No workspace folder is open.');
73
- return undefined;
74
- }
75
-
76
- if (folders.length === 1) {
77
- return folders[0];
78
- }
79
-
80
- const pick = await vscode.window.showWorkspaceFolderPick({
81
- placeHolder: 'Select workspace folder for Zenith command'
82
- });
83
- return pick || undefined;
84
- }
85
-
86
- async function runInWorkspaceTerminal(command: string, terminalName: string): Promise<void> {
87
- const folder = await selectWorkspaceFolder();
88
- if (!folder) {
89
- return;
90
- }
91
-
92
- const terminal = vscode.window.createTerminal({
93
- name: terminalName,
94
- cwd: folder.uri.fsPath
95
- });
96
- terminal.show(true);
97
- terminal.sendText(command);
98
- }
99
-
100
- export function activate(context: vscode.ExtensionContext) {
101
- startLanguageClient(context).catch((error) => {
102
- vscode.window.showErrorMessage(`Zenith: Failed to start language server: ${String(error)}`);
103
- });
104
-
105
- context.subscriptions.push(
106
- vscode.commands.registerCommand('zenith.runContractPack', async () => {
107
- await runInWorkspaceTerminal('npm test', 'Zenith Contract Pack');
108
- })
109
- );
110
-
111
- context.subscriptions.push(
112
- vscode.commands.registerCommand('zenith.runLegacyTests', async () => {
113
- await runInWorkspaceTerminal('npm run test:legacy', 'Zenith Legacy Tests');
114
- })
115
- );
116
-
117
- context.subscriptions.push(
118
- vscode.commands.registerCommand('zenith.build', async () => {
119
- await runInWorkspaceTerminal('zenith build', 'Zenith Build');
120
- })
121
- );
122
-
123
- context.subscriptions.push(
124
- vscode.commands.registerCommand('zenith.restartServer', async () => {
125
- await restartLanguageClient(context);
126
- vscode.window.showInformationMessage('Zenith language server restarted.');
127
- })
128
- );
129
-
130
- context.subscriptions.push(
131
- vscode.workspace.onDidChangeConfiguration(async (event) => {
132
- if (!event.affectsConfiguration('zenith.languageServer.path')) {
133
- return;
134
- }
135
- await restartLanguageClient(context);
136
- })
137
- );
138
-
139
- console.log('Zenith Language Support activated');
140
- }
141
-
142
- export function deactivate(): Thenable<void> | undefined {
143
- if (!client) {
144
- return undefined;
145
- }
146
- return client.stop();
147
- }
@@ -1,36 +0,0 @@
1
- <script setup="ts" lang="ts">
2
- state count = 0
3
-
4
- function increment() {
5
- count = count + 1
6
- }
7
-
8
- function decrement() {
9
- count = count - 1
10
- }
11
-
12
- zenOnMount(() => {
13
- console.log('🚀 Zenith app mounted!')
14
- })
15
- </script>
16
-
17
- <div class="card" onClick={() => increment()} disabled>
18
- <h1>Counter: {count}</h1>
19
- <button onClick={() => increment()}>+</button>
20
- <button onClick={() => decrement()}>-</button>
21
- </div>
22
-
23
- <Counter count={count} :data-id="myId" />
24
-
25
- <style scoped>
26
- .card {
27
- padding: 1rem;
28
- border-radius: 8px;
29
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
30
- }
31
-
32
- button {
33
- margin: 0.5rem;
34
- padding: 0.5rem 1rem;
35
- }
36
- </style>
@@ -1,73 +0,0 @@
1
- /**
2
- * Acceptance tests: grammar and snippets contain expected tokens/prefixes.
3
- * No VS Code required. Runs in CI.
4
- */
5
- const test = require('node:test');
6
- const assert = require('node:assert/strict');
7
- const fs = require('node:fs');
8
- const path = require('node:path');
9
-
10
- const ROOT = path.resolve(__dirname, '..');
11
-
12
- const CANONICAL_PRIMITIVES = [
13
- 'state',
14
- 'signal',
15
- 'ref',
16
- 'zenMount',
17
- 'zenWindow',
18
- 'zenDocument',
19
- 'zenOn',
20
- 'zenResize',
21
- 'collectRefs'
22
- ];
23
-
24
- const SNIPPET_PREFIXES = [
25
- 'zenOn',
26
- 'zenResize',
27
- 'zenWindow',
28
- 'zenMount',
29
- 'ref',
30
- 'state',
31
- 'signal',
32
- 'on:click',
33
- 'collectRefs'
34
- ];
35
-
36
- test('grammar includes canonical primitives', () => {
37
- const grammarPath = path.join(ROOT, 'syntaxes', 'zenith.tmLanguage.json');
38
- const grammar = JSON.parse(fs.readFileSync(grammarPath, 'utf8'));
39
-
40
- const repo = grammar.repository || {};
41
- const grammarStr = JSON.stringify(grammar);
42
-
43
- for (const prim of CANONICAL_PRIMITIVES) {
44
- assert.ok(
45
- grammarStr.includes(prim),
46
- `Grammar should include "${prim}"`
47
- );
48
- }
49
-
50
- assert.ok(grammar.scopeName === 'text.html.zenith', 'Scope should be text.html.zenith');
51
- assert.ok(grammar.fileTypes?.includes('zen'), 'File types should include .zen');
52
- });
53
-
54
- test('snippets include expected prefixes', () => {
55
- const snippetsPath = path.join(ROOT, 'snippets', 'zenith.code-snippets');
56
- const snippets = JSON.parse(fs.readFileSync(snippetsPath, 'utf8'));
57
- const snippetStr = JSON.stringify(snippets);
58
-
59
- for (const prefix of SNIPPET_PREFIXES) {
60
- assert.ok(
61
- snippetStr.includes(prefix),
62
- `Snippets should include "${prefix}"`
63
- );
64
- }
65
- });
66
-
67
- test('package.json contributes single grammar for zenith', () => {
68
- const pkg = JSON.parse(fs.readFileSync(path.join(ROOT, 'package.json'), 'utf8'));
69
- const grammars = pkg.contributes?.grammars || [];
70
- const zenithGrammars = grammars.filter((g) => g.language === 'zenith');
71
- assert.equal(zenithGrammars.length, 1, 'Exactly one grammar for zenith');
72
- assert.equal(zenithGrammars[0]?.scopeName, 'text.html.zenith');
73
- });
package/tsconfig.json DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "commonjs",
5
- "lib": [
6
- "ES2020"
7
- ],
8
- "outDir": "./out",
9
- "rootDir": "./src",
10
- "strict": true,
11
- "esModuleInterop": true,
12
- "skipLibCheck": true,
13
- "forceConsistentCasingInFileNames": true,
14
- "declaration": true,
15
- "declarationMap": true,
16
- "sourceMap": true,
17
- "moduleResolution": "node"
18
- },
19
- "include": [
20
- "src/**/*"
21
- ],
22
- "exclude": [
23
- "node_modules",
24
- "out"
25
- ]
26
- }