import { expect, it, describe } from "bun:test"; function gcTrace() { Bun.gc(true); } const getByteLength = (str) => { // returns the byte length of an utf8 string var s = str.length; for (var i = str.length - 1; i >= 0; i--) { var code = str.charCodeAt(i); if (code > 0x7f && code <= 0x7ff) s++; else if (code > 0x7ff && code <= 0xffff) s += 2; if (code >= 0xdc00 && code <= 0xdfff) i--; //trail surrogate } return s; }; describe("TextDecoder", () => { it("should decode ascii text", () => { const decoder = new TextDecoder("latin1"); gcTrace(true); expect(decoder.encoding).toBe("windows-1252"); gcTrace(true); expect(decoder.decode(new Uint8Array([0x41, 0x42, 0x43]))).toBe("ABC"); gcTrace(true); const result = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]; gcTrace(true); expect(decoder.decode(Uint8Array.from(result))).toBe( String.fromCharCode(...result) ); gcTrace(true); }); it("should decode unicode text", () => { const decoder = new TextDecoder(); gcTrace(true); var text = `❤️ Red Heart`; const bytes = [ 226, 157, 164, 239, 184, 143, 32, 82, 101, 100, 32, 72, 101, 97, 114, 116, ]; const decoded = decoder.decode(Uint8Array.from(bytes)); expect(decoder.encoding).toBe("utf-8"); gcTrace(true); for (let i = 0; i < text.length; i++) { expect(decoded.charCodeAt(i)).toBe(text.charCodeAt(i)); } expect(decoded).toHaveLength(text.length); gcTrace(true); }); it("should decode unicode text with multiple consecutive emoji", () => { const decoder = new TextDecoder(); const encoder = new TextEncoder(); gcTrace(true); var text = `❤️❤️❤️❤️❤️❤️ Red Heart`; text += ` ✨ Sparkles 🔥 Fire 😀 😃 😄 😁 😆 😅 😂 🤣 🥲 ☺️ 😊 😇 🙂 🙃 😉 😌 😍 🥰 😘 😗 😙 😚 😋 😛 😝 😜 🤪 🤨 🧐 🤓 😎 🥸 🤩 🥳 😏 😒 😞 😔 😟 😕 🙁 ☹️ 😣 😖 😫 😩 🥺 😢 😭 😤 😠 😡 🤬 🤯 😳 🥵 🥶 😱 😨 😰`; gcTrace(true); expect(decoder.decode(encoder.encode(text))).toBe(text); gcTrace(true); const bytes = new Uint8Array(getByteLength(text) * 8); gcTrace(true); const amount = encoder.encodeInto(text, bytes); gcTrace(true); expect(decoder.decode(bytes.subarray(0, amount.written))).toBe(text); gcTrace(true); }); }); describe("TextEncoder", () => { it("should encode latin1 text", () => { gcTrace(true); const text = "Hello World!"; const encoder = new TextEncoder(); gcTrace(true); const encoded = encoder.encode(text); gcTrace(true); expect(encoded instanceof Uint8Array).toBe(true); expect(encoded.length).toBe(text.length); gcTrace(true); const result = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]; for (let i = 0; i < result.length; i++) { expect(encoded[i]).toBe(result[i]); } }); it("should encode long latin1 text", async () => { const text = "Hello World!".repeat(1000); const encoder = new TextEncoder(); gcTrace(true); const encoded = encoder.encode(text); gcTrace(true); expect(encoded instanceof Uint8Array).toBe(true); expect(encoded.length).toBe(text.length); gcTrace(true); const decoded = new TextDecoder().decode(encoded); expect(decoded).toBe(text); gcTrace(); await new Promise((resolve) => setTimeout(resolve, 1)); gcTrace(); expect(decoded).toBe(text); }); it("should encode latin1 rope text", () => { var text = "Hello"; text += " "; text += "World!"; gcTrace(true); const encoder = new TextEncoder(); const encoded = encoder.encode(text); gcTrace(true); const into = new Uint8Array(100); const out = encoder.encodeInto(text, into); gcTrace(true); expect(out.read).toBe(text.length); expect(out.written).toBe(encoded.length); expect(encoded instanceof Uint8Array).toBe(true); const result = [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100, 33]; for (let i = 0; i < result.length; i++) { expect(encoded[i]).toBe(result[i]); expect(encoded[i]).toBe(into[i]); } expect(encoded.length).toBe(getByteLength(text)); }); it("should encode utf-16 text", () => { var text = `❤️ Red Heart ✨ Sparkles 🔥 Fire `; var encoder = new TextEncoder(); var decoder = new TextDecoder(); gcTrace(true); expect(decoder.decode(encoder.encode(text))).toBe(text); gcTrace(true); }); // this test is from a web platform test in WebKit describe("should use a unicode replacement character for invalid surrogate pairs", () => { var bad = [ { encoding: "utf-16le", input: [0x00, 0xd8], expected: "\uFFFD", name: "lone surrogate lead", }, { encoding: "utf-16le", input: [0x00, 0xdc], expected: "\uFFFD", name: "lone surrogate trail", }, { encoding: "utf-16le", input: [0x00, 0xd8, 0x00, 0x00], expected: "\uFFFD\u0000", name: "unmatched surrogate lead", }, { encoding: "utf-16le", input: [0x00, 0xdc, 0x00, 0x00], expected: "\uFFFD\u0000", name: "unmatched surrogate trail", }, { encoding: "utf-16le", input: [0x00, 0xdc, 0x00, 0xd8], expected: "\uFFFD\uFFFD", name: "swapped surrogate pair", }, ]; bad.forEach(function (t) { it(t.encoding + " - " + t.name, () => { gcTrace(true); expect( new TextDecoder(t.encoding).decode(new Uint8Array(t.input)) ).toBe(t.expected); expect( new TextDecoder(t.encoding).decode( new Uint16Array(new Uint8Array(t.input).buffer) ) ).toBe(t.expected); gcTrace(true); }); // test(function () { // assert_throws_js(TypeError, function () { // new TextDecoder(t.encoding, { fatal: true }).decode( // new Uint8Array(t.input) // ); // }); // }, t.encoding + " - " + t.name + " (fatal flag set)"); }); }); it("should encode utf-16 rope text", () => { gcTrace(true); var textReal = `❤️ Red Heart ✨ Sparkles 🔥 Fire`; var a = textReal.split(""); var text = ""; for (let j of a) { text += j; } var encoder = new TextEncoder(); expect(new TextDecoder().decode(encoder.encode(text))).toBe(textReal); }); }); ='feat/create-astro-ui'>feat/create-astro-ui Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/examples/framework-alpine/src/pages/index.astro (unfollow)
AgeCommit message (Collapse)AuthorFilesLines
2022-05-12fix(vercel): added type definitions (#3355)Gravatar Juan Martín Seery 2-1/+18
* Added missing types * Changeset
2022-05-12[ci] release (#3334)create-astro@0.12.1astro@1.0.0-beta.28@astrojs/vue@0.1.4@astrojs/vercel@0.2.0@astrojs/svelte@0.1.3@astrojs/react@0.1.2@astrojs/netlify@0.3.4Gravatar github-actions[bot] 58-196/+171
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-05-12Serialize route generation (#3354)Gravatar Juan Martín Seery 5-59/+61
2022-05-12Corrected the default value of trailingSlash (#3353)Gravatar Rafid Muhymin Wafi 1-1/+1
2022-05-12[ci] formatGravatar matthewp 1-85/+78
2022-05-12Fixed search bar of the docs example not working (#3247)Gravatar Rafid Muhymin Wafi 1-76/+94
* fixed search bar not working * fixed search bar not working during build * fix search bar throwing error on production site
2022-05-12Add config option customPages (#3315)Gravatar Eloi-Perez 1-0/+14
* Add config option customPages Add config option customPages to be able to add custom URL pages to the sitemap.xml * add comment to document customPages option
2022-05-12fix: vite types (#3352)Gravatar Juan Martín Seery 4-5/+16
* Re-export vite types and added them to zod schema * Removed casted typed * Changeset
2022-05-12[ci] update lockfile (#3287)Gravatar Fred K. Schott 33-1038/+1096
* [ci] update lockfile * chore: fix lockfile * fix: pin turbo Co-authored-by: FredKSchott <FredKSchott@users.noreply.github.com> Co-authored-by: Nate Moore <nate@skypack.dev>
2022-05-12[ci] formatGravatar matthewp 2-2/+2
2022-05-12add error hints (#3350)Gravatar Fred K. Schott 3-0/+19
* add error hints * chore: add changeset Co-authored-by: Nate Moore <nate@skypack.dev>
2022-05-12[ci] formatGravatar matthewp 2-10/+6
2022-05-12Fix: React - Use "createRoot" instead of "hydrateRoot" for `client:only` (#3337)Gravatar Ben Holmes 4-22/+34
* feat: pass "client" directive to clientEntrypoints * refactor: remove hydration warning suppression react 17 * feat: remove hydration warning suppression react 18 * chore: changeset * fix: change metadata to options bag
2022-05-12[ci] formatGravatar matthewp 1-2/+8
2022-05-12Resolve components by module ID during compilation (#3300)Gravatar Tony Sullivan 22-41/+407
* WIP: adding test coverage * test fixes * moving the shared lib up a directory to reproduce the bug * fix: transform with the module ID instead of parsing the filepath * adding the shared lib to the workspaces list * fix: client-only assets now get the full URL from vite * why is this needed for windows? * WIP: using /@fs to handle windows filepaths * fix: remove /@fs from hoisted script imports * nit: removing unused imports * fix: strip off the path root when mapping client:only styles * had to reverse the `/@fs` handling to work on windows and unix * chore: adding comments to explain the fix * chore: adding changeset
2022-05-12[ci] collect statsGravatar FredKSchott 1-0/+1
2022-05-11Exclude `node-fetch` from vite.optimizeDeps (#3348)Gravatar Nate Moore 2-0/+6
* fix: exclude `node-fetch` from vite.optimizeDeps * chore: format
2022-05-11fix: updated blog template with existing address (#3312)Gravatar Gautier Ben Aïm 1-2/+2
2022-05-11refactor(vercel): Build Output API v3 (#3216)Gravatar Juan Martín Seery 42-231/+659
* Removed ignores * Migration to v3 * More changes * Remove legacy redirects * Fail when there is no ENABLE_VC_BUILD * Fix edge * Updated readme * Changeset * Added static mode * Updated documentation * Updated shim * Made edge work! * Updated changeset * Ensure empty dir * Fixed redirects for dynamic paths * Removed extra declaration * Splited imports * Updated readme * Fixed some urls * Deprecated shim! * [test]: Vercel NFT * Beautify * Edge bundle to node 14.19 Vercel runs 14.19.1 (I've checked it manually) * Re-added shim (#3304) * Added `node:` prefix * Use the same bundling as Deno for Edge * Remove esbuild * Fixed shim * Moved nft * Updated changeset * Added note about Edge * fix typo * Added support for Node 16 (vercel/vercel#7772)
2022-05-11Fix APIRoute type (#3344)Gravatar Matthew Phillips 3-11/+8
* Fix APIRoute type * Adds a changeset * Update usage of the two API route signatures
2022-05-11[create-astro] Finalize developer experience... with gradients 🚀 (#3313)Gravatar Ben Holmes 5-23/+123
* wip: port gradient helpers from sandbox ideas * feat: wire up rocket gradient 🚀 * feat: wire up rocket gradient on install step * refactor: update "next steps" wording * deps: add chalk (for rendering gradient) * chore: changeset * chore: clean up sstray template string