@hyperframes/parsers 0.9.49 → 0.9.51

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 (2) hide show
  1. package/dist/slideshow.js +19 -4
  2. package/package.json +2 -2
package/dist/slideshow.js CHANGED
@@ -11,11 +11,26 @@ function slideshowIslandRegex(flags = "i") {
11
11
  flags
12
12
  );
13
13
  }
14
+ var ISLAND_TYPE_ATTR = new RegExp(
15
+ `type[\\t\\n\\f\\r ]*=[\\t\\n\\f\\r ]*["']${SLIDESHOW_ISLAND_TYPE.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}["']`,
16
+ "i"
17
+ );
18
+ function slideshowIslandJson(html) {
19
+ for (const tag of html.matchAll(/<script[^>]*>?/gi)) {
20
+ if (!tag[0].endsWith(">")) return null;
21
+ if (!ISLAND_TYPE_ATTR.test(tag[0])) continue;
22
+ const bodyStart = tag.index + tag[0].length;
23
+ const close = /<\/script>/gi;
24
+ close.lastIndex = bodyStart;
25
+ const end = close.exec(html);
26
+ return end ? html.slice(bodyStart, end.index) : null;
27
+ }
28
+ return null;
29
+ }
14
30
  function parseSlideshowManifest(html) {
15
- const re = slideshowIslandRegex("i");
16
- const match = re.exec(html);
17
- if (!match || match[1] === void 0) return null;
18
- const raw = match[1].trim();
31
+ const island = slideshowIslandJson(html);
32
+ if (island === null) return null;
33
+ const raw = island.trim();
19
34
  if (raw.length === 0) return null;
20
35
  const parsed = JSON.parse(raw);
21
36
  if (!isManifest(parsed)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperframes/parsers",
3
- "version": "0.9.49",
3
+ "version": "0.9.51",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/heygen-com/hyperframes",
@@ -139,7 +139,7 @@
139
139
  "tsx": "^4.21.0",
140
140
  "typescript": "^5.0.0",
141
141
  "vitest": "^4.1.12",
142
- "@hyperframes/core": "0.9.49"
142
+ "@hyperframes/core": "0.9.51"
143
143
  },
144
144
  "scripts": {
145
145
  "build": "tsup",