mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
chore:更换到主分支
This commit is contained in:
82
node_modules/@vue/compiler-sfc/README.md
generated
vendored
82
node_modules/@vue/compiler-sfc/README.md
generated
vendored
@@ -1,15 +1,83 @@
|
||||
# @vue/compiler-sfc
|
||||
|
||||
> Lower level utilities for compiling Vue single file components
|
||||
> Lower level utilities for compiling Vue Single File Components
|
||||
|
||||
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue single file components into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader).
|
||||
This package contains lower level utilities that you can use if you are writing a plugin / transform for a bundler or module system that compiles Vue Single File Components (SFCs) into JavaScript. It is used in [vue-loader](https://github.com/vuejs/vue-loader), [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue) and [vite](https://github.com/vitejs/vite).
|
||||
|
||||
The API surface is intentionally minimal - the goal is to reuse as much as possible while being as flexible as possible.
|
||||
## Browser Build Notes
|
||||
|
||||
## Browser Build Usage
|
||||
|
||||
This package relies on `postcss`, `postcss-selector-parser` and `postcss-modules`
|
||||
The browser build relies on a browser-bundled build of `postcss` to be available under the global `postcss` (since it can't be properly bundled by Rollup).
|
||||
|
||||
## API
|
||||
|
||||
TODO
|
||||
The API is intentionally low-level due to the various considerations when integrating Vue SFCs in a build system:
|
||||
|
||||
- Separate hot-module replacement (HMR) for script, template and styles
|
||||
- template updates should not reset component state
|
||||
- style updates should be performed without component re-render
|
||||
|
||||
- Leveraging the tool's plugin system for pre-processor handling. e.g. `<style lang="scss">` should be processed by the corresponding webpack loader.
|
||||
|
||||
- In some cases, transformers of each block in an SFC do not share the same execution context. For example, when used with `thread-loader` or other parallelized configurations, the template sub-loader in `vue-loader` may not have access to the full SFC and its descriptor.
|
||||
|
||||
The general idea is to generate a facade module that imports the individual blocks of the component. The trick is the module imports itself with different query strings so that the build system can handle each request as "virtual" modules:
|
||||
|
||||
```
|
||||
+--------------------+
|
||||
| |
|
||||
| script transform |
|
||||
+----->+ |
|
||||
| +--------------------+
|
||||
|
|
||||
+--------------------+ | +--------------------+
|
||||
| | | | |
|
||||
| facade transform +----------->+ template transform |
|
||||
| | | | |
|
||||
+--------------------+ | +--------------------+
|
||||
|
|
||||
| +--------------------+
|
||||
+----->+ |
|
||||
| style transform |
|
||||
| |
|
||||
+--------------------+
|
||||
```
|
||||
|
||||
Where the facade module looks like this:
|
||||
|
||||
```js
|
||||
// main script
|
||||
import script from '/project/foo.vue?vue&type=script'
|
||||
// template compiled to render function
|
||||
import { render } from '/project/foo.vue?vue&type=template&id=xxxxxx'
|
||||
// css
|
||||
import '/project/foo.vue?vue&type=style&index=0&id=xxxxxx'
|
||||
|
||||
// attach render function to script
|
||||
script.render = render
|
||||
|
||||
// attach additional metadata
|
||||
// some of these should be dev only
|
||||
script.__file = 'example.vue'
|
||||
script.__scopeId = 'xxxxxx'
|
||||
|
||||
// additional tooling-specific HMR handling code
|
||||
// using __VUE_HMR_API__ global
|
||||
|
||||
export default script
|
||||
```
|
||||
|
||||
### High Level Workflow
|
||||
|
||||
1. In facade transform, parse the source into descriptor with the `parse` API and generate the above facade module code based on the descriptor;
|
||||
|
||||
2. In script transform, use `compileScript` to process the script. This handles features like `<script setup>` and CSS variable injection. Alternatively, this can be done directly in the facade module (with the code inlined instead of imported), but it will require rewriting `export default` to a temp variable (a `rewriteDefault` convenience API is provided for this purpose) so additional options can be attached to the exported object.
|
||||
|
||||
3. In template transform, use `compileTemplate` to compile the raw template into render function code.
|
||||
|
||||
4. In style transform, use `compileStyle` to compile raw CSS to handle `<style scoped>`, `<style module>` and CSS variable injection.
|
||||
|
||||
Options needed for these APIs can be passed via the query string.
|
||||
|
||||
|
||||
|
||||
For detailed API references and options, check out the source type definitions. For actual usage of these APIs, check out [rollup-plugin-vue](https://github.com/vuejs/rollup-plugin-vue/tree/next) or [vue-loader](https://github.com/vuejs/vue-loader/tree/next).
|
||||
|
||||
1808
node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js
generated
vendored
1808
node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js
generated
vendored
File diff suppressed because it is too large
Load Diff
68
node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts
generated
vendored
68
node_modules/@vue/compiler-sfc/dist/compiler-sfc.d.ts
generated
vendored
@@ -2,6 +2,7 @@ import { BindingMetadata } from '@vue/compiler-core';
|
||||
import { CodegenResult } from '@vue/compiler-core';
|
||||
import { CompilerError } from '@vue/compiler-core';
|
||||
import { CompilerOptions } from '@vue/compiler-core';
|
||||
import { ElementNode } from '@vue/compiler-core';
|
||||
import { generateCodeFrame } from '@vue/compiler-core';
|
||||
import { LazyResult } from 'postcss';
|
||||
import { ParserOptions } from '@vue/compiler-core';
|
||||
@@ -37,13 +38,26 @@ export { CompilerOptions }
|
||||
* It requires the whole SFC descriptor because we need to handle and merge
|
||||
* normal `<script>` + `<script setup>` if both are present.
|
||||
*/
|
||||
export declare function compileScript(sfc: SFCDescriptor, options?: SFCScriptCompileOptions): SFCScriptBlock;
|
||||
export declare function compileScript(sfc: SFCDescriptor, options: SFCScriptCompileOptions): SFCScriptBlock;
|
||||
|
||||
export declare function compileStyle(options: SFCStyleCompileOptions): SFCStyleCompileResults;
|
||||
|
||||
export declare function compileStyleAsync(options: SFCAsyncStyleCompileOptions): Promise<SFCStyleCompileResults>;
|
||||
|
||||
export declare function compileTemplate(options: SFCTemplateCompileOptions): SFCTemplateCompileResults;
|
||||
|
||||
/**
|
||||
* Aligns with postcss-modules
|
||||
* https://github.com/css-modules/postcss-modules
|
||||
*/
|
||||
declare interface CSSModulesOptions {
|
||||
scopeBehaviour?: 'global' | 'local';
|
||||
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
|
||||
hashPrefix?: string;
|
||||
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
||||
exportGlobals?: boolean;
|
||||
globalModulePaths?: string[];
|
||||
}
|
||||
export { generateCodeFrame }
|
||||
|
||||
export declare function parse(source: string, { sourceMap, filename, sourceRoot, pad, compiler }?: SFCParseOptions): SFCParseResult;
|
||||
@@ -59,13 +73,7 @@ export declare function rewriteDefault(input: string, as: string, parserPlugins?
|
||||
export declare interface SFCAsyncStyleCompileOptions extends SFCStyleCompileOptions {
|
||||
isAsync?: boolean;
|
||||
modules?: boolean;
|
||||
modulesOptions?: {
|
||||
scopeBehaviour?: 'global' | 'local';
|
||||
globalModulePaths?: string[];
|
||||
generateScopedName?: string | ((name: string, filename: string, css: string) => string);
|
||||
hashPrefix?: string;
|
||||
localsConvention?: 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
||||
};
|
||||
modulesOptions?: CSSModulesOptions;
|
||||
}
|
||||
|
||||
export declare interface SFCBlock {
|
||||
@@ -86,6 +94,7 @@ export declare interface SFCDescriptor {
|
||||
scriptSetup: SFCScriptBlock | null;
|
||||
styles: SFCStyleBlock[];
|
||||
customBlocks: SFCBlock[];
|
||||
cssVars: string[];
|
||||
}
|
||||
|
||||
export declare interface SFCParseOptions {
|
||||
@@ -110,16 +119,39 @@ export declare interface SFCScriptBlock extends SFCBlock {
|
||||
}
|
||||
|
||||
export declare interface SFCScriptCompileOptions {
|
||||
/**
|
||||
* Scope ID for prefixing injected CSS varialbes.
|
||||
* This must be consistent with the `id` passed to `compileStyle`.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Production mode. Used to determine whether to generate hashed CSS variables
|
||||
*/
|
||||
isProd?: boolean;
|
||||
/**
|
||||
* https://babeljs.io/docs/en/babel-parser#plugins
|
||||
*/
|
||||
babelParserPlugins?: ParserPlugin[];
|
||||
/**
|
||||
* Enable ref: label sugar
|
||||
* https://github.com/vuejs/rfcs/pull/228
|
||||
* @default true
|
||||
*/
|
||||
refSugar?: boolean;
|
||||
/**
|
||||
* Compile the template and inline the resulting render function
|
||||
* directly inside setup().
|
||||
* - Only affects <script setup>
|
||||
* - This should only be used in production because it prevents the template
|
||||
* from being hot-reloaded separately from component state.
|
||||
*/
|
||||
inlineTemplate?: boolean;
|
||||
templateOptions?: Partial<SFCTemplateCompileOptions>;
|
||||
}
|
||||
|
||||
export declare interface SFCStyleBlock extends SFCBlock {
|
||||
type: 'style';
|
||||
scoped?: boolean;
|
||||
vars?: string;
|
||||
module?: string | boolean;
|
||||
}
|
||||
|
||||
@@ -127,21 +159,25 @@ export declare interface SFCStyleCompileOptions {
|
||||
source: string;
|
||||
filename: string;
|
||||
id: string;
|
||||
map?: RawSourceMap;
|
||||
scoped?: boolean;
|
||||
vars?: boolean;
|
||||
trim?: boolean;
|
||||
isProd?: boolean;
|
||||
inMap?: RawSourceMap;
|
||||
preprocessLang?: PreprocessLang;
|
||||
preprocessOptions?: any;
|
||||
preprocessCustomRequire?: (id: string) => any;
|
||||
postcssOptions?: any;
|
||||
postcssPlugins?: any[];
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
map?: RawSourceMap;
|
||||
}
|
||||
|
||||
export declare interface SFCStyleCompileResults {
|
||||
code: string;
|
||||
map: RawSourceMap | undefined;
|
||||
rawResult: LazyResult | Result | undefined;
|
||||
rawResult: Result | LazyResult | undefined;
|
||||
errors: Error[];
|
||||
modules?: Record<string, string>;
|
||||
dependencies: Set<string>;
|
||||
@@ -149,13 +185,17 @@ export declare interface SFCStyleCompileResults {
|
||||
|
||||
export declare interface SFCTemplateBlock extends SFCBlock {
|
||||
type: 'template';
|
||||
functional?: boolean;
|
||||
ast: ElementNode;
|
||||
}
|
||||
|
||||
export declare interface SFCTemplateCompileOptions {
|
||||
source: string;
|
||||
filename: string;
|
||||
id: string;
|
||||
scoped?: boolean;
|
||||
isProd?: boolean;
|
||||
ssr?: boolean;
|
||||
ssrCssVars?: string[];
|
||||
inMap?: RawSourceMap;
|
||||
compiler?: TemplateCompiler;
|
||||
compilerOptions?: CompilerOptions;
|
||||
@@ -176,6 +216,8 @@ export declare interface SFCTemplateCompileOptions {
|
||||
|
||||
export declare interface SFCTemplateCompileResults {
|
||||
code: string;
|
||||
ast?: RootNode;
|
||||
preamble?: string;
|
||||
source: string;
|
||||
tips: string[];
|
||||
errors: (string | CompilerError)[];
|
||||
|
||||
36612
node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js
generated
vendored
36612
node_modules/@vue/compiler-sfc/dist/compiler-sfc.esm-browser.js
generated
vendored
File diff suppressed because it is too large
Load Diff
17197
node_modules/@vue/compiler-sfc/dist/compiler-sfc.global.js
generated
vendored
17197
node_modules/@vue/compiler-sfc/dist/compiler-sfc.global.js
generated
vendored
File diff suppressed because it is too large
Load Diff
15
node_modules/@vue/compiler-sfc/node_modules/lru-cache/LICENSE
generated
vendored
15
node_modules/@vue/compiler-sfc/node_modules/lru-cache/LICENSE
generated
vendored
@@ -1,15 +0,0 @@
|
||||
The ISC License
|
||||
|
||||
Copyright (c) Isaac Z. Schlueter and Contributors
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
166
node_modules/@vue/compiler-sfc/node_modules/lru-cache/README.md
generated
vendored
166
node_modules/@vue/compiler-sfc/node_modules/lru-cache/README.md
generated
vendored
@@ -1,166 +0,0 @@
|
||||
# lru cache
|
||||
|
||||
A cache object that deletes the least-recently-used items.
|
||||
|
||||
[](https://travis-ci.org/isaacs/node-lru-cache) [](https://coveralls.io/github/isaacs/node-lru-cache)
|
||||
|
||||
## Installation:
|
||||
|
||||
```javascript
|
||||
npm install lru-cache --save
|
||||
```
|
||||
|
||||
## Usage:
|
||||
|
||||
```javascript
|
||||
var LRU = require("lru-cache")
|
||||
, options = { max: 500
|
||||
, length: function (n, key) { return n * 2 + key.length }
|
||||
, dispose: function (key, n) { n.close() }
|
||||
, maxAge: 1000 * 60 * 60 }
|
||||
, cache = new LRU(options)
|
||||
, otherCache = new LRU(50) // sets just the max size
|
||||
|
||||
cache.set("key", "value")
|
||||
cache.get("key") // "value"
|
||||
|
||||
// non-string keys ARE fully supported
|
||||
// but note that it must be THE SAME object, not
|
||||
// just a JSON-equivalent object.
|
||||
var someObject = { a: 1 }
|
||||
cache.set(someObject, 'a value')
|
||||
// Object keys are not toString()-ed
|
||||
cache.set('[object Object]', 'a different value')
|
||||
assert.equal(cache.get(someObject), 'a value')
|
||||
// A similar object with same keys/values won't work,
|
||||
// because it's a different object identity
|
||||
assert.equal(cache.get({ a: 1 }), undefined)
|
||||
|
||||
cache.reset() // empty the cache
|
||||
```
|
||||
|
||||
If you put more stuff in it, then items will fall out.
|
||||
|
||||
If you try to put an oversized thing in it, then it'll fall out right
|
||||
away.
|
||||
|
||||
## Options
|
||||
|
||||
* `max` The maximum size of the cache, checked by applying the length
|
||||
function to all values in the cache. Not setting this is kind of
|
||||
silly, since that's the whole purpose of this lib, but it defaults
|
||||
to `Infinity`. Setting it to a non-number or negative number will
|
||||
throw a `TypeError`. Setting it to 0 makes it be `Infinity`.
|
||||
* `maxAge` Maximum age in ms. Items are not pro-actively pruned out
|
||||
as they age, but if you try to get an item that is too old, it'll
|
||||
drop it and return undefined instead of giving it to you.
|
||||
Setting this to a negative value will make everything seem old!
|
||||
Setting it to a non-number will throw a `TypeError`.
|
||||
* `length` Function that is used to calculate the length of stored
|
||||
items. If you're storing strings or buffers, then you probably want
|
||||
to do something like `function(n, key){return n.length}`. The default is
|
||||
`function(){return 1}`, which is fine if you want to store `max`
|
||||
like-sized things. The item is passed as the first argument, and
|
||||
the key is passed as the second argumnet.
|
||||
* `dispose` Function that is called on items when they are dropped
|
||||
from the cache. This can be handy if you want to close file
|
||||
descriptors or do other cleanup tasks when items are no longer
|
||||
accessible. Called with `key, value`. It's called *before*
|
||||
actually removing the item from the internal cache, so if you want
|
||||
to immediately put it back in, you'll have to do that in a
|
||||
`nextTick` or `setTimeout` callback or it won't do anything.
|
||||
* `stale` By default, if you set a `maxAge`, it'll only actually pull
|
||||
stale items out of the cache when you `get(key)`. (That is, it's
|
||||
not pre-emptively doing a `setTimeout` or anything.) If you set
|
||||
`stale:true`, it'll return the stale value before deleting it. If
|
||||
you don't set this, then it'll return `undefined` when you try to
|
||||
get a stale entry, as if it had already been deleted.
|
||||
* `noDisposeOnSet` By default, if you set a `dispose()` method, then
|
||||
it'll be called whenever a `set()` operation overwrites an existing
|
||||
key. If you set this option, `dispose()` will only be called when a
|
||||
key falls out of the cache, not when it is overwritten.
|
||||
* `updateAgeOnGet` When using time-expiring entries with `maxAge`,
|
||||
setting this to `true` will make each item's effective time update
|
||||
to the current time whenever it is retrieved from cache, causing it
|
||||
to not expire. (It can still fall out of cache based on recency of
|
||||
use, of course.)
|
||||
|
||||
## API
|
||||
|
||||
* `set(key, value, maxAge)`
|
||||
* `get(key) => value`
|
||||
|
||||
Both of these will update the "recently used"-ness of the key.
|
||||
They do what you think. `maxAge` is optional and overrides the
|
||||
cache `maxAge` option if provided.
|
||||
|
||||
If the key is not found, `get()` will return `undefined`.
|
||||
|
||||
The key and val can be any value.
|
||||
|
||||
* `peek(key)`
|
||||
|
||||
Returns the key value (or `undefined` if not found) without
|
||||
updating the "recently used"-ness of the key.
|
||||
|
||||
(If you find yourself using this a lot, you *might* be using the
|
||||
wrong sort of data structure, but there are some use cases where
|
||||
it's handy.)
|
||||
|
||||
* `del(key)`
|
||||
|
||||
Deletes a key out of the cache.
|
||||
|
||||
* `reset()`
|
||||
|
||||
Clear the cache entirely, throwing away all values.
|
||||
|
||||
* `has(key)`
|
||||
|
||||
Check if a key is in the cache, without updating the recent-ness
|
||||
or deleting it for being stale.
|
||||
|
||||
* `forEach(function(value,key,cache), [thisp])`
|
||||
|
||||
Just like `Array.prototype.forEach`. Iterates over all the keys
|
||||
in the cache, in order of recent-ness. (Ie, more recently used
|
||||
items are iterated over first.)
|
||||
|
||||
* `rforEach(function(value,key,cache), [thisp])`
|
||||
|
||||
The same as `cache.forEach(...)` but items are iterated over in
|
||||
reverse order. (ie, less recently used items are iterated over
|
||||
first.)
|
||||
|
||||
* `keys()`
|
||||
|
||||
Return an array of the keys in the cache.
|
||||
|
||||
* `values()`
|
||||
|
||||
Return an array of the values in the cache.
|
||||
|
||||
* `length`
|
||||
|
||||
Return total length of objects in cache taking into account
|
||||
`length` options function.
|
||||
|
||||
* `itemCount`
|
||||
|
||||
Return total quantity of objects currently in cache. Note, that
|
||||
`stale` (see options) items are returned as part of this item
|
||||
count.
|
||||
|
||||
* `dump()`
|
||||
|
||||
Return an array of the cache entries ready for serialization and usage
|
||||
with 'destinationCache.load(arr)`.
|
||||
|
||||
* `load(cacheEntriesArray)`
|
||||
|
||||
Loads another cache entries array, obtained with `sourceCache.dump()`,
|
||||
into the cache. The destination cache is reset before loading new entries
|
||||
|
||||
* `prune()`
|
||||
|
||||
Manually iterates over the entire cache proactively pruning old entries
|
||||
334
node_modules/@vue/compiler-sfc/node_modules/lru-cache/index.js
generated
vendored
334
node_modules/@vue/compiler-sfc/node_modules/lru-cache/index.js
generated
vendored
@@ -1,334 +0,0 @@
|
||||
'use strict'
|
||||
|
||||
// A linked list to keep track of recently-used-ness
|
||||
const Yallist = require('yallist')
|
||||
|
||||
const MAX = Symbol('max')
|
||||
const LENGTH = Symbol('length')
|
||||
const LENGTH_CALCULATOR = Symbol('lengthCalculator')
|
||||
const ALLOW_STALE = Symbol('allowStale')
|
||||
const MAX_AGE = Symbol('maxAge')
|
||||
const DISPOSE = Symbol('dispose')
|
||||
const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet')
|
||||
const LRU_LIST = Symbol('lruList')
|
||||
const CACHE = Symbol('cache')
|
||||
const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet')
|
||||
|
||||
const naiveLength = () => 1
|
||||
|
||||
// lruList is a yallist where the head is the youngest
|
||||
// item, and the tail is the oldest. the list contains the Hit
|
||||
// objects as the entries.
|
||||
// Each Hit object has a reference to its Yallist.Node. This
|
||||
// never changes.
|
||||
//
|
||||
// cache is a Map (or PseudoMap) that matches the keys to
|
||||
// the Yallist.Node object.
|
||||
class LRUCache {
|
||||
constructor (options) {
|
||||
if (typeof options === 'number')
|
||||
options = { max: options }
|
||||
|
||||
if (!options)
|
||||
options = {}
|
||||
|
||||
if (options.max && (typeof options.max !== 'number' || options.max < 0))
|
||||
throw new TypeError('max must be a non-negative number')
|
||||
// Kind of weird to have a default max of Infinity, but oh well.
|
||||
const max = this[MAX] = options.max || Infinity
|
||||
|
||||
const lc = options.length || naiveLength
|
||||
this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc
|
||||
this[ALLOW_STALE] = options.stale || false
|
||||
if (options.maxAge && typeof options.maxAge !== 'number')
|
||||
throw new TypeError('maxAge must be a number')
|
||||
this[MAX_AGE] = options.maxAge || 0
|
||||
this[DISPOSE] = options.dispose
|
||||
this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false
|
||||
this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false
|
||||
this.reset()
|
||||
}
|
||||
|
||||
// resize the cache when the max changes.
|
||||
set max (mL) {
|
||||
if (typeof mL !== 'number' || mL < 0)
|
||||
throw new TypeError('max must be a non-negative number')
|
||||
|
||||
this[MAX] = mL || Infinity
|
||||
trim(this)
|
||||
}
|
||||
get max () {
|
||||
return this[MAX]
|
||||
}
|
||||
|
||||
set allowStale (allowStale) {
|
||||
this[ALLOW_STALE] = !!allowStale
|
||||
}
|
||||
get allowStale () {
|
||||
return this[ALLOW_STALE]
|
||||
}
|
||||
|
||||
set maxAge (mA) {
|
||||
if (typeof mA !== 'number')
|
||||
throw new TypeError('maxAge must be a non-negative number')
|
||||
|
||||
this[MAX_AGE] = mA
|
||||
trim(this)
|
||||
}
|
||||
get maxAge () {
|
||||
return this[MAX_AGE]
|
||||
}
|
||||
|
||||
// resize the cache when the lengthCalculator changes.
|
||||
set lengthCalculator (lC) {
|
||||
if (typeof lC !== 'function')
|
||||
lC = naiveLength
|
||||
|
||||
if (lC !== this[LENGTH_CALCULATOR]) {
|
||||
this[LENGTH_CALCULATOR] = lC
|
||||
this[LENGTH] = 0
|
||||
this[LRU_LIST].forEach(hit => {
|
||||
hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key)
|
||||
this[LENGTH] += hit.length
|
||||
})
|
||||
}
|
||||
trim(this)
|
||||
}
|
||||
get lengthCalculator () { return this[LENGTH_CALCULATOR] }
|
||||
|
||||
get length () { return this[LENGTH] }
|
||||
get itemCount () { return this[LRU_LIST].length }
|
||||
|
||||
rforEach (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (let walker = this[LRU_LIST].tail; walker !== null;) {
|
||||
const prev = walker.prev
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
|
||||
forEach (fn, thisp) {
|
||||
thisp = thisp || this
|
||||
for (let walker = this[LRU_LIST].head; walker !== null;) {
|
||||
const next = walker.next
|
||||
forEachStep(this, fn, walker, thisp)
|
||||
walker = next
|
||||
}
|
||||
}
|
||||
|
||||
keys () {
|
||||
return this[LRU_LIST].toArray().map(k => k.key)
|
||||
}
|
||||
|
||||
values () {
|
||||
return this[LRU_LIST].toArray().map(k => k.value)
|
||||
}
|
||||
|
||||
reset () {
|
||||
if (this[DISPOSE] &&
|
||||
this[LRU_LIST] &&
|
||||
this[LRU_LIST].length) {
|
||||
this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value))
|
||||
}
|
||||
|
||||
this[CACHE] = new Map() // hash of items by key
|
||||
this[LRU_LIST] = new Yallist() // list of items in order of use recency
|
||||
this[LENGTH] = 0 // length of items in the list
|
||||
}
|
||||
|
||||
dump () {
|
||||
return this[LRU_LIST].map(hit =>
|
||||
isStale(this, hit) ? false : {
|
||||
k: hit.key,
|
||||
v: hit.value,
|
||||
e: hit.now + (hit.maxAge || 0)
|
||||
}).toArray().filter(h => h)
|
||||
}
|
||||
|
||||
dumpLru () {
|
||||
return this[LRU_LIST]
|
||||
}
|
||||
|
||||
set (key, value, maxAge) {
|
||||
maxAge = maxAge || this[MAX_AGE]
|
||||
|
||||
if (maxAge && typeof maxAge !== 'number')
|
||||
throw new TypeError('maxAge must be a number')
|
||||
|
||||
const now = maxAge ? Date.now() : 0
|
||||
const len = this[LENGTH_CALCULATOR](value, key)
|
||||
|
||||
if (this[CACHE].has(key)) {
|
||||
if (len > this[MAX]) {
|
||||
del(this, this[CACHE].get(key))
|
||||
return false
|
||||
}
|
||||
|
||||
const node = this[CACHE].get(key)
|
||||
const item = node.value
|
||||
|
||||
// dispose of the old one before overwriting
|
||||
// split out into 2 ifs for better coverage tracking
|
||||
if (this[DISPOSE]) {
|
||||
if (!this[NO_DISPOSE_ON_SET])
|
||||
this[DISPOSE](key, item.value)
|
||||
}
|
||||
|
||||
item.now = now
|
||||
item.maxAge = maxAge
|
||||
item.value = value
|
||||
this[LENGTH] += len - item.length
|
||||
item.length = len
|
||||
this.get(key)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
const hit = new Entry(key, value, len, now, maxAge)
|
||||
|
||||
// oversized objects fall out of cache automatically.
|
||||
if (hit.length > this[MAX]) {
|
||||
if (this[DISPOSE])
|
||||
this[DISPOSE](key, value)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
this[LENGTH] += hit.length
|
||||
this[LRU_LIST].unshift(hit)
|
||||
this[CACHE].set(key, this[LRU_LIST].head)
|
||||
trim(this)
|
||||
return true
|
||||
}
|
||||
|
||||
has (key) {
|
||||
if (!this[CACHE].has(key)) return false
|
||||
const hit = this[CACHE].get(key).value
|
||||
return !isStale(this, hit)
|
||||
}
|
||||
|
||||
get (key) {
|
||||
return get(this, key, true)
|
||||
}
|
||||
|
||||
peek (key) {
|
||||
return get(this, key, false)
|
||||
}
|
||||
|
||||
pop () {
|
||||
const node = this[LRU_LIST].tail
|
||||
if (!node)
|
||||
return null
|
||||
|
||||
del(this, node)
|
||||
return node.value
|
||||
}
|
||||
|
||||
del (key) {
|
||||
del(this, this[CACHE].get(key))
|
||||
}
|
||||
|
||||
load (arr) {
|
||||
// reset the cache
|
||||
this.reset()
|
||||
|
||||
const now = Date.now()
|
||||
// A previous serialized cache has the most recent items first
|
||||
for (let l = arr.length - 1; l >= 0; l--) {
|
||||
const hit = arr[l]
|
||||
const expiresAt = hit.e || 0
|
||||
if (expiresAt === 0)
|
||||
// the item was created without expiration in a non aged cache
|
||||
this.set(hit.k, hit.v)
|
||||
else {
|
||||
const maxAge = expiresAt - now
|
||||
// dont add already expired items
|
||||
if (maxAge > 0) {
|
||||
this.set(hit.k, hit.v, maxAge)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prune () {
|
||||
this[CACHE].forEach((value, key) => get(this, key, false))
|
||||
}
|
||||
}
|
||||
|
||||
const get = (self, key, doUse) => {
|
||||
const node = self[CACHE].get(key)
|
||||
if (node) {
|
||||
const hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE])
|
||||
return undefined
|
||||
} else {
|
||||
if (doUse) {
|
||||
if (self[UPDATE_AGE_ON_GET])
|
||||
node.value.now = Date.now()
|
||||
self[LRU_LIST].unshiftNode(node)
|
||||
}
|
||||
}
|
||||
return hit.value
|
||||
}
|
||||
}
|
||||
|
||||
const isStale = (self, hit) => {
|
||||
if (!hit || (!hit.maxAge && !self[MAX_AGE]))
|
||||
return false
|
||||
|
||||
const diff = Date.now() - hit.now
|
||||
return hit.maxAge ? diff > hit.maxAge
|
||||
: self[MAX_AGE] && (diff > self[MAX_AGE])
|
||||
}
|
||||
|
||||
const trim = self => {
|
||||
if (self[LENGTH] > self[MAX]) {
|
||||
for (let walker = self[LRU_LIST].tail;
|
||||
self[LENGTH] > self[MAX] && walker !== null;) {
|
||||
// We know that we're about to delete this one, and also
|
||||
// what the next least recently used key will be, so just
|
||||
// go ahead and set it now.
|
||||
const prev = walker.prev
|
||||
del(self, walker)
|
||||
walker = prev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const del = (self, node) => {
|
||||
if (node) {
|
||||
const hit = node.value
|
||||
if (self[DISPOSE])
|
||||
self[DISPOSE](hit.key, hit.value)
|
||||
|
||||
self[LENGTH] -= hit.length
|
||||
self[CACHE].delete(hit.key)
|
||||
self[LRU_LIST].removeNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
class Entry {
|
||||
constructor (key, value, length, now, maxAge) {
|
||||
this.key = key
|
||||
this.value = value
|
||||
this.length = length
|
||||
this.now = now
|
||||
this.maxAge = maxAge || 0
|
||||
}
|
||||
}
|
||||
|
||||
const forEachStep = (self, fn, node, thisp) => {
|
||||
let hit = node.value
|
||||
if (isStale(self, hit)) {
|
||||
del(self, node)
|
||||
if (!self[ALLOW_STALE])
|
||||
hit = undefined
|
||||
}
|
||||
if (hit)
|
||||
fn.call(thisp, hit.value, hit.key, self)
|
||||
}
|
||||
|
||||
module.exports = LRUCache
|
||||
71
node_modules/@vue/compiler-sfc/node_modules/lru-cache/package.json
generated
vendored
71
node_modules/@vue/compiler-sfc/node_modules/lru-cache/package.json
generated
vendored
@@ -1,71 +0,0 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"lru-cache@5.1.1",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "lru-cache@5.1.1",
|
||||
"_id": "lru-cache@5.1.1",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-HaJ+ZxAnGUdpXa9oSOhH8B2EuSA=",
|
||||
"_location": "/@vue/compiler-sfc/lru-cache",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "lru-cache@5.1.1",
|
||||
"name": "lru-cache",
|
||||
"escapedName": "lru-cache",
|
||||
"rawSpec": "5.1.1",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "5.1.1"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@vue/compiler-sfc"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/lru-cache/-/lru-cache-5.1.1.tgz",
|
||||
"_spec": "5.1.1",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/node-lru-cache/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"yallist": "^3.0.2"
|
||||
},
|
||||
"description": "A cache object that deletes the least-recently-used items.",
|
||||
"devDependencies": {
|
||||
"benchmark": "^2.1.4",
|
||||
"tap": "^12.1.0"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/node-lru-cache#readme",
|
||||
"keywords": [
|
||||
"mru",
|
||||
"lru",
|
||||
"cache"
|
||||
],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "lru-cache",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/node-lru-cache.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coveragerport": "tap --coverage-report=html",
|
||||
"postpublish": "git push origin --all; git push origin --tags",
|
||||
"postversion": "npm publish",
|
||||
"preversion": "npm test",
|
||||
"snap": "TAP_SNAPSHOT=1 tap test/*.js -J",
|
||||
"test": "tap test/*.js --100 -J"
|
||||
},
|
||||
"version": "5.1.1"
|
||||
}
|
||||
44
node_modules/@vue/compiler-sfc/package.json
generated
vendored
44
node_modules/@vue/compiler-sfc/package.json
generated
vendored
@@ -1,36 +1,37 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"@vue/compiler-sfc@3.0.2",
|
||||
"@vue/compiler-sfc@3.0.6",
|
||||
"J:\\Github\\CURD-TS"
|
||||
]
|
||||
],
|
||||
"_development": true,
|
||||
"_from": "@vue/compiler-sfc@3.0.2",
|
||||
"_id": "@vue/compiler-sfc@3.0.2",
|
||||
"_from": "@vue/compiler-sfc@3.0.6",
|
||||
"_id": "@vue/compiler-sfc@3.0.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-IscP7XLDR6TV+i2y6AWUsxk9zlc=",
|
||||
"_integrity": "sha1-OUX3OpPVKGh5nx4zKnW7iEmXask=",
|
||||
"_location": "/@vue/compiler-sfc",
|
||||
"_phantomChildren": {
|
||||
"yallist": "3.1.1"
|
||||
"colorette": "1.2.1",
|
||||
"nanoid": "3.1.20",
|
||||
"source-map": "0.6.1"
|
||||
},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "@vue/compiler-sfc@3.0.2",
|
||||
"raw": "@vue/compiler-sfc@3.0.6",
|
||||
"name": "@vue/compiler-sfc",
|
||||
"escapedName": "@vue%2fcompiler-sfc",
|
||||
"scope": "@vue",
|
||||
"rawSpec": "3.0.2",
|
||||
"rawSpec": "3.0.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "3.0.2"
|
||||
"fetchSpec": "3.0.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/vite",
|
||||
"/vitepress"
|
||||
"#DEV:/"
|
||||
],
|
||||
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-sfc/-/compiler-sfc-3.0.2.tgz",
|
||||
"_spec": "3.0.2",
|
||||
"_resolved": "http://192.168.250.101:4873/@vue%2fcompiler-sfc/-/compiler-sfc-3.0.6.tgz",
|
||||
"_spec": "3.0.6",
|
||||
"_where": "J:\\Github\\CURD-TS",
|
||||
"author": {
|
||||
"name": "Evan You"
|
||||
@@ -42,8 +43,7 @@
|
||||
"name": "VueCompilerSFC",
|
||||
"formats": [
|
||||
"cjs",
|
||||
"global",
|
||||
"esm-browser"
|
||||
"global"
|
||||
],
|
||||
"prod": false,
|
||||
"enableNonBrowserBranches": true
|
||||
@@ -51,18 +51,18 @@
|
||||
"dependencies": {
|
||||
"@babel/parser": "^7.12.0",
|
||||
"@babel/types": "^7.12.0",
|
||||
"@vue/compiler-core": "3.0.2",
|
||||
"@vue/compiler-dom": "3.0.2",
|
||||
"@vue/compiler-ssr": "3.0.2",
|
||||
"@vue/shared": "3.0.2",
|
||||
"@vue/compiler-core": "3.0.6",
|
||||
"@vue/compiler-dom": "3.0.6",
|
||||
"@vue/compiler-ssr": "3.0.6",
|
||||
"@vue/shared": "3.0.6",
|
||||
"consolidate": "^0.16.0",
|
||||
"estree-walker": "^2.0.1",
|
||||
"hash-sum": "^2.0.0",
|
||||
"lru-cache": "^5.1.1",
|
||||
"magic-string": "^0.25.7",
|
||||
"merge-source-map": "^1.1.0",
|
||||
"postcss": "^7.0.32",
|
||||
"postcss-modules": "^3.2.2",
|
||||
"postcss": "^8.1.10",
|
||||
"postcss-modules": "^4.0.0",
|
||||
"postcss-selector-parser": "^6.0.4",
|
||||
"source-map": "^0.6.1"
|
||||
},
|
||||
@@ -84,7 +84,7 @@
|
||||
"main": "dist/compiler-sfc.cjs.js",
|
||||
"name": "@vue/compiler-sfc",
|
||||
"peerDependencies": {
|
||||
"vue": "3.0.2"
|
||||
"vue": "3.0.6"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -92,5 +92,5 @@
|
||||
"directory": "packages/compiler-sfc"
|
||||
},
|
||||
"types": "dist/compiler-sfc.d.ts",
|
||||
"version": "3.0.2"
|
||||
"version": "3.0.6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user