FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

21
node_modules/solid-refresh/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2020-2021 Ryan Carniato
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.

190
node_modules/solid-refresh/README.md generated vendored Normal file
View File

@@ -0,0 +1,190 @@
<p>
<img width="100%" src="https://assets.solidjs.com/banner?project=Refresh&type=core" alt="Solid Refresh">
</p>
# Solid Refresh
```bash
npm i -D solid-refresh
```
```bash
yarn add -D solid-refresh
```
```bash
pnpm add -D solid-refresh
```
This project aims to provide HMR for Solid for various bundlers. It comes with a babel plugin and a runtime. Over time I hope to add different bundlers. Today it supports:
* Vite (with option `bundler: "vite"`)
* Snowpack (with option `bundler: "esm"`)
* Webpack (for strict ESM, use option `bundler: "webpack5"`)
* Nollup
## Setup
### Vite
`solid-refresh` is already built into [`vite-plugin-solid`](https://github.com/solidjs/vite-plugin-solid).
### Webpack & Rspack
You can read the following guides first, respectively:
* [Webpack](https://webpack.js.org/guides/hot-module-replacement#enabling-hmr)
* [Rspack](https://www.rspack.dev/guide/dev-server.html#hmr)
* [Rspack SolidJS guide](https://www.rspack.dev/guide/solid.html)
> **Note**
> Rspack has HMR already enabled by default. The guide only tells you how to disable it or run the dev server on a proxy server.
Requires the use of [`babel-loader`](https://www.npmjs.com/package/babel-loader). Add the following to `.babelrc`:
```json
{
"env": {
"development": {
"plugins": ["solid-refresh/babel"]
}
}
}
```
If you're using strict ESM a.k.a. `import.meta.webpackHot`:
```json
{
"env": {
"development": {
"plugins": [["solid-refresh/babel", {
"bundler": "webpack5" // or "rspack-esm"
}]]
}
}
}
```
In your webpack config, be sure to have the following options:
```js
devServer: {
liveReload: false,
hot: true,
}
```
### Nollup
Requires the use of [`@rollup/plugin-babel`](https://www.npmjs.com/package/@rollup/plugin-babel). Add the following to `.babelrc`:
```json
{
"env": {
"development": {
"plugins": ["solid-refresh/babel"]
}
}
}
```
### Snowpack
Requires the use of [`@snowpack/plugin-babel`](https://www.npmjs.com/package/@snowpack/plugin-babel). Add the following to `.babelrc`:
```json
{
"env": {
"development": {
"plugins": ["solid-refresh/babel", { "bundler": "esm" }]
}
}
}
```
### Other dev servers
* [`Parcel`](https://parceljs.org/)
* ParcelJS doesn't support [conditional exports](https://nodejs.org/api/packages.html#conditional-exports) yet, which makes ParcelJS load the production build of SolidJS instead of its development build. Solid Refresh requires the SolidJS development build to work.
* [`wmr`](https://wmr.dev/)
* SolidJS is yet to be supported or isn't clear yet. It will use the same config as Snowpack.
* [`rollup-plugin-hot`](https://github.com/rixo/rollup-plugin-hot)
* The library uses almost an ESM HMR-like API however it behaves the same way as Parcel. Supporting this library is still unclear.
* [`@web/dev-server`](https://modern-web.dev/docs/dev-server)
* The library supports HMR through their [HMR Plugin](https://modern-web.dev/docs/dev-server/plugins/hmr). The HMR interface is basically the same as Snowpack's.
### Development Environment
In any case, your build system needs to support conditional exports and have the `development` condition set.
> **Warning**
> In some standard HMR implementations, this may cause your app to reload the full page if the development environment isn't properly set!
## How it works
The babel plugin will transform components with matching Pascal-cased names (indicating that they are components). This detection is supported in variable declarations, function declarations and named exports:
```jsx
// This works
function Foo() {
return <h1>Hello Foo</h1>;
}
// This also works
const Bar = () => <h1>Hello Bar</h1>;
```
The components are wrapped and memoized. When the module receives an update, it replaces the old components from the old module with the new components.
## Automatic Render Cleanup
The plugin automatically handles cleanups for unhandled `render` and `hydrate` calls from `solid-js/web`.
You can disable this feature entirely through the option `"fixRender": false`.
## Pragma
On a per file basis, use comments at top of file to opt out(change moves up to parent):
```js
/* @refresh skip */
```
Or force reload:
```js
/* @refresh reload */
```
### `@refresh granular`
By default, components from the old module are replaced with the new ones from the replacement module, which might cause components that hasn't really changed to unmount abruptly.
Adding `@refresh granular` comment pragma in the file allows components to opt-in to granular replacement: If the component has changed *code-wise*, it will be replaced, otherwise, it will be retained, which allows unchanged ancestor components to preserve lifecycles.
## Limitations
* Preserving state: The default mode does not allow preserving state through module replacement. `@refresh granular` allows this partially.
* No HOC support.
## Custom `render`/`createContext`
You can define custom `render`/`createContext` calls by using the `imports` option
```js
{
"imports": [
{
// Only either "render" or "createContext"
"type": "render",
// Import identifier
"name": "render",
// Kind of import (named or default)
"kind": "named",
// Module source
"source": "my-solid-library"
}
],
}
```

744
node_modules/solid-refresh/dist/babel.cjs generated vendored Normal file
View File

@@ -0,0 +1,744 @@
'use strict';
var path = require('path');
var t = require('@babel/types');
var _generator = require('@babel/generator');
var helperModuleImports = require('@babel/helper-module-imports');
function _interopNamespaceDefault(e) {
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n.default = e;
return Object.freeze(n);
}
var t__namespace = /*#__PURE__*/_interopNamespaceDefault(t);
/**
* Copyright (c) 2019 Jason Dent
* https://github.com/Jason3S/xxhash
*/
const PRIME32_1 = 2654435761;
const PRIME32_2 = 2246822519;
const PRIME32_3 = 3266489917;
const PRIME32_4 = 668265263;
const PRIME32_5 = 374761393;
function toUtf8(text) {
const bytes = [];
for (let i = 0, n = text.length; i < n; ++i) {
const c = text.charCodeAt(i);
if (c < 0x80) {
bytes.push(c);
}
else if (c < 0x800) {
bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
}
else if (c < 0xd800 || c >= 0xe000) {
bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
}
else {
const cp = 0x10000 + (((c & 0x3ff) << 10) | (text.charCodeAt(++i) & 0x3ff));
bytes.push(0xf0 | ((cp >> 18) & 0x7), 0x80 | ((cp >> 12) & 0x3f), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
}
}
return new Uint8Array(bytes);
}
/**
*
* @param buffer - byte array or string
* @param seed - optional seed (32-bit unsigned);
*/
function xxHash32(buffer, seed = 0) {
buffer = typeof buffer === 'string' ? toUtf8(buffer) : buffer;
const b = buffer;
/*
Step 1. Initialize internal accumulators
Each accumulator gets an initial value based on optional seed input. Since the seed is optional, it can be 0.
```
u32 acc1 = seed + PRIME32_1 + PRIME32_2;
u32 acc2 = seed + PRIME32_2;
u32 acc3 = seed + 0;
u32 acc4 = seed - PRIME32_1;
```
Special case : input is less than 16 bytes
When input is too small (< 16 bytes), the algorithm will not process any stripe. Consequently, it will not
make use of parallel accumulators.
In which case, a simplified initialization is performed, using a single accumulator :
u32 acc = seed + PRIME32_5;
The algorithm then proceeds directly to step 4.
*/
let acc = (seed + PRIME32_5) & 0xffffffff;
let offset = 0;
if (b.length >= 16) {
const accN = [
(seed + PRIME32_1 + PRIME32_2) & 0xffffffff,
(seed + PRIME32_2) & 0xffffffff,
(seed + 0) & 0xffffffff,
(seed - PRIME32_1) & 0xffffffff,
];
/*
Step 2. Process stripes
A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes, of 4 bytes each.
The first lane is used to update accumulator 1, the second lane is used to update accumulator 2, and so on.
Each lane read its associated 32-bit value using little-endian convention.
For each {lane, accumulator}, the update process is called a round, and applies the following formula :
```
accN = accN + (laneN * PRIME32_2);
accN = accN <<< 13;
accN = accN * PRIME32_1;
```
This shuffles the bits so that any bit from input lane impacts several bits in output accumulator.
All operations are performed modulo 2^32.
Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume
the whole input, except the last remaining bytes which cannot form a stripe (< 16 bytes). When that
happens, move to step 3.
*/
const b = buffer;
const limit = b.length - 16;
let lane = 0;
for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {
const i = offset;
const laneN0 = b[i + 0] + (b[i + 1] << 8);
const laneN1 = b[i + 2] + (b[i + 3] << 8);
const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16);
let acc = (accN[lane] + laneNP) & 0xffffffff;
acc = (acc << 13) | (acc >>> 19);
const acc0 = acc & 0xffff;
const acc1 = acc >>> 16;
accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff;
lane = (lane + 1) & 0x3;
}
/*
Step 3. Accumulator convergence
All 4 lane accumulators from previous steps are merged to produce a single remaining accumulator
of same width (32-bit). The associated formula is as follows :
```
acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);
```
*/
acc =
(((accN[0] << 1) | (accN[0] >>> 31)) +
((accN[1] << 7) | (accN[1] >>> 25)) +
((accN[2] << 12) | (accN[2] >>> 20)) +
((accN[3] << 18) | (accN[3] >>> 14))) &
0xffffffff;
}
/*
Step 4. Add input length
The input total length is presumed known at this stage. This step is just about adding the length to
accumulator, so that it participates to final mixing.
```
acc = acc + (u32)inputLength;
```
*/
acc = (acc + buffer.length) & 0xffffffff;
/*
Step 5. Consume remaining input
There may be up to 15 bytes remaining to consume from the input. The final stage will digest them according
to following pseudo-code :
```
while (remainingLength >= 4) {
lane = read_32bit_little_endian(input_ptr);
acc = acc + lane * PRIME32_3;
acc = (acc <<< 17) * PRIME32_4;
input_ptr += 4; remainingLength -= 4;
}
```
This process ensures that all input bytes are present in the final mix.
*/
const limit = buffer.length - 4;
for (; offset <= limit; offset += 4) {
const i = offset;
const laneN0 = b[i + 0] + (b[i + 1] << 8);
const laneN1 = b[i + 2] + (b[i + 3] << 8);
const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16);
acc = (acc + laneP) & 0xffffffff;
acc = (acc << 17) | (acc >>> 15);
acc =
((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) &
0xffffffff;
}
/*
```
while (remainingLength >= 1) {
lane = read_byte(input_ptr);
acc = acc + lane * PRIME32_5;
acc = (acc <<< 11) * PRIME32_1;
input_ptr += 1; remainingLength -= 1;
}
```
*/
for (; offset < b.length; ++offset) {
const lane = b[offset];
acc = acc + lane * PRIME32_5;
acc = (acc << 11) | (acc >>> 21);
acc =
((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) &
0xffffffff;
}
/*
Step 6. Final mix (avalanche)
The final mix ensures that all input bits have a chance to impact any bit in the output digest,
resulting in an unbiased distribution. This is also called avalanche effect.
```
acc = acc xor (acc >> 15);
acc = acc * PRIME32_2;
acc = acc xor (acc >> 13);
acc = acc * PRIME32_3;
acc = acc xor (acc >> 16);
```
*/
acc = acc ^ (acc >>> 15);
acc =
(((acc & 0xffff) * PRIME32_2) & 0xffffffff) +
(((acc >>> 16) * PRIME32_2) << 16);
acc = acc ^ (acc >>> 13);
acc =
(((acc & 0xffff) * PRIME32_3) & 0xffffffff) +
(((acc >>> 16) * PRIME32_3) << 16);
acc = acc ^ (acc >>> 16);
// turn any negatives back into a positive number;
return acc < 0 ? acc + 4294967296 : acc;
}
// https://github.com/babel/babel/issues/15269
let generator;
if (typeof _generator !== 'function') {
generator = _generator.default;
}
else {
generator = _generator;
}
const CWD = process.cwd();
function getFile(filename) {
return path.relative(CWD, filename);
}
// This is just a Pascal heuristic
// we only assume a function is a component
// if the first character is in uppercase
function isComponentishName(name) {
return name[0] >= 'A' && name[0] <= 'Z';
}
function isESMHMR(bundler) {
// The currently known ESM HMR implementations
// esm - the original ESM HMR Spec
// vite - Vite's implementation
return bundler === 'esm' || bundler === 'vite';
}
// Source of solid-refresh (for import)
const SOLID_REFRESH_MODULE = 'solid-refresh';
// Exported names from solid-refresh that will be imported
const IMPORTS = {
registry: '$$registry',
refresh: '$$refresh',
component: '$$component',
context: '$$context',
decline: '$$decline',
};
function getSolidRefreshIdentifier(state, path, name) {
const target = `${name}`;
const current = state.hooks.get(target);
if (current) {
return current;
}
const newID = helperModuleImports.addNamed(path, name, SOLID_REFRESH_MODULE);
state.hooks.set(target, newID);
return newID;
}
function getHotIdentifier(state) {
const bundler = state.opts.bundler;
// vite/esm uses `import.meta.hot`
if (isESMHMR(bundler)) {
return t__namespace.memberExpression(t__namespace.memberExpression(t__namespace.identifier('import'), t__namespace.identifier('meta')), t__namespace.identifier('hot'));
}
// webpack 5 uses `import.meta.webpackHot`
// rspack does as well
if (bundler === 'webpack5' || bundler === 'rspack-esm') {
return t__namespace.memberExpression(t__namespace.memberExpression(t__namespace.identifier('import'), t__namespace.identifier('meta')), t__namespace.identifier('webpackHot'));
}
// `module.hot` is the default.
return t__namespace.memberExpression(t__namespace.identifier('module'), t__namespace.identifier('hot'));
}
function generateViteRequirement(state, statements, pathToHot) {
if (state.opts.bundler === 'vite') {
// Vite requires that the owner module has an `import.meta.hot.accept()` call
statements.push(t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.memberExpression(pathToHot, t__namespace.identifier('accept')), [])));
}
}
function getHMRDeclineCall(state, path) {
var _a;
const pathToHot = getHotIdentifier(state);
const statements = [
t__namespace.expressionStatement(t__namespace.callExpression(getSolidRefreshIdentifier(state, path, IMPORTS.decline), [t__namespace.stringLiteral((_a = state.opts.bundler) !== null && _a !== void 0 ? _a : 'standard'), pathToHot])),
];
generateViteRequirement(state, statements, pathToHot);
return t__namespace.ifStatement(pathToHot, t__namespace.blockStatement(statements));
}
function getStatementPath(path) {
if (t__namespace.isStatement(path.node)) {
return path;
}
if (path.parentPath) {
return getStatementPath(path.parentPath);
}
return null;
}
const REGISTRY = 'REGISTRY';
function createRegistry(state, path) {
var _a;
const current = state.hooks.get(REGISTRY);
if (current) {
return current;
}
const program = path.scope.getProgramParent();
const identifier = program.generateUidIdentifier(REGISTRY);
program.push({
id: identifier,
kind: 'const',
init: t__namespace.callExpression(getSolidRefreshIdentifier(state, path, IMPORTS.registry), []),
});
const pathToHot = getHotIdentifier(state);
const statements = [
t__namespace.expressionStatement(t__namespace.callExpression(getSolidRefreshIdentifier(state, path, IMPORTS.refresh), [
t__namespace.stringLiteral((_a = state.opts.bundler) !== null && _a !== void 0 ? _a : 'standard'),
pathToHot,
identifier,
])),
];
generateViteRequirement(state, statements, pathToHot);
program.path.pushContainer('body', [
t__namespace.ifStatement(pathToHot, t__namespace.blockStatement(statements)),
]);
state.hooks.set(REGISTRY, identifier);
return identifier;
}
function createSignatureValue(node) {
const code = generator(node);
const result = xxHash32(code.code).toString(16);
return result;
}
function isForeignBinding(source, current, name) {
if (source === current) {
return true;
}
if (current.scope.hasOwnBinding(name)) {
return false;
}
if (current.parentPath) {
return isForeignBinding(source, current.parentPath, name);
}
return true;
}
function isInTypescript(path) {
let parent = path.parentPath;
while (parent) {
if (t__namespace.isTypeScript(parent.node) && !t__namespace.isExpression(parent.node)) {
return true;
}
parent = parent.parentPath;
}
return false;
}
function getBindings(path) {
const identifiers = new Set();
path.traverse({
ReferencedIdentifier(p) {
// Check identifiers that aren't in a TS expression
if (!isInTypescript(p) && isForeignBinding(path, p, p.node.name)) {
identifiers.add(p.node.name);
}
},
});
const collected = [];
for (const identifier of identifiers) {
collected.push(t__namespace.identifier(identifier));
}
return collected;
}
const IMPORT_IDENTITIES = [
{
type: 'createContext',
name: 'createContext',
kind: 'named',
source: 'solid-js',
},
{
type: 'createContext',
name: 'createContext',
kind: 'named',
source: 'solid-js/web',
},
{ type: 'render', name: 'render', kind: 'named', source: 'solid-js/web' },
{ type: 'render', name: 'hydrate', kind: 'named', source: 'solid-js/web' },
];
function getImportSpecifierName(specifier) {
switch (specifier.imported.type) {
case 'Identifier':
return specifier.imported.name;
case 'StringLiteral':
return specifier.imported.value;
}
}
function registerImportSpecifier(state, id, specifier) {
switch (specifier.type) {
case 'ImportDefaultSpecifier': {
if (id.kind === 'default') {
state.registrations.identifiers.set(specifier.local, id);
}
break;
}
case 'ImportSpecifier': {
if ((id.kind === 'named' &&
getImportSpecifierName(specifier) === id.name) ||
(id.kind === 'default' &&
getImportSpecifierName(specifier) === 'default')) {
state.registrations.identifiers.set(specifier.local, id);
}
break;
}
case 'ImportNamespaceSpecifier': {
let current = state.registrations.namespaces.get(specifier.local);
if (!current) {
current = [];
}
current.push(id);
state.registrations.namespaces.set(specifier.local, current);
break;
}
}
}
function registerImportSpecifiers(state, p) {
for (let i = 0, len = state.imports.length; i < len; i++) {
const id = state.imports[i];
if (p.node.source.value === id.source) {
for (let k = 0, klen = p.node.specifiers.length; k < klen; k++) {
registerImportSpecifier(state, id, p.node.specifiers[k]);
}
}
}
}
function captureIdentifiers(state, path) {
path.traverse({
ImportDeclaration(p) {
if (p.node.importKind === 'value') {
registerImportSpecifiers(state, p);
}
},
});
}
function unwrapExpression(node, key) {
switch (node.type) {
case 'ParenthesizedExpression':
case 'TypeCastExpression':
case 'TSAsExpression':
case 'TSSatisfiesExpression':
case 'TSNonNullExpression':
case 'TSInstantiationExpression':
case 'TSTypeAssertion':
return unwrapExpression(node.expression, key);
default:
return key(node) ? node : undefined;
}
}
function isIdentifierValidCallee(state, path, callee, target) {
const binding = path.scope.getBindingIdentifier(callee.name);
if (binding) {
const result = state.registrations.identifiers.get(binding);
if (result && result.type === target) {
return true;
}
}
return false;
}
function isPropertyValidCallee(result, target, propName) {
for (let i = 0, len = result.length; i < len; i++) {
const registration = result[i];
if (registration.type === target) {
if (registration.kind === 'default') {
if (propName === 'default') {
return true;
}
}
else if (registration.kind === 'named' &&
registration.name === propName) {
return true;
}
}
}
return false;
}
function isMemberExpressionValidCallee(state, path, member, target) {
if (!t__namespace.isIdentifier(member.property)) {
return false;
}
const trueObject = unwrapExpression(member.object, t__namespace.isIdentifier);
if (!trueObject) {
return false;
}
const binding = path.scope.getBindingIdentifier(trueObject.name);
if (!binding) {
return false;
}
const result = state.registrations.namespaces.get(binding);
if (!result) {
return false;
}
return isPropertyValidCallee(result, target, member.property.name);
}
function isValidCallee(state, path, { callee }, target) {
if (t__namespace.isV8IntrinsicIdentifier(callee)) {
return false;
}
const trueCallee = unwrapExpression(callee, t__namespace.isIdentifier);
if (trueCallee) {
return isIdentifierValidCallee(state, path, trueCallee, target);
}
const trueMember = unwrapExpression(callee, t__namespace.isMemberExpression);
if (trueMember && !trueMember.computed) {
return isMemberExpressionValidCallee(state, path, trueMember, target);
}
return false;
}
function checkValidRenderCall(path) {
let currentPath = path.parentPath;
while (currentPath) {
if (t__namespace.isProgram(currentPath.node)) {
return true;
}
if (!t__namespace.isStatement(currentPath.node)) {
return false;
}
currentPath = currentPath.parentPath;
}
return false;
}
function fixRenderCalls(state, path) {
path.traverse({
ExpressionStatement(p) {
const trueCallExpr = unwrapExpression(p.node.expression, t__namespace.isCallExpression);
if (trueCallExpr &&
checkValidRenderCall(p) &&
isValidCallee(state, p, trueCallExpr, 'render')) {
// Replace with variable declaration
const id = p.scope.generateUidIdentifier('cleanup');
p.replaceWith(t__namespace.variableDeclaration('const', [
t__namespace.variableDeclarator(id, p.node.expression),
]));
const pathToHot = getHotIdentifier(state);
p.insertAfter(t__namespace.ifStatement(pathToHot, t__namespace.expressionStatement(t__namespace.callExpression(t__namespace.memberExpression(pathToHot, t__namespace.identifier('dispose')), [id]))));
p.skip();
}
},
});
}
function wrapComponent(state, path, identifier, component, original = component) {
const statementPath = getStatementPath(path);
if (statementPath) {
const registry = createRegistry(state, statementPath);
const hotName = t__namespace.stringLiteral(identifier.name);
const componentCall = getSolidRefreshIdentifier(state, statementPath, IMPORTS.component);
const properties = [];
if (state.filename && original.loc) {
const filePath = getFile(state.filename);
properties.push(t__namespace.objectProperty(t__namespace.identifier('location'), t__namespace.stringLiteral(`${filePath}:${original.loc.start.line}:${original.loc.start.column}`)));
}
if (state.granular) {
properties.push(t__namespace.objectProperty(t__namespace.identifier('signature'), t__namespace.stringLiteral(createSignatureValue(component))));
const dependencies = getBindings(path);
if (dependencies.length) {
const dependencyKeys = [];
let id;
for (let i = 0, len = dependencies.length; i < len; i++) {
id = dependencies[i];
dependencyKeys.push(t__namespace.objectProperty(id, id, false, true));
}
properties.push(t__namespace.objectProperty(t__namespace.identifier('dependencies'), t__namespace.arrowFunctionExpression([], t__namespace.objectExpression(dependencyKeys))));
}
return t__namespace.callExpression(componentCall, [
registry,
hotName,
component,
t__namespace.objectExpression(properties),
]);
}
return t__namespace.callExpression(componentCall, [
registry,
hotName,
component,
...(properties.length ? [t__namespace.objectExpression(properties)] : []),
]);
}
return component;
}
function wrapContext(state, path, identifier, context) {
const statementPath = getStatementPath(path);
if (statementPath) {
const registry = createRegistry(state, statementPath);
const hotName = t__namespace.stringLiteral(identifier.name);
const contextCall = getSolidRefreshIdentifier(state, statementPath, IMPORTS.context);
return t__namespace.callExpression(contextCall, [registry, hotName, context]);
}
return context;
}
function setupProgram(state, path) {
var _a;
let shouldSkip = false;
const comments = state.file.ast.comments;
if (comments) {
for (const { value: comment } of comments) {
if (/^\s*@refresh granular\s*$/.test(comment)) {
state.granular = true;
break;
}
if (/^\s*@refresh skip\s*$/.test(comment)) {
state.processed = true;
shouldSkip = true;
break;
}
if (/^\s*@refresh reload\s*$/.test(comment)) {
state.processed = true;
path.pushContainer('body', getHMRDeclineCall(state, path));
break;
}
}
}
captureIdentifiers(state, path);
if (!shouldSkip && ((_a = state.opts.fixRender) !== null && _a !== void 0 ? _a : true)) {
fixRenderCalls(state, path);
}
}
function transformExportNamedDeclaration(state, path) {
if (state.processed) {
return;
}
const decl = path.node.declaration;
// Check if declaration is FunctionDeclaration
if (t__namespace.isFunctionDeclaration(decl) &&
!(decl.generator || decl.async) &&
// Might be component-like, but the only valid components
// have zero or one parameter
decl.params.length < 2) {
// Check if the declaration has an identifier, and then check
// if the name is component-ish
if (decl.id && isComponentishName(decl.id.name)) {
path.node.declaration = t__namespace.variableDeclaration('const', [
t__namespace.variableDeclarator(decl.id, wrapComponent(state, path, decl.id, t__namespace.functionExpression(decl.id, decl.params, decl.body), decl)),
]);
}
}
}
function isStatementTopLevel(path) {
const programParent = path.scope.getProgramParent();
const blockParent = path.scope.getBlockParent();
return programParent === blockParent;
}
function transformVariableDeclarator(state, path) {
if (state.processed) {
return;
}
if (path.parentPath.isVariableDeclaration() &&
!isStatementTopLevel(path.parentPath)) {
return;
}
const identifier = path.node.id;
const init = path.node.init;
if (!(init && t__namespace.isIdentifier(identifier))) {
return;
}
if (isComponentishName(identifier.name)) {
const trueFuncExpr = unwrapExpression(init, t__namespace.isFunctionExpression) ||
unwrapExpression(init, t__namespace.isArrowFunctionExpression);
// Check for valid FunctionExpression or ArrowFunctionExpression
if (trueFuncExpr &&
// Must not be async or generator
!(trueFuncExpr.async || trueFuncExpr.generator) &&
// Might be component-like, but the only valid components
// have zero or one parameter
trueFuncExpr.params.length < 2) {
path.node.init = wrapComponent(state, path, identifier, trueFuncExpr);
}
}
// For `createContext` calls
const trueCallExpr = unwrapExpression(init, t__namespace.isCallExpression);
if (trueCallExpr &&
isValidCallee(state, path, trueCallExpr, 'createContext')) {
path.node.init = wrapContext(state, path, identifier, trueCallExpr);
}
}
function solidRefreshPlugin() {
return {
name: 'Solid Refresh',
pre() {
this.hooks = new Map();
this.processed = false;
this.granular = false;
this.registrations = {
identifiers: new Map(),
namespaces: new Map(),
};
this.imports = [...IMPORT_IDENTITIES, ...(this.opts.imports || [])];
},
visitor: {
Program(programPath, state) {
setupProgram(state, programPath);
programPath.traverse({
ExportNamedDeclaration(path) {
transformExportNamedDeclaration(state, path);
},
VariableDeclarator(path) {
transformVariableDeclarator(state, path);
},
FunctionDeclaration(path) {
if (state.processed) {
return;
}
if (path.parentPath.isProgram() ||
path.parentPath.isExportDefaultDeclaration()) {
const decl = path.node;
// Check if declaration is FunctionDeclaration
if (
// Check if the declaration has an identifier, and then check
decl.id &&
// if the name is component-ish
isComponentishName(decl.id.name) &&
!(decl.generator || decl.async) &&
// Might be component-like, but the only valid components
// have zero or one parameter
decl.params.length < 2) {
const replacement = wrapComponent(state, path, decl.id, t__namespace.functionExpression(decl.id, decl.params, decl.body), decl);
const newDecl = t__namespace.variableDeclaration('var', [
t__namespace.variableDeclarator(decl.id, replacement),
]);
if (path.parentPath.isExportDefaultDeclaration()) {
const parent = path.parentPath
.parentPath;
const first = parent.get('body')[0];
first.insertBefore(newDecl);
path.replaceWith(decl.id);
}
else {
const parent = path.parentPath;
const first = parent.get('body')[0];
first.insertBefore(newDecl);
path.remove();
}
}
}
},
});
},
},
};
}
module.exports = solidRefreshPlugin;

723
node_modules/solid-refresh/dist/babel.mjs generated vendored Normal file
View File

@@ -0,0 +1,723 @@
import path from 'path';
import * as t from '@babel/types';
import _generator from '@babel/generator';
import { addNamed } from '@babel/helper-module-imports';
/**
* Copyright (c) 2019 Jason Dent
* https://github.com/Jason3S/xxhash
*/
const PRIME32_1 = 2654435761;
const PRIME32_2 = 2246822519;
const PRIME32_3 = 3266489917;
const PRIME32_4 = 668265263;
const PRIME32_5 = 374761393;
function toUtf8(text) {
const bytes = [];
for (let i = 0, n = text.length; i < n; ++i) {
const c = text.charCodeAt(i);
if (c < 0x80) {
bytes.push(c);
}
else if (c < 0x800) {
bytes.push(0xc0 | (c >> 6), 0x80 | (c & 0x3f));
}
else if (c < 0xd800 || c >= 0xe000) {
bytes.push(0xe0 | (c >> 12), 0x80 | ((c >> 6) & 0x3f), 0x80 | (c & 0x3f));
}
else {
const cp = 0x10000 + (((c & 0x3ff) << 10) | (text.charCodeAt(++i) & 0x3ff));
bytes.push(0xf0 | ((cp >> 18) & 0x7), 0x80 | ((cp >> 12) & 0x3f), 0x80 | ((cp >> 6) & 0x3f), 0x80 | (cp & 0x3f));
}
}
return new Uint8Array(bytes);
}
/**
*
* @param buffer - byte array or string
* @param seed - optional seed (32-bit unsigned);
*/
function xxHash32(buffer, seed = 0) {
buffer = typeof buffer === 'string' ? toUtf8(buffer) : buffer;
const b = buffer;
/*
Step 1. Initialize internal accumulators
Each accumulator gets an initial value based on optional seed input. Since the seed is optional, it can be 0.
```
u32 acc1 = seed + PRIME32_1 + PRIME32_2;
u32 acc2 = seed + PRIME32_2;
u32 acc3 = seed + 0;
u32 acc4 = seed - PRIME32_1;
```
Special case : input is less than 16 bytes
When input is too small (< 16 bytes), the algorithm will not process any stripe. Consequently, it will not
make use of parallel accumulators.
In which case, a simplified initialization is performed, using a single accumulator :
u32 acc = seed + PRIME32_5;
The algorithm then proceeds directly to step 4.
*/
let acc = (seed + PRIME32_5) & 0xffffffff;
let offset = 0;
if (b.length >= 16) {
const accN = [
(seed + PRIME32_1 + PRIME32_2) & 0xffffffff,
(seed + PRIME32_2) & 0xffffffff,
(seed + 0) & 0xffffffff,
(seed - PRIME32_1) & 0xffffffff,
];
/*
Step 2. Process stripes
A stripe is a contiguous segment of 16 bytes. It is evenly divided into 4 lanes, of 4 bytes each.
The first lane is used to update accumulator 1, the second lane is used to update accumulator 2, and so on.
Each lane read its associated 32-bit value using little-endian convention.
For each {lane, accumulator}, the update process is called a round, and applies the following formula :
```
accN = accN + (laneN * PRIME32_2);
accN = accN <<< 13;
accN = accN * PRIME32_1;
```
This shuffles the bits so that any bit from input lane impacts several bits in output accumulator.
All operations are performed modulo 2^32.
Input is consumed one full stripe at a time. Step 2 is looped as many times as necessary to consume
the whole input, except the last remaining bytes which cannot form a stripe (< 16 bytes). When that
happens, move to step 3.
*/
const b = buffer;
const limit = b.length - 16;
let lane = 0;
for (offset = 0; (offset & 0xfffffff0) <= limit; offset += 4) {
const i = offset;
const laneN0 = b[i + 0] + (b[i + 1] << 8);
const laneN1 = b[i + 2] + (b[i + 3] << 8);
const laneNP = laneN0 * PRIME32_2 + ((laneN1 * PRIME32_2) << 16);
let acc = (accN[lane] + laneNP) & 0xffffffff;
acc = (acc << 13) | (acc >>> 19);
const acc0 = acc & 0xffff;
const acc1 = acc >>> 16;
accN[lane] = (acc0 * PRIME32_1 + ((acc1 * PRIME32_1) << 16)) & 0xffffffff;
lane = (lane + 1) & 0x3;
}
/*
Step 3. Accumulator convergence
All 4 lane accumulators from previous steps are merged to produce a single remaining accumulator
of same width (32-bit). The associated formula is as follows :
```
acc = (acc1 <<< 1) + (acc2 <<< 7) + (acc3 <<< 12) + (acc4 <<< 18);
```
*/
acc =
(((accN[0] << 1) | (accN[0] >>> 31)) +
((accN[1] << 7) | (accN[1] >>> 25)) +
((accN[2] << 12) | (accN[2] >>> 20)) +
((accN[3] << 18) | (accN[3] >>> 14))) &
0xffffffff;
}
/*
Step 4. Add input length
The input total length is presumed known at this stage. This step is just about adding the length to
accumulator, so that it participates to final mixing.
```
acc = acc + (u32)inputLength;
```
*/
acc = (acc + buffer.length) & 0xffffffff;
/*
Step 5. Consume remaining input
There may be up to 15 bytes remaining to consume from the input. The final stage will digest them according
to following pseudo-code :
```
while (remainingLength >= 4) {
lane = read_32bit_little_endian(input_ptr);
acc = acc + lane * PRIME32_3;
acc = (acc <<< 17) * PRIME32_4;
input_ptr += 4; remainingLength -= 4;
}
```
This process ensures that all input bytes are present in the final mix.
*/
const limit = buffer.length - 4;
for (; offset <= limit; offset += 4) {
const i = offset;
const laneN0 = b[i + 0] + (b[i + 1] << 8);
const laneN1 = b[i + 2] + (b[i + 3] << 8);
const laneP = laneN0 * PRIME32_3 + ((laneN1 * PRIME32_3) << 16);
acc = (acc + laneP) & 0xffffffff;
acc = (acc << 17) | (acc >>> 15);
acc =
((acc & 0xffff) * PRIME32_4 + (((acc >>> 16) * PRIME32_4) << 16)) &
0xffffffff;
}
/*
```
while (remainingLength >= 1) {
lane = read_byte(input_ptr);
acc = acc + lane * PRIME32_5;
acc = (acc <<< 11) * PRIME32_1;
input_ptr += 1; remainingLength -= 1;
}
```
*/
for (; offset < b.length; ++offset) {
const lane = b[offset];
acc = acc + lane * PRIME32_5;
acc = (acc << 11) | (acc >>> 21);
acc =
((acc & 0xffff) * PRIME32_1 + (((acc >>> 16) * PRIME32_1) << 16)) &
0xffffffff;
}
/*
Step 6. Final mix (avalanche)
The final mix ensures that all input bits have a chance to impact any bit in the output digest,
resulting in an unbiased distribution. This is also called avalanche effect.
```
acc = acc xor (acc >> 15);
acc = acc * PRIME32_2;
acc = acc xor (acc >> 13);
acc = acc * PRIME32_3;
acc = acc xor (acc >> 16);
```
*/
acc = acc ^ (acc >>> 15);
acc =
(((acc & 0xffff) * PRIME32_2) & 0xffffffff) +
(((acc >>> 16) * PRIME32_2) << 16);
acc = acc ^ (acc >>> 13);
acc =
(((acc & 0xffff) * PRIME32_3) & 0xffffffff) +
(((acc >>> 16) * PRIME32_3) << 16);
acc = acc ^ (acc >>> 16);
// turn any negatives back into a positive number;
return acc < 0 ? acc + 4294967296 : acc;
}
// https://github.com/babel/babel/issues/15269
let generator;
if (typeof _generator !== 'function') {
generator = _generator.default;
}
else {
generator = _generator;
}
const CWD = process.cwd();
function getFile(filename) {
return path.relative(CWD, filename);
}
// This is just a Pascal heuristic
// we only assume a function is a component
// if the first character is in uppercase
function isComponentishName(name) {
return name[0] >= 'A' && name[0] <= 'Z';
}
function isESMHMR(bundler) {
// The currently known ESM HMR implementations
// esm - the original ESM HMR Spec
// vite - Vite's implementation
return bundler === 'esm' || bundler === 'vite';
}
// Source of solid-refresh (for import)
const SOLID_REFRESH_MODULE = 'solid-refresh';
// Exported names from solid-refresh that will be imported
const IMPORTS = {
registry: '$$registry',
refresh: '$$refresh',
component: '$$component',
context: '$$context',
decline: '$$decline',
};
function getSolidRefreshIdentifier(state, path, name) {
const target = `${name}`;
const current = state.hooks.get(target);
if (current) {
return current;
}
const newID = addNamed(path, name, SOLID_REFRESH_MODULE);
state.hooks.set(target, newID);
return newID;
}
function getHotIdentifier(state) {
const bundler = state.opts.bundler;
// vite/esm uses `import.meta.hot`
if (isESMHMR(bundler)) {
return t.memberExpression(t.memberExpression(t.identifier('import'), t.identifier('meta')), t.identifier('hot'));
}
// webpack 5 uses `import.meta.webpackHot`
// rspack does as well
if (bundler === 'webpack5' || bundler === 'rspack-esm') {
return t.memberExpression(t.memberExpression(t.identifier('import'), t.identifier('meta')), t.identifier('webpackHot'));
}
// `module.hot` is the default.
return t.memberExpression(t.identifier('module'), t.identifier('hot'));
}
function generateViteRequirement(state, statements, pathToHot) {
if (state.opts.bundler === 'vite') {
// Vite requires that the owner module has an `import.meta.hot.accept()` call
statements.push(t.expressionStatement(t.callExpression(t.memberExpression(pathToHot, t.identifier('accept')), [])));
}
}
function getHMRDeclineCall(state, path) {
var _a;
const pathToHot = getHotIdentifier(state);
const statements = [
t.expressionStatement(t.callExpression(getSolidRefreshIdentifier(state, path, IMPORTS.decline), [t.stringLiteral((_a = state.opts.bundler) !== null && _a !== void 0 ? _a : 'standard'), pathToHot])),
];
generateViteRequirement(state, statements, pathToHot);
return t.ifStatement(pathToHot, t.blockStatement(statements));
}
function getStatementPath(path) {
if (t.isStatement(path.node)) {
return path;
}
if (path.parentPath) {
return getStatementPath(path.parentPath);
}
return null;
}
const REGISTRY = 'REGISTRY';
function createRegistry(state, path) {
var _a;
const current = state.hooks.get(REGISTRY);
if (current) {
return current;
}
const program = path.scope.getProgramParent();
const identifier = program.generateUidIdentifier(REGISTRY);
program.push({
id: identifier,
kind: 'const',
init: t.callExpression(getSolidRefreshIdentifier(state, path, IMPORTS.registry), []),
});
const pathToHot = getHotIdentifier(state);
const statements = [
t.expressionStatement(t.callExpression(getSolidRefreshIdentifier(state, path, IMPORTS.refresh), [
t.stringLiteral((_a = state.opts.bundler) !== null && _a !== void 0 ? _a : 'standard'),
pathToHot,
identifier,
])),
];
generateViteRequirement(state, statements, pathToHot);
program.path.pushContainer('body', [
t.ifStatement(pathToHot, t.blockStatement(statements)),
]);
state.hooks.set(REGISTRY, identifier);
return identifier;
}
function createSignatureValue(node) {
const code = generator(node);
const result = xxHash32(code.code).toString(16);
return result;
}
function isForeignBinding(source, current, name) {
if (source === current) {
return true;
}
if (current.scope.hasOwnBinding(name)) {
return false;
}
if (current.parentPath) {
return isForeignBinding(source, current.parentPath, name);
}
return true;
}
function isInTypescript(path) {
let parent = path.parentPath;
while (parent) {
if (t.isTypeScript(parent.node) && !t.isExpression(parent.node)) {
return true;
}
parent = parent.parentPath;
}
return false;
}
function getBindings(path) {
const identifiers = new Set();
path.traverse({
ReferencedIdentifier(p) {
// Check identifiers that aren't in a TS expression
if (!isInTypescript(p) && isForeignBinding(path, p, p.node.name)) {
identifiers.add(p.node.name);
}
},
});
const collected = [];
for (const identifier of identifiers) {
collected.push(t.identifier(identifier));
}
return collected;
}
const IMPORT_IDENTITIES = [
{
type: 'createContext',
name: 'createContext',
kind: 'named',
source: 'solid-js',
},
{
type: 'createContext',
name: 'createContext',
kind: 'named',
source: 'solid-js/web',
},
{ type: 'render', name: 'render', kind: 'named', source: 'solid-js/web' },
{ type: 'render', name: 'hydrate', kind: 'named', source: 'solid-js/web' },
];
function getImportSpecifierName(specifier) {
switch (specifier.imported.type) {
case 'Identifier':
return specifier.imported.name;
case 'StringLiteral':
return specifier.imported.value;
}
}
function registerImportSpecifier(state, id, specifier) {
switch (specifier.type) {
case 'ImportDefaultSpecifier': {
if (id.kind === 'default') {
state.registrations.identifiers.set(specifier.local, id);
}
break;
}
case 'ImportSpecifier': {
if ((id.kind === 'named' &&
getImportSpecifierName(specifier) === id.name) ||
(id.kind === 'default' &&
getImportSpecifierName(specifier) === 'default')) {
state.registrations.identifiers.set(specifier.local, id);
}
break;
}
case 'ImportNamespaceSpecifier': {
let current = state.registrations.namespaces.get(specifier.local);
if (!current) {
current = [];
}
current.push(id);
state.registrations.namespaces.set(specifier.local, current);
break;
}
}
}
function registerImportSpecifiers(state, p) {
for (let i = 0, len = state.imports.length; i < len; i++) {
const id = state.imports[i];
if (p.node.source.value === id.source) {
for (let k = 0, klen = p.node.specifiers.length; k < klen; k++) {
registerImportSpecifier(state, id, p.node.specifiers[k]);
}
}
}
}
function captureIdentifiers(state, path) {
path.traverse({
ImportDeclaration(p) {
if (p.node.importKind === 'value') {
registerImportSpecifiers(state, p);
}
},
});
}
function unwrapExpression(node, key) {
switch (node.type) {
case 'ParenthesizedExpression':
case 'TypeCastExpression':
case 'TSAsExpression':
case 'TSSatisfiesExpression':
case 'TSNonNullExpression':
case 'TSInstantiationExpression':
case 'TSTypeAssertion':
return unwrapExpression(node.expression, key);
default:
return key(node) ? node : undefined;
}
}
function isIdentifierValidCallee(state, path, callee, target) {
const binding = path.scope.getBindingIdentifier(callee.name);
if (binding) {
const result = state.registrations.identifiers.get(binding);
if (result && result.type === target) {
return true;
}
}
return false;
}
function isPropertyValidCallee(result, target, propName) {
for (let i = 0, len = result.length; i < len; i++) {
const registration = result[i];
if (registration.type === target) {
if (registration.kind === 'default') {
if (propName === 'default') {
return true;
}
}
else if (registration.kind === 'named' &&
registration.name === propName) {
return true;
}
}
}
return false;
}
function isMemberExpressionValidCallee(state, path, member, target) {
if (!t.isIdentifier(member.property)) {
return false;
}
const trueObject = unwrapExpression(member.object, t.isIdentifier);
if (!trueObject) {
return false;
}
const binding = path.scope.getBindingIdentifier(trueObject.name);
if (!binding) {
return false;
}
const result = state.registrations.namespaces.get(binding);
if (!result) {
return false;
}
return isPropertyValidCallee(result, target, member.property.name);
}
function isValidCallee(state, path, { callee }, target) {
if (t.isV8IntrinsicIdentifier(callee)) {
return false;
}
const trueCallee = unwrapExpression(callee, t.isIdentifier);
if (trueCallee) {
return isIdentifierValidCallee(state, path, trueCallee, target);
}
const trueMember = unwrapExpression(callee, t.isMemberExpression);
if (trueMember && !trueMember.computed) {
return isMemberExpressionValidCallee(state, path, trueMember, target);
}
return false;
}
function checkValidRenderCall(path) {
let currentPath = path.parentPath;
while (currentPath) {
if (t.isProgram(currentPath.node)) {
return true;
}
if (!t.isStatement(currentPath.node)) {
return false;
}
currentPath = currentPath.parentPath;
}
return false;
}
function fixRenderCalls(state, path) {
path.traverse({
ExpressionStatement(p) {
const trueCallExpr = unwrapExpression(p.node.expression, t.isCallExpression);
if (trueCallExpr &&
checkValidRenderCall(p) &&
isValidCallee(state, p, trueCallExpr, 'render')) {
// Replace with variable declaration
const id = p.scope.generateUidIdentifier('cleanup');
p.replaceWith(t.variableDeclaration('const', [
t.variableDeclarator(id, p.node.expression),
]));
const pathToHot = getHotIdentifier(state);
p.insertAfter(t.ifStatement(pathToHot, t.expressionStatement(t.callExpression(t.memberExpression(pathToHot, t.identifier('dispose')), [id]))));
p.skip();
}
},
});
}
function wrapComponent(state, path, identifier, component, original = component) {
const statementPath = getStatementPath(path);
if (statementPath) {
const registry = createRegistry(state, statementPath);
const hotName = t.stringLiteral(identifier.name);
const componentCall = getSolidRefreshIdentifier(state, statementPath, IMPORTS.component);
const properties = [];
if (state.filename && original.loc) {
const filePath = getFile(state.filename);
properties.push(t.objectProperty(t.identifier('location'), t.stringLiteral(`${filePath}:${original.loc.start.line}:${original.loc.start.column}`)));
}
if (state.granular) {
properties.push(t.objectProperty(t.identifier('signature'), t.stringLiteral(createSignatureValue(component))));
const dependencies = getBindings(path);
if (dependencies.length) {
const dependencyKeys = [];
let id;
for (let i = 0, len = dependencies.length; i < len; i++) {
id = dependencies[i];
dependencyKeys.push(t.objectProperty(id, id, false, true));
}
properties.push(t.objectProperty(t.identifier('dependencies'), t.arrowFunctionExpression([], t.objectExpression(dependencyKeys))));
}
return t.callExpression(componentCall, [
registry,
hotName,
component,
t.objectExpression(properties),
]);
}
return t.callExpression(componentCall, [
registry,
hotName,
component,
...(properties.length ? [t.objectExpression(properties)] : []),
]);
}
return component;
}
function wrapContext(state, path, identifier, context) {
const statementPath = getStatementPath(path);
if (statementPath) {
const registry = createRegistry(state, statementPath);
const hotName = t.stringLiteral(identifier.name);
const contextCall = getSolidRefreshIdentifier(state, statementPath, IMPORTS.context);
return t.callExpression(contextCall, [registry, hotName, context]);
}
return context;
}
function setupProgram(state, path) {
var _a;
let shouldSkip = false;
const comments = state.file.ast.comments;
if (comments) {
for (const { value: comment } of comments) {
if (/^\s*@refresh granular\s*$/.test(comment)) {
state.granular = true;
break;
}
if (/^\s*@refresh skip\s*$/.test(comment)) {
state.processed = true;
shouldSkip = true;
break;
}
if (/^\s*@refresh reload\s*$/.test(comment)) {
state.processed = true;
path.pushContainer('body', getHMRDeclineCall(state, path));
break;
}
}
}
captureIdentifiers(state, path);
if (!shouldSkip && ((_a = state.opts.fixRender) !== null && _a !== void 0 ? _a : true)) {
fixRenderCalls(state, path);
}
}
function transformExportNamedDeclaration(state, path) {
if (state.processed) {
return;
}
const decl = path.node.declaration;
// Check if declaration is FunctionDeclaration
if (t.isFunctionDeclaration(decl) &&
!(decl.generator || decl.async) &&
// Might be component-like, but the only valid components
// have zero or one parameter
decl.params.length < 2) {
// Check if the declaration has an identifier, and then check
// if the name is component-ish
if (decl.id && isComponentishName(decl.id.name)) {
path.node.declaration = t.variableDeclaration('const', [
t.variableDeclarator(decl.id, wrapComponent(state, path, decl.id, t.functionExpression(decl.id, decl.params, decl.body), decl)),
]);
}
}
}
function isStatementTopLevel(path) {
const programParent = path.scope.getProgramParent();
const blockParent = path.scope.getBlockParent();
return programParent === blockParent;
}
function transformVariableDeclarator(state, path) {
if (state.processed) {
return;
}
if (path.parentPath.isVariableDeclaration() &&
!isStatementTopLevel(path.parentPath)) {
return;
}
const identifier = path.node.id;
const init = path.node.init;
if (!(init && t.isIdentifier(identifier))) {
return;
}
if (isComponentishName(identifier.name)) {
const trueFuncExpr = unwrapExpression(init, t.isFunctionExpression) ||
unwrapExpression(init, t.isArrowFunctionExpression);
// Check for valid FunctionExpression or ArrowFunctionExpression
if (trueFuncExpr &&
// Must not be async or generator
!(trueFuncExpr.async || trueFuncExpr.generator) &&
// Might be component-like, but the only valid components
// have zero or one parameter
trueFuncExpr.params.length < 2) {
path.node.init = wrapComponent(state, path, identifier, trueFuncExpr);
}
}
// For `createContext` calls
const trueCallExpr = unwrapExpression(init, t.isCallExpression);
if (trueCallExpr &&
isValidCallee(state, path, trueCallExpr, 'createContext')) {
path.node.init = wrapContext(state, path, identifier, trueCallExpr);
}
}
function solidRefreshPlugin() {
return {
name: 'Solid Refresh',
pre() {
this.hooks = new Map();
this.processed = false;
this.granular = false;
this.registrations = {
identifiers: new Map(),
namespaces: new Map(),
};
this.imports = [...IMPORT_IDENTITIES, ...(this.opts.imports || [])];
},
visitor: {
Program(programPath, state) {
setupProgram(state, programPath);
programPath.traverse({
ExportNamedDeclaration(path) {
transformExportNamedDeclaration(state, path);
},
VariableDeclarator(path) {
transformVariableDeclarator(state, path);
},
FunctionDeclaration(path) {
if (state.processed) {
return;
}
if (path.parentPath.isProgram() ||
path.parentPath.isExportDefaultDeclaration()) {
const decl = path.node;
// Check if declaration is FunctionDeclaration
if (
// Check if the declaration has an identifier, and then check
decl.id &&
// if the name is component-ish
isComponentishName(decl.id.name) &&
!(decl.generator || decl.async) &&
// Might be component-like, but the only valid components
// have zero or one parameter
decl.params.length < 2) {
const replacement = wrapComponent(state, path, decl.id, t.functionExpression(decl.id, decl.params, decl.body), decl);
const newDecl = t.variableDeclaration('var', [
t.variableDeclarator(decl.id, replacement),
]);
if (path.parentPath.isExportDefaultDeclaration()) {
const parent = path.parentPath
.parentPath;
const first = parent.get('body')[0];
first.insertBefore(newDecl);
path.replaceWith(decl.id);
}
else {
const parent = path.parentPath;
const first = parent.get('body')[0];
first.insertBefore(newDecl);
path.remove();
}
}
}
},
});
},
},
};
}
export { solidRefreshPlugin as default };

328
node_modules/solid-refresh/dist/solid-refresh.cjs generated vendored Normal file
View File

@@ -0,0 +1,328 @@
'use strict';
var solidJs = require('solid-js');
function setComponentProperty(component, key, value) {
const descriptor = Object.getOwnPropertyDescriptor(component, key);
if (descriptor) {
Object.defineProperty(component, key, Object.assign(Object.assign({}, descriptor), { value }));
}
else {
Object.defineProperty(component, key, {
value,
writable: false,
enumerable: false,
configurable: true,
});
}
}
function createProxy(source, name, location) {
const refreshName = `[solid-refresh]${name}`;
function HMRComp(props) {
const s = source();
if (!s || solidJs.$DEVCOMP in s) {
return solidJs.createMemo(() => {
const c = source();
if (c) {
return solidJs.untrack(() => c(props));
}
return undefined;
}, {
name: refreshName,
});
}
// no $DEVCOMP means it did not go through devComponent so source() is a regular function, not a component
return s(props);
}
setComponentProperty(HMRComp, 'name', refreshName);
if (location) {
setComponentProperty(HMRComp, 'location', location);
}
return new Proxy(HMRComp, {
get(_, property) {
if (property === 'location' || property === 'name') {
return HMRComp[property];
}
return source()[property];
},
set(_, property, value) {
source()[property] = value;
return true;
},
});
}
function isListUpdatedInternal(a, b) {
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
// Check if both objects has the same amount of keys
if (aKeys.length !== bKeys.length) {
return true;
}
// Merge keys
const keys = new Set([...aKeys, ...bKeys]);
// Now check if merged keys has the same amount of keys as the other two
// for example: { a, b } and { a, c } produces { a, b, c }
if (keys.size !== aKeys.length) {
return true;
}
// Now compare each items
for (const key of keys) {
// This covers NaN. No need for Object.is since it's extreme for -0
if (a[key] !== b[key] || (a[key] !== a[key] && b[key] !== b[key])) {
return true;
}
}
return false;
}
function isListUpdated(a, b) {
if (a && b) {
return isListUpdatedInternal(a, b);
}
if (a == null && b != null) {
return true;
}
if (a != null && b == null) {
return true;
}
return false;
}
function $$registry() {
return {
components: new Map(),
contexts: new Map(),
};
}
function $$component(registry, id, component, options = {}) {
const [comp, setComp] = solidJs.createSignal(component, { internal: true });
const proxy = createProxy(comp, id, options.location);
registry.components.set(id, Object.assign({ id,
component,
proxy, update: setComp }, options));
return proxy;
}
function $$context(registry, id, context) {
registry.contexts.set(id, {
id,
context,
});
return context;
}
function patchComponent(oldData, newData) {
var _a, _b;
// Check if incoming module has signature
if (newData.signature) {
// Compare signatures
const oldDeps = (_a = oldData.dependencies) === null || _a === void 0 ? void 0 : _a.call(oldData);
const newDeps = (_b = newData.dependencies) === null || _b === void 0 ? void 0 : _b.call(newData);
if (newData.signature !== oldData.signature ||
isListUpdated(newDeps, oldDeps)) {
// Replace signatures and dependencies
oldData.dependencies = newDeps ? () => newDeps : undefined;
oldData.signature = newData.signature;
// Remount
oldData.update(() => newData.component);
}
}
else {
// No granular update, remount
oldData.update(() => newData.component);
}
// Always rely on the first proxy
// This is to allow modules newly importing
// the updated version to still be able
// to render the latest version despite
// not receiving the first proxy
newData.update(() => oldData.proxy);
}
function patchComponents(oldData, newData) {
const components = new Set([
...oldData.components.keys(),
...newData.components.keys(),
]);
for (const key of components) {
const oldComponent = oldData.components.get(key);
const newComponent = newData.components.get(key);
if (oldComponent) {
if (newComponent) {
patchComponent(oldComponent, newComponent);
}
else {
// We need to invalidate
return true;
}
}
else if (newComponent) {
oldData.components.set(key, newComponent);
}
}
return false;
}
function patchContext(oldData, newData) {
oldData.context.defaultValue = newData.context.defaultValue;
newData.context.id = oldData.context.id;
newData.context.Provider = oldData.context.Provider;
}
function patchContexts(oldData, newData) {
const contexts = new Set([
...oldData.contexts.keys(),
...newData.contexts.keys(),
]);
for (const key of contexts) {
const oldContext = oldData.contexts.get(key);
const newContext = newData.contexts.get(key);
if (oldContext) {
if (newContext) {
patchContext(oldContext, newContext);
}
else {
// We need to invalidate
return true;
}
}
else if (newContext) {
oldData.contexts.set(key, newContext);
}
}
return false;
}
function patchRegistry(oldRegistry, newRegistry) {
const shouldInvalidateByContext = patchContexts(oldRegistry, newRegistry);
const shouldInvalidateByComponents = patchComponents(oldRegistry, newRegistry);
// In the future we may add other HMR features here
return shouldInvalidateByComponents || shouldInvalidateByContext;
}
const SOLID_REFRESH = 'solid-refresh';
const SOLID_REFRESH_PREV = 'solid-refresh-prev';
function $$decline(...[type, hot, inline]) {
switch (type) {
case 'esm': {
// Snowpack's ESM assumes invalidate as a normal page reload
// decline should be better
if (inline) {
hot.invalidate();
}
else {
hot.decline();
}
break;
}
case 'vite': {
// Vite is no-op on decline, just call invalidate
if (inline) {
hot.invalidate();
}
else {
hot.accept(() => {
hot.invalidate();
});
}
break;
}
case 'rspack-esm':
case 'webpack5': {
if (inline) {
hot.invalidate();
}
else {
hot.decline();
}
break;
}
case 'standard': {
// Some implementations do not have decline/invalidate
if (inline) {
if (hot.invalidate) {
hot.invalidate();
}
else {
window.location.reload();
}
}
else if (hot.decline) {
hot.decline();
}
else {
hot.accept(() => {
if (hot.invalidate) {
hot.invalidate();
}
else {
window.location.reload();
}
});
}
break;
}
}
}
let warned = false;
function shouldWarnAndDecline() {
const result = solidJs.DEV && Object.keys(solidJs.DEV).length;
if (result) {
return false;
}
if (!warned) {
console.warn("To use solid-refresh, you need to use the dev build of SolidJS. Make sure your build system supports package.json conditional exports and has the 'development' condition turned on.");
warned = true;
}
return true;
}
function $$refreshESM(type, hot, registry) {
if (shouldWarnAndDecline()) {
$$decline(type, hot);
}
else if (hot.data) {
hot.data[SOLID_REFRESH] = hot.data[SOLID_REFRESH] || registry;
hot.data[SOLID_REFRESH_PREV] = registry;
hot.accept(mod => {
if (mod == null ||
patchRegistry(hot.data[SOLID_REFRESH], hot.data[SOLID_REFRESH_PREV])) {
hot.invalidate();
}
});
}
else {
// I guess just decline if hot.data doesn't exist
$$decline(type, hot);
}
}
function $$refreshStandard(type, hot, registry) {
if (shouldWarnAndDecline()) {
$$decline(type, hot);
}
else {
const current = hot.data;
if (current && current[SOLID_REFRESH]) {
if (patchRegistry(current[SOLID_REFRESH], registry)) {
$$decline(type, hot, true);
}
}
hot.dispose((data) => {
data[SOLID_REFRESH] = current ? current[SOLID_REFRESH] : registry;
});
hot.accept();
}
}
function $$refresh(...[type, hot, registry]) {
switch (type) {
case 'esm':
case 'vite': {
$$refreshESM(type, hot, registry);
break;
}
case 'standard':
case 'webpack5':
case 'rspack-esm': {
$$refreshStandard(type, hot, registry);
break;
}
}
}
exports.$$component = $$component;
exports.$$context = $$context;
exports.$$decline = $$decline;
exports.$$refresh = $$refresh;
exports.$$registry = $$registry;

152
node_modules/solid-refresh/dist/solid-refresh.js generated vendored Normal file
View File

@@ -0,0 +1,152 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var solidJs = require('solid-js');
function createProxy(source) {
return new Proxy(function hmrCompWrapper(props, ...rest) {
const s = source();
if (!s || solidJs.$DEVCOMP in s) {
return solidJs.createMemo(() => {
const c = source();
if (c) {
return solidJs.untrack(() => c(props));
}
return undefined;
});
}
// no $DEVCOMP means it did not go through devComponent so source() is a regular function, not a component
return s.call(this, props, ...rest);
}, {
get(_, property) {
return source()[property];
},
set(_, property, value) {
source()[property] = value;
return true;
}
});
}
function isListUpdated(a, b) {
if (a == null && b != null) {
return true;
}
if (a != null && b == null) {
return true;
}
if (a && b) {
if (a.length !== b.length) {
return true;
}
for (let i = 0, len = a.length; i < len; i++) {
if (!Object.is(a[i], b[i])) {
return true;
}
}
}
return false;
}
function hot$1({ component: Comp, id, signature, dependencies }, hot) {
if (hot) {
const [comp, setComp] = solidJs.createSignal(Comp, { internal: true });
const prev = hot.data;
// Check if there's previous data
if (prev && prev[id]) {
// Check if there's a new signature and dependency
// This is always new in standard HMR
if (signature && dependencies) {
// Check if signature changed
// or dependencies changed
if (prev[id].signature !== signature ||
isListUpdated(prev[id].dependencies, dependencies)) {
// Remount
prev[id].dependencies = dependencies;
prev[id].signature = signature;
prev[id].setComp(() => Comp);
}
}
else {
prev[id].setComp(() => Comp);
}
}
hot.dispose(data => {
data[id] = prev
? prev[id]
: {
setComp,
signature,
dependencies
};
});
hot.accept();
return createProxy(comp);
}
return Comp;
}
const HOT_DATA_PREFIX = "solid-refresh-ctx";
function hot({ component: Comp, id, signature, dependencies }, hot) {
let Component = Comp;
function handler(newModule) {
const registration = newModule.$$registrations[id];
if (!registration) {
// For some reason, the registration was lost, invalidate
return true;
}
registration.component.setComp = Comp.setComp;
registration.component.signature = Comp.signature;
registration.component.dependencies = Comp.dependencies;
// Check if incoming module has signature
if (registration.signature && registration.dependencies) {
// Compare old signature and dependencies
if (registration.signature !== Comp.signature ||
isListUpdated(registration.dependencies, Comp.dependencies)) {
// Remount
Comp.dependencies = registration.dependencies;
Comp.signature = registration.signature;
Comp.setComp(() => registration.component);
}
}
else {
// No granular update, remount
Comp.setComp(() => registration.component);
}
registration.component.signature = Comp.signature;
registration.component.dependencies = Comp.dependencies;
return false;
}
if (hot && hot.data) {
const refreshData = (hot.data[HOT_DATA_PREFIX] = hot.data[HOT_DATA_PREFIX] || {});
if (refreshData[id]) {
Comp.setComp = refreshData[id].Comp.setComp;
return { Component: refreshData[id].Component, handler };
}
const [comp, setComp] = solidJs.createSignal(Comp, { internal: true });
Comp.setComp = setComp;
Comp.dependencies = dependencies;
Comp.signature = signature;
Component = createProxy(comp);
refreshData[id] = { Component, Comp };
}
return { Component, handler };
}
let warned = false;
function shouldWarnAndDecline() {
const result = solidJs.DEV && Object.keys(solidJs.DEV).length;
if (result) {
return false;
}
if (!warned) {
console.warn("To use solid-refresh, you need to use the dev build of SolidJS. Make sure your build system supports package.json conditional exports and has the 'development' condition turned on.");
warned = true;
}
return true;
}
exports.esm = hot;
exports.shouldWarnAndDecline = shouldWarnAndDecline;
exports.standard = hot$1;

322
node_modules/solid-refresh/dist/solid-refresh.mjs generated vendored Normal file
View File

@@ -0,0 +1,322 @@
import { $DEVCOMP, createMemo, untrack, createSignal, DEV } from 'solid-js';
function setComponentProperty(component, key, value) {
const descriptor = Object.getOwnPropertyDescriptor(component, key);
if (descriptor) {
Object.defineProperty(component, key, Object.assign(Object.assign({}, descriptor), { value }));
}
else {
Object.defineProperty(component, key, {
value,
writable: false,
enumerable: false,
configurable: true,
});
}
}
function createProxy(source, name, location) {
const refreshName = `[solid-refresh]${name}`;
function HMRComp(props) {
const s = source();
if (!s || $DEVCOMP in s) {
return createMemo(() => {
const c = source();
if (c) {
return untrack(() => c(props));
}
return undefined;
}, {
name: refreshName,
});
}
// no $DEVCOMP means it did not go through devComponent so source() is a regular function, not a component
return s(props);
}
setComponentProperty(HMRComp, 'name', refreshName);
if (location) {
setComponentProperty(HMRComp, 'location', location);
}
return new Proxy(HMRComp, {
get(_, property) {
if (property === 'location' || property === 'name') {
return HMRComp[property];
}
return source()[property];
},
set(_, property, value) {
source()[property] = value;
return true;
},
});
}
function isListUpdatedInternal(a, b) {
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
// Check if both objects has the same amount of keys
if (aKeys.length !== bKeys.length) {
return true;
}
// Merge keys
const keys = new Set([...aKeys, ...bKeys]);
// Now check if merged keys has the same amount of keys as the other two
// for example: { a, b } and { a, c } produces { a, b, c }
if (keys.size !== aKeys.length) {
return true;
}
// Now compare each items
for (const key of keys) {
// This covers NaN. No need for Object.is since it's extreme for -0
if (a[key] !== b[key] || (a[key] !== a[key] && b[key] !== b[key])) {
return true;
}
}
return false;
}
function isListUpdated(a, b) {
if (a && b) {
return isListUpdatedInternal(a, b);
}
if (a == null && b != null) {
return true;
}
if (a != null && b == null) {
return true;
}
return false;
}
function $$registry() {
return {
components: new Map(),
contexts: new Map(),
};
}
function $$component(registry, id, component, options = {}) {
const [comp, setComp] = createSignal(component, { internal: true });
const proxy = createProxy(comp, id, options.location);
registry.components.set(id, Object.assign({ id,
component,
proxy, update: setComp }, options));
return proxy;
}
function $$context(registry, id, context) {
registry.contexts.set(id, {
id,
context,
});
return context;
}
function patchComponent(oldData, newData) {
var _a, _b;
// Check if incoming module has signature
if (newData.signature) {
// Compare signatures
const oldDeps = (_a = oldData.dependencies) === null || _a === void 0 ? void 0 : _a.call(oldData);
const newDeps = (_b = newData.dependencies) === null || _b === void 0 ? void 0 : _b.call(newData);
if (newData.signature !== oldData.signature ||
isListUpdated(newDeps, oldDeps)) {
// Replace signatures and dependencies
oldData.dependencies = newDeps ? () => newDeps : undefined;
oldData.signature = newData.signature;
// Remount
oldData.update(() => newData.component);
}
}
else {
// No granular update, remount
oldData.update(() => newData.component);
}
// Always rely on the first proxy
// This is to allow modules newly importing
// the updated version to still be able
// to render the latest version despite
// not receiving the first proxy
newData.update(() => oldData.proxy);
}
function patchComponents(oldData, newData) {
const components = new Set([
...oldData.components.keys(),
...newData.components.keys(),
]);
for (const key of components) {
const oldComponent = oldData.components.get(key);
const newComponent = newData.components.get(key);
if (oldComponent) {
if (newComponent) {
patchComponent(oldComponent, newComponent);
}
else {
// We need to invalidate
return true;
}
}
else if (newComponent) {
oldData.components.set(key, newComponent);
}
}
return false;
}
function patchContext(oldData, newData) {
oldData.context.defaultValue = newData.context.defaultValue;
newData.context.id = oldData.context.id;
newData.context.Provider = oldData.context.Provider;
}
function patchContexts(oldData, newData) {
const contexts = new Set([
...oldData.contexts.keys(),
...newData.contexts.keys(),
]);
for (const key of contexts) {
const oldContext = oldData.contexts.get(key);
const newContext = newData.contexts.get(key);
if (oldContext) {
if (newContext) {
patchContext(oldContext, newContext);
}
else {
// We need to invalidate
return true;
}
}
else if (newContext) {
oldData.contexts.set(key, newContext);
}
}
return false;
}
function patchRegistry(oldRegistry, newRegistry) {
const shouldInvalidateByContext = patchContexts(oldRegistry, newRegistry);
const shouldInvalidateByComponents = patchComponents(oldRegistry, newRegistry);
// In the future we may add other HMR features here
return shouldInvalidateByComponents || shouldInvalidateByContext;
}
const SOLID_REFRESH = 'solid-refresh';
const SOLID_REFRESH_PREV = 'solid-refresh-prev';
function $$decline(...[type, hot, inline]) {
switch (type) {
case 'esm': {
// Snowpack's ESM assumes invalidate as a normal page reload
// decline should be better
if (inline) {
hot.invalidate();
}
else {
hot.decline();
}
break;
}
case 'vite': {
// Vite is no-op on decline, just call invalidate
if (inline) {
hot.invalidate();
}
else {
hot.accept(() => {
hot.invalidate();
});
}
break;
}
case 'rspack-esm':
case 'webpack5': {
if (inline) {
hot.invalidate();
}
else {
hot.decline();
}
break;
}
case 'standard': {
// Some implementations do not have decline/invalidate
if (inline) {
if (hot.invalidate) {
hot.invalidate();
}
else {
window.location.reload();
}
}
else if (hot.decline) {
hot.decline();
}
else {
hot.accept(() => {
if (hot.invalidate) {
hot.invalidate();
}
else {
window.location.reload();
}
});
}
break;
}
}
}
let warned = false;
function shouldWarnAndDecline() {
const result = DEV && Object.keys(DEV).length;
if (result) {
return false;
}
if (!warned) {
console.warn("To use solid-refresh, you need to use the dev build of SolidJS. Make sure your build system supports package.json conditional exports and has the 'development' condition turned on.");
warned = true;
}
return true;
}
function $$refreshESM(type, hot, registry) {
if (shouldWarnAndDecline()) {
$$decline(type, hot);
}
else if (hot.data) {
hot.data[SOLID_REFRESH] = hot.data[SOLID_REFRESH] || registry;
hot.data[SOLID_REFRESH_PREV] = registry;
hot.accept(mod => {
if (mod == null ||
patchRegistry(hot.data[SOLID_REFRESH], hot.data[SOLID_REFRESH_PREV])) {
hot.invalidate();
}
});
}
else {
// I guess just decline if hot.data doesn't exist
$$decline(type, hot);
}
}
function $$refreshStandard(type, hot, registry) {
if (shouldWarnAndDecline()) {
$$decline(type, hot);
}
else {
const current = hot.data;
if (current && current[SOLID_REFRESH]) {
if (patchRegistry(current[SOLID_REFRESH], registry)) {
$$decline(type, hot, true);
}
}
hot.dispose((data) => {
data[SOLID_REFRESH] = current ? current[SOLID_REFRESH] : registry;
});
hot.accept();
}
}
function $$refresh(...[type, hot, registry]) {
switch (type) {
case 'esm':
case 'vite': {
$$refreshESM(type, hot, registry);
break;
}
case 'standard':
case 'webpack5':
case 'rspack-esm': {
$$refreshStandard(type, hot, registry);
break;
}
}
}
export { $$component, $$context, $$decline, $$refresh, $$registry };

25
node_modules/solid-refresh/dist/src/babel/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import * as babel from '@babel/core';
import * as t from '@babel/types';
import { RuntimeType } from '../shared/types';
interface Options {
bundler?: RuntimeType;
fixRender?: boolean;
}
type ImportHook = Map<string, t.Identifier>;
interface ImportIdentifiers {
identifiers: Map<t.Identifier, ImportIdentity>;
namespaces: Map<t.Identifier, ImportIdentity>;
}
interface State extends babel.PluginPass {
hooks: ImportHook;
opts: Options;
processed: boolean;
granular: boolean;
imports: ImportIdentifiers;
}
interface ImportIdentity {
name: string;
source: string;
}
export default function solidRefreshPlugin(): babel.PluginObj<State>;
export {};

2
node_modules/solid-refresh/dist/src/babel/utils.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
export declare function forEach<T>(arr: T[], callback: (value: T, index: number) => boolean | void): void;
export declare function map<T, R>(arr: T[], callback: (value: T, index: number) => R): R[];

View File

@@ -0,0 +1,6 @@
/**
*
* @param buffer - byte array or string
* @param seed - optional seed (32-bit unsigned);
*/
export declare function xxHash32(buffer: Uint8Array | string, seed?: number): number;

View File

@@ -0,0 +1,5 @@
import { JSX, Accessor } from 'solid-js';
export interface BaseComponent<P> {
(props: P): JSX.Element;
}
export default function createProxy<C extends BaseComponent<P>, P>(source: Accessor<C>, name: string, location?: string): (props: P) => JSX.Element;

51
node_modules/solid-refresh/dist/src/runtime/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,51 @@
import { Context, JSX } from 'solid-js';
import { ESMRuntimeType, StandardRuntimeType } from '../shared/types';
interface ComponentOptions {
location?: string;
signature?: string;
dependencies?: Record<string, any>;
}
export interface ComponentRegistrationData<P> extends ComponentOptions {
id: string;
component: (props: P) => JSX.Element;
proxy: (props: P) => JSX.Element;
update: (action: () => (props: P) => JSX.Element) => void;
}
export interface ContextRegistrationData<T> {
id: string;
context: Context<T>;
}
export interface Registry {
components: Map<string, ComponentRegistrationData<any>>;
contexts: Map<string, ContextRegistrationData<any>>;
}
export declare function $$registry(): Registry;
export declare function $$component<P>(registry: Registry, id: string, component: (props: P) => JSX.Element, options?: ComponentOptions): (props: P) => JSX.Element;
export declare function $$context<T>(registry: Registry, id: string, context: Context<T>): Context<T>;
declare const SOLID_REFRESH = "solid-refresh";
declare const SOLID_REFRESH_PREV = "solid-refresh-prev";
type HotData = {
[key in typeof SOLID_REFRESH | typeof SOLID_REFRESH_PREV]: Registry;
};
interface ESMHot {
data: HotData;
accept: (cb: (module?: unknown) => void) => void;
invalidate: () => void;
decline: () => void;
}
interface StandardHot {
data: HotData;
accept: (cb?: () => void) => void;
dispose: (cb: (data: HotData) => void) => void;
invalidate?: () => void;
decline?: () => void;
}
type ESMDecline = [type: ESMRuntimeType, hot: ESMHot, inline?: boolean];
type StandardDecline = [type: StandardRuntimeType, hot: StandardHot, inline?: boolean];
type Decline = ESMDecline | StandardDecline;
export declare function $$decline(...[type, hot, inline]: Decline): void;
type ESMRefresh = [type: ESMRuntimeType, hot: ESMHot, registry: Registry];
type StandardRefresh = [type: StandardRuntimeType, hot: StandardHot, registry: Registry];
type Refresh = ESMRefresh | StandardRefresh;
export declare function $$refresh(...[type, hot, registry]: Refresh): void;
export {};

View File

@@ -0,0 +1 @@
export default function isListUpdated(a: Record<string, any> | undefined, b: Record<string, any> | undefined): boolean;

View File

@@ -0,0 +1,3 @@
export type ESMRuntimeType = 'esm' | 'vite';
export type StandardRuntimeType = 'standard' | 'webpack5' | 'rspack-esm';
export type RuntimeType = ESMRuntimeType | StandardRuntimeType;

View File

@@ -0,0 +1,31 @@
import type * as babel from '@babel/core';
import * as t from '@babel/types';
import type { RuntimeType } from '../shared/types';
interface Options {
bundler?: RuntimeType;
fixRender?: boolean;
imports?: ImportIdentity[];
}
type ImportHook = Map<string, t.Identifier>;
interface ImportIdentifiers {
identifiers: Map<t.Identifier, ImportIdentity>;
namespaces: Map<t.Identifier, ImportIdentity[]>;
}
interface State extends babel.PluginPass {
hooks: ImportHook;
opts: Options;
processed: boolean;
granular: boolean;
registrations: ImportIdentifiers;
fixRender?: boolean;
imports: ImportIdentity[];
}
interface ImportIdentity {
name: string;
source: string;
kind: 'named' | 'default';
type: 'createContext' | 'render';
}
export default function solidRefreshPlugin(): babel.PluginObj<State>;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/babel/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,KAAK,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAIlC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAgBnD,UAAU,OAAO;IACf,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,cAAc,EAAE,CAAC;CAC5B;AAED,KAAK,UAAU,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;AAE5C,UAAU,iBAAiB;IACzB,WAAW,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC/C,UAAU,EAAE,GAAG,CAAC,CAAC,CAAC,UAAU,EAAE,cAAc,EAAE,CAAC,CAAC;CACjD;AAED,UAAU,KAAM,SAAQ,KAAK,CAAC,UAAU;IACtC,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,aAAa,EAAE,iBAAiB,CAAC;IACjC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,EAAE,cAAc,EAAE,CAAC;CAC3B;AAuMD,UAAU,cAAc;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;IAC1B,IAAI,EAAE,eAAe,GAAG,QAAQ,CAAC;CAClC;AAocD,MAAM,CAAC,OAAO,UAAU,kBAAkB,IAAI,KAAK,CAAC,SAAS,CAAC,KAAK,CAAC,CAyEnE"}

View File

@@ -0,0 +1,7 @@
/**
*
* @param buffer - byte array or string
* @param seed - optional seed (32-bit unsigned);
*/
export declare function xxHash32(buffer: Uint8Array | string, seed?: number): number;
//# sourceMappingURL=xxhash32.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"xxhash32.d.ts","sourceRoot":"","sources":["../../../src/babel/xxhash32.ts"],"names":[],"mappings":"AAiCA;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,IAAI,SAAI,GAAG,MAAM,CAqKtE"}

View File

@@ -0,0 +1,6 @@
import type { JSX, Accessor } from 'solid-js';
export interface BaseComponent<P> {
(props: P): JSX.Element;
}
export default function createProxy<C extends BaseComponent<P>, P>(source: Accessor<C>, name: string, location?: string): (props: P) => JSX.Element;
//# sourceMappingURL=create-proxy.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"create-proxy.d.ts","sourceRoot":"","sources":["../../../src/runtime/create-proxy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAG9C,MAAM,WAAW,aAAa,CAAC,CAAC;IAC9B,CAAC,KAAK,EAAE,CAAC,GAAG,GAAG,CAAC,OAAO,CAAC;CACzB;AAuBD,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,CAAC,SAAS,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,EAC/D,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,EACnB,IAAI,EAAE,MAAM,EACZ,QAAQ,CAAC,EAAE,MAAM,GAChB,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAuC3B"}

View File

@@ -0,0 +1,60 @@
import type { Context, JSX } from 'solid-js';
import type { ESMRuntimeType, StandardRuntimeType } from '../shared/types';
interface ComponentOptions {
location?: string;
signature?: string;
dependencies?: () => Record<string, any>;
}
export interface ComponentRegistrationData<P> extends ComponentOptions {
id: string;
component: (props: P) => JSX.Element;
proxy: (props: P) => JSX.Element;
update: (action: () => (props: P) => JSX.Element) => void;
}
export interface ContextRegistrationData<T> {
id: string;
context: Context<T>;
}
export interface Registry {
components: Map<string, ComponentRegistrationData<any>>;
contexts: Map<string, ContextRegistrationData<any>>;
}
export declare function $$registry(): Registry;
export declare function $$component<P>(registry: Registry, id: string, component: (props: P) => JSX.Element, options?: ComponentOptions): (props: P) => JSX.Element;
export declare function $$context<T>(registry: Registry, id: string, context: Context<T>): Context<T>;
declare const SOLID_REFRESH = "solid-refresh";
declare const SOLID_REFRESH_PREV = "solid-refresh-prev";
type HotData = {
[key in typeof SOLID_REFRESH | typeof SOLID_REFRESH_PREV]: Registry;
};
interface ESMHot {
data: HotData;
accept: (cb: (module?: unknown) => void) => void;
invalidate: () => void;
decline: () => void;
}
interface StandardHot {
data: HotData;
accept: (cb?: () => void) => void;
dispose: (cb: (data: HotData) => void) => void;
invalidate?: () => void;
decline?: () => void;
}
type ESMDecline = [type: ESMRuntimeType, hot: ESMHot, inline?: boolean];
type StandardDecline = [
type: StandardRuntimeType,
hot: StandardHot,
inline?: boolean
];
type Decline = ESMDecline | StandardDecline;
export declare function $$decline(...[type, hot, inline]: Decline): void;
type ESMRefresh = [type: ESMRuntimeType, hot: ESMHot, registry: Registry];
type StandardRefresh = [
type: StandardRuntimeType,
hot: StandardHot,
registry: Registry
];
type Refresh = ESMRefresh | StandardRefresh;
export declare function $$refresh(...[type, hot, registry]: Refresh): void;
export {};
//# sourceMappingURL=index.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/runtime/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAE7C,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAI3E,UAAU,gBAAgB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAGlB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,YAAY,CAAC,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC1C;AAGD,MAAM,WAAW,yBAAyB,CAAC,CAAC,CAAE,SAAQ,gBAAgB;IAGpE,EAAE,EAAE,MAAM,CAAC;IAEX,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;IACrC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;IAGjC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;CAC3D;AAGD,MAAM,WAAW,uBAAuB,CAAC,CAAC;IAGxC,EAAE,EAAE,MAAM,CAAC;IAEX,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;CACrB;AAED,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,GAAG,CAAC,MAAM,EAAE,yBAAyB,CAAC,GAAG,CAAC,CAAC,CAAC;IACxD,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC;CACrD;AAED,wBAAgB,UAAU,IAAI,QAAQ,CAKrC;AAED,wBAAgB,WAAW,CAAC,CAAC,EAC3B,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,MAAM,EACV,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,EACpC,OAAO,GAAE,gBAAqB,GAC7B,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAe3B;AAED,wBAAgB,SAAS,CAAC,CAAC,EACzB,QAAQ,EAAE,QAAQ,EAClB,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,GAClB,OAAO,CAAC,CAAC,CAAC,CAMZ;AAmGD,QAAA,MAAM,aAAa,kBAAkB,CAAC;AACtC,QAAA,MAAM,kBAAkB,uBAAuB,CAAC;AAEhD,KAAK,OAAO,GAAG;KACZ,GAAG,IAAI,OAAO,aAAa,GAAG,OAAO,kBAAkB,GAAG,QAAQ;CACpE,CAAC;AAEF,UAAU,MAAM;IACd,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;IACjD,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,UAAU,WAAW;IACnB,IAAI,EAAE,OAAO,CAAC;IACd,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,IAAI,KAAK,IAAI,CAAC;IAClC,OAAO,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,KAAK,IAAI,CAAC;IAC/C,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;AACxE,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,mBAAmB;IACzB,GAAG,EAAE,WAAW;IAChB,MAAM,CAAC,EAAE,OAAO;CACjB,CAAC;AACF,KAAK,OAAO,GAAG,UAAU,GAAG,eAAe,CAAC;AAE5C,wBAAgB,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,CAAC,EAAE,OAAO,QAsDxD;AA8DD,KAAK,UAAU,GAAG,CAAC,IAAI,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC1E,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,mBAAmB;IACzB,GAAG,EAAE,WAAW;IAChB,QAAQ,EAAE,QAAQ;CACnB,CAAC;AAEF,KAAK,OAAO,GAAG,UAAU,GAAG,eAAe,CAAC;AAE5C,wBAAgB,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,QAAQ,CAAC,EAAE,OAAO,QAc1D"}

View File

@@ -0,0 +1,2 @@
export default function isListUpdated(a: Record<string, any> | undefined, b: Record<string, any> | undefined): boolean;
//# sourceMappingURL=is-list-updated.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"is-list-updated.d.ts","sourceRoot":"","sources":["../../../src/runtime/is-list-updated.ts"],"names":[],"mappings":"AA2BA,MAAM,CAAC,OAAO,UAAU,aAAa,CACnC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,EAClC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,SAAS,GACjC,OAAO,CAWT"}

View File

@@ -0,0 +1,4 @@
export type ESMRuntimeType = 'esm' | 'vite';
export type StandardRuntimeType = 'standard' | 'webpack5' | 'rspack-esm';
export type RuntimeType = ESMRuntimeType | StandardRuntimeType;
//# sourceMappingURL=types.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,MAAM,CAAC;AAG5C,MAAM,MAAM,mBAAmB,GAAG,UAAU,GAAG,UAAU,GAAG,YAAY,CAAC;AAEzE,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG,mBAAmB,CAAC"}

77
node_modules/solid-refresh/package.json generated vendored Normal file
View File

@@ -0,0 +1,77 @@
{
"name": "solid-refresh",
"type": "module",
"description": "Universal HMR for SolidJS",
"author": "Ryan Carniato",
"license": "MIT",
"version": "0.6.3",
"homepage": "https://github.com/solidjs/solid-refresh#readme",
"repository": {
"type": "git",
"url": "https://github.com/solidjs/solid-refresh"
},
"main": "dist/solid-refresh.cjs",
"module": "dist/solid-refresh.mjs",
"exports": {
".": {
"import": "./dist/solid-refresh.mjs",
"require": "./dist/solid-refresh.cjs",
"default": "./dist/solid-refresh.cjs",
"types": "./dist/src/runtime/index.d.ts"
},
"./babel": {
"import": "./dist/babel.mjs",
"require": "./dist/babel.cjs",
"default": "./dist/babel.cjs",
"types": "./dist/src/babel/index.d.ts"
},
"./dist/*": "./dist/*"
},
"typesVersions": {
"*": {
"babel": [
"./dist/src/babel/index.d.ts"
]
}
},
"files": [
"dist"
],
"publishConfig": {
"access": "public"
},
"contributors": [
"Alexis Munsayac"
],
"sideEffects": false,
"devDependencies": {
"@babel/core": "^7.23.6",
"@biomejs/biome": "^1.5.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-typescript": "^11.1.5",
"@types/babel__core": "^7.20.5",
"@types/babel__generator": "^7.6.8",
"@types/babel__helper-module-imports": "^7.18.3",
"@types/babel__traverse": "^7.20.4",
"@types/node": "^20.10.5",
"babel-preset-solid": "^1.8.9",
"rollup": "^4.9.1",
"solid-js": "^1.8.7",
"tslib": "^2.6.2",
"typescript": "^5.3.3",
"vitest": "^1.1.0"
},
"peerDependencies": {
"solid-js": "^1.3"
},
"dependencies": {
"@babel/generator": "^7.23.6",
"@babel/helper-module-imports": "^7.22.15",
"@babel/types": "^7.23.6"
},
"scripts": {
"build": "rollup -c",
"test": "vitest",
"test:CI": "vitest"
}
}