Sha256: 7f349eea103fba6a6c68bd530b645d2d2e9a4025cbc33ecf562944543f437f1d

Contents?: true

Size: 1.18 KB

Versions: 25

Compression:

Stored size: 1.18 KB

Contents

// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE

// declare global: tern, server

var server;

this.onmessage = function(e) {
  var data = e.data;
  switch (data.type) {
  case "init": return startServer(data.defs, data.plugins, data.scripts);
  case "add": return server.addFile(data.name, data.text);
  case "del": return server.delFile(data.name);
  case "req": return server.request(data.body, function(err, reqData) {
    postMessage({id: data.id, body: reqData, err: err && String(err)});
  });
  case "getFile":
    var c = pending[data.id];
    delete pending[data.id];
    return c(data.err, data.text);
  default: throw new Error("Unknown message type: " + data.type);
  }
};

var nextId = 0, pending = {};
function getFile(file, c) {
  postMessage({type: "getFile", name: file, id: ++nextId});
  pending[nextId] = c;
}

function startServer(defs, plugins, scripts) {
  if (scripts) importScripts.apply(null, scripts);

  server = new tern.Server({
    getFile: getFile,
    async: true,
    defs: defs,
    plugins: plugins
  });
}

this.console = {
  log: function(v) { postMessage({type: "debug", message: v}); }
};

Version data entries

25 entries across 25 versions & 3 rubygems

Version Path
rails_db-2.4.5 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
rails_db-2.4.4 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
rails_db-2.4.3 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
wallaby-7.0.0.beta2 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
wallaby-7.0.0.beta1 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
wallaby-6.1.6 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
rails_db-2.4.2 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
wallaby-6.1.5 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
wallaby-6.1.4 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
rails_db-2.4.1 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
rails_db-2.4.0 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
wallaby-6.1.3 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
wallaby-6.1.2 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
wallaby-6.1.1 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
wallaby-6.1.0 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
rails_db-2.3.1 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
rails_db-2.3.0 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js
wallaby-6.0.2 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
wallaby-6.0.1 vendor/assets/javascripts/codemirror/5.49.2/addon/tern/worker.js
rails_db-2.2.1 app/assets/javascripts/codemirror/codemirror/addons/tern/worker.js