This commit is contained in:
2025-07-06 20:54:40 +08:00
parent f665eaab54
commit ced488a958
4076 changed files with 1108355 additions and 0 deletions

21
node_modules/@vue/devtools-core/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 webfansplz
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.

3
node_modules/@vue/devtools-core/README.md generated vendored Normal file
View File

@@ -0,0 +1,3 @@
# @vue/devtools-core
> Internal core functions shared across @vue/devtools packages.

689
node_modules/@vue/devtools-core/dist/index.cjs generated vendored Normal file
View File

@@ -0,0 +1,689 @@
"use strict";
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target2, all) => {
for (var name in all)
__defProp(target2, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/index.ts
var index_exports = {};
__export(index_exports, {
DevToolsMessagingEvents: () => DevToolsMessagingEvents,
VueDevToolsVuePlugin: () => VueDevToolsVuePlugin,
createDevToolsStateContext: () => createDevToolsStateContext,
createViteClientRpc: () => createViteClientRpc,
createViteServerRpc: () => createViteServerRpc,
functions: () => functions,
getDevToolsClientUrl: () => getDevToolsClientUrl,
onDevToolsConnected: () => onDevToolsConnected,
onRpcConnected: () => onRpcConnected,
onRpcSeverReady: () => onRpcSeverReady,
onViteRpcConnected: () => onViteRpcConnected,
refreshCurrentPageData: () => refreshCurrentPageData,
rpc: () => rpc,
rpcServer: () => rpcServer,
setDevToolsClientUrl: () => setDevToolsClientUrl,
useDevToolsState: () => useDevToolsState,
viteRpc: () => viteRpc,
viteRpcFunctions: () => viteRpcFunctions
});
module.exports = __toCommonJS(index_exports);
// src/client.ts
var import_devtools_shared = require("@vue/devtools-shared");
function setDevToolsClientUrl(url) {
import_devtools_shared.target.__VUE_DEVTOOLS_CLIENT_URL__ = url;
}
function getDevToolsClientUrl() {
var _a;
return (_a = import_devtools_shared.target.__VUE_DEVTOOLS_CLIENT_URL__) != null ? _a : (() => {
if (import_devtools_shared.isBrowser) {
const devtoolsMeta = document.querySelector("meta[name=__VUE_DEVTOOLS_CLIENT_URL__]");
if (devtoolsMeta)
return devtoolsMeta.getAttribute("content");
}
return "";
})();
}
// src/rpc/global.ts
var import_devtools_kit = require("@vue/devtools-kit");
// ../../node_modules/.pnpm/hookable@5.5.3/node_modules/hookable/dist/index.mjs
function flatHooks(configHooks, hooks3 = {}, parentName) {
for (const key in configHooks) {
const subHook = configHooks[key];
const name = parentName ? `${parentName}:${key}` : key;
if (typeof subHook === "object" && subHook !== null) {
flatHooks(subHook, hooks3, name);
} else if (typeof subHook === "function") {
hooks3[name] = subHook;
}
}
return hooks3;
}
var defaultTask = { run: (function_) => function_() };
var _createTask = () => defaultTask;
var createTask = typeof console.createTask !== "undefined" ? console.createTask : _createTask;
function serialTaskCaller(hooks3, args) {
const name = args.shift();
const task = createTask(name);
return hooks3.reduce(
(promise, hookFunction) => promise.then(() => task.run(() => hookFunction(...args))),
Promise.resolve()
);
}
function parallelTaskCaller(hooks3, args) {
const name = args.shift();
const task = createTask(name);
return Promise.all(hooks3.map((hook) => task.run(() => hook(...args))));
}
function callEachWith(callbacks, arg0) {
for (const callback of [...callbacks]) {
callback(arg0);
}
}
var Hookable = class {
constructor() {
this._hooks = {};
this._before = void 0;
this._after = void 0;
this._deprecatedMessages = void 0;
this._deprecatedHooks = {};
this.hook = this.hook.bind(this);
this.callHook = this.callHook.bind(this);
this.callHookWith = this.callHookWith.bind(this);
}
hook(name, function_, options = {}) {
if (!name || typeof function_ !== "function") {
return () => {
};
}
const originalName = name;
let dep;
while (this._deprecatedHooks[name]) {
dep = this._deprecatedHooks[name];
name = dep.to;
}
if (dep && !options.allowDeprecated) {
let message = dep.message;
if (!message) {
message = `${originalName} hook has been deprecated` + (dep.to ? `, please use ${dep.to}` : "");
}
if (!this._deprecatedMessages) {
this._deprecatedMessages = /* @__PURE__ */ new Set();
}
if (!this._deprecatedMessages.has(message)) {
console.warn(message);
this._deprecatedMessages.add(message);
}
}
if (!function_.name) {
try {
Object.defineProperty(function_, "name", {
get: () => "_" + name.replace(/\W+/g, "_") + "_hook_cb",
configurable: true
});
} catch (e) {
}
}
this._hooks[name] = this._hooks[name] || [];
this._hooks[name].push(function_);
return () => {
if (function_) {
this.removeHook(name, function_);
function_ = void 0;
}
};
}
hookOnce(name, function_) {
let _unreg;
let _function = (...arguments_) => {
if (typeof _unreg === "function") {
_unreg();
}
_unreg = void 0;
_function = void 0;
return function_(...arguments_);
};
_unreg = this.hook(name, _function);
return _unreg;
}
removeHook(name, function_) {
if (this._hooks[name]) {
const index = this._hooks[name].indexOf(function_);
if (index !== -1) {
this._hooks[name].splice(index, 1);
}
if (this._hooks[name].length === 0) {
delete this._hooks[name];
}
}
}
deprecateHook(name, deprecated) {
this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
const _hooks = this._hooks[name] || [];
delete this._hooks[name];
for (const hook of _hooks) {
this.hook(name, hook);
}
}
deprecateHooks(deprecatedHooks) {
Object.assign(this._deprecatedHooks, deprecatedHooks);
for (const name in deprecatedHooks) {
this.deprecateHook(name, deprecatedHooks[name]);
}
}
addHooks(configHooks) {
const hooks3 = flatHooks(configHooks);
const removeFns = Object.keys(hooks3).map(
(key) => this.hook(key, hooks3[key])
);
return () => {
for (const unreg of removeFns.splice(0, removeFns.length)) {
unreg();
}
};
}
removeHooks(configHooks) {
const hooks3 = flatHooks(configHooks);
for (const key in hooks3) {
this.removeHook(key, hooks3[key]);
}
}
removeAllHooks() {
for (const key in this._hooks) {
delete this._hooks[key];
}
}
callHook(name, ...arguments_) {
arguments_.unshift(name);
return this.callHookWith(serialTaskCaller, name, ...arguments_);
}
callHookParallel(name, ...arguments_) {
arguments_.unshift(name);
return this.callHookWith(parallelTaskCaller, name, ...arguments_);
}
callHookWith(caller, name, ...arguments_) {
const event = this._before || this._after ? { name, args: arguments_, context: {} } : void 0;
if (this._before) {
callEachWith(this._before, event);
}
const result = caller(
name in this._hooks ? [...this._hooks[name]] : [],
arguments_
);
if (result instanceof Promise) {
return result.finally(() => {
if (this._after && event) {
callEachWith(this._after, event);
}
});
}
if (this._after && event) {
callEachWith(this._after, event);
}
return result;
}
beforeEach(function_) {
this._before = this._before || [];
this._before.push(function_);
return () => {
if (this._before !== void 0) {
const index = this._before.indexOf(function_);
if (index !== -1) {
this._before.splice(index, 1);
}
}
};
}
afterEach(function_) {
this._after = this._after || [];
this._after.push(function_);
return () => {
if (this._after !== void 0) {
const index = this._after.indexOf(function_);
if (index !== -1) {
this._after.splice(index, 1);
}
}
};
}
};
function createHooks() {
return new Hookable();
}
// src/rpc/global.ts
var hooks = createHooks();
var DevToolsMessagingEvents = /* @__PURE__ */ ((DevToolsMessagingEvents2) => {
DevToolsMessagingEvents2["INSPECTOR_TREE_UPDATED"] = "inspector-tree-updated";
DevToolsMessagingEvents2["INSPECTOR_STATE_UPDATED"] = "inspector-state-updated";
DevToolsMessagingEvents2["DEVTOOLS_STATE_UPDATED"] = "devtools-state-updated";
DevToolsMessagingEvents2["ROUTER_INFO_UPDATED"] = "router-info-updated";
DevToolsMessagingEvents2["TIMELINE_EVENT_UPDATED"] = "timeline-event-updated";
DevToolsMessagingEvents2["INSPECTOR_UPDATED"] = "inspector-updated";
DevToolsMessagingEvents2["ACTIVE_APP_UNMOUNTED"] = "active-app-updated";
DevToolsMessagingEvents2["DESTROY_DEVTOOLS_CLIENT"] = "destroy-devtools-client";
DevToolsMessagingEvents2["RELOAD_DEVTOOLS_CLIENT"] = "reload-devtools-client";
return DevToolsMessagingEvents2;
})(DevToolsMessagingEvents || {});
function getDevToolsState() {
var _a;
const state = import_devtools_kit.devtools.ctx.state;
return {
connected: state.connected,
clientConnected: true,
vueVersion: ((_a = state == null ? void 0 : state.activeAppRecord) == null ? void 0 : _a.version) || "",
tabs: state.tabs,
commands: state.commands,
vitePluginDetected: state.vitePluginDetected,
appRecords: state.appRecords.map((item) => ({
id: item.id,
name: item.name,
version: item.version,
routerId: item.routerId
})),
activeAppRecordId: state.activeAppRecordId,
timelineLayersState: state.timelineLayersState
};
}
var functions = {
on: (event, handler) => {
hooks.hook(event, handler);
},
off: (event, handler) => {
hooks.removeHook(event, handler);
},
once: (event, handler) => {
hooks.hookOnce(event, handler);
},
emit: (event, ...args) => {
hooks.callHook(event, ...args);
},
heartbeat: () => {
return true;
},
devtoolsState: () => {
return getDevToolsState();
},
async getInspectorTree(payload) {
const res = await import_devtools_kit.devtools.ctx.api.getInspectorTree(payload);
return (0, import_devtools_kit.stringify)(res);
},
async getInspectorState(payload) {
const inspector = (0, import_devtools_kit.getInspector)(payload.inspectorId);
if (inspector)
inspector.selectedNodeId = payload.nodeId;
const res = await import_devtools_kit.devtools.ctx.api.getInspectorState(payload);
return (0, import_devtools_kit.stringify)(res);
},
async editInspectorState(payload) {
return await import_devtools_kit.devtools.ctx.api.editInspectorState(payload);
},
sendInspectorState(id) {
return import_devtools_kit.devtools.ctx.api.sendInspectorState(id);
},
inspectComponentInspector() {
return import_devtools_kit.devtools.ctx.api.inspectComponentInspector();
},
cancelInspectComponentInspector() {
return import_devtools_kit.devtools.ctx.api.cancelInspectComponentInspector();
},
getComponentRenderCode(id) {
return import_devtools_kit.devtools.ctx.api.getComponentRenderCode(id);
},
scrollToComponent(id) {
return import_devtools_kit.devtools.ctx.api.scrollToComponent(id);
},
inspectDOM(id) {
return import_devtools_kit.devtools.ctx.api.inspectDOM(id);
},
getInspectorNodeActions(id) {
return (0, import_devtools_kit.getInspectorNodeActions)(id);
},
getInspectorActions(id) {
return (0, import_devtools_kit.getInspectorActions)(id);
},
updateTimelineLayersState(state) {
return (0, import_devtools_kit.updateTimelineLayersState)(state);
},
callInspectorNodeAction(inspectorId, actionIndex, nodeId) {
var _a;
const nodeActions = (0, import_devtools_kit.getInspectorNodeActions)(inspectorId);
if (nodeActions == null ? void 0 : nodeActions.length) {
const item = nodeActions[actionIndex];
(_a = item.action) == null ? void 0 : _a.call(item, nodeId);
}
},
callInspectorAction(inspectorId, actionIndex) {
var _a;
const actions = (0, import_devtools_kit.getInspectorActions)(inspectorId);
if (actions == null ? void 0 : actions.length) {
const item = actions[actionIndex];
(_a = item.action) == null ? void 0 : _a.call(item);
}
},
openInEditor(options) {
return import_devtools_kit.devtools.ctx.api.openInEditor(options);
},
async checkVueInspectorDetected() {
return !!await import_devtools_kit.devtools.ctx.api.getVueInspector();
},
async enableVueInspector() {
var _a, _b, _c;
const inspector = await ((_c = (_b = (_a = import_devtools_kit.devtools) == null ? void 0 : _a.api) == null ? void 0 : _b.getVueInspector) == null ? void 0 : _c.call(_b));
if (inspector)
await inspector.enable();
},
async toggleApp(id, options) {
return import_devtools_kit.devtools.ctx.api.toggleApp(id, options);
},
updatePluginSettings(pluginId, key, value) {
return import_devtools_kit.devtools.ctx.api.updatePluginSettings(pluginId, key, value);
},
getPluginSettings(pluginId) {
return import_devtools_kit.devtools.ctx.api.getPluginSettings(pluginId);
},
getRouterInfo() {
return import_devtools_kit.devtoolsRouterInfo;
},
navigate(path) {
var _a;
return (_a = import_devtools_kit.devtoolsRouter.value) == null ? void 0 : _a.push(path).catch(() => ({}));
},
getMatchedRoutes(path) {
var _a, _b, _c;
const c = console.warn;
console.warn = () => {
};
const matched = (_c = (_b = (_a = import_devtools_kit.devtoolsRouter.value) == null ? void 0 : _a.resolve) == null ? void 0 : _b.call(_a, {
path: path || "/"
}).matched) != null ? _c : [];
console.warn = c;
return matched;
},
toggleClientConnected(state) {
(0, import_devtools_kit.toggleClientConnected)(state);
},
getCustomInspector() {
return (0, import_devtools_kit.getActiveInspectors)();
},
getInspectorInfo(id) {
return (0, import_devtools_kit.getInspectorInfo)(id);
},
highlighComponent(uid) {
return import_devtools_kit.devtools.ctx.hooks.callHook(import_devtools_kit.DevToolsContextHookKeys.COMPONENT_HIGHLIGHT, { uid });
},
unhighlight() {
return import_devtools_kit.devtools.ctx.hooks.callHook(import_devtools_kit.DevToolsContextHookKeys.COMPONENT_UNHIGHLIGHT);
},
updateDevToolsClientDetected(params) {
(0, import_devtools_kit.updateDevToolsClientDetected)(params);
},
// listen to devtools server events
initDevToolsServerListener() {
const rpcServer2 = (0, import_devtools_kit.getRpcServer)();
const broadcast = rpcServer2.broadcast;
import_devtools_kit.devtools.ctx.hooks.hook(import_devtools_kit.DevToolsMessagingHookKeys.SEND_INSPECTOR_TREE_TO_CLIENT, (payload) => {
broadcast.emit("inspector-tree-updated" /* INSPECTOR_TREE_UPDATED */, (0, import_devtools_kit.stringify)(payload));
});
import_devtools_kit.devtools.ctx.hooks.hook(import_devtools_kit.DevToolsMessagingHookKeys.SEND_INSPECTOR_STATE_TO_CLIENT, (payload) => {
broadcast.emit("inspector-state-updated" /* INSPECTOR_STATE_UPDATED */, (0, import_devtools_kit.stringify)(payload));
});
import_devtools_kit.devtools.ctx.hooks.hook(import_devtools_kit.DevToolsMessagingHookKeys.DEVTOOLS_STATE_UPDATED, () => {
broadcast.emit("devtools-state-updated" /* DEVTOOLS_STATE_UPDATED */, getDevToolsState());
});
import_devtools_kit.devtools.ctx.hooks.hook(import_devtools_kit.DevToolsMessagingHookKeys.ROUTER_INFO_UPDATED, ({ state }) => {
broadcast.emit("router-info-updated" /* ROUTER_INFO_UPDATED */, state);
});
import_devtools_kit.devtools.ctx.hooks.hook(import_devtools_kit.DevToolsMessagingHookKeys.SEND_TIMELINE_EVENT_TO_CLIENT, (payload) => {
broadcast.emit("timeline-event-updated" /* TIMELINE_EVENT_UPDATED */, (0, import_devtools_kit.stringify)(payload));
});
import_devtools_kit.devtools.ctx.hooks.hook(import_devtools_kit.DevToolsMessagingHookKeys.SEND_INSPECTOR_TO_CLIENT, (payload) => {
broadcast.emit("inspector-updated" /* INSPECTOR_UPDATED */, payload);
});
import_devtools_kit.devtools.ctx.hooks.hook(import_devtools_kit.DevToolsMessagingHookKeys.SEND_ACTIVE_APP_UNMOUNTED_TO_CLIENT, () => {
broadcast.emit("active-app-updated" /* ACTIVE_APP_UNMOUNTED */);
});
}
};
var rpc = new Proxy({
value: {},
functions: {}
}, {
get(target2, property) {
const _rpc = (0, import_devtools_kit.getRpcClient)();
if (property === "value") {
return _rpc;
} else if (property === "functions") {
return _rpc.$functions;
}
}
});
var rpcServer = new Proxy({
value: {},
functions: {}
}, {
get(target2, property) {
const _rpc = (0, import_devtools_kit.getRpcServer)();
if (property === "value") {
return _rpc;
} else if (property === "functions") {
return _rpc.functions;
}
}
});
function onRpcConnected(callback) {
let timer = null;
let retryCount = 0;
function heartbeat() {
var _a, _b;
(_b = (_a = rpc.value) == null ? void 0 : _a.heartbeat) == null ? void 0 : _b.call(_a).then(() => {
callback();
clearTimeout(timer);
}).catch(() => {
});
}
timer = setInterval(() => {
if (retryCount >= 30) {
clearTimeout(timer);
}
retryCount++;
heartbeat();
}, retryCount * 200 + 200);
heartbeat();
}
function onRpcSeverReady(callback) {
let timer = null;
const timeout = 120;
function heartbeat() {
if (rpcServer.value.clients.length > 0) {
callback();
clearTimeout(timer);
}
}
timer = setInterval(() => {
heartbeat();
}, timeout);
}
// src/rpc/vite.ts
var import_devtools_kit2 = require("@vue/devtools-kit");
var hooks2 = createHooks();
var viteRpcFunctions = {
on: (event, handler) => {
hooks2.hook(event, handler);
},
off: (event, handler) => {
hooks2.removeHook(event, handler);
},
once: (event, handler) => {
hooks2.hookOnce(event, handler);
},
emit: (event, ...args) => {
hooks2.callHook(event, ...args);
},
heartbeat: () => {
return true;
}
};
var viteRpc = new Proxy({
value: {},
functions: {}
}, {
get(target2, property) {
const _rpc = (0, import_devtools_kit2.getViteRpcClient)();
if (property === "value") {
return _rpc;
} else if (property === "functions") {
return _rpc == null ? void 0 : _rpc.$functions;
}
}
});
function onViteRpcConnected(callback) {
let timer = null;
function heartbeat() {
var _a, _b;
(_b = (_a = viteRpc.value) == null ? void 0 : _a.heartbeat) == null ? void 0 : _b.call(_a).then(() => {
clearTimeout(timer);
callback();
}).catch(() => ({}));
timer = setTimeout(() => {
heartbeat();
}, 80);
}
heartbeat();
}
function createViteClientRpc() {
(0, import_devtools_kit2.createRpcClient)(viteRpcFunctions, {
preset: "vite"
});
}
function createViteServerRpc(functions2) {
(0, import_devtools_kit2.createRpcServer)(functions2, {
preset: "vite"
});
}
// src/vue-plugin/devtools-state.ts
var import_vue = require("vue");
var VueDevToolsStateSymbol = Symbol.for("__VueDevToolsStateSymbol__");
function VueDevToolsVuePlugin() {
return {
install(app) {
const state = createDevToolsStateContext();
state.getDevToolsState();
app.provide(VueDevToolsStateSymbol, state);
app.config.globalProperties.$getDevToolsState = state.getDevToolsState;
app.config.globalProperties.$disconnectDevToolsClient = () => {
state.clientConnected.value = false;
state.connected.value = false;
};
}
};
}
function createDevToolsStateContext() {
const connected = (0, import_vue.ref)(false);
const clientConnected = (0, import_vue.ref)(false);
const vueVersion = (0, import_vue.ref)("");
const tabs = (0, import_vue.ref)([]);
const commands = (0, import_vue.ref)([]);
const vitePluginDetected = (0, import_vue.ref)(false);
const appRecords = (0, import_vue.ref)([]);
const activeAppRecordId = (0, import_vue.ref)("");
const timelineLayersState = (0, import_vue.ref)({});
function updateState(data) {
connected.value = data.connected;
clientConnected.value = data.clientConnected;
vueVersion.value = data.vueVersion || "";
tabs.value = data.tabs;
commands.value = data.commands;
vitePluginDetected.value = data.vitePluginDetected;
appRecords.value = data.appRecords;
activeAppRecordId.value = data.activeAppRecordId;
timelineLayersState.value = data.timelineLayersState;
}
function getDevToolsState2() {
onRpcConnected(() => {
rpc.value.devtoolsState().then((data) => {
updateState(data);
});
rpc.functions.off("devtools-state-updated" /* DEVTOOLS_STATE_UPDATED */, updateState);
rpc.functions.on("devtools-state-updated" /* DEVTOOLS_STATE_UPDATED */, updateState);
});
}
return {
getDevToolsState: getDevToolsState2,
connected,
clientConnected,
vueVersion,
tabs,
commands,
vitePluginDetected,
appRecords,
activeAppRecordId,
timelineLayersState
};
}
function useDevToolsState() {
return (0, import_vue.inject)(VueDevToolsStateSymbol);
}
var fns = [];
function onDevToolsConnected(fn) {
const { connected, clientConnected } = useDevToolsState();
fns.push(fn);
(0, import_vue.onUnmounted)(() => {
fns.splice(fns.indexOf(fn), 1);
});
const devtoolsReady = (0, import_vue.computed)(() => clientConnected.value && connected.value);
if (devtoolsReady.value) {
fn();
} else {
const stop = (0, import_vue.watch)(devtoolsReady, (v) => {
if (v) {
fn();
stop();
}
});
}
return () => {
fns.splice(fns.indexOf(fn), 1);
};
}
function refreshCurrentPageData() {
fns.forEach((fn) => fn());
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
DevToolsMessagingEvents,
VueDevToolsVuePlugin,
createDevToolsStateContext,
createViteClientRpc,
createViteServerRpc,
functions,
getDevToolsClientUrl,
onDevToolsConnected,
onRpcConnected,
onRpcSeverReady,
onViteRpcConnected,
refreshCurrentPageData,
rpc,
rpcServer,
setDevToolsClientUrl,
useDevToolsState,
viteRpc,
viteRpcFunctions
});

340
node_modules/@vue/devtools-core/dist/index.d.cts generated vendored Normal file
View File

@@ -0,0 +1,340 @@
import * as vue_router from 'vue-router';
import * as _vue_devtools_kit from '@vue/devtools-kit';
import { DevToolsV6PluginAPIHookPayloads, DevToolsV6PluginAPIHookKeys, OpenInEditorOptions, getRpcClient, getRpcServer, getViteRpcClient, CustomTab, CustomCommand, AppRecord } from '@vue/devtools-kit';
import { ModuleNode } from 'vite';
import { App, Ref } from 'vue';
declare function setDevToolsClientUrl(url: string): void;
declare function getDevToolsClientUrl(): any;
declare enum DevToolsMessagingEvents {
INSPECTOR_TREE_UPDATED = "inspector-tree-updated",
INSPECTOR_STATE_UPDATED = "inspector-state-updated",
DEVTOOLS_STATE_UPDATED = "devtools-state-updated",
ROUTER_INFO_UPDATED = "router-info-updated",
TIMELINE_EVENT_UPDATED = "timeline-event-updated",
INSPECTOR_UPDATED = "inspector-updated",
ACTIVE_APP_UNMOUNTED = "active-app-updated",
DESTROY_DEVTOOLS_CLIENT = "destroy-devtools-client",
RELOAD_DEVTOOLS_CLIENT = "reload-devtools-client"
}
declare const functions: {
on: (event: string, handler: Function) => void;
off: (event: string, handler: Function) => void;
once: (event: string, handler: Function) => void;
emit: (event: string, ...args: any[]) => void;
heartbeat: () => boolean;
devtoolsState: () => {
connected: boolean;
clientConnected: boolean;
vueVersion: string;
tabs: _vue_devtools_kit.CustomTab[];
commands: _vue_devtools_kit.CustomCommand[];
vitePluginDetected: boolean;
appRecords: {
id: string;
name: string;
version: string | undefined;
routerId: string | undefined;
}[];
activeAppRecordId: string;
timelineLayersState: Record<string, boolean>;
};
getInspectorTree(payload: Pick<DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_TREE], "inspectorId" | "filter">): Promise<string>;
getInspectorState(payload: Pick<DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_STATE], "inspectorId" | "nodeId">): Promise<string>;
editInspectorState(payload: DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.EDIT_INSPECTOR_STATE]): Promise<void>;
sendInspectorState(id: string): void;
inspectComponentInspector(): Promise<string>;
cancelInspectComponentInspector(): void;
getComponentRenderCode(id: string): any;
scrollToComponent(id: string): void;
inspectDOM(id: string): void;
getInspectorNodeActions(id: string): {
icon: string;
tooltip?: string;
action: (nodeId: string) => void | Promise<void>;
}[] | undefined;
getInspectorActions(id: string): {
icon: string;
tooltip?: string;
action: () => void | Promise<void>;
}[] | undefined;
updateTimelineLayersState(state: Record<string, boolean>): void;
callInspectorNodeAction(inspectorId: string, actionIndex: number, nodeId: string): void;
callInspectorAction(inspectorId: string, actionIndex: number): void;
openInEditor(options: OpenInEditorOptions): void;
checkVueInspectorDetected(): Promise<boolean>;
enableVueInspector(): Promise<void>;
toggleApp(id: string, options?: {
inspectingComponent?: boolean;
}): Promise<void>;
updatePluginSettings(pluginId: string, key: string, value: string): void;
getPluginSettings(pluginId: string): {
options: Record<string, {
label: string;
description?: string;
} & ({
type: "boolean";
defaultValue: boolean;
} | {
type: "choice";
defaultValue: string | number;
options: {
value: string | number;
label: string;
}[];
component?: "select" | "button-group";
} | {
type: "text";
defaultValue: string;
})> | null;
values: any;
};
getRouterInfo(): _vue_devtools_kit.RouterInfo;
navigate(path: string): Promise<void | vue_router.NavigationFailure | {} | undefined>;
getMatchedRoutes(path: string): vue_router.RouteRecordNormalized[];
toggleClientConnected(state: boolean): void;
getCustomInspector(): {
id: string;
label: string;
logo: string;
icon: string;
packageName: string | undefined;
homepage: string | undefined;
pluginId: string;
}[];
getInspectorInfo(id: string): {
id: string;
label: string;
logo: string | undefined;
packageName: string | undefined;
homepage: string | undefined;
timelineLayers: {
id: string;
label: string;
color: number;
}[];
treeFilterPlaceholder: string;
stateFilterPlaceholder: string;
} | undefined;
highlighComponent(uid: string): Promise<any>;
unhighlight(): Promise<any>;
updateDevToolsClientDetected(params: Record<string, boolean>): void;
initDevToolsServerListener(): void;
};
type RPCFunctions = typeof functions;
declare const rpc: {
value: ReturnType<typeof getRpcClient<RPCFunctions>>;
functions: ReturnType<typeof getRpcClient<RPCFunctions>>;
};
declare const rpcServer: {
value: ReturnType<typeof getRpcServer<RPCFunctions>>;
functions: ReturnType<typeof getRpcServer<RPCFunctions>>;
};
declare function onRpcConnected(callback: () => void): void;
declare function onRpcSeverReady(callback: () => void): void;
type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'wasm' | 'other';
interface AssetInfo {
path: string;
type: AssetType;
publicPath: string;
relativePath: string;
filePath: string;
size: number;
mtime: number;
}
interface ImageMeta {
width: number;
height: number;
orientation?: number;
type?: string;
mimeType?: string;
}
type AssetImporter = Pick<ModuleNode, 'url' | 'id'>;
interface AssetEntry {
path: string;
content: string;
encoding?: BufferEncoding;
override?: boolean;
}
interface CodeSnippet {
code: string;
lang: string;
name: string;
docs?: string;
}
interface ModuleInfo {
id: string;
plugins: {
name: string;
transform?: number;
resolveId?: number;
}[];
deps: string[];
virtual: boolean;
}
declare const viteRpcFunctions: {
on: (event: string, handler: Function) => void;
off: (event: string, handler: Function) => void;
once: (event: string, handler: Function) => void;
emit: (event: string, ...args: any[]) => void;
heartbeat: () => boolean;
};
type ViteRPCFunctions = typeof viteRpcFunctions & {
getStaticAssets: () => Promise<AssetInfo[]>;
getAssetImporters: (url: string) => Promise<AssetImporter[]>;
getImageMeta: (filepath: string) => Promise<ImageMeta>;
getTextAssetContent: (filepath: string, limit?: number) => Promise<string>;
getRoot: () => Promise<string>;
getGraphModules: () => Promise<ModuleInfo[]>;
};
declare const viteRpc: {
value: ReturnType<typeof getViteRpcClient<ViteRPCFunctions>>;
functions: ReturnType<typeof getViteRpcClient<ViteRPCFunctions>>;
};
declare function onViteRpcConnected(callback: () => void): void;
declare function createViteClientRpc(): void;
declare function createViteServerRpc(functions: Record<string, any>): void;
interface DevToolsState {
connected: boolean;
clientConnected: boolean;
vueVersion: string;
tabs: CustomTab[];
commands: CustomCommand[];
vitePluginDetected: boolean;
appRecords: AppRecord[];
activeAppRecordId: string;
timelineLayersState: Record<string, boolean>;
}
type DevToolsRefState = {
[P in keyof DevToolsState]: Ref<DevToolsState[P]>;
};
declare function VueDevToolsVuePlugin(): {
install(app: App): void;
};
declare function createDevToolsStateContext(): {
getDevToolsState: () => void;
connected: Ref<boolean, boolean>;
clientConnected: Ref<boolean, boolean>;
vueVersion: Ref<string, string>;
tabs: Ref<{
name: string;
icon?: string | undefined;
title: string;
view: {
type: "iframe";
src: string;
persistent?: boolean | undefined;
} | {
type: "vnode";
vnode: VNode;
} | {
type: "sfc";
sfc: string;
};
category?: ("app" | "pinned" | "modules" | "advanced") | undefined;
}[], CustomTab[] | {
name: string;
icon?: string | undefined;
title: string;
view: {
type: "iframe";
src: string;
persistent?: boolean | undefined;
} | {
type: "vnode";
vnode: VNode;
} | {
type: "sfc";
sfc: string;
};
category?: ("app" | "pinned" | "modules" | "advanced") | undefined;
}[]>;
commands: Ref<{
id: string;
title: string;
description?: string | undefined;
order?: number | undefined;
icon?: string | undefined;
action?: {
type: "url";
src: string;
} | undefined;
children?: {
title: string;
id: string;
icon?: string | undefined;
description?: string | undefined;
order?: number | undefined;
action?: {
type: "url";
src: string;
} | undefined;
}[] | undefined;
}[], CustomCommand[] | {
id: string;
title: string;
description?: string | undefined;
order?: number | undefined;
icon?: string | undefined;
action?: {
type: "url";
src: string;
} | undefined;
children?: {
title: string;
id: string;
icon?: string | undefined;
description?: string | undefined;
order?: number | undefined;
action?: {
type: "url";
src: string;
} | undefined;
}[] | undefined;
}[]>;
vitePluginDetected: Ref<boolean, boolean>;
appRecords: Ref<{
id: string;
name: string;
app?: _vue_devtools_kit.App;
version?: string | undefined;
types?: Record<string, string | symbol> | undefined;
instanceMap: Map<string, any> & Omit<Map<string, any>, keyof Map<any, any>>;
perfGroupIds: Map<string, {
groupId: number;
time: number;
}> & Omit<Map<string, {
groupId: number;
time: number;
}>, keyof Map<any, any>>;
rootInstance: _vue_devtools_kit.VueAppInstance;
routerId?: string | undefined;
}[], AppRecord[] | {
id: string;
name: string;
app?: _vue_devtools_kit.App;
version?: string | undefined;
types?: Record<string, string | symbol> | undefined;
instanceMap: Map<string, any> & Omit<Map<string, any>, keyof Map<any, any>>;
perfGroupIds: Map<string, {
groupId: number;
time: number;
}> & Omit<Map<string, {
groupId: number;
time: number;
}>, keyof Map<any, any>>;
rootInstance: _vue_devtools_kit.VueAppInstance;
routerId?: string | undefined;
}[]>;
activeAppRecordId: Ref<string, string>;
timelineLayersState: Ref<Record<string, boolean>, Record<string, boolean>>;
};
declare function useDevToolsState(): DevToolsRefState;
declare function onDevToolsConnected(fn: () => void): () => void;
declare function refreshCurrentPageData(): void;
export { type AssetEntry, type AssetImporter, type AssetInfo, type AssetType, type CodeSnippet, DevToolsMessagingEvents, type ImageMeta, type ModuleInfo, type RPCFunctions, type ViteRPCFunctions, VueDevToolsVuePlugin, createDevToolsStateContext, createViteClientRpc, createViteServerRpc, functions, getDevToolsClientUrl, onDevToolsConnected, onRpcConnected, onRpcSeverReady, onViteRpcConnected, refreshCurrentPageData, rpc, rpcServer, setDevToolsClientUrl, useDevToolsState, viteRpc, viteRpcFunctions };

