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/CLAUDE.md
CHANGED
|
@@ -32,7 +32,6 @@ Each subpath is an independent, tree-shakeable barrel. Import from the subpath,
|
|
|
32
32
|
| --------------------- | --------------------------- | --------------------------------------------------------------- | ------------------ |
|
|
33
33
|
| `ranuts` | `index.ts` | Root barrel — re-exports the utils + visual surface | browser + node |
|
|
34
34
|
| `ranuts/utils` | `src/utils/index.ts` | DOM/BOM, string, object, number, color, time, etc. | browser + node\* |
|
|
35
|
-
| `ranuts/node` | `src/node/index.ts` | HTTP server, router, ws, fs, streams, middleware | **node only** |
|
|
36
35
|
| `ranuts/visual` | `src/utils/visual/index.ts` | 2D rendering engine (Canvas / WebGL / WebGPU) | **browser only** |
|
|
37
36
|
| `ranuts/i18n` | `src/utils/i18n.ts` | `I18nCore` / `createI18n` / `useI18n` — DOM-free | browser + node |
|
|
38
37
|
| `ranuts/sw` | `src/sw/index.ts` | Cache strategies + the precache protocol's SW half | **service worker** |
|
|
@@ -43,8 +42,7 @@ Each subpath is an independent, tree-shakeable barrel. Import from the subpath,
|
|
|
43
42
|
\* `ranuts/utils` is broad: most functions are browser-oriented (touch `window`/`document`),
|
|
44
43
|
but pure helpers (`str`, `obj`, `number`, `compose`, `cloneDeep`, …) run anywhere. Functions
|
|
45
44
|
that read browser globals generally guard with `typeof window/document !== 'undefined'`; do
|
|
46
|
-
the same for any new code.
|
|
47
|
-
`fs`/`http`/`child_process` (these are marked external in the build).
|
|
45
|
+
the same for any new code.
|
|
48
46
|
|
|
49
47
|
---
|
|
50
48
|
|
|
@@ -80,7 +78,6 @@ packages/ranuts/
|
|
|
80
78
|
│ │ ├── diff.ts # diffLines — line-level diff as unified-style hunks
|
|
81
79
|
│ │ ├── visual/ # ranuts/visual — 2D rendering engine (see below)
|
|
82
80
|
│ │ └── totp/ # TOTP + hand-rolled SHA
|
|
83
|
-
│ ├── node/ # ranuts/node — mini HTTP framework
|
|
84
81
|
│ ├── vnode/ # ranuts/vnode — virtual DOM
|
|
85
82
|
│ ├── stream/ # ranuts/stream — SSE + StreamChunk + accumulator + budget
|
|
86
83
|
│ └── conversation/ # ranuts/conversation — event log → nodes, with publication cadence
|
|
@@ -297,16 +294,12 @@ Then `npm run doc:api`.
|
|
|
297
294
|
|
|
298
295
|
- Guard every `window`/`document`/`localStorage`/`navigator` access with `typeof … !== 'undefined'`
|
|
299
296
|
in code reachable from `ranuts/utils` (it's imported in node too).
|
|
300
|
-
- **Guard at call time, not module load.** `
|
|
301
|
-
the
|
|
302
|
-
import-early/call-later flow — and it cannot be stubbed in tests. New code checks
|
|
303
|
-
`typeof window === 'undefined'` inside the function. `isClient` stays exported for
|
|
304
|
-
compatibility but should not be used for new branches.
|
|
297
|
+
- **Guard at call time, not module load.** Check `typeof window === 'undefined'` inside
|
|
298
|
+
the function, so SSR and delayed browser access use the current environment.
|
|
305
299
|
- Never call `window.setTimeout` / `window.setInterval`. The bare globals work in Node, Web
|
|
306
300
|
Workers and the browser alike; the `window.`-prefixed ones throw `ReferenceError` outside a
|
|
307
301
|
document. (This is what made `throttle` unusable in SSR before 0.3.)
|
|
308
|
-
- Keep `ranuts/
|
|
309
|
-
`ranuts/sw`: it runs in a `ServiceWorkerGlobalScope` with no `window`/`document`, which is
|
|
302
|
+
- Keep `ranuts/sw` separate: it runs in a `ServiceWorkerGlobalScope` with no `window`/`document`, which is
|
|
310
303
|
why it is its own entry rather than part of the utils barrel.
|
|
311
304
|
|
|
312
305
|
### Ship both halves of a protocol, or neither
|
|
@@ -374,7 +367,6 @@ npm run doc:api:check # verify it is fresh without writing (what CI runs)
|
|
|
374
367
|
| Pitfall | Fix |
|
|
375
368
|
| -------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
376
369
|
| Importing from a deep source path or `@/…` | Import from the public subpath (`ranuts/utils`, `ranuts/visual`, …). `@/…` is build-internal only. |
|
|
377
|
-
| Importing `ranuts/node` in browser code | It externalizes `fs`/`http`/`child_process` — server-only. Use `ranuts/utils` for browser helpers. |
|
|
378
370
|
| `new Application()` then `render()` with WebGPU | Device init is async — use `await Application.create(...)`, then `app.start()`. |
|
|
379
371
|
| Hand-editing `docs/API.md` | It's generated. Edit the source JSDoc and run `npm run doc:api`. |
|
|
380
372
|
| Adding an export but it's missing from `docs/API.md` | Re-export it from the module's `index.ts` barrel, then `npm run doc:api`. |
|
|
@@ -382,14 +374,12 @@ npm run doc:api:check # verify it is fresh without writing (what CI runs)
|
|
|
382
374
|
| `console.log` left in a function that a test calls | `vitest.config.ts` `onConsoleLog` throws — remove it or the test fails. |
|
|
383
375
|
| Assuming a GPU/Canvas test can run in CI | Test env is node (no DOM/GPU). Test pure logic; gate visual checks behind a browser demo. |
|
|
384
376
|
| Passing a non-`#rrggbb` color to the GPU backend and expecting it to fail | It won't — `getRgb` resolves any CSS color via the browser parser, matching the Canvas backend. |
|
|
385
|
-
| Branching on `isClient` in new code | It's a module-load-time constant — wrong after SSR, unstubbable in tests. Check `typeof window === 'undefined'` inside the function. |
|
|
386
377
|
| Reaching for `randomString` / `getRandomString` to make a token or code | Both are `Math.random()` based and predictable. Use `secureRandomString` / `secureToken` from `secure.ts` for anything an attacker would want to guess. |
|
|
387
378
|
| Comparing a secret with `===` | Returns early at the first differing byte, leaking the shared prefix through timing. Use `safeEqual`. |
|
|
388
379
|
| Asserting a distribution drawn from the real CSPRNG | The window that catches the bias also fires on sampling noise. Script the bytes with `withBytes` (`test/utils/secure.test.ts`) and assert an equality. |
|
|
389
380
|
| Decoding chunked text per chunk | A multi-byte character straddling a boundary becomes replacement characters. `concatBytes` first, decode once. |
|
|
390
381
|
| `window.setTimeout` in a `ranuts/utils` module | Throws outside a document. Use the bare `setTimeout`. |
|
|
391
382
|
| A module-level factory that keeps mutable state shared by everything it produces | Give each produced function its own state (this is why `generateThrottle` was removed). |
|
|
392
|
-
| Reaching for `memoize` expecting per-argument caching | It only runs once and ignores later arguments. Use `once` (its new name), `singleFlight` for async, or a `Map` for real keyed caching. |
|
|
393
383
|
| Assuming `createSignal` deep-compares | It uses `Object.is` since 0.3. Pass `{ equals: isEqual }` when you want deep comparison. |
|
|
394
384
|
| Testing a boolean URL flag with `getAllQueryString(url).embed` | `?embed` (no value) is the usual spelling and reads as `''`, which is falsy. Use `queryFlag('embed')`. |
|
|
395
385
|
| `Promise.race([task, timeoutPromise])` for a deadline | Leaks the timer when the task wins. Use `withTimeout` / `withTimeoutFallback` — they always clear it. |
|
|
@@ -407,7 +397,7 @@ Each fixed a defect rather than changing a preference.
|
|
|
407
397
|
| Symbol | Change | Migration |
|
|
408
398
|
| ------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
|
|
409
399
|
| `generateThrottle` | **Removed.** The factory's generated functions shared one timer and one timestamp, so unrelated throttled functions suppressed each other. | `const f = throttle(fn, delay)` |
|
|
410
|
-
| `memoize` |
|
|
400
|
+
| `memoize` | Removed. Use `once`; per-argument caching requires its own key map. |
|
|
411
401
|
| `createSignal` | `{ equals: true }` used to freeze the signal (it meant "always equal"); every write ran `cloneDeep` + `isEqual`, which overrode `equals` and put an O(size) copy on the write path. | Pass `{ equals: isEqual }` if you relied on deep comparison. |
|
|
412
402
|
| `QuestQueue` | Rewritten. `add()` never started anything, it popped LIFO, one promise carried unrelated tasks' results, and `allSettled` was off by one. The `total` constructor option is gone. | Use `await queue.add(task)`, `queue.allSettled(tasks)`, `queue.onIdle()`. |
|
|
413
403
|
| `report` | Return type narrowed to `boolean`; the image fallback is now reachable; **no default endpoint**. | `setReportUrl(url)` once, or pass `report({ url })`. |
|
|
@@ -415,7 +405,7 @@ Each fixed a defect rather than changing a preference.
|
|
|
415
405
|
| `getHost` | **Removed.** Built a URL from a domain baked into this repo, and a stale edit had reduced its output to the unreachable literal `'//log.'`. | `setReportUrl` / `report({ url })`. |
|
|
416
406
|
| `createData` | No longer reads a hard-coded `chaxus_prod` cookie; `userId` appears only when configured. | `setReportUrl({ userIdCookie })`. |
|
|
417
407
|
| `formatJson` | Now `JSON.stringify` with lenient parsing in front. The old hand-rolled formatter corrupted braces/commas **inside string values** and mis-handled escaped quotes. Gained an `indent` param. | Output spacing now matches `JSON.stringify`. |
|
|
418
|
-
| `timestampToTime` |
|
|
408
|
+
| `timestampToTime` | Removed. Use `formatDate` for strings, or `new Date(timestamp)` for a date object. |
|
|
419
409
|
| `replaceOld` | Returns a restore function instead of `void`. | Additive; keep the returned function. |
|
|
420
410
|
| `handleConsole` / `handleFetchHook` / `handleXhrHook` / `handleError` / `handleClick` | Return a teardown function instead of `void`. | Additive; call it on teardown. |
|
|
421
411
|
| `Monitor` | No longer auto-starts from the constructor (it was gated on a global `window.ranlog`, so a second instance silently did nothing). Takes `{ url, channels, … }`; `start()` returns `stop()`. `createData()` is now evaluated per event, not captured at install time. | `new Monitor({ url }).start()`. |
|
|
@@ -449,3 +439,20 @@ page. Removed rather than deprecated, per the same `0.x`-experimental rationale
|
|
|
449
439
|
in-repo consumers found (`isBangDevice` for an unused `$env.isBang` field, `setAttributeByGlobal`
|
|
450
440
|
for a one-line `window.__VUE_PROD_DEVTOOLS__ = false`) — both inlined rather than kept as a
|
|
451
441
|
reason to preserve the library export.
|
|
442
|
+
|
|
443
|
+
## Alpha removals
|
|
444
|
+
|
|
445
|
+
The `ranuts/node` subpath and the `memoize`, `timeFormat`, `timestampToTime`, `isClient`,
|
|
446
|
+
`md5`, `FMT` exports have been removed. Use platform Node APIs and the maintained utility names.
|
|
447
|
+
|
|
448
|
+
## Binary response types
|
|
449
|
+
|
|
450
|
+
`requestUrlToBuffer(url)` returns ArrayBuffer data by default. An explicit `responseType`
|
|
451
|
+
selects Blob, string or Document/null; JSON and a fully dynamic mode yield unknown until
|
|
452
|
+
validated. `onProgress` observes download progress; the wrapper does not expose cancellation.
|
|
453
|
+
`createObjectURL` also accepts existing string URLs and returns them unchanged.
|
|
454
|
+
|
|
455
|
+
The declaration build uses the shared `bin/prepare-declarations.ts` normalizer to resolve
|
|
456
|
+
aliases and add NodeNext-compatible relative specifiers. Packages publish ESM only; no
|
|
457
|
+
CommonJS builds or `.d.cts` forwarding declarations are generated. Browser script tags can
|
|
458
|
+
load `dist/iife/index.iife.js` (`ranuts`) or `dist/iife/utils.iife.js` (`ranuts_utils`).
|
package/README.de.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ranuts
|
|
2
|
+
|
|
3
|
+
TypeScript-Werkzeuge für Browser-APIs, Datenverarbeitung, Streams und 2D-Rendering.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ranuts) · [MIT](./LICENSE)
|
|
6
|
+
|
|
7
|
+
ESM · IIFE · TypeScript
|
|
8
|
+
|
|
9
|
+
[English](./README.md) | [中文](./README.zh-CN.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [Português](./README.pt.md) | [한국어](./README.ko.md) | **Deutsch** | [فارسی](./README.fa.md)
|
|
10
|
+
|
|
11
|
+
## Schnellstart
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install ranuts@0.5.0
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { rgbToHex } from 'ranuts/utils';
|
|
19
|
+
|
|
20
|
+
console.log(rgbToHex(1, 2, 3)); // #010203
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## ESM
|
|
24
|
+
|
|
25
|
+
Wähle den Einstieg nach Laufzeit und Aufgabe. Einzelne Helfer brauchen Browser-Globals; nicht alle Funktionen sind serverkompatibel.
|
|
26
|
+
|
|
27
|
+
| Paket | Einsatz |
|
|
28
|
+
| --------------------- | -------------------------------------------------------- |
|
|
29
|
+
| `ranuts/utils` | DOM/BOM, Farben, Binärdaten, Speicher und weitere Helfer |
|
|
30
|
+
| `ranuts/i18n` | Eigenständige Internationalisierung |
|
|
31
|
+
| `ranuts/stream` | SSE-Parsing und Zustand gestreamter Antworten |
|
|
32
|
+
| `ranuts/conversation` | Projektion von Gesprächsereignissen |
|
|
33
|
+
| `ranuts/visual` | 2D-Rendering; Browser |
|
|
34
|
+
| `ranuts/vnode` | Virtuelles DOM; Browser |
|
|
35
|
+
| `ranuts/sw` | Cache-Strategien für Service Worker |
|
|
36
|
+
|
|
37
|
+
## IIFE / CDN
|
|
38
|
+
|
|
39
|
+
Für ein klassisches script-Tag steht das veröffentlichte eigenständige IIFE bereit; ein Bundler oder Modullader ist nicht nötig.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/ranuts@0.5.0/dist/iife/utils.iife.js"></script>
|
|
43
|
+
<script>
|
|
44
|
+
console.log(ranuts_utils.rgbToHex(1, 2, 3));
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Das Utility-IIFE stellt `ranuts_utils` bereit, das vollständige `dist/iife/index.iife.js` stellt `ranuts` bereit.
|
|
49
|
+
|
|
50
|
+
## Dokumentation
|
|
51
|
+
|
|
52
|
+
- [ranuts](https://ran.chaxus.com/de/src/ranuts/)
|
|
53
|
+
- [API](./docs/API.md)
|
|
54
|
+
- [Referenz für Maintainer und Agents](./CLAUDE.md)
|
|
55
|
+
|
|
56
|
+
## Mitwirken
|
|
57
|
+
|
|
58
|
+
[Referenz für Maintainer und Agents](./CLAUDE.md) · [AGENTS.md](https://github.com/chaxus/ran/blob/main/AGENTS.md)
|
|
59
|
+
|
|
60
|
+
## Lizenz
|
|
61
|
+
|
|
62
|
+
[MIT](./LICENSE)
|
package/README.es.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ranuts
|
|
2
|
+
|
|
3
|
+
Utilidades TypeScript para APIs del navegador, datos, flujos y renderizado 2D.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ranuts) · [MIT](./LICENSE)
|
|
6
|
+
|
|
7
|
+
ESM · IIFE · TypeScript
|
|
8
|
+
|
|
9
|
+
[English](./README.md) | [中文](./README.zh-CN.md) | [日本語](./README.ja.md) | **Español** | [Português](./README.pt.md) | [한국어](./README.ko.md) | [Deutsch](./README.de.md) | [فارسی](./README.fa.md)
|
|
10
|
+
|
|
11
|
+
## Inicio rápido
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install ranuts@0.5.0
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { rgbToHex } from 'ranuts/utils';
|
|
19
|
+
|
|
20
|
+
console.log(rgbToHex(1, 2, 3)); // #010203
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## ESM
|
|
24
|
+
|
|
25
|
+
Elige una entrada según el entorno y la tarea. Algunas utilidades necesitan objetos globales del navegador; importar el paquete no hace que todas funcionen en el servidor.
|
|
26
|
+
|
|
27
|
+
| Paquete | Uso |
|
|
28
|
+
| --------------------- | ----------------------------------------------------------- |
|
|
29
|
+
| `ranuts/utils` | DOM/BOM, color, binarios, almacenamiento y otras utilidades |
|
|
30
|
+
| `ranuts/i18n` | Internacionalización independiente |
|
|
31
|
+
| `ranuts/stream` | Análisis SSE y estado de respuestas en streaming |
|
|
32
|
+
| `ranuts/conversation` | Proyección del registro de eventos de conversación |
|
|
33
|
+
| `ranuts/visual` | Renderizado 2D; navegador |
|
|
34
|
+
| `ranuts/vnode` | DOM virtual; navegador |
|
|
35
|
+
| `ranuts/sw` | Estrategias de caché de Service Worker |
|
|
36
|
+
|
|
37
|
+
## IIFE / CDN
|
|
38
|
+
|
|
39
|
+
Para una etiqueta script clásica, usa el IIFE independiente publicado; no necesitas bundler ni cargador de módulos.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/ranuts@0.5.0/dist/iife/utils.iife.js"></script>
|
|
43
|
+
<script>
|
|
44
|
+
console.log(ranuts_utils.rgbToHex(1, 2, 3));
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
El IIFE de utilidades expone `ranuts_utils`; el completo `dist/iife/index.iife.js` expone `ranuts`.
|
|
49
|
+
|
|
50
|
+
## Documentación
|
|
51
|
+
|
|
52
|
+
- [ranuts](https://ran.chaxus.com/es/src/ranuts/)
|
|
53
|
+
- [API](./docs/API.md)
|
|
54
|
+
- [Referencia para mantenedores y agentes](./CLAUDE.md)
|
|
55
|
+
|
|
56
|
+
## Contribuir
|
|
57
|
+
|
|
58
|
+
[Referencia para mantenedores y agentes](./CLAUDE.md) · [AGENTS.md](https://github.com/chaxus/ran/blob/main/AGENTS.md)
|
|
59
|
+
|
|
60
|
+
## Licencia
|
|
61
|
+
|
|
62
|
+
[MIT](./LICENSE)
|
package/README.fa.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ranuts
|
|
2
|
+
|
|
3
|
+
ابزارهای TypeScript برای API مرورگر، پردازش داده، جریانها و ترسیم دوبعدی.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ranuts) · [MIT](./LICENSE)
|
|
6
|
+
|
|
7
|
+
ESM · IIFE · TypeScript
|
|
8
|
+
|
|
9
|
+
[English](./README.md) | [中文](./README.zh-CN.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [Português](./README.pt.md) | [한국어](./README.ko.md) | [Deutsch](./README.de.md) | **فارسی**
|
|
10
|
+
|
|
11
|
+
## شروع سریع
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install ranuts@0.5.0
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { rgbToHex } from 'ranuts/utils';
|
|
19
|
+
|
|
20
|
+
console.log(rgbToHex(1, 2, 3)); // #010203
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## ESM
|
|
24
|
+
|
|
25
|
+
ورودی را بر اساس محیط اجرا و کار انتخاب کنید. بعضی ابزارها به متغیرهای سراسری مرورگر نیاز دارند و همه توابع روی سرور قابل اجرا نیستند.
|
|
26
|
+
|
|
27
|
+
| بسته | کاربرد |
|
|
28
|
+
| --------------------- | ----------------------------------------------------- |
|
|
29
|
+
| `ranuts/utils` | DOM/BOM، رنگ، داده دودویی، ذخیرهسازی و ابزارهای دیگر |
|
|
30
|
+
| `ranuts/i18n` | بینالمللیسازی مستقل |
|
|
31
|
+
| `ranuts/stream` | تجزیه SSE و وضعیت پاسخ جریانی |
|
|
32
|
+
| `ranuts/conversation` | نگاشت رویدادهای گفتگو |
|
|
33
|
+
| `ranuts/visual` | ترسیم دوبعدی؛ مرورگر |
|
|
34
|
+
| `ranuts/vnode` | DOM مجازی؛ مرورگر |
|
|
35
|
+
| `ranuts/sw` | راهبردهای کش Service Worker |
|
|
36
|
+
|
|
37
|
+
## IIFE / CDN
|
|
38
|
+
|
|
39
|
+
برای تگ script معمولی از IIFE مستقل منتشرشده استفاده کنید؛ نیازی به ابزار ساخت یا بارگذار ماژول نیست.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/ranuts@0.5.0/dist/iife/utils.iife.js"></script>
|
|
43
|
+
<script>
|
|
44
|
+
console.log(ranuts_utils.rgbToHex(1, 2, 3));
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
IIFE ابزارها `ranuts_utils` و بسته کامل `dist/iife/index.iife.js` نام `ranuts` را ارائه میکند.
|
|
49
|
+
|
|
50
|
+
## مستندات
|
|
51
|
+
|
|
52
|
+
- [ranuts](https://ran.chaxus.com/fa/src/ranuts/)
|
|
53
|
+
- [API](./docs/API.md)
|
|
54
|
+
- [مرجع نگهدارندگان و Agentها](./CLAUDE.md)
|
|
55
|
+
|
|
56
|
+
## مشارکت
|
|
57
|
+
|
|
58
|
+
[مرجع نگهدارندگان و Agentها](./CLAUDE.md) · [AGENTS.md](https://github.com/chaxus/ran/blob/main/AGENTS.md)
|
|
59
|
+
|
|
60
|
+
## مجوز
|
|
61
|
+
|
|
62
|
+
[MIT](./LICENSE)
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ranuts
|
|
2
|
+
|
|
3
|
+
ブラウザー API、データ処理、ストリーム、2D 描画向け TypeScript ユーティリティ。
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ranuts) · [MIT](./LICENSE)
|
|
6
|
+
|
|
7
|
+
ESM · IIFE · TypeScript
|
|
8
|
+
|
|
9
|
+
[English](./README.md) | [中文](./README.zh-CN.md) | **日本語** | [Español](./README.es.md) | [Português](./README.pt.md) | [한국어](./README.ko.md) | [Deutsch](./README.de.md) | [فارسی](./README.fa.md)
|
|
10
|
+
|
|
11
|
+
## クイックスタート
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install ranuts@0.5.0
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { rgbToHex } from 'ranuts/utils';
|
|
19
|
+
|
|
20
|
+
console.log(rgbToHex(1, 2, 3)); // #010203
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## ESM
|
|
24
|
+
|
|
25
|
+
実行環境と用途に合う入口を選んでください。一部の関数はブラウザーのグローバル変数を必要とし、すべての関数がサーバー対応とは限りません。
|
|
26
|
+
|
|
27
|
+
| パッケージ | 用途 |
|
|
28
|
+
| --------------------- | ------------------------------------- |
|
|
29
|
+
| `ranuts/utils` | DOM/BOM、色、バイナリ、ストレージなど |
|
|
30
|
+
| `ranuts/i18n` | 独立した国際化エンジン |
|
|
31
|
+
| `ranuts/stream` | SSE 解析とストリーム応答の状態 |
|
|
32
|
+
| `ranuts/conversation` | 会話イベントログの投影 |
|
|
33
|
+
| `ranuts/visual` | 2D 描画;ブラウザー |
|
|
34
|
+
| `ranuts/vnode` | 仮想 DOM;ブラウザー |
|
|
35
|
+
| `ranuts/sw` | Service Worker のキャッシュ戦略 |
|
|
36
|
+
|
|
37
|
+
## IIFE / CDN
|
|
38
|
+
|
|
39
|
+
通常の script タグでは公開済みの独立 IIFE を使用します。バンドラーやモジュールローダーは不要です。
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/ranuts@0.5.0/dist/iife/utils.iife.js"></script>
|
|
43
|
+
<script>
|
|
44
|
+
console.log(ranuts_utils.rgbToHex(1, 2, 3));
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
ユーティリティ IIFE のグローバル名は `ranuts_utils`、完全版 `dist/iife/index.iife.js` は `ranuts` です。
|
|
49
|
+
|
|
50
|
+
## ドキュメント
|
|
51
|
+
|
|
52
|
+
- [ranuts](https://ran.chaxus.com/ja/src/ranuts/)
|
|
53
|
+
- [API](./docs/API.md)
|
|
54
|
+
- [メンテナーと Agent 向け資料](./CLAUDE.md)
|
|
55
|
+
|
|
56
|
+
## 貢献
|
|
57
|
+
|
|
58
|
+
[メンテナーと Agent 向け資料](./CLAUDE.md) · [AGENTS.md](https://github.com/chaxus/ran/blob/main/AGENTS.md)
|
|
59
|
+
|
|
60
|
+
## ライセンス
|
|
61
|
+
|
|
62
|
+
[MIT](./LICENSE)
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ranuts
|
|
2
|
+
|
|
3
|
+
브라우저 API, 데이터 처리, 스트림, 2D 렌더링을 위한 TypeScript 유틸리티.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ranuts) · [MIT](./LICENSE)
|
|
6
|
+
|
|
7
|
+
ESM · IIFE · TypeScript
|
|
8
|
+
|
|
9
|
+
[English](./README.md) | [中文](./README.zh-CN.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [Português](./README.pt.md) | **한국어** | [Deutsch](./README.de.md) | [فارسی](./README.fa.md)
|
|
10
|
+
|
|
11
|
+
## 빠른 시작
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install ranuts@0.5.0
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { rgbToHex } from 'ranuts/utils';
|
|
19
|
+
|
|
20
|
+
console.log(rgbToHex(1, 2, 3)); // #010203
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## ESM
|
|
24
|
+
|
|
25
|
+
실행 환경과 작업에 맞는 진입점을 선택하세요. 일부 함수는 브라우저 전역 객체가 필요하며 모든 함수가 서버에서 작동하는 것은 아닙니다.
|
|
26
|
+
|
|
27
|
+
| 패키지 | 용도 |
|
|
28
|
+
| --------------------- | ---------------------------------- |
|
|
29
|
+
| `ranuts/utils` | DOM/BOM, 색상, 바이너리, 저장소 등 |
|
|
30
|
+
| `ranuts/i18n` | 독립 국제화 엔진 |
|
|
31
|
+
| `ranuts/stream` | SSE 파싱과 스트리밍 응답 상태 |
|
|
32
|
+
| `ranuts/conversation` | 대화 이벤트 로그 투영 |
|
|
33
|
+
| `ranuts/visual` | 2D 렌더링; 브라우저 |
|
|
34
|
+
| `ranuts/vnode` | 가상 DOM; 브라우저 |
|
|
35
|
+
| `ranuts/sw` | Service Worker 캐시 전략 |
|
|
36
|
+
|
|
37
|
+
## IIFE / CDN
|
|
38
|
+
|
|
39
|
+
일반 script 태그에서는 배포된 독립 IIFE를 번들러나 모듈 로더 없이 사용할 수 있습니다.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/ranuts@0.5.0/dist/iife/utils.iife.js"></script>
|
|
43
|
+
<script>
|
|
44
|
+
console.log(ranuts_utils.rgbToHex(1, 2, 3));
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
유틸리티 IIFE는 `ranuts_utils`, 전체 `dist/iife/index.iife.js`는 `ranuts`를 노출합니다.
|
|
49
|
+
|
|
50
|
+
## 문서
|
|
51
|
+
|
|
52
|
+
- [ranuts](https://ran.chaxus.com/ko/src/ranuts/)
|
|
53
|
+
- [API](./docs/API.md)
|
|
54
|
+
- [유지 관리자와 Agent 참고](./CLAUDE.md)
|
|
55
|
+
|
|
56
|
+
## 기여
|
|
57
|
+
|
|
58
|
+
[유지 관리자와 Agent 참고](./CLAUDE.md) · [AGENTS.md](https://github.com/chaxus/ran/blob/main/AGENTS.md)
|
|
59
|
+
|
|
60
|
+
## 라이선스
|
|
61
|
+
|
|
62
|
+
[MIT](./LICENSE)
|
package/README.md
CHANGED
|
@@ -1,119 +1,62 @@
|
|
|
1
1
|
# ranuts
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
TypeScript utilities for browser APIs, data processing, streams and 2D rendering.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
[](https://www.npmjs.com/package/ranuts) · [MIT](./LICENSE)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
<a href="https://github.com/chaxus/ran"><img src="https://img.shields.io/npm/v/ranuts.svg" alt="npm-v"></a>
|
|
9
|
-
<a href="https://github.com/chaxus/ran"><img src="https://img.shields.io/npm/dt/ranuts.svg" alt="npm-d"></a>
|
|
10
|
-
<a href="https://github.com/chaxus/ran"><img src="https://img.badgesize.io/https:/unpkg.com/ranuts/dist/index.js?label=brotli&compression=brotli" alt="brotli"></a>
|
|
11
|
-
<a href="https://github.com/chaxus/ran"><img src="https://img.shields.io/badge/module%20formats-umd%2C%20esm-green.svg" alt="module formats: umd, esm"></a>
|
|
7
|
+
ESM · IIFE · TypeScript
|
|
12
8
|
|
|
13
|
-
**English** | [中文](./README.zh-CN.md)
|
|
9
|
+
**English** | [中文](./README.zh-CN.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | [Português](./README.pt.md) | [한국어](./README.ko.md) | [Deutsch](./README.de.md) | [فارسی](./README.fa.md)
|
|
14
10
|
|
|
15
|
-
|
|
11
|
+
## Quick start
|
|
16
12
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
This is an **experimental utility library** in early development. While functional, it's primarily designed for learning and experimentation.
|
|
20
|
-
|
|
21
|
-
**Key points:**
|
|
22
|
-
|
|
23
|
-
- 🚧 **Early Development**: Features are still being developed and refined
|
|
24
|
-
- 🧪 **Experimental**: APIs may change frequently
|
|
25
|
-
- 📚 **Learning Focus**: Primarily for learning JavaScript/TypeScript utilities
|
|
26
|
-
|
|
27
|
-
## Install
|
|
28
|
-
|
|
29
|
-
Using npm:
|
|
30
|
-
|
|
31
|
-
```console
|
|
32
|
-
npm install ranuts@latest --save
|
|
13
|
+
```sh
|
|
14
|
+
npm install ranuts@0.5.0
|
|
33
15
|
```
|
|
34
16
|
|
|
35
|
-
|
|
17
|
+
```ts
|
|
18
|
+
import { rgbToHex } from 'ranuts/utils';
|
|
36
19
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
**For AI agents / LLMs:** start from [CLAUDE.md](./CLAUDE.md) (orientation: entry points,
|
|
40
|
-
runtime constraints, conventions) and [docs/API.md](./docs/API.md) (generated reference of
|
|
41
|
-
every exported symbol with signatures + descriptions, run `npm run doc:api` to refresh).
|
|
42
|
-
|
|
43
|
-
Or install the ready-made **Claude Code skill** from the `ran` plugin marketplace — it
|
|
44
|
-
gives assistants the import map, `ranuts/utils` inventory, usage examples, and conventions,
|
|
45
|
-
and points to the API reference shipped in the package:
|
|
46
|
-
|
|
47
|
-
```bash
|
|
48
|
-
/plugin marketplace add chaxus/ran
|
|
49
|
-
/plugin install ranuts@ran
|
|
20
|
+
console.log(rgbToHex(1, 2, 3)); // #010203
|
|
50
21
|
```
|
|
51
22
|
|
|
52
|
-
|
|
23
|
+
## ESM
|
|
53
24
|
|
|
54
|
-
|
|
25
|
+
Choose an entry by runtime and task. Individual utilities may require browser globals; importing a package does not make every helper server-compatible.
|
|
55
26
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
- `ranuts/conversation` — project an append-only event log into renderable conversation nodes
|
|
66
|
-
- `ranuts/i18n` — the i18n engine on its own, without the rest of `utils`
|
|
67
|
-
|
|
68
|
-
```js
|
|
69
|
-
import { debounce } from 'ranuts/utils';
|
|
70
|
-
import { readFile } from 'ranuts/node';
|
|
71
|
-
import { createI18n } from 'ranuts/i18n';
|
|
72
|
-
```
|
|
27
|
+
| Package | Use for |
|
|
28
|
+
| --------------------- | ------------------------------------------------- |
|
|
29
|
+
| `ranuts/utils` | DOM/BOM, color, binary, storage and other helpers |
|
|
30
|
+
| `ranuts/i18n` | Internationalization without the utility barrel |
|
|
31
|
+
| `ranuts/stream` | SSE parsing and streamed-response state |
|
|
32
|
+
| `ranuts/conversation` | Conversation event-log projection |
|
|
33
|
+
| `ranuts/visual` | 2D rendering; browser |
|
|
34
|
+
| `ranuts/vnode` | Virtual DOM; browser |
|
|
35
|
+
| `ranuts/sw` | Service-worker cache strategies; service worker |
|
|
73
36
|
|
|
74
|
-
|
|
37
|
+
## IIFE / CDN
|
|
75
38
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
```js
|
|
79
|
-
import { debounce } from 'ranuts';
|
|
80
|
-
|
|
81
|
-
const onResize = debounce(() => {
|
|
82
|
-
console.log('window resized');
|
|
83
|
-
}, 200);
|
|
84
|
-
|
|
85
|
-
window.addEventListener('resize', onResize);
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
- UMD, IIFE, CJS
|
|
39
|
+
For a classic browser script tag, use the published standalone IIFE; no bundler or module loader is needed.
|
|
89
40
|
|
|
90
41
|
```html
|
|
91
|
-
<script src="
|
|
92
|
-
|
|
93
|
-
<script>
|
|
94
|
-
const { debounce } = require('ranuts')
|
|
95
|
-
const onResize = debounce(() => {
|
|
96
|
-
console.log('window resized');
|
|
97
|
-
}, 200);
|
|
98
|
-
|
|
99
|
-
window.addEventListener('resize', onResize);
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/ranuts@0.5.0/dist/iife/utils.iife.js"></script>
|
|
100
43
|
<script>
|
|
44
|
+
console.log(ranuts_utils.rgbToHex(1, 2, 3));
|
|
45
|
+
</script>
|
|
101
46
|
```
|
|
102
47
|
|
|
103
|
-
|
|
48
|
+
The utility IIFE exposes `ranuts_utils`; the full `dist/iife/index.iife.js` exposes `ranuts`.
|
|
104
49
|
|
|
105
|
-
|
|
50
|
+
## Documentation
|
|
106
51
|
|
|
107
|
-
|
|
52
|
+
- [ranuts](https://ran.chaxus.com/src/ranuts/)
|
|
53
|
+
- [API](./docs/API.md)
|
|
54
|
+
- [Maintainer and agent reference](./CLAUDE.md)
|
|
108
55
|
|
|
109
|
-
|
|
110
|
-
<img src="https://contrib.rocks/image?repo=chaxus/ran" />
|
|
111
|
-
</a>
|
|
112
|
-
|
|
113
|
-
## Visitors
|
|
56
|
+
## Contributing
|
|
114
57
|
|
|
115
|
-
|
|
58
|
+
[Maintainer and agent reference](./CLAUDE.md) · [AGENTS.md](https://github.com/chaxus/ran/blob/main/AGENTS.md)
|
|
116
59
|
|
|
117
|
-
##
|
|
60
|
+
## License
|
|
118
61
|
|
|
119
|
-
[
|
|
62
|
+
[MIT](./LICENSE)
|
package/README.pt.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ranuts
|
|
2
|
+
|
|
3
|
+
Utilitários TypeScript para APIs do navegador, dados, streams e renderização 2D.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/ranuts) · [MIT](./LICENSE)
|
|
6
|
+
|
|
7
|
+
ESM · IIFE · TypeScript
|
|
8
|
+
|
|
9
|
+
[English](./README.md) | [中文](./README.zh-CN.md) | [日本語](./README.ja.md) | [Español](./README.es.md) | **Português** | [한국어](./README.ko.md) | [Deutsch](./README.de.md) | [فارسی](./README.fa.md)
|
|
10
|
+
|
|
11
|
+
## Início rápido
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
npm install ranuts@0.5.0
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { rgbToHex } from 'ranuts/utils';
|
|
19
|
+
|
|
20
|
+
console.log(rgbToHex(1, 2, 3)); // #010203
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## ESM
|
|
24
|
+
|
|
25
|
+
Escolha a entrada conforme o ambiente e a tarefa. Alguns utilitários exigem objetos globais do navegador; importar o pacote não torna todas as funções compatíveis com o servidor.
|
|
26
|
+
|
|
27
|
+
| Pacote | Uso |
|
|
28
|
+
| --------------------- | ------------------------------------------------------------ |
|
|
29
|
+
| `ranuts/utils` | DOM/BOM, cores, binários, armazenamento e outros utilitários |
|
|
30
|
+
| `ranuts/i18n` | Internacionalização independente |
|
|
31
|
+
| `ranuts/stream` | Análise SSE e estado de respostas em streaming |
|
|
32
|
+
| `ranuts/conversation` | Projeção do log de eventos de conversa |
|
|
33
|
+
| `ranuts/visual` | Renderização 2D; navegador |
|
|
34
|
+
| `ranuts/vnode` | DOM virtual; navegador |
|
|
35
|
+
| `ranuts/sw` | Estratégias de cache do Service Worker |
|
|
36
|
+
|
|
37
|
+
## IIFE / CDN
|
|
38
|
+
|
|
39
|
+
Para uma tag script clássica, use o IIFE independente publicado; não é necessário bundler ou carregador de módulos.
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<script src="https://cdn.jsdelivr.net/npm/ranuts@0.5.0/dist/iife/utils.iife.js"></script>
|
|
43
|
+
<script>
|
|
44
|
+
console.log(ranuts_utils.rgbToHex(1, 2, 3));
|
|
45
|
+
</script>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
O IIFE de utilitários expõe `ranuts_utils`; o completo `dist/iife/index.iife.js` expõe `ranuts`.
|
|
49
|
+
|
|
50
|
+
## Documentação
|
|
51
|
+
|
|
52
|
+
- [ranuts](https://ran.chaxus.com/pt/src/ranuts/)
|
|
53
|
+
- [API](./docs/API.md)
|
|
54
|
+
- [Referência para mantenedores e agentes](./CLAUDE.md)
|
|
55
|
+
|
|
56
|
+
## Contribuir
|
|
57
|
+
|
|
58
|
+
[Referência para mantenedores e agentes](./CLAUDE.md) · [AGENTS.md](https://github.com/chaxus/ran/blob/main/AGENTS.md)
|
|
59
|
+
|
|
60
|
+
## Licença
|
|
61
|
+
|
|
62
|
+
[MIT](./LICENSE)
|