"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const emscripten_wasm_loader_1 = require("emscripten-wasm-loader");
const nanoid = require("nanoid");
const logger_1 = require("../util/logger");
/**
 * Construct few utility function to be used interop between raw libsass interface.
 *
 * @param {SassAsmModule} asmModule
 */
const buildInteropUtility = (asmModule) => {
    const { FS, Pointer_stringify, _free, allocateUTF8 } = asmModule;
    const str = {
        alloc: allocateUTF8,
        ptrToString: Pointer_stringify
    };
    const nodePathId = `/${nanoid(45)}`;
    FS.mkdir(nodePathId);
    logger_1.log(`sassLoader: root mounting point created`, { nodePathId });
    const mountPath = emscripten_wasm_loader_1.mountDirectory(FS, nodePathId);
    const unmountPath = emscripten_wasm_loader_1.unmount(FS, nodePathId);
    return {
        str,
        mount: mountPath,
        unmount: unmountPath,
        free: _free
    };
};
exports.buildInteropUtility = buildInteropUtility;
//# sourceMappingURL=interopUtility.js.map