The npm workspace package with the code the Vue frontends share: API calls, sign-in state, the color scheme, and the Gherkin runner the editor, the demo and the PoCs run scenarios with.
@regelrecht/frontend-shared holds the frontend code that more than one Vue app needs. It is not built or published on its own: the apps import its source files through the npm workspace, and Vite bundles whatever they import.
<script setup lang="ts">; only the generated Gherkin grammar is JavaScriptpackages/frontend-shared/private, not published)npm test -w packages/frontend-sharedvue-tsc, npm run typecheck -w packages/frontend-sharedThe editor is the reference for what lives here, and the other apps conform to it. Which app uses what:
| App | Imports |
|---|---|
Editor (frontend/) | API calls, sign-in state, the GitHub link status, the color scheme and its submenu (components/WeergaveMenuItem.vue), value helpers, the Gherkin runner |
Demo (frontend-demo/) | The color scheme, value helpers, the Gherkin runner |
The two static PoCs (frontend-poc-*) | The Gherkin runner, saved state, browser variants, the line diff, the reload-on-stale-bundle handler, the tool-call formatter, the shared components |
Lawmaking (frontend-lawmaking/) | The color scheme |
Chronolexography PoC (packages/poc-chronolexografie/frontend/) | The chronolexography form fields, value helpers |
The package root (src/index.ts) exports only the small primitives. Everything else has its own subpath in the exports map of package.json, so an app pulls in only what it imports: ./gherkin, ./lib/*, ./components/* and the individual modules as ./*, without an extension. The one JavaScript file, ./gherkin/grammar.generated.js, keeps its extension.
| Module | Purpose |
|---|---|
apiFetch.ts | A thin wrapper around fetch. A non-ok response throws an ApiError carrying the status, the body text and the content type. It deliberately has no retries, timeouts or auth handling; apiFetch returns the raw Response so callers keep the headers the ETag/If-Match handling relies on |
useAuth.ts | Sign-in state from /auth/status, the realm roles of the current user, and hasRole / hasAnyRole for showing role-specific UI. The backend still enforces every route |
useGithubAuth.ts | Whether the user has linked a GitHub account, from the editor API’s /auth/github/status. When the endpoint is missing or fails, the controls are hidden |
useColorScheme.ts | The light/dark/auto picker. It sets data-scheme on <html>, which the design system keys its dark tokens on, and leaves it off for auto. Persistence is injected: the editor stores the choice server-side, other apps use localStorage |
values.ts | isUnknown and missingFacts: one definition of how the engine’s Unknown value (RFC-036) arrives in JavaScript |
The package is written in TypeScript. As in the editor, tsconfig.json references two programs: tsconfig.app.json for the package code, and tsconfig.node.json for the tests, their support code and the scripts, which run under Node and get its types. The app config extends @vue/tsconfig/tsconfig.dom.json (strict mode) and sets allowJs, which lets the TypeScript modules import grammar.generated.js; that file stays JavaScript because bdd/codegen/gen-js.mjs writes it and docs/scripts/check-gherkin-steps.mjs loads it with plain Node. steps.ts checks its entries against the GrammarEntry type.
node cannot load these modules. The other conventions all frontends share are in Frontend Code.GherkinEngine interface. The engine’s own generated .d.ts is part of each app’s WASM build output, which this package cannot reach../chronolex/*, ./components/chronolex/*)Form fields for the chronolexography PoC, as its core (packages/poc-chronolexografie/src/kern.rs) derives them from the law. chronolex/waarden.ts puts values in words, chronolex/tabel.ts compares and shows a field that holds a table, and chronolex/voorinvulling.ts applies the UI spec: what is prefilled, what the system fills, what the form hides. VeldInvoer.vue picks the input by the field’s type and takes the label and help a UI spec gives; TabelInvoer.vue edits a table row by row, and OordeelKeuze.vue asks yes, no or empty. Their tests live in the PoC (packages/poc-chronolexografie/frontend/tests/), because their fixture reads the PoC’s test source (packages/poc-chronolexografie/tests/bron-voorinvullen).
./gherkin)A JavaScript runner for the canonical scenario language in bdd/grammar.yaml, run against the WASM build of the engine. The editor’s scenario builder and the demo’s scenario page both run on it.
| Module | Purpose |
|---|---|
parser.ts | Wraps @cucumber/gherkin into a small AST of scenarios, steps and data tables |
grammar.generated.js | The step patterns, generated from bdd/grammar.yaml by just bdd-codegen. Never edit it by hand; CI regenerates it and fails when the committed file differs |
steps.ts | Turns the generated grammar into step definitions and matches step text against them |
actions.ts | The one dispatch that gives each grammar action its behavior, the JavaScript counterpart of the Rust BDD dispatch |
context.ts | ExecutionContext, the state of one scenario run |
The runner supports only the core tier. A step from another tier throws instead of doing nothing, so a scenario that needs more than the WASM engine offers fails visibly.
These came in with the proof-of-concepts behind the PoC Portal. Their code is in English; the text they show to users is Dutch.
| Module | Purpose |
|---|---|
usePersistedState.ts | Keeps choices and settings across a page reload in localStorage, under a prefix per case. Two PoCs share one origin behind the portal, and without the prefix they would read each other’s state. An edited rulework is deliberately not stored here |
browserVariants.ts | Variants a user saves in their own browser, in the same shape as the variants checked into the case. Each file keeps a fingerprint of the law text it started from, so the app can say when the corpus has changed underneath it. Variants saved before the code was translated carry Dutch field names; they are read under both names and written back in the new format |
reloadOnStaleBundle.ts | Reloads the page when a lazily loaded view no longer exists after a deploy, at most once per ten seconds |
formatToolCall.ts | Renders a tool call in the policy assistant’s feed as one readable line, whatever shape the model’s arguments take. Used by AssistentPanel.vue in both static PoCs |
lib/diff.ts | A line diff (longest common subsequence) for showing a change to a law’s YAML, with no dependency |
components/ | Panel.vue (a collapsible section), ColumnMenu.vue (a menu to pick variants as columns), AssistantNotices.vue (notices from the policy assistant) and OptimizationPathChart.vue (the path the assistant takes toward a target, which needs the optional echarts peer dependency) |
./regelrijm/index)RegelRijm reads an action tree as Dutch: [hoogte zorgtoeslag] wordt: afgerond op hele centen ( het deel van … boven … ). It is generated from the
YAML each time a rule is shown, never written by hand, and the same tree always
gives the same text. The grammar, the choices that keep two trees from reading
alike, and the editor pane are in RFC-054.
| Export | Purpose |
|---|---|
renderAction(action, { article, glossary }) | The full reading of one action, as text and as a token stream for HTML |
renderFocus(action, path, { article, depth, open }) | The reading of one operation, with operations deeper than depth folded into their signature, ⟨bedrag uit [a] en [b]⟩: what the part gives and which inputs it reads. open holds path keys (pathKey) of folded parts to show one level deeper |
articleContext(article, glossary) | The declared units, the vocabulary and the article’s constants, built once per article |
untranslated(segments), references(segments) | The names a reading shows without a term, and every name it refers to |
A name without a term reads as [humanised name]; a glossary (name: term)
is optional and can be passed in by the caller, so a corpus kept elsewhere keeps
its words out of this package. The tests next to the module read every action in
corpus/regulation back to its tree with a parser that exists
only in test-support/. npm run regelrijm-report -w packages/frontend-shared -- corpus/regulation,
run from the repository root,
reports per corpus how many rules read on one line and which names have no
term. The script is TypeScript and runs through tsx, which resolves the
extensionless imports that plain Node cannot.
An exploration into transparent, executable legislation, and one of the three projects in the starting selection of the Nederlandse Digitale Dienst.
GitHub repository
How it works
Demo walkthrough
Stay informed
Roadmap (Dutch)
Documentation
Research
Basiswerk recht (Dutch)
Nederlandse Digitale Dienst
Ministry of Economic Affairs and Climate Policy