@gjsify/adwaita-core 0.51.1 → 0.52.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.
Files changed (48) hide show
  1. package/lib/esm/box.js +1 -0
  2. package/lib/esm/conformance/box.js +1 -0
  3. package/lib/esm/conformance/dialog.js +1 -1
  4. package/lib/esm/conformance/index.js +1 -1
  5. package/lib/esm/conformance/label.js +1 -0
  6. package/lib/esm/conformance/rows.js +1 -1
  7. package/lib/esm/conformance/shared-trees.js +1 -1
  8. package/lib/esm/conformance/tags.js +1 -0
  9. package/lib/esm/conformance/value-lists.js +1 -0
  10. package/lib/esm/dialog.js +1 -1
  11. package/lib/esm/gio-menu.js +1 -0
  12. package/lib/esm/gtk-adjustment.js +1 -0
  13. package/lib/esm/gtk-string-list.js +1 -0
  14. package/lib/esm/index.js +1 -1
  15. package/lib/esm/label.js +1 -0
  16. package/lib/esm/markup.js +4 -0
  17. package/lib/esm/rows.js +1 -1
  18. package/lib/esm/source.js +1 -0
  19. package/lib/esm/tags.js +1 -0
  20. package/lib/esm/tokens.generated.js +1 -1
  21. package/lib/types/box.d.ts +18 -0
  22. package/lib/types/box.spec.d.ts +2 -0
  23. package/lib/types/conformance/box.d.ts +21 -0
  24. package/lib/types/conformance/dialog.d.ts +123 -1
  25. package/lib/types/conformance/index.d.ts +14 -6
  26. package/lib/types/conformance/label.d.ts +115 -0
  27. package/lib/types/conformance/rows.d.ts +29 -0
  28. package/lib/types/conformance/shared-trees.d.ts +155 -5
  29. package/lib/types/conformance/tags.d.ts +46 -0
  30. package/lib/types/conformance/value-lists.d.ts +19 -0
  31. package/lib/types/dialog.d.ts +163 -0
  32. package/lib/types/gio-menu.d.ts +46 -0
  33. package/lib/types/gtk-adjustment.d.ts +73 -0
  34. package/lib/types/gtk-adjustment.spec.d.ts +2 -0
  35. package/lib/types/gtk-string-list.d.ts +70 -0
  36. package/lib/types/gtk-string-list.spec.d.ts +2 -0
  37. package/lib/types/index.d.ts +14 -3
  38. package/lib/types/label.d.ts +135 -0
  39. package/lib/types/label.spec.d.ts +2 -0
  40. package/lib/types/markup.d.ts +14 -0
  41. package/lib/types/markup.spec.d.ts +2 -0
  42. package/lib/types/rows.d.ts +20 -0
  43. package/lib/types/source.d.ts +94 -0
  44. package/lib/types/source.spec.d.ts +2 -0
  45. package/lib/types/tags.d.ts +48 -0
  46. package/lib/types/tags.spec.d.ts +2 -0
  47. package/lib/types/tokens.generated.d.ts +1 -1
  48. package/package.json +12 -4
