5/5/1404
This commit is contained in:
-2
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Generated
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
Generated
Vendored
-2
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./api.js"), exports);
|
||||
__exportStar(require("./app.js"), exports);
|
||||
__exportStar(require("./component.js"), exports);
|
||||
__exportStar(require("./context.js"), exports);
|
||||
__exportStar(require("./hooks.js"), exports);
|
||||
__exportStar(require("./util.js"), exports);
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.HOOK_PLUGIN_SETTINGS_SET = exports.HOOK_SETUP = void 0;
|
||||
exports.HOOK_SETUP = 'devtools-plugin:setup';
|
||||
exports.HOOK_PLUGIN_SETTINGS_SET = 'plugin:settings:set';
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.isProxyAvailable = exports.getTarget = exports.getDevtoolsGlobalHook = void 0;
|
||||
function getDevtoolsGlobalHook() {
|
||||
return getTarget().__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
||||
}
|
||||
exports.getDevtoolsGlobalHook = getDevtoolsGlobalHook;
|
||||
function getTarget() {
|
||||
// @ts-expect-error navigator and windows are not available in all environments
|
||||
return (typeof navigator !== 'undefined' && typeof window !== 'undefined')
|
||||
? window
|
||||
: typeof globalThis !== 'undefined'
|
||||
? globalThis
|
||||
: {};
|
||||
}
|
||||
exports.getTarget = getTarget;
|
||||
exports.isProxyAvailable = typeof Proxy === 'function';
|
||||
-45
@@ -1,45 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.setupDevtoolsPlugin = void 0;
|
||||
const env_js_1 = require("./env.js");
|
||||
const const_js_1 = require("./const.js");
|
||||
const proxy_js_1 = require("./proxy.js");
|
||||
__exportStar(require("./api/index.js"), exports);
|
||||
__exportStar(require("./plugin.js"), exports);
|
||||
__exportStar(require("./time.js"), exports);
|
||||
function setupDevtoolsPlugin(pluginDescriptor, setupFn) {
|
||||
const descriptor = pluginDescriptor;
|
||||
const target = (0, env_js_1.getTarget)();
|
||||
const hook = (0, env_js_1.getDevtoolsGlobalHook)();
|
||||
const enableProxy = env_js_1.isProxyAvailable && descriptor.enableEarlyProxy;
|
||||
if (hook && (target.__VUE_DEVTOOLS_PLUGIN_API_AVAILABLE__ || !enableProxy)) {
|
||||
hook.emit(const_js_1.HOOK_SETUP, pluginDescriptor, setupFn);
|
||||
}
|
||||
else {
|
||||
const proxy = enableProxy ? new proxy_js_1.ApiProxy(descriptor, hook) : null;
|
||||
const list = target.__VUE_DEVTOOLS_PLUGINS__ = target.__VUE_DEVTOOLS_PLUGINS__ || [];
|
||||
list.push({
|
||||
pluginDescriptor: descriptor,
|
||||
setupFn,
|
||||
proxy,
|
||||
});
|
||||
if (proxy) {
|
||||
setupFn(proxy.proxiedTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.setupDevtoolsPlugin = setupDevtoolsPlugin;
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
-111
@@ -1,111 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ApiProxy = void 0;
|
||||
const const_js_1 = require("./const.js");
|
||||
const time_js_1 = require("./time.js");
|
||||
class ApiProxy {
|
||||
constructor(plugin, hook) {
|
||||
this.target = null;
|
||||
this.targetQueue = [];
|
||||
this.onQueue = [];
|
||||
this.plugin = plugin;
|
||||
this.hook = hook;
|
||||
const defaultSettings = {};
|
||||
if (plugin.settings) {
|
||||
for (const id in plugin.settings) {
|
||||
const item = plugin.settings[id];
|
||||
defaultSettings[id] = item.defaultValue;
|
||||
}
|
||||
}
|
||||
const localSettingsSaveId = `__vue-devtools-plugin-settings__${plugin.id}`;
|
||||
let currentSettings = Object.assign({}, defaultSettings);
|
||||
try {
|
||||
const raw = localStorage.getItem(localSettingsSaveId);
|
||||
const data = JSON.parse(raw);
|
||||
Object.assign(currentSettings, data);
|
||||
}
|
||||
catch (e) {
|
||||
// noop
|
||||
}
|
||||
this.fallbacks = {
|
||||
getSettings() {
|
||||
return currentSettings;
|
||||
},
|
||||
setSettings(value) {
|
||||
try {
|
||||
localStorage.setItem(localSettingsSaveId, JSON.stringify(value));
|
||||
}
|
||||
catch (e) {
|
||||
// noop
|
||||
}
|
||||
currentSettings = value;
|
||||
},
|
||||
now() {
|
||||
return (0, time_js_1.now)();
|
||||
},
|
||||
};
|
||||
if (hook) {
|
||||
hook.on(const_js_1.HOOK_PLUGIN_SETTINGS_SET, (pluginId, value) => {
|
||||
if (pluginId === this.plugin.id) {
|
||||
this.fallbacks.setSettings(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.proxiedOn = new Proxy({}, {
|
||||
get: (_target, prop) => {
|
||||
if (this.target) {
|
||||
return this.target.on[prop];
|
||||
}
|
||||
else {
|
||||
return (...args) => {
|
||||
this.onQueue.push({
|
||||
method: prop,
|
||||
args,
|
||||
});
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
this.proxiedTarget = new Proxy({}, {
|
||||
get: (_target, prop) => {
|
||||
if (this.target) {
|
||||
return this.target[prop];
|
||||
}
|
||||
else if (prop === 'on') {
|
||||
return this.proxiedOn;
|
||||
}
|
||||
else if (Object.keys(this.fallbacks).includes(prop)) {
|
||||
return (...args) => {
|
||||
this.targetQueue.push({
|
||||
method: prop,
|
||||
args,
|
||||
resolve: () => { },
|
||||
});
|
||||
return this.fallbacks[prop](...args);
|
||||
};
|
||||
}
|
||||
else {
|
||||
return (...args) => {
|
||||
return new Promise((resolve) => {
|
||||
this.targetQueue.push({
|
||||
method: prop,
|
||||
args,
|
||||
resolve,
|
||||
});
|
||||
});
|
||||
};
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
async setRealTarget(target) {
|
||||
this.target = target;
|
||||
for (const item of this.onQueue) {
|
||||
this.target.on[item.method](...item.args);
|
||||
}
|
||||
for (const item of this.targetQueue) {
|
||||
item.resolve(await this.target[item.method](...item.args));
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.ApiProxy = ApiProxy;
|
||||
-28
@@ -1,28 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.now = exports.isPerformanceSupported = void 0;
|
||||
let supported;
|
||||
let perf;
|
||||
function isPerformanceSupported() {
|
||||
var _a;
|
||||
if (supported !== undefined) {
|
||||
return supported;
|
||||
}
|
||||
if (typeof window !== 'undefined' && window.performance) {
|
||||
supported = true;
|
||||
perf = window.performance;
|
||||
}
|
||||
else if (typeof globalThis !== 'undefined' && ((_a = globalThis.perf_hooks) === null || _a === void 0 ? void 0 : _a.performance)) {
|
||||
supported = true;
|
||||
perf = globalThis.perf_hooks.performance;
|
||||
}
|
||||
else {
|
||||
supported = false;
|
||||
}
|
||||
return supported;
|
||||
}
|
||||
exports.isPerformanceSupported = isPerformanceSupported;
|
||||
function now() {
|
||||
return isPerformanceSupported() ? perf.now() : Date.now();
|
||||
}
|
||||
exports.now = now;
|
||||
-37
@@ -1,37 +0,0 @@
|
||||
{
|
||||
"name": "@vue/devtools-api",
|
||||
"version": "6.6.4",
|
||||
"description": "Interact with the Vue devtools from the page",
|
||||
"author": {
|
||||
"name": "Guillaume Chau"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"url": "https://github.com/vuejs/vue-devtools.git",
|
||||
"type": "git",
|
||||
"directory": "packages/api"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"main": "lib/cjs/index.js",
|
||||
"browser": "lib/esm/index.js",
|
||||
"module": "lib/esm/index.js",
|
||||
"types": "lib/esm/index.d.ts",
|
||||
"files": [
|
||||
"lib/cjs",
|
||||
"lib/esm"
|
||||
],
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "rimraf lib && yarn build:esm && yarn build:cjs",
|
||||
"build:esm": "tsc --module es2015 --outDir lib/esm -d",
|
||||
"build:cjs": "tsc --module commonjs --outDir lib/cjs",
|
||||
"build:watch": "yarn tsc --module es2015 --outDir lib/esm -d -w --sourceMap"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.11.16",
|
||||
"@types/webpack-env": "^1.15.1",
|
||||
"typescript": "^5.3.3"
|
||||
}
|
||||
}
|
||||
-46
@@ -1,46 +0,0 @@
|
||||
{
|
||||
"name": "vue-demi",
|
||||
"version": "0.12.5",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
"repository": "https://github.com/antfu/vue-demi.git",
|
||||
"funding": "https://github.com/sponsors/antfu",
|
||||
"license": "MIT",
|
||||
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
||||
"main": "lib/index.cjs",
|
||||
"jsdelivr": "lib/index.iife.js",
|
||||
"unpkg": "lib/index.iife.js",
|
||||
"module": "lib/index.mjs",
|
||||
"types": "lib/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./lib/index.cjs",
|
||||
"import": "./lib/index.mjs",
|
||||
"browser": "./lib/index.mjs"
|
||||
},
|
||||
"./*": "./*"
|
||||
},
|
||||
"bin": {
|
||||
"vue-demi-fix": "bin/vue-demi-fix.js",
|
||||
"vue-demi-switch": "bin/vue-demi-switch.js"
|
||||
},
|
||||
"files": [
|
||||
"lib",
|
||||
"bin",
|
||||
"scripts"
|
||||
],
|
||||
"scripts": {
|
||||
"postinstall": "node ./scripts/postinstall.js",
|
||||
"release": "npx bumpp --tag --commit --push && npm publish"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/composition-api": "^1.0.0-rc.1",
|
||||
"vue": "^3.0.0-0 || ^2.6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vue/composition-api": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
-34
@@ -1,34 +0,0 @@
|
||||
import * as Vue from 'vue'
|
||||
|
||||
var isVue2 = false
|
||||
var isVue3 = true
|
||||
var Vue2 = undefined
|
||||
|
||||
function install() {}
|
||||
|
||||
export function set(target, key, val) {
|
||||
if (Array.isArray(target)) {
|
||||
target.length = Math.max(target.length, key)
|
||||
target.splice(key, 1, val)
|
||||
return val
|
||||
}
|
||||
target[key] = val
|
||||
return val
|
||||
}
|
||||
|
||||
export function del(target, key) {
|
||||
if (Array.isArray(target)) {
|
||||
target.splice(key, 1)
|
||||
return
|
||||
}
|
||||
delete target[key]
|
||||
}
|
||||
|
||||
export * from 'vue'
|
||||
export {
|
||||
Vue,
|
||||
Vue2,
|
||||
isVue2,
|
||||
isVue3,
|
||||
install,
|
||||
}
|
||||
Generated
Vendored
Generated
Vendored
Generated
Vendored
Generated
Vendored
-3786
File diff suppressed because it is too large
Load Diff
-2
@@ -1,2 +0,0 @@
|
||||
global.__VUE_PROD_DEVTOOLS__ = false;
|
||||
export * from '../dist/vue-router.mjs'
|
||||
-149
@@ -1,149 +0,0 @@
|
||||
{
|
||||
"name": "vue-router",
|
||||
"version": "4.5.1",
|
||||
"main": "index.js",
|
||||
"unpkg": "dist/vue-router.global.js",
|
||||
"jsdelivr": "dist/vue-router.global.js",
|
||||
"module": "dist/vue-router.mjs",
|
||||
"types": "dist/vue-router.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./dist/vue-router.d.ts",
|
||||
"node": {
|
||||
"import": {
|
||||
"production": "./dist/vue-router.node.mjs",
|
||||
"development": "./dist/vue-router.node.mjs",
|
||||
"default": "./dist/vue-router.node.mjs"
|
||||
},
|
||||
"require": {
|
||||
"production": "./dist/vue-router.prod.cjs",
|
||||
"development": "./dist/vue-router.cjs",
|
||||
"default": "./dist/vue-router.prod.cjs"
|
||||
}
|
||||
},
|
||||
"import": "./dist/vue-router.mjs",
|
||||
"require": "./index.js"
|
||||
},
|
||||
"./dist/*": "./dist/*",
|
||||
"./vetur/*": "./vetur/*",
|
||||
"./package.json": "./package.json",
|
||||
"./auto-routes": {
|
||||
"types": "./vue-router-auto-routes.d.ts",
|
||||
"node": {
|
||||
"import": {
|
||||
"production": "./dist/vue-router.node.mjs",
|
||||
"development": "./dist/vue-router.node.mjs",
|
||||
"default": "./dist/vue-router.node.mjs"
|
||||
},
|
||||
"require": {
|
||||
"production": "./dist/vue-router.prod.cjs",
|
||||
"development": "./dist/vue-router.cjs",
|
||||
"default": "./dist/vue-router.prod.cjs"
|
||||
}
|
||||
},
|
||||
"import": "./dist/vue-router.mjs",
|
||||
"require": "./index.js"
|
||||
},
|
||||
"./auto": {
|
||||
"types": "./vue-router-auto.d.ts",
|
||||
"node": {
|
||||
"import": {
|
||||
"production": "./dist/vue-router.node.mjs",
|
||||
"development": "./dist/vue-router.node.mjs",
|
||||
"default": "./dist/vue-router.node.mjs"
|
||||
},
|
||||
"require": {
|
||||
"production": "./dist/vue-router.prod.cjs",
|
||||
"development": "./dist/vue-router.cjs",
|
||||
"default": "./dist/vue-router.prod.cjs"
|
||||
}
|
||||
},
|
||||
"import": "./dist/vue-router.mjs",
|
||||
"require": "./index.js"
|
||||
}
|
||||
},
|
||||
"sideEffects": false,
|
||||
"author": {
|
||||
"name": "Eduardo San Martin Morote",
|
||||
"email": "posva13@gmail.com"
|
||||
},
|
||||
"funding": "https://github.com/sponsors/posva",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/vuejs/router.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/vuejs/router/issues"
|
||||
},
|
||||
"homepage": "https://github.com/vuejs/router#readme",
|
||||
"files": [
|
||||
"index.js",
|
||||
"dist/*.{js,cjs,mjs}",
|
||||
"dist/vue-router.d.ts",
|
||||
"vue-router-auto.d.ts",
|
||||
"vue-router-auto-routes.d.ts",
|
||||
"vetur/tags.json",
|
||||
"vetur/attributes.json",
|
||||
"README.md"
|
||||
],
|
||||
"peerDependencies": {
|
||||
"vue": "^3.2.0"
|
||||
},
|
||||
"vetur": {
|
||||
"tags": "vetur/tags.json",
|
||||
"attributes": "vetur/attributes.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@vue/devtools-api": "^6.6.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/api-extractor": "^7.48.0",
|
||||
"@rollup/plugin-alias": "^5.1.1",
|
||||
"@rollup/plugin-commonjs": "^25.0.8",
|
||||
"@rollup/plugin-node-resolve": "^15.3.0",
|
||||
"@rollup/plugin-replace": "^5.0.7",
|
||||
"@rollup/plugin-terser": "^0.4.4",
|
||||
"@types/jsdom": "^21.1.7",
|
||||
"@types/nightwatch": "^2.3.32",
|
||||
"@vitejs/plugin-vue": "^5.2.0",
|
||||
"@vue/compiler-sfc": "~3.5.13",
|
||||
"@vue/server-renderer": "~3.5.13",
|
||||
"@vue/test-utils": "^2.4.6",
|
||||
"browserstack-local": "^1.5.5",
|
||||
"chromedriver": "^131.0.1",
|
||||
"connect-history-api-fallback": "^1.6.0",
|
||||
"conventional-changelog-cli": "^2.2.2",
|
||||
"dotenv": "^16.4.5",
|
||||
"faked-promise": "^2.2.2",
|
||||
"geckodriver": "^4.5.1",
|
||||
"happy-dom": "^15.11.6",
|
||||
"nightwatch": "^2.6.25",
|
||||
"nightwatch-helpers": "^1.2.0",
|
||||
"rimraf": "^6.0.1",
|
||||
"rollup": "^3.29.5",
|
||||
"rollup-plugin-analyzer": "^4.0.0",
|
||||
"rollup-plugin-typescript2": "^0.36.0",
|
||||
"vite": "^5.4.11",
|
||||
"vue": "~3.5.13"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "vitest --ui",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 1",
|
||||
"build": "rimraf dist && rollup -c rollup.config.mjs",
|
||||
"build:dts": "api-extractor run --local --verbose && tail -n +10 src/globalExtensions.ts >> dist/vue-router.d.ts",
|
||||
"build:playground": "vue-tsc --noEmit && vite build --config playground/vite.config.ts",
|
||||
"build:e2e": "vue-tsc --noEmit && vite build --config e2e/vite.config.mjs",
|
||||
"build:size": "pnpm run build && rollup -c size-checks/rollup.config.mjs",
|
||||
"dev:e2e": "vite --config e2e/vite.config.mjs",
|
||||
"test:types": "tsc --build tsconfig.json",
|
||||
"test:unit": "vitest --coverage run",
|
||||
"test": "pnpm run build && pnpm run build:dts && pnpm run test:types && pnpm run test:unit && pnpm run test:e2e",
|
||||
"test:e2e": "pnpm run test:e2e:headless",
|
||||
"test:e2e:headless": "node e2e/runner.mjs --env chrome-headless",
|
||||
"test:e2e:native": "node e2e/runner.mjs --env chrome",
|
||||
"test:e2e:ci": "node e2e/runner.mjs --env chrome-headless --retries 2",
|
||||
"test:e2e:bs": "node e2e/runner.mjs --local -e android5 --tag browserstack",
|
||||
"test:e2e:bs-test": "node e2e/runner.mjs --local --env browserstack.local_chrome --tag browserstack"
|
||||
}
|
||||
}
|
||||
-286
@@ -1,286 +0,0 @@
|
||||
import { ref, onMounted, onUnmounted, watch } from 'vue-demi';
|
||||
|
||||
var LifecycleEnum = /* @__PURE__ */ ((LifecycleEnum2) => {
|
||||
LifecycleEnum2["LOADING"] = "loading";
|
||||
LifecycleEnum2["LOADED"] = "loaded";
|
||||
LifecycleEnum2["ERROR"] = "error";
|
||||
return LifecycleEnum2;
|
||||
})(LifecycleEnum || {});
|
||||
|
||||
const inBrowser = typeof window !== "undefined" && window !== null;
|
||||
const hasIntersectionObserver = checkIntersectionObserver();
|
||||
const isEnumerable = Object.prototype.propertyIsEnumerable;
|
||||
const getSymbols = Object.getOwnPropertySymbols;
|
||||
function isObject(val) {
|
||||
return typeof val === "function" || toString.call(val) === "[object Object]";
|
||||
}
|
||||
function isPrimitive(val) {
|
||||
return typeof val === "object" ? val === null : typeof val !== "function";
|
||||
}
|
||||
function isValidKey(key) {
|
||||
return key !== "__proto__" && key !== "constructor" && key !== "prototype";
|
||||
}
|
||||
function checkIntersectionObserver() {
|
||||
if (inBrowser && "IntersectionObserver" in window && "IntersectionObserverEntry" in window && "intersectionRatio" in window.IntersectionObserverEntry.prototype) {
|
||||
if (!("isIntersecting" in window.IntersectionObserverEntry.prototype)) {
|
||||
Object.defineProperty(window.IntersectionObserverEntry.prototype, "isIntersecting", {
|
||||
get() {
|
||||
return this.intersectionRatio > 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function assignSymbols(target, ...args) {
|
||||
if (!isObject(target))
|
||||
throw new TypeError("expected the first argument to be an object");
|
||||
if (args.length === 0 || typeof Symbol !== "function" || typeof getSymbols !== "function")
|
||||
return target;
|
||||
for (const arg of args) {
|
||||
const names = getSymbols(arg);
|
||||
for (const key of names) {
|
||||
if (isEnumerable.call(arg, key))
|
||||
target[key] = arg[key];
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
function assign(target, ...args) {
|
||||
let i = 0;
|
||||
if (isPrimitive(target))
|
||||
target = args[i++];
|
||||
if (!target)
|
||||
target = {};
|
||||
for (; i < args.length; i++) {
|
||||
if (isObject(args[i])) {
|
||||
for (const key of Object.keys(args[i])) {
|
||||
if (isValidKey(key)) {
|
||||
if (isObject(target[key]) && isObject(args[i][key]))
|
||||
assign(target[key], args[i][key]);
|
||||
else
|
||||
target[key] = args[i][key];
|
||||
}
|
||||
}
|
||||
assignSymbols(target, args[i]);
|
||||
}
|
||||
}
|
||||
return target;
|
||||
}
|
||||
|
||||
const DEFAULT_LOADING = "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";
|
||||
const DEFAULT_ERROR = "";
|
||||
|
||||
const DEFAULT_OBSERVER_OPTIONS = {
|
||||
rootMargin: "0px",
|
||||
threshold: 0
|
||||
};
|
||||
const TIMEOUT_ID_DATA_ATTR = "data-lazy-timeout-id";
|
||||
class Lazy {
|
||||
constructor(options) {
|
||||
this.options = {
|
||||
loading: DEFAULT_LOADING,
|
||||
error: DEFAULT_ERROR,
|
||||
observerOptions: DEFAULT_OBSERVER_OPTIONS,
|
||||
log: true,
|
||||
lifecycle: {},
|
||||
logLevel: "error"
|
||||
};
|
||||
this._images = /* @__PURE__ */ new WeakMap();
|
||||
this.config(options);
|
||||
}
|
||||
config(options = {}) {
|
||||
assign(this.options, options);
|
||||
}
|
||||
mount(el, binding) {
|
||||
if (!el)
|
||||
return;
|
||||
const { src, loading, error, lifecycle, delay } = this._valueFormatter(typeof binding === "string" ? binding : binding.value);
|
||||
this._lifecycle(LifecycleEnum.LOADING, lifecycle, el);
|
||||
el.setAttribute("src", loading || DEFAULT_LOADING);
|
||||
if (!hasIntersectionObserver) {
|
||||
this.loadImages(el, src, error, lifecycle);
|
||||
this._log(() => {
|
||||
this._logger("Not support IntersectionObserver!");
|
||||
});
|
||||
}
|
||||
this._initIntersectionObserver(el, src, error, lifecycle, delay);
|
||||
}
|
||||
update(el, binding) {
|
||||
if (!el)
|
||||
return;
|
||||
this._realObserver(el)?.unobserve(el);
|
||||
const { src, error, lifecycle, delay } = this._valueFormatter(typeof binding === "string" ? binding : binding.value);
|
||||
this._initIntersectionObserver(el, src, error, lifecycle, delay);
|
||||
}
|
||||
unmount(el) {
|
||||
if (!el)
|
||||
return;
|
||||
this._realObserver(el)?.unobserve(el);
|
||||
this._images.delete(el);
|
||||
}
|
||||
loadImages(el, src, error, lifecycle) {
|
||||
this._setImageSrc(el, src, error, lifecycle);
|
||||
}
|
||||
_setImageSrc(el, src, error, lifecycle) {
|
||||
if (el.tagName.toLowerCase() === "img") {
|
||||
if (src) {
|
||||
const preSrc = el.getAttribute("src");
|
||||
if (preSrc !== src)
|
||||
el.setAttribute("src", src);
|
||||
}
|
||||
this._listenImageStatus(el, () => {
|
||||
this._lifecycle(LifecycleEnum.LOADED, lifecycle, el);
|
||||
}, () => {
|
||||
el.onload = null;
|
||||
this._lifecycle(LifecycleEnum.ERROR, lifecycle, el);
|
||||
this._realObserver(el)?.disconnect();
|
||||
if (error) {
|
||||
const newImageSrc = el.getAttribute("src");
|
||||
if (newImageSrc !== error)
|
||||
el.setAttribute("src", error);
|
||||
}
|
||||
this._log(() => {
|
||||
this._logger(`Image failed to load!And failed src was: ${src} `);
|
||||
});
|
||||
});
|
||||
} else {
|
||||
el.style.backgroundImage = `url('${src}')`;
|
||||
}
|
||||
}
|
||||
_initIntersectionObserver(el, src, error, lifecycle, delay) {
|
||||
const observerOptions = this.options.observerOptions;
|
||||
this._images.set(el, new IntersectionObserver((entries) => {
|
||||
Array.prototype.forEach.call(entries, (entry) => {
|
||||
if (delay && delay > 0)
|
||||
this._delayedIntersectionCallback(el, entry, delay, src, error, lifecycle);
|
||||
else
|
||||
this._intersectionCallback(el, entry, src, error, lifecycle);
|
||||
});
|
||||
}, observerOptions));
|
||||
this._realObserver(el)?.observe(el);
|
||||
}
|
||||
_intersectionCallback(el, entry, src, error, lifecycle) {
|
||||
if (entry.isIntersecting) {
|
||||
this._realObserver(el)?.unobserve(entry.target);
|
||||
this._setImageSrc(el, src, error, lifecycle);
|
||||
}
|
||||
}
|
||||
_delayedIntersectionCallback(el, entry, delay, src, error, lifecycle) {
|
||||
if (entry.isIntersecting) {
|
||||
if (entry.target.hasAttribute(TIMEOUT_ID_DATA_ATTR))
|
||||
return;
|
||||
const timeoutId = setTimeout(() => {
|
||||
this._intersectionCallback(el, entry, src, error, lifecycle);
|
||||
entry.target.removeAttribute(TIMEOUT_ID_DATA_ATTR);
|
||||
}, delay);
|
||||
entry.target.setAttribute(TIMEOUT_ID_DATA_ATTR, String(timeoutId));
|
||||
} else {
|
||||
if (entry.target.hasAttribute(TIMEOUT_ID_DATA_ATTR)) {
|
||||
clearTimeout(Number(entry.target.getAttribute(TIMEOUT_ID_DATA_ATTR)));
|
||||
entry.target.removeAttribute(TIMEOUT_ID_DATA_ATTR);
|
||||
}
|
||||
}
|
||||
}
|
||||
_listenImageStatus(image, success, error) {
|
||||
image.onload = success;
|
||||
image.onerror = error;
|
||||
}
|
||||
_valueFormatter(value) {
|
||||
let src = value;
|
||||
let loading = this.options.loading;
|
||||
let error = this.options.error;
|
||||
let lifecycle = this.options.lifecycle;
|
||||
let delay = this.options.delay;
|
||||
if (isObject(value)) {
|
||||
src = value.src;
|
||||
loading = value.loading || this.options.loading;
|
||||
error = value.error || this.options.error;
|
||||
lifecycle = value.lifecycle || this.options.lifecycle;
|
||||
delay = value.delay || this.options.delay;
|
||||
}
|
||||
return {
|
||||
src,
|
||||
loading,
|
||||
error,
|
||||
lifecycle,
|
||||
delay
|
||||
};
|
||||
}
|
||||
_log(callback) {
|
||||
if (this.options.log)
|
||||
callback();
|
||||
}
|
||||
_lifecycle(life, lifecycle, el) {
|
||||
switch (life) {
|
||||
case LifecycleEnum.LOADING:
|
||||
el?.setAttribute("lazy", LifecycleEnum.LOADING);
|
||||
if (lifecycle?.loading)
|
||||
lifecycle.loading(el);
|
||||
break;
|
||||
case LifecycleEnum.LOADED:
|
||||
el?.setAttribute("lazy", LifecycleEnum.LOADED);
|
||||
if (lifecycle?.loaded)
|
||||
lifecycle.loaded(el);
|
||||
break;
|
||||
case LifecycleEnum.ERROR:
|
||||
el?.setAttribute("lazy", LifecycleEnum.ERROR);
|
||||
if (lifecycle?.error)
|
||||
lifecycle.error(el);
|
||||
break;
|
||||
}
|
||||
}
|
||||
_realObserver(el) {
|
||||
return this._images.get(el);
|
||||
}
|
||||
_logger(message, ...optionalParams) {
|
||||
let log = console.error;
|
||||
switch (this.options.logLevel) {
|
||||
case "error":
|
||||
log = console.error;
|
||||
break;
|
||||
case "warn":
|
||||
log = console.warn;
|
||||
break;
|
||||
case "info":
|
||||
log = console.info;
|
||||
break;
|
||||
case "debug":
|
||||
log = console.debug;
|
||||
break;
|
||||
}
|
||||
log(message, optionalParams);
|
||||
}
|
||||
}
|
||||
|
||||
function useLazyload(src, options) {
|
||||
const lazyRef = ref(null);
|
||||
const lazy = new Lazy(options);
|
||||
onMounted(() => {
|
||||
lazyRef.value && lazy.mount(lazyRef.value, src.value);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
lazyRef.value && lazy.unmount(lazyRef.value);
|
||||
});
|
||||
watch(src, (newVal) => {
|
||||
if (src.value)
|
||||
lazy.update(lazyRef.value, newVal);
|
||||
});
|
||||
return lazyRef;
|
||||
}
|
||||
|
||||
const index = {
|
||||
install(Vue, options) {
|
||||
const lazy = new Lazy(options);
|
||||
Vue.config.globalProperties.$Lazyload = lazy;
|
||||
Vue.provide("Lazyload", lazy);
|
||||
Vue.directive("lazy", {
|
||||
mounted: lazy.mount.bind(lazy),
|
||||
updated: lazy.update.bind(lazy),
|
||||
unmounted: lazy.unmount.bind(lazy)
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
export { index as default, useLazyload };
|
||||
-104
@@ -1,104 +0,0 @@
|
||||
{
|
||||
"name": "vue3-lazyload",
|
||||
"version": "0.3.8",
|
||||
"packageManager": "pnpm@6.32.3",
|
||||
"description": "A Vue3.x image lazyload plugin",
|
||||
"license": "MIT",
|
||||
"author": "木荣 <admin@imuboy.cn>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/murongg/vue3-lazyload.git"
|
||||
},
|
||||
"main": "./dist/index.cjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"exports": {
|
||||
".": {
|
||||
"require": "./dist/index.cjs",
|
||||
"import": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.ts"
|
||||
}
|
||||
},
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"*": [
|
||||
"./dist/*",
|
||||
"./dist/index.d.ts"
|
||||
]
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"sideEffects": false,
|
||||
"scripts": {
|
||||
"build": "rimraf dist && unbuild && npm run rollup:build",
|
||||
"rollup:build": "node rollup.config.js",
|
||||
"dev": "unbuild --stub",
|
||||
"lint": "eslint .",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"demo:dev": "vite",
|
||||
"demo:build": "vite build",
|
||||
"prepublishOnly": "nr build",
|
||||
"release": "bumpp --commit --push --tag && pnpm publish",
|
||||
"start": "esno src/index.ts",
|
||||
"test": "vitest",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"prepare": "husky install"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@vue/composition-api": "^1.0.0-rc.1",
|
||||
"vue": "^2.0.0 || >=3.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@vue/composition-api": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"vue-demi": "^0.12.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.18.6",
|
||||
"@babel/types": "^7.17.0",
|
||||
"@murongg/eslint-config": "^0.1.0",
|
||||
"@rollup/plugin-babel": "^5.3.1",
|
||||
"@rollup/plugin-commonjs": "^22.0.1",
|
||||
"@rollup/plugin-node-resolve": "^13.3.0",
|
||||
"@rollup/plugin-typescript": "^8.3.3",
|
||||
"@types/node": "^14.11.8",
|
||||
"@vitejs/plugin-vue": "^2.3.2",
|
||||
"@vue/eslint-config-typescript": "^7.0.0",
|
||||
"@vue/test-utils": "^2.0.0-beta.6",
|
||||
"bumpp": "^7.1.1",
|
||||
"eslint": "^8.13.0",
|
||||
"esno": "^0.14.1",
|
||||
"happy-dom": "^3.1.1",
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^13.0.0",
|
||||
"pnpm": "^6.32.6",
|
||||
"prettier": "^2.1.2",
|
||||
"rimraf": "^3.0.2",
|
||||
"rollup": "^2.75.7",
|
||||
"rollup-plugin-uglify": "^6.0.4",
|
||||
"typescript": "^4.6.3",
|
||||
"unbuild": "^0.7.2",
|
||||
"vite": "^2.9.1",
|
||||
"vitest": "^0.9.3",
|
||||
"vue": "^3.2.33"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*": "pnpm run lint:fix"
|
||||
},
|
||||
"typings": "types/index.d.ts",
|
||||
"bugs": {
|
||||
"url": "https://github.com/murongg/vue3-lazyload/issues"
|
||||
},
|
||||
"config": {
|
||||
"commitizen": {
|
||||
"path": "./node_modules/cz-conventional-changelog"
|
||||
}
|
||||
},
|
||||
"homepage": "https://github.com/murongg/vue3-lazyload#readme"
|
||||
}
|
||||
Reference in New Issue
Block a user