This commit is contained in:
walkpan
2024-08-18 23:38:55 +08:00
parent e8dbb9bab3
commit 8f57f57c1d
1004 changed files with 234067 additions and 16087 deletions

View File

@@ -0,0 +1,31 @@
## 0.3.11
- Fix docs
## 0.3.9
- Fixed issue with unzipping
## 0.3.7
- Patched streaming compression bugs
- Added demo page
## 0.3.6
- Allowed true ESM imports
## 0.3.4
- Fixed rare overflow bug causing corruption
- Added async stream termination
- Added UMD bundle
## 0.3.0
- Added support for asynchronous and synchronous streaming
- Reduced bundle size by autogenerating worker code, even in minified environments
- Error detection rather than hanging
- Improved performance
## 0.2.3
- Improved Zlib autodetection
## 0.2.2
- Fixed Node Worker
## 0.2.1
- Fixed ZIP bug
## 0.2.0
- Added support for ZIP files (parallelized)
- Added ability to terminate running asynchronous operations
## 0.1.0
- Rewrote API: added support for asynchronous (Worker) compression/decompression, fixed critical bug involving fixed Huffman trees
## 0.0.1
- Created, works on basic input

21
extensions/Excel转JSON/node_modules/fflate/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020 Arjun Barrett
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.

354
extensions/Excel转JSON/node_modules/fflate/README.md generated vendored Normal file
View File

