@nocobase/plugin-multi-portal 2.2.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +107 -0
- package/README.md +14 -0
- package/client-v2.d.ts +2 -0
- package/client-v2.js +1 -0
- package/client.d.ts +2 -0
- package/client.js +1 -0
- package/dist/client/index.d.ts +9 -0
- package/dist/client/index.js +10 -0
- package/dist/client/locale.d.ts +10 -0
- package/dist/client/models/index.d.ts +11 -0
- package/dist/client/plugin.d.ts +13 -0
- package/dist/client-v2/354.ead3e96143164cd5.js +10 -0
- package/dist/client-v2/499.ef2ff0c022687485.js +10 -0
- package/dist/client-v2/778.23ba409a924ee34a.js +10 -0
- package/dist/client-v2/845.f2b0ce44ae4be707.js +10 -0
- package/dist/client-v2/entryActions/PortalEntryActionModel.d.ts +52 -0
- package/dist/client-v2/entryActions/portalEntryActionStore.d.ts +36 -0
- package/dist/client-v2/entryActions/registerPortalEntryActions.d.ts +10 -0
- package/dist/client-v2/entryActions/types.d.ts +41 -0
- package/dist/client-v2/entryActions/url.d.ts +10 -0
- package/dist/client-v2/index.d.ts +9 -0
- package/dist/client-v2/index.js +10 -0
- package/dist/client-v2/layoutRegistration.d.ts +38 -0
- package/dist/client-v2/locale.d.ts +13 -0
- package/dist/client-v2/models/MultiPortalBlockModel.d.ts +13 -0
- package/dist/client-v2/models/MultiPortalMobilePageModels.d.ts +34 -0
- package/dist/client-v2/pages/MultiPortalsPage.d.ts +80 -0
- package/dist/client-v2/permissions/MultiPortalPermissionsTab.d.ts +21 -0
- package/dist/client-v2/permissions/multiPortalPermissions.d.ts +12 -0
- package/dist/client-v2/plugin.d.ts +13 -0
- package/dist/client-v2/routeRepositoryScope.d.ts +11 -0
- package/dist/client-v2/routeUrl.d.ts +18 -0
- package/dist/externalVersion.js +25 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +48 -0
- package/dist/locale/en-US.json +82 -0
- package/dist/locale/zh-CN.json +82 -0
- package/dist/node_modules/tar/dist/commonjs/create.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/create.js +82 -0
- package/dist/node_modules/tar/dist/commonjs/cwd-error.d.ts +8 -0
- package/dist/node_modules/tar/dist/commonjs/cwd-error.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/extract.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/extract.js +88 -0
- package/dist/node_modules/tar/dist/commonjs/get-write-flag.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/get-write-flag.js +32 -0
- package/dist/node_modules/tar/dist/commonjs/header.d.ts +53 -0
- package/dist/node_modules/tar/dist/commonjs/header.js +312 -0
- package/dist/node_modules/tar/dist/commonjs/index.d.ts +20 -0
- package/dist/node_modules/tar/dist/commonjs/index.js +64 -0
- package/dist/node_modules/tar/dist/commonjs/index.min.js +1 -0
- package/dist/node_modules/tar/dist/commonjs/large-numbers.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/large-numbers.js +99 -0
- package/dist/node_modules/tar/dist/commonjs/list.d.ts +7 -0
- package/dist/node_modules/tar/dist/commonjs/list.js +145 -0
- package/dist/node_modules/tar/dist/commonjs/make-command.d.ts +49 -0
- package/dist/node_modules/tar/dist/commonjs/make-command.js +52 -0
- package/dist/node_modules/tar/dist/commonjs/mkdir.d.ts +25 -0
- package/dist/node_modules/tar/dist/commonjs/mkdir.js +187 -0
- package/dist/node_modules/tar/dist/commonjs/mode-fix.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/mode-fix.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-unicode.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-unicode.js +38 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/normalize-windows-path.js +12 -0
- package/dist/node_modules/tar/dist/commonjs/options.d.ts +596 -0
- package/dist/node_modules/tar/dist/commonjs/options.js +66 -0
- package/dist/node_modules/tar/dist/commonjs/pack.d.ts +105 -0
- package/dist/node_modules/tar/dist/commonjs/pack.js +545 -0
- package/dist/node_modules/tar/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/dist/commonjs/parse.d.ts +85 -0
- package/dist/node_modules/tar/dist/commonjs/parse.js +610 -0
- package/dist/node_modules/tar/dist/commonjs/path-reservations.d.ts +11 -0
- package/dist/node_modules/tar/dist/commonjs/path-reservations.js +170 -0
- package/dist/node_modules/tar/dist/commonjs/pax.d.ts +26 -0
- package/dist/node_modules/tar/dist/commonjs/pax.js +158 -0
- package/dist/node_modules/tar/dist/commonjs/process-umask.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/process-umask.js +7 -0
- package/dist/node_modules/tar/dist/commonjs/read-entry.d.ts +36 -0
- package/dist/node_modules/tar/dist/commonjs/read-entry.js +136 -0
- package/dist/node_modules/tar/dist/commonjs/replace.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/replace.js +227 -0
- package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/strip-absolute-path.js +29 -0
- package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/strip-trailing-slashes.js +18 -0
- package/dist/node_modules/tar/dist/commonjs/symlink-error.d.ts +9 -0
- package/dist/node_modules/tar/dist/commonjs/symlink-error.js +19 -0
- package/dist/node_modules/tar/dist/commonjs/types.d.ts +7 -0
- package/dist/node_modules/tar/dist/commonjs/types.js +50 -0
- package/dist/node_modules/tar/dist/commonjs/unpack.d.ts +101 -0
- package/dist/node_modules/tar/dist/commonjs/unpack.js +932 -0
- package/dist/node_modules/tar/dist/commonjs/update.d.ts +2 -0
- package/dist/node_modules/tar/dist/commonjs/update.js +33 -0
- package/dist/node_modules/tar/dist/commonjs/warn-method.d.ts +24 -0
- package/dist/node_modules/tar/dist/commonjs/warn-method.js +31 -0
- package/dist/node_modules/tar/dist/commonjs/winchars.d.ts +3 -0
- package/dist/node_modules/tar/dist/commonjs/winchars.js +14 -0
- package/dist/node_modules/tar/dist/commonjs/write-entry.d.ts +129 -0
- package/dist/node_modules/tar/dist/commonjs/write-entry.js +698 -0
- package/dist/node_modules/tar/dist/esm/create.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/create.js +76 -0
- package/dist/node_modules/tar/dist/esm/cwd-error.d.ts +8 -0
- package/dist/node_modules/tar/dist/esm/cwd-error.js +14 -0
- package/dist/node_modules/tar/dist/esm/extract.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/extract.js +49 -0
- package/dist/node_modules/tar/dist/esm/get-write-flag.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/get-write-flag.js +26 -0
- package/dist/node_modules/tar/dist/esm/header.d.ts +53 -0
- package/dist/node_modules/tar/dist/esm/header.js +275 -0
- package/dist/node_modules/tar/dist/esm/index.d.ts +20 -0
- package/dist/node_modules/tar/dist/esm/index.js +20 -0
- package/dist/node_modules/tar/dist/esm/index.min.js +4 -0
- package/dist/node_modules/tar/dist/esm/large-numbers.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/large-numbers.js +94 -0
- package/dist/node_modules/tar/dist/esm/list.d.ts +7 -0
- package/dist/node_modules/tar/dist/esm/list.js +105 -0
- package/dist/node_modules/tar/dist/esm/make-command.d.ts +49 -0
- package/dist/node_modules/tar/dist/esm/make-command.js +48 -0
- package/dist/node_modules/tar/dist/esm/mkdir.d.ts +25 -0
- package/dist/node_modules/tar/dist/esm/mkdir.js +179 -0
- package/dist/node_modules/tar/dist/esm/mode-fix.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/mode-fix.js +25 -0
- package/dist/node_modules/tar/dist/esm/normalize-unicode.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/normalize-unicode.js +34 -0
- package/dist/node_modules/tar/dist/esm/normalize-windows-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/normalize-windows-path.js +9 -0
- package/dist/node_modules/tar/dist/esm/options.d.ts +596 -0
- package/dist/node_modules/tar/dist/esm/options.js +54 -0
- package/dist/node_modules/tar/dist/esm/pack.d.ts +105 -0
- package/dist/node_modules/tar/dist/esm/pack.js +503 -0
- package/dist/node_modules/tar/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/dist/esm/parse.d.ts +85 -0
- package/dist/node_modules/tar/dist/esm/parse.js +606 -0
- package/dist/node_modules/tar/dist/esm/path-reservations.d.ts +11 -0
- package/dist/node_modules/tar/dist/esm/path-reservations.js +166 -0
- package/dist/node_modules/tar/dist/esm/pax.d.ts +26 -0
- package/dist/node_modules/tar/dist/esm/pax.js +154 -0
- package/dist/node_modules/tar/dist/esm/process-umask.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/process-umask.js +3 -0
- package/dist/node_modules/tar/dist/esm/read-entry.d.ts +36 -0
- package/dist/node_modules/tar/dist/esm/read-entry.js +132 -0
- package/dist/node_modules/tar/dist/esm/replace.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/replace.js +221 -0
- package/dist/node_modules/tar/dist/esm/strip-absolute-path.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/strip-absolute-path.js +25 -0
- package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/strip-trailing-slashes.js +14 -0
- package/dist/node_modules/tar/dist/esm/symlink-error.d.ts +9 -0
- package/dist/node_modules/tar/dist/esm/symlink-error.js +15 -0
- package/dist/node_modules/tar/dist/esm/types.d.ts +7 -0
- package/dist/node_modules/tar/dist/esm/types.js +45 -0
- package/dist/node_modules/tar/dist/esm/unpack.d.ts +101 -0
- package/dist/node_modules/tar/dist/esm/unpack.js +891 -0
- package/dist/node_modules/tar/dist/esm/update.d.ts +2 -0
- package/dist/node_modules/tar/dist/esm/update.js +30 -0
- package/dist/node_modules/tar/dist/esm/warn-method.d.ts +24 -0
- package/dist/node_modules/tar/dist/esm/warn-method.js +27 -0
- package/dist/node_modules/tar/dist/esm/winchars.d.ts +3 -0
- package/dist/node_modules/tar/dist/esm/winchars.js +9 -0
- package/dist/node_modules/tar/dist/esm/write-entry.d.ts +129 -0
- package/dist/node_modules/tar/dist/esm/write-entry.js +656 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/index.d.ts +3 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/index.js +93 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/esm/index.d.ts +3 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/esm/index.js +85 -0
- package/dist/node_modules/tar/node_modules/chownr/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/chownr/package.json +69 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/index.d.ts +549 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/index.js +1028 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/esm/index.d.ts +549 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/esm/index.js +1018 -0
- package/dist/node_modules/tar/node_modules/minipass/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minipass/package.json +82 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/constants.d.ts +2 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/constants.js +123 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/index.d.ts +99 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/index.js +416 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/constants.d.ts +2 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/constants.js +117 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/index.d.ts +99 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/index.js +363 -0
- package/dist/node_modules/tar/node_modules/minizlib/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/minizlib/package.json +80 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.d.ts +39 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/index.js +384 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/commonjs/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.d.ts +39 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/index.js +379 -0
- package/dist/node_modules/tar/node_modules/yallist/dist/esm/package.json +3 -0
- package/dist/node_modules/tar/node_modules/yallist/package.json +68 -0
- package/dist/node_modules/tar/package.json +1 -0
- package/dist/server/collections/desktopRoutes.d.ts +14 -0
- package/dist/server/collections/desktopRoutes.js +48 -0
- package/dist/server/collections/extendRoleField.d.ts +14 -0
- package/dist/server/collections/extendRoleField.js +51 -0
- package/dist/server/collections/multiPortals.d.ts +10 -0
- package/dist/server/collections/multiPortals.js +128 -0
- package/dist/server/collections/rolesMultiPortalDesktopRoutes.d.ts +10 -0
- package/dist/server/collections/rolesMultiPortalDesktopRoutes.js +76 -0
- package/dist/server/collections/rolesMultiPortalRoutePolicies.d.ts +10 -0
- package/dist/server/collections/rolesMultiPortalRoutePolicies.js +73 -0
- package/dist/server/collections/rolesMultiPortals.d.ts +10 -0
- package/dist/server/collections/rolesMultiPortals.js +68 -0
- package/dist/server/ensureDefaultRoleMultiPortalAccess.d.ts +11 -0
- package/dist/server/ensureDefaultRoleMultiPortalAccess.js +70 -0
- package/dist/server/index.d.ts +9 -0
- package/dist/server/index.js +42 -0
- package/dist/server/migrations/20260723105200-drop-ui-layout-foreign-key-constraint.d.ts +13 -0
- package/dist/server/migrations/20260723105200-drop-ui-layout-foreign-key-constraint.js +104 -0
- package/dist/server/plugin.d.ts +63 -0
- package/dist/server/plugin.js +2130 -0
- package/package.json +34 -0
- package/server.d.ts +2 -0
- package/server.js +1 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import assert from 'assert';
|
|
2
|
+
import { Buffer } from 'buffer';
|
|
3
|
+
import { Minipass } from 'minipass';
|
|
4
|
+
import * as realZlib from 'zlib';
|
|
5
|
+
import { constants } from './constants.js';
|
|
6
|
+
export { constants } from './constants.js';
|
|
7
|
+
const OriginalBufferConcat = Buffer.concat;
|
|
8
|
+
const desc = Object.getOwnPropertyDescriptor(Buffer, 'concat');
|
|
9
|
+
const noop = (args) => args;
|
|
10
|
+
const passthroughBufferConcat = desc?.writable === true || desc?.set !== undefined
|
|
11
|
+
? (makeNoOp) => {
|
|
12
|
+
Buffer.concat = makeNoOp ? noop : OriginalBufferConcat;
|
|
13
|
+
}
|
|
14
|
+
: (_) => { };
|
|
15
|
+
const _superWrite = Symbol('_superWrite');
|
|
16
|
+
export class ZlibError extends Error {
|
|
17
|
+
code;
|
|
18
|
+
errno;
|
|
19
|
+
constructor(err, origin) {
|
|
20
|
+
super('zlib: ' + err.message, { cause: err });
|
|
21
|
+
this.code = err.code;
|
|
22
|
+
this.errno = err.errno;
|
|
23
|
+
/* c8 ignore next */
|
|
24
|
+
if (!this.code)
|
|
25
|
+
this.code = 'ZLIB_ERROR';
|
|
26
|
+
this.message = 'zlib: ' + err.message;
|
|
27
|
+
Error.captureStackTrace(this, origin ?? this.constructor);
|
|
28
|
+
}
|
|
29
|
+
get name() {
|
|
30
|
+
return 'ZlibError';
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// the Zlib class they all inherit from
|
|
34
|
+
// This thing manages the queue of requests, and returns
|
|
35
|
+
// true or false if there is anything in the queue when
|
|
36
|
+
// you call the .write() method.
|
|
37
|
+
const _flushFlag = Symbol('flushFlag');
|
|
38
|
+
class ZlibBase extends Minipass {
|
|
39
|
+
#sawError = false;
|
|
40
|
+
#ended = false;
|
|
41
|
+
#flushFlag;
|
|
42
|
+
#finishFlushFlag;
|
|
43
|
+
#fullFlushFlag;
|
|
44
|
+
#handle;
|
|
45
|
+
#onError;
|
|
46
|
+
get sawError() {
|
|
47
|
+
return this.#sawError;
|
|
48
|
+
}
|
|
49
|
+
get handle() {
|
|
50
|
+
return this.#handle;
|
|
51
|
+
}
|
|
52
|
+
/* c8 ignore start */
|
|
53
|
+
get flushFlag() {
|
|
54
|
+
return this.#flushFlag;
|
|
55
|
+
}
|
|
56
|
+
/* c8 ignore stop */
|
|
57
|
+
constructor(opts, mode) {
|
|
58
|
+
if (!opts || typeof opts !== 'object')
|
|
59
|
+
throw new TypeError('invalid options for ZlibBase constructor');
|
|
60
|
+
//@ts-ignore
|
|
61
|
+
super(opts);
|
|
62
|
+
/* c8 ignore start */
|
|
63
|
+
this.#flushFlag = opts.flush ?? 0;
|
|
64
|
+
this.#finishFlushFlag = opts.finishFlush ?? 0;
|
|
65
|
+
this.#fullFlushFlag = opts.fullFlushFlag ?? 0;
|
|
66
|
+
/* c8 ignore stop */
|
|
67
|
+
//@ts-ignore
|
|
68
|
+
if (typeof realZlib[mode] !== 'function') {
|
|
69
|
+
throw new TypeError('Compression method not supported: ' + mode);
|
|
70
|
+
}
|
|
71
|
+
// this will throw if any options are invalid for the class selected
|
|
72
|
+
try {
|
|
73
|
+
// @types/node doesn't know that it exports the classes, but they're there
|
|
74
|
+
//@ts-ignore
|
|
75
|
+
this.#handle = new realZlib[mode](opts);
|
|
76
|
+
}
|
|
77
|
+
catch (er) {
|
|
78
|
+
// make sure that all errors get decorated properly
|
|
79
|
+
throw new ZlibError(er, this.constructor);
|
|
80
|
+
}
|
|
81
|
+
this.#onError = err => {
|
|
82
|
+
// no sense raising multiple errors, since we abort on the first one.
|
|
83
|
+
if (this.#sawError)
|
|
84
|
+
return;
|
|
85
|
+
this.#sawError = true;
|
|
86
|
+
// there is no way to cleanly recover.
|
|
87
|
+
// continuing only obscures problems.
|
|
88
|
+
this.close();
|
|
89
|
+
this.emit('error', err);
|
|
90
|
+
};
|
|
91
|
+
this.#handle?.on('error', er => this.#onError(new ZlibError(er)));
|
|
92
|
+
this.once('end', () => this.close);
|
|
93
|
+
}
|
|
94
|
+
close() {
|
|
95
|
+
if (this.#handle) {
|
|
96
|
+
this.#handle.close();
|
|
97
|
+
this.#handle = undefined;
|
|
98
|
+
this.emit('close');
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
reset() {
|
|
102
|
+
if (!this.#sawError) {
|
|
103
|
+
assert(this.#handle, 'zlib binding closed');
|
|
104
|
+
//@ts-ignore
|
|
105
|
+
return this.#handle.reset?.();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
flush(flushFlag) {
|
|
109
|
+
if (this.ended)
|
|
110
|
+
return;
|
|
111
|
+
if (typeof flushFlag !== 'number')
|
|
112
|
+
flushFlag = this.#fullFlushFlag;
|
|
113
|
+
this.write(Object.assign(Buffer.alloc(0), { [_flushFlag]: flushFlag }));
|
|
114
|
+
}
|
|
115
|
+
end(chunk, encoding, cb) {
|
|
116
|
+
/* c8 ignore start */
|
|
117
|
+
if (typeof chunk === 'function') {
|
|
118
|
+
cb = chunk;
|
|
119
|
+
encoding = undefined;
|
|
120
|
+
chunk = undefined;
|
|
121
|
+
}
|
|
122
|
+
if (typeof encoding === 'function') {
|
|
123
|
+
cb = encoding;
|
|
124
|
+
encoding = undefined;
|
|
125
|
+
}
|
|
126
|
+
/* c8 ignore stop */
|
|
127
|
+
if (chunk) {
|
|
128
|
+
if (encoding)
|
|
129
|
+
this.write(chunk, encoding);
|
|
130
|
+
else
|
|
131
|
+
this.write(chunk);
|
|
132
|
+
}
|
|
133
|
+
this.flush(this.#finishFlushFlag);
|
|
134
|
+
this.#ended = true;
|
|
135
|
+
return super.end(cb);
|
|
136
|
+
}
|
|
137
|
+
get ended() {
|
|
138
|
+
return this.#ended;
|
|
139
|
+
}
|
|
140
|
+
// overridden in the gzip classes to do portable writes
|
|
141
|
+
[_superWrite](data) {
|
|
142
|
+
return super.write(data);
|
|
143
|
+
}
|
|
144
|
+
write(chunk, encoding, cb) {
|
|
145
|
+
// process the chunk using the sync process
|
|
146
|
+
// then super.write() all the outputted chunks
|
|
147
|
+
if (typeof encoding === 'function')
|
|
148
|
+
(cb = encoding), (encoding = 'utf8');
|
|
149
|
+
if (typeof chunk === 'string')
|
|
150
|
+
chunk = Buffer.from(chunk, encoding);
|
|
151
|
+
if (this.#sawError)
|
|
152
|
+
return;
|
|
153
|
+
assert(this.#handle, 'zlib binding closed');
|
|
154
|
+
// _processChunk tries to .close() the native handle after it's done, so we
|
|
155
|
+
// intercept that by temporarily making it a no-op.
|
|
156
|
+
// diving into the node:zlib internals a bit here
|
|
157
|
+
const nativeHandle = this.#handle
|
|
158
|
+
._handle;
|
|
159
|
+
const originalNativeClose = nativeHandle.close;
|
|
160
|
+
nativeHandle.close = () => { };
|
|
161
|
+
const originalClose = this.#handle.close;
|
|
162
|
+
this.#handle.close = () => { };
|
|
163
|
+
// It also calls `Buffer.concat()` at the end, which may be convenient
|
|
164
|
+
// for some, but which we are not interested in as it slows us down.
|
|
165
|
+
passthroughBufferConcat(true);
|
|
166
|
+
let result = undefined;
|
|
167
|
+
try {
|
|
168
|
+
const flushFlag = typeof chunk[_flushFlag] === 'number'
|
|
169
|
+
? chunk[_flushFlag]
|
|
170
|
+
: this.#flushFlag;
|
|
171
|
+
result = this.#handle._processChunk(chunk, flushFlag);
|
|
172
|
+
// if we don't throw, reset it back how it was
|
|
173
|
+
passthroughBufferConcat(false);
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
// or if we do, put Buffer.concat() back before we emit error
|
|
177
|
+
// Error events call into user code, which may call Buffer.concat()
|
|
178
|
+
passthroughBufferConcat(false);
|
|
179
|
+
this.#onError(new ZlibError(err, this.write));
|
|
180
|
+
}
|
|
181
|
+
finally {
|
|
182
|
+
if (this.#handle) {
|
|
183
|
+
// Core zlib resets `_handle` to null after attempting to close the
|
|
184
|
+
// native handle. Our no-op handler prevented actual closure, but we
|
|
185
|
+
// need to restore the `._handle` property.
|
|
186
|
+
;
|
|
187
|
+
this.#handle._handle =
|
|
188
|
+
nativeHandle;
|
|
189
|
+
nativeHandle.close = originalNativeClose;
|
|
190
|
+
this.#handle.close = originalClose;
|
|
191
|
+
// `_processChunk()` adds an 'error' listener. If we don't remove it
|
|
192
|
+
// after each call, these handlers start piling up.
|
|
193
|
+
this.#handle.removeAllListeners('error');
|
|
194
|
+
// make sure OUR error listener is still attached tho
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
if (this.#handle)
|
|
198
|
+
this.#handle.on('error', er => this.#onError(new ZlibError(er, this.write)));
|
|
199
|
+
let writeReturn;
|
|
200
|
+
if (result) {
|
|
201
|
+
if (Array.isArray(result) && result.length > 0) {
|
|
202
|
+
const r = result[0];
|
|
203
|
+
// The first buffer is always `handle._outBuffer`, which would be
|
|
204
|
+
// re-used for later invocations; so, we always have to copy that one.
|
|
205
|
+
writeReturn = this[_superWrite](Buffer.from(r));
|
|
206
|
+
for (let i = 1; i < result.length; i++) {
|
|
207
|
+
writeReturn = this[_superWrite](result[i]);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
// either a single Buffer or an empty array
|
|
212
|
+
writeReturn = this[_superWrite](Buffer.from(result));
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
if (cb)
|
|
216
|
+
cb();
|
|
217
|
+
return writeReturn;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
export class Zlib extends ZlibBase {
|
|
221
|
+
#level;
|
|
222
|
+
#strategy;
|
|
223
|
+
constructor(opts, mode) {
|
|
224
|
+
opts = opts || {};
|
|
225
|
+
opts.flush = opts.flush || constants.Z_NO_FLUSH;
|
|
226
|
+
opts.finishFlush = opts.finishFlush || constants.Z_FINISH;
|
|
227
|
+
opts.fullFlushFlag = constants.Z_FULL_FLUSH;
|
|
228
|
+
super(opts, mode);
|
|
229
|
+
this.#level = opts.level;
|
|
230
|
+
this.#strategy = opts.strategy;
|
|
231
|
+
}
|
|
232
|
+
params(level, strategy) {
|
|
233
|
+
if (this.sawError)
|
|
234
|
+
return;
|
|
235
|
+
if (!this.handle)
|
|
236
|
+
throw new Error('cannot switch params when binding is closed');
|
|
237
|
+
// no way to test this without also not supporting params at all
|
|
238
|
+
/* c8 ignore start */
|
|
239
|
+
if (!this.handle.params)
|
|
240
|
+
throw new Error('not supported in this implementation');
|
|
241
|
+
/* c8 ignore stop */
|
|
242
|
+
if (this.#level !== level || this.#strategy !== strategy) {
|
|
243
|
+
this.flush(constants.Z_SYNC_FLUSH);
|
|
244
|
+
assert(this.handle, 'zlib binding closed');
|
|
245
|
+
// .params() calls .flush(), but the latter is always async in the
|
|
246
|
+
// core zlib. We override .flush() temporarily to intercept that and
|
|
247
|
+
// flush synchronously.
|
|
248
|
+
const origFlush = this.handle.flush;
|
|
249
|
+
this.handle.flush = (flushFlag, cb) => {
|
|
250
|
+
/* c8 ignore start */
|
|
251
|
+
if (typeof flushFlag === 'function') {
|
|
252
|
+
cb = flushFlag;
|
|
253
|
+
flushFlag = this.flushFlag;
|
|
254
|
+
}
|
|
255
|
+
/* c8 ignore stop */
|
|
256
|
+
this.flush(flushFlag);
|
|
257
|
+
cb?.();
|
|
258
|
+
};
|
|
259
|
+
try {
|
|
260
|
+
;
|
|
261
|
+
this.handle.params(level, strategy);
|
|
262
|
+
}
|
|
263
|
+
finally {
|
|
264
|
+
this.handle.flush = origFlush;
|
|
265
|
+
}
|
|
266
|
+
/* c8 ignore start */
|
|
267
|
+
if (this.handle) {
|
|
268
|
+
this.#level = level;
|
|
269
|
+
this.#strategy = strategy;
|
|
270
|
+
}
|
|
271
|
+
/* c8 ignore stop */
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
// minimal 2-byte header
|
|
276
|
+
export class Deflate extends Zlib {
|
|
277
|
+
constructor(opts) {
|
|
278
|
+
super(opts, 'Deflate');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
export class Inflate extends Zlib {
|
|
282
|
+
constructor(opts) {
|
|
283
|
+
super(opts, 'Inflate');
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
export class Gzip extends Zlib {
|
|
287
|
+
#portable;
|
|
288
|
+
constructor(opts) {
|
|
289
|
+
super(opts, 'Gzip');
|
|
290
|
+
this.#portable = opts && !!opts.portable;
|
|
291
|
+
}
|
|
292
|
+
[_superWrite](data) {
|
|
293
|
+
if (!this.#portable)
|
|
294
|
+
return super[_superWrite](data);
|
|
295
|
+
// we'll always get the header emitted in one first chunk
|
|
296
|
+
// overwrite the OS indicator byte with 0xFF
|
|
297
|
+
this.#portable = false;
|
|
298
|
+
data[9] = 255;
|
|
299
|
+
return super[_superWrite](data);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
export class Gunzip extends Zlib {
|
|
303
|
+
constructor(opts) {
|
|
304
|
+
super(opts, 'Gunzip');
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
// raw - no header
|
|
308
|
+
export class DeflateRaw extends Zlib {
|
|
309
|
+
constructor(opts) {
|
|
310
|
+
super(opts, 'DeflateRaw');
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
export class InflateRaw extends Zlib {
|
|
314
|
+
constructor(opts) {
|
|
315
|
+
super(opts, 'InflateRaw');
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
// auto-detect header.
|
|
319
|
+
export class Unzip extends Zlib {
|
|
320
|
+
constructor(opts) {
|
|
321
|
+
super(opts, 'Unzip');
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
class Brotli extends ZlibBase {
|
|
325
|
+
constructor(opts, mode) {
|
|
326
|
+
opts = opts || {};
|
|
327
|
+
opts.flush = opts.flush || constants.BROTLI_OPERATION_PROCESS;
|
|
328
|
+
opts.finishFlush =
|
|
329
|
+
opts.finishFlush || constants.BROTLI_OPERATION_FINISH;
|
|
330
|
+
opts.fullFlushFlag = constants.BROTLI_OPERATION_FLUSH;
|
|
331
|
+
super(opts, mode);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
export class BrotliCompress extends Brotli {
|
|
335
|
+
constructor(opts) {
|
|
336
|
+
super(opts, 'BrotliCompress');
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
export class BrotliDecompress extends Brotli {
|
|
340
|
+
constructor(opts) {
|
|
341
|
+
super(opts, 'BrotliDecompress');
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
class Zstd extends ZlibBase {
|
|
345
|
+
constructor(opts, mode) {
|
|
346
|
+
opts = opts || {};
|
|
347
|
+
opts.flush = opts.flush || constants.ZSTD_e_continue;
|
|
348
|
+
opts.finishFlush = opts.finishFlush || constants.ZSTD_e_end;
|
|
349
|
+
opts.fullFlushFlag = constants.ZSTD_e_flush;
|
|
350
|
+
super(opts, mode);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
export class ZstdCompress extends Zstd {
|
|
354
|
+
constructor(opts) {
|
|
355
|
+
super(opts, 'ZstdCompress');
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
export class ZstdDecompress extends Zstd {
|
|
359
|
+
constructor(opts) {
|
|
360
|
+
super(opts, 'ZstdDecompress');
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "minizlib",
|
|
3
|
+
"version": "3.1.0",
|
|
4
|
+
"description": "A small fast zlib stream built on [minipass](http://npm.im/minipass) and Node.js's zlib binding.",
|
|
5
|
+
"main": "./dist/commonjs/index.js",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"minipass": "^7.1.2"
|
|
8
|
+
},
|
|
9
|
+
"scripts": {
|
|
10
|
+
"prepare": "tshy",
|
|
11
|
+
"pretest": "npm run prepare",
|
|
12
|
+
"test": "tap",
|
|
13
|
+
"preversion": "npm test",
|
|
14
|
+
"postversion": "npm publish",
|
|
15
|
+
"prepublishOnly": "git push origin --follow-tags",
|
|
16
|
+
"format": "prettier --write . --loglevel warn",
|
|
17
|
+
"typedoc": "typedoc --tsconfig .tshy/esm.json ./src/*.ts"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/isaacs/minizlib.git"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"zlib",
|
|
25
|
+
"gzip",
|
|
26
|
+
"gunzip",
|
|
27
|
+
"deflate",
|
|
28
|
+
"inflate",
|
|
29
|
+
"compression",
|
|
30
|
+
"zip",
|
|
31
|
+
"unzip"
|
|
32
|
+
],
|
|
33
|
+
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/node": "^24.5.2",
|
|
37
|
+
"tap": "^21.1.0",
|
|
38
|
+
"tshy": "^3.0.2",
|
|
39
|
+
"typedoc": "^0.28.1"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">= 18"
|
|
46
|
+
},
|
|
47
|
+
"tshy": {
|
|
48
|
+
"exports": {
|
|
49
|
+
"./package.json": "./package.json",
|
|
50
|
+
".": "./src/index.ts"
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"exports": {
|
|
54
|
+
"./package.json": "./package.json",
|
|
55
|
+
".": {
|
|
56
|
+
"import": {
|
|
57
|
+
"types": "./dist/esm/index.d.ts",
|
|
58
|
+
"default": "./dist/esm/index.js"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
62
|
+
"default": "./dist/commonjs/index.js"
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"types": "./dist/commonjs/index.d.ts",
|
|
67
|
+
"type": "module",
|
|
68
|
+
"prettier": {
|
|
69
|
+
"semi": false,
|
|
70
|
+
"printWidth": 75,
|
|
71
|
+
"tabWidth": 2,
|
|
72
|
+
"useTabs": false,
|
|
73
|
+
"singleQuote": true,
|
|
74
|
+
"jsxSingleQuote": false,
|
|
75
|
+
"bracketSameLine": true,
|
|
76
|
+
"arrowParens": "avoid",
|
|
77
|
+
"endOfLine": "lf"
|
|
78
|
+
},
|
|
79
|
+
"module": "./dist/esm/index.js"
|
|
80
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export declare class Yallist<T = unknown> {
|
|
2
|
+
tail?: Node<T>;
|
|
3
|
+
head?: Node<T>;
|
|
4
|
+
length: number;
|
|
5
|
+
static create<T = unknown>(list?: Iterable<T>): Yallist<T>;
|
|
6
|
+
constructor(list?: Iterable<T>);
|
|
7
|
+
[Symbol.iterator](): Generator<T, void, unknown>;
|
|
8
|
+
removeNode(node: Node<T>): Node<T> | undefined;
|
|
9
|
+
unshiftNode(node: Node<T>): void;
|
|
10
|
+
pushNode(node: Node<T>): void;
|
|
11
|
+
push(...args: T[]): number;
|
|
12
|
+
unshift(...args: T[]): number;
|
|
13
|
+
pop(): T | undefined;
|
|
14
|
+
shift(): T | undefined;
|
|
15
|
+
forEach(fn: (value: T, i: number, list: Yallist<T>) => any, thisp?: any): void;
|
|
16
|
+
forEachReverse(fn: (value: T, i: number, list: Yallist<T>) => any, thisp?: any): void;
|
|
17
|
+
get(n: number): T | undefined;
|
|
18
|
+
getReverse(n: number): T | undefined;
|
|
19
|
+
map<R = any>(fn: (value: T, list: Yallist<T>) => R, thisp?: any): Yallist<R>;
|
|
20
|
+
mapReverse<R = any>(fn: (value: T, list: Yallist<T>) => R, thisp?: any): Yallist<R>;
|
|
21
|
+
reduce(fn: (left: T, right: T, i: number) => T): T;
|
|
22
|
+
reduce<R = any>(fn: (acc: R, next: T, i: number) => R, initial: R): R;
|
|
23
|
+
reduceReverse(fn: (left: T, right: T, i: number) => T): T;
|
|
24
|
+
reduceReverse<R = any>(fn: (acc: R, next: T, i: number) => R, initial: R): R;
|
|
25
|
+
toArray(): any[];
|
|
26
|
+
toArrayReverse(): any[];
|
|
27
|
+
slice(from?: number, to?: number): Yallist<unknown>;
|
|
28
|
+
sliceReverse(from?: number, to?: number): Yallist<unknown>;
|
|
29
|
+
splice(start: number, deleteCount?: number, ...nodes: T[]): T[];
|
|
30
|
+
reverse(): this;
|
|
31
|
+
}
|
|
32
|
+
export declare class Node<T = unknown> {
|
|
33
|
+
list?: Yallist<T>;
|
|
34
|
+
next?: Node<T>;
|
|
35
|
+
prev?: Node<T>;
|
|
36
|
+
value: T;
|
|
37
|
+
constructor(value: T, prev?: Node<T> | undefined, next?: Node<T> | undefined, list?: Yallist<T> | undefined);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|