react-native-transformer-text-input 0.4.0 → 0.4.1
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.
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
import { Platform } from 'react-native';
|
|
3
4
|
export class Transformer {
|
|
4
5
|
constructor(worklet) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
// On web there is no UI runtime: the web TransformerTextInput runs the
|
|
7
|
+
// worklet synchronously in JS, so it doesn't need to be compiled by the
|
|
8
|
+
// worklets plugin. Native runs it on the UI thread and requires a real
|
|
9
|
+
// worklet, so keep enforcing the directive there.
|
|
10
|
+
if (Platform.OS !== 'web') {
|
|
11
|
+
const workletHash = worklet.__workletHash;
|
|
12
|
+
if (workletHash == null) {
|
|
13
|
+
throw new Error('[rntti] Transformer must be a worklet. Did you forget to add the "worklet" directive?');
|
|
14
|
+
}
|
|
8
15
|
}
|
|
9
16
|
this._worklet = worklet;
|
|
10
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Transformer","constructor","worklet","workletHash","__workletHash","Error","_worklet"],"sourceRoot":"../../src","sources":["Transformer.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"names":["Platform","Transformer","constructor","worklet","OS","workletHash","__workletHash","Error","_worklet"],"sourceRoot":"../../src","sources":["Transformer.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAiBvC,OAAO,MAAMC,WAAW,CAAC;EAGvBC,WAAWA,CAACC,OAA2B,EAAE;IACvC;IACA;IACA;IACA;IACA,IAAIH,QAAQ,CAACI,EAAE,KAAK,KAAK,EAAE;MACzB,MAAMC,WAAW,GAAIF,OAAO,CAAgCG,aAAa;MACzE,IAAID,WAAW,IAAI,IAAI,EAAE;QACvB,MAAM,IAAIE,KAAK,CACb,uFACF,CAAC;MACH;IACF;IACA,IAAI,CAACC,QAAQ,GAAGL,OAAO;EACzB;EAEA,IAAIA,OAAOA,CAAA,EAAG;IACZ,OAAO,IAAI,CAACK,QAAQ;EACtB;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Transformer.d.ts","sourceRoot":"","sources":["../../../src/Transformer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Transformer.d.ts","sourceRoot":"","sources":["../../../src/Transformer.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE;IACvC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,SAAS,CAAC;IACrB,iBAAiB,EAAE,SAAS,CAAC;CAC9B,KACG;IACE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;CAC9B,GACD,IAAI,GACJ,SAAS,CAAC;AAEd,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;gBAElC,OAAO,EAAE,kBAAkB;IAgBvC,IAAI,OAAO,uBAEV;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-transformer-text-input",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "TextInput component that allows transforming text synchronously with a worklet",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
package/src/Transformer.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
|
|
1
3
|
export type Selection = { start: number; end: number };
|
|
2
4
|
|
|
3
5
|
export type TransformerWorklet = (input: {
|
|
@@ -17,11 +19,17 @@ export class Transformer {
|
|
|
17
19
|
private readonly _worklet: TransformerWorklet;
|
|
18
20
|
|
|
19
21
|
constructor(worklet: TransformerWorklet) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
// On web there is no UI runtime: the web TransformerTextInput runs the
|
|
23
|
+
// worklet synchronously in JS, so it doesn't need to be compiled by the
|
|
24
|
+
// worklets plugin. Native runs it on the UI thread and requires a real
|
|
25
|
+
// worklet, so keep enforcing the directive there.
|
|
26
|
+
if (Platform.OS !== 'web') {
|
|
27
|
+
const workletHash = (worklet as { __workletHash?: number }).__workletHash;
|
|
28
|
+
if (workletHash == null) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
'[rntti] Transformer must be a worklet. Did you forget to add the "worklet" directive?',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
25
33
|
}
|
|
26
34
|
this._worklet = worklet;
|
|
27
35
|
}
|