@gjsify/adwaita-web 0.14.0 → 0.15.1
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 +58 -0
- package/dist/adwaita-web.css +209 -0
- package/dist/adwaita-web.css.map +1 -1
- package/lib/types/elements/adw-menu-button.d.ts +34 -0
- package/lib/types/elements/adw-view-stack.d.ts +37 -0
- package/lib/types/elements/adw-view-switcher-bar.d.ts +27 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/source-view/adw-source-view.d.ts +75 -0
- package/lib/types/source-view/asm6502.d.ts +28 -0
- package/lib/types/source-view/hex.d.ts +27 -0
- package/lib/types/source-view/index.d.ts +4 -0
- package/lib/types/source-view/theme.d.ts +15 -0
- package/lib/types/styles.generated.d.ts +1 -1
- package/package.json +21 -11
- package/scss/_menu_button.scss +151 -0
- package/scss/_root.scss +22 -0
- package/scss/_theme.scss +3 -0
- package/scss/_variables.scss +5 -0
- package/scss/_view_stack.scss +29 -0
- package/scss/_view_switcher_bar.scss +94 -0
- package/scss/adwaita-skin.scss +4 -0
- package/src/elements/adw-menu-button.ts +247 -0
- package/src/elements/adw-view-stack.ts +174 -0
- package/src/elements/adw-view-switcher-bar.ts +168 -0
- package/src/index.ts +5 -0
- package/src/source-view/adw-source-view.ts +436 -0
- package/src/source-view/asm6502.ts +232 -0
- package/src/source-view/hex.ts +43 -0
- package/src/source-view/index.ts +28 -0
- package/src/source-view/theme.ts +224 -0
- package/src/index.js +0 -1
- package/src/styles.generated.js +0 -2976
- package/src/styles2.generated.js +0 -2976
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** A menu entry. `id` defaults to `label` on activation; `icon` is optional. */
|
|
2
|
+
export interface AdwMenuItem {
|
|
3
|
+
id?: string;
|
|
4
|
+
label: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class AdwMenuButton extends HTMLElement {
|
|
8
|
+
private _buttonEl;
|
|
9
|
+
private _popoverEl;
|
|
10
|
+
private _items;
|
|
11
|
+
private _menuTitle;
|
|
12
|
+
private _active;
|
|
13
|
+
private _initialized;
|
|
14
|
+
private _itemButtons;
|
|
15
|
+
private _onDocumentPointerDown;
|
|
16
|
+
private _onDocumentKeyDown;
|
|
17
|
+
static get observedAttributes(): string[];
|
|
18
|
+
/** Whether the popover menu is currently open. */
|
|
19
|
+
get active(): boolean;
|
|
20
|
+
/** The menu entries. Setting rebuilds the popover. */
|
|
21
|
+
get menuItems(): AdwMenuItem[];
|
|
22
|
+
set menuItems(value: AdwMenuItem[]);
|
|
23
|
+
/** The optional popover heading. */
|
|
24
|
+
get menuTitle(): string;
|
|
25
|
+
set menuTitle(value: string);
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
disconnectedCallback(): void;
|
|
28
|
+
attributeChangedCallback(name: string): void;
|
|
29
|
+
private _parseMenuAttr;
|
|
30
|
+
private _setActive;
|
|
31
|
+
private _onMenuKeyDown;
|
|
32
|
+
private _render;
|
|
33
|
+
private _renderMenu;
|
|
34
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/** A page descriptor exposed via `pages` (consumed by a bound switcher bar). */
|
|
2
|
+
export interface AdwViewStackPageInfo {
|
|
3
|
+
/** Stable id used by visibleChildName + switcher binding. */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Human-facing title shown by a bound switcher. */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Symbolic icon name (no `-symbolic` suffix), or '' for none. */
|
|
8
|
+
icon: string;
|
|
9
|
+
/** The page's content container (the visibility-toggled node). */
|
|
10
|
+
element: HTMLElement;
|
|
11
|
+
}
|
|
12
|
+
export declare class AdwViewStack extends HTMLElement {
|
|
13
|
+
private _pages;
|
|
14
|
+
private _visibleIndex;
|
|
15
|
+
private _initialized;
|
|
16
|
+
static get observedAttributes(): string[];
|
|
17
|
+
/** All pages in declaration/add order. A bound switcher reads this. */
|
|
18
|
+
get pages(): readonly AdwViewStackPageInfo[];
|
|
19
|
+
/** Zero-based index of the visible page. Out-of-range/same values no-op. */
|
|
20
|
+
get visibleChildIndex(): number;
|
|
21
|
+
set visibleChildIndex(value: number);
|
|
22
|
+
/** Name of the visible page, or '' when the stack is empty. */
|
|
23
|
+
get visibleChildName(): string;
|
|
24
|
+
set visibleChildName(name: string);
|
|
25
|
+
/** The visible page's content element, or null when empty. */
|
|
26
|
+
get visibleChild(): HTMLElement | null;
|
|
27
|
+
connectedCallback(): void;
|
|
28
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
29
|
+
/**
|
|
30
|
+
* Append a page. The FIRST page added becomes visible automatically; later
|
|
31
|
+
* pages are added hidden. Mirrors Adw.ViewStack.add()/the NS twin's add().
|
|
32
|
+
*/
|
|
33
|
+
add(content: HTMLElement, name: string, title?: string, icon?: string): AdwViewStackPageInfo;
|
|
34
|
+
/** Convenience alias mirroring Adw.ViewStack.add_titled() (no icon). */
|
|
35
|
+
addTitled(content: HTMLElement, name: string, title: string): AdwViewStackPageInfo;
|
|
36
|
+
private _apply;
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { AdwViewStack } from './adw-view-stack.js';
|
|
2
|
+
export declare class AdwViewSwitcherBar extends HTMLElement {
|
|
3
|
+
private _barEl;
|
|
4
|
+
private _buttons;
|
|
5
|
+
private _stack;
|
|
6
|
+
private _revealed;
|
|
7
|
+
private _initialized;
|
|
8
|
+
private _onStackNotify;
|
|
9
|
+
static get observedAttributes(): string[];
|
|
10
|
+
/** The bound stack element, or null when unbound. */
|
|
11
|
+
get stack(): AdwViewStack | null;
|
|
12
|
+
set stack(value: AdwViewStack | string | null);
|
|
13
|
+
/** Whether the bar is revealed (shown). Hidden when false. */
|
|
14
|
+
get revealed(): boolean;
|
|
15
|
+
set revealed(value: boolean);
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
disconnectedCallback(): void;
|
|
18
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
19
|
+
/** Bind to a stack element (or null). Unbinds the previous one and rebuilds. */
|
|
20
|
+
setStack(stack: AdwViewStack | null): void;
|
|
21
|
+
/** Rebuild the buttons — call after adding pages to the bound stack. */
|
|
22
|
+
refresh(): void;
|
|
23
|
+
private _resolveStack;
|
|
24
|
+
private _rebuild;
|
|
25
|
+
private _syncActive;
|
|
26
|
+
private _applyRevealed;
|
|
27
|
+
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -31,6 +31,11 @@ export { AdwCarousel, AdwCarouselIndicatorDots, AdwCarouselIndicatorLines } from
|
|
|
31
31
|
export { AdwTabPage, AdwTabView } from './elements/adw-tab-view.js';
|
|
32
32
|
export { AdwViewSwitcher, AdwViewSwitcherPage } from './elements/adw-view-switcher.js';
|
|
33
33
|
export { AdwInlineViewSwitcher, AdwViewStackPage } from './elements/adw-inline-view-switcher.js';
|
|
34
|
+
export { AdwViewStack } from './elements/adw-view-stack.js';
|
|
35
|
+
export type { AdwViewStackPageInfo } from './elements/adw-view-stack.js';
|
|
36
|
+
export { AdwViewSwitcherBar } from './elements/adw-view-switcher-bar.js';
|
|
37
|
+
export { AdwMenuButton } from './elements/adw-menu-button.js';
|
|
38
|
+
export type { AdwMenuItem } from './elements/adw-menu-button.js';
|
|
34
39
|
export { AdwNavigationPage, AdwNavigationView } from './elements/adw-navigation-view.js';
|
|
35
40
|
export { AdwBottomSheet, AdwBottomSheetContent, AdwBottomSheetSheet } from './elements/adw-bottom-sheet.js';
|
|
36
41
|
export { AdwSidebar, AdwSidebarItem, AdwSidebarSection } from './elements/adw-sidebar.js';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { EditorView } from '@codemirror/view';
|
|
2
|
+
export declare class AdwSourceView extends HTMLElement {
|
|
3
|
+
private _view?;
|
|
4
|
+
private _editorHost;
|
|
5
|
+
private _copyButton;
|
|
6
|
+
private _initialized;
|
|
7
|
+
private _suppressChangeEvent;
|
|
8
|
+
private _code;
|
|
9
|
+
private _editable;
|
|
10
|
+
private _selectable;
|
|
11
|
+
private _lineNumbers;
|
|
12
|
+
private _lineNumberStart;
|
|
13
|
+
private _hexAddresses;
|
|
14
|
+
private _language;
|
|
15
|
+
private _copyable;
|
|
16
|
+
private _copyButtonIcon;
|
|
17
|
+
private _copyButtonTooltip;
|
|
18
|
+
private readonly _editableComp;
|
|
19
|
+
private readonly _lineNumbersComp;
|
|
20
|
+
private readonly _selectableComp;
|
|
21
|
+
private readonly _languageComp;
|
|
22
|
+
private readonly _copyComp;
|
|
23
|
+
static get observedAttributes(): string[];
|
|
24
|
+
/** The document text. Programmatic assignment does NOT emit `code-changed`. */
|
|
25
|
+
get code(): string;
|
|
26
|
+
set code(value: string);
|
|
27
|
+
/** Whether the user can edit the buffer (drives readOnly + active-line). */
|
|
28
|
+
get editable(): boolean;
|
|
29
|
+
set editable(value: boolean);
|
|
30
|
+
/** Inverse of `editable` — mirrors the native widget's readonly prop. */
|
|
31
|
+
get readonly(): boolean;
|
|
32
|
+
set readonly(value: boolean);
|
|
33
|
+
/** Whether the content is selectable by the user. */
|
|
34
|
+
get selectable(): boolean;
|
|
35
|
+
set selectable(value: boolean);
|
|
36
|
+
/** Whether the gutter is shown. */
|
|
37
|
+
get lineNumbers(): boolean;
|
|
38
|
+
set lineNumbers(value: boolean);
|
|
39
|
+
/** First gutter value: decimal offset, or the base ADDRESS in hex mode. */
|
|
40
|
+
get lineNumberStart(): number | undefined;
|
|
41
|
+
set lineNumberStart(value: number | undefined);
|
|
42
|
+
/** Render the gutter as 4-digit hex addresses (monitor / hexdump panes). */
|
|
43
|
+
get hexAddresses(): boolean;
|
|
44
|
+
set hexAddresses(value: boolean);
|
|
45
|
+
/** `6502` / `6502-assembler` enables highlighting; anything else = plain. */
|
|
46
|
+
get language(): string;
|
|
47
|
+
set language(value: string);
|
|
48
|
+
/** Whether the floating copy button is shown. */
|
|
49
|
+
get copyable(): boolean;
|
|
50
|
+
set copyable(value: boolean);
|
|
51
|
+
/** Icon name for the copy button (`edit-copy`/`copy` render an inline SVG). */
|
|
52
|
+
get copyButtonIcon(): string;
|
|
53
|
+
set copyButtonIcon(value: string);
|
|
54
|
+
/** Accessible label / tooltip for the copy button. */
|
|
55
|
+
get copyButtonTooltip(): string;
|
|
56
|
+
set copyButtonTooltip(value: string);
|
|
57
|
+
/** Whether the editor fills its host's height (vs. auto-sizing to content). */
|
|
58
|
+
get fillHeight(): boolean;
|
|
59
|
+
set fillHeight(value: boolean);
|
|
60
|
+
/** The live CodeMirror EditorView (null until connected). Escape hatch. */
|
|
61
|
+
get view(): EditorView | null;
|
|
62
|
+
connectedCallback(): void;
|
|
63
|
+
disconnectedCallback(): void;
|
|
64
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
65
|
+
private _baseExtensions;
|
|
66
|
+
private _editableExtension;
|
|
67
|
+
private _lineNumbersExtension;
|
|
68
|
+
private _selectableExtension;
|
|
69
|
+
private _languageExtension;
|
|
70
|
+
private _copyExtension;
|
|
71
|
+
private _reconfigure;
|
|
72
|
+
private _onCopyButtonClick;
|
|
73
|
+
private _renderCopyIcon;
|
|
74
|
+
private _readDeclarativeAttributes;
|
|
75
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type StreamParser, type StringStream } from '@codemirror/language';
|
|
2
|
+
import { type Extension } from '@codemirror/state';
|
|
3
|
+
import { type Tag } from '@lezer/highlight';
|
|
4
|
+
/** The 56 official NMOS 6502 mnemonics (uppercased for case-insensitive match). */
|
|
5
|
+
export declare const OPCODES: ReadonlySet<string>;
|
|
6
|
+
/** The registers that appear as bare operands (`ASL A`, `LDA $00,X`). */
|
|
7
|
+
export declare const REGISTERS: ReadonlySet<string>;
|
|
8
|
+
/** Assembler pseudo-ops. `define`/`dcb` are the easy6502 dialect; the rest are
|
|
9
|
+
* common cross-assembler directives (with the leading dot handled separately). */
|
|
10
|
+
export declare const DIRECTIVE_WORDS: ReadonlySet<string>;
|
|
11
|
+
/**
|
|
12
|
+
* Classify an identifier-shaped token. Pure + side-effect-free so it is unit
|
|
13
|
+
* testable without a CodeMirror stream. `atLineStart` decides whether an
|
|
14
|
+
* unknown word is a label DEFINITION (column 0) or a symbol REFERENCE.
|
|
15
|
+
*/
|
|
16
|
+
export declare function classifyWord(word: string, atLineStart: boolean): string;
|
|
17
|
+
/**
|
|
18
|
+
* Tokenize one token from the stream. Exported for unit tests (feed it a
|
|
19
|
+
* `StringStream`). Returns a token-class name (see file header) or `null` for
|
|
20
|
+
* whitespace/unclassified punctuation.
|
|
21
|
+
*/
|
|
22
|
+
export declare function token6502(stream: StringStream): string | null;
|
|
23
|
+
/** Maps this mode's token-class names to @lezer/highlight tags. */
|
|
24
|
+
export declare const asm6502TokenTable: Record<string, Tag>;
|
|
25
|
+
/** The StreamParser powering the 6502 mode. */
|
|
26
|
+
export declare const asm6502Parser: StreamParser<unknown>;
|
|
27
|
+
/** The 6502 assembly language extension for a CodeMirror EditorState. */
|
|
28
|
+
export declare function asm6502(): Extension;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Bytes represented per visual line in the hex monitor / hexdump gutter. */
|
|
2
|
+
export declare const HEX_ADDRESS_STRIDE = 16;
|
|
3
|
+
/**
|
|
4
|
+
* Format a 1-based CodeMirror line number as a 4-digit uppercase hex address,
|
|
5
|
+
* the way the native GtkSourceView hex gutter renders monitor/hexdump rows:
|
|
6
|
+
* each row advances the address by `stride` bytes from `start`.
|
|
7
|
+
*
|
|
8
|
+
* @param lineNo 1-based line number (CodeMirror's `formatNumber` contract).
|
|
9
|
+
* @param start base address of the first row (e.g. 0x0600 for a 6502 program).
|
|
10
|
+
* @param stride bytes per row (default 16 — one hexdump row).
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatHexAddress(lineNo: number, start: number, stride?: number): string;
|
|
13
|
+
/**
|
|
14
|
+
* Format a 1-based CodeMirror line number for the normal (decimal) gutter,
|
|
15
|
+
* offset by `start` so a pane can begin numbering at an arbitrary value —
|
|
16
|
+
* the web twin of the native renderer's `line + startValue`.
|
|
17
|
+
*
|
|
18
|
+
* @param lineNo 1-based line number.
|
|
19
|
+
* @param start value shown on the first line (default 1 → identity).
|
|
20
|
+
*/
|
|
21
|
+
export declare function formatLineNumber(lineNo: number, start?: number): string;
|
|
22
|
+
/**
|
|
23
|
+
* Strip every whitespace character from `text` — the copy-without-spaces
|
|
24
|
+
* transform the native hex monitor applies so a copied address/byte run pastes
|
|
25
|
+
* as a compact hex string. Mirrors `text.replace(/\s/g, '')` in the GTK widget.
|
|
26
|
+
*/
|
|
27
|
+
export declare function stripWhitespace(text: string): string;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AdwSourceView } from './adw-source-view.js';
|
|
2
|
+
export { asm6502, asm6502Parser, asm6502TokenTable, classifyWord, token6502, OPCODES, REGISTERS, DIRECTIVE_WORDS, } from './asm6502.js';
|
|
3
|
+
export { adwaitaEditorTheme, adwaitaHighlightStyle, ensureSourceViewStyleInjected, SOURCE_VIEW_CSS, SOURCE_VIEW_STYLE_ID, } from './theme.js';
|
|
4
|
+
export { formatHexAddress, formatLineNumber, stripWhitespace, HEX_ADDRESS_STRIDE } from './hex.js';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { HighlightStyle } from '@codemirror/language';
|
|
2
|
+
/** The CodeMirror EditorView theme mapping `.cm-*` chrome to Adwaita tokens. */
|
|
3
|
+
export declare const adwaitaEditorTheme: import("@codemirror/state").Extension;
|
|
4
|
+
/** Syntax highlighting mapping tags → the `--adw-src-*` palette variables. */
|
|
5
|
+
export declare const adwaitaHighlightStyle: HighlightStyle;
|
|
6
|
+
/** Element id of the injected stylesheet (idempotency guard). */
|
|
7
|
+
export declare const SOURCE_VIEW_STYLE_ID = "adw-source-view-style";
|
|
8
|
+
/** The chrome stylesheet: container, copy button, LTR pin, syntax palette. */
|
|
9
|
+
export declare const SOURCE_VIEW_CSS = "\n.adw-source-view {\n --adw-src-comment: #5e5c64;\n --adw-src-keyword: #1c71d8;\n --adw-src-number: #c64600;\n --adw-src-string: #26a269;\n --adw-src-label: #813d9c;\n --adw-src-register: #007e8a;\n --adw-src-directive: #a51d2d;\n --adw-src-operator: rgba(0, 0, 6, 0.55);\n --adw-src-selection: color-mix(in srgb, var(--accent-bg-color, #3584e4) 26%, transparent);\n --adw-src-gutter-bg: var(--view-bg-color, #ffffff);\n --adw-src-gutter-fg: rgba(0, 0, 6, 0.35);\n --adw-src-active-line: color-mix(in srgb, var(--view-fg-color, #00000a) 4%, transparent);\n\n /* Source code is inherently LTR \u2014 pin the whole widget so the gutter,\n scrollbar and copy button never mirror under an RTL page. */\n direction: ltr;\n position: relative;\n display: block;\n box-sizing: border-box;\n overflow: hidden;\n border-radius: var(--card-radius, 12px);\n background-color: var(--view-bg-color, #ffffff);\n color: var(--view-fg-color, rgba(0, 0, 6, 0.8));\n}\n\n.adw-source-view .cm-editor {\n border-radius: inherit;\n max-height: 100%;\n}\n\n.adw-source-view.adw-source-view--fill,\n.adw-source-view.adw-source-view--fill .cm-editor {\n height: 100%;\n}\n\n.adw-source-view .cm-editor.cm-focused {\n outline: none;\n}\n\n.adw-source-view__copy {\n position: absolute;\n top: 6px;\n right: 6px;\n z-index: 2;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n width: 30px;\n height: 30px;\n padding: 0;\n border: none;\n border-radius: var(--button-radius, 9px);\n background-color: color-mix(in srgb, var(--view-bg-color, #ffffff) 82%, transparent);\n color: var(--view-fg-color, rgba(0, 0, 6, 0.75));\n opacity: 0.72;\n cursor: pointer;\n transition: opacity 0.15s ease, background-color 0.15s ease;\n -webkit-backdrop-filter: blur(6px);\n backdrop-filter: blur(6px);\n}\n\n.adw-source-view__copy:hover {\n opacity: 1;\n background-color: var(--button-hover-color, rgba(0, 0, 6, 0.13));\n}\n\n.adw-source-view__copy:active {\n background-color: var(--button-active-color, rgba(0, 0, 6, 0.19));\n}\n\n.adw-source-view__copy:focus-visible {\n opacity: 1;\n outline: 2px solid var(--accent-color, #1c71d8);\n outline-offset: 1px;\n}\n\n.adw-source-view__copy[hidden] {\n display: none;\n}\n\n.adw-source-view__copy svg {\n width: 16px;\n height: 16px;\n display: block;\n}\n\n.adw-source-view__copy .adw-icon {\n width: 16px;\n height: 16px;\n background-color: currentColor;\n -webkit-mask-repeat: no-repeat;\n mask-repeat: no-repeat;\n -webkit-mask-position: center;\n mask-position: center;\n}\n\n@media (prefers-color-scheme: dark) {\n :root:not(.theme-light) .adw-source-view {\n --adw-src-comment: #9a9996;\n --adw-src-keyword: #78aeed;\n --adw-src-number: #ffa348;\n --adw-src-string: #8ff0a4;\n --adw-src-label: #dc8add;\n --adw-src-register: #33d1c9;\n --adw-src-directive: #f66151;\n --adw-src-operator: rgba(255, 255, 255, 0.55);\n --adw-src-gutter-fg: rgba(255, 255, 255, 0.35);\n --adw-src-active-line: color-mix(in srgb, #ffffff 6%, transparent);\n }\n}\n\n:root.theme-dark .adw-source-view {\n --adw-src-comment: #9a9996;\n --adw-src-keyword: #78aeed;\n --adw-src-number: #ffa348;\n --adw-src-string: #8ff0a4;\n --adw-src-label: #dc8add;\n --adw-src-register: #33d1c9;\n --adw-src-directive: #f66151;\n --adw-src-operator: rgba(255, 255, 255, 0.55);\n --adw-src-gutter-fg: rgba(255, 255, 255, 0.35);\n --adw-src-active-line: color-mix(in srgb, #ffffff 6%, transparent);\n}\n";
|
|
10
|
+
/**
|
|
11
|
+
* Inject the chrome stylesheet once (browser-only, idempotent). Matches the
|
|
12
|
+
* self-injection pattern of `@gjsify/adwaita-web`'s main entry, so importing
|
|
13
|
+
* the source-view subpath is enough to style it under any bundler.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ensureSourceViewStyleInjected(): void;
|