@glossarist/concept-browser 0.7.59 → 0.7.61

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 CHANGED
@@ -432,7 +432,7 @@ Sites currently powered by `@glossarist/concept-browser`. When cutting a release
432
432
  | [`geolexica/osgeo.geolexica.org`](https://github.com/geolexica/osgeo.geolexica.org) | https://osgeo.geolexica.org |
433
433
  | [`oimlsmart/vocab`](https://github.com/oimlsmart/vocab) | https://www.oimlsmart.org/vocab/ (VIML)¹ |
434
434
  | [`metanorma/oiml-terms`](https://github.com/metanorma/oiml-terms) | https://metanorma.github.io/oiml-terms/ |
435
- | [`metanorma/iala-vocab`](https://github.com/metanorma/iala-vocab) | https://metanorma.github.io/iala-vocab/ |
435
+ | [`glossarist/iala-vocab`](https://github.com/glossarist/iala-vocab) | https://glossarist.github.io/iala-vocab/ |
436
436
  | [`metanorma/iso-10303-2-vocab`](https://github.com/metanorma/iso-10303-2-vocab) | https://metanorma.github.io/iso-10303-2-vocab/ |
437
437
 
438
438
  To add a new deployment here, open a PR against this README.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glossarist/concept-browser",
3
- "version": "0.7.59",
3
+ "version": "0.7.61",
4
4
  "description": "Vue SPA for browsing Glossarist terminology datasets with cross-reference resolution, graph visualization, and multi-language support",
5
5
  "type": "module",
6
6
  "bin": {
@@ -31,7 +31,7 @@
31
31
  "autoprefixer": "^10.4.21",
32
32
  "d3": "^7.9.0",
33
33
  "favicons": "^7.2.0",
34
- "glossarist": "^0.4.8",
34
+ "glossarist": "^0.4.9",
35
35
  "js-yaml": "^4.1.0",
36
36
  "jszip": "^3.10.1",
37
37
  "pinia": "^2.3.1",
@@ -1612,7 +1612,7 @@ for (const [id, count] of Object.entries(counts)) {
1612
1612
 
1613
1613
  writeBuildActivity(total, registry.map(r => r.id));
1614
1614
 
1615
- fs.writeFileSync(path.join(DATA, '_vocab.ttl'), buildVocabularyTurtle());
1615
+ fs.writeFileSync(path.join(DATA, '_vocab.ttl'), await buildVocabularyTurtle());
1616
1616
  console.log('Emitted vocabulary graph: data/_vocab.ttl');
1617
1617
 
1618
1618
  const contributors = config.contributors ?? [];
@@ -1,6 +1,21 @@
1
+ // Vocab turtle builder — emits SKOS ConceptSchemes for the
2
+ // glossarist enumeration IRIs.
3
+ //
4
+ // Delegates to glossarist-js's vocabulary emitter + writeTurtle so the
5
+ // canonical prefix list, CURIE handling, and serialization stay in one
6
+ // place. The output is byte-equivalent in semantics ( CURIEs resolved
7
+ // to absolute IRIs, then re-rendered via glossarist-js's n3 writer with
8
+ // the canonical prefix map ).
9
+
1
10
  import { readFileSync } from 'node:fs';
2
11
  import { join, dirname } from 'node:path';
3
12
  import { fileURLToPath } from 'node:url';
13
+ import {
14
+ vocabularyToQuads,
15
+ collectQuads,
16
+ writeTurtle,
17
+ PREFIXES,
18
+ } from 'glossarist/rdf';
4
19
 
5
20
  const __dirname = dirname(fileURLToPath(import.meta.url));
6
21
  const VOCAB_PATH = join(__dirname, '..', '..', 'data', 'glossarist-vocab.json');
@@ -9,54 +24,20 @@ function loadVocab(path = VOCAB_PATH) {
9
24
  return JSON.parse(readFileSync(path, 'utf8'));
10
25
  }
11
26
 
12
- function ttlLit(s) {
13
- if (s == null) return '""';
14
- const escaped = String(s).replace(/\\/g, '\\\\').replace(/"/g, '\\"')
15
- .replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t');
16
- return `"${escaped}"`;
17
- }
18
-
19
- function ttlPrefixed(qname) {
20
- const colonIdx = qname.indexOf(':');
21
- if (colonIdx < 0) return qname;
22
- const local = qname.slice(colonIdx + 1);
23
- const escaped = local.replace(/([/])/g, '\\$1');
24
- return `${qname.slice(0, colonIdx + 1)}${escaped}`;
27
+ // n3's writer prefixes must omit the trailing # or / — those go in
28
+ // the local name. Build the prefix-only map for writeTurtle.
29
+ function writerPrefixes() {
30
+ const out = {};
31
+ for (const [k, v] of Object.entries(PREFIXES)) {
32
+ out[k] = v;
33
+ }
34
+ return out;
25
35
  }
26
36
 
27
- export function buildVocabularyTurtle() {
37
+ export async function buildVocabularyTurtle() {
28
38
  const vocab = loadVocab();
29
- const lines = [
30
- '@prefix skos: <http://www.w3.org/2004/02/skos/core#> .',
31
- '@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .',
32
- '@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .',
33
- '@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .',
34
- '@prefix dcterms: <http://purl.org/dc/terms/> .',
35
- '@prefix gloss: <https://www.glossarist.org/ontologies/> .',
36
- '',
37
- ];
38
-
39
- for (const scheme of vocab.schemes) {
40
- const schemeLines = [
41
- `${ttlPrefixed(scheme.schemeIri)} a skos:ConceptScheme ;`,
42
- ` rdfs:label ${ttlLit(scheme.label)} ;`,
43
- ];
44
- for (const term of scheme.terms) {
45
- schemeLines.push(` skos:hasTopConcept ${ttlPrefixed(term.iri)} ;`);
46
- }
47
- schemeLines[schemeLines.length - 1] = schemeLines[schemeLines.length - 1].replace(/ ;$/, ' .');
48
- lines.push(...schemeLines);
49
-
50
- for (const term of scheme.terms) {
51
- lines.push(`${ttlPrefixed(term.iri)} a skos:Concept ;`);
52
- lines.push(` rdfs:label ${ttlLit(term.label)} ;`);
53
- lines.push(` skos:inScheme ${ttlPrefixed(scheme.schemeIri)} .`);
54
- lines.push('');
55
- }
56
- lines.push('');
57
- }
58
-
59
- return lines.join('\n') + '\n';
39
+ const quads = collectQuads(vocabularyToQuads(vocab.schemes));
40
+ return writeTurtle(quads, { prefixes: writerPrefixes() });
60
41
  }
61
42
 
62
43
  export function listVocabSchemes() {
@@ -15,7 +15,7 @@ function runInline(code: string): string {
15
15
 
16
16
  describe('WS F Layer 8 — build pipeline integration', () => {
17
17
  it('vocab-turtle.mjs produces parseable Turtle with 7 schemes', () => {
18
- const out = runInline(`import { buildVocabularyTurtle } from './scripts/lib/vocab-turtle.mjs'; console.log(buildVocabularyTurtle());`);
18
+ const out = runInline(`import { buildVocabularyTurtle } from './scripts/lib/vocab-turtle.mjs'; console.log(await buildVocabularyTurtle());`);
19
19
  const store = parseTurtle(out);
20
20
  const schemes = [...store].filter(q =>
21
21
  q.predicate.value === 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type' &&
@@ -119,7 +119,7 @@ describe('WS F Layer 8 — build pipeline integration', () => {
119
119
  import { buildBibliographyTurtle } from './scripts/lib/bibliography-turtle.mjs';
120
120
  import { buildVersionHistoryTurtle } from './scripts/lib/version-turtle.mjs';
121
121
  const parts = [
122
- buildVocabularyTurtle(),
122
+ await buildVocabularyTurtle(),
123
123
  buildDatasetTurtle({ datasetIri: 'https://glossarist.org/test/', registerId: 'test', title: 't', modified: '2026-01-01', languages: ['eng'], distributions: [], topConceptUris: [], sections: [] }),
124
124
  buildActivityTurtle({ runId: 'r', startedAt: '2026-01-01T00:00:00Z', endedAt: '2026-01-01T00:05:00Z', toolId: 'cb', toolVersion: '0', datasetRegisters: [], conceptCount: 0 }),
125
125
  buildAgentsTurtle([{ name: 'Ada' }]),
@@ -13,22 +13,22 @@ const SKOS = 'http://www.w3.org/2004/02/skos/core#';
13
13
  const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
14
14
 
15
15
  describe('buildVocabularyTurtle (mjs)', () => {
16
- it('parses without errors and produces a non-empty graph', () => {
17
- const ttl = buildVocabularyTurtle();
16
+ it('parses without errors and produces a non-empty graph', async () => {
17
+ const ttl = await buildVocabularyTurtle();
18
18
  const store = parse(ttl);
19
19
  expect(store.size).toBeGreaterThan(0);
20
20
  });
21
21
 
22
- it('declares at least one skos:ConceptScheme', () => {
23
- const store = parse(buildVocabularyTurtle());
22
+ it('declares at least one skos:ConceptScheme', async () => {
23
+ const store = parse(await buildVocabularyTurtle());
24
24
  const schemes = [...store].filter(q =>
25
25
  q.predicate.value === RDF_TYPE && q.object.value === `${SKOS}ConceptScheme`,
26
26
  );
27
27
  expect(schemes.length).toBeGreaterThan(0);
28
28
  });
29
29
 
30
- it('declares enumeration IRIs as skos:Concept instances', () => {
31
- const store = parse(buildVocabularyTurtle());
30
+ it('declares enumeration IRIs as skos:Concept instances', async () => {
31
+ const store = parse(await buildVocabularyTurtle());
32
32
  const concepts = [...store].filter(q =>
33
33
  q.predicate.value === RDF_TYPE && q.object.value === `${SKOS}Concept`,
34
34
  );
@@ -53,8 +53,8 @@ describe('buildVocabularyTurtle (mjs)', () => {
53
53
  expect(schemes.length).toBe(7);
54
54
  });
55
55
 
56
- it('emits skos:hasTopConcept and skos:inScheme bidirectionally', () => {
57
- const store = parse(buildVocabularyTurtle());
56
+ it('emits skos:hasTopConcept and skos:inScheme bidirectionally', async () => {
57
+ const store = parse(await buildVocabularyTurtle());
58
58
  const hasTopConcept = [...store].filter(q => q.predicate.value === `${SKOS}hasTopConcept`);
59
59
  const inScheme = [...store].filter(q => q.predicate.value === `${SKOS}inScheme`);
60
60
  expect(hasTopConcept.length).toBeGreaterThan(0);
@@ -33,7 +33,7 @@ export const GROUP_TYPES: Record<DatasetGroupKind, GroupTypeMeta> = {
33
33
  kind: 'lineage',
34
34
  label: 'Edition series',
35
35
  description: 'Same vocabulary, different editions over time',
36
- glyph: '⏳',
36
+ glyph: '⟶',
37
37
  ordered: true,
38
38
  supersession: true,
39
39
  sameVocabulary: true,
@@ -2,6 +2,7 @@
2
2
  import { computed, ref, watch, onMounted, onUnmounted, onBeforeUnmount } from 'vue';
3
3
  import { useRoute, useRouter } from 'vue-router';
4
4
  import { useVocabularyStore } from '../stores/vocabulary';
5
+ import { useUiStore } from '../stores/ui';
5
6
  import { useDsStyle } from '../utils/dataset-style';
6
7
  import { useDatasetLoader } from '../composables/use-dataset-loader';
7
8
  import { FORMAT_LABELS } from '../config/types';
@@ -17,6 +18,7 @@ import { formatSectionLabel } from '../utils/section-display';
17
18
  const props = defineProps<{ registerId: string }>();
18
19
 
19
20
  const store = useVocabularyStore();
21
+ const uiStore = useUiStore();
20
22
  const { getStyle } = useDsStyle();
21
23
  const { ensureLoaded, loading, localError } = useDatasetLoader(() => props.registerId);
22
24
  const { t } = useI18n();
@@ -30,6 +32,16 @@ const localizedDescription = computed(() => localizedDatasetField(props.register
30
32
  const adapter = computed(() => store.datasets.get(props.registerId));
31
33
  const chunkLoading = ref(false);
32
34
 
35
+ // Concept-count badge: tinted bg + always-readable text in either mode.
36
+ // Previously used `.light` for bg and `.dark` for text — but `.dark` is
37
+ // just `.light` with alpha, so text was invisible against the bg.
38
+ const conceptCountBadgeStyle = computed(() => {
39
+ const s = getStyle(props.registerId);
40
+ return uiStore.isDark
41
+ ? { backgroundColor: s.darkAlpha(0.25), color: s.light }
42
+ : { backgroundColor: s.light, color: '#ffffff' };
43
+ });
44
+
33
45
  // Background chunk preloading via requestIdleCallback
34
46
  let idlePreloadHandle: ReturnType<typeof requestIdleCallback> | ReturnType<typeof setTimeout> | null = null;
35
47
 
@@ -310,7 +322,7 @@ function clearSection() {
310
322
  <h1 class="font-serif text-3xl text-ink-800 mb-2">{{ localizedTitle }}</h1>
311
323
  <p class="text-ink-400 leading-relaxed max-w-2xl">{{ localizedDescription }}</p>
312
324
  <div class="flex flex-wrap gap-2 mt-4">
313
- <span class="badge" :style="{ backgroundColor: getStyle(registerId).light, color: getStyle(registerId).dark }">{{ manifest.conceptCount.toLocaleString() }} {{ t('dataset.concepts') }}</span>
325
+ <span class="badge" :style="conceptCountBadgeStyle">{{ manifest.conceptCount.toLocaleString() }} {{ t('dataset.concepts') }}</span>
314
326
  <span class="badge badge-gray">{{ manifest.languages.length }} {{ t('dataset.languages') }}</span>
315
327
  <span class="badge badge-green">{{ manifest.owner }}</span>
316
328
  <router-link :to="{ name: 'stats', params: { registerId } }" class="badge badge-blue hover:opacity-80 transition-opacity">
@@ -1,6 +1,7 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, ref } from 'vue';
3
3
  import { useVocabularyStore } from '../stores/vocabulary';
4
+ import { useUiStore } from '../stores/ui';
4
5
  import { useRouter } from 'vue-router';
5
6
  import { useDsStyle } from '../utils/dataset-style';
6
7
  import { useSiteConfig } from '../config/use-site-config';
@@ -8,10 +9,18 @@ import { useI18n } from '../i18n';
8
9
  import HomeSeriesSection from '../components/HomeSeriesSection.vue';
9
10
 
10
11
  const store = useVocabularyStore();
12
+ const uiStore = useUiStore();
11
13
  const router = useRouter();
12
14
  const { getStyle } = useDsStyle();
13
15
  const { config: siteConfig, localizedTitle, localizedSubtitle, localizedDescription, localizedDatasetField } = useSiteConfig();
14
16
  const { t } = useI18n();
17
+
18
+ function tagBadgeStyle(dsId: string) {
19
+ const s = getStyle(dsId);
20
+ return uiStore.isDark
21
+ ? { backgroundColor: s.darkAlpha(0.25), color: s.light }
22
+ : { backgroundColor: s.light, color: '#ffffff' };
23
+ }
15
24
  const exploring = ref(false);
16
25
 
17
26
  async function exploreRandom() {
@@ -181,7 +190,7 @@ function goToGraph() { router.push({ name: 'graph' }); }
181
190
  </div>
182
191
 
183
192
  <div class="flex flex-wrap gap-1.5 pl-[22px] mb-3">
184
- <span v-for="tag in (ds.manifest.tags ?? []).slice(0, 3)" :key="tag" class="badge text-[10px]" :style="{ backgroundColor: getStyle(ds.id).light, color: getStyle(ds.id).dark }">
193
+ <span v-for="tag in (ds.manifest.tags ?? []).slice(0, 3)" :key="tag" class="badge text-[10px]" :style="tagBadgeStyle(ds.id)">
185
194
  {{ tag }}
186
195
  </span>
187
196
  </div>