340
node_modules/@vue/devtools-core/dist/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,340 @@
import * as vue_router from 'vue-router';
import * as _vue_devtools_kit from '@vue/devtools-kit';
import { DevToolsV6PluginAPIHookPayloads, DevToolsV6PluginAPIHookKeys, OpenInEditorOptions, getRpcClient, getRpcServer, getViteRpcClient, CustomTab, CustomCommand, AppRecord } from '@vue/devtools-kit';
import { ModuleNode } from 'vite';
import { App, Ref } from 'vue';
declare function setDevToolsClientUrl(url: string): void;
declare function getDevToolsClientUrl(): any;
declare enum DevToolsMessagingEvents {
INSPECTOR_TREE_UPDATED = "inspector-tree-updated",
INSPECTOR_STATE_UPDATED = "inspector-state-updated",
DEVTOOLS_STATE_UPDATED = "devtools-state-updated",
ROUTER_INFO_UPDATED = "router-info-updated",
TIMELINE_EVENT_UPDATED = "timeline-event-updated",
INSPECTOR_UPDATED = "inspector-updated",
ACTIVE_APP_UNMOUNTED = "active-app-updated",
DESTROY_DEVTOOLS_CLIENT = "destroy-devtools-client",
RELOAD_DEVTOOLS_CLIENT = "reload-devtools-client"
}
declare const functions: {
on: (event: string, handler: Function) => void;
off: (event: string, handler: Function) => void;
once: (event: string, handler: Function) => void;
emit: (event: string, ...args: any[]) => void;
heartbeat: () => boolean;
devtoolsState: () => {
connected: boolean;
clientConnected: boolean;
vueVersion: string;
tabs: _vue_devtools_kit.CustomTab[];
commands: _vue_devtools_kit.CustomCommand[];
vitePluginDetected: boolean;
appRecords: {
id: string;
name: string;
version: string | undefined;
routerId: string | undefined;
}[];
activeAppRecordId: string;
timelineLayersState: Record<string, boolean>;
};
getInspectorTree(payload: Pick<DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_TREE], "inspectorId" | "filter">): Promise<string>;
getInspectorState(payload: Pick<DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.GET_INSPECTOR_STATE], "inspectorId" | "nodeId">): Promise<string>;
editInspectorState(payload: DevToolsV6PluginAPIHookPayloads[DevToolsV6PluginAPIHookKeys.EDIT_INSPECTOR_STATE]): Promise<void>;
sendInspectorState(id: string): void;
inspectComponentInspector(): Promise<string>;
cancelInspectComponentInspector(): void;
getComponentRenderCode(id: string): any;
scrollToComponent(id: string): void;
inspectDOM(id: string): void;
getInspectorNodeActions(id: string): {
icon: string;
tooltip?: string;
action: (nodeId: string) => void | Promise<void>;
}[] | undefined;
getInspectorActions(id: string): {
icon: string;
tooltip?: string;
action: () => void | Promise<void>;
}[] | undefined;
updateTimelineLayersState(state: Record<string, boolean>): void;
callInspectorNodeAction(inspectorId: string, actionIndex: number, nodeId: string): void;
callInspectorAction(inspectorId: string, actionIndex: number): void;
openInEditor(options: OpenInEditorOptions): void;
checkVueInspectorDetected(): Promise<boolean>;
enableVueInspector(): Promise<void>;
toggleApp(id: string, options?: {
inspectingComponent?: boolean;
}): Promise<void>;
updatePluginSettings(pluginId: string, key: string, value: string): void;
getPluginSettings(pluginId: string): {
options: Record<string, {
label: string;
description?: string;
} & ({
type: "boolean";
defaultValue: boolean;
} | {
type: "choice";
defaultValue: string | number;
options: {
value: string | number;
label: string;
}[];
component?: "select" | "button-group";
} | {
type: "text";
defaultValue: string;
})> | null;
values: any;
};
getRouterInfo(): _vue_devtools_kit.RouterInfo;
navigate(path: string): Promise<void | vue_router.NavigationFailure | {} | undefined>;
getMatchedRoutes(path: string): vue_router.RouteRecordNormalized[];
toggleClientConnected(state: boolean): void;
getCustomInspector(): {
id: string;
label: string;
logo: string;
icon: string;
packageName: string | undefined;
homepage: string | undefined;
pluginId: string;
}[];
getInspectorInfo(id: string): {
id: string;
label: string;
logo: string | undefined;
packageName: string | undefined;
homepage: string | undefined;
timelineLayers: {
id: string;
label: string;
color: number;
}[];
treeFilterPlaceholder: string;
stateFilterPlaceholder: string;
} | undefined;
highlighComponent(uid: string): Promise<any>;
unhighlight(): Promise<any>;
updateDevToolsClientDetected(params: Record<string, boolean>): void;
initDevToolsServerListener(): void;
};
type RPCFunctions = typeof functions;
declare const rpc: {
value: ReturnType<typeof getRpcClient<RPCFunctions>>;
functions: ReturnType<typeof getRpcClient<RPCFunctions>>;
};
declare const rpcServer: {
value: ReturnType<typeof getRpcServer<RPCFunctions>>;
functions: ReturnType<typeof getRpcServer<RPCFunctions>>;
};
declare function onRpcConnected(callback: () => void): void;
declare function onRpcSeverReady(callback: () => void): void;
type AssetType = 'image' | 'font' | 'video' | 'audio' | 'text' | 'json' | 'wasm' | 'other';
interface AssetInfo {
path: string;
type: AssetType;
publicPath: string;
relativePath: string;
filePath: string;
size: number;
mtime: number;
}
interface ImageMeta {
width: number;
height: number;
orientation?: number;
type?: string;
mimeType?: string;
}
type AssetImporter = Pick<ModuleNode, 'url' | 'id'>;
interface AssetEntry {
path: string;
content: string;
encoding?: BufferEncoding;
override?: boolean;
}
interface CodeSnippet {
code: string;
lang: string;
name: string;
docs?: string;
}
interface ModuleInfo {
id: string;
plugins: {
name: string;
transform?: number;
resolveId?: number;
}[];
deps: string[];
virtual: boolean;
}
declare const viteRpcFunctions: {
on: (event: string, handler: Function) => void;
off: (event: string, handler: Function) => void;
once: (event: string, handler: Function) => void;
emit: (event: string, ...args: any[]) => void;
heartbeat: () => boolean;
};
type ViteRPCFunctions = typeof viteRpcFunctions & {
getStaticAssets: () => Promise<AssetInfo[]>;
getAssetImporters: (url: string) => Promise<AssetImporter[]>;
getImageMeta: (filepath: string) => Promise<ImageMeta>;
getTextAssetContent: (filepath: string, limit?: number) => Promise<string>;
getRoot: () => Promise<string>;
getGraphModules: () => Promise<ModuleInfo[]>;
};
declare const viteRpc: {
value: ReturnType<typeof getViteRpcClient<ViteRPCFunctions>>;
functions: ReturnType<typeof getViteRpcClient<ViteRPCFunctions>>;
};
declare function onViteRpcConnected(callback: () => void): void;
declare function createViteClientRpc(): void;
declare function createViteServerRpc(functions: Record<string, any>): void;
interface DevToolsState {
connected: boolean;
clientConnected: boolean;
vueVersion: string;
tabs: CustomTab[];
commands: CustomCommand[];
vitePluginDetected: boolean;
appRecords: AppRecord[];
activeAppRecordId: string;
timelineLayersState: Record<string, boolean>;
}
type DevToolsRefState = {
[P in keyof DevToolsState]: Ref<DevToolsState[P]>;
};
declare function VueDevToolsVuePlugin(): {
install(app: App): void;
};
declare function createDevToolsStateContext(): {
getDevToolsState: () => void;
connected: Ref<boolean, boolean>;
clientConnected: Ref<boolean, boolean>;
vueVersion: Ref<string, string>;
tabs: Ref<{
name: string;
icon?: string | undefined;
title: string;
view: {
type: "iframe";
src: string;
persistent?: boolean | undefined;
} | {
type: "vnode";
vnode: VNode;
} | {
type: "sfc";
sfc: string;
};
category?: ("app" | "pinned" | "modules" | "advanced") | undefined;
}[], CustomTab[] | {
name: string;
icon?: string | undefined;
title: string;
view: {
type: "iframe";
src: string;
persistent?: boolean | undefined;
} | {
type: "vnode";
vnode: VNode;
} | {
type: "sfc";
sfc: string;
};
category?: ("app" | "pinned" | "modules" | "advanced") | undefined;
}[]>;
commands: Ref<{
id: string;
title: string;
description?: string | undefined;
order?: number | undefined;
icon?: string | undefined;
action?: {
type: "url";
src: string;
} | undefined;
children?: {
title: string;
id: string;
icon?: string | undefined;
description?: string | undefined;
order?: number | undefined;
action?: {
type: "url";
src: string;
} | undefined;
}[] | undefined;
}[], CustomCommand[] | {
id: string;
title: string;
description?: string | undefined;
order?: number | undefined;
icon?: string | undefined;
action?: {
type: "url";
src: string;
} | undefined;
children?: {
title: string;
id: string;
icon?: string | undefined;
description?: string | undefined;
order?: number | undefined;
action?: {
type: "url";
src: string;
} | undefined;
}[] | undefined;
}[]>;
vitePluginDetected: Ref<boolean, boolean>;
appRecords: Ref<{
id: string;
name: string;
app?: _vue_devtools_kit.App;
version?: string | undefined;
types?: Record<string, string | symbol> | undefined;
instanceMap: Map<string, any> & Omit<Map<string, any>, keyof Map<any, any>>;
perfGroupIds: Map<string, {
groupId: number;
time: number;
}> & Omit<Map<string, {
groupId: number;
time: number;
}>, keyof Map<any, any>>;
rootInstance: _vue_devtools_kit.VueAppInstance;
routerId?: string | undefined;
}[], AppRecord[] | {
id: string;
name: string;
app?: _vue_devtools_kit.App;
version?: string | undefined;
types?: Record<string, string | symbol> | undefined;
instanceMap: Map<string, any> & Omit<Map<string, any>, keyof Map<any, any>>;
perfGroupIds: Map<string, {
groupId: number;
time: number;
}> & Omit<Map<string, {
groupId: number;
time: number;
}>, keyof Map<any, any>>;
rootInstance: _vue_devtools_kit.VueAppInstance;
routerId?: string | undefined;
}[]>;
activeAppRecordId: Ref<string, string>;
timelineLayersState: Ref<Record<string, boolean>, Record<string, boolean>>;
};
declare function useDevToolsState(): DevToolsRefState;
declare function onDevToolsConnected(fn: () => void): () => void;
declare function refreshCurrentPageData(): void;
export { type AssetEntry, type AssetImporter, type AssetInfo, type AssetType, type CodeSnippet, DevToolsMessagingEvents, type ImageMeta, type ModuleInfo, type RPCFunctions, type ViteRPCFunctions, VueDevToolsVuePlugin, createDevToolsStateContext, createViteClientRpc, createViteServerRpc, functions, getDevToolsClientUrl, onDevToolsConnected, onRpcConnected, onRpcSeverReady, onViteRpcConnected, refreshCurrentPageData, rpc, rpcServer, setDevToolsClientUrl, useDevToolsState, viteRpc, viteRpcFunctions };

