Astro+Directus(Visual-Editing)+Snipcart Test-Stack
This commit is contained in:
commit
1459e99cb0
10119 files changed
+1499318
No files matched your search
+2
@@ -0,0 +1,2 @@
|
||||
import t from"./xxhash.wasm";async function e(){return function(t){const{exports:{mem:e,xxh32:n,xxh64:r,init32:i,update32:o,digest32:a,init64:s,update64:u,digest64:h}}=t;let c=new Uint8Array(e.buffer);function f(t,n){if(e.buffer.byteLength<t+n){const r=Math.ceil((t+n-e.buffer.byteLength)/65536);e.grow(r),c=new Uint8Array(e.buffer)}}function g(t,e,n,r,i,o){f(t);const a=new Uint8Array(t);return c.set(a),n(0,e),a.set(c.subarray(0,t)),{update(e){let n;return c.set(a),"string"==typeof e?(f(3*e.length,t),n=w.encodeInto(e,c.subarray(t)).written):(f(e.byteLength,t),c.set(e,t),n=e.byteLength),r(0,t,n),a.set(c.subarray(0,t)),this},digest:()=>(c.set(a),o(i(0)))}}function b(t){return t>>>0}const y=2n**64n-1n;function d(t){return t&y}const w=new TextEncoder,x=0,p=0n;function l(t,e=x){return f(3*t.length,0),b(n(0,w.encodeInto(t,c).written,e))}function L(t,e=p){return f(3*t.length,0),d(r(0,w.encodeInto(t,c).written,e))}return{h32:l,h32ToString:(t,e=x)=>l(t,e).toString(16).padStart(8,"0"),h32Raw:(t,e=x)=>(f(t.byteLength,0),c.set(t),b(n(0,t.byteLength,e))),create32:(t=x)=>g(48,t,i,o,a,b),h64:L,h64ToString:(t,e=p)=>L(t,e).toString(16).padStart(16,"0"),h64Raw:(t,e=p)=>(f(t.byteLength,0),c.set(t),d(r(0,t.byteLength,e))),create64:(t=p)=>g(88,t,s,u,h,d)}}(await WebAssembly.instantiate(t))}export{e as default};
|
||||
//# sourceMappingURL=xxhash-wasm.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"xxhash-wasm.js","sources":["../src/index.workerd.js","../src/xxhash.js"],"sourcesContent":["import { xxhash } from \"./xxhash\";\n\n// In CloudFlare workerd we must use import to prevent code injection.\nimport module from \"./xxhash.wasm\";\n\nexport default async function () {\n return xxhash(await WebAssembly.instantiate(module));\n}\n","const u32_BYTES = 4;\nconst u64_BYTES = 8;\n\n// The xxh32 hash state struct:\nconst XXH32_STATE_SIZE_BYTES =\n u32_BYTES + // total_len\n u32_BYTES + // large_len\n u32_BYTES * 4 + // Accumulator lanes\n u32_BYTES * 4 + // Internal buffer\n u32_BYTES + // memsize\n u32_BYTES; // reserved\n\n// The xxh64 hash state struct:\nconst XXH64_STATE_SIZE_BYTES =\n u64_BYTES + // total_len\n u64_BYTES * 4 + // Accumulator lanes\n u64_BYTES * 4 + // Internal buffer\n u32_BYTES + // memsize\n u32_BYTES + // reserved32\n u64_BYTES; // reserved64\n\nexport function xxhash(instance) {\n const {\n exports: {\n mem,\n xxh32,\n xxh64,\n init32,\n update32,\n digest32,\n init64,\n update64,\n digest64,\n },\n } = instance;\n\n let memory = new Uint8Array(mem.buffer);\n // Grow the wasm linear memory to accommodate length + offset bytes\n function growMemory(length, offset) {\n if (mem.buffer.byteLength < length + offset) {\n const extraPages = Math.ceil(\n // Wasm pages are spec'd to 64K\n (length + offset - mem.buffer.byteLength) / (64 * 1024),\n );\n mem.grow(extraPages);\n // After growing, the original memory's ArrayBuffer is detached, so we'll\n // need to replace our view over it with a new one over the new backing\n // ArrayBuffer.\n memory = new Uint8Array(mem.buffer);\n }\n }\n\n // The h32 and h64 streaming hash APIs are identical, so we can implement\n // them both by way of a templated call to this generalized function.\n function create(size, seed, init, update, digest, finalize) {\n // Ensure that we've actually got enough space in the wasm memory to store\n // the state blob for this hasher.\n growMemory(size);\n\n // We'll hold our hashing state in this closure.\n const state = new Uint8Array(size);\n memory.set(state);\n init(0, seed);\n\n // Each time we interact with wasm, it may have mutated our state so we'll\n // need to read it back into our closed copy.\n state.set(memory.subarray(0, size));\n\n return {\n update(input) {\n memory.set(state);\n let length;\n if (typeof input === \"string\") {\n growMemory(input.length * 3, size);\n length = encoder.encodeInto(input, memory.subarray(size)).written;\n } else {\n // The only other valid input type is a Uint8Array\n growMemory(input.byteLength, size);\n memory.set(input, size);\n length = input.byteLength;\n }\n update(0, size, length);\n state.set(memory.subarray(0, size));\n return this;\n },\n digest() {\n memory.set(state);\n return finalize(digest(0));\n },\n };\n }\n\n // Logical shift right makes it an u32, otherwise it's interpreted as an i32.\n function forceUnsigned32(i) {\n return i >>> 0;\n }\n\n // BigInts are arbitrary precision and signed, so to get the \"correct\" u64\n // value from the return, we'll need to force that interpretation.\n const u64Max = 2n ** 64n - 1n;\n function forceUnsigned64(i) {\n return i & u64Max;\n }\n\n const encoder = new TextEncoder();\n const defaultSeed = 0;\n const defaultBigSeed = 0n;\n\n function h32(str, seed = defaultSeed) {\n // https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder/encodeInto#buffer_sizing\n // By sizing the buffer to 3 * string-length we guarantee that the buffer\n // will be appropriately sized for the utf-8 encoding of the string.\n growMemory(str.length * 3, 0);\n return forceUnsigned32(\n xxh32(0, encoder.encodeInto(str, memory).written, seed),\n );\n }\n\n function h64(str, seed = defaultBigSeed) {\n growMemory(str.length * 3, 0);\n return forceUnsigned64(\n xxh64(0, encoder.encodeInto(str, memory).written, seed),\n );\n }\n\n return {\n h32,\n h32ToString(str, seed = defaultSeed) {\n return h32(str, seed).toString(16).padStart(8, \"0\");\n },\n h32Raw(inputBuffer, seed = defaultSeed) {\n growMemory(inputBuffer.byteLength, 0);\n memory.set(inputBuffer);\n return forceUnsigned32(xxh32(0, inputBuffer.byteLength, seed));\n },\n create32(seed = defaultSeed) {\n return create(\n XXH32_STATE_SIZE_BYTES,\n seed,\n init32,\n update32,\n digest32,\n forceUnsigned32,\n );\n },\n h64,\n h64ToString(str, seed = defaultBigSeed) {\n return h64(str, seed).toString(16).padStart(16, \"0\");\n },\n h64Raw(inputBuffer, seed = defaultBigSeed) {\n growMemory(inputBLine truncated
|
||||
BIN
Binary file not shown.
Reference in new issue
Block a user