@noodleseed/one 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. package/dist/cli.js +5 -0
  2. package/dist/cli.js.map +1 -1
  3. package/dist/commands/shared.d.ts +1 -1
  4. package/dist/commands/shared.d.ts.map +1 -1
  5. package/dist/commands/shared.js +2 -2
  6. package/dist/commands/shared.js.map +1 -1
  7. package/dist/react-widget-build.js +20 -1
  8. package/dist/react-widget-build.js.map +1 -1
  9. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.d.ts.map +1 -1
  10. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js +1 -0
  11. package/node_modules/@noodle-borg/agent-kit/dist/curated/command-groups.js.map +1 -1
  12. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.d.ts.map +1 -1
  13. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js +1 -0
  14. package/node_modules/@noodle-borg/agent-kit/dist/generated/surface.js.map +1 -1
  15. package/node_modules/@noodle-borg/agent-kit/package.json +1 -1
  16. package/package.json +2 -20
  17. package/node_modules/@oxc-project/types/LICENSE +0 -22
  18. package/node_modules/@oxc-project/types/README.md +0 -3
  19. package/node_modules/@oxc-project/types/package.json +0 -26
  20. package/node_modules/@oxc-project/types/types.d.ts +0 -1912
  21. package/node_modules/@rolldown/binding-linux-x64-gnu/README.md +0 -3
  22. package/node_modules/@rolldown/binding-linux-x64-gnu/package.json +0 -40
  23. package/node_modules/@rolldown/binding-linux-x64-gnu/rolldown-binding.linux-x64-gnu.node +0 -0
  24. package/node_modules/@rolldown/pluginutils/LICENSE +0 -21
  25. package/node_modules/@rolldown/pluginutils/README.md +0 -145
  26. package/node_modules/@rolldown/pluginutils/dist/filter/index.d.mts +0 -194
  27. package/node_modules/@rolldown/pluginutils/dist/filter/index.mjs +0 -2
  28. package/node_modules/@rolldown/pluginutils/dist/filter-B_mD-HGz.mjs +0 -323
  29. package/node_modules/@rolldown/pluginutils/dist/index.d.mts +0 -2
  30. package/node_modules/@rolldown/pluginutils/dist/index.mjs +0 -2
  31. package/node_modules/@rolldown/pluginutils/package.json +0 -40
  32. package/node_modules/@vitejs/plugin-react/LICENSE +0 -21
  33. package/node_modules/@vitejs/plugin-react/README.md +0 -169
  34. package/node_modules/@vitejs/plugin-react/dist/index.d.ts +0 -48
  35. package/node_modules/@vitejs/plugin-react/dist/index.js +0 -200
  36. package/node_modules/@vitejs/plugin-react/dist/refresh-runtime.js +0 -663
  37. package/node_modules/@vitejs/plugin-react/package.json +0 -87
  38. package/node_modules/@vitejs/plugin-react/types/optionalTypes.d.ts +0 -12
  39. package/node_modules/@vitejs/plugin-react/types/preamble.d.ts +0 -1
  40. package/node_modules/detect-libc/LICENSE +0 -201
  41. package/node_modules/detect-libc/README.md +0 -163
  42. package/node_modules/detect-libc/index.d.ts +0 -14
  43. package/node_modules/detect-libc/lib/detect-libc.js +0 -313
  44. package/node_modules/detect-libc/lib/elf.js +0 -39
  45. package/node_modules/detect-libc/lib/filesystem.js +0 -51
  46. package/node_modules/detect-libc/lib/process.js +0 -24
  47. package/node_modules/detect-libc/package.json +0 -44
  48. package/node_modules/fdir/LICENSE +0 -7
  49. package/node_modules/fdir/README.md +0 -91
  50. package/node_modules/fdir/dist/index.cjs +0 -588
  51. package/node_modules/fdir/dist/index.d.cts +0 -155
  52. package/node_modules/fdir/dist/index.d.mts +0 -155
  53. package/node_modules/fdir/dist/index.mjs +0 -570
  54. package/node_modules/fdir/package.json +0 -103
  55. package/node_modules/lightningcss/LICENSE +0 -373
  56. package/node_modules/lightningcss/README.md +0 -105
  57. package/node_modules/lightningcss/node/ast.d.ts +0 -9892
  58. package/node_modules/lightningcss/node/ast.js.flow +0 -10539
  59. package/node_modules/lightningcss/node/browserslistToTargets.js +0 -48
  60. package/node_modules/lightningcss/node/composeVisitors.js +0 -450
  61. package/node_modules/lightningcss/node/flags.js +0 -28
  62. package/node_modules/lightningcss/node/index.d.ts +0 -494
  63. package/node_modules/lightningcss/node/index.js +0 -59
  64. package/node_modules/lightningcss/node/index.js.flow +0 -843
  65. package/node_modules/lightningcss/node/index.mjs +0 -4
  66. package/node_modules/lightningcss/node/targets.d.ts +0 -40
  67. package/node_modules/lightningcss/node/targets.js.flow +0 -39
  68. package/node_modules/lightningcss/package.json +0 -110
  69. package/node_modules/lightningcss-linux-x64-gnu/LICENSE +0 -373
  70. package/node_modules/lightningcss-linux-x64-gnu/README.md +0 -1
  71. package/node_modules/lightningcss-linux-x64-gnu/lightningcss.linux-x64-gnu.node +0 -0
  72. package/node_modules/lightningcss-linux-x64-gnu/package.json +0 -37
  73. package/node_modules/nanoid/.claude/settings.local.json +0 -14
  74. package/node_modules/nanoid/LICENSE +0 -20
  75. package/node_modules/nanoid/README.md +0 -39
  76. package/node_modules/nanoid/async/index.browser.cjs +0 -69
  77. package/node_modules/nanoid/async/index.browser.js +0 -34
  78. package/node_modules/nanoid/async/index.cjs +0 -71
  79. package/node_modules/nanoid/async/index.d.ts +0 -56
  80. package/node_modules/nanoid/async/index.js +0 -35
  81. package/node_modules/nanoid/async/index.native.js +0 -26
  82. package/node_modules/nanoid/async/package.json +0 -12
  83. package/node_modules/nanoid/bin/nanoid.cjs +0 -55
  84. package/node_modules/nanoid/index.browser.cjs +0 -72
  85. package/node_modules/nanoid/index.browser.js +0 -34
  86. package/node_modules/nanoid/index.cjs +0 -86
  87. package/node_modules/nanoid/index.d.cts +0 -91
  88. package/node_modules/nanoid/index.d.ts +0 -91
  89. package/node_modules/nanoid/index.js +0 -46
  90. package/node_modules/nanoid/nanoid.js +0 -1
  91. package/node_modules/nanoid/non-secure/index.cjs +0 -34
  92. package/node_modules/nanoid/non-secure/index.d.ts +0 -33
  93. package/node_modules/nanoid/non-secure/index.js +0 -21
  94. package/node_modules/nanoid/non-secure/package.json +0 -6
  95. package/node_modules/nanoid/package.json +0 -89
  96. package/node_modules/nanoid/url-alphabet/index.cjs +0 -7
  97. package/node_modules/nanoid/url-alphabet/index.js +0 -3
  98. package/node_modules/nanoid/url-alphabet/package.json +0 -6
  99. package/node_modules/picocolors/LICENSE +0 -15
  100. package/node_modules/picocolors/README.md +0 -21
  101. package/node_modules/picocolors/package.json +0 -25
  102. package/node_modules/picocolors/picocolors.browser.js +0 -4
  103. package/node_modules/picocolors/picocolors.d.ts +0 -5
  104. package/node_modules/picocolors/picocolors.js +0 -75
  105. package/node_modules/picocolors/types.d.ts +0 -51
  106. package/node_modules/picomatch/LICENSE +0 -21
  107. package/node_modules/picomatch/README.md +0 -749
  108. package/node_modules/picomatch/index.js +0 -17
  109. package/node_modules/picomatch/lib/constants.js +0 -184
  110. package/node_modules/picomatch/lib/parse.js +0 -1386
  111. package/node_modules/picomatch/lib/picomatch.js +0 -349
  112. package/node_modules/picomatch/lib/scan.js +0 -391
  113. package/node_modules/picomatch/lib/utils.js +0 -72
  114. package/node_modules/picomatch/package.json +0 -82
  115. package/node_modules/picomatch/posix.js +0 -3
  116. package/node_modules/postcss/LICENSE +0 -20
  117. package/node_modules/postcss/README.md +0 -28
  118. package/node_modules/postcss/lib/at-rule.d.ts +0 -139
  119. package/node_modules/postcss/lib/at-rule.js +0 -25
  120. package/node_modules/postcss/lib/comment.d.ts +0 -67
  121. package/node_modules/postcss/lib/comment.js +0 -13
  122. package/node_modules/postcss/lib/container.d.ts +0 -478
  123. package/node_modules/postcss/lib/container.js +0 -447
  124. package/node_modules/postcss/lib/css-syntax-error.d.ts +0 -247
  125. package/node_modules/postcss/lib/css-syntax-error.js +0 -133
  126. package/node_modules/postcss/lib/declaration.d.ts +0 -150
  127. package/node_modules/postcss/lib/declaration.js +0 -24
  128. package/node_modules/postcss/lib/document.d.ts +0 -68
  129. package/node_modules/postcss/lib/document.js +0 -33
  130. package/node_modules/postcss/lib/fromJSON.d.ts +0 -9
  131. package/node_modules/postcss/lib/fromJSON.js +0 -54
  132. package/node_modules/postcss/lib/input.d.ts +0 -226
  133. package/node_modules/postcss/lib/input.js +0 -273
  134. package/node_modules/postcss/lib/lazy-result.d.ts +0 -189
  135. package/node_modules/postcss/lib/lazy-result.js +0 -563
  136. package/node_modules/postcss/lib/list.d.ts +0 -60
  137. package/node_modules/postcss/lib/list.js +0 -58
  138. package/node_modules/postcss/lib/map-generator.js +0 -376
  139. package/node_modules/postcss/lib/no-work-result.d.ts +0 -45
  140. package/node_modules/postcss/lib/no-work-result.js +0 -137
  141. package/node_modules/postcss/lib/node.d.ts +0 -555
  142. package/node_modules/postcss/lib/node.js +0 -449
  143. package/node_modules/postcss/lib/parse.d.ts +0 -9
  144. package/node_modules/postcss/lib/parse.js +0 -42
  145. package/node_modules/postcss/lib/parser.js +0 -618
  146. package/node_modules/postcss/lib/postcss.d.mts +0 -66
  147. package/node_modules/postcss/lib/postcss.d.ts +0 -461
  148. package/node_modules/postcss/lib/postcss.js +0 -101
  149. package/node_modules/postcss/lib/postcss.mjs +0 -30
  150. package/node_modules/postcss/lib/previous-map.d.ts +0 -80
  151. package/node_modules/postcss/lib/previous-map.js +0 -161
  152. package/node_modules/postcss/lib/processor.d.ts +0 -114
  153. package/node_modules/postcss/lib/processor.js +0 -67
  154. package/node_modules/postcss/lib/result.d.ts +0 -204
  155. package/node_modules/postcss/lib/result.js +0 -42
  156. package/node_modules/postcss/lib/root.d.ts +0 -86
  157. package/node_modules/postcss/lib/root.js +0 -61
  158. package/node_modules/postcss/lib/rule.d.ts +0 -126
  159. package/node_modules/postcss/lib/rule.js +0 -27
  160. package/node_modules/postcss/lib/stringifier.d.ts +0 -45
  161. package/node_modules/postcss/lib/stringifier.js +0 -374
  162. package/node_modules/postcss/lib/stringify.d.ts +0 -9
  163. package/node_modules/postcss/lib/stringify.js +0 -11
  164. package/node_modules/postcss/lib/symbols.js +0 -5
  165. package/node_modules/postcss/lib/terminal-highlight.js +0 -70
  166. package/node_modules/postcss/lib/tokenize.js +0 -270
  167. package/node_modules/postcss/lib/warn-once.js +0 -13
  168. package/node_modules/postcss/lib/warning.d.ts +0 -146
  169. package/node_modules/postcss/lib/warning.js +0 -37
  170. package/node_modules/postcss/package.json +0 -88
  171. package/node_modules/rolldown/LICENSE +0 -25
  172. package/node_modules/rolldown/README.md +0 -11
  173. package/node_modules/rolldown/bin/cli.mjs +0 -2
  174. package/node_modules/rolldown/dist/cli.d.mts +0 -1
  175. package/node_modules/rolldown/dist/cli.mjs +0 -1202
  176. package/node_modules/rolldown/dist/config.d.mts +0 -14
  177. package/node_modules/rolldown/dist/config.mjs +0 -4
  178. package/node_modules/rolldown/dist/experimental-index.d.mts +0 -280
  179. package/node_modules/rolldown/dist/experimental-index.mjs +0 -330
  180. package/node_modules/rolldown/dist/experimental-runtime-types.d.ts +0 -107
  181. package/node_modules/rolldown/dist/filter-index.d.mts +0 -195
  182. package/node_modules/rolldown/dist/filter-index.mjs +0 -380
  183. package/node_modules/rolldown/dist/get-log-filter.d.mts +0 -3
  184. package/node_modules/rolldown/dist/get-log-filter.mjs +0 -68
  185. package/node_modules/rolldown/dist/index.d.mts +0 -4
  186. package/node_modules/rolldown/dist/index.mjs +0 -50
  187. package/node_modules/rolldown/dist/parallel-plugin-worker.d.mts +0 -1
  188. package/node_modules/rolldown/dist/parallel-plugin-worker.mjs +0 -28
  189. package/node_modules/rolldown/dist/parallel-plugin.d.mts +0 -13
  190. package/node_modules/rolldown/dist/parallel-plugin.mjs +0 -6
  191. package/node_modules/rolldown/dist/parse-ast-index.d.mts +0 -32
  192. package/node_modules/rolldown/dist/parse-ast-index.mjs +0 -60
  193. package/node_modules/rolldown/dist/plugins-index.d.mts +0 -33
  194. package/node_modules/rolldown/dist/plugins-index.mjs +0 -40
  195. package/node_modules/rolldown/dist/shared/binding-B1q9aYT-.d.mts +0 -1947
  196. package/node_modules/rolldown/dist/shared/binding-Dh6LYCIB.mjs +0 -589
  197. package/node_modules/rolldown/dist/shared/bindingify-input-options-CzVhGygm.mjs +0 -2240
  198. package/node_modules/rolldown/dist/shared/constructors-688OwP2q.mjs +0 -65
  199. package/node_modules/rolldown/dist/shared/constructors-awZ1VNvg.d.mts +0 -36
  200. package/node_modules/rolldown/dist/shared/define-config-Demdg3_4.mjs +0 -6
  201. package/node_modules/rolldown/dist/shared/define-config-sxBscJ3M.d.mts +0 -3901
  202. package/node_modules/rolldown/dist/shared/error-B68YLzl3.mjs +0 -85
  203. package/node_modules/rolldown/dist/shared/get-log-filter-BpNVNJ5-.d.mts +0 -35
  204. package/node_modules/rolldown/dist/shared/load-config-BvPPEM7l.mjs +0 -120
  205. package/node_modules/rolldown/dist/shared/logging-BSNejiLS.d.mts +0 -50
  206. package/node_modules/rolldown/dist/shared/logs-aMKUxRpj.mjs +0 -180
  207. package/node_modules/rolldown/dist/shared/misc-CoQm4NHO.mjs +0 -21
  208. package/node_modules/rolldown/dist/shared/normalize-string-or-regex-BpXHYeN4.mjs +0 -68
  209. package/node_modules/rolldown/dist/shared/parse-CTgsjpo8.mjs +0 -74
  210. package/node_modules/rolldown/dist/shared/prompt-B1Yc1NPt.mjs +0 -847
  211. package/node_modules/rolldown/dist/shared/resolve-tsconfig-BkhP9bkX.mjs +0 -124
  212. package/node_modules/rolldown/dist/shared/rolldown-Brph2NSU.mjs +0 -40
  213. package/node_modules/rolldown/dist/shared/rolldown-build-DR0wzp0V.mjs +0 -3264
  214. package/node_modules/rolldown/dist/shared/transform-CEmFsvJW.d.mts +0 -149
  215. package/node_modules/rolldown/dist/shared/watch-FrHSqg24.mjs +0 -374
  216. package/node_modules/rolldown/dist/utils-index.d.mts +0 -376
  217. package/node_modules/rolldown/dist/utils-index.mjs +0 -2414
  218. package/node_modules/rolldown/package.json +0 -153
  219. package/node_modules/source-map-js/LICENSE +0 -28
  220. package/node_modules/source-map-js/README.md +0 -765
  221. package/node_modules/source-map-js/lib/array-set.js +0 -121
  222. package/node_modules/source-map-js/lib/base64-vlq.js +0 -140
  223. package/node_modules/source-map-js/lib/base64.js +0 -67
  224. package/node_modules/source-map-js/lib/binary-search.js +0 -111
  225. package/node_modules/source-map-js/lib/mapping-list.js +0 -79
  226. package/node_modules/source-map-js/lib/quick-sort.js +0 -132
  227. package/node_modules/source-map-js/lib/source-map-consumer.d.ts +0 -1
  228. package/node_modules/source-map-js/lib/source-map-consumer.js +0 -1188
  229. package/node_modules/source-map-js/lib/source-map-generator.d.ts +0 -1
  230. package/node_modules/source-map-js/lib/source-map-generator.js +0 -444
  231. package/node_modules/source-map-js/lib/source-node.d.ts +0 -1
  232. package/node_modules/source-map-js/lib/source-node.js +0 -413
  233. package/node_modules/source-map-js/lib/util.js +0 -594
  234. package/node_modules/source-map-js/package.json +0 -71
  235. package/node_modules/source-map-js/source-map.d.ts +0 -104
  236. package/node_modules/source-map-js/source-map.js +0 -8
  237. package/node_modules/tinyglobby/LICENSE +0 -21
  238. package/node_modules/tinyglobby/README.md +0 -25
  239. package/node_modules/tinyglobby/dist/index.cjs +0 -335
  240. package/node_modules/tinyglobby/dist/index.d.cts +0 -148
  241. package/node_modules/tinyglobby/dist/index.d.mts +0 -148
  242. package/node_modules/tinyglobby/dist/index.mjs +0 -307
  243. package/node_modules/tinyglobby/package.json +0 -70
  244. package/node_modules/vite/LICENSE.md +0 -2287
  245. package/node_modules/vite/README.md +0 -20
  246. package/node_modules/vite/bin/openChrome.js +0 -68
  247. package/node_modules/vite/bin/vite.js +0 -79
  248. package/node_modules/vite/client.d.ts +0 -285
  249. package/node_modules/vite/dist/client/client.mjs +0 -1269
  250. package/node_modules/vite/dist/client/env.mjs +0 -18
  251. package/node_modules/vite/dist/node/chunks/build.js +0 -5371
  252. package/node_modules/vite/dist/node/chunks/dist.js +0 -6784
  253. package/node_modules/vite/dist/node/chunks/lib.js +0 -371
  254. package/node_modules/vite/dist/node/chunks/logger.js +0 -364
  255. package/node_modules/vite/dist/node/chunks/moduleRunnerTransport.d.ts +0 -96
  256. package/node_modules/vite/dist/node/chunks/node.js +0 -35770
  257. package/node_modules/vite/dist/node/chunks/postcss-import.js +0 -467
  258. package/node_modules/vite/dist/node/cli.js +0 -836
  259. package/node_modules/vite/dist/node/index.d.ts +0 -4010
  260. package/node_modules/vite/dist/node/index.js +0 -3
  261. package/node_modules/vite/dist/node/internal.d.ts +0 -2
  262. package/node_modules/vite/dist/node/internal.js +0 -2
  263. package/node_modules/vite/dist/node/module-runner.d.ts +0 -314
  264. package/node_modules/vite/dist/node/module-runner.js +0 -1274
  265. package/node_modules/vite/misc/false.js +0 -1
  266. package/node_modules/vite/misc/true.js +0 -1
  267. package/node_modules/vite/package.json +0 -194
  268. package/node_modules/vite/types/customEvent.d.ts +0 -79
  269. package/node_modules/vite/types/hmrPayload.d.ts +0 -80
  270. package/node_modules/vite/types/hot.d.ts +0 -39
  271. package/node_modules/vite/types/import-meta.d.ts +0 -5
  272. package/node_modules/vite/types/importGlob.d.ts +0 -131
  273. package/node_modules/vite/types/importMeta.d.ts +0 -30
  274. package/node_modules/vite/types/internal/cssPreprocessorOptions.d.ts +0 -44
  275. package/node_modules/vite/types/internal/esbuildOptions.d.ts +0 -28
  276. package/node_modules/vite/types/internal/lightningcssOptions.d.ts +0 -18
  277. package/node_modules/vite/types/internal/rollupTypeCompat.d.ts +0 -24
  278. package/node_modules/vite/types/internal/terserOptions.d.ts +0 -11
  279. package/node_modules/vite/types/metadata.d.ts +0 -47