645
node_modules/@vue/devtools-core/dist/index.js generated vendored Normal file
View File

@@ -0,0 +1,645 @@
// src/client.ts
import { isBrowser, target } from "@vue/devtools-shared";
function setDevToolsClientUrl(url) {
target.__VUE_DEVTOOLS_CLIENT_URL__ = url;
}
function getDevToolsClientUrl() {
var _a;
return (_a = target.__VUE_DEVTOOLS_CLIENT_URL__) != null ? _a : (() => {
if (isBrowser) {
const devtoolsMeta = document.querySelector("meta[name=__VUE_DEVTOOLS_CLIENT_URL__]");
if (devtoolsMeta)
return devtoolsMeta.getAttribute("content");
}
return "";
})();
}
// src/rpc/global.ts
import { devtools, DevToolsContextHookKeys, DevToolsMessagingHookKeys, devtoolsRouter, devtoolsRouterInfo, getActiveInspectors, getInspector, getInspectorActions, getInspectorInfo, getInspectorNodeActions, getRpcClient, getRpcServer, stringify, toggleClientConnected, updateDevToolsClientDetected, updateTimelineLayersState } from "@vue/devtools-kit";
// ../../node_modules/.pnpm/hookable@5.5.3/node_modules/hookable/dist/index.mjs
function flatHooks(configHooks, hooks3 = {}, parentName) {
for (const key in configHooks) {
const subHook = configHooks[key];
const name = parentName ? `${parentName}:${key}` : key;
if (typeof subHook === "object" && subHook !== null) {
flatHooks(subHook, hooks3, name);
} else if (typeof subHook === "function") {
hooks3[name] = subHook;
}
}
return hooks3;
}
var defaultTask = { run: (function_) => function_() };
var _createTask = () => defaultTask;
var createTask = typeof console.createTask !== "undefined" ? console.createTask : _createTask;
function serialTaskCaller(hooks3, args) {
const name = args.shift();
const task = createTask(name);
return hooks3.reduce(
(promise, hookFunction) => promise.then(() => task.run(() => hookFunction(...args))),
Promise.resolve()
);
}
function parallelTaskCaller(hooks3, args) {
const name = args.shift();
const task = createTask(name);
return Promise.all(hooks3.map((hook) => task.run(() => hook(...args))));
}
function callEachWith(callbacks, arg0) {
for (const callback of [...callbacks]) {
callback(arg0);
}
}
var Hookable = class {
constructor() {
this._hooks = {};
this._before = void 0;
this._after = void 0;
this._deprecatedMessages = void 0;
this._deprecatedHooks = {};
this.hook = this.hook.bind(this);
this.callHook = this.callHook.bind(this);
this.callHookWith = this.callHookWith.bind(this);
}
hook(name, function_, options = {}) {
if (!name || typeof function_ !== "function") {
return () => {
};
}
const originalName = name;
let dep;
while (this._deprecatedHooks[name]) {
dep = this._deprecatedHooks[name];
name = dep.to;
}
if (dep && !options.allowDeprecated) {
let message = dep.message;
if (!message) {
message = `${originalName} hook has been deprecated` + (dep.to ? `, please use ${dep.to}` : "");
}
if (!this._deprecatedMessages) {
this._deprecatedMessages = /* @__PURE__ */ new Set();
}
if (!this._deprecatedMessages.has(message)) {
console.warn(message);
this._deprecatedMessages.add(message);
}
}
if (!function_.name) {
try {
Object.defineProperty(function_, "name", {
get: () => "_" + name.replace(/\W+/g, "_") + "_hook_cb",
configurable: true
});
} catch (e) {
}
}
this._hooks[name] = this._hooks[name] || [];
this._hooks[name].push(function_);
return () => {
if (function_) {
this.removeHook(name, function_);
function_ = void 0;
}
};
}
hookOnce(name, function_) {
let _unreg;
let _function = (...arguments_) => {
if (typeof _unreg === "function") {
_unreg();
}
_unreg = void 0;
_function = void 0;
return function_(...arguments_);
};
_unreg = this.hook(name, _function);
return _unreg;
}
removeHook(name, function_) {
if (this._hooks[name]) {
const index = this._hooks[name].indexOf(function_);
if (index !== -1) {
this._hooks[name].splice(index, 1);
}
if (this._hooks[name].length === 0) {
delete this._hooks[name];
}
}
}
deprecateHook(name, deprecated) {
this._deprecatedHooks[name] = typeof deprecated === "string" ? { to: deprecated } : deprecated;
const _hooks = this._hooks[name] || [];
delete this._hooks[name];
for (const hook of _hooks) {
this.hook(name, hook);
}
}
deprecateHooks(deprecatedHooks) {
Object.assign(this._deprecatedHooks, deprecatedHooks);
for (const name in deprecatedHooks) {
this.deprecateHook(name, deprecatedHooks[name]);
}
}
addHooks(configHooks) {
const hooks3 = flatHooks(configHooks);
const removeFns = Object.keys(hooks3).map(
(key) => this.hook(key, hooks3[key])
);
return () => {
for (const unreg of removeFns.splice(0, removeFns.length)) {
unreg();
}
};
}
removeHooks(configHooks) {
const hooks3 = flatHooks(configHooks);
for (const key in hooks3) {
this.removeHook(key, hooks3[key]);
}
}
removeAllHooks() {
for (const key in this._hooks) {
delete this._hooks[key];
}
}
callHook(name, ...arguments_) {
arguments_.unshift(name);
return this.callHookWith(serialTaskCaller, name, ...arguments_);
}
callHookParallel(name, ...arguments_) {
arguments_.unshift(name);
return this.callHookWith(parallelTaskCaller, name, ...arguments_);
}
callHookWith(caller, name, ...arguments_) {
const event = this._before || this._after ? { name, args: arguments_, context: {} } : void 0;
if (this._before) {
callEachWith(this._before, event);
}
const result = caller(
name in this._hooks ? [...this._hooks[name]] : [],
arguments_
);
if (result instanceof Promise) {
return result.finally(() => {
if (this._after && event) {
callEachWith(this._after, event);
}
});
}
if (this._after && event) {
callEachWith(this._after, event);
}
return result;
}
beforeEach(function_) {
this._before = this._before || [];
this._before.push(function_);
return () => {
if (this._before !== void 0) {
const index = this._before.indexOf(function_);
if (index !== -1) {
this._before.splice(index, 1);
}
}
};
}
afterEach(function_) {
this._after = this._after || [];
this._after.push(function_);
return () => {
if (this._after !== void 0) {
const index = this._after.indexOf(function_);
if (index !== -1) {
this._after.splice(index, 1);
}
}
};
}
};
function createHooks() {
return new Hookable();
}
// src/rpc/global.ts
var hooks = createHooks();
var DevToolsMessagingEvents = /* @__PURE__ */ ((DevToolsMessagingEvents2) => {
DevToolsMessagingEvents2["INSPECTOR_TREE_UPDATED"] = "inspector-tree-updated";
DevToolsMessagingEvents2["INSPECTOR_STATE_UPDATED"] = "inspector-state-updated";
DevToolsMessagingEvents2["DEVTOOLS_STATE_UPDATED"] = "devtools-state-updated";
DevToolsMessagingEvents2["ROUTER_INFO_UPDATED"] = "router-info-updated";
DevToolsMessagingEvents2["TIMELINE_EVENT_UPDATED"] = "timeline-event-updated";
DevToolsMessagingEvents2["INSPECTOR_UPDATED"] = "inspector-updated";
DevToolsMessagingEvents2["ACTIVE_APP_UNMOUNTED"] = "active-app-updated";
DevToolsMessagingEvents2["DESTROY_DEVTOOLS_CLIENT"] = "destroy-devtools-client";
DevToolsMessagingEvents2["RELOAD_DEVTOOLS_CLIENT"] = "reload-devtools-client";
return DevToolsMessagingEvents2;
})(DevToolsMessagingEvents || {});
function getDevToolsState() {
var _a;
const state = devtools.ctx.state;
return {
connected: state.connected,
clientConnected: true,
vueVersion: ((_a = state == null ? void 0 : state.activeAppRecord) == null ? void 0 : _a.version) || "",
tabs: state.tabs,
commands: state.commands,
vitePluginDetected: state.vitePluginDetected,
appRecords: state.appRecords.map((item) => ({
id: item.id,
name: item.name,
version: item.version,
routerId: item.routerId
})),
activeAppRecordId: state.activeAppRecordId,
timelineLayersState: state.timelineLayersState
};
}
var functions = {
on: (event, handler) => {
hooks.hook(event, handler);
},
off: (event, handler) => {
hooks.removeHook(event, handler);
},
once: (event, handler) => {
hooks.hookOnce(event, handler);
},
emit: (event, ...args) => {
hooks.callHook(event, ...args);
},
heartbeat: () => {
return true;
},
devtoolsState: () => {
return getDevToolsState();
},
async getInspectorTree(payload) {
const res = await devtools.ctx.api.getInspectorTree(payload);
return stringify(res);
},
async getInspectorState(payload) {
const inspector = getInspector(payload.inspectorId);
if (inspector)
inspector.selectedNodeId = payload.nodeId;
const res = await devtools.ctx.api.getInspectorState(payload);
return stringify(res);
},
async editInspectorState(payload) {
return await devtools.ctx.api.editInspectorState(payload);
},
sendInspectorState(id) {
return devtools.ctx.api.sendInspectorState(id);
},
inspectComponentInspector() {
return devtools.ctx.api.inspectComponentInspector();
},
cancelInspectComponentInspector() {
return devtools.ctx.api.cancelInspectComponentInspector();
},
getComponentRenderCode(id) {
return devtools.ctx.api.getComponentRenderCode(id);
},
scrollToComponent(id) {
return devtools.ctx.api.scrollToComponent(id);
},
inspectDOM(id) {
return devtools.ctx.api.inspectDOM(id);
},
getInspectorNodeActions(id) {
return getInspectorNodeActions(id);
},
getInspectorActions(id) {
return getInspectorActions(id);
},
updateTimelineLayersState(state) {
return updateTimelineLayersState(state);
},
callInspectorNodeAction(inspectorId, actionIndex, nodeId) {
var _a;
const nodeActions = getInspectorNodeActions(inspectorId);
if (nodeActions == null ? void 0 : nodeActions.length) {
const item = nodeActions[actionIndex];
(_a = item.action) == null ? void 0 : _a.call(item, nodeId);
}
},
callInspectorAction(inspectorId, actionIndex) {
var _a;
const actions = getInspectorActions(inspectorId);
if (actions == null ? void 0 : actions.length) {
const item = actions[actionIndex];
(_a = item.action) == null ? void 0 : _a.call(item);
}
},
openInEditor(options) {
return devtools.ctx.api.openInEditor(options);
},
async checkVueInspectorDetected() {
return !!await devtools.ctx.api.getVueInspector();
},
async enableVueInspector() {
var _a, _b, _c;
const inspector = await ((_c = (_b = (_a = devtools) == null ? void 0 : _a.api) == null ? void 0 : _b.getVueInspector) == null ? void 0 : _c.call(_b));
if (inspector)
await inspector.enable();
},
async toggleApp(id, options) {
return devtools.ctx.api.toggleApp(id, options);
},
updatePluginSettings(pluginId, key, value) {
return devtools.ctx.api.updatePluginSettings(pluginId, key, value);
},
getPluginSettings(pluginId) {
return devtools.ctx.api.getPluginSettings(pluginId);
},
getRouterInfo() {
return devtoolsRouterInfo;
},
navigate(path) {
var _a;
return (_a = devtoolsRouter.value) == null ? void 0 : _a.push(path).catch(() => ({}));
},
getMatchedRoutes(path) {
var _a, _b, _c;
const c = console.warn;
console.warn = () => {
};
const matched = (_c = (_b = (_a = devtoolsRouter.value) == null ? void 0 : _a.resolve) == null ? void 0 : _b.call(_a, {
path: path || "/"
}).matched) != null ? _c : [];
console.warn = c;
return matched;
},
toggleClientConnected(state) {
toggleClientConnected(state);
},
getCustomInspector() {
return getActiveInspectors();
},
getInspectorInfo(id) {
return getInspectorInfo(id);
},
highlighComponent(uid) {
return devtools.ctx.hooks.callHook(DevToolsContextHookKeys.COMPONENT_HIGHLIGHT, { uid });
},
unhighlight() {
return devtools.ctx.hooks.callHook(DevToolsContextHookKeys.COMPONENT_UNHIGHLIGHT);
},
updateDevToolsClientDetected(params) {
updateDevToolsClientDetected(params);
},
// listen to devtools server events
initDevToolsServerListener() {
const rpcServer2 = getRpcServer();
const broadcast = rpcServer2.broadcast;
devtools.ctx.hooks.hook(DevToolsMessagingHookKeys.SEND_INSPECTOR_TREE_TO_CLIENT, (payload) => {
broadcast.emit("inspector-tree-updated" /* INSPECTOR_TREE_UPDATED */, stringify(payload));
});
devtools.ctx.hooks.hook(DevToolsMessagingHookKeys.SEND_INSPECTOR_STATE_TO_CLIENT, (payload) => {
broadcast.emit("inspector-state-updated" /* INSPECTOR_STATE_UPDATED */, stringify(payload));
});
devtools.ctx.hooks.hook(DevToolsMessagingHookKeys.DEVTOOLS_STATE_UPDATED, () => {
broadcast.emit("devtools-state-updated" /* DEVTOOLS_STATE_UPDATED */, getDevToolsState());
});
devtools.ctx.hooks.hook(DevToolsMessagingHookKeys.ROUTER_INFO_UPDATED, ({ state }) => {
broadcast.emit("router-info-updated" /* ROUTER_INFO_UPDATED */, state);
});
devtools.ctx.hooks.hook(DevToolsMessagingHookKeys.SEND_TIMELINE_EVENT_TO_CLIENT, (payload) => {
broadcast.emit("timeline-event-updated" /* TIMELINE_EVENT_UPDATED */, stringify(payload));
});
devtools.ctx.hooks.hook(DevToolsMessagingHookKeys.SEND_INSPECTOR_TO_CLIENT, (payload) => {
broadcast.emit("inspector-updated" /* INSPECTOR_UPDATED */, payload);
});
devtools.ctx.hooks.hook(DevToolsMessagingHookKeys.SEND_ACTIVE_APP_UNMOUNTED_TO_CLIENT, () => {
broadcast.emit("active-app-updated" /* ACTIVE_APP_UNMOUNTED */);
});
}
};
var rpc = new Proxy({
value: {},
functions: {}
}, {
get(target2, property) {
const _rpc = getRpcClient();
if (property === "value") {
return _rpc;
} else if (property === "functions") {
return _rpc.$functions;
}
}
});
var rpcServer = new Proxy({
value: {},
functions: {}
}, {
get(target2, property) {
const _rpc = getRpcServer();
if (property === "value") {
return _rpc;
} else if (property === "functions") {
return _rpc.functions;
}
}
});
function onRpcConnected(callback) {
let timer = null;
let retryCount = 0;
function heartbeat() {
var _a, _b;
(_b = (_a = rpc.value) == null ? void 0 : _a.heartbeat) == null ? void 0 : _b.call(_a).then(() => {
callback();
clearTimeout(timer);
}).catch(() => {
});
}
timer = setInterval(() => {
if (retryCount >= 30) {
clearTimeout(timer);
}
retryCount++;
heartbeat();
}, retryCount * 200 + 200);
heartbeat();
}
function onRpcSeverReady(callback) {
let timer = null;
const timeout = 120;
function heartbeat() {
if (rpcServer.value.clients.length > 0) {
callback();
clearTimeout(timer);
}
}
timer = setInterval(() => {
heartbeat();
}, timeout);
}
// src/rpc/vite.ts
import { createRpcClient, createRpcServer, getViteRpcClient } from "@vue/devtools-kit";
var hooks2 = createHooks();
var viteRpcFunctions = {
on: (event, handler) => {
hooks2.hook(event, handler);
},
off: (event, handler) => {
hooks2.removeHook(event, handler);
},
once: (event, handler) => {
hooks2.hookOnce(event, handler);
},
emit: (event, ...args) => {
hooks2.callHook(event, ...args);
},
heartbeat: () => {
return true;
}
};
var viteRpc = new Proxy({
value: {},
functions: {}
}, {
get(target2, property) {
const _rpc = getViteRpcClient();
if (property === "value") {
return _rpc;
} else if (property === "functions") {
return _rpc == null ? void 0 : _rpc.$functions;
}
}
});
function onViteRpcConnected(callback) {
let timer = null;
function heartbeat() {
var _a, _b;
(_b = (_a = viteRpc.value) == null ? void 0 : _a.heartbeat) == null ? void 0 : _b.call(_a).then(() => {
clearTimeout(timer);
callback();
}).catch(() => ({}));
timer = setTimeout(() => {
heartbeat();
}, 80);
}
heartbeat();
}
function createViteClientRpc() {
createRpcClient(viteRpcFunctions, {
preset: "vite"
});
}
function createViteServerRpc(functions2) {
createRpcServer(functions2, {
preset: "vite"
});
}
// src/vue-plugin/devtools-state.ts
import { computed, inject, onUnmounted, ref, watch } from "vue";
var VueDevToolsStateSymbol = Symbol.for("__VueDevToolsStateSymbol__");
function VueDevToolsVuePlugin() {
return {
install(app) {
const state = createDevToolsStateContext();
state.getDevToolsState();
app.provide(VueDevToolsStateSymbol, state);
app.config.globalProperties.$getDevToolsState = state.getDevToolsState;
app.config.globalProperties.$disconnectDevToolsClient = () => {
state.clientConnected.value = false;
state.connected.value = false;
};
}
};
}
function createDevToolsStateContext() {
const connected = ref(false);
const clientConnected = ref(false);
const vueVersion = ref("");
const tabs = ref([]);
const commands = ref([]);
const vitePluginDetected = ref(false);
const appRecords = ref([]);
const activeAppRecordId = ref("");
const timelineLayersState = ref({});
function updateState(data) {
connected.value = data.connected;
clientConnected.value = data.clientConnected;
vueVersion.value = data.vueVersion || "";
tabs.value = data.tabs;
commands.value = data.commands;
vitePluginDetected.value = data.vitePluginDetected;
appRecords.value = data.appRecords;
activeAppRecordId.value = data.activeAppRecordId;
timelineLayersState.value = data.timelineLayersState;
}
function getDevToolsState2() {
onRpcConnected(() => {
rpc.value.devtoolsState().then((data) => {
updateState(data);
});
rpc.functions.off("devtools-state-updated" /* DEVTOOLS_STATE_UPDATED */, updateState);
rpc.functions.on("devtools-state-updated" /* DEVTOOLS_STATE_UPDATED */, updateState);
});
}
return {
getDevToolsState: getDevToolsState2,
connected,
clientConnected,
vueVersion,
tabs,
commands,
vitePluginDetected,
appRecords,
activeAppRecordId,
timelineLayersState
};
}
function useDevToolsState() {
return inject(VueDevToolsStateSymbol);
}
var fns = [];
function onDevToolsConnected(fn) {
const { connected, clientConnected } = useDevToolsState();
fns.push(fn);
onUnmounted(() => {
fns.splice(fns.indexOf(fn), 1);
});
const devtoolsReady = computed(() => clientConnected.value && connected.value);
if (devtoolsReady.value) {
fn();
} else {
const stop = watch(devtoolsReady, (v) => {
if (v) {
fn();
stop();
}
});
}
return () => {
fns.splice(fns.indexOf(fn), 1);
};
}
function refreshCurrentPageData() {
fns.forEach((fn) => fn());
}
export {
DevToolsMessagingEvents,
VueDevToolsVuePlugin,
createDevToolsStateContext,
createViteClientRpc,
createViteServerRpc,
functions,
getDevToolsClientUrl,
onDevToolsConnected,
onRpcConnected,
onRpcSeverReady,
onViteRpcConnected,
refreshCurrentPageData,
rpc,
rpcServer,
setDevToolsClientUrl,
useDevToolsState,
viteRpc,
viteRpcFunctions
};

