Skip to content

refactor(bridge): use native DetailedDefinition.examples (glossarist 0.4.2)#72

Merged
ronaldtse merged 1 commit into
mainfrom
refactor/remove-note-examples-bridge
Jun 22, 2026
Merged

refactor(bridge): use native DetailedDefinition.examples (glossarist 0.4.2)#72
ronaldtse merged 1 commit into
mainfrom
refactor/remove-note-examples-bridge

Conversation

@ronaldtse

Copy link
Copy Markdown
Member

Summary

PR #69 (b597b15) shipped scoped examples UI with a temporary WeakMap bridge because the published glossarist@0.4.0 DetailedDefinition class did not expose examples natively. That workaround was explicitly marked "remove once the published model carries the field."

glossarist@0.4.2 (glossarist-js PR #28, released today) adds readonly examples: DetailedDefinition[] to DetailedDefinition with the same lazy-instantiation pattern as sources. The bridge is now redundant — the model owns the nesting.

What's removed

  • src/adapters/model-bridge.ts: extraNoteExamples WeakMap, getNoteExamples() accessor, and the attachBridges block that paired raw with model instances for notes/definition/examples/annotations
  • src/composables/use-concept-content.ts: toRaw + getNoteExamples call, replaced with direct n.examples access

What's kept

mapDetailedDefinitionFromJsonLd in model-bridge.ts — still translates JSON-LD wire shape (gl:content, gl:examples) to the DetailedDefinition.fromJSON input shape.

Verification

Dependency bump

glossarist: ^0.4.0^0.4.2

Refs: glossarist/glossarist-js#28, #69

…0.4.2)

PR #69 (b597b15) shipped scoped examples UI with a temporary WeakMap
bridge because the published glossarist@0.4.0 DetailedDefinition class
did not expose `examples` natively. That workaround was explicitly
marked 'remove once the published model carries the field'.

glossarist@0.4.2 (PR glossarist/glossarist-js#28, released today) adds
`readonly examples: DetailedDefinition[]` to DetailedDefinition with
the same lazy-instantiation pattern as `sources`. The bridge is now
redundant — the model owns the nesting.

Removed:
- src/adapters/model-bridge.ts: extraNoteExamples WeakMap, getNoteExamples
  accessor, and the attachBridges block that paired raw with model
  instances for notes/definition/examples/annotations
- src/composables/use-concept-content.ts: toRaw + getNoteExamples call,
  replaced with direct `n.examples` access

Kept mapDetailedDefinitionFromJsonLd in model-bridge — it still
translates JSON-LD wire shape (gl:content, gl:examples) to the
DetailedDefinition.fromJSON input shape.

Verified: full test suite (797 passing including the scoped-examples
test from PR #69), vue-tsc clean, build clean.
@ronaldtse ronaldtse merged commit a778749 into main Jun 22, 2026
4 checks passed
@ronaldtse ronaldtse deleted the refactor/remove-note-examples-bridge branch June 22, 2026 08:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant