@simonbackx/vue-app-navigation 2.15.0 → 2.17.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/dist/index.js CHANGED
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => {
4
4
  __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
  return value;
6
6
  };
7
- import { inject, proxyRefs, markRaw, ref, reactive, getCurrentInstance, provide, computed, unref, onActivated, onMounted, queuePostFlushCb, onBeforeUnmount, onBeforeMount, onUpdated, warn, h, setTransitionHooks, callWithAsyncErrorHandling, ErrorCodes, shallowRef, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, defineComponent, Transition, withCtx, createBlock, createCommentVNode, customRef, onScopeDispose, TransitionGroup, Fragment, renderList, isRef, onDeactivated, normalizeClass, normalizeStyle } from "vue";
7
+ import { inject, proxyRefs, markRaw, ref, reactive, defineComponent, getCurrentInstance, provide, computed, unref, onActivated, onMounted, queuePostFlushCb, onBeforeUnmount, onBeforeMount, onUpdated, warn, h, setTransitionHooks, callWithAsyncErrorHandling, ErrorCodes, shallowRef, resolveComponent, openBlock, createElementBlock, createElementVNode, createVNode, mergeProps, Transition, withCtx, createBlock, createCommentVNode, customRef, onScopeDispose, TransitionGroup, Fragment, renderList, isRef, onDeactivated, normalizeClass, normalizeStyle } from "vue";
8
8
  const _UrlHelper = class _UrlHelper {
9
9
  constructor(url, localFixedPrefix) {
10
10
  __publicField(this, "url");
@@ -203,6 +203,7 @@ function templateToUrl(template, params) {
203
203
  }
204
204
  class HistoryManagerStatic {
205
205
  constructor() {
206
+ __publicField(this, "debug", false);
206
207
  // undoActions: Map<number, (animate: boolean) => void> = new Map();
207
208
  __publicField(this, "states", []);
208
209
  __publicField(this, "counter", 0);
@@ -303,6 +304,9 @@ class HistoryManagerStatic {
303
304
  if (!this.active) {
304
305
  return;
305
306
  }
307
+ if (this.debug) {
308
+ console.log("Set url: " + url + ", for index " + index + " with current counter: " + this.counter, title);
309
+ }
306
310
  if (index === void 0 || index === this.counter) {
307
311
  const state = this.states[this.states.length - 1];
308
312
  const count = state.index;
@@ -319,6 +323,9 @@ class HistoryManagerStatic {
319
323
  if (this.counter !== count || state.url !== url) {
320
324
  return;
321
325
  }
326
+ if (this.debug) {
327
+ console.log("history.replaceState", count, url);
328
+ }
322
329
  const formattedUrl = this.resolveUrl(count);
323
330
  history.replaceState({ counter: count }, "", formattedUrl);
324
331
  if (state.title) {
@@ -340,8 +347,11 @@ class HistoryManagerStatic {
340
347
  console.error("Search state with index ", index, "but received state with index", state.index);
341
348
  return;
342
349
  }
343
- if (state.url !== url)
344
- ;
350
+ if (state.url !== url) {
351
+ if (this.debug) {
352
+ console.info("Changed url for old state: " + state.index + " to " + url);
353
+ }
354
+ }
345
355
  state.url = url;
346
356
  if (title) {
347
357
  state.title = title;
@@ -363,6 +373,9 @@ class HistoryManagerStatic {
363
373
  if (this.counter !== count) {
364
374
  return;
365
375
  }
376
+ if (this.debug) {
377
+ console.log("history.replaceState - updateUrl");
378
+ }
366
379
  const formattedUrl = this.resolveUrl(count);
367
380
  history.replaceState({ counter: count }, "", formattedUrl);
368
381
  });
@@ -428,19 +441,31 @@ class HistoryManagerStatic {
428
441
  const c = this.counter;
429
442
  if (state.adjustHistory) {
430
443
  this.addToQueue(() => {
444
+ if (this.debug) {
445
+ console.log("history.pushState", c, url);
446
+ }
431
447
  const formattedUrl = url === void 0 ? void 0 : "/" + UrlHelper.trim(UrlHelper.transformUrl(url));
432
448
  history.pushState({ counter: c }, "", formattedUrl);
433
449
  });
434
450
  } else {
435
451
  this.addToQueue(() => {
452
+ if (this.debug) {
453
+ console.log("history.replaceState", c);
454
+ }
436
455
  history.replaceState({ counter: c }, "", void 0);
437
456
  });
438
457
  }
458
+ if (this.debug) {
459
+ console.log("Push new state ", this.states[this.states.length - 1]);
460
+ }
439
461
  }
440
462
  /**
441
463
  * Call when an action is performed that breaks back/forward navigation
442
464
  */
443
465
  invalidateHistory() {
466
+ if (this.debug) {
467
+ console.log("HistoryManger.invalidateHistory");
468
+ }
444
469
  for (const state of this.states) {
445
470
  state.undoAction = null;
446
471
  state.invalid = state.index !== this.counter;
@@ -450,6 +475,9 @@ class HistoryManagerStatic {
450
475
  * Return to a given history point in time, if needed
451
476
  */
452
477
  returnToHistoryIndex(counter) {
478
+ if (this.debug) {
479
+ console.log("Did return to history index " + counter + ", coming from " + this.counter);
480
+ }
453
481
  if (counter > this.counter) {
454
482
  console.warn("Performed non-compatible navigation. Probably because side-by-side views navigating");
455
483
  this.invalidateHistory();
@@ -474,10 +502,16 @@ class HistoryManagerStatic {
474
502
  console.log("Deleted states", deletedStates.length);
475
503
  const adjustHistoryCount = deletedStates.filter((state) => state.adjustHistory).length;
476
504
  if (adjustHistoryCount > 0) {
505
+ if (this.debug) {
506
+ console.log("Adjusting browser history state: popping " + adjustHistoryCount + " items");
507
+ }
477
508
  this.go(-adjustHistoryCount);
478
509
  }
479
510
  }
480
511
  if (this.states[this.counter].url) {
512
+ if (this.debug) {
513
+ console.log("Setting manual url without history api: " + this.states[this.counter].url);
514
+ }
481
515
  this.setUrl(this.states[this.counter].url, this.states[this.counter].title);
482
516
  }
483
517
  return this.counter;
@@ -486,6 +520,9 @@ class HistoryManagerStatic {
486
520
  history.scrollRestoration = "manual";
487
521
  async function onPopState(event) {
488
522
  var _a;
523
+ if (this.debug) {
524
+ console.log("HistoryManager popstate");
525
+ }
489
526
  if (this.isAdjustingState) {
490
527
  console.warn("Duplicate popstate");
491
528
  return;
@@ -499,6 +536,9 @@ class HistoryManagerStatic {
499
536
  if (newCounter > this.counter) {
500
537
  const amount = newCounter - this.counter;
501
538
  this.go(-amount);
539
+ if (this.debug) {
540
+ console.log("Not allowed to go forward, going back " + amount + " steps");
541
+ }
502
542
  } else {
503
543
  const animate = this.counter - newCounter == 1 && this.animateHistoryPop;
504
544
  this.counter = newCounter;
@@ -518,6 +558,9 @@ class HistoryManagerStatic {
518
558
  }
519
559
  for (const state of deletedStates) {
520
560
  if (state.undoAction) {
561
+ if (this.debug) {
562
+ console.log("Executing undoAction...");
563
+ }
521
564
  await state.undoAction(animate);
522
565
  } else {
523
566
  if (state.adjustHistory) {
@@ -567,7 +610,6 @@ class HistoryManagerStatic {
567
610
  });
568
611
  }
569
612
  }
570
- __publicField(HistoryManagerStatic, "debug", false);
571
613
  const HistoryManager = new HistoryManagerStatic();
572
614
  function useCurrentComponent() {
573
615
  return inject("navigation_currentComponent", null);
@@ -945,7 +987,7 @@ function makeProvidesParentReactive(instance) {
945
987
  instance.provides = Object.create(proxyProvider);
946
988
  return reactiveInstance;
947
989
  }
948
- const ComponentWithPropertiesInstance = {
990
+ const ComponentWithPropertiesInstance = defineComponent({
949
991
  name: "ComponentWithPropertiesInstance",
950
992
  props: {
951
993
  component: {
@@ -959,7 +1001,7 @@ const ComponentWithPropertiesInstance = {
959
1001
  }
960
1002
  },
961
1003
  __isKeepAlive: true,
962
- setup(props) {
1004
+ setup(props, context) {
963
1005
  const instance = getCurrentInstance();
964
1006
  const sharedContext = instance.ctx;
965
1007
  const reactiveInstance = makeProvidesParentReactive(instance);
@@ -1114,7 +1156,7 @@ const ComponentWithPropertiesInstance = {
1114
1156
  return null;
1115
1157
  }
1116
1158
  props.component.component.inheritAttrs = false;
1117
- const vnode = h(props.component.component, props.component.properties);
1159
+ const vnode = h(props.component.component, { ...props.component.properties, ...context.attrs });
1118
1160
  const comp = vnode.type;
1119
1161
  const key = vnode.key == null ? comp : vnode.key;
1120
1162
  pendingCacheKey = key;
@@ -1138,7 +1180,7 @@ const ComponentWithPropertiesInstance = {
1138
1180
  return vnode;
1139
1181
  };
1140
1182
  }
1141
- };
1183
+ });
1142
1184
  const _sfc_main$5 = {
1143
1185
  name: "FramedComponent",
1144
1186
  components: {
@@ -1172,7 +1214,7 @@ function _sfc_render$2(_ctx, _cache, $props, $setup, $data, $options) {
1172
1214
  const _component_ComponentWithPropertiesInstance = resolveComponent("ComponentWithPropertiesInstance");
1173
1215
  return openBlock(), createElementBlock("div", null, [
1174
1216
  createElementVNode("div", null, [
1175
- createVNode(_component_ComponentWithPropertiesInstance, { component: $props.root }, null, 8, ["component"])
1217
+ createVNode(_component_ComponentWithPropertiesInstance, mergeProps({ component: $props.root }, _ctx.$attrs), null, 16, ["component"])
1176
1218
  ])
1177
1219
  ]);
1178
1220
  }
@@ -11,7 +11,7 @@ type HistoryState = {
11
11
  undoAction: ((animate: boolean) => void | Promise<void>) | null;
12
12
  };
13
13
  declare class HistoryManagerStatic {
14
- static debug: boolean;
14
+ debug: boolean;
15
15
  states: HistoryState[];
16
16
  counter: number;
17
17
  active: boolean;
@@ -74,8 +74,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
74
74
  default: null;
75
75
  };
76
76
  }>> & Readonly<{}>, {
77
- root: ComponentWithProperties | null;
78
77
  customProvide: Record<string, any>;
78
+ root: ComponentWithProperties | null;
79
79
  initialComponents: ComponentWithProperties[] | null;
80
80
  animationType: string;
81
81
  }, {}, {
@@ -119,8 +119,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
119
119
  default: null;
120
120
  };
121
121
  }>> & Readonly<{}>, {
122
- root: ComponentWithProperties | null;
123
122
  customProvide: Record<string, any>;
123
+ root: ComponentWithProperties | null;
124
124
  initialComponents: ComponentWithProperties[] | null;
125
125
  animationType: string;
126
126
  }, {}, {
@@ -445,8 +445,8 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
445
445
  default: null;
446
446
  };
447
447
  }>> & Readonly<{}>, {
448
- root: ComponentWithProperties | null;
449
448
  customProvide: Record<string, any>;
449
+ root: ComponentWithProperties | null;
450
450
  initialComponents: ComponentWithProperties[] | null;
451
451
  animationType: string;
452
452
  }, {}, {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@simonbackx/vue-app-navigation",
3
3
  "main": "./dist/index.js",
4
4
  "types": "./dist/index.d.ts",
5
- "version": "2.15.0",
5
+ "version": "2.17.0",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./dist/index.js",