init
This commit is contained in:
		
							
								
								
									
										2
									
								
								.env.example
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.env.example
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| password=888888 | ||||
| envision_registry=https://kevisual.silkyai.cn/api/router | ||||
							
								
								
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,7 @@ | ||||
| dist | ||||
| node_modules | ||||
|  | ||||
| .DS_Store | ||||
| .env* | ||||
| !.env.example | ||||
| .turbo | ||||
							
								
								
									
										2
									
								
								.npmrc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.npmrc
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| //npm.xiongxiao.me/:_authToken=${ME_NPM_TOKEN} | ||||
| //registry.npmjs.org/:_authToken=${NPM_TOKEN} | ||||
							
								
								
									
										11
									
								
								index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								index.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| <html> | ||||
|  | ||||
| <head> | ||||
|   <title>Query Login</title> | ||||
| </head> | ||||
|  | ||||
| <body> | ||||
|   <script src="src/test/login.ts" type="module"></script> | ||||
| </body> | ||||
|  | ||||
| </html> | ||||
							
								
								
									
										35
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -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 <xiongxiao@xiongxiao.me>", | ||||
|   "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" | ||||
|   } | ||||
| } | ||||
							
								
								
									
										54
									
								
								src/query-mark.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/query-mark.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -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<T = any>(data: any, opts?: DataOpts) { | ||||
|     try { | ||||
|       return this.query.post<T>({ path: 'mark', ...data }, opts); | ||||
|     } catch (error) { | ||||
|       console.log('error', error); | ||||
|       return { | ||||
|         code: 400, | ||||
|       } as any; | ||||
|     } | ||||
|   } | ||||
| } | ||||
							
								
								
									
										28
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								tsconfig.json
									
									
									
									
									
										Normal file
									
								
							| @@ -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/*" | ||||
|       ] | ||||
|     } | ||||
|   }, | ||||
| } | ||||
							
								
								
									
										16
									
								
								tsup.config.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								tsup.config.ts
									
									
									
									
									
										Normal file
									
								
							| @@ -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', | ||||
|   }, | ||||
| }); | ||||
		Reference in New Issue
	
	Block a user