Criada a API do site
This commit is contained in:
21
node_modules/vite-hot-client/LICENSE
generated
vendored
Normal file
21
node_modules/vite-hot-client/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021 Anthony Fu <https://github.com/antfu>
|
||||
|
||||
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.
|
||||
52
node_modules/vite-hot-client/README.md
generated
vendored
Normal file
52
node_modules/vite-hot-client/README.md
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
# vite-hot-client
|
||||
|
||||
[](https://www.npmjs.com/package/vite-hot-client)
|
||||
|
||||
Get Vite's `import.meta.hot` at runtime.
|
||||
|
||||
**You don't normally need this library directly**. It's designed for embedded UI on top of Vite for client-server communication. For example:
|
||||
|
||||
- [`vite-plugin-inspect`](https://github.com/antfu/vite-plugin-inspect)
|
||||
- [`@unocss/inspector`](https://github.com/unocss/unocss/tree/main/packages/inspector)
|
||||
- [`@vitest/ui`](https://github.com/vitest-dev/vitest/tree/main/packages/ui)
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i vite-hot-client
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { hot } from 'vite-hot-client'
|
||||
|
||||
// import.meta.hot
|
||||
if (hot) {
|
||||
hot.on('update', () => {
|
||||
// ...
|
||||
})
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
import { createHotContext } from 'vite-hot-client'
|
||||
|
||||
const hot = createHotContext('/path/to/module')
|
||||
|
||||
if (hot) {
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/antfu/static/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2022 [Anthony Fu](https://github.com/antfu)
|
||||
20
node_modules/vite-hot-client/dist/index.d.mts
generated
vendored
Normal file
20
node_modules/vite-hot-client/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/// <reference types="vite/client" />
|
||||
type ViteHotContext = Exclude<ImportMeta['hot'], undefined>;
|
||||
interface ViteClient {
|
||||
createHotContext: (path: string) => ViteHotContext;
|
||||
}
|
||||
/**
|
||||
* Get the module of `/@vite/client`
|
||||
*/
|
||||
declare function getViteClient(base?: string, warning?: boolean): Promise<ViteClient | undefined>;
|
||||
declare function createHotContext(path?: string, base?: string): Promise<ViteHotContext | undefined>;
|
||||
/**
|
||||
* Guess the vite client provided bases from the current pathname.
|
||||
*/
|
||||
declare function guessBasesFromPathname(pathname?: string): string[];
|
||||
/**
|
||||
* Try to resolve the vite client provided bases.
|
||||
*/
|
||||
declare function tryCreateHotContext(path?: string, bases?: string[]): Promise<ViteHotContext | undefined>;
|
||||
|
||||
export { type ViteClient, type ViteHotContext, createHotContext, getViteClient, guessBasesFromPathname, tryCreateHotContext };
|
||||
20
node_modules/vite-hot-client/dist/index.d.ts
generated
vendored
Normal file
20
node_modules/vite-hot-client/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/// <reference types="vite/client" />
|
||||
type ViteHotContext = Exclude<ImportMeta['hot'], undefined>;
|
||||
interface ViteClient {
|
||||
createHotContext: (path: string) => ViteHotContext;
|
||||
}
|
||||
/**
|
||||
* Get the module of `/@vite/client`
|
||||
*/
|
||||
declare function getViteClient(base?: string, warning?: boolean): Promise<ViteClient | undefined>;
|
||||
declare function createHotContext(path?: string, base?: string): Promise<ViteHotContext | undefined>;
|
||||
/**
|
||||
* Guess the vite client provided bases from the current pathname.
|
||||
*/
|
||||
declare function guessBasesFromPathname(pathname?: string): string[];
|
||||
/**
|
||||
* Try to resolve the vite client provided bases.
|
||||
*/
|
||||
declare function tryCreateHotContext(path?: string, bases?: string[]): Promise<ViteHotContext | undefined>;
|
||||
|
||||
export { type ViteClient, type ViteHotContext, createHotContext, getViteClient, guessBasesFromPathname, tryCreateHotContext };
|
||||
36
node_modules/vite-hot-client/dist/index.mjs
generated
vendored
Normal file
36
node_modules/vite-hot-client/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
async function getViteClient(base = "/", warning = true) {
|
||||
try {
|
||||
const url = `${base}@vite/client`;
|
||||
const res = await fetch(url);
|
||||
const text = await res.text();
|
||||
if (text.startsWith("<") || !res.headers.get("content-type")?.includes("javascript"))
|
||||
throw new Error("Not javascript");
|
||||
return await import(
|
||||
/* @vite-ignore */
|
||||
url
|
||||
);
|
||||
} catch {
|
||||
if (warning)
|
||||
console.error(`[vite-hot-client] Failed to import "${base}@vite/client"`);
|
||||
}
|
||||
return void 0;
|
||||
}
|
||||
async function createHotContext(path = "/____", base = "/") {
|
||||
const viteClient = await getViteClient(base);
|
||||
return viteClient?.createHotContext(path);
|
||||
}
|
||||
function guessBasesFromPathname(pathname = window.location.pathname) {
|
||||
return pathname.split("/").map((i, idx, arr) => arr.slice(0, idx + 1).join("/") || "/");
|
||||
}
|
||||
async function tryCreateHotContext(path = "/___", bases) {
|
||||
bases = bases ?? guessBasesFromPathname();
|
||||
for (const base of bases) {
|
||||
const viteClient = await getViteClient(base, false);
|
||||
const hot = viteClient?.createHotContext(path);
|
||||
if (hot)
|
||||
return hot;
|
||||
}
|
||||
console.error("[vite-hot-client] Failed to import vite client, tried with:", bases);
|
||||
}
|
||||
|
||||
export { createHotContext, getViteClient, guessBasesFromPathname, tryCreateHotContext };
|
||||
55
node_modules/vite-hot-client/package.json
generated
vendored
Normal file
55
node_modules/vite-hot-client/package.json
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
"name": "vite-hot-client",
|
||||
"type": "module",
|
||||
"version": "2.1.0",
|
||||
"description": "Get Vite's import.meta.hot at runtime.",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"license": "MIT",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"homepage": "https://github.com/antfu/vite-hot-client#readme",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/antfu/vite-hot-client.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/antfu/vite-hot-client/issues"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/index.d.ts",
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"vite": "^2.6.0 || ^3.0.0 || ^4.0.0 || ^5.0.0-0 || ^6.0.0-0 || ^7.0.0-0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^4.16.1",
|
||||
"@antfu/ni": "^25.0.0",
|
||||
"@babel/types": "^7.27.7",
|
||||
"@types/node": "^24.0.7",
|
||||
"bumpp": "^10.2.0",
|
||||
"eslint": "^9.30.0",
|
||||
"pnpm": "^10.12.4",
|
||||
"rimraf": "^6.0.1",
|
||||
"tsx": "^4.20.3",
|
||||
"typescript": "^5.8.3",
|
||||
"unbuild": "^3.5.0",
|
||||
"vite": "^7.0.0",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf dist && unbuild && tsx scripts/patch-types.ts",
|
||||
"dev": "unbuild --stub",
|
||||
"lint": "eslint .",
|
||||
"release": "bumpp && pnpm publish",
|
||||
"typecheck": "tsc --noEmit"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user