diff --git a/.github/assets/banner.svg b/.github/assets/banner.svg index b21fcbf..d589b7d 100644 --- a/.github/assets/banner.svg +++ b/.github/assets/banner.svg @@ -1,5 +1,5 @@ -tiny: smaller, faster drop-ins for YAML, JSON5, JSONC and INI libraries +tiny: smaller, faster drop-ins for YAML, JSON5, JSONC and INI libraries, and linkify-it @@ -7,7 +7,7 @@ tiny Smaller, faster parsers. Same API. -18 +19 drop-in replacements 12.0× faster than yaml 2 diff --git a/.github/drop-ins.json b/.github/drop-ins.json index f9e76f7..6ab491e 100644 --- a/.github/drop-ins.json +++ b/.github/drop-ins.json @@ -282,6 +282,20 @@ "theirs": 6.977973875000316, "ours": 0.5743697890625299 } + }, + { + "package": "tinylinkify", + "library": "linkify-it 5.0.2", + "entry": "tinylinkify/linkify-it", + "gzip": { + "theirs": 4211, + "ours": 3998 + }, + "parse": { + "theirs": 5.928683062499999, + "ours": 5.55748618749999 + }, + "machine": "AMD Ryzen 7 255 w/ Radeon 780M Graphics, Node 24.21.0" } ], "root": { @@ -335,6 +349,20 @@ "theirs": 1.5631965937500354, "ours": 0.44089388281247466 } + }, + { + "package": "tinylinkify", + "library": "linkify-it 5.0.2", + "entry": "tinylinkify", + "gzip": { + "theirs": 4211, + "ours": 1836 + }, + "parse": { + "theirs": 5.666320437499962, + "ours": 2.022400906250141 + }, + "machine": "AMD Ryzen 7 255 w/ Radeon 780M Graphics, Node 24.21.0" } ] } diff --git a/.github/scripts/brand.ts b/.github/scripts/brand.ts index eb59a90..0de4462 100644 --- a/.github/scripts/brand.ts +++ b/.github/scripts/brand.ts @@ -76,7 +76,7 @@ ${b.stats `; -const { dropIns, root } = readDropIns(); +const { dropIns, root, roots = [] } = readDropIns(); const row = (library: string) => dropIns.find((r) => r.library === library)!; const count = (pkg: string) => String(dropIns.filter((r) => r.package === pkg).length); const dependencies = (pkg: string) => @@ -89,7 +89,7 @@ const banners: Banner[] = [ { file: ".github/assets/banner.svg", name: "tiny", - title: "tiny: smaller, faster drop-ins for YAML, JSON5, JSONC and INI libraries", + title: "tiny: smaller, faster drop-ins for YAML, JSON5, JSONC and INI libraries, and linkify-it", tagline: "Smaller, faster parsers. Same API.", stats: [ [String(dropIns.length), "drop-in replacements"], @@ -131,6 +131,17 @@ const banners: Banner[] = [ [dependencies("tinyini"), "dependencies"], ], }, + { + file: "packages/tinylinkify/.github/banner.svg", + name: "tinylinkify", + title: "tinylinkify: GFM links in text, and a smaller, faster drop-in for linkify-it 5", + tagline: "GFM links in text, and a faster linkify-it.", + stats: [ + [`${kib(roots.find((r) => r.entry === "tinylinkify")!.gzip.ours)} KiB`, "own API, gzipped"], + [times(roots.find((r) => r.entry === "tinylinkify")!.parse), "faster than linkify-it"], + [dependencies("tinylinkify"), "dependencies"], + ], + }, ]; const write = (file: string, content: string | Buffer) => { diff --git a/.github/scripts/drop-ins.ts b/.github/scripts/drop-ins.ts index 8836387..a1d9a98 100644 --- a/.github/scripts/drop-ins.ts +++ b/.github/scripts/drop-ins.ts @@ -3,11 +3,18 @@ // package's large benchmark file. The numbers come from each package's own // scripts/size.ts and bench/index.ts, run with --json. automd.config.ts turns // the file into the tables in the READMEs. -// Usage: node --no-warnings .github/scripts/drop-ins.ts +// Name packages to measure only theirs: the other rows stay as they are, and +// rows measured on another machine than the file's say which. +// Usage: node --no-warnings .github/scripts/drop-ins.ts [package...] import { execFileSync } from "node:child_process"; -import { writeFileSync } from "node:fs"; +import { existsSync, writeFileSync } from "node:fs"; import { cpus } from "node:os"; -import type { Comparison, DropIns } from "../../automd.config.ts"; +import { readDropIns, type Comparison, type DropIns } from "../../automd.config.ts"; + +const only = process.argv.slice(2); +const measure = (pkg: string) => !only.length || only.includes(pkg); +const previous = existsSync(".github/drop-ins.json") ? readDropIns() : undefined; +const machine = `${cpus()[0]!.model.trim()}, Node ${process.versions.node}`; // A script may log a build first, so the JSON starts at the first line that is // only "{" or "[". @@ -23,12 +30,13 @@ const run = (pkg: string, script: string) => { type Sizes = Record; type Rows = { operation: string; theirs: number; ours?: number; tinyaml?: number; library?: string }[]; -const yamlSize: Sizes = run("tinyaml", "scripts/size.ts"); -const yamlBench: Rows = run("tinyaml", "bench/index.ts"); -const json5Size: Sizes = run("tinyjson5", "scripts/size.ts"); -const json5Bench: Rows = run("tinyjson5", "bench/index.ts"); -const iniSize: Sizes = run("tinyini", "scripts/size.ts"); -const iniBench: Rows = run("tinyini", "bench/index.ts"); +// A package's sizes and timings, or nothing when it isn't being measured. +const numbers = (pkg: string): [Sizes, Rows] => + measure(pkg) ? [run(pkg, "scripts/size.ts"), run(pkg, "bench/index.ts")] : [{}, []]; +const [yamlSize, yamlBench] = numbers("tinyaml"); +const [json5Size, json5Bench] = numbers("tinyjson5"); +const [iniSize, iniBench] = numbers("tinyini"); +const [linkSize, linkBench] = numbers("tinylinkify"); const timing = (rows: Rows, operation: string, library?: string) => { const r = rows.find((r) => r.operation === operation && (!library || r.library === library)); @@ -42,22 +50,34 @@ const compare = ( [theirs, ours]: [string, string], rows: Rows, benchLibrary?: string, -): Comparison => ({ - package: pkg, - library, - entry, - gzip: { theirs: sizes[theirs]!.gzip, ours: sizes[ours]!.gzip }, - parse: timing(rows, "parse large", benchLibrary)!, - // A library that only parses, such as strip-json-comments, has no stringify row. - stringify: timing(rows, "stringify large", benchLibrary), -}); + // What "parse" is for this package's bench: linkify-it's is `match`. + parse = "parse large", +): Comparison => { + if (!measure(pkg)) { + const kept = [...(previous?.dropIns ?? []), previous?.root, ...(previous?.roots ?? [])].find( + (r) => r?.entry === entry && r.library === library, + ); + if (!kept) throw new Error(`${entry} has no row in .github/drop-ins.json; measure ${pkg}`); + return { ...kept, machine: kept.machine ?? previous!.machine }; + } + return { + package: pkg, + library, + entry, + gzip: { theirs: sizes[theirs]!.gzip, ours: sizes[ours]!.gzip }, + parse: timing(rows, parse, benchLibrary)!, + // A library that only parses, such as strip-json-comments, has no stringify row. + stringify: timing(rows, "stringify large", benchLibrary), + machine, + }; +}; const yaml = (library: string, entry: string, size: string, bench: string) => compare("tinyaml", library, entry, yamlSize, [size, entry], yamlBench, bench); const ini = (library: string, entry: string, bench = library) => compare("tinyini", library, entry, iniSize, [library, entry], iniBench, bench); const data: DropIns = { - machine: `${cpus()[0]!.model.trim()}, Node ${process.versions.node}`, + machine, dropIns: [ yaml("js-yaml 4", "tinyaml/js-yaml", "js-yaml 4", "js-yaml"), yaml("js-yaml 5", "tinyaml/js-yaml-v5", "js-yaml 5", "js-yaml 5"), @@ -84,6 +104,16 @@ const data: DropIns = { ini("ini 1.3.8", "tinyini/ini-v1"), ini("@one-ini/wasm 0.2.1", "tinyini/one-ini"), ini("@one-ini/wasm 0.1.1", "tinyini/one-ini-v0.1"), + compare( + "tinylinkify", + "linkify-it 5.0.2", + "tinylinkify/linkify-it", + linkSize, + ["linkify-it 5.0.2", "tinylinkify/linkify-it"], + linkBench, + "linkify-it 5.0.2", + "match large", + ), ], root: yaml("yaml 2", "tinyaml", "yaml", "yaml (tinyaml root)"), // The other packages' own APIs, each against the library its users switch from. @@ -98,8 +128,25 @@ const data: DropIns = { "json5 2.2.3 (tinyjson5 root)", ), ini("ini 7.0.0", "tinyini", "ini 7.0.0 (tinyini root)"), + compare( + "tinylinkify", + "linkify-it 5.0.2", + "tinylinkify", + linkSize, + ["linkify-it 5.0.2", "tinylinkify"], + linkBench, + "linkify-it 5.0.2 (tinylinkify root)", + "match large", + ), ], }; +// The file's machine is the one most rows were measured on; rows from it +// don't repeat it. +const rows = [...data.dropIns, data.root, ...data.roots!]; +const tally = new Map(); +for (const r of rows) tally.set(r.machine!, (tally.get(r.machine!) ?? 0) + 1); +data.machine = [...tally].sort((a, b) => b[1] - a[1])[0]![0]; +for (const r of rows) if (r.machine === data.machine) delete r.machine; writeFileSync(".github/drop-ins.json", `${JSON.stringify(data, null, 2)}\n`); console.log(".github/drop-ins.json"); diff --git a/README.md b/README.md index f83d668..392e2c9 100644 --- a/README.md +++ b/README.md @@ -2,36 +2,40 @@ tiny - + [![tinyaml](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=tinyaml&label=tinyaml&icon=npm)](https://www.npmjs.com/package/tinyaml) [![tinyjson5](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=tinyjson5&label=tinyjson5&icon=npm)](https://www.npmjs.com/package/tinyjson5) [![tinyini](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=tinyini&label=tinyini&icon=npm)](https://www.npmjs.com/package/tinyini) +[![tinylinkify](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=tinylinkify&label=tinylinkify&icon=npm)](https://www.npmjs.com/package/tinylinkify) [![license: MIT](https://comark-ui.onmax.me/badge.svg?label=license&value=MIT)](./LICENSE) [![Release status](https://comark-ui.onmax.me/badge.svg?source=github-actions&repository=onmax%2Ftiny&workflow=release.yaml&icon=github)](https://github.com/onmax/tiny/actions/workflows/release.yaml) -Smaller, faster, dependency-free parsers you can drop in for the libraries you already use. Change one import and keep your code. +Smaller, faster, dependency-free parsers and linkifiers you can drop in for the libraries you already use. Change one import and keep your code. [Packages](#packages) · [Switching](#switching) · [Size and speed](#size-and-speed) · [Docs](https://tiny.onmax.me) ## Packages -| Package | Reads and writes | Bundle, gzip | Replaces | -| --------------------------------- | ---------------- | -------------------------------------------: | -------------------------------------------------------------- | -| [tinyaml](./packages/tinyaml) | YAML | [7.7 KiB](./packages/tinyaml#size-and-speed) | js-yaml 4 and 5, yaml 2, yamljs, @std/yaml | -| [tinyjson5](./packages/tinyjson5) | JSON5 | [3.4 KiB](./packages/tinyjson5#size) | json5 2.2.3 | -| [tinyini](./packages/tinyini) | INI | [1.3 KiB](./packages/tinyini#size) | ini 1.3.8, 2 to 4.0 and 4.1.3 to 7, @one-ini/wasm 0.1.1 to 0.2 | +| Package | Reads and writes | Bundle, gzip | Replaces | +| ------------------------------------- | ---------------- | -------------------------------------------: | -------------------------------------------------------------- | +| [tinyaml](./packages/tinyaml) | YAML | [7.7 KiB](./packages/tinyaml#size-and-speed) | js-yaml 4 and 5, yaml 2, yamljs, @std/yaml | +| [tinyjson5](./packages/tinyjson5) | JSON5 | [3.4 KiB](./packages/tinyjson5#size) | json5 2.2.3 | +| [tinyini](./packages/tinyini) | INI | [1.3 KiB](./packages/tinyini#size) | ini 1.3.8, 2 to 4.0 and 4.1.3 to 7, @one-ini/wasm 0.1.1 to 0.2 | +| [tinylinkify](./packages/tinylinkify) | Links in text | [1.8 KiB](./packages/tinylinkify#size) | linkify-it 4 and 5 | Bundle sizes include every export of each package's root API, minified and gzipped. See [Size and speed](#size-and-speed) for the drop-in replacements. Each package is published on its own, so install only the ones you use: ```sh -pnpm add tinyaml tinyjson5 tinyini +pnpm add tinyaml tinyjson5 tinyini tinylinkify ``` +tinylinkify also has `tinylinkify/gfm`, which gives markdown-it and markdown-exit the links remark-gfm and GitHub make, `www.` links included. + ## Switching The quickest way is the codemod. Run it in your project: @@ -40,7 +44,7 @@ The quickest way is the codemod. Run it in your project: npx tinyswap ``` -It finds the libraries you use, picks the tiny subpath that matches each installed version, and asks which ones to migrate. It shows the files it will change, then rewrites the imports and requires, swaps the dependencies in package.json, and offers to run your install. It covers js-yaml, yaml, yamljs, @std/yaml, json5, strip-json-comments, jsonc-parser, comment-json, jju, ini and @one-ini/wasm. `pnpm dlx tinyswap` and `bunx tinyswap` work too, and you can pass a directory, which defaults to the current one. +It finds the libraries you use, picks the tiny subpath that matches each installed version, and asks which ones to migrate. It shows the files it will change, then rewrites the imports and requires, swaps the dependencies in package.json, and offers to run your install. It covers js-yaml, yaml, yamljs, @std/yaml, json5, strip-json-comments, jsonc-parser, comment-json, jju, ini, @one-ini/wasm and linkify-it. `pnpm dlx tinyswap` and `bunx tinyswap` work too, and you can pass a directory, which defaults to the current one. It won't write to a project outside git or with uncommitted changes unless you pass `--force`. `--yes` migrates everything it finds without asking, `--dry-run` prints the diff and writes nothing, `--only js-yaml,json5` limits it to those libraries, and `--help` lists the flags. @@ -55,6 +59,9 @@ To switch by hand, change the import. The calls, options, output and errors stay - import ini from "ini"; + import ini from "tinyini/ini"; + +- import LinkifyIt from "linkify-it"; ++ import LinkifyIt from "tinylinkify/linkify-it"; ``` Each package matches its original on that library's own tests and on tens of thousands to millions of fuzzed inputs, and lists every place it still differs. @@ -83,14 +90,15 @@ Each package matches its original on that library's own tests and on tens of tho | ini 1.3.8 | `tinyini/ini-v1` | 1.4 → 1.4 KiB | 1.6× faster | 1.7× faster | | @one-ini/wasm 0.2.1 | `tinyini/one-ini` | 36.0 → 1.7 KiB | 12.4× faster | — | | @one-ini/wasm 0.1.1 | `tinyini/one-ini-v0.1` | 32.3 → 1.7 KiB | 12.1× faster | — | +| linkify-it 5.0.2 | `tinylinkify/linkify-it` | 4.1 → 3.9 KiB | 1.1× faster | — | For new code, the root `tinyaml` API is 7.7 KiB, 1.9× smaller than js-yaml 4 and 3.9× smaller than yaml 2. It parses 18.7× faster than yaml 2 and stringifies 12.9× faster. -Size is the minified bundle, gzipped. Speed is the median time to parse and stringify each package's large benchmark file. @one-ini/wasm's size adds its .wasm file, gzipped, and its speed is parse_to_uint32array on a 100 KB .editorconfig. strip-json-comments only strips comments, so its time is the time to strip them. Measured on Apple M4, Node 26.13.0. +Size is the minified bundle, gzipped. Speed is the median time to parse and stringify each package's large benchmark file. @one-ini/wasm's size adds its .wasm file, gzipped, and its speed is parse_to_uint32array on a 100 KB .editorconfig. strip-json-comments only strips comments, so its time is the time to strip them. linkify-it only finds links, so its time is `match` on 100 KB of text. Measured on Apple M4, Node 26.13.0 (tinyaml, tinyjson5, tinyini) and AMD Ryzen 7 255 w/ Radeon 780M Graphics, Node 24.21.0 (tinylinkify). -ini is already small, so the tinyini entries that replace it save little and win on speed. Each package's README has the full results and the inputs they come from. +ini is already small, so the tinyini entries that replace it save little and win on speed. Most of linkify-it is the patterns its drop-in keeps, so `tinylinkify/linkify-it` saves 5% and wins most where markdown-it calls it on chat, 1.4× faster; `tinylinkify/gfm` is half its size and up to 3× faster, with GFM's links rather than linkify-it's. Each package's README has the full results and the inputs they come from. ## Develop diff --git a/automd.config.ts b/automd.config.ts index 0af601c..ac5ae08 100644 --- a/automd.config.ts +++ b/automd.config.ts @@ -142,7 +142,15 @@ export default { } // Another package's own API, from `roots`, against the library its users switch from. const own = data.roots?.find((r) => r.package === args.package); - if (own) + // tinylinkify's root finds GFM links, not linkify-it's, so it's the + // same work on the same text rather than the same result. + if (own?.package === "tinylinkify") + lines.push( + "", + `The root \`tinylinkify\` API, which finds GFM links, is ${kib(own.gzip.ours)} KiB against ${kib(own.gzip.theirs)} KiB for ${own.library}, ` + + `and finds them ${times(own.parse)} faster than linkify-it finds its own in the same text.`, + ); + else if (own) lines.push( "", `The root \`${own.entry}\` API is ${kib(own.gzip.ours)} KiB against ${kib(own.gzip.theirs)} KiB for ${own.library}. ` + @@ -159,6 +167,9 @@ export default { (rows.some((r) => r.library.startsWith("strip-json-comments")) ? " strip-json-comments only strips comments, so its time is the time to strip them." : "") + + (rows.some((r) => r.library.startsWith("linkify-it")) + ? " linkify-it only finds links, so its time is `match` on 100 KB of text." + : "") + ` Measured on ${machines(data, rows)}.`, ); return { contents: lines.join("\n") }; diff --git a/docs/pages/index.md b/docs/pages/index.md index 5bbf2a0..b21f48d 100644 --- a/docs/pages/index.md +++ b/docs/pages/index.md @@ -1,8 +1,8 @@ --- title: tiny -description: Smaller, faster drop-ins for js-yaml, yaml, yamljs, @std/yaml, json5 and ini. +description: Smaller, faster drop-ins for js-yaml, yaml, yamljs, @std/yaml, json5, ini and linkify-it. headline: Smaller, faster parsers. Same API. -tagline: Drop-in replacements for the YAML, JSON5 and INI libraries you already use, with no dependencies. Change one import and keep your code. +tagline: Drop-in replacements for the YAML, JSON5, INI and linkify libraries you already use, with no dependencies. Change one import and keep your code. command: npx tinyswap --- @@ -21,11 +21,16 @@ import JSON5 from "tinyjson5/json5"; import ini from "ini"; import ini from "tinyini/ini"; ``` + +```ts [tinylinkify] icon=lucide:link del={1} ins={2} +import LinkifyIt from "linkify-it"; +import LinkifyIt from "tinylinkify/linkify-it"; +``` :: ## Packages -Each format is its own package, so you install only the ones you read. +Each format is its own package, so you install only the ones you need. ::packages :: @@ -54,10 +59,11 @@ Each format is its own package, so you install only the ones you read. | ini 1.3.8 | `tinyini/ini-v1` | 1.4 → 1.4 KiB | 1.6× faster | 1.7× faster | | @one-ini/wasm 0.2.1 | `tinyini/one-ini` | 36.0 → 1.7 KiB | 12.4× faster | — | | @one-ini/wasm 0.1.1 | `tinyini/one-ini-v0.1` | 32.3 → 1.7 KiB | 12.1× faster | — | +| linkify-it 5.0.2 | `tinylinkify/linkify-it` | 4.1 → 3.9 KiB | 1.1× faster | — | For new code, the root `tinyaml` API is 7.7 KiB, 1.9× smaller than js-yaml 4 and 3.9× smaller than yaml 2. It parses 18.7× faster than yaml 2 and stringifies 12.9× faster. -Size is the minified bundle, gzipped. Speed is the median time to parse and stringify each package's large benchmark file. @one-ini/wasm's size adds its .wasm file, gzipped, and its speed is parse_to_uint32array on a 100 KB .editorconfig. strip-json-comments only strips comments, so its time is the time to strip them. Measured on Apple M4, Node 26.13.0. +Size is the minified bundle, gzipped. Speed is the median time to parse and stringify each package's large benchmark file. @one-ini/wasm's size adds its .wasm file, gzipped, and its speed is parse_to_uint32array on a 100 KB .editorconfig. strip-json-comments only strips comments, so its time is the time to strip them. linkify-it only finds links, so its time is `match` on 100 KB of text. Measured on Apple M4, Node 26.13.0 (tinyaml, tinyjson5, tinyini) and AMD Ryzen 7 255 w/ Radeon 780M Graphics, Node 24.21.0 (tinylinkify). @@ -65,18 +71,18 @@ Size is the minified bundle, gzipped. Speed is the median time to parse and stri ::accordion :::accordion-item{label="How close is each package to the library it replaces?"} -Each one runs the original library's own tests. It's also compared with the original on fuzzed inputs, 1 million for tinyjson5, 6 million calls for tinyini, and every yaml-test-suite case plus thousands of edits for tinyaml. The compatibility pages list every known difference for [tinyaml](/tinyaml/guide/switching/), [tinyjson5](/tinyjson5/compatibility/), [tinyini](/tinyini/compatibility/). +Each one runs the original library's own tests. It's also compared with the original on fuzzed inputs, 1 million for tinyjson5, 6 million calls for tinyini and tinylinkify, and every yaml-test-suite case plus thousands of edits for tinyaml. The compatibility pages list every known difference for [tinyaml](/tinyaml/guide/switching/), [tinyjson5](/tinyjson5/compatibility/), [tinyini](/tinyini/compatibility/), [tinylinkify](/tinylinkify/compatibility/). ::: :::accordion-item{label="Can I load them with require()?"} -Yes. All three are ESM only, and Node 22.12 and later load ESM with `require()`, as do bundlers. +Yes. All four are ESM only, and Node 22.12 and later load ESM with `require()`, as do bundlers. ::: :::accordion-item{label="Why are they faster?"} -Each parser reads character codes in one pass and builds JavaScript values directly, without a tokenizer or a syntax tree in between. tinyjson5's jsonc-parser, comment-json and jju subpaths keep the scanner or tokenizer those APIs expose, and run it faster. +Each parser reads character codes in one pass and builds JavaScript values directly, without a tokenizer or a syntax tree in between. tinyjson5's jsonc-parser, comment-json and jju subpaths keep the scanner or tokenizer those APIs expose, and run it faster. tinylinkify's GFM entries read character codes the same way; its linkify-it subpath keeps linkify-it's patterns, which its users can change, and skips the searches that can't match. ::: :::accordion-item{label="How are the numbers measured?"} -With scripts in the repository, which you can rerun. The commands are on [tinyaml](/tinyaml/numbers/reproduce/), [tinyjson5](/tinyjson5/develop/), [tinyini](/tinyini/develop/). +With scripts in the repository, which you can rerun. The commands are on [tinyaml](/tinyaml/numbers/reproduce/), [tinyjson5](/tinyjson5/develop/), [tinyini](/tinyini/develop/), [tinylinkify](/tinylinkify/develop/). ::: :: diff --git a/docs/pages/tinylinkify/compatibility.md b/docs/pages/tinylinkify/compatibility.md new file mode 100644 index 0000000..9d7ed4c --- /dev/null +++ b/docs/pages/tinylinkify/compatibility.md @@ -0,0 +1,45 @@ +--- +title: Compatibility with linkify-it +label: Compatibility +description: The subpath that replaces linkify-it 4 and 5, how it was checked, and every place it still differs. +--- + +`tinylinkify/linkify-it` exports linkify-it's constructor, so switching is a change to the import line. It has linkify-it's instance properties, `re` sources, schemas, options, validators and error messages; the last column is linkify-it's own test suite, run with tinylinkify in its place. + +`npx tinyswap` makes this change for you: it rewrites the imports and swaps the dependency in package.json. + +| Library | Change the import to | Size, gzip | Its own tests on tinylinkify | +| --------------------- | -------------------------- | --------------- | ---------------------------- | +| linkify-it 4.0.1, 5.x | `"tinylinkify/linkify-it"` | 4.11 → 3.90 KiB | 176 of 176 pass | + +```ts +// before +import LinkifyIt from "linkify-it"; +const LinkifyIt = require("linkify-it"); +// after +import LinkifyIt from "tinylinkify/linkify-it"; +const LinkifyIt = require("tinylinkify/linkify-it"); +``` + +It follows linkify-it 5.0.2. [`scripts/versions.ts`](https://github.com/onmax/tiny/blob/main/packages/tinylinkify/scripts/versions.ts) fuzzes linkify-it 3.0.3, 4.0.1, 5.0.0, 5.0.1 and 5.0.2, each against the next: 3.0.3 has no `matchAtStart`, 4.0.1 and 5.0.0 behave the same, 5.0.1 changed how they search, and 5.0.1 and 5.0.2 behave the same. linkify-it 6 is another API, a class with no `pretest` and fuzzy links off by default, and markdown-it 15 and markdown-exit 2 use it; this entry doesn't cover it. + +## linkify-it 5: what's different + +- Unicode punctuation. linkify-it reads it from uc.micro 2.1.0, which has Unicode 15.1; tinylinkify reads the engine's `\p{P}`. On Node 24, which has Unicode 17, 14 more code points are punctuation, so a fuzzy link ends at them where linkify-it reads them as letters: U+1B4E, U+1B4F, U+1B7F, U+10D6E, U+10ED0, U+113D4, U+113D5, U+113D7, U+113D8, U+11BE1, U+16D6D to U+16D6F and U+1E5FF. On another engine, the set is that engine's. +- `re.src_P` holds the same class as uc.micro's `P` for that Unicode version, written with the characters themselves rather than escapes, so the patterns built from it stay well under the 20,480 characters above which V8 stops optimizing a regular expression. linkify-it's fuzzy link pattern is 19,243 characters; tinylinkify's is 11,731. Every other `re` source is linkify-it's, character for character, and they work without the `u` flag as linkify-it's do. +- Start-up. tinylinkify builds that class the first time you construct a linkifier, once per process. On the machine below, importing, constructing and matching once takes 14.2 ms, against 12.4 ms for linkify-it. +- Replaced built-ins. The shortcuts below use `RegExp.prototype.exec` and `String.prototype.indexOf` as they were when tinylinkify loaded, so a program that replaces them afterwards sees them called where linkify-it would call the replacement. +- Packaging. ESM only, with a `"module.exports"` export, so `require("tinylinkify/linkify-it")` returns the constructor on Node 22.12 and later, as `require("linkify-it")` does. linkify-it's other files, such as `linkify-it/lib/re.mjs`, have no equivalent, and tinyswap leaves imports of them alone. The types are the signatures of `@types/linkify-it` 5.0.0, as its ESM types have them: with `import LinkifyIt = require("tinylinkify/linkify-it")` in CommonJS TypeScript, import `Options` and `Match` by name, since `LinkifyIt.Options` and `LinkifyIt.Match` don't resolve. +- linkify-it 4.0.1 and 5.0.0. Since 5.0.1, linkify-it searches each pattern on from where its last match ended, so in `` it finds `a@b.co` and no longer `:c@d.com` too, and since 5.0.2 an email name after `mailto:` is at most 64 characters. linkify-it 4 reads punctuation from uc.micro 1.0.6, which has Unicode 11, 56 code points fewer than 2.1.0. + +`match` gets there faster without changing what it finds. It skips the fuzzy link search when the text has no `.` followed by a TLD, which every fuzzy link has; starts the fuzzy email search at most 65 characters before the first `@` that follows a character an email name can end in, since a name is at most 64; and runs each built-in schema's pattern once where linkify-it runs it twice. Each shortcut holds only while the pattern is the one tinylinkify built, with the same source, flags and built-in methods, and for text that is a string: a pattern you replace in `re`, recompile, give methods of its own, or change in `onCompile` gets linkify-it's way. A skipped search still resets the pattern's `lastIndex`, as linkify-it's does. + +## How it's checked + +The drop-in is checked against linkify-it 5.0.2, and the GFM entries against remark-gfm, each installed next to it as a development dependency: + +- linkify-it 5.0.2's own tests, copied unchanged into [`test/suites`](https://github.com/onmax/tiny/tree/main/packages/tinylinkify/test/suites) and run with tinylinkify in its place: 172 fixture and API tests, 3 pathological inputs that must not hang, and the CommonJS `require()` test, 176 of 176, as linkify-it passes them. +- 200,000 fuzzed inputs, made by editing linkify-it's fixtures, its benchmark samples and chat with the pieces its patterns care about, through `pretest`, `test`, `match`, `matchAtStart` and `testSchemaAt` on 14 setups: each option, `---`, replaced and added TLDs, added, aliased and disabled schemas, a replaced normalizer and an `onCompile` that changes a template. Arguments of the wrong type, bad schema definitions, odd options, and patterns in `re` changed in place (recompiled, given their own `exec`, `test` or `Symbol.match`, frozen, or left with a `lastIndex`) are compared too, errors by class and message, and every `re` source after construction. The reference that must match on every input is linkify-it with uc.micro's punctuation swapped for the engine's, built one code point at a time apart from tinylinkify's code: 6,002,040 calls, 0 differences. Against linkify-it as published, the inputs that differ are those with one of the 14 code points above, about 2.3% of them, since the fuzzer adds them on purpose. +- The GFM entries against remark-gfm's autolink step on plain text: micromark with the autolink literal extension and every other construct turned off, then mdast-util-gfm-autolink-literal, so the text is one run as tinylinkify sees it. 69,935 fuzzed lines from the micromark and mdast fixtures, the benchmark samples and chat, with 45,348 links: 0 differences in offsets or URLs, for the root, for `tinylinkify/gfm`'s `match`, and for its `matchAtStart` on each `http(s)://` link, and `test` agrees with whether there's a link. +- The GFM spec 0.29's 11 autolink examples and the fixtures of micromark-extension-gfm-autolink-literal (22) and mdast-util-gfm-autolink-literal (30), whose HTML is what github.com renders, through markdown-exit with tinylinkify/gfm, link for link: it matches remark-gfm on 11, 14 and 15 of them, and GitHub on 10, 3 and 15, where linkify-it matches GitHub on 6, 0 and 1. The fixtures it doesn't match are the markdown cases listed above, mostly `[` before every line; the spec example is `ftp://`. +- Every fuzzer and suite runner exits with an error on a difference or a failed test, and when a suite runs no tests. diff --git a/docs/pages/tinylinkify/develop.md b/docs/pages/tinylinkify/develop.md new file mode 100644 index 0000000..4a1a395 --- /dev/null +++ b/docs/pages/tinylinkify/develop.md @@ -0,0 +1,27 @@ +--- +title: Run the checks yourself +label: Develop +description: The scripts that rerun the tests, the fuzzers, the size and the benchmarks. +--- + +Run these from `packages/tinylinkify` in the [repository](https://github.com/onmax/tiny). + +tinylinkify is developed with pnpm 12, Node 26 and [Vite+](https://viteplus.dev) (`vp`), which runs oxlint, oxfmt, Vitest and tsdown. [tsrs](https://github.com/oxc-project/tsrs) does the typecheck. On Node, the published package needs version 22.12 or later. + +```sh +pnpm install +pnpm ready # format, build, lint, typecheck and test +pnpm test:dist # the tests against the built dist/ +``` + +## Run the comparisons + +```sh +pnpm linkify-it-tests # linkify-it's own tests against linkify-it and tinylinkify +node scripts/fuzz.ts 20000 1 # the drop-in against linkify-it; the second number is the seed +node scripts/versions.ts 20000 # linkify-it 3.0.3 to 5.0.2, each against the next +node scripts/fuzz-gfm.ts 20000 1 # the GFM entries against remark-gfm on plain text +node scripts/gfm-fixtures.ts # markdown-exit with tinylinkify/gfm on the GFM fixtures; --all for every case +pnpm size # bundle sizes +pnpm bench # speed +``` diff --git a/docs/pages/tinylinkify/getting-started.md b/docs/pages/tinylinkify/getting-started.md new file mode 100644 index 0000000..a6f140f --- /dev/null +++ b/docs/pages/tinylinkify/getting-started.md @@ -0,0 +1,62 @@ +--- +title: Get started +description: Install tinylinkify and find GFM links in plain text with its own API, give markdown-it GFM links, or switch from linkify-it with one import. +--- + +```sh +pnpm add tinylinkify +``` + +npm holds no package under this name until the first release. Until then, clone this repository and run `pnpm install` and `pnpm build` to get the package in `dist/`. + +```ts +import { find, test } from "tinylinkify"; + +find("see www.example.com, or mail a.b@example.com. cc @alice"); +// [ +// { schema: "", index: 4, lastIndex: 19, text: "www.example.com", url: "http://www.example.com" }, +// { schema: "mailto:", index: 29, lastIndex: 44, text: "a.b@example.com", url: "mailto:a.b@example.com" }, +// ] +test("@alice see you at 10."); // false +``` + +`find(text)` returns every link in `text`, in order, and `test(text)` whether there is one. A link has the `index` it starts at and the `lastIndex` it ends at, its `text` as written, the `url` it points to, and a `schema`: `""` for a `www.` link, `http:` or `https:`, `mailto:` for an email, or `xmpp:`. + +The rules are GitHub's [autolink literals](https://github.github.com/gfm/#autolinks-extension-), as remark-gfm applies them, on text with no other markdown in it: + +- `www.` links start at the beginning or after whitespace, `(`, `*`, `_`, `[`, `]` or `~`, and `http://` and `https://` links anywhere but after a letter. A `www.` host needs a dot, and neither host may have an underscore in its last two labels. +- Trailing `?`, `!`, `.`, `,`, `:`, `*`, `_`, `~`, quotes and a character reference such as `&hl;` aren't part of the link, nor is a closing parenthesis it didn't open. `<` ends it. +- An email is letters, digits, `.`, `-`, `_` and `+`, an `@`, then a domain with a dot that ends in a letter. It can't follow a letter, digit, those characters or `/`, so `@mentions` aren't links. +- remark-gfm then searches the text between those links once more, by its own rules, which also link after any punctuation, and `mailto:` and `xmpp:` addresses with a domain the first rules turn down. tinylinkify does both. + +Characters are UTF-16 code units, as micromark reads them, so a host can be `例え.テスト` and an emoji doesn't end a path. There are no options: tinylinkify finds what remark-gfm finds. + +Already on linkify-it? It has a drop-in subpath: see [Compatibility](/tinylinkify/compatibility/). + +## GFM links in markdown-it and markdown-exit + +markdown-it and markdown-exit find links with linkify-it, whose rules aren't GFM's. linkify-it 5 links bare domains such as `example.com`, which remark-gfm doesn't, but only with a TLD on its list, so not `example.dev`; linkify-it 6, which markdown-it 15 and markdown-exit 2 use, links no bare domain by default, `www.example.com` included. `tinylinkify/gfm` is the root's rules behind the methods they call, so their `linkify` option links what GitHub does: + +```ts +import MarkdownExit from "markdown-exit"; +import { linkifyGfm } from "tinylinkify/gfm"; + +const md = MarkdownExit().use(linkifyGfm); +md.render("see www.example.com, thanks @alice"); +// '

see www.example.com, thanks @alice

\n' +``` + +The plugin turns `linkify` on and sets `md.linkify` to a `LinkifyIt` from `tinylinkify/gfm`, with the options you pass it. With markdown-exit 2's `markdown-exit/core`, which leaves linkify-it out, write `createMarkdownExit().use(linkifyGfm)`. + +It isn't a drop-in for linkify-it, since the links differ. It has `test`, `pretest`, `match` and `matchAtStart`, whose matches have linkify-it's fields, and `set`, which reads `fuzzyLink` (`www.` links) and `fuzzyEmail` (emails without `mailto:`). `tlds` and `add` take their arguments and do nothing, since GFM has no TLD list or custom schemas, and `fuzzyIP` is ignored: GFM links an IP address only after `http://` or `https://`. `pretest` is a quick check that never says no to text with a link: `www.`, `://`, or an address character before an `@`, so chat full of `@mentions` skips `match`. + +markdown-it 14 and markdown-exit 1 call `pretest` and then `match`; markdown-it 15 and markdown-exit 2 call `test` and then `match`, and import linkify-it 6's named `LinkifyIt`, which `tinylinkify/gfm` exports too. Its `test` stops at the first link, so a paragraph tested before its text costs little, and `match` keeps the links it found for a `test` of the same text; with markdown-exit 2 it renders 52 chat messages 1.2 times faster than linkify-it 6.1.0 does. + +markdown-exit with it links the same as remark-gfm on 98 of 98 chat messages, where linkify-it gets 83 (URLs compared after decoding). The parsers still differ around the linkifier, and tinylinkify/gfm can't change that from inside linkify-it's interface: + +- **After an unclosed `[`.** remark-gfm's parser reads no autolink literal after a `[` that hasn't closed yet, and its second search links them by its own rules: it keeps `*`, `_`, `~` and `<` in the link and leaves out `>`, `}` and `&`, needs a dot in the host, and links `mailto:foo@bar.com` with its prefix. markdown-exit asks the linkifier from inside its parser, where the `[` doesn't show, so `[www.commonmark.org/he section.icon), "arrow-left", "arrow-right", "search"].map( diff --git a/packages/tinyini/README.md b/packages/tinyini/README.md index e93fa01..6531254 100644 --- a/packages/tinyini/README.md +++ b/packages/tinyini/README.md @@ -4,7 +4,11 @@ - +[![release](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=tinyini&label=release&icon=npm)](https://github.com/onmax/tiny/releases) +[![size](https://comark-ui.onmax.me/badge.svg?label=size&value=1.3+KiB+gzip)](#size) +[![dependencies](https://comark-ui.onmax.me/badge.svg?label=dependencies&value=0)](https://www.npmjs.com/package/tinyini?activeTab=dependencies) +[![license: MIT](https://comark-ui.onmax.me/badge.svg?label=license&value=MIT)](./LICENSE) +[![Release status](https://comark-ui.onmax.me/badge.svg?source=github-actions&repository=onmax%2Ftiny&workflow=release.yaml&icon=github)](https://github.com/onmax/tiny/actions/workflows/release.yaml) @@ -21,7 +25,17 @@ tinyini ships drop-in replacements for ini 7 (and 4.1.3 to 6), ini 2, ini 1.3.8, - +| You use | Switch to | Size, gzip | Parses | Stringifies | +| ------------------- | ---------------------- | -------------: | -----------: | ----------: | +| ini 7.0.0 | `tinyini/ini` | 1.6 → 1.5 KiB | 1.8× faster | 2.9× faster | +| ini 2.0.0 | `tinyini/ini-v2` | 1.4 → 1.4 KiB | 1.6× faster | 1.6× faster | +| ini 1.3.8 | `tinyini/ini-v1` | 1.4 → 1.4 KiB | 1.6× faster | 1.7× faster | +| @one-ini/wasm 0.2.1 | `tinyini/one-ini` | 36.0 → 1.7 KiB | 12.4× faster | — | +| @one-ini/wasm 0.1.1 | `tinyini/one-ini-v0.1` | 32.3 → 1.7 KiB | 12.1× faster | — | + +The root `tinyini` API is 1.3 KiB against 1.6 KiB for ini 7.0.0. It parses 2.4× faster than ini 7.0.0 and stringifies 3.5× faster. + +Size is the minified bundle, gzipped. Speed is the median time to parse and stringify the large benchmark file. @one-ini/wasm's size adds its .wasm file, gzipped, and its speed is parse_to_uint32array on a 100 KB .editorconfig. Measured on Apple M4, Node 26.13.0. diff --git a/packages/tinyjson5/README.md b/packages/tinyjson5/README.md index 78776e7..6955ac3 100644 --- a/packages/tinyjson5/README.md +++ b/packages/tinyjson5/README.md @@ -4,7 +4,11 @@ - +[![release](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=tinyjson5&label=release&icon=npm)](https://github.com/onmax/tiny/releases) +[![size](https://comark-ui.onmax.me/badge.svg?label=size&value=3.4+KiB+gzip)](#size) +[![dependencies](https://comark-ui.onmax.me/badge.svg?label=dependencies&value=0)](https://www.npmjs.com/package/tinyjson5?activeTab=dependencies) +[![license: MIT](https://comark-ui.onmax.me/badge.svg?label=license&value=MIT)](./LICENSE) +[![Release status](https://comark-ui.onmax.me/badge.svg?source=github-actions&repository=onmax%2Ftiny&workflow=release.yaml&icon=github)](https://github.com/onmax/tiny/actions/workflows/release.yaml) @@ -21,7 +25,20 @@ tinyjson5 ships drop-in replacements for json5 2 and 1, strip-json-comments 3, 2 - +| You use | Switch to | Size, gzip | Parses | Stringifies | +| --------------------- | ---------------------------------- | --------------: | ----------: | ----------: | +| json5 2.2.3 | `tinyjson5/json5` | 7.5 → 3.2 KiB | 7.4× faster | 4.7× faster | +| json5 1.0.2 | `tinyjson5/json5-v1` | 8.3 → 3.3 KiB | 7.1× faster | 5.1× faster | +| strip-json-comments 3 | `tinyjson5/strip-json-comments` | 0.7 → 0.5 KiB | 3.8× faster | — | +| strip-json-comments 2 | `tinyjson5/strip-json-comments-v2` | 0.6 → 0.5 KiB | 4.2× faster | — | +| strip-json-comments 5 | `tinyjson5/strip-json-comments-v5` | 0.6 → 0.6 KiB | 3.6× faster | — | +| jsonc-parser 3.3.1 | `tinyjson5/jsonc-parser` | 6.6 → 5.7 KiB | 1.2× faster | — | +| comment-json 4.6.2 | `tinyjson5/comment-json` | 35.3 → 18.2 KiB | 1.8× faster | 1.3× faster | +| jju 1.4.0 | `tinyjson5/jju` | 9.6 → 9.5 KiB | 1.1× faster | 1.6× faster | + +The root `tinyjson5` API is 3.4 KiB against 7.5 KiB for json5 2.2.3. It parses 6.3× faster than json5 2.2.3 and stringifies 4.3× faster. + +Size is the minified bundle, gzipped. Speed is the median time to parse and stringify the large benchmark file. strip-json-comments only strips comments, so its time is the time to strip them. Measured on Apple M4, Node 26.13.0. diff --git a/packages/tinylinkify/.github/banner.svg b/packages/tinylinkify/.github/banner.svg new file mode 100644 index 0000000..e2824cf --- /dev/null +++ b/packages/tinylinkify/.github/banner.svg @@ -0,0 +1,18 @@ + +tinylinkify: GFM links in text, and a smaller, faster drop-in for linkify-it 5 + + + + + +tinylinkify +GFM links in text, and a faster linkify-it. +1.8 KiB +own API, gzipped +2.8× +faster than linkify-it +0 +dependencies + + + diff --git a/packages/tinylinkify/LICENSE b/packages/tinylinkify/LICENSE new file mode 100644 index 0000000..5f573fd --- /dev/null +++ b/packages/tinylinkify/LICENSE @@ -0,0 +1,111 @@ +MIT License + +Copyright (c) 2026 onmax + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +--- + +tinylinkify/linkify-it reproduces the behaviour, messages, regular +expressions and parts of the code of linkify-it 5.0.2. tinylinkify and +tinylinkify/gfm follow the rules and copy the regular expressions of +micromark-extension-gfm-autolink-literal 2.1.0 and +mdast-util-gfm-autolink-literal 2.1.0. Their licenses and copyright notices +follow. + +--- + +linkify-it (version 5.0.2) + +Copyright (c) 2015 Vitaly Puzrin. + +Permission is hereby granted, free of charge, to any person +obtaining a copy of this software and associated documentation +files (the "Software"), to deal in the Software without +restriction, including without limitation the rights to use, +copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS IN THE SOFTWARE. + +--- + +micromark-extension-gfm-autolink-literal (version 2.1.0) + +(The MIT License) + +Copyright (c) 2020 Titus Wormer + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +--- + +mdast-util-gfm-autolink-literal (version 2.1.0) + +(The MIT License) + +Copyright (c) Titus Wormer + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +'Software'), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/packages/tinylinkify/README.md b/packages/tinylinkify/README.md new file mode 100644 index 0000000..66c299f --- /dev/null +++ b/packages/tinylinkify/README.md @@ -0,0 +1,213 @@ +

+ tinylinkify +

+ + + +[![release](https://comark-ui.onmax.me/badge.svg?source=npm-version&package=tinylinkify&label=release&icon=npm)](https://github.com/onmax/tiny/releases) +[![size](https://comark-ui.onmax.me/badge.svg?label=size&value=1.8+KiB+gzip)](#size) +[![dependencies](https://comark-ui.onmax.me/badge.svg?label=dependencies&value=0)](https://www.npmjs.com/package/tinylinkify?activeTab=dependencies) +[![license: MIT](https://comark-ui.onmax.me/badge.svg?label=license&value=MIT)](./LICENSE) +[![Release status](https://comark-ui.onmax.me/badge.svg?source=github-actions&repository=onmax%2Ftiny&workflow=release.yaml&icon=github)](https://github.com/onmax/tiny/actions/workflows/release.yaml) + + + +**Links in plain text, in 1.8 KiB.** No dependencies, GFM's autolink rules as remark-gfm and GitHub apply them, and up to 3 times faster than linkify-it. + +Already on linkify-it? Change one import and keep your code: + +```diff +- import LinkifyIt from "linkify-it"; ++ import LinkifyIt from "tinylinkify/linkify-it"; +``` + +tinylinkify ships a drop-in replacement for linkify-it 5 (and 4), and `tinylinkify/gfm`, which gives markdown-it and markdown-exit GFM's links through linkify-it's interface. The drop-in is smaller and faster than linkify-it, passes linkify-it's own tests, and gives the same result on hundreds of thousands of fuzzed inputs, apart from the differences listed under [Switching](#switching-from-linkify-it). + + + +| You use | Switch to | Size, gzip | Parses | Stringifies | +| ---------------- | ------------------------ | ------------: | ----------: | ----------: | +| linkify-it 5.0.2 | `tinylinkify/linkify-it` | 4.1 → 3.9 KiB | 1.1× faster | — | + +The root `tinylinkify` API, which finds GFM links, is 1.8 KiB against 4.1 KiB for linkify-it 5.0.2, and finds them 2.8× faster than linkify-it finds its own in the same text. + +Size is the minified bundle, gzipped. Speed is the median time to parse and stringify the large benchmark file. linkify-it only finds links, so its time is `match` on 100 KB of text. Measured on AMD Ryzen 7 255 w/ Radeon 780M Graphics, Node 24.21.0. + + + +[Get started](#get-started) · [GFM links in markdown-it](#gfm-links-in-markdown-it-and-markdown-exit) · [Switching](#switching-from-linkify-it) · [Size](#size) · [Speed](#speed) · [How it's checked](#how-its-checked) · [npm](https://www.npmjs.com/package/tinylinkify) + +An independent project by [@onmax](https://github.com/onmax). + +## Get started + +```sh +pnpm add tinylinkify +``` + +npm holds no package under this name until the first release. Until then, clone this repository and run `pnpm install` and `pnpm build` to get the package in `dist/`. + +```ts +import { find, test } from "tinylinkify"; + +find("see www.example.com, or mail a.b@example.com. cc @alice"); +// [ +// { schema: "", index: 4, lastIndex: 19, text: "www.example.com", url: "http://www.example.com" }, +// { schema: "mailto:", index: 29, lastIndex: 44, text: "a.b@example.com", url: "mailto:a.b@example.com" }, +// ] +test("@alice see you at 10."); // false +``` + +`find(text)` returns every link in `text`, in order, and `test(text)` whether there is one. A link has the `index` it starts at and the `lastIndex` it ends at, its `text` as written, the `url` it points to, and a `schema`: `""` for a `www.` link, `http:` or `https:`, `mailto:` for an email, or `xmpp:`. + +The rules are GitHub's [autolink literals](https://github.github.com/gfm/#autolinks-extension-), as remark-gfm applies them, on text with no other markdown in it: + +- `www.` links start at the beginning or after whitespace, `(`, `*`, `_`, `[`, `]` or `~`, and `http://` and `https://` links anywhere but after a letter. A `www.` host needs a dot, and neither host may have an underscore in its last two labels. +- Trailing `?`, `!`, `.`, `,`, `:`, `*`, `_`, `~`, quotes and a character reference such as `&hl;` aren't part of the link, nor is a closing parenthesis it didn't open. `<` ends it. +- An email is letters, digits, `.`, `-`, `_` and `+`, an `@`, then a domain with a dot that ends in a letter. It can't follow a letter, digit, those characters or `/`, so `@mentions` aren't links. +- remark-gfm then searches the text between those links once more, by its own rules, which also link after any punctuation, and `mailto:` and `xmpp:` addresses with a domain the first rules turn down. tinylinkify does both. + +Characters are UTF-16 code units, as micromark reads them, so a host can be `例え.テスト` and an emoji doesn't end a path. There are no options: tinylinkify finds what remark-gfm finds. + +## GFM links in markdown-it and markdown-exit + +markdown-it and markdown-exit find links with linkify-it, whose rules aren't GFM's. linkify-it 5 links bare domains such as `example.com`, which remark-gfm doesn't, but only with a TLD on its list, so not `example.dev`; linkify-it 6, which markdown-it 15 and markdown-exit 2 use, links no bare domain by default, `www.example.com` included. `tinylinkify/gfm` is the root's rules behind the methods they call, so their `linkify` option links what GitHub does: + +```ts +import MarkdownExit from "markdown-exit"; +import { linkifyGfm } from "tinylinkify/gfm"; + +const md = MarkdownExit().use(linkifyGfm); +md.render("see www.example.com, thanks @alice"); +// '

see www.example.com, thanks @alice

\n' +``` + +The plugin turns `linkify` on and sets `md.linkify` to a `LinkifyIt` from `tinylinkify/gfm`, with the options you pass it. With markdown-exit 2's `markdown-exit/core`, which leaves linkify-it out, write `createMarkdownExit().use(linkifyGfm)`. + +It isn't a drop-in for linkify-it, since the links differ. It has `test`, `pretest`, `match` and `matchAtStart`, whose matches have linkify-it's fields, and `set`, which reads `fuzzyLink` (`www.` links) and `fuzzyEmail` (emails without `mailto:`). `tlds` and `add` take their arguments and do nothing, since GFM has no TLD list or custom schemas, and `fuzzyIP` is ignored: GFM links an IP address only after `http://` or `https://`. `pretest` is a quick check that never says no to text with a link: `www.`, `://`, or an address character before an `@`, so chat full of `@mentions` skips `match`. + +markdown-it 14 and markdown-exit 1 call `pretest` and then `match`; markdown-it 15 and markdown-exit 2 call `test` and then `match`, and import linkify-it 6's named `LinkifyIt`, which `tinylinkify/gfm` exports too. Its `test` stops at the first link, so a paragraph tested before its text costs little, and `match` keeps the links it found for a `test` of the same text; with markdown-exit 2 it renders 52 chat messages 1.2 times faster than linkify-it 6.1.0 does. + +markdown-exit with it links the same as remark-gfm on 98 of 98 chat messages, where linkify-it gets 83 (URLs compared after decoding). The parsers still differ around the linkifier, and tinylinkify/gfm can't change that from inside linkify-it's interface: + +- **After an unclosed `[`.** remark-gfm's parser reads no autolink literal after a `[` that hasn't closed yet, and its second search links them by its own rules: it keeps `*`, `_`, `~` and `<` in the link and leaves out `>`, `}` and `&`, needs a dot in the host, and links `mailto:foo@bar.com` with its prefix. markdown-exit asks the linkifier from inside its parser, where the `[` doesn't show, so `[www.commonmark.org/he +linkify-it 5: what's different + +- Unicode punctuation. linkify-it reads it from uc.micro 2.1.0, which has Unicode 15.1; tinylinkify reads the engine's `\p{P}`. On Node 24, which has Unicode 17, 14 more code points are punctuation, so a fuzzy link ends at them where linkify-it reads them as letters: U+1B4E, U+1B4F, U+1B7F, U+10D6E, U+10ED0, U+113D4, U+113D5, U+113D7, U+113D8, U+11BE1, U+16D6D to U+16D6F and U+1E5FF. On another engine, the set is that engine's. +- `re.src_P` holds the same class as uc.micro's `P` for that Unicode version, written with the characters themselves rather than escapes, so the patterns built from it stay well under the 20,480 characters above which V8 stops optimizing a regular expression. linkify-it's fuzzy link pattern is 19,243 characters; tinylinkify's is 11,731. Every other `re` source is linkify-it's, character for character, and they work without the `u` flag as linkify-it's do. +- Start-up. tinylinkify builds that class the first time you construct a linkifier, once per process. On the machine below, importing, constructing and matching once takes 14.2 ms, against 12.4 ms for linkify-it. +- Replaced built-ins. The shortcuts below use `RegExp.prototype.exec` and `String.prototype.indexOf` as they were when tinylinkify loaded, so a program that replaces them afterwards sees them called where linkify-it would call the replacement. +- Packaging. ESM only, with a `"module.exports"` export, so `require("tinylinkify/linkify-it")` returns the constructor on Node 22.12 and later, as `require("linkify-it")` does. linkify-it's other files, such as `linkify-it/lib/re.mjs`, have no equivalent, and tinyswap leaves imports of them alone. The types are the signatures of `@types/linkify-it` 5.0.0, as its ESM types have them: with `import LinkifyIt = require("tinylinkify/linkify-it")` in CommonJS TypeScript, import `Options` and `Match` by name, since `LinkifyIt.Options` and `LinkifyIt.Match` don't resolve. +- linkify-it 4.0.1 and 5.0.0. Since 5.0.1, linkify-it searches each pattern on from where its last match ended, so in `` it finds `a@b.co` and no longer `:c@d.com` too, and since 5.0.2 an email name after `mailto:` is at most 64 characters. linkify-it 4 reads punctuation from uc.micro 1.0.6, which has Unicode 11, 56 code points fewer than 2.1.0. + +`match` gets there faster without changing what it finds. It skips the fuzzy link search when the text has no `.` followed by a TLD, which every fuzzy link has; starts the fuzzy email search at most 65 characters before the first `@` that follows a character an email name can end in, since a name is at most 64; and runs each built-in schema's pattern once where linkify-it runs it twice. Each shortcut holds only while the pattern is the one tinylinkify built, with the same source, flags and built-in methods, and for text that is a string: a pattern you replace in `re`, recompile, give methods of its own, or change in `onCompile` gets linkify-it's way. A skipped search still resets the pattern's `lastIndex`, as linkify-it's does. + + + +## Size + +Each entry as npm ships it in `dist/`, bundled with esbuild, minified ESM, then gzip -9, from [`scripts/size.ts`](./scripts/size.ts). An entry counts its named exports and its default export. A KiB is 1,024 bytes. Measured on Linux with Node 24.21.0. + +| Entry | Minified | Gzip | +| ------------------------ | --------- | -------- | +| `tinylinkify` | 3.55 KiB | 1.79 KiB | +| `tinylinkify/gfm` | 4.65 KiB | 2.22 KiB | +| `tinylinkify/linkify-it` | 10.32 KiB | 3.90 KiB | +| linkify-it 5.0.2 | 11.25 KiB | 4.11 KiB | +| linkify-it 6.1.0 | 13.30 KiB | 4.40 KiB | + +Most of linkify-it is its patterns, which the drop-in keeps, so it saves what uc.micro's punctuation table weighed, less the code that builds the class and the shortcuts. The GFM entries share one search; `tinylinkify/gfm` adds the interface around it, and is half the size of linkify-it 6.1.0, which markdown-it 15 and markdown-exit 2 use. `scripts/size.ts` fails if an entry outgrows its budget or linkify-it, if one entry bundles another's code, if a package specifier such as `tinylinkify/gfm` loads the wrong entry, or if the root stops being the smallest. + +## Speed + +Median time per call over seven rounds, from [`bench/index.ts`](./bench/index.ts), on the built `dist/` (AMD Ryzen 7 255, Node 24.21.0, on a machine other jobs share). The two sides' rounds interleave, and which runs first alternates. The inputs are linkify-it's five benchmark samples, 52 chat messages full of `@mentions`, and about 100 KB of all of them; the call is the one markdown-it makes, `match` after a `pretest` that passes. The GFM entries find GFM's links, not linkify-it's, so theirs is the same work on the same text, not the same result. linkify-it 6.1.0 has no `pretest`, so its rows are `test` and then `match`, as markdown-it 15 and markdown-exit 2 call it, each on a new `tinylinkify/gfm`, since it keeps the links of the last text it matched, which a benchmark repeating one text would reuse. linkify-it 6 links no fuzzy domains by default, so on linkify-it's samples, which are mostly those, it does a fraction of the work and is 4 to 8 times faster than `tinylinkify/gfm`; on 100 KB it's 1.3 times faster. The last rows are markdown-exit rendering the chat messages with each linkifier, markdown-exit 2 on its core, where you set the linkifier. + +| Library | Operation | Library | tinylinkify | Speedup | +| ----------------------------------------------- | ----------------- | -------: | ----------: | ------: | +| linkify-it 5.0.2 → `tinylinkify/linkify-it` | match chat | 202.2 µs | 157.5 µs | 1.3x | +| | match email_fuzzy | 80.7 µs | 67.1 µs | 1.2x | +| | match link_fuzzy | 80.7 µs | 66.9 µs | 1.2x | +| | match link_normal | 86.3 µs | 71.6 µs | 1.2x | +| | match many | 70.4 µs | 61.5 µs | 1.1x | +| | match many_fast | 69.4 µs | 59.9 µs | 1.2x | +| | match large | 5.65 ms | 5.55 ms | 1.0x | +| linkify-it 5.0.2 → `tinylinkify/gfm` | match chat | 203.8 µs | 61.8 µs | 3.3x | +| | match email_fuzzy | 82.5 µs | 62.6 µs | 1.3x | +| | match link_fuzzy | 80.6 µs | 61.2 µs | 1.3x | +| | match link_normal | 86.8 µs | 29.7 µs | 2.9x | +| | match many | 69.8 µs | 64.9 µs | 1.1x | +| | match many_fast | 69.2 µs | 66.0 µs | 1.0x | +| | match large | 5.76 ms | 2.03 ms | 2.8x | +| linkify-it 5.0.2 → `tinylinkify` | match chat | 198.6 µs | 61.9 µs | 3.2x | +| | match large | 5.99 ms | 2.17 ms | 2.8x | +| linkify-it 6.1.0 → `tinylinkify/gfm` | test, match chat | 75.9 µs | 63.8 µs | 1.2x | +| | test, match large | 1.52 ms | 1.99 ms | 0.8x | +| markdown-exit 1.3.0, linkify-it 5.0.2 → drop-in | render chat | 343.1 µs | 246.8 µs | 1.4x | +| markdown-exit 1.3.0, linkify-it 5.0.2 → `/gfm` | render chat | 345.9 µs | 199.4 µs | 1.7x | +| markdown-exit 2.1.0, linkify-it 6.1.0 → `/gfm` | render chat | 230.2 µs | 197.6 µs | 1.2x | + +`node bench/index.ts` prints every row, the root's and linkify-it 6's on each sample included. + +## How it's checked + +The drop-in is checked against linkify-it 5.0.2, and the GFM entries against remark-gfm, each installed next to it as a development dependency: + +- linkify-it 5.0.2's own tests, copied unchanged into [`test/suites`](./test/suites) and run with tinylinkify in its place: 172 fixture and API tests, 3 pathological inputs that must not hang, and the CommonJS `require()` test, 176 of 176, as linkify-it passes them. +- 200,000 fuzzed inputs, made by editing linkify-it's fixtures, its benchmark samples and chat with the pieces its patterns care about, through `pretest`, `test`, `match`, `matchAtStart` and `testSchemaAt` on 14 setups: each option, `---`, replaced and added TLDs, added, aliased and disabled schemas, a replaced normalizer and an `onCompile` that changes a template. Arguments of the wrong type, bad schema definitions, odd options, and patterns in `re` changed in place (recompiled, given their own `exec`, `test` or `Symbol.match`, frozen, or left with a `lastIndex`) are compared too, errors by class and message, and every `re` source after construction. The reference that must match on every input is linkify-it with uc.micro's punctuation swapped for the engine's, built one code point at a time apart from tinylinkify's code: 6,002,040 calls, 0 differences. Against linkify-it as published, the inputs that differ are those with one of the 14 code points above, about 2.3% of them, since the fuzzer adds them on purpose. +- The GFM entries against remark-gfm's autolink step on plain text: micromark with the autolink literal extension and every other construct turned off, then mdast-util-gfm-autolink-literal, so the text is one run as tinylinkify sees it. 69,935 fuzzed lines from the micromark and mdast fixtures, the benchmark samples and chat, with 45,348 links: 0 differences in offsets or URLs, for the root, for `tinylinkify/gfm`'s `match`, and for its `matchAtStart` on each `http(s)://` link, and `test` agrees with whether there's a link. +- The GFM spec 0.29's 11 autolink examples and the fixtures of micromark-extension-gfm-autolink-literal (22) and mdast-util-gfm-autolink-literal (30), whose HTML is what github.com renders, through markdown-exit with tinylinkify/gfm, link for link: it matches remark-gfm on 11, 14 and 15 of them, and GitHub on 10, 3 and 15, where linkify-it matches GitHub on 6, 0 and 1. The fixtures it doesn't match are the markdown cases listed above, mostly `[` before every line; the spec example is `ftp://`. +- Every fuzzer and suite runner exits with an error on a difference or a failed test, and when a suite runs no tests. + +## Run the comparisons yourself + +```sh +pnpm linkify-it-tests # linkify-it's own tests against linkify-it and tinylinkify +node scripts/fuzz.ts 20000 1 # the drop-in against linkify-it; the second number is the seed +node scripts/versions.ts 20000 # linkify-it 3.0.3 to 5.0.2, each against the next +node scripts/fuzz-gfm.ts 20000 1 # the GFM entries against remark-gfm on plain text +node scripts/gfm-fixtures.ts # markdown-exit with tinylinkify/gfm on the GFM fixtures; --all for every case +pnpm size # bundle sizes +pnpm bench # speed +``` + +## Develop + +tinylinkify is developed with pnpm 12, Node 26 and [Vite+](https://viteplus.dev) (`vp`), which runs oxlint, oxfmt, Vitest and tsdown. [tsrs](https://github.com/oxc-project/tsrs) does the typecheck. On Node, the published package needs version 22.12 or later. + +```sh +pnpm install +pnpm ready # format, build, lint, typecheck and test +pnpm test:dist # the tests against the built dist/ +``` + +## License + +[MIT](./LICENSE). `tinylinkify/linkify-it` follows the behaviour and parts of the code of linkify-it, and the GFM entries copy the rules and patterns of micromark-extension-gfm-autolink-literal and mdast-util-gfm-autolink-literal, so [LICENSE](./LICENSE) also carries their notices. The tests in `test/suites/linkify-it-5.0.2` are linkify-it's, and the fixtures in `test/suites/micromark-*` and `test/suites/mdast-*` are micromark's and mdast's, under the MIT licenses in those folders. `test/suites/gfm-spec-0.29` adapts the GFM spec, under CC BY-SA 4.0. diff --git a/packages/tinylinkify/bench/index.ts b/packages/tinylinkify/bench/index.ts new file mode 100644 index 0000000..75f074c --- /dev/null +++ b/packages/tinylinkify/bench/index.ts @@ -0,0 +1,144 @@ +// Median time per call over seven rounds: tinylinkify/linkify-it, the root +// and tinylinkify/gfm against linkify-it 5.0.2, on linkify-it's own benchmark +// samples, 52 chat messages, and about 100 KB of all of them, on the call +// markdown-it makes, `match` after a `pretest` that passes; and markdown-exit +// rendering the chat messages with each linkifier, and tinylinkify/gfm against +// linkify-it 6.1.0, which markdown-it 15 and markdown-exit 2 call with `test`. The GFM entries find GFM's +// links, not linkify-it's, so theirs is the same work on the same text, not +// the same result. +// It measures the built dist/, what npm ships, building it first if it's +// stale, through scripts/dist-loader.ts; --source measures src/ instead. +// The two sides' rounds interleave, and which runs first alternates from +// round to round, so neither gains from going first. +// Usage: node bench/index.ts [--json] [--source] +import LinkifyIt from "linkify-it"; +import { LinkifyIt as LinkifyIt6 } from "linkify-it-v6"; +import MarkdownExit from "markdown-exit"; +import { createMarkdownExit } from "markdown-exit-v2/core"; +import { build } from "../scripts/dist.ts"; +import { benchSamples } from "../scripts/shared.ts"; + +const source = process.argv.includes("--source"); +if (!source) { + build(); + // Imports of src/ below resolve to dist/ from here on. + await import("../scripts/dist-loader.ts"); +} +const root = await import("../src/index.ts"); +const dropIn = (await import("../src/linkify-it/index.ts")).default; +const gfm = (await import("../src/gfm/index.ts")).default; + +const samples = benchSamples(); +let large = ""; +for (let i = 0; large.length < 100 * 1024; i++) large += `${Object.values(samples)[i % 6]}\n\n`; +const inputs: Record = { ...samples, large }; + +type Find = (text: string) => unknown; +const linkify = + (l: { pretest(t: string): boolean; match(t: string): unknown }): Find => + (text) => + l.pretest(text) && l.match(text); +// linkify-it 6 has no pretest; markdown-exit 2 calls test, then match. +const tested = + (l: { test(t: string): boolean; match(t: string): unknown }): Find => + (text) => + l.test(text) && l.match(text); +// tinylinkify/gfm keeps the links of the last text for the match after a +// test, so each call gets a new one, as each text in a document is new. +const fresh = + (call: (l: never) => Find): Find => + (text) => + call(new gfm() as never)(text); +// markdown-exit 2's core, which leaves the linkifier to you. +const render2 = (Linkify: new () => unknown): Find => { + const md = createMarkdownExit({ linkify: true }) as unknown as { + linkify: unknown; + render(s: string): string; + }; + md.linkify = new Linkify(); + return (text) => md.render(text); +}; +const render = (Linkify: new () => unknown): Find => { + const md = MarkdownExit({ linkify: true }) as unknown as { + linkify: unknown; + render(s: string): string; + }; + md.linkify = new Linkify(); + return (text) => md.render(text); +}; + +const pairs: [string, string, Record, Find, Find][] = [ + ["linkify-it 5.0.2", "match", inputs, linkify(new LinkifyIt()), linkify(new dropIn())], + ["linkify-it 5.0.2 (tinylinkify/gfm)", "match", inputs, linkify(new LinkifyIt()), fresh(linkify)], + ["linkify-it 5.0.2 (tinylinkify root)", "match", inputs, linkify(new LinkifyIt()), root.find], + ["linkify-it 6.1.0 (tinylinkify/gfm)", "match", inputs, tested(new LinkifyIt6()), fresh(tested)], + [ + "markdown-exit 1.3.0 (tinylinkify/linkify-it)", + "render", + { chat: samples.chat! }, + render(LinkifyIt as never), + render(dropIn as never), + ], + [ + "markdown-exit 1.3.0 (tinylinkify/gfm)", + "render", + { chat: samples.chat! }, + render(LinkifyIt as never), + render(gfm as never), + ], + [ + "markdown-exit 2.1.0, linkify-it 6.1.0 (tinylinkify/gfm)", + "render", + { chat: samples.chat! }, + render2(LinkifyIt6), + render2(gfm as never), + ], +]; + +function time(fn: () => unknown): number { + let iterations = 1; + for (;;) { + const start = performance.now(); + for (let i = 0; i < iterations; i++) fn(); + const elapsed = performance.now() - start; + if (elapsed > 50) return elapsed / iterations; + iterations *= 2; + } +} + +// Seven rounds of each, interleaved: round r times `theirs` first when r +// is even, `ours` first when it's odd. The medians. +function medians(theirs: () => unknown, ours: () => unknown) { + const times: { theirs: number[]; ours: number[] } = { theirs: [], ours: [] }; + for (let round = 0; round < 7; round++) + for (const side of round % 2 ? (["ours", "theirs"] as const) : (["theirs", "ours"] as const)) + times[side].push(time(side === "theirs" ? theirs : ours)); + const median = (list: number[]) => list.sort((a, b) => a - b)[3]!; + return { theirs: median(times.theirs), ours: median(times.ours) }; +} + +const format = (ms: number) => (ms < 1 ? `${(ms * 1000).toFixed(1)} µs` : `${ms.toFixed(2)} ms`); + +const rows: { library: string; operation: string; theirs: number; ours: number }[] = []; +for (const [library, op, texts, theirs, ours] of pairs) + for (const [name, text] of Object.entries(texts)) + rows.push({ + library, + operation: `${op} ${name}`, + ...medians( + () => theirs(text), + () => ours(text), + ), + }); + +if (process.argv.includes("--json")) console.log(JSON.stringify(rows, null, 2)); +else { + console.log(`tinylinkify from ${source ? "src/" : "the built dist/"}\n`); + console.log( + "| Library | Operation | Library time | tinylinkify | Speedup |\n| --- | --- | --: | --: | --: |", + ); + for (const r of rows) + console.log( + `| ${r.library} | ${r.operation} | ${format(r.theirs)} | ${format(r.ours)} | ${(r.theirs / r.ours).toFixed(1)}x |`, + ); +} diff --git a/packages/tinylinkify/bench/samples/chat.txt b/packages/tinylinkify/bench/samples/chat.txt new file mode 100644 index 0000000..84db746 --- /dev/null +++ b/packages/tinylinkify/bench/samples/chat.txt @@ -0,0 +1,52 @@ +@alice can you take a look at https://github.com/vercel/chat/pull/1 when you get a chance? +@bob @carol standup in 5, notes are in the usual doc +lgtm 🚀 merging now +the preview is up at https://chat-git-feat-comark-vercel.vercel.app/ (password is in 1password) +@dave_99 did you see the error from last night? stack trace in #incidents +docs: www.example.com/docs/getting-started, see the "Adapters" section +email me at alex.smith+chat@example.co.uk if Slack is down +thanks @erin! 🙏 +@frank I pushed a fix, can you re-run CI? https://github.com/vercel/chat/actions/runs/123456789 +does anyone know why `pnpm install` hangs on node 22? @grace mentioned it last week +re: the outage — status page is https://www.vercel-status.com and the postmortem is in Notion +@heidi @ivan @judy reminder that the retro is tomorrow at 10:00 +I think it's fine, but let's ask @mallory before shipping +https://vercel.com/docs/functions/runtimes#node.js-version (see the table) +can someone review #482? it's small, mostly renames +@oscar the link is www.google.com/search?q=markdown+(spec) btw +the bug only shows up with emoji in the thread title 😅 repro: create a thread named "🔥 hotfix" +@peggy did the deploy go out? I don't see it on prod yet +yes, deployed at 14:32 UTC, commit a1b2c3d +@trent great, closing the ticket +FYI the API returns 429 if you send more than 1 msg/sec per channel +@victor can you share the Figma? I only have the old link +here: https://www.figma.com/file/AbCdEf/Chat-SDK?node-id=12%3A34 +meeting notes → notion.so/vercel/Chat-SDK-sync-2024 (ask @walter for access) +ping @alice @bob @carol @dave @erin @frank — please fill in the survey by Friday +"https://example.com/quoted" is how it shows up in the export, with the quotes +looks like (https://example.com/a_(b)) breaks the old parser +@zoe no worries, I'll pick it up tomorrow +anyone else seeing timeouts from the Teams adapter? started around 9am +@alice: ✅ done, see https://github.com/vercel/chat/commit/0f1e2d3c4b5a69788776655443322110ffeeddcc +it's in packages/adapter-slack/src/index.ts, around line 200 +@bob the regex should be /^@(\w+)/ not /@(\w+)/g +cc @security for the token rotation, details at https://vercel.com/security. +we should move to https://comark.dev — smaller bundle and it supports GFM tables +@carol I'll be offline next week, @dave is covering +reply in thread pls 🧵 +@erin here's the doc: https://docs.google.com/document/d/1AbCdEfGhIjKlMnOpQrStUvWxYz/edit#heading=h.abc123 +haha yes 😂 +@frank which version? `chat@4.2.0` or the canary? +the canary, 4.3.0-canary.12 +ok, upgrading. thanks! +mailto:support@example.com works too if you want to forward the logs +@grace @heidi I opened https://github.com/vercel/chat/issues/77 to track it +not sure, maybe ask in #help? or email help@vercel.com +@ivan can you rotate the webhook secret? the old one leaked in a screenshot +done, new one is in the vault +@judy 👍 +the RFC is at www.rfc-editor.org/rfc/rfc3986.txt, section 2.2 for reserved chars +@mallory sounds good, let's sync after lunch +I tried http://localhost:3000/api/webhooks/slack and got a 401, is the signing secret set? +@oscar yes, it's SLACK_SIGNING_SECRET in .env.local +@peggy the slides are here: https://www.canva.com/design/DAF123/view?utm_content=DAF123&utm_campaign=designshare diff --git a/packages/tinylinkify/bench/samples/email_fuzzy.txt b/packages/tinylinkify/bench/samples/email_fuzzy.txt new file mode 100644 index 0000000..c1507ea --- /dev/null +++ b/packages/tinylinkify/bench/samples/email_fuzzy.txt @@ -0,0 +1,11 @@ +Lorem ipsum dolor sit amet, adipiscing elit. Cras imperdiet nec erat ac condimentum. Nulla vel rutrum ligula. Sed hendrerit interdum orci a posuere. Vivamus ut velit aliquet, mollis purus eget, iaculis nisl. Proin posuere malesuada ante. Proin auctor orci eros, ac molestie lorem dictum nec. Vestibulum sit amet erat est. Morbi luctus sed elit ac luctus. Proin blandit, enim vitae egestas posuere, neque elit ultricies dui, vel mattis nibh enim ac lorem. Maecenas molestie nisl sit amet velit dictum lobortis. Aliquam erat volutpat. + +Vivamus sagittis, diam in lobortis, sapien arcu mattis erat, vel aliquet sem urna et risus. Ut feugiat sapien vitae mi elementum laoreet. Suspendisse potenti. Aliquam erat nisl, aliquam pretium libero aliquet, sagittis eleifend nunc. In hac habitasse platea dictumst. Integer turpis augue, tincidunt dignissim mauris id, rhoncus dapibus purus. Maecenas et enim odio. Nullam massa metus, varius quis vehicula sed, pharetra mollis erat. In quis viverra velit. Vivamus placerat, est nec hendrerit varius, enim dui hendrerit magna, ut pulvinar nibh lorem vel lacus. Mauris a orci iaculis, hendrerit eros sed, gravida leo. In dictum mauris vel augue varius, ac ullamcorper nisl ornare. In eu posuere velit, ac fermentum arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam sed malesuada leo, at interdum elit. + +Nullam ut tincidunt nunc metus lacus, commodo eget justo ut, rutrum varius nunc. Sed non rhoncus risus. Morbi sodales gravida pulvinar. Duis malesuada, odio volutpat elementum vulputate, massa magna scelerisque ante, et accumsan tellus nunc in sem. Donec mattis arcu et velit aliquet, non sagittis justo vestibulum. Suspendisse volutpat felis lectus, nec consequat ipsum mattis id. Donec dapibus vehicula facilisis. In tincidunt mi nisi, nec faucibus tortor euismod nec. Suspendisse ante ligula, aliquet vitae libero eu, vulputate dapibus libero. Sed bibendum, sapien at posuere interdum, libero est sollicitudin magna, ac gravida tellus purus eu ipsum. Proin ut quam arcu. + +Suspendisse potenti. Donec ante velit, ornare at augue quis, tristique laoreet sem. Etiam in ipsum elit. Nullam cursus dolor sit amet nulla feugiat tristique. Phasellus ac tellus tincidunt, imperdiet purus eget, ullamcorper ipsum. Cras eu tincidunt sem. Nullam sed dapibus magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id venenatis tortor. In consectetur sollicitudin pharetra. Etiam convallis nisi nunc, et aliquam turpis viverra sit amet. Maecenas faucibus sodales tortor. Suspendisse lobortis mi eu leo viverra volutpat. Pellentesque velit ante, vehicula sodales congue ut, elementum a urna. Cras tempor, ipsum eget luctus rhoncus, arcu ligula fermentum urna, vulputate pharetra enim enim non libero. + +Proin diam quam, elementum in eleifend id, elementum et metus. Cras in justo consequat justo semper ultrices. Sed dignissim lectus a ante mollis, nec vulputate ante molestie. Proin in porta nunc. Etiam pulvinar turpis sed velit porttitor, vel adipiscing velit fringilla. Cras ac tellus vitae purus pharetra tincidunt. Sed cursus aliquet aliquet. Cras eleifend commodo malesuada. In turpis turpis, ullamcorper ut tincidunt a, ullamcorper a nunc. Etiam luctus tellus ac dapibus gravida. Ut nec lacus laoreet neque ullamcorper volutpat. + +Nunc et leo erat. Aenean mattis ultrices lorem, eget adipiscing dolor ultricies eu. In hac habitasse platea dictumst. Vivamus cursus feugiat sapien quis aliquam. Mauris quam libero, porta vel volutpat ut, blandit a purus. Vivamus vestibulum dui vel tortor molestie, sit amet feugiat sem commodo. Nulla facilisi. Sed molestie arcu eget tellus vestibulum tristique markdown-it@github.com. diff --git a/packages/tinylinkify/bench/samples/link_fuzzy.txt b/packages/tinylinkify/bench/samples/link_fuzzy.txt new file mode 100644 index 0000000..c1507ea --- /dev/null +++ b/packages/tinylinkify/bench/samples/link_fuzzy.txt @@ -0,0 +1,11 @@ +Lorem ipsum dolor sit amet, adipiscing elit. Cras imperdiet nec erat ac condimentum. Nulla vel rutrum ligula. Sed hendrerit interdum orci a posuere. Vivamus ut velit aliquet, mollis purus eget, iaculis nisl. Proin posuere malesuada ante. Proin auctor orci eros, ac molestie lorem dictum nec. Vestibulum sit amet erat est. Morbi luctus sed elit ac luctus. Proin blandit, enim vitae egestas posuere, neque elit ultricies dui, vel mattis nibh enim ac lorem. Maecenas molestie nisl sit amet velit dictum lobortis. Aliquam erat volutpat. + +Vivamus sagittis, diam in lobortis, sapien arcu mattis erat, vel aliquet sem urna et risus. Ut feugiat sapien vitae mi elementum laoreet. Suspendisse potenti. Aliquam erat nisl, aliquam pretium libero aliquet, sagittis eleifend nunc. In hac habitasse platea dictumst. Integer turpis augue, tincidunt dignissim mauris id, rhoncus dapibus purus. Maecenas et enim odio. Nullam massa metus, varius quis vehicula sed, pharetra mollis erat. In quis viverra velit. Vivamus placerat, est nec hendrerit varius, enim dui hendrerit magna, ut pulvinar nibh lorem vel lacus. Mauris a orci iaculis, hendrerit eros sed, gravida leo. In dictum mauris vel augue varius, ac ullamcorper nisl ornare. In eu posuere velit, ac fermentum arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam sed malesuada leo, at interdum elit. + +Nullam ut tincidunt nunc metus lacus, commodo eget justo ut, rutrum varius nunc. Sed non rhoncus risus. Morbi sodales gravida pulvinar. Duis malesuada, odio volutpat elementum vulputate, massa magna scelerisque ante, et accumsan tellus nunc in sem. Donec mattis arcu et velit aliquet, non sagittis justo vestibulum. Suspendisse volutpat felis lectus, nec consequat ipsum mattis id. Donec dapibus vehicula facilisis. In tincidunt mi nisi, nec faucibus tortor euismod nec. Suspendisse ante ligula, aliquet vitae libero eu, vulputate dapibus libero. Sed bibendum, sapien at posuere interdum, libero est sollicitudin magna, ac gravida tellus purus eu ipsum. Proin ut quam arcu. + +Suspendisse potenti. Donec ante velit, ornare at augue quis, tristique laoreet sem. Etiam in ipsum elit. Nullam cursus dolor sit amet nulla feugiat tristique. Phasellus ac tellus tincidunt, imperdiet purus eget, ullamcorper ipsum. Cras eu tincidunt sem. Nullam sed dapibus magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id venenatis tortor. In consectetur sollicitudin pharetra. Etiam convallis nisi nunc, et aliquam turpis viverra sit amet. Maecenas faucibus sodales tortor. Suspendisse lobortis mi eu leo viverra volutpat. Pellentesque velit ante, vehicula sodales congue ut, elementum a urna. Cras tempor, ipsum eget luctus rhoncus, arcu ligula fermentum urna, vulputate pharetra enim enim non libero. + +Proin diam quam, elementum in eleifend id, elementum et metus. Cras in justo consequat justo semper ultrices. Sed dignissim lectus a ante mollis, nec vulputate ante molestie. Proin in porta nunc. Etiam pulvinar turpis sed velit porttitor, vel adipiscing velit fringilla. Cras ac tellus vitae purus pharetra tincidunt. Sed cursus aliquet aliquet. Cras eleifend commodo malesuada. In turpis turpis, ullamcorper ut tincidunt a, ullamcorper a nunc. Etiam luctus tellus ac dapibus gravida. Ut nec lacus laoreet neque ullamcorper volutpat. + +Nunc et leo erat. Aenean mattis ultrices lorem, eget adipiscing dolor ultricies eu. In hac habitasse platea dictumst. Vivamus cursus feugiat sapien quis aliquam. Mauris quam libero, porta vel volutpat ut, blandit a purus. Vivamus vestibulum dui vel tortor molestie, sit amet feugiat sem commodo. Nulla facilisi. Sed molestie arcu eget tellus vestibulum tristique markdown-it@github.com. diff --git a/packages/tinylinkify/bench/samples/link_normal.txt b/packages/tinylinkify/bench/samples/link_normal.txt new file mode 100644 index 0000000..6c06b65 --- /dev/null +++ b/packages/tinylinkify/bench/samples/link_normal.txt @@ -0,0 +1,11 @@ +Lorem ipsum dolor sit amet, adipiscing elit. Cras imperdiet nec erat ac condimentum. Nulla vel rutrum ligula. Sed hendrerit interdum orci a posuere. Vivamus ut velit aliquet, mollis purus eget, iaculis nisl. Proin posuere malesuada ante. Proin auctor orci eros, ac molestie lorem dictum nec. Vestibulum sit amet erat est. Morbi luctus sed elit ac luctus. Proin blandit, enim vitae egestas posuere, neque elit ultricies dui, vel mattis nibh enim ac lorem. Maecenas molestie nisl sit amet velit dictum lobortis. Aliquam erat volutpat. + +Vivamus sagittis, diam in lobortis, sapien arcu mattis erat, vel aliquet sem urna et risus. Ut feugiat sapien vitae mi elementum laoreet. Suspendisse potenti. Aliquam erat nisl, aliquam pretium libero aliquet, sagittis eleifend nunc. In hac habitasse platea dictumst. Integer turpis augue, tincidunt dignissim mauris id, rhoncus dapibus purus. Maecenas et enim odio. Nullam massa metus, varius quis vehicula sed, pharetra mollis erat. In quis viverra velit. Vivamus placerat, est nec hendrerit varius, enim dui hendrerit magna, ut pulvinar nibh lorem vel lacus. Mauris a orci iaculis, hendrerit eros sed, gravida leo. In dictum mauris vel augue varius, ac ullamcorper nisl ornare. In eu posuere velit, ac fermentum arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam sed malesuada leo, at interdum elit. + +Nullam ut tincidunt nunc metus lacus, commodo eget justo ut, rutrum varius nunc. Sed non rhoncus risus. Morbi sodales gravida pulvinar. Duis malesuada, odio volutpat elementum vulputate, massa magna scelerisque ante, et accumsan tellus nunc in sem. Donec mattis arcu et velit aliquet, non sagittis justo vestibulum. Suspendisse volutpat felis lectus, nec consequat ipsum mattis id. Donec dapibus vehicula facilisis. In tincidunt mi nisi, nec faucibus tortor euismod nec. Suspendisse ante ligula, aliquet vitae libero eu, vulputate dapibus libero. Sed bibendum, sapien at posuere interdum, libero est sollicitudin magna, ac gravida tellus purus eu ipsum. Proin ut quam arcu. + +Suspendisse potenti. Donec ante velit, ornare at augue quis, tristique laoreet sem. Etiam in ipsum elit. Nullam cursus dolor sit amet nulla feugiat tristique. Phasellus ac tellus tincidunt, imperdiet purus eget, ullamcorper ipsum. Cras eu tincidunt sem. Nullam sed dapibus magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id venenatis tortor. In consectetur sollicitudin pharetra. Etiam convallis nisi nunc, et aliquam turpis viverra sit amet. Maecenas faucibus sodales tortor. Suspendisse lobortis mi eu leo viverra volutpat. Pellentesque velit ante, vehicula sodales congue ut, elementum a urna. Cras tempor, ipsum eget luctus rhoncus, arcu ligula fermentum urna, vulputate pharetra enim enim non libero. + +Proin diam quam, elementum in eleifend id, elementum et metus. Cras in justo consequat justo semper ultrices. Sed dignissim lectus a ante mollis, nec vulputate ante molestie. Proin in porta nunc. Etiam pulvinar turpis sed velit porttitor, vel adipiscing velit fringilla. Cras ac tellus vitae purus pharetra tincidunt. Sed cursus aliquet aliquet. Cras eleifend commodo malesuada. In turpis turpis, ullamcorper ut tincidunt a, ullamcorper a nunc. Etiam luctus tellus ac dapibus gravida. Ut nec lacus laoreet neque ullamcorper volutpat. + +Nunc et leo erat. Aenean mattis ultrices lorem, eget adipiscing dolor ultricies eu. In hac habitasse platea dictumst. Vivamus cursus feugiat sapien quis aliquam. Mauris quam libero, porta vel volutpat ut, blandit a purus. Vivamus vestibulum dui vel tortor molestie, sit amet feugiat sem commodo. Nulla facilisi. Sed molestie arcu eget tellus vestibulum tristique https://github.com/markdown-it diff --git a/packages/tinylinkify/bench/samples/many.txt b/packages/tinylinkify/bench/samples/many.txt new file mode 100644 index 0000000..acb88a3 --- /dev/null +++ b/packages/tinylinkify/bench/samples/many.txt @@ -0,0 +1,11 @@ +Lorem ipsum dolor sit amet, adipiscing elit. Cras imperdiet nec erat ac condimentum. Nulla vel rutrum ligula. Sed hendrerit interdum orci a posuere. Vivamus ut velit aliquet, mollis purus eget, iaculis nisl. Proin posuere malesuada ante. Proin auctor orci eros, ac molestie lorem dictum nec. Vestibulum sit amet erat est. Morbi luctus sed elit ac luctus. Proin blandit, enim vitae egestas posuere, neque elit ultricies dui, vel mattis nibh enim ac lorem. Maecenas molestie nisl sit amet velit dictum lobortis. Aliquam erat volutpat. + +Vivamus sagittis, diam in github.com/markdown-it/markdown-it lobortis, sapien arcu mattis erat, vel aliquet sem urna et risus. Ut feugiat sapien vitae mi elementum laoreet. Suspendisse potenti. Aliquam erat nisl, aliquam pretium libero aliquet, sagittis eleifend nunc. In hac habitasse platea dictumst. Integer turpis augue, tincidunt dignissim mauris id, rhoncus dapibus purus. Maecenas et enim odio. Nullam massa metus, varius quis vehicula sed, pharetra mollis erat. In quis viverra velit. Vivamus placerat, est nec hendrerit varius, enim dui hendrerit magna, ut pulvinar nibh lorem vel lacus. Mauris a orci iaculis, hendrerit eros sed, gravida leo. In dictum mauris vel augue varius, ac ullamcorper nisl ornare. In eu posuere velit, ac fermentum arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam sed malesuada leo, at interdum elit. + +Nullam ut tincidunt nunc metus lacus, http://github.com/markdown-it commodo eget justo ut, rutrum varius nunc. Sed non rhoncus risus. Morbi sodales gravida pulvinar. Duis malesuada, odio volutpat elementum vulputate, massa magna scelerisque ante, et accumsan tellus nunc in sem. Donec mattis arcu et velit aliquet, non sagittis justo vestibulum. Suspendisse volutpat felis lectus, nec consequat ipsum mattis id. Donec dapibus vehicula facilisis. In tincidunt mi nisi, nec faucibus tortor euismod nec. Suspendisse ante ligula, aliquet vitae libero eu, vulputate dapibus libero. Sed bibendum, sapien at posuere interdum, libero est sollicitudin magna, ac gravida tellus purus eu ipsum. Proin ut quam arcu. + +Suspendisse potenti. Donec ante velit, markdown-it@github.com ornare at augue quis, tristique laoreet sem. Etiam in ipsum elit. Nullam cursus dolor sit amet nulla feugiat tristique. Phasellus ac tellus tincidunt, imperdiet purus eget, ullamcorper ipsum. Cras eu tincidunt sem. Nullam sed dapibus magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id venenatis tortor. In consectetur sollicitudin pharetra. Etiam convallis nisi nunc, et aliquam turpis viverra sit amet. Maecenas faucibus sodales tortor. Suspendisse lobortis mi eu leo viverra volutpat. Pellentesque velit ante, vehicula sodales congue ut, elementum a urna. Cras tempor, ipsum eget luctus rhoncus, arcu ligula fermentum urna, vulputate pharetra enim enim non libero. + +Proin diam quam, elementum in eleifend id, elementum et metus. Cras in justo consequat justo semper ultrices. Sed dignissim lectus a ante mollis, nec vulputate ante molestie. Proin in porta nunc. Etiam pulvinar turpis sed velit porttitor, vel adipiscing velit fringilla. Cras ac tellus vitae purus pharetra tincidunt. Sed cursus aliquet aliquet. Cras eleifend commodo malesuada. In turpis turpis, ullamcorper ut tincidunt a, ullamcorper a nunc. Etiam luctus tellus ac dapibus gravida. Ut nec lacus laoreet neque ullamcorper volutpat. + +Nunc et leo erat. Aenean mattis ultrices lorem, eget adipiscing dolor ultricies eu. In hac habitasse platea dictumst. Vivamus cursus feugiat sapien quis aliquam. Mauris quam libero, porta vel volutpat ut, blandit a purus. Vivamus vestibulum dui vel tortor molestie, sit amet feugiat sem commodo. Nulla facilisi. Sed molestie arcu eget tellus vestibulum tristique. diff --git a/packages/tinylinkify/bench/samples/many_fast.txt b/packages/tinylinkify/bench/samples/many_fast.txt new file mode 100644 index 0000000..2679c75 --- /dev/null +++ b/packages/tinylinkify/bench/samples/many_fast.txt @@ -0,0 +1,13 @@ +Lorem ipsum dolor sit amet, adipiscing elit. Cras imperdiet nec erat ac condimentum. Nulla vel rutrum ligula. Sed hendrerit interdum orci a posuere. Vivamus ut velit aliquet, mollis purus eget, iaculis nisl. Proin posuere malesuada ante. Proin auctor orci eros, ac molestie lorem dictum nec. Vestibulum sit amet erat est. Morbi luctus sed elit ac luctus. Proin blandit, enim vitae egestas posuere, neque elit ultricies dui, vel mattis nibh enim ac lorem. Maecenas molestie nisl sit amet velit dictum lobortis. Aliquam erat volutpat. + +Vivamus sagittis, diam in https://github.com/markdown-it/markdown-it lobortis, sapien arcu mattis erat, vel aliquet sem urna et risus. Ut feugiat sapien vitae mi elementum laoreet. Suspendisse potenti. Aliquam erat nisl, aliquam pretium libero aliquet, sagittis eleifend nunc. In hac habitasse platea dictumst. Integer turpis augue, tincidunt dignissim mauris id, rhoncus dapibus purus. Maecenas et enim odio. Nullam massa metus, varius quis vehicula sed, pharetra mollis erat. In quis viverra velit. Vivamus placerat, est nec hendrerit varius, enim dui hendrerit magna, ut pulvinar nibh lorem vel lacus. Mauris a orci iaculis, hendrerit eros sed, gravida leo. In dictum mauris vel augue varius, ac ullamcorper nisl ornare. In eu posuere velit, ac fermentum arcu. Interdum et malesuada fames ac ante ipsum primis in faucibus. Nullam sed malesuada leo, at interdum elit. + +Nullam ut tincidunt nunc metus lacus, github.com/markdown-it commodo eget justo ut, rutrum varius nunc. Sed non rhoncus risus. Morbi sodales gravida pulvinar. Duis malesuada, odio volutpat elementum vulputate, massa magna scelerisque ante, et accumsan tellus nunc in sem. Donec mattis arcu et velit aliquet, non sagittis justo vestibulum. Suspendisse volutpat felis lectus, nec consequat ipsum mattis id. Donec dapibus vehicula facilisis. In tincidunt mi nisi, nec faucibus tortor euismod nec. Suspendisse ante ligula, aliquet vitae libero eu, vulputate dapibus libero. Sed bibendum, sapien at posuere interdum, libero est sollicitudin magna, ac gravida tellus purus eu ipsum. Proin ut quam arcu. + +Suspendisse potenti. Donec ante velit, markdown-it@github.com ornare at augue quis, tristique laoreet sem. Etiam in ipsum elit. Nullam cursus dolor sit amet nulla feugiat tristique. Phasellus ac tellus tincidunt, imperdiet purus eget, ullamcorper ipsum. Cras eu tincidunt sem. Nullam sed dapibus magna. Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id venenatis tortor. In consectetur sollicitudin pharetra. Etiam convallis nisi nunc, et aliquam turpis viverra sit amet. Maecenas faucibus sodales tortor. Suspendisse lobortis mi eu leo viverra volutpat. Pellentesque velit ante, vehicula sodales congue ut, elementum a urna. Cras tempor, ipsum eget luctus rhoncus, arcu ligula fermentum urna, vulputate pharetra enim enim non libero. + +Proin diam quam, elementum in eleifend id, elementum et metus. Cras in justo consequat justo semper ultrices. Sed dignissim lectus a ante mollis, nec vulputate ante molestie. Proin in porta nunc. Etiam pulvinar turpis sed velit porttitor, vel adipiscing velit fringilla. Cras ac tellus vitae purus pharetra tincidunt. Sed cursus aliquet aliquet. Cras eleifend commodo malesuada. In turpis turpis, ullamcorper ut tincidunt a, ullamcorper a nunc. Etiam luctus tellus ac dapibus gravida. Ut nec lacus laoreet neque ullamcorper volutpat. + +Nunc et leo erat. Aenean mattis ultrices lorem, eget adipiscing dolor ultricies eu. In hac habitasse platea dictumst. Vivamus cursus feugiat sapien quis aliquam. Mauris quam libero, porta vel volutpat ut, blandit a purus. Vivamus vestibulum dui vel tortor molestie, sit amet feugiat sem commodo. Nulla facilisi. Sed molestie arcu eget tellus vestibulum tristique. + +https://github.com/markdown-it diff --git a/packages/tinylinkify/package.json b/packages/tinylinkify/package.json new file mode 100644 index 0000000..e74d0d7 --- /dev/null +++ b/packages/tinylinkify/package.json @@ -0,0 +1,94 @@ +{ + "name": "tinylinkify", + "version": "0.1.1", + "description": "Tiny, fast link finder for plain text, with GFM autolink literals and a drop-in replacement for linkify-it", + "keywords": [ + "autolink", + "gfm", + "linkify", + "linkify-it", + "markdown-it", + "url" + ], + "homepage": "https://github.com/onmax/tiny/tree/main/packages/tinylinkify#readme", + "bugs": "https://github.com/onmax/tiny/issues", + "license": "MIT", + "author": "onmax", + "repository": { + "type": "git", + "url": "git+https://github.com/onmax/tiny.git", + "directory": "packages/tinylinkify" + }, + "files": [ + "dist" + ], + "type": "module", + "sideEffects": false, + "typesVersions": { + "*": { + "package.json": [ + "./package.json" + ], + "linkify-it": [ + "./dist/linkify-it.d.mts" + ], + "gfm": [ + "./dist/gfm.d.mts" + ], + "*": [ + "./dist/index.d.mts" + ] + } + }, + "exports": { + ".": "./dist/index.mjs", + "./linkify-it": "./dist/linkify-it.mjs", + "./gfm": "./dist/gfm.mjs", + "./package.json": "./package.json" + }, + "publishConfig": { + "access": "public", + "provenance": true + }, + "scripts": { + "build": "vp pack", + "lint": "vp lint", + "fmt": "vp fmt", + "typecheck": "tsrs --noEmit", + "test": "vp test", + "test:dist": "vp test run --config test/dist.config.ts", + "check": "vp check && pnpm typecheck", + "ready": "vp fmt && pnpm build && pnpm check && pnpm test", + "prepare": "vp config", + "linkify-it-tests": "node scripts/linkify-it-tests.ts", + "fuzz": "node scripts/fuzz.ts", + "versions": "node scripts/versions.ts", + "gfm-fixtures": "node scripts/gfm-fixtures.ts", + "fuzz:gfm": "node scripts/fuzz-gfm.ts", + "size": "node scripts/size.ts", + "bench": "node bench/index.ts" + }, + "devDependencies": { + "@types/linkify-it": "5.0.0", + "@types/node": "^26.6.6", + "esbuild": "^0.28.2", + "linkify-it": "5.0.2", + "linkify-it-v6": "npm:linkify-it@6.1.0", + "markdown-exit": "1.3.0", + "markdown-exit-v2": "npm:markdown-exit@2.1.0", + "mdast-util-from-markdown": "2.1.0", + "mdast-util-gfm-autolink-literal": "2.1.0", + "micromark-extension-gfm-autolink-literal": "2.1.0", + "publint": "^0.3.25", + "remark-gfm": "4.0.1", + "remark-parse": "11.0.0", + "tsrs": "0.20.1-ts7.1.0-beta", + "typescript": "^7.0.2", + "uc.micro": "2.1.0", + "unified": "11.0.5", + "vite-plus": "^1.4.0" + }, + "engines": { + "node": ">=22.12.0" + } +} diff --git a/packages/tinylinkify/scripts/dist-loader.ts b/packages/tinylinkify/scripts/dist-loader.ts new file mode 100644 index 0000000..4790382 --- /dev/null +++ b/packages/tinylinkify/scripts/dist-loader.ts @@ -0,0 +1,21 @@ +// Runs a script against dist/ instead of src/: an import of one of our +// entries' index.ts resolves to the file it's built to. +// Usage: node --import ./scripts/dist-loader.ts scripts/