@jasonshimmy/vite-plugin-cer-app 0.25.0 → 0.26.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.
@@ -1 +1 @@
1
- {"version":3,"file":"app-template.d.ts","sourceRoot":"","sources":["../../src/runtime/app-template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CA2hBtF"}
1
+ {"version":3,"file":"app-template.d.ts","sourceRoot":"","sources":["../../src/runtime/app-template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CAAC,aAAa,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAqkBtF"}
@@ -77,6 +77,12 @@ let _currentPageKey = null
77
77
  // redirects (e.g. middleware returning '/login') so cer-layout-view falls
78
78
  // back to <router-view> when the current route differs from what was pre-loaded.
79
79
  let _currentPagePath = null
80
+ // The pathname + query whose page data is currently loaded. Browser history
81
+ // traversals that change only the fragment must stay on the runtime router's
82
+ // lightweight scroll path instead of needlessly re-running the page loader.
83
+ let _currentPageLocation = typeof window !== 'undefined'
84
+ ? window.location.pathname + window.location.search
85
+ : null
80
86
  // Route chunks and loaders may resolve out of order during rapid navigation or
81
87
  // initial hydration. Only the newest request is allowed to publish page state.
82
88
  let _pageLoadVersion = 0
@@ -104,6 +110,7 @@ async function _loadPageForPath(path, options = {}) {
104
110
  _currentPageAttrs = {}
105
111
  _currentPageKey = null
106
112
  _currentPagePath = url.pathname
113
+ _currentPageLocation = url.pathname + url.search
107
114
  return
108
115
  }
109
116
  const mod = await route.load()
@@ -140,6 +147,7 @@ async function _loadPageForPath(path, options = {}) {
140
147
  }
141
148
  _currentPageTag = mod.default ?? null
142
149
  _currentPagePath = url.pathname
150
+ _currentPageLocation = url.pathname + url.search
143
151
  _currentPageAttrs = loaderAttrs
144
152
  _currentPageKey = loadVersion
145
153
  } catch {
@@ -207,6 +215,40 @@ router.replace = async (path) => {
207
215
  }
208
216
  }
209
217
 
218
+ // The runtime router owns the History API and commits route state on popstate.
219
+ // push/replace above can prepare the destination before that commit because the
220
+ // app initiated those navigations. Browser Back/Forward bypass those methods,
221
+ // so mirror their page-module/data preparation here. The runtime registered its
222
+ // popstate listener during initRouter(); its async guard pipeline and this async
223
+ // page load can safely proceed together, while isNavigating guarantees a final
224
+ // render after the page load publishes its non-reactive tag/attrs bookkeeping.
225
+ window.addEventListener('popstate', () => {
226
+ const path = window.location.pathname + window.location.search + window.location.hash
227
+ const pageLocation = window.location.pathname + window.location.search
228
+
229
+ // Fragment-only traversal needs no new component or loader data. The runtime
230
+ // still receives the event and synchronizes the route fragment/scroll state.
231
+ if (pageLocation === _currentPageLocation) return
232
+
233
+ const navigationIntent = ++_navigationIntent
234
+ isNavigating.value = true
235
+ _activateClientRouteRendering()
236
+ currentError.value = null
237
+
238
+ void (async () => {
239
+ try {
240
+ delete (globalThis).__CER_DATA__
241
+ await _loadPageForPath(path)
242
+ } catch (err) {
243
+ if (navigationIntent === _navigationIntent) {
244
+ currentError.value = err instanceof Error ? err.message : String(err)
245
+ }
246
+ } finally {
247
+ if (navigationIntent === _navigationIntent) isNavigating.value = false
248
+ }
249
+ })()
250
+ })
251
+
210
252
  // Make ordinary internal links participate in client-side routing even when
211
253
  // their owning custom element has not hydrated yet. The listener runs in the
212
254
  // bubble phase so an upgraded component gets first refusal: handlers such as
@@ -1 +1 @@
1
- {"version":3,"file":"app-template.js","sourceRoot":"","sources":["../../src/runtime/app-template.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CAAC,gBAAmC,EAAE;IAC5E,MAAM,kBAAkB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,aAAa,CAAC,CAAC;SACnD,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,WAAW,SAAS,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,CA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AAC,IAAI,CAAC,CAAA;IACb,OAAO;;;;EAIP,kBAAkB,GAAG,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4jBpD,CAAA;AACD,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jasonshimmy/vite-plugin-cer-app",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "description": "Nuxt-style meta-framework for @jasonshimmy/custom-elements-runtime",
5
5
  "type": "module",
6
6
  "keywords": [