TheDesk Akane (16.0.1)
This commit is contained in:
parent
b3ff01188c
commit
a2a937e220
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -6,3 +6,4 @@ app/.DS_Store
|
|||
.DS_Store
|
||||
enq.md
|
||||
app/.tkn
|
||||
app/node_modules
|
18
LATEST.md
18
LATEST.md
|
@ -1,23 +1,13 @@
|
|||
## For Astarte(kirishima.cloud), My Primary Instance
|
||||
|
||||
TheDesk :thedesk: Mio (15.10.0)
|
||||
・音声読み上げに対応
|
||||
・Twitterのツイートに対するリンクをリッチに表示
|
||||
・削除追跡取り下げ
|
||||
・アップデートスキップの有効期限を次バージョン時にする機能
|
||||
・CINDERELLA NowPlaying(imastodon.net).
|
||||
・ライセンス変更(v5)
|
||||
TheDesk :thedesk: Akane (16.0.1)
|
||||
|
||||
ほか
|
||||
https://thedesk.top
|
||||
:github: https://github.com/cutls/TheDesk #Desk #DeskUpdate
|
||||
|
||||
## For Other Instances
|
||||
|
||||
PCクライアントTheDesk Mio (15.10.0)
|
||||
・音声読み上げに対応
|
||||
・Twitterのツイートに対するリンクをリッチに表示
|
||||
・削除追跡取り下げ
|
||||
・アップデートスキップの有効期限を次バージョン時にする機能
|
||||
・CINDERELLA NowPlaying(imastodon.net).
|
||||
・ライセンス変更(v5)
|
||||
TheDesk :thedesk: Akane (16.0.1)
|
||||
|
||||
https://thedesk.top
|
|
@ -0,0 +1,81 @@
|
|||
<!doctype html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<title>Account Manager - TheDesk</title>
|
||||
<meta content="width=device-width,initial-scale=1.0" name="viewport">
|
||||
<link href="./css/materialize.css" type="text/css" rel="stylesheet">
|
||||
<link href="./css/themes.css" type="text/css" rel="stylesheet">
|
||||
<link href="./css/master.css" type="text/css" rel="stylesheet">
|
||||
<link href='./css/font-awesome.css' rel='stylesheet' type='text/css'>
|
||||
<link href='./css/tl.css' rel='stylesheet' type='text/css'>
|
||||
<link href='./css/userdata.css' rel='stylesheet' type='text/css'>
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Open+Sans:300" rel="stylesheet">
|
||||
<style>.acct{display:flex; justify-content:space-around;}
|
||||
.card{width:400px; background-color: #9e9e9e; margin:10px; }
|
||||
body,html{overflow-y: scroll;}
|
||||
#acct-list{display:flex; flex-wrap:wrap; color:white; align-items: flex-start}
|
||||
.lts{font-size:150%}
|
||||
.colorsel{ display:flex; }
|
||||
.card .colorsel div:not(.exc){width:20px;height:20px;}
|
||||
.card .colorsel div.exc{width:40px;height:20px;}
|
||||
</style>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body id="mainView">
|
||||
<script type="text/javascript" src="./js/common/jquery.js"></script>
|
||||
<script type="text/javascript" src="./js/platform/first.js"></script>
|
||||
<script type="text/javascript" src="./js/common/materialize.js"></script>
|
||||
<script type="text/javascript" src="./js/lang/lang.js"></script>
|
||||
<script>
|
||||
var lang="ja";
|
||||
</script>
|
||||
<script type="text/javascript" src="./js/ui/tips.js"></script>
|
||||
<script type="text/javascript" src="./js/common/time.js"></script>
|
||||
<script type="text/javascript" src="./js/common/modal.js"></script>
|
||||
<a href="index.html" class="btn waves-effect orange nex" style="width:100%; max-width:200px;">戻る</a><br>
|
||||
<h5>アカウント一覧</h5>
|
||||
<div id="acct-list"></div>
|
||||
<div class="divider"></div>
|
||||
<h5>アカウントを追加</h5><br>
|
||||
<div id="add">
|
||||
<div class="row">
|
||||
<div class="col s6">
|
||||
<input type="text" id="url" style="width:70%" placeholder="ex)mstdn.jp">
|
||||
<div id="ins-suggest"></div>
|
||||
Windows以外でご使用の方やPleromaにログインされる方はチェックを入れて下さい。<br>
|
||||
<input type="checkbox" class="filled-in" id="linux" />
|
||||
<label for="linux">コードセットアップ</label><br>
|
||||
<button class="btn waves-effect" onclick="instance()">Login</button><br>
|
||||
</div>
|
||||
<div class="col s6">
|
||||
<span style="font-family:Open Sans;">Supports</span>
|
||||
<div id="support" class="collection transparent"></div>
|
||||
</div>
|
||||
</div>
|
||||
<h5>メインアカウント</h5>
|
||||
<div class="input-field" style="width:300px"><span data-trans="your_acct">アカウントを選択</span>
|
||||
<br>
|
||||
<select id="main-acct-sel" class="acct-sel" style="color:black" onchange="mainacct()"></select>
|
||||
<label></label>
|
||||
</div>
|
||||
</div>
|
||||
<div id="auth" style="display:none">
|
||||
指定されたコードを貼り付けてください。ログインウィンドウは閉じていただいて構いません。<br>
|
||||
<input type="text" id="code" placeholder="コードを入力">
|
||||
<button class="btn waves-effect" onclick="code()">Auth</button><br>
|
||||
</div>
|
||||
Instance data by <a href="https://instances.social" target="_blank">instances.social API</a><br>
|
||||
<img src="./img/loading.svg" id="ins-prof" width="200"><br>
|
||||
@<span id="ins-upd"></span><br>
|
||||
ドメイン名:<span id="ins-name"></span><br>
|
||||
接続インスタンス数:<span id="ins-connect"></span>個<br>
|
||||
トゥート数:<span id="ins-toot"></span>個<br>
|
||||
ユーザー数:<span id="ins-user"></span>ユーザー数<br>
|
||||
コネクション:<span id="ins-per"></span>%<br>
|
||||
Mastodonバージョン:<span id="ins-ver"></span><br>
|
||||
<script type="text/javascript" src="./js/ui/theme.js"></script>
|
||||
<script type="text/javascript" src="./js/platform/end.js"></script>
|
||||
<script type="text/javascript" src="./js/common/sha256.js"></script>
|
||||
<script type="text/javascript" src="./js/login/instance.js"></script>
|
||||
<script type="text/javascript" src="./js/login/manager.js"></script>
|
||||
<script type="text/javascript" src="./js/tl/date.js"></script>
|
|
@ -26,7 +26,7 @@
|
|||
<script type="text/javascript" src="./js/common/modal.js"></script>
|
||||
<script type="text/javascript" src="./js/ui/jquery-ui.min.js"></script>
|
||||
<script>
|
||||
var ver="Akane (16.0.0)";
|
||||
var ver="Akane (16.0.1)";
|
||||
//betaを入れるとバージョンチェックしない
|
||||
//GitHubに上げるときはindex.htmlをちゃんとする。(index.start.html)
|
||||
//var ver="beta";
|
||||
|
@ -521,8 +521,19 @@ var lang="{{lang}}";
|
|||
<h3>TheDesk</h3>
|
||||
<a href="https://thedesk.top" target="_blank">HP</a><br>
|
||||
<a href="https://github.com/cutls/TheDesk" target="_blank">GitHub</a><br><br>
|
||||
<div id="release-Akane_16-0-0" style="display:none">
|
||||
<h5>Release Note Akane (16.0.0)</h5>
|
||||
<div id="release-Akane_16-0-1" style="display:none">
|
||||
<h5>Release Note Akane (16.0.1)</h5>
|
||||
<b>アップデートでTLが表示できなくなったユーザー様へ</b><br>
|
||||
今回のバージョンで設定のインポート/エクスポートを実装いたしました。<br>
|
||||
設定より一度エクスポートしていただき、もう一度インポートすることにより正常に動作すると思われます。<br>
|
||||
<u>開発環境でこのバグが再現できなかったため、あくまでも憶測による対処です。</u><br>
|
||||
<br>
|
||||
ご迷惑をおかけいたしましたことを深くお詫び申し上げます。<br>
|
||||
16.0.1<br>
|
||||
<ul>
|
||||
<li>(β)Windows環境ではアップデート時に自動で展開を行います。ダウンロードを押すだけでアップデートは完結します。</li>
|
||||
</ul>
|
||||
16.0.0
|
||||
<ul>
|
||||
<li>言語設定:英語に対応</li>
|
||||
<li>Misskeyに暫定対応</li>
|
||||
|
|
|
@ -98,3 +98,27 @@ var lang_setting_main={
|
|||
"ja":"起動時・投稿時のアカウントを{{set}}に設定しました。",
|
||||
"en":"Default account:{{set}}"
|
||||
}
|
||||
var lang_setting_ksref={
|
||||
"ja":"キーボードショートカットが更新されました。",
|
||||
"en":"Keyboard shortcuts are refreshed."
|
||||
}
|
||||
var lang_setting_nomuting={
|
||||
"ja":"ミュートしているクライアントはありません。",
|
||||
"en":"No client is muted."
|
||||
}
|
||||
var lang_setting_notftest={
|
||||
"ja":"通知テスト",
|
||||
"en":" Notification test "
|
||||
}
|
||||
var lang_setting_notftestprof={
|
||||
"ja":"アイコンはあなたのアカウントのものです。",
|
||||
"en":"Your icon is shown."
|
||||
}
|
||||
var lang_setting_exportwarn={
|
||||
"ja":"重要なデータのみエクスポートされます。エクスポートされたデータは外部に公開しないでください。全ての認証データが含まれています。",
|
||||
"en":"Only important data will be exported. You must keep this data secure."
|
||||
}
|
||||
var lang_setting_importwarn={
|
||||
"ja":"全てのデータがリセットされます。",
|
||||
"en":"All data will be deleted."
|
||||
}
|
|
@ -168,4 +168,13 @@ function progshow(e) {
|
|||
ipc.on('reload', function (event, arg) {
|
||||
location.reload();
|
||||
})
|
||||
ipc.on('mess', function (event, arg) {
|
||||
if(arg=="unzip"){
|
||||
if(lang=="ja"){
|
||||
$("body").text("アップデートを展開中です。");
|
||||
}else{
|
||||
$("body").text("Unzipping...");
|
||||
}
|
||||
|
||||
}
|
||||
})
|
|
@ -6,6 +6,9 @@ $voise = null;
|
|||
$synthes.voice = $voise; // 音声の設定
|
||||
localStorage.removeItem("voicebank");
|
||||
speechSynthesis.cancel()
|
||||
if(!localStorage.getItem("voice_vol")){
|
||||
localStorage.setItem("voice_vol",1)
|
||||
}
|
||||
$synthes.rate=localStorage.getItem("voice_speed");
|
||||
$synthes.pitch=localStorage.getItem("voice_pitch");
|
||||
$synthes.volume=localStorage.getItem("voice_vol");
|
||||
|
@ -30,6 +33,7 @@ $repeat = setInterval(function() {
|
|||
var obj = JSON.parse(voice);
|
||||
if(obj[0]){
|
||||
$synthes.text = obj[0];
|
||||
console.log($synthes);
|
||||
speechSynthesis.speak($synthes);
|
||||
obj.splice(0, 1);
|
||||
var json = JSON.stringify(obj);
|
||||
|
|
|
@ -224,7 +224,7 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice) {
|
|||
if (JSON.parse(mess.data).type == "note") {
|
||||
var obj = JSON.parse(mess.data).body;
|
||||
if(voice){
|
||||
say(obj.content)
|
||||
say(obj.text)
|
||||
}
|
||||
var templete = misskeyParse([obj], type, acct_id, tlid,"",mute);
|
||||
var pool = localStorage.getItem("pool_" + tlid);
|
||||
|
|
|
@ -16,6 +16,7 @@ function addToggle() {
|
|||
}
|
||||
//最初、カラム変更時に発火
|
||||
function parseColumn() {
|
||||
console.log("parse");
|
||||
var size = localStorage.getItem("size");
|
||||
if (size) {
|
||||
$("#timeline-container").css("font-size", size + "px");
|
||||
|
|
|
@ -318,10 +318,10 @@ function climute(){
|
|||
var cli = localStorage.getItem("client_mute");
|
||||
var obj = JSON.parse(cli);
|
||||
if(!obj){
|
||||
$("#mute-cli").html("ミュートしているクライアントはありません。");
|
||||
$("#mute-cli").html(lang_setting_nomuting[lang]);
|
||||
}else{
|
||||
if(!obj[0]){
|
||||
$("#mute-cli").html("ミュートしているクライアントはありません。");
|
||||
$("#mute-cli").html(lang_setting_nomuting[lang]);
|
||||
return;
|
||||
}
|
||||
var templete;
|
||||
|
@ -331,7 +331,7 @@ function climute(){
|
|||
templete = '<div class="acct" id="acct_' + key + '">' + list +
|
||||
'.' +
|
||||
cli + '<button class="btn waves-effect red disTar" onclick="cliMuteDel(' +
|
||||
key + ')">削除</button><br></div>';
|
||||
key + ')">'+lang_del[lang]+'</button><br></div>';
|
||||
$("#mute-cli").append(templete);
|
||||
});
|
||||
}
|
||||
|
@ -371,27 +371,183 @@ function wordempSave(){
|
|||
localStorage.setItem("word_emp", json);
|
||||
}
|
||||
function notftest(){
|
||||
var electron = require("electron");
|
||||
var electron = require("electron");
|
||||
var ipc = electron.ipcRenderer;
|
||||
var os = electron.remote.process.platform;
|
||||
var options = {
|
||||
body: '通知テスト(画像はあなたのアカウントのアイコンです)',
|
||||
body: lang_setting_notftest[lang]+'('+lang_setting_notftestprof[lang]+')',
|
||||
icon: localStorage.getItem("prof_0")
|
||||
};
|
||||
if(os=="darwin"){
|
||||
var n = new Notification('TheDesk通知テスト', options);
|
||||
var n = new Notification('TheDesk'+lang_setting_notftest[lang], options);
|
||||
}else{
|
||||
ipc.send('native-notf', ['TheDesk通知テスト','通知テスト(画像はあなたのアカウントのアイコンです)',localStorage.getItem('prof_0')]);
|
||||
ipc.send('native-notf', ['TheDesk'+lang_setting_notftest[lang],lang_setting_notftest[lang]+'('+lang_setting_notftestprof[lang]+')',localStorage.getItem('prof_0')]);
|
||||
}
|
||||
|
||||
}
|
||||
function oks(no){
|
||||
var txt=$("#oks-"+no).val();
|
||||
localStorage.setItem("oks-"+no, txt);
|
||||
Materialize.toast("キーボードショートカットを更新しました。", 3000);
|
||||
Materialize.toast(lang_setting_ksref[lang], 3000);
|
||||
}
|
||||
function oksload(){
|
||||
if(localStorage.getItem("oks-1")){$("#oks-1").val(localStorage.getItem("oks-1"))}
|
||||
if(localStorage.getItem("oks-2")){$("#oks-2").val(localStorage.getItem("oks-2"))}
|
||||
if(localStorage.getItem("oks-3")){$("#oks-3").val(localStorage.getItem("oks-3"))}
|
||||
}
|
||||
function exportSettings(){
|
||||
if(!confirm(lang_setting_exportwarn[lang])){
|
||||
return false;
|
||||
}
|
||||
var electron = require("electron");
|
||||
var remote=electron.remote;
|
||||
var dialog=remote.dialog;
|
||||
var ipc = electron.ipcRenderer;
|
||||
dialog.showSaveDialog(null, {
|
||||
title: 'Export',
|
||||
properties: ['openFile', 'createDirectory'],
|
||||
defaultPath: "export.thedeskconfig"
|
||||
}, (savedFiles) => {
|
||||
console.log(savedFiles);
|
||||
if(!savedFiles){
|
||||
return false;
|
||||
}
|
||||
var exp={};
|
||||
//Accounts
|
||||
var multi = localStorage.getItem("multi");
|
||||
var acct = JSON.parse(multi);
|
||||
exp.accts=acct;
|
||||
//Columns
|
||||
var multi = localStorage.getItem("column");
|
||||
var column = JSON.parse(multi);
|
||||
exp.columns=column;
|
||||
//Themes
|
||||
exp.theme=localStorage.getItem("theme");
|
||||
//Min width
|
||||
exp.minwidth=localStorage.getItem("width");
|
||||
//Font
|
||||
exp.font=localStorage.getItem("font");
|
||||
exp.size=localStorage.getItem("size");
|
||||
//Img height
|
||||
exp.imgheight=localStorage.getItem("img-height");
|
||||
//Main
|
||||
exp.mainuse=localStorage.getItem("mainuse");
|
||||
//CW text
|
||||
exp.cw=localStorage.getItem("cw-text");
|
||||
//vis
|
||||
exp.vis=localStorage.getItem("vis");
|
||||
//keysc
|
||||
exp.ksc=[
|
||||
localStorage.getItem("oks-1"),
|
||||
localStorage.getItem("oks-2"),
|
||||
localStorage.getItem("oks-3")
|
||||
];
|
||||
//climu
|
||||
var cli = localStorage.getItem("client_mute");
|
||||
var climu = JSON.parse(cli);
|
||||
exp.clientMute=climu;
|
||||
//wordmu
|
||||
var wdm = localStorage.getItem("word_mute");
|
||||
var wordmu = JSON.parse(wdm);
|
||||
exp.wordMute=wordmu;
|
||||
//spotify
|
||||
exp.spotifyArtwork=localStorage.getItem("artwork")
|
||||
exp.spotifyTemplete=localStorage.getItem("np-temp")
|
||||
//tags
|
||||
var tagarr = localStorage.getItem("tag");
|
||||
var favtag = JSON.parse(tagarr);
|
||||
exp.favoriteTags=favtag;
|
||||
console.log(exp);
|
||||
ipc.send('export', [savedFiles,JSON.stringify(exp)]);
|
||||
alert("Done.")
|
||||
//cards
|
||||
//lang
|
||||
});
|
||||
}
|
||||
function importSettings(){
|
||||
if(!confirm(lang_setting_importwarn[lang])){
|
||||
return false;
|
||||
}
|
||||
var electron = require("electron");
|
||||
var remote=electron.remote;
|
||||
var dialog=remote.dialog;
|
||||
var ipc = electron.ipcRenderer;
|
||||
dialog.showOpenDialog(null, {
|
||||
title: 'Import',
|
||||
properties: ['openFile'],
|
||||
filters: [
|
||||
{name: 'TheDesk Config', extensions: ['thedeskconfig']},
|
||||
]
|
||||
}, (fileNames) => {
|
||||
console.log(fileNames);
|
||||
if(!fileNames){
|
||||
return false;
|
||||
}
|
||||
ipc.send('import', fileNames[0]);
|
||||
ipc.on('config', function (event, arg) {
|
||||
var obj = JSON.parse(arg);
|
||||
if(obj){
|
||||
localStorage.clear();
|
||||
localStorage.setItem("multi",JSON.stringify(obj.accts));
|
||||
for(var key=0;key<obj.accts.length;key++){
|
||||
var acct=obj.accts[key];
|
||||
localStorage.setItem("name_" + key, acct.name);
|
||||
localStorage.setItem("user_" + key, acct.user);
|
||||
localStorage.setItem("user-id_" + key, acct.id);
|
||||
localStorage.setItem("prof_" + key, acct.prof);
|
||||
localStorage.setItem("domain_" + key, acct.domain);
|
||||
localStorage.setItem("acct_"+ key + "_at", acct.at);
|
||||
}
|
||||
localStorage.setItem("column",JSON.stringify(obj.columns));
|
||||
localStorage.setItem("theme",obj.theme);
|
||||
if(obj.width){
|
||||
console.log(obj.width)
|
||||
localStorage.setItem("width",obj.width);
|
||||
}
|
||||
if(obj.font){
|
||||
localStorage.setItem("font",obj.font);
|
||||
}
|
||||
if(obj.size){
|
||||
localStorage.setItem("size",obj.size);
|
||||
}
|
||||
themes(obj.theme);
|
||||
if(obj.imgheight){
|
||||
localStorage.setItem("img-height",obj.imgheight);
|
||||
}
|
||||
localStorage.setItem("mainuse",obj.mainuse);
|
||||
if(obj.cw){
|
||||
localStorage.setItem("cwtext",obj.cw);
|
||||
}
|
||||
localStorage.setItem("vis",obj.vis);
|
||||
if(obj.ksc[0]){
|
||||
localStorage.setItem("oks-1",obj.ksc[0]);
|
||||
}
|
||||
if(obj.ksc[1]){
|
||||
localStorage.setItem("oks-2",obj.ksc[1]);
|
||||
}
|
||||
if(obj.ksc[2]){
|
||||
localStorage.setItem("oks-3",obj.ksc[2]);
|
||||
}
|
||||
if(obj.clientMute){
|
||||
localStorage.setItem("client_mute",JSON.stringify(obj.clientMute));
|
||||
}
|
||||
if(obj.wordMute){
|
||||
localStorage.setItem("word_mute",JSON.stringify(obj.wordMute));
|
||||
}
|
||||
if(obj.favoriteTags){
|
||||
localStorage.setItem("tag",JSON.stringify(obj.favoriteTags));
|
||||
}
|
||||
localStorage.setItem("np-temp",obj.spotifyTemplete);
|
||||
for(var i=0;i<obj.columns.length;i++){
|
||||
localStorage.setItem("card_" + i,"true");
|
||||
localStorage.removeItem("catch_" + i);
|
||||
}
|
||||
location.href="language.html";
|
||||
}else{
|
||||
alert("Error.")
|
||||
}
|
||||
})
|
||||
//cards
|
||||
//lang
|
||||
});
|
||||
}
|
|
@ -24,6 +24,7 @@
|
|||
<span id="notice"></span>
|
||||
<script>
|
||||
//コード受信
|
||||
localStorage.removeItem("lang")
|
||||
if(location.search){
|
||||
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)/);
|
||||
var mode=m[1];
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
"hours":"hours",
|
||||
"mins":"minutes",
|
||||
"warnOnIntegratedTL":"Integrated TL/Plus TL will hide both Home-filtering words and Local-filtering words.",
|
||||
"helloTheDesk":"<h3>Welcome to TheDesk</h3><a href=\"acct.html\">Add an account</a> or click <i class=\"material-icons\">add</i> to add a column.",
|
||||
"helloTheDesk":"<h3>Welcome to TheDesk</h3><br><a href=\"acct.html\">Add an account</a> or click <i class=\"material-icons\">add</i> to add a column.",
|
||||
"addColumn":"Add a column",
|
||||
"sortColumns":"Sort",
|
||||
"acctMan":"Account Manager",
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
"hours":"時間",
|
||||
"mins":"分",
|
||||
"warnOnIntegratedTL":"Integrated TL/Plus TLは、公開/ホームのフィルターワードが合算されて適応されます。どちらか一方の指定でも非表示になります。",
|
||||
"helloTheDesk":"<h3>Welcome to TheDesk</h3><a href=\"acct.html\">アカウントを追加</a>するか下の<i class=\"material-icons\">add</i>ボタンよりカラムを追加してください。",
|
||||
"helloTheDesk":"<h3>Welcome to TheDesk</h3><br><a href=\"acct.html\">アカウントを追加</a>するか下の<i class=\"material-icons\">add</i>ボタンよりカラムを追加してください。",
|
||||
"addColumn":"カラム追加",
|
||||
"sortColumns":"カラム一覧/並べ替え",
|
||||
"acctMan":"アカウントマネージャー",
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
"change":"Change",
|
||||
"env":"System Preferences",
|
||||
"setlang":"Languages",
|
||||
"backup":"Import and export of preferences",
|
||||
"import":"Import",
|
||||
"export":"Export",
|
||||
"theme":"Themes",
|
||||
"popup":"Popup notification(on window)",
|
||||
"popupwarn":"Hide to set \"0\"",
|
||||
|
|
|
@ -6,6 +6,9 @@
|
|||
"change":"変更",
|
||||
"env":"環境設定",
|
||||
"setlang":"言語",
|
||||
"backup":"設定のインポートとエクスポート",
|
||||
"import":"インポート",
|
||||
"export":"エクスポート",
|
||||
"theme":"テーマの設定",
|
||||
"popup":"新規通知のポップアップお知らせの表示秒数",
|
||||
"popupwarn":"0に設定すると表示されません",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"nowver":"Current version",
|
||||
"afterdl":"TheDesk will be quit TheDesk after downloading.",
|
||||
"download":"Download",
|
||||
"cdn":"Delivered by Amazon Web Services(S3/CloudFront)",
|
||||
"winzip":"On Windows, TheDesk will self-unzip and launch the latest file. Durling unzippng, TheDesk may freeze. It takes several seconds.",
|
||||
"releasenote1":"Visit a releasenote of ",
|
||||
"releasenote2":"",
|
||||
"skipupd":"Skip this uodate",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"nowver":"現在のバージョン",
|
||||
"afterdl":"ダウンロード後は選択したフォルダが開きソフトは閉じられます。",
|
||||
"download":"ダウンロード",
|
||||
"cdn":"アップデートはセキュアかつ高速なAmazon CloudFront CDNを通じて提供されます。",
|
||||
"winzip":"Windows環境の場合、自動で展開され起動します。展開時にTheDeskが固まることがありますが、しばらくお待ち下さい。",
|
||||
"releasenote1":"アップデート内容の詳細は",
|
||||
"releasenote2":"をご覧ください。",
|
||||
"skipupd":"このアップデートを飛ばす",
|
||||
|
|
32
app/main.js
32
app/main.js
|
@ -367,7 +367,7 @@ function dl(ver,files,fullname){
|
|||
}else if(platform=="darwin"){
|
||||
var zip="TheDesk-darwin-x64.zip";
|
||||
}
|
||||
zip=zip+"?"+ver;
|
||||
//zip=zip+"?"+ver;
|
||||
var l = 8;
|
||||
|
||||
// 生成する文字列に含める文字セット
|
||||
|
@ -378,7 +378,7 @@ function dl(ver,files,fullname){
|
|||
for(var i=0; i<l; i++){
|
||||
r += c[Math.floor(Math.random()*cl)];
|
||||
}
|
||||
zip=zip+r;
|
||||
|
||||
updatewin.webContents.send('mess', "ダウンロードを開始します。");
|
||||
const opts = {
|
||||
directory:files,
|
||||
|
@ -392,7 +392,27 @@ function dl(ver,files,fullname){
|
|||
'https://dl.thedesk.top/'+zip, opts)
|
||||
.then(dl => {
|
||||
updatewin.webContents.send('mess', "ダウンロードが完了しました。");
|
||||
app.quit();
|
||||
if(platform=="win32"){
|
||||
mainWindow.webContents.send('mess', "unzip");
|
||||
console.log(files+"/"+zip);
|
||||
fs.rename(files+"/"+zip, app.getPath("userData")+"/TheDesk-temp.zip", function (err) {
|
||||
var AdmZip = require('adm-zip');
|
||||
var zipp = new AdmZip(app.getPath("userData")+"/TheDesk-temp.zip");
|
||||
zipp.extractAllTo(app.getPath("userData")+"/",true);
|
||||
var bat='@echo off\nrmdir /s /q "'+files+'\\TheDesk-win32-'+bit+'" /Q\nmove /Y "'+app.getPath("userData")+'\\TheDesk-win32-'+bit+'" "'+files+'\\"\nstart '+files+'\\TheDesk-win32-'+bit+'\\TheDesk.exe\nexit';
|
||||
fs.writeFile(app.getPath("userData")+"/update.bat",bat,function(err){
|
||||
const exec = require('child_process').exec;
|
||||
exec('start '+app.getPath("userData")+"\\update.bat", (err, stdout, stderr) => {
|
||||
app.quit();
|
||||
if (err) { console.log(err); }
|
||||
console.log(stdout);
|
||||
});
|
||||
});
|
||||
})
|
||||
}else{
|
||||
app.quit();
|
||||
}
|
||||
|
||||
})
|
||||
.catch(console.error);
|
||||
}
|
||||
|
@ -561,5 +581,11 @@ ipc.on('mkc', (e, arg) => {
|
|||
var mkc = fs.readFileSync(__dirname + '/.tkn', 'utf8');
|
||||
mainWindow.webContents.send('mkcr', mkc);
|
||||
});
|
||||
ipc.on('export', (e, args) => {
|
||||
fs.writeFileSync(args[0], args[1]);
|
||||
});
|
||||
ipc.on('import', (e, arg) => {
|
||||
mainWindow.webContents.send('config', fs.readFileSync(arg, 'utf8'));
|
||||
});
|
||||
|
||||
app.setAsDefaultProtocolClient('thedesk')
|
5
app/package-lock.json
generated
5
app/package-lock.json
generated
|
@ -4,6 +4,11 @@
|
|||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"adm-zip": {
|
||||
"version": "0.4.11",
|
||||
"resolved": "https://registry.npmjs.org/adm-zip/-/adm-zip-0.4.11.tgz",
|
||||
"integrity": "sha512-L8vcjDTCOIJk7wFvmlEUN7AsSb8T+2JrdP7KINBjzr24TJ5Mwj590sLu3BC7zNZowvJWa/JtPmD8eJCzdtDWjA=="
|
||||
},
|
||||
"ajv": {
|
||||
"version": "5.5.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "TheDesk",
|
||||
"version": "15.10.0",
|
||||
"version": "16.0.1",
|
||||
"description": "TheDesk on Mastodonはシンプルと多機能を両立したデスクトップ向けクライアントです",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
@ -10,6 +10,7 @@
|
|||
"author": "Cutls P",
|
||||
"license": "TheDesk LICENSE",
|
||||
"dependencies": {
|
||||
"adm-zip": "^0.4.11",
|
||||
"electron-dl": "^1.11.0",
|
||||
"jimp": "^0.2.28",
|
||||
"node-notifier": "^5.2.1",
|
||||
|
|
348
app/setting.html
348
app/setting.html
|
@ -0,0 +1,348 @@
|
|||
<!doctype html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<title>Settings - TheDesk</title>
|
||||
<meta content="width=device-width,initial-scale=1.0" name="viewport">
|
||||
<link href="./css/materialize.css" type="text/css" rel="stylesheet">
|
||||
<link href="./css/themes.css" type="text/css" rel="stylesheet">
|
||||
<link href="./css/master.css" type="text/css" rel="stylesheet">
|
||||
<link href='./css/font-awesome.css' rel='stylesheet' type='text/css'>
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Open+Sans:300" rel="stylesheet">
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body id="mainView" style="overflow-y:scroll">
|
||||
<script type="text/javascript" src="./js/common/jquery.js"></script>
|
||||
<script type="text/javascript" src="./js/platform/first.js"></script>
|
||||
<script type="text/javascript" src="./js/common/materialize.js"></script>
|
||||
<script type="text/javascript" src="./js/lang/setting.lang.js"></script>
|
||||
<script>var lang="ja";</script>
|
||||
<h4>設定</h4>
|
||||
<ul class="collapsible" data-collapsible="accordion">
|
||||
<li>
|
||||
<div class="collapsible-header">
|
||||
<i class="material-icons">desktop_windows</i>環境設定
|
||||
</div>
|
||||
<div class="collapsible-body">
|
||||
<h5>言語</h5>
|
||||
<a href="language.html" class="btn waves-effect indigo nex" style="width:100%; max-width:200px;">変更</a><br>
|
||||
<h5>設定のインポートとエクスポート</h5>
|
||||
<button onclick="exportSettings()" class="btn waves-effect lime darken-3" style="width:100%; max-width:200px;">エクスポート</button>
|
||||
<button onclick="importSettings()" class="btn waves-effect cyan darken-3" style="width:100%; max-width:200px;">インポート</button>
|
||||
<h5>テーマの設定</h5>
|
||||
<input class="with-gap" onchange="settings()" name="theme" type="radio" id="black" value="black" />
|
||||
<label for="black">Black</label>
|
||||
<input class="with-gap" onchange="settings()" name="theme" type="radio" id="white" value="white" />
|
||||
<label for="white">White</label>
|
||||
<input class="with-gap" onchange="settings()" name="theme" type="radio" id="indigo" value="indigo" />
|
||||
<label for="indigo">Indigo<span class="imas hide">(エンドレスナイト)</span></label>
|
||||
<input class="with-gap" onchange="settings()" name="theme" type="radio" id="brown" value="brown" />
|
||||
<label for="brown">Brown<span class="imas hide">(ビタースイート・タイム)</span></label>
|
||||
<input class="with-gap" onchange="settings()" name="theme" type="radio" id="green" value="green" />
|
||||
<label for="green">Green<span class="imas hide">(ユースフルロマンス)</span></label>
|
||||
<br>
|
||||
<h5>新規通知のポップアップお知らせの表示秒数</h5>0に設定すると表示されません
|
||||
<br>
|
||||
<input type="text" style="width:50px" id="popup">秒
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="settings()">設定</button>
|
||||
<br>
|
||||
<h5>ネイティブ通知設定</h5>
|
||||
Windows 10の最新バージョンでは通知が表示されません。これは既知のバグですが解決が難しいため保留しています。<br><a onclick="notftest()" class="pointer">通知テスト</a>
|
||||
<br>
|
||||
<input class="with-gap" onchange="settings()" name="notf" type="radio" id="ntf_yes" value="yes" />
|
||||
<label for="ntf_yes">はい</label>
|
||||
<input class="with-gap" onchange="settings()" name="notf" type="radio" id="ntf_no" value="no" />
|
||||
<label for="ntf_no">いいえ</label>
|
||||
<br>
|
||||
<h5>マルチカラムの最低横幅</h5>画面全体の横幅÷コラム数がこの値を超えた時、横スクロールとなります。
|
||||
<br>
|
||||
<input type="text" style="width:50px" id="width">px以上
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="settings()">設定</button>
|
||||
<br>
|
||||
<h5>フォント</h5>
|
||||
ローカルフォントを指定します。<br>
|
||||
<input type="text" style="width:150px" id="font">
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="settings()">設定</button>
|
||||
<br>
|
||||
<h5>フォントサイズ</h5>
|
||||
<span style="font-size:15px">15px(絶対指定)</span>
|
||||
<br>
|
||||
<input type="text" style="width:50px" id="size">px
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="settings()">設定</button>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="collapsible-header">
|
||||
<i class="material-icons">reorder</i>タイムラインの設定
|
||||
</div>
|
||||
<div class="collapsible-body">
|
||||
<h5>時間表記設定</h5>相対時間の例:"1分前","3日前"
|
||||
<br>絶対時間の例"23:25:21","2017年12月30日 23:59:00"
|
||||
<br>混合表示は、当日のトゥートのみ相対、それ以外は絶対で表示
|
||||
<br>
|
||||
<input class="with-gap" onchange="settings()" onchange="settings()" name="time" type="radio" id="relative" value="relative" />
|
||||
<label for="relative">相対時間</label>
|
||||
<input class="with-gap" onchange="settings()" name="time" type="radio" id="absolute" value="absolute" />
|
||||
<label for="absolute">絶対時間</label>
|
||||
<input class="with-gap" onchange="settings()" name="time" type="radio" id="double" value="double" />
|
||||
<label for="double">両方表示</label>
|
||||
<input class="with-gap" onchange="settings()" name="time" type="radio" id="medium" value="medium" />
|
||||
<label for="medium">混合表示</label>
|
||||
<h5>独自ロケールを使用</h5>対応インスタンスではそのインスタンスにあわせた言語表示ができます。
|
||||
<br>
|
||||
<input class="with-gap" onchange="settings()" name="ul" type="radio" id="ul_yes" value="yes" />
|
||||
<label for="ul_yes">はい</label>
|
||||
<input class="with-gap" onchange="settings()" name="ul" type="radio" id="ul_no" value="no" />
|
||||
<label for="ul_no">いいえ</label>
|
||||
<br>
|
||||
<h5>非表示設定の画像(NSFW)を隠す</h5>きつめのぼかしがかかります。
|
||||
<br>
|
||||
<input class="with-gap" onchange="settings()" name="nsfw" type="radio" id="n_yes" value="yes" />
|
||||
<label for="n_yes">はい</label>
|
||||
<input class="with-gap" onchange="settings()" name="nsfw" type="radio" id="n_no" value="no" />
|
||||
<label for="n_no">いいえ</label>
|
||||
<br>
|
||||
<h5>非表示設定のテキスト(CW)を隠す</h5>
|
||||
<input class="with-gap" onchange="settings()" name="cw" type="radio" id="c_yes" value="yes" />
|
||||
<label for="c_yes">はい</label>
|
||||
<input class="with-gap" onchange="settings()" name="cw" type="radio" id="c_no" value="no" />
|
||||
<label for="c_no">いいえ</label>
|
||||
<br>
|
||||
<h5>アイコンのアニメーションを再生する</h5>
|
||||
<input class="with-gap" onchange="settings()" name="gif" type="radio" id="g_yes" value="yes" />
|
||||
<label for="g_yes">はい</label>
|
||||
<input class="with-gap" onchange="settings()" name="gif" type="radio" id="g_no" value="no" />
|
||||
<label for="g_no">いいえ</label>
|
||||
<br>
|
||||
<h5>タグタイムラインの表示範囲</h5>
|
||||
<input class="with-gap" onchange="settings()" name="tag" type="radio" id="t_all" value="all" />
|
||||
<label for="t_all">接続しているインスタンス</label>
|
||||
<input class="with-gap" onchange="settings()" name="tag" type="radio" id="t_local" value="local" />
|
||||
<label for="t_local">検索対象のインスタンスのみ</label>
|
||||
<br>
|
||||
<h5>viaを表示する</h5>
|
||||
<input class="with-gap" onchange="settings()" name="via" type="radio" id="via_yes" value="yes" />
|
||||
<label for="via_yes">はい</label>
|
||||
<input class="with-gap" onchange="settings()" name="via" type="radio" id="via_hide" value="hide" />
|
||||
<label for="via_hide">いいえ</label>
|
||||
<br>
|
||||
<h5>マウスオーバーするまでアクションメニューを非表示</h5>
|
||||
1画面で得られる情報量が格段にアップしますが、すこし鬱陶しいと思うかもしれません。<br>
|
||||
<input class="with-gap" onchange="settings()" name="mov" type="radio" id="mov_yes" value="yes" />
|
||||
<label for="mov_yes">はい</label>
|
||||
<input class="with-gap" onchange="settings()" name="mov" type="radio" id="mov_no" value="no" />
|
||||
<label for="mov_no">いいえ</label>
|
||||
<br>
|
||||
<h5>指定行数以上を折りたたむ</h5>
|
||||
5文字以下のトゥートは折りたたみません。また、折りたたみ時は改行が描画されません。改行のみを行数とカウントします。
|
||||
<br>
|
||||
<input type="text" style="width:50px" id="sentence">行以上または
|
||||
<input type="text" style="width:50px" id="letters">文字以上
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="settings()">設定</button>
|
||||
<br>
|
||||
<h5>画像の高さ
|
||||
</h5>
|
||||
<input type="text" style="width:50px" id="img-height">px
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="settings()">設定</button>
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="collapsible-header">
|
||||
<i class="material-icons">send</i>投稿設定
|
||||
</div>
|
||||
<div class="collapsible-body">
|
||||
<h5>デフォルトの警告文</h5>
|
||||
<input type="text" style="width:150px" id="cw-text">
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="settings()">設定</button>
|
||||
<br>
|
||||
<h5>デフォルトの公開設定</h5>
|
||||
<input class="with-gap" onchange="settings()" name="vis" type="radio" id="public" value="public" />
|
||||
<label for="public">公開(Public)</label>
|
||||
<input class="with-gap" onchange="settings()" name="vis" type="radio" id="unlisted" value="unlisted" />
|
||||
<label for="unlisted">未収載(Unlisted)</label>
|
||||
<input class="with-gap" onchange="settings()" name="vis" type="radio" id="private" value="private" />
|
||||
<label for="private">非公開(Private)</label>
|
||||
<input class="with-gap" onchange="settings()" name="vis" type="radio" id="direct" value="direct" />
|
||||
<label for="direct">ダイレクト(Direct)</label>
|
||||
<input class="with-gap" onchange="settings()" name="vis" type="radio" id="memory" value="memory" />
|
||||
<label for="memory">前回の投稿設定を記憶する(インスタンスごとに記憶されます)</label>
|
||||
<input class="with-gap" onchange="settings()" name="vis" type="radio" id="server" value="server" />
|
||||
<label for="server">マストドンアカウント設定の既定値</label>
|
||||
<br>
|
||||
<h5>画像投稿設定</h5>
|
||||
<input class="with-gap" onchange="settings()" name="img" type="radio" id="i_url" value="url" />
|
||||
<label for="i_url">画像を投稿し、画像のURLを最後に表示</label>
|
||||
<input class="with-gap" onchange="settings()" name="img" type="radio" id="i_no-act" value="no-act" />
|
||||
<label for="i_no-act">画像を投稿するがURLは表示しない</label>
|
||||
<br>
|
||||
<input class="with-gap" onchange="settings()" name="img" type="radio" id="i_inline" value="inline" disabled />
|
||||
<label for="i_inline">現在利用できません。
|
||||
<!--画像を投稿し、インラインで表示(Markdownに対応したインスタンスのみ。マルチアカウント環境では非推奨。)-->
|
||||
</label>
|
||||
<br>
|
||||
<h5>引用形式</h5>
|
||||
<input class="with-gap" onchange="settings()" name="quote" type="radio" id="q_simple" value="simple" />
|
||||
<label for="q_simple">URLのみ</label>
|
||||
<input class="with-gap" onchange="settings()" name="quote" type="radio" id="q_mention" value="mention" />
|
||||
<label for="q_mention">URLとアカウント名(相手に通知)</label>
|
||||
<input class="with-gap" onchange="settings()" name="quote" type="radio" id="q_full" value="full" />
|
||||
<label for="q_full">本文・URL・アカウント名
|
||||
</label>
|
||||
<br>
|
||||
<h5>投稿後や起動時のアカウント</h5>
|
||||
メインアカウントはアカウント設定で指定できます。投稿以外のアカウント選択にも影響します。<br>
|
||||
<input class="with-gap" onchange="settings()" name="main" type="radio" id="mn_remain" value="remain" />
|
||||
<label for="mn_remain">最後に使用したアカウント</label>
|
||||
<input class="with-gap" onchange="settings()" name="main" type="radio" id="mn_main" value="main" />
|
||||
<label for="mn_main">メインアカウント</label>
|
||||
</label>
|
||||
<br>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="collapsible-header">
|
||||
<i class="material-icons">keyboard</i>キーボードショートカットの設定
|
||||
</div>
|
||||
<div class="collapsible-body">
|
||||
<h5>簡単文字入力</h5>
|
||||
絵文字やタグ、>BTなどを登録しておくとすぐに入力できます。<br>
|
||||
Ctrl+Shift+1:<input type="text" style="width:150px" id="oks-1">
|
||||
<button onclick="oks(1)" class="btn waves-effect" style="width:100px;">設定</button><br><br>
|
||||
Ctrl+Shift+2:<input type="text" style="width:150px" id="oks-2">
|
||||
<button onclick="oks(2)" class="btn waves-effect" style="width:100px;">設定</button><br><br>
|
||||
Ctrl+Shift+3:<input type="text" style="width:150px" id="oks-3">
|
||||
<button onclick="oks(3)" class="btn waves-effect" style="width:100px;">設定</button><br><br>
|
||||
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="collapsible-header">
|
||||
<i class="material-icons">bookmark</i>ミュート・強調の設定
|
||||
</div>
|
||||
<div class="collapsible-body">
|
||||
<h5>クライアントミュート</h5>
|
||||
<div id="mute-cli"></div>
|
||||
<h5>クライアント強調</h5>
|
||||
各トゥートのクライアントをクリックすると設定できます。
|
||||
<h5>ワードミュート</h5>
|
||||
Enterで確定<br>
|
||||
<div class="chips" id="wordmute" style="background-color:gray;"></div>
|
||||
<button onclick="wordmuteSave()" class="btn waves-effect" style="width:100px;">設定</button>
|
||||
<h5>ワード強調</h5>
|
||||
Enterで確定<br>
|
||||
<div class="chips" id="wordemp" style="background-color:gray;"></div>
|
||||
<button onclick="wordempSave()" class="btn waves-effect" style="width:100px;">設定</button>
|
||||
<h5>ユーザー強調</h5>
|
||||
各ユーザーのデータ表示画面で設定できます。
|
||||
<span class="emphasized"> 強調色(テーマによって異なります。) </span>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="collapsible-header">
|
||||
<i class="fa fa-spotify"></i>SpotifyとNowPlayingの設定
|
||||
</div>
|
||||
<div class="collapsible-body">
|
||||
<i class="material-icons" style="font-size:24px;">music_note</i>ボタンから簡単にNowPlayingができます。<br>
|
||||
<h5>アカウントの連携</h5>
|
||||
APIの性質上,thedesk.topへアクセスします。<br>
|
||||
<div id="spotify-code-show" class="hide"><input type="text" id="spotify-code"><button onclick="spotifyAuth()" class="btn waves-effect" style="width:100px;">設定</button></div>
|
||||
<a onclick="spotifyConnect()" class="btn waves-effect nex" style="width:100%; max-width:200px; background-color:#1ed760;" id="spotify-enable"><i class="fa fa-spotify left"></i>接続</a>
|
||||
<a onclick="spotifyDisconnect()" class="btn waves-effect nex disabled" style="width:100%; max-width:200px; background-color:#1ed760;" id="spotify-disable"><i class="fa fa-spotify left"></i>切断</a>
|
||||
<h5>テンプレートの編集</h5>
|
||||
以下を編集してテンプレートを変更できます。<br>
|
||||
<textarea id="np-temp" class="materialize-textarea" data-length="500">#NowPlaying {song} / {album} / {artist}
|
||||
{url}</textarea><br>
|
||||
テンプレート:{song}:曲名/{album}:アルバム名/{artist}:アーティスト名/{url}:各曲のSpotifyのURL<br>
|
||||
iTunes NowPlayingでも{url}以外のテンプレートに従ってトゥートされます。また、作曲家{composer}/サンプルレート{hz}/ビットレート{bitRate}/ジャンル{genre}が有効です。<br>
|
||||
<span class="imas hide">CINDERELLA NowPlaying(imastodon.net限定)では作曲家{composer}/作詞家{lyricist}/BPM{bpm}が有効です。<br>
|
||||
CINDERELLA NowPlayingはimastodon.netにログインしているとき、トゥート欄に「//」を入力し、その後に曲名を入れることで可能です。</span><br>
|
||||
<button onclick="spotifySave()" class="btn waves-effect" style="width:100px;">設定</button>
|
||||
<h5>Spotifyでアルバムアートワークを添付する</h5>
|
||||
<span class="imas hide">この設定はCINDERELLA NowPlaying(imastodon.net限定)にも適用されます。</span><br>
|
||||
<input class="with-gap" onchange="spotifyFlagSave()" name="awk" type="radio" id="awk_yes" value="yes" />
|
||||
<label for="awk_yes">はい</label>
|
||||
<input class="with-gap" onchange="spotifyFlagSave()" name="awk" type="radio" id="awk_no" value="no" />
|
||||
<label for="awk_no">いいえ</label>
|
||||
<br>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="collapsible-header">
|
||||
<i class="material-icons">hearing</i>読み上げの設定
|
||||
</div>
|
||||
<div class="collapsible-body">
|
||||
<h5>読み上げの速さ</h5>
|
||||
1-100まで、デフォルトは10。<br>
|
||||
<p class="range-field"><input type="range" id="voicespeed" min="1" max="100" value="10" style="width:500px; max-width:100%"/></p>
|
||||
<h5>読み上げの高さ</h5>
|
||||
0-100まで、デフォルトは50。(大きくなるほど高い)<br>
|
||||
<p class="range-field"><input type="range" id="voicepitch" min="0" max="100" value="50" style="width:500px; max-width:100%"/></p>
|
||||
<h5>読み上げの音量</h5>
|
||||
0-100まで、デフォルトは100。<br>
|
||||
<p class="range-field"><input type="range" id="voicevol" min="0" max="100" value="100" style="width:500px; max-width:100%"/></p>
|
||||
<h5>テスト</h5>
|
||||
<input type="text" style="width:350px" id="voicetxt" value="これはテスト音声です。TheDeskはオープンソースのPC向けマストドンクライアントです。マルチインスタンスやマルチカラムに対応しています。">
|
||||
<button class="btn waves-effect blue" style="width:150px;" onclick="voicePlay()" id="testplay">再生/停止</button><br>
|
||||
<br>
|
||||
<button class="btn waves-effect" style="width:100px;" onclick="voiceSettings()">設定</button>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<br>
|
||||
<a href="index.html" class="btn waves-effect orange nex" style="width:100%; max-width:200px;"><i class="material-icons left">undo</i>戻る</a>
|
||||
<br>
|
||||
<br>キーボードショートカット一覧
|
||||
<li>Ctrl+1-9:1番目~9番目のTLにスクロール</li>
|
||||
<li>N:投稿パネルを開く</li>
|
||||
<li>X:投稿パネルを開閉</li>
|
||||
<li>Ctrl+Enter:投稿</li>
|
||||
<li>Ctrl+E:全ての通知を既読にする</li>
|
||||
<li>Esc:投稿パネルを消す</li>
|
||||
<li>F5:スーパーリロード</li>
|
||||
<li>Ctrl+Shift+C:入力内容を消す</li>
|
||||
<li>Ctrl+Shift+S:設定</li>
|
||||
<li>Ctrl+Shift+M:アカウントマネージャ</li>
|
||||
<li>Ctrl+Shift+N:NowPlaying(Spotify)</li>
|
||||
<li>Ctrl+Shift+P:現在選択中のプロフィール</li>
|
||||
<li>←/→:イメージビューワー起動時に画像切り替え</li>
|
||||
<li>マウスホイール:イメージビューワー時に拡大縮小</li>
|
||||
<div class="hide kirishima">
|
||||
以下Markdownに対応したインスタンスのみ。
|
||||
<br>
|
||||
<li>Ctrl+B/I/S/U:太字/斜字/取り消し/下線</li>
|
||||
<li>Shift+Enter:全角スペースを入れて改行</li>
|
||||
<li>Shift+Space:ゼロ幅スペース</li>
|
||||
以下アスタルテにログインしている場合のみ
|
||||
<br>
|
||||
<li>Ctrl+R:
|
||||
<a href="https://astarte.thedesk.top">アスタルテ暇人ランキング</a>を開く
|
||||
</li><br>
|
||||
</div>
|
||||
<button class="btn waves-effect red" style="width:100%; max-width:500px;" onclick="if(confirm('全てのデータを削除します。この操作は取り消せません。')){ localStorage.clear(); location.href='index.html'; }"><i class="material-icons left">delete</i>初期化</button><br><br>
|
||||
<button class="btn waves-effect indigo" onclick="about()" style="width:100%; max-width:500px;"><i class="material-icons left">info</i>このソフトについて</button>
|
||||
<a href="https://thedesk.top" class="btn waves-effect deep-purple lighten-2" style="width:100%; max-width:500px;"><i class="material-icons left">web</i>公式HP</a>
|
||||
<a href="https://enty.jp/Cutls" class="btn waves-effect purple lighten-2" style="width:100%; max-width:500px;"><i class="material-icons left">trending_up</i>支援(Enty)</a>
|
||||
<a href="https://docs.thedesk.top" class="btn waves-effect blue darken-2" style="width:100%; max-width:500px;"><i class="material-icons left">list</i>ヘルプ/Docs(Constructing)</a>
|
||||
<a href="https://github.com/cutls/TheDesk" class="btn waves-effect black lighten-2" style="width:100%; max-width:500px;"><i class="fa fa-github left"></i>GitHub</a>
|
||||
<a href="index.html?mode=user&code=Cutls@kirishima.cloud" class="btn waves-effect blue lighten-2" style="width:100%; max-width:500px;"><img src="./img/desk_full.svg" class="left" width="25" style="padding-top:5px;">Developer: Cutls@kirishima.cloud</a>
|
||||
<a class="btn waves-effect red lighten-2" href="https://osushi.love/Cutls_P" target="_blank" style="width:100%; max-width:500px;"><img src="./img/sushi.svg" class="left" width="25" style="padding-top:5px;">寿司を投げる</a>
|
||||
<br>
|
||||
<a onclick="localStorage.removeItem('new-ver-skip'); location.href='index.html';" class="pointer">アップデートを確認</a><br>
|
||||
<a href="oss.html">OSS License(オープンソースライセンス)</a><br>
|
||||
<span style="font-family:Open Sans;">Copyright © TheDesk 2018 All Rights Reserved.
|
||||
<a href="https://github.com/cutls/TheDesk/blob/master/LICENSE.md">TheDesk LICENSE (Latest Ver.)</a>
|
||||
<br>Developer: Cutls P(
|
||||
<a href="index.html?mode=user&code=Cutls@kirishima.cloud">@Cutls@kirishima.cloud</a>)
|
||||
<br>
|
||||
</span><br>
|
||||
TheDeskおよびCutls Pは<a href="https://donken.org/">被災地支援のためのマストドン研究会</a>をログイン機能提供等の形で応援しています。<br>
|
||||
タグタイムラインを開く:<a href="index.html?mode=tag&code=被災地支援のためのマストドン研究会">#被災地支援のためのマストドン研究会</a><br>
|
||||
<script type="text/javascript" src="./js/common/about.js"></script>
|
||||
<script type="text/javascript" src="./js/platform/end.js"></script>
|
||||
<script type="text/javascript" src="./js/login/logout.js"></script>
|
||||
<script type="text/javascript" src="./js/ui/spotify.js"></script>
|
||||
<script type="text/javascript" src="./js/tl/speech.js"></script>
|
||||
<script type="text/javascript" src="./js/ui/settings.js"></script>
|
||||
<script type="text/javascript" src="./js/ui/theme.js"></script>
|
||||
<script type="text/javascript" src="./js/tl/date.js"></script>
|
|
@ -24,7 +24,10 @@
|
|||
</div>
|
||||
<div class="collapsible-body">
|
||||
<h5>{{setlang}}</h5>
|
||||
<a href="language.html" class="btn waves-effect indigo nex" style="width:100%; max-width:200px;">{{change}}</a>
|
||||
<a href="language.html" class="btn waves-effect indigo nex" style="width:100%; max-width:200px;">{{change}}</a><br>
|
||||
<h5>{{backup}}</h5>
|
||||
<button onclick="exportSettings()" class="btn waves-effect lime darken-3" style="width:100%; max-width:200px;">{{export}}</button>
|
||||
<button onclick="importSettings()" class="btn waves-effect cyan darken-3" style="width:100%; max-width:200px;">{{import}}</button>
|
||||
<h5>{{theme}}</h5>
|
||||
<input class="with-gap" onchange="settings()" name="theme" type="radio" id="black" value="black" />
|
||||
<label for="black">Black</label>
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
<!doctype html>
|
||||
<html lang="ja">
|
||||
<head>
|
||||
<title>Update - TheDesk</title>
|
||||
<link href="./css/materialize.css" type="text/css" rel="stylesheet">
|
||||
<link href="./css/master.css" type="text/css" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Open+Sans:300" rel="stylesheet">
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
<style>
|
||||
body{
|
||||
font-family:'Open Sans';
|
||||
-webkit-app-region: drag;
|
||||
cursor: move;
|
||||
padding:10px;
|
||||
}
|
||||
a,button{
|
||||
-webkit-app-region: no-drag;
|
||||
}</style>
|
||||
<script type="text/javascript" src="./js/common/jquery.js"></script>
|
||||
<script type="text/javascript" src="./js/platform/first.js"></script>
|
||||
<script type="text/javascript" src="./js/common/materialize.js"></script>
|
||||
<h5>アップデートがあります[TheDesk <span id="ver"></span>]</h5>
|
||||
<span id="det"></span><br>
|
||||
現在のバージョン<span id="now"></span><br>
|
||||
ダウンロード後は選択したフォルダが開きソフトは閉じられます。<br>
|
||||
<button id="update" class="waves-effect btn" onclick="update('true')">ダウンロード</button>
|
||||
<p id="prog"></p>
|
||||
<div class="progress">
|
||||
<div class="determinate" style="width: 0%"></div>
|
||||
</div><br>
|
||||
<b>Windows環境の場合、自動で展開され起動します。展開時にTheDeskが固まることがありますが、しばらくお待ち下さい。</b><br>
|
||||
アップデート内容の詳細は<a href="https://github.com/cutls/TheDesk/blob/master/LATEST.md">GitHub</a>をご覧ください。<br><br>
|
||||
このアップデートを飛ばす(<a onclick="window.close();" class="pointer">次回TL表示時まで</a>/<a onclick="nextv();" class="pointer">次のバージョンが出るまで</a>)<br>
|
||||
<a onclick="quit()" class="pointer">このソフトを終了</a><br>
|
||||
<a onclick="about()" class="pointer">このソフトについて</a><br>
|
||||
アップデートに問題が生じる場合は<a href="https://thedesk.top">TheDesk HP</a>からのダウンロードをおためしください。
|
||||
<script type="text/javascript" src="./js/common/about.js"></script>
|
||||
<script type="text/javascript" src="./js/platform/end.js"></script>
|
||||
<script>
|
||||
var electron = require("electron");
|
||||
var ipc = electron.ipcRenderer;
|
||||
verck();
|
||||
function update(sel){
|
||||
$("#prog").text("");
|
||||
ipc.send('download-btn', [sel,enc(localStorage.getItem("next-ver"))]);
|
||||
}
|
||||
function quit(){
|
||||
ipc.send('quit', 'go');
|
||||
}
|
||||
ipc.on('prog', function (event, arg) {
|
||||
console.log(arg);
|
||||
$(".determinate").css('width',arg*100+"%");
|
||||
$("#prog").text("ダウンロード中:"+Math.floor(arg*100)+"%");
|
||||
})
|
||||
ipc.on('mess', function (event, arg) {
|
||||
console.log(arg);
|
||||
$("#prog").text(arg);
|
||||
})
|
||||
function verck(){
|
||||
var start="https://thedesk.top/ver.json";
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
headers: {'content-type': 'application/json'},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
console.log(json);
|
||||
$("#ver").text(json.desk);
|
||||
localStorage.setItem("next-ver",json.desk);
|
||||
$("#det").text(json.detail);
|
||||
$("#now").text(localStorage.getItem("ver"));
|
||||
});
|
||||
}
|
||||
function nextv(){
|
||||
localStorage.setItem("new-ver-skip","true");
|
||||
window.close();
|
||||
}
|
||||
function enc(ver){
|
||||
var ver = ver.replace( /\s/g , "" );
|
||||
var ver = ver.replace( /\(/g , "-" );
|
||||
var ver = ver.replace( /\)/g , "" );
|
||||
var ver = ver.replace( /\[/g , "_" );
|
||||
var ver = ver.replace( /\]/g , "" );
|
||||
return ver;
|
||||
}
|
||||
</script>
|
|
@ -30,7 +30,7 @@ a,button{
|
|||
<div class="progress">
|
||||
<div class="determinate" style="width: 0%"></div>
|
||||
</div><br>
|
||||
{{cdn}}<br>
|
||||
<b>{{winzip}}</b><br>
|
||||
{{releasenote1}}<a href="https://github.com/cutls/TheDesk/blob/master/LATEST.md">GitHub</a>{{releasenote2}}<br><br>
|
||||
{{skipupd}}(<a onclick="window.close();" class="pointer">{{nexttl}}</a>/<a onclick="nextv();" class="pointer">{{nextver}}</a>)<br>
|
||||
<a onclick="quit()" class="pointer">{{endthedesk}}</a><br>
|
||||
|
|
2
node_modules/jszip/.jshintignore
generated
vendored
Normal file
2
node_modules/jszip/.jshintignore
generated
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
test
|
12
node_modules/jszip/.jshintrc
generated
vendored
Normal file
12
node_modules/jszip/.jshintrc
generated
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"undef": true,
|
||||
"strict": true,
|
||||
"sub": true,
|
||||
|
||||
"globals": {
|
||||
"TextEncoder": false,
|
||||
"TextDecoder": false
|
||||
},
|
||||
"browser": true,
|
||||
"node": true
|
||||
}
|
9
node_modules/jszip/.npmignore
generated
vendored
Normal file
9
node_modules/jszip/.npmignore
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
_config.yml
|
||||
bower.json
|
||||
component.json
|
||||
dist
|
||||
docs
|
||||
documentation
|
||||
Gruntfile.js
|
||||
index.html
|
||||
test
|
11
node_modules/jszip/.travis.yml
generated
vendored
Normal file
11
node_modules/jszip/.travis.yml
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- '0.10'
|
||||
script: npm run $COMMAND
|
||||
env:
|
||||
matrix:
|
||||
- COMMAND=test-node
|
||||
- COMMAND=test-browser
|
||||
global:
|
||||
- secure: MhA8GHU42X3GWTUMaqdZVvarx4BMjhQCUGNi3kvuD/iCmKVb7gMwj4jbds7AcJdsCRsRk8bBGzZs/E7HidBJMPDa5DhgLKy9EV1s42JlHq8lVzbJeWIGgrtyJvhVUkGRy2OJjnDSgh3U6elkQmvDn74jreSQc6m/yGoPFF1nqq8=
|
||||
- secure: qREw6aUu2DnB+2reMuHgygSkumRiJvt7Z5Fz4uEVoraqbe65e4PGhtzypr9uIgCN43vxS2D5tAIeDbfid5VQrWFUQnrC9O5Z5qgVPsKN94zZ1tvYurXI4wRlAg58nNjkfGXWhLI3VUjjDTp5gYcMqgfe5hpEFYUPnUQkKGnaqAk=
|
69
node_modules/jszip/CHANGES.md
generated
vendored
Normal file
69
node_modules/jszip/CHANGES.md
generated
vendored
Normal file
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
title: Changelog
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
### v2.5.0 2015-03-10
|
||||
- add support for custom mime-types (see [#199](https://github.com/Stuk/jszip/issues/199)).
|
||||
- add an option to set the DEFLATE level (see [#201](https://github.com/Stuk/jszip/issues/201)).
|
||||
- improve the error message with corrupted zip (see [#202](https://github.com/Stuk/jszip/issues/202)).
|
||||
- add support for UNIX / DOS permissions (see [#200](https://github.com/Stuk/jszip/issues/200) and [#205](https://github.com/Stuk/jszip/issues/205)).
|
||||
|
||||
### v2.4.0 2014-07-24
|
||||
- update pako to 0.2.5 (see [#156](https://github.com/Stuk/jszip/issues/156)).
|
||||
- make JSZip work in a Firefox addon context (see [#151](https://github.com/Stuk/jszip/issues/151)).
|
||||
- add an option (`createFolders`) to control the subfolder generation (see [#154](https://github.com/Stuk/jszip/issues/154)).
|
||||
- allow `Buffer` polyfill in the browser (see [#139](https://github.com/Stuk/jszip/issues/139)).
|
||||
|
||||
### v2.3.0 2014-06-18
|
||||
- don't generate subfolders (see [#130](https://github.com/Stuk/jszip/issues/130)).
|
||||
- add comment support (see [#134](https://github.com/Stuk/jszip/issues/134)).
|
||||
- on `ZipObject#options`, the attributes `date` and `dir` have been deprecated and are now on `ZipObject` (see [the upgrade guide](http://stuk.github.io/jszip/documentation/upgrade_guide.html)).
|
||||
- on `ZipObject#options`, the attributes `base64` and `binary` have been deprecated (see [the upgrade guide](http://stuk.github.io/jszip/documentation/upgrade_guide.html)).
|
||||
- deprecate internal functions exposed in the public API (see [#123](https://github.com/Stuk/jszip/issues/123)).
|
||||
- improve UTF-8 support (see [#142](https://github.com/Stuk/jszip/issues/142)).
|
||||
|
||||
### v2.2.2, 2014-05-01
|
||||
- update pako to v0.2.1, fix an error when decompressing some files (see [#126](https://github.com/Stuk/jszip/issues/126)).
|
||||
|
||||
### v2.2.1, 2014-04-23
|
||||
- fix unreadable generated file on Windows 8 (see [#112](https://github.com/Stuk/jszip/issues/112)).
|
||||
- replace zlibjs with pako.
|
||||
|
||||
### v2.2.0, 2014-02-25
|
||||
- make the `new` operator optional before the `JSZip` constructor (see [#93](https://github.com/Stuk/jszip/pull/93)).
|
||||
- update zlibjs to v0.2.0.
|
||||
|
||||
### v2.1.1, 2014-02-13
|
||||
- use the npm package for zlib.js instead of the github url.
|
||||
|
||||
### v2.1.0, 2014-02-06
|
||||
- split the files and use Browserify to generate the final file (see [#74](https://github.com/Stuk/jszip/pull/74))
|
||||
- packaging change : instead of 4 files (jszip.js, jszip-load.js, jszip-inflate.js, jszip-deflate.js) we now have 2 files : dist/jszip.js and dist/jszip.min.js
|
||||
- add component/bower support
|
||||
- rename variable: 'byte' is a reserved word (see [#76](https://github.com/Stuk/jszip/pull/76))
|
||||
- add support for the unicode path extra field (see [#82](https://github.com/Stuk/jszip/pull/82))
|
||||
- ensure that the generated files have a header with the licenses (see [#80](https://github.com/Stuk/jszip/pull/80))
|
||||
|
||||
# v2.0.0, 2013-10-20
|
||||
|
||||
- `JSZipBase64` has been renamed to `JSZip.base64`.
|
||||
- The `data` attribute on the object returned by `zip.file(name)` has been removed. Use `asText()`, `asBinary()`, `asUint8Array()`, `asArrayBuffer()` or `asNodeBuffer()`.
|
||||
|
||||
- [Fix issue with Android browser](https://github.com/Stuk/jszip/pull/60)
|
||||
|
||||
- The compression/decompression methods now give their input type with the `compressInputType` and `uncompressInputType` attributes.
|
||||
- Lazily decompress data when needed and [improve performance in general](https://github.com/Stuk/jszip/pull/56)
|
||||
- [Add support for `Buffer` in Node.js](https://github.com/Stuk/jszip/pull/57).
|
||||
- Package for CommonJS/npm.
|
||||
|
||||
### v1.0.1, 2013-03-04
|
||||
|
||||
- Fixed an issue when generating a compressed zip file with empty files or folders, see #33.
|
||||
- With bad data (null or undefined), asText/asBinary/asUint8Array/asArrayBuffer methods now return an empty string, see #36.
|
||||
|
||||
# v1.0.0, 2013-02-14
|
||||
|
||||
- First release after a long period without version.
|
||||
|
49
node_modules/jszip/CHANGES.md.orig
generated
vendored
Normal file
49
node_modules/jszip/CHANGES.md.orig
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
<<<<<<< HEAD
|
||||
### v2.2.1, 2014-04-23
|
||||
- fix unreadable generated file on Windows 8 (see [#112](https://github.com/Stuk/jszip/issues/112)).
|
||||
- replace zlibjs with pako.
|
||||
=======
|
||||
---
|
||||
title: Changelog
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
>>>>>>> Rewrite the documentation
|
||||
|
||||
### v2.2.0, 2014-02-25
|
||||
- make the `new` operator optional before the `JSZip` constructor (see [#93](https://github.com/Stuk/jszip/pull/93)).
|
||||
- update zlibjs to v0.2.0.
|
||||
|
||||
### v2.1.1, 2014-02-13
|
||||
- use the npm package for zlib.js instead of the github url.
|
||||
|
||||
### v2.1.0, 2014-02-06
|
||||
- split the files and use Browserify to generate the final file (see [#74](https://github.com/Stuk/jszip/pull/74))
|
||||
- packaging change : instead of 4 files (jszip.js, jszip-load.js, jszip-inflate.js, jszip-deflate.js) we now have 2 files : dist/jszip.js and dist/jszip.min.js
|
||||
- add component/bower support
|
||||
- rename variable: 'byte' is a reserved word (see [#76](https://github.com/Stuk/jszip/pull/76))
|
||||
- add support for the unicode path extra field (see [#82](https://github.com/Stuk/jszip/pull/82))
|
||||
- ensure that the generated files have a header with the licenses (see [#80](https://github.com/Stuk/jszip/pull/80))
|
||||
|
||||
# v2.0.0, 2013-10-20
|
||||
|
||||
- `JSZipBase64` has been renamed to `JSZip.base64`.
|
||||
- The `data` attribute on the object returned by `zip.file(name)` has been removed. Use `asText()`, `asBinary()`, `asUint8Array()`, `asArrayBuffer()` or `asNodeBuffer()`.
|
||||
|
||||
- [Fix issue with Android browser](https://github.com/Stuk/jszip/pull/60)
|
||||
|
||||
- The compression/decompression methods now give their input type with the `compressInputType` and `uncompressInputType` attributes.
|
||||
- Lazily decompress data when needed and [improve performance in general](https://github.com/Stuk/jszip/pull/56)
|
||||
- [Add support for `Buffer` in Node.js](https://github.com/Stuk/jszip/pull/57).
|
||||
- Package for CommonJS/npm.
|
||||
|
||||
### v1.0.1, 2013-03-04
|
||||
|
||||
- Fixed an issue when generating a compressed zip file with empty files or folders, see #33.
|
||||
- With bad data (null or undefined), asText/asBinary/asUint8Array/asArrayBuffer methods now return an empty string, see #36.
|
||||
|
||||
# v1.0.0, 2013-02-14
|
||||
|
||||
- First release after a long period without version.
|
||||
|
651
node_modules/jszip/LICENSE.markdown
generated
vendored
Normal file
651
node_modules/jszip/LICENSE.markdown
generated
vendored
Normal file
|
@ -0,0 +1,651 @@
|
|||
JSZip is dual licensed. You may use it under the MIT license *or* the GPLv3
|
||||
license.
|
||||
|
||||
The MIT License
|
||||
===============
|
||||
|
||||
Copyright (c) 2009-2014 Stuart Knightley, David Duponchel, Franz Buchinger, António Afonso
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
|
||||
GPL version 3
|
||||
=============
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
41
node_modules/jszip/README.markdown
generated
vendored
Normal file
41
node_modules/jszip/README.markdown
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
JSZip
|
||||
=====
|
||||
|
||||
A library for creating, reading and editing .zip files with Javascript, with a
|
||||
lovely and simple API.
|
||||
|
||||
See http://stuartk.com/jszip for all the documentation.
|
||||
|
||||
```javascript
|
||||
var zip = new JSZip();
|
||||
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
|
||||
var img = zip.folder("images");
|
||||
img.file("smile.gif", imgData, {base64: true});
|
||||
|
||||
var content = zip.generate({type:"blob"});
|
||||
|
||||
// see FileSaver.js
|
||||
saveAs(content, "example.zip");
|
||||
|
||||
/*
|
||||
Results in a zip containing
|
||||
Hello.txt
|
||||
images/
|
||||
smile.gif
|
||||
*/
|
||||
```
|
||||
|
||||
Test status
|
||||
-----------
|
||||
|
||||
[![Build Status](https://api.travis-ci.org/Stuk/jszip.svg?branch=master)](http://travis-ci.org/Stuk/jszip)
|
||||
|
||||
[![Selenium Test Status](https://saucelabs.com/browser-matrix/jszip.svg)](https://saucelabs.com/u/jszip)
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
JSZip is dual-licensed. You may use it under the MIT license *or* the GPLv3
|
||||
license. See [LICENSE.markdown](LICENSE.markdown).
|
702
node_modules/jszip/index.html.orig
generated
vendored
Normal file
702
node_modules/jszip/index.html.orig
generated
vendored
Normal file
|
@ -0,0 +1,702 @@
|
|||
---
|
||||
title: JSZip
|
||||
layout: default
|
||||
section: main
|
||||
---
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
|
||||
JSZip is a javascript library for creating, reading and editing .zip files, with a
|
||||
lovely and simple API.
|
||||
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<p>
|
||||
<strong>Current version</strong> : v2.2.0
|
||||
</p>
|
||||
<p>
|
||||
<strong>License</strong> : JSZip is dual-licensed. You may use it under the
|
||||
MIT license <em>or</em> the GPLv3 license. See
|
||||
<a href="https://github.com/Stuk/jszip/blob/master/LICENSE.markdown">LICENSE.markdown</a>.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-5">
|
||||
|
||||
<h3>Example</h3>
|
||||
|
||||
<script type="text/javascript">
|
||||
imgData = "R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=";
|
||||
|
||||
jQuery(function($) {
|
||||
$("#demo").click(function () {
|
||||
try {
|
||||
eval($("#demo-code").val());
|
||||
$("#status")
|
||||
.removeClass()
|
||||
.addClass("text-success")
|
||||
.text("Done!");
|
||||
}
|
||||
catch (e) {
|
||||
$("#status")
|
||||
.removeClass()
|
||||
.addClass("text-danger")
|
||||
.text(e);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<textarea class="form-control" id="demo-code" rows="7" spellcheck="false">
|
||||
var zip = new JSZip();
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
var img = zip.folder("images");
|
||||
img.file("smile.gif", imgData, {base64: true});
|
||||
<<<<<<< HEAD
|
||||
var content = zip.generate();
|
||||
location.href="data:application/zip;base64,"+content;
|
||||
</textarea>
|
||||
<button id="demo">Run!</button>
|
||||
<span id="status"></span>
|
||||
</div>
|
||||
|
||||
<div id="why" class="grid_4 border">
|
||||
<h2>Why?</h2>
|
||||
<ol>
|
||||
<li>JavaScript today is capable of generating a lot of data. The easiest way to deliver multiple files to your users is in a zip file. Instead of wasting server resources and bandwidth you can get the client to do it for you.</li>
|
||||
<li>Because it's cool!</li>
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
<div id="where" class="grid_3">
|
||||
<h2>Where?</h2>
|
||||
<p>
|
||||
<a href="http://github.com/Stuk/jszip/zipball/master" class="download grid_3 alpha omega">Download</a>
|
||||
<small>from <a href="http://github.com/Stuk/jszip">Github</a></small>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
See also: the <a href="test/">test suite</a>
|
||||
</p>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="grid_9 border">
|
||||
<h2>Tell me more!</h2>
|
||||
|
||||
<h3>Browser support</h3>
|
||||
<table cellspacing="0" class="browser_support">
|
||||
<tr><th class="op">Opera</th> <th class="ff">Firefox</th> <th class="sf">Safari</th> <th class="cr">Chrome</th> <th class="ie">Internet Explorer</th> </tr>
|
||||
<tr><td>Yes</td> <td>Yes</td> <td>Yes</td> <td>Yes</td> <td>Yes</td></tr>
|
||||
<tr>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with 3.0 / 3.6 / latest version</td>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with IE 6 / 7 / 8 / 9 / 10</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<p>While JSZip should work everywhere, the tricky part is to give the zip file to the user.</p>
|
||||
|
||||
<h3>Browser support for <a href="https://en.wikipedia.org/wiki/Data_URI_scheme">data URI scheme</a> with zip</h3>
|
||||
<table cellspacing="0" class="browser_support">
|
||||
<tr><th class="op">Opera</th> <th class="ff">Firefox</th> <th class="sf">Safari</th> <th class="cr">Chrome</th> <th class="ie">Internet Explorer</th> </tr>
|
||||
<tr><td>7.5+</td> <td>3.0+</td> <td>Yes</td> <td>Yes</td> <td>No</td></tr>
|
||||
<tr>
|
||||
<td>Filename is "default.zip"</td>
|
||||
<td>Filename is random alphanumeric with ".part" extension</td>
|
||||
<td>Filename is "Unknown" (no extension)</td>
|
||||
<td>Filename is "download.zip" on OSX and Linux, and just "download" on Windows (<a href="https://github.com/Stuk/jszip/issues/9">issue #9</a>)</td>
|
||||
<td><a href="http://msdn.microsoft.com/en-us/library/cc848897(VS.85).aspx">Only supports data URLs for some content</a>. (May be able to use <a href="http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/">MHTML</a>?)</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Filename problems</h3>
|
||||
<p>The biggest issue with JSZip is that the filenames are very awkward, Firefox generates filenames such as <code>a5sZQRsx.zip.part</code> (see bugs <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=367231">367231</a> and <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=532230">532230</a>), and Safari isn't much better with just <code>Unknown</code>. Sadly there is no pure Javascript solution (and working in every browsers) to this. However...</p>
|
||||
|
||||
<h4>Solution-ish: <a href="https://github.com/dcneiner/downloadify">Downloadify</a></h4>
|
||||
<p>Downloadify uses a small Flash SWF to download files to a user's computer with a filename that you can choose. Doug Neiner has added the <code>dataType</code> option to allow you to pass a zip for downloading. Follow the <a href="http://pixelgraphics.us/downloadify/test.html">Downloadify demo</a> with the following changes:</p>
|
||||
<pre class="example">
|
||||
zip = new JSZip();
|
||||
zip.file("Hello.", "hello.txt");
|
||||
Downloadify.create('downloadify',{
|
||||
...
|
||||
data: function(){
|
||||
return zip.generate();
|
||||
},
|
||||
...
|
||||
dataType: 'base64'
|
||||
});</pre>
|
||||
|
||||
<h4>Other solution-ish: Blob URL / FileSaver / FileSaver.js</h4>
|
||||
<p>With <a href="http://caniuse.com/bloburls">some recent browsers</a> come a new way to download Blobs (a zip file for example) : blob urls. The <a href="http://updates.html5rocks.com/2011/08/Downloading-resources-in-HTML5-a-download">download attribute on <a></a> allows you to give the name of the file. Blob urls start to be widely supported but this attribute is currently only supported in Chrome and Firefox (>= 20). See <a href="examples/download-zip-file.html">the example</a>. Note : on IE 10/11, using a blob url as a href doesn't seem to work.</p>
|
||||
<pre class="example">
|
||||
var blob = zip.generate({type:"blob"});
|
||||
myLink.href = window.URL.createObjectURL(blob);
|
||||
myLink.download = "myFile.zip";</pre>
|
||||
|
||||
<p>An other solution is the <a href="http://www.w3.org/TR/file-writer-api/#the-filesaver-interface">FileSaver</a> interface, created (at the time of writing) with <code>saveAs</code>. This works on Chrome and IE >= 10 (not in compatibility view) but not Firefox.</p>
|
||||
<pre class="example">
|
||||
var blob = zip.generate({type:"blob"});
|
||||
window.saveAs(blob, "hello.zip");</pre>
|
||||
|
||||
<p>Finally, you can use the polyfill <a href="https://github.com/eligrey/FileSaver.js">FileSaver.js</a> which will use a FileSaver if present or else a blob url.</p>
|
||||
|
||||
<h3>Usage with Google Gears</h3>
|
||||
<p>
|
||||
<a href="http://www.picurl.org/blog/author/franz/">Franz Buchinger</a> has written a brilliant tutorial on <a href="http://www.picurl.org/blog/2009/11/22/creating-zip-archives-with-gears/">using JSZip with Google Gears</a> (<a href="http://www.picurl.org/blog/2009/11/29/gearszipper-part2-adding-support-for-real-files-and-canvas-elements/">part 2</a>). If you want to let your Gears users download several files at once I really recommend having a look at some of his <a href="http://picurl.org/gears/zipper/">examples</a>.</p>
|
||||
|
||||
<h3>Reading a zip file from an ajax call</h3>
|
||||
<p>
|
||||
When doing an ajax call to get the binary data, the browser will try to interpret the binary as text, corrupting it. The solution is to <a href="https://developer.mozilla.org/En/XMLHttpRequest/Using_XMLHttpRequest#Receiving_binary_data_in_older_browsers">set the mimetype to 'text/plain; charset=x-user-defined'</a>. This solution works well in all browsers but IE. If you need IE support, please see what is done in the file test/index.html.
|
||||
</p>
|
||||
<p>An other solution is to use a modern browser (supporting <a href="http://caniuse.com/xhr2">xhr2</a>) : setting <code>xhr.type = 'arraybuffer';</code> will do the trick, JSZip supports ArrayBuffers. Please see <a href="examples/get-binary-files-xhr2.html">the example</a>.
|
||||
|
||||
<h3>Reading a local zip file (File API)</h3>
|
||||
<p>
|
||||
JSZip supports (if available in the browser) the File API : reading a local zip file is simple : <code>new JSZip(readerEvent.target.result);</code>. Please see the <a href="examples/read-local-file-api.html">complete example</a> for more details.
|
||||
</p>
|
||||
|
||||
<h2 style="margin-top: 2em;">Documentation</h2>
|
||||
|
||||
<h4 id="doc_new_JSZip">new JSZip() or JSZip()</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>The default constructor.</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>A new JSZip.</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
var zip = new JSZip();
|
||||
// same as
|
||||
var zip = JSZip();</pre>
|
||||
|
||||
<h4 id="doc_new_JSZip_data_options">new JSZip(data [,options]) or JSZip(data [,options])</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Create a new JSZip file and load an existing zip file. See the documentation of <a href="#doc_load_data_options"><code>load()</code></a> for more details and <a href="#zip_load_limits">this</a> for the limitations.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>data</code> (same types as <a href="#doc_load_data_options"><code>load()</code></a>) the content of the zip file to load.</dd>
|
||||
<dd><code>options</code> (Object) options to pass to the <a href="#doc_load_data_options"><code>load()</code></a> method..</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>A new JSZip.</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
new JSZip(zipDataFromXHR, {base64:false});
|
||||
// same as
|
||||
JSZip(zipDataFromXHR, {base64:false});
|
||||
// same as
|
||||
var zip = new JSZip();
|
||||
zip.load(zipDataFromXHR, {base64:false});</pre>
|
||||
|
||||
<h4 id="doc_file_name">file(name)</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Get a file with the specified name.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>name</code> (String) the name of the file.</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>The file if any, <code>null</code> otherwise. The file has the following structure :
|
||||
<ul>
|
||||
<li><code>name</code> the absolute path of the file</li>
|
||||
<li><code>options</code> the options of the file. The available options are :
|
||||
<ul>
|
||||
<li><code>base64</code>, boolean, cf <a href="#doc_file_name_data_options">file(name, data [,options])</a></li>
|
||||
<li><code>binary</code>, boolean, cf <a href="#doc_file_name_data_options">file(name, data [,options])</a></li>
|
||||
<li><code>dir</code>, boolean, true if this is a directory</li>
|
||||
<li><code>date</code>, date, cf <a href="#doc_file_name_data_options">file(name, data [,options])</a></li>
|
||||
<li><code>compression</code>, String, cf <a href="#doc_file_name_data_options">file(name, data [,options])</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><code>asText()</code>, string, the content as an utf8 string (utf8 encoded if necessary).</li>
|
||||
<li><code>asBinary()</code>, string, the content as binary (utf8 decoded if necessary).</li>
|
||||
<li><code>asArrayBuffer()</code>, ArrayBuffer, need a <a href="#jszip_support">compatible browser</a>.</li>
|
||||
<li><code>asUint8Array()</code>, Uint8Array, need a <a href="#jszip_support">compatible browser</a>.</li>
|
||||
<li><code>asNodeBuffer()</code>, nodejs Buffer, need <a href="#jszip_support">nodejs</a>.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
var zip = new JSZip();
|
||||
zip.file("file.txt", "content");
|
||||
|
||||
zip.file("file.txt").name // "file.txt"
|
||||
zip.file("file.txt").asText() // "content"
|
||||
zip.file("file.txt").options.dir // false
|
||||
|
||||
// utf8 example
|
||||
var zip = new JSZip(zipFromAjaxWithUTF8);
|
||||
zip.file("amount.txt").asText() // "€15"
|
||||
zip.file("amount.txt").asArrayBuffer() // an ArrayBuffer containing €15
|
||||
zip.file("amount.txt").asUint8Array() // an Uint8Array containing €15
|
||||
</pre>
|
||||
|
||||
<h4 id="doc_file_regex">file(regex)</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Search a file in the current folder and subfolders with a <a href="http://www.javascriptkit.com/javatutors/redev.shtml">regular expression</a>. The regex is tested against the relative filename.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>regex</code> (RegExp) the regex to use.</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>An array of matching files (an empty array if none matched).</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
var zip = new JSZip();
|
||||
zip.file("file1.txt", "content");
|
||||
zip.file("file2.txt", "content");
|
||||
|
||||
zip.file(/file/); // array of size 2
|
||||
|
||||
// example with a relative path :
|
||||
var folder = zip.folder("sub");
|
||||
folder
|
||||
.file("file3.txt", "content") // relative path from folder : file3.txt
|
||||
.file("file4.txt", "content"); // relative path from folder : file4.txt
|
||||
|
||||
folder.file(/file/); // array of size 2
|
||||
folder.file(/^file/); // array of size 2, the relative paths start with file
|
||||
|
||||
// arrays contain objects in the form:
|
||||
// {name: "file2.txt", dir: false, asText : function () {...}, ...}</pre>
|
||||
|
||||
<h4 id="doc_file_name_data_options">file(name, data [,options])</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Add a file to the zip file.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>name</code> (String) the name of the file.</dd>
|
||||
<dd><code>data</code> (String/ArrayBuffer/Uint8Array/Buffer) the content of the file.</dd>
|
||||
<dd><code>options</code> (Object) the options :
|
||||
<ul>
|
||||
<li><code>base64</code> (boolean) set to <code>true</code> if the data
|
||||
is base64 encoded. For example image data from a <code><canvas></code> element.
|
||||
Plain text and HTML do not need this option.</li>
|
||||
<li><code>binary</code> (boolean) defaults to <code>true</code> if the data
|
||||
is base64 encoded, <code>false</code> otherwise. If set to false then
|
||||
UTF-8 characters will be encoded. If the data is an ArrayBuffer or an Uint8Array, this will be set to true.</li>
|
||||
<li><code>date</code> (Date) use it to specify the last modification date.
|
||||
If not set the current date is used.</li>
|
||||
<li><code>compression</code> (String), default null. If set, specifies the file compression method to use. If not, the default file compression is used, cf <a href="#doc_generate_options">generate(options)</a>.</li>
|
||||
<li><code>optimizedBinaryString</code> (boolean), default false. Set it to true if (and only if) the input is a string and
|
||||
has already been prepared with a 0xFF mask.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>A JSZip object, for chaining.</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
zip.file("smile.gif", "R0lGODdhBQAFAIACAAAAAP/eACwAAAAABQAFAAACCIwPkWerClIBADs=", {base64: true});
|
||||
zip.file("magic.txt", "U2VjcmV0IGNvZGU=", {base64: true, binary: false});
|
||||
zip.file("Xmas.txt", "Ho ho ho !", {date : new Date("December 25, 2007 00:00:01")});
|
||||
zip.file("folder/file.txt", "file in folder");
|
||||
|
||||
zip.file("animals.txt", "dog,platypus\n").file("people.txt", "james,sebastian\n");
|
||||
|
||||
// result : Hello.txt, smile.gif, magic.txt, Xmas.txt, animals.txt, people.txt,
|
||||
// folder/, folder/file.txt</pre>
|
||||
|
||||
<h4 id="doc_folder_name">folder(name)</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Add a directory to the zip file.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>name</code> (String) the name of the directory.</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>a new JSZip (for chaining), with the new folder as root.</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
zip.folder("images");
|
||||
zip.folder("css").file("style.css", "body {background: #FF0000}");
|
||||
// or specify an absolute path (using forward slashes)
|
||||
zip.file("css/font.css", "body {font-family: sans-serif}")
|
||||
|
||||
// result : images/, css/, css/style.css, css/font.css</pre>
|
||||
|
||||
<h4 id="doc_folder_regex">folder(regex)</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Search a subdirectory.</dd>
|
||||
<dd>Search a subdirectory in the current directory with a <a href="http://www.javascriptkit.com/javatutors/redev.shtml">regular expression</a>. The regex is tested against the relative path.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>regex</code> (RegExp) the regex to use.</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>An array of matching folders (an empty array if none matched).</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
var zip = new JSZip();
|
||||
zip.folder("home/Pierre/videos");
|
||||
zip.folder("home/Pierre/photos");
|
||||
zip.folder("home/Jean/videos");
|
||||
zip.folder("home/Jean/photos");
|
||||
|
||||
zip.folder(/videos/); // array of size 2
|
||||
|
||||
zip.folder("home/Jean").folder(/^vid/); // array of 1</pre>
|
||||
|
||||
<h4 id="doc_remove_name">remove(name)</h4>
|
||||
<p>Delete a file or folder.</p>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Delete a file or folder (recursively).</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>name</code> (String) the name of the file/folder to delete.</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>The current JSZip object.</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
var zip = new JSZip();
|
||||
zip.file("Hello.txt", "Hello World\n");
|
||||
zip.file("temp.txt", "nothing").remove("temp.txt");
|
||||
// result : Hello.txt
|
||||
|
||||
zip.folder("css").file("style.css", "body {background: #FF0000}");
|
||||
zip.remove("Hello.txt").remove("css");
|
||||
//result : empty zip</pre>
|
||||
|
||||
<h4 id="doc_generate_options">generate(options)</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Generates the complete zip file.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>options</code> (Object) the options to generate the zip file :
|
||||
<ul>
|
||||
<li><code>base64</code> (boolean) <strong>deprecated</strong>, use "type" instead. <code>false</code> to get the result as a raw byte string.
|
||||
Default : <code>true</code>, encode as base64.</li>
|
||||
<li><code>compression</code> (String) the default file compression method to use. <code>"STORE"</code> (no compression) by default,
|
||||
you can use <code>"DEFLATE"</code> or write your own.</li>
|
||||
<li><code>type</code> (String) the type of zip to return. The possible values are :
|
||||
<ul>
|
||||
<li><code>base64</code> (default) : the result will be a string, the binary in a base64 form.</li>
|
||||
<li><code>string</code> : the result will be a string in "binary" form, 1 byte per char.</li>
|
||||
<li><code>uint8array</code> : the result will be a Uint8Array containing the zip. This requires a compatible browser.</li>
|
||||
<li><code>arraybuffer</code> : the result will be a ArrayBuffer containing the zip. This requires a compatible browser.</li>
|
||||
<li><code>blob</code> : the result will be a Blob containing the zip. This requires a compatible browser.</li>
|
||||
<li><code>nodebuffer</code> : the result will be a nodejs Buffer containing the zip. This requires nodejs.</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>The generated zip file.</dd>
|
||||
</dl>
|
||||
HTML5 note : when using type = "uint8array", "arraybuffer" or "blob", be sure to check if the browser supports it (you can use <a href="#jszip_support"><code>JSZip.support</code></a>).
|
||||
This method will throw an exception otherwise.
|
||||
<pre class="example">
|
||||
content = zip.generate(); // base64
|
||||
location.href="data:application/zip;base64,"+content;</pre>
|
||||
|
||||
<pre class="example">
|
||||
var blobLink = document.getElementById('blobLink');
|
||||
blobLink.download = "hello.zip";
|
||||
blobLink.href = window.URL.createObjectURL(
|
||||
zip.generate({type:"blob"})
|
||||
);</pre>
|
||||
|
||||
<pre class="example">
|
||||
content = zip.generate({type:"string"});
|
||||
for (var c = 0; c < content.length; c++) {
|
||||
console.log(content.charCodeAt(c));
|
||||
// do other things
|
||||
}</pre>
|
||||
|
||||
<h4 id="doc_load_data_options">load(data, options)</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Read an existing zip and merge the data in the current JSZip object. This technique has some limitations, see <a href="#zip_load_limits">below</a>.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>data</code> (String/ArrayBuffer/Uint8Array/Buffer) the zip file</dd>
|
||||
<dd><code>options</code> (Object) the options to load the zip file :
|
||||
<ul>
|
||||
<li><code>base64</code> (boolean) <code>true</code> if the data is base64 encoded, <code>false</code> for binary. Default : <code>false</code>.</li>
|
||||
<li><code>checkCRC32</code> (boolean) <code>true</code> if the read data should be checked against its CRC32. Default : <code>false</code>.</li>
|
||||
<li><code>optimizedBinaryString</code> (boolean), default false. Set it to true if (and only if) the input is a string and
|
||||
has already been prepared with a 0xFF mask.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>The current JSZip object.</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
var zip = new JSZip();
|
||||
zip.load(zipDataFromXHR);</pre>
|
||||
|
||||
<h5>Zip features supported by this method</h5>
|
||||
<ul>
|
||||
<li>Compression (<code>DEFLATE</code> supported)</li>
|
||||
<li>zip with data descriptor</li>
|
||||
<li>ZIP64</li>
|
||||
<li>UTF8 in file name, UTF8 in file content</li>
|
||||
</ul>
|
||||
<h5>Zip features not (yet) supported</h5>
|
||||
<ul>
|
||||
<li>password protected zip</li>
|
||||
<li>multi-volume zip</li>
|
||||
</ul>
|
||||
|
||||
<h4 id="doc_filter_predicate">filter(predicate)</h4>
|
||||
<dl>
|
||||
<dt>Description : </dt>
|
||||
<dd>Filter nested files/folders with the specified function.</dd>
|
||||
<dt>Parameters : </dt>
|
||||
<dd><code>predicate</code> (function) the predicate to use : <code>function (relativePath, file) {...}</code> It takes 2 arguments : the relative path and the file.
|
||||
<ul>
|
||||
<li><code>relativePath</code> (String) The filename and its path, reliatively to the current folder.</li>
|
||||
<li><code>file</code> (Object) The file being tested. Like the result of <a href="#doc_file_name"><code>file(name)</code></a>, the file has the form <code>{name:"...", options:{...}, asText:function,...}</code>.</li>
|
||||
<li>Return true if the file should be included, false otherwise.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt>Returns : </dt>
|
||||
<dd>An array of matching elements.</dd>
|
||||
</dl>
|
||||
<pre class="example">
|
||||
var zip = new JSZip().folder("dir");
|
||||
zip.file("readme.txt", "content");
|
||||
zip.filter(function (relativePath, file){
|
||||
// relativePath == "readme.txt"
|
||||
// file = {name:"dir/readme.txt",options:{...},asText:function}
|
||||
return true/false;
|
||||
});</pre>
|
||||
|
||||
<h4 id="jszip_support">JSZip.support</h4>
|
||||
<p>
|
||||
If the browser supports them, JSZip can take advantage of some new features : ArrayBuffer, Blob, Uint8Array.
|
||||
To know if JSZip can use them, you can check the JSZip.support object. It contains the following
|
||||
properties :
|
||||
<ul>
|
||||
<li><code>arraybuffer</code> : true if JSZip can read and generate ArrayBuffer, false otherwise.</li>
|
||||
<li><code>uint8array</code> : true if JSZip can read and generate Uint8Array, false otherwise.</li>
|
||||
<li><code>blob</code> : true if JSZip can read and generate Blob, false otherwise.</li>
|
||||
<li><code>nodebuffer</code> : true if JSZip can read and generate nodejs Buffer, false otherwise.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
<h3 id="zip_load_limits">Loading zip files, limitations</h3>
|
||||
<h4>Not supported features</h4>
|
||||
<p>
|
||||
All the features of zip files are not supported.
|
||||
Classic zip files will work but encrypted zip, multi-volume, etc are not supported
|
||||
and the load() method will throw an <code>Error</code>.
|
||||
</p>
|
||||
<h4>ZIP64 and 32bit integers</h4>
|
||||
<p>
|
||||
ZIP64 files can be loaded, but only if the zip file is not "too big". ZIP64 uses 64bits integers
|
||||
but Javascript represents all numbers as
|
||||
<a href="http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf">
|
||||
64-bit double precision IEEE 754 floating point numbers</a> (see section 8.5).
|
||||
So, we have 53bits for integers and
|
||||
<a href="https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators">
|
||||
bitwise operations treat everything as 32bits</a>.
|
||||
So if all the 64bits integers can fit into 32 bits integers, everything will be fine. If
|
||||
it's not the case, you will have other problems anyway (see next limitation).
|
||||
</p>
|
||||
<h4>Performance issues</h4>
|
||||
<p>
|
||||
An other limitation comes from the browser (and the machine running the browser).
|
||||
A compressed zip file of 10MB is "easily" opened by firefox/chrome/opera/IE10 but
|
||||
will crash older IE. Also keep in mind that strings in javascript are encoded in UTF-16 :
|
||||
a 10MB ascii text file will take 20MB of memory.
|
||||
</p>
|
||||
<p>
|
||||
If you're having performance issues, please consider the following :
|
||||
<ul>
|
||||
<li>Don't use IE < 10. Everything is better with WebGL support.</li>
|
||||
<li>
|
||||
If you load the file from an ajax call, ask your XHR an ArrayBuffer.
|
||||
Loading a string is asking for troubles.
|
||||
</li>
|
||||
<li>
|
||||
If you want to get the content of an ASCII file as a string, consider using
|
||||
<code>asBinary()</code> instead of <code>asText()</code>. The transformation
|
||||
"binary string" -> "utf string" is a consuming process.
|
||||
</li>
|
||||
</ul>
|
||||
</p>
|
||||
<h4>The output zip will differ from the input zip</h4>
|
||||
<p>
|
||||
Reading and generating a zip file won't give you back the same file.
|
||||
Some data are discarded (file metadata) and other are added (subfolders).
|
||||
</p>
|
||||
|
||||
<h2><a href="https://github.com/Stuk/jszip/blob/master/CHANGES.md">Changelog</a></h2>
|
||||
|
||||
<h2 id="migrating_guide">Migrating Guide</h2>
|
||||
<h3>From 2.0.0 to 2.1.0</h3>
|
||||
<p>
|
||||
<ul>
|
||||
<li>The packaging changed : instead of loading jszip.js, jszip-load.js, jszip-inflate.js, jszip-deflate.js, just include dist/jszip.js or dist/jszip.min.js</li>
|
||||
</ul>
|
||||
</p>
|
||||
<h3>From 1.x to 2.x</h3>
|
||||
<p>
|
||||
<ul>
|
||||
<li><code>JSZipBase64</code> has been renamed to <code>JSZip.base64</code>.</li>
|
||||
<li>
|
||||
The <code>data</code> attribute doesn't exist anymore :
|
||||
use the getters <code>asText()</code>, <code>asBinary()</code>, etc
|
||||
</li>
|
||||
<li>
|
||||
The compression/decompression methods now give their input type with the
|
||||
<code>compressInputType</code> and <code>uncompressInputType</code> attributes.
|
||||
</ul>
|
||||
|
||||
Example for the data attribute :
|
||||
<pre>// before
|
||||
zip.file("test.txt").data;
|
||||
zip.files["test.txt"].data;
|
||||
zip.file("image.png").data;
|
||||
zip.files["image.png"].data;
|
||||
|
||||
// after
|
||||
zip.file("test.txt").asText();
|
||||
zip.files["test.txt"].asText();
|
||||
zip.file("image.png").asBinary();
|
||||
zip.files["image.png"].asBinary();
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div id="who" class="grid_3">
|
||||
<h2>Anything else?</h2>
|
||||
|
||||
<h3>License</h3>
|
||||
<p>
|
||||
<a href="https://github.com/Stuk/jszip/blob/master/LICENSE.markdown">MIT license or GPLv3</a>
|
||||
</p>
|
||||
|
||||
<h3>Version</h3>
|
||||
<p>2.2.1</p>
|
||||
<p>See the <a href="#migrating_guide">migrating guide</a> when updating the library!</p>
|
||||
|
||||
<h3>Todo</h3>
|
||||
<ul>
|
||||
<li>Set correct version needed to extract</li>
|
||||
<li>Set correct version made by</li>
|
||||
<li>Set internal and external file attributes in central directory</li>
|
||||
<li>Allow setting of attributes/other info in <code>add()</code> options object</li>
|
||||
<li>Look into using <a href="http://www.phpied.com/mhtml-when-you-need-data-uris-in-ie7-and-under/">MHTML</a> for IE</li>
|
||||
</ul>
|
||||
|
||||
<h3>Who?</h3>
|
||||
<p><a href="http://stuartk.com">Stuart Knightley</a>, with contributions from:</p>
|
||||
<ul>
|
||||
<li><a href="http://www.picurl.org/blog/author/franz/">Franz Buchinger</a></li>
|
||||
<li><a href="http://www.aadsm.net/">António Afonso</a></li>
|
||||
<li><a href="http://github.com/dduponchel">David Duponchel</a></li>
|
||||
<li><a href="http://yiminghe.javaeye.com">yiminghe</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Contact and bugs</h3>
|
||||
<ul>
|
||||
<li><a href="https://github.com/Stuk/jszip/issues">Issue tracker</a></li>
|
||||
<li><a href="mailto:stuart -at- stuartk.com?subject=JSZip">Email me</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
=======
|
||||
var content = zip.generate({type:"blob"});
|
||||
// see FileSaver.js
|
||||
saveAs(content, "example.zip");</textarea>
|
||||
<button id="demo" class="btn btn-primary">Run!</button>
|
||||
<span id="status"></span>
|
||||
>>>>>>> Rewrite the documentation
|
||||
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
|
||||
<h3>Installation</h3>
|
||||
|
||||
<p>
|
||||
<strong>With npm</strong> : <code>npm install jszip</code>
|
||||
</p>
|
||||
<p>
|
||||
<strong>With bower</strong> : <code>bower install Stuk/jszip</code>
|
||||
</p>
|
||||
<p>
|
||||
<strong>With component</strong> : <code>component install Stuk/jszip</code>
|
||||
</p>
|
||||
<p>
|
||||
<strong>Manually</strong> : <a href="http://github.com/Stuk/jszip/zipball/master">download JSZip</a>
|
||||
and include the file <code>dist/jszip.js</code> or <code>dist/jszip.min.js</code>
|
||||
</p>
|
||||
<br>
|
||||
<p>
|
||||
Installed ? Great ! You can now check our
|
||||
<a href="{{site.baseurl}}/documentation/examples.html">guides and examples !</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3>Support</h3>
|
||||
|
||||
<table class="browser_support">
|
||||
<tr>
|
||||
<th class="support_op">Opera</th>
|
||||
<th class="support_ff">Firefox</th>
|
||||
<th class="support_sf">Safari</th>
|
||||
<th class="support_cr">Chrome</th>
|
||||
<th class="support_ie">Internet Explorer</th>
|
||||
<th class="support_nd">Node.js</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
<td>Yes</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with 3.0 / 3.6 / latest version</td>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with the latest version</td>
|
||||
<td>Tested with IE 6 / 7 / 8 / 9 / 10</td>
|
||||
<td>Tested with node.js 0.8 and 0.10</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h3>Getting help</h3>
|
||||
|
||||
<p>
|
||||
Having trouble ? We'd like to help !
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
Try the <a href="{{site.baseurl}}/documentation/faq.html">FAQ</a>, it has
|
||||
answers to common questions.
|
||||
</li>
|
||||
<li>
|
||||
If you're looking for informations about a specific method, try the
|
||||
<a href="{{site.baseurl}}/documentation/api_jszip.html">documentation</a>.
|
||||
</li>
|
||||
<li>
|
||||
Check the
|
||||
<a href="{{site.baseurl}}/documentation/examples.html">examples</a>.
|
||||
</li>
|
||||
<li>
|
||||
Report bugs in our
|
||||
<a href="https://github.com/Stuk/jszip/issues">Bug tracker</a>.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>Test status</h3>
|
||||
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Travis build :</dt>
|
||||
<dd>
|
||||
<a href="http://travis-ci.org/Stuk/jszip">
|
||||
<img src="https://secure.travis-ci.org/Stuk/jszip.png?branch=master" alt="" />
|
||||
</a>
|
||||
</dd>
|
||||
<dt>Saucelabs build :</dt>
|
||||
<dd>
|
||||
<a href="https://saucelabs.com/u/jszip">
|
||||
<img src="https://saucelabs.com/browser-matrix/jszip.svg" alt="" />
|
||||
</a>
|
||||
</dd>
|
||||
<dt>Live tests :</dt>
|
||||
<dd>
|
||||
<a href="{{site.baseurl}}/test/">See for yourself !</a>
|
||||
</dd>
|
||||
</dl>
|
70
node_modules/jszip/lib/base64.js
generated
vendored
Normal file
70
node_modules/jszip/lib/base64.js
generated
vendored
Normal file
|
@ -0,0 +1,70 @@
|
|||
'use strict';
|
||||
// private property
|
||||
var _keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
||||
|
||||
|
||||
// public method for encoding
|
||||
exports.encode = function(input, utf8) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
chr1 = input.charCodeAt(i++);
|
||||
chr2 = input.charCodeAt(i++);
|
||||
chr3 = input.charCodeAt(i++);
|
||||
|
||||
enc1 = chr1 >> 2;
|
||||
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
|
||||
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
|
||||
enc4 = chr3 & 63;
|
||||
|
||||
if (isNaN(chr2)) {
|
||||
enc3 = enc4 = 64;
|
||||
}
|
||||
else if (isNaN(chr3)) {
|
||||
enc4 = 64;
|
||||
}
|
||||
|
||||
output = output + _keyStr.charAt(enc1) + _keyStr.charAt(enc2) + _keyStr.charAt(enc3) + _keyStr.charAt(enc4);
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
// public method for decoding
|
||||
exports.decode = function(input, utf8) {
|
||||
var output = "";
|
||||
var chr1, chr2, chr3;
|
||||
var enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
|
||||
while (i < input.length) {
|
||||
|
||||
enc1 = _keyStr.indexOf(input.charAt(i++));
|
||||
enc2 = _keyStr.indexOf(input.charAt(i++));
|
||||
enc3 = _keyStr.indexOf(input.charAt(i++));
|
||||
enc4 = _keyStr.indexOf(input.charAt(i++));
|
||||
|
||||
chr1 = (enc1 << 2) | (enc2 >> 4);
|
||||
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
||||
chr3 = ((enc3 & 3) << 6) | enc4;
|
||||
|
||||
output = output + String.fromCharCode(chr1);
|
||||
|
||||
if (enc3 != 64) {
|
||||
output = output + String.fromCharCode(chr2);
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output = output + String.fromCharCode(chr3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
};
|
28
node_modules/jszip/lib/compressedObject.js
generated
vendored
Normal file
28
node_modules/jszip/lib/compressedObject.js
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
'use strict';
|
||||
function CompressedObject() {
|
||||
this.compressedSize = 0;
|
||||
this.uncompressedSize = 0;
|
||||
this.crc32 = 0;
|
||||
this.compressionMethod = null;
|
||||
this.compressedContent = null;
|
||||
}
|
||||
|
||||
CompressedObject.prototype = {
|
||||
/**
|
||||
* Return the decompressed content in an unspecified format.
|
||||
* The format will depend on the decompressor.
|
||||
* @return {Object} the decompressed content.
|
||||
*/
|
||||
getContent: function() {
|
||||
return null; // see implementation
|
||||
},
|
||||
/**
|
||||
* Return the compressed content in an unspecified format.
|
||||
* The format will depend on the compressed conten source.
|
||||
* @return {Object} the compressed content.
|
||||
*/
|
||||
getCompressedContent: function() {
|
||||
return null; // see implementation
|
||||
}
|
||||
};
|
||||
module.exports = CompressedObject;
|
13
node_modules/jszip/lib/compressions.js
generated
vendored
Normal file
13
node_modules/jszip/lib/compressions.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
exports.STORE = {
|
||||
magic: "\x00\x00",
|
||||
compress: function(content, compressionOptions) {
|
||||
return content; // no compression
|
||||
},
|
||||
uncompress: function(content) {
|
||||
return content; // no compression
|
||||
},
|
||||
compressInputType: null,
|
||||
uncompressInputType: null
|
||||
};
|
||||
exports.DEFLATE = require('./flate');
|
102
node_modules/jszip/lib/crc32.js
generated
vendored
Normal file
102
node_modules/jszip/lib/crc32.js
generated
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
var table = [
|
||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,
|
||||
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
|
||||
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
|
||||
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
|
||||
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
|
||||
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
|
||||
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
|
||||
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
|
||||
0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,
|
||||
0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,
|
||||
0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,
|
||||
0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,
|
||||
0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,
|
||||
0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,
|
||||
0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,
|
||||
0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,
|
||||
0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,
|
||||
0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,
|
||||
0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,
|
||||
0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,
|
||||
0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,
|
||||
0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,
|
||||
0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,
|
||||
0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,
|
||||
0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,
|
||||
0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,
|
||||
0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,
|
||||
0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,
|
||||
0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,
|
||||
0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,
|
||||
0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,
|
||||
0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,
|
||||
0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,
|
||||
0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,
|
||||
0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,
|
||||
0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,
|
||||
0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,
|
||||
0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,
|
||||
0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,
|
||||
0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,
|
||||
0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,
|
||||
0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,
|
||||
0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,
|
||||
0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,
|
||||
0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,
|
||||
0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,
|
||||
0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,
|
||||
0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,
|
||||
0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,
|
||||
0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,
|
||||
0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,
|
||||
0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,
|
||||
0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,
|
||||
0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,
|
||||
0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,
|
||||
0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,
|
||||
0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,
|
||||
0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,
|
||||
0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,
|
||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,
|
||||
0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,
|
||||
0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||
];
|
||||
|
||||
/**
|
||||
*
|
||||
* Javascript crc32
|
||||
* http://www.webtoolkit.info/
|
||||
*
|
||||
*/
|
||||
module.exports = function crc32(input, crc) {
|
||||
if (typeof input === "undefined" || !input.length) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var isArray = utils.getTypeOf(input) !== "string";
|
||||
|
||||
if (typeof(crc) == "undefined") {
|
||||
crc = 0;
|
||||
}
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var b = 0;
|
||||
|
||||
crc = crc ^ (-1);
|
||||
for (var i = 0, iTop = input.length; i < iTop; i++) {
|
||||
b = isArray ? input[i] : input.charCodeAt(i);
|
||||
y = (crc ^ b) & 0xFF;
|
||||
x = table[y];
|
||||
crc = (crc >>> 8) ^ x;
|
||||
}
|
||||
|
||||
return crc ^ (-1);
|
||||
};
|
||||
// vim: set shiftwidth=4 softtabstop=4:
|
107
node_modules/jszip/lib/dataReader.js
generated
vendored
Normal file
107
node_modules/jszip/lib/dataReader.js
generated
vendored
Normal file
|
@ -0,0 +1,107 @@
|
|||
'use strict';
|
||||
var utils = require('./utils');
|
||||
|
||||
function DataReader(data) {
|
||||
this.data = null; // type : see implementation
|
||||
this.length = 0;
|
||||
this.index = 0;
|
||||
}
|
||||
DataReader.prototype = {
|
||||
/**
|
||||
* Check that the offset will not go too far.
|
||||
* @param {string} offset the additional offset to check.
|
||||
* @throws {Error} an Error if the offset is out of bounds.
|
||||
*/
|
||||
checkOffset: function(offset) {
|
||||
this.checkIndex(this.index + offset);
|
||||
},
|
||||
/**
|
||||
* Check that the specifed index will not be too far.
|
||||
* @param {string} newIndex the index to check.
|
||||
* @throws {Error} an Error if the index is out of bounds.
|
||||
*/
|
||||
checkIndex: function(newIndex) {
|
||||
if (this.length < newIndex || newIndex < 0) {
|
||||
throw new Error("End of data reached (data length = " + this.length + ", asked index = " + (newIndex) + "). Corrupted zip ?");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Change the index.
|
||||
* @param {number} newIndex The new index.
|
||||
* @throws {Error} if the new index is out of the data.
|
||||
*/
|
||||
setIndex: function(newIndex) {
|
||||
this.checkIndex(newIndex);
|
||||
this.index = newIndex;
|
||||
},
|
||||
/**
|
||||
* Skip the next n bytes.
|
||||
* @param {number} n the number of bytes to skip.
|
||||
* @throws {Error} if the new index is out of the data.
|
||||
*/
|
||||
skip: function(n) {
|
||||
this.setIndex(this.index + n);
|
||||
},
|
||||
/**
|
||||
* Get the byte at the specified index.
|
||||
* @param {number} i the index to use.
|
||||
* @return {number} a byte.
|
||||
*/
|
||||
byteAt: function(i) {
|
||||
// see implementations
|
||||
},
|
||||
/**
|
||||
* Get the next number with a given byte size.
|
||||
* @param {number} size the number of bytes to read.
|
||||
* @return {number} the corresponding number.
|
||||
*/
|
||||
readInt: function(size) {
|
||||
var result = 0,
|
||||
i;
|
||||
this.checkOffset(size);
|
||||
for (i = this.index + size - 1; i >= this.index; i--) {
|
||||
result = (result << 8) + this.byteAt(i);
|
||||
}
|
||||
this.index += size;
|
||||
return result;
|
||||
},
|
||||
/**
|
||||
* Get the next string with a given byte size.
|
||||
* @param {number} size the number of bytes to read.
|
||||
* @return {string} the corresponding string.
|
||||
*/
|
||||
readString: function(size) {
|
||||
return utils.transformTo("string", this.readData(size));
|
||||
},
|
||||
/**
|
||||
* Get raw data without conversion, <size> bytes.
|
||||
* @param {number} size the number of bytes to read.
|
||||
* @return {Object} the raw data, implementation specific.
|
||||
*/
|
||||
readData: function(size) {
|
||||
// see implementations
|
||||
},
|
||||
/**
|
||||
* Find the last occurence of a zip signature (4 bytes).
|
||||
* @param {string} sig the signature to find.
|
||||
* @return {number} the index of the last occurence, -1 if not found.
|
||||
*/
|
||||
lastIndexOfSignature: function(sig) {
|
||||
// see implementations
|
||||
},
|
||||
/**
|
||||
* Get the next date.
|
||||
* @return {Date} the date.
|
||||
*/
|
||||
readDate: function() {
|
||||
var dostime = this.readInt(4);
|
||||
return new Date(
|
||||
((dostime >> 25) & 0x7f) + 1980, // year
|
||||
((dostime >> 21) & 0x0f) - 1, // month
|
||||
(dostime >> 16) & 0x1f, // day
|
||||
(dostime >> 11) & 0x1f, // hour
|
||||
(dostime >> 5) & 0x3f, // minute
|
||||
(dostime & 0x1f) << 1); // second
|
||||
}
|
||||
};
|
||||
module.exports = DataReader;
|
11
node_modules/jszip/lib/defaults.js
generated
vendored
Normal file
11
node_modules/jszip/lib/defaults.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
'use strict';
|
||||
exports.base64 = false;
|
||||
exports.binary = false;
|
||||
exports.dir = false;
|
||||
exports.createFolders = false;
|
||||
exports.date = null;
|
||||
exports.compression = null;
|
||||
exports.compressionOptions = null;
|
||||
exports.comment = null;
|
||||
exports.unixPermissions = null;
|
||||
exports.dosPermissions = null;
|
105
node_modules/jszip/lib/deprecatedPublicUtils.js
generated
vendored
Normal file
105
node_modules/jszip/lib/deprecatedPublicUtils.js
generated
vendored
Normal file
|
@ -0,0 +1,105 @@
|
|||
'use strict';
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.string2binary = function(str) {
|
||||
return utils.string2binary(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.string2Uint8Array = function(str) {
|
||||
return utils.transformTo("uint8array", str);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.uint8Array2String = function(array) {
|
||||
return utils.transformTo("string", array);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.string2Blob = function(str) {
|
||||
var buffer = utils.transformTo("arraybuffer", str);
|
||||
return utils.arrayBuffer2Blob(buffer);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.arrayBuffer2Blob = function(buffer) {
|
||||
return utils.arrayBuffer2Blob(buffer);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.transformTo = function(outputType, input) {
|
||||
return utils.transformTo(outputType, input);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.getTypeOf = function(input) {
|
||||
return utils.getTypeOf(input);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.checkSupport = function(type) {
|
||||
return utils.checkSupport(type);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This value will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.MAX_VALUE_16BITS = utils.MAX_VALUE_16BITS;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This value will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.MAX_VALUE_32BITS = utils.MAX_VALUE_32BITS;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.pretty = function(str) {
|
||||
return utils.pretty(str);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.findCompression = function(compressionMethod) {
|
||||
return utils.findCompression(compressionMethod);
|
||||
};
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This function will be removed in a future version without replacement.
|
||||
*/
|
||||
exports.isRegExp = function (object) {
|
||||
return utils.isRegExp(object);
|
||||
};
|
||||
|
16
node_modules/jszip/lib/flate.js
generated
vendored
Normal file
16
node_modules/jszip/lib/flate.js
generated
vendored
Normal file
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
var USE_TYPEDARRAY = (typeof Uint8Array !== 'undefined') && (typeof Uint16Array !== 'undefined') && (typeof Uint32Array !== 'undefined');
|
||||
|
||||
var pako = require("pako");
|
||||
exports.uncompressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
|
||||
exports.compressInputType = USE_TYPEDARRAY ? "uint8array" : "array";
|
||||
|
||||
exports.magic = "\x08\x00";
|
||||
exports.compress = function(input, compressionOptions) {
|
||||
return pako.deflateRaw(input, {
|
||||
level : compressionOptions.level || -1 // default compression
|
||||
});
|
||||
};
|
||||
exports.uncompress = function(input) {
|
||||
return pako.inflateRaw(input);
|
||||
};
|
79
node_modules/jszip/lib/index.js
generated
vendored
Normal file
79
node_modules/jszip/lib/index.js
generated
vendored
Normal file
|
@ -0,0 +1,79 @@
|
|||
'use strict';
|
||||
|
||||
var base64 = require('./base64');
|
||||
|
||||
/**
|
||||
Usage:
|
||||
zip = new JSZip();
|
||||
zip.file("hello.txt", "Hello, World!").file("tempfile", "nothing");
|
||||
zip.folder("images").file("smile.gif", base64Data, {base64: true});
|
||||
zip.file("Xmas.txt", "Ho ho ho !", {date : new Date("December 25, 2007 00:00:01")});
|
||||
zip.remove("tempfile");
|
||||
|
||||
base64zip = zip.generate();
|
||||
|
||||
**/
|
||||
|
||||
/**
|
||||
* Representation a of zip file in js
|
||||
* @constructor
|
||||
* @param {String=|ArrayBuffer=|Uint8Array=} data the data to load, if any (optional).
|
||||
* @param {Object=} options the options for creating this objects (optional).
|
||||
*/
|
||||
function JSZip(data, options) {
|
||||
// if this constructor is used without `new`, it adds `new` before itself:
|
||||
if(!(this instanceof JSZip)) return new JSZip(data, options);
|
||||
|
||||
// object containing the files :
|
||||
// {
|
||||
// "folder/" : {...},
|
||||
// "folder/data.txt" : {...}
|
||||
// }
|
||||
this.files = {};
|
||||
|
||||
this.comment = null;
|
||||
|
||||
// Where we are in the hierarchy
|
||||
this.root = "";
|
||||
if (data) {
|
||||
this.load(data, options);
|
||||
}
|
||||
this.clone = function() {
|
||||
var newObj = new JSZip();
|
||||
for (var i in this) {
|
||||
if (typeof this[i] !== "function") {
|
||||
newObj[i] = this[i];
|
||||
}
|
||||
}
|
||||
return newObj;
|
||||
};
|
||||
}
|
||||
JSZip.prototype = require('./object');
|
||||
JSZip.prototype.load = require('./load');
|
||||
JSZip.support = require('./support');
|
||||
JSZip.defaults = require('./defaults');
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This namespace will be removed in a future version without replacement.
|
||||
*/
|
||||
JSZip.utils = require('./deprecatedPublicUtils');
|
||||
|
||||
JSZip.base64 = {
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
encode : function(input) {
|
||||
return base64.encode(input);
|
||||
},
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
decode : function(input) {
|
||||
return base64.decode(input);
|
||||
}
|
||||
};
|
||||
JSZip.compressions = require('./compressions');
|
||||
module.exports = JSZip;
|
11
node_modules/jszip/lib/license_header.js
generated
vendored
Normal file
11
node_modules/jszip/lib/license_header.js
generated
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
/*!
|
||||
|
||||
JSZip - A Javascript class for generating and reading zip files
|
||||
<http://stuartk.com/jszip>
|
||||
|
||||
(c) 2009-2014 Stuart Knightley <stuart [at] stuartk.com>
|
||||
Dual licenced under the MIT license or GPLv3. See https://raw.github.com/Stuk/jszip/master/LICENSE.markdown.
|
||||
|
||||
JSZip uses the library pako released under the MIT license :
|
||||
https://github.com/nodeca/pako/blob/master/LICENSE
|
||||
*/
|
31
node_modules/jszip/lib/load.js
generated
vendored
Normal file
31
node_modules/jszip/lib/load.js
generated
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
var base64 = require('./base64');
|
||||
var ZipEntries = require('./zipEntries');
|
||||
module.exports = function(data, options) {
|
||||
var files, zipEntries, i, input;
|
||||
options = options || {};
|
||||
if (options.base64) {
|
||||
data = base64.decode(data);
|
||||
}
|
||||
|
||||
zipEntries = new ZipEntries(data, options);
|
||||
files = zipEntries.files;
|
||||
for (i = 0; i < files.length; i++) {
|
||||
input = files[i];
|
||||
this.file(input.fileName, input.decompressed, {
|
||||
binary: true,
|
||||
optimizedBinaryString: true,
|
||||
date: input.date,
|
||||
dir: input.dir,
|
||||
comment : input.fileComment.length ? input.fileComment : null,
|
||||
unixPermissions : input.unixPermissions,
|
||||
dosPermissions : input.dosPermissions,
|
||||
createFolders: options.createFolders
|
||||
});
|
||||
}
|
||||
if (zipEntries.zipComment.length) {
|
||||
this.comment = zipEntries.zipComment;
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
7
node_modules/jszip/lib/nodeBuffer.js
generated
vendored
Normal file
7
node_modules/jszip/lib/nodeBuffer.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
module.exports = function(data, encoding){
|
||||
return new Buffer(data, encoding);
|
||||
};
|
||||
module.exports.test = function(b){
|
||||
return Buffer.isBuffer(b);
|
||||
};
|
20
node_modules/jszip/lib/nodeBufferReader.js
generated
vendored
Normal file
20
node_modules/jszip/lib/nodeBufferReader.js
generated
vendored
Normal file
|
@ -0,0 +1,20 @@
|
|||
'use strict';
|
||||
var Uint8ArrayReader = require('./uint8ArrayReader');
|
||||
|
||||
function NodeBufferReader(data) {
|
||||
this.data = data;
|
||||
this.length = this.data.length;
|
||||
this.index = 0;
|
||||
}
|
||||
NodeBufferReader.prototype = new Uint8ArrayReader();
|
||||
|
||||
/**
|
||||
* @see DataReader.readData
|
||||
*/
|
||||
NodeBufferReader.prototype.readData = function(size) {
|
||||
this.checkOffset(size);
|
||||
var result = this.data.slice(this.index, this.index + size);
|
||||
this.index += size;
|
||||
return result;
|
||||
};
|
||||
module.exports = NodeBufferReader;
|
883
node_modules/jszip/lib/object.js
generated
vendored
Normal file
883
node_modules/jszip/lib/object.js
generated
vendored
Normal file
|
@ -0,0 +1,883 @@
|
|||
'use strict';
|
||||
var support = require('./support');
|
||||
var utils = require('./utils');
|
||||
var crc32 = require('./crc32');
|
||||
var signature = require('./signature');
|
||||
var defaults = require('./defaults');
|
||||
var base64 = require('./base64');
|
||||
var compressions = require('./compressions');
|
||||
var CompressedObject = require('./compressedObject');
|
||||
var nodeBuffer = require('./nodeBuffer');
|
||||
var utf8 = require('./utf8');
|
||||
var StringWriter = require('./stringWriter');
|
||||
var Uint8ArrayWriter = require('./uint8ArrayWriter');
|
||||
|
||||
/**
|
||||
* Returns the raw data of a ZipObject, decompress the content if necessary.
|
||||
* @param {ZipObject} file the file to use.
|
||||
* @return {String|ArrayBuffer|Uint8Array|Buffer} the data.
|
||||
*/
|
||||
var getRawData = function(file) {
|
||||
if (file._data instanceof CompressedObject) {
|
||||
file._data = file._data.getContent();
|
||||
file.options.binary = true;
|
||||
file.options.base64 = false;
|
||||
|
||||
if (utils.getTypeOf(file._data) === "uint8array") {
|
||||
var copy = file._data;
|
||||
// when reading an arraybuffer, the CompressedObject mechanism will keep it and subarray() a Uint8Array.
|
||||
// if we request a file in the same format, we might get the same Uint8Array or its ArrayBuffer (the original zip file).
|
||||
file._data = new Uint8Array(copy.length);
|
||||
// with an empty Uint8Array, Opera fails with a "Offset larger than array size"
|
||||
if (copy.length !== 0) {
|
||||
file._data.set(copy, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return file._data;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the data of a ZipObject in a binary form. If the content is an unicode string, encode it.
|
||||
* @param {ZipObject} file the file to use.
|
||||
* @return {String|ArrayBuffer|Uint8Array|Buffer} the data.
|
||||
*/
|
||||
var getBinaryData = function(file) {
|
||||
var result = getRawData(file),
|
||||
type = utils.getTypeOf(result);
|
||||
if (type === "string") {
|
||||
if (!file.options.binary) {
|
||||
// unicode text !
|
||||
// unicode string => binary string is a painful process, check if we can avoid it.
|
||||
if (support.nodebuffer) {
|
||||
return nodeBuffer(result, "utf-8");
|
||||
}
|
||||
}
|
||||
return file.asBinary();
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform this._data into a string.
|
||||
* @param {function} filter a function String -> String, applied if not null on the result.
|
||||
* @return {String} the string representing this._data.
|
||||
*/
|
||||
var dataToString = function(asUTF8) {
|
||||
var result = getRawData(this);
|
||||
if (result === null || typeof result === "undefined") {
|
||||
return "";
|
||||
}
|
||||
// if the data is a base64 string, we decode it before checking the encoding !
|
||||
if (this.options.base64) {
|
||||
result = base64.decode(result);
|
||||
}
|
||||
if (asUTF8 && this.options.binary) {
|
||||
// JSZip.prototype.utf8decode supports arrays as input
|
||||
// skip to array => string step, utf8decode will do it.
|
||||
result = out.utf8decode(result);
|
||||
}
|
||||
else {
|
||||
// no utf8 transformation, do the array => string step.
|
||||
result = utils.transformTo("string", result);
|
||||
}
|
||||
|
||||
if (!asUTF8 && !this.options.binary) {
|
||||
result = utils.transformTo("string", out.utf8encode(result));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
/**
|
||||
* A simple object representing a file in the zip file.
|
||||
* @constructor
|
||||
* @param {string} name the name of the file
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data
|
||||
* @param {Object} options the options of the file
|
||||
*/
|
||||
var ZipObject = function(name, data, options) {
|
||||
this.name = name;
|
||||
this.dir = options.dir;
|
||||
this.date = options.date;
|
||||
this.comment = options.comment;
|
||||
this.unixPermissions = options.unixPermissions;
|
||||
this.dosPermissions = options.dosPermissions;
|
||||
|
||||
this._data = data;
|
||||
this.options = options;
|
||||
|
||||
/*
|
||||
* This object contains initial values for dir and date.
|
||||
* With them, we can check if the user changed the deprecated metadata in
|
||||
* `ZipObject#options` or not.
|
||||
*/
|
||||
this._initialMetadata = {
|
||||
dir : options.dir,
|
||||
date : options.date
|
||||
};
|
||||
};
|
||||
|
||||
ZipObject.prototype = {
|
||||
/**
|
||||
* Return the content as UTF8 string.
|
||||
* @return {string} the UTF8 string.
|
||||
*/
|
||||
asText: function() {
|
||||
return dataToString.call(this, true);
|
||||
},
|
||||
/**
|
||||
* Returns the binary content.
|
||||
* @return {string} the content as binary.
|
||||
*/
|
||||
asBinary: function() {
|
||||
return dataToString.call(this, false);
|
||||
},
|
||||
/**
|
||||
* Returns the content as a nodejs Buffer.
|
||||
* @return {Buffer} the content as a Buffer.
|
||||
*/
|
||||
asNodeBuffer: function() {
|
||||
var result = getBinaryData(this);
|
||||
return utils.transformTo("nodebuffer", result);
|
||||
},
|
||||
/**
|
||||
* Returns the content as an Uint8Array.
|
||||
* @return {Uint8Array} the content as an Uint8Array.
|
||||
*/
|
||||
asUint8Array: function() {
|
||||
var result = getBinaryData(this);
|
||||
return utils.transformTo("uint8array", result);
|
||||
},
|
||||
/**
|
||||
* Returns the content as an ArrayBuffer.
|
||||
* @return {ArrayBuffer} the content as an ArrayBufer.
|
||||
*/
|
||||
asArrayBuffer: function() {
|
||||
return this.asUint8Array().buffer;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform an integer into a string in hexadecimal.
|
||||
* @private
|
||||
* @param {number} dec the number to convert.
|
||||
* @param {number} bytes the number of bytes to generate.
|
||||
* @returns {string} the result.
|
||||
*/
|
||||
var decToHex = function(dec, bytes) {
|
||||
var hex = "",
|
||||
i;
|
||||
for (i = 0; i < bytes; i++) {
|
||||
hex += String.fromCharCode(dec & 0xff);
|
||||
dec = dec >>> 8;
|
||||
}
|
||||
return hex;
|
||||
};
|
||||
|
||||
/**
|
||||
* Merge the objects passed as parameters into a new one.
|
||||
* @private
|
||||
* @param {...Object} var_args All objects to merge.
|
||||
* @return {Object} a new object with the data of the others.
|
||||
*/
|
||||
var extend = function() {
|
||||
var result = {}, i, attr;
|
||||
for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers
|
||||
for (attr in arguments[i]) {
|
||||
if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
|
||||
result[attr] = arguments[i][attr];
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Transforms the (incomplete) options from the user into the complete
|
||||
* set of options to create a file.
|
||||
* @private
|
||||
* @param {Object} o the options from the user.
|
||||
* @return {Object} the complete set of options.
|
||||
*/
|
||||
var prepareFileAttrs = function(o) {
|
||||
o = o || {};
|
||||
if (o.base64 === true && (o.binary === null || o.binary === undefined)) {
|
||||
o.binary = true;
|
||||
}
|
||||
o = extend(o, defaults);
|
||||
o.date = o.date || new Date();
|
||||
if (o.compression !== null) o.compression = o.compression.toUpperCase();
|
||||
|
||||
return o;
|
||||
};
|
||||
|
||||
/**
|
||||
* Add a file in the current folder.
|
||||
* @private
|
||||
* @param {string} name the name of the file
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the data of the file
|
||||
* @param {Object} o the options of the file
|
||||
* @return {Object} the new file.
|
||||
*/
|
||||
var fileAdd = function(name, data, o) {
|
||||
// be sure sub folders exist
|
||||
var dataType = utils.getTypeOf(data),
|
||||
parent;
|
||||
|
||||
o = prepareFileAttrs(o);
|
||||
|
||||
if (typeof o.unixPermissions === "string") {
|
||||
o.unixPermissions = parseInt(o.unixPermissions, 8);
|
||||
}
|
||||
|
||||
// UNX_IFDIR 0040000 see zipinfo.c
|
||||
if (o.unixPermissions && (o.unixPermissions & 0x4000)) {
|
||||
o.dir = true;
|
||||
}
|
||||
// Bit 4 Directory
|
||||
if (o.dosPermissions && (o.dosPermissions & 0x0010)) {
|
||||
o.dir = true;
|
||||
}
|
||||
|
||||
if (o.dir) {
|
||||
name = forceTrailingSlash(name);
|
||||
}
|
||||
|
||||
if (o.createFolders && (parent = parentFolder(name))) {
|
||||
folderAdd.call(this, parent, true);
|
||||
}
|
||||
|
||||
if (o.dir || data === null || typeof data === "undefined") {
|
||||
o.base64 = false;
|
||||
o.binary = false;
|
||||
data = null;
|
||||
dataType = null;
|
||||
}
|
||||
else if (dataType === "string") {
|
||||
if (o.binary && !o.base64) {
|
||||
// optimizedBinaryString == true means that the file has already been filtered with a 0xFF mask
|
||||
if (o.optimizedBinaryString !== true) {
|
||||
// this is a string, not in a base64 format.
|
||||
// Be sure that this is a correct "binary string"
|
||||
data = utils.string2binary(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // arraybuffer, uint8array, ...
|
||||
o.base64 = false;
|
||||
o.binary = true;
|
||||
|
||||
if (!dataType && !(data instanceof CompressedObject)) {
|
||||
throw new Error("The data of '" + name + "' is in an unsupported format !");
|
||||
}
|
||||
|
||||
// special case : it's way easier to work with Uint8Array than with ArrayBuffer
|
||||
if (dataType === "arraybuffer") {
|
||||
data = utils.transformTo("uint8array", data);
|
||||
}
|
||||
}
|
||||
|
||||
var object = new ZipObject(name, data, o);
|
||||
this.files[name] = object;
|
||||
return object;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find the parent folder of the path.
|
||||
* @private
|
||||
* @param {string} path the path to use
|
||||
* @return {string} the parent folder, or ""
|
||||
*/
|
||||
var parentFolder = function (path) {
|
||||
if (path.slice(-1) == '/') {
|
||||
path = path.substring(0, path.length - 1);
|
||||
}
|
||||
var lastSlash = path.lastIndexOf('/');
|
||||
return (lastSlash > 0) ? path.substring(0, lastSlash) : "";
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the path with a slash at the end.
|
||||
* @private
|
||||
* @param {String} path the path to check.
|
||||
* @return {String} the path with a trailing slash.
|
||||
*/
|
||||
var forceTrailingSlash = function(path) {
|
||||
// Check the name ends with a /
|
||||
if (path.slice(-1) != "/") {
|
||||
path += "/"; // IE doesn't like substr(-1)
|
||||
}
|
||||
return path;
|
||||
};
|
||||
/**
|
||||
* Add a (sub) folder in the current folder.
|
||||
* @private
|
||||
* @param {string} name the folder's name
|
||||
* @param {boolean=} [createFolders] If true, automatically create sub
|
||||
* folders. Defaults to false.
|
||||
* @return {Object} the new folder.
|
||||
*/
|
||||
var folderAdd = function(name, createFolders) {
|
||||
createFolders = (typeof createFolders !== 'undefined') ? createFolders : false;
|
||||
|
||||
name = forceTrailingSlash(name);
|
||||
|
||||
// Does this folder already exist?
|
||||
if (!this.files[name]) {
|
||||
fileAdd.call(this, name, null, {
|
||||
dir: true,
|
||||
createFolders: createFolders
|
||||
});
|
||||
}
|
||||
return this.files[name];
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate a JSZip.CompressedObject for a given zipOject.
|
||||
* @param {ZipObject} file the object to read.
|
||||
* @param {JSZip.compression} compression the compression to use.
|
||||
* @param {Object} compressionOptions the options to use when compressing.
|
||||
* @return {JSZip.CompressedObject} the compressed result.
|
||||
*/
|
||||
var generateCompressedObjectFrom = function(file, compression, compressionOptions) {
|
||||
var result = new CompressedObject(),
|
||||
content;
|
||||
|
||||
// the data has not been decompressed, we might reuse things !
|
||||
if (file._data instanceof CompressedObject) {
|
||||
result.uncompressedSize = file._data.uncompressedSize;
|
||||
result.crc32 = file._data.crc32;
|
||||
|
||||
if (result.uncompressedSize === 0 || file.dir) {
|
||||
compression = compressions['STORE'];
|
||||
result.compressedContent = "";
|
||||
result.crc32 = 0;
|
||||
}
|
||||
else if (file._data.compressionMethod === compression.magic) {
|
||||
result.compressedContent = file._data.getCompressedContent();
|
||||
}
|
||||
else {
|
||||
content = file._data.getContent();
|
||||
// need to decompress / recompress
|
||||
result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// have uncompressed data
|
||||
content = getBinaryData(file);
|
||||
if (!content || content.length === 0 || file.dir) {
|
||||
compression = compressions['STORE'];
|
||||
content = "";
|
||||
}
|
||||
result.uncompressedSize = content.length;
|
||||
result.crc32 = crc32(content);
|
||||
result.compressedContent = compression.compress(utils.transformTo(compression.compressInputType, content), compressionOptions);
|
||||
}
|
||||
|
||||
result.compressedSize = result.compressedContent.length;
|
||||
result.compressionMethod = compression.magic;
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Generate the UNIX part of the external file attributes.
|
||||
* @param {Object} unixPermissions the unix permissions or null.
|
||||
* @param {Boolean} isDir true if the entry is a directory, false otherwise.
|
||||
* @return {Number} a 32 bit integer.
|
||||
*
|
||||
* adapted from http://unix.stackexchange.com/questions/14705/the-zip-formats-external-file-attribute :
|
||||
*
|
||||
* TTTTsstrwxrwxrwx0000000000ADVSHR
|
||||
* ^^^^____________________________ file type, see zipinfo.c (UNX_*)
|
||||
* ^^^_________________________ setuid, setgid, sticky
|
||||
* ^^^^^^^^^________________ permissions
|
||||
* ^^^^^^^^^^______ not used ?
|
||||
* ^^^^^^ DOS attribute bits : Archive, Directory, Volume label, System file, Hidden, Read only
|
||||
*/
|
||||
var generateUnixExternalFileAttr = function (unixPermissions, isDir) {
|
||||
|
||||
var result = unixPermissions;
|
||||
if (!unixPermissions) {
|
||||
// I can't use octal values in strict mode, hence the hexa.
|
||||
// 040775 => 0x41fd
|
||||
// 0100664 => 0x81b4
|
||||
result = isDir ? 0x41fd : 0x81b4;
|
||||
}
|
||||
|
||||
return (result & 0xFFFF) << 16;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate the DOS part of the external file attributes.
|
||||
* @param {Object} dosPermissions the dos permissions or null.
|
||||
* @param {Boolean} isDir true if the entry is a directory, false otherwise.
|
||||
* @return {Number} a 32 bit integer.
|
||||
*
|
||||
* Bit 0 Read-Only
|
||||
* Bit 1 Hidden
|
||||
* Bit 2 System
|
||||
* Bit 3 Volume Label
|
||||
* Bit 4 Directory
|
||||
* Bit 5 Archive
|
||||
*/
|
||||
var generateDosExternalFileAttr = function (dosPermissions, isDir) {
|
||||
|
||||
// the dir flag is already set for compatibility
|
||||
|
||||
return (dosPermissions || 0) & 0x3F;
|
||||
};
|
||||
|
||||
/**
|
||||
* Generate the various parts used in the construction of the final zip file.
|
||||
* @param {string} name the file name.
|
||||
* @param {ZipObject} file the file content.
|
||||
* @param {JSZip.CompressedObject} compressedObject the compressed object.
|
||||
* @param {number} offset the current offset from the start of the zip file.
|
||||
* @param {String} platform let's pretend we are this platform (change platform dependents fields)
|
||||
* @return {object} the zip parts.
|
||||
*/
|
||||
var generateZipParts = function(name, file, compressedObject, offset, platform) {
|
||||
var data = compressedObject.compressedContent,
|
||||
utfEncodedFileName = utils.transformTo("string", utf8.utf8encode(file.name)),
|
||||
comment = file.comment || "",
|
||||
utfEncodedComment = utils.transformTo("string", utf8.utf8encode(comment)),
|
||||
useUTF8ForFileName = utfEncodedFileName.length !== file.name.length,
|
||||
useUTF8ForComment = utfEncodedComment.length !== comment.length,
|
||||
o = file.options,
|
||||
dosTime,
|
||||
dosDate,
|
||||
extraFields = "",
|
||||
unicodePathExtraField = "",
|
||||
unicodeCommentExtraField = "",
|
||||
dir, date;
|
||||
|
||||
|
||||
// handle the deprecated options.dir
|
||||
if (file._initialMetadata.dir !== file.dir) {
|
||||
dir = file.dir;
|
||||
} else {
|
||||
dir = o.dir;
|
||||
}
|
||||
|
||||
// handle the deprecated options.date
|
||||
if(file._initialMetadata.date !== file.date) {
|
||||
date = file.date;
|
||||
} else {
|
||||
date = o.date;
|
||||
}
|
||||
|
||||
var extFileAttr = 0;
|
||||
var versionMadeBy = 0;
|
||||
if (dir) {
|
||||
// dos or unix, we set the dos dir flag
|
||||
extFileAttr |= 0x00010;
|
||||
}
|
||||
if(platform === "UNIX") {
|
||||
versionMadeBy = 0x031E; // UNIX, version 3.0
|
||||
extFileAttr |= generateUnixExternalFileAttr(file.unixPermissions, dir);
|
||||
} else { // DOS or other, fallback to DOS
|
||||
versionMadeBy = 0x0014; // DOS, version 2.0
|
||||
extFileAttr |= generateDosExternalFileAttr(file.dosPermissions, dir);
|
||||
}
|
||||
|
||||
// date
|
||||
// @see http://www.delorie.com/djgpp/doc/rbinter/it/52/13.html
|
||||
// @see http://www.delorie.com/djgpp/doc/rbinter/it/65/16.html
|
||||
// @see http://www.delorie.com/djgpp/doc/rbinter/it/66/16.html
|
||||
|
||||
dosTime = date.getHours();
|
||||
dosTime = dosTime << 6;
|
||||
dosTime = dosTime | date.getMinutes();
|
||||
dosTime = dosTime << 5;
|
||||
dosTime = dosTime | date.getSeconds() / 2;
|
||||
|
||||
dosDate = date.getFullYear() - 1980;
|
||||
dosDate = dosDate << 4;
|
||||
dosDate = dosDate | (date.getMonth() + 1);
|
||||
dosDate = dosDate << 5;
|
||||
dosDate = dosDate | date.getDate();
|
||||
|
||||
if (useUTF8ForFileName) {
|
||||
// set the unicode path extra field. unzip needs at least one extra
|
||||
// field to correctly handle unicode path, so using the path is as good
|
||||
// as any other information. This could improve the situation with
|
||||
// other archive managers too.
|
||||
// This field is usually used without the utf8 flag, with a non
|
||||
// unicode path in the header (winrar, winzip). This helps (a bit)
|
||||
// with the messy Windows' default compressed folders feature but
|
||||
// breaks on p7zip which doesn't seek the unicode path extra field.
|
||||
// So for now, UTF-8 everywhere !
|
||||
unicodePathExtraField =
|
||||
// Version
|
||||
decToHex(1, 1) +
|
||||
// NameCRC32
|
||||
decToHex(crc32(utfEncodedFileName), 4) +
|
||||
// UnicodeName
|
||||
utfEncodedFileName;
|
||||
|
||||
extraFields +=
|
||||
// Info-ZIP Unicode Path Extra Field
|
||||
"\x75\x70" +
|
||||
// size
|
||||
decToHex(unicodePathExtraField.length, 2) +
|
||||
// content
|
||||
unicodePathExtraField;
|
||||
}
|
||||
|
||||
if(useUTF8ForComment) {
|
||||
|
||||
unicodeCommentExtraField =
|
||||
// Version
|
||||
decToHex(1, 1) +
|
||||
// CommentCRC32
|
||||
decToHex(this.crc32(utfEncodedComment), 4) +
|
||||
// UnicodeName
|
||||
utfEncodedComment;
|
||||
|
||||
extraFields +=
|
||||
// Info-ZIP Unicode Path Extra Field
|
||||
"\x75\x63" +
|
||||
// size
|
||||
decToHex(unicodeCommentExtraField.length, 2) +
|
||||
// content
|
||||
unicodeCommentExtraField;
|
||||
}
|
||||
|
||||
var header = "";
|
||||
|
||||
// version needed to extract
|
||||
header += "\x0A\x00";
|
||||
// general purpose bit flag
|
||||
// set bit 11 if utf8
|
||||
header += (useUTF8ForFileName || useUTF8ForComment) ? "\x00\x08" : "\x00\x00";
|
||||
// compression method
|
||||
header += compressedObject.compressionMethod;
|
||||
// last mod file time
|
||||
header += decToHex(dosTime, 2);
|
||||
// last mod file date
|
||||
header += decToHex(dosDate, 2);
|
||||
// crc-32
|
||||
header += decToHex(compressedObject.crc32, 4);
|
||||
// compressed size
|
||||
header += decToHex(compressedObject.compressedSize, 4);
|
||||
// uncompressed size
|
||||
header += decToHex(compressedObject.uncompressedSize, 4);
|
||||
// file name length
|
||||
header += decToHex(utfEncodedFileName.length, 2);
|
||||
// extra field length
|
||||
header += decToHex(extraFields.length, 2);
|
||||
|
||||
|
||||
var fileRecord = signature.LOCAL_FILE_HEADER + header + utfEncodedFileName + extraFields;
|
||||
|
||||
var dirRecord = signature.CENTRAL_FILE_HEADER +
|
||||
// version made by (00: DOS)
|
||||
decToHex(versionMadeBy, 2) +
|
||||
// file header (common to file and central directory)
|
||||
header +
|
||||
// file comment length
|
||||
decToHex(utfEncodedComment.length, 2) +
|
||||
// disk number start
|
||||
"\x00\x00" +
|
||||
// internal file attributes TODO
|
||||
"\x00\x00" +
|
||||
// external file attributes
|
||||
decToHex(extFileAttr, 4) +
|
||||
// relative offset of local header
|
||||
decToHex(offset, 4) +
|
||||
// file name
|
||||
utfEncodedFileName +
|
||||
// extra field
|
||||
extraFields +
|
||||
// file comment
|
||||
utfEncodedComment;
|
||||
|
||||
return {
|
||||
fileRecord: fileRecord,
|
||||
dirRecord: dirRecord,
|
||||
compressedObject: compressedObject
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// return the actual prototype of JSZip
|
||||
var out = {
|
||||
/**
|
||||
* Read an existing zip and merge the data in the current JSZip object.
|
||||
* The implementation is in jszip-load.js, don't forget to include it.
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} stream The stream to load
|
||||
* @param {Object} options Options for loading the stream.
|
||||
* options.base64 : is the stream in base64 ? default : false
|
||||
* @return {JSZip} the current JSZip object
|
||||
*/
|
||||
load: function(stream, options) {
|
||||
throw new Error("Load method is not defined. Is the file jszip-load.js included ?");
|
||||
},
|
||||
|
||||
/**
|
||||
* Filter nested files/folders with the specified function.
|
||||
* @param {Function} search the predicate to use :
|
||||
* function (relativePath, file) {...}
|
||||
* It takes 2 arguments : the relative path and the file.
|
||||
* @return {Array} An array of matching elements.
|
||||
*/
|
||||
filter: function(search) {
|
||||
var result = [],
|
||||
filename, relativePath, file, fileClone;
|
||||
for (filename in this.files) {
|
||||
if (!this.files.hasOwnProperty(filename)) {
|
||||
continue;
|
||||
}
|
||||
file = this.files[filename];
|
||||
// return a new object, don't let the user mess with our internal objects :)
|
||||
fileClone = new ZipObject(file.name, file._data, extend(file.options));
|
||||
relativePath = filename.slice(this.root.length, filename.length);
|
||||
if (filename.slice(0, this.root.length) === this.root && // the file is in the current root
|
||||
search(relativePath, fileClone)) { // and the file matches the function
|
||||
result.push(fileClone);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a file to the zip file, or search a file.
|
||||
* @param {string|RegExp} name The name of the file to add (if data is defined),
|
||||
* the name of the file to find (if no data) or a regex to match files.
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded
|
||||
* @param {Object} o File options
|
||||
* @return {JSZip|Object|Array} this JSZip object (when adding a file),
|
||||
* a file (when searching by string) or an array of files (when searching by regex).
|
||||
*/
|
||||
file: function(name, data, o) {
|
||||
if (arguments.length === 1) {
|
||||
if (utils.isRegExp(name)) {
|
||||
var regexp = name;
|
||||
return this.filter(function(relativePath, file) {
|
||||
return !file.dir && regexp.test(relativePath);
|
||||
});
|
||||
}
|
||||
else { // text
|
||||
return this.filter(function(relativePath, file) {
|
||||
return !file.dir && relativePath === name;
|
||||
})[0] || null;
|
||||
}
|
||||
}
|
||||
else { // more than one argument : we have data !
|
||||
name = this.root + name;
|
||||
fileAdd.call(this, name, data, o);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a directory to the zip file, or search.
|
||||
* @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.
|
||||
* @return {JSZip} an object with the new directory as the root, or an array containing matching folders.
|
||||
*/
|
||||
folder: function(arg) {
|
||||
if (!arg) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (utils.isRegExp(arg)) {
|
||||
return this.filter(function(relativePath, file) {
|
||||
return file.dir && arg.test(relativePath);
|
||||
});
|
||||
}
|
||||
|
||||
// else, name is a new folder
|
||||
var name = this.root + arg;
|
||||
var newFolder = folderAdd.call(this, name);
|
||||
|
||||
// Allow chaining by returning a new object with this folder as the root
|
||||
var ret = this.clone();
|
||||
ret.root = newFolder.name;
|
||||
return ret;
|
||||
},
|
||||
|
||||
/**
|
||||
* Delete a file, or a directory and all sub-files, from the zip
|
||||
* @param {string} name the name of the file to delete
|
||||
* @return {JSZip} this JSZip object
|
||||
*/
|
||||
remove: function(name) {
|
||||
name = this.root + name;
|
||||
var file = this.files[name];
|
||||
if (!file) {
|
||||
// Look for any folders
|
||||
if (name.slice(-1) != "/") {
|
||||
name += "/";
|
||||
}
|
||||
file = this.files[name];
|
||||
}
|
||||
|
||||
if (file && !file.dir) {
|
||||
// file
|
||||
delete this.files[name];
|
||||
} else {
|
||||
// maybe a folder, delete recursively
|
||||
var kids = this.filter(function(relativePath, file) {
|
||||
return file.name.slice(0, name.length) === name;
|
||||
});
|
||||
for (var i = 0; i < kids.length; i++) {
|
||||
delete this.files[kids[i].name];
|
||||
}
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Generate the complete zip file
|
||||
* @param {Object} options the options to generate the zip file :
|
||||
* - base64, (deprecated, use type instead) true to generate base64.
|
||||
* - compression, "STORE" by default.
|
||||
* - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
|
||||
* @return {String|Uint8Array|ArrayBuffer|Buffer|Blob} the zip file
|
||||
*/
|
||||
generate: function(options) {
|
||||
options = extend(options || {}, {
|
||||
base64: true,
|
||||
compression: "STORE",
|
||||
compressionOptions : null,
|
||||
type: "base64",
|
||||
platform: "DOS",
|
||||
comment: null,
|
||||
mimeType: 'application/zip'
|
||||
});
|
||||
|
||||
utils.checkSupport(options.type);
|
||||
|
||||
// accept nodejs `process.platform`
|
||||
if(
|
||||
options.platform === 'darwin' ||
|
||||
options.platform === 'freebsd' ||
|
||||
options.platform === 'linux' ||
|
||||
options.platform === 'sunos'
|
||||
) {
|
||||
options.platform = "UNIX";
|
||||
}
|
||||
if (options.platform === 'win32') {
|
||||
options.platform = "DOS";
|
||||
}
|
||||
|
||||
var zipData = [],
|
||||
localDirLength = 0,
|
||||
centralDirLength = 0,
|
||||
writer, i,
|
||||
utfEncodedComment = utils.transformTo("string", this.utf8encode(options.comment || this.comment || ""));
|
||||
|
||||
// first, generate all the zip parts.
|
||||
for (var name in this.files) {
|
||||
if (!this.files.hasOwnProperty(name)) {
|
||||
continue;
|
||||
}
|
||||
var file = this.files[name];
|
||||
|
||||
var compressionName = file.options.compression || options.compression.toUpperCase();
|
||||
var compression = compressions[compressionName];
|
||||
if (!compression) {
|
||||
throw new Error(compressionName + " is not a valid compression method !");
|
||||
}
|
||||
var compressionOptions = file.options.compressionOptions || options.compressionOptions || {};
|
||||
|
||||
var compressedObject = generateCompressedObjectFrom.call(this, file, compression, compressionOptions);
|
||||
|
||||
var zipPart = generateZipParts.call(this, name, file, compressedObject, localDirLength, options.platform);
|
||||
localDirLength += zipPart.fileRecord.length + compressedObject.compressedSize;
|
||||
centralDirLength += zipPart.dirRecord.length;
|
||||
zipData.push(zipPart);
|
||||
}
|
||||
|
||||
var dirEnd = "";
|
||||
|
||||
// end of central dir signature
|
||||
dirEnd = signature.CENTRAL_DIRECTORY_END +
|
||||
// number of this disk
|
||||
"\x00\x00" +
|
||||
// number of the disk with the start of the central directory
|
||||
"\x00\x00" +
|
||||
// total number of entries in the central directory on this disk
|
||||
decToHex(zipData.length, 2) +
|
||||
// total number of entries in the central directory
|
||||
decToHex(zipData.length, 2) +
|
||||
// size of the central directory 4 bytes
|
||||
decToHex(centralDirLength, 4) +
|
||||
// offset of start of central directory with respect to the starting disk number
|
||||
decToHex(localDirLength, 4) +
|
||||
// .ZIP file comment length
|
||||
decToHex(utfEncodedComment.length, 2) +
|
||||
// .ZIP file comment
|
||||
utfEncodedComment;
|
||||
|
||||
|
||||
// we have all the parts (and the total length)
|
||||
// time to create a writer !
|
||||
var typeName = options.type.toLowerCase();
|
||||
if(typeName==="uint8array"||typeName==="arraybuffer"||typeName==="blob"||typeName==="nodebuffer") {
|
||||
writer = new Uint8ArrayWriter(localDirLength + centralDirLength + dirEnd.length);
|
||||
}else{
|
||||
writer = new StringWriter(localDirLength + centralDirLength + dirEnd.length);
|
||||
}
|
||||
|
||||
for (i = 0; i < zipData.length; i++) {
|
||||
writer.append(zipData[i].fileRecord);
|
||||
writer.append(zipData[i].compressedObject.compressedContent);
|
||||
}
|
||||
for (i = 0; i < zipData.length; i++) {
|
||||
writer.append(zipData[i].dirRecord);
|
||||
}
|
||||
|
||||
writer.append(dirEnd);
|
||||
|
||||
var zip = writer.finalize();
|
||||
|
||||
|
||||
|
||||
switch(options.type.toLowerCase()) {
|
||||
// case "zip is an Uint8Array"
|
||||
case "uint8array" :
|
||||
case "arraybuffer" :
|
||||
case "nodebuffer" :
|
||||
return utils.transformTo(options.type.toLowerCase(), zip);
|
||||
case "blob" :
|
||||
return utils.arrayBuffer2Blob(utils.transformTo("arraybuffer", zip), options.mimeType);
|
||||
// case "zip is a string"
|
||||
case "base64" :
|
||||
return (options.base64) ? base64.encode(zip) : zip;
|
||||
default : // case "string" :
|
||||
return zip;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
crc32: function (input, crc) {
|
||||
return crc32(input, crc);
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
utf8encode: function (string) {
|
||||
return utils.transformTo("string", utf8.utf8encode(string));
|
||||
},
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* This method will be removed in a future version without replacement.
|
||||
*/
|
||||
utf8decode: function (input) {
|
||||
return utf8.utf8decode(input);
|
||||
}
|
||||
};
|
||||
module.exports = out;
|
7
node_modules/jszip/lib/signature.js
generated
vendored
Normal file
7
node_modules/jszip/lib/signature.js
generated
vendored
Normal file
|
@ -0,0 +1,7 @@
|
|||
'use strict';
|
||||
exports.LOCAL_FILE_HEADER = "PK\x03\x04";
|
||||
exports.CENTRAL_FILE_HEADER = "PK\x01\x02";
|
||||
exports.CENTRAL_DIRECTORY_END = "PK\x05\x06";
|
||||
exports.ZIP64_CENTRAL_DIRECTORY_LOCATOR = "PK\x06\x07";
|
||||
exports.ZIP64_CENTRAL_DIRECTORY_END = "PK\x06\x06";
|
||||
exports.DATA_DESCRIPTOR = "PK\x07\x08";
|
36
node_modules/jszip/lib/stringReader.js
generated
vendored
Normal file
36
node_modules/jszip/lib/stringReader.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
var DataReader = require('./dataReader');
|
||||
var utils = require('./utils');
|
||||
|
||||
function StringReader(data, optimizedBinaryString) {
|
||||
this.data = data;
|
||||
if (!optimizedBinaryString) {
|
||||
this.data = utils.string2binary(this.data);
|
||||
}
|
||||
this.length = this.data.length;
|
||||
this.index = 0;
|
||||
}
|
||||
StringReader.prototype = new DataReader();
|
||||
/**
|
||||
* @see DataReader.byteAt
|
||||
*/
|
||||
StringReader.prototype.byteAt = function(i) {
|
||||
return this.data.charCodeAt(i);
|
||||
};
|
||||
/**
|
||||
* @see DataReader.lastIndexOfSignature
|
||||
*/
|
||||
StringReader.prototype.lastIndexOfSignature = function(sig) {
|
||||
return this.data.lastIndexOf(sig);
|
||||
};
|
||||
/**
|
||||
* @see DataReader.readData
|
||||
*/
|
||||
StringReader.prototype.readData = function(size) {
|
||||
this.checkOffset(size);
|
||||
// this will work because the constructor applied the "& 0xff" mask.
|
||||
var result = this.data.slice(this.index, this.index + size);
|
||||
this.index += size;
|
||||
return result;
|
||||
};
|
||||
module.exports = StringReader;
|
30
node_modules/jszip/lib/stringWriter.js
generated
vendored
Normal file
30
node_modules/jszip/lib/stringWriter.js
generated
vendored
Normal file
|
@ -0,0 +1,30 @@
|
|||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* An object to write any content to a string.
|
||||
* @constructor
|
||||
*/
|
||||
var StringWriter = function() {
|
||||
this.data = [];
|
||||
};
|
||||
StringWriter.prototype = {
|
||||
/**
|
||||
* Append any content to the current string.
|
||||
* @param {Object} input the content to add.
|
||||
*/
|
||||
append: function(input) {
|
||||
input = utils.transformTo("string", input);
|
||||
this.data.push(input);
|
||||
},
|
||||
/**
|
||||
* Finalize the construction an return the result.
|
||||
* @return {string} the generated string.
|
||||
*/
|
||||
finalize: function() {
|
||||
return this.data.join("");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = StringWriter;
|
34
node_modules/jszip/lib/support.js
generated
vendored
Normal file
34
node_modules/jszip/lib/support.js
generated
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
'use strict';
|
||||
exports.base64 = true;
|
||||
exports.array = true;
|
||||
exports.string = true;
|
||||
exports.arraybuffer = typeof ArrayBuffer !== "undefined" && typeof Uint8Array !== "undefined";
|
||||
// contains true if JSZip can read/generate nodejs Buffer, false otherwise.
|
||||
// Browserify will provide a Buffer implementation for browsers, which is
|
||||
// an augmented Uint8Array (i.e., can be used as either Buffer or U8).
|
||||
exports.nodebuffer = typeof Buffer !== "undefined";
|
||||
// contains true if JSZip can read/generate Uint8Array, false otherwise.
|
||||
exports.uint8array = typeof Uint8Array !== "undefined";
|
||||
|
||||
if (typeof ArrayBuffer === "undefined") {
|
||||
exports.blob = false;
|
||||
}
|
||||
else {
|
||||
var buffer = new ArrayBuffer(0);
|
||||
try {
|
||||
exports.blob = new Blob([buffer], {
|
||||
type: "application/zip"
|
||||
}).size === 0;
|
||||
}
|
||||
catch (e) {
|
||||
try {
|
||||
var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
||||
var builder = new Builder();
|
||||
builder.append(buffer);
|
||||
exports.blob = builder.getBlob('application/zip').size === 0;
|
||||
}
|
||||
catch (e) {
|
||||
exports.blob = false;
|
||||
}
|
||||
}
|
||||
}
|
47
node_modules/jszip/lib/uint8ArrayReader.js
generated
vendored
Normal file
47
node_modules/jszip/lib/uint8ArrayReader.js
generated
vendored
Normal file
|
@ -0,0 +1,47 @@
|
|||
'use strict';
|
||||
var DataReader = require('./dataReader');
|
||||
|
||||
function Uint8ArrayReader(data) {
|
||||
if (data) {
|
||||
this.data = data;
|
||||
this.length = this.data.length;
|
||||
this.index = 0;
|
||||
}
|
||||
}
|
||||
Uint8ArrayReader.prototype = new DataReader();
|
||||
/**
|
||||
* @see DataReader.byteAt
|
||||
*/
|
||||
Uint8ArrayReader.prototype.byteAt = function(i) {
|
||||
return this.data[i];
|
||||
};
|
||||
/**
|
||||
* @see DataReader.lastIndexOfSignature
|
||||
*/
|
||||
Uint8ArrayReader.prototype.lastIndexOfSignature = function(sig) {
|
||||
var sig0 = sig.charCodeAt(0),
|
||||
sig1 = sig.charCodeAt(1),
|
||||
sig2 = sig.charCodeAt(2),
|
||||
sig3 = sig.charCodeAt(3);
|
||||
for (var i = this.length - 4; i >= 0; --i) {
|
||||
if (this.data[i] === sig0 && this.data[i + 1] === sig1 && this.data[i + 2] === sig2 && this.data[i + 3] === sig3) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
};
|
||||
/**
|
||||
* @see DataReader.readData
|
||||
*/
|
||||
Uint8ArrayReader.prototype.readData = function(size) {
|
||||
this.checkOffset(size);
|
||||
if(size === 0) {
|
||||
// in IE10, when using subarray(idx, idx), we get the array [0x00] instead of [].
|
||||
return new Uint8Array(0);
|
||||
}
|
||||
var result = this.data.subarray(this.index, this.index + size);
|
||||
this.index += size;
|
||||
return result;
|
||||
};
|
||||
module.exports = Uint8ArrayReader;
|
36
node_modules/jszip/lib/uint8ArrayWriter.js
generated
vendored
Normal file
36
node_modules/jszip/lib/uint8ArrayWriter.js
generated
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
|
||||
/**
|
||||
* An object to write any content to an Uint8Array.
|
||||
* @constructor
|
||||
* @param {number} length The length of the array.
|
||||
*/
|
||||
var Uint8ArrayWriter = function(length) {
|
||||
this.data = new Uint8Array(length);
|
||||
this.index = 0;
|
||||
};
|
||||
Uint8ArrayWriter.prototype = {
|
||||
/**
|
||||
* Append any content to the current array.
|
||||
* @param {Object} input the content to add.
|
||||
*/
|
||||
append: function(input) {
|
||||
if (input.length !== 0) {
|
||||
// with an empty Uint8Array, Opera fails with a "Offset larger than array size"
|
||||
input = utils.transformTo("uint8array", input);
|
||||
this.data.set(input, this.index);
|
||||
this.index += input.length;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Finalize the construction an return the result.
|
||||
* @return {Uint8Array} the generated array.
|
||||
*/
|
||||
finalize: function() {
|
||||
return this.data;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = Uint8ArrayWriter;
|
207
node_modules/jszip/lib/utf8.js
generated
vendored
Normal file
207
node_modules/jszip/lib/utf8.js
generated
vendored
Normal file
|
@ -0,0 +1,207 @@
|
|||
'use strict';
|
||||
|
||||
var utils = require('./utils');
|
||||
var support = require('./support');
|
||||
var nodeBuffer = require('./nodeBuffer');
|
||||
|
||||
/**
|
||||
* The following functions come from pako, from pako/lib/utils/strings
|
||||
* released under the MIT license, see pako https://github.com/nodeca/pako/
|
||||
*/
|
||||
|
||||
// Table with utf8 lengths (calculated by first byte of sequence)
|
||||
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
|
||||
// because max possible codepoint is 0x10ffff
|
||||
var _utf8len = new Array(256);
|
||||
for (var i=0; i<256; i++) {
|
||||
_utf8len[i] = (i >= 252 ? 6 : i >= 248 ? 5 : i >= 240 ? 4 : i >= 224 ? 3 : i >= 192 ? 2 : 1);
|
||||
}
|
||||
_utf8len[254]=_utf8len[254]=1; // Invalid sequence start
|
||||
|
||||
// convert string to array (typed, when possible)
|
||||
var string2buf = function (str) {
|
||||
var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
|
||||
|
||||
// count binary size
|
||||
for (m_pos = 0; m_pos < str_len; m_pos++) {
|
||||
c = str.charCodeAt(m_pos);
|
||||
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
|
||||
c2 = str.charCodeAt(m_pos+1);
|
||||
if ((c2 & 0xfc00) === 0xdc00) {
|
||||
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
||||
m_pos++;
|
||||
}
|
||||
}
|
||||
buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
|
||||
}
|
||||
|
||||
// allocate buffer
|
||||
if (support.uint8array) {
|
||||
buf = new Uint8Array(buf_len);
|
||||
} else {
|
||||
buf = new Array(buf_len);
|
||||
}
|
||||
|
||||
// convert
|
||||
for (i=0, m_pos = 0; i < buf_len; m_pos++) {
|
||||
c = str.charCodeAt(m_pos);
|
||||
if ((c & 0xfc00) === 0xd800 && (m_pos+1 < str_len)) {
|
||||
c2 = str.charCodeAt(m_pos+1);
|
||||
if ((c2 & 0xfc00) === 0xdc00) {
|
||||
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
||||
m_pos++;
|
||||
}
|
||||
}
|
||||
if (c < 0x80) {
|
||||
/* one byte */
|
||||
buf[i++] = c;
|
||||
} else if (c < 0x800) {
|
||||
/* two bytes */
|
||||
buf[i++] = 0xC0 | (c >>> 6);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
} else if (c < 0x10000) {
|
||||
/* three bytes */
|
||||
buf[i++] = 0xE0 | (c >>> 12);
|
||||
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
} else {
|
||||
/* four bytes */
|
||||
buf[i++] = 0xf0 | (c >>> 18);
|
||||
buf[i++] = 0x80 | (c >>> 12 & 0x3f);
|
||||
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
};
|
||||
|
||||
// Calculate max possible position in utf8 buffer,
|
||||
// that will not break sequence. If that's not possible
|
||||
// - (very small limits) return max size as is.
|
||||
//
|
||||
// buf[] - utf8 bytes array
|
||||
// max - length limit (mandatory);
|
||||
var utf8border = function(buf, max) {
|
||||
var pos;
|
||||
|
||||
max = max || buf.length;
|
||||
if (max > buf.length) { max = buf.length; }
|
||||
|
||||
// go back from last position, until start of sequence found
|
||||
pos = max-1;
|
||||
while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
|
||||
|
||||
// Fuckup - very small and broken sequence,
|
||||
// return max, because we should return something anyway.
|
||||
if (pos < 0) { return max; }
|
||||
|
||||
// If we came to start of buffer - that means vuffer is too small,
|
||||
// return max too.
|
||||
if (pos === 0) { return max; }
|
||||
|
||||
return (pos + _utf8len[buf[pos]] > max) ? pos : max;
|
||||
};
|
||||
|
||||
// convert array to string
|
||||
var buf2string = function (buf) {
|
||||
var str, i, out, c, c_len;
|
||||
var len = buf.length;
|
||||
|
||||
// Reserve max possible length (2 words per char)
|
||||
// NB: by unknown reasons, Array is significantly faster for
|
||||
// String.fromCharCode.apply than Uint16Array.
|
||||
var utf16buf = new Array(len*2);
|
||||
|
||||
for (out=0, i=0; i<len;) {
|
||||
c = buf[i++];
|
||||
// quick process ascii
|
||||
if (c < 0x80) { utf16buf[out++] = c; continue; }
|
||||
|
||||
c_len = _utf8len[c];
|
||||
// skip 5 & 6 byte codes
|
||||
if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len-1; continue; }
|
||||
|
||||
// apply mask on first byte
|
||||
c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
|
||||
// join the rest
|
||||
while (c_len > 1 && i < len) {
|
||||
c = (c << 6) | (buf[i++] & 0x3f);
|
||||
c_len--;
|
||||
}
|
||||
|
||||
// terminated by end of string?
|
||||
if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
|
||||
|
||||
if (c < 0x10000) {
|
||||
utf16buf[out++] = c;
|
||||
} else {
|
||||
c -= 0x10000;
|
||||
utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
|
||||
utf16buf[out++] = 0xdc00 | (c & 0x3ff);
|
||||
}
|
||||
}
|
||||
|
||||
// shrinkBuf(utf16buf, out)
|
||||
if (utf16buf.length !== out) {
|
||||
if(utf16buf.subarray) {
|
||||
utf16buf = utf16buf.subarray(0, out);
|
||||
} else {
|
||||
utf16buf.length = out;
|
||||
}
|
||||
}
|
||||
|
||||
// return String.fromCharCode.apply(null, utf16buf);
|
||||
return utils.applyFromCharCode(utf16buf);
|
||||
};
|
||||
|
||||
|
||||
// That's all for the pako functions.
|
||||
|
||||
|
||||
/**
|
||||
* Transform a javascript string into an array (typed if possible) of bytes,
|
||||
* UTF-8 encoded.
|
||||
* @param {String} str the string to encode
|
||||
* @return {Array|Uint8Array|Buffer} the UTF-8 encoded string.
|
||||
*/
|
||||
exports.utf8encode = function utf8encode(str) {
|
||||
if (support.nodebuffer) {
|
||||
return nodeBuffer(str, "utf-8");
|
||||
}
|
||||
|
||||
return string2buf(str);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Transform a bytes array (or a representation) representing an UTF-8 encoded
|
||||
* string into a javascript string.
|
||||
* @param {Array|Uint8Array|Buffer} buf the data de decode
|
||||
* @return {String} the decoded string.
|
||||
*/
|
||||
exports.utf8decode = function utf8decode(buf) {
|
||||
if (support.nodebuffer) {
|
||||
return utils.transformTo("nodebuffer", buf).toString("utf-8");
|
||||
}
|
||||
|
||||
buf = utils.transformTo(support.uint8array ? "uint8array" : "array", buf);
|
||||
|
||||
// return buf2string(buf);
|
||||
// Chrome prefers to work with "small" chunks of data
|
||||
// for the method buf2string.
|
||||
// Firefox and Chrome has their own shortcut, IE doesn't seem to really care.
|
||||
var result = [], k = 0, len = buf.length, chunk = 65536;
|
||||
while (k < len) {
|
||||
var nextBoundary = utf8border(buf, Math.min(k + chunk, len));
|
||||
if (support.uint8array) {
|
||||
result.push(buf2string(buf.subarray(k, nextBoundary)));
|
||||
} else {
|
||||
result.push(buf2string(buf.slice(k, nextBoundary)));
|
||||
}
|
||||
k = nextBoundary;
|
||||
}
|
||||
return result.join("");
|
||||
|
||||
};
|
||||
// vim: set shiftwidth=4 softtabstop=4:
|
326
node_modules/jszip/lib/utils.js
generated
vendored
Normal file
326
node_modules/jszip/lib/utils.js
generated
vendored
Normal file
|
@ -0,0 +1,326 @@
|
|||
'use strict';
|
||||
var support = require('./support');
|
||||
var compressions = require('./compressions');
|
||||
var nodeBuffer = require('./nodeBuffer');
|
||||
/**
|
||||
* Convert a string to a "binary string" : a string containing only char codes between 0 and 255.
|
||||
* @param {string} str the string to transform.
|
||||
* @return {String} the binary string.
|
||||
*/
|
||||
exports.string2binary = function(str) {
|
||||
var result = "";
|
||||
for (var i = 0; i < str.length; i++) {
|
||||
result += String.fromCharCode(str.charCodeAt(i) & 0xff);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
exports.arrayBuffer2Blob = function(buffer, mimeType) {
|
||||
exports.checkSupport("blob");
|
||||
mimeType = mimeType || 'application/zip';
|
||||
|
||||
try {
|
||||
// Blob constructor
|
||||
return new Blob([buffer], {
|
||||
type: mimeType
|
||||
});
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
try {
|
||||
// deprecated, browser only, old way
|
||||
var Builder = window.BlobBuilder || window.WebKitBlobBuilder || window.MozBlobBuilder || window.MSBlobBuilder;
|
||||
var builder = new Builder();
|
||||
builder.append(buffer);
|
||||
return builder.getBlob(mimeType);
|
||||
}
|
||||
catch (e) {
|
||||
|
||||
// well, fuck ?!
|
||||
throw new Error("Bug : can't construct the Blob.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
/**
|
||||
* The identity function.
|
||||
* @param {Object} input the input.
|
||||
* @return {Object} the same input.
|
||||
*/
|
||||
function identity(input) {
|
||||
return input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill in an array with a string.
|
||||
* @param {String} str the string to use.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).
|
||||
* @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.
|
||||
*/
|
||||
function stringToArrayLike(str, array) {
|
||||
for (var i = 0; i < str.length; ++i) {
|
||||
array[i] = str.charCodeAt(i) & 0xFF;
|
||||
}
|
||||
return array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform an array-like object to a string.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
|
||||
* @return {String} the result.
|
||||
*/
|
||||
function arrayLikeToString(array) {
|
||||
// Performances notes :
|
||||
// --------------------
|
||||
// String.fromCharCode.apply(null, array) is the fastest, see
|
||||
// see http://jsperf.com/converting-a-uint8array-to-a-string/2
|
||||
// but the stack is limited (and we can get huge arrays !).
|
||||
//
|
||||
// result += String.fromCharCode(array[i]); generate too many strings !
|
||||
//
|
||||
// This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
|
||||
var chunk = 65536;
|
||||
var result = [],
|
||||
len = array.length,
|
||||
type = exports.getTypeOf(array),
|
||||
k = 0,
|
||||
canUseApply = true;
|
||||
try {
|
||||
switch(type) {
|
||||
case "uint8array":
|
||||
String.fromCharCode.apply(null, new Uint8Array(0));
|
||||
break;
|
||||
case "nodebuffer":
|
||||
String.fromCharCode.apply(null, nodeBuffer(0));
|
||||
break;
|
||||
}
|
||||
} catch(e) {
|
||||
canUseApply = false;
|
||||
}
|
||||
|
||||
// no apply : slow and painful algorithm
|
||||
// default browser on android 4.*
|
||||
if (!canUseApply) {
|
||||
var resultStr = "";
|
||||
for(var i = 0; i < array.length;i++) {
|
||||
resultStr += String.fromCharCode(array[i]);
|
||||
}
|
||||
return resultStr;
|
||||
}
|
||||
while (k < len && chunk > 1) {
|
||||
try {
|
||||
if (type === "array" || type === "nodebuffer") {
|
||||
result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
|
||||
}
|
||||
else {
|
||||
result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
|
||||
}
|
||||
k += chunk;
|
||||
}
|
||||
catch (e) {
|
||||
chunk = Math.floor(chunk / 2);
|
||||
}
|
||||
}
|
||||
return result.join("");
|
||||
}
|
||||
|
||||
exports.applyFromCharCode = arrayLikeToString;
|
||||
|
||||
|
||||
/**
|
||||
* Copy the data from an array-like to an other array-like.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.
|
||||
* @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.
|
||||
* @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.
|
||||
*/
|
||||
function arrayLikeToArrayLike(arrayFrom, arrayTo) {
|
||||
for (var i = 0; i < arrayFrom.length; i++) {
|
||||
arrayTo[i] = arrayFrom[i];
|
||||
}
|
||||
return arrayTo;
|
||||
}
|
||||
|
||||
// a matrix containing functions to transform everything into everything.
|
||||
var transform = {};
|
||||
|
||||
// string to ?
|
||||
transform["string"] = {
|
||||
"string": identity,
|
||||
"array": function(input) {
|
||||
return stringToArrayLike(input, new Array(input.length));
|
||||
},
|
||||
"arraybuffer": function(input) {
|
||||
return transform["string"]["uint8array"](input).buffer;
|
||||
},
|
||||
"uint8array": function(input) {
|
||||
return stringToArrayLike(input, new Uint8Array(input.length));
|
||||
},
|
||||
"nodebuffer": function(input) {
|
||||
return stringToArrayLike(input, nodeBuffer(input.length));
|
||||
}
|
||||
};
|
||||
|
||||
// array to ?
|
||||
transform["array"] = {
|
||||
"string": arrayLikeToString,
|
||||
"array": identity,
|
||||
"arraybuffer": function(input) {
|
||||
return (new Uint8Array(input)).buffer;
|
||||
},
|
||||
"uint8array": function(input) {
|
||||
return new Uint8Array(input);
|
||||
},
|
||||
"nodebuffer": function(input) {
|
||||
return nodeBuffer(input);
|
||||
}
|
||||
};
|
||||
|
||||
// arraybuffer to ?
|
||||
transform["arraybuffer"] = {
|
||||
"string": function(input) {
|
||||
return arrayLikeToString(new Uint8Array(input));
|
||||
},
|
||||
"array": function(input) {
|
||||
return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
|
||||
},
|
||||
"arraybuffer": identity,
|
||||
"uint8array": function(input) {
|
||||
return new Uint8Array(input);
|
||||
},
|
||||
"nodebuffer": function(input) {
|
||||
return nodeBuffer(new Uint8Array(input));
|
||||
}
|
||||
};
|
||||
|
||||
// uint8array to ?
|
||||
transform["uint8array"] = {
|
||||
"string": arrayLikeToString,
|
||||
"array": function(input) {
|
||||
return arrayLikeToArrayLike(input, new Array(input.length));
|
||||
},
|
||||
"arraybuffer": function(input) {
|
||||
return input.buffer;
|
||||
},
|
||||
"uint8array": identity,
|
||||
"nodebuffer": function(input) {
|
||||
return nodeBuffer(input);
|
||||
}
|
||||
};
|
||||
|
||||
// nodebuffer to ?
|
||||
transform["nodebuffer"] = {
|
||||
"string": arrayLikeToString,
|
||||
"array": function(input) {
|
||||
return arrayLikeToArrayLike(input, new Array(input.length));
|
||||
},
|
||||
"arraybuffer": function(input) {
|
||||
return transform["nodebuffer"]["uint8array"](input).buffer;
|
||||
},
|
||||
"uint8array": function(input) {
|
||||
return arrayLikeToArrayLike(input, new Uint8Array(input.length));
|
||||
},
|
||||
"nodebuffer": identity
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform an input into any type.
|
||||
* The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.
|
||||
* If no output type is specified, the unmodified input will be returned.
|
||||
* @param {String} outputType the output type.
|
||||
* @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.
|
||||
* @throws {Error} an Error if the browser doesn't support the requested output type.
|
||||
*/
|
||||
exports.transformTo = function(outputType, input) {
|
||||
if (!input) {
|
||||
// undefined, null, etc
|
||||
// an empty string won't harm.
|
||||
input = "";
|
||||
}
|
||||
if (!outputType) {
|
||||
return input;
|
||||
}
|
||||
exports.checkSupport(outputType);
|
||||
var inputType = exports.getTypeOf(input);
|
||||
var result = transform[inputType][outputType](input);
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the type of the input.
|
||||
* The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.
|
||||
* @param {Object} input the input to identify.
|
||||
* @return {String} the (lowercase) type of the input.
|
||||
*/
|
||||
exports.getTypeOf = function(input) {
|
||||
if (typeof input === "string") {
|
||||
return "string";
|
||||
}
|
||||
if (Object.prototype.toString.call(input) === "[object Array]") {
|
||||
return "array";
|
||||
}
|
||||
if (support.nodebuffer && nodeBuffer.test(input)) {
|
||||
return "nodebuffer";
|
||||
}
|
||||
if (support.uint8array && input instanceof Uint8Array) {
|
||||
return "uint8array";
|
||||
}
|
||||
if (support.arraybuffer && input instanceof ArrayBuffer) {
|
||||
return "arraybuffer";
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Throw an exception if the type is not supported.
|
||||
* @param {String} type the type to check.
|
||||
* @throws {Error} an Error if the browser doesn't support the requested type.
|
||||
*/
|
||||
exports.checkSupport = function(type) {
|
||||
var supported = support[type.toLowerCase()];
|
||||
if (!supported) {
|
||||
throw new Error(type + " is not supported by this browser");
|
||||
}
|
||||
};
|
||||
exports.MAX_VALUE_16BITS = 65535;
|
||||
exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1
|
||||
|
||||
/**
|
||||
* Prettify a string read as binary.
|
||||
* @param {string} str the string to prettify.
|
||||
* @return {string} a pretty string.
|
||||
*/
|
||||
exports.pretty = function(str) {
|
||||
var res = '',
|
||||
code, i;
|
||||
for (i = 0; i < (str || "").length; i++) {
|
||||
code = str.charCodeAt(i);
|
||||
res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
|
||||
}
|
||||
return res;
|
||||
};
|
||||
|
||||
/**
|
||||
* Find a compression registered in JSZip.
|
||||
* @param {string} compressionMethod the method magic to find.
|
||||
* @return {Object|null} the JSZip compression object, null if none found.
|
||||
*/
|
||||
exports.findCompression = function(compressionMethod) {
|
||||
for (var method in compressions) {
|
||||
if (!compressions.hasOwnProperty(method)) {
|
||||
continue;
|
||||
}
|
||||
if (compressions[method].magic === compressionMethod) {
|
||||
return compressions[method];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/**
|
||||
* Cross-window, cross-Node-context regular expression detection
|
||||
* @param {Object} object Anything
|
||||
* @return {Boolean} true if the object is a regular expression,
|
||||
* false otherwise
|
||||
*/
|
||||
exports.isRegExp = function (object) {
|
||||
return Object.prototype.toString.call(object) === "[object RegExp]";
|
||||
};
|
||||
|
221
node_modules/jszip/lib/zipEntries.js
generated
vendored
Normal file
221
node_modules/jszip/lib/zipEntries.js
generated
vendored
Normal file
|
@ -0,0 +1,221 @@
|
|||
'use strict';
|
||||
var StringReader = require('./stringReader');
|
||||
var NodeBufferReader = require('./nodeBufferReader');
|
||||
var Uint8ArrayReader = require('./uint8ArrayReader');
|
||||
var utils = require('./utils');
|
||||
var sig = require('./signature');
|
||||
var ZipEntry = require('./zipEntry');
|
||||
var support = require('./support');
|
||||
var jszipProto = require('./object');
|
||||
// class ZipEntries {{{
|
||||
/**
|
||||
* All the entries in the zip file.
|
||||
* @constructor
|
||||
* @param {String|ArrayBuffer|Uint8Array} data the binary stream to load.
|
||||
* @param {Object} loadOptions Options for loading the stream.
|
||||
*/
|
||||
function ZipEntries(data, loadOptions) {
|
||||
this.files = [];
|
||||
this.loadOptions = loadOptions;
|
||||
if (data) {
|
||||
this.load(data);
|
||||
}
|
||||
}
|
||||
ZipEntries.prototype = {
|
||||
/**
|
||||
* Check that the reader is on the speficied signature.
|
||||
* @param {string} expectedSignature the expected signature.
|
||||
* @throws {Error} if it is an other signature.
|
||||
*/
|
||||
checkSignature: function(expectedSignature) {
|
||||
var signature = this.reader.readString(4);
|
||||
if (signature !== expectedSignature) {
|
||||
throw new Error("Corrupted zip or bug : unexpected signature " + "(" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the end of the central directory.
|
||||
*/
|
||||
readBlockEndOfCentral: function() {
|
||||
this.diskNumber = this.reader.readInt(2);
|
||||
this.diskWithCentralDirStart = this.reader.readInt(2);
|
||||
this.centralDirRecordsOnThisDisk = this.reader.readInt(2);
|
||||
this.centralDirRecords = this.reader.readInt(2);
|
||||
this.centralDirSize = this.reader.readInt(4);
|
||||
this.centralDirOffset = this.reader.readInt(4);
|
||||
|
||||
this.zipCommentLength = this.reader.readInt(2);
|
||||
// warning : the encoding depends of the system locale
|
||||
// On a linux machine with LANG=en_US.utf8, this field is utf8 encoded.
|
||||
// On a windows machine, this field is encoded with the localized windows code page.
|
||||
this.zipComment = this.reader.readString(this.zipCommentLength);
|
||||
// To get consistent behavior with the generation part, we will assume that
|
||||
// this is utf8 encoded.
|
||||
this.zipComment = jszipProto.utf8decode(this.zipComment);
|
||||
},
|
||||
/**
|
||||
* Read the end of the Zip 64 central directory.
|
||||
* Not merged with the method readEndOfCentral :
|
||||
* The end of central can coexist with its Zip64 brother,
|
||||
* I don't want to read the wrong number of bytes !
|
||||
*/
|
||||
readBlockZip64EndOfCentral: function() {
|
||||
this.zip64EndOfCentralSize = this.reader.readInt(8);
|
||||
this.versionMadeBy = this.reader.readString(2);
|
||||
this.versionNeeded = this.reader.readInt(2);
|
||||
this.diskNumber = this.reader.readInt(4);
|
||||
this.diskWithCentralDirStart = this.reader.readInt(4);
|
||||
this.centralDirRecordsOnThisDisk = this.reader.readInt(8);
|
||||
this.centralDirRecords = this.reader.readInt(8);
|
||||
this.centralDirSize = this.reader.readInt(8);
|
||||
this.centralDirOffset = this.reader.readInt(8);
|
||||
|
||||
this.zip64ExtensibleData = {};
|
||||
var extraDataSize = this.zip64EndOfCentralSize - 44,
|
||||
index = 0,
|
||||
extraFieldId,
|
||||
extraFieldLength,
|
||||
extraFieldValue;
|
||||
while (index < extraDataSize) {
|
||||
extraFieldId = this.reader.readInt(2);
|
||||
extraFieldLength = this.reader.readInt(4);
|
||||
extraFieldValue = this.reader.readString(extraFieldLength);
|
||||
this.zip64ExtensibleData[extraFieldId] = {
|
||||
id: extraFieldId,
|
||||
length: extraFieldLength,
|
||||
value: extraFieldValue
|
||||
};
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the end of the Zip 64 central directory locator.
|
||||
*/
|
||||
readBlockZip64EndOfCentralLocator: function() {
|
||||
this.diskWithZip64CentralDirStart = this.reader.readInt(4);
|
||||
this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
|
||||
this.disksCount = this.reader.readInt(4);
|
||||
if (this.disksCount > 1) {
|
||||
throw new Error("Multi-volumes zip are not supported");
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the local files, based on the offset read in the central part.
|
||||
*/
|
||||
readLocalFiles: function() {
|
||||
var i, file;
|
||||
for (i = 0; i < this.files.length; i++) {
|
||||
file = this.files[i];
|
||||
this.reader.setIndex(file.localHeaderOffset);
|
||||
this.checkSignature(sig.LOCAL_FILE_HEADER);
|
||||
file.readLocalPart(this.reader);
|
||||
file.handleUTF8();
|
||||
file.processAttributes();
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the central directory.
|
||||
*/
|
||||
readCentralDir: function() {
|
||||
var file;
|
||||
|
||||
this.reader.setIndex(this.centralDirOffset);
|
||||
while (this.reader.readString(4) === sig.CENTRAL_FILE_HEADER) {
|
||||
file = new ZipEntry({
|
||||
zip64: this.zip64
|
||||
}, this.loadOptions);
|
||||
file.readCentralPart(this.reader);
|
||||
this.files.push(file);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the end of central directory.
|
||||
*/
|
||||
readEndOfCentral: function() {
|
||||
var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
|
||||
if (offset === -1) {
|
||||
// Check if the content is a truncated zip or complete garbage.
|
||||
// A "LOCAL_FILE_HEADER" is not required at the beginning (auto
|
||||
// extractible zip for example) but it can give a good hint.
|
||||
// If an ajax request was used without responseType, we will also
|
||||
// get unreadable data.
|
||||
var isGarbage = true;
|
||||
try {
|
||||
this.reader.setIndex(0);
|
||||
this.checkSignature(sig.LOCAL_FILE_HEADER);
|
||||
isGarbage = false;
|
||||
} catch (e) {}
|
||||
|
||||
if (isGarbage) {
|
||||
throw new Error("Can't find end of central directory : is this a zip file ? " +
|
||||
"If it is, see http://stuk.github.io/jszip/documentation/howto/read_zip.html");
|
||||
} else {
|
||||
throw new Error("Corrupted zip : can't find end of central directory");
|
||||
}
|
||||
}
|
||||
this.reader.setIndex(offset);
|
||||
this.checkSignature(sig.CENTRAL_DIRECTORY_END);
|
||||
this.readBlockEndOfCentral();
|
||||
|
||||
|
||||
/* extract from the zip spec :
|
||||
4) If one of the fields in the end of central directory
|
||||
record is too small to hold required data, the field
|
||||
should be set to -1 (0xFFFF or 0xFFFFFFFF) and the
|
||||
ZIP64 format record should be created.
|
||||
5) The end of central directory record and the
|
||||
Zip64 end of central directory locator record must
|
||||
reside on the same disk when splitting or spanning
|
||||
an archive.
|
||||
*/
|
||||
if (this.diskNumber === utils.MAX_VALUE_16BITS || this.diskWithCentralDirStart === utils.MAX_VALUE_16BITS || this.centralDirRecordsOnThisDisk === utils.MAX_VALUE_16BITS || this.centralDirRecords === utils.MAX_VALUE_16BITS || this.centralDirSize === utils.MAX_VALUE_32BITS || this.centralDirOffset === utils.MAX_VALUE_32BITS) {
|
||||
this.zip64 = true;
|
||||
|
||||
/*
|
||||
Warning : the zip64 extension is supported, but ONLY if the 64bits integer read from
|
||||
the zip file can fit into a 32bits integer. This cannot be solved : Javascript represents
|
||||
all numbers as 64-bit double precision IEEE 754 floating point numbers.
|
||||
So, we have 53bits for integers and bitwise operations treat everything as 32bits.
|
||||
see https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Operators/Bitwise_Operators
|
||||
and http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf section 8.5
|
||||
*/
|
||||
|
||||
// should look for a zip64 EOCD locator
|
||||
offset = this.reader.lastIndexOfSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
|
||||
if (offset === -1) {
|
||||
throw new Error("Corrupted zip : can't find the ZIP64 end of central directory locator");
|
||||
}
|
||||
this.reader.setIndex(offset);
|
||||
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_LOCATOR);
|
||||
this.readBlockZip64EndOfCentralLocator();
|
||||
|
||||
// now the zip64 EOCD record
|
||||
this.reader.setIndex(this.relativeOffsetEndOfZip64CentralDir);
|
||||
this.checkSignature(sig.ZIP64_CENTRAL_DIRECTORY_END);
|
||||
this.readBlockZip64EndOfCentral();
|
||||
}
|
||||
},
|
||||
prepareReader: function(data) {
|
||||
var type = utils.getTypeOf(data);
|
||||
if (type === "string" && !support.uint8array) {
|
||||
this.reader = new StringReader(data, this.loadOptions.optimizedBinaryString);
|
||||
}
|
||||
else if (type === "nodebuffer") {
|
||||
this.reader = new NodeBufferReader(data);
|
||||
}
|
||||
else {
|
||||
this.reader = new Uint8ArrayReader(utils.transformTo("uint8array", data));
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read a zip file and create ZipEntries.
|
||||
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.
|
||||
*/
|
||||
load: function(data) {
|
||||
this.prepareReader(data);
|
||||
this.readEndOfCentral();
|
||||
this.readCentralDir();
|
||||
this.readLocalFiles();
|
||||
}
|
||||
};
|
||||
// }}} end of ZipEntries
|
||||
module.exports = ZipEntries;
|
310
node_modules/jszip/lib/zipEntry.js
generated
vendored
Normal file
310
node_modules/jszip/lib/zipEntry.js
generated
vendored
Normal file
|
@ -0,0 +1,310 @@
|
|||
'use strict';
|
||||
var StringReader = require('./stringReader');
|
||||
var utils = require('./utils');
|
||||
var CompressedObject = require('./compressedObject');
|
||||
var jszipProto = require('./object');
|
||||
|
||||
var MADE_BY_DOS = 0x00;
|
||||
var MADE_BY_UNIX = 0x03;
|
||||
|
||||
// class ZipEntry {{{
|
||||
/**
|
||||
* An entry in the zip file.
|
||||
* @constructor
|
||||
* @param {Object} options Options of the current file.
|
||||
* @param {Object} loadOptions Options for loading the stream.
|
||||
*/
|
||||
function ZipEntry(options, loadOptions) {
|
||||
this.options = options;
|
||||
this.loadOptions = loadOptions;
|
||||
}
|
||||
ZipEntry.prototype = {
|
||||
/**
|
||||
* say if the file is encrypted.
|
||||
* @return {boolean} true if the file is encrypted, false otherwise.
|
||||
*/
|
||||
isEncrypted: function() {
|
||||
// bit 1 is set
|
||||
return (this.bitFlag & 0x0001) === 0x0001;
|
||||
},
|
||||
/**
|
||||
* say if the file has utf-8 filename/comment.
|
||||
* @return {boolean} true if the filename/comment is in utf-8, false otherwise.
|
||||
*/
|
||||
useUTF8: function() {
|
||||
// bit 11 is set
|
||||
return (this.bitFlag & 0x0800) === 0x0800;
|
||||
},
|
||||
/**
|
||||
* Prepare the function used to generate the compressed content from this ZipFile.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
* @param {number} from the offset from where we should read the data.
|
||||
* @param {number} length the length of the data to read.
|
||||
* @return {Function} the callback to get the compressed content (the type depends of the DataReader class).
|
||||
*/
|
||||
prepareCompressedContent: function(reader, from, length) {
|
||||
return function() {
|
||||
var previousIndex = reader.index;
|
||||
reader.setIndex(from);
|
||||
var compressedFileData = reader.readData(length);
|
||||
reader.setIndex(previousIndex);
|
||||
|
||||
return compressedFileData;
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Prepare the function used to generate the uncompressed content from this ZipFile.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
* @param {number} from the offset from where we should read the data.
|
||||
* @param {number} length the length of the data to read.
|
||||
* @param {JSZip.compression} compression the compression used on this file.
|
||||
* @param {number} uncompressedSize the uncompressed size to expect.
|
||||
* @return {Function} the callback to get the uncompressed content (the type depends of the DataReader class).
|
||||
*/
|
||||
prepareContent: function(reader, from, length, compression, uncompressedSize) {
|
||||
return function() {
|
||||
|
||||
var compressedFileData = utils.transformTo(compression.uncompressInputType, this.getCompressedContent());
|
||||
var uncompressedFileData = compression.uncompress(compressedFileData);
|
||||
|
||||
if (uncompressedFileData.length !== uncompressedSize) {
|
||||
throw new Error("Bug : uncompressed data size mismatch");
|
||||
}
|
||||
|
||||
return uncompressedFileData;
|
||||
};
|
||||
},
|
||||
/**
|
||||
* Read the local part of a zip file and add the info in this object.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
readLocalPart: function(reader) {
|
||||
var compression, localExtraFieldsLength;
|
||||
|
||||
// we already know everything from the central dir !
|
||||
// If the central dir data are false, we are doomed.
|
||||
// On the bright side, the local part is scary : zip64, data descriptors, both, etc.
|
||||
// The less data we get here, the more reliable this should be.
|
||||
// Let's skip the whole header and dash to the data !
|
||||
reader.skip(22);
|
||||
// in some zip created on windows, the filename stored in the central dir contains \ instead of /.
|
||||
// Strangely, the filename here is OK.
|
||||
// I would love to treat these zip files as corrupted (see http://www.info-zip.org/FAQ.html#backslashes
|
||||
// or APPNOTE#4.4.17.1, "All slashes MUST be forward slashes '/'") but there are a lot of bad zip generators...
|
||||
// Search "unzip mismatching "local" filename continuing with "central" filename version" on
|
||||
// the internet.
|
||||
//
|
||||
// I think I see the logic here : the central directory is used to display
|
||||
// content and the local directory is used to extract the files. Mixing / and \
|
||||
// may be used to display \ to windows users and use / when extracting the files.
|
||||
// Unfortunately, this lead also to some issues : http://seclists.org/fulldisclosure/2009/Sep/394
|
||||
this.fileNameLength = reader.readInt(2);
|
||||
localExtraFieldsLength = reader.readInt(2); // can't be sure this will be the same as the central dir
|
||||
this.fileName = reader.readString(this.fileNameLength);
|
||||
reader.skip(localExtraFieldsLength);
|
||||
|
||||
if (this.compressedSize == -1 || this.uncompressedSize == -1) {
|
||||
throw new Error("Bug or corrupted zip : didn't get enough informations from the central directory " + "(compressedSize == -1 || uncompressedSize == -1)");
|
||||
}
|
||||
|
||||
compression = utils.findCompression(this.compressionMethod);
|
||||
if (compression === null) { // no compression found
|
||||
throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + this.fileName + ")");
|
||||
}
|
||||
this.decompressed = new CompressedObject();
|
||||
this.decompressed.compressedSize = this.compressedSize;
|
||||
this.decompressed.uncompressedSize = this.uncompressedSize;
|
||||
this.decompressed.crc32 = this.crc32;
|
||||
this.decompressed.compressionMethod = this.compressionMethod;
|
||||
this.decompressed.getCompressedContent = this.prepareCompressedContent(reader, reader.index, this.compressedSize, compression);
|
||||
this.decompressed.getContent = this.prepareContent(reader, reader.index, this.compressedSize, compression, this.uncompressedSize);
|
||||
|
||||
// we need to compute the crc32...
|
||||
if (this.loadOptions.checkCRC32) {
|
||||
this.decompressed = utils.transformTo("string", this.decompressed.getContent());
|
||||
if (jszipProto.crc32(this.decompressed) !== this.crc32) {
|
||||
throw new Error("Corrupted zip : CRC32 mismatch");
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Read the central part of a zip file and add the info in this object.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
readCentralPart: function(reader) {
|
||||
this.versionMadeBy = reader.readInt(2);
|
||||
this.versionNeeded = reader.readInt(2);
|
||||
this.bitFlag = reader.readInt(2);
|
||||
this.compressionMethod = reader.readString(2);
|
||||
this.date = reader.readDate();
|
||||
this.crc32 = reader.readInt(4);
|
||||
this.compressedSize = reader.readInt(4);
|
||||
this.uncompressedSize = reader.readInt(4);
|
||||
this.fileNameLength = reader.readInt(2);
|
||||
this.extraFieldsLength = reader.readInt(2);
|
||||
this.fileCommentLength = reader.readInt(2);
|
||||
this.diskNumberStart = reader.readInt(2);
|
||||
this.internalFileAttributes = reader.readInt(2);
|
||||
this.externalFileAttributes = reader.readInt(4);
|
||||
this.localHeaderOffset = reader.readInt(4);
|
||||
|
||||
if (this.isEncrypted()) {
|
||||
throw new Error("Encrypted zip are not supported");
|
||||
}
|
||||
|
||||
this.fileName = reader.readString(this.fileNameLength);
|
||||
this.readExtraFields(reader);
|
||||
this.parseZIP64ExtraField(reader);
|
||||
this.fileComment = reader.readString(this.fileCommentLength);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the external file attributes and get the unix/dos permissions.
|
||||
*/
|
||||
processAttributes: function () {
|
||||
this.unixPermissions = null;
|
||||
this.dosPermissions = null;
|
||||
var madeBy = this.versionMadeBy >> 8;
|
||||
|
||||
// Check if we have the DOS directory flag set.
|
||||
// We look for it in the DOS and UNIX permissions
|
||||
// but some unknown platform could set it as a compatibility flag.
|
||||
this.dir = this.externalFileAttributes & 0x0010 ? true : false;
|
||||
|
||||
if(madeBy === MADE_BY_DOS) {
|
||||
// first 6 bits (0 to 5)
|
||||
this.dosPermissions = this.externalFileAttributes & 0x3F;
|
||||
}
|
||||
|
||||
if(madeBy === MADE_BY_UNIX) {
|
||||
this.unixPermissions = (this.externalFileAttributes >> 16) & 0xFFFF;
|
||||
// the octal permissions are in (this.unixPermissions & 0x01FF).toString(8);
|
||||
}
|
||||
|
||||
// fail safe : if the name ends with a / it probably means a folder
|
||||
if (!this.dir && this.fileName.slice(-1) === '/') {
|
||||
this.dir = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parse the ZIP64 extra field and merge the info in the current ZipEntry.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
parseZIP64ExtraField: function(reader) {
|
||||
|
||||
if (!this.extraFields[0x0001]) {
|
||||
return;
|
||||
}
|
||||
|
||||
// should be something, preparing the extra reader
|
||||
var extraReader = new StringReader(this.extraFields[0x0001].value);
|
||||
|
||||
// I really hope that these 64bits integer can fit in 32 bits integer, because js
|
||||
// won't let us have more.
|
||||
if (this.uncompressedSize === utils.MAX_VALUE_32BITS) {
|
||||
this.uncompressedSize = extraReader.readInt(8);
|
||||
}
|
||||
if (this.compressedSize === utils.MAX_VALUE_32BITS) {
|
||||
this.compressedSize = extraReader.readInt(8);
|
||||
}
|
||||
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) {
|
||||
this.localHeaderOffset = extraReader.readInt(8);
|
||||
}
|
||||
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) {
|
||||
this.diskNumberStart = extraReader.readInt(4);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Read the central part of a zip file and add the info in this object.
|
||||
* @param {DataReader} reader the reader to use.
|
||||
*/
|
||||
readExtraFields: function(reader) {
|
||||
var start = reader.index,
|
||||
extraFieldId,
|
||||
extraFieldLength,
|
||||
extraFieldValue;
|
||||
|
||||
this.extraFields = this.extraFields || {};
|
||||
|
||||
while (reader.index < start + this.extraFieldsLength) {
|
||||
extraFieldId = reader.readInt(2);
|
||||
extraFieldLength = reader.readInt(2);
|
||||
extraFieldValue = reader.readString(extraFieldLength);
|
||||
|
||||
this.extraFields[extraFieldId] = {
|
||||
id: extraFieldId,
|
||||
length: extraFieldLength,
|
||||
value: extraFieldValue
|
||||
};
|
||||
}
|
||||
},
|
||||
/**
|
||||
* Apply an UTF8 transformation if needed.
|
||||
*/
|
||||
handleUTF8: function() {
|
||||
if (this.useUTF8()) {
|
||||
this.fileName = jszipProto.utf8decode(this.fileName);
|
||||
this.fileComment = jszipProto.utf8decode(this.fileComment);
|
||||
} else {
|
||||
var upath = this.findExtraFieldUnicodePath();
|
||||
if (upath !== null) {
|
||||
this.fileName = upath;
|
||||
}
|
||||
var ucomment = this.findExtraFieldUnicodeComment();
|
||||
if (ucomment !== null) {
|
||||
this.fileComment = ucomment;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the unicode path declared in the extra field, if any.
|
||||
* @return {String} the unicode path, null otherwise.
|
||||
*/
|
||||
findExtraFieldUnicodePath: function() {
|
||||
var upathField = this.extraFields[0x7075];
|
||||
if (upathField) {
|
||||
var extraReader = new StringReader(upathField.value);
|
||||
|
||||
// wrong version
|
||||
if (extraReader.readInt(1) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// the crc of the filename changed, this field is out of date.
|
||||
if (jszipProto.crc32(this.fileName) !== extraReader.readInt(4)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jszipProto.utf8decode(extraReader.readString(upathField.length - 5));
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Find the unicode comment declared in the extra field, if any.
|
||||
* @return {String} the unicode comment, null otherwise.
|
||||
*/
|
||||
findExtraFieldUnicodeComment: function() {
|
||||
var ucommentField = this.extraFields[0x6375];
|
||||
if (ucommentField) {
|
||||
var extraReader = new StringReader(ucommentField.value);
|
||||
|
||||
// wrong version
|
||||
if (extraReader.readInt(1) !== 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// the crc of the comment changed, this field is out of date.
|
||||
if (jszipProto.crc32(this.fileComment) !== extraReader.readInt(4)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return jszipProto.utf8decode(extraReader.readString(ucommentField.length - 5));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
module.exports = ZipEntry;
|
85
node_modules/jszip/package.json
generated
vendored
Normal file
85
node_modules/jszip/package.json
generated
vendored
Normal file
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
"_from": "jszip@2.5.0",
|
||||
"_id": "jszip@2.5.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-dET9hVHd8+XacZj+oMkbyDCMwnQ=",
|
||||
"_location": "/jszip",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "jszip@2.5.0",
|
||||
"name": "jszip",
|
||||
"escapedName": "jszip",
|
||||
"rawSpec": "2.5.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.5.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/node-zip"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/jszip/-/jszip-2.5.0.tgz",
|
||||
"_shasum": "7444fd8551ddf3e5da7198fea0c91bc8308cc274",
|
||||
"_spec": "jszip@2.5.0",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\node_modules\\node-zip",
|
||||
"author": {
|
||||
"name": "Stuart Knightley",
|
||||
"email": "stuart@stuartk.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/Stuk/jszip/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Franz Buchinger"
|
||||
},
|
||||
{
|
||||
"name": "António Afonso"
|
||||
},
|
||||
{
|
||||
"name": "David Duponchel"
|
||||
},
|
||||
{
|
||||
"name": "yiminghe"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"pako": "~0.2.5"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Create, read and edit .zip files with Javascript http://stuartk.com/jszip",
|
||||
"devDependencies": {
|
||||
"browserify": "~4.1.4",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-browserify": "~2.1.0",
|
||||
"grunt-cli": "~0.1.9",
|
||||
"grunt-contrib-connect": "~0.7.1",
|
||||
"grunt-contrib-jshint": "~0.10.0",
|
||||
"grunt-contrib-uglify": "~0.4.0",
|
||||
"grunt-saucelabs": "~7.0.0",
|
||||
"jshint": "~2.5.1",
|
||||
"jszip-utils": "~0.0.2",
|
||||
"qunit": "~0.6.3"
|
||||
},
|
||||
"homepage": "https://github.com/Stuk/jszip#readme",
|
||||
"keywords": [
|
||||
"zip",
|
||||
"deflate",
|
||||
"inflate"
|
||||
],
|
||||
"license": "MIT or GPLv3",
|
||||
"main": "./lib/index",
|
||||
"name": "jszip",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/Stuk/jszip.git"
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "grunt jshint",
|
||||
"test": "npm run test-node && npm run test-browser",
|
||||
"test-browser": "grunt build && grunt test",
|
||||
"test-node": "cd test && qunit -c node.js -t test.js"
|
||||
},
|
||||
"version": "2.5.0"
|
||||
}
|
247
node_modules/jszip/vendor/FileSaver.js
generated
vendored
Normal file
247
node_modules/jszip/vendor/FileSaver.js
generated
vendored
Normal file
|
@ -0,0 +1,247 @@
|
|||
/*! FileSaver.js
|
||||
* A saveAs() FileSaver implementation.
|
||||
* 2014-01-24
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* License: X11/MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*global self */
|
||||
/*jslint bitwise: true, indent: 4, laxbreak: true, laxcomma: true, smarttabs: true, plusplus: true */
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/FileSaver.js */
|
||||
|
||||
var saveAs = saveAs
|
||||
// IE 10+ (native saveAs)
|
||||
|| (typeof navigator !== "undefined" &&
|
||||
navigator.msSaveOrOpenBlob && navigator.msSaveOrOpenBlob.bind(navigator))
|
||||
// Everyone else
|
||||
|| (function(view) {
|
||||
"use strict";
|
||||
// IE <10 is explicitly unsupported
|
||||
if (typeof navigator !== "undefined" &&
|
||||
/MSIE [1-9]\./.test(navigator.userAgent)) {
|
||||
return;
|
||||
}
|
||||
var
|
||||
doc = view.document
|
||||
// only get URL when necessary in case BlobBuilder.js hasn't overridden it yet
|
||||
, get_URL = function() {
|
||||
return view.URL || view.webkitURL || view;
|
||||
}
|
||||
, URL = view.URL || view.webkitURL || view
|
||||
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
||||
, can_use_save_link = !view.externalHost && "download" in save_link
|
||||
, click = function(node) {
|
||||
var event = doc.createEvent("MouseEvents");
|
||||
event.initMouseEvent(
|
||||
"click", true, false, view, 0, 0, 0, 0, 0
|
||||
, false, false, false, false, 0, null
|
||||
);
|
||||
node.dispatchEvent(event);
|
||||
}
|
||||
, webkit_req_fs = view.webkitRequestFileSystem
|
||||
, req_fs = view.requestFileSystem || webkit_req_fs || view.mozRequestFileSystem
|
||||
, throw_outside = function(ex) {
|
||||
(view.setImmediate || view.setTimeout)(function() {
|
||||
throw ex;
|
||||
}, 0);
|
||||
}
|
||||
, force_saveable_type = "application/octet-stream"
|
||||
, fs_min_size = 0
|
||||
, deletion_queue = []
|
||||
, process_deletion_queue = function() {
|
||||
var i = deletion_queue.length;
|
||||
while (i--) {
|
||||
var file = deletion_queue[i];
|
||||
if (typeof file === "string") { // file is an object URL
|
||||
URL.revokeObjectURL(file);
|
||||
} else { // file is a File
|
||||
file.remove();
|
||||
}
|
||||
}
|
||||
deletion_queue.length = 0; // clear queue
|
||||
}
|
||||
, dispatch = function(filesaver, event_types, event) {
|
||||
event_types = [].concat(event_types);
|
||||
var i = event_types.length;
|
||||
while (i--) {
|
||||
var listener = filesaver["on" + event_types[i]];
|
||||
if (typeof listener === "function") {
|
||||
try {
|
||||
listener.call(filesaver, event || filesaver);
|
||||
} catch (ex) {
|
||||
throw_outside(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
, FileSaver = function(blob, name) {
|
||||
// First try a.download, then web filesystem, then object URLs
|
||||
var
|
||||
filesaver = this
|
||||
, type = blob.type
|
||||
, blob_changed = false
|
||||
, object_url
|
||||
, target_view
|
||||
, get_object_url = function() {
|
||||
var object_url = get_URL().createObjectURL(blob);
|
||||
deletion_queue.push(object_url);
|
||||
return object_url;
|
||||
}
|
||||
, dispatch_all = function() {
|
||||
dispatch(filesaver, "writestart progress write writeend".split(" "));
|
||||
}
|
||||
// on any filesys errors revert to saving with object URLs
|
||||
, fs_error = function() {
|
||||
// don't create more object URLs than needed
|
||||
if (blob_changed || !object_url) {
|
||||
object_url = get_object_url(blob);
|
||||
}
|
||||
if (target_view) {
|
||||
target_view.location.href = object_url;
|
||||
} else {
|
||||
window.open(object_url, "_blank");
|
||||
}
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
}
|
||||
, abortable = function(func) {
|
||||
return function() {
|
||||
if (filesaver.readyState !== filesaver.DONE) {
|
||||
return func.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
}
|
||||
, create_if_not_found = {create: true, exclusive: false}
|
||||
, slice
|
||||
;
|
||||
filesaver.readyState = filesaver.INIT;
|
||||
if (!name) {
|
||||
name = "download";
|
||||
}
|
||||
if (can_use_save_link) {
|
||||
object_url = get_object_url(blob);
|
||||
// FF for Android has a nasty garbage collection mechanism
|
||||
// that turns all objects that are not pure javascript into 'deadObject'
|
||||
// this means `doc` and `save_link` are unusable and need to be recreated
|
||||
// `view` is usable though:
|
||||
doc = view.document;
|
||||
save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a");
|
||||
save_link.href = object_url;
|
||||
save_link.download = name;
|
||||
var event = doc.createEvent("MouseEvents");
|
||||
event.initMouseEvent(
|
||||
"click", true, false, view, 0, 0, 0, 0, 0
|
||||
, false, false, false, false, 0, null
|
||||
);
|
||||
save_link.dispatchEvent(event);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
return;
|
||||
}
|
||||
// Object and web filesystem URLs have a problem saving in Google Chrome when
|
||||
// viewed in a tab, so I force save with application/octet-stream
|
||||
// http://code.google.com/p/chromium/issues/detail?id=91158
|
||||
if (view.chrome && type && type !== force_saveable_type) {
|
||||
slice = blob.slice || blob.webkitSlice;
|
||||
blob = slice.call(blob, 0, blob.size, force_saveable_type);
|
||||
blob_changed = true;
|
||||
}
|
||||
// Since I can't be sure that the guessed media type will trigger a download
|
||||
// in WebKit, I append .download to the filename.
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=65440
|
||||
if (webkit_req_fs && name !== "download") {
|
||||
name += ".download";
|
||||
}
|
||||
if (type === force_saveable_type || webkit_req_fs) {
|
||||
target_view = view;
|
||||
}
|
||||
if (!req_fs) {
|
||||
fs_error();
|
||||
return;
|
||||
}
|
||||
fs_min_size += blob.size;
|
||||
req_fs(view.TEMPORARY, fs_min_size, abortable(function(fs) {
|
||||
fs.root.getDirectory("saved", create_if_not_found, abortable(function(dir) {
|
||||
var save = function() {
|
||||
dir.getFile(name, create_if_not_found, abortable(function(file) {
|
||||
file.createWriter(abortable(function(writer) {
|
||||
writer.onwriteend = function(event) {
|
||||
target_view.location.href = file.toURL();
|
||||
deletion_queue.push(file);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch(filesaver, "writeend", event);
|
||||
};
|
||||
writer.onerror = function() {
|
||||
var error = writer.error;
|
||||
if (error.code !== error.ABORT_ERR) {
|
||||
fs_error();
|
||||
}
|
||||
};
|
||||
"writestart progress write abort".split(" ").forEach(function(event) {
|
||||
writer["on" + event] = filesaver["on" + event];
|
||||
});
|
||||
writer.write(blob);
|
||||
filesaver.abort = function() {
|
||||
writer.abort();
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
};
|
||||
filesaver.readyState = filesaver.WRITING;
|
||||
}), fs_error);
|
||||
}), fs_error);
|
||||
};
|
||||
dir.getFile(name, {create: false}, abortable(function(file) {
|
||||
// delete file if it already exists
|
||||
file.remove();
|
||||
save();
|
||||
}), abortable(function(ex) {
|
||||
if (ex.code === ex.NOT_FOUND_ERR) {
|
||||
save();
|
||||
} else {
|
||||
fs_error();
|
||||
}
|
||||
}));
|
||||
}), fs_error);
|
||||
}), fs_error);
|
||||
}
|
||||
, FS_proto = FileSaver.prototype
|
||||
, saveAs = function(blob, name) {
|
||||
return new FileSaver(blob, name);
|
||||
}
|
||||
;
|
||||
FS_proto.abort = function() {
|
||||
var filesaver = this;
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch(filesaver, "abort");
|
||||
};
|
||||
FS_proto.readyState = FS_proto.INIT = 0;
|
||||
FS_proto.WRITING = 1;
|
||||
FS_proto.DONE = 2;
|
||||
|
||||
FS_proto.error =
|
||||
FS_proto.onwritestart =
|
||||
FS_proto.onprogress =
|
||||
FS_proto.onwrite =
|
||||
FS_proto.onabort =
|
||||
FS_proto.onerror =
|
||||
FS_proto.onwriteend =
|
||||
null;
|
||||
|
||||
view.addEventListener("unload", process_deletion_queue, false);
|
||||
saveAs.unload = function() {
|
||||
process_deletion_queue();
|
||||
view.removeEventListener("unload", process_deletion_queue, false);
|
||||
};
|
||||
return saveAs;
|
||||
}(
|
||||
typeof self !== "undefined" && self
|
||||
|| typeof window !== "undefined" && window
|
||||
|| this.content
|
||||
));
|
||||
// `self` is undefined in Firefox for Android content script context
|
||||
// while `this` is nsIContentFrameMessageManager
|
||||
// with an attribute `content` that corresponds to the window
|
||||
|
||||
if (typeof module !== "undefined") module.exports = saveAs;
|
90
node_modules/pako/CHANGELOG.md
generated
vendored
Normal file
90
node_modules/pako/CHANGELOG.md
generated
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
1.0.2 / 2016-07-21
|
||||
------------------
|
||||
|
||||
- Fixed nasty bug in deflate (wrong `d_buf` offset), which could cause
|
||||
broken data in some rare cases.
|
||||
- Also released as 0.2.9 to give chance to old dependents, not updated to 1.x
|
||||
version.
|
||||
|
||||
|
||||
1.0.1 / 2016-04-01
|
||||
------------------
|
||||
|
||||
- Added dictionary support. Thanks to @dignifiedquire.
|
||||
|
||||
|
||||
1.0.0 / 2016-02-17
|
||||
------------------
|
||||
|
||||
- Maintenance release (semver, coding style).
|
||||
|
||||
|
||||
0.2.8 / 2015-09-14
|
||||
------------------
|
||||
|
||||
- Fixed regression after 0.2.4 for edge conditions in inflate wrapper (#65).
|
||||
Added more tests to cover possible cases.
|
||||
|
||||
|
||||
0.2.7 / 2015-06-09
|
||||
------------------
|
||||
|
||||
- Added Z_SYNC_FLUSH support. Thanks to @TinoLange.
|
||||
|
||||
|
||||
0.2.6 / 2015-03-24
|
||||
------------------
|
||||
|
||||
- Allow ArrayBuffer input.
|
||||
|
||||
|
||||
0.2.5 / 2014-07-19
|
||||
------------------
|
||||
|
||||
- Workaround for Chrome 38.0.2096.0 script parser bug, #30.
|
||||
|
||||
|
||||
0.2.4 / 2014-07-07
|
||||
------------------
|
||||
|
||||
- Fixed bug in inflate wrapper, #29
|
||||
|
||||
|
||||
0.2.3 / 2014-06-09
|
||||
------------------
|
||||
|
||||
- Maintenance release, dependencies update.
|
||||
|
||||
|
||||
0.2.2 / 2014-06-04
|
||||
------------------
|
||||
|
||||
- Fixed iOS 5.1 Safary issue with `apply(typed_array)`, #26.
|
||||
|
||||
|
||||
0.2.1 / 2014-05-01
|
||||
------------------
|
||||
|
||||
- Fixed collision on switch dynamic/fixed tables.
|
||||
|
||||
|
||||
0.2.0 / 2014-04-18
|
||||
------------------
|
||||
|
||||
- Added custom gzip headers support.
|
||||
- Added strings support.
|
||||
- Improved memory allocations for small chunks.
|
||||
- ZStream properties rename/cleanup.
|
||||
- More coverage tests.
|
||||
|
||||
|
||||
0.1.1 / 2014-03-20
|
||||
------------------
|
||||
|
||||
- Bugfixes for inflate/deflate.
|
||||
|
||||
|
||||
0.1.0 / 2014-03-15
|
||||
------------------
|
||||
|
||||
- First release.
|
21
node_modules/pako/LICENSE
generated
vendored
Normal file
21
node_modules/pako/LICENSE
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (C) 2014-2016 by Vitaly Puzrin
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
176
node_modules/pako/README.md
generated
vendored
Normal file
176
node_modules/pako/README.md
generated
vendored
Normal file
|
@ -0,0 +1,176 @@
|
|||
pako - zlib port to javascript, very fast!
|
||||
==========================================
|
||||
|
||||
[![Build Status](https://travis-ci.org/nodeca/pako.svg?branch=master)](https://travis-ci.org/nodeca/pako)
|
||||
[![NPM version](https://img.shields.io/npm/v/pako.svg)](https://www.npmjs.org/package/pako)
|
||||
|
||||
__Why pako is cool:__
|
||||
|
||||
- Almost as fast in modern JS engines as C implementation (see benchmarks).
|
||||
- Works in browsers, you can browserify any separate component.
|
||||
- Chunking support for big blobs.
|
||||
- Results are binary equal to well known [zlib](http://www.zlib.net/) (now v1.2.8 ported).
|
||||
|
||||
This project was done to understand how fast JS can be and is it necessary to
|
||||
develop native C modules for CPU-intensive tasks. Enjoy the result!
|
||||
|
||||
|
||||
__Famous projects, using pako:__
|
||||
|
||||
- [browserify](http://browserify.org/) (via [browserify-zlib](https://github.com/devongovett/browserify-zlib))
|
||||
- [JSZip](http://stuk.github.io/jszip/)
|
||||
- [mincer](https://github.com/nodeca/mincer)
|
||||
- [JS-Git](https://github.com/creationix/js-git) and
|
||||
[Tedit](https://chrome.google.com/webstore/detail/tedit-development-environ/ooekdijbnbbjdfjocaiflnjgoohnblgf)
|
||||
by [@creatronix](https://github.com/creationix)
|
||||
|
||||
|
||||
__Benchmarks:__
|
||||
|
||||
```
|
||||
node v0.10.26, 1mb sample:
|
||||
|
||||
deflate-dankogai x 4.73 ops/sec ±0.82% (15 runs sampled)
|
||||
deflate-gildas x 4.58 ops/sec ±2.33% (15 runs sampled)
|
||||
deflate-imaya x 3.22 ops/sec ±3.95% (12 runs sampled)
|
||||
! deflate-pako x 6.99 ops/sec ±0.51% (21 runs sampled)
|
||||
deflate-pako-string x 5.89 ops/sec ±0.77% (18 runs sampled)
|
||||
deflate-pako-untyped x 4.39 ops/sec ±1.58% (14 runs sampled)
|
||||
* deflate-zlib x 14.71 ops/sec ±4.23% (59 runs sampled)
|
||||
inflate-dankogai x 32.16 ops/sec ±0.13% (56 runs sampled)
|
||||
inflate-imaya x 30.35 ops/sec ±0.92% (53 runs sampled)
|
||||
! inflate-pako x 69.89 ops/sec ±1.46% (71 runs sampled)
|
||||
inflate-pako-string x 19.22 ops/sec ±1.86% (49 runs sampled)
|
||||
inflate-pako-untyped x 17.19 ops/sec ±0.85% (32 runs sampled)
|
||||
* inflate-zlib x 70.03 ops/sec ±1.64% (81 runs sampled)
|
||||
|
||||
node v0.11.12, 1mb sample:
|
||||
|
||||
deflate-dankogai x 5.60 ops/sec ±0.49% (17 runs sampled)
|
||||
deflate-gildas x 5.06 ops/sec ±6.00% (16 runs sampled)
|
||||
deflate-imaya x 3.52 ops/sec ±3.71% (13 runs sampled)
|
||||
! deflate-pako x 11.52 ops/sec ±0.22% (32 runs sampled)
|
||||
deflate-pako-string x 9.53 ops/sec ±1.12% (27 runs sampled)
|
||||
deflate-pako-untyped x 5.44 ops/sec ±0.72% (17 runs sampled)
|
||||
* deflate-zlib x 14.05 ops/sec ±3.34% (63 runs sampled)
|
||||
inflate-dankogai x 42.19 ops/sec ±0.09% (56 runs sampled)
|
||||
inflate-imaya x 79.68 ops/sec ±1.07% (68 runs sampled)
|
||||
! inflate-pako x 97.52 ops/sec ±0.83% (80 runs sampled)
|
||||
inflate-pako-string x 45.19 ops/sec ±1.69% (57 runs sampled)
|
||||
inflate-pako-untyped x 24.35 ops/sec ±2.59% (40 runs sampled)
|
||||
* inflate-zlib x 60.32 ops/sec ±1.36% (69 runs sampled)
|
||||
```
|
||||
|
||||
zlib's test is partialy afferted by marshling (that make sense for inflate only).
|
||||
You can change deflate level to 0 in benchmark source, to investigate details.
|
||||
For deflate level 6 results can be considered as correct.
|
||||
|
||||
__Install:__
|
||||
|
||||
node.js:
|
||||
|
||||
```
|
||||
npm install pako
|
||||
```
|
||||
|
||||
browser:
|
||||
|
||||
```
|
||||
bower install pako
|
||||
```
|
||||
|
||||
|
||||
Example & API
|
||||
-------------
|
||||
|
||||
Full docs - http://nodeca.github.io/pako/
|
||||
|
||||
```javascript
|
||||
var pako = require('pako');
|
||||
|
||||
// Deflate
|
||||
//
|
||||
var input = new Uint8Array();
|
||||
//... fill input data here
|
||||
var output = pako.deflate(input);
|
||||
|
||||
// Inflate (simple wrapper can throw exception on broken stream)
|
||||
//
|
||||
var compressed = new Uint8Array();
|
||||
//... fill data to uncompress here
|
||||
try {
|
||||
var result = pako.inflate(compressed);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
|
||||
//
|
||||
// Alternate interface for chunking & without exceptions
|
||||
//
|
||||
|
||||
var inflator = new pako.Inflate();
|
||||
|
||||
inflator.push(chunk1, false);
|
||||
inflator.push(chunk2, false);
|
||||
...
|
||||
inflator.push(chunkN, true); // true -> last chunk
|
||||
|
||||
if (inflator.err) {
|
||||
console.log(inflator.msg);
|
||||
}
|
||||
|
||||
var output = inflator.result;
|
||||
|
||||
```
|
||||
|
||||
Sometime you can wish to work with strings. For example, to send
|
||||
big objects as json to server. Pako detects input data type. You can
|
||||
force output to be string with option `{ to: 'string' }`.
|
||||
|
||||
```javascript
|
||||
var pako = require('pako');
|
||||
|
||||
var test = { my: 'super', puper: [456, 567], awesome: 'pako' };
|
||||
|
||||
var binaryString = pako.deflate(JSON.stringify(test), { to: 'string' });
|
||||
|
||||
//
|
||||
// Here you can do base64 encode, make xhr requests and so on.
|
||||
//
|
||||
|
||||
var restored = JSON.parse(pako.inflate(binaryString, { to: 'string' }));
|
||||
```
|
||||
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
Pako does not contain some specific zlib functions:
|
||||
|
||||
- __deflate__ - methods `deflateCopy`, `deflateBound`, `deflateParams`,
|
||||
`deflatePending`, `deflatePrime`, `deflateTune`.
|
||||
- __inflate__ - methods `inflateCopy`, `inflateMark`,
|
||||
`inflatePrime`, `inflateGetDictionary`, `inflateSync`, `inflateSyncPoint`, `inflateUndermine`.
|
||||
- High level inflate/deflate wrappers (classes) may not support some flush
|
||||
modes. Those should work: Z_NO_FLUSH, Z_FINISH, Z_SYNC_FLUSH.
|
||||
|
||||
|
||||
Authors
|
||||
-------
|
||||
|
||||
- Andrey Tupitsin [@anrd83](https://github.com/andr83)
|
||||
- Vitaly Puzrin [@puzrin](https://github.com/puzrin)
|
||||
|
||||
Personal thanks to:
|
||||
|
||||
- Vyacheslav Egorov ([@mraleph](https://github.com/mraleph)) for his awesome
|
||||
tutorials about optimising JS code for v8, [IRHydra](http://mrale.ph/irhydra/)
|
||||
tool and his advices.
|
||||
- David Duponchel ([@dduponchel](https://github.com/dduponchel)) for help with
|
||||
testing.
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
MIT
|
6606
node_modules/pako/dist/pako.js
generated
vendored
Normal file
6606
node_modules/pako/dist/pako.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
3
node_modules/pako/dist/pako.min.js
generated
vendored
Normal file
3
node_modules/pako/dist/pako.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3879
node_modules/pako/dist/pako_deflate.js
generated
vendored
Normal file
3879
node_modules/pako/dist/pako_deflate.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/pako/dist/pako_deflate.min.js
generated
vendored
Normal file
2
node_modules/pako/dist/pako_deflate.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
3127
node_modules/pako/dist/pako_inflate.js
generated
vendored
Normal file
3127
node_modules/pako/dist/pako_inflate.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
2
node_modules/pako/dist/pako_inflate.min.js
generated
vendored
Normal file
2
node_modules/pako/dist/pako_inflate.min.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
14
node_modules/pako/index.js
generated
vendored
Normal file
14
node_modules/pako/index.js
generated
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
// Top level file is just a mixin of submodules & constants
|
||||
'use strict';
|
||||
|
||||
var assign = require('./lib/utils/common').assign;
|
||||
|
||||
var deflate = require('./lib/deflate');
|
||||
var inflate = require('./lib/inflate');
|
||||
var constants = require('./lib/zlib/constants');
|
||||
|
||||
var pako = {};
|
||||
|
||||
assign(pako, deflate, inflate, constants);
|
||||
|
||||
module.exports = pako;
|
400
node_modules/pako/lib/deflate.js
generated
vendored
Normal file
400
node_modules/pako/lib/deflate.js
generated
vendored
Normal file
|
@ -0,0 +1,400 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var zlib_deflate = require('./zlib/deflate');
|
||||
var utils = require('./utils/common');
|
||||
var strings = require('./utils/strings');
|
||||
var msg = require('./zlib/messages');
|
||||
var ZStream = require('./zlib/zstream');
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/* Public constants ==========================================================*/
|
||||
/* ===========================================================================*/
|
||||
|
||||
var Z_NO_FLUSH = 0;
|
||||
var Z_FINISH = 4;
|
||||
|
||||
var Z_OK = 0;
|
||||
var Z_STREAM_END = 1;
|
||||
var Z_SYNC_FLUSH = 2;
|
||||
|
||||
var Z_DEFAULT_COMPRESSION = -1;
|
||||
|
||||
var Z_DEFAULT_STRATEGY = 0;
|
||||
|
||||
var Z_DEFLATED = 8;
|
||||
|
||||
/* ===========================================================================*/
|
||||
|
||||
|
||||
/**
|
||||
* class Deflate
|
||||
*
|
||||
* Generic JS-style wrapper for zlib calls. If you don't need
|
||||
* streaming behaviour - use more simple functions: [[deflate]],
|
||||
* [[deflateRaw]] and [[gzip]].
|
||||
**/
|
||||
|
||||
/* internal
|
||||
* Deflate.chunks -> Array
|
||||
*
|
||||
* Chunks of output data, if [[Deflate#onData]] not overriden.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Deflate.result -> Uint8Array|Array
|
||||
*
|
||||
* Compressed result, generated by default [[Deflate#onData]]
|
||||
* and [[Deflate#onEnd]] handlers. Filled after you push last chunk
|
||||
* (call [[Deflate#push]] with `Z_FINISH` / `true` param) or if you
|
||||
* push a chunk with explicit flush (call [[Deflate#push]] with
|
||||
* `Z_SYNC_FLUSH` param).
|
||||
**/
|
||||
|
||||
/**
|
||||
* Deflate.err -> Number
|
||||
*
|
||||
* Error code after deflate finished. 0 (Z_OK) on success.
|
||||
* You will not need it in real life, because deflate errors
|
||||
* are possible only on wrong options or bad `onData` / `onEnd`
|
||||
* custom handlers.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Deflate.msg -> String
|
||||
*
|
||||
* Error message, if [[Deflate.err]] != 0
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* new Deflate(options)
|
||||
* - options (Object): zlib deflate options.
|
||||
*
|
||||
* Creates new deflator instance with specified params. Throws exception
|
||||
* on bad params. Supported options:
|
||||
*
|
||||
* - `level`
|
||||
* - `windowBits`
|
||||
* - `memLevel`
|
||||
* - `strategy`
|
||||
* - `dictionary`
|
||||
*
|
||||
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
||||
* for more information on these.
|
||||
*
|
||||
* Additional options, for internal needs:
|
||||
*
|
||||
* - `chunkSize` - size of generated data chunks (16K by default)
|
||||
* - `raw` (Boolean) - do raw deflate
|
||||
* - `gzip` (Boolean) - create gzip wrapper
|
||||
* - `to` (String) - if equal to 'string', then result will be "binary string"
|
||||
* (each char code [0..255])
|
||||
* - `header` (Object) - custom header for gzip
|
||||
* - `text` (Boolean) - true if compressed data believed to be text
|
||||
* - `time` (Number) - modification time, unix timestamp
|
||||
* - `os` (Number) - operation system code
|
||||
* - `extra` (Array) - array of bytes with extra data (max 65536)
|
||||
* - `name` (String) - file name (binary string)
|
||||
* - `comment` (String) - comment (binary string)
|
||||
* - `hcrc` (Boolean) - true if header crc should be added
|
||||
*
|
||||
* ##### Example:
|
||||
*
|
||||
* ```javascript
|
||||
* var pako = require('pako')
|
||||
* , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
|
||||
* , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
|
||||
*
|
||||
* var deflate = new pako.Deflate({ level: 3});
|
||||
*
|
||||
* deflate.push(chunk1, false);
|
||||
* deflate.push(chunk2, true); // true -> last chunk
|
||||
*
|
||||
* if (deflate.err) { throw new Error(deflate.err); }
|
||||
*
|
||||
* console.log(deflate.result);
|
||||
* ```
|
||||
**/
|
||||
function Deflate(options) {
|
||||
if (!(this instanceof Deflate)) return new Deflate(options);
|
||||
|
||||
this.options = utils.assign({
|
||||
level: Z_DEFAULT_COMPRESSION,
|
||||
method: Z_DEFLATED,
|
||||
chunkSize: 16384,
|
||||
windowBits: 15,
|
||||
memLevel: 8,
|
||||
strategy: Z_DEFAULT_STRATEGY,
|
||||
to: ''
|
||||
}, options || {});
|
||||
|
||||
var opt = this.options;
|
||||
|
||||
if (opt.raw && (opt.windowBits > 0)) {
|
||||
opt.windowBits = -opt.windowBits;
|
||||
}
|
||||
|
||||
else if (opt.gzip && (opt.windowBits > 0) && (opt.windowBits < 16)) {
|
||||
opt.windowBits += 16;
|
||||
}
|
||||
|
||||
this.err = 0; // error code, if happens (0 = Z_OK)
|
||||
this.msg = ''; // error message
|
||||
this.ended = false; // used to avoid multiple onEnd() calls
|
||||
this.chunks = []; // chunks of compressed data
|
||||
|
||||
this.strm = new ZStream();
|
||||
this.strm.avail_out = 0;
|
||||
|
||||
var status = zlib_deflate.deflateInit2(
|
||||
this.strm,
|
||||
opt.level,
|
||||
opt.method,
|
||||
opt.windowBits,
|
||||
opt.memLevel,
|
||||
opt.strategy
|
||||
);
|
||||
|
||||
if (status !== Z_OK) {
|
||||
throw new Error(msg[status]);
|
||||
}
|
||||
|
||||
if (opt.header) {
|
||||
zlib_deflate.deflateSetHeader(this.strm, opt.header);
|
||||
}
|
||||
|
||||
if (opt.dictionary) {
|
||||
var dict;
|
||||
// Convert data if needed
|
||||
if (typeof opt.dictionary === 'string') {
|
||||
// If we need to compress text, change encoding to utf8.
|
||||
dict = strings.string2buf(opt.dictionary);
|
||||
} else if (toString.call(opt.dictionary) === '[object ArrayBuffer]') {
|
||||
dict = new Uint8Array(opt.dictionary);
|
||||
} else {
|
||||
dict = opt.dictionary;
|
||||
}
|
||||
|
||||
status = zlib_deflate.deflateSetDictionary(this.strm, dict);
|
||||
|
||||
if (status !== Z_OK) {
|
||||
throw new Error(msg[status]);
|
||||
}
|
||||
|
||||
this._dict_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deflate#push(data[, mode]) -> Boolean
|
||||
* - data (Uint8Array|Array|ArrayBuffer|String): input data. Strings will be
|
||||
* converted to utf8 byte sequence.
|
||||
* - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
|
||||
* See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
|
||||
*
|
||||
* Sends input data to deflate pipe, generating [[Deflate#onData]] calls with
|
||||
* new compressed chunks. Returns `true` on success. The last data block must have
|
||||
* mode Z_FINISH (or `true`). That will flush internal pending buffers and call
|
||||
* [[Deflate#onEnd]]. For interim explicit flushes (without ending the stream) you
|
||||
* can use mode Z_SYNC_FLUSH, keeping the compression context.
|
||||
*
|
||||
* On fail call [[Deflate#onEnd]] with error code and return false.
|
||||
*
|
||||
* We strongly recommend to use `Uint8Array` on input for best speed (output
|
||||
* array format is detected automatically). Also, don't skip last param and always
|
||||
* use the same type in your code (boolean or number). That will improve JS speed.
|
||||
*
|
||||
* For regular `Array`-s make sure all elements are [0..255].
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* ```javascript
|
||||
* push(chunk, false); // push one of data chunks
|
||||
* ...
|
||||
* push(chunk, true); // push last chunk
|
||||
* ```
|
||||
**/
|
||||
Deflate.prototype.push = function (data, mode) {
|
||||
var strm = this.strm;
|
||||
var chunkSize = this.options.chunkSize;
|
||||
var status, _mode;
|
||||
|
||||
if (this.ended) { return false; }
|
||||
|
||||
_mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH : Z_NO_FLUSH);
|
||||
|
||||
// Convert data if needed
|
||||
if (typeof data === 'string') {
|
||||
// If we need to compress text, change encoding to utf8.
|
||||
strm.input = strings.string2buf(data);
|
||||
} else if (toString.call(data) === '[object ArrayBuffer]') {
|
||||
strm.input = new Uint8Array(data);
|
||||
} else {
|
||||
strm.input = data;
|
||||
}
|
||||
|
||||
strm.next_in = 0;
|
||||
strm.avail_in = strm.input.length;
|
||||
|
||||
do {
|
||||
if (strm.avail_out === 0) {
|
||||
strm.output = new utils.Buf8(chunkSize);
|
||||
strm.next_out = 0;
|
||||
strm.avail_out = chunkSize;
|
||||
}
|
||||
status = zlib_deflate.deflate(strm, _mode); /* no bad return value */
|
||||
|
||||
if (status !== Z_STREAM_END && status !== Z_OK) {
|
||||
this.onEnd(status);
|
||||
this.ended = true;
|
||||
return false;
|
||||
}
|
||||
if (strm.avail_out === 0 || (strm.avail_in === 0 && (_mode === Z_FINISH || _mode === Z_SYNC_FLUSH))) {
|
||||
if (this.options.to === 'string') {
|
||||
this.onData(strings.buf2binstring(utils.shrinkBuf(strm.output, strm.next_out)));
|
||||
} else {
|
||||
this.onData(utils.shrinkBuf(strm.output, strm.next_out));
|
||||
}
|
||||
}
|
||||
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END);
|
||||
|
||||
// Finalize on the last chunk.
|
||||
if (_mode === Z_FINISH) {
|
||||
status = zlib_deflate.deflateEnd(this.strm);
|
||||
this.onEnd(status);
|
||||
this.ended = true;
|
||||
return status === Z_OK;
|
||||
}
|
||||
|
||||
// callback interim results if Z_SYNC_FLUSH.
|
||||
if (_mode === Z_SYNC_FLUSH) {
|
||||
this.onEnd(Z_OK);
|
||||
strm.avail_out = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deflate#onData(chunk) -> Void
|
||||
* - chunk (Uint8Array|Array|String): ouput data. Type of array depends
|
||||
* on js engine support. When string output requested, each chunk
|
||||
* will be string.
|
||||
*
|
||||
* By default, stores data blocks in `chunks[]` property and glue
|
||||
* those in `onEnd`. Override this handler, if you need another behaviour.
|
||||
**/
|
||||
Deflate.prototype.onData = function (chunk) {
|
||||
this.chunks.push(chunk);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Deflate#onEnd(status) -> Void
|
||||
* - status (Number): deflate status. 0 (Z_OK) on success,
|
||||
* other if not.
|
||||
*
|
||||
* Called once after you tell deflate that the input stream is
|
||||
* complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
|
||||
* or if an error happened. By default - join collected chunks,
|
||||
* free memory and fill `results` / `err` properties.
|
||||
**/
|
||||
Deflate.prototype.onEnd = function (status) {
|
||||
// On success - join
|
||||
if (status === Z_OK) {
|
||||
if (this.options.to === 'string') {
|
||||
this.result = this.chunks.join('');
|
||||
} else {
|
||||
this.result = utils.flattenChunks(this.chunks);
|
||||
}
|
||||
}
|
||||
this.chunks = [];
|
||||
this.err = status;
|
||||
this.msg = this.strm.msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* deflate(data[, options]) -> Uint8Array|Array|String
|
||||
* - data (Uint8Array|Array|String): input data to compress.
|
||||
* - options (Object): zlib deflate options.
|
||||
*
|
||||
* Compress `data` with deflate algorithm and `options`.
|
||||
*
|
||||
* Supported options are:
|
||||
*
|
||||
* - level
|
||||
* - windowBits
|
||||
* - memLevel
|
||||
* - strategy
|
||||
* - dictionary
|
||||
*
|
||||
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
||||
* for more information on these.
|
||||
*
|
||||
* Sugar (options):
|
||||
*
|
||||
* - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
|
||||
* negative windowBits implicitly.
|
||||
* - `to` (String) - if equal to 'string', then result will be "binary string"
|
||||
* (each char code [0..255])
|
||||
*
|
||||
* ##### Example:
|
||||
*
|
||||
* ```javascript
|
||||
* var pako = require('pako')
|
||||
* , data = Uint8Array([1,2,3,4,5,6,7,8,9]);
|
||||
*
|
||||
* console.log(pako.deflate(data));
|
||||
* ```
|
||||
**/
|
||||
function deflate(input, options) {
|
||||
var deflator = new Deflate(options);
|
||||
|
||||
deflator.push(input, true);
|
||||
|
||||
// That will never happens, if you don't cheat with options :)
|
||||
if (deflator.err) { throw deflator.msg; }
|
||||
|
||||
return deflator.result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* deflateRaw(data[, options]) -> Uint8Array|Array|String
|
||||
* - data (Uint8Array|Array|String): input data to compress.
|
||||
* - options (Object): zlib deflate options.
|
||||
*
|
||||
* The same as [[deflate]], but creates raw data, without wrapper
|
||||
* (header and adler32 crc).
|
||||
**/
|
||||
function deflateRaw(input, options) {
|
||||
options = options || {};
|
||||
options.raw = true;
|
||||
return deflate(input, options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gzip(data[, options]) -> Uint8Array|Array|String
|
||||
* - data (Uint8Array|Array|String): input data to compress.
|
||||
* - options (Object): zlib deflate options.
|
||||
*
|
||||
* The same as [[deflate]], but create gzip wrapper instead of
|
||||
* deflate one.
|
||||
**/
|
||||
function gzip(input, options) {
|
||||
options = options || {};
|
||||
options.gzip = true;
|
||||
return deflate(input, options);
|
||||
}
|
||||
|
||||
|
||||
exports.Deflate = Deflate;
|
||||
exports.deflate = deflate;
|
||||
exports.deflateRaw = deflateRaw;
|
||||
exports.gzip = gzip;
|
418
node_modules/pako/lib/inflate.js
generated
vendored
Normal file
418
node_modules/pako/lib/inflate.js
generated
vendored
Normal file
|
@ -0,0 +1,418 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var zlib_inflate = require('./zlib/inflate');
|
||||
var utils = require('./utils/common');
|
||||
var strings = require('./utils/strings');
|
||||
var c = require('./zlib/constants');
|
||||
var msg = require('./zlib/messages');
|
||||
var ZStream = require('./zlib/zstream');
|
||||
var GZheader = require('./zlib/gzheader');
|
||||
|
||||
var toString = Object.prototype.toString;
|
||||
|
||||
/**
|
||||
* class Inflate
|
||||
*
|
||||
* Generic JS-style wrapper for zlib calls. If you don't need
|
||||
* streaming behaviour - use more simple functions: [[inflate]]
|
||||
* and [[inflateRaw]].
|
||||
**/
|
||||
|
||||
/* internal
|
||||
* inflate.chunks -> Array
|
||||
*
|
||||
* Chunks of output data, if [[Inflate#onData]] not overriden.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Inflate.result -> Uint8Array|Array|String
|
||||
*
|
||||
* Uncompressed result, generated by default [[Inflate#onData]]
|
||||
* and [[Inflate#onEnd]] handlers. Filled after you push last chunk
|
||||
* (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
|
||||
* push a chunk with explicit flush (call [[Inflate#push]] with
|
||||
* `Z_SYNC_FLUSH` param).
|
||||
**/
|
||||
|
||||
/**
|
||||
* Inflate.err -> Number
|
||||
*
|
||||
* Error code after inflate finished. 0 (Z_OK) on success.
|
||||
* Should be checked if broken data possible.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Inflate.msg -> String
|
||||
*
|
||||
* Error message, if [[Inflate.err]] != 0
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* new Inflate(options)
|
||||
* - options (Object): zlib inflate options.
|
||||
*
|
||||
* Creates new inflator instance with specified params. Throws exception
|
||||
* on bad params. Supported options:
|
||||
*
|
||||
* - `windowBits`
|
||||
* - `dictionary`
|
||||
*
|
||||
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
||||
* for more information on these.
|
||||
*
|
||||
* Additional options, for internal needs:
|
||||
*
|
||||
* - `chunkSize` - size of generated data chunks (16K by default)
|
||||
* - `raw` (Boolean) - do raw inflate
|
||||
* - `to` (String) - if equal to 'string', then result will be converted
|
||||
* from utf8 to utf16 (javascript) string. When string output requested,
|
||||
* chunk length can differ from `chunkSize`, depending on content.
|
||||
*
|
||||
* By default, when no options set, autodetect deflate/gzip data format via
|
||||
* wrapper header.
|
||||
*
|
||||
* ##### Example:
|
||||
*
|
||||
* ```javascript
|
||||
* var pako = require('pako')
|
||||
* , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
|
||||
* , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
|
||||
*
|
||||
* var inflate = new pako.Inflate({ level: 3});
|
||||
*
|
||||
* inflate.push(chunk1, false);
|
||||
* inflate.push(chunk2, true); // true -> last chunk
|
||||
*
|
||||
* if (inflate.err) { throw new Error(inflate.err); }
|
||||
*
|
||||
* console.log(inflate.result);
|
||||
* ```
|
||||
**/
|
||||
function Inflate(options) {
|
||||
if (!(this instanceof Inflate)) return new Inflate(options);
|
||||
|
||||
this.options = utils.assign({
|
||||
chunkSize: 16384,
|
||||
windowBits: 0,
|
||||
to: ''
|
||||
}, options || {});
|
||||
|
||||
var opt = this.options;
|
||||
|
||||
// Force window size for `raw` data, if not set directly,
|
||||
// because we have no header for autodetect.
|
||||
if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
|
||||
opt.windowBits = -opt.windowBits;
|
||||
if (opt.windowBits === 0) { opt.windowBits = -15; }
|
||||
}
|
||||
|
||||
// If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
|
||||
if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
|
||||
!(options && options.windowBits)) {
|
||||
opt.windowBits += 32;
|
||||
}
|
||||
|
||||
// Gzip header has no info about windows size, we can do autodetect only
|
||||
// for deflate. So, if window size not set, force it to max when gzip possible
|
||||
if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
|
||||
// bit 3 (16) -> gzipped data
|
||||
// bit 4 (32) -> autodetect gzip/deflate
|
||||
if ((opt.windowBits & 15) === 0) {
|
||||
opt.windowBits |= 15;
|
||||
}
|
||||
}
|
||||
|
||||
this.err = 0; // error code, if happens (0 = Z_OK)
|
||||
this.msg = ''; // error message
|
||||
this.ended = false; // used to avoid multiple onEnd() calls
|
||||
this.chunks = []; // chunks of compressed data
|
||||
|
||||
this.strm = new ZStream();
|
||||
this.strm.avail_out = 0;
|
||||
|
||||
var status = zlib_inflate.inflateInit2(
|
||||
this.strm,
|
||||
opt.windowBits
|
||||
);
|
||||
|
||||
if (status !== c.Z_OK) {
|
||||
throw new Error(msg[status]);
|
||||
}
|
||||
|
||||
this.header = new GZheader();
|
||||
|
||||
zlib_inflate.inflateGetHeader(this.strm, this.header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inflate#push(data[, mode]) -> Boolean
|
||||
* - data (Uint8Array|Array|ArrayBuffer|String): input data
|
||||
* - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
|
||||
* See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
|
||||
*
|
||||
* Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
|
||||
* new output chunks. Returns `true` on success. The last data block must have
|
||||
* mode Z_FINISH (or `true`). That will flush internal pending buffers and call
|
||||
* [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
|
||||
* can use mode Z_SYNC_FLUSH, keeping the decompression context.
|
||||
*
|
||||
* On fail call [[Inflate#onEnd]] with error code and return false.
|
||||
*
|
||||
* We strongly recommend to use `Uint8Array` on input for best speed (output
|
||||
* format is detected automatically). Also, don't skip last param and always
|
||||
* use the same type in your code (boolean or number). That will improve JS speed.
|
||||
*
|
||||
* For regular `Array`-s make sure all elements are [0..255].
|
||||
*
|
||||
* ##### Example
|
||||
*
|
||||
* ```javascript
|
||||
* push(chunk, false); // push one of data chunks
|
||||
* ...
|
||||
* push(chunk, true); // push last chunk
|
||||
* ```
|
||||
**/
|
||||
Inflate.prototype.push = function (data, mode) {
|
||||
var strm = this.strm;
|
||||
var chunkSize = this.options.chunkSize;
|
||||
var dictionary = this.options.dictionary;
|
||||
var status, _mode;
|
||||
var next_out_utf8, tail, utf8str;
|
||||
var dict;
|
||||
|
||||
// Flag to properly process Z_BUF_ERROR on testing inflate call
|
||||
// when we check that all output data was flushed.
|
||||
var allowBufError = false;
|
||||
|
||||
if (this.ended) { return false; }
|
||||
_mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
|
||||
|
||||
// Convert data if needed
|
||||
if (typeof data === 'string') {
|
||||
// Only binary strings can be decompressed on practice
|
||||
strm.input = strings.binstring2buf(data);
|
||||
} else if (toString.call(data) === '[object ArrayBuffer]') {
|
||||
strm.input = new Uint8Array(data);
|
||||
} else {
|
||||
strm.input = data;
|
||||
}
|
||||
|
||||
strm.next_in = 0;
|
||||
strm.avail_in = strm.input.length;
|
||||
|
||||
do {
|
||||
if (strm.avail_out === 0) {
|
||||
strm.output = new utils.Buf8(chunkSize);
|
||||
strm.next_out = 0;
|
||||
strm.avail_out = chunkSize;
|
||||
}
|
||||
|
||||
status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
|
||||
|
||||
if (status === c.Z_NEED_DICT && dictionary) {
|
||||
// Convert data if needed
|
||||
if (typeof dictionary === 'string') {
|
||||
dict = strings.string2buf(dictionary);
|
||||
} else if (toString.call(dictionary) === '[object ArrayBuffer]') {
|
||||
dict = new Uint8Array(dictionary);
|
||||
} else {
|
||||
dict = dictionary;
|
||||
}
|
||||
|
||||
status = zlib_inflate.inflateSetDictionary(this.strm, dict);
|
||||
|
||||
}
|
||||
|
||||
if (status === c.Z_BUF_ERROR && allowBufError === true) {
|
||||
status = c.Z_OK;
|
||||
allowBufError = false;
|
||||
}
|
||||
|
||||
if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
|
||||
this.onEnd(status);
|
||||
this.ended = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strm.next_out) {
|
||||
if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {
|
||||
|
||||
if (this.options.to === 'string') {
|
||||
|
||||
next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
|
||||
|
||||
tail = strm.next_out - next_out_utf8;
|
||||
utf8str = strings.buf2string(strm.output, next_out_utf8);
|
||||
|
||||
// move tail
|
||||
strm.next_out = tail;
|
||||
strm.avail_out = chunkSize - tail;
|
||||
if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }
|
||||
|
||||
this.onData(utf8str);
|
||||
|
||||
} else {
|
||||
this.onData(utils.shrinkBuf(strm.output, strm.next_out));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// When no more input data, we should check that internal inflate buffers
|
||||
// are flushed. The only way to do it when avail_out = 0 - run one more
|
||||
// inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
|
||||
// Here we set flag to process this error properly.
|
||||
//
|
||||
// NOTE. Deflate does not return error in this case and does not needs such
|
||||
// logic.
|
||||
if (strm.avail_in === 0 && strm.avail_out === 0) {
|
||||
allowBufError = true;
|
||||
}
|
||||
|
||||
} while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
|
||||
|
||||
if (status === c.Z_STREAM_END) {
|
||||
_mode = c.Z_FINISH;
|
||||
}
|
||||
|
||||
// Finalize on the last chunk.
|
||||
if (_mode === c.Z_FINISH) {
|
||||
status = zlib_inflate.inflateEnd(this.strm);
|
||||
this.onEnd(status);
|
||||
this.ended = true;
|
||||
return status === c.Z_OK;
|
||||
}
|
||||
|
||||
// callback interim results if Z_SYNC_FLUSH.
|
||||
if (_mode === c.Z_SYNC_FLUSH) {
|
||||
this.onEnd(c.Z_OK);
|
||||
strm.avail_out = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Inflate#onData(chunk) -> Void
|
||||
* - chunk (Uint8Array|Array|String): ouput data. Type of array depends
|
||||
* on js engine support. When string output requested, each chunk
|
||||
* will be string.
|
||||
*
|
||||
* By default, stores data blocks in `chunks[]` property and glue
|
||||
* those in `onEnd`. Override this handler, if you need another behaviour.
|
||||
**/
|
||||
Inflate.prototype.onData = function (chunk) {
|
||||
this.chunks.push(chunk);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Inflate#onEnd(status) -> Void
|
||||
* - status (Number): inflate status. 0 (Z_OK) on success,
|
||||
* other if not.
|
||||
*
|
||||
* Called either after you tell inflate that the input stream is
|
||||
* complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
|
||||
* or if an error happened. By default - join collected chunks,
|
||||
* free memory and fill `results` / `err` properties.
|
||||
**/
|
||||
Inflate.prototype.onEnd = function (status) {
|
||||
// On success - join
|
||||
if (status === c.Z_OK) {
|
||||
if (this.options.to === 'string') {
|
||||
// Glue & convert here, until we teach pako to send
|
||||
// utf8 alligned strings to onData
|
||||
this.result = this.chunks.join('');
|
||||
} else {
|
||||
this.result = utils.flattenChunks(this.chunks);
|
||||
}
|
||||
}
|
||||
this.chunks = [];
|
||||
this.err = status;
|
||||
this.msg = this.strm.msg;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* inflate(data[, options]) -> Uint8Array|Array|String
|
||||
* - data (Uint8Array|Array|String): input data to decompress.
|
||||
* - options (Object): zlib inflate options.
|
||||
*
|
||||
* Decompress `data` with inflate/ungzip and `options`. Autodetect
|
||||
* format via wrapper header by default. That's why we don't provide
|
||||
* separate `ungzip` method.
|
||||
*
|
||||
* Supported options are:
|
||||
*
|
||||
* - windowBits
|
||||
*
|
||||
* [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
||||
* for more information.
|
||||
*
|
||||
* Sugar (options):
|
||||
*
|
||||
* - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
|
||||
* negative windowBits implicitly.
|
||||
* - `to` (String) - if equal to 'string', then result will be converted
|
||||
* from utf8 to utf16 (javascript) string. When string output requested,
|
||||
* chunk length can differ from `chunkSize`, depending on content.
|
||||
*
|
||||
*
|
||||
* ##### Example:
|
||||
*
|
||||
* ```javascript
|
||||
* var pako = require('pako')
|
||||
* , input = pako.deflate([1,2,3,4,5,6,7,8,9])
|
||||
* , output;
|
||||
*
|
||||
* try {
|
||||
* output = pako.inflate(input);
|
||||
* } catch (err)
|
||||
* console.log(err);
|
||||
* }
|
||||
* ```
|
||||
**/
|
||||
function inflate(input, options) {
|
||||
var inflator = new Inflate(options);
|
||||
|
||||
inflator.push(input, true);
|
||||
|
||||
// That will never happens, if you don't cheat with options :)
|
||||
if (inflator.err) { throw inflator.msg; }
|
||||
|
||||
return inflator.result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* inflateRaw(data[, options]) -> Uint8Array|Array|String
|
||||
* - data (Uint8Array|Array|String): input data to decompress.
|
||||
* - options (Object): zlib inflate options.
|
||||
*
|
||||
* The same as [[inflate]], but creates raw data, without wrapper
|
||||
* (header and adler32 crc).
|
||||
**/
|
||||
function inflateRaw(input, options) {
|
||||
options = options || {};
|
||||
options.raw = true;
|
||||
return inflate(input, options);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ungzip(data[, options]) -> Uint8Array|Array|String
|
||||
* - data (Uint8Array|Array|String): input data to decompress.
|
||||
* - options (Object): zlib inflate options.
|
||||
*
|
||||
* Just shortcut to [[inflate]], because it autodetects format
|
||||
* by header.content. Done for convenience.
|
||||
**/
|
||||
|
||||
|
||||
exports.Inflate = Inflate;
|
||||
exports.inflate = inflate;
|
||||
exports.inflateRaw = inflateRaw;
|
||||
exports.ungzip = inflate;
|
102
node_modules/pako/lib/utils/common.js
generated
vendored
Normal file
102
node_modules/pako/lib/utils/common.js
generated
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var TYPED_OK = (typeof Uint8Array !== 'undefined') &&
|
||||
(typeof Uint16Array !== 'undefined') &&
|
||||
(typeof Int32Array !== 'undefined');
|
||||
|
||||
|
||||
exports.assign = function (obj /*from1, from2, from3, ...*/) {
|
||||
var sources = Array.prototype.slice.call(arguments, 1);
|
||||
while (sources.length) {
|
||||
var source = sources.shift();
|
||||
if (!source) { continue; }
|
||||
|
||||
if (typeof source !== 'object') {
|
||||
throw new TypeError(source + 'must be non-object');
|
||||
}
|
||||
|
||||
for (var p in source) {
|
||||
if (source.hasOwnProperty(p)) {
|
||||
obj[p] = source[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
// reduce buffer size, avoiding mem copy
|
||||
exports.shrinkBuf = function (buf, size) {
|
||||
if (buf.length === size) { return buf; }
|
||||
if (buf.subarray) { return buf.subarray(0, size); }
|
||||
buf.length = size;
|
||||
return buf;
|
||||
};
|
||||
|
||||
|
||||
var fnTyped = {
|
||||
arraySet: function (dest, src, src_offs, len, dest_offs) {
|
||||
if (src.subarray && dest.subarray) {
|
||||
dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
|
||||
return;
|
||||
}
|
||||
// Fallback to ordinary array
|
||||
for (var i = 0; i < len; i++) {
|
||||
dest[dest_offs + i] = src[src_offs + i];
|
||||
}
|
||||
},
|
||||
// Join array of chunks to single array.
|
||||
flattenChunks: function (chunks) {
|
||||
var i, l, len, pos, chunk, result;
|
||||
|
||||
// calculate data length
|
||||
len = 0;
|
||||
for (i = 0, l = chunks.length; i < l; i++) {
|
||||
len += chunks[i].length;
|
||||
}
|
||||
|
||||
// join chunks
|
||||
result = new Uint8Array(len);
|
||||
pos = 0;
|
||||
for (i = 0, l = chunks.length; i < l; i++) {
|
||||
chunk = chunks[i];
|
||||
result.set(chunk, pos);
|
||||
pos += chunk.length;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
var fnUntyped = {
|
||||
arraySet: function (dest, src, src_offs, len, dest_offs) {
|
||||
for (var i = 0; i < len; i++) {
|
||||
dest[dest_offs + i] = src[src_offs + i];
|
||||
}
|
||||
},
|
||||
// Join array of chunks to single array.
|
||||
flattenChunks: function (chunks) {
|
||||
return [].concat.apply([], chunks);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Enable/Disable typed arrays use, for testing
|
||||
//
|
||||
exports.setTyped = function (on) {
|
||||
if (on) {
|
||||
exports.Buf8 = Uint8Array;
|
||||
exports.Buf16 = Uint16Array;
|
||||
exports.Buf32 = Int32Array;
|
||||
exports.assign(exports, fnTyped);
|
||||
} else {
|
||||
exports.Buf8 = Array;
|
||||
exports.Buf16 = Array;
|
||||
exports.Buf32 = Array;
|
||||
exports.assign(exports, fnUntyped);
|
||||
}
|
||||
};
|
||||
|
||||
exports.setTyped(TYPED_OK);
|
185
node_modules/pako/lib/utils/strings.js
generated
vendored
Normal file
185
node_modules/pako/lib/utils/strings.js
generated
vendored
Normal file
|
@ -0,0 +1,185 @@
|
|||
// String encode/decode helpers
|
||||
'use strict';
|
||||
|
||||
|
||||
var utils = require('./common');
|
||||
|
||||
|
||||
// Quick check if we can use fast array to bin string conversion
|
||||
//
|
||||
// - apply(Array) can fail on Android 2.2
|
||||
// - apply(Uint8Array) can fail on iOS 5.1 Safary
|
||||
//
|
||||
var STR_APPLY_OK = true;
|
||||
var STR_APPLY_UIA_OK = true;
|
||||
|
||||
try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }
|
||||
try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }
|
||||
|
||||
|
||||
// Table with utf8 lengths (calculated by first byte of sequence)
|
||||
// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
|
||||
// because max possible codepoint is 0x10ffff
|
||||
var _utf8len = new utils.Buf8(256);
|
||||
for (var q = 0; q < 256; q++) {
|
||||
_utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
|
||||
}
|
||||
_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
|
||||
|
||||
|
||||
// convert string to array (typed, when possible)
|
||||
exports.string2buf = function (str) {
|
||||
var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
|
||||
|
||||
// count binary size
|
||||
for (m_pos = 0; m_pos < str_len; m_pos++) {
|
||||
c = str.charCodeAt(m_pos);
|
||||
if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
|
||||
c2 = str.charCodeAt(m_pos + 1);
|
||||
if ((c2 & 0xfc00) === 0xdc00) {
|
||||
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
||||
m_pos++;
|
||||
}
|
||||
}
|
||||
buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
|
||||
}
|
||||
|
||||
// allocate buffer
|
||||
buf = new utils.Buf8(buf_len);
|
||||
|
||||
// convert
|
||||
for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
|
||||
c = str.charCodeAt(m_pos);
|
||||
if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
|
||||
c2 = str.charCodeAt(m_pos + 1);
|
||||
if ((c2 & 0xfc00) === 0xdc00) {
|
||||
c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
||||
m_pos++;
|
||||
}
|
||||
}
|
||||
if (c < 0x80) {
|
||||
/* one byte */
|
||||
buf[i++] = c;
|
||||
} else if (c < 0x800) {
|
||||
/* two bytes */
|
||||
buf[i++] = 0xC0 | (c >>> 6);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
} else if (c < 0x10000) {
|
||||
/* three bytes */
|
||||
buf[i++] = 0xE0 | (c >>> 12);
|
||||
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
} else {
|
||||
/* four bytes */
|
||||
buf[i++] = 0xf0 | (c >>> 18);
|
||||
buf[i++] = 0x80 | (c >>> 12 & 0x3f);
|
||||
buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
||||
buf[i++] = 0x80 | (c & 0x3f);
|
||||
}
|
||||
}
|
||||
|
||||
return buf;
|
||||
};
|
||||
|
||||
// Helper (used in 2 places)
|
||||
function buf2binstring(buf, len) {
|
||||
// use fallback for big arrays to avoid stack overflow
|
||||
if (len < 65537) {
|
||||
if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {
|
||||
return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
|
||||
}
|
||||
}
|
||||
|
||||
var result = '';
|
||||
for (var i = 0; i < len; i++) {
|
||||
result += String.fromCharCode(buf[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
// Convert byte array to binary string
|
||||
exports.buf2binstring = function (buf) {
|
||||
return buf2binstring(buf, buf.length);
|
||||
};
|
||||
|
||||
|
||||
// Convert binary string (typed, when possible)
|
||||
exports.binstring2buf = function (str) {
|
||||
var buf = new utils.Buf8(str.length);
|
||||
for (var i = 0, len = buf.length; i < len; i++) {
|
||||
buf[i] = str.charCodeAt(i);
|
||||
}
|
||||
return buf;
|
||||
};
|
||||
|
||||
|
||||
// convert array to string
|
||||
exports.buf2string = function (buf, max) {
|
||||
var i, out, c, c_len;
|
||||
var len = max || buf.length;
|
||||
|
||||
// Reserve max possible length (2 words per char)
|
||||
// NB: by unknown reasons, Array is significantly faster for
|
||||
// String.fromCharCode.apply than Uint16Array.
|
||||
var utf16buf = new Array(len * 2);
|
||||
|
||||
for (out = 0, i = 0; i < len;) {
|
||||
c = buf[i++];
|
||||
// quick process ascii
|
||||
if (c < 0x80) { utf16buf[out++] = c; continue; }
|
||||
|
||||
c_len = _utf8len[c];
|
||||
// skip 5 & 6 byte codes
|
||||
if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }
|
||||
|
||||
// apply mask on first byte
|
||||
c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
|
||||
// join the rest
|
||||
while (c_len > 1 && i < len) {
|
||||
c = (c << 6) | (buf[i++] & 0x3f);
|
||||
c_len--;
|
||||
}
|
||||
|
||||
// terminated by end of string?
|
||||
if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
|
||||
|
||||
if (c < 0x10000) {
|
||||
utf16buf[out++] = c;
|
||||
} else {
|
||||
c -= 0x10000;
|
||||
utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
|
||||
utf16buf[out++] = 0xdc00 | (c & 0x3ff);
|
||||
}
|
||||
}
|
||||
|
||||
return buf2binstring(utf16buf, out);
|
||||
};
|
||||
|
||||
|
||||
// Calculate max possible position in utf8 buffer,
|
||||
// that will not break sequence. If that's not possible
|
||||
// - (very small limits) return max size as is.
|
||||
//
|
||||
// buf[] - utf8 bytes array
|
||||
// max - length limit (mandatory);
|
||||
exports.utf8border = function (buf, max) {
|
||||
var pos;
|
||||
|
||||
max = max || buf.length;
|
||||
if (max > buf.length) { max = buf.length; }
|
||||
|
||||
// go back from last position, until start of sequence found
|
||||
pos = max - 1;
|
||||
while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
|
||||
|
||||
// Fuckup - very small and broken sequence,
|
||||
// return max, because we should return something anyway.
|
||||
if (pos < 0) { return max; }
|
||||
|
||||
// If we came to start of buffer - that means vuffer is too small,
|
||||
// return max too.
|
||||
if (pos === 0) { return max; }
|
||||
|
||||
return (pos + _utf8len[buf[pos]] > max) ? pos : max;
|
||||
};
|
32
node_modules/pako/lib/zlib/adler32.js
generated
vendored
Normal file
32
node_modules/pako/lib/zlib/adler32.js
generated
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
'use strict';
|
||||
|
||||
// Note: adler32 takes 12% for level 0 and 2% for level 6.
|
||||
// It doesn't worth to make additional optimizationa as in original.
|
||||
// Small size is preferable.
|
||||
|
||||
function adler32(adler, buf, len, pos) {
|
||||
var s1 = (adler & 0xffff) |0,
|
||||
s2 = ((adler >>> 16) & 0xffff) |0,
|
||||
n = 0;
|
||||
|
||||
while (len !== 0) {
|
||||
// Set limit ~ twice less than 5552, to keep
|
||||
// s2 in 31-bits, because we force signed ints.
|
||||
// in other case %= will fail.
|
||||
n = len > 2000 ? 2000 : len;
|
||||
len -= n;
|
||||
|
||||
do {
|
||||
s1 = (s1 + buf[pos++]) |0;
|
||||
s2 = (s2 + s1) |0;
|
||||
} while (--n);
|
||||
|
||||
s1 %= 65521;
|
||||
s2 %= 65521;
|
||||
}
|
||||
|
||||
return (s1 | (s2 << 16)) |0;
|
||||
}
|
||||
|
||||
|
||||
module.exports = adler32;
|
50
node_modules/pako/lib/zlib/constants.js
generated
vendored
Normal file
50
node_modules/pako/lib/zlib/constants.js
generated
vendored
Normal file
|
@ -0,0 +1,50 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
/* Allowed flush values; see deflate() and inflate() below for details */
|
||||
Z_NO_FLUSH: 0,
|
||||
Z_PARTIAL_FLUSH: 1,
|
||||
Z_SYNC_FLUSH: 2,
|
||||
Z_FULL_FLUSH: 3,
|
||||
Z_FINISH: 4,
|
||||
Z_BLOCK: 5,
|
||||
Z_TREES: 6,
|
||||
|
||||
/* Return codes for the compression/decompression functions. Negative values
|
||||
* are errors, positive values are used for special but normal events.
|
||||
*/
|
||||
Z_OK: 0,
|
||||
Z_STREAM_END: 1,
|
||||
Z_NEED_DICT: 2,
|
||||
Z_ERRNO: -1,
|
||||
Z_STREAM_ERROR: -2,
|
||||
Z_DATA_ERROR: -3,
|
||||
//Z_MEM_ERROR: -4,
|
||||
Z_BUF_ERROR: -5,
|
||||
//Z_VERSION_ERROR: -6,
|
||||
|
||||
/* compression levels */
|
||||
Z_NO_COMPRESSION: 0,
|
||||
Z_BEST_SPEED: 1,
|
||||
Z_BEST_COMPRESSION: 9,
|
||||
Z_DEFAULT_COMPRESSION: -1,
|
||||
|
||||
|
||||
Z_FILTERED: 1,
|
||||
Z_HUFFMAN_ONLY: 2,
|
||||
Z_RLE: 3,
|
||||
Z_FIXED: 4,
|
||||
Z_DEFAULT_STRATEGY: 0,
|
||||
|
||||
/* Possible values of the data_type field (though see inflate()) */
|
||||
Z_BINARY: 0,
|
||||
Z_TEXT: 1,
|
||||
//Z_ASCII: 1, // = Z_TEXT (deprecated)
|
||||
Z_UNKNOWN: 2,
|
||||
|
||||
/* The deflate compression method */
|
||||
Z_DEFLATED: 8
|
||||
//Z_NULL: null // Use -1 or null inline, depending on var type
|
||||
};
|
41
node_modules/pako/lib/zlib/crc32.js
generated
vendored
Normal file
41
node_modules/pako/lib/zlib/crc32.js
generated
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
'use strict';
|
||||
|
||||
// Note: we can't get significant speed boost here.
|
||||
// So write code to minimize size - no pregenerated tables
|
||||
// and array tools dependencies.
|
||||
|
||||
|
||||
// Use ordinary array, since untyped makes no boost here
|
||||
function makeTable() {
|
||||
var c, table = [];
|
||||
|
||||
for (var n = 0; n < 256; n++) {
|
||||
c = n;
|
||||
for (var k = 0; k < 8; k++) {
|
||||
c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
|
||||
}
|
||||
table[n] = c;
|
||||
}
|
||||
|
||||
return table;
|
||||
}
|
||||
|
||||
// Create table on load. Just 255 signed longs. Not a problem.
|
||||
var crcTable = makeTable();
|
||||
|
||||
|
||||
function crc32(crc, buf, len, pos) {
|
||||
var t = crcTable,
|
||||
end = pos + len;
|
||||
|
||||
crc ^= -1;
|
||||
|
||||
for (var i = pos; i < end; i++) {
|
||||
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
|
||||
}
|
||||
|
||||
return (crc ^ (-1)); // >>> 0;
|
||||
}
|
||||
|
||||
|
||||
module.exports = crc32;
|
1855
node_modules/pako/lib/zlib/deflate.js
generated
vendored
Normal file
1855
node_modules/pako/lib/zlib/deflate.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
40
node_modules/pako/lib/zlib/gzheader.js
generated
vendored
Normal file
40
node_modules/pako/lib/zlib/gzheader.js
generated
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
function GZheader() {
|
||||
/* true if compressed data believed to be text */
|
||||
this.text = 0;
|
||||
/* modification time */
|
||||
this.time = 0;
|
||||
/* extra flags (not used when writing a gzip file) */
|
||||
this.xflags = 0;
|
||||
/* operating system */
|
||||
this.os = 0;
|
||||
/* pointer to extra field or Z_NULL if none */
|
||||
this.extra = null;
|
||||
/* extra field length (valid if extra != Z_NULL) */
|
||||
this.extra_len = 0; // Actually, we don't need it in JS,
|
||||
// but leave for few code modifications
|
||||
|
||||
//
|
||||
// Setup limits is not necessary because in js we should not preallocate memory
|
||||
// for inflate use constant limit in 65536 bytes
|
||||
//
|
||||
|
||||
/* space at extra (only when reading header) */
|
||||
// this.extra_max = 0;
|
||||
/* pointer to zero-terminated file name or Z_NULL */
|
||||
this.name = '';
|
||||
/* space at name (only when reading header) */
|
||||
// this.name_max = 0;
|
||||
/* pointer to zero-terminated comment or Z_NULL */
|
||||
this.comment = '';
|
||||
/* space at comment (only when reading header) */
|
||||
// this.comm_max = 0;
|
||||
/* true if there was or will be a header crc */
|
||||
this.hcrc = 0;
|
||||
/* true when done reading gzip header (not used when writing a gzip file) */
|
||||
this.done = false;
|
||||
}
|
||||
|
||||
module.exports = GZheader;
|
326
node_modules/pako/lib/zlib/inffast.js
generated
vendored
Normal file
326
node_modules/pako/lib/zlib/inffast.js
generated
vendored
Normal file
|
@ -0,0 +1,326 @@
|
|||
'use strict';
|
||||
|
||||
// See state defs from inflate.js
|
||||
var BAD = 30; /* got a data error -- remain here until reset */
|
||||
var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
|
||||
|
||||
/*
|
||||
Decode literal, length, and distance codes and write out the resulting
|
||||
literal and match bytes until either not enough input or output is
|
||||
available, an end-of-block is encountered, or a data error is encountered.
|
||||
When large enough input and output buffers are supplied to inflate(), for
|
||||
example, a 16K input buffer and a 64K output buffer, more than 95% of the
|
||||
inflate execution time is spent in this routine.
|
||||
|
||||
Entry assumptions:
|
||||
|
||||
state.mode === LEN
|
||||
strm.avail_in >= 6
|
||||
strm.avail_out >= 258
|
||||
start >= strm.avail_out
|
||||
state.bits < 8
|
||||
|
||||
On return, state.mode is one of:
|
||||
|
||||
LEN -- ran out of enough output space or enough available input
|
||||
TYPE -- reached end of block code, inflate() to interpret next block
|
||||
BAD -- error in block data
|
||||
|
||||
Notes:
|
||||
|
||||
- The maximum input bits used by a length/distance pair is 15 bits for the
|
||||
length code, 5 bits for the length extra, 15 bits for the distance code,
|
||||
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
|
||||
Therefore if strm.avail_in >= 6, then there is enough input to avoid
|
||||
checking for available input while decoding.
|
||||
|
||||
- The maximum bytes that a single length/distance pair can output is 258
|
||||
bytes, which is the maximum length that can be coded. inflate_fast()
|
||||
requires strm.avail_out >= 258 for each loop to avoid checking for
|
||||
output space.
|
||||
*/
|
||||
module.exports = function inflate_fast(strm, start) {
|
||||
var state;
|
||||
var _in; /* local strm.input */
|
||||
var last; /* have enough input while in < last */
|
||||
var _out; /* local strm.output */
|
||||
var beg; /* inflate()'s initial strm.output */
|
||||
var end; /* while out < end, enough space available */
|
||||
//#ifdef INFLATE_STRICT
|
||||
var dmax; /* maximum distance from zlib header */
|
||||
//#endif
|
||||
var wsize; /* window size or zero if not using window */
|
||||
var whave; /* valid bytes in the window */
|
||||
var wnext; /* window write index */
|
||||
// Use `s_window` instead `window`, avoid conflict with instrumentation tools
|
||||
var s_window; /* allocated sliding window, if wsize != 0 */
|
||||
var hold; /* local strm.hold */
|
||||
var bits; /* local strm.bits */
|
||||
var lcode; /* local strm.lencode */
|
||||
var dcode; /* local strm.distcode */
|
||||
var lmask; /* mask for first level of length codes */
|
||||
var dmask; /* mask for first level of distance codes */
|
||||
var here; /* retrieved table entry */
|
||||
var op; /* code bits, operation, extra bits, or */
|
||||
/* window position, window bytes to copy */
|
||||
var len; /* match length, unused bytes */
|
||||
var dist; /* match distance */
|
||||
var from; /* where to copy match from */
|
||||
var from_source;
|
||||
|
||||
|
||||
var input, output; // JS specific, because we have no pointers
|
||||
|
||||
/* copy state to local variables */
|
||||
state = strm.state;
|
||||
//here = state.here;
|
||||
_in = strm.next_in;
|
||||
input = strm.input;
|
||||
last = _in + (strm.avail_in - 5);
|
||||
_out = strm.next_out;
|
||||
output = strm.output;
|
||||
beg = _out - (start - strm.avail_out);
|
||||
end = _out + (strm.avail_out - 257);
|
||||
//#ifdef INFLATE_STRICT
|
||||
dmax = state.dmax;
|
||||
//#endif
|
||||
wsize = state.wsize;
|
||||
whave = state.whave;
|
||||
wnext = state.wnext;
|
||||
s_window = state.window;
|
||||
hold = state.hold;
|
||||
bits = state.bits;
|
||||
lcode = state.lencode;
|
||||
dcode = state.distcode;
|
||||
lmask = (1 << state.lenbits) - 1;
|
||||
dmask = (1 << state.distbits) - 1;
|
||||
|
||||
|
||||
/* decode literals and length/distances until end-of-block or not enough
|
||||
input data or output space */
|
||||
|
||||
top:
|
||||
do {
|
||||
if (bits < 15) {
|
||||
hold += input[_in++] << bits;
|
||||
bits += 8;
|
||||
hold += input[_in++] << bits;
|
||||
bits += 8;
|
||||
}
|
||||
|
||||
here = lcode[hold & lmask];
|
||||
|
||||
dolen:
|
||||
for (;;) { // Goto emulation
|
||||
op = here >>> 24/*here.bits*/;
|
||||
hold >>>= op;
|
||||
bits -= op;
|
||||
op = (here >>> 16) & 0xff/*here.op*/;
|
||||
if (op === 0) { /* literal */
|
||||
//Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||
// "inflate: literal '%c'\n" :
|
||||
// "inflate: literal 0x%02x\n", here.val));
|
||||
output[_out++] = here & 0xffff/*here.val*/;
|
||||
}
|
||||
else if (op & 16) { /* length base */
|
||||
len = here & 0xffff/*here.val*/;
|
||||
op &= 15; /* number of extra bits */
|
||||
if (op) {
|
||||
if (bits < op) {
|
||||
hold += input[_in++] << bits;
|
||||
bits += 8;
|
||||
}
|
||||
len += hold & ((1 << op) - 1);
|
||||
hold >>>= op;
|
||||
bits -= op;
|
||||
}
|
||||
//Tracevv((stderr, "inflate: length %u\n", len));
|
||||
if (bits < 15) {
|
||||
hold += input[_in++] << bits;
|
||||
bits += 8;
|
||||
hold += input[_in++] << bits;
|
||||
bits += 8;
|
||||
}
|
||||
here = dcode[hold & dmask];
|
||||
|
||||
dodist:
|
||||
for (;;) { // goto emulation
|
||||
op = here >>> 24/*here.bits*/;
|
||||
hold >>>= op;
|
||||
bits -= op;
|
||||
op = (here >>> 16) & 0xff/*here.op*/;
|
||||
|
||||
if (op & 16) { /* distance base */
|
||||
dist = here & 0xffff/*here.val*/;
|
||||
op &= 15; /* number of extra bits */
|
||||
if (bits < op) {
|
||||
hold += input[_in++] << bits;
|
||||
bits += 8;
|
||||
if (bits < op) {
|
||||
hold += input[_in++] << bits;
|
||||
bits += 8;
|
||||
}
|
||||
}
|
||||
dist += hold & ((1 << op) - 1);
|
||||
//#ifdef INFLATE_STRICT
|
||||
if (dist > dmax) {
|
||||
strm.msg = 'invalid distance too far back';
|
||||
state.mode = BAD;
|
||||
break top;
|
||||
}
|
||||
//#endif
|
||||
hold >>>= op;
|
||||
bits -= op;
|
||||
//Tracevv((stderr, "inflate: distance %u\n", dist));
|
||||
op = _out - beg; /* max distance in output */
|
||||
if (dist > op) { /* see if copy from window */
|
||||
op = dist - op; /* distance back in window */
|
||||
if (op > whave) {
|
||||
if (state.sane) {
|
||||
strm.msg = 'invalid distance too far back';
|
||||
state.mode = BAD;
|
||||
break top;
|
||||
}
|
||||
|
||||
// (!) This block is disabled in zlib defailts,
|
||||
// don't enable it for binary compatibility
|
||||
//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||
// if (len <= op - whave) {
|
||||
// do {
|
||||
// output[_out++] = 0;
|
||||
// } while (--len);
|
||||
// continue top;
|
||||
// }
|
||||
// len -= op - whave;
|
||||
// do {
|
||||
// output[_out++] = 0;
|
||||
// } while (--op > whave);
|
||||
// if (op === 0) {
|
||||
// from = _out - dist;
|
||||
// do {
|
||||
// output[_out++] = output[from++];
|
||||
// } while (--len);
|
||||
// continue top;
|
||||
// }
|
||||
//#endif
|
||||
}
|
||||
from = 0; // window index
|
||||
from_source = s_window;
|
||||
if (wnext === 0) { /* very common case */
|
||||
from += wsize - op;
|
||||
if (op < len) { /* some from window */
|
||||
len -= op;
|
||||
do {
|
||||
output[_out++] = s_window[from++];
|
||||
} while (--op);
|
||||
from = _out - dist; /* rest from output */
|
||||
from_source = output;
|
||||
}
|
||||
}
|
||||
else if (wnext < op) { /* wrap around window */
|
||||
from += wsize + wnext - op;
|
||||
op -= wnext;
|
||||
if (op < len) { /* some from end of window */
|
||||
len -= op;
|
||||
do {
|
||||
output[_out++] = s_window[from++];
|
||||
} while (--op);
|
||||
from = 0;
|
||||
if (wnext < len) { /* some from start of window */
|
||||
op = wnext;
|
||||
len -= op;
|
||||
do {
|
||||
output[_out++] = s_window[from++];
|
||||
} while (--op);
|
||||
from = _out - dist; /* rest from output */
|
||||
from_source = output;
|
||||
}
|
||||
}
|
||||
}
|
||||
else { /* contiguous in window */
|
||||
from += wnext - op;
|
||||
if (op < len) { /* some from window */
|
||||
len -= op;
|
||||
do {
|
||||
output[_out++] = s_window[from++];
|
||||
} while (--op);
|
||||
from = _out - dist; /* rest from output */
|
||||
from_source = output;
|
||||
}
|
||||
}
|
||||
while (len > 2) {
|
||||
output[_out++] = from_source[from++];
|
||||
output[_out++] = from_source[from++];
|
||||
output[_out++] = from_source[from++];
|
||||
len -= 3;
|
||||
}
|
||||
if (len) {
|
||||
output[_out++] = from_source[from++];
|
||||
if (len > 1) {
|
||||
output[_out++] = from_source[from++];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
from = _out - dist; /* copy direct from output */
|
||||
do { /* minimum length is three */
|
||||
output[_out++] = output[from++];
|
||||
output[_out++] = output[from++];
|
||||
output[_out++] = output[from++];
|
||||
len -= 3;
|
||||
} while (len > 2);
|
||||
if (len) {
|
||||
output[_out++] = output[from++];
|
||||
if (len > 1) {
|
||||
output[_out++] = output[from++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((op & 64) === 0) { /* 2nd level distance code */
|
||||
here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
|
||||
continue dodist;
|
||||
}
|
||||
else {
|
||||
strm.msg = 'invalid distance code';
|
||||
state.mode = BAD;
|
||||
break top;
|
||||
}
|
||||
|
||||
break; // need to emulate goto via "continue"
|
||||
}
|
||||
}
|
||||
else if ((op & 64) === 0) { /* 2nd level length code */
|
||||
here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
|
||||
continue dolen;
|
||||
}
|
||||
else if (op & 32) { /* end-of-block */
|
||||
//Tracevv((stderr, "inflate: end of block\n"));
|
||||
state.mode = TYPE;
|
||||
break top;
|
||||
}
|
||||
else {
|
||||
strm.msg = 'invalid literal/length code';
|
||||
state.mode = BAD;
|
||||
break top;
|
||||
}
|
||||
|
||||
break; // need to emulate goto via "continue"
|
||||
}
|
||||
} while (_in < last && _out < end);
|
||||
|
||||
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
|
||||
len = bits >> 3;
|
||||
_in -= len;
|
||||
bits -= len << 3;
|
||||
hold &= (1 << bits) - 1;
|
||||
|
||||
/* update state and return */
|
||||
strm.next_in = _in;
|
||||
strm.next_out = _out;
|
||||
strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
|
||||
strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
|
||||
state.hold = hold;
|
||||
state.bits = bits;
|
||||
return;
|
||||
};
|
1538
node_modules/pako/lib/zlib/inflate.js
generated
vendored
Normal file
1538
node_modules/pako/lib/zlib/inflate.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
327
node_modules/pako/lib/zlib/inftrees.js
generated
vendored
Normal file
327
node_modules/pako/lib/zlib/inftrees.js
generated
vendored
Normal file
|
@ -0,0 +1,327 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
var utils = require('../utils/common');
|
||||
|
||||
var MAXBITS = 15;
|
||||
var ENOUGH_LENS = 852;
|
||||
var ENOUGH_DISTS = 592;
|
||||
//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
|
||||
|
||||
var CODES = 0;
|
||||
var LENS = 1;
|
||||
var DISTS = 2;
|
||||
|
||||
var lbase = [ /* Length codes 257..285 base */
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
|
||||
];
|
||||
|
||||
var lext = [ /* Length codes 257..285 extra */
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78
|
||||
];
|
||||
|
||||
var dbase = [ /* Distance codes 0..29 base */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577, 0, 0
|
||||
];
|
||||
|
||||
var dext = [ /* Distance codes 0..29 extra */
|
||||
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
|
||||
23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
|
||||
28, 28, 29, 29, 64, 64
|
||||
];
|
||||
|
||||
module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)
|
||||
{
|
||||
var bits = opts.bits;
|
||||
//here = opts.here; /* table entry for duplication */
|
||||
|
||||
var len = 0; /* a code's length in bits */
|
||||
var sym = 0; /* index of code symbols */
|
||||
var min = 0, max = 0; /* minimum and maximum code lengths */
|
||||
var root = 0; /* number of index bits for root table */
|
||||
var curr = 0; /* number of index bits for current table */
|
||||
var drop = 0; /* code bits to drop for sub-table */
|
||||
var left = 0; /* number of prefix codes available */
|
||||
var used = 0; /* code entries in table used */
|
||||
var huff = 0; /* Huffman code */
|
||||
var incr; /* for incrementing code, index */
|
||||
var fill; /* index for replicating entries */
|
||||
var low; /* low bits for current root entry */
|
||||
var mask; /* mask for low root bits */
|
||||
var next; /* next available space in table */
|
||||
var base = null; /* base value table to use */
|
||||
var base_index = 0;
|
||||
// var shoextra; /* extra bits table to use */
|
||||
var end; /* use base and extra for symbol > end */
|
||||
var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
|
||||
var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
|
||||
var extra = null;
|
||||
var extra_index = 0;
|
||||
|
||||
var here_bits, here_op, here_val;
|
||||
|
||||
/*
|
||||
Process a set of code lengths to create a canonical Huffman code. The
|
||||
code lengths are lens[0..codes-1]. Each length corresponds to the
|
||||
symbols 0..codes-1. The Huffman code is generated by first sorting the
|
||||
symbols by length from short to long, and retaining the symbol order
|
||||
for codes with equal lengths. Then the code starts with all zero bits
|
||||
for the first code of the shortest length, and the codes are integer
|
||||
increments for the same length, and zeros are appended as the length
|
||||
increases. For the deflate format, these bits are stored backwards
|
||||
from their more natural integer increment ordering, and so when the
|
||||
decoding tables are built in the large loop below, the integer codes
|
||||
are incremented backwards.
|
||||
|
||||
This routine assumes, but does not check, that all of the entries in
|
||||
lens[] are in the range 0..MAXBITS. The caller must assure this.
|
||||
1..MAXBITS is interpreted as that code length. zero means that that
|
||||
symbol does not occur in this code.
|
||||
|
||||
The codes are sorted by computing a count of codes for each length,
|
||||
creating from that a table of starting indices for each length in the
|
||||
sorted table, and then entering the symbols in order in the sorted
|
||||
table. The sorted table is work[], with that space being provided by
|
||||
the caller.
|
||||
|
||||
The length counts are used for other purposes as well, i.e. finding
|
||||
the minimum and maximum length codes, determining if there are any
|
||||
codes at all, checking for a valid set of lengths, and looking ahead
|
||||
at length counts to determine sub-table sizes when building the
|
||||
decoding tables.
|
||||
*/
|
||||
|
||||
/* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
|
||||
for (len = 0; len <= MAXBITS; len++) {
|
||||
count[len] = 0;
|
||||
}
|
||||
for (sym = 0; sym < codes; sym++) {
|
||||
count[lens[lens_index + sym]]++;
|
||||
}
|
||||
|
||||
/* bound code lengths, force root to be within code lengths */
|
||||
root = bits;
|
||||
for (max = MAXBITS; max >= 1; max--) {
|
||||
if (count[max] !== 0) { break; }
|
||||
}
|
||||
if (root > max) {
|
||||
root = max;
|
||||
}
|
||||
if (max === 0) { /* no symbols to code at all */
|
||||
//table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
|
||||
//table.bits[opts.table_index] = 1; //here.bits = (var char)1;
|
||||
//table.val[opts.table_index++] = 0; //here.val = (var short)0;
|
||||
table[table_index++] = (1 << 24) | (64 << 16) | 0;
|
||||
|
||||
|
||||
//table.op[opts.table_index] = 64;
|
||||
//table.bits[opts.table_index] = 1;
|
||||
//table.val[opts.table_index++] = 0;
|
||||
table[table_index++] = (1 << 24) | (64 << 16) | 0;
|
||||
|
||||
opts.bits = 1;
|
||||
return 0; /* no symbols, but wait for decoding to report error */
|
||||
}
|
||||
for (min = 1; min < max; min++) {
|
||||
if (count[min] !== 0) { break; }
|
||||
}
|
||||
if (root < min) {
|
||||
root = min;
|
||||
}
|
||||
|
||||
/* check for an over-subscribed or incomplete set of lengths */
|
||||
left = 1;
|
||||
for (len = 1; len <= MAXBITS; len++) {
|
||||
left <<= 1;
|
||||
left -= count[len];
|
||||
if (left < 0) {
|
||||
return -1;
|
||||
} /* over-subscribed */
|
||||
}
|
||||
if (left > 0 && (type === CODES || max !== 1)) {
|
||||
return -1; /* incomplete set */
|
||||
}
|
||||
|
||||
/* generate offsets into symbol table for each length for sorting */
|
||||
offs[1] = 0;
|
||||
for (len = 1; len < MAXBITS; len++) {
|
||||
offs[len + 1] = offs[len] + count[len];
|
||||
}
|
||||
|
||||
/* sort symbols by length, by symbol order within each length */
|
||||
for (sym = 0; sym < codes; sym++) {
|
||||
if (lens[lens_index + sym] !== 0) {
|
||||
work[offs[lens[lens_index + sym]]++] = sym;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Create and fill in decoding tables. In this loop, the table being
|
||||
filled is at next and has curr index bits. The code being used is huff
|
||||
with length len. That code is converted to an index by dropping drop
|
||||
bits off of the bottom. For codes where len is less than drop + curr,
|
||||
those top drop + curr - len bits are incremented through all values to
|
||||
fill the table with replicated entries.
|
||||
|
||||
root is the number of index bits for the root table. When len exceeds
|
||||
root, sub-tables are created pointed to by the root entry with an index
|
||||
of the low root bits of huff. This is saved in low to check for when a
|
||||
new sub-table should be started. drop is zero when the root table is
|
||||
being filled, and drop is root when sub-tables are being filled.
|
||||
|
||||
When a new sub-table is needed, it is necessary to look ahead in the
|
||||
code lengths to determine what size sub-table is needed. The length
|
||||
counts are used for this, and so count[] is decremented as codes are
|
||||
entered in the tables.
|
||||
|
||||
used keeps track of how many table entries have been allocated from the
|
||||
provided *table space. It is checked for LENS and DIST tables against
|
||||
the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
|
||||
the initial root table size constants. See the comments in inftrees.h
|
||||
for more information.
|
||||
|
||||
sym increments through all symbols, and the loop terminates when
|
||||
all codes of length max, i.e. all codes, have been processed. This
|
||||
routine permits incomplete codes, so another loop after this one fills
|
||||
in the rest of the decoding tables with invalid code markers.
|
||||
*/
|
||||
|
||||
/* set up for code type */
|
||||
// poor man optimization - use if-else instead of switch,
|
||||
// to avoid deopts in old v8
|
||||
if (type === CODES) {
|
||||
base = extra = work; /* dummy value--not used */
|
||||
end = 19;
|
||||
|
||||
} else if (type === LENS) {
|
||||
base = lbase;
|
||||
base_index -= 257;
|
||||
extra = lext;
|
||||
extra_index -= 257;
|
||||
end = 256;
|
||||
|
||||
} else { /* DISTS */
|
||||
base = dbase;
|
||||
extra = dext;
|
||||
end = -1;
|
||||
}
|
||||
|
||||
/* initialize opts for loop */
|
||||
huff = 0; /* starting code */
|
||||
sym = 0; /* starting code symbol */
|
||||
len = min; /* starting code length */
|
||||
next = table_index; /* current table to fill in */
|
||||
curr = root; /* current table index bits */
|
||||
drop = 0; /* current bits to drop from code for index */
|
||||
low = -1; /* trigger new sub-table when len > root */
|
||||
used = 1 << root; /* use root table entries */
|
||||
mask = used - 1; /* mask for comparing low */
|
||||
|
||||
/* check available table space */
|
||||
if ((type === LENS && used > ENOUGH_LENS) ||
|
||||
(type === DISTS && used > ENOUGH_DISTS)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
var i = 0;
|
||||
/* process all codes and make table entries */
|
||||
for (;;) {
|
||||
i++;
|
||||
/* create table entry */
|
||||
here_bits = len - drop;
|
||||
if (work[sym] < end) {
|
||||
here_op = 0;
|
||||
here_val = work[sym];
|
||||
}
|
||||
else if (work[sym] > end) {
|
||||
here_op = extra[extra_index + work[sym]];
|
||||
here_val = base[base_index + work[sym]];
|
||||
}
|
||||
else {
|
||||
here_op = 32 + 64; /* end of block */
|
||||
here_val = 0;
|
||||
}
|
||||
|
||||
/* replicate for those indices with low len bits equal to huff */
|
||||
incr = 1 << (len - drop);
|
||||
fill = 1 << curr;
|
||||
min = fill; /* save offset to next table */
|
||||
do {
|
||||
fill -= incr;
|
||||
table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;
|
||||
} while (fill !== 0);
|
||||
|
||||
/* backwards increment the len-bit code huff */
|
||||
incr = 1 << (len - 1);
|
||||
while (huff & incr) {
|
||||
incr >>= 1;
|
||||
}
|
||||
if (incr !== 0) {
|
||||
huff &= incr - 1;
|
||||
huff += incr;
|
||||
} else {
|
||||
huff = 0;
|
||||
}
|
||||
|
||||
/* go to next symbol, update count, len */
|
||||
sym++;
|
||||
if (--count[len] === 0) {
|
||||
if (len === max) { break; }
|
||||
len = lens[lens_index + work[sym]];
|
||||
}
|
||||
|
||||
/* create new sub-table if needed */
|
||||
if (len > root && (huff & mask) !== low) {
|
||||
/* if first time, transition to sub-tables */
|
||||
if (drop === 0) {
|
||||
drop = root;
|
||||
}
|
||||
|
||||
/* increment past last table */
|
||||
next += min; /* here min is 1 << curr */
|
||||
|
||||
/* determine length of next table */
|
||||
curr = len - drop;
|
||||
left = 1 << curr;
|
||||
while (curr + drop < max) {
|
||||
left -= count[curr + drop];
|
||||
if (left <= 0) { break; }
|
||||
curr++;
|
||||
left <<= 1;
|
||||
}
|
||||
|
||||
/* check for enough space */
|
||||
used += 1 << curr;
|
||||
if ((type === LENS && used > ENOUGH_LENS) ||
|
||||
(type === DISTS && used > ENOUGH_DISTS)) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* point entry in root table to sub-table */
|
||||
low = huff & mask;
|
||||
/*table.op[low] = curr;
|
||||
table.bits[low] = root;
|
||||
table.val[low] = next - opts.table_index;*/
|
||||
table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;
|
||||
}
|
||||
}
|
||||
|
||||
/* fill in remaining table entry if code is incomplete (guaranteed to have
|
||||
at most one remaining entry, since if the code is incomplete, the
|
||||
maximum code length that was allowed to get this far is one bit) */
|
||||
if (huff !== 0) {
|
||||
//table.op[next + huff] = 64; /* invalid code marker */
|
||||
//table.bits[next + huff] = len - drop;
|
||||
//table.val[next + huff] = 0;
|
||||
table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;
|
||||
}
|
||||
|
||||
/* set return parameters */
|
||||
//opts.table_index += used;
|
||||
opts.bits = root;
|
||||
return 0;
|
||||
};
|
13
node_modules/pako/lib/zlib/messages.js
generated
vendored
Normal file
13
node_modules/pako/lib/zlib/messages.js
generated
vendored
Normal file
|
@ -0,0 +1,13 @@
|
|||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
2: 'need dictionary', /* Z_NEED_DICT 2 */
|
||||
1: 'stream end', /* Z_STREAM_END 1 */
|
||||
0: '', /* Z_OK 0 */
|
||||
'-1': 'file error', /* Z_ERRNO (-1) */
|
||||
'-2': 'stream error', /* Z_STREAM_ERROR (-2) */
|
||||
'-3': 'data error', /* Z_DATA_ERROR (-3) */
|
||||
'-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */
|
||||
'-5': 'buffer error', /* Z_BUF_ERROR (-5) */
|
||||
'-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
|
||||
};
|
1202
node_modules/pako/lib/zlib/trees.js
generated
vendored
Normal file
1202
node_modules/pako/lib/zlib/trees.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
29
node_modules/pako/lib/zlib/zstream.js
generated
vendored
Normal file
29
node_modules/pako/lib/zlib/zstream.js
generated
vendored
Normal file
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
|
||||
function ZStream() {
|
||||
/* next input byte */
|
||||
this.input = null; // JS specific, because we have no pointers
|
||||
this.next_in = 0;
|
||||
/* number of bytes available at input */
|
||||
this.avail_in = 0;
|
||||
/* total number of input bytes read so far */
|
||||
this.total_in = 0;
|
||||
/* next output byte should be put there */
|
||||
this.output = null; // JS specific, because we have no pointers
|
||||
this.next_out = 0;
|
||||
/* remaining free space at output */
|
||||
this.avail_out = 0;
|
||||
/* total number of bytes output so far */
|
||||
this.total_out = 0;
|
||||
/* last error message, NULL if no error */
|
||||
this.msg = ''/*Z_NULL*/;
|
||||
/* not visible by applications */
|
||||
this.state = null;
|
||||
/* best guess about the data type: binary or text */
|
||||
this.data_type = 2/*Z_UNKNOWN*/;
|
||||
/* adler32 value of the uncompressed data */
|
||||
this.adler = 0;
|
||||
}
|
||||
|
||||
module.exports = ZStream;
|
77
node_modules/pako/package.json
generated
vendored
Normal file
77
node_modules/pako/package.json
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
"_from": "pako@~0.2.5",
|
||||
"_id": "pako@0.2.9",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU=",
|
||||
"_location": "/pako",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "pako@~0.2.5",
|
||||
"name": "pako",
|
||||
"escapedName": "pako",
|
||||
"rawSpec": "~0.2.5",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "~0.2.5"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/jszip"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
|
||||
"_shasum": "f3f7522f4ef782348da8161bad9ecfd51bf83a75",
|
||||
"_spec": "pako@~0.2.5",
|
||||
"_where": "C:\\Users\\ryuki\\TheDesk\\node_modules\\jszip",
|
||||
"bugs": {
|
||||
"url": "https://github.com/nodeca/pako/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Andrei Tuputcyn",
|
||||
"url": "https://github.com/andr83"
|
||||
},
|
||||
{
|
||||
"name": "Vitaly Puzrin",
|
||||
"url": "https://github.com/puzrin"
|
||||
}
|
||||
],
|
||||
"deprecated": false,
|
||||
"description": "zlib port to javascript - fast, modularized, with browser support",
|
||||
"devDependencies": {
|
||||
"ansi": "*",
|
||||
"async": "*",
|
||||
"benchmark": "*",
|
||||
"browserify": "*",
|
||||
"eslint": "^2.1.0",
|
||||
"eslint-plugin-nodeca": "~1.0.3",
|
||||
"grunt": "~0.4.4",
|
||||
"grunt-cli": "~0.1.13",
|
||||
"grunt-contrib-connect": "~0.9.0",
|
||||
"grunt-saucelabs": "~8.6.0",
|
||||
"istanbul": "*",
|
||||
"lodash": "*",
|
||||
"mocha": "1.21.5",
|
||||
"ndoc": "*",
|
||||
"uglify-js": "*"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"dist/",
|
||||
"lib/"
|
||||
],
|
||||
"homepage": "https://github.com/nodeca/pako",
|
||||
"keywords": [
|
||||
"zlib",
|
||||
"deflate",
|
||||
"inflate",
|
||||
"gzip"
|
||||
],
|
||||
"license": "MIT",
|
||||
"name": "pako",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/nodeca/pako.git"
|
||||
},
|
||||
"version": "0.2.9"
|
||||
}
|
18
package-lock.json
generated
18
package-lock.json
generated
|
@ -1,3 +1,19 @@
|
|||
{
|
||||
"lockfileVersion": 1
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"jszip": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/jszip/-/jszip-2.5.0.tgz",
|
||||
"integrity": "sha1-dET9hVHd8+XacZj+oMkbyDCMwnQ=",
|
||||
"requires": {
|
||||
"pako": "0.2.9"
|
||||
}
|
||||
},
|
||||
"pako": {
|
||||
"version": "0.2.9",
|
||||
"resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz",
|
||||
"integrity": "sha1-8/dSL073gjSNqBYbrZ7P1Rv4OnU="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user