@flighthq/textsegment 0.5.1-next.1404.457d1da → 0.5.1-next.1410.b534771
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/package.json +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.1410.b534771](https://github.com/flighthq/flight/tree/b53477179b2672048eb54d134f94ee8af050d130/packages/textsegment)
|
|
17
|
+
- [License](https://github.com/flighthq/flight/blob/b53477179b2672048eb54d134f94ee8af050d130/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"}
|
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.1410.b534771",
|
|
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.1410.b534771",
|
|
42
|
+
"@flighthq/log": "0.5.1-next.1410.b534771",
|
|
43
|
+
"@flighthq/types": "0.5.1-next.1410.b534771"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"typescript": "^5.3.0"
|
|
@@ -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,
|