commit a617a68e2f436b996b255af61cd212d191482d7e Author: xion Date: Wed Mar 26 11:49:56 2025 +0800 init diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..b247dc2 --- /dev/null +++ b/.env.example @@ -0,0 +1,2 @@ +password=888888 +envision_registry=https://kevisual.silkyai.cn/api/router \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..74681a2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +dist +node_modules + +.DS_Store +.env* +!.env.example +.turbo diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..7446745 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +//npm.xiongxiao.me/:_authToken=${ME_NPM_TOKEN} +//registry.npmjs.org/:_authToken=${NPM_TOKEN} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..f530cbb --- /dev/null +++ b/index.html @@ -0,0 +1,11 @@ + + + + Query Login + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..ad485c9 --- /dev/null +++ b/package.json @@ -0,0 +1,35 @@ +{ + "name": "@kevisual/query-mark", + "version": "0.0.2", + "description": "", + "main": "dist/query-mark.js", + "types": "dist/query-mark.d.ts", + "scripts": { + "build": "tsup", + "watch": "tsup --watch", + "dev": "tsup --watch", + "dev:lib": "pnpm run dev" + }, + "keywords": [], + "author": "abearxiong ", + "license": "MIT", + "type": "module", + "publishConfig": { + "access": "public" + }, + "peerDependencies": { + "@kevisual/query": "^0.0.15" + }, + "devDependencies": { + "@types/node": "^22.13.11", + "tsup": "^8.4.0" + }, + "exports": { + ".": "./dist/query-mark.js", + "./base": "./dist/query-mark.js" + }, + "dependencies": { + "@kevisual/cache": "^0.0.1", + "dotenv": "^16.4.7" + } +} \ No newline at end of file diff --git a/src/query-mark.ts b/src/query-mark.ts new file mode 100644 index 0000000..8e3b7e2 --- /dev/null +++ b/src/query-mark.ts @@ -0,0 +1,54 @@ +import { Query } from '@kevisual/query'; +import type { Result, DataOpts } from '@kevisual/query/query'; +import { setBaseResponse } from '@kevisual/query/query'; + +export type QueryMarkOpts = { + query?: Query; + isBrowser?: boolean; + onLoad?: () => void; + storage?: Storage; + cache: Cache; +}; +export type QueryMarkData = { + id?: string; + title?: string; + description?: string; + [key: string]: any; +}; +export type QueryMarkResult = { + accessToken: string; + refreshToken: string; +}; + +export class QueryMark { + query: Query; + isBrowser: boolean; + load?: boolean; + storage: Storage; + onLoad?: () => void; + + constructor(opts?: QueryMarkOpts) { + this.query = opts?.query || new Query(); + this.isBrowser = opts?.isBrowser ?? true; + this.init(); + this.onLoad = opts?.onLoad; + this.storage = opts?.storage || localStorage; + } + setQuery(query: Query) { + this.query = query; + } + private async init() { + this.load = true; + this.onLoad?.(); + } + async post(data: any, opts?: DataOpts) { + try { + return this.query.post({ path: 'mark', ...data }, opts); + } catch (error) { + console.log('error', error); + return { + code: 400, + } as any; + } + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..8f70d0f --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "module": "nodenext", + "target": "esnext", + "noImplicitAny": false, + "outDir": "./dist", + "sourceMap": false, + "allowJs": true, + "newLine": "LF", + "baseUrl": "./", + "typeRoots": [ + "node_modules/@types", + ], + "declaration": true, + "noEmit": false, + "allowImportingTsExtensions": true, + "emitDeclarationOnly": true, + "moduleResolution": "NodeNext", + "experimentalDecorators": true, + "emitDecoratorMetadata": true, + "esModuleInterop": true, + "paths": { + "@/*": [ + "src/*" + ] + } + }, +} \ No newline at end of file diff --git a/tsup.config.ts b/tsup.config.ts new file mode 100644 index 0000000..c7b94e6 --- /dev/null +++ b/tsup.config.ts @@ -0,0 +1,16 @@ +import { defineConfig } from 'tsup'; + +export default defineConfig({ + entry: ['src/query-mark.ts'], + + splitting: false, + sourcemap: false, + clean: true, + format: 'esm', + dts: true, + outDir: 'dist', + tsconfig: 'tsconfig.json', + define: { + IS_BROWSER: 'false', + }, +});