fynixui 1.0.10

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.
Files changed (129) hide show
  1. package/LICENSE +21 -0
  2. package/dist/context/context.d.ts +19 -0
  3. package/dist/context/context.d.ts.map +1 -0
  4. package/dist/context/context.js +4 -0
  5. package/dist/context/context.js.map +7 -0
  6. package/dist/custom/button.d.ts +2 -0
  7. package/dist/custom/button.d.ts.map +1 -0
  8. package/dist/custom/button.js +4 -0
  9. package/dist/custom/button.js.map +7 -0
  10. package/dist/custom/index.d.ts +3 -0
  11. package/dist/custom/index.d.ts.map +1 -0
  12. package/dist/custom/index.js +2 -0
  13. package/dist/custom/index.js.map +7 -0
  14. package/dist/custom/path.d.ts +14 -0
  15. package/dist/custom/path.d.ts.map +1 -0
  16. package/dist/custom/path.js +20 -0
  17. package/dist/custom/path.js.map +7 -0
  18. package/dist/error/errorOverlay.d.ts +3 -0
  19. package/dist/error/errorOverlay.d.ts.map +1 -0
  20. package/dist/error/errorOverlay.js +84 -0
  21. package/dist/error/errorOverlay.js.map +7 -0
  22. package/dist/fynix/index.d.ts +6 -0
  23. package/dist/fynix/index.d.ts.map +1 -0
  24. package/dist/fynix/index.js +5 -0
  25. package/dist/fynix/index.js.map +7 -0
  26. package/dist/hooks/nixAsync.d.ts +20 -0
  27. package/dist/hooks/nixAsync.d.ts.map +1 -0
  28. package/dist/hooks/nixAsync.js +114 -0
  29. package/dist/hooks/nixAsync.js.map +7 -0
  30. package/dist/hooks/nixAsyncCache.d.ts +19 -0
  31. package/dist/hooks/nixAsyncCache.d.ts.map +1 -0
  32. package/dist/hooks/nixAsyncCache.js +137 -0
  33. package/dist/hooks/nixAsyncCache.js.map +7 -0
  34. package/dist/hooks/nixAsyncDebounce.d.ts +22 -0
  35. package/dist/hooks/nixAsyncDebounce.d.ts.map +1 -0
  36. package/dist/hooks/nixAsyncDebounce.js +77 -0
  37. package/dist/hooks/nixAsyncDebounce.js.map +7 -0
  38. package/dist/hooks/nixAsyncQuery.d.ts +16 -0
  39. package/dist/hooks/nixAsyncQuery.d.ts.map +1 -0
  40. package/dist/hooks/nixAsyncQuery.js +87 -0
  41. package/dist/hooks/nixAsyncQuery.js.map +7 -0
  42. package/dist/hooks/nixCallback.d.ts +2 -0
  43. package/dist/hooks/nixCallback.d.ts.map +1 -0
  44. package/dist/hooks/nixCallback.js +34 -0
  45. package/dist/hooks/nixCallback.js.map +7 -0
  46. package/dist/hooks/nixComputed.d.ts +16 -0
  47. package/dist/hooks/nixComputed.d.ts.map +1 -0
  48. package/dist/hooks/nixComputed.js +175 -0
  49. package/dist/hooks/nixComputed.js.map +7 -0
  50. package/dist/hooks/nixDebounce.d.ts +11 -0
  51. package/dist/hooks/nixDebounce.d.ts.map +1 -0
  52. package/dist/hooks/nixDebounce.js +55 -0
  53. package/dist/hooks/nixDebounce.js.map +7 -0
  54. package/dist/hooks/nixEffect.d.ts +4 -0
  55. package/dist/hooks/nixEffect.d.ts.map +1 -0
  56. package/dist/hooks/nixEffect.js +75 -0
  57. package/dist/hooks/nixEffect.js.map +7 -0
  58. package/dist/hooks/nixFor.d.ts +13 -0
  59. package/dist/hooks/nixFor.d.ts.map +1 -0
  60. package/dist/hooks/nixFor.js +43 -0
  61. package/dist/hooks/nixFor.js.map +7 -0
  62. package/dist/hooks/nixForm.d.ts +33 -0
  63. package/dist/hooks/nixForm.d.ts.map +1 -0
  64. package/dist/hooks/nixForm.js +123 -0
  65. package/dist/hooks/nixForm.js.map +7 -0
  66. package/dist/hooks/nixFormAsync.d.ts +42 -0
  67. package/dist/hooks/nixFormAsync.d.ts.map +1 -0
  68. package/dist/hooks/nixFormAsync.js +169 -0
  69. package/dist/hooks/nixFormAsync.js.map +7 -0
  70. package/dist/hooks/nixInterval.d.ts +2 -0
  71. package/dist/hooks/nixInterval.d.ts.map +1 -0
  72. package/dist/hooks/nixInterval.js +23 -0
  73. package/dist/hooks/nixInterval.js.map +7 -0
  74. package/dist/hooks/nixLazy.d.ts +8 -0
  75. package/dist/hooks/nixLazy.d.ts.map +1 -0
  76. package/dist/hooks/nixLazy.js +58 -0
  77. package/dist/hooks/nixLazy.js.map +7 -0
  78. package/dist/hooks/nixLazyAsync.d.ts +10 -0
  79. package/dist/hooks/nixLazyAsync.d.ts.map +1 -0
  80. package/dist/hooks/nixLazyAsync.js +71 -0
  81. package/dist/hooks/nixLazyAsync.js.map +7 -0
  82. package/dist/hooks/nixLazyFormAsync.d.ts +50 -0
  83. package/dist/hooks/nixLazyFormAsync.d.ts.map +1 -0
  84. package/dist/hooks/nixLazyFormAsync.js +221 -0
  85. package/dist/hooks/nixLazyFormAsync.js.map +7 -0
  86. package/dist/hooks/nixLocalStorage.d.ts +8 -0
  87. package/dist/hooks/nixLocalStorage.d.ts.map +1 -0
  88. package/dist/hooks/nixLocalStorage.js +136 -0
  89. package/dist/hooks/nixLocalStorage.js.map +7 -0
  90. package/dist/hooks/nixMemo.d.ts +2 -0
  91. package/dist/hooks/nixMemo.d.ts.map +1 -0
  92. package/dist/hooks/nixMemo.js +30 -0
  93. package/dist/hooks/nixMemo.js.map +7 -0
  94. package/dist/hooks/nixPrevious.d.ts +2 -0
  95. package/dist/hooks/nixPrevious.d.ts.map +1 -0
  96. package/dist/hooks/nixPrevious.js +15 -0
  97. package/dist/hooks/nixPrevious.js.map +7 -0
  98. package/dist/hooks/nixRef.d.ts +4 -0
  99. package/dist/hooks/nixRef.d.ts.map +1 -0
  100. package/dist/hooks/nixRef.js +17 -0
  101. package/dist/hooks/nixRef.js.map +7 -0
  102. package/dist/hooks/nixState.d.ts +15 -0
  103. package/dist/hooks/nixState.d.ts.map +1 -0
  104. package/dist/hooks/nixState.js +127 -0
  105. package/dist/hooks/nixState.js.map +7 -0
  106. package/dist/hooks/nixStore.d.ts +10 -0
  107. package/dist/hooks/nixStore.d.ts.map +1 -0
  108. package/dist/hooks/nixStore.js +103 -0
  109. package/dist/hooks/nixStore.js.map +7 -0
  110. package/dist/package.json +221 -0
  111. package/dist/plugins/vite-plugin-res.d.ts +38 -0
  112. package/dist/plugins/vite-plugin-res.d.ts.map +1 -0
  113. package/dist/plugins/vite-plugin-res.js +106 -0
  114. package/dist/plugins/vite-plugin-res.js.map +7 -0
  115. package/dist/router/router.d.ts +48 -0
  116. package/dist/router/router.d.ts.map +1 -0
  117. package/dist/router/router.js +872 -0
  118. package/dist/router/router.js.map +7 -0
  119. package/dist/runtime.d.ts +124 -0
  120. package/dist/runtime.d.ts.map +1 -0
  121. package/dist/runtime.js +1361 -0
  122. package/dist/runtime.js.map +7 -0
  123. package/package.json +254 -0
  124. package/types/fnx.d.ts +34 -0
  125. package/types/fynix-ui.d.ts +323 -0
  126. package/types/global.d.ts +279 -0
  127. package/types/index.d.ts +37 -0
  128. package/types/jsx.d.ts +993 -0
  129. package/types/vite-env.d.ts +545 -0
