mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-27 00:30:09 +02:00
add basic Js13kgames mode
This commit is contained in:
@@ -61,6 +61,7 @@
|
|||||||
"copy-webpack-plugin": "^4.5.1",
|
"copy-webpack-plugin": "^4.5.1",
|
||||||
"esprima": "^4.0.0",
|
"esprima": "^4.0.0",
|
||||||
"firebase": "^5.0.4",
|
"firebase": "^5.0.4",
|
||||||
|
"jszip": "^3.1.5",
|
||||||
"preact": "^8.2.6",
|
"preact": "^8.2.6",
|
||||||
"preact-compat": "^3.17.0",
|
"preact-compat": "^3.17.0",
|
||||||
"preact-portal": "^1.1.3",
|
"preact-portal": "^1.1.3",
|
||||||
|
@@ -1,6 +1,41 @@
|
|||||||
import { h, Component } from 'preact';
|
import { h, Component } from 'preact';
|
||||||
import { Button } from './common';
|
import { Button } from './common';
|
||||||
|
|
||||||
|
class JS13K extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
const compoDate = new Date('August 13 2018 11:00 GMT');
|
||||||
|
var now = new Date();
|
||||||
|
var daysLeft;
|
||||||
|
if (+compoDate > +now) {
|
||||||
|
daysLeft = Math.floor((compoDate - now) / 1000 / 3600 / 24);
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
daysLeft
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div class="flex flex-v-center">
|
||||||
|
<img
|
||||||
|
src="http://js13kgames.com/img/js13kgames.png"
|
||||||
|
alt="JS13K Games logo"
|
||||||
|
height="24"
|
||||||
|
/>{' '}
|
||||||
|
<div class="footer__js13k-text">{this.state.daysLeft} days to go</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
color: this.props.codeSize > 10 ? 'crimson' : 'limegreen'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{(this.props.codeSize / 1024).toFixed(2)} KB/ 13KB
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export default class Footer extends Component {
|
export default class Footer extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@@ -15,7 +50,83 @@ export default class Footer extends Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div id="footer" class="footer">
|
<div id="footer" class="footer">
|
||||||
<div class="footer__right fr">
|
<div>
|
||||||
|
<a
|
||||||
|
href="https://webmakerapp.com/"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<div class="logo" />
|
||||||
|
</a>
|
||||||
|
©
|
||||||
|
<span class="web-maker-with-tag">Web Maker</span>
|
||||||
|
<Button
|
||||||
|
onClick={this.props.helpBtnClickHandler}
|
||||||
|
data-event-category="ui"
|
||||||
|
data-event-action="helpButtonClick"
|
||||||
|
class="footer__link hint--rounded hint--top-right"
|
||||||
|
aria-label="Help"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
style="width:20px; height:20px; vertical-align:text-bottom"
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path d="M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z" />
|
||||||
|
</svg>
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
onClick={this.props.keyboardShortcutsBtnClickHandler}
|
||||||
|
data-event-category="ui"
|
||||||
|
data-event-action="keyboardShortcutButtonClick"
|
||||||
|
class="footer__link hint--rounded hint--top-right hide-on-mobile"
|
||||||
|
aria-label="Keyboard shortcuts"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
style={{
|
||||||
|
width: '20px',
|
||||||
|
height: '20px',
|
||||||
|
verticalAlign: 'text-bottom'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<use xlinkHref="#keyboard-icon" />
|
||||||
|
</svg>
|
||||||
|
</Button>
|
||||||
|
<a
|
||||||
|
class="footer__link hint--rounded hint--top-right"
|
||||||
|
aria-label="Tweet about 'Web Maker'"
|
||||||
|
href="http://twitter.com/share?url=https://webmakerapp.com/&text=Web Maker - A blazing fast %26 offline web playground! via @webmakerApp&related=webmakerApp&hashtags=web,frontend,playground,offline"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
style={{
|
||||||
|
width: '20px',
|
||||||
|
height: '20px',
|
||||||
|
verticalAlign: 'text-bottom'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<use xlinkHref="#twitter-icon" />
|
||||||
|
</svg>
|
||||||
|
</a>
|
||||||
|
<Button
|
||||||
|
onClick={this.props.supportDeveloperBtnClickHandler}
|
||||||
|
data-event-category="ui"
|
||||||
|
data-event-action="supportDeveloperFooterBtnClick"
|
||||||
|
class="footer__link ml-1 hint--rounded hint--top-right hide-on-mobile support-link"
|
||||||
|
aria-label="Support the developer by pledging some amount"
|
||||||
|
>
|
||||||
|
Donate
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{this.props.prefs.isJs13kModeOn ? (
|
||||||
|
<div class="flex">
|
||||||
|
<JS13K codeSize={this.props.codeSize} />
|
||||||
|
<button onClick={this.props.onJs13KBtnClick}>Help</button>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
|
|
||||||
|
<div class="footer__right">
|
||||||
<button
|
<button
|
||||||
onClick={this.props.saveHtmlBtnClickHandler}
|
onClick={this.props.saveHtmlBtnClickHandler}
|
||||||
id="saveHtmlBtn"
|
id="saveHtmlBtn"
|
||||||
@@ -150,72 +261,6 @@ export default class Footer extends Component {
|
|||||||
</svg>
|
</svg>
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
<a
|
|
||||||
href="https://webmakerapp.com/"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<div class="logo" />
|
|
||||||
</a>
|
|
||||||
©
|
|
||||||
<span class="web-maker-with-tag">Web Maker</span>
|
|
||||||
<Button
|
|
||||||
onClick={this.props.helpBtnClickHandler}
|
|
||||||
data-event-category="ui"
|
|
||||||
data-event-action="helpButtonClick"
|
|
||||||
class="footer__link hint--rounded hint--top-right"
|
|
||||||
aria-label="Help"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
style="width:20px; height:20px; vertical-align:text-bottom"
|
|
||||||
viewBox="0 0 24 24"
|
|
||||||
>
|
|
||||||
<path d="M15.07,11.25L14.17,12.17C13.45,12.89 13,13.5 13,15H11V14.5C11,13.39 11.45,12.39 12.17,11.67L13.41,10.41C13.78,10.05 14,9.55 14,9C14,7.89 13.1,7 12,7A2,2 0 0,0 10,9H8A4,4 0 0,1 12,5A4,4 0 0,1 16,9C16,9.88 15.64,10.67 15.07,11.25M13,19H11V17H13M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12C22,6.47 17.5,2 12,2Z" />
|
|
||||||
</svg>
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
onClick={this.props.keyboardShortcutsBtnClickHandler}
|
|
||||||
data-event-category="ui"
|
|
||||||
data-event-action="keyboardShortcutButtonClick"
|
|
||||||
class="footer__link hint--rounded hint--top-right hide-on-mobile"
|
|
||||||
aria-label="Keyboard shortcuts"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
style={{
|
|
||||||
width: '20px',
|
|
||||||
height: '20px',
|
|
||||||
verticalAlign: 'text-bottom'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<use xlinkHref="#keyboard-icon" />
|
|
||||||
</svg>
|
|
||||||
</Button>
|
|
||||||
<a
|
|
||||||
class="footer__link hint--rounded hint--top-right"
|
|
||||||
aria-label="Tweet about 'Web Maker'"
|
|
||||||
href="http://twitter.com/share?url=https://webmakerapp.com/&text=Web Maker - A blazing fast %26 offline web playground! via @webmakerApp&related=webmakerApp&hashtags=web,frontend,playground,offline"
|
|
||||||
target="_blank"
|
|
||||||
rel="noopener noreferrer"
|
|
||||||
>
|
|
||||||
<svg
|
|
||||||
style={{
|
|
||||||
width: '20px',
|
|
||||||
height: '20px',
|
|
||||||
verticalAlign: 'text-bottom'
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<use xlinkHref="#twitter-icon" />
|
|
||||||
</svg>
|
|
||||||
</a>
|
|
||||||
<Button
|
|
||||||
onClick={this.props.supportDeveloperBtnClickHandler}
|
|
||||||
data-event-category="ui"
|
|
||||||
data-event-action="supportDeveloperFooterBtnClick"
|
|
||||||
class="footer__link ml-1 hint--rounded hint--top-right hide-on-mobile support-link"
|
|
||||||
aria-label="Support the developer by pledging some amount"
|
|
||||||
>
|
|
||||||
Support the developer
|
|
||||||
</Button>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
74
src/components/Js13KModal.jsx
Normal file
74
src/components/Js13KModal.jsx
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
import { h } from 'preact';
|
||||||
|
import Modal from './Modal';
|
||||||
|
|
||||||
|
export function Js13KModal({ show, closeHandler }) {
|
||||||
|
return (
|
||||||
|
<Modal show={show} closeHandler={closeHandler} small>
|
||||||
|
<div class="tac">
|
||||||
|
<div className="flex flex-v-center flex-h-center ">
|
||||||
|
<img
|
||||||
|
src="/icon-128.png"
|
||||||
|
alt="Web Maker logo"
|
||||||
|
height="100"
|
||||||
|
style="margin:0 0.5rem;"
|
||||||
|
/>
|
||||||
|
<h2>Web Maker</h2>
|
||||||
|
<span style="font-size:3rem;margin:0 1rem;">➕</span>
|
||||||
|
<h2>JS13K Games</h2>
|
||||||
|
<img
|
||||||
|
src="http://js13kgames.com/img/logo.png"
|
||||||
|
alt="JS13K Games logo"
|
||||||
|
height="100"
|
||||||
|
style="margin:0 0.5rem;"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p>
|
||||||
|
<strong>Js13kGames</strong> is a JavaScript coding competition for{' '}
|
||||||
|
<strong>HTML5 Game Developers</strong>. The fun part of the compo is
|
||||||
|
the file size limit set to <strong>13 kilobytes</strong>. The
|
||||||
|
competition will start at <strong>13:00 CEST, 13th August</strong> and
|
||||||
|
will end at <strong>13:00 CEST, 13th September 2018</strong>.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Web Maker is an frontend playground that works offline! You can play
|
||||||
|
around quickly with HTML, JavaScript & CSS to build your awesome game
|
||||||
|
right here.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="https://gamedevelopment.tutsplus.com/articles/how-to-minify-your-html5-game-for-the-js13kgames-competition--cms-21883"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Read Tuts+ Gamedev intro article
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="http://js13kgames.github.io/resources/"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Resources and useful tools
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a
|
||||||
|
href="http://2018.js13kgames.com/#rules"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>
|
||||||
|
Compo rules
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>Have fun building games!</p>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
@@ -56,7 +56,9 @@ export default class Modal extends Component {
|
|||||||
return (
|
return (
|
||||||
<Portal into="body">
|
<Portal into="body">
|
||||||
<div
|
<div
|
||||||
class={`${this.props.extraClasses || ''} modal is-modal-visible`}
|
class={`${this.props.extraClasses || ''} modal is-modal-visible ${
|
||||||
|
this.props.small ? 'modal--small' : ''
|
||||||
|
}`}
|
||||||
ref={el => (this.overlayEl = el)}
|
ref={el => (this.overlayEl = el)}
|
||||||
onClick={this.onOverlayClick.bind(this)}
|
onClick={this.onOverlayClick.bind(this)}
|
||||||
>
|
>
|
||||||
|
@@ -286,6 +286,14 @@ export default class Settings extends Component {
|
|||||||
pref={this.props.prefs.isCodeBlastOn}
|
pref={this.props.prefs.isCodeBlastOn}
|
||||||
onChange={this.updateSetting.bind(this)}
|
onChange={this.updateSetting.bind(this)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<CheckboxSetting
|
||||||
|
title="Get ready to build some games at JS13KGames"
|
||||||
|
label="JS13KGames Mode"
|
||||||
|
name="isJs13kModeOn"
|
||||||
|
pref={this.props.prefs.isJs13kModeOn}
|
||||||
|
onChange={this.updateSetting.bind(this)}
|
||||||
|
/>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
@@ -10,13 +10,15 @@ import SavedItemPane from './SavedItemPane.jsx';
|
|||||||
import AddLibrary from './AddLibrary.jsx';
|
import AddLibrary from './AddLibrary.jsx';
|
||||||
import Modal from './Modal.jsx';
|
import Modal from './Modal.jsx';
|
||||||
import Login from './Login.jsx';
|
import Login from './Login.jsx';
|
||||||
|
import { computeHtml, computeCss, computeJs } from '../computes';
|
||||||
import {
|
import {
|
||||||
log,
|
log,
|
||||||
generateRandomId,
|
generateRandomId,
|
||||||
semverCompare,
|
semverCompare,
|
||||||
saveAsHtml,
|
saveAsHtml,
|
||||||
handleDownloadsPermission,
|
handleDownloadsPermission,
|
||||||
downloadFile
|
downloadFile,
|
||||||
|
getCompleteHtml
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
import { itemService } from '../itemService';
|
import { itemService } from '../itemService';
|
||||||
import '../db';
|
import '../db';
|
||||||
@@ -38,7 +40,9 @@ import { Alerts } from './Alerts';
|
|||||||
import Portal from 'preact-portal';
|
import Portal from 'preact-portal';
|
||||||
import { HelpModal } from './HelpModal';
|
import { HelpModal } from './HelpModal';
|
||||||
import { OnboardingModal } from './OnboardingModal';
|
import { OnboardingModal } from './OnboardingModal';
|
||||||
|
import { Js13KModal } from './Js13KModal';
|
||||||
import { Icons } from './Icons';
|
import { Icons } from './Icons';
|
||||||
|
import JSZip from 'jszip';
|
||||||
|
|
||||||
if (module.hot) {
|
if (module.hot) {
|
||||||
require('preact/debug');
|
require('preact/debug');
|
||||||
@@ -68,6 +72,7 @@ export default class App extends Component {
|
|||||||
isKeyboardShortcutsModalOpen: false,
|
isKeyboardShortcutsModalOpen: false,
|
||||||
isAskToImportModalOpen: false,
|
isAskToImportModalOpen: false,
|
||||||
isOnboardModalOpen: false,
|
isOnboardModalOpen: false,
|
||||||
|
isJs13KModalOpen: false,
|
||||||
prefs: {},
|
prefs: {},
|
||||||
currentItem: {
|
currentItem: {
|
||||||
title: '',
|
title: '',
|
||||||
@@ -96,7 +101,8 @@ export default class App extends Component {
|
|||||||
lightVersion: false,
|
lightVersion: false,
|
||||||
lineWrap: true,
|
lineWrap: true,
|
||||||
infiniteLoopTimeout: 1000,
|
infiniteLoopTimeout: 1000,
|
||||||
layoutMode: 2
|
layoutMode: 2,
|
||||||
|
isJs13kModeOn: false
|
||||||
};
|
};
|
||||||
this.prefs = {};
|
this.prefs = {};
|
||||||
|
|
||||||
@@ -493,7 +499,8 @@ export default class App extends Component {
|
|||||||
isSupportDeveloperModalOpen: false,
|
isSupportDeveloperModalOpen: false,
|
||||||
isKeyboardShortcutsModalOpen: false,
|
isKeyboardShortcutsModalOpen: false,
|
||||||
isAskToImportModalOpen: false,
|
isAskToImportModalOpen: false,
|
||||||
isOnboardModalOpen: false
|
isOnboardModalOpen: false,
|
||||||
|
isJs13KModalOpen: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
onExternalLibChange(newValues) {
|
onExternalLibChange(newValues) {
|
||||||
@@ -697,6 +704,7 @@ export default class App extends Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.calculateCodeSize();
|
||||||
}
|
}
|
||||||
onCodeSettingsChange(type, settings) {
|
onCodeSettingsChange(type, settings) {
|
||||||
this.state.currentItem[`${type}Settings`] = {
|
this.state.currentItem[`${type}Settings`] = {
|
||||||
@@ -973,6 +981,138 @@ export default class App extends Component {
|
|||||||
this.state.currentItem.mainSizes = this.getMainPaneSizes();
|
this.state.currentItem.mainSizes = this.getMainPaneSizes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculate byte size of a text snippet
|
||||||
|
* @author Lea Verou
|
||||||
|
* MIT License
|
||||||
|
*/
|
||||||
|
calculateTextSize(text) {
|
||||||
|
if (!text) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
var crlf = /(\r?\n|\r)/g,
|
||||||
|
whitespace = /(\r?\n|\r|\s+)/g;
|
||||||
|
|
||||||
|
const ByteSize = {
|
||||||
|
count: function(text, options) {
|
||||||
|
// Set option defaults
|
||||||
|
options = options || {};
|
||||||
|
options.lineBreaks = options.lineBreaks || 1;
|
||||||
|
options.ignoreWhitespace = options.ignoreWhitespace || false;
|
||||||
|
|
||||||
|
var length = text.length,
|
||||||
|
nonAscii = length - text.replace(/[\u0100-\uFFFF]/g, '').length,
|
||||||
|
lineBreaks = length - text.replace(crlf, '').length;
|
||||||
|
|
||||||
|
if (options.ignoreWhitespace) {
|
||||||
|
// Strip whitespace
|
||||||
|
text = text.replace(whitespace, '');
|
||||||
|
|
||||||
|
return text.length + nonAscii;
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
length +
|
||||||
|
nonAscii +
|
||||||
|
Math.max(0, options.lineBreaks * (lineBreaks - 1))
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
format: function(count, plainText) {
|
||||||
|
var level = 0;
|
||||||
|
|
||||||
|
while (count > 1024) {
|
||||||
|
count /= 1024;
|
||||||
|
level++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Round to 2 decimals
|
||||||
|
count = Math.round(count * 100) / 100;
|
||||||
|
|
||||||
|
level = ['', 'K', 'M', 'G', 'T'][level];
|
||||||
|
|
||||||
|
return (
|
||||||
|
(plainText ? count : '<strong>' + count + '</strong>') +
|
||||||
|
' ' +
|
||||||
|
level +
|
||||||
|
'B'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return ByteSize.count(text);
|
||||||
|
}
|
||||||
|
getExternalLibCode() {
|
||||||
|
const item = this.state.currentItem;
|
||||||
|
var libs = (item.externalLibs && item.externalLibs.js) || '';
|
||||||
|
libs += ('\n' + item.externalLibs && item.externalLibs.css) || '';
|
||||||
|
libs = libs.split('\n').filter(lib => lib);
|
||||||
|
return libs.map(lib =>
|
||||||
|
fetch(lib)
|
||||||
|
.then(res => res.text())
|
||||||
|
.then(data => {
|
||||||
|
return {
|
||||||
|
code: data,
|
||||||
|
url: 'dsfds'
|
||||||
|
};
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
calculateCodeSize() {
|
||||||
|
const item = this.state.currentItem;
|
||||||
|
var htmlPromise = computeHtml(item.html, item.htmlMode);
|
||||||
|
var cssPromise = computeCss(item.css, item.cssMode);
|
||||||
|
var jsPromise = computeJs(item.js, item.jsMode, false);
|
||||||
|
Promise.all([
|
||||||
|
htmlPromise,
|
||||||
|
cssPromise,
|
||||||
|
jsPromise,
|
||||||
|
...this.getExternalLibCode()
|
||||||
|
]).then(result => {
|
||||||
|
var html = result[0].code || '',
|
||||||
|
css = result[1].code || '',
|
||||||
|
js = result[2].code || '';
|
||||||
|
|
||||||
|
var fileContent = getCompleteHtml(html, css, js, item, true);
|
||||||
|
|
||||||
|
var zip = new JSZip();
|
||||||
|
// Add an top-level, arbitrary text file with contents
|
||||||
|
zip.file('index.html', fileContent);
|
||||||
|
[result[3]].map(externalLib =>
|
||||||
|
zip.file(externalLib.name, externalLib.code)
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log('ORIGINAL', this.calculateTextSize(fileContent));
|
||||||
|
|
||||||
|
var promise = null;
|
||||||
|
if (0 && JSZip.support.uint8array) {
|
||||||
|
promise = zip.generateAsync({ type: 'uint8array' });
|
||||||
|
} else {
|
||||||
|
promise = zip.generateAsync({
|
||||||
|
type: 'string',
|
||||||
|
compression: 'DEFLATE',
|
||||||
|
compressionOptions: {
|
||||||
|
level: 9
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
promise.then(data => {
|
||||||
|
const zipContent = data;
|
||||||
|
const size = this.calculateTextSize(data);
|
||||||
|
this.setState({
|
||||||
|
codeSize: size
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
js13KBtnClickHandler() {
|
||||||
|
this.setState({
|
||||||
|
isJs13KModalOpen: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -1006,6 +1146,7 @@ export default class App extends Component {
|
|||||||
/>
|
/>
|
||||||
<div class="global-console-container" id="globalConsoleContainerEl" />
|
<div class="global-console-container" id="globalConsoleContainerEl" />
|
||||||
<Footer
|
<Footer
|
||||||
|
prefs={this.state.prefs}
|
||||||
layoutBtnClickHandler={this.layoutBtnClickHandler.bind(this)}
|
layoutBtnClickHandler={this.layoutBtnClickHandler.bind(this)}
|
||||||
helpBtnClickHandler={() => this.setState({ isHelpModalOpen: true })}
|
helpBtnClickHandler={() => this.setState({ isHelpModalOpen: true })}
|
||||||
settingsBtnClickHandler={() =>
|
settingsBtnClickHandler={() =>
|
||||||
@@ -1028,7 +1169,9 @@ export default class App extends Component {
|
|||||||
screenshotBtnClickHandler={this.screenshotBtnClickHandler.bind(
|
screenshotBtnClickHandler={this.screenshotBtnClickHandler.bind(
|
||||||
this
|
this
|
||||||
)}
|
)}
|
||||||
|
onJs13KBtnClick={this.js13KBtnClickHandler.bind(this)}
|
||||||
hasUnseenChangelog={this.state.hasUnseenChangelog}
|
hasUnseenChangelog={this.state.hasUnseenChangelog}
|
||||||
|
codeSize={this.state.codeSize}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -1145,6 +1288,11 @@ export default class App extends Component {
|
|||||||
closeHandler={() => this.setState({ isOnboardModalOpen: false })}
|
closeHandler={() => this.setState({ isOnboardModalOpen: false })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<Js13KModal
|
||||||
|
show={this.state.isJs13KModalOpen}
|
||||||
|
closeHandler={() => this.setState({ isJs13KModalOpen: false })}
|
||||||
|
/>
|
||||||
|
|
||||||
<Portal into="body">
|
<Portal into="body">
|
||||||
<div
|
<div
|
||||||
class="modal-overlay"
|
class="modal-overlay"
|
||||||
|
@@ -573,6 +573,8 @@ body > #demo-frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.footer {
|
.footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
/* Because .console is 6 */
|
/* Because .console is 6 */
|
||||||
z-index: 6;
|
z-index: 6;
|
||||||
}
|
}
|
||||||
@@ -852,7 +854,8 @@ body > #demo-frame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.pledge-modal .modal__content,
|
.pledge-modal .modal__content,
|
||||||
.ask-to-import-modal .modal__content {
|
.ask-to-import-modal .modal__content,
|
||||||
|
.modal--small .modal__content {
|
||||||
max-width: 800px;
|
max-width: 800px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1506,6 +1509,16 @@ body:not(.is-app) .show-when-app {
|
|||||||
visibility: visible;
|
visibility: visible;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.footer__js13k-text {
|
||||||
|
padding: 1px 9px;
|
||||||
|
text-transform: uppercase;
|
||||||
|
background: #b12a34;
|
||||||
|
color: white;
|
||||||
|
border-radius: 3px;
|
||||||
|
letter-spacing: 0.7px;
|
||||||
|
margin-left: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 600px) {
|
@media screen and (max-width: 600px) {
|
||||||
body {
|
body {
|
||||||
font-size: 70%;
|
font-size: 70%;
|
||||||
|
@@ -378,7 +378,7 @@ export function saveAsHtml(item) {
|
|||||||
var htmlPromise = computeHtml(item.html, item.htmlMode);
|
var htmlPromise = computeHtml(item.html, item.htmlMode);
|
||||||
var cssPromise = computeCss(item.css, item.cssMode);
|
var cssPromise = computeCss(item.css, item.cssMode);
|
||||||
var jsPromise = computeJs(item.js, item.jsMode, false);
|
var jsPromise = computeJs(item.js, item.jsMode, false);
|
||||||
Promise.all([htmlPromise, cssPromise, jsPromise]).then(function(result) {
|
Promise.all([htmlPromise, cssPromise, jsPromise]).then(result => {
|
||||||
var html = result[0].code,
|
var html = result[0].code,
|
||||||
css = result[1].code,
|
css = result[1].code,
|
||||||
js = result[2].code;
|
js = result[2].code;
|
||||||
|
45
yarn.lock
45
yarn.lock
@@ -2467,6 +2467,10 @@ core-js@^2.4.0, core-js@^2.5.0:
|
|||||||
version "2.5.7"
|
version "2.5.7"
|
||||||
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e"
|
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.5.7.tgz#f972608ff0cead68b841a16a932d0b183791814e"
|
||||||
|
|
||||||
|
core-js@~2.3.0:
|
||||||
|
version "2.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.3.0.tgz#fab83fbb0b2d8dc85fa636c4b9d34c75420c6d65"
|
||||||
|
|
||||||
core-util-is@1.0.2, core-util-is@~1.0.0:
|
core-util-is@1.0.2, core-util-is@~1.0.0:
|
||||||
version "1.0.2"
|
version "1.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"
|
||||||
@@ -3242,6 +3246,10 @@ es6-promise@^4.0.5:
|
|||||||
version "4.2.4"
|
version "4.2.4"
|
||||||
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"
|
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"
|
||||||
|
|
||||||
|
es6-promise@~3.0.2:
|
||||||
|
version "3.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.0.2.tgz#010d5858423a5f118979665f46486a95c6ee2bb6"
|
||||||
|
|
||||||
es6-set@~0.1.5:
|
es6-set@~0.1.5:
|
||||||
version "0.1.5"
|
version "0.1.5"
|
||||||
resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1"
|
resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1"
|
||||||
@@ -4812,6 +4820,10 @@ ignore@^3.3.3, ignore@^3.3.5:
|
|||||||
version "3.3.8"
|
version "3.3.8"
|
||||||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.8.tgz#3f8e9c35d38708a3a7e0e9abb6c73e7ee7707b2b"
|
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.8.tgz#3f8e9c35d38708a3a7e0e9abb6c73e7ee7707b2b"
|
||||||
|
|
||||||
|
immediate@~3.0.5:
|
||||||
|
version "3.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b"
|
||||||
|
|
||||||
immutability-helper@^2.1.2:
|
immutability-helper@^2.1.2:
|
||||||
version "2.7.0"
|
version "2.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/immutability-helper/-/immutability-helper-2.7.0.tgz#4ea9916cc8f45142ec3e3f0fce75fa5d66fa1b38"
|
resolved "https://registry.yarnpkg.com/immutability-helper/-/immutability-helper-2.7.0.tgz#4ea9916cc8f45142ec3e3f0fce75fa5d66fa1b38"
|
||||||
@@ -5752,6 +5764,16 @@ jsx-ast-utils@^2.0.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
array-includes "^3.0.3"
|
array-includes "^3.0.3"
|
||||||
|
|
||||||
|
jszip@^3.1.5:
|
||||||
|
version "3.1.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.1.5.tgz#e3c2a6c6d706ac6e603314036d43cd40beefdf37"
|
||||||
|
dependencies:
|
||||||
|
core-js "~2.3.0"
|
||||||
|
es6-promise "~3.0.2"
|
||||||
|
lie "~3.1.0"
|
||||||
|
pako "~1.0.2"
|
||||||
|
readable-stream "~2.0.6"
|
||||||
|
|
||||||
killable@^1.0.0:
|
killable@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.0.tgz#da8b84bd47de5395878f95d64d02f2449fe05e6b"
|
resolved "https://registry.yarnpkg.com/killable/-/killable-1.0.0.tgz#da8b84bd47de5395878f95d64d02f2449fe05e6b"
|
||||||
@@ -5823,6 +5845,12 @@ levn@^0.3.0, levn@~0.3.0:
|
|||||||
prelude-ls "~1.1.2"
|
prelude-ls "~1.1.2"
|
||||||
type-check "~0.3.2"
|
type-check "~0.3.2"
|
||||||
|
|
||||||
|
lie@~3.1.0:
|
||||||
|
version "3.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/lie/-/lie-3.1.1.tgz#9a436b2cc7746ca59de7a41fa469b3efb76bd87e"
|
||||||
|
dependencies:
|
||||||
|
immediate "~3.0.5"
|
||||||
|
|
||||||
liftoff@^2.1.0:
|
liftoff@^2.1.0:
|
||||||
version "2.5.0"
|
version "2.5.0"
|
||||||
resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.5.0.tgz#2009291bb31cea861bbf10a7c15a28caf75c31ec"
|
resolved "https://registry.yarnpkg.com/liftoff/-/liftoff-2.5.0.tgz#2009291bb31cea861bbf10a7c15a28caf75c31ec"
|
||||||
@@ -6993,7 +7021,7 @@ package-json@^4.0.0:
|
|||||||
registry-url "^3.0.3"
|
registry-url "^3.0.3"
|
||||||
semver "^5.1.0"
|
semver "^5.1.0"
|
||||||
|
|
||||||
pako@~1.0.5:
|
pako@~1.0.2, pako@~1.0.5:
|
||||||
version "1.0.6"
|
version "1.0.6"
|
||||||
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
|
resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.6.tgz#0101211baa70c4bca4a0f63f2206e97b7dfaf258"
|
||||||
|
|
||||||
@@ -7694,6 +7722,10 @@ process-nextick-args@^2.0.0, process-nextick-args@~2.0.0:
|
|||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
|
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"
|
||||||
|
|
||||||
|
process-nextick-args@~1.0.6:
|
||||||
|
version "1.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"
|
||||||
|
|
||||||
process@^0.11.10:
|
process@^0.11.10:
|
||||||
version "0.11.10"
|
version "0.11.10"
|
||||||
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
|
resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182"
|
||||||
@@ -7960,6 +7992,17 @@ readable-stream@~1.1.9:
|
|||||||
isarray "0.0.1"
|
isarray "0.0.1"
|
||||||
string_decoder "~0.10.x"
|
string_decoder "~0.10.x"
|
||||||
|
|
||||||
|
readable-stream@~2.0.6:
|
||||||
|
version "2.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.0.6.tgz#8f90341e68a53ccc928788dacfcd11b36eb9b78e"
|
||||||
|
dependencies:
|
||||||
|
core-util-is "~1.0.0"
|
||||||
|
inherits "~2.0.1"
|
||||||
|
isarray "~1.0.0"
|
||||||
|
process-nextick-args "~1.0.6"
|
||||||
|
string_decoder "~0.10.x"
|
||||||
|
util-deprecate "~1.0.1"
|
||||||
|
|
||||||
readdirp@^2.0.0:
|
readdirp@^2.0.0:
|
||||||
version "2.1.0"
|
version "2.1.0"
|
||||||
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78"
|
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.1.0.tgz#4ed0ad060df3073300c48440373f72d1cc642d78"
|
||||||
|
Reference in New Issue
Block a user