@hot-updater/cli-tools 0.31.1 → 0.31.3
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/dist/{chunk-BEJ448es.mjs → chunk-hT5z_Zn9.mjs} +1 -1
- package/dist/index.d.mts +6 -11
- package/dist/index.mjs +393 -14
- package/package.json +4 -4
|
@@ -6,7 +6,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
6
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
7
|
var __getProtoOf = Object.getPrototypeOf;
|
|
8
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
10
|
var __exportAll = (all, no_symbols) => {
|
|
11
11
|
let target = {};
|
|
12
12
|
for (var name in all) __defProp(target, name, {
|
package/dist/index.d.mts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Readable } from "stream";
|
|
2
2
|
import { Key as Key$1 } from "node:readline";
|
|
3
3
|
import { Readable as Readable$1, Writable } from "node:stream";
|
|
4
|
-
import * as _$_hot_updater_core0 from "@hot-updater/core";
|
|
5
4
|
import { Bundle, ConfigInput, DatabasePlugin, NodeStoragePlugin, Platform, RequiredDeep } from "@hot-updater/plugin-core";
|
|
6
5
|
|
|
7
6
|
//#region src/BuildLogger.d.ts
|
|
@@ -90,9 +89,9 @@ declare class ConfigBuilder implements IConfigBuilder {
|
|
|
90
89
|
getResult(): string;
|
|
91
90
|
}
|
|
92
91
|
//#endregion
|
|
93
|
-
//#region
|
|
92
|
+
//#region src/colors.d.ts
|
|
94
93
|
type Formatter = (input: string | number | null | undefined) => string;
|
|
95
|
-
|
|
94
|
+
type Colors = {
|
|
96
95
|
isColorSupported: boolean;
|
|
97
96
|
reset: Formatter;
|
|
98
97
|
bold: Formatter;
|
|
@@ -135,12 +134,8 @@ interface Colors {
|
|
|
135
134
|
bgMagentaBright: Formatter;
|
|
136
135
|
bgCyanBright: Formatter;
|
|
137
136
|
bgWhiteBright: Formatter;
|
|
138
|
-
}
|
|
139
|
-
//#endregion
|
|
140
|
-
//#region ../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.d.ts
|
|
141
|
-
declare const picocolors: Colors & {
|
|
142
|
-
createColors: (enabled?: boolean) => Colors;
|
|
143
137
|
};
|
|
138
|
+
declare const typedColors: Colors;
|
|
144
139
|
//#endregion
|
|
145
140
|
//#region src/copyDirToTmp.d.ts
|
|
146
141
|
declare const copyDirToTmp: (dir: string, childDirname?: string) => Promise<{
|
|
@@ -398,7 +393,7 @@ declare function createCopiedBundleArchive({
|
|
|
398
393
|
channel: string;
|
|
399
394
|
storageUri: string;
|
|
400
395
|
fileHash: string;
|
|
401
|
-
metadata:
|
|
396
|
+
metadata: import("@hot-updater/core").BundleMetadata | undefined;
|
|
402
397
|
assetBaseStorageUri: string;
|
|
403
398
|
patches: never[];
|
|
404
399
|
patchBaseBundleId: null;
|
|
@@ -407,7 +402,7 @@ declare function createCopiedBundleArchive({
|
|
|
407
402
|
patchBaseFileHash: null;
|
|
408
403
|
patchFileHash: null;
|
|
409
404
|
patchStorageUri: null;
|
|
410
|
-
platform:
|
|
405
|
+
platform: import("@hot-updater/core").Platform;
|
|
411
406
|
shouldForceUpdate: boolean;
|
|
412
407
|
enabled: boolean;
|
|
413
408
|
gitCommitHash: string | null;
|
|
@@ -986,4 +981,4 @@ type TransformTemplateArgs<T extends string> = { [Key in ExtractPlaceholders<T>]
|
|
|
986
981
|
*/
|
|
987
982
|
declare function transformTemplate<T extends string>(templateString: T, values: TransformTemplateArgs<T>): string;
|
|
988
983
|
//#endregion
|
|
989
|
-
export { BuildLogger, BuildLoggerConfig, BuildType, ConfigBuilder, ConfigBuilderScaffold, ConfigResponse, CreateHotUpdaterConfigScaffoldFromBuilderOptions, CreateHotUpdaterConfigScaffoldOptions, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, HotUpdateDirUtil, HotUpdaterConfigOptions, HotUpdaterConfigScaffold, HotUpdaterLogWriter, IConfigBuilder, ImportInfo, LEGACY_BUNDLE_ERROR, ManagedHelperStatement, ManagedHelperStrategy, PromoteBundleDependencies, PromoteBundleInput, PromptProgress, PromptSpinner, ProviderConfig, ReactNativeMetadata, ReadPackageUpResult, WriteHotUpdaterConfigResult, banner,
|
|
984
|
+
export { BuildLogger, BuildLoggerConfig, BuildType, ConfigBuilder, ConfigBuilderScaffold, ConfigResponse, CreateHotUpdaterConfigScaffoldFromBuilderOptions, CreateHotUpdaterConfigScaffoldOptions, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, HotUpdateDirUtil, HotUpdaterConfigOptions, HotUpdaterConfigScaffold, HotUpdaterLogWriter, IConfigBuilder, ImportInfo, LEGACY_BUNDLE_ERROR, ManagedHelperStatement, ManagedHelperStrategy, PromoteBundleDependencies, PromoteBundleInput, PromptProgress, PromptSpinner, ProviderConfig, ReactNativeMetadata, ReadPackageUpResult, WriteHotUpdaterConfigResult, banner, typedColors as colors, copyDirToTmp, createCopiedBundleArchive, createHotUpdaterConfigScaffold, createHotUpdaterConfigScaffoldFromBuilder, createLogWriter, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, decryptJson, encryptJson, ensureInstallPackages, getAndroidSdkPath, getCwd, getPackageManager, getReactNativeMetadatas, link, loadConfig, log, makeEnv, index_d_exports as p, printBanner, promoteBundle, readPackageUp, renderImportStatements, resolveHotUpdaterServerVersion, resolvePackageVersion, stripAnsi, transformEnv, transformTemplate, writeHotUpdaterConfig };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-
|
|
1
|
+
import { i as __toESM, n as __exportAll, r as __require, t as __commonJSMin } from "./chunk-hT5z_Zn9.mjs";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import path, { dirname, parse } from "path";
|
|
4
4
|
import { createInterface } from "readline";
|
|
@@ -105,6 +105,7 @@ var import_picocolors = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin((
|
|
|
105
105
|
module.exports = createColors();
|
|
106
106
|
module.exports.createColors = createColors;
|
|
107
107
|
})))(), 1);
|
|
108
|
+
const typedColors = import_picocolors.default;
|
|
108
109
|
//#endregion
|
|
109
110
|
//#region ../../node_modules/.pnpm/workspace-tools@0.36.4/node_modules/workspace-tools/lib/graph/getPackageDependencies.js
|
|
110
111
|
var require_getPackageDependencies = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
@@ -3017,6 +3018,9 @@ var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3017
3018
|
CHAR_VERTICAL_LINE: 124,
|
|
3018
3019
|
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
3019
3020
|
SEP: path$12.sep,
|
|
3021
|
+
/**
|
|
3022
|
+
* Create EXTGLOB_CHARS
|
|
3023
|
+
*/
|
|
3020
3024
|
extglobChars(chars) {
|
|
3021
3025
|
return {
|
|
3022
3026
|
"!": {
|
|
@@ -3046,6 +3050,9 @@ var require_constants$3 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
3046
3050
|
}
|
|
3047
3051
|
};
|
|
3048
3052
|
},
|
|
3053
|
+
/**
|
|
3054
|
+
* Create GLOB_CHARS
|
|
3055
|
+
*/
|
|
3049
3056
|
globChars(win32) {
|
|
3050
3057
|
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
3051
3058
|
}
|
|
@@ -18491,7 +18498,7 @@ var import_lib$1 = (/* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
18491
18498
|
__exportStar(require_listOfWorkspacePackageNames(), exports);
|
|
18492
18499
|
__exportStar(require_getAllPackageJsonFiles(), exports);
|
|
18493
18500
|
})))();
|
|
18494
|
-
const getCwd = () => (0, import_lib$1.findPackageRoot)(process.cwd());
|
|
18501
|
+
const getCwd = () => (0, import_lib$1.findPackageRoot)(process.cwd()) ?? process.cwd();
|
|
18495
18502
|
//#endregion
|
|
18496
18503
|
//#region ../../node_modules/.pnpm/@clack+core@1.0.1/node_modules/@clack/core/dist/index.mjs
|
|
18497
18504
|
var import_src = (/* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -19013,7 +19020,8 @@ var Vt$1 = class extends x$1 {
|
|
|
19013
19020
|
this.#s = e;
|
|
19014
19021
|
const s = this.options;
|
|
19015
19022
|
e ? this.filteredOptions = s.filter((n) => this.#i(e, n)) : this.filteredOptions = [...s];
|
|
19016
|
-
|
|
19023
|
+
const i = wt$1(this.focusedValue, this.filteredOptions);
|
|
19024
|
+
this.#t = B(i, 0, this.filteredOptions);
|
|
19017
19025
|
const r = this.filteredOptions[this.#t];
|
|
19018
19026
|
r && !r.disabled ? this.focusedValue = r.value : this.focusedValue = void 0, this.multiple || (this.focusedValue !== void 0 ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
19019
19027
|
}
|
|
@@ -19052,7 +19060,10 @@ var yt$1 = class extends x$1 {
|
|
|
19052
19060
|
if (this.value === void 0 && (this.value = []), e.group === !0) {
|
|
19053
19061
|
const s = e.value, i = this.getGroupItems(s);
|
|
19054
19062
|
this.isGroupSelected(s) ? this.value = this.value.filter((r) => i.findIndex((n) => n.value === r) === -1) : this.value = [...this.value, ...i.map((r) => r.value)], this.value = Array.from(new Set(this.value));
|
|
19055
|
-
} else
|
|
19063
|
+
} else {
|
|
19064
|
+
const s = this.value.includes(e.value);
|
|
19065
|
+
this.value = s ? this.value.filter((i) => i !== e.value) : [...this.value, e.value];
|
|
19066
|
+
}
|
|
19056
19067
|
}
|
|
19057
19068
|
constructor(e) {
|
|
19058
19069
|
super(e, !1);
|
|
@@ -19097,17 +19108,19 @@ var Lt$1 = class extends x$1 {
|
|
|
19097
19108
|
return this.options.filter((e) => e.disabled !== !0);
|
|
19098
19109
|
}
|
|
19099
19110
|
toggleAll() {
|
|
19100
|
-
const e = this._enabledOptions;
|
|
19101
|
-
this.value =
|
|
19111
|
+
const e = this._enabledOptions, s = this.value !== void 0 && this.value.length === e.length;
|
|
19112
|
+
this.value = s ? [] : e.map((i) => i.value);
|
|
19102
19113
|
}
|
|
19103
19114
|
toggleInvert() {
|
|
19104
19115
|
const e = this.value;
|
|
19105
19116
|
if (!e) return;
|
|
19106
|
-
|
|
19117
|
+
const s = this._enabledOptions.filter((i) => !e.includes(i.value));
|
|
19118
|
+
this.value = s.map((i) => i.value);
|
|
19107
19119
|
}
|
|
19108
19120
|
toggleValue() {
|
|
19109
19121
|
this.value === void 0 && (this.value = []);
|
|
19110
|
-
|
|
19122
|
+
const e = this.value.includes(this._value);
|
|
19123
|
+
this.value = e ? this.value.filter((s) => s !== this._value) : [...this.value, this._value];
|
|
19111
19124
|
}
|
|
19112
19125
|
constructor(e) {
|
|
19113
19126
|
super(e, !1), this.options = e.options, this.value = [...e.initialValues ?? []];
|
|
@@ -20516,6 +20529,7 @@ const resolveNextCompletedStage = ({ line, progressStages, completedStages }) =>
|
|
|
20516
20529
|
return nextCompletedStages;
|
|
20517
20530
|
};
|
|
20518
20531
|
var BuildLogger = class {
|
|
20532
|
+
config;
|
|
20519
20533
|
state = createInitialState();
|
|
20520
20534
|
logWriter;
|
|
20521
20535
|
promptProgress;
|
|
@@ -20615,7 +20629,7 @@ var BuildLogger = class {
|
|
|
20615
20629
|
showLogFileLocation() {
|
|
20616
20630
|
if (!this.logWriter?.logFilePath) return;
|
|
20617
20631
|
const relativePath = path.relative(getCwd(), this.logWriter.logFilePath);
|
|
20618
|
-
const highlightedPath =
|
|
20632
|
+
const highlightedPath = typedColors.blueBright(relativePath);
|
|
20619
20633
|
R.info(`Build log stored at ${highlightedPath}`);
|
|
20620
20634
|
}
|
|
20621
20635
|
};
|
|
@@ -23823,8 +23837,10 @@ var Header = class {
|
|
|
23823
23837
|
this.devmaj = decNumber(buf, off + 329, 8) ?? 0;
|
|
23824
23838
|
this.devmin = decNumber(buf, off + 337, 8) ?? 0;
|
|
23825
23839
|
/* c8 ignore stop */
|
|
23826
|
-
if (buf[off + 475] !== 0)
|
|
23827
|
-
|
|
23840
|
+
if (buf[off + 475] !== 0) {
|
|
23841
|
+
const prefix = decString(buf, off + 345, 155);
|
|
23842
|
+
this.path = prefix + "/" + this.path;
|
|
23843
|
+
} else {
|
|
23828
23844
|
const prefix = decString(buf, off + 345, 130);
|
|
23829
23845
|
if (prefix) this.path = prefix + "/" + this.path;
|
|
23830
23846
|
this.atime = decDate(buf, off + 476, 12);
|
|
@@ -23993,7 +24009,9 @@ var Pax = class Pax {
|
|
|
23993
24009
|
const buf = Buffer.allocUnsafe(bufLen);
|
|
23994
24010
|
for (let i = 0; i < 512; i++) buf[i] = 0;
|
|
23995
24011
|
new Header({
|
|
24012
|
+
/* c8 ignore start */
|
|
23996
24013
|
path: ("PaxHeader/" + basename(this.path ?? "")).slice(0, 99),
|
|
24014
|
+
/* c8 ignore stop */
|
|
23997
24015
|
mode: this.mode || 420,
|
|
23998
24016
|
uid: this.uid,
|
|
23999
24017
|
gid: this.gid,
|
|
@@ -24406,6 +24424,7 @@ while (this[PROCESSENTRY](this[QUEUE$1].shift()));
|
|
|
24406
24424
|
ex.linkpath = this[META].replace(/\0.*/, "");
|
|
24407
24425
|
break;
|
|
24408
24426
|
}
|
|
24427
|
+
/* c8 ignore start */
|
|
24409
24428
|
default: throw new Error("unknown meta: " + entry.type);
|
|
24410
24429
|
}
|
|
24411
24430
|
}
|
|
@@ -24542,6 +24561,7 @@ while (this[PROCESSENTRY](this[QUEUE$1].shift()));
|
|
|
24542
24561
|
case "meta":
|
|
24543
24562
|
position += this[CONSUMEMETA](chunk, position);
|
|
24544
24563
|
break;
|
|
24564
|
+
/* c8 ignore start */
|
|
24545
24565
|
default: throw new Error("invalid state: " + this[STATE]);
|
|
24546
24566
|
}
|
|
24547
24567
|
if (position < length) if (this[BUFFER]) this[BUFFER] = Buffer.concat([chunk.subarray(position), this[BUFFER]]);
|
|
@@ -24848,6 +24868,7 @@ var WriteEntry = class extends Minipass {
|
|
|
24848
24868
|
gid: this.portable ? void 0 : this.stat.gid,
|
|
24849
24869
|
size: this.stat.size,
|
|
24850
24870
|
mtime: this.noMtime ? void 0 : this.mtime || this.stat.mtime,
|
|
24871
|
+
/* c8 ignore next */
|
|
24851
24872
|
type: this.type === "Unsupported" ? void 0 : this.type,
|
|
24852
24873
|
uname: this.portable ? void 0 : this.stat.uid === this.myuid ? this.myuser : "",
|
|
24853
24874
|
atime: this.portable ? void 0 : this.stat.atime,
|
|
@@ -27478,7 +27499,8 @@ var require__stream_writable = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
27478
27499
|
this.ended = false;
|
|
27479
27500
|
this.finished = false;
|
|
27480
27501
|
this.destroyed = false;
|
|
27481
|
-
|
|
27502
|
+
var noDecode = options.decodeStrings === false;
|
|
27503
|
+
this.decodeStrings = !noDecode;
|
|
27482
27504
|
this.defaultEncoding = options.defaultEncoding || "utf8";
|
|
27483
27505
|
this.length = 0;
|
|
27484
27506
|
this.writing = false;
|
|
@@ -28964,7 +28986,18 @@ var require_base64 = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
28964
28986
|
//#region ../../node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/lib/nodejsUtils.js
|
|
28965
28987
|
var require_nodejsUtils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
28966
28988
|
module.exports = {
|
|
28989
|
+
/**
|
|
28990
|
+
* True if this is running in Nodejs, will be undefined in a browser.
|
|
28991
|
+
* In a browser, browserify won't include this file and the whole module
|
|
28992
|
+
* will be resolved an empty object.
|
|
28993
|
+
*/
|
|
28967
28994
|
isNode: typeof Buffer !== "undefined",
|
|
28995
|
+
/**
|
|
28996
|
+
* Create a new nodejs Buffer from an existing content.
|
|
28997
|
+
* @param {Object} data the data to pass to the constructor.
|
|
28998
|
+
* @param {String} encoding the encoding to use.
|
|
28999
|
+
* @return {Buffer} a new Buffer.
|
|
29000
|
+
*/
|
|
28968
29001
|
newBufferFrom: function(data, encoding) {
|
|
28969
29002
|
if (Buffer.from && Buffer.from !== Uint8Array.from) return Buffer.from(data, encoding);
|
|
28970
29003
|
else {
|
|
@@ -28972,6 +29005,11 @@ var require_nodejsUtils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
28972
29005
|
return new Buffer(data, encoding);
|
|
28973
29006
|
}
|
|
28974
29007
|
},
|
|
29008
|
+
/**
|
|
29009
|
+
* Create a new nodejs Buffer with the specified size.
|
|
29010
|
+
* @param {Integer} size the size of the buffer.
|
|
29011
|
+
* @return {Buffer} a new Buffer.
|
|
29012
|
+
*/
|
|
28975
29013
|
allocBuffer: function(size) {
|
|
28976
29014
|
if (Buffer.alloc) return Buffer.alloc(size);
|
|
28977
29015
|
else {
|
|
@@ -28980,6 +29018,11 @@ var require_nodejsUtils = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
28980
29018
|
return buf;
|
|
28981
29019
|
}
|
|
28982
29020
|
},
|
|
29021
|
+
/**
|
|
29022
|
+
* Find out if an object is a Buffer.
|
|
29023
|
+
* @param {Object} b the object to test.
|
|
29024
|
+
* @return {Boolean} true if the object is a Buffer, false otherwise.
|
|
29025
|
+
*/
|
|
28983
29026
|
isBuffer: function(b) {
|
|
28984
29027
|
return Buffer.isBuffer(b);
|
|
28985
29028
|
},
|
|
@@ -29472,6 +29515,15 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29472
29515
|
* can be optimized by the browser JIT compiler.
|
|
29473
29516
|
*/
|
|
29474
29517
|
var arrayToStringHelper = {
|
|
29518
|
+
/**
|
|
29519
|
+
* Transform an array of int into a string, chunk by chunk.
|
|
29520
|
+
* See the performances notes on arrayLikeToString.
|
|
29521
|
+
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
|
|
29522
|
+
* @param {String} type the type of the array.
|
|
29523
|
+
* @param {Integer} chunk the chunk size.
|
|
29524
|
+
* @return {String} the resulting string.
|
|
29525
|
+
* @throws Error if the chunk is too big for the stack.
|
|
29526
|
+
*/
|
|
29475
29527
|
stringifyByChunk: function(array, type, chunk) {
|
|
29476
29528
|
var result = [], k = 0, len = array.length;
|
|
29477
29529
|
if (len <= chunk) return String.fromCharCode.apply(null, array);
|
|
@@ -29482,12 +29534,22 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29482
29534
|
}
|
|
29483
29535
|
return result.join("");
|
|
29484
29536
|
},
|
|
29537
|
+
/**
|
|
29538
|
+
* Call String.fromCharCode on every item in the array.
|
|
29539
|
+
* This is the naive implementation, which generate A LOT of intermediate string.
|
|
29540
|
+
* This should be used when everything else fail.
|
|
29541
|
+
* @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
|
|
29542
|
+
* @return {String} the result.
|
|
29543
|
+
*/
|
|
29485
29544
|
stringifyByChar: function(array) {
|
|
29486
29545
|
var resultStr = "";
|
|
29487
29546
|
for (var i = 0; i < array.length; i++) resultStr += String.fromCharCode(array[i]);
|
|
29488
29547
|
return resultStr;
|
|
29489
29548
|
},
|
|
29490
29549
|
applyCanBeUsed: {
|
|
29550
|
+
/**
|
|
29551
|
+
* true if the browser accepts to use String.fromCharCode on Uint8Array
|
|
29552
|
+
*/
|
|
29491
29553
|
uint8array: (function() {
|
|
29492
29554
|
try {
|
|
29493
29555
|
return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
|
|
@@ -29495,6 +29557,9 @@ var require_utils = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
29495
29557
|
return false;
|
|
29496
29558
|
}
|
|
29497
29559
|
})(),
|
|
29560
|
+
/**
|
|
29561
|
+
* true if the browser accepts to use String.fromCharCode on nodejs Buffer.
|
|
29562
|
+
*/
|
|
29498
29563
|
nodebuffer: (function() {
|
|
29499
29564
|
try {
|
|
29500
29565
|
return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
|
|
@@ -29771,9 +29836,17 @@ var require_GenericWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
29771
29836
|
this.previous = null;
|
|
29772
29837
|
}
|
|
29773
29838
|
GenericWorker.prototype = {
|
|
29839
|
+
/**
|
|
29840
|
+
* Push a chunk to the next workers.
|
|
29841
|
+
* @param {Object} chunk the chunk to push
|
|
29842
|
+
*/
|
|
29774
29843
|
push: function(chunk) {
|
|
29775
29844
|
this.emit("data", chunk);
|
|
29776
29845
|
},
|
|
29846
|
+
/**
|
|
29847
|
+
* End the stream.
|
|
29848
|
+
* @return {Boolean} true if this call ended the worker, false otherwise.
|
|
29849
|
+
*/
|
|
29777
29850
|
end: function() {
|
|
29778
29851
|
if (this.isFinished) return false;
|
|
29779
29852
|
this.flush();
|
|
@@ -29786,6 +29859,11 @@ var require_GenericWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
29786
29859
|
}
|
|
29787
29860
|
return true;
|
|
29788
29861
|
},
|
|
29862
|
+
/**
|
|
29863
|
+
* End the stream with an error.
|
|
29864
|
+
* @param {Error} e the error which caused the premature end.
|
|
29865
|
+
* @return {Boolean} true if this call ended the worker with an error, false otherwise.
|
|
29866
|
+
*/
|
|
29789
29867
|
error: function(e) {
|
|
29790
29868
|
if (this.isFinished) return false;
|
|
29791
29869
|
if (this.isPaused) this.generatedError = e;
|
|
@@ -29797,20 +29875,47 @@ var require_GenericWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
29797
29875
|
}
|
|
29798
29876
|
return true;
|
|
29799
29877
|
},
|
|
29878
|
+
/**
|
|
29879
|
+
* Add a callback on an event.
|
|
29880
|
+
* @param {String} name the name of the event (data, end, error)
|
|
29881
|
+
* @param {Function} listener the function to call when the event is triggered
|
|
29882
|
+
* @return {GenericWorker} the current object for chainability
|
|
29883
|
+
*/
|
|
29800
29884
|
on: function(name, listener) {
|
|
29801
29885
|
this._listeners[name].push(listener);
|
|
29802
29886
|
return this;
|
|
29803
29887
|
},
|
|
29888
|
+
/**
|
|
29889
|
+
* Clean any references when a worker is ending.
|
|
29890
|
+
*/
|
|
29804
29891
|
cleanUp: function() {
|
|
29805
29892
|
this.streamInfo = this.generatedError = this.extraStreamInfo = null;
|
|
29806
29893
|
this._listeners = [];
|
|
29807
29894
|
},
|
|
29895
|
+
/**
|
|
29896
|
+
* Trigger an event. This will call registered callback with the provided arg.
|
|
29897
|
+
* @param {String} name the name of the event (data, end, error)
|
|
29898
|
+
* @param {Object} arg the argument to call the callback with.
|
|
29899
|
+
*/
|
|
29808
29900
|
emit: function(name, arg) {
|
|
29809
29901
|
if (this._listeners[name]) for (var i = 0; i < this._listeners[name].length; i++) this._listeners[name][i].call(this, arg);
|
|
29810
29902
|
},
|
|
29903
|
+
/**
|
|
29904
|
+
* Chain a worker with an other.
|
|
29905
|
+
* @param {Worker} next the worker receiving events from the current one.
|
|
29906
|
+
* @return {worker} the next worker for chainability
|
|
29907
|
+
*/
|
|
29811
29908
|
pipe: function(next) {
|
|
29812
29909
|
return next.registerPrevious(this);
|
|
29813
29910
|
},
|
|
29911
|
+
/**
|
|
29912
|
+
* Same as `pipe` in the other direction.
|
|
29913
|
+
* Using an API with `pipe(next)` is very easy.
|
|
29914
|
+
* Implementing the API with the point of view of the next one registering
|
|
29915
|
+
* a source is easier, see the ZipFileWorker.
|
|
29916
|
+
* @param {Worker} previous the previous worker, sending events to this one
|
|
29917
|
+
* @return {Worker} the current worker for chainability
|
|
29918
|
+
*/
|
|
29814
29919
|
registerPrevious: function(previous) {
|
|
29815
29920
|
if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
|
|
29816
29921
|
this.streamInfo = previous.streamInfo;
|
|
@@ -29828,12 +29933,20 @@ var require_GenericWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
29828
29933
|
});
|
|
29829
29934
|
return this;
|
|
29830
29935
|
},
|
|
29936
|
+
/**
|
|
29937
|
+
* Pause the stream so it doesn't send events anymore.
|
|
29938
|
+
* @return {Boolean} true if this call paused the worker, false otherwise.
|
|
29939
|
+
*/
|
|
29831
29940
|
pause: function() {
|
|
29832
29941
|
if (this.isPaused || this.isFinished) return false;
|
|
29833
29942
|
this.isPaused = true;
|
|
29834
29943
|
if (this.previous) this.previous.pause();
|
|
29835
29944
|
return true;
|
|
29836
29945
|
},
|
|
29946
|
+
/**
|
|
29947
|
+
* Resume a paused stream.
|
|
29948
|
+
* @return {Boolean} true if this call resumed the worker, false otherwise.
|
|
29949
|
+
*/
|
|
29837
29950
|
resume: function() {
|
|
29838
29951
|
if (!this.isPaused || this.isFinished) return false;
|
|
29839
29952
|
this.isPaused = false;
|
|
@@ -29845,26 +29958,50 @@ var require_GenericWorker = /* @__PURE__ */ __commonJSMin(((exports, module) =>
|
|
|
29845
29958
|
if (this.previous) this.previous.resume();
|
|
29846
29959
|
return !withError;
|
|
29847
29960
|
},
|
|
29961
|
+
/**
|
|
29962
|
+
* Flush any remaining bytes as the stream is ending.
|
|
29963
|
+
*/
|
|
29848
29964
|
flush: function() {},
|
|
29965
|
+
/**
|
|
29966
|
+
* Process a chunk. This is usually the method overridden.
|
|
29967
|
+
* @param {Object} chunk the chunk to process.
|
|
29968
|
+
*/
|
|
29849
29969
|
processChunk: function(chunk) {
|
|
29850
29970
|
this.push(chunk);
|
|
29851
29971
|
},
|
|
29972
|
+
/**
|
|
29973
|
+
* Add a key/value to be added in the workers chain streamInfo once activated.
|
|
29974
|
+
* @param {String} key the key to use
|
|
29975
|
+
* @param {Object} value the associated value
|
|
29976
|
+
* @return {Worker} the current worker for chainability
|
|
29977
|
+
*/
|
|
29852
29978
|
withStreamInfo: function(key, value) {
|
|
29853
29979
|
this.extraStreamInfo[key] = value;
|
|
29854
29980
|
this.mergeStreamInfo();
|
|
29855
29981
|
return this;
|
|
29856
29982
|
},
|
|
29983
|
+
/**
|
|
29984
|
+
* Merge this worker's streamInfo into the chain's streamInfo.
|
|
29985
|
+
*/
|
|
29857
29986
|
mergeStreamInfo: function() {
|
|
29858
29987
|
for (var key in this.extraStreamInfo) {
|
|
29859
29988
|
if (!Object.prototype.hasOwnProperty.call(this.extraStreamInfo, key)) continue;
|
|
29860
29989
|
this.streamInfo[key] = this.extraStreamInfo[key];
|
|
29861
29990
|
}
|
|
29862
29991
|
},
|
|
29992
|
+
/**
|
|
29993
|
+
* Lock the stream to prevent further updates on the workers chain.
|
|
29994
|
+
* After calling this method, all calls to pipe will fail.
|
|
29995
|
+
*/
|
|
29863
29996
|
lock: function() {
|
|
29864
29997
|
if (this.isLocked) throw new Error("The stream '" + this + "' has already been used.");
|
|
29865
29998
|
this.isLocked = true;
|
|
29866
29999
|
if (this.previous) this.previous.lock();
|
|
29867
30000
|
},
|
|
30001
|
+
/**
|
|
30002
|
+
*
|
|
30003
|
+
* Pretty print the workers chain.
|
|
30004
|
+
*/
|
|
29868
30005
|
toString: function() {
|
|
29869
30006
|
var me = "Worker " + this.name;
|
|
29870
30007
|
if (this.previous) return this.previous + " -> " + me;
|
|
@@ -30234,9 +30371,21 @@ var require_StreamHelper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30234
30371
|
}
|
|
30235
30372
|
}
|
|
30236
30373
|
StreamHelper.prototype = {
|
|
30374
|
+
/**
|
|
30375
|
+
* Listen a StreamHelper, accumulate its content and concatenate it into a
|
|
30376
|
+
* complete block.
|
|
30377
|
+
* @param {Function} updateCb the update callback.
|
|
30378
|
+
* @return Promise the promise for the accumulation.
|
|
30379
|
+
*/
|
|
30237
30380
|
accumulate: function(updateCb) {
|
|
30238
30381
|
return accumulate(this, updateCb);
|
|
30239
30382
|
},
|
|
30383
|
+
/**
|
|
30384
|
+
* Add a listener on an event triggered on a stream.
|
|
30385
|
+
* @param {String} evt the name of the event
|
|
30386
|
+
* @param {Function} fn the listener
|
|
30387
|
+
* @return {StreamHelper} the current helper.
|
|
30388
|
+
*/
|
|
30240
30389
|
on: function(evt, fn) {
|
|
30241
30390
|
var self = this;
|
|
30242
30391
|
if (evt === "data") this._worker.on(evt, function(chunk) {
|
|
@@ -30247,14 +30396,27 @@ var require_StreamHelper = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30247
30396
|
});
|
|
30248
30397
|
return this;
|
|
30249
30398
|
},
|
|
30399
|
+
/**
|
|
30400
|
+
* Resume the flow of chunks.
|
|
30401
|
+
* @return {StreamHelper} the current helper.
|
|
30402
|
+
*/
|
|
30250
30403
|
resume: function() {
|
|
30251
30404
|
utils.delay(this._worker.resume, [], this._worker);
|
|
30252
30405
|
return this;
|
|
30253
30406
|
},
|
|
30407
|
+
/**
|
|
30408
|
+
* Pause the flow of chunks.
|
|
30409
|
+
* @return {StreamHelper} the current helper.
|
|
30410
|
+
*/
|
|
30254
30411
|
pause: function() {
|
|
30255
30412
|
this._worker.pause();
|
|
30256
30413
|
return this;
|
|
30257
30414
|
},
|
|
30415
|
+
/**
|
|
30416
|
+
* Return a nodejs stream for this helper.
|
|
30417
|
+
* @param {Function} updateCb the update callback.
|
|
30418
|
+
* @return {NodejsStreamOutputAdapter} the nodejs stream.
|
|
30419
|
+
*/
|
|
30258
30420
|
toNodejsStream: function(updateCb) {
|
|
30259
30421
|
utils.checkSupport("nodestream");
|
|
30260
30422
|
if (this._outputType !== "nodebuffer") throw new Error(this._outputType + " is not supported by this method");
|
|
@@ -30490,6 +30652,10 @@ var require_compressedObject = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
30490
30652
|
this.compressedContent = data;
|
|
30491
30653
|
}
|
|
30492
30654
|
CompressedObject.prototype = {
|
|
30655
|
+
/**
|
|
30656
|
+
* Create a worker to get the uncompressed content.
|
|
30657
|
+
* @return {GenericWorker} the worker.
|
|
30658
|
+
*/
|
|
30493
30659
|
getContentWorker: function() {
|
|
30494
30660
|
var worker = new DataWorker(external.Promise.resolve(this.compressedContent)).pipe(this.compression.uncompressWorker()).pipe(new DataLengthProbe("data_length"));
|
|
30495
30661
|
var that = this;
|
|
@@ -30498,6 +30664,10 @@ var require_compressedObject = /* @__PURE__ */ __commonJSMin(((exports, module)
|
|
|
30498
30664
|
});
|
|
30499
30665
|
return worker;
|
|
30500
30666
|
},
|
|
30667
|
+
/**
|
|
30668
|
+
* Create a worker to get the compressed content.
|
|
30669
|
+
* @return {GenericWorker} the worker.
|
|
30670
|
+
*/
|
|
30501
30671
|
getCompressedWorker: function() {
|
|
30502
30672
|
return new DataWorker(external.Promise.resolve(this.compressedContent)).withStreamInfo("compressedSize", this.compressedSize).withStreamInfo("uncompressedSize", this.uncompressedSize).withStreamInfo("crc32", this.crc32).withStreamInfo("compression", this.compression);
|
|
30503
30673
|
}
|
|
@@ -30545,6 +30715,11 @@ var require_zipObject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30545
30715
|
};
|
|
30546
30716
|
};
|
|
30547
30717
|
ZipObject.prototype = {
|
|
30718
|
+
/**
|
|
30719
|
+
* Create an internal stream for the content of this object.
|
|
30720
|
+
* @param {String} type the type of each chunk.
|
|
30721
|
+
* @return StreamHelper the stream.
|
|
30722
|
+
*/
|
|
30548
30723
|
internalStream: function(type) {
|
|
30549
30724
|
var result = null, outputType = "string";
|
|
30550
30725
|
try {
|
|
@@ -30562,12 +30737,31 @@ var require_zipObject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30562
30737
|
}
|
|
30563
30738
|
return new StreamHelper(result, outputType, "");
|
|
30564
30739
|
},
|
|
30740
|
+
/**
|
|
30741
|
+
* Prepare the content in the asked type.
|
|
30742
|
+
* @param {String} type the type of the result.
|
|
30743
|
+
* @param {Function} onUpdate a function to call on each internal update.
|
|
30744
|
+
* @return Promise the promise of the result.
|
|
30745
|
+
*/
|
|
30565
30746
|
async: function(type, onUpdate) {
|
|
30566
30747
|
return this.internalStream(type).accumulate(onUpdate);
|
|
30567
30748
|
},
|
|
30749
|
+
/**
|
|
30750
|
+
* Prepare the content as a nodejs stream.
|
|
30751
|
+
* @param {String} type the type of each chunk.
|
|
30752
|
+
* @param {Function} onUpdate a function to call on each internal update.
|
|
30753
|
+
* @return Stream the stream.
|
|
30754
|
+
*/
|
|
30568
30755
|
nodeStream: function(type, onUpdate) {
|
|
30569
30756
|
return this.internalStream(type || "nodebuffer").toNodejsStream(onUpdate);
|
|
30570
30757
|
},
|
|
30758
|
+
/**
|
|
30759
|
+
* Return a worker for the compressed content.
|
|
30760
|
+
* @private
|
|
30761
|
+
* @param {Object} compression the compression object to use.
|
|
30762
|
+
* @param {Object} compressionOptions the options to use when compressing.
|
|
30763
|
+
* @return Worker the worker.
|
|
30764
|
+
*/
|
|
30571
30765
|
_compressWorker: function(compression, compressionOptions) {
|
|
30572
30766
|
if (this._data instanceof CompressedObject && this._data.compression.magic === compression.magic) return this._data.getCompressedWorker();
|
|
30573
30767
|
else {
|
|
@@ -30576,6 +30770,11 @@ var require_zipObject = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
30576
30770
|
return CompressedObject.createWorkerFrom(result, compression, compressionOptions);
|
|
30577
30771
|
}
|
|
30578
30772
|
},
|
|
30773
|
+
/**
|
|
30774
|
+
* Return a worker for the decompressed content.
|
|
30775
|
+
* @private
|
|
30776
|
+
* @return Worker the worker.
|
|
30777
|
+
*/
|
|
30579
30778
|
_decompressWorker: function() {
|
|
30580
30779
|
if (this._data instanceof CompressedObject) return this._data.getContentWorker();
|
|
30581
30780
|
else if (this._data instanceof GenericWorker) return this._data;
|
|
@@ -35115,9 +35314,18 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35115
35314
|
return Object.prototype.toString.call(object) === "[object RegExp]";
|
|
35116
35315
|
}
|
|
35117
35316
|
module.exports = {
|
|
35317
|
+
/**
|
|
35318
|
+
* @see loadAsync
|
|
35319
|
+
*/
|
|
35118
35320
|
load: function() {
|
|
35119
35321
|
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
|
|
35120
35322
|
},
|
|
35323
|
+
/**
|
|
35324
|
+
* Call a callback function for each entry at this folder level.
|
|
35325
|
+
* @param {Function} cb the callback function:
|
|
35326
|
+
* function (relativePath, file) {...}
|
|
35327
|
+
* It takes 2 arguments : the relative path and the file.
|
|
35328
|
+
*/
|
|
35121
35329
|
forEach: function(cb) {
|
|
35122
35330
|
var filename, relativePath, file;
|
|
35123
35331
|
for (filename in this.files) {
|
|
@@ -35126,6 +35334,13 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35126
35334
|
if (relativePath && filename.slice(0, this.root.length) === this.root) cb(relativePath, file);
|
|
35127
35335
|
}
|
|
35128
35336
|
},
|
|
35337
|
+
/**
|
|
35338
|
+
* Filter nested files/folders with the specified function.
|
|
35339
|
+
* @param {Function} search the predicate to use :
|
|
35340
|
+
* function (relativePath, file) {...}
|
|
35341
|
+
* It takes 2 arguments : the relative path and the file.
|
|
35342
|
+
* @return {Array} An array of matching elements.
|
|
35343
|
+
*/
|
|
35129
35344
|
filter: function(search) {
|
|
35130
35345
|
var result = [];
|
|
35131
35346
|
this.forEach(function(relativePath, entry) {
|
|
@@ -35133,6 +35348,15 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35133
35348
|
});
|
|
35134
35349
|
return result;
|
|
35135
35350
|
},
|
|
35351
|
+
/**
|
|
35352
|
+
* Add a file to the zip file, or search a file.
|
|
35353
|
+
* @param {string|RegExp} name The name of the file to add (if data is defined),
|
|
35354
|
+
* the name of the file to find (if no data) or a regex to match files.
|
|
35355
|
+
* @param {String|ArrayBuffer|Uint8Array|Buffer} data The file data, either raw or base64 encoded
|
|
35356
|
+
* @param {Object} o File options
|
|
35357
|
+
* @return {JSZip|Object|Array} this JSZip object (when adding a file),
|
|
35358
|
+
* a file (when searching by string) or an array of files (when searching by regex).
|
|
35359
|
+
*/
|
|
35136
35360
|
file: function(name, data, o) {
|
|
35137
35361
|
if (arguments.length === 1) if (isRegExp(name)) {
|
|
35138
35362
|
var regexp = name;
|
|
@@ -35150,6 +35374,11 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35150
35374
|
}
|
|
35151
35375
|
return this;
|
|
35152
35376
|
},
|
|
35377
|
+
/**
|
|
35378
|
+
* Add a directory to the zip file, or search.
|
|
35379
|
+
* @param {String|RegExp} arg The name of the directory to add, or a regex to search folders.
|
|
35380
|
+
* @return {JSZip} an object with the new directory as the root, or an array containing matching folders.
|
|
35381
|
+
*/
|
|
35153
35382
|
folder: function(arg) {
|
|
35154
35383
|
if (!arg) return this;
|
|
35155
35384
|
if (isRegExp(arg)) return this.filter(function(relativePath, file) {
|
|
@@ -35161,6 +35390,11 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35161
35390
|
ret.root = newFolder.name;
|
|
35162
35391
|
return ret;
|
|
35163
35392
|
},
|
|
35393
|
+
/**
|
|
35394
|
+
* Delete a file, or a directory and all sub-files, from the zip
|
|
35395
|
+
* @param {string} name the name of the file to delete
|
|
35396
|
+
* @return {JSZip} this JSZip object
|
|
35397
|
+
*/
|
|
35164
35398
|
remove: function(name) {
|
|
35165
35399
|
name = this.root + name;
|
|
35166
35400
|
var file = this.files[name];
|
|
@@ -35177,9 +35411,19 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35177
35411
|
}
|
|
35178
35412
|
return this;
|
|
35179
35413
|
},
|
|
35414
|
+
/**
|
|
35415
|
+
* @deprecated This method has been removed in JSZip 3.0, please check the upgrade guide.
|
|
35416
|
+
*/
|
|
35180
35417
|
generate: function() {
|
|
35181
35418
|
throw new Error("This method has been removed in JSZip 3.0, please check the upgrade guide.");
|
|
35182
35419
|
},
|
|
35420
|
+
/**
|
|
35421
|
+
* Generate the complete zip file as an internal stream.
|
|
35422
|
+
* @param {Object} options the options to generate the zip file :
|
|
35423
|
+
* - compression, "STORE" by default.
|
|
35424
|
+
* - type, "base64" by default. Values are : string, base64, uint8array, arraybuffer, blob.
|
|
35425
|
+
* @return {StreamHelper} the streamed zip file.
|
|
35426
|
+
*/
|
|
35183
35427
|
generateInternalStream: function(options) {
|
|
35184
35428
|
var worker, opts = {};
|
|
35185
35429
|
try {
|
|
@@ -35208,9 +35452,17 @@ var require_object = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35208
35452
|
}
|
|
35209
35453
|
return new StreamHelper(worker, opts.type || "string", opts.mimeType);
|
|
35210
35454
|
},
|
|
35455
|
+
/**
|
|
35456
|
+
* Generate the complete zip file asynchronously.
|
|
35457
|
+
* @see generateInternalStream
|
|
35458
|
+
*/
|
|
35211
35459
|
generateAsync: function(options, onUpdate) {
|
|
35212
35460
|
return this.generateInternalStream(options).accumulate(onUpdate);
|
|
35213
35461
|
},
|
|
35462
|
+
/**
|
|
35463
|
+
* Generate the complete zip file asynchronously.
|
|
35464
|
+
* @see generateInternalStream
|
|
35465
|
+
*/
|
|
35214
35466
|
generateNodeStream: function(options, onUpdate) {
|
|
35215
35467
|
options = options || {};
|
|
35216
35468
|
if (!options.type) options.type = "nodebuffer";
|
|
@@ -35229,20 +35481,50 @@ var require_DataReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35229
35481
|
this.zero = 0;
|
|
35230
35482
|
}
|
|
35231
35483
|
DataReader.prototype = {
|
|
35484
|
+
/**
|
|
35485
|
+
* Check that the offset will not go too far.
|
|
35486
|
+
* @param {string} offset the additional offset to check.
|
|
35487
|
+
* @throws {Error} an Error if the offset is out of bounds.
|
|
35488
|
+
*/
|
|
35232
35489
|
checkOffset: function(offset) {
|
|
35233
35490
|
this.checkIndex(this.index + offset);
|
|
35234
35491
|
},
|
|
35492
|
+
/**
|
|
35493
|
+
* Check that the specified index will not be too far.
|
|
35494
|
+
* @param {string} newIndex the index to check.
|
|
35495
|
+
* @throws {Error} an Error if the index is out of bounds.
|
|
35496
|
+
*/
|
|
35235
35497
|
checkIndex: function(newIndex) {
|
|
35236
35498
|
if (this.length < this.zero + newIndex || newIndex < 0) throw new Error("End of data reached (data length = " + this.length + ", asked index = " + newIndex + "). Corrupted zip ?");
|
|
35237
35499
|
},
|
|
35500
|
+
/**
|
|
35501
|
+
* Change the index.
|
|
35502
|
+
* @param {number} newIndex The new index.
|
|
35503
|
+
* @throws {Error} if the new index is out of the data.
|
|
35504
|
+
*/
|
|
35238
35505
|
setIndex: function(newIndex) {
|
|
35239
35506
|
this.checkIndex(newIndex);
|
|
35240
35507
|
this.index = newIndex;
|
|
35241
35508
|
},
|
|
35509
|
+
/**
|
|
35510
|
+
* Skip the next n bytes.
|
|
35511
|
+
* @param {number} n the number of bytes to skip.
|
|
35512
|
+
* @throws {Error} if the new index is out of the data.
|
|
35513
|
+
*/
|
|
35242
35514
|
skip: function(n) {
|
|
35243
35515
|
this.setIndex(this.index + n);
|
|
35244
35516
|
},
|
|
35517
|
+
/**
|
|
35518
|
+
* Get the byte at the specified index.
|
|
35519
|
+
* @param {number} i the index to use.
|
|
35520
|
+
* @return {number} a byte.
|
|
35521
|
+
*/
|
|
35245
35522
|
byteAt: function() {},
|
|
35523
|
+
/**
|
|
35524
|
+
* Get the next number with a given byte size.
|
|
35525
|
+
* @param {number} size the number of bytes to read.
|
|
35526
|
+
* @return {number} the corresponding number.
|
|
35527
|
+
*/
|
|
35246
35528
|
readInt: function(size) {
|
|
35247
35529
|
var result = 0, i;
|
|
35248
35530
|
this.checkOffset(size);
|
|
@@ -35250,12 +35532,36 @@ var require_DataReader = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35250
35532
|
this.index += size;
|
|
35251
35533
|
return result;
|
|
35252
35534
|
},
|
|
35535
|
+
/**
|
|
35536
|
+
* Get the next string with a given byte size.
|
|
35537
|
+
* @param {number} size the number of bytes to read.
|
|
35538
|
+
* @return {string} the corresponding string.
|
|
35539
|
+
*/
|
|
35253
35540
|
readString: function(size) {
|
|
35254
35541
|
return utils.transformTo("string", this.readData(size));
|
|
35255
35542
|
},
|
|
35543
|
+
/**
|
|
35544
|
+
* Get raw data without conversion, <size> bytes.
|
|
35545
|
+
* @param {number} size the number of bytes to read.
|
|
35546
|
+
* @return {Object} the raw data, implementation specific.
|
|
35547
|
+
*/
|
|
35256
35548
|
readData: function() {},
|
|
35549
|
+
/**
|
|
35550
|
+
* Find the last occurrence of a zip signature (4 bytes).
|
|
35551
|
+
* @param {string} sig the signature to find.
|
|
35552
|
+
* @return {number} the index of the last occurrence, -1 if not found.
|
|
35553
|
+
*/
|
|
35257
35554
|
lastIndexOfSignature: function() {},
|
|
35555
|
+
/**
|
|
35556
|
+
* Read the signature (4 bytes) at the current position and compare it with sig.
|
|
35557
|
+
* @param {string} sig the expected signature
|
|
35558
|
+
* @return {boolean} true if the signature matches, false otherwise.
|
|
35559
|
+
*/
|
|
35258
35560
|
readAndCheckSignature: function() {},
|
|
35561
|
+
/**
|
|
35562
|
+
* Get the next date.
|
|
35563
|
+
* @return {Date} the date.
|
|
35564
|
+
*/
|
|
35259
35565
|
readDate: function() {
|
|
35260
35566
|
var dostime = this.readInt(4);
|
|
35261
35567
|
return new Date(Date.UTC((dostime >> 25 & 127) + 1980, (dostime >> 21 & 15) - 1, dostime >> 16 & 31, dostime >> 11 & 31, dostime >> 5 & 63, (dostime & 31) << 1));
|
|
@@ -35443,12 +35749,24 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35443
35749
|
this.loadOptions = loadOptions;
|
|
35444
35750
|
}
|
|
35445
35751
|
ZipEntry.prototype = {
|
|
35752
|
+
/**
|
|
35753
|
+
* say if the file is encrypted.
|
|
35754
|
+
* @return {boolean} true if the file is encrypted, false otherwise.
|
|
35755
|
+
*/
|
|
35446
35756
|
isEncrypted: function() {
|
|
35447
35757
|
return (this.bitFlag & 1) === 1;
|
|
35448
35758
|
},
|
|
35759
|
+
/**
|
|
35760
|
+
* say if the file has utf-8 filename/comment.
|
|
35761
|
+
* @return {boolean} true if the filename/comment is in utf-8, false otherwise.
|
|
35762
|
+
*/
|
|
35449
35763
|
useUTF8: function() {
|
|
35450
35764
|
return (this.bitFlag & 2048) === 2048;
|
|
35451
35765
|
},
|
|
35766
|
+
/**
|
|
35767
|
+
* Read the local part of a zip file and add the info in this object.
|
|
35768
|
+
* @param {DataReader} reader the reader to use.
|
|
35769
|
+
*/
|
|
35452
35770
|
readLocalPart: function(reader) {
|
|
35453
35771
|
var compression, localExtraFieldsLength;
|
|
35454
35772
|
reader.skip(22);
|
|
@@ -35461,6 +35779,10 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35461
35779
|
if (compression === null) throw new Error("Corrupted zip : compression " + utils.pretty(this.compressionMethod) + " unknown (inner file : " + utils.transformTo("string", this.fileName) + ")");
|
|
35462
35780
|
this.decompressed = new CompressedObject(this.compressedSize, this.uncompressedSize, this.crc32, compression, reader.readData(this.compressedSize));
|
|
35463
35781
|
},
|
|
35782
|
+
/**
|
|
35783
|
+
* Read the central part of a zip file and add the info in this object.
|
|
35784
|
+
* @param {DataReader} reader the reader to use.
|
|
35785
|
+
*/
|
|
35464
35786
|
readCentralPart: function(reader) {
|
|
35465
35787
|
this.versionMadeBy = reader.readInt(2);
|
|
35466
35788
|
reader.skip(2);
|
|
@@ -35483,6 +35805,9 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35483
35805
|
this.parseZIP64ExtraField(reader);
|
|
35484
35806
|
this.fileComment = reader.readData(this.fileCommentLength);
|
|
35485
35807
|
},
|
|
35808
|
+
/**
|
|
35809
|
+
* Parse the external file attributes and get the unix/dos permissions.
|
|
35810
|
+
*/
|
|
35486
35811
|
processAttributes: function() {
|
|
35487
35812
|
this.unixPermissions = null;
|
|
35488
35813
|
this.dosPermissions = null;
|
|
@@ -35492,6 +35817,10 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35492
35817
|
if (madeBy === MADE_BY_UNIX) this.unixPermissions = this.externalFileAttributes >> 16 & 65535;
|
|
35493
35818
|
if (!this.dir && this.fileNameStr.slice(-1) === "/") this.dir = true;
|
|
35494
35819
|
},
|
|
35820
|
+
/**
|
|
35821
|
+
* Parse the ZIP64 extra field and merge the info in the current ZipEntry.
|
|
35822
|
+
* @param {DataReader} reader the reader to use.
|
|
35823
|
+
*/
|
|
35495
35824
|
parseZIP64ExtraField: function() {
|
|
35496
35825
|
if (!this.extraFields[1]) return;
|
|
35497
35826
|
var extraReader = readerFor(this.extraFields[1].value);
|
|
@@ -35500,6 +35829,10 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35500
35829
|
if (this.localHeaderOffset === utils.MAX_VALUE_32BITS) this.localHeaderOffset = extraReader.readInt(8);
|
|
35501
35830
|
if (this.diskNumberStart === utils.MAX_VALUE_32BITS) this.diskNumberStart = extraReader.readInt(4);
|
|
35502
35831
|
},
|
|
35832
|
+
/**
|
|
35833
|
+
* Read the central part of a zip file and add the info in this object.
|
|
35834
|
+
* @param {DataReader} reader the reader to use.
|
|
35835
|
+
*/
|
|
35503
35836
|
readExtraFields: function(reader) {
|
|
35504
35837
|
var end = reader.index + this.extraFieldsLength, extraFieldId, extraFieldLength, extraFieldValue;
|
|
35505
35838
|
if (!this.extraFields) this.extraFields = {};
|
|
@@ -35515,6 +35848,9 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35515
35848
|
}
|
|
35516
35849
|
reader.setIndex(end);
|
|
35517
35850
|
},
|
|
35851
|
+
/**
|
|
35852
|
+
* Apply an UTF8 transformation if needed.
|
|
35853
|
+
*/
|
|
35518
35854
|
handleUTF8: function() {
|
|
35519
35855
|
var decodeParamType = support.uint8array ? "uint8array" : "array";
|
|
35520
35856
|
if (this.useUTF8()) {
|
|
@@ -35535,6 +35871,10 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35535
35871
|
}
|
|
35536
35872
|
}
|
|
35537
35873
|
},
|
|
35874
|
+
/**
|
|
35875
|
+
* Find the unicode path declared in the extra field, if any.
|
|
35876
|
+
* @return {String} the unicode path, null otherwise.
|
|
35877
|
+
*/
|
|
35538
35878
|
findExtraFieldUnicodePath: function() {
|
|
35539
35879
|
var upathField = this.extraFields[28789];
|
|
35540
35880
|
if (upathField) {
|
|
@@ -35545,6 +35885,10 @@ var require_zipEntry = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35545
35885
|
}
|
|
35546
35886
|
return null;
|
|
35547
35887
|
},
|
|
35888
|
+
/**
|
|
35889
|
+
* Find the unicode comment declared in the extra field, if any.
|
|
35890
|
+
* @return {String} the unicode comment, null otherwise.
|
|
35891
|
+
*/
|
|
35548
35892
|
findExtraFieldUnicodeComment: function() {
|
|
35549
35893
|
var ucommentField = this.extraFields[25461];
|
|
35550
35894
|
if (ucommentField) {
|
|
@@ -35576,6 +35920,11 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35576
35920
|
this.loadOptions = loadOptions;
|
|
35577
35921
|
}
|
|
35578
35922
|
ZipEntries.prototype = {
|
|
35923
|
+
/**
|
|
35924
|
+
* Check that the reader is on the specified signature.
|
|
35925
|
+
* @param {string} expectedSignature the expected signature.
|
|
35926
|
+
* @throws {Error} if it is an other signature.
|
|
35927
|
+
*/
|
|
35579
35928
|
checkSignature: function(expectedSignature) {
|
|
35580
35929
|
if (!this.reader.readAndCheckSignature(expectedSignature)) {
|
|
35581
35930
|
this.reader.index -= 4;
|
|
@@ -35583,6 +35932,12 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35583
35932
|
throw new Error("Corrupted zip or bug: unexpected signature (" + utils.pretty(signature) + ", expected " + utils.pretty(expectedSignature) + ")");
|
|
35584
35933
|
}
|
|
35585
35934
|
},
|
|
35935
|
+
/**
|
|
35936
|
+
* Check if the given signature is at the given index.
|
|
35937
|
+
* @param {number} askedIndex the index to check.
|
|
35938
|
+
* @param {string} expectedSignature the signature to expect.
|
|
35939
|
+
* @return {boolean} true if the signature is here, false otherwise.
|
|
35940
|
+
*/
|
|
35586
35941
|
isSignature: function(askedIndex, expectedSignature) {
|
|
35587
35942
|
var currentIndex = this.reader.index;
|
|
35588
35943
|
this.reader.setIndex(askedIndex);
|
|
@@ -35590,6 +35945,9 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35590
35945
|
this.reader.setIndex(currentIndex);
|
|
35591
35946
|
return result;
|
|
35592
35947
|
},
|
|
35948
|
+
/**
|
|
35949
|
+
* Read the end of the central directory.
|
|
35950
|
+
*/
|
|
35593
35951
|
readBlockEndOfCentral: function() {
|
|
35594
35952
|
this.diskNumber = this.reader.readInt(2);
|
|
35595
35953
|
this.diskWithCentralDirStart = this.reader.readInt(2);
|
|
@@ -35603,6 +35961,12 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35603
35961
|
var decodeContent = utils.transformTo(decodeParamType, zipComment);
|
|
35604
35962
|
this.zipComment = this.loadOptions.decodeFileName(decodeContent);
|
|
35605
35963
|
},
|
|
35964
|
+
/**
|
|
35965
|
+
* Read the end of the Zip 64 central directory.
|
|
35966
|
+
* Not merged with the method readEndOfCentral :
|
|
35967
|
+
* The end of central can coexist with its Zip64 brother,
|
|
35968
|
+
* I don't want to read the wrong number of bytes !
|
|
35969
|
+
*/
|
|
35606
35970
|
readBlockZip64EndOfCentral: function() {
|
|
35607
35971
|
this.zip64EndOfCentralSize = this.reader.readInt(8);
|
|
35608
35972
|
this.reader.skip(4);
|
|
@@ -35625,12 +35989,18 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35625
35989
|
};
|
|
35626
35990
|
}
|
|
35627
35991
|
},
|
|
35992
|
+
/**
|
|
35993
|
+
* Read the end of the Zip 64 central directory locator.
|
|
35994
|
+
*/
|
|
35628
35995
|
readBlockZip64EndOfCentralLocator: function() {
|
|
35629
35996
|
this.diskWithZip64CentralDirStart = this.reader.readInt(4);
|
|
35630
35997
|
this.relativeOffsetEndOfZip64CentralDir = this.reader.readInt(8);
|
|
35631
35998
|
this.disksCount = this.reader.readInt(4);
|
|
35632
35999
|
if (this.disksCount > 1) throw new Error("Multi-volumes zip are not supported");
|
|
35633
36000
|
},
|
|
36001
|
+
/**
|
|
36002
|
+
* Read the local files, based on the offset read in the central part.
|
|
36003
|
+
*/
|
|
35634
36004
|
readLocalFiles: function() {
|
|
35635
36005
|
var i, file;
|
|
35636
36006
|
for (i = 0; i < this.files.length; i++) {
|
|
@@ -35642,6 +36012,9 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35642
36012
|
file.processAttributes();
|
|
35643
36013
|
}
|
|
35644
36014
|
},
|
|
36015
|
+
/**
|
|
36016
|
+
* Read the central directory.
|
|
36017
|
+
*/
|
|
35645
36018
|
readCentralDir: function() {
|
|
35646
36019
|
var file;
|
|
35647
36020
|
this.reader.setIndex(this.centralDirOffset);
|
|
@@ -35654,6 +36027,9 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35654
36027
|
if (this.centralDirRecords !== 0 && this.files.length === 0) throw new Error("Corrupted zip or bug: expected " + this.centralDirRecords + " records in central dir, got " + this.files.length);
|
|
35655
36028
|
}
|
|
35656
36029
|
},
|
|
36030
|
+
/**
|
|
36031
|
+
* Read the end of central directory.
|
|
36032
|
+
*/
|
|
35657
36033
|
readEndOfCentral: function() {
|
|
35658
36034
|
var offset = this.reader.lastIndexOfSignature(sig.CENTRAL_DIRECTORY_END);
|
|
35659
36035
|
if (offset < 0) if (!this.isSignature(0, sig.LOCAL_FILE_HEADER)) throw new Error("Can't find end of central directory : is this a zip file ? If it is, see https://stuk.github.io/jszip/documentation/howto/read_zip.html");
|
|
@@ -35689,6 +36065,10 @@ var require_zipEntries = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
35689
36065
|
prepareReader: function(data) {
|
|
35690
36066
|
this.reader = readerFor(data);
|
|
35691
36067
|
},
|
|
36068
|
+
/**
|
|
36069
|
+
* Read a zip file and create ZipEntries.
|
|
36070
|
+
* @param {String|ArrayBuffer|Uint8Array|Buffer} data the binary string representing a zip file.
|
|
36071
|
+
*/
|
|
35692
36072
|
load: function(data) {
|
|
35693
36073
|
this.prepareReader(data);
|
|
35694
36074
|
this.readEndOfCentral();
|
|
@@ -43372,5 +43752,4 @@ function transformTemplate(templateString, values) {
|
|
|
43372
43752
|
return result;
|
|
43373
43753
|
}
|
|
43374
43754
|
//#endregion
|
|
43375
|
-
|
|
43376
|
-
export { BuildLogger, ConfigBuilder, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, HotUpdateDirUtil, LEGACY_BUNDLE_ERROR, banner, colors, copyDirToTmp, createCopiedBundleArchive, createHotUpdaterConfigScaffold, createHotUpdaterConfigScaffoldFromBuilder, createLogWriter, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, decryptJson, encryptJson, ensureInstallPackages, getAndroidSdkPath, getCwd, getPackageManager, getReactNativeMetadatas, link, loadConfig, log, makeEnv, dist_exports as p, printBanner, promoteBundle, readPackageUp, renderImportStatements, resolveHotUpdaterServerVersion, resolvePackageVersion, stripAnsi, transformEnv, transformTemplate, writeHotUpdaterConfig };
|
|
43755
|
+
export { BuildLogger, ConfigBuilder, HOT_UPDATER_SERVER_PACKAGE_VERSION_ENV, HotUpdateDirUtil, LEGACY_BUNDLE_ERROR, banner, typedColors as colors, copyDirToTmp, createCopiedBundleArchive, createHotUpdaterConfigScaffold, createHotUpdaterConfigScaffoldFromBuilder, createLogWriter, createTarBr, createTarBrTargetFiles, createTarGz, createTarGzTargetFiles, createZip, createZipTargetFiles, decryptJson, encryptJson, ensureInstallPackages, getAndroidSdkPath, getCwd, getPackageManager, getReactNativeMetadatas, link, loadConfig, log, makeEnv, dist_exports as p, printBanner, promoteBundle, readPackageUp, renderImportStatements, resolveHotUpdaterServerVersion, resolvePackageVersion, stripAnsi, transformEnv, transformTemplate, writeHotUpdaterConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hot-updater/cli-tools",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"oxc-transform": "0.121.0",
|
|
47
47
|
"typescript": "6.0.2",
|
|
48
48
|
"unconfig": "7.5.0",
|
|
49
|
-
"@hot-updater/core": "0.31.
|
|
50
|
-
"@hot-updater/
|
|
49
|
+
"@hot-updater/plugin-core": "0.31.3",
|
|
50
|
+
"@hot-updater/core": "0.31.3"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"@clack/prompts": "1.0.1",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"semver": "^7.6.3",
|
|
63
63
|
"tar": "^7.5.1",
|
|
64
64
|
"workspace-tools": "^0.36.4",
|
|
65
|
-
"@hot-updater/test-utils": "0.31.
|
|
65
|
+
"@hot-updater/test-utils": "0.31.3"
|
|
66
66
|
},
|
|
67
67
|
"inlinedDependencies": {
|
|
68
68
|
"@babel/code-frame": "7.29.0",
|