@flighthq/textsegment 0.5.1-edge.1410.b534771 β†’ 0.5.1-edge.1467.7e2fc7d

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
@@ -13,5 +13,5 @@ Import the supported application-facing API from `@flighthq/textsegment`. The `@
13
13
  This package is part of the locked-version Flight SDK graph. Applications may instead install and import `@flighthq/sdk` when package-level tree shaking is sufficient.
14
14
 
15
15
  - [Flight project](https://github.com/flighthq/flight)
16
- - [Source for @flighthq/textsegment@0.5.1-edge.1410.b534771](https://github.com/flighthq/flight/tree/b53477179b2672048eb54d134f94ee8af050d130/packages/textsegment)
17
- - [License](https://github.com/flighthq/flight/blob/b53477179b2672048eb54d134f94ee8af050d130/LICENSE.md)
16
+ - [Source for @flighthq/textsegment@0.5.1-edge.1467.7e2fc7d](https://github.com/flighthq/flight/tree/7e2fc7df5378313ceaf21ba8d6ef39cc18a6f4ad/packages/textsegment)
17
+ - [License](https://github.com/flighthq/flight/blob/7e2fc7df5378313ceaf21ba8d6ef39cc18a6f4ad/LICENSE.md)
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { createDefaultTextSegmenterBackend, disableTextSegmentGuards, enableTextSegmentGuards, explainTextSegmenterBackend, getNextGraphemeBoundary, getNextSentenceBoundary, getNextWordBoundary, getPreviousGraphemeBoundary, getPreviousSentenceBoundary, getPreviousWordBoundary, getWordRangeAt, segmentGraphemes, segmentSentences, segmentWords, webTextSegmenterBackend, } from './contract';
1
+ export { disableTextSegmentGuards, enableTextSegmentGuards, explainTextSegmenterBackend, getNextGraphemeBoundary, getNextSentenceBoundary, getNextWordBoundary, getPreviousGraphemeBoundary, getPreviousSentenceBoundary, getPreviousWordBoundary, getWordRangeAt, segmentGraphemes, segmentSentences, segmentWords, webTextSegmenterBackend, } from './contract';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export { createDefaultTextSegmenterBackend, disableTextSegmentGuards, enableTextSegmentGuards, explainTextSegmenterBackend, getNextGraphemeBoundary, getNextSentenceBoundary, getNextWordBoundary, getPreviousGraphemeBoundary, getPreviousSentenceBoundary, getPreviousWordBoundary, getWordRangeAt, segmentGraphemes, segmentSentences, segmentWords, webTextSegmenterBackend, } from './contract';
1
+ export { disableTextSegmentGuards, enableTextSegmentGuards, explainTextSegmenterBackend, getNextGraphemeBoundary, getNextSentenceBoundary, getNextWordBoundary, getPreviousGraphemeBoundary, getPreviousSentenceBoundary, getPreviousWordBoundary, getWordRangeAt, segmentGraphemes, segmentSentences, segmentWords, webTextSegmenterBackend, } from './contract';
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,EACjC,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,2BAA2B,EAC3B,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,2BAA2B,EAC3B,2BAA2B,EAC3B,uBAAuB,EACvB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,uBAAuB,GACxB,MAAM,YAAY,CAAC"}
@@ -1,8 +1,5 @@
1
- import type { EntityConstruction, HostTextSegmenterCapability, TextSegmenterBackendExplanation } from '@flighthq/types/contract';
2
- export declare function createDefaultTextSegmenterBackend(): HostTextSegmenterCapability;
1
+ import type { HostTextSegmenterCapability, TextSegmenterExplanation } from '@flighthq/types/contract';
3
2
  export declare const webTextSegmenterBackend: HostTextSegmenterCapability;
4
- export declare function createWebTextSegmenterBackend(): HostTextSegmenterCapability;
5
3
  /** Describes which provider an operation would use and whether Intl.Segmenter is present. */
6
- export declare function explainTextSegmenterBackend(textSegmenter: Readonly<HostTextSegmenterCapability>): TextSegmenterBackendExplanation;
7
- export declare function initializeWebTextSegmenterBackend(out: EntityConstruction<HostTextSegmenterCapability>): void;
4
+ export declare function explainTextSegmenterBackend(textSegmenter: Readonly<HostTextSegmenterCapability>): TextSegmenterExplanation;
8
5
  //# sourceMappingURL=textSegmenterBackend.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"textSegmenterBackend.d.ts","sourceRoot":"","sources":["../src/textSegmenterBackend.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,kBAAkB,EAClB,2BAA2B,EAG3B,+BAA+B,EAChC,MAAM,0BAA0B,CAAC;AAIlC,wBAAgB,iCAAiC,IAAI,2BAA2B,CAE/E;AAID,eAAO,MAAM,uBAAuB,EAAE,2BAA6D,CAAC;AAQpG,wBAAgB,6BAA6B,IAAI,2BAA2B,CAI3E;AAED,6FAA6F;AAC7F,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,QAAQ,CAAC,2BAA2B,CAAC,GACnD,+BAA+B,CAQjC;AAED,wBAAgB,iCAAiC,CAAC,GAAG,EAAE,kBAAkB,CAAC,2BAA2B,CAAC,GAAG,IAAI,CAE5G"}
1
+ {"version":3,"file":"textSegmenterBackend.d.ts","sourceRoot":"","sources":["../src/textSegmenterBackend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,2BAA2B,EAG3B,wBAAwB,EACzB,MAAM,0BAA0B,CAAC;AAMlC,eAAO,MAAM,uBAAuB,EAAE,2BAA6D,CAAC;AAcpG,6FAA6F;AAC7F,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,QAAQ,CAAC,2BAA2B,CAAC,GACnD,wBAAwB,CAQ1B"}
@@ -1,8 +1,4 @@
1
- import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
1
  import { reportTextSegmenterUnavailable } from './textSegmentGuards';
3
- export function createDefaultTextSegmenterBackend() {
4
- return createWebTextSegmenterBackend();
5
- }
6
2
  // Stable bundled web provider. Hosts can import this directly when composing their explicit
7
3
  // capability object.
8
4
  export const webTextSegmenterBackend = createWebTextSegmenterBackend();
@@ -12,10 +8,10 @@ export const webTextSegmenterBackend = createWebTextSegmenterBackend();
12
8
  // expensive relative to a single segment() call. Where Intl.Segmenter is absent (an old or headless
13
9
  // engine), segment() returns [] rather than throwing; compose a from-scratch UAX #29 backend into
14
10
  // the host for those environments.
15
- export function createWebTextSegmenterBackend() {
16
- const out = allocateEntity();
11
+ function createWebTextSegmenterBackend() {
12
+ const out = {};
17
13
  initializeWebTextSegmenterBackend(out);
18
- return finishEntity(out);
14
+ return out;
19
15
  }
20
16
  /** Describes which provider an operation would use and whether Intl.Segmenter is present. */
21
17
  export function explainTextSegmenterBackend(textSegmenter) {
@@ -27,7 +23,7 @@ export function explainTextSegmenterBackend(textSegmenter) {
27
23
  intlSegmenterAvailable,
28
24
  };
29
25
  }
30
- export function initializeWebTextSegmenterBackend(out) {
26
+ function initializeWebTextSegmenterBackend(out) {
31
27
  out.segment = segmentWithIntlSegmenter;
32
28
  }
33
29
  // Cached Intl.Segmenter instances keyed by `locale|granularity`. A Map preserves insertion order, so
@@ -1 +1 @@
1
- {"version":3,"file":"textSegmenterBackend.js","sourceRoot":"","sources":["../src/textSegmenterBackend.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AASzE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qBAAqB,CAAC;AAErE,MAAM,UAAU,iCAAiC;IAC/C,OAAO,6BAA6B,EAAE,CAAC;AACzC,CAAC;AAED,4FAA4F;AAC5F,qBAAqB;AACrB,MAAM,CAAC,MAAM,uBAAuB,GAAgC,6BAA6B,EAAE,CAAC;AAEpG,gGAAgG;AAChG,gGAAgG;AAChG,mGAAmG;AACnG,oGAAoG;AACpG,kGAAkG;AAClG,mCAAmC;AACnC,MAAM,UAAU,6BAA6B;IAC3C,MAAM,GAAG,GAAG,cAAc,EAA+B,CAAC;IAC1D,iCAAiC,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC;AAED,6FAA6F;AAC7F,MAAM,UAAU,2BAA2B,CACzC,aAAoD;IAEpD,MAAM,GAAG,GAAG,aAAa,KAAK,uBAAuB,CAAC;IACtD,MAAM,sBAAsB,GAAG,gBAAgB,EAAE,CAAC;IAClD,OAAO;QACL,SAAS,EAAE,CAAC,GAAG,IAAI,sBAAsB;QACzC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ;QACpC,sBAAsB;KACvB,CAAC;AACJ,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IAAI,CAAC,SAAS,KAAK,WAAW,CAAC;AAC9E,CAAC;AAED,SAAS,wBAAwB,CAC/B,IAAY,EACZ,WAAmC,EACnC,MAAe;IAEf,MAAM,SAAS,GAAG,kBAAkB,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAC1D,IAAI,SAAS,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC;IAElC,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,MAAM,iBAAiB,GAAG,WAAW,KAAK,MAAM,CAAC;IACjD,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,MAAM,MAAM,GAAgB,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;QAC5F,4EAA4E;QAC5E,IAAI,iBAAiB;YAAE,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,KAAK,CAAC;QACpE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flighthq/textsegment",
3
- "version": "0.5.1-edge.1410.b534771",
3
+ "version": "0.5.1-edge.1467.7e2fc7d",
4
4
  "author": "Joshua Granick and other contributors",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -38,9 +38,9 @@
38
38
  "clean:dist": "tsx ../../scripts/clean-package-dist.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@flighthq/entity": "0.5.1-edge.1410.b534771",
42
- "@flighthq/log": "0.5.1-edge.1410.b534771",
43
- "@flighthq/types": "0.5.1-edge.1410.b534771"
41
+ "@flighthq/entity": "0.5.1-edge.1467.7e2fc7d",
42
+ "@flighthq/log": "0.5.1-edge.1467.7e2fc7d",
43
+ "@flighthq/types": "0.5.1-edge.1467.7e2fc7d"
44
44
  },
45
45
  "devDependencies": {
46
46
  "typescript": "^5.3.0"
@@ -4,9 +4,9 @@ import { vi } from 'vitest';
4
4
 
5
5
  import { disableTextSegmentGuards, enableTextSegmentGuards } from './enableTextSegmentGuards';
6
6
  import { segmentGraphemes } from './textSegment';
7
- import { createDefaultTextSegmenterBackend } from './textSegmenterBackend';
7
+ import { webTextSegmenterBackend } from './textSegmenterBackend';
8
8
 
9
- const backend = createDefaultTextSegmenterBackend();
9
+ const backend = webTextSegmenterBackend;
10
10
 
11
11
  let entries: LogEntry[];
12
12
 
@@ -2,9 +2,9 @@ import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
2
2
  import type { HostTextSegmenterCapability, TextSegment, TextSegmentGranularity } from '@flighthq/types/contract';
3
3
 
4
4
  import { segmentGraphemes, segmentSentences, segmentWords } from './textSegment';
5
- import { createDefaultTextSegmenterBackend } from './textSegmenterBackend';
5
+ import { webTextSegmenterBackend } from './textSegmenterBackend';
6
6
 
7
- const backend = createDefaultTextSegmenterBackend();
7
+ const backend = webTextSegmenterBackend;
8
8
 
9
9
  describe('segmentGraphemes', () => {
10
10
  it('isolates callers that interleave different explicit hosts', () => {
@@ -29,20 +29,20 @@ describe('segmentGraphemes', () => {
29
29
 
30
30
  it('threads the locale argument to the active backend', () => {
31
31
  let seenLocale: string | undefined = 'unset';
32
- const fake = allocateEntity<HostTextSegmenterCapability>();
32
+ const fake = {} as HostTextSegmenterCapability;
33
33
  fake.segment = (text: string, _granularity: TextSegmentGranularity, locale?: string): readonly TextSegment[] => {
34
34
  seenLocale = locale;
35
35
  return [{ start: 0, end: text.length, text }];
36
36
  };
37
- segmentGraphemes(finishEntity(fake), 'hi', 'de-DE');
37
+ segmentGraphemes(fake, 'hi', 'de-DE');
38
38
  expect(seenLocale).toBe('de-DE');
39
39
  });
40
40
  });
41
41
 
42
42
  function taggingBackend(tag: string): HostTextSegmenterCapability {
43
- const out = allocateEntity<HostTextSegmenterCapability>();
43
+ const out = {} as HostTextSegmenterCapability;
44
44
  out.segment = () => [{ start: 0, end: tag.length, text: tag }];
45
- return finishEntity(out);
45
+ return out;
46
46
  }
47
47
 
48
48
  describe('segmentSentences', () => {
@@ -11,9 +11,9 @@ import {
11
11
  getPreviousWordBoundary,
12
12
  getWordRangeAt,
13
13
  } from './textSegmentBoundary';
14
- import { createDefaultTextSegmenterBackend, webTextSegmenterBackend } from './textSegmenterBackend';
14
+ import { webTextSegmenterBackend } from './textSegmenterBackend';
15
15
 
16
- const backend = createDefaultTextSegmenterBackend();
16
+ const backend = webTextSegmenterBackend;
17
17
 
18
18
  // A ZWJ family emoji is a single grapheme cluster spanning several UTF-16 code units.
19
19
  const FAMILY = 'πŸ‘¨β€πŸ‘©β€πŸ‘§';
@@ -102,9 +102,9 @@ describe('getPreviousWordBoundary', () => {
102
102
 
103
103
  describe('getWordRangeAt', () => {
104
104
  it('threads an explicit host through the boundary helper', () => {
105
- const explicit = allocateEntity<HostTextSegmenterCapability>();
105
+ const explicit = {} as HostTextSegmenterCapability;
106
106
  explicit.segment = (text: string) => [{ start: 0, end: text.length, text, isWordLike: true }];
107
- expect(getWordRangeAt(finishEntity(explicit), 'word', 1)).toEqual({ start: 0, end: 4 });
107
+ expect(getWordRangeAt(explicit, 'word', 1)).toEqual({ start: 0, end: 4 });
108
108
  });
109
109
 
110
110
  it('returns the word range under an index', () => {
@@ -125,12 +125,12 @@ describe('getWordRangeAt', () => {
125
125
 
126
126
  it('threads the locale to the active backend', () => {
127
127
  let seenLocale: string | undefined = 'unset';
128
- const localeBackend = allocateEntity<HostTextSegmenterCapability>();
128
+ const localeBackend = {} as HostTextSegmenterCapability;
129
129
  localeBackend.segment = (text: string, _granularity: string, locale: string) => {
130
130
  seenLocale = locale;
131
131
  return [{ start: 0, end: text.length, text, isWordLike: true }];
132
132
  };
133
- getWordRangeAt(finishEntity(localeBackend), 'word', 1, 'ja-JP');
133
+ getWordRangeAt(localeBackend, 'word', 1, 'ja-JP');
134
134
  expect(seenLocale).toBe('ja-JP');
135
135
  });
136
136
  });
@@ -1,9 +1,9 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
3
  import { segmentGraphemes } from './textSegment';
4
- import { createDefaultTextSegmenterBackend } from './textSegmenterBackend';
4
+ import { webTextSegmenterBackend } from './textSegmenterBackend';
5
5
 
6
- const backend = createDefaultTextSegmenterBackend();
6
+ const backend = webTextSegmenterBackend;
7
7
 
8
8
  const graphemeFixtures: ReadonlyArray<{ clusters: string[]; text: string }> = [
9
9
  { text: 'πŸ‡ΊπŸ‡ΈπŸ‡¨πŸ‡¦', clusters: ['πŸ‡ΊπŸ‡Έ', 'πŸ‡¨πŸ‡¦'] },
@@ -3,13 +3,7 @@ import type { EntityRuntimeKey } from '@flighthq/types/contract';
3
3
  import type { HostTextSegmenterCapability, TextSegment, TextSegmentGranularity } from '@flighthq/types/contract';
4
4
  import { vi } from 'vitest';
5
5
 
6
- import {
7
- createDefaultTextSegmenterBackend,
8
- createWebTextSegmenterBackend,
9
- explainTextSegmenterBackend,
10
- initializeWebTextSegmenterBackend,
11
- webTextSegmenterBackend,
12
- } from './textSegmenterBackend';
6
+ import { explainTextSegmenterBackend, webTextSegmenterBackend } from './textSegmenterBackend';
13
7
 
14
8
  interface RecordingBackend extends HostTextSegmenterCapability {
15
9
  calls: Array<{ text: string; granularity: TextSegmentGranularity; locale: string | undefined }>;
@@ -30,37 +24,6 @@ afterEach(() => {
30
24
  vi.unstubAllGlobals();
31
25
  });
32
26
 
33
- describe('createDefaultTextSegmenterBackend', () => {
34
- it('returns a web segmenter backend', () => {
35
- const backend = createDefaultTextSegmenterBackend();
36
- expect(backend.segment('ab', 'grapheme').length).toBe(2);
37
- });
38
- });
39
-
40
- describe('createWebTextSegmenterBackend', () => {
41
- it('segments a ZWJ family emoji as a single grapheme', () => {
42
- const segments = createWebTextSegmenterBackend().segment('aπŸ‘¨β€πŸ‘©β€πŸ‘§b', 'grapheme');
43
- expect(segments.map((s) => s.text)).toEqual(['a', 'πŸ‘¨β€πŸ‘©β€πŸ‘§', 'b']);
44
- });
45
-
46
- it('reports isWordLike for word granularity and omits it otherwise', () => {
47
- const backend = createWebTextSegmenterBackend();
48
- const words = backend.segment('Hi there', 'word');
49
- expect(words.every((s) => typeof s.isWordLike === 'boolean')).toBe(true);
50
- const graphemes = backend.segment('Hi', 'grapheme');
51
- expect(graphemes.every((s) => s.isWordLike === undefined)).toBe(true);
52
- });
53
-
54
- it('produces gap-free start/end offsets covering the whole string', () => {
55
- const segments = createWebTextSegmenterBackend().segment('abc', 'grapheme');
56
- expect(segments).toEqual([
57
- { start: 0, end: 1, text: 'a' },
58
- { start: 1, end: 2, text: 'b' },
59
- { start: 2, end: 3, text: 'c' },
60
- ]);
61
- });
62
- });
63
-
64
27
  describe('explainTextSegmenterBackend', () => {
65
28
  it('reports the bundled Intl capability as available', () => {
66
29
  expect(explainTextSegmenterBackend(webTextSegmenterBackend)).toEqual({
@@ -88,12 +51,6 @@ describe('explainTextSegmenterBackend', () => {
88
51
  });
89
52
  });
90
53
 
91
- describe('initializeWebTextSegmenterBackend', () => {
92
- it('is the construction initializer of createWebTextSegmenterBackend', () => {
93
- expect(typeof initializeWebTextSegmenterBackend).toBe('function');
94
- });
95
- });
96
-
97
54
  describe('webTextSegmenterBackend', () => {
98
55
  it('provides the stable bundled Intl fallback', () => {
99
56
  expect(webTextSegmenterBackend.segment('aπŸ‘¨β€πŸ‘©β€πŸ‘§b', 'grapheme').map((segment) => segment.text)).toEqual([
@@ -102,4 +59,25 @@ describe('webTextSegmenterBackend', () => {
102
59
  'b',
103
60
  ]);
104
61
  });
62
+
63
+ it('segments a ZWJ family emoji as a single grapheme', () => {
64
+ const segments = webTextSegmenterBackend.segment('aπŸ‘¨β€πŸ‘©β€πŸ‘§b', 'grapheme');
65
+ expect(segments.map((s: TextSegment) => s.text)).toEqual(['a', 'πŸ‘¨β€πŸ‘©β€πŸ‘§', 'b']);
66
+ });
67
+
68
+ it('reports isWordLike for word granularity and omits it otherwise', () => {
69
+ const words = webTextSegmenterBackend.segment('Hi there', 'word');
70
+ expect(words.every((s: TextSegment) => typeof s.isWordLike === 'boolean')).toBe(true);
71
+ const graphemes = webTextSegmenterBackend.segment('Hi', 'grapheme');
72
+ expect(graphemes.every((s: TextSegment) => s.isWordLike === undefined)).toBe(true);
73
+ });
74
+
75
+ it('produces gap-free start/end offsets covering the whole string', () => {
76
+ const segments = webTextSegmenterBackend.segment('abc', 'grapheme');
77
+ expect(segments).toEqual([
78
+ { start: 0, end: 1, text: 'a' },
79
+ { start: 1, end: 2, text: 'b' },
80
+ { start: 2, end: 3, text: 'c' },
81
+ ]);
82
+ });
105
83
  });