yann-core 0.0.1 → 1.0.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.
@@ -0,0 +1,95 @@
1
+ import { getCurrentScope as k, onScopeDispose as D } from "vue";
2
+ const N = 1e3 / 60, F = 20, O = 2 ** 31 - 1, _ = 1e-6;
3
+ function M(r) {
4
+ return r !== null && (typeof r == "object" || typeof r == "function") && "then" in r && typeof r.then == "function";
5
+ }
6
+ function q(r, o = N, w = {}) {
7
+ if (o = typeof o == "number" ? o : N, !Number.isFinite(o) || o < 0)
8
+ throw new RangeError("interval must be finite and non-negative");
9
+ const { type: x = "ignoreCallbackTime", loop: i = !0 } = w;
10
+ if (typeof i == "number" && (Number.isNaN(i) || i === -1 / 0))
11
+ throw new RangeError("loop must be a finite number or Infinity");
12
+ if (typeof requestAnimationFrame != "function" || typeof cancelAnimationFrame != "function")
13
+ return { stop: () => {
14
+ }, pause: () => {
15
+ }, start: () => {
16
+ } };
17
+ let h = r, d = w.onError, t = "running", c = null, l = null, A = 0, g = 0, a = !1, p = 0, y = typeof i == "number" ? Math.max(1, Math.ceil(i)) : i ? 1 / 0 : 1;
18
+ const m = () => (t === "paused" ? g : performance.now()) - A;
19
+ let b = m() + o;
20
+ const T = () => {
21
+ p++, c !== null && clearTimeout(c), l !== null && cancelAnimationFrame(l), c = null, l = null;
22
+ }, E = () => {
23
+ t = "stopped", T(), h = null, d = void 0;
24
+ }, f = () => {
25
+ if (t !== "running" || a) return;
26
+ T();
27
+ const e = p, n = b - m();
28
+ n > F ? c = setTimeout(() => {
29
+ e === p && (c = null, f());
30
+ }, Math.min(O, n - F)) : l = requestAnimationFrame(() => {
31
+ e === p && (l = null, C());
32
+ });
33
+ }, u = (e) => {
34
+ if (a = !1, t !== "stopped") {
35
+ if (y === 0) {
36
+ E();
37
+ return;
38
+ }
39
+ b = (x === "waitAfterCallback" ? m() : e) + o, f();
40
+ }
41
+ }, I = (e, n) => {
42
+ if (t === "stopped") {
43
+ u(n);
44
+ return;
45
+ }
46
+ try {
47
+ if (d) {
48
+ const s = d(e);
49
+ if (M(s)) {
50
+ Promise.resolve(s).then(
51
+ () => u(n),
52
+ (S) => {
53
+ console.error(S), u(n);
54
+ }
55
+ );
56
+ return;
57
+ }
58
+ } else
59
+ console.error(e);
60
+ } catch (s) {
61
+ console.error(s);
62
+ }
63
+ u(n);
64
+ }, C = () => {
65
+ if (t !== "running" || a || h === null) return;
66
+ const e = m();
67
+ if (e + _ < b) {
68
+ f();
69
+ return;
70
+ }
71
+ a = !0, y = Math.max(0, y - 1);
72
+ try {
73
+ const n = h();
74
+ if (M(n)) {
75
+ Promise.resolve(n).then(
76
+ () => u(e),
77
+ (s) => I(s, e)
78
+ );
79
+ return;
80
+ }
81
+ } catch (n) {
82
+ I(n, e);
83
+ return;
84
+ }
85
+ u(e);
86
+ }, L = () => {
87
+ t === "running" && (g = performance.now(), t = "paused", T());
88
+ }, R = () => {
89
+ t === "paused" && (A += performance.now() - g, t = "running", f());
90
+ };
91
+ return k() && D(E), f(), { stop: E, pause: L, start: R };
92
+ }
93
+ export {
94
+ q as useRafTimer
95
+ };
package/package.json CHANGED
@@ -1,53 +1,52 @@
1
1
  {
2
2
  "name": "yann-core",
3
- "version": "0.0.1",
3
+ "version": "1.0.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/types/index.d.ts",
9
+ "sideEffects": false,
9
10
  "scripts": {
10
- "build": "run-p type-check \"build-only {@}\" --",
11
+ "build": "pnpm type-check && pnpm build-only",
11
12
  "build-only": "vite build",
12
- "type-check": "vue-tsc --build",
13
+ "type-check": "tsc --build tsconfig.json tsconfig.tests.json",
13
14
  "lint:oxlint": "oxlint . --fix -D correctness --ignore-path .gitignore",
14
15
  "lint:eslint": "eslint . --fix",
15
- "lint": "run-s lint:*",
16
+ "lint": "pnpm lint:oxlint && pnpm lint:eslint",
17
+ "lint:check": "oxlint . -D correctness --ignore-path .gitignore && eslint .",
18
+ "test": "vitest run",
19
+ "benchmark": "node --expose-gc scripts/benchmark.mjs",
20
+ "verify:package": "node scripts/verify-package.mjs",
16
21
  "format": "prettier --write src/"
17
22
  },
18
23
  "dependencies": {
19
- "@vueuse/core": "^12.8.2",
20
- "localforage": "^1.10.0",
21
- "lodash-es": "^4.17.21",
22
- "nanoid": "^5.1.3",
23
- "p-limit": "^6.2.0",
24
- "pinia": "^3.0.1",
25
- "radash": "^12.1.0",
26
- "vue": "^3.5.13",
27
- "vue-i18n": "^11.1.2",
28
- "vue-router": "^4.5.0"
24
+ "lodash-es": "^4.17.21"
25
+ },
26
+ "peerDependencies": {
27
+ "vue": "^3.5.13"
29
28
  },
30
29
  "devDependencies": {
31
- "@tsconfig/node22": "^22.0.0",
32
30
  "@types/lodash-es": "^4.17.12",
33
31
  "@types/node": "^22.13.4",
34
- "@vitejs/plugin-vue": "^5.2.1",
35
- "@vitejs/plugin-vue-jsx": "^4.1.1",
36
32
  "@vue/eslint-config-prettier": "^10.2.0",
37
33
  "@vue/eslint-config-typescript": "^14.4.0",
38
- "@vue/tsconfig": "^0.7.0",
39
34
  "eslint": "^9.20.1",
40
35
  "eslint-plugin-oxlint": "^0.15.10",
41
36
  "eslint-plugin-vue": "^9.32.0",
42
37
  "jiti": "^2.4.2",
43
- "npm-run-all2": "^7.0.2",
44
38
  "oxlint": "^0.15.10",
45
39
  "prettier": "^3.5.1",
46
40
  "typescript": "~5.7.3",
47
41
  "vite": "^6.1.0",
48
42
  "vite-plugin-dts": "^4.5.3",
49
- "vite-plugin-vue-devtools": "^7.7.2",
50
- "vue-tsc": "^2.2.2"
43
+ "vitest": "^3.2.4",
44
+ "vue": "^3.5.13"
51
45
  },
52
- "files": ["dist"]
53
- }
46
+ "files": [
47
+ "dist"
48
+ ],
49
+ "publishConfig": {
50
+ "registry": "https://registry.npmjs.org/"
51
+ }
52
+ }
@@ -1 +0,0 @@
1
- export {};