site-panzai/node_modules/nuxt/dist/app/island-hash.js
2026-11-13 13:57:04 +01:00

25 lines
604 B
JavaScript

import { hash } from "ohash";
export function filterIslandProps(props) {
if (!props) {
return {};
}
const out = {};
for (const key in props) {
if (!key.startsWith("data-v-")) {
out[key] = props[key];
}
}
return out;
}
export function serializeIslandProps(props) {
return JSON.stringify(filterIslandProps(props));
}
export function computeIslandHash(name, serializedProps, context, source) {
let parsed;
try {
parsed = JSON.parse(serializedProps);
} catch {
parsed = serializedProps;
}
return hash([name, parsed, context, source]).replace(/[-_]/g, "");
}