Add es6-promise polyfill to build step so users don't have to.
This commit is contained in:
parent
4cd664a919
commit
39e1e145e4
11
Gruntfile.js
11
Gruntfile.js
|
@ -38,7 +38,7 @@ module.exports = function(grunt) {
|
||||||
'test/lib/unittests-bundle.js': [ './test/unittests.js' ]
|
'test/lib/unittests-bundle.js': [ './test/unittests.js' ]
|
||||||
},
|
},
|
||||||
options: {
|
options: {
|
||||||
external: [ 'openpgp', 'crypto', 'node-localstorage', 'es6-promise']
|
external: [ 'openpgp', 'crypto', 'node-localstorage']
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -116,15 +116,8 @@ module.exports = function(grunt) {
|
||||||
expand: true,
|
expand: true,
|
||||||
flatten: true,
|
flatten: true,
|
||||||
cwd: 'node_modules/',
|
cwd: 'node_modules/',
|
||||||
src: ['mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js', 'es6-promise/dist/promise*.js'],
|
src: ['mocha/mocha.css', 'mocha/mocha.js', 'chai/chai.js'],
|
||||||
dest: 'test/lib/'
|
dest: 'test/lib/'
|
||||||
},
|
|
||||||
polyfill: {
|
|
||||||
expand: true,
|
|
||||||
flatten: true,
|
|
||||||
cwd: 'node_modules/',
|
|
||||||
src: ['es6-promise/dist/promise*.js'],
|
|
||||||
dest: 'dist/'
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clean: ['dist/'],
|
clean: ['dist/'],
|
||||||
|
|
|
@ -27,7 +27,7 @@ The library can be loaded via AMD/require.js or accessed globally via `window.o
|
||||||
|
|
||||||
OpenPGP.js only supports browsers that implement `window.crypto.getRandomValues`. Also, if the browsers support [native WebCrypto](http://www.w3.org/TR/WebCryptoAPI/) via the `window.crypto.subtle` api, this will be used. Though this can be deactivated by setting `config.useWebCrypto = false`. In this case the library will fall back to Web Worker operations if the `initWorker(workerPath)` is set.
|
OpenPGP.js only supports browsers that implement `window.crypto.getRandomValues`. Also, if the browsers support [native WebCrypto](http://www.w3.org/TR/WebCryptoAPI/) via the `window.crypto.subtle` api, this will be used. Though this can be deactivated by setting `config.useWebCrypto = false`. In this case the library will fall back to Web Worker operations if the `initWorker(workerPath)` is set.
|
||||||
|
|
||||||
OpenPGP.js uses ES6 promises which are available in [most modern browsers](http://caniuse.com/#feat=promises). If you need to support browsers that do not support Promises, fear not! There is a [polyfill](https://github.com/jakearchibald/es6-promise).
|
OpenPGP.js uses ES6 promises which are available in [most modern browsers](http://caniuse.com/#feat=promises). If you need to support browsers that do not support Promises, fear not! There is a [polyfill](https://github.com/jakearchibald/es6-promise), which is included in the build step. So no action required on the developer's part for promises!
|
||||||
|
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browserify": "~2.35",
|
"browserify": "~2.35",
|
||||||
"chai": "~1.8.1",
|
"chai": "~1.8.1",
|
||||||
"es6-promise": "1.0.0",
|
|
||||||
"grunt": "~0.4.2",
|
"grunt": "~0.4.2",
|
||||||
"grunt-browserify": "~1.2.11",
|
"grunt-browserify": "~1.2.11",
|
||||||
"grunt-cli": "~0.1.13",
|
"grunt-cli": "~0.1.13",
|
||||||
|
@ -47,6 +46,7 @@
|
||||||
"phantomjs": "~1.9.2-5"
|
"phantomjs": "~1.9.2-5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"es6-promise": "^1.0.0",
|
||||||
"node-localstorage": "~0.3.4"
|
"node-localstorage": "~0.3.4"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|
|
@ -41,6 +41,11 @@ var armor = require('./encoding/armor.js'),
|
||||||
util = require('./util'),
|
util = require('./util'),
|
||||||
AsyncProxy = require('./worker/async_proxy.js');
|
AsyncProxy = require('./worker/async_proxy.js');
|
||||||
|
|
||||||
|
if (typeof Promise === 'undefined') {
|
||||||
|
// load ES6 Promises polyfill
|
||||||
|
require('es6-promise').polyfill();
|
||||||
|
}
|
||||||
|
|
||||||
var asyncProxy; // instance of the asyncproxy
|
var asyncProxy; // instance of the asyncproxy
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,10 +39,6 @@ if (!Function.prototype.bind) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof Promise === 'undefined') {
|
|
||||||
// promises polyfill
|
|
||||||
importScripts('promise-1.0.0.js');
|
|
||||||
}
|
|
||||||
importScripts('openpgp.js');
|
importScripts('openpgp.js');
|
||||||
|
|
||||||
var MIN_SIZE_RANDOM_BUFFER = 40000;
|
var MIN_SIZE_RANDOM_BUFFER = 40000;
|
||||||
|
|
|
@ -9,9 +9,6 @@
|
||||||
<body>
|
<body>
|
||||||
<div id="mocha"></div>
|
<div id="mocha"></div>
|
||||||
|
|
||||||
<!-- polyfills -->
|
|
||||||
<script src="lib/promise-1.0.0.js"></script>
|
|
||||||
|
|
||||||
<!-- libs -->
|
<!-- libs -->
|
||||||
<script src="../dist/openpgp.js"></script>
|
<script src="../dist/openpgp.js"></script>
|
||||||
<script src="lib/chai.js"></script>
|
<script src="lib/chai.js"></script>
|
||||||
|
|
|
@ -1,8 +1,3 @@
|
||||||
if (typeof window === 'undefined') {
|
|
||||||
// load ES6 Promises polyfill under node.js
|
|
||||||
require('es6-promise').polyfill();
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('Unit Tests', function () {
|
describe('Unit Tests', function () {
|
||||||
require('./general');
|
require('./general');
|
||||||
require('./crypto');
|
require('./crypto');
|
||||||
|
|
Loading…
Reference in New Issue
Block a user