rhua-chatgpt-web 1.0.64 → 1.0.66
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/{api_chain-faWaMGYk.cjs → api_chain-BeIaRZra.cjs} +1 -1
- package/dist/{api_chain-CF4PyLek.js → api_chain-DF18AKhy.js} +2 -2
- package/dist/{combine_docs_chain-H0s1aIKL.cjs → combine_docs_chain-BJKWrH7-.cjs} +1 -1
- package/dist/{combine_docs_chain-CjI8TKE2.js → combine_docs_chain-DVt_QF1z.js} +2 -2
- package/dist/{few_shot-Cs0vrRKR.cjs → few_shot-4KXXo1jw.cjs} +1 -1
- package/dist/{few_shot-DZ_h6hjj.js → few_shot-DLO4sh7P.js} +1 -1
- package/dist/index-2yo2kUGy.cjs +1 -0
- package/dist/index-5VYfR_5m.js +4 -0
- package/dist/index-B0wjEi98.cjs +1 -0
- package/dist/index-BEZf1ZPW.js +22 -0
- package/dist/index-Bd6vpkW7.js +399 -0
- package/dist/index-Bt8YXmsf.cjs +1 -0
- package/dist/index-Bv12SXjQ.cjs +1 -0
- package/dist/index-CPCpg6YW.cjs +1 -0
- package/dist/index-CbTur5sy.js +523 -0
- package/dist/index-CdZNxWqh.cjs +1 -0
- package/dist/index-D8E1uiLz.cjs +1 -0
- package/dist/index-DP27uNQQ.cjs +1 -0
- package/dist/index-DZ-veFCy.js +8431 -0
- package/dist/index-D_2mcJnM.js +4 -0
- package/dist/{index-PLUIJdfM.cjs → index-D_tNbyFe.cjs} +3 -3
- package/dist/index-DawAjlkV.cjs +1 -0
- package/dist/index-DhZCJfye.cjs +1 -0
- package/dist/index-DpPcvw7m.js +891 -0
- package/dist/{index-C19x3jbG.js → index-DvUW1FOA.js} +137 -58
- package/dist/index-DyYDZPYV.js +7 -0
- package/dist/index-DzQtCQ6Z.js +4 -0
- package/dist/index-GotW1yO2.js +1134 -0
- package/dist/index-NySJ5CR5.js +97 -0
- package/dist/index-OIum_iDx.cjs +1 -0
- package/dist/index-YwBw-Oln.js +4 -0
- package/dist/index-xPv-T73M.cjs +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.es-C0DXUwhk.js +60657 -0
- package/dist/index.es-Kia_Q21T.cjs +32 -0
- package/dist/index.esm.js +7 -7
- package/dist/{llm_chain-DunBe8Fo.cjs → llm_chain-DxQKp_Vf.cjs} +1 -1
- package/dist/{llm_chain-57y-Bkgf.js → llm_chain-Zo6Ojo9e.js} +1 -1
- package/dist/module-BYKmqHYm.cjs +1 -0
- package/dist/module-CnqjwKgs.js +2582 -0
- package/dist/native-CLBO_ikU.cjs +1 -0
- package/dist/native-D-bZ0OKf.js +40144 -0
- package/dist/{sequential_chain-aLaujhQd.js → sequential_chain-Bpkf4vr9.js} +1 -1
- package/dist/{sequential_chain-CiWagHsc.cjs → sequential_chain-D5sV8mmu.cjs} +1 -1
- package/dist/style.css +1 -1
- package/dist/{vector_db_qa-C31pnucA.cjs → vector_db_qa-BXe5-B9d.cjs} +1 -1
- package/dist/{vector_db_qa-CDk842tI.js → vector_db_qa-B_N1Q6n3.js} +3 -3
- package/dist/vue.runtime.esm-bundler-B0phHADm.cjs +28 -0
- package/dist/vue.runtime.esm-bundler-uPvnzsTN.js +7792 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-D_tNbyFe.cjs"),i=require("./llm_chain-DxQKp_Vf.cjs");require("zod");const t="You are given the below API Documentation:\n{api_docs}\nUsing this documentation, generate the full API url to call for answering the user question.\nYou should build the API url in order to get a response that is as short as possible, while still getting the necessary information to answer the question. Pay attention to deliberately exclude any unnecessary pieces of data in the API call.\n\nQuestion:{question}\nAPI url:",a=new e.PromptTemplate({inputVariables:["api_docs","question"],template:t}),n=`${t} {api_url}\n\nHere is the response from the API:\n\n{api_response}\n\nSummarize this response to answer the original question.\n\nSummary:`,s=new e.PromptTemplate({inputVariables:["api_docs","question","api_url","api_response"],template:n});class r extends e.BaseChain{get inputKeys(){return[this.inputKey]}get outputKeys(){return[this.outputKey]}constructor(e){super(e),Object.defineProperty(this,"apiAnswerChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiRequestChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"apiDocs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"headers",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"question"}),Object.defineProperty(this,"outputKey",{enumerable:!0,configurable:!0,writable:!0,value:"output"}),this.apiRequestChain=e.apiRequestChain,this.apiAnswerChain=e.apiAnswerChain,this.apiDocs=e.apiDocs,this.inputKey=e.inputKey??this.inputKey,this.outputKey=e.outputKey??this.outputKey,this.headers=e.headers??this.headers}async _call(e,i){const t=e[this.inputKey],a=await this.apiRequestChain.predict({question:t,api_docs:this.apiDocs},null==i?void 0:i.getChild("request")),n=await fetch(a,{headers:this.headers}),s=await n.text(),r=await this.apiAnswerChain.predict({question:t,api_docs:this.apiDocs,api_url:a,api_response:s},null==i?void 0:i.getChild("response"));return{[this.outputKey]:r}}_chainType(){return"api_chain"}static async deserialize(e){const{api_request_chain:t,api_answer_chain:a,api_docs:n}=e;if(!t)throw new Error("LLMChain must have api_request_chain");if(!a)throw new Error("LLMChain must have api_answer_chain");if(!n)throw new Error("LLMChain must have api_docs");return new r({apiAnswerChain:await i.LLMChain.deserialize(a),apiRequestChain:await i.LLMChain.deserialize(t),apiDocs:n})}serialize(){return{_type:this._chainType(),api_answer_chain:this.apiAnswerChain.serialize(),api_request_chain:this.apiRequestChain.serialize(),api_docs:this.apiDocs}}static fromLLMAndAPIDocs(e,t,n={}){const{apiUrlPrompt:r=a,apiResponsePrompt:o=s}=n,u=new i.LLMChain({prompt:r,llm:e});return new this({apiAnswerChain:new i.LLMChain({prompt:o,llm:e}),apiRequestChain:u,apiDocs:t,...n})}}exports.APIChain=r;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as PromptTemplate,
|
|
2
|
-
import { LLMChain } from "./llm_chain-
|
|
1
|
+
import { P as PromptTemplate, i as BaseChain } from "./index-DvUW1FOA.js";
|
|
2
|
+
import { LLMChain } from "./llm_chain-Zo6Ojo9e.js";
|
|
3
3
|
import "zod";
|
|
4
4
|
const API_URL_RAW_PROMPT_TEMPLATE = `You are given the below API Documentation:
|
|
5
5
|
{api_docs}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("zod");const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"}),require("zod");const e=require("./index-D_tNbyFe.cjs"),t=require("./llm_chain-DxQKp_Vf.cjs");class i extends e.BaseChain{static lc_name(){return"StuffDocumentsChain"}get inputKeys(){return[this.inputKey,...this.llmChain.inputKeys].filter(e=>e!==this.documentVariableName)}get outputKeys(){return this.llmChain.outputKeys}constructor(e){super(e),Object.defineProperty(this,"llmChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"input_documents"}),Object.defineProperty(this,"documentVariableName",{enumerable:!0,configurable:!0,writable:!0,value:"context"}),this.llmChain=e.llmChain,this.documentVariableName=e.documentVariableName??this.documentVariableName,this.inputKey=e.inputKey??this.inputKey}_prepInputs(e){if(!(this.inputKey in e))throw new Error(`Document key ${this.inputKey} not found.`);const{[this.inputKey]:t,...i}=e,n=t.map(({pageContent:e})=>e).join("\n\n");return{...i,[this.documentVariableName]:n}}async _call(e,t){return await this.llmChain.call(this._prepInputs(e),null==t?void 0:t.getChild("combine_documents"))}_chainType(){return"stuff_documents_chain"}static async deserialize(e){if(!e.llm_chain)throw new Error("Missing llm_chain");return new i({llmChain:await t.LLMChain.deserialize(e.llm_chain)})}serialize(){return{_type:this._chainType(),llm_chain:this.llmChain.serialize()}}}class n extends e.BaseChain{static lc_name(){return"MapReduceDocumentsChain"}get inputKeys(){return[this.inputKey,...this.combineDocumentChain.inputKeys]}get outputKeys(){return this.combineDocumentChain.outputKeys}constructor(e){super(e),Object.defineProperty(this,"llmChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"input_documents"}),Object.defineProperty(this,"documentVariableName",{enumerable:!0,configurable:!0,writable:!0,value:"context"}),Object.defineProperty(this,"returnIntermediateSteps",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"maxTokens",{enumerable:!0,configurable:!0,writable:!0,value:3e3}),Object.defineProperty(this,"maxIterations",{enumerable:!0,configurable:!0,writable:!0,value:10}),Object.defineProperty(this,"ensureMapStep",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"combineDocumentChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.llmChain=e.llmChain,this.combineDocumentChain=e.combineDocumentChain,this.documentVariableName=e.documentVariableName??this.documentVariableName,this.ensureMapStep=e.ensureMapStep??this.ensureMapStep,this.inputKey=e.inputKey??this.inputKey,this.maxTokens=e.maxTokens??this.maxTokens,this.maxIterations=e.maxIterations??this.maxIterations,this.returnIntermediateSteps=e.returnIntermediateSteps??!1}async _call(e,t){if(!(this.inputKey in e))throw new Error(`Document key ${this.inputKey} not found.`);const{[this.inputKey]:i,...n}=e;let a=i,r=[];for(let o=0;o<this.maxIterations;o+=1){const e=a.map(e=>({[this.documentVariableName]:e.pageContent,...n}));if(0!==o||!this.ensureMapStep){const e=await this.combineDocumentChain.llmChain.prompt.format(this.combineDocumentChain._prepInputs({[this.combineDocumentChain.inputKey]:a,...n}));if(await this.combineDocumentChain.llmChain._getNumTokens(e)<this.maxTokens)break}const i=await this.llmChain.apply(e,t?Array.from({length:e.length},(e,i)=>t.getChild(`map_${i+1}`)):void 0),{outputKey:s}=this.llmChain;this.returnIntermediateSteps&&(r=r.concat(i.map(e=>e[s]))),a=i.map(e=>({pageContent:e[s],metadata:{}}))}const s={[this.combineDocumentChain.inputKey]:a,...n},u=await this.combineDocumentChain.call(s,null==t?void 0:t.getChild("combine_documents"));return this.returnIntermediateSteps?{...u,intermediateSteps:r}:u}_chainType(){return"map_reduce_documents_chain"}static async deserialize(e){if(!e.llm_chain)throw new Error("Missing llm_chain");if(!e.combine_document_chain)throw new Error("Missing combine_document_chain");return new n({llmChain:await t.LLMChain.deserialize(e.llm_chain),combineDocumentChain:await i.deserialize(e.combine_document_chain)})}serialize(){return{_type:this._chainType(),llm_chain:this.llmChain.serialize(),combine_document_chain:this.combineDocumentChain.serialize()}}}class a extends e.BaseChain{static lc_name(){return"RefineDocumentsChain"}get defaultDocumentPrompt(){return new e.PromptTemplate({inputVariables:["page_content"],template:"{page_content}"})}get inputKeys(){return[...new Set([this.inputKey,...this.llmChain.inputKeys,...this.refineLLMChain.inputKeys])].filter(e=>e!==this.documentVariableName&&e!==this.initialResponseName)}get outputKeys(){return[this.outputKey]}constructor(e){super(e),Object.defineProperty(this,"llmChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"inputKey",{enumerable:!0,configurable:!0,writable:!0,value:"input_documents"}),Object.defineProperty(this,"outputKey",{enumerable:!0,configurable:!0,writable:!0,value:"output_text"}),Object.defineProperty(this,"documentVariableName",{enumerable:!0,configurable:!0,writable:!0,value:"context"}),Object.defineProperty(this,"initialResponseName",{enumerable:!0,configurable:!0,writable:!0,value:"existing_answer"}),Object.defineProperty(this,"refineLLMChain",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"documentPrompt",{enumerable:!0,configurable:!0,writable:!0,value:this.defaultDocumentPrompt}),this.llmChain=e.llmChain,this.refineLLMChain=e.refineLLMChain,this.documentVariableName=e.documentVariableName??this.documentVariableName,this.inputKey=e.inputKey??this.inputKey,this.outputKey=e.outputKey??this.outputKey,this.documentPrompt=e.documentPrompt??this.documentPrompt,this.initialResponseName=e.initialResponseName??this.initialResponseName}async _constructInitialInputs(e,t){const i={page_content:e.pageContent,...e.metadata},n={};this.documentPrompt.inputVariables.forEach(e=>{n[e]=i[e]});return{...{[this.documentVariableName]:await this.documentPrompt.format({...n})},...t}}async _constructRefineInputs(e,t){const i={page_content:e.pageContent,...e.metadata},n={};this.documentPrompt.inputVariables.forEach(e=>{n[e]=i[e]});const a={[this.documentVariableName]:await this.documentPrompt.format({...n})};return{[this.initialResponseName]:t,...a}}async _call(e,t){if(!(this.inputKey in e))throw new Error(`Document key ${this.inputKey} not found.`);const{[this.inputKey]:i,...n}=e,a=i,r=await this._constructInitialInputs(a[0],n);let s=await this.llmChain.predict({...r},null==t?void 0:t.getChild("answer"));for(let u=1;u<a.length;u+=1){const e={...await this._constructRefineInputs(a[u],s),...n};s=await this.refineLLMChain.predict({...e},null==t?void 0:t.getChild("refine"))}return{[this.outputKey]:s}}_chainType(){return"refine_documents_chain"}static async deserialize(e){const i=e.llm_chain;if(!i)throw new Error("Missing llm_chain");const n=e.refine_llm_chain;if(!n)throw new Error("Missing refine_llm_chain");return new a({llmChain:await t.LLMChain.deserialize(i),refineLLMChain:await t.LLMChain.deserialize(n)})}serialize(){return{_type:this._chainType(),llm_chain:this.llmChain.serialize(),refine_llm_chain:this.refineLLMChain.serialize()}}}exports.MapReduceDocumentsChain=n,exports.RefineDocumentsChain=a,exports.StuffDocumentsChain=i;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "zod";
|
|
2
|
-
import {
|
|
3
|
-
import { LLMChain } from "./llm_chain-
|
|
2
|
+
import { i as BaseChain, P as PromptTemplate } from "./index-DvUW1FOA.js";
|
|
3
|
+
import { LLMChain } from "./llm_chain-Zo6Ojo9e.js";
|
|
4
4
|
class StuffDocumentsChain extends BaseChain {
|
|
5
5
|
static lc_name() {
|
|
6
6
|
return "StuffDocumentsChain";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-D_tNbyFe.cjs");require("zod");class t extends e.BaseStringPromptTemplate{constructor(t){if(super(t),Object.defineProperty(this,"lc_serializable",{enumerable:!0,configurable:!0,writable:!0,value:!1}),Object.defineProperty(this,"examples",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"exampleSelector",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"examplePrompt",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"suffix",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"exampleSeparator",{enumerable:!0,configurable:!0,writable:!0,value:"\n\n"}),Object.defineProperty(this,"prefix",{enumerable:!0,configurable:!0,writable:!0,value:""}),Object.defineProperty(this,"templateFormat",{enumerable:!0,configurable:!0,writable:!0,value:"f-string"}),Object.defineProperty(this,"validateTemplate",{enumerable:!0,configurable:!0,writable:!0,value:!0}),Object.assign(this,t),void 0!==this.examples&&void 0!==this.exampleSelector)throw new Error("Only one of 'examples' and 'example_selector' should be provided");if(void 0===this.examples&&void 0===this.exampleSelector)throw new Error("One of 'examples' and 'example_selector' should be provided");if(this.validateTemplate){let t=this.inputVariables;this.partialVariables&&(t=t.concat(Object.keys(this.partialVariables))),e.checkValidTemplate(this.prefix+this.suffix,this.templateFormat,t)}}_getPromptType(){return"few_shot"}static lc_name(){return"FewShotPromptTemplate"}async getExamples(e){if(void 0!==this.examples)return this.examples;if(void 0!==this.exampleSelector)return this.exampleSelector.selectExamples(e);throw new Error("One of 'examples' and 'example_selector' should be provided")}async partial(e){const r=this.inputVariables.filter(t=>!(t in e)),a={...this.partialVariables??{},...e},i={...this,inputVariables:r,partialVariables:a};return new t(i)}async format(t){const r=await this.mergePartialAndUserVariables(t),a=await this.getExamples(r),i=await Promise.all(a.map(e=>this.examplePrompt.format(e))),l=[this.prefix,...i,this.suffix].join(this.exampleSeparator);return e.renderTemplate(l,this.templateFormat,r)}serialize(){if(this.exampleSelector||!this.examples)throw new Error("Serializing an example selector is not currently supported");if(void 0!==this.outputParser)throw new Error("Serializing an output parser is not currently supported");return{_type:this._getPromptType(),input_variables:this.inputVariables,example_prompt:this.examplePrompt.serialize(),example_separator:this.exampleSeparator,suffix:this.suffix,prefix:this.prefix,template_format:this.templateFormat,examples:this.examples}}static async deserialize(r){const{example_prompt:a}=r;if(!a)throw new Error("Missing example prompt");const i=await e.PromptTemplate.deserialize(a);let l;if(!Array.isArray(r.examples))throw new Error("Invalid examples format. Only list or string are supported.");return l=r.examples,new t({inputVariables:r.input_variables,examplePrompt:i,examples:l,exampleSeparator:r.example_separator,prefix:r.prefix,suffix:r.suffix,templateFormat:r.template_format})}}exports.FewShotPromptTemplate=t;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BaseStringPromptTemplate,
|
|
1
|
+
import { B as BaseStringPromptTemplate, e as checkValidTemplate, g as renderTemplate, P as PromptTemplate } from "./index-DvUW1FOA.js";
|
|
2
2
|
import "zod";
|
|
3
3
|
class FewShotPromptTemplate extends BaseStringPromptTemplate {
|
|
4
4
|
constructor(input) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const n={}.hasOwnProperty;exports.zwitch=function(t,i){const l=i||{};function r(i,...l){let s=r.invalid;const c=r.handlers;if(i&&n.call(i,t)){const l=String(i[t]);s=n.call(c,l)?c[l]:r.unknown}if(s)return s.call(this,i,...l)}return r.handlers=l.handlers||{},r.invalid=l.invalid,r.unknown=l.unknown,r};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-D_tNbyFe.cjs");exports.default=e.remarkRehype,exports.defaultFootnoteBackContent=e.defaultFootnoteBackContent,exports.defaultFootnoteBackLabel=e.defaultFootnoteBackLabel,exports.defaultHandlers=e.handlers;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const own = {}.hasOwnProperty;
|
|
2
|
+
function zwitch(key, options) {
|
|
3
|
+
const settings = options || {};
|
|
4
|
+
function one(value, ...parameters) {
|
|
5
|
+
let fn = one.invalid;
|
|
6
|
+
const handlers = one.handlers;
|
|
7
|
+
if (value && own.call(value, key)) {
|
|
8
|
+
const id = String(value[key]);
|
|
9
|
+
fn = own.call(handlers, id) ? handlers[id] : one.unknown;
|
|
10
|
+
}
|
|
11
|
+
if (fn) {
|
|
12
|
+
return fn.call(this, value, ...parameters);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
one.handlers = settings.handlers || {};
|
|
16
|
+
one.invalid = settings.invalid;
|
|
17
|
+
one.unknown = settings.unknown;
|
|
18
|
+
return one;
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
zwitch as z
|
|
22
|
+
};
|
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
import { n as convertElement, o as convert, p as isElement, w as whitespace } from "./index-DvUW1FOA.js";
|
|
2
|
+
const embedded = convertElement(
|
|
3
|
+
/**
|
|
4
|
+
* @param element
|
|
5
|
+
* @returns {element is {tagName: 'audio' | 'canvas' | 'embed' | 'iframe' | 'img' | 'math' | 'object' | 'picture' | 'svg' | 'video'}}
|
|
6
|
+
*/
|
|
7
|
+
function(element) {
|
|
8
|
+
return element.tagName === "audio" || element.tagName === "canvas" || element.tagName === "embed" || element.tagName === "iframe" || element.tagName === "img" || element.tagName === "math" || element.tagName === "object" || element.tagName === "picture" || element.tagName === "svg" || element.tagName === "video";
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
const blocks = [
|
|
12
|
+
"address",
|
|
13
|
+
// Flow content.
|
|
14
|
+
"article",
|
|
15
|
+
// Sections and headings.
|
|
16
|
+
"aside",
|
|
17
|
+
// Sections and headings.
|
|
18
|
+
"blockquote",
|
|
19
|
+
// Flow content.
|
|
20
|
+
"body",
|
|
21
|
+
// Page.
|
|
22
|
+
"br",
|
|
23
|
+
// Contribute whitespace intrinsically.
|
|
24
|
+
"caption",
|
|
25
|
+
// Similar to block.
|
|
26
|
+
"center",
|
|
27
|
+
// Flow content, legacy.
|
|
28
|
+
"col",
|
|
29
|
+
// Similar to block.
|
|
30
|
+
"colgroup",
|
|
31
|
+
// Similar to block.
|
|
32
|
+
"dd",
|
|
33
|
+
// Lists.
|
|
34
|
+
"dialog",
|
|
35
|
+
// Flow content.
|
|
36
|
+
"dir",
|
|
37
|
+
// Lists, legacy.
|
|
38
|
+
"div",
|
|
39
|
+
// Flow content.
|
|
40
|
+
"dl",
|
|
41
|
+
// Lists.
|
|
42
|
+
"dt",
|
|
43
|
+
// Lists.
|
|
44
|
+
"figcaption",
|
|
45
|
+
// Flow content.
|
|
46
|
+
"figure",
|
|
47
|
+
// Flow content.
|
|
48
|
+
"footer",
|
|
49
|
+
// Flow content.
|
|
50
|
+
"form",
|
|
51
|
+
// Flow content.
|
|
52
|
+
"h1",
|
|
53
|
+
// Sections and headings.
|
|
54
|
+
"h2",
|
|
55
|
+
// Sections and headings.
|
|
56
|
+
"h3",
|
|
57
|
+
// Sections and headings.
|
|
58
|
+
"h4",
|
|
59
|
+
// Sections and headings.
|
|
60
|
+
"h5",
|
|
61
|
+
// Sections and headings.
|
|
62
|
+
"h6",
|
|
63
|
+
// Sections and headings.
|
|
64
|
+
"head",
|
|
65
|
+
// Page.
|
|
66
|
+
"header",
|
|
67
|
+
// Flow content.
|
|
68
|
+
"hgroup",
|
|
69
|
+
// Sections and headings.
|
|
70
|
+
"hr",
|
|
71
|
+
// Flow content.
|
|
72
|
+
"html",
|
|
73
|
+
// Page.
|
|
74
|
+
"legend",
|
|
75
|
+
// Flow content.
|
|
76
|
+
"li",
|
|
77
|
+
// Block-like.
|
|
78
|
+
"li",
|
|
79
|
+
// Similar to block.
|
|
80
|
+
"listing",
|
|
81
|
+
// Flow content, legacy
|
|
82
|
+
"main",
|
|
83
|
+
// Flow content.
|
|
84
|
+
"menu",
|
|
85
|
+
// Lists.
|
|
86
|
+
"nav",
|
|
87
|
+
// Sections and headings.
|
|
88
|
+
"ol",
|
|
89
|
+
// Lists.
|
|
90
|
+
"optgroup",
|
|
91
|
+
// Similar to block.
|
|
92
|
+
"option",
|
|
93
|
+
// Similar to block.
|
|
94
|
+
"p",
|
|
95
|
+
// Flow content.
|
|
96
|
+
"plaintext",
|
|
97
|
+
// Flow content, legacy
|
|
98
|
+
"pre",
|
|
99
|
+
// Flow content.
|
|
100
|
+
"section",
|
|
101
|
+
// Sections and headings.
|
|
102
|
+
"summary",
|
|
103
|
+
// Similar to block.
|
|
104
|
+
"table",
|
|
105
|
+
// Similar to block.
|
|
106
|
+
"tbody",
|
|
107
|
+
// Similar to block.
|
|
108
|
+
"td",
|
|
109
|
+
// Block-like.
|
|
110
|
+
"td",
|
|
111
|
+
// Similar to block.
|
|
112
|
+
"tfoot",
|
|
113
|
+
// Similar to block.
|
|
114
|
+
"th",
|
|
115
|
+
// Block-like.
|
|
116
|
+
"th",
|
|
117
|
+
// Similar to block.
|
|
118
|
+
"thead",
|
|
119
|
+
// Similar to block.
|
|
120
|
+
"tr",
|
|
121
|
+
// Similar to block.
|
|
122
|
+
"ul",
|
|
123
|
+
// Lists.
|
|
124
|
+
"wbr",
|
|
125
|
+
// Contribute whitespace intrinsically.
|
|
126
|
+
"xmp"
|
|
127
|
+
// Flow content, legacy
|
|
128
|
+
];
|
|
129
|
+
const content$1 = [
|
|
130
|
+
// Form.
|
|
131
|
+
"button",
|
|
132
|
+
"input",
|
|
133
|
+
"select",
|
|
134
|
+
"textarea"
|
|
135
|
+
];
|
|
136
|
+
const skippable$1 = [
|
|
137
|
+
"area",
|
|
138
|
+
"base",
|
|
139
|
+
"basefont",
|
|
140
|
+
"dialog",
|
|
141
|
+
"datalist",
|
|
142
|
+
"head",
|
|
143
|
+
"link",
|
|
144
|
+
"meta",
|
|
145
|
+
"noembed",
|
|
146
|
+
"noframes",
|
|
147
|
+
"param",
|
|
148
|
+
"rp",
|
|
149
|
+
"script",
|
|
150
|
+
"source",
|
|
151
|
+
"style",
|
|
152
|
+
"template",
|
|
153
|
+
"track",
|
|
154
|
+
"title"
|
|
155
|
+
];
|
|
156
|
+
const emptyOptions = {};
|
|
157
|
+
const ignorableNode = convert(["comment", "doctype"]);
|
|
158
|
+
function minifyWhitespace(tree, options) {
|
|
159
|
+
const settings = options || emptyOptions;
|
|
160
|
+
minify(tree, {
|
|
161
|
+
collapse: collapseFactory(
|
|
162
|
+
settings.newlines ? replaceNewlines : replaceWhitespace
|
|
163
|
+
),
|
|
164
|
+
whitespace: "normal"
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
function minify(node, state) {
|
|
168
|
+
if ("children" in node) {
|
|
169
|
+
const settings = { ...state };
|
|
170
|
+
if (node.type === "root" || blocklike(node)) {
|
|
171
|
+
settings.before = true;
|
|
172
|
+
settings.after = true;
|
|
173
|
+
}
|
|
174
|
+
settings.whitespace = inferWhiteSpace(node, state);
|
|
175
|
+
return all(node, settings);
|
|
176
|
+
}
|
|
177
|
+
if (node.type === "text") {
|
|
178
|
+
if (state.whitespace === "normal") {
|
|
179
|
+
return minifyText(node, state);
|
|
180
|
+
}
|
|
181
|
+
if (state.whitespace === "nowrap") {
|
|
182
|
+
node.value = state.collapse(node.value);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return { ignore: ignorableNode(node), stripAtStart: false, remove: false };
|
|
186
|
+
}
|
|
187
|
+
function minifyText(node, state) {
|
|
188
|
+
const value = state.collapse(node.value);
|
|
189
|
+
const result = { ignore: false, stripAtStart: false, remove: false };
|
|
190
|
+
let start = 0;
|
|
191
|
+
let end = value.length;
|
|
192
|
+
if (state.before && removable(value.charAt(0))) {
|
|
193
|
+
start++;
|
|
194
|
+
}
|
|
195
|
+
if (start !== end && removable(value.charAt(end - 1))) {
|
|
196
|
+
if (state.after) {
|
|
197
|
+
end--;
|
|
198
|
+
} else {
|
|
199
|
+
result.stripAtStart = true;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
if (start === end) {
|
|
203
|
+
result.remove = true;
|
|
204
|
+
} else {
|
|
205
|
+
node.value = value.slice(start, end);
|
|
206
|
+
}
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
function all(parent, state) {
|
|
210
|
+
let before = state.before;
|
|
211
|
+
const after = state.after;
|
|
212
|
+
const children = parent.children;
|
|
213
|
+
let length = children.length;
|
|
214
|
+
let index = -1;
|
|
215
|
+
while (++index < length) {
|
|
216
|
+
const result = minify(children[index], {
|
|
217
|
+
...state,
|
|
218
|
+
after: collapsableAfter(children, index, after),
|
|
219
|
+
before
|
|
220
|
+
});
|
|
221
|
+
if (result.remove) {
|
|
222
|
+
children.splice(index, 1);
|
|
223
|
+
index--;
|
|
224
|
+
length--;
|
|
225
|
+
} else if (!result.ignore) {
|
|
226
|
+
before = result.stripAtStart;
|
|
227
|
+
}
|
|
228
|
+
if (content(children[index])) {
|
|
229
|
+
before = false;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return { ignore: false, stripAtStart: Boolean(before || after), remove: false };
|
|
233
|
+
}
|
|
234
|
+
function collapsableAfter(nodes, index, after) {
|
|
235
|
+
while (++index < nodes.length) {
|
|
236
|
+
const node = nodes[index];
|
|
237
|
+
let result = inferBoundary(node);
|
|
238
|
+
if (result === void 0 && "children" in node && !skippable(node)) {
|
|
239
|
+
result = collapsableAfter(node.children, -1);
|
|
240
|
+
}
|
|
241
|
+
if (typeof result === "boolean") {
|
|
242
|
+
return result;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return after;
|
|
246
|
+
}
|
|
247
|
+
function inferBoundary(node) {
|
|
248
|
+
if (node.type === "element") {
|
|
249
|
+
if (content(node)) {
|
|
250
|
+
return false;
|
|
251
|
+
}
|
|
252
|
+
if (blocklike(node)) {
|
|
253
|
+
return true;
|
|
254
|
+
}
|
|
255
|
+
} else if (node.type === "text") {
|
|
256
|
+
if (!whitespace(node)) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
} else if (!ignorableNode(node)) {
|
|
260
|
+
return false;
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
function content(node) {
|
|
264
|
+
return embedded(node) || isElement(node, content$1);
|
|
265
|
+
}
|
|
266
|
+
function blocklike(node) {
|
|
267
|
+
return isElement(node, blocks);
|
|
268
|
+
}
|
|
269
|
+
function skippable(node) {
|
|
270
|
+
return Boolean(node.type === "element" && node.properties.hidden) || ignorableNode(node) || isElement(node, skippable$1);
|
|
271
|
+
}
|
|
272
|
+
function removable(character) {
|
|
273
|
+
return character === " " || character === "\n";
|
|
274
|
+
}
|
|
275
|
+
function replaceNewlines(value) {
|
|
276
|
+
const match = /\r?\n|\r/.exec(value);
|
|
277
|
+
return match ? match[0] : " ";
|
|
278
|
+
}
|
|
279
|
+
function replaceWhitespace() {
|
|
280
|
+
return " ";
|
|
281
|
+
}
|
|
282
|
+
function collapseFactory(replace) {
|
|
283
|
+
return collapse;
|
|
284
|
+
function collapse(value) {
|
|
285
|
+
return String(value).replace(/[\t\n\v\f\r ]+/g, replace);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
function inferWhiteSpace(node, state) {
|
|
289
|
+
if ("tagName" in node && node.properties) {
|
|
290
|
+
switch (node.tagName) {
|
|
291
|
+
case "listing":
|
|
292
|
+
case "plaintext":
|
|
293
|
+
case "script":
|
|
294
|
+
case "style":
|
|
295
|
+
case "xmp": {
|
|
296
|
+
return "pre";
|
|
297
|
+
}
|
|
298
|
+
case "nobr": {
|
|
299
|
+
return "nowrap";
|
|
300
|
+
}
|
|
301
|
+
case "pre": {
|
|
302
|
+
return node.properties.wrap ? "pre-wrap" : "pre";
|
|
303
|
+
}
|
|
304
|
+
case "td":
|
|
305
|
+
case "th": {
|
|
306
|
+
return node.properties.noWrap ? "nowrap" : state.whitespace;
|
|
307
|
+
}
|
|
308
|
+
case "textarea": {
|
|
309
|
+
return "pre-wrap";
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return state.whitespace;
|
|
314
|
+
}
|
|
315
|
+
const own = {}.hasOwnProperty;
|
|
316
|
+
function hasProperty(node, name) {
|
|
317
|
+
const value = node.type === "element" && own.call(node.properties, name) && node.properties[name];
|
|
318
|
+
return value !== null && value !== void 0 && value !== false;
|
|
319
|
+
}
|
|
320
|
+
const list = /* @__PURE__ */ new Set(["pingback", "prefetch", "stylesheet"]);
|
|
321
|
+
function isBodyOkLink(node) {
|
|
322
|
+
if (node.type !== "element" || node.tagName !== "link") {
|
|
323
|
+
return false;
|
|
324
|
+
}
|
|
325
|
+
if (node.properties.itemProp) {
|
|
326
|
+
return true;
|
|
327
|
+
}
|
|
328
|
+
const value = node.properties.rel;
|
|
329
|
+
let index = -1;
|
|
330
|
+
if (!Array.isArray(value) || value.length === 0) {
|
|
331
|
+
return false;
|
|
332
|
+
}
|
|
333
|
+
while (++index < value.length) {
|
|
334
|
+
if (!list.has(String(value[index]))) {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
const basic = convertElement([
|
|
341
|
+
"a",
|
|
342
|
+
"abbr",
|
|
343
|
+
// `area` is in fact only phrasing if it is inside a `map` element.
|
|
344
|
+
// However, since `area`s are required to be inside a `map` element, and it’s
|
|
345
|
+
// a rather involved check, it’s ignored here for now.
|
|
346
|
+
"area",
|
|
347
|
+
"b",
|
|
348
|
+
"bdi",
|
|
349
|
+
"bdo",
|
|
350
|
+
"br",
|
|
351
|
+
"button",
|
|
352
|
+
"cite",
|
|
353
|
+
"code",
|
|
354
|
+
"data",
|
|
355
|
+
"datalist",
|
|
356
|
+
"del",
|
|
357
|
+
"dfn",
|
|
358
|
+
"em",
|
|
359
|
+
"i",
|
|
360
|
+
"input",
|
|
361
|
+
"ins",
|
|
362
|
+
"kbd",
|
|
363
|
+
"keygen",
|
|
364
|
+
"label",
|
|
365
|
+
"map",
|
|
366
|
+
"mark",
|
|
367
|
+
"meter",
|
|
368
|
+
"noscript",
|
|
369
|
+
"output",
|
|
370
|
+
"progress",
|
|
371
|
+
"q",
|
|
372
|
+
"ruby",
|
|
373
|
+
"s",
|
|
374
|
+
"samp",
|
|
375
|
+
"script",
|
|
376
|
+
"select",
|
|
377
|
+
"small",
|
|
378
|
+
"span",
|
|
379
|
+
"strong",
|
|
380
|
+
"sub",
|
|
381
|
+
"sup",
|
|
382
|
+
"template",
|
|
383
|
+
"textarea",
|
|
384
|
+
"time",
|
|
385
|
+
"u",
|
|
386
|
+
"var",
|
|
387
|
+
"wbr"
|
|
388
|
+
]);
|
|
389
|
+
const meta = convertElement("meta");
|
|
390
|
+
function phrasing(value) {
|
|
391
|
+
return Boolean(
|
|
392
|
+
value.type === "text" || basic(value) || embedded(value) || isBodyOkLink(value) || meta(value) && hasProperty(value, "itemProp")
|
|
393
|
+
);
|
|
394
|
+
}
|
|
395
|
+
export {
|
|
396
|
+
embedded as e,
|
|
397
|
+
minifyWhitespace as m,
|
|
398
|
+
phrasing as p
|
|
399
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DhZCJfye.cjs"),t=require("./index-D_tNbyFe.cjs"),n=["pre","script","style","textarea"],i={};function a(e,t){return Boolean(t&&"element"===t.type&&e.blanks.length>0&&e.blanks.includes(t.tagName))}function l(t,n){return"root"===n.type||"element"===n.type&&(t.head||"script"===n.tagName||e.embedded(n)||!e.phrasing(n))}exports.default=function(r){return function(c){!function(r,c){const d=c||i,s={blanks:d.blanks||[],head:!1,indentInitial:!1!==d.indentInitial,indent:"number"==typeof d.indent?" ".repeat(d.indent):"string"==typeof d.indent?d.indent:" "};function o(e,n,i){const l=e[e.length-1],r=l&&t.whitespace(l)?e[e.length-2]:l,c=(a(s,r)&&a(s,i)?"\n\n":"\n")+s.indent.repeat(Math.max(n,0));l&&"text"===l.type?l.value=t.whitespace(l)?c:l.value+c:e.push({type:"text",value:c})}e.minifyWhitespace(r,{newlines:!0}),t.visitParents(r,function(e,i){if(!("children"in e))return;if("element"===e.type&&"head"===e.tagName&&(s.head=!0),s.head&&"element"===e.type&&"body"===e.tagName&&(s.head=!1),"element"===e.type&&n.includes(e.tagName))return t.SKIP;if(0===e.children.length||!l(s,e))return;let a=i.length;s.indentInitial||a--;let r=!1;for(const t of e.children)"comment"!==t.type&&"text"!==t.type||(t.value.includes("\n")&&(r=!0),t.value=t.value.replace(/ *\n/g,"$&"+s.indent.repeat(a)));const c=[];let d;for(const t of e.children)(l(s,t)||r&&!d)&&(o(c,a,t),r=!0),d=t,c.push(t);d&&(r||l(s,d))&&(t.whitespace(d)&&(c.pop(),d=c[c.length-1]),o(c,a-1)),e.children=c})}(c,r)}};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-D_tNbyFe.cjs");exports.default=e.remarkParse;
|