@flighthq/textsegment 0.5.1-next.1410.b534771 → 0.5.1-next.1450.5738463
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 +2 -2
- package/dist/textSegmenterBackend.d.ts +2 -2
- package/dist/textSegmenterBackend.d.ts.map +1 -1
- package/dist/textSegmenterBackend.js +2 -3
- package/dist/textSegmenterBackend.js.map +1 -1
- package/package.json +4 -4
- package/src/textSegment.test.ts +4 -4
- package/src/textSegmentBoundary.test.ts +4 -4
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-next.
|
|
17
|
-
- [License](https://github.com/flighthq/flight/blob/
|
|
16
|
+
- [Source for @flighthq/textsegment@0.5.1-next.1450.5738463](https://github.com/flighthq/flight/tree/5738463479690d1fd0a89839d92fcc6164a3d23b/packages/textsegment)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/5738463479690d1fd0a89839d92fcc6164a3d23b/LICENSE.md)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { HostTextSegmenterCapability, TextSegmenterBackendExplanation } from '@flighthq/types/contract';
|
|
2
2
|
export declare function createDefaultTextSegmenterBackend(): HostTextSegmenterCapability;
|
|
3
3
|
export declare const webTextSegmenterBackend: HostTextSegmenterCapability;
|
|
4
4
|
export declare function createWebTextSegmenterBackend(): HostTextSegmenterCapability;
|
|
5
5
|
/** Describes which provider an operation would use and whether Intl.Segmenter is present. */
|
|
6
6
|
export declare function explainTextSegmenterBackend(textSegmenter: Readonly<HostTextSegmenterCapability>): TextSegmenterBackendExplanation;
|
|
7
|
-
export declare function initializeWebTextSegmenterBackend(out:
|
|
7
|
+
export declare function initializeWebTextSegmenterBackend(out: HostTextSegmenterCapability): void;
|
|
8
8
|
//# sourceMappingURL=textSegmenterBackend.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textSegmenterBackend.d.ts","sourceRoot":"","sources":["../src/textSegmenterBackend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"textSegmenterBackend.d.ts","sourceRoot":"","sources":["../src/textSegmenterBackend.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,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,2BAA2B,GAAG,IAAI,CAExF"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { allocateEntity, finishEntity } from '@flighthq/entity/contract';
|
|
2
1
|
import { reportTextSegmenterUnavailable } from './textSegmentGuards';
|
|
3
2
|
export function createDefaultTextSegmenterBackend() {
|
|
4
3
|
return createWebTextSegmenterBackend();
|
|
@@ -13,9 +12,9 @@ export const webTextSegmenterBackend = createWebTextSegmenterBackend();
|
|
|
13
12
|
// engine), segment() returns [] rather than throwing; compose a from-scratch UAX #29 backend into
|
|
14
13
|
// the host for those environments.
|
|
15
14
|
export function createWebTextSegmenterBackend() {
|
|
16
|
-
const out =
|
|
15
|
+
const out = {};
|
|
17
16
|
initializeWebTextSegmenterBackend(out);
|
|
18
|
-
return
|
|
17
|
+
return out;
|
|
19
18
|
}
|
|
20
19
|
/** Describes which provider an operation would use and whether Intl.Segmenter is present. */
|
|
21
20
|
export function explainTextSegmenterBackend(textSegmenter) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textSegmenterBackend.js","sourceRoot":"","sources":["../src/textSegmenterBackend.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"textSegmenterBackend.js","sourceRoot":"","sources":["../src/textSegmenterBackend.ts"],"names":[],"mappings":"AAOA,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,EAAiC,CAAC;IAC9C,iCAAiC,CAAC,GAAG,CAAC,CAAC;IACvC,OAAO,GAAG,CAAC;AACb,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,CAAC;AAED,MAAM,UAAU,iCAAiC,CAAC,GAAgC;IAChF,GAAG,CAAC,OAAO,GAAG,wBAAwB,CAAC;AACzC,CAAC;AAED,qGAAqG;AACrG,oGAAoG;AACpG,mDAAmD;AACnD,MAAM,eAAe,GAAG,IAAI,GAAG,EAA0B,CAAC;AAC1D,MAAM,uBAAuB,GAAG,EAAE,CAAC;A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E,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-next.
|
|
3
|
+
"version": "0.5.1-next.1450.5738463",
|
|
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-next.
|
|
42
|
-
"@flighthq/log": "0.5.1-next.
|
|
43
|
-
"@flighthq/types": "0.5.1-next.
|
|
41
|
+
"@flighthq/entity": "0.5.1-next.1450.5738463",
|
|
42
|
+
"@flighthq/log": "0.5.1-next.1450.5738463",
|
|
43
|
+
"@flighthq/types": "0.5.1-next.1450.5738463"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
package/src/textSegment.test.ts
CHANGED
|
@@ -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 =
|
|
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(
|
|
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 =
|
|
43
|
+
const out = {} as HostTextSegmenterCapability;
|
|
44
44
|
out.segment = () => [{ start: 0, end: tag.length, text: tag }];
|
|
45
|
-
return
|
|
45
|
+
return out;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
describe('segmentSentences', () => {
|
|
@@ -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 =
|
|
105
|
+
const explicit = {} as HostTextSegmenterCapability;
|
|
106
106
|
explicit.segment = (text: string) => [{ start: 0, end: text.length, text, isWordLike: true }];
|
|
107
|
-
expect(getWordRangeAt(
|
|
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 =
|
|
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(
|
|
133
|
+
getWordRangeAt(localeBackend, 'word', 1, 'ja-JP');
|
|
134
134
|
expect(seenLocale).toBe('ja-JP');
|
|
135
135
|
});
|
|
136
136
|
});
|