提交 73711e23 编写于 作者: J junkunzhang

chore: add wx-wasm-sdk

上级 2207f740
module.exports = {"dst":"/Users/nebulaliu/Desktop/wechat08/webgl-min","dataPath":"/Users/nebulaliu/Documents/tgit/unity-wasm/SDKAdmin/Assets","useDXT5":false,"textureList":[{"path":"desttop%203.6d43fe29","width":128,"height":32,"astc":null},{"path":"desttop%201.3e66353f","width":128,"height":32,"astc":"8x8"},{"path":"desttop.f8798eb6","width":128,"height":32,"astc":"4x4"},{"path":"desttop%202.d4d200a5","width":128,"height":32,"astc":"6x6"}]}
\ No newline at end of file
fileFormatVersion: 2
guid: 9d7cd0d0ded094b7ba7d2ece84a4b04b
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
var AdmZip = require("adm-zip");
var fs = require("fs");
var Path = require("path");
if (process.argv.length < 4) {
console.error("need source path");
process.exit(-1);
}
var sourcePath = process.argv[2];
var distPath = process.argv[3];
var zip = new AdmZip();
zip.addLocalFile(sourcePath)
zip.writeZip(distPath)
fileFormatVersion: 2
guid: ff9b59496ea294c17a9b8c1514b4653d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 599d4159d35494759822717d09588b5e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
MIT License
Copyright (c) 2012 Another-D-Mention Software and other contributors
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.
fileFormatVersion: 2
guid: 0d066318b1c684453a7232490f041de5
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
# ADM-ZIP for NodeJS with added support for electron original-fs
ADM-ZIP is a pure JavaScript implementation for zip data compression for [NodeJS](https://nodejs.org/).
# Installation
With [npm](https://www.npmjs.com/) do:
$ npm install adm-zip
## What is it good for?
The library allows you to:
- decompress zip files directly to disk or in memory buffers
- compress files and store them to disk in .zip format or in compressed buffers
- update content of/add new/delete files from an existing .zip
# Dependencies
There are no other nodeJS libraries that ADM-ZIP is dependent of
# Examples
## Basic usage
```javascript
var AdmZip = require("adm-zip");
// reading archives
var zip = new AdmZip("./my_file.zip");
var zipEntries = zip.getEntries(); // an array of ZipEntry records
zipEntries.forEach(function (zipEntry) {
console.log(zipEntry.toString()); // outputs zip entries information
if (zipEntry.entryName == "my_file.txt") {
console.log(zipEntry.getData().toString("utf8"));
}
});
// outputs the content of some_folder/my_file.txt
console.log(zip.readAsText("some_folder/my_file.txt"));
// extracts the specified file to the specified location
zip.extractEntryTo(/*entry name*/ "some_folder/my_file.txt", /*target path*/ "/home/me/tempfolder", /*maintainEntryPath*/ false, /*overwrite*/ true);
// extracts everything
zip.extractAllTo(/*target path*/ "/home/me/zipcontent/", /*overwrite*/ true);
// creating archives
var zip = new AdmZip();
// add file directly
var content = "inner content of the file";
zip.addFile("test.txt", Buffer.from(content, "utf8"), "entry comment goes here");
// add local file
zip.addLocalFile("/home/me/some_picture.png");
// get everything as a buffer
var willSendthis = zip.toBuffer();
// or write everything to disk
zip.writeZip(/*target file name*/ "/home/me/files.zip");
// ... more examples in the wiki
```
For more detailed information please check out the [wiki](https://github.com/cthackers/adm-zip/wiki).
[![Build Status](https://travis-ci.org/cthackers/adm-zip.svg?branch=master)](https://travis-ci.org/cthackers/adm-zip)
fileFormatVersion: 2
guid: 037e857a9c4cf491e9d40008eff99c93
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 17ff91324c8214676b58cdf24cb370ca
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 33503299476c54508989084b732c1dfc
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
var Utils = require("../util"),
Constants = Utils.Constants;
/* The central directory file header */
module.exports = function () {
var _verMade = 20, // v2.0
_version = 10, // v1.0
_flags = 0,
_method = 0,
_time = 0,
_crc = 0,
_compressedSize = 0,
_size = 0,
_fnameLen = 0,
_extraLen = 0,
_comLen = 0,
_diskStart = 0,
_inattr = 0,
_attr = 0,
_offset = 0;
_verMade |= Utils.isWin ? 0x0a00 : 0x0300;
// Set EFS flag since filename and comment fields are all by default encoded using UTF-8.
// Without it file names may be corrupted for other apps when file names use unicode chars
_flags |= Constants.FLG_EFS;
var _dataHeader = {};
function setTime(val) {
val = new Date(val);
_time =
(((val.getFullYear() - 1980) & 0x7f) << 25) | // b09-16 years from 1980
((val.getMonth() + 1) << 21) | // b05-08 month
(val.getDate() << 16) | // b00-04 hour
// 2 bytes time
(val.getHours() << 11) | // b11-15 hour
(val.getMinutes() << 5) | // b05-10 minute
(val.getSeconds() >> 1); // b00-04 seconds divided by 2
}
setTime(+new Date());
return {
get made() {
return _verMade;
},
set made(val) {
_verMade = val;
},
get version() {
return _version;
},
set version(val) {
_version = val;
},
get flags() {
return _flags;
},
set flags(val) {
_flags = val;
},
get method() {
return _method;
},
set method(val) {
switch (val) {
case Constants.STORED:
this.version = 10;
case Constants.DEFLATED:
default:
this.version = 20;
}
_method = val;
},
get time() {
return new Date(((_time >> 25) & 0x7f) + 1980, ((_time >> 21) & 0x0f) - 1, (_time >> 16) & 0x1f, (_time >> 11) & 0x1f, (_time >> 5) & 0x3f, (_time & 0x1f) << 1);
},
set time(val) {
setTime(val);
},
get crc() {
return _crc;
},
set crc(val) {
_crc = Math.max(0, val) >>> 0;
},
get compressedSize() {
return _compressedSize;
},
set compressedSize(val) {
_compressedSize = Math.max(0, val) >>> 0;
},
get size() {
return _size;
},
set size(val) {
_size = Math.max(0, val) >>> 0;
},
get fileNameLength() {
return _fnameLen;
},
set fileNameLength(val) {
_fnameLen = val;
},
get extraLength() {
return _extraLen;
},
set extraLength(val) {
_extraLen = val;
},
get commentLength() {
return _comLen;
},
set commentLength(val) {
_comLen = val;
},
get diskNumStart() {
return _diskStart;
},
set diskNumStart(val) {
_diskStart = Math.max(0, val) >>> 0;
},
get inAttr() {
return _inattr;
},
set inAttr(val) {
_inattr = Math.max(0, val) >>> 0;
},
get attr() {
return _attr;
},
set attr(val) {
_attr = Math.max(0, val) >>> 0;
},
// get Unix file permissions
get fileAttr() {
return _attr ? (((_attr >>> 0) | 0) >> 16) & 0xfff : 0;
},
get offset() {
return _offset;
},
set offset(val) {
_offset = Math.max(0, val) >>> 0;
},
get encripted() {
return (_flags & 1) === 1;
},
get entryHeaderSize() {
return Constants.CENHDR + _fnameLen + _extraLen + _comLen;
},
get realDataOffset() {
return _offset + Constants.LOCHDR + _dataHeader.fnameLen + _dataHeader.extraLen;
},
get dataHeader() {
return _dataHeader;
},
loadDataHeaderFromBinary: function (/*Buffer*/ input) {
var data = input.slice(_offset, _offset + Constants.LOCHDR);
// 30 bytes and should start with "PK\003\004"
if (data.readUInt32LE(0) !== Constants.LOCSIG) {
throw new Error(Utils.Errors.INVALID_LOC);
}
_dataHeader = {
// version needed to extract
version: data.readUInt16LE(Constants.LOCVER),
// general purpose bit flag
flags: data.readUInt16LE(Constants.LOCFLG),
// compression method
method: data.readUInt16LE(Constants.LOCHOW),
// modification time (2 bytes time, 2 bytes date)
time: data.readUInt32LE(Constants.LOCTIM),
// uncompressed file crc-32 value
crc: data.readUInt32LE(Constants.LOCCRC),
// compressed size
compressedSize: data.readUInt32LE(Constants.LOCSIZ),
// uncompressed size
size: data.readUInt32LE(Constants.LOCLEN),
// filename length
fnameLen: data.readUInt16LE(Constants.LOCNAM),
// extra field length
extraLen: data.readUInt16LE(Constants.LOCEXT)
};
},
loadFromBinary: function (/*Buffer*/ data) {
// data should be 46 bytes and start with "PK 01 02"
if (data.length !== Constants.CENHDR || data.readUInt32LE(0) !== Constants.CENSIG) {
throw new Error(Utils.Errors.INVALID_CEN);
}
// version made by
_verMade = data.readUInt16LE(Constants.CENVEM);
// version needed to extract
_version = data.readUInt16LE(Constants.CENVER);
// encrypt, decrypt flags
_flags = data.readUInt16LE(Constants.CENFLG);
// compression method
_method = data.readUInt16LE(Constants.CENHOW);
// modification time (2 bytes time, 2 bytes date)
_time = data.readUInt32LE(Constants.CENTIM);
// uncompressed file crc-32 value
_crc = data.readUInt32LE(Constants.CENCRC);
// compressed size
_compressedSize = data.readUInt32LE(Constants.CENSIZ);
// uncompressed size
_size = data.readUInt32LE(Constants.CENLEN);
// filename length
_fnameLen = data.readUInt16LE(Constants.CENNAM);
// extra field length
_extraLen = data.readUInt16LE(Constants.CENEXT);
// file comment length
_comLen = data.readUInt16LE(Constants.CENCOM);
// volume number start
_diskStart = data.readUInt16LE(Constants.CENDSK);
// internal file attributes
_inattr = data.readUInt16LE(Constants.CENATT);
// external file attributes
_attr = data.readUInt32LE(Constants.CENATX);
// LOC header offset
_offset = data.readUInt32LE(Constants.CENOFF);
},
dataHeaderToBinary: function () {
// LOC header size (30 bytes)
var data = Buffer.alloc(Constants.LOCHDR);
// "PK\003\004"
data.writeUInt32LE(Constants.LOCSIG, 0);
// version needed to extract
data.writeUInt16LE(_version, Constants.LOCVER);
// general purpose bit flag
data.writeUInt16LE(_flags, Constants.LOCFLG);
// compression method
data.writeUInt16LE(_method, Constants.LOCHOW);
// modification time (2 bytes time, 2 bytes date)
data.writeUInt32LE(_time, Constants.LOCTIM);
// uncompressed file crc-32 value
data.writeUInt32LE(_crc, Constants.LOCCRC);
// compressed size
data.writeUInt32LE(_compressedSize, Constants.LOCSIZ);
// uncompressed size
data.writeUInt32LE(_size, Constants.LOCLEN);
// filename length
data.writeUInt16LE(_fnameLen, Constants.LOCNAM);
// extra field length
data.writeUInt16LE(_extraLen, Constants.LOCEXT);
return data;
},
entryHeaderToBinary: function () {
// CEN header size (46 bytes)
var data = Buffer.alloc(Constants.CENHDR + _fnameLen + _extraLen + _comLen);
// "PK\001\002"
data.writeUInt32LE(Constants.CENSIG, 0);
// version made by
data.writeUInt16LE(_verMade, Constants.CENVEM);
// version needed to extract
data.writeUInt16LE(_version, Constants.CENVER);
// encrypt, decrypt flags
data.writeUInt16LE(_flags, Constants.CENFLG);
// compression method
data.writeUInt16LE(_method, Constants.CENHOW);
// modification time (2 bytes time, 2 bytes date)
data.writeUInt32LE(_time, Constants.CENTIM);
// uncompressed file crc-32 value
data.writeUInt32LE(_crc, Constants.CENCRC);
// compressed size
data.writeUInt32LE(_compressedSize, Constants.CENSIZ);
// uncompressed size
data.writeUInt32LE(_size, Constants.CENLEN);
// filename length
data.writeUInt16LE(_fnameLen, Constants.CENNAM);
// extra field length
data.writeUInt16LE(_extraLen, Constants.CENEXT);
// file comment length
data.writeUInt16LE(_comLen, Constants.CENCOM);
// volume number start
data.writeUInt16LE(_diskStart, Constants.CENDSK);
// internal file attributes
data.writeUInt16LE(_inattr, Constants.CENATT);
// external file attributes
data.writeUInt32LE(_attr, Constants.CENATX);
// LOC header offset
data.writeUInt32LE(_offset, Constants.CENOFF);
// fill all with
data.fill(0x00, Constants.CENHDR);
return data;
},
toJSON: function () {
const bytes = function (nr) {
return nr + " bytes";
};
return {
made: _verMade,
version: _version,
flags: _flags,
method: Utils.methodToString(_method),
time: this.time,
crc: "0x" + _crc.toString(16).toUpperCase(),
compressedSize: bytes(_compressedSize),
size: bytes(_size),
fileNameLength: bytes(_fnameLen),
extraLength: bytes(_extraLen),
commentLength: bytes(_comLen),
diskNumStart: _diskStart,
inAttr: _inattr,
attr: _attr,
offset: _offset,
entryHeaderSize: bytes(Constants.CENHDR + _fnameLen + _extraLen + _comLen)
};
},
toString: function () {
return JSON.stringify(this.toJSON(), null, "\t");
}
};
};
fileFormatVersion: 2
guid: e4b79ad927e90448b9c00ae190077cfd
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
exports.EntryHeader = require("./entryHeader");
exports.MainHeader = require("./mainHeader");
fileFormatVersion: 2
guid: 36454c64f3dda4031998672d5d2cc71f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
var Utils = require("../util"),
Constants = Utils.Constants;
/* The entries in the end of central directory */
module.exports = function () {
var _volumeEntries = 0,
_totalEntries = 0,
_size = 0,
_offset = 0,
_commentLength = 0;
return {
get diskEntries() {
return _volumeEntries;
},
set diskEntries(/*Number*/ val) {
_volumeEntries = _totalEntries = val;
},
get totalEntries() {
return _totalEntries;
},
set totalEntries(/*Number*/ val) {
_totalEntries = _volumeEntries = val;
},
get size() {
return _size;
},
set size(/*Number*/ val) {
_size = val;
},
get offset() {
return _offset;
},
set offset(/*Number*/ val) {
_offset = val;
},
get commentLength() {
return _commentLength;
},
set commentLength(/*Number*/ val) {
_commentLength = val;
},
get mainHeaderSize() {
return Constants.ENDHDR + _commentLength;
},
loadFromBinary: function (/*Buffer*/ data) {
// data should be 22 bytes and start with "PK 05 06"
// or be 56+ bytes and start with "PK 06 06" for Zip64
if (
(data.length !== Constants.ENDHDR || data.readUInt32LE(0) !== Constants.ENDSIG) &&
(data.length < Constants.ZIP64HDR || data.readUInt32LE(0) !== Constants.ZIP64SIG)
) {
throw new Error(Utils.Errors.INVALID_END);
}
if (data.readUInt32LE(0) === Constants.ENDSIG) {
// number of entries on this volume
_volumeEntries = data.readUInt16LE(Constants.ENDSUB);
// total number of entries
_totalEntries = data.readUInt16LE(Constants.ENDTOT);
// central directory size in bytes
_size = data.readUInt32LE(Constants.ENDSIZ);
// offset of first CEN header
_offset = data.readUInt32LE(Constants.ENDOFF);
// zip file comment length
_commentLength = data.readUInt16LE(Constants.ENDCOM);
} else {
// number of entries on this volume
_volumeEntries = Utils.readBigUInt64LE(data, Constants.ZIP64SUB);
// total number of entries
_totalEntries = Utils.readBigUInt64LE(data, Constants.ZIP64TOT);
// central directory size in bytes
_size = Utils.readBigUInt64LE(data, Constants.ZIP64SIZ);
// offset of first CEN header
_offset = Utils.readBigUInt64LE(data, Constants.ZIP64OFF);
_commentLength = 0;
}
},
toBinary: function () {
var b = Buffer.alloc(Constants.ENDHDR + _commentLength);
// "PK 05 06" signature
b.writeUInt32LE(Constants.ENDSIG, 0);
b.writeUInt32LE(0, 4);
// number of entries on this volume
b.writeUInt16LE(_volumeEntries, Constants.ENDSUB);
// total number of entries
b.writeUInt16LE(_totalEntries, Constants.ENDTOT);
// central directory size in bytes
b.writeUInt32LE(_size, Constants.ENDSIZ);
// offset of first CEN header
b.writeUInt32LE(_offset, Constants.ENDOFF);
// zip file comment length
b.writeUInt16LE(_commentLength, Constants.ENDCOM);
// fill comment memory with spaces so no garbage is left there
b.fill(" ", Constants.ENDHDR);
return b;
},
toJSON: function () {
// creates 0x0000 style output
const offset = function (nr, len) {
let offs = nr.toString(16).toUpperCase();
while (offs.length < len) offs = "0" + offs;
return "0x" + offs;
};
return {
diskEntries: _volumeEntries,
totalEntries: _totalEntries,
size: _size + " bytes",
offset: offset(_offset, 4),
commentLength: _commentLength
};
},
toString: function () {
return JSON.stringify(this.toJSON(), null, "\t");
}
};
};
fileFormatVersion: 2
guid: d6fbf84c8aa2a46a482abfbbd7abf82a
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: bf4ef2f6260524f40b29f368e83b7aed
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
module.exports = function (/*Buffer*/ inbuf) {
var zlib = require("zlib");
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
return {
deflate: function () {
return zlib.deflateRawSync(inbuf, opts);
},
deflateAsync: function (/*Function*/ callback) {
var tmp = zlib.createDeflateRaw(opts),
parts = [],
total = 0;
tmp.on("data", function (data) {
parts.push(data);
total += data.length;
});
tmp.on("end", function () {
var buf = Buffer.alloc(total),
written = 0;
buf.fill(0);
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
part.copy(buf, written);
written += part.length;
}
callback && callback(buf);
});
tmp.end(inbuf);
}
};
};
fileFormatVersion: 2
guid: 8feeccfc3e8d54f6084c94b58e6b771c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
exports.Deflater = require("./deflater");
exports.Inflater = require("./inflater");
exports.ZipCrypto = require("./zipcrypto");
fileFormatVersion: 2
guid: b2afdb29ddb404ce6ae99893ec82501d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
module.exports = function (/*Buffer*/ inbuf) {
var zlib = require("zlib");
return {
inflate: function () {
return zlib.inflateRawSync(inbuf);
},
inflateAsync: function (/*Function*/ callback) {
var tmp = zlib.createInflateRaw(),
parts = [],
total = 0;
tmp.on("data", function (data) {
parts.push(data);
total += data.length;
});
tmp.on("end", function () {
var buf = Buffer.alloc(total),
written = 0;
buf.fill(0);
for (var i = 0; i < parts.length; i++) {
var part = parts[i];
part.copy(buf, written);
written += part.length;
}
callback && callback(buf);
});
tmp.end(inbuf);
}
};
};
fileFormatVersion: 2
guid: 82821624f639b402aa12bffe17b43a48
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
"use strict";
// node crypt, we use it for generate salt
// eslint-disable-next-line node/no-unsupported-features/node-builtins
const { randomFillSync } = require("crypto");
// generate CRC32 lookup table
const crctable = new Uint32Array(256).map((t, crc) => {
for (let j = 0; j < 8; j++) {
if (0 !== (crc & 1)) {
crc = (crc >>> 1) ^ 0xedb88320;
} else {
crc >>>= 1;
}
}
return crc >>> 0;
});
// C-style uInt32 Multiply (discards higher bits, when JS multiply discards lower bits)
const uMul = (a, b) => Math.imul(a, b) >>> 0;
// crc32 byte single update (actually same function is part of utils.crc32 function :) )
const crc32update = (pCrc32, bval) => {
return crctable[(pCrc32 ^ bval) & 0xff] ^ (pCrc32 >>> 8);
};
// function for generating salt for encrytion header
const genSalt = () => {
if ("function" === typeof randomFillSync) {
return randomFillSync(Buffer.alloc(12));
} else {
// fallback if function is not defined
return genSalt.node();
}
};
// salt generation with node random function (mainly as fallback)
genSalt.node = () => {
const salt = Buffer.alloc(12);
const len = salt.length;
for (let i = 0; i < len; i++) salt[i] = (Math.random() * 256) & 0xff;
return salt;
};
// general config
const config = {
genSalt
};
// Class Initkeys handles same basic ops with keys
function Initkeys(pw) {
const pass = Buffer.isBuffer(pw) ? pw : Buffer.from(pw);
this.keys = new Uint32Array([0x12345678, 0x23456789, 0x34567890]);
for (let i = 0; i < pass.length; i++) {
this.updateKeys(pass[i]);
}
}
Initkeys.prototype.updateKeys = function (byteValue) {
const keys = this.keys;
keys[0] = crc32update(keys[0], byteValue);
keys[1] += keys[0] & 0xff;
keys[1] = uMul(keys[1], 134775813) + 1;
keys[2] = crc32update(keys[2], keys[1] >>> 24);
return byteValue;
};
Initkeys.prototype.next = function () {
const k = (this.keys[2] | 2) >>> 0; // key
return (uMul(k, k ^ 1) >> 8) & 0xff; // decode
};
function make_decrypter(/*Buffer*/ pwd) {
// 1. Stage initialize key
const keys = new Initkeys(pwd);
// return decrypter function
return function (/*Buffer*/ data) {
// result - we create new Buffer for results
const result = Buffer.alloc(data.length);
let pos = 0;
// process input data
for (let c of data) {
//c ^= keys.next();
//result[pos++] = c; // decode & Save Value
result[pos++] = keys.updateKeys(c ^ keys.next()); // update keys with decoded byte
}
return result;
};
}
function make_encrypter(/*Buffer*/ pwd) {
// 1. Stage initialize key
const keys = new Initkeys(pwd);
// return encrypting function, result and pos is here so we dont have to merge buffers later
return function (/*Buffer*/ data, /*Buffer*/ result, /* Number */ pos = 0) {
// result - we create new Buffer for results
if (!result) result = Buffer.alloc(data.length);
// process input data
for (let c of data) {
const k = keys.next(); // save key byte
result[pos++] = c ^ k; // save val
keys.updateKeys(c); // update keys with decoded byte
}
return result;
};
}
function decrypt(/*Buffer*/ data, /*Object*/ header, /*String, Buffer*/ pwd) {
if (!data || !Buffer.isBuffer(data) || data.length < 12) {
return Buffer.alloc(0);
}
// 1. We Initialize and generate decrypting function
const decrypter = make_decrypter(pwd);
// 2. decrypt salt what is always 12 bytes and is a part of file content
const salt = decrypter(data.slice(0, 12));
// 3. does password meet expectations
if (salt[11] !== header.crc >>> 24) {
throw "ADM-ZIP: Wrong Password";
}
// 4. decode content
return decrypter(data.slice(12));
}
// lets add way to populate salt, NOT RECOMMENDED for production but maybe useful for testing general functionality
function _salter(data) {
if (Buffer.isBuffer(data) && data.length >= 12) {
// be aware - currently salting buffer data is modified
config.genSalt = function () {
return data.slice(0, 12);
};
} else if (data === "node") {
// test salt generation with node random function
config.genSalt = genSalt.node;
} else {
// if value is not acceptable config gets reset.
config.genSalt = genSalt;
}
}
function encrypt(/*Buffer*/ data, /*Object*/ header, /*String, Buffer*/ pwd, /*Boolean*/ oldlike = false) {
// 1. test data if data is not Buffer we make buffer from it
if (data == null) data = Buffer.alloc(0);
// if data is not buffer be make buffer from it
if (!Buffer.isBuffer(data)) data = Buffer.from(data.toString());
// 2. We Initialize and generate encrypting function
const encrypter = make_encrypter(pwd);
// 3. generate salt (12-bytes of random data)
const salt = config.genSalt();
salt[11] = (header.crc >>> 24) & 0xff;
// old implementations (before PKZip 2.04g) used two byte check
if (oldlike) salt[10] = (header.crc >>> 16) & 0xff;
// 4. create output
const result = Buffer.alloc(data.length + 12);
encrypter(salt, result);
// finally encode content
return encrypter(data, result, 12);
}
module.exports = { decrypt, encrypt, _salter };
fileFormatVersion: 2
guid: dddbecc39e7d9424a915f02b4d3cab4a
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
{
"name": "adm-zip",
"version": "0.5.9",
"description": "Javascript implementation of zip for nodejs with support for electron original-fs. Allows user to create or extract zip files both in memory or to/from disk",
"scripts": {
"test": "mocha -R spec",
"test:format": "npm run format:prettier:raw -- --check",
"format": "npm run format:prettier",
"format:prettier": "npm run format:prettier:raw -- --write",
"format:prettier:raw": "prettier \"**/*.{js,yml,json}\""
},
"keywords": [
"zip",
"methods",
"archive",
"unzip"
],
"homepage": "https://github.com/cthackers/adm-zip",
"author": "Nasca Iacob <sy@another-d-mention.ro> (https://github.com/cthackers)",
"bugs": {
"email": "sy@another-d-mention.ro",
"url": "https://github.com/cthackers/adm-zip/issues"
},
"license": "MIT",
"files": [
"adm-zip.js",
"headers",
"methods",
"util",
"zipEntry.js",
"zipFile.js",
"LICENSE"
],
"main": "adm-zip.js",
"repository": {
"type": "git",
"url": "https://github.com/cthackers/adm-zip.git"
},
"engines": {
"node": ">=6.0"
},
"devDependencies": {
"chai": "^4.3.4",
"mocha": "^8.3.2",
"prettier": "^2.2.1",
"rimraf": "^3.0.2"
}
}
fileFormatVersion: 2
guid: c5b1ddac1e8894364b0ef883cc221b8c
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: a7b948128a6b9474190a2142f0faa730
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
module.exports = {
/* The local file header */
LOCHDR : 30, // LOC header size
LOCSIG : 0x04034b50, // "PK\003\004"
LOCVER : 4, // version needed to extract
LOCFLG : 6, // general purpose bit flag
LOCHOW : 8, // compression method
LOCTIM : 10, // modification time (2 bytes time, 2 bytes date)
LOCCRC : 14, // uncompressed file crc-32 value
LOCSIZ : 18, // compressed size
LOCLEN : 22, // uncompressed size
LOCNAM : 26, // filename length
LOCEXT : 28, // extra field length
/* The Data descriptor */
EXTSIG : 0x08074b50, // "PK\007\008"
EXTHDR : 16, // EXT header size
EXTCRC : 4, // uncompressed file crc-32 value
EXTSIZ : 8, // compressed size
EXTLEN : 12, // uncompressed size
/* The central directory file header */
CENHDR : 46, // CEN header size
CENSIG : 0x02014b50, // "PK\001\002"
CENVEM : 4, // version made by
CENVER : 6, // version needed to extract
CENFLG : 8, // encrypt, decrypt flags
CENHOW : 10, // compression method
CENTIM : 12, // modification time (2 bytes time, 2 bytes date)
CENCRC : 16, // uncompressed file crc-32 value
CENSIZ : 20, // compressed size
CENLEN : 24, // uncompressed size
CENNAM : 28, // filename length
CENEXT : 30, // extra field length
CENCOM : 32, // file comment length
CENDSK : 34, // volume number start
CENATT : 36, // internal file attributes
CENATX : 38, // external file attributes (host system dependent)
CENOFF : 42, // LOC header offset
/* The entries in the end of central directory */
ENDHDR : 22, // END header size
ENDSIG : 0x06054b50, // "PK\005\006"
ENDSUB : 8, // number of entries on this disk
ENDTOT : 10, // total number of entries
ENDSIZ : 12, // central directory size in bytes
ENDOFF : 16, // offset of first CEN header
ENDCOM : 20, // zip file comment length
END64HDR : 20, // zip64 END header size
END64SIG : 0x07064b50, // zip64 Locator signature, "PK\006\007"
END64START : 4, // number of the disk with the start of the zip64
END64OFF : 8, // relative offset of the zip64 end of central directory
END64NUMDISKS : 16, // total number of disks
ZIP64SIG : 0x06064b50, // zip64 signature, "PK\006\006"
ZIP64HDR : 56, // zip64 record minimum size
ZIP64LEAD : 12, // leading bytes at the start of the record, not counted by the value stored in ZIP64SIZE
ZIP64SIZE : 4, // zip64 size of the central directory record
ZIP64VEM : 12, // zip64 version made by
ZIP64VER : 14, // zip64 version needed to extract
ZIP64DSK : 16, // zip64 number of this disk
ZIP64DSKDIR : 20, // number of the disk with the start of the record directory
ZIP64SUB : 24, // number of entries on this disk
ZIP64TOT : 32, // total number of entries
ZIP64SIZB : 40, // zip64 central directory size in bytes
ZIP64OFF : 48, // offset of start of central directory with respect to the starting disk number
ZIP64EXTRA : 56, // extensible data sector
/* Compression methods */
STORED : 0, // no compression
SHRUNK : 1, // shrunk
REDUCED1 : 2, // reduced with compression factor 1
REDUCED2 : 3, // reduced with compression factor 2
REDUCED3 : 4, // reduced with compression factor 3
REDUCED4 : 5, // reduced with compression factor 4
IMPLODED : 6, // imploded
// 7 reserved for Tokenizing compression algorithm
DEFLATED : 8, // deflated
ENHANCED_DEFLATED: 9, // enhanced deflated
PKWARE : 10,// PKWare DCL imploded
// 11 reserved by PKWARE
BZIP2 : 12, // compressed using BZIP2
// 13 reserved by PKWARE
LZMA : 14, // LZMA
// 15-17 reserved by PKWARE
IBM_TERSE : 18, // compressed using IBM TERSE
IBM_LZ77 : 19, // IBM LZ77 z
AES_ENCRYPT : 99, // WinZIP AES encryption method
/* General purpose bit flag */
// values can obtained with expression 2**bitnr
FLG_ENC : 1, // Bit 0: encrypted file
FLG_COMP1 : 2, // Bit 1, compression option
FLG_COMP2 : 4, // Bit 2, compression option
FLG_DESC : 8, // Bit 3, data descriptor
FLG_ENH : 16, // Bit 4, enhanced deflating
FLG_PATCH : 32, // Bit 5, indicates that the file is compressed patched data.
FLG_STR : 64, // Bit 6, strong encryption (patented)
// Bits 7-10: Currently unused.
FLG_EFS : 2048, // Bit 11: Language encoding flag (EFS)
// Bit 12: Reserved by PKWARE for enhanced compression.
// Bit 13: encrypted the Central Directory (patented).
// Bits 14-15: Reserved by PKWARE.
FLG_MSK : 4096, // mask header values
/* Load type */
FILE : 2,
BUFFER : 1,
NONE : 0,
/* 4.5 Extensible data fields */
EF_ID : 0,
EF_SIZE : 2,
/* Header IDs */
ID_ZIP64 : 0x0001,
ID_AVINFO : 0x0007,
ID_PFS : 0x0008,
ID_OS2 : 0x0009,
ID_NTFS : 0x000a,
ID_OPENVMS : 0x000c,
ID_UNIX : 0x000d,
ID_FORK : 0x000e,
ID_PATCH : 0x000f,
ID_X509_PKCS7 : 0x0014,
ID_X509_CERTID_F : 0x0015,
ID_X509_CERTID_C : 0x0016,
ID_STRONGENC : 0x0017,
ID_RECORD_MGT : 0x0018,
ID_X509_PKCS7_RL : 0x0019,
ID_IBM1 : 0x0065,
ID_IBM2 : 0x0066,
ID_POSZIP : 0x4690,
EF_ZIP64_OR_32 : 0xffffffff,
EF_ZIP64_OR_16 : 0xffff,
EF_ZIP64_SUNCOMP : 0,
EF_ZIP64_SCOMP : 8,
EF_ZIP64_RHO : 16,
EF_ZIP64_DSN : 24
};
fileFormatVersion: 2
guid: 0b1568b2422eb451aab6056fe707a0e1
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
module.exports = {
/* Header error messages */
INVALID_LOC: "Invalid LOC header (bad signature)",
INVALID_CEN: "Invalid CEN header (bad signature)",
INVALID_END: "Invalid END header (bad signature)",
/* ZipEntry error messages*/
NO_DATA: "Nothing to decompress",
BAD_CRC: "CRC32 checksum failed",
FILE_IN_THE_WAY: "There is a file in the way: %s",
UNKNOWN_METHOD: "Invalid/unsupported compression method",
/* Inflater error messages */
AVAIL_DATA: "inflate::Available inflate data did not terminate",
INVALID_DISTANCE: "inflate::Invalid literal/length or distance code in fixed or dynamic block",
TO_MANY_CODES: "inflate::Dynamic block code description: too many length or distance codes",
INVALID_REPEAT_LEN: "inflate::Dynamic block code description: repeat more than specified lengths",
INVALID_REPEAT_FIRST: "inflate::Dynamic block code description: repeat lengths with no first length",
INCOMPLETE_CODES: "inflate::Dynamic block code description: code lengths codes incomplete",
INVALID_DYN_DISTANCE: "inflate::Dynamic block code description: invalid distance code lengths",
INVALID_CODES_LEN: "inflate::Dynamic block code description: invalid literal/length code lengths",
INVALID_STORE_BLOCK: "inflate::Stored block length did not match one's complement",
INVALID_BLOCK_TYPE: "inflate::Invalid block type (type == 3)",
/* ADM-ZIP error messages */
CANT_EXTRACT_FILE: "Could not extract the file",
CANT_OVERRIDE: "Target file already exists",
NO_ZIP: "No zip file was loaded",
NO_ENTRY: "Entry doesn't exist",
DIRECTORY_CONTENT_ERROR: "A directory cannot have content",
FILE_NOT_FOUND: "File not found: %s",
NOT_IMPLEMENTED: "Not implemented",
INVALID_FILENAME: "Invalid filename",
INVALID_FORMAT: "Invalid or unsupported zip format. No END header found"
};
fileFormatVersion: 2
guid: 220f66be131e944348c75e91034383b6
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
const fs = require("./fileSystem").require();
const pth = require("path");
fs.existsSync = fs.existsSync || pth.existsSync;
module.exports = function (/*String*/ path) {
var _path = path || "",
_obj = newAttr(),
_stat = null;
function newAttr() {
return {
directory: false,
readonly: false,
hidden: false,
executable: false,
mtime: 0,
atime: 0
};
}
if (_path && fs.existsSync(_path)) {
_stat = fs.statSync(_path);
_obj.directory = _stat.isDirectory();
_obj.mtime = _stat.mtime;
_obj.atime = _stat.atime;
_obj.executable = (0o111 & _stat.mode) !== 0; // file is executable who ever har right not just owner
_obj.readonly = (0o200 & _stat.mode) === 0; // readonly if owner has no write right
_obj.hidden = pth.basename(_path)[0] === ".";
} else {
console.warn("Invalid path: " + _path);
}
return {
get directory() {
return _obj.directory;
},
get readOnly() {
return _obj.readonly;
},
get hidden() {
return _obj.hidden;
},
get mtime() {
return _obj.mtime;
},
get atime() {
return _obj.atime;
},
get executable() {
return _obj.executable;
},
decodeAttributes: function () {},
encodeAttributes: function () {},
toJSON: function () {
return {
path: _path,
isDirectory: _obj.directory,
isReadOnly: _obj.readonly,
isHidden: _obj.hidden,
isExecutable: _obj.executable,
mTime: _obj.mtime,
aTime: _obj.atime
};
},
toString: function () {
return JSON.stringify(this.toJSON(), null, "\t");
}
};
};
fileFormatVersion: 2
guid: 9b56312359af44ba89c45ef2c453b32d
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
exports.require = function () {
if (typeof process === "object" && process.versions && process.versions["electron"]) {
try {
const originalFs = require("original-fs");
if (Object.keys(originalFs).length > 0) {
return originalFs;
}
} catch (e) {}
}
return require("fs");
};
fileFormatVersion: 2
guid: 62cfbe4ffa5ff4e388c3795d86a9cf71
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
module.exports = require("./utils");
module.exports.Constants = require("./constants");
module.exports.Errors = require("./errors");
module.exports.FileAttr = require("./fattr");
fileFormatVersion: 2
guid: cc61925ffee27474b969e2aa4efd0254
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
const fsystem = require("./fileSystem").require();
const pth = require("path");
const Constants = require("./constants");
const isWin = typeof process === "object" && "win32" === process.platform;
const is_Obj = (obj) => obj && typeof obj === "object";
// generate CRC32 lookup table
const crcTable = new Uint32Array(256).map((t, c) => {
for (let k = 0; k < 8; k++) {
if ((c & 1) !== 0) {
c = 0xedb88320 ^ (c >>> 1);
} else {
c >>>= 1;
}
}
return c >>> 0;
});
// UTILS functions
function Utils(opts) {
this.sep = pth.sep;
this.fs = fsystem;
if (is_Obj(opts)) {
// custom filesystem
if (is_Obj(opts.fs) && typeof opts.fs.statSync === "function") {
this.fs = opts.fs;
}
}
}
module.exports = Utils;
// INSTANCED functions
Utils.prototype.makeDir = function (/*String*/ folder) {
const self = this;
// Sync - make directories tree
function mkdirSync(/*String*/ fpath) {
let resolvedPath = fpath.split(self.sep)[0];
fpath.split(self.sep).forEach(function (name) {
if (!name || name.substr(-1, 1) === ":") return;
resolvedPath += self.sep + name;
var stat;
try {
stat = self.fs.statSync(resolvedPath);
} catch (e) {
self.fs.mkdirSync(resolvedPath);
}
if (stat && stat.isFile()) throw Errors.FILE_IN_THE_WAY.replace("%s", resolvedPath);
});
}
mkdirSync(folder);
};
Utils.prototype.writeFileTo = function (/*String*/ path, /*Buffer*/ content, /*Boolean*/ overwrite, /*Number*/ attr) {
const self = this;
if (self.fs.existsSync(path)) {
if (!overwrite) return false; // cannot overwrite
var stat = self.fs.statSync(path);
if (stat.isDirectory()) {
return false;
}
}
var folder = pth.dirname(path);
if (!self.fs.existsSync(folder)) {
self.makeDir(folder);
}
var fd;
try {
fd = self.fs.openSync(path, "w", 438); // 0666
} catch (e) {
self.fs.chmodSync(path, 438);
fd = self.fs.openSync(path, "w", 438);
}
if (fd) {
try {
self.fs.writeSync(fd, content, 0, content.length, 0);
} finally {
self.fs.closeSync(fd);
}
}
self.fs.chmodSync(path, attr || 438);
return true;
};
Utils.prototype.writeFileToAsync = function (/*String*/ path, /*Buffer*/ content, /*Boolean*/ overwrite, /*Number*/ attr, /*Function*/ callback) {
if (typeof attr === "function") {
callback = attr;
attr = undefined;
}
const self = this;
self.fs.exists(path, function (exist) {
if (exist && !overwrite) return callback(false);
self.fs.stat(path, function (err, stat) {
if (exist && stat.isDirectory()) {
return callback(false);
}
var folder = pth.dirname(path);
self.fs.exists(folder, function (exists) {
if (!exists) self.makeDir(folder);
self.fs.open(path, "w", 438, function (err, fd) {
if (err) {
self.fs.chmod(path, 438, function () {
self.fs.open(path, "w", 438, function (err, fd) {
self.fs.write(fd, content, 0, content.length, 0, function () {
self.fs.close(fd, function () {
self.fs.chmod(path, attr || 438, function () {
callback(true);
});
});
});
});
});
} else if (fd) {
self.fs.write(fd, content, 0, content.length, 0, function () {
self.fs.close(fd, function () {
self.fs.chmod(path, attr || 438, function () {
callback(true);
});
});
});
} else {
self.fs.chmod(path, attr || 438, function () {
callback(true);
});
}
});
});
});
});
};
Utils.prototype.findFiles = function (/*String*/ path) {
const self = this;
function findSync(/*String*/ dir, /*RegExp*/ pattern, /*Boolean*/ recursive) {
if (typeof pattern === "boolean") {
recursive = pattern;
pattern = undefined;
}
let files = [];
self.fs.readdirSync(dir).forEach(function (file) {
var path = pth.join(dir, file);
if (self.fs.statSync(path).isDirectory() && recursive) files = files.concat(findSync(path, pattern, recursive));
if (!pattern || pattern.test(path)) {
files.push(pth.normalize(path) + (self.fs.statSync(path).isDirectory() ? self.sep : ""));
}
});
return files;
}
return findSync(path, undefined, true);
};
Utils.prototype.getAttributes = function () {};
Utils.prototype.setAttributes = function () {};
// STATIC functions
// crc32 single update (it is part of crc32)
Utils.crc32update = function (crc, byte) {
return crcTable[(crc ^ byte) & 0xff] ^ (crc >>> 8);
};
Utils.crc32 = function (buf) {
if (typeof buf === "string") {
buf = Buffer.from(buf, "utf8");
}
// Generate crcTable
if (!crcTable.length) genCRCTable();
let len = buf.length;
let crc = ~0;
for (let off = 0; off < len; ) crc = Utils.crc32update(crc, buf[off++]);
// xor and cast as uint32 number
return ~crc >>> 0;
};
Utils.methodToString = function (/*Number*/ method) {
switch (method) {
case Constants.STORED:
return "STORED (" + method + ")";
case Constants.DEFLATED:
return "DEFLATED (" + method + ")";
default:
return "UNSUPPORTED (" + method + ")";
}
};
// removes ".." style path elements
Utils.canonical = function (/*string*/ path) {
if (!path) return "";
// trick normalize think path is absolute
var safeSuffix = pth.posix.normalize("/" + path.split("\\").join("/"));
return pth.join(".", safeSuffix);
};
// make abolute paths taking prefix as root folder
Utils.sanitize = function (/*string*/ prefix, /*string*/ name) {
prefix = pth.resolve(pth.normalize(prefix));
var parts = name.split("/");
for (var i = 0, l = parts.length; i < l; i++) {
var path = pth.normalize(pth.join(prefix, parts.slice(i, l).join(pth.sep)));
if (path.indexOf(prefix) === 0) {
return path;
}
}
return pth.normalize(pth.join(prefix, pth.basename(name)));
};
// converts buffer, Uint8Array, string types to buffer
Utils.toBuffer = function toBuffer(/*buffer, Uint8Array, string*/ input) {
if (Buffer.isBuffer(input)) {
return input;
} else if (input instanceof Uint8Array) {
return Buffer.from(input);
} else {
// expect string all other values are invalid and return empty buffer
return typeof input === "string" ? Buffer.from(input, "utf8") : Buffer.alloc(0);
}
};
Utils.readBigUInt64LE = function (/*Buffer*/ buffer, /*int*/ index) {
var slice = Buffer.from(buffer.slice(index, index + 8));
slice.swap64();
return parseInt(`0x${slice.toString("hex")}`);
};
Utils.isWin = isWin; // Do we have windows system
Utils.crcTable = crcTable;
fileFormatVersion: 2
guid: 245b94df6bfcb4e049248d336d5f6ee7
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
var Utils = require("./util"),
Headers = require("./headers"),
Constants = Utils.Constants,
Methods = require("./methods");
module.exports = function (/*Buffer*/ input) {
var _entryHeader = new Headers.EntryHeader(),
_entryName = Buffer.alloc(0),
_comment = Buffer.alloc(0),
_isDirectory = false,
uncompressedData = null,
_extra = Buffer.alloc(0);
function getCompressedDataFromZip() {
if (!input || !Buffer.isBuffer(input)) {
return Buffer.alloc(0);
}
_entryHeader.loadDataHeaderFromBinary(input);
return input.slice(_entryHeader.realDataOffset, _entryHeader.realDataOffset + _entryHeader.compressedSize);
}
function crc32OK(data) {
// if bit 3 (0x08) of the general-purpose flags field is set, then the CRC-32 and file sizes are not known when the header is written
if ((_entryHeader.flags & 0x8) !== 0x8) {
if (Utils.crc32(data) !== _entryHeader.dataHeader.crc) {
return false;
}
} else {
// @TODO: load and check data descriptor header
// The fields in the local header are filled with zero, and the CRC-32 and size are appended in a 12-byte structure
// (optionally preceded by a 4-byte signature) immediately after the compressed data:
}
return true;
}
function decompress(/*Boolean*/ async, /*Function*/ callback, /*String, Buffer*/ pass) {
if (typeof callback === "undefined" && typeof async === "string") {
pass = async;
async = void 0;
}
if (_isDirectory) {
if (async && callback) {
callback(Buffer.alloc(0), Utils.Errors.DIRECTORY_CONTENT_ERROR); //si added error.
}
return Buffer.alloc(0);
}
var compressedData = getCompressedDataFromZip();
if (compressedData.length === 0) {
// File is empty, nothing to decompress.
if (async && callback) callback(compressedData);
return compressedData;
}
if (_entryHeader.encripted) {
if ("string" !== typeof pass && !Buffer.isBuffer(pass)) {
throw new Error("ADM-ZIP: Incompatible password parameter");
}
compressedData = Methods.ZipCrypto.decrypt(compressedData, _entryHeader, pass);
}
var data = Buffer.alloc(_entryHeader.size);
switch (_entryHeader.method) {
case Utils.Constants.STORED:
compressedData.copy(data);
if (!crc32OK(data)) {
if (async && callback) callback(data, Utils.Errors.BAD_CRC); //si added error
throw new Error(Utils.Errors.BAD_CRC);
} else {
//si added otherwise did not seem to return data.
if (async && callback) callback(data);
return data;
}
case Utils.Constants.DEFLATED:
var inflater = new Methods.Inflater(compressedData);
if (!async) {
const result = inflater.inflate(data);
result.copy(data, 0);
if (!crc32OK(data)) {
throw new Error(Utils.Errors.BAD_CRC + " " + _entryName.toString());
}
return data;
} else {
inflater.inflateAsync(function (result) {
result.copy(result, 0);
if (callback) {
if (!crc32OK(result)) {
callback(result, Utils.Errors.BAD_CRC); //si added error
} else {
callback(result);
}
}
});
}
break;
default:
if (async && callback) callback(Buffer.alloc(0), Utils.Errors.UNKNOWN_METHOD);
throw new Error(Utils.Errors.UNKNOWN_METHOD);
}
}
function compress(/*Boolean*/ async, /*Function*/ callback) {
if ((!uncompressedData || !uncompressedData.length) && Buffer.isBuffer(input)) {
// no data set or the data wasn't changed to require recompression
if (async && callback) callback(getCompressedDataFromZip());
return getCompressedDataFromZip();
}
if (uncompressedData.length && !_isDirectory) {
var compressedData;
// Local file header
switch (_entryHeader.method) {
case Utils.Constants.STORED:
_entryHeader.compressedSize = _entryHeader.size;
compressedData = Buffer.alloc(uncompressedData.length);
uncompressedData.copy(compressedData);
if (async && callback) callback(compressedData);
return compressedData;
default:
case Utils.Constants.DEFLATED:
var deflater = new Methods.Deflater(uncompressedData);
if (!async) {
var deflated = deflater.deflate();
_entryHeader.compressedSize = deflated.length;
return deflated;
} else {
deflater.deflateAsync(function (data) {
compressedData = Buffer.alloc(data.length);
_entryHeader.compressedSize = data.length;
data.copy(compressedData);
callback && callback(compressedData);
});
}
deflater = null;
break;
}
} else if (async && callback) {
callback(Buffer.alloc(0));
} else {
return Buffer.alloc(0);
}
}
function readUInt64LE(buffer, offset) {
return (buffer.readUInt32LE(offset + 4) << 4) + buffer.readUInt32LE(offset);
}
function parseExtra(data) {
var offset = 0;
var signature, size, part;
while (offset < data.length) {
signature = data.readUInt16LE(offset);
offset += 2;
size = data.readUInt16LE(offset);
offset += 2;
part = data.slice(offset, offset + size);
offset += size;
if (Constants.ID_ZIP64 === signature) {
parseZip64ExtendedInformation(part);
}
}
}
//Override header field values with values from the ZIP64 extra field
function parseZip64ExtendedInformation(data) {
var size, compressedSize, offset, diskNumStart;
if (data.length >= Constants.EF_ZIP64_SCOMP) {
size = readUInt64LE(data, Constants.EF_ZIP64_SUNCOMP);
if (_entryHeader.size === Constants.EF_ZIP64_OR_32) {
_entryHeader.size = size;
}
}
if (data.length >= Constants.EF_ZIP64_RHO) {
compressedSize = readUInt64LE(data, Constants.EF_ZIP64_SCOMP);
if (_entryHeader.compressedSize === Constants.EF_ZIP64_OR_32) {
_entryHeader.compressedSize = compressedSize;
}
}
if (data.length >= Constants.EF_ZIP64_DSN) {
offset = readUInt64LE(data, Constants.EF_ZIP64_RHO);
if (_entryHeader.offset === Constants.EF_ZIP64_OR_32) {
_entryHeader.offset = offset;
}
}
if (data.length >= Constants.EF_ZIP64_DSN + 4) {
diskNumStart = data.readUInt32LE(Constants.EF_ZIP64_DSN);
if (_entryHeader.diskNumStart === Constants.EF_ZIP64_OR_16) {
_entryHeader.diskNumStart = diskNumStart;
}
}
}
return {
get entryName() {
return _entryName.toString();
},
get rawEntryName() {
return _entryName;
},
set entryName(val) {
_entryName = Utils.toBuffer(val);
var lastChar = _entryName[_entryName.length - 1];
_isDirectory = lastChar === 47 || lastChar === 92;
_entryHeader.fileNameLength = _entryName.length;
},
get extra() {
return _extra;
},
set extra(val) {
_extra = val;
_entryHeader.extraLength = val.length;
parseExtra(val);
},
get comment() {
return _comment.toString();
},
set comment(val) {
_comment = Utils.toBuffer(val);
_entryHeader.commentLength = _comment.length;
},
get name() {
var n = _entryName.toString();
return _isDirectory
? n
.substr(n.length - 1)
.split("/")
.pop()
: n.split("/").pop();
},
get isDirectory() {
return _isDirectory;
},
getCompressedData: function () {
return compress(false, null);
},
getCompressedDataAsync: function (/*Function*/ callback) {
compress(true, callback);
},
setData: function (value) {
uncompressedData = Utils.toBuffer(value);
if (!_isDirectory && uncompressedData.length) {
_entryHeader.size = uncompressedData.length;
_entryHeader.method = Utils.Constants.DEFLATED;
_entryHeader.crc = Utils.crc32(value);
_entryHeader.changed = true;
} else {
// folders and blank files should be stored
_entryHeader.method = Utils.Constants.STORED;
}
},
getData: function (pass) {
if (_entryHeader.changed) {
return uncompressedData;
} else {
return decompress(false, null, pass);
}
},
getDataAsync: function (/*Function*/ callback, pass) {
if (_entryHeader.changed) {
callback(uncompressedData);
} else {
decompress(true, callback, pass);
}
},
set attr(attr) {
_entryHeader.attr = attr;
},
get attr() {
return _entryHeader.attr;
},
set header(/*Buffer*/ data) {
_entryHeader.loadFromBinary(data);
},
get header() {
return _entryHeader;
},
packHeader: function () {
// 1. create header (buffer)
var header = _entryHeader.entryHeaderToBinary();
var addpos = Utils.Constants.CENHDR;
// 2. add file name
_entryName.copy(header, addpos);
addpos += _entryName.length;
// 3. add extra data
if (_entryHeader.extraLength) {
_extra.copy(header, addpos);
addpos += _entryHeader.extraLength;
}
// 4. add file comment
if (_entryHeader.commentLength) {
_comment.copy(header, addpos);
}
return header;
},
toJSON: function () {
const bytes = function (nr) {
return "<" + ((nr && nr.length + " bytes buffer") || "null") + ">";
};
return {
entryName: this.entryName,
name: this.name,
comment: this.comment,
isDirectory: this.isDirectory,
header: _entryHeader.toJSON(),
compressedData: bytes(input),
data: bytes(uncompressedData)
};
},
toString: function () {
return JSON.stringify(this.toJSON(), null, "\t");
}
};
};
fileFormatVersion: 2
guid: 3462ed03b1654480b8b6cc807990787f
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
const ZipEntry = require("./zipEntry");
const Headers = require("./headers");
const Utils = require("./util");
module.exports = function (/*Buffer|null*/ inBuffer, /** object */ options) {
var entryList = [],
entryTable = {},
_comment = Buffer.alloc(0),
mainHeader = new Headers.MainHeader(),
loadedEntries = false;
// assign options
const opts = Object.assign(Object.create(null), options);
const { noSort } = opts;
if (inBuffer) {
// is a memory buffer
readMainHeader(opts.readEntries);
} else {
// none. is a new file
loadedEntries = true;
}
function iterateEntries(callback) {
const totalEntries = mainHeader.diskEntries; // total number of entries
let index = mainHeader.offset; // offset of first CEN header
for (let i = 0; i < totalEntries; i++) {
let tmp = index;
const entry = new ZipEntry(inBuffer);
entry.header = inBuffer.slice(tmp, (tmp += Utils.Constants.CENHDR));
entry.entryName = inBuffer.slice(tmp, (tmp += entry.header.fileNameLength));
index += entry.header.entryHeaderSize;
callback(entry);
}
}
function readEntries() {
loadedEntries = true;
entryTable = {};
entryList = new Array(mainHeader.diskEntries); // total number of entries
var index = mainHeader.offset; // offset of first CEN header
for (var i = 0; i < entryList.length; i++) {
var tmp = index,
entry = new ZipEntry(inBuffer);
entry.header = inBuffer.slice(tmp, (tmp += Utils.Constants.CENHDR));
entry.entryName = inBuffer.slice(tmp, (tmp += entry.header.fileNameLength));
if (entry.header.extraLength) {
entry.extra = inBuffer.slice(tmp, (tmp += entry.header.extraLength));
}
if (entry.header.commentLength) entry.comment = inBuffer.slice(tmp, tmp + entry.header.commentLength);
index += entry.header.entryHeaderSize;
entryList[i] = entry;
entryTable[entry.entryName] = entry;
}
}
function readMainHeader(/*Boolean*/ readNow) {
var i = inBuffer.length - Utils.Constants.ENDHDR, // END header size
max = Math.max(0, i - 0xffff), // 0xFFFF is the max zip file comment length
n = max,
endStart = inBuffer.length,
endOffset = -1, // Start offset of the END header
commentEnd = 0;
for (i; i >= n; i--) {
if (inBuffer[i] !== 0x50) continue; // quick check that the byte is 'P'
if (inBuffer.readUInt32LE(i) === Utils.Constants.ENDSIG) {
// "PK\005\006"
endOffset = i;
commentEnd = i;
endStart = i + Utils.Constants.ENDHDR;
// We already found a regular signature, let's look just a bit further to check if there's any zip64 signature
n = i - Utils.Constants.END64HDR;
continue;
}
if (inBuffer.readUInt32LE(i) === Utils.Constants.END64SIG) {
// Found a zip64 signature, let's continue reading the whole zip64 record
n = max;
continue;
}
if (inBuffer.readUInt32LE(i) === Utils.Constants.ZIP64SIG) {
// Found the zip64 record, let's determine it's size
endOffset = i;
endStart = i + Utils.readBigUInt64LE(inBuffer, i + Utils.Constants.ZIP64SIZE) + Utils.Constants.ZIP64LEAD;
break;
}
}
if (!~endOffset) throw new Error(Utils.Errors.INVALID_FORMAT);
mainHeader.loadFromBinary(inBuffer.slice(endOffset, endStart));
if (mainHeader.commentLength) {
_comment = inBuffer.slice(commentEnd + Utils.Constants.ENDHDR);
}
if (readNow) readEntries();
}
function sortEntries() {
if (entryList.length > 1 && !noSort) {
entryList.sort((a, b) => a.entryName.toLowerCase().localeCompare(b.entryName.toLowerCase()));
}
}
return {
/**
* Returns an array of ZipEntry objects existent in the current opened archive
* @return Array
*/
get entries() {
if (!loadedEntries) {
readEntries();
}
return entryList;
},
/**
* Archive comment
* @return {String}
*/
get comment() {
return _comment.toString();
},
set comment(val) {
_comment = Utils.toBuffer(val);
mainHeader.commentLength = _comment.length;
},
getEntryCount: function () {
if (!loadedEntries) {
return mainHeader.diskEntries;
}
return entryList.length;
},
forEach: function (callback) {
if (!loadedEntries) {
iterateEntries(callback);
return;
}
entryList.forEach(callback);
},
/**
* Returns a reference to the entry with the given name or null if entry is inexistent
*
* @param entryName
* @return ZipEntry
*/
getEntry: function (/*String*/ entryName) {
if (!loadedEntries) {
readEntries();
}
return entryTable[entryName] || null;
},
/**
* Adds the given entry to the entry list
*
* @param entry
*/
setEntry: function (/*ZipEntry*/ entry) {
if (!loadedEntries) {
readEntries();
}
entryList.push(entry);
entryTable[entry.entryName] = entry;
mainHeader.totalEntries = entryList.length;
},
/**
* Removes the entry with the given name from the entry list.
*
* If the entry is a directory, then all nested files and directories will be removed
* @param entryName
*/
deleteEntry: function (/*String*/ entryName) {
if (!loadedEntries) {
readEntries();
}
var entry = entryTable[entryName];
if (entry && entry.isDirectory) {
var _self = this;
this.getEntryChildren(entry).forEach(function (child) {
if (child.entryName !== entryName) {
_self.deleteEntry(child.entryName);
}
});
}
entryList.splice(entryList.indexOf(entry), 1);
delete entryTable[entryName];
mainHeader.totalEntries = entryList.length;
},
/**
* Iterates and returns all nested files and directories of the given entry
*
* @param entry
* @return Array
*/
getEntryChildren: function (/*ZipEntry*/ entry) {
if (!loadedEntries) {
readEntries();
}
if (entry && entry.isDirectory) {
const list = [];
const name = entry.entryName;
const len = name.length;
entryList.forEach(function (zipEntry) {
if (zipEntry.entryName.substr(0, len) === name) {
list.push(zipEntry);
}
});
return list;
}
return [];
},
/**
* Returns the zip file
*
* @return Buffer
*/
compressToBuffer: function () {
if (!loadedEntries) {
readEntries();
}
sortEntries();
const dataBlock = [];
const entryHeaders = [];
let totalSize = 0;
let dindex = 0;
mainHeader.size = 0;
mainHeader.offset = 0;
for (const entry of entryList) {
// compress data and set local and entry header accordingly. Reason why is called first
const compressedData = entry.getCompressedData();
// 1. construct data header
entry.header.offset = dindex;
const dataHeader = entry.header.dataHeaderToBinary();
const entryNameLen = entry.rawEntryName.length;
// 1.2. postheader - data after data header
const postHeader = Buffer.alloc(entryNameLen + entry.extra.length);
entry.rawEntryName.copy(postHeader, 0);
postHeader.copy(entry.extra, entryNameLen);
// 2. offsets
const dataLength = dataHeader.length + postHeader.length + compressedData.length;
dindex += dataLength;
// 3. store values in sequence
dataBlock.push(dataHeader);
dataBlock.push(postHeader);
dataBlock.push(compressedData);
// 4. construct entry header
const entryHeader = entry.packHeader();
entryHeaders.push(entryHeader);
// 5. update main header
mainHeader.size += entryHeader.length;
totalSize += dataLength + entryHeader.length;
}
totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
// point to end of data and beginning of central directory first record
mainHeader.offset = dindex;
dindex = 0;
const outBuffer = Buffer.alloc(totalSize);
// write data blocks
for (const content of dataBlock) {
content.copy(outBuffer, dindex);
dindex += content.length;
}
// write central directory entries
for (const content of entryHeaders) {
content.copy(outBuffer, dindex);
dindex += content.length;
}
// write main header
const mh = mainHeader.toBinary();
if (_comment) {
_comment.copy(mh, Utils.Constants.ENDHDR); // add zip file comment
}
mh.copy(outBuffer, dindex);
return outBuffer;
},
toAsyncBuffer: function (/*Function*/ onSuccess, /*Function*/ onFail, /*Function*/ onItemStart, /*Function*/ onItemEnd) {
try {
if (!loadedEntries) {
readEntries();
}
sortEntries();
const dataBlock = [];
const entryHeaders = [];
let totalSize = 0;
let dindex = 0;
mainHeader.size = 0;
mainHeader.offset = 0;
const compress2Buffer = function (entryLists) {
if (entryLists.length) {
const entry = entryLists.pop();
const name = entry.entryName + entry.extra.toString();
if (onItemStart) onItemStart(name);
entry.getCompressedDataAsync(function (compressedData) {
if (onItemEnd) onItemEnd(name);
entry.header.offset = dindex;
// data header
const dataHeader = entry.header.dataHeaderToBinary();
const postHeader = Buffer.alloc(name.length, name);
const dataLength = dataHeader.length + postHeader.length + compressedData.length;
dindex += dataLength;
dataBlock.push(dataHeader);
dataBlock.push(postHeader);
dataBlock.push(compressedData);
const entryHeader = entry.packHeader();
entryHeaders.push(entryHeader);
mainHeader.size += entryHeader.length;
totalSize += dataLength + entryHeader.length;
compress2Buffer(entryLists);
});
} else {
totalSize += mainHeader.mainHeaderSize; // also includes zip file comment length
// point to end of data and beginning of central directory first record
mainHeader.offset = dindex;
dindex = 0;
const outBuffer = Buffer.alloc(totalSize);
dataBlock.forEach(function (content) {
content.copy(outBuffer, dindex); // write data blocks
dindex += content.length;
});
entryHeaders.forEach(function (content) {
content.copy(outBuffer, dindex); // write central directory entries
dindex += content.length;
});
const mh = mainHeader.toBinary();
if (_comment) {
_comment.copy(mh, Utils.Constants.ENDHDR); // add zip file comment
}
mh.copy(outBuffer, dindex); // write main header
onSuccess(outBuffer);
}
};
compress2Buffer(entryList);
} catch (e) {
onFail(e);
}
}
};
};
fileFormatVersion: 2
guid: ef277ff8180fa4942856255996ff6ec8
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9925d197d84944670867d1ce5152a1d1
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
: Any
second:
enabled: 0
settings:
Exclude Editor: 1
Exclude Linux64: 1
Exclude OSXUniversal: 1
Exclude WebGL: 1
Exclude Win: 1
Exclude Win64: 1
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Collections.Generic;
using UnityEditor;
using System.IO;
using System.Text.RegularExpressions;
using System;
namespace WeChatWASM
{
public class WXBundleSelectorWindow : EditorWindow
{
public static WXEditorScriptObject miniGameConf;
private int totalPage; //页面总数
private
const int countPerPage = 15; //定义每一页的数量
private int page = 1; //当前page
private
const int pathMaxLength = 64;
private Vector2 scrollRoot;
private string[] ignoreRule;
private string[] noneIgnoreRule;
private string searchText = "";
private string searchTextCache = ""; //做一个Cache 因为 OnGUI 是频繁调用的,不应该频繁处理
private void OnEnable()
{
this.init();
}
private void init()
{
miniGameConf = UnityUtil.GetEditorConf();
this.loadIgnore();
//扫描微信小游戏导出目录
this.scanMiniGameDirBundle(true);
}
private List<string> fileList = new List<string>();
private List<string> showFileList = new List<string>(); //搜索显示状态下的列表
private List<string> selectedFileList = new List<string>();
/**
扫描微信小游戏目录内的资源包信息
*/
private void scanMiniGameDirBundle(bool userule = false)
{
if (string.IsNullOrEmpty(miniGameConf.CompressTexture.bundleSuffix))
{
this.showToast("bundle后缀不能为空", true);
return;
}
if (string.IsNullOrEmpty(miniGameConf.ProjectConf.DST))
{
this.showToast("请先转换为小游戏", true);
return;
}
if (!File.Exists(miniGameConf.ProjectConf.DST + "/webgl/index.html"))
{
this.showToast("请先转换为小游戏,并确保导出目录下存在webgl目录");
return;
}
string bundleSuffixArg = miniGameConf.CompressTexture.bundleSuffix;
string[] bundleSuffix = bundleSuffixArg.Split(';');
string sourceDir = miniGameConf.ProjectConf.DST + "/webgl".Replace('\\', '/');
string bundleDir = miniGameConf.CompressTexture.bundleDir;
this.fileList.Clear();
this.fileList.Add("首包资源");
this.page = 1;
this.recFile(sourceDir, bundleSuffix);
if (!string.IsNullOrEmpty(bundleDir))
{
bundleDir = bundleDir.Replace('\\', '/');
this.recFile(bundleDir, bundleSuffix);
}
if (userule) //规则中存在一些特定的要加入的
{
for (int i = 0; i < this.ignoreRule.Length; i++)
{
string path = this.ignoreRule[i];
if (path.Equals("首包资源"))
{
if (!this.selectedFileList.Contains(path))
{
this.selectedFileList.Add(path);
}
continue;
}
FileInfo info = new FileInfo(this.ignoreRule[i]);
if (info.Exists)
{
if (!this.fileList.Contains(path))
{
this.fileList.Add(path);
}
if (!this.selectedFileList.Contains(path))
{
this.selectedFileList.Add(path);
}
}
}
}
//重新扫描后对已选资源删除不再扫描结果内的元素
foreach (string item in this.selectedFileList)
{
if (!this.fileList.Contains(item))
{
this.selectedFileList.Remove(item);
}
}
if (userule) //此时排除一些不忽略的
{
for (int i = 0; i < this.noneIgnoreRule.Length; i++)
{
string path = this.noneIgnoreRule[i];
if (this.selectedFileList.Contains(path))
{
this.selectedFileList.Remove(path);
}
}
}
this.search();
if (this.fileList.Count == 1)
{
this.showToast("请检查bundle后缀以及资源目录内容,未搜索到相关资源", true);
return;
}
if (!userule)
this.showToast($"搜索完成,共计 {this.fileList.Count - 1} 个bundle资源");
}
/**
递归搜素
*/
private void recFile(string dir, string[] bundleSuffix)
{
if (!Directory.Exists(dir))
{
this.showToast($"目录无效【{dir}】", true);
return;
}
DirectoryInfo dirInfo = new DirectoryInfo(dir);
FileSystemInfo[] fileinfo = dirInfo.GetFileSystemInfos();
foreach (FileSystemInfo i in fileinfo)
{
if (i is DirectoryInfo)
{
this.recFile(i.FullName, bundleSuffix);
}
else
{
this.addFileList(i.FullName, bundleSuffix);
}
}
}
private void addFileList(string path, string[] bundleSuffix)
{
for (int i = 0; i < bundleSuffix.Length; i++)
{
if (Regex.Match(path, @"\." + bundleSuffix[i] + "$").Success)
{
if (!this.fileList.Contains(path))
this.fileList.Add(path);
return;
}
}
}
private void showToast(string content, bool err = false)
{
if (err)
{
UnityEngine.Debug.LogError(content);
}
else
{
UnityEngine.Debug.LogFormat(content);
}
ShowNotification(new GUIContent(content));
}
private bool isSelected(string path)
{
return this.selectedFileList.Contains(path);
}
private void change(string path, bool selected)
{
if (selected)
{
if (!this.isSelected(path))
{
this.selectedFileList.Add(path);
}
}
else
{
if (this.isSelected(path))
{
this.selectedFileList.Remove(path);
}
}
}
/**
对已有的结果进行关键词检索更新新的列表
搜索显示不会影响已选中的项目内容,但是会影响总条数与页面关系
已忽略的将其置顶
*/
private void search()
{
this.showFileList.Clear();
List<string> unselectedfileList = new List<string>();
string search = searchText.Trim();
if (search.Equals(""))
{
foreach (string item in this.fileList)
{
if (item.Equals("首包资源") || this.selectedFileList.Contains(item))
{
this.showFileList.Add(item);
}
else
{
unselectedfileList.Add(item);
}
}
}
else
{
foreach (string item in this.fileList)
{
if (item.IndexOf(this.searchText) != -1)
{
if (item.Equals("首包资源") || this.selectedFileList.Contains(item))
{
this.showFileList.Add(item);
}
else
{
unselectedfileList.Add(item);
}
}
}
}
foreach (string item in unselectedfileList)
{
this.showFileList.Add(item);
}
totalPage = (int)Mathf.Ceil((float)showFileList.Count / (float)countPerPage); //计算总页数
}
/**
路径字符串截断处理
*/
private string stringSub(string path)
{
if (path.Length <= pathMaxLength)
{
return path;
}
string tempPath = path.Substring(path.Length - pathMaxLength);
return "..." + tempPath;
}
/**
配置文件保存在 webgl 目录内的 .wxbundleignore 文件内
例:
xxxx/a.bundle
!xxxx/b.bundle
意为对 a.bundler 忽略;
b.bundle 不忽略;
*/
private void confirm()
{
string path = miniGameConf.ProjectConf.DST + "/webgl".Replace('\\', '/') + "/.wxbundleignore";
using (FileStream file = new FileStream(path, FileMode.Create, FileAccess.Write))
{
using (StreamWriter writer = new StreamWriter(file))
{
foreach (string item in this.fileList)
{
string row = item.Equals("首包资源") ? "#" : item;
if (this.selectedFileList.Contains(item))
{
writer.WriteLine(row);
}
else
{
writer.WriteLine($"!{row}");
}
}
}
}
this.showToast("保存成功");
}
/**
读取 .wxbundleignore 文件 若该文件不存在则视为默认全选
*/
private void loadIgnore()
{
string path = miniGameConf.ProjectConf.DST + "/webgl".Replace('\\', '/') + "/.wxbundleignore";
FileInfo info = new FileInfo(path);
if (!info.Exists)
{
this.ignoreRule = new string[] { };
this.noneIgnoreRule = new string[] { };
return;
}
string content = "";
using (FileStream file = new FileStream(path, FileMode.Open, FileAccess.Read))
{
using (StreamReader reader = new StreamReader(file))
{
content = reader.ReadToEnd();
}
}
string[] rule = content.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
List<string> ignore = new List<string>();
List<string> noneIgnore = new List<string>();
for (int i = 0; i < rule.Length; i++)
{
string row = rule[i];
if (string.IsNullOrWhiteSpace(row))
continue;
if (row.Length > 0 && row[0] == '!')
{
noneIgnore.Add(row.Equals("!#") ? "首包资源" : row.Substring(1));
}
else
{
ignore.Add(row.Equals("#") ? "首包资源" : row);
}
}
this.ignoreRule = ignore.ToArray();
this.noneIgnoreRule = noneIgnore.ToArray();
}
private void selectAll()
{
this.selectedFileList.Clear();
foreach (string i in this.fileList)
{
this.selectedFileList.Add(i);
}
}
private void OnGUI()
{
EditorGUILayout.BeginVertical("box");
EditorGUILayout.LabelField("请选择需要忽略的bundle资源,若被忽略资源此前被压缩过,忽略后将被还原为未压缩");
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("扫描资源", GUILayout.Width(90)))
{
this.scanMiniGameDirBundle();
}
if (searchText.Trim().Equals(""))
{
if (GUILayout.Button("全部选择", GUILayout.Width(65)))
{
this.selectAll();
}
if (GUILayout.Button("全部反选", GUILayout.Width(65)))
{
foreach (string i in this.fileList)
{
this.change(i, !this.isSelected(i));
}
}
}
searchText = EditorGUILayout.TextArea(searchText, "SearchTextField", GUILayout.MaxWidth(300));
if (!searchText.Equals(searchTextCache))
{
this.searchTextCache = this.searchText;
this.search();
}
EditorGUILayout.EndHorizontal();
scrollRoot = EditorGUILayout.BeginScrollView(scrollRoot);
EditorGUILayout.BeginVertical("frameBox", GUILayout.MinHeight(200));
string[] list = this.showFileList.ToArray();
List<string> currentList = new List<string>();
for (int i = (page - 1) * countPerPage; i < list.Length; i++)
{
if (i >= page * countPerPage) break;
EditorGUILayout.BeginHorizontal("box");
this.change(list[i], GUILayout.Toggle(this.isSelected(list[i]), this.stringSub(list[i])));
currentList.Add(list[i]);
if (!list[i].Equals("首包资源"))
{
if (GUILayout.Button("定位", GUILayout.Width(40)))
{
EditorUtility.RevealInFinder(list[i]);
}
}
EditorGUILayout.EndHorizontal();
}
EditorGUILayout.EndVertical();
EditorGUILayout.EndScrollView();
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField($"当前页:{page.ToString()}/{totalPage} 总条数:{this.showFileList.Count} 已选:{this.selectedFileList.Count}");
if (GUILayout.Button("上一页"))
{
page -= 1;
page = Mathf.Clamp(page, 1, totalPage);
}
if (GUILayout.Button("下一页"))
{
page += 1;
page = Mathf.Clamp(page, 1, totalPage);
}
if (GUILayout.Button("本页选择"))
{
foreach (string i in currentList)
{
this.change(i, true);
}
}
if (GUILayout.Button("本页反选"))
{
foreach (string i in currentList)
{
this.change(i, !this.isSelected(i));
}
}
if (GUILayout.Button("确定"))
{
this.confirm();
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.EndVertical();
}
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 4ca65f8831e5848ed8f1fef82eeae8c0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 098fca9e9cf3648fb96333b231a4ad7b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
var UDPSocketLibrary =
{
$udpSocketManager:
{
/*
* Map of instances
*
* Instance structure:
* {
* url: string,
* ws: WebSocket
* }
*/
instances: {},
/* Last instance ID */
lastId: 0,
/* Event listeners */
onOpen: null,
onMessage: null,
onError: null,
onClose: null,
},
WXCreateUDPSocket: function (server, remotePort, localPort) {
var instanceId = ++udpSocketManager.lastId;
var udpSocket = wx.createUDPSocket();
if (localPort == 0) {
localPort = udpSocket.bind()
} else {
udpSocket.bind(localPort)
}
var instance = {
instanceId: instanceId,
socket: udpSocket,
server: UTF8ToString(server),
remotePort: remotePort,
localPort: localPort,
OnMessage: (function (res) {
if (udpSocketManager.onMessage) {
var dataBuffer = new Uint8Array(res.message);
var buffer = _malloc(dataBuffer.length);
HEAPU8.set(dataBuffer, buffer);
Module.dynCall_viii(udpSocketManager.onMessage, instanceId, buffer, dataBuffer.length);
_free(buffer)
}
}),
OnError: (function (res) {
if (udpSocketManager.onError) {
var msg = res.errMsg;
console.log("udp socket on error " + instanceId + " " + msg);
var length = lengthBytesUTF8(msg) + 1;
var buffer = _malloc(length);
stringToUTF8(msg, buffer, length);
Module.dynCall_vii(udpSocketManager.onError, instanceId, buffer);
_free(buffer)
}
}),
OnClose: (function (res) {
if (udpSocketManager.onClose) {
Module.dynCall_vi(udpSocketManager.onClose, instanceId)
}
})
};
udpSocket.onMessage(instance.OnMessage);
udpSocket.onError(instance.OnError);
udpSocket.onClose(instance.OnClose);
udpSocket.connect({
address:instance.server,
port:instance.remotePort
});
udpSocketManager.instances[instanceId] = instance;
return instanceId
},
WXSendUDPSocket: function (instanceId, bufferPtr, offset, length) {
var instance = udpSocketManager.instances[instanceId];
if (instance && instance.socket) {
instance.socket.write({
address: instance.server,
port: instance.remotePort,
message: buffer.slice(bufferPtr + offset, bufferPtr + length)
})
} else {
console.log("udp socket instance not found " + instanceId)
}
},
WXCloseUDPSocket: function (instanceId) {
var instance = udpSocketManager.instances[instanceId];
if (instance && instance.socket) {
instance.socket.close();
instance.socket = null;
delete udpSocketManager.instances[instanceId]
} else {
console.log("udp socket instance not found " + instanceId)
}
},
WXUDPSocketSetOnMessage: function (callback) {
udpSocketManager.onMessage = callback
},
WXUDPSocketSetOnClose: function (callback) {
udpSocketManager.onClose = callback
},
WXUDPSocketSetOnError: function (callback) {
udpSocketManager.onError = callback
}
};
autoAddDeps(UDPSocketLibrary, '$udpSocketManager');
mergeInto(LibraryManager.library, UDPSocketLibrary);
\ No newline at end of file
fileFormatVersion: 2
guid: 1a619860d36bdfb4eaa583d3ba561e99
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 0
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
WebGL: WebGL
second:
enabled: 1
settings: {}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Runtime.InteropServices;
using System;
using LitJson;
using System.Collections.Generic;
using UnityEngine.Scripting;
namespace WeChatWASM
{
/// <summary>
/// 微信相机
/// </summary>
public class WXCamera
{
private string instanceId;
public WXCamera(string id)
{
instanceId = id;
}
/// <summary>
/// [Camera.closeFrameChange()](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.closeFrameChange.html)
/// 需要基础库: `2.9.0`
/// 关闭监听帧数据
/// </summary>
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WXCameraCloseFrameChange(string id);
public void CloseFrameChange(){
WXCameraCloseFrameChange(instanceId);
}
/// <summary>
/// [Camera.destroy()](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.destroy.html)
/// 需要基础库: `2.9.0`
/// 销毁相机
/// </summary>
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WXCameraDestroy(string id);
public void Destroy(){
WXCameraDestroy(instanceId);
}
/// <summary>
/// [Camera.listenFrameChange()](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.listenFrameChange.html)
/// 需要基础库: `2.9.0`
/// 开启监听帧数据
/// </summary>
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WXCameraListenFrameChange(string id);
public void ListenFrameChange(){
WXCameraListenFrameChange(instanceId);
}
/// <summary>
/// [Camera.onAuthCancel(function callback)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.onAuthCancel.html)
/// 需要基础库: `2.9.0`
/// 监听用户不允许授权使用摄像头的情况
/// </summary>
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WXCameraOnAuthCancel(string id);
public static Dictionary<string,Action> OnAuthCancelActionList;
public void OnAuthCancel(Action callback){
if(OnAuthCancelActionList == null){
OnAuthCancelActionList = new Dictionary<string,Action>();
}
if(OnAuthCancelActionList.ContainsKey(instanceId)){
OnAuthCancelActionList[instanceId] += callback;
}else{
OnAuthCancelActionList.Add(instanceId, callback);
WXCameraOnAuthCancel(instanceId);
}
}
/// <summary>
/// [Camera.onCameraFrame(function callback)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.onCameraFrame.html)
/// 需要基础库: `2.9.0`
/// 监听摄像头实时帧数据
/// </summary>
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WXCameraOnCameraFrame(string id);
public static Dictionary<string,Action<OnCameraFrameCallbackResult>> OnCameraFrameActionList;
public void OnCameraFrame(Action<OnCameraFrameCallbackResult> callback){
if(OnCameraFrameActionList == null){
OnCameraFrameActionList = new Dictionary<string,Action<OnCameraFrameCallbackResult>>();
}
if(OnCameraFrameActionList.ContainsKey(instanceId)){
OnCameraFrameActionList[instanceId] += callback;
}else{
OnCameraFrameActionList.Add(instanceId, callback);
WXCameraOnCameraFrame(instanceId);
}
}
/// <summary>
/// [Camera.onStop(function callback)](https://developers.weixin.qq.com/minigame/dev/api/media/camera/Camera.onStop.html)
/// 需要基础库: `2.9.0`
/// 监听摄像头非正常终止事件,如退出后台等情况
/// </summary>
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WXCameraOnStop(string id);
public static Dictionary<string,Action> OnStopActionList;
public void OnStop(Action callback){
if(OnStopActionList == null){
OnStopActionList = new Dictionary<string,Action>();
}
if (OnStopActionList.ContainsKey(instanceId)){
OnStopActionList[instanceId] += callback;
}else{
OnStopActionList.Add(instanceId, callback);
WXCameraOnStop(instanceId);
}
}
}
[Preserve]
public class OnCameraFrameCallbackResult
{
/// <summary>
/// 图像像素点数据,一维数组,每四项表示一个像素点的 rgba
/// </summary>
public byte[] data;
/// <summary>
/// 图像数据矩形的高度
/// </summary>
public int height;
/// <summary>
/// 图像数据矩形的宽度
/// </summary>
public int width;
}
[Preserve]
public class CreateCameraOption {
/// <summary>
/// 接口调用结束的回调函数(调用成功、失败都会执行)
/// </summary>
public Action<GeneralCallbackResult> complete;
/// <summary>
/// 摄像头朝向,值为 front, back
/// </summary>
public string devicePosition = "back";
/// <summary>
/// 接口调用失败的回调函数
/// </summary>
public Action<GeneralCallbackResult> fail;
/// <summary>
/// 闪光灯,值为 auto, on, off
/// </summary>
public string flash = "auto";
/// <summary>
/// 相机的高度
/// </summary>
public double height = 150f;
/// <summary>
/// 帧数据图像尺寸,值为 small, medium, large
/// </summary>
public string size = "small";
/// <summary>
/// 接口调用成功的回调函数
/// </summary>
public Action<GeneralCallbackResult> success;
/// <summary>
/// 相机的宽度
/// </summary>
public double width = 300f;
/// <summary>
/// 相机的左上角横坐标
/// </summary>
public double x = 0f;
/// <summary>
/// 相机的左上角纵坐标
/// </summary>
public double y = 0f;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: ea8b94bc1dd3a48e79cee5ebb773b8d3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Runtime.InteropServices;
using System;
using LitJson;
using System.Collections.Generic;
using UnityEngine.Scripting;
namespace WeChatWASM
{
/// <summary>
/// 游戏对局回放
/// </summary>
public class WXGameRecorder
{
private string instanceId;
public static Dictionary<string, Action<GameRecorderCallbackRes>> OnActionList = new Dictionary<string, Action<GameRecorderCallbackRes>>();
public WXGameRecorder(string id)
{
instanceId = id;
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_GameRecorderOff(string id, string eventType);
public void Off(string eventType)
{
if (OnActionList.ContainsKey(eventType))
{
OnActionList[eventType] = null;
WX_GameRecorderOff(instanceId, eventType);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_GameRecorderOn(string id, string eventType);
public void On(string eventType, Action<GameRecorderCallbackRes> callback = null)
{
OnActionList.Add(eventType, callback);
WX_GameRecorderOn(instanceId, eventType);
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_GameRecorderStart(string id, string option);
public void Start(GameRecorderStartOption option)
{
WX_GameRecorderStart(instanceId, JsonMapper.ToJson(option));
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_GameRecorderAbort(string id);
public void Abort()
{
WX_GameRecorderAbort(instanceId);
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_GameRecorderPause(string id);
public void Pause()
{
WX_GameRecorderPause(instanceId);
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_GameRecorderResume(string id);
public void Resume()
{
WX_GameRecorderResume(instanceId);
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_GameRecorderStop(string id);
public void Stop()
{
WX_GameRecorderStop(instanceId);
}
}
[Preserve]
public class GameRecorderStartOption
{
/// <summary>
/// 视频比特率(kbps),默认值1000,最大值 3000,最小值 600
/// </summary>
public double bitrate = 1000;
/// <summary>
/// 视频的时长限制,单位为秒(s)。最大值 7200,最小值 5,到达指定时长后不会再录入。但还需要手动调用 [GameRecorder.stop()](https://developers.weixin.qq.com/minigame/dev/api/game-recorder/GameRecorder.stop.html) 来结束录制。
/// </summary>
public double duration = 7200;
/// <summary>
/// 视频 fps
/// </summary>
public double fps = 24;
/// <summary>
/// 视频关键帧间隔
/// </summary>
public double gop = 12;
/// <summary>
/// 需要基础库: `2.10.0`
///
/// 是否录制游戏音效(仅iOS支持)
/// </summary>
public bool hookBgm = true;
}
[Preserve]
public class GameRecorderCallbackRes
{
public float currentTime;
public int code;
public string message;
public float duration;
}
[Preserve]
public class GameRecorderCallback
{
public string eventType;
public string result;
}
[Preserve]
public class operateGameRecorderOption
{
/// <summary>
/// 分享的对局回放打开后的标题内容
/// </summary>
public string title = "";
/// <summary>
/// 分享的对局回放打开后的描述内容
/// </summary>
public string desc = "";
/// <summary>
/// 分享的对局回放打开后跳转小游戏的 query
/// </summary>
public string query = "";
/// <summary>
/// 分享的对局回放打开后跳转小游戏的 path (独立分包路径)
/// </summary>
public string path = "";
/// <summary>
/// 对局回放背景音乐的地址
/// </summary>
public string bgm = "";
/// <summary>
/// 对局回放的剪辑区间,是一个二维数组,单位 ms(毫秒)
/// </summary>
public int[][] timeRange = null;
/// <summary>
/// 对局回放的音量大小,最小0,最大1
/// </summary>
public double volume = 1;
/// <summary>
/// 对局回放的播放速率,只能设置以下几个值: 0.3, 0.5, 1, 1.5, 2, 2.5, 3
/// </summary>
public double number = 1;
/// <summary>
/// 如果原始视频文件中有音频,是否与新传入的bgm混音,默认为false,表示不混音,只保留一个音轨,值为true时表示原始音频与传入的bgm混音
/// </summary>
public bool audioMix = false;
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: 56cd5d5008b2e45ba97026adf819ebec
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using System.Runtime.InteropServices;
using System;
using LitJson;
using System.Collections.Generic;
using UnityEngine.Scripting;
namespace WeChatWASM
{
public class WXRecorderManager
{
private string instanceId;
public WXRecorderManager(string id)
{
instanceId = id;
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderError(string id);
public static Dictionary<string,Action> OnRecorderErrorActionList;
public void OnError(Action callback){
if(OnRecorderErrorActionList == null){
OnRecorderErrorActionList = new Dictionary<string,Action>();
}
if(OnRecorderErrorActionList.ContainsKey(instanceId)){
OnRecorderErrorActionList[instanceId] += callback;
}else{
OnRecorderErrorActionList.Add(instanceId,callback);
WX_OnRecorderError(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderFrameRecorded(string id);
public static Dictionary<string,Action<OnFrameRecordedCallbackResult>> OnRecorderFrameRecordedActionList;
public void OnFrameRecorded(Action<OnFrameRecordedCallbackResult> callback){
if(OnRecorderFrameRecordedActionList == null){
OnRecorderFrameRecordedActionList = new Dictionary<string,Action<OnFrameRecordedCallbackResult>>();
}
if(OnRecorderFrameRecordedActionList.ContainsKey(instanceId)){
OnRecorderFrameRecordedActionList[instanceId] += callback;
}else{
OnRecorderFrameRecordedActionList.Add(instanceId,callback);
WX_OnRecorderFrameRecorded(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderInterruptionBegin(string id);
public static Dictionary<string,Action> OnRecorderInterruptionBeginActionList;
public void OnInterruptionBegin(Action callback){
if(OnRecorderInterruptionBeginActionList == null){
OnRecorderInterruptionBeginActionList = new Dictionary<string,Action>();
}
if(OnRecorderInterruptionBeginActionList.ContainsKey(instanceId)){
OnRecorderInterruptionBeginActionList[instanceId] += callback;
}else{
OnRecorderInterruptionBeginActionList.Add(instanceId,callback);
WX_OnRecorderInterruptionBegin(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderInterruptionEnd(string id);
public static Dictionary<string,Action> OnRecorderInterruptionEndActionList;
public void OnInterruptionEnd(Action callback){
if(OnRecorderInterruptionEndActionList == null){
OnRecorderInterruptionEndActionList = new Dictionary<string,Action>();
}
if(OnRecorderInterruptionEndActionList.ContainsKey(instanceId)){
OnRecorderInterruptionEndActionList[instanceId] += callback;
}else{
OnRecorderInterruptionEndActionList.Add(instanceId,callback);
WX_OnRecorderInterruptionEnd(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderPause(string id);
public static Dictionary<string,Action> OnRecorderPauseActionList;
public void OnPause(Action callback){
if(OnRecorderPauseActionList == null){
OnRecorderPauseActionList = new Dictionary<string,Action>();
}
if(OnRecorderPauseActionList.ContainsKey(instanceId)){
OnRecorderPauseActionList[instanceId] += callback;
}else{
OnRecorderPauseActionList.Add(instanceId,callback);
WX_OnRecorderPause(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderResume(string id);
public static Dictionary<string,Action> OnRecorderResumeActionList;
public void OnResume(Action callback){
if(OnRecorderResumeActionList == null){
OnRecorderResumeActionList = new Dictionary<string,Action>();
}
if(OnRecorderResumeActionList.ContainsKey(instanceId)){
OnRecorderResumeActionList[instanceId] += callback;
}else{
OnRecorderResumeActionList.Add(instanceId,callback);
WX_OnRecorderResume(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderStart(string id);
public static Dictionary<string,Action> OnRecorderStartActionList;
public void OnStart(Action callback){
if(OnRecorderStartActionList == null){
OnRecorderStartActionList = new Dictionary<string,Action>();
}
if(OnRecorderStartActionList.ContainsKey(instanceId)){
OnRecorderStartActionList[instanceId] += callback;
}else{
OnRecorderStartActionList.Add(instanceId,callback);
WX_OnRecorderStart(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_OnRecorderStop(string id);
public static Dictionary<string,Action<OnStopCallbackResult>> OnRecorderStopActionList;
public void OnStop(Action<OnStopCallbackResult> callback){
if(OnRecorderStopActionList == null){
OnRecorderStopActionList = new Dictionary<string,Action<OnStopCallbackResult>>();
}
if(OnRecorderStopActionList.ContainsKey(instanceId)){
OnRecorderStopActionList[instanceId] += callback;
}else{
OnRecorderStopActionList.Add(instanceId,callback);
WX_OnRecorderStop(instanceId);
}
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_RecorderPause(string id);
public void Pause(){
WX_RecorderPause(instanceId);
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_RecorderResume(string id);
public void Resume(){
WX_RecorderResume(instanceId);
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_RecorderStart(string id, string option);
public void Start(RecorderManagerStartOption option){
WX_RecorderStart(instanceId, JsonMapper.ToJson(option));
}
#if UNITY_WEBGL
[DllImport("__Internal")]
#endif
private static extern void WX_RecorderStop(string id);
public void Stop(){
WX_RecorderStop(instanceId);
}
}
[Preserve]
public class OnFrameRecordedCallbackResult {
/// <summary>
/// 录音分片数据
/// </summary>
public byte[] frameBuffer;
/// <summary>
/// 当前帧是否正常录音结束前的最后一帧
/// </summary>
public bool isLastFrame;
}
[Preserve]
public class OnFrameRecordedBufferCallbackResult {
/// <summary>
/// 录音分片数据长度
/// </summary>
public long frameBufferLength;
/// <summary>
/// 当前帧是否正常录音结束前的最后一帧
/// </summary>
public bool isLastFrame;
}
[Preserve]
public class OnStopCallbackResult {
/// <summary>
/// 录音总时长,单位:ms
/// </summary>
public double duration;
/// <summary>
/// 录音文件大小,单位:Byte
/// </summary>
public double fileSize;
/// <summary>
/// 录音文件的临时路径 (本地路径)
/// </summary>
public string tempFilePath;
}
[Preserve]
public class RecorderManagerStartOption {
/// <summary>
/// 需要基础库: `2.1.0`
/// 指定录音的音频输入源,可通过 [wx.getAvailableAudioSources()](https://developers.weixin.qq.com/minigame/dev/api/media/audio/wx.getAvailableAudioSources.html) 获取当前可用的音频源
/// 可选值:
/// - 'auto': 自动设置,默认使用手机麦克风,插上耳麦后自动切换使用耳机麦克风,所有平台适用;
/// - 'buildInMic': 手机麦克风,仅限 iOS;
/// - 'headsetMic': 有线耳机麦克风,仅限 iOS;
/// - 'mic': 麦克风(没插耳麦时是手机麦克风,插耳麦时是耳机麦克风),仅限 Android;
/// - 'camcorder': 同 mic,适用于录制音视频内容,仅限 Android;
/// - 'voice_communication': 同 mic,适用于实时沟通,仅限 Android;
/// - 'voice_recognition': 同 mic,适用于语音识别,仅限 Android;
/// </summary>
public string audioSource;
/// <summary>
/// 录音的时长,单位 ms,最大值 600000(10 分钟)
/// </summary>
public double duration;
/// <summary>
/// 编码码率,有效值见下表格
/// </summary>
public double encodeBitRate;
/// <summary>
/// 音频格式
/// 可选值:
/// - 'mp3': mp3 格式;
/// - 'aac': aac 格式;
/// - 'wav': wav 格式;
/// - 'PCM': pcm 格式;
/// </summary>
public string format;
/// <summary>
/// 指定帧大小,单位 KB。传入 frameSize 后,每录制指定帧大小的内容后,会回调录制的文件内容,不指定则不会回调。暂仅支持 mp3、pcm 格式。
/// </summary>
public double frameSize;
/// <summary>
/// 录音通道数
/// 可选值:
/// - 1: 1 个通道;
/// - 2: 2 个通道;
/// </summary>
public double numberOfChannels;
/// <summary>
/// 采样率(pc不支持)
/// 可选值:
/// - 8000: 8000 采样率;
/// - 11025: 11025 采样率;
/// - 12000: 12000 采样率;
/// - 16000: 16000 采样率;
/// - 22050: 22050 采样率;
/// - 24000: 24000 采样率;
/// - 32000: 32000 采样率;
/// - 44100: 44100 采样率;
/// - 48000: 48000 采样率;
/// </summary>
public double sampleRate;
}
}
fileFormatVersion: 2
guid: 047f95cd7c9ba4ba2b65a6908f141d28
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
此差异已折叠。
fileFormatVersion: 2
guid: 6e1df66d774cb46a99fc9a959cc3c66d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册