@dtmd/temper 0.0.21 → 0.0.22
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/dist/src/assembly.js +1 -1
- package/dist/src/declarations.d.ts +4 -40
- package/dist/src/declarations.js +62 -69
- package/dist/src/emit.js +199 -102
- package/dist/src/generated/PayloadMember.d.ts +9 -3
- package/dist/src/member-address.d.ts +97 -28
- package/dist/src/member-address.js +104 -34
- package/dist/src/prose.d.ts +39 -3
- package/dist/src/prose.js +41 -5
- package/package.json +3 -3
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The member-address grammar — one home for every spelling a member's identity takes and
|
|
3
|
-
* for the reader those writers round-trip against. Three spellings, each the one
|
|
4
|
-
* it
|
|
3
|
+
* for the reader those writers round-trip against. Three spellings, each built on the one
|
|
4
|
+
* before it:
|
|
5
5
|
*
|
|
6
6
|
* - `<kind>:<name>` — a **host address**, a top-level member's own identity.
|
|
7
7
|
* - `<host-address>/<kind>/<key>` — a **nested-member address**, the identity a member
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* beneath a host carries. Any member's address may host, so the host segment is itself
|
|
9
|
+
* a member address and the spelling nests as deep as the model does.
|
|
10
|
+
* - `<member-address>/<leaf>` — a **leaf address**, one authored string beneath a nested
|
|
11
|
+
* member. A grain of its own, and no member address at all.
|
|
11
12
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
13
|
+
* Every name, key and leaf is **one segment** — a leaf's child path joins its own layers
|
|
14
|
+
* with `.`, never `/` (`declarations.ts`'s `embeddedLeafMentionRows`) — so the segment
|
|
15
|
+
* **count** decides the grain: a member address has an odd count, a leaf address an even
|
|
16
|
+
* one. That parity is the whole discrimination, which is why both grains are read off
|
|
17
|
+
* **one** segmentation ({@link segment}) rather than two independently-shaped parses that
|
|
18
|
+
* could come to disagree about where the member ends. The engine's `src/member_address.rs`
|
|
19
|
+
* is the other end of the same grammar: a spelling moves on both sides at once or the seam
|
|
16
20
|
* breaks.
|
|
17
21
|
*/
|
|
18
22
|
/** The two halves a host address names — the reader's answer, and never re-split by hand. */
|
|
@@ -24,7 +28,10 @@ export interface HostAddress {
|
|
|
24
28
|
}
|
|
25
29
|
/** One parsed nested-member address. */
|
|
26
30
|
export interface NestedAddress {
|
|
27
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* The host member's own address — every segment but the final two, verbatim, and itself
|
|
33
|
+
* a member address (`area:a`, or `area:a/page/b` one layer down).
|
|
34
|
+
*/
|
|
28
35
|
readonly host: string;
|
|
29
36
|
/** The nested member's kind. */
|
|
30
37
|
readonly kind: string;
|
|
@@ -35,22 +42,71 @@ export interface NestedAddress {
|
|
|
35
42
|
export interface LeafAddress {
|
|
36
43
|
/**
|
|
37
44
|
* The member the leaf lives under, verbatim as its author spelled it: the canonical
|
|
38
|
-
* `<kind>:<name>` host address,
|
|
39
|
-
*
|
|
40
|
-
* question, not the grammar's.
|
|
45
|
+
* `<kind>:<name>` host address, that host's own whole address one layer down, or the
|
|
46
|
+
* bare member id a lock committed before the writers spelled the canonical head.
|
|
47
|
+
* Which spelling a head is, is resolution's question, not the grammar's.
|
|
41
48
|
*/
|
|
42
49
|
readonly member: string;
|
|
43
50
|
/** The nested member's kind. */
|
|
44
51
|
readonly kind: string;
|
|
45
52
|
/** The nested member's key among its host's members of that kind. */
|
|
46
53
|
readonly key: string;
|
|
47
|
-
/**
|
|
54
|
+
/**
|
|
55
|
+
* The leaf's path within the nested member — the address's **final segment**, dots
|
|
56
|
+
* intact and carrying no `/`: a child path joins its own layers with `.`
|
|
57
|
+
* (`declarations.ts`'s `embeddedLeafMentionRows`), so a further `/` is a further segment
|
|
58
|
+
* and the count reads the whole as a member address instead.
|
|
59
|
+
*/
|
|
48
60
|
readonly childPath: string;
|
|
49
61
|
}
|
|
50
62
|
/** Spell a top-level member's own `<kind>:<name>` address. */
|
|
51
63
|
export declare function hostAddress(kind: string, name: string): string;
|
|
52
64
|
/** Spell a nested member's address from its host's address, its own kind and its key. */
|
|
53
65
|
export declare function nestedAddress(host: string, kind: string, key: string): string;
|
|
66
|
+
/**
|
|
67
|
+
* The three facts a member's own address composes from — its kind, its name, and the host
|
|
68
|
+
* member a nested-file child sits under. Structurally what a composed `Member` carries, so
|
|
69
|
+
* {@link memberAddress} takes one without this module depending on `kind.ts`: the grammar
|
|
70
|
+
* is the bottom of the tree and owes the member model nothing.
|
|
71
|
+
*/
|
|
72
|
+
export interface AddressedMember {
|
|
73
|
+
/** The member's kind. */
|
|
74
|
+
readonly kind: string;
|
|
75
|
+
/** The member's name among its kind — its key where it sits beneath a host. */
|
|
76
|
+
readonly name: string;
|
|
77
|
+
/**
|
|
78
|
+
* The host a nested-file child composes under; absent at every other locus. Itself an
|
|
79
|
+
* addressed member, because a host may be nested too and contributes its **own whole
|
|
80
|
+
* address** — the shape recurses exactly as far as the model nests, which is what a
|
|
81
|
+
* composed `Member` already carries (`kind.ts`'s `Member.host`).
|
|
82
|
+
*/
|
|
83
|
+
readonly host?: AddressedMember | undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* A member's **own address** — the one home for the discrimination between the two forms a
|
|
87
|
+
* composed member's identity takes, and the twin of the engine's `payload_member_address`
|
|
88
|
+
* over the same member arriving on the seam ({@link AddressedMember.host} is the payload's
|
|
89
|
+
* own `host` column).
|
|
90
|
+
*
|
|
91
|
+
* A top-level member's address is its kind joined onto its name ({@link hostAddress}). A
|
|
92
|
+
* nested **file** child's identity *is* its whole `<host-address>/<kind>/<key>` address,
|
|
93
|
+
* exactly as an embedded member's is: the host segment is the whole of what tells two
|
|
94
|
+
* same-named children under different hosts apart, so two hosts may each carry a `home`
|
|
95
|
+
* and neither claims the other's. Keying one by `<kind>:<name>` alone made a child's name
|
|
96
|
+
* corpus-wide at a grain the grammar scopes to a host.
|
|
97
|
+
*
|
|
98
|
+
* The host contributes its **own whole address**, composed through this very function, so
|
|
99
|
+
* depth is the model's to choose rather than the grammar's: any member's address may host,
|
|
100
|
+
* and a host that is itself nested is spelled `area:a/page/b`, so the grandparent survives
|
|
101
|
+
* into every row its child is declared under. Flattening the host to `<kind>:<name>` lost
|
|
102
|
+
* that grandparent the moment a second layer emitted, and keyed two cousins — one name
|
|
103
|
+
* under each of two hosts — under one address.
|
|
104
|
+
*
|
|
105
|
+
* Every site naming "the address of this member" reads the rule here rather than deciding
|
|
106
|
+
* the join again, so the rows a member is declared, cited and mentioned under cannot come
|
|
107
|
+
* to disagree with the address it resolves at.
|
|
108
|
+
*/
|
|
109
|
+
export declare function memberAddress(member: AddressedMember): string;
|
|
54
110
|
/**
|
|
55
111
|
* Whether `spelling` is exactly **one segment** of this grammar — non-empty, and carrying
|
|
56
112
|
* none of the `/` {@link segment} cuts an address at.
|
|
@@ -58,9 +114,11 @@ export declare function nestedAddress(host: string, kind: string, key: string):
|
|
|
58
114
|
* The predicate every writer's caller judges a key by, because {@link nestedAddress} is
|
|
59
115
|
* infallible and the reader beneath it is not. A key carrying a `/` shifts every segment
|
|
60
116
|
* below it by one: `nestedAddress("spec:alpha", "decision", "authority/rejected")` spells
|
|
61
|
-
* the very address the member keyed `authority` spells for its `rejected` leaf
|
|
62
|
-
*
|
|
63
|
-
*
|
|
117
|
+
* the very address the member keyed `authority` spells for its `rejected` leaf — and since
|
|
118
|
+
* the count decides the grain, that address is **even** and so a leaf's by construction,
|
|
119
|
+
* no member address at all. The member's own identity answers its sibling's leaf and
|
|
120
|
+
* nothing answers the member. An empty key spells an address {@link segment} admits at no
|
|
121
|
+
* grain at all.
|
|
64
122
|
* `specs/model/representation.md` ("member") makes both a malformed lock rather than a
|
|
65
123
|
* precedence rule: resolution is total, and coincident addresses are refused.
|
|
66
124
|
*
|
|
@@ -84,9 +142,13 @@ export declare function isOneSegment(spelling: string): boolean;
|
|
|
84
142
|
*/
|
|
85
143
|
export declare function isNameQualifier(spelling: string): boolean;
|
|
86
144
|
/**
|
|
87
|
-
* Spell one leaf's address beneath a nested member. `member` is carried verbatim,
|
|
88
|
-
* writer
|
|
89
|
-
*
|
|
145
|
+
* Spell one leaf's address beneath a nested member. `member` is carried verbatim, and
|
|
146
|
+
* every writer hands it the hosting member's **own whole address** at whatever grain the
|
|
147
|
+
* host sits — `<kind>:<name>` top-level, the host's whole address under a nested one
|
|
148
|
+
* ({@link memberAddress}). A bare member id spells a head the reader still accepts for
|
|
149
|
+
* the locks that commit it ({@link LeafAddress.member}), never one to write: a nested
|
|
150
|
+
* file child's identity *is* its host-qualified address, so a bare head names no member
|
|
151
|
+
* at resolution and two sibling children of one name head one string.
|
|
90
152
|
*/
|
|
91
153
|
export declare function leafAddress(member: string, kind: string, key: string, childPath: string): string;
|
|
92
154
|
/**
|
|
@@ -125,17 +187,24 @@ export declare function edgeLookupKey(address: string, to: readonly string[]): s
|
|
|
125
187
|
*/
|
|
126
188
|
export declare function parseHostAddress(address: string): HostAddress | undefined;
|
|
127
189
|
/**
|
|
128
|
-
* Parse a nested-member address, or `undefined` when `address` is not one
|
|
129
|
-
* non-empty segments, the first of them a host address.
|
|
190
|
+
* Parse a nested-member address, or `undefined` when `address` is not one.
|
|
130
191
|
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* the
|
|
192
|
+
* The grammar is an **odd** count of non-empty segments, three or more: a host address —
|
|
193
|
+
* every segment but the final two, itself a member address at any depth — then the nested
|
|
194
|
+
* kind and the key. Depth is the model's to choose, not the grammar's: any member's address
|
|
195
|
+
* may host, so the reader reads what the model nests rather than capping at one layer.
|
|
196
|
+
*
|
|
197
|
+
* The **leaf tail is ruled out by the count**: a leaf is its own grain, parsed by
|
|
198
|
+
* {@link parseLeafAddress} off this very segmentation, so an even count is no member
|
|
199
|
+
* address at all. Truncating one to the member that happens to contain the leaf would
|
|
200
|
+
* answer a leaf reference with a member the author never named.
|
|
134
201
|
*/
|
|
135
202
|
export declare function parseNestedAddress(address: string): NestedAddress | undefined;
|
|
136
203
|
/**
|
|
137
|
-
* Parse a leaf address
|
|
138
|
-
*
|
|
139
|
-
*
|
|
204
|
+
* Parse a leaf address — a member address plus its `/<leaf>` tail, so an **even** count of
|
|
205
|
+
* segments — or `undefined` when `target` carries an odd count or a segment-shaped hole.
|
|
206
|
+
*
|
|
207
|
+
* The head is carried on verbatim rather than split, because the bare member id is a live
|
|
208
|
+
* short form ({@link LeafAddress.member}).
|
|
140
209
|
*/
|
|
141
210
|
export declare function parseLeafAddress(target: string): LeafAddress | undefined;
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The member-address grammar — one home for every spelling a member's identity takes and
|
|
3
|
-
* for the reader those writers round-trip against. Three spellings, each the one
|
|
4
|
-
* it
|
|
3
|
+
* for the reader those writers round-trip against. Three spellings, each built on the one
|
|
4
|
+
* before it:
|
|
5
5
|
*
|
|
6
6
|
* - `<kind>:<name>` — a **host address**, a top-level member's own identity.
|
|
7
7
|
* - `<host-address>/<kind>/<key>` — a **nested-member address**, the identity a member
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
8
|
+
* beneath a host carries. Any member's address may host, so the host segment is itself
|
|
9
|
+
* a member address and the spelling nests as deep as the model does.
|
|
10
|
+
* - `<member-address>/<leaf>` — a **leaf address**, one authored string beneath a nested
|
|
11
|
+
* member. A grain of its own, and no member address at all.
|
|
12
|
+
*
|
|
13
|
+
* Every name, key and leaf is **one segment** — a leaf's child path joins its own layers
|
|
14
|
+
* with `.`, never `/` (`declarations.ts`'s `embeddedLeafMentionRows`) — so the segment
|
|
15
|
+
* **count** decides the grain: a member address has an odd count, a leaf address an even
|
|
16
|
+
* one. That parity is the whole discrimination, which is why both grains are read off
|
|
17
|
+
* **one** segmentation ({@link segment}) rather than two independently-shaped parses that
|
|
18
|
+
* could come to disagree about where the member ends. The engine's `src/member_address.rs`
|
|
19
|
+
* is the other end of the same grammar: a spelling moves on both sides at once or the seam
|
|
16
20
|
* breaks.
|
|
17
21
|
*/
|
|
18
22
|
/** Spell a top-level member's own `<kind>:<name>` address. */
|
|
@@ -23,6 +27,36 @@ export function hostAddress(kind, name) {
|
|
|
23
27
|
export function nestedAddress(host, kind, key) {
|
|
24
28
|
return `${host}/${kind}/${key}`;
|
|
25
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* A member's **own address** — the one home for the discrimination between the two forms a
|
|
32
|
+
* composed member's identity takes, and the twin of the engine's `payload_member_address`
|
|
33
|
+
* over the same member arriving on the seam ({@link AddressedMember.host} is the payload's
|
|
34
|
+
* own `host` column).
|
|
35
|
+
*
|
|
36
|
+
* A top-level member's address is its kind joined onto its name ({@link hostAddress}). A
|
|
37
|
+
* nested **file** child's identity *is* its whole `<host-address>/<kind>/<key>` address,
|
|
38
|
+
* exactly as an embedded member's is: the host segment is the whole of what tells two
|
|
39
|
+
* same-named children under different hosts apart, so two hosts may each carry a `home`
|
|
40
|
+
* and neither claims the other's. Keying one by `<kind>:<name>` alone made a child's name
|
|
41
|
+
* corpus-wide at a grain the grammar scopes to a host.
|
|
42
|
+
*
|
|
43
|
+
* The host contributes its **own whole address**, composed through this very function, so
|
|
44
|
+
* depth is the model's to choose rather than the grammar's: any member's address may host,
|
|
45
|
+
* and a host that is itself nested is spelled `area:a/page/b`, so the grandparent survives
|
|
46
|
+
* into every row its child is declared under. Flattening the host to `<kind>:<name>` lost
|
|
47
|
+
* that grandparent the moment a second layer emitted, and keyed two cousins — one name
|
|
48
|
+
* under each of two hosts — under one address.
|
|
49
|
+
*
|
|
50
|
+
* Every site naming "the address of this member" reads the rule here rather than deciding
|
|
51
|
+
* the join again, so the rows a member is declared, cited and mentioned under cannot come
|
|
52
|
+
* to disagree with the address it resolves at.
|
|
53
|
+
*/
|
|
54
|
+
export function memberAddress(member) {
|
|
55
|
+
const { host } = member;
|
|
56
|
+
if (host === undefined)
|
|
57
|
+
return hostAddress(member.kind, member.name);
|
|
58
|
+
return nestedAddress(memberAddress(host), member.kind, member.name);
|
|
59
|
+
}
|
|
26
60
|
/**
|
|
27
61
|
* Whether `spelling` is exactly **one segment** of this grammar — non-empty, and carrying
|
|
28
62
|
* none of the `/` {@link segment} cuts an address at.
|
|
@@ -30,9 +64,11 @@ export function nestedAddress(host, kind, key) {
|
|
|
30
64
|
* The predicate every writer's caller judges a key by, because {@link nestedAddress} is
|
|
31
65
|
* infallible and the reader beneath it is not. A key carrying a `/` shifts every segment
|
|
32
66
|
* below it by one: `nestedAddress("spec:alpha", "decision", "authority/rejected")` spells
|
|
33
|
-
* the very address the member keyed `authority` spells for its `rejected` leaf
|
|
34
|
-
*
|
|
35
|
-
*
|
|
67
|
+
* the very address the member keyed `authority` spells for its `rejected` leaf — and since
|
|
68
|
+
* the count decides the grain, that address is **even** and so a leaf's by construction,
|
|
69
|
+
* no member address at all. The member's own identity answers its sibling's leaf and
|
|
70
|
+
* nothing answers the member. An empty key spells an address {@link segment} admits at no
|
|
71
|
+
* grain at all.
|
|
36
72
|
* `specs/model/representation.md` ("member") makes both a malformed lock rather than a
|
|
37
73
|
* precedence rule: resolution is total, and coincident addresses are refused.
|
|
38
74
|
*
|
|
@@ -60,9 +96,13 @@ export function isNameQualifier(spelling) {
|
|
|
60
96
|
return !spelling.includes("/");
|
|
61
97
|
}
|
|
62
98
|
/**
|
|
63
|
-
* Spell one leaf's address beneath a nested member. `member` is carried verbatim,
|
|
64
|
-
* writer
|
|
65
|
-
*
|
|
99
|
+
* Spell one leaf's address beneath a nested member. `member` is carried verbatim, and
|
|
100
|
+
* every writer hands it the hosting member's **own whole address** at whatever grain the
|
|
101
|
+
* host sits — `<kind>:<name>` top-level, the host's whole address under a nested one
|
|
102
|
+
* ({@link memberAddress}). A bare member id spells a head the reader still accepts for
|
|
103
|
+
* the locks that commit it ({@link LeafAddress.member}), never one to write: a nested
|
|
104
|
+
* file child's identity *is* its host-qualified address, so a bare head names no member
|
|
105
|
+
* at resolution and two sibling children of one name head one string.
|
|
66
106
|
*/
|
|
67
107
|
export function leafAddress(member, kind, key, childPath) {
|
|
68
108
|
return `${nestedAddress(member, kind, key)}/${childPath}`;
|
|
@@ -115,39 +155,69 @@ export function parseHostAddress(address) {
|
|
|
115
155
|
}
|
|
116
156
|
/**
|
|
117
157
|
* Cut an address into its segments, or `undefined` when it carries fewer than three or a
|
|
118
|
-
* segment-shaped hole
|
|
119
|
-
*
|
|
158
|
+
* segment-shaped hole — an address names exactly one thing or the reader refuses, so an
|
|
159
|
+
* empty segment names nothing.
|
|
160
|
+
*
|
|
161
|
+
* The cut is at **every** `/`, and the count decides the grain: every name, key and leaf
|
|
162
|
+
* is one segment, so an even count ends in a `/<leaf>` tail and an odd one stops at member
|
|
163
|
+
* grain. The tail is therefore the final segment alone, not the remainder past a fixed
|
|
164
|
+
* count.
|
|
165
|
+
*
|
|
166
|
+
* Three is the cut's floor: the shallowest member address beneath a host is
|
|
167
|
+
* `<kind>:<name>/<kind>/<key>`, and the shallowest leaf address names a nested member's
|
|
168
|
+
* kind and key ahead of its leaf ({@link LeafAddress}), so it is four.
|
|
120
169
|
*/
|
|
121
170
|
function segment(address) {
|
|
122
171
|
const parts = address.split("/");
|
|
123
|
-
if (parts.length < 3)
|
|
172
|
+
if (parts.length < 3 || parts.includes(""))
|
|
124
173
|
return undefined;
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
174
|
+
// Even is leaf grain: the final segment is the whole leaf, and everything ahead of it is
|
|
175
|
+
// a member address of odd count — three segments at least, which the cut below takes
|
|
176
|
+
// apart.
|
|
177
|
+
const leaf = parts.length % 2 === 0;
|
|
178
|
+
const member = leaf ? parts.slice(0, -1) : parts;
|
|
179
|
+
// A member address ends in its own kind and key; everything ahead of those two is the
|
|
180
|
+
// host address, carried whole however deep it runs.
|
|
181
|
+
return {
|
|
182
|
+
host: member.slice(0, -2).join("/"),
|
|
183
|
+
kind: member[member.length - 2],
|
|
184
|
+
key: member[member.length - 1],
|
|
185
|
+
tail: leaf ? parts[parts.length - 1] : undefined,
|
|
186
|
+
};
|
|
130
187
|
}
|
|
131
188
|
/**
|
|
132
|
-
* Parse a nested-member address, or `undefined` when `address` is not one
|
|
133
|
-
*
|
|
189
|
+
* Parse a nested-member address, or `undefined` when `address` is not one.
|
|
190
|
+
*
|
|
191
|
+
* The grammar is an **odd** count of non-empty segments, three or more: a host address —
|
|
192
|
+
* every segment but the final two, itself a member address at any depth — then the nested
|
|
193
|
+
* kind and the key. Depth is the model's to choose, not the grammar's: any member's address
|
|
194
|
+
* may host, so the reader reads what the model nests rather than capping at one layer.
|
|
134
195
|
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
* the
|
|
196
|
+
* The **leaf tail is ruled out by the count**: a leaf is its own grain, parsed by
|
|
197
|
+
* {@link parseLeafAddress} off this very segmentation, so an even count is no member
|
|
198
|
+
* address at all. Truncating one to the member that happens to contain the leaf would
|
|
199
|
+
* answer a leaf reference with a member the author never named.
|
|
138
200
|
*/
|
|
139
201
|
export function parseNestedAddress(address) {
|
|
140
202
|
const segments = segment(address);
|
|
203
|
+
// An odd count and no tail: an even count ends in a `/<leaf>`, a different grain.
|
|
141
204
|
if (segments === undefined || segments.tail !== undefined)
|
|
142
205
|
return undefined;
|
|
143
|
-
|
|
206
|
+
// The host is itself a member address, read at its own grain: a top-level host address,
|
|
207
|
+
// or a nested one read back through this very parser however deep it runs. Never off a
|
|
208
|
+
// first-colon split, which would take `area` / `a/page/b` out of `area:a/page/b`.
|
|
209
|
+
const { host } = segments;
|
|
210
|
+
if (parseHostAddress(host) === undefined && parseNestedAddress(host) === undefined) {
|
|
144
211
|
return undefined;
|
|
145
|
-
|
|
212
|
+
}
|
|
213
|
+
return { host, kind: segments.kind, key: segments.key };
|
|
146
214
|
}
|
|
147
215
|
/**
|
|
148
|
-
* Parse a leaf address
|
|
149
|
-
*
|
|
150
|
-
*
|
|
216
|
+
* Parse a leaf address — a member address plus its `/<leaf>` tail, so an **even** count of
|
|
217
|
+
* segments — or `undefined` when `target` carries an odd count or a segment-shaped hole.
|
|
218
|
+
*
|
|
219
|
+
* The head is carried on verbatim rather than split, because the bare member id is a live
|
|
220
|
+
* short form ({@link LeafAddress.member}).
|
|
151
221
|
*/
|
|
152
222
|
export function parseLeafAddress(target) {
|
|
153
223
|
const segments = segment(target);
|
package/dist/src/prose.d.ts
CHANGED
|
@@ -22,9 +22,10 @@ export interface Mentionable {
|
|
|
22
22
|
readonly display: string;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
|
-
* Spell a
|
|
26
|
-
* {@link
|
|
27
|
-
* repeats to cite a member from prose.
|
|
25
|
+
* Spell a member as the {@link Mentionable} a mention carries: its own
|
|
26
|
+
* {@link memberAddress}, its bare name the display text — the convention every corpus
|
|
27
|
+
* repeats to cite a member from prose. A nested file child spells the host-qualified
|
|
28
|
+
* address it resolves at, exactly as its declaration rows key by it.
|
|
28
29
|
*/
|
|
29
30
|
export declare function mentionOf(member: Member): Mentionable;
|
|
30
31
|
/** One authored interpolation: position in the template plus its target. */
|
|
@@ -201,3 +202,38 @@ export declare function renderText(prose: Text): string;
|
|
|
201
202
|
* If a mention names no declared value and has no discovery locus.
|
|
202
203
|
*/
|
|
203
204
|
export declare function resolveLeaf(value: string | Text, scope: MentionScope, context: string): string;
|
|
205
|
+
/**
|
|
206
|
+
* One embedded member value's leaves after {@link resolveEmbeddedLeaves} — the
|
|
207
|
+
* top-level fields and each collection's entries, every `Text` already rendered to
|
|
208
|
+
* its final stored string. Both faces of a composed body spell this same pair:
|
|
209
|
+
* `kind.ts`'s `ResolvedEmbeddedMemberValue` (what a `render` hook receives) and the
|
|
210
|
+
* generated `NestedMemberRow` (what the engine reads), the entry shape theirs share
|
|
211
|
+
* as `ResolvedEmbeddedMemberCollectionEntry` and `CollectionEntryWire`.
|
|
212
|
+
*/
|
|
213
|
+
export interface ResolvedEmbeddedLeaves {
|
|
214
|
+
/** Top-level leaves, keyed by field name, in authored order. */
|
|
215
|
+
readonly leaves: Record<string, string>;
|
|
216
|
+
/** Sibling collections, each entry's leaves resolved, in authored order. */
|
|
217
|
+
readonly collections: Record<string, {
|
|
218
|
+
readonly key: string;
|
|
219
|
+
readonly leaves: Record<string, string>;
|
|
220
|
+
}[]>;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Resolve one embedded member value's leaves — the top-level fields and each
|
|
224
|
+
* collection entry's — to their final stored strings, each through
|
|
225
|
+
* {@link resolveLeaf} against `scope`, in authored order.
|
|
226
|
+
*
|
|
227
|
+
* The one walk behind both faces of a composed body: the `member.<kind> <key>`
|
|
228
|
+
* fence `emit` renders and the `nested_member` declaration row the engine reads.
|
|
229
|
+
* Each face still reads the authored value for itself (0018's second read), but
|
|
230
|
+
* off this one resolution, so a dangling leaf mention refuses identically
|
|
231
|
+
* whichever face runs — both name the leaf by the one context grammar
|
|
232
|
+
* ``member.<kind> <key>: leaf `<child-path>` ``, a collection entry's child path
|
|
233
|
+
* spelled `<collection>.<entry-key>.<field>`.
|
|
234
|
+
*
|
|
235
|
+
* # Throws
|
|
236
|
+
* If a leaf's mention names no declared value and has no discovery locus, or a
|
|
237
|
+
* leaf carries an include ({@link resolveLeaf}).
|
|
238
|
+
*/
|
|
239
|
+
export declare function resolveEmbeddedLeaves(value: EmbeddedMemberValue, scope: MentionScope): ResolvedEmbeddedLeaves;
|
package/dist/src/prose.js
CHANGED
|
@@ -13,14 +13,15 @@
|
|
|
13
13
|
* **include** (an {@link Include}) pulls the target file's bytes into the host's emitted
|
|
14
14
|
* projection. Both are authored per word and resolution-checked at emit, never mined.
|
|
15
15
|
*/
|
|
16
|
-
import {
|
|
16
|
+
import { memberAddress, parseHostAddress } from "./member-address.js";
|
|
17
17
|
/**
|
|
18
|
-
* Spell a
|
|
19
|
-
* {@link
|
|
20
|
-
* repeats to cite a member from prose.
|
|
18
|
+
* Spell a member as the {@link Mentionable} a mention carries: its own
|
|
19
|
+
* {@link memberAddress}, its bare name the display text — the convention every corpus
|
|
20
|
+
* repeats to cite a member from prose. A nested file child spells the host-qualified
|
|
21
|
+
* address it resolves at, exactly as its declaration rows key by it.
|
|
21
22
|
*/
|
|
22
23
|
export function mentionOf(member) {
|
|
23
|
-
return { address:
|
|
24
|
+
return { address: memberAddress(member), display: member.name };
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* Whether an unresolved address **defers to the gate** rather than refusing at emit: a
|
|
@@ -238,3 +239,38 @@ export function resolveLeaf(value, scope, context) {
|
|
|
238
239
|
checkMentions(value.mentions, scope, context);
|
|
239
240
|
return renderText(value);
|
|
240
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Resolve one embedded member value's leaves — the top-level fields and each
|
|
244
|
+
* collection entry's — to their final stored strings, each through
|
|
245
|
+
* {@link resolveLeaf} against `scope`, in authored order.
|
|
246
|
+
*
|
|
247
|
+
* The one walk behind both faces of a composed body: the `member.<kind> <key>`
|
|
248
|
+
* fence `emit` renders and the `nested_member` declaration row the engine reads.
|
|
249
|
+
* Each face still reads the authored value for itself (0018's second read), but
|
|
250
|
+
* off this one resolution, so a dangling leaf mention refuses identically
|
|
251
|
+
* whichever face runs — both name the leaf by the one context grammar
|
|
252
|
+
* ``member.<kind> <key>: leaf `<child-path>` ``, a collection entry's child path
|
|
253
|
+
* spelled `<collection>.<entry-key>.<field>`.
|
|
254
|
+
*
|
|
255
|
+
* # Throws
|
|
256
|
+
* If a leaf's mention names no declared value and has no discovery locus, or a
|
|
257
|
+
* leaf carries an include ({@link resolveLeaf}).
|
|
258
|
+
*/
|
|
259
|
+
export function resolveEmbeddedLeaves(value, scope) {
|
|
260
|
+
const context = (childPath) => `member.${value.kind} ${value.key}: leaf \`${childPath}\``;
|
|
261
|
+
const leaves = {};
|
|
262
|
+
for (const [field, leaf] of Object.entries(value.leaves)) {
|
|
263
|
+
leaves[field] = resolveLeaf(leaf, scope, context(field));
|
|
264
|
+
}
|
|
265
|
+
const collections = {};
|
|
266
|
+
for (const [collection, entries] of Object.entries(value.collections)) {
|
|
267
|
+
collections[collection] = entries.map((entry) => {
|
|
268
|
+
const entryLeaves = {};
|
|
269
|
+
for (const [field, leaf] of Object.entries(entry.leaves)) {
|
|
270
|
+
entryLeaves[field] = resolveLeaf(leaf, scope, context(`${collection}.${entry.key}.${field}`));
|
|
271
|
+
}
|
|
272
|
+
return { key: entry.key, leaves: entryLeaves };
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
return { leaves, collections };
|
|
276
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dtmd/temper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.22",
|
|
4
4
|
"description": "The temper authoring face — the six-noun model as typed modules: harness(), kind<T>(), clause values, needs, and file()/text/blocks(). Emit compiles to the declaration rows the engine reads, a byte-faithful projection, and the lock.",
|
|
5
5
|
"license": "(MIT OR Apache-2.0)",
|
|
6
6
|
"repository": {
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"temper": "bin/temper.js"
|
|
53
53
|
},
|
|
54
54
|
"optionalDependencies": {
|
|
55
|
-
"@dtmd/temper-linux-x64": "0.0.
|
|
56
|
-
"@dtmd/temper-win32-x64": "0.0.
|
|
55
|
+
"@dtmd/temper-linux-x64": "0.0.22",
|
|
56
|
+
"@dtmd/temper-win32-x64": "0.0.22"
|
|
57
57
|
}
|
|
58
58
|
}
|