1// generated by diplomat-tool 2import { BidiParagraph } from "./BidiParagraph.mjs" 3import wasm from "./diplomat-wasm.mjs"; 4import * as diplomatRuntime from "./diplomat-runtime.mjs"; 5 6 7/** An object containing bidi information for a given string, produced by `for_text()` on `Bidi` 8* 9*See the [Rust documentation for `BidiInfo`](https://docs.rs/unicode_bidi/latest/unicode_bidi/struct.BidiInfo.html) for more information. 10*/ 11const BidiInfo_box_destroy_registry = new FinalizationRegistry((ptr) => { 12 wasm.icu4x_BidiInfo_destroy_mv1(ptr); 13}); 14 15export class BidiInfo { 16 17 // Internal ptr reference: 18 #ptr = null; 19 20 // Lifetimes are only to keep dependencies alive. 21 // Since JS won't garbage collect until there are no incoming edges. 22 #selfEdge = []; 23 #textEdge = []; 24 25 #internalConstructor(symbol, ptr, selfEdge, textEdge) { 26 if (symbol !== diplomatRuntime.internalConstructor) { 27 console.error("BidiInfo is an Opaque type. You cannot call its constructor."); 28 return; 29 } 30 31 32 this.#textEdge = textEdge; 33 34 this.#ptr = ptr; 35 this.#selfEdge = selfEdge; 36 37 // Are we being borrowed? If not, we can register. 38 if (this.#selfEdge.length === 0) { 39 BidiInfo_box_destroy_registry.register(this, this.#ptr); 40 } 41 42 return this; 43 } 44 get ffiValue() { 45 return this.#ptr; 46 } 47 48 get paragraphCount() { 49 const result = wasm.icu4x_BidiInfo_paragraph_count_mv1(this.ffiValue); 50 51 try { 52 return result; 53 } 54 55 finally {} 56 } 57 58 paragraphAt(n) { 59 // This lifetime edge depends on lifetimes 'text 60 let textEdges = [this]; 61 62 const result = wasm.icu4x_BidiInfo_paragraph_at_mv1(this.ffiValue, n); 63 64 try { 65 return result === 0 ? null : new BidiParagraph(diplomatRuntime.internalConstructor, result, [], textEdges); 66 } 67 68 finally {} 69 } 70 71 get size() { 72 const result = wasm.icu4x_BidiInfo_size_mv1(this.ffiValue); 73 74 try { 75 return result; 76 } 77 78 finally {} 79 } 80 81 levelAt(pos) { 82 const result = wasm.icu4x_BidiInfo_level_at_mv1(this.ffiValue, pos); 83 84 try { 85 return result; 86 } 87 88 finally {} 89 } 90 91 constructor(symbol, ptr, selfEdge, textEdge) { 92 return this.#internalConstructor(...arguments) 93 } 94}