@internetarchive/bookreader 5.0.0-107 → 5.0.0-109

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@internetarchive/bookreader",
3
- "version": "5.0.0-107",
3
+ "version": "5.0.0-109",
4
4
  "description": "The Internet Archive BookReader.",
5
5
  "type": "module",
6
6
  "files": [
@@ -106,7 +106,7 @@
106
106
  ]
107
107
  },
108
108
  "scripts": {
109
- "preversion": "npm run test && node scripts/preversion.js",
109
+ "preversion": "node scripts/preversion.js",
110
110
  "version": "node scripts/version.js",
111
111
  "postversion": "node scripts/postversion.js",
112
112
  "build": "npm run clean && npx concurrently --group npm:build-js npm:build-css npm:build-assets npm:build-hypothesis npm:build-bergamot",
@@ -10,8 +10,8 @@ import { sharedStyles } from '../../css/sharedStyles.js';
10
10
  import { svgToDataUrl } from '../../util/lit.js';
11
11
  /** @typedef {import('@/src/plugins/search/plugin.search.js').SearchInsideMatch} SearchInsideMatch */
12
12
 
13
- const checkmarkIconData = svgToDataUrl(checkmarkIconTemplate.strings[0]);
14
- const closeIconData = svgToDataUrl(closeIconTemplate.strings[0]);
13
+ const checkmarkIconData = svgToDataUrl(checkmarkIconTemplate);
14
+ const closeIconData = svgToDataUrl(closeIconTemplate);
15
15
 
16
16
  export class IABookSearchResults extends LitElement {
17
17
  static get properties() {
package/src/util/lit.js CHANGED
@@ -2,9 +2,14 @@ import { css } from 'lit';
2
2
 
3
3
  /**
4
4
  * Convert an SVG string to a data URL usable in CSS
5
- * @param {string} svgString
5
+ * @param {import('lit').TemplateResult} svgTemplate - The SVG template to convert
6
6
  * @returns {import('lit').CSSResult}
7
7
  */
8
- export function svgToDataUrl(svgString) {
8
+ export function svgToDataUrl(svgTemplate) {
9
+ // No clue why, on prod the template from the close icon comes in as a class instead of a TemplateResult.
10
+ // Might be a discrepancy with lit versions.
11
+ if (svgTemplate.prototype) svgTemplate = svgTemplate.prototype.render();
12
+
13
+ const svgString = svgTemplate.strings[0];
9
14
  return css([`data:image/svg+xml;base64,${btoa(svgString.replace(/\n/g, ' '))}`]);
10
15
  }