trueinteractions / tint-chromium

Use Chromium (chrome) as your WebView with Tint
8 stars 1 forks source link

Add OS X support #1

Open trevorlinton opened 9 years ago

JohnLouderback commented 9 years ago

Hi Trevor, any news on this issue? This will be something I will need for my current project and I'm moving into the stage where I'll need to start developing cross-platform.

trevorlinton commented 9 years ago

Yes, we have an initial set of classes for OSX ready to go but have been struggling getting an automated (e.g., npm install chromium) to work on OS X. The windows version of chromium can be downloaded through the nuget package management without troubles, however the OSX of CEF, from what we can find can only be manually downloaded from https://cefbuilds.com which as you may notice has a captcha around it..

I suppose we could simply give the user instructions to download the CEF OSX bundle, extract it and place it in the npm modules directory but my gut says that will be a bit error prone. I emailed the adobe team to ask if they could share a direct download last week, i'll email them again.

I'll keep you posted, thanks john.

JohnLouderback commented 9 years ago

So, it appears the CEFBuilds.com website's security sucks. I wrote a quick and dirty script to automatically download whatever the latest OS X binaries are. The script isn't bulletproof. It uses a vulnerability I've found in their markup. It appears to work in all my quick tests, unless I'm downloading the wrong file. Let me know if this works for you.

var http = require('https');
var fs = require('fs');
var dlProgress = 0;
var dlTotal = 0;
var pageProgress = 0;
var pageTotal = 0;
var lastDLProgress = 0;
var lastPageProgress = 0;

var options = {
  host: 'cefbuilds.com',
  path: '/'
};

var download = function(url, dest, cb) {
  var file = fs.createWriteStream(dest);
  var request = http.get(url, function(response) {
    dlTotal = parseInt(response.headers['content-length'], 10);
    response.on('data', function(chunk) {
      dlProgress += chunk.length;
      var progress = parseInt((dlProgress / dlTotal)*100);
      if (progress > lastDLProgress) {
        process.stdout.clearLine(); 
        process.stdout.cursorTo(0);
        process.stdout.write(progress + '% downloaded');
        lastDLProgress = progress;
      }
    });
    response.pipe(file);
    file.on('finish', function() {
      file.close(cb);  // close() is async, call cb after close completes.
    });
  }).on('error', function(err) { // Handle errors
    fs.unlink(dest); // Delete the file async. (But we don't check the result)
    if (cb) cb(err.message);
  });
};

http.request(options, function(response) {
  var data = '';
  pageTotal = parseInt(response.headers['content-length'], 10);
  response.on('data', function (chunk) {
    pageProgress += chunk.length;
    data += chunk;
    var progress = parseInt((pageProgress / pageTotal)*100);
    if (progress > lastPageProgress) {
      process.stdout.clearLine(); 
      process.stdout.cursorTo(0);
      process.stdout.write(progress + '% of page loaded.');
      lastPageProgress = progress;
    }
  });
  response.on('end', function () {
    var regex = new RegExp('s3key="(.*?_macosx64.7z)"', 'i')
    console.log('\nhttps://cefbuilds.s3.amazonaws.com/' + regex.exec(data)[1] + '\n');
    download('https://cefbuilds.s3.amazonaws.com/' + regex.exec(data)[1], process.cwd() + '/osxcef.7z', function() {
      console.log('\n\nDONE!');
    })
  });
}).end();
JohnLouderback commented 9 years ago

Hi Trevor, was the above useful at all?

trevorlinton commented 9 years ago

@JohnLouderback Yes! Very helpful, it however did expose a CPU timing bug we've been resolving. So oddly we spent a good portion of the week benchmarking and trying to fix a performance issue the script you posted exposed. I'll get the classes integrated (hopefully in the next few days) and posted up to the repo.

Thanks again (and BTW, the CPU issue will be resolved with the release in 2.1.15 on monday).

JohnLouderback commented 9 years ago

Awesome to hear. Glad I could help.

JohnLouderback commented 9 years ago

Hey Trevor,

Any news with this one?

ayoungh commented 9 years ago

Really looking forward to this too, would have been good to mention this on the NPM page...

chimon2000 commented 8 years ago

+1