Auto-commit 2026-04-29 16:31

This commit is contained in:
2026-04-29 16:31:27 -04:00
parent e8687bb6b2
commit 0495ee5bd2
19691 changed files with 3272886 additions and 138 deletions

21
node_modules/preact-render-to-string/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 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.

91
node_modules/preact-render-to-string/README.md generated vendored Normal file
View File

@@ -0,0 +1,91 @@
# preact-render-to-string
[![NPM](http://img.shields.io/npm/v/preact-render-to-string.svg)](https://www.npmjs.com/package/preact-render-to-string)
[![Build status](https://github.com/preactjs/preact-render-to-string/actions/workflows/ci.yml/badge.svg)](https://github.com/preactjs/preact-render-to-string/actions/workflows/ci.yml)
Render JSX and [Preact](https://github.com/preactjs/preact) components to an HTML string.
Works in Node & the browser, making it useful for universal/isomorphic rendering.
\>\> **[Cute Fox-Related Demo](http://codepen.io/developit/pen/dYZqjE?editors=001)** _(@ CodePen)_ <<
---
### Render JSX/VDOM to HTML
```js
import { render } from 'preact-render-to-string';
import { h } from 'preact';
/** @jsx h */
let vdom = <div class="foo">content</div>;
let html = render(vdom);
console.log(html);
// <div class="foo">content</div>
```
### Render Preact Components to HTML
```js
import { render } from 'preact-render-to-string';
import { h, Component } from 'preact';
/** @jsx h */
// Classical components work
class Fox extends Component {
render({ name }) {
return <span class="fox">{name}</span>;
}
}
// ... and so do pure functional components:
const Box = ({ type, children }) => (
<div class={`box box-${type}`}>{children}</div>
);
let html = render(
<Box type="open">
<Fox name="Finn" />
</Box>
);
console.log(html);
// <div class="box box-open"><span class="fox">Finn</span></div>
```
---
### Render JSX / Preact / Whatever via Express!
```js
import express from 'express';
import { h } from 'preact';
import { render } from 'preact-render-to-string';
/** @jsx h */
// silly example component:
const Fox = ({ name }) => (
<div class="fox">
<h5>{name}</h5>
<p>This page is all about {name}.</p>
</div>
);
// basic HTTP server via express:
const app = express();
app.listen(8080);
// on each request, render and return a component:
app.get('/:fox', (req, res) => {
let html = render(<Fox name={req.params.fox} />);
// send it back wrapped up as an HTML5 document:
res.send(`<!DOCTYPE html><html><body>${html}</body></html>`);
});
```
---
### License
[MIT](http://choosealicense.com/licenses/mit/)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

16
node_modules/preact-render-to-string/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import { VNode } from 'preact';
interface Options {
shallow?: boolean;
xml?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export function renderToString(
vnode: VNode,
context?: any,
options?: Options
): string;
export function shallowRender(vnode: VNode, context?: any): string;
export default render;

1
node_modules/preact-render-to-string/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./commonjs').default;

File diff suppressed because one or more lines are too long

2
node_modules/preact-render-to-string/dist/index.mjs generated vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

13
node_modules/preact-render-to-string/dist/jsx.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { VNode } from 'preact';
interface Options {
jsx?: boolean;
xml?: boolean;
functions?: boolean;
functionNames?: boolean;
skipFalseAttributes?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export default render;

1
node_modules/preact-render-to-string/dist/jsx.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./jsx-entry').default;

1
node_modules/preact-render-to-string/dist/jsx.js.map generated vendored Normal file

File diff suppressed because one or more lines are too long

2
node_modules/preact-render-to-string/dist/jsx.mjs generated vendored Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
export {};

1
node_modules/preact-render-to-string/jsx.js generated vendored Normal file
View File

@@ -0,0 +1 @@
module.exports = require('./dist/jsx'); // eslint-disable-line

View File

@@ -0,0 +1,3 @@
__tests__
perf
.travis.yml

View File

@@ -0,0 +1,15 @@
## ISC License
Copyright (c) 2016, James Kyle <me@thejameskyle.com>
Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.

View File

@@ -0,0 +1,94 @@
# pretty-format [![Travis build status](http://img.shields.io/travis/thejameskyle/pretty-format.svg?style=flat)](https://travis-ci.org/thejameskyle/pretty-format)
> Stringify any JavaScript value.
- Supports [all built-in JavaScript types](#type-support)
- [Blazingly fast](https://gist.github.com/thejameskyle/2b04ffe4941aafa8f970de077843a8fd) (similar performance to v8's `JSON.stringify` and significantly faster than Node's `util.format`)
- Plugin system for extending with custom types (i.e. [`ReactTestComponent`](#reacttestcomponent-plugin))
## Installation
```sh
$ npm install pretty-format
```
## Usage
```js
var prettyFormat = require('pretty-format');
var obj = { property: {} };
obj.circularReference = obj;
obj[Symbol('foo')] = 'foo';
obj.map = new Map();
obj.map.set('prop', 'value');
obj.array = [1, NaN, Infinity];
console.log(prettyFormat(obj));
```
**Result:**
```js
Object {
"property": Object {},
"circularReference": [Circular],
"map": Map {
"prop" => "value"
},
"array": Array [
1,
NaN,
Infinity
],
Symbol(foo): "foo"
}
```
#### Type Support
`Object`, `Array`, `ArrayBuffer`, `DataView`, `Float32Array`, `Float64Array`, `Int8Array`, `Int16Array`, `Int32Array`, `Uint8Array`, `Uint8ClampedArray`, `Uint16Array`, `Uint32Array`, `arguments`, `Boolean`, `Date`, `Error`, `Function`, `Infinity`, `Map`, `NaN`, `null`, `Number`, `RegExp`, `Set`, `String`, `Symbol`, `undefined`, `WeakMap`, `WeakSet`
### Plugins
Pretty format also supports adding plugins:
```js
var fooPlugin = {
test: function(val) {
return val && val.hasOwnProperty('foo');
},
print: function(val, print, indent) {
return 'Foo: ' + print(val.foo);
}
};
var obj = { foo: { bar: {} } };
prettyFormat(obj, {
plugins: [fooPlugin]
});
// Foo: Object {
// "bar": Object {}
// }
```
#### `ReactTestComponent` plugin
```js
var prettyFormat = require('pretty-format');
var reactPlugin = require('pretty-format/plugins/ReactTestComponent');
var React = require('react');
var renderer = require('react/lib/ReactTestRenderer');
var jsx = React.createElement('h1', null, 'Hello World');
prettyFormat(renderer.create(jsx).toJSON(), {
plugins: [reactPlugin]
});
// <h1>
// Hello World
// </h1>
```

View File

@@ -0,0 +1,343 @@
'use strict';
const printString = require('./printString');
const toString = Object.prototype.toString;
const toISOString = Date.prototype.toISOString;
const errorToString = Error.prototype.toString;
const regExpToString = RegExp.prototype.toString;
const symbolToString = Symbol.prototype.toString;
const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
const NEWLINE_REGEXP = /\n/ig;
const getSymbols = Object.getOwnPropertySymbols || (obj => []);
function isToStringedArrayType(toStringed) {
return (
toStringed === '[object Array]' ||
toStringed === '[object ArrayBuffer]' ||
toStringed === '[object DataView]' ||
toStringed === '[object Float32Array]' ||
toStringed === '[object Float64Array]' ||
toStringed === '[object Int8Array]' ||
toStringed === '[object Int16Array]' ||
toStringed === '[object Int32Array]' ||
toStringed === '[object Uint8Array]' ||
toStringed === '[object Uint8ClampedArray]' ||
toStringed === '[object Uint16Array]' ||
toStringed === '[object Uint32Array]'
);
}
function printNumber(val) {
if (val != +val) return 'NaN';
const isNegativeZero = val === 0 && (1 / val) < 0;
return isNegativeZero ? '-0' : '' + val;
}
function printFunction(val) {
if (val.name === '') {
return '[Function anonymous]'
} else {
return '[Function ' + val.name + ']';
}
}
function printSymbol(val) {
return symbolToString.call(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
}
function printError(val) {
return '[' + errorToString.call(val) + ']';
}
function printBasicValue(val) {
if (val === true || val === false) return '' + val;
if (val === undefined) return 'undefined';
if (val === null) return 'null';
const typeOf = typeof val;
if (typeOf === 'number') return printNumber(val);
if (typeOf === 'string') return '"' + printString(val) + '"';
if (typeOf === 'function') return printFunction(val);
if (typeOf === 'symbol') return printSymbol(val);
const toStringed = toString.call(val);
if (toStringed === '[object WeakMap]') return 'WeakMap {}';
if (toStringed === '[object WeakSet]') return 'WeakSet {}';
if (toStringed === '[object Function]' || toStringed === '[object GeneratorFunction]') return printFunction(val, min);
if (toStringed === '[object Symbol]') return printSymbol(val);
if (toStringed === '[object Date]') return toISOString.call(val);
if (toStringed === '[object Error]') return printError(val);
if (toStringed === '[object RegExp]') return regExpToString.call(val);
if (toStringed === '[object Arguments]' && val.length === 0) return 'Arguments []';
if (isToStringedArrayType(toStringed) && val.length === 0) return val.constructor.name + ' []';
if (val instanceof Error) return printError(val);
return false;
}
function printList(list, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
let body = '';
if (list.length) {
body += edgeSpacing;
const innerIndent = prevIndent + indent;
for (let i = 0; i < list.length; i++) {
body += innerIndent + print(list[i], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
if (i < list.length - 1) {
body += ',' + spacing;
}
}
body += edgeSpacing + prevIndent;
}
return '[' + body + ']';
}
function printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
return (min ? '' : 'Arguments ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
}
function printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
return (min ? '' : val.constructor.name + ' ') + printList(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
}
function printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
let result = 'Map {';
const iterator = val.entries();
let current = iterator.next();
if (!current.done) {
result += edgeSpacing;
const innerIndent = prevIndent + indent;
while (!current.done) {
const key = print(current.value[0], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
const value = print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
result += innerIndent + key + ' => ' + value;
current = iterator.next();
if (!current.done) {
result += ',' + spacing;
}
}
result += edgeSpacing + prevIndent;
}
return result + '}';
}
function printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
const constructor = min ? '' : (val.constructor ? val.constructor.name + ' ' : 'Object ');
let result = constructor + '{';
let keys = Object.keys(val).sort();
const symbols = getSymbols(val);
if (symbols.length) {
keys = keys
.filter(key => !(typeof key === 'symbol' || toString.call(key) === '[object Symbol]'))
.concat(symbols);
}
if (keys.length) {
result += edgeSpacing;
const innerIndent = prevIndent + indent;
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
const name = print(key, indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
const value = print(val[key], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
result += innerIndent + name + ': ' + value;
if (i < keys.length - 1) {
result += ',' + spacing;
}
}
result += edgeSpacing + prevIndent;
}
return result + '}';
}
function printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
let result = 'Set {';
const iterator = val.entries();
let current = iterator.next();
if (!current.done) {
result += edgeSpacing;
const innerIndent = prevIndent + indent;
while (!current.done) {
result += innerIndent + print(current.value[1], indent, innerIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
current = iterator.next();
if (!current.done) {
result += ',' + spacing;
}
}
result += edgeSpacing + prevIndent;
}
return result + '}';
}
function printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
refs = refs.slice();
if (refs.indexOf(val) > -1) {
return '[Circular]';
} else {
refs.push(val);
}
currentDepth++;
const hitMaxDepth = currentDepth > maxDepth;
if (!hitMaxDepth && val.toJSON && typeof val.toJSON === 'function') {
return print(val.toJSON(), indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
}
const toStringed = toString.call(val);
if (toStringed === '[object Arguments]') {
return hitMaxDepth ? '[Arguments]' : printArguments(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
} else if (isToStringedArrayType(toStringed)) {
return hitMaxDepth ? '[Array]' : printArray(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
} else if (toStringed === '[object Map]') {
return hitMaxDepth ? '[Map]' : printMap(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
} else if (toStringed === '[object Set]') {
return hitMaxDepth ? '[Set]' : printSet(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
} else if (typeof val === 'object') {
return hitMaxDepth ? '[Object]' : printObject(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
}
}
function printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
let match = false;
let plugin;
for (let p = 0; p < plugins.length; p++) {
plugin = plugins[p];
if (plugin.test(val)) {
match = true;
break;
}
}
if (!match) {
return false;
}
function boundPrint(val) {
return print(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
}
function boundIndent(str) {
const indentation = prevIndent + indent;
return indentation + str.replace(NEWLINE_REGEXP, '\n' + indentation);
}
return plugin.print(val, boundPrint, boundIndent, {
edgeSpacing: edgeSpacing,
spacing: spacing
});
}
function print(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min) {
const basic = printBasicValue(val);
if (basic) return basic;
const plugin = printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
if (plugin) return plugin;
return printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, maxDepth, currentDepth, plugins, min);
}
const DEFAULTS = {
indent: 2,
min: false,
maxDepth: Infinity,
plugins: []
};
function validateOptions(opts) {
Object.keys(opts).forEach(key => {
if (!DEFAULTS.hasOwnProperty(key)) {
throw new Error('prettyFormat: Invalid option: ' + key);
}
});
if (opts.min && opts.indent !== undefined && opts.indent !== 0) {
throw new Error('prettyFormat: Cannot run with min option and indent');
}
}
function normalizeOptions(opts) {
const result = {};
Object.keys(DEFAULTS).forEach(key =>
result[key] = opts.hasOwnProperty(key) ? opts[key] : DEFAULTS[key]
);
if (result.min) {
result.indent = 0;
}
return result;
}
function createIndent(indent) {
return new Array(indent + 1).join(' ');
}
function prettyFormat(val, opts) {
if (!opts) {
opts = DEFAULTS;
} else {
validateOptions(opts)
opts = normalizeOptions(opts);
}
let indent;
let refs;
const prevIndent = '';
const currentDepth = 0;
const spacing = opts.min ? ' ' : '\n';
const edgeSpacing = opts.min ? '' : '\n';
if (opts && opts.plugins.length) {
indent = createIndent(opts.indent);
refs = [];
var pluginsResult = printPlugin(val, indent, prevIndent, spacing, edgeSpacing, refs, opts.maxDepth, currentDepth, opts.plugins, opts.min);
if (pluginsResult) return pluginsResult;
}
var basicResult = printBasicValue(val);
if (basicResult) return basicResult;
if (!indent) indent = createIndent(opts.indent);
if (!refs) refs = [];
return printComplexValue(val, indent, prevIndent, spacing, edgeSpacing, refs, opts.maxDepth, currentDepth, opts.plugins, opts.min);
}
module.exports = prettyFormat;

View File

@@ -0,0 +1,26 @@
{
"name": "pretty-format",
"version": "3.8.0",
"description": "Stringify any JavaScript value.",
"license": "MIT",
"main": "index.js",
"author": "James Kyle <me@thejameskyle.com>",
"keywords": [],
"repository": "https://github.com/thejameskyle/pretty-format.git",
"bugs": "https://github.com/thejameskyle/pretty-format/issues",
"homepage": "https://github.com/thejameskle/pretty-format",
"scripts": {
"test": "jest",
"perf": "node perf/test.js"
},
"jest": {
"testEnvironment": "node",
"verbose": true
},
"devDependencies": {
"chalk": "^1.1.3",
"jest": "^15.1.1",
"left-pad": "^1.1.1",
"react": "15.3.0"
}
}

View File

@@ -0,0 +1,74 @@
'use strict';
const printString = require('../printString');
const reactElement = Symbol.for('react.element');
function traverseChildren(opaqueChildren, cb) {
if (Array.isArray(opaqueChildren)) {
opaqueChildren.forEach(child => traverseChildren(child, cb));
} else if (opaqueChildren != null && opaqueChildren !== false) {
cb(opaqueChildren);
}
}
function printChildren(flatChildren, print, indent, opts) {
return flatChildren.map(node => {
if (typeof node === 'object') {
return printElement(node, print, indent, opts);
} else if (typeof node === 'string') {
return printString(node);
} else {
return print(node);
}
}).join(opts.edgeSpacing);
}
function printProps(props, print, indent, opts) {
return Object.keys(props).sort().map(name => {
if (name === 'children') {
return '';
}
const prop = props[name];
let printed = print(prop);
if (typeof prop !== 'string') {
if (printed.indexOf('\n') !== -1) {
printed = '{' + opts.edgeSpacing + indent(indent(printed) + opts.edgeSpacing + '}');
} else {
printed = '{' + printed + '}';
}
}
return opts.spacing + indent(name + '=') + printed;
}).join('');
}
function printElement(element, print, indent, opts) {
let result = '<' + element.type;
result += printProps(element.props, print, indent, opts);
const opaqueChildren = element.props.children;
if (opaqueChildren) {
let flatChildren = [];
traverseChildren(opaqueChildren, child => {
flatChildren.push(child);
});
const children = printChildren(flatChildren, print, indent, opts);
result += '>' + opts.edgeSpacing + indent(children) + opts.edgeSpacing + '</' + element.type + '>';
} else {
result += ' />';
}
return result;
}
module.exports = {
test(object) {
return object && object.$$typeof === reactElement;
},
print(val, print, indent, opts) {
return printElement(val, print, indent, opts);
}
};

View File

@@ -0,0 +1,58 @@
'use strict';
const printString = require('../printString');
const reactTestInstance = Symbol.for('react.test.json');
function printChildren(children, print, indent, opts) {
return children.map(child => printInstance(child, print, indent, opts)).join(opts.edgeSpacing);
}
function printProps(props, print, indent, opts) {
return Object.keys(props).sort().map(name => {
const prop = props[name];
let printed = print(prop);
if (typeof prop !== 'string') {
if (printed.indexOf('\n') !== -1) {
printed = '{' + opts.edgeSpacing + indent(indent(printed) + opts.edgeSpacing + '}');
} else {
printed = '{' + printed + '}';
}
}
return opts.spacing + indent(name + '=') + printed;
}).join('');
}
function printInstance(instance, print, indent, opts) {
if (typeof instance == 'number') {
return print(instance);
} else if (typeof instance === 'string') {
return printString(instance);
}
let result = '<' + instance.type;
if (instance.props) {
result += printProps(instance.props, print, indent, opts);
}
if (instance.children) {
const children = printChildren(instance.children, print, indent, opts);
result += '>' + opts.edgeSpacing + indent(children) + opts.edgeSpacing + '</' + instance.type + '>';
} else {
result += ' />';
}
return result;
}
module.exports = {
test(object) {
return object && object.$$typeof === reactTestInstance;
},
print(val, print, indent, opts) {
return printInstance(val, print, indent, opts);
}
};

View File

@@ -0,0 +1,7 @@
'use strict';
const ESCAPED_CHARACTERS = /(\\|\"|\')/g;
module.exports = function printString(val) {
return val.replace(ESCAPED_CHARACTERS, '\\$1');
}

149
node_modules/preact-render-to-string/package.json generated vendored Normal file
View File

@@ -0,0 +1,149 @@
{
"name": "preact-render-to-string",
"amdName": "preactRenderToString",
"version": "5.2.6",
"description": "Render JSX to an HTML string, with support for Preact components.",
"main": "dist/index.js",
"umd:main": "dist/index.js",
"module": "dist/index.module.js",
"jsnext:main": "dist/index.module.js",
"types": "src/index.d.ts",
"exports": {
".": {
"types": "./src/index.d.ts",
"import": "./dist/index.mjs",
"browser": "./dist/index.module.js",
"require": "./dist/index.js"
},
"./jsx": {
"types": "./jsx.d.ts",
"import": "./dist/jsx.mjs",
"browser": "./dist/jsx.module.js",
"require": "./dist/jsx.js"
},
"./package.json": "./package.json"
},
"scripts": {
"bench": "BABEL_ENV=test node -r @babel/register benchmarks index.js",
"bench:v8": "BABEL_ENV=test microbundle benchmarks/index.js -f modern --alias benchmarkjs-pretty=benchmarks/lib/benchmark-lite.js --external none --target node --no-compress --no-sourcemap --raw -o benchmarks/.v8.js && v8 --module benchmarks/.v8.modern.js",
"build": "npm run -s transpile && npm run -s transpile:jsx && npm run -s copy-typescript-definition",
"postbuild": "node ./config/node-13-exports.js && node ./config/node-commonjs.js",
"transpile": "microbundle src/index.js -f es,umd --target web --external preact",
"transpile:jsx": "microbundle src/jsx.js -o dist/jsx.js --target web --external preact && microbundle dist/jsx.js -o dist/jsx.js -f cjs --external preact",
"copy-typescript-definition": "copyfiles -f src/*.d.ts dist",
"test": "eslint src test && tsc && npm run test:mocha && npm run test:mocha:compat && npm run test:mocha:debug && npm run bench",
"test:mocha": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/**/[!compat][!debug]*.test.js",
"test:mocha:compat": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/compat.test.js 'test/compat-*.test.js'",
"test:mocha:debug": "BABEL_ENV=test mocha -r @babel/register -r test/setup.js test/debug.test.js 'test/debug-*.test.js'",
"format": "prettier src/**/*.{d.ts,js} test/**/*.js --write",
"prepublishOnly": "npm run build",
"release": "npm run build && git commit -am $npm_package_version && git tag $npm_package_version && git push && git push --tags && npm publish"
},
"keywords": [
"preact",
"render",
"universal",
"isomorphic"
],
"files": [
"src",
"dist",
"jsx.js",
"typings.json"
],
"eslintConfig": {
"extends": "developit",
"rules": {
"react/prefer-stateless-function": 0,
"react/jsx-no-bind": 0,
"react/no-danger": 0,
"jest/valid-expect": 0,
"new-cap": 0,
"curly": "off",
"brace-style": "off",
"indent": "off"
},
"settings": {
"react": {
"version": "16.8"
}
}
},
"babel": {
"env": {
"test": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": true
}
}
]
],
"plugins": [
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "h"
}
]
]
}
}
},
"author": "Jason Miller <jason@developit.ca>",
"license": "MIT",
"repository": "developit/preact-render-to-string",
"bugs": "https://github.com/developit/preact-render-to-string/issues",
"homepage": "https://github.com/developit/preact-render-to-string",
"peerDependencies": {
"preact": ">=10"
},
"devDependencies": {
"@babel/plugin-transform-react-jsx": "^7.12.12",
"@babel/preset-env": "^7.12.11",
"@babel/register": "^7.12.10",
"@changesets/cli": "^2.18.0",
"@changesets/changelog-github": "^0.4.1",
"benchmarkjs-pretty": "^2.0.1",
"chai": "^4.2.0",
"copyfiles": "^2.4.1",
"eslint": "^7.16.0",
"eslint-config-developit": "^1.2.0",
"husky": "^4.3.6",
"lint-staged": "^10.5.3",
"microbundle": "^0.13.0",
"mocha": "^8.2.1",
"preact": "^10.11.1",
"prettier": "^2.2.1",
"sinon": "^9.2.2",
"sinon-chai": "^3.5.0",
"typescript": "^4.1.3"
},
"dependencies": {
"pretty-format": "^3.8.0"
},
"prettier": {
"singleQuote": true,
"trailingComma": "none",
"useTabs": true,
"tabWidth": 2
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx,yml}": [
"prettier --write"
]
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"mangle": {
"compress": {
"reduce_funcs": false
}
}
}

16
node_modules/preact-render-to-string/src/constants.js generated vendored Normal file
View File

@@ -0,0 +1,16 @@
// Options hooks
export const DIFF = '__b';
export const RENDER = '__r';
export const DIFFED = 'diffed';
export const COMMIT = '__c';
export const SKIP_EFFECTS = '__s';
// VNode properties
export const COMPONENT = '__c';
export const CHILDREN = '__k';
export const PARENT = '__';
// Component properties
export const VNODE = '__v';
export const DIRTY = '__d';
export const NEXT_STATE = '__s';

16
node_modules/preact-render-to-string/src/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,16 @@
import { VNode } from 'preact';
interface Options {
shallow?: boolean;
xml?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export function renderToString(
vnode: VNode,
context?: any,
options?: Options
): string;
export function shallowRender(vnode: VNode, context?: any): string;
export default render;

457
node_modules/preact-render-to-string/src/index.js generated vendored Normal file
View File

@@ -0,0 +1,457 @@
import {
encodeEntities,
styleObjToCss,
getContext,
createComponent,
UNSAFE_NAME,
XLINK,
VOID_ELEMENTS
} from './util';
import { options, h, Fragment } from 'preact';
import { _renderToStringPretty } from './pretty';
import {
COMMIT,
COMPONENT,
DIFF,
DIFFED,
DIRTY,
NEXT_STATE,
PARENT,
RENDER,
SKIP_EFFECTS,
VNODE,
CHILDREN
} from './constants';
/** @typedef {import('preact').VNode} VNode */
const SHALLOW = { shallow: true };
/** Render Preact JSX + Components to an HTML string.
* @name render
* @function
* @param {VNode} vnode JSX VNode to render.
* @param {Object} [context={}] Optionally pass an initial context object through the render path.
* @param {Object} [options={}] Rendering options
* @param {Boolean} [options.shallow=false] If `true`, renders nested Components as HTML elements (`<Foo a="b" />`).
* @param {Boolean} [options.xml=false] If `true`, uses self-closing tags for elements without children.
* @param {Boolean} [options.pretty=false] If `true`, adds whitespace for readability
* @param {RegExp|undefined} [options.voidElements] RegeEx that matches elements that are considered void (self-closing)
*/
renderToString.render = renderToString;
/** Only render elements, leaving Components inline as `<ComponentName ... />`.
* This method is just a convenience alias for `render(vnode, context, { shallow:true })`
* @name shallow
* @function
* @param {VNode} vnode JSX VNode to render.
* @param {Object} [context={}] Optionally pass an initial context object through the render path.
*/
let shallowRender = (vnode, context) => renderToString(vnode, context, SHALLOW);
const EMPTY_ARR = [];
function renderToString(vnode, context, opts) {
context = context || {};
// Performance optimization: `renderToString` is synchronous and we
// therefore don't execute any effects. To do that we pass an empty
// array to `options._commit` (`__c`). But we can go one step further
// and avoid a lot of dirty checks and allocations by setting
// `options._skipEffects` (`__s`) too.
const previousSkipEffects = options[SKIP_EFFECTS];
options[SKIP_EFFECTS] = true;
const parent = h(Fragment, null);
parent[CHILDREN] = [vnode];
let res;
if (
opts &&
(opts.pretty ||
opts.voidElements ||
opts.sortAttributes ||
opts.shallow ||
opts.allAttributes ||
opts.xml ||
opts.attributeHook)
) {
res = _renderToStringPretty(vnode, context, opts);
} else {
res = _renderToString(vnode, context, false, undefined, parent);
}
// options._commit, we don't schedule any effects in this library right now,
// so we can pass an empty queue to this hook.
if (options[COMMIT]) options[COMMIT](vnode, EMPTY_ARR);
options[SKIP_EFFECTS] = previousSkipEffects;
EMPTY_ARR.length = 0;
return res;
}
/**
* @param {VNode} vnode
* @param {Record<string, unknown>} context
* @returns {string}
*/
function renderFunctionComponent(vnode, context) {
// eslint-disable-next-line lines-around-comment
/** @type {string} */
let rendered,
c = createComponent(vnode, context),
cctx = getContext(vnode.type, context);
vnode[COMPONENT] = c;
// If a hook invokes setState() to invalidate the component during rendering,
// re-render it up to 25 times to allow "settling" of memoized states.
// Note:
// This will need to be updated for Preact 11 to use internal.flags rather than component._dirty:
// https://github.com/preactjs/preact/blob/d4ca6fdb19bc715e49fd144e69f7296b2f4daa40/src/diff/component.js#L35-L44
let renderHook = options[RENDER];
let count = 0;
while (c[DIRTY] && count++ < 25) {
c[DIRTY] = false;
if (renderHook) renderHook(vnode);
// stateless functional components
rendered = vnode.type.call(c, vnode.props, cctx);
}
return rendered;
}
/**
* @param {VNode} vnode
* @param {Record<string, unknown>} context
* @returns {VNode}
*/
function renderClassComponent(vnode, context) {
let nodeName = vnode.type,
cctx = getContext(nodeName, context);
/** @type {import("preact").Component} */
let c = new nodeName(vnode.props, cctx);
vnode[COMPONENT] = c;
c[VNODE] = vnode;
// turn off stateful re-rendering:
c[DIRTY] = true;
c.props = vnode.props;
if (c.state == null) c.state = {};
if (c[NEXT_STATE] == null) {
c[NEXT_STATE] = c.state;
}
c.context = cctx;
if (nodeName.getDerivedStateFromProps) {
c.state = assign(
{},
c.state,
nodeName.getDerivedStateFromProps(c.props, c.state)
);
} else if (c.componentWillMount) {
c.componentWillMount();
// If the user called setState in cWM we need to flush pending,
// state updates. This is the same behaviour in React.
c.state = c[NEXT_STATE] !== c.state ? c[NEXT_STATE] : c.state;
}
let renderHook = options[RENDER];
if (renderHook) renderHook(vnode);
return c.render(c.props, c.state, c.context);
}
/**
* @param {any} vnode
* @returns {VNode}
*/
function normalizeVNode(vnode) {
if (vnode == null || typeof vnode == 'boolean') {
return null;
} else if (
typeof vnode == 'string' ||
typeof vnode == 'number' ||
typeof vnode == 'bigint'
) {
return h(null, null, vnode);
}
return vnode;
}
/**
* @param {string} name
* @param {boolean} isSvgMode
* @returns {string}
*/
function normalizePropName(name, isSvgMode) {
if (name === 'className') {
return 'class';
} else if (name === 'htmlFor') {
return 'for';
} else if (name === 'defaultValue') {
return 'value';
} else if (name === 'defaultChecked') {
return 'checked';
} else if (name === 'defaultSelected') {
return 'selected';
} else if (isSvgMode && XLINK.test(name)) {
return name.toLowerCase().replace(/^xlink:?/, 'xlink:');
}
return name;
}
/**
* @param {string} name
* @param {string | Record<string, unknown>} v
* @returns {string}
*/
function normalizePropValue(name, v) {
if (name === 'style' && v != null && typeof v === 'object') {
return styleObjToCss(v);
} else if (name[0] === 'a' && name[1] === 'r' && typeof v === 'boolean') {
// always use string values instead of booleans for aria attributes
// also see https://github.com/preactjs/preact/pull/2347/files
return String(v);
}
return v;
}
const isArray = Array.isArray;
const assign = Object.assign;
/**
* The default export is an alias of `render()`.
* @param {any} vnode
* @param {Record<string, unknown>} context
* @param {boolean} isSvgMode
* @param {any} selectValue
* @param {VNode | null} parent
* @returns {string}
*/
function _renderToString(vnode, context, isSvgMode, selectValue, parent) {
// Ignore non-rendered VNodes/values
if (vnode == null || vnode === true || vnode === false || vnode === '') {
return '';
}
// Text VNodes: escape as HTML
if (typeof vnode !== 'object') {
if (typeof vnode === 'function') return '';
return encodeEntities(vnode);
}
// Recurse into children / Arrays
if (isArray(vnode)) {
let rendered = '';
parent[CHILDREN] = vnode;
for (let i = 0; i < vnode.length; i++) {
rendered =
rendered +
_renderToString(vnode[i], context, isSvgMode, selectValue, parent);
vnode[i] = normalizeVNode(vnode[i]);
}
return rendered;
}
// VNodes have {constructor:undefined} to prevent JSON injection:
if (vnode.constructor !== undefined) return '';
vnode[PARENT] = parent;
if (options[DIFF]) options[DIFF](vnode);
let type = vnode.type,
props = vnode.props;
// Invoke rendering on Components
const isComponent = typeof type === 'function';
if (isComponent) {
let rendered;
if (type === Fragment) {
rendered = props.children;
} else {
if (type.prototype && typeof type.prototype.render === 'function') {
rendered = renderClassComponent(vnode, context);
} else {
rendered = renderFunctionComponent(vnode, context);
}
let component = vnode[COMPONENT];
if (component.getChildContext) {
context = assign({}, context, component.getChildContext());
}
}
// When a component returns a Fragment node we flatten it in core, so we
// need to mirror that logic here too
let isTopLevelFragment =
rendered != null && rendered.type === Fragment && rendered.key == null;
rendered = isTopLevelFragment ? rendered.props.children : rendered;
// Recurse into children before invoking the after-diff hook
const str = _renderToString(
rendered,
context,
isSvgMode,
selectValue,
vnode
);
if (options[DIFFED]) options[DIFFED](vnode);
vnode[PARENT] = undefined;
if (options.unmount) options.unmount(vnode);
return str;
}
// Serialize Element VNodes to HTML
let s = '<',
children,
html;
s = s + type;
if (props) {
children = props.children;
for (let name in props) {
let v = props[name];
if (
name === 'key' ||
name === 'ref' ||
name === '__self' ||
name === '__source' ||
name === 'children' ||
(name === 'className' && 'class' in props) ||
(name === 'htmlFor' && 'for' in props)
) {
continue;
}
if (UNSAFE_NAME.test(name)) continue;
name = normalizePropName(name, isSvgMode);
v = normalizePropValue(name, v);
if (name === 'dangerouslySetInnerHTML') {
html = v && v.__html;
} else if (type === 'textarea' && name === 'value') {
// <textarea value="a&b"> --> <textarea>a&amp;b</textarea>
children = v;
} else if ((v || v === 0 || v === '') && typeof v !== 'function') {
if (v === true || v === '') {
v = name;
s = s + ' ' + name;
continue;
}
if (name === 'value') {
if (type === 'select') {
selectValue = v;
continue;
} else if (
// If we're looking at an <option> and it's the currently selected one
type === 'option' &&
selectValue == v &&
// and the <option> doesn't already have a selected attribute on it
!('selected' in props)
) {
s = s + ' selected';
}
}
s = s + ' ' + name + '="' + encodeEntities(v) + '"';
}
}
}
let startElement = s;
s = s + '>';
if (UNSAFE_NAME.test(type)) {
throw new Error(`${type} is not a valid HTML tag name in ${s}`);
}
let pieces = '';
let hasChildren = false;
if (html) {
pieces = pieces + html;
hasChildren = true;
} else if (typeof children === 'string') {
pieces = pieces + encodeEntities(children);
hasChildren = true;
} else if (isArray(children)) {
vnode[CHILDREN] = children;
for (let i = 0; i < children.length; i++) {
let child = children[i];
children[i] = normalizeVNode(child);
if (child != null && child !== false) {
let childSvgMode =
type === 'svg' || (type !== 'foreignObject' && isSvgMode);
let ret = _renderToString(
child,
context,
childSvgMode,
selectValue,
vnode
);
// Skip if we received an empty string
if (ret) {
pieces = pieces + ret;
hasChildren = true;
}
}
}
} else if (children != null && children !== false && children !== true) {
vnode[CHILDREN] = [normalizeVNode(children)];
let childSvgMode =
type === 'svg' || (type !== 'foreignObject' && isSvgMode);
let ret = _renderToString(
children,
context,
childSvgMode,
selectValue,
vnode
);
// Skip if we received an empty string
if (ret) {
pieces = pieces + ret;
hasChildren = true;
}
}
if (options[DIFFED]) options[DIFFED](vnode);
vnode[PARENT] = undefined;
if (options.unmount) options.unmount(vnode);
if (hasChildren) {
s = s + pieces;
} else if (VOID_ELEMENTS.test(type)) {
return startElement + ' />';
}
return s + '</' + type + '>';
}
/** The default export is an alias of `render()`. */
renderToString.shallowRender = shallowRender;
export default renderToString;
export {
renderToString as render,
renderToString as renderToStaticMarkup,
renderToString,
shallowRender
};

13
node_modules/preact-render-to-string/src/jsx.d.ts generated vendored Normal file
View File

@@ -0,0 +1,13 @@
import { VNode } from 'preact';
interface Options {
jsx?: boolean;
xml?: boolean;
functions?: boolean;
functionNames?: boolean;
skipFalseAttributes?: boolean;
pretty?: boolean | string;
}
export function render(vnode: VNode, context?: any, options?: Options): string;
export default render;

76
node_modules/preact-render-to-string/src/jsx.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
import './polyfills';
import renderToString from './index';
import { indent, encodeEntities } from './util';
import prettyFormat from 'pretty-format';
// we have to patch in Array support, Possible issue in npm.im/pretty-format
let preactPlugin = {
test(object) {
return (
object &&
typeof object === 'object' &&
'type' in object &&
'props' in object &&
'key' in object
);
},
print(val, print, indent) {
return renderToString(val, preactPlugin.context, preactPlugin.opts, true);
}
};
let prettyFormatOpts = {
plugins: [preactPlugin]
};
function attributeHook(name, value, context, opts, isComponent) {
let type = typeof value;
// Use render-to-string's built-in handling for these properties
if (name === 'dangerouslySetInnerHTML') return false;
// always skip null & undefined values, skip false DOM attributes, skip functions if told to
if (value == null || (type === 'function' && !opts.functions)) return '';
if (
opts.skipFalseAttributes &&
!isComponent &&
(value === false ||
((name === 'class' || name === 'style') && value === ''))
)
return '';
let indentChar = typeof opts.pretty === 'string' ? opts.pretty : '\t';
if (type !== 'string') {
if (type === 'function' && !opts.functionNames) {
value = 'Function';
} else {
preactPlugin.context = context;
preactPlugin.opts = opts;
value = prettyFormat(value, prettyFormatOpts);
if (~value.indexOf('\n')) {
value = `${indent('\n' + value, indentChar)}\n`;
}
}
return indent(`\n${name}={${value}}`, indentChar);
}
return `\n${indentChar}${name}="${encodeEntities(value)}"`;
}
let defaultOpts = {
attributeHook,
jsx: true,
xml: false,
functions: true,
functionNames: true,
skipFalseAttributes: true,
pretty: ' '
};
function renderToJsxString(vnode, context, opts, inner) {
opts = Object.assign({}, defaultOpts, opts || {});
return renderToString(vnode, context, opts, inner);
}
export default renderToJsxString;
export { renderToJsxString as render };

View File

@@ -0,0 +1,8 @@
if (typeof Symbol !== 'function') {
let c = 0;
// eslint-disable-next-line
Symbol = function (s) {
return `@@${s}${++c}`;
};
Symbol.for = (s) => `@@${s}`;
}

View File

@@ -0,0 +1 @@
export {};

389
node_modules/preact-render-to-string/src/pretty.js generated vendored Normal file
View File

@@ -0,0 +1,389 @@
import {
encodeEntities,
indent,
isLargeString,
styleObjToCss,
getChildren,
createComponent,
getContext,
UNSAFE_NAME,
XLINK,
VOID_ELEMENTS
} from './util';
import { options, Fragment } from 'preact';
// components without names, kept as a hash for later comparison to return consistent UnnamedComponentXX names.
const UNNAMED = [];
export function _renderToStringPretty(
vnode,
context,
opts,
inner,
isSvgMode,
selectValue
) {
if (vnode == null || typeof vnode === 'boolean') {
return '';
}
// #text nodes
if (typeof vnode !== 'object') {
if (typeof vnode === 'function') return '';
return encodeEntities(vnode);
}
let pretty = opts.pretty,
indentChar = pretty && typeof pretty === 'string' ? pretty : '\t';
if (Array.isArray(vnode)) {
let rendered = '';
for (let i = 0; i < vnode.length; i++) {
if (pretty && i > 0) rendered = rendered + '\n';
rendered =
rendered +
_renderToStringPretty(
vnode[i],
context,
opts,
inner,
isSvgMode,
selectValue
);
}
return rendered;
}
// VNodes have {constructor:undefined} to prevent JSON injection:
if (vnode.constructor !== undefined) return '';
let nodeName = vnode.type,
props = vnode.props,
isComponent = false;
// components
if (typeof nodeName === 'function') {
isComponent = true;
if (opts.shallow && (inner || opts.renderRootComponent === false)) {
nodeName = getComponentName(nodeName);
} else if (nodeName === Fragment) {
const children = [];
getChildren(children, vnode.props.children);
return _renderToStringPretty(
children,
context,
opts,
opts.shallowHighOrder !== false,
isSvgMode,
selectValue
);
} else {
let rendered;
let c = (vnode.__c = createComponent(vnode, context));
// options._diff
if (options.__b) options.__b(vnode);
// options._render
let renderHook = options.__r;
if (
!nodeName.prototype ||
typeof nodeName.prototype.render !== 'function'
) {
let cctx = getContext(nodeName, context);
// If a hook invokes setState() to invalidate the component during rendering,
// re-render it up to 25 times to allow "settling" of memoized states.
// Note:
// This will need to be updated for Preact 11 to use internal.flags rather than component._dirty:
// https://github.com/preactjs/preact/blob/d4ca6fdb19bc715e49fd144e69f7296b2f4daa40/src/diff/component.js#L35-L44
let count = 0;
while (c.__d && count++ < 25) {
c.__d = false;
if (renderHook) renderHook(vnode);
// stateless functional components
rendered = nodeName.call(vnode.__c, props, cctx);
}
} else {
let cctx = getContext(nodeName, context);
// c = new nodeName(props, context);
c = vnode.__c = new nodeName(props, cctx);
c.__v = vnode;
// turn off stateful re-rendering:
c._dirty = c.__d = true;
c.props = props;
if (c.state == null) c.state = {};
if (c._nextState == null && c.__s == null) {
c._nextState = c.__s = c.state;
}
c.context = cctx;
if (nodeName.getDerivedStateFromProps)
c.state = Object.assign(
{},
c.state,
nodeName.getDerivedStateFromProps(c.props, c.state)
);
else if (c.componentWillMount) {
c.componentWillMount();
// If the user called setState in cWM we need to flush pending,
// state updates. This is the same behaviour in React.
c.state =
c._nextState !== c.state
? c._nextState
: c.__s !== c.state
? c.__s
: c.state;
}
if (renderHook) renderHook(vnode);
rendered = c.render(c.props, c.state, c.context);
}
if (c.getChildContext) {
context = Object.assign({}, context, c.getChildContext());
}
if (options.diffed) options.diffed(vnode);
return _renderToStringPretty(
rendered,
context,
opts,
opts.shallowHighOrder !== false,
isSvgMode,
selectValue
);
}
}
// render JSX to HTML
let s = '<' + nodeName,
propChildren,
html;
if (props) {
let attrs = Object.keys(props);
// allow sorting lexicographically for more determinism (useful for tests, such as via preact-jsx-chai)
if (opts && opts.sortAttributes === true) attrs.sort();
for (let i = 0; i < attrs.length; i++) {
let name = attrs[i],
v = props[name];
if (name === 'children') {
propChildren = v;
continue;
}
if (UNSAFE_NAME.test(name)) continue;
if (
!(opts && opts.allAttributes) &&
(name === 'key' ||
name === 'ref' ||
name === '__self' ||
name === '__source')
)
continue;
if (name === 'defaultValue') {
name = 'value';
} else if (name === 'defaultChecked') {
name = 'checked';
} else if (name === 'defaultSelected') {
name = 'selected';
} else if (name === 'className') {
if (typeof props.class !== 'undefined') continue;
name = 'class';
} else if (isSvgMode && XLINK.test(name)) {
name = name.toLowerCase().replace(/^xlink:?/, 'xlink:');
}
if (name === 'htmlFor') {
if (props.for) continue;
name = 'for';
}
if (name === 'style' && v && typeof v === 'object') {
v = styleObjToCss(v);
}
// always use string values instead of booleans for aria attributes
// also see https://github.com/preactjs/preact/pull/2347/files
if (name[0] === 'a' && name['1'] === 'r' && typeof v === 'boolean') {
v = String(v);
}
let hooked =
opts.attributeHook &&
opts.attributeHook(name, v, context, opts, isComponent);
if (hooked || hooked === '') {
s = s + hooked;
continue;
}
if (name === 'dangerouslySetInnerHTML') {
html = v && v.__html;
} else if (nodeName === 'textarea' && name === 'value') {
// <textarea value="a&b"> --> <textarea>a&amp;b</textarea>
propChildren = v;
} else if ((v || v === 0 || v === '') && typeof v !== 'function') {
if (v === true || v === '') {
v = name;
// in non-xml mode, allow boolean attributes
if (!opts || !opts.xml) {
s = s + ' ' + name;
continue;
}
}
if (name === 'value') {
if (nodeName === 'select') {
selectValue = v;
continue;
} else if (
// If we're looking at an <option> and it's the currently selected one
nodeName === 'option' &&
selectValue == v &&
// and the <option> doesn't already have a selected attribute on it
typeof props.selected === 'undefined'
) {
s = s + ` selected`;
}
}
s = s + ` ${name}="${encodeEntities(v)}"`;
}
}
}
// account for >1 multiline attribute
if (pretty) {
let sub = s.replace(/\n\s*/, ' ');
if (sub !== s && !~sub.indexOf('\n')) s = sub;
else if (pretty && ~s.indexOf('\n')) s = s + '\n';
}
s = s + '>';
if (UNSAFE_NAME.test(nodeName))
throw new Error(`${nodeName} is not a valid HTML tag name in ${s}`);
let isVoid =
VOID_ELEMENTS.test(nodeName) ||
(opts.voidElements && opts.voidElements.test(nodeName));
let pieces = [];
let children;
if (html) {
// if multiline, indent.
if (pretty && isLargeString(html)) {
html = '\n' + indentChar + indent(html, indentChar);
}
s = s + html;
} else if (
propChildren != null &&
getChildren((children = []), propChildren).length
) {
let hasLarge = pretty && ~s.indexOf('\n');
let lastWasText = false;
for (let i = 0; i < children.length; i++) {
let child = children[i];
if (child != null && child !== false) {
let childSvgMode =
nodeName === 'svg'
? true
: nodeName === 'foreignObject'
? false
: isSvgMode,
ret = _renderToStringPretty(
child,
context,
opts,
true,
childSvgMode,
selectValue
);
if (pretty && !hasLarge && isLargeString(ret)) hasLarge = true;
// Skip if we received an empty string
if (ret) {
if (pretty) {
let isText = ret.length > 0 && ret[0] != '<';
// We merge adjacent text nodes, otherwise each piece would be printed
// on a new line.
if (lastWasText && isText) {
pieces[pieces.length - 1] += ret;
} else {
pieces.push(ret);
}
lastWasText = isText;
} else {
pieces.push(ret);
}
}
}
}
if (pretty && hasLarge) {
for (let i = pieces.length; i--; ) {
pieces[i] = '\n' + indentChar + indent(pieces[i], indentChar);
}
}
}
if (pieces.length || html) {
s = s + pieces.join('');
} else if (opts && opts.xml) {
return s.substring(0, s.length - 1) + ' />';
}
if (isVoid && !children && !html) {
s = s.replace(/>$/, ' />');
} else {
if (pretty && ~s.indexOf('\n')) s = s + '\n';
s = s + `</${nodeName}>`;
}
return s;
}
function getComponentName(component) {
return (
component.displayName ||
(component !== Function && component.name) ||
getFallbackComponentName(component)
);
}
function getFallbackComponentName(component) {
let str = Function.prototype.toString.call(component),
name = (str.match(/^\s*function\s+([^( ]+)/) || '')[1];
if (!name) {
// search for an existing indexed name for the given component:
let index = -1;
for (let i = UNNAMED.length; i--; ) {
if (UNNAMED[i] === component) {
index = i;
break;
}
}
// not found, create a new indexed name:
if (index < 0) {
index = UNNAMED.push(component) - 1;
}
name = `UnnamedComponent${index}`;
}
return name;
}

125
node_modules/preact-render-to-string/src/util.js generated vendored Normal file
View File

@@ -0,0 +1,125 @@
// DOM properties that should NOT have "px" added when numeric
export const IS_NON_DIMENSIONAL = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|^--/i;
export const VOID_ELEMENTS = /^(area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/;
export const UNSAFE_NAME = /[\s\n\\/='"\0<>]/;
export const XLINK = /^xlink:?./;
const ENCODED_ENTITIES = /["&<]/;
export function encodeEntities(str) {
// Ensure we're always parsing and returning a string:
str += '';
// Skip all work for strings with no entities needing encoding:
if (ENCODED_ENTITIES.test(str) === false) return str;
let last = 0,
i = 0,
out = '',
ch = '';
// Seek forward in str until the next entity char:
for (; i < str.length; i++) {
switch (str.charCodeAt(i)) {
case 34:
ch = '&quot;';
break;
case 38:
ch = '&amp;';
break;
case 60:
ch = '&lt;';
break;
default:
continue;
}
// Append skipped/buffered characters and the encoded entity:
if (i !== last) out += str.slice(last, i);
out += ch;
// Start the next seek/buffer after the entity's offset:
last = i + 1;
}
if (i !== last) out += str.slice(last, i);
return out;
}
export let indent = (s, char) =>
String(s).replace(/(\n+)/g, '$1' + (char || '\t'));
export let isLargeString = (s, length, ignoreLines) =>
String(s).length > (length || 40) ||
(!ignoreLines && String(s).indexOf('\n') !== -1) ||
String(s).indexOf('<') !== -1;
const JS_TO_CSS = {};
const CSS_REGEX = /([A-Z])/g;
// Convert an Object style to a CSSText string
export function styleObjToCss(s) {
let str = '';
for (let prop in s) {
let val = s[prop];
if (val != null && val !== '') {
if (str) str += ' ';
// str += jsToCss(prop);
str +=
prop[0] == '-'
? prop
: JS_TO_CSS[prop] ||
(JS_TO_CSS[prop] = prop.replace(CSS_REGEX, '-$1').toLowerCase());
if (typeof val === 'number' && IS_NON_DIMENSIONAL.test(prop) === false) {
str = str + ': ' + val + 'px;';
} else {
str = str + ': ' + val + ';';
}
}
}
return str || undefined;
}
/**
* Get flattened children from the children prop
* @param {Array} accumulator
* @param {any} children A `props.children` opaque object.
* @returns {Array} accumulator
* @private
*/
export function getChildren(accumulator, children) {
if (Array.isArray(children)) {
children.reduce(getChildren, accumulator);
} else if (children != null && children !== false) {
accumulator.push(children);
}
return accumulator;
}
function markAsDirty() {
this.__d = true;
}
export function createComponent(vnode, context) {
return {
__v: vnode,
context,
props: vnode.props,
// silently drop state updates
setState: markAsDirty,
forceUpdate: markAsDirty,
__d: true,
// hooks
__h: []
};
}
// Necessary for createContext api. Setting this property will pass
// the context value as `this.context` just for this component.
export function getContext(nodeName, context) {
let cxType = nodeName.contextType;
let provider = cxType && context[cxType.__c];
return cxType != null
? provider
? provider.props.value
: cxType.__
: context;
}

5
node_modules/preact-render-to-string/typings.json generated vendored Normal file
View File

@@ -0,0 +1,5 @@
{
"name": "preact-render-to-string",
"main": "src/index.d.ts",
"version": false
}