@venizia/vulcan-okf 0.4.4 → 0.4.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@venizia/vulcan-okf",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "description": "VULCAN knowledge tooling: OKF v0.2 conformance check (plus --strict house rules), gen, coverage and the offline graph explorer for a project's .agents/knowledge bundle. Bun-only.",
5
5
  "homepage": "https://github.com/VENIZIA-AI/vulcan/tree/main/packages/okf",
6
6
  "bugs": {
@@ -1,3 +1,5 @@
1
+ import { TableCells } from '../common/index.ts';
2
+ import type { TTableCell } from '../common/index.ts';
1
3
  import { escapeHtml } from './html.ts';
2
4
 
3
5
  const TABLE_ROW = /^\s*\|.*\|\s*$/;
@@ -35,7 +37,7 @@ const splitCells = (opts: { line: string }): string[] =>
35
37
  .split('|')
36
38
  .map((cell) => cell.trim());
37
39
 
38
- const renderRow = (opts: { line: string; cellTag: 'th' | 'td' }): string =>
40
+ const renderRow = (opts: { line: string; cellTag: TTableCell }): string =>
39
41
  `<tr>${splitCells({ line: opts.line })
40
42
  .map((cell) => `<${opts.cellTag}>${renderInline({ text: cell })}</${opts.cellTag}>`)
41
43
  .join('')}</tr>`;
@@ -99,12 +101,12 @@ export const renderMarkdown = (opts: { source: string }): string => {
99
101
 
100
102
  if (isTableRow({ line }) && next !== undefined && isTableSeparator({ line: next })) {
101
103
  flushBlocks();
102
- let table = `<table><thead>${renderRow({ line, cellTag: 'th' })}</thead><tbody>`;
104
+ let table = `<table><thead>${renderRow({ line, cellTag: TableCells.HEADER })}</thead><tbody>`;
103
105
 
104
106
  index += 2;
105
107
 
106
108
  while (index < lines.length && isTableRow({ line: lines[index] })) {
107
- table += renderRow({ line: lines[index], cellTag: 'td' });
109
+ table += renderRow({ line: lines[index], cellTag: TableCells.DATA });
108
110
  index++;
109
111
  }
110
112
 
@@ -1,9 +1,11 @@
1
+ import { ThemeModes } from '../common/index.ts';
2
+ import type { TThemeMode } from '../common/index.ts';
1
3
  import { readParentDocument } from './frame.ts';
2
4
 
3
5
  type TPalette = Record<string, string>;
4
6
 
5
- const FALLBACK_PALETTES: Record<'light' | 'dark', TPalette> = {
6
- light: {
7
+ const FALLBACK_PALETTES: Record<TThemeMode, TPalette> = {
8
+ [ThemeModes.LIGHT]: {
7
9
  bg: '#ffffff',
8
10
  'bg-soft': '#f7f7f9',
9
11
  'bg-alt': '#eeeef1',
@@ -12,7 +14,7 @@ const FALLBACK_PALETTES: Record<'light' | 'dark', TPalette> = {
12
14
  border: '#e3e3e8',
13
15
  brand: '#3b5bdb',
14
16
  },
15
- dark: {
17
+ [ThemeModes.DARK]: {
16
18
  bg: '#16161a',
17
19
  'bg-soft': '#1c1c21',
18
20
  'bg-alt': '#121215',
@@ -54,7 +56,7 @@ export class VizTheme {
54
56
  }
55
57
  }
56
58
 
57
- root.style.setProperty('color-scheme', this.dark ? 'dark' : 'light');
59
+ root.style.setProperty('color-scheme', this.dark ? ThemeModes.DARK : ThemeModes.LIGHT);
58
60
  }
59
61
 
60
62
  static watch(opts: { onChange: () => void }): void {
@@ -78,7 +80,7 @@ export class VizTheme {
78
80
  private static readSystemPalette(): TPalette {
79
81
  this.dark = matchMedia(DARK_QUERY).matches;
80
82
 
81
- return FALLBACK_PALETTES[this.dark ? 'dark' : 'light'];
83
+ return FALLBACK_PALETTES[this.dark ? ThemeModes.DARK : ThemeModes.LIGHT];
82
84
  }
83
85
 
84
86
  private static readWikiPalette(): TPalette | undefined {
@@ -24,6 +24,30 @@ export class VizConstants {
24
24
  static readonly SEARCH_RESULT_LIMIT = 40;
25
25
  }
26
26
 
27
+ /** The color scheme the explorer follows: the wiki's, or the system's. */
28
+ export class ThemeModes {
29
+ static readonly LIGHT = 'light';
30
+ static readonly DARK = 'dark';
31
+
32
+ static readonly SCHEME_SET = new Set<string>([this.LIGHT, this.DARK]);
33
+
34
+ static isValid(value: string): boolean {
35
+ return this.SCHEME_SET.has(value);
36
+ }
37
+ }
38
+
39
+ /** The cell tags of a markdown table: a header cell and a data cell. */
40
+ export class TableCells {
41
+ static readonly HEADER = 'th';
42
+ static readonly DATA = 'td';
43
+
44
+ static readonly SCHEME_SET = new Set<string>([this.HEADER, this.DATA]);
45
+
46
+ static isValid(value: string): boolean {
47
+ return this.SCHEME_SET.has(value);
48
+ }
49
+ }
50
+
27
51
  /** The placeholders `template.html` carries; the builder fills them, the client never sees them. */
28
52
  export class VizTemplateTokens {
29
53
  static readonly DATA = '__OKF_DATA__';
@@ -1,8 +1,10 @@
1
1
  import type { TConstValue } from '../../common/index.ts';
2
- import type { Locales, VizViews } from './constants.ts';
2
+ import type { Locales, TableCells, ThemeModes, VizViews } from './constants.ts';
3
3
 
4
4
  export type TLocale = TConstValue<typeof Locales>;
5
5
  export type TVizView = TConstValue<typeof VizViews>;
6
+ export type TThemeMode = TConstValue<typeof ThemeModes>;
7
+ export type TTableCell = TConstValue<typeof TableCells>;
6
8
 
7
9
  export interface IVizNode {
8
10
  id: string;