@flighthq/textsegment 0.5.1-next.1405.69d9356 → 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/enableTextSegmentGuards.d.ts +1 -1
- package/dist/enableTextSegmentGuards.d.ts.map +1 -1
- package/dist/enableTextSegmentGuards.js +2 -2
- package/dist/enableTextSegmentGuards.js.map +1 -1
- package/dist/textSegment.d.ts +3 -3
- package/dist/textSegment.d.ts.map +1 -1
- package/dist/textSegment.js +6 -6
- package/dist/textSegment.js.map +1 -1
- 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/src/textSegmenterBackend.test.ts +3 -3
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,5 +1,5 @@
|
|
|
1
1
|
/** Uninstalls the guard installed by enableTextSegmentGuards. */
|
|
2
2
|
export declare function disableTextSegmentGuards(): void;
|
|
3
|
-
/** Installs an opt-in warning for use of the bundled
|
|
3
|
+
/** Installs an opt-in warning for use of the bundled capability where Intl.Segmenter is absent. */
|
|
4
4
|
export declare function enableTextSegmentGuards(): void;
|
|
5
5
|
//# sourceMappingURL=enableTextSegmentGuards.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableTextSegmentGuards.d.ts","sourceRoot":"","sources":["../src/enableTextSegmentGuards.ts"],"names":[],"mappings":"AAKA,iEAAiE;AACjE,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED,
|
|
1
|
+
{"version":3,"file":"enableTextSegmentGuards.d.ts","sourceRoot":"","sources":["../src/enableTextSegmentGuards.ts"],"names":[],"mappings":"AAKA,iEAAiE;AACjE,wBAAgB,wBAAwB,IAAI,IAAI,CAE/C;AAED,mGAAmG;AACnG,wBAAgB,uBAAuB,IAAI,IAAI,CAE9C"}
|
|
@@ -5,13 +5,13 @@ import { setTextSegmentGuard } from './textSegmentGuards';
|
|
|
5
5
|
export function disableTextSegmentGuards() {
|
|
6
6
|
setTextSegmentGuard(null);
|
|
7
7
|
}
|
|
8
|
-
/** Installs an opt-in warning for use of the bundled
|
|
8
|
+
/** Installs an opt-in warning for use of the bundled capability where Intl.Segmenter is absent. */
|
|
9
9
|
export function enableTextSegmentGuards() {
|
|
10
10
|
setTextSegmentGuard(warnOnMissingIntlSegmenter);
|
|
11
11
|
}
|
|
12
12
|
function warnOnMissingIntlSegmenter() {
|
|
13
13
|
logOnce('textsegment:intl-segmenter-unavailable', LogLevel.Warn, {
|
|
14
|
-
message: 'segmentGraphemes: Intl.Segmenter is unavailable and no replacement
|
|
14
|
+
message: 'segmentGraphemes: Intl.Segmenter is unavailable and no replacement capability was supplied, so segmentation returned no results. Pass a HostTextSegmenterCapability with full Unicode coverage to the operation.',
|
|
15
15
|
}, 'textsegment');
|
|
16
16
|
}
|
|
17
17
|
//# sourceMappingURL=enableTextSegmentGuards.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enableTextSegmentGuards.js","sourceRoot":"","sources":["../src/enableTextSegmentGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,iEAAiE;AACjE,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,
|
|
1
|
+
{"version":3,"file":"enableTextSegmentGuards.js","sourceRoot":"","sources":["../src/enableTextSegmentGuards.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D,iEAAiE;AACjE,MAAM,UAAU,wBAAwB;IACtC,mBAAmB,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,uBAAuB;IACrC,mBAAmB,CAAC,0BAA0B,CAAC,CAAC;AAClD,CAAC;AAED,SAAS,0BAA0B;IACjC,OAAO,CACL,wCAAwC,EACxC,QAAQ,CAAC,IAAI,EACb;QACE,OAAO,EACL,kNAAkN;KACrN,EACD,aAAa,CACd,CAAC;AACJ,CAAC"}
|
package/dist/textSegment.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HostTextSegmenterCapability, TextSegment } from '@flighthq/types/contract';
|
|
2
|
-
export declare function segmentGraphemes(
|
|
3
|
-
export declare function segmentSentences(
|
|
4
|
-
export declare function segmentWords(
|
|
2
|
+
export declare function segmentGraphemes(hostTextSegmenter: Readonly<HostTextSegmenterCapability>, text: string, locale?: string): readonly TextSegment[];
|
|
3
|
+
export declare function segmentSentences(hostTextSegmenter: Readonly<HostTextSegmenterCapability>, text: string, locale?: string): readonly TextSegment[];
|
|
4
|
+
export declare function segmentWords(hostTextSegmenter: Readonly<HostTextSegmenterCapability>, text: string, locale?: string): readonly TextSegment[];
|
|
5
5
|
//# sourceMappingURL=textSegment.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textSegment.d.ts","sourceRoot":"","sources":["../src/textSegment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEzF,wBAAgB,gBAAgB,CAC9B,
|
|
1
|
+
{"version":3,"file":"textSegment.d.ts","sourceRoot":"","sources":["../src/textSegment.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAEzF,wBAAgB,gBAAgB,CAC9B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,SAAS,WAAW,EAAE,CAExB;AAED,wBAAgB,gBAAgB,CAC9B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,SAAS,WAAW,EAAE,CAExB;AAED,wBAAgB,YAAY,CAC1B,iBAAiB,EAAE,QAAQ,CAAC,2BAA2B,CAAC,EACxD,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,GACd,SAAS,WAAW,EAAE,CAExB"}
|
package/dist/textSegment.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export function segmentGraphemes(
|
|
2
|
-
return
|
|
1
|
+
export function segmentGraphemes(hostTextSegmenter, text, locale) {
|
|
2
|
+
return hostTextSegmenter.segment(text, 'grapheme', locale);
|
|
3
3
|
}
|
|
4
|
-
export function segmentSentences(
|
|
5
|
-
return
|
|
4
|
+
export function segmentSentences(hostTextSegmenter, text, locale) {
|
|
5
|
+
return hostTextSegmenter.segment(text, 'sentence', locale);
|
|
6
6
|
}
|
|
7
|
-
export function segmentWords(
|
|
8
|
-
return
|
|
7
|
+
export function segmentWords(hostTextSegmenter, text, locale) {
|
|
8
|
+
return hostTextSegmenter.segment(text, 'word', locale);
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=textSegment.js.map
|
package/dist/textSegment.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textSegment.js","sourceRoot":"","sources":["../src/textSegment.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAC9B,
|
|
1
|
+
{"version":3,"file":"textSegment.js","sourceRoot":"","sources":["../src/textSegment.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,gBAAgB,CAC9B,iBAAwD,EACxD,IAAY,EACZ,MAAe;IAEf,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,gBAAgB,CAC9B,iBAAwD,EACxD,IAAY,EACZ,MAAe;IAEf,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AAC7D,CAAC;AAED,MAAM,UAAU,YAAY,CAC1B,iBAAwD,EACxD,IAAY,EACZ,MAAe;IAEf,OAAO,iBAAiB,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AACzD,CAAC"}
|
|
@@ -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":"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"}
|
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
|
});
|
|
@@ -62,7 +62,7 @@ describe('createWebTextSegmenterBackend', () => {
|
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
describe('explainTextSegmenterBackend', () => {
|
|
65
|
-
it('reports the bundled Intl
|
|
65
|
+
it('reports the bundled Intl capability as available', () => {
|
|
66
66
|
expect(explainTextSegmenterBackend(webTextSegmenterBackend)).toEqual({
|
|
67
67
|
available: true,
|
|
68
68
|
backend: 'web-intl',
|
|
@@ -70,7 +70,7 @@ describe('explainTextSegmenterBackend', () => {
|
|
|
70
70
|
});
|
|
71
71
|
});
|
|
72
72
|
|
|
73
|
-
it('identifies a custom
|
|
73
|
+
it('identifies a custom capability independently of Intl availability', () => {
|
|
74
74
|
expect(explainTextSegmenterBackend(recordingBackend())).toEqual({
|
|
75
75
|
available: true,
|
|
76
76
|
backend: 'custom',
|
|
@@ -78,7 +78,7 @@ describe('explainTextSegmenterBackend', () => {
|
|
|
78
78
|
});
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
it('reports the bundled
|
|
81
|
+
it('reports the bundled capability unavailable when the runtime primitive is absent', () => {
|
|
82
82
|
vi.stubGlobal('Intl', { Segmenter: undefined });
|
|
83
83
|
expect(explainTextSegmenterBackend(webTextSegmenterBackend)).toEqual({
|
|
84
84
|
available: false,
|