iles
Version:
Vite & Vue powered static site generator with partial hydration
86 lines (83 loc) • 2.47 kB
JavaScript
import {
__commonJS,
__toESM
} from "../chunk-JSBRDJBE.js";
// ../../node_modules/.pnpm/hash-sum@2.0.0/node_modules/hash-sum/hash-sum.js
var require_hash_sum = __commonJS({
"../../node_modules/.pnpm/hash-sum@2.0.0/node_modules/hash-sum/hash-sum.js"(exports, module) {
"use strict";
function pad(hash2, len) {
while (hash2.length < len) {
hash2 = "0" + hash2;
}
return hash2;
}
function fold(hash2, text) {
var i;
var chr;
var len;
if (text.length === 0) {
return hash2;
}
for (i = 0, len = text.length; i < len; i++) {
chr = text.charCodeAt(i);
hash2 = (hash2 << 5) - hash2 + chr;
hash2 |= 0;
}
return hash2 < 0 ? hash2 * -2 : hash2;
}
function foldObject(hash2, o, seen) {
return Object.keys(o).sort().reduce(foldKey, hash2);
function foldKey(hash3, key) {
return foldValue(hash3, o[key], key, seen);
}
}
function foldValue(input, value, key, seen) {
var hash2 = fold(fold(fold(input, key), toString(value)), typeof value);
if (value === null) {
return fold(hash2, "null");
}
if (value === void 0) {
return fold(hash2, "undefined");
}
if (typeof value === "object" || typeof value === "function") {
if (seen.indexOf(value) !== -1) {
return fold(hash2, "[Circular]" + key);
}
seen.push(value);
var objHash = foldObject(hash2, value, seen);
if (!("valueOf" in value) || typeof value.valueOf !== "function") {
return objHash;
}
try {
return fold(objHash, String(value.valueOf()));
} catch (err) {
return fold(objHash, "[valueOf exception]" + (err.stack || err.message));
}
}
return fold(hash2, value.toString());
}
function toString(o) {
return Object.prototype.toString.call(o);
}
function sum(o) {
return pad(foldValue(0, o, "", []).toString(16), 8);
}
module.exports = sum;
}
});
// src/node/plugin/hmr.ts
var import_hash_sum = __toESM(require_hash_sum(), 1);
function hmrRuntime(id) {
const hmrId = (0, import_hash_sum.default)(`${id}default`);
return `
_sfc_main.__hmrId = "${hmrId}"
__VUE_HMR_RUNTIME__.createRecord("${hmrId}", _sfc_main)
import.meta.hot.accept(({default: __default}) => {
__VUE_HMR_RUNTIME__.reload("${hmrId}", __default)
})
`;
}
export {
hmrRuntime
};