@lisergia/core 15.0.0 → 16.0.1

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/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # @lisergia/core
2
2
 
3
+ ## 16.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Update routing popState logic.
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @lisergia/config-tsconfig@16.0.0
13
+
3
14
  ## 15.0.0
4
15
 
5
16
  ### Major Changes
package/dist/index.cjs CHANGED
@@ -260,6 +260,7 @@ var ApplicationManager = class extends Component {
260
260
  nextPage: import_mobx2.observable,
261
261
  // Route Information.
262
262
  route: import_mobx2.observable,
263
+ routeHistory: import_mobx2.observable,
263
264
  // Template Information.
264
265
  template: import_mobx2.observable,
265
266
  // Page Scroll.
@@ -381,11 +382,13 @@ var ApplicationManager = class extends Component {
381
382
  // Navigate.
382
383
  //
383
384
  route = window.location.pathname;
385
+ routeHistory = [this.route];
386
+ routePushState = true;
384
387
  onRouteChange({ oldValue, newValue }) {
385
388
  const href = newValue.replace(window.location.origin, "");
386
389
  this.onRouteChangeRequest({
387
390
  href,
388
- pushState: true
391
+ pushState: this.routePushState
389
392
  });
390
393
  }
391
394
  async onRouteChangeRequest({ href, pushState = true }) {
@@ -423,6 +426,7 @@ var ApplicationManager = class extends Component {
423
426
  if (pushState) {
424
427
  window.history.pushState({}, this.nextPage.title, href);
425
428
  }
429
+ this.routeHistory.push(href);
426
430
  }
427
431
  //
428
432
  // Pop State.
@@ -431,17 +435,15 @@ var ApplicationManager = class extends Component {
431
435
  if (event.state === null) {
432
436
  return event.preventDefault();
433
437
  }
434
- this.onRouteChangeRequest({
435
- href: document.location.pathname,
436
- pushState: false
437
- });
438
+ this.routePushState = false;
439
+ this.route = document.location.pathname;
440
+ this.routePushState = false;
438
441
  }
439
442
  //
440
443
  // Scroll.
441
444
  //
442
445
  get scroll() {
443
- var _a;
444
- return ((_a = this.currentPage) == null ? void 0 : _a.scroll) ?? 0;
446
+ return this.currentPage.scroll ?? 0;
445
447
  }
446
448
  //
447
449
  // Listeners.
package/dist/index.d.cts CHANGED
@@ -153,6 +153,8 @@ declare class ApplicationManager extends Component {
153
153
  createPage(template?: string): void;
154
154
  destroyPage(): void;
155
155
  route: string;
156
+ routeHistory: Array<string>;
157
+ routePushState: boolean;
156
158
  onRouteChange({ oldValue, newValue }: IValueDidChange<string>): void;
157
159
  onRouteChangeRequest({ href, pushState }: {
158
160
  href: string;
package/dist/index.d.ts CHANGED
@@ -153,6 +153,8 @@ declare class ApplicationManager extends Component {
153
153
  createPage(template?: string): void;
154
154
  destroyPage(): void;
155
155
  route: string;
156
+ routeHistory: Array<string>;
157
+ routePushState: boolean;
156
158
  onRouteChange({ oldValue, newValue }: IValueDidChange<string>): void;
157
159
  onRouteChangeRequest({ href, pushState }: {
158
160
  href: string;
package/dist/index.js CHANGED
@@ -217,6 +217,7 @@ var ApplicationManager = class extends Component {
217
217
  nextPage: observable,
218
218
  // Route Information.
219
219
  route: observable,
220
+ routeHistory: observable,
220
221
  // Template Information.
221
222
  template: observable,
222
223
  // Page Scroll.
@@ -338,11 +339,13 @@ var ApplicationManager = class extends Component {
338
339
  // Navigate.
339
340
  //
340
341
  route = window.location.pathname;
342
+ routeHistory = [this.route];
343
+ routePushState = true;
341
344
  onRouteChange({ oldValue, newValue }) {
342
345
  const href = newValue.replace(window.location.origin, "");
343
346
  this.onRouteChangeRequest({
344
347
  href,
345
- pushState: true
348
+ pushState: this.routePushState
346
349
  });
347
350
  }
348
351
  async onRouteChangeRequest({ href, pushState = true }) {
@@ -380,6 +383,7 @@ var ApplicationManager = class extends Component {
380
383
  if (pushState) {
381
384
  window.history.pushState({}, this.nextPage.title, href);
382
385
  }
386
+ this.routeHistory.push(href);
383
387
  }
384
388
  //
385
389
  // Pop State.
@@ -388,17 +392,15 @@ var ApplicationManager = class extends Component {
388
392
  if (event.state === null) {
389
393
  return event.preventDefault();
390
394
  }
391
- this.onRouteChangeRequest({
392
- href: document.location.pathname,
393
- pushState: false
394
- });
395
+ this.routePushState = false;
396
+ this.route = document.location.pathname;
397
+ this.routePushState = false;
395
398
  }
396
399
  //
397
400
  // Scroll.
398
401
  //
399
402
  get scroll() {
400
- var _a;
401
- return ((_a = this.currentPage) == null ? void 0 : _a.scroll) ?? 0;
403
+ return this.currentPage.scroll ?? 0;
402
404
  }
403
405
  //
404
406
  // Listeners.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lisergia/core",
3
- "version": "15.0.0",
3
+ "version": "16.0.1",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "dev": "tsup src/index.ts --format cjs,esm --dts --watch"
10
10
  },
11
11
  "dependencies": {
12
- "@lisergia/config-tsconfig": "15.0.0",
12
+ "@lisergia/config-tsconfig": "16.0.0",
13
13
  "auto-bind": "^5.0.1",
14
14
  "gsap": "^3.13.0",
15
15
  "lenis": "^1.3.1",
package/src/App.ts CHANGED
@@ -43,6 +43,7 @@ export class ApplicationManager extends Component {
43
43
 
44
44
  // Route Information.
45
45
  route: observable,
46
+ routeHistory: observable,
46
47
 
47
48
  // Template Information.
48
49
  template: observable,
@@ -204,13 +205,15 @@ export class ApplicationManager extends Component {
204
205
  // Navigate.
205
206
  //
206
207
  route: string = window.location.pathname
208
+ routeHistory: Array<string> = [this.route]
209
+ routePushState: boolean = true
207
210
 
208
211
  onRouteChange({ oldValue, newValue }: IValueDidChange<string>) {
209
212
  const href = newValue.replace(window.location.origin, '')
210
213
 
211
214
  this.onRouteChangeRequest({
212
215
  href,
213
- pushState: true,
216
+ pushState: this.routePushState,
214
217
  })
215
218
  }
216
219
 
@@ -261,6 +264,8 @@ export class ApplicationManager extends Component {
261
264
  if (pushState) {
262
265
  window.history.pushState({}, this.nextPage.title!, href)
263
266
  }
267
+
268
+ this.routeHistory.push(href)
264
269
  }
265
270
 
266
271
  //
@@ -271,17 +276,16 @@ export class ApplicationManager extends Component {
271
276
  return event.preventDefault()
272
277
  }
273
278
 
274
- this.onRouteChangeRequest({
275
- href: document.location.pathname,
276
- pushState: false,
277
- })
279
+ this.routePushState = false
280
+ this.route = document.location.pathname
281
+ this.routePushState = false
278
282
  }
279
283
 
280
284
  //
281
285
  // Scroll.
282
286
  //
283
287
  get scroll() {
284
- return this.currentPage?.scroll ?? 0
288
+ return this.currentPage!.scroll ?? 0
285
289
  }
286
290
 
287
291
  //
@@ -1,20 +0,0 @@
1
-
2
- 
3
- > @lisergia/core@14.0.0 build
4
- > tsup src/index.ts --format cjs,esm --dts
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.5.0
9
- CLI Target: node16
10
- CJS Build start
11
- ESM Build start
12
- CJS dist/index.cjs 16.00 KB
13
- CJS ⚡️ Build success in 34ms
14
- ESM dist/index.js 13.77 KB
15
- ESM ⚡️ Build success in 34ms
16
- DTS Build start
17
- DTS ⚡️ Build success in 825ms
18
- DTS dist/index.d.cts 5.76 KB
19
- DTS dist/index.d.ts 5.76 KB
20
- ⠙