@altopelago/aeon-highlight 0.0.0-stage → 0.17.0-rc.3
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 -0
- package/README.md +124 -2
- package/dist/aeon-token-highlight.d.mts +8 -0
- package/dist/aeon-token-highlight.d.mts.map +1 -0
- package/dist/aeon-token-highlight.mjs +164 -0
- package/dist/aeon-token-highlight.mjs.map +1 -0
- package/dist/element.d.ts +7 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +124 -0
- package/dist/element.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/presentation-highlight.d.mts +6 -0
- package/dist/presentation-highlight.d.mts.map +1 -0
- package/dist/presentation-highlight.mjs +239 -0
- package/dist/presentation-highlight.mjs.map +1 -0
- package/dist/renderer.d.ts +21 -0
- package/dist/renderer.d.ts.map +1 -0
- package/dist/renderer.js +14 -0
- package/dist/renderer.js.map +1 -0
- package/dist/theme-light.css +55 -0
- package/dist/theme.css +55 -0
- package/dist/themes.d.ts +4 -0
- package/dist/themes.d.ts.map +1 -0
- package/dist/themes.js +4 -0
- package/dist/themes.js.map +1 -0
- package/package.json +65 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 AltoPelago
|
|
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
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @altopelago/aeon-highlight
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Optional lexer-backed AEON rendering for browsers and server-side HTML generation.
|
|
4
|
+
Prepared for the TypeScript 0.17.0 release; publication is on hold.
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
import {highlightAeon} from '@altopelago/aeon-highlight';
|
|
8
|
+
const html = highlightAeon('name\\id\\:string="Hello"');
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The renderer uses `@altopelago/aeon-lexer`, original UTF-16 source spans and escaped
|
|
12
|
+
source text. It preserves text, gaps and malformed input; it has no custom AEON
|
|
13
|
+
scanner. Sources above `MAX_HIGHLIGHT_SOURCE_CODE_UNITS` (1,048,576) render as
|
|
14
|
+
escaped plain text without lexing. This presentation allowance does not change
|
|
15
|
+
compiler/parser limits. This API renders text; it does not validate documents or
|
|
16
|
+
resolve references or identities.
|
|
17
|
+
|
|
18
|
+
`highlightAeon(source, {diagnosticLine, diagnosticColumn})` optionally marks a
|
|
19
|
+
one-based line and UTF-16 column. `highlightJson(source)` is a separate presentation
|
|
20
|
+
helper. Optional &ND decoration is confined to lexer-classified doc comments.
|
|
21
|
+
Both JavaScript entry points can be imported without a DOM. Core/runtime packages do
|
|
22
|
+
not depend on this package.
|
|
23
|
+
|
|
24
|
+
## Optional custom element
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import {defineAeonCodeBlock} from '@altopelago/aeon-highlight/element';
|
|
28
|
+
defineAeonCodeBlock(); // Explicit, idempotent browser registration.
|
|
29
|
+
const block = document.createElement('aeon-code-block');
|
|
30
|
+
block.setAttribute('theme', 'light'); // Omit for dark.
|
|
31
|
+
block.setAttribute('title', 'Example');
|
|
32
|
+
block.code = source; // Exact source, including empty strings and trailing newlines.
|
|
33
|
+
document.body.append(block);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
`code` property overrides the `code` attribute; otherwise source comes from a
|
|
37
|
+
nested `script[type="text/plain"]`, a template's content, or text content. Empty
|
|
38
|
+
attributes are respected. Source is not trimmed. For arbitrary source use the
|
|
39
|
+
property rather than interpolating HTML. Light-DOM edits and edits within the selected template content update the display;
|
|
40
|
+
disconnecting the element disconnects its observer. `show-copy="false"` hides
|
|
41
|
+
the copy button. Register only one implementation per tag; a foreign existing
|
|
42
|
+
definition is rejected rather than assumed to support this API. Copy uses the browser clipboard API following a button click;
|
|
43
|
+
unavailable clipboard access is reported in a live status region.
|
|
44
|
+
|
|
45
|
+
The component is an AEON code block. Site-specific expansion controls, JSON,
|
|
46
|
+
TypeScript, grammar rendering and navigation remain consumer responsibilities.
|
|
47
|
+
|
|
48
|
+
## Themes
|
|
49
|
+
|
|
50
|
+
For renderer output, load either exported stylesheet and wrap it in
|
|
51
|
+
`<pre class="aeon-highlight"><code>…rendered HTML…</code></pre>`:
|
|
52
|
+
|
|
53
|
+
- `@altopelago/aeon-highlight/theme.css`: existing AEON dark palette.
|
|
54
|
+
- `@altopelago/aeon-highlight/theme-light.css`: existing Aeonite light palette.
|
|
55
|
+
|
|
56
|
+
Styles are scoped to `.aeon-highlight`. The component carries equivalent shadow
|
|
57
|
+
styles and uses `theme="light"` for the light palette. Consumers can override
|
|
58
|
+
`--aeon-*` custom properties on the wrapper/element. Names used as keys, types or
|
|
59
|
+
tags retain their distinct existing colours; unclassified identifiers retain the
|
|
60
|
+
foreground. Symbols, identities and SANSA addresses have explicit theme colours.
|
|
61
|
+
|
|
62
|
+
## Development
|
|
63
|
+
|
|
64
|
+
From `implementations/typescript`:
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
pnpm --filter @altopelago/aeon-highlight... build
|
|
68
|
+
pnpm --filter @altopelago/aeon-highlight... typecheck
|
|
69
|
+
pnpm --filter @altopelago/aeon-highlight... test
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The [consumer migration checklist](../../../../docs/browser-highlighting-0.17.0.md)
|
|
73
|
+
keeps adoption separate from package preparation and PR #197.
|
|
74
|
+
|
|
75
|
+
### Browser lifecycle regression
|
|
76
|
+
|
|
77
|
+
`test/browser/element-lifecycle.html` and its module execute real DOM mutation
|
|
78
|
+
cases, including selected-template edits/replacement, source precedence, script
|
|
79
|
+
type changes and disconnect/reconnect. Copy both files into the root of a local
|
|
80
|
+
packed consumer alongside `node_modules`, serve that root over loopback, open the
|
|
81
|
+
page and press **Run lifecycle tests**. The import map uses the installed package
|
|
82
|
+
and lexer; it has no workspace fallback. This browser fixture is separate from
|
|
83
|
+
the Node-only test command above. Clipboard permissions and the browser-engine
|
|
84
|
+
matrix remain release qualification checks.
|
|
85
|
+
|
|
86
|
+
## Hosts with a selected lexer
|
|
87
|
+
|
|
88
|
+
`@altopelago/aeon-highlight/renderer` exports `createHighlighter(lexer)` and the
|
|
89
|
+
`Highlighter`, `LexerProvider` and diagnostic option types. This entry loads no
|
|
90
|
+
lexer or DOM. Supply the actual implementation namespace selected by the host:
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
import * as lexer from '@aeon/lexer'; // The host page's existing import map.
|
|
94
|
+
import {createHighlighter} from '@altopelago/aeon-highlight/renderer';
|
|
95
|
+
const {highlightAeon, highlightJson} = createHighlighter(lexer);
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
This keeps legacy website 0.16 and candidate 0.17 tokenization tied to their own
|
|
99
|
+
selected runtimes. Consumers must test those exact provider artifacts. The root
|
|
100
|
+
and element entries retain their matching 0.17 lexer dependency and unchanged
|
|
101
|
+
APIs. Provider rendering does not add a parser or a fallback scanner.
|
|
102
|
+
|
|
103
|
+
Numbers (including radix/hex literals) use `tok-number` / `--aeon-number`;
|
|
104
|
+
dates, times and datetimes use `tok-temporal` / `--aeon-temporal`. Dark defaults
|
|
105
|
+
are cyan `#7dd3fc` and light yellow `#f5e6a8`; light-theme equivalents are
|
|
106
|
+
`#006b80` and `#806500`. SANSA address literals retain `tok-sansa` and inherit
|
|
107
|
+
`--aeon-symbol`. Booleans and other literals retain `--aeon-literal`. JSON
|
|
108
|
+
numbers use the numeric colour too. These are presentation roles over existing
|
|
109
|
+
lexer tokens and do not change parsing or reference semantics.
|
|
110
|
+
|
|
111
|
+
### Custom OKLCH colours
|
|
112
|
+
|
|
113
|
+
Custom properties also accept OKLCH, for example on the rendered wrapper:
|
|
114
|
+
|
|
115
|
+
```css
|
|
116
|
+
.aeon-highlight.my-theme {
|
|
117
|
+
--aeon-number: oklch(0.78 0.14 230.32);
|
|
118
|
+
--aeon-string: oklch(0.78 0.14 91.25);
|
|
119
|
+
--aeon-symbol: oklch(0.78 0.14 176.9);
|
|
120
|
+
--aeon-sansa: var(--aeon-symbol);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
The local source playground provides three selectable experimental presets and
|
|
125
|
+
shared L/C controls. Those local presets are not additional package exports.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const MAX_HIGHLIGHT_SOURCE_CODE_UNITS = 1048576;
|
|
2
|
+
export declare function createAeonHighlighter({ tokenize, TokenType }: {
|
|
3
|
+
TokenType: any;
|
|
4
|
+
tokenize: any;
|
|
5
|
+
}): {
|
|
6
|
+
highlightAeon: (source: string, diagnosticLine?: number | null, diagnosticColumn?: number) => any;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=aeon-token-highlight.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aeon-token-highlight.d.mts","sourceRoot":"","sources":["../src/aeon-token-highlight.mjs"],"names":[],"mappings":"AAIA,eAAO,MAAM,+BAA+B,UAAY,CAAC;AAEzD,wBAAgB,qBAAqB,CAAC,EAAC,QAAQ,EAAE,SAAS,EAAC;;;CAAA;4BA6H7C,MAAM,mBAAiB,MAAM,GAAC,IAAI,qBAAyB,MAAM;EAQ9E"}
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { escapeHtml, renderDocComment, highlightFromColumn } from './presentation-highlight.mjs';
|
|
2
|
+
// A presentation allowance only: larger inputs remain visible as escaped text.
|
|
3
|
+
// It does not change compiler, parser, reference or resolver limits.
|
|
4
|
+
export const MAX_HIGHLIGHT_SOURCE_CODE_UNITS = 1_048_576;
|
|
5
|
+
export function createAeonHighlighter({ tokenize, TokenType }) {
|
|
6
|
+
const styles = new Map([
|
|
7
|
+
[TokenType.String, 'string'],
|
|
8
|
+
[TokenType.StructuralIdentity, 'identity'],
|
|
9
|
+
[TokenType.SansaAddressLiteral, 'sansa'],
|
|
10
|
+
[TokenType.Tilde, 'binding'], [TokenType.TildeArrow, 'binding'],
|
|
11
|
+
[TokenType.Equals, 'operator'],
|
|
12
|
+
[TokenType.SymbolicLiteral, 'symbol'],
|
|
13
|
+
...['Number', 'HexLiteral', 'RadixLiteral'].map(name => [TokenType[name], 'number']),
|
|
14
|
+
...['Date', 'DateTime', 'Time'].map(name => [TokenType[name], 'temporal']),
|
|
15
|
+
...['EncodingLiteral', 'SeparatorLiteral', 'True', 'False', 'Yes', 'No', 'On', 'Off']
|
|
16
|
+
.map(name => [TokenType[name], 'literal']),
|
|
17
|
+
...['LeftBrace', 'RightBrace', 'LeftBracket', 'RightBracket', 'LeftParen', 'RightParen',
|
|
18
|
+
'LeftAngle', 'RightAngle', 'Colon', 'Comma', 'Dot', 'At', 'Caret', 'Hash', 'Dollar',
|
|
19
|
+
'Question', 'Percent', 'Ampersand', 'Semicolon', 'Symbol'].map(name => [TokenType[name], 'punct']),
|
|
20
|
+
].filter(([type]) => type !== undefined));
|
|
21
|
+
const comments = new Map([
|
|
22
|
+
['plain', 'comment'], ['doc', 'comment-doc'], ['annotation', 'comment-annotation'],
|
|
23
|
+
['hint', 'comment-hint'], ['host', 'comment-host'],
|
|
24
|
+
]);
|
|
25
|
+
const reservedComments = new Map([
|
|
26
|
+
['structure', 'comment-structure'], ['profile', 'comment-profile'], ['instructions', 'comment-future'],
|
|
27
|
+
]);
|
|
28
|
+
// Presentation roles over implementation tokens only. These do not validate,
|
|
29
|
+
// split, consume or reinterpret AEON source, and are never used by execution.
|
|
30
|
+
function presentationRoles(tokens) {
|
|
31
|
+
const roles = new Map();
|
|
32
|
+
const significant = tokens.filter(t => t.type !== TokenType.LineComment &&
|
|
33
|
+
t.type !== TokenType.BlockComment && t.type !== TokenType.Newline && t.type !== TokenType.EOF);
|
|
34
|
+
let datatype = false, typeDepth = 0, reference = false, referenceDepth = 0;
|
|
35
|
+
let previous;
|
|
36
|
+
const braces = [];
|
|
37
|
+
for (let i = 0; i < significant.length; i++) {
|
|
38
|
+
const token = significant[i], next = significant[i + 1];
|
|
39
|
+
const type = token.type;
|
|
40
|
+
const adjacent = previous && previous.span.end.offset === token.span.start.offset;
|
|
41
|
+
if (reference && ((!adjacent && previous?.type !== TokenType.TildeArrow) || (referenceDepth === 0 &&
|
|
42
|
+
[TokenType.Comma, TokenType.RightBrace, TokenType.RightAngle, TokenType.RightBracket, TokenType.Equals].includes(type))))
|
|
43
|
+
reference = false;
|
|
44
|
+
if (type === TokenType.Tilde || type === TokenType.TildeArrow) {
|
|
45
|
+
reference = true;
|
|
46
|
+
referenceDepth = 0;
|
|
47
|
+
}
|
|
48
|
+
if (reference) {
|
|
49
|
+
roles.set(token, 'binding');
|
|
50
|
+
if (type === TokenType.LeftBracket)
|
|
51
|
+
referenceDepth++;
|
|
52
|
+
if (type === TokenType.RightBracket)
|
|
53
|
+
referenceDepth--;
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (type === TokenType.Equals || type === TokenType.At ||
|
|
57
|
+
(typeDepth === 0 && [TokenType.LeftBrace, TokenType.RightBrace, TokenType.Comma].includes(type)))
|
|
58
|
+
datatype = false;
|
|
59
|
+
if (type === TokenType.Colon) {
|
|
60
|
+
datatype = true;
|
|
61
|
+
typeDepth = 0;
|
|
62
|
+
}
|
|
63
|
+
else if (datatype) {
|
|
64
|
+
roles.set(token, 'type');
|
|
65
|
+
if (type === TokenType.LeftAngle || type === TokenType.LeftBracket)
|
|
66
|
+
typeDepth++;
|
|
67
|
+
if (type === TokenType.RightAngle || type === TokenType.RightBracket)
|
|
68
|
+
typeDepth--;
|
|
69
|
+
}
|
|
70
|
+
else if (type === TokenType.Identifier || type === TokenType.String) {
|
|
71
|
+
if (previous?.type === TokenType.LeftAngle)
|
|
72
|
+
roles.set(token, 'tag');
|
|
73
|
+
else if ([TokenType.Colon, TokenType.StructuralIdentity, TokenType.Equals, TokenType.At].includes(next?.type))
|
|
74
|
+
roles.set(token, 'key');
|
|
75
|
+
else if (type === TokenType.Identifier && ['NaN', 'Infinity'].includes(token.value))
|
|
76
|
+
roles.set(token, 'number');
|
|
77
|
+
else if (previous?.type === TokenType.Symbol && previous.value === '!')
|
|
78
|
+
roles.set(token, 'literal');
|
|
79
|
+
}
|
|
80
|
+
if (type === TokenType.LeftBrace) {
|
|
81
|
+
const attributes = previous?.type === TokenType.At;
|
|
82
|
+
braces.push(attributes);
|
|
83
|
+
if (attributes) {
|
|
84
|
+
roles.set(previous, 'attribute-punct');
|
|
85
|
+
roles.set(token, 'attribute-punct');
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
if (type === TokenType.RightBrace && braces.pop())
|
|
89
|
+
roles.set(token, 'attribute-punct');
|
|
90
|
+
if (type === TokenType.Symbol && token.value === '!')
|
|
91
|
+
roles.set(token, 'literal');
|
|
92
|
+
}
|
|
93
|
+
previous = token;
|
|
94
|
+
}
|
|
95
|
+
for (let i = 0; i + 2 < significant.length; i++) {
|
|
96
|
+
if (significant[i].type === TokenType.Identifier && significant[i].value === 'aeon' &&
|
|
97
|
+
significant[i + 1].type === TokenType.Colon && significant[i + 2].type === TokenType.Identifier) {
|
|
98
|
+
for (const t of significant.slice(i, i + 3))
|
|
99
|
+
roles.set(t, 'directive');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return roles;
|
|
103
|
+
}
|
|
104
|
+
function renderToken(text, token, role) {
|
|
105
|
+
let style = role ?? styles.get(token.type);
|
|
106
|
+
if (token.type === TokenType.LineComment || token.type === TokenType.BlockComment) {
|
|
107
|
+
style = token.comment?.channel === 'reserved'
|
|
108
|
+
? reservedComments.get(token.comment.subtype) ?? 'comment'
|
|
109
|
+
: comments.get(token.comment?.channel) ?? 'comment';
|
|
110
|
+
// Optional &ND decoration operates only inside lexer-classified doc comments.
|
|
111
|
+
if (style === 'comment-doc')
|
|
112
|
+
return renderDocComment(text);
|
|
113
|
+
}
|
|
114
|
+
if (!style)
|
|
115
|
+
return escapeHtml(text);
|
|
116
|
+
// Keep spans balanced on every line for diagnostics and editor scrolling.
|
|
117
|
+
return text.split('\n').map(line => `<span class="tok-${style}">${escapeHtml(line)}</span>`).join('\n');
|
|
118
|
+
}
|
|
119
|
+
function renderSource(source) {
|
|
120
|
+
if (source.length > MAX_HIGHLIGHT_SOURCE_CODE_UNITS)
|
|
121
|
+
return escapeHtml(source);
|
|
122
|
+
let tokens;
|
|
123
|
+
try {
|
|
124
|
+
tokens = tokenize(source, { includeComments: true, includeNewlines: true }).tokens;
|
|
125
|
+
}
|
|
126
|
+
catch {
|
|
127
|
+
return escapeHtml(source);
|
|
128
|
+
}
|
|
129
|
+
if (!Array.isArray(tokens))
|
|
130
|
+
return escapeHtml(source);
|
|
131
|
+
let cursor = 0;
|
|
132
|
+
const output = [];
|
|
133
|
+
for (const token of tokens) {
|
|
134
|
+
const start = token.span?.start?.offset, end = token.span?.end?.offset;
|
|
135
|
+
if (!Number.isInteger(start) || !Number.isInteger(end) || start < cursor || end < start || end > source.length) {
|
|
136
|
+
return escapeHtml(source);
|
|
137
|
+
}
|
|
138
|
+
cursor = end;
|
|
139
|
+
}
|
|
140
|
+
cursor = 0;
|
|
141
|
+
const roles = presentationRoles(tokens);
|
|
142
|
+
for (const token of tokens) {
|
|
143
|
+
const start = token.span.start.offset, end = token.span.end.offset;
|
|
144
|
+
if (end === start)
|
|
145
|
+
continue;
|
|
146
|
+
output.push(escapeHtml(source.slice(cursor, start)));
|
|
147
|
+
// Token values may be decoded. Only the original source slice is displayed.
|
|
148
|
+
output.push(renderToken(source.slice(start, end), token, roles.get(token)));
|
|
149
|
+
cursor = end;
|
|
150
|
+
}
|
|
151
|
+
output.push(escapeHtml(source.slice(cursor)));
|
|
152
|
+
return output.join('');
|
|
153
|
+
}
|
|
154
|
+
/** @param {string} source @param {number|null} diagnosticLine @param {number} diagnosticColumn */
|
|
155
|
+
function highlightAeon(source, diagnosticLine = null, diagnosticColumn = 1) {
|
|
156
|
+
const html = renderSource(source);
|
|
157
|
+
if (!Number.isInteger(diagnosticLine) || diagnosticLine < 1)
|
|
158
|
+
return html;
|
|
159
|
+
return html.split('\n').map((line, index) => index + 1 === diagnosticLine
|
|
160
|
+
? highlightFromColumn(line, diagnosticColumn) : line).join('\n');
|
|
161
|
+
}
|
|
162
|
+
return { highlightAeon };
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=aeon-token-highlight.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aeon-token-highlight.mjs","sourceRoot":"","sources":["../src/aeon-token-highlight.mjs"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAC,MAAM,8BAA8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}
|
|
4
|
+
export type AeonCodeBlockConstructor = new () => AeonCodeBlockElement;
|
|
5
|
+
/** Explicit registration. Importing this module has no DOM side effects. */
|
|
6
|
+
export declare function defineAeonCodeBlock(tagName?: string): AeonCodeBlockConstructor;
|
|
7
|
+
//# sourceMappingURL=element.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAmBA,MAAM,WAAW,oBAAqB,SAAQ,WAAW;IAAG,IAAI,EAAE,MAAM,CAAC;CAAE;AAC3E,MAAM,MAAM,wBAAwB,GAAG,UAAU,oBAAoB,CAAC;AAGtE,4EAA4E;AAC5E,wBAAgB,mBAAmB,CAAC,OAAO,SAAoB,GAAG,wBAAwB,CAqFzF"}
|
package/dist/element.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { highlightAeon } from './index.js';
|
|
2
|
+
import { darkVariables, lightVariables, tokenStyles } from './themes.js';
|
|
3
|
+
const shellStyles = `
|
|
4
|
+
:host { display:block; min-width:0; ${darkVariables} color:var(--aeon-fg); }
|
|
5
|
+
:host([theme="light"]) { ${lightVariables} }
|
|
6
|
+
.frame { border:1px solid var(--aeon-border); background:var(--aeon-bg); }
|
|
7
|
+
.header { display:flex; align-items:center; justify-content:space-between; gap:1rem;
|
|
8
|
+
padding:.65rem .8rem; border-bottom:1px solid var(--aeon-border); background:var(--aeon-panel); }
|
|
9
|
+
.title, button { font:inherit; }
|
|
10
|
+
button { color:var(--aeon-fg); background:var(--aeon-bg); border:1px solid var(--aeon-border);
|
|
11
|
+
padding:.25rem .55rem; cursor:pointer; }
|
|
12
|
+
button:focus-visible { outline:2px solid var(--aeon-key); outline-offset:2px; }
|
|
13
|
+
[hidden] { display:none; }
|
|
14
|
+
pre { margin:0; padding:.8rem; overflow:auto; tab-size:2; white-space:pre;
|
|
15
|
+
font: .78rem/1.45 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
|
|
16
|
+
code { font:inherit; }
|
|
17
|
+
${tokenStyles}`;
|
|
18
|
+
const ownedDefinitions = new WeakSet();
|
|
19
|
+
/** Explicit registration. Importing this module has no DOM side effects. */
|
|
20
|
+
export function defineAeonCodeBlock(tagName = 'aeon-code-block') {
|
|
21
|
+
if (typeof customElements === 'undefined' || typeof HTMLElement === 'undefined') {
|
|
22
|
+
throw new Error('defineAeonCodeBlock requires a browser with custom elements.');
|
|
23
|
+
}
|
|
24
|
+
const existing = customElements.get(tagName);
|
|
25
|
+
if (existing) {
|
|
26
|
+
if (!ownedDefinitions.has(existing))
|
|
27
|
+
throw new Error(`Custom element ${tagName} is already defined by another implementation.`);
|
|
28
|
+
return existing;
|
|
29
|
+
}
|
|
30
|
+
class AeonCodeBlock extends HTMLElement {
|
|
31
|
+
static get observedAttributes() { return ['title', 'show-copy', 'code']; }
|
|
32
|
+
sourceOverride;
|
|
33
|
+
codeElement;
|
|
34
|
+
titleElement;
|
|
35
|
+
copyButton;
|
|
36
|
+
status;
|
|
37
|
+
observer;
|
|
38
|
+
templateObserver;
|
|
39
|
+
observedTemplate = null;
|
|
40
|
+
constructor() {
|
|
41
|
+
super();
|
|
42
|
+
const shadow = this.attachShadow({ mode: 'open' });
|
|
43
|
+
const style = document.createElement('style');
|
|
44
|
+
style.textContent = shellStyles;
|
|
45
|
+
const frame = document.createElement('div');
|
|
46
|
+
frame.className = 'frame';
|
|
47
|
+
const header = document.createElement('div');
|
|
48
|
+
header.className = 'header';
|
|
49
|
+
this.titleElement = document.createElement('span');
|
|
50
|
+
this.titleElement.className = 'title';
|
|
51
|
+
this.copyButton = document.createElement('button');
|
|
52
|
+
this.copyButton.type = 'button';
|
|
53
|
+
this.copyButton.textContent = 'Copy';
|
|
54
|
+
this.copyButton.setAttribute('aria-label', 'Copy AEON source');
|
|
55
|
+
this.status = document.createElement('span');
|
|
56
|
+
this.status.setAttribute('role', 'status');
|
|
57
|
+
const pre = document.createElement('pre');
|
|
58
|
+
this.codeElement = document.createElement('code');
|
|
59
|
+
pre.append(this.codeElement);
|
|
60
|
+
header.append(this.titleElement, this.copyButton, this.status);
|
|
61
|
+
frame.append(header, pre);
|
|
62
|
+
shadow.append(style, frame);
|
|
63
|
+
this.copyButton.addEventListener('click', () => { void this.copySource(); });
|
|
64
|
+
this.observer = new MutationObserver(() => this.render());
|
|
65
|
+
this.templateObserver = new MutationObserver(() => this.render());
|
|
66
|
+
}
|
|
67
|
+
/** Exact authored source; assigning it does not rewrite light DOM. */
|
|
68
|
+
get code() { return this.readSource().text; }
|
|
69
|
+
readSource() {
|
|
70
|
+
if (this.sourceOverride !== undefined)
|
|
71
|
+
return { text: this.sourceOverride, template: null };
|
|
72
|
+
const attribute = this.getAttribute('code');
|
|
73
|
+
if (attribute !== null)
|
|
74
|
+
return { text: attribute, template: null };
|
|
75
|
+
const script = this.querySelector('script[type="text/plain"]');
|
|
76
|
+
if (script)
|
|
77
|
+
return { text: script.textContent ?? '', template: null };
|
|
78
|
+
const template = this.querySelector('template');
|
|
79
|
+
if (template instanceof HTMLTemplateElement) {
|
|
80
|
+
return { text: template.content.textContent ?? '', template: template.content };
|
|
81
|
+
}
|
|
82
|
+
return { text: this.textContent ?? '', template: null };
|
|
83
|
+
}
|
|
84
|
+
set code(source) { this.sourceOverride = source; this.render(); }
|
|
85
|
+
connectedCallback() {
|
|
86
|
+
this.observer.observe(this, { childList: true, characterData: true, subtree: true,
|
|
87
|
+
attributes: true, attributeFilter: ['type'] });
|
|
88
|
+
this.render();
|
|
89
|
+
}
|
|
90
|
+
disconnectedCallback() {
|
|
91
|
+
this.observer.disconnect();
|
|
92
|
+
this.templateObserver.disconnect();
|
|
93
|
+
this.observedTemplate = null;
|
|
94
|
+
}
|
|
95
|
+
attributeChangedCallback() { this.render(); }
|
|
96
|
+
render() {
|
|
97
|
+
const source = this.readSource();
|
|
98
|
+
const template = this.isConnected ? source.template : null;
|
|
99
|
+
if (template !== this.observedTemplate) {
|
|
100
|
+
this.templateObserver.disconnect();
|
|
101
|
+
this.observedTemplate = template;
|
|
102
|
+
if (template)
|
|
103
|
+
this.templateObserver.observe(template, { childList: true, characterData: true, subtree: true });
|
|
104
|
+
}
|
|
105
|
+
this.titleElement.textContent = this.getAttribute('title') ?? 'Code';
|
|
106
|
+
this.copyButton.hidden = this.getAttribute('show-copy') === 'false';
|
|
107
|
+
this.codeElement.innerHTML = highlightAeon(source.text);
|
|
108
|
+
this.status.textContent = '';
|
|
109
|
+
}
|
|
110
|
+
async copySource() {
|
|
111
|
+
try {
|
|
112
|
+
await navigator.clipboard.writeText(this.code);
|
|
113
|
+
this.status.textContent = 'Copied';
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
this.status.textContent = 'Copy unavailable';
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
customElements.define(tagName, AeonCodeBlock);
|
|
121
|
+
ownedDefinitions.add(AeonCodeBlock);
|
|
122
|
+
return AeonCodeBlock;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=element.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"element.js","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AACzC,OAAO,EAAC,aAAa,EAAE,cAAc,EAAE,WAAW,EAAC,MAAM,aAAa,CAAC;AAEvE,MAAM,WAAW,GAAG;sCACkB,aAAa;2BACxB,cAAc;;;;;;;;;;;;EAYvC,WAAW,EAAE,CAAC;AAIhB,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAA4B,CAAC;AAEjE,4EAA4E;AAC5E,MAAM,UAAU,mBAAmB,CAAC,OAAO,GAAG,iBAAiB;IAC3D,IAAI,OAAO,cAAc,KAAK,WAAW,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;QAC9E,MAAM,IAAI,KAAK,CAAC,8DAA8D,CAAC,CAAC;IACpF,CAAC;IACD,MAA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,GAAG,QAAQ,CAAC;YAAC,CAAC;YAC3F,MAAM,CAAC;gBAAC,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,kBAAkB,CAAC;YAAC,CAAC;QAC3D,CAAC;KACJ;IACD,cAAc,CAAC,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC9C,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACpC,OAAO,aAAa,CAAC;AACzB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { MAX_HIGHLIGHT_SOURCE_CODE_UNITS } from './renderer.js';
|
|
2
|
+
export type { HighlightOptions } from './renderer.js';
|
|
3
|
+
/** Render original source using the package's matching implementation lexer. */
|
|
4
|
+
export declare const highlightAeon: (source: string, options?: import("./renderer.js").HighlightOptions) => string;
|
|
5
|
+
/** Separate JSON presentation helper; it does not parse or validate AEON. */
|
|
6
|
+
export declare const highlightJson: (source: string) => string;
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,+BAA+B,EAAC,MAAM,eAAe,CAAC;AAC9D,YAAY,EAAC,gBAAgB,EAAC,MAAM,eAAe,CAAC;AAGpD,gFAAgF;AAChF,eAAO,MAAM,aAAa,gFAAyB,CAAC;AACpD,6EAA6E;AAC7E,eAAO,MAAM,aAAa,4BAAyB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as lexer from '@altopelago/aeon-lexer';
|
|
2
|
+
import { createHighlighter } from './renderer.js';
|
|
3
|
+
export { MAX_HIGHLIGHT_SOURCE_CODE_UNITS } from './renderer.js';
|
|
4
|
+
const renderer = createHighlighter(lexer);
|
|
5
|
+
/** Render original source using the package's matching implementation lexer. */
|
|
6
|
+
export const highlightAeon = renderer.highlightAeon;
|
|
7
|
+
/** Separate JSON presentation helper; it does not parse or validate AEON. */
|
|
8
|
+
export const highlightJson = renderer.highlightJson;
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAChD,OAAO,EAAC,+BAA+B,EAAC,MAAM,eAAe,CAAC;AAG9D,MAAM,QAAQ,GAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC1C,gFAAgF;AAChF,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC;AACpD,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
declare function escapeHtml(value: any): any;
|
|
2
|
+
declare function renderDocComment(value: any): any;
|
|
3
|
+
declare function highlightFromColumn(html: any, column: any): string;
|
|
4
|
+
declare function highlightJson(source: any): string;
|
|
5
|
+
export { escapeHtml, renderDocComment, highlightFromColumn, highlightJson };
|
|
6
|
+
//# sourceMappingURL=presentation-highlight.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-highlight.d.mts","sourceRoot":"","sources":["../src/presentation-highlight.mjs"],"names":[],"mappings":"AACA,iBAAS,UAAU,CAAC,KAAK,KAAA,OAKxB;AAwED,iBAAS,gBAAgB,CAAC,KAAK,KAAA,OA8C9B;AAED,iBAAS,mBAAmB,CAAC,IAAI,KAAA,EAAE,MAAM,KAAA,UAuDxC;AAED,iBAAS,aAAa,CAAC,MAAM,KAAA,UAqC5B;AAGD,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAC,CAAC"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
// JSON colouring and &ND comment decoration; no AEON tokenization.
|
|
2
|
+
function escapeHtml(value) {
|
|
3
|
+
return value
|
|
4
|
+
.replace(/&/g, "&")
|
|
5
|
+
.replace(/</g, "<")
|
|
6
|
+
.replace(/>/g, ">");
|
|
7
|
+
}
|
|
8
|
+
function wrap(type, value) {
|
|
9
|
+
return `<span class="tok-${type}">${escapeHtml(value)}</span>`;
|
|
10
|
+
}
|
|
11
|
+
function wrapRaw(type, html) {
|
|
12
|
+
return `<span class="tok-${type}">${html}</span>`;
|
|
13
|
+
}
|
|
14
|
+
function renderAndInline(value) {
|
|
15
|
+
const parts = [];
|
|
16
|
+
let index = 0;
|
|
17
|
+
let start = 0;
|
|
18
|
+
let noClosingBracket = false;
|
|
19
|
+
while (start < value.length) {
|
|
20
|
+
let token;
|
|
21
|
+
const next = value[start + 1];
|
|
22
|
+
if (value[start] === '\\' && next !== undefined && '[]|\\'.includes(next)) {
|
|
23
|
+
token = value.slice(start, start + 2);
|
|
24
|
+
}
|
|
25
|
+
else if (value[start] === '|') {
|
|
26
|
+
token = '|';
|
|
27
|
+
}
|
|
28
|
+
else if (value[start] === '[' && next !== undefined
|
|
29
|
+
&& '*/$@ x=._<'.includes(next) && !noClosingBracket) {
|
|
30
|
+
const end = value.indexOf(']', start + 2);
|
|
31
|
+
// A failed search proves there is no closer for any later opener.
|
|
32
|
+
// Complete tokens consume their whole searched interval.
|
|
33
|
+
if (end === -1)
|
|
34
|
+
noClosingBracket = true;
|
|
35
|
+
else
|
|
36
|
+
token = value.slice(start, end + 1);
|
|
37
|
+
}
|
|
38
|
+
if (token === undefined) {
|
|
39
|
+
start += 1;
|
|
40
|
+
continue;
|
|
41
|
+
}
|
|
42
|
+
if (start > index) {
|
|
43
|
+
parts.push(escapeHtml(value.slice(index, start)));
|
|
44
|
+
}
|
|
45
|
+
if (token.startsWith('\\')) {
|
|
46
|
+
parts.push(wrap('and-escape', token));
|
|
47
|
+
}
|
|
48
|
+
else if (token === '|') {
|
|
49
|
+
parts.push(wrap('and-table-pipe', token));
|
|
50
|
+
}
|
|
51
|
+
else if (/^\[(?: |x|=|\.|_|<)/.test(token)) {
|
|
52
|
+
parts.push(wrap('and-invalid', token));
|
|
53
|
+
}
|
|
54
|
+
else if (token.startsWith('[*')) {
|
|
55
|
+
parts.push(wrap('and-strong', token));
|
|
56
|
+
}
|
|
57
|
+
else if (token.startsWith('[/')) {
|
|
58
|
+
parts.push(wrap('and-emphasis', token));
|
|
59
|
+
}
|
|
60
|
+
else if (token.startsWith('[$')) {
|
|
61
|
+
parts.push(wrap('and-code', token));
|
|
62
|
+
}
|
|
63
|
+
else if (token.startsWith('[@')) {
|
|
64
|
+
const link = /^(\[@)(.*?)(\|)(.*)(\])$/.exec(token);
|
|
65
|
+
if (link) {
|
|
66
|
+
parts.push(wrap('and-link', link[1] + link[2]) +
|
|
67
|
+
wrap('and-link-separator', link[3]) +
|
|
68
|
+
wrap('and-link-target', link[4]) +
|
|
69
|
+
wrap('and-link', link[5]));
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
parts.push(wrap('and-link', token));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
index = start + token.length;
|
|
76
|
+
start = index;
|
|
77
|
+
}
|
|
78
|
+
if (index < value.length) {
|
|
79
|
+
parts.push(escapeHtml(value.slice(index)));
|
|
80
|
+
}
|
|
81
|
+
return parts.join('');
|
|
82
|
+
}
|
|
83
|
+
function renderDocComment(value) {
|
|
84
|
+
return value
|
|
85
|
+
.split('\n')
|
|
86
|
+
.map((line) => {
|
|
87
|
+
if (/^\s*(?:\/#|#\/)\s*$/.test(line)) {
|
|
88
|
+
return wrap('comment-doc', line);
|
|
89
|
+
}
|
|
90
|
+
const header = /^(\s*)(&ND)(\s+v[0-9]+)?(.*)$/.exec(line);
|
|
91
|
+
if (header) {
|
|
92
|
+
return escapeHtml(header[1]) + wrap('and-header', header[2]) + (header[3] ? wrap('and-version', header[3]) : '') + wrapRaw('comment-doc', renderAndInline(header[4]));
|
|
93
|
+
}
|
|
94
|
+
const codeFence = /^(\s*)(`{3,})([A-Za-z0-9_+.-]+)?(.*)$/.exec(line);
|
|
95
|
+
if (codeFence) {
|
|
96
|
+
return escapeHtml(codeFence[1]) + wrap('and-fence', codeFence[2]) + (codeFence[3] ? wrap('and-fence-label', codeFence[3]) : '') + wrapRaw('comment-doc', renderAndInline(codeFence[4]));
|
|
97
|
+
}
|
|
98
|
+
const extensionFence = /^(\s*)(\+{3})([A-Za-z0-9_./+-]+|fallback)?(.*)$/.exec(line);
|
|
99
|
+
if (extensionFence) {
|
|
100
|
+
return escapeHtml(extensionFence[1]) + wrap('and-extension-fence', extensionFence[2]) + (extensionFence[3] ? wrap('and-extension-name', extensionFence[3]) : '') + wrapRaw('comment-doc', renderAndInline(extensionFence[4]));
|
|
101
|
+
}
|
|
102
|
+
const rule = /^(\s*)(---)(\s*)$/.exec(line);
|
|
103
|
+
if (rule) {
|
|
104
|
+
return escapeHtml(rule[1]) + wrap('and-rule', rule[2]) + escapeHtml(rule[3]);
|
|
105
|
+
}
|
|
106
|
+
const quote = /^(\s*(?:>\s*)+)(.*)$/.exec(line);
|
|
107
|
+
if (quote) {
|
|
108
|
+
return wrap('and-quote', quote[1]) + wrapRaw('and-quote-text', renderAndInline(quote[2]));
|
|
109
|
+
}
|
|
110
|
+
const heading = /^(\s{0,3})(#{1,6})(\s+.*)$/.exec(line);
|
|
111
|
+
if (heading) {
|
|
112
|
+
return escapeHtml(heading[1]) + wrap('and-heading-marker', heading[2]) + wrapRaw('and-heading', renderAndInline(heading[3]));
|
|
113
|
+
}
|
|
114
|
+
const list = /^(\s*)(-\s+|\d+\.\s+)(.*)$/.exec(line);
|
|
115
|
+
if (list) {
|
|
116
|
+
return escapeHtml(list[1]) + wrap('and-list-marker', list[2]) + wrapRaw('and-list-text', renderAndInline(list[3]));
|
|
117
|
+
}
|
|
118
|
+
return wrapRaw('comment-doc', renderAndInline(line));
|
|
119
|
+
})
|
|
120
|
+
.join('\n');
|
|
121
|
+
}
|
|
122
|
+
function highlightFromColumn(html, column) {
|
|
123
|
+
const target = Math.max(0, column - 1);
|
|
124
|
+
const openTags = [];
|
|
125
|
+
let output = "";
|
|
126
|
+
let index = 0;
|
|
127
|
+
let visibleIndex = 0;
|
|
128
|
+
let marked = false;
|
|
129
|
+
let markedContent = false;
|
|
130
|
+
const startMark = () => {
|
|
131
|
+
for (let tagIndex = openTags.length - 1; tagIndex >= 0; tagIndex -= 1) {
|
|
132
|
+
output += "</span>";
|
|
133
|
+
}
|
|
134
|
+
output += '<span class="aeon-diagnostic-line">';
|
|
135
|
+
for (const tag of openTags)
|
|
136
|
+
output += tag;
|
|
137
|
+
marked = true;
|
|
138
|
+
};
|
|
139
|
+
while (index < html.length) {
|
|
140
|
+
if (!marked && visibleIndex >= target)
|
|
141
|
+
startMark();
|
|
142
|
+
if (html[index] === "<") {
|
|
143
|
+
const end = html.indexOf(">", index);
|
|
144
|
+
if (end === -1)
|
|
145
|
+
break;
|
|
146
|
+
const tag = html.slice(index, end + 1);
|
|
147
|
+
output += tag;
|
|
148
|
+
if (tag.startsWith("</")) {
|
|
149
|
+
openTags.pop();
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
openTags.push(tag);
|
|
153
|
+
}
|
|
154
|
+
index = end + 1;
|
|
155
|
+
continue;
|
|
156
|
+
}
|
|
157
|
+
if (html[index] === "&") {
|
|
158
|
+
const end = html.indexOf(";", index);
|
|
159
|
+
if (end !== -1) {
|
|
160
|
+
output += html.slice(index, end + 1);
|
|
161
|
+
index = end + 1;
|
|
162
|
+
visibleIndex += 1;
|
|
163
|
+
if (marked)
|
|
164
|
+
markedContent = true;
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
output += html[index];
|
|
169
|
+
index += 1;
|
|
170
|
+
visibleIndex += 1;
|
|
171
|
+
if (marked)
|
|
172
|
+
markedContent = true;
|
|
173
|
+
}
|
|
174
|
+
if (!marked)
|
|
175
|
+
startMark();
|
|
176
|
+
if (!markedContent)
|
|
177
|
+
output += "​";
|
|
178
|
+
return `${output}</span>`;
|
|
179
|
+
}
|
|
180
|
+
function highlightJson(source) {
|
|
181
|
+
// Quoted text is walked once; no quote/escape repetition enters a regex.
|
|
182
|
+
const pattern = /\b(true|false|null)\b|(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)|([{}[\],:])/y;
|
|
183
|
+
let html = "";
|
|
184
|
+
let index = 0;
|
|
185
|
+
while (index < source.length) {
|
|
186
|
+
if (source[index] === '"') {
|
|
187
|
+
const start = index;
|
|
188
|
+
let end = index + 1;
|
|
189
|
+
let closed = false;
|
|
190
|
+
while (end < source.length) {
|
|
191
|
+
const ch = source[end];
|
|
192
|
+
if (ch === '\\')
|
|
193
|
+
end = Math.min(source.length, end + 2);
|
|
194
|
+
else if (ch === '"') {
|
|
195
|
+
end += 1;
|
|
196
|
+
closed = true;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
else
|
|
200
|
+
end += 1;
|
|
201
|
+
}
|
|
202
|
+
if (!closed) {
|
|
203
|
+
html += escapeHtml(source.slice(start));
|
|
204
|
+
break;
|
|
205
|
+
}
|
|
206
|
+
let colon = end;
|
|
207
|
+
while (colon < source.length && ' \t\r\n'.includes(source[colon]))
|
|
208
|
+
colon += 1;
|
|
209
|
+
const isKey = source[colon] === ':';
|
|
210
|
+
html += isKey
|
|
211
|
+
? `<span class="json-key">${escapeHtml(source.slice(start, end))}</span>`
|
|
212
|
+
: `<span class="json-string">${escapeHtml(source.slice(start, end))}</span>`;
|
|
213
|
+
if (isKey) {
|
|
214
|
+
html += escapeHtml(source.slice(end, colon + 1));
|
|
215
|
+
index = colon + 1;
|
|
216
|
+
}
|
|
217
|
+
else
|
|
218
|
+
index = end;
|
|
219
|
+
continue;
|
|
220
|
+
}
|
|
221
|
+
pattern.lastIndex = index;
|
|
222
|
+
const token = pattern.exec(source);
|
|
223
|
+
if (!token) {
|
|
224
|
+
html += escapeHtml(source[index++]);
|
|
225
|
+
continue;
|
|
226
|
+
}
|
|
227
|
+
const [match, keyword, num, punct] = token;
|
|
228
|
+
if (keyword)
|
|
229
|
+
html += `<span class="json-${keyword === 'null' ? 'null' : 'bool'}">${escapeHtml(match)}</span>`;
|
|
230
|
+
else if (num)
|
|
231
|
+
html += `<span class="json-number">${escapeHtml(match)}</span>`;
|
|
232
|
+
else if (punct)
|
|
233
|
+
html += `<span class="json-punct">${escapeHtml(match)}</span>`;
|
|
234
|
+
index = pattern.lastIndex;
|
|
235
|
+
}
|
|
236
|
+
return html;
|
|
237
|
+
}
|
|
238
|
+
export { escapeHtml, renderDocComment, highlightFromColumn, highlightJson };
|
|
239
|
+
//# sourceMappingURL=presentation-highlight.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"presentation-highlight.mjs","sourceRoot":"","sources":["../src/presentation-highlight.mjs"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,SAAS,UAAU,CAAC,KAAK;IACvB,OAAO,KAAK;SACT,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;SACtB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;SACrB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAC3B,CAAC;AAED,SAAS,IAAI,CAAC,IAAI,EAAE,KAAK;IACvB,OAAO,oBAAoB,IAAI,KAAK,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;AACjE,CAAC;AAED,SAAS,OAAO,CAAC,IAAI,EAAE,IAAI;IACzB,OAAO,oBAAoB,IAAI,KAAK,IAAI,SAAS,CAAC;AACpD,CAAC;AAED,SAAS,eAAe,CAAC,KAAK;IAC5B,MAAM,KAAK,GAAG,EAAE,CAAC;IACjB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,gBAAgB,GAAG,KAAK,CAAC;IAE7B,OAAO,KA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AAC,CAAC,CAAC;YAAC,SAAS;QAAC,CAAC;QAC9D,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,KAAK,CAAC;QAC3C,IAAI,OAAO;YAAE,IAAI,IAAI,qBAAqB,OAAO,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;aACzG,IAAI,GAAG;YAAE,IAAI,IAAI,6BAA6B,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;aACzE,IAAI,KAAK;YAAE,IAAI,IAAI,4BAA4B,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC;QAC/E,KAAK,GAAG,OAAO,CAAC,SAAS,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAGD,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,aAAa,EAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Token, TokenType, tokenize } from '@altopelago/aeon-lexer';
|
|
2
|
+
import { MAX_HIGHLIGHT_SOURCE_CODE_UNITS } from './aeon-token-highlight.mjs';
|
|
3
|
+
export { MAX_HIGHLIGHT_SOURCE_CODE_UNITS };
|
|
4
|
+
export interface HighlightOptions {
|
|
5
|
+
readonly diagnosticLine?: number;
|
|
6
|
+
readonly diagnosticColumn?: number;
|
|
7
|
+
}
|
|
8
|
+
/** Supply the implementation lexer selected by the host's own module graph. */
|
|
9
|
+
export interface LexerProvider {
|
|
10
|
+
readonly TokenType: typeof TokenType;
|
|
11
|
+
readonly tokenize: (source: string, options?: Parameters<typeof tokenize>[1]) => {
|
|
12
|
+
readonly tokens: readonly Token[];
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface Highlighter {
|
|
16
|
+
highlightAeon(source: string, options?: HighlightOptions): string;
|
|
17
|
+
highlightJson(source: string): string;
|
|
18
|
+
}
|
|
19
|
+
/** Rendering only: no lexer, parser or DOM is loaded by this entry point. */
|
|
20
|
+
export declare function createHighlighter(provider: LexerProvider): Highlighter;
|
|
21
|
+
//# sourceMappingURL=renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAwB,+BAA+B,EAAC,MAAM,4BAA4B,CAAC;AAGlG,OAAO,EAAC,+BAA+B,EAAC,CAAC;AACzC,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CACtC;AACD,+EAA+E;AAC/E,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,SAAS,EAAE,OAAO,SAAS,CAAC;IACrC,QAAQ,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK;QAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAA;KAAC,CAAC;CACxH;AACD,MAAM,WAAW,WAAW;IACxB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,MAAM,CAAC;IAClE,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC;CACzC;AACD,6EAA6E;AAC7E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,aAAa,GAAG,WAAW,CAQtE"}
|
package/dist/renderer.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createAeonHighlighter, MAX_HIGHLIGHT_SOURCE_CODE_UNITS } from './aeon-token-highlight.mjs';
|
|
2
|
+
import { highlightJson as renderJson } from './presentation-highlight.mjs';
|
|
3
|
+
export { MAX_HIGHLIGHT_SOURCE_CODE_UNITS };
|
|
4
|
+
/** Rendering only: no lexer, parser or DOM is loaded by this entry point. */
|
|
5
|
+
export function createHighlighter(provider) {
|
|
6
|
+
const renderer = createAeonHighlighter(provider);
|
|
7
|
+
return {
|
|
8
|
+
highlightAeon(source, options = {}) {
|
|
9
|
+
return renderer.highlightAeon(source, options.diagnosticLine ?? null, options.diagnosticColumn ?? 1);
|
|
10
|
+
},
|
|
11
|
+
highlightJson(source) { return renderJson(source); },
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["../src/renderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,qBAAqB,EAAE,+BAA+B,EAAC,MAAM,4BAA4B,CAAC;AAClG,OAAO,EAAC,aAAa,IAAI,UAAU,EAAC,MAAM,8BAA8B,CAAC;AAEzE,OAAO,EAAC,+BAA+B,EAAC,CAAC;AAczC,6EAA6E;AAC7E,MAAM,UAAU,iBAAiB,CAAC,QAAuB;IACrD,MAAM,QAAQ,GAAG,qBAAqB,CAAC,QAAQ,CAAC,CAAC;IACjD,OAAO;QACH,aAAa,CAAC,MAAM,EAAE,OAAO,GAAG,EAAE;YAC9B,OAAO,QAAQ,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,cAAc,IAAI,IAAI,EAAE,OAAO,CAAC,gBAAgB,IAAI,CAAC,CAAC,CAAC;QACzG,CAAC;QACD,aAAa,CAAC,MAAM,IAAI,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;KACvD,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.aeon-highlight { --aeon-bg: #ffffff; --aeon-panel: #fbfbf9; --aeon-border: #d8d8d3; --aeon-fg: #1b1b1b; --aeon-muted: #5a5a5a; --aeon-key: #006f56; --aeon-type: #5d5a8d; --aeon-attribute: #7b4f68; --aeon-attribute-punct: #8a6d3b; --aeon-tag: #8b6f1f; --aeon-string: #7a5c1f; --aeon-literal: #526c20; --aeon-number: #006b80; --aeon-temporal: #806500; --aeon-symbol: #007a65; --aeon-directive: #006f56; --aeon-comment: #767676; --aeon-comment-doc: #666a78; --aeon-comment-annotation: #0b6a73; --aeon-comment-hint: #94623d; --aeon-comment-host: #6b6f78; --aeon-punct: #707070; --aeon-binding: #006f56; --aeon-identity: #8b6f1f; --aeon-sansa: var(--aeon-symbol); --aeon-operator: #1b1b1b; color: var(--aeon-fg); background: var(--aeon-bg); }
|
|
2
|
+
.aeon-highlight .tok-key { color: var(--aeon-key); }
|
|
3
|
+
.aeon-highlight .tok-type { color: var(--aeon-type); }
|
|
4
|
+
.aeon-highlight .tok-attribute { color: var(--aeon-attribute); }
|
|
5
|
+
.aeon-highlight .tok-attribute-punct { color: var(--aeon-attribute-punct); }
|
|
6
|
+
.aeon-highlight .tok-tag { color: var(--aeon-tag); }
|
|
7
|
+
.aeon-highlight .tok-string { color: var(--aeon-string); }
|
|
8
|
+
.aeon-highlight .tok-literal { color: var(--aeon-literal); }
|
|
9
|
+
.aeon-highlight .tok-number { color: var(--aeon-number); }
|
|
10
|
+
.aeon-highlight .tok-temporal { color: var(--aeon-temporal); }
|
|
11
|
+
.aeon-highlight .tok-symbol { color: var(--aeon-symbol); }
|
|
12
|
+
.aeon-highlight .tok-directive { color: var(--aeon-directive); }
|
|
13
|
+
.aeon-highlight .tok-comment { color: var(--aeon-comment); }
|
|
14
|
+
.aeon-highlight .tok-comment-doc { color: var(--aeon-comment-doc); }
|
|
15
|
+
.aeon-highlight .tok-comment-annotation { color: var(--aeon-comment-annotation); }
|
|
16
|
+
.aeon-highlight .tok-comment-hint { color: var(--aeon-comment-hint); }
|
|
17
|
+
.aeon-highlight .tok-comment-host { color: var(--aeon-comment-host); }
|
|
18
|
+
.aeon-highlight .tok-punct { color: var(--aeon-punct); }
|
|
19
|
+
.aeon-highlight .tok-binding { color: var(--aeon-binding); }
|
|
20
|
+
.aeon-highlight .tok-identity { color: var(--aeon-identity); }
|
|
21
|
+
.aeon-highlight .tok-sansa { color: var(--aeon-sansa); }
|
|
22
|
+
.aeon-highlight .tok-operator { color: var(--aeon-operator); }
|
|
23
|
+
.aeon-highlight .tok-tag-punct { color: var(--aeon-punct); }
|
|
24
|
+
.aeon-highlight .tok-comment-structure { color: var(--aeon-comment-hint); }
|
|
25
|
+
.aeon-highlight .tok-comment-profile { color: var(--aeon-comment-doc); }
|
|
26
|
+
.aeon-highlight .tok-comment-future { color: var(--aeon-comment-host); }
|
|
27
|
+
.aeon-highlight .tok-and-header { color: var(--aeon-fg); }
|
|
28
|
+
.aeon-highlight .tok-and-heading { color: var(--aeon-fg); }
|
|
29
|
+
.aeon-highlight .tok-and-version { color: var(--aeon-comment-doc); }
|
|
30
|
+
.aeon-highlight .tok-and-heading-marker { color: var(--aeon-comment-doc); }
|
|
31
|
+
.aeon-highlight .tok-and-rule { color: var(--aeon-punct); }
|
|
32
|
+
.aeon-highlight .tok-and-table-pipe { color: var(--aeon-punct); }
|
|
33
|
+
.aeon-highlight .tok-and-link-separator { color: var(--aeon-punct); }
|
|
34
|
+
.aeon-highlight .tok-and-strong { color: var(--aeon-fg); }
|
|
35
|
+
.aeon-highlight .tok-and-emphasis { color: var(--aeon-comment-doc); }
|
|
36
|
+
.aeon-highlight .tok-and-list-marker { color: var(--aeon-comment-doc); }
|
|
37
|
+
.aeon-highlight .tok-and-list-text { color: var(--aeon-comment-doc); }
|
|
38
|
+
.aeon-highlight .tok-and-quote { color: var(--aeon-comment-doc); }
|
|
39
|
+
.aeon-highlight .tok-and-quote-text { color: var(--aeon-comment-doc); }
|
|
40
|
+
.aeon-highlight .tok-and-code { color: var(--aeon-string); }
|
|
41
|
+
.aeon-highlight .tok-and-link { color: var(--aeon-binding); }
|
|
42
|
+
.aeon-highlight .tok-and-link-target { color: var(--aeon-comment-doc); }
|
|
43
|
+
.aeon-highlight .tok-and-fence { color: var(--aeon-punct); }
|
|
44
|
+
.aeon-highlight .tok-and-extension-fence { color: var(--aeon-punct); }
|
|
45
|
+
.aeon-highlight .tok-and-fence-label { color: var(--aeon-type); }
|
|
46
|
+
.aeon-highlight .tok-and-extension-name { color: var(--aeon-type); }
|
|
47
|
+
.aeon-highlight .tok-and-escape { color: var(--aeon-type); }
|
|
48
|
+
.aeon-highlight .tok-and-invalid { color: var(--aeon-comment-host); }
|
|
49
|
+
.aeon-highlight .json-key { color: var(--aeon-key); }
|
|
50
|
+
.aeon-highlight .json-string { color: var(--aeon-string); }
|
|
51
|
+
.aeon-highlight .json-number { color: var(--aeon-number); }
|
|
52
|
+
.aeon-highlight .json-bool, .aeon-highlight .json-null { color: var(--aeon-literal); }
|
|
53
|
+
.aeon-highlight .json-punct { color: var(--aeon-punct); }
|
|
54
|
+
.aeon-highlight .tok-and-strong, .aeon-highlight .tok-and-header, .aeon-highlight .tok-and-heading { font-weight: 700; }
|
|
55
|
+
.aeon-highlight .tok-and-emphasis { font-style: italic; }
|
package/dist/theme.css
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
.aeon-highlight { --aeon-bg: #202124; --aeon-panel: #172131; --aeon-border: #333333; --aeon-fg: #e5e7eb; --aeon-muted: #9aa6b2; --aeon-key: #7fb2ff; --aeon-type: #c7b8ff; --aeon-attribute: #caa0bf; --aeon-attribute-punct: #d8b070; --aeon-tag: #e2c97a; --aeon-string: #d9c58b; --aeon-literal: #c7d98a; --aeon-number: #7dd3fc; --aeon-temporal: #f5e6a8; --aeon-symbol: #50dabe; --aeon-directive: #8ec7d9; --aeon-comment: #a8adb8; --aeon-comment-doc: #9aa9c7; --aeon-comment-annotation: #7fc7d4; --aeon-comment-hint: #d9ad7c; --aeon-comment-host: #a7b2c4; --aeon-punct: #8d96a6; --aeon-binding: #7fb2ff; --aeon-identity: #e2c97a; --aeon-sansa: var(--aeon-symbol); --aeon-operator: #e5e7eb; color: var(--aeon-fg); background: var(--aeon-bg); }
|
|
2
|
+
.aeon-highlight .tok-key { color: var(--aeon-key); }
|
|
3
|
+
.aeon-highlight .tok-type { color: var(--aeon-type); }
|
|
4
|
+
.aeon-highlight .tok-attribute { color: var(--aeon-attribute); }
|
|
5
|
+
.aeon-highlight .tok-attribute-punct { color: var(--aeon-attribute-punct); }
|
|
6
|
+
.aeon-highlight .tok-tag { color: var(--aeon-tag); }
|
|
7
|
+
.aeon-highlight .tok-string { color: var(--aeon-string); }
|
|
8
|
+
.aeon-highlight .tok-literal { color: var(--aeon-literal); }
|
|
9
|
+
.aeon-highlight .tok-number { color: var(--aeon-number); }
|
|
10
|
+
.aeon-highlight .tok-temporal { color: var(--aeon-temporal); }
|
|
11
|
+
.aeon-highlight .tok-symbol { color: var(--aeon-symbol); }
|
|
12
|
+
.aeon-highlight .tok-directive { color: var(--aeon-directive); }
|
|
13
|
+
.aeon-highlight .tok-comment { color: var(--aeon-comment); }
|
|
14
|
+
.aeon-highlight .tok-comment-doc { color: var(--aeon-comment-doc); }
|
|
15
|
+
.aeon-highlight .tok-comment-annotation { color: var(--aeon-comment-annotation); }
|
|
16
|
+
.aeon-highlight .tok-comment-hint { color: var(--aeon-comment-hint); }
|
|
17
|
+
.aeon-highlight .tok-comment-host { color: var(--aeon-comment-host); }
|
|
18
|
+
.aeon-highlight .tok-punct { color: var(--aeon-punct); }
|
|
19
|
+
.aeon-highlight .tok-binding { color: var(--aeon-binding); }
|
|
20
|
+
.aeon-highlight .tok-identity { color: var(--aeon-identity); }
|
|
21
|
+
.aeon-highlight .tok-sansa { color: var(--aeon-sansa); }
|
|
22
|
+
.aeon-highlight .tok-operator { color: var(--aeon-operator); }
|
|
23
|
+
.aeon-highlight .tok-tag-punct { color: var(--aeon-punct); }
|
|
24
|
+
.aeon-highlight .tok-comment-structure { color: var(--aeon-comment-hint); }
|
|
25
|
+
.aeon-highlight .tok-comment-profile { color: var(--aeon-comment-doc); }
|
|
26
|
+
.aeon-highlight .tok-comment-future { color: var(--aeon-comment-host); }
|
|
27
|
+
.aeon-highlight .tok-and-header { color: var(--aeon-fg); }
|
|
28
|
+
.aeon-highlight .tok-and-heading { color: var(--aeon-fg); }
|
|
29
|
+
.aeon-highlight .tok-and-version { color: var(--aeon-comment-doc); }
|
|
30
|
+
.aeon-highlight .tok-and-heading-marker { color: var(--aeon-comment-doc); }
|
|
31
|
+
.aeon-highlight .tok-and-rule { color: var(--aeon-punct); }
|
|
32
|
+
.aeon-highlight .tok-and-table-pipe { color: var(--aeon-punct); }
|
|
33
|
+
.aeon-highlight .tok-and-link-separator { color: var(--aeon-punct); }
|
|
34
|
+
.aeon-highlight .tok-and-strong { color: var(--aeon-fg); }
|
|
35
|
+
.aeon-highlight .tok-and-emphasis { color: var(--aeon-comment-doc); }
|
|
36
|
+
.aeon-highlight .tok-and-list-marker { color: var(--aeon-comment-doc); }
|
|
37
|
+
.aeon-highlight .tok-and-list-text { color: var(--aeon-comment-doc); }
|
|
38
|
+
.aeon-highlight .tok-and-quote { color: var(--aeon-comment-doc); }
|
|
39
|
+
.aeon-highlight .tok-and-quote-text { color: var(--aeon-comment-doc); }
|
|
40
|
+
.aeon-highlight .tok-and-code { color: var(--aeon-string); }
|
|
41
|
+
.aeon-highlight .tok-and-link { color: var(--aeon-binding); }
|
|
42
|
+
.aeon-highlight .tok-and-link-target { color: var(--aeon-comment-doc); }
|
|
43
|
+
.aeon-highlight .tok-and-fence { color: var(--aeon-punct); }
|
|
44
|
+
.aeon-highlight .tok-and-extension-fence { color: var(--aeon-punct); }
|
|
45
|
+
.aeon-highlight .tok-and-fence-label { color: var(--aeon-type); }
|
|
46
|
+
.aeon-highlight .tok-and-extension-name { color: var(--aeon-type); }
|
|
47
|
+
.aeon-highlight .tok-and-escape { color: var(--aeon-type); }
|
|
48
|
+
.aeon-highlight .tok-and-invalid { color: var(--aeon-comment-host); }
|
|
49
|
+
.aeon-highlight .json-key { color: var(--aeon-key); }
|
|
50
|
+
.aeon-highlight .json-string { color: var(--aeon-string); }
|
|
51
|
+
.aeon-highlight .json-number { color: var(--aeon-number); }
|
|
52
|
+
.aeon-highlight .json-bool, .aeon-highlight .json-null { color: var(--aeon-literal); }
|
|
53
|
+
.aeon-highlight .json-punct { color: var(--aeon-punct); }
|
|
54
|
+
.aeon-highlight .tok-and-strong, .aeon-highlight .tok-and-header, .aeon-highlight .tok-and-heading { font-weight: 700; }
|
|
55
|
+
.aeon-highlight .tok-and-emphasis { font-style: italic; }
|
package/dist/themes.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare const darkVariables = "--aeon-bg: #202124; --aeon-panel: #172131; --aeon-border: #333333; --aeon-fg: #e5e7eb; --aeon-muted: #9aa6b2; --aeon-key: #7fb2ff; --aeon-type: #c7b8ff; --aeon-attribute: #caa0bf; --aeon-attribute-punct: #d8b070; --aeon-tag: #e2c97a; --aeon-string: #d9c58b; --aeon-literal: #c7d98a; --aeon-number: #7dd3fc; --aeon-temporal: #f5e6a8; --aeon-symbol: #50dabe; --aeon-directive: #8ec7d9; --aeon-comment: #a8adb8; --aeon-comment-doc: #9aa9c7; --aeon-comment-annotation: #7fc7d4; --aeon-comment-hint: #d9ad7c; --aeon-comment-host: #a7b2c4; --aeon-punct: #8d96a6; --aeon-binding: #7fb2ff; --aeon-identity: #e2c97a; --aeon-sansa: var(--aeon-symbol); --aeon-operator: #e5e7eb;";
|
|
2
|
+
export declare const lightVariables = "--aeon-bg: #ffffff; --aeon-panel: #fbfbf9; --aeon-border: #d8d8d3; --aeon-fg: #1b1b1b; --aeon-muted: #5a5a5a; --aeon-key: #006f56; --aeon-type: #5d5a8d; --aeon-attribute: #7b4f68; --aeon-attribute-punct: #8a6d3b; --aeon-tag: #8b6f1f; --aeon-string: #7a5c1f; --aeon-literal: #526c20; --aeon-number: #006b80; --aeon-temporal: #806500; --aeon-symbol: #007a65; --aeon-directive: #006f56; --aeon-comment: #767676; --aeon-comment-doc: #666a78; --aeon-comment-annotation: #0b6a73; --aeon-comment-hint: #94623d; --aeon-comment-host: #6b6f78; --aeon-punct: #707070; --aeon-binding: #006f56; --aeon-identity: #8b6f1f; --aeon-sansa: var(--aeon-symbol); --aeon-operator: #1b1b1b;";
|
|
3
|
+
export declare const tokenStyles = ".tok-key { color: var(--aeon-key); }\n.tok-type { color: var(--aeon-type); }\n.tok-attribute { color: var(--aeon-attribute); }\n.tok-attribute-punct { color: var(--aeon-attribute-punct); }\n.tok-tag { color: var(--aeon-tag); }\n.tok-string { color: var(--aeon-string); }\n.tok-literal { color: var(--aeon-literal); }\n.tok-number { color: var(--aeon-number); }\n.tok-temporal { color: var(--aeon-temporal); }\n.tok-symbol { color: var(--aeon-symbol); }\n.tok-directive { color: var(--aeon-directive); }\n.tok-comment { color: var(--aeon-comment); }\n.tok-comment-doc { color: var(--aeon-comment-doc); }\n.tok-comment-annotation { color: var(--aeon-comment-annotation); }\n.tok-comment-hint { color: var(--aeon-comment-hint); }\n.tok-comment-host { color: var(--aeon-comment-host); }\n.tok-punct { color: var(--aeon-punct); }\n.tok-binding { color: var(--aeon-binding); }\n.tok-identity { color: var(--aeon-identity); }\n.tok-sansa { color: var(--aeon-sansa); }\n.tok-operator { color: var(--aeon-operator); }\n.tok-tag-punct { color: var(--aeon-punct); }\n.tok-comment-structure { color: var(--aeon-comment-hint); }\n.tok-comment-profile { color: var(--aeon-comment-doc); }\n.tok-comment-future { color: var(--aeon-comment-host); }\n.tok-and-header { color: var(--aeon-fg); }\n.tok-and-heading { color: var(--aeon-fg); }\n.tok-and-version { color: var(--aeon-comment-doc); }\n.tok-and-heading-marker { color: var(--aeon-comment-doc); }\n.tok-and-rule { color: var(--aeon-punct); }\n.tok-and-table-pipe { color: var(--aeon-punct); }\n.tok-and-link-separator { color: var(--aeon-punct); }\n.tok-and-strong { color: var(--aeon-fg); }\n.tok-and-emphasis { color: var(--aeon-comment-doc); }\n.tok-and-list-marker { color: var(--aeon-comment-doc); }\n.tok-and-list-text { color: var(--aeon-comment-doc); }\n.tok-and-quote { color: var(--aeon-comment-doc); }\n.tok-and-quote-text { color: var(--aeon-comment-doc); }\n.tok-and-code { color: var(--aeon-string); }\n.tok-and-link { color: var(--aeon-binding); }\n.tok-and-link-target { color: var(--aeon-comment-doc); }\n.tok-and-fence { color: var(--aeon-punct); }\n.tok-and-extension-fence { color: var(--aeon-punct); }\n.tok-and-fence-label { color: var(--aeon-type); }\n.tok-and-extension-name { color: var(--aeon-type); }\n.tok-and-escape { color: var(--aeon-type); }\n.tok-and-invalid { color: var(--aeon-comment-host); }\n.json-key { color: var(--aeon-key); }\n.json-string { color: var(--aeon-string); }\n.json-number { color: var(--aeon-number); }\n.json-bool, .json-null { color: var(--aeon-literal); }\n.json-punct { color: var(--aeon-punct); }\n.tok-and-strong, .tok-and-header, .tok-and-heading { font-weight: 700; }\n.tok-and-emphasis { font-style: italic; }\n";
|
|
4
|
+
//# sourceMappingURL=themes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,gqBAAgqB,CAAC;AAC3rB,eAAO,MAAM,cAAc,gqBAAgqB,CAAC;AAC5rB,eAAO,MAAM,WAAW,+pFAA+pF,CAAC"}
|
package/dist/themes.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export const darkVariables = "--aeon-bg: #202124; --aeon-panel: #172131; --aeon-border: #333333; --aeon-fg: #e5e7eb; --aeon-muted: #9aa6b2; --aeon-key: #7fb2ff; --aeon-type: #c7b8ff; --aeon-attribute: #caa0bf; --aeon-attribute-punct: #d8b070; --aeon-tag: #e2c97a; --aeon-string: #d9c58b; --aeon-literal: #c7d98a; --aeon-number: #7dd3fc; --aeon-temporal: #f5e6a8; --aeon-symbol: #50dabe; --aeon-directive: #8ec7d9; --aeon-comment: #a8adb8; --aeon-comment-doc: #9aa9c7; --aeon-comment-annotation: #7fc7d4; --aeon-comment-hint: #d9ad7c; --aeon-comment-host: #a7b2c4; --aeon-punct: #8d96a6; --aeon-binding: #7fb2ff; --aeon-identity: #e2c97a; --aeon-sansa: var(--aeon-symbol); --aeon-operator: #e5e7eb;";
|
|
2
|
+
export const lightVariables = "--aeon-bg: #ffffff; --aeon-panel: #fbfbf9; --aeon-border: #d8d8d3; --aeon-fg: #1b1b1b; --aeon-muted: #5a5a5a; --aeon-key: #006f56; --aeon-type: #5d5a8d; --aeon-attribute: #7b4f68; --aeon-attribute-punct: #8a6d3b; --aeon-tag: #8b6f1f; --aeon-string: #7a5c1f; --aeon-literal: #526c20; --aeon-number: #006b80; --aeon-temporal: #806500; --aeon-symbol: #007a65; --aeon-directive: #006f56; --aeon-comment: #767676; --aeon-comment-doc: #666a78; --aeon-comment-annotation: #0b6a73; --aeon-comment-hint: #94623d; --aeon-comment-host: #6b6f78; --aeon-punct: #707070; --aeon-binding: #006f56; --aeon-identity: #8b6f1f; --aeon-sansa: var(--aeon-symbol); --aeon-operator: #1b1b1b;";
|
|
3
|
+
export const tokenStyles = ".tok-key { color: var(--aeon-key); }\n.tok-type { color: var(--aeon-type); }\n.tok-attribute { color: var(--aeon-attribute); }\n.tok-attribute-punct { color: var(--aeon-attribute-punct); }\n.tok-tag { color: var(--aeon-tag); }\n.tok-string { color: var(--aeon-string); }\n.tok-literal { color: var(--aeon-literal); }\n.tok-number { color: var(--aeon-number); }\n.tok-temporal { color: var(--aeon-temporal); }\n.tok-symbol { color: var(--aeon-symbol); }\n.tok-directive { color: var(--aeon-directive); }\n.tok-comment { color: var(--aeon-comment); }\n.tok-comment-doc { color: var(--aeon-comment-doc); }\n.tok-comment-annotation { color: var(--aeon-comment-annotation); }\n.tok-comment-hint { color: var(--aeon-comment-hint); }\n.tok-comment-host { color: var(--aeon-comment-host); }\n.tok-punct { color: var(--aeon-punct); }\n.tok-binding { color: var(--aeon-binding); }\n.tok-identity { color: var(--aeon-identity); }\n.tok-sansa { color: var(--aeon-sansa); }\n.tok-operator { color: var(--aeon-operator); }\n.tok-tag-punct { color: var(--aeon-punct); }\n.tok-comment-structure { color: var(--aeon-comment-hint); }\n.tok-comment-profile { color: var(--aeon-comment-doc); }\n.tok-comment-future { color: var(--aeon-comment-host); }\n.tok-and-header { color: var(--aeon-fg); }\n.tok-and-heading { color: var(--aeon-fg); }\n.tok-and-version { color: var(--aeon-comment-doc); }\n.tok-and-heading-marker { color: var(--aeon-comment-doc); }\n.tok-and-rule { color: var(--aeon-punct); }\n.tok-and-table-pipe { color: var(--aeon-punct); }\n.tok-and-link-separator { color: var(--aeon-punct); }\n.tok-and-strong { color: var(--aeon-fg); }\n.tok-and-emphasis { color: var(--aeon-comment-doc); }\n.tok-and-list-marker { color: var(--aeon-comment-doc); }\n.tok-and-list-text { color: var(--aeon-comment-doc); }\n.tok-and-quote { color: var(--aeon-comment-doc); }\n.tok-and-quote-text { color: var(--aeon-comment-doc); }\n.tok-and-code { color: var(--aeon-string); }\n.tok-and-link { color: var(--aeon-binding); }\n.tok-and-link-target { color: var(--aeon-comment-doc); }\n.tok-and-fence { color: var(--aeon-punct); }\n.tok-and-extension-fence { color: var(--aeon-punct); }\n.tok-and-fence-label { color: var(--aeon-type); }\n.tok-and-extension-name { color: var(--aeon-type); }\n.tok-and-escape { color: var(--aeon-type); }\n.tok-and-invalid { color: var(--aeon-comment-host); }\n.json-key { color: var(--aeon-key); }\n.json-string { color: var(--aeon-string); }\n.json-number { color: var(--aeon-number); }\n.json-bool, .json-null { color: var(--aeon-literal); }\n.json-punct { color: var(--aeon-punct); }\n.tok-and-strong, .tok-and-header, .tok-and-heading { font-weight: 700; }\n.tok-and-emphasis { font-style: italic; }\n";
|
|
4
|
+
//# sourceMappingURL=themes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"themes.js","sourceRoot":"","sources":["../src/themes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG,6pBAA6pB,CAAC;AAC3rB,MAAM,CAAC,MAAM,cAAc,GAAG,6pBAA6pB,CAAC;AAC5rB,MAAM,CAAC,MAAM,WAAW,GAAG,4pFAA4pF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,68 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@altopelago/aeon-highlight",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.17.0-rc.3",
|
|
4
|
+
"description": "Lexer-backed AEON highlighting, optional browser code block and themes.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./element": {
|
|
15
|
+
"types": "./dist/element.d.ts",
|
|
16
|
+
"import": "./dist/element.js"
|
|
17
|
+
},
|
|
18
|
+
"./theme.css": "./dist/theme.css",
|
|
19
|
+
"./theme-light.css": "./dist/theme-light.css",
|
|
20
|
+
"./renderer": {
|
|
21
|
+
"types": "./dist/renderer.d.ts",
|
|
22
|
+
"import": "./dist/renderer.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"!dist/**/*.test.d.ts",
|
|
28
|
+
"!dist/**/*.test.d.ts.map",
|
|
29
|
+
"!dist/**/*.test.js",
|
|
30
|
+
"!dist/**/*.test.js.map"
|
|
31
|
+
],
|
|
32
|
+
"sideEffects": [
|
|
33
|
+
"./dist/theme.css",
|
|
34
|
+
"./dist/theme-light.css"
|
|
35
|
+
],
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=20.0.0"
|
|
38
|
+
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "git+https://github.com/AltoPelago/aeon.git",
|
|
42
|
+
"directory": "implementations/typescript/packages/highlight"
|
|
43
|
+
},
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/AltoPelago/aeon/issues"
|
|
46
|
+
},
|
|
47
|
+
"homepage": "https://github.com/AltoPelago/aeon/tree/main/implementations/typescript/packages/highlight#readme",
|
|
48
|
+
"keywords": [
|
|
49
|
+
"aeon",
|
|
50
|
+
"aeonite",
|
|
51
|
+
"syntax-highlighting",
|
|
52
|
+
"web-components",
|
|
53
|
+
"browser",
|
|
54
|
+
"typescript"
|
|
55
|
+
],
|
|
56
|
+
"publishConfig": {
|
|
57
|
+
"access": "public"
|
|
58
|
+
},
|
|
59
|
+
"dependencies": {
|
|
60
|
+
"@altopelago/aeon-lexer": "0.17.0-rc.3"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsc -p tsconfig.json && node build-assets.mjs",
|
|
64
|
+
"test": "node --test test/*.test.mjs",
|
|
65
|
+
"clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
|
|
66
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
67
|
+
}
|
|
6
68
|
}
|