@cloudflare/vite-plugin 1.9.1 → 1.9.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.
|
@@ -4595,6 +4595,7 @@ var HEADER_SIZE = 20;
|
|
|
4595
4595
|
var PATH_HASH_SIZE = 16;
|
|
4596
4596
|
var CONTENT_HASH_SIZE = 16;
|
|
4597
4597
|
var TAIL_SIZE = 8;
|
|
4598
|
+
var CONTENT_HASH_OFFSET = PATH_HASH_SIZE;
|
|
4598
4599
|
var ENTRY_SIZE = PATH_HASH_SIZE + CONTENT_HASH_SIZE + TAIL_SIZE;
|
|
4599
4600
|
var MAX_ASSET_SIZE = 25 * 1024 * 1024;
|
|
4600
4601
|
|
|
@@ -4678,6 +4679,76 @@ var contentHashToKey = (buffer) => {
|
|
|
4678
4679
|
return [...contentHash].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
4679
4680
|
};
|
|
4680
4681
|
|
|
4682
|
+
// ../workers-shared/asset-worker/src/assets-manifest.2.ts
|
|
4683
|
+
var AssetsManifest2 = class {
|
|
4684
|
+
data;
|
|
4685
|
+
constructor(data) {
|
|
4686
|
+
this.data = new Uint8Array(data);
|
|
4687
|
+
}
|
|
4688
|
+
async get(pathname) {
|
|
4689
|
+
const pathHash = await hashPath2(pathname);
|
|
4690
|
+
const entry = binarySearch2(this.data, pathHash);
|
|
4691
|
+
return entry ? Uint8ToHexString(entry) : null;
|
|
4692
|
+
}
|
|
4693
|
+
};
|
|
4694
|
+
var hashPath2 = async (path) => {
|
|
4695
|
+
const encoder = new TextEncoder();
|
|
4696
|
+
const data = encoder.encode(path);
|
|
4697
|
+
const hashBuffer = await crypto.subtle.digest(
|
|
4698
|
+
"SHA-256",
|
|
4699
|
+
data.buffer
|
|
4700
|
+
);
|
|
4701
|
+
return new Uint8Array(hashBuffer, 0, PATH_HASH_SIZE);
|
|
4702
|
+
};
|
|
4703
|
+
var binarySearch2 = (manifest, pathHash) => {
|
|
4704
|
+
if (pathHash.byteLength !== PATH_HASH_SIZE) {
|
|
4705
|
+
throw new TypeError(
|
|
4706
|
+
`Search value should have a length of ${PATH_HASH_SIZE}`
|
|
4707
|
+
);
|
|
4708
|
+
}
|
|
4709
|
+
const numberOfEntries = (manifest.byteLength - HEADER_SIZE) / ENTRY_SIZE;
|
|
4710
|
+
if (numberOfEntries === 0) {
|
|
4711
|
+
return false;
|
|
4712
|
+
}
|
|
4713
|
+
let lowIndex = 0;
|
|
4714
|
+
let highIndex = numberOfEntries - 1;
|
|
4715
|
+
while (lowIndex <= highIndex) {
|
|
4716
|
+
const middleIndex = lowIndex + highIndex >> 1;
|
|
4717
|
+
const cmp = comparePathHashWithEntry(pathHash, manifest, middleIndex);
|
|
4718
|
+
if (cmp < 0) {
|
|
4719
|
+
highIndex = middleIndex - 1;
|
|
4720
|
+
continue;
|
|
4721
|
+
}
|
|
4722
|
+
if (cmp > 0) {
|
|
4723
|
+
lowIndex = middleIndex + 1;
|
|
4724
|
+
continue;
|
|
4725
|
+
}
|
|
4726
|
+
return new Uint8Array(
|
|
4727
|
+
manifest.buffer,
|
|
4728
|
+
HEADER_SIZE + middleIndex * ENTRY_SIZE + CONTENT_HASH_OFFSET,
|
|
4729
|
+
CONTENT_HASH_SIZE
|
|
4730
|
+
);
|
|
4731
|
+
}
|
|
4732
|
+
return false;
|
|
4733
|
+
};
|
|
4734
|
+
function comparePathHashWithEntry(searchValue, manifest, entryIndex) {
|
|
4735
|
+
let entryOffset = HEADER_SIZE + entryIndex * ENTRY_SIZE;
|
|
4736
|
+
for (let offset = 0; offset < PATH_HASH_SIZE; offset++, entryOffset++) {
|
|
4737
|
+
const s = searchValue[offset];
|
|
4738
|
+
const e = manifest[entryOffset];
|
|
4739
|
+
if (s < e) {
|
|
4740
|
+
return -1;
|
|
4741
|
+
}
|
|
4742
|
+
if (s > e) {
|
|
4743
|
+
return 1;
|
|
4744
|
+
}
|
|
4745
|
+
}
|
|
4746
|
+
return 0;
|
|
4747
|
+
}
|
|
4748
|
+
var Uint8ToHexString = (array) => {
|
|
4749
|
+
return [...array].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
4750
|
+
};
|
|
4751
|
+
|
|
4681
4752
|
// ../workers-shared/asset-worker/src/compatibility-flags.ts
|
|
4682
4753
|
var SEC_FETCH_MODE_NAVIGATE_HEADER_PREFERS_ASSET_SERVING = {
|
|
4683
4754
|
enable: "assets_navigation_prefers_asset_serving",
|
|
@@ -4761,7 +4832,10 @@ var ExperimentAnalytics = class {
|
|
|
4761
4832
|
this.data.manifestReadTime ?? -1
|
|
4762
4833
|
// double1
|
|
4763
4834
|
],
|
|
4764
|
-
blobs: [
|
|
4835
|
+
blobs: [
|
|
4836
|
+
this.data.binarySearchVersion
|
|
4837
|
+
// blob1
|
|
4838
|
+
]
|
|
4765
4839
|
});
|
|
4766
4840
|
}
|
|
4767
4841
|
};
|
|
@@ -5963,6 +6037,8 @@ var worker_default = class extends WorkerEntrypoint {
|
|
|
5963
6037
|
});
|
|
5964
6038
|
}
|
|
5965
6039
|
async unstable_exists(pathname, _request) {
|
|
6040
|
+
const BINARY_SEARCH_EXPERIMENT_SAMPLE_RATE = 0.5;
|
|
6041
|
+
const binarySearchVersion = Math.random() < BINARY_SEARCH_EXPERIMENT_SAMPLE_RATE ? "current" : "perfTest";
|
|
5966
6042
|
const analytics = new ExperimentAnalytics(this.env.EXPERIMENT_ANALYTICS);
|
|
5967
6043
|
const performance = new PerformanceTimer(this.env.UNSAFE_PERFORMANCE);
|
|
5968
6044
|
const jaeger = this.env.JAEGER ?? mockJaegerBinding();
|
|
@@ -5970,13 +6046,28 @@ var worker_default = class extends WorkerEntrypoint {
|
|
|
5970
6046
|
if (this.env.COLO_METADATA && this.env.VERSION_METADATA && this.env.CONFIG) {
|
|
5971
6047
|
analytics.setData({
|
|
5972
6048
|
accountId: this.env.CONFIG.account_id,
|
|
5973
|
-
experimentName: "manifest-read-timing"
|
|
6049
|
+
experimentName: "manifest-read-timing",
|
|
6050
|
+
binarySearchVersion
|
|
5974
6051
|
});
|
|
5975
6052
|
}
|
|
5976
6053
|
const startTimeMs = performance.now();
|
|
5977
6054
|
try {
|
|
5978
|
-
|
|
5979
|
-
|
|
6055
|
+
let eTag;
|
|
6056
|
+
if (binarySearchVersion === "perfTest") {
|
|
6057
|
+
try {
|
|
6058
|
+
const assetsManifest = new AssetsManifest2(
|
|
6059
|
+
this.env.ASSETS_MANIFEST
|
|
6060
|
+
);
|
|
6061
|
+
eTag = await assetsManifest.get(pathname);
|
|
6062
|
+
} catch {
|
|
6063
|
+
analytics.setData({ binarySearchVersion: "current-fallback" });
|
|
6064
|
+
const assetsManifest = new AssetsManifest(this.env.ASSETS_MANIFEST);
|
|
6065
|
+
eTag = await assetsManifest.get(pathname);
|
|
6066
|
+
}
|
|
6067
|
+
} else {
|
|
6068
|
+
const assetsManifest = new AssetsManifest(this.env.ASSETS_MANIFEST);
|
|
6069
|
+
eTag = await assetsManifest.get(pathname);
|
|
6070
|
+
}
|
|
5980
6071
|
span.setTags({
|
|
5981
6072
|
path: pathname,
|
|
5982
6073
|
found: eTag !== null,
|
|
@@ -4580,8 +4580,10 @@ var Analytics = class {
|
|
|
4580
4580
|
// double6
|
|
4581
4581
|
this.data.abuseMitigationBlocked ? 1 : 0,
|
|
4582
4582
|
// double7
|
|
4583
|
-
this.data.userWorkerFreeTierLimiting ? 1 : 0
|
|
4583
|
+
this.data.userWorkerFreeTierLimiting ? 1 : 0,
|
|
4584
4584
|
// double8
|
|
4585
|
+
this.data.timeToDispatch ?? -1
|
|
4586
|
+
// double9
|
|
4585
4587
|
],
|
|
4586
4588
|
blobs: [
|
|
4587
4589
|
this.data.hostname?.substring(0, 256),
|
|
@@ -6177,6 +6179,9 @@ var worker_default = {
|
|
|
6177
6179
|
}
|
|
6178
6180
|
}
|
|
6179
6181
|
}
|
|
6182
|
+
analytics.setData({
|
|
6183
|
+
timeToDispatch: performance.now() - startTimeMs
|
|
6184
|
+
});
|
|
6180
6185
|
if (shouldBlockNonImageResponse) {
|
|
6181
6186
|
const resp = await env.USER_WORKER.fetch(maybeSecondRequest);
|
|
6182
6187
|
const isImage = resp.headers.get("content-type")?.startsWith("image/");
|
|
@@ -6200,6 +6205,9 @@ var worker_default = {
|
|
|
6200
6205
|
asset,
|
|
6201
6206
|
dispatchType: "asset" /* ASSETS */
|
|
6202
6207
|
});
|
|
6208
|
+
analytics.setData({
|
|
6209
|
+
timeToDispatch: performance.now() - startTimeMs
|
|
6210
|
+
});
|
|
6203
6211
|
return env.ASSET_WORKER.fetch(maybeSecondRequest);
|
|
6204
6212
|
});
|
|
6205
6213
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudflare/vite-plugin",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "Cloudflare plugin for Vite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"tinyglobby": "^0.2.12",
|
|
42
42
|
"unenv": "2.0.0-rc.17",
|
|
43
43
|
"ws": "8.18.0",
|
|
44
|
-
"miniflare": "4.
|
|
45
|
-
"wrangler": "4.24.
|
|
44
|
+
"miniflare": "4.20250709.0",
|
|
45
|
+
"wrangler": "4.24.2"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@cloudflare/workers-types": "^4.
|
|
48
|
+
"@cloudflare/workers-types": "^4.20250709.0",
|
|
49
49
|
"@types/node": "^22.10.1",
|
|
50
50
|
"@types/ws": "^8.5.13",
|
|
51
51
|
"magic-string": "^0.30.12",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"vite": "7.0.0",
|
|
56
56
|
"vitest": "~3.2.0",
|
|
57
57
|
"@cloudflare/mock-npm-registry": "0.0.0",
|
|
58
|
-
"@cloudflare/workers-shared": "0.18.
|
|
58
|
+
"@cloudflare/workers-shared": "0.18.2",
|
|
59
59
|
"@cloudflare/workers-tsconfig": "0.0.0"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
62
|
"vite": "^6.1.0 || ^7.0.0",
|
|
63
|
-
"wrangler": "4.24.
|
|
63
|
+
"wrangler": "4.24.2"
|
|
64
64
|
},
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|