Astro+Directus(Visual-Editing)+Snipcart Test-Stack
This commit is contained in:
commit
1459e99cb0
10119 files changed
+1499318
No files matched your search
+87
@@ -0,0 +1,87 @@
|
||||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
type Node$1 = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
|
||||
export type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
|
||||
interface Location$1 {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: NodeType;
|
||||
loc: [
|
||||
Location$1,
|
||||
Location$1
|
||||
];
|
||||
parent: Node$1;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface LiteralNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface ParentNode$1 extends BaseNode {
|
||||
children: Node$1[];
|
||||
}
|
||||
export interface DocumentNode extends Omit<ParentNode$1, "parent"> {
|
||||
type: typeof DOCUMENT_NODE;
|
||||
attributes: Record<string, string>;
|
||||
parent: undefined;
|
||||
}
|
||||
export interface ElementNode extends ParentNode$1 {
|
||||
type: typeof ELEMENT_NODE;
|
||||
name: string;
|
||||
attributes: Record<string, string>;
|
||||
}
|
||||
export interface TextNode extends LiteralNode {
|
||||
type: typeof TEXT_NODE;
|
||||
}
|
||||
export interface CommentNode extends LiteralNode {
|
||||
type: typeof COMMENT_NODE;
|
||||
}
|
||||
export interface DoctypeNode extends LiteralNode {
|
||||
type: typeof DOCTYPE_NODE;
|
||||
}
|
||||
export declare const DOCUMENT_NODE = 0;
|
||||
export declare const ELEMENT_NODE = 1;
|
||||
export declare const TEXT_NODE = 2;
|
||||
export declare const COMMENT_NODE = 3;
|
||||
export declare const DOCTYPE_NODE = 4;
|
||||
export declare function h(type: any, props?: null | Record<string, any>, ...children: any[]): ElementNode;
|
||||
export declare const Fragment: unique symbol;
|
||||
export declare function parse(input: string | ReturnType<typeof html>): any;
|
||||
export interface Visitor {
|
||||
(node: Node$1, parent?: Node$1, index?: number): void | Promise<void>;
|
||||
}
|
||||
export interface VisitorSync {
|
||||
(node: Node$1, parent?: Node$1, index?: number): void;
|
||||
}
|
||||
export declare const RenderFn: unique symbol;
|
||||
export declare function __unsafeHTML(str: string): {
|
||||
value: string;
|
||||
};
|
||||
export declare function __unsafeRenderFn(node: ElementNode, fn: (props: Record<string, any>, ...children: Node$1[]) => Node$1): ElementNode;
|
||||
export declare function attrs(attributes: Record<string, string>): {
|
||||
value: string;
|
||||
};
|
||||
export declare function html(tmpl: TemplateStringsArray, ...vals: any[]): {
|
||||
value: string;
|
||||
};
|
||||
export declare function walk(node: Node$1, callback: Visitor): Promise<void>;
|
||||
export declare function walkSync(node: Node$1, callback: VisitorSync): void;
|
||||
export declare function renderSync(node: Node$1): string;
|
||||
export declare function render(node: Node$1): Promise<string>;
|
||||
interface Transformer$1 {
|
||||
(node: Node$1): Node$1 | Promise<Node$1>;
|
||||
}
|
||||
export interface TransformerSync {
|
||||
(node: Node$1): Node$1;
|
||||
}
|
||||
export declare function transform(markup: string | Node$1, transformers?: Transformer$1[]): Promise<string>;
|
||||
export declare function transformSync(markup: string | Node$1, transformers?: TransformerSync[]): string;
|
||||
|
||||
export {
|
||||
Location$1 as Location,
|
||||
Node$1 as Node,
|
||||
Transformer$1 as Transformer,
|
||||
};
|
||||
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
var R=0,j=1,X=2,V=3,Y=4;function F(e,t={},...i){let r={type:1,name:typeof e=="function"?e.name:e,attributes:t||{},children:i.map(n=>typeof n=="string"?{type:2,value:y(String(n))}:n),parent:void 0,loc:[]};return typeof e=="function"&&$(r,e),r}var S=Symbol("Fragment"),D=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),x=new Set(["script","style"]),o=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm,b=/[\@\.a-z0-9_\:\-]/i;function I(e){let t={};if(e){let i="none",r,n="",a,l;for(let c=0;c<e.length;c++){let d=e[c];i==="none"?b.test(d)?(r&&(t[r]=n,r=void 0,n=""),a=c,i="key"):d==="="&&r&&(i="value"):i==="key"?b.test(d)||(r=e.substring(a,c),d==="="?i="value":i="none"):d===l&&c>0&&e[c-1]!=="\\"?l&&(n=e.substring(a,c),l=void 0,i="none"):(d==='"'||d==="'")&&!l&&(a=c+1,l=d)}i==="key"&&a!=null&&a<e.length&&(r=e.substring(a,e.length)),r&&(t[r]=n)}return t}function P(e){let t=typeof e=="string"?e:e.value,i,r,n,a,l,c,d,m,s,u=[];o.lastIndex=0,r=i={type:0,children:[]};let g=0;function h(){a=t.substring(g,o.lastIndex-n[0].length),a&&r.children.push({type:2,value:a,parent:r})}for(;n=o.exec(t);){if(c=n[5]||n[8],d=n[6]||n[9],m=n[7]||n[10],x.has(r.name)&&n[2]!==r.name){l=o.lastIndex-n[0].length,r.children.length>0&&(r.children[0].value+=n[0]);continue}else if(c==="<!--"){if(l=o.lastIndex-n[0].length,x.has(r.name))continue;s={type:3,value:d,parent:r,loc:[{start:l,end:l+c.length},{start:o.lastIndex-m.length,end:o.lastIndex}]},u.push(s),s.parent.children.push(s)}else if(c==="<!")l=o.lastIndex-n[0].length,s={type:4,value:d,parent:r,loc:[{start:l,end:l+c.length},{start:o.lastIndex-m.length,end:o.lastIndex}]},u.push(s),s.parent.children.push(s);else if(n[1]!=="/")if(h(),x.has(r.name)){g=o.lastIndex,h();continue}else s={type:1,name:n[2]+"",attributes:I(n[3]),parent:r,children:[],loc:[{start:o.lastIndex-n[0].length,end:o.lastIndex}]},u.push(s),s.parent.children.push(s),n[4]&&n[4].indexOf("/")>-1||D.has(s.name)?(s.loc[1]=s.loc[0],s.isSelfClosingTag=!0):r=s;else h(),n[2]+""===r.name?(s=r,r=s.parent,s.loc.push({start:o.lastIndex-n[0].length,end:o.lastIndex}),a=t.substring(s.loc[0].end,s.loc[1].start),s.children.length===0&&s.children.push({type:2,value:a,parent:r})):n[2]+""===u[u.length-1].name&&u[u.length-1].isSelfClosingTag===!0&&(s=u[u.length-1],s.loc.push({start:o.lastIndex-n[0].length,end:o.lastIndex}));g=o.lastIndex}return a=t.slice(g),r.children.push({type:2,value:a,parent:r}),i}var T=class{constructor(t){this.callback=t}async visit(t,i,r){if(await this.callback(t,i,r),Array.isArray(t.children)){let n=[];for(let a=0;a<t.children.length;a++){let l=t.children[a];n.push(this.visit(l,t,a))}await Promise.all(n)}}},O=class{constructor(t){this.callback=t}visit(t,i,r){if(this.callback(t,i,r),Array.isArray(t.children))for(let n=0;n<t.children.length;n++){let a=t.children[n];this.visit(a,t,n)}}},p=Symbol("HTMLString"),M=Symbol("AttrString"),f=Symbol("RenderFn");function E(e,t=[p]){let i={value:e};for(let r of t)Object.defineProperty(i,r,{value:!0,enumerable:!1,writable:!1});return i}function U(e){return E(e)}function $(e,t){return Object.defineProperty(e,f,{value:t,enumerable:!1}),e}var A={"&":"&","<":"<",">":">"};function y(e){return e.replace(/[&<>]/g,t=>A[t]||t)}function N(e){let t="";for(let[i,r]of Object.entries(e))t+=` ${i}="${r}"`;return E(t,[p,M])}function H(e,...t){let i="";for(let r=0;r<e.length;r++){i+=e[r];let n=t[r];i.endsWith("...")&&n&&typeof n=="object"?(i=i.slice(0,-3).trimEnd(),i+=N(n).value):n&&n[M]?(i=i.trimEnd(),i+=n.value):n&&n[p]?i+=n.value:typeof n=="string"?i+=y(n):(n||n===0)&&(i+=String(n))}return E(i)}function z(e,t){return new T(t).visit(e)}function B(e,t){return new O(t).visit(e)}function C(e){if(e.children.length===0){let t=e;for(;t=t.parent;)if(t.name==="svg")return!0}return!1}async function k(e){let{name:t,attributes:i={}}=e,r=await Promise.all(e.children.map(a=>_(a))).then(a=>a.join(""));if(f in e){let a=await e[f](i,E(r));return a&&a[p]?a.value:y(String(a))}if(t===S)return r;let n=C(e);return n||D.has(t)?`<${e.name}${N(i).value}${n?" /":""}>`:`<${e.name}${N(i).value}>${r}</${e.name}>`}function L(e){let{name:t,attributes:i={}}=e,r=e.children.map(a=>v(a)).join("");if(f in e){let a=e[f](i,E(r));return a&&a[p]?a.value:y(String(a))}if(t===S)return r;let n=C(e);return n||D.has(t)?`<${e.name}${N(i).value}${n?" /":""}>`:`<${e.name}${N(i).value}>${r}</${e.name}>`}function v(e){switch(e.type){case 0:return e.children.map(t=>v(t)).join("");case 1:return L(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}async function _(e){switch(e.type){case 0:return Promise.all(e.children.map(t=>_(t))).then(t=>t.join(""));case 1:return k(e);case 2:return`${e.value}`;case 3:return`<!--${e.value}-->`;case 4:return`<!${e.value}>`}}function w(e,t){if(!Array.isArray(t))throw new Error(`Invalid second argument for \`transform\`! Expected \`Transformer[]\` but
Line truncated
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/index.ts"],
|
||||
"sourcesContent": ["export type Node =\n\t| DocumentNode\n\t| ElementNode\n\t| TextNode\n\t| CommentNode\n\t| DoctypeNode;\nexport type NodeType =\n\t| typeof DOCUMENT_NODE\n\t| typeof ELEMENT_NODE\n\t| typeof TEXT_NODE\n\t| typeof COMMENT_NODE\n\t| typeof DOCTYPE_NODE;\nexport interface Location {\n\tstart: number;\n\tend: number;\n}\ninterface BaseNode {\n\ttype: NodeType;\n\tloc: [Location, Location];\n\tparent: Node;\n\t[key: string]: any;\n}\n\ninterface LiteralNode extends BaseNode {\n\tvalue: string;\n}\n\ninterface ParentNode extends BaseNode {\n\tchildren: Node[];\n}\n\nexport interface DocumentNode extends Omit<ParentNode, 'parent'> {\n\ttype: typeof DOCUMENT_NODE;\n\tattributes: Record<string, string>;\n\tparent: undefined;\n}\n\nexport interface ElementNode extends ParentNode {\n\ttype: typeof ELEMENT_NODE;\n\tname: string;\n\tattributes: Record<string, string>;\n}\n\nexport interface TextNode extends LiteralNode {\n\ttype: typeof TEXT_NODE;\n}\n\nexport interface CommentNode extends LiteralNode {\n\ttype: typeof COMMENT_NODE;\n}\n\nexport interface DoctypeNode extends LiteralNode {\n\ttype: typeof DOCTYPE_NODE;\n}\n\nexport const DOCUMENT_NODE = 0;\nexport const ELEMENT_NODE = 1;\nexport const TEXT_NODE = 2;\nexport const COMMENT_NODE = 3;\nexport const DOCTYPE_NODE = 4;\n\nexport function h(\n\ttype: any,\n\tprops: null | Record<string, any> = {},\n\t...children: any[]\n) {\n\tconst vnode: ElementNode = {\n\t\ttype: ELEMENT_NODE,\n\t\tname: typeof type === 'function' ? type.name : type,\n\t\tattributes: props || {},\n\t\tchildren: children.map((child) =>\n\t\t\ttypeof child === 'string'\n\t\t\t\t? { type: TEXT_NODE, value: escapeHTML(String(child)) }\n\t\t\t\t: child,\n\t\t),\n\t\tparent: undefined as any,\n\t\tloc: [] as any,\n\t};\n\tif (typeof type === 'function') {\n\t\t__unsafeRenderFn(vnode, type);\n\t}\n\treturn vnode;\n}\nexport const Fragment = Symbol('Fragment');\n\nconst VOID_TAGS = new Set<string>([\n\t'area',\n\t'base',\n\t'br',\n\t'col',\n\t'embed',\n\t'hr',\n\t'img',\n\t'input',\n\t'keygen',\n\t'link',\n\t'meta',\n\t'param',\n\t'source',\n\t'track',\n\t'wbr',\n]);\nconst RAW_TAGS = new Set<string>(['script', 'style']);\nconst DOM_PARSER_RE =\n\t/(?:<(\\/?)([a-zA-Z][a-zA-Z0-9\\:-]*)(?:\\s([^>]*?))?((?:\\s*\\/)?)>|(<\\!\\-\\-)([\\s\\S]*?)(\\-\\->)|(<\\!)([\\s\\S]*?)(>))/gm;\n\nconst ATTR_KEY_IDENTIFIER = /[\\@\\.a-z0-9_\\:\\-]/i;\n\nfunction splitAttrs(str?: string) {\n\tlet obj: Record<string, string> = {};\n\tif (str) {\n\t\tlet state: 'none' | 'key' | 'value' = 'none';\n\t\tlet currentKey: string | undefined;\n\t\tlet currentValue: string = '';\n\t\tlet tokenStartIndex: number | undefined;\n\t\tlet valueDelimiter: '\"' | \"'\" | undefined;\n\t\tfor (let currentIndex = 0; currentIndex < str.length; currentIndex++) {\n\t\t\tconst currentChar = str[currentIndex];\n\n\t\t\tif (state === 'none') {\n\t\t\t\tif (ATTR_KEY_IDENTIFIER.test(currentChar)) {\n\t\t\t\t\t// add attribute\n\t\t\t\t\tif (currentKey) {\n\t\t\t\t\t\tobj[currentKey] = currentValue;\n\t\t\t\t\t\tcurrentKey = undefined;\n\t\t\t\t\t\tcurrentValue = '';\n\t\t\t\t\t}\n\n\t\t\t\t\ttokenStartIndex = currentIndex;\n\t\t\t\t\tstate = 'key';\n\t\t\t\t} else if (currentChar === '=' && currentKey) {\n\t\t\t\t\tstate = 'value';\n\t\t\t\t}\n\t\t\t} else if (state === 'key') {\n\t\t\t\tif (!ATTR_KEY_IDENTIFIER.test(currentChar)) {\n\t\t\t\t\tcurrentKey = str.substring(tokenStartIndex!, currentIndex);\n\t\t\t\t\tif (currentChar === '=') {\n\t\t\t\t\t\tstate = 'value';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstate = 'none';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tif (\n\t\t\t\t\tcurrentChar === valueDelimiter &&\n\t\t\t\t\tcurrentIndex > 0 &&\n\t\t\t\t\tstr[currentIndex - 1] !== '\\\\'\n\t\t\t\t) {\n\t\t\t\t\tif (valueDelimiter) {\n\t\t\t\t\t\tcurrentValue = str.substring(tokenStartIndex!, currentIndex);\n\t\t\t\t\t\tvalueDelimiter = undefined;\n\t\t\t\t\t\tstate = 'none';\n\t\t\t\t\t}\n\t\t\t\t} else if (\n\t\t\t\t\t(currentChar === '\"' || currentChar === \"'\") &&\n\t\t\t\t\t!valueDelimiter\n\t\t\t\t) {\n\t\t\t\t\ttokenStartIndex = currentIndex + 1;\n\t\t\t\t\tvalueDelimiter = currentChar;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif (\n\t\t\tstate === 'key' &&\n\t\t\ttokenStartIndex != undefined &&\n\t\t\ttokenStartIndex < str.length\n\t\t) {\n\t\t\tcurrentKey = str.substring(tokenStartIndex, str.length);\n\t\t}\n\t\tif (currentKey) {\n\t\t\tobj[currentKey] = currentValue;\n\t\t}\n\t}\n\treturn obj;\n}\n\nexport function parse(input: string | ReturnType<typeof html>): any {\n\tlet str = typeof input === 'string' ? input : input.value;\n\tlet doc: Node,\n\t\tparent: Node,\n\t\ttoken: any,\n\t\ttext,\n\t\ti,\n\t\tbStart,\n\t\tbText,\n\t\tbEnd,\n\t\ttag: Node;\n\tconst tags: Node[] = [];\n\tDOM_PARSER_RE.lastIndex = 0;\n\tparent = doc = {\n\t\ttype: DOCUMENT_NODE,\n\t\tchildren: [] as Node[],\n\t} as any;\n\n\tlet lastIndex = 0;\n\tfunction commitTextNode() {\n\t\ttext = str.substring(lastIndex, DOM_PARSER_RE.lastIndex - token[0].lengLine truncated
|
||||
"mappings": "AAuDO,IAAMA,EAAgB,EAChBC,EAAe,EACfC,EAAY,EACZC,EAAe,EACfC,EAAe,EAErB,SAASC,EACfC,EACAC,EAAoC,CAAC,KAClCC,EACF,CACD,IAAMC,EAAqB,CAC1B,KAAM,EACN,KAAM,OAAOH,GAAS,WAAaA,EAAK,KAAOA,EAC/C,WAAYC,GAAS,CAAC,EACtB,SAAUC,EAAS,IAAKE,GACvB,OAAOA,GAAU,SACd,CAAE,KAAM,EAAW,MAAOC,EAAW,OAAOD,CAAK,CAAC,CAAE,EACpDA,CACJ,EACA,OAAQ,OACR,IAAK,CAAC,CACP,EACA,OAAI,OAAOJ,GAAS,YACnBM,EAAiBH,EAAOH,CAAI,EAEtBG,CACR,CACO,IAAMI,EAAW,OAAO,UAAU,EAEnCC,EAAY,IAAI,IAAY,CACjC,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,SACA,OACA,OACA,QACA,SACA,QACA,KACD,CAAC,EACKC,EAAW,IA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ACR,CAEO,SAASC,EAAalC,EAAa,CACzC,OAAOgC,EAAKhC,CAAG,CAChB,CACO,SAASP,EACfgC,EACAU,EACC,CACD,cAAO,eAAeV,EAAMM,EAAU,CACrC,MAAOI,EACP,WAAY,EACb,CAAC,EACMV,CACR,CAEA,IAAMW,EAAuC,CAC5C,IAAK,QACL,IAAK,OACLine truncated
|
||||
"names": ["DOCUMENT_NODE", "ELEMENT_NODE", "TEXT_NODE", "COMMENT_NODE", "DOCTYPE_NODE", "h", "type", "props", "children", "vnode", "child", "escapeHTML", "__unsafeRenderFn", "Fragment", "VOID_TAGS", "RAW_TAGS", "DOM_PARSER_RE", "ATTR_KEY_IDENTIFIER", "splitAttrs", "str", "obj", "state", "currentKey", "currentValue", "tokenStartIndex", "valueDelimiter", "currentIndex", "currentChar", "parse", "input", "doc", "parent", "token", "text", "i", "bStart", "bText", "bEnd", "tag", "tags", "lastIndex", "commitTextNode", "Walker", "callback", "node", "index", "promises", "WalkerSync", "HTMLString", "AttrString", "RenderFn", "mark", "v", "__unsafeHTML", "fn", "ESCAPE_CHARS", "c", "attrs", "attributes", "attrStr", "key", "value", "html", "tmpl", "vals", "buf", "expr", "walk", "walkSync", "canSelfClose", "n", "renderElement", "name", "render", "res", "isSelfClosing", "renderElementSync", "renderSync", "parseTransformArgs", "markup", "transformers", "transform", "newDoc", "t", "transformSync"]
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
type Node$1 = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
|
||||
type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
|
||||
interface Location$1 {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: NodeType;
|
||||
loc: [
|
||||
Location$1,
|
||||
Location$1
|
||||
];
|
||||
parent: Node$1;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface LiteralNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface ParentNode$1 extends BaseNode {
|
||||
children: Node$1[];
|
||||
}
|
||||
interface DocumentNode extends Omit<ParentNode$1, "parent"> {
|
||||
type: typeof DOCUMENT_NODE;
|
||||
attributes: Record<string, string>;
|
||||
parent: undefined;
|
||||
}
|
||||
interface ElementNode extends ParentNode$1 {
|
||||
type: typeof ELEMENT_NODE;
|
||||
name: string;
|
||||
attributes: Record<string, string>;
|
||||
}
|
||||
interface TextNode extends LiteralNode {
|
||||
type: typeof TEXT_NODE;
|
||||
}
|
||||
interface CommentNode extends LiteralNode {
|
||||
type: typeof COMMENT_NODE;
|
||||
}
|
||||
interface DoctypeNode extends LiteralNode {
|
||||
type: typeof DOCTYPE_NODE;
|
||||
}
|
||||
declare const DOCUMENT_NODE = 0;
|
||||
declare const ELEMENT_NODE = 1;
|
||||
declare const TEXT_NODE = 2;
|
||||
declare const COMMENT_NODE = 3;
|
||||
declare const DOCTYPE_NODE = 4;
|
||||
export declare const Fragment: unique symbol;
|
||||
declare function createVNode(type: any, { children, ...attributes }: Record<string, any>, key: string, __self: string, __source: string): ElementNode;
|
||||
|
||||
export {
|
||||
createVNode as jsx,
|
||||
createVNode as jsxDEV,
|
||||
createVNode as jsxs,
|
||||
};
|
||||
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{TEXT_NODE as a}from"../index.js";import{ELEMENT_NODE as s,Fragment as d,__unsafeRenderFn as f}from"../index.js";function g(n,{children:e,...o},i,m,u){let t={type:s,name:typeof n=="function"?n.name:n,attributes:o,children:(Array.isArray(e)?e:[e]).map(r=>typeof r=="string"?{type:a,value:r}:r),parent:void 0,loc:[]};return typeof n=="function"&&f(t,n),t}export{d as Fragment,g as jsx,g as jsxDEV,g as jsxs};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../src/jsx-runtime/index.ts"],
|
||||
"sourcesContent": ["import { ElementNode, Node, TEXT_NODE } from '../index.js';\nimport { ELEMENT_NODE, Fragment, __unsafeRenderFn } from '../index.js';\n\nfunction createVNode(\n\ttype: any,\n\t{ children, ...attributes }: Record<string, any>,\n\tkey: string,\n\t__self: string,\n\t__source: string,\n) {\n\tconst vnode: ElementNode = {\n\t\ttype: ELEMENT_NODE,\n\t\tname: typeof type === 'function' ? type.name : type,\n\t\tattributes,\n\t\tchildren: (Array.isArray(children) ? children : [children]).map((child) => {\n\t\t\tif (typeof child === 'string') {\n\t\t\t\treturn {\n\t\t\t\t\ttype: TEXT_NODE,\n\t\t\t\t\tvalue: child,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn child;\n\t\t}),\n\t\tparent: undefined as any,\n\t\tloc: [] as any,\n\t};\n\n\tif (typeof type === 'function') {\n\t\t__unsafeRenderFn(vnode, type);\n\t}\n\n\treturn vnode;\n}\n\nexport {\n\tcreateVNode as jsx,\n\tcreateVNode as jsxs,\n\tcreateVNode as jsxDEV,\n\tFragment,\n};\n"],
|
||||
"mappings": "AAAA,OAA4B,aAAAA,MAAiB,cAC7C,OAAS,gBAAAC,EAAc,YAAAC,EAAU,oBAAAC,MAAwB,cAEzD,SAASC,EACRC,EACA,CAAE,SAAAC,EAAU,GAAGC,CAAW,EAC1BC,EACAC,EACAC,EACC,CACD,IAAMC,EAAqB,CAC1B,KAAMV,EACN,KAAM,OAAOI,GAAS,WAAaA,EAAK,KAAOA,EAC/C,WAAAE,EACA,UAAW,MAAM,QAAQD,CAAQ,EAAIA,EAAW,CAACA,CAAQ,GAAG,IAAKM,GAC5D,OAAOA,GAAU,SACb,CACN,KAAMZ,EACN,MAAOY,CACR,EAEMA,CACP,EACD,OAAQ,OACR,IAAK,CAAC,CACP,EAEA,OAAI,OAAOP,GAAS,YACnBF,EAAiBQ,EAAON,CAAI,EAGtBM,CACR",
|
||||
"names": ["TEXT_NODE", "ELEMENT_NODE", "Fragment", "__unsafeRenderFn", "createVNode", "type", "children", "attributes", "key", "__self", "__source", "vnode", "child"]
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
type Node$1 = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
|
||||
type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
|
||||
interface Location$1 {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: NodeType;
|
||||
loc: [
|
||||
Location$1,
|
||||
Location$1
|
||||
];
|
||||
parent: Node$1;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface LiteralNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface ParentNode$1 extends BaseNode {
|
||||
children: Node$1[];
|
||||
}
|
||||
interface DocumentNode extends Omit<ParentNode$1, "parent"> {
|
||||
type: typeof DOCUMENT_NODE;
|
||||
attributes: Record<string, string>;
|
||||
parent: undefined;
|
||||
}
|
||||
interface ElementNode extends ParentNode$1 {
|
||||
type: typeof ELEMENT_NODE;
|
||||
name: string;
|
||||
attributes: Record<string, string>;
|
||||
}
|
||||
interface TextNode extends LiteralNode {
|
||||
type: typeof TEXT_NODE;
|
||||
}
|
||||
interface CommentNode extends LiteralNode {
|
||||
type: typeof COMMENT_NODE;
|
||||
}
|
||||
interface DoctypeNode extends LiteralNode {
|
||||
type: typeof DOCTYPE_NODE;
|
||||
}
|
||||
declare const DOCUMENT_NODE = 0;
|
||||
declare const ELEMENT_NODE = 1;
|
||||
declare const TEXT_NODE = 2;
|
||||
declare const COMMENT_NODE = 3;
|
||||
declare const DOCTYPE_NODE = 4;
|
||||
export declare function specificity(selector: string): number;
|
||||
export declare function matches(node: Node$1, selector: string): boolean;
|
||||
export declare function querySelector(node: Node$1, selector: string): Node$1;
|
||||
export declare function querySelectorAll(node: Node$1, selector: string): Node$1[];
|
||||
|
||||
export {
|
||||
querySelectorAll as default,
|
||||
};
|
||||
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{ELEMENT_NODE as f,TEXT_NODE as _,walkSync as j}from"./index.js";var w={attribute:/\[\s*(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?(?<name>[-\w\P{ASCII}]+)\s*(?:(?<operator>\W?=)\s*(?<value>.+?)\s*(\s(?<caseSensitive>[iIsS]))?\s*)?\]/gu,id:/#(?<name>[-\w\P{ASCII}]+)/gu,class:/\.(?<name>[-\w\P{ASCII}]+)/gu,comma:/\s*,\s*/g,combinator:/\s*[\s>+~]\s*/g,"pseudo-element":/::(?<name>[-\w\P{ASCII}]+)(?:\((?<argument>¶*)\))?/gu,"pseudo-class":/:(?<name>[-\w\P{ASCII}]+)(?:\((?<argument>¶*)\))?/gu,universal:/(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?\*/gu,type:/(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?(?<name>[-\w\P{ASCII}]+)/gu},v=new Set(["combinator","comma"]),A=new Set(["not","is","where","has","matches","-moz-any","-webkit-any","nth-child","nth-last-child"]),E=/(?<index>[\dn+-]+)\s+of\s+(?<subtree>.+)/,k={"nth-child":E,"nth-last-child":E},T=t=>{switch(t){case"pseudo-element":case"pseudo-class":return new RegExp(w[t].source.replace("(?<argument>\xB6*)","(?<argument>.*)"),"gu");default:return w[t]}};function M(t,n){let e=0,r="";for(;n<t.length;n++){let s=t[n];switch(s){case"(":++e;break;case")":--e}if(r+=s,e===0)return r}return r}function O(t,n=w){if(!t)return[];let e=[t];for(let[s,o]of Object.entries(n))for(let i=0;i<e.length;i++){let c=e[i];if(typeof c!="string")continue;o.lastIndex=0;let a=o.exec(c);if(!a)continue;let u=a.index-1,l=[],h=a[0],m=c.slice(0,u+1);m&&l.push(m),l.push({...a.groups,type:s,content:h});let y=c.slice(u+h.length+1);y&&l.push(y),e.splice(i,1,...l)}let r=0;for(let s of e)switch(typeof s){case"string":throw new Error(`Unexpected sequence ${s} found at index ${r}`);case"object":r+=s.content.length,s.pos=[r-s.content.length,r],v.has(s.type)&&(s.content=s.content.trim()||" ")}return e}var $=/(['"])([^\\\n]+?)\1/g,P=/\\./g;function U(t,n=w){if((t=t.trim())==="")return[];let e=[];t=(t=t.replace(P,(o,i)=>(e.push({value:o,offset:i}),"\uE000".repeat(o.length)))).replace($,(o,i,c,a)=>(e.push({value:o,offset:a}),`${i}${"\uE001".repeat(c.length)}${i}`));{let o,i=0;for(;(o=t.indexOf("(",i))>-1;){let c=M(t,o);e.push({value:c,offset:o}),t=`${t.substring(0,o)}(${"\xB6".repeat(c.length-2)})${t.substring(o+c.length)}`,i=o+c.length}}let r=O(t,n),s=new Set;for(let o of e.reverse())for(let i of r){let{offset:c,value:a}=o;if(!(i.pos[0]<=c&&c+a.length<=i.pos[1]))continue;let{content:u}=i,l=c-i.pos[0];i.content=u.slice(0,l)+a+u.slice(l+a.length),i.content!==u&&s.add(i)}for(let o of s){let i=T(o.type);if(!i)throw new Error(`Unknown token type: ${o.type}`);i.lastIndex=0;let c=i.exec(o.content);if(!c)throw new Error(`Unable to parse content for ${o.type}: ${o.content}`);Object.assign(o,c.groups)}return r}function g(t,{list:n=!0}={}){if(n&&t.find(e=>e.type==="comma")){let e=[],r=[];for(let s=0;s<t.length;s++)if(t[s].type==="comma"){if(r.length===0)throw new Error("Incorrect comma at "+s);e.push(g(r,{list:!1})),r.length=0}else r.push(t[s]);if(r.length===0)throw new Error("Trailing comma");return e.push(g(r,{list:!1})),{type:"list",list:e}}for(let e=t.length-1;e>=0;e--){let r=t[e];if(r.type==="combinator"){let s=t.slice(0,e),o=t.slice(e+1);return{type:"complex",combinator:r.content,left:g(s),right:g(o)}}}switch(t.length){case 0:throw new Error("Could not build AST.");case 1:return t[0];default:return{type:"compound",list:[...t]}}}function*p(t,n){switch(t.type){case"list":for(let e of t.list)yield*p(e,t);break;case"complex":yield*p(t.left,t),yield*p(t.right,t);break;case"compound":yield*t.list.map(e=>[e,t]);break;default:yield[t,n]}}function b(t,{recursive:n=!0,list:e=!0}={}){let r=U(t);if(!r)return;let s=g(r,{list:e});if(!n)return s;for(let[o]of p(s)){if(o.type!=="pseudo-class"||!o.argument||!A.has(o.name))continue;let i=o.argument,c=k[o.name];if(c){let a=c.exec(i);if(!a)continue;Object.assign(o,a.groups),i=a.groups.subtree}i&&Object.assign(o,{subtree:b(i,{recursive:!0,list:!0})})}return s}function x(t,n){return n=n||Math.max(...t)+1,t[0]*(n<<1)+t[1]*n+t[2]}function N(t){let n=t;if(typeof n=="string"&&(n=b(n,{recursive:!0})),!n)return[];if(n.type==="list"&&"list"in n){let r=10,s=n.list.map(i=>{let c=N(i);return r=Math.max(r,...N(i)),c}),o=s.map(i=>x(i,r));return s[o.indexOf(Math.max(...o))]}let e=[0,0,0];for(let[r]of p(n))switch(r.type){case"id":e[0]++;break;case"class":case"attribute":e[1]++;break;case"pseudo-element":case"type":e[2]++;break;case"pseudo-class":if(r.name==="where")break;if(!A.has(r.name)||!r.subtree){e[1]++;break}N(r.subtree).forEach((s,o)=>e[o]+=s),r.name!=="nth-child"&&r.name!=="nth-last-child"||e[1]++}return e}function G(t){return x(N(t),10)}function J(t,n){return d(n)(t,t.parent,I(t,t.parent))}function X(t,n){let e=d(n);try{return C(t,(r,s,o)=>{let i=e(r,s,o);return i||!1},{single:!0})[0]}catch(r){if(r instanceof Error)throw r;return r}}function R(t,n){let e=d(n);return C(t,(r,s,o)=>{let i=e(r,s,o);return i||!1})}var F=R;function C(t,n,e={single:!1}){let r=[];return j(t,(s,o,i)=>{if(!(s&&s.type!==f)&&n(s,o,i)){if(e.single)throw s;r.push(s)}}),r}var L=t=>{let{operator:n="="}=t;switch(n){case"=":returnLine truncated
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../src/selector.ts", "../node_modules/.pnpm/parsel-js@1.1.2/node_modules/parsel-js/dist/parsel.min.js"],
|
||||
"sourcesContent": ["import type { Node } from './index.js';\nimport { ELEMENT_NODE, TEXT_NODE, walkSync } from './index.js';\nimport type { AST, AttributeToken } from 'parsel-js';\nimport {\n\tparse,\n\tspecificity as getSpecificity,\n\tspecificityToNumber,\n} from 'parsel-js';\n\nexport function specificity(selector: string) {\n\treturn specificityToNumber(getSpecificity(selector), 10);\n}\n\nexport function matches(node: Node, selector: string): boolean {\n\tconst match = selectorToMatch(selector);\n\treturn match(node, node.parent, nthChildIndex(node, node.parent));\n}\n\nexport function querySelector(node: Node, selector: string): Node {\n\tconst match = selectorToMatch(selector);\n\ttry {\n\t\treturn select(\n\t\t\tnode,\n\t\t\t(n: Node, parent?: Node, index?: number) => {\n\t\t\t\tlet m = match(n, parent, index);\n\t\t\t\tif (!m) return false;\n\t\t\t\treturn m;\n\t\t\t},\n\t\t\t{ single: true },\n\t\t)[0];\n\t} catch (e) {\n\t\tif (e instanceof Error) {\n\t\t\tthrow e;\n\t\t}\n\t\treturn e as Node;\n\t}\n}\n\nexport function querySelectorAll(node: Node, selector: string): Node[] {\n\tconst match = selectorToMatch(selector);\n\treturn select(node, (n: Node, parent?: Node, index?: number) => {\n\t\tlet m = match(n, parent, index);\n\t\tif (!m) return false;\n\t\treturn m;\n\t});\n}\n\nexport default querySelectorAll;\n\ninterface Matcher {\n\t(n: Node, parent?: Node, index?: number): boolean;\n}\n\nfunction select(\n\tnode: Node,\n\tmatch: Matcher,\n\topts: { single?: boolean } = { single: false },\n): Node[] {\n\tlet nodes: Node[] = [];\n\twalkSync(node, (n, parent, index): void => {\n\t\tif (n && n.type !== ELEMENT_NODE) return;\n\t\tif (match(n, parent, index)) {\n\t\t\tif (opts.single) throw n;\n\t\t\tnodes.push(n);\n\t\t}\n\t});\n\treturn nodes;\n}\n\nconst getAttributeMatch = (selector: AttributeToken) => {\n\tconst { operator = '=' } = selector;\n\tswitch (operator) {\n\t\tcase '=':\n\t\t\treturn (a: string, b: string) => a === b;\n\t\tcase '~=':\n\t\t\treturn (a: string, b: string) => a.split(/\\s+/g).includes(b);\n\t\tcase '|=':\n\t\t\treturn (a: string, b: string) => a.startsWith(b + '-');\n\t\tcase '*=':\n\t\t\treturn (a: string, b: string) => a.indexOf(b) > -1;\n\t\tcase '$=':\n\t\t\treturn (a: string, b: string) => a.endsWith(b);\n\t\tcase '^=':\n\t\t\treturn (a: string, b: string) => a.startsWith(b);\n\t}\n\treturn (a: string, b: string) => false;\n};\n\nconst nthChildIndex = (node: Node, parent?: Node) =>\n\tparent?.children\n\t\t.filter((n: Node) => n.type === ELEMENT_NODE)\n\t\t.findIndex((n: Node) => n === node);\nconst nthChild = (formula: string) => {\n\tlet [_, A = '1', B = '0'] =\n\t\t/^\\s*(?:(-?(?:\\d+)?)n)?\\s*\\+?\\s*(\\d+)?\\s*$/gm.exec(formula) ?? [];\n\tif (A.length === 0) A = '1';\n\tconst a = Number.parseInt(A === '-' ? '-1' : A);\n\tconst b = Number.parseInt(B);\n\treturn (n: number) => a * n + b;\n};\nconst lastChild = (node: Node, parent?: Node) =>\n\tparent?.children.filter((n: Node) => n.type === ELEMENT_NODE).pop() === node;\nconst firstChild = (node: Node, parent?: Node) =>\n\tparent?.children.filter((n: Node) => n.type === ELEMENT_NODE).shift() ===\n\tnode;\nconst onlyChild = (node: Node, parent?: Node) =>\n\tparent?.children.filter((n: Node) => n.type === ELEMENT_NODE).length === 1;\n\nconst createMatch = (selector: AST): Matcher => {\n\tswitch (selector.type) {\n\t\tcase 'type':\n\t\t\treturn (node: Node) => {\n\t\t\t\tif (selector.content === '*') return true;\n\t\t\t\treturn node.name === selector.name;\n\t\t\t};\n\t\tcase 'class':\n\t\t\treturn (node: Node) =>\n\t\t\t\tnode.attributes?.class?.split(/\\s+/g).includes(selector.name);\n\t\tcase 'id':\n\t\t\treturn (node: Node) => node.attributes?.id === selector.name;\n\t\tcase 'pseudo-class': {\n\t\t\tswitch (selector.name) {\n\t\t\t\tcase 'global':\n\t\t\t\t\treturn (...args) =>\n\t\t\t\t\t\tselectorToMatch(parse(selector.argument!)!)(...args);\n\t\t\t\tcase 'not':\n\t\t\t\t\treturn (...args) => !createMatch(selector.subtree!)(...args);\n\t\t\t\tcase 'is':\n\t\t\t\t\treturn (...args) => selectorToMatch(selector.subtree!)(...args);\n\t\t\t\tcase 'where':\n\t\t\t\t\treturn (...args) => selectorToMatch(selector.subtree!)(...args);\n\t\t\t\tcase 'root':\n\t\t\t\t\treturn (node: Node, parent?: Node) =>\n\t\t\t\t\t\tnode.type === ELEMENT_NODE && node.name === 'html';\n\t\t\t\tcase 'empty':\n\t\t\t\t\treturn (node: Node) =>\n\t\t\t\t\t\tnode.type === ELEMENT_NODE &&\n\t\t\t\t\t\t(node.children.length === 0 ||\n\t\t\t\t\t\t\tnode.children.every(\n\t\t\t\t\t\t\t\t(n: Node) => n.type === TEXT_NODE && n.value.trim() === '',\n\t\t\t\t\t\t\t));\n\t\t\t\tcase 'first-child':\n\t\t\t\t\treturn (node: Node, parent?: Node) => firstChild(node, parent);\n\t\t\t\tcase 'last-child':\n\t\t\t\t\treturn (node: Node, parent?: Node) => lastChild(node, parent);\n\t\t\t\tcase 'only-child':\n\t\t\t\t\treturn (node: Node, parent?: Node) => onlyChild(node, parent);\n\t\t\t\tcase 'nth-child':\n\t\t\t\t\treturn (node: Node, parent?: Node) =Line truncated
|
||||
"mappings": "AACA,OAAS,gBAAAA,EAAc,aAAAC,EAAW,YAAAC,MAAgB,aCDlD,IAAMC,EAAE,CAAC,UAAU,uJAAuJ,GAAG,8BAA8B,MAAM,+BAA+B,MAAM,WAAW,WAAW,iBAAiB,iBAAiB,uDAAuD,eAAe,sDAAsD,UAAU,8CAA8C,KAAK,mEAAmE,EAAEC,EAAE,IAAI,IAAI,CAAC,aAAa,OAAO,CAAC,EAAEC,EAAE,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,MAAM,UAAU,WAAW,cAAc,YAAY,gBAAgB,CAAC,EAAEC,EAAE,2CAA2CC,EAAE,CAAC,YAAYD,EAAE,iBAAiBA,CAAC,EAAEE,EAAE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AC,CAAC,EAAE,GAAG,CAACD,EAAE,OAAOG,EAAE,OAAS,CAACJ,CAAC,IAAI,EAAEI,CAAC,EAAE,CAAkD,GAA7BJ,EAAE,OAAnB,gBAAyB,CAACA,EAAE,UAAqB,CAACM,EAAE,IAAIN,EAAE,IAAI,EAAE,SAAS,IAAIC,EAAED,EAAE,SAAeE,EAAEK,EAAEP,EAAE,IAAI,EAAE,GAAGE,EAAE,CAAC,IAAMI,EAAEJ,EAAE,KAAKD,CAAC,EAAE,GAAG,CAACK,EAAE,SAAS,OAAO,OAAON,EAAEM,EAAE,MAAM,EAAEL,EAAEK,EAAE,OAAO,OAAO,CAACL,GAAG,OAAO,OAAOD,EAAE,CAAC,QAAQD,EAAEE,EAAE,CAAC,UAAU,GAAG,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAOG,CAAC,CAA0G,SAASI,EAAEC,EAAEC,EAAE,CAAC,OAAOA,EAAEA,GAAG,KAAK,IAAI,GAAGD,CAAC,ELine truncated
|
||||
"names": ["ELEMENT_NODE", "TEXT_NODE", "walkSync", "e", "t", "n", "s", "o", "r", "c", "i", "a", "l", "u", "f", "m", "e", "t", "s", "u", "c", "f", "n", "o", "d", "e", "t", "w", "m", "n", "s", "specificity", "selector", "d", "w", "matches", "node", "selectorToMatch", "nthChildIndex", "querySelector", "match", "select", "n", "parent", "index", "m", "e", "querySelectorAll", "selector_default", "opts", "nodes", "walkSync", "ELEMENT_NODE", "getAttributeMatch", "operator", "a", "b", "nthChild", "formula", "_", "A", "B", "lastChild", "firstChild", "onlyChild", "createMatch", "_a", "_b", "args", "TEXT_NODE", "target", "nth", "elements", "childIndex", "i", "caseSensitive", "name", "value", "attrs", "attr", "attrVal", "sel", "matchers", "s", "left", "right", "combinator", "matchLeft", "matchRight", "leftMatches", "sibling", "prevSiblings", "el", "prev"]
|
||||
}
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
type Node$1 = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
|
||||
type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
|
||||
interface Location$1 {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: NodeType;
|
||||
loc: [
|
||||
Location$1,
|
||||
Location$1
|
||||
];
|
||||
parent: Node$1;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface LiteralNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface ParentNode$1 extends BaseNode {
|
||||
children: Node$1[];
|
||||
}
|
||||
interface DocumentNode extends Omit<ParentNode$1, "parent"> {
|
||||
type: typeof DOCUMENT_NODE;
|
||||
attributes: Record<string, string>;
|
||||
parent: undefined;
|
||||
}
|
||||
interface ElementNode extends ParentNode$1 {
|
||||
type: typeof ELEMENT_NODE;
|
||||
name: string;
|
||||
attributes: Record<string, string>;
|
||||
}
|
||||
interface TextNode extends LiteralNode {
|
||||
type: typeof TEXT_NODE;
|
||||
}
|
||||
interface CommentNode extends LiteralNode {
|
||||
type: typeof COMMENT_NODE;
|
||||
}
|
||||
interface DoctypeNode extends LiteralNode {
|
||||
type: typeof DOCTYPE_NODE;
|
||||
}
|
||||
declare const DOCUMENT_NODE = 0;
|
||||
declare const ELEMENT_NODE = 1;
|
||||
declare const TEXT_NODE = 2;
|
||||
declare const COMMENT_NODE = 3;
|
||||
declare const DOCTYPE_NODE = 4;
|
||||
type Integer = number;
|
||||
type Environment = {
|
||||
mediaType: "screen" | "print" | "not-screen-or-print";
|
||||
anyHover: "none" | "hover";
|
||||
anyPointer: "none" | "coarse" | "fine";
|
||||
colorGamut: "not-srgb" | "srgb-but-not-p3" | "p3-but-not-rec2020" | "rec2020";
|
||||
grid: "bitmap" | "grid";
|
||||
hover: "none" | "hover";
|
||||
overflowBlock: "none" | "scroll" | "paged";
|
||||
overflowInline: "none" | "scroll";
|
||||
pointer: "none" | "coarse" | "fine";
|
||||
scan: "interlace" | "progressive";
|
||||
update: "none" | "slow" | "fast";
|
||||
widthPx: Integer;
|
||||
heightPx: Integer;
|
||||
deviceWidthPx: Integer;
|
||||
deviceHeightPx: Integer;
|
||||
colorBits: Integer;
|
||||
monochromeBits: "not-monochrome" | Integer;
|
||||
colorIndex: "none" | Integer;
|
||||
dppx: Integer;
|
||||
displayMode: "fullscreen" | "standalone" | "minimal-ui" | "browser";
|
||||
dynamicRange: "not-hdr" | "hdr";
|
||||
environmentBlending: "opaque" | "additive" | "subtractive";
|
||||
forcedColors: "none" | "active";
|
||||
invertedColors: "none" | "inverted";
|
||||
navControls: "none" | "back";
|
||||
prefersColorScheme: "no-preference" | "light" | "dark";
|
||||
prefersContrast: "no-preference" | "less" | "more" | "custom";
|
||||
prefersReducedData: "no-preference" | "reduce";
|
||||
prefersReducedMotion: "no-preference" | "reduce";
|
||||
prefersReducedTransparency: "no-preference" | "reduce";
|
||||
scripting: "none" | "initial-only" | "enabled";
|
||||
videoColorGamut: "not-srgb" | "srgb-but-not-p3" | "p3-but-not-rec2020" | "rec2020";
|
||||
videoDynamicRange: "not-hdr" | "hdr";
|
||||
horizontalViewportSegments: Integer;
|
||||
verticalViewportSegments: Integer;
|
||||
};
|
||||
export interface InlineOptions {
|
||||
/** Emit `style` attributes as objects rather than strings. */
|
||||
useObjectSyntax: boolean;
|
||||
env: Partial<Environment> & {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
}
|
||||
declare function inline(opts?: Partial<InlineOptions>): (doc: Node$1) => Node$1;
|
||||
|
||||
export {
|
||||
inline as default,
|
||||
};
|
||||
|
||||
export {};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import{walkSync as Rt,ELEMENT_NODE as Ct,TEXT_NODE as At}from"../index.js";import{querySelectorAll as St,specificity as ht}from"../selector.js";var Pe="comm",Ie="rule",we="decl";var ce=Math.abs,U=String.fromCharCode;function J(e){return e.trim()}function Y(e,r,t){return e.replace(r,t)}function Ne(e,r,t){return e.indexOf(r,t)}function L(e,r){return e.charCodeAt(r)|0}function S(e,r,t){return e.slice(r,t)}function R(e){return e.length}function ke(e){return e.length}function F(e,r){return r.push(e),e}var ee=1,D=1,Oe=0,N=0,T=0,G="";function te(e,r,t,o,n,i,a,s){return{value:e,root:r,parent:t,type:o,props:n,children:i,line:ee,column:D,length:a,return:"",siblings:s}}function Re(){return T}function Ce(){return T=N>0?L(G,--N):0,D--,T===10&&(D=1,ee--),T}function k(){return T=N<Oe?L(G,N++):0,D++,T===10&&(D=1,ee++),T}function A(){return L(G,N)}function Q(){return N}function re(e,r){return S(G,e,r)}function B(e){switch(e){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function Ae(e){return ee=D=1,Oe=R(G=e),N=0,[]}function Se(e){return G="",e}function ne(e){return J(re(N-1,de(e===91?e+2:e===40?e+1:e)))}function _e(e){for(;(T=A())&&T<33;)k();return B(e)>2||B(T)>3?"":" "}function Me(e,r){for(;--r&&k()&&!(T<48||T>102||T>57&&T<65||T>70&&T<97););return re(e,Q()+(r<6&&A()==32&&k()==32))}function de(e){for(;k();)switch(T){case e:return N;case 34:case 39:e!==34&&e!==39&&de(T);break;case 40:e===41&&de(e);break;case 92:k();break}return N}function Le(e,r){for(;k()&&e+T!==57;)if(e+T===84&&A()===47)break;return"/*"+re(r,N-1)+"*"+U(e===47?e:k())}function Ve(e){for(;!B(A());)k();return re(e,N)}function fe(e){return Se(oe("",null,null,null,[""],e=Ae(e),0,[0],e))}function oe(e,r,t,o,n,i,a,s,l){for(var p=0,u=0,c=a,d=0,f=0,m=0,v=1,b=1,P=1,y=0,I="",E=n,x=i,g=o,h=I;b;)switch(m=y,y=k()){case 40:if(m!=108&&L(h,c-1)==58){Ne(h+=Y(ne(y),"&","&\f"),"&\f",ce(p?s[p-1]:0))!=-1&&(P=-1);break}case 34:case 39:case 91:h+=ne(y);break;case 9:case 10:case 13:case 32:h+=_e(m);break;case 92:h+=Me(Q()-1,7);continue;case 47:switch(A()){case 42:case 47:F(vt(Le(k(),Q()),r,t,l),l),(B(m||1)==5||B(A()||1)==5)&&R(h)&&S(h,-1,void 0)!==" "&&(h+=" ");break;default:h+="/"}break;case 123*v:s[p++]=R(h)*P;case 125*v:case 59:case 0:switch(y){case 0:case 125:b=0;case 59+u:P==-1&&(h=Y(h,/\f/g,"")),f>0&&(R(h)-c||v===0&&m===47)&&F(f>32?De(h+";",o,t,c-1,l):De(Y(h," ","")+";",o,t,c-2,l),l);break;case 59:h+=";";default:if(F(g=Fe(h,r,t,p,u,n,s,I,E=[],x=[],c,i),i),y===123)if(u===0)oe(h,r,g,g,E,i,c,s,x);else switch(d===99&&L(h,3)===110?100:d){case 100:case 108:case 109:case 115:oe(e,g,g,o&&F(Fe(e,g,g,0,0,n,s,I,n,E=[],c,x),x),n,x,c,s,o?E:x);break;default:oe(h,g,g,g,[""],x,0,s,x)}}p=u=f=0,v=P=1,I=h="",c=a;break;case 58:c=1+R(h),f=m;default:if(v<1){if(y==123)--v;else if(y==125&&v++==0&&Ce()==125)continue}switch(h+=U(y),y*v){case 38:P=u>0?1:(h+="\f",-1);break;case 44:s[p++]=(R(h)-1)*P,P=1;break;case 64:A()===45&&(h+=ne(k())),d=A(),u=c=R(I=h+=Ve(Q())),y++;break;case 45:m===45&&R(h)==2&&(v=0)}}return i}function Fe(e,r,t,o,n,i,a,s,l,p,u,c){for(var d=n-1,f=n===0?i:[""],m=ke(f),v=0,b=0,P=0;v<o;++v)for(var y=0,I=S(e,d+1,d=ce(b=a[v])),E=e;y<m;++y)(E=J(b>0?f[y]+" "+I:Y(I,/&\f/g,f[y])))&&(l[P++]=E);return te(e,r,t,n===0?Ie:s,l,p,u,c)}function vt(e,r,t,o){return te(e,r,t,Pe,U(Re()),S(e,2,-2),0,o)}function De(e,r,t,o,n){return te(e,r,t,we,S(e,0,o),S(e,o+1,-1),o,n)}var C=e=>typeof e=="object"&&e!==null&&"errid"in e,yt=e=>{let r=[[]],t=[];for(let o of e)if(o.type==="comma"&&t.length===0)r.push([]);else{switch(o.type){case"function":case"(":t.push(")");break;case"[":t.push("]");break;case"{":t.push("}");break;case")":case"]":case"}":t.at(-1)===o.type&&t.pop();break}r[r.length-1].push(o)}return r},Be=e=>{let r=yt(e);if(r.length===1&&r[0].length===0)return{type:"query-list",mediaQueries:[{type:"query"}]};{let t=[];for(let o of r){let n=Ge(o);C(n)?t.push({type:"query",prefix:"not"}):t.push(n)}return{type:"query-list",mediaQueries:t}}},Ge=e=>{var r,t,o;let n=e.at(0);if(n){if(n.type==="("){let i=_(e,!0);if(C(i)){let{start:a,end:s}=(r=e.at(1))!==null&&r!==void 0?r:n;return{errid:"EXPECT_FEATURE_OR_CONDITION",start:a,end:s,child:i}}return{type:"query",mediaCondition:i}}if(n.type==="ident"){let i,a,{value:s,end:l}=n;s!=="only"&&s!=="not"||(i=s);let p=i===void 0?0:1,u=e.at(p);if(!u)return{errid:"EXPECT_LPAREN_OR_TYPE",start:l,end:l};if(u.type!=="ident"){if(i==="not"&&u.type==="("){let c=_(e.slice(p),!0);if(C(c)){let{start:d,end:f}=(t=e.at(p+1))!==null&&t!==void 0?t:u;return{errid:"EXPECT_CONDITION",start:d,end:f,child:c}}return{type:"query",mediaCondition:{type:"condition",operator:"not",children:[c]}}}{let{start:c,end:d}=u;return{errid:"EXPECT_TYPE",start:c,end:d}}}{let{value:c,start:d,end:f}=u;if(c==="all")a=void 0;else if(c==="print"||c==="screen")a=c;else{if(c!=="tty"&&c!=="tv"&&c!=="projection"&&c!=="handheld"&&c!=="braille"&Line truncated
|
||||
`),a=fe(i),s=new Map;function l(u){if(u.type==="rule"){let c=Object.fromEntries(u.children.map(d=>[d.props,d.children]));for(let d of u.props){let f=Object.assign(s.get(d)??{},c);s.set(d,f)}}else if(u.type==="@media"&&(e!=null&&e.env)){let c=Mt(e.env),f=(Array.isArray(u.props)?u.props:[u.props]).map(m=>ft(m));for(let m of f)if(mt(m,c)){for(let v of u.children)l(v);return}}}for(let u of a)l(u);let p=new Map;for(let[u,c]of Array.from(s).sort(([d],[f])=>{let m=ht(d),v=ht(f);return m>v?1:v>m?-1:0})){let d=St(t,u);for(let f of d){let m=p.get(f)??{};p.set(f,Object.assign(m,c))}}for(let[u,c]of p){let d=u.attributes.style??"",f={};for(let m of fe(d))m.type==="decl"&&typeof m.props=="string"&&typeof m.children=="string"&&(f[m.props]=m.children);f=Object.assign({},c,f),r?u.attributes.style=f:u.attributes.style=`${Object.entries(f).map(([m,v])=>`${m}:${v.replace("!important","")};`).join("")}`}return t}}function Mt(e){let{width:r,height:t,dppx:o=1,widthPx:n=r,heightPx:i=t,deviceWidthPx:a=r*o,deviceHeightPx:s=t*o,...l}=e;return{widthPx:n,heightPx:i,deviceWidthPx:a,deviceHeightPx:s,dppx:o,...l}}export{_t as default};
|
||||
/*! Bundled license information:
|
||||
|
||||
media-query-parser/dist/index.js:
|
||||
(**! media-query-parser | Tom Golden <oss@tom.bio> (https://tom.bio) | @license MIT *)
|
||||
*/
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../src/transformers/inline.ts", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Enum.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Utility.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Tokenizer.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Parser.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/ast/ast.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/flatten/flatten.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/internals.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/codepoints.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/process.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/tokens.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/lexer/lexer.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/utils.js", "../../node_modules/.pnpm/media-query-parser@3.0.0-beta.1/node_modules/media-query-parser/dist/index.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/helpers.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/units.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/compile.js", "../../node_modules/.pnpm/media-query-fns@2.0.0/node_modules/media-query-fns/dist/matches.js"],
|
||||
"sourcesContent": ["import { walkSync, ELEMENT_NODE, TEXT_NODE, Node } from '../index.js';\nimport { querySelectorAll, specificity } from '../selector.js';\nimport { type Element as CSSEntry, compile } from 'stylis';\nimport { compileQuery, matches, type Environment } from 'media-query-fns';\n\nexport interface InlineOptions {\n\t/** Emit `style` attributes as objects rather than strings. */\n\tuseObjectSyntax: boolean;\n\tenv: Partial<Environment> & { width: number; height: number };\n}\nexport default function inline(opts?: Partial<InlineOptions>) {\n\tconst { useObjectSyntax = false } = opts ?? {};\n\treturn (doc: Node): Node => {\n\t\tconst style: string[] = useObjectSyntax ? [':where([style]) {}'] : [];\n\t\tconst actions: (() => void)[] = [];\n\t\twalkSync(doc, (node: Node, parent?: Node) => {\n\t\t\tif (node.type === ELEMENT_NODE) {\n\t\t\t\tif (node.name === 'style') {\n\t\t\t\t\tstyle.push(\n\t\t\t\t\t\tnode.children\n\t\t\t\t\t\t\t.map((c: Node) => (c.type === TEXT_NODE ? c.value : ''))\n\t\t\t\t\t\t\t.join(''),\n\t\t\t\t\t);\n\t\t\t\t\tactions.push(() => {\n\t\t\t\t\t\tparent!.children = parent!.children.filter((c: Node) => c !== node);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t\tfor (const action of actions) {\n\t\t\taction();\n\t\t}\n\t\tconst styles = style.join('\\n');\n\t\tconst css = compile(styles);\n\t\tconst selectors = new Map<string, Record<string, string>>();\n\n\t\tfunction applyRule(rule: CSSEntry) {\n\t\t\tif (rule.type === 'rule') {\n\t\t\t\tconst rules = Object.fromEntries(\n\t\t\t\t\t(rule.children as unknown as Element[]).map((child: any) => [\n\t\t\t\t\t\tchild.props,\n\t\t\t\t\t\tchild.children,\n\t\t\t\t\t]),\n\t\t\t\t);\n\t\t\t\tfor (const selector of rule.props) {\n\t\t\t\t\tconst value = Object.assign(selectors.get(selector) ?? {}, rules);\n\t\t\t\t\tselectors.set(selector, value);\n\t\t\t\t}\n\t\t\t} else if (rule.type === '@media' && opts?.env) {\n\t\t\t\tconst env = getEnvironment(opts.env);\n\t\t\t\tconst args = Array.isArray(rule.props) ? rule.props : [rule.props];\n\t\t\t\tconst queries = args.map((arg) => compileQuery(arg));\n\t\t\t\tfor (const query of queries) {\n\t\t\t\t\tif (matches(query, env)) {\n\t\t\t\t\t\tfor (const child of rule.children) {\n\t\t\t\t\t\t\tapplyRule(child as CSSEntry);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const rule of css) {\n\t\t\tapplyRule(rule);\n\t\t}\n\t\tconst rules = new Map<Node, Record<string, string>>();\n\t\tfor (const [selector, styles] of Array.from(selectors).sort(([a], [b]) => {\n\t\t\tconst $a = specificity(a);\n\t\t\tconst $b = specificity(b);\n\t\t\tif ($a > $b) return 1;\n\t\t\tif ($b > $a) return -1;\n\t\t\treturn 0;\n\t\t})) {\n\t\t\tconst nodes = querySelectorAll(doc, selector);\n\t\t\tfor (const node of nodes) {\n\t\t\t\tconst curr = rules.get(node) ?? {};\n\t\t\t\trules.set(node, Object.assign(curr, styles));\n\t\t\t}\n\t\t}\n\n\t\tfor (const [node, rule] of rules) {\n\t\t\tlet style = node.attributes.style ?? '';\n\t\t\tlet styleObj: Record<string, string> = {};\n\t\t\tfor (const decl of compile(style)) {\n\t\t\t\tif (decl.type === 'decl') {\n\t\t\t\t\tif (\n\t\t\t\t\t\ttypeof decl.props === 'string' &&\n\t\t\t\t\t\ttypeof decl.children === 'string'\n\t\t\t\t\t) {\n\t\t\t\t\t\tstyleObj[decl.props] = decl.children;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tstyleObj = Object.assign({}, rule, styleObj);\n\t\t\tif (useObjectSyntax) {\n\t\t\t\tnode.attributes.style = styleObj;\n\t\t\t} else {\n\t\t\t\tnode.attributes.style = `${Object.entries(styleObj)\n\t\t\t\t\t.map(([decl, value]) => `${decl}:${value.replace('!important', '')};`)\n\t\t\t\t\t.join('')}`;\n\t\t\t}\n\t\t}\n\t\treturn doc;\n\t};\n}\n\ntype AlwaysDefinedValues =\n\t| 'widthPx'\n\t| 'heightPx'\n\t| 'deviceWidthPx'\n\t| 'deviceHeightPx'\n\t| 'dppx';\ntype ResolvedEnvironment = Omit<Partial<Environment>, AlwaysDefinedValues> &\n\tRecord<AlwaysDefinedValues, number>;\nfunction getEnvironment(baseEnv: InlineOptions['env']): ResolvedEnvironment {\n\tconst {\n\t\twidth,\n\t\theight,\n\t\tdppx = 1,\n\t\twidthPx = width,\n\t\theightPx = height,\n\t\tdeviceWidthPx = width * dppx,\n\t\tdeviceHeightPx = height * dppx,\n\t\t...env\n\t} = baseEnv;\n\treturn {\n\t\twidthPx,\n\t\theightPx,\n\t\tdeviceWidthPx,\n\t\tdeviceHeightPx,\n\t\tdppx,\n\t\t...env,\n\t};\n}\n", "export var MS = '-ms-'\nexport var MOZ = '-moz-'\nexport var WEBKIT = '-webkit-'\n\nexport var COMMENT = 'comm'\nexport var RULESET = 'rule'\nexport var DECLARATION = 'decl'\n\nexport var PAGE = '@page'\nexport var MEDIA = '@media'\nexport var IMPORT = '@import'\nexport var CHARSET = '@charset'\nexport var VIEWPORT = '@viewport'\nexport var SUPPORTS = '@supports'\nexport var DOCUMENT = '@document'\nexport var NAMESPACE = '@namespace'\nexport var KEYFRAMES = '@keyframes'\nexport var FONT_FACE = '@font-face'\nexport var COUNTER_STYLE = '@counter-style'\nexport var FONT_FEATURE_VALUES = '@font-feature-values'\nexport var LAYER = '@layer'\nexport var SCOPE Line truncated
|
||||
"mappings": "AAAA,OAAS,YAAAA,GAAU,gBAAAC,GAAc,aAAAC,OAAuB,cACxD,OAAS,oBAAAC,GAAkB,eAAAC,OAAmB,iBCGvC,IAAIC,GAAU,OACVC,GAAU,OACVC,GAAc,OCFlB,IAAIC,GAAM,KAAK,IAMXC,EAAO,OAAO,aAqBlB,SAASC,EAAMC,EAAO,CAC5B,OAAOA,EAAM,KAAK,CACnB,CAiBO,SAASC,EAASC,EAAOC,EAASC,EAAa,CACrD,OAAOF,EAAM,QAAQC,EAASC,CAAW,CAC1C,CAQO,SAASC,GAASH,EAAOI,EAAQC,EAAU,CACjD,OAAOL,EAAM,QAAQI,EAAQC,CAAQ,CACtC,CAOO,SAASC,EAAQN,EAAOO,EAAO,CACrC,OAAOP,EAAM,WAAWO,CAAK,EAAI,CAClC,CAQO,SAASC,EAAQR,EAAOS,EAAOC,EAAK,CAC1C,OAAOV,EAAM,MAAMS,EAAOC,CAAG,CAC9B,CAMO,SAASC,EAAQX,EAAO,CAC9B,OAAOA,EAAM,MACd,CAMO,SAASY,GAAQZ,EAAO,CAC9B,OAAOA,EAAM,MACd,CAOO,SAASa,EAAQb,EAAOc,EAAO,CACrC,OAAOA,EAAM,KAAKd,CAAK,EAAGA,CAC3B,CCxGO,IAAIe,GAAO,EACPC,EAAS,EACTC,GAAS,EACTC,EAAW,EACXC,EAAY,EACZC,EAAa,GAYjB,SAASC,GAAMC,EAAOC,EAAMC,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AOiB,EAAQC,CAAQ,EAC3N,MACD,QACCtB,GAAMwB,EAAYD,EAAWA,Line truncated
|
||||
"names": ["walkSync", "ELEMENT_NODE", "TEXT_NODE", "querySelectorAll", "specificity", "COMMENT", "RULESET", "DECLARATION", "abs", "from", "trim", "value", "replace", "value", "pattern", "replacement", "indexof", "search", "position", "charat", "index", "substr", "begin", "end", "strlen", "sizeof", "append", "array", "line", "column", "length", "position", "character", "characters", "node", "value", "root", "parent", "type", "props", "children", "siblings", "char", "character", "prev", "position", "charat", "characters", "column", "line", "next", "length", "peek", "caret", "slice", "begin", "end", "substr", "token", "type", "alloc", "value", "strlen", "dealloc", "delimit", "trim", "delimiter", "whitespace", "type", "character", "peek", "next", "token", "escaping", "index", "count", "next", "character", "slice", "caret", "peek", "delimiter", "type", "position", "commenter", "from", "identifier", "token", "compile", "value", "dealloc", "parse", "alloc", "root", "parent", "rule", "rules", "rulesets", "pseudo", "points", "declarations", "index", "offset", "length", "atrule", "property", "previous", "variable", "scanning", "ampersand", "character", "type", "props", "children", "reference", "characters", "next", "charat", "indexof", "replace", "delimit", "abs", "whitespace", "escaping", "caret", "peek", "append", "comment", "commenter", "token", "strlen", "substr", "declaration", "ruleset", "prev", "from", "identifier", "siblings", "post", "size", "sizeof", "i", "j", "k", "x", "y", "z", "trim", "node", "RULESET", "COMMENT", "char", "DECLARATION", "isParserError", "splitMediaQueryList", "t", "r", "n", "readMediaQueryList", "e", "readMediaQuery", "i", "readMediaCondition", "a", "d", "s", "o", "l", "u", "readMediaFeature", "readRange", "p", "f", "c", "h", "v", "flattenMediaQueryList", "e", "flattenMediaQuery", "flattenMediaCondition", "o", "i", "invertParserError", "t", "d", "e", "deleteUndefinedValues", "e", "readCodepoints", "s", "t", "r", "a", "convertToParserTokens", "t", "r", "s", "codepointsToTokens", "f", "c", "p", "d", "h", "e", "n", "s", "consumeString", "t", "wouldStartIdentifier", "consumeIdentUnsafe", "consumeNumeric", "consumeIdentLike", "consumeIdent", "u", "r", "consumeEscape", "i", "a", "consumeNumber", "o", "l", "consumeUrl", "lexer", "m", "e", "codepointsToTokens", "readCodepoints", "isParserError", "convertToParserTokens", "isParserError", "r", "parseMediaQueryList", "t", "e", "lexer", "isParserError", "invertParserError", "deleteUndefinedValues", "flattenMediaQueryList", "readMediaQueryList", "DISCRETE_FEATURES", "RANGE_NUMBER_FEATURES", "RANGE_RATIO_FEATURES", "permToConditionPairs", "e", "hasDiscreteKey", "t", "isDiscreteKey", "hasRangeRatioKey", "isRangeRatioKey", "o", "hasRangeNumberKey", "isRangeNumberKey", "hasRangeKey", "isRangeKey", "isFeatureKey", "isRangeNumberKey", "isRangeRatioKey", "isDiscreteKey", "attachPair", "t", "andRanges", "e", "o", "n", "r", "s", "a", "i", "p", "u", "d", "l", "g", "f", "h", "y", "R", "b", "m", "boundRange", "hasRangeRatioKey", "RANGE_RATIO_FEATURES", "RANGE_NUMBER_FEATURES", "notRatioRange", "t", "RANGE_RATIO_FEATURES", "o", "n", "r", "s", "i", "c", "d", "l", "notNumberRange", "RANGE_NUMBER_FEATURES", "i", "convertToUnit", "t", "n", "compileStaticUnitConversions", "r", "o", "a", "u", "p", "m", "s", "f", "v", "c", "simplifyMediaFeature", "isRangeKey", "e", "isFeatureKey", "getRatio", "getValue", "RANGE_NUMBER_FEATURES", "andPerms", "e", "r", "mergePerms", "a", "permToConditionPairs", "attachPair", "hasRangeNumberKey", "hasRangeRatioKey", "andRanges", "notPerms", "invertPerm", "o", "t", "hasDiscreteKey", "DISCRETE_FEATURES", "notRatioRange", "notNumberRange", "s", "mediaFeatureToPerms", "simplifyMediaFeature", "isDiscreteKey", "isRangeRatioKey", "getRatio", "boundRange", "getValue", "mediaConditionToPerms", "simplifyPerms", "n", "i", "hasRangeKey", "compileAST", "compileStaticUnitConversions", "compileQuery", "parseMediaQueryList", "isParserError", "DESKTOP_ENVIRONMENT", "e", "validateEnv", "o", "matches", "r", "t", "n", "i", "s", "a", "l", "f", "inline", "opts", "useObjectSyntax", "doc", "style", "actions", "walkSync", "node", "parent", "ELEMENT_NODE", "c", "TEXT_NODE", "action", "styles", "css", "compile", "selectors", "applyRule", "rule", "rules", "child", "selector", "value", "env", "getEnvironment", "queries", "arg", "compileQuery", "query", "matches", "a", "b", "$a", "specificity", "$b", "nodes", "querySelectorAll", "curr", "styleObj", "decl", "baseEnv", "width", "height", "dppx", "widthPx", "heightPx", "deviceWidthPx", "deviceHeightPx"]
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
type Node$1 = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
|
||||
type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
|
||||
interface Location$1 {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: NodeType;
|
||||
loc: [
|
||||
Location$1,
|
||||
Location$1
|
||||
];
|
||||
parent: Node$1;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface LiteralNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface ParentNode$1 extends BaseNode {
|
||||
children: Node$1[];
|
||||
}
|
||||
interface DocumentNode extends Omit<ParentNode$1, "parent"> {
|
||||
type: typeof DOCUMENT_NODE;
|
||||
attributes: Record<string, string>;
|
||||
parent: undefined;
|
||||
}
|
||||
interface ElementNode extends ParentNode$1 {
|
||||
type: typeof ELEMENT_NODE;
|
||||
name: string;
|
||||
attributes: Record<string, string>;
|
||||
}
|
||||
interface TextNode extends LiteralNode {
|
||||
type: typeof TEXT_NODE;
|
||||
}
|
||||
interface CommentNode extends LiteralNode {
|
||||
type: typeof COMMENT_NODE;
|
||||
}
|
||||
interface DoctypeNode extends LiteralNode {
|
||||
type: typeof DOCTYPE_NODE;
|
||||
}
|
||||
declare const DOCUMENT_NODE = 0;
|
||||
declare const ELEMENT_NODE = 1;
|
||||
declare const TEXT_NODE = 2;
|
||||
declare const COMMENT_NODE = 3;
|
||||
declare const DOCTYPE_NODE = 4;
|
||||
export interface SanitizeOptions {
|
||||
/** An Array of strings indicating elements that the sanitizer should not remove. All elements not in the array will be dropped. */
|
||||
allowElements?: string[];
|
||||
/** An Array of strings indicating elements that the sanitizer should not remove. All elements not in the array will be removed while keeping their child content. */
|
||||
unblockElements?: string[];
|
||||
/** An Array of strings indicating elements that the sanitizer should remove, but keeping their child elements. */
|
||||
blockElements?: string[];
|
||||
/** An Array of strings indicating elements (including nested elements) that the sanitizer should remove. */
|
||||
dropElements?: string[];
|
||||
/** An Object where each key is the attribute name and the value is an Array of allowed tag names. Matching attributes will not be removed. All attributes that are not in the array will be dropped. */
|
||||
allowAttributes?: Record<string, string[]>;
|
||||
/** An Object where each key is the attribute name and the value is an Array of dropped tag names. Matching attributes will be removed. */
|
||||
dropAttributes?: Record<string, string[]>;
|
||||
/** A Boolean value set to false (default) to remove components and their children. If set to true, components will be subject to built-in and custom configuration checks (and will be retained or dropped based on those checks). */
|
||||
allowComponents?: boolean;
|
||||
/** A Boolean value set to false (default) to remove custom elements and their children. If set to true, custom elements will be subject to built-in and custom configuration checks (and will be retained or dropped based on those checks). */
|
||||
allowCustomElements?: boolean;
|
||||
/** A Boolean value set to false (default) to remove HTML comments. Set to true in order to keep comments. */
|
||||
allowComments?: boolean;
|
||||
}
|
||||
declare function sanitize(opts?: SanitizeOptions): (doc: Node$1) => Node$1;
|
||||
|
||||
export {
|
||||
sanitize as default,
|
||||
};
|
||||
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{ELEMENT_NODE as a,walkSync as p}from"../index.js";function f(t){var n;if(t===void 0)return{allowElements:[],dropElements:["script"],allowComponents:!1,allowCustomElements:!1,allowComments:!1};{let e=new Set([]);(n=t.allowElements)!=null&&n.includes("script")||e.add("script");for(let l of t.dropElements??[])e.add(l);return{allowComponents:!1,allowCustomElements:!1,allowComments:!1,...t,dropElements:Array.from(e)}}}function E(t){return t.name.includes("-")?"custom-element":/[\_\$A-Z]/.test(t.name[0])||t.name.includes(".")?"component":"element"}function w(t,n,e){var l,o,s,r;return((l=e.allowElements)==null?void 0:l.length)>0&&e.allowElements.includes(t)?"allow":((o=e.blockElements)==null?void 0:o.length)>0&&e.blockElements.includes(t)?"block":((s=e.dropElements)==null?void 0:s.length)>0&&e.dropElements.find(u=>u===t)||n==="component"&&!e.allowComponents||n==="custom-element"&&!e.allowCustomElements?"drop":e.unblockElements?e.unblockElements.some(u=>u===t)?"allow":"block":((r=e.allowElements)==null?void 0:r.length)>0?"drop":"allow"}function b(t,n){var l,o,s,r,u,m,c,d;let e=t.attributes;for(let i of Object.keys(t.attributes))(l=n.allowAttributes)!=null&&l[i]&&((o=n.allowAttributes)!=null&&o[i].includes(t.name))||(r=(s=n.allowAttributes)==null?void 0:s[i])!=null&&r.includes("*")||((u=n.dropAttributes)!=null&&u[i]&&((m=n.dropAttributes)!=null&&m[i].includes(t.name))||(d=(c=n.dropAttributes)==null?void 0:c[i])!=null&&d.includes("*"))&&delete e[i];return e}function g(t,n,e){let l=E(n),{name:o}=n,s=w(o,l,t);return s==="drop"?()=>{e.children=e.children.filter(r=>r!==n)}:s==="block"?()=>{e.children=e.children.map(r=>r===n?r.children:r).flat(1)}:()=>{n.attributes=b(n,t)}}function N(t){let n=f(t);return e=>{let l=[];p(e,(o,s)=>{switch(o.type){case a:{l.push(g(n,o,s));return}default:return}});for(let o=l.length-1;o>=0;o--)l[o]();return e}}export{N as default};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../src/transformers/sanitize.ts"],
|
||||
"sourcesContent": ["import { ElementNode, ELEMENT_NODE, Node, walkSync } from '../index.js';\n\nexport interface SanitizeOptions {\n\t/** An Array of strings indicating elements that the sanitizer should not remove. All elements not in the array will be dropped. */\n\tallowElements?: string[];\n\t/** An Array of strings indicating elements that the sanitizer should not remove. All elements not in the array will be removed while keeping their child content. */\n\tunblockElements?: string[];\n\t/** An Array of strings indicating elements that the sanitizer should remove, but keeping their child elements. */\n\tblockElements?: string[];\n\t/** An Array of strings indicating elements (including nested elements) that the sanitizer should remove. */\n\tdropElements?: string[];\n\t/** An Object where each key is the attribute name and the value is an Array of allowed tag names. Matching attributes will not be removed. All attributes that are not in the array will be dropped. */\n\tallowAttributes?: Record<string, string[]>;\n\t/** An Object where each key is the attribute name and the value is an Array of dropped tag names. Matching attributes will be removed. */\n\tdropAttributes?: Record<string, string[]>;\n\t/** A Boolean value set to false (default) to remove components and their children. If set to true, components will be subject to built-in and custom configuration checks (and will be retained or dropped based on those checks). */\n\tallowComponents?: boolean;\n\t/** A Boolean value set to false (default) to remove custom elements and their children. If set to true, custom elements will be subject to built-in and custom configuration checks (and will be retained or dropped based on those checks). */\n\tallowCustomElements?: boolean;\n\t/** A Boolean value set to false (default) to remove HTML comments. Set to true in order to keep comments. */\n\tallowComments?: boolean;\n}\n\nfunction resolveSantizeOptions(\n\tsanitize?: SanitizeOptions,\n): Required<SanitizeOptions> {\n\tif (sanitize === undefined) {\n\t\treturn {\n\t\t\tallowElements: [] as string[],\n\t\t\tdropElements: ['script'],\n\t\t\tallowComponents: false,\n\t\t\tallowCustomElements: false,\n\t\t\tallowComments: false,\n\t\t} as Required<SanitizeOptions>;\n\t} else {\n\t\tconst dropElements = new Set<string>([]);\n\t\tif (!sanitize.allowElements?.includes('script')) {\n\t\t\tdropElements.add('script');\n\t\t}\n\t\tfor (const dropElement of sanitize.dropElements ?? []) {\n\t\t\tdropElements.add(dropElement);\n\t\t}\n\t\treturn {\n\t\t\tallowComponents: false,\n\t\t\tallowCustomElements: false,\n\t\t\tallowComments: false,\n\t\t\t...sanitize,\n\t\t\tdropElements: Array.from(dropElements),\n\t\t} as Required<SanitizeOptions>;\n\t}\n}\n\ntype NodeKind = 'element' | 'component' | 'custom-element';\nfunction getNodeKind(node: ElementNode): NodeKind {\n\tif (node.name.includes('-')) return 'custom-element';\n\tif (/[\\_\\$A-Z]/.test(node.name[0]) || node.name.includes('.'))\n\t\treturn 'component';\n\treturn 'element';\n}\n\ntype ActionType = 'allow' | 'drop' | 'block';\nfunction getAction(\n\tname: string,\n\tkind: NodeKind,\n\tsanitize: Required<SanitizeOptions>,\n): ActionType {\n\tif (sanitize.allowElements?.length > 0) {\n\t\tif (sanitize.allowElements.includes(name)) return 'allow';\n\t}\n\tif (sanitize.blockElements?.length > 0) {\n\t\tif (sanitize.blockElements.includes(name)) return 'block';\n\t}\n\tif (sanitize.dropElements?.length > 0) {\n\t\tif (sanitize.dropElements.find((n) => n === name)) return 'drop';\n\t}\n\tif (kind === 'component' && !sanitize.allowComponents) return 'drop';\n\tif (kind === 'custom-element' && !sanitize.allowCustomElements) return 'drop';\n\tif (sanitize.unblockElements) {\n\t\treturn sanitize.unblockElements.some((n) => n === name) ? 'allow' : 'block';\n\t}\n\treturn sanitize.allowElements?.length > 0 ? 'drop' : 'allow';\n}\n\nfunction sanitizeAttributes(\n\tnode: ElementNode,\n\tsanitize: Required<SanitizeOptions>,\n): Record<string, string> {\n\tconst attrs: Record<string, string> = node.attributes;\n\tfor (const key of Object.keys(node.attributes)) {\n\t\tif (\n\t\t\t(sanitize.allowAttributes?.[key] &&\n\t\t\t\tsanitize.allowAttributes?.[key].includes(node.name)) ||\n\t\t\tsanitize.allowAttributes?.[key]?.includes('*')\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\t\tif (\n\t\t\t(sanitize.dropAttributes?.[key] &&\n\t\t\t\tsanitize.dropAttributes?.[key].includes(node.name)) ||\n\t\t\tsanitize.dropAttributes?.[key]?.includes('*')\n\t\t) {\n\t\t\tdelete attrs[key];\n\t\t}\n\t}\n\treturn attrs;\n}\n\nfunction sanitizeElement(\n\topts: Required<SanitizeOptions>,\n\tnode: ElementNode,\n\tparent: Node,\n) {\n\tconst kind = getNodeKind(node);\n\tconst { name } = node;\n\tconst action = getAction(name, kind, opts);\n\tif (action === 'drop')\n\t\treturn () => {\n\t\t\tparent!.children = parent!.children.filter(\n\t\t\t\t(child: Node) => child !== node,\n\t\t\t);\n\t\t};\n\tif (action === 'block')\n\t\treturn () => {\n\t\t\tparent!.Line truncated
|
||||
"mappings": "AAAA,OAAsB,gBAAAA,EAAoB,YAAAC,MAAgB,cAuB1D,SAASC,EACRC,EAC4B,CAzB7B,IAAAC,EA0BC,GAAID,IAAa,OAChB,MAAO,CACN,cAAe,CAAC,EAChB,aAAc,CAAC,QAAQ,EACvB,gBAAiB,GACjB,oBAAqB,GACrB,cAAe,EAChB,EACM,CACN,IAAME,EAAe,IAAI,IAAY,CAAC,CAAC,GAClCD,EAAAD,EAAS,gBAAT,MAAAC,EAAwB,SAAS,WACrCC,EAAa,IAAI,QAAQ,EAE1B,QAAWC,KAAeH,EAAS,cAAgB,CAAC,EACnDE,EAAa,IAAIC,CAAW,EAE7B,MAAO,CACN,gBAAiB,GACjB,oBAAqB,GACrB,cAAe,GACf,GAAGH,EACH,aAAc,MAAM,KAAKE,CAAY,CACtC,CACD,CACD,CAGA,SAASE,EAAYC,EAA6B,CACjD,OAAIA,EAAK,KAAK,SAAS,GAAG,EAAU,iBAChC,YAAY,KAAKA,EAAK,KAAK,CAAC,CAAC,GAAKA,EAAK,KAAK,SAAS,GAAG,EACpD,YACD,SACR,CAGA,SAASC,EACRC,EACAC,EACAR,EACa,CAjEd,IAAAC,EAAAQ,EAAAC,EAAAC,EAkEC,QAAIV,EAAAD,EAAS,gBAAT,YAAAC,EAAwB,QAAS,GAChCD,EAAS,cAAc,SAASO,CAAI,EAAU,UAE/CE,EAAAT,EAAS,gBAAT,YAAAS,EAAwB,QAAS,GAChCT,EAAS,cAAc,SAASO,CAAI,EAAU,UAE/CG,EAAAV,EAAS,eAAT,YAAAU,EAAuB,QAAS,GAC/BV,EAAS,aAAa,KAAMY,GAAMA,IAAML,CAAI,GAE7CC,IAAS,aAAe,CAACR,EAAS,iBAClCQ,IAAS,kBAAoB,CAACR,EAAS,oBAA4B,OACnEA,EAAS,gBACLA,EA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C3C,OAAQI,GAAoB,CAC3B,IAAIC,EAAiB,CAAC,EACtB5B,EAAS2B,EAAK,CAACpB,EAAYiB,IAAkB,CAC5C,OAAQjB,EAAK,KAAM,CAClB,KAAKR,EAAc,CAClB6B,EAAQ,KAAKN,EAAgBpB,EAAUK,EAAMiB,CAAO,CAAC,EACrD,MACD,CACA,QACC,MACF,CACD,CAAC,EAED,QAASK,EAAID,EAAQ,OAAS,EAAGC,GAAK,EAAGA,IACxCD,EAAQC,CAAC,EAAE,EAEZ,OAAOF,CACR,CACD",
|
||||
"names": ["ELEMENT_NODE", "walkSync", "resolveSantizeOptions", "sanitize", "_a", "dropElements", "dropElement", "getNodeKind", "node", "getAction", "name", "kind", "_b", "_c", "_d", "n", "sanitizeAttributes", "_e", "_f", "_g", "_h", "attrs", "key", "sanitizeElement", "opts", "parent", "action", "child", "doc", "actions", "i"]
|
||||
}
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
type Node$1 = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
|
||||
type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
|
||||
interface Location$1 {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: NodeType;
|
||||
loc: [
|
||||
Location$1,
|
||||
Location$1
|
||||
];
|
||||
parent: Node$1;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface LiteralNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface ParentNode$1 extends BaseNode {
|
||||
children: Node$1[];
|
||||
}
|
||||
interface DocumentNode extends Omit<ParentNode$1, "parent"> {
|
||||
type: typeof DOCUMENT_NODE;
|
||||
attributes: Record<string, string>;
|
||||
parent: undefined;
|
||||
}
|
||||
interface ElementNode extends ParentNode$1 {
|
||||
type: typeof ELEMENT_NODE;
|
||||
name: string;
|
||||
attributes: Record<string, string>;
|
||||
}
|
||||
interface TextNode extends LiteralNode {
|
||||
type: typeof TEXT_NODE;
|
||||
}
|
||||
interface CommentNode extends LiteralNode {
|
||||
type: typeof COMMENT_NODE;
|
||||
}
|
||||
interface DoctypeNode extends LiteralNode {
|
||||
type: typeof DOCTYPE_NODE;
|
||||
}
|
||||
declare const DOCUMENT_NODE = 0;
|
||||
declare const ELEMENT_NODE = 1;
|
||||
declare const TEXT_NODE = 2;
|
||||
declare const COMMENT_NODE = 3;
|
||||
declare const DOCTYPE_NODE = 4;
|
||||
export interface ScopeOptions {
|
||||
hash?: string;
|
||||
attribute?: string;
|
||||
}
|
||||
declare function scope(opts?: ScopeOptions): (doc: Node$1) => Promise<Node$1>;
|
||||
|
||||
export {
|
||||
scope as default,
|
||||
};
|
||||
|
||||
export {};
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
var F={attribute:/\[\s*(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?(?<name>[-\w\P{ASCII}]+)\s*(?:(?<operator>\W?=)\s*(?<value>.+?)\s*(\s(?<caseSensitive>[iIsS]))?\s*)?\]/gu,id:/#(?<name>[-\w\P{ASCII}]+)/gu,class:/\.(?<name>[-\w\P{ASCII}]+)/gu,comma:/\s*,\s*/g,combinator:/\s*[\s>+~]\s*/g,"pseudo-element":/::(?<name>[-\w\P{ASCII}]+)(?:\((?<argument>¶*)\))?/gu,"pseudo-class":/:(?<name>[-\w\P{ASCII}]+)(?:\((?<argument>¶*)\))?/gu,universal:/(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?\*/gu,type:/(?:(?<namespace>\*|[-\w\P{ASCII}]*)\|)?(?<name>[-\w\P{ASCII}]+)/gu},kr=new Set(["combinator","comma"]),Ir=new Set(["not","is","where","has","matches","-moz-any","-webkit-any","nth-child","nth-last-child"]),ar=/(?<index>[\dn+-]+)\s+of\s+(?<subtree>.+)/,Or={"nth-child":ar,"nth-last-child":ar},Tr=r=>{switch(r){case"pseudo-element":case"pseudo-class":return new RegExp(F[r].source.replace("(?<argument>\xB6*)","(?<argument>.*)"),"gu");default:return F[r]}};function Cr(r,e){let t=0,n="";for(;e<r.length;e++){let s=r[e];switch(s){case"(":++t;break;case")":--t}if(n+=s,t===0)return n}return n}function Nr(r,e=F){if(!r)return[];let t=[r];for(let[s,a]of Object.entries(e))for(let i=0;i<t.length;i++){let o=t[i];if(typeof o!="string")continue;a.lastIndex=0;let c=a.exec(o);if(!c)continue;let p=c.index-1,l=[],h=c[0],S=o.slice(0,p+1);S&&l.push(S),l.push({...c.groups,type:s,content:h});let d=o.slice(p+h.length+1);d&&l.push(d),t.splice(i,1,...l)}let n=0;for(let s of t)switch(typeof s){case"string":throw new Error(`Unexpected sequence ${s} found at index ${n}`);case"object":n+=s.content.length,s.pos=[n-s.content.length,n],kr.has(s.type)&&(s.content=s.content.trim()||" ")}return t}var Rr=/(['"])([^\\\n]+?)\1/g,Mr=/\\./g;function $r(r,e=F){if((r=r.trim())==="")return[];let t=[];r=(r=r.replace(Mr,(a,i)=>(t.push({value:a,offset:i}),"\uE000".repeat(a.length)))).replace(Rr,(a,i,o,c)=>(t.push({value:a,offset:c}),`${i}${"\uE001".repeat(o.length)}${i}`));{let a,i=0;for(;(a=r.indexOf("(",i))>-1;){let o=Cr(r,a);t.push({value:o,offset:a}),r=`${r.substring(0,a)}(${"\xB6".repeat(o.length-2)})${r.substring(a+o.length)}`,i=a+o.length}}let n=Nr(r,e),s=new Set;for(let a of t.reverse())for(let i of n){let{offset:o,value:c}=a;if(!(i.pos[0]<=o&&o+c.length<=i.pos[1]))continue;let{content:p}=i,l=o-i.pos[0];i.content=p.slice(0,l)+c+p.slice(l+c.length),i.content!==p&&s.add(i)}for(let a of s){let i=Tr(a.type);if(!i)throw new Error(`Unknown token type: ${a.type}`);i.lastIndex=0;let o=i.exec(a.content);if(!o)throw new Error(`Unable to parse content for ${a.type}: ${a.content}`);Object.assign(a,o.groups)}return n}function L(r,{list:e=!0}={}){if(e&&r.find(t=>t.type==="comma")){let t=[],n=[];for(let s=0;s<r.length;s++)if(r[s].type==="comma"){if(n.length===0)throw new Error("Incorrect comma at "+s);t.push(L(n,{list:!1})),n.length=0}else n.push(r[s]);if(n.length===0)throw new Error("Trailing comma");return t.push(L(n,{list:!1})),{type:"list",list:t}}for(let t=r.length-1;t>=0;t--){let n=r[t];if(n.type==="combinator"){let s=r.slice(0,t),a=r.slice(t+1);return{type:"complex",combinator:n.content,left:L(s),right:L(a)}}}switch(r.length){case 0:throw new Error("Could not build AST.");case 1:return r[0];default:return{type:"compound",list:[...r]}}}function*D(r,e){switch(r.type){case"list":for(let t of r.list)yield*D(t,r);break;case"complex":yield*D(r.left,r),yield*D(r.right,r);break;case"compound":yield*r.list.map(t=>[t,r]);break;default:yield[r,e]}}function J(r,{recursive:e=!0,list:t=!0}={}){let n=$r(r);if(!n)return;let s=L(n,{list:t});if(!e)return s;for(let[a]of D(s)){if(a.type!=="pseudo-class"||!a.argument||!Ir.has(a.name))continue;let i=a.argument,o=Or[a.name];if(o){let c=o.exec(i);if(!c)continue;Object.assign(a,c.groups),i=c.groups.subtree}i&&Object.assign(a,{subtree:J(i,{recursive:!0,list:!0})})}return s}var K="comm",Y="rule",V="decl";var ir="@import";var cr="@keyframes";var ur="@layer";var Q=Math.abs,z=String.fromCharCode;function W(r){return r.trim()}function N(r,e,t){return r.replace(e,t)}function fr(r,e,t){return r.indexOf(e,t)}function T(r,e){return r.charCodeAt(e)|0}function A(r,e,t){return r.slice(e,t)}function g(r){return r.length}function B(r){return r.length}function R(r,e){return e.push(r),r}var G=1,M=1,pr=0,b=0,f=0,P="";function Z(r,e,t,n,s,a,i,o){return{value:r,root:e,parent:t,type:n,props:s,children:a,line:G,column:M,length:i,return:"",siblings:o}}function lr(){return f}function hr(){return f=b>0?T(P,--b):0,M--,f===10&&(M=1,G--),f}function w(){return f=b<pr?T(P,b++):0,M++,f===10&&(M=1,G++),f}function k(){return T(P,b)}function _(){return b}function q(r,e){return A(P,r,e)}function $(r){switch(r){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function mr(r){return G=M=1,pr=g(P=r),b=0,[]}function gr(r){return P="",r}function H(r){return W(q(b-1,rr(r===91?r+2:r===40?r+1:r)))}function xr(r){for(Line truncated
|
||||
/**
|
||||
* shorthash - https://github.com/bibig/node-shorthash
|
||||
*
|
||||
* @license
|
||||
*
|
||||
* (The MIT License)
|
||||
*
|
||||
* Copyright (c) 2013 Bibig <bibig@me.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
* obtaining a copy of this software and associated documentation
|
||||
* files (the "Software"), to deal in the Software without
|
||||
* restriction, including without limitation the rights to use,
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following
|
||||
* conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be
|
||||
* included in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../node_modules/.pnpm/parsel-js@1.1.2/node_modules/parsel-js/dist/parsel.min.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Enum.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Utility.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Tokenizer.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Parser.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Serializer.js", "../../node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Middleware.js", "../../src/transformers/scope.ts"],
|
||||
"sourcesContent": ["const e={attribute:/\\[\\s*(?:(?<namespace>\\*|[-\\w\\P{ASCII}]*)\\|)?(?<name>[-\\w\\P{ASCII}]+)\\s*(?:(?<operator>\\W?=)\\s*(?<value>.+?)\\s*(\\s(?<caseSensitive>[iIsS]))?\\s*)?\\]/gu,id:/#(?<name>[-\\w\\P{ASCII}]+)/gu,class:/\\.(?<name>[-\\w\\P{ASCII}]+)/gu,comma:/\\s*,\\s*/g,combinator:/\\s*[\\s>+~]\\s*/g,\"pseudo-element\":/::(?<name>[-\\w\\P{ASCII}]+)(?:\\((?<argument>\u00B6*)\\))?/gu,\"pseudo-class\":/:(?<name>[-\\w\\P{ASCII}]+)(?:\\((?<argument>\u00B6*)\\))?/gu,universal:/(?:(?<namespace>\\*|[-\\w\\P{ASCII}]*)\\|)?\\*/gu,type:/(?:(?<namespace>\\*|[-\\w\\P{ASCII}]*)\\|)?(?<name>[-\\w\\P{ASCII}]+)/gu},t=new Set([\"combinator\",\"comma\"]),n=new Set([\"not\",\"is\",\"where\",\"has\",\"matches\",\"-moz-any\",\"-webkit-any\",\"nth-child\",\"nth-last-child\"]),s=/(?<index>[\\dn+-]+)\\s+of\\s+(?<subtree>.+)/,o={\"nth-child\":s,\"nth-last-child\":s},r=t=>{switch(t){case\"pseudo-element\":case\"pseudo-class\":return new RegExp(e[t].source.replace(\"(?<argument>\u00B6*)\",\"(?<argument>.*)\"),\"gu\");default:return e[t]}};function c(e,t){let n=0,s=\"\";for(;t<e.length;t++){const o=e[t];switch(o){case\"(\":++n;break;case\")\":--n}if(s+=o,0===n)return s}return s}function i(n,s=e){if(!n)return[];const o=[n];for(const[e,t]of Object.entries(s))for(let n=0;n<o.length;n++){const s=o[n];if(\"string\"!=typeof s)continue;t.lastIndex=0;const r=t.exec(s);if(!r)continue;const c=r.index-1,i=[],a=r[0],l=s.slice(0,c+1);l&&i.push(l),i.push({...r.groups,type:e,content:a});const u=s.slice(c+a.length+1);u&&i.push(u),o.splice(n,1,...i)}let r=0;for(const e of o)switch(typeof e){case\"string\":throw new Error(`Unexpected sequence ${e} found at index ${r}`);case\"object\":r+=e.content.length,e.pos=[r-e.content.length,r],t.has(e.type)&&(e.content=e.content.trim()||\" \")}return o}const a=/(['\"])([^\\\\\\n]+?)\\1/g,l=/\\\\./g;function u(t,n=e){if(\"\"===(t=t.trim()))return[];const s=[];t=(t=t.replace(l,((e,t)=>(s.push({value:e,offset:t}),\"\uE000\".repeat(e.length))))).replace(a,((e,t,n,o)=>(s.push({value:e,offset:o}),`${t}${\"\uE001\".repeat(n.length)}${t}`)));{let e,n=0;for(;(e=t.indexOf(\"(\",n))>-1;){const o=c(t,e);s.push({value:o,offset:e}),t=`${t.substring(0,e)}(${\"\u00B6\".repeat(o.length-2)})${t.substring(e+o.length)}`,n=e+o.length}}const o=i(t,n),u=new Set;for(const e of s.reverse())for(const t of o){const{offset:n,value:s}=e;if(!(t.pos[0]<=n&&n+s.length<=t.pos[1]))continue;const{content:o}=t,r=n-t.pos[0];t.content=o.slice(0,r)+s+o.slice(r+s.length),t.content!==o&&u.add(t)}for(const e of u){const t=r(e.type);if(!t)throw new Error(`Unknown token type: ${e.type}`);t.lastIndex=0;const n=t.exec(e.content);if(!n)throw new Error(`Unable to parse content for ${e.type}: ${e.content}`);Object.assign(e,n.groups)}return o}function f(e,{list:t=!0}={}){if(t&&e.find((e=>\"comma\"===e.type))){const t=[],n=[];for(let s=0;s<e.length;s++)if(\"comma\"===e[s].type){if(0===n.length)throw new Error(\"Incorrect comma at \"+s);t.push(f(n,{list:!1})),n.length=0}else n.push(e[s]);if(0===n.length)throw new Error(\"Trailing comma\");return t.push(f(n,{list:!1})),{type:\"list\",list:t}}for(let t=e.length-1;t>=0;t--){let n=e[t];if(\"combinator\"===n.type){let s=e.slice(0,t),o=e.slice(t+1);return{type:\"complex\",combinator:n.content,left:f(s),right:f(o)}}}switch(e.length){case 0:throw new Error(\"Could not build AST.\");case 1:return e[0];default:return{type:\"compound\",list:[...e]}}}function*p(e,t){switch(e.type){case\"list\":for(let t of e.list)yield*p(t,e);break;case\"complex\":yield*p(e.left,e),yield*p(e.right,e);break;case\"compound\":yield*e.list.map((t=>[t,e]));break;default:yield[e,t]}}function h(e,t,n){if(e)for(const[s,o]of p(e,n))t(s,o)}function m(e,{recursive:t=!0,list:s=!0}={}){const r=u(e);if(!r)return;const c=f(r,{list:s});if(!t)return c;for(const[e]of p(c)){if(\"pseudo-class\"!==e.type||!e.argument)continue;if(!n.has(e.name))continue;let t=e.argument;const s=o[e.name];if(s){const n=s.exec(t);if(!n)continue;Object.assign(e,n.groups),t=n.groups.subtree}t&&Object.assign(e,{subtree:m(t,{recursive:!0,list:!0})})}return c}function g(e){let t;return t=Array.isArray(e)?e:[...p(e)].map((([e])=>e)),t.map((e=>e.content)).join(\"\")}function d(e,t){return t=t||Math.max(...e)+1,e[0]*(t<<1)+e[1]*t+e[2]}function w(e){let t=e;if(\"string\"==typeof t&&(t=m(t,{recursive:!0})),!t)return[];if(\"list\"===t.type&&\"list\"in t){let e=10;const n=t.list.map((t=>{const n=w(t);return e=Math.max(e,...w(t)),n})),s=n.map((t=>d(t,e)));return n[s.indexOf(Math.max(...s))]}const s=[0,0,0];for(const[e]of p(t))switch(e.type){case\"id\":s[0]++;break;case\"class\":case\"attribute\":s[1]++;break;case\"pseudo-element\":case\"type\":s[2]++;break;case\"pseudo-class\":if(\"where\"===e.name)break;if(!n.has(e.name)||!e.subtree){s[1]++;break}w(e.subtree).forEach(((e,t)=>s[t]+=e)),\"nth-child\"!==e.name&&\"nth-last-child\"!==e.name||s[1]++}return s}export{n as RECURSIVE_PSEUDO_CLASSES,o as RECURSIVE_PSEUDO_CLASSES_ARGS,e as TOKENS,t as TRIM_TOKENS,p as flatten,cLine truncated
|
||||
"mappings": "AAAA,IAAMA,EAAE,CAAC,UAAU,uJAAuJ,GAAG,8BAA8B,MAAM,+BAA+B,MAAM,WAAW,WAAW,iBAAiB,iBAAiB,uDAAuD,eAAe,sDAAsD,UAAU,8CAA8C,KAAK,mEAAmE,EAAEC,GAAE,IAAI,IAAI,CAAC,aAAa,OAAO,CAAC,EAAEC,GAAE,IAAI,IAAI,CAAC,MAAM,KAAK,QAAQ,MAAM,UAAU,WAAW,cAAc,YAAY,gBAAgB,CAAC,EAAEC,GAAE,2CAA2CC,GAAE,CAAC,YAAYD,GAAE,iBAAiBA,EAAC,EAAEE,GAAEJ,GAAG,CAAC,OAAOA,EAAE,CAAC,IAAI,iBAAiB,IAAI,eAAe,OAAO,IAAI,OAAOD,EAAEC,CAAC,EAAE,OAAO,QAAQ,qBAAkB,iBAAiB,EAAE,IAAI,EAAE,QAAQ,OAAOD,EAAEC,CAAC,CAAC,CAAC,EAAE,SAASK,GAAEN,EAAEC,EAAE,CAAC,IAAIC,EAAE,EAAEC,EAAE,GAAG,KAAKF,EAAED,EAAE,OAAOC,IAAI,CAAC,IAAMG,EAAEJ,EAAEC,CAAC,EAAE,OAAOG,EAAE,CAAC,IAAI,IAAI,EAAEF,EAAE,MAAM,IAAI,IAAI,EAAEA,CAAC,CAAC,GAAGC,GAAGC,EAAMF,IAAJ,EAAM,OAAOC,CAAC,CAAC,OAAOA,CAAC,CAAC,SAASI,GAAEL,EAAEC,EAAEH,EAAE,CAAC,GAAG,CAACE,EAAE,MAAM,CAAC,EAAE,IAAME,EAAE,CAACF,CAAC,EAAE,OAAS,CAACF,EAAEC,CAAC,IAAI,OAAO,Q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,aAIhB,IAAIC,GAAQ,SChBZ,IAAIC,EAAM,KAAK,ILine truncated
|
||||
"names": ["e", "t", "n", "s", "o", "r", "c", "i", "a", "l", "u", "f", "p", "m", "e", "t", "s", "r", "u", "c", "f", "p", "n", "o", "COMMENT", "RULESET", "DECLARATION", "IMPORT", "KEYFRAMES", "LAYER", "abs", "from", "trim", "value", "replace", "value", "pattern", "replacement", "indexof", "search", "position", "charat", "index", "substr", "begin", "end", "strlen", "sizeof", "append", "array", "line", "column", "length", "position", "character", "characters", "node", "value", "root", "parent", "type", "props", "children", "siblings", "char", "character", "prev", "position", "charat", "characters", "column", "line", "next", "length", "peek", "caret", "slice", "begin", "end", "substr", "token", "type", "alloc", "value", "strlen", "dealloc", "delimit", "trim", "delimiter", "whitespace", "type", "character", "peek", "next", "token", "escaping", "index", "count", "next", "character", "slice", "caret", "peek", "delimiter", "type", "position", "commenter", "from", "identifier", "token", "compile", "value", "dealloc", "parse", "alloc", "root", "parent", "rule", "rules", "rulesets", "pseudo", "points", "declarations", "index", "offset", "length", "atrule", "property", "previous", "variable", "scanning", "ampersand", "character", "type", "props", "children", "reference", "characters", "next", "charat", "indexof", "replace", "delimit", "abs", "whitespace", "escaping", "caret", "peek", "append", "comment", "commenter", "token", "strlen", "substr", "declaration", "ruleset", "prev", "from", "identifier", "siblings", "post", "size", "sizeof", "i", "j", "k", "x", "y", "z", "trim", "node", "RULESET", "COMMENT", "char", "DECLARATION", "serialize", "children", "callback", "output", "i", "stringify", "element", "index", "LAYER", "IMPORT", "DECLARATION", "COMMENT", "KEYFRAMES", "RULESET", "strlen", "middleware", "collection", "length", "sizeof", "element", "index", "children", "callback", "output", "i", "ELEMENT_NODE", "TEXT_NODE", "render", "walkSync", "matches", "scope", "opts", "doc", "hash", "shorthash", "actions", "hasStyle", "selectors", "nodes", "node", "hasAttribute", "selector", "getSelectors", "scopeElement", "scopeCSS", "s", "action", "NEVER_SCOPED", "name", "scopeSelector", "ast", "m", "left", "right", "combinator", "css", "serialize", "compile", "middleware", "element", "prop", "stringify", "p", "dictionary", "binary", "bitwise", "str", "i", "ch", "text", "num", "result", "integer", "sign"]
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// Generated by dts-bundle-generator v9.5.1
|
||||
|
||||
type Node$1 = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
|
||||
type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
|
||||
interface Location$1 {
|
||||
start: number;
|
||||
end: number;
|
||||
}
|
||||
interface BaseNode {
|
||||
type: NodeType;
|
||||
loc: [
|
||||
Location$1,
|
||||
Location$1
|
||||
];
|
||||
parent: Node$1;
|
||||
[key: string]: any;
|
||||
}
|
||||
interface LiteralNode extends BaseNode {
|
||||
value: string;
|
||||
}
|
||||
interface ParentNode$1 extends BaseNode {
|
||||
children: Node$1[];
|
||||
}
|
||||
interface DocumentNode extends Omit<ParentNode$1, "parent"> {
|
||||
type: typeof DOCUMENT_NODE;
|
||||
attributes: Record<string, string>;
|
||||
parent: undefined;
|
||||
}
|
||||
interface ElementNode extends ParentNode$1 {
|
||||
type: typeof ELEMENT_NODE;
|
||||
name: string;
|
||||
attributes: Record<string, string>;
|
||||
}
|
||||
interface TextNode extends LiteralNode {
|
||||
type: typeof TEXT_NODE;
|
||||
}
|
||||
interface CommentNode extends LiteralNode {
|
||||
type: typeof COMMENT_NODE;
|
||||
}
|
||||
interface DoctypeNode extends LiteralNode {
|
||||
type: typeof DOCTYPE_NODE;
|
||||
}
|
||||
declare const DOCUMENT_NODE = 0;
|
||||
declare const ELEMENT_NODE = 1;
|
||||
declare const TEXT_NODE = 2;
|
||||
declare const COMMENT_NODE = 3;
|
||||
declare const DOCTYPE_NODE = 4;
|
||||
declare function swap(components?: Record<string, string | ((props: Record<string, any>, ...children: any[]) => any)>): (doc: Node$1) => Node$1;
|
||||
|
||||
export {
|
||||
swap as default,
|
||||
};
|
||||
|
||||
export {};
|
||||
+1
@@ -0,0 +1 @@
|
||||
import{RenderFn as r}from"../index.js";import{__unsafeRenderFn as i}from"../index.js";import{querySelectorAll as s}from"../selector.js";function d(t={}){return o=>{for(let[f,e]of Object.entries(t))for(let n of s(o,f))typeof e=="string"?(n.name=e,r in n&&delete n[r]):typeof e=="function"&&i(n,e);return o}}export{d as default};
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"version": 3,
|
||||
"sources": ["../../src/transformers/swap.ts"],
|
||||
"sourcesContent": ["import { ElementNode, RenderFn } from '../index.js';\nimport { Node, __unsafeRenderFn } from '../index.js';\nimport { querySelectorAll } from '../selector.js';\n\nexport default function swap(\n\tcomponents: Record<\n\t\tstring,\n\t\tstring | ((props: Record<string, any>, ...children: any[]) => any)\n\t> = {},\n) {\n\treturn (doc: Node): Node => {\n\t\tfor (const [selector, component] of Object.entries(components)) {\n\t\t\tfor (const node of querySelectorAll(doc, selector)) {\n\t\t\t\tif (typeof component === 'string') {\n\t\t\t\t\tnode.name = component;\n\t\t\t\t\tif (RenderFn in node) {\n\t\t\t\t\t\tdelete (node as any)[RenderFn];\n\t\t\t\t\t}\n\t\t\t\t} else if (typeof component === 'function') {\n\t\t\t\t\t__unsafeRenderFn(node as ElementNode, component);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn doc;\n\t};\n}\n"],
|
||||
"mappings": "AAAA,OAAsB,YAAAA,MAAgB,cACtC,OAAe,oBAAAC,MAAwB,cACvC,OAAS,oBAAAC,MAAwB,iBAElB,SAARC,EACNC,EAGI,CAAC,EACJ,CACD,OAAQC,GAAoB,CAC3B,OAAW,CAACC,EAAUC,CAAS,IAAK,OAAO,QAAQH,CAAU,EAC5D,QAAWI,KAAQN,EAAiBG,EAAKC,CAAQ,EAC5C,OAAOC,GAAc,UACxBC,EAAK,KAAOD,EACRP,KAAYQ,GACf,OAAQA,EAAaR,CAAQ,GAEpB,OAAOO,GAAc,YAC/BN,EAAiBO,EAAqBD,CAAS,EAIlD,OAAOF,CACR,CACD",
|
||||
"names": ["RenderFn", "__unsafeRenderFn", "querySelectorAll", "swap", "components", "doc", "selector", "component", "node"]
|
||||
}
|
||||
Reference in new issue
Block a user