diff --git a/package.json b/package.json index 2be34a3..b288fa6 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "url": "git+ssh://git@github.com/LLK/scratch-render.git" }, "main": "./dist/node/scratch-render.js", + "browser": "./dist/web/scratch-render.js", "scripts": { "build": "webpack --progress --colors", "docs": "jsdoc -c .jsdoc.json", diff --git a/src/RenderWebGL.js b/src/RenderWebGL.js index 33ae9d5..929b753 100644 --- a/src/RenderWebGL.js +++ b/src/RenderWebGL.js @@ -229,8 +229,8 @@ class RenderWebGL extends EventEmitter { * Create a new bitmap skin from a snapshot of the provided bitmap data. * @param {ImageData|HTMLImageElement|HTMLCanvasElement|HTMLVideoElement} bitmapData - new contents for this skin. * @param {!int} [costumeResolution=1] - The resolution to use for this bitmap. - * @param {?Array} rotationCenter Optional: rotation center of the skin. If not supplied, the center of the - * skin will be used + * @param {?Array} [rotationCenter] Optional: rotation center of the skin. If not supplied, the center of + * the skin will be used. * @returns {!int} the ID for the new skin. */ createBitmapSkin (bitmapData, costumeResolution, rotationCenter) { @@ -630,9 +630,9 @@ class RenderWebGL extends EventEmitter { * pick drawables that are not visible or have ghost set all the way up. * @param {int} centerX The client x coordinate of the picking location. * @param {int} centerY The client y coordinate of the picking location. - * @param {int} touchWidth The client width of the touch event (optional). - * @param {int} touchHeight The client height of the touch event (optional). - * @param {Array} candidateIDs The Drawable IDs to pick from, otherwise all. + * @param {int} [touchWidth] The client width of the touch event (optional). + * @param {int} [touchHeight] The client height of the touch event (optional). + * @param {Array} [candidateIDs] The Drawable IDs to pick from, otherwise all. * @returns {int} The ID of the topmost Drawable under the picking location, or * RenderConstants.ID_NONE if there is no Drawable at that location. */ diff --git a/src/index-web.js b/src/index-web.js deleted file mode 100644 index 0d76145..0000000 --- a/src/index-web.js +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-env browser */ -require('babel-polyfill'); - -/** - * Export for use in a web page. - * @type {RenderWebGL} - */ -window.RenderWebGL = require('./index'); diff --git a/src/playground/.eslintrc.js b/src/playground/.eslintrc.js new file mode 100644 index 0000000..0711afb --- /dev/null +++ b/src/playground/.eslintrc.js @@ -0,0 +1,7 @@ +module.exports = { + root: true, + extends: ['scratch'], + env: { + browser: true + } +}; diff --git a/src/playground/index.html b/src/playground/index.html index 0d041c3..34596be 100644 --- a/src/playground/index.html +++ b/src/playground/index.html @@ -11,6 +11,7 @@

+ +

- Min: - Max: + +

diff --git a/webpack.config.js b/webpack.config.js index 677caf4..e380f05 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -13,7 +13,7 @@ const base = { rules: [ { include: [ - path.resolve(__dirname, 'src') + path.resolve('src') ], test: /\.js$/, loader: 'babel-loader', @@ -40,10 +40,12 @@ module.exports = [ Object.assign({}, base, { target: 'web', entry: { - 'scratch-render': './src/index-web.js' + 'scratch-render': './src/index.js' }, output: { - path: path.resolve(__dirname, 'playground'), + library: 'ScratchRender', + libraryTarget: 'umd', + path: path.resolve('playground'), filename: '[name].js' }, plugins: base.plugins.concat([ @@ -58,11 +60,13 @@ module.exports = [ Object.assign({}, base, { target: 'web', entry: { - 'scratch-render': './src/index-web.js', - 'scratch-render.min': './src/index-web.js' + 'scratch-render': './src/index.js', + 'scratch-render.min': './src/index.js' }, output: { - path: path.resolve(__dirname, 'dist/web'), + library: 'ScratchRender', + libraryTarget: 'umd', + path: path.resolve('dist', 'web'), filename: '[name].js' } }), @@ -75,7 +79,7 @@ module.exports = [ output: { library: 'ScratchRender', libraryTarget: 'commonjs2', - path: path.resolve(__dirname, 'dist/node'), + path: path.resolve('dist', 'node'), filename: '[name].js' } })