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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/custom/button.js
CHANGED
|
@@ -1,4 +1,244 @@
|
|
|
1
1
|
import { Fynix } from "../runtime.js";
|
|
2
|
+
const VARIANT_STYLES = {
|
|
3
|
+
primary: {
|
|
4
|
+
bg: "#0d6efd",
|
|
5
|
+
color: "#fff",
|
|
6
|
+
border: "#0d6efd",
|
|
7
|
+
hoverBg: "#0b5ed7",
|
|
8
|
+
hoverColor: "#fff",
|
|
9
|
+
hoverBorder: "#0a58ca",
|
|
10
|
+
},
|
|
11
|
+
secondary: {
|
|
12
|
+
bg: "#6c757d",
|
|
13
|
+
color: "#fff",
|
|
14
|
+
border: "#6c757d",
|
|
15
|
+
hoverBg: "#5c636a",
|
|
16
|
+
hoverColor: "#fff",
|
|
17
|
+
hoverBorder: "#565e64",
|
|
18
|
+
},
|
|
19
|
+
success: {
|
|
20
|
+
bg: "#198754",
|
|
21
|
+
color: "#fff",
|
|
22
|
+
border: "#198754",
|
|
23
|
+
hoverBg: "#157347",
|
|
24
|
+
hoverColor: "#fff",
|
|
25
|
+
hoverBorder: "#146c43",
|
|
26
|
+
},
|
|
27
|
+
danger: {
|
|
28
|
+
bg: "#dc3545",
|
|
29
|
+
color: "#fff",
|
|
30
|
+
border: "#dc3545",
|
|
31
|
+
hoverBg: "#bb2d3b",
|
|
32
|
+
hoverColor: "#fff",
|
|
33
|
+
hoverBorder: "#b02a37",
|
|
34
|
+
},
|
|
35
|
+
warning: {
|
|
36
|
+
bg: "#ffc107",
|
|
37
|
+
color: "#212529",
|
|
38
|
+
border: "#ffc107",
|
|
39
|
+
hoverBg: "#ffca2c",
|
|
40
|
+
hoverColor: "#212529",
|
|
41
|
+
hoverBorder: "#ffc720",
|
|
42
|
+
},
|
|
43
|
+
info: {
|
|
44
|
+
bg: "#0dcaf0",
|
|
45
|
+
color: "#212529",
|
|
46
|
+
border: "#0dcaf0",
|
|
47
|
+
hoverBg: "#31d2f2",
|
|
48
|
+
hoverColor: "#212529",
|
|
49
|
+
hoverBorder: "#25cff2",
|
|
50
|
+
},
|
|
51
|
+
light: {
|
|
52
|
+
bg: "#f8f9fa",
|
|
53
|
+
color: "#212529",
|
|
54
|
+
border: "#dee2e6",
|
|
55
|
+
hoverBg: "#f9fafb",
|
|
56
|
+
hoverColor: "#212529",
|
|
57
|
+
hoverBorder: "#d3d4d5",
|
|
58
|
+
},
|
|
59
|
+
dark: {
|
|
60
|
+
bg: "#212529",
|
|
61
|
+
color: "#fff",
|
|
62
|
+
border: "#212529",
|
|
63
|
+
hoverBg: "#424649",
|
|
64
|
+
hoverColor: "#fff",
|
|
65
|
+
hoverBorder: "#373b3e",
|
|
66
|
+
},
|
|
67
|
+
link: {
|
|
68
|
+
bg: "transparent",
|
|
69
|
+
color: "#0d6efd",
|
|
70
|
+
border: "transparent",
|
|
71
|
+
hoverBg: "transparent",
|
|
72
|
+
hoverColor: "#0a58ca",
|
|
73
|
+
hoverBorder: "transparent",
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
const OUTLINE_STYLES = {
|
|
77
|
+
primary: {
|
|
78
|
+
bg: "transparent",
|
|
79
|
+
color: "#0d6efd",
|
|
80
|
+
border: "#0d6efd",
|
|
81
|
+
hoverBg: "#0d6efd",
|
|
82
|
+
hoverColor: "#fff",
|
|
83
|
+
hoverBorder: "#0d6efd",
|
|
84
|
+
},
|
|
85
|
+
secondary: {
|
|
86
|
+
bg: "transparent",
|
|
87
|
+
color: "#6c757d",
|
|
88
|
+
border: "#6c757d",
|
|
89
|
+
hoverBg: "#6c757d",
|
|
90
|
+
hoverColor: "#fff",
|
|
91
|
+
hoverBorder: "#6c757d",
|
|
92
|
+
},
|
|
93
|
+
success: {
|
|
94
|
+
bg: "transparent",
|
|
95
|
+
color: "#198754",
|
|
96
|
+
border: "#198754",
|
|
97
|
+
hoverBg: "#198754",
|
|
98
|
+
hoverColor: "#fff",
|
|
99
|
+
hoverBorder: "#198754",
|
|
100
|
+
},
|
|
101
|
+
danger: {
|
|
102
|
+
bg: "transparent",
|
|
103
|
+
color: "#dc3545",
|
|
104
|
+
border: "#dc3545",
|
|
105
|
+
hoverBg: "#dc3545",
|
|
106
|
+
hoverColor: "#fff",
|
|
107
|
+
hoverBorder: "#dc3545",
|
|
108
|
+
},
|
|
109
|
+
warning: {
|
|
110
|
+
bg: "transparent",
|
|
111
|
+
color: "#ffc107",
|
|
112
|
+
border: "#ffc107",
|
|
113
|
+
hoverBg: "#ffc107",
|
|
114
|
+
hoverColor: "#212529",
|
|
115
|
+
hoverBorder: "#ffc107",
|
|
116
|
+
},
|
|
117
|
+
info: {
|
|
118
|
+
bg: "transparent",
|
|
119
|
+
color: "#0dcaf0",
|
|
120
|
+
border: "#0dcaf0",
|
|
121
|
+
hoverBg: "#0dcaf0",
|
|
122
|
+
hoverColor: "#212529",
|
|
123
|
+
hoverBorder: "#0dcaf0",
|
|
124
|
+
},
|
|
125
|
+
light: {
|
|
126
|
+
bg: "transparent",
|
|
127
|
+
color: "#adb5bd",
|
|
128
|
+
border: "#adb5bd",
|
|
129
|
+
hoverBg: "#f8f9fa",
|
|
130
|
+
hoverColor: "#212529",
|
|
131
|
+
hoverBorder: "#adb5bd",
|
|
132
|
+
},
|
|
133
|
+
dark: {
|
|
134
|
+
bg: "transparent",
|
|
135
|
+
color: "#212529",
|
|
136
|
+
border: "#212529",
|
|
137
|
+
hoverBg: "#212529",
|
|
138
|
+
hoverColor: "#fff",
|
|
139
|
+
hoverBorder: "#212529",
|
|
140
|
+
},
|
|
141
|
+
link: {
|
|
142
|
+
bg: "transparent",
|
|
143
|
+
color: "#0d6efd",
|
|
144
|
+
border: "transparent",
|
|
145
|
+
hoverBg: "transparent",
|
|
146
|
+
hoverColor: "#0a58ca",
|
|
147
|
+
hoverBorder: "transparent",
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
const SIZE_STYLES = {
|
|
151
|
+
sm: { padding: "4px 8px", fontSize: "12px" },
|
|
152
|
+
md: { padding: "6px 12px", fontSize: "14px" },
|
|
153
|
+
lg: { padding: "8px 16px", fontSize: "16px" },
|
|
154
|
+
};
|
|
155
|
+
const BASE_STYLE = {
|
|
156
|
+
display: "inline-block",
|
|
157
|
+
fontWeight: "400",
|
|
158
|
+
lineHeight: "1.5",
|
|
159
|
+
textAlign: "center",
|
|
160
|
+
textDecoration: "none",
|
|
161
|
+
verticalAlign: "middle",
|
|
162
|
+
cursor: "pointer",
|
|
163
|
+
userSelect: "none",
|
|
164
|
+
borderWidth: "1px",
|
|
165
|
+
borderStyle: "solid",
|
|
166
|
+
borderRadius: "4px",
|
|
167
|
+
transition: "color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out",
|
|
168
|
+
};
|
|
169
|
+
let stylesInjected = false;
|
|
170
|
+
function injectButtonStyles() {
|
|
171
|
+
if (stylesInjected || typeof document === "undefined")
|
|
172
|
+
return;
|
|
173
|
+
stylesInjected = true;
|
|
174
|
+
const rules = [];
|
|
175
|
+
for (const [variant, colors] of Object.entries(VARIANT_STYLES)) {
|
|
176
|
+
rules.push(`
|
|
177
|
+
button[data-fynix-btn="${variant}"]:not([disabled]):hover {
|
|
178
|
+
background-color: ${colors.hoverBg} !important;
|
|
179
|
+
color: ${colors.hoverColor} !important;
|
|
180
|
+
border-color: ${colors.hoverBorder} !important;
|
|
181
|
+
${variant === "link" ? "text-decoration: underline !important;" : ""}
|
|
182
|
+
}
|
|
183
|
+
`);
|
|
184
|
+
}
|
|
185
|
+
for (const [variant, colors] of Object.entries(OUTLINE_STYLES)) {
|
|
186
|
+
rules.push(`
|
|
187
|
+
button[data-fynix-btn="outline-${variant}"]:not([disabled]):hover {
|
|
188
|
+
background-color: ${colors.hoverBg} !important;
|
|
189
|
+
color: ${colors.hoverColor} !important;
|
|
190
|
+
border-color: ${colors.hoverBorder} !important;
|
|
191
|
+
}
|
|
192
|
+
`);
|
|
193
|
+
}
|
|
194
|
+
const style = document.createElement("style");
|
|
195
|
+
style.setAttribute("data-fynix", "button-styles");
|
|
196
|
+
style.textContent = rules.join("\n");
|
|
197
|
+
document.head.appendChild(style);
|
|
198
|
+
}
|
|
2
199
|
export function Button({ value = "", ...props }) {
|
|
3
|
-
|
|
200
|
+
const { value: _stripped, ...cleanProps } = props;
|
|
201
|
+
return Fynix("button", cleanProps, value);
|
|
202
|
+
}
|
|
203
|
+
function UIButton({ value = "", variant = "primary", size = "md", outline = false, style: customStyle = {}, disabled = false, ...props }) {
|
|
204
|
+
injectButtonStyles();
|
|
205
|
+
const colors = outline ? OUTLINE_STYLES[variant] : VARIANT_STYLES[variant];
|
|
206
|
+
const sizing = SIZE_STYLES[size];
|
|
207
|
+
const dataAttr = outline ? `outline-${variant}` : variant;
|
|
208
|
+
const computedStyle = {
|
|
209
|
+
...BASE_STYLE,
|
|
210
|
+
backgroundColor: colors.bg,
|
|
211
|
+
color: colors.color,
|
|
212
|
+
borderColor: colors.border,
|
|
213
|
+
padding: sizing.padding,
|
|
214
|
+
fontSize: sizing.fontSize,
|
|
215
|
+
opacity: disabled ? "0.65" : "1",
|
|
216
|
+
pointerEvents: disabled ? "none" : "auto",
|
|
217
|
+
...customStyle,
|
|
218
|
+
};
|
|
219
|
+
return Button({
|
|
220
|
+
value,
|
|
221
|
+
style: computedStyle,
|
|
222
|
+
disabled,
|
|
223
|
+
"data-fynix-btn": dataAttr,
|
|
224
|
+
...props,
|
|
225
|
+
});
|
|
4
226
|
}
|
|
227
|
+
export const PrimaryButton = (p) => UIButton({ ...p, variant: "primary" });
|
|
228
|
+
export const SecondaryButton = (p) => UIButton({ ...p, variant: "secondary" });
|
|
229
|
+
export const SuccessButton = (p) => UIButton({ ...p, variant: "success" });
|
|
230
|
+
export const DangerButton = (p) => UIButton({ ...p, variant: "danger" });
|
|
231
|
+
export const WarningButton = (p) => UIButton({ ...p, variant: "warning" });
|
|
232
|
+
export const InfoButton = (p) => UIButton({ ...p, variant: "info" });
|
|
233
|
+
export const LightButton = (p) => UIButton({ ...p, variant: "light" });
|
|
234
|
+
export const DarkButton = (p) => UIButton({ ...p, variant: "dark" });
|
|
235
|
+
export const LinkButton = (p) => UIButton({ ...p, variant: "link" });
|
|
236
|
+
export const OutlinePrimaryButton = (p) => UIButton({ ...p, variant: "primary", outline: true });
|
|
237
|
+
export const OutlineSecondaryButton = (p) => UIButton({ ...p, variant: "secondary", outline: true });
|
|
238
|
+
export const OutlineSuccessButton = (p) => UIButton({ ...p, variant: "success", outline: true });
|
|
239
|
+
export const OutlineDangerButton = (p) => UIButton({ ...p, variant: "danger", outline: true });
|
|
240
|
+
export const OutlineWarningButton = (p) => UIButton({ ...p, variant: "warning", outline: true });
|
|
241
|
+
export const OutlineInfoButton = (p) => UIButton({ ...p, variant: "info", outline: true });
|
|
242
|
+
export const OutlineLightButton = (p) => UIButton({ ...p, variant: "light", outline: true });
|
|
243
|
+
export const OutlineDarkButton = (p) => UIButton({ ...p, variant: "dark", outline: true });
|
|
244
|
+
export const OutlineLinkButton = (p) => UIButton({ ...p, variant: "link", outline: true });
|
package/dist/custom/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Button } from "./button";
|
|
1
|
+
export { Button, PrimaryButton, SecondaryButton, SuccessButton, DangerButton, WarningButton, InfoButton, LightButton, DarkButton, LinkButton, } from "./button";
|
|
2
2
|
export { Path } from "./path";
|
package/dist/hooks/nixFor.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { Fragment } from "../runtime";
|
|
1
|
+
import { Fragment } from "../runtime.js";
|
|
2
2
|
export function For(props) {
|
|
3
3
|
let items = [];
|
|
4
|
-
if (props.each &&
|
|
4
|
+
if (props.each &&
|
|
5
|
+
typeof props.each === "object" &&
|
|
6
|
+
"_isNixState" in props.each) {
|
|
5
7
|
items = props.each.value;
|
|
6
8
|
}
|
|
7
9
|
else if (Array.isArray(props.each)) {
|
|
@@ -33,9 +35,9 @@ export function For(props) {
|
|
|
33
35
|
type: "div",
|
|
34
36
|
props: {
|
|
35
37
|
children: ["Error rendering item"],
|
|
36
|
-
style: "color: red;"
|
|
38
|
+
style: "color: red;",
|
|
37
39
|
},
|
|
38
|
-
key: index
|
|
40
|
+
key: index,
|
|
39
41
|
};
|
|
40
42
|
}
|
|
41
43
|
});
|
package/dist/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"
|
|
@@ -201,7 +202,7 @@
|
|
|
201
202
|
"typesVersions": {
|
|
202
203
|
"*": {
|
|
203
204
|
"*": [
|
|
204
|
-
"./dist/*"
|
|
205
|
+
"./dist-types/*"
|
|
205
206
|
],
|
|
206
207
|
"types": [
|
|
207
208
|
"./types/index.d.ts"
|
|
@@ -213,9 +214,5 @@
|
|
|
213
214
|
"./types/global.d.ts"
|
|
214
215
|
]
|
|
215
216
|
}
|
|
216
|
-
},
|
|
217
|
-
"dependencies": {
|
|
218
|
-
"fdir": "^6.5.0",
|
|
219
|
-
"rollup": "^4.56.0"
|
|
220
217
|
}
|
|
221
218
|
}
|
|
@@ -1,8 +1,18 @@
|
|
|
1
1
|
import { transform } from "esbuild";
|
|
2
2
|
import { normalizePath } from "vite";
|
|
3
|
+
import crypto from "crypto";
|
|
3
4
|
export default function fynixPlugin(options = {}) {
|
|
4
|
-
const { jsxFactory = "Fynix", jsxFragment = "Fynix.Fragment", include = [".ts", ".js", ".jsx", ".tsx", ".fnx"], exclude = ["node_modules"],
|
|
5
|
+
const { jsxFactory = "Fynix", jsxFragment = "Fynix.Fragment", include = [".ts", ".js", ".jsx", ".tsx", ".fnx"], exclude = ["node_modules"], esbuildOptions = {}, } = options;
|
|
5
6
|
let viteServer = null;
|
|
7
|
+
const transformCache = new Map();
|
|
8
|
+
function hasJsxLike(code) {
|
|
9
|
+
return (/<[A-Za-z]/.test(code) ||
|
|
10
|
+
/Fynix\s*\(/.test(code) ||
|
|
11
|
+
/Fragment|<>/.test(code));
|
|
12
|
+
}
|
|
13
|
+
function getContentHash(code) {
|
|
14
|
+
return crypto.createHash("md5").update(code).digest("hex");
|
|
15
|
+
}
|
|
6
16
|
return {
|
|
7
17
|
name: "vite-plugin-fynix",
|
|
8
18
|
enforce: "pre",
|
|
@@ -17,6 +27,14 @@ export default function fynixPlugin(options = {}) {
|
|
|
17
27
|
const shouldInclude = include.some((ext) => normalizedId.endsWith(ext));
|
|
18
28
|
if (!shouldInclude)
|
|
19
29
|
return null;
|
|
30
|
+
if (!hasJsxLike(code)) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const contentHash = getContentHash(code);
|
|
34
|
+
const cached = transformCache.get(normalizedId);
|
|
35
|
+
if (cached && cached.contentHash === contentHash) {
|
|
36
|
+
return { code: cached.code, map: cached.map };
|
|
37
|
+
}
|
|
20
38
|
const ctx = this;
|
|
21
39
|
if (typeof ctx.addWatchFile === "function") {
|
|
22
40
|
ctx.addWatchFile(id);
|
|
@@ -39,16 +57,19 @@ export default function fynixPlugin(options = {}) {
|
|
|
39
57
|
loader,
|
|
40
58
|
jsxFactory,
|
|
41
59
|
jsxFragment,
|
|
42
|
-
sourcemap,
|
|
60
|
+
sourcemap: false,
|
|
43
61
|
sourcefile: id,
|
|
44
62
|
target: "esnext",
|
|
45
63
|
format: "esm",
|
|
46
64
|
...esbuildOptions,
|
|
47
65
|
});
|
|
48
|
-
|
|
66
|
+
const transformed = {
|
|
49
67
|
code: result.code,
|
|
50
|
-
map:
|
|
68
|
+
map: null,
|
|
69
|
+
contentHash,
|
|
51
70
|
};
|
|
71
|
+
transformCache.set(normalizedId, transformed);
|
|
72
|
+
return { code: transformed.code, map: transformed.map };
|
|
52
73
|
}
|
|
53
74
|
catch (error) {
|
|
54
75
|
const err = error;
|
|
@@ -71,6 +92,7 @@ export default function fynixPlugin(options = {}) {
|
|
|
71
92
|
handleHotUpdate(ctx) {
|
|
72
93
|
const { file, server } = ctx;
|
|
73
94
|
const normalizedFile = normalizePath(file);
|
|
95
|
+
transformCache.delete(normalizedFile);
|
|
74
96
|
const shouldReload = include.some((ext) => normalizedFile.endsWith(ext));
|
|
75
97
|
if (shouldReload) {
|
|
76
98
|
console.log(`\x1b[32m[vite-plugin-fynix]\x1b[0m HMR: full-reload triggered by ${normalizedFile}`);
|