Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/register-ontologies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@_linked/react': major
---

`linkedPackage` (and the package's own exports) give `registerOntologies` in place of `linkedOntology`, which the core this release builds on no longer has. A package registers its ontologies from a generated `src/ontologies/index.ts` with `registerOntologies([...], import.meta.url)`; no package registers a prefix. The component index (`components.ttl`) declares the `core` namespace itself instead of reading it from core's ontology module; its bytes are unchanged.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
The old range long predated the core versions this package is actually built and
tested against; ^2.22.8 states the real requirement. Checked against every
package that depends on `@_linked/react` — auth, primitives, rdfs, schema,
shape-ui, sioc and the Create Now app — each already declares or resolves core
shape-ui, sioc and the host app — each already declares or resolves core
2.22.8, so none of them warns on this.

Narrowing a peer range is in principle a breaking change; it is released as a
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ Both formats are supported. For linked-set wrappers, the external API is also `o

### Export your components from `src/components/index.ts`

A package offers its components to builders (Create Now's drag-and-drop builder) through
A package offers its components to builders (such as a host app's drag-and-drop builder) through
`src/components/index.ts`: export each linked component by name.

```ts
Expand Down
2 changes: 1 addition & 1 deletion docs/reports/004-component-index.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
date: 2026-10-29
summary: >
The react half of the component index (CN plan 282 step CI, K8): `componentIndexTurtle` and
The react half of the component index (the host app's component plan, step CI, K8): `componentIndexTurtle` and
`componentIndexEntries` in `@_linked/react/utils/componentIndex` turn a package's
`components/index` exports into the Turtle `linked build` writes as `lib/esm/data/components.ttl`;
`linkedSetComponent` marks its result. Minor. The whole step: cli report 042.
Expand Down
67 changes: 67 additions & 0 deletions docs/reports/006-register-ontologies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
date: 2026-11-10
summary: >
`@_linked/react` compiles against the core that replaced `linkedOntology` with
`registerOntologies` and dropped `ns` from its ontology module: the package object gives
`registerOntologies`, and the component index declares the `core` namespace itself. Major.
packages: [react]
---

# 006 — `registerOntologies` in place of `linkedOntology`

## PR

**What changed.** The core this release builds on registers a package's ontologies with
`registerOntologies(ontologies, import.meta.url)` from a generated `ontologies/index`, registers no
prefix, and its `ontologies/linked-core` module holds only literal terms (no `ns`).

- `src/package.ts`: `linkedPackage(...)` and the package's own exports give `registerOntologies`
in place of `linkedOntology` (the rest of core's package object is spread as before).
- `src/utils/componentIndex.ts`: the `core` prefix of `components.ttl` is a literal namespace
(`https://linked.cm/ont/core/`) next to the `xsd` one, instead of `ns('')` from core's ontology
module. The file is self-contained and declares its own prefixes, so it does not depend on the
app's prefix map; its bytes are unchanged.

Major changeset (`.changeset/register-ontologies.md`): `linkedOntology` leaves the public exports.

**Verification**

`npx linked build`:

```
✔ Writing components.ttl
✔ Checking sideEffects
✔ Checking dependencies
✔ Build successful
```

`npm test`:

```
Test Suites: 7 passed, 7 total
Tests: 84 passed, 84 total
```

`npm run typecheck` (`tsc -p tsconfig-test.json --noEmit`): exit 0, no output.
`component-index.test.tsx` asserts the prefix line `@prefix core: <https://linked.cm/ont/core/> .`.

**Deviations.** None.

**Follow-ups.** None in this repo. Raising the `@_linked/core` range to the new major happens at
release, with every package of the coordinated major.

## Details

### Phases

1. Inventory: a grep of `src` for the removed core API (`linkedOntology`, `ns` from ontology
modules, `Prefix.add`, `toFullIfPossible`, `resolvePrefixedUri`) and for prefixed strings that
rely on a globally registered prefix. Two hits, both fixed; no prefixed strings.
2. Fix, build, test, typecheck (above).

### Decisions

| # | Problem | Choice | Alternative | Rationale |
|---|---|---|---|---|
| 1 | `components.ttl` needs the core namespace; core's module no longer exports `ns` | a literal, like the `xsd` one beside it | `createNameSpace` or reading the registry | the file's prefix section is fixed text; a literal states it directly |
| 2 | changeset level | major | minor | `linkedOntology` is removed from the exports |
27 changes: 19 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"setup": "npx semantu-agents"
},
"peerDependencies": {
"@_linked/core": "^2.46.0",
"@_linked/core": "^3.0.0",
"react": "^18.2.0 || ^19.0.0",
"react-native": ">=0.76"
},
Expand All @@ -69,8 +69,8 @@
},
"devDependencies": {
"@_linked/cli": "^1.45.5",
"@_linked/core": "^2.46.0",
"@_linked/xsd": "^1.4.1",
"@_linked/core": "^3.0.0",
"@_linked/xsd": "^2.0.0",
"@changesets/changelog-github": "^1.0.0",
"@changesets/cli": "^3.0.0",
"@jest/globals": "^30.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const registry = sharedState('@_linked/react', 'componentRegistry', () => ({

const {
linkedUtil,
linkedOntology,
registerOntologies,
linkedShape,
registerPackageExport,
registerPackageModule,
Expand Down Expand Up @@ -67,7 +67,7 @@ export {
linkedSetComponent,
linkedShape,
linkedUtil,
linkedOntology,
registerOntologies,
registerPackageExport,
registerPackageModule,
packageExports,
Expand Down
7 changes: 5 additions & 2 deletions src/utils/componentIndex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import {QueryBuilder} from '@_linked/core/queries/QueryBuilder';
import {isLinkedInstance} from '@_linked/core/utils/linkedError';
import {getPackageUri} from '@_linked/core/shapes/SHACL';
import {coreOntology, ns as coreNs} from '@_linked/core/ontologies/linked-core';
import {coreOntology} from '@_linked/core/ontologies/linked-core';
import {rdf, ns as rdfNs} from '@_linked/core/ontologies/rdf';

export interface ComponentIndexEntry {
Expand All @@ -27,9 +27,12 @@ export interface ComponentIndexEntry {
query: string;
}

// The file declares its own prefixes: it is a self-contained document, written whatever map the
// running app has loaded.
const CORE = 'https://linked.cm/ont/core/';
const XSD = 'http://www.w3.org/2001/XMLSchema#';
const PREFIXES: [string, string][] = [
['core', coreNs('').id],
['core', CORE],
['rdf', rdfNs('').id],
['xsd', XSD],
];
Expand Down