ranuts 0.4.1-alpha.2 → 0.5.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.
- 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 +306 -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/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 +80 -80
- package/dist/src/utils/index.js +306 -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 +1 -1
- package/dist/src/utils/script.js +46 -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 -6
- package/dist/src/utils/str.js +395 -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 +12 -16
- 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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
var o = () => typeof window < "u", f = (e, r = {}) => {
|
|
2
|
+
const { timeout: t = 8e3, fallbackDelay: a = 2500 } = r;
|
|
3
|
+
if (!o()) return () => {
|
|
4
|
+
};
|
|
5
|
+
const c = window.requestIdleCallback;
|
|
6
|
+
if (c) {
|
|
7
|
+
const s = c(e, { timeout: t });
|
|
8
|
+
return () => window.cancelIdleCallback?.(s);
|
|
9
|
+
}
|
|
10
|
+
const i = setTimeout(e, a);
|
|
11
|
+
return () => clearTimeout(i);
|
|
12
|
+
}, l = (e = {}) => {
|
|
13
|
+
const { optOutKey: r, slowTypes: t = ["slow-2g", "2g"] } = e;
|
|
14
|
+
if (!o()) return !1;
|
|
15
|
+
if (r) try {
|
|
16
|
+
if (localStorage.getItem(r)) return !1;
|
|
17
|
+
} catch {
|
|
18
|
+
}
|
|
19
|
+
const a = navigator.connection;
|
|
20
|
+
return !(a?.saveData || a?.effectiveType && t.includes(a.effectiveType));
|
|
21
|
+
}, d = () => typeof caches < "u", u = async (e) => {
|
|
22
|
+
if (!d()) return !1;
|
|
23
|
+
try {
|
|
24
|
+
return !!await caches.match(e);
|
|
25
|
+
} catch {
|
|
26
|
+
return !1;
|
|
27
|
+
}
|
|
28
|
+
}, n = /* @__PURE__ */ new Map(), h = (e) => {
|
|
29
|
+
const r = n.get(e);
|
|
30
|
+
if (r) return r;
|
|
31
|
+
const t = (async () => {
|
|
32
|
+
try {
|
|
33
|
+
if (await u(e)) return;
|
|
34
|
+
const a = (await fetch(e, { cache: "force-cache" })).body?.getReader();
|
|
35
|
+
if (!a) return;
|
|
36
|
+
try {
|
|
37
|
+
for (; !(await a.read()).done; ) ;
|
|
38
|
+
} finally {
|
|
39
|
+
a.releaseLock();
|
|
40
|
+
}
|
|
41
|
+
} catch {
|
|
42
|
+
}
|
|
43
|
+
})().finally(() => n.delete(e));
|
|
44
|
+
return n.set(e, t), t;
|
|
45
|
+
}, v = (e, r) => {
|
|
46
|
+
try {
|
|
47
|
+
const t = typeof navigator < "u" && "serviceWorker" in navigator ? navigator.serviceWorker.controller : null;
|
|
48
|
+
return t ? (t.postMessage({
|
|
49
|
+
type: r,
|
|
50
|
+
urls: e
|
|
51
|
+
}), !0) : !1;
|
|
52
|
+
} catch {
|
|
53
|
+
return !1;
|
|
54
|
+
}
|
|
55
|
+
}, w = async (e, r = {}) => {
|
|
56
|
+
if (e.length !== 0 && !(r.serviceWorkerMessage && v(e, r.serviceWorkerMessage)))
|
|
57
|
+
for (const t of e) await h(t);
|
|
58
|
+
}, y = (e, r = {}) => l(r) ? f(() => {
|
|
59
|
+
w(e, r);
|
|
60
|
+
}, r) : () => {
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
u as isUrlCached,
|
|
64
|
+
l as networkAllowsDownload,
|
|
65
|
+
h as prefetchUrl,
|
|
66
|
+
w as prefetchUrls,
|
|
67
|
+
y as prefetchWhenIdle,
|
|
68
|
+
f as whenIdle
|
|
69
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var i = class {
|
|
2
|
+
running = 0;
|
|
3
|
+
executed = 0;
|
|
4
|
+
simultaneous;
|
|
5
|
+
queue = [];
|
|
6
|
+
idleWaiters = [];
|
|
7
|
+
constructor({ simultaneous: e = 1 } = {}) {
|
|
8
|
+
this.simultaneous = Math.max(1, e);
|
|
9
|
+
}
|
|
10
|
+
get pending() {
|
|
11
|
+
return this.queue.length;
|
|
12
|
+
}
|
|
13
|
+
get idle() {
|
|
14
|
+
return this.queue.length === 0 && this.running === 0;
|
|
15
|
+
}
|
|
16
|
+
add = (e) => typeof e != "function" ? Promise.reject(/* @__PURE__ */ new TypeError("QuestQueue.add expects a function")) : new Promise((t, s) => {
|
|
17
|
+
this.queue.push({
|
|
18
|
+
task: e,
|
|
19
|
+
resolve: t,
|
|
20
|
+
reject: s
|
|
21
|
+
}), this.next();
|
|
22
|
+
});
|
|
23
|
+
allSettled = (e) => Promise.allSettled(e.map((t) => this.add(t)));
|
|
24
|
+
onIdle = () => this.idle ? Promise.resolve() : new Promise((e) => this.idleWaiters.push(e));
|
|
25
|
+
clear = () => {
|
|
26
|
+
const e = this.queue.splice(0, this.queue.length);
|
|
27
|
+
for (const t of e) t.reject(/* @__PURE__ */ new Error("QuestQueue cleared"));
|
|
28
|
+
this.settleIdle();
|
|
29
|
+
};
|
|
30
|
+
next = () => {
|
|
31
|
+
for (; this.running < this.simultaneous && this.queue.length > 0; ) {
|
|
32
|
+
const e = this.queue.shift();
|
|
33
|
+
this.running++, Promise.resolve().then(e.task).then(e.resolve, e.reject).finally(() => {
|
|
34
|
+
this.running--, this.executed++, this.settleIdle(), this.next();
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
settleIdle = () => {
|
|
39
|
+
if (!this.idle) return;
|
|
40
|
+
const e = this.idleWaiters.splice(0, this.idleWaiters.length);
|
|
41
|
+
for (const t of e) t();
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
i as QuestQueue
|
|
46
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { randomString as i } from "./str.js";
|
|
2
|
+
import { getCookie as a, getWindow as s } from "./bom.js";
|
|
3
|
+
import { querystring as f } from "./obj.js";
|
|
4
|
+
var o = {}, l = (e) => {
|
|
5
|
+
typeof e == "string" ? o.url = e : Object.assign(o, e);
|
|
6
|
+
}, u = () => o.url ?? "", d = ({ url: e = "", type: t = "application/json; charset=UTF-8", payload: r = {} }) => {
|
|
7
|
+
if (typeof navigator > "u" || !navigator.sendBeacon || !e) return !1;
|
|
8
|
+
const n = new Blob([JSON.stringify(r)], { type: t });
|
|
9
|
+
return navigator.sendBeacon(e, n);
|
|
10
|
+
}, g = ({ url: e = "", payload: t = {} }) => {
|
|
11
|
+
if (typeof document > "u" || !e) return !1;
|
|
12
|
+
const r = new Image();
|
|
13
|
+
return r.width = 1, r.height = 1, r.src = `${e}?${f(t)}`, !0;
|
|
14
|
+
}, w = ({ url: e, type: t = "application/json; charset=UTF-8", payload: r = {} }) => {
|
|
15
|
+
const n = e || u();
|
|
16
|
+
return n ? d({
|
|
17
|
+
url: n,
|
|
18
|
+
type: t,
|
|
19
|
+
payload: r
|
|
20
|
+
}) || g({
|
|
21
|
+
url: n,
|
|
22
|
+
payload: r
|
|
23
|
+
}) : !1;
|
|
24
|
+
};
|
|
25
|
+
function h(e = {}) {
|
|
26
|
+
if (typeof window > "u") return {};
|
|
27
|
+
const { width: t, height: r } = s();
|
|
28
|
+
return {
|
|
29
|
+
id: i(),
|
|
30
|
+
path: window.location.href,
|
|
31
|
+
time: Date.now(),
|
|
32
|
+
referrer: document.referrer,
|
|
33
|
+
ratio: `${t}x${r}`,
|
|
34
|
+
userAgent: window.navigator.userAgent,
|
|
35
|
+
...o.userIdCookie ? { userId: a(o.userIdCookie) } : {},
|
|
36
|
+
...e
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
h as createData,
|
|
41
|
+
u as getReportUrl,
|
|
42
|
+
w as report,
|
|
43
|
+
l as setReportUrl
|
|
44
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { noop as o } from "./noop.js";
|
|
2
|
+
import { replaceOld as c } from "./obj.js";
|
|
3
|
+
var y = (s = {}) => {
|
|
4
|
+
if (typeof window > "u") return o;
|
|
5
|
+
const { requestHook: r = o, responseHook: d = o, errorHook: u = o } = s;
|
|
6
|
+
return c(window, "fetch", (i) => {
|
|
7
|
+
if (typeof i != "function") return;
|
|
8
|
+
const f = i;
|
|
9
|
+
return (n, t) => (r(n, t), f.apply(window, [n, t]).then((e) => (d(n, t, e), e)).catch((e) => {
|
|
10
|
+
throw u(n, e), e;
|
|
11
|
+
}));
|
|
12
|
+
});
|
|
13
|
+
}, H = (s = {}) => {
|
|
14
|
+
if (typeof window > "u" || typeof XMLHttpRequest > "u") return o;
|
|
15
|
+
const r = XMLHttpRequest.prototype, { requestHook: d = o, responseHook: u = o, errorHook: i = o } = s, f = c(r, "open", (t) => {
|
|
16
|
+
if (typeof t != "function") return;
|
|
17
|
+
const e = t;
|
|
18
|
+
return function(...p) {
|
|
19
|
+
d(p), e.apply(this, p);
|
|
20
|
+
};
|
|
21
|
+
}), n = c(r, "send", (t) => {
|
|
22
|
+
if (typeof t != "function") return;
|
|
23
|
+
const e = t;
|
|
24
|
+
return function(...p) {
|
|
25
|
+
this.addEventListener("loadend", () => u(this), { once: !0 }), this.addEventListener("error", () => i(this), { once: !0 }), e.apply(this, p);
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return () => {
|
|
29
|
+
n(), f();
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
y as handleFetchHook,
|
|
34
|
+
H as handleXhrHook
|
|
35
|
+
};
|
|
@@ -12,7 +12,7 @@ export interface LoadScriptOptions {
|
|
|
12
12
|
* and **guarantees the same script is evaluated only once** — injecting a third-party SDK
|
|
13
13
|
* twice usually means its initialisation side effects ran twice.
|
|
14
14
|
*
|
|
15
|
-
* The
|
|
15
|
+
* The key includes the type and exact content, so distinct sources and URL/inline scripts stay separate.
|
|
16
16
|
*
|
|
17
17
|
* @param {LoadScriptOptions} options
|
|
18
18
|
* @return {Promise<{ success: boolean }>} rejects with `{ success: false, error }` on failure
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var d = /* @__PURE__ */ new Set(), p = ({ type: t, content: o }) => new Promise((r, a) => {
|
|
2
|
+
const e = `${t}:${o}`;
|
|
3
|
+
if (d.has(e)) {
|
|
4
|
+
r({ success: !0 });
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
const n = document.createElement("script");
|
|
8
|
+
if (n.onload = function() {
|
|
9
|
+
d.add(e), r({ success: !0 });
|
|
10
|
+
}, n.onerror = function(s) {
|
|
11
|
+
a({
|
|
12
|
+
success: !1,
|
|
13
|
+
error: s
|
|
14
|
+
});
|
|
15
|
+
}, t === "content") {
|
|
16
|
+
n.textContent = o, document.body.append(n), d.add(e), r({ success: !0 });
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
n.src = o, document.body.append(n);
|
|
20
|
+
}), m = (t, o, r) => {
|
|
21
|
+
t = Array.isArray(t) ? t : [t];
|
|
22
|
+
const a = t.map((e) => {
|
|
23
|
+
const n = e.toLowerCase().endsWith(".css");
|
|
24
|
+
let s;
|
|
25
|
+
if (n) {
|
|
26
|
+
const c = document.createElement("link");
|
|
27
|
+
c.type = "text/css", c.rel = "stylesheet", c.href = e, s = c;
|
|
28
|
+
} else
|
|
29
|
+
s = document.createElement("script"), s.type = "text/javascript", s.src = e;
|
|
30
|
+
const i = document.getElementsByTagName("body")[0];
|
|
31
|
+
return (o || i).appendChild(s), new Promise((c) => {
|
|
32
|
+
s.onload = () => {
|
|
33
|
+
c();
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
return new Promise((e) => {
|
|
38
|
+
Promise.all(a).then(() => {
|
|
39
|
+
r && r(), e();
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
p as loadScript,
|
|
45
|
+
m as scriptOnLoad
|
|
46
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var b = 24;
|
|
2
|
+
function H(r) {
|
|
3
|
+
return Math.max(0, r.scrollHeight - r.clientHeight);
|
|
4
|
+
}
|
|
5
|
+
function h(r, e) {
|
|
6
|
+
return r.getBoundingClientRect().top - e.getBoundingClientRect().top;
|
|
7
|
+
}
|
|
8
|
+
function m(r) {
|
|
9
|
+
const { scrollport: e, observe: u = [], threshold: g = b, onPinnedChange: T } = r;
|
|
10
|
+
let l = !0, n = e.scrollTop, t = null, f = !1;
|
|
11
|
+
const p = (o) => {
|
|
12
|
+
o !== l && (l = o, T?.(o));
|
|
13
|
+
}, s = (o) => {
|
|
14
|
+
e.scrollTop = o, n = e.scrollTop;
|
|
15
|
+
}, a = () => {
|
|
16
|
+
t = null, s(e.scrollHeight), p(!0);
|
|
17
|
+
}, d = () => {
|
|
18
|
+
const o = H(e);
|
|
19
|
+
if (!(Math.abs(e.scrollTop - Math.min(n, o)) > 0.5)) {
|
|
20
|
+
l ? a() : n = e.scrollTop;
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
n = e.scrollTop, p(o - e.scrollTop <= g);
|
|
24
|
+
};
|
|
25
|
+
e.addEventListener("scroll", d, { passive: !0 });
|
|
26
|
+
let c = null;
|
|
27
|
+
if (u.length > 0 && typeof ResizeObserver < "u") {
|
|
28
|
+
c = new ResizeObserver(() => {
|
|
29
|
+
l && !f && s(e.scrollHeight);
|
|
30
|
+
});
|
|
31
|
+
for (const o of u) c.observe(o);
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
get pinned() {
|
|
35
|
+
return l;
|
|
36
|
+
},
|
|
37
|
+
toBottom: a,
|
|
38
|
+
follow() {
|
|
39
|
+
l && s(e.scrollHeight);
|
|
40
|
+
},
|
|
41
|
+
captureAnchor(o) {
|
|
42
|
+
t = {
|
|
43
|
+
row: o,
|
|
44
|
+
top: h(o, e)
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
restoreAnchor(o) {
|
|
48
|
+
if (t === null) return !1;
|
|
49
|
+
const i = o === void 0 ? t.row : o(), { top: v } = t;
|
|
50
|
+
return t = null, i === null || !e.contains(i) ? !1 : (s(e.scrollTop + h(i, e) - v), !0);
|
|
51
|
+
},
|
|
52
|
+
releaseAnchor() {
|
|
53
|
+
t = null;
|
|
54
|
+
},
|
|
55
|
+
destroy() {
|
|
56
|
+
f = !0, e.removeEventListener("scroll", d), c?.disconnect();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
export {
|
|
61
|
+
m as createBottomFollower
|
|
62
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
var u = () => {
|
|
2
|
+
const e = globalThis.crypto;
|
|
3
|
+
if (!e?.getRandomValues) throw new Error("ranuts/secure: Web Crypto is unavailable (needs a browser, Node >= 19, Deno or a Worker)");
|
|
4
|
+
return e;
|
|
5
|
+
}, c = (e, r) => {
|
|
6
|
+
const o = new TextEncoder(), s = typeof e == "string" ? o.encode(e) : e, a = typeof r == "string" ? o.encode(r) : r;
|
|
7
|
+
if (s.length !== a.length) return !1;
|
|
8
|
+
let n = 0;
|
|
9
|
+
for (let t = 0; t < s.length; t++) n |= s[t] ^ a[t];
|
|
10
|
+
return n === 0;
|
|
11
|
+
}, g = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789", l = (e, r = g) => {
|
|
12
|
+
if (!Number.isInteger(e) || e < 0) throw new RangeError("secureRandomString: length must be a whole number");
|
|
13
|
+
if (r.length < 2) throw new RangeError("secureRandomString: alphabet needs at least two characters");
|
|
14
|
+
if (r.length > 256) throw new RangeError("secureRandomString: alphabet must fit in one byte");
|
|
15
|
+
if (e === 0) return "";
|
|
16
|
+
const o = u(), s = Math.floor(256 / r.length) * r.length;
|
|
17
|
+
let a = "";
|
|
18
|
+
const n = new Uint8Array(Math.min(Math.max(e, 16), 4096));
|
|
19
|
+
let t = n.length;
|
|
20
|
+
for (; a.length < e; ) {
|
|
21
|
+
t >= n.length && (o.getRandomValues(n), t = 0);
|
|
22
|
+
const i = n[t++];
|
|
23
|
+
i < s && (a += r[i % r.length]);
|
|
24
|
+
}
|
|
25
|
+
return a;
|
|
26
|
+
}, f = (e = 32) => {
|
|
27
|
+
if (!Number.isInteger(e) || e < 1) throw new RangeError("secureToken: bytes must be a positive whole number");
|
|
28
|
+
const r = new Uint8Array(e);
|
|
29
|
+
return u().getRandomValues(r), Array.from(r, (o) => o.toString(16).padStart(2, "0")).join("");
|
|
30
|
+
};
|
|
31
|
+
export {
|
|
32
|
+
g as UNAMBIGUOUS_ALPHABET,
|
|
33
|
+
c as safeEqual,
|
|
34
|
+
l as secureRandomString,
|
|
35
|
+
f as secureToken
|
|
36
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var u = (l) => {
|
|
2
|
+
const n = Array.from({ length: l.length });
|
|
3
|
+
let i = 0;
|
|
4
|
+
for (let t = 0; t < l.length; t++)
|
|
5
|
+
n[t] = i, i += l[t] || 0;
|
|
6
|
+
return n;
|
|
7
|
+
}, h = (l, n) => {
|
|
8
|
+
if (l.length === 0) return 0;
|
|
9
|
+
let i = 0, t = l.length - 1, f = 0;
|
|
10
|
+
for (; i <= t; ) {
|
|
11
|
+
const r = i + t >> 1;
|
|
12
|
+
l[r] <= n ? (f = r, i = r + 1) : t = r - 1;
|
|
13
|
+
}
|
|
14
|
+
return f;
|
|
15
|
+
}, c = (l, n, i) => {
|
|
16
|
+
const t = n + l.length, f = i.map((e) => ({
|
|
17
|
+
value: e.value,
|
|
18
|
+
s: Math.max(e.start, n) - n,
|
|
19
|
+
e: Math.min(e.end, t) - n
|
|
20
|
+
})).filter((e) => e.e > e.s).sort((e, s) => e.s - s.s || e.e - s.e), r = [], a = (e, s, g) => {
|
|
21
|
+
r.push({
|
|
22
|
+
text: l.slice(e, s),
|
|
23
|
+
start: n + e,
|
|
24
|
+
end: n + s,
|
|
25
|
+
value: g
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
let o = 0;
|
|
29
|
+
for (const e of f) {
|
|
30
|
+
let s = e.s;
|
|
31
|
+
if (s < o) {
|
|
32
|
+
if (e.e <= o) continue;
|
|
33
|
+
s = o;
|
|
34
|
+
}
|
|
35
|
+
s > o && a(o, s, null), a(s, e.e, e.value), o = e.e;
|
|
36
|
+
}
|
|
37
|
+
return o < l.length && a(o, l.length, null), r.length === 0 && a(0, l.length, null), r;
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
u as buildOffsets,
|
|
41
|
+
h as indexForOffset,
|
|
42
|
+
c as segmentByRanges
|
|
43
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SyncHook as u } from "./subscribe.js";
|
|
2
|
+
var f = new u(), g = (c, o = {}) => {
|
|
3
|
+
const { subscriber: n, equals: t } = o;
|
|
4
|
+
let e = c;
|
|
5
|
+
const i = (r, s) => t === !1 ? !0 : typeof t == "function" ? !t(r, s) : !Object.is(r, s);
|
|
6
|
+
return [() => e, (r) => {
|
|
7
|
+
i(e, r) && (e = r, n && f.call(n));
|
|
8
|
+
}];
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
g as createSignal,
|
|
12
|
+
f as subscribers
|
|
13
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var u = () => {
|
|
2
|
+
if (typeof window > "u") return;
|
|
3
|
+
const e = window;
|
|
4
|
+
return e.SpeechRecognition ?? e.webkitSpeechRecognition;
|
|
5
|
+
}, z = (e) => e === "not-allowed" || e === "service-not-allowed" ? "denied" : e === "no-speech" ? "noSpeech" : e === "aborted" ? "aborted" : "failed", E = () => u() !== void 0, k = (e = {}) => {
|
|
6
|
+
const { lang: s, continuous: S = !0, interimResults: R = !0, onResult: b, onError: d, onStart: m, onEnd: f } = e;
|
|
7
|
+
let n = null;
|
|
8
|
+
const y = () => {
|
|
9
|
+
n = null, f?.();
|
|
10
|
+
}, l = {
|
|
11
|
+
get supported() {
|
|
12
|
+
return u() !== void 0;
|
|
13
|
+
},
|
|
14
|
+
get active() {
|
|
15
|
+
return n !== null;
|
|
16
|
+
},
|
|
17
|
+
start() {
|
|
18
|
+
const p = u();
|
|
19
|
+
if (!(!p || n))
|
|
20
|
+
try {
|
|
21
|
+
const t = new p();
|
|
22
|
+
t.lang = typeof s == "function" ? s() : s ?? "", t.continuous = S, t.interimResults = R, t.maxAlternatives = 1;
|
|
23
|
+
let a = "", r = 0;
|
|
24
|
+
t.onresult = (o) => {
|
|
25
|
+
const i = o.results, g = Math.min(o.resultIndex ?? 0, i.length);
|
|
26
|
+
for (g < r && (r = 0, a = ""); r < g; r++) a += i[r]?.[0]?.transcript ?? "";
|
|
27
|
+
let h = "", v = !0;
|
|
28
|
+
for (let c = r; c < i.length; c++) {
|
|
29
|
+
const w = i[c];
|
|
30
|
+
h += w?.[0]?.transcript ?? "", w?.isFinal === !1 && (v = !1);
|
|
31
|
+
}
|
|
32
|
+
b?.(a + h, v);
|
|
33
|
+
}, t.onerror = (o) => d?.({
|
|
34
|
+
kind: z(o.error),
|
|
35
|
+
detail: o.error
|
|
36
|
+
}), t.onstart = () => m?.(), t.onend = y, n = t, t.start();
|
|
37
|
+
} catch (t) {
|
|
38
|
+
n = null, d?.({
|
|
39
|
+
kind: "failed",
|
|
40
|
+
detail: t instanceof Error ? t.message : String(t)
|
|
41
|
+
}), f?.();
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
stop() {
|
|
45
|
+
n?.stop();
|
|
46
|
+
},
|
|
47
|
+
abort() {
|
|
48
|
+
n?.abort();
|
|
49
|
+
},
|
|
50
|
+
toggle() {
|
|
51
|
+
n ? l.stop() : l.start();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
return l;
|
|
55
|
+
};
|
|
56
|
+
export {
|
|
57
|
+
k as createSpeechRecognizer,
|
|
58
|
+
E as isSpeechRecognitionSupported
|
|
59
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var o = () => {
|
|
2
|
+
try {
|
|
3
|
+
return typeof localStorage > "u" ? null : localStorage;
|
|
4
|
+
} catch {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
}, l = (r, e) => {
|
|
8
|
+
try {
|
|
9
|
+
o()?.setItem(r, e);
|
|
10
|
+
} catch {
|
|
11
|
+
}
|
|
12
|
+
}, n = (r) => {
|
|
13
|
+
try {
|
|
14
|
+
return o()?.getItem(r) ?? "";
|
|
15
|
+
} catch {
|
|
16
|
+
return "";
|
|
17
|
+
}
|
|
18
|
+
}, u = (r) => {
|
|
19
|
+
try {
|
|
20
|
+
o()?.removeItem(r);
|
|
21
|
+
} catch {
|
|
22
|
+
}
|
|
23
|
+
}, m = (r = "") => {
|
|
24
|
+
const e = (t) => `${r}${t}`;
|
|
25
|
+
return {
|
|
26
|
+
keyOf: e,
|
|
27
|
+
get: (t, c) => {
|
|
28
|
+
const a = n(e(t));
|
|
29
|
+
if (!a) return c;
|
|
30
|
+
try {
|
|
31
|
+
return JSON.parse(a);
|
|
32
|
+
} catch {
|
|
33
|
+
return c;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
set: (t, c) => {
|
|
37
|
+
let a;
|
|
38
|
+
try {
|
|
39
|
+
a = JSON.stringify(c);
|
|
40
|
+
} catch {
|
|
41
|
+
return !1;
|
|
42
|
+
}
|
|
43
|
+
return l(e(t), a), n(e(t)) === a;
|
|
44
|
+
},
|
|
45
|
+
remove: (t) => u(e(t))
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
export {
|
|
49
|
+
m as createStore,
|
|
50
|
+
n as localStorageGetItem,
|
|
51
|
+
u as localStorageRemoveItem,
|
|
52
|
+
l as localStorageSetItem
|
|
53
|
+
};
|
package/dist/src/utils/str.d.ts
CHANGED
|
@@ -107,12 +107,6 @@ export interface TransformText {
|
|
|
107
107
|
content: string;
|
|
108
108
|
}
|
|
109
109
|
export declare const transformText: (content: string | ArrayBuffer) => TransformText | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* MD5 hash function implementation
|
|
112
|
-
* @param str The string to hash
|
|
113
|
-
* @returns The MD5 hash as a hexadecimal string
|
|
114
|
-
*/
|
|
115
|
-
export declare const md5: (str: string) => string;
|
|
116
110
|
/**
|
|
117
111
|
* @description: A short random-ish base-36 string.
|
|
118
112
|
*
|