@sharpee/text-blocks 0.9.61-beta

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 David Cornelson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Type Guards for TextBlock types
3
+ *
4
+ * Utilities for safely working with TextContent, IDecoration, and ITextBlock.
5
+ */
6
+ import type { TextContent, IDecoration, ITextBlock } from './types';
7
+ /**
8
+ * Check if content is a decoration (not a plain string).
9
+ *
10
+ * @example
11
+ * const content: TextContent = getContent();
12
+ * if (isDecoration(content)) {
13
+ * console.log(content.type); // TypeScript knows this is IDecoration
14
+ * }
15
+ */
16
+ export declare function isDecoration(content: TextContent): content is IDecoration;
17
+ /**
18
+ * Check if a value is a valid TextBlock.
19
+ *
20
+ * @example
21
+ * if (isTextBlock(value)) {
22
+ * console.log(value.key);
23
+ * }
24
+ */
25
+ export declare function isTextBlock(value: unknown): value is ITextBlock;
26
+ /**
27
+ * Check if a block key starts with a given prefix.
28
+ *
29
+ * @example
30
+ * if (hasKeyPrefix(block, 'status.')) {
31
+ * // Render to status bar
32
+ * }
33
+ */
34
+ export declare function hasKeyPrefix(block: ITextBlock, prefix: string): boolean;
35
+ /**
36
+ * Check if a block is a status block.
37
+ */
38
+ export declare function isStatusBlock(block: ITextBlock): boolean;
39
+ /**
40
+ * Check if a block is a room-related block.
41
+ */
42
+ export declare function isRoomBlock(block: ITextBlock): boolean;
43
+ /**
44
+ * Check if a block is an action-related block.
45
+ */
46
+ export declare function isActionBlock(block: ITextBlock): boolean;
47
+ /**
48
+ * Extract plain text from TextContent, stripping all decorations.
49
+ *
50
+ * @example
51
+ * const text = extractPlainText([
52
+ * 'You take ',
53
+ * { type: 'item', content: ['the sword'] },
54
+ * '.'
55
+ * ]);
56
+ * // Returns: "You take the sword."
57
+ */
58
+ export declare function extractPlainText(content: ReadonlyArray<TextContent>): string;
59
+ //# sourceMappingURL=guards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.d.ts","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEpE;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,IAAI,WAAW,CAEzE;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAS/D;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAExD;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAEtD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAExD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,MAAM,CAS5E"}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ /**
3
+ * Type Guards for TextBlock types
4
+ *
5
+ * Utilities for safely working with TextContent, IDecoration, and ITextBlock.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.isDecoration = isDecoration;
9
+ exports.isTextBlock = isTextBlock;
10
+ exports.hasKeyPrefix = hasKeyPrefix;
11
+ exports.isStatusBlock = isStatusBlock;
12
+ exports.isRoomBlock = isRoomBlock;
13
+ exports.isActionBlock = isActionBlock;
14
+ exports.extractPlainText = extractPlainText;
15
+ /**
16
+ * Check if content is a decoration (not a plain string).
17
+ *
18
+ * @example
19
+ * const content: TextContent = getContent();
20
+ * if (isDecoration(content)) {
21
+ * console.log(content.type); // TypeScript knows this is IDecoration
22
+ * }
23
+ */
24
+ function isDecoration(content) {
25
+ return typeof content === 'object' && content !== null && 'type' in content && 'content' in content;
26
+ }
27
+ /**
28
+ * Check if a value is a valid TextBlock.
29
+ *
30
+ * @example
31
+ * if (isTextBlock(value)) {
32
+ * console.log(value.key);
33
+ * }
34
+ */
35
+ function isTextBlock(value) {
36
+ return (typeof value === 'object' &&
37
+ value !== null &&
38
+ 'key' in value &&
39
+ 'content' in value &&
40
+ typeof value.key === 'string' &&
41
+ Array.isArray(value.content));
42
+ }
43
+ /**
44
+ * Check if a block key starts with a given prefix.
45
+ *
46
+ * @example
47
+ * if (hasKeyPrefix(block, 'status.')) {
48
+ * // Render to status bar
49
+ * }
50
+ */
51
+ function hasKeyPrefix(block, prefix) {
52
+ return block.key.startsWith(prefix);
53
+ }
54
+ /**
55
+ * Check if a block is a status block.
56
+ */
57
+ function isStatusBlock(block) {
58
+ return hasKeyPrefix(block, 'status.');
59
+ }
60
+ /**
61
+ * Check if a block is a room-related block.
62
+ */
63
+ function isRoomBlock(block) {
64
+ return hasKeyPrefix(block, 'room.');
65
+ }
66
+ /**
67
+ * Check if a block is an action-related block.
68
+ */
69
+ function isActionBlock(block) {
70
+ return hasKeyPrefix(block, 'action.');
71
+ }
72
+ /**
73
+ * Extract plain text from TextContent, stripping all decorations.
74
+ *
75
+ * @example
76
+ * const text = extractPlainText([
77
+ * 'You take ',
78
+ * { type: 'item', content: ['the sword'] },
79
+ * '.'
80
+ * ]);
81
+ * // Returns: "You take the sword."
82
+ */
83
+ function extractPlainText(content) {
84
+ return content
85
+ .map((item) => {
86
+ if (typeof item === 'string') {
87
+ return item;
88
+ }
89
+ return extractPlainText(item.content);
90
+ })
91
+ .join('');
92
+ }
93
+ //# sourceMappingURL=guards.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guards.js","sourceRoot":"","sources":["../src/guards.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;AAaH,oCAEC;AAUD,kCASC;AAUD,oCAEC;AAKD,sCAEC;AAKD,kCAEC;AAKD,sCAEC;AAaD,4CASC;AArFD;;;;;;;;GAQG;AACH,SAAgB,YAAY,CAAC,OAAoB;IAC/C,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,IAAI,MAAM,IAAI,OAAO,IAAI,SAAS,IAAI,OAAO,CAAC;AACtG,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAC,KAAc;IACxC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,KAAK,IAAI,KAAK;QACd,SAAS,IAAI,KAAK;QAClB,OAAQ,KAAoB,CAAC,GAAG,KAAK,QAAQ;QAC7C,KAAK,CAAC,OAAO,CAAE,KAAoB,CAAC,OAAO,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,YAAY,CAAC,KAAiB,EAAE,MAAc;IAC5D,OAAO,KAAK,CAAC,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,KAAiB;IAC7C,OAAO,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAiB;IAC3C,OAAO,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,KAAiB;IAC7C,OAAO,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;AACxC,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,gBAAgB,CAAC,OAAmC;IAClE,OAAO,OAAO;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC;QACd,CAAC;QACD,OAAO,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxC,CAAC,CAAC;SACD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @sharpee/text-blocks
3
+ *
4
+ * Pure interfaces for structured text output in Sharpee IF platform.
5
+ *
6
+ * This package contains only TypeScript interfaces and type guards -
7
+ * no runtime dependencies. It defines the contract between TextService
8
+ * and clients (CLI, React, etc.).
9
+ *
10
+ * @packageDocumentation
11
+ * @see ADR-096: Text Service Architecture
12
+ * @see ADR-091: Text Decorations
13
+ */
14
+ export type { TextContent, IDecoration, ITextBlock } from './types.js';
15
+ export { CORE_DECORATION_TYPES, CORE_BLOCK_KEYS } from './types.js';
16
+ export { CORE_BLOCK_KEYS as BLOCK_KEYS } from './types.js';
17
+ export { isDecoration, isTextBlock, hasKeyPrefix, isStatusBlock, isRoomBlock, isActionBlock, extractPlainText, } from './guards.js';
18
+ export declare const BLOCK_KEY_PREFIXES: {
19
+ readonly STATUS: "status.";
20
+ readonly ROOM: "room.";
21
+ readonly ACTION: "action.";
22
+ };
23
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAGvE,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGpE,OAAO,EAAE,eAAe,IAAI,UAAU,EAAE,MAAM,YAAY,CAAC;AAG3D,OAAO,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACb,WAAW,EACX,aAAa,EACb,gBAAgB,GACjB,MAAM,aAAa,CAAC;AAGrB,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAC"}
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ /**
3
+ * @sharpee/text-blocks
4
+ *
5
+ * Pure interfaces for structured text output in Sharpee IF platform.
6
+ *
7
+ * This package contains only TypeScript interfaces and type guards -
8
+ * no runtime dependencies. It defines the contract between TextService
9
+ * and clients (CLI, React, etc.).
10
+ *
11
+ * @packageDocumentation
12
+ * @see ADR-096: Text Service Architecture
13
+ * @see ADR-091: Text Decorations
14
+ */
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.BLOCK_KEY_PREFIXES = exports.extractPlainText = exports.isActionBlock = exports.isRoomBlock = exports.isStatusBlock = exports.hasKeyPrefix = exports.isTextBlock = exports.isDecoration = exports.BLOCK_KEYS = exports.CORE_BLOCK_KEYS = exports.CORE_DECORATION_TYPES = void 0;
17
+ // Constants
18
+ var types_js_1 = require("./types.js");
19
+ Object.defineProperty(exports, "CORE_DECORATION_TYPES", { enumerable: true, get: function () { return types_js_1.CORE_DECORATION_TYPES; } });
20
+ Object.defineProperty(exports, "CORE_BLOCK_KEYS", { enumerable: true, get: function () { return types_js_1.CORE_BLOCK_KEYS; } });
21
+ // Alias for text-service compatibility
22
+ var types_js_2 = require("./types.js");
23
+ Object.defineProperty(exports, "BLOCK_KEYS", { enumerable: true, get: function () { return types_js_2.CORE_BLOCK_KEYS; } });
24
+ // Type guards and utilities
25
+ var guards_js_1 = require("./guards.js");
26
+ Object.defineProperty(exports, "isDecoration", { enumerable: true, get: function () { return guards_js_1.isDecoration; } });
27
+ Object.defineProperty(exports, "isTextBlock", { enumerable: true, get: function () { return guards_js_1.isTextBlock; } });
28
+ Object.defineProperty(exports, "hasKeyPrefix", { enumerable: true, get: function () { return guards_js_1.hasKeyPrefix; } });
29
+ Object.defineProperty(exports, "isStatusBlock", { enumerable: true, get: function () { return guards_js_1.isStatusBlock; } });
30
+ Object.defineProperty(exports, "isRoomBlock", { enumerable: true, get: function () { return guards_js_1.isRoomBlock; } });
31
+ Object.defineProperty(exports, "isActionBlock", { enumerable: true, get: function () { return guards_js_1.isActionBlock; } });
32
+ Object.defineProperty(exports, "extractPlainText", { enumerable: true, get: function () { return guards_js_1.extractPlainText; } });
33
+ // Block key prefixes for routing
34
+ exports.BLOCK_KEY_PREFIXES = {
35
+ STATUS: 'status.',
36
+ ROOM: 'room.',
37
+ ACTION: 'action.',
38
+ };
39
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;AAKH,YAAY;AACZ,uCAAoE;AAA3D,iHAAA,qBAAqB,OAAA;AAAE,2GAAA,eAAe,OAAA;AAE/C,uCAAuC;AACvC,uCAA2D;AAAlD,sGAAA,eAAe,OAAc;AAEtC,4BAA4B;AAC5B,yCAQqB;AAPnB,yGAAA,YAAY,OAAA;AACZ,wGAAA,WAAW,OAAA;AACX,yGAAA,YAAY,OAAA;AACZ,0GAAA,aAAa,OAAA;AACb,wGAAA,WAAW,OAAA;AACX,0GAAA,aAAa,OAAA;AACb,6GAAA,gBAAgB,OAAA;AAGlB,iCAAiC;AACpB,QAAA,kBAAkB,GAAG;IAChC,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,OAAO;IACb,MAAM,EAAE,SAAS;CACT,CAAC"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * @sharpee/text-blocks
3
+ *
4
+ * Pure interfaces for structured text output.
5
+ * No runtime dependencies - types only.
6
+ *
7
+ * @see ADR-096: Text Service Architecture
8
+ * @see ADR-091: Text Decorations
9
+ */
10
+ /**
11
+ * Content within a text block - either plain string or decorated content.
12
+ *
13
+ * @example
14
+ * // Plain text
15
+ * const plain: TextContent = "You take the sword.";
16
+ *
17
+ * // Decorated content
18
+ * const decorated: TextContent = {
19
+ * type: 'item',
20
+ * content: ['brass lantern']
21
+ * };
22
+ */
23
+ export type TextContent = string | IDecoration;
24
+ /**
25
+ * Decorated content with semantic type.
26
+ *
27
+ * The `type` field is an open string to support:
28
+ * - Core types: 'em', 'strong', 'item', 'room', 'npc', 'command', 'direction'
29
+ * - Presentational: 'underline', 'strikethrough', 'super', 'sub'
30
+ * - Story-defined: 'photopia.red', 'dungeo.thief', etc.
31
+ *
32
+ * @example
33
+ * // Emphasis
34
+ * { type: 'em', content: ['carefully'] }
35
+ *
36
+ * // Item name
37
+ * { type: 'item', content: ['brass lantern'] }
38
+ *
39
+ * // Nested decorations
40
+ * { type: 'item', content: [
41
+ * { type: 'em', content: ['glowing'] },
42
+ * ' lantern'
43
+ * ]}
44
+ *
45
+ * // Story-defined color (Photopia pattern)
46
+ * { type: 'photopia.red', content: ['The light was red, like always.'] }
47
+ */
48
+ export interface IDecoration {
49
+ /**
50
+ * Semantic type of the decoration.
51
+ * Open string to allow story extensions.
52
+ */
53
+ readonly type: string;
54
+ /**
55
+ * Content within the decoration.
56
+ * Can contain nested decorations or plain strings.
57
+ */
58
+ readonly content: ReadonlyArray<TextContent>;
59
+ }
60
+ /**
61
+ * A block of text output with semantic key (channel).
62
+ *
63
+ * Keys act as channels (FyreVM pattern). Clients route blocks by key:
64
+ * - `room.name` - Room title
65
+ * - `room.description` - Room description
66
+ * - `room.contents` - Items in room
67
+ * - `action.result` - Action outcome
68
+ * - `action.blocked` - Why action failed
69
+ * - `status.room` - Current location (status bar)
70
+ * - `status.score` - Current score (status bar)
71
+ * - `status.turns` - Turn count (status bar)
72
+ * - `error` - System errors
73
+ * - `prompt` - Command prompt
74
+ * - Story-defined keys: 'dungeo.thief.taunt', etc.
75
+ *
76
+ * @example
77
+ * // Room name block
78
+ * {
79
+ * key: 'room.name',
80
+ * content: [{ type: 'room', content: ['West of House'] }]
81
+ * }
82
+ *
83
+ * // Action result with decorated item
84
+ * {
85
+ * key: 'action.result',
86
+ * content: [
87
+ * 'You take ',
88
+ * { type: 'item', content: ['the brass lantern'] },
89
+ * '.'
90
+ * ]
91
+ * }
92
+ *
93
+ * // Status bar block
94
+ * {
95
+ * key: 'status.score',
96
+ * content: ['42']
97
+ * }
98
+ */
99
+ export interface ITextBlock {
100
+ /**
101
+ * Semantic key identifying the block type/channel.
102
+ * Clients route blocks to UI regions based on key prefix.
103
+ */
104
+ readonly key: string;
105
+ /**
106
+ * Block content - array of plain strings and decorations.
107
+ */
108
+ readonly content: ReadonlyArray<TextContent>;
109
+ }
110
+ /**
111
+ * Core decoration types defined by the platform.
112
+ * Stories can extend with custom types.
113
+ */
114
+ export declare const CORE_DECORATION_TYPES: {
115
+ /** Emphasis (typically italic) */
116
+ readonly EM: "em";
117
+ /** Strong emphasis (typically bold) */
118
+ readonly STRONG: "strong";
119
+ /** Item/object name */
120
+ readonly ITEM: "item";
121
+ /** Room/location name */
122
+ readonly ROOM: "room";
123
+ /** NPC/character name */
124
+ readonly NPC: "npc";
125
+ /** Suggested command */
126
+ readonly COMMAND: "command";
127
+ /** Exit direction */
128
+ readonly DIRECTION: "direction";
129
+ /** Underlined text */
130
+ readonly UNDERLINE: "underline";
131
+ /** Struck-through text */
132
+ readonly STRIKETHROUGH: "strikethrough";
133
+ /** Superscript */
134
+ readonly SUPER: "super";
135
+ /** Subscript */
136
+ readonly SUB: "sub";
137
+ };
138
+ /**
139
+ * Core block keys defined by the platform.
140
+ * Stories can emit custom keys.
141
+ */
142
+ export declare const CORE_BLOCK_KEYS: {
143
+ /** Room title */
144
+ readonly ROOM_NAME: "room.name";
145
+ /** Room description */
146
+ readonly ROOM_DESCRIPTION: "room.description";
147
+ /** Items visible in room */
148
+ readonly ROOM_CONTENTS: "room.contents";
149
+ /** Action success result */
150
+ readonly ACTION_RESULT: "action.result";
151
+ /** Action blocked message */
152
+ readonly ACTION_BLOCKED: "action.blocked";
153
+ /** Current room (status bar) */
154
+ readonly STATUS_ROOM: "status.room";
155
+ /** Current score (status bar) */
156
+ readonly STATUS_SCORE: "status.score";
157
+ /** Turn count (status bar) */
158
+ readonly STATUS_TURNS: "status.turns";
159
+ /** System error */
160
+ readonly ERROR: "error";
161
+ /** Command prompt */
162
+ readonly PROMPT: "prompt";
163
+ /** Game/story message */
164
+ readonly GAME_MESSAGE: "game.message";
165
+ /** Game opening banner */
166
+ readonly GAME_BANNER: "game.banner";
167
+ };
168
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,WAAW,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,WAAW,UAAU;IACzB;;;OAGG;IACH,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;CAC9C;AAED;;;GAGG;AACH,eAAO,MAAM,qBAAqB;IAChC,kCAAkC;;IAElC,uCAAuC;;IAEvC,uBAAuB;;IAEvB,yBAAyB;;IAEzB,yBAAyB;;IAEzB,wBAAwB;;IAExB,qBAAqB;;IAErB,sBAAsB;;IAEtB,0BAA0B;;IAE1B,kBAAkB;;IAElB,gBAAgB;;CAER,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,eAAe;IAC1B,iBAAiB;;IAEjB,uBAAuB;;IAEvB,4BAA4B;;IAE5B,4BAA4B;;IAE5B,6BAA6B;;IAE7B,gCAAgC;;IAEhC,iCAAiC;;IAEjC,8BAA8B;;IAE9B,mBAAmB;;IAEnB,qBAAqB;;IAErB,yBAAyB;;IAEzB,0BAA0B;;CAElB,CAAC"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ /**
3
+ * @sharpee/text-blocks
4
+ *
5
+ * Pure interfaces for structured text output.
6
+ * No runtime dependencies - types only.
7
+ *
8
+ * @see ADR-096: Text Service Architecture
9
+ * @see ADR-091: Text Decorations
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CORE_BLOCK_KEYS = exports.CORE_DECORATION_TYPES = void 0;
13
+ /**
14
+ * Core decoration types defined by the platform.
15
+ * Stories can extend with custom types.
16
+ */
17
+ exports.CORE_DECORATION_TYPES = {
18
+ /** Emphasis (typically italic) */
19
+ EM: 'em',
20
+ /** Strong emphasis (typically bold) */
21
+ STRONG: 'strong',
22
+ /** Item/object name */
23
+ ITEM: 'item',
24
+ /** Room/location name */
25
+ ROOM: 'room',
26
+ /** NPC/character name */
27
+ NPC: 'npc',
28
+ /** Suggested command */
29
+ COMMAND: 'command',
30
+ /** Exit direction */
31
+ DIRECTION: 'direction',
32
+ /** Underlined text */
33
+ UNDERLINE: 'underline',
34
+ /** Struck-through text */
35
+ STRIKETHROUGH: 'strikethrough',
36
+ /** Superscript */
37
+ SUPER: 'super',
38
+ /** Subscript */
39
+ SUB: 'sub',
40
+ };
41
+ /**
42
+ * Core block keys defined by the platform.
43
+ * Stories can emit custom keys.
44
+ */
45
+ exports.CORE_BLOCK_KEYS = {
46
+ /** Room title */
47
+ ROOM_NAME: 'room.name',
48
+ /** Room description */
49
+ ROOM_DESCRIPTION: 'room.description',
50
+ /** Items visible in room */
51
+ ROOM_CONTENTS: 'room.contents',
52
+ /** Action success result */
53
+ ACTION_RESULT: 'action.result',
54
+ /** Action blocked message */
55
+ ACTION_BLOCKED: 'action.blocked',
56
+ /** Current room (status bar) */
57
+ STATUS_ROOM: 'status.room',
58
+ /** Current score (status bar) */
59
+ STATUS_SCORE: 'status.score',
60
+ /** Turn count (status bar) */
61
+ STATUS_TURNS: 'status.turns',
62
+ /** System error */
63
+ ERROR: 'error',
64
+ /** Command prompt */
65
+ PROMPT: 'prompt',
66
+ /** Game/story message */
67
+ GAME_MESSAGE: 'game.message',
68
+ /** Game opening banner */
69
+ GAME_BANNER: 'game.banner',
70
+ };
71
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AA2GH;;;GAGG;AACU,QAAA,qBAAqB,GAAG;IACnC,kCAAkC;IAClC,EAAE,EAAE,IAAI;IACR,uCAAuC;IACvC,MAAM,EAAE,QAAQ;IAChB,uBAAuB;IACvB,IAAI,EAAE,MAAM;IACZ,yBAAyB;IACzB,IAAI,EAAE,MAAM;IACZ,yBAAyB;IACzB,GAAG,EAAE,KAAK;IACV,wBAAwB;IACxB,OAAO,EAAE,SAAS;IAClB,qBAAqB;IACrB,SAAS,EAAE,WAAW;IACtB,sBAAsB;IACtB,SAAS,EAAE,WAAW;IACtB,0BAA0B;IAC1B,aAAa,EAAE,eAAe;IAC9B,kBAAkB;IAClB,KAAK,EAAE,OAAO;IACd,gBAAgB;IAChB,GAAG,EAAE,KAAK;CACF,CAAC;AAEX;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC7B,iBAAiB;IACjB,SAAS,EAAE,WAAW;IACtB,uBAAuB;IACvB,gBAAgB,EAAE,kBAAkB;IACpC,4BAA4B;IAC5B,aAAa,EAAE,eAAe;IAC9B,4BAA4B;IAC5B,aAAa,EAAE,eAAe;IAC9B,6BAA6B;IAC7B,cAAc,EAAE,gBAAgB;IAChC,gCAAgC;IAChC,WAAW,EAAE,aAAa;IAC1B,iCAAiC;IACjC,YAAY,EAAE,cAAc;IAC5B,8BAA8B;IAC9B,YAAY,EAAE,cAAc;IAC5B,mBAAmB;IACnB,KAAK,EAAE,OAAO;IACd,qBAAqB;IACrB,MAAM,EAAE,QAAQ;IAChB,yBAAyB;IACzB,YAAY,EAAE,cAAc;IAC5B,0BAA0B;IAC1B,WAAW,EAAE,aAAa;CAClB,CAAC"}
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@sharpee/text-blocks",
3
+ "version": "0.9.61-beta",
4
+ "description": "Pure interfaces for structured text output (ITextBlock, IDecoration)",
5
+ "main": "dist-npm/index.js",
6
+ "types": "dist-npm/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist-npm/index.d.ts",
10
+ "import": "./dist-npm/index.js",
11
+ "require": "./dist-npm/index.js"
12
+ }
13
+ },
14
+ "devDependencies": {
15
+ "@types/node": "^20.8.0",
16
+ "@typescript-eslint/eslint-plugin": "^6.7.4",
17
+ "@typescript-eslint/parser": "^6.7.4",
18
+ "eslint": "^8.50.0",
19
+ "rimraf": "^5.0.5",
20
+ "typescript": "^5.2.2"
21
+ },
22
+ "files": [
23
+ "dist-npm"
24
+ ],
25
+ "keywords": [
26
+ "interactive-fiction",
27
+ "if",
28
+ "text-adventure",
29
+ "sharpee",
30
+ "text-blocks",
31
+ "structured-output"
32
+ ],
33
+ "author": "Sharpee Team",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/ChicagoDave/sharpee.git",
38
+ "directory": "packages/text-blocks"
39
+ },
40
+ "homepage": "https://github.com/ChicagoDave/sharpee#readme",
41
+ "bugs": {
42
+ "url": "https://github.com/ChicagoDave/sharpee/issues"
43
+ },
44
+ "engines": {
45
+ "node": ">=18.0.0"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "scripts": {
51
+ "build": "tsc",
52
+ "clean": "rimraf dist",
53
+ "lint": "eslint src --ext .ts",
54
+ "build:npm": "tsc --outDir dist-npm"
55
+ }
56
+ }