diff --git a/js/src/core/lib/snapshot.js b/js/src/core/lib/snapshot.js index 023a9cf3..54081875 100644 --- a/js/src/core/lib/snapshot.js +++ b/js/src/core/lib/snapshot.js @@ -3,9 +3,9 @@ const fflate = require('fflate'); const requireJsSource = require('../../../../node_modules/requirejs/require?raw'); const fflateJsSource = require('../../../../node_modules/fflate/umd/index?raw'); const fileLoader = require('./helpers/fileLoader'); -const templateStandalone = require('./snapshot_standalone.txt'); -const templateOnline = require('./snapshot_online.txt'); -const templateInline = require('./snapshot_inline.txt'); +const templateStandalone = require('./snapshot_standalone').default; +const templateOnline = require('./snapshot_online').default; +const templateInline = require('./snapshot_inline').default; const semverRange = require('../../version').version; const buffer = require('./helpers/buffer'); @@ -26,7 +26,8 @@ if (typeof (sourceCode) === 'undefined') { } if (typeof (path) !== 'undefined') { - path = path.replace('k3d.js', 'standalone.js').replace('index.js', 'standalone.js'); + path = path.replaceAll('\\\\', '/').replaceAll('\\', '/'); + path = path.split('/').slice(0, -1).join('/') + '/standalone.js'; } else { // use npm repository path = `https://unpkg.com/k3d@${semverRange}/dist/standalone.js`; @@ -68,7 +69,7 @@ function getHTMLSnapshot(K3D, compressionLevel) { } function handleFileSelect(K3D, evt) { - const {files} = evt.dataTransfer; + const { files } = evt.dataTransfer; const HTMLSnapshotReader = new FileReader(); const BinarySnapshotReader = new FileReader(); const STLReader = new FileReader(); @@ -141,7 +142,7 @@ function snapshotGUI(gui, K3D) { filename = `${K3D.parameters.name}.html`; } - data = new Blob([data], {type: 'text/plain;charset=utf-8'}); + data = new Blob([data], { type: 'text/plain;charset=utf-8' }); FileSaver.saveAs(data, filename); }, }; diff --git a/js/src/core/lib/snapshot_inline.txt b/js/src/core/lib/snapshot_inline.js similarity index 92% rename from js/src/core/lib/snapshot_inline.txt rename to js/src/core/lib/snapshot_inline.js index 4c42dd43..6a9b82db 100644 --- a/js/src/core/lib/snapshot_inline.txt +++ b/js/src/core/lib/snapshot_inline.js @@ -1,4 +1,4 @@ -
+export default `
\ No newline at end of file +`; \ No newline at end of file diff --git a/js/src/core/lib/snapshot_online.txt b/js/src/core/lib/snapshot_online.js similarity index 97% rename from js/src/core/lib/snapshot_online.txt rename to js/src/core/lib/snapshot_online.js index 784334e9..813cb470 100644 --- a/js/src/core/lib/snapshot_online.txt +++ b/js/src/core/lib/snapshot_online.js @@ -1,4 +1,4 @@ - +export default ` @@ -54,4 +54,4 @@ }); - +`; \ No newline at end of file diff --git a/js/src/core/lib/snapshot_standalone.txt b/js/src/core/lib/snapshot_standalone.js similarity index 97% rename from js/src/core/lib/snapshot_standalone.txt rename to js/src/core/lib/snapshot_standalone.js index 584f44f5..026989bd 100644 --- a/js/src/core/lib/snapshot_standalone.txt +++ b/js/src/core/lib/snapshot_standalone.js @@ -1,4 +1,4 @@ - +export default ` @@ -62,4 +62,4 @@ }); - +`; \ No newline at end of file diff --git a/js/webpack.config.js b/js/webpack.config.js index c7eed58e..cded3143 100644 --- a/js/webpack.config.js +++ b/js/webpack.config.js @@ -107,15 +107,14 @@ module.exports = [ { entry: './src/standalone.js', output: - { - filename: 'standalone.js', - path: `${__dirname}/../k3d/static`, - library: 'k3d', - libraryTarget: 'amd', - publicPath: `https://unpkg.com/k3d@${version}/dist/`, - }, + { + filename: 'standalone.js', + path: `${__dirname}/../k3d/static`, + library: 'k3d', + libraryTarget: 'amd', + publicPath: `https://unpkg.com/k3d@${version}/dist/`, + }, mode, - devtool: 'source-map', module: { rules, }, @@ -133,15 +132,30 @@ module.exports = [ { entry: './src/standalone.js', output: - { - filename: 'standalone.js', - path: `${__dirname}/dist/`, - library: 'k3d', - libraryTarget: 'amd', - publicPath: `https://unpkg.com/k3d@${version}/dist/`, + { + filename: 'standalone.js', + path: `${__dirname}/dist/`, + library: 'k3d', + libraryTarget: 'amd', + publicPath: `https://unpkg.com/k3d@${version}/dist/`, + }, + mode, + module: { + rules, }, + plugins, + }, + { + entry: './src/standalone.js', + output: + { + filename: 'standalone.js', + path: `${__dirname}/../k3d/labextension/static/`, + library: 'k3d', + libraryTarget: 'amd', + publicPath: `https://unpkg.com/k3d@${version}/dist/`, + }, mode, - devtool: 'source-map', module: { rules, },