@@ -0,0 +1,94 @@
1
+ /**
2
+ * The read/advance surface a stream tokenizer needs from its host editor — the
3
+ * exact eight members {@link tokenizeAsm6502} touches, with CodeMirror's
4
+ * `StringStream` signatures, so passing one satisfies this structurally.
5
+ *
6
+ * `next()` returns `string | void` rather than `string | undefined` because
7
+ * that is what `StringStream` declares, and `void` is not assignable to
8
+ * `undefined`: narrowing here would reject the very class this exists to accept.
9
+ */
10
+ export interface AdwSourceTokenStream {
11
+ /** The text consumed since the current token started. */
12
+ current(): string;
13
+ /** Consume the whitespace run ahead of the cursor; true if any was there. */
14
+ eatSpace(): boolean;
15
+ /** Consume while characters match; true if any were consumed. */
16
+ eatWhile(match: string | RegExp | ((ch: string) => boolean)): boolean;
17
+ /** True at the end of the line. */
18
+ eol(): boolean;
19
+ /** Read one character and advance. */
20
+ next(): string | void;
21
+ /** The character at the cursor, without advancing. */
22
+ peek(): string | undefined;
23
+ /** Jump to the end of the line. */
24
+ skipToEnd(): void;
25
+ /** True at the start of the line — what makes a bare word a label. */
26
+ sol(): boolean;
27
+ }
28
+ /** The token classes {@link tokenizeAsm6502} can emit. */
29
+ export type AdwSourceTokenClass = 'comment' | 'directive' | 'identifier' | 'label' | 'number' | 'opcode' | 'operator' | 'register' | 'string';
30
+ /** The 56 official NMOS 6502 mnemonics (uppercased for case-insensitive match). */
31
+ export declare const ADW_SOURCE_6502_OPCODES: ReadonlySet<string>;
32
+ /** The registers that appear as bare operands (`ASL A`, `LDA $00,X`). */
33
+ export declare const ADW_SOURCE_6502_REGISTERS: ReadonlySet<string>;
34
+ /** Assembler pseudo-ops. `define`/`dcb` are the easy6502 dialect; the rest are
35
+ * common cross-assembler directives (with the leading dot handled separately). */
36
+ export declare const ADW_SOURCE_6502_DIRECTIVES: ReadonlySet<string>;
37
+ /** The comment introducer 6502 assembly uses, for an editor's comment command. */
38
+ export declare const ADW_SOURCE_6502_LINE_COMMENT = ";";
39
+ /**
40
+ * Classify an identifier-shaped token. Pure + side-effect-free so it is unit
41
+ * testable without a stream at all. `atLineStart` decides whether an unknown
42
+ * word is a label DEFINITION (column 0) or a symbol REFERENCE.
43
+ */
44
+ export declare function classifyAsm6502Word(word: string, atLineStart: boolean): AdwSourceTokenClass;
45
+ /**
46
+ * Tokenize one token from `stream`. Returns a token class or `null` for
47
+ * whitespace and unclassified punctuation, which is the contract a CodeMirror
48
+ * `StreamParser.token` wants — and, being typed on
49
+ * {@link AdwSourceTokenStream}, the contract any other editor can meet too.
50
+ */
51
+ export declare function tokenizeAsm6502(stream: AdwSourceTokenStream): AdwSourceTokenClass | null;
52
+ /**
53
+ * The colourable roles a token class maps onto. Fewer than the token classes,
54
+ * because a language names tokens after its own grammar (`opcode`) while a
55
+ * colour scheme names them after what a reader sees (`keyword`) — and the
56
+ * second set is what a scheme, a stylesheet or another language shares.
57
+ */
58
+ export type AdwSourceSyntaxRole = 'comment' | 'directive' | 'keyword' | 'label' | 'number' | 'operator' | 'register' | 'string';
59
+ /** The roles in the order a generated stylesheet emits them. */
60
+ export declare const ADW_SOURCE_SYNTAX_ROLES: readonly AdwSourceSyntaxRole[];
61
+ /** One colour per {@link AdwSourceSyntaxRole}, as a CSS-parsable colour. */
62
+ export type AdwSourcePalette = Readonly<Record<AdwSourceSyntaxRole, string>>;
63
+ /**
64
+ * Which role paints a token class. `identifier` maps to `null`: a plain symbol
65
+ * reference is deliberately UNCOLOURED, taking the view's foreground, exactly
66
+ * as the native GtkSourceView scheme leaves it.
67
+ */
68
+ export declare const ADW_SOURCE_6502_TOKEN_ROLES: Readonly<Record<AdwSourceTokenClass, AdwSourceSyntaxRole | null>>;
69
+ /** Light-scheme syntax colours (Adwaita named palette). */
70
+ export declare const ADW_SOURCE_PALETTE_LIGHT: AdwSourcePalette;
71
+ /** Dark-scheme syntax colours (Adwaita named palette). */
72
+ export declare const ADW_SOURCE_PALETTE_DARK: AdwSourcePalette;
73
+ /** Bytes represented per visual line in the hex monitor / hexdump gutter. */
74
+ export declare const ADW_SOURCE_HEX_STRIDE = 16;
75
+ /**
76
+ * Format a 1-based line number as a 4-digit uppercase hex address, the way the
77
+ * native GtkSourceView hex gutter renders monitor/hexdump rows: each row advances
78
+ * the address by `stride` bytes from `start` (the base address of the first row,
79
+ * e.g. 0x0600 for a 6502 program). `lineNo` is 1-based, per CodeMirror's
80
+ * `formatNumber` contract.
81
+ */
82
+ export declare function formatHexAddress(lineNo: number, start: number, stride?: number): string;
83
+ /**
84
+ * Format a 1-based line number for the normal (decimal) gutter, offset so
85
+ * `start` is the value shown on the first line — the web twin of the native
86
+ * renderer's `line + startValue`.
87
+ */
88
+ export declare function formatLineNumber(lineNo: number, start?: number): string;
89
+ /**
90
+ * Strip every whitespace character from `text` — the copy-without-spaces
91
+ * transform the native hex monitor applies so a copied address/byte run pastes
92
+ * as a compact hex string. Mirrors `text.replace(/\s/g, '')` in the GTK widget.
93
+ */
94
+ export declare function stripSourceWhitespace(text: string): string;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -0,0 +1,48 @@
1
+ /**
2
+ * `AdwPreferencesGroup` -> `adw-preferences-group`.
3
+ *
4
+ * THE RULE: the last capital of an acronym run opens the next word, which is why `GLArea`
5
+ * is `gl-area` and not `g-l-area`. The first version of this function was a naive
6
+ * `([a-z0-9])([A-Z])` split, and `GtkGLArea` caught it — it produced `gtk-glarea` where
7
+ * `gtk-host` stamps `gtk-gl-area`, which is why arm 11 of `check-generated-website-data.mjs`
8
+ * holds the `scripts/` restatement against every row of the generated table rather than
9
+ * against a handful of tags a corpus happens to use today.
10
+ *
11
+ * NOT AN INVERSE OF ANYTHING. Tag -> GType is lossy in exactly that case — `gtk-gl-area`
12
+ * reads back as `GtkGlArea` and no case rule can know better — so a reverse lookup has to be
13
+ * a table read backwards, never a second rule.
14
+ */
15
+ export declare const hostTagOf: (gtype: string) => string;
16
+ /**
17
+ * `buttonLabel` -> `button-label`.
18
+ *
19
+ * NOT AN ALIAS TABLE and not a second transform beside {@link hostTagOf}: a case rule over
20
+ * the authored property NAME, with no entry to give a name it does not recognise. A markup
21
+ * renderer's tree builder turns an authored prop into a DOM attribute with this rule, and
22
+ * arm 13 of `check-generated-website-data.mjs` reads a gallery fence's attributes back
23
+ * through the `scripts/` restatement of it, so the two stay one spelling rather than two.
24
+ */
25
+ export declare const attributeOf: (prop: string) => string;
26
+ /**
27
+ * `maximum-size` -> `maximumSize`: a GObject property name as the JavaScript member a
28
+ * NativeScript widget declares for it.
29
+ *
30
+ * A `.blp` projects its properties under their GIR spelling, because that is what GtkBuilder
31
+ * and the `<adw-*>` attributes read. The NativeScript port names the same property in camel
32
+ * case (`Adw.Clamp:maximum-size` is `AdwClamp.maximumSize`), so a builder handed a projected
33
+ * tree needs this rule to find the member, and without it every hyphenated property of a real
34
+ * `.blp` is refused as reaching nothing. GObject treats `_` and `-` in a property name as one
35
+ * separator, so both close a word here. Idempotent on a camel-case name, which is how the
36
+ * gallery's hand-authored trees already spell theirs.
37
+ */
38
+ export declare const propertyOf: (name: string) => string;
39
+ /**
40
+ * `GtkWidget`'s four margins, as the CSS property each one is — `start`/`end` the LOGICAL
41
+ * edges `gtk_widget_set_margin_start` documents, `top`/`bottom` physical as in GTK.
42
+ *
43
+ * A markup renderer writes them as inline style, because an attribute cannot carry a length
44
+ * into a stylesheet portably (`attr()` with a type is not in every engine). ONE table for the
45
+ * two places that do it: `buildSharedTree` in `@gjsify/adwaita-web`, and `sharedTreeHtml` in
46
+ * `./markup.ts`, whose markup has to parse back to exactly what that builder made.
47
+ */
48
+ export declare const GTK_WIDGET_MARGIN_CSS: Readonly<Record<string, string>>;
@@ -0,0 +1,2 @@
1
+ declare const _default: () => Promise<void>;
2
+ export default _default;
@@ -31,4 +31,4 @@ export declare const ADWAITA_DARK_ONLY_TOKENS: readonly string[];
31
31
  */