@@ -0,0 +1,127 @@
1
+ import { activeContext } from "../context/context";
2
+ export function nixState(initial) {
3
+ const ctx = activeContext;
4
+ if (!ctx)
5
+ throw new Error("nixState() called outside component");
6
+ const idx = ctx.hookIndex++;
7
+ if (!ctx.hooks[idx]) {
8
+ let value = initial;
9
+ const subscribers = new Set();
10
+ let isDestroyed = false;
11
+ if (initial !== null && typeof initial === "object") {
12
+ if ("__proto__" in initial ||
13
+ "constructor" in initial ||
14
+ "prototype" in initial) {
15
+ if (Array.isArray(initial)) {
16
+ value = [...initial];
17
+ }
18
+ else {
19
+ value = { ...initial };
20
+ delete value.__proto__;
21
+ delete value.constructor;
22
+ delete value.prototype;
23
+ }
24
+ }
25
+ }
26
+ const s = {
27
+ get value() {
28
+ if (isDestroyed) {
29
+ return value;
30
+ }
31
+ if (activeContext && !isDestroyed) {
32
+ activeContext._accessedStates.add(s);
33
+ }
34
+ return value;
35
+ },
36
+ set value(newVal) {
37
+ if (isDestroyed) {
38
+ return;
39
+ }
40
+ if (newVal === value)
41
+ return;
42
+ if (newVal !== null && typeof newVal === "object") {
43
+ if ("__proto__" in newVal ||
44
+ "constructor" in newVal ||
45
+ "prototype" in newVal) {
46
+ if (Array.isArray(newVal)) {
47
+ newVal = [...newVal];
48
+ }
49
+ else {
50
+ newVal = { ...newVal };
51
+ delete newVal.__proto__;
52
+ delete newVal.constructor;
53
+ delete newVal.prototype;
54
+ }
55
+ }
56
+ }
57
+ value = newVal;
58
+ const subsArray = Array.from(subscribers);
59
+ subsArray.forEach((fn) => {
60
+ try {
61
+ fn(newVal);
62
+ }
63
+ catch (err) {
64
+ console.error("[nixState] Subscriber error:", err);
65
+ subscribers.delete(fn);
66
+ }
67
+ });
68
+ },
69
+ subscribe(fn) {
70
+ if (typeof fn !== "function") {
71
+ console.error("[nixState] subscribe() requires a function");
72
+ return () => { };
73
+ }
74
+ if (isDestroyed) {
75
+ console.warn("[nixState] Cannot subscribe to destroyed state");
76
+ return () => { };
77
+ }
78
+ const MAX_SUBSCRIBERS = 1000;
79
+ if (subscribers.size >= MAX_SUBSCRIBERS) {
80
+ console.error("[nixState] Maximum subscriber limit reached");
81
+ return () => { };
82
+ }
83
+ subscribers.add(fn);
84
+ return () => {
85
+ subscribers.delete(fn);
86
+ };
87
+ },
88
+ cleanup() {
89
+ if (isDestroyed)
90
+ return;
91
+ isDestroyed = true;
92
+ subscribers.clear();
93
+ if (value !== null && typeof value === "object") {
94
+ if (Array.isArray(value)) {
95
+ value = [];
96
+ }
97
+ else {
98
+ value = null;
99
+ }
100
+ }
101
+ console.log("[nixState] State cleaned up");
102
+ },
103
+ getSubscriberCount() {
104
+ return subscribers.size;
105
+ },
106
+ isDestroyed() {
107
+ return isDestroyed;
108
+ },
109
+ asReadOnly() {
110
+ return {
111
+ get value() {
112
+ return s.value;
113
+ },
114
+ subscribe: s.subscribe.bind(s),
115
+ _isNixState: true,
116
+ _isReadOnly: true,
117
+ };
118
+ },
119
+ _isNixState: true,
120
+ };
121
+ ctx.hooks[idx] = s;
122
+ if (ctx.stateCleanups) {
123
+ ctx.stateCleanups.push(() => s.cleanup());
124
+ }
125
+ }
126
+ return ctx.hooks[idx];
127
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../hooks/nixState.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 nixState - Reactive State\r\n Memory Leaks & Security Issues Resolved\r\n---------------------- */\r\nimport { activeContext } from \"../context/context\";\r\n\r\n/**\r\n * Creates a reactive state value that triggers component re-renders when changed.\r\n * Must be called within a component function.\r\n *\r\n * @param {any} initial - The initial value for the state\r\n * @returns {NixState} A reactive state object with value getter/setter and subscription methods\r\n *\r\n * @typedef {Object} NixState\r\n * @property {any} value - Get/set the current state value. Getting tracks the dependency, setting triggers subscribers.\r\n * @property {(fn: Function) => Function} subscribe - Subscribe to state changes. Returns unsubscribe function.\r\n * @property {() => void} cleanup - Cleanup all subscriptions to prevent memory leaks\r\n * @property {() => number} getSubscriberCount - Get number of active subscribers (debugging)\r\n * @property {() => boolean} isDestroyed - Check if state has been destroyed\r\n * @property {() => Object} asReadOnly - Get read-only version of the state\r\n * @property {boolean} _isNixState - Internal flag to identify nixState objects\r\n *\r\n * @example\r\n * const Counter = () => {\r\n * const count = nixState(0);\r\n *\r\n * return h(\"div\", {},\r\n * h(\"p\", {}, \"Count: \", count),\r\n * h(\"button\", { \"r-click\": () => count.value++ }, \"Increment\")\r\n * );\r\n * };\r\n *\r\n * @example\r\n * // With cleanup\r\n * const MyComponent = () => {\r\n * const state = nixState(0);\r\n *\r\n * nixEffect(() => {\r\n * return () => state.cleanup(); // Clean up on unmount\r\n * }, []);\r\n * };\r\n *\r\n * @throws {Error} If called outside a component context\r\n */\r\nexport function nixState<T>(initial: T): {\r\n value: T;\r\n subscribe: (fn: (value: T) => void) => () => void;\r\n cleanup: () => void;\r\n getSubscriberCount: () => number;\r\n isDestroyed: () => boolean;\r\n asReadOnly: () => {\r\n value: T;\r\n subscribe: (fn: (value: T) => void) => () => void;\r\n _isNixState: true;\r\n _isReadOnly: true;\r\n };\r\n _isNixState: 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(\"nixState() called outside component\");\r\n\r\n const idx = ctx.hookIndex++;\r\n if (!ctx.hooks[idx]) {\r\n let value: T = initial;\r\n const subscribers: Set<(value: T) => void> = new Set();\r\n let isDestroyed = false;\r\n\r\n // Security: Validate initial value to prevent prototype pollution\r\n if (initial !== null && typeof initial === \"object\") {\r\n if (\r\n \"__proto__\" in (initial as any) ||\r\n \"constructor\" in (initial as any) ||\r\n \"prototype\" in (initial as any)\r\n ) {\r\n // Create a clean copy without dangerous properties\r\n if (Array.isArray(initial)) {\r\n value = [...(initial as any)] as T;\r\n } else {\r\n value = { ...(initial as any) };\r\n delete (value as any).__proto__;\r\n delete (value as any).constructor;\r\n delete (value as any).prototype;\r\n }\r\n }\r\n }\r\n\r\n const s = {\r\n get value(): T {\r\n if (isDestroyed) {\r\n /* console.warn(\"[nixState] Accessing destroyed state\"); */\r\n return value;\r\n }\r\n if (activeContext && !isDestroyed) {\r\n activeContext._accessedStates.add(s);\r\n }\r\n return value;\r\n },\r\n set value(newVal: T) {\r\n if (isDestroyed) {\r\n /* console.warn(\"[nixState] Attempting to update destroyed state\"); */\r\n return;\r\n }\r\n if (newVal === value) return;\r\n if (newVal !== null && typeof newVal === \"object\") {\r\n if (\r\n \"__proto__\" in (newVal as any) ||\r\n \"constructor\" in (newVal as any) ||\r\n \"prototype\" in (newVal as any)\r\n ) {\r\n /* console.warn(\r\n \"[nixState] Security: Dangerous properties detected in new value\"\r\n ); */\r\n if (Array.isArray(newVal)) {\r\n newVal = [...(newVal as any)] as T;\r\n } else {\r\n newVal = { ...(newVal as any) };\r\n delete (newVal as any).__proto__;\r\n delete (newVal as any).constructor;\r\n delete (newVal as any).prototype;\r\n }\r\n }\r\n }\r\n value = newVal;\r\n const subsArray = Array.from(subscribers);\r\n subsArray.forEach((fn) => {\r\n try {\r\n fn(newVal);\r\n } catch (err) {\r\n console.error(\"[nixState] Subscriber error:\", err);\r\n subscribers.delete(fn);\r\n }\r\n });\r\n },\r\n subscribe(fn: (value: T) => void): () => void {\r\n if (typeof fn !== \"function\") {\r\n console.error(\"[nixState] subscribe() requires a function\");\r\n return () => {};\r\n }\r\n if (isDestroyed) {\r\n console.warn(\"[nixState] Cannot subscribe to destroyed state\");\r\n return () => {};\r\n }\r\n const MAX_SUBSCRIBERS = 1000;\r\n if (subscribers.size >= MAX_SUBSCRIBERS) {\r\n console.error(\"[nixState] 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 subscribers.clear();\r\n if (value !== null && typeof value === \"object\") {\r\n if (Array.isArray(value)) {\r\n value = [] as any as T;\r\n } else {\r\n value = null as any as T;\r\n }\r\n }\r\n console.log(\"[nixState] State cleaned up\");\r\n },\r\n getSubscriberCount(): number {\r\n return subscribers.size;\r\n },\r\n isDestroyed(): boolean {\r\n return isDestroyed;\r\n },\r\n asReadOnly(): {\r\n value: T;\r\n subscribe: (fn: (value: T) => void) => () => void;\r\n _isNixState: true;\r\n _isReadOnly: true;\r\n } {\r\n return {\r\n get value() {\r\n return s.value;\r\n },\r\n subscribe: s.subscribe.bind(s),\r\n _isNixState: true,\r\n _isReadOnly: true,\r\n };\r\n },\r\n _isNixState: true as const,\r\n };\r\n\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 nixState<T>>;\r\n}\r\n"],
5
+ "mappings": ";;AA0BA,SAAS,qBAAqB;AAwCvB,SAAS,SAAY,SAa1B;AACA,QAAM,MAAM;AAOZ,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,qCAAqC;AAE/D,QAAM,MAAM,IAAI;AAChB,MAAI,CAAC,IAAI,MAAM,GAAG,GAAG;AACnB,QAAI,QAAW;AACf,UAAM,cAAuC,oBAAI,IAAI;AACrD,QAAI,cAAc;AAGlB,QAAI,YAAY,QAAQ,OAAO,YAAY,UAAU;AACnD,UACE,eAAgB,WAChB,iBAAkB,WAClB,eAAgB,SAChB;AAEA,YAAI,MAAM,QAAQ,OAAO,GAAG;AAC1B,kBAAQ,CAAC,GAAI,OAAe;AAAA,QAC9B,OAAO;AACL,kBAAQ,EAAE,GAAI,QAAgB;AAC9B,iBAAQ,MAAc;AACtB,iBAAQ,MAAc;AACtB,iBAAQ,MAAc;AAAA,QACxB;AAAA,MACF;AAAA,IACF;AAEA,UAAM,IAAI;AAAA,MACR,IAAI,QAAW;AACb,YAAI,aAAa;AAEf,iBAAO;AAAA,QACT;AACA,YAAI,iBAAiB,CAAC,aAAa;AACjC,wBAAc,gBAAgB,IAAI,CAAC;AAAA,QACrC;AACA,eAAO;AAAA,MACT;AAAA,MACA,IAAI,MAAM,QAAW;AACnB,YAAI,aAAa;AAEf;AAAA,QACF;AACA,YAAI,WAAW,MAAO;AACtB,YAAI,WAAW,QAAQ,OAAO,WAAW,UAAU;AACjD,cACE,eAAgB,UAChB,iBAAkB,UAClB,eAAgB,QAChB;AAIA,gBAAI,MAAM,QAAQ,MAAM,GAAG;AACzB,uBAAS,CAAC,GAAI,MAAc;AAAA,YAC9B,OAAO;AACL,uBAAS,EAAE,GAAI,OAAe;AAC9B,qBAAQ,OAAe;AACvB,qBAAQ,OAAe;AACvB,qBAAQ,OAAe;AAAA,YACzB;AAAA,UACF;AAAA,QACF;AACA,gBAAQ;AACR,cAAM,YAAY,MAAM,KAAK,WAAW;AACxC,kBAAU,QAAQ,CAAC,OAAO;AACxB,cAAI;AACF,eAAG,MAAM;AAAA,UACX,SAAS,KAAK;AACZ,oBAAQ,MAAM,gCAAgC,GAAG;AACjD,wBAAY,OAAO,EAAE;AAAA,UACvB;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,UAAU,IAAoC;AAC5C,YAAI,OAAO,OAAO,YAAY;AAC5B,kBAAQ,MAAM,4CAA4C;AAC1D,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AACA,YAAI,aAAa;AACf,kBAAQ,KAAK,gDAAgD;AAC7D,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AACA,cAAM,kBAAkB;AACxB,YAAI,YAAY,QAAQ,iBAAiB;AACvC,kBAAQ,MAAM,6CAA6C;AAC3D,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AACA,oBAAY,IAAI,EAAE;AAClB,eAAO,MAAM;AACX,sBAAY,OAAO,EAAE;AAAA,QACvB;AAAA,MACF;AAAA,MACA,UAAgB;AACd,YAAI,YAAa;AACjB,sBAAc;AACd,oBAAY,MAAM;AAClB,YAAI,UAAU,QAAQ,OAAO,UAAU,UAAU;AAC/C,cAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,oBAAQ,CAAC;AAAA,UACX,OAAO;AACL,oBAAQ;AAAA,UACV;AAAA,QACF;AACA,gBAAQ,IAAI,6BAA6B;AAAA,MAC3C;AAAA,MACA,qBAA6B;AAC3B,eAAO,YAAY;AAAA,MACrB;AAAA,MACA,cAAuB;AACrB,eAAO;AAAA,MACT;AAAA,MACA,aAKE;AACA,eAAO;AAAA,UACL,IAAI,QAAQ;AACV,mBAAO,EAAE;AAAA,UACX;AAAA,UACA,WAAW,EAAE,UAAU,KAAK,CAAC;AAAA,UAC7B,aAAa;AAAA,UACb,aAAa;AAAA,QACf;AAAA,MACF;AAAA,MACA,aAAa;AAAA,IACf;AAEA,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;AA7JgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,10 @@
1
+ export declare function nixStore<T = any>(path: string, initial: T): {
2
+ value: T;
3
+ subscribe: (fn: () => void) => () => void;
4
+ path: string;
5
+ cleanup: () => void;
6
+ getSubscriberCount: () => number;
7
+ isDestroyed: () => boolean;
8
+ _isNixState: boolean;
9
+ };
10
+ //# sourceMappingURL=nixStore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nixStore.d.ts","sourceRoot":"","sources":["../../hooks/nixStore.ts"],"names":[],"mappings":"AAkCA,wBAAgB,QAAQ,CAAC,CAAC,GAAG,GAAG,EAC9B,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,CAAC,GACT;IACD,KAAK,EAAE,CAAC,CAAC;IACT,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,kBAAkB,EAAE,MAAM,MAAM,CAAC;IACjC,WAAW,EAAE,MAAM,OAAO,CAAC;IAC3B,WAAW,EAAE,OAAO,CAAC;CACtB,CAkJA"}
@@ -0,0 +1,103 @@
1
+ import { activeContext } from "../context/context";
2
+ export function nixStore(path, initial) {
3
+ if (!path || typeof path !== "string") {
4
+ throw new Error("[nixStore] Path must be a non-empty string");
5
+ }
6
+ const dangerousKeys = ["__proto__", "constructor", "prototype"];
7
+ if (dangerousKeys.some((key) => path.includes(key))) {
8
+ throw new Error("[nixStore] Path contains dangerous keywords");
9
+ }
10
+ if (path.length > 200) {
11
+ throw new Error("[nixStore] Path too long (max 200 characters)");
12
+ }
13
+ const ctx = activeContext;
14
+ if (!ctx)
15
+ throw new Error("nixStore() called outside component");
16
+ const idx = ctx.hookIndex++;
17
+ if (!ctx.hooks[idx]) {
18
+ let value = initial;
19
+ const subscribers = new Set();
20
+ let isDestroyed = false;
21
+ let maxSubscribers = 100;
22
+ const s = {
23
+ get value() {
24
+ if (isDestroyed) {
25
+ console.warn("[nixStore] Accessing destroyed store:", path);
26
+ return value;
27
+ }
28
+ try {
29
+ if (activeContext?._accessedStates) {
30
+ activeContext._accessedStates.add(s);
31
+ }
32
+ }
33
+ catch (err) {
34
+ console.error("[nixStore] Error tracking accessed state:", err);
35
+ }
36
+ return value;
37
+ },
38
+ set value(v) {
39
+ if (isDestroyed) {
40
+ console.warn("[nixStore] Attempting to set value on destroyed store:", path);
41
+ return;
42
+ }
43
+ if (v && typeof v === "object") {
44
+ const safeValue = Object.create(null);
45
+ for (const key in v) {
46
+ if (Object.prototype.hasOwnProperty.call(v, key) &&
47
+ !dangerousKeys.includes(key)) {
48
+ safeValue[key] = v[key];
49
+ }
50
+ }
51
+ value = safeValue;
52
+ }
53
+ else {
54
+ value = v;
55
+ }
56
+ const subscriberArray = Array.from(subscribers);
57
+ subscriberArray.forEach((fn) => {
58
+ try {
59
+ fn();
60
+ }
61
+ catch (err) {
62
+ console.error("[nixStore] Subscriber error:", err);
63
+ subscribers.delete(fn);
64
+ }
65
+ });
66
+ },
67
+ subscribe(fn) {
68
+ if (isDestroyed) {
69
+ console.warn("[nixStore] Attempting to subscribe to destroyed store:", path);
70
+ return () => { };
71
+ }
72
+ if (typeof fn !== "function") {
73
+ console.error("[nixStore] Subscriber must be a function");
74
+ return () => { };
75
+ }
76
+ if (subscribers.size >= maxSubscribers) {
77
+ console.warn(`[nixStore] Maximum subscribers (${maxSubscribers}) reached for store:`, path);
78
+ return () => { };
79
+ }
80
+ subscribers.add(fn);
81
+ return () => {
82
+ subscribers.delete(fn);
83
+ };
84
+ },
85
+ cleanup() {
86
+ if (isDestroyed)
87
+ return;
88
+ isDestroyed = true;
89
+ subscribers.clear();
90
+ console.debug(`[nixStore] Cleaned up store: ${path}`);
91
+ },
92
+ getSubscriberCount: () => subscribers.size,
93
+ isDestroyed: () => isDestroyed,
94
+ path,
95
+ _isNixState: true,
96
+ };
97
+ if (!ctx.cleanups)
98
+ ctx.cleanups = [];
99
+ ctx.cleanups.push(() => s.cleanup());
100
+ ctx.hooks[idx] = s;
101
+ }
102
+ return ctx.hooks[idx];
103
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../hooks/nixStore.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 * Reactive store hook with subscription support and enhanced security.\r\n * Memory-safe: cleans up subscribers on component unmount.\r\n * Prevents prototype pollution and validates inputs.\r\n *\r\n * @template T\r\n * @param {string} path - Path identifier (required, must be safe)\r\n * @param {T} initial - Initial value\r\n * @returns {Object} Reactive store object with get/set/subscribe\r\n */\r\nexport function nixStore<T = any>(\r\n path: string,\r\n initial: T\r\n): {\r\n value: T;\r\n subscribe: (fn: () => void) => () => void;\r\n path: string;\r\n cleanup: () => void;\r\n getSubscriberCount: () => number;\r\n isDestroyed: () => boolean;\r\n _isNixState: boolean;\r\n} {\r\n // Input validation\r\n if (!path || typeof path !== \"string\") {\r\n throw new Error(\"[nixStore] Path must be a non-empty string\");\r\n }\r\n\r\n // Validate path for security (prevent prototype pollution)\r\n const dangerousKeys = [\"__proto__\", \"constructor\", \"prototype\"];\r\n if (dangerousKeys.some((key) => path.includes(key))) {\r\n throw new Error(\"[nixStore] Path contains dangerous keywords\");\r\n }\r\n\r\n if (path.length > 200) {\r\n throw new Error(\"[nixStore] Path too long (max 200 characters)\");\r\n }\r\n\r\n type StoreHook = {\r\n value: T;\r\n subscribe: (fn: () => void) => () => void;\r\n path: string;\r\n cleanup: () => void;\r\n getSubscriberCount: () => number;\r\n isDestroyed: () => boolean;\r\n _isNixState: boolean;\r\n };\r\n\r\n const ctx = activeContext as\r\n | (typeof activeContext & {\r\n hookIndex: number;\r\n hooks: Array<StoreHook | undefined>;\r\n cleanups?: Array<() => void>;\r\n })\r\n | undefined;\r\n if (!ctx) throw new Error(\"nixStore() called outside component\");\r\n\r\n const idx: number = ctx.hookIndex++;\r\n\r\n if (!ctx.hooks[idx]) {\r\n let value: T = initial;\r\n const subscribers: Set<() => void> = new Set();\r\n let isDestroyed = false;\r\n let maxSubscribers = 100; // Prevent memory leaks\r\n\r\n const s: StoreHook = {\r\n get value() {\r\n if (isDestroyed) {\r\n console.warn(\"[nixStore] Accessing destroyed store:\", path);\r\n return value;\r\n }\r\n\r\n try {\r\n if ((activeContext as any)?._accessedStates) {\r\n (activeContext as any)._accessedStates.add(s);\r\n }\r\n } catch (err) {\r\n console.error(\"[nixStore] Error tracking accessed state:\", err);\r\n }\r\n return value;\r\n },\r\n set value(v: T) {\r\n if (isDestroyed) {\r\n console.warn(\r\n \"[nixStore] Attempting to set value on destroyed store:\",\r\n path\r\n );\r\n return;\r\n }\r\n\r\n // Validate value for security\r\n if (v && typeof v === \"object\") {\r\n // Create safe object without dangerous properties\r\n const safeValue = Object.create(null);\r\n for (const key in v) {\r\n if (\r\n Object.prototype.hasOwnProperty.call(v, key) &&\r\n !dangerousKeys.includes(key)\r\n ) {\r\n safeValue[key] = v[key];\r\n }\r\n }\r\n value = safeValue as T;\r\n } else {\r\n value = v;\r\n }\r\n\r\n // Notify subscribers safely\r\n const subscriberArray = Array.from(subscribers);\r\n subscriberArray.forEach((fn) => {\r\n try {\r\n fn();\r\n } catch (err) {\r\n console.error(\"[nixStore] Subscriber error:\", err);\r\n // Remove failing subscriber to prevent repeated errors\r\n subscribers.delete(fn);\r\n }\r\n });\r\n },\r\n subscribe(fn: () => void) {\r\n if (isDestroyed) {\r\n console.warn(\r\n \"[nixStore] Attempting to subscribe to destroyed store:\",\r\n path\r\n );\r\n return () => {};\r\n }\r\n\r\n if (typeof fn !== \"function\") {\r\n console.error(\"[nixStore] Subscriber must be a function\");\r\n return () => {};\r\n }\r\n\r\n if (subscribers.size >= maxSubscribers) {\r\n console.warn(\r\n `[nixStore] Maximum subscribers (${maxSubscribers}) reached for store:`,\r\n path\r\n );\r\n return () => {};\r\n }\r\n\r\n subscribers.add(fn);\r\n // Return cleanup function\r\n return () => {\r\n subscribers.delete(fn);\r\n };\r\n },\r\n cleanup() {\r\n if (isDestroyed) return;\r\n\r\n isDestroyed = true;\r\n subscribers.clear();\r\n console.debug(`[nixStore] Cleaned up store: ${path}`);\r\n },\r\n getSubscriberCount: () => subscribers.size,\r\n isDestroyed: () => isDestroyed,\r\n path,\r\n _isNixState: true,\r\n };\r\n\r\n // Register cleanup on component unmount\r\n if (!ctx.cleanups) ctx.cleanups = [];\r\n ctx.cleanups.push(() => s.cleanup());\r\n\r\n ctx.hooks[idx] = s;\r\n }\r\n\r\n return ctx.hooks[idx] as StoreHook;\r\n}\r\n"],
5
+ "mappings": ";;AAsBA,SAAS,qBAAqB;AAYvB,SAAS,SACd,MACA,SASA;AAEA,MAAI,CAAC,QAAQ,OAAO,SAAS,UAAU;AACrC,UAAM,IAAI,MAAM,4CAA4C;AAAA,EAC9D;AAGA,QAAM,gBAAgB,CAAC,aAAa,eAAe,WAAW;AAC9D,MAAI,cAAc,KAAK,CAAC,QAAQ,KAAK,SAAS,GAAG,CAAC,GAAG;AACnD,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC/D;AAEA,MAAI,KAAK,SAAS,KAAK;AACrB,UAAM,IAAI,MAAM,+CAA+C;AAAA,EACjE;AAYA,QAAM,MAAM;AAOZ,MAAI,CAAC,IAAK,OAAM,IAAI,MAAM,qCAAqC;AAE/D,QAAM,MAAc,IAAI;AAExB,MAAI,CAAC,IAAI,MAAM,GAAG,GAAG;AACnB,QAAI,QAAW;AACf,UAAM,cAA+B,oBAAI,IAAI;AAC7C,QAAI,cAAc;AAClB,QAAI,iBAAiB;AAErB,UAAM,IAAe;AAAA,MACnB,IAAI,QAAQ;AACV,YAAI,aAAa;AACf,kBAAQ,KAAK,yCAAyC,IAAI;AAC1D,iBAAO;AAAA,QACT;AAEA,YAAI;AACF,cAAK,eAAuB,iBAAiB;AAC3C,YAAC,cAAsB,gBAAgB,IAAI,CAAC;AAAA,UAC9C;AAAA,QACF,SAAS,KAAK;AACZ,kBAAQ,MAAM,6CAA6C,GAAG;AAAA,QAChE;AACA,eAAO;AAAA,MACT;AAAA,MACA,IAAI,MAAM,GAAM;AACd,YAAI,aAAa;AACf,kBAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AACA;AAAA,QACF;AAGA,YAAI,KAAK,OAAO,MAAM,UAAU;AAE9B,gBAAM,YAAY,uBAAO,OAAO,IAAI;AACpC,qBAAW,OAAO,GAAG;AACnB,gBACE,OAAO,UAAU,eAAe,KAAK,GAAG,GAAG,KAC3C,CAAC,cAAc,SAAS,GAAG,GAC3B;AACA,wBAAU,GAAG,IAAI,EAAE,GAAG;AAAA,YACxB;AAAA,UACF;AACA,kBAAQ;AAAA,QACV,OAAO;AACL,kBAAQ;AAAA,QACV;AAGA,cAAM,kBAAkB,MAAM,KAAK,WAAW;AAC9C,wBAAgB,QAAQ,CAAC,OAAO;AAC9B,cAAI;AACF,eAAG;AAAA,UACL,SAAS,KAAK;AACZ,oBAAQ,MAAM,gCAAgC,GAAG;AAEjD,wBAAY,OAAO,EAAE;AAAA,UACvB;AAAA,QACF,CAAC;AAAA,MACH;AAAA,MACA,UAAU,IAAgB;AACxB,YAAI,aAAa;AACf,kBAAQ;AAAA,YACN;AAAA,YACA;AAAA,UACF;AACA,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAEA,YAAI,OAAO,OAAO,YAAY;AAC5B,kBAAQ,MAAM,0CAA0C;AACxD,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAEA,YAAI,YAAY,QAAQ,gBAAgB;AACtC,kBAAQ;AAAA,YACN,mCAAmC,cAAc;AAAA,YACjD;AAAA,UACF;AACA,iBAAO,MAAM;AAAA,UAAC;AAAA,QAChB;AAEA,oBAAY,IAAI,EAAE;AAElB,eAAO,MAAM;AACX,sBAAY,OAAO,EAAE;AAAA,QACvB;AAAA,MACF;AAAA,MACA,UAAU;AACR,YAAI,YAAa;AAEjB,sBAAc;AACd,oBAAY,MAAM;AAClB,gBAAQ,MAAM,gCAAgC,IAAI,EAAE;AAAA,MACtD;AAAA,MACA,oBAAoB,6BAAM,YAAY,MAAlB;AAAA,MACpB,aAAa,6BAAM,aAAN;AAAA,MACb;AAAA,MACA,aAAa;AAAA,IACf;AAGA,QAAI,CAAC,IAAI,SAAU,KAAI,WAAW,CAAC;AACnC,QAAI,SAAS,KAAK,MAAM,EAAE,QAAQ,CAAC;AAEnC,QAAI,MAAM,GAAG,IAAI;AAAA,EACnB;AAEA,SAAO,IAAI,MAAM,GAAG;AACtB;AA7JgB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,221 @@
1
+ {
2
+ "name": "fynixui",
3
+ "version": "1.0.10",
4
+ "type": "module",
5
+ "description": "Core package for Fynix UI framework - A lightweight, reactive UI framework with TypeScript support.",
6
+ "main": "./dist/fynix/index.js",
7
+ "module": "./dist/fynix/index.js",
8
+ "types": "./types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/fynix/index.d.ts",
12
+ "import": "./dist/fynix/index.js",
13
+ "default": "./dist/fynix/index.js"
14
+ },
15
+ "./runtime": {
16
+ "types": "./dist/runtime.d.ts",
17
+ "import": "./dist/runtime.js"
18
+ },
19
+ "./context": {
20
+ "types": "./dist/context/context.d.ts",
21
+ "import": "./dist/context/context.js"
22
+ },
23
+ "./custom": {
24
+ "types": "./dist/custom/index.d.ts",
25
+ "import": "./dist/custom/index.js"
26
+ },
27
+ "./custom/button": {
28
+ "types": "./dist/custom/button.d.ts",
29
+ "import": "./dist/custom/button.js"
30
+ },
31
+ "./custom/path": {
32
+ "types": "./dist/custom/path.d.ts",
33
+ "import": "./dist/custom/path.js"
34
+ },
35
+ "./error": {
36
+ "types": "./dist/error/errorOverlay.d.ts",
37
+ "import": "./dist/error/errorOverlay.js"
38
+ },
39
+ "./router": {
40
+ "types": "./dist/router/router.d.ts",
41
+ "import": "./dist/router/router.js"
42
+ },
43
+ "./hooks/nixState": {
44
+ "types": "./dist/hooks/nixState.d.ts",
45
+ "import": "./dist/hooks/nixState.js"
46
+ },
47
+ "./hooks/nixStore": {
48
+ "types": "./dist/hooks/nixStore.d.ts",
49
+ "import": "./dist/hooks/nixStore.js"
50
+ },
51
+ "./hooks/nixEffect": {
52
+ "types": "./dist/hooks/nixEffect.d.ts",
53
+ "import": "./dist/hooks/nixEffect.js"
54
+ },
55
+ "./hooks/nixAsync": {
56
+ "types": "./dist/hooks/nixAsync.d.ts",
57
+ "import": "./dist/hooks/nixAsync.js"
58
+ },
59
+ "./hooks/nixAsyncCache": {
60
+ "types": "./dist/hooks/nixAsyncCache.d.ts",
61
+ "import": "./dist/hooks/nixAsyncCache.js"
62
+ },
63
+ "./hooks/nixAsyncDebounce": {
64
+ "types": "./dist/hooks/nixAsyncDebounce.d.ts",
65
+ "import": "./dist/hooks/nixAsyncDebounce.js"
66
+ },
67
+ "./hooks/nixAsyncQuery": {
68
+ "types": "./dist/hooks/nixAsyncQuery.d.ts",
69
+ "import": "./dist/hooks/nixAsyncQuery.js"
70
+ },
71
+ "./hooks/nixCallback": {
72
+ "types": "./dist/hooks/nixCallback.d.ts",
73
+ "import": "./dist/hooks/nixCallback.js"
74
+ },
75
+ "./hooks/nixComputed": {
76
+ "types": "./dist/hooks/nixComputed.d.ts",
77
+ "import": "./dist/hooks/nixComputed.js"
78
+ },
79
+ "./hooks/nixDebounce": {
80
+ "types": "./dist/hooks/nixDebounce.d.ts",
81
+ "import": "./dist/hooks/nixDebounce.js"
82
+ },
83
+ "./hooks/nixForm": {
84
+ "types": "./dist/hooks/nixForm.d.ts",
85
+ "import": "./dist/hooks/nixForm.js"
86
+ },
87
+ "./hooks/nixFormAsync": {
88
+ "types": "./dist/hooks/nixFormAsync.d.ts",
89
+ "import": "./dist/hooks/nixFormAsync.js"
90
+ },
91
+ "./hooks/nixInterval": {
92
+ "types": "./dist/hooks/nixInterval.d.ts",
93
+ "import": "./dist/hooks/nixInterval.js"
94
+ },
95
+ "./hooks/nixLazy": {
96
+ "types": "./dist/hooks/nixLazy.d.ts",
97
+ "import": "./dist/hooks/nixLazy.js"
98
+ },
99
+ "./hooks/nixLazyAsync": {
100
+ "types": "./dist/hooks/nixLazyAsync.d.ts",
101
+ "import": "./dist/hooks/nixLazyAsync.js"
102
+ },
103
+ "./hooks/nixLazyFormAsync": {
104
+ "types": "./dist/hooks/nixLazyFormAsync.d.ts",
105
+ "import": "./dist/hooks/nixLazyFormAsync.js"
106
+ },
107
+ "./hooks/nixLocalStorage": {
108
+ "types": "./dist/hooks/nixLocalStorage.d.ts",
109
+ "import": "./dist/hooks/nixLocalStorage.js"
110
+ },
111
+ "./hooks/nixMemo": {
112
+ "types": "./dist/hooks/nixMemo.d.ts",
113
+ "import": "./dist/hooks/nixMemo.js"
114
+ },
115
+ "./hooks/nixPrevious": {
116
+ "types": "./dist/hooks/nixPrevious.d.ts",
117
+ "import": "./dist/hooks/nixPrevious.js"
118
+ },
119
+ "./hooks/nixRef": {
120
+ "types": "./dist/hooks/nixRef.d.ts",
121
+ "import": "./dist/hooks/nixRef.js"
122
+ },
123
+ "./plugins/vite-plugin-res": {
124
+ "types": "./dist/plugins/vite-plugin-res.d.ts",
125
+ "import": "./dist/plugins/vite-plugin-res.js"
126
+ },
127
+ "./typescript-plugin": {
128
+ "import": "./dist/typescript-fynix-plugin/index.js",
129
+ "types": "./dist/typescript-fynix-plugin/index.d.ts"
130
+ },
131
+ "./types": {
132
+ "types": "./types/index.d.ts"
133
+ },
134
+ "./types/jsx": {
135
+ "types": "./types/jsx.d.ts"
136
+ },
137
+ "./types/global": {
138
+ "types": "./types/global.d.ts"
139
+ },
140
+ "./types/fnx": {
141
+ "types": "./types/fnx.d.ts"
142
+ },
143
+ "./hooks/nixFor": {
144
+ "types": "./dist/hooks/nixFor.d.ts",
145
+ "import": "./dist/hooks/nixFor.js"
146
+ },
147
+ "./package.json": "./package.json"
148
+ },
149
+ "files": [
150
+ "dist/",
151
+ "types/",
152
+ "README.md",
153
+ "LICENSE"
154
+ ],
155
+ "keywords": [
156
+ "fynix",
157
+ "ui",
158
+ "framework",
159
+ "reactive",
160
+ "typescript",
161
+ "jsx",
162
+ "virtual-dom",
163
+ "hooks",
164
+ "router",
165
+ "state-management"
166
+ ],
167
+ "author": {
168
+ "name": "Resty Gonzales",
169
+ "email": "restygonzales749@gmail.com"
170
+ },
171
+ "repository": {
172
+ "type": "git",
173
+ "url": "https://github.com/fynixorg/ui.git"
174
+ },
175
+ "bugs": {
176
+ "url": "https://github.com/fynixorg/ui/issues"
177
+ },
178
+ "homepage": "https://github.com/fynixorg/ui#readme",
179
+ "license": "MIT",
180
+ "engines": {
181
+ "node": ">=18.0.0",
182
+ "npm": ">=9.0.0"
183
+ },
184
+ "publishConfig": {
185
+ "access": "public",
186
+ "registry": "https://registry.npmjs.org/"
187
+ },
188
+ "peerDependencies": {
189
+ "typescript": ">=5.0.0",
190
+ "vite": "^6.0.0 || ^7.0.0"
191
+ },
192
+ "peerDependenciesMeta": {
193
+ "typescript": {
194
+ "optional": true
195
+ },
196
+ "vite": {
197
+ "optional": true
198
+ }
199
+ },
200
+ "sideEffects": false,
201
+ "typesVersions": {
202
+ "*": {
203
+ "*": [
204
+ "./dist/*"
205
+ ],
206
+ "types": [
207
+ "./types/index.d.ts"
208
+ ],
209
+ "types/jsx": [
210
+ "./types/jsx.d.ts"
211
+ ],
212
+ "types/global": [
213
+ "./types/global.d.ts"
214
+ ]
215
+ }
216
+ },
217
+ "dependencies": {
218
+ "fdir": "^6.5.0",
219
+ "rollup": "^4.56.0"
220
+ }
221
+ }
@@ -0,0 +1,38 @@
1
+ import { type TransformOptions } from "esbuild";
2
+ import type { HmrContext, ViteDevServer } from "vite";
3
+ interface FynixPluginOptions {
4
+ jsxFactory?: string;
5
+ jsxFragment?: string;
6
+ include?: string[];
7
+ exclude?: string[];
8
+ sourcemap?: boolean;
9
+ esbuildOptions?: Partial<TransformOptions>;
10
+ }
11
+ export default function fynixPlugin(options?: FynixPluginOptions): {
12
+ name: string;
13
+ enforce: "pre";
14
+ configureServer(server: ViteDevServer): void;
15
+ transform(code: string, id: string): Promise<{
16
+ code: string;
17
+ map: string | null;
18
+ } | null>;
19
+ handleHotUpdate(ctx: HmrContext): never[] | undefined;
20
+ config(): {
21
+ esbuild: false;
22
+ optimizeDeps: {
23
+ include: string[];
24
+ esbuildOptions: {
25
+ jsx: string;
26
+ jsxFactory: string;
27
+ jsxFragment: string;
28
+ };
29
+ };
30
+ resolve: {
31
+ extensions: string[];
32
+ };
33
+ };
34
+ buildStart(): void;
35
+ };
36
+ export { fynixPlugin };
37
+ export type { FynixPluginOptions };
38
+ //# sourceMappingURL=vite-plugin-res.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin-res.d.ts","sourceRoot":"","sources":["../../plugins/vite-plugin-res.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AAMtD,UAAU,kBAAkB;IAK1B,UAAU,CAAC,EAAE,MAAM,CAAC;IAMpB,WAAW,CAAC,EAAE,MAAM,CAAC;IAMrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAMnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IAMnB,SAAS,CAAC,EAAE,OAAO,CAAC;IAKpB,cAAc,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC5C;AAaD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,OAAO,GAAE,kBAAuB;;;4BAoBxC,aAAa;oBAIf,MAAM,MAAM,MAAM;;;;yBAqEnB,UAAU;;;;;;;;;;;;;;;;EA0ClC;AAKD,OAAO,EAAE,WAAW,EAAE,CAAC;AAKvB,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
@@ -0,0 +1,106 @@
1
+ import { transform } from "esbuild";
2
+ import { normalizePath } from "vite";
3
+ export default function fynixPlugin(options = {}) {
4
+ const { jsxFactory = "Fynix", jsxFragment = "Fynix.Fragment", include = [".ts", ".js", ".jsx", ".tsx", ".fnx"], exclude = ["node_modules"], sourcemap = true, esbuildOptions = {}, } = options;
5
+ let viteServer = null;
6
+ return {
7
+ name: "vite-plugin-fynix",
8
+ enforce: "pre",
9
+ configureServer(server) {
10
+ viteServer = server;
11
+ },
12
+ async transform(code, id) {
13
+ const normalizedId = normalizePath(id);
14
+ const shouldExclude = exclude.some((pattern) => normalizedId.includes(pattern));
15
+ if (shouldExclude)
16
+ return null;
17
+ const shouldInclude = include.some((ext) => normalizedId.endsWith(ext));
18
+ if (!shouldInclude)
19
+ return null;
20
+ const ctx = this;
21
+ if (typeof ctx.addWatchFile === "function") {
22
+ ctx.addWatchFile(id);
23
+ }
24
+ try {
25
+ let loader = "tsx";
26
+ if (normalizedId.endsWith(".ts") || normalizedId.endsWith(".fnx")) {
27
+ loader = "tsx";
28
+ }
29
+ else if (normalizedId.endsWith(".tsx")) {
30
+ loader = "tsx";
31
+ }
32
+ else if (normalizedId.endsWith(".jsx")) {
33
+ loader = "jsx";
34
+ }
35
+ else if (normalizedId.endsWith(".js")) {
36
+ loader = "jsx";
37
+ }
38
+ const result = await transform(code, {
39
+ loader,
40
+ jsxFactory,
41
+ jsxFragment,
42
+ sourcemap,
43
+ sourcefile: id,
44
+ target: "esnext",
45
+ format: "esm",
46
+ ...esbuildOptions,
47
+ });
48
+ return {
49
+ code: result.code,
50
+ map: result.map || null,
51
+ };
52
+ }
53
+ catch (error) {
54
+ const err = error;
55
+ if (viteServer) {
56
+ viteServer.ws.send({
57
+ type: "error",
58
+ err: {
59
+ message: err.message,
60
+ stack: err.stack || "",
61
+ plugin: "vite-plugin-fynix",
62
+ id,
63
+ },
64
+ });
65
+ }
66
+ console.error(`\x1b[32m[vite-plugin-fynix]\x1b[0m \x1b[31mFailed to transform ${id}:\x1b[0m`);
67
+ console.error(err.message);
68
+ return null;
69
+ }
70
+ },
71
+ handleHotUpdate(ctx) {
72
+ const { file, server } = ctx;
73
+ const normalizedFile = normalizePath(file);
74
+ const shouldReload = include.some((ext) => normalizedFile.endsWith(ext));
75
+ if (shouldReload) {
76
+ console.log(`\x1b[32m[vite-plugin-fynix]\x1b[0m HMR: full-reload triggered by ${normalizedFile}`);
77
+ server.ws.send({
78
+ type: "full-reload",
79
+ path: "*",
80
+ });
81
+ return [];
82
+ }
83
+ return undefined;
84
+ },
85
+ config() {
86
+ return {
87
+ esbuild: false,
88
+ optimizeDeps: {
89
+ include: ["fynixui"],
90
+ esbuildOptions: {
91
+ jsx: "transform",
92
+ jsxFactory,
93
+ jsxFragment,
94
+ },
95
+ },
96
+ resolve: {
97
+ extensions: [".fnx", ".ts", ".tsx", ".js", ".jsx", ".json"],
98
+ },
99
+ };
100
+ },
101
+ buildStart() {
102
+ console.log(`\x1b[32m[vite-plugin-fynix]\x1b[0m Initialized with JSX factory: ${jsxFactory}`);
103
+ },
104
+ };
105
+ }
106
+ export { fynixPlugin };