the editable site (validation-lab)
This commit is contained in:
commit
3ac81d5a52
13454 files changed
+2227005
No files matched your search
+395
@@ -0,0 +1,395 @@
|
||||
# ultrahtml
|
||||
|
||||
## 1.7.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 4694b57: Updates the build target from Node 16 to Node 22. Published code now uses modern syntax like optional chaining (`?.`) directly instead of downleveled equivalents, resulting in slightly smaller output. Node 22 or later is now the supported runtime baseline.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 236be9a: Remove sourcemaps and disable minification of published sources.
|
||||
- 236be9a: Improve performance by using character codes and numeric comparisons.
|
||||
- 4c1c0a0: Improve parsing performance by 1.5x and render performance by 2x.
|
||||
|
||||
## 1.6.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 124e573: Adds a new `transformSync` function, a synchronous alternative to the `transform` function. This can be used when there are no `async` transformer functions.
|
||||
|
||||
```js
|
||||
import { transformSync, html } from "ultrahtml";
|
||||
import swap from "ultrahtml/transformers/swap";
|
||||
|
||||
const output = transformSync(`<h1>Hello world!</h1>`, [
|
||||
swap({
|
||||
h1: "h2",
|
||||
}),
|
||||
]);
|
||||
|
||||
console.log(output); // <h2>Hello world!</h2>
|
||||
```
|
||||
|
||||
- f0a1da3: Adds a new `unblockElements` option to the `sanitize` transformer. This option makes it easier to remove all or most HTML from a string without dropping child content.
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- f0a1da3: Fixes sanitization of nested elements.
|
||||
|
||||
For example, the following code:
|
||||
|
||||
```js
|
||||
const output = await transform("<h1>Hello <strong>world!</strong></h1>", [
|
||||
sanitize({ blockElements: ["h1", "strong"] }),
|
||||
]);
|
||||
```
|
||||
|
||||
produced the following output before this fix:
|
||||
|
||||
```html
|
||||
Hello <strong>world!</strong>
|
||||
```
|
||||
|
||||
and now correctly produces:
|
||||
|
||||
```html
|
||||
Hello world!
|
||||
```
|
||||
|
||||
- e8aee16: Improve parser performance for attributes
|
||||
- 8388fe7: Updates internal dependency on `esbuild`
|
||||
|
||||
## 1.5.3
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- ebc97e0: upgrades `dts-bundle-generator` to `9.2.1`, fixing an issue with `.d.ts`
|
||||
generation which led methods prefixed with two underscores to be
|
||||
incorrectly made private in the generated declaration file.
|
||||
|
||||
## 1.5.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 244be0a: Update `parsel-js` to latest
|
||||
|
||||
## 1.5.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- a989b5a: Bundle type definitions in `.d.ts` files
|
||||
|
||||
## 1.5.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 7c93190: Add support for static media queries to `ultrahtml/transformers/inline`.
|
||||
|
||||
You may now pass an `env` value to the transformer, for example:
|
||||
|
||||
```js
|
||||
import { transform } from "ultrahtml";
|
||||
import inline from "ultrahtml/transformers/inline";
|
||||
|
||||
const output = await transform(input, [
|
||||
// Acts as if the screen is 960px wide and 1280px tall
|
||||
inline({ env: { width: 960, height: 1280 } }),
|
||||
]);
|
||||
```
|
||||
|
||||
## 1.4.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 8bbaeef: Allow elements inside of `<svg>` to be self-closing for compactness
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 5715bc3: Fix `sanitize` transformer behavior when only using `allowElements`
|
||||
|
||||
## 1.3.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 0556b19: Add `renderSync` export
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 3362aa2: Add `main` entrypoint
|
||||
|
||||
## 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
@@ -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.
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
# `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.
|
||||
|
||||
```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>
|
||||
```
|
||||
|
||||
#### `transformSync`
|
||||
|
||||
The `transformSync` function is identical to the `transform` function, but is synchronous. This should only be used when it is guaranteed there are no `async` functions in the transformers.
|
||||
|
||||
```js
|
||||
import { transformSync, html } from "ultrahtml";
|
||||
import swap from "ultrahtml/transformers/swap";
|
||||
import sanitize from "ultrahtml/transformers/sanitize";
|
||||
|
||||
const output = transformSync(`<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 a proposed HTML Sanitizer API (circa 2022.) Although that proposal has since been withdrawn, it remains as the foundation of `ultrahtml`'s API. In a future major version of `ultrahtml`, we hope to track against [WICG Sanitizer API proposal](https://wicg.github.io/sanitizer-api/) if it becomes an official WHATWG specification.
|
||||
|
||||
| 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. |
|
||||
| unblockElements | `string[]` | `undefined` | An array of strings indicating elements that the sanitizer should not remove. All elements not in the array will be removed, but keep their child content. |
|
||||
| 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
|
||||
+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 {};
|
||||
+464
@@ -0,0 +1,464 @@
|
||||
// src/index.ts
|
||||
var DOCUMENT_NODE = 0;
|
||||
var ELEMENT_NODE = 1;
|
||||
var TEXT_NODE = 2;
|
||||
var COMMENT_NODE = 3;
|
||||
var DOCTYPE_NODE = 4;
|
||||
function h(type, props = {}, ...children) {
|
||||
const vnode = {
|
||||
type: ELEMENT_NODE,
|
||||
name: typeof type === "function" ? type.name : type,
|
||||
attributes: props || {},
|
||||
children: children.map(
|
||||
(child) => typeof child === "string" ? { type: TEXT_NODE, value: escapeHTML(String(child)) } : child
|
||||
),
|
||||
parent: void 0,
|
||||
loc: []
|
||||
};
|
||||
if (typeof type === "function") {
|
||||
__unsafeRenderFn(vnode, type);
|
||||
}
|
||||
return vnode;
|
||||
}
|
||||
var Fragment = Symbol("Fragment");
|
||||
var VOID_TAGS = /* @__PURE__ */ new Set([
|
||||
"area",
|
||||
"base",
|
||||
"br",
|
||||
"col",
|
||||
"embed",
|
||||
"hr",
|
||||
"img",
|
||||
"input",
|
||||
"keygen",
|
||||
"link",
|
||||
"meta",
|
||||
"param",
|
||||
"source",
|
||||
"track",
|
||||
"wbr"
|
||||
]);
|
||||
var RAW_TAGS = /* @__PURE__ */ new Set(["script", "style"]);
|
||||
var DOM_PARSER_RE = /(?:<(\/?)([a-zA-Z][a-zA-Z0-9\:-]*)(?:\s([^>]*?))?((?:\s*\/)?)>|(<\!\-\-)([\s\S]*?)(\-\->)|(<\!)([\s\S]*?)(>))/gm;
|
||||
var CHAR_AT = 64;
|
||||
var CHAR_DOT = 46;
|
||||
var CHAR_HYPHEN = 45;
|
||||
var CHAR_COLON = 58;
|
||||
var CHAR_UNDERSCORE = 95;
|
||||
var CHAR_EQUALS = 61;
|
||||
var CHAR_DOUBLE_QUOTE = 34;
|
||||
var CHAR_SINGLE_QUOTE = 39;
|
||||
var CHAR_BACKSLASH = 92;
|
||||
function isAttrKeyIdentifier(chr) {
|
||||
return chr >= 97 && chr <= 122 || // a-z
|
||||
chr >= 65 && chr <= 90 || // A-Z
|
||||
chr >= 48 && chr <= 57 || // 0-9
|
||||
chr === CHAR_AT || chr === CHAR_DOT || chr === CHAR_HYPHEN || chr === CHAR_COLON || chr === CHAR_UNDERSCORE;
|
||||
}
|
||||
function splitAttrs(str) {
|
||||
let obj = {};
|
||||
if (str) {
|
||||
let state = "none";
|
||||
let currentKey;
|
||||
let currentValue = "";
|
||||
let tokenStartIndex;
|
||||
for (let currentIndex = 0; currentIndex < str.length; currentIndex++) {
|
||||
const currentChar = str.charCodeAt(currentIndex);
|
||||
if (state === "none") {
|
||||
if (isAttrKeyIdentifier(currentChar)) {
|
||||
if (currentKey) {
|
||||
obj[currentKey] = currentValue;
|
||||
currentKey = void 0;
|
||||
currentValue = "";
|
||||
}
|
||||
tokenStartIndex = currentIndex;
|
||||
state = "key";
|
||||
} else if (currentChar === CHAR_EQUALS && currentKey) {
|
||||
state = "value";
|
||||
}
|
||||
} else if (state === "key") {
|
||||
if (!isAttrKeyIdentifier(currentChar)) {
|
||||
currentKey = str.substring(tokenStartIndex, currentIndex);
|
||||
if (currentChar === CHAR_EQUALS) {
|
||||
state = "value";
|
||||
} else {
|
||||
state = "none";
|
||||
}
|
||||
}
|
||||
} else if (currentChar === CHAR_DOUBLE_QUOTE || currentChar === CHAR_SINGLE_QUOTE) {
|
||||
const quote = currentChar === CHAR_DOUBLE_QUOTE ? '"' : "'";
|
||||
const valueStart = currentIndex + 1;
|
||||
let closeIndex = str.indexOf(quote, valueStart);
|
||||
while (closeIndex > 0 && str.charCodeAt(closeIndex - 1) === CHAR_BACKSLASH) {
|
||||
closeIndex = str.indexOf(quote, closeIndex + 1);
|
||||
}
|
||||
if (closeIndex === -1) {
|
||||
break;
|
||||
}
|
||||
currentValue = str.substring(valueStart, closeIndex);
|
||||
currentIndex = closeIndex;
|
||||
state = "none";
|
||||
}
|
||||
}
|
||||
if (state === "key" && tokenStartIndex != void 0 && tokenStartIndex < str.length) {
|
||||
currentKey = str.substring(tokenStartIndex, str.length);
|
||||
}
|
||||
if (currentKey) {
|
||||
obj[currentKey] = currentValue;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
function parse(input) {
|
||||
let str = typeof input === "string" ? input : input.value;
|
||||
let doc, parent, token, text, i, bStart, bText, bEnd, tag;
|
||||
const tags = [];
|
||||
DOM_PARSER_RE.lastIndex = 0;
|
||||
parent = doc = {
|
||||
type: DOCUMENT_NODE,
|
||||
children: []
|
||||
};
|
||||
let lastIndex = 0;
|
||||
function commitTextNode() {
|
||||
text = str.substring(lastIndex, DOM_PARSER_RE.lastIndex - token[0].length);
|
||||
if (text) {
|
||||
parent.children.push({
|
||||
type: TEXT_NODE,
|
||||
value: text,
|
||||
parent
|
||||
});
|
||||
}
|
||||
}
|
||||
while (token = DOM_PARSER_RE.exec(str)) {
|
||||
bStart = token[5] || token[8];
|
||||
bText = token[6] || token[9];
|
||||
bEnd = token[7] || token[10];
|
||||
if (RAW_TAGS.has(parent.name) && token[2] !== parent.name) {
|
||||
i = DOM_PARSER_RE.lastIndex - token[0].length;
|
||||
if (parent.children.length > 0) {
|
||||
parent.children[0].value += token[0];
|
||||
}
|
||||
continue;
|
||||
} else if (bStart === "<!--") {
|
||||
i = DOM_PARSER_RE.lastIndex - token[0].length;
|
||||
if (RAW_TAGS.has(parent.name)) {
|
||||
continue;
|
||||
}
|
||||
tag = {
|
||||
type: COMMENT_NODE,
|
||||
value: bText,
|
||||
parent,
|
||||
loc: [
|
||||
{
|
||||
start: i,
|
||||
end: i + bStart.length
|
||||
},
|
||||
{
|
||||
start: DOM_PARSER_RE.lastIndex - bEnd.length,
|
||||
end: DOM_PARSER_RE.lastIndex
|
||||
}
|
||||
]
|
||||
};
|
||||
tags.push(tag);
|
||||
tag.parent.children.push(tag);
|
||||
} else if (bStart === "<!") {
|
||||
i = DOM_PARSER_RE.lastIndex - token[0].length;
|
||||
tag = {
|
||||
type: DOCTYPE_NODE,
|
||||
value: bText,
|
||||
parent,
|
||||
loc: [
|
||||
{
|
||||
start: i,
|
||||
end: i + bStart.length
|
||||
},
|
||||
{
|
||||
start: DOM_PARSER_RE.lastIndex - bEnd.length,
|
||||
end: DOM_PARSER_RE.lastIndex
|
||||
}
|
||||
]
|
||||
};
|
||||
tags.push(tag);
|
||||
tag.parent.children.push(tag);
|
||||
} else if (token[1] !== "/") {
|
||||
commitTextNode();
|
||||
if (RAW_TAGS.has(parent.name)) {
|
||||
lastIndex = DOM_PARSER_RE.lastIndex;
|
||||
commitTextNode();
|
||||
continue;
|
||||
} else {
|
||||
tag = {
|
||||
type: ELEMENT_NODE,
|
||||
name: token[2] + "",
|
||||
attributes: splitAttrs(token[3]),
|
||||
parent,
|
||||
children: [],
|
||||
loc: [
|
||||
{
|
||||
start: DOM_PARSER_RE.lastIndex - token[0].length,
|
||||
end: DOM_PARSER_RE.lastIndex
|
||||
}
|
||||
]
|
||||
};
|
||||
tags.push(tag);
|
||||
tag.parent.children.push(tag);
|
||||
if (token[4] && token[4].indexOf("/") > -1 || VOID_TAGS.has(tag.name)) {
|
||||
tag.loc[1] = tag.loc[0];
|
||||
tag.isSelfClosingTag = true;
|
||||
} else {
|
||||
parent = tag;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
commitTextNode();
|
||||
if (token[2] + "" === parent.name) {
|
||||
tag = parent;
|
||||
parent = tag.parent;
|
||||
tag.loc.push({
|
||||
start: DOM_PARSER_RE.lastIndex - token[0].length,
|
||||
end: DOM_PARSER_RE.lastIndex
|
||||
});
|
||||
text = str.substring(tag.loc[0].end, tag.loc[1].start);
|
||||
if (tag.children.length === 0) {
|
||||
tag.children.push({
|
||||
type: TEXT_NODE,
|
||||
value: text,
|
||||
parent
|
||||
});
|
||||
}
|
||||
} else if (token[2] + "" === tags[tags.length - 1].name && tags[tags.length - 1].isSelfClosingTag === true) {
|
||||
tag = tags[tags.length - 1];
|
||||
tag.loc.push({
|
||||
start: DOM_PARSER_RE.lastIndex - token[0].length,
|
||||
end: DOM_PARSER_RE.lastIndex
|
||||
});
|
||||
}
|
||||
}
|
||||
lastIndex = DOM_PARSER_RE.lastIndex;
|
||||
}
|
||||
text = str.slice(lastIndex);
|
||||
parent.children.push({
|
||||
type: TEXT_NODE,
|
||||
value: text,
|
||||
parent
|
||||
});
|
||||
return doc;
|
||||
}
|
||||
var Walker = class {
|
||||
constructor(callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
async visit(node, parent, index) {
|
||||
await this.callback(node, parent, index);
|
||||
if (Array.isArray(node.children)) {
|
||||
let promises = [];
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
const child = node.children[i];
|
||||
promises.push(this.visit(child, node, i));
|
||||
}
|
||||
await Promise.all(promises);
|
||||
}
|
||||
}
|
||||
};
|
||||
var WalkerSync = class {
|
||||
constructor(callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
visit(node, parent, index) {
|
||||
this.callback(node, parent, index);
|
||||
if (Array.isArray(node.children)) {
|
||||
for (let i = 0; i < node.children.length; i++) {
|
||||
const child = node.children[i];
|
||||
this.visit(child, node, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
var HTMLString = Symbol("HTMLString");
|
||||
var AttrString = Symbol("AttrString");
|
||||
var RenderFn = Symbol("RenderFn");
|
||||
function mark(str, tags = [HTMLString]) {
|
||||
const v = { value: str };
|
||||
for (const tag of tags) {
|
||||
Object.defineProperty(v, tag, {
|
||||
value: true,
|
||||
enumerable: false,
|
||||
writable: false
|
||||
});
|
||||
}
|
||||
return v;
|
||||
}
|
||||
function __unsafeHTML(str) {
|
||||
return mark(str);
|
||||
}
|
||||
function __unsafeRenderFn(node, fn) {
|
||||
Object.defineProperty(node, RenderFn, {
|
||||
value: fn,
|
||||
enumerable: false
|
||||
});
|
||||
return node;
|
||||
}
|
||||
var ESCAPE_CHARS = {
|
||||
"&": "&",
|
||||
"<": "<",
|
||||
">": ">"
|
||||
};
|
||||
function escapeHTML(str) {
|
||||
return str.replace(/[&<>]/g, (c) => ESCAPE_CHARS[c] || c);
|
||||
}
|
||||
function attrsToString(attributes) {
|
||||
let attrStr = "";
|
||||
for (const [key, value] of Object.entries(attributes)) {
|
||||
attrStr += ` ${key}="${value}"`;
|
||||
}
|
||||
return attrStr;
|
||||
}
|
||||
function attrs(attributes) {
|
||||
return mark(attrsToString(attributes), [HTMLString, AttrString]);
|
||||
}
|
||||
function html(tmpl, ...vals) {
|
||||
let buf = "";
|
||||
for (let i = 0; i < tmpl.length; i++) {
|
||||
buf += tmpl[i];
|
||||
const expr = vals[i];
|
||||
if (buf.endsWith("...") && expr && typeof expr === "object") {
|
||||
buf = buf.slice(0, -3).trimEnd();
|
||||
buf += attrsToString(expr);
|
||||
} else if (expr && expr[AttrString]) {
|
||||
buf = buf.trimEnd();
|
||||
buf += expr.value;
|
||||
} else if (expr && expr[HTMLString]) {
|
||||
buf += expr.value;
|
||||
} else if (typeof expr === "string") {
|
||||
buf += escapeHTML(expr);
|
||||
} else if (expr || expr === 0) {
|
||||
buf += String(expr);
|
||||
}
|
||||
}
|
||||
return mark(buf);
|
||||
}
|
||||
function walk(node, callback) {
|
||||
const walker = new Walker(callback);
|
||||
return walker.visit(node);
|
||||
}
|
||||
function walkSync(node, callback) {
|
||||
const walker = new WalkerSync(callback);
|
||||
return walker.visit(node);
|
||||
}
|
||||
function canSelfClose(node) {
|
||||
if (node.children.length === 0) {
|
||||
let n = node;
|
||||
while (n = n.parent) {
|
||||
if (n.name === "svg") return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
async function renderElement(node) {
|
||||
const { name, attributes = {} } = node;
|
||||
const children = await Promise.all(
|
||||
node.children.map((child) => render(child))
|
||||
).then((res) => res.join(""));
|
||||
if (RenderFn in node) {
|
||||
const value = await node[RenderFn](attributes, mark(children));
|
||||
if (value && value[HTMLString]) return value.value;
|
||||
return escapeHTML(String(value));
|
||||
}
|
||||
if (name === Fragment) return children;
|
||||
const isSelfClosing = canSelfClose(node);
|
||||
if (isSelfClosing || VOID_TAGS.has(name)) {
|
||||
return `<${node.name}${attrsToString(attributes)}${isSelfClosing ? " /" : ""}>`;
|
||||
}
|
||||
return `<${node.name}${attrsToString(attributes)}>${children}</${node.name}>`;
|
||||
}
|
||||
function renderElementSync(node) {
|
||||
const { name, attributes = {} } = node;
|
||||
const children = node.children.map((child) => renderSync(child)).join("");
|
||||
if (RenderFn in node) {
|
||||
const value = node[RenderFn](attributes, mark(children));
|
||||
if (value && value[HTMLString]) return value.value;
|
||||
return escapeHTML(String(value));
|
||||
}
|
||||
if (name === Fragment) return children;
|
||||
const isSelfClosing = canSelfClose(node);
|
||||
if (isSelfClosing || VOID_TAGS.has(name)) {
|
||||
return `<${node.name}${attrsToString(attributes)}${isSelfClosing ? " /" : ""}>`;
|
||||
}
|
||||
return `<${node.name}${attrsToString(attributes)}>${children}</${node.name}>`;
|
||||
}
|
||||
function renderSync(node) {
|
||||
switch (node.type) {
|
||||
case DOCUMENT_NODE:
|
||||
return node.children.map((child) => renderSync(child)).join("");
|
||||
case ELEMENT_NODE:
|
||||
return renderElementSync(node);
|
||||
case TEXT_NODE:
|
||||
return `${node.value}`;
|
||||
case COMMENT_NODE:
|
||||
return `<!--${node.value}-->`;
|
||||
case DOCTYPE_NODE:
|
||||
return `<!${node.value}>`;
|
||||
}
|
||||
}
|
||||
async function render(node) {
|
||||
switch (node.type) {
|
||||
case DOCUMENT_NODE:
|
||||
return Promise.all(
|
||||
node.children.map((child) => render(child))
|
||||
).then((res) => res.join(""));
|
||||
case ELEMENT_NODE:
|
||||
return renderElement(node);
|
||||
case TEXT_NODE:
|
||||
return `${node.value}`;
|
||||
case COMMENT_NODE:
|
||||
return `<!--${node.value}-->`;
|
||||
case DOCTYPE_NODE:
|
||||
return `<!${node.value}>`;
|
||||
}
|
||||
}
|
||||
function parseTransformArgs(markup, transformers) {
|
||||
if (!Array.isArray(transformers)) {
|
||||
throw new Error(
|
||||
`Invalid second argument for \`transform\`! Expected \`Transformer[]\` but got \`${typeof transformers}\``
|
||||
);
|
||||
}
|
||||
const doc = typeof markup === "string" ? parse(markup) : markup;
|
||||
return { doc };
|
||||
}
|
||||
async function transform(markup, transformers = []) {
|
||||
const { doc } = parseTransformArgs(markup, transformers);
|
||||
let newDoc = doc;
|
||||
for (const t of transformers) {
|
||||
newDoc = await t(newDoc);
|
||||
}
|
||||
return render(newDoc);
|
||||
}
|
||||
function transformSync(markup, transformers = []) {
|
||||
const { doc } = parseTransformArgs(markup, transformers);
|
||||
let newDoc = doc;
|
||||
for (const t of transformers) {
|
||||
newDoc = t(newDoc);
|
||||
}
|
||||
return renderSync(newDoc);
|
||||
}
|
||||
export {
|
||||
COMMENT_NODE,
|
||||
DOCTYPE_NODE,
|
||||
DOCUMENT_NODE,
|
||||
ELEMENT_NODE,
|
||||
Fragment,
|
||||
RenderFn,
|
||||
TEXT_NODE,
|
||||
__unsafeHTML,
|
||||
__unsafeRenderFn,
|
||||
attrs,
|
||||
h,
|
||||
html,
|
||||
parse,
|
||||
render,
|
||||
renderSync,
|
||||
transform,
|
||||
transformSync,
|
||||
walk,
|
||||
walkSync
|
||||
};
|
||||
+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 {};
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// src/jsx-runtime/index.ts
|
||||
import { TEXT_NODE } from "../index.js";
|
||||
import { ELEMENT_NODE, Fragment, __unsafeRenderFn } from "../index.js";
|
||||
function createVNode(type, { children, ...attributes }, key, __self, __source) {
|
||||
const vnode = {
|
||||
type: ELEMENT_NODE,
|
||||
name: typeof type === "function" ? type.name : type,
|
||||
attributes,
|
||||
children: (Array.isArray(children) ? children : [children]).map((child) => {
|
||||
if (typeof child === "string") {
|
||||
return {
|
||||
type: TEXT_NODE,
|
||||
value: child
|
||||
};
|
||||
}
|
||||
return child;
|
||||
}),
|
||||
parent: void 0,
|
||||
loc: []
|
||||
};
|
||||
if (typeof type === "function") {
|
||||
__unsafeRenderFn(vnode, type);
|
||||
}
|
||||
return vnode;
|
||||
}
|
||||
export {
|
||||
Fragment,
|
||||
createVNode as jsx,
|
||||
createVNode as jsxDEV,
|
||||
createVNode as jsxs
|
||||
};
|
||||
+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 {};
|
||||
+425
@@ -0,0 +1,425 @@
|
||||
// src/selector.ts
|
||||
import { ELEMENT_NODE, TEXT_NODE, walkSync } from "./index.js";
|
||||
|
||||
// node_modules/.pnpm/parsel-js@1.1.2/node_modules/parsel-js/dist/parsel.min.js
|
||||
var 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>¶*)\))?/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 };
|
||||
var t = /* @__PURE__ */ new Set(["combinator", "comma"]);
|
||||
var n = /* @__PURE__ */ new Set(["not", "is", "where", "has", "matches", "-moz-any", "-webkit-any", "nth-child", "nth-last-child"]);
|
||||
var s = /(?<index>[\dn+-]+)\s+of\s+(?<subtree>.+)/;
|
||||
var o = { "nth-child": s, "nth-last-child": s };
|
||||
var r = (t2) => {
|
||||
switch (t2) {
|
||||
case "pseudo-element":
|
||||
case "pseudo-class":
|
||||
return new RegExp(e[t2].source.replace("(?<argument>\xB6*)", "(?<argument>.*)"), "gu");
|
||||
default:
|
||||
return e[t2];
|
||||
}
|
||||
};
|
||||
function c(e2, t2) {
|
||||
let n2 = 0, s2 = "";
|
||||
for (; t2 < e2.length; t2++) {
|
||||
const o2 = e2[t2];
|
||||
switch (o2) {
|
||||
case "(":
|
||||
++n2;
|
||||
break;
|
||||
case ")":
|
||||
--n2;
|
||||
}
|
||||
if (s2 += o2, 0 === n2) return s2;
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
function i(n2, s2 = e) {
|
||||
if (!n2) return [];
|
||||
const o2 = [n2];
|
||||
for (const [e2, t2] of Object.entries(s2)) for (let n3 = 0; n3 < o2.length; n3++) {
|
||||
const s3 = o2[n3];
|
||||
if ("string" != typeof s3) continue;
|
||||
t2.lastIndex = 0;
|
||||
const r3 = t2.exec(s3);
|
||||
if (!r3) continue;
|
||||
const c2 = r3.index - 1, i2 = [], a2 = r3[0], l2 = s3.slice(0, c2 + 1);
|
||||
l2 && i2.push(l2), i2.push({ ...r3.groups, type: e2, content: a2 });
|
||||
const u2 = s3.slice(c2 + a2.length + 1);
|
||||
u2 && i2.push(u2), o2.splice(n3, 1, ...i2);
|
||||
}
|
||||
let r2 = 0;
|
||||
for (const e2 of o2) switch (typeof e2) {
|
||||
case "string":
|
||||
throw new Error(`Unexpected sequence ${e2} found at index ${r2}`);
|
||||
case "object":
|
||||
r2 += e2.content.length, e2.pos = [r2 - e2.content.length, r2], t.has(e2.type) && (e2.content = e2.content.trim() || " ");
|
||||
}
|
||||
return o2;
|
||||
}
|
||||
var a = /(['"])([^\\\n]+?)\1/g;
|
||||
var l = /\\./g;
|
||||
function u(t2, n2 = e) {
|
||||
if ("" === (t2 = t2.trim())) return [];
|
||||
const s2 = [];
|
||||
t2 = (t2 = t2.replace(l, (e2, t3) => (s2.push({ value: e2, offset: t3 }), "\uE000".repeat(e2.length)))).replace(a, (e2, t3, n3, o3) => (s2.push({ value: e2, offset: o3 }), `${t3}${"\uE001".repeat(n3.length)}${t3}`));
|
||||
{
|
||||
let e2, n3 = 0;
|
||||
for (; (e2 = t2.indexOf("(", n3)) > -1; ) {
|
||||
const o3 = c(t2, e2);
|
||||
s2.push({ value: o3, offset: e2 }), t2 = `${t2.substring(0, e2)}(${"\xB6".repeat(o3.length - 2)})${t2.substring(e2 + o3.length)}`, n3 = e2 + o3.length;
|
||||
}
|
||||
}
|
||||
const o2 = i(t2, n2), u2 = /* @__PURE__ */ new Set();
|
||||
for (const e2 of s2.reverse()) for (const t3 of o2) {
|
||||
const { offset: n3, value: s3 } = e2;
|
||||
if (!(t3.pos[0] <= n3 && n3 + s3.length <= t3.pos[1])) continue;
|
||||
const { content: o3 } = t3, r2 = n3 - t3.pos[0];
|
||||
t3.content = o3.slice(0, r2) + s3 + o3.slice(r2 + s3.length), t3.content !== o3 && u2.add(t3);
|
||||
}
|
||||
for (const e2 of u2) {
|
||||
const t3 = r(e2.type);
|
||||
if (!t3) throw new Error(`Unknown token type: ${e2.type}`);
|
||||
t3.lastIndex = 0;
|
||||
const n3 = t3.exec(e2.content);
|
||||
if (!n3) throw new Error(`Unable to parse content for ${e2.type}: ${e2.content}`);
|
||||
Object.assign(e2, n3.groups);
|
||||
}
|
||||
return o2;
|
||||
}
|
||||
function f(e2, { list: t2 = true } = {}) {
|
||||
if (t2 && e2.find((e3) => "comma" === e3.type)) {
|
||||
const t3 = [], n2 = [];
|
||||
for (let s2 = 0; s2 < e2.length; s2++) if ("comma" === e2[s2].type) {
|
||||
if (0 === n2.length) throw new Error("Incorrect comma at " + s2);
|
||||
t3.push(f(n2, { list: false })), n2.length = 0;
|
||||
} else n2.push(e2[s2]);
|
||||
if (0 === n2.length) throw new Error("Trailing comma");
|
||||
return t3.push(f(n2, { list: false })), { type: "list", list: t3 };
|
||||
}
|
||||
for (let t3 = e2.length - 1; t3 >= 0; t3--) {
|
||||
let n2 = e2[t3];
|
||||
if ("combinator" === n2.type) {
|
||||
let s2 = e2.slice(0, t3), o2 = e2.slice(t3 + 1);
|
||||
return { type: "complex", combinator: n2.content, left: f(s2), right: f(o2) };
|
||||
}
|
||||
}
|
||||
switch (e2.length) {
|
||||
case 0:
|
||||
throw new Error("Could not build AST.");
|
||||
case 1:
|
||||
return e2[0];
|
||||
default:
|
||||
return { type: "compound", list: [...e2] };
|
||||
}
|
||||
}
|
||||
function* p(e2, t2) {
|
||||
switch (e2.type) {
|
||||
case "list":
|
||||
for (let t3 of e2.list) yield* p(t3, e2);
|
||||
break;
|
||||
case "complex":
|
||||
yield* p(e2.left, e2), yield* p(e2.right, e2);
|
||||
break;
|
||||
case "compound":
|
||||
yield* e2.list.map((t3) => [t3, e2]);
|
||||
break;
|
||||
default:
|
||||
yield [e2, t2];
|
||||
}
|
||||
}
|
||||
function m(e2, { recursive: t2 = true, list: s2 = true } = {}) {
|
||||
const r2 = u(e2);
|
||||
if (!r2) return;
|
||||
const c2 = f(r2, { list: s2 });
|
||||
if (!t2) return c2;
|
||||
for (const [e3] of p(c2)) {
|
||||
if ("pseudo-class" !== e3.type || !e3.argument) continue;
|
||||
if (!n.has(e3.name)) continue;
|
||||
let t3 = e3.argument;
|
||||
const s3 = o[e3.name];
|
||||
if (s3) {
|
||||
const n2 = s3.exec(t3);
|
||||
if (!n2) continue;
|
||||
Object.assign(e3, n2.groups), t3 = n2.groups.subtree;
|
||||
}
|
||||
t3 && Object.assign(e3, { subtree: m(t3, { recursive: true, list: true }) });
|
||||
}
|
||||
return c2;
|
||||
}
|
||||
function d(e2, t2) {
|
||||
return t2 = t2 || Math.max(...e2) + 1, e2[0] * (t2 << 1) + e2[1] * t2 + e2[2];
|
||||
}
|
||||
function w(e2) {
|
||||
let t2 = e2;
|
||||
if ("string" == typeof t2 && (t2 = m(t2, { recursive: true })), !t2) return [];
|
||||
if ("list" === t2.type && "list" in t2) {
|
||||
let e3 = 10;
|
||||
const n2 = t2.list.map((t3) => {
|
||||
const n3 = w(t3);
|
||||
return e3 = Math.max(e3, ...w(t3)), n3;
|
||||
}), s3 = n2.map((t3) => d(t3, e3));
|
||||
return n2[s3.indexOf(Math.max(...s3))];
|
||||
}
|
||||
const s2 = [0, 0, 0];
|
||||
for (const [e3] of p(t2)) switch (e3.type) {
|
||||
case "id":
|
||||
s2[0]++;
|
||||
break;
|
||||
case "class":
|
||||
case "attribute":
|
||||
s2[1]++;
|
||||
break;
|
||||
case "pseudo-element":
|
||||
case "type":
|
||||
s2[2]++;
|
||||
break;
|
||||
case "pseudo-class":
|
||||
if ("where" === e3.name) break;
|
||||
if (!n.has(e3.name) || !e3.subtree) {
|
||||
s2[1]++;
|
||||
break;
|
||||
}
|
||||
w(e3.subtree).forEach((e4, t3) => s2[t3] += e4), "nth-child" !== e3.name && "nth-last-child" !== e3.name || s2[1]++;
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
|
||||
// src/selector.ts
|
||||
function specificity(selector) {
|
||||
return d(w(selector), 10);
|
||||
}
|
||||
function matches(node, selector) {
|
||||
const match = selectorToMatch(selector);
|
||||
return match(node, node.parent, nthChildIndex(node, node.parent));
|
||||
}
|
||||
function querySelector(node, selector) {
|
||||
const match = selectorToMatch(selector);
|
||||
try {
|
||||
return select(
|
||||
node,
|
||||
(n2, parent, index) => {
|
||||
let m2 = match(n2, parent, index);
|
||||
if (!m2) return false;
|
||||
return m2;
|
||||
},
|
||||
{ single: true }
|
||||
)[0];
|
||||
} catch (e2) {
|
||||
if (e2 instanceof Error) {
|
||||
throw e2;
|
||||
}
|
||||
return e2;
|
||||
}
|
||||
}
|
||||
function querySelectorAll(node, selector) {
|
||||
const match = selectorToMatch(selector);
|
||||
return select(node, (n2, parent, index) => {
|
||||
let m2 = match(n2, parent, index);
|
||||
if (!m2) return false;
|
||||
return m2;
|
||||
});
|
||||
}
|
||||
var selector_default = querySelectorAll;
|
||||
function select(node, match, opts = { single: false }) {
|
||||
let nodes = [];
|
||||
walkSync(node, (n2, parent, index) => {
|
||||
if (n2 && n2.type !== ELEMENT_NODE) return;
|
||||
if (match(n2, parent, index)) {
|
||||
if (opts.single) throw n2;
|
||||
nodes.push(n2);
|
||||
}
|
||||
});
|
||||
return nodes;
|
||||
}
|
||||
var getAttributeMatch = (selector) => {
|
||||
const { operator = "=" } = selector;
|
||||
switch (operator) {
|
||||
case "=":
|
||||
return (a2, b) => a2 === b;
|
||||
case "~=":
|
||||
return (a2, b) => a2.split(/\s+/g).includes(b);
|
||||
case "|=":
|
||||
return (a2, b) => a2.startsWith(b + "-");
|
||||
case "*=":
|
||||
return (a2, b) => a2.indexOf(b) > -1;
|
||||
case "$=":
|
||||
return (a2, b) => a2.endsWith(b);
|
||||
case "^=":
|
||||
return (a2, b) => a2.startsWith(b);
|
||||
}
|
||||
return (a2, b) => false;
|
||||
};
|
||||
var nthChildIndex = (node, parent) => parent?.children.filter((n2) => n2.type === ELEMENT_NODE).findIndex((n2) => n2 === node);
|
||||
var nthChild = (formula) => {
|
||||
let [_, A = "1", B = "0"] = /^\s*(?:(-?(?:\d+)?)n)?\s*\+?\s*(\d+)?\s*$/gm.exec(formula) ?? [];
|
||||
if (A.length === 0) A = "1";
|
||||
const a2 = Number.parseInt(A === "-" ? "-1" : A);
|
||||
const b = Number.parseInt(B);
|
||||
return (n2) => a2 * n2 + b;
|
||||
};
|
||||
var lastChild = (node, parent) => parent?.children.filter((n2) => n2.type === ELEMENT_NODE).pop() === node;
|
||||
var firstChild = (node, parent) => parent?.children.filter((n2) => n2.type === ELEMENT_NODE).shift() === node;
|
||||
var onlyChild = (node, parent) => parent?.children.filter((n2) => n2.type === ELEMENT_NODE).length === 1;
|
||||
var createMatch = (selector) => {
|
||||
switch (selector.type) {
|
||||
case "type":
|
||||
return (node) => {
|
||||
if (selector.content === "*") return true;
|
||||
return node.name === selector.name;
|
||||
};
|
||||
case "class":
|
||||
return (node) => node.attributes?.class?.split(/\s+/g).includes(selector.name);
|
||||
case "id":
|
||||
return (node) => node.attributes?.id === selector.name;
|
||||
case "pseudo-class": {
|
||||
switch (selector.name) {
|
||||
case "global":
|
||||
return (...args) => selectorToMatch(m(selector.argument))(...args);
|
||||
case "not":
|
||||
return (...args) => !createMatch(selector.subtree)(...args);
|
||||
case "is":
|
||||
return (...args) => selectorToMatch(selector.subtree)(...args);
|
||||
case "where":
|
||||
return (...args) => selectorToMatch(selector.subtree)(...args);
|
||||
case "root":
|
||||
return (node, parent) => node.type === ELEMENT_NODE && node.name === "html";
|
||||
case "empty":
|
||||
return (node) => node.type === ELEMENT_NODE && (node.children.length === 0 || node.children.every(
|
||||
(n2) => n2.type === TEXT_NODE && n2.value.trim() === ""
|
||||
));
|
||||
case "first-child":
|
||||
return (node, parent) => firstChild(node, parent);
|
||||
case "last-child":
|
||||
return (node, parent) => lastChild(node, parent);
|
||||
case "only-child":
|
||||
return (node, parent) => onlyChild(node, parent);
|
||||
case "nth-child":
|
||||
return (node, parent) => {
|
||||
const target = nthChildIndex(node, parent) + 1;
|
||||
if (Number.isNaN(Number(selector.argument))) {
|
||||
switch (selector.argument) {
|
||||
case "odd":
|
||||
return Math.abs(target % 2) == 1;
|
||||
case "even":
|
||||
return target % 2 === 0;
|
||||
default: {
|
||||
if (!selector.argument) {
|
||||
throw new Error(`Unsupported empty nth-child selector!`);
|
||||
}
|
||||
const nth = nthChild(selector.argument);
|
||||
const elements = parent?.children.filter(
|
||||
(n2) => n2.type === ELEMENT_NODE
|
||||
);
|
||||
const childIndex = nthChildIndex(node, parent) + 1;
|
||||
for (let i2 = 0; i2 < elements.length; i2++) {
|
||||
let n2 = nth(i2);
|
||||
if (n2 > elements.length) return false;
|
||||
if (n2 === childIndex) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return target === Number(selector.argument);
|
||||
};
|
||||
default:
|
||||
throw new Error(`Unhandled pseudo-class: ${selector.name}!`);
|
||||
}
|
||||
}
|
||||
case "attribute":
|
||||
return (node) => {
|
||||
let { caseSensitive, name, value } = selector;
|
||||
if (!node.attributes) return false;
|
||||
const attrs = Object.entries(node.attributes);
|
||||
for (let [attr, attrVal] of attrs) {
|
||||
if (caseSensitive === "i") {
|
||||
value = name.toLowerCase();
|
||||
attrVal = attr.toLowerCase();
|
||||
}
|
||||
if (attr !== name) continue;
|
||||
if (!value) return true;
|
||||
if ((value[0] === '"' || value[0] === "'") && value[0] === value[value.length - 1]) {
|
||||
value = JSON.parse(value);
|
||||
}
|
||||
if (value) {
|
||||
return getAttributeMatch(selector)(attrVal, value);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
case "universal":
|
||||
return (_) => {
|
||||
return true;
|
||||
};
|
||||
default: {
|
||||
throw new Error(`Unhandled selector: ${selector.type}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
var selectorToMatch = (sel) => {
|
||||
let selector = typeof sel === "string" ? m(sel) : sel;
|
||||
switch (selector?.type) {
|
||||
case "list": {
|
||||
const matchers = selector.list.map((s2) => createMatch(s2));
|
||||
return (node, parent, index) => {
|
||||
for (const match of matchers) {
|
||||
if (match(node, parent)) return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
}
|
||||
case "compound": {
|
||||
const matchers = selector.list.map((s2) => createMatch(s2));
|
||||
return (node, parent, index) => {
|
||||
for (const match of matchers) {
|
||||
if (!match(node, parent)) return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
}
|
||||
case "complex": {
|
||||
const { left, right, combinator } = selector;
|
||||
const matchLeft = selectorToMatch(left);
|
||||
const matchRight = selectorToMatch(right);
|
||||
let leftMatches = /* @__PURE__ */ new WeakSet();
|
||||
return (node, parent, i2 = 0) => {
|
||||
if (matchLeft(node)) {
|
||||
leftMatches.add(node);
|
||||
} else if (parent && leftMatches.has(parent) && combinator === " ") {
|
||||
leftMatches.add(node);
|
||||
}
|
||||
if (!matchRight(node)) return false;
|
||||
switch (combinator) {
|
||||
case " ":
|
||||
// fall-through
|
||||
case ">":
|
||||
return parent ? leftMatches.has(parent) : false;
|
||||
case "~": {
|
||||
if (!parent) return false;
|
||||
for (let sibling of parent.children.slice(0, i2)) {
|
||||
if (leftMatches.has(sibling)) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
case "+": {
|
||||
if (!parent) return false;
|
||||
let prevSiblings = parent.children.slice(0, i2).filter((el) => el.type === ELEMENT_NODE);
|
||||
if (prevSiblings.length === 0) return false;
|
||||
const prev = prevSiblings[prevSiblings.length - 1];
|
||||
if (!prev) return false;
|
||||
if (leftMatches.has(prev)) return true;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
default:
|
||||
return createMatch(selector);
|
||||
}
|
||||
};
|
||||
export {
|
||||
selector_default as default,
|
||||
matches,
|
||||
querySelector,
|
||||
querySelectorAll,
|
||||
specificity
|
||||
};
|
||||
+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 {};
|
||||
+1908
File diff suppressed because it is too large.
Load diff
+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 {};
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
// src/transformers/sanitize.ts
|
||||
import { ELEMENT_NODE, walkSync } from "../index.js";
|
||||
function resolveSantizeOptions(sanitize2) {
|
||||
if (sanitize2 === void 0) {
|
||||
return {
|
||||
allowElements: [],
|
||||
dropElements: ["script"],
|
||||
allowComponents: false,
|
||||
allowCustomElements: false,
|
||||
allowComments: false
|
||||
};
|
||||
} else {
|
||||
const dropElements = /* @__PURE__ */ new Set([]);
|
||||
if (!sanitize2.allowElements?.includes("script")) {
|
||||
dropElements.add("script");
|
||||
}
|
||||
for (const dropElement of sanitize2.dropElements ?? []) {
|
||||
dropElements.add(dropElement);
|
||||
}
|
||||
return {
|
||||
allowComponents: false,
|
||||
allowCustomElements: false,
|
||||
allowComments: false,
|
||||
...sanitize2,
|
||||
dropElements: Array.from(dropElements)
|
||||
};
|
||||
}
|
||||
}
|
||||
function getNodeKind(node) {
|
||||
if (node.name.includes("-")) return "custom-element";
|
||||
if (/[\_\$A-Z]/.test(node.name[0]) || node.name.includes("."))
|
||||
return "component";
|
||||
return "element";
|
||||
}
|
||||
function getAction(name, kind, sanitize2) {
|
||||
if (sanitize2.allowElements?.length > 0) {
|
||||
if (sanitize2.allowElements.includes(name)) return "allow";
|
||||
}
|
||||
if (sanitize2.blockElements?.length > 0) {
|
||||
if (sanitize2.blockElements.includes(name)) return "block";
|
||||
}
|
||||
if (sanitize2.dropElements?.length > 0) {
|
||||
if (sanitize2.dropElements.find((n) => n === name)) return "drop";
|
||||
}
|
||||
if (kind === "component" && !sanitize2.allowComponents) return "drop";
|
||||
if (kind === "custom-element" && !sanitize2.allowCustomElements) return "drop";
|
||||
if (sanitize2.unblockElements) {
|
||||
return sanitize2.unblockElements.some((n) => n === name) ? "allow" : "block";
|
||||
}
|
||||
return sanitize2.allowElements?.length > 0 ? "drop" : "allow";
|
||||
}
|
||||
function sanitizeAttributes(node, sanitize2) {
|
||||
const attrs = node.attributes;
|
||||
for (const key of Object.keys(node.attributes)) {
|
||||
if (sanitize2.allowAttributes?.[key] && sanitize2.allowAttributes?.[key].includes(node.name) || sanitize2.allowAttributes?.[key]?.includes("*")) {
|
||||
continue;
|
||||
}
|
||||
if (sanitize2.dropAttributes?.[key] && sanitize2.dropAttributes?.[key].includes(node.name) || sanitize2.dropAttributes?.[key]?.includes("*")) {
|
||||
delete attrs[key];
|
||||
}
|
||||
}
|
||||
return attrs;
|
||||
}
|
||||
function sanitizeElement(opts, node, parent) {
|
||||
const kind = getNodeKind(node);
|
||||
const { name } = node;
|
||||
const action = getAction(name, kind, opts);
|
||||
if (action === "drop")
|
||||
return () => {
|
||||
parent.children = parent.children.filter(
|
||||
(child) => child !== node
|
||||
);
|
||||
};
|
||||
if (action === "block")
|
||||
return () => {
|
||||
parent.children = parent.children.map((child) => child === node ? child.children : child).flat(1);
|
||||
};
|
||||
return () => {
|
||||
node.attributes = sanitizeAttributes(node, opts);
|
||||
};
|
||||
}
|
||||
function sanitize(opts) {
|
||||
const sanitize2 = resolveSantizeOptions(opts);
|
||||
return (doc) => {
|
||||
let actions = [];
|
||||
walkSync(doc, (node, parent) => {
|
||||
switch (node.type) {
|
||||
case ELEMENT_NODE: {
|
||||
actions.push(sanitizeElement(sanitize2, node, parent));
|
||||
return;
|
||||
}
|
||||
default:
|
||||
return;
|
||||
}
|
||||
});
|
||||
for (let i = actions.length - 1; i >= 0; i--) {
|
||||
actions[i]();
|
||||
}
|
||||
return doc;
|
||||
};
|
||||
}
|
||||
export {
|
||||
sanitize as default
|
||||
};
|
||||
+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 {};
|
||||
+707
@@ -0,0 +1,707 @@
|
||||
// node_modules/.pnpm/parsel-js@1.1.2/node_modules/parsel-js/dist/parsel.min.js
|
||||
var 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>¶*)\))?/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 };
|
||||
var t = /* @__PURE__ */ new Set(["combinator", "comma"]);
|
||||
var n = /* @__PURE__ */ new Set(["not", "is", "where", "has", "matches", "-moz-any", "-webkit-any", "nth-child", "nth-last-child"]);
|
||||
var s = /(?<index>[\dn+-]+)\s+of\s+(?<subtree>.+)/;
|
||||
var o = { "nth-child": s, "nth-last-child": s };
|
||||
var r = (t2) => {
|
||||
switch (t2) {
|
||||
case "pseudo-element":
|
||||
case "pseudo-class":
|
||||
return new RegExp(e[t2].source.replace("(?<argument>\xB6*)", "(?<argument>.*)"), "gu");
|
||||
default:
|
||||
return e[t2];
|
||||
}
|
||||
};
|
||||
function c(e2, t2) {
|
||||
let n2 = 0, s2 = "";
|
||||
for (; t2 < e2.length; t2++) {
|
||||
const o2 = e2[t2];
|
||||
switch (o2) {
|
||||
case "(":
|
||||
++n2;
|
||||
break;
|
||||
case ")":
|
||||
--n2;
|
||||
}
|
||||
if (s2 += o2, 0 === n2) return s2;
|
||||
}
|
||||
return s2;
|
||||
}
|
||||
function i(n2, s2 = e) {
|
||||
if (!n2) return [];
|
||||
const o2 = [n2];
|
||||
for (const [e2, t2] of Object.entries(s2)) for (let n3 = 0; n3 < o2.length; n3++) {
|
||||
const s3 = o2[n3];
|
||||
if ("string" != typeof s3) continue;
|
||||
t2.lastIndex = 0;
|
||||
const r3 = t2.exec(s3);
|
||||
if (!r3) continue;
|
||||
const c2 = r3.index - 1, i2 = [], a2 = r3[0], l2 = s3.slice(0, c2 + 1);
|
||||
l2 && i2.push(l2), i2.push({ ...r3.groups, type: e2, content: a2 });
|
||||
const u2 = s3.slice(c2 + a2.length + 1);
|
||||
u2 && i2.push(u2), o2.splice(n3, 1, ...i2);
|
||||
}
|
||||
let r2 = 0;
|
||||
for (const e2 of o2) switch (typeof e2) {
|
||||
case "string":
|
||||
throw new Error(`Unexpected sequence ${e2} found at index ${r2}`);
|
||||
case "object":
|
||||
r2 += e2.content.length, e2.pos = [r2 - e2.content.length, r2], t.has(e2.type) && (e2.content = e2.content.trim() || " ");
|
||||
}
|
||||
return o2;
|
||||
}
|
||||
var a = /(['"])([^\\\n]+?)\1/g;
|
||||
var l = /\\./g;
|
||||
function u(t2, n2 = e) {
|
||||
if ("" === (t2 = t2.trim())) return [];
|
||||
const s2 = [];
|
||||
t2 = (t2 = t2.replace(l, (e2, t3) => (s2.push({ value: e2, offset: t3 }), "\uE000".repeat(e2.length)))).replace(a, (e2, t3, n3, o3) => (s2.push({ value: e2, offset: o3 }), `${t3}${"\uE001".repeat(n3.length)}${t3}`));
|
||||
{
|
||||
let e2, n3 = 0;
|
||||
for (; (e2 = t2.indexOf("(", n3)) > -1; ) {
|
||||
const o3 = c(t2, e2);
|
||||
s2.push({ value: o3, offset: e2 }), t2 = `${t2.substring(0, e2)}(${"\xB6".repeat(o3.length - 2)})${t2.substring(e2 + o3.length)}`, n3 = e2 + o3.length;
|
||||
}
|
||||
}
|
||||
const o2 = i(t2, n2), u2 = /* @__PURE__ */ new Set();
|
||||
for (const e2 of s2.reverse()) for (const t3 of o2) {
|
||||
const { offset: n3, value: s3 } = e2;
|
||||
if (!(t3.pos[0] <= n3 && n3 + s3.length <= t3.pos[1])) continue;
|
||||
const { content: o3 } = t3, r2 = n3 - t3.pos[0];
|
||||
t3.content = o3.slice(0, r2) + s3 + o3.slice(r2 + s3.length), t3.content !== o3 && u2.add(t3);
|
||||
}
|
||||
for (const e2 of u2) {
|
||||
const t3 = r(e2.type);
|
||||
if (!t3) throw new Error(`Unknown token type: ${e2.type}`);
|
||||
t3.lastIndex = 0;
|
||||
const n3 = t3.exec(e2.content);
|
||||
if (!n3) throw new Error(`Unable to parse content for ${e2.type}: ${e2.content}`);
|
||||
Object.assign(e2, n3.groups);
|
||||
}
|
||||
return o2;
|
||||
}
|
||||
function f(e2, { list: t2 = true } = {}) {
|
||||
if (t2 && e2.find((e3) => "comma" === e3.type)) {
|
||||
const t3 = [], n2 = [];
|
||||
for (let s2 = 0; s2 < e2.length; s2++) if ("comma" === e2[s2].type) {
|
||||
if (0 === n2.length) throw new Error("Incorrect comma at " + s2);
|
||||
t3.push(f(n2, { list: false })), n2.length = 0;
|
||||
} else n2.push(e2[s2]);
|
||||
if (0 === n2.length) throw new Error("Trailing comma");
|
||||
return t3.push(f(n2, { list: false })), { type: "list", list: t3 };
|
||||
}
|
||||
for (let t3 = e2.length - 1; t3 >= 0; t3--) {
|
||||
let n2 = e2[t3];
|
||||
if ("combinator" === n2.type) {
|
||||
let s2 = e2.slice(0, t3), o2 = e2.slice(t3 + 1);
|
||||
return { type: "complex", combinator: n2.content, left: f(s2), right: f(o2) };
|
||||
}
|
||||
}
|
||||
switch (e2.length) {
|
||||
case 0:
|
||||
throw new Error("Could not build AST.");
|
||||
case 1:
|
||||
return e2[0];
|
||||
default:
|
||||
return { type: "compound", list: [...e2] };
|
||||
}
|
||||
}
|
||||
function* p(e2, t2) {
|
||||
switch (e2.type) {
|
||||
case "list":
|
||||
for (let t3 of e2.list) yield* p(t3, e2);
|
||||
break;
|
||||
case "complex":
|
||||
yield* p(e2.left, e2), yield* p(e2.right, e2);
|
||||
break;
|
||||
case "compound":
|
||||
yield* e2.list.map((t3) => [t3, e2]);
|
||||
break;
|
||||
default:
|
||||
yield [e2, t2];
|
||||
}
|
||||
}
|
||||
function m(e2, { recursive: t2 = true, list: s2 = true } = {}) {
|
||||
const r2 = u(e2);
|
||||
if (!r2) return;
|
||||
const c2 = f(r2, { list: s2 });
|
||||
if (!t2) return c2;
|
||||
for (const [e3] of p(c2)) {
|
||||
if ("pseudo-class" !== e3.type || !e3.argument) continue;
|
||||
if (!n.has(e3.name)) continue;
|
||||
let t3 = e3.argument;
|
||||
const s3 = o[e3.name];
|
||||
if (s3) {
|
||||
const n2 = s3.exec(t3);
|
||||
if (!n2) continue;
|
||||
Object.assign(e3, n2.groups), t3 = n2.groups.subtree;
|
||||
}
|
||||
t3 && Object.assign(e3, { subtree: m(t3, { recursive: true, list: true }) });
|
||||
}
|
||||
return c2;
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Enum.js
|
||||
var COMMENT = "comm";
|
||||
var RULESET = "rule";
|
||||
var DECLARATION = "decl";
|
||||
var IMPORT = "@import";
|
||||
var KEYFRAMES = "@keyframes";
|
||||
var LAYER = "@layer";
|
||||
|
||||
// node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Utility.js
|
||||
var abs = Math.abs;
|
||||
var from = String.fromCharCode;
|
||||
function trim(value) {
|
||||
return value.trim();
|
||||
}
|
||||
function replace(value, pattern, replacement) {
|
||||
return value.replace(pattern, replacement);
|
||||
}
|
||||
function indexof(value, search, position2) {
|
||||
return value.indexOf(search, position2);
|
||||
}
|
||||
function charat(value, index) {
|
||||
return value.charCodeAt(index) | 0;
|
||||
}
|
||||
function substr(value, begin, end) {
|
||||
return value.slice(begin, end);
|
||||
}
|
||||
function strlen(value) {
|
||||
return value.length;
|
||||
}
|
||||
function sizeof(value) {
|
||||
return value.length;
|
||||
}
|
||||
function append(value, array) {
|
||||
return array.push(value), value;
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Tokenizer.js
|
||||
var line = 1;
|
||||
var column = 1;
|
||||
var length = 0;
|
||||
var position = 0;
|
||||
var character = 0;
|
||||
var characters = "";
|
||||
function node(value, root, parent, type, props, children, length2, siblings) {
|
||||
return { value, root, parent, type, props, children, line, column, length: length2, return: "", siblings };
|
||||
}
|
||||
function char() {
|
||||
return character;
|
||||
}
|
||||
function prev() {
|
||||
character = position > 0 ? charat(characters, --position) : 0;
|
||||
if (column--, character === 10)
|
||||
column = 1, line--;
|
||||
return character;
|
||||
}
|
||||
function next() {
|
||||
character = position < length ? charat(characters, position++) : 0;
|
||||
if (column++, character === 10)
|
||||
column = 1, line++;
|
||||
return character;
|
||||
}
|
||||
function peek() {
|
||||
return charat(characters, position);
|
||||
}
|
||||
function caret() {
|
||||
return position;
|
||||
}
|
||||
function slice(begin, end) {
|
||||
return substr(characters, begin, end);
|
||||
}
|
||||
function token(type) {
|
||||
switch (type) {
|
||||
// \0 \t \n \r \s whitespace token
|
||||
case 0:
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
case 32:
|
||||
return 5;
|
||||
// ! + , / > @ ~ isolate token
|
||||
case 33:
|
||||
case 43:
|
||||
case 44:
|
||||
case 47:
|
||||
case 62:
|
||||
case 64:
|
||||
case 126:
|
||||
// ; { } breakpoint token
|
||||
case 59:
|
||||
case 123:
|
||||
case 125:
|
||||
return 4;
|
||||
// : accompanied token
|
||||
case 58:
|
||||
return 3;
|
||||
// " ' ( [ opening delimit token
|
||||
case 34:
|
||||
case 39:
|
||||
case 40:
|
||||
case 91:
|
||||
return 2;
|
||||
// ) ] closing delimit token
|
||||
case 41:
|
||||
case 93:
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
function alloc(value) {
|
||||
return line = column = 1, length = strlen(characters = value), position = 0, [];
|
||||
}
|
||||
function dealloc(value) {
|
||||
return characters = "", value;
|
||||
}
|
||||
function delimit(type) {
|
||||
return trim(slice(position - 1, delimiter(type === 91 ? type + 2 : type === 40 ? type + 1 : type)));
|
||||
}
|
||||
function whitespace(type) {
|
||||
while (character = peek())
|
||||
if (character < 33)
|
||||
next();
|
||||
else
|
||||
break;
|
||||
return token(type) > 2 || token(character) > 3 ? "" : " ";
|
||||
}
|
||||
function escaping(index, count) {
|
||||
while (--count && next())
|
||||
if (character < 48 || character > 102 || character > 57 && character < 65 || character > 70 && character < 97)
|
||||
break;
|
||||
return slice(index, caret() + (count < 6 && peek() == 32 && next() == 32));
|
||||
}
|
||||
function delimiter(type) {
|
||||
while (next())
|
||||
switch (character) {
|
||||
// ] ) " '
|
||||
case type:
|
||||
return position;
|
||||
// " '
|
||||
case 34:
|
||||
case 39:
|
||||
if (type !== 34 && type !== 39)
|
||||
delimiter(character);
|
||||
break;
|
||||
// (
|
||||
case 40:
|
||||
if (type === 41)
|
||||
delimiter(type);
|
||||
break;
|
||||
// \
|
||||
case 92:
|
||||
next();
|
||||
break;
|
||||
}
|
||||
return position;
|
||||
}
|
||||
function commenter(type, index) {
|
||||
while (next())
|
||||
if (type + character === 47 + 10)
|
||||
break;
|
||||
else if (type + character === 42 + 42 && peek() === 47)
|
||||
break;
|
||||
return "/*" + slice(index, position - 1) + "*" + from(type === 47 ? type : next());
|
||||
}
|
||||
function identifier(index) {
|
||||
while (!token(peek()))
|
||||
next();
|
||||
return slice(index, position);
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Parser.js
|
||||
function compile(value) {
|
||||
return dealloc(parse("", null, null, null, [""], value = alloc(value), 0, [0], value));
|
||||
}
|
||||
function parse(value, root, parent, rule, rules, rulesets, pseudo, points, declarations) {
|
||||
var index = 0;
|
||||
var offset = 0;
|
||||
var length2 = pseudo;
|
||||
var atrule = 0;
|
||||
var property = 0;
|
||||
var previous = 0;
|
||||
var variable = 1;
|
||||
var scanning = 1;
|
||||
var ampersand = 1;
|
||||
var character2 = 0;
|
||||
var type = "";
|
||||
var props = rules;
|
||||
var children = rulesets;
|
||||
var reference = rule;
|
||||
var characters2 = type;
|
||||
while (scanning)
|
||||
switch (previous = character2, character2 = next()) {
|
||||
// (
|
||||
case 40:
|
||||
if (previous != 108 && charat(characters2, length2 - 1) == 58) {
|
||||
if (indexof(characters2 += replace(delimit(character2), "&", "&\f"), "&\f", abs(index ? points[index - 1] : 0)) != -1)
|
||||
ampersand = -1;
|
||||
break;
|
||||
}
|
||||
// " ' [
|
||||
case 34:
|
||||
case 39:
|
||||
case 91:
|
||||
characters2 += delimit(character2);
|
||||
break;
|
||||
// \t \n \r \s
|
||||
case 9:
|
||||
case 10:
|
||||
case 13:
|
||||
case 32:
|
||||
characters2 += whitespace(previous);
|
||||
break;
|
||||
// \
|
||||
case 92:
|
||||
characters2 += escaping(caret() - 1, 7);
|
||||
continue;
|
||||
// /
|
||||
case 47:
|
||||
switch (peek()) {
|
||||
case 42:
|
||||
case 47:
|
||||
append(comment(commenter(next(), caret()), root, parent, declarations), declarations);
|
||||
if ((token(previous || 1) == 5 || token(peek() || 1) == 5) && strlen(characters2) && substr(characters2, -1, void 0) !== " ") characters2 += " ";
|
||||
break;
|
||||
default:
|
||||
characters2 += "/";
|
||||
}
|
||||
break;
|
||||
// {
|
||||
case 123 * variable:
|
||||
points[index++] = strlen(characters2) * ampersand;
|
||||
// } ; \0
|
||||
case 125 * variable:
|
||||
case 59:
|
||||
case 0:
|
||||
switch (character2) {
|
||||
// \0 }
|
||||
case 0:
|
||||
case 125:
|
||||
scanning = 0;
|
||||
// ;
|
||||
case 59 + offset:
|
||||
if (ampersand == -1) characters2 = replace(characters2, /\f/g, "");
|
||||
if (property > 0 && (strlen(characters2) - length2 || variable === 0 && previous === 47))
|
||||
append(property > 32 ? declaration(characters2 + ";", rule, parent, length2 - 1, declarations) : declaration(replace(characters2, " ", "") + ";", rule, parent, length2 - 2, declarations), declarations);
|
||||
break;
|
||||
// @ ;
|
||||
case 59:
|
||||
characters2 += ";";
|
||||
// { rule/at-rule
|
||||
default:
|
||||
append(reference = ruleset(characters2, root, parent, index, offset, rules, points, type, props = [], children = [], length2, rulesets), rulesets);
|
||||
if (character2 === 123)
|
||||
if (offset === 0)
|
||||
parse(characters2, root, reference, reference, props, rulesets, length2, points, children);
|
||||
else
|
||||
switch (atrule === 99 && charat(characters2, 3) === 110 ? 100 : atrule) {
|
||||
// d l m s
|
||||
case 100:
|
||||
case 108:
|
||||
case 109:
|
||||
case 115:
|
||||
parse(value, reference, reference, rule && append(ruleset(value, reference, reference, 0, 0, rules, points, type, rules, props = [], length2, children), children), rules, children, length2, points, rule ? props : children);
|
||||
break;
|
||||
default:
|
||||
parse(characters2, reference, reference, reference, [""], children, 0, points, children);
|
||||
}
|
||||
}
|
||||
index = offset = property = 0, variable = ampersand = 1, type = characters2 = "", length2 = pseudo;
|
||||
break;
|
||||
// :
|
||||
case 58:
|
||||
length2 = 1 + strlen(characters2), property = previous;
|
||||
default:
|
||||
if (variable < 1) {
|
||||
if (character2 == 123)
|
||||
--variable;
|
||||
else if (character2 == 125 && variable++ == 0 && prev() == 125)
|
||||
continue;
|
||||
}
|
||||
switch (characters2 += from(character2), character2 * variable) {
|
||||
// &
|
||||
case 38:
|
||||
ampersand = offset > 0 ? 1 : (characters2 += "\f", -1);
|
||||
break;
|
||||
// ,
|
||||
case 44:
|
||||
points[index++] = (strlen(characters2) - 1) * ampersand, ampersand = 1;
|
||||
break;
|
||||
// @
|
||||
case 64:
|
||||
if (peek() === 45)
|
||||
characters2 += delimit(next());
|
||||
atrule = peek(), offset = length2 = strlen(type = characters2 += identifier(caret())), character2++;
|
||||
break;
|
||||
// -
|
||||
case 45:
|
||||
if (previous === 45 && strlen(characters2) == 2)
|
||||
variable = 0;
|
||||
}
|
||||
}
|
||||
return rulesets;
|
||||
}
|
||||
function ruleset(value, root, parent, index, offset, rules, points, type, props, children, length2, siblings) {
|
||||
var post = offset - 1;
|
||||
var rule = offset === 0 ? rules : [""];
|
||||
var size = sizeof(rule);
|
||||
for (var i2 = 0, j = 0, k = 0; i2 < index; ++i2)
|
||||
for (var x = 0, y = substr(value, post + 1, post = abs(j = points[i2])), z = value; x < size; ++x)
|
||||
if (z = trim(j > 0 ? rule[x] + " " + y : replace(y, /&\f/g, rule[x])))
|
||||
props[k++] = z;
|
||||
return node(value, root, parent, offset === 0 ? RULESET : type, props, children, length2, siblings);
|
||||
}
|
||||
function comment(value, root, parent, siblings) {
|
||||
return node(value, root, parent, COMMENT, from(char()), substr(value, 2, -2), 0, siblings);
|
||||
}
|
||||
function declaration(value, root, parent, length2, siblings) {
|
||||
return node(value, root, parent, DECLARATION, substr(value, 0, length2), substr(value, length2 + 1, -1), length2, siblings);
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Serializer.js
|
||||
function serialize(children, callback) {
|
||||
var output = "";
|
||||
for (var i2 = 0; i2 < children.length; i2++)
|
||||
output += callback(children[i2], i2, children, callback) || "";
|
||||
return output;
|
||||
}
|
||||
function stringify(element, index, children, callback) {
|
||||
switch (element.type) {
|
||||
case LAYER:
|
||||
if (element.children.length) break;
|
||||
case IMPORT:
|
||||
case DECLARATION:
|
||||
return element.return = element.return || element.value;
|
||||
case COMMENT:
|
||||
return "";
|
||||
case KEYFRAMES:
|
||||
return element.return = element.value + "{" + serialize(element.children, callback) + "}";
|
||||
case RULESET:
|
||||
if (!strlen(element.value = element.props.join(","))) return "";
|
||||
}
|
||||
return strlen(children = serialize(element.children, callback)) ? element.return = element.value + "{" + children + "}" : "";
|
||||
}
|
||||
|
||||
// node_modules/.pnpm/stylis@4.3.4/node_modules/stylis/src/Middleware.js
|
||||
function middleware(collection) {
|
||||
var length2 = sizeof(collection);
|
||||
return function(element, index, children, callback) {
|
||||
var output = "";
|
||||
for (var i2 = 0; i2 < length2; i2++)
|
||||
output += collection[i2](element, index, children, callback) || "";
|
||||
return output;
|
||||
};
|
||||
}
|
||||
|
||||
// src/transformers/scope.ts
|
||||
import { ELEMENT_NODE, TEXT_NODE, render, walkSync } from "../index.js";
|
||||
import { matches } from "../selector.js";
|
||||
function scope(opts = {}) {
|
||||
return async (doc) => {
|
||||
const hash = opts.hash ?? shorthash(await render(doc));
|
||||
const actions = [];
|
||||
let hasStyle = false;
|
||||
const selectors = /* @__PURE__ */ new Set();
|
||||
const nodes = /* @__PURE__ */ new Set();
|
||||
walkSync(doc, (node2) => {
|
||||
if (node2.type === ELEMENT_NODE && node2.name === "style") {
|
||||
if (!opts.attribute || hasAttribute(node2, opts.attribute)) {
|
||||
hasStyle = true;
|
||||
if (opts.attribute) {
|
||||
delete node2.attributes[opts.attribute];
|
||||
}
|
||||
for (const selector of getSelectors(node2.children[0].value)) {
|
||||
selectors.add(selector);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (node2.type === ELEMENT_NODE) {
|
||||
nodes.add(node2);
|
||||
}
|
||||
});
|
||||
if (hasStyle) {
|
||||
walkSync(doc, (node2) => {
|
||||
if (node2.type === ELEMENT_NODE) {
|
||||
actions.push(() => scopeElement(node2, hash, selectors));
|
||||
if (node2.name === "style") {
|
||||
actions.push(() => {
|
||||
node2.children = node2.children.map((c2) => {
|
||||
if (c2.type !== TEXT_NODE) return c2;
|
||||
c2.value = scopeCSS(c2.value, hash);
|
||||
if (c2.value === "") {
|
||||
node2.parent.children = node2.parent.children.filter(
|
||||
(s2) => s2 !== node2
|
||||
);
|
||||
}
|
||||
return c2;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
for (const action of actions) {
|
||||
action();
|
||||
}
|
||||
return doc;
|
||||
};
|
||||
}
|
||||
var NEVER_SCOPED = /* @__PURE__ */ new Set([
|
||||
"base",
|
||||
"font",
|
||||
"frame",
|
||||
"frameset",
|
||||
"head",
|
||||
"link",
|
||||
"meta",
|
||||
"noframes",
|
||||
"noscript",
|
||||
"script",
|
||||
"style",
|
||||
"title"
|
||||
]);
|
||||
function hasAttribute(node2, name) {
|
||||
if (name in node2.attributes) {
|
||||
return node2.attributes[name] !== "false";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function scopeElement(node2, hash, selectors) {
|
||||
const { name } = node2;
|
||||
if (!name) return;
|
||||
if (name.length < 1) return;
|
||||
if (NEVER_SCOPED.has(name)) return;
|
||||
if (node2.attributes["data-scope"]) return;
|
||||
for (const selector of selectors) {
|
||||
if (matches(node2, selector)) {
|
||||
node2.attributes["data-scope"] = hash;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
function scopeSelector(selector, hash) {
|
||||
const ast = m(selector);
|
||||
const scope2 = (node2) => {
|
||||
switch (node2.type) {
|
||||
case "pseudo-class": {
|
||||
if (node2.name === "root") return node2.content;
|
||||
if (node2.name === "global") return node2.argument;
|
||||
return `${node2.content}:where([data-scope="${hash}"])`;
|
||||
}
|
||||
case "compound":
|
||||
return `${selector}:where([data-scope="${hash}"])`;
|
||||
case "complex": {
|
||||
const { left, right, combinator } = node2;
|
||||
return `${scope2(left)}${combinator}${scope2(right)}`;
|
||||
}
|
||||
case "list":
|
||||
return node2.list.map((s2) => scope2(s2)).join(" ");
|
||||
default:
|
||||
return `${node2.content}:where([data-scope="${hash}"])`;
|
||||
}
|
||||
};
|
||||
return scope2(ast);
|
||||
}
|
||||
function scopeCSS(css, hash) {
|
||||
return serialize(
|
||||
compile(css),
|
||||
middleware([
|
||||
(element) => {
|
||||
if (element.type === "rule") {
|
||||
if (Array.isArray(element.props)) {
|
||||
element.props = element.props.map(
|
||||
(prop) => scopeSelector(prop, hash)
|
||||
);
|
||||
} else {
|
||||
element.props = scopeSelector(element.props, hash);
|
||||
}
|
||||
}
|
||||
},
|
||||
stringify
|
||||
])
|
||||
);
|
||||
}
|
||||
function getSelectors(css) {
|
||||
const selectors = /* @__PURE__ */ new Set();
|
||||
serialize(
|
||||
compile(css),
|
||||
middleware([
|
||||
(element) => {
|
||||
if (element.type === "rule") {
|
||||
if (Array.isArray(element.props)) {
|
||||
for (const p2 of element.props) {
|
||||
selectors.add(p2);
|
||||
}
|
||||
} else {
|
||||
selectors.add(element.props);
|
||||
}
|
||||
}
|
||||
}
|
||||
])
|
||||
);
|
||||
return Array.from(selectors);
|
||||
}
|
||||
var dictionary = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY";
|
||||
var binary = dictionary.length;
|
||||
function bitwise(str) {
|
||||
let hash = 0;
|
||||
if (str.length === 0) return hash;
|
||||
for (let i2 = 0; i2 < str.length; i2++) {
|
||||
const ch = str.charCodeAt(i2);
|
||||
hash = (hash << 5) - hash + ch;
|
||||
hash = hash & hash;
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
function shorthash(text) {
|
||||
let num;
|
||||
let result = "";
|
||||
let integer = bitwise(text);
|
||||
const sign = integer < 0 ? "Z" : "";
|
||||
integer = Math.abs(integer);
|
||||
while (integer >= binary) {
|
||||
num = integer % binary;
|
||||
integer = Math.floor(integer / binary);
|
||||
result = dictionary[num] + result;
|
||||
}
|
||||
if (integer > 0) {
|
||||
result = dictionary[integer] + result;
|
||||
}
|
||||
return sign + result;
|
||||
}
|
||||
export {
|
||||
scope as default
|
||||
};
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
+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 {};
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// src/transformers/swap.ts
|
||||
import { RenderFn } from "../index.js";
|
||||
import { __unsafeRenderFn } from "../index.js";
|
||||
import { querySelectorAll } from "../selector.js";
|
||||
function swap(components = {}) {
|
||||
return (doc) => {
|
||||
for (const [selector, component] of Object.entries(components)) {
|
||||
for (const node of querySelectorAll(doc, selector)) {
|
||||
if (typeof component === "string") {
|
||||
node.name = component;
|
||||
if (RenderFn in node) {
|
||||
delete node[RenderFn];
|
||||
}
|
||||
} else if (typeof component === "function") {
|
||||
__unsafeRenderFn(node, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
return doc;
|
||||
};
|
||||
}
|
||||
export {
|
||||
swap as default
|
||||
};
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './dist/jsx-runtime/index';
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
{
|
||||
"name": "ultrahtml",
|
||||
"type": "module",
|
||||
"version": "1.7.0",
|
||||
"types": "./dist/index.d.ts",
|
||||
"main": "./dist/index.js",
|
||||
"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": "24.18.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@biomejs/biome": "1.9.2",
|
||||
"@changesets/cli": "^2.27.8",
|
||||
"@types/stylis": "^4.2.6",
|
||||
"dts-bundle-generator": "^9.5.1",
|
||||
"esbuild": "^0.25.2",
|
||||
"gzip-size": "^7.0.0",
|
||||
"markdown-it": "^13.0.2",
|
||||
"media-query-fns": "^2.0.0",
|
||||
"parsel-js": "^1.1.2",
|
||||
"pretty-bytes": "^6.1.1",
|
||||
"stylis": "^4.3.4",
|
||||
"vitest": "^2.1.1"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "node scripts/build.js",
|
||||
"format": "biome format --write",
|
||||
"dev": "vitest",
|
||||
"test": "vitest run"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './dist/selector';
|
||||
+1
@@ -0,0 +1 @@
|
||||
export * from './dist/transform';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { default } from '../dist/transformers/inline';
|
||||
export * from '../dist/transformers/inline';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { default } from '../dist/transformers/sanitize';
|
||||
export * from '../dist/transformers/sanitize';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { default } from '../dist/transformers/scope';
|
||||
export * from '../dist/transformers/scope';
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
export { default } from '../dist/transformers/swap';
|
||||
export * from '../dist/transformers/swap';
|
||||
Reference in new issue
Block a user