@sharpee/if-domain 2.1.1 → 3.0.0
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/endings.d.ts +39 -0
- package/endings.d.ts.map +1 -0
- package/endings.js +34 -0
- package/endings.js.map +1 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +4 -0
- package/index.js.map +1 -1
- package/package.json +3 -3
- package/phrase.d.ts +33 -3
- package/phrase.d.ts.map +1 -1
- package/phrase.js +6 -1
- package/phrase.js.map +1 -1
- package/snippets.d.ts +73 -0
- package/snippets.d.ts.map +1 -0
- package/snippets.js +54 -0
- package/snippets.js.map +1 -0
package/endings.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Story ending contract (ADR-210 Platform Prerequisite 3).
|
|
3
|
+
*
|
|
4
|
+
* Purpose: bless the existing story-ending convention as a stable wire
|
|
5
|
+
* contract — the event types stories/loaders emit when a story ends and the
|
|
6
|
+
* world-state key the generic `isComplete()` reads. No behavior lives here;
|
|
7
|
+
* emitters build the events with existing primitives.
|
|
8
|
+
*
|
|
9
|
+
* Public interface: `StoryEndingEvents`, `STORY_ENDING_FLAG`,
|
|
10
|
+
* `StoryEndingKind`, `IStoryEndingData`.
|
|
11
|
+
*
|
|
12
|
+
* Owner context: `@sharpee/if-domain` — shared by the story-loader (emits on
|
|
13
|
+
* `win`/`lose`), the engine/clients (react to endings), and transcript tests
|
|
14
|
+
* (assert on the event types), so per the co-located wire-type rule it lives
|
|
15
|
+
* here. INVARIANT: values are frozen contract — changing them breaks saved
|
|
16
|
+
* games and golden transcripts; additions only.
|
|
17
|
+
*/
|
|
18
|
+
/** Semantic event types emitted when a story ends. */
|
|
19
|
+
export declare const StoryEndingEvents: {
|
|
20
|
+
/** The player has won (`win` in Chord; `story.victory` by convention). */
|
|
21
|
+
readonly VICTORY: "story.victory";
|
|
22
|
+
/** The player has lost (`lose` in Chord; `story.defeat` by convention). */
|
|
23
|
+
readonly DEFEAT: "story.defeat";
|
|
24
|
+
};
|
|
25
|
+
/** How a story ended. */
|
|
26
|
+
export type StoryEndingKind = 'victory' | 'defeat';
|
|
27
|
+
/**
|
|
28
|
+
* World-state key holding the ending once one is reached (a
|
|
29
|
+
* `StoryEndingKind`), or unset while play continues. The generic
|
|
30
|
+
* `isComplete()` reads this key; stories never implement completion logic.
|
|
31
|
+
*/
|
|
32
|
+
export declare const STORY_ENDING_FLAG = "story.ending";
|
|
33
|
+
/** Payload carried by a `StoryEndingEvents` event. */
|
|
34
|
+
export interface IStoryEndingData {
|
|
35
|
+
ending: StoryEndingKind;
|
|
36
|
+
/** Message ID of the ending phrase, when the author supplied one. */
|
|
37
|
+
messageId?: string;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=endings.d.ts.map
|
package/endings.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endings.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/endings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,sDAAsD;AACtD,eAAO,MAAM,iBAAiB;IAC5B,0EAA0E;;IAE1E,2EAA2E;;CAEnE,CAAC;AAEX,yBAAyB;AACzB,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD,sDAAsD;AACtD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,qEAAqE;IACrE,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
|
package/endings.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Story ending contract (ADR-210 Platform Prerequisite 3).
|
|
4
|
+
*
|
|
5
|
+
* Purpose: bless the existing story-ending convention as a stable wire
|
|
6
|
+
* contract — the event types stories/loaders emit when a story ends and the
|
|
7
|
+
* world-state key the generic `isComplete()` reads. No behavior lives here;
|
|
8
|
+
* emitters build the events with existing primitives.
|
|
9
|
+
*
|
|
10
|
+
* Public interface: `StoryEndingEvents`, `STORY_ENDING_FLAG`,
|
|
11
|
+
* `StoryEndingKind`, `IStoryEndingData`.
|
|
12
|
+
*
|
|
13
|
+
* Owner context: `@sharpee/if-domain` — shared by the story-loader (emits on
|
|
14
|
+
* `win`/`lose`), the engine/clients (react to endings), and transcript tests
|
|
15
|
+
* (assert on the event types), so per the co-located wire-type rule it lives
|
|
16
|
+
* here. INVARIANT: values are frozen contract — changing them breaks saved
|
|
17
|
+
* games and golden transcripts; additions only.
|
|
18
|
+
*/
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.STORY_ENDING_FLAG = exports.StoryEndingEvents = void 0;
|
|
21
|
+
/** Semantic event types emitted when a story ends. */
|
|
22
|
+
exports.StoryEndingEvents = {
|
|
23
|
+
/** The player has won (`win` in Chord; `story.victory` by convention). */
|
|
24
|
+
VICTORY: 'story.victory',
|
|
25
|
+
/** The player has lost (`lose` in Chord; `story.defeat` by convention). */
|
|
26
|
+
DEFEAT: 'story.defeat',
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* World-state key holding the ending once one is reached (a
|
|
30
|
+
* `StoryEndingKind`), or unset while play continues. The generic
|
|
31
|
+
* `isComplete()` reads this key; stories never implement completion logic.
|
|
32
|
+
*/
|
|
33
|
+
exports.STORY_ENDING_FLAG = 'story.ending';
|
|
34
|
+
//# sourceMappingURL=endings.js.map
|
package/endings.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"endings.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/endings.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;GAgBG;;;AAEH,sDAAsD;AACzC,QAAA,iBAAiB,GAAG;IAC/B,0EAA0E;IAC1E,OAAO,EAAE,eAAe;IACxB,2EAA2E;IAC3E,MAAM,EAAE,cAAc;CACd,CAAC;AAKX;;;;GAIG;AACU,QAAA,iBAAiB,GAAG,cAAc,CAAC"}
|
package/index.d.ts
CHANGED
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,aAAa,CAAC;AAG5B,cAAc,WAAW,CAAC;AAG1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,oBAAoB,CAAC;AAGnC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC;AAGzB,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,UAAU,CAAC;AAGzB,cAAc,aAAa,CAAC;AAG5B,cAAc,WAAW,CAAC;AAG1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,4BAA4B,CAAC;AAG3C,cAAc,oBAAoB,CAAC;AAGnC,cAAc,wBAAwB,CAAC;AAGvC,cAAc,WAAW,CAAC;AAG1B,cAAc,UAAU,CAAC;AAGzB,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,YAAY,CAAC;AAG3B,cAAc,WAAW,CAAC"}
|
package/index.js
CHANGED
|
@@ -43,4 +43,8 @@ __exportStar(require("./channels"), exports);
|
|
|
43
43
|
__exportStar(require("./sound"), exports);
|
|
44
44
|
// Phrase algebra — language-neutral phrase contracts (ADR-192)
|
|
45
45
|
__exportStar(require("./phrase"), exports);
|
|
46
|
+
// Room-description snippet contracts (ADR-209)
|
|
47
|
+
__exportStar(require("./snippets"), exports);
|
|
48
|
+
// Story ending contract (ADR-210 Prerequisite 3)
|
|
49
|
+
__exportStar(require("./endings"), exports);
|
|
46
50
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,gBAAgB;AAChB,2CAAyB;AAEzB,mBAAmB;AACnB,8CAA4B;AAE5B,sBAAsB;AACtB,4CAA0B;AAE1B,+BAA+B;AAC/B,sDAAoC;AACpC,6DAA2C;AAE3C,mBAAmB;AACnB,qDAAmC;AAEnC,uBAAuB;AACvB,yDAAuC;AAEvC,iBAAiB;AACjB,4CAA0B;AAE1B,yBAAyB;AACzB,2CAAyB;AAEzB,uCAAuC;AACvC,6CAA2B;AAE3B,gDAAgD;AAChD,0CAAwB;AAExB,+DAA+D;AAC/D,2CAAyB"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAEH,gBAAgB;AAChB,2CAAyB;AAEzB,mBAAmB;AACnB,8CAA4B;AAE5B,sBAAsB;AACtB,4CAA0B;AAE1B,+BAA+B;AAC/B,sDAAoC;AACpC,6DAA2C;AAE3C,mBAAmB;AACnB,qDAAmC;AAEnC,uBAAuB;AACvB,yDAAuC;AAEvC,iBAAiB;AACjB,4CAA0B;AAE1B,yBAAyB;AACzB,2CAAyB;AAEzB,uCAAuC;AACvC,6CAA2B;AAE3B,gDAAgD;AAChD,0CAAwB;AAExB,+DAA+D;AAC/D,2CAAyB;AAEzB,+CAA+C;AAC/C,6CAA2B;AAE3B,iDAAiD;AACjD,4CAA0B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sharpee/if-domain",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Core domain model and contracts for Sharpee Interactive Fiction Platform",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@sharpee/core": "^
|
|
16
|
-
"@sharpee/text-blocks": "^
|
|
15
|
+
"@sharpee/core": "^3.0.0",
|
|
16
|
+
"@sharpee/text-blocks": "^3.0.0"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
19
19
|
"interactive-fiction",
|
package/phrase.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* `messageId → formatter-chain → string` pipeline with
|
|
8
8
|
* `messageId → phrase tree → Assembler → ITextBlock[]`.
|
|
9
9
|
*
|
|
10
|
-
* Public interface: the `Phrase` union (
|
|
10
|
+
* Public interface: the `Phrase` union (16 members), `PhraseProducer`,
|
|
11
11
|
* `RenderContext` (with the `reference` / `textState` / `contribute` write +
|
|
12
12
|
* `slotContributions` read seams), `Assembler`, and the `isX` kind type guards.
|
|
13
13
|
*
|
|
@@ -85,7 +85,17 @@ export interface PhraseList extends PhraseBase {
|
|
|
85
85
|
items: Phrase[];
|
|
86
86
|
conj: 'and' | 'or';
|
|
87
87
|
}
|
|
88
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* Combinator: ordered join under one punctuation authority.
|
|
90
|
+
*
|
|
91
|
+
* ADR-209 (room-description snippets) reuses this kind as its splice carrier —
|
|
92
|
+
* the ADR's provisional `Seq` was never added because this IS it: the English
|
|
93
|
+
* Assembler realizes `parts` by in-order run concatenation with NO joining
|
|
94
|
+
* punctuation (parts abut byte-exactly; the whitespace authority only
|
|
95
|
+
* collapses, never inserts). A spliced description is a `Sequence` of
|
|
96
|
+
* `Verbatim` prose segments interleaved with resolved snippet values
|
|
97
|
+
* (`Literal` / `Choice`); `Empty` parts are absorbed.
|
|
98
|
+
*/
|
|
89
99
|
export interface Sequence extends PhraseBase {
|
|
90
100
|
kind: 'seq';
|
|
91
101
|
parts: Phrase[];
|
|
@@ -225,6 +235,24 @@ export interface Choice extends PhraseBase {
|
|
|
225
235
|
/** Stable per-choice-site key (text-state secondary key). */
|
|
226
236
|
messageKey: string;
|
|
227
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* Wrapper — a mode-annotated splice part (ADR-211 §Interface contracts). Carries
|
|
240
|
+
* a description-marker fragment together with the join mode its MARKER SITE was
|
|
241
|
+
* classified as (from the authored host prose, never from the fragment text):
|
|
242
|
+
* `clause` (mid-sentence) or `sentence` (after a terminator). The site-mode
|
|
243
|
+
* classification is producer-side (stdlib snippet resolver); the separator
|
|
244
|
+
* CHARACTERS (`', '` / `' '`) are locale realization and belong to the
|
|
245
|
+
* Assembler — none appear here (file invariant). Boundary sites (start of text,
|
|
246
|
+
* paragraph edge) never wrap in `Spliced` at all: their separator is always
|
|
247
|
+
* empty, so the resolver emits `content` directly.
|
|
248
|
+
*/
|
|
249
|
+
export interface Spliced extends PhraseBase {
|
|
250
|
+
kind: 'spliced';
|
|
251
|
+
/** Join mode computed from the authored marker site. */
|
|
252
|
+
mode: 'clause' | 'sentence';
|
|
253
|
+
/** The fragment (bare — never carries its own separator). */
|
|
254
|
+
content: Phrase;
|
|
255
|
+
}
|
|
228
256
|
/**
|
|
229
257
|
* Atom — a sentence boundary (ADR-201 §2). Declares that `child` realizes as a
|
|
230
258
|
* sentence: its first glyph is capitalized and a terminal mark is emitted at its
|
|
@@ -258,7 +286,7 @@ export interface Quote extends PhraseBase {
|
|
|
258
286
|
* `Verb` in ADR-199, and `Sentence`/`Quote` in ADR-201; remaining stubs are
|
|
259
287
|
* reserved for their follow-on ADRs. Extension is additive.
|
|
260
288
|
*/
|
|
261
|
-
export type Phrase = Literal | NounPhrase | PhraseList | Sequence | Empty | Verb | Pronoun | Numeral | Verbatim | Contents | Slot | Optional | Choice | Sentence | Quote;
|
|
289
|
+
export type Phrase = Literal | NounPhrase | PhraseList | Sequence | Empty | Verb | Pronoun | Numeral | Verbatim | Contents | Slot | Optional | Choice | Spliced | Sentence | Quote;
|
|
262
290
|
/**
|
|
263
291
|
* Read-only world access for realization. Language-neutral subset of the world
|
|
264
292
|
* model exposed to the Assembler — no mutation, no parser or command surface.
|
|
@@ -443,6 +471,8 @@ export declare function isSlot(p: Phrase): p is Slot;
|
|
|
443
471
|
export declare function isOptional(p: Phrase): p is Optional;
|
|
444
472
|
/** @returns true if the phrase is a `Choice` (ADR-196). */
|
|
445
473
|
export declare function isChoice(p: Phrase): p is Choice;
|
|
474
|
+
/** @returns true if the phrase is a `Spliced` wrapper (ADR-211). */
|
|
475
|
+
export declare function isSpliced(p: Phrase): p is Spliced;
|
|
446
476
|
/** @returns true if the phrase is a `Sentence` (ADR-201). */
|
|
447
477
|
export declare function isSentence(p: Phrase): p is Sentence;
|
|
448
478
|
/** @returns true if the phrase is a `Quote` (ADR-201). */
|
package/phrase.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phrase.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/phrase.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAM/D;;;;GAIG;AACH,MAAM,WAAW,UAAU;IACzB,+DAA+D;IAC/D,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;CAC7B;AAMD,wFAAwF;AACxF,MAAM,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ED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,QAAQ,CAEnD;AAED,yDAAyD;AACzD,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,IAAI,CAE3C;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,QAAQ,CAEnD;AAED,2DAA2D;AAC3D,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,MAAM,CAE/C;AAED,oEAAoE;AACpE,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,OAAO,CAEjD;AAED,6DAA6D;AAC7D,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,QAAQ,CAEnD;AAED,0DAA0D;AAC1D,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,GAAG,CAAC,IAAI,KAAK,CAE7C"}
|
package/phrase.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* `messageId → formatter-chain → string` pipeline with
|
|
9
9
|
* `messageId → phrase tree → Assembler → ITextBlock[]`.
|
|
10
10
|
*
|
|
11
|
-
* Public interface: the `Phrase` union (
|
|
11
|
+
* Public interface: the `Phrase` union (16 members), `PhraseProducer`,
|
|
12
12
|
* `RenderContext` (with the `reference` / `textState` / `contribute` write +
|
|
13
13
|
* `slotContributions` read seams), `Assembler`, and the `isX` kind type guards.
|
|
14
14
|
*
|
|
@@ -40,6 +40,7 @@ exports.isContents = isContents;
|
|
|
40
40
|
exports.isSlot = isSlot;
|
|
41
41
|
exports.isOptional = isOptional;
|
|
42
42
|
exports.isChoice = isChoice;
|
|
43
|
+
exports.isSpliced = isSpliced;
|
|
43
44
|
exports.isSentence = isSentence;
|
|
44
45
|
exports.isQuote = isQuote;
|
|
45
46
|
// ---------------------------------------------------------------------------
|
|
@@ -97,6 +98,10 @@ function isOptional(p) {
|
|
|
97
98
|
function isChoice(p) {
|
|
98
99
|
return p.kind === 'choice';
|
|
99
100
|
}
|
|
101
|
+
/** @returns true if the phrase is a `Spliced` wrapper (ADR-211). */
|
|
102
|
+
function isSpliced(p) {
|
|
103
|
+
return p.kind === 'spliced';
|
|
104
|
+
}
|
|
100
105
|
/** @returns true if the phrase is a `Sentence` (ADR-201). */
|
|
101
106
|
function isSentence(p) {
|
|
102
107
|
return p.kind === 'sentence';
|
package/phrase.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"phrase.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/phrase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;
|
|
1
|
+
{"version":3,"file":"phrase.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/phrase.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;;AAqfH,8BAEC;AAGD,oCAEC;AAGD,oCAEC;AAGD,gCAEC;AAGD,0BAEC;AAGD,wBAEC;AAGD,8BAEC;AAGD,8BAEC;AAGD,gCAEC;AAGD,gCAEC;AAGD,wBAEC;AAGD,gCAEC;AAGD,4BAEC;AAGD,8BAEC;AAGD,gCAEC;AAGD,0BAEC;AAlFD,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,kDAAkD;AAClD,SAAgB,SAAS,CAAC,CAAS;IACjC,OAAO,CAAC,CAAC,IAAI,KAAK,SAAS,CAAC;AAC9B,CAAC;AAED,qDAAqD;AACrD,SAAgB,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;AAC3B,CAAC;AAED,qDAAqD;AACrD,SAAgB,YAAY,CAAC,CAAS;IACpC,OAAO,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC;AAC3B,CAAC;AAED,mDAAmD;AACn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IAAI,KAAK,UAAU,CAAC;AAC/B,CAAC;AAED,0DAA0D;AAC1D,SAAgB,OAAO,CAAC,CAAS;IAC/B,OAAO,CAAC,CAAC,IAAI,KAAK,OAAO,CAAC;AAC5B,CAAC"}
|
package/snippets.d.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Room-description snippet contracts (ADR-209).
|
|
3
|
+
*
|
|
4
|
+
* Purpose: declare the wire types for author-written snippet maps — text
|
|
5
|
+
* spliced into room descriptions at explicit `{snippet:name}` markers — and
|
|
6
|
+
* the shared marker-extraction helper both the engine (load-time validation)
|
|
7
|
+
* and stdlib (render-time scan) consume.
|
|
8
|
+
*
|
|
9
|
+
* Public interface: `SnippetText`, `SnippetEntry`, `SnippetMap`,
|
|
10
|
+
* `SNIPPET_MARKER_PATTERN`, `extractSnippetMarkers`.
|
|
11
|
+
*
|
|
12
|
+
* Owner context: `@sharpee/if-domain` — these types are shared by world-model
|
|
13
|
+
* (RoomTrait storage), stdlib (scan/gate/resolve in the looking action), and
|
|
14
|
+
* lang-en-us (realization), so per the co-located wire-type rule they live
|
|
15
|
+
* here, beside the phrase contract. INVARIANT: no runtime-specific types and
|
|
16
|
+
* no locale logic — snippet TEXT is opaque author prose; selection semantics
|
|
17
|
+
* ride the existing `Choice` machinery (phrase.ts).
|
|
18
|
+
*/
|
|
19
|
+
/**
|
|
20
|
+
* One snippet text: a raw author string, or a message id resolved through the
|
|
21
|
+
* language provider (the multilingual path — consistent with NPC actions'
|
|
22
|
+
* `{ text } | { messageId }` split, ADR-209 resolution Q6).
|
|
23
|
+
*/
|
|
24
|
+
export type SnippetText = {
|
|
25
|
+
text: string;
|
|
26
|
+
} | {
|
|
27
|
+
messageId: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* One marker's entry in a room's snippet map (ADR-209 Interface contracts):
|
|
31
|
+
* - `string` — one text, spliced verbatim every render.
|
|
32
|
+
* - `string[]` — short form: `cycling` over the texts (resolution Q3).
|
|
33
|
+
* - `SnippetText & { mentions? }` — one text with an optional presence gate.
|
|
34
|
+
* - long form — explicit selector over `texts`, optional presence gate.
|
|
35
|
+
*
|
|
36
|
+
* `mentions` is a serializable entity id doing two jobs (resolution Q7):
|
|
37
|
+
* coverage-lint metadata, and a presence gate — the entry renders only while
|
|
38
|
+
* that entity is transitively contained in the room (resolution Q9).
|
|
39
|
+
*/
|
|
40
|
+
export type SnippetEntry = string | string[] | (SnippetText & {
|
|
41
|
+
mentions?: string;
|
|
42
|
+
}) | {
|
|
43
|
+
selector?: 'cycling' | 'stopping' | 'sticky' | 'random' | 'firstTime';
|
|
44
|
+
texts: Array<string | SnippetText>;
|
|
45
|
+
mentions?: string;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* A room's marker→snippet table, supplied by the author. Plain, serializable
|
|
49
|
+
* data: it rides the room trait through save/load; selection counters live in
|
|
50
|
+
* the text-state store (`Choice`), never here.
|
|
51
|
+
*/
|
|
52
|
+
export type SnippetMap = Record<string, SnippetEntry>;
|
|
53
|
+
/**
|
|
54
|
+
* The `{snippet:name}` marker pattern. Marker names are identifier-like
|
|
55
|
+
* (letters, digits, `_`, `-`); anything else inside the braces is not a
|
|
56
|
+
* marker and passes through as literal prose (a room WITHOUT a snippet map is
|
|
57
|
+
* never scanned at all — ADR-209 semantics 5, AC-7).
|
|
58
|
+
*/
|
|
59
|
+
export declare const SNIPPET_MARKER_PATTERN: RegExp;
|
|
60
|
+
/**
|
|
61
|
+
* Extract the marker names appearing in a description text, in order of first
|
|
62
|
+
* appearance, deduplicated (a duplicate marker resolves once per render —
|
|
63
|
+
* ADR-209 resolution Q8).
|
|
64
|
+
*
|
|
65
|
+
* Shared, pure helper: the engine's load-time unbound-marker validation and
|
|
66
|
+
* stdlib's render-time scan must agree on what a marker IS, so both import
|
|
67
|
+
* this one implementation.
|
|
68
|
+
*
|
|
69
|
+
* @param text a room `description` or `initialDescription` text
|
|
70
|
+
* @returns the distinct marker names, in first-appearance order
|
|
71
|
+
*/
|
|
72
|
+
export declare function extractSnippetMarkers(text: string): string[];
|
|
73
|
+
//# sourceMappingURL=snippets.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/snippets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,MAAM,EAAE,GACR,CAAC,WAAW,GAAG;IAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,GACrC;IACE,QAAQ,CAAC,EAAE,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC;IACtE,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,WAAW,CAAC,CAAC;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEN;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAEtD;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,QAAkC,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAW5D"}
|
package/snippets.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file Room-description snippet contracts (ADR-209).
|
|
4
|
+
*
|
|
5
|
+
* Purpose: declare the wire types for author-written snippet maps — text
|
|
6
|
+
* spliced into room descriptions at explicit `{snippet:name}` markers — and
|
|
7
|
+
* the shared marker-extraction helper both the engine (load-time validation)
|
|
8
|
+
* and stdlib (render-time scan) consume.
|
|
9
|
+
*
|
|
10
|
+
* Public interface: `SnippetText`, `SnippetEntry`, `SnippetMap`,
|
|
11
|
+
* `SNIPPET_MARKER_PATTERN`, `extractSnippetMarkers`.
|
|
12
|
+
*
|
|
13
|
+
* Owner context: `@sharpee/if-domain` — these types are shared by world-model
|
|
14
|
+
* (RoomTrait storage), stdlib (scan/gate/resolve in the looking action), and
|
|
15
|
+
* lang-en-us (realization), so per the co-located wire-type rule they live
|
|
16
|
+
* here, beside the phrase contract. INVARIANT: no runtime-specific types and
|
|
17
|
+
* no locale logic — snippet TEXT is opaque author prose; selection semantics
|
|
18
|
+
* ride the existing `Choice` machinery (phrase.ts).
|
|
19
|
+
*/
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
exports.SNIPPET_MARKER_PATTERN = void 0;
|
|
22
|
+
exports.extractSnippetMarkers = extractSnippetMarkers;
|
|
23
|
+
/**
|
|
24
|
+
* The `{snippet:name}` marker pattern. Marker names are identifier-like
|
|
25
|
+
* (letters, digits, `_`, `-`); anything else inside the braces is not a
|
|
26
|
+
* marker and passes through as literal prose (a room WITHOUT a snippet map is
|
|
27
|
+
* never scanned at all — ADR-209 semantics 5, AC-7).
|
|
28
|
+
*/
|
|
29
|
+
exports.SNIPPET_MARKER_PATTERN = /\{snippet:([A-Za-z0-9_-]+)\}/g;
|
|
30
|
+
/**
|
|
31
|
+
* Extract the marker names appearing in a description text, in order of first
|
|
32
|
+
* appearance, deduplicated (a duplicate marker resolves once per render —
|
|
33
|
+
* ADR-209 resolution Q8).
|
|
34
|
+
*
|
|
35
|
+
* Shared, pure helper: the engine's load-time unbound-marker validation and
|
|
36
|
+
* stdlib's render-time scan must agree on what a marker IS, so both import
|
|
37
|
+
* this one implementation.
|
|
38
|
+
*
|
|
39
|
+
* @param text a room `description` or `initialDescription` text
|
|
40
|
+
* @returns the distinct marker names, in first-appearance order
|
|
41
|
+
*/
|
|
42
|
+
function extractSnippetMarkers(text) {
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
const names = [];
|
|
45
|
+
for (const match of text.matchAll(exports.SNIPPET_MARKER_PATTERN)) {
|
|
46
|
+
const name = match[1];
|
|
47
|
+
if (!seen.has(name)) {
|
|
48
|
+
seen.add(name);
|
|
49
|
+
names.push(name);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return names;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=snippets.js.map
|
package/snippets.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snippets.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/if-domain/src/snippets.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;GAiBG;;;AAyDH,sDAWC;AA/BD;;;;;GAKG;AACU,QAAA,sBAAsB,GAAG,+BAA+B,CAAC;AAEtE;;;;;;;;;;;GAWG;AACH,SAAgB,qBAAqB,CAAC,IAAY;IAChD,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,CAAC,8BAAsB,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;QACtB,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACpB,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACf,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|