@rocketspark/domain-checker 1.0.13 → 1.0.14

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.
Files changed (63) hide show
  1. package/CLAUDE.md +24 -1
  2. package/README.md +4 -1
  3. package/build/141.index.js +1 -1
  4. package/build/147.index.js +1 -1
  5. package/build/167.index.js +1 -1
  6. package/build/17.index.js +1 -1
  7. package/build/194.index.js +1 -1
  8. package/build/208.index.js +1 -1
  9. package/build/237.index.js +1 -1
  10. package/build/245.index.js +1 -1
  11. package/build/278.index.js +1 -1
  12. package/build/386.index.js +1 -1
  13. package/build/404.index.js +1 -1
  14. package/build/420.index.js +1 -1
  15. package/build/514.index.js +1 -1
  16. package/build/524.index.js +1 -1
  17. package/build/542.index.js +1 -1
  18. package/build/551.index.js +1 -1
  19. package/build/567.index.js +1 -1
  20. package/build/571.index.js +1 -1
  21. package/build/572.index.js +1 -1
  22. package/build/584.index.js +1 -1
  23. package/build/588.index.js +1 -1
  24. package/build/598.index.js +1 -1
  25. package/build/60.index.js +1 -1
  26. package/build/616.index.js +1 -1
  27. package/build/631.index.js +1 -1
  28. package/build/643.index.js +1 -1
  29. package/build/654.index.js +1 -1
  30. package/build/66.index.js +1 -1
  31. package/build/697.index.js +1 -1
  32. package/build/714.index.js +1 -1
  33. package/build/717.index.js +1 -1
  34. package/build/795.index.js +1 -1
  35. package/build/8.index.js +1 -1
  36. package/build/808.index.js +1 -1
  37. package/build/810.index.js +1 -1
  38. package/build/833.index.js +1 -1
  39. package/build/835.index.js +1 -1
  40. package/build/847.index.js +1 -1
  41. package/build/853.index.js +1 -1
  42. package/build/871.index.js +1 -1
  43. package/build/890.index.js +1 -1
  44. package/build/899.index.js +1 -1
  45. package/build/938.index.js +1 -1
  46. package/build/964.index.js +1 -1
  47. package/build/970.index.js +1 -1
  48. package/build/984.index.js +1 -1
  49. package/build/993.index.js +1 -1
  50. package/build/css/index.css +1 -1
  51. package/build/index.js +3 -10
  52. package/build/index.js.map +1 -1
  53. package/build/types/Components/Cart.d.ts +4 -0
  54. package/build/types/Components/PopupContainer.d.ts +2 -0
  55. package/build/types/Components/SearchAlternativeRow.d.ts +8 -2
  56. package/build/types/Components/SearchAlternatives.d.ts +9 -2
  57. package/build/types/Components/SearchFlow.test.d.ts +4 -0
  58. package/build/types/Helpers/Fetch.d.ts +2 -1
  59. package/build/types/Helpers/Fetch.test.d.ts +4 -0
  60. package/build/types/Helpers/sanitize.d.ts +7 -1
  61. package/build/types/Helpers/sanitize.test.d.ts +1 -0
  62. package/build/types/index.d.ts +7 -0
  63. package/package.json +2 -4
@@ -14,14 +14,18 @@ export default class Cart {
14
14
  private cart;
15
15
  private readonly classNames;
16
16
  private readonly locale;
17
+ private resizeFrame;
17
18
  constructor(container: HTMLElement, cart: HTMLElement, classNames: ClassNames, locale: Locale);
18
19
  isInCart(domain: string): boolean;
19
20
  addDomain(domain: string, domainDetails: DomainResponse): void;
21
+ /** Removes window listeners so the cart can be garbage collected. */
22
+ destroy(): void;
20
23
  removeDomain(domain: string): void;
21
24
  private resetGetItNowButton;
22
25
  private updateCartDisplayState;
23
26
  private updateCartHeadingCount;
24
27
  private build;
25
28
  private getTemplate;
29
+ private onResize;
26
30
  private getSelectedDomainPeriod;
27
31
  }
