@cloudflare/vite-plugin 1.9.3 → 1.9.4

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,103 +4595,24 @@ 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 PATH_HASH_OFFSET = 0;
4598
4599
  var CONTENT_HASH_OFFSET = PATH_HASH_SIZE;
4599
4600
  var ENTRY_SIZE = PATH_HASH_SIZE + CONTENT_HASH_SIZE + TAIL_SIZE;
4600
4601
  var MAX_ASSET_SIZE = 25 * 1024 * 1024;
4601
4602
 
4602
4603
  // ../workers-shared/asset-worker/src/assets-manifest.ts
4603
4604
  var AssetsManifest = class {
4604
- data;
4605
- constructor(data) {
4606
- this.data = data;
4607
- }
4608
- async get(pathname) {
4609
- const pathHash = await hashPath(pathname);
4610
- const entry = binarySearch(
4611
- new Uint8Array(this.data, HEADER_SIZE),
4612
- pathHash
4613
- );
4614
- return entry ? contentHashToKey(entry) : null;
4615
- }
4616
- };
4617
- var hashPath = async (path) => {
4618
- const encoder = new TextEncoder();
4619
- const data = encoder.encode(path);
4620
- const hashBuffer = await crypto.subtle.digest(
4621
- "SHA-256",
4622
- data.buffer
4623
- );
4624
- return new Uint8Array(hashBuffer, 0, PATH_HASH_SIZE);
4625
- };
4626
- var binarySearch = (arr, searchValue) => {
4627
- if (arr.byteLength === 0) {
4628
- return false;
4629
- }
4630
- const offset = arr.byteOffset + (arr.byteLength / ENTRY_SIZE >> 1) * ENTRY_SIZE;
4631
- const current = new Uint8Array(arr.buffer, offset, PATH_HASH_SIZE);
4632
- if (current.byteLength !== searchValue.byteLength) {
4633
- throw new TypeError(
4634
- "Search value and current value are of different lengths"
4635
- );
4636
- }
4637
- const cmp = compare(searchValue, current);
4638
- if (cmp < 0) {
4639
- const nextOffset = arr.byteOffset;
4640
- const nextLength = offset - arr.byteOffset;
4641
- return binarySearch(
4642
- new Uint8Array(arr.buffer, nextOffset, nextLength),
4643
- searchValue
4644
- );
4645
- } else if (cmp > 0) {
4646
- const nextOffset = offset + ENTRY_SIZE;
4647
- const nextLength = arr.buffer.byteLength - offset - ENTRY_SIZE;
4648
- return binarySearch(
4649
- new Uint8Array(arr.buffer, nextOffset, nextLength),
4650
- searchValue
4651
- );
4652
- } else {
4653
- return new Uint8Array(arr.buffer, offset, ENTRY_SIZE);
4654
- }
4655
- };
4656
- var compare = (a, b) => {
4657
- if (a.byteLength < b.byteLength) {
4658
- return -1;
4659
- }
4660
- if (a.byteLength > b.byteLength) {
4661
- return 1;
4662
- }
4663
- for (const [i, v] of a.entries()) {
4664
- const bVal = b[i];
4665
- if (v < bVal) {
4666
- return -1;
4667
- }
4668
- if (v > bVal) {
4669
- return 1;
4670
- }
4671
- }
4672
- return 0;
4673
- };
4674
- var contentHashToKey = (buffer) => {
4675
- const contentHash = buffer.slice(
4676
- PATH_HASH_SIZE,
4677
- PATH_HASH_SIZE + CONTENT_HASH_SIZE
4678
- );
4679
- return [...contentHash].map((b) => b.toString(16).padStart(2, "0")).join("");
4680
- };
4681
-
4682
- // ../workers-shared/asset-worker/src/assets-manifest.2.ts
4683
- var AssetsManifest2 = class {
4684
4605
  data;
4685
4606
  constructor(data) {
4686
4607
  this.data = new Uint8Array(data);
4687
4608
  }
4688
4609
  async get(pathname) {
4689
- const pathHash = await hashPath2(pathname);
4690
- const entry = binarySearch2(this.data, pathHash);
4610
+ const pathHash = await hashPath(pathname);
4611
+ const entry = binarySearch(this.data, pathHash);
4691
4612
  return entry ? Uint8ToHexString(entry) : null;
4692
4613
  }
4693
4614
  };
4694
- var hashPath2 = async (path) => {
4615
+ var hashPath = async (path) => {
4695
4616
  const encoder = new TextEncoder();
4696
4617
  const data = encoder.encode(path);
4697
4618
  const hashBuffer = await crypto.subtle.digest(
@@ -4700,7 +4621,7 @@ var hashPath2 = async (path) => {
4700
4621
  );
4701
4622
  return new Uint8Array(hashBuffer, 0, PATH_HASH_SIZE);
4702
4623
  };
4703
- var binarySearch2 = (manifest, pathHash) => {
4624
+ var binarySearch = (manifest, pathHash) => {
4704
4625
  if (pathHash.byteLength !== PATH_HASH_SIZE) {
4705
4626
  throw new TypeError(
4706
4627
  `Search value should have a length of ${PATH_HASH_SIZE}`
@@ -4732,10 +4653,10 @@ var binarySearch2 = (manifest, pathHash) => {
4732
4653
  return false;
4733
4654
  };
4734
4655
  function comparePathHashWithEntry(searchValue, manifest, entryIndex) {
4735
- let entryOffset = HEADER_SIZE + entryIndex * ENTRY_SIZE;
4736
- for (let offset = 0; offset < PATH_HASH_SIZE; offset++, entryOffset++) {
4656
+ let pathHashOffset = HEADER_SIZE + entryIndex * ENTRY_SIZE + PATH_HASH_OFFSET;
4657
+ for (let offset = 0; offset < PATH_HASH_SIZE; offset++, pathHashOffset++) {
4737
4658
  const s = searchValue[offset];
4738
- const e = manifest[entryOffset];
4659
+ const e = manifest[pathHashOffset];
4739
4660
  if (s < e) {
4740
4661
  return -1;
4741
4662
  }
@@ -6037,8 +5958,6 @@ var worker_default = class extends WorkerEntrypoint {
6037
5958
  });
6038
5959
  }
6039
5960
  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";
6042
5961
  const analytics = new ExperimentAnalytics(this.env.EXPERIMENT_ANALYTICS);
6043
5962
  const performance = new PerformanceTimer(this.env.UNSAFE_PERFORMANCE);
6044
5963
  const jaeger = this.env.JAEGER ?? mockJaegerBinding();
@@ -6046,28 +5965,13 @@ var worker_default = class extends WorkerEntrypoint {
6046
5965
  if (this.env.COLO_METADATA && this.env.VERSION_METADATA && this.env.CONFIG) {
6047
5966
  analytics.setData({
6048
5967
  accountId: this.env.CONFIG.account_id,
6049
- experimentName: "manifest-read-timing",
6050
- binarySearchVersion
5968
+ experimentName: "manifest-read-timing"
6051
5969
  });
6052
5970
  }
6053
5971
  const startTimeMs = performance.now();
6054
5972
  try {
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
- }
5973
+ const assetsManifest = new AssetsManifest(this.env.ASSETS_MANIFEST);
5974
+ const eTag = await assetsManifest.get(pathname);
6071
5975
  span.setTags({
6072
5976
  path: pathname,
6073
5977
  found: eTag !== null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudflare/vite-plugin",
3
- "version": "1.9.3",
3
+ "version": "1.9.4",
4
4
  "description": "Cloudflare plugin for Vite",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -42,7 +42,7 @@
42
42
  "unenv": "2.0.0-rc.17",
43
43
  "ws": "8.18.0",
44
44
  "miniflare": "4.20250709.0",
45
- "wrangler": "4.24.2"
45
+ "wrangler": "4.24.3"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@cloudflare/workers-types": "^4.20250709.0",
@@ -54,13 +54,13 @@
54
54
  "typescript": "^5.7.2",
55
55
  "vite": "7.0.0",
56
56
  "vitest": "~3.2.0",
57
+ "@cloudflare/workers-shared": "0.18.3",
57
58
  "@cloudflare/mock-npm-registry": "0.0.0",
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.2"
63
+ "wrangler": "4.24.3"
64
64
  },
65
65
  "publishConfig": {
66
66
  "access": "public"