feat: init
This commit is contained in:
21
node_modules/unimport/LICENSE
generated
vendored
Normal file
21
node_modules/unimport/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2022 - UnJS
|
||||
|
||||
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.
|
||||
450
node_modules/unimport/README.md
generated
vendored
Normal file
450
node_modules/unimport/README.md
generated
vendored
Normal file
@@ -0,0 +1,450 @@
|
||||
# unimport
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![Codecov][codecov-src]][codecov-href]
|
||||
|
||||
> Unified utils for auto importing APIs in modules, used in [nuxt](https://github.com/nuxt/nuxt) and [unplugin-auto-import](https://github.com/antfu/unplugin-auto-import)
|
||||
|
||||
## Features
|
||||
|
||||
- Auto import register APIs for Vite, Webpack or esbuild powered by [unplugin](https://github.com/unjs/unplugin)
|
||||
- TypeScript declaration file generation
|
||||
- Auto import for custom APIs defined under specific directories
|
||||
- Auto import for Vue template
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
# npm
|
||||
npm install unimport
|
||||
|
||||
# yarn
|
||||
yarn add unimport
|
||||
|
||||
# pnpm
|
||||
pnpm install unimport
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### Plugin Usage
|
||||
|
||||
Powered by [unplugin](https://github.com/unjs/unplugin), `unimport` provides a plugin interface for bundlers.
|
||||
|
||||
#### Vite / Rollup
|
||||
|
||||
```ts
|
||||
// vite.config.js / rollup.config.js
|
||||
import Unimport from 'unimport/unplugin'
|
||||
|
||||
export default {
|
||||
plugins: [
|
||||
Unimport.vite({ /* plugin options */ })
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
#### Webpack
|
||||
|
||||
```ts
|
||||
// webpack.config.js
|
||||
import Unimport from 'unimport/unplugin'
|
||||
|
||||
module.exports = {
|
||||
plugins: [
|
||||
Unimport.webpack({ /* plugin options */ })
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### Programmatic Usage
|
||||
|
||||
<!-- eslint-skip -->
|
||||
|
||||
```js
|
||||
// ESM
|
||||
import { createUnimport } from 'unimport'
|
||||
|
||||
// CommonJS
|
||||
const { createUnimport } = require('unimport')
|
||||
```
|
||||
|
||||
```js
|
||||
const { injectImports } = createUnimport({
|
||||
imports: [{ name: 'fooBar', from: 'test-id' }]
|
||||
})
|
||||
|
||||
// { code: "import { fooBar } from 'test-id';console.log(fooBar())" }
|
||||
console.log(injectImports('console.log(fooBar())'))
|
||||
```
|
||||
|
||||
## Configurations
|
||||
|
||||
### Imports Item
|
||||
|
||||
###### Named import
|
||||
|
||||
```ts
|
||||
imports: [
|
||||
{ name: 'ref', from: 'vue' },
|
||||
{ name: 'useState', as: 'useSignal', from: 'react' },
|
||||
]
|
||||
```
|
||||
|
||||
Will be injected as:
|
||||
|
||||
```ts
|
||||
import { useState as useSignal } from 'react'
|
||||
import { ref } from 'vue'
|
||||
```
|
||||
|
||||
###### Default import
|
||||
|
||||
```ts
|
||||
imports: [
|
||||
{ name: 'default', as: '_', from: 'lodash' }
|
||||
]
|
||||
```
|
||||
|
||||
Will be injected as:
|
||||
|
||||
```ts
|
||||
import _ from 'lodash'
|
||||
```
|
||||
|
||||
###### Namespace import
|
||||
|
||||
```ts
|
||||
imports: [
|
||||
{ name: '*', as: '_', from: 'lodash' }
|
||||
]
|
||||
```
|
||||
|
||||
Will be injected as:
|
||||
|
||||
```ts
|
||||
import * as _ from 'lodash'
|
||||
```
|
||||
|
||||
###### Export assignment import
|
||||
|
||||
This is a special case for libraries authored with [TypeScript's `export =` syntax](https://www.typescriptlang.org/docs/handbook/modules/reference.html#export--and-import--require). You don't need it the most of the time.
|
||||
|
||||
```ts
|
||||
imports: [
|
||||
{ name: '=', as: 'browser', from: 'webextension-polyfill' }
|
||||
]
|
||||
```
|
||||
|
||||
Will be injected as:
|
||||
|
||||
```ts
|
||||
import browser from 'webextension-polyfill'
|
||||
```
|
||||
|
||||
And the type declaration will be added as:
|
||||
|
||||
```ts
|
||||
const browser: typeof import('webextension-polyfill')
|
||||
```
|
||||
|
||||
###### Custom Presets
|
||||
|
||||
Presets are provided as a shorthand for declaring imports from the same package:
|
||||
|
||||
```ts
|
||||
presets: [
|
||||
{
|
||||
from: 'vue',
|
||||
imports: [
|
||||
'ref',
|
||||
'reactive',
|
||||
// ...
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
Will be equivalent as:
|
||||
|
||||
```ts
|
||||
imports: [
|
||||
{ name: 'ref', from: 'vue' },
|
||||
{ name: 'reactive', from: 'vue' },
|
||||
// ...
|
||||
]
|
||||
```
|
||||
|
||||
###### Built-in Presets
|
||||
|
||||
`unimport` also provides some built-in presets for common libraries:
|
||||
|
||||
```ts
|
||||
presets: [
|
||||
'vue',
|
||||
'pinia',
|
||||
'vue-i18n',
|
||||
// ...
|
||||
]
|
||||
```
|
||||
|
||||
You can check out [`src/presets`](./src/presets/) for all the options available or refer to the type declaration.
|
||||
|
||||
###### Exports Auto Scan
|
||||
|
||||
Since `unimport` v0.7.0, we also support auto scanning the examples from a local installed package, for example:
|
||||
|
||||
```ts
|
||||
presets: [
|
||||
{
|
||||
package: 'h3',
|
||||
ignore: ['isStream', /^[A-Z]/, /^[a-z]*$/, r => r.length > 8]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
This will be expanded into:
|
||||
|
||||
```ts
|
||||
imports: [
|
||||
{
|
||||
from: 'h3',
|
||||
name: 'appendHeader',
|
||||
},
|
||||
{
|
||||
from: 'h3',
|
||||
name: 'appendHeaders',
|
||||
},
|
||||
{
|
||||
from: 'h3',
|
||||
name: 'appendResponseHeader',
|
||||
},
|
||||
// ...
|
||||
]
|
||||
```
|
||||
|
||||
The `ignore` option is used to filter out the exports, it can be a string, regex or a function that returns a boolean.
|
||||
|
||||
By default, the result is strongly cached by the version of the package. You can disable this by setting `cache: false`.
|
||||
|
||||
### Type Declarations
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
dts: true // or a path to generated file
|
||||
})
|
||||
```
|
||||
|
||||
### Directory Auto Import
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
dirs: [
|
||||
'./composables/*',
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
Scan for modules under `./composables` and auto-import the named exports.
|
||||
|
||||
#### Nested Directories
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
dirs: [
|
||||
'./composables/**/*',
|
||||
{
|
||||
glob: './composables/nested/**/*',
|
||||
types: false // disable scan the type declarations
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
Named exports for modules under `./composables/**/*` will be registered for auto imports, and filter out the types in `./composables/nested/**/*`.
|
||||
|
||||
#### Directory Scan Options
|
||||
|
||||
You can also provide custom options for directory scan, for example:
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
dirsScanOptions: {
|
||||
filePatterns: ['*.ts'], // optional, default `['*.{ts,js,mjs,cjs,mts,cts}']`, glob patterns for matching files
|
||||
fileFilter: file => file.endsWith('.ts'), // optional, default `() => true`, filter files
|
||||
types: true, // optional, default `true`, enable/disable scan the type declarations
|
||||
cwd: process.cwd(), // optional, default `process.cwd()`, custom cwd for directory scan
|
||||
},
|
||||
dirs: [
|
||||
'./composables/**/*',
|
||||
{
|
||||
glob: './composables/nested/**/*',
|
||||
types: false
|
||||
}
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
### Opt-out Auto Import
|
||||
|
||||
You can opt-out auto-import for specific modules by adding a comment:
|
||||
|
||||
```ts
|
||||
// @unimport-disable
|
||||
```
|
||||
|
||||
It can be customized by setting `commentsDisable`:
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
commentsDisable: [
|
||||
'@unimport-disable',
|
||||
'@custom-imports-disable',
|
||||
]
|
||||
})
|
||||
```
|
||||
|
||||
### Acorn Parser
|
||||
|
||||
By default, `unimport` uses RegExp to detect unimport entries. In some cases, RegExp might not be able to detect all the entries (false positive & false negative).
|
||||
|
||||
We introduced a new AST-based parser powered by [acorn](https://github.com/acornjs/acorn), providing a more accurate result. The limitation is when using Acorn, it assumes all input code are valid and vanilla JavaScript code.
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
parser: 'acorn'
|
||||
})
|
||||
```
|
||||
|
||||
### Vue Template Auto Import
|
||||
|
||||
In Vue's template, the usage of API is in a different context than plain modules. Thus some custom transformations are required. To enable it, set `addons.vueTemplate` to `true`:
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
addons: {
|
||||
vueTemplate: true
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Caveats
|
||||
|
||||
When auto-import a ref, inline operations won't be auto-unwrapped.
|
||||
|
||||
```ts
|
||||
export const counter = ref(0)
|
||||
```
|
||||
|
||||
```html
|
||||
<template>
|
||||
<!-- this is ok -->
|
||||
<div>{{ counter }}</div>
|
||||
|
||||
<!-- counter here is a ref, this won't work, volar will throw -->
|
||||
<div>{{ counter + 1 }}</div>
|
||||
|
||||
<!-- use this instead -->
|
||||
<div>{{ counter.value + 1 }}</div>
|
||||
</template>
|
||||
```
|
||||
|
||||
We recommend using [Volar](https://github.com/johnsoncodehk/volar) for type checking, which will help you to identify the misusage.
|
||||
|
||||
### Vue Directives Auto Import and TypeScript Declaration Generation
|
||||
|
||||
In Vue's template, the usage of directives is in a different context than plain modules. Thus some custom transformations are required. To enable it, set `addons.vueDirectives` to `true`:
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
addons: {
|
||||
vueDirectives: true
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
#### Library Authors
|
||||
|
||||
When including directives in your presets, you should:
|
||||
- provide the corresponding imports with `meta.vueDirective` set to `true`, otherwise, `unimport` will not be able to detect your directives.
|
||||
- use named exports for your directives, or use default export and use `as` in the Import.
|
||||
- set `dtsDisabled` to `true` if you provide a type declaration for your directives.
|
||||
|
||||
```ts
|
||||
import type { InlinePreset } from 'unimport'
|
||||
import { defineUnimportPreset } from 'unimport'
|
||||
|
||||
export const composables = defineUnimportPreset({
|
||||
from: 'my-unimport-library/composables',
|
||||
/* imports and other options */
|
||||
})
|
||||
|
||||
export const directives = defineUnimportPreset({
|
||||
from: 'my-unimport-library/directives',
|
||||
// disable dts generation globally
|
||||
dtsEnabled: false,
|
||||
// you can declare the vue directive globally
|
||||
meta: {
|
||||
vueDirective: true
|
||||
},
|
||||
imports: [{
|
||||
name: 'ClickOutside',
|
||||
// disable dts generation per import
|
||||
dtsEnabled: false,
|
||||
// you can declare the vue directive per import
|
||||
meta: {
|
||||
vueDirective: true
|
||||
}
|
||||
}, {
|
||||
name: 'default',
|
||||
// you should declare `as` for default exports
|
||||
as: 'Focus'
|
||||
}]
|
||||
})
|
||||
```
|
||||
|
||||
#### Using Directory Scan and Local Directives
|
||||
|
||||
If you add a directory scan for your local directives in the project, you need to:
|
||||
- provide `isDirective` in the `vueDirectives`: `unimport` will use it to detect them (will never be called for imports with `meta.vueDirective` set to `true`).
|
||||
- use always named exports for your directives.
|
||||
|
||||
```ts
|
||||
Unimport.vite({
|
||||
dirs: ['./directives/**'],
|
||||
addons: {
|
||||
vueDirectives: {
|
||||
isDirective: (normalizedImportFrom, _importEntry) => {
|
||||
return normalizedImportFrom.includes('/directives/')
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
```
|
||||
|
||||
## 💻 Development
|
||||
|
||||
- Clone this repository
|
||||
- Enable [Corepack](https://github.com/nodejs/corepack) using `corepack enable` (use `npm i -g corepack` for Node.js < 16.10)
|
||||
- Install dependencies using `pnpm install`
|
||||
- Run interactive tests using `pnpm dev`
|
||||
|
||||
## License
|
||||
|
||||
Made with 💛
|
||||
|
||||
Published under [MIT License](./LICENSE).
|
||||
|
||||
<!-- Badges -->
|
||||
[npm-version-src]: https://img.shields.io/npm/v/unimport?style=flat-square
|
||||
[npm-version-href]: https://npmjs.com/package/unimport
|
||||
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/unimport?style=flat-square
|
||||
[npm-downloads-href]: https://npmjs.com/package/unimport
|
||||
|
||||
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/unimport/ci/main?style=flat-square
|
||||
[github-actions-href]: https://github.com/unjs/unimport/actions?query=workflow%3Aci
|
||||
|
||||
[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/unimport/main?style=flat-square
|
||||
[codecov-href]: https://codecov.io/gh/unjs/unimport
|
||||
8
node_modules/unimport/dist/addons.d.mts
generated
vendored
Normal file
8
node_modules/unimport/dist/addons.d.mts
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
import { o as AddonVueDirectivesOptions, s as Addon } from './shared/unimport.C0UbTDPO.mjs';
|
||||
export { v as vueTemplateAddon } from './shared/unimport.C9weIfOZ.mjs';
|
||||
import 'magic-string';
|
||||
import 'mlly';
|
||||
|
||||
declare function vueDirectivesAddon(options?: AddonVueDirectivesOptions): Addon;
|
||||
|
||||
export { vueDirectivesAddon };
|
||||
8
node_modules/unimport/dist/addons.mjs
generated
vendored
Normal file
8
node_modules/unimport/dist/addons.mjs
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export { v as vueDirectivesAddon, a as vueTemplateAddon } from './shared/unimport.CWY7iHFZ.mjs';
|
||||
import 'node:path';
|
||||
import 'node:process';
|
||||
import 'pathe';
|
||||
import 'scule';
|
||||
import 'magic-string';
|
||||
import 'mlly';
|
||||
import 'strip-literal';
|
||||
244
node_modules/unimport/dist/chunks/detect-acorn.mjs
generated
vendored
Normal file
244
node_modules/unimport/dist/chunks/detect-acorn.mjs
generated
vendored
Normal file
@@ -0,0 +1,244 @@
|
||||
import { parse } from 'acorn';
|
||||
import { walk } from 'estree-walker';
|
||||
import { n as getMagicString } from '../shared/unimport.CWY7iHFZ.mjs';
|
||||
import 'node:path';
|
||||
import 'node:process';
|
||||
import 'pathe';
|
||||
import 'scule';
|
||||
import 'magic-string';
|
||||
import 'mlly';
|
||||
import 'strip-literal';
|
||||
|
||||
async function detectImportsAcorn(code, ctx, options) {
|
||||
const s = getMagicString(code);
|
||||
const map = await ctx.getImportMap();
|
||||
let matchedImports = [];
|
||||
const enableAutoImport = options?.autoImport !== false;
|
||||
const enableTransformVirtualImports = options?.transformVirtualImports !== false && ctx.options.virtualImports?.length;
|
||||
if (enableAutoImport || enableTransformVirtualImports) {
|
||||
const ast = parse(s.original, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true
|
||||
});
|
||||
const virtualImports = createVirtualImportsAcronWalker(map, ctx.options.virtualImports);
|
||||
const scopes = traveseScopes(
|
||||
ast,
|
||||
enableTransformVirtualImports ? virtualImports.walk : {}
|
||||
);
|
||||
if (enableAutoImport) {
|
||||
const identifiers = scopes.unmatched;
|
||||
matchedImports.push(
|
||||
...Array.from(identifiers).map((name) => {
|
||||
const item = map.get(name);
|
||||
if (item && !item.disabled)
|
||||
return item;
|
||||
return null;
|
||||
}).filter(Boolean)
|
||||
);
|
||||
for (const addon of ctx.addons)
|
||||
matchedImports = await addon.matchImports?.call(ctx, identifiers, matchedImports) || matchedImports;
|
||||
}
|
||||
virtualImports.ranges.forEach(([start, end]) => {
|
||||
s.remove(start, end);
|
||||
});
|
||||
matchedImports.push(...virtualImports.imports);
|
||||
}
|
||||
return {
|
||||
s,
|
||||
strippedCode: code.toString(),
|
||||
matchedImports,
|
||||
isCJSContext: false,
|
||||
firstOccurrence: 0
|
||||
// TODO:
|
||||
};
|
||||
}
|
||||
function traveseScopes(ast, additionalWalk) {
|
||||
const scopes = [];
|
||||
let scopeCurrent = void 0;
|
||||
const scopesStack = [];
|
||||
function pushScope(node) {
|
||||
scopeCurrent = {
|
||||
node,
|
||||
parent: scopeCurrent,
|
||||
declarations: /* @__PURE__ */ new Set(),
|
||||
references: /* @__PURE__ */ new Set()
|
||||
};
|
||||
scopes.push(scopeCurrent);
|
||||
scopesStack.push(scopeCurrent);
|
||||
}
|
||||
function popScope(node) {
|
||||
const scope = scopesStack.pop();
|
||||
if (scope?.node !== node)
|
||||
throw new Error("Scope mismatch");
|
||||
scopeCurrent = scopesStack[scopesStack.length - 1];
|
||||
}
|
||||
pushScope(void 0);
|
||||
walk(ast, {
|
||||
enter(node, parent, prop, index) {
|
||||
additionalWalk?.enter?.call(this, node, parent, prop, index);
|
||||
switch (node.type) {
|
||||
// ====== Declaration ======
|
||||
case "ImportSpecifier":
|
||||
case "ImportDefaultSpecifier":
|
||||
case "ImportNamespaceSpecifier":
|
||||
scopeCurrent.declarations.add(node.local.name);
|
||||
return;
|
||||
case "FunctionDeclaration":
|
||||
case "ClassDeclaration":
|
||||
if (node.id)
|
||||
scopeCurrent.declarations.add(node.id.name);
|
||||
return;
|
||||
case "VariableDeclarator":
|
||||
if (node.id.type === "Identifier") {
|
||||
scopeCurrent.declarations.add(node.id.name);
|
||||
} else {
|
||||
walk(node.id, {
|
||||
enter(node2) {
|
||||
if (node2.type === "ObjectPattern") {
|
||||
node2.properties.forEach((i) => {
|
||||
if (i.type === "Property" && i.value.type === "Identifier")
|
||||
scopeCurrent.declarations.add(i.value.name);
|
||||
else if (i.type === "RestElement" && i.argument.type === "Identifier")
|
||||
scopeCurrent.declarations.add(i.argument.name);
|
||||
});
|
||||
} else if (node2.type === "ArrayPattern") {
|
||||
node2.elements.forEach((i) => {
|
||||
if (i?.type === "Identifier")
|
||||
scopeCurrent.declarations.add(i.name);
|
||||
if (i?.type === "RestElement" && i.argument.type === "Identifier")
|
||||
scopeCurrent.declarations.add(i.argument.name);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return;
|
||||
// ====== Scope ======
|
||||
case "BlockStatement":
|
||||
switch (parent?.type) {
|
||||
// for a function body scope, take the function parameters as declarations
|
||||
case "FunctionDeclaration":
|
||||
// e.g. function foo(p1, p2) { ... }
|
||||
case "ArrowFunctionExpression":
|
||||
// e.g. (p1, p2) => { ... }
|
||||
case "FunctionExpression": {
|
||||
const parameterIdentifiers = parent.params.filter((p) => p.type === "Identifier");
|
||||
for (const id of parameterIdentifiers) {
|
||||
scopeCurrent.declarations.add(id.name);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
pushScope(node);
|
||||
return;
|
||||
// ====== Reference ======
|
||||
case "Identifier":
|
||||
switch (parent?.type) {
|
||||
case "CallExpression":
|
||||
if (parent.callee === node || parent.arguments.includes(node))
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "MemberExpression":
|
||||
if (parent.object === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "VariableDeclarator":
|
||||
if (parent.init === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "SpreadElement":
|
||||
if (parent.argument === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "ClassDeclaration":
|
||||
if (parent.superClass === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "Property":
|
||||
if (parent.value === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "TemplateLiteral":
|
||||
if (parent.expressions.includes(node))
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "AssignmentExpression":
|
||||
if (parent.right === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "IfStatement":
|
||||
case "WhileStatement":
|
||||
case "DoWhileStatement":
|
||||
if (parent.test === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
case "SwitchStatement":
|
||||
if (parent.discriminant === node)
|
||||
scopeCurrent.references.add(node.name);
|
||||
return;
|
||||
}
|
||||
if (parent?.type.includes("Expression"))
|
||||
scopeCurrent.references.add(node.name);
|
||||
}
|
||||
},
|
||||
leave(node, parent, prop, index) {
|
||||
additionalWalk?.leave?.call(this, node, parent, prop, index);
|
||||
switch (node.type) {
|
||||
case "BlockStatement":
|
||||
popScope(node);
|
||||
}
|
||||
}
|
||||
});
|
||||
const unmatched = /* @__PURE__ */ new Set();
|
||||
for (const scope of scopes) {
|
||||
for (const name of scope.references) {
|
||||
let defined = false;
|
||||
let parent = scope;
|
||||
while (parent) {
|
||||
if (parent.declarations.has(name)) {
|
||||
defined = true;
|
||||
break;
|
||||
}
|
||||
parent = parent?.parent;
|
||||
}
|
||||
if (!defined)
|
||||
unmatched.add(name);
|
||||
}
|
||||
}
|
||||
return {
|
||||
unmatched,
|
||||
scopes
|
||||
};
|
||||
}
|
||||
function createVirtualImportsAcronWalker(importMap, virtualImports = []) {
|
||||
const imports = [];
|
||||
const ranges = [];
|
||||
return {
|
||||
imports,
|
||||
ranges,
|
||||
walk: {
|
||||
enter(node) {
|
||||
if (node.type === "ImportDeclaration") {
|
||||
if (virtualImports.includes(node.source.value)) {
|
||||
ranges.push([node.start, node.end]);
|
||||
node.specifiers.forEach((i) => {
|
||||
if (i.type === "ImportSpecifier" && i.imported.type === "Identifier") {
|
||||
const original = importMap.get(i.imported.name);
|
||||
if (!original)
|
||||
throw new Error(`[unimport] failed to find "${i.imported.name}" imported from "${node.source.value}"`);
|
||||
imports.push({
|
||||
from: original.from,
|
||||
name: original.name,
|
||||
as: i.local.name
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export { createVirtualImportsAcronWalker, detectImportsAcorn, traveseScopes };
|
||||
52
node_modules/unimport/dist/index.d.mts
generated
vendored
Normal file
52
node_modules/unimport/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
export { v as vueTemplateAddon } from './shared/unimport.C9weIfOZ.mjs';
|
||||
import { U as UnimportOptions, a as Unimport, I as Import, b as InstallGlobalOptions, S as ScanDir, c as ScanDirExportsOptions, B as BuiltinPresetName, P as Preset, d as InlinePreset, T as ToExportsOptions, e as TypeDeclarationOptions, M as MagicStringResult } from './shared/unimport.C0UbTDPO.mjs';
|
||||
export { s as Addon, o as AddonVueDirectivesOptions, A as AddonsOptions, D as DetectImportResult, i as ImportCommon, t as ImportInjectionResult, h as ImportName, q as InjectImportsOptions, m as InjectionUsageRecord, g as ModuleId, k as PackagePreset, p as PathFromResolver, j as PresetImport, r as Thenable, l as UnimportContext, n as UnimportMeta, f as builtinPresets } from './shared/unimport.C0UbTDPO.mjs';
|
||||
import { StripLiteralOptions } from 'strip-literal';
|
||||
import MagicString from 'magic-string';
|
||||
import 'mlly';
|
||||
|
||||
declare let version: string;
|
||||
|
||||
declare function createUnimport(opts: Partial<UnimportOptions>): Unimport;
|
||||
|
||||
declare function installGlobalAutoImports(imports: Import[] | Unimport, options?: InstallGlobalOptions): Promise<any>;
|
||||
|
||||
declare function normalizeScanDirs(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Required<ScanDir>[];
|
||||
declare function scanFilesFromDir(dir: ScanDir | ScanDir[], options?: ScanDirExportsOptions): Promise<string[]>;
|
||||
declare function scanDirExports(dirs: (string | ScanDir)[], options?: ScanDirExportsOptions): Promise<Import[]>;
|
||||
declare function dedupeDtsExports(exports: Import[]): Import[];
|
||||
declare function scanExports(filepath: string, includeTypes: boolean, seen?: Set<string>): Promise<Import[]>;
|
||||
|
||||
declare function resolvePreset(preset: Preset): Promise<Import[]>;
|
||||
declare function resolveBuiltinPresets(presets: (BuiltinPresetName | Preset)[]): Promise<Import[]>;
|
||||
|
||||
declare const excludeRE: RegExp[];
|
||||
declare const importAsRE: RegExp;
|
||||
declare const separatorRE: RegExp;
|
||||
/**
|
||||
* | |
|
||||
* destructing case&ternary non-call inheritance | id |
|
||||
* ↓ ↓ ↓ ↓ | |
|
||||
*/
|
||||
declare const matchRE: RegExp;
|
||||
declare function stripCommentsAndStrings(code: string, options?: StripLiteralOptions): string;
|
||||
|
||||
declare function defineUnimportPreset(preset: InlinePreset): InlinePreset;
|
||||
declare function stringifyImports(imports: Import[], isCJS?: boolean): string;
|
||||
declare function dedupeImports(imports: Import[], warn: (msg: string) => void): Import[];
|
||||
declare function toExports(imports: Import[], fileDir?: string, includeType?: boolean, options?: ToExportsOptions): string;
|
||||
declare function stripFileExtension(path: string): string;
|
||||
declare function toTypeDeclarationItems(imports: Import[], options?: TypeDeclarationOptions): string[];
|
||||
declare function toTypeDeclarationFile(imports: Import[], options?: TypeDeclarationOptions): string;
|
||||
declare function toTypeReExports(imports: Import[], options?: TypeDeclarationOptions): string;
|
||||
declare function getString(code: string | MagicString): string;
|
||||
declare function getMagicString(code: string | MagicString): MagicString;
|
||||
declare function addImportToCode(code: string | MagicString, imports: Import[], isCJS?: boolean, mergeExisting?: boolean, injectAtLast?: boolean, firstOccurrence?: number, onResolved?: (imports: Import[]) => void | Import[], onStringified?: (str: string, imports: Import[]) => void | string): MagicStringResult;
|
||||
declare function normalizeImports(imports: Import[]): Import[];
|
||||
declare function resolveIdAbsolute(id: string, parentId?: string): string;
|
||||
/**
|
||||
* @deprecated renamed to `stringifyImports`
|
||||
*/
|
||||
declare const toImports: typeof stringifyImports;
|
||||
|
||||
export { BuiltinPresetName, Import, InlinePreset, InstallGlobalOptions, MagicStringResult, Preset, ScanDir, ScanDirExportsOptions, ToExportsOptions, TypeDeclarationOptions, Unimport, UnimportOptions, addImportToCode, createUnimport, dedupeDtsExports, dedupeImports, defineUnimportPreset, excludeRE, getMagicString, getString, importAsRE, installGlobalAutoImports, matchRE, normalizeImports, normalizeScanDirs, resolveBuiltinPresets, resolveIdAbsolute, resolvePreset, scanDirExports, scanExports, scanFilesFromDir, separatorRE, stringifyImports, stripCommentsAndStrings, stripFileExtension, toExports, toImports, toTypeDeclarationFile, toTypeDeclarationItems, toTypeReExports, version };
|
||||
39
node_modules/unimport/dist/index.mjs
generated
vendored
Normal file
39
node_modules/unimport/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
export { b as builtinPresets, c as createUnimport, e as dedupeDtsExports, n as normalizeScanDirs, r as resolveBuiltinPresets, a as resolvePreset, d as scanDirExports, f as scanExports, s as scanFilesFromDir, v as version } from './shared/unimport.u_OYhQoS.mjs';
|
||||
export { o as addImportToCode, f as dedupeImports, d as defineUnimportPreset, e as excludeRE, n as getMagicString, l as getString, i as importAsRE, m as matchRE, p as normalizeImports, r as resolveIdAbsolute, s as separatorRE, c as stringifyImports, b as stripCommentsAndStrings, g as stripFileExtension, t as toExports, q as toImports, j as toTypeDeclarationFile, h as toTypeDeclarationItems, k as toTypeReExports, a as vueTemplateAddon } from './shared/unimport.CWY7iHFZ.mjs';
|
||||
import 'mlly';
|
||||
import 'node:fs';
|
||||
import 'node:fs/promises';
|
||||
import 'node:process';
|
||||
import 'node:url';
|
||||
import 'pathe';
|
||||
import 'picomatch';
|
||||
import 'scule';
|
||||
import 'tinyglobby';
|
||||
import 'node:os';
|
||||
import 'pkg-types';
|
||||
import 'local-pkg';
|
||||
import 'node:path';
|
||||
import 'magic-string';
|
||||
import 'strip-literal';
|
||||
|
||||
async function installGlobalAutoImports(imports, options = {}) {
|
||||
const {
|
||||
globalObject = globalThis,
|
||||
overrides = false
|
||||
} = options;
|
||||
imports = Array.isArray(imports) ? imports : await imports.getImports();
|
||||
await Promise.all(
|
||||
imports.map(async (i) => {
|
||||
if (i.disabled || i.type)
|
||||
return;
|
||||
const as = i.as || i.name;
|
||||
if (overrides || !(as in globalObject)) {
|
||||
const module = await import(i.from);
|
||||
globalObject[as] = module[i.name];
|
||||
}
|
||||
})
|
||||
);
|
||||
return globalObject;
|
||||
}
|
||||
|
||||
export { installGlobalAutoImports };
|
||||
408
node_modules/unimport/dist/shared/unimport.C0UbTDPO.d.mts
generated
vendored
Normal file
408
node_modules/unimport/dist/shared/unimport.C0UbTDPO.d.mts
generated
vendored
Normal file
@@ -0,0 +1,408 @@
|
||||
import MagicString from 'magic-string';
|
||||
import { ESMExport } from 'mlly';
|
||||
|
||||
declare const builtinPresets: {
|
||||
'@vue/composition-api': InlinePreset;
|
||||
'@vueuse/core': () => Preset;
|
||||
'@vueuse/head': InlinePreset;
|
||||
pinia: InlinePreset;
|
||||
preact: InlinePreset;
|
||||
quasar: InlinePreset;
|
||||
react: InlinePreset;
|
||||
'react-router': InlinePreset;
|
||||
'react-router-dom': InlinePreset;
|
||||
svelte: InlinePreset;
|
||||
'svelte/animate': InlinePreset;
|
||||
'svelte/easing': InlinePreset;
|
||||
'svelte/motion': InlinePreset;
|
||||
'svelte/store': InlinePreset;
|
||||
'svelte/transition': InlinePreset;
|
||||
'vee-validate': InlinePreset;
|
||||
vitepress: InlinePreset;
|
||||
'vue-demi': InlinePreset;
|
||||
'vue-i18n': InlinePreset;
|
||||
'vue-router': InlinePreset;
|
||||
'vue-router-composables': InlinePreset;
|
||||
vue: InlinePreset;
|
||||
'vue/macros': InlinePreset;
|
||||
vuex: InlinePreset;
|
||||
vitest: InlinePreset;
|
||||
'uni-app': InlinePreset;
|
||||
'solid-js': InlinePreset;
|
||||
'solid-app-router': InlinePreset;
|
||||
rxjs: InlinePreset;
|
||||
'date-fns': InlinePreset;
|
||||
};
|
||||
type BuiltinPresetName = keyof typeof builtinPresets;
|
||||
|
||||
type ModuleId = string;
|
||||
type ImportName = string;
|
||||
interface ImportCommon {
|
||||
/** Module specifier to import from */
|
||||
from: ModuleId;
|
||||
/**
|
||||
* Priority of the import, if multiple imports have the same name, the one with the highest priority will be used
|
||||
* @default 1
|
||||
*/
|
||||
priority?: number;
|
||||
/** If this import is disabled */
|
||||
disabled?: boolean;
|
||||
/** Won't output import in declaration file if true */
|
||||
dtsDisabled?: boolean;
|
||||
/** Import declaration type like const / var / enum */
|
||||
declarationType?: ESMExport['declarationType'];
|
||||
/**
|
||||
* Metadata of the import
|
||||
*/
|
||||
meta?: {
|
||||
/** Short description of the import */
|
||||
description?: string;
|
||||
/** URL to the documentation */
|
||||
docsUrl?: string;
|
||||
/** Additional metadata */
|
||||
[key: string]: any;
|
||||
};
|
||||
/**
|
||||
* If this import is a pure type import
|
||||
*/
|
||||
type?: boolean;
|
||||
/**
|
||||
* Using this as the from when generating type declarations
|
||||
*/
|
||||
typeFrom?: ModuleId;
|
||||
}
|
||||
interface Import extends ImportCommon {
|
||||
/** Import name to be detected */
|
||||
name: ImportName;
|
||||
/** Import as this name */
|
||||
as?: ImportName;
|
||||
/**
|
||||
* With properties
|
||||
*
|
||||
* Ignored for CJS imports.
|
||||
*/
|
||||
with?: Record<string, string>;
|
||||
}
|
||||
type PresetImport = Omit<Import, 'from'> | ImportName | [name: ImportName, as?: ImportName, from?: ModuleId];
|
||||
interface InlinePreset extends ImportCommon {
|
||||
imports: (PresetImport | InlinePreset)[];
|
||||
}
|
||||
/**
|
||||
* Auto extract exports from a package for auto import
|
||||
*/
|
||||
interface PackagePreset {
|
||||
/**
|
||||
* Name of the package
|
||||
*/
|
||||
package: string;
|
||||
/**
|
||||
* Path of the importer
|
||||
* @default process.cwd()
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* RegExp, string, or custom function to exclude names of the extracted imports
|
||||
*/
|
||||
ignore?: (string | RegExp | ((name: string) => boolean))[];
|
||||
/**
|
||||
* Use local cache if exits
|
||||
* @default true
|
||||
*/
|
||||
cache?: boolean;
|
||||
}
|
||||
type Preset = InlinePreset | PackagePreset;
|
||||
interface UnimportContext {
|
||||
readonly version: string;
|
||||
options: Partial<UnimportOptions>;
|
||||
staticImports: Import[];
|
||||
dynamicImports: Import[];
|
||||
addons: Addon[];
|
||||
getImports: () => Promise<Import[]>;
|
||||
getImportMap: () => Promise<Map<string, Import>>;
|
||||
getMetadata: () => UnimportMeta | undefined;
|
||||
modifyDynamicImports: (fn: (imports: Import[]) => Thenable<void | Import[]>) => Promise<void>;
|
||||
clearDynamicImports: () => void;
|
||||
replaceImports: (imports: UnimportOptions['imports']) => Promise<Import[]>;
|
||||
invalidate: () => void;
|
||||
resolveId: (id: string, parentId?: string) => Thenable<string | null | undefined | void>;
|
||||
}
|
||||
interface DetectImportResult {
|
||||
s: MagicString;
|
||||
strippedCode: string;
|
||||
isCJSContext: boolean;
|
||||
matchedImports: Import[];
|
||||
firstOccurrence: number;
|
||||
}
|
||||
interface Unimport {
|
||||
readonly version: string;
|
||||
init: () => Promise<void>;
|
||||
clearDynamicImports: UnimportContext['clearDynamicImports'];
|
||||
getImportMap: UnimportContext['getImportMap'];
|
||||
getImports: UnimportContext['getImports'];
|
||||
getInternalContext: () => UnimportContext;
|
||||
getMetadata: UnimportContext['getMetadata'];
|
||||
modifyDynamicImports: UnimportContext['modifyDynamicImports'];
|
||||
generateTypeDeclarations: (options?: TypeDeclarationOptions) => Promise<string>;
|
||||
/**
|
||||
* Get un-imported usages from code
|
||||
*/
|
||||
detectImports: (code: string | MagicString) => Promise<DetectImportResult>;
|
||||
/**
|
||||
* Insert missing imports statements to code
|
||||
*/
|
||||
injectImports: (code: string | MagicString, id?: string, options?: InjectImportsOptions) => Promise<ImportInjectionResult>;
|
||||
scanImportsFromDir: (dir?: (string | ScanDir)[], options?: ScanDirExportsOptions) => Promise<Import[]>;
|
||||
scanImportsFromFile: (file: string, includeTypes?: boolean) => Promise<Import[]>;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
toExports: (filepath?: string, includeTypes?: boolean) => Promise<string>;
|
||||
}
|
||||
interface InjectionUsageRecord {
|
||||
import: Import;
|
||||
count: number;
|
||||
moduleIds: string[];
|
||||
}
|
||||
interface UnimportMeta {
|
||||
injectionUsage: Record<string, InjectionUsageRecord>;
|
||||
}
|
||||
interface AddonsOptions {
|
||||
addons?: Addon[];
|
||||
/**
|
||||
* Enable auto import inside for Vue's <template>
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
vueTemplate?: boolean;
|
||||
/**
|
||||
* Enable auto import directives for Vue's SFC.
|
||||
*
|
||||
* Library authors should include `meta.vueDirective: true` in the import metadata.
|
||||
*
|
||||
* When using a local directives folder, provide the `isDirective`
|
||||
* callback to check if the import is a Vue directive.
|
||||
*/
|
||||
vueDirectives?: true | AddonVueDirectivesOptions;
|
||||
}
|
||||
interface AddonVueDirectivesOptions {
|
||||
/**
|
||||
* Checks if the import is a Vue directive.
|
||||
*
|
||||
* **NOTES**:
|
||||
* - imports from a library should include `meta.vueDirective: true`.
|
||||
* - this callback is only invoked for local directives (only when meta.vueDirective is not set).
|
||||
*
|
||||
* @param from The path of the import normalized.
|
||||
* @param importEntry The import entry.
|
||||
*/
|
||||
isDirective?: (from: string, importEntry: Import) => boolean;
|
||||
}
|
||||
interface UnimportOptions extends Pick<InjectImportsOptions, 'injectAtEnd' | 'mergeExisting' | 'parser'> {
|
||||
/**
|
||||
* Auto import items
|
||||
*/
|
||||
imports: Import[];
|
||||
/**
|
||||
* Auto import preset
|
||||
*/
|
||||
presets: (Preset | BuiltinPresetName)[];
|
||||
/**
|
||||
* Custom warning function
|
||||
* @default console.warn
|
||||
*/
|
||||
warn: (msg: string) => void;
|
||||
/**
|
||||
* Custom debug log function
|
||||
* @default console.log
|
||||
*/
|
||||
debugLog: (msg: string) => void;
|
||||
/**
|
||||
* Unimport Addons.
|
||||
* To use built-in addons, use:
|
||||
* ```js
|
||||
* addons: {
|
||||
* addons: [<custom-addons-here>] // if you want to use also custom addons
|
||||
* vueTemplate: true,
|
||||
* vueDirectives: [<the-directives-here>]
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Built-in addons:
|
||||
* - vueDirectives: enable auto import directives for Vue's SFC
|
||||
* - vueTemplate: enable auto import inside for Vue's <template>
|
||||
*
|
||||
* @default {}
|
||||
*/
|
||||
addons: AddonsOptions | Addon[];
|
||||
/**
|
||||
* Name of virtual modules that exposed all the registed auto-imports
|
||||
* @default []
|
||||
*/
|
||||
virtualImports: string[];
|
||||
/**
|
||||
* Directories to scan for auto import
|
||||
* @default []
|
||||
*/
|
||||
dirs?: (string | ScanDir)[];
|
||||
/**
|
||||
* Options for scanning directories for auto import
|
||||
*/
|
||||
dirsScanOptions?: ScanDirExportsOptions;
|
||||
/**
|
||||
* Custom resolver to auto import id
|
||||
*/
|
||||
resolveId?: (id: string, importee?: string) => Thenable<string | void>;
|
||||
/**
|
||||
* Custom magic comments to be opt-out for auto import, per file/module
|
||||
*
|
||||
* @default ['@unimport-disable', '@imports-disable']
|
||||
*/
|
||||
commentsDisable?: string[];
|
||||
/**
|
||||
* Custom magic comments to debug auto import, printed to console
|
||||
*
|
||||
* @default ['@unimport-debug', '@imports-debug']
|
||||
*/
|
||||
commentsDebug?: string[];
|
||||
/**
|
||||
* Collect meta data for each auto import. Accessible via `ctx.meta`
|
||||
*/
|
||||
collectMeta?: boolean;
|
||||
}
|
||||
type PathFromResolver = (_import: Import) => string | undefined;
|
||||
interface ScanDirExportsOptions {
|
||||
/**
|
||||
* Glob patterns for matching files
|
||||
*
|
||||
* @default ['*.{ts,js,mjs,cjs,mts,cts,tsx,jsx}']
|
||||
*/
|
||||
filePatterns?: string[];
|
||||
/**
|
||||
* Custom function to filter scanned files
|
||||
*/
|
||||
fileFilter?: (file: string) => boolean;
|
||||
/**
|
||||
* Register type exports
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
types?: boolean;
|
||||
/**
|
||||
* Current working directory
|
||||
*
|
||||
* @default process.cwd()
|
||||
*/
|
||||
cwd?: string;
|
||||
}
|
||||
interface ScanDir {
|
||||
/**
|
||||
* Path pattern of the directory
|
||||
*/
|
||||
glob: string;
|
||||
/**
|
||||
* Register type exports
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
types?: boolean;
|
||||
}
|
||||
interface TypeDeclarationOptions {
|
||||
/**
|
||||
* Custom resolver for path of the import
|
||||
*/
|
||||
resolvePath?: PathFromResolver;
|
||||
/**
|
||||
* Append `export {}` to the end of the file
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
exportHelper?: boolean;
|
||||
/**
|
||||
* Auto-import for type exports
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
typeReExports?: boolean;
|
||||
}
|
||||
interface InjectImportsOptions {
|
||||
/**
|
||||
* Merge the existing imports
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
mergeExisting?: boolean;
|
||||
/**
|
||||
* If the module should be auto imported
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
autoImport?: boolean;
|
||||
/**
|
||||
* If the module should be transformed for virtual modules.
|
||||
* Only available when `virtualImports` is set.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
transformVirtualImports?: boolean;
|
||||
/**
|
||||
* Parser to use for parsing the code
|
||||
*
|
||||
* Note that `acorn` only takes valid JS Code, should usually only be used after transformationa and transpilation
|
||||
*
|
||||
* @default 'regex'
|
||||
*/
|
||||
parser?: 'acorn' | 'regex';
|
||||
/**
|
||||
* Inject the imports at the end of other imports
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
injectAtEnd?: boolean;
|
||||
}
|
||||
type Thenable<T> = Promise<T> | T;
|
||||
interface Addon {
|
||||
name?: string;
|
||||
transform?: (this: UnimportContext, code: MagicString, id: string | undefined) => Thenable<MagicString>;
|
||||
declaration?: (this: UnimportContext, dts: string, options: TypeDeclarationOptions) => Thenable<string>;
|
||||
matchImports?: (this: UnimportContext, identifiers: Set<string>, matched: Import[]) => Thenable<Import[] | void>;
|
||||
/**
|
||||
* Extend or modify the imports list before injecting
|
||||
*/
|
||||
extendImports?: (this: UnimportContext, imports: Import[]) => Import[] | void;
|
||||
/**
|
||||
* Resolve imports before injecting
|
||||
*/
|
||||
injectImportsResolved?: (this: UnimportContext, imports: Import[], code: MagicString, id?: string) => Import[] | void;
|
||||
/**
|
||||
* Modify the injection code before injecting
|
||||
*/
|
||||
injectImportsStringified?: (this: UnimportContext, injection: string, imports: Import[], code: MagicString, id?: string) => string | void;
|
||||
}
|
||||
interface InstallGlobalOptions {
|
||||
/**
|
||||
* @default globalThis
|
||||
*/
|
||||
globalObject?: any;
|
||||
/**
|
||||
* Overrides the existing property
|
||||
* @default false
|
||||
*/
|
||||
overrides?: boolean;
|
||||
}
|
||||
interface MagicStringResult {
|
||||
s: MagicString;
|
||||
code: string;
|
||||
}
|
||||
interface ImportInjectionResult extends MagicStringResult {
|
||||
imports: Import[];
|
||||
}
|
||||
interface ToExportsOptions {
|
||||
/**
|
||||
* Whether to retrieve module names from imports' `typeFrom` property when provided
|
||||
* @default false
|
||||
*/
|
||||
declaration?: boolean;
|
||||
}
|
||||
|
||||
export { builtinPresets as f };
|
||||
export type { AddonsOptions as A, BuiltinPresetName as B, DetectImportResult as D, Import as I, MagicStringResult as M, Preset as P, ScanDir as S, ToExportsOptions as T, UnimportOptions as U, Unimport as a, InstallGlobalOptions as b, ScanDirExportsOptions as c, InlinePreset as d, TypeDeclarationOptions as e, ModuleId as g, ImportName as h, ImportCommon as i, PresetImport as j, PackagePreset as k, UnimportContext as l, InjectionUsageRecord as m, UnimportMeta as n, AddonVueDirectivesOptions as o, PathFromResolver as p, InjectImportsOptions as q, Thenable as r, Addon as s, ImportInjectionResult as t };
|
||||
5
node_modules/unimport/dist/shared/unimport.C9weIfOZ.d.mts
generated
vendored
Normal file
5
node_modules/unimport/dist/shared/unimport.C9weIfOZ.d.mts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { s as Addon } from './unimport.C0UbTDPO.mjs';
|
||||
|
||||
declare function vueTemplateAddon(): Addon;
|
||||
|
||||
export { vueTemplateAddon as v };
|
||||
554
node_modules/unimport/dist/shared/unimport.CWY7iHFZ.mjs
generated
vendored
Normal file
554
node_modules/unimport/dist/shared/unimport.CWY7iHFZ.mjs
generated
vendored
Normal file
@@ -0,0 +1,554 @@
|
||||
import { basename } from 'node:path';
|
||||
import process from 'node:process';
|
||||
import { isAbsolute, relative, resolve } from 'pathe';
|
||||
import { camelCase, kebabCase } from 'scule';
|
||||
import MagicString from 'magic-string';
|
||||
import { findStaticImports, parseStaticImport, resolvePathSync } from 'mlly';
|
||||
import { stripLiteral } from 'strip-literal';
|
||||
|
||||
const excludeRE = [
|
||||
// imported/exported from other module
|
||||
/\b(import|export)\b([\w$*{},\s]+?)\bfrom\s*["']/g,
|
||||
// defined as function
|
||||
/\bfunction\s*([\w$]+)\s*\(/g,
|
||||
// defined as class
|
||||
/\bclass\s*([\w$]+)\s*\{/g,
|
||||
// defined as local variable
|
||||
// eslint-disable-next-line regexp/no-super-linear-backtracking
|
||||
/\b(?:const|let|var)\s+?(\[.*?\]|\{.*?\}|.+?)\s*?[=;\n]/gs
|
||||
];
|
||||
const importAsRE = /^.*\sas\s+/;
|
||||
const separatorRE = /[,[\]{}\n]|\b(?:import|export)\b/g;
|
||||
const matchRE = /(^|\.\.\.|(?:\bcase|\?)\s+|[^\w$/)]|\bextends\s+)([\w$]+)\s*(?=[.()[\]}:;?+\-*&|`<>,\n]|\b(?:instanceof|in)\b|$|(?<=extends\s+\w+)\s+\{)/g;
|
||||
const regexRE = /\/\S*?(?<!\\)(?<!\[[^\]]*)\/[gimsuy]*/g;
|
||||
function stripCommentsAndStrings(code, options) {
|
||||
return stripLiteral(code, options).replace(regexRE, 'new RegExp("")');
|
||||
}
|
||||
|
||||
function defineUnimportPreset(preset) {
|
||||
return preset;
|
||||
}
|
||||
const identifierRE = /^[A-Z_$][\w$]*$/i;
|
||||
const safePropertyName = /^[a-z$_][\w$]*$/i;
|
||||
function stringifyWith(withValues) {
|
||||
let withDefs = "";
|
||||
for (let entries = Object.entries(withValues), l = entries.length, i = 0; i < l; i++) {
|
||||
const [prop, value] = entries[i];
|
||||
withDefs += safePropertyName.test(prop) ? prop : JSON.stringify(prop);
|
||||
withDefs += `: ${JSON.stringify(String(value))}`;
|
||||
if (i + 1 !== l)
|
||||
withDefs += ", ";
|
||||
}
|
||||
return `{ ${withDefs} }`;
|
||||
}
|
||||
function stringifyImports(imports, isCJS = false) {
|
||||
const map = toImportModuleMap(imports);
|
||||
return Object.entries(map).flatMap(([name, importSet]) => {
|
||||
const entries = [];
|
||||
const imports2 = Array.from(importSet).filter((i) => {
|
||||
if (!i.name || i.as === "") {
|
||||
let importStr;
|
||||
if (isCJS) {
|
||||
importStr = `require('${name}');`;
|
||||
} else {
|
||||
importStr = `import '${name}'`;
|
||||
if (i.with)
|
||||
importStr += ` with ${stringifyWith(i.with)}`;
|
||||
importStr += ";";
|
||||
}
|
||||
entries.push(importStr);
|
||||
return false;
|
||||
} else if (i.name === "default" || i.name === "=") {
|
||||
let importStr;
|
||||
if (isCJS) {
|
||||
importStr = i.name === "=" ? `const ${i.as} = require('${name}');` : `const { default: ${i.as} } = require('${name}');`;
|
||||
} else {
|
||||
importStr = `import ${i.as} from '${name}'`;
|
||||
if (i.with)
|
||||
importStr += ` with ${stringifyWith(i.with)}`;
|
||||
importStr += ";";
|
||||
}
|
||||
entries.push(importStr);
|
||||
return false;
|
||||
} else if (i.name === "*") {
|
||||
let importStr;
|
||||
if (isCJS) {
|
||||
importStr = `const ${i.as} = require('${name}');`;
|
||||
} else {
|
||||
importStr = `import * as ${i.as} from '${name}'`;
|
||||
if (i.with)
|
||||
importStr += ` with ${stringifyWith(i.with)}`;
|
||||
importStr += ";";
|
||||
}
|
||||
entries.push(importStr);
|
||||
return false;
|
||||
} else if (!isCJS && i.with) {
|
||||
entries.push(`import { ${stringifyImportAlias(i)} } from '${name}' with ${stringifyWith(i.with)};`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (imports2.length) {
|
||||
const importsAs = imports2.map((i) => stringifyImportAlias(i, isCJS));
|
||||
entries.push(
|
||||
isCJS ? `const { ${importsAs.join(", ")} } = require('${name}');` : `import { ${importsAs.join(", ")} } from '${name}';`
|
||||
);
|
||||
}
|
||||
return entries;
|
||||
}).join("\n");
|
||||
}
|
||||
function dedupeImports(imports, warn) {
|
||||
const map = /* @__PURE__ */ new Map();
|
||||
const indexToRemove = /* @__PURE__ */ new Set();
|
||||
imports.filter((i) => !i.disabled).forEach((i, idx) => {
|
||||
if (i.declarationType === "enum" || i.declarationType === "const enum" || i.declarationType === "class")
|
||||
return;
|
||||
const name = i.as ?? i.name;
|
||||
if (!map.has(name)) {
|
||||
map.set(name, idx);
|
||||
return;
|
||||
}
|
||||
const other = imports[map.get(name)];
|
||||
if (other.from === i.from) {
|
||||
indexToRemove.add(idx);
|
||||
return;
|
||||
}
|
||||
const diff = (other.priority || 1) - (i.priority || 1);
|
||||
if (diff === 0)
|
||||
warn(`Duplicated imports "${name}", the one from "${other.from}" has been ignored and "${i.from}" is used`);
|
||||
if (diff <= 0) {
|
||||
indexToRemove.add(map.get(name));
|
||||
map.set(name, idx);
|
||||
} else {
|
||||
indexToRemove.add(idx);
|
||||
}
|
||||
});
|
||||
return imports.filter((_, idx) => !indexToRemove.has(idx));
|
||||
}
|
||||
function toExports(imports, fileDir, includeType = false, options = {}) {
|
||||
const map = toImportModuleMap(imports, includeType, options);
|
||||
return Object.entries(map).flatMap(([name, imports2]) => {
|
||||
if (isFilePath(name))
|
||||
name = name.replace(/\.[a-z]+$/i, "");
|
||||
if (fileDir && isAbsolute(name)) {
|
||||
name = relative(fileDir, name);
|
||||
if (!name.match(/^[./]/))
|
||||
name = `./${name}`;
|
||||
}
|
||||
const entries = [];
|
||||
const filtered = Array.from(imports2).filter((i) => {
|
||||
if (i.name === "*") {
|
||||
entries.push(`export * as ${i.as} from '${name}';`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
if (filtered.length)
|
||||
entries.push(`export { ${filtered.map((i) => stringifyImportAlias(i, false)).join(", ")} } from '${name}';`);
|
||||
return entries;
|
||||
}).join("\n");
|
||||
}
|
||||
function stripFileExtension(path) {
|
||||
return path.replace(/\.[a-z]+$/i, "");
|
||||
}
|
||||
function toTypeDeclarationItems(imports, options) {
|
||||
return imports.map((i) => {
|
||||
const from = options?.resolvePath?.(i) || stripFileExtension(i.typeFrom || i.from);
|
||||
let typeDef = "";
|
||||
if (i.with)
|
||||
typeDef += `import('${from}', { with: ${stringifyWith(i.with)} })`;
|
||||
else
|
||||
typeDef += `import('${from}')`;
|
||||
if (i.name !== "*" && i.name !== "=")
|
||||
typeDef += identifierRE.test(i.name) ? `.${i.name}` : `['${i.name}']`;
|
||||
return `const ${i.as}: typeof ${typeDef}`;
|
||||
}).sort();
|
||||
}
|
||||
function toTypeDeclarationFile(imports, options) {
|
||||
const items = toTypeDeclarationItems(imports, options);
|
||||
const {
|
||||
exportHelper = true
|
||||
} = options || {};
|
||||
let declaration = "";
|
||||
if (exportHelper)
|
||||
declaration += "export {}\n";
|
||||
declaration += `declare global {
|
||||
${items.map((i) => ` ${i}`).join("\n")}
|
||||
}`;
|
||||
return declaration;
|
||||
}
|
||||
function makeTypeModulesMap(imports, resolvePath) {
|
||||
const modulesMap = /* @__PURE__ */ new Map();
|
||||
const resolveImportFrom = typeof resolvePath === "function" ? (i) => {
|
||||
return resolvePath(i) || stripFileExtension(i.typeFrom || i.from);
|
||||
} : (i) => stripFileExtension(i.typeFrom || i.from);
|
||||
for (const import_ of imports) {
|
||||
const from = resolveImportFrom(import_);
|
||||
let module = modulesMap.get(from);
|
||||
if (!module) {
|
||||
module = { typeImports: /* @__PURE__ */ new Set(), starTypeImport: void 0 };
|
||||
modulesMap.set(from, module);
|
||||
}
|
||||
if (import_.name === "*") {
|
||||
if (import_.as)
|
||||
module.starTypeImport = import_;
|
||||
} else {
|
||||
module.typeImports.add(import_);
|
||||
}
|
||||
}
|
||||
return modulesMap;
|
||||
}
|
||||
function toTypeReExports(imports, options) {
|
||||
const importsMap = makeTypeModulesMap(imports, options?.resolvePath);
|
||||
const code = Array.from(importsMap).flatMap(([from, module]) => {
|
||||
from = from.replace(/\.d\.([cm]?)ts$/i, ".$1js");
|
||||
const { starTypeImport, typeImports } = module;
|
||||
const strings = [];
|
||||
if (typeImports.size) {
|
||||
const typeImportNames = Array.from(typeImports).map(({ name, as }) => {
|
||||
if (as && as !== name)
|
||||
return `${name} as ${as}`;
|
||||
return name;
|
||||
});
|
||||
strings.push(
|
||||
"// @ts-ignore",
|
||||
`export type { ${typeImportNames.join(", ")} } from '${from}'`
|
||||
);
|
||||
}
|
||||
if (starTypeImport) {
|
||||
strings.push(
|
||||
"// @ts-ignore",
|
||||
`export type * as ${starTypeImport.as} from '${from}'`
|
||||
);
|
||||
}
|
||||
if (strings.length) {
|
||||
strings.push(
|
||||
// This is a workaround for a TypeScript issue where type-only re-exports are not properly initialized.
|
||||
`import('${from}')`
|
||||
);
|
||||
}
|
||||
return strings;
|
||||
});
|
||||
return `// for type re-export
|
||||
declare global {
|
||||
${code.map((i) => ` ${i}`).join("\n")}
|
||||
}`;
|
||||
}
|
||||
function stringifyImportAlias(item, isCJS = false) {
|
||||
return item.as === void 0 || item.name === item.as ? item.name : isCJS ? `${item.name}: ${item.as}` : `${item.name} as ${item.as}`;
|
||||
}
|
||||
function toImportModuleMap(imports, includeType = false, options = {}) {
|
||||
const map = {};
|
||||
for (const _import of imports) {
|
||||
if (_import.type && !includeType)
|
||||
continue;
|
||||
const from = options.declaration && _import.typeFrom || _import.from;
|
||||
if (!map[from])
|
||||
map[from] = /* @__PURE__ */ new Set();
|
||||
map[from].add(_import);
|
||||
}
|
||||
return map;
|
||||
}
|
||||
function getString(code) {
|
||||
if (typeof code === "string")
|
||||
return code;
|
||||
return code.toString();
|
||||
}
|
||||
function getMagicString(code) {
|
||||
if (typeof code === "string")
|
||||
return new MagicString(code);
|
||||
return code;
|
||||
}
|
||||
function addImportToCode(code, imports, isCJS = false, mergeExisting = false, injectAtLast = false, firstOccurrence = Number.POSITIVE_INFINITY, onResolved, onStringified) {
|
||||
let newImports = [];
|
||||
const s = getMagicString(code);
|
||||
let _staticImports;
|
||||
const strippedCode = stripCommentsAndStrings(s.original);
|
||||
function findStaticImportsLazy() {
|
||||
if (!_staticImports) {
|
||||
_staticImports = findStaticImports(s.original).filter((i) => Boolean(strippedCode.slice(i.start, i.end).trim())).map((i) => parseStaticImport(i));
|
||||
}
|
||||
return _staticImports;
|
||||
}
|
||||
function hasShebang() {
|
||||
const shebangRegex = /^#!.+/;
|
||||
return shebangRegex.test(s.original);
|
||||
}
|
||||
if (mergeExisting && !isCJS) {
|
||||
const existingImports = findStaticImportsLazy();
|
||||
const map = /* @__PURE__ */ new Map();
|
||||
imports.forEach((i) => {
|
||||
const target = existingImports.find((e) => e.specifier === i.from && e.imports.startsWith("{"));
|
||||
if (!target)
|
||||
return newImports.push(i);
|
||||
if (!map.has(target))
|
||||
map.set(target, []);
|
||||
map.get(target).push(i);
|
||||
});
|
||||
for (const [target, items] of map.entries()) {
|
||||
const strings = items.map((i) => `${stringifyImportAlias(i)}, `);
|
||||
const importLength = target.code.match(/^\s*import\s*\{/)?.[0]?.length;
|
||||
if (importLength)
|
||||
s.appendLeft(target.start + importLength, ` ${strings.join("").trim()}`);
|
||||
}
|
||||
} else {
|
||||
newImports = imports;
|
||||
}
|
||||
newImports = onResolved?.(newImports) ?? newImports;
|
||||
let newEntries = stringifyImports(newImports, isCJS);
|
||||
newEntries = onStringified?.(newEntries, newImports) ?? newEntries;
|
||||
if (newEntries) {
|
||||
const insertionIndex = injectAtLast ? findStaticImportsLazy().reverse().find((i) => i.end <= firstOccurrence)?.end ?? 0 : 0;
|
||||
if (insertionIndex > 0)
|
||||
s.appendRight(insertionIndex, `
|
||||
${newEntries}
|
||||
`);
|
||||
else if (hasShebang())
|
||||
s.appendLeft(s.original.indexOf("\n") + 1, `
|
||||
${newEntries}
|
||||
`);
|
||||
else
|
||||
s.prepend(`${newEntries}
|
||||
`);
|
||||
}
|
||||
return {
|
||||
s,
|
||||
get code() {
|
||||
return s.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
function normalizeImports(imports) {
|
||||
for (const _import of imports)
|
||||
_import.as = _import.as ?? _import.name;
|
||||
return imports;
|
||||
}
|
||||
function resolveIdAbsolute(id, parentId) {
|
||||
return resolvePathSync(id, {
|
||||
url: parentId
|
||||
});
|
||||
}
|
||||
function isFilePath(path) {
|
||||
return path.startsWith(".") || isAbsolute(path) || path.includes("://");
|
||||
}
|
||||
const toImports = stringifyImports;
|
||||
|
||||
const contextRE$1 = /\b_ctx\.([$\w]+)\b/g;
|
||||
const UNREF_KEY = "__unimport_unref_";
|
||||
const VUE_TEMPLATE_NAME = "unimport:vue-template";
|
||||
function vueTemplateAddon() {
|
||||
const self = {
|
||||
name: VUE_TEMPLATE_NAME,
|
||||
async transform(s, id) {
|
||||
if (!s.original.includes("_ctx.") || s.original.includes(UNREF_KEY))
|
||||
return s;
|
||||
const matches = Array.from(s.original.matchAll(contextRE$1));
|
||||
const imports = await this.getImports();
|
||||
let targets = [];
|
||||
for (const match of matches) {
|
||||
const name = match[1];
|
||||
const item = imports.find((i) => i.as === name);
|
||||
if (!item)
|
||||
continue;
|
||||
const start = match.index;
|
||||
const end = start + match[0].length;
|
||||
const tempName = `__unimport_${name}`;
|
||||
s.overwrite(start, end, `(${JSON.stringify(name)} in _ctx ? _ctx.${name} : ${UNREF_KEY}(${tempName}))`);
|
||||
if (!targets.find((i) => i.as === tempName)) {
|
||||
targets.push({
|
||||
...item,
|
||||
as: tempName
|
||||
});
|
||||
}
|
||||
}
|
||||
if (targets.length) {
|
||||
targets.push({
|
||||
name: "unref",
|
||||
from: "vue",
|
||||
as: UNREF_KEY
|
||||
});
|
||||
for (const addon of this.addons) {
|
||||
if (addon === self)
|
||||
continue;
|
||||
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
|
||||
}
|
||||
let injection = stringifyImports(targets);
|
||||
for (const addon of this.addons) {
|
||||
if (addon === self)
|
||||
continue;
|
||||
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
|
||||
}
|
||||
s.prepend(injection);
|
||||
}
|
||||
return s;
|
||||
},
|
||||
async declaration(dts, options) {
|
||||
const imports = await this.getImports();
|
||||
const items = imports.map((i) => {
|
||||
if (i.type || i.dtsDisabled)
|
||||
return "";
|
||||
const from = options?.resolvePath?.(i) || i.from;
|
||||
return `readonly ${i.as}: UnwrapRef<typeof import('${from}')${i.name !== "*" ? `['${i.name}']` : ""}>`;
|
||||
}).filter(Boolean).sort();
|
||||
const extendItems = items.map((i) => ` ${i}`).join("\n");
|
||||
return `${dts}
|
||||
// for vue template auto import
|
||||
import { UnwrapRef } from 'vue'
|
||||
declare module 'vue' {
|
||||
interface ComponentCustomProperties {
|
||||
${extendItems}
|
||||
}
|
||||
}`;
|
||||
}
|
||||
};
|
||||
return self;
|
||||
}
|
||||
|
||||
const contextRE = /resolveDirective as _resolveDirective/;
|
||||
const contextText = `${contextRE.source}, `;
|
||||
const directiveRE = /(?:var|const) (\w+) = _resolveDirective\("([\w.-]+)"\);?\s*/g;
|
||||
const VUE_DIRECTIVES_NAME = "unimport:vue-directives";
|
||||
function vueDirectivesAddon(options = {}) {
|
||||
function isDirective(importEntry) {
|
||||
let isDirective2 = importEntry.meta?.vueDirective === true;
|
||||
if (isDirective2) {
|
||||
return true;
|
||||
}
|
||||
isDirective2 = options.isDirective?.(normalizePath(process.cwd(), importEntry.from), importEntry) ?? false;
|
||||
if (isDirective2) {
|
||||
importEntry.meta ??= {};
|
||||
importEntry.meta.vueDirective = true;
|
||||
}
|
||||
return isDirective2;
|
||||
}
|
||||
const self = {
|
||||
name: VUE_DIRECTIVES_NAME,
|
||||
async transform(s, id) {
|
||||
if (!s.original.match(contextRE))
|
||||
return s;
|
||||
const matches = Array.from(s.original.matchAll(directiveRE)).sort((a, b) => b.index - a.index);
|
||||
if (!matches.length)
|
||||
return s;
|
||||
let targets = [];
|
||||
for await (const [
|
||||
begin,
|
||||
end,
|
||||
importEntry
|
||||
] of findDirectives(
|
||||
isDirective,
|
||||
matches,
|
||||
this.getImports()
|
||||
)) {
|
||||
s.overwrite(begin, end, "");
|
||||
targets.push(importEntry);
|
||||
}
|
||||
if (!targets.length)
|
||||
return s;
|
||||
if (!s.toString().match(directiveRE))
|
||||
s.replace(contextText, "");
|
||||
for (const addon of this.addons) {
|
||||
if (addon === self)
|
||||
continue;
|
||||
targets = await addon.injectImportsResolved?.call(this, targets, s, id) ?? targets;
|
||||
}
|
||||
let injection = stringifyImports(targets);
|
||||
for (const addon of this.addons) {
|
||||
if (addon === self)
|
||||
continue;
|
||||
injection = await addon.injectImportsStringified?.call(this, injection, targets, s, id) ?? injection;
|
||||
}
|
||||
s.prepend(injection);
|
||||
return s;
|
||||
},
|
||||
async declaration(dts, options2) {
|
||||
const directivesMap = await this.getImports().then((imports) => {
|
||||
return imports.filter(isDirective).reduce((acc, i) => {
|
||||
if (i.type || i.dtsDisabled)
|
||||
return acc;
|
||||
let name;
|
||||
if (i.name === "default" && (i.as === "default" || !i.as)) {
|
||||
const file = basename(i.from);
|
||||
const idx = file.indexOf(".");
|
||||
name = idx > -1 ? file.slice(0, idx) : file;
|
||||
} else {
|
||||
name = i.as ?? i.name;
|
||||
}
|
||||
name = name[0] === "v" ? camelCase(name) : camelCase(`v-${name}`);
|
||||
if (!acc.has(name)) {
|
||||
acc.set(name, i);
|
||||
}
|
||||
return acc;
|
||||
}, /* @__PURE__ */ new Map());
|
||||
});
|
||||
if (!directivesMap.size)
|
||||
return dts;
|
||||
const directives = Array.from(directivesMap.entries()).map(([name, i]) => ` ${name}: typeof import('${options2?.resolvePath?.(i) || i.from}')['${i.name}']`).sort().join("\n");
|
||||
return `${dts}
|
||||
// for vue directives auto import
|
||||
declare module 'vue' {
|
||||
interface GlobalDirectives {
|
||||
${directives}
|
||||
}
|
||||
}`;
|
||||
}
|
||||
};
|
||||
return self;
|
||||
}
|
||||
function resolvePath(cwd, path) {
|
||||
return path[0] === "." ? resolve(cwd, path) : path;
|
||||
}
|
||||
function normalizePath(cwd, path) {
|
||||
return resolvePath(cwd, path).replace(/\\/g, "/");
|
||||
}
|
||||
async function* findDirectives(isDirective, regexArray, importsPromise) {
|
||||
const imports = (await importsPromise).filter(isDirective);
|
||||
if (!imports.length)
|
||||
return;
|
||||
const symbols = regexArray.reduce((acc, regex) => {
|
||||
const [all, symbol, resolveDirectiveName] = regex;
|
||||
if (acc.has(symbol))
|
||||
return acc;
|
||||
acc.set(symbol, [
|
||||
regex.index,
|
||||
regex.index + all.length,
|
||||
kebabCase(resolveDirectiveName)
|
||||
]);
|
||||
return acc;
|
||||
}, /* @__PURE__ */ new Map());
|
||||
for (const [symbol, data] of symbols.entries()) {
|
||||
yield* findDirective(imports, symbol, data);
|
||||
}
|
||||
}
|
||||
function* findDirective(imports, symbol, [begin, end, importName]) {
|
||||
let resolvedName;
|
||||
for (const i of imports) {
|
||||
if (i.name === "default" && (i.as === "default" || !i.as)) {
|
||||
const file = basename(i.from);
|
||||
const idx = file.indexOf(".");
|
||||
resolvedName = kebabCase(idx > -1 ? file.slice(0, idx) : file);
|
||||
} else {
|
||||
resolvedName = kebabCase(i.as ?? i.name);
|
||||
}
|
||||
if (resolvedName === importName) {
|
||||
yield [
|
||||
begin,
|
||||
end,
|
||||
{ ...i, name: i.name, as: symbol }
|
||||
];
|
||||
return;
|
||||
}
|
||||
if (resolvedName[0] === "v") {
|
||||
resolvedName = resolvedName.slice(resolvedName[1] === "-" ? 2 : 1);
|
||||
}
|
||||
if (resolvedName === importName) {
|
||||
yield [
|
||||
begin,
|
||||
end,
|
||||
{ ...i, name: i.name, as: symbol }
|
||||
];
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { VUE_TEMPLATE_NAME as V, vueTemplateAddon as a, stripCommentsAndStrings as b, stringifyImports as c, defineUnimportPreset as d, excludeRE as e, dedupeImports as f, stripFileExtension as g, toTypeDeclarationItems as h, importAsRE as i, toTypeDeclarationFile as j, toTypeReExports as k, getString as l, matchRE as m, getMagicString as n, addImportToCode as o, normalizeImports as p, toImports as q, resolveIdAbsolute as r, separatorRE as s, toExports as t, VUE_DIRECTIVES_NAME as u, vueDirectivesAddon as v };
|
||||
1462
node_modules/unimport/dist/shared/unimport.u_OYhQoS.mjs
generated
vendored
Normal file
1462
node_modules/unimport/dist/shared/unimport.u_OYhQoS.mjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
24
node_modules/unimport/dist/unplugin.d.mts
generated
vendored
Normal file
24
node_modules/unimport/dist/unplugin.d.mts
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import * as unplugin from 'unplugin';
|
||||
import { FilterPattern } from 'unplugin-utils';
|
||||
import { U as UnimportOptions } from './shared/unimport.C0UbTDPO.mjs';
|
||||
import 'magic-string';
|
||||
import 'mlly';
|
||||
|
||||
interface UnimportPluginOptions extends UnimportOptions {
|
||||
include: FilterPattern;
|
||||
exclude: FilterPattern;
|
||||
dts: boolean | string;
|
||||
/**
|
||||
* Enable implicit auto import.
|
||||
* Generate global TypeScript definitions.
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
autoImport?: boolean;
|
||||
}
|
||||
declare const defaultIncludes: RegExp[];
|
||||
declare const defaultExcludes: RegExp[];
|
||||
declare const _default: unplugin.UnpluginInstance<Partial<UnimportPluginOptions>, boolean>;
|
||||
|
||||
export { _default as default, defaultExcludes, defaultIncludes };
|
||||
export type { UnimportPluginOptions };
|
||||
62
node_modules/unimport/dist/unplugin.mjs
generated
vendored
Normal file
62
node_modules/unimport/dist/unplugin.mjs
generated
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
import { promises } from 'node:fs';
|
||||
import MagicString from 'magic-string';
|
||||
import { createUnplugin } from 'unplugin';
|
||||
import { createFilter } from 'unplugin-utils';
|
||||
import { c as createUnimport } from './shared/unimport.u_OYhQoS.mjs';
|
||||
import './shared/unimport.CWY7iHFZ.mjs';
|
||||
import 'node:path';
|
||||
import 'node:process';
|
||||
import 'pathe';
|
||||
import 'scule';
|
||||
import 'mlly';
|
||||
import 'strip-literal';
|
||||
import 'node:fs/promises';
|
||||
import 'node:url';
|
||||
import 'picomatch';
|
||||
import 'tinyglobby';
|
||||
import 'node:os';
|
||||
import 'pkg-types';
|
||||
import 'local-pkg';
|
||||
|
||||
const defaultIncludes = [/\.[jt]sx?$/, /\.vue$/, /\.vue\?vue/, /\.svelte$/];
|
||||
const defaultExcludes = [/[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/];
|
||||
function toArray(x) {
|
||||
return x == null ? [] : Array.isArray(x) ? x : [x];
|
||||
}
|
||||
const unplugin = createUnplugin((options = {}) => {
|
||||
const ctx = createUnimport(options);
|
||||
const filter = createFilter(
|
||||
toArray(options.include || []).length ? options.include : defaultIncludes,
|
||||
options.exclude || defaultExcludes
|
||||
);
|
||||
const dts = options.dts === true ? "unimport.d.ts" : options.dts;
|
||||
const {
|
||||
autoImport = true
|
||||
} = options;
|
||||
return {
|
||||
name: "unimport",
|
||||
enforce: "post",
|
||||
transformInclude(id) {
|
||||
return filter(id);
|
||||
},
|
||||
async transform(code, id) {
|
||||
const s = new MagicString(code);
|
||||
await ctx.injectImports(s, id, {
|
||||
autoImport
|
||||
});
|
||||
if (!s.hasChanged())
|
||||
return;
|
||||
return {
|
||||
code: s.toString(),
|
||||
map: s.generateMap()
|
||||
};
|
||||
},
|
||||
async buildStart() {
|
||||
await ctx.init();
|
||||
if (dts)
|
||||
return promises.writeFile(dts, await ctx.generateTypeDeclarations(), "utf-8");
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
export { unplugin as default, defaultExcludes, defaultIncludes };
|
||||
7
node_modules/unimport/node_modules/estree-walker/LICENSE
generated
vendored
Normal file
7
node_modules/unimport/node_modules/estree-walker/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2015-20 [these people](https://github.com/Rich-Harris/estree-walker/graphs/contributors)
|
||||
|
||||
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.
|
||||
48
node_modules/unimport/node_modules/estree-walker/README.md
generated
vendored
Normal file
48
node_modules/unimport/node_modules/estree-walker/README.md
generated
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
# estree-walker
|
||||
|
||||
Simple utility for walking an [ESTree](https://github.com/estree/estree)-compliant AST, such as one generated by [acorn](https://github.com/marijnh/acorn).
|
||||
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
npm i estree-walker
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var walk = require('estree-walker').walk;
|
||||
var acorn = require('acorn');
|
||||
|
||||
ast = acorn.parse(sourceCode, options); // https://github.com/acornjs/acorn
|
||||
|
||||
walk(ast, {
|
||||
enter(node, parent, prop, index) {
|
||||
// some code happens
|
||||
},
|
||||
leave(node, parent, prop, index) {
|
||||
// some code happens
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Inside the `enter` function, calling `this.skip()` will prevent the node's children being walked, or the `leave` function (which is optional) being called.
|
||||
|
||||
Call `this.replace(new_node)` in either `enter` or `leave` to replace the current node with a new one.
|
||||
|
||||
Call `this.remove()` in either `enter` or `leave` to remove the current node.
|
||||
|
||||
## Why not use estraverse?
|
||||
|
||||
The ESTree spec is evolving to accommodate ES6/7. I've had a couple of experiences where [estraverse](https://github.com/estools/estraverse) was unable to handle an AST generated by recent versions of acorn, because it hard-codes visitor keys.
|
||||
|
||||
estree-walker, by contrast, simply enumerates a node's properties to find child nodes (and child lists of nodes), and is therefore resistant to spec changes. It's also much smaller. (The performance, if you're wondering, is basically identical.)
|
||||
|
||||
None of which should be taken as criticism of estraverse, which has more features and has been battle-tested in many more situations, and for which I'm very grateful.
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
38
node_modules/unimport/node_modules/estree-walker/package.json
generated
vendored
Normal file
38
node_modules/unimport/node_modules/estree-walker/package.json
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
{
|
||||
"name": "estree-walker",
|
||||
"description": "Traverse an ESTree-compliant AST",
|
||||
"version": "3.0.3",
|
||||
"private": false,
|
||||
"author": "Rich Harris",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Rich-Harris/estree-walker"
|
||||
},
|
||||
"type": "module",
|
||||
"module": "./src/index.js",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"types": "./types/index.d.ts",
|
||||
"import": "./src/index.js"
|
||||
}
|
||||
},
|
||||
"types": "types/index.d.ts",
|
||||
"scripts": {
|
||||
"prepublishOnly": "tsc && npm test",
|
||||
"test": "uvu test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/estree": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "^4.9.0",
|
||||
"uvu": "^0.5.1"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"types",
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
152
node_modules/unimport/node_modules/estree-walker/src/async.js
generated
vendored
Normal file
152
node_modules/unimport/node_modules/estree-walker/src/async.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
import { WalkerBase } from './walker.js';
|
||||
|
||||
/**
|
||||
* @typedef { import('estree').Node} Node
|
||||
* @typedef { import('./walker.js').WalkerContext} WalkerContext
|
||||
* @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: Node,
|
||||
* parent: Node | null,
|
||||
* key: string | number | symbol | null | undefined,
|
||||
* index: number | null | undefined
|
||||
* ) => Promise<void>} AsyncHandler
|
||||
*/
|
||||
|
||||
export class AsyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {AsyncHandler} [enter]
|
||||
* @param {AsyncHandler} [leave]
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_skip = false;
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_remove = false;
|
||||
|
||||
/** @type {Node | null} */
|
||||
this.replacement = null;
|
||||
|
||||
/** @type {WalkerContext} */
|
||||
this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};
|
||||
|
||||
/** @type {AsyncHandler | undefined} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {AsyncHandler | undefined} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Node} node
|
||||
* @param {Parent | null} parent
|
||||
* @param {keyof Parent} [prop]
|
||||
* @param {number | null} [index]
|
||||
* @returns {Promise<Node | null>}
|
||||
*/
|
||||
async visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
await this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
/** @type {keyof Node} */
|
||||
let key;
|
||||
|
||||
for (key in node) {
|
||||
/** @type {unknown} */
|
||||
const value = node[key];
|
||||
|
||||
if (value && typeof value === 'object') {
|
||||
if (Array.isArray(value)) {
|
||||
const nodes = /** @type {Array<unknown>} */ (value);
|
||||
for (let i = 0; i < nodes.length; i += 1) {
|
||||
const item = nodes[i];
|
||||
if (isNode(item)) {
|
||||
if (!(await this.visit(item, node, key, i))) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (isNode(value)) {
|
||||
await this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
await this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ducktype a node.
|
||||
*
|
||||
* @param {unknown} value
|
||||
* @returns {value is Node}
|
||||
*/
|
||||
function isNode(value) {
|
||||
return (
|
||||
value !== null && typeof value === 'object' && 'type' in value && typeof value.type === 'string'
|
||||
);
|
||||
}
|
||||
34
node_modules/unimport/node_modules/estree-walker/src/index.js
generated
vendored
Normal file
34
node_modules/unimport/node_modules/estree-walker/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import { SyncWalker } from './sync.js';
|
||||
import { AsyncWalker } from './async.js';
|
||||
|
||||
/**
|
||||
* @typedef {import('estree').Node} Node
|
||||
* @typedef {import('./sync.js').SyncHandler} SyncHandler
|
||||
* @typedef {import('./async.js').AsyncHandler} AsyncHandler
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Node} ast
|
||||
* @param {{
|
||||
* enter?: SyncHandler
|
||||
* leave?: SyncHandler
|
||||
* }} walker
|
||||
* @returns {Node | null}
|
||||
*/
|
||||
export function walk(ast, { enter, leave }) {
|
||||
const instance = new SyncWalker(enter, leave);
|
||||
return instance.visit(ast, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} ast
|
||||
* @param {{
|
||||
* enter?: AsyncHandler
|
||||
* leave?: AsyncHandler
|
||||
* }} walker
|
||||
* @returns {Promise<Node | null>}
|
||||
*/
|
||||
export async function asyncWalk(ast, { enter, leave }) {
|
||||
const instance = new AsyncWalker(enter, leave);
|
||||
return await instance.visit(ast, null);
|
||||
}
|
||||
152
node_modules/unimport/node_modules/estree-walker/src/sync.js
generated
vendored
Normal file
152
node_modules/unimport/node_modules/estree-walker/src/sync.js
generated
vendored
Normal file
@@ -0,0 +1,152 @@
|
||||
import { WalkerBase } from './walker.js';
|
||||
|
||||
/**
|
||||
* @typedef { import('estree').Node} Node
|
||||
* @typedef { import('./walker.js').WalkerContext} WalkerContext
|
||||
* @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: Node,
|
||||
* parent: Node | null,
|
||||
* key: string | number | symbol | null | undefined,
|
||||
* index: number | null | undefined
|
||||
* ) => void} SyncHandler
|
||||
*/
|
||||
|
||||
export class SyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {SyncHandler} [enter]
|
||||
* @param {SyncHandler} [leave]
|
||||
*/
|
||||
constructor(enter, leave) {
|
||||
super();
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_skip = false;
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_remove = false;
|
||||
|
||||
/** @type {Node | null} */
|
||||
this.replacement = null;
|
||||
|
||||
/** @type {WalkerContext} */
|
||||
this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};
|
||||
|
||||
/** @type {SyncHandler | undefined} */
|
||||
this.enter = enter;
|
||||
|
||||
/** @type {SyncHandler | undefined} */
|
||||
this.leave = leave;
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Node} node
|
||||
* @param {Parent | null} parent
|
||||
* @param {keyof Parent} [prop]
|
||||
* @param {number | null} [index]
|
||||
* @returns {Node | null}
|
||||
*/
|
||||
visit(node, parent, prop, index) {
|
||||
if (node) {
|
||||
if (this.enter) {
|
||||
const _should_skip = this.should_skip;
|
||||
const _should_remove = this.should_remove;
|
||||
const _replacement = this.replacement;
|
||||
this.should_skip = false;
|
||||
this.should_remove = false;
|
||||
this.replacement = null;
|
||||
|
||||
this.enter.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const skipped = this.should_skip;
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.should_skip = _should_skip;
|
||||
this.should_remove = _should_remove;
|
||||
this.replacement = _replacement;
|
||||
|
||||
if (skipped) return node;
|
||||
if (removed) return null;
|
||||
}
|
||||
|
||||
/** @type {keyof Node} */
|
||||
let key;
|
||||
|
||||
for (key in node) {
|
||||
/** @type {unknown} */
|
||||
const value = node[key];
|
||||
|
||||
if (value && typeof value === 'object') {
|
||||
if (Array.isArray(value)) {
|
||||
const nodes = /** @type {Array<unknown>} */ (value);
|
||||
for (let i = 0; i < nodes.length; i += 1) {
|
||||
const item = nodes[i];
|
||||
if (isNode(item)) {
|
||||
if (!this.visit(item, node, key, i)) {
|
||||
// removed
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (isNode(value)) {
|
||||
this.visit(value, node, key, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this.leave) {
|
||||
const _replacement = this.replacement;
|
||||
const _should_remove = this.should_remove;
|
||||
this.replacement = null;
|
||||
this.should_remove = false;
|
||||
|
||||
this.leave.call(this.context, node, parent, prop, index);
|
||||
|
||||
if (this.replacement) {
|
||||
node = this.replacement;
|
||||
this.replace(parent, prop, index, node);
|
||||
}
|
||||
|
||||
if (this.should_remove) {
|
||||
this.remove(parent, prop, index);
|
||||
}
|
||||
|
||||
const removed = this.should_remove;
|
||||
|
||||
this.replacement = _replacement;
|
||||
this.should_remove = _should_remove;
|
||||
|
||||
if (removed) return null;
|
||||
}
|
||||
}
|
||||
|
||||
return node;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ducktype a node.
|
||||
*
|
||||
* @param {unknown} value
|
||||
* @returns {value is Node}
|
||||
*/
|
||||
function isNode(value) {
|
||||
return (
|
||||
value !== null && typeof value === 'object' && 'type' in value && typeof value.type === 'string'
|
||||
);
|
||||
}
|
||||
61
node_modules/unimport/node_modules/estree-walker/src/walker.js
generated
vendored
Normal file
61
node_modules/unimport/node_modules/estree-walker/src/walker.js
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
* @typedef { import('estree').Node} Node
|
||||
* @typedef {{
|
||||
* skip: () => void;
|
||||
* remove: () => void;
|
||||
* replace: (node: Node) => void;
|
||||
* }} WalkerContext
|
||||
*/
|
||||
|
||||
export class WalkerBase {
|
||||
constructor() {
|
||||
/** @type {boolean} */
|
||||
this.should_skip = false;
|
||||
|
||||
/** @type {boolean} */
|
||||
this.should_remove = false;
|
||||
|
||||
/** @type {Node | null} */
|
||||
this.replacement = null;
|
||||
|
||||
/** @type {WalkerContext} */
|
||||
this.context = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node) => (this.replacement = node)
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Parent | null | undefined} parent
|
||||
* @param {keyof Parent | null | undefined} prop
|
||||
* @param {number | null | undefined} index
|
||||
* @param {Node} node
|
||||
*/
|
||||
replace(parent, prop, index, node) {
|
||||
if (parent && prop) {
|
||||
if (index != null) {
|
||||
/** @type {Array<Node>} */ (parent[prop])[index] = node;
|
||||
} else {
|
||||
/** @type {Node} */ (parent[prop]) = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Parent | null | undefined} parent
|
||||
* @param {keyof Parent | null | undefined} prop
|
||||
* @param {number | null | undefined} index
|
||||
*/
|
||||
remove(parent, prop, index) {
|
||||
if (parent && prop) {
|
||||
if (index !== null && index !== undefined) {
|
||||
/** @type {Array<Node>} */ (parent[prop]).splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
node_modules/unimport/node_modules/estree-walker/types/async.d.ts
generated
vendored
Normal file
36
node_modules/unimport/node_modules/estree-walker/types/async.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @typedef { import('estree').Node} Node
|
||||
* @typedef { import('./walker.js').WalkerContext} WalkerContext
|
||||
* @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: Node,
|
||||
* parent: Node | null,
|
||||
* key: string | number | symbol | null | undefined,
|
||||
* index: number | null | undefined
|
||||
* ) => Promise<void>} AsyncHandler
|
||||
*/
|
||||
export class AsyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {AsyncHandler} [enter]
|
||||
* @param {AsyncHandler} [leave]
|
||||
*/
|
||||
constructor(enter?: AsyncHandler | undefined, leave?: AsyncHandler | undefined);
|
||||
/** @type {AsyncHandler | undefined} */
|
||||
enter: AsyncHandler | undefined;
|
||||
/** @type {AsyncHandler | undefined} */
|
||||
leave: AsyncHandler | undefined;
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Node} node
|
||||
* @param {Parent | null} parent
|
||||
* @param {keyof Parent} [prop]
|
||||
* @param {number | null} [index]
|
||||
* @returns {Promise<Node | null>}
|
||||
*/
|
||||
visit<Parent extends import("estree").Node>(node: Node, parent: Parent | null, prop?: keyof Parent | undefined, index?: number | null | undefined): Promise<Node | null>;
|
||||
}
|
||||
export type Node = import('estree').Node;
|
||||
export type WalkerContext = import('./walker.js').WalkerContext;
|
||||
export type AsyncHandler = (this: WalkerContext, node: Node, parent: Node | null, key: string | number | symbol | null | undefined, index: number | null | undefined) => Promise<void>;
|
||||
import { WalkerBase } from "./walker.js";
|
||||
32
node_modules/unimport/node_modules/estree-walker/types/index.d.ts
generated
vendored
Normal file
32
node_modules/unimport/node_modules/estree-walker/types/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* @typedef {import('estree').Node} Node
|
||||
* @typedef {import('./sync.js').SyncHandler} SyncHandler
|
||||
* @typedef {import('./async.js').AsyncHandler} AsyncHandler
|
||||
*/
|
||||
/**
|
||||
* @param {Node} ast
|
||||
* @param {{
|
||||
* enter?: SyncHandler
|
||||
* leave?: SyncHandler
|
||||
* }} walker
|
||||
* @returns {Node | null}
|
||||
*/
|
||||
export function walk(ast: Node, { enter, leave }: {
|
||||
enter?: SyncHandler;
|
||||
leave?: SyncHandler;
|
||||
}): Node | null;
|
||||
/**
|
||||
* @param {Node} ast
|
||||
* @param {{
|
||||
* enter?: AsyncHandler
|
||||
* leave?: AsyncHandler
|
||||
* }} walker
|
||||
* @returns {Promise<Node | null>}
|
||||
*/
|
||||
export function asyncWalk(ast: Node, { enter, leave }: {
|
||||
enter?: AsyncHandler;
|
||||
leave?: AsyncHandler;
|
||||
}): Promise<Node | null>;
|
||||
export type Node = import('estree').Node;
|
||||
export type SyncHandler = import('./sync.js').SyncHandler;
|
||||
export type AsyncHandler = import('./async.js').AsyncHandler;
|
||||
36
node_modules/unimport/node_modules/estree-walker/types/sync.d.ts
generated
vendored
Normal file
36
node_modules/unimport/node_modules/estree-walker/types/sync.d.ts
generated
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
/**
|
||||
* @typedef { import('estree').Node} Node
|
||||
* @typedef { import('./walker.js').WalkerContext} WalkerContext
|
||||
* @typedef {(
|
||||
* this: WalkerContext,
|
||||
* node: Node,
|
||||
* parent: Node | null,
|
||||
* key: string | number | symbol | null | undefined,
|
||||
* index: number | null | undefined
|
||||
* ) => void} SyncHandler
|
||||
*/
|
||||
export class SyncWalker extends WalkerBase {
|
||||
/**
|
||||
*
|
||||
* @param {SyncHandler} [enter]
|
||||
* @param {SyncHandler} [leave]
|
||||
*/
|
||||
constructor(enter?: SyncHandler | undefined, leave?: SyncHandler | undefined);
|
||||
/** @type {SyncHandler | undefined} */
|
||||
enter: SyncHandler | undefined;
|
||||
/** @type {SyncHandler | undefined} */
|
||||
leave: SyncHandler | undefined;
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Node} node
|
||||
* @param {Parent | null} parent
|
||||
* @param {keyof Parent} [prop]
|
||||
* @param {number | null} [index]
|
||||
* @returns {Node | null}
|
||||
*/
|
||||
visit<Parent extends import("estree").Node>(node: Node, parent: Parent | null, prop?: keyof Parent | undefined, index?: number | null | undefined): Node | null;
|
||||
}
|
||||
export type Node = import('estree').Node;
|
||||
export type WalkerContext = import('./walker.js').WalkerContext;
|
||||
export type SyncHandler = (this: WalkerContext, node: Node, parent: Node | null, key: string | number | symbol | null | undefined, index: number | null | undefined) => void;
|
||||
import { WalkerBase } from "./walker.js";
|
||||
39
node_modules/unimport/node_modules/estree-walker/types/walker.d.ts
generated
vendored
Normal file
39
node_modules/unimport/node_modules/estree-walker/types/walker.d.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* @typedef { import('estree').Node} Node
|
||||
* @typedef {{
|
||||
* skip: () => void;
|
||||
* remove: () => void;
|
||||
* replace: (node: Node) => void;
|
||||
* }} WalkerContext
|
||||
*/
|
||||
export class WalkerBase {
|
||||
/** @type {boolean} */
|
||||
should_skip: boolean;
|
||||
/** @type {boolean} */
|
||||
should_remove: boolean;
|
||||
/** @type {Node | null} */
|
||||
replacement: Node | null;
|
||||
/** @type {WalkerContext} */
|
||||
context: WalkerContext;
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Parent | null | undefined} parent
|
||||
* @param {keyof Parent | null | undefined} prop
|
||||
* @param {number | null | undefined} index
|
||||
* @param {Node} node
|
||||
*/
|
||||
replace<Parent extends import("estree").Node>(parent: Parent | null | undefined, prop: keyof Parent | null | undefined, index: number | null | undefined, node: Node): void;
|
||||
/**
|
||||
* @template {Node} Parent
|
||||
* @param {Parent | null | undefined} parent
|
||||
* @param {keyof Parent | null | undefined} prop
|
||||
* @param {number | null | undefined} index
|
||||
*/
|
||||
remove<Parent_1 extends import("estree").Node>(parent: Parent_1 | null | undefined, prop: keyof Parent_1 | null | undefined, index: number | null | undefined): void;
|
||||
}
|
||||
export type Node = import('estree').Node;
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: Node) => void;
|
||||
};
|
||||
70
node_modules/unimport/node_modules/pathe/LICENSE
generated
vendored
Normal file
70
node_modules/unimport/node_modules/pathe/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Pooya Parsa <pooya@pi0.io> - Daniel Roe <daniel@roe.dev>
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Copyright Joyent, Inc. and other Node contributors.
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
Bundled zeptomatch (https://github.com/fabiospampinato/zeptomatch)
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2023-present Fabio Spampinato
|
||||
|
||||
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.
|
||||
73
node_modules/unimport/node_modules/pathe/README.md
generated
vendored
Normal file
73
node_modules/unimport/node_modules/pathe/README.md
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
# 🛣️ pathe
|
||||
|
||||
> Universal filesystem path utils
|
||||
|
||||
[![version][npm-v-src]][npm-v-href]
|
||||
[![downloads][npm-d-src]][npm-d-href]
|
||||
[![size][size-src]][size-href]
|
||||
|
||||
## ❓ Why
|
||||
|
||||
For [historical reasons](https://docs.microsoft.com/en-us/archive/blogs/larryosterman/why-is-the-dos-path-character), windows followed MS-DOS and used backslash for separating paths rather than slash used for macOS, Linux, and other Posix operating systems. Nowadays, [Windows](https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file?redirectedfrom=MSDN) supports both Slash and Backslash for paths. [Node.js's built-in `path` module](https://nodejs.org/api/path.html) in the default operation of the path module varies based on the operating system on which a Node.js application is running. Specifically, when running on a Windows operating system, the path module will assume that Windows-style paths are being used. **This makes inconsistent code behavior between Windows and POSIX.**
|
||||
|
||||
Compared to popular [upath](https://github.com/anodynos/upath), pathe provides **identical exports** of Node.js with normalization on **all operations** and is written in modern **ESM/TypeScript** and has **no dependency on Node.js**!
|
||||
|
||||
This package is a drop-in replacement of the Node.js's [path module](https://nodejs.org/api/path.html) module and ensures paths are normalized with slash `/` and work in environments including Node.js.
|
||||
|
||||
## 💿 Usage
|
||||
|
||||
Install using npm or yarn:
|
||||
|
||||
```bash
|
||||
# npm
|
||||
npm i pathe
|
||||
|
||||
# yarn
|
||||
yarn add pathe
|
||||
|
||||
# pnpm
|
||||
pnpm i pathe
|
||||
```
|
||||
|
||||
Import:
|
||||
|
||||
```js
|
||||
// ESM / Typescript
|
||||
import { resolve, matchesGlob } from "pathe";
|
||||
|
||||
// CommonJS
|
||||
const { resolve, matchesGlob } = require("pathe");
|
||||
```
|
||||
|
||||
Read more about path utils from [Node.js documentation](https://nodejs.org/api/path.html) and rest assured behavior is consistently like POSIX regardless of your input paths format and running platform (the only exception is `delimiter` constant export, it will be set to `;` on windows platform).
|
||||
|
||||
### Extra utilities
|
||||
|
||||
Pathe exports some extra utilities that do not exist in standard Node.js [path module](https://nodejs.org/api/path.html).
|
||||
In order to use them, you can import from `pathe/utils` subpath:
|
||||
|
||||
```js
|
||||
import {
|
||||
filename,
|
||||
normalizeAliases,
|
||||
resolveAlias,
|
||||
reverseResolveAlias,
|
||||
} from "pathe/utils";
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Made with 💛 Published under the [MIT](./LICENSE) license.
|
||||
|
||||
Some code was used from the Node.js project. Glob supported is powered by [zeptomatch](https://github.com/fabiospampinato/zeptomatch).
|
||||
|
||||
<!-- Refs -->
|
||||
|
||||
[npm-v-src]: https://img.shields.io/npm/v/pathe?style=flat-square
|
||||
[npm-v-href]: https://npmjs.com/package/pathe
|
||||
[npm-d-src]: https://img.shields.io/npm/dm/pathe?style=flat-square
|
||||
[npm-d-href]: https://npmjs.com/package/pathe
|
||||
[github-actions-src]: https://img.shields.io/github/workflow/status/unjs/pathe/ci/main?style=flat-square
|
||||
[github-actions-href]: https://github.com/unjs/pathe/actions?query=workflow%3Aci
|
||||
[size-src]: https://packagephobia.now.sh/badge?p=pathe
|
||||
[size-href]: https://packagephobia.now.sh/result?p=pathe
|
||||
39
node_modules/unimport/node_modules/pathe/dist/index.cjs
generated
vendored
Normal file
39
node_modules/unimport/node_modules/pathe/dist/index.cjs
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, '__esModule', { value: true });
|
||||
|
||||
const _path = require('./shared/pathe.BSlhyZSM.cjs');
|
||||
|
||||
const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
||||
const _platforms = { posix: void 0, win32: void 0 };
|
||||
const mix = (del = delimiter) => {
|
||||
return new Proxy(_path._path, {
|
||||
get(_, prop) {
|
||||
if (prop === "delimiter") return del;
|
||||
if (prop === "posix") return posix;
|
||||
if (prop === "win32") return win32;
|
||||
return _platforms[prop] || _path._path[prop];
|
||||
}
|
||||
});
|
||||
};
|
||||
const posix = /* @__PURE__ */ mix(":");
|
||||
const win32 = /* @__PURE__ */ mix(";");
|
||||
|
||||
exports.basename = _path.basename;
|
||||
exports.dirname = _path.dirname;
|
||||
exports.extname = _path.extname;
|
||||
exports.format = _path.format;
|
||||
exports.isAbsolute = _path.isAbsolute;
|
||||
exports.join = _path.join;
|
||||
exports.matchesGlob = _path.matchesGlob;
|
||||
exports.normalize = _path.normalize;
|
||||
exports.normalizeString = _path.normalizeString;
|
||||
exports.parse = _path.parse;
|
||||
exports.relative = _path.relative;
|
||||
exports.resolve = _path.resolve;
|
||||
exports.sep = _path.sep;
|
||||
exports.toNamespacedPath = _path.toNamespacedPath;
|
||||
exports.default = posix;
|
||||
exports.delimiter = delimiter;
|
||||
exports.posix = posix;
|
||||
exports.win32 = win32;
|
||||
47
node_modules/unimport/node_modules/pathe/dist/index.d.cts
generated
vendored
Normal file
47
node_modules/unimport/node_modules/pathe/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as path from 'node:path';
|
||||
import path__default from 'node:path';
|
||||
|
||||
/**
|
||||
* Constant for path separator.
|
||||
*
|
||||
* Always equals to `"/"`.
|
||||
*/
|
||||
declare const sep = "/";
|
||||
declare const normalize: typeof path__default.normalize;
|
||||
declare const join: typeof path__default.join;
|
||||
declare const resolve: typeof path__default.resolve;
|
||||
/**
|
||||
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
||||
*
|
||||
* @param path - The path to normalise.
|
||||
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
||||
* @returns the normalised path string.
|
||||
*/
|
||||
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
||||
declare const isAbsolute: typeof path__default.isAbsolute;
|
||||
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
|
||||
declare const extname: typeof path__default.extname;
|
||||
declare const relative: typeof path__default.relative;
|
||||
declare const dirname: typeof path__default.dirname;
|
||||
declare const format: typeof path__default.format;
|
||||
declare const basename: typeof path__default.basename;
|
||||
declare const parse: typeof path__default.parse;
|
||||
/**
|
||||
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||
* @param path The path to glob-match against.
|
||||
* @param pattern The glob to check the path against.
|
||||
*/
|
||||
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
|
||||
|
||||
type NodePath = typeof path;
|
||||
/**
|
||||
* The platform-specific file delimiter.
|
||||
*
|
||||
* Equals to `";"` in windows and `":"` in all other platforms.
|
||||
*/
|
||||
declare const delimiter: ";" | ":";
|
||||
declare const posix: NodePath["posix"];
|
||||
declare const win32: NodePath["win32"];
|
||||
declare const _default: NodePath;
|
||||
|
||||
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };
|
||||
47
node_modules/unimport/node_modules/pathe/dist/index.d.mts
generated
vendored
Normal file
47
node_modules/unimport/node_modules/pathe/dist/index.d.mts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as path from 'node:path';
|
||||
import path__default from 'node:path';
|
||||
|
||||
/**
|
||||
* Constant for path separator.
|
||||
*
|
||||
* Always equals to `"/"`.
|
||||
*/
|
||||
declare const sep = "/";
|
||||
declare const normalize: typeof path__default.normalize;
|
||||
declare const join: typeof path__default.join;
|
||||
declare const resolve: typeof path__default.resolve;
|
||||
/**
|
||||
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
||||
*
|
||||
* @param path - The path to normalise.
|
||||
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
||||
* @returns the normalised path string.
|
||||
*/
|
||||
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
||||
declare const isAbsolute: typeof path__default.isAbsolute;
|
||||
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
|
||||
declare const extname: typeof path__default.extname;
|
||||
declare const relative: typeof path__default.relative;
|
||||
declare const dirname: typeof path__default.dirname;
|
||||
declare const format: typeof path__default.format;
|
||||
declare const basename: typeof path__default.basename;
|
||||
declare const parse: typeof path__default.parse;
|
||||
/**
|
||||
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||
* @param path The path to glob-match against.
|
||||
* @param pattern The glob to check the path against.
|
||||
*/
|
||||
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
|
||||
|
||||
type NodePath = typeof path;
|
||||
/**
|
||||
* The platform-specific file delimiter.
|
||||
*
|
||||
* Equals to `";"` in windows and `":"` in all other platforms.
|
||||
*/
|
||||
declare const delimiter: ";" | ":";
|
||||
declare const posix: NodePath["posix"];
|
||||
declare const win32: NodePath["win32"];
|
||||
declare const _default: NodePath;
|
||||
|
||||
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };
|
||||
47
node_modules/unimport/node_modules/pathe/dist/index.d.ts
generated
vendored
Normal file
47
node_modules/unimport/node_modules/pathe/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import * as path from 'node:path';
|
||||
import path__default from 'node:path';
|
||||
|
||||
/**
|
||||
* Constant for path separator.
|
||||
*
|
||||
* Always equals to `"/"`.
|
||||
*/
|
||||
declare const sep = "/";
|
||||
declare const normalize: typeof path__default.normalize;
|
||||
declare const join: typeof path__default.join;
|
||||
declare const resolve: typeof path__default.resolve;
|
||||
/**
|
||||
* Resolves a string path, resolving '.' and '.' segments and allowing paths above the root.
|
||||
*
|
||||
* @param path - The path to normalise.
|
||||
* @param allowAboveRoot - Whether to allow the resulting path to be above the root directory.
|
||||
* @returns the normalised path string.
|
||||
*/
|
||||
declare function normalizeString(path: string, allowAboveRoot: boolean): string;
|
||||
declare const isAbsolute: typeof path__default.isAbsolute;
|
||||
declare const toNamespacedPath: typeof path__default.toNamespacedPath;
|
||||
declare const extname: typeof path__default.extname;
|
||||
declare const relative: typeof path__default.relative;
|
||||
declare const dirname: typeof path__default.dirname;
|
||||
declare const format: typeof path__default.format;
|
||||
declare const basename: typeof path__default.basename;
|
||||
declare const parse: typeof path__default.parse;
|
||||
/**
|
||||
* The `path.matchesGlob()` method determines if `path` matches the `pattern`.
|
||||
* @param path The path to glob-match against.
|
||||
* @param pattern The glob to check the path against.
|
||||
*/
|
||||
declare const matchesGlob: (path: string, pattern: string | string[]) => boolean;
|
||||
|
||||
type NodePath = typeof path;
|
||||
/**
|
||||
* The platform-specific file delimiter.
|
||||
*
|
||||
* Equals to `";"` in windows and `":"` in all other platforms.
|
||||
*/
|
||||
declare const delimiter: ";" | ":";
|
||||
declare const posix: NodePath["posix"];
|
||||
declare const win32: NodePath["win32"];
|
||||
declare const _default: NodePath;
|
||||
|
||||
export { basename, _default as default, delimiter, dirname, extname, format, isAbsolute, join, matchesGlob, normalize, normalizeString, parse, posix, relative, resolve, sep, toNamespacedPath, win32 };
|
||||
19
node_modules/unimport/node_modules/pathe/dist/index.mjs
generated
vendored
Normal file
19
node_modules/unimport/node_modules/pathe/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { _ as _path } from './shared/pathe.M-eThtNZ.mjs';
|
||||
export { c as basename, d as dirname, e as extname, f as format, i as isAbsolute, j as join, m as matchesGlob, n as normalize, a as normalizeString, p as parse, b as relative, r as resolve, s as sep, t as toNamespacedPath } from './shared/pathe.M-eThtNZ.mjs';
|
||||
|
||||
const delimiter = /* @__PURE__ */ (() => globalThis.process?.platform === "win32" ? ";" : ":")();
|
||||
const _platforms = { posix: void 0, win32: void 0 };
|
||||
const mix = (del = delimiter) => {
|
||||
return new Proxy(_path, {
|
||||
get(_, prop) {
|
||||
if (prop === "delimiter") return del;
|
||||
if (prop === "posix") return posix;
|
||||
if (prop === "win32") return win32;
|
||||
return _platforms[prop] || _path[prop];
|
||||
}
|
||||
});
|
||||
};
|
||||
const posix = /* @__PURE__ */ mix(":");
|
||||
const win32 = /* @__PURE__ */ mix(";");
|
||||
|
||||
export { posix as default, delimiter, posix, win32 };
|
||||
266
node_modules/unimport/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs
generated
vendored
Normal file
266
node_modules/unimport/node_modules/pathe/dist/shared/pathe.BSlhyZSM.cjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
249
node_modules/unimport/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
generated
vendored
Normal file
249
node_modules/unimport/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
82
node_modules/unimport/node_modules/pathe/dist/utils.cjs
generated
vendored
Normal file
82
node_modules/unimport/node_modules/pathe/dist/utils.cjs
generated
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
'use strict';
|
||||
|
||||
const _path = require('./shared/pathe.BSlhyZSM.cjs');
|
||||
|
||||
const pathSeparators = /* @__PURE__ */ new Set(["/", "\\", void 0]);
|
||||
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
||||
const SLASH_RE = /[/\\]/;
|
||||
function normalizeAliases(_aliases) {
|
||||
if (_aliases[normalizedAliasSymbol]) {
|
||||
return _aliases;
|
||||
}
|
||||
const aliases = Object.fromEntries(
|
||||
Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b))
|
||||
);
|
||||
for (const key in aliases) {
|
||||
for (const alias in aliases) {
|
||||
if (alias === key || key.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) {
|
||||
aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.defineProperty(aliases, normalizedAliasSymbol, {
|
||||
value: true,
|
||||
enumerable: false
|
||||
});
|
||||
return aliases;
|
||||
}
|
||||
function resolveAlias(path, aliases) {
|
||||
const _path$1 = _path.normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
for (const [alias, to] of Object.entries(aliases)) {
|
||||
if (!_path$1.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path$1[_alias.length])) {
|
||||
return _path.join(to, _path$1.slice(alias.length));
|
||||
}
|
||||
}
|
||||
return _path$1;
|
||||
}
|
||||
function reverseResolveAlias(path, aliases) {
|
||||
const _path$1 = _path.normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
const matches = [];
|
||||
for (const [to, alias] of Object.entries(aliases)) {
|
||||
if (!_path$1.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path$1[_alias.length])) {
|
||||
matches.push(_path.join(to, _path$1.slice(alias.length)));
|
||||
}
|
||||
}
|
||||
return matches.sort((a, b) => b.length - a.length);
|
||||
}
|
||||
function filename(path) {
|
||||
const base = path.split(SLASH_RE).pop();
|
||||
if (!base) {
|
||||
return void 0;
|
||||
}
|
||||
const separatorIndex = base.lastIndexOf(".");
|
||||
if (separatorIndex <= 0) {
|
||||
return base;
|
||||
}
|
||||
return base.slice(0, separatorIndex);
|
||||
}
|
||||
function _compareAliases(a, b) {
|
||||
return b.split("/").length - a.split("/").length;
|
||||
}
|
||||
function hasTrailingSlash(path = "/") {
|
||||
const lastChar = path[path.length - 1];
|
||||
return lastChar === "/" || lastChar === "\\";
|
||||
}
|
||||
|
||||
exports.filename = filename;
|
||||
exports.normalizeAliases = normalizeAliases;
|
||||
exports.resolveAlias = resolveAlias;
|
||||
exports.reverseResolveAlias = reverseResolveAlias;
|
||||
32
node_modules/unimport/node_modules/pathe/dist/utils.d.cts
generated
vendored
Normal file
32
node_modules/unimport/node_modules/pathe/dist/utils.d.cts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
|
||||
* This function also ensures that aliases do not resolve to themselves cyclically.
|
||||
*
|
||||
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
|
||||
* @returns a set of normalised alias mappings.
|
||||
*/
|
||||
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
|
||||
/**
|
||||
* Resolves a path string to its alias if applicable, otherwise returns the original path.
|
||||
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
|
||||
*
|
||||
* @param path - The path string to resolve.
|
||||
* @param aliases - A set of alias mappings to use for resolution.
|
||||
* @returns the resolved path as a string.
|
||||
*/
|
||||
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
|
||||
/**
|
||||
* Resolves a path string to its possible alias.
|
||||
*
|
||||
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
|
||||
*/
|
||||
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
|
||||
/**
|
||||
* Extracts the filename from a given path, excluding any directory paths and the file extension.
|
||||
*
|
||||
* @param path - The full path of the file from which to extract the filename.
|
||||
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
|
||||
*/
|
||||
declare function filename(path: string): string | undefined;
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
32
node_modules/unimport/node_modules/pathe/dist/utils.d.mts
generated
vendored
Normal file
32
node_modules/unimport/node_modules/pathe/dist/utils.d.mts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
|
||||
* This function also ensures that aliases do not resolve to themselves cyclically.
|
||||
*
|
||||
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
|
||||
* @returns a set of normalised alias mappings.
|
||||
*/
|
||||
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
|
||||
/**
|
||||
* Resolves a path string to its alias if applicable, otherwise returns the original path.
|
||||
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
|
||||
*
|
||||
* @param path - The path string to resolve.
|
||||
* @param aliases - A set of alias mappings to use for resolution.
|
||||
* @returns the resolved path as a string.
|
||||
*/
|
||||
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
|
||||
/**
|
||||
* Resolves a path string to its possible alias.
|
||||
*
|
||||
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
|
||||
*/
|
||||
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
|
||||
/**
|
||||
* Extracts the filename from a given path, excluding any directory paths and the file extension.
|
||||
*
|
||||
* @param path - The full path of the file from which to extract the filename.
|
||||
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
|
||||
*/
|
||||
declare function filename(path: string): string | undefined;
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
32
node_modules/unimport/node_modules/pathe/dist/utils.d.ts
generated
vendored
Normal file
32
node_modules/unimport/node_modules/pathe/dist/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1,32 @@
|
||||
/**
|
||||
* Normalises alias mappings, ensuring that more specific aliases are resolved before less specific ones.
|
||||
* This function also ensures that aliases do not resolve to themselves cyclically.
|
||||
*
|
||||
* @param _aliases - A set of alias mappings where each key is an alias and its value is the actual path it points to.
|
||||
* @returns a set of normalised alias mappings.
|
||||
*/
|
||||
declare function normalizeAliases(_aliases: Record<string, string>): Record<string, string>;
|
||||
/**
|
||||
* Resolves a path string to its alias if applicable, otherwise returns the original path.
|
||||
* This function normalises the path, resolves the alias and then joins it to the alias target if necessary.
|
||||
*
|
||||
* @param path - The path string to resolve.
|
||||
* @param aliases - A set of alias mappings to use for resolution.
|
||||
* @returns the resolved path as a string.
|
||||
*/
|
||||
declare function resolveAlias(path: string, aliases: Record<string, string>): string;
|
||||
/**
|
||||
* Resolves a path string to its possible alias.
|
||||
*
|
||||
* Returns an array of possible alias resolutions (could be empty), sorted by specificity (longest first).
|
||||
*/
|
||||
declare function reverseResolveAlias(path: string, aliases: Record<string, string>): string[];
|
||||
/**
|
||||
* Extracts the filename from a given path, excluding any directory paths and the file extension.
|
||||
*
|
||||
* @param path - The full path of the file from which to extract the filename.
|
||||
* @returns the filename without the extension, or `undefined` if the filename cannot be extracted.
|
||||
*/
|
||||
declare function filename(path: string): string | undefined;
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
77
node_modules/unimport/node_modules/pathe/dist/utils.mjs
generated
vendored
Normal file
77
node_modules/unimport/node_modules/pathe/dist/utils.mjs
generated
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
import { g as normalizeWindowsPath, j as join } from './shared/pathe.M-eThtNZ.mjs';
|
||||
|
||||
const pathSeparators = /* @__PURE__ */ new Set(["/", "\\", void 0]);
|
||||
const normalizedAliasSymbol = Symbol.for("pathe:normalizedAlias");
|
||||
const SLASH_RE = /[/\\]/;
|
||||
function normalizeAliases(_aliases) {
|
||||
if (_aliases[normalizedAliasSymbol]) {
|
||||
return _aliases;
|
||||
}
|
||||
const aliases = Object.fromEntries(
|
||||
Object.entries(_aliases).sort(([a], [b]) => _compareAliases(a, b))
|
||||
);
|
||||
for (const key in aliases) {
|
||||
for (const alias in aliases) {
|
||||
if (alias === key || key.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
if (aliases[key]?.startsWith(alias) && pathSeparators.has(aliases[key][alias.length])) {
|
||||
aliases[key] = aliases[alias] + aliases[key].slice(alias.length);
|
||||
}
|
||||
}
|
||||
}
|
||||
Object.defineProperty(aliases, normalizedAliasSymbol, {
|
||||
value: true,
|
||||
enumerable: false
|
||||
});
|
||||
return aliases;
|
||||
}
|
||||
function resolveAlias(path, aliases) {
|
||||
const _path = normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
for (const [alias, to] of Object.entries(aliases)) {
|
||||
if (!_path.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path[_alias.length])) {
|
||||
return join(to, _path.slice(alias.length));
|
||||
}
|
||||
}
|
||||
return _path;
|
||||
}
|
||||
function reverseResolveAlias(path, aliases) {
|
||||
const _path = normalizeWindowsPath(path);
|
||||
aliases = normalizeAliases(aliases);
|
||||
const matches = [];
|
||||
for (const [to, alias] of Object.entries(aliases)) {
|
||||
if (!_path.startsWith(alias)) {
|
||||
continue;
|
||||
}
|
||||
const _alias = hasTrailingSlash(alias) ? alias.slice(0, -1) : alias;
|
||||
if (hasTrailingSlash(_path[_alias.length])) {
|
||||
matches.push(join(to, _path.slice(alias.length)));
|
||||
}
|
||||
}
|
||||
return matches.sort((a, b) => b.length - a.length);
|
||||
}
|
||||
function filename(path) {
|
||||
const base = path.split(SLASH_RE).pop();
|
||||
if (!base) {
|
||||
return void 0;
|
||||
}
|
||||
const separatorIndex = base.lastIndexOf(".");
|
||||
if (separatorIndex <= 0) {
|
||||
return base;
|
||||
}
|
||||
return base.slice(0, separatorIndex);
|
||||
}
|
||||
function _compareAliases(a, b) {
|
||||
return b.split("/").length - a.split("/").length;
|
||||
}
|
||||
function hasTrailingSlash(path = "/") {
|
||||
const lastChar = path[path.length - 1];
|
||||
return lastChar === "/" || lastChar === "\\";
|
||||
}
|
||||
|
||||
export { filename, normalizeAliases, resolveAlias, reverseResolveAlias };
|
||||
61
node_modules/unimport/node_modules/pathe/package.json
generated
vendored
Normal file
61
node_modules/unimport/node_modules/pathe/package.json
generated
vendored
Normal file
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "pathe",
|
||||
"version": "2.0.3",
|
||||
"description": "Universal filesystem path utils",
|
||||
"repository": "unjs/pathe",
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": {
|
||||
"import": {
|
||||
"types": "./dist/index.d.mts",
|
||||
"default": "./dist/index.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/index.d.cts",
|
||||
"default": "./dist/index.cjs"
|
||||
}
|
||||
},
|
||||
"./utils": {
|
||||
"import": {
|
||||
"types": "./dist/utils.d.mts",
|
||||
"default": "./dist/utils.mjs"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/utils.d.cts",
|
||||
"default": "./dist/utils.cjs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"files": [
|
||||
"dist",
|
||||
"utils.d.ts"
|
||||
],
|
||||
"devDependencies": {
|
||||
"@types/node": "^22.13.1",
|
||||
"@vitest/coverage-v8": "^3.0.5",
|
||||
"changelogen": "^0.5.7",
|
||||
"esbuild": "^0.25.0",
|
||||
"eslint": "^9.20.1",
|
||||
"eslint-config-unjs": "^0.4.2",
|
||||
"jiti": "^2.4.2",
|
||||
"prettier": "^3.5.0",
|
||||
"typescript": "^5.7.3",
|
||||
"unbuild": "^3.3.1",
|
||||
"vitest": "^3.0.5",
|
||||
"zeptomatch": "^2.0.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "vitest",
|
||||
"lint": "eslint . && prettier -c src test",
|
||||
"lint:fix": "eslint . --fix && prettier -w src test",
|
||||
"release": "pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags",
|
||||
"test": "pnpm lint && vitest run --coverage",
|
||||
"test:types": "tsc --noEmit"
|
||||
}
|
||||
}
|
||||
1
node_modules/unimport/node_modules/pathe/utils.d.ts
generated
vendored
Normal file
1
node_modules/unimport/node_modules/pathe/utils.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./dist/utils";
|
||||
43
node_modules/unimport/node_modules/unplugin-utils/LICENSE
generated
vendored
Normal file
43
node_modules/unimport/node_modules/unplugin-utils/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright © 2025-PRESENT Kevin Deng (https://github.com/sxzz)
|
||||
|
||||
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.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
||||
|
||||
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.
|
||||
74
node_modules/unimport/node_modules/unplugin-utils/README.md
generated
vendored
Normal file
74
node_modules/unimport/node_modules/unplugin-utils/README.md
generated
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
# unplugin-utils
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![Unit Test][unit-test-src]][unit-test-href]
|
||||
[![codecov][codecov-src]][codecov-href]
|
||||
|
||||
A set of utility functions commonly used by unplugins.
|
||||
|
||||
Thanks to [@rollup/pluginutils](https://github.com/rollup/plugins/tree/master/packages/pluginutils). This projects is heavily copied from it.
|
||||
|
||||
## Why Fork?
|
||||
|
||||
- 🌍 Platform agnostic, supports running in the browser, Node.js...
|
||||
- ✂️ Subset, smaller bundle size.
|
||||
- **💯 Coverage**: 100% test coverage.
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
npm i unplugin-utils
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
### createFilter
|
||||
|
||||
```ts
|
||||
export default function myPlugin(options = {}) {
|
||||
const filter = createFilter(options.include, options.exclude)
|
||||
|
||||
return {
|
||||
transform(code, id) {
|
||||
if (!filter(id)) return
|
||||
|
||||
// proceed with the transformation...
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### normalizePath
|
||||
|
||||
```ts
|
||||
import { normalizePath } from 'unplugin-utils'
|
||||
|
||||
normalizePath(String.raw`foo\bar`) // 'foo/bar'
|
||||
normalizePath('foo/bar') // 'foo/bar'
|
||||
```
|
||||
|
||||
## Sponsors
|
||||
|
||||
<p align="center">
|
||||
<a href="https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg">
|
||||
<img src='https://cdn.jsdelivr.net/gh/sxzz/sponsors/sponsors.svg'/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2025-PRESENT [Kevin Deng](https://github.com/sxzz)
|
||||
|
||||
[MIT](./LICENSE) Copyright (c) 2019 RollupJS Plugin Contributors (https://github.com/rollup/plugins/graphs/contributors)
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/unplugin-utils.svg
|
||||
[npm-version-href]: https://npmjs.com/package/unplugin-utils
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin-utils
|
||||
[npm-downloads-href]: https://www.npmcharts.com/compare/unplugin-utils?interval=30
|
||||
[unit-test-src]: https://github.com/sxzz/unplugin-utils/actions/workflows/unit-test.yml/badge.svg
|
||||
[unit-test-href]: https://github.com/sxzz/unplugin-utils/actions/workflows/unit-test.yml
|
||||
[codecov-src]: https://codecov.io/gh/sxzz/unplugin-utils/graph/badge.svg?token=VDWXCPSL1O
|
||||
[codecov-href]: https://codecov.io/gh/sxzz/unplugin-utils
|
||||
31
node_modules/unimport/node_modules/unplugin-utils/dist/index.d.ts
generated
vendored
Normal file
31
node_modules/unimport/node_modules/unplugin-utils/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
//#region src/filter.d.ts
|
||||
/**
|
||||
* A valid `picomatch` glob pattern, or array of patterns.
|
||||
*/
|
||||
type FilterPattern = ReadonlyArray<string | RegExp> | string | RegExp | null;
|
||||
/**
|
||||
* Constructs a filter function which can be used to determine whether or not
|
||||
* certain modules should be operated upon.
|
||||
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
||||
* @param exclude ID must not match any of the `exclude` patterns.
|
||||
* @param options Additional options.
|
||||
* @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
|
||||
* If a `string` is specified, then the value will be used as the base directory.
|
||||
* Relative paths will be resolved against `process.cwd()` first.
|
||||
* If `false`, then the patterns will not be resolved against any directory.
|
||||
* This can be useful if you want to create a filter for virtual module names.
|
||||
*/
|
||||
declare function createFilter(include?: FilterPattern, exclude?: FilterPattern, options?: {
|
||||
resolve?: string | false | null;
|
||||
}): (id: string | unknown) => boolean;
|
||||
//#endregion
|
||||
//#region src/path.d.ts
|
||||
/**
|
||||
* Converts path separators to forward slash.
|
||||
*/
|
||||
declare function normalizePath(filename: string): string;
|
||||
//#endregion
|
||||
//#region src/utils.d.ts
|
||||
declare function toArray<T>(thing: readonly T[] | T | undefined | null): readonly T[];
|
||||
//#endregion
|
||||
export { FilterPattern, createFilter, normalizePath, toArray };
|
||||
67
node_modules/unimport/node_modules/unplugin-utils/dist/index.js
generated
vendored
Normal file
67
node_modules/unimport/node_modules/unplugin-utils/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
import { isAbsolute, join, resolve } from "pathe";
|
||||
import pm from "picomatch";
|
||||
|
||||
//#region src/path.ts
|
||||
/**
|
||||
* Converts path separators to forward slash.
|
||||
*/
|
||||
function normalizePath(filename) {
|
||||
return filename.replaceAll("\\", "/");
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils.ts
|
||||
const isArray = Array.isArray;
|
||||
function toArray(thing) {
|
||||
if (isArray(thing)) return thing;
|
||||
if (thing == null) return [];
|
||||
return [thing];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/filter.ts
|
||||
const escapeMark = "[_#EsCaPe#_]";
|
||||
function getMatcherString(id, resolutionBase) {
|
||||
if (resolutionBase === false || isAbsolute(id) || id.startsWith("**")) return normalizePath(id);
|
||||
const basePath = normalizePath(resolve(resolutionBase || "")).replaceAll(/[-^$*+?.()|[\]{}]/g, `${escapeMark}$&`);
|
||||
return join(basePath, normalizePath(id)).replaceAll(escapeMark, "\\");
|
||||
}
|
||||
/**
|
||||
* Constructs a filter function which can be used to determine whether or not
|
||||
* certain modules should be operated upon.
|
||||
* @param include If `include` is omitted or has zero length, filter will return `true` by default.
|
||||
* @param exclude ID must not match any of the `exclude` patterns.
|
||||
* @param options Additional options.
|
||||
* @param options.resolve Optionally resolves the patterns against a directory other than `process.cwd()`.
|
||||
* If a `string` is specified, then the value will be used as the base directory.
|
||||
* Relative paths will be resolved against `process.cwd()` first.
|
||||
* If `false`, then the patterns will not be resolved against any directory.
|
||||
* This can be useful if you want to create a filter for virtual module names.
|
||||
*/
|
||||
function createFilter(include, exclude, options) {
|
||||
const resolutionBase = options && options.resolve;
|
||||
const getMatcher = (id) => id instanceof RegExp ? id : { test: (what) => {
|
||||
const pattern = getMatcherString(id, resolutionBase);
|
||||
return pm(pattern, { dot: true })(what);
|
||||
} };
|
||||
const includeMatchers = toArray(include).map(getMatcher);
|
||||
const excludeMatchers = toArray(exclude).map(getMatcher);
|
||||
if (!includeMatchers.length && !excludeMatchers.length) return (id) => typeof id === "string" && !id.includes("\0");
|
||||
return function result(id) {
|
||||
if (typeof id !== "string") return false;
|
||||
if (id.includes("\0")) return false;
|
||||
const pathId = normalizePath(id);
|
||||
for (const matcher of excludeMatchers) {
|
||||
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
||||
if (matcher.test(pathId)) return false;
|
||||
}
|
||||
for (const matcher of includeMatchers) {
|
||||
if (matcher instanceof RegExp) matcher.lastIndex = 0;
|
||||
if (matcher.test(pathId)) return true;
|
||||
}
|
||||
return !includeMatchers.length;
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { createFilter, normalizePath, toArray };
|
||||
67
node_modules/unimport/node_modules/unplugin-utils/package.json
generated
vendored
Normal file
67
node_modules/unimport/node_modules/unplugin-utils/package.json
generated
vendored
Normal file
@@ -0,0 +1,67 @@
|
||||
{
|
||||
"name": "unplugin-utils",
|
||||
"version": "0.3.1",
|
||||
"description": "A set of utility functions commonly used by unplugins.",
|
||||
"type": "module",
|
||||
"license": "MIT",
|
||||
"homepage": "https://github.com/sxzz/unplugin-utils#readme",
|
||||
"bugs": {
|
||||
"url": "https://github.com/sxzz/unplugin-utils/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/sxzz/unplugin-utils.git"
|
||||
},
|
||||
"author": "Kevin Deng <sxzz@sxzz.moe>",
|
||||
"funding": "https://github.com/sponsors/sxzz",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": "./dist/index.js",
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"dependencies": {
|
||||
"pathe": "^2.0.3",
|
||||
"picomatch": "^4.0.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sxzz/eslint-config": "^7.2.7",
|
||||
"@sxzz/prettier-config": "^2.2.4",
|
||||
"@types/node": "^24.7.0",
|
||||
"@types/picomatch": "^4.0.2",
|
||||
"@vitest/coverage-v8": "3.2.4",
|
||||
"bumpp": "^10.3.1",
|
||||
"eslint": "^9.37.0",
|
||||
"oxc-transform": "^0.94.0",
|
||||
"prettier": "^3.6.2",
|
||||
"tsdown": "^0.15.6",
|
||||
"tsx": "^4.20.6",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^3.2.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=20.19.0"
|
||||
},
|
||||
"prettier": "@sxzz/prettier-config",
|
||||
"tsdown": {
|
||||
"platform": "neutral",
|
||||
"exports": true
|
||||
},
|
||||
"scripts": {
|
||||
"lint": "eslint --cache .",
|
||||
"lint:fix": "pnpm run lint --fix",
|
||||
"build": "tsdown",
|
||||
"dev": "tsdown --watch",
|
||||
"test": "vitest",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"format": "prettier --cache --write .",
|
||||
"release": "bumpp"
|
||||
}
|
||||
}
|
||||
21
node_modules/unimport/node_modules/unplugin/LICENSE
generated
vendored
Normal file
21
node_modules/unimport/node_modules/unplugin/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-PRESENT Nuxt Contrib
|
||||
|
||||
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.
|
||||
35
node_modules/unimport/node_modules/unplugin/README.md
generated
vendored
Normal file
35
node_modules/unimport/node_modules/unplugin/README.md
generated
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
# Unplugin
|
||||
|
||||
[![npm version][npm-version-src]][npm-version-href]
|
||||
[![npm downloads][npm-downloads-src]][npm-downloads-href]
|
||||
[![License][license-src]][license-href]
|
||||
|
||||
Unified plugin system for build tools.
|
||||
|
||||
Currently supports:
|
||||
|
||||
- [Vite](https://vite.dev/)
|
||||
- [Rollup](https://rollupjs.org/)
|
||||
- [Webpack](https://webpack.js.org/)
|
||||
- [esbuild](https://esbuild.github.io/)
|
||||
- [Rspack](https://www.rspack.dev/)
|
||||
- [Rolldown](https://rolldown.rs/)
|
||||
- [Farm](https://www.farmfe.org/)
|
||||
- And every framework built on top of them.
|
||||
|
||||
## Documentations
|
||||
|
||||
Learn more on the [Documentation](https://unplugin.unjs.io/)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2021-PRESENT Nuxt Contrib
|
||||
|
||||
<!-- Badges -->
|
||||
|
||||
[npm-version-src]: https://img.shields.io/npm/v/unplugin?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-version-href]: https://npmjs.com/package/unplugin
|
||||
[npm-downloads-src]: https://img.shields.io/npm/dm/unplugin?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[npm-downloads-href]: https://npmjs.com/package/unplugin
|
||||
[license-src]: https://img.shields.io/github/license/unjs/unplugin.svg?style=flat&colorA=18181B&colorB=F0DB4F
|
||||
[license-href]: https://github.com/unjs/unplugin/blob/main/LICENSE
|
||||
169
node_modules/unimport/node_modules/unplugin/dist/context-CQfDPcdE.cjs
generated
vendored
Normal file
169
node_modules/unimport/node_modules/unplugin/dist/context-CQfDPcdE.cjs
generated
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
//#region rolldown:runtime
|
||||
var __create = Object.create;
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __getProtoOf = Object.getPrototypeOf;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
||||
key = keys[i];
|
||||
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
||||
get: ((k) => from[k]).bind(null, key),
|
||||
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
||||
});
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
||||
value: mod,
|
||||
enumerable: true
|
||||
}) : target, mod));
|
||||
|
||||
//#endregion
|
||||
let node_path = require("node:path");
|
||||
node_path = __toESM(node_path);
|
||||
let picomatch = require("picomatch");
|
||||
picomatch = __toESM(picomatch);
|
||||
let acorn = require("acorn");
|
||||
acorn = __toESM(acorn);
|
||||
|
||||
//#region src/utils/general.ts
|
||||
function toArray(array) {
|
||||
array = array || [];
|
||||
if (Array.isArray(array)) return array;
|
||||
return [array];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils/filter.ts
|
||||
const BACKSLASH_REGEX = /\\/g;
|
||||
function normalize(path) {
|
||||
return path.replace(BACKSLASH_REGEX, "/");
|
||||
}
|
||||
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
||||
function isAbsolute(path) {
|
||||
return ABSOLUTE_PATH_REGEX.test(path);
|
||||
}
|
||||
function getMatcherString(glob, cwd) {
|
||||
if (glob.startsWith("**") || isAbsolute(glob)) return normalize(glob);
|
||||
return normalize((0, node_path.resolve)(cwd, glob));
|
||||
}
|
||||
function patternToIdFilter(pattern) {
|
||||
if (pattern instanceof RegExp) return (id) => {
|
||||
const normalizedId = normalize(id);
|
||||
const result = pattern.test(normalizedId);
|
||||
pattern.lastIndex = 0;
|
||||
return result;
|
||||
};
|
||||
const matcher = (0, picomatch.default)(getMatcherString(pattern, process.cwd()), { dot: true });
|
||||
return (id) => {
|
||||
return matcher(normalize(id));
|
||||
};
|
||||
}
|
||||
function patternToCodeFilter(pattern) {
|
||||
if (pattern instanceof RegExp) return (code) => {
|
||||
const result = pattern.test(code);
|
||||
pattern.lastIndex = 0;
|
||||
return result;
|
||||
};
|
||||
return (code) => code.includes(pattern);
|
||||
}
|
||||
function createFilter(exclude, include) {
|
||||
if (!exclude && !include) return;
|
||||
return (input) => {
|
||||
if (exclude?.some((filter) => filter(input))) return false;
|
||||
if (include?.some((filter) => filter(input))) return true;
|
||||
return !(include && include.length > 0);
|
||||
};
|
||||
}
|
||||
function normalizeFilter(filter) {
|
||||
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
||||
if (Array.isArray(filter)) return { include: filter };
|
||||
return {
|
||||
exclude: filter.exclude ? toArray(filter.exclude) : void 0,
|
||||
include: filter.include ? toArray(filter.include) : void 0
|
||||
};
|
||||
}
|
||||
function createIdFilter(filter) {
|
||||
if (!filter) return;
|
||||
const { exclude, include } = normalizeFilter(filter);
|
||||
const excludeFilter = exclude?.map(patternToIdFilter);
|
||||
const includeFilter = include?.map(patternToIdFilter);
|
||||
return createFilter(excludeFilter, includeFilter);
|
||||
}
|
||||
function createCodeFilter(filter) {
|
||||
if (!filter) return;
|
||||
const { exclude, include } = normalizeFilter(filter);
|
||||
const excludeFilter = exclude?.map(patternToCodeFilter);
|
||||
const includeFilter = include?.map(patternToCodeFilter);
|
||||
return createFilter(excludeFilter, includeFilter);
|
||||
}
|
||||
function createFilterForId(filter) {
|
||||
const filterFunction = createIdFilter(filter);
|
||||
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
||||
}
|
||||
function createFilterForTransform(idFilter, codeFilter) {
|
||||
if (!idFilter && !codeFilter) return;
|
||||
const idFilterFunction = createIdFilter(idFilter);
|
||||
const codeFilterFunction = createCodeFilter(codeFilter);
|
||||
return (id, code) => {
|
||||
let fallback = true;
|
||||
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
||||
if (!fallback) return false;
|
||||
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
||||
return fallback;
|
||||
};
|
||||
}
|
||||
function normalizeObjectHook(name, hook) {
|
||||
let handler;
|
||||
let filter;
|
||||
if (typeof hook === "function") handler = hook;
|
||||
else {
|
||||
handler = hook.handler;
|
||||
const hookFilter = hook.filter;
|
||||
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
||||
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
||||
}
|
||||
return {
|
||||
handler,
|
||||
filter: filter || (() => true)
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils/context.ts
|
||||
function parse(code, opts = {}) {
|
||||
return acorn.Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, '__toESM', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return __toESM;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'normalizeObjectHook', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return normalizeObjectHook;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'parse', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return parse;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'toArray', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return toArray;
|
||||
}
|
||||
});
|
||||
69
node_modules/unimport/node_modules/unplugin/dist/context-CrbHoDid.cjs
generated
vendored
Normal file
69
node_modules/unimport/node_modules/unplugin/dist/context-CrbHoDid.cjs
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
const require_context = require('./context-CQfDPcdE.cjs');
|
||||
let node_path = require("node:path");
|
||||
node_path = require_context.__toESM(node_path);
|
||||
let node_buffer = require("node:buffer");
|
||||
node_buffer = require_context.__toESM(node_buffer);
|
||||
|
||||
//#region src/rspack/context.ts
|
||||
function createBuildContext(compiler, compilation, loaderContext, inputSourceMap) {
|
||||
return {
|
||||
getNativeBuildContext() {
|
||||
return {
|
||||
framework: "rspack",
|
||||
compiler,
|
||||
compilation,
|
||||
loaderContext,
|
||||
inputSourceMap
|
||||
};
|
||||
},
|
||||
addWatchFile(file) {
|
||||
const cwd = process.cwd();
|
||||
compilation.fileDependencies.add((0, node_path.resolve)(cwd, file));
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(compilation.fileDependencies);
|
||||
},
|
||||
parse: require_context.parse,
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
const { sources } = compilation.compiler.webpack;
|
||||
compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : node_buffer.Buffer.from(emittedFile.source)));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function createContext(loader) {
|
||||
return {
|
||||
error: (error) => loader.emitError(normalizeMessage(error)),
|
||||
warn: (message) => loader.emitWarning(normalizeMessage(message))
|
||||
};
|
||||
}
|
||||
function normalizeMessage(error) {
|
||||
const err = new Error(typeof error === "string" ? error : error.message);
|
||||
if (typeof error === "object") {
|
||||
err.stack = error.stack;
|
||||
err.cause = error.meta;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'createBuildContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return createBuildContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'createContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return createContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'normalizeMessage', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return normalizeMessage;
|
||||
}
|
||||
});
|
||||
120
node_modules/unimport/node_modules/unplugin/dist/context-Csj9j3eN.js
generated
vendored
Normal file
120
node_modules/unimport/node_modules/unplugin/dist/context-Csj9j3eN.js
generated
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
import { resolve } from "node:path";
|
||||
import picomatch from "picomatch";
|
||||
import { Parser } from "acorn";
|
||||
|
||||
//#region src/utils/general.ts
|
||||
function toArray(array) {
|
||||
array = array || [];
|
||||
if (Array.isArray(array)) return array;
|
||||
return [array];
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils/filter.ts
|
||||
const BACKSLASH_REGEX = /\\/g;
|
||||
function normalize$1(path$1) {
|
||||
return path$1.replace(BACKSLASH_REGEX, "/");
|
||||
}
|
||||
const ABSOLUTE_PATH_REGEX = /^(?:\/|(?:[A-Z]:)?[/\\|])/i;
|
||||
function isAbsolute$1(path$1) {
|
||||
return ABSOLUTE_PATH_REGEX.test(path$1);
|
||||
}
|
||||
function getMatcherString(glob, cwd) {
|
||||
if (glob.startsWith("**") || isAbsolute$1(glob)) return normalize$1(glob);
|
||||
return normalize$1(resolve(cwd, glob));
|
||||
}
|
||||
function patternToIdFilter(pattern) {
|
||||
if (pattern instanceof RegExp) return (id) => {
|
||||
const normalizedId = normalize$1(id);
|
||||
const result = pattern.test(normalizedId);
|
||||
pattern.lastIndex = 0;
|
||||
return result;
|
||||
};
|
||||
const matcher = picomatch(getMatcherString(pattern, process.cwd()), { dot: true });
|
||||
return (id) => {
|
||||
return matcher(normalize$1(id));
|
||||
};
|
||||
}
|
||||
function patternToCodeFilter(pattern) {
|
||||
if (pattern instanceof RegExp) return (code) => {
|
||||
const result = pattern.test(code);
|
||||
pattern.lastIndex = 0;
|
||||
return result;
|
||||
};
|
||||
return (code) => code.includes(pattern);
|
||||
}
|
||||
function createFilter(exclude, include) {
|
||||
if (!exclude && !include) return;
|
||||
return (input) => {
|
||||
if (exclude?.some((filter) => filter(input))) return false;
|
||||
if (include?.some((filter) => filter(input))) return true;
|
||||
return !(include && include.length > 0);
|
||||
};
|
||||
}
|
||||
function normalizeFilter(filter) {
|
||||
if (typeof filter === "string" || filter instanceof RegExp) return { include: [filter] };
|
||||
if (Array.isArray(filter)) return { include: filter };
|
||||
return {
|
||||
exclude: filter.exclude ? toArray(filter.exclude) : void 0,
|
||||
include: filter.include ? toArray(filter.include) : void 0
|
||||
};
|
||||
}
|
||||
function createIdFilter(filter) {
|
||||
if (!filter) return;
|
||||
const { exclude, include } = normalizeFilter(filter);
|
||||
const excludeFilter = exclude?.map(patternToIdFilter);
|
||||
const includeFilter = include?.map(patternToIdFilter);
|
||||
return createFilter(excludeFilter, includeFilter);
|
||||
}
|
||||
function createCodeFilter(filter) {
|
||||
if (!filter) return;
|
||||
const { exclude, include } = normalizeFilter(filter);
|
||||
const excludeFilter = exclude?.map(patternToCodeFilter);
|
||||
const includeFilter = include?.map(patternToCodeFilter);
|
||||
return createFilter(excludeFilter, includeFilter);
|
||||
}
|
||||
function createFilterForId(filter) {
|
||||
const filterFunction = createIdFilter(filter);
|
||||
return filterFunction ? (id) => !!filterFunction(id) : void 0;
|
||||
}
|
||||
function createFilterForTransform(idFilter, codeFilter) {
|
||||
if (!idFilter && !codeFilter) return;
|
||||
const idFilterFunction = createIdFilter(idFilter);
|
||||
const codeFilterFunction = createCodeFilter(codeFilter);
|
||||
return (id, code) => {
|
||||
let fallback = true;
|
||||
if (idFilterFunction) fallback &&= idFilterFunction(id);
|
||||
if (!fallback) return false;
|
||||
if (codeFilterFunction) fallback &&= codeFilterFunction(code);
|
||||
return fallback;
|
||||
};
|
||||
}
|
||||
function normalizeObjectHook(name, hook) {
|
||||
let handler;
|
||||
let filter;
|
||||
if (typeof hook === "function") handler = hook;
|
||||
else {
|
||||
handler = hook.handler;
|
||||
const hookFilter = hook.filter;
|
||||
if (name === "resolveId" || name === "load") filter = createFilterForId(hookFilter?.id);
|
||||
else filter = createFilterForTransform(hookFilter?.id, hookFilter?.code);
|
||||
}
|
||||
return {
|
||||
handler,
|
||||
filter: filter || (() => true)
|
||||
};
|
||||
}
|
||||
|
||||
//#endregion
|
||||
//#region src/utils/context.ts
|
||||
function parse(code, opts = {}) {
|
||||
return Parser.parse(code, {
|
||||
sourceType: "module",
|
||||
ecmaVersion: "latest",
|
||||
locations: true,
|
||||
...opts
|
||||
});
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { normalizeObjectHook as n, toArray as r, parse as t };
|
||||
92
node_modules/unimport/node_modules/unplugin/dist/context-D7WFmOmt.cjs
generated
vendored
Normal file
92
node_modules/unimport/node_modules/unplugin/dist/context-D7WFmOmt.cjs
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
const require_context = require('./context-CQfDPcdE.cjs');
|
||||
let node_path = require("node:path");
|
||||
node_path = require_context.__toESM(node_path);
|
||||
let node_buffer = require("node:buffer");
|
||||
node_buffer = require_context.__toESM(node_buffer);
|
||||
let node_process = require("node:process");
|
||||
node_process = require_context.__toESM(node_process);
|
||||
let node_module = require("node:module");
|
||||
node_module = require_context.__toESM(node_module);
|
||||
|
||||
//#region src/webpack/context.ts
|
||||
function contextOptionsFromCompilation(compilation) {
|
||||
return {
|
||||
addWatchFile(file) {
|
||||
(compilation.fileDependencies ?? compilation.compilationDependencies).add(file);
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
|
||||
}
|
||||
};
|
||||
}
|
||||
const require$1 = (0, node_module.createRequire)(require("url").pathToFileURL(__filename).href);
|
||||
function getSource(fileSource) {
|
||||
return new (require$1("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : node_buffer.Buffer.from(fileSource.buffer));
|
||||
}
|
||||
function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
|
||||
return {
|
||||
parse: require_context.parse,
|
||||
addWatchFile(id) {
|
||||
options.addWatchFile((0, node_path.resolve)(node_process.default.cwd(), id));
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
if (!compilation) throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
|
||||
compilation.emitAsset(outFileName, getSource(emittedFile.source));
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return options.getWatchFiles();
|
||||
},
|
||||
getNativeBuildContext() {
|
||||
return {
|
||||
framework: "webpack",
|
||||
compiler,
|
||||
compilation,
|
||||
loaderContext,
|
||||
inputSourceMap
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
function createContext(loader) {
|
||||
return {
|
||||
error: (error) => loader.emitError(normalizeMessage(error)),
|
||||
warn: (message) => loader.emitWarning(normalizeMessage(message))
|
||||
};
|
||||
}
|
||||
function normalizeMessage(error) {
|
||||
const err = new Error(typeof error === "string" ? error : error.message);
|
||||
if (typeof error === "object") {
|
||||
err.stack = error.stack;
|
||||
err.cause = error.meta;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'contextOptionsFromCompilation', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return contextOptionsFromCompilation;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'createBuildContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return createBuildContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'createContext', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return createContext;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'normalizeMessage', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return normalizeMessage;
|
||||
}
|
||||
});
|
||||
50
node_modules/unimport/node_modules/unplugin/dist/context-DkYlx1xL.js
generated
vendored
Normal file
50
node_modules/unimport/node_modules/unplugin/dist/context-DkYlx1xL.js
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
import { t as parse } from "./context-Csj9j3eN.js";
|
||||
import { resolve } from "node:path";
|
||||
import { Buffer } from "node:buffer";
|
||||
|
||||
//#region src/rspack/context.ts
|
||||
function createBuildContext(compiler, compilation, loaderContext, inputSourceMap) {
|
||||
return {
|
||||
getNativeBuildContext() {
|
||||
return {
|
||||
framework: "rspack",
|
||||
compiler,
|
||||
compilation,
|
||||
loaderContext,
|
||||
inputSourceMap
|
||||
};
|
||||
},
|
||||
addWatchFile(file) {
|
||||
const cwd = process.cwd();
|
||||
compilation.fileDependencies.add(resolve(cwd, file));
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(compilation.fileDependencies);
|
||||
},
|
||||
parse,
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
const { sources } = compilation.compiler.webpack;
|
||||
compilation.emitAsset(outFileName, new sources.RawSource(typeof emittedFile.source === "string" ? emittedFile.source : Buffer.from(emittedFile.source)));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
function createContext(loader) {
|
||||
return {
|
||||
error: (error) => loader.emitError(normalizeMessage(error)),
|
||||
warn: (message) => loader.emitWarning(normalizeMessage(message))
|
||||
};
|
||||
}
|
||||
function normalizeMessage(error) {
|
||||
const err = new Error(typeof error === "string" ? error : error.message);
|
||||
if (typeof error === "object") {
|
||||
err.stack = error.stack;
|
||||
err.cause = error.meta;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { createContext as n, normalizeMessage as r, createBuildContext as t };
|
||||
65
node_modules/unimport/node_modules/unplugin/dist/context-OCFO8EW1.js
generated
vendored
Normal file
65
node_modules/unimport/node_modules/unplugin/dist/context-OCFO8EW1.js
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
import { t as parse } from "./context-Csj9j3eN.js";
|
||||
import { createRequire } from "node:module";
|
||||
import { resolve } from "node:path";
|
||||
import { Buffer } from "node:buffer";
|
||||
import process from "node:process";
|
||||
|
||||
//#region src/webpack/context.ts
|
||||
function contextOptionsFromCompilation(compilation) {
|
||||
return {
|
||||
addWatchFile(file) {
|
||||
(compilation.fileDependencies ?? compilation.compilationDependencies).add(file);
|
||||
},
|
||||
getWatchFiles() {
|
||||
return Array.from(compilation.fileDependencies ?? compilation.compilationDependencies);
|
||||
}
|
||||
};
|
||||
}
|
||||
const require = createRequire(import.meta.url);
|
||||
function getSource(fileSource) {
|
||||
return new (require("webpack")).sources.RawSource(typeof fileSource === "string" ? fileSource : Buffer.from(fileSource.buffer));
|
||||
}
|
||||
function createBuildContext(options, compiler, compilation, loaderContext, inputSourceMap) {
|
||||
return {
|
||||
parse,
|
||||
addWatchFile(id) {
|
||||
options.addWatchFile(resolve(process.cwd(), id));
|
||||
},
|
||||
emitFile(emittedFile) {
|
||||
const outFileName = emittedFile.fileName || emittedFile.name;
|
||||
if (emittedFile.source && outFileName) {
|
||||
if (!compilation) throw new Error("unplugin/webpack: emitFile outside supported hooks (buildStart, buildEnd, load, transform, watchChange)");
|
||||
compilation.emitAsset(outFileName, getSource(emittedFile.source));
|
||||
}
|
||||
},
|
||||
getWatchFiles() {
|
||||
return options.getWatchFiles();
|
||||
},
|
||||
getNativeBuildContext() {
|
||||
return {
|
||||
framework: "webpack",
|
||||
compiler,
|
||||
compilation,
|
||||
loaderContext,
|
||||
inputSourceMap
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
function createContext(loader) {
|
||||
return {
|
||||
error: (error) => loader.emitError(normalizeMessage(error)),
|
||||
warn: (message) => loader.emitWarning(normalizeMessage(message))
|
||||
};
|
||||
}
|
||||
function normalizeMessage(error) {
|
||||
const err = new Error(typeof error === "string" ? error : error.message);
|
||||
if (typeof error === "object") {
|
||||
err.stack = error.stack;
|
||||
err.cause = error.meta;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { normalizeMessage as i, createBuildContext as n, createContext as r, contextOptionsFromCompilation as t };
|
||||
1013
node_modules/unimport/node_modules/unplugin/dist/index.cjs
generated
vendored
Normal file
1013
node_modules/unimport/node_modules/unplugin/dist/index.cjs
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
198
node_modules/unimport/node_modules/unplugin/dist/index.d.cts
generated
vendored
Normal file
198
node_modules/unimport/node_modules/unplugin/dist/index.d.cts
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
import { CompilationContext, JsPlugin } from "@farmfe/core";
|
||||
import { Compilation, Compiler as RspackCompiler, LoaderContext, RspackPluginInstance } from "@rspack/core";
|
||||
import { BuildOptions, Loader, Plugin as EsbuildPlugin, PluginBuild } from "esbuild";
|
||||
import { Plugin as RolldownPlugin } from "rolldown";
|
||||
import { AstNode, EmittedAsset, Plugin as RollupPlugin, PluginContextMeta, SourceMapInput } from "rollup";
|
||||
import { Plugin as UnloaderPlugin } from "unloader";
|
||||
import { Plugin as VitePlugin } from "vite";
|
||||
import { Compilation as Compilation$1, Compiler as WebpackCompiler, LoaderContext as LoaderContext$1, WebpackPluginInstance } from "webpack";
|
||||
import VirtualModulesPlugin from "webpack-virtual-modules";
|
||||
|
||||
//#region src/types.d.ts
|
||||
type Thenable<T> = T | Promise<T>;
|
||||
/**
|
||||
* Null or whatever
|
||||
*/
|
||||
type Nullable<T> = T | null | undefined;
|
||||
/**
|
||||
* Array, or not yet
|
||||
*/
|
||||
type Arrayable<T> = T | Array<T>;
|
||||
interface SourceMapCompact {
|
||||
file?: string | undefined;
|
||||
mappings: string;
|
||||
names: string[];
|
||||
sourceRoot?: string | undefined;
|
||||
sources: string[];
|
||||
sourcesContent?: (string | null)[] | undefined;
|
||||
version: number;
|
||||
}
|
||||
type TransformResult = string | {
|
||||
code: string;
|
||||
map?: SourceMapInput | SourceMapCompact | null | undefined;
|
||||
} | null | undefined | void;
|
||||
interface ExternalIdResult {
|
||||
id: string;
|
||||
external?: boolean | undefined;
|
||||
}
|
||||
type NativeBuildContext = {
|
||||
framework: "webpack";
|
||||
compiler: WebpackCompiler;
|
||||
compilation?: Compilation$1 | undefined;
|
||||
loaderContext?: LoaderContext$1<{
|
||||
unpluginName: string;
|
||||
}> | undefined;
|
||||
inputSourceMap?: any;
|
||||
} | {
|
||||
framework: "esbuild";
|
||||
build: PluginBuild;
|
||||
} | {
|
||||
framework: "rspack";
|
||||
compiler: RspackCompiler;
|
||||
compilation: Compilation;
|
||||
loaderContext?: LoaderContext | undefined;
|
||||
inputSourceMap?: any;
|
||||
} | {
|
||||
framework: "farm";
|
||||
context: CompilationContext;
|
||||
};
|
||||
interface UnpluginBuildContext {
|
||||
addWatchFile: (id: string) => void;
|
||||
emitFile: (emittedFile: EmittedAsset) => void;
|
||||
getWatchFiles: () => string[];
|
||||
parse: (input: string, options?: any) => AstNode;
|
||||
getNativeBuildContext?: (() => NativeBuildContext) | undefined;
|
||||
}
|
||||
type StringOrRegExp = string | RegExp;
|
||||
type FilterPattern = Arrayable<StringOrRegExp>;
|
||||
type StringFilter = FilterPattern | {
|
||||
include?: FilterPattern | undefined;
|
||||
exclude?: FilterPattern | undefined;
|
||||
};
|
||||
interface HookFilter {
|
||||
id?: StringFilter | undefined;
|
||||
code?: StringFilter | undefined;
|
||||
}
|
||||
interface ObjectHook<T extends HookFnMap[keyof HookFnMap], F extends keyof HookFilter> {
|
||||
filter?: Pick<HookFilter, F> | undefined;
|
||||
handler: T;
|
||||
}
|
||||
type Hook<T extends HookFnMap[keyof HookFnMap], F extends keyof HookFilter> = T | ObjectHook<T, F>;
|
||||
interface HookFnMap {
|
||||
buildStart: (this: UnpluginBuildContext) => Thenable<void>;
|
||||
buildEnd: (this: UnpluginBuildContext) => Thenable<void>;
|
||||
transform: (this: UnpluginBuildContext & UnpluginContext, code: string, id: string) => Thenable<TransformResult>;
|
||||
load: (this: UnpluginBuildContext & UnpluginContext, id: string) => Thenable<TransformResult>;
|
||||
resolveId: (this: UnpluginBuildContext & UnpluginContext, id: string, importer: string | undefined, options: {
|
||||
isEntry: boolean;
|
||||
}) => Thenable<string | ExternalIdResult | null | undefined>;
|
||||
writeBundle: (this: void) => Thenable<void>;
|
||||
}
|
||||
interface UnpluginOptions {
|
||||
name: string;
|
||||
enforce?: "post" | "pre" | undefined;
|
||||
buildStart?: HookFnMap["buildStart"] | undefined;
|
||||
buildEnd?: HookFnMap["buildEnd"] | undefined;
|
||||
transform?: Hook<HookFnMap["transform"], "code" | "id"> | undefined;
|
||||
load?: Hook<HookFnMap["load"], "id"> | undefined;
|
||||
resolveId?: Hook<HookFnMap["resolveId"], "id"> | undefined;
|
||||
writeBundle?: HookFnMap["writeBundle"] | undefined;
|
||||
watchChange?: ((this: UnpluginBuildContext, id: string, change: {
|
||||
event: "create" | "update" | "delete";
|
||||
}) => void) | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be loaded.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*
|
||||
* @deprecated Use `load.filter` instead.
|
||||
*/
|
||||
loadInclude?: ((id: string) => boolean | null | undefined) | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be transformed.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*
|
||||
* @deprecated Use `transform.filter` instead.
|
||||
*/
|
||||
transformInclude?: ((id: string) => boolean | null | undefined) | undefined;
|
||||
rollup?: Partial<RollupPlugin> | undefined;
|
||||
webpack?: ((compiler: WebpackCompiler) => void) | undefined;
|
||||
rspack?: ((compiler: RspackCompiler) => void) | undefined;
|
||||
vite?: Partial<VitePlugin> | undefined;
|
||||
unloader?: Partial<UnloaderPlugin> | undefined;
|
||||
rolldown?: Partial<RolldownPlugin> | undefined;
|
||||
esbuild?: {
|
||||
onResolveFilter?: RegExp | undefined;
|
||||
onLoadFilter?: RegExp | undefined;
|
||||
loader?: Loader | ((code: string, id: string) => Loader) | undefined;
|
||||
setup?: ((build: PluginBuild) => void | Promise<void>) | undefined;
|
||||
config?: ((options: BuildOptions) => void) | undefined;
|
||||
} | undefined;
|
||||
farm?: Partial<JsPlugin> | undefined;
|
||||
}
|
||||
interface ResolvedUnpluginOptions extends UnpluginOptions {
|
||||
__vfs?: VirtualModulesPlugin | undefined;
|
||||
__vfsModules?: Map<string, Promise<unknown>> | Set<string> | undefined;
|
||||
__virtualModulePrefix: string;
|
||||
}
|
||||
type UnpluginFactory<UserOptions, Nested extends boolean = boolean> = (options: UserOptions, meta: UnpluginContextMeta) => Nested extends true ? Array<UnpluginOptions> : UnpluginOptions;
|
||||
type UnpluginFactoryOutput<UserOptions, Return> = undefined extends UserOptions ? (options?: UserOptions | undefined) => Return : (options: UserOptions) => Return;
|
||||
interface UnpluginInstance<UserOptions, Nested extends boolean = boolean> {
|
||||
rollup: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<RollupPlugin> : RollupPlugin>;
|
||||
vite: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<VitePlugin> : VitePlugin>;
|
||||
rolldown: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<RolldownPlugin> : RolldownPlugin>;
|
||||
webpack: UnpluginFactoryOutput<UserOptions, WebpackPluginInstance>;
|
||||
rspack: UnpluginFactoryOutput<UserOptions, RspackPluginInstance>;
|
||||
esbuild: UnpluginFactoryOutput<UserOptions, EsbuildPlugin>;
|
||||
unloader: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<UnloaderPlugin> : UnloaderPlugin>;
|
||||
farm: UnpluginFactoryOutput<UserOptions, JsPlugin>;
|
||||
raw: UnpluginFactory<UserOptions, Nested>;
|
||||
}
|
||||
type UnpluginContextMeta = Partial<PluginContextMeta> & ({
|
||||
framework: "rollup" | "vite" | "rolldown" | "farm" | "unloader";
|
||||
} | {
|
||||
framework: "webpack";
|
||||
webpack: {
|
||||
compiler: WebpackCompiler;
|
||||
};
|
||||
} | {
|
||||
framework: "esbuild";
|
||||
/** Set the host plugin name of esbuild when returning multiple plugins */
|
||||
esbuildHostName?: string | undefined;
|
||||
} | {
|
||||
framework: "rspack";
|
||||
rspack: {
|
||||
compiler: RspackCompiler;
|
||||
};
|
||||
});
|
||||
interface UnpluginMessage {
|
||||
name?: string | undefined;
|
||||
id?: string | undefined;
|
||||
message: string;
|
||||
stack?: string | undefined;
|
||||
code?: string | undefined;
|
||||
plugin?: string | undefined;
|
||||
pluginCode?: unknown | undefined;
|
||||
loc?: {
|
||||
column: number;
|
||||
file?: string | undefined;
|
||||
line: number;
|
||||
} | undefined;
|
||||
meta?: any;
|
||||
}
|
||||
interface UnpluginContext {
|
||||
error: (message: string | UnpluginMessage) => void;
|
||||
warn: (message: string | UnpluginMessage) => void;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/define.d.ts
|
||||
declare function createUnplugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;
|
||||
declare function createEsbuildPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["esbuild"];
|
||||
declare function createRollupPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rollup"];
|
||||
declare function createVitePlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["vite"];
|
||||
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rolldown"];
|
||||
declare function createWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["webpack"];
|
||||
declare function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rspack"];
|
||||
declare function createFarmPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["farm"];
|
||||
declare function createUnloaderPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["unloader"];
|
||||
//#endregion
|
||||
export { Arrayable, type EsbuildPlugin, ExternalIdResult, FilterPattern, Hook, HookFilter, HookFnMap, NativeBuildContext, Nullable, ObjectHook, ResolvedUnpluginOptions, type RolldownPlugin, type RollupPlugin, type RspackCompiler, type RspackPluginInstance, SourceMapCompact, StringFilter, StringOrRegExp, Thenable, TransformResult, type UnloaderPlugin, UnpluginBuildContext, UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginFactoryOutput, UnpluginInstance, UnpluginMessage, UnpluginOptions, type VitePlugin, type WebpackCompiler, type WebpackPluginInstance, createEsbuildPlugin, createFarmPlugin, createRolldownPlugin, createRollupPlugin, createRspackPlugin, createUnloaderPlugin, createUnplugin, createVitePlugin, createWebpackPlugin };
|
||||
198
node_modules/unimport/node_modules/unplugin/dist/index.d.ts
generated
vendored
Normal file
198
node_modules/unimport/node_modules/unplugin/dist/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,198 @@
|
||||
import VirtualModulesPlugin from "webpack-virtual-modules";
|
||||
import { CompilationContext, JsPlugin } from "@farmfe/core";
|
||||
import { Compilation, Compiler as RspackCompiler, LoaderContext, RspackPluginInstance } from "@rspack/core";
|
||||
import { BuildOptions, Loader, Plugin as EsbuildPlugin, PluginBuild } from "esbuild";
|
||||
import { Plugin as RolldownPlugin } from "rolldown";
|
||||
import { AstNode, EmittedAsset, Plugin as RollupPlugin, PluginContextMeta, SourceMapInput } from "rollup";
|
||||
import { Plugin as UnloaderPlugin } from "unloader";
|
||||
import { Plugin as VitePlugin } from "vite";
|
||||
import { Compilation as Compilation$1, Compiler as WebpackCompiler, LoaderContext as LoaderContext$1, WebpackPluginInstance } from "webpack";
|
||||
|
||||
//#region src/types.d.ts
|
||||
type Thenable<T> = T | Promise<T>;
|
||||
/**
|
||||
* Null or whatever
|
||||
*/
|
||||
type Nullable<T> = T | null | undefined;
|
||||
/**
|
||||
* Array, or not yet
|
||||
*/
|
||||
type Arrayable<T> = T | Array<T>;
|
||||
interface SourceMapCompact {
|
||||
file?: string | undefined;
|
||||
mappings: string;
|
||||
names: string[];
|
||||
sourceRoot?: string | undefined;
|
||||
sources: string[];
|
||||
sourcesContent?: (string | null)[] | undefined;
|
||||
version: number;
|
||||
}
|
||||
type TransformResult = string | {
|
||||
code: string;
|
||||
map?: SourceMapInput | SourceMapCompact | null | undefined;
|
||||
} | null | undefined | void;
|
||||
interface ExternalIdResult {
|
||||
id: string;
|
||||
external?: boolean | undefined;
|
||||
}
|
||||
type NativeBuildContext = {
|
||||
framework: "webpack";
|
||||
compiler: WebpackCompiler;
|
||||
compilation?: Compilation$1 | undefined;
|
||||
loaderContext?: LoaderContext$1<{
|
||||
unpluginName: string;
|
||||
}> | undefined;
|
||||
inputSourceMap?: any;
|
||||
} | {
|
||||
framework: "esbuild";
|
||||
build: PluginBuild;
|
||||
} | {
|
||||
framework: "rspack";
|
||||
compiler: RspackCompiler;
|
||||
compilation: Compilation;
|
||||
loaderContext?: LoaderContext | undefined;
|
||||
inputSourceMap?: any;
|
||||
} | {
|
||||
framework: "farm";
|
||||
context: CompilationContext;
|
||||
};
|
||||
interface UnpluginBuildContext {
|
||||
addWatchFile: (id: string) => void;
|
||||
emitFile: (emittedFile: EmittedAsset) => void;
|
||||
getWatchFiles: () => string[];
|
||||
parse: (input: string, options?: any) => AstNode;
|
||||
getNativeBuildContext?: (() => NativeBuildContext) | undefined;
|
||||
}
|
||||
type StringOrRegExp = string | RegExp;
|
||||
type FilterPattern = Arrayable<StringOrRegExp>;
|
||||
type StringFilter = FilterPattern | {
|
||||
include?: FilterPattern | undefined;
|
||||
exclude?: FilterPattern | undefined;
|
||||
};
|
||||
interface HookFilter {
|
||||
id?: StringFilter | undefined;
|
||||
code?: StringFilter | undefined;
|
||||
}
|
||||
interface ObjectHook<T extends HookFnMap[keyof HookFnMap], F extends keyof HookFilter> {
|
||||
filter?: Pick<HookFilter, F> | undefined;
|
||||
handler: T;
|
||||
}
|
||||
type Hook<T extends HookFnMap[keyof HookFnMap], F extends keyof HookFilter> = T | ObjectHook<T, F>;
|
||||
interface HookFnMap {
|
||||
buildStart: (this: UnpluginBuildContext) => Thenable<void>;
|
||||
buildEnd: (this: UnpluginBuildContext) => Thenable<void>;
|
||||
transform: (this: UnpluginBuildContext & UnpluginContext, code: string, id: string) => Thenable<TransformResult>;
|
||||
load: (this: UnpluginBuildContext & UnpluginContext, id: string) => Thenable<TransformResult>;
|
||||
resolveId: (this: UnpluginBuildContext & UnpluginContext, id: string, importer: string | undefined, options: {
|
||||
isEntry: boolean;
|
||||
}) => Thenable<string | ExternalIdResult | null | undefined>;
|
||||
writeBundle: (this: void) => Thenable<void>;
|
||||
}
|
||||
interface UnpluginOptions {
|
||||
name: string;
|
||||
enforce?: "post" | "pre" | undefined;
|
||||
buildStart?: HookFnMap["buildStart"] | undefined;
|
||||
buildEnd?: HookFnMap["buildEnd"] | undefined;
|
||||
transform?: Hook<HookFnMap["transform"], "code" | "id"> | undefined;
|
||||
load?: Hook<HookFnMap["load"], "id"> | undefined;
|
||||
resolveId?: Hook<HookFnMap["resolveId"], "id"> | undefined;
|
||||
writeBundle?: HookFnMap["writeBundle"] | undefined;
|
||||
watchChange?: ((this: UnpluginBuildContext, id: string, change: {
|
||||
event: "create" | "update" | "delete";
|
||||
}) => void) | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be loaded.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*
|
||||
* @deprecated Use `load.filter` instead.
|
||||
*/
|
||||
loadInclude?: ((id: string) => boolean | null | undefined) | undefined;
|
||||
/**
|
||||
* Custom predicate function to filter modules to be transformed.
|
||||
* When omitted, all modules will be included (might have potential perf impact on Webpack).
|
||||
*
|
||||
* @deprecated Use `transform.filter` instead.
|
||||
*/
|
||||
transformInclude?: ((id: string) => boolean | null | undefined) | undefined;
|
||||
rollup?: Partial<RollupPlugin> | undefined;
|
||||
webpack?: ((compiler: WebpackCompiler) => void) | undefined;
|
||||
rspack?: ((compiler: RspackCompiler) => void) | undefined;
|
||||
vite?: Partial<VitePlugin> | undefined;
|
||||
unloader?: Partial<UnloaderPlugin> | undefined;
|
||||
rolldown?: Partial<RolldownPlugin> | undefined;
|
||||
esbuild?: {
|
||||
onResolveFilter?: RegExp | undefined;
|
||||
onLoadFilter?: RegExp | undefined;
|
||||
loader?: Loader | ((code: string, id: string) => Loader) | undefined;
|
||||
setup?: ((build: PluginBuild) => void | Promise<void>) | undefined;
|
||||
config?: ((options: BuildOptions) => void) | undefined;
|
||||
} | undefined;
|
||||
farm?: Partial<JsPlugin> | undefined;
|
||||
}
|
||||
interface ResolvedUnpluginOptions extends UnpluginOptions {
|
||||
__vfs?: VirtualModulesPlugin | undefined;
|
||||
__vfsModules?: Map<string, Promise<unknown>> | Set<string> | undefined;
|
||||
__virtualModulePrefix: string;
|
||||
}
|
||||
type UnpluginFactory<UserOptions, Nested extends boolean = boolean> = (options: UserOptions, meta: UnpluginContextMeta) => Nested extends true ? Array<UnpluginOptions> : UnpluginOptions;
|
||||
type UnpluginFactoryOutput<UserOptions, Return> = undefined extends UserOptions ? (options?: UserOptions | undefined) => Return : (options: UserOptions) => Return;
|
||||
interface UnpluginInstance<UserOptions, Nested extends boolean = boolean> {
|
||||
rollup: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<RollupPlugin> : RollupPlugin>;
|
||||
vite: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<VitePlugin> : VitePlugin>;
|
||||
rolldown: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<RolldownPlugin> : RolldownPlugin>;
|
||||
webpack: UnpluginFactoryOutput<UserOptions, WebpackPluginInstance>;
|
||||
rspack: UnpluginFactoryOutput<UserOptions, RspackPluginInstance>;
|
||||
esbuild: UnpluginFactoryOutput<UserOptions, EsbuildPlugin>;
|
||||
unloader: UnpluginFactoryOutput<UserOptions, Nested extends true ? Array<UnloaderPlugin> : UnloaderPlugin>;
|
||||
farm: UnpluginFactoryOutput<UserOptions, JsPlugin>;
|
||||
raw: UnpluginFactory<UserOptions, Nested>;
|
||||
}
|
||||
type UnpluginContextMeta = Partial<PluginContextMeta> & ({
|
||||
framework: "rollup" | "vite" | "rolldown" | "farm" | "unloader";
|
||||
} | {
|
||||
framework: "webpack";
|
||||
webpack: {
|
||||
compiler: WebpackCompiler;
|
||||
};
|
||||
} | {
|
||||
framework: "esbuild";
|
||||
/** Set the host plugin name of esbuild when returning multiple plugins */
|
||||
esbuildHostName?: string | undefined;
|
||||
} | {
|
||||
framework: "rspack";
|
||||
rspack: {
|
||||
compiler: RspackCompiler;
|
||||
};
|
||||
});
|
||||
interface UnpluginMessage {
|
||||
name?: string | undefined;
|
||||
id?: string | undefined;
|
||||
message: string;
|
||||
stack?: string | undefined;
|
||||
code?: string | undefined;
|
||||
plugin?: string | undefined;
|
||||
pluginCode?: unknown | undefined;
|
||||
loc?: {
|
||||
column: number;
|
||||
file?: string | undefined;
|
||||
line: number;
|
||||
} | undefined;
|
||||
meta?: any;
|
||||
}
|
||||
interface UnpluginContext {
|
||||
error: (message: string | UnpluginMessage) => void;
|
||||
warn: (message: string | UnpluginMessage) => void;
|
||||
}
|
||||
//#endregion
|
||||
//#region src/define.d.ts
|
||||
declare function createUnplugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions, Nested>;
|
||||
declare function createEsbuildPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["esbuild"];
|
||||
declare function createRollupPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rollup"];
|
||||
declare function createVitePlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["vite"];
|
||||
declare function createRolldownPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rolldown"];
|
||||
declare function createWebpackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["webpack"];
|
||||
declare function createRspackPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["rspack"];
|
||||
declare function createFarmPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["farm"];
|
||||
declare function createUnloaderPlugin<UserOptions, Nested extends boolean = boolean>(factory: UnpluginFactory<UserOptions, Nested>): UnpluginInstance<UserOptions>["unloader"];
|
||||
//#endregion
|
||||
export { Arrayable, type EsbuildPlugin, ExternalIdResult, FilterPattern, Hook, HookFilter, HookFnMap, NativeBuildContext, Nullable, ObjectHook, ResolvedUnpluginOptions, type RolldownPlugin, type RollupPlugin, type RspackCompiler, type RspackPluginInstance, SourceMapCompact, StringFilter, StringOrRegExp, Thenable, TransformResult, type UnloaderPlugin, UnpluginBuildContext, UnpluginContext, UnpluginContextMeta, UnpluginFactory, UnpluginFactoryOutput, UnpluginInstance, UnpluginMessage, UnpluginOptions, type VitePlugin, type WebpackCompiler, type WebpackPluginInstance, createEsbuildPlugin, createFarmPlugin, createRolldownPlugin, createRollupPlugin, createRspackPlugin, createUnloaderPlugin, createUnplugin, createVitePlugin, createWebpackPlugin };
|
||||
1005
node_modules/unimport/node_modules/unplugin/dist/index.js
generated
vendored
Normal file
1005
node_modules/unimport/node_modules/unplugin/dist/index.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
27
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.cjs
generated
vendored
Normal file
27
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.cjs
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
const require_context = require('../../context-CQfDPcdE.cjs');
|
||||
const require_webpack_like = require('../../webpack-like-DDVwPJ4e.cjs');
|
||||
const require_context$1 = require('../../context-CrbHoDid.cjs');
|
||||
const require_utils = require('../../utils-CJMEEaD7.cjs');
|
||||
|
||||
//#region src/rspack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id) return callback(null, source, map);
|
||||
if (require_utils.isVirtualModuleId(id, plugin)) id = require_utils.decodeVirtualModuleId(id, plugin);
|
||||
const context = require_context$1.createContext(this);
|
||||
const { handler } = require_context.normalizeObjectHook("load", plugin.load);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, this._compilation && require_context$1.createBuildContext(this._compiler, this._compilation, this), context), require_webpack_like.normalizeAbsolutePath(id));
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, res.map ?? map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
module.exports = load;
|
||||
5
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.d.cts
generated
vendored
Normal file
5
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.d.cts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from "@rspack/core";
|
||||
|
||||
//#region src/rspack/loaders/load.d.ts
|
||||
declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
export = load;
|
||||
6
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.d.ts
generated
vendored
Normal file
6
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "@rspack/core";
|
||||
|
||||
//#region src/rspack/loaders/load.d.ts
|
||||
declare function load(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { load as default };
|
||||
27
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.js
generated
vendored
Normal file
27
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/load.js
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { n as normalizeObjectHook } from "../../context-Csj9j3eN.js";
|
||||
import { t as normalizeAbsolutePath } from "../../webpack-like-DFGTNSuV.js";
|
||||
import { n as createContext, t as createBuildContext } from "../../context-DkYlx1xL.js";
|
||||
import { i as isVirtualModuleId, n as decodeVirtualModuleId } from "../../utils-BosfZ0pB.js";
|
||||
|
||||
//#region src/rspack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id) return callback(null, source, map);
|
||||
if (isVirtualModuleId(id, plugin)) id = decodeVirtualModuleId(id, plugin);
|
||||
const context = createContext(this);
|
||||
const { handler } = normalizeObjectHook("load", plugin.load);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, this._compilation && createBuildContext(this._compiler, this._compilation, this), context), normalizeAbsolutePath(id));
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, res.map ?? map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { load as default };
|
||||
25
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.cjs
generated
vendored
Normal file
25
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.cjs
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
const require_context = require('../../context-CQfDPcdE.cjs');
|
||||
const require_context$1 = require('../../context-CrbHoDid.cjs');
|
||||
|
||||
//#region src/rspack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
if (!plugin?.transform) return callback(null, source, map);
|
||||
const id = this.resource;
|
||||
const context = require_context$1.createContext(this);
|
||||
const { handler, filter } = require_context.normalizeObjectHook("transform", plugin.transform);
|
||||
if (!filter(this.resource, source)) return callback(null, source, map);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, this._compilation && require_context$1.createBuildContext(this._compiler, this._compilation, this, map), context), source, id);
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, map == null ? map : res.map || map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
module.exports = transform;
|
||||
5
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.d.cts
generated
vendored
Normal file
5
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.d.cts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from "@rspack/core";
|
||||
|
||||
//#region src/rspack/loaders/transform.d.ts
|
||||
declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
export = transform;
|
||||
6
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.d.ts
generated
vendored
Normal file
6
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "@rspack/core";
|
||||
|
||||
//#region src/rspack/loaders/transform.d.ts
|
||||
declare function transform(this: LoaderContext, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
25
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.js
generated
vendored
Normal file
25
node_modules/unimport/node_modules/unplugin/dist/rspack/loaders/transform.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import { n as normalizeObjectHook } from "../../context-Csj9j3eN.js";
|
||||
import { n as createContext, t as createBuildContext } from "../../context-DkYlx1xL.js";
|
||||
|
||||
//#region src/rspack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
if (!plugin?.transform) return callback(null, source, map);
|
||||
const id = this.resource;
|
||||
const context = createContext(this);
|
||||
const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
|
||||
if (!filter(this.resource, source)) return callback(null, source, map);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, this._compilation && createBuildContext(this._compiler, this._compilation, this, map), context), source, id);
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, map == null ? map : res.map || map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
54
node_modules/unimport/node_modules/unplugin/dist/utils-BosfZ0pB.js
generated
vendored
Normal file
54
node_modules/unimport/node_modules/unplugin/dist/utils-BosfZ0pB.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import fs from "node:fs";
|
||||
import { basename, dirname, resolve } from "node:path";
|
||||
|
||||
//#region src/rspack/utils.ts
|
||||
function encodeVirtualModuleId(id, plugin) {
|
||||
return resolve(plugin.__virtualModulePrefix, encodeURIComponent(id));
|
||||
}
|
||||
function decodeVirtualModuleId(encoded, _plugin) {
|
||||
return decodeURIComponent(basename(encoded));
|
||||
}
|
||||
function isVirtualModuleId(encoded, plugin) {
|
||||
return dirname(encoded) === plugin.__virtualModulePrefix;
|
||||
}
|
||||
var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin {
|
||||
name = "FakeVirtualModulesPlugin";
|
||||
static counters = /* @__PURE__ */ new Map();
|
||||
static initCleanup = false;
|
||||
constructor(plugin) {
|
||||
this.plugin = plugin;
|
||||
if (!FakeVirtualModulesPlugin.initCleanup) {
|
||||
FakeVirtualModulesPlugin.initCleanup = true;
|
||||
process.once("exit", () => {
|
||||
FakeVirtualModulesPlugin.counters.forEach((_, dir) => {
|
||||
fs.rmSync(dir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
apply(compiler) {
|
||||
const dir = this.plugin.__virtualModulePrefix;
|
||||
if (!fs.existsSync(dir)) fs.mkdirSync(dir, { recursive: true });
|
||||
const counter = FakeVirtualModulesPlugin.counters.get(dir) ?? 0;
|
||||
FakeVirtualModulesPlugin.counters.set(dir, counter + 1);
|
||||
compiler.hooks.shutdown.tap(this.name, () => {
|
||||
const counter$1 = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
|
||||
if (counter$1 === 0) {
|
||||
FakeVirtualModulesPlugin.counters.delete(dir);
|
||||
fs.rmSync(dir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
} else FakeVirtualModulesPlugin.counters.set(dir, counter$1);
|
||||
});
|
||||
}
|
||||
async writeModule(file) {
|
||||
return fs.promises.writeFile(file, "");
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
export { isVirtualModuleId as i, decodeVirtualModuleId as n, encodeVirtualModuleId as r, FakeVirtualModulesPlugin as t };
|
||||
80
node_modules/unimport/node_modules/unplugin/dist/utils-CJMEEaD7.cjs
generated
vendored
Normal file
80
node_modules/unimport/node_modules/unplugin/dist/utils-CJMEEaD7.cjs
generated
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
const require_context = require('./context-CQfDPcdE.cjs');
|
||||
let node_fs = require("node:fs");
|
||||
node_fs = require_context.__toESM(node_fs);
|
||||
let node_path = require("node:path");
|
||||
node_path = require_context.__toESM(node_path);
|
||||
|
||||
//#region src/rspack/utils.ts
|
||||
function encodeVirtualModuleId(id, plugin) {
|
||||
return (0, node_path.resolve)(plugin.__virtualModulePrefix, encodeURIComponent(id));
|
||||
}
|
||||
function decodeVirtualModuleId(encoded, _plugin) {
|
||||
return decodeURIComponent((0, node_path.basename)(encoded));
|
||||
}
|
||||
function isVirtualModuleId(encoded, plugin) {
|
||||
return (0, node_path.dirname)(encoded) === plugin.__virtualModulePrefix;
|
||||
}
|
||||
var FakeVirtualModulesPlugin = class FakeVirtualModulesPlugin {
|
||||
name = "FakeVirtualModulesPlugin";
|
||||
static counters = /* @__PURE__ */ new Map();
|
||||
static initCleanup = false;
|
||||
constructor(plugin) {
|
||||
this.plugin = plugin;
|
||||
if (!FakeVirtualModulesPlugin.initCleanup) {
|
||||
FakeVirtualModulesPlugin.initCleanup = true;
|
||||
process.once("exit", () => {
|
||||
FakeVirtualModulesPlugin.counters.forEach((_, dir) => {
|
||||
node_fs.default.rmSync(dir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
apply(compiler) {
|
||||
const dir = this.plugin.__virtualModulePrefix;
|
||||
if (!node_fs.default.existsSync(dir)) node_fs.default.mkdirSync(dir, { recursive: true });
|
||||
const counter = FakeVirtualModulesPlugin.counters.get(dir) ?? 0;
|
||||
FakeVirtualModulesPlugin.counters.set(dir, counter + 1);
|
||||
compiler.hooks.shutdown.tap(this.name, () => {
|
||||
const counter$1 = (FakeVirtualModulesPlugin.counters.get(dir) ?? 1) - 1;
|
||||
if (counter$1 === 0) {
|
||||
FakeVirtualModulesPlugin.counters.delete(dir);
|
||||
node_fs.default.rmSync(dir, {
|
||||
recursive: true,
|
||||
force: true
|
||||
});
|
||||
} else FakeVirtualModulesPlugin.counters.set(dir, counter$1);
|
||||
});
|
||||
}
|
||||
async writeModule(file) {
|
||||
return node_fs.default.promises.writeFile(file, "");
|
||||
}
|
||||
};
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'FakeVirtualModulesPlugin', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return FakeVirtualModulesPlugin;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'decodeVirtualModuleId', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return decodeVirtualModuleId;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'encodeVirtualModuleId', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return encodeVirtualModuleId;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'isVirtualModuleId', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return isVirtualModuleId;
|
||||
}
|
||||
});
|
||||
45
node_modules/unimport/node_modules/unplugin/dist/webpack-like-DDVwPJ4e.cjs
generated
vendored
Normal file
45
node_modules/unimport/node_modules/unplugin/dist/webpack-like-DDVwPJ4e.cjs
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
const require_context = require('./context-CQfDPcdE.cjs');
|
||||
let node_path = require("node:path");
|
||||
node_path = require_context.__toESM(node_path);
|
||||
|
||||
//#region src/utils/webpack-like.ts
|
||||
function transformUse(data, plugin, transformLoader) {
|
||||
if (data.resource == null) return [];
|
||||
const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
|
||||
if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
|
||||
const { filter } = require_context.normalizeObjectHook("load", plugin.transform);
|
||||
if (!filter(id)) return [];
|
||||
return [{
|
||||
loader: transformLoader,
|
||||
options: { plugin },
|
||||
ident: plugin.name
|
||||
}];
|
||||
}
|
||||
/**
|
||||
* Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
|
||||
* the input path to the native os format. This is useful in cases where we want to normalize
|
||||
* the `id` argument of a hook. Any absolute ids should be in the default format
|
||||
* of the operating system. Any relative imports or node_module imports should remain
|
||||
* untouched.
|
||||
*
|
||||
* @param path - Path to normalize.
|
||||
* @returns a new normalized path.
|
||||
*/
|
||||
function normalizeAbsolutePath(path) {
|
||||
if ((0, node_path.isAbsolute)(path)) return (0, node_path.normalize)(path);
|
||||
else return path;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
Object.defineProperty(exports, 'normalizeAbsolutePath', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return normalizeAbsolutePath;
|
||||
}
|
||||
});
|
||||
Object.defineProperty(exports, 'transformUse', {
|
||||
enumerable: true,
|
||||
get: function () {
|
||||
return transformUse;
|
||||
}
|
||||
});
|
||||
33
node_modules/unimport/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
generated
vendored
Normal file
33
node_modules/unimport/node_modules/unplugin/dist/webpack-like-DFGTNSuV.js
generated
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import { n as normalizeObjectHook } from "./context-Csj9j3eN.js";
|
||||
import { isAbsolute, normalize } from "node:path";
|
||||
|
||||
//#region src/utils/webpack-like.ts
|
||||
function transformUse(data, plugin, transformLoader) {
|
||||
if (data.resource == null) return [];
|
||||
const id = normalizeAbsolutePath(data.resource + (data.resourceQuery || ""));
|
||||
if (plugin.transformInclude && !plugin.transformInclude(id)) return [];
|
||||
const { filter } = normalizeObjectHook("load", plugin.transform);
|
||||
if (!filter(id)) return [];
|
||||
return [{
|
||||
loader: transformLoader,
|
||||
options: { plugin },
|
||||
ident: plugin.name
|
||||
}];
|
||||
}
|
||||
/**
|
||||
* Normalizes a given path when it's absolute. Normalizing means returning a new path by converting
|
||||
* the input path to the native os format. This is useful in cases where we want to normalize
|
||||
* the `id` argument of a hook. Any absolute ids should be in the default format
|
||||
* of the operating system. Any relative imports or node_module imports should remain
|
||||
* untouched.
|
||||
*
|
||||
* @param path - Path to normalize.
|
||||
* @returns a new normalized path.
|
||||
*/
|
||||
function normalizeAbsolutePath(path$1) {
|
||||
if (isAbsolute(path$1)) return normalize(path$1);
|
||||
else return path$1;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { transformUse as n, normalizeAbsolutePath as t };
|
||||
28
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.cjs
generated
vendored
Normal file
28
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.cjs
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
const require_context = require('../../context-CQfDPcdE.cjs');
|
||||
const require_webpack_like = require('../../webpack-like-DDVwPJ4e.cjs');
|
||||
const require_context$1 = require('../../context-D7WFmOmt.cjs');
|
||||
|
||||
//#region src/webpack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id) return callback(null, source, map);
|
||||
if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
||||
const context = require_context$1.createContext(this);
|
||||
const { handler } = require_context.normalizeObjectHook("load", plugin.load);
|
||||
const res = await handler.call(Object.assign({}, require_context$1.createBuildContext({
|
||||
addWatchFile: (file) => {
|
||||
this.addDependency(file);
|
||||
},
|
||||
getWatchFiles: () => {
|
||||
return this.getDependencies();
|
||||
}
|
||||
}, this._compiler, this._compilation, this), context), require_webpack_like.normalizeAbsolutePath(id));
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, res.map ?? map);
|
||||
else callback(null, res, map);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
module.exports = load;
|
||||
5
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.d.cts
generated
vendored
Normal file
5
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.d.cts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from "webpack";
|
||||
|
||||
//#region src/webpack/loaders/load.d.ts
|
||||
declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
export = load;
|
||||
6
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.d.ts
generated
vendored
Normal file
6
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "webpack";
|
||||
|
||||
//#region src/webpack/loaders/load.d.ts
|
||||
declare function load(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { load as default };
|
||||
28
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.js
generated
vendored
Normal file
28
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/load.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
import { n as normalizeObjectHook } from "../../context-Csj9j3eN.js";
|
||||
import { t as normalizeAbsolutePath } from "../../webpack-like-DFGTNSuV.js";
|
||||
import { n as createBuildContext, r as createContext } from "../../context-OCFO8EW1.js";
|
||||
|
||||
//#region src/webpack/loaders/load.ts
|
||||
async function load(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
let id = this.resource;
|
||||
if (!plugin?.load || !id) return callback(null, source, map);
|
||||
if (id.startsWith(plugin.__virtualModulePrefix)) id = decodeURIComponent(id.slice(plugin.__virtualModulePrefix.length));
|
||||
const context = createContext(this);
|
||||
const { handler } = normalizeObjectHook("load", plugin.load);
|
||||
const res = await handler.call(Object.assign({}, createBuildContext({
|
||||
addWatchFile: (file) => {
|
||||
this.addDependency(file);
|
||||
},
|
||||
getWatchFiles: () => {
|
||||
return this.getDependencies();
|
||||
}
|
||||
}, this._compiler, this._compilation, this), context), normalizeAbsolutePath(id));
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, res.map ?? map);
|
||||
else callback(null, res, map);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { load as default };
|
||||
31
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.cjs
generated
vendored
Normal file
31
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.cjs
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
const require_context = require('../../context-CQfDPcdE.cjs');
|
||||
const require_context$1 = require('../../context-D7WFmOmt.cjs');
|
||||
|
||||
//#region src/webpack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
if (!plugin?.transform) return callback(null, source, map);
|
||||
const context = require_context$1.createContext(this);
|
||||
const { handler, filter } = require_context.normalizeObjectHook("transform", plugin.transform);
|
||||
if (!filter(this.resource, source)) return callback(null, source, map);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, require_context$1.createBuildContext({
|
||||
addWatchFile: (file) => {
|
||||
this.addDependency(file);
|
||||
},
|
||||
getWatchFiles: () => {
|
||||
return this.getDependencies();
|
||||
}
|
||||
}, this._compiler, this._compilation, this, map), context), source, this.resource);
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, map == null ? map : res.map || map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
module.exports = transform;
|
||||
5
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.d.cts
generated
vendored
Normal file
5
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.d.cts
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { LoaderContext } from "webpack";
|
||||
|
||||
//#region src/webpack/loaders/transform.d.ts
|
||||
declare function transform(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
export = transform;
|
||||
6
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.d.ts
generated
vendored
Normal file
6
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.d.ts
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
import { LoaderContext } from "webpack";
|
||||
|
||||
//#region src/webpack/loaders/transform.d.ts
|
||||
declare function transform(this: LoaderContext<any>, source: string, map: any): Promise<void>;
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
31
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.js
generated
vendored
Normal file
31
node_modules/unimport/node_modules/unplugin/dist/webpack/loaders/transform.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
import { n as normalizeObjectHook } from "../../context-Csj9j3eN.js";
|
||||
import { n as createBuildContext, r as createContext } from "../../context-OCFO8EW1.js";
|
||||
|
||||
//#region src/webpack/loaders/transform.ts
|
||||
async function transform(source, map) {
|
||||
const callback = this.async();
|
||||
const { plugin } = this.query;
|
||||
if (!plugin?.transform) return callback(null, source, map);
|
||||
const context = createContext(this);
|
||||
const { handler, filter } = normalizeObjectHook("transform", plugin.transform);
|
||||
if (!filter(this.resource, source)) return callback(null, source, map);
|
||||
try {
|
||||
const res = await handler.call(Object.assign({}, createBuildContext({
|
||||
addWatchFile: (file) => {
|
||||
this.addDependency(file);
|
||||
},
|
||||
getWatchFiles: () => {
|
||||
return this.getDependencies();
|
||||
}
|
||||
}, this._compiler, this._compilation, this, map), context), source, this.resource);
|
||||
if (res == null) callback(null, source, map);
|
||||
else if (typeof res !== "string") callback(null, res.code, map == null ? map : res.map || map);
|
||||
else callback(null, res, map);
|
||||
} catch (error) {
|
||||
if (error instanceof Error) callback(error);
|
||||
else callback(new Error(String(error)));
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { transform as default };
|
||||
92
node_modules/unimport/node_modules/unplugin/package.json
generated
vendored
Normal file
92
node_modules/unimport/node_modules/unplugin/package.json
generated
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
{
|
||||
"name": "unplugin",
|
||||
"type": "module",
|
||||
"version": "2.3.11",
|
||||
"description": "Unified plugin system for build tools",
|
||||
"license": "MIT",
|
||||
"homepage": "https://unplugin.unjs.io",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/unjs/unplugin.git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": {
|
||||
"import": "./dist/index.js",
|
||||
"require": "./dist/index.cjs"
|
||||
},
|
||||
"./dist/webpack/loaders/*": "./dist/webpack/loaders/*.cjs",
|
||||
"./dist/rspack/loaders/*": "./dist/rspack/loaders/*.cjs"
|
||||
},
|
||||
"main": "dist/index.js",
|
||||
"module": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@jridgewell/remapping": "^2.3.5",
|
||||
"acorn": "^8.15.0",
|
||||
"picomatch": "^4.0.3",
|
||||
"webpack-virtual-modules": "^0.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^6.2.0",
|
||||
"@antfu/ni": "^27.0.1",
|
||||
"@farmfe/cli": "^1.0.5",
|
||||
"@farmfe/core": "^1.7.11",
|
||||
"@rspack/cli": "^1.6.0",
|
||||
"@rspack/core": "^1.6.0",
|
||||
"@types/fs-extra": "^11.0.4",
|
||||
"@types/node": "^24.10.0",
|
||||
"@types/picomatch": "^4.0.2",
|
||||
"ansis": "^4.2.0",
|
||||
"bumpp": "^10.3.1",
|
||||
"esbuild": "^0.25.12",
|
||||
"esbuild-plugin-copy": "^2.1.1",
|
||||
"eslint": "^9.39.0",
|
||||
"eslint-plugin-format": "^1.0.2",
|
||||
"fast-glob": "^3.3.3",
|
||||
"fs-extra": "^11.3.2",
|
||||
"jiti": "^2.6.1",
|
||||
"lint-staged": "^16.2.6",
|
||||
"magic-string": "^0.30.21",
|
||||
"rolldown": "^1.0.0-beta.46",
|
||||
"rollup": "^4.52.5",
|
||||
"simple-git-hooks": "^2.13.1",
|
||||
"tsdown": "^0.15.12",
|
||||
"typescript": "~5.9.3",
|
||||
"unloader": "^0.5.0",
|
||||
"unplugin-unused": "^0.5.5",
|
||||
"vite": "^7.1.12",
|
||||
"vitest": "^4.0.6",
|
||||
"webpack": "^5.102.1",
|
||||
"webpack-cli": "^6.0.1",
|
||||
"unplugin": "2.3.11"
|
||||
},
|
||||
"resolutions": {
|
||||
"esbuild": "catalog:"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "pnpm i --frozen-lockfile --ignore-scripts --offline && npx lint-staged"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*": "eslint --fix"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "tsdown",
|
||||
"dev": "tsdown --watch src",
|
||||
"lint": "eslint --cache .",
|
||||
"lint:fix": "nr lint --fix",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"docs:dev": "pnpm -C docs run dev",
|
||||
"docs:build": "pnpm -C docs run build",
|
||||
"docs:gen-files": "pnpm -C docs run gen-files",
|
||||
"release": "bumpp",
|
||||
"test": "nr test:build && vitest run --pool=forks",
|
||||
"test:build": "jiti scripts/buildFixtures.ts"
|
||||
}
|
||||
}
|
||||
70
node_modules/unimport/package.json
generated
vendored
Normal file
70
node_modules/unimport/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "unimport",
|
||||
"type": "module",
|
||||
"version": "5.6.0",
|
||||
"description": "Unified utils for auto importing APIs in modules",
|
||||
"license": "MIT",
|
||||
"repository": "unjs/unimport",
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
".": "./dist/index.mjs",
|
||||
"./unplugin": "./dist/unplugin.mjs",
|
||||
"./addons": "./dist/addons.mjs",
|
||||
"./*": "./*"
|
||||
},
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.mts",
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"dist"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18.12.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": "^8.15.0",
|
||||
"escape-string-regexp": "^5.0.0",
|
||||
"estree-walker": "^3.0.3",
|
||||
"local-pkg": "^1.1.2",
|
||||
"magic-string": "^0.30.21",
|
||||
"mlly": "^1.8.0",
|
||||
"pathe": "^2.0.3",
|
||||
"picomatch": "^4.0.3",
|
||||
"pkg-types": "^2.3.0",
|
||||
"scule": "^1.3.0",
|
||||
"strip-literal": "^3.1.0",
|
||||
"tinyglobby": "^0.2.15",
|
||||
"unplugin": "^2.3.11",
|
||||
"unplugin-utils": "^0.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@antfu/eslint-config": "^6.6.1",
|
||||
"@types/estree": "^1.0.8",
|
||||
"@types/node": "^25.0.2",
|
||||
"@types/picomatch": "^4.0.2",
|
||||
"@vitest/coverage-v8": "^4.0.15",
|
||||
"bumpp": "^10.3.2",
|
||||
"eslint": "^9.39.2",
|
||||
"h3": "^1.15.4",
|
||||
"jquery": "^3.7.1",
|
||||
"lit": "^3.3.1",
|
||||
"typescript": "^5.9.3",
|
||||
"unbuild": "^3.6.1",
|
||||
"vitest": "^4.0.15",
|
||||
"vue-tsc": "^3.1.8"
|
||||
},
|
||||
"resolutions": {
|
||||
"chokidar": "catalog:dev"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "unbuild",
|
||||
"dev": "vitest dev",
|
||||
"lint": "eslint .",
|
||||
"play": "pnpm -C playground run dev",
|
||||
"play:build": "pnpm -C playground run build",
|
||||
"typecheck": "vue-tsc --noEmit",
|
||||
"release": "pnpm run test --run && bumpp",
|
||||
"test": "vitest --coverage"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user