fynixui 1.0.10 → 1.0.12
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/dist/custom/DataTable.js +1 -0
- package/dist/custom/button.js +241 -1
- package/dist/custom/index.js +1 -1
- package/dist/error/errorOverlay.js +1 -1
- package/dist/hooks/nixFor.js +6 -4
- package/dist/package.json +34 -37
- package/dist/plugins/vite-plugin-res.js +26 -4
- package/dist/router/router.js +108 -217
- package/dist/runtime.js +1251 -1028
- package/{dist → dist-types}/context/context.d.ts +1 -2
- package/dist-types/custom/DataTable.d.ts +0 -0
- package/dist-types/custom/button.d.ts +35 -0
- package/dist-types/custom/index.d.ts +2 -0
- package/{dist → dist-types}/custom/path.d.ts +0 -1
- package/{dist → dist-types}/error/errorOverlay.d.ts +0 -1
- package/{dist → dist-types}/fynix/index.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixAsync.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixAsyncCache.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixAsyncDebounce.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixAsyncQuery.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixCallback.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixComputed.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixDebounce.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixEffect.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixFor.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixForm.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixFormAsync.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixInterval.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixLazy.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixLazyAsync.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixLazyFormAsync.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixLocalStorage.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixMemo.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixPrevious.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixRef.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixState.d.ts +0 -1
- package/{dist → dist-types}/hooks/nixStore.d.ts +0 -1
- package/{dist → dist-types}/plugins/vite-plugin-res.d.ts +0 -1
- package/{dist → dist-types}/router/router.d.ts +14 -11
- package/dist-types/runtime.d.ts +200 -0
- package/package.json +43 -41
- package/dist/context/context.d.ts.map +0 -1
- package/dist/context/context.js.map +0 -7
- package/dist/custom/button.d.ts +0 -2
- package/dist/custom/button.d.ts.map +0 -1
- package/dist/custom/button.js.map +0 -7
- package/dist/custom/index.d.ts +0 -3
- package/dist/custom/index.d.ts.map +0 -1
- package/dist/custom/index.js.map +0 -7
- package/dist/custom/path.d.ts.map +0 -1
- package/dist/custom/path.js.map +0 -7
- package/dist/error/errorOverlay.d.ts.map +0 -1
- package/dist/error/errorOverlay.js.map +0 -7
- package/dist/fynix/index.d.ts.map +0 -1
- package/dist/fynix/index.js.map +0 -7
- package/dist/hooks/nixAsync.d.ts.map +0 -1
- package/dist/hooks/nixAsync.js.map +0 -7
- package/dist/hooks/nixAsyncCache.d.ts.map +0 -1
- package/dist/hooks/nixAsyncCache.js.map +0 -7
- package/dist/hooks/nixAsyncDebounce.d.ts.map +0 -1
- package/dist/hooks/nixAsyncDebounce.js.map +0 -7
- package/dist/hooks/nixAsyncQuery.d.ts.map +0 -1
- package/dist/hooks/nixAsyncQuery.js.map +0 -7
- package/dist/hooks/nixCallback.d.ts.map +0 -1
- package/dist/hooks/nixCallback.js.map +0 -7
- package/dist/hooks/nixComputed.d.ts.map +0 -1
- package/dist/hooks/nixComputed.js.map +0 -7
- package/dist/hooks/nixDebounce.d.ts.map +0 -1
- package/dist/hooks/nixDebounce.js.map +0 -7
- package/dist/hooks/nixEffect.d.ts.map +0 -1
- package/dist/hooks/nixEffect.js.map +0 -7
- package/dist/hooks/nixFor.d.ts.map +0 -1
- package/dist/hooks/nixFor.js.map +0 -7
- package/dist/hooks/nixForm.d.ts.map +0 -1
- package/dist/hooks/nixForm.js.map +0 -7
- package/dist/hooks/nixFormAsync.d.ts.map +0 -1
- package/dist/hooks/nixFormAsync.js.map +0 -7
- package/dist/hooks/nixInterval.d.ts.map +0 -1
- package/dist/hooks/nixInterval.js.map +0 -7
- package/dist/hooks/nixLazy.d.ts.map +0 -1
- package/dist/hooks/nixLazy.js.map +0 -7
- package/dist/hooks/nixLazyAsync.d.ts.map +0 -1
- package/dist/hooks/nixLazyAsync.js.map +0 -7
- package/dist/hooks/nixLazyFormAsync.d.ts.map +0 -1
- package/dist/hooks/nixLazyFormAsync.js.map +0 -7
- package/dist/hooks/nixLocalStorage.d.ts.map +0 -1
- package/dist/hooks/nixLocalStorage.js.map +0 -7
- package/dist/hooks/nixMemo.d.ts.map +0 -1
- package/dist/hooks/nixMemo.js.map +0 -7
- package/dist/hooks/nixPrevious.d.ts.map +0 -1
- package/dist/hooks/nixPrevious.js.map +0 -7
- package/dist/hooks/nixRef.d.ts.map +0 -1
- package/dist/hooks/nixRef.js.map +0 -7
- package/dist/hooks/nixState.d.ts.map +0 -1
- package/dist/hooks/nixState.js.map +0 -7
- package/dist/hooks/nixStore.d.ts.map +0 -1
- package/dist/hooks/nixStore.js.map +0 -7
- package/dist/plugins/vite-plugin-res.d.ts.map +0 -1
- package/dist/plugins/vite-plugin-res.js.map +0 -7
- package/dist/router/router.d.ts.map +0 -1
- package/dist/router/router.js.map +0 -7
- package/dist/runtime.d.ts +0 -124
- package/dist/runtime.d.ts.map +0 -1
- package/dist/runtime.js.map +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fynixui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core package for Fynix UI framework - A lightweight, reactive UI framework with TypeScript support.",
|
|
6
6
|
"main": "./dist/fynix/index.js",
|
|
@@ -8,125 +8,125 @@
|
|
|
8
8
|
"types": "./types/index.d.ts",
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
11
|
-
"types": "./dist/fynix/index.d.ts",
|
|
11
|
+
"types": "./dist-types/fynix/index.d.ts",
|
|
12
12
|
"import": "./dist/fynix/index.js",
|
|
13
13
|
"default": "./dist/fynix/index.js"
|
|
14
14
|
},
|
|
15
15
|
"./runtime": {
|
|
16
|
-
"types": "./dist/runtime.d.ts",
|
|
16
|
+
"types": "./dist-types/runtime.d.ts",
|
|
17
17
|
"import": "./dist/runtime.js"
|
|
18
18
|
},
|
|
19
19
|
"./context": {
|
|
20
|
-
"types": "./dist/context/context.d.ts",
|
|
20
|
+
"types": "./dist-types/context/context.d.ts",
|
|
21
21
|
"import": "./dist/context/context.js"
|
|
22
22
|
},
|
|
23
23
|
"./custom": {
|
|
24
|
-
"types": "./dist/custom/index.d.ts",
|
|
24
|
+
"types": "./dist-types/custom/index.d.ts",
|
|
25
25
|
"import": "./dist/custom/index.js"
|
|
26
26
|
},
|
|
27
27
|
"./custom/button": {
|
|
28
|
-
"types": "./dist/custom/button.d.ts",
|
|
28
|
+
"types": "./dist-types/custom/button.d.ts",
|
|
29
29
|
"import": "./dist/custom/button.js"
|
|
30
30
|
},
|
|
31
31
|
"./custom/path": {
|
|
32
|
-
"types": "./dist/custom/path.d.ts",
|
|
32
|
+
"types": "./dist-types/custom/path.d.ts",
|
|
33
33
|
"import": "./dist/custom/path.js"
|
|
34
34
|
},
|
|
35
35
|
"./error": {
|
|
36
|
-
"types": "./dist/error/errorOverlay.d.ts",
|
|
36
|
+
"types": "./dist-types/error/errorOverlay.d.ts",
|
|
37
37
|
"import": "./dist/error/errorOverlay.js"
|
|
38
38
|
},
|
|
39
39
|
"./router": {
|
|
40
|
-
"types": "./dist/router/router.d.ts",
|
|
40
|
+
"types": "./dist-types/router/router.d.ts",
|
|
41
41
|
"import": "./dist/router/router.js"
|
|
42
42
|
},
|
|
43
43
|
"./hooks/nixState": {
|
|
44
|
-
"types": "./dist/hooks/nixState.d.ts",
|
|
44
|
+
"types": "./dist-types/hooks/nixState.d.ts",
|
|
45
45
|
"import": "./dist/hooks/nixState.js"
|
|
46
46
|
},
|
|
47
47
|
"./hooks/nixStore": {
|
|
48
|
-
"types": "./dist/hooks/nixStore.d.ts",
|
|
48
|
+
"types": "./dist-types/hooks/nixStore.d.ts",
|
|
49
49
|
"import": "./dist/hooks/nixStore.js"
|
|
50
50
|
},
|
|
51
51
|
"./hooks/nixEffect": {
|
|
52
|
-
"types": "./dist/hooks/nixEffect.d.ts",
|
|
52
|
+
"types": "./dist-types/hooks/nixEffect.d.ts",
|
|
53
53
|
"import": "./dist/hooks/nixEffect.js"
|
|
54
54
|
},
|
|
55
55
|
"./hooks/nixAsync": {
|
|
56
|
-
"types": "./dist/hooks/nixAsync.d.ts",
|
|
56
|
+
"types": "./dist-types/hooks/nixAsync.d.ts",
|
|
57
57
|
"import": "./dist/hooks/nixAsync.js"
|
|
58
58
|
},
|
|
59
59
|
"./hooks/nixAsyncCache": {
|
|
60
|
-
"types": "./dist/hooks/nixAsyncCache.d.ts",
|
|
60
|
+
"types": "./dist-types/hooks/nixAsyncCache.d.ts",
|
|
61
61
|
"import": "./dist/hooks/nixAsyncCache.js"
|
|
62
62
|
},
|
|
63
63
|
"./hooks/nixAsyncDebounce": {
|
|
64
|
-
"types": "./dist/hooks/nixAsyncDebounce.d.ts",
|
|
64
|
+
"types": "./dist-types/hooks/nixAsyncDebounce.d.ts",
|
|
65
65
|
"import": "./dist/hooks/nixAsyncDebounce.js"
|
|
66
66
|
},
|
|
67
67
|
"./hooks/nixAsyncQuery": {
|
|
68
|
-
"types": "./dist/hooks/nixAsyncQuery.d.ts",
|
|
68
|
+
"types": "./dist-types/hooks/nixAsyncQuery.d.ts",
|
|
69
69
|
"import": "./dist/hooks/nixAsyncQuery.js"
|
|
70
70
|
},
|
|
71
71
|
"./hooks/nixCallback": {
|
|
72
|
-
"types": "./dist/hooks/nixCallback.d.ts",
|
|
72
|
+
"types": "./dist-types/hooks/nixCallback.d.ts",
|
|
73
73
|
"import": "./dist/hooks/nixCallback.js"
|
|
74
74
|
},
|
|
75
75
|
"./hooks/nixComputed": {
|
|
76
|
-
"types": "./dist/hooks/nixComputed.d.ts",
|
|
76
|
+
"types": "./dist-types/hooks/nixComputed.d.ts",
|
|
77
77
|
"import": "./dist/hooks/nixComputed.js"
|
|
78
78
|
},
|
|
79
79
|
"./hooks/nixDebounce": {
|
|
80
|
-
"types": "./dist/hooks/nixDebounce.d.ts",
|
|
80
|
+
"types": "./dist-types/hooks/nixDebounce.d.ts",
|
|
81
81
|
"import": "./dist/hooks/nixDebounce.js"
|
|
82
82
|
},
|
|
83
83
|
"./hooks/nixForm": {
|
|
84
|
-
"types": "./dist/hooks/nixForm.d.ts",
|
|
84
|
+
"types": "./dist-types/hooks/nixForm.d.ts",
|
|
85
85
|
"import": "./dist/hooks/nixForm.js"
|
|
86
86
|
},
|
|
87
87
|
"./hooks/nixFormAsync": {
|
|
88
|
-
"types": "./dist/hooks/nixFormAsync.d.ts",
|
|
88
|
+
"types": "./dist-types/hooks/nixFormAsync.d.ts",
|
|
89
89
|
"import": "./dist/hooks/nixFormAsync.js"
|
|
90
90
|
},
|
|
91
91
|
"./hooks/nixInterval": {
|
|
92
|
-
"types": "./dist/hooks/nixInterval.d.ts",
|
|
92
|
+
"types": "./dist-types/hooks/nixInterval.d.ts",
|
|
93
93
|
"import": "./dist/hooks/nixInterval.js"
|
|
94
94
|
},
|
|
95
95
|
"./hooks/nixLazy": {
|
|
96
|
-
"types": "./dist/hooks/nixLazy.d.ts",
|
|
96
|
+
"types": "./dist-types/hooks/nixLazy.d.ts",
|
|
97
97
|
"import": "./dist/hooks/nixLazy.js"
|
|
98
98
|
},
|
|
99
99
|
"./hooks/nixLazyAsync": {
|
|
100
|
-
"types": "./dist/hooks/nixLazyAsync.d.ts",
|
|
100
|
+
"types": "./dist-types/hooks/nixLazyAsync.d.ts",
|
|
101
101
|
"import": "./dist/hooks/nixLazyAsync.js"
|
|
102
102
|
},
|
|
103
103
|
"./hooks/nixLazyFormAsync": {
|
|
104
|
-
"types": "./dist/hooks/nixLazyFormAsync.d.ts",
|
|
104
|
+
"types": "./dist-types/hooks/nixLazyFormAsync.d.ts",
|
|
105
105
|
"import": "./dist/hooks/nixLazyFormAsync.js"
|
|
106
106
|
},
|
|
107
107
|
"./hooks/nixLocalStorage": {
|
|
108
|
-
"types": "./dist/hooks/nixLocalStorage.d.ts",
|
|
108
|
+
"types": "./dist-types/hooks/nixLocalStorage.d.ts",
|
|
109
109
|
"import": "./dist/hooks/nixLocalStorage.js"
|
|
110
110
|
},
|
|
111
111
|
"./hooks/nixMemo": {
|
|
112
|
-
"types": "./dist/hooks/nixMemo.d.ts",
|
|
112
|
+
"types": "./dist-types/hooks/nixMemo.d.ts",
|
|
113
113
|
"import": "./dist/hooks/nixMemo.js"
|
|
114
114
|
},
|
|
115
115
|
"./hooks/nixPrevious": {
|
|
116
|
-
"types": "./dist/hooks/nixPrevious.d.ts",
|
|
116
|
+
"types": "./dist-types/hooks/nixPrevious.d.ts",
|
|
117
117
|
"import": "./dist/hooks/nixPrevious.js"
|
|
118
118
|
},
|
|
119
119
|
"./hooks/nixRef": {
|
|
120
|
-
"types": "./dist/hooks/nixRef.d.ts",
|
|
120
|
+
"types": "./dist-types/hooks/nixRef.d.ts",
|
|
121
121
|
"import": "./dist/hooks/nixRef.js"
|
|
122
122
|
},
|
|
123
123
|
"./plugins/vite-plugin-res": {
|
|
124
|
-
"types": "./dist/plugins/vite-plugin-res.d.ts",
|
|
124
|
+
"types": "./dist-types/plugins/vite-plugin-res.d.ts",
|
|
125
125
|
"import": "./dist/plugins/vite-plugin-res.js"
|
|
126
126
|
},
|
|
127
127
|
"./typescript-plugin": {
|
|
128
128
|
"import": "./dist/typescript-fynix-plugin/index.js",
|
|
129
|
-
"types": "./dist/typescript-fynix-plugin/index.d.ts"
|
|
129
|
+
"types": "./dist-types/typescript-fynix-plugin/index.d.ts"
|
|
130
130
|
},
|
|
131
131
|
"./types": {
|
|
132
132
|
"types": "./types/index.d.ts"
|
|
@@ -141,13 +141,14 @@
|
|
|
141
141
|
"types": "./types/fnx.d.ts"
|
|
142
142
|
},
|
|
143
143
|
"./hooks/nixFor": {
|
|
144
|
-
"types": "./dist/hooks/nixFor.d.ts",
|
|
144
|
+
"types": "./dist-types/hooks/nixFor.d.ts",
|
|
145
145
|
"import": "./dist/hooks/nixFor.js"
|
|
146
146
|
},
|
|
147
147
|
"./package.json": "./package.json"
|
|
148
148
|
},
|
|
149
149
|
"files": [
|
|
150
150
|
"dist/",
|
|
151
|
+
"dist-types/",
|
|
151
152
|
"types/",
|
|
152
153
|
"README.md",
|
|
153
154
|
"LICENSE"
|
|
@@ -192,7 +193,7 @@
|
|
|
192
193
|
"build:types": "tsc --project tsconfig.build.json",
|
|
193
194
|
"type-check": "tsc --noEmit",
|
|
194
195
|
"type-check:watch": "tsc --noEmit --watch",
|
|
195
|
-
"clean": "rimraf dist",
|
|
196
|
+
"clean": "rimraf dist dist-types",
|
|
196
197
|
"lint": "eslint . --ext .fnx,.ts,.tsx,.js,.jsx --max-warnings 0",
|
|
197
198
|
"lint:fix": "eslint . --ext .fnx,.ts,.tsx,.js,.jsx --fix",
|
|
198
199
|
"format": "prettier --write \"**/*.{.fnx,ts,tsx,js,jsx,json,css,md}\"",
|
|
@@ -200,6 +201,8 @@
|
|
|
200
201
|
"test": "vitest run",
|
|
201
202
|
"test:watch": "vitest",
|
|
202
203
|
"test:coverage": "vitest run --coverage",
|
|
204
|
+
"benchmark": "vitest run --config vitest.bench.config.ts --reporter=verbose",
|
|
205
|
+
"benchmark:watch": "vitest --config vitest.bench.config.ts",
|
|
203
206
|
"prepublishOnly": "npm run build",
|
|
204
207
|
"prepack": "npm run build",
|
|
205
208
|
"version": "npm run format && git add -A",
|
|
@@ -212,11 +215,14 @@
|
|
|
212
215
|
"@vitest/coverage-v8": "^2.1.8",
|
|
213
216
|
"esbuild": "^0.24.2",
|
|
214
217
|
"eslint": "^9.18.0",
|
|
218
|
+
"fdir": "^6.5.0",
|
|
219
|
+
"jsdom": "^29.0.0",
|
|
215
220
|
"prettier": "^3.4.2",
|
|
216
221
|
"rimraf": "^6.1.2",
|
|
222
|
+
"rollup": "^4.56.0",
|
|
217
223
|
"typescript": "^5.9.3",
|
|
218
|
-
"
|
|
219
|
-
"
|
|
224
|
+
"vite": "^7.1.11",
|
|
225
|
+
"vitest": "^2.1.8"
|
|
220
226
|
},
|
|
221
227
|
"peerDependencies": {
|
|
222
228
|
"typescript": ">=5.0.0",
|
|
@@ -234,7 +240,7 @@
|
|
|
234
240
|
"typesVersions": {
|
|
235
241
|
"*": {
|
|
236
242
|
"*": [
|
|
237
|
-
"./dist/*"
|
|
243
|
+
"./dist-types/*"
|
|
238
244
|
],
|
|
239
245
|
"types": [
|
|
240
246
|
"./types/index.d.ts"
|
|
@@ -246,9 +252,5 @@
|
|
|
246
252
|
"./types/global.d.ts"
|
|
247
253
|
]
|
|
248
254
|
}
|
|
249
|
-
},
|
|
250
|
-
"dependencies": {
|
|
251
|
-
"fdir": "^6.5.0",
|
|
252
|
-
"rollup": "^4.56.0"
|
|
253
255
|
}
|
|
254
|
-
}
|
|
256
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../context/context.ts"],"names":[],"mappings":"AA8CA,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,GAAG,EAAE,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,QAAQ,EAAE,QAAQ,EAAE,CAAC;IACrB,aAAa,CAAC,EAAE,QAAQ,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1B,cAAc,EAAE,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,qBAAqB,EAAE,QAAQ,EAAE,CAAC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,QAAQ,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,cAAc,EAAE,OAAO,CAAC;CACzB;AAMD,eAAO,IAAI,aAAa,EAAE,gBAAgB,GAAG,IAAW,CAAC;AASzD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,gBAAgB,GAAG,IAAI,GAAG,IAAI,CAEnE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../context/context.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/**\r\n * @fileoverview Component context management for Fynix framework.\r\n * Tracks the currently rendering component to enable hooks to access component state.\r\n */\r\n\r\n/**\r\n * @typedef {Object} ComponentContext\r\n * @property {Array<any>} hooks - Array of hook states\r\n * @property {number} hookIndex - Current hook index during render\r\n * @property {Array<Function>} effects - Array of effect cleanup functions\r\n * @property {Array<Function>} cleanups - Array of cleanup functions\r\n * @property {Array<Function>} [stateCleanups] - Array of state cleanup functions\r\n * @property {Object} _vnode - Associated virtual node\r\n * @property {Set<any>} _accessedStates - Set of states accessed during render\r\n * @property {Set<any>} _subscriptions - Set of active subscriptions\r\n * @property {Array<Function>} _subscriptionCleanups - Array of subscription cleanup functions\r\n * @property {number} version - Component version for tracking updates\r\n * @property {Function|null} rerender - Function to trigger component re-render\r\n * @property {Function} Component - Component function\r\n * @property {boolean} _isMounted - Whether component is mounted\r\n * @property {boolean} _isRerendering - Whether component is currently re-rendering\r\n */\r\n\r\n// TypeScript interface for ComponentContext\r\nexport interface ComponentContext {\r\n hooks: any[];\r\n hookIndex: number;\r\n effects: Function[];\r\n cleanups: Function[];\r\n stateCleanups?: Function[];\r\n _vnode: object;\r\n _accessedStates: Set<any>;\r\n _subscriptions: Set<any>;\r\n _subscriptionCleanups: Function[];\r\n version: number;\r\n rerender: (() => void) | null;\r\n Component: Function;\r\n _isMounted: boolean;\r\n _isRerendering: boolean;\r\n}\r\n\r\n/**\r\n * The currently active component context.\r\n * This is set during component rendering to allow hooks to access the component's state.\r\n */\r\nexport let activeContext: ComponentContext | null = null;\r\n\r\n/**\r\n * Set the active component context.\r\n * Called internally by the runtime when entering/exiting component rendering.\r\n *\r\n * @param ctx - The component context to set as active, or null to clear\r\n * @returns void\r\n */\r\nexport function setActiveContext(ctx: ComponentContext | null): void {\r\n activeContext = ctx;\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AAmEO,IAAI,gBAAyC;AAS7C,SAAS,iBAAiB,KAAoC;AACnE,kBAAgB;AAClB;AAFgB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/custom/button.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../custom/button.ts"],"names":[],"mappings":"AAkEA,wBAAgB,MAAM,CAAC,EAAE,KAAU,EAAE,GAAG,KAAK,EAAE,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,CAEzE"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../custom/button.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/**\r\n * @fileoverview Button component for Fynix applications.\r\n * Simple wrapper around native button element with Fynix integration.\r\n */\r\n\r\nimport { Fynix } from \"../runtime.js\";\r\n\r\n/**\r\n * @typedef {Object} ButtonProps\r\n * @property {string} [value=\"\"] - Button text content\r\n * @property {string} [type=\"button\"] - Button type (button, submit, reset)\r\n * @property {boolean} [disabled=false] - Whether button is disabled\r\n * @property {string} [rc] - Reactive class attribute (Fynix-specific)\r\n * @property {string} [class] - CSS class names\r\n * @property {(this: HTMLElement, event: MouseEvent) => void} [r-click] - Click event handler\r\n */\r\n\r\n/**\r\n * Button component for Fynix applications.\r\n * Renders a native HTML button element with Fynix event handling.\r\n *\r\n * @param {ButtonProps & Record<string, any>} props - Component props\r\n * @returns {VNode} Button element virtual node\r\n *\r\n * @example\r\n * // Basic button\r\n * <Button value=\"Click Me\" />\r\n *\r\n * @example\r\n * // With click handler\r\n * <Button\r\n * value=\"Submit\"\r\n * r-click={() => console.log('Clicked!')}\r\n * />\r\n *\r\n * @example\r\n * // Submit button with styling\r\n * <Button\r\n * value=\"Save\"\r\n * type=\"submit\"\r\n * rc=\"px-4 py-2 bg-blue-500 text-white rounded\"\r\n * />\r\n */\r\n// Use 'any' as the return type to avoid the VNode type export error\r\nexport function Button({ value = \"\", ...props }: Record<string, any>): any {\r\n return Fynix(\"button\", props, value);\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AA2BA,SAAS,aAAa;AAuCf,SAAS,OAAO,EAAE,QAAQ,IAAI,GAAG,MAAM,GAA6B;AACzE,SAAO,MAAM,UAAU,OAAO,KAAK;AACrC;AAFgB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
package/dist/custom/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../custom/index.ts"],"names":[],"mappings":"AA8BA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC"}
|
package/dist/custom/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../custom/index.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/**\r\n * @fileoverview Custom Fynix components export module.\r\n * Re-exports Button and Path components for convenient importing.\r\n *\r\n * @example\r\n * import { Button, Path } from '@fynixorg/ui/custom';\r\n */\r\n\r\nexport { Button } from \"./button\";\r\n\r\nexport { Path } from \"./path\";\r\n"],
|
|
5
|
-
"mappings": "AA8BA,SAAS,cAAc;AAEvB,SAAS,YAAY;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../custom/path.ts"],"names":[],"mappings":"AA0CA,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KAC1C;CACF;AA0CD,wBAAgB,IAAI,CAAC,EACnB,EAAQ,EACR,KAAU,EACV,KAAK,EAAE,UAAe,EACtB,GAAG,KAAK,EACT,EAAE;IACD,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAC;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB,GAAG,GAAG,CAoCN"}
|
package/dist/custom/path.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../custom/path.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/**\r\n * @fileoverview Path component for SPA navigation in Fynix applications.\r\n * Provides client-side routing with prop passing between routes.\r\n */\r\n\r\nimport { Fynix, nixState } from \"../runtime.js\";\r\n\r\n/**\r\n * @typedef {Object} PathProps\r\n * @property {string} [to=\"#\"] - URL to navigate to (relative or absolute)\r\n * @property {string} [value=\"\"] - Link text content\r\n * @property {Record<string, any>} [props={}] - Props to pass to the destination route component\r\n * @property {string} [target] - Link target (_blank, _self, etc.)\r\n * @property {string} [rel] - Link relationship (noopener, noreferrer, etc.)\r\n * @property {string} [rc] - Reactive class attribute (Fynix-specific)\r\n * @property {string} [class] - CSS class names\r\n * @property {string} [id] - Element ID\r\n */\r\n\r\n/** Extend Window interface for __fynixLinkProps__ */\r\ndeclare global {\r\n interface Window {\r\n __fynixLinkProps__?: Record<string, any>;\r\n }\r\n}\r\n\r\n/** Unique counter for props keys */\r\nlet propsCounter = 0;\r\n\r\n/**\r\n * SPA navigation link component for Fynix router.\r\n * Automatically handles client-side navigation and prop passing between routes.\r\n *\r\n * @param {PathProps & Record<string, any>} options - Component props\r\n * @returns {VNode} Anchor element virtual node\r\n *\r\n * @example\r\n * // Basic navigation\r\n * <Path to=\"/about\" value=\"About Us\" />\r\n *\r\n * @example\r\n * // Navigate with props\r\n * <Path\r\n * to=\"/user/123\"\r\n * value=\"View Profile\"\r\n * props={{ userId: 123, fromSearch: true }}\r\n * />\r\n *\r\n * @example\r\n * // External link\r\n * <Path\r\n * to=\"https://github.com\"\r\n * value=\"GitHub\"\r\n * target=\"_blank\"\r\n * rel=\"noopener noreferrer\"\r\n * />\r\n *\r\n * @example\r\n * // With styling\r\n * <Path\r\n * to=\"/dashboard\"\r\n * value=\"Dashboard\"\r\n * rc=\"px-4 py-2 bg-blue-500 text-white rounded\"\r\n * />\r\n */\r\n// Use 'any' as the return type to avoid the VNode type export error\r\nexport function Path({\r\n to = \"#\",\r\n value = \"\",\r\n props: routeProps = {},\r\n ...attrs\r\n}: {\r\n to?: string;\r\n value?: string;\r\n props?: { [key: string]: any };\r\n [key: string]: any;\r\n}): any {\r\n ///console.log(\"[Path Component] Received routeProps:\", routeProps);\r\n\r\n // Wrap plain props in nixState if not already\r\n const wrappedProps: { [key: string]: any } = {};\r\n for (const [k, v] of Object.entries(routeProps as { [key: string]: any })) {\r\n wrappedProps[k] = v && v._isNixState ? v : nixState(v);\r\n }\r\n\r\n // Generate a unique key for this props object\r\n // FIX: Do not use __ prefix as router blocks it for security\r\n const propsKey = `fynixProp_${Date.now()}_${propsCounter++}`;\r\n\r\n // FIX: Store props in the namespace expected by the router\r\n if (!window.__fynixLinkProps__) {\r\n window.__fynixLinkProps__ = {};\r\n }\r\n\r\n // Debug log\r\n // console.log(\"[Path] Storage props:\", propsKey, wrappedProps);\r\n\r\n window.__fynixLinkProps__[propsKey] = wrappedProps;\r\n\r\n // Create the anchor element\r\n const el = Fynix(\r\n \"a\",\r\n {\r\n href: to,\r\n \"data-fynix-link\": true, // SPA link detection\r\n \"data-props-key\": propsKey,\r\n ...attrs,\r\n },\r\n value\r\n );\r\n\r\n return el;\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AA2BA,SAAS,OAAO,gBAAgB;AAsBhC,IAAI,eAAe;AAuCZ,SAAS,KAAK;AAAA,EACnB,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO,aAAa,CAAC;AAAA,EACrB,GAAG;AACL,GAKQ;AAIN,QAAM,eAAuC,CAAC;AAC9C,aAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,UAAoC,GAAG;AACzE,iBAAa,CAAC,IAAI,KAAK,EAAE,cAAc,IAAI,SAAS,CAAC;AAAA,EACvD;AAIA,QAAM,WAAW,aAAa,KAAK,IAAI,CAAC,IAAI,cAAc;AAG1D,MAAI,CAAC,OAAO,oBAAoB;AAC9B,WAAO,qBAAqB,CAAC;AAAA,EAC/B;AAKA,SAAO,mBAAmB,QAAQ,IAAI;AAGtC,QAAM,KAAK;AAAA,IACT;AAAA,IACA;AAAA,MACE,MAAM;AAAA,MACN,mBAAmB;AAAA;AAAA,MACnB,kBAAkB;AAAA,MAClB,GAAG;AAAA,IACL;AAAA,IACA;AAAA,EACF;AAEA,SAAO;AACT;AA9CgB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errorOverlay.d.ts","sourceRoot":"","sources":["../../error/errorOverlay.ts"],"names":[],"mappings":"AAyCA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CA2FnD;AAQD,wBAAgB,kBAAkB,IAAI,IAAI,CAMzC"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../error/errorOverlay.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/**\r\n * @fileoverview Development error overlay for Fynix applications.\r\n * Displays runtime errors in a user-friendly overlay during development.\r\n */\r\n\r\n/**\r\n * Display an error overlay with error details.\r\n * Shows error message, stack trace, and a close button.\r\n *\r\n * @param {Error} error - The error object to display\r\n * @returns {void}\r\n *\r\n * @example\r\n * try {\r\n * // some code\r\n * } catch (err) {\r\n * showErrorOverlay(err);\r\n * }\r\n */\r\nexport function showErrorOverlay(error: Error): void {\r\n removeErrorOverlay();\r\n\r\n const overlay = document.createElement(\"div\");\r\n overlay.id = \"dev-error-overlay\";\r\n Object.assign(overlay.style, {\r\n position: \"fixed\",\r\n inset: 0,\r\n width: \"100%\",\r\n height: \"100%\",\r\n backgroundColor: \"rgba(0, 0, 0, 0.9)\",\r\n color: \"#fff\",\r\n fontFamily: \"Consolas, monospace\",\r\n padding: \"30px\",\r\n zIndex: 99999,\r\n overflowY: \"auto\",\r\n transition: \"opacity 0.25s ease\",\r\n opacity: \"0\",\r\n });\r\n\r\n const container = document.createElement(\"div\");\r\n container.style.position = \"relative\"; // important for absolute button\r\n container.style.maxWidth = \"900px\";\r\n container.style.margin = \"50px auto\";\r\n container.style.background = \"rgba(255, 255, 255, 0.05)\";\r\n container.style.borderRadius = \"8px\";\r\n container.style.padding = \"20px 30px\";\r\n container.style.boxShadow = \"0 0 10px rgba(255, 0, 0, 0.3)\";\r\n\r\n // Close Button\r\n const closeBtn = document.createElement(\"button\");\r\n closeBtn.textContent = \"\u00D7 Close\";\r\n Object.assign(closeBtn.style, {\r\n position: \"absolute\",\r\n top: \"10px\",\r\n right: \"10px\",\r\n background: \"#ff5555\",\r\n color: \"#fff\",\r\n border: \"none\",\r\n padding: \"6px 12px\",\r\n fontSize: \"16px\",\r\n borderRadius: \"4px\",\r\n cursor: \"pointer\",\r\n zIndex: 10,\r\n });\r\n closeBtn.addEventListener(\"click\", () => removeErrorOverlay());\r\n container.appendChild(closeBtn);\r\n\r\n // Title\r\n const title = document.createElement(\"h1\");\r\n title.textContent = \"Runtime Error\";\r\n Object.assign(title.style, {\r\n color: \"#ff5555\",\r\n fontSize: \"24px\",\r\n marginBottom: \"10px\",\r\n });\r\n\r\n // Message\r\n const message = document.createElement(\"pre\");\r\n message.textContent = error?.message || \"Unknown error\";\r\n Object.assign(message.style, {\r\n whiteSpace: \"pre-wrap\",\r\n background: \"rgba(255, 255, 255, 0.1)\",\r\n padding: \"10px\",\r\n borderRadius: \"6px\",\r\n marginTop: \"10px\",\r\n color: \"#ffaaaa\",\r\n });\r\n\r\n // Stack trace\r\n const stack = document.createElement(\"pre\");\r\n stack.textContent = error?.stack || \"\";\r\n Object.assign(stack.style, {\r\n whiteSpace: \"pre-wrap\",\r\n marginTop: \"15px\",\r\n color: \"#ccc\",\r\n });\r\n\r\n container.appendChild(title);\r\n container.appendChild(message);\r\n container.appendChild(stack);\r\n overlay.appendChild(container);\r\n document.body.appendChild(overlay);\r\n\r\n // Smooth fade-in\r\n requestAnimationFrame(() => {\r\n overlay.style.opacity = \"1\";\r\n });\r\n\r\n // Console log\r\n console.error(\"[FynixJS Runtime Error]\", error);\r\n}\r\n\r\n/**\r\n * Remove the error overlay from the DOM.\r\n * Fades out the overlay before removing it.\r\n *\r\n * @returns {void}\r\n */\r\nexport function removeErrorOverlay(): void {\r\n const existing = document.getElementById(\"dev-error-overlay\");\r\n if (existing) {\r\n existing.style.opacity = \"0\";\r\n setTimeout(() => existing.remove(), 200);\r\n }\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AAyCO,SAAS,iBAAiB,OAAoB;AACnD,qBAAmB;AAEnB,QAAM,UAAU,SAAS,cAAc,KAAK;AAC5C,UAAQ,KAAK;AACb,SAAO,OAAO,QAAQ,OAAO;AAAA,IAC3B,UAAU;AAAA,IACV,OAAO;AAAA,IACP,OAAO;AAAA,IACP,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,SAAS;AAAA,IACT,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,YAAY;AAAA,IACZ,SAAS;AAAA,EACX,CAAC;AAED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AS,KAAK,YAAY,OAAO;AAGjC,wBAAsB,MAAM;AAC1B,YAAQ,MAAM,UAAU;AAAA,EAC1B,CAAC;AAGD,UAAQ,MAAM,2BAA2B,KAAK;AAChD;AA3FgB;AAmGT,SAAS,qBAA2B;AACzC,QAAM,WAAW,SAAS,eAAe,mBAAmB;AAC5D,MAAI,UAAU;AACZ,aAAS,MAAM,UAAU;AACzB,eAAW,MAAM,SAAS,OAAO,GAAG,GAAG;AAAA,EACzC;AACF;AANgB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../fynix/index.ts"],"names":[],"mappings":"AA2BA,cAAc,eAAe,CAAC;AAE9B,cAAc,qBAAqB,CAAC;AACpC,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/fynix/index.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../fynix/index.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n// fynix/index.js - Single entry point for all core functionality\r\n\r\n/// <reference path=\"../types/jsx.d.ts\" />\r\n/// <reference path=\"../types/global.d.ts\" />\r\n\r\nexport * from \"../runtime.js\";\r\n// Re-export Fynix namespace and hooks under new names\r\nexport * from \"../router/router.js\";\r\nexport { default as createFynix } from \"../router/router.js\";\r\nexport { Fynix } from \"../runtime.js\";\r\nexport { For } from \"../hooks/nixFor.js\";\r\n"],
|
|
5
|
-
"mappings": "AA2BA,cAAc;AAEd,cAAc;AACd,SAAoB,WAAXA,gBAA8B;AACvC,SAAS,aAAa;AACtB,SAAS,WAAW;",
|
|
6
|
-
"names": ["default"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nixAsync.d.ts","sourceRoot":"","sources":["../../hooks/nixAsync.ts"],"names":[],"mappings":"AAmCA,wBAAgB,QAAQ,CAAC,CAAC,EACxB,cAAc,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACnD,OAAO,GAAE;IACP,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,OAAO,CAAC;CACd,GACL;IACD,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;IAC1B,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;KAAE,CAAC;IAC/B,OAAO,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5B,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,SAAS,EAAE,MAAM,MAAM,CAAC;CACzB,CA8IA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../hooks/nixAsync.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n\r\nimport { nixState } from \"./nixState\";\r\n\r\n/**\r\n * Async state helper with AbortController support and race condition protection.\r\n *\r\n * @template T\r\n * @param {(signal: AbortSignal) => Promise<T>} promiseFactory\r\n * @param {Object} options - Configuration options\r\n * @param {number} options.timeout - Request timeout in milliseconds (default: 30000)\r\n * @param {number} options.retries - Number of retry attempts (default: 0)\r\n * @param {boolean} options.autoRun - Whether to run immediately (default: false)\r\n */\r\nexport function nixAsync<T>(\r\n promiseFactory: (signal: AbortSignal) => Promise<T>,\r\n options: {\r\n timeout?: number;\r\n retries?: number;\r\n autoRun?: boolean;\r\n } = {}\r\n): {\r\n data: { value: T | null };\r\n error: { value: Error | null };\r\n loading: { value: boolean };\r\n run: () => Promise<void>;\r\n cancel: () => void;\r\n cleanup: () => void;\r\n getCallId: () => number;\r\n} {\r\n const { timeout = 30000, retries = 0, autoRun = false } = options;\r\n\r\n if (typeof promiseFactory !== \"function\") {\r\n throw new TypeError(\"[nixAsync] promiseFactory must be a function\");\r\n }\r\n\r\n const data = nixState<T | null>(null);\r\n const error = nixState<Error | null>(null);\r\n const loading = nixState<boolean>(false);\r\n\r\n let active = true;\r\n let controller: AbortController | null = null;\r\n let callId = 0;\r\n let timeoutId: NodeJS.Timeout | null = null;\r\n let retryCount = 0;\r\n\r\n const cleanup = (): void => {\r\n active = false;\r\n if (controller) {\r\n controller.abort();\r\n controller = null;\r\n }\r\n if (timeoutId) {\r\n clearTimeout(timeoutId);\r\n timeoutId = null;\r\n }\r\n callId = 0;\r\n retryCount = 0;\r\n };\r\n\r\n const run = async (): Promise<void> => {\r\n if (!active) {\r\n console.warn(\"[nixAsync] Attempted to run on destroyed async hook\");\r\n return;\r\n }\r\n\r\n // Cancel previous request\r\n if (controller) {\r\n controller.abort();\r\n }\r\n if (timeoutId) {\r\n clearTimeout(timeoutId);\r\n }\r\n\r\n controller = new AbortController();\r\n const signal = controller.signal;\r\n const currentCallId = ++callId;\r\n retryCount = 0;\r\n\r\n loading.value = true;\r\n error.value = null;\r\n\r\n // Set timeout\r\n if (timeout > 0) {\r\n timeoutId = setTimeout(() => {\r\n if (controller && currentCallId === callId) {\r\n controller.abort();\r\n if (active && currentCallId === callId) {\r\n error.value = new Error(`Request timeout after ${timeout}ms`);\r\n loading.value = false;\r\n }\r\n }\r\n }, timeout);\r\n }\r\n\r\n try {\r\n const result = await promiseFactory(signal);\r\n\r\n // Check if this is still the current call and component is active\r\n if (!active || currentCallId !== callId || signal.aborted) {\r\n return;\r\n }\r\n\r\n data.value = result;\r\n retryCount = 0;\r\n } catch (e: unknown) {\r\n // Check if this is still the current call and component is active\r\n if (!active || currentCallId !== callId) {\r\n return;\r\n }\r\n\r\n // Don't set error if aborted (user cancelled)\r\n if (signal.aborted) {\r\n return;\r\n }\r\n\r\n const errorInstance = e instanceof Error ? e : new Error(String(e));\r\n\r\n // Retry logic\r\n if (retryCount < retries && active && currentCallId === callId) {\r\n retryCount++;\r\n console.warn(\r\n `[nixAsync] Retrying (${retryCount}/${retries}):`,\r\n errorInstance.message\r\n );\r\n // Exponential backoff: 1s, 2s, 4s, etc.\r\n const retryDelay = Math.min(1000 * Math.pow(2, retryCount - 1), 10000);\r\n setTimeout(() => {\r\n if (active && currentCallId === callId) {\r\n run();\r\n }\r\n }, retryDelay);\r\n return;\r\n }\r\n\r\n error.value = errorInstance;\r\n } finally {\r\n if (timeoutId) {\r\n clearTimeout(timeoutId);\r\n timeoutId = null;\r\n }\r\n\r\n if (active && currentCallId === callId && !signal.aborted) {\r\n loading.value = false;\r\n }\r\n }\r\n };\r\n\r\n const cancel = (): void => {\r\n if (controller) {\r\n controller.abort();\r\n }\r\n if (timeoutId) {\r\n clearTimeout(timeoutId);\r\n timeoutId = null;\r\n }\r\n loading.value = false;\r\n retryCount = 0;\r\n };\r\n\r\n const getCallId = (): number => callId;\r\n\r\n // Auto-run if requested\r\n if (autoRun) {\r\n // Use setTimeout to avoid running during component initialization\r\n setTimeout(() => {\r\n if (active) run();\r\n }, 0);\r\n }\r\n\r\n return { data, error, loading, run, cancel, cleanup, getCallId };\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AAuBA,SAAS,gBAAgB;AAYlB,SAAS,SACd,gBACA,UAII,CAAC,GASL;AACA,QAAM,EAAE,UAAU,KAAO,UAAU,GAAG,UAAU,MAAM,IAAI;AA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appings":"AAoEA,wBAAgB,cAAc,CAC5B,GAAG,EAAE,GAAG,EACR,cAAc,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,EAClC,OAAO,GAAE;IACP,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC;CAChC,GACL;IACD,IAAI,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC;IACrB,KAAK,EAAE;QAAE,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC;IACtB,OAAO,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5B,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,UAAU,EAAE,MAAM,IAAI,CAAC;CACxB,CA6IA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../hooks/nixAsyncCache.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\nimport { nixState } from \"./nixState\";\r\n\r\nconst asyncCache: Map<\r\n any,\r\n {\r\n data?: any;\r\n promise?: Promise<any>;\r\n timestamp?: number;\r\n ttl?: number;\r\n }\r\n> = new Map();\r\n\r\n// Cache cleanup to prevent memory leaks\r\nconst CACHE_CLEANUP_INTERVAL = 60000; // 1 minute\r\nlet cacheCleanupTimer: NodeJS.Timeout | null = null;\r\n\r\nconst startCacheCleanup = () => {\r\n if (cacheCleanupTimer) return;\r\n\r\n cacheCleanupTimer = setInterval(() => {\r\n const now = Date.now();\r\n const entries = Array.from(asyncCache.entries());\r\n\r\n for (const [key, entry] of entries) {\r\n if (entry.timestamp && entry.ttl && now - entry.timestamp > entry.ttl) {\r\n asyncCache.delete(key);\r\n }\r\n }\r\n\r\n // If cache is empty, stop cleanup timer\r\n if (asyncCache.size === 0 && cacheCleanupTimer) {\r\n clearInterval(cacheCleanupTimer);\r\n cacheCleanupTimer = null;\r\n }\r\n }, CACHE_CLEANUP_INTERVAL);\r\n};\r\n\r\n/**\r\n * Cached async hook with enhanced security and memory management.\r\n *\r\n * @param {any} key - Cache key (must be serializable)\r\n * @param {() => Promise<any>} promiseFactory - Function that returns a promise\r\n * @param {object} options - Configuration options\r\n * @returns {object} Reactive state object with data, error, loading, and control methods\r\n */\r\n\r\nexport function nixAsyncCached(\r\n key: any,\r\n promiseFactory: () => Promise<any>,\r\n options: {\r\n ttl?: number; // Time to live in ms\r\n maxCacheSize?: number;\r\n validateKey?: (key: any) => boolean;\r\n } = {}\r\n): {\r\n data: { value: any };\r\n error: { value: any };\r\n loading: { value: boolean };\r\n run: () => Promise<void>;\r\n cancel: () => void;\r\n clearCache: () => void;\r\n} {\r\n // Input validation\r\n if (!promiseFactory || typeof promiseFactory !== \"function\") {\r\n throw new Error(\"[nixAsyncCache] promiseFactory must be a function\");\r\n }\r\n\r\n // Validate cache key\r\n if (key == null) {\r\n throw new Error(\"[nixAsyncCache] Key cannot be null or undefined\");\r\n }\r\n\r\n if (options.validateKey && !options.validateKey(key)) {\r\n throw new Error(\"[nixAsyncCache] Invalid cache key\");\r\n }\r\n\r\n const { ttl = 300000, maxCacheSize = 100 } = options; // 5 min default TTL\r\n\r\n // Enforce cache size limits to prevent memory attacks\r\n if (asyncCache.size >= maxCacheSize) {\r\n // Remove oldest entries\r\n const entries = Array.from(asyncCache.entries());\r\n const entriesToRemove = Math.max(1, Math.floor(maxCacheSize * 0.1)); // Remove 10%\r\n\r\n for (let i = 0; i < entriesToRemove; i++) {\r\n const entry = entries[i];\r\n if (entry) {\r\n asyncCache.delete(entry[0]);\r\n }\r\n }\r\n }\r\n\r\n const data = nixState(null) as { value: any };\r\n const error = nixState(null) as { value: any };\r\n const loading = nixState(false) as { value: boolean };\r\n\r\n let active: boolean = true;\r\n let abortController: AbortController | null = null;\r\n\r\n startCacheCleanup();\r\n\r\n const run = async (): Promise<void> => {\r\n if (!active) return;\r\n\r\n // Cancel previous request if still running\r\n if (abortController) {\r\n abortController.abort();\r\n }\r\n\r\n abortController = new AbortController();\r\n loading.value = true;\r\n error.value = null;\r\n\r\n try {\r\n // Cache hit with resolved data\r\n if (asyncCache.has(key)) {\r\n const cached = asyncCache.get(key)!;\r\n const now = Date.now();\r\n\r\n // Check TTL\r\n if (cached.timestamp && now - cached.timestamp > ttl) {\r\n asyncCache.delete(key);\r\n } else if (cached.data !== undefined) {\r\n data.value = cached.data;\r\n loading.value = false;\r\n return;\r\n }\r\n\r\n // Deduping: reuse in-flight promise if still valid\r\n if (cached.promise) {\r\n try {\r\n const result = await cached.promise;\r\n if (!active || abortController?.signal.aborted) return;\r\n data.value = result;\r\n loading.value = false;\r\n return;\r\n } catch (e) {\r\n if (!active || abortController?.signal.aborted) return;\r\n error.value = e;\r\n loading.value = false;\r\n return;\r\n }\r\n }\r\n }\r\n\r\n // Cache miss - create new promise\r\n const promise = Promise.resolve().then(() => {\r\n if (abortController?.signal.aborted) {\r\n throw new Error(\"Request was aborted\");\r\n }\r\n return promiseFactory();\r\n });\r\n\r\n asyncCache.set(key, {\r\n promise,\r\n timestamp: Date.now(),\r\n ttl,\r\n });\r\n\r\n const result = await promise;\r\n\r\n if (!active || abortController?.signal.aborted) return;\r\n\r\n // Cache successful result\r\n asyncCache.set(key, {\r\n data: result,\r\n timestamp: Date.now(),\r\n ttl,\r\n });\r\n\r\n data.value = result;\r\n } catch (e) {\r\n // Remove failed promise from cache\r\n if (asyncCache.has(key)) {\r\n const cached = asyncCache.get(key)!;\r\n if (cached.promise && !cached.data) {\r\n asyncCache.delete(key);\r\n }\r\n }\r\n\r\n if (!active || abortController?.signal.aborted) return;\r\n error.value = e;\r\n } finally {\r\n if (active && !abortController?.signal.aborted) {\r\n loading.value = false;\r\n }\r\n }\r\n };\r\n\r\n const cancel = (): void => {\r\n active = false;\r\n if (abortController) {\r\n abortController.abort();\r\n abortController = null;\r\n }\r\n };\r\n\r\n const clearCache = (): void => {\r\n asyncCache.delete(key);\r\n };\r\n\r\n return { data, error, loading, run, cancel, clearCache };\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AAsBA,SAAS,gBAAgB;AAEzB,MAAM,aAQF,oBAAI,IAAI;AAGZ,MAAM,yBAAyB;AAC/B,IAAI,oBAA2C;AAE/C,MAAM,oBAAoB,6BAAM;AAC9B,MAAI,kBAAmB;AAEvB,sBAAoB,YAAY,MAAM;AACpC,UAAM,MAAM,KAAK,IAAI;AACrB,UAAM,UAAU,MAAM,KAAK,WAAW,QAAQ,CAAC;AAE/C,eAAW,CAAC,KAAK,KAAK,KAAK,SAAS;AAClC,UAAI,MAAM,aAAa,MAAM,OAAO,MAAM,MAAM,YAAY,MAAM,KAAK;AACrE,mBAAW,OAAO,GAAG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
-
"version": 3,
|
|
3
|
-
"sources": ["../../hooks/nixAsyncDebounce.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\nimport { nixState } from \"./nixState\";\r\n\r\n/**\r\n * Debounced and cancellable async data fetcher with caching and deduping.\r\n *\r\n * @param {() => Promise<any>} promiseFactory - Async function that returns a promise.\r\n * @param {Object} [options={}] - Options for debounce, caching, and abort.\r\n * @param {number} [options.delay=300] - Debounce delay in ms.\r\n * @param {boolean} [options.leading=false] - Run on leading edge.\r\n * @param {boolean} [options.trailing=true] - Run on trailing edge.\r\n * @param {number} [options.maxWait] - Max wait time before forced invocation.\r\n * @param {boolean} [options.cache=true] - Enable caching of last result.\r\n * @param {AbortSignal} [options.signal] - Optional AbortSignal to cancel request.\r\n * @returns {Object} { data, error, loading, run, cancel }\r\n *\r\n * @example\r\n * const controller = new AbortController();\r\n * const { data, error, loading, run, cancel } = nixAsyncDebounce(\r\n * () => fetch('/api/data').then(r => r.json()),\r\n * { delay: 500, maxWait: 2000, leading: true, signal: controller.signal }\r\n * );\r\n */\r\nexport interface NixAsyncDebounceOptions {\r\n delay?: number;\r\n leading?: boolean;\r\n trailing?: boolean;\r\n maxWait?: number;\r\n cache?: boolean;\r\n signal?: AbortSignal;\r\n}\r\n\r\nexport function nixAsyncDebounce(\r\n promiseFactory: () => Promise<any>,\r\n options: NixAsyncDebounceOptions = {}\r\n): {\r\n data: { value: any };\r\n error: { value: any };\r\n loading: { value: boolean };\r\n run: () => void | Promise<any>;\r\n cancel: () => void;\r\n} {\r\n const data = nixState(null) as { value: any };\r\n const error = nixState(null) as { value: any };\r\n const loading = nixState(false) as { value: boolean };\r\n\r\n const {\r\n delay = 300,\r\n leading = false,\r\n trailing = true,\r\n maxWait,\r\n cache = true,\r\n signal,\r\n } = options;\r\n\r\n let lastResult: any = null;\r\n let lastError: any = null;\r\n let timerId: ReturnType<typeof setTimeout> | null = null;\r\n let lastInvokeTime: number = 0;\r\n let pendingPromise: Promise<any> | null = null;\r\n\r\n const invoke = async (): Promise<any> => {\r\n if (cache && lastResult !== null) {\r\n data.value = lastResult;\r\n error.value = lastError;\r\n loading.value = false;\r\n return lastResult;\r\n }\r\n\r\n loading.value = true;\r\n error.value = null;\r\n\r\n const abortController = new AbortController();\r\n if (signal) {\r\n signal.addEventListener(\"abort\", () => {\r\n abortController.abort();\r\n cancel();\r\n });\r\n }\r\n\r\n pendingPromise = promiseFactory();\r\n\r\n try {\r\n const result = await pendingPromise;\r\n lastResult = result;\r\n data.value = result;\r\n return result;\r\n } catch (e: any) {\r\n if (e.name !== \"AbortError\") {\r\n lastError = e;\r\n error.value = e;\r\n }\r\n throw e;\r\n } finally {\r\n loading.value = false;\r\n pendingPromise = null;\r\n lastInvokeTime = Date.now();\r\n }\r\n };\r\n\r\n const run = (): void | Promise<any> => {\r\n const now = Date.now();\r\n const timeSinceLastInvoke = now - lastInvokeTime;\r\n const remainingTime = delay - timeSinceLastInvoke;\r\n\r\n const shouldInvokeLeading = leading && !timerId;\r\n\r\n if (maxWait !== undefined && timeSinceLastInvoke >= maxWait) {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n return invoke();\r\n }\r\n\r\n if (timerId) clearTimeout(timerId);\r\n\r\n if (shouldInvokeLeading) return invoke();\r\n\r\n if (trailing) {\r\n timerId = setTimeout(\r\n () => {\r\n timerId = null;\r\n invoke();\r\n },\r\n remainingTime > 0 ? remainingTime : delay\r\n );\r\n }\r\n };\r\n\r\n const cancel = (): void => {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n pendingPromise = null;\r\n };\r\n\r\n return { data, error, loading, run, cancel };\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AAsBA,SAAS,gBAAgB;AA+BlB,SAAS,iBACd,gBACA,UAAmC,CAAC,GAOpC;AACA,QAAM,OAAO,SAAS,IAAI;AAC1B,QAAM,QAAQ,SAAS,IAAI;AAC3B,QAAM,UAAU,SAAS,KAAK;AAE9B,QAAM;AAAA,IACJ,QAAQ;AAAA,IACR,UAAU;AAAA,IACV,WAAW;AAAA,IACX;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,EACF,IAAI;AAEJ,MAAI,aAAkB;AACtB,MAAI,YAAiB;AACrB,MAAI,UAAgD;AACpD,MAAI,iBAAyB;AAC7B,MAAI,iBAAsC;AAE1C,QAAM,SAAS,mCAA0B;AACvC,QAAI,SAAS,eAAe,MAAM;AAChC,WAAK,QAAQ;AACb,YAAM,QAAQ;AACd,cAAQ,QAAQ;AAChB,aAAO;AAAA,IACT;AAEA,YAAQ,QAAQ;AAChB,UAAM,QAAQ;AAEd,UAAM,kBAAkB,IAAI,gBAAgB;AAC5C,QAAI,QAAQ;AACV,aAAO,iBAAiB,SAAS,MAAM;AACrC,wBAAgB,MAAM;AACtB,eAAO;AAAA,MACT,CAAC;AAAA,IACH;AAEA,qBAAi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,EAC5C,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC7B;IACD,IAAI,EAAE;QAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAA;KAAE,CAAC;IAC1B,KAAK,EAAE;QAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;KAAE,CAAC;IAC/B,OAAO,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5B,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACzB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CA+FA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../hooks/nixAsyncQuery.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\nimport { nixState } from \"./nixState\";\r\n\r\n/**\r\n * Global async cache.\r\n * key -> {\r\n * data?: any,\r\n * error?: Error,\r\n * promise?: Promise<any>,\r\n * controller?: AbortController,\r\n * timestamp?: number\r\n * }\r\n */\r\nconst asyncCache: Map<\r\n string,\r\n {\r\n data?: any;\r\n error?: Error;\r\n promise?: Promise<any>;\r\n controller?: AbortController;\r\n timestamp?: number;\r\n }\r\n> = new Map();\r\n\r\n/**\r\n * Unified async query helper with:\r\n * - AbortController cancellation\r\n * - Request deduping\r\n * - Shared caching\r\n *\r\n * @template T\r\n * @param {string} key\r\n * Unique cache key representing the request\r\n *\r\n * @param {(signal: AbortSignal) => Promise<T>} queryFn\r\n * Function that performs the async operation\r\n *\r\n * @param {{\r\n * ttl?: number\r\n * }} [options]\r\n *\r\n * @returns {{\r\n * data: { value: T | null },\r\n * error: { value: Error | null },\r\n * loading: { value: boolean },\r\n * run: () => Promise<void>,\r\n * cancel: () => void\r\n * }}\r\n */\r\nexport function nixAsyncQuery<T>(\r\n key: string,\r\n queryFn: (signal: AbortSignal) => Promise<T>,\r\n options: { ttl?: number } = {}\r\n): {\r\n data: { value: T | null };\r\n error: { value: Error | null };\r\n loading: { value: boolean };\r\n run: () => Promise<void>;\r\n cancel: () => void;\r\n} {\r\n const data = nixState(null) as { value: T | null };\r\n const error = nixState(null) as { value: Error | null };\r\n const loading = nixState(false) as { value: boolean };\r\n\r\n const ttl: number = options.ttl ?? 0;\r\n let active: boolean = true;\r\n let callId: number = 0;\r\n\r\n const run = async (): Promise<void> => {\r\n const id = ++callId;\r\n loading.value = true;\r\n error.value = null;\r\n\r\n const now = Date.now();\r\n const cached = asyncCache.get(key);\r\n\r\n // Serve fresh cached data\r\n if (\r\n cached?.data &&\r\n (!ttl ||\r\n (typeof cached.timestamp === \"number\" && now - cached.timestamp < ttl))\r\n ) {\r\n data.value = cached.data;\r\n loading.value = false;\r\n return;\r\n }\r\n\r\n // Deduping: reuse in-flight request\r\n if (cached?.promise) {\r\n try {\r\n const result = await cached.promise;\r\n if (!active || id !== callId) return;\r\n // Sanitize result before storing in state\r\n const safeResult =\r\n typeof result === \"object\" && result !== null\r\n ? JSON.parse(JSON.stringify(result))\r\n : result;\r\n data.value = safeResult;\r\n } catch (e: any) {\r\n if (!active || id !== callId) return;\r\n error.value = e instanceof Error ? e : new Error(String(e));\r\n } finally {\r\n if (active && id === callId) loading.value = false;\r\n }\r\n return;\r\n }\r\n\r\n // New request\r\n const controller = new AbortController();\r\n const promise = (async () => {\r\n try {\r\n const result = await queryFn(controller.signal);\r\n asyncCache.set(key, {\r\n data: result,\r\n timestamp: Date.now(),\r\n });\r\n return result;\r\n } catch (e) {\r\n asyncCache.delete(key);\r\n throw e instanceof Error ? e : new Error(String(e));\r\n }\r\n })();\r\n\r\n asyncCache.set(key, { promise, controller });\r\n\r\n try {\r\n const result = await promise;\r\n if (!active || id !== callId) return;\r\n // Sanitize result before storing in state\r\n const safeResult =\r\n typeof result === \"object\" && result !== null\r\n ? JSON.parse(JSON.stringify(result))\r\n : result;\r\n data.value = safeResult;\r\n } catch (e: any) {\r\n if (!active || id !== callId) return;\r\n error.value = e instanceof Error ? e : new Error(String(e));\r\n } finally {\r\n if (active && id === callId) loading.value = false;\r\n }\r\n };\r\n\r\n /**\r\n * Cancels in-flight request and prevents state updates.\r\n */\r\n const cancel = (): void => {\r\n active = false;\r\n const cached = asyncCache.get(key);\r\n if (cached?.controller) {\r\n cached.controller.abort();\r\n }\r\n };\r\n\r\n return { data, error, loading, run, cancel };\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AAsBA,SAAS,gBAAgB;AAYzB,MAAM,aASF,oBAAI,IAAI;AA2BL,SAAS,cACd,KACA,SACA,UAA4B,CAAC,GAO7B;AACA,QAAM,OAAO,SAAS,IAAI;AAC1B,QAAM,QAAQ,SAAS,IAAI;AAC3B,QAAM,UAAU,SAAS,KAAK;AAE9B,QAAM,MAAc,QAAQ,OAAO;AACnC,MAAI,SAAkB;AACtB,MAAI,SA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,OAAO,WAAW,YAAY,WAAW,OACrC,KAAK,MAAM,KAAK,UAAU,MAAM,CAAC,IACjC;AACN,WAAK,QAAQ;AAAA,IACf,SAAS,GAAQ;AACf,UAAI,CAAC,UAAU,OAAO,OAAQ;AAC9B,YAAM,QAAQ,aAAa,QAAQ,IAAI,IAAI,MAAM,OAAO,CAAC,CAAC;AAAA,IAC5D,UAAE;AACA,UAAI,UAAU,OAAO,OAAQ,SAAQ,QAAQ;AAAA,IAC/C;AAAA,EACF,GAxEY;AA6EZ,QAAM,SAAS,6BAAY;AACzB,aAAS;AACT,UAAM,SAAS,WAAW,IAAI,GAAG;AACjC,QAAI,QAAQ,YAAY;AACtB,aAAO,WAAW,MAAM;AAAA,IAC1B;AAAA,EACF,GANe;AAQf,SAAO,EAAE,MAAM,OAAO,SAAS,KAAK,OAAO;AAC7C;AAzGgB;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nixCallback.d.ts","sourceRoot":"","sources":["../../hooks/nixCallback.ts"],"names":[],"mappings":"AAqDA,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAC3D,EAAE,EAAE,CAAC,EACL,IAAI,GAAE,GAAG,EAAO,GACf,CAAC,CAiCH"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../hooks/nixCallback.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\nimport { activeContext } from \"../context/context\";\r\n\r\n/**\r\n * Memoizes a callback function based on a dependency array.\r\n * Similar to React's useCallback.\r\n *\r\n * @param {Function} fn\r\n * Function to memoize. Should be pure and not mutate external state.\r\n *\r\n * @param {Array<any>} [deps=[]]\r\n * Dependency array. Callback identity changes only when deps change.\r\n *\r\n * @returns {Function}\r\n * Memoized callback function.\r\n *\r\n * @throws {Error}\r\n * If called outside of a component context.\r\n *\r\n * @example\r\n * const onClick = nixCallback(() => {\r\n * console.log(count.value);\r\n * }, [count.value]);\r\n *\r\n * @security\r\n * - Avoids JSON.stringify to prevent crashes on circular references\r\n * - Limits dependency array size to prevent performance abuse\r\n *\r\n * @memory\r\n * - Does not allocate large temporary strings\r\n * - Reuses function reference when deps are unchanged\r\n */\r\nexport function nixCallback<T extends (...args: any[]) => any>(\r\n fn: T,\r\n deps: any[] = []\r\n): T {\r\n const ctx = activeContext as {\r\n hookIndex: number;\r\n hooks: Array<{ value: T; deps: any[] } | undefined>;\r\n };\r\n if (!ctx) throw new Error(\"nixCallback() called outside component\");\r\n\r\n if (typeof fn !== \"function\") {\r\n console.error(\"[nixCallback] First argument must be a function\");\r\n return fn;\r\n }\r\n\r\n if (!Array.isArray(deps)) {\r\n console.error(\"[nixCallback] Second argument must be an array\");\r\n deps = [];\r\n }\r\n\r\n const MAX_DEPS = 100;\r\n if (deps.length > MAX_DEPS) {\r\n console.warn(\r\n `[nixCallback] Dependency array too large (${deps.length}). Limited to ${MAX_DEPS}.`\r\n );\r\n deps = deps.slice(0, MAX_DEPS);\r\n }\r\n\r\n const idx: number = ctx.hookIndex++;\r\n const prev: { value: T; deps: any[] } | undefined = ctx.hooks[idx];\r\n\r\n if (!prev || !shallowArrayEqual(prev.deps, deps)) {\r\n ctx.hooks[idx] = { value: fn, deps };\r\n }\r\n\r\n return ctx.hooks[idx]!.value;\r\n}\r\n\r\n/**\r\n * Shallow comparison for dependency arrays.\r\n *\r\n * @param {Array<any>} a\r\n * @param {Array<any>} b\r\n * @returns {boolean}\r\n */\r\nfunction shallowArrayEqual(a: any[], b: any[]): boolean {\r\n if (a.length !== b.length) return false;\r\n for (let i = 0; i < a.length; i++) {\r\n if (!Object.is(a[i], b[i])) return false;\r\n }\r\n return true;\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AAsBA,SAAS,qBAAqB;AA+BvB,SAAS,YACd,IACA,OAAc,CAAC,GACZ;AACH,QAAM,MAAM;AAIZ,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,wCAAwC;AAElE,MAAI,OAAO,OAAO,YAAY;AAC5B,YAAQ,MAAM,iDAAiD;AAC/D,WAAO;AAAA,EACT;AAEA,MAAI,CAAC,MAAM,QAAQ,IAAI,GAAG;AACxB,YAAQ,MAAM,gDAAgD;AAC9D,WAAO,CAAC;AAAA,EACV;AAEA,QAAM,WAAW;AACjB,MAAI,KAAK,SAAS,UAAU;AAC1B,YAAQ;AAAA,MACN,6CAA6C,KAAK,MAAM,iBAAiB,QAAQ;AAAA,IACnF;AACA,WAAO,KAAK,MAAM,GAAG,QAAQ;AAAA,EAC/B;AAEA,QAAM,MAAc,IAAI;AACxB,QAAM,OAA8C,IAAI,MAAM,GAAG;AAEjE,MAAI,CAAC,QAAQ,CAAC,kBAAkB,KAAK,MAAM,IAAI,GAAG;AAChD,QAAI,MAAM,GAAG,IAAI,EAAE,OAAO,IAAI,KAAK;AAAA,EACrC;AAEA,SAAO,IAAI,MAAM,GAAG,EAAG;AACzB;AApCgB;AA6ChB,SAAS,kBAAkB,GAAU,GAAmB;AACtD,MAAI,EAAE,WAAW,EAAE,OAAQ,QAAO;AAClC,WAAS,IAAI,GAAG,IAAI,EAAE,QAAQ,KAAK;AACjC,QAAI,CAAC,OAAO,GAAG,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAG,QAAO;AAAA,EACrC;AACA,SAAO;AACT;AANS;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nixComputed.d.ts","sourceRoot":"","sources":["../../hooks/nixComputed.ts"],"names":[],"mappings":"AAuFA,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,GAAG;IAClD,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,KAAK,MAAM,IAAI,CAAC;IAClD,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kBAAkB,EAAE,MAAM,MAAM,CAAC;IACjC,kBAAkB,EAAE,MAAM,MAAM,CAAC;IACjC,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,iBAAiB,EAAE,MAAM,KAAK,CAAC;QAC7B,KAAK,EAAE,GAAG,CAAC;QACX,UAAU,EAAE,OAAO,CAAC;QACpB,UAAU,EAAE,OAAO,CAAC;KACrB,CAAC,CAAC;IACH,WAAW,EAAE,IAAI,CAAC;IAClB,WAAW,EAAE,IAAI,CAAC;CACnB,CA8LA"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../hooks/nixComputed.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/* ----------------------\r\n nixComputed - Computed/Derived State\r\n Memory Leaks & Security Issues Resolved\r\n---------------------- */\r\nimport { activeContext, setActiveContext } from \"../context/context\";\r\n\r\n/**\r\n * @template T\r\n * @typedef {Object} ComputedState\r\n * @property {T} value - Get the computed value (read-only)\r\n * @property {(fn: (value: T) => void) => (() => void)} subscribe - Subscribe to computed value changes\r\n * @property {() => void} cleanup - Cleanup all subscriptions and dependencies\r\n * @property {() => number} getSubscriberCount - Get number of active subscribers (debugging)\r\n * @property {() => number} getDependencyCount - Get number of tracked dependencies (debugging)\r\n * @property {() => boolean} isDestroyed - Check if computed state has been destroyed\r\n * @property {boolean} _isNixState - Internal flag (computed states behave like states)\r\n * @property {boolean} _isComputed - Internal flag to identify computed states\r\n */\r\n\r\n/**\r\n * Create a derived/computed state from other states.\r\n * Automatically tracks dependencies and updates when any dependency changes.\r\n *\r\n * @template T\r\n * @param {() => T} computeFn - Function that computes the derived value\r\n * @returns {ComputedState<T>} A reactive state object with the computed value\r\n *\r\n * @example\r\n * const count = nixState(5);\r\n * const doubled = nixComputed(() => count.value * 2);\r\n * console.log(doubled.value); // 10\r\n * count.value = 10;\r\n * console.log(doubled.value); // 20\r\n *\r\n * @example\r\n * // Multiple dependencies\r\n * const a = nixState(5);\r\n * const b = nixState(10);\r\n * const sum = nixComputed(() => a.value + b.value);\r\n * console.log(sum.value); // 15\r\n *\r\n * @example\r\n * // Conditional dependencies\r\n * const flag = nixState(true);\r\n * const x = nixState(1);\r\n * const y = nixState(2);\r\n * const result = nixComputed(() => flag.value ? x.value : y.value);\r\n *\r\n * @example\r\n * // With cleanup\r\n * const MyComponent = () => {\r\n * const count = nixState(0);\r\n * const doubled = nixComputed(() => count.value * 2);\r\n *\r\n * nixEffect(() => {\r\n * return () => {\r\n * doubled.cleanup();\r\n * count.cleanup();\r\n * };\r\n * }, []);\r\n * };\r\n *\r\n * @throws {Error} If called outside a component context\r\n * @throws {TypeError} If computeFn is not a function\r\n */\r\nexport function nixComputed<T>(computeFn: () => T): {\r\n value: T;\r\n subscribe: (fn: (value: T) => void) => () => void;\r\n cleanup: () => void;\r\n getSubscriberCount: () => number;\r\n getDependencyCount: () => number;\r\n isDestroyed: () => boolean;\r\n getDependencyInfo: () => Array<{\r\n state: any;\r\n hasCleanup: boolean;\r\n isComputed: boolean;\r\n }>;\r\n _isNixState: true;\r\n _isComputed: true;\r\n} {\r\n const ctx = activeContext as\r\n | (typeof activeContext & {\r\n hookIndex: number;\r\n hooks: Array<any>;\r\n stateCleanups?: Array<() => void>;\r\n })\r\n | undefined;\r\n if (!ctx) throw new Error(\"nixComputed() called outside component\");\r\n\r\n if (typeof computeFn !== \"function\") {\r\n throw new TypeError(\"[nixComputed] First argument must be a function\");\r\n }\r\n\r\n const idx = ctx.hookIndex++;\r\n if (!ctx.hooks[idx]) {\r\n const subscribers: Set<(value: T) => void> = new Set();\r\n const dependencies: Set<any> = new Set();\r\n const unsubscribers: Map<any, () => void> = new Map();\r\n let cachedValue: T;\r\n let isStale = true;\r\n let isDestroyed = false;\r\n let isComputing = false;\r\n\r\n function compute(): T {\r\n if (isDestroyed) return cachedValue;\r\n if (isComputing) {\r\n console.error(\"[nixComputed] Circular dependency detected\");\r\n return cachedValue;\r\n }\r\n isComputing = true;\r\n // Provide all required properties for ComponentContext type\r\n // Use type assertion for safety and future-proofing\r\n const trackingContext = {\r\n _accessedStates: new Set(),\r\n hookIndex: 0,\r\n hooks: [],\r\n _subscriptions: new Set(),\r\n _subscriptionCleanups: [],\r\n effects: [],\r\n cleanups: [],\r\n _vnode: null,\r\n version: 0,\r\n props: {},\r\n stateCleanups: [],\r\n parent: null,\r\n context: {},\r\n rerender: () => {},\r\n Component: null,\r\n _isMounted: false,\r\n _isRerendering: false,\r\n } as any; // Use 'as any' to satisfy ComponentContext type\r\n const prevContext = activeContext;\r\n try {\r\n setActiveContext(trackingContext);\r\n cachedValue = computeFn();\r\n const oldDeps = Array.from(dependencies);\r\n oldDeps.forEach((dep) => {\r\n if (!trackingContext._accessedStates.has(dep)) {\r\n if (unsubscribers.has(dep)) {\r\n try {\r\n unsubscribers.get(dep)!();\r\n } catch (e) {\r\n console.error(\r\n \"[nixComputed] Error unsubscribing from old dependency:\",\r\n e\r\n );\r\n }\r\n unsubscribers.delete(dep);\r\n }\r\n dependencies.delete(dep);\r\n }\r\n });\r\n trackingContext._accessedStates.forEach((state: any) => {\r\n if (!dependencies.has(state)) {\r\n const unsub = state.subscribe(() => {\r\n if (isDestroyed) return;\r\n\r\n isStale = true;\r\n // Get fresh value when dependency changes\r\n const newValue = s.value;\r\n const subsArray = Array.from(subscribers);\r\n subsArray.forEach((fn) => {\r\n try {\r\n fn(newValue);\r\n } catch (e) {\r\n console.error(\"[nixComputed] Subscriber error:\", e);\r\n subscribers.delete(fn);\r\n }\r\n });\r\n });\r\n unsubscribers.set(state, unsub);\r\n dependencies.add(state);\r\n }\r\n });\r\n isStale = false;\r\n } catch (err) {\r\n console.error(\"[nixComputed] Compute error:\", err);\r\n isStale = false;\r\n } finally {\r\n setActiveContext(prevContext);\r\n isComputing = false;\r\n }\r\n return cachedValue;\r\n }\r\n\r\n // All cleanup functionality is now part of the s object below\r\n\r\n const s = {\r\n get value(): T {\r\n if (isDestroyed) {\r\n console.warn(\"[nixComputed] Accessing destroyed computed state\");\r\n return cachedValue;\r\n }\r\n if (isStale) {\r\n compute();\r\n }\r\n if (activeContext && (activeContext as any)._accessedStates) {\r\n (activeContext as any)._accessedStates.add(s);\r\n }\r\n return cachedValue;\r\n },\r\n subscribe(fn: (value: T) => void): () => void {\r\n if (typeof fn !== \"function\") {\r\n console.error(\"[nixComputed] subscribe() requires a function\");\r\n return () => {};\r\n }\r\n if (isDestroyed) {\r\n console.warn(\r\n \"[nixComputed] Cannot subscribe to destroyed computed state\"\r\n );\r\n return () => {};\r\n }\r\n const MAX_SUBSCRIBERS = 1000;\r\n if (subscribers.size >= MAX_SUBSCRIBERS) {\r\n console.error(\"[nixComputed] Maximum subscriber limit reached\");\r\n return () => {};\r\n }\r\n subscribers.add(fn);\r\n return () => {\r\n subscribers.delete(fn);\r\n };\r\n },\r\n cleanup(): void {\r\n if (isDestroyed) return;\r\n isDestroyed = true;\r\n unsubscribers.forEach((unsub) => {\r\n try {\r\n unsub();\r\n } catch (e) {\r\n console.error(\"[nixComputed] Cleanup error:\", e);\r\n }\r\n });\r\n unsubscribers.clear();\r\n dependencies.clear();\r\n subscribers.clear();\r\n cachedValue = null as any as T;\r\n console.log(\"[nixComputed] Computed state cleaned up\");\r\n },\r\n getSubscriberCount(): number {\r\n return subscribers.size;\r\n },\r\n getDependencyCount(): number {\r\n return dependencies.size;\r\n },\r\n isDestroyed(): boolean {\r\n return isDestroyed;\r\n },\r\n getDependencyInfo(): Array<{\r\n state: any;\r\n hasCleanup: boolean;\r\n isComputed: boolean;\r\n }> {\r\n return Array.from(dependencies).map((state) => ({\r\n state,\r\n hasCleanup: unsubscribers.has(state),\r\n isComputed: !!state._isComputed,\r\n }));\r\n },\r\n _isNixState: true as const,\r\n _isComputed: true as const,\r\n };\r\n\r\n compute();\r\n ctx.hooks[idx] = s;\r\n if (ctx.stateCleanups) {\r\n ctx.stateCleanups.push(() => s.cleanup());\r\n }\r\n }\r\n return ctx.hooks[idx] as ReturnType<typeof nixComputed<T>>;\r\n}\r\n"],
|
|
5
|
-
"mappings": ";;AA0BA,SAAS,eAAe,wBAAwB;AA6DzC,SAAS,YAAe,WAc7B;AACA,QAAM,MAAM;AAOZ,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,wCAAwC;AAElE,MAAI,OAAO,cAAc,YAAY;AACnC,UAAM,IAAI,UAAU,iDAAiD;AAAA,EACvE;AAEA,QAAM,MAAM,IAAI;AAChB,MAAI,CAAC,IAAI,MAAM,GAAG,GAAG;AASnB,QAASA,WAAT,WAAsB;AACpB,UAAI,YAAa,QAAO;AACxB,UAAI,aAAa;AACf,gBAAQ,MAAM,4CAA4C;AAC1D,eAAO;AAAA,MACT;AACA,oBAAc;AAGd,YAAM,kBAAkB;AAAA,QACtB,iBAAiB,oBAAI,IAAI;AAAA,QACzB,WAAW;AAAA,QACX,OAAO,CAAC;AAAA,QACR,gBAAgB,oBAAI,IAAI;AAAA,QACxB,uBAAuB,CAAC;AAAA,QACxB,SAAS,CAAC;AAAA,QACV,UAAU,CAAC;AAAA,QACX,QAAQ;AAAA,QACR,SAAS;AAAA,QACT,OAAO,CAAC;AAAA,QACR,eAAe,CAAC;AAAA,QAChB,QAAQ;AAAA,QACR,SAAS,CAAC;AAAA,QACV,UAAU,6BAAM;AAAA,QAAC,GAAP;AAAA,QACV,WAAW;AAAA,QACX,YAAY;AAAA,QACZ,gBAAgB;AAAA,MAClB;AACA,YAAM,cAAc;AACpB,UAAI;AACF,yBAAiB,eAAe;AAChC,sBAAc,UAAU;AACxB,cAAM,UAAU,MAAM,KAAK,YAAY;AACvC,gBAAQ,QAAQ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AA,UACnC,YAAY,CAAC,CAAC,MAAM;AAAA,QACtB,EAAE;AAAA,MACJ;AAAA,MACA,aAAa;AAAA,MACb,aAAa;AAAA,IACf;AAEA,IAAAA,SAAQ;AACR,QAAI,MAAM,GAAG,IAAI;AACjB,QAAI,IAAI,eAAe;AACrB,UAAI,cAAc,KAAK,MAAM,EAAE,QAAQ,CAAC;AAAA,IAC1C;AAAA,EACF;AACA,SAAO,IAAI,MAAM,GAAG;AACtB;AA5MgB;",
|
|
6
|
-
"names": ["compute"]
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nixDebounce.d.ts","sourceRoot":"","sources":["../../hooks/nixDebounce.ts"],"names":[],"mappings":"AAiDA,MAAM,WAAW,kBAAkB;IACjC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IAAI,CAAC,CAClE,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,KACnB,IAAI,CAAC,GAAG;IACX,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EAC3D,EAAE,EAAE,CAAC,EACL,KAAK,GAAE,MAAY,EACnB,OAAO,GAAE,kBAAuB,GAC/B,iBAAiB,CAAC,CAAC,CAAC,CA8DtB"}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../hooks/nixDebounce.ts"],
|
|
4
|
-
"sourcesContent": ["/* MIT License\r\n\r\n* Copyright (c) 2026 Resty Gonzales\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in all\r\ncopies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\r\n* SOFTWARE.\r\n */\r\n/**\r\n * @fileoverview Debounce utility function with advanced options.\r\n * Supports leading/trailing edge invocation, maxWait, and AbortController.\r\n */\r\n\r\n/**\r\n * Debounce a function with options for leading, trailing, maxWait, and AbortController support.\r\n *\r\n * @param {Function} fn - The function to debounce\r\n * @param {number} [delay=300] - Delay in milliseconds\r\n * @param {Object} [options={}] - Debounce options\r\n * @param {boolean} [options.leading=false] - Invoke on the leading edge\r\n * @param {boolean} [options.trailing=true] - Invoke on the trailing edge\r\n * @param {number} [options.maxWait] - Maximum wait time before forced invocation\r\n * @param {AbortSignal} [options.signal] - Optional AbortSignal to cancel pending calls\r\n * @returns {Function} Debounced function with `.cancel()` method\r\n *\r\n * @example\r\n * const controller = new AbortController();\r\n * const debounced = nixDebounce(() => console.log('Hello'), 500, {\r\n * leading: true,\r\n * maxWait: 2000,\r\n * signal: controller.signal\r\n * });\r\n * debounced();\r\n * controller.abort(); // Cancel pending invocation\r\n */\r\nexport interface NixDebounceOptions {\r\n leading?: boolean;\r\n trailing?: boolean;\r\n maxWait?: number;\r\n signal?: AbortSignal;\r\n}\r\n\r\nexport type DebouncedFunction<T extends (...args: any[]) => any> = ((\r\n ...args: Parameters<T>\r\n) => void) & {\r\n cancel: () => void;\r\n};\r\n\r\nexport function nixDebounce<T extends (...args: any[]) => any>(\r\n fn: T,\r\n delay: number = 300,\r\n options: NixDebounceOptions = {}\r\n): DebouncedFunction<T> {\r\n let timerId: ReturnType<typeof setTimeout> | null = null;\r\n let lastInvokeTime = 0;\r\n let lastArgs: Parameters<T> | null = null;\r\n let lastThis: any = null;\r\n\r\n const { leading = false, trailing = true, maxWait, signal } = options;\r\n\r\n if (signal) {\r\n signal.addEventListener(\"abort\", () => {\r\n if (timerId) {\r\n clearTimeout(timerId);\r\n timerId = null;\r\n }\r\n lastArgs = null;\r\n lastThis = null;\r\n });\r\n }\r\n\r\n const invoke = () => {\r\n lastInvokeTime = Date.now();\r\n if (lastArgs) {\r\n fn.apply(lastThis, lastArgs);\r\n lastArgs = lastThis = null;\r\n }\r\n };\r\n\r\n const debounced = function (this: unknown, ...args: Parameters<T>) {\r\n const now = Date.now();\r\n lastArgs = args;\r\n lastThis = this;\r\n\r\n const shouldInvokeLeading = leading && !timerId;\r\n const timeSinceLastInvoke = now - lastInvokeTime;\r\n const remainingTime = delay - timeSinceLastInvoke;\r\n\r\n if (maxWait !== undefined && timeSinceLastInvoke >= maxWait) {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n invoke();\r\n return;\r\n }\r\n\r\n if (timerId) clearTimeout(timerId);\r\n\r\n if (shouldInvokeLeading) {\r\n invoke();\r\n }\r\n\r\n if (trailing) {\r\n timerId = setTimeout(invoke, remainingTime > 0 ? remainingTime : delay);\r\n }\r\n } as DebouncedFunction<T>;\r\n\r\n debounced.cancel = () => {\r\n if (timerId) clearTimeout(timerId);\r\n timerId = null;\r\n lastArgs = null;\r\n lastThis = null;\r\n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