billy-herrington-utils 2.0.0 → 2.0.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/index.d.ts CHANGED
@@ -216,6 +216,7 @@ export declare class RulesGlobal {
216
216
  thumbsSelector: string;
217
217
  getThumbsStrategy: 'default' | 'auto';
218
218
  getThumbs(html: HTMLElement): HTMLElement[];
219
+ paginationStrategyOptions: Parameters<typeof getPaginationStrategy>[0];
219
220
  paginationStrategy: PaginationStrategy;
220
221
  get observable(): HTMLElement;
221
222
  mutationObservers: MutationObserver[];
@@ -231,7 +232,7 @@ export declare class RulesGlobal {
231
232
  scheme: JabroniTypes.SchemeInput;
232
233
  gui: JabronioGUI;
233
234
  dataManager: DataManager;
234
- infiniteScroller: InfiniteScroller;
235
+ infiniteScroller?: InfiniteScroller;
235
236
  private resetInfiniteScroller;
236
237
  initialGrope: 'all-in-one' | 'all-in-all' | undefined;
237
238
  gropeInit(): void;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "billy-herrington-utils",
3
3
  "description": "daddy told us not to be ashamed of our utils",
4
- "version": "2.0.0",
4
+ "version": "2.0.2",
5
5
  "license": "MIT",
6
6
  "keywords": [
7
7
  "utils",
@@ -39,6 +39,7 @@ export class PaginationStrategyPathnameParams extends PaginationStrategy {
39
39
  const links = getPaginationLinks(
40
40
  (this.getPaginationElement() || document) as HTMLElement,
41
41
  this.url.href,
42
+ true,
42
43
  this.pathnameSelector,
43
44
  );
44
45
  const pages = Array.from(links, this.extractPage);
@@ -6,6 +6,7 @@ export function parseURL(s: HTMLAnchorElement | Location | URL | string): URL {
6
6
  export function getPaginationLinks(
7
7
  doc: Element | HTMLElement | Document = document,
8
8
  url: Location | URL | string = location.href,
9
+ pathnameStrict = true,
9
10
  pathnameSelector = /\/(page\/)?\d+\/?$/,
10
11
  ): string[] {
11
12
  const currentUrl = parseURL(url);
@@ -20,7 +21,7 @@ export function getPaginationLinks(
20
21
  return (
21
22
  // in case of origin sometimes it's protocols problem cause some links can be not https but http
22
23
  linkUrl.hostname === currentUrl.hostname &&
23
- linkUrl.pathname.startsWith(currentUrl.pathname)
24
+ (pathnameStrict ? linkUrl.pathname.startsWith(currentUrl.pathname) : true)
24
25
  );
25
26
  } catch {
26
27
  return false;
@@ -131,7 +131,8 @@ export class RulesGlobal {
131
131
  return thumbs;
132
132
  }
133
133
 
134
- paginationStrategy = getPaginationStrategy({});
134
+ paginationStrategyOptions: Parameters<typeof getPaginationStrategy>[0] = {};
135
+ paginationStrategy = getPaginationStrategy(this.paginationStrategyOptions);
135
136
 
136
137
  // get paginationElement() {
137
138
  // return this.paginationStrategy.getPaginationElement();
@@ -160,7 +161,7 @@ export class RulesGlobal {
160
161
  this.mutationObservers.forEach((o) => {
161
162
  o.disconnect();
162
163
  });
163
- this.infiniteScroller = this.resetInfiniteScroller();
164
+ this.resetInfiniteScroller();
164
165
  this.resetOn();
165
166
  }
166
167
 
@@ -194,17 +195,17 @@ export class RulesGlobal {
194
195
  public scheme = setupScheme(this.defaultSchemeOptions, this.customScheme);
195
196
  public gui = new JabronioGUI(this.scheme, this.store);
196
197
  public dataManager = new DataManager(this, this.store.state);
197
- public infiniteScroller: InfiniteScroller;
198
+ public infiniteScroller?: InfiniteScroller;
198
199
 
199
- private resetInfiniteScroller = () => {
200
+ private resetInfiniteScroller() {
200
201
  this.infiniteScroller?.dispose();
201
- const infiniteScroller = InfiniteScroller.create(
202
+ if (!this.paginationStrategy.hasPagination) return;
203
+ this.infiniteScroller = InfiniteScroller.create(
202
204
  this.store,
203
205
  this,
204
206
  this.dataManager.parseData,
205
207
  );
206
- return infiniteScroller;
207
- };
208
+ }
208
209
 
209
210
  public initialGrope: 'all-in-one' | 'all-in-all' | undefined;
210
211
 
@@ -222,7 +223,7 @@ export class RulesGlobal {
222
223
 
223
224
  constructor() {
224
225
  this.store.subscribe(() => this.dataManager.applyFilters());
225
- this.infiniteScroller = this.resetInfiniteScroller();
226
+ this.resetInfiniteScroller();
226
227
  this.resetOn();
227
228
  this.animatePreview?.();
228
229
  this.gropeInit();