@@ -0,0 +1,354 @@
# fflate
High performance (de)compression in an 8kB package
## Why fflate?
`fflate` (short for fast flate) is the **fastest, smallest, and most versatile** pure JavaScript compression and decompression library in existence, handily beating [`pako`](https://npmjs.com/package/pako), [`tiny-inflate`](https://npmjs.com/package/tiny-inflate), and [`UZIP.js`](https://github.com/photopea/UZIP.js) in performance benchmarks while being multiple times more lightweight. Its compression ratios are often better than even the original Zlib C library. It includes support for DEFLATE, GZIP, and Zlib data. Data compressed by `fflate` can be decompressed by other tools, and vice versa.
In addition to the base decompression and compression APIs, `fflate` supports high-speed ZIP file archiving for an extra 3 kB. In fact, the compressor, in synchronous mode, compresses both more quickly and with a higher compression ratio than most compression software (even Info-ZIP, a C program), and in asynchronous mode it can utilize multiple threads to achieve over 3x the performance of any other utility.
| | `pako` | `tiny-inflate` | `UZIP.js` | `fflate` |
|-----------------------------|--------|------------------------|-----------------------|--------------------------------|
| Decompression performance | 1x | Up to 40% slower | **Up to 40% faster** | **Up to 40% faster** |
| Compression performance | 1x | N/A | Up to 5% faster | **Up to 50% faster** |
| Base bundle size (minified) | 45.6kB | **3kB (inflate only)** | 14.2kB | 8kB **(3kB for inflate only)** |
| Compression support | ✅ | ❌ | ✅ | ✅ |
| Thread/Worker safe | ✅ | ✅ | ❌ | ✅ |
| ZIP support | ❌ | ❌ | ✅ | ✅ |
| Streaming support | ✅ | ❌ | ❌ | ✅ |
| GZIP/Zlib support | ✅ | ❌ | ❌ | ✅ |
| Doesn't hang on error | ✅ | ❌ | ❌ | ✅ |
| Multi-thread/Asynchronous | ❌ | ❌ | ❌ | ✅ |
| Uses ES Modules | ❌ | ❌ | ❌ | ✅ |
## Demo
If you'd like to try `fflate` for yourself without installing it, you can take a look at the [browser demo](https://101arrowz.github.io/fflate). Since `fflate` is a pure JavaScript library, it works in both the browser and Node.js (see [Browser support](https://github.com/101arrowz/fflate/#browser-support) for more info).
## Usage
Install `fflate`:
```sh
npm i fflate # or yarn add fflate, or pnpm add fflate
```
Import:
```js
// I will assume that you use the following for the rest of this guide
import * as fflate from 'fflate';
// However, you should import ONLY what you need to minimize bloat.
// So, if you just need GZIP compression support:
import { gzipSync } from 'fflate';
// Woo! You just saved 15 kB off your bundle with one line.
```
If your environment doesn't support ES Modules (e.g. Node.js):
```js
// Try to avoid this when using fflate in the browser, as it will import
// all of fflate's components, even those that you aren't using.
const fflate = require('fflate');
```
If you want to load from a CDN in the browser:
```html
<!--
You should use either UNPKG or jsDelivr (i.e. only one of the following)
Note that tree shaking is completely unsupported from the CDN
-->
<script src="https://unpkg.com/fflate"></script>
<script src="https://cdn.jsdelivr.net/npm/fflate/umd/index.js"></script>
<!-- Now, the global variable fflate contains the library -->
```
And use:
```js
// This is an ArrayBuffer of data
const massiveFileBuf = await fetch('/aMassiveFile').then(
res => res.arrayBuffer()
);
// To use fflate, you need a Uint8Array
const massiveFile = new Uint8Array(massiveFileBuf);
// Note that Node.js Buffers work just fine as well:
// const massiveFile = require('fs').readFileSync('aMassiveFile.txt');
// Higher level means lower performance but better compression
// The level ranges from 0 (no compression) to 9 (max compression)
// The default level is 6
const notSoMassive = fflate.zlibSync(massiveFile, { level: 9 });
const massiveAgain = fflate.unzlibSync(notSoMassive);
const gzipped = fflate.gzipSync(massiveFile, {
// GZIP-specific: the filename to use when decompressed
filename: 'aMassiveFile.txt',
// GZIP-specific: the modification time. Can be a Date, date string,
// or Unix timestamp
mtime: '9/1/16 2:00 PM'
});
```
`fflate` can autodetect a compressed file's format as well:
```js
const compressed = new Uint8Array(
await fetch('/GZIPorZLIBorDEFLATE').then(res => res.arrayBuffer())
);
// Above example with Node.js Buffers:
// Buffer.from('H4sIAAAAAAAAE8tIzcnJBwCGphA2BQAAAA==', 'base64');
const decompressed = fflate.decompressSync(compressed);
```
Using strings is easy with `fflate`'s string conversion API:
```js
const buf = fflate.strToU8('Hello world!');
// The default compression method is gzip
// Increasing mem may increase performance at the cost of memory
// The mem ranges from 0 to 12, where 4 is the default
const compressed = fflate.compressSync(buf, { level: 6, mem: 8 });
// When you need to decompress:
const decompressed = fflate.decompressSync(compressed);
const origText = fflate.strFromU8(decompressed);
console.log(origText); // Hello world!
```
If you need to use an (albeit inefficient) binary string, you can set the second argument to `true`.
```js
const buf = fflate.strToU8('Hello world!');
// The second argument, latin1, is a boolean that indicates that the data
// is not Unicode but rather should be encoded and decoded as Latin-1.
const compressedString = fflate.strFromU8(
fflate.compressSync(buf),
true
);
const decompressed = fflate.decompressSync(
fflate.strToU8(compressedString, true)
);
const origText = fflate.strFromU8(decompressed);
console.log(origText); // Hello world!
```
You can use streams as well to incrementally add data to be compressed or decompressed:
```js
// This example uses synchronous streams, but for the best experience
// you'll definitely want to use asynchronous streams.
let outStr = '';
const gzipStream = new fflate.Gzip({ level: 9 }, (chunk, isLast) => {
// accumulate in an inefficient binary string (just an example)
outStr += fflate.strFromU8(chunk, true);
});
// You can also attach the data handler separately if you don't want to
// do so in the constructor.
gzipStream.ondata = (chunk, final) => { ... }
// Since this is synchronous, all errors will be thrown by stream.push()
gzipStream.push(chunk1);
gzipStream.push(chunk2);
...
// You should mark the last chunk by using true in the second argument
// In addition to being necessary for the stream to work properly, this
// will also set the isLast parameter in the handler to true.
gzipStream.push(lastChunk, true);
console.log(outStr); // The compressed binary string is now available
// The options parameter for compression streams is optional; you can
// provide one parameter (the handler) or none at all if you set
// deflateStream.ondata later.
const deflateStream = new fflate.Deflate((chunk, final) => {
console.log(chunk, final);
});
const inflateStream = new fflate.Inflate();
inflateStream.ondata = (decompressedChunk, final) => {
// print out a string of the compressed data
console.log(fflate.strFromU8(decompressedChunk));
};
// Decompress streams auto-detect the compression method, as the
// non-streaming decompress() method does.
const dcmpStrm = new fflate.Decompress((chunk, final) => {
console.log(
'This chunk was encoded in either GZIP, Zlib, or DEFLATE',
chunk
);
});
```
You can create multi-file ZIP archives easily as well. Note that by default, compression is enabled for all files, which is not useful when ZIPping many PNGs, JPEGs, PDFs, etc. because those formats are already compressed. You should either override the level on a per-file basis or globally to avoid wasting resources.
```js
// Note that the asynchronous version (see below) runs in parallel and
// is *much* (up to 3x) faster for larger archives.
const zipped = fflate.zipSync({
// Directories can be nested structures, as in an actual filesystem
'dir1': {
'nested': {
// You can use Unicode in filenames
'你好.txt': std('Hey there!')
},
// You can also manually write out a directory path
'other/tmp.txt': new Uint8Array([97, 98, 99, 100])
},
// You can also provide compression options
'myImageData.bmp': [aMassiveFile, { level: 9, mem: 12 }],
// PNG is pre-compressed; no need to waste time
'superTinyFile.png': [aPNGFile, { level: 0 }]
}, {
// These options are the defaults for all files, but file-specific
// options take precedence.
level: 1
});
// If you write the zipped data to myzip.zip and unzip, the folder
// structure will be outputted as:
// myzip.zip (original file)
// dir1
// |-> nested
// | |-> 你好.txt
// |-> other
// | |-> tmp.txt
// myImageData.bmp
// superTinyFile.bin
// When decompressing, folders are not nested; all filepaths are fully
// written out in the keys. For example, the return value may be:
// { 'nested/directory/a2.txt': Uint8Array(2) [97, 97] })
const decompressed = fflate.unzipSync(zipped);
```
As you may have guessed, there is an asynchronous version of every method as well. Unlike most libraries, this will cause the compression or decompression run in a separate thread entirely and automatically by using Web (or Node) Workers. This means that the processing will not block the main thread at all.
Note that there is a significant initial overhead to using workers of about 70ms, so it's best to avoid the asynchronous API unless necessary. However, if you're compressing multiple large files at once, or the synchronous API causes the main thread to hang for too long, the callback APIs are an order of magnitude better.
```js
import { gzip, zlib, AsyncGzip, zip, strFromU8 } from 'fflate';
// Workers will work in almost any browser (even IE11!)
// However, they fail below Node v12 without the --experimental-worker
// CLI flag, and will fail entirely on Node below v10.
// All of the async APIs use a node-style callback as so:
const terminate = gzip(aMassiveFile, (err, data) => {
if (err) {
// The compressed data was likely corrupt, so we have to handle
// the error.
return;
}
// Use data however you like
console.log(data.length);
});
if (needToCancel) {
// The return value of any of the asynchronous APIs is a function that,
// when called, will immediately cancel the operation. The callback
// will not be called.
terminate();
}
// If you wish to provide options, use the second argument.
// The consume option will render the data inside aMassiveFile unusable,
// but can dramatically improve performance and reduce memory usage.
zlib(aMassiveFile, { consume: true, level: 9 }, (err, data) => {
// Use the data
});
// Asynchronous streams are similar to synchronous streams, but the
// handler has the error that occurred (if any) as the first parameter,
// and they don't block the main thread.
// Additionally, any buffers that are pushed in will be consumed and
// rendered unusable; if you need to use a buffer you push in, you
// should clone it first.
const gzs = new AsyncGzip({ level: 9, mem: 12, filename: 'hello.txt' });
let wasCallbackCalled = false;
gzs.ondata = (err, chunk, final) => {
// Note the new err parameter
if (err) {
// Note that after this occurs, the stream becomes corrupt and must
// be discarded. You can't continue pushing chunks and expect it to
// work.
console.error(err);
return;
}
wasCallbackCalled = true;
}
gzs.push(chunk);
// Since the stream is asynchronous, the callback will not be called
// immediately. If such behavior is absolutely necessary (it shouldn't
// be), use synchronous streams.
console.log(wasCallbackCalled) // false
// To terminate an asynchronous stream's internal worker, call
// stream.terminate().
gzs.terminate();
// This is way faster than zipSync because the compression of multiple
// files runs in parallel. In fact, the fact that it's parallelized
// makes it faster than most standalone ZIP CLIs. The effect is most
// significant for multiple large files; less so for many small ones.
zip({ f1: aMassiveFile, 'f2.txt': anotherMassiveFile }, (err, data) => {
// Save the ZIP file
});
// unzip is the only async function without support for consume option
// Also parallelized, so unzip is also often much faster than unzipSync
unzip(aMassiveZIPFile, (err, unzipped) => {
// If the archive has data.xml, log it here
console.log(unzipped['data.xml']);
// Conversion to string
console.log(strFromU8(unzipped['data.xml']))
})
```
See the [documentation](https://github.com/101arrowz/fflate/blob/master/docs/README.md) for more detailed information about the API.
## Bundle size estimates
Since `fflate` uses ES Modules, this table should give you a general idea of `fflate`'s bundle size for the features you need. The maximum bundle size that is possible with `fflate` is about 22kB if you use every single feature, but feature parity with `pako` is only around 10kB (as opposed to 45kB from `pako`). If your bundle size increases dramatically after adding `fflate`, please [create an issue](https://github.com/101arrowz/fflate/issues/new).
| Feature | Bundle size (minified) | Nearest competitor |
|-------------------------|--------------------------------|------------------------|
| Decompression | 3kB | `tiny-inflate` |
| Compression | 5kB | `UZIP.js`, 184% larger |
| Async decompression | 4kB (1kB + raw decompression) | N/A |
| Async compression | 5kB (1kB + raw compression) | N/A |
| ZIP decompression | 5kB (2kB + raw decompression) | `UZIP.js`, 184% larger |
| ZIP compression | 7kB (2kB + raw compression) | `UZIP.js`, 103% larger |
| GZIP/Zlib decompression | 4kB (1kB + raw decompression) | `pako`, 1040% larger |
| GZIP/Zlib compression | 5kB (1kB + raw compression) | `pako`, 812% larger |
| Streaming decompression | 4kB (1kB + raw decompression) | `pako`, 1040% larger |
| Streaming compression | 5kB (1kB + raw compression) | `pako`, 812% larger |
## What makes `fflate` so fast?
Many JavaScript compression/decompression libraries exist. However, the most popular one, [`pako`](https://npmjs.com/package/pako), is merely a clone of Zlib rewritten nearly line-for-line in JavaScript. Although it is by no means poorly made, `pako` doesn't recognize the many differences between JavaScript and C, and therefore is suboptimal for performance. Moreover, even when minified, the library is 45 kB; it may not seem like much, but for anyone concerned with optimizing bundle size (especially library authors), it's more weight than necessary.
Note that there exist some small libraries like [`tiny-inflate`](https://npmjs.com/package/tiny-inflate) for solely decompression, and with a minified size of 3 kB, it can be appealing; however, its performance is lackluster, typically 40% worse than `pako` in my tests.
[`UZIP.js`](https://github.com/photopea/UZIP.js) is both faster (by up to 40%) and smaller (14 kB minified) than `pako`, and it contains a variety of innovations that make it excellent for both performance and compression ratio. However, the developer made a variety of tiny mistakes and inefficient design choices that make it imperfect. Moreover, it does not support GZIP or Zlib data directly; one must remove the headers manually to use `UZIP.js`.
So what makes `fflate` different? It takes the brilliant innovations of `UZIP.js` and optimizes them while adding direct support for GZIP and Zlib data. And unlike all of the above libraries, it uses ES Modules to allow for partial builds through tree shaking, meaning that it can rival even `tiny-inflate` in size while maintaining excellent performance. The end result is a library that, in total, weighs 8kB minified for the core build (3kB for decompression only and 5kB for compression only), is about 15% faster than `UZIP.js` or up to 60% faster than `pako`, and achieves the same or better compression ratio than the rest.
Before you decide that `fflate` is the end-all compression library, you should note that JavaScript simply cannot rival the performance of a compiled language. If you're willing to have 160 kB of extra weight and [much less browser support](https://caniuse.com/wasm), you can achieve more performance than `fflate` with a WASM build of Zlib like [`wasm-flate`](https://www.npmjs.com/package/wasm-flate). And if you're only using Node.js, just use the [native Zlib bindings](https://nodejs.org/api/zlib.html) that offer the best performance. Though note that even against these compiled libraries, `fflate` is only around 30% slower in decompression and 10% slower in compression, and can still achieve better compression ratios!
## Browser support
`fflate` makes heavy use of typed arrays (`Uint8Array`, `Uint16Array`, etc.). Typed arrays can be polyfilled at the cost of performance, but the most recent browser that doesn't support them [is from 2011](https://caniuse.com/typedarrays), so I wouldn't bother.
The asynchronous APIs also use `Worker`, which is not supported in a few browsers (however, the vast majority of browsers that support typed arrays support `Worker`).
Other than that, `fflate` is completely ES3, meaning you probably won't even need a bundler to use it.
## Testing
You can validate the performance of `fflate` with `npm`/`yarn`/`pnpm` `test`. It validates that the module is working as expected, ensures the outputs are no more than 5% larger than competitors at max compression, and outputs performance metrics to `test/results`.
Note that the time it takes for the CLI to show the completion of each test is not representative of the time each package took, so please check the JSON output if you want accurate masurements.
## License
This software is [MIT Licensed](./LICENSE), with special exemptions for projects
and organizations as noted below:
- [SheetJS](https://github.com/SheetJS/) is exempt from MIT licensing and may
license any source code from this software under the BSD Zero Clause License

File diff suppressed because it is too large Load Diff

1789
extensions/Excel转JSON/node_modules/fflate/esm/index.mjs generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,746 @@
/**
* Options for compressing data into a DEFLATE format
*/
export interface DeflateOptions {
/**
* The level of compression to use, ranging from 0-9.
*
* 0 will store the data without compression.
* 1 is fastest but compresses the worst, 9 is slowest but compresses the best.
* The default level is 6.
*
* Typically, binary data benefits much more from higher values than text data.
* In both cases, higher values usually take disproportionately longer than the reduction in final size that results.
*
* For example, a 1 MB text file could:
* - become 1.01 MB with level 0 in 1ms
* - become 400 kB with level 1 in 10ms
* - become 320 kB with level 9 in 100ms
*/
level?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
/**
* The memory level to use, ranging from 0-12. Increasing this increases speed and compression ratio at the cost of memory.
*
* Note that this is exponential: while level 0 uses 4 kB, level 4 uses 64 kB, level 8 uses 1 MB, and level 12 uses 16 MB.
* It is recommended not to lower the value below 4, since that tends to hurt performance.
* In addition, values above 8 tend to help very little on most data and can even hurt performance.
*
* The default value is automatically determined based on the size of the input data.
*/
mem?: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
}
/**
* Options for compressing data into a GZIP format
*/
export interface GzipOptions extends DeflateOptions {
/**
* When the file was last modified. Defaults to the current time.
* If you're using GZIP, set this to 0 to avoid revealing a modification date entirely.
*/
mtime?: Date | string | number;
/**
* The filename of the data. If the `gunzip` command is used to decompress the data, it will output a file
* with this name instead of the name of the compressed file.
*/
filename?: string;
}
/**
* Options for compressing data into a Zlib format
*/
export interface ZlibOptions extends DeflateOptions {
}
/**
* Handler for data (de)compression streams
* @param data The data output from the stream processor
* @param final Whether this is the final block
*/
export declare type FlateStreamHandler = (data: Uint8Array, final: boolean) => void;
/**
* Handler for asynchronous data (de)compression streams
* @param err Any error that occurred
* @param data The data output from the stream processor
* @param final Whether this is the final block
*/
export declare type AsyncFlateStreamHandler = (err: Error, data: Uint8Array, final: boolean) => void;
/**
* Callback for asynchronous (de)compression methods
* @param err Any error that occurred
* @param data The resulting data. Only present if `err` is null
*/
export declare type FlateCallback = (err: Error, data: Uint8Array) => void;
interface AsyncOptions {
/**
* Whether or not to "consume" the source data. This will make the typed array/buffer you pass in
* unusable but will increase performance and reduce memory usage.
*/
consume?: boolean;
}
/**
* Options for compressing data asynchronously into a DEFLATE format
*/
export interface AsyncDeflateOptions extends DeflateOptions, AsyncOptions {
}
/**
* Options for decompressing DEFLATE data asynchronously
*/
export interface AsyncInflateOptions extends AsyncOptions {
/**
* The original size of the data. Currently, the asynchronous API disallows
* writing into a buffer you provide; the best you can do is provide the
* size in bytes and be given back a new typed array.
*/
size?: number;
}
/**
* Options for compressing data asynchronously into a GZIP format
*/
export interface AsyncGzipOptions extends GzipOptions, AsyncOptions {
}
/**
* Options for decompressing GZIP data asynchronously
*/
export interface AsyncGunzipOptions extends AsyncOptions {
}
/**
* Options for compressing data asynchronously into a Zlib format
*/
export interface AsyncZlibOptions extends ZlibOptions, AsyncOptions {
}
/**
* Options for decompressing Zlib data asynchronously
*/
export interface AsyncUnzlibOptions extends AsyncInflateOptions {
}
/**
* A terminable compression/decompression process
*/
export interface AsyncTerminable {
/**
* Terminates the worker thread immediately. The callback will not be called.
*/
(): void;
}
/**
* Streaming DEFLATE compression
*/
export declare class Deflate {
/**
* Creates a DEFLATE stream
* @param opts The compression options
* @param cb The callback to call whenever data is deflated
*/
constructor(opts: DeflateOptions, cb?: FlateStreamHandler);
constructor(cb?: FlateStreamHandler);
private o;
private d;
/**
* The handler to call whenever data is available
*/
ondata: FlateStreamHandler;
private p;
/**
* Pushes a chunk to be deflated
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
}
/**
* Asynchronous streaming DEFLATE compression
*/
export declare class AsyncDeflate {
/**
* The handler to call whenever data is available
*/
ondata: AsyncFlateStreamHandler;
/**
* Creates an asynchronous DEFLATE stream
* @param opts The compression options
* @param cb The callback to call whenever data is deflated
*/
constructor(opts: DeflateOptions, cb?: AsyncFlateStreamHandler);
/**
* Creates an asynchronous DEFLATE stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb?: AsyncFlateStreamHandler);
/**
* Pushes a chunk to be deflated
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
/**
* A method to terminate the stream's internal worker. Subsequent calls to
* push() will silently fail.
*/
terminate: AsyncTerminable;
}
/**
* Asynchronously compresses data with DEFLATE without any wrapper
* @param data The data to compress
* @param opts The compression options
* @param cb The function to be called upon compression completion
* @returns A function that can be used to immediately terminate the compression
*/
export declare function deflate(data: Uint8Array, opts: AsyncDeflateOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchronously compresses data with DEFLATE without any wrapper
* @param data The data to compress
* @param cb The function to be called upon compression completion
*/
export declare function deflate(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
/**
* Compresses data with DEFLATE without any wrapper
* @param data The data to compress
* @param opts The compression options
* @returns The deflated version of the data
*/
export declare function deflateSync(data: Uint8Array, opts?: DeflateOptions): Uint8Array;
/**
* Streaming DEFLATE decompression
*/
export declare class Inflate {
/**
* Creates an inflation stream
* @param cb The callback to call whenever data is inflated
*/
constructor(cb?: FlateStreamHandler);
private s;
private o;
private p;
private d;
/**
* The handler to call whenever data is available
*/
ondata: FlateStreamHandler;
private e;
private c;
/**
* Pushes a chunk to be inflated
* @param chunk The chunk to push
* @param final Whether this is the final chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
}
/**
* Asynchronous streaming DEFLATE decompression
*/
export declare class AsyncInflate {
/**
* The handler to call whenever data is available
*/
ondata: AsyncFlateStreamHandler;
/**
* Creates an asynchronous inflation stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb?: AsyncFlateStreamHandler);
/**
* Pushes a chunk to be inflated
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
/**
* A method to terminate the stream's internal worker. Subsequent calls to
* push() will silently fail.
*/
terminate: AsyncTerminable;
}
/**
* Asynchronously expands DEFLATE data with no wrapper
* @param data The data to decompress
* @param opts The decompression options
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function inflate(data: Uint8Array, opts: AsyncInflateOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchronously expands DEFLATE data with no wrapper
* @param data The data to decompress
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function inflate(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
/**
* Expands DEFLATE data with no wrapper
* @param data The data to decompress
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
* @returns The decompressed version of the data
*/
export declare function inflateSync(data: Uint8Array, out?: Uint8Array): Uint8Array;
/**
* Streaming GZIP compression
*/
export declare class Gzip {
private c;
private l;
private v;
private o;
/**
* The handler to call whenever data is available
*/
ondata: FlateStreamHandler;
/**
* Creates a GZIP stream
* @param opts The compression options
* @param cb The callback to call whenever data is deflated
*/
constructor(opts: GzipOptions, cb?: FlateStreamHandler);
/**
* Creates a GZIP stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb?: FlateStreamHandler);
/**
* Pushes a chunk to be GZIPped
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
private p;
}
/**
* Asynchronous streaming GZIP compression
*/
export declare class AsyncGzip {
/**
* The handler to call whenever data is available
*/
ondata: AsyncFlateStreamHandler;
/**
* Creates an asynchronous GZIP stream
* @param opts The compression options
* @param cb The callback to call whenever data is deflated
*/
constructor(opts: GzipOptions, cb?: AsyncFlateStreamHandler);
/**
* Creates an asynchronous GZIP stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb?: AsyncFlateStreamHandler);
/**
* Pushes a chunk to be GZIPped
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
/**
* A method to terminate the stream's internal worker. Subsequent calls to
* push() will silently fail.
*/
terminate: AsyncTerminable;
}
/**
* Asynchronously compresses data with GZIP
* @param data The data to compress
* @param opts The compression options
* @param cb The function to be called upon compression completion
* @returns A function that can be used to immediately terminate the compression
*/
export declare function gzip(data: Uint8Array, opts: AsyncGzipOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchronously compresses data with GZIP
* @param data The data to compress
* @param cb The function to be called upon compression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function gzip(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
/**
* Compresses data with GZIP
* @param data The data to compress
* @param opts The compression options
* @returns The gzipped version of the data
*/
export declare function gzipSync(data: Uint8Array, opts?: GzipOptions): Uint8Array;
/**
* Streaming GZIP decompression
*/
export declare class Gunzip {
private v;
private p;
/**
* The handler to call whenever data is available
*/
ondata: FlateStreamHandler;
/**
* Creates a GUNZIP stream
* @param cb The callback to call whenever data is inflated
*/
constructor(cb?: FlateStreamHandler);
/**
* Pushes a chunk to be GUNZIPped
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
}
/**
* Asynchronous streaming GZIP decompression
*/
export declare class AsyncGunzip {
/**
* The handler to call whenever data is available
*/
ondata: AsyncFlateStreamHandler;
/**
* Creates an asynchronous GUNZIP stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb: AsyncFlateStreamHandler);
/**
* Pushes a chunk to be GUNZIPped
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
/**
* A method to terminate the stream's internal worker. Subsequent calls to
* push() will silently fail.
*/
terminate: AsyncTerminable;
}
/**
* Asynchronously expands GZIP data
* @param data The data to decompress
* @param opts The decompression options
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function gunzip(data: Uint8Array, opts: AsyncGunzipOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchronously expands GZIP data
* @param data The data to decompress
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function gunzip(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
/**
* Expands GZIP data
* @param data The data to decompress
* @param out Where to write the data. GZIP already encodes the output size, so providing this doesn't save memory.
* @returns The decompressed version of the data
*/
export declare function gunzipSync(data: Uint8Array, out?: Uint8Array): Uint8Array;
/**
* Streaming Zlib compression
*/
export declare class Zlib {
private c;
private v;
private o;
/**
* The handler to call whenever data is available
*/
ondata: FlateStreamHandler;
/**
* Creates a Zlib stream
* @param opts The compression options
* @param cb The callback to call whenever data is deflated
*/
constructor(opts: ZlibOptions, cb?: FlateStreamHandler);
/**
* Creates a Zlib stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb?: FlateStreamHandler);
/**
* Pushes a chunk to be zlibbed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
private p;
}
/**
* Asynchronous streaming Zlib compression
*/
export declare class AsyncZlib {
/**
* The handler to call whenever data is available
*/
ondata: AsyncFlateStreamHandler;
/**
* Creates an asynchronous DEFLATE stream
* @param opts The compression options
* @param cb The callback to call whenever data is deflated
*/
constructor(opts: ZlibOptions, cb?: AsyncFlateStreamHandler);
/**
* Creates an asynchronous DEFLATE stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb?: AsyncFlateStreamHandler);
/**
* Pushes a chunk to be deflated
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
/**
* A method to terminate the stream's internal worker. Subsequent calls to
* push() will silently fail.
*/
terminate: AsyncTerminable;
}
/**
* Asynchronously compresses data with Zlib
* @param data The data to compress
* @param opts The compression options
* @param cb The function to be called upon compression completion
*/
export declare function zlib(data: Uint8Array, opts: AsyncZlibOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchronously compresses data with Zlib
* @param data The data to compress
* @param cb The function to be called upon compression completion
* @returns A function that can be used to immediately terminate the compression
*/
export declare function zlib(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
/**
* Compress data with Zlib
* @param data The data to compress
* @param opts The compression options
* @returns The zlib-compressed version of the data
*/
export declare function zlibSync(data: Uint8Array, opts?: ZlibOptions): Uint8Array;
/**
* Streaming Zlib decompression
*/
export declare class Unzlib {
private v;
private p;
/**
* The handler to call whenever data is available
*/
ondata: FlateStreamHandler;
/**
* Creates a Zlib decompression stream
* @param cb The callback to call whenever data is inflated
*/
constructor(cb?: FlateStreamHandler);
/**
* Pushes a chunk to be unzlibbed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
}
/**
* Asynchronous streaming Zlib decompression
*/
export declare class AsyncUnzlib {
/**
* The handler to call whenever data is available
*/
ondata: AsyncFlateStreamHandler;
/**
* Creates an asynchronous Zlib decompression stream
* @param cb The callback to call whenever data is deflated
*/
constructor(cb?: AsyncFlateStreamHandler);
/**
* Pushes a chunk to be decompressed from Zlib
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
/**
* A method to terminate the stream's internal worker. Subsequent calls to
* push() will silently fail.
*/
terminate: AsyncTerminable;
}
/**
* Asynchronously expands Zlib data
* @param data The data to decompress
* @param opts The decompression options
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function unzlib(data: Uint8Array, opts: AsyncGunzipOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchronously expands Zlib data
* @param data The data to decompress
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function unzlib(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
/**
* Expands Zlib data
* @param data The data to decompress
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
* @returns The decompressed version of the data
*/
export declare function unzlibSync(data: Uint8Array, out?: Uint8Array): Uint8Array;
export { gzip as compress, AsyncGzip as AsyncCompress };
export { gzipSync as compressSync, Gzip as Compress };
/**
* Streaming GZIP, Zlib, or raw DEFLATE decompression
*/
export declare class Decompress {
private G;
private I;
private Z;
/**
* Creates a decompression stream
* @param cb The callback to call whenever data is decompressed
*/
constructor(cb?: FlateStreamHandler);
private s;
/**
* The handler to call whenever data is available
*/
ondata: FlateStreamHandler;
private p;
/**
* Pushes a chunk to be decompressed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
}
/**
* Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression
*/
export declare class AsyncDecompress {
private G;
private I;
private Z;
/**
* Creates an asynchronous decompression stream
* @param cb The callback to call whenever data is decompressed
*/
constructor(cb?: AsyncFlateStreamHandler);
/**
* The handler to call whenever data is available
*/
ondata: AsyncFlateStreamHandler;
/**
* Pushes a chunk to be decompressed
* @param chunk The chunk to push
* @param final Whether this is the last chunk
*/
push(chunk: Uint8Array, final?: boolean): void;
}
/**
* Asynchrononously expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
* @param data The data to decompress
* @param opts The decompression options
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function decompress(data: Uint8Array, opts: AsyncInflateOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchrononously expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
* @param data The data to decompress
* @param cb The function to be called upon decompression completion
* @returns A function that can be used to immediately terminate the decompression
*/
export declare function decompress(data: Uint8Array, cb: FlateCallback): AsyncTerminable;
/**
* Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format
* @param data The data to decompress
* @param out Where to write the data. Saves memory if you know the decompressed size and provide an output buffer of that length.
* @returns The decompressed version of the data
*/
export declare function decompressSync(data: Uint8Array, out?: Uint8Array): Uint8Array;
/**
* Options for creating a ZIP archive
*/
export interface ZipOptions extends DeflateOptions, Pick<GzipOptions, 'mtime'> {
}
/**
* Options for asynchronously creating a ZIP archive
*/
export interface AsyncZipOptions extends AsyncDeflateOptions, Pick<AsyncGzipOptions, 'mtime'> {
}
/**
* Options for asynchronously expanding a ZIP archive
*/
export interface AsyncUnzipOptions extends AsyncOptions {
}
/**
* A file that can be used to create a ZIP archive
*/
export declare type ZippableFile = Uint8Array | [Uint8Array, ZipOptions];
/**
* A file that can be used to asynchronously create a ZIP archive
*/
export declare type AsyncZippableFile = Uint8Array | [Uint8Array, AsyncZipOptions];
/**
* The complete directory structure of a ZIPpable archive
*/
export interface Zippable extends Record<string, Zippable | ZippableFile> {
}
/**
* The complete directory structure of an asynchronously ZIPpable archive
*/
export interface AsyncZippable extends Record<string, AsyncZippable | AsyncZippableFile> {
}
/**
* An unzipped archive. The full path of each file is used as the key,
* and the file is the value
*/
export interface Unzipped extends Record<string, Uint8Array> {
}
/**
* Callback for asynchronous ZIP decompression
* @param err Any error that occurred
* @param data The decompressed ZIP archive
*/
export declare type UnzipCallback = (err: Error, data: Unzipped) => void;
/**
* Converts a string into a Uint8Array for use with compression/decompression methods
* @param str The string to encode
* @param latin1 Whether or not to interpret the data as Latin-1. This should
* not need to be true unless decoding a binary string.
* @returns The string encoded in UTF-8/Latin-1 binary
*/
export declare function strToU8(str: string, latin1?: boolean): Uint8Array;
/**
* Converts a Uint8Array to a string
* @param dat The data to decode to string
* @param latin1 Whether or not to interpret the data as Latin-1. This should
* not need to be true unless encoding to binary string.
* @returns The original UTF-8/Latin-1 string
*/
export declare function strFromU8(dat: Uint8Array, latin1?: boolean): string;
/**
* Asynchronously creates a ZIP file
* @param data The directory structure for the ZIP archive
* @param opts The main options, merged with per-file options
* @param cb The callback to call with the generated ZIP archive
* @returns A function that can be used to immediately terminate the compression
*/
export declare function zip(data: AsyncZippable, opts: AsyncZipOptions, cb: FlateCallback): AsyncTerminable;
/**
* Asynchronously creates a ZIP file
* @param data The directory structure for the ZIP archive
* @param cb The callback to call with the generated ZIP archive
* @returns A function that can be used to immediately terminate the compression
*/
export declare function zip(data: AsyncZippable, cb: FlateCallback): AsyncTerminable;
/**
* Synchronously creates a ZIP file. Prefer using `zip` for better performance
* with more than one file.
* @param data The directory structure for the ZIP archive
* @param opts The main options, merged with per-file options
* @returns The generated ZIP archive
*/
export declare function zipSync(data: Zippable, opts?: ZipOptions): Uint8Array;
/**
* Asynchronously decompresses a ZIP archive
* @param data The raw compressed ZIP file
* @param cb The callback to call with the decompressed files
* @returns A function that can be used to immediately terminate the unzipping
*/
export declare function unzip(data: Uint8Array, cb: UnzipCallback): AsyncTerminable;
/**
* Synchronously decompresses a ZIP archive. Prefer using `unzip` for better
* performance with more than one file.
* @param data The raw compressed ZIP file
* @returns The decompressed files
*/
export declare function unzipSync(data: Uint8Array): Unzipped;

1793
extensions/Excel转JSON/node_modules/fflate/lib/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,21 @@
"use strict";
exports.__esModule = true;
// Mediocre shim
var worker_threads_1 = require("worker_threads");
var workerAdd = ";var __w=require('worker_threads');__w.parentPort.on('message',function(m){onmessage({data:m})}),postMessage=function(m,t){__w.parentPort.postMessage(m,t)},close=process.exit;self=global";
exports["default"] = (function (c, _, msg, transfer, cb) {
var done = false;
var w = new worker_threads_1.Worker(c + workerAdd, { eval: true })
.on('error', function (e) { return cb(e, null); })
.on('message', function (m) { return cb(null, m); })
.on('exit', function (c) {
if (c && !done)
cb(new Error('Exited with code ' + c), null);
});
w.postMessage(msg, transfer);
w.terminate = function () {
done = true;
return worker_threads_1.Worker.prototype.terminate.call(w);
};
return w;
});

View File

@@ -0,0 +1,11 @@
"use strict";
exports.__esModule = true;
var ch2 = {};
exports["default"] = (function (c, id, msg, transfer, cb) {
var u = ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([c], { type: 'text/javascript' })));
var w = new Worker(u);
w.onerror = function (e) { return cb(e.error, null); };
w.onmessage = function (e) { return cb(null, e.data); };
w.postMessage(msg, transfer);
return w;
});

View File

@@ -0,0 +1,117 @@
{
"_args": [
[
"fflate@0.3.11",
"/Users/wuyu/Desktop/61/Git/h5game_ailesson_v2.4/packages/excel_to_json"
]
],
"_from": "fflate@0.3.11",
"_id": "fflate@0.3.11",
"_inBundle": false,
"_integrity": "sha1-LEQNcYD964GeZImNiFivMnsEKl0=",
"_location": "/fflate",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "fflate@0.3.11",
"name": "fflate",
"escapedName": "fflate",
"rawSpec": "0.3.11",
"saveSpec": null,
"fetchSpec": "0.3.11"
},
"_requiredBy": [
"/node-xlsx/xlsx"
],
"_resolved": "https://registry.nlark.com/fflate/download/fflate-0.3.11.tgz",
"_spec": "0.3.11",
"_where": "/Users/wuyu/Desktop/61/Git/h5game_ailesson_v2.4/packages/excel_to_json",
"alias": {
"react": "preact/compat",
"react-dom": "preact/compat",
"react-dom/test-utils": "preact/test-utils"
},
"author": {
"name": "Arjun Barrett"
},
"browser": {
"./lib/node-worker.js": "./lib/worker.js",
"./esm/index.mjs": "./esm/browser.js"
},
"bugs": {
"url": "https://github.com/101arrowz/fflate/issues"
},
"description": "High performance (de)compression in an 8kB package",
"devDependencies": {
"@types/node": "^14.11.2",
"@types/pako": "*",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"jszip": "^3.5.0",
"pako": "*",
"parcel": "^2.0.0-nightly.440",
"parcel-config-precache-manifest": "^0.0.3",
"preact": "^10.5.5",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"rmwc": "^6.1.4",
"simple-git": "^2.22.0",
"terser": "^5.3.8",
"tiny-inflate": "*",
"ts-node": "^9.0.0",
"typedoc": "^0.17.0-3",
"typedoc-plugin-markdown": "^3.0.2",
"typescript": "^4.0.2",
"uvu": "^0.3.3",
"uzip": "*"
},
"homepage": "https://github.com/101arrowz/fflate#readme",
"jsdelivr": "./umd/index.js",
"keywords": [
"gzip",
"gunzip",
"deflate",
"inflate",
"compression",
"decompression",
"zlib",
"pako",
"jszip",
"browser",
"node.js",
"tiny",
"zip",
"unzip",
"non-blocking"
],
"license": "MIT",
"main": "./lib/index.js",
"module": "./esm/index.mjs",
"name": "fflate",
"repository": {
"type": "git",
"url": "git+https://github.com/101arrowz/fflate.git"
},
"scripts": {
"build": "yarn build:lib && yarn build:docs && yarn build:rewrite && yarn build:demo",
"build:demo": "tsc --project tsconfig.demo.json && parcel build demo/index.html --public-url \"./\" && SC=cpGHPages yarn script",
"build:docs": "typedoc --mode library --plugin typedoc-plugin-markdown --hideProjectName --hideBreadcrumbs --readme none --disableSources --excludePrivate --excludeProtected --out docs/ src/index.ts",
"build:lib": "tsc && tsc --project tsconfig.esm.json && yarn build:umd",
"build:rewrite": "SC=rewriteBuilds yarn script",
"build:umd": "SC=buildUMD yarn script",
"prepack": "yarn build && yarn test",
"script": "node -r ts-node/register scripts/$SC.ts",
"test": "TS_NODE_PROJECT=test/tsconfig.json uvu -b -r ts-node/register test"
},
"sideEffects": false,
"targets": {
"main": false,
"module": false,
"browser": false,
"types": false
},
"types": "./lib/index.d.ts",
"unpkg": "./umd/index.js",
"version": "0.3.11"
}

File diff suppressed because one or more lines are too long