@openeditor/emoji 0.0.34 → 0.0.35

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/README.md CHANGED
@@ -17,3 +17,9 @@ import { OpenEditorEmojiPicker } from "@openeditor/emoji";
17
17
  onEmojiSelect={(emoji) => console.log(emoji)}
18
18
  />
19
19
  ```
20
+
21
+ The picker requests its packaged English locale from
22
+ `/api/openeditor/emoji-data/{locale}/{file}` by default. Serve that route with
23
+ `createOpenEditorEmojiDataResponse` from `@openeditor/emoji/data`, or pass a
24
+ different `emojibaseUrl`. The React Native embedded surface handles the same
25
+ route internally and remains fully offline.
package/dist/data.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ export { O as OPENEDITOR_EMOJI_DATA_URL, a as OpenEditorEmojiDataRequest, p as parseOpenEditorEmojiDataPath } from './endpoint-hqKhDQcd.js';
2
+
1
3
  declare const OPENEDITOR_EMOJI_DATA_LOCALE = "en";
2
4
  type OpenEditorEmojiDataFile = "data.json" | "messages.json";
3
5
  /**
@@ -6,6 +8,8 @@ type OpenEditorEmojiDataFile = "data.json" | "messages.json";
6
8
  * expose a third-party CDN in their Content Security Policy.
7
9
  */
8
10
  declare const getOpenEditorEmojiData: (locale: string, file: string) => unknown | undefined;
9
- declare const createOpenEditorEmojiDataResponse: (locale: string, file: string) => Response;
11
+ declare const createOpenEditorEmojiDataResponse: (locale: string, file: string, options?: {
12
+ method?: string;
13
+ }) => Response;
10
14
 
11
15
  export { OPENEDITOR_EMOJI_DATA_LOCALE, type OpenEditorEmojiDataFile, createOpenEditorEmojiDataResponse, getOpenEditorEmojiData };
package/dist/data.js CHANGED
@@ -4,6 +4,24 @@ var data_default = [{ label: "regional indicator A", hexcode: "1F1E6", emoji: "\
4
4
  // ../../node_modules/.pnpm/emojibase-data@16.0.2_emojibase@17.0.0/node_modules/emojibase-data/en/messages.json
5
5
  var messages_default = { groups: [{ key: "smileys-emotion", message: "smileys & emotion", order: 0 }, { key: "people-body", message: "people & body", order: 1 }, { key: "component", message: "components", order: 2 }, { key: "animals-nature", message: "animals & nature", order: 3 }, { key: "food-drink", message: "food & drink", order: 4 }, { key: "travel-places", message: "travel & places", order: 5 }, { key: "activities", message: "activities", order: 6 }, { key: "objects", message: "objects", order: 7 }, { key: "symbols", message: "symbols", order: 8 }, { key: "flags", message: "flags", order: 9 }], skinTones: [{ key: "dark", message: "dark skin tone" }, { key: "light", message: "light skin tone" }, { key: "medium", message: "medium skin tone" }, { key: "medium-dark", message: "medium-dark skin tone" }, { key: "medium-light", message: "medium-light skin tone" }], subgroups: [{ key: "face-smiling", message: "smiling", order: 0 }, { key: "face-affection", message: "affectionate", order: 1 }, { key: "face-tongue", message: "with tongue", order: 2 }, { key: "face-hand", message: "with hands", order: 3 }, { key: "face-neutral-skeptical", message: "neutral / skeptical", order: 4 }, { key: "face-sleepy", message: "sleepy", order: 5 }, { key: "face-unwell", message: "unwell", order: 6 }, { key: "face-hat", message: "with hats", order: 7 }, { key: "face-glasses", message: "with glasses", order: 8 }, { key: "face-concerned", message: "concerned", order: 9 }, { key: "face-negative", message: "negative", order: 10 }, { key: "face-costume", message: "costumed & creatures", order: 11 }, { key: "cat-face", message: "cat faces", order: 12 }, { key: "monkey-face", message: "monkey faces", order: 13 }, { key: "heart", message: "hearts", order: 14 }, { key: "emotion", message: "emotions", order: 15 }, { key: "hand-fingers-open", message: "fingers open", order: 16 }, { key: "hand-fingers-partial", message: "hand signs", order: 17 }, { key: "hand-single-finger", message: "finger pointing", order: 18 }, { key: "hand-fingers-closed", message: "fingers closed", order: 19 }, { key: "hands", message: "hands", order: 20 }, { key: "hand-prop", message: "hand props", order: 21 }, { key: "body-parts", message: "body parts", order: 22 }, { key: "person", message: "people", order: 23 }, { key: "person-gesture", message: "gestures", order: 24 }, { key: "person-role", message: "roles & careers", order: 25 }, { key: "person-fantasy", message: "fantasy", order: 26 }, { key: "person-activity", message: "activities", order: 27 }, { key: "person-sport", message: "athletics", order: 28 }, { key: "person-resting", message: "resting", order: 29 }, { key: "family", message: "family", order: 30 }, { key: "person-symbol", message: "people symbols", order: 31 }, { key: "skin-tone", message: "skin tones", order: 32 }, { key: "hair-style", message: "hair styles", order: 33 }, { key: "animal-mammal", message: "mammals", order: 34 }, { key: "animal-bird", message: "birds", order: 35 }, { key: "animal-amphibian", message: "amphibians", order: 36 }, { key: "animal-reptile", message: "reptiles", order: 37 }, { key: "animal-marine", message: "marine life", order: 38 }, { key: "animal-bug", message: "bugs", order: 39 }, { key: "plant-flower", message: "flowers", order: 40 }, { key: "plant-other", message: "other plants", order: 41 }, { key: "food-fruit", message: "fruit", order: 42 }, { key: "food-vegetable", message: "vegetables", order: 43 }, { key: "food-prepared", message: "cooked / prepared", order: 44 }, { key: "food-asian", message: "asian", order: 45 }, { key: "food-marine", message: "seafood", order: 46 }, { key: "food-sweet", message: "sweets & candy", order: 46 }, { key: "drink", message: "drink", order: 47 }, { key: "dishware", message: "dishware", order: 48 }, { key: "place-map", message: "globes & maps", order: 49 }, { key: "place-geographic", message: "geographic locations", order: 50 }, { key: "place-building", message: "buildings", order: 51 }, { key: "place-religious", message: "religious buildings", order: 52 }, { key: "place-other", message: "other places", order: 53 }, { key: "transport-ground", message: "ground transportation", order: 54 }, { key: "transport-water", message: "water transportation", order: 55 }, { key: "transport-air", message: "air transportation", order: 56 }, { key: "hotel", message: "hotel", order: 57 }, { key: "time", message: "time", order: 58 }, { key: "sky-weather", message: "weather", order: 59 }, { key: "event", message: "events & holidays", order: 60 }, { key: "award-medal", message: "award medals", order: 61 }, { key: "sport", message: "sports", order: 62 }, { key: "game", message: "games & hobbies", order: 63 }, { key: "arts-crafts", message: "arts & crafts", order: 64 }, { key: "clothing", message: "clothing", order: 65 }, { key: "sound", message: "sound", order: 66 }, { key: "music", message: "music", order: 67 }, { key: "musical-instrument", message: "musical instruments", order: 68 }, { key: "phone", message: "phone", order: 69 }, { key: "computer", message: "computer", order: 70 }, { key: "light-video", message: "light, film & video", order: 71 }, { key: "book-paper", message: "books & paper", order: 72 }, { key: "money", message: "money", order: 73 }, { key: "mail", message: "mail", order: 74 }, { key: "writing", message: "writing", order: 75 }, { key: "office", message: "office supplies", order: 76 }, { key: "lock", message: "lock & keys", order: 77 }, { key: "tool", message: "tools", order: 78 }, { key: "science", message: "science equipment", order: 79 }, { key: "medical", message: "medical", order: 80 }, { key: "household", message: "household items", order: 81 }, { key: "other-object", message: "other objects", order: 82 }, { key: "transport-sign", message: "transport signs", order: 83 }, { key: "warning", message: "warning symbols", order: 84 }, { key: "arrow", message: "arrows", order: 85 }, { key: "religion", message: "religious symbols", order: 86 }, { key: "zodiac", message: "zodiac signs", order: 87 }, { key: "av-symbol", message: "audio & video symbols", order: 88 }, { key: "gender", message: "gender signs", order: 89 }, { key: "math", message: "math symbols", order: 90 }, { key: "punctuation", message: "punctuation", order: 91 }, { key: "currency", message: "currencies", order: 92 }, { key: "other-symbol", message: "other symbols", order: 93 }, { key: "keycap", message: "keypad characters", order: 94 }, { key: "alphanum", message: "alphanumeric symbols", order: 95 }, { key: "geometric", message: "shapes & colors", order: 96 }, { key: "flag", message: "other flags", order: 97 }, { key: "country-flag", message: "country flags", order: 98 }, { key: "subdivision-flag", message: "subdivision flags", order: 99 }] };
6
6
 
7
+ // src/endpoint.ts
8
+ var OPENEDITOR_EMOJI_DATA_URL = "/api/openeditor/emoji-data";
9
+ var parseOpenEditorEmojiDataPath = (pathname) => {
10
+ const prefix = `${OPENEDITOR_EMOJI_DATA_URL}/`;
11
+ if (!pathname.startsWith(prefix)) return null;
12
+ const segments = pathname.slice(prefix.length).split("/");
13
+ if (segments.length !== 2 || segments.some((segment) => !segment))
14
+ return null;
15
+ try {
16
+ return {
17
+ locale: decodeURIComponent(segments[0] ?? ""),
18
+ file: decodeURIComponent(segments[1] ?? "")
19
+ };
20
+ } catch {
21
+ return null;
22
+ }
23
+ };
24
+
7
25
  // src/data.ts
8
26
  var OPENEDITOR_EMOJI_DATA_LOCALE = "en";
9
27
  var getOpenEditorEmojiData = (locale, file) => {
@@ -12,18 +30,29 @@ var getOpenEditorEmojiData = (locale, file) => {
12
30
  if (file === "messages.json") return messages_default;
13
31
  return void 0;
14
32
  };
15
- var createOpenEditorEmojiDataResponse = (locale, file) => {
33
+ var createOpenEditorEmojiDataResponse = (locale, file, options = {}) => {
16
34
  const emojiData = getOpenEditorEmojiData(locale, file);
35
+ const method = options.method?.toUpperCase();
17
36
  if (emojiData === void 0) {
18
- return Response.json({ error: "Emoji data not found" }, { status: 404 });
37
+ return new Response(
38
+ method === "HEAD" ? null : JSON.stringify({ error: "Emoji data not found" }),
39
+ {
40
+ headers: { "Content-Type": "application/json; charset=utf-8" },
41
+ status: 404
42
+ }
43
+ );
44
+ }
45
+ const headers = {
46
+ "Cache-Control": "public, max-age=86400, stale-while-revalidate=604800",
47
+ "Content-Type": "application/json; charset=utf-8",
48
+ ETag: '"openeditor-emoji-v1"'
49
+ };
50
+ if (method === "HEAD") {
51
+ return new Response(null, { headers });
19
52
  }
20
- return Response.json(emojiData, {
21
- headers: {
22
- "Cache-Control": "public, max-age=86400, stale-while-revalidate=604800"
23
- }
24
- });
53
+ return new Response(JSON.stringify(emojiData), { headers });
25
54
  };
26
55
 
27
- export { OPENEDITOR_EMOJI_DATA_LOCALE, createOpenEditorEmojiDataResponse, getOpenEditorEmojiData };
56
+ export { OPENEDITOR_EMOJI_DATA_LOCALE, OPENEDITOR_EMOJI_DATA_URL, createOpenEditorEmojiDataResponse, getOpenEditorEmojiData, parseOpenEditorEmojiDataPath };
28
57
  //# sourceMappingURL=data.js.map
29
58
  //# sourceMappingURL=data.js.map