@@ -23,6 +23,8 @@ export default class PopupContainer {
23
23
  setLoading(loading: boolean): void;
24
24
  open(): this;
25
25
  close(): this;
26
+ /** Tears the popup down: cancels pending lookups and detaches from the document. */
27
+ destroy(): void;
26
28
  setHeading(heading: string): this;
27
29
  setPrice(price?: string): this;
28
30
  setCaptionMessage(message: string): this;
@@ -1,4 +1,5 @@
1
1
  import { ClassNames } from '../Interfaces/class-names';
2
+ import { DomainResponse } from '../Helpers/Fetch';
2
3
  import { Locale } from '../Interfaces/locale';
3
4
  import Cart from './Cart';
4
5
  export default class SearchAlternativeRow {
@@ -14,16 +15,21 @@ export default class SearchAlternativeRow {
14
15
  private pricing;
15
16
  private blurb;
16
17
  private domainDetails;
17
- constructor({ element, prefix, suffix, classNames, locale, cart, }: {
18
+ constructor({ element, prefix, suffix, classNames, locale, cart, knownDetails, signal, }: {
18
19
  element: HTMLRsHeaderElement;
19
20
  prefix: string;
20
21
  suffix: string;
21
22
  classNames: ClassNames;
22
23
  locale: Locale;
23
24
  cart: Cart;
25
+ /** Details already returned by an earlier lookup; skips the per-row fetch. */
26
+ knownDetails?: DomainResponse;
27
+ /** Aborts the per-row fetch when the results list is replaced. */
28
+ signal?: AbortSignal;
24
29
  });
25
30
  private build;
26
- private buildDomain;
27
31
  private addListeners;
32
+ private showTick;
28
33
  private fetchDetails;
34
+ private render;
29
35
  }
@@ -1,5 +1,5 @@
1
1
  import { ClassNames } from '../Interfaces/class-names';
2
- import { DomainSuggestions } from '../Helpers/Fetch';
2
+ import { DomainResponse, DomainSuggestions } from '../Helpers/Fetch';
3
3
  import { Locale } from '../Interfaces/locale';
4
4
  import Cart from './Cart';
5
5
  export default class SearchAlternatives {
@@ -8,6 +8,7 @@ export default class SearchAlternatives {
8
8
  private readonly locale;
9
9
  private readonly rowType;
10
10
  private readonly cart;
11
+ private abortController;
11
12
  constructor({ element, classNames, locale, rowType, cart, }: {
12
13
  element: HTMLRsHeaderElement;
13
14
  classNames: ClassNames;
@@ -15,7 +16,13 @@ export default class SearchAlternatives {
15
16
  rowType: 'preferred' | 'alternative';
16
17
  cart: Cart;
17
18
  });
18
- showDomains(suggestions: DomainSuggestions): this;
19
+ /**
20
+ * Renders one row per suffix. When `knownDetails` is supplied (the searched
21
+ * domain's own response) the row renders immediately instead of re-fetching.
22
+ */
23
+ showDomains(suggestions: DomainSuggestions, knownDetails?: DomainResponse): this;
24
+ /** Cancels any in-flight row lookups from the previous search. */
25
+ abortPending(): void;
19
26
  private removeAllRows;
20
27
  private getTemplate;
21
28
  }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
@@ -19,4 +19,5 @@ export interface DomainResponse {
19
19
  pricing: Pricing;
20
20
  domainSuggestions: DomainSuggestions;
21
21
  }
22
- export declare const FetchDomain: (domainName: string, locale: string, limit?: number) => Promise<DomainResponse>;
22
+ export declare const clearFetchCache: () => void;
23
+ export declare const FetchDomain: (domainName: string, locale: string, limit?: number, signal?: AbortSignal) => Promise<DomainResponse>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * @jest-environment jsdom
3
+ */
4
+ export {};
@@ -1 +1,7 @@
1
- export declare function sanitiseHtml(html: string): string;
1
+ /**
2
+ * Decodes HTML entities in a string returned by the API (e.g. `&pound;` → `£`)
3
+ * and drops any markup, returning plain text that is safe to assign via
4
+ * `textContent`. Replaces the former `sanitize-html` dependency, which pulled a
5
+ * full server-side HTML parser into the browser bundle to process price strings.
6
+ */
7
+ export declare function decodeHtmlText(html: string | null | undefined): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -16,7 +16,14 @@ declare class DomainChecker {
16
16
  private popupContainer;
17
17
  constructor(element: HTMLElement, options?: Partial<Options>);
18
18
  static setPopupStatus(popupContainer: PopupContainer, { success, isAvailable, pricing, error }: Partial<DomainResponse>): void;
19
+ /** Removes the widget's DOM and listeners from the host page. */
20
+ destroy(): void;
19
21
  private autofillSearchBar;
22
+ /**
23
+ * The popup (results, alternatives and cart) is only built on first use so
24
+ * page load does not pay for DOM that stays hidden until a search happens.
25
+ */
26
+ private getPopup;
20
27
  private getDomainFromUrl;
21
28
  private init;
22
29
  private getTemplate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rocketspark/domain-checker",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
4
4
  "description": "Embeddable Domain Checker for Rocketspark",
5
5
  "main": "build/index.js",
6
6
  "types": "build/types/index.d.ts",
@@ -68,9 +68,7 @@
68
68
  "url-loader": "^4.1.1",
69
69
  "webpack": "^5.72.1",
70
70
  "webpack-cli": "^4.9.2",
71
- "webpack-dev-server": "4.9.0",
72
- "@types/sanitize-html": "^2.16.0",
73
- "sanitize-html": "^2.17.0"
71
+ "webpack-dev-server": "4.9.0"
74
72
  },
75
73
  "jest": {
76
74
  "moduleNameMapper": {