webforai 1.1.5 → 1.1.6

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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2023 inaridiy
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2023 inaridiy
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,74 +1,74 @@
1
- # Web for AI
2
-
3
- ![LOGO](https://github.com/inaridiy/webforai/blob/main/images/logo.webp)
4
-
5
- A library that provides a web interface for AI
6
-
7
- ## Features
8
-
9
- - Ultra-precise HTML2Markdown conversion
10
- - Ultra-precise Markdown segmentation based on AST
11
- - Ultra-precise HTML retrieval functions using headless browsers
12
- - The core functionality is edge-native (runs on Cloudflare Workers!!!)
13
-
14
- ## Demo
15
-
16
- There is a demo API for Html2Markdown deployed on CloudflareWorker. Please access the following link
17
-
18
- - [https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai](https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai)
19
- - [https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E](https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E)
20
-
21
- ## Quick Start
22
-
23
- Just install and execute scripts
24
-
25
- ```bash
26
- pnpm i webforai playwright
27
- ```
28
-
29
- ```js
30
- import { promises as fs } from "fs";
31
- import { htmlToMarkdown, htmlToMdast } from "webforai";
32
- import { loadHtml } from "webforai/loaders/playwright";
33
-
34
- const url = "https://www.npmjs.com/package/webforai";
35
- const html = await loadHtml(url);
36
-
37
- const markdown = htmlToMarkdown(html, { solveLinks: url });
38
-
39
- await fs.writeFile("output.md", markdown);
40
- ```
41
-
42
- other examples are in [examples](./examples/simple/src/index.ts)
43
-
44
- ## Usage
45
-
46
- ### Main Functions
47
-
48
- **`htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions): string`**
49
- Convert HTML to Markdown. By default, unnecessary HTML is excluded and processed.
50
- If `solveLinks` is specified, the relative links in the Mdast will be resolved.
51
- This function just calls htmlToMdast and mdastToMarkdown in that order internally.
52
-
53
- **`htmlToMdast(html: string, options?: HtmlToMdastOptions): Mdast`**
54
- This project uses Hast and Mdast as defined by syntax-tree internally.
55
- This function converts HTML to Mdast, an intermediate representation, which is required when using `mdastSplitter`, etc.
56
-
57
- **`mdastToMarkdown(mdast: Mdast | RootContent[], options?: { solveLinks?: string }): string`**
58
- Convert Mdast to Markdown. If `solveLinks` is specified, the relative links in the Mdast will be resolved.
59
-
60
- ### Loader Functions
61
-
62
- **`loadHtml(url: string, options?: LoadHtmlOptions): Promise<string>`**
63
- Load HTML from the specified URL. This function uses Playwright internally.
64
-
65
- ## Early Users
66
-
67
- ### Voice Genius - Explanatory video generation by AI
68
-
69
- <img src="https://github.com/inaridiy/webforai/blob/main/images/voice-genius.png" width="300px">
70
-
71
- by [@moons14](https://twitter.com/moons_dev)
72
-
73
- AI can be used to automatically generate highly accurate commentary videos.
74
- Supports conversations and presentations using synthesized voice, embedding of images in videos, etc.
1
+ # Web for AI
2
+
3
+ ![LOGO](https://github.com/inaridiy/webforai/blob/main/images/logo.webp)
4
+
5
+ A library that provides a web interface for AI
6
+
7
+ ## Features
8
+
9
+ - Ultra-precise HTML2Markdown conversion
10
+ - Ultra-precise Markdown segmentation based on AST
11
+ - Ultra-precise HTML retrieval functions using headless browsers
12
+ - The core functionality is edge-native (runs on Cloudflare Workers!!!)
13
+
14
+ ## Demo
15
+
16
+ There is a demo API for Html2Markdown deployed on CloudflareWorker. Please access the following link
17
+
18
+ - [https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai](https://webforai.inaridiy.workers.dev/?url=https://www.npmjs.com/package/webforai)
19
+ - [https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E](https://webforai.inaridiy.workers.dev/?html=%3Ch1%3EHello%20World%3C/h1%3E)
20
+
21
+ ## Quick Start
22
+
23
+ Just install and execute scripts
24
+
25
+ ```bash
26
+ pnpm i webforai playwright
27
+ ```
28
+
29
+ ```js
30
+ import { promises as fs } from "fs";
31
+ import { htmlToMarkdown, htmlToMdast } from "webforai";
32
+ import { loadHtml } from "webforai/loaders/playwright";
33
+
34
+ const url = "https://www.npmjs.com/package/webforai";
35
+ const html = await loadHtml(url);
36
+
37
+ const markdown = htmlToMarkdown(html, { solveLinks: url });
38
+
39
+ await fs.writeFile("output.md", markdown);
40
+ ```
41
+
42
+ other examples are in [examples](./examples/simple/src/index.ts)
43
+
44
+ ## Usage
45
+
46
+ ### Main Functions
47
+
48
+ **`htmlToMarkdown(html: string, options?: HtmlToMarkdownOptions): string`**
49
+ Convert HTML to Markdown. By default, unnecessary HTML is excluded and processed.
50
+ If `solveLinks` is specified, the relative links in the Mdast will be resolved.
51
+ This function just calls htmlToMdast and mdastToMarkdown in that order internally.
52
+
53
+ **`htmlToMdast(html: string, options?: HtmlToMdastOptions): Mdast`**
54
+ This project uses Hast and Mdast as defined by syntax-tree internally.
55
+ This function converts HTML to Mdast, an intermediate representation, which is required when using `mdastSplitter`, etc.
56
+
57
+ **`mdastToMarkdown(mdast: Mdast | RootContent[], options?: { solveLinks?: string }): string`**
58
+ Convert Mdast to Markdown. If `solveLinks` is specified, the relative links in the Mdast will be resolved.
59
+
60
+ ### Loader Functions
61
+
62
+ **`loadHtml(url: string, options?: LoadHtmlOptions): Promise<string>`**
63
+ Load HTML from the specified URL. This function uses Playwright internally.
64
+
65
+ ## Early Users
66
+
67
+ ### Voice Genius - Explanatory video generation by AI
68
+
69
+ <img src="https://github.com/inaridiy/webforai/blob/main/images/voice-genius.png" width="300px">
70
+
71
+ by [@moons14](https://twitter.com/moons_dev)
72
+
73
+ AI can be used to automatically generate highly accurate commentary videos.
74
+ Supports conversations and presentations using synthesized voice, embedding of images in videos, etc.
@@ -40,7 +40,7 @@ const evaluateTextComplexity = (text) => {
40
40
  complexityScore
41
41
  };
42
42
  };
43
- const REMOVE_REGEX = /icon|header|nav|speechify-ignore|assist|-ad-|banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|assist|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i;
43
+ const REMOVE_REGEX = /fallback|icon|header|nav|speechify-ignore|assist|-ad-|banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|assist|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i;
44
44
  const HIDDEN_REGEX = /hidden|^hid$| hid$| hid |^hid /i;
45
45
  const stronglyExtractHast = (hast) => {
46
46
  const selectors = ["article", "#article", "#content", "main", "div.container"];
@@ -45,8 +45,15 @@ const htmlToMdast = (html, options) => {
45
45
  throw new Error(`Invalid extractHast: ${extractHast2}`);
46
46
  }, hast) || hast;
47
47
  const mdast = (0, import_hast_util_to_mdast.toMdast)(extractedHast, {
48
- handlers: { div: import_custom_div_handler.customDivHandler, math: import_math_handler.mathHandler, a: import_custom_a_handler.customAHandler, br: () => {
49
- } }
48
+ handlers: {
49
+ div: import_custom_div_handler.customDivHandler,
50
+ math: import_math_handler.mathHandler,
51
+ a: (0, import_custom_a_handler.customAHandler)({ asText: options?.linkAsText }),
52
+ br: () => {
53
+ },
54
+ ...options?.hideImage ? { img: () => {
55
+ } } : {}
56
+ }
50
57
  });
51
58
  return mdast;
52
59
  };
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var cf_puppeteer_exports = {};
30
+ __export(cf_puppeteer_exports, {
31
+ loadHtml: () => loadHtml
32
+ });
33
+ module.exports = __toCommonJS(cf_puppeteer_exports);
34
+ var import_puppeteer = __toESM(require("@cloudflare/puppeteer"), 1);
35
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
36
+ const loadHtml = async (url, ctx) => {
37
+ const browser = await import_puppeteer.default.launch(ctx);
38
+ const page = await browser.newPage();
39
+ await page.goto(url);
40
+ const html = await page.content();
41
+ await Promise.race([page.waitForNetworkIdle(), sleep(1e4)]);
42
+ await page.close();
43
+ return html;
44
+ };
45
+ // Annotate the CommonJS export names for ESM import in node:
46
+ 0 && (module.exports = {
47
+ loadHtml
48
+ });
@@ -22,7 +22,13 @@ __export(custom_a_handler_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(custom_a_handler_exports);
24
24
  var import_hast_util_to_mdast = require("hast-util-to-mdast");
25
- const customAHandler = (state, node) => {
25
+ const customAHandler = (options) => (state, node) => {
26
+ if (options?.asText) {
27
+ const link2 = import_hast_util_to_mdast.defaultHandlers.a(state, node);
28
+ if (link2.children?.[0]?.type === "text")
29
+ return link2.children[0];
30
+ return void 0;
31
+ }
26
32
  const link = import_hast_util_to_mdast.defaultHandlers.a(state, node);
27
33
  if (link.children.length > 0)
28
34
  return link;
@@ -18,7 +18,7 @@ var evaluateTextComplexity = (text) => {
18
18
  complexityScore
19
19
  };
20
20
  };
21
- var REMOVE_REGEX = /icon|header|nav|speechify-ignore|assist|-ad-|banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|assist|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i;
21
+ var REMOVE_REGEX = /fallback|icon|header|nav|speechify-ignore|assist|-ad-|banner|combx|comment|com-|contact|foot|footer|footnote|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|assist|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|tool|widget/i;
22
22
  var HIDDEN_REGEX = /hidden|^hid$| hid$| hid |^hid /i;
23
23
  var stronglyExtractHast = (hast) => {
24
24
  const selectors = ["article", "#article", "#content", "main", "div.container"];
@@ -23,8 +23,15 @@ var htmlToMdast = (html, options) => {
23
23
  throw new Error(`Invalid extractHast: ${extractHast2}`);
24
24
  }, hast) || hast;
25
25
  const mdast = toMdast(extractedHast, {
26
- handlers: { div: customDivHandler, math: mathHandler, a: customAHandler, br: () => {
27
- } }
26
+ handlers: {
27
+ div: customDivHandler,
28
+ math: mathHandler,
29
+ a: customAHandler({ asText: options?.linkAsText }),
30
+ br: () => {
31
+ },
32
+ ...options?.hideImage ? { img: () => {
33
+ } } : {}
34
+ }
28
35
  });
29
36
  return mdast;
30
37
  };
@@ -0,0 +1,15 @@
1
+ // src/loaders/cf-puppeteer.ts
2
+ import puppeteer from "@cloudflare/puppeteer";
3
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
4
+ var loadHtml = async (url, ctx) => {
5
+ const browser = await puppeteer.launch(ctx);
6
+ const page = await browser.newPage();
7
+ await page.goto(url);
8
+ const html = await page.content();
9
+ await Promise.race([page.waitForNetworkIdle(), sleep(1e4)]);
10
+ await page.close();
11
+ return html;
12
+ };
13
+ export {
14
+ loadHtml
15
+ };
@@ -1,6 +1,12 @@
1
1
  // src/mdast-handlers/custom-a-handler.ts
2
2
  import { defaultHandlers } from "hast-util-to-mdast";
3
- var customAHandler = (state, node) => {
3
+ var customAHandler = (options) => (state, node) => {
4
+ if (options?.asText) {
5
+ const link2 = defaultHandlers.a(state, node);
6
+ if (link2.children?.[0]?.type === "text")
7
+ return link2.children[0];
8
+ return void 0;
9
+ }
4
10
  const link = defaultHandlers.a(state, node);
5
11
  if (link.children.length > 0)
6
12
  return link;
@@ -1 +1 @@
1
- {"version":3,"file":"strongly.js","sourceRoot":"","sources":["../../../src/extract-hast/strongly.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAE3C,MAAM,sBAAsB,GAAG,CAAC,IAAY,EAAE,EAAE;IAC/C,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACvC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IAE/B,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC;IAE9B,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;IAE5C,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;IACnC,MAAM,eAAe,GAAG,WAAW,CAAC,IAAI,CAAC;IAEzC,MAAM,eAAe,GAAG,aAAa,GAAG,GAAG,GAAG,CAAC,eAAe,GAAG,SAAS,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC;IAExF,OAAO;QACN,SAAS;QACT,SAAS;QACT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MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;QACvC,IAAI,OAAO,EAAE,CAAC;YACb,eAAe,GAAG,OAAO,CAAC;YAC1B,MAAM;QACP,CAAC;IACF,CAAC;IAED,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,EAAE,CAAC,IAAI,EAAE,EAAE;QACxD,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC1C,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC;QACzC,MAAM,OAAO,GAAG,IAAe,CAAC;QAChC,MAAM,WAAW,GAAG,GAAG,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,UAAU,CAAC,EAAE,IAAI,OAAO,CAAC,UAAU,CAAC,SAAS,EAAE,CAAC;QAClG,IAAI,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC;YAAE,OAAO,KAAK,CAAC;QACjD,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChD,MAAM,UAAU,GAAG,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QAC3D,IAAI,QAAQ,IAAI,UAAU,CAAC,eAAe,GAAG,EAAE;YAAE,OAAO,KAAK,CAAC;QAC9D,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;IAEH,OAAO,eAAuB,CAAC;AAChC,CAAC,CAAC"}
@@ -3,6 +3,8 @@ import type { Nodes as Mdast } from "mdast";
3
3
  type ExtractHast = ((hast: Hast) => Hast) | false | "strongly";
4
4
  export type HtmlToMdastOptions = {
5
5
  extractHast?: ExtractHast | ExtractHast[];
6
+ linkAsText?: boolean;
7
+ hideImage?: boolean;
6
8
  };
7
9
  export declare const htmlToMdast: (html: string, options?: HtmlToMdastOptions) => Mdast;
8
10
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"html-to-mdast.js","sourceRoot":"","sources":["../../src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CAAO,CAAC,GAAG,EAAE,WAAW,EAAE,EAAE;QAC9C,IAAI,WAAW,KAAK,KAAK;YAAE,OAAO,GAAG,CAAC;QACtC,IAAI,OAAO,WAAW,KAAK,QAAQ,IAAI,WAAW,IAAI,mBAAmB;YACxE,OAAO,mBAAmB,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC;QAC9C,IAAI,OAAO,WAAW,KAAK,UAAU;YAAE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;QAC/D,MAAM,IAAI,KAAK,CAAC,wBAAwB,WAAW,EAAE,CAAC,CAAC;IACxD,CAAC,EAAE,IAAI,CAAC,IAAI,IAAI,CAAC;IAElB,MAAM,KAAK,GAAG,OAAO,CAAC,aAAa,EAAE;QACpC,QAAQ,EAAE;YACT,GAAG,EAAE,gBAAgB;YACrB,IAAI,EAAE,WAAW;YACjB,CAAC,EAAE,cAAc,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;YAClD,EAAE,EAAE,GAAG,EAAE,GAAE,CAAC;YACZ,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD;KACD,CAAC,CAAC;IAEH,OAAO,KAAK,CAAC;AACd,CAAC,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const loadHtml: (url: string, ctx: puppeteer.BrowserWorker) => Promise<any>;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cf-puppeteer.js","sourceRoot":"","sources":["../../../src/loaders/cf-puppeteer.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,uBAAuB,CAAC;AAE9C,MAAM,KAAK,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAEhF,MAAM,CAAC,MAAM,QAAQ,GAAG,KAAK,EAAE,GAAW,EAAE,GAA4B,EAAE,EAAE;IAC3E,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5C,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;IACrC,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAErB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IAElC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE9D,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IAEnB,OAAO,IAAI,CAAC;AACb,CAAC,CAAC"}
@@ -1,2 +1,4 @@
1
1
  import { type Handle } from "hast-util-to-mdast";
2
- export declare const customAHandler: Handle;
2
+ export declare const customAHandler: (options?: {
3
+ asText?: boolean;
4
+ }) => Handle;
@@ -1 +1 @@
1
- {"version":3,"file":"custom-a-handler.js","sourceRoot":"","sources":["../../../src/mdast-handlers/custom-a-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE,MAAM,CAAC,MAAM,cAAc,GAAW,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACrD,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC"}
1
+ {"version":3,"file":"custom-a-handler.js","sourceRoot":"","sources":["../../../src/mdast-handlers/custom-a-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAElE,MAAM,CAAC,MAAM,cAAc,GAC1B,CAAC,OAA8B,EAAU,EAAE,CAC3C,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;IACf,IAAI,OAAO,EAAE,MAAM,EAAE,CAAC;QACrB,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAC5C,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,MAAM;YAAE,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;QACjE,OAAO,SAAS,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,GAAG,eAAe,CAAC,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAC5C,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,SAAS,CAAC;AAClB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webforai",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "A library that provides a web interface for AI",
5
5
  "author": "inaridiy",
6
6
  "license": "MIT",
@@ -41,6 +41,11 @@
41
41
  "types": "./dist/types/loaders/playwright.d.ts",
42
42
  "import": "./dist/loaders/playwright.js",
43
43
  "require": "./dist/cjs/loaders/playwright.js"
44
+ },
45
+ "./loaders/cf-puppeteer": {
46
+ "types": "./dist/types/loaders/cf-puppeteer.d.ts",
47
+ "import": "./dist/loaders/cf-puppeteer.js",
48
+ "require": "./dist/cjs/loaders/cf-puppeteer.js"
44
49
  }
45
50
  },
46
51
  "typesVersions": {
@@ -50,15 +55,22 @@
50
55
  ],
51
56
  "loaders/playwright": [
52
57
  "./dist/types/loaders/playwright.d.ts"
58
+ ],
59
+ "loaders/cf-puppeteer": [
60
+ "./dist/types/loaders/cf-puppeteer.d.ts"
53
61
  ]
54
62
  }
55
63
  },
56
64
  "peerDependencies": {
57
- "playwright": "^1.0.0"
65
+ "playwright": "^1.0.0",
66
+ "@cloudflare/puppeteer": "^0.0.6"
58
67
  },
59
68
  "peerDependenciesMeta": {
60
69
  "playwright": {
61
70
  "optional": true
71
+ },
72
+ "@cloudflare/puppeteer": {
73
+ "optional": true
62
74
  }
63
75
  },
64
76
  "dependencies": {
@@ -77,6 +89,7 @@
77
89
  "unist-util-remove": "^4.0.0"
78
90
  },
79
91
  "devDependencies": {
92
+ "@cloudflare/puppeteer": "^0.0.6",
80
93
  "@tsconfig/recommended": "^1.0.3",
81
94
  "@types/hast": "^3.0.2",
82
95
  "@types/mdast": "^4.0.2",