@vm75/inditrans 0.3.5 → 0.3.6

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/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.6
2
+
3
+ - Refactored nodejs interface. Updated readme.
4
+
1
5
  ## 0.3.5
2
6
 
3
7
  - Fixed wasm, tests and nodejs support
package/README.md CHANGED
@@ -2,45 +2,58 @@
2
2
 
3
3
  An experimental transliterator library for some [Indic/Brahmi](https://en.wikipedia.org/wiki/Brahmic_scripts) scripts.
4
4
 
5
- * Available on all platforms. Uses ffi for non-Web platforms and wasm for Web.
6
- * Self-contained and performant.
7
- * Supports [vedic accents](https://en.wikipedia.org/wiki/Vedic_accent). Useful for vedic scriptures.
5
+ - Self-contained and performant. Uses wasm.
6
+ - Supports [vedic accents](https://en.wikipedia.org/wiki/Vedic_accent). Useful for vedic scriptures.
7
+ - Smart transliteration to and from Tamil. Supports tamil superscript.
8
8
 
9
9
  References:
10
+
10
11
  - [inditrans on Github](https://github.com/vm75/inditrans)
11
- - [inditrans on pub.dev](https://pub.dev/packages/inditrans)
12
+ - [inditrans for Flutter](https://pub.dev/packages/inditrans)
13
+ - [inditrans for nodejs](https://www.npmjs.com/package/@vm75/inditrans)
12
14
 
13
15
  ## Supported scripts
14
- * Brahmi scripts:
15
- * bengali
16
- * devanagari
17
- * gujarati
18
- * gurmukhi
19
- * kannada
20
- * malayalam
21
- * oriya
22
- * tamil
23
- * telugu
24
- * Roman scripts
25
- * iast (https://en.wikipedia.org/wiki/International_Alphabet_of_Sanskrit_Transliteration)
26
- * ipa (https://en.wikipedia.org/wiki/International_Phonetic_Alphabet)
27
- * iso 15919 (https://en.wikipedia.org/wiki/ISO_15919)
28
- * itrans (https://en.wikipedia.org/wiki/ITRANS)
29
- * readablelatin (custom)
16
+
17
+ - Brahmi scripts:
18
+ - assamese
19
+ - bengali
20
+ - devanagari
21
+ - gujarati
22
+ - gurmukhi
23
+ - kannada
24
+ - malayalam
25
+ - oriya
26
+ - sinhala
27
+ - tamil
28
+ - telugu
29
+ - Roman scripts
30
+ - iast (https://en.wikipedia.org/wiki/International_Alphabet_of_Sanskrit_Transliteration)
31
+ - ipa (https://en.wikipedia.org/wiki/International_Phonetic_Alphabet)
32
+ - iso 15919 (https://en.wikipedia.org/wiki/ISO_15919)
33
+ - itrans (https://en.wikipedia.org/wiki/ITRANS)
34
+ - readablelatin (easy to read latin script)
35
+
36
+ ## Installation
37
+
38
+ ```
39
+ npm install @vm75/inditrans
40
+ ```
30
41
 
31
42
  ## Usage example
32
- ```dart
33
- import 'package:inditrans/inditrans.dart' as inditrans;
34
43
 
35
- Future<void> main() async {
44
+ ```javascript
45
+ import * as inditrans from 'inditrans';
46
+
47
+ async function test() {
36
48
  // Init needs to complete before Inditrans could be used
37
- await inditrans.init();
49
+ await indiTrans.init();
38
50
 
39
- final result = inditrans.transliterate(
40
- "श्री॒ गु॒रु॒भ्यो नमः॒ । ह॒रिः॒ ओ३म् ॥",
41
- inditrans.Script.devanagari,
42
- inditrans.Script.tamil,
43
- inditrans.Options.IgnoreVedicAccents + inditrans.Options.TamilSuperscripted);
51
+ result = inditrans.transliterate(
52
+ "श्री॒ गु॒रु॒भ्यो नमः॒ । ह॒रिः॒ ओ३म् ॥",
53
+ inditrans.Script.devanagari,
54
+ inditrans.Script.tamil,
55
+ inditrans.Option.IgnoreVedicAccents + inditrans.Option.TamilSuperscripted
56
+ );
44
57
  ...
45
58
  }
46
59
  ```
@@ -0,0 +1,12 @@
1
+ import { Option } from './Option';
2
+ import { Script } from './Script';
3
+ export declare class Inditrans {
4
+ static instance: Promise<Inditrans>;
5
+ private static _init;
6
+ private module;
7
+ private memory;
8
+ private constructor();
9
+ private utf82ToString;
10
+ private stringToUtf8;
11
+ transliterate(text: string, from: Script, to: Script, options: Option): string;
12
+ }
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.IndiTrans = void 0;
6
+ exports.Inditrans = void 0;
7
7
  const fs_1 = __importDefault(require("fs"));
8
- class IndiTrans {
9
- static instance = IndiTrans._init();
8
+ class Inditrans {
9
+ static instance = Inditrans._init();
10
10
  static async _init() {
11
11
  const { instance } = await WebAssembly.instantiate(fs_1.default.readFileSync(`${__dirname}/inditrans.wasm`));
12
- return new IndiTrans(instance.exports);
12
+ return new Inditrans(instance.exports);
13
13
  }
14
14
  module;
15
15
  memory;
@@ -44,7 +44,7 @@ class IndiTrans {
44
44
  return ret;
45
45
  }
46
46
  transliterate(text, from, to, options) {
47
- const pointers = [text, from, to].map((str) => this.stringToUtf8(str));
47
+ const pointers = [text, from, to].map((str) => this.stringToUtf8(str.toString()));
48
48
  const resultPtr = this.module.transliterate(pointers[0], pointers[1], pointers[2], options);
49
49
  let result = '';
50
50
  if (resultPtr !== 0) {
@@ -55,5 +55,5 @@ class IndiTrans {
55
55
  return result;
56
56
  }
57
57
  }
58
- exports.IndiTrans = IndiTrans;
59
- //# sourceMappingURL=IndiTrans.js.map
58
+ exports.Inditrans = Inditrans;
59
+ //# sourceMappingURL=Inditrans.js.map
@@ -1,4 +1,4 @@
1
- export interface IndiTransModule {
1
+ export interface InditransModule {
2
2
  transliterate(text: number, from: number, to: number, options: number): number;
3
3
  releaseBuffer(ptr: number): void;
4
4
  stackAlloc(size: number): number;
@@ -1,3 +1,3 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=IndiTransModule.js.map
3
+ //# sourceMappingURL=InditransModule.js.map
@@ -1,4 +1,4 @@
1
- export declare enum TranslitOptions {
1
+ export declare enum Option {
2
2
  None = 0,
3
3
  IgnoreVedicAccents = 1,
4
4
  IgnoreQuotedMarkers = 2,
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Option = void 0;
4
+ var Option;
5
+ (function (Option) {
6
+ Option[Option["None"] = 0] = "None";
7
+ Option[Option["IgnoreVedicAccents"] = 1] = "IgnoreVedicAccents";
8
+ Option[Option["IgnoreQuotedMarkers"] = 2] = "IgnoreQuotedMarkers";
9
+ Option[Option["TamilTraditional"] = 4] = "TamilTraditional";
10
+ Option[Option["TamilSuperscripted"] = 8] = "TamilSuperscripted";
11
+ Option[Option["RetainZeroWidthChars"] = 16] = "RetainZeroWidthChars";
12
+ Option[Option["ASCIINumerals"] = 32] = "ASCIINumerals";
13
+ })(Option = exports.Option || (exports.Option = {}));
14
+ //# sourceMappingURL=Option.js.map
@@ -0,0 +1,19 @@
1
+ export declare enum Script {
2
+ assamese = "assamese",
3
+ bengali = "bengali",
4
+ devanagari = "devanagari",
5
+ readablelatin = "readablelatin",
6
+ gujarati = "gujarati",
7
+ gurmukhi = "gurmukhi",
8
+ iast = "iast",
9
+ indic = "indic",
10
+ ipa = "ipa",
11
+ iso = "iso",
12
+ itrans = "itrans",
13
+ kannada = "kannada",
14
+ malayalam = "malayalam",
15
+ oriya = "oriya",
16
+ sinhala = "sinhala",
17
+ tamil = "tamil",
18
+ telugu = "telugu"
19
+ }
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Script = void 0;
4
+ var Script;
5
+ (function (Script) {
6
+ Script["assamese"] = "assamese";
7
+ Script["bengali"] = "bengali";
8
+ Script["devanagari"] = "devanagari";
9
+ Script["readablelatin"] = "readablelatin";
10
+ Script["gujarati"] = "gujarati";
11
+ Script["gurmukhi"] = "gurmukhi";
12
+ Script["iast"] = "iast";
13
+ Script["indic"] = "indic";
14
+ Script["ipa"] = "ipa";
15
+ Script["iso"] = "iso";
16
+ Script["itrans"] = "itrans";
17
+ Script["kannada"] = "kannada";
18
+ Script["malayalam"] = "malayalam";
19
+ Script["oriya"] = "oriya";
20
+ Script["sinhala"] = "sinhala";
21
+ Script["tamil"] = "tamil";
22
+ Script["telugu"] = "telugu";
23
+ })(Script = exports.Script || (exports.Script = {}));
24
+ //# sourceMappingURL=Script.js.map
@@ -1,3 +1,7 @@
1
- import { IndiTrans } from './IndiTrans';
2
- import { TranslitOptions } from './TranslitOptions';
3
- export { IndiTrans, TranslitOptions };
1
+ import { Option } from './Option';
2
+ import { Script } from './Script';
3
+ export { Option, Script };
4
+ export declare function init(): Promise<void>;
5
+ export declare function transliterate(text: string, from: Script, to: Script, options: Option): string;
6
+ declare const _default: (typeof Option | typeof Script | typeof init | typeof transliterate)[];
7
+ export default _default;
package/dist/src/index.js CHANGED
@@ -1,8 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TranslitOptions = exports.IndiTrans = void 0;
4
- const IndiTrans_1 = require("./IndiTrans");
5
- Object.defineProperty(exports, "IndiTrans", { enumerable: true, get: function () { return IndiTrans_1.IndiTrans; } });
6
- const TranslitOptions_1 = require("./TranslitOptions");
7
- Object.defineProperty(exports, "TranslitOptions", { enumerable: true, get: function () { return TranslitOptions_1.TranslitOptions; } });
3
+ exports.transliterate = exports.init = exports.Script = exports.Option = void 0;
4
+ const Inditrans_1 = require("./Inditrans");
5
+ const Option_1 = require("./Option");
6
+ Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return Option_1.Option; } });
7
+ const Script_1 = require("./Script");
8
+ Object.defineProperty(exports, "Script", { enumerable: true, get: function () { return Script_1.Script; } });
9
+ let inditrans = null;
10
+ async function init() {
11
+ inditrans = await Inditrans_1.Inditrans.instance;
12
+ }
13
+ exports.init = init;
14
+ function transliterate(text, from, to, options) {
15
+ if (!inditrans) {
16
+ throw new Error('Inditrans not initialized');
17
+ }
18
+ return inditrans.transliterate(text, from, to, options);
19
+ }
20
+ exports.transliterate = transliterate;
21
+ exports.default = [Option_1.Option, Script_1.Script, init, transliterate];
8
22
  //# sourceMappingURL=index.js.map
@@ -1,8 +1,8 @@
1
- import { IndiTransModule } from './IndiTransModule';
1
+ import { InditransModule } from './InditransModule';
2
2
  export declare class Codec {
3
3
  private module;
4
4
  private memory;
5
- constructor(module: IndiTransModule);
5
+ constructor(module: InditransModule);
6
6
  private stringToNativeArray;
7
7
  private nativeArrayToString;
8
8
  private stringToUtf82;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vm75/inditrans",
3
- "version": "0.3.5",
3
+ "version": "0.3.6",
4
4
  "description": "An experimental transliterator library for some Indic scripts.",
5
5
  "main": "./dist/src/index.js",
6
6
  "author": "VM75",
@@ -23,7 +23,7 @@
23
23
  "test": "yarn build && yarn jest --config jestconfig.json",
24
24
  "copy-files": "shx mkdir -p dist/src && shx cp -f src/inditrans.wasm dist/src/",
25
25
  "prepack": "yarn clean && yarn build",
26
- "publish": "yarn test && npm publish --access=public"
26
+ "pub": "yarn test && npm publish --access=public"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@types/jest": "^27.0.2",
@@ -1,11 +0,0 @@
1
- import { TranslitOptions } from './TranslitOptions';
2
- export declare class IndiTrans {
3
- static instance: Promise<IndiTrans>;
4
- private static _init;
5
- private module;
6
- private memory;
7
- private constructor();
8
- private utf82ToString;
9
- private stringToUtf8;
10
- transliterate(text: string, from: string, to: string, options: TranslitOptions): string;
11
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TranslitOptions = void 0;
4
- var TranslitOptions;
5
- (function (TranslitOptions) {
6
- TranslitOptions[TranslitOptions["None"] = 0] = "None";
7
- TranslitOptions[TranslitOptions["IgnoreVedicAccents"] = 1] = "IgnoreVedicAccents";
8
- TranslitOptions[TranslitOptions["IgnoreQuotedMarkers"] = 2] = "IgnoreQuotedMarkers";
9
- TranslitOptions[TranslitOptions["TamilTraditional"] = 4] = "TamilTraditional";
10
- TranslitOptions[TranslitOptions["TamilSuperscripted"] = 8] = "TamilSuperscripted";
11
- TranslitOptions[TranslitOptions["RetainZeroWidthChars"] = 16] = "RetainZeroWidthChars";
12
- TranslitOptions[TranslitOptions["ASCIINumerals"] = 32] = "ASCIINumerals";
13
- })(TranslitOptions = exports.TranslitOptions || (exports.TranslitOptions = {}));
14
- //# sourceMappingURL=TranslitOptions.js.map