@inglorious/web 2.4.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -441,6 +441,13 @@ api.notify("navigate", "/users/456")
441
441
 
442
442
  // Or navigate back in history
443
443
  api.notify("navigate", -1)
444
+
445
+ // With options
446
+ api.notify("navigate", {
447
+ to: "/users/456",
448
+ replace: true, // Replace current history entry
449
+ force: true, // Force navigation even if path is identical
450
+ })
444
451
  ```
445
452
 
446
453
  ### 4. Lazy Loading Routes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inglorious/web",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "A new web framework that leverages the power of the Inglorious Store combined with the performance and simplicity of lit-html.",
5
5
  "author": "IceOnFire <antony.mistretta@gmail.com> (https://ingloriouscoderz.it)",
6
6
  "license": "MIT",
@@ -38,8 +38,8 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "lit-html": "^3.3.1",
41
- "@inglorious/utils": "3.7.0",
42
- "@inglorious/store": "7.1.4"
41
+ "@inglorious/store": "7.1.4",
42
+ "@inglorious/utils": "3.7.0"
43
43
  },
44
44
  "devDependencies": {
45
45
  "prettier": "^3.6.2",
package/src/router.js CHANGED
@@ -88,7 +88,7 @@ export const router = {
88
88
  const options = ["number", "string"].includes(typeof payload)
89
89
  ? { to: payload }
90
90
  : payload
91
- const { to, params, replace, state = {} } = options
91
+ const { to, params, replace, force, state = {} } = options
92
92
 
93
93
  // Numeric navigation (back/forward)
94
94
  if (typeof to === "number") {
@@ -114,11 +114,13 @@ export const router = {
114
114
  return
115
115
  }
116
116
 
117
- // Prevent navigation if the full path (including query/hash) is identical.
118
- const currentFullPath =
119
- entity.path + window.location.search + window.location.hash
120
- if (path === currentFullPath) {
121
- return
117
+ if (!force) {
118
+ // Prevent navigation if the full path (including query/hash) is identical.
119
+ const currentFullPath =
120
+ entity.path + window.location.search + window.location.hash
121
+ if (path === currentFullPath) {
122
+ return
123
+ }
122
124
  }
123
125
 
124
126
  // Asynchronous navigation
@@ -138,6 +138,20 @@ describe("router", () => {
138
138
  expect.any(Object),
139
139
  )
140
140
  })
141
+
142
+ it("should navigate if the path is identical but force is true", () => {
143
+ entity.path = "/users"
144
+ vi.spyOn(window, "location", "get").mockReturnValue({
145
+ pathname: "/users",
146
+ search: "",
147
+ hash: "",
148
+ })
149
+
150
+ router.navigate(entity, { to: "/users", force: true }, api)
151
+
152
+ expect(history.pushState).toHaveBeenCalled()
153
+ expect(api.notify).toHaveBeenCalledWith("routeChange", expect.any(Object))
154
+ })
141
155
  })
142
156
 
143
157
  describe("routeSync()", () => {