32
32
  export declare const ADWAITA_UNRESOLVED_TOKENS: readonly string[];
33
33
  /** How many tokens the light contract carries — derived, never typed. */
34
- export declare const ADWAITA_TOKEN_COUNT = 68;
34
+ export declare const ADWAITA_TOKEN_COUNT = 69;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/adwaita-core",
3
- "version": "0.51.1",
3
+ "version": "0.52.0",
4
4
  "description": "Headless Adwaita widget behavior (breakpoint condition grammar + apply/unapply state machine, color-scheme observable, avatar derivation) shared by the web and NativeScript Adwaita renderers — pure TS, no platform imports",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -17,6 +17,14 @@
17
17
  "./tokens": {
18
18
  "types": "./lib/types/tokens.d.ts",
19
19
  "default": "./lib/esm/tokens.js"
20
+ },
21
+ "./tags": {
22
+ "types": "./lib/types/tags.d.ts",
23
+ "default": "./lib/esm/tags.js"
24
+ },
25
+ "./markup": {
26
+ "types": "./lib/types/markup.d.ts",
27
+ "default": "./lib/esm/markup.js"
20
28
  }
21
29
  },
22
30
  "files": [
@@ -36,7 +44,7 @@
36
44
  "test:gjs": "gjsify run test.gjs.mjs",
37
45
  "test:node": "node test.node.mjs",
38
46
  "test:bun": "bun test.node.mjs",
39
- "test:deno": "deno run -A --no-lock --node-modules-dir=none test.node.mjs",
47
+ "test:deno": "deno run -A --no-lock --node-modules-dir=none --min-dep-age=0 test.node.mjs",
40
48
  "test:cross-runtime": "gjsify run build:test:node && gjsify run test:node && gjsify run test:bun && gjsify run test:deno"
41
49
  },
42
50
  "keywords": [
@@ -50,8 +58,8 @@
50
58
  "headless"
51
59
  ],
52
60
  "devDependencies": {
53
- "@gjsify/cli": "^0.51.1",
54
- "@gjsify/unit": "^0.51.1",
61
+ "@gjsify/cli": "^0.52.0",
62
+ "@gjsify/unit": "^0.52.0",
55
63
  "@types/node": "^25.9.2",
56
64
  "typescript": "^6.0.3"
57
65
  },