• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// generated by diplomat-tool
2import wasm from "./diplomat-wasm.mjs";
3import * as diplomatRuntime from "./diplomat-runtime.mjs";
4
5
6/** An object allowing control over the logging used
7*/
8const Logger_box_destroy_registry = new FinalizationRegistry((ptr) => {
9    wasm.icu4x_Logger_destroy_mv1(ptr);
10});
11
12export class Logger {
13
14    // Internal ptr reference:
15    #ptr = null;
16
17    // Lifetimes are only to keep dependencies alive.
18    // Since JS won't garbage collect until there are no incoming edges.
19    #selfEdge = [];
20
21    #internalConstructor(symbol, ptr, selfEdge) {
22        if (symbol !== diplomatRuntime.internalConstructor) {
23            console.error("Logger is an Opaque type. You cannot call its constructor.");
24            return;
25        }
26
27        this.#ptr = ptr;
28        this.#selfEdge = selfEdge;
29
30        // Are we being borrowed? If not, we can register.
31        if (this.#selfEdge.length === 0) {
32            Logger_box_destroy_registry.register(this, this.#ptr);
33        }
34
35        return this;
36    }
37    get ffiValue() {
38        return this.#ptr;
39    }
40
41    static initSimpleLogger() {
42        const result = wasm.icu4x_Logger_init_simple_logger_mv1();
43
44        try {
45            return result;
46        }
47
48        finally {}
49    }
50
51    constructor(symbol, ptr, selfEdge) {
52        return this.#internalConstructor(...arguments)
53    }
54}