ranuts 0.4.1-alpha.2 → 0.5.1
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.
- package/CLAUDE.md +23 -16
- package/README.de.md +62 -0
- package/README.es.md +62 -0
- package/README.fa.md +62 -0
- package/README.ja.md +62 -0
- package/README.ko.md +62 -0
- package/README.md +35 -92
- package/README.pt.md +62 -0
- package/README.zh-CN.md +35 -91
- package/dist/iife/index.iife.js +4 -0
- package/dist/iife/utils.iife.js +4 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +307 -1
- package/dist/src/_virtual/_rolldown/runtime/index.js +12 -0
- package/dist/src/conversation/engine.d.ts +1 -1
- package/dist/src/conversation/engine.js +101 -0
- package/dist/src/conversation/index.d.ts +3 -3
- package/dist/src/conversation/index.js +4 -1
- package/dist/src/stream/accumulator.d.ts +1 -1
- package/dist/src/stream/accumulator.js +79 -0
- package/dist/src/stream/budget.d.ts +1 -1
- package/dist/src/stream/budget.js +45 -0
- package/dist/src/stream/index.d.ts +7 -7
- package/dist/src/stream/index.js +11 -1
- package/dist/src/stream/sse.d.ts +1 -1
- package/dist/src/stream/sse.js +61 -0
- package/dist/src/sw/index.js +52 -1
- package/dist/src/utils/async.js +49 -0
- package/dist/src/utils/audioRecorder.js +1121 -0
- package/dist/src/utils/behavior.js +9 -0
- package/dist/src/utils/binary.js +89 -0
- package/dist/src/utils/bom.d.ts +31 -9
- package/dist/src/utils/bom.js +165 -0
- package/dist/src/utils/bridge.js +310 -0
- package/dist/src/utils/canvas.js +103 -0
- package/dist/src/utils/chain.js +76 -0
- package/dist/src/utils/charset.d.ts +15 -0
- package/dist/src/utils/charset.js +21 -0
- package/dist/src/utils/color.d.ts +0 -1
- package/dist/src/utils/color.js +312 -0
- package/dist/src/utils/compose.js +22 -0
- package/dist/src/utils/console.js +22 -0
- package/dist/src/utils/debounce.js +18 -0
- package/dist/src/utils/device.d.ts +0 -9
- package/dist/src/utils/device.js +31 -0
- package/dist/src/utils/diff.js +110 -0
- package/dist/src/utils/dom.d.ts +1 -1
- package/dist/src/utils/dom.js +89 -0
- package/dist/src/utils/error.js +11 -0
- package/dist/src/utils/event.d.ts +3 -3
- package/dist/src/utils/event.js +39 -0
- package/dist/src/utils/file.js +14 -0
- package/dist/src/utils/func.js +4 -0
- package/dist/src/utils/i18n/index.js +79 -1
- package/dist/src/utils/idb.js +177 -0
- package/dist/src/utils/img.d.ts +1 -1
- package/dist/src/utils/img.js +68 -0
- package/dist/src/utils/index.d.ts +82 -80
- package/dist/src/utils/index.js +307 -1
- package/dist/src/utils/lang.d.ts +23 -6
- package/dist/src/utils/lang.js +42 -0
- package/dist/src/utils/localePath.js +48 -0
- package/dist/src/utils/memoize.d.ts +1 -7
- package/dist/src/utils/memoize.js +16 -0
- package/dist/src/utils/mimeType.js +841 -0
- package/dist/src/utils/monitor.js +84 -0
- package/dist/src/utils/network.js +117 -0
- package/dist/src/utils/noop.js +5 -0
- package/dist/src/utils/number.js +185 -0
- package/dist/src/utils/obj.d.ts +2 -2
- package/dist/src/utils/obj.js +140 -0
- package/dist/src/utils/paginate.js +93 -0
- package/dist/src/utils/performance.js +26 -0
- package/dist/src/utils/placement.js +37 -0
- package/dist/src/utils/prefetch.js +69 -0
- package/dist/src/utils/queue.js +46 -0
- package/dist/src/utils/report.js +44 -0
- package/dist/src/utils/request.js +35 -0
- package/dist/src/utils/script.d.ts +4 -2
- package/dist/src/utils/script.js +45 -0
- package/dist/src/utils/scroll.d.ts +2 -0
- package/dist/src/utils/scroll.js +62 -0
- package/dist/src/utils/secure.js +36 -0
- package/dist/src/utils/segment.js +43 -0
- package/dist/src/utils/signal.d.ts +1 -1
- package/dist/src/utils/signal.js +13 -0
- package/dist/src/utils/speech.js +59 -0
- package/dist/src/utils/storage.js +53 -0
- package/dist/src/utils/str.d.ts +0 -21
- package/dist/src/utils/str.js +377 -0
- package/dist/src/utils/style.js +29 -0
- package/dist/src/utils/subscribe.js +58 -0
- package/dist/src/utils/throttle.js +17 -0
- package/dist/src/utils/time.d.ts +0 -21
- package/dist/src/utils/time.js +97 -0
- package/dist/src/utils/totp/sha/common.d.ts +1 -1
- package/dist/src/utils/totp/sha/common.js +201 -0
- package/dist/src/utils/totp/sha/converters.d.ts +1 -1
- package/dist/src/utils/totp/sha/converters.js +188 -0
- package/dist/src/utils/totp/sha/primitives_32.js +55 -0
- package/dist/src/utils/totp/sha/primitives_64.js +85 -0
- package/dist/src/utils/totp/sha/sha.d.ts +1 -1
- package/dist/src/utils/totp/sha/sha.js +30 -0
- package/dist/src/utils/totp/sha/sha1.d.ts +2 -2
- package/dist/src/utils/totp/sha/sha1.js +51 -0
- package/dist/src/utils/totp/sha/sha256.d.ts +2 -2
- package/dist/src/utils/totp/sha/sha256.js +56 -0
- package/dist/src/utils/totp/sha/sha3.d.ts +3 -3
- package/dist/src/utils/totp/sha/sha3.js +253 -0
- package/dist/src/utils/totp/sha/sha512.d.ts +3 -3
- package/dist/src/utils/totp/sha/sha512.js +177 -0
- package/dist/src/utils/totp/totp.js +49 -0
- package/dist/src/utils/tween.js +59 -0
- package/dist/src/utils/visual/application.d.ts +4 -4
- package/dist/src/utils/visual/application.js +42 -0
- package/dist/src/utils/visual/enums.js +19 -0
- package/dist/src/utils/visual/event/boundary.d.ts +2 -2
- package/dist/src/utils/visual/event/boundary.js +93 -0
- package/dist/src/utils/visual/event/event.d.ts +1 -1
- package/dist/src/utils/visual/event/event.js +34 -0
- package/dist/src/utils/visual/event/index.d.ts +4 -4
- package/dist/src/utils/visual/event/types.d.ts +2 -2
- package/dist/src/utils/visual/event/types.js +23 -0
- package/dist/src/utils/visual/graphics/graphics.d.ts +8 -8
- package/dist/src/utils/visual/graphics/graphics.js +168 -0
- package/dist/src/utils/visual/graphics/graphicsData.d.ts +3 -3
- package/dist/src/utils/visual/graphics/graphicsData.js +12 -0
- package/dist/src/utils/visual/graphics/graphicsGeometry.d.ts +7 -7
- package/dist/src/utils/visual/graphics/graphicsGeometry.js +39 -0
- package/dist/src/utils/visual/graphics/index.d.ts +3 -3
- package/dist/src/utils/visual/index.d.ts +8 -8
- package/dist/src/utils/visual/index.js +20 -1
- package/dist/src/utils/visual/math/bezier.js +15 -0
- package/dist/src/utils/visual/math/enums.js +6 -0
- package/dist/src/utils/visual/math/index.d.ts +4 -4
- package/dist/src/utils/visual/math/matrix.d.ts +1 -1
- package/dist/src/utils/visual/math/matrix.js +59 -0
- package/dist/src/utils/visual/math/transform.d.ts +2 -2
- package/dist/src/utils/visual/math/transform.js +50 -0
- package/dist/src/utils/visual/render/batchRenderer.d.ts +4 -4
- package/dist/src/utils/visual/render/batchRenderer.js +59 -0
- package/dist/src/utils/visual/render/canvasRenderer.d.ts +3 -3
- package/dist/src/utils/visual/render/canvasRenderer.js +17 -0
- package/dist/src/utils/visual/render/filter.d.ts +1 -1
- package/dist/src/utils/visual/render/filter.js +92 -0
- package/dist/src/utils/visual/render/index.d.ts +2 -2
- package/dist/src/utils/visual/render/index.js +20 -0
- package/dist/src/utils/visual/render/render.d.ts +4 -4
- package/dist/src/utils/visual/render/render.js +19 -0
- package/dist/src/utils/visual/render/renderTarget.js +28 -0
- package/dist/src/utils/visual/render/utils/batch/index.d.ts +4 -4
- package/dist/src/utils/visual/render/utils/batch/index.js +88 -0
- package/dist/src/utils/visual/render/utils/earcut.js +328 -0
- package/dist/src/utils/visual/render/utils/float.js +65 -0
- package/dist/src/utils/visual/render/utils/index.js +50 -0
- package/dist/src/utils/visual/render/utils/verticy.d.ts +2 -2
- package/dist/src/utils/visual/render/utils/verticy.js +162 -0
- package/dist/src/utils/visual/render/utils/webgl/initShader.d.ts +1 -1
- package/dist/src/utils/visual/render/utils/webgl/initShader.js +31 -0
- package/dist/src/utils/visual/render/utils/webgl/shaders.js +22 -0
- package/dist/src/utils/visual/render/utils/webgpu/shaders.js +32 -0
- package/dist/src/utils/visual/render/webGPURenderer.d.ts +2 -2
- package/dist/src/utils/visual/render/webGPURenderer.js +185 -0
- package/dist/src/utils/visual/render/webGlRenderer.d.ts +2 -2
- package/dist/src/utils/visual/render/webGlRenderer.js +88 -0
- package/dist/src/utils/visual/shape/circle.d.ts +3 -3
- package/dist/src/utils/visual/shape/circle.js +17 -0
- package/dist/src/utils/visual/shape/ellipse.d.ts +3 -3
- package/dist/src/utils/visual/shape/ellipse.js +18 -0
- package/dist/src/utils/visual/shape/index.d.ts +6 -6
- package/dist/src/utils/visual/shape/polygon.d.ts +3 -3
- package/dist/src/utils/visual/shape/polygon.js +29 -0
- package/dist/src/utils/visual/shape/rectangle.d.ts +3 -3
- package/dist/src/utils/visual/shape/rectangle.js +18 -0
- package/dist/src/utils/visual/shape/roundedRectangle.d.ts +3 -3
- package/dist/src/utils/visual/shape/roundedRectangle.js +32 -0
- package/dist/src/utils/visual/shape/shape.d.ts +2 -2
- package/dist/src/utils/visual/shape/shape.js +5 -0
- package/dist/src/utils/visual/style/fill.js +18 -0
- package/dist/src/utils/visual/style/index.d.ts +2 -2
- package/dist/src/utils/visual/style/line.d.ts +2 -2
- package/dist/src/utils/visual/style/line.js +18 -0
- package/dist/src/utils/visual/types.d.ts +1 -1
- package/dist/src/utils/visual/vertex/container.d.ts +5 -5
- package/dist/src/utils/visual/vertex/container.js +54 -0
- package/dist/src/utils/visual/vertex/point.js +37 -0
- package/dist/src/utils/visual/vertex/vertex.d.ts +7 -7
- package/dist/src/utils/visual/vertex/vertex.js +76 -0
- package/dist/src/utils/worker.js +89 -0
- package/dist/src/utils/zip.js +161 -0
- package/dist/src/vnode/h.d.ts +1 -1
- package/dist/src/vnode/h.js +22 -0
- package/dist/src/vnode/hooks.d.ts +1 -1
- package/dist/src/vnode/htmlDomApi.js +94 -0
- package/dist/src/vnode/index.d.ts +16 -16
- package/dist/src/vnode/index.js +28 -1
- package/dist/src/vnode/init.d.ts +1 -1
- package/dist/src/vnode/init.js +104 -0
- package/dist/src/vnode/is.d.ts +1 -1
- package/dist/src/vnode/is.js +20 -0
- package/dist/src/vnode/modules/attributes.d.ts +1 -1
- package/dist/src/vnode/modules/attributes.js +21 -0
- package/dist/src/vnode/modules/class.d.ts +1 -1
- package/dist/src/vnode/modules/class.js +18 -0
- package/dist/src/vnode/modules/index.js +15 -0
- package/dist/src/vnode/modules/listeners.d.ts +1 -1
- package/dist/src/vnode/modules/listeners.js +36 -0
- package/dist/src/vnode/modules/props.d.ts +1 -1
- package/dist/src/vnode/modules/props.js +17 -0
- package/dist/src/vnode/modules/style.d.ts +1 -1
- package/dist/src/vnode/modules/style.js +52 -0
- package/dist/src/vnode/vnode.d.ts +6 -6
- package/dist/src/vnode/vnode.js +13 -0
- package/dist/third-party/jschardet/LICENSE.txt +504 -0
- package/dist/third-party/jschardet/NOTICE.txt +33 -0
- package/docs/API.md +8 -64
- package/package.json +14 -18
- package/dist/bin/generate-api-docs.d.ts +0 -1
- package/dist/build/build.es.d.ts +0 -2
- package/dist/build/build.umd.d.ts +0 -2
- package/dist/build/build.umd.node.d.ts +0 -2
- package/dist/build/build.umd.utils.d.ts +0 -2
- package/dist/chain-CTywmh_H.js +0 -1
- package/dist/color-BTvZUuf-.js +0 -1
- package/dist/enums-BAgbyGdH.js +0 -1
- package/dist/examples/clone-deep-example.d.ts +0 -1
- package/dist/examples/is-equal-example.d.ts +0 -1
- package/dist/i18n-DW21b_DJ.js +0 -1
- package/dist/plugins/vite-plugins-banner.d.ts +0 -2
- package/dist/rolldown-runtime-I3TIJKkN.js +0 -1
- package/dist/src/node/appendFile.d.ts +0 -7
- package/dist/src/node/body.d.ts +0 -9
- package/dist/src/node/color.d.ts +0 -7
- package/dist/src/node/command.d.ts +0 -8
- package/dist/src/node/ctx2req.d.ts +0 -5
- package/dist/src/node/fileInfo.d.ts +0 -7
- package/dist/src/node/fs.d.ts +0 -7
- package/dist/src/node/get.d.ts +0 -10
- package/dist/src/node/getIPAdress.d.ts +0 -1
- package/dist/src/node/index.d.ts +0 -25
- package/dist/src/node/index.js +0 -1
- package/dist/src/node/isColorSupported.d.ts +0 -2
- package/dist/src/node/paresUrl.d.ts +0 -19
- package/dist/src/node/readDir.d.ts +0 -6
- package/dist/src/node/readFile.d.ts +0 -9
- package/dist/src/node/router.d.ts +0 -42
- package/dist/src/node/send.d.ts +0 -7
- package/dist/src/node/server.d.ts +0 -18
- package/dist/src/node/startTask.d.ts +0 -2
- package/dist/src/node/stream.d.ts +0 -15
- package/dist/src/node/taskEnd.d.ts +0 -2
- package/dist/src/node/traverse.d.ts +0 -17
- package/dist/src/node/watchFile.d.ts +0 -8
- package/dist/src/node/writeFile.d.ts +0 -8
- package/dist/src/node/ws.d.ts +0 -8
- package/dist/src/utils/visual/render/utils/batch/index.test.d.ts +0 -1
- package/dist/src/utils/visual/render/utils/index.test.d.ts +0 -1
- package/dist/test/binary.test.d.ts +0 -1
- package/dist/test/bridge.test.d.ts +0 -1
- package/dist/test/budget.test.d.ts +0 -1
- package/dist/test/canvas.test.d.ts +0 -1
- package/dist/test/clearBr.test.d.ts +0 -1
- package/dist/test/cloneDeep.test.d.ts +0 -1
- package/dist/test/color.test.d.ts +0 -1
- package/dist/test/command.test.d.ts +0 -1
- package/dist/test/conversation.test.d.ts +0 -1
- package/dist/test/diff.test.d.ts +0 -1
- package/dist/test/encodeUrl.test.d.ts +0 -1
- package/dist/test/escapeHtml.test.d.ts +0 -1
- package/dist/test/formatBytes.test.d.ts +0 -1
- package/dist/test/is-equal.test.d.ts +0 -1
- package/dist/test/mimeType.test.d.ts +0 -1
- package/dist/test/package-exports.test.d.ts +0 -1
- package/dist/test/scroll.test.d.ts +0 -1
- package/dist/test/server.test.d.ts +0 -1
- package/dist/test/status.test.d.ts +0 -1
- package/dist/test/stream.test.d.ts +0 -1
- package/dist/test/sw.test.d.ts +0 -1
- package/dist/test/totp.test.d.ts +0 -1
- package/dist/test/tween.test.d.ts +0 -1
- package/dist/test/utils/async.test.d.ts +0 -1
- package/dist/test/utils/autosize.test.d.ts +0 -1
- package/dist/test/utils/color-grade.test.d.ts +0 -1
- package/dist/test/utils/compose.test.d.ts +0 -1
- package/dist/test/utils/event.test.d.ts +0 -1
- package/dist/test/utils/file-read.test.d.ts +0 -1
- package/dist/test/utils/format.test.d.ts +0 -1
- package/dist/test/utils/i18n.test.d.ts +0 -1
- package/dist/test/utils/idb-collection.test.d.ts +0 -1
- package/dist/test/utils/idb.test.d.ts +0 -1
- package/dist/test/utils/instrumentation.test.d.ts +0 -1
- package/dist/test/utils/interp.test.d.ts +0 -1
- package/dist/test/utils/lang.test.d.ts +0 -1
- package/dist/test/utils/locale-path.test.d.ts +0 -1
- package/dist/test/utils/media-query.test.d.ts +0 -1
- package/dist/test/utils/mergeObj.test.d.ts +0 -1
- package/dist/test/utils/number-parse.test.d.ts +0 -1
- package/dist/test/utils/paginate.test.d.ts +0 -1
- package/dist/test/utils/placement.test.d.ts +0 -1
- package/dist/test/utils/prefetch.test.d.ts +0 -1
- package/dist/test/utils/query-storage.test.d.ts +0 -1
- package/dist/test/utils/queue.test.d.ts +0 -1
- package/dist/test/utils/report-config.test.d.ts +0 -1
- package/dist/test/utils/report-image.test.d.ts +0 -1
- package/dist/test/utils/secure.test.d.ts +0 -1
- package/dist/test/utils/segment.test.d.ts +0 -1
- package/dist/test/utils/signal-once.test.d.ts +0 -1
- package/dist/test/utils/single-flight.test.d.ts +0 -1
- package/dist/test/utils/speech.test.d.ts +0 -1
- package/dist/test/utils/text-boundary.test.d.ts +0 -1
- package/dist/test/utils/time.test.d.ts +0 -1
- package/dist/test/utils/timing.test.d.ts +0 -1
- package/dist/test/utils/truncate.test.d.ts +0 -1
- package/dist/test/utils/visual/filter.test.d.ts +0 -1
- package/dist/test/utils/worker-client.test.d.ts +0 -1
- package/dist/test/utils/worker-serve.test.d.ts +0 -1
- package/dist/test/utils/zip.test.d.ts +0 -1
- package/dist/test/visual/math.test.d.ts +0 -1
- package/dist/test/visual-application.test.d.ts +0 -1
- package/dist/test/visual-batch.test.d.ts +0 -1
- package/dist/test/visual-math.test.d.ts +0 -1
- package/dist/test/vnode/index.d.ts +0 -1
- package/dist/test/vnode/server.d.ts +0 -2
- package/dist/test/vnode/vnode.d.ts +0 -1
- package/dist/test/vnode.test.d.ts +0 -1
- package/dist/test/websocket.test.d.ts +0 -1
- package/dist/test/writeFile.test.d.ts +0 -1
- package/dist/umd/index.umd.cjs +0 -1
- package/dist/umd/node/node.umd.cjs +0 -1
- package/dist/umd/utils/utils.umd.cjs +0 -1
- package/dist/utils-B4FnyUzW.js +0 -1
- package/dist/vite.config.d.ts +0 -8
- package/dist/vitest.config.d.ts +0 -2
package/docs/API.md
CHANGED
|
@@ -8,13 +8,12 @@ constraints, conventions) read [../CLAUDE.md](../CLAUDE.md) first.
|
|
|
8
8
|
Import from the **subpath** that owns the symbol, e.g. `import { debounce } from
|
|
9
9
|
'ranuts/utils'`. The root `ranuts` barrel re-exports the utils + visual surface.
|
|
10
10
|
|
|
11
|
-
**
|
|
11
|
+
**422 exports** across 7 entry points.
|
|
12
12
|
|
|
13
13
|
## Entry points
|
|
14
14
|
|
|
15
|
-
- [`ranuts/utils`](#ranuts-utils) — Browser and general-purpose utilities · _browser + node_ ·
|
|
15
|
+
- [`ranuts/utils`](#ranuts-utils) — Browser and general-purpose utilities · _browser + node_ · 333 exports
|
|
16
16
|
- [`ranuts/sw`](#ranuts-sw) — Service Worker caching strategies and the precache protocol · _service worker only_ · 9 exports
|
|
17
|
-
- [`ranuts/node`](#ranuts-node) — Node server utilities (fs / http / ws / middleware) · _node only_ · 26 exports
|
|
18
17
|
- [`ranuts/visual`](#ranuts-visual) — 2D rendering engine (Canvas / WebGL / WebGPU) · _browser only_ · 16 exports
|
|
19
18
|
- [`ranuts/i18n`](#ranuts-i18n) — Framework-agnostic i18n engine (also re-exported from ranuts/utils) · _browser + node_ · 9 exports
|
|
20
19
|
- [`ranuts/vnode`](#ranuts-vnode) — Snabbdom-style virtual DOM · _browser_ · 26 exports
|
|
@@ -58,7 +57,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
58
57
|
- `compose<T>(middleware: Array<Middleware<T>>) => ComposedMiddleware<T>` — Run a chain of async functions as if it were sequential
|
|
59
58
|
- `computePlacement(options: ComputePlacementOptions) => ComputedPlacement` — Position a floating panel relative to an anchor rect: flips to the opposite
|
|
60
59
|
- `concatBytes(chunks: readonly Uint8Array[]) => Uint8Array` — Join byte chunks into one buffer, in order.
|
|
61
|
-
- `connection() =>
|
|
60
|
+
- `connection() => NetworkInformation | undefined` — Current network status: type, throughput, and whether the connection changed
|
|
62
61
|
- `convertImageToBase64(file: File) => Promise<convertImageToBase64Return>` — Convert an image to base64
|
|
63
62
|
- `cosinePalette(t: number, a: RGB, b: RGB, c: RGB, d: RGB) => RGB` — Inigo Quilez cosine gradient palette: `a + b * cos(2π(c·t + d))`. Each of `a,b,c,d` is an RGB triple; `t` is the position 0..1. Returns an RGB triple.
|
|
64
63
|
- `crc32(data: Uint8Array) => number` — CRC32 checksum (IEEE 802.3 polynomial), the one ZIP stores per entry.
|
|
@@ -70,7 +69,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
70
69
|
- `createHandoff<T>({ dbName, storeName, key }: HandoffOptions) => Handoff<T>` — A one-shot value handoff between two pages of the same origin, backed by
|
|
71
70
|
- `createI18n<TDict extends StringValues<TDict> = MessageDict>(config?: I18nConfig<TDict>) => I18nCore<TDict>` — Create and register the global i18n singleton.
|
|
72
71
|
- `createLocalePath(config: LocalePathConfig) => LocalePath` — Create the set of locale path conversion functions.
|
|
73
|
-
- `createObjectURL(src: Blob | ArrayBuffer | Response) => Promise<string>`
|
|
72
|
+
- `createObjectURL(src: string | Blob | ArrayBuffer | Response) => Promise<string>`
|
|
74
73
|
- `createPortBridge(port: MessagePort) => PortBridge` — Build a bridge on any MessagePort (a Web Worker, a SharedWorker, or a port from a completed handshake).
|
|
75
74
|
- `createRaceGuard() => RaceGuard` — Bump-and-compare guard against a stale async response overwriting a newer
|
|
76
75
|
- `createSignal<T = unknown>(value: T, options?: SignalOptions<T>) => [() => T, (newValue: T) => void]` — Create a minimal signal with optional event broadcasting, returned as
|
|
@@ -84,7 +83,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
84
83
|
- `decodeTextBytes(bytes: Uint8Array, encodings?: string[]) => string` — Decode text bytes, trying encodings in order until one holds.
|
|
85
84
|
- `deferred<T = void>() => Deferred<T>` — A promise plus its `resolve` / `reject`, for the case where the thing that
|
|
86
85
|
- `delay(ms: number) => Promise<void>` — Resolve after `ms` milliseconds. Uses the bare `setTimeout`, so it works in
|
|
87
|
-
- `detectLanguage(text: string, sampleSize?: number) => TextLanguage` — Decide a text's primary
|
|
86
|
+
- `detectLanguage(text: string, sampleSize?: number) => TextLanguage` — Decide a text's primary script from character ratios. Pure statistics, no
|
|
88
87
|
- `diffLines(oldText: string, newText: string, options?: DiffOptions) => DiffHunk[]` — Diffs two texts by line.
|
|
89
88
|
- `durationHandler<T, U>(handler: (...args: T[]) => U, ...params: T[]) => ((a: number) => Promise<U>)` — Run a function repeatedly at a fixed interval
|
|
90
89
|
- `encodeUrl(url: string) => string` — Encode a URL to a percent-encoded form, excluding already-encoded sequences.
|
|
@@ -92,7 +91,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
92
91
|
- `fanShapedByArc(ctx: CanvasRenderingContext2D, maxRadius: number, start: number, end: number, gutter: number) => void` — Trace a pie slice with arc(), including the gutter between slices.
|
|
93
92
|
- `fenceCode(body: string, lang?: string) => string` — Wrap text in a Markdown code fence long enough to survive backticks inside it.
|
|
94
93
|
- `fetchMaybeGzip(input: RequestInfo | URL, init?: RequestInit) => Promise<Uint8Array>` — Fetch a resource that may be delivered gzipped or already
|
|
95
|
-
- `filterObj(obj: Record<string, unknown>, list: Array<string>) => Record<string, unknown>` — Return a new object without the
|
|
94
|
+
- `filterObj(obj: Record<string, unknown>, list: Array<string>) => Record<string, unknown>` — Return a new object without the listed keys — typically used to drop fields before sending an object on
|
|
96
95
|
- `fit(value: number, a1: number, a2: number, b1: number, b2: number) => number` — Remap `value` from `[a1, a2]` onto `[b1, b2]` and clamp to the output range — the shader `fit`.
|
|
97
96
|
- `formatBytes(bytes: number) => string` — Format a byte count for a person to read.
|
|
98
97
|
- `formatDate(value?: DateInput, pattern?: string) => string` — Format a date with a token pattern. Accepts a timestamp, a date string, a
|
|
@@ -161,8 +160,6 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
161
160
|
- `luma(r: number, g: number, b: number) => number` — Perceived brightness (luma) of an RGB colour using Rec. 601 weights. Channels may be 0..1 or 0..255 — the result keeps that scale.
|
|
162
161
|
- `matchMediaQuery(query: string) => boolean` — Read whether a media query currently matches, synchronously. Returns false under SSR.
|
|
163
162
|
- `mathjs(a: number, type: string, b: number) => ComputeNumberResult`
|
|
164
|
-
- `md5(str: string) => string` — MD5 hash function implementation
|
|
165
|
-
- `memoize<T extends Func>(fn: T | unknown) => ((...args: Parameters<T>) => ReturnType<T>)` — Former name of `once`. The name is misleading — it does not cache per
|
|
166
163
|
- `merge(a: Obj, b?: Obj) => Obj` — Merge objects
|
|
167
164
|
- `mergeExports(obj: Record<string, string>, exports: Record<string, string>) => Record<string, string>` — Copy an exports object onto `obj`, then freeze it
|
|
168
165
|
- `navigatorLanguage() => TextLanguage` — Map the browser UI language into the same buckets (the default when there is
|
|
@@ -198,7 +195,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
198
195
|
- `removeClassToElement(element: Element, removeClass: string) => void` — Remove a class from an element
|
|
199
196
|
- `replaceOld(source: any, name: string, replacement: (...args: unknown[]) => unknown, isForced?: boolean) => () => void` — Replace a property on an object, wrapping whatever was there before.
|
|
200
197
|
- `report({ url, type, payload }: BeaconPayload) => boolean` — Send a telemetry beacon. Prefers `navigator.sendBeacon` (does not block
|
|
201
|
-
- `requestUrlToBuffer(src: string, options
|
|
198
|
+
- `requestUrlToBuffer{ (src: string, options?: Partial<RequestUrlToArraybufferOption<'' | 'arraybuffer'>>): Promise<requestUrlToArraybufferReturn>; <T extends XML… (+2 overloads)` — Fetch a URL as an ArrayBuffer by default, or as the requested XHR response type
|
|
202
199
|
- `resolveLocale(options: ResolveLocaleOptions) => string` — Resolve which of your supported locales to use, from the usual chain:
|
|
203
200
|
- `rewriteZip(bytes: Uint8Array, options?: RewriteZipOptions) => Promise<Uint8Array>` — Rebuild an archive with some entries replaced and/or new entries appended.
|
|
204
201
|
- `rgbaString(r: number, g: number, b: number, a: number) => string` — Build a CSS `rgba()` string. Alpha is 0–100 rather than 0–1, matching the
|
|
@@ -226,8 +223,6 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
226
223
|
- `srgbToLinear(c: number) => number` — Convert one sRGB channel (0..1) to linear-light (IEC 61966-2-1 transfer function).
|
|
227
224
|
- `strParse(str?: string, sep?: string | RegExp, eq?: string | RegExp) => Record<string, string>` — Parse a delimited string into an object, e.g.
|
|
228
225
|
- `throttle<T extends (...args: any[]) => any>(fn: T, delay?: number) => Throttled<T>` — Throttle — under a burst of calls, run at a fixed interval: the first call
|
|
229
|
-
- `timeFormat(time: number) => string` — Format a number of seconds as a colon-separated duration
|
|
230
|
-
- `timestampToTime(timestamp?: number | string) => Date & { format?: Function; }` — Turn a timestamp into a `Date` carrying a `format` method.
|
|
231
226
|
- `toFullWidth(value: string) => string` — Convert half-width characters to full-width (the inverse of `toHalfWidth`)
|
|
232
227
|
- `toHalfWidth(value: string) => string` — Convert full-width characters to half-width (digits, letters, punctuation and
|
|
233
228
|
- `toString(value: string | number) => string`
|
|
@@ -349,7 +344,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
349
344
|
- `type RGB` — An RGB triple with each channel in 0..1 (linear or sRGB depending on the operation).
|
|
350
345
|
- `type SpeechErrorKind` — `denied` means the user or the browser refused the microphone — worth surfacing.
|
|
351
346
|
- `type StringValues` — "An object whose values are all strings" — the constraint the dictionary type parameter
|
|
352
|
-
- `type TextLanguage` — Coarse
|
|
347
|
+
- `type TextLanguage` — Coarse script bucket: the four writing systems that need different handling, plus
|
|
353
348
|
- `type TranslateParams`
|
|
354
349
|
- `type TruncatePosition` — Which end of the string gets dropped when it is too long.
|
|
355
350
|
|
|
@@ -364,9 +359,7 @@ import { /* … */ } from 'ranuts/utils';
|
|
|
364
359
|
- `const cubic: SpeedType`
|
|
365
360
|
- `const DEFAULT_CHANNEL: "default"`
|
|
366
361
|
- `const expo: SpeedType`
|
|
367
|
-
- `const FMT: Record<string, string[]>`
|
|
368
362
|
- `const HEX_COLOR_REGEX: RegExp` — `#rgb` / `#rrggbb` (the `#` is required)
|
|
369
|
-
- `const isClient: boolean` — Whether a `window` existed **when this module was first imported**.
|
|
370
363
|
- `const MessageCodec: { encode(data: any): string; decode<T = any>(encodedStr: string): T | null; encodeFile(file: File): Promise<string>; decodeFile(encoded: st…` — Message codec.
|
|
371
364
|
- `const MimeType: Map<string, string>`
|
|
372
365
|
- `const MOBILE_MEDIA_QUERY: "(max-width: 768px)"` — Viewport breakpoint, matching where the mobile layout takes over
|
|
@@ -406,55 +399,6 @@ import { /* … */ } from 'ranuts/sw';
|
|
|
406
399
|
- `interface ServePrecacheOptions`
|
|
407
400
|
- `interface SWScope` — Minimal view of the SW global the helpers touch, so they can be unit-tested with a stub.
|
|
408
401
|
|
|
409
|
-
## `ranuts/node`
|
|
410
|
-
|
|
411
|
-
Node server utilities (fs / http / ws / middleware) · runtime: **node only** · source: `src/node/index.ts`
|
|
412
|
-
|
|
413
|
-
```ts
|
|
414
|
-
import { /* … */ } from 'ranuts/node';
|
|
415
|
-
```
|
|
416
|
-
|
|
417
|
-
### Functions
|
|
418
|
-
|
|
419
|
-
- `appendFile(path: string, content: string) => Promise<Ranuts.Identification>` — Append content to an existing file
|
|
420
|
-
- `bodyMiddleware(options?: Partial<ServerBody>) => MiddlewareFunction`
|
|
421
|
-
- `connect(connectMiddleware: ConnectMiddleware) => MiddlewareFunction`
|
|
422
|
-
- `get({ url }: Request) => Promise<Response>`
|
|
423
|
-
- `getIPAdress() => string | undefined`
|
|
424
|
-
- `default(req: Req) => ParseUrl | undefined` — Parse an IncomingMessage's request URL; the return type is always ParseUrl
|
|
425
|
-
- `prompt({ message, stream, defaultResponse }: PromptOption) => Promise<boolean>`
|
|
426
|
-
- `queryFileInfo(path: string) => Promise<Ranuts.Identification>` — Stat a file — typically to tell a file from a directory via data.isDirectory()
|
|
427
|
-
- `readDir(options: Options) => Array<string>`
|
|
428
|
-
- `readFile(path: string, format?: BufferEncoding) => FilePromiseResult` — Read a file, returning a status code and the content on success
|
|
429
|
-
- `readStream(option: ReadOption) => ReadStream`
|
|
430
|
-
- `runCommand(command: string, args: string[]) => Promise<void>`
|
|
431
|
-
- `startTask() => symbol`
|
|
432
|
-
- `staticMiddleware(option?: Partial<Option>) => MiddlewareFunction`
|
|
433
|
-
- `taskEnd(symbol: symbol) => number | bigint`
|
|
434
|
-
- `traverse(dir: string, callback: Caller, pre?: string) => Promise<any>` — Walk every directory recursively, running a function for each file found
|
|
435
|
-
- `traverseSync(dir: string, callback: Caller, pre?: string) => void` — Synchronous: walk every directory recursively, running a function for each file found
|
|
436
|
-
- `watchFile(path: string, interval?: number) => Promise<Ranuts.Identification>` — Watch a file for changes and report its status
|
|
437
|
-
- `writeFile(path: string, content: string) => Promise<Ranuts.Identification>` — Write a file at the given path, truncating it if it exists and creating it if it does not
|
|
438
|
-
- `writeStream(option: WriteOption) => WriteStream`
|
|
439
|
-
- `WSS(this: any, server: http.Server) => void` — Create a WebSocket Server
|
|
440
|
-
|
|
441
|
-
### Classes
|
|
442
|
-
|
|
443
|
-
- `class Router`
|
|
444
|
-
- `class Server`
|
|
445
|
-
|
|
446
|
-
### Interfaces
|
|
447
|
-
|
|
448
|
-
- `interface Context`
|
|
449
|
-
|
|
450
|
-
### Constants
|
|
451
|
-
|
|
452
|
-
- `const isColorSupported: boolean`
|
|
453
|
-
|
|
454
|
-
### Other
|
|
455
|
-
|
|
456
|
-
- `default`
|
|
457
|
-
|
|
458
402
|
## `ranuts/visual`
|
|
459
403
|
|
|
460
404
|
2D rendering engine (Canvas / WebGL / WebGPU) · runtime: **browser only** · source: `src/utils/visual/index.ts`
|
package/package.json
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ranuts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "Tree-shakeable TypeScript utility library: DOM/BOM helpers, string/object/number/color utils, debounce/throttle/compose, a 2D rendering engine and a virtual DOM.",
|
|
5
|
-
"main": "dist/
|
|
5
|
+
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"type": "module",
|
|
8
|
+
"sideEffects": [
|
|
9
|
+
"./dist/iife/**"
|
|
10
|
+
],
|
|
8
11
|
"types": "dist/index.d.ts",
|
|
9
12
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
13
|
+
"node": ">=24.0.0"
|
|
11
14
|
},
|
|
12
15
|
"exports": {
|
|
13
16
|
".": {
|
|
14
17
|
"types": "./dist/index.d.ts",
|
|
15
|
-
"import": "./dist/index.js"
|
|
16
|
-
"require": "./dist/umd/index.umd.cjs"
|
|
17
|
-
},
|
|
18
|
-
"./node": {
|
|
19
|
-
"types": "./dist/src/node/index.d.ts",
|
|
20
|
-
"import": "./dist/src/node/index.js",
|
|
21
|
-
"require": "./dist/umd/node/node.umd.cjs"
|
|
18
|
+
"import": "./dist/index.js"
|
|
22
19
|
},
|
|
23
20
|
"./utils": {
|
|
24
21
|
"types": "./dist/src/utils/index.d.ts",
|
|
25
|
-
"import": "./dist/src/utils/index.js"
|
|
26
|
-
"require": "./dist/umd/utils/utils.umd.cjs"
|
|
22
|
+
"import": "./dist/src/utils/index.js"
|
|
27
23
|
},
|
|
28
24
|
"./visual": {
|
|
29
25
|
"types": "./dist/src/utils/visual/index.d.ts",
|
|
@@ -97,14 +93,14 @@
|
|
|
97
93
|
"license": "MIT",
|
|
98
94
|
"devDependencies": {
|
|
99
95
|
"@types/node": "26.1.2",
|
|
100
|
-
"@vitest/coverage-v8": "4.1.
|
|
96
|
+
"@vitest/coverage-v8": "4.1.11",
|
|
101
97
|
"@webgpu/types": "0.1.71",
|
|
102
|
-
"jsdom": "
|
|
98
|
+
"jsdom": "30.0.1",
|
|
103
99
|
"terser": "5.49.2",
|
|
104
100
|
"tsx": "4.23.10",
|
|
105
101
|
"typescript": "7.0.2",
|
|
106
|
-
"vite": "8.2.
|
|
107
|
-
"vitest": "4.1.
|
|
102
|
+
"vite": "8.2.4",
|
|
103
|
+
"vitest": "4.1.11"
|
|
108
104
|
},
|
|
109
105
|
"dependencies": {
|
|
110
106
|
"jschardet": "3.1.4"
|
|
@@ -113,10 +109,10 @@
|
|
|
113
109
|
"build": "sh ./bin/build.sh",
|
|
114
110
|
"test": "vitest run",
|
|
115
111
|
"test:coverage": "vitest run --coverage",
|
|
112
|
+
"verify:package": "node bin/verify-package.ts",
|
|
116
113
|
"tsc": "tsc --noEmit",
|
|
117
114
|
"dev": "vite --host",
|
|
118
115
|
"doc:api": "tsx ./bin/generate-api-docs.ts",
|
|
119
|
-
"doc:api:check": "tsx ./bin/generate-api-docs.ts --check"
|
|
120
|
-
"prepublish": "npm run build"
|
|
116
|
+
"doc:api:check": "tsx ./bin/generate-api-docs.ts --check"
|
|
121
117
|
}
|
|
122
118
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/build/build.es.d.ts
DELETED
package/dist/chain-CTywmh_H.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=["svg","path","g","circle","rect","line","polyline","polygon","ellipse","text","tspan","textPath","defs","marker","radialGradient","stop","linearGradient","clipPath","mask","pattern","image","use","symbol","foreignObject","feGaussianBlur","feColorMatrix"],t=class t{listener;element;constructor(e,t){this.element=this.create(e,t),this.listener=/* @__PURE__ */new Map}create=(t,n)=>e.includes(t)?document.createElementNS("http://www.w3.org/2000/svg",t,n):document.createElement(t,n);setAttribute=(e,t)=>(this.element.setAttribute(e,t),this);removeAttribute=e=>(this.element.removeAttribute(e),this);append=e=>(this.element.appendChild(e),this);remove=e=>(this.element.removeChild(e),this);setTextContent=e=>(this.element.textContent=e,this);setStyle=(e,t)=>(this.element.style.setProperty(e,t),this);addElementByType=(e,n)=>{e instanceof t&&n.appendChild(e.element),e instanceof HTMLElement&&n.appendChild(e)};addChild=e=>{if(Array.isArray(e)){const t=document.createDocumentFragment();e.forEach(e=>{this.addElementByType(e,t)}),this.element.appendChild(t)}else this.addElementByType(e,this.element);return this};listen=(e,t,n)=>{let s=this.listener.get(e);s||(s=/* @__PURE__ */new Map,this.listener.set(e,s));const i=s.get(t.name);return i===t&&console.warn(`${i.name} listener has been added to ${e} event, please remove it first.`),this.element.addEventListener(e,t,n),s.set(t.name,t),this};clearListener=(e,t,n)=>{this.element.removeEventListener(e,t,n);const s=this.listener.get(e);return s?s.delete(t.name):console.warn(`No ${e} event listener has been added.`),this};clearAllListener=()=>{for(const[e,t]of this.listener){for(const[n,s]of t)this.element.removeEventListener(e,s),t.delete(n);this.listener.delete(e)}return this}},n=(e,n)=>new t(e,n);export{n,t};
|