elit 3.3.1 → 3.3.2

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/cli.js CHANGED
@@ -1435,7 +1435,7 @@ var require_package = __commonJS({
1435
1435
  "package.json"(exports2, module2) {
1436
1436
  module2.exports = {
1437
1437
  name: "elit",
1438
- version: "3.3.1",
1438
+ version: "3.3.2",
1439
1439
  description: "Optimized lightweight library for creating DOM elements with reactive state",
1440
1440
  main: "dist/index.js",
1441
1441
  module: "dist/index.mjs",
package/dist/index.js CHANGED
@@ -2216,7 +2216,20 @@ function createRouter(options) {
2216
2216
  if (match?.route.beforeEnter) {
2217
2217
  if (!executeGuard(match.route.beforeEnter, location2, currentRoute.value, navigate, replace)) return;
2218
2218
  }
2219
- const url = mode === "hash" ? "#" + path : base2 + path;
2219
+ let urlPath = path;
2220
+ let url;
2221
+ if (mode === "hash") {
2222
+ url = "#" + path;
2223
+ } else {
2224
+ const hasBaseSlash = base2.endsWith("/");
2225
+ const hasPathSlash = path.startsWith("/");
2226
+ if (hasBaseSlash && hasPathSlash) {
2227
+ urlPath = path.slice(1);
2228
+ } else if (!hasBaseSlash && !hasPathSlash && path !== "/") {
2229
+ urlPath = "/" + path;
2230
+ }
2231
+ url = base2 + urlPath;
2232
+ }
2220
2233
  if (replace) {
2221
2234
  window.history.replaceState({ path }, "", url);
2222
2235
  } else {
@@ -2238,6 +2251,7 @@ function createRouter(options) {
2238
2251
  }
2239
2252
  return {
2240
2253
  currentRoute,
2254
+ mode,
2241
2255
  navigate,
2242
2256
  push: (path) => navigate(path, false),
2243
2257
  replace: (path) => navigate(path, true),
@@ -2273,11 +2287,12 @@ function createRouterView(router, options) {
2273
2287
  };
2274
2288
  }
2275
2289
  var routerLink = (router, props, ...children) => {
2290
+ const href = router.mode === "hash" ? `#${props.to}` : props.to;
2276
2291
  return {
2277
2292
  tagName: "a",
2278
2293
  props: {
2279
2294
  ...props,
2280
- href: props.to,
2295
+ href,
2281
2296
  onclick: (e) => {
2282
2297
  e.preventDefault();
2283
2298
  router.push(props.to);
package/dist/index.mjs CHANGED
@@ -1937,7 +1937,20 @@ function createRouter(options) {
1937
1937
  if (match?.route.beforeEnter) {
1938
1938
  if (!executeGuard(match.route.beforeEnter, location2, currentRoute.value, navigate, replace)) return;
1939
1939
  }
1940
- const url = mode === "hash" ? "#" + path : base2 + path;
1940
+ let urlPath = path;
1941
+ let url;
1942
+ if (mode === "hash") {
1943
+ url = "#" + path;
1944
+ } else {
1945
+ const hasBaseSlash = base2.endsWith("/");
1946
+ const hasPathSlash = path.startsWith("/");
1947
+ if (hasBaseSlash && hasPathSlash) {
1948
+ urlPath = path.slice(1);
1949
+ } else if (!hasBaseSlash && !hasPathSlash && path !== "/") {
1950
+ urlPath = "/" + path;
1951
+ }
1952
+ url = base2 + urlPath;
1953
+ }
1941
1954
  if (replace) {
1942
1955
  window.history.replaceState({ path }, "", url);
1943
1956
  } else {
@@ -1959,6 +1972,7 @@ function createRouter(options) {
1959
1972
  }
1960
1973
  return {
1961
1974
  currentRoute,
1975
+ mode,
1962
1976
  navigate,
1963
1977
  push: (path) => navigate(path, false),
1964
1978
  replace: (path) => navigate(path, true),
@@ -1994,11 +2008,12 @@ function createRouterView(router, options) {
1994
2008
  };
1995
2009
  }
1996
2010
  var routerLink = (router, props, ...children) => {
2011
+ const href = router.mode === "hash" ? `#${props.to}` : props.to;
1997
2012
  return {
1998
2013
  tagName: "a",
1999
2014
  props: {
2000
2015
  ...props,
2001
- href: props.to,
2016
+ href,
2002
2017
  onclick: (e) => {
2003
2018
  e.preventDefault();
2004
2019
  router.push(props.to);
package/dist/router.d.mts CHANGED
@@ -30,6 +30,7 @@ interface RouterOptions {
30
30
  }
31
31
  interface Router {
32
32
  currentRoute: State<RouteLocation>;
33
+ mode: 'history' | 'hash';
33
34
  navigate: (path: string, replace?: boolean) => void;
34
35
  push: (path: string) => void;
35
36
  replace: (path: string) => void;
package/dist/router.d.ts CHANGED
@@ -24,6 +24,7 @@ export interface RouterOptions {
24
24
  }
25
25
  export interface Router {
26
26
  currentRoute: State<RouteLocation>;
27
+ mode: 'history' | 'hash';
27
28
  navigate: (path: string, replace?: boolean) => void;
28
29
  push: (path: string) => void;
29
30
  replace: (path: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAG1D,MAAM,WAAW,KAAK;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,KAAK,GAAG,KAAK,CAAC;IAClD,WAAW,CAAC,EAAE,CAAC,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,IAAI,KAAK,OAAO,GAAG,MAAM,GAAG,IAAI,CAAC;CAC5F;AAED,MAAM,WAAW,WAAW;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC1B,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,KAAK,GAAG,KAAK,CAAC;CACrD;AAED,MAAM,WAAW,MAAM;IACnB,YAAY,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC;IACnC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC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,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,GAAG,MAAM,KAAK,CAoBpF;AAGD,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,OAAO,KAAK,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,EAAE,GAAG,UAAU,KAAK,EAAE,KAAG,KAgBhG,CAAC"}
package/dist/router.js CHANGED
@@ -772,7 +772,20 @@ function createRouter(options) {
772
772
  if (match?.route.beforeEnter) {
773
773
  if (!executeGuard(match.route.beforeEnter, location, currentRoute.value, navigate, replace)) return;
774
774
  }
775
- const url = mode === "hash" ? "#" + path : base + path;
775
+ let urlPath = path;
776
+ let url;
777
+ if (mode === "hash") {
778
+ url = "#" + path;
779
+ } else {
780
+ const hasBaseSlash = base.endsWith("/");
781
+ const hasPathSlash = path.startsWith("/");
782
+ if (hasBaseSlash && hasPathSlash) {
783
+ urlPath = path.slice(1);
784
+ } else if (!hasBaseSlash && !hasPathSlash && path !== "/") {
785
+ urlPath = "/" + path;
786
+ }
787
+ url = base + urlPath;
788
+ }
776
789
  if (replace) {
777
790
  window.history.replaceState({ path }, "", url);
778
791
  } else {
@@ -794,6 +807,7 @@ function createRouter(options) {
794
807
  }
795
808
  return {
796
809
  currentRoute,
810
+ mode,
797
811
  navigate,
798
812
  push: (path) => navigate(path, false),
799
813
  replace: (path) => navigate(path, true),
@@ -829,11 +843,12 @@ function createRouterView(router, options) {
829
843
  };
830
844
  }
831
845
  var routerLink = (router, props, ...children) => {
846
+ const href = router.mode === "hash" ? `#${props.to}` : props.to;
832
847
  return {
833
848
  tagName: "a",
834
849
  props: {
835
850
  ...props,
836
- href: props.to,
851
+ href,
837
852
  onclick: (e) => {
838
853
  e.preventDefault();
839
854
  router.push(props.to);
package/dist/router.mjs CHANGED
@@ -744,7 +744,20 @@ function createRouter(options) {
744
744
  if (match?.route.beforeEnter) {
745
745
  if (!executeGuard(match.route.beforeEnter, location, currentRoute.value, navigate, replace)) return;
746
746
  }
747
- const url = mode === "hash" ? "#" + path : base + path;
747
+ let urlPath = path;
748
+ let url;
749
+ if (mode === "hash") {
750
+ url = "#" + path;
751
+ } else {
752
+ const hasBaseSlash = base.endsWith("/");
753
+ const hasPathSlash = path.startsWith("/");
754
+ if (hasBaseSlash && hasPathSlash) {
755
+ urlPath = path.slice(1);
756
+ } else if (!hasBaseSlash && !hasPathSlash && path !== "/") {
757
+ urlPath = "/" + path;
758
+ }
759
+ url = base + urlPath;
760
+ }
748
761
  if (replace) {
749
762
  window.history.replaceState({ path }, "", url);
750
763
  } else {
@@ -766,6 +779,7 @@ function createRouter(options) {
766
779
  }
767
780
  return {
768
781
  currentRoute,
782
+ mode,
769
783
  navigate,
770
784
  push: (path) => navigate(path, false),
771
785
  replace: (path) => navigate(path, true),
@@ -801,11 +815,12 @@ function createRouterView(router, options) {
801
815
  };
802
816
  }
803
817
  var routerLink = (router, props, ...children) => {
818
+ const href = router.mode === "hash" ? `#${props.to}` : props.to;
804
819
  return {
805
820
  tagName: "a",
806
821
  props: {
807
822
  ...props,
808
- href: props.to,
823
+ href,
809
824
  onclick: (e) => {
810
825
  e.preventDefault();
811
826
  router.push(props.to);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elit",
3
- "version": "3.3.1",
3
+ "version": "3.3.2",
4
4
  "description": "Optimized lightweight library for creating DOM elements with reactive state",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/router.ts CHANGED
@@ -31,6 +31,7 @@ export interface RouterOptions {
31
31
 
32
32
  export interface Router {
33
33
  currentRoute: State<RouteLocation>;
34
+ mode: 'history' | 'hash';
34
35
  navigate: (path: string, replace?: boolean) => void;
35
36
  push: (path: string) => void;
36
37
  replace: (path: string) => void;
@@ -157,7 +158,23 @@ export function createRouter(options: RouterOptions): Router {
157
158
  if (!executeGuard(match.route.beforeEnter, location, currentRoute.value, navigate, replace)) return;
158
159
  }
159
160
 
160
- const url = mode === 'hash' ? '#' + path : base + path;
161
+ // Remove leading slash from path if base has trailing slash, or add slash if needed
162
+ let urlPath = path;
163
+ let url: string;
164
+ if (mode === 'hash') {
165
+ url = '#' + path;
166
+ } else {
167
+ // Ensure proper path joining
168
+ const hasBaseSlash = base.endsWith('/');
169
+ const hasPathSlash = path.startsWith('/');
170
+ if (hasBaseSlash && hasPathSlash) {
171
+ urlPath = path.slice(1); // Remove duplicate slash
172
+ } else if (!hasBaseSlash && !hasPathSlash && path !== '/') {
173
+ urlPath = '/' + path; // Add slash between
174
+ }
175
+ url = base + urlPath;
176
+ }
177
+
161
178
  if (replace) {
162
179
  window.history.replaceState({ path }, '', url);
163
180
  } else {
@@ -183,6 +200,7 @@ export function createRouter(options: RouterOptions): Router {
183
200
 
184
201
  return {
185
202
  currentRoute,
203
+ mode,
186
204
  navigate,
187
205
  push: (path: string) => navigate(path, false),
188
206
  replace: (path: string) => navigate(path, true),
@@ -224,11 +242,14 @@ export function createRouterView(router: Router, options: RouterOptions): () =>
224
242
 
225
243
  // Link component - prevents default and uses router
226
244
  export const routerLink = (router: Router, props: Props & { to: string }, ...children: Child[]): VNode => {
245
+ // Use router.mode to determine href format
246
+ const href = router.mode === 'hash' ? `#${props.to}` : props.to;
247
+
227
248
  return {
228
249
  tagName: 'a',
229
250
  props: {
230
251
  ...props,
231
- href: props.to,
252
+ href,
232
253
  onclick: (e: MouseEvent) => {
233
254
  e.preventDefault();
234
255
  router.push(props.to);