@sharpee/lang-en-us 1.5.0 → 2.1.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/actions/about.d.ts +1 -0
- package/actions/about.d.ts.map +1 -1
- package/actions/about.js +15 -8
- package/actions/about.js.map +1 -1
- package/actions/again.d.ts.map +1 -1
- package/actions/again.js.map +1 -1
- package/actions/answering.d.ts.map +1 -1
- package/actions/answering.js.map +1 -1
- package/actions/asking.d.ts.map +1 -1
- package/actions/asking.js +14 -14
- package/actions/asking.js.map +1 -1
- package/actions/attacking.d.ts.map +1 -1
- package/actions/attacking.js +51 -51
- package/actions/attacking.js.map +1 -1
- package/actions/climbing.d.ts.map +1 -1
- package/actions/climbing.js +4 -4
- package/actions/climbing.js.map +1 -1
- package/actions/closing.d.ts.map +1 -1
- package/actions/closing.js +5 -5
- package/actions/closing.js.map +1 -1
- package/actions/drinking.d.ts.map +1 -1
- package/actions/drinking.js +20 -20
- package/actions/drinking.js.map +1 -1
- package/actions/dropping.d.ts.map +1 -1
- package/actions/dropping.js +3 -3
- package/actions/dropping.js.map +1 -1
- package/actions/eating.d.ts.map +1 -1
- package/actions/eating.js +20 -20
- package/actions/eating.js.map +1 -1
- package/actions/entering.d.ts.map +1 -1
- package/actions/entering.js +10 -10
- package/actions/entering.js.map +1 -1
- package/actions/examining.d.ts.map +1 -1
- package/actions/examining.js +28 -23
- package/actions/examining.js.map +1 -1
- package/actions/exiting.d.ts.map +1 -1
- package/actions/exiting.js +4 -4
- package/actions/exiting.js.map +1 -1
- package/actions/giving.d.ts.map +1 -1
- package/actions/giving.js +12 -12
- package/actions/giving.js.map +1 -1
- package/actions/going.d.ts.map +1 -1
- package/actions/going.js +7 -7
- package/actions/going.js.map +1 -1
- package/actions/help.d.ts +3 -3
- package/actions/help.d.ts.map +1 -1
- package/actions/help.js +9 -7
- package/actions/help.js.map +1 -1
- package/actions/hiding.d.ts.map +1 -1
- package/actions/hiding.js.map +1 -1
- package/actions/index.d.ts +5 -3
- package/actions/index.d.ts.map +1 -1
- package/actions/index.js.map +1 -1
- package/actions/inserting.d.ts.map +1 -1
- package/actions/inserting.js +8 -8
- package/actions/inserting.js.map +1 -1
- package/actions/inventory.d.ts.map +1 -1
- package/actions/inventory.js.map +1 -1
- package/actions/listening.d.ts.map +1 -1
- package/actions/listening.js +7 -7
- package/actions/listening.js.map +1 -1
- package/actions/locking.d.ts.map +1 -1
- package/actions/locking.js +8 -8
- package/actions/locking.js.map +1 -1
- package/actions/looking.d.ts.map +1 -1
- package/actions/looking.js +5 -5
- package/actions/looking.js.map +1 -1
- package/actions/lowering.d.ts.map +1 -1
- package/actions/lowering.js +2 -2
- package/actions/lowering.js.map +1 -1
- package/actions/opening.d.ts.map +1 -1
- package/actions/opening.js +7 -7
- package/actions/opening.js.map +1 -1
- package/actions/pulling.d.ts.map +1 -1
- package/actions/pulling.js +19 -19
- package/actions/pulling.js.map +1 -1
- package/actions/pushing.d.ts.map +1 -1
- package/actions/pushing.js +14 -14
- package/actions/pushing.js.map +1 -1
- package/actions/putting.d.ts.map +1 -1
- package/actions/putting.js +12 -12
- package/actions/putting.js.map +1 -1
- package/actions/quitting.d.ts.map +1 -1
- package/actions/quitting.js.map +1 -1
- package/actions/raising.d.ts.map +1 -1
- package/actions/raising.js +2 -2
- package/actions/raising.js.map +1 -1
- package/actions/reading.d.ts.map +1 -1
- package/actions/reading.js +10 -8
- package/actions/reading.js.map +1 -1
- package/actions/removing.d.ts.map +1 -1
- package/actions/removing.js +8 -8
- package/actions/removing.js.map +1 -1
- package/actions/restoring.d.ts.map +1 -1
- package/actions/restoring.js +6 -6
- package/actions/restoring.js.map +1 -1
- package/actions/saving.d.ts.map +1 -1
- package/actions/saving.js +6 -6
- package/actions/saving.js.map +1 -1
- package/actions/scoring.d.ts.map +1 -1
- package/actions/scoring.js.map +1 -1
- package/actions/searching.d.ts.map +1 -1
- package/actions/searching.js +7 -7
- package/actions/searching.js.map +1 -1
- package/actions/showing.d.ts.map +1 -1
- package/actions/showing.js +11 -11
- package/actions/showing.js.map +1 -1
- package/actions/sleeping.d.ts.map +1 -1
- package/actions/sleeping.js.map +1 -1
- package/actions/smelling.d.ts.map +1 -1
- package/actions/smelling.js +10 -10
- package/actions/smelling.js.map +1 -1
- package/actions/switching-off.d.ts.map +1 -1
- package/actions/switching-off.js +12 -12
- package/actions/switching-off.js.map +1 -1
- package/actions/switching-on.d.ts.map +1 -1
- package/actions/switching-on.js +12 -12
- package/actions/switching-on.js.map +1 -1
- package/actions/taking-off.d.ts.map +1 -1
- package/actions/taking-off.js +4 -4
- package/actions/taking-off.js.map +1 -1
- package/actions/taking.d.ts +1 -0
- package/actions/taking.d.ts.map +1 -1
- package/actions/taking.js +7 -5
- package/actions/taking.js.map +1 -1
- package/actions/talking.d.ts.map +1 -1
- package/actions/talking.js +15 -15
- package/actions/talking.js.map +1 -1
- package/actions/telling.d.ts.map +1 -1
- package/actions/telling.js +13 -13
- package/actions/telling.js.map +1 -1
- package/actions/throwing.d.ts.map +1 -1
- package/actions/throwing.js +21 -21
- package/actions/throwing.js.map +1 -1
- package/actions/touching.d.ts.map +1 -1
- package/actions/touching.js +20 -20
- package/actions/touching.js.map +1 -1
- package/actions/turning.d.ts.map +1 -1
- package/actions/turning.js +24 -24
- package/actions/turning.js.map +1 -1
- package/actions/undoing.d.ts.map +1 -1
- package/actions/undoing.js.map +1 -1
- package/actions/unlocking.d.ts.map +1 -1
- package/actions/unlocking.js +8 -8
- package/actions/unlocking.js.map +1 -1
- package/actions/version.d.ts.map +1 -1
- package/actions/version.js +3 -3
- package/actions/version.js.map +1 -1
- package/actions/waiting.d.ts.map +1 -1
- package/actions/waiting.js +1 -1
- package/actions/waiting.js.map +1 -1
- package/actions/wearing.d.ts.map +1 -1
- package/actions/wearing.js +5 -5
- package/actions/wearing.js.map +1 -1
- package/assembler/english-assembler.d.ts +66 -0
- package/assembler/english-assembler.d.ts.map +1 -0
- package/assembler/english-assembler.js +806 -0
- package/assembler/english-assembler.js.map +1 -0
- package/assembler/errors.d.ts +23 -0
- package/assembler/errors.d.ts.map +1 -0
- package/assembler/errors.js +35 -0
- package/assembler/errors.js.map +1 -0
- package/assembler/index.d.ts +10 -0
- package/assembler/index.d.ts.map +1 -0
- package/assembler/index.js +17 -0
- package/assembler/index.js.map +1 -0
- package/data/events.d.ts.map +1 -1
- package/data/events.js +11 -11
- package/data/events.js.map +1 -1
- package/data/messages.d.ts.map +1 -1
- package/data/messages.js +1 -1
- package/data/messages.js.map +1 -1
- package/data/verbs.d.ts.map +1 -1
- package/data/verbs.js.map +1 -1
- package/data/words.d.ts.map +1 -1
- package/data/words.js.map +1 -1
- package/grammar.d.ts.map +1 -1
- package/grammar.js.map +1 -1
- package/index.d.ts +2 -1
- package/index.d.ts.map +1 -1
- package/index.js +4 -1
- package/index.js.map +1 -1
- package/language-provider.d.ts +50 -24
- package/language-provider.d.ts.map +1 -1
- package/language-provider.js +96 -40
- package/language-provider.js.map +1 -1
- package/npc/conversation.d.ts +5 -0
- package/npc/conversation.d.ts.map +1 -1
- package/npc/conversation.js +24 -19
- package/npc/conversation.js.map +1 -1
- package/npc/index.d.ts.map +1 -1
- package/npc/index.js.map +1 -1
- package/npc/influence.d.ts.map +1 -1
- package/npc/influence.js +4 -4
- package/npc/influence.js.map +1 -1
- package/npc/npc.d.ts +6 -0
- package/npc/npc.d.ts.map +1 -1
- package/npc/npc.js +39 -33
- package/npc/npc.js.map +1 -1
- package/npc/propagation.d.ts.map +1 -1
- package/npc/propagation.js +6 -6
- package/npc/propagation.js.map +1 -1
- package/number-words.d.ts +18 -0
- package/number-words.d.ts.map +1 -1
- package/number-words.js +77 -0
- package/number-words.js.map +1 -1
- package/package.json +3 -3
- package/parser/index.d.ts +8 -0
- package/parser/index.d.ts.map +1 -0
- package/parser/index.js +13 -0
- package/parser/index.js.map +1 -0
- package/parser/parse-phrase-template.d.ts +62 -0
- package/parser/parse-phrase-template.d.ts.map +1 -0
- package/parser/parse-phrase-template.js +384 -0
- package/parser/parse-phrase-template.js.map +1 -0
- package/perspective/index.d.ts.map +1 -1
- package/perspective/index.js.map +1 -1
- package/perspective/placeholder-resolver.d.ts +1 -1
- package/perspective/placeholder-resolver.d.ts.map +1 -1
- package/perspective/placeholder-resolver.js +12 -1
- package/perspective/placeholder-resolver.js.map +1 -1
- package/platform-messages.d.ts +26 -0
- package/platform-messages.d.ts.map +1 -0
- package/platform-messages.js +31 -0
- package/platform-messages.js.map +1 -0
- package/pluralize.d.ts.map +1 -1
- package/pluralize.js.map +1 -1
- package/sound-messages.d.ts +8 -8
- package/sound-messages.d.ts.map +1 -1
- package/sound-messages.js +8 -8
- package/sound-messages.js.map +1 -1
- package/formatters/article.d.ts +0 -41
- package/formatters/article.d.ts.map +0 -1
- package/formatters/article.js +0 -143
- package/formatters/article.js.map +0 -1
- package/formatters/index.d.ts +0 -19
- package/formatters/index.d.ts.map +0 -1
- package/formatters/index.js +0 -42
- package/formatters/index.js.map +0 -1
- package/formatters/list.d.ts +0 -56
- package/formatters/list.d.ts.map +0 -1
- package/formatters/list.js +0 -178
- package/formatters/list.js.map +0 -1
- package/formatters/registry.d.ts +0 -49
- package/formatters/registry.d.ts.map +0 -1
- package/formatters/registry.js +0 -136
- package/formatters/registry.js.map +0 -1
- package/formatters/text.d.ts +0 -33
- package/formatters/text.d.ts.map +0 -1
- package/formatters/text.js +0 -80
- package/formatters/text.js.map +0 -1
- package/formatters/types.d.ts +0 -52
- package/formatters/types.d.ts.map +0 -1
- package/formatters/types.js +0 -14
- package/formatters/types.js.map +0 -1
- package/formatters/verb.d.ts +0 -30
- package/formatters/verb.d.ts.map +0 -1
- package/formatters/verb.js +0 -59
- package/formatters/verb.js.map +0 -1
package/sound-messages.js
CHANGED
|
@@ -39,23 +39,23 @@ exports.soundMessages = {
|
|
|
39
39
|
// ────────────────────────────────────────────────────────────────────
|
|
40
40
|
// Default fallbacks — used when no kind-specific entry exists
|
|
41
41
|
// ────────────────────────────────────────────────────────────────────
|
|
42
|
-
'sound.heard.default.full': '{You} {hear} {kind}.',
|
|
43
|
-
'sound.heard.default.muffled': '{You} {hear} a muffled {kind}.',
|
|
44
|
-
'sound.heard.default.fragments': '{You} {catch} broken {kind}.',
|
|
42
|
+
'sound.heard.default.full': '{You} {hear} {verbatim:kind}.',
|
|
43
|
+
'sound.heard.default.muffled': '{You} {hear} a muffled {verbatim:kind}.',
|
|
44
|
+
'sound.heard.default.fragments': '{You} {catch} broken {verbatim:kind}.',
|
|
45
45
|
'sound.heard.default.presence-only': '{You} {hear} something distant.',
|
|
46
46
|
// ────────────────────────────────────────────────────────────────────
|
|
47
47
|
// Speech — content-bearing dialogue (NPCs, conversations)
|
|
48
48
|
// ────────────────────────────────────────────────────────────────────
|
|
49
|
-
'sound.heard.speech.full': '{You} {hear}: "{content}"',
|
|
50
|
-
'sound.heard.speech.muffled': '{You} {catch} a muffled voice: "{content}"',
|
|
49
|
+
'sound.heard.speech.full': '{You} {hear}: "{verbatim:content}"',
|
|
50
|
+
'sound.heard.speech.muffled': '{You} {catch} a muffled voice: "{verbatim:content}"',
|
|
51
51
|
'sound.heard.speech.fragments': '{You} {catch} fragments of speech.',
|
|
52
52
|
'sound.heard.speech.presence-only': '{You} {hear} voices nearby.',
|
|
53
53
|
// ────────────────────────────────────────────────────────────────────
|
|
54
54
|
// Ambient — environmental sounds (footsteps, doors, mechanical)
|
|
55
55
|
// ────────────────────────────────────────────────────────────────────
|
|
56
|
-
'sound.heard.ambient.full': '{You} {hear} {kind}.',
|
|
57
|
-
'sound.heard.ambient.muffled': '{You} {hear} a muffled {kind}.',
|
|
58
|
-
'sound.heard.ambient.fragments': '{You} {catch} the faint sound of {kind}.',
|
|
56
|
+
'sound.heard.ambient.full': '{You} {hear} {verbatim:kind}.',
|
|
57
|
+
'sound.heard.ambient.muffled': '{You} {hear} a muffled {verbatim:kind}.',
|
|
58
|
+
'sound.heard.ambient.fragments': '{You} {catch} the faint sound of {verbatim:kind}.',
|
|
59
59
|
'sound.heard.ambient.presence-only': '{You} {hear} something at the edge of hearing.',
|
|
60
60
|
};
|
|
61
61
|
/**
|
package/sound-messages.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sound-messages.js","sourceRoot":"","sources":["../../../../../../repos/
|
|
1
|
+
{"version":3,"file":"sound-messages.js","sourceRoot":"","sources":["../../../../../../repos/sharpee_v2/packages/lang-en-us/src/sound-messages.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;;;AAgDH,wCAEC;AAOD,wDAEC;AAzDY,QAAA,aAAa,GAAG;IAC3B,uEAAuE;IACvE,+DAA+D;IAC/D,uEAAuE;IAEvE,0BAA0B,EAAE,+BAA+B;IAC3D,6BAA6B,EAAE,yCAAyC;IACxE,+BAA+B,EAAE,uCAAuC;IACxE,mCAAmC,EAAE,iCAAiC;IAEtE,uEAAuE;IACvE,2DAA2D;IAC3D,uEAAuE;IAEvE,yBAAyB,EAAE,oCAAoC;IAC/D,4BAA4B,EAAE,qDAAqD;IACnF,8BAA8B,EAAE,oCAAoC;IACpE,kCAAkC,EAAE,6BAA6B;IAEjE,uEAAuE;IACvE,iEAAiE;IACjE,uEAAuE;IAEvE,0BAA0B,EAAE,+BAA+B;IAC3D,6BAA6B,EAAE,yCAAyC;IACxE,+BAA+B,EAAE,mDAAmD;IACpF,mCAAmC,EAAE,gDAAgD;CAC7E,CAAC;AAUX;;;;;;;;GAQG;AACH,SAAgB,cAAc,CAAC,IAAY,EAAE,IAA8B;IACzE,OAAO,eAAe,IAAI,IAAI,IAAI,EAAE,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,SAAgB,sBAAsB,CAAC,IAA8B;IACnE,OAAO,uBAAuB,IAAI,EAAE,CAAC;AACvC,CAAC"}
|
package/formatters/article.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Article Formatters
|
|
3
|
-
*
|
|
4
|
-
* Formatters for adding articles to nouns based on noun type.
|
|
5
|
-
*
|
|
6
|
-
* @see ADR-095 Message Templates with Formatters
|
|
7
|
-
*/
|
|
8
|
-
import type { Formatter } from './types.js';
|
|
9
|
-
/**
|
|
10
|
-
* "a" formatter - indefinite article
|
|
11
|
-
*
|
|
12
|
-
* Respects nounType:
|
|
13
|
-
* - common: "a sword" / "an apple"
|
|
14
|
-
* - proper: "John" (no article)
|
|
15
|
-
* - mass: "some water"
|
|
16
|
-
* - unique: "the sun"
|
|
17
|
-
* - plural: "swords" (no article for indefinite plural)
|
|
18
|
-
*/
|
|
19
|
-
export declare const aFormatter: Formatter;
|
|
20
|
-
/**
|
|
21
|
-
* "the" formatter - definite article
|
|
22
|
-
*
|
|
23
|
-
* Respects nounType:
|
|
24
|
-
* - proper: "John" (no article)
|
|
25
|
-
* - all others: "the X"
|
|
26
|
-
*/
|
|
27
|
-
export declare const theFormatter: Formatter;
|
|
28
|
-
/**
|
|
29
|
-
* "some" formatter - partitive article
|
|
30
|
-
*
|
|
31
|
-
* Primarily for mass nouns: "some water"
|
|
32
|
-
* Also works for plurals: "some coins"
|
|
33
|
-
*/
|
|
34
|
-
export declare const someFormatter: Formatter;
|
|
35
|
-
/**
|
|
36
|
-
* "your" formatter - possessive
|
|
37
|
-
*
|
|
38
|
-
* Creates "your X" phrases
|
|
39
|
-
*/
|
|
40
|
-
export declare const yourFormatter: Formatter;
|
|
41
|
-
//# sourceMappingURL=article.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"article.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/lang-en-us/src/formatters/article.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAgC,MAAM,YAAY,CAAC;AAwC1E;;;;;;;;;GASG;AACH,eAAO,MAAM,UAAU,EAAE,SA6BxB,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,EAAE,SAiB1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,aAAa,EAAE,SAiB3B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,SAQ3B,CAAC"}
|
package/formatters/article.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Article Formatters
|
|
4
|
-
*
|
|
5
|
-
* Formatters for adding articles to nouns based on noun type.
|
|
6
|
-
*
|
|
7
|
-
* @see ADR-095 Message Templates with Formatters
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.yourFormatter = exports.someFormatter = exports.theFormatter = exports.aFormatter = void 0;
|
|
11
|
-
/**
|
|
12
|
-
* Get indefinite article for a word (a/an)
|
|
13
|
-
*/
|
|
14
|
-
function getIndefiniteArticle(word) {
|
|
15
|
-
if (!word || word.length === 0)
|
|
16
|
-
return 'a';
|
|
17
|
-
const lower = word.toLowerCase();
|
|
18
|
-
// Special cases
|
|
19
|
-
if (lower.startsWith('hour'))
|
|
20
|
-
return 'an';
|
|
21
|
-
if (lower.startsWith('honest'))
|
|
22
|
-
return 'an';
|
|
23
|
-
if (lower.startsWith('heir'))
|
|
24
|
-
return 'an';
|
|
25
|
-
if (lower.startsWith('uni'))
|
|
26
|
-
return 'a'; // university
|
|
27
|
-
if (lower.startsWith('one'))
|
|
28
|
-
return 'a'; // one-way
|
|
29
|
-
const firstChar = lower[0];
|
|
30
|
-
const vowels = ['a', 'e', 'i', 'o', 'u'];
|
|
31
|
-
return vowels.includes(firstChar) ? 'an' : 'a';
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Extract name from value (string or EntityInfo)
|
|
35
|
-
*/
|
|
36
|
-
function getName(value) {
|
|
37
|
-
return typeof value === 'string' ? value : value.name;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Get entity info from value
|
|
41
|
-
*/
|
|
42
|
-
function getEntityInfo(value) {
|
|
43
|
-
if (typeof value === 'string') {
|
|
44
|
-
return { name: value };
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* "a" formatter - indefinite article
|
|
50
|
-
*
|
|
51
|
-
* Respects nounType:
|
|
52
|
-
* - common: "a sword" / "an apple"
|
|
53
|
-
* - proper: "John" (no article)
|
|
54
|
-
* - mass: "some water"
|
|
55
|
-
* - unique: "the sun"
|
|
56
|
-
* - plural: "swords" (no article for indefinite plural)
|
|
57
|
-
*/
|
|
58
|
-
const aFormatter = (value, _context) => {
|
|
59
|
-
// Handle arrays - format each item
|
|
60
|
-
if (Array.isArray(value)) {
|
|
61
|
-
return value.map((v) => (0, exports.aFormatter)(v, _context)).join(', ');
|
|
62
|
-
}
|
|
63
|
-
const info = getEntityInfo(value);
|
|
64
|
-
const name = info.name;
|
|
65
|
-
// Check noun type
|
|
66
|
-
const nounType = info.nounType ?? (info.properName ? 'proper' : 'common');
|
|
67
|
-
switch (nounType) {
|
|
68
|
-
case 'proper':
|
|
69
|
-
return name; // No article for proper names
|
|
70
|
-
case 'mass':
|
|
71
|
-
return `some ${name}`;
|
|
72
|
-
case 'unique':
|
|
73
|
-
return `the ${name}`;
|
|
74
|
-
case 'plural':
|
|
75
|
-
return name; // No article for indefinite plurals
|
|
76
|
-
case 'common':
|
|
77
|
-
default:
|
|
78
|
-
// Check if entity has custom article
|
|
79
|
-
if (info.article && info.article !== 'a' && info.article !== 'an') {
|
|
80
|
-
return `${info.article} ${name}`;
|
|
81
|
-
}
|
|
82
|
-
return `${getIndefiniteArticle(name)} ${name}`;
|
|
83
|
-
}
|
|
84
|
-
};
|
|
85
|
-
exports.aFormatter = aFormatter;
|
|
86
|
-
/**
|
|
87
|
-
* "the" formatter - definite article
|
|
88
|
-
*
|
|
89
|
-
* Respects nounType:
|
|
90
|
-
* - proper: "John" (no article)
|
|
91
|
-
* - all others: "the X"
|
|
92
|
-
*/
|
|
93
|
-
const theFormatter = (value, _context) => {
|
|
94
|
-
// Handle arrays - format each item
|
|
95
|
-
if (Array.isArray(value)) {
|
|
96
|
-
return value.map((v) => (0, exports.theFormatter)(v, _context)).join(', ');
|
|
97
|
-
}
|
|
98
|
-
const info = getEntityInfo(value);
|
|
99
|
-
const name = info.name;
|
|
100
|
-
// Check noun type
|
|
101
|
-
const nounType = info.nounType ?? (info.properName ? 'proper' : 'common');
|
|
102
|
-
if (nounType === 'proper') {
|
|
103
|
-
return name; // No article for proper names
|
|
104
|
-
}
|
|
105
|
-
return `the ${name}`;
|
|
106
|
-
};
|
|
107
|
-
exports.theFormatter = theFormatter;
|
|
108
|
-
/**
|
|
109
|
-
* "some" formatter - partitive article
|
|
110
|
-
*
|
|
111
|
-
* Primarily for mass nouns: "some water"
|
|
112
|
-
* Also works for plurals: "some coins"
|
|
113
|
-
*/
|
|
114
|
-
const someFormatter = (value, _context) => {
|
|
115
|
-
// Handle arrays - format each item
|
|
116
|
-
if (Array.isArray(value)) {
|
|
117
|
-
return value.map((v) => (0, exports.someFormatter)(v, _context)).join(', ');
|
|
118
|
-
}
|
|
119
|
-
const info = getEntityInfo(value);
|
|
120
|
-
const name = info.name;
|
|
121
|
-
// Check noun type
|
|
122
|
-
const nounType = info.nounType ?? (info.properName ? 'proper' : 'common');
|
|
123
|
-
if (nounType === 'proper') {
|
|
124
|
-
return name; // No article for proper names
|
|
125
|
-
}
|
|
126
|
-
return `some ${name}`;
|
|
127
|
-
};
|
|
128
|
-
exports.someFormatter = someFormatter;
|
|
129
|
-
/**
|
|
130
|
-
* "your" formatter - possessive
|
|
131
|
-
*
|
|
132
|
-
* Creates "your X" phrases
|
|
133
|
-
*/
|
|
134
|
-
const yourFormatter = (value, _context) => {
|
|
135
|
-
// Handle arrays
|
|
136
|
-
if (Array.isArray(value)) {
|
|
137
|
-
return value.map((v) => (0, exports.yourFormatter)(v, _context)).join(', ');
|
|
138
|
-
}
|
|
139
|
-
const name = getName(value);
|
|
140
|
-
return `your ${name}`;
|
|
141
|
-
};
|
|
142
|
-
exports.yourFormatter = yourFormatter;
|
|
143
|
-
//# sourceMappingURL=article.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"article.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/lang-en-us/src/formatters/article.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAIH;;GAEG;AACH,SAAS,oBAAoB,CAAC,IAAY;IACxC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC;IAE3C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IAEjC,gBAAgB;IAChB,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5C,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC,CAAE,aAAa;IACvD,IAAI,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC;QAAE,OAAO,GAAG,CAAC,CAAG,UAAU;IAErD,MAAM,SAAS,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;IAC3B,MAAM,MAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IAEzC,OAAO,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AACjD,CAAC;AAED;;GAEG;AACH,SAAS,OAAO,CAAC,KAA0B;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK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jE,CAAC;IAED,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IAEvB,kBAAkB;IAClB,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAE1E,IAAI,QAAQ,KAAK,QAAQ,EAAE,CAAC;QAC1B,OAAO,IAAI,CAAC,CAAC,8BAA8B;IAC7C,CAAC;IAED,OAAO,QAAQ,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC;AAjBW,QAAA,aAAa,iBAiBxB;AAEF;;;;GAIG;AACI,MAAM,aAAa,GAAc,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;IAC1D,gBAAgB;IAChB,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAA,qBAAa,EAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,OAAO,QAAQ,IAAI,EAAE,CAAC;AACxB,CAAC,CAAC;AARW,QAAA,aAAa,iBAQxB"}
|
package/formatters/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Formatter System
|
|
3
|
-
*
|
|
4
|
-
* Formatters transform placeholder values in message templates.
|
|
5
|
-
*
|
|
6
|
-
* Syntax: {formatter:formatter:...:placeholder} (the placeholder is the last segment)
|
|
7
|
-
* Example: {a:item} → "a sword"
|
|
8
|
-
* Example: {list:items} → "a sword, a key, and a coin" (articles + grouping, ADR-190)
|
|
9
|
-
* Example: {the-list:items} → "the sword, the key, and the coin"
|
|
10
|
-
*
|
|
11
|
-
* @see ADR-095 Message Templates with Formatters
|
|
12
|
-
*/
|
|
13
|
-
export type { Formatter, FormatterRegistry, FormatterContext, EntityInfo, } from './types.js';
|
|
14
|
-
export { createFormatterRegistry, parsePlaceholder, applyFormatters, formatMessage, } from './registry.js';
|
|
15
|
-
export { aFormatter, theFormatter, someFormatter, yourFormatter } from './article.js';
|
|
16
|
-
export { listFormatter, orListFormatter, commaListFormatter, countFormatter } from './list.js';
|
|
17
|
-
export { capFormatter, upperFormatter, lowerFormatter, titleFormatter } from './text.js';
|
|
18
|
-
export { isFormatter, wasFormatter, hasFormatter } from './verb.js';
|
|
19
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/lang-en-us/src/formatters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,GACX,MAAM,YAAY,CAAC;AAGpB,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,eAAe,EACf,aAAa,GACd,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACtF,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC"}
|
package/formatters/index.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Formatter System
|
|
4
|
-
*
|
|
5
|
-
* Formatters transform placeholder values in message templates.
|
|
6
|
-
*
|
|
7
|
-
* Syntax: {formatter:formatter:...:placeholder} (the placeholder is the last segment)
|
|
8
|
-
* Example: {a:item} → "a sword"
|
|
9
|
-
* Example: {list:items} → "a sword, a key, and a coin" (articles + grouping, ADR-190)
|
|
10
|
-
* Example: {the-list:items} → "the sword, the key, and the coin"
|
|
11
|
-
*
|
|
12
|
-
* @see ADR-095 Message Templates with Formatters
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.hasFormatter = exports.wasFormatter = exports.isFormatter = exports.titleFormatter = exports.lowerFormatter = exports.upperFormatter = exports.capFormatter = exports.countFormatter = exports.commaListFormatter = exports.orListFormatter = exports.listFormatter = exports.yourFormatter = exports.someFormatter = exports.theFormatter = exports.aFormatter = exports.formatMessage = exports.applyFormatters = exports.parsePlaceholder = exports.createFormatterRegistry = void 0;
|
|
16
|
-
// Registry and utilities
|
|
17
|
-
var registry_js_1 = require("./registry.js");
|
|
18
|
-
Object.defineProperty(exports, "createFormatterRegistry", { enumerable: true, get: function () { return registry_js_1.createFormatterRegistry; } });
|
|
19
|
-
Object.defineProperty(exports, "parsePlaceholder", { enumerable: true, get: function () { return registry_js_1.parsePlaceholder; } });
|
|
20
|
-
Object.defineProperty(exports, "applyFormatters", { enumerable: true, get: function () { return registry_js_1.applyFormatters; } });
|
|
21
|
-
Object.defineProperty(exports, "formatMessage", { enumerable: true, get: function () { return registry_js_1.formatMessage; } });
|
|
22
|
-
// Individual formatters (for direct use or testing)
|
|
23
|
-
var article_js_1 = require("./article.js");
|
|
24
|
-
Object.defineProperty(exports, "aFormatter", { enumerable: true, get: function () { return article_js_1.aFormatter; } });
|
|
25
|
-
Object.defineProperty(exports, "theFormatter", { enumerable: true, get: function () { return article_js_1.theFormatter; } });
|
|
26
|
-
Object.defineProperty(exports, "someFormatter", { enumerable: true, get: function () { return article_js_1.someFormatter; } });
|
|
27
|
-
Object.defineProperty(exports, "yourFormatter", { enumerable: true, get: function () { return article_js_1.yourFormatter; } });
|
|
28
|
-
var list_js_1 = require("./list.js");
|
|
29
|
-
Object.defineProperty(exports, "listFormatter", { enumerable: true, get: function () { return list_js_1.listFormatter; } });
|
|
30
|
-
Object.defineProperty(exports, "orListFormatter", { enumerable: true, get: function () { return list_js_1.orListFormatter; } });
|
|
31
|
-
Object.defineProperty(exports, "commaListFormatter", { enumerable: true, get: function () { return list_js_1.commaListFormatter; } });
|
|
32
|
-
Object.defineProperty(exports, "countFormatter", { enumerable: true, get: function () { return list_js_1.countFormatter; } });
|
|
33
|
-
var text_js_1 = require("./text.js");
|
|
34
|
-
Object.defineProperty(exports, "capFormatter", { enumerable: true, get: function () { return text_js_1.capFormatter; } });
|
|
35
|
-
Object.defineProperty(exports, "upperFormatter", { enumerable: true, get: function () { return text_js_1.upperFormatter; } });
|
|
36
|
-
Object.defineProperty(exports, "lowerFormatter", { enumerable: true, get: function () { return text_js_1.lowerFormatter; } });
|
|
37
|
-
Object.defineProperty(exports, "titleFormatter", { enumerable: true, get: function () { return text_js_1.titleFormatter; } });
|
|
38
|
-
var verb_js_1 = require("./verb.js");
|
|
39
|
-
Object.defineProperty(exports, "isFormatter", { enumerable: true, get: function () { return verb_js_1.isFormatter; } });
|
|
40
|
-
Object.defineProperty(exports, "wasFormatter", { enumerable: true, get: function () { return verb_js_1.wasFormatter; } });
|
|
41
|
-
Object.defineProperty(exports, "hasFormatter", { enumerable: true, get: function () { return verb_js_1.hasFormatter; } });
|
|
42
|
-
//# sourceMappingURL=index.js.map
|
package/formatters/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/lang-en-us/src/formatters/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAUH,yBAAyB;AACzB,6CAKuB;AAJrB,sHAAA,uBAAuB,OAAA;AACvB,+GAAA,gBAAgB,OAAA;AAChB,8GAAA,eAAe,OAAA;AACf,4GAAA,aAAa,OAAA;AAGf,oDAAoD;AACpD,2CAAsF;AAA7E,wGAAA,UAAU,OAAA;AAAE,0GAAA,YAAY,OAAA;AAAE,2GAAA,aAAa,OAAA;AAAE,2GAAA,aAAa,OAAA;AAC/D,qCAA+F;AAAtF,wGAAA,aAAa,OAAA;AAAE,0GAAA,eAAe,OAAA;AAAE,6GAAA,kBAAkB,OAAA;AAAE,yGAAA,cAAc,OAAA;AAC3E,qCAAyF;AAAhF,uGAAA,YAAY,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,yGAAA,cAAc,OAAA;AAAE,yGAAA,cAAc,OAAA;AACrE,qCAAoE;AAA3D,sGAAA,WAAW,OAAA;AAAE,uGAAA,YAAY,OAAA;AAAE,uGAAA,YAAY,OAAA"}
|
package/formatters/list.d.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* List Formatters
|
|
3
|
-
*
|
|
4
|
-
* Formatters for joining arrays of items into prose.
|
|
5
|
-
*
|
|
6
|
-
* @see ADR-095 Message Templates with Formatters
|
|
7
|
-
*/
|
|
8
|
-
import type { Formatter } from './types.js';
|
|
9
|
-
/**
|
|
10
|
-
* "list" formatter — natural-language list of entities (ADR-190).
|
|
11
|
-
*
|
|
12
|
-
* Each `EntityInfo` element gets its indefinite article ("a goat", "an apple",
|
|
13
|
-
* "some sand"); identical common nouns group and pluralize ("two goats"); the
|
|
14
|
-
* parts join with commas and "and", with the serial (Oxford) comma controlled by
|
|
15
|
-
* the story's `serialComma` setting (default on). Bare strings render as-is.
|
|
16
|
-
* Empty → "nothing".
|
|
17
|
-
*
|
|
18
|
-
* {list:items} → "a goat, two rabbits, and a parrot"
|
|
19
|
-
*/
|
|
20
|
-
export declare const listFormatter: Formatter;
|
|
21
|
-
/**
|
|
22
|
-
* "the-list" formatter — definite variant: "the goat, the rabbit, and the parrot".
|
|
23
|
-
* No count-grouping (definite items are individuated); proper names take no article.
|
|
24
|
-
*/
|
|
25
|
-
export declare const theListFormatter: Formatter;
|
|
26
|
-
/**
|
|
27
|
-
* "names" formatter — plain name join (the pre-ADR-190 `list` behavior) for
|
|
28
|
-
* non-entity string lists: no articles, no grouping. Empty → "".
|
|
29
|
-
*/
|
|
30
|
-
export declare const namesFormatter: Formatter;
|
|
31
|
-
/**
|
|
32
|
-
* "or-list" formatter - join with commas and "or"
|
|
33
|
-
*
|
|
34
|
-
* Single: "north"
|
|
35
|
-
* Two: "north or south"
|
|
36
|
-
* Three+: "north, south, or east"
|
|
37
|
-
*/
|
|
38
|
-
export declare const orListFormatter: Formatter;
|
|
39
|
-
/**
|
|
40
|
-
* "comma-list" formatter - join with commas only (no conjunction)
|
|
41
|
-
*
|
|
42
|
-
* "a sword, a key, a coin"
|
|
43
|
-
*/
|
|
44
|
-
export declare const commaListFormatter: Formatter;
|
|
45
|
-
/**
|
|
46
|
-
* "count" formatter - a count word plus the (pluralized) noun.
|
|
47
|
-
*
|
|
48
|
-
* Spells out 1–10, numeric for 11+ (ADR-190). Uses the entity's `plural` override
|
|
49
|
-
* (from `IdentityTrait.plural`) when present, else the `pluralize()` heuristic.
|
|
50
|
-
*
|
|
51
|
-
* Example: {count:items} with 3 swords → "three swords"
|
|
52
|
-
* Example: {count:items} with 1 sword → "one sword"
|
|
53
|
-
* Example: {count:items} with 0 → "nothing"
|
|
54
|
-
*/
|
|
55
|
-
export declare const countFormatter: Formatter;
|
|
56
|
-
//# sourceMappingURL=list.d.ts.map
|
package/formatters/list.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/lang-en-us/src/formatters/list.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAgC,MAAM,YAAY,CAAC;AAwF1E;;;;;;;;;;GAUG;AACH,eAAO,MAAM,aAAa,EAAE,SAC6C,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,gBAAgB,EAAE,SACwC,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,SAI5B,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,EAAE,SAU7B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,SAGhC,CAAC;AAaF;;;;;;;;;GASG;AACH,eAAO,MAAM,cAAc,EAAE,SAS5B,CAAC"}
|
package/formatters/list.js
DELETED
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* List Formatters
|
|
4
|
-
*
|
|
5
|
-
* Formatters for joining arrays of items into prose.
|
|
6
|
-
*
|
|
7
|
-
* @see ADR-095 Message Templates with Formatters
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.countFormatter = exports.commaListFormatter = exports.orListFormatter = exports.namesFormatter = exports.theListFormatter = exports.listFormatter = void 0;
|
|
11
|
-
const article_js_1 = require("./article.js");
|
|
12
|
-
const pluralize_js_1 = require("../pluralize.js");
|
|
13
|
-
const number_words_js_1 = require("../number-words.js");
|
|
14
|
-
/**
|
|
15
|
-
* Extract name from value (string or EntityInfo)
|
|
16
|
-
*/
|
|
17
|
-
function getName(value) {
|
|
18
|
-
return typeof value === 'string' ? value : value.name;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Ensure value is an array
|
|
22
|
-
*/
|
|
23
|
-
function ensureArray(value) {
|
|
24
|
-
if (Array.isArray(value)) {
|
|
25
|
-
return value.map((v) => getName(v));
|
|
26
|
-
}
|
|
27
|
-
return [getName(value)];
|
|
28
|
-
}
|
|
29
|
-
/** True for a bare string element (no entity metadata to article/group). */
|
|
30
|
-
function isBare(v) {
|
|
31
|
-
return typeof v === 'string';
|
|
32
|
-
}
|
|
33
|
-
/** A common noun groups by name; proper/mass/unique/plural do not. */
|
|
34
|
-
function isCommonNoun(ei) {
|
|
35
|
-
const nounType = ei.nounType ?? (ei.properName ? 'proper' : 'common');
|
|
36
|
-
return nounType === 'common';
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Render each element into a phrase. In indefinite mode, identical common-noun
|
|
40
|
-
* entities group and pluralize ("two goats"); bare strings render as-is (no
|
|
41
|
-
* article), preserving plain name lists. In definite mode, every entity becomes
|
|
42
|
-
* "the X" with no grouping.
|
|
43
|
-
*/
|
|
44
|
-
function renderListParts(value, mode, context) {
|
|
45
|
-
const arr = Array.isArray(value) ? value : value == null ? [] : [value];
|
|
46
|
-
if (mode === 'definite') {
|
|
47
|
-
return arr.map((v) => (isBare(v) ? v : (0, article_js_1.theFormatter)(v, context)));
|
|
48
|
-
}
|
|
49
|
-
const parts = [];
|
|
50
|
-
const groupIndex = new Map();
|
|
51
|
-
for (const v of arr) {
|
|
52
|
-
if (!isBare(v) && isCommonNoun(v)) {
|
|
53
|
-
const ei = v;
|
|
54
|
-
const existing = groupIndex.get(ei.name);
|
|
55
|
-
if (existing !== undefined) {
|
|
56
|
-
parts[existing].count++;
|
|
57
|
-
continue;
|
|
58
|
-
}
|
|
59
|
-
groupIndex.set(ei.name, parts.length);
|
|
60
|
-
parts.push({ value: v, ei, count: 1 });
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
parts.push({ value: v, count: 1 });
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
return parts.map((p) => {
|
|
67
|
-
if (p.count > 1 && p.ei) {
|
|
68
|
-
const plural = p.ei.plural ?? (0, pluralize_js_1.pluralize)(p.ei.name);
|
|
69
|
-
return `${(0, number_words_js_1.countWord)(p.count)} ${plural}`;
|
|
70
|
-
}
|
|
71
|
-
return isBare(p.value) ? p.value : (0, article_js_1.aFormatter)(p.value, context);
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
/** Join rendered parts with commas and a conjunction; serial comma per setting. */
|
|
75
|
-
function joinList(parts, conjunction, context) {
|
|
76
|
-
if (parts.length === 0)
|
|
77
|
-
return 'nothing';
|
|
78
|
-
if (parts.length === 1)
|
|
79
|
-
return parts[0];
|
|
80
|
-
if (parts.length === 2)
|
|
81
|
-
return `${parts[0]} ${conjunction} ${parts[1]}`;
|
|
82
|
-
const serial = context?.settings?.serialComma ?? true;
|
|
83
|
-
const head = parts.slice(0, -1).join(', ');
|
|
84
|
-
const last = parts[parts.length - 1];
|
|
85
|
-
return serial ? `${head}, ${conjunction} ${last}` : `${head} ${conjunction} ${last}`;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* "list" formatter — natural-language list of entities (ADR-190).
|
|
89
|
-
*
|
|
90
|
-
* Each `EntityInfo` element gets its indefinite article ("a goat", "an apple",
|
|
91
|
-
* "some sand"); identical common nouns group and pluralize ("two goats"); the
|
|
92
|
-
* parts join with commas and "and", with the serial (Oxford) comma controlled by
|
|
93
|
-
* the story's `serialComma` setting (default on). Bare strings render as-is.
|
|
94
|
-
* Empty → "nothing".
|
|
95
|
-
*
|
|
96
|
-
* {list:items} → "a goat, two rabbits, and a parrot"
|
|
97
|
-
*/
|
|
98
|
-
const listFormatter = (value, context) => joinList(renderListParts(value, 'indefinite', context), 'and', context);
|
|
99
|
-
exports.listFormatter = listFormatter;
|
|
100
|
-
/**
|
|
101
|
-
* "the-list" formatter — definite variant: "the goat, the rabbit, and the parrot".
|
|
102
|
-
* No count-grouping (definite items are individuated); proper names take no article.
|
|
103
|
-
*/
|
|
104
|
-
const theListFormatter = (value, context) => joinList(renderListParts(value, 'definite', context), 'and', context);
|
|
105
|
-
exports.theListFormatter = theListFormatter;
|
|
106
|
-
/**
|
|
107
|
-
* "names" formatter — plain name join (the pre-ADR-190 `list` behavior) for
|
|
108
|
-
* non-entity string lists: no articles, no grouping. Empty → "".
|
|
109
|
-
*/
|
|
110
|
-
const namesFormatter = (value, context) => {
|
|
111
|
-
const items = ensureArray(value);
|
|
112
|
-
if (items.length === 0)
|
|
113
|
-
return '';
|
|
114
|
-
return joinList(items, 'and', context);
|
|
115
|
-
};
|
|
116
|
-
exports.namesFormatter = namesFormatter;
|
|
117
|
-
/**
|
|
118
|
-
* "or-list" formatter - join with commas and "or"
|
|
119
|
-
*
|
|
120
|
-
* Single: "north"
|
|
121
|
-
* Two: "north or south"
|
|
122
|
-
* Three+: "north, south, or east"
|
|
123
|
-
*/
|
|
124
|
-
const orListFormatter = (value, _context) => {
|
|
125
|
-
const items = ensureArray(value);
|
|
126
|
-
if (items.length === 0)
|
|
127
|
-
return '';
|
|
128
|
-
if (items.length === 1)
|
|
129
|
-
return items[0];
|
|
130
|
-
if (items.length === 2)
|
|
131
|
-
return `${items[0]} or ${items[1]}`;
|
|
132
|
-
const allButLast = items.slice(0, -1);
|
|
133
|
-
const last = items[items.length - 1];
|
|
134
|
-
return `${allButLast.join(', ')}, or ${last}`;
|
|
135
|
-
};
|
|
136
|
-
exports.orListFormatter = orListFormatter;
|
|
137
|
-
/**
|
|
138
|
-
* "comma-list" formatter - join with commas only (no conjunction)
|
|
139
|
-
*
|
|
140
|
-
* "a sword, a key, a coin"
|
|
141
|
-
*/
|
|
142
|
-
const commaListFormatter = (value, _context) => {
|
|
143
|
-
const items = ensureArray(value);
|
|
144
|
-
return items.join(', ');
|
|
145
|
-
};
|
|
146
|
-
exports.commaListFormatter = commaListFormatter;
|
|
147
|
-
/** First element's noun name and optional plural override (EntityInfo or string). */
|
|
148
|
-
function firstNoun(value) {
|
|
149
|
-
const arr = Array.isArray(value) ? value : value == null ? [] : [value];
|
|
150
|
-
const first = arr[0];
|
|
151
|
-
if (first && typeof first === 'object' && 'name' in first) {
|
|
152
|
-
const ei = first;
|
|
153
|
-
return { name: ei.name, plural: ei.plural };
|
|
154
|
-
}
|
|
155
|
-
return { name: first == null ? '' : String(first) };
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* "count" formatter - a count word plus the (pluralized) noun.
|
|
159
|
-
*
|
|
160
|
-
* Spells out 1–10, numeric for 11+ (ADR-190). Uses the entity's `plural` override
|
|
161
|
-
* (from `IdentityTrait.plural`) when present, else the `pluralize()` heuristic.
|
|
162
|
-
*
|
|
163
|
-
* Example: {count:items} with 3 swords → "three swords"
|
|
164
|
-
* Example: {count:items} with 1 sword → "one sword"
|
|
165
|
-
* Example: {count:items} with 0 → "nothing"
|
|
166
|
-
*/
|
|
167
|
-
const countFormatter = (value, _context) => {
|
|
168
|
-
const count = Array.isArray(value) ? value.length : value == null ? 0 : 1;
|
|
169
|
-
if (count === 0)
|
|
170
|
-
return 'nothing';
|
|
171
|
-
const { name, plural } = firstNoun(value);
|
|
172
|
-
if (count === 1)
|
|
173
|
-
return `one ${name}`;
|
|
174
|
-
const pluralNoun = plural ?? (0, pluralize_js_1.pluralize)(name);
|
|
175
|
-
return `${(0, number_words_js_1.countWord)(count)} ${pluralNoun}`;
|
|
176
|
-
};
|
|
177
|
-
exports.countFormatter = countFormatter;
|
|
178
|
-
//# sourceMappingURL=list.js.map
|
package/formatters/list.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/lang-en-us/src/formatters/list.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAGH,6CAAwD;AACxD,kDAA4C;AAC5C,wDAA+C;AAE/C;;GAEG;AACH,SAAS,OAAO,CAAC,KAA0B;IACzC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC;AACxD,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,CAAC,OAAO,CAAC,KAA4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|
-
* @see ADR-095 Message Templates with Formatters
|
|
7
|
-
*/
|
|
8
|
-
import type { FormatterRegistry, FormatterContext, EntityInfo } from './types.js';
|
|
9
|
-
/**
|
|
10
|
-
* Create the default formatter registry with all built-in formatters
|
|
11
|
-
*/
|
|
12
|
-
export declare function createFormatterRegistry(): FormatterRegistry;
|
|
13
|
-
/**
|
|
14
|
-
* Parse a placeholder with formatters
|
|
15
|
-
*
|
|
16
|
-
* Syntax: {formatter:formatter:...:placeholder}
|
|
17
|
-
*
|
|
18
|
-
* @returns Object with formatters array and final placeholder name
|
|
19
|
-
*/
|
|
20
|
-
export declare function parsePlaceholder(placeholder: string): {
|
|
21
|
-
formatters: string[];
|
|
22
|
-
name: string;
|
|
23
|
-
};
|
|
24
|
-
/**
|
|
25
|
-
* Apply formatters to a value in sequence
|
|
26
|
-
*
|
|
27
|
-
* @param value - The value to format
|
|
28
|
-
* @param formatters - Array of formatter names to apply in order
|
|
29
|
-
* @param registry - The formatter registry
|
|
30
|
-
* @param context - Formatting context
|
|
31
|
-
* @returns Formatted string
|
|
32
|
-
*/
|
|
33
|
-
export declare function applyFormatters(value: string | number | boolean | string[] | EntityInfo | EntityInfo[], formatters: string[], registry: FormatterRegistry, context: FormatterContext): string;
|
|
34
|
-
/**
|
|
35
|
-
* Format a message template with placeholders
|
|
36
|
-
*
|
|
37
|
-
* Supports both:
|
|
38
|
-
* - Simple placeholders: {item}
|
|
39
|
-
* - Formatted placeholders: {a:item}, {list:items}, {the:cap:item}
|
|
40
|
-
* (the placeholder is the last colon segment)
|
|
41
|
-
*
|
|
42
|
-
* @param template - Message template with {placeholder} syntax
|
|
43
|
-
* @param params - Values for placeholders
|
|
44
|
-
* @param registry - Formatter registry
|
|
45
|
-
* @param context - Formatting context
|
|
46
|
-
* @returns Formatted message
|
|
47
|
-
*/
|
|
48
|
-
export declare function formatMessage(template: string, params: Record<string, string | number | boolean | string[] | EntityInfo | EntityInfo[]>, registry: FormatterRegistry, context?: FormatterContext): string;
|
|
49
|
-
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../../../repos/sharpee_v1/packages/lang-en-us/src/formatters/registry.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAa,iBAAiB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAM7F;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,iBAAiB,CA8B3D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG;IACrD,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;CACd,CAYA;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,UAAU,EAAE,EACvE,UAAU,EAAE,MAAM,EAAE,EACpB,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,EAAE,gBAAgB,GACxB,MAAM,CAuBR;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,EAAE,GAAG,UAAU,GAAG,UAAU,EAAE,CAAC,EACxF,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,MAAM,CA8BR"}
|