Remove shortid from HTML demo to reduce dependencies
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Andrey Sitnik · committed by Andrey Sitnik · parent 4bf7b85 · Browse files · 6 files·+55 added−236 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+55 added−236 removed
- tests:+55 added−7 removed
- other:+0 added−229 removed
Provenance
- Commit
3574115- Tree
64bb535- Author
Andrey Sitnik <andrey@sitnik.es>- Committer
Andrey Sitnik <andrey@sitnik.es>- Parent
4bf7b85
6 files changed+55 added−236 removed
added:test/demo/dist/assets/index-CqL4y9Wm.js+8 added
1+var e=Object.defineProperty,t=(t,n)=>{let r={};for(var i in t)e(r,i,{get:t[i],enumerable:!0});return n||e(r,Symbol.toStringTag,{value:`Module`}),r};(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=[];for(let e=0;e<256;++e)n.push((e+256).toString(16).slice(1));function r(e,t=0){return(n[e[t+0]]+n[e[t+1]]+n[e[t+2]]+n[e[t+3]]+`-`+n[e[t+4]]+n[e[t+5]]+`-`+n[e[t+6]]+n[e[t+7]]+`-`+n[e[t+8]]+n[e[t+9]]+`-`+n[e[t+10]]+n[e[t+11]]+n[e[t+12]]+n[e[t+13]]+n[e[t+14]]+n[e[t+15]]).toLowerCase()}var i,a=new Uint8Array(16);function o(){if(!i){if(typeof crypto>`u`||!crypto.getRandomValues)throw Error(`crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported`);i=crypto.getRandomValues.bind(crypto)}return i(a)}var s={randomUUID:typeof crypto<`u`&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function c(e,t,n){e||={};let i=e.random??e.rng?.()??o();if(i.length<16)throw Error(`Random bytes length must be >= 16`);if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,t){if(n||=0,n<0||n+16>t.length)throw RangeError(`UUID byte range ${n}:${n+15} is out of buffer bounds`);for(let e=0;e<16;++e)t[n+e]=i[e];return t}return r(i)}function l(e,t,n){return s.randomUUID&&!t&&!e?s.randomUUID():c(e,t,n)}var u=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,d=t({customAlphabet:()=>m,customRandom:()=>p,nanoid:()=>h,random:()=>f,urlAlphabet:()=>u}),f=e=>crypto.getRandomValues(new Uint8Array(e)),p=(e,t,n)=>{let r=(2<<Math.log2(e.length-1))-1,i=-~(1.6*r*t/e.length);return(a=t)=>{let o=``;for(;;){let t=n(i),s=i|0;for(;s--;)if(o+=e[t[s]&r]||``,o.length>=a)return o}}},m=(e,t=21)=>p(e,t|0,f),h=(e=21)=>{let t=``,n=crypto.getRandomValues(new Uint8Array(e|=0));for(;e--;)t+=u[n[e]&63];return t},g=`useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict`,_=(e=21)=>{let t=``,n=e|0;for(;n--;)t+=g[Math.random()*64|0];return t},{customAlphabet:v,nanoid:y,random:b}=d,x=_,S=50*1e3,C=`abcdefghijklmnopqrstuvwxyz`,w=26,T=v(C,w);function E(e){return String(Math.floor(e*100)).replace(/\d{6}$/,`,$&`).replace(/\d{3}$/,`,$&`)}function D(e,t){let n=O(e,t),r=Object.keys(n.chars),i=r.length,a=``,o=r.reduce((e,t)=>e+n.chars[t],0)/i;for(let e of r.sort()){let t=n.chars[e]/o;a+=`<div class="dot" style="2+ background: hsl(${200*t}, 100%, 50%);3+ width: ${100/i}%;4+ ">${e}</div>`}document.body.innerHTML+=`<section>5+ <span>${E(S*1e3/n.time)} ops/sec</span>6+ <h2>${n.title}</h2>7+ ${a}8+ </section>`}function O(e,t){let n={},r=[],i,a=Date.now();for(i=0;i<S;i++)r.push(t());let o=Date.now();for(i=0;i<S;i++){let t=r[i];e===`uuid/v4`&&(t=t.replace(/-./g,``));for(let e of t)n[e]||(n[e]=0),n[e]+=1}return{chars:n,time:o-a,title:e}}var k=[()=>D(`ideal`,()=>{let e=[];for(let t=0;t<w;t++)e.push(C[t]);return e}),()=>D(`nanoid`,()=>y()),()=>D(`nanoid2`,()=>T()),()=>D(`uuid/v4`,()=>l()),()=>D(`nanoid/non-secure`,()=>x()),()=>D(`random % alphabet`,()=>[...b(w)].map(e=>C[e%26]))];function A(){k.length!==0&&(k.shift()(),setTimeout(A,10))}var j=``;for(let e=0;e<10;e++)j+=`<div>${y()}</div>`;document.body.innerHTML=`<main>${j}</main>`,A();added:test/demo/dist/index.html+47 added
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647<!doctype html><html> <head> <meta charset="UTF-8" /> <title>Nano ID</title> <style> body { font-family: monospace; text-align: center; margin: 3rem 2rem; } main { font-size: 120%; line-height: 1.5; padding-bottom: 3rem; } section { width: 620px; margin: 0 auto; } section + section { padding-top: 1rem; } span { float: right; font-size: 90%; } h2 { font-size: 90%; font-weight: bold; text-align: left; margin: 0; padding-bottom: 0.5rem; } .dot { height: 1.5rem; line-height: 1.5rem; color: rgba(0, 0, 0, 0.5); display: inline-block; font-size: 70%; } </style> <script type="module" crossorigin src="/assets/index-CqL4y9Wm.js"></script> </head> <body> </body></html>modified:test/demo/index.js-2 removed
1123469 unmodified lines74757677797879808117 unmodified linesimport shortid from 'shortid'import { v4 as uuid4 } from 'uuid'
import * as nanoidExport from '../../index.browser.js'import * as nonSecureExport from '../../non-secure/index.js'69 unmodified lines }), () => printDistr('nanoid', () => nanoid()), () => printDistr('nanoid2', () => nanoid2()), () => printDistr('uuid/v4', () => uuid4()), () => printDistr('shortid', () => shortid()), () => printDistr('nanoid/non-secure', () => nonSecure()), () => printDistr('random % alphabet', () => { return [...random(LENGTH)].map(i => ALPHABET[i % ALPHABET.length])17 unmodified linesdeleted:test/demo/vite.config.js-5 removed
12345import { viteCommonjs } from '@originjs/vite-plugin-commonjs'
export default { plugins: [viteCommonjs()]}modified:package.json-1 removed
53 unmodified lines54 "@babel/core": "^7.29.0",55 "@logux/oxc-configs": "^0.2.2",56 "@lukeed/uuid": "^2.0.1",57 "@napi-rs/uuid": "^0.2.2",58- "@originjs/vite-plugin-commonjs": "^1.0.3",58 "@size-limit/file": "^12.0.1",59 "@size-limit/webpack": "^12.0.1",60 "@types/node": "^25.5.2",61 "actions-up": "^1.12.1",66 unmodified linesmodified:pnpm-lock.yaml-228 removed
18 unmodified lines19 version: 2.0.120 '@napi-rs/uuid':21 specifier: ^0.2.222 version: 0.2.223- '@originjs/vite-plugin-commonjs':24- specifier: ^1.0.325- version: 1.0.323 '@size-limit/file':24 specifier: ^12.0.125 version: 12.0.1(size-limit@12.0.1(jiti@2.5.1))26 '@size-limit/webpack':131 unmodified lines158 159 '@emnapi/wasi-threads@1.2.1':160 resolution: {integrity: sha512-uTII7OYF+/Mes/MrcIOYp5yOtSMLBWSIoLPpcgwipoiKbli6k322tcoFsxoIIxPDqW01SQGAgko4EzZi2BNv2w==}161 165- '@esbuild/linux-loong64@0.14.54':166- resolution: {integrity: sha512-bZBrLAIX1kpWelV0XemxBZllyRmM6vgFQQG2GdNb+r3Fkp0FOh1NJSvekXDs7jq70k4euu1cryLMfU+mTXlEpw==}167- engines: {node: '>=12'}168- cpu: [loong64]169- os: [linux]170-162 '@jridgewell/gen-mapping@0.3.13':163 resolution: {integrity: sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==}164 165 '@jridgewell/remapping@2.3.5':119 unmodified lines285 peerDependencies:286 '@emnapi/core': ^1.7.1287 '@emnapi/runtime': ^1.7.1288 298- '@originjs/vite-plugin-commonjs@1.0.3':299- resolution: {integrity: sha512-KuEXeGPptM2lyxdIEJ4R11+5ztipHoE7hy8ClZt3PYaOVQ/pyngd2alaSrPnwyFeOW1UagRBaQ752aA1dTMdOQ==}300-289 '@oxc-project/types@0.122.0':290 resolution: {integrity: sha512-oLAl5kBpV4w69UtFZ9xqcmTi+GENWOcPF7FCrczTiBbmC0ibXxCwyvZGbO39rCVEuLGAZM84DH0pUIyyv/YJzA==}291 292 '@oxlint-tsgolint/darwin-arm64@0.20.0':437 unmodified lines730 731 es-module-lexer@2.0.0:732 resolution: {integrity: sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==}733 746- esbuild-android-64@0.14.54:747- resolution: {integrity: sha512-Tz2++Aqqz0rJ7kYBfz+iqyE3QMycD4vk7LBRyWaAVFgFtQ/O8EJOnVmTOiDWYZ/uYzB4kvP+bqejYdVKzE5lAQ==}748- engines: {node: '>=12'}749- cpu: [x64]750- os: [android]751-752- esbuild-android-arm64@0.14.54:753- resolution: {integrity: sha512-F9E+/QDi9sSkLaClO8SOV6etqPd+5DgJje1F9lOWoNncDdOBL2YF59IhsWATSt0TLZbYCf3pNlTHvVV5VfHdvg==}754- engines: {node: '>=12'}755- cpu: [arm64]756- os: [android]757-758- esbuild-darwin-64@0.14.54:759- resolution: {integrity: sha512-jtdKWV3nBviOd5v4hOpkVmpxsBy90CGzebpbO9beiqUYVMBtSc0AL9zGftFuBon7PNDcdvNCEuQqw2x0wP9yug==}760- engines: {node: '>=12'}761- cpu: [x64]762- os: [darwin]763-764- esbuild-darwin-arm64@0.14.54:765- resolution: {integrity: sha512-OPafJHD2oUPyvJMrsCvDGkRrVCar5aVyHfWGQzY1dWnzErjrDuSETxwA2HSsyg2jORLY8yBfzc1MIpUkXlctmw==}766- engines: {node: '>=12'}767- cpu: [arm64]768- os: [darwin]769-770- esbuild-freebsd-64@0.14.54:771- resolution: {integrity: sha512-OKwd4gmwHqOTp4mOGZKe/XUlbDJ4Q9TjX0hMPIDBUWWu/kwhBAudJdBoxnjNf9ocIB6GN6CPowYpR/hRCbSYAg==}772- engines: {node: '>=12'}773- cpu: [x64]774- os: [freebsd]775-776- esbuild-freebsd-arm64@0.14.54:777- resolution: {integrity: sha512-sFwueGr7OvIFiQT6WeG0jRLjkjdqWWSrfbVwZp8iMP+8UHEHRBvlaxL6IuKNDwAozNUmbb8nIMXa7oAOARGs1Q==}778- engines: {node: '>=12'}779- cpu: [arm64]780- os: [freebsd]781-782- esbuild-linux-32@0.14.54:783- resolution: {integrity: sha512-1ZuY+JDI//WmklKlBgJnglpUL1owm2OX+8E1syCD6UAxcMM/XoWd76OHSjl/0MR0LisSAXDqgjT3uJqT67O3qw==}784- engines: {node: '>=12'}785- cpu: [ia32]786- os: [linux]787-788- esbuild-linux-64@0.14.54:789- resolution: {integrity: sha512-EgjAgH5HwTbtNsTqQOXWApBaPVdDn7XcK+/PtJwZLT1UmpLoznPd8c5CxqsH2dQK3j05YsB3L17T8vE7cp4cCg==}790- engines: {node: '>=12'}791- cpu: [x64]792- os: [linux]793-794- esbuild-linux-arm64@0.14.54:795- resolution: {integrity: sha512-WL71L+0Rwv+Gv/HTmxTEmpv0UgmxYa5ftZILVi2QmZBgX3q7+tDeOQNqGtdXSdsL8TQi1vIaVFHUPDe0O0kdig==}796- engines: {node: '>=12'}797- cpu: [arm64]798- os: [linux]799-800- esbuild-linux-arm@0.14.54:801- resolution: {integrity: sha512-qqz/SjemQhVMTnvcLGoLOdFpCYbz4v4fUo+TfsWG+1aOu70/80RV6bgNpR2JCrppV2moUQkww+6bWxXRL9YMGw==}802- engines: {node: '>=12'}803- cpu: [arm]804- os: [linux]805-806- esbuild-linux-mips64le@0.14.54:807- resolution: {integrity: sha512-qTHGQB8D1etd0u1+sB6p0ikLKRVuCWhYQhAHRPkO+OF3I/iSlTKNNS0Lh2Oc0g0UFGguaFZZiPJdJey3AGpAlw==}808- engines: {node: '>=12'}809- cpu: [mips64el]810- os: [linux]811-812- esbuild-linux-ppc64le@0.14.54:813- resolution: {integrity: sha512-j3OMlzHiqwZBDPRCDFKcx595XVfOfOnv68Ax3U4UKZ3MTYQB5Yz3X1mn5GnodEVYzhtZgxEBidLWeIs8FDSfrQ==}814- engines: {node: '>=12'}815- cpu: [ppc64]816- os: [linux]817-818- esbuild-linux-riscv64@0.14.54:819- resolution: {integrity: sha512-y7Vt7Wl9dkOGZjxQZnDAqqn+XOqFD7IMWiewY5SPlNlzMX39ocPQlOaoxvT4FllA5viyV26/QzHtvTjVNOxHZg==}820- engines: {node: '>=12'}821- cpu: [riscv64]822- os: [linux]823-824- esbuild-linux-s390x@0.14.54:825- resolution: {integrity: sha512-zaHpW9dziAsi7lRcyV4r8dhfG1qBidQWUXweUjnw+lliChJqQr+6XD71K41oEIC3Mx1KStovEmlzm+MkGZHnHA==}826- engines: {node: '>=12'}827- cpu: [s390x]828- os: [linux]829-830- esbuild-netbsd-64@0.14.54:831- resolution: {integrity: sha512-PR01lmIMnfJTgeU9VJTDY9ZerDWVFIUzAtJuDHwwceppW7cQWjBBqP48NdeRtoP04/AtO9a7w3viI+PIDr6d+w==}832- engines: {node: '>=12'}833- cpu: [x64]834- os: [netbsd]835-836- esbuild-openbsd-64@0.14.54:837- resolution: {integrity: sha512-Qyk7ikT2o7Wu76UsvvDS5q0amJvmRzDyVlL0qf5VLsLchjCa1+IAvd8kTBgUxD7VBUUVgItLkk609ZHUc1oCaw==}838- engines: {node: '>=12'}839- cpu: [x64]840- os: [openbsd]841-842- esbuild-sunos-64@0.14.54:843- resolution: {integrity: sha512-28GZ24KmMSeKi5ueWzMcco6EBHStL3B6ubM7M51RmPwXQGLe0teBGJocmWhgwccA1GeFXqxzILIxXpHbl9Q/Kw==}844- engines: {node: '>=12'}845- cpu: [x64]846- os: [sunos]847-848- esbuild-windows-32@0.14.54:849- resolution: {integrity: sha512-T+rdZW19ql9MjS7pixmZYVObd9G7kcaZo+sETqNH4RCkuuYSuv9AGHUVnPoP9hhuE1WM1ZimHz1CIBHBboLU7w==}850- engines: {node: '>=12'}851- cpu: [ia32]852- os: [win32]853-854- esbuild-windows-64@0.14.54:855- resolution: {integrity: sha512-AoHTRBUuYwXtZhjXZbA1pGfTo8cJo3vZIcWGLiUcTNgHpJJMC1rVA44ZereBHMJtotyN71S8Qw0npiCIkW96cQ==}856- engines: {node: '>=12'}857- cpu: [x64]858- os: [win32]859-860- esbuild-windows-arm64@0.14.54:861- resolution: {integrity: sha512-M0kuUvXhot1zOISQGXwWn6YtS+Y/1RT9WrVIOywZnJHo3jCDyewAc79aKNQWFCQm+xNHVTq9h8dZKvygoXQQRg==}862- engines: {node: '>=12'}863- cpu: [arm64]864- os: [win32]865-866- esbuild@0.14.54:867- resolution: {integrity: sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==}868- engines: {node: '>=12'}869- hasBin: true870-734 escalade@3.2.0:735 resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==}736 engines: {node: '>=6'}737 549 unmodified lines1287 dependencies:1288 tslib: 2.8.11289 optional: true1290 1428- '@esbuild/linux-loong64@0.14.54':1429- optional: true1430-1291 '@jridgewell/gen-mapping@0.3.13':1292 dependencies:1293 '@jridgewell/sourcemap-codec': 1.5.51294 '@jridgewell/trace-mapping': 0.3.3191 unmodified lines1386 '@emnapi/runtime': 1.9.21387 '@tybys/wasm-util': 0.10.11388 optional: true1389 1530- '@originjs/vite-plugin-commonjs@1.0.3':1531- dependencies:1532- esbuild: 0.14.541533-1390 '@oxc-project/types@0.122.0': {}1391 1392 '@oxlint-tsgolint/darwin-arm64@0.20.0':1393 optional: true327 unmodified lines1721 strip-ansi: 6.0.11722 1723 es-module-lexer@2.0.0: {}1724 1869- esbuild-android-64@0.14.54:1870- optional: true1871-1872- esbuild-android-arm64@0.14.54:1873- optional: true1874-1875- esbuild-darwin-64@0.14.54:1876- optional: true1877-1878- esbuild-darwin-arm64@0.14.54:1879- optional: true1880-1881- esbuild-freebsd-64@0.14.54:1882- optional: true1883-1884- esbuild-freebsd-arm64@0.14.54:1885- optional: true1886-1887- esbuild-linux-32@0.14.54:1888- optional: true1889-1890- esbuild-linux-64@0.14.54:1891- optional: true1892-1893- esbuild-linux-arm64@0.14.54:1894- optional: true1895-1896- esbuild-linux-arm@0.14.54:1897- optional: true1898-1899- esbuild-linux-mips64le@0.14.54:1900- optional: true1901-1902- esbuild-linux-ppc64le@0.14.54:1903- optional: true1904-1905- esbuild-linux-riscv64@0.14.54:1906- optional: true1907-1908- esbuild-linux-s390x@0.14.54:1909- optional: true1910-1911- esbuild-netbsd-64@0.14.54:1912- optional: true1913-1914- esbuild-openbsd-64@0.14.54:1915- optional: true1916-1917- esbuild-sunos-64@0.14.54:1918- optional: true1919-1920- esbuild-windows-32@0.14.54:1921- optional: true1922-1923- esbuild-windows-64@0.14.54:1924- optional: true1925-1926- esbuild-windows-arm64@0.14.54:1927- optional: true1928-1929- esbuild@0.14.54:1930- optionalDependencies:1931- '@esbuild/linux-loong64': 0.14.541932- esbuild-android-64: 0.14.541933- esbuild-android-arm64: 0.14.541934- esbuild-darwin-64: 0.14.541935- esbuild-darwin-arm64: 0.14.541936- esbuild-freebsd-64: 0.14.541937- esbuild-freebsd-arm64: 0.14.541938- esbuild-linux-32: 0.14.541939- esbuild-linux-64: 0.14.541940- esbuild-linux-arm: 0.14.541941- esbuild-linux-arm64: 0.14.541942- esbuild-linux-mips64le: 0.14.541943- esbuild-linux-ppc64le: 0.14.541944- esbuild-linux-riscv64: 0.14.541945- esbuild-linux-s390x: 0.14.541946- esbuild-netbsd-64: 0.14.541947- esbuild-openbsd-64: 0.14.541948- esbuild-sunos-64: 0.14.541949- esbuild-windows-32: 0.14.541950- esbuild-windows-64: 0.14.541951- esbuild-windows-arm64: 0.14.541952-1725 escalade@3.2.0: {}1726 1727 eslint-plugin-prefer-let@4.2.2:1728 dependencies:362 unmodified lines