@almadar/extensions 1.0.15 → 2.0.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/LICENSE +21 -72
- package/README.md +25 -0
- package/package.json +7 -5
- package/dist/index.d.ts +0 -213
package/LICENSE
CHANGED
|
@@ -1,72 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
23
|
-
available distribution of a specific version of the Licensed Work under this
|
|
24
|
-
License, whichever comes first, the Licensor hereby grants you rights under
|
|
25
|
-
the terms of the Change License, and the rights granted in the paragraph
|
|
26
|
-
above terminate.
|
|
27
|
-
|
|
28
|
-
If your use of the Licensed Work does not comply with the requirements
|
|
29
|
-
currently in effect as described in this License, you must purchase a
|
|
30
|
-
commercial license from the Licensor, its affiliated entities, or authorized
|
|
31
|
-
resellers, or you must refrain from using the Licensed Work.
|
|
32
|
-
|
|
33
|
-
All copies of the original and modified Licensed Work, and derivative works
|
|
34
|
-
of the Licensed Work, are subject to this License. This License applies
|
|
35
|
-
separately for each version of the Licensed Work and the Change Date may vary
|
|
36
|
-
for each version of the Licensed Work released by Licensor.
|
|
37
|
-
|
|
38
|
-
You must conspicuously display this License on each original or modified copy
|
|
39
|
-
of the Licensed Work. If you receive the Licensed Work in original or
|
|
40
|
-
modified form from a third party, the terms and conditions set forth in this
|
|
41
|
-
License apply to your use of that work.
|
|
42
|
-
|
|
43
|
-
Any use of the Licensed Work in violation of this License will automatically
|
|
44
|
-
terminate your rights under this License for the current and all other
|
|
45
|
-
versions of the Licensed Work.
|
|
46
|
-
|
|
47
|
-
This License does not grant you any right in any trademark or logo of
|
|
48
|
-
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
49
|
-
Licensor as expressly required by this License).
|
|
50
|
-
|
|
51
|
-
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
52
|
-
AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
53
|
-
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
54
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
55
|
-
TITLE.
|
|
56
|
-
|
|
57
|
-
---
|
|
58
|
-
|
|
59
|
-
License text copyright (c) 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
60
|
-
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
61
|
-
|
|
62
|
-
ADDITIONAL TERMS:
|
|
63
|
-
|
|
64
|
-
Documentation (builder/packages/website/docs/) is licensed under CC BY 4.0.
|
|
65
|
-
|
|
66
|
-
TRADEMARKS:
|
|
67
|
-
|
|
68
|
-
"Orbital", "KFlow", "Almadar", and the Almadar logo are trademarks of
|
|
69
|
-
Almadar FZE. You may not use these trademarks without prior written
|
|
70
|
-
permission from Almadar FZE.
|
|
71
|
-
|
|
72
|
-
For licensing inquiries: licensing@almadar.io
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Almadar Team
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @almadar/extensions
|
|
2
|
+
|
|
3
|
+
> Editor extension utilities for .orb files — virtual document wrapper and S-expression grammar generator
|
|
4
|
+
|
|
5
|
+
Part of the [Almadar](https://github.com/almadar-io/almadar) platform.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @almadar/extensions
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { /* ... */ } from '@almadar/extensions';
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## API
|
|
20
|
+
|
|
21
|
+
<!-- Document public exports here -->
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almadar/extensions",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Editor extension utilities for .orb files — virtual document wrapper and S-expression grammar generator",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -19,17 +19,18 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@almadar/core": "
|
|
23
|
-
"@almadar/operators": "
|
|
22
|
+
"@almadar/core": ">=2.0.0",
|
|
23
|
+
"@almadar/operators": ">=2.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"tsup": "^8.0.0",
|
|
27
|
-
"typescript": "^5.4.0"
|
|
27
|
+
"typescript": "^5.4.0",
|
|
28
|
+
"tsx": "^4.0.0"
|
|
28
29
|
},
|
|
29
30
|
"repository": {
|
|
30
31
|
"type": "git",
|
|
31
32
|
"url": "https://github.com/almadar-io/almadar.git",
|
|
32
|
-
"directory": "packages/
|
|
33
|
+
"directory": "docs/packages/extensions"
|
|
33
34
|
},
|
|
34
35
|
"license": "MIT",
|
|
35
36
|
"keywords": [
|
|
@@ -40,6 +41,7 @@
|
|
|
40
41
|
"vscode",
|
|
41
42
|
"zed"
|
|
42
43
|
],
|
|
44
|
+
"homepage": "https://github.com/almadar-io/almadar#readme",
|
|
43
45
|
"scripts": {
|
|
44
46
|
"build": "tsup && pnpm run generate-grammar && pnpm run build:editors",
|
|
45
47
|
"build:core": "tsup && pnpm run generate-grammar",
|
package/dist/index.d.ts
DELETED
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Virtual Document — The TypeScript Wrapper Trick
|
|
3
|
-
*
|
|
4
|
-
* Wraps .orb JSON content inside a TypeScript file that imports
|
|
5
|
-
* OrbitalSchema from @almadar/core. This lets the TypeScript
|
|
6
|
-
* language server validate the entire .orb structure for free.
|
|
7
|
-
*
|
|
8
|
-
* @packageDocumentation
|
|
9
|
-
*/
|
|
10
|
-
/**
|
|
11
|
-
* Number of lines the prefix adds before .orb content begins.
|
|
12
|
-
* Used to offset diagnostics back to original .orb line numbers.
|
|
13
|
-
*
|
|
14
|
-
* The prefix is exactly 2 lines:
|
|
15
|
-
* Line 1: import type { OrbitalSchema } from '@almadar/core';
|
|
16
|
-
* Line 2: const _orbital = ... (the .orb content starts on THIS line)
|
|
17
|
-
*
|
|
18
|
-
* So .orb line 1 corresponds to virtual .ts line 2.
|
|
19
|
-
*/
|
|
20
|
-
declare const WRAPPER_LINE_OFFSET = 1;
|
|
21
|
-
/**
|
|
22
|
-
* Number of characters on the prefix line before .orb content begins.
|
|
23
|
-
* `const _orbital = ` is 18 characters.
|
|
24
|
-
*/
|
|
25
|
-
declare const WRAPPER_COL_OFFSET = 18;
|
|
26
|
-
/**
|
|
27
|
-
* Wrap raw .orb JSON content into a virtual TypeScript file.
|
|
28
|
-
*
|
|
29
|
-
* @param orbContent - The raw JSON string from the .orb file
|
|
30
|
-
* @returns The complete TypeScript source that tsserver can validate
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```ts
|
|
34
|
-
* const orbJson = fs.readFileSync('app.orb', 'utf-8');
|
|
35
|
-
* const tsContent = wrapOrbContent(orbJson);
|
|
36
|
-
* // tsContent is now a valid .ts file that TypeScript can check
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function wrapOrbContent(orbContent: string): string;
|
|
40
|
-
/**
|
|
41
|
-
* Extract the original .orb content from a wrapped virtual TypeScript file.
|
|
42
|
-
*
|
|
43
|
-
* @param virtualContent - The virtual .ts file content
|
|
44
|
-
* @returns The original .orb JSON string, or null if not a valid wrapper
|
|
45
|
-
*/
|
|
46
|
-
declare function unwrapOrbContent(virtualContent: string): string | null;
|
|
47
|
-
/**
|
|
48
|
-
* Generate the virtual .ts filename for a given .orb file path.
|
|
49
|
-
*
|
|
50
|
-
* @param orbFilePath - Absolute path to the .orb file
|
|
51
|
-
* @returns The virtual .ts file path (same directory, `.orb.ts` extension)
|
|
52
|
-
*
|
|
53
|
-
* @example
|
|
54
|
-
* ```ts
|
|
55
|
-
* getVirtualPath('/projects/app.orb')
|
|
56
|
-
* // → '/projects/app.orb.ts'
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare function getVirtualPath(orbFilePath: string): string;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Diagnostic Mapper
|
|
63
|
-
*
|
|
64
|
-
* Maps TypeScript diagnostics from the virtual .ts file back to
|
|
65
|
-
* the original .orb file positions, adjusting for the wrapper prefix.
|
|
66
|
-
*
|
|
67
|
-
* @packageDocumentation
|
|
68
|
-
*/
|
|
69
|
-
/**
|
|
70
|
-
* A position in a text document (0-indexed line and character).
|
|
71
|
-
*/
|
|
72
|
-
interface Position {
|
|
73
|
-
/** 0-indexed line number */
|
|
74
|
-
line: number;
|
|
75
|
-
/** 0-indexed character offset within the line */
|
|
76
|
-
character: number;
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* A range in a text document.
|
|
80
|
-
*/
|
|
81
|
-
interface Range {
|
|
82
|
-
start: Position;
|
|
83
|
-
end: Position;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Severity levels matching both VSCode and Zed conventions.
|
|
87
|
-
*/
|
|
88
|
-
type DiagnosticSeverity = 'error' | 'warning' | 'info' | 'hint';
|
|
89
|
-
/**
|
|
90
|
-
* An editor-agnostic diagnostic — the universal unit that
|
|
91
|
-
* VSCode and Zed extensions translate into their native format.
|
|
92
|
-
*/
|
|
93
|
-
interface OrbDiagnostic {
|
|
94
|
-
/** Human-readable error message */
|
|
95
|
-
message: string;
|
|
96
|
-
/** Location in the .orb file (already adjusted from virtual .ts) */
|
|
97
|
-
range: Range;
|
|
98
|
-
/** Severity level */
|
|
99
|
-
severity: DiagnosticSeverity;
|
|
100
|
-
/** TypeScript error code (e.g. 2322, 2353) for filtering */
|
|
101
|
-
code?: number;
|
|
102
|
-
/** Source identifier */
|
|
103
|
-
source: 'almadar-ts';
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Raw TypeScript diagnostic (minimal shape matching ts.Diagnostic).
|
|
107
|
-
* Extensions should map their TS server output to this shape.
|
|
108
|
-
*/
|
|
109
|
-
interface TsDiagnostic {
|
|
110
|
-
/** 0-indexed line in the virtual .ts file */
|
|
111
|
-
line: number;
|
|
112
|
-
/** 0-indexed character in the virtual .ts file */
|
|
113
|
-
character: number;
|
|
114
|
-
/** End line (optional, defaults to same as line) */
|
|
115
|
-
endLine?: number;
|
|
116
|
-
/** End character (optional) */
|
|
117
|
-
endCharacter?: number;
|
|
118
|
-
/** Error message text */
|
|
119
|
-
messageText: string;
|
|
120
|
-
/** TS error code */
|
|
121
|
-
code?: number;
|
|
122
|
-
/** 1 = error, 2 = warning, 3 = info, 4 = hint */
|
|
123
|
-
category?: number;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Map a virtual .ts file position back to the original .orb position.
|
|
127
|
-
*
|
|
128
|
-
* @param virtualLine - 0-indexed line in the virtual .ts file
|
|
129
|
-
* @param virtualChar - 0-indexed character in the virtual .ts file
|
|
130
|
-
* @returns Adjusted position in the .orb file
|
|
131
|
-
*/
|
|
132
|
-
declare function mapPositionToOrb(virtualLine: number, virtualChar: number): Position;
|
|
133
|
-
/**
|
|
134
|
-
* Map a single TypeScript diagnostic to an OrbDiagnostic.
|
|
135
|
-
*
|
|
136
|
-
* @param tsDiag - The raw TypeScript diagnostic
|
|
137
|
-
* @returns An editor-agnostic diagnostic with adjusted positions
|
|
138
|
-
*/
|
|
139
|
-
declare function mapDiagnostic(tsDiag: TsDiagnostic): OrbDiagnostic;
|
|
140
|
-
/**
|
|
141
|
-
* Map an array of TypeScript diagnostics to OrbDiagnostics.
|
|
142
|
-
* Filters out diagnostics that fall within the wrapper prefix.
|
|
143
|
-
*
|
|
144
|
-
* @param diagnostics - Array of raw TypeScript diagnostics
|
|
145
|
-
* @returns Array of editor-agnostic diagnostics
|
|
146
|
-
*/
|
|
147
|
-
declare function mapDiagnostics(diagnostics: TsDiagnostic[]): OrbDiagnostic[];
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* S-Expression Grammar Generator
|
|
151
|
-
*
|
|
152
|
-
* Generates a TextMate injection grammar for S-expression syntax
|
|
153
|
-
* highlighting inside .orb files. The grammar is derived from
|
|
154
|
-
* @almadar/operators — the single source of truth for all operator names.
|
|
155
|
-
*
|
|
156
|
-
* This means new operators automatically get highlighting when
|
|
157
|
-
* the package is rebuilt. No manual grammar maintenance.
|
|
158
|
-
*
|
|
159
|
-
* @packageDocumentation
|
|
160
|
-
*/
|
|
161
|
-
/**
|
|
162
|
-
* TextMate grammar rule
|
|
163
|
-
*/
|
|
164
|
-
interface TmRule {
|
|
165
|
-
name: string;
|
|
166
|
-
match: string;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* TextMate injection grammar structure
|
|
170
|
-
*/
|
|
171
|
-
interface TmInjectionGrammar {
|
|
172
|
-
scopeName: string;
|
|
173
|
-
injectionSelector: string;
|
|
174
|
-
patterns: TmRule[];
|
|
175
|
-
}
|
|
176
|
-
/**
|
|
177
|
-
* Generate a TextMate injection grammar for S-expression highlighting.
|
|
178
|
-
*
|
|
179
|
-
* The grammar injects into `.orb` files (JSON scope) and highlights:
|
|
180
|
-
* - **Operators** by category (arithmetic, effect, control, etc.)
|
|
181
|
-
* - **Bindings** (`@entity.field`, `@payload.value`)
|
|
182
|
-
* - **Events** (UPPER_CASE_NAMES)
|
|
183
|
-
*
|
|
184
|
-
* @returns A complete TextMate injection grammar object
|
|
185
|
-
*
|
|
186
|
-
* @example
|
|
187
|
-
* ```ts
|
|
188
|
-
* import { generateSExprGrammar } from '@almadar/extensions';
|
|
189
|
-
* import { writeFileSync } from 'fs';
|
|
190
|
-
*
|
|
191
|
-
* const grammar = generateSExprGrammar();
|
|
192
|
-
* writeFileSync('sexpr.injection.json', JSON.stringify(grammar, null, 2));
|
|
193
|
-
* ```
|
|
194
|
-
*/
|
|
195
|
-
declare function generateSExprGrammar(): TmInjectionGrammar;
|
|
196
|
-
/**
|
|
197
|
-
* Serialize the grammar to a formatted JSON string.
|
|
198
|
-
* Ready to be written to `sexpr.injection.json`.
|
|
199
|
-
*/
|
|
200
|
-
declare function generateSExprGrammarJson(): string;
|
|
201
|
-
/**
|
|
202
|
-
* Get a flat list of all operator names from the registry.
|
|
203
|
-
* Useful for editor extensions that need the operator list without
|
|
204
|
-
* importing @almadar/operators directly.
|
|
205
|
-
*/
|
|
206
|
-
declare function getOperatorNames(): string[];
|
|
207
|
-
/**
|
|
208
|
-
* Get operators grouped by category.
|
|
209
|
-
* Useful for autocomplete that groups suggestions by category.
|
|
210
|
-
*/
|
|
211
|
-
declare function getOperatorsByCategory(): Record<string, string[]>;
|
|
212
|
-
|
|
213
|
-
export { type DiagnosticSeverity, type OrbDiagnostic, type Position, type Range, type TmInjectionGrammar, type TsDiagnostic, WRAPPER_COL_OFFSET, WRAPPER_LINE_OFFSET, generateSExprGrammar, generateSExprGrammarJson, getOperatorNames, getOperatorsByCategory, getVirtualPath, mapDiagnostic, mapDiagnostics, mapPositionToOrb, unwrapOrbContent, wrapOrbContent };
|