@hot-updater/repack 0.16.5

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/index.cjs ADDED
@@ -0,0 +1,348 @@
1
+ /*! For license information please see index.cjs.LICENSE.txt */
2
+ var __webpack_modules__ = {
3
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js": function(module) {
4
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
5
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
6
+ let formatter = (open, close, replace = open)=>(input)=>{
7
+ let string = "" + input, index = string.indexOf(close, open.length);
8
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
9
+ };
10
+ let replaceClose = (string, close, replace, index)=>{
11
+ let result = "", cursor = 0;
12
+ do {
13
+ result += string.substring(cursor, index) + replace;
14
+ cursor = index + close.length;
15
+ index = string.indexOf(close, cursor);
16
+ }while (~index);
17
+ return result + string.substring(cursor);
18
+ };
19
+ let createColors = (enabled = isColorSupported)=>{
20
+ let f = enabled ? formatter : ()=>String;
21
+ return {
22
+ isColorSupported: enabled,
23
+ reset: f("\x1b[0m", "\x1b[0m"),
24
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
25
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
26
+ italic: f("\x1b[3m", "\x1b[23m"),
27
+ underline: f("\x1b[4m", "\x1b[24m"),
28
+ inverse: f("\x1b[7m", "\x1b[27m"),
29
+ hidden: f("\x1b[8m", "\x1b[28m"),
30
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
31
+ black: f("\x1b[30m", "\x1b[39m"),
32
+ red: f("\x1b[31m", "\x1b[39m"),
33
+ green: f("\x1b[32m", "\x1b[39m"),
34
+ yellow: f("\x1b[33m", "\x1b[39m"),
35
+ blue: f("\x1b[34m", "\x1b[39m"),
36
+ magenta: f("\x1b[35m", "\x1b[39m"),
37
+ cyan: f("\x1b[36m", "\x1b[39m"),
38
+ white: f("\x1b[37m", "\x1b[39m"),
39
+ gray: f("\x1b[90m", "\x1b[39m"),
40
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
41
+ bgRed: f("\x1b[41m", "\x1b[49m"),
42
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
43
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
44
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
45
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
46
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
47
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
48
+ blackBright: f("\x1b[90m", "\x1b[39m"),
49
+ redBright: f("\x1b[91m", "\x1b[39m"),
50
+ greenBright: f("\x1b[92m", "\x1b[39m"),
51
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
52
+ blueBright: f("\x1b[94m", "\x1b[39m"),
53
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
54
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
55
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
56
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
57
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
58
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
59
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
60
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
61
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
62
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
63
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m")
64
+ };
65
+ };
66
+ module.exports = createColors();
67
+ module.exports.createColors = createColors;
68
+ }
69
+ };
70
+ var __webpack_module_cache__ = {};
71
+ function __webpack_require__(moduleId) {
72
+ var cachedModule = __webpack_module_cache__[moduleId];
73
+ if (void 0 !== cachedModule) return cachedModule.exports;
74
+ var module = __webpack_module_cache__[moduleId] = {
75
+ exports: {}
76
+ };
77
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
78
+ return module.exports;
79
+ }
80
+ (()=>{
81
+ __webpack_require__.n = (module)=>{
82
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
83
+ __webpack_require__.d(getter, {
84
+ a: getter
85
+ });
86
+ return getter;
87
+ };
88
+ })();
89
+ (()=>{
90
+ __webpack_require__.d = (exports1, definition)=>{
91
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
92
+ enumerable: true,
93
+ get: definition[key]
94
+ });
95
+ };
96
+ })();
97
+ (()=>{
98
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
99
+ })();
100
+ (()=>{
101
+ __webpack_require__.r = (exports1)=>{
102
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
103
+ value: 'Module'
104
+ });
105
+ Object.defineProperty(exports1, '__esModule', {
106
+ value: true
107
+ });
108
+ };
109
+ })();
110
+ var __webpack_exports__ = {};
111
+ (()=>{
112
+ "use strict";
113
+ __webpack_require__.r(__webpack_exports__);
114
+ __webpack_require__.d(__webpack_exports__, {
115
+ getChannel: ()=>getChannel,
116
+ HotUpdaterPlugin: ()=>HotUpdaterPlugin
117
+ });
118
+ const external_fs_namespaceObject = require("fs");
119
+ var external_fs_default = /*#__PURE__*/ __webpack_require__.n(external_fs_namespaceObject);
120
+ const external_path_namespaceObject = require("path");
121
+ var external_path_default = /*#__PURE__*/ __webpack_require__.n(external_path_namespaceObject);
122
+ const plugin_core_namespaceObject = require("@hot-updater/plugin-core");
123
+ var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
124
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
125
+ /**
126
+ * uuidv7: A JavaScript implementation of UUID version 7
127
+ *
128
+ * Copyright 2021-2024 LiosK
129
+ *
130
+ * @license Apache-2.0
131
+ * @packageDocumentation
132
+ */ const DIGITS = "0123456789abcdef";
133
+ class UUID {
134
+ constructor(bytes){
135
+ this.bytes = bytes;
136
+ }
137
+ static ofInner(bytes) {
138
+ if (16 === bytes.length) return new UUID(bytes);
139
+ throw new TypeError("not 128-bit length");
140
+ }
141
+ static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) {
142
+ if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 281474976710655 || randA > 0xfff || randBHi > 1073741823 || randBLo > 4294967295) throw new RangeError("invalid field value");
143
+ const bytes = new Uint8Array(16);
144
+ bytes[0] = unixTsMs / 2 ** 40;
145
+ bytes[1] = unixTsMs / 2 ** 32;
146
+ bytes[2] = unixTsMs / 2 ** 24;
147
+ bytes[3] = unixTsMs / 2 ** 16;
148
+ bytes[4] = unixTsMs / 256;
149
+ bytes[5] = unixTsMs;
150
+ bytes[6] = 0x70 | randA >>> 8;
151
+ bytes[7] = randA;
152
+ bytes[8] = 0x80 | randBHi >>> 24;
153
+ bytes[9] = randBHi >>> 16;
154
+ bytes[10] = randBHi >>> 8;
155
+ bytes[11] = randBHi;
156
+ bytes[12] = randBLo >>> 24;
157
+ bytes[13] = randBLo >>> 16;
158
+ bytes[14] = randBLo >>> 8;
159
+ bytes[15] = randBLo;
160
+ return new UUID(bytes);
161
+ }
162
+ static parse(uuid) {
163
+ var _a, _b, _c, _d;
164
+ let hex;
165
+ switch(uuid.length){
166
+ case 32:
167
+ hex = null == (_a = /^[0-9a-f]{32}$/i.exec(uuid)) ? void 0 : _a[0];
168
+ break;
169
+ case 36:
170
+ hex = null == (_b = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)) ? void 0 : _b.slice(1, 6).join("");
171
+ break;
172
+ case 38:
173
+ hex = null == (_c = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid)) ? void 0 : _c.slice(1, 6).join("");
174
+ break;
175
+ case 45:
176
+ hex = null == (_d = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)) ? void 0 : _d.slice(1, 6).join("");
177
+ break;
178
+ default:
179
+ break;
180
+ }
181
+ if (hex) {
182
+ const inner = new Uint8Array(16);
183
+ for(let i = 0; i < 16; i += 4){
184
+ const n = parseInt(hex.substring(2 * i, 2 * i + 8), 16);
185
+ inner[i + 0] = n >>> 24;
186
+ inner[i + 1] = n >>> 16;
187
+ inner[i + 2] = n >>> 8;
188
+ inner[i + 3] = n;
189
+ }
190
+ return new UUID(inner);
191
+ }
192
+ throw new SyntaxError("could not parse UUID string");
193
+ }
194
+ toString() {
195
+ let text = "";
196
+ for(let i = 0; i < this.bytes.length; i++){
197
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
198
+ text += DIGITS.charAt(0xf & this.bytes[i]);
199
+ if (3 === i || 5 === i || 7 === i || 9 === i) text += "-";
200
+ }
201
+ return text;
202
+ }
203
+ toHex() {
204
+ let text = "";
205
+ for(let i = 0; i < this.bytes.length; i++){
206
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
207
+ text += DIGITS.charAt(0xf & this.bytes[i]);
208
+ }
209
+ return text;
210
+ }
211
+ toJSON() {
212
+ return this.toString();
213
+ }
214
+ getVariant() {
215
+ const n = this.bytes[8] >>> 4;
216
+ if (n < 0) throw new Error("unreachable");
217
+ if (n <= 7) return this.bytes.every((e)=>0 === e) ? "NIL" : "VAR_0";
218
+ if (n <= 11) return "VAR_10";
219
+ if (n <= 13) return "VAR_110";
220
+ if (n <= 15) return this.bytes.every((e)=>0xff === e) ? "MAX" : "VAR_RESERVED";
221
+ else throw new Error("unreachable");
222
+ }
223
+ getVersion() {
224
+ return "VAR_10" === this.getVariant() ? this.bytes[6] >>> 4 : void 0;
225
+ }
226
+ clone() {
227
+ return new UUID(this.bytes.slice(0));
228
+ }
229
+ equals(other) {
230
+ return 0 === this.compareTo(other);
231
+ }
232
+ compareTo(other) {
233
+ for(let i = 0; i < 16; i++){
234
+ const diff = this.bytes[i] - other.bytes[i];
235
+ if (0 !== diff) return Math.sign(diff);
236
+ }
237
+ return 0;
238
+ }
239
+ }
240
+ class V7Generator {
241
+ constructor(randomNumberGenerator){
242
+ this.timestamp = 0;
243
+ this.counter = 0;
244
+ this.random = null != randomNumberGenerator ? randomNumberGenerator : getDefaultRandom();
245
+ }
246
+ generate() {
247
+ return this.generateOrResetCore(Date.now(), 10000);
248
+ }
249
+ generateOrAbort() {
250
+ return this.generateOrAbortCore(Date.now(), 10000);
251
+ }
252
+ generateOrResetCore(unixTsMs, rollbackAllowance) {
253
+ let value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
254
+ if (void 0 === value) {
255
+ this.timestamp = 0;
256
+ value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
257
+ }
258
+ return value;
259
+ }
260
+ generateOrAbortCore(unixTsMs, rollbackAllowance) {
261
+ const MAX_COUNTER = 4398046511103;
262
+ if (!Number.isInteger(unixTsMs) || unixTsMs < 1 || unixTsMs > 281474976710655) throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
263
+ if (rollbackAllowance < 0 || rollbackAllowance > 281474976710655) throw new RangeError("`rollbackAllowance` out of reasonable range");
264
+ if (unixTsMs > this.timestamp) {
265
+ this.timestamp = unixTsMs;
266
+ this.resetCounter();
267
+ } else {
268
+ if (!(unixTsMs + rollbackAllowance >= this.timestamp)) return;
269
+ this.counter++;
270
+ if (this.counter > MAX_COUNTER) {
271
+ this.timestamp++;
272
+ this.resetCounter();
273
+ }
274
+ }
275
+ return UUID.fromFieldsV7(this.timestamp, Math.trunc(this.counter / 2 ** 30), this.counter & 2 ** 30 - 1, this.random.nextUint32());
276
+ }
277
+ resetCounter() {
278
+ this.counter = 0x400 * this.random.nextUint32() + (0x3ff & this.random.nextUint32());
279
+ }
280
+ generateV4() {
281
+ const bytes = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
282
+ bytes[6] = 0x40 | bytes[6] >>> 4;
283
+ bytes[8] = 0x80 | bytes[8] >>> 2;
284
+ return UUID.ofInner(bytes);
285
+ }
286
+ }
287
+ const getDefaultRandom = ()=>{
288
+ if ("undefined" != typeof crypto && void 0 !== crypto.getRandomValues) return new BufferedCryptoRandom();
289
+ if ("undefined" != typeof UUIDV7_DENY_WEAK_RNG && UUIDV7_DENY_WEAK_RNG) throw new Error("no cryptographically strong RNG available");
290
+ return {
291
+ nextUint32: ()=>65536 * Math.trunc(65536 * Math.random()) + Math.trunc(65536 * Math.random())
292
+ };
293
+ };
294
+ class BufferedCryptoRandom {
295
+ constructor(){
296
+ this.buffer = new Uint32Array(8);
297
+ this.cursor = 0xffff;
298
+ }
299
+ nextUint32() {
300
+ if (this.cursor >= this.buffer.length) {
301
+ crypto.getRandomValues(this.buffer);
302
+ this.cursor = 0;
303
+ }
304
+ return this.buffer[this.cursor++];
305
+ }
306
+ }
307
+ let defaultGenerator;
308
+ const uuidv7 = ()=>uuidv7obj().toString();
309
+ const uuidv7obj = ()=>(defaultGenerator || (defaultGenerator = new V7Generator())).generate();
310
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
311
+ const getBundleId = ()=>{
312
+ const buildOutDir = process.env["BUILD_OUT_DIR"];
313
+ if (!buildOutDir) return NIL_UUID;
314
+ const bundleIdPath = external_path_default().join(buildOutDir, "BUNDLE_ID");
315
+ let bundleId = uuidv7();
316
+ if (external_fs_default().existsSync(bundleIdPath)) bundleId = external_fs_default().readFileSync(bundleIdPath, "utf-8");
317
+ else {
318
+ external_fs_default().writeFileSync(bundleIdPath, bundleId);
319
+ console.log(picocolors_default().green(`[HotUpdater] Generated bundle ID: ${bundleId}`));
320
+ }
321
+ return bundleId;
322
+ };
323
+ const getChannel = ()=>{
324
+ const currentEnv = process.env["BABEL_ENV"] || process.env["NODE_ENV"];
325
+ if ("development" === currentEnv) return null;
326
+ const envChannel = process.env["HOT_UPDATER_CHANNEL"];
327
+ if (envChannel) return envChannel;
328
+ const { releaseChannel } = (0, plugin_core_namespaceObject.loadConfigSync)(null);
329
+ return releaseChannel;
330
+ };
331
+ class HotUpdaterPlugin {
332
+ apply(compiler) {
333
+ new compiler.webpack.DefinePlugin({
334
+ __HOT_UPDATER_BUNDLE_ID: JSON.stringify(getBundleId()),
335
+ __HOT_UPDATER_CHANNEL: JSON.stringify(getChannel())
336
+ }).apply(compiler);
337
+ }
338
+ }
339
+ })();
340
+ exports.HotUpdaterPlugin = __webpack_exports__.HotUpdaterPlugin;
341
+ exports.getChannel = __webpack_exports__.getChannel;
342
+ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
343
+ "HotUpdaterPlugin",
344
+ "getChannel"
345
+ ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
346
+ Object.defineProperty(exports, '__esModule', {
347
+ value: true
348
+ });
@@ -0,0 +1,8 @@
1
+ /**
2
+ * uuidv7: A JavaScript implementation of UUID version 7
3
+ *
4
+ * Copyright 2021-2024 LiosK
5
+ *
6
+ * @license Apache-2.0
7
+ * @packageDocumentation
8
+ */
@@ -0,0 +1,5 @@
1
+ import type { Compiler, RspackPluginInstance } from "@rspack/core";
2
+ export declare const getChannel: () => string | null;
3
+ export declare class HotUpdaterPlugin implements RspackPluginInstance {
4
+ apply(compiler: Compiler): void;
5
+ }
package/dist/index.js ADDED
@@ -0,0 +1,319 @@
1
+ /*! For license information please see index.js.LICENSE.txt */
2
+ import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
3
+ import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
4
+ import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__ from "@hot-updater/plugin-core";
5
+ var __webpack_modules__ = {
6
+ "../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js": function(module) {
7
+ let p = process || {}, argv = p.argv || [], env = p.env || {};
8
+ let isColorSupported = !(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || "win32" === p.platform || (p.stdout || {}).isTTY && "dumb" !== env.TERM || !!env.CI);
9
+ let formatter = (open, close, replace = open)=>(input)=>{
10
+ let string = "" + input, index = string.indexOf(close, open.length);
11
+ return ~index ? open + replaceClose(string, close, replace, index) + close : open + string + close;
12
+ };
13
+ let replaceClose = (string, close, replace, index)=>{
14
+ let result = "", cursor = 0;
15
+ do {
16
+ result += string.substring(cursor, index) + replace;
17
+ cursor = index + close.length;
18
+ index = string.indexOf(close, cursor);
19
+ }while (~index);
20
+ return result + string.substring(cursor);
21
+ };
22
+ let createColors = (enabled = isColorSupported)=>{
23
+ let f = enabled ? formatter : ()=>String;
24
+ return {
25
+ isColorSupported: enabled,
26
+ reset: f("\x1b[0m", "\x1b[0m"),
27
+ bold: f("\x1b[1m", "\x1b[22m", "\x1b[22m\x1b[1m"),
28
+ dim: f("\x1b[2m", "\x1b[22m", "\x1b[22m\x1b[2m"),
29
+ italic: f("\x1b[3m", "\x1b[23m"),
30
+ underline: f("\x1b[4m", "\x1b[24m"),
31
+ inverse: f("\x1b[7m", "\x1b[27m"),
32
+ hidden: f("\x1b[8m", "\x1b[28m"),
33
+ strikethrough: f("\x1b[9m", "\x1b[29m"),
34
+ black: f("\x1b[30m", "\x1b[39m"),
35
+ red: f("\x1b[31m", "\x1b[39m"),
36
+ green: f("\x1b[32m", "\x1b[39m"),
37
+ yellow: f("\x1b[33m", "\x1b[39m"),
38
+ blue: f("\x1b[34m", "\x1b[39m"),
39
+ magenta: f("\x1b[35m", "\x1b[39m"),
40
+ cyan: f("\x1b[36m", "\x1b[39m"),
41
+ white: f("\x1b[37m", "\x1b[39m"),
42
+ gray: f("\x1b[90m", "\x1b[39m"),
43
+ bgBlack: f("\x1b[40m", "\x1b[49m"),
44
+ bgRed: f("\x1b[41m", "\x1b[49m"),
45
+ bgGreen: f("\x1b[42m", "\x1b[49m"),
46
+ bgYellow: f("\x1b[43m", "\x1b[49m"),
47
+ bgBlue: f("\x1b[44m", "\x1b[49m"),
48
+ bgMagenta: f("\x1b[45m", "\x1b[49m"),
49
+ bgCyan: f("\x1b[46m", "\x1b[49m"),
50
+ bgWhite: f("\x1b[47m", "\x1b[49m"),
51
+ blackBright: f("\x1b[90m", "\x1b[39m"),
52
+ redBright: f("\x1b[91m", "\x1b[39m"),
53
+ greenBright: f("\x1b[92m", "\x1b[39m"),
54
+ yellowBright: f("\x1b[93m", "\x1b[39m"),
55
+ blueBright: f("\x1b[94m", "\x1b[39m"),
56
+ magentaBright: f("\x1b[95m", "\x1b[39m"),
57
+ cyanBright: f("\x1b[96m", "\x1b[39m"),
58
+ whiteBright: f("\x1b[97m", "\x1b[39m"),
59
+ bgBlackBright: f("\x1b[100m", "\x1b[49m"),
60
+ bgRedBright: f("\x1b[101m", "\x1b[49m"),
61
+ bgGreenBright: f("\x1b[102m", "\x1b[49m"),
62
+ bgYellowBright: f("\x1b[103m", "\x1b[49m"),
63
+ bgBlueBright: f("\x1b[104m", "\x1b[49m"),
64
+ bgMagentaBright: f("\x1b[105m", "\x1b[49m"),
65
+ bgCyanBright: f("\x1b[106m", "\x1b[49m"),
66
+ bgWhiteBright: f("\x1b[107m", "\x1b[49m")
67
+ };
68
+ };
69
+ module.exports = createColors();
70
+ module.exports.createColors = createColors;
71
+ }
72
+ };
73
+ var __webpack_module_cache__ = {};
74
+ function __webpack_require__(moduleId) {
75
+ var cachedModule = __webpack_module_cache__[moduleId];
76
+ if (void 0 !== cachedModule) return cachedModule.exports;
77
+ var module = __webpack_module_cache__[moduleId] = {
78
+ exports: {}
79
+ };
80
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
81
+ return module.exports;
82
+ }
83
+ (()=>{
84
+ __webpack_require__.n = (module)=>{
85
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
86
+ __webpack_require__.d(getter, {
87
+ a: getter
88
+ });
89
+ return getter;
90
+ };
91
+ })();
92
+ (()=>{
93
+ __webpack_require__.d = (exports, definition)=>{
94
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
95
+ enumerable: true,
96
+ get: definition[key]
97
+ });
98
+ };
99
+ })();
100
+ (()=>{
101
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
102
+ })();
103
+ var picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
104
+ var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
105
+ /**
106
+ * uuidv7: A JavaScript implementation of UUID version 7
107
+ *
108
+ * Copyright 2021-2024 LiosK
109
+ *
110
+ * @license Apache-2.0
111
+ * @packageDocumentation
112
+ */ const DIGITS = "0123456789abcdef";
113
+ class UUID {
114
+ constructor(bytes){
115
+ this.bytes = bytes;
116
+ }
117
+ static ofInner(bytes) {
118
+ if (16 === bytes.length) return new UUID(bytes);
119
+ throw new TypeError("not 128-bit length");
120
+ }
121
+ static fromFieldsV7(unixTsMs, randA, randBHi, randBLo) {
122
+ if (!Number.isInteger(unixTsMs) || !Number.isInteger(randA) || !Number.isInteger(randBHi) || !Number.isInteger(randBLo) || unixTsMs < 0 || randA < 0 || randBHi < 0 || randBLo < 0 || unixTsMs > 281474976710655 || randA > 0xfff || randBHi > 1073741823 || randBLo > 4294967295) throw new RangeError("invalid field value");
123
+ const bytes = new Uint8Array(16);
124
+ bytes[0] = unixTsMs / 2 ** 40;
125
+ bytes[1] = unixTsMs / 2 ** 32;
126
+ bytes[2] = unixTsMs / 2 ** 24;
127
+ bytes[3] = unixTsMs / 2 ** 16;
128
+ bytes[4] = unixTsMs / 256;
129
+ bytes[5] = unixTsMs;
130
+ bytes[6] = 0x70 | randA >>> 8;
131
+ bytes[7] = randA;
132
+ bytes[8] = 0x80 | randBHi >>> 24;
133
+ bytes[9] = randBHi >>> 16;
134
+ bytes[10] = randBHi >>> 8;
135
+ bytes[11] = randBHi;
136
+ bytes[12] = randBLo >>> 24;
137
+ bytes[13] = randBLo >>> 16;
138
+ bytes[14] = randBLo >>> 8;
139
+ bytes[15] = randBLo;
140
+ return new UUID(bytes);
141
+ }
142
+ static parse(uuid) {
143
+ var _a, _b, _c, _d;
144
+ let hex;
145
+ switch(uuid.length){
146
+ case 32:
147
+ hex = null == (_a = /^[0-9a-f]{32}$/i.exec(uuid)) ? void 0 : _a[0];
148
+ break;
149
+ case 36:
150
+ hex = null == (_b = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)) ? void 0 : _b.slice(1, 6).join("");
151
+ break;
152
+ case 38:
153
+ hex = null == (_c = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(uuid)) ? void 0 : _c.slice(1, 6).join("");
154
+ break;
155
+ case 45:
156
+ hex = null == (_d = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(uuid)) ? void 0 : _d.slice(1, 6).join("");
157
+ break;
158
+ default:
159
+ break;
160
+ }
161
+ if (hex) {
162
+ const inner = new Uint8Array(16);
163
+ for(let i = 0; i < 16; i += 4){
164
+ const n = parseInt(hex.substring(2 * i, 2 * i + 8), 16);
165
+ inner[i + 0] = n >>> 24;
166
+ inner[i + 1] = n >>> 16;
167
+ inner[i + 2] = n >>> 8;
168
+ inner[i + 3] = n;
169
+ }
170
+ return new UUID(inner);
171
+ }
172
+ throw new SyntaxError("could not parse UUID string");
173
+ }
174
+ toString() {
175
+ let text = "";
176
+ for(let i = 0; i < this.bytes.length; i++){
177
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
178
+ text += DIGITS.charAt(0xf & this.bytes[i]);
179
+ if (3 === i || 5 === i || 7 === i || 9 === i) text += "-";
180
+ }
181
+ return text;
182
+ }
183
+ toHex() {
184
+ let text = "";
185
+ for(let i = 0; i < this.bytes.length; i++){
186
+ text += DIGITS.charAt(this.bytes[i] >>> 4);
187
+ text += DIGITS.charAt(0xf & this.bytes[i]);
188
+ }
189
+ return text;
190
+ }
191
+ toJSON() {
192
+ return this.toString();
193
+ }
194
+ getVariant() {
195
+ const n = this.bytes[8] >>> 4;
196
+ if (n < 0) throw new Error("unreachable");
197
+ if (n <= 7) return this.bytes.every((e)=>0 === e) ? "NIL" : "VAR_0";
198
+ if (n <= 11) return "VAR_10";
199
+ if (n <= 13) return "VAR_110";
200
+ if (n <= 15) return this.bytes.every((e)=>0xff === e) ? "MAX" : "VAR_RESERVED";
201
+ else throw new Error("unreachable");
202
+ }
203
+ getVersion() {
204
+ return "VAR_10" === this.getVariant() ? this.bytes[6] >>> 4 : void 0;
205
+ }
206
+ clone() {
207
+ return new UUID(this.bytes.slice(0));
208
+ }
209
+ equals(other) {
210
+ return 0 === this.compareTo(other);
211
+ }
212
+ compareTo(other) {
213
+ for(let i = 0; i < 16; i++){
214
+ const diff = this.bytes[i] - other.bytes[i];
215
+ if (0 !== diff) return Math.sign(diff);
216
+ }
217
+ return 0;
218
+ }
219
+ }
220
+ class V7Generator {
221
+ constructor(randomNumberGenerator){
222
+ this.timestamp = 0;
223
+ this.counter = 0;
224
+ this.random = null != randomNumberGenerator ? randomNumberGenerator : getDefaultRandom();
225
+ }
226
+ generate() {
227
+ return this.generateOrResetCore(Date.now(), 10000);
228
+ }
229
+ generateOrAbort() {
230
+ return this.generateOrAbortCore(Date.now(), 10000);
231
+ }
232
+ generateOrResetCore(unixTsMs, rollbackAllowance) {
233
+ let value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
234
+ if (void 0 === value) {
235
+ this.timestamp = 0;
236
+ value = this.generateOrAbortCore(unixTsMs, rollbackAllowance);
237
+ }
238
+ return value;
239
+ }
240
+ generateOrAbortCore(unixTsMs, rollbackAllowance) {
241
+ const MAX_COUNTER = 4398046511103;
242
+ if (!Number.isInteger(unixTsMs) || unixTsMs < 1 || unixTsMs > 281474976710655) throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
243
+ if (rollbackAllowance < 0 || rollbackAllowance > 281474976710655) throw new RangeError("`rollbackAllowance` out of reasonable range");
244
+ if (unixTsMs > this.timestamp) {
245
+ this.timestamp = unixTsMs;
246
+ this.resetCounter();
247
+ } else {
248
+ if (!(unixTsMs + rollbackAllowance >= this.timestamp)) return;
249
+ this.counter++;
250
+ if (this.counter > MAX_COUNTER) {
251
+ this.timestamp++;
252
+ this.resetCounter();
253
+ }
254
+ }
255
+ return UUID.fromFieldsV7(this.timestamp, Math.trunc(this.counter / 2 ** 30), this.counter & 2 ** 30 - 1, this.random.nextUint32());
256
+ }
257
+ resetCounter() {
258
+ this.counter = 0x400 * this.random.nextUint32() + (0x3ff & this.random.nextUint32());
259
+ }
260
+ generateV4() {
261
+ const bytes = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
262
+ bytes[6] = 0x40 | bytes[6] >>> 4;
263
+ bytes[8] = 0x80 | bytes[8] >>> 2;
264
+ return UUID.ofInner(bytes);
265
+ }
266
+ }
267
+ const getDefaultRandom = ()=>{
268
+ if ("undefined" != typeof crypto && void 0 !== crypto.getRandomValues) return new BufferedCryptoRandom();
269
+ if ("undefined" != typeof UUIDV7_DENY_WEAK_RNG && UUIDV7_DENY_WEAK_RNG) throw new Error("no cryptographically strong RNG available");
270
+ return {
271
+ nextUint32: ()=>65536 * Math.trunc(65536 * Math.random()) + Math.trunc(65536 * Math.random())
272
+ };
273
+ };
274
+ class BufferedCryptoRandom {
275
+ constructor(){
276
+ this.buffer = new Uint32Array(8);
277
+ this.cursor = 0xffff;
278
+ }
279
+ nextUint32() {
280
+ if (this.cursor >= this.buffer.length) {
281
+ crypto.getRandomValues(this.buffer);
282
+ this.cursor = 0;
283
+ }
284
+ return this.buffer[this.cursor++];
285
+ }
286
+ }
287
+ let defaultGenerator;
288
+ const uuidv7 = ()=>uuidv7obj().toString();
289
+ const uuidv7obj = ()=>(defaultGenerator || (defaultGenerator = new V7Generator())).generate();
290
+ const NIL_UUID = "00000000-0000-0000-0000-000000000000";
291
+ const getBundleId = ()=>{
292
+ const buildOutDir = process.env["BUILD_OUT_DIR"];
293
+ if (!buildOutDir) return NIL_UUID;
294
+ const bundleIdPath = __WEBPACK_EXTERNAL_MODULE_path__["default"].join(buildOutDir, "BUNDLE_ID");
295
+ let bundleId = uuidv7();
296
+ if (__WEBPACK_EXTERNAL_MODULE_fs__["default"].existsSync(bundleIdPath)) bundleId = __WEBPACK_EXTERNAL_MODULE_fs__["default"].readFileSync(bundleIdPath, "utf-8");
297
+ else {
298
+ __WEBPACK_EXTERNAL_MODULE_fs__["default"].writeFileSync(bundleIdPath, bundleId);
299
+ console.log(picocolors_default().green(`[HotUpdater] Generated bundle ID: ${bundleId}`));
300
+ }
301
+ return bundleId;
302
+ };
303
+ const getChannel = ()=>{
304
+ const currentEnv = process.env["BABEL_ENV"] || process.env["NODE_ENV"];
305
+ if ("development" === currentEnv) return null;
306
+ const envChannel = process.env["HOT_UPDATER_CHANNEL"];
307
+ if (envChannel) return envChannel;
308
+ const { releaseChannel } = (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__.loadConfigSync)(null);
309
+ return releaseChannel;
310
+ };
311
+ class HotUpdaterPlugin {
312
+ apply(compiler) {
313
+ new compiler.webpack.DefinePlugin({
314
+ __HOT_UPDATER_BUNDLE_ID: JSON.stringify(getBundleId()),
315
+ __HOT_UPDATER_CHANNEL: JSON.stringify(getChannel())
316
+ }).apply(compiler);
317
+ }
318
+ }
319
+ export { HotUpdaterPlugin, getChannel };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * uuidv7: A JavaScript implementation of UUID version 7
3
+ *
4
+ * Copyright 2021-2024 LiosK
5
+ *
6
+ * @license Apache-2.0
7
+ * @packageDocumentation
8
+ */
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@hot-updater/repack",
3
+ "type": "module",
4
+ "version": "0.16.5",
5
+ "description": "React Native OTA solution for self-hosted",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.js",
8
+ "types": "dist/index.d.ts",
9
+ "license": "MIT",
10
+ "repository": "https://github.com/gronxb/hot-updater",
11
+ "author": "gronxb <gron1gh1@gmail.com> (https://github.com/gronxb)",
12
+ "bugs": {
13
+ "url": "https://github.com/gronxb/hot-updater/issues"
14
+ },
15
+ "homepage": "https://github.com/gronxb/hot-updater#readme",
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "files": [
20
+ "dist",
21
+ "package.json"
22
+ ],
23
+ "devDependencies": {
24
+ "@callstack/repack": "5.0.6",
25
+ "@rspack/core": "1.3.7",
26
+ "@types/node": "^22.8.7",
27
+ "picocolors": "^1.0.0",
28
+ "uuidv7": "^1.0.2"
29
+ },
30
+ "peerDependencies": {
31
+ "@callstack/repack": "*"
32
+ },
33
+ "dependencies": {
34
+ "@hot-updater/plugin-core": "0.16.5"
35
+ },
36
+ "scripts": {
37
+ "build": "rslib build",
38
+ "test:type": "tsc --noEmit"
39
+ }
40
+ }