<commit_before>import Check from "./Check.js";
import CompressedTextureBuffer from "./CompressedTextureBuffer.js";
import defined from "./defined.js";
import TaskProcessor from "./TaskProcessor.js";

/**
 * Transcodes KTX2 textures using web workers.
 *
 * @private
 */
function KTX2Transcoder() {}

KTX2Transcoder._transcodeTaskProcessor = new TaskProcessor(
  "transcodeKTX2",
  Number.POSITIVE_INFINITY // KTX2 transcoding is used in place of Resource.fetchImage, so it can't reject as "just soooo busy right now"
);

KTX2Transcoder._readyPromise = undefined;

function makeReadyPromise() {
  var readyPromise = KTX2Transcoder._transcodeTaskProcessor
    .initWebAssemblyModule({
      modulePath: "ThirdParty/Workers/basis_transcoder.js",
      wasmBinaryFile: "ThirdParty/basis_transcoder.wasm",
    })
    .then(function () {
      return KTX2Transcoder._transcodeTaskProcessor;
    });
  KTX2Transcoder._readyPromise = readyPromise;
}

KTX2Transcoder.transcode = function (ktx2Buffer, supportedTargetFormats) {
  //>>includeStart('debug', pragmas.debug);
  Check.defined("supportedTargetFormats", supportedTargetFormats);
  //>>includeEnd('debug');

  if (!defined(KTX2Transcoder._readyPromise)) {
    makeReadyPromise();
  }

  return KTX2Transcoder._readyPromise
    .then(function (taskProcessor) {
      var parameters;
      if (ktx2Buffer instanceof ArrayBuffer) {
        var view = new Uint8Array(ktx2Buffer);
        parameters = {
          supportedTargetFormats: supportedTargetFormats,
          ktx2Buffer: view,<commit_msg>wrap KTX2Transcoder task processor in getter<commit_after>import Check from "./Check.js";
import CompressedTextureBuffer from "./CompressedTextureBuffer.js";
import defined from "./defined.js";
import TaskProcessor from "./TaskProcessor.js";

/**
 * Transcodes KTX2 textures using web workers.
 *
 * @private
 */
function KTX2Transcoder() {}

KTX2Transcoder._transcoderTaskProcessor = undefined;
KTX2Transcoder._getTranscoderTaskProcessor = function () {
  if (!defined(KTX2Transcoder._transcoderTaskProcessor)) {
    KTX2Transcoder._transcoderTaskProcessor = new TaskProcessor(
      "transcodeKTX2",
      Number.POSITIVE_INFINITY // KTX2 transcoding is used in place of Resource.fetchImage, so it can't reject as "just soooo busy right now"
    );
  }
  return KTX2Transcoder._transcoderTaskProcessor;
};

KTX2Transcoder._readyPromise = undefined;

function makeReadyPromise() {
  var taskProcessor = KTX2Transcoder._getTranscoderTaskProcessor();
  var readyPromise = taskProcessor
    .initWebAssemblyModule({
      modulePath: "ThirdParty/Workers/basis_transcoder.js",
      wasmBinaryFile: "ThirdParty/basis_transcoder.wasm",
    })
    .then(function () {
      return KTX2Transcoder._transcodeTaskProcessor;
    });
  KTX2Transcoder._readyPromise = readyPromise;
}

KTX2Transcoder.transcode = function (ktx2Buffer, supportedTargetFormats) {
  //>>includeStart('debug', pragmas.debug);
  Check.defined("supportedTargetFormats", supportedTargetFormats);
  //>>includeEnd('debug');

  if (!defined(KTX2Transcoder._readyPromise)) {
    makeReadyPromise();
  }

  return KTX2Transcoder._readyPromise
    .then(function (taskProcessor) {
      var parameters;
      if (ktx2Buffer instanceof ArrayBuffer) {
        var view = new Uint8Array(ktx2Buffer);
        parameters = {
          supportedTargetFormats: supportedTargetFormats,
          ktx2Buffer: view,
{'fraction_non_alphanumeric': 0.10149603989439718, 'fraction_numerical': 0.011440305074801994, 'mean_word_length': 4.491143317230274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7530922', 'n_tokens_mistral': 1045, 'n_tokens_neox': 1022, 'n_words': 207}