@getlang/lib
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -9,6 +9,6 @@ import type { ElementType } from 'domelementtype'; | ||
} | ||
export type AnyHtmlNode = dh.AnyNode | Attribute; | ||
export declare const parse: (html: string) => AnyHtmlNode; | ||
export declare const select: (el: AnyHtmlNode, selector: string, expand: boolean) => any; | ||
export declare const toValue: (el: AnyHtmlNode) => string; | ||
export type AnyNode = dh.AnyNode | Attribute; | ||
export declare const parse: (html: string) => AnyNode; | ||
export declare const select: (el: AnyNode, selector: string, expand: boolean) => any; | ||
export declare const toValue: (el: AnyNode) => string; | ||
export {}; |
import type { AnyNode } from 'acorn'; | ||
export declare const parse: (js: string) => AnyNode; | ||
export declare const select: (node: AnyNode, selector: string, expand: boolean) => AnyNode | AnyNode[] | undefined; | ||
export declare const select: (node: AnyNode, selector: string, expand: boolean) => import("estree").Program | import("estree").Property | import("estree").CatchClause | import("estree").ClassDeclaration | import("estree").ClassExpression | import("estree").ClassBody | import("estree").Identifier | import("estree").SimpleLiteral | import("estree").RegExpLiteral | import("estree").BigIntLiteral | import("estree").ArrayExpression | import("estree").ArrowFunctionExpression | import("estree").AssignmentExpression | import("estree").AwaitExpression | import("estree").BinaryExpression | import("estree").SimpleCallExpression | import("estree").NewExpression | import("estree").ChainExpression | import("estree").ConditionalExpression | import("estree").FunctionExpression | import("estree").ImportExpression | import("estree").LogicalExpression | import("estree").MemberExpression | import("estree").MetaProperty | import("estree").ObjectExpression | import("estree").SequenceExpression | import("estree").TaggedTemplateExpression | import("estree").TemplateLiteral | import("estree").ThisExpression | import("estree").UnaryExpression | import("estree").UpdateExpression | import("estree").YieldExpression | import("estree").FunctionDeclaration | import("estree").MethodDefinition | import("estree").ImportDeclaration | import("estree").ExportNamedDeclaration | import("estree").ExportDefaultDeclaration | import("estree").ExportAllDeclaration | import("estree").ImportSpecifier | import("estree").ImportDefaultSpecifier | import("estree").ImportNamespaceSpecifier | import("estree").ExportSpecifier | import("estree").ObjectPattern | import("estree").ArrayPattern | import("estree").RestElement | import("estree").AssignmentPattern | import("estree").PrivateIdentifier | import("estree").PropertyDefinition | import("estree").SpreadElement | import("estree").ExpressionStatement | import("estree").BlockStatement | import("estree").StaticBlock | import("estree").EmptyStatement | import("estree").DebuggerStatement | import("estree").WithStatement | import("estree").ReturnStatement | import("estree").LabeledStatement | import("estree").BreakStatement | import("estree").ContinueStatement | import("estree").IfStatement | import("estree").SwitchStatement | import("estree").ThrowStatement | import("estree").TryStatement | import("estree").WhileStatement | import("estree").DoWhileStatement | import("estree").ForStatement | import("estree").ForInStatement | import("estree").ForOfStatement | import("estree").VariableDeclaration | import("estree").Super | import("estree").SwitchCase | import("estree").TemplateElement | import("estree").VariableDeclarator | import("estree").Node[] | undefined; | ||
export declare const toValue: (node: AnyNode) => string | number | bigint | boolean | RegExp | null | undefined; |
{ | ||
"name": "@getlang/lib", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"license": "Apache-2.0", | ||
@@ -33,3 +33,8 @@ "type": "module", | ||
"set-cookie-parser": "^2.6.0" | ||
}, | ||
"devDependencies": { | ||
"@types/esquery": "^1.5.4", | ||
"@types/lodash-es": "^4.17.12", | ||
"@types/set-cookie-parser": "^2.4.9" | ||
} | ||
} |
@@ -22,9 +22,9 @@ import type { ElementType } from 'domelementtype' | ||
export type AnyHtmlNode = dh.AnyNode | Attribute | ||
export type AnyNode = dh.AnyNode | Attribute | ||
export const parse = (html: string): AnyHtmlNode => { | ||
export const parse = (html: string): AnyNode => { | ||
return parse5(html, { treeAdapter: adapter }) | ||
} | ||
const selectXpath = (el: AnyHtmlNode, selector: string, expand: boolean) => { | ||
const selectXpath = (el: AnyNode, selector: string, expand: boolean) => { | ||
try { | ||
@@ -37,3 +37,3 @@ const parseXpath = new xpath.XPathParser() | ||
let root: AnyHtmlNode = el | ||
let root: AnyNode = el | ||
if (el.nodeType === 9) { | ||
@@ -53,3 +53,3 @@ // Document -> HtmlElement | ||
const selectCss = (el: AnyHtmlNode, selector: string, expand: boolean) => { | ||
const selectCss = (el: AnyNode, selector: string, expand: boolean) => { | ||
try { | ||
@@ -67,3 +67,3 @@ parseCss(selector) | ||
export const select = (el: AnyHtmlNode, selector: string, expand: boolean) => { | ||
export const select = (el: AnyNode, selector: string, expand: boolean) => { | ||
return selector.startsWith('xpath:') | ||
@@ -74,3 +74,3 @@ ? selectXpath(el, selector.slice(6), expand) | ||
export const toValue = (el: AnyHtmlNode) => { | ||
export const toValue = (el: AnyNode) => { | ||
let str = '' | ||
@@ -77,0 +77,0 @@ if (el.nodeType === 2) { |
@@ -12,3 +12,3 @@ import { parse as acorn } from 'acorn' | ||
try { | ||
const matches = esquery(node, selector) | ||
const matches = esquery(node as any, selector) | ||
if (expand) { | ||
@@ -15,0 +15,0 @@ return matches |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34188
3
634