repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
purest-admin | github_2023 | dymproject | typescript | PureHttp.httpInterceptorsRequest | private httpInterceptorsRequest(): void {
PureHttp.axiosInstance.interceptors.request.use(
async (config: PureHttpRequestConfig): Promise<any> => {
// 开启进度条动画
// NProgress.start();
// 优先判断post/get等方法是否传入回调,否则执行初始化设置等回调
if (typeof config.beforeRequestCallback === "function") {
... | /** 请求拦截 */ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/http/index.ts#L63-L91 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | PureHttp.httpInterceptorsResponse | private httpInterceptorsResponse(): void {
const instance = PureHttp.axiosInstance;
instance.interceptors.response.use(
(response: PureHttpResponse) => {
const $config = response.config;
// 关闭进度条动画
// NProgress.done();
// 优先判断post/get等方法是否传入回调,否则执行初始化设置等回调
if ($conf... | /** 响应拦截 */ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/http/index.ts#L94-L166 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | PureHttp.request | public request<T>(
method: RequestMethods,
url: string,
param?: AxiosRequestConfig,
axiosConfig?: PureHttpRequestConfig
): Promise<T> {
const config = {
method,
url,
...param,
...axiosConfig
} as PureHttpRequestConfig;
config.baseURL = "/api/v1";
// 单独处理自定义请求/响应... | /** 通用请求工具函数 */ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/http/index.ts#L169-L198 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | PureHttp.post | public post<T, P>(
url: string,
params?: AxiosRequestConfig<T>,
config?: PureHttpRequestConfig
): Promise<P> {
return this.request<P>("post", url, params, config);
} | /** 单独抽离的post工具函数 */ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/http/index.ts#L201-L207 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | PureHttp.get | public get<T, P>(
url: string,
params?: AxiosRequestConfig<T>,
config?: PureHttpRequestConfig
): Promise<P> {
return this.request<P>("get", url, params, config);
} | /** 单独抽离的get工具函数 */ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/http/index.ts#L210-L216 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | StorageProxy.setItem | public async setItem<T>(k: string, v: T, m = 0): Promise<T> {
return new Promise((resolve, reject) => {
this.storage
.setItem(k, {
data: v,
expires: m ? new Date().getTime() + m * 60 * 1000 : 0
})
.then(value => {
resolve(value.data);
})
.c... | /**
* @description 将对应键名的数据保存到离线仓库
* @param k 键名
* @param v 键值
* @param m 缓存时间(单位`分`,默认`0`分钟,永久缓存)
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/localforage/index.ts#L21-L35 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | StorageProxy.getItem | public async getItem<T>(k: string): Promise<T> {
return new Promise((resolve, reject) => {
this.storage
.getItem(k)
.then((value: ExpiresData<T>) => {
value && (value.expires > new Date().getTime() || value.expires === 0)
? resolve(value.data)
: resolve(null);... | /**
* @description 从离线仓库中获取对应键名的值
* @param k 键名
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/localforage/index.ts#L41-L54 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | StorageProxy.removeItem | public async removeItem(k: string) {
return new Promise<void>((resolve, reject) => {
this.storage
.removeItem(k)
.then(() => {
resolve();
})
.catch(err => {
reject(err);
});
});
} | /**
* @description 从离线仓库中删除对应键名的值
* @param k 键名
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/localforage/index.ts#L60-L71 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | StorageProxy.clear | public async clear() {
return new Promise<void>((resolve, reject) => {
this.storage
.clear()
.then(() => {
resolve();
})
.catch(err => {
reject(err);
});
});
} | /**
* @description 从离线仓库中删除所有的键名,重置数据库
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/localforage/index.ts#L76-L87 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | StorageProxy.keys | public async keys() {
return new Promise<string[]>((resolve, reject) => {
this.storage
.keys()
.then(keys => {
resolve(keys);
})
.catch(err => {
reject(err);
});
});
} | /**
* @description 获取数据仓库中所有的key
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/pure-admin/src/utils/localforage/index.ts#L92-L103 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | initApplication | async function initApplication() {
// name用于指定项目唯一标识
// 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
const env = import.meta.env.PROD ? 'prod' : 'dev';
const appVersion = import.meta.env.VITE_APP_VERSION;
const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
// app偏好设置初始化
await initPr... | /**
* 应用初始化完成之后再进行页面加载渲染
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/main.ts#L9-L29 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | doReAuthenticate | async function doReAuthenticate() {
console.warn('Access token or refresh token is invalid or expired. ');
const accessStore = useAccessStore();
const authStore = useAuthStore();
accessStore.setAccessToken(null);
if (
preferences.app.loginExpiredMode === 'modal' &&
accessStore.isAccessCh... | /**
* 重新认证逻辑
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/api/request.ts#L31-L44 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | doRefreshToken | async function doRefreshToken() {
const accessStore = useAccessStore();
const resp = await refreshTokenApi();
const newToken = resp.data;
accessStore.setAccessToken(newToken);
return newToken;
} | /**
* 刷新token逻辑
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/api/request.ts#L49-L55 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadMessages | async function loadMessages(lang: SupportedLanguagesType) {
const [appLocaleMessages] = await Promise.all([
localesMap[lang]?.(),
loadThirdPartyMessage(lang),
]);
return appLocaleMessages?.default;
} | /**
* 加载应用特有的语言包
* 这里也可以改造为从服务端获取翻译数据
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/locales/index.ts#L31-L37 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadThirdPartyMessage | async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
await Promise.all([loadAntdLocale(lang), loadDayjsLocale(lang)]);
} | /**
* 加载第三方组件库的语言包
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/locales/index.ts#L43-L45 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadDayjsLocale | async function loadDayjsLocale(lang: SupportedLanguagesType) {
let locale;
switch (lang) {
case 'en-US': {
locale = await import('dayjs/locale/en');
break;
}
case 'zh-CN': {
locale = await import('dayjs/locale/zh-cn');
break;
}
// 默认使用英语
default: {
locale = awai... | /**
* 加载dayjs的语言包
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/locales/index.ts#L51-L72 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadAntdLocale | async function loadAntdLocale(lang: SupportedLanguagesType) {
switch (lang) {
case 'en-US': {
antdLocale.value = antdEnLocale;
break;
}
case 'zh-CN': {
antdLocale.value = antdDefaultLocale;
break;
}
}
} | /**
* 加载antd的语言包
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/locales/index.ts#L78-L89 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | setupCommonGuard | function setupCommonGuard(router: Router) {
// 记录已经加载的页面
const loadedPaths = new Set<string>();
router.beforeEach(async (to) => {
to.meta.loaded = loadedPaths.has(to.path);
// 页面加载进度条
if (!to.meta.loaded && preferences.transition.progress) {
startProgress();
}
return true;
});
rou... | /**
* 通用守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/router/guard.ts#L17-L41 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | setupAccessGuard | function setupAccessGuard(router: Router) {
router.beforeEach(async (to, from) => {
const accessStore = useAccessStore();
const userStore = useUserStore();
const authStore = useAuthStore();
// 基本路由,这些路由不需要进入权限拦截
if (coreRouteNames.includes(to.name as string)) {
if (to.path === LOGIN_PATH &&... | /**
* 权限访问守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/router/guard.ts#L47-L120 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | createRouterGuard | function createRouterGuard(router: Router) {
/** 通用 */
setupCommonGuard(router);
/** 权限访问 */
setupAccessGuard(router);
} | /**
* 项目守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/router/guard.ts#L126-L131 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | authLogin | async function authLogin(
params: Recordable<any>,
onSuccess?: () => Promise<void> | void,
) {
// 异步处理用户登录操作并获取 accessToken
let userInfo: null | UserInfo = null;
try {
loginLoading.value = true;
const { accessToken } = await loginApi(params);
// 如果成功获取到 accessToken
if (acc... | /**
* 异步处理登录操作
* Asynchronously handle the login process
* @param params 登录表单数据
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-antd/src/store/auth.ts#L27-L75 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | initApplication | async function initApplication() {
// name用于指定项目唯一标识
// 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
const env = import.meta.env.PROD ? 'prod' : 'dev';
const appVersion = import.meta.env.VITE_APP_VERSION;
const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
// app偏好设置初始化
await initPr... | /**
* 应用初始化完成之后再进行页面加载渲染
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/main.ts#L9-L29 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | formatToken | function formatToken(token: null | string) {
return token ? `Bearer ${token}` : null;
} | /**
* 重新认证逻辑
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/api/request.ts#L58-L60 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadMessages | async function loadMessages(lang: SupportedLanguagesType) {
const [appLocaleMessages] = await Promise.all([
localesMap[lang]?.(),
loadThirdPartyMessage(lang),
]);
return appLocaleMessages?.default;
} | /**
* 加载应用特有的语言包
* 这里也可以改造为从服务端获取翻译数据
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/locales/index.ts#L31-L37 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadThirdPartyMessage | async function loadThirdPartyMessage(lang: SupportedLanguagesType) {
await Promise.all([loadElementLocale(lang), loadDayjsLocale(lang)]);
} | /**
* 加载第三方组件库的语言包
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/locales/index.ts#L43-L45 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadDayjsLocale | async function loadDayjsLocale(lang: SupportedLanguagesType) {
let locale;
switch (lang) {
case 'en-US': {
locale = await import('dayjs/locale/en');
break;
}
case 'zh-CN': {
locale = await import('dayjs/locale/zh-cn');
break;
}
// 默认使用英语
default: {
locale = awai... | /**
* 加载dayjs的语言包
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/locales/index.ts#L51-L72 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadElementLocale | async function loadElementLocale(lang: SupportedLanguagesType) {
switch (lang) {
case 'en-US': {
elementLocale.value = enLocale;
break;
}
case 'zh-CN': {
elementLocale.value = defaultLocale;
break;
}
}
} | /**
* 加载element-plus的语言包
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/locales/index.ts#L78-L89 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | setupCommonGuard | function setupCommonGuard(router: Router) {
// 记录已经加载的页面
const loadedPaths = new Set<string>();
router.beforeEach(async (to) => {
to.meta.loaded = loadedPaths.has(to.path);
// 页面加载进度条
if (!to.meta.loaded && preferences.transition.progress) {
startProgress();
}
return true;
});
rou... | /**
* 通用守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/router/guard.ts#L17-L41 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | setupAccessGuard | function setupAccessGuard(router: Router) {
router.beforeEach(async (to, from) => {
const accessStore = useAccessStore();
const userStore = useUserStore();
const authStore = useAuthStore();
// 基本路由,这些路由不需要进入权限拦截
if (coreRouteNames.includes(to.name as string)) {
if (to.path === LOGIN_PATH &&... | /**
* 权限访问守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/router/guard.ts#L47-L120 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | createRouterGuard | function createRouterGuard(router: Router) {
/** 通用 */
setupCommonGuard(router);
/** 权限访问 */
setupAccessGuard(router);
} | /**
* 项目守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/router/guard.ts#L126-L131 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | authLogin | async function authLogin(
params: Recordable<any>,
onSuccess?: () => Promise<void> | void,
) {
// 异步处理用户登录操作并获取 accessToken
let userInfo: null | UserInfo = null;
try {
loginLoading.value = true;
const loginResult = await loginApi(params);
if (loginResult) {
userInfo = awa... | /**
* 异步处理登录操作
* Asynchronously handle the login process
* @param params 登录表单数据
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-ele/src/store/auth.ts#L27-L65 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | initApplication | async function initApplication() {
// name用于指定项目唯一标识
// 用于区分不同项目的偏好设置以及存储数据的key前缀以及其他一些需要隔离的数据
const env = import.meta.env.PROD ? 'prod' : 'dev';
const appVersion = import.meta.env.VITE_APP_VERSION;
const namespace = `${import.meta.env.VITE_APP_NAMESPACE}-${appVersion}-${env}`;
// app偏好设置初始化
await initPr... | /**
* 应用初始化完成之后再进行页面加载渲染
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/main.ts#L9-L29 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | doReAuthenticate | async function doReAuthenticate() {
console.warn('Access token or refresh token is invalid or expired. ');
const accessStore = useAccessStore();
const authStore = useAuthStore();
accessStore.setAccessToken(null);
if (
preferences.app.loginExpiredMode === 'modal' &&
accessStore.isAccessCh... | /**
* 重新认证逻辑
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/api/request.ts#L30-L43 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | doRefreshToken | async function doRefreshToken() {
const accessStore = useAccessStore();
const resp = await refreshTokenApi();
const newToken = resp.data;
accessStore.setAccessToken(newToken);
return newToken;
} | /**
* 刷新token逻辑
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/api/request.ts#L48-L54 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadMessages | async function loadMessages(lang: SupportedLanguagesType) {
const appLocaleMessages = await localesMap[lang]?.();
return appLocaleMessages?.default;
} | /**
* 加载应用特有的语言包
* 这里也可以改造为从服务端获取翻译数据
* @param lang
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/locales/index.ts#L24-L27 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | setupCommonGuard | function setupCommonGuard(router: Router) {
// 记录已经加载的页面
const loadedPaths = new Set<string>();
router.beforeEach(async (to) => {
to.meta.loaded = loadedPaths.has(to.path);
// 页面加载进度条
if (!to.meta.loaded && preferences.transition.progress) {
startProgress();
}
return true;
});
rou... | /**
* 通用守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/router/guard.ts#L17-L41 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | setupAccessGuard | function setupAccessGuard(router: Router) {
router.beforeEach(async (to, from) => {
const accessStore = useAccessStore();
const userStore = useUserStore();
const authStore = useAuthStore();
// 基本路由,这些路由不需要进入权限拦截
if (coreRouteNames.includes(to.name as string)) {
if (to.path === LOGIN_PATH &&... | /**
* 权限访问守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/router/guard.ts#L47-L119 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | createRouterGuard | function createRouterGuard(router: Router) {
/** 通用 */
setupCommonGuard(router);
/** 权限访问 */
setupAccessGuard(router);
} | /**
* 项目守卫配置
* @param router
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/router/guard.ts#L125-L130 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | authLogin | async function authLogin(
params: Recordable<any>,
onSuccess?: () => Promise<void> | void,
) {
// 异步处理用户登录操作并获取 accessToken
let userInfo: null | UserInfo = null;
try {
loginLoading.value = true;
const { accessToken } = await loginApi(params);
// 如果成功获取到 accessToken
if (acc... | /**
* 异步处理登录操作
* Asynchronously handle the login process
* @param params 登录表单数据
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/apps/web-naive/src/store/auth.ts#L27-L76 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getStagedFiles | async function getStagedFiles(): Promise<string[]> {
try {
const { stdout } = await execa('git', [
'-c',
'submodule.recurse=false',
'diff',
'--staged',
'--diff-filter=ACMR',
'--name-only',
'--ignore-submodules',
'-z',
]);
let changedList = stdout ? stdout.r... | /**
* 获取暂存区文件
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/node-utils/src/git.ts#L10-L32 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | generatorContentHash | function generatorContentHash(content: string, hashLSize?: number) {
const hash = createHash('md5').update(content, 'utf8').digest('hex');
if (hashLSize) {
return hash.slice(0, hashLSize);
}
return hash;
} | /**
* 生产基于内容的 hash,可自定义长度
* @param content
* @param hashLSize
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/node-utils/src/hash.ts#L8-L16 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | findMonorepoRoot | function findMonorepoRoot(cwd: string = process.cwd()) {
const lockFile = findUpSync('pnpm-lock.yaml', {
cwd,
type: 'file',
});
return dirname(lockFile || '');
} | /**
* 查找大仓的根目录
* @param cwd
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/node-utils/src/monorepo.ts#L13-L19 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getPackagesSync | function getPackagesSync() {
const root = findMonorepoRoot();
return getPackagesSyncFunc(root);
} | /**
* 获取大仓的所有包
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/node-utils/src/monorepo.ts#L24-L27 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getPackages | async function getPackages() {
const root = findMonorepoRoot();
return await getPackagesFunc(root);
} | /**
* 获取大仓的所有包
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/node-utils/src/monorepo.ts#L32-L36 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getPackage | async function getPackage(pkgName: string) {
const { packages } = await getPackages();
return packages.find((pkg) => pkg.packageJson.name === pkgName);
} | /**
* 获取大仓指定的包
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/node-utils/src/monorepo.ts#L41-L44 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | toPosixPath | function toPosixPath(pathname: string) {
return pathname.split(`\\`).join(posix.sep);
} | /**
* 将给定的文件路径转换为 POSIX 风格。
* @param {string} pathname - 原始文件路径。
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/node-utils/src/path.ts#L7-L9 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | viteExtraAppConfigPlugin | async function viteExtraAppConfigPlugin({
isBuild,
root,
}: PluginOptions): Promise<PluginOption | undefined> {
let publicPath: string;
let source: string;
if (!isBuild) {
return;
}
const { version = '' } = await readPackageJSON(root);
return {
async configResolved(config) {
publicPath ... | /**
* 用于将配置文件抽离出来并注入到项目中
* @returns
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/extra-app-config.ts#L24-L71 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getShimsUrl | async function getShimsUrl(provide: string) {
// const version = await getLatestVersionOfShims();
const version = '1.10.0';
const shimsSubpath = `dist/es-module-shims.js`;
const providerShimsMap: Record<string, string> = {
'esm.sh': `https://esm.sh/es-module-shims@${version}/${shimsSubpath}`,
// unpkg:... | // async function getLatestVersionOfShims() { | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/importmap.ts#L25-L40 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadConditionPlugins | async function loadConditionPlugins(conditionPlugins: ConditionPlugin[]) {
const plugins: PluginOption[] = [];
for (const conditionPlugin of conditionPlugins) {
if (conditionPlugin.condition) {
const realPlugins = await conditionPlugin.plugins();
plugins.push(...realPlugins);
}
}
return plug... | /**
* 获取条件成立的 vite 插件
* @param conditionPlugins
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/index.ts#L34-L43 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadCommonPlugins | async function loadCommonPlugins(
options: CommonPluginOptions,
): Promise<ConditionPlugin[]> {
const { devtools, injectMetadata, isBuild, visualizer } = options;
return [
{
condition: true,
plugins: () => [
viteVue({
script: {
defineModel: true,
// propsD... | /**
* 根据条件获取通用的vite插件
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/index.ts#L48-L83 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadApplicationPlugins | async function loadApplicationPlugins(
options: ApplicationPluginOptions,
): Promise<PluginOption[]> {
// 单独取,否则commonOptions拿不到
const isBuild = options.isBuild;
const env = options.env;
const {
archiver,
archiverPluginOptions,
compress,
compressTypes,
extraAppConfig,
html,
i18n,
... | /**
* 根据条件获取应用类型的vite插件
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/index.ts#L88-L217 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadLibraryPlugins | async function loadLibraryPlugins(
options: LibraryPluginOptions,
): Promise<PluginOption[]> {
// 单独取,否则commonOptions拿不到
const isBuild = options.isBuild;
const { dts, ...commonOptions } = options;
const commonPlugins = await loadCommonPlugins(commonOptions);
return await loadConditionPlugins([
...common... | /**
* 根据条件获取库类型的vite插件
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/index.ts#L222-L236 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | viteMetadataPlugin | async function viteMetadataPlugin(
root = process.cwd(),
): Promise<PluginOption | undefined> {
const { author, description, homepage, license, version } =
await readPackageJSON(root);
const buildTime = dateUtil().format('YYYY-MM-DD HH:mm:ss');
return {
async config() {
const { dependencies, dev... | /**
* 用于注入项目信息
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/inject-metadata.ts#L70-L109 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | viteLicensePlugin | async function viteLicensePlugin(
root = process.cwd(),
): Promise<PluginOption | undefined> {
const {
description = '',
homepage = '',
version = '',
} = await readPackageJSON(root);
return {
apply: 'build',
enforce: 'post',
generateBundle: {
handler: (_options: NormalizedOutputOp... | /**
* 用于注入版权信息
* @returns
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/license.ts#L17-L61 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | viteInjectAppLoadingPlugin | async function viteInjectAppLoadingPlugin(
isBuild: boolean,
env: Record<string, any> = {},
loadingTemplate = 'loading.html',
): Promise<PluginOption | undefined> {
const loadingHtml = await getLoadingRawByHtmlTemplate(loadingTemplate);
const { version } = await readPackageJSON(process.cwd());
const envRaw ... | /**
* 用于生成将loading样式注入到项目中
* 为多app提供loading样式,无需在每个 app -> index.html单独引入
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/inject-app-loading/index.ts#L14-L49 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getLoadingRawByHtmlTemplate | async function getLoadingRawByHtmlTemplate(loadingTemplate: string) {
// 支持在app内自定义loading模板,模版参考default-loading.html即可
let appLoadingPath = join(process.cwd(), loadingTemplate);
if (!fs.existsSync(appLoadingPath)) {
const __dirname = fileURLToPath(new URL('.', import.meta.url));
appLoadingPath = join(__... | /**
* 用于获取loading的html模板
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/plugins/inject-app-loading/index.ts#L54-L64 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getConfFiles | function getConfFiles() {
const script = process.env.npm_lifecycle_script as string;
const reg = /--mode ([\d_a-z]+)/;
const result = reg.exec(script);
let mode = 'production';
if (result) {
mode = result[1] as string;
}
return ['.env', '.env.local', `.env.${mode}`, `.env.${mode}.local`];
} | /**
* 获取当前环境下生效的配置文件名
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/utils/env.ts#L21-L30 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | loadEnv | async function loadEnv<T = Record<string, string>>(
match = 'VITE_GLOB_',
confFiles = getConfFiles(),
) {
let envConfig = {};
for (const confFile of confFiles) {
try {
const confFilePath = join(process.cwd(), confFile);
if (existsSync(confFilePath)) {
const envPath = await fs.readFile(c... | /**
* Get the environment variables starting with the specified prefix
* @param match prefix
* @param confFiles ext
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/internal/vite-config/src/utils/env.ts#L37-L64 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
purest-admin | github_2023 | dymproject | typescript | getLintFiles | async function getLintFiles(files: string[] = []) {
const lintFiles: string[] = [];
if (files?.length > 0) {
return files.filter((file) => basename(file) === 'package.json');
}
const { packages } = await getPackages();
for (const { dir } of packages) {
lintFiles.push(join(dir, 'package.json'));
}... | /**
* Get files that require lint
* @param files
*/ | https://github.com/dymproject/purest-admin/blob/5d07de62daefeb4797975e839bad066e1d88cf4c/client-vue/vben-admin/scripts/vsh/src/publint/index.ts#L39-L52 | 5d07de62daefeb4797975e839bad066e1d88cf4c |
kin | github_2023 | kin-lang | typescript | Lexer.advance | private advance(): void {
this.currentPos++;
} | /* Function to advance the current position */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L25-L27 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.peek | private peek(): string {
return this.sourceCodes[this.currentPos];
} | /* Function to get current character without advancing */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L30-L32 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.consume | private consume(): string {
const char: string = this.peek();
this.advance();
return char;
} | /*Function to get current character and advance*/ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L35-L39 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.makeTokenWithLexeme | private makeTokenWithLexeme(type: TokenType, lexeme: string): Token {
return {
line: this.currentLine,
type,
lexeme,
};
} | /* Function to create a new token with a lexeme */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L42-L48 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.isSingleAlphaCharacter | private isSingleAlphaCharacter(s: string): boolean {
return /^[a-zA-Z]$/.test(s);
} | /* check if a given string represents a single alphabetical character*/ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L51-L53 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.isDigit | private isDigit(s: string): boolean {
return /^[0-9]$/.test(s);
} | /* check if a given string represents a single digit*/ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L56-L58 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.alphaNumeric | private alphaNumeric(s: string): boolean {
return this.isDigit(s) || this.isSingleAlphaCharacter(s);
} | /* check if a given string represent a digit or an alphabetical character */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L61-L63 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.skipWhitespaceAndComments | private skipWhitespaceAndComments(): void {
while (true) {
const c: string = this.peek();
if (c === ' ' || c === '\t' || c === '\r') {
this.advance();
} else if (c === '\n') {
/* Newline character */
this.advance();
this.currentLine++;
} else if (c === '#') {
... | /* Ignore comments and whitespaces */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L66-L87 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.scanNumber | private scanNumber(negative = false): Token {
const start: number = this.currentPos;
while (this.isDigit(this.peek())) {
this.advance();
}
if (
this.peek() == '.' &&
this.isDigit(this.sourceCodes[this.currentPos + 1])
) {
this.advance();
while (this.isDigit(this.peek())... | /* Function to scan a number */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L90-L111 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.scanStringLiteral | private scanStringLiteral(): Token {
const start: number = this.currentPos;
const quote: string = this.consume();
while (this.peek() !== quote) {
if (this.peek() === '\n' || this.currentPos === this.sourceCodes.length) {
throw new Error(
`Unterminated string literal at line ${this.cu... | /* Function to scan a string litelar */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L114-L131 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.scanIdentifierOrKeywork | private scanIdentifierOrKeywork(): Token {
const start: number = this.currentPos;
while (this.alphaNumeric(this.peek()) || this.peek() === '_') {
this.advance();
}
const lexeme: string = this.sourceCodes.slice(start, this.currentPos);
/* Check if lexeme is a keywork */
if (lexeme === 'ni... | /* Function to scan an identifier or a keyword */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L134-L162 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.scanToken | private scanToken(): Token {
this.skipWhitespaceAndComments(); // skip whitespace and comments
/* Check End Of Source Codes */
if (this.currentPos == this.sourceCodes.length) {
return this.makeTokenWithLexeme(TokenType.EOF, 'EOF');
}
const char = this.peek();
switch (char) {
/* On... | /* Function to scan the next token */ | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L165-L294 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Lexer.tokenize | public tokenize(): Token[] {
const tokens: Token[] = new Array<Token>();
/* Loop through source codes, scanning tokens */
for (;;) {
const token: Token = this.scanToken();
tokens.push(token);
if (token.type === TokenType.EOF) break;
}
return tokens;
} | // generate tokens from the source. | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/lexer/lexer.ts#L297-L306 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Parser.parse_expr | private parse_expr(): Expr {
return this.parse_assignment_expr();
} | // ! This is to avoid assigning values to undefined indexes in arrays, since arrays are objects | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/parser/parser.ts#L166-L168 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | Parser.parse_call_member_expr | private parse_call_member_expr(): Expr {
const member = this.parse_member_expr();
if (this.at().type == TokenType.OPEN_PARANTHESES) {
return this.parse_call_expr(member);
}
return member;
} | // foo.x() | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/parser/parser.ts#L284-L292 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
kin | github_2023 | kin-lang | typescript | EvalExpr.eval_identifier | public static eval_identifier(
ident: Identifier,
env: Environment,
): RuntimeVal {
const val = env.lookupVar(ident.symbol);
return val;
} | // value to return from function | https://github.com/kin-lang/kin/blob/7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4/src/runtime/eval/expressions.ts#L38-L44 | 7ab98d401845ddf2b24a7d1b8e7cbc772cd655b4 |
permissionless.js | github_2023 | pimlicolabs | typescript | SINGLETON_PAYMASTER_V07_CALL | const SINGLETON_PAYMASTER_V07_CALL = (owner: Address): Hex =>
concat([
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x610160604052600060a052600160c052605060e052600c6101005260346101205260146101405234801561003257600080fd5b506040516126343803806126348339810160408190526100519161... | // Creates the call that deploys the SingletonPaymaster v0.7 | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless-test/mock-aa-infra/mock-paymaster/singletonPaymasters.ts#L101-L108 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | SINGLETON_PAYMASTER_V06_CALL | const SINGLETON_PAYMASTER_V06_CALL = (owner: Address): Hex =>
concat([
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x610140604052600060a052600160c052605060e052600c6101005260146101205234801561002c57600080fd5b5060405161270838038061270883398101604081905261004b916101a4565b8282... | // Creates the call that deploys the SingletonPaymaster v0.6 | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless-test/mock-aa-infra/mock-paymaster/singletonPaymasters.ts#L111-L118 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | RpcError.constructor | constructor(
msg: string,
readonly code?: number,
readonly data: unknown = undefined
) {
super(msg)
} | // error codes from: https://eips.ethereum.org/EIPS/eip-1474 | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless-test/mock-aa-infra/mock-paymaster/helpers/schema.ts#L22-L28 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getAccountInitCode | const getAccountInitCode = async ({
owner,
index,
ecdsaModuleAddress
}: {
owner: Address
index: bigint
ecdsaModuleAddress: Address
}): Promise<Hex> => {
if (!owner) throw new Error("Owner account not found")
// Build the module setup data
const ecdsaOwnershipInitData = encodeFunctio... | /**
* Get the account initialization code for Biconomy smart account with ECDSA as default authorization module
* @param owner
* @param index
* @param factoryAddress
* @param ecdsaValidatorAddress
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/biconomy/toBiconomySmartAccount.ts#L68-L92 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getDefaultAddresses | const getDefaultAddresses = ({
validatorAddress: _validatorAddress,
metaFactoryAddress: _metaFactoryAddress,
bootstrapAddress: _bootstrapAddress
}: Partial<NetworkAddresses>): NetworkAddresses => {
const addresses = DEFAULT_CONTRACT_ADDRESS
const validatorAddress = _validatorAddress ?? addresses.val... | /**
* Get default addresses for Etherspot Smart Account based on chainId
* @param chainId
* @param validatorAddress
* @param accountLogicAddress
* @param factoryAddress
* @param metaFactoryAddress
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/etherspot/toEtherspotSmartAccount.ts#L81-L98 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getInitialisationData | const getInitialisationData = ({
owner,
validatorAddress,
bootstrapAddress
}: {
owner: Address
validatorAddress: Address
bootstrapAddress: Address
}) => {
const initMSAData = getInitMSAData(validatorAddress)
const initCode = encodeAbiParameters(
[{ type: "address" }, { type: "ad... | /**
* Get the initialization data for a etherspot smart account
* @param entryPoint
* @param owner
* @param validatorAddress
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/etherspot/toEtherspotSmartAccount.ts#L106-L123 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getAccountInitCode | const getAccountInitCode = async ({
owner,
index,
validatorAddress,
bootstrapAddress
}: {
owner: Address
index: bigint
validatorAddress: Address
bootstrapAddress: Address
}): Promise<Hex> => {
if (!owner) throw new Error("Owner account not found")
// Build the account initializa... | /**
* Get the account initialization code for a etherspot smart account
* @param entryPoint
* @param owner
* @param index
* @param validatorAddress
* @param bootstrapAddress
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/etherspot/toEtherspotSmartAccount.ts#L133-L158 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | generateInitCode | const generateInitCode = () =>
getAccountInitCode({
owner: localOwner.address,
index,
validatorAddress,
bootstrapAddress
}) | // Helper to generate the init code for the smart account | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/etherspot/toEtherspotSmartAccount.ts#L231-L237 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getDefaultKernelVersion | const getDefaultKernelVersion = <TEntryPointVersion extends "0.6" | "0.7">(
entryPointVersion: TEntryPointVersion,
version?: KernelVersion<TEntryPointVersion>
): KernelVersion<TEntryPointVersion> => {
if (version) {
return version
}
return (
entryPointVersion === "0.6" ? "0.2.2" : "0... | /**
* Get supported Kernel Smart Account version based on entryPoint
* @param entryPoint
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts#L151-L161 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getDefaultAddresses | const getDefaultAddresses = ({
validatorAddress: _validatorAddress,
accountLogicAddress: _accountLogicAddress,
factoryAddress: _factoryAddress,
metaFactoryAddress: _metaFactoryAddress,
kernelVersion,
isWebAuthn
}: Partial<KERNEL_ADDRESSES> & {
kernelVersion: KernelVersion<"0.6" | "0.7">
... | /**
* Get default addresses for Kernel Smart Account based on entryPoint or user input
* @param entryPointAddress
* @param ecdsaValidatorAddress
* @param accountLogicAddress
* @param factoryAddress
* @param metaFactoryAddress
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts#L178-L204 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getInitializationData | const getInitializationData = <entryPointVersion extends "0.6" | "0.7">({
entryPoint: { version: entryPointVersion },
kernelVersion,
validatorData,
validatorAddress
}: {
kernelVersion: KernelVersion<entryPointVersion>
entryPoint: {
version: entryPointVersion
}
validatorData: Hex
... | /**
* Get the initialization data for a kernel smart account
* @param entryPoint
* @param owner
* @param ecdsaValidatorAddress
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts#L218-L263 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | getAccountInitCode | const getAccountInitCode = async <entryPointVersion extends "0.6" | "0.7">({
entryPointVersion,
kernelVersion,
validatorData,
index,
factoryAddress,
accountLogicAddress,
validatorAddress,
useMetaFactory
}: {
kernelVersion: KernelVersion<entryPointVersion>
entryPointVersion: entry... | /**
* Get the account initialization code for a kernel smart account
* @param entryPoint
* @param owner
* @param index
* @param factoryAddress
* @param accountLogicAddress
* @param ecdsaValidatorAddress
*/ | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts#L313-L363 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
permissionless.js | github_2023 | pimlicolabs | typescript | generateInitCode | const generateInitCode = async () =>
getAccountInitCode({
entryPointVersion: entryPoint.version,
kernelVersion,
validatorData: await getValidatorData(owner),
index,
factoryAddress,
accountLogicAddress,
validatorAddress,
... | // Helper to generate the init code for the smart account | https://github.com/pimlicolabs/permissionless.js/blob/f2d32a1de78093875ae96c4f77ad98f9f2388f43/packages/permissionless/accounts/kernel/toKernelSmartAccount.ts#L493-L503 | f2d32a1de78093875ae96c4f77ad98f9f2388f43 |
tanyaaja.in | github_2023 | mazipan | typescript | styleToString | const styleToString = (style: { [key: string]: string | number }): string => {
return Object.entries(style)
.map(
([key, value]) =>
`${key}: ${typeof value === 'string' ? `"${value}"` : value}`,
)
.join(',')
} | // Convert style object to JSX style string | https://github.com/mazipan/tanyaaja.in/blob/b52403a3f310a8be21b4eac4d57e058034e47a0d/src/lib/jsx-parser.ts#L119-L126 | b52403a3f310a8be21b4eac4d57e058034e47a0d |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.constructor | constructor(opts: {
l1SignerOrProvider: SignerOrProviderLike
l2SignerOrProvider: SignerOrProviderLike
l1ChainId: NumberLike
l2ChainId: NumberLike
depositConfirmationBlocks?: NumberLike
l1BlockTimeSeconds?: NumberLike
contracts?: DeepPartial<OEContractsLike>
bridges?: BridgeAdapterData
... | /**
* Creates a new CrossChainProvider instance.
* @param opts Options for the provider.
* @param opts.l1SignerOrProvider Signer or Provider for the L1 chain, or a JSON-RPC url.
* @param opts.l2SignerOrProvider Signer or Provider for the L2 chain, or a JSON-RPC url.
* @param opts.l1ChainId Chain ID for t... | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L145-L193 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.l1Provider | get l1Provider(): Provider {
if (Provider.isProvider(this.l1SignerOrProvider)) {
return this.l1SignerOrProvider
} else {
return this.l1SignerOrProvider.provider
}
} | /**
* Provider connected to the L1 chain.
*/ | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L198-L204 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.l2Provider | get l2Provider(): Provider {
if (Provider.isProvider(this.l2SignerOrProvider)) {
return this.l2SignerOrProvider
} else {
return this.l2SignerOrProvider.provider
}
} | /**
* Provider connected to the L2 chain.
*/ | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L209-L215 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.l1Signer | get l1Signer(): Signer {
if (Provider.isProvider(this.l1SignerOrProvider)) {
throw new Error(`messenger has no L1 signer`)
} else {
return this.l1SignerOrProvider
}
} | /**
* Signer connected to the L1 chain.
*/ | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L220-L226 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.l2Signer | get l2Signer(): Signer {
if (Provider.isProvider(this.l2SignerOrProvider)) {
throw new Error(`messenger has no L2 signer`)
} else {
return this.l2SignerOrProvider
}
} | /**
* Signer connected to the L2 chain.
*/ | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L231-L237 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.fpac | public async fpac(): Promise<boolean> {
if (
this.contracts.l1.OptimismPortal.address === ethers.constants.AddressZero
) {
// Only really relevant for certain SDK tests where the portal is not deployed. We should
// probably just update the tests so the portal gets deployed but feels like it's... | /**
* Uses portal version to determine if the messenger is using fpac contracts. Better not to cache
* this value as it will change during the fpac upgrade and we want clients to automatically
* begin using the new logic without throwing any errors.
* @returns Whether or not the messenger is using fpac cont... | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L245-L259 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.getMessagesByTransaction | public async getMessagesByTransaction(
transaction: TransactionLike,
opts: {
direction?: MessageDirection
} = {}
): Promise<CrossChainMessage[]> {
// Wait for the transaction receipt if the input is waitable.
await (transaction as TransactionResponse).wait?.()
// Convert the input to a ... | /**
* Retrieves all cross chain messages sent within a given transaction.
* @param transaction Transaction hash or receipt to find messages from.
* @param opts Options object.
* @param opts.direction Direction to search for messages in. If not provided, will attempt to
* automatically search both directi... | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L270-L352 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.toBedrockCrossChainMessage | public async toBedrockCrossChainMessage(
message: MessageLike,
messageIndex = 0
): Promise<CrossChainMessage> {
const resolved = await this.toCrossChainMessage(message, messageIndex)
// Bedrock messages are already in the correct format.
const { version } = decodeVersionedNonce(resolved.messageNo... | /**
* Transforms a legacy message into its corresponding Bedrock representation.
* @param message Legacy message to transform.
* @param messageIndex The index of the message, if multiple exist from multicall
* @returns Bedrock representation of the message.
*/ | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L360-L398 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.toLowLevelMessage | public async toLowLevelMessage(
message: MessageLike,
messageIndex = 0
): Promise<LowLevelMessage> {
const resolved = await this.toCrossChainMessage(message, messageIndex)
if (resolved.direction === MessageDirection.L1_TO_L2) {
throw new Error(`can only convert L2 to L1 messages to low level`)
... | /**
* Transforms a CrossChainMessenger message into its low-level representation inside the
* L2ToL1MessagePasser contract on L2.
* @param message Message to transform.
* @param messageIndex The index of the message, if multiple exist from multicall
* @return Transformed message.
*/ | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L407-L487 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.getBridgeForTokenPair | public async getBridgeForTokenPair(
l1Token: AddressLike,
l2Token: AddressLike
): Promise<IBridgeAdapter> {
const bridges: IBridgeAdapter[] = []
for (const bridge of Object.values(this.bridges)) {
try {
if (await bridge.supportsTokenPair(l1Token, l2Token)) {
bridges.push(bridge... | /**
* Finds the appropriate bridge adapter for a given L1<>L2 token pair. Will throw if no bridges
* support the token pair or if more than one bridge supports the token pair.
* @param l1Token L1 token address.
* @param l2Token L2 token address.
* @returns The appropriate bridge adapter for the given tok... | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L513-L542 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
ecosystem | github_2023 | ethereum-optimism | typescript | CrossChainMessenger.getDepositsByAddress | public async getDepositsByAddress(
address: AddressLike,
opts: {
fromBlock?: BlockTag
toBlock?: BlockTag
} = {}
): Promise<TokenBridgeMessage[]> {
return (
await Promise.all(
Object.values(this.bridges).map(async (bridge) => {
return bridge.getDepositsByAddress(addr... | /**
* Gets all deposits for a given address.
* @param address Address to search for messages from.
* @param opts Options object.
* @param opts.fromBlock Block to start searching for messages from. If not provided, will start
* from the first block (block #0).
* @param opts.toBlock Block to stop search... | https://github.com/ethereum-optimism/ecosystem/blob/c3d635fcb59f21f38710c4235fc741f57d16dad5/packages/sdk/src/cross-chain-messenger.ts#L554-L575 | c3d635fcb59f21f38710c4235fc741f57d16dad5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.