View File

@@ -0,0 +1,16 @@
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*)
if command -v cygpath > /dev/null 2>&1; then
basedir=`cygpath -w "$basedir"`
fi
;;
esac
if [ -x "$basedir/node" ]; then
exec "$basedir/node" "$basedir/../nanoid/bin/nanoid.js" "$@"
else
exec node "$basedir/../nanoid/bin/nanoid.js" "$@"
fi

View File

@@ -0,0 +1,17 @@
@ECHO off
GOTO start
:find_dp0
SET dp0=%~dp0
EXIT /b
:start
SETLOCAL
CALL :find_dp0
IF EXIST "%dp0%\node.exe" (
SET "_prog=%dp0%\node.exe"
) ELSE (
SET "_prog=node"
SET PATHEXT=%PATHEXT:;.JS;=;%
)
endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\nanoid\bin\nanoid.js" %*

View File

@@ -0,0 +1,28 @@
#!/usr/bin/env pwsh
$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
$exe=""
if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
# Fix case when both the Windows and Linux builds of Node
# are installed in the same directory
$exe=".exe"
}
$ret=0
if (Test-Path "$basedir/node$exe") {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.js" $args
} else {
& "$basedir/node$exe" "$basedir/../nanoid/bin/nanoid.js" $args
}
$ret=$LASTEXITCODE
} else {
# Support pipeline input
if ($MyInvocation.ExpectingInput) {
$input | & "node$exe" "$basedir/../nanoid/bin/nanoid.js" $args
} else {
& "node$exe" "$basedir/../nanoid/bin/nanoid.js" $args
}
$ret=$LASTEXITCODE
}
exit $ret

View File

@@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright 2017 Andrey Sitnik <andrey@sitnik.ru>
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.

View File

@@ -0,0 +1,38 @@
# Nano ID
<img src="https://ai.github.io/nanoid/logo.svg" align="right"
alt="Nano ID logo by Anton Lovchikov" width="180" height="94">
**English** | [Русский](./README.ru.md) | [简体中文](./README.zh-CN.md) | [Bahasa Indonesia](./README.id-ID.md)
A tiny, secure, URL-friendly, unique string ID generator for JavaScript.
> “An amazing level of senseless perfectionism,
> which is simply impossible not to respect.”
* **Small.** 118 bytes (minified and brotlied). No dependencies.
[Size Limit] controls the size.
* **Safe.** It uses hardware random generator. Can be used in clusters.
* **Short IDs.** It uses a larger alphabet than UUID (`A-Za-z0-9_-`).
So ID size was reduced from 36 to 21 symbols.
* **Portable.** Nano ID was ported
to over [20 programming languages](./README.md#other-programming-languages).
```js
import { nanoid } from 'nanoid'
model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
```
---
<img src="https://cdn.evilmartians.com/badges/logo-no-label.svg" alt="" width="22" height="16" />  Made at <b><a href="https://evilmartians.com/devtools?utm_source=nanoid&utm_campaign=devtools-button&utm_medium=github">Evil Martians</a></b>, product consulting for <b>developer tools</b>.
---
[online tool]: https://gitpod.io/#https://github.com/ai/nanoid/
[with Babel]: https://developer.epages.com/blog/coding/how-to-transpile-node-modules-with-babel-and-webpack-in-a-monorepo/
[Size Limit]: https://github.com/ai/size-limit
## Docs
Read full docs **[here](https://github.com/ai/nanoid#readme)**.

View File

@@ -0,0 +1,45 @@
#!/usr/bin/env node
import { customAlphabet, nanoid } from '../index.js'
function print(msg) {
process.stdout.write(msg + '\n')
}
function error(msg) {
process.stderr.write(msg + '\n')
process.exit(1)
}
if (process.argv.includes('--help') || process.argv.includes('-h')) {
print(`Usage
$ nanoid [options]
Options
-s, --size Generated ID size
-a, --alphabet Alphabet to use
-h, --help Show this help
Examples
$ nanoid -s 15
S9sBF77U6sDB8Yg
$ nanoid --size 10 --alphabet abc
bcabababca`)
process.exit()
}
let alphabet, size
for (let i = 2; i < process.argv.length; i++) {
let arg = process.argv[i]
if (arg === '--size' || arg === '-s') {
size = Number(process.argv[i + 1])
i += 1
if (Number.isNaN(size) || size <= 0) {
error('Size must be positive integer')
}
} else if (arg === '--alphabet' || arg === '-a') {
alphabet = process.argv[i + 1]
i += 1
} else {
error('Unknown argument ' + arg)
}
}
if (alphabet) {
let customNanoid = customAlphabet(alphabet, size)
print(customNanoid())
} else {
print(nanoid(size))
}

View File

@@ -0,0 +1,29 @@
/* @ts-self-types="./index.d.ts" */
import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'
export { urlAlphabet } from './url-alphabet/index.js'
export let random = bytes => crypto.getRandomValues(new Uint8Array(bytes))
export let customRandom = (alphabet, defaultSize, getRandom) => {
let mask = (2 << Math.log2(alphabet.length - 1)) - 1
let step = -~((1.6 * mask * defaultSize) / alphabet.length)
return (size = defaultSize) => {
let id = ''
while (true) {
let bytes = getRandom(step)
let j = step | 0
while (j--) {
id += alphabet[bytes[j] & mask] || ''
if (id.length >= size) return id
}
}
}
}
export let customAlphabet = (alphabet, size = 21) =>
customRandom(alphabet, size | 0, random)
export let nanoid = (size = 21) => {
let id = ''
let bytes = crypto.getRandomValues(new Uint8Array((size |= 0)))
while (size--) {
id += scopedUrlAlphabet[bytes[size] & 63]
}
return id
}

View File

@@ -0,0 +1,106 @@
/**
* A tiny, secure, URL-friendly, unique string ID generator for JavaScript
* with hardware random generator.
*
* ```js
* import { nanoid } from 'nanoid'
* model.id = nanoid() //=> "V1StGXR8_Z5jdHi6B-myT"
* ```
*
* @module
*/
/**
* Generate secure URL-friendly unique ID.
*
* By default, the ID will have 21 symbols to have a collision probability
* similar to UUID v4.
*
* ```js
* import { nanoid } from 'nanoid'
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
* ```
*
* @param size Size of the ID. The default size is 21.
* @typeparam Type The ID type to replace `string` with some opaque type.
* @returns A random string.
*/
export function nanoid<Type extends string>(size?: number): Type
/**
* Generate secure unique ID with custom alphabet.
*
* Alphabet must contain 256 symbols or less. Otherwise, the generator
* will not be secure.
*
* @param alphabet Alphabet used to generate the ID.
* @param defaultSize Size of the ID. The default size is 21.
* @typeparam Type The ID type to replace `string` with some opaque type.
* @returns A random string generator.
*
* ```js
* const { customAlphabet } = require('nanoid')
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
* nanoid() //=> "8ё56а"
* ```
*/
export function customAlphabet<Type extends string>(
alphabet: string,
defaultSize?: number
): (size?: number) => Type
/**
* Generate unique ID with custom random generator and alphabet.
*
* Alphabet must contain 256 symbols or less. Otherwise, the generator
* will not be secure.
*
* ```js
* import { customRandom } from 'nanoid/format'
*
* const nanoid = customRandom('abcdef', 5, size => {
* const random = []
* for (let i = 0; i < size; i++) {
* random.push(randomByte())
* }
* return random
* })
*
* nanoid() //=> "fbaef"
* ```
*
* @param alphabet Alphabet used to generate a random string.
* @param size Size of the random string.
* @param random A random bytes generator.
* @typeparam Type The ID type to replace `string` with some opaque type.
* @returns A random string generator.
*/
export function customRandom<Type extends string>(
alphabet: string,
size: number,
random: (bytes: number) => Uint8Array
): () => Type
/**
* URL safe symbols.
*
* ```js
* import { urlAlphabet } from 'nanoid'
* const nanoid = customAlphabet(urlAlphabet, 10)
* nanoid() //=> "Uakgb_J5m9"
* ```
*/
export const urlAlphabet: string
/**
* Generate an array of random bytes collected from hardware noise.
*
* ```js
* import { customRandom, random } from 'nanoid'
* const nanoid = customRandom("abcdef", 5, random)
* ```
*
* @param bytes Size of the array.
* @returns An array of random bytes.
*/
export function random(bytes: number): Uint8Array

View File

@@ -0,0 +1,46 @@
import { webcrypto as crypto } from 'node:crypto'
import { urlAlphabet as scopedUrlAlphabet } from './url-alphabet/index.js'
export { urlAlphabet } from './url-alphabet/index.js'
const POOL_SIZE_MULTIPLIER = 128
let pool, poolOffset
function fillPool(bytes) {
if (!pool || pool.length < bytes) {
pool = Buffer.allocUnsafe(bytes * POOL_SIZE_MULTIPLIER)
crypto.getRandomValues(pool)
poolOffset = 0
} else if (poolOffset + bytes > pool.length) {
crypto.getRandomValues(pool)
poolOffset = 0
}
poolOffset += bytes
}
export function random(bytes) {
fillPool((bytes |= 0))
return pool.subarray(poolOffset - bytes, poolOffset)
}
export function customRandom(alphabet, defaultSize, getRandom) {
let mask = (2 << (31 - Math.clz32((alphabet.length - 1) | 1))) - 1
let step = Math.ceil((1.6 * mask * defaultSize) / alphabet.length)
return (size = defaultSize) => {
let id = ''
while (true) {
let bytes = getRandom(step)
let i = step
while (i--) {
id += alphabet[bytes[i] & mask] || ''
if (id.length >= size) return id
}
}
}
}
export function customAlphabet(alphabet, size = 21) {
return customRandom(alphabet, size, random)
}
export function nanoid(size = 21) {
fillPool((size |= 0))
let id = ''
for (let i = poolOffset - size; i < poolOffset; i++) {
id += scopedUrlAlphabet[pool[i] & 63]
}
return id
}

View File

@@ -0,0 +1 @@
let a="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";export let nanoid=(e=21)=>{let t="",r=crypto.getRandomValues(new Uint8Array(e));for(let n=0;n<e;n++)t+=a[63&r[n]];return t};

View File

@@ -0,0 +1,48 @@
/**
* By default, Nano ID uses hardware random bytes generation for security
* and low collision probability. If you are not so concerned with security,
* you can use it for environments without hardware random generators.
*
* ```js
* import { nanoid } from 'nanoid/non-secure'
* const id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqLJ"
* ```
*
* @module
*/
/**
* Generate URL-friendly unique ID. This method uses the non-secure
* predictable random generator with bigger collision probability.
*
* ```js
* import { nanoid } from 'nanoid/non-secure'
* model.id = nanoid() //=> "Uakgb_J5m9g-0JDMbcJqL"
* ```
*
* @param size Size of the ID. The default size is 21.
* @typeparam Type The ID type to replace `string` with some opaque type.
* @returns A random string.
*/
export function nanoid<Type extends string>(size?: number): Type
/**
* Generate a unique ID based on a custom alphabet.
* This method uses the non-secure predictable random generator
* with bigger collision probability.
*
* @param alphabet Alphabet used to generate the ID.
* @param defaultSize Size of the ID. The default size is 21.
* @typeparam Type The ID type to replace `string` with some opaque type.
* @returns A random string generator.
*
* ```js
* import { customAlphabet } from 'nanoid/non-secure'
* const nanoid = customAlphabet('0123456789абвгдеё', 5)
* model.id = nanoid() //=> "8ё56а"
* ```
*/
export function customAlphabet<Type extends string>(
alphabet: string,
defaultSize?: number
): (size?: number) => Type

View File

@@ -0,0 +1,21 @@
/* @ts-self-types="./index.d.ts" */
let urlAlphabet =
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'
export let customAlphabet = (alphabet, defaultSize = 21) => {
return (size = defaultSize) => {
let id = ''
let i = size | 0
while (i--) {
id += alphabet[(Math.random() * alphabet.length) | 0]
}
return id
}
}
export let nanoid = (size = 21) => {
let id = ''
let i = size | 0
while (i--) {
id += urlAlphabet[(Math.random() * 64) | 0]
}
return id
}

View File

@@ -0,0 +1,42 @@
{
"name": "nanoid",
"version": "5.1.5",
"description": "A tiny (118 bytes), secure URL-friendly unique string ID generator",
"keywords": [
"uuid",
"random",
"id",
"url"
],
"type": "module",
"engines": {
"node": "^18 || >=20"
},
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/ai"
}
],
"author": "Andrey Sitnik <andrey@sitnik.ru>",
"license": "MIT",
"repository": "ai/nanoid",
"exports": {
".": {
"browser": "./index.browser.js",
"react-native": "./index.browser.js",
"default": "./index.js"
},
"./non-secure": "./non-secure/index.js",
"./package.json": "./package.json"
},
"browser": {
"./index.js": "./index.browser.js"
},
"react-native": {
"./index.js": "./index.browser.js"
},
"bin": "./bin/nanoid.js",
"sideEffects": false,
"types": "./index.d.ts"
}

View File

@@ -0,0 +1,2 @@
export const urlAlphabet =
'useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict'

43
node_modules/@vue/devtools-core/package.json generated vendored Normal file
View File

@@ -0,0 +1,43 @@
{
"name": "@vue/devtools-core",
"type": "module",
"version": "7.7.6",
"author": "webfansplz",
"license": "MIT",
"repository": {
"directory": "packages/core",
"type": "git",
"url": "git+https://github.com/vuejs/devtools.git"
},
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"files": [
"dist",
"server.d.ts"
],
"peerDependencies": {
"vue": "^3.0.0"
},
"dependencies": {
"mitt": "^3.0.1",
"nanoid": "^5.1.0",
"pathe": "^2.0.3",
"vite-hot-client": "^2.0.4",
"@vue/devtools-shared": "^7.7.6",
"@vue/devtools-kit": "^7.7.6"
},
"devDependencies": {
"vue": "^3.5.13"
},
"scripts": {
"build": "tsup --clean",
"prepare:type": "tsup --dts-only",
"stub": "tsup --watch --onSuccess 'tsup --dts-only'"
}
}