nitropack-nightly 2.11.0-20250221-151704.a7feefae → 2.11.0-20250221-163722.f7e0e885

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.
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250221-151704.a7feefae";
1
+ const version = "2.11.0-20250221-163722.f7e0e885";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250221-151704.a7feefae";
1
+ const version = "2.11.0-20250221-163722.f7e0e885";
2
2
 
3
3
  export { version };
@@ -1,3 +1,3 @@
1
- const version = "2.11.0-20250221-151704.a7feefae";
1
+ const version = "2.11.0-20250221-163722.f7e0e885";
2
2
 
3
3
  export { version };
@@ -1089,7 +1089,7 @@ function unique(arr) {
1089
1089
  return [...new Set(arr)];
1090
1090
  }
1091
1091
  function getImportId(p, lazy) {
1092
- return (lazy ? "_lazy_" : "_") + hash(p).slice(0, 6);
1092
+ return (lazy ? "_lazy_" : "_") + hash(p).replace(/-/g, "").slice(0, 6);
1093
1093
  }
1094
1094
  const WILDCARD_PATH_RE = /\/\*\*.*$/;
1095
1095
  function extendMiddlewareWithRuleOverlaps(handlers2, routeRules) {
@@ -1967,10 +1967,12 @@ const getRollupConfig = (nitro) => {
1967
1967
  virtual(
1968
1968
  {
1969
1969
  "#nitro-internal-virtual/plugins": `
1970
- ${nitroPlugins.map((plugin) => `import _${hash(plugin)} from '${plugin}';`).join("\n")}
1970
+ ${nitroPlugins.map(
1971
+ (plugin) => `import _${hash(plugin).replace(/-/g, "")} from '${plugin}';`
1972
+ ).join("\n")}
1971
1973
 
1972
1974
  export const plugins = [
1973
- ${nitroPlugins.map((plugin) => `_${hash(plugin)}`).join(",\n")}
1975
+ ${nitroPlugins.map((plugin) => `_${hash(plugin).replace(/-/g, "")}`).join(",\n")}
1974
1976
  ]
1975
1977
  `
1976
1978
  },
@@ -6,10 +6,10 @@ import {
6
6
  isEvent,
7
7
  splitCookiesString
8
8
  } from "h3";
9
- import { hash } from "ohash";
10
9
  import { parseURL } from "ufo";
11
10
  import { useNitroApp } from "./app.mjs";
12
11
  import { useStorage } from "./storage.mjs";
12
+ import { hash } from "./hash.mjs";
13
13
  function defaultCacheOptions() {
14
14
  return {
15
15
  name: "_",
@@ -119,7 +119,7 @@ export function cachedFunction(fn, opts = {}) {
119
119
  return defineCachedFunction(fn, opts);
120
120
  }
121
121
  function getKey(...args) {
122
- return args.length > 0 ? hash(args, {}) : "";
122
+ return args.length > 0 ? hash(args) : "";
123
123
  }
124
124
  function escapeKey(key) {
125
125
  return String(key).replace(/\W/g, "");
@@ -0,0 +1,6 @@
1
+ export declare function hash(value: any): any;
2
+ /**
3
+ Source: https://github.com/unjs/ohash/blob/v1/src/object-hash.ts
4
+ Based on https://github.com/puleos/object-hash v3.0.0 (MIT)
5
+ */
6
+ export declare function serialize(object: any): string;
@@ -0,0 +1,179 @@
1
+ import { digest } from "ohash";
2
+ export function hash(value) {
3
+ return digest(typeof value === "string" ? value : serialize(value)).replace(/[-_]/g, "").slice(0, 10);
4
+ }
5
+ export function serialize(object) {
6
+ const hasher = new Hasher();
7
+ hasher.dispatch(object);
8
+ return hasher.buff;
9
+ }
10
+ class Hasher {
11
+ buff = "";
12
+ #context = /* @__PURE__ */ new Map();
13
+ write(str) {
14
+ this.buff += str;
15
+ }
16
+ dispatch(value) {
17
+ const type = value === null ? "null" : typeof value;
18
+ return this[type](value);
19
+ }
20
+ object(object) {
21
+ if (object && typeof object.toJSON === "function") {
22
+ return this.object(object.toJSON());
23
+ }
24
+ const objString = Object.prototype.toString.call(object);
25
+ let objType = "";
26
+ const objectLength = objString.length;
27
+ objType = objectLength < 10 ? "unknown:[" + objString + "]" : objString.slice(8, objectLength - 1);
28
+ objType = objType.toLowerCase();
29
+ let objectNumber = null;
30
+ if ((objectNumber = this.#context.get(object)) === void 0) {
31
+ this.#context.set(object, this.#context.size);
32
+ } else {
33
+ return this.dispatch("[CIRCULAR:" + objectNumber + "]");
34
+ }
35
+ if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
36
+ this.write("buffer:");
37
+ return this.write(object.toString("utf8"));
38
+ }
39
+ if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
40
+ if (this[objType]) {
41
+ this[objType](object);
42
+ } else {
43
+ this.unknown(object, objType);
44
+ }
45
+ } else {
46
+ const keys = Object.keys(object).sort();
47
+ const extraKeys = [];
48
+ this.write("object:" + (keys.length + extraKeys.length) + ":");
49
+ const dispatchForKey = (key) => {
50
+ this.dispatch(key);
51
+ this.write(":");
52
+ this.dispatch(object[key]);
53
+ this.write(",");
54
+ };
55
+ for (const key of keys) {
56
+ dispatchForKey(key);
57
+ }
58
+ for (const key of extraKeys) {
59
+ dispatchForKey(key);
60
+ }
61
+ }
62
+ }
63
+ array(arr, unordered) {
64
+ unordered = unordered === void 0 ? false : unordered;
65
+ this.write("array:" + arr.length + ":");
66
+ if (!unordered || arr.length <= 1) {
67
+ for (const entry of arr) {
68
+ this.dispatch(entry);
69
+ }
70
+ return;
71
+ }
72
+ const contextAdditions = /* @__PURE__ */ new Map();
73
+ const entries = arr.map((entry) => {
74
+ const hasher = new Hasher();
75
+ hasher.dispatch(entry);
76
+ for (const [key, value] of hasher.#context) {
77
+ contextAdditions.set(key, value);
78
+ }
79
+ return hasher.toString();
80
+ });
81
+ this.#context = contextAdditions;
82
+ entries.sort();
83
+ return this.array(entries, false);
84
+ }
85
+ date(date) {
86
+ return this.write("date:" + date.toJSON());
87
+ }
88
+ symbol(sym) {
89
+ return this.write("symbol:" + sym.toString());
90
+ }
91
+ unknown(value, type) {
92
+ this.write(type);
93
+ if (!value) {
94
+ return;
95
+ }
96
+ this.write(":");
97
+ if (value && typeof value.entries === "function") {
98
+ return this.array(
99
+ [...value.entries()],
100
+ true
101
+ /* ordered */
102
+ );
103
+ }
104
+ }
105
+ error(err) {
106
+ return this.write("error:" + err.toString());
107
+ }
108
+ boolean(bool) {
109
+ return this.write("bool:" + bool);
110
+ }
111
+ string(string) {
112
+ this.write("string:" + string.length + ":");
113
+ this.write(string);
114
+ }
115
+ function(fn) {
116
+ this.write("fn:");
117
+ if (isNativeFunction(fn)) {
118
+ this.dispatch("[native]");
119
+ } else {
120
+ this.dispatch(fn.toString());
121
+ }
122
+ }
123
+ number(number) {
124
+ return this.write("number:" + number);
125
+ }
126
+ null() {
127
+ return this.write("Null");
128
+ }
129
+ undefined() {
130
+ return this.write("Undefined");
131
+ }
132
+ regexp(regex) {
133
+ return this.write("regex:" + regex.toString());
134
+ }
135
+ arraybuffer(arr) {
136
+ this.write("arraybuffer:");
137
+ return this.dispatch(new Uint8Array(arr));
138
+ }
139
+ url(url) {
140
+ return this.write("url:" + url.toString());
141
+ }
142
+ map(map) {
143
+ this.write("map:");
144
+ const arr = [...map];
145
+ return this.array(arr, false);
146
+ }
147
+ set(set) {
148
+ this.write("set:");
149
+ const arr = [...set];
150
+ return this.array(arr, false);
151
+ }
152
+ bigint(number) {
153
+ return this.write("bigint:" + number.toString());
154
+ }
155
+ }
156
+ for (const type of [
157
+ "uint8array",
158
+ "uint8clampedarray",
159
+ "unt8array",
160
+ "uint16array",
161
+ "unt16array",
162
+ "uint32array",
163
+ "unt32array",
164
+ "float32array",
165
+ "float64array"
166
+ ]) {
167
+ Hasher.prototype[type] = function(arr) {
168
+ this.write(type + ":");
169
+ return this.array([...arr], false);
170
+ };
171
+ }
172
+ const nativeFunc = "[native code] }";
173
+ const nativeFuncLength = nativeFunc.length;
174
+ function isNativeFunction(f) {
175
+ if (typeof f !== "function") {
176
+ return false;
177
+ }
178
+ return Function.prototype.toString.call(f).slice(-nativeFuncLength) === nativeFunc;
179
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nitropack-nightly",
3
- "version": "2.11.0-20250221-151704.a7feefae",
3
+ "version": "2.11.0-20250221-163722.f7e0e885",
4
4
  "description": "Build and Deploy Universal JavaScript Servers",
5
5
  "repository": "nitrojs/nitro",
6
6
  "license": "MIT",
@@ -108,7 +108,7 @@
108
108
  "@types/http-proxy": "^1.17.16",
109
109
  "@vercel/nft": "^0.29.2",
110
110
  "archiver": "^7.0.1",
111
- "c12": "^2.0.2",
111
+ "c12": "^2.0.4",
112
112
  "chokidar": "^4.0.3",
113
113
  "citty": "^0.1.6",
114
114
  "compatx": "^0.1.8",
@@ -142,7 +142,7 @@
142
142
  "node-fetch-native": "^1.6.6",
143
143
  "node-mock-http": "^1.0.0",
144
144
  "ofetch": "^1.4.1",
145
- "ohash": "^1.1.4",
145
+ "ohash": "^2.0.4",
146
146
  "openapi-typescript": "^7.6.1",
147
147
  "pathe": "^2.0.3",
148
148
  "perfect-debounce": "^1.0.0",
@@ -199,6 +199,7 @@
199
199
  "firebase-functions": "^4.9.0",
200
200
  "get-port-please": "^3.1.2",
201
201
  "miniflare": "^3.20250214.0",
202
+ "ohash-v1": "npm:ohash@^1.1.4",
202
203
  "prettier": "^3.5.1",
203
204
  "typescript": "^5.7.3",
204
205
  "unbuild": "^3.3.1",