Przeglądaj źródła

Editor: Replace JSZip with fflate.

Mugen87 4 lat temu
rodzic
commit
24735cea88

+ 0 - 1
editor/index.html

@@ -41,7 +41,6 @@
 		<script src="js/libs/ternjs/doc_comment.js"></script>
 		<script src="js/libs/tern-threejs/threejs.js"></script>
 		<script src="js/libs/signals.min.js"></script>
-		<script src="js/libs/jszip.min.js"></script>
 
 		<script type="module">
 

+ 13 - 7
editor/js/Menubar.File.js

@@ -1,5 +1,7 @@
 import * as THREE from '../../build/three.module.js';
 
+import { zipSync, strToU8 } from './libs/fflate-deflate.min.module.js';
+
 import { UIPanel, UIRow, UIHorizontalRule } from './libs/ui.js';
 
 function MenubarFile( editor ) {
@@ -388,7 +390,7 @@ function MenubarFile( editor ) {
 	option.setTextContent( strings.getKey( 'menubar/file/publish' ) );
 	option.onClick( function () {
 
-		var zip = new JSZip(); // eslint-disable-line no-undef
+		var toZip = {};
 
 		//
 
@@ -399,7 +401,7 @@ function MenubarFile( editor ) {
 		output = JSON.stringify( output, parseNumber, '\t' );
 		output = output.replace( /[\n\t]+([\d\.e\-\[\]]+)/g, '$1' );
 
-		zip.file( 'app.json', output );
+		toZip[ 'app.json' ] = strToU8( output );
 
 		//
 
@@ -407,7 +409,11 @@ function MenubarFile( editor ) {
 
 		var manager = new THREE.LoadingManager( function () {
 
-			save( zip.generate( { type: 'blob' } ), ( title !== '' ? title : 'untitled' ) + '.zip' );
+			var zipped = zipSync( toZip, { level: 9 } );
+
+			var blob = new Blob( [ zipped.buffer ], { type: 'application/zip' } );
+
+			save( blob, ( title !== '' ? title : 'untitled' ) + '.zip' );
 
 		} );
 
@@ -439,22 +445,22 @@ function MenubarFile( editor ) {
 
 			content = content.replace( '\n\t\t\t/* edit button */\n', editButton );
 
-			zip.file( 'index.html', content );
+			toZip[ 'index.html' ] = strToU8( content );
 
 		} );
 		loader.load( 'js/libs/app.js', function ( content ) {
 
-			zip.file( 'js/app.js', content );
+			toZip[ 'js/app.js' ] = strToU8( content );
 
 		} );
 		loader.load( '../build/three.module.js', function ( content ) {
 
-			zip.file( 'js/three.module.js', content );
+			toZip[ 'js/three.module.js' ] = strToU8( content );
 
 		} );
 		loader.load( '../examples/jsm/webxr/VRButton.js', function ( content ) {
 
-			zip.file( 'js/VRButton.js', content );
+			toZip[ 'js/VRButton.js' ] = strToU8( content );
 
 		} );
 

Plik diff jest za duży
+ 6 - 0
editor/js/libs/fflate-deflate.min.module.js


Plik diff jest za duży
+ 0 - 11
editor/js/libs/jszip.min.js


+ 1 - 1
editor/sw.js

@@ -99,7 +99,7 @@ const assets = [
 	'./js/libs/tern-threejs/threejs.js',
 
 	'./js/libs/signals.min.js',
-	'./js/libs/jszip.min.js',
+	'./js/libs/fflate-deflate.min.module.js',
 	'./js/libs/ui.js',
 	'./js/libs/ui.three.js',
 

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików