initial commit

This commit is contained in:
Zoe
2023-01-03 09:29:04 -06:00
commit 7851137d88
12889 changed files with 2557443 additions and 0 deletions

277
node_modules/ultrahtml/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,277 @@
# ultrahtml
## 1.2.0
### Minor Changes
- 7792f5d: Add `useObjectSyntax` option to inline transformer. Note that this option is currently not compatible with `transform`
## 1.1.0
### Minor Changes
- d910619: Remove `resolveAsset` option from `inline` transformer, making it synchronous again.
## 1.0.4
### Patch Changes
- c5799aa: Update attribute handling to account for attributes with newlines
## 1.0.3
### Patch Changes
- d7cb17d: Fix another edge case with text inside script/styles
## 1.0.2
### Patch Changes
- c7a1ef6: Fix edge case with `<script>` parsing
## 1.0.1
### Patch Changes
- b136e51: Fix unhandled edge case with `sanitize` transformer
- dce0b68: Fix style and script elements having their contents parsed as HTML
## 1.0.0
### Major Changes
- 95c0f73: `ultrahtml` is a complete markup toolkit with a tiny footprint. Parse, transform, and render HTML on the server, in the browser, with or without a build step.
## Breaking Changes
The signature of `transform` has been updated. Rather than applying sanitization and component swapping by default, these have been split out to individual `ultrahtml/transformers` that can be applied modularly.
In `ultrahtml@0.x`, `transform` accepted an options object with `sanitize` and `components`. Other transformations would need to be applied outside of this flow.
```js
import { transform } from "ultrahtml";
await transform(markup, {
components: { h1: "h2" },
sanitize: { allowElements: ["h1", "h2", "h3"] }
});
```
In `ultrahtml@1.x`, `transform` accepts an array of transformers to apply. The `sanitize` and `components` options can be handled with the built-in transformers named `sanitize` and `swap`.
```js
import { transform } from "ultrahtml";
import swap from "ultrahtml/transformers/swap";
import sanitize from "ultrahtml/transformers/sanitize";
await transform(markup, [
swap({ h1: "h2" }),
sanitize({ allowElements: ["h1", "h2", "h3"] })
]);
```
## New Features
### JSX Runtime
`ultrahtml` now comes with `h` and `Fragment` functions for JSX, as well as a `jsx-runtime` export.
### Tranformers
Transformers are AST transformations that can be applied to any `ultrahtml` Node. Usually these are applied to entire documents.
**New** `inline` transformer inlines CSS from `<style>` blocks directly to matching elements.
**New** `scope` transformer scopes CSS from `<style>` blocks to the elements in a given document or component.
### Patch Changes
- 4699020: Update JSX runtime child handling
- da119c1: Fix transformer definitions
- d29a0e2: Add `resolveAsset` option to the `inline` transformer
- 401b13a: Fix JSX runtime types
- 44a771e: Update list of void HTML tags
## 1.0.0-next.4
### Patch Changes
- d29a0e2: Add `resolveAsset` option to the `inline` transformer
## 1.0.0-next.3
### Patch Changes
- 4699020: Update JSX runtime child handling
## 1.0.0-next.2
### Patch Changes
- 401b13a: Fix JSX runtime types
## 1.0.0-next.1
### Patch Changes
- da119c1: Fix transformer definitions
## 1.0.0-next.0
### Major Changes
- 95c0f73: `ultrahtml` is a complete markup toolkit with a tiny footprint. Parse, transform, and render HTML on the server, in the browser, with or without a build step.
## Breaking Changes
The signature of `transform` has been updated. Rather than applying sanitization and component swapping by default, these have been split out to individual `ultrahtml/transformers` that can be applied modularly.
In `ultrahtml@0.x`, `transform` accepted an options object with `sanitize` and `components`. Other transformations would need to be applied outside of this flow.
```js
import { transform } from "ultrahtml";
await transform(markup, {
components: { h1: "h2" },
sanitize: { allowElements: ["h1", "h2", "h3"] }
});
```
In `ultrahtml@1.x`, `transform` accepts an array of transformers to apply. The `sanitize` and `components` options can be handled with the built-in transformers named `sanitize` and `swap`.
```js
import { transform } from "ultrahtml";
import swap from "ultrahtml/transformers/swap";
import sanitize from "ultrahtml/transformers/sanitize";
await transform(markup, [
swap({ h1: "h2" }),
sanitize({ allowElements: ["h1", "h2", "h3"] })
]);
```
## New Features
### JSX Runtime
`ultrahtml` now comes with `h` and `Fragment` functions for JSX, as well as a `jsx-runtime` export.
### Tranformers
Transformers are AST transformations that can be applied to any `ultrahtml` Node. Usually these are applied to entire documents.
**New** `inline` transformer inlines CSS from `<style>` blocks directly to matching elements.
**New** `scope` transformer scopes CSS from `<style>` blocks to the elements in a given document or component.
## 0.4.0
### Minor Changes
- 83c2e35: Improve declarations for node types
## 0.3.3
### Patch Changes
- 3b8fb6e: Remove bundledDependencies field
## 0.3.2
### Patch Changes
- 74010dd: Bundle parsel-js to avoid ESM/CJS issues
- d7b514d: Fix CJS compat issue (again)
## 0.3.1
### Patch Changes
- a105c5e: Fix CJS compat issue
## 0.3.0
### Minor Changes
- 2de70f3: Add `ultrahtml/selector` module which exports `querySelector`, `querySelectorAll`, and `matches` functions.
To use `querySelectorAll`, pass the root `Node` as the first argument and any valid CSS selector as the second argument. Note that if a CSS selector you need is not yet implemented, you are invited to [open an issue](https://github.com/natemoo-re/ultrahtml/issues).
```js
import { parse } from "ultrahtml";
import { querySelectorAll, matches } from "ultrahtml/selector";
const doc = parse(`
<html>
<head>
<title>Demo</title>
/head>
<body>
<h1>Hello world!</h1>
</body>
</html>
`);
const h1 = querySelector(doc, "h1");
const match = matches(h1, "h1");
```
## 0.2.1
### Patch Changes
- 037711f: Update types
## 0.2.0
### Minor Changes
- 97b297f: Add `walkSync` export
## 0.1.3
### Patch Changes
- 123f7ea: Fix custom elements transform.
## 0.1.2
### Patch Changes
- 758bbba: Improve documentation
## 0.1.1
### Patch Changes
- 2f92e93: Export node types
## 0.1.0
### Minor Changes
- 517e24d: Fix edge cases with text node detection, refactor for compactness
## 0.0.5
### Patch Changes
- 23771a3: Fix `walk` function definition
## 0.0.4
### Patch Changes
- 4d082b3: Ensure types are included
## 0.0.3
### Patch Changes
- e0e8a2b: Add `__unsafeHTML` export
## 0.0.2
### Patch Changes
- f6e3a71: Support async components

35
node_modules/ultrahtml/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,35 @@
MIT License Copyright (c) 2022 Nate Moore
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
(including the next paragraph) 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.
---
Portions of this code were borrowed from https://github.com/developit/htmlParser
The MIT License (MIT)
Copyright (c) 2013 Jason Miller
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.

98
node_modules/ultrahtml/README.md generated vendored Normal file
View File

@@ -0,0 +1,98 @@
# `ultrahtml`
A 1.75kB library for enhancing `html`. `ultrahtml` has zero dependencies and is compatible with any JavaScript runtime.
### Features
- Tiny, fault-tolerant and friendly HTML-like parser. Works with HTML, Astro, Vue, Svelte, and any other HTML-like syntax.
- Built-in AST `walk` utility
- Built-in `transform` utility for easy output manipulation
- Automatic but configurable sanitization, see [Sanitization](#sanitization)
- Handy `html` template utility
- `querySelector` and `querySelectorAll` support using `ultrahtml/selector`
#### `walk`
The `walk` function provides full control over the AST. It can be used to scan for text, elements, components, or any other validation you might want to do.
> **Note** > `walk` is `async` and **must** be `await`ed. Use `walkSync` if it is guaranteed there are no `async` components in the tree.
```js
import { parse, walk, ELEMENT_NODE } from "ultrahtml";
const ast = parse(`<h1>Hello world!</h1>`);
await walk(ast, async (node) => {
if (node.type === ELEMENT_NODE && node.name === "script") {
throw new Error("Found a script!");
}
});
```
#### `walkSync`
The `walkSync` function is identical to the `walk` function, but is synchronous. This should only be used when it is guaranteed there are no `async` components in the tree.
```js
import { parse, walkSync, ELEMENT_NODE } from "ultrahtml";
const ast = parse(`<h1>Hello world!</h1>`);
walkSync(ast, (node) => {
if (node.type === ELEMENT_NODE && node.name === "script") {
throw new Error("Found a script!");
}
});
```
#### `render`
The `render` function allows you to serialize an AST back into a string.
> **Note**
> By default, `render` will sanitize your markup, removing any `script` tags. Pass `{ sanitize: false }` to disable this behavior.
```js
import { parse, render } from "ultrahtml";
const ast = parse(`<h1>Hello world!</h1>`);
const output = await render(ast);
```
#### `transform`
The `transform` function provides a straight-forward way to modify any markup. Sanitize content, swap in-place elements/Components, and more using a set of built-in transformers, or write your own custom transformer.
```js
import { transform, html } from "ultrahtml";
import swap from "ultrahtml/transformers/swap";
import sanitize from "ultrahtml/transformers/sanitize";
const output = await transform(`<h1>Hello world!</h1>`, [
swap({
h1: "h2",
h3: (props, children) => html`<h2 class="ultra">${children}</h2>`,
}),
sanitize({ allowElements: ["h1", "h2", "h3"] }),
]);
console.log(output); // <h2>Hello world!</h2>
```
#### Sanitization
`ultrahtml/transformers/sanitize` implements an extension of the [HTML Sanitizer API](https://developer.mozilla.org/en-US/docs/Web/API/Sanitizer/Sanitizer).
| Option | Type | Default | Description |
| ------------------- | -------------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| allowElements | `string[]` | `undefined` | An array of strings indicating elements that the sanitizer should not remove. All elements not in the array will be dropped. |
| blockElements | `string[]` | `undefined` | An array of strings indicating elements that the sanitizer should remove, but keep their child elements. |
| dropElements | `string[]` | `["script"]` | An array of strings indicating elements (including nested elements) that the sanitizer should remove. |
| allowAttributes | `Record<string, string[]>` | `undefined` | 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. |
| dropAttributes | `Record<string, string[]>` | `undefined` | An object where each key is the attribute name and the value is an Array of dropped tag names. Matching attributes will be removed. |
| allowComponents | `boolean` | `false` | 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). |
| allowCustomElements | `boolean` | `false` | 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). |
| allowComments | `boolean` | `false` | A boolean value set to false (default) to remove HTML comments. Set to true in order to keep comments. |
## Acknowledgements
- [Jason Miller](https://twitter.com/_developit)'s [`htmlParser`](https://github.com/developit/htmlParser) provided a great, lightweight base for this parser
- [Titus Wormer](https://twitter.com/wooorm)'s [`mdx`](https://mdxjs.com) for inspiration

70
node_modules/ultrahtml/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,70 @@
export declare type Node = DocumentNode | ElementNode | TextNode | CommentNode | DoctypeNode;
export declare type NodeType = typeof DOCUMENT_NODE | typeof ELEMENT_NODE | typeof TEXT_NODE | typeof COMMENT_NODE | typeof DOCTYPE_NODE;
export interface Location {
start: number;
end: number;
}
interface BaseNode {
type: NodeType;
loc: [Location, Location];
parent: Node;
[key: string]: any;
}
interface LiteralNode extends BaseNode {
value: string;
}
interface ParentNode extends BaseNode {
children: Node[];
}
export interface DocumentNode extends Omit<ParentNode, "parent"> {
type: typeof DOCUMENT_NODE;
attributes: Record<string, string>;
parent: undefined;
}
export interface ElementNode extends ParentNode {
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, parent?: Node, index?: number): void | Promise<void>;
}
export interface VisitorSync {
(node: Node, parent?: Node, 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[]) => Node): 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, callback: Visitor): Promise<void>;
export declare function walkSync(node: Node, callback: VisitorSync): void;
export declare function render(node: Node): Promise<string>;
export interface Transformer {
(node: Node): Node | Promise<Node>;
}
export declare function transform(markup: string | Node, transformers?: Transformer[]): Promise<string>;
export {};

1
node_modules/ultrahtml/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
var A=0,L=1,R=2,k=3,$=4;function X(t,n={},...o){let r={type:1,name:typeof t=="function"?t.name:t,attributes:n||{},children:o.map(e=>typeof e=="string"?{type:2,value:O(String(e))}:e),parent:void 0,loc:[]};return typeof t=="function"&&w(r,t),r}var S=Symbol("Fragment"),_=new Set(["area","base","br","col","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"]),g=new Set(["script","style"]),v=/([\@\.a-z0-9_\:\-]*)\s*?=?\s*?(['"]?)([\s\S]*?)\2\s+/gim,i=/(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm;function M(t){let n={},o;if(t)for(v.lastIndex=0,t=" "+(t||"")+" ";o=v.exec(t);)o[0]!==" "&&(n[o[1]]=o[3]);return n}function P(t){let n=typeof t=="string"?t:t.value,o,r,e,s,l,d,N,E,a,c=[];i.lastIndex=0,r=o={type:0,children:[]};let u=0;function y(){s=n.substring(u,i.lastIndex-e[0].length),s&&r.children.push({type:2,value:s,parent:r})}for(;e=i.exec(n);){if(d=e[5]||e[8],N=e[6]||e[9],E=e[7]||e[10],g.has(r.name)&&e[2]!==r.name){l=i.lastIndex-e[0].length,r.children.length>0&&(r.children[0].value+=e[0]);continue}else if(d==="<!--"){if(l=i.lastIndex-e[0].length,g.has(r.name))continue;a={type:3,value:N,parent:r,loc:[{start:l,end:l+d.length},{start:i.lastIndex-E.length,end:i.lastIndex}]},c.push(a),a.parent.children.push(a)}else if(d==="<!")l=i.lastIndex-e[0].length,a={type:4,value:N,parent:r,loc:[{start:l,end:l+d.length},{start:i.lastIndex-E.length,end:i.lastIndex}]},c.push(a),a.parent.children.push(a);else if(e[1]!=="/")if(y(),g.has(r.name)){u=i.lastIndex,y();continue}else a={type:1,name:e[2]+"",attributes:M(e[3]),parent:r,children:[],loc:[{start:i.lastIndex-e[0].length,end:i.lastIndex}]},c.push(a),a.parent.children.push(a),e[4]&&e[4].indexOf("/")>-1||_.has(a.name)?(a.loc[1]=a.loc[0],a.isSelfClosingTag=!0):r=a;else y(),e[2]+""===r.name?(a=r,r=a.parent,a.loc.push({start:i.lastIndex-e[0].length,end:i.lastIndex}),s=n.substring(a.loc[0].end,a.loc[1].start),a.children.length===0&&a.children.push({type:2,value:s,parent:r})):e[2]+""===c[c.length-1].name&&c[c.length-1].isSelfClosingTag===!0&&(a=c[c.length-1],a.loc.push({start:i.lastIndex-e[0].length,end:i.lastIndex}));u=i.lastIndex}return s=n.slice(u),r.children.push({type:2,value:s,parent:r}),o}var h=class{constructor(n){this.callback=n}async visit(n,o,r){if(await this.callback(n,o,r),Array.isArray(n.children)){let e=[];for(let s=0;s<n.children.length;s++){let l=n.children[s];e.push(this.visit(l,n,s))}await Promise.all(e)}}},m=class{constructor(n){this.callback=n}visit(n,o,r){if(this.callback(n,o,r),Array.isArray(n.children))for(let e=0;e<n.children.length;e++){let s=n.children[e];this.visit(s,n,e)}}},p=Symbol("HTMLString"),b=Symbol("AttrString"),x=Symbol("RenderFn");function f(t,n=[p]){let o={value:t};for(let r of n)Object.defineProperty(o,r,{value:!0,enumerable:!1,writable:!1});return o}function j(t){return f(t)}function w(t,n){return Object.defineProperty(t,x,{value:n,enumerable:!1}),t}var I={"&":"&amp;","<":"&lt;",">":"&gt;"};function O(t){return t.replace(/[&<>]/g,n=>I[n]||n)}function T(t){let n="";for(let[o,r]of Object.entries(t))n+=` ${o}="${r}"`;return f(n,[p,b])}function V(t,...n){let o="";for(let r=0;r<t.length;r++){o+=t[r];let e=n[r];o.endsWith("...")&&e&&typeof e=="object"?(o=o.slice(0,-3).trimEnd(),o+=T(e).value):e&&e[b]?(o=o.trimEnd(),o+=e.value):e&&e[p]?o+=e.value:typeof e=="string"?o+=O(e):(e||e===0)&&(o+=String(e))}return f(o)}function F(t,n){return new h(n).visit(t)}function H(t,n){return new m(n).visit(t)}async function C(t){let{name:n,attributes:o={}}=t,r=await Promise.all(t.children.map(e=>D(e))).then(e=>e.join(""));if(x in t){let e=await t[x](o,f(r));return e&&e[p]?e.value:O(String(e))}return n===S?r:_.has(n)?`<${t.name}${T(o).value}>`:`<${t.name}${T(o).value}>${r}</${t.name}>`}async function D(t){switch(t.type){case 0:return Promise.all(t.children.map(n=>D(n))).then(n=>n.join(""));case 1:return C(t);case 2:return`${t.value}`;case 3:return`<!--${t.value}-->`;case 4:return`<!${t.value}>`}}async function U(t,n=[]){if(!Array.isArray(n))throw new Error(`Invalid second argument for \`transform\`! Expected \`Transformer[]\` but got \`${typeof n}\``);let r=typeof t=="string"?P(t):t;for(let e of n)r=await e(r);return D(r)}export{k as COMMENT_NODE,$ as DOCTYPE_NODE,A as DOCUMENT_NODE,L as ELEMENT_NODE,S as Fragment,x as RenderFn,R as TEXT_NODE,j as __unsafeHTML,w as __unsafeRenderFn,T as attrs,X as h,V as html,P as parse,D as render,U as transform,F as walk,H as walkSync};

7
node_modules/ultrahtml/dist/index.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

4
node_modules/ultrahtml/dist/jsx-runtime/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,4 @@
import { ElementNode } from "../index.js";
import { Fragment } from "../index.js";
declare function createVNode(type: any, { children, ...attributes }: Record<string, any>, key: string, __self: string, __source: string): ElementNode;
export { createVNode as jsx, createVNode as jsxs, createVNode as jsxDEV, Fragment, };

1
node_modules/ultrahtml/dist/jsx-runtime/index.js generated vendored Normal file
View File

@@ -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
node_modules/ultrahtml/dist/jsx-runtime/index.js.map generated vendored Normal file
View File

@@ -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 type: any,\n { children, ...attributes }: Record<string, any>,\n key: string,\n __self: string,\n __source: string\n) {\n const vnode: ElementNode = {\n type: ELEMENT_NODE,\n name: typeof type === \"function\" ? type.name : type,\n attributes,\n children: (Array.isArray(children) ? children : [children]).map((child) => {\n if (typeof child === \"string\") {\n return {\n type: TEXT_NODE,\n value: child,\n };\n }\n return child;\n }),\n parent: undefined as any,\n loc: [] as any,\n };\n\n if (typeof type === \"function\") {\n __unsafeRenderFn(vnode, type);\n }\n\n return vnode;\n}\n\nexport {\n createVNode as jsx,\n createVNode as jsxs,\n createVNode as jsxDEV,\n Fragment,\n};\n"],
"mappings": "AAAA,OAA4B,aAAAA,MAAiB,cAC7C,OAAS,gBAAAC,EAAc,YAAAC,EAAU,oBAAAC,MAAwB,cAEzD,SAASC,EACPC,EACA,CAAE,SAAAC,KAAaC,CAAW,EAC1BC,EACAC,EACAC,EACA,CACA,IAAMC,EAAqB,CACzB,KAAMV,EACN,KAAM,OAAOI,GAAS,WAAaA,EAAK,KAAOA,EAC/C,WAAAE,EACA,UAAW,MAAM,QAAQD,CAAQ,EAAIA,EAAW,CAACA,CAAQ,GAAG,IAAKM,GAC3D,OAAOA,GAAU,SACZ,CACL,KAAMZ,EACN,MAAOY,CACT,EAEKA,CACR,EACD,OAAQ,OACR,IAAK,CAAC,CACR,EAEA,OAAI,OAAOP,GAAS,YAClBF,EAAiBQ,EAAON,CAAI,EAGvBM,CACT",
"names": ["TEXT_NODE", "ELEMENT_NODE", "Fragment", "__unsafeRenderFn", "createVNode", "type", "children", "attributes", "key", "__self", "__source", "vnode", "child"]
}

6
node_modules/ultrahtml/dist/selector.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import type { Node } from './index.js';
export declare function specificity(selector: string): number;
export declare function matches(node: Node, selector: string): boolean;
export declare function querySelector(node: Node, selector: string): Node;
export declare function querySelectorAll(node: Node, selector: string): Node[];
export default querySelectorAll;

1
node_modules/ultrahtml/dist/selector.js generated vendored Normal file

File diff suppressed because one or more lines are too long

7
node_modules/ultrahtml/dist/selector.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

6
node_modules/ultrahtml/dist/transformers/inline.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { Node } from "../index.js";
export interface InlineOptions {
/** Emit `style` attributes as objects rather than strings. */
useObjectSyntax?: boolean;
}
export default function inline(opts?: InlineOptions): (doc: Node) => Node;

2
node_modules/ultrahtml/dist/transformers/inline.js generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import{walkSync as ue,ELEMENT_NODE as le,TEXT_NODE as xe}from"../index.js";import{querySelectorAll as me,specificity as fe}from"../selector.js";var Y="comm",q="rule",B="decl";var G=Math.abs,C=String.fromCharCode;function D(e){return e.trim()}function P(e,r,a){return e.replace(r,a)}function X(e,r){return e.indexOf(r)}function M(e,r){return e.charCodeAt(r)|0}function A(e,r,a){return e.slice(r,a)}function O(e){return e.length}function Z(e){return e.length}function R(e,r){return r.push(e),e}var _=1,S=1,J=0,h=0,c=0,j="";function z(e,r,a,p,u,E,w){return{value:e,root:r,parent:a,type:p,props:u,children:E,line:_,column:S,length:w,return:""}}function Q(){return c}function ee(){return c=h>0?M(j,--h):0,S--,c===10&&(S=1,_--),c}function d(){return c=h<J?M(j,h++):0,S++,c===10&&(S=1,_++),c}function T(){return M(j,h)}function I(){return h}function F(e,r){return A(j,e,r)}function H(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 re(e){return _=S=1,J=O(j=e),h=0,[]}function te(e){return j="",e}function $(e){return D(F(h-1,K(e===91?e+2:e===40?e+1:e)))}function ne(e){for(;(c=T())&&c<33;)d();return H(e)>2||H(c)>3?"":" "}function oe(e,r){for(;--r&&d()&&!(c<48||c>102||c>57&&c<65||c>70&&c<97););return F(e,I()+(r<6&&T()==32&&d()==32))}function K(e){for(;d();)switch(c){case e:return h;case 34:case 39:e!==34&&e!==39&&K(c);break;case 40:e===41&&K(e);break;case 92:d();break}return h}function ae(e,r){for(;d()&&e+c!==47+10;)if(e+c===42+42&&T()===47)break;return"/*"+F(r,h-1)+"*"+C(e===47?e:d())}function ce(e){for(;!H(T());)d();return F(e,h)}function V(e){return te(W("",null,null,null,[""],e=re(e),0,[0],e))}function W(e,r,a,p,u,E,w,m,k){for(var n=0,f=0,t=w,s=0,i=0,l=0,b=1,L=1,v=1,x=0,N="",U=u,y=E,g=p,o=N;L;)switch(l=x,x=d()){case 40:if(l!=108&&M(o,t-1)==58){X(o+=P($(x),"&","&\f"),"&\f")!=-1&&(v=-1);break}case 34:case 39:case 91:o+=$(x);break;case 9:case 10:case 13:case 32:o+=ne(l);break;case 92:o+=oe(I()-1,7);continue;case 47:switch(T()){case 42:case 47:R(pe(ae(d(),I()),r,a),k);break;default:o+="/"}break;case 123*b:m[n++]=O(o)*v;case 125*b:case 59:case 0:switch(x){case 0:case 125:L=0;case 59+f:i>0&&O(o)-t&&R(i>32?ie(o+";",p,a,t-1):ie(P(o," ","")+";",p,a,t-2),k);break;case 59:o+=";";default:if(R(g=se(o,r,a,n,f,u,m,N,U=[],y=[],t),E),x===123)if(f===0)W(o,r,g,g,U,E,t,m,y);else switch(s){case 100:case 109:case 115:W(e,g,g,p&&R(se(e,g,g,0,0,u,m,N,u,U=[],t),y),u,y,t,m,p?U:y);break;default:W(o,g,g,g,[""],y,0,m,y)}}n=f=i=0,b=v=1,N=o="",t=w;break;case 58:t=1+O(o),i=l;default:if(b<1){if(x==123)--b;else if(x==125&&b++==0&&ee()==125)continue}switch(o+=C(x),x*b){case 38:v=f>0?1:(o+="\f",-1);break;case 44:m[n++]=(O(o)-1)*v,v=1;break;case 64:T()===45&&(o+=$(d())),s=T(),f=t=O(N=o+=ce(I())),x++;break;case 45:l===45&&O(o)==2&&(b=0)}}return E}function se(e,r,a,p,u,E,w,m,k,n,f){for(var t=u-1,s=u===0?E:[""],i=Z(s),l=0,b=0,L=0;l<p;++l)for(var v=0,x=A(e,t+1,t=G(b=w[l])),N=e;v<i;++v)(N=D(b>0?s[v]+" "+x:P(x,/&\f/g,s[v])))&&(k[L++]=N);return z(e,r,a,u===0?q:m,k,n,f)}function pe(e,r,a){return z(e,r,a,Y,C(Q()),A(e,2,-2),0)}function ie(e,r,a,p){return z(e,r,a,B,A(e,0,p),A(e,p+1,-1),p)}function he(e){let{useObjectSyntax:r=!1}=e??{};return a=>{let p=r?[":where([style]) {}"]:[],u=[];ue(a,(n,f)=>{n.type===le&&n.name==="style"&&(p.push(n.children.map(t=>t.type===xe?t.value:"").join("")),u.push(()=>{f.children=f.children.filter(t=>t!==n)}))});for(let n of u)n();let E=p.join(`
`),w=V(E),m=new Map;for(let n of w)if(n.type==="rule"){let f=Object.fromEntries(n.children.map(t=>[t.props,t.children]));for(let t of n.props){let s=Object.assign(m.get(t)??{},f);m.set(t,s)}}let k=new Map;for(let[n,f]of Array.from(m).sort(([t],[s])=>{let i=fe(t),l=fe(s);return i>l?1:l>i?-1:0})){let t=me(a,n);for(let s of t){let i=k.get(s)??{};k.set(s,Object.assign(i,f))}}for(let[n,f]of k){let t=n.attributes.style??"",s={};for(let i of V(t))i.type==="decl"&&typeof i.props=="string"&&typeof i.children=="string"&&(s[i.props]=i.children);s=Object.assign({},f,s),r?n.attributes.style=s:n.attributes.style=`${Object.entries(s).map(([i,l])=>`${i}:${l.replace("!important","")};`).join("")}`}return a}}export{he as default};

File diff suppressed because one or more lines are too long

20
node_modules/ultrahtml/dist/transformers/sanitize.d.ts generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import { Node } from "../index.js";
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 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;
}
export default function sanitize(opts?: SanitizeOptions): (doc: Node) => Node;

1
node_modules/ultrahtml/dist/transformers/sanitize.js generated vendored Normal file
View File

@@ -0,0 +1 @@
import{ELEMENT_NODE as a,walkSync as f}from"../index.js";function p(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 o of t.dropElements??[])e.add(o);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 o,l,r;return((o=e.allowElements)==null?void 0:o.length)>0&&e.allowElements.includes(t)?"allow":((l=e.blockElements)==null?void 0:l.length)>0&&e.blockElements.includes(t)?"block":((r=e.dropElements)==null?void 0:r.length)>0&&e.dropElements.find(s=>s===t)||n==="component"&&!e.allowComponents||n==="custom-element"&&!e.allowCustomElements?"drop":"allow"}function b(t,n){var o,l,r,s,u,m,c,d;let e=t.attributes;for(let i of Object.keys(t.attributes))((o=n.allowAttributes)==null?void 0:o[i])&&((l=n.allowAttributes)==null?void 0:l[i].includes(t.name))||((s=(r=n.allowAttributes)==null?void 0:r[i])==null?void 0:s.includes("*"))||(((u=n.dropAttributes)==null?void 0:u[i])&&((m=n.dropAttributes)==null?void 0:m[i].includes(t.name))||((d=(c=n.dropAttributes)==null?void 0:c[i])==null?void 0:d.includes("*")))&&delete e[i];return e}function g(t,n,e){let o=E(n),{name:l}=n,r=w(l,o,t);return r==="drop"?()=>{e.children=e.children.filter(s=>s!==n)}:r==="block"?()=>{e.children=e.children.map(s=>s===n?s.children:s).flat(1)}:()=>{n.attributes=b(n,t)}}function N(t){let n=p(t);return e=>{let o=[];f(e,(l,r)=>{switch(l.type){case a:{o.push(g(n,l,r));return}default:return}});for(let l of o)l();return e}}export{N as default};

File diff suppressed because one or more lines are too long

6
node_modules/ultrahtml/dist/transformers/scope.d.ts generated vendored Normal file
View File

@@ -0,0 +1,6 @@
import { Node } from "../index.js";
export interface ScopeOptions {
hash?: string;
attribute?: string;
}
export default function scope(opts?: ScopeOptions): (doc: Node) => Promise<Node>;

31
node_modules/ultrahtml/dist/transformers/scope.js generated vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
node_modules/ultrahtml/dist/transformers/swap.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Node } from "../index.js";
export default function swap(components?: Record<string, string | ((props: Record<string, any>, ...children: any[]) => any)>): (doc: Node) => Node;

1
node_modules/ultrahtml/dist/transformers/swap.js generated vendored Normal file
View File

@@ -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
node_modules/ultrahtml/dist/transformers/swap.js.map generated vendored Normal file
View File

@@ -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(components: Record<string, string | ((props: Record<string, any>, ...children: any[]) => any)> = {}) {\n return (doc: Node): Node => {\n for (const [selector, component] of Object.entries(components)) {\n for (const node of querySelectorAll(doc, selector)) {\n if (typeof component === 'string') {\n node.name = component;\n if (RenderFn in node) {\n delete (node as any)[RenderFn]\n }\n } else if (typeof component === 'function') {\n __unsafeRenderFn(node as ElementNode, component)\n }\n }\n }\n return doc;\n };\n}\n"],
"mappings": "AAAA,OAAsB,YAAAA,MAAgB,cACtC,OAAe,oBAAAC,MAAwB,cACvC,OAAS,oBAAAC,MAAwB,iBAElB,SAARC,EAAsBC,EAAiG,CAAC,EAAG,CAChI,OAAQC,GAAoB,CAC1B,OAAW,CAACC,EAAUC,CAAS,IAAK,OAAO,QAAQH,CAAU,EAC3D,QAAWI,KAAQN,EAAiBG,EAAKC,CAAQ,EAC3C,OAAOC,GAAc,UACvBC,EAAK,KAAOD,EACRP,KAAYQ,GACd,OAAQA,EAAaR,IAEd,OAAOO,GAAc,YAC9BN,EAAiBO,EAAqBD,CAAS,EAIrD,OAAOF,CACT,CACF",
"names": ["RenderFn", "__unsafeRenderFn", "querySelectorAll", "swap", "components", "doc", "selector", "component", "node"]
}

1
node_modules/ultrahtml/jsx-runtime.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/jsx-runtime/index'

78
node_modules/ultrahtml/package.json generated vendored Normal file
View File

@@ -0,0 +1,78 @@
{
"name": "ultrahtml",
"type": "module",
"version": "1.2.0",
"types": "./dist/index.d.ts",
"repository": {
"type": "git",
"url": "https://github.com/natemoo-re/ultrahtml"
},
"bugs": {
"url": "https://github.com/natemoo-re/ultrahtml/issues"
},
"homepage": "https://github.com/natemoo-re/ultrahtml#README",
"files": [
"selector.d.ts",
"transform.d.ts",
"jsx-runtime.d.ts",
"transformers",
"dist",
"CHANGELOG.md"
],
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
},
"./package.json": "./package.json",
"./selector": {
"types": "./dist/selector.d.ts",
"import": "./dist/selector.js"
},
"./transformers/*": {
"types": "./dist/transformers/*.d.ts",
"import": "./dist/transformers/*.js"
},
"./jsx-runtime": {
"types": "./dist/jsx-runtime/index.d.ts",
"import": "./dist/jsx-runtime/index.js"
}
},
"keywords": [
"html",
"template",
"sanitize"
],
"author": {
"name": "Nate Moore",
"email": "nate@natemoo.re",
"url": "https://twitter.com/n_moore"
},
"license": "MIT",
"volta": {
"node": "18.7.0"
},
"packageManager": "pnpm@7.6.0",
"devDependencies": {
"@changesets/cli": "^2.18.1",
"@types/stylis": "^4.0.2",
"chalk": "^5.1.2",
"esbuild": "^0.14.51",
"globby": "^13.1.2",
"gzip-size": "^7.0.0",
"markdown-it": "^13.0.1",
"npm-run-all": "^4.1.5",
"parsel-js": "^1.0.2",
"prettier": "^2.5.1",
"pretty-bytes": "^6.0.0",
"stylis": "^4.1.2",
"typescript": "^4.7.4",
"vitest": "^0.20.2"
},
"scripts": {
"build": "node scripts/build.js && tsc -p .",
"lint": "prettier \"**/*.{js,ts,md}\"",
"dev": "vitest",
"test": "vitest run"
}
}

1
node_modules/ultrahtml/selector.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/selector';

1
node_modules/ultrahtml/transform.d.ts generated vendored Normal file
View File

@@ -0,0 +1 @@
export * from './dist/transform';

2
node_modules/ultrahtml/transformers/inline.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { default } from '../dist/transformers/inline';
export * from '../dist/transformers/inline';

2
node_modules/ultrahtml/transformers/sanitize.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { default } from '../dist/transformers/sanitize';
export * from '../dist/transformers/sanitize';

2
node_modules/ultrahtml/transformers/scope.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { default } from '../dist/transformers/scope';
export * from '../dist/transformers/scope';

2
node_modules/ultrahtml/transformers/swap.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export { default } from '../dist/transformers/swap';
export * from '../dist/transformers/swap';