nuxt-og-image 6.7.1 → 6.7.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.
Files changed (35) hide show
  1. package/dist/chunks/tw4.cjs +7 -7
  2. package/dist/chunks/tw4.mjs +7 -7
  3. package/dist/chunks/uno.cjs +6 -6
  4. package/dist/chunks/uno.mjs +6 -6
  5. package/dist/cli.cjs +5 -12
  6. package/dist/cli.mjs +3 -10
  7. package/dist/devtools/lib/og-image/shared/urlEncoding.ts +5 -4
  8. package/dist/module.cjs +5 -5
  9. package/dist/module.json +1 -1
  10. package/dist/module.mjs +5 -5
  11. package/dist/runtime/app/plugins/__zero-runtime/og-image-canonical-urls.server.js +4 -6
  12. package/dist/runtime/app/plugins/__zero-runtime/route-rule-og-image.server.js +4 -6
  13. package/dist/runtime/app/plugins/og-image-canonical-urls.server.d.ts +1 -2
  14. package/dist/runtime/app/plugins/og-image-canonical-urls.server.js +1 -7
  15. package/dist/runtime/app/plugins/route-rule-og-image.server.d.ts +1 -2
  16. package/dist/runtime/app/plugins/route-rule-og-image.server.js +1 -7
  17. package/dist/runtime/app/utils/plugins.d.ts +2 -3
  18. package/dist/runtime/app/utils/plugins.js +5 -5
  19. package/dist/runtime/server/og-image/context.js +3 -3
  20. package/dist/runtime/server/og-image/takumi/nodes.d.ts +2 -1
  21. package/dist/runtime/server/og-image/takumi/nodes.js +16 -7
  22. package/dist/runtime/server/util/cache.js +2 -2
  23. package/dist/runtime/server/util/kit.js +2 -2
  24. package/dist/runtime/shared/hash.d.ts +10 -0
  25. package/dist/runtime/shared/hash.js +5 -0
  26. package/dist/runtime/shared/urlEncoding.d.ts +3 -2
  27. package/dist/runtime/shared/urlEncoding.js +9 -9
  28. package/dist/shared/{nuxt-og-image.BCK8Adm4.cjs → nuxt-og-image.BRBtdkUp.cjs} +570 -81
  29. package/dist/shared/{nuxt-og-image.Pfj5JkJd.mjs → nuxt-og-image.Bv8VSGTj.mjs} +499 -10
  30. package/dist/shared/nuxt-og-image.CJa2KCie.mjs +189 -0
  31. package/dist/shared/nuxt-og-image.CMYbz66P.cjs +193 -0
  32. package/package.json +43 -41
  33. package/types/virtual.d.ts +9 -0
  34. package/dist/shared/nuxt-og-image.DQkJQHaN.cjs +0 -689
  35. package/dist/shared/nuxt-og-image.LgUGeaz-.mjs +0 -660
@@ -1,4 +1,4 @@
1
- import { hash } from "ohash";
1
+ import { digest } from "ohash/crypto";
2
2
  const MAX_PATH_LENGTH = 200;
3
3
  const RE_BASE64_PADDING = /=/g;
4
4
  const RE_BASE64_PLUS = /\+/g;
@@ -85,13 +85,13 @@ function b64Decode(str) {
85
85
  return Buffer.from(padded, "base64").toString("utf8");
86
86
  }
87
87
  function simpleHash(str) {
88
- let hash2 = 0;
88
+ let hash = 0;
89
89
  for (let i = 0; i < str.length; i++) {
90
90
  const char = str.charCodeAt(i);
91
- hash2 = (hash2 << 5) - hash2 + char;
92
- hash2 = hash2 & hash2;
91
+ hash = (hash << 5) - hash + char;
92
+ hash = hash & hash;
93
93
  }
94
- return Math.abs(hash2).toString(36);
94
+ return Math.abs(hash).toString(36);
95
95
  }
96
96
  export function hashOgImageOptions(options, componentHash, version) {
97
97
  const { _path, _hash, ...hashableOptions } = options;
@@ -233,10 +233,10 @@ export function buildOgImageUrl(options, extension = "png", isStatic = false, de
233
233
  const encoded = encodeOgImageParams(options, defaults);
234
234
  const prefix = isStatic ? "/_og/s" : "/_og/d";
235
235
  if (isStatic && (encoded.length > MAX_PATH_LENGTH || encoded.includes("%"))) {
236
- const hash2 = hashOgImageOptions(options);
236
+ const hash = hashOgImageOptions(options);
237
237
  return {
238
- url: `${prefix}/o_${hash2}.${extension}`,
239
- hash: hash2
238
+ url: `${prefix}/o_${hash}.${extension}`,
239
+ hash
240
240
  };
241
241
  }
242
242
  const segment = encoded || "default";
@@ -246,7 +246,7 @@ export function buildOgImageUrl(options, extension = "png", isStatic = false, de
246
246
  };
247
247
  }
248
248
  export function signEncodedParams(encoded, secret) {
249
- return hash(`${secret}:${encoded}`).slice(0, 16);
249
+ return digest(`${secret}:${encoded}`).slice(0, 16);
250
250
  }
251
251
  export function verifyOgImageSignature(encoded, signature, secret) {
252
252
  const expected = signEncodedParams(encoded, secret);