@@ -1,39 +0,0 @@
1
- # Nano ID
2
-
3
- <img src="https://ai.github.io/nanoid/logo.svg" align="right"
4
- alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
5
-
6
- **English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md)
7
-
8
- A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
9
-
10
- > “An amazing level of senseless perfectionism,
11
- > which is simply impossible not to respect.”
12
-
13
- * **Small.** 130 bytes (minified and gzipped). No dependencies.
14
- [Size Limit] controls the size.
15
- * **Fast.** It is 2 times faster than UUID.
16
- * **Safe.** It uses hardware random generator. Can be used in clusters.
17
- * **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
18
- So ID size was reduced from 36 to 21 symbols.
19
- * **Portable.** Nano ID was ported
20
- to [20 programming languages](#other-programming-languages).
21
-
22
- ```js
23
- import { nanoid } from 'nanoid'
24
- model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
25
- ```
26
-
27
- Supports modern browsers, IE [with Babel], Node.js and React Native.
28
-
29
- [online tool]: https://gitpod.io/#https://github.com/ai/nanoid/
30
- [with Babel]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
31
- [Size Limit]: https://github.com/ai/size-limit
32
-
33
- <a href="https://evilmartians.com/?utm_source=nanoid">
34
- <img src="https://evilmartians.com/badges/sponsored-by-evil-martians.svg"
35
- alt="Sponsored by Evil Martians" width="236" height="54">
36
- </a>
37
-
38
- ## Docs
39
- Read full docs **[here](https://github.com/ai/nanoid#readme)**.
@@ -1,69 +0,0 @@
1
- let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
2
-
3
- let customAlphabet = (alphabet, defaultSize = 21) => {
4
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
5
- // values closer to the alphabet size. The bitmask calculates the closest
6
- // `2^31 - 1` number, which exceeds the alphabet size.
7
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
8
- // `Math.clz32` is not used, because it is not available in browsers.
9
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
10
- // Though, the bitmask solution is not perfect since the bytes exceeding
11
- // the alphabet size are refused. Therefore, to reliably generate the ID,
12
- // the random bytes redundancy has to be satisfied.
13
-
14
- // Note: every hardware random generator call is performance expensive,
15
- // because the system call for entropy collection takes a lot of time.
16
- // So, to avoid additional system calls, extra bytes are requested in advance.
17
-
18
- // Next, a step determines how many random bytes to generate.
19
- // The number of random bytes gets decided upon the ID size, mask,
20
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
21
- // according to benchmarks).
22
-
23
- // `-~f => Math.ceil(f)` if f is a float
24
- // `-~i => i + 1` if i is an integer
25
- let step = -~((1.6 * mask * defaultSize) / alphabet.length)
26
-
27
- return async (size = defaultSize) => {
28
- let id = ''
29
- while (true) {
30
- let bytes = crypto.getRandomValues(new Uint8Array(step))
31
- // A compact alternative for `for (var i = 0; i < step; i++)`.
32
- let i = step | 0
33
- while (i--) {
34
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
35
- id += alphabet[bytes[i] & mask] || ''
36
- if (id.length === size) return id
37
- }
38
- }
39
- }
40
- }
41
-
42
- let nanoid = async (size = 21) => {
43
- let id = ''
44
- let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
45
-
46
- // A compact alternative for `for (var i = 0; i < step; i++)`.
47
- while (size--) {
48
- // It is incorrect to use bytes exceeding the alphabet size.
49
- // The following mask reduces the random byte in the 0-255 value
50
- // range to the 0-63 value range. Therefore, adding hacks, such
51
- // as empty string fallback or magic numbers, is unneccessary because
52
- // the bitmask trims bytes down to the alphabet size.
53
- let byte = bytes[size] & 63
54
- if (byte < 36) {
55
- // `0-9a-z`
56
- id += byte.toString(36)
57
- } else if (byte < 62) {
58
- // `A-Z`
59
- id += (byte - 26).toString(36).toUpperCase()
60
- } else if (byte < 63) {
61
- id += '_'
62
- } else {
63
- id += '-'
64
- }
65
- }
66
- return id
67
- }
68
-
69
- module.exports = { nanoid, customAlphabet, random }
@@ -1,34 +0,0 @@
1
- let random = async bytes => crypto.getRandomValues(new Uint8Array(bytes))
2
- let customAlphabet = (alphabet, defaultSize = 21) => {
3
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
4
- let step = -~((1.6 * mask * defaultSize) / alphabet.length)
5
- return async (size = defaultSize) => {
6
- let id = ''
7
- while (true) {
8
- let bytes = crypto.getRandomValues(new Uint8Array(step))
9
- let i = step | 0
10
- while (i--) {
11
- id += alphabet[bytes[i] & mask] || ''
12
- if (id.length === size) return id
13
- }
14
- }
15
- }
16
- }
17
- let nanoid = async (size = 21) => {
18
- let id = ''
19
- let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
20
- while (size--) {
21
- let byte = bytes[size] & 63
22
- if (byte < 36) {
23
- id += byte.toString(36)
24
- } else if (byte < 62) {
25
- id += (byte - 26).toString(36).toUpperCase()
26
- } else if (byte < 63) {
27
- id += '_'
28
- } else {
29
- id += '-'
30
- }
31
- }
32
- return id
33
- }
34
- export { nanoid, customAlphabet, random }
@@ -1,71 +0,0 @@
1
- let crypto = require('crypto')
2
-
3
- let { urlAlphabet } = require('../url-alphabet/index.cjs')
4
-
5
- // `crypto.randomFill()` is a little faster than `crypto.randomBytes()`,
6
- // because it is possible to use in combination with `Buffer.allocUnsafe()`.
7
- let random = bytes =>
8
- new Promise((resolve, reject) => {
9
- // `Buffer.allocUnsafe()` is faster because it doesn’t flush the memory.
10
- // Memory flushing is unnecessary since the buffer allocation itself resets
11
- // the memory with the new bytes.
12
- crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
13
- if (err) {
14
- reject(err)
15
- } else {
16
- resolve(buf)
17
- }
18
- })
19
- })
20
-
21
- let customAlphabet = (alphabet, defaultSize = 21) => {
22
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
23
- // values closer to the alphabet size. The bitmask calculates the closest
24
- // `2^31 - 1` number, which exceeds the alphabet size.
25
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
26
- let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
27
- // Though, the bitmask solution is not perfect since the bytes exceeding
28
- // the alphabet size are refused. Therefore, to reliably generate the ID,
29
- // the random bytes redundancy has to be satisfied.
30
-
31
- // Note: every hardware random generator call is performance expensive,
32
- // because the system call for entropy collection takes a lot of time.
33
- // So, to avoid additional system calls, extra bytes are requested in advance.
34
-
35
- // Next, a step determines how many random bytes to generate.
36
- // The number of random bytes gets decided upon the ID size, mask,
37
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
38
- // according to benchmarks).
39
- let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
40
-
41
- let tick = (id, size = defaultSize) =>
42
- random(step).then(bytes => {
43
- // A compact alternative for `for (var i = 0; i < step; i++)`.
44
- let i = step
45
- while (i--) {
46
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
47
- id += alphabet[bytes[i] & mask] || ''
48
- if (id.length >= size) return id
49
- }
50
- return tick(id, size)
51
- })
52
-
53
- return size => tick('', size)
54
- }
55
-
56
- let nanoid = (size = 21) =>
57
- random((size |= 0)).then(bytes => {
58
- let id = ''
59
- // A compact alternative for `for (var i = 0; i < step; i++)`.
60
- while (size--) {
61
- // It is incorrect to use bytes exceeding the alphabet size.
62
- // The following mask reduces the random byte in the 0-255 value
63
- // range to the 0-63 value range. Therefore, adding hacks, such
64
- // as empty string fallback or magic numbers, is unneccessary because
65
- // the bitmask trims bytes down to the alphabet size.
66
- id += urlAlphabet[bytes[size] & 63]
67
- }
68
- return id
69
- })
70
-
71
- module.exports = { nanoid, customAlphabet, random }
@@ -1,56 +0,0 @@
1
- /**
2
- * Generate secure URL-friendly unique ID. The non-blocking version.
3
- *
4
- * By default, the ID will have 21 symbols to have a collision probability
5
- * similar to UUID v4.
6
- *
7
- * ```js
8
- * import { nanoid } from 'nanoid/async'
9
- * nanoid().then(id => {
10
- * model.id = id
11
- * })
12
- * ```
13
- *
14
- * @param size Size of the ID. The default size is 21.
15
- * @returns A promise with a random string.
16
- */
17
- export function nanoid(size?: number): Promise<string>
18
-
19
- /**
20
- * A low-level function.
21
- * Generate secure unique ID with custom alphabet. The non-blocking version.
22
- *
23
- * Alphabet must contain 256 symbols or less. Otherwise, the generator
24
- * will not be secure.
25
- *
26
- * @param alphabet Alphabet used to generate the ID.
27
- * @param defaultSize Size of the ID. The default size is 21.
28
- * @returns A function that returns a promise with a random string.
29
- *
30
- * ```js
31
- * import { customAlphabet } from 'nanoid/async'
32
- * const nanoid = customAlphabet('0123456789абвгдеё', 5)
33
- * nanoid().then(id => {
34
- * model.id = id //=> "8ё56а"
35
- * })
36
- * ```
37
- */
38
- export function customAlphabet(
39
- alphabet: string,
40
- defaultSize?: number
41
- ): (size?: number) => Promise<string>
42
-
43
- /**
44
- * Generate an array of random bytes collected from hardware noise.
45
- *
46
- * ```js
47
- * import { random } from 'nanoid/async'
48
- * random(5).then(bytes => {
49
- * bytes //=> [10, 67, 212, 67, 89]
50
- * })
51
- * ```
52
- *
53
- * @param bytes Size of the array.
54
- * @returns A promise with a random bytes array.
55
- */
56
- export function random(bytes: number): Promise<Uint8Array>
@@ -1,35 +0,0 @@
1
- import crypto from 'crypto'
2
- import { urlAlphabet } from '../url-alphabet/index.js'
3
- let random = bytes =>
4
- new Promise((resolve, reject) => {
5
- crypto.randomFill(Buffer.allocUnsafe(bytes), (err, buf) => {
6
- if (err) {
7
- reject(err)
8
- } else {
9
- resolve(buf)
10
- }
11
- })
12
- })
13
- let customAlphabet = (alphabet, defaultSize = 21) => {
14
- let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
15
- let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
16
- let tick = (id, size = defaultSize) =>
17
- random(step).then(bytes => {
18
- let i = step
19
- while (i--) {
20
- id += alphabet[bytes[i] & mask] || ''
21
- if (id.length >= size) return id
22
- }
23
- return tick(id, size)
24
- })
25
- return size => tick('', size)
26
- }
27
- let nanoid = (size = 21) =>
28
- random((size |= 0)).then(bytes => {
29
- let id = ''
30
- while (size--) {
31
- id += urlAlphabet[bytes[size] & 63]
32
- }
33
- return id
34
- })
35
- export { nanoid, customAlphabet, random }
@@ -1,26 +0,0 @@
1
- import { getRandomBytesAsync } from 'expo-random'
2
- import { urlAlphabet } from '../url-alphabet/index.js'
3
- let random = getRandomBytesAsync
4
- let customAlphabet = (alphabet, defaultSize = 21) => {
5
- let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
6
- let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
7
- let tick = (id, size = defaultSize) =>
8
- random(step).then(bytes => {
9
- let i = step
10
- while (i--) {
11
- id += alphabet[bytes[i] & mask] || ''
12
- if (id.length >= size) return id
13
- }
14
- return tick(id, size)
15
- })
16
- return size => tick('', size)
17
- }
18
- let nanoid = (size = 21) =>
19
- random((size |= 0)).then(bytes => {
20
- let id = ''
21
- while (size--) {
22
- id += urlAlphabet[bytes[size] & 63]
23
- }
24
- return id
25
- })
26
- export { nanoid, customAlphabet, random }
@@ -1,12 +0,0 @@
1
- {
2
- "type": "module",
3
- "main": "index.cjs",
4
- "module": "index.js",
5
- "react-native": {
6
- "./index.js": "./index.native.js"
7
- },
8
- "browser": {
9
- "./index.js": "./index.browser.js",
10
- "./index.cjs": "./index.browser.cjs"
11
- }
12
- }
@@ -1,55 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- let { nanoid, customAlphabet } = require('..')
4
-
5
- function print(msg) {
6
- process.stdout.write(msg + '\n')
7
- }
8
-
9
- function error(msg) {
10
- process.stderr.write(msg + '\n')
11
- process.exit(1)
12
- }
13
-
14
- if (process.argv.includes('--help') || process.argv.includes('-h')) {
15
- print(`
16
- Usage
17
- $ nanoid [options]
18
-
19
- Options
20
- -s, --size Generated ID size
21
- -a, --alphabet Alphabet to use
22
- -h, --help Show this help
23
-
24
- Examples
25
- $ nanoid --s 15
26
- S9sBF77U6sDB8Yg
27
-
28
- $ nanoid --size 10 --alphabet abc
29
- bcabababca`)
30
- process.exit()
31
- }
32
-
33
- let alphabet, size
34
- for (let i = 2; i < process.argv.length; i++) {
35
- let arg = process.argv[i]
36
- if (arg === '--size' || arg === '-s') {
37
- size = Number(process.argv[i + 1])
38
- i += 1
39
- if (Number.isNaN(size) || size <= 0) {
40
- error('Size must be positive integer')
41
- }
42
- } else if (arg === '--alphabet' || arg === '-a') {
43
- alphabet = process.argv[i + 1]
44
- i += 1
45
- } else {
46
- error('Unknown argument ' + arg)
47
- }
48
- }
49
-
50
- if (alphabet) {
51
- let customNanoid = customAlphabet(alphabet, size)
52
- print(customNanoid())
53
- } else {
54
- print(nanoid(size))
55
- }
@@ -1,72 +0,0 @@
1
- // This file replaces `index.js` in bundlers like webpack or Rollup,
2
- // according to `browser` config in `package.json`.
3
-
4
- let { urlAlphabet } = require('./url-alphabet/index.cjs')
5
-
6
- let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
7
-
8
- let customRandom = (alphabet, defaultSize, getRandom) => {
9
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
10
- // values closer to the alphabet size. The bitmask calculates the closest
11
- // `2^31 - 1` number, which exceeds the alphabet size.
12
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
13
- // `Math.clz32` is not used, because it is not available in browsers.
14
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
15
- // Though, the bitmask solution is not perfect since the bytes exceeding
16
- // the alphabet size are refused. Therefore, to reliably generate the ID,
17
- // the random bytes redundancy has to be satisfied.
18
-
19
- // Note: every hardware random generator call is performance expensive,
20
- // because the system call for entropy collection takes a lot of time.
21
- // So, to avoid additional system calls, extra bytes are requested in advance.
22
-
23
- // Next, a step determines how many random bytes to generate.
24
- // The number of random bytes gets decided upon the ID size, mask,
25
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
26
- // according to benchmarks).
27
-
28
- // `-~f => Math.ceil(f)` if f is a float
29
- // `-~i => i + 1` if i is an integer
30
- let step = -~((1.6 * mask * defaultSize) / alphabet.length)
31
-
32
- return (size = defaultSize) => {
33
- let id = ''
34
- while (true) {
35
- let bytes = getRandom(step)
36
- // A compact alternative for `for (var i = 0; i < step; i++)`.
37
- let j = step | 0
38
- while (j--) {
39
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
40
- id += alphabet[bytes[j] & mask] || ''
41
- if (id.length === size) return id
42
- }
43
- }
44
- }
45
- }
46
-
47
- let customAlphabet = (alphabet, size = 21) =>
48
- customRandom(alphabet, size, random)
49
-
50
- let nanoid = (size = 21) =>
51
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
52
- // It is incorrect to use bytes exceeding the alphabet size.
53
- // The following mask reduces the random byte in the 0-255 value
54
- // range to the 0-63 value range. Therefore, adding hacks, such
55
- // as empty string fallback or magic numbers, is unneccessary because
56
- // the bitmask trims bytes down to the alphabet size.
57
- byte &= 63
58
- if (byte < 36) {
59
- // `0-9a-z`
60
- id += byte.toString(36)
61
- } else if (byte < 62) {
62
- // `A-Z`
63
- id += (byte - 26).toString(36).toUpperCase()
64
- } else if (byte > 62) {
65
- id += '-'
66
- } else {
67
- id += '_'
68
- }
69
- return id
70
- }, '')
71
-
72
- module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }
@@ -1,34 +0,0 @@
1
- import { urlAlphabet } from './url-alphabet/index.js'
2
- let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
3
- let customRandom = (alphabet, defaultSize, getRandom) => {
4
- let mask = (2 << (Math.log(alphabet.length - 1) / Math.LN2)) - 1
5
- let step = -~((1.6 * mask * defaultSize) / alphabet.length)
6
- return (size = defaultSize) => {
7
- let id = ''
8
- while (true) {
9
- let bytes = getRandom(step)
10
- let j = step | 0
11
- while (j--) {
12
- id += alphabet[bytes[j] & mask] || ''
13
- if (id.length === size) return id
14
- }
15
- }
16
- }
17
- }
18
- let customAlphabet = (alphabet, size = 21) =>
19
- customRandom(alphabet, size, random)
20
- let nanoid = (size = 21) =>
21
- crypto.getRandomValues(new Uint8Array(size)).reduce((id, byte) => {
22
- byte &= 63
23
- if (byte < 36) {
24
- id += byte.toString(36)
25
- } else if (byte < 62) {
26
- id += (byte - 26).toString(36).toUpperCase()
27
- } else if (byte > 62) {
28
- id += '-'
29
- } else {
30
- id += '_'
31
- }
32
- return id
33
- }, '')
34
- export { nanoid, customAlphabet, customRandom, urlAlphabet, random }
@@ -1,86 +0,0 @@
1
- let crypto = require('crypto')
2
-
3
- let { urlAlphabet } = require('./url-alphabet/index.cjs')
4
-
5
- // It is best to make fewer, larger requests to the crypto module to
6
- // avoid system call overhead. So, random numbers are generated in a
7
- // pool. The pool is a Buffer that is larger than the initial random
8
- // request size by this multiplier. The pool is enlarged if subsequent
9
- // requests exceed the maximum buffer size.
10
- const POOL_SIZE_MULTIPLIER = 128
11
- let pool, poolOffset
12
-
13
- let fillPool = bytes => {
14
- if (bytes < 0 || bytes > 1024) throw new RangeError('Wrong ID size')
15
- if (!pool || pool.length < bytes) {
16
- pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
17
- crypto.randomFillSync(pool)
18
- poolOffset = 0
19
- } else if (poolOffset + bytes > pool.length) {
20
- crypto.randomFillSync(pool)
21
- poolOffset = 0
22
- }
23
- poolOffset += bytes
24
- }
25
-
26
- let random = bytes => {
27
- // `|=` convert `bytes` to number to prevent `valueOf` abusing and pool pollution
28
- fillPool((bytes |= 0))
29
- return pool.subarray(poolOffset - bytes, poolOffset)
30
- }
31
-
32
- let customRandom = (alphabet, defaultSize, getRandom) => {
33
- // First, a bitmask is necessary to generate the ID. The bitmask makes bytes
34
- // values closer to the alphabet size. The bitmask calculates the closest
35
- // `2^31 - 1` number, which exceeds the alphabet size.
36
- // For example, the bitmask for the alphabet size 30 is 31 (00011111).
37
- let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
38
- // Though, the bitmask solution is not perfect since the bytes exceeding
39
- // the alphabet size are refused. Therefore, to reliably generate the ID,
40
- // the random bytes redundancy has to be satisfied.
41
-
42
- // Note: every hardware random generator call is performance expensive,
43
- // because the system call for entropy collection takes a lot of time.
44
- // So, to avoid additional system calls, extra bytes are requested in advance.
45
-
46
- // Next, a step determines how many random bytes to generate.
47
- // The number of random bytes gets decided upon the ID size, mask,
48
- // alphabet size, and magic number 1.6 (using 1.6 peaks at performance
49
- // according to benchmarks).
50
- let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
51
-
52
- return (size = defaultSize) => {
53
- let id = ''
54
- while (true) {
55
- let bytes = getRandom(step)
56
- // A compact alternative for `for (let i = 0; i < step; i++)`.
57
- let i = step
58
- while (i--) {
59
- // Adding `|| ''` refuses a random byte that exceeds the alphabet size.
60
- id += alphabet[bytes[i] & mask] || ''
61
- if (id.length === size) return id
62
- }
63
- }
64
- }
65
- }
66
-
67
- let customAlphabet = (alphabet, size = 21) =>
68
- customRandom(alphabet, size, random)
69
-
70
- let nanoid = (size = 21) => {
71
- // `|=` convert `size` to number to prevent `valueOf` abusing and pool pollution
72
- fillPool((size |= 0))
73
- let id = ''
74
- // We are reading directly from the random pool to avoid creating new array
75
- for (let i = poolOffset - size; i < poolOffset; i++) {
76
- // It is incorrect to use bytes exceeding the alphabet size.
77
- // The following mask reduces the random byte in the 0-255 value
78
- // range to the 0-63 value range. Therefore, adding hacks, such
79
- // as empty string fallback or magic numbers, is unneccessary because
80
- // the bitmask trims bytes down to the alphabet size.
81
- id += urlAlphabet[pool[i] & 63]
82
- }
83
- return id
84
- }
85
-
86
- module.exports = { nanoid, customAlphabet, customRandom, urlAlphabet, random }