@weapp-vite/hmr 0.2.2 → 0.3.0
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.d.mts +0 -16
- package/dist/index.mjs +7 -14
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/assets.d.ts
|
|
2
1
|
export interface HmrAsset {
|
|
3
2
|
fileName: string;
|
|
4
3
|
source: string | Uint8Array;
|
|
@@ -21,8 +20,6 @@ export declare class HmrAssetStore<T extends HmrAsset = HmrAsset> {
|
|
|
21
20
|
diff(assets: readonly T[], retainedFileNames?: Iterable<string>): HmrAssetChanges<T>;
|
|
22
21
|
commit(assets: readonly T[], write: (changes: HmrAssetChanges<T>) => Promise<void>, retainedFileNames?: Iterable<string>): Promise<HmrAssetChanges<T>>;
|
|
23
22
|
}
|
|
24
|
-
//#endregion
|
|
25
|
-
//#region src/types.d.ts
|
|
26
23
|
export interface HmrCompilerOutputRequest {
|
|
27
24
|
fileName: string;
|
|
28
25
|
code: string;
|
|
@@ -61,8 +58,6 @@ export interface HmrCompilerPreparation {
|
|
|
61
58
|
export interface HmrCompilerProvider {
|
|
62
59
|
prepareHmr?: (request: HmrCompilerRequest) => HmrCompilerPreparation | Promise<HmrCompilerPreparation>;
|
|
63
60
|
}
|
|
64
|
-
//#endregion
|
|
65
|
-
//#region src/batch.d.ts
|
|
66
61
|
export interface HmrSourceMap {
|
|
67
62
|
version: number;
|
|
68
63
|
sources: string[];
|
|
@@ -113,8 +108,6 @@ export declare function transformHmrPatch(patch: {
|
|
|
113
108
|
export declare function transformHmrBatch<B extends HmrBatch>(batch: B, preparations: readonly HmrCompilerPreparation[], options: {
|
|
114
109
|
sourcemap: boolean;
|
|
115
110
|
}): Promise<TransformedHmrBatch<B>>;
|
|
116
|
-
//#endregion
|
|
117
|
-
//#region src/compilerHost.d.ts
|
|
118
111
|
interface Provider {
|
|
119
112
|
prepare?: HmrCompilerProvider['prepareHmr'];
|
|
120
113
|
}
|
|
@@ -149,8 +142,6 @@ export declare class HmrCompilerHost {
|
|
|
149
142
|
freeze(changedFiles: readonly string[]): HmrCompilerRequest;
|
|
150
143
|
prepare(request: HmrCompilerRequest): Promise<HmrCompilerPreparation[]>;
|
|
151
144
|
}
|
|
152
|
-
//#endregion
|
|
153
|
-
//#region src/deliveryCoordinator.d.ts
|
|
154
145
|
export interface HmrDeliveryPreparation {
|
|
155
146
|
commit: () => Promise<void>;
|
|
156
147
|
publish: () => Promise<void>;
|
|
@@ -191,8 +182,6 @@ export declare class HmrDeliveryCoordinator {
|
|
|
191
182
|
private throwDisposalFailures;
|
|
192
183
|
private drain;
|
|
193
184
|
}
|
|
194
|
-
//#endregion
|
|
195
|
-
//#region src/errors.d.ts
|
|
196
185
|
export declare class CompilerHmrResyncError extends Error {
|
|
197
186
|
readonly files: readonly string[];
|
|
198
187
|
constructor(files: readonly string[], message: string);
|
|
@@ -201,13 +190,9 @@ export declare class CompilerHmrResyncError extends Error {
|
|
|
201
190
|
export declare class HmrPreparationCleanupError extends AggregateError {
|
|
202
191
|
constructor(failure: unknown, cleanupErrors: readonly unknown[]);
|
|
203
192
|
}
|
|
204
|
-
//#endregion
|
|
205
|
-
//#region src/retention.d.ts
|
|
206
193
|
export declare const maxRetainedDeltaCount = 1000;
|
|
207
194
|
export declare const maxRetainedDeltaBytes: number;
|
|
208
195
|
export declare function shouldResetStatefulHmrRetention(count: number, bytes: number, nextBytes: number): boolean;
|
|
209
|
-
//#endregion
|
|
210
|
-
//#region src/transaction.d.ts
|
|
211
196
|
export interface HmrBatchIdentity {
|
|
212
197
|
generation: string;
|
|
213
198
|
revision: number;
|
|
@@ -237,5 +222,4 @@ export declare class HmrTransaction<T> {
|
|
|
237
222
|
private isDisposed;
|
|
238
223
|
private deliver;
|
|
239
224
|
}
|
|
240
|
-
//#endregion
|
|
241
225
|
export {};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Buffer } from "node:buffer";
|
|
2
2
|
import remapping from "@jridgewell/remapping";
|
|
3
|
-
|
|
3
|
+
// src/assets.ts
|
|
4
4
|
function copyAsset(asset) {
|
|
5
5
|
return {
|
|
6
6
|
...asset,
|
|
@@ -63,8 +63,7 @@ var HmrAssetStore = class {
|
|
|
63
63
|
return changes;
|
|
64
64
|
}
|
|
65
65
|
};
|
|
66
|
-
|
|
67
|
-
//#region src/batch.ts
|
|
66
|
+
// src/batch.ts
|
|
68
67
|
/** 在回调入口保留完整元数据和原始顺序,不合并不同的源码代次。 */
|
|
69
68
|
function captureHmrBatch(batch) {
|
|
70
69
|
const snapshot = structuredClone(batch);
|
|
@@ -164,8 +163,7 @@ async function transformHmrBatch(batch, preparations, options) {
|
|
|
164
163
|
updates
|
|
165
164
|
};
|
|
166
165
|
}
|
|
167
|
-
|
|
168
|
-
//#region src/errors.ts
|
|
166
|
+
// src/errors.ts
|
|
169
167
|
var CompilerHmrResyncError = class extends Error {
|
|
170
168
|
files;
|
|
171
169
|
constructor(files, message) {
|
|
@@ -181,8 +179,7 @@ var HmrPreparationCleanupError = class extends AggregateError {
|
|
|
181
179
|
this.name = "HmrPreparationCleanupError";
|
|
182
180
|
}
|
|
183
181
|
};
|
|
184
|
-
|
|
185
|
-
//#region src/compilerHost.ts
|
|
182
|
+
// src/compilerHost.ts
|
|
186
183
|
/** 部分准备失败后仍尝试全部释放,保留最初的拒绝及每个清理错误。 */
|
|
187
184
|
async function rejectPreparations(results, failure) {
|
|
188
185
|
const failures = (await Promise.allSettled(results.map((result) => Promise.resolve().then(() => result.dispose?.())))).flatMap((result) => result.status === "rejected" ? [result.reason] : []);
|
|
@@ -294,15 +291,13 @@ var HmrCompilerHost = class {
|
|
|
294
291
|
return results;
|
|
295
292
|
}
|
|
296
293
|
};
|
|
297
|
-
|
|
298
|
-
//#region src/retention.ts
|
|
294
|
+
// src/retention.ts
|
|
299
295
|
const maxRetainedDeltaCount = 1e3;
|
|
300
296
|
const maxRetainedDeltaBytes = 16777216;
|
|
301
297
|
function shouldResetStatefulHmrRetention(count, bytes, nextBytes) {
|
|
302
298
|
return count >= 1e3 || bytes + nextBytes >= 16777216;
|
|
303
299
|
}
|
|
304
|
-
|
|
305
|
-
//#region src/deliveryCoordinator.ts
|
|
300
|
+
// src/deliveryCoordinator.ts
|
|
306
301
|
/** 编译结果可以提前准备,资产提交与客户端执行确认必须保持同一条交付链。 */
|
|
307
302
|
var HmrDeliveryCoordinator = class {
|
|
308
303
|
onError;
|
|
@@ -469,8 +464,7 @@ var HmrDeliveryCoordinator = class {
|
|
|
469
464
|
}
|
|
470
465
|
}
|
|
471
466
|
};
|
|
472
|
-
|
|
473
|
-
//#region src/transaction.ts
|
|
467
|
+
// src/transaction.ts
|
|
474
468
|
/** 可由现有宿主队列调度的单批事务;确认入口不占用或等待该队列。 */
|
|
475
469
|
var HmrTransaction = class {
|
|
476
470
|
options;
|
|
@@ -541,5 +535,4 @@ var HmrTransaction = class {
|
|
|
541
535
|
}
|
|
542
536
|
}
|
|
543
537
|
};
|
|
544
|
-
//#endregion
|
|
545
538
|
export { CompilerHmrResyncError, HmrAssetStore, HmrCompilerHost, HmrDeliveryCoordinator, HmrPreparationCleanupError, HmrTransaction, captureHmrBatch, composeHmrSourceMaps, maxRetainedDeltaBytes, maxRetainedDeltaCount, normalizeHmrSourceMap, shouldResetStatefulHmrRetention, transformHmrBatch, transformHmrPatch };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weapp-vite/hmr",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"description": "小程序宿主共享的编译批次、资产提交与交付协调内核",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://github.com/weapp-vite/weapp-vite#readme",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dist"
|
|
35
35
|
],
|
|
36
36
|
"engines": {
|
|
37
|
-
"node": "^
|
|
37
|
+
"node": "^22.23.4 || ^24.22.1 || >=26.12.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
40
|
"@jridgewell/remapping": "^2.3.5"
|