mdld-parse 0.9.5 β 0.9.6
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 +45 -9
- package/dist/README.md +45 -9
- package/dist/docs/API.md +41 -5
- package/dist/docs/Parser.md +16 -7
- package/dist/docs/primary-subject.md +96 -21
- package/dist/index.html +9 -9
- package/dist/index.js +32 -27
- package/package.json +1 -1
- package/dist/docs/Nostr.md +0 -544
package/README.md
CHANGED
|
@@ -57,7 +57,7 @@ console.log(result.quads);
|
|
|
57
57
|
- **β‘ Polarity system** - Sophisticated diff authoring with `+` and `-` prefixes
|
|
58
58
|
- **π Origin tracking** - Complete provenance with lean quad-to-source mapping
|
|
59
59
|
- **π― Elevated statements** - Automatic rdf:Statement pattern detection for "golden" graph extraction
|
|
60
|
-
- **π·οΈ Primary metadata** -
|
|
60
|
+
- **π·οΈ Primary metadata** - Structured primary object with subject, type, and label for document identity
|
|
61
61
|
|
|
62
62
|
## π What is MD-LD?
|
|
63
63
|
|
|
@@ -233,18 +233,33 @@ Parse MD-LD markdown and return RDF quads with lean origin tracking.
|
|
|
233
233
|
- `dataFactory` (object, optional) β Custom RDF/JS DataFactory
|
|
234
234
|
- `graph` (string, optional) β Named graph IRI
|
|
235
235
|
|
|
236
|
-
**Returns:** `{ quads, remove, statements, origin, context, primarySubject,
|
|
236
|
+
**Returns:** `{ quads, remove, statements, origin, context, primarySubject, primary, md }`
|
|
237
237
|
|
|
238
238
|
- `quads` β Array of RDF/JS Quads (final resolved graph state)
|
|
239
239
|
- `remove` β Array of RDF/JS Quads (external retractions targeting prior state)
|
|
240
240
|
- `statements` β Array of elevated RDF/JS Quads extracted from rdf:Statement patterns
|
|
241
241
|
- `origin` β Lean origin tracking object with quadIndex for UI navigation
|
|
242
242
|
- `context` β Final context used (includes prefixes)
|
|
243
|
-
- `primarySubject` β String IRI or null (
|
|
244
|
-
- `
|
|
245
|
-
- `primaryLabel` β String or null (first rdfs:label literal)
|
|
243
|
+
- `primarySubject` β String IRI or null (canonical append identity)
|
|
244
|
+
- `primary` β Object containing primary metadata (semantic surface descriptor)
|
|
246
245
|
- `md` β Clean Markdown with all MD-LD annotations stripped (round-trip safe)
|
|
247
246
|
|
|
247
|
+
**Dual-Layer Architecture:**
|
|
248
|
+
|
|
249
|
+
| Layer | Field | Purpose | Use Cases |
|
|
250
|
+
|-------|-------|---------|-----------|
|
|
251
|
+
| **Canonical Identity** | `primarySubject` | Append routing, storage, synchronization | `append()`, file placement, authority validation |
|
|
252
|
+
| **Semantic Surface** | `primary` | UI, indexing, navigation, agent orientation | Dashboards, search, previews, timelines |
|
|
253
|
+
|
|
254
|
+
**Primary Object Structure:**
|
|
255
|
+
```javascript
|
|
256
|
+
primary: {
|
|
257
|
+
subject: string | null, // First non-fragment subject declaration
|
|
258
|
+
type: string | null, // First rdf:type declaration
|
|
259
|
+
label: string | null // First rdfs:label literal
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
248
263
|
### `merge(docs, options)`
|
|
249
264
|
|
|
250
265
|
Merge multiple MDLD documents with diff polarity resolution.
|
|
@@ -254,13 +269,34 @@ Merge multiple MDLD documents with diff polarity resolution.
|
|
|
254
269
|
- `options` (object, optional):
|
|
255
270
|
- `context` (object) β Prefix mappings (merged with DEFAULT_CONTEXT)
|
|
256
271
|
|
|
257
|
-
**Returns:** `{ quads, remove, origin, context, primarySubjects }`
|
|
272
|
+
**Returns:** `{ quads, remove, origin, context, primarySubjects, primary }`
|
|
258
273
|
|
|
259
274
|
- `quads` β Array of RDF/JS Quads (final resolved graph state)
|
|
260
275
|
- `remove` β Array of RDF/JS Quads (external retractions targeting prior state)
|
|
261
|
-
- `origin` β Merge origin
|
|
262
|
-
- `context` β Final
|
|
263
|
-
- `primarySubjects` β Array of string IRIs (
|
|
276
|
+
- `origin` β Merge origin with document tracking
|
|
277
|
+
- `context` β Final context used (includes prefixes)
|
|
278
|
+
- `primarySubjects` β Array of string IRIs (canonical append identities, ordered by merge)
|
|
279
|
+
- `primary` β Array of primary objects (semantic surface descriptors, ordered by merge)
|
|
280
|
+
|
|
281
|
+
**Dual-Layer Architecture:**
|
|
282
|
+
|
|
283
|
+
| Layer | Field | Purpose | Use Cases |
|
|
284
|
+
|-------|-------|---------|-----------|
|
|
285
|
+
| **Canonical Identity** | `primarySubjects` | Append routing, storage, synchronization | Multi-document append, file organization |
|
|
286
|
+
| **Semantic Surface** | `primary` | UI, indexing, navigation, agent orientation | Vault indexing, document discovery, search |
|
|
287
|
+
|
|
288
|
+
**Primary Object Array Structure:**
|
|
289
|
+
```javascript
|
|
290
|
+
primary: [
|
|
291
|
+
{
|
|
292
|
+
subject: string | null, // First non-fragment subject declaration
|
|
293
|
+
type: string | null, // First rdf:type declaration
|
|
294
|
+
label: string | null // First rdfs:label literal
|
|
295
|
+
},
|
|
296
|
+
// ... one object per document
|
|
297
|
+
]
|
|
298
|
+
```
|
|
299
|
+
|
|
264
300
|
|
|
265
301
|
### `generate({ quads, context, primarySubject })`
|
|
266
302
|
|
package/dist/README.md
CHANGED
|
@@ -57,7 +57,7 @@ console.log(result.quads);
|
|
|
57
57
|
- **β‘ Polarity system** - Sophisticated diff authoring with `+` and `-` prefixes
|
|
58
58
|
- **π Origin tracking** - Complete provenance with lean quad-to-source mapping
|
|
59
59
|
- **π― Elevated statements** - Automatic rdf:Statement pattern detection for "golden" graph extraction
|
|
60
|
-
- **π·οΈ Primary metadata** -
|
|
60
|
+
- **π·οΈ Primary metadata** - Structured primary object with subject, type, and label for document identity
|
|
61
61
|
|
|
62
62
|
## π What is MD-LD?
|
|
63
63
|
|
|
@@ -233,18 +233,33 @@ Parse MD-LD markdown and return RDF quads with lean origin tracking.
|
|
|
233
233
|
- `dataFactory` (object, optional) β Custom RDF/JS DataFactory
|
|
234
234
|
- `graph` (string, optional) β Named graph IRI
|
|
235
235
|
|
|
236
|
-
**Returns:** `{ quads, remove, statements, origin, context, primarySubject,
|
|
236
|
+
**Returns:** `{ quads, remove, statements, origin, context, primarySubject, primary, md }`
|
|
237
237
|
|
|
238
238
|
- `quads` β Array of RDF/JS Quads (final resolved graph state)
|
|
239
239
|
- `remove` β Array of RDF/JS Quads (external retractions targeting prior state)
|
|
240
240
|
- `statements` β Array of elevated RDF/JS Quads extracted from rdf:Statement patterns
|
|
241
241
|
- `origin` β Lean origin tracking object with quadIndex for UI navigation
|
|
242
242
|
- `context` β Final context used (includes prefixes)
|
|
243
|
-
- `primarySubject` β String IRI or null (
|
|
244
|
-
- `
|
|
245
|
-
- `primaryLabel` β String or null (first rdfs:label literal)
|
|
243
|
+
- `primarySubject` β String IRI or null (canonical append identity)
|
|
244
|
+
- `primary` β Object containing primary metadata (semantic surface descriptor)
|
|
246
245
|
- `md` β Clean Markdown with all MD-LD annotations stripped (round-trip safe)
|
|
247
246
|
|
|
247
|
+
**Dual-Layer Architecture:**
|
|
248
|
+
|
|
249
|
+
| Layer | Field | Purpose | Use Cases |
|
|
250
|
+
|-------|-------|---------|-----------|
|
|
251
|
+
| **Canonical Identity** | `primarySubject` | Append routing, storage, synchronization | `append()`, file placement, authority validation |
|
|
252
|
+
| **Semantic Surface** | `primary` | UI, indexing, navigation, agent orientation | Dashboards, search, previews, timelines |
|
|
253
|
+
|
|
254
|
+
**Primary Object Structure:**
|
|
255
|
+
```javascript
|
|
256
|
+
primary: {
|
|
257
|
+
subject: string | null, // First non-fragment subject declaration
|
|
258
|
+
type: string | null, // First rdf:type declaration
|
|
259
|
+
label: string | null // First rdfs:label literal
|
|
260
|
+
}
|
|
261
|
+
```
|
|
262
|
+
|
|
248
263
|
### `merge(docs, options)`
|
|
249
264
|
|
|
250
265
|
Merge multiple MDLD documents with diff polarity resolution.
|
|
@@ -254,13 +269,34 @@ Merge multiple MDLD documents with diff polarity resolution.
|
|
|
254
269
|
- `options` (object, optional):
|
|
255
270
|
- `context` (object) β Prefix mappings (merged with DEFAULT_CONTEXT)
|
|
256
271
|
|
|
257
|
-
**Returns:** `{ quads, remove, origin, context, primarySubjects }`
|
|
272
|
+
**Returns:** `{ quads, remove, origin, context, primarySubjects, primary }`
|
|
258
273
|
|
|
259
274
|
- `quads` β Array of RDF/JS Quads (final resolved graph state)
|
|
260
275
|
- `remove` β Array of RDF/JS Quads (external retractions targeting prior state)
|
|
261
|
-
- `origin` β Merge origin
|
|
262
|
-
- `context` β Final
|
|
263
|
-
- `primarySubjects` β Array of string IRIs (
|
|
276
|
+
- `origin` β Merge origin with document tracking
|
|
277
|
+
- `context` β Final context used (includes prefixes)
|
|
278
|
+
- `primarySubjects` β Array of string IRIs (canonical append identities, ordered by merge)
|
|
279
|
+
- `primary` β Array of primary objects (semantic surface descriptors, ordered by merge)
|
|
280
|
+
|
|
281
|
+
**Dual-Layer Architecture:**
|
|
282
|
+
|
|
283
|
+
| Layer | Field | Purpose | Use Cases |
|
|
284
|
+
|-------|-------|---------|-----------|
|
|
285
|
+
| **Canonical Identity** | `primarySubjects` | Append routing, storage, synchronization | Multi-document append, file organization |
|
|
286
|
+
| **Semantic Surface** | `primary` | UI, indexing, navigation, agent orientation | Vault indexing, document discovery, search |
|
|
287
|
+
|
|
288
|
+
**Primary Object Array Structure:**
|
|
289
|
+
```javascript
|
|
290
|
+
primary: [
|
|
291
|
+
{
|
|
292
|
+
subject: string | null, // First non-fragment subject declaration
|
|
293
|
+
type: string | null, // First rdf:type declaration
|
|
294
|
+
label: string | null // First rdfs:label literal
|
|
295
|
+
},
|
|
296
|
+
// ... one object per document
|
|
297
|
+
]
|
|
298
|
+
```
|
|
299
|
+
|
|
264
300
|
|
|
265
301
|
### `generate({ quads, context, primarySubject })`
|
|
266
302
|
|
package/dist/docs/API.md
CHANGED
|
@@ -14,15 +14,30 @@ Parse MD-LD markdown and return RDF quads.
|
|
|
14
14
|
- `dataFactory` (object, optional) β Custom RDF/JS DataFactory
|
|
15
15
|
- `graph` (string, optional) β Named graph IRI
|
|
16
16
|
|
|
17
|
-
**Returns:** `{ quads, context, primarySubject,
|
|
17
|
+
**Returns:** `{ quads, context, primarySubject, primary, origin, remove, statements }`
|
|
18
18
|
|
|
19
19
|
- `quads` β Array of RDF/JS Quads (final resolved graph state)
|
|
20
20
|
- `remove` β Array of RDF/JS Quads (external retractions targeting prior state)
|
|
21
21
|
- `origin` β Lean origin tracking object with quadIndex for UI navigation
|
|
22
22
|
- `context` β Final context used (includes prefixes)
|
|
23
|
-
- `primarySubject` β String IRI or null (
|
|
24
|
-
- `
|
|
25
|
-
|
|
23
|
+
- `primarySubject` β String IRI or null (canonical append identity)
|
|
24
|
+
- `primary` β Object containing primary metadata (semantic surface descriptor)
|
|
25
|
+
|
|
26
|
+
**Dual-Layer Architecture:**
|
|
27
|
+
|
|
28
|
+
| Layer | Field | Purpose | Use Cases |
|
|
29
|
+
|-------|-------|---------|-----------|
|
|
30
|
+
| **Canonical Identity** | `primarySubject` | Append routing, storage, synchronization | `append()`, file placement, authority validation |
|
|
31
|
+
| **Semantic Surface** | `primary` | UI, indexing, navigation, agent orientation | Dashboards, search, previews, timelines |
|
|
32
|
+
|
|
33
|
+
**Primary Object Structure:**
|
|
34
|
+
```javascript
|
|
35
|
+
primary: {
|
|
36
|
+
subject: string | null, // First non-fragment subject declaration
|
|
37
|
+
type: string | null, // First rdf:type declaration
|
|
38
|
+
label: string | null // First rdfs:label literal
|
|
39
|
+
}
|
|
40
|
+
```
|
|
26
41
|
|
|
27
42
|
> Legacy: `parse(text, options)` supported for backward compatibility (deprecated)
|
|
28
43
|
|
|
@@ -125,7 +140,7 @@ Merge multiple MDLD documents with diff polarity resolution.
|
|
|
125
140
|
- `options` (object, optional):
|
|
126
141
|
- `context` (object) β Prefix mappings (merged with DEFAULT_CONTEXT)
|
|
127
142
|
|
|
128
|
-
**Returns:** `{ quads, remove, origin, context }`
|
|
143
|
+
**Returns:** `{ quads, remove, origin, context, primarySubjects, primary }`
|
|
129
144
|
|
|
130
145
|
- `quads` β Merged array of RDF/JS Quads
|
|
131
146
|
- `remove` β Array of retractions from merge process
|
|
@@ -133,6 +148,27 @@ Merge multiple MDLD documents with diff polarity resolution.
|
|
|
133
148
|
- `documents` β Array of document metadata
|
|
134
149
|
- `quadIndex` β Combined quad index from all documents
|
|
135
150
|
- `context` β Final merged context
|
|
151
|
+
- `primarySubjects` β Array of string IRIs (canonical append identities, ordered by merge)
|
|
152
|
+
- `primary` β Array of primary objects (semantic surface descriptors, ordered by merge)
|
|
153
|
+
|
|
154
|
+
**Dual-Layer Architecture:**
|
|
155
|
+
|
|
156
|
+
| Layer | Field | Purpose | Use Cases |
|
|
157
|
+
|-------|-------|---------|-----------|
|
|
158
|
+
| **Canonical Identity** | `primarySubjects` | Append routing, storage, synchronization | Multi-document append, file organization |
|
|
159
|
+
| **Semantic Surface** | `primary` | UI, indexing, navigation, agent orientation | Vault indexing, document discovery, search |
|
|
160
|
+
|
|
161
|
+
**Primary Object Array Structure:**
|
|
162
|
+
```javascript
|
|
163
|
+
primary: [
|
|
164
|
+
{
|
|
165
|
+
subject: string | null, // First non-fragment subject declaration
|
|
166
|
+
type: string | null, // First rdf:type declaration
|
|
167
|
+
label: string | null // First rdfs:label literal
|
|
168
|
+
},
|
|
169
|
+
// ... one object per document
|
|
170
|
+
]
|
|
171
|
+
```
|
|
136
172
|
|
|
137
173
|
#### Basic Merge Example
|
|
138
174
|
|
package/dist/docs/Parser.md
CHANGED
|
@@ -530,13 +530,22 @@ for (let i = 0; i < tokens.length; i++) {
|
|
|
530
530
|
// Process retractions and ensure hard invariant
|
|
531
531
|
const filteredRemove = processRetractions(state.quads, state.removeSet);
|
|
532
532
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
533
|
+
// Create structured primary object for semantic surface
|
|
534
|
+
const primary = {
|
|
535
|
+
subject: state.primarySubject,
|
|
536
|
+
type: state.primaryType,
|
|
537
|
+
label: state.primaryLabel
|
|
538
|
+
};
|
|
539
|
+
|
|
540
|
+
return {
|
|
541
|
+
quads: state.quads, // Final resolved graph state
|
|
542
|
+
remove: filteredRemove, // External retractions only
|
|
543
|
+
statements: state.statements, // Elevated statements
|
|
544
|
+
origin: state.origin, // Complete provenance
|
|
545
|
+
context: state.ctx, // Final prefix context
|
|
546
|
+
primarySubject: state.primarySubject, // Canonical append identity
|
|
547
|
+
primary // Semantic surface descriptor
|
|
548
|
+
};
|
|
540
549
|
```
|
|
541
550
|
|
|
542
551
|
#### Retraction Processing
|
|
@@ -8,9 +8,18 @@ MD-LD tracks three primary metadata fields during parsing to provide immediate d
|
|
|
8
8
|
|
|
9
9
|
| Field | Source | Purpose |
|
|
10
10
|
|-------|--------|---------|
|
|
11
|
-
| **primarySubject** | First non-fragment `{=subject}` | Document identity |
|
|
12
|
-
| **primaryType** | First
|
|
13
|
-
| **primaryLabel** | First `
|
|
11
|
+
| **primarySubject** | First non-fragment `{=subject}` | Document identity (canonical append identity) |
|
|
12
|
+
| **primaryType** | First `rdf:type` declaration | Document category (semantic classification) |
|
|
13
|
+
| **primaryLabel** | First `rdfs:label` literal | Human-readable name (UI & display) |
|
|
14
|
+
|
|
15
|
+
## Dual-Layer Architecture
|
|
16
|
+
|
|
17
|
+
MD-LD implements a **dual-layer architecture** that separates concerns cleanly:
|
|
18
|
+
|
|
19
|
+
| Layer | Field | Role | Use Cases |
|
|
20
|
+
| ------ | ------ | --------- | ---------- |
|
|
21
|
+
| **Canonical Identity** | `primarySubject` | Storage, routing, synchronization, append operations |
|
|
22
|
+
| **Semantic Surface** | `primary` object | UI rendering, indexing, navigation, agent orientation |
|
|
14
23
|
|
|
15
24
|
## What is a Primary Subject?
|
|
16
25
|
|
|
@@ -20,10 +29,28 @@ The Primary Subject is the first non-fragment subject declaration (`{=IRI}`) in
|
|
|
20
29
|
|
|
21
30
|
The Primary Type is the first `rdf:type` declaration associated with the Primary Subject. It provides a way to identify the type of the main entity described by a document.
|
|
22
31
|
|
|
32
|
+
### 1. First Type Declaration Wins
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
# Person {=my:alice .prov:Person .schema:Person}
|
|
36
|
+
[Details] {label}
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
`primaryType` captures the **first rdf:type assertion emitted while current subject == primarySubject**. This is parser-precise and avoids ambiguity with later type declarations for other entities.
|
|
40
|
+
|
|
23
41
|
## What is a Primary Label?
|
|
24
42
|
|
|
25
43
|
The Primary Label is the first `rdfs:label` literal associated with the Primary Subject. It provides a human-readable name for the main entity described by a document.
|
|
26
44
|
|
|
45
|
+
### 2. First Label Declaration Wins
|
|
46
|
+
|
|
47
|
+
```markdown
|
|
48
|
+
# Person {=my:alice .prov:Person label}
|
|
49
|
+
[Alice Smith] {rdfs:label}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`primaryLabel` captures the **first emitted rdfs:label literal while current subject == primarySubject**. This ensures the label is associated with the primary subject, not other entities in the document.
|
|
53
|
+
|
|
27
54
|
## Example Document
|
|
28
55
|
|
|
29
56
|
```markdown
|
|
@@ -53,13 +80,17 @@ const md = `[ex] <tag:alice@example.org,2026:articles/>
|
|
|
53
80
|
|
|
54
81
|
const result = parse({ text: md });
|
|
55
82
|
|
|
83
|
+
// Canonical append identity
|
|
56
84
|
console.log('Primary Subject:', result.primarySubject);
|
|
57
|
-
|
|
58
|
-
console.log('Primary
|
|
85
|
+
// Semantic surface descriptor
|
|
86
|
+
console.log('Primary Object:', result.primary);
|
|
59
87
|
// Output:
|
|
60
88
|
// Primary Subject: tag:alice@example.org,2026:articles/understanding-primary-subject
|
|
61
|
-
// Primary
|
|
62
|
-
//
|
|
89
|
+
// Primary Object: {
|
|
90
|
+
// subject: 'tag:alice@example.org,2026:articles/understanding-primary-subject',
|
|
91
|
+
// type: 'http://schema.org/Article',
|
|
92
|
+
// label: 'Understanding Primary Subjects'
|
|
93
|
+
// }
|
|
63
94
|
```
|
|
64
95
|
|
|
65
96
|
## Key Behaviors
|
|
@@ -115,8 +146,16 @@ const doc2 = `[ex] <http://example.org/>
|
|
|
115
146
|
|
|
116
147
|
const result = merge([doc1, doc2], { context: { ex: 'http://example.org/' } });
|
|
117
148
|
|
|
118
|
-
|
|
119
|
-
|
|
149
|
+
// Canonical append identities
|
|
150
|
+
console.log('Primary Subjects:', result.primarySubjects);
|
|
151
|
+
// Semantic surface descriptors
|
|
152
|
+
console.log('Primary Objects:', result.primary);
|
|
153
|
+
// Output:
|
|
154
|
+
// Primary Subjects: ['http://example.org/doc1', 'http://example.org/doc2']
|
|
155
|
+
// Primary Objects: [
|
|
156
|
+
// { subject: 'http://example.org/doc1', type: 'http://schema.org/Article', label: 'Document 1' },
|
|
157
|
+
// { subject: 'http://example.org/doc2', type: 'http://schema.org/Article', label: 'Document 2' }
|
|
158
|
+
// ]
|
|
120
159
|
```
|
|
121
160
|
|
|
122
161
|
## Use Cases
|
|
@@ -206,13 +245,18 @@ const doc1 = `[blog] <https://example.com/blog/>
|
|
|
206
245
|
[Hello World] {schema:headline}`;
|
|
207
246
|
|
|
208
247
|
const result1 = parse({ text: doc1, context: { blog: 'https://example.com/blog/', schema: 'http://schema.org/' } });
|
|
248
|
+
|
|
249
|
+
// Canonical append identity
|
|
209
250
|
console.log('Primary Subject:', result1.primarySubject);
|
|
210
|
-
|
|
211
|
-
console.log('Primary
|
|
251
|
+
// Semantic surface descriptor
|
|
252
|
+
console.log('Primary Object:', result1.primary);
|
|
212
253
|
// Output:
|
|
213
254
|
// Primary Subject: https://example.com/blog/post1
|
|
214
|
-
// Primary
|
|
215
|
-
//
|
|
255
|
+
// Primary Object: {
|
|
256
|
+
// subject: 'https://example.com/blog/post1',
|
|
257
|
+
// type: 'http://schema.org/BlogPosting',
|
|
258
|
+
// label: 'My First Post'
|
|
259
|
+
// }
|
|
216
260
|
|
|
217
261
|
// Multiple documents
|
|
218
262
|
const doc2 = `[blog] <https://example.com/blog/>
|
|
@@ -221,8 +265,16 @@ const doc2 = `[blog] <https://example.com/blog/>
|
|
|
221
265
|
|
|
222
266
|
const merged = merge([doc1, doc2], { context: { blog: 'https://example.com/blog/', schema: 'http://schema.org/' } });
|
|
223
267
|
|
|
224
|
-
|
|
225
|
-
|
|
268
|
+
// Canonical append identities
|
|
269
|
+
console.log('Primary Subjects:', merged.primarySubjects);
|
|
270
|
+
// Semantic surface descriptors
|
|
271
|
+
console.log('Primary Objects:', merged.primary);
|
|
272
|
+
// Output:
|
|
273
|
+
// Primary Subjects: ['https://example.com/blog/post1', 'https://example.com/blog/post2']
|
|
274
|
+
// Primary Objects: [
|
|
275
|
+
// { subject: 'https://example.com/blog/post1', type: 'http://schema.org/BlogPosting', label: 'My First Post' },
|
|
276
|
+
// { subject: 'https://example.com/blog/post2', type: 'http://schema.org/BlogPosting', label: 'My Second Post' }
|
|
277
|
+
// ]
|
|
226
278
|
```
|
|
227
279
|
|
|
228
280
|
## Document Identity Trio
|
|
@@ -232,19 +284,42 @@ The primary metadata trio provides sufficient document/append stream identity fo
|
|
|
232
284
|
```javascript
|
|
233
285
|
// Nostr integration example
|
|
234
286
|
const nostrTags = [
|
|
235
|
-
['s', result.primarySubject],
|
|
236
|
-
['t', result.
|
|
237
|
-
['d', result.
|
|
287
|
+
['s', result.primarySubject], // subject addressing (canonical)
|
|
288
|
+
['t', result.primary.type], // type filtering
|
|
289
|
+
['d', result.primary.label] // display identifier
|
|
238
290
|
];
|
|
239
291
|
|
|
240
292
|
// Document fingerprint
|
|
241
293
|
const fingerprint = {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
label: result.primaryLabel // Human-readable name
|
|
294
|
+
canonical: result.primarySubject, // What the document is about (append identity)
|
|
295
|
+
semantic: result.primary // How to present and index the document
|
|
245
296
|
};
|
|
246
297
|
```
|
|
247
298
|
|
|
299
|
+
## Primary Metadata is Parser-Level Metadata
|
|
300
|
+
|
|
301
|
+
**Important**: Primary metadata is derived parser state and does not introduce additional RDF triples or semantic entailments. It describes document intent, not graph semantics.
|
|
302
|
+
|
|
303
|
+
### Key Distinctions
|
|
304
|
+
|
|
305
|
+
| Aspect | Primary Metadata | RDF Semantics |
|
|
306
|
+
|---------|------------------|----------------|
|
|
307
|
+
| **Source** | Parser extraction rules | Triple patterns |
|
|
308
|
+
| **Scope** | Document-level intent | Graph-level relationships |
|
|
309
|
+
| **Purpose** | Routing, UI, indexing | Reasoning, inference |
|
|
310
|
+
| **Stability** | Deterministic extraction | Dynamic inference |
|
|
311
|
+
|
|
312
|
+
### Stability Guarantees
|
|
313
|
+
|
|
314
|
+
`primarySubject` is **stable under rewrite() operations that preserve extracted quads**. This means:
|
|
315
|
+
|
|
316
|
+
- Append routing remains consistent across document updates
|
|
317
|
+
- Synchronization identity is preserved during merges
|
|
318
|
+
- File mapping stays stable through rewrite operations
|
|
319
|
+
- Index references remain valid
|
|
320
|
+
|
|
321
|
+
This stability is crucial for distributed systems and local-first architectures.
|
|
322
|
+
|
|
248
323
|
## Specification
|
|
249
324
|
|
|
250
325
|
For complete details on Primary Subject semantics, see the [MD-LD Specification](../spec/Spec.md#17-primary-subject).
|
package/dist/index.html
CHANGED
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
|
|
31
31
|
|
|
32
32
|
<script type="module" crossorigin>var e=Object.defineProperty,t=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),n=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var r={"@vocab":`http://www.w3.org/2000/01/rdf-schema#`,rdf:`http://www.w3.org/1999/02/22-rdf-syntax-ns#`,rdfs:`http://www.w3.org/2000/01/rdf-schema#`,xsd:`http://www.w3.org/2001/XMLSchema#`,sh:`http://www.w3.org/ns/shacl#`,prov:`http://www.w3.org/ns/prov#`},i=/^(https?|ftp|mailto|tag|nih|urn|uuid|did|web|ipfs|ipns|data|file|urn:uuid):/,a=/^(https?|ftp|mailto|tag|nih|urn|uuid|did|web|ipfs|ipns|data|file):/,o=class{constructor(e){this.id=e}equals(e){return!!e&&this.termType===e.termType&&this.value===e.value}},s=class extends o{constructor(e){super(e),this.termType=`NamedNode`,this.value=e}},c=class extends o{constructor(e){super(e),this.termType=`Literal`,this.value=``,this.language=``,this.datatype=null;let t=e.match(/^"([^"\\]*(?:\\.[^"\\]*)*)"(\^\^([^"]+))?(@([^-]+)(--(.+))?)?$/);t?(this.value=t[1].replace(/\\"/g,`"`).replace(/\\\\/g,`\\`),t[5]?(this.language=t[5],this.datatype=new s(`http://www.w3.org/1999/02/22-rdf-syntax-ns#langString`)):t[3]?this.datatype=new s(t[3]):this.datatype=new s(`http://www.w3.org/2001/XMLSchema#string`)):(this.value=e.replace(/^"|"$/g,``),this.datatype=new s(`http://www.w3.org/2001/XMLSchema#string`))}equals(e){return!!e&&this.termType===e.termType&&this.value===e.value&&this.language===e.language&&this.datatype?.value===e.datatype?.value}},l=class extends o{constructor(e){super(e||`b${Math.random().toString(36).slice(2,11)}`),this.termType=`BlankNode`,this.value=this.id}},u=class extends o{constructor(e){super(e),this.termType=`Variable`,this.value=e}},d=new class extends o{constructor(){super(``),this.termType=`DefaultGraph`,this.value=``}equals(e){return!!e&&this.termType===e.termType}},f=class extends o{constructor(e,t,n,r=d){super(`${e.id}|${t.id}|${n.id}|${r.id}`),this.termType=`Quad`,this.subject=e,this.predicate=t,this.object=n,this.graph=r}equals(e){return!!e&&this.termType===e.termType&&this.subject.equals(e.subject)&&this.predicate.equals(e.predicate)&&this.object.equals(e.object)&&this.graph.equals(e.graph)}toJSON(){return{termType:this.termType,subject:this.subject.toJSON?this.subject.toJSON():{termType:this.subject.termType,value:this.subject.value},predicate:this.predicate.toJSON?this.predicate.toJSON():{termType:this.predicate.termType,value:this.predicate.value},object:this.object.toJSON?this.object.toJSON():{termType:this.object.termType,value:this.object.value},graph:this.graph.toJSON?this.graph.toJSON():{termType:this.graph.termType,value:this.graph.value}}}},p={boolean:`http://www.w3.org/2001/XMLSchema#boolean`,integer:`http://www.w3.org/2001/XMLSchema#integer`,double:`http://www.w3.org/2001/XMLSchema#double`,string:`http://www.w3.org/2001/XMLSchema#string`},m={namedNode:e=>new s(e),blankNode:e=>new l(e),literal:(e,t)=>{let n=String(e).replace(/"/g,`\\"`);if(typeof t==`string`)return new c(`"${n}"@${t.toLowerCase()}`);if(t!==void 0&&!(`termType`in t)){let e=t.direction?`--${t.direction.toLowerCase()}`:``;return new c(`"${n}"@${t.language.toLowerCase()}${e}`)}let r=t?t.value:``;return r===``&&(typeof e==`boolean`?r=p.boolean:typeof e==`number`&&(Number.isFinite(e)?r=Number.isInteger(e)?p.integer:p.double:(r=p.double,Number.isNaN(e)||(e=e>0?`INF`:`-INF`)))),r===``||r===p.string?new c(`"${n}"`):new c(`"${n}"^^${r}`)},variable:e=>new u(e),defaultGraph:()=>d,quad:(e,t,n,r)=>new f(e,t,n,r),triple:(e,t,n,r)=>new f(e,t,n,r),fromTerm:e=>{if(e instanceof o)return e;switch(e.termType){case`NamedNode`:return new s(e.value);case`BlankNode`:return new l(e.value);case`Variable`:return new u(e.value);case`DefaultGraph`:return d;case`Literal`:let t=String(e.value).replace(/"/g,`\\"`);return e.language?new c(`"${t}"@${e.language}`):e.datatype?new c(`"${t}"^^${e.datatype.value||e.datatype}`):new c(`"${t}"`);case`Quad`:return m.fromQuad(e);default:throw Error(`Unexpected termType: ${e.termType}`)}},fromQuad:e=>{if(e instanceof f)return e;if(e.termType!==`Quad`){if(e.subject&&e.predicate&&e.object)return new f(m.fromTerm(e.subject),m.fromTerm(e.predicate),m.fromTerm(e.object),m.fromTerm(e.graph||m.defaultGraph()));throw Error(`Unexpected termType: ${e.termType}`)}return new f(m.fromTerm(e.subject),m.fromTerm(e.predicate),m.fromTerm(e.object),m.fromTerm(e.graph))}};function h(e,t){if(!e||!t||!t.quadIndex)return null;let n=C(e);return n&&t.quadIndex.get(n)||null}function g(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n);return Math.abs(t).toString(16).slice(0,12)}var _=new Map;function v(e,t){if(e==null)return null;let n=`${e}|${t[`@vocab`]||``}|${Object.keys(t).filter(e=>e!==`@vocab`).sort().map(e=>`${e}:${t[e]}`).join(`,`)}`;if(_.has(n))return _.get(n);let r=(typeof e==`string`?e:typeof e==`object`&&typeof e.value==`string`?e.value:String(e)).trim(),a;if(r.match(i))a=r;else if(r.includes(`:`)){let[e,n]=r.split(`:`,2);e&&!t[e]&&e!==`@vocab`&&console.warn(`Undefined prefix "${e}" in IRI "${r}" - treating as literal`),a=t[e]?t[e]+n:r}else a=(t[`@vocab`]||``)+r;return _.set(n,a),a}function y(e,t){if(!e||!a.test(e))return e;if(t[`@vocab`]&&e.startsWith(t[`@vocab`]))return e.substring(t[`@vocab`].length);for(let[n,r]of Object.entries(t))if(n!==`@vocab`&&e.startsWith(r)&&Object.entries(t).filter(([t,n])=>t!==`@vocab`&&e.startsWith(n)).every(([e,t])=>r.length>=t.length||e===n&&t.length===r.length))return n+`:`+e.substring(r.length);return e}var b={"=#":{kind:`fragment`,extract:e=>e.substring(2).replace(`}`,``)},"+#":{kind:`softFragment`,extract:e=>e.substring(2).replace(`}`,``)},"+":{kind:`object`,extract:e=>e.substring(1)},"^^":{kind:`datatype`,extract:e=>e.substring(2)},"@":{kind:`language`,extract:e=>e.substring(1)},".":{kind:`type`,extract:e=>e.substring(1)},"!":{kind:`property`,form:`!`,extract:e=>e.substring(1)},"?":{kind:`property`,form:`?`,extract:e=>e.substring(1)}};function x(e){try{let t=String(e||``).trim().replace(/^\{|\}$/g,``).trim();if(!t)return{subject:null,object:null,types:[],predicates:[],datatype:null,language:null,entries:[]};let n={subject:null,object:null,types:[],predicates:[],datatype:null,language:null,entries:[]},r=/\S+/g,i;for(;(i=r.exec(t))!==null;){let e=i[0],t=1+i.index,r=t+e.length,a=n.entries.length,o=!1;if(e.startsWith(`-`)&&e.length>1&&(o=!0,e=e.slice(1)),e===`=`){o&&console.warn(`-= is not valid, subject declarations have no polarity`),n.subject=`RESET`,n.entries.push({kind:`subjectReset`,relRange:{start:t,end:r},raw:e});continue}if(e.startsWith(`=`)&&!e.startsWith(`=#`)){o&&console.warn(`-= is not valid, subject declarations have no polarity`);let i=e.substring(1);n.subject=i,n.entries.push({kind:`subject`,iri:i,relRange:{start:t,end:r},raw:e});continue}let s=!1;for(let[c,l]of Object.entries(b))if(e.startsWith(c)){let c={kind:l.kind,relRange:{start:t,end:r},raw:i[0]},u=l.extract(e);l.kind===`fragment`?(n.subject=`=#${u}`,c.fragment=u):l.kind===`softFragment`?(n.object=`#${u}`,c.fragment=u):l.kind===`object`?(o&&=(console.warn(`-+ is not valid, object declarations have no polarity`),!1),n.object=u,c.iri=u):l.kind===`datatype`?(o&&=(console.warn(`-^^ is not valid, datatype modifiers have no polarity`),!1),n.language||(n.datatype=u),c.datatype=u):l.kind===`language`?(o&&=(console.warn(`-@ is not valid, language modifiers have no polarity`),!1),n.language=u,n.datatype=null,c.language=u):l.kind===`type`?(n.types.push({iri:u,entryIndex:a,remove:o}),c.iri=u,c.remove=o):l.kind===`property`&&(n.predicates.push({iri:u,form:l.form,entryIndex:a,remove:o}),c.iri=u,c.form=l.form,c.remove=o),n.entries.push(c),s=!0;break}s||(n.predicates.push({iri:e,form:``,entryIndex:a,remove:o}),n.entries.push({kind:`property`,iri:e,form:``,relRange:{start:t,end:r},raw:i[0],remove:o}))}return n}catch(t){return console.error(`Error parsing semantic block ${e}:`,t),{subject:null,object:null,types:[],predicates:[],datatype:null,language:null,entries:[]}}}function S(e,t,n){let r=n.termType===`Literal`?JSON.stringify({t:`Literal`,v:n.value,lang:n.language||``,dt:n.datatype?.value||``}):JSON.stringify({t:n.termType,v:n.value});return JSON.stringify([e.value,t.value,r])}function C(e){return e?S(e.subject,e.predicate,e.object):null}function w(e,t,n,r,i){return t?i.literal(e,i.namedNode(v(t,r))):n?i.literal(e,n):i.literal(e)}function T(e){if(e.length<3)return null;let t=e[0];if(t!=="`"&&t!==`~`)return null;let n=1;for(;n<e.length&&e[n]===t;)n++;if(n<3)return null;let r=e.slice(n).trimStart(),i=r.match(/^([^\s{]+)/),a=i?i[1]:``,o=r.match(/\{([^}]+)\}/),s=o?o[1]:null;return{fenceChar:t,fenceLength:n,lang:a,attrs:s,infoString:r}}function E(e){if(e[0]!==`[`)return null;let t=e.indexOf(`]`,1);if(t===-1)return null;let n=e.slice(1,t).trim();if(!n)return null;let r=t+1;for(;r<e.length&&(e[r]===` `||e[r]===` `);)r++;if(r>=e.length||e[r]!==`<`)return null;let i=e.indexOf(`>`,r+1);if(i===-1)return null;let a=e.slice(r+1,i).trim();return a?{prefix:n,iri:a}:null}function D(e){if(e[0]!==`#`)return null;let t=1;for(;t<e.length&&t<6&&e[t]===`#`;)t++;if(t>=e.length||e[t]!==` `&&e[t]!==` `)return null;let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;let r=e.slice(n),i=r.match(/\s*\{([^}]+)\}\s*$/),a=r,o=null;return i&&(o=i[1],a=r.slice(0,-i[0].length).trim()),{depth:t,content:a,attrs:o}}function ee(e){let t=0;for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;let n=t;if(t>=e.length)return null;let r=e[t],i,a=t+1;if(r===`-`||r===`*`||r===`+`)i=r;else if(r>=`0`&&r<=`9`){let n=t+1;for(;n<e.length&&e[n]>=`0`&&e[n]<=`9`;)n++;if(n>=e.length||e[n]!==`.`)return null;i=e.slice(t,n+1),a=n+1}else return null;if(a>=e.length||e[a]!==` `&&e[a]!==` `)return null;for(;a<e.length&&(e[a]===` `||e[a]===` `);)a++;let o=e.slice(a),s=null,c=o.match(/\s*\{([^}]+)\}\s*$/);return c&&(s=c[1],o=o.slice(0,-c[0].length).trim()),{indent:n,marker:i,content:o,attrs:s}}function O(e){if(e[0]!==`>`||e.length>1&&e[1]!==` `&&e[1]!==` `)return null;let t=1;for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;let n=e.slice(t),r=null,i=n.match(/\s*\{([^}]+)\}\s*$/);return i&&(r=i[1],n=n.slice(0,-i[0].length).trim()),{content:n,attrs:r}}function k(e){let t=0;for(;t<e.length&&(e[t]===` `||e[t]===` `);)t++;if(t>=e.length||e[t]!==`{`||(t++,t>=e.length||e[t]!==`=`))return null;t++;let n=t,r=1;for(;t<e.length&&r>0;)e[t]===`{`&&r++,e[t]===`}`&&r--,r>0&&t++;if(r>0)return null;let i=e.slice(n,t).trim();for(t++;t<e.length&&(e[t]===` `||e[t]===` `);)t++;return t<e.length?null:{content:i}}function A(e,t,n=`[`,r=`]`){let i=1,a=t+1;for(;a<e.length&&i>0;)e[a]===n&&i++,e[a]===r&&i--,i>0&&a++;return i===0?a:null}function j(e,t){let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;if(n>=e.length||e[n]!==`{`)return null;let r=e.indexOf(`}`,n+1);return r===-1?null:{attrs:e.slice(n+1,r),endPos:r+1}}function M(e,t){if(e[t]!==`<`)return null;let n=e.indexOf(`>`,t+1);if(n===-1)return null;let r=e.slice(t+1,n).trim();return r.match(/^[a-zA-Z][a-zA-Z0-9+\-.]*:/)?{url:r,endPos:n+1}:null}function N(e,t){let n=e[t];if(n!==`*`&&n!==`_`)return null;let r=1;for(;t+r<e.length&&e[t+r]===n;)r++;if(r>2)return null;let i=r===1?`emphasis`:`strong`,a=n.repeat(r),o=t+r,s=o;for(;s<e.length;){if(e.slice(s,s+r)===a){if(s+r<e.length&&e[s+r]===n){s++;continue}let t=e.slice(o,s),a=s+r,c=j(e,a),l=c?c.endPos:a;return{type:i,content:t,attrs:c?.attrs||null,endPos:l,contentEnd:a}}s++}return null}function P(e,t){if(e[t]!=="`")return null;let n=1;for(;t+n<e.length&&e[t+n]==="`";)n++;if(n>2)return null;let r="`".repeat(n),i=t+n,a=i;for(;a<e.length;){if(e.slice(a,a+n)===r){let t=e.slice(i,a),r=a+n,o=j(e,r),s=o?o.endPos:r;return{type:`code`,content:t,attrs:o?.attrs||null,endPos:s,contentEnd:r}}a++}return null}function te(e,t){if(e[t]!==`[`)return null;let n=A(e,t,`[`,`]`);if(!n)return null;let r=e.slice(t+1,n),i=n+1,a=null;if(i<e.length&&e[i]===`(`){let t=e.indexOf(`)`,i+1);t!==-1&&(a=e.slice(i+1,t),i=t+1)}else if(i<e.length&&e[i]===`<`){let t=e.indexOf(`>`,i+1);if(t!==-1){let n=e.slice(i+1,t).trim();n.match(/^[a-zA-Z][a-zA-Z0-9+\-.]*:/)&&(a=n,i=t+1)}}let o=j(e,i),s=o?o.endPos:i;return{type:a?`link`:`span`,text:r,url:a,attrs:o?.attrs||null,endPos:s,bracketEnd:n+1}}function F(e,t=0){let n=[],r=e.length,i=0;for(;i<r;){let r=e[i],a=null;switch(r){case`<`:if(a=M(e,i),a){let t=j(e,a.endPos);t&&(a.attrs=t.attrs,a.endPos=t.endPos),a.type=`link`,a.text=a.url}break;case`[`:a=te(e,i);break;case`*`:case`_`:a=N(e,i);break;case"`":a=P(e,i);break}if(!a){i++;continue}let o=a.url,s=a.type,c=a.attrs;if(o?.startsWith(`=`)||s===`link`&&!c&&!o){i=a.endPos;continue}let l=t+i,u=t+a.endPos,d=t+(a.contentEnd||a.bracketEnd||a.endPos),f={type:s,text:a.content===void 0?a.text===void 0?o:a.text:a.content,range:[l,u],valueRange:[l+ +(s===`url`),d-+(s===`url`)],attrs:c,url:o,pos:a.endPos};c&&(f.attrsRange=[d,u]),n.push(f),i=a.endPos}return n}var I=new Map;function ne(e){return I.has(e)||I.set(e,RegExp(`^(${e}{3,})`)),I.get(e)}function re(e,t,n,r,i){let a=r+(r<e.length&&e[r]===` `?1:e.slice(r).match(/^\s+/)?.[0]?.length||0);return{valueRange:[n+a,n+a+i],attrsRange:L(e,t,n)}}function L(e,t,n){if(!t)return null;let r=e.lastIndexOf(t);return r>=0?[n+r,n+r+t.length]:null}function R(e,t,n,r=null,i=null,a=null,o={}){let s={type:e,range:t,text:n,attrs:r,attrsRange:i,valueRange:a,...o};return Object.defineProperty(s,`_carriers`,{enumerable:!1,writable:!0,value:null}),s}function ie(e,t,n,r,i){let a=i[4]||null,o=re(t,a,n,i[1].length+(i[2]?i[2].length:0),i[3].length);return R(e,[n,r-1],i[3].trim(),a,o.attrsRange,o.valueRange,{indent:i[1].length})}var z={},ae=Object.freeze({predicates:[],types:[],subject:null});function oe(e){if(!e)return ae;let t=z[e];return t||(t=Object.freeze(x(e)),z[e]=t),t}function se(e){if(!e.text)return``;let t=e.text;e.attrsRange&&(t=t.substring(0,e.attrsRange[0]-(e.range?.[0]||0))+t.substring(e.attrsRange[1]-(e.range?.[0]||0)));let n=(e._carriers||[]).filter(e=>e.attrsRange).map(t=>t.attrsRange.map(t=>t-(e.range?.[0]||0))).filter(([e,n])=>e>=0&&n<=t.length).sort((e,t)=>t[0]-e[0]);for(let[e,r]of n)t=t.substring(0,e)+t.substring(r);switch(e.type){case`heading`:return t.replace(/^#+\s*/,``).trim();case`list`:return t.replace(/^[-*+]\s*/,``).trim();case`blockquote`:return t.replace(/^>\s*/,``).trim();default:return t.trim()}}function ce(e,t,n,r=null){return{blockId:e.id,range:e.range,carrierType:e.carrierType,subject:t.value,predicate:n.value,context:e.context,polarity:r?.remove?`-`:`+`,value:e.text||``}}function le(e,t,n){if(!t)return null;let r=t.value,i=r.indexOf(`#`),a=i>-1?r.slice(0,i):r;return n.namedNode(a+`#`+e)}function ue(e,t){return e.subject?e.subject===`RESET`?(t.currentSubject=null,null):e.subject.startsWith(`=#`)?le(e.subject.substring(2),t.currentSubject,t.df):t.df.namedNode(v(e.subject,t.ctx)):null}function de(e,t){return e.object?e.object.startsWith(`#`)?le(e.object.substring(1),t.currentSubject,t.df):t.df.namedNode(v(e.object,t.ctx)):null}function fe(e){return e?.termType===`Literal`}function pe(e){return e?.termType===`NamedNode`}function me(e){return e?.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`}function he(e,t){if(!e)return null;let n=y(e,t);return n.includes(`:`)?n.split(`:`)[0]:null}function ge(e,t){let n=new Set;for(let r of e.values())for(let e of r){let r=he(e.subject.value,t);r&&n.add(r);let i=he(e.predicate.value,t);if(i&&n.add(i),pe(e.object)){let r=he(e.object.value,t);r&&n.add(r)}if(e.object.datatype&&e.object.datatype.value){let r=he(e.object.datatype.value,t);r&&n.add(r)}}return n}function _e(e,t,n,r,i=[]){let a=r(e,t);t.currentBlock=a,t.blockStack.push(a.id),i.forEach(n=>n(e,t)),n(e,t,e.type),t.blockStack.pop(),t.currentBlock=t.blockStack.length>0?t.origin.blocks.get(t.blockStack[t.blockStack.length-1]):null}function B(e){return e.sort((e,t)=>e.predicate.value.localeCompare(t.predicate.value))}var ve=(e,t)=>`[${e}] <${t}>\n`;function V(e,t){let n=y(e.predicate.value,t);e.object.language?n+=` @${e.object.language}`:e.object.datatype.value!==`http://www.w3.org/2001/XMLSchema#string`&&(n+=` ^^${y(e.object.datatype.value,t)}`);let r=e.object.value||e.object,i=typeof r==`string`?r:String(r),a=e.object.datatype?.value||``;return i.includes(`
|
|
33
|
-
`)?`~~~ {${n}}\n${i}\n~~~\n\n`:a.includes(`integer`)||a.includes(`decimal`)||a.includes(`double`)||a.includes(`float`)?`\`${i}\` {${n}}\n`:a.includes(`date`)||a.includes(`time`)?`*${i}* {${n}}\n`:a.includes(`boolean`)?`**${i}** {${n}}\n`:`[${i}] {${n}}\n`}var ye=(e,t,n=null)=>{let r=y(e.object.value,t),i=y(e.predicate.value,t);return`[${n&&n.has(e.object.value)?n.get(e.object.value):r}] {+${r} ?${i}}\n`};function be(e){let t=[],n=[],r=[];for(let i of e)me(i.predicate)?t.push(i):fe(i.object)?n.push(i):pe(i.object)&&r.push(i);return{types:t,literals:n,objects:r}}function H(e,t={}){let n=typeof e==`object`&&!!e&&`text`in e,i=n?e.text:e,a=n?{context:e.context,dataFactory:e.dataFactory,graph:e.graph}:t,o={ctx:{...r,...a.context||{}},df:a.dataFactory||m,graph:a.graph?m.namedNode(a.graph):m.defaultGraph(),quads:[],quadBuffer:new Map,removeSet:new Set,origin:{quadIndex:new Map,blocks:new Map,documentStructure:[]},currentSubject:null,primarySubject:null,primaryType:null,primaryLabel:null,tokens:null,currentTokenIndex:-1,statements:[],statementCandidates:new Map,currentBlock:null,blockStack:[]},s=Se(i);o.tokens=s.tokens;for(let e=0;e<o.tokens.length;e++){let t=o.tokens[e];if(o.currentTokenIndex=e,t.type===`prefix`){let e=t.iri;if(t.iri.includes(`:`)){let n=t.iri.indexOf(`:`),r=t.iri.substring(0,n),i=t.iri.substring(n+1);o.ctx[r]&&r!==`@vocab`&&(e=o.ctx[r]+i)}o.ctx[t.prefix]=e;continue}Le[t.type]?.(t,o)}let c=new Set;for(let e of o.quads)c.add(S(e.subject,e.predicate,e.object));let l=[];for(let e of o.removeSet){let t=S(e.subject,e.predicate,e.object);c.has(t)||l.push(e)}return{quads:o.quads,remove:l,statements:o.statements,origin:o.origin,context:o.ctx,primarySubject:o.primarySubject,
|
|
33
|
+
`)?`~~~ {${n}}\n${i}\n~~~\n\n`:a.includes(`integer`)||a.includes(`decimal`)||a.includes(`double`)||a.includes(`float`)?`\`${i}\` {${n}}\n`:a.includes(`date`)||a.includes(`time`)?`*${i}* {${n}}\n`:a.includes(`boolean`)?`**${i}** {${n}}\n`:`[${i}] {${n}}\n`}var ye=(e,t,n=null)=>{let r=y(e.object.value,t),i=y(e.predicate.value,t);return`[${n&&n.has(e.object.value)?n.get(e.object.value):r}] {+${r} ?${i}}\n`};function be(e){let t=[],n=[],r=[];for(let i of e)me(i.predicate)?t.push(i):fe(i.object)?n.push(i):pe(i.object)&&r.push(i);return{types:t,literals:n,objects:r}}function H(e,t={}){let n=typeof e==`object`&&!!e&&`text`in e,i=n?e.text:e,a=n?{context:e.context,dataFactory:e.dataFactory,graph:e.graph}:t,o={ctx:{...r,...a.context||{}},df:a.dataFactory||m,graph:a.graph?m.namedNode(a.graph):m.defaultGraph(),quads:[],quadBuffer:new Map,removeSet:new Set,origin:{quadIndex:new Map,blocks:new Map,documentStructure:[]},currentSubject:null,primarySubject:null,primaryType:null,primaryLabel:null,tokens:null,currentTokenIndex:-1,statements:[],statementCandidates:new Map,currentBlock:null,blockStack:[]},s=Se(i);o.tokens=s.tokens;for(let e=0;e<o.tokens.length;e++){let t=o.tokens[e];if(o.currentTokenIndex=e,t.type===`prefix`){let e=t.iri;if(t.iri.includes(`:`)){let n=t.iri.indexOf(`:`),r=t.iri.substring(0,n),i=t.iri.substring(n+1);o.ctx[r]&&r!==`@vocab`&&(e=o.ctx[r]+i)}o.ctx[t.prefix]=e;continue}Le[t.type]?.(t,o)}let c=new Set;for(let e of o.quads)c.add(S(e.subject,e.predicate,e.object));let l=[];for(let e of o.removeSet){let t=S(e.subject,e.predicate,e.object);c.has(t)||l.push(e)}let u={subject:o.primarySubject,type:o.primaryType,label:o.primaryLabel};return{quads:o.quads,remove:l,statements:o.statements,origin:o.origin,context:o.ctx,primarySubject:o.primarySubject,primary:u,md:s.md}}function xe(e){return e.type===`code`?[]:e._carriers||=Ce(e.text,e.range[0])}function Se(e){let t=[],n=[],r=e.split(`
|
|
34
34
|
`),i=0,a=null,o=[{type:`fence`,test:e=>T(e.trim()),process:s},{type:`content`,test:()=>a,process:e=>a.content.push(e)},{type:`prefix`,test:e=>E(e),process:c},{type:`standalone`,test:e=>k(e),process:p},{type:`heading`,test:e=>D(e),process:l},{type:`list`,test:e=>ee(e),process:u},{type:`blockquote`,test:e=>O(e),process:d},{type:`para`,test:e=>e.trim(),process:f}];function s(e,r,i){let o=e.trim();if(a){let i=a.fence[0],s=i.repeat(a.fence.length),c=o.match(ne(i));if(c&&c[1]===s){let i=a.valueRangeStart,o=Math.max(i,r-1);t.push({type:`code`,range:[a.start,r],text:a.content.join(`
|
|
35
35
|
`),lang:a.lang,attrs:a.attrs,attrsRange:a.attrsRange,valueRange:[i,o]});for(let e of a.content)n.push(e);a=null;let s=e.replace(/\r?\n.*$/,``);n.push(s)}}else{let t=T(o);if(!t)return!1;let i=t.attrs,s=i?e.indexOf(i):-1,c=r+e.length+1;a={fence:t.fenceChar.repeat(t.fenceLength),start:r,content:[],lang:t.lang,attrs:i,attrsRange:i&&s>=0?[r+s,r+s+i.length]:null,valueRangeStart:c};let l=e.replace(/\s*\{[^}]+\}\s*$/,``);n.push(l)}return!0}function c(e,n,r){let i=E(e);return t.push({type:`prefix`,prefix:i.prefix,iri:i.iri}),!0}function l(e,r,i){let a=D(e),o=a.attrs,s=a.depth,c=re(e,o,r,s,a.content.length);t.push(R(`heading`,[r,i-1],a.content,o,c.attrsRange,c.valueRange,{depth:a.depth}));let l=`${`#`.repeat(a.depth)} ${a.content}`;return n.push(l),!0}function u(e,r,i){let a=ee(e),o=` `.repeat(a.indent),s=[e,o,a.marker,a.content,a.attrs];t.push(ie(`list`,e,r,i,s));let c=`${o}${a.marker} ${a.content}`;return n.push(c),!0}function d(e,r,i){let a=O(e),o=a.attrs,s=e.startsWith(`> `)?2:e.indexOf(`>`)+1,c=s+a.content.length;t.push(R(`blockquote`,[r,i-1],a.content,o,L(e,o,r),[r+s,r+c]));let l=`> ${a.content}`;return n.push(l),!0}function f(e,r,i){t.push(R(`para`,[r,i-1],e.trim()));let a=e,o=F(a,0);for(let e of o)if(e.attrs&&(e.type===`emphasis`||e.type===`code`)){let t=a.substring(0,e.range[0]),n=a.substring(e.range[1]);a=t+(e.text||``)+n}return a=a.replace(/\[([^\]]+)\]\s*\{[^}]+\}/g,`$1`),a=a.replace(/\s*\{[^}]+\}\s*/g,` `),a=a.replace(/\s+/g,` `).trim(),n.push(a),!0}function p(e,n,r){return t.push({type:`standalone`,text:e.trim(),range:[n,r-1]}),!0}for(let e=0;e<r.length;e++){let t=r[e],n=i;i+=t.length+1;for(let e of o)if(e.test(t)&&e.process(t,n,i))break}return{tokens:t,md:n.join(`
|
|
36
|
-
`)}}function Ce(e,t=0){return F(e,t)}function we(e,t){let n=e._blockId||g(`${e.type}:${e.range?.[0]}:${e.range?.[1]}`);e._blockId=n;let r=xe(e),i=se(e),a={id:n,type:e.type,range:e.range,text:i,subject:null,types:[],predicates:[],carriers:[],listLevel:e.indent||0,parentBlockId:t.blockStack.length>0?t.blockStack[t.blockStack.length-1]:null,quadKeys:[]};for(let e of r){let t={type:e.type,range:e.range,text:e.text,subject:null,predicates:[],sem:null};if(e.attrs){let n=oe(e.attrs);t.sem=n,t.predicates=n.predicates||[],t.subject=n.subject,t.types=n.types||[]}a.carriers.push(t)}return t.origin.blocks.set(n,a),t.origin.documentStructure.push(a),a}function Te(e,t,n,r){if(t.subject&&t.subject!==`RESET`){let n=ue(t,r);n&&(e.subject=n.value)}if(t.types&&t.types.length>0&&t.types.forEach(t=>{let n=v(typeof t==`string`?t:t.iri,r.ctx);e.types.includes(n)||e.types.push(n)}),t.predicates&&t.predicates.length>0&&t.predicates.forEach(t=>{let n={iri:v(t.iri,r.ctx),form:t.form||``,object:null};e.predicates.push(n)}),n){let t={type:n.type,range:n.range,text:n.text,subject:null,predicates:[]};if(n.attrs){let e=oe(n.attrs);t.sem=e,t.predicates=e.predicates||[],t.subject=e.subject,t.types=e.types||[]}e.carriers.push(t)}}function Ee(e,t,n,r={}){let{preserveGlobalSubject:i=!1,implicitSubject:a=null}=r;if(t.subject===`RESET`){n.currentSubject=null;return}let o=n.currentSubject,s=ue(t,n),c=de(t,n);s&&!n.primarySubject&&!t.subject.startsWith(`=#`)&&(n.primarySubject=s.value),s&&!i&&!a&&(n.currentSubject=s);let l=i?s||o:a||n.currentSubject;if(!l)return;let u=De(l.value,t.types,t.predicates,e.range,e.attrsRange||null,e.valueRange||null,e.type||null,n.ctx,e.text),d=w(e.text,t.datatype,t.language,n.ctx,n.df),f=e.url?n.df.namedNode(v(e.url,n.ctx)):null,p=s||f;n.currentBlock&&Te(n.currentBlock,t,e,n),je(t,s,c,f,l,u,n,e),Ne(t,s,o,c,p,l,d,u,n,e)}function De(e,t,n,r,i,a,o,s,c){let l={subject:e,types:t.map(e=>v(typeof e==`string`?e:e.iri,s)),predicates:n.map(e=>({iri:v(e.iri,s),form:e.form}))};return{id:g([e,o||`unknown`,l.types.join(`,`),l.predicates.map(e=>`${e.form}${e.iri}`).join(`,`)].join(`|`)),range:{start:r[0],end:r[1]},carrierType:o||null,subject:e,types:l.types,predicates:l.predicates,context:s,text:c||``}}function Oe(e,t,n,r,i,a,o,s,c,l=null,u=null,d=null,f=null){if(!a||!o||!s)return;let p=c.quad(a,o,s);if(l?.remove){let i=S(p.subject,p.predicate,p.object);if(t.has(i)){t.delete(i);let n=e.findIndex(e=>e.subject.value===p.subject.value&&e.predicate.value===p.predicate.value&&e.object.value===p.object.value);n!==-1&&e.splice(n,1),r.delete(i)}else n.add(p)}else{let n=S(p.subject,p.predicate,p.object);t.set(n,p),e.push(p),f&&(!f.primaryType&&o.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`&&(f.primaryType=s.value),!f.primaryLabel&&o.value===`http://www.w3.org/2000/01/rdf-schema#label`&&s.termType===`Literal`&&(f.primaryLabel=s.value)),ke(p,c,l,u,d);let m=ce(i,a,o,l);r.set(n,m),f.currentBlock&&i.id===f.currentBlock.id&&(f.currentBlock.quadKeys||(f.currentBlock.quadKeys=[]),f.currentBlock.quadKeys.push(n))}}function ke(e,t,n,r=null,i=null){if(!r||!i)return;let a=e.predicate.value;if(a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`&&a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#subject`&&a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate`&&a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#object`)return;if(a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`&&e.object.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement`){i.set(e.subject.value,{spo:{}});return}let o=i.get(e.subject.value);if(o&&(a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#subject`?o.spo.subject=e.object:a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate`?o.spo.predicate=e.object:a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#object`&&(o.spo.object=e.object,o.objectQuad=e),o.spo.subject&&o.spo.predicate&&o.spo.object)){let n=t.quad(o.spo.subject,o.spo.predicate,o.spo.object);r.push(n),i.delete(e.subject.value)}}var Ae=(e,t,n,r,i=null)=>{let a=v(e,n.ctx),o=typeof i==`object`?i:{entryIndex:i,remove:!1};Oe(n.quads,n.quadBuffer,n.removeSet,n.origin.quadIndex,r,t,n.df.namedNode(v(`rdf:type`,n.ctx)),n.df.namedNode(a),n.df,{kind:`type`,token:`.${e}`,expandedType:a,entryIndex:o.entryIndex,remove:o.remove},n.statements,n.statementCandidates,n)};function je(e,t,n,r,i,a,o,s){e.types.forEach(e=>{Ae(typeof e==`string`?e:e.iri,t||n||r||i,o,a,typeof e==`string`?{entryIndex:null,remove:!1}:e)})}var Me=(e,t,n,r,i,a,o,s)=>{if(e.form===``&&t?.type===`link`&&t?.url&&t.text===t.url)return null;switch(e.form){case``:return n?{subject:i||o,object:s}:t?.type===`link`&&t?.url&&t.text!==t.url?{subject:a,object:s}:{subject:i||o,object:s};case`?`:return{subject:n?r:o,object:i||a};case`!`:return{subject:i||a,object:n?r:o};default:return null}};function Ne(e,t,n,r,i,a,o,s,c,l){e.predicates.forEach(e=>{let u=Me(e,l,t,n,r,i,a,o);if(u){let t=c.df.namedNode(v(e.iri,c.ctx));Oe(c.quads,c.quadBuffer,c.removeSet,c.origin.quadIndex,s,u.subject,t,u.object,c.df,{kind:`pred`,token:`${e.form}${e.iri}`,form:e.form,expandedPredicate:t.value,entryIndex:e.entryIndex,remove:e.remove||!1},c.statements,c.statementCandidates,c)}})}function Pe(e,t,n,r={}){Ee(e,t,n,r)}function Fe(e,t,n){if(e.attrs){let r=oe(e.attrs);Pe({type:n,text:e.text,range:e.range,attrsRange:e.attrsRange||null,valueRange:e.valueRange||null},r,t)}xe(e).forEach(e=>{e.attrs&&Pe(e,oe(e.attrs),t)})}function Ie(e,t){let n=k(e.text);if(!n)return;let r=oe(`{=${n.content}}`),i=e.range[0]+e.text.indexOf(`{=`);Pe({type:`standalone`,text:``,range:e.range,attrsRange:[i,i+(n.content?n.content.length:0)],valueRange:null},r,t)}var Le={heading:(e,t)=>_e(e,t,Fe,we),code:(e,t)=>_e(e,t,Fe,we),blockquote:(e,t)=>_e(e,t,Fe,we),para:(e,t)=>_e(e,t,Fe,we,[Ie]),list:(e,t)=>_e(e,t,Fe,we),standalone:(e,t)=>Ie(e,t)};function Re(e){return C(e)}function ze(e,t,n){return typeof e==`string`?H({text:e,...t,context:{...n,...t.context}}):e}function U(e,t={}){let n=new Map,i=new Set,a=[],o=new Map,s=[],c=new Map,l=[];for(let
|
|
36
|
+
`)}}function Ce(e,t=0){return F(e,t)}function we(e,t){let n=e._blockId||g(`${e.type}:${e.range?.[0]}:${e.range?.[1]}`);e._blockId=n;let r=xe(e),i=se(e),a={id:n,type:e.type,range:e.range,text:i,subject:null,types:[],predicates:[],carriers:[],listLevel:e.indent||0,parentBlockId:t.blockStack.length>0?t.blockStack[t.blockStack.length-1]:null,quadKeys:[]};for(let e of r){let t={type:e.type,range:e.range,text:e.text,subject:null,predicates:[],sem:null};if(e.attrs){let n=oe(e.attrs);t.sem=n,t.predicates=n.predicates||[],t.subject=n.subject,t.types=n.types||[]}a.carriers.push(t)}return t.origin.blocks.set(n,a),t.origin.documentStructure.push(a),a}function Te(e,t,n,r){if(t.subject&&t.subject!==`RESET`){let n=ue(t,r);n&&(e.subject=n.value)}if(t.types&&t.types.length>0&&t.types.forEach(t=>{let n=v(typeof t==`string`?t:t.iri,r.ctx);e.types.includes(n)||e.types.push(n)}),t.predicates&&t.predicates.length>0&&t.predicates.forEach(t=>{let n={iri:v(t.iri,r.ctx),form:t.form||``,object:null};e.predicates.push(n)}),n){let t={type:n.type,range:n.range,text:n.text,subject:null,predicates:[]};if(n.attrs){let e=oe(n.attrs);t.sem=e,t.predicates=e.predicates||[],t.subject=e.subject,t.types=e.types||[]}e.carriers.push(t)}}function Ee(e,t,n,r={}){let{preserveGlobalSubject:i=!1,implicitSubject:a=null}=r;if(t.subject===`RESET`){n.currentSubject=null;return}let o=n.currentSubject,s=ue(t,n),c=de(t,n);s&&!n.primarySubject&&!t.subject.startsWith(`=#`)&&(n.primarySubject=s.value),s&&!i&&!a&&(n.currentSubject=s);let l=i?s||o:a||n.currentSubject;if(!l)return;let u=De(l.value,t.types,t.predicates,e.range,e.attrsRange||null,e.valueRange||null,e.type||null,n.ctx,e.text),d=w(e.text,t.datatype,t.language,n.ctx,n.df),f=e.url?n.df.namedNode(v(e.url,n.ctx)):null,p=s||f;n.currentBlock&&Te(n.currentBlock,t,e,n),je(t,s,c,f,l,u,n,e),Ne(t,s,o,c,p,l,d,u,n,e)}function De(e,t,n,r,i,a,o,s,c){let l={subject:e,types:t.map(e=>v(typeof e==`string`?e:e.iri,s)),predicates:n.map(e=>({iri:v(e.iri,s),form:e.form}))};return{id:g([e,o||`unknown`,l.types.join(`,`),l.predicates.map(e=>`${e.form}${e.iri}`).join(`,`)].join(`|`)),range:{start:r[0],end:r[1]},carrierType:o||null,subject:e,types:l.types,predicates:l.predicates,context:s,text:c||``}}function Oe(e,t,n,r,i,a,o,s,c,l=null,u=null,d=null,f=null){if(!a||!o||!s)return;let p=c.quad(a,o,s);if(l?.remove){let i=S(p.subject,p.predicate,p.object);if(t.has(i)){t.delete(i);let n=e.findIndex(e=>e.subject.value===p.subject.value&&e.predicate.value===p.predicate.value&&e.object.value===p.object.value);n!==-1&&e.splice(n,1),r.delete(i)}else n.add(p)}else{let n=S(p.subject,p.predicate,p.object);t.set(n,p),e.push(p),f&&(!f.primaryType&&o.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`&&(f.primaryType=s.value),!f.primaryLabel&&o.value===`http://www.w3.org/2000/01/rdf-schema#label`&&s.termType===`Literal`&&(f.primaryLabel=s.value)),ke(p,c,l,u,d);let m=ce(i,a,o,l);r.set(n,m),f.currentBlock&&i.id===f.currentBlock.id&&(f.currentBlock.quadKeys||(f.currentBlock.quadKeys=[]),f.currentBlock.quadKeys.push(n))}}function ke(e,t,n,r=null,i=null){if(!r||!i)return;let a=e.predicate.value;if(a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`&&a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#subject`&&a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate`&&a!==`http://www.w3.org/1999/02/22-rdf-syntax-ns#object`)return;if(a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#type`&&e.object.value===`http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement`){i.set(e.subject.value,{spo:{}});return}let o=i.get(e.subject.value);if(o&&(a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#subject`?o.spo.subject=e.object:a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate`?o.spo.predicate=e.object:a===`http://www.w3.org/1999/02/22-rdf-syntax-ns#object`&&(o.spo.object=e.object,o.objectQuad=e),o.spo.subject&&o.spo.predicate&&o.spo.object)){let n=t.quad(o.spo.subject,o.spo.predicate,o.spo.object);r.push(n),i.delete(e.subject.value)}}var Ae=(e,t,n,r,i=null)=>{let a=v(e,n.ctx),o=typeof i==`object`?i:{entryIndex:i,remove:!1};Oe(n.quads,n.quadBuffer,n.removeSet,n.origin.quadIndex,r,t,n.df.namedNode(v(`rdf:type`,n.ctx)),n.df.namedNode(a),n.df,{kind:`type`,token:`.${e}`,expandedType:a,entryIndex:o.entryIndex,remove:o.remove},n.statements,n.statementCandidates,n)};function je(e,t,n,r,i,a,o,s){e.types.forEach(e=>{Ae(typeof e==`string`?e:e.iri,t||n||r||i,o,a,typeof e==`string`?{entryIndex:null,remove:!1}:e)})}var Me=(e,t,n,r,i,a,o,s)=>{if(e.form===``&&t?.type===`link`&&t?.url&&t.text===t.url)return null;switch(e.form){case``:return n?{subject:i||o,object:s}:t?.type===`link`&&t?.url&&t.text!==t.url?{subject:a,object:s}:{subject:i||o,object:s};case`?`:return{subject:n?r:o,object:i||a};case`!`:return{subject:i||a,object:n?r:o};default:return null}};function Ne(e,t,n,r,i,a,o,s,c,l){e.predicates.forEach(e=>{let u=Me(e,l,t,n,r,i,a,o);if(u){let t=c.df.namedNode(v(e.iri,c.ctx));Oe(c.quads,c.quadBuffer,c.removeSet,c.origin.quadIndex,s,u.subject,t,u.object,c.df,{kind:`pred`,token:`${e.form}${e.iri}`,form:e.form,expandedPredicate:t.value,entryIndex:e.entryIndex,remove:e.remove||!1},c.statements,c.statementCandidates,c)}})}function Pe(e,t,n,r={}){Ee(e,t,n,r)}function Fe(e,t,n){if(e.attrs){let r=oe(e.attrs);Pe({type:n,text:e.text,range:e.range,attrsRange:e.attrsRange||null,valueRange:e.valueRange||null},r,t)}xe(e).forEach(e=>{e.attrs&&Pe(e,oe(e.attrs),t)})}function Ie(e,t){let n=k(e.text);if(!n)return;let r=oe(`{=${n.content}}`),i=e.range[0]+e.text.indexOf(`{=`);Pe({type:`standalone`,text:``,range:e.range,attrsRange:[i,i+(n.content?n.content.length:0)],valueRange:null},r,t)}var Le={heading:(e,t)=>_e(e,t,Fe,we),code:(e,t)=>_e(e,t,Fe,we),blockquote:(e,t)=>_e(e,t,Fe,we),para:(e,t)=>_e(e,t,Fe,we,[Ie]),list:(e,t)=>_e(e,t,Fe,we),standalone:(e,t)=>Ie(e,t)};function Re(e){return C(e)}function ze(e,t,n){return typeof e==`string`?H({text:e,...t,context:{...n,...t.context}}):e}function U(e,t={}){let n=new Map,i=new Set,a=[],o=new Map,s=[],c=new Map,l=[],u=[];for(let d=0;d<e.length;d++){let f=e[d],p=ze(f,t,{...r,...t.context});if(p.context)for(let[e,t]of Object.entries(p.context))!c.has(e)&&!r[e]&&c.set(e,t);let m={index:d,input:typeof f==`string`?`string`:`ParseResult`,origin:p.origin,context:p.context,statementsCount:p.statements?.length||0};a.push(m),p.statements&&p.statements.length>0&&s.push(...p.statements),p.primary&&(p.primary.subject||p.primary.type||p.primary.label)&&l.push(p.primary),p.primarySubject&&u.push(p.primarySubject);for(let e of p.quads){let t=Re(e);n.set(t,e);let r=p.origin.quadIndex.get(t);o.set(t,{...r||{},documentIndex:d,polarity:`+`})}for(let e of p.remove){let t=Re(e);n.has(t)?n.delete(t):i.add(e);let r=p.origin.quadIndex.get(t);o.set(t,{...r||{},documentIndex:d,polarity:`-`})}}let d=Array.from(n.values()),f=Array.from(i),p={documents:a,quadIndex:o},m={...r,...t.context,...Object.fromEntries(c)},h=new Set(d.map(Re)),g=new Set(f.map(Re));return{quads:d.filter(e=>!g.has(Re(e))),remove:f.filter(e=>!h.has(Re(e))),statements:s,origin:p,context:m,primarySubjects:u,primary:l}}var Be=new Map,Ve=1e3;function He(e,t){let n=`${e}|${JSON.stringify(t)}`;if(Be.has(n))return Be.get(n);let r=y(e,t);return Be.size>=Ve&&Array.from(Be.keys()).slice(0,Math.floor(Ve/2)).forEach(e=>Be.delete(e)),Be.set(n,r),r}function Ue(e,t={}){if(!e)return e;for(let[n,r]of Object.entries(t))if(e.startsWith(r)||e.startsWith(r.slice(0,-1)))return e.substring(r.length);for(let t of[`#`,`/`,`:`]){let n=e.lastIndexOf(t);if(n!==-1&&n<e.length-1)return e.substring(n+1)}return e}function We({quads:e,context:t={},primarySubject:n=null}){let i=Object.assign({},r,t),a=Ge(e),o=Ke(a),s=n;!s&&a.length>0&&(s=a[0].subject.value);let{text:c}=qe(o,i,s);return{text:c,context:i}}function Ge(e){return!e||e.length===0?[]:e.map(e=>e.subject.termType&&e.predicate.termType&&e.object.termType?e:{subject:m.fromTerm(e.subject),predicate:m.fromTerm(e.predicate),object:m.fromTerm(e.object)}).sort((e,t)=>{let n=e.subject.value.localeCompare(t.subject.value);if(n!==0)return n;let r=e.predicate.value.localeCompare(t.predicate.value);if(r!==0)return r;let i=(fe(e.object),e.object.value),a=(fe(t.object),t.object.value);return i.localeCompare(a)})}function Ke(e){let t=new Map;for(let n of e){let e=n.subject.value,r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function qe(e,t,n=null){let i=[],a=ge(e,t),o=Je(e),s=Object.entries(t).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of s)e!==`@vocab`&&!e.startsWith(`@`)&&!r[e]&&a.has(e)&&i.push(ve(e,t));s.length>0&&i.push(`
|
|
37
37
|
`);let c=Array.from(e.keys()).sort(),l=n,u=l?[l,...c.filter(e=>e!==l)]:c;for(let n of u){let r=e.get(n);if(!r)continue;let a=He(n,t),{types:s,literals:c,objects:l}=be(r),u=o.has(n),d=u?o.get(n):Ue(n,t),f=s.length>0?s.map(e=>`.`+He(e.object.value,t)).sort().join(` `):``;u&&(f+=(f?` `:``)+`label`);let p=f?` `+f:``;i.push(`# ${d} {=${a}${p}}\n\n`);let m=u?o.get(n):null;B(c).forEach(e=>{e.predicate.value===`http://www.w3.org/2000/01/rdf-schema#label`&&e.object.value===m||i.push(V(e,t))}),B(l).forEach(e=>{i.push(ye(e,t,o))}),i.push(`
|
|
38
38
|
`)}return{text:i.join(``)}}function Je(e){let t=new Map;for(let n of e.values())for(let e of n)e.predicate.value===`http://www.w3.org/2000/01/rdf-schema#label`&&e.object.termType===`Literal`&&t.set(e.subject.value,e.object.value);return t}function W(e){return String(e).replaceAll(`&`,`&`).replaceAll(`<`,`<`).replaceAll(`>`,`>`).replaceAll(`"`,`"`).replaceAll(`'`,`'`)}var G={text:`#6b7280`,marker:`#f97316`,retraction:`#dc2626`,value:`#eab308`,annotation:`#4b5563`};function Ye(e,t){let n=t;for(;n<e.length&&e[n]!==`
|
|
39
39
|
`&&e[n]!==`\r`;){if(e[n]===`{`)return!0;n++}return!1}function Xe(e,t){let n=e[t];if(n===`*`&&t+1<e.length&&e[t+1]===`*`){let n=e.indexOf(`**`,t+2);if(n!==-1){let r=e.slice(t+2,n),i=Ye(e,n+2)?` style="color: ${G.marker}"`:``;return{html:`<span${i}>**</span><strong>${W(r)}</strong><span${i}>**</span>`,nextIndex:n+2}}}if(n===`_`&&t+1<e.length&&e[t+1]===`_`){let n=e.indexOf(`__`,t+2);if(n!==-1){let r=e.slice(t+2,n),i=Ye(e,n+2)?` style="color: ${G.marker}"`:``;return{html:`<span${i}>__</span><strong>${W(r)}</strong><span${i}>__</span>`,nextIndex:n+2}}}if(n===`*`){let n=e.indexOf(`*`,t+1);if(n!==-1){let r=e.slice(t+1,n),i=Ye(e,n+1)?` style="color: ${G.marker}"`:``;return{html:`<span${i}>*</span><em>${W(r)}</em><span${i}>*</span>`,nextIndex:n+1}}}if(n===`_`){let n=e.indexOf(`_`,t+1);if(n!==-1){let r=e.slice(t+1,n),i=Ye(e,n+1)?` style="color: ${G.marker}"`:``;return{html:`<span${i}>_</span><em>${W(r)}</em><span${i}>_</span>`,nextIndex:n+1}}}if(n==="`"){let n=e.indexOf("`",t+1);if(n!==-1){let r=e.slice(t+1,n),i=Ye(e,n+1)?` style="color: ${G.marker}"`:``;return{html:`<span${i}>\`</span><code style="background-color:#7773">${W(r)}</code><span${i}>\`</span>`,nextIndex:n+1}}}return null}var Ze=new Map;function Qe(e){let t=0;for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);t=(t<<5)-t+r,t&=t}return Math.abs(t)}function $e(e){if(Ze.has(e))return Ze.get(e);let t=Qe(e),n=`hsl(${t%360}, ${15+t%10}%, ${45+t%10}%)`;return Ze.set(e,n),n}function et(e){let t=new Map,n=/^\[(\w+)\]\s*<([^>]*)>\s*$/gm,i;for(;(i=n.exec(e))!==null;){let e=i[1],n=i[2];if(n.includes(`:`)){let e=n.indexOf(`:`);if(e>0){let r=n.slice(0,e),i=n.slice(e+1);t.has(r)&&(n=t.get(r)+i)}}t.set(e,n)}for(let[e,n]of Object.entries(r))e!==`@vocab`&&t.set(e,n);return t}function tt(e,t,n){let r=t?G.retraction:G.text,i=e.indexOf(`:`);if(i>0){let t=e.slice(0,i),r=e.slice(i+1);if(n.has(t)){let e=n.get(t),i=$e(e),a=e+r,o=$e(a);return`<span style="color: ${i}">${W(t)}</span><span style="color: ${G.marker}">:</span><span data-iri="${a}" style="color: ${o}">${W(r)}</span> `}}return e.startsWith(`http:`)||e.startsWith(`https:`)||e.startsWith(`tag:`)||e.startsWith(`urn:`)?`<span style="color: ${$e(e)}">${W(e)}</span> `:`<span style="color: ${r}">${W(e)}</span> `}function nt(e,t){let n=e.trim().split(/\s+/),r=``,i=!1;for(let e=0;e<n.length;e++){let a=n[e];if(!a)continue;if(a.startsWith(`=`)||a.startsWith(`+`)){let e=a[0],n=a.slice(1);r+=`<span style="color: ${G.marker}">${W(e)}</span>${tt(n,!1,t)}`;continue}if(a===`-`){i=!0,r+=`<span style="color: ${G.retraction}">${W(a)}</span> `;continue}if(a.startsWith(`-`)&&a.length>1){r+=`<span style="color: ${G.retraction}">${W(a)}</span> `;continue}let o=i;if(i=!1,a.startsWith(`?`)||a.startsWith(`!`)){let e=a[0],n=a.slice(1),i=o?G.retraction:G.marker;r+=`<span style="color: ${i}">${W(e)}</span>${tt(n,o,t)}`;continue}if(a.startsWith(`^^`)){let e=a.slice(2),n=o?G.retraction:G.marker;r+=`<span style="color: ${n}">${W(`^^`)}</span>${tt(e,o,t)}`;continue}if(a.startsWith(`@`)){let e=a.slice(1),n=o?G.retraction:G.marker;r+=`<span style="color: ${n}">${W(`@`)}</span>${tt(e,o,t)}`;continue}if(a.startsWith(`.`)){let e=a.slice(1),n=o?G.retraction:G.marker;r+=`<span style="color: ${n}">${W(`.`)}</span>${tt(e,o,t)}`;continue}r+=tt(a,o,t)}return r.trim()}function rt(e){let t=et(e),n=``,r=0;for(;r<e.length;){let i=e[r];if(i===`{`){let a=e.indexOf(`}`,r);if(a===-1){n+=W(i),r++;continue}let o=nt(e.slice(r+1,a),t);n+=`<span style="color: ${G.annotation}; opacity: 0.75">{</span>`,n+=o,n+=`<span style="color: ${G.annotation}; opacity: 0.75">}</span>`,r=a+1;continue}if(i===`[`){let a=e.indexOf(`]`,r);if(a===-1){n+=W(i),r++;continue}let o=e.slice(r+1,a),s=a+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]===`<`){let i=e.indexOf(`>`,s);if(i!==-1){let a=e.slice(s+1,i),c=t.has(o)?$e(t.get(o)):G.text;n+=`<span style="color: ${G.annotation}; opacity: 0.75">[</span><span style="color: ${c}">${W(o)}</span><span style="color: ${G.annotation}; opacity: 0.75">]</span> <span style="color: ${G.text}; opacity: 0.6"><${W(a)}></span>`,r=i+1;continue}}let c=e.slice(r+1,a),l=Ye(e,a+1)?G.marker:G.value,u=W(c);n+=`<span style="color: ${l}; opacity: 0.85">[</span><span style=" opacity: 1.0">${u}</span><span style="color: ${l}; opacity: 0.85">]</span>`,r=a+1;continue}if(i===`*`||i===`_`||i==="`"){let t=Xe(e,r);if(t){n+=t.html,r=t.nextIndex;continue}}if(i===`#`){let i=0,a=r;for(;a<e.length&&e[a]===`#`;)i++,a++;if(i<=6&&(a>=e.length||e[a]===` `||e[a]===` `)){let o=e.indexOf(`
|
|
@@ -41,14 +41,14 @@
|
|
|
41
41
|
`;if((t===`
|
|
42
42
|
`||t===`\r`||t===` `||t===` `)&&e[r+1]===` `){let t=Ye(e,r+2)?`color: ${G.marker}; opacity: 0.85`:``;n+=`<span style="${t}">${W(i)}</span>`,r++;continue}}if(i===`>`){let t=r>0?e[r-1]:`
|
|
43
43
|
`;if((t===`
|
|
44
|
-
`||t===`\r`||t===` `||t===` `)&&e[r+1]===` `){let t=Ye(e,r+2)?`color: ${G.marker}; opacity: 0.85`:``;n+=`<span style="${t}">${W(i)}</span>`,r++;continue}}n+=W(i),r++}return n}function K(e,t){if(!e)throw Error(t)}function it(e,t,n,r){return e.find(e=>e.subject.value===t&&e.predicate.value===n&&(r===null||(e.object.termType,e.object.value===r)))}function q(e,t,n,r){return!!it(e,t,n,r)}var at=[{name:`Primary subject - first subject declaration`,fn:()=>{let{primarySubject:e}=H({text:`[ex] <http://example.org/>
|
|
44
|
+
`||t===`\r`||t===` `||t===` `)&&e[r+1]===` `){let t=Ye(e,r+2)?`color: ${G.marker}; opacity: 0.85`:``;n+=`<span style="${t}">${W(i)}</span>`,r++;continue}}n+=W(i),r++}return n}function K(e,t){if(!e)throw Error(t)}function it(e,t,n,r){return e.find(e=>e.subject.value===t&&e.predicate.value===n&&(r===null||(e.object.termType,e.object.value===r)))}function q(e,t,n,r){return!!it(e,t,n,r)}var at=[{name:`Primary subject - first subject declaration`,fn:()=>{let{primarySubject:e,primary:t}=H({text:`[ex] <http://example.org/>
|
|
45
45
|
|
|
46
46
|
# Document {=ex:doc .ex:Article label}
|
|
47
|
-
[Alice] {ex:author}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/doc`,`Primary subject should be ex:doc, got ${e}`)}},{name:`Primary subject - null when no subject declared`,fn:()=>{let{primarySubject:e}=H({text:`[Alice] {label}`});K(e===null,`Primary subject should be null when no subject declared`)}},{name:`Primary subject - fragment does not become primary`,fn:()=>{let{primarySubject:e}=H({text:`[ex] <http://example.org/>
|
|
47
|
+
[Alice] {ex:author}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/doc`,`Primary subject should be ex:doc, got ${e}`),K(t!==null,`Should have a primary object`),K(t.subject===`http://example.org/doc`,`Primary object subject should be ex:doc, got ${t.subject}`),K(t.type===`http://example.org/Article`,`Primary object type should be ex:Article, got ${t.type}`),K(t.label===`Document`,`Primary object label should be Document, got ${t.label}`)}},{name:`Primary subject - null when no subject declared`,fn:()=>{let{primarySubject:e,primary:t}=H({text:`[Alice] {label}`});K(e===null,`Primary subject should be null when no subject declared`),K(t!==null,`Primary object should exist even when no subject declared`),K(t.subject===null,`Primary object subject should be null when no subject declared`),K(t.type===null,`Primary object type should be null when no subject declared`),K(t.label===null,`Primary object label should be null when no label exists`)}},{name:`Primary subject - fragment does not become primary`,fn:()=>{let{primarySubject:e,primary:t}=H({text:`[ex] <http://example.org/>
|
|
48
48
|
|
|
49
49
|
# Document {=ex:doc}
|
|
50
50
|
{=#summary}
|
|
51
|
-
[Content] {label}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/doc`,`Primary subject should be ex:doc, not fragment`)}},{name:`Primary subject - reset does not clear primary`,fn:()=>{let{primarySubject:e}=H({text:`[ex] <http://example.org/>
|
|
51
|
+
[Content] {label}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/doc`,`Primary subject should be ex:doc, not fragment`),K(t!==null,`Should have a primary object`),K(t.subject===`http://example.org/doc`,`Primary object subject should be ex:doc, not fragment`)}},{name:`Primary subject - reset does not clear primary`,fn:()=>{let{primarySubject:e,primary:t}=H({text:`[ex] <http://example.org/>
|
|
52
52
|
|
|
53
53
|
# First {=ex:first}
|
|
54
54
|
[Value] {label}
|
|
@@ -56,16 +56,16 @@
|
|
|
56
56
|
# Reset {=}
|
|
57
57
|
|
|
58
58
|
# Second {=ex:second}
|
|
59
|
-
[Value] {label}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/first`,`Primary subject should remain ex:first after reset, got ${e}`)}},{name:`Primary subject - first non-fragment subject wins`,fn:()=>{let{primarySubject:e}=H({text:`[ex] <http://example.org/>
|
|
59
|
+
[Value] {label}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/first`,`Primary subject should remain ex:first after reset, got ${e}`),K(t!==null,`Should have a primary object`),K(t.subject===`http://example.org/first`,`Primary object subject should be ex:first after reset, got ${t.subject}`)}},{name:`Primary subject - first non-fragment subject wins`,fn:()=>{let{primarySubject:e,primary:t}=H({text:`[ex] <http://example.org/>
|
|
60
60
|
|
|
61
61
|
{=#summary}
|
|
62
62
|
[Content] {label}
|
|
63
63
|
|
|
64
64
|
# Document {=ex:doc}
|
|
65
|
-
[Alice] {ex:author}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/doc`,`Primary subject should be ex:doc, not fragment`)}},{name:`Primary subject - round-trip with generate()`,fn:()=>{let{quads:e,primarySubject:t}=H({text:`[ex] <http://example.org/>
|
|
65
|
+
[Alice] {ex:author}`});K(e!==null,`Should have a primary subject`),K(e===`http://example.org/doc`,`Primary subject should be ex:doc, not fragment`),K(t!==null,`Should have a primary object`),K(t.subject===`http://example.org/doc`,`Primary object subject should be ex:doc, not fragment`)}},{name:`Primary subject - round-trip with generate()`,fn:()=>{let{quads:e,primarySubject:t,primary:n}=H({text:`[ex] <http://example.org/>
|
|
66
66
|
|
|
67
67
|
# Document {=ex:doc .ex:Article label}
|
|
68
|
-
[Alice] {ex:author}`}),
|
|
68
|
+
[Alice] {ex:author}`}),r=We({quads:e,context:{ex:`http://example.org/`},primarySubject:t}),{primarySubject:i,primary:a}=H({text:r.text,context:r.context});K(t!==null,`Original should have primary subject`),K(n!==null,`Original should have primary object`),K(i!==null,`Regenerated should have primary subject`),K(a!==null,`Regenerated should have primary object`),K(t===i,`Primary subject should be preserved in round-trip: ${t} vs ${i}`),K(n.subject===a.subject,`Primary object subject should be preserved: ${n.subject} vs ${a.subject}`),K(n.type===a.type,`Primary object type should be preserved: ${n.type} vs ${a.type}`),K(n.label===a.label,`Primary object label should be preserved: ${n.label} vs ${a.label}`)}},{name:`Subject declaration sets context`,fn:()=>{let{quads:e,context:t}=H({text:`[ex] <http://example.org/>
|
|
69
69
|
# Title {=ex:doc}
|
|
70
70
|
|
|
71
71
|
[value] {label}`});K(q(e,`http://example.org/doc`,`http://www.w3.org/2000/01/rdf-schema#label`,`value`),`Subject should be ex:doc`)}},{name:`Subject reset with {=}`,fn:()=>{let{quads:e}=H({text:`[ex] <http://example.org/>
|
|
@@ -549,7 +549,7 @@ List items:
|
|
|
549
549
|
|
|
550
550
|
[Alice Smith] {author}`}),t=h(e.quads.find(e=>e.subject.value===`http://example.org/article`&&e.predicate.value===`http://www.w3.org/2000/01/rdf-schema#author`),e.origin);ot(t,`Should locate quad`),ot(t.range.start>=0,`Range start should be non-negative`),ot(t.range.end<=87,`Range end should be within text`),ot(t.range.start<t.range.end,`Range start should be before end`),J(t.value,`Alice Smith`),J(t.polarity,`+`)}}];function Y(e,t){if(!e)throw Error(t||`Assertion failed`)}function ct(e){let t=e.object.datatype?.value||``,n=e.object.language||``;return`${e.subject.value}|${e.predicate.value}|${e.object.value}|${t}|${n}`}function lt(e,t,n,r){return e.some(e=>e.subject.value===t&&e.predicate.value===n&&e.object.value===r)}var ut=[{name:`Primary subjects - single document`,fn:()=>{let e=U([`[my] <tag:hr@example.com,2026:>
|
|
551
551
|
# Employee {=my:emp456 .my:Employee}
|
|
552
|
-
[Alice] {my:name}`]);Y(e.primarySubjects.length===1,`Should have 1 primary subject, got ${e.primarySubjects.length}`),Y(e.primarySubjects[0]===`tag:hr@example.com,2026:emp456`,`Primary subject should be my:emp456, got ${e.primarySubjects[0]}`)}},{name:`Primary subjects - multiple documents`,fn:()=>{let e=U([`[ex] <http://example.org/>
|
|
552
|
+
[Alice] {my:name}`]);Y(e.primarySubjects.length===1,`Should have 1 primary subject, got ${e.primarySubjects.length}`),Y(e.primarySubjects[0]===`tag:hr@example.com,2026:emp456`,`Primary subject should be my:emp456, got ${e.primarySubjects[0]}`),Y(e.primary.length===1,`Should have 1 primary object, got ${e.primary.length}`),Y(e.primary[0].subject===`tag:hr@example.com,2026:emp456`,`Primary object subject should be my:emp456, got ${e.primary[0].subject}`),Y(e.primary[0].type===`tag:hr@example.com,2026:Employee`,`Primary object type should be my:Employee, got ${e.primary[0].type}`),Y(e.primary[0].label===null,`Primary object label should be null, got ${e.primary[0].label}`)}},{name:`Primary subjects - multiple documents`,fn:()=>{let e=U([`[ex] <http://example.org/>
|
|
553
553
|
# Doc1 {=ex:doc1}
|
|
554
554
|
[Value] {label}`,`[ex] <http://example.org/>
|
|
555
555
|
# Doc2 {=ex:doc2}
|
package/dist/index.js
CHANGED
|
@@ -745,6 +745,11 @@ function I(t, n = {}) {
|
|
|
745
745
|
let t = v(e.subject, e.predicate, e.object);
|
|
746
746
|
c.has(t) || l.push(e);
|
|
747
747
|
}
|
|
748
|
+
let u = {
|
|
749
|
+
subject: o.primarySubject,
|
|
750
|
+
type: o.primaryType,
|
|
751
|
+
label: o.primaryLabel
|
|
752
|
+
};
|
|
748
753
|
return {
|
|
749
754
|
quads: o.quads,
|
|
750
755
|
remove: l,
|
|
@@ -752,8 +757,7 @@ function I(t, n = {}) {
|
|
|
752
757
|
origin: o.origin,
|
|
753
758
|
context: o.ctx,
|
|
754
759
|
primarySubject: o.primarySubject,
|
|
755
|
-
|
|
756
|
-
primaryLabel: o.primaryLabel,
|
|
760
|
+
primary: u,
|
|
757
761
|
md: s.md
|
|
758
762
|
};
|
|
759
763
|
}
|
|
@@ -1152,57 +1156,58 @@ function Re(e, t, n) {
|
|
|
1152
1156
|
}) : e;
|
|
1153
1157
|
}
|
|
1154
1158
|
function ze(t, n = {}) {
|
|
1155
|
-
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = [], o = /* @__PURE__ */ new Map(), s = [], c = /* @__PURE__ */ new Map(), l = [];
|
|
1156
|
-
for (let
|
|
1157
|
-
let
|
|
1159
|
+
let r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Set(), a = [], o = /* @__PURE__ */ new Map(), s = [], c = /* @__PURE__ */ new Map(), l = [], u = [];
|
|
1160
|
+
for (let d = 0; d < t.length; d++) {
|
|
1161
|
+
let f = t[d], p = Re(f, n, {
|
|
1158
1162
|
...e,
|
|
1159
1163
|
...n.context
|
|
1160
1164
|
});
|
|
1161
|
-
if (
|
|
1162
|
-
let
|
|
1163
|
-
index:
|
|
1164
|
-
input: typeof
|
|
1165
|
-
origin:
|
|
1166
|
-
context:
|
|
1167
|
-
statementsCount:
|
|
1165
|
+
if (p.context) for (let [t, n] of Object.entries(p.context)) !c.has(t) && !e[t] && c.set(t, n);
|
|
1166
|
+
let m = {
|
|
1167
|
+
index: d,
|
|
1168
|
+
input: typeof f == "string" ? "string" : "ParseResult",
|
|
1169
|
+
origin: p.origin,
|
|
1170
|
+
context: p.context,
|
|
1171
|
+
statementsCount: p.statements?.length || 0
|
|
1168
1172
|
};
|
|
1169
|
-
a.push(
|
|
1170
|
-
for (let e of
|
|
1173
|
+
a.push(m), p.statements && p.statements.length > 0 && s.push(...p.statements), p.primary && (p.primary.subject || p.primary.type || p.primary.label) && l.push(p.primary), p.primarySubject && u.push(p.primarySubject);
|
|
1174
|
+
for (let e of p.quads) {
|
|
1171
1175
|
let t = U(e);
|
|
1172
1176
|
r.set(t, e);
|
|
1173
|
-
let n =
|
|
1177
|
+
let n = p.origin.quadIndex.get(t);
|
|
1174
1178
|
o.set(t, {
|
|
1175
1179
|
...n || {},
|
|
1176
|
-
documentIndex:
|
|
1180
|
+
documentIndex: d,
|
|
1177
1181
|
polarity: "+"
|
|
1178
1182
|
});
|
|
1179
1183
|
}
|
|
1180
|
-
for (let e of
|
|
1184
|
+
for (let e of p.remove) {
|
|
1181
1185
|
let t = U(e);
|
|
1182
1186
|
r.has(t) ? r.delete(t) : i.add(e);
|
|
1183
|
-
let n =
|
|
1187
|
+
let n = p.origin.quadIndex.get(t);
|
|
1184
1188
|
o.set(t, {
|
|
1185
1189
|
...n || {},
|
|
1186
|
-
documentIndex:
|
|
1190
|
+
documentIndex: d,
|
|
1187
1191
|
polarity: "-"
|
|
1188
1192
|
});
|
|
1189
1193
|
}
|
|
1190
1194
|
}
|
|
1191
|
-
let
|
|
1195
|
+
let d = Array.from(r.values()), f = Array.from(i), p = {
|
|
1192
1196
|
documents: a,
|
|
1193
1197
|
quadIndex: o
|
|
1194
|
-
},
|
|
1198
|
+
}, m = {
|
|
1195
1199
|
...e,
|
|
1196
1200
|
...n.context,
|
|
1197
1201
|
...Object.fromEntries(c)
|
|
1198
|
-
},
|
|
1202
|
+
}, h = new Set(d.map(U)), g = new Set(f.map(U));
|
|
1199
1203
|
return {
|
|
1200
|
-
quads:
|
|
1201
|
-
remove:
|
|
1204
|
+
quads: d.filter((e) => !g.has(U(e))),
|
|
1205
|
+
remove: f.filter((e) => !h.has(U(e))),
|
|
1202
1206
|
statements: s,
|
|
1203
|
-
origin:
|
|
1204
|
-
context:
|
|
1205
|
-
primarySubjects:
|
|
1207
|
+
origin: p,
|
|
1208
|
+
context: m,
|
|
1209
|
+
primarySubjects: u,
|
|
1210
|
+
primary: l
|
|
1206
1211
|
};
|
|
1207
1212
|
}
|
|
1208
1213
|
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mdld-parse",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.6",
|
|
4
4
|
"description": "A standards-compliant parser for **MD-LD (Markdown-Linked Data)** β a human-friendly RDF authoring format that extends Markdown with semantic annotations.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800",
|
package/dist/docs/Nostr.md
DELETED
|
@@ -1,544 +0,0 @@
|
|
|
1
|
-
Nostr is an unusually strong fit for MDLD because both systems share the same deep property:
|
|
2
|
-
|
|
3
|
-
```text
|
|
4
|
-
append-only truth propagation
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
This alignment is much more important than protocol compatibility.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
# 1. Why Nostr fits MDLD unusually well
|
|
12
|
-
|
|
13
|
-
Nostr events are already:
|
|
14
|
-
|
|
15
|
-
```text id="z7l1d7"
|
|
16
|
-
signed
|
|
17
|
-
timestamped
|
|
18
|
-
distributed
|
|
19
|
-
immutable
|
|
20
|
-
referential
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Which is extremely close to:
|
|
24
|
-
|
|
25
|
-
```text id="hqzc8w"
|
|
26
|
-
prov:Activity
|
|
27
|
-
prov:Entity
|
|
28
|
-
rdf:Statement
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
In many ways:
|
|
32
|
-
|
|
33
|
-
```text id="o7mj5h"
|
|
34
|
-
Nostr event β transport-level PROV activity
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
# 2. Current Nostr limitation
|
|
40
|
-
|
|
41
|
-
Today most Nostr clients treat events as:
|
|
42
|
-
|
|
43
|
-
```text id="hz2qmh"
|
|
44
|
-
social posts
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
But semantically they are:
|
|
48
|
-
|
|
49
|
-
```text id="t0k9r5"
|
|
50
|
-
distributed append-only graph fragments
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
MDLD unlocks this hidden layer.
|
|
54
|
-
|
|
55
|
-
---
|
|
56
|
-
|
|
57
|
-
# 3. MDLD + Nostr = semantic social substrate
|
|
58
|
-
|
|
59
|
-
Current flow:
|
|
60
|
-
|
|
61
|
-
```text id="cjjr2q"
|
|
62
|
-
human writes post
|
|
63
|
-
β relay distributes bytes
|
|
64
|
-
β client renders text
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
MDLD flow:
|
|
68
|
-
|
|
69
|
-
```text id="n0r0ki"
|
|
70
|
-
human writes semantic text
|
|
71
|
-
β relay distributes graph fragments
|
|
72
|
-
β agents reason over global graph
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
That is a major shift.
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
# 4. The critical inversion
|
|
80
|
-
|
|
81
|
-
Today:
|
|
82
|
-
|
|
83
|
-
```text id="pdx8es"
|
|
84
|
-
social media = content first
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
MDLD + Nostr:
|
|
88
|
-
|
|
89
|
-
```text id="3l7x5o"
|
|
90
|
-
semantic state first
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
Posts become:
|
|
94
|
-
|
|
95
|
-
```text id="lqzv0f"
|
|
96
|
-
portable knowledge mutations
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
# 5. Why append-only matters
|
|
102
|
-
|
|
103
|
-
Both systems fundamentally avoid:
|
|
104
|
-
|
|
105
|
-
```text id="s8bzlp"
|
|
106
|
-
mutable centralized state
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Instead:
|
|
110
|
-
|
|
111
|
-
```text id="ngw4w4"
|
|
112
|
-
state = accumulation of events
|
|
113
|
-
```
|
|
114
|
-
|
|
115
|
-
This makes the systems naturally composable.
|
|
116
|
-
|
|
117
|
-
---
|
|
118
|
-
|
|
119
|
-
# 6. Nostr event as MDLD carrier
|
|
120
|
-
|
|
121
|
-
Very simple model:
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Event content
|
|
126
|
-
|
|
127
|
-
```md
|
|
128
|
-
# Observation {=tag:alice@example.com,2026:obs/1 .rdf:Statement}
|
|
129
|
-
|
|
130
|
-
[Bob] {+tag:bob@example.com,2026:person/Bob ?rdf:subject}
|
|
131
|
-
[likes] {+my:likes ?rdf:predicate}
|
|
132
|
-
[coffee] {rdf:object}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## Nostr layer
|
|
138
|
-
|
|
139
|
-
Provides:
|
|
140
|
-
|
|
141
|
-
```text id="om1g7k"
|
|
142
|
-
β signature
|
|
143
|
-
β timestamp
|
|
144
|
-
β author pubkey
|
|
145
|
-
β distribution
|
|
146
|
-
β relay persistence
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
---
|
|
150
|
-
|
|
151
|
-
# 7. Nostr pubkey β authority binding
|
|
152
|
-
|
|
153
|
-
This is extremely elegant.
|
|
154
|
-
|
|
155
|
-
---
|
|
156
|
-
|
|
157
|
-
## Mapping
|
|
158
|
-
|
|
159
|
-
```text id="n9p6pz"
|
|
160
|
-
npub...
|
|
161
|
-
β
|
|
162
|
-
tag:npub...,2026:
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
or:
|
|
166
|
-
|
|
167
|
-
```text id="8b0z0r"
|
|
168
|
-
nostr:npub...
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
173
|
-
## Result
|
|
174
|
-
|
|
175
|
-
Authority becomes cryptographically backed.
|
|
176
|
-
|
|
177
|
-
---
|
|
178
|
-
|
|
179
|
-
# 8. Global distributed graph emerges naturally
|
|
180
|
-
|
|
181
|
-
Each user publishes:
|
|
182
|
-
|
|
183
|
-
```text id="z7zj6n"
|
|
184
|
-
small semantic append events
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
Agents aggregate:
|
|
188
|
-
|
|
189
|
-
```text id="px5j2m"
|
|
190
|
-
local semantic state
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
No central graph DB required.
|
|
194
|
-
|
|
195
|
-
---
|
|
196
|
-
|
|
197
|
-
# 9. Relays become semantic streams
|
|
198
|
-
|
|
199
|
-
Today relays store:
|
|
200
|
-
|
|
201
|
-
```text id="v9v4ys"
|
|
202
|
-
opaque text blobs
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
MDLD relays effectively distribute:
|
|
206
|
-
|
|
207
|
-
```text id="9c5gw4"
|
|
208
|
-
portable knowledge updates
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
---
|
|
212
|
-
|
|
213
|
-
# 10. Agent-native internet
|
|
214
|
-
|
|
215
|
-
This is where things get profound.
|
|
216
|
-
|
|
217
|
-
Current web:
|
|
218
|
-
|
|
219
|
-
```text id="mh50wd"
|
|
220
|
-
HTML for humans
|
|
221
|
-
JSON APIs for machines
|
|
222
|
-
```
|
|
223
|
-
|
|
224
|
-
MDLD+Nostr:
|
|
225
|
-
|
|
226
|
-
```text id="9m4h24"
|
|
227
|
-
same substrate for both
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
Humans read prose.
|
|
231
|
-
|
|
232
|
-
Agents read graph.
|
|
233
|
-
|
|
234
|
-
---
|
|
235
|
-
|
|
236
|
-
# 11. βPostingβ becomes distributed cognition
|
|
237
|
-
|
|
238
|
-
This is the deeper breakthrough.
|
|
239
|
-
|
|
240
|
-
A post is no longer:
|
|
241
|
-
|
|
242
|
-
```text id="8a8n05"
|
|
243
|
-
content artifact
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
It becomes:
|
|
247
|
-
|
|
248
|
-
```text id="8c1m09"
|
|
249
|
-
knowledge mutation event
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
With:
|
|
253
|
-
|
|
254
|
-
* provenance
|
|
255
|
-
* trust
|
|
256
|
-
* execution
|
|
257
|
-
* references
|
|
258
|
-
* validation
|
|
259
|
-
|
|
260
|
-
---
|
|
261
|
-
|
|
262
|
-
# 12. Agent coordination becomes native
|
|
263
|
-
|
|
264
|
-
Example:
|
|
265
|
-
|
|
266
|
-
---
|
|
267
|
-
|
|
268
|
-
## Human publishes
|
|
269
|
-
|
|
270
|
-
```md
|
|
271
|
-
# Need help {=tag:alice:task/1 .prov:Activity}
|
|
272
|
-
|
|
273
|
-
Need somebody to summarize these papers.
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
---
|
|
277
|
-
|
|
278
|
-
## Agent sees it
|
|
279
|
-
|
|
280
|
-
Creates:
|
|
281
|
-
|
|
282
|
-
```md
|
|
283
|
-
# Summary activity {=tag:agent:activity/42 .prov:Activity}
|
|
284
|
-
|
|
285
|
-
Used:
|
|
286
|
-
- paper1.pdf
|
|
287
|
-
- paper2.pdf
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
---
|
|
291
|
-
|
|
292
|
-
## Another agent validates
|
|
293
|
-
|
|
294
|
-
---
|
|
295
|
-
|
|
296
|
-
## Human approves
|
|
297
|
-
|
|
298
|
-
Entire workflow exists as graph.
|
|
299
|
-
|
|
300
|
-
No SaaS required.
|
|
301
|
-
|
|
302
|
-
---
|
|
303
|
-
|
|
304
|
-
# 13. Nostr solves discovery/distribution
|
|
305
|
-
|
|
306
|
-
Your vault solves:
|
|
307
|
-
|
|
308
|
-
```text id="u5ahz9"
|
|
309
|
-
state
|
|
310
|
-
execution
|
|
311
|
-
memory
|
|
312
|
-
reasoning
|
|
313
|
-
```
|
|
314
|
-
|
|
315
|
-
Nostr solves:
|
|
316
|
-
|
|
317
|
-
```text id="9d1rv7"
|
|
318
|
-
distribution
|
|
319
|
-
identity
|
|
320
|
-
replication
|
|
321
|
-
federation
|
|
322
|
-
```
|
|
323
|
-
|
|
324
|
-
This is an extremely strong pairing.
|
|
325
|
-
|
|
326
|
-
---
|
|
327
|
-
|
|
328
|
-
# 14. ZIP vaults + Nostr
|
|
329
|
-
|
|
330
|
-
Very powerful combination:
|
|
331
|
-
|
|
332
|
-
---
|
|
333
|
-
|
|
334
|
-
## Small events
|
|
335
|
-
|
|
336
|
-
Distributed directly:
|
|
337
|
-
|
|
338
|
-
```text id="jz8je9"
|
|
339
|
-
MDLD snippets
|
|
340
|
-
```
|
|
341
|
-
|
|
342
|
-
---
|
|
343
|
-
|
|
344
|
-
## Large artifacts
|
|
345
|
-
|
|
346
|
-
Referenced:
|
|
347
|
-
|
|
348
|
-
```text id="k34h67"
|
|
349
|
-
vault snapshots
|
|
350
|
-
datasets
|
|
351
|
-
media
|
|
352
|
-
models
|
|
353
|
-
```
|
|
354
|
-
|
|
355
|
-
via:
|
|
356
|
-
|
|
357
|
-
* torrents
|
|
358
|
-
* IPFS
|
|
359
|
-
* object stores
|
|
360
|
-
|
|
361
|
-
---
|
|
362
|
-
|
|
363
|
-
# 15. Local-first agent ecology
|
|
364
|
-
|
|
365
|
-
Each vault becomes:
|
|
366
|
-
|
|
367
|
-
```text id="l6e3m2"
|
|
368
|
-
local semantic organism
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
Nostr provides:
|
|
372
|
-
|
|
373
|
-
```text id="s4bd3f"
|
|
374
|
-
cross-organism signaling
|
|
375
|
-
```
|
|
376
|
-
|
|
377
|
-
---
|
|
378
|
-
|
|
379
|
-
# 16. Social network becomes graph market
|
|
380
|
-
|
|
381
|
-
Instead of:
|
|
382
|
-
|
|
383
|
-
```text id="v5aqx7"
|
|
384
|
-
feeds
|
|
385
|
-
likes
|
|
386
|
-
posts
|
|
387
|
-
```
|
|
388
|
-
|
|
389
|
-
You get:
|
|
390
|
-
|
|
391
|
-
```text id="1x6sqn"
|
|
392
|
-
claims
|
|
393
|
-
activities
|
|
394
|
-
plans
|
|
395
|
-
results
|
|
396
|
-
trust
|
|
397
|
-
```
|
|
398
|
-
|
|
399
|
-
This is qualitatively different.
|
|
400
|
-
|
|
401
|
-
---
|
|
402
|
-
|
|
403
|
-
# 17. Trust becomes graph-native
|
|
404
|
-
|
|
405
|
-
Because provenance is first-class.
|
|
406
|
-
|
|
407
|
-
Agents can reason about:
|
|
408
|
-
|
|
409
|
-
```text id="j7jv58"
|
|
410
|
-
β who asserted
|
|
411
|
-
β confidence
|
|
412
|
-
β derivation
|
|
413
|
-
β validation chain
|
|
414
|
-
β execution trace
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
Current social media cannot do this.
|
|
418
|
-
|
|
419
|
-
---
|
|
420
|
-
|
|
421
|
-
# 18. βFollowingβ changes meaning
|
|
422
|
-
|
|
423
|
-
Today:
|
|
424
|
-
|
|
425
|
-
```text id="t0uwjt"
|
|
426
|
-
follow = content subscription
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
MDLD+Nostr:
|
|
430
|
-
|
|
431
|
-
```text id="9m1t4q"
|
|
432
|
-
follow = semantic trust subscription
|
|
433
|
-
```
|
|
434
|
-
|
|
435
|
-
Huge difference.
|
|
436
|
-
|
|
437
|
-
---
|
|
438
|
-
|
|
439
|
-
# 19. Emergent distributed knowledge graph
|
|
440
|
-
|
|
441
|
-
Without central ontology governance.
|
|
442
|
-
|
|
443
|
-
Because:
|
|
444
|
-
|
|
445
|
-
* RDF is extensible
|
|
446
|
-
* MDLD is lightweight
|
|
447
|
-
* provenance is explicit
|
|
448
|
-
|
|
449
|
-
You get:
|
|
450
|
-
|
|
451
|
-
```text id="7xh3rq"
|
|
452
|
-
federated semantic emergence
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
instead of:
|
|
456
|
-
|
|
457
|
-
```text id="1n0ybs"
|
|
458
|
-
top-down schema enforcement
|
|
459
|
-
```
|
|
460
|
-
|
|
461
|
-
---
|
|
462
|
-
|
|
463
|
-
# 20. The deeper architectural shift
|
|
464
|
-
|
|
465
|
-
Todayβs internet:
|
|
466
|
-
|
|
467
|
-
```text id="m6c3sk"
|
|
468
|
-
documents linked by URLs
|
|
469
|
-
```
|
|
470
|
-
|
|
471
|
-
Semantic Web tried:
|
|
472
|
-
|
|
473
|
-
```text id="yjwmow"
|
|
474
|
-
formal graphs requiring specialists
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
MDLD+Nostr becomes:
|
|
478
|
-
|
|
479
|
-
```text id="jlwm9s"
|
|
480
|
-
human semantic publishing
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
which is radically more socially scalable.
|
|
484
|
-
|
|
485
|
-
---
|
|
486
|
-
|
|
487
|
-
# 21. The most important insight
|
|
488
|
-
|
|
489
|
-
You are not building:
|
|
490
|
-
|
|
491
|
-
```text id="wboiow"
|
|
492
|
-
an RDF note app
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
You are building:
|
|
496
|
-
|
|
497
|
-
```text id="98o3ef"
|
|
498
|
-
a distributed semantic civilization substrate
|
|
499
|
-
```
|
|
500
|
-
|
|
501
|
-
where:
|
|
502
|
-
|
|
503
|
-
* humans write naturally
|
|
504
|
-
* agents reason structurally
|
|
505
|
-
* provenance is preserved
|
|
506
|
-
* execution is inspectable
|
|
507
|
-
* knowledge is portable
|
|
508
|
-
* no platform owns the graph
|
|
509
|
-
|
|
510
|
-
---
|
|
511
|
-
|
|
512
|
-
# Final synthesis
|
|
513
|
-
|
|
514
|
-
MDLD + Nostr + Vaults creates:
|
|
515
|
-
|
|
516
|
-
```text
|
|
517
|
-
semantic local-first internet
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
with:
|
|
521
|
-
|
|
522
|
-
```text
|
|
523
|
-
Markdown β human layer
|
|
524
|
-
RDF β meaning layer
|
|
525
|
-
PROV β time/trust layer
|
|
526
|
-
SHACL β control layer
|
|
527
|
-
JS β execution layer
|
|
528
|
-
ZIP β storage layer
|
|
529
|
-
Nostr β distribution layer
|
|
530
|
-
```
|
|
531
|
-
|
|
532
|
-
This is not merely:
|
|
533
|
-
|
|
534
|
-
```text
|
|
535
|
-
better knowledge management
|
|
536
|
-
```
|
|
537
|
-
|
|
538
|
-
It is potentially:
|
|
539
|
-
|
|
540
|
-
```text
|
|
541
|
-
a post-platform computing model
|
|
542
|
-
```
|
|
543
|
-
|
|
544
|
-
where publishing, memory, execution, coordination, and trust all converge into one append-only semantic substrate.
|