@shadowob/shared 1.1.0 → 1.1.3

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.
@@ -1,3 +1,5 @@
1
+ import { g as MessageMentionRange, e as MessageMention } from '../message.types-lG4qBSus.js';
2
+
1
3
  type CatPattern = 'none' | 'tabby' | 'tuxedo' | 'siamese' | 'calico' | 'bicolor';
2
4
  type CatExpression = 'smile' | 'open' | 'flat' | 'sad' | 'surprised' | 'kawaii' | 'winking' | 'smirk';
3
5
  type CatDecoration = 'none' | 'glasses' | 'blush' | 'scar' | 'flower' | 'fish' | 'headband';
@@ -15,6 +17,43 @@ interface CatConfig {
15
17
  declare function generateRandomCatConfig(): CatConfig;
16
18
  declare function renderCatSvg(config: CatConfig): string;
17
19
 
20
+ type MessageMentionTextSegment = {
21
+ type: 'text';
22
+ text: string;
23
+ } | {
24
+ type: 'mention';
25
+ text: string;
26
+ range: MessageMentionRange;
27
+ mention: MessageMention;
28
+ };
29
+ declare function canonicalMentionToken(mention: Pick<MessageMention, 'kind' | 'targetId'> & Partial<MessageMention>): string;
30
+ declare function parseCanonicalMentionToken(token: string): {
31
+ kind: 'user';
32
+ targetId: string;
33
+ } | {
34
+ kind: 'channel';
35
+ targetId: string;
36
+ } | {
37
+ kind: 'server';
38
+ targetId: string;
39
+ } | {
40
+ kind: 'here' | 'everyone';
41
+ targetId?: string;
42
+ } | null;
43
+ declare function isCanonicalMentionToken(token: string): boolean;
44
+ declare function segmentTextByMentions(content: string, mentions: readonly MessageMention[] | null | undefined): MessageMentionTextSegment[];
45
+ declare function assignMentionRanges(content: string, mentions: readonly MessageMention[] | null | undefined): MessageMention[];
46
+ declare function canonicalizeMentionContent(content: string, mentions: readonly MessageMention[] | null | undefined): {
47
+ content: string;
48
+ mentions: MessageMention[];
49
+ };
50
+ declare function mentionDisplayText(mention: Pick<MessageMention, 'label' | 'token'>): string;
51
+ declare function escapeMarkdownLinkLabel(label: string): string;
52
+ declare function buildMentionMarkdownLinks(content: string, mentions: readonly MessageMention[] | null | undefined, hrefForMention: (mention: MessageMention, index: number) => string | null | undefined): {
53
+ markdown: string;
54
+ mentions: MessageMention[];
55
+ };
56
+
18
57
  /**
19
58
  * Pixel Art Cat Avatar System
20
59
  * 8 unique cat variants with distinct color schemes inspired by the Shadow logo
@@ -38,4 +77,4 @@ declare function formatDate(date: string | Date): string;
38
77
  declare function isValidEmail(email: string): boolean;
39
78
  declare function slugify(text: string): string;
40
79
 
41
- export { type BgPattern, CAT_AVATAR_COUNT, type CatConfig, type CatDecoration, type CatExpression, type CatPattern, formatDate, generateInviteCode, generateRandomCatConfig, getAllCatAvatars, getCatAvatar, getCatAvatarByUserId, getCatSvgString, isValidEmail, renderCatSvg, slugify };
80
+ export { type BgPattern, CAT_AVATAR_COUNT, type CatConfig, type CatDecoration, type CatExpression, type CatPattern, type MessageMentionTextSegment, assignMentionRanges, buildMentionMarkdownLinks, canonicalMentionToken, canonicalizeMentionContent, escapeMarkdownLinkLabel, formatDate, generateInviteCode, generateRandomCatConfig, getAllCatAvatars, getCatAvatar, getCatAvatarByUserId, getCatSvgString, isCanonicalMentionToken, isValidEmail, mentionDisplayText, parseCanonicalMentionToken, renderCatSvg, segmentTextByMentions, slugify };
@@ -1,5 +1,10 @@
1
1
  import {
2
2
  CAT_AVATAR_COUNT,
3
+ assignMentionRanges,
4
+ buildMentionMarkdownLinks,
5
+ canonicalMentionToken,
6
+ canonicalizeMentionContent,
7
+ escapeMarkdownLinkLabel,
3
8
  formatDate,
4
9
  generateInviteCode,
5
10
  generateRandomCatConfig,
@@ -7,12 +12,21 @@ import {
7
12
  getCatAvatar,
8
13
  getCatAvatarByUserId,
9
14
  getCatSvgString,
15
+ isCanonicalMentionToken,
10
16
  isValidEmail,
17
+ mentionDisplayText,
18
+ parseCanonicalMentionToken,
11
19
  renderCatSvg,
20
+ segmentTextByMentions,
12
21
  slugify
13
- } from "../chunk-PXKHJSTK.js";
22
+ } from "../chunk-E3UBH4AI.js";
14
23
  export {
15
24
  CAT_AVATAR_COUNT,
25
+ assignMentionRanges,
26
+ buildMentionMarkdownLinks,
27
+ canonicalMentionToken,
28
+ canonicalizeMentionContent,
29
+ escapeMarkdownLinkLabel,
16
30
  formatDate,
17
31
  generateInviteCode,
18
32
  generateRandomCatConfig,
@@ -20,7 +34,11 @@ export {
20
34
  getCatAvatar,
21
35
  getCatAvatarByUserId,
22
36
  getCatSvgString,
37
+ isCanonicalMentionToken,
23
38
  isValidEmail,
39
+ mentionDisplayText,
40
+ parseCanonicalMentionToken,
24
41
  renderCatSvg,
42
+ segmentTextByMentions,
25
43
  slugify
26
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shadowob/shared",
3
- "version": "1.1.0",
3
+ "version": "1.1.3",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -10,6 +10,7 @@
10
10
  ".": {
11
11
  "types": "./dist/index.d.ts",
12
12
  "development": "./src/index.ts",
13
+ "react-native": "./src/index.ts",
13
14
  "import": "./dist/index.js",
14
15
  "require": "./dist/index.cjs",
15
16
  "default": "./dist/index.js"
@@ -17,6 +18,7 @@
17
18
  "./types": {
18
19
  "types": "./dist/types/index.d.ts",
19
20
  "development": "./src/types/index.ts",
21
+ "react-native": "./src/types/index.ts",
20
22
  "import": "./dist/types/index.js",
21
23
  "require": "./dist/types/index.cjs",
22
24
  "default": "./dist/types/index.js"
@@ -24,13 +26,23 @@
24
26
  "./constants": {
25
27
  "types": "./dist/constants/index.d.ts",
26
28
  "development": "./src/constants/index.ts",
29
+ "react-native": "./src/constants/index.ts",
27
30
  "import": "./dist/constants/index.js",
28
31
  "require": "./dist/constants/index.cjs",
29
32
  "default": "./dist/constants/index.js"
30
33
  },
34
+ "./play-catalog": {
35
+ "types": "./dist/play-catalog/index.d.ts",
36
+ "development": "./src/play-catalog/index.ts",
37
+ "react-native": "./src/play-catalog/index.ts",
38
+ "import": "./dist/play-catalog/index.js",
39
+ "require": "./dist/play-catalog/index.cjs",
40
+ "default": "./dist/play-catalog/index.js"
41
+ },
31
42
  "./utils": {
32
43
  "types": "./dist/utils/index.d.ts",
33
44
  "development": "./src/utils/index.ts",
45
+ "react-native": "./src/utils/index.ts",
34
46
  "import": "./dist/utils/index.js",
35
47
  "require": "./dist/utils/index.cjs",
36
48
  "default": "./dist/utils/index.js"
@@ -40,7 +52,7 @@
40
52
  "dist"
41
53
  ],
42
54
  "dependencies": {
43
- "nanoid": "^5.1.7"
55
+ "nanoid": "^5.1.11"
44
56
  },
45
57
  "devDependencies": {
46
58
  "tsup": "^8.5.0",
@@ -52,6 +64,7 @@
52
64
  "scripts": {
53
65
  "build": "tsup",
54
66
  "dev": "tsup --watch",
67
+ "typecheck": "tsc --noEmit",
55
68
  "test": "vitest run",
56
69
  "test:watch": "vitest"
57
70
  }