From dd3f9ddb9bbe546229b945616b344796fa601383 Mon Sep 17 00:00:00 2001 From: Alec Date: Mon, 1 Jul 2024 07:27:41 +0000 Subject: [PATCH 1/4] save --- .gitignore | 2 ++ apps/backend/src/orbitdb/keystore.ts | 1 + packages/lib/package.json | 2 +- packages/lib/{ => src}/ajv/index.ts | 0 packages/lib/{ => src}/ajv/schema.ts | 0 packages/lib/{ => src}/automerge/index.ts | 0 packages/lib/{ => src}/bullmq/events.ts | 0 packages/lib/{ => src}/bullmq/index.ts | 0 packages/lib/{ => src}/jose/keys.ts | 0 packages/lib/{ => src}/jose/sign.ts | 0 packages/lib/{ => src}/jose/types.ts | 0 packages/lib/{ => src}/logger/index.ts | 0 packages/lib/{ => src}/mongodb/index.ts | 0 packages/lib/{ => src}/quicktype/index.ts | 0 packages/lib/{ => src}/radix/index.ts | 0 packages/lib/{ => src}/radix/store.ts | 0 packages/lib/{ => src}/redis/index.ts | 0 packages/lib/{ => src}/superjson/index.ts | 0 packages/lib/{ => src}/transformer/index.ts | 0 packages/lib/{ => src}/ws/index.ts | 0 packages/lib/{ => src}/ws/ws.ts | 0 packages/lib/{ => src}/ws/wss.ts | 0 packages/lib/tsconfig.json | 6 ++++++ 23 files changed, 10 insertions(+), 1 deletion(-) rename packages/lib/{ => src}/ajv/index.ts (100%) rename packages/lib/{ => src}/ajv/schema.ts (100%) rename packages/lib/{ => src}/automerge/index.ts (100%) rename packages/lib/{ => src}/bullmq/events.ts (100%) rename packages/lib/{ => src}/bullmq/index.ts (100%) rename packages/lib/{ => src}/jose/keys.ts (100%) rename packages/lib/{ => src}/jose/sign.ts (100%) rename packages/lib/{ => src}/jose/types.ts (100%) rename packages/lib/{ => src}/logger/index.ts (100%) rename packages/lib/{ => src}/mongodb/index.ts (100%) rename packages/lib/{ => src}/quicktype/index.ts (100%) rename packages/lib/{ => src}/radix/index.ts (100%) rename packages/lib/{ => src}/radix/store.ts (100%) rename packages/lib/{ => src}/redis/index.ts (100%) rename packages/lib/{ => src}/superjson/index.ts (100%) rename packages/lib/{ => src}/transformer/index.ts (100%) rename packages/lib/{ => src}/ws/index.ts (100%) rename packages/lib/{ => src}/ws/ws.ts (100%) rename packages/lib/{ => src}/ws/wss.ts (100%) create mode 100644 packages/lib/tsconfig.json diff --git a/.gitignore b/.gitignore index 4a4628d..957d6c2 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,5 @@ core # Other .scraper-* *.log* + +.idea diff --git a/apps/backend/src/orbitdb/keystore.ts b/apps/backend/src/orbitdb/keystore.ts index 3403138..aff2456 100644 --- a/apps/backend/src/orbitdb/keystore.ts +++ b/apps/backend/src/orbitdb/keystore.ts @@ -22,6 +22,7 @@ await ipfs.start() const keystore = await KeyStore({ path: keysPath }) const identities = await Identities({ keystore, ipfs }) + const provider = PublicKeyIdentityProvider({ keystore }) const identity = await identities.createIdentity({ id, provider }) diff --git a/packages/lib/package.json b/packages/lib/package.json index 0ae6ebe..2b6aee9 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -19,9 +19,9 @@ "*" ], "scripts": { + "build": "yarn tsc -b", "dev": "yarn esno src/index.ts", "typecheck": "yarn tsc --noEmit", - "build": "cross-env NODE_OPTIONS=\"--no-warnings\" yarn rollup --configPlugin esbuild --config rollup.config.ts", "start": "cross-env NODE_OPTIONS=\"--no-warnings --experimental-modules --experimental-import-meta-resolve\" yarn node src/esm/index.mjs", "schema": "yarn typescript-json-schema --out schema.json --skipLibCheck src/index.ts Options", "release": "yarn npm publish", diff --git a/packages/lib/ajv/index.ts b/packages/lib/src/ajv/index.ts similarity index 100% rename from packages/lib/ajv/index.ts rename to packages/lib/src/ajv/index.ts diff --git a/packages/lib/ajv/schema.ts b/packages/lib/src/ajv/schema.ts similarity index 100% rename from packages/lib/ajv/schema.ts rename to packages/lib/src/ajv/schema.ts diff --git a/packages/lib/automerge/index.ts b/packages/lib/src/automerge/index.ts similarity index 100% rename from packages/lib/automerge/index.ts rename to packages/lib/src/automerge/index.ts diff --git a/packages/lib/bullmq/events.ts b/packages/lib/src/bullmq/events.ts similarity index 100% rename from packages/lib/bullmq/events.ts rename to packages/lib/src/bullmq/events.ts diff --git a/packages/lib/bullmq/index.ts b/packages/lib/src/bullmq/index.ts similarity index 100% rename from packages/lib/bullmq/index.ts rename to packages/lib/src/bullmq/index.ts diff --git a/packages/lib/jose/keys.ts b/packages/lib/src/jose/keys.ts similarity index 100% rename from packages/lib/jose/keys.ts rename to packages/lib/src/jose/keys.ts diff --git a/packages/lib/jose/sign.ts b/packages/lib/src/jose/sign.ts similarity index 100% rename from packages/lib/jose/sign.ts rename to packages/lib/src/jose/sign.ts diff --git a/packages/lib/jose/types.ts b/packages/lib/src/jose/types.ts similarity index 100% rename from packages/lib/jose/types.ts rename to packages/lib/src/jose/types.ts diff --git a/packages/lib/logger/index.ts b/packages/lib/src/logger/index.ts similarity index 100% rename from packages/lib/logger/index.ts rename to packages/lib/src/logger/index.ts diff --git a/packages/lib/mongodb/index.ts b/packages/lib/src/mongodb/index.ts similarity index 100% rename from packages/lib/mongodb/index.ts rename to packages/lib/src/mongodb/index.ts diff --git a/packages/lib/quicktype/index.ts b/packages/lib/src/quicktype/index.ts similarity index 100% rename from packages/lib/quicktype/index.ts rename to packages/lib/src/quicktype/index.ts diff --git a/packages/lib/radix/index.ts b/packages/lib/src/radix/index.ts similarity index 100% rename from packages/lib/radix/index.ts rename to packages/lib/src/radix/index.ts diff --git a/packages/lib/radix/store.ts b/packages/lib/src/radix/store.ts similarity index 100% rename from packages/lib/radix/store.ts rename to packages/lib/src/radix/store.ts diff --git a/packages/lib/redis/index.ts b/packages/lib/src/redis/index.ts similarity index 100% rename from packages/lib/redis/index.ts rename to packages/lib/src/redis/index.ts diff --git a/packages/lib/superjson/index.ts b/packages/lib/src/superjson/index.ts similarity index 100% rename from packages/lib/superjson/index.ts rename to packages/lib/src/superjson/index.ts diff --git a/packages/lib/transformer/index.ts b/packages/lib/src/transformer/index.ts similarity index 100% rename from packages/lib/transformer/index.ts rename to packages/lib/src/transformer/index.ts diff --git a/packages/lib/ws/index.ts b/packages/lib/src/ws/index.ts similarity index 100% rename from packages/lib/ws/index.ts rename to packages/lib/src/ws/index.ts diff --git a/packages/lib/ws/ws.ts b/packages/lib/src/ws/ws.ts similarity index 100% rename from packages/lib/ws/ws.ts rename to packages/lib/src/ws/ws.ts diff --git a/packages/lib/ws/wss.ts b/packages/lib/src/ws/wss.ts similarity index 100% rename from packages/lib/ws/wss.ts rename to packages/lib/src/ws/wss.ts diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json new file mode 100644 index 0000000..db22027 --- /dev/null +++ b/packages/lib/tsconfig.json @@ -0,0 +1,6 @@ +{ + "extends": "../../tsconfig.json", + "compilerOptions": { + "sourceMap": true + } +} \ No newline at end of file From 54cd7ff4ba86f227962ae85addfa778183f7ecbd Mon Sep 17 00:00:00 2001 From: Alec Date: Mon, 1 Jul 2024 08:17:27 +0000 Subject: [PATCH 2/4] refactor export libs --- apps/backend/src/context.ts | 1 + package.json | 1 + packages/lib/package.json | 54 ++++++++++++++++++++++++++++++++-- packages/lib/src/ajv/schema.ts | 4 +-- packages/lib/tsconfig.json | 45 ++++++++++++++++++++++++++-- scripts/generate_types.ts | 2 +- yarn.lock | 3 +- 7 files changed, 101 insertions(+), 9 deletions(-) diff --git a/apps/backend/src/context.ts b/apps/backend/src/context.ts index ec749d9..33127f2 100644 --- a/apps/backend/src/context.ts +++ b/apps/backend/src/context.ts @@ -1,3 +1,4 @@ +// import { createAjv } from '@regioni/lib/ajv' import { createAjv } from '@regioni/lib/ajv' import { bullmq } from '@regioni/lib/bullmq' import { createRedisStore } from '@regioni/lib/redis' diff --git a/package.json b/package.json index d957eaa..55a5c9f 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "apps/*" ], "devDependencies": { + "@regioni/lib": "workspace:^", "@sozdev/eslint-config": "^0.0.11", "@sozdev/rollup-build": "^0.0.10", "@types/ws": "^8.5.10", diff --git a/packages/lib/package.json b/packages/lib/package.json index 2b6aee9..d7ac1aa 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -15,8 +15,58 @@ "bugs": "https://gitea.local/regioni/lib/issues", "keywords": [], "sideEffects": false, + "exports": { + "./ajv": { + "import": "./dist/ajv/index.js", + "types": "./dist/ajv/index.d.ts" + }, + "./automerge": { + "import": "./dist/automerge/index.js", + "types": "./dist/automerge/index.d.ts" + }, + "./bullmq": { + "import": "./dist/bullmq/index.js", + "types": "./dist/bullmq/index.d.ts" + }, + "./jose": { + "import": "./dist/jose/index.js", + "types": "./dist/jose/index.d.ts" + }, + "./logger": { + "import": "./dist/logger/index.js", + "types": "./dist/logger/index.d.ts" + }, + "./mongodb": { + "import": "./dist/mongodb/index.js", + "types": "./dist/mongodb/index.d.ts" + }, + "./quicktype": { + "import": "./dist/quicktype/index.js", + "types": "./dist/quicktype/index.d.ts" + }, + "./redis": { + "import": "./dist/redis/index.js", + "types": "./dist/redis/index.d.ts" + }, + "./radix": { + "import": "./dist/radix/index.js", + "types": "./dist/radix/index.d.ts" + }, + "./superjson": { + "import": "./dist/superjson/index.js", + "types": "./dist/superjson/index.d.ts" + }, + "./transformer": { + "import": "./dist/transformer/index.js", + "types": "./dist/transformer/index.d.ts" + }, + "./ws": { + "import": "./dist/ws/index.js", + "types": "./dist/ws/index.d.ts" + } + }, "files": [ - "*" + "dist" ], "scripts": { "build": "yarn tsc -b", @@ -48,7 +98,7 @@ "esno": "^4.7.0", "lint-staged": "^15.2.7", "simple-git-hooks": "^2.9.0", - "typescript": "^5.2.2", + "typescript": "^5.5.2", "typescript-json-schema": "0.62.0" }, "simple-git-hooks": { diff --git a/packages/lib/src/ajv/schema.ts b/packages/lib/src/ajv/schema.ts index f6f94d3..737a31d 100644 --- a/packages/lib/src/ajv/schema.ts +++ b/packages/lib/src/ajv/schema.ts @@ -1,9 +1,9 @@ import type { JSONSchemaType } from 'ajv' -import type { TestUserInfo } from 'types' +// import type { TestUserInfo } from 'types' export const userSchema: JSONSchemaType<{ status: string - info?: TestUserInfo + // info?: TestUserInfo date: string }> = { type: 'object', diff --git a/packages/lib/tsconfig.json b/packages/lib/tsconfig.json index db22027..8d19784 100644 --- a/packages/lib/tsconfig.json +++ b/packages/lib/tsconfig.json @@ -1,6 +1,45 @@ { - "extends": "../../tsconfig.json", + "$schema": "https://json.schemastore.org/tsconfig.json", "compilerOptions": { - "sourceMap": true - } + "target": "ESNext", + "lib": [ + "ESNext", + "DOM" + ], + "baseUrl": ".", + "rootDir": "./src/", + "module": "ESNext", + "moduleResolution": "Bundler", + "noResolve": false, + "paths": { + // "~/*": [ + // "src/*" + // ], + "@/*": [ + "src/*" + ], + "types/*": [ + "types/*" + ] + }, + "resolveJsonModule": true, + "resolvePackageJsonExports": true, + "resolvePackageJsonImports": true, + "allowJs": true, + "strict": true, + "declaration": true, + "importHelpers": true, + "outDir": "dist", + "sourceMap": true, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true + }, + "include": [ + "types/**/*", + "src/**/*", + "lib/**/*", + "scripts/**/*" + ] } \ No newline at end of file diff --git a/scripts/generate_types.ts b/scripts/generate_types.ts index 7e0a622..9fdb098 100644 --- a/scripts/generate_types.ts +++ b/scripts/generate_types.ts @@ -5,7 +5,7 @@ import consola from 'consola' import glob from 'fast-glob' import { TypeScriptTargetLanguage } from 'quicktype-core' -import { quicktypeMultipleJSONSchema } from '@/quicktype' +import { quicktypeMultipleJSONSchema } from '@regioni/lib/src/quicktype' import type { JSONSchemaSourceData } from 'quicktype-core' diff --git a/yarn.lock b/yarn.lock index 8599e00..0da8af2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5185,7 +5185,7 @@ __metadata: rollup-plugin-esbuild: "npm:^6.1.0" rollup-plugin-peer-deps-external: "npm:^2.2.4" simple-git-hooks: "npm:^2.9.0" - typescript: "npm:^5.2.2" + typescript: "npm:^5.5.2" typescript-json-schema: "npm:0.62.0" languageName: unknown linkType: soft @@ -5951,6 +5951,7 @@ __metadata: version: 0.0.0-use.local resolution: "@sozdev/typescript-template@workspace:." dependencies: + "@regioni/lib": "workspace:^" "@sozdev/eslint-config": "npm:^0.0.11" "@sozdev/rollup-build": "npm:^0.0.10" "@types/ws": "npm:^8.5.10" From 3e96be8d99b97234d71d5620ae934a24ff59944c Mon Sep 17 00:00:00 2001 From: Alec Date: Mon, 1 Jul 2024 12:02:12 +0000 Subject: [PATCH 3/4] save --- apps/backend/build.config.ts | 38 +++ apps/backend/package.json | 8 +- apps/backend/rollup.config.mjs | 18 ++ apps/backend/src/routers/data.ts | 2 +- apps/backend/tsconfig.json | 4 +- package.json | 2 +- packages/build/src/index.ts | 10 +- packages/lib/src/bullmq/index.ts | 1 + yarn.lock | 454 ++++++++++++++++++++++--------- 9 files changed, 404 insertions(+), 133 deletions(-) create mode 100644 apps/backend/build.config.ts diff --git a/apps/backend/build.config.ts b/apps/backend/build.config.ts new file mode 100644 index 0000000..105a5d6 --- /dev/null +++ b/apps/backend/build.config.ts @@ -0,0 +1,38 @@ +import wasm from "@rollup/plugin-wasm"; +import { defineBuildConfig } from "unbuild"; + +export default defineBuildConfig({ + hooks: { + "rollup:options": (_,options) => { + options.plugins = Array.isArray(options.plugins) ? options.plugins : [options.plugins]; + options.plugins.push(wasm()); + } + }, + entries: [ + { + input: "src/index.ts", + outDir: "dist/esm", + builder: "rollup", + + // plugins: [wasm()], + // format: "esm", + // esbuild: {}, + }, + // { + // input: "src/index.ts", + // outDir: "dist/cjs", + // format: "cjs", + // ext: "cjs", + // declaration: false, + + // }, + ], + declaration: true, + rollup: { + emitCJS: true, + // output: { + + // plugins: [wasm()], + // }, + }, +}); diff --git a/apps/backend/package.json b/apps/backend/package.json index ba74ef8..1b6ec28 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -37,7 +37,7 @@ "dist" ], "scripts": { - "build": "cross-env NODE_OPTIONS=\"--no-warnings\" yarn rollup --config ./rollup.config.mjs", + "build": "cross-env NODE_OPTIONS=\"--no-warnings\" yarn rollup --config ./rollup.config.mjs", "start": "cross-env NODE_OPTIONS=\"--no-warnings --experimental-modules --experimental-import-meta-resolve\" yarn node dist/esm/index.mjs", "schema": "yarn typescript-json-schema --out schema.json --skipLibCheck src/index.ts Options", "typecheck": "yarn tsc --noEmit", @@ -90,9 +90,13 @@ }, "devDependencies": { "@regioni/lib": "workspace:^", + "@rollup/plugin-wasm": "^6.2.2", "@types/orbitdb__core": "workspace:^", "esbuild": "^0.21.5", "rollup": "^4.14.0", - "tsx": "^4.7.2" + "rollup-plugin-node-polyfills": "^0.2.1", + "rollup-plugin-terser": "^7.0.2", + "tsx": "^4.7.2", + "unbuild": "^2.0.0" } } diff --git a/apps/backend/rollup.config.mjs b/apps/backend/rollup.config.mjs index 280535f..0ac8702 100644 --- a/apps/backend/rollup.config.mjs +++ b/apps/backend/rollup.config.mjs @@ -1,4 +1,8 @@ import build from '@regioni/build' +import wasm from '@rollup/plugin-wasm' + +// import { terser } from 'rollup-plugin-terser' +// import nodePolyfills from 'rollup-plugin-node-polyfills' export default build({ src: './src', @@ -6,7 +10,21 @@ export default build({ input: './index.ts', pkg: './package.json', tsconfig: './tsconfig.build.json', + plugins: [ + wasm(), + // nodePolyfills(), + // terser() + ], + esbuild: { + minify: true, + }, + resolve: { modulePaths: [], + preferBuiltins: false, }, + json: { + compact: true, + }, + }) diff --git a/apps/backend/src/routers/data.ts b/apps/backend/src/routers/data.ts index 6c1ff0b..e4adc18 100644 --- a/apps/backend/src/routers/data.ts +++ b/apps/backend/src/routers/data.ts @@ -1,4 +1,4 @@ -import { queueEvents } from '@regioni/lib/bullmq/events' +import { queueEvents } from '@regioni/lib/bullmq' import { observable } from '@trpc/server/observable' import consola from 'consola' import { z } from 'zod' diff --git a/apps/backend/tsconfig.json b/apps/backend/tsconfig.json index 996e095..3bdc858 100644 --- a/apps/backend/tsconfig.json +++ b/apps/backend/tsconfig.json @@ -1,7 +1,7 @@ { "$schema": "https://json.schemastore.org/tsconfig.json", "compilerOptions": { - "target": "ESNext", + "target": "ES2017", "lib": [ "ESNext", "DOM" @@ -28,4 +28,4 @@ "include": [ "src/**/*" ] -} \ No newline at end of file +} diff --git a/package.json b/package.json index 55a5c9f..a359341 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "frontend:build": "yarn workspace @regioni/nuxt-frontend run build", "backend:dev": "yarn workspace @regioni/backend dev", "backend:build": "yarn workspace @regioni/backend run build", - "packages:build": "yarn workspace @regioni/build run build && yarn workspace", + "packages:build": "yarn workspace @regioni/build run build && yarn workspace @regioni/lib run build", "generate:types": "yarn tsx scripts/generate_types.ts", "generate:keys": "yarn tsx scripts/generate_keys.ts" }, diff --git a/packages/build/src/index.ts b/packages/build/src/index.ts index e226047..2907a3e 100644 --- a/packages/build/src/index.ts +++ b/packages/build/src/index.ts @@ -7,7 +7,7 @@ import commonjs from '@rollup/plugin-commonjs' import json from '@rollup/plugin-json' import resolve from '@rollup/plugin-node-resolve' import defu from 'defu' -import { defineConfig } from 'rollup' +import { InputPluginOption, defineConfig } from 'rollup' import dts from 'rollup-plugin-dts' import esbuild from 'rollup-plugin-esbuild' @@ -44,6 +44,7 @@ export interface Options { commonjs?: RollupCommonJSOptions esbuild?: RollupEsbuildOptions dts?: RollupDtsOptions + plugins?: InputPluginOption[] } function build(options?: Options) { @@ -89,12 +90,14 @@ function build(options?: Options) { }, resolve: { preferBuiltins: true, + }, commonjs: { - exclude: external, + // exclude: external, }, esbuild: { - exclude: external, + // include: external, + // exclude: external, minify: true, tsconfig: tsconfigFile, }, @@ -133,6 +136,7 @@ function build(options?: Options) { resolve(opts.resolve), commonjs(opts.commonjs), esbuild(opts.esbuild), + ...(opts.plugins || []) ], }, { diff --git a/packages/lib/src/bullmq/index.ts b/packages/lib/src/bullmq/index.ts index be15f54..faed4ba 100644 --- a/packages/lib/src/bullmq/index.ts +++ b/packages/lib/src/bullmq/index.ts @@ -1,4 +1,5 @@ import { Queue } from 'bullmq' +export * from './events' export const bullmq = new Queue< { message: string }, diff --git a/yarn.lock b/yarn.lock index 0da8af2..5407fd8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -161,7 +161,7 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.23.5, @babel/code-frame@npm:^7.24.7": +"@babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.23.5, @babel/code-frame@npm:^7.24.2, @babel/code-frame@npm:^7.24.7": version: 7.24.7 resolution: "@babel/code-frame@npm:7.24.7" dependencies: @@ -5100,6 +5100,7 @@ __metadata: "@orbitdb/core": "npm:^2.2.0" "@regioni/build": "workspace:^" "@regioni/lib": "workspace:^" + "@rollup/plugin-wasm": "npm:^6.2.2" "@trpc/client": "npm:^10.45.2" "@trpc/server": "npm:^10.45.2" "@types/orbitdb__core": "workspace:^" @@ -5128,9 +5129,12 @@ __metadata: radix-ts: "npm:^1.0.2" redis: "npm:^4.6.13" rollup: "npm:^4.14.0" + rollup-plugin-node-polyfills: "npm:^0.2.1" + rollup-plugin-terser: "npm:^7.0.2" superjson: "npm:^2.2.1" ts-pattern: "npm:^5.1.0" tsx: "npm:^4.7.2" + unbuild: "npm:^2.0.0" unstorage: "npm:^1.10.2" winston: "npm:^3.13.0" ws: "npm:^8.16.0" @@ -5271,9 +5275,9 @@ __metadata: languageName: unknown linkType: soft -"@rollup/plugin-alias@npm:^5.0.1": - version: 5.0.1 - resolution: "@rollup/plugin-alias@npm:5.0.1" +"@rollup/plugin-alias@npm:^5.0.0, @rollup/plugin-alias@npm:^5.1.0": + version: 5.1.0 + resolution: "@rollup/plugin-alias@npm:5.1.0" dependencies: slash: "npm:^4.0.0" peerDependencies: @@ -5281,13 +5285,13 @@ __metadata: peerDependenciesMeta: rollup: optional: true - checksum: 10/99ae776b4dc3fd3e0cb2b535689d80a3b7eafc8f29bcd5441f4b1d5c8b7934ee2c57071df9c4c74c6e89d5b908e4ee5ef3d0202c7bd008694b2e016548e40b67 + checksum: 10/2749f9563dba9274e4324fcd14ffe761fa66ee3baab307ba583d0348adfa2c1d2a164f59eac8c26a9ce7c713a99a991a831c072101e83697157ccf082c362310 languageName: node linkType: hard -"@rollup/plugin-alias@npm:^5.1.0": - version: 5.1.0 - resolution: "@rollup/plugin-alias@npm:5.1.0" +"@rollup/plugin-alias@npm:^5.0.1": + version: 5.0.1 + resolution: "@rollup/plugin-alias@npm:5.0.1" dependencies: slash: "npm:^4.0.0" peerDependencies: @@ -5295,7 +5299,7 @@ __metadata: peerDependenciesMeta: rollup: optional: true - checksum: 10/2749f9563dba9274e4324fcd14ffe761fa66ee3baab307ba583d0348adfa2c1d2a164f59eac8c26a9ce7c713a99a991a831c072101e83697157ccf082c362310 + checksum: 10/99ae776b4dc3fd3e0cb2b535689d80a3b7eafc8f29bcd5441f4b1d5c8b7934ee2c57071df9c4c74c6e89d5b908e4ee5ef3d0202c7bd008694b2e016548e40b67 languageName: node linkType: hard @@ -5316,9 +5320,9 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-commonjs@npm:^25.0.7": - version: 25.0.7 - resolution: "@rollup/plugin-commonjs@npm:25.0.7" +"@rollup/plugin-commonjs@npm:^25.0.4, @rollup/plugin-commonjs@npm:^25.0.8": + version: 25.0.8 + resolution: "@rollup/plugin-commonjs@npm:25.0.8" dependencies: "@rollup/pluginutils": "npm:^5.0.1" commondir: "npm:^1.0.1" @@ -5331,13 +5335,13 @@ __metadata: peerDependenciesMeta: rollup: optional: true - checksum: 10/89b108e245d1af6e7878ac949bfcd44e48f7d0c1eda0cb0b7e89c231ae73de455ffe2ac65eb03a398da4e8c300ce404f997fe66f8dde3d4d4794ffd2c1241fc3 + checksum: 10/2d6190450bdf2ca2c4ab71a35eb5bf245349ad7dab6fc84a3a4e65147fd694be816e3c31b575c9e55a70a2f82132b79092d1ee04358e6e504beb31a8c82178bb languageName: node linkType: hard -"@rollup/plugin-commonjs@npm:^25.0.8": - version: 25.0.8 - resolution: "@rollup/plugin-commonjs@npm:25.0.8" +"@rollup/plugin-commonjs@npm:^25.0.7": + version: 25.0.7 + resolution: "@rollup/plugin-commonjs@npm:25.0.7" dependencies: "@rollup/pluginutils": "npm:^5.0.1" commondir: "npm:^1.0.1" @@ -5350,7 +5354,7 @@ __metadata: peerDependenciesMeta: rollup: optional: true - checksum: 10/2d6190450bdf2ca2c4ab71a35eb5bf245349ad7dab6fc84a3a4e65147fd694be816e3c31b575c9e55a70a2f82132b79092d1ee04358e6e504beb31a8c82178bb + checksum: 10/89b108e245d1af6e7878ac949bfcd44e48f7d0c1eda0cb0b7e89c231ae73de455ffe2ac65eb03a398da4e8c300ce404f997fe66f8dde3d4d4794ffd2c1241fc3 languageName: node linkType: hard @@ -5389,35 +5393,35 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-json@npm:^6.0.1": - version: 6.0.1 - resolution: "@rollup/plugin-json@npm:6.0.1" +"@rollup/plugin-json@npm:^6.0.0, @rollup/plugin-json@npm:^6.1.0": + version: 6.1.0 + resolution: "@rollup/plugin-json@npm:6.1.0" dependencies: - "@rollup/pluginutils": "npm:^5.0.1" + "@rollup/pluginutils": "npm:^5.1.0" peerDependencies: rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 peerDependenciesMeta: rollup: optional: true - checksum: 10/86995e3ceec0205bd0b5ae3075f4592e0ab3e6e6327a5dcfc825b44113eaae5819d26d5403d29b177ac59299e0b08c641c8d030e0c72805b92805ededc9cac44 + checksum: 10/cc018d20c80242a2b8b44fae61a968049cf31bb8406218187cc7cda35747616594e79452dd65722e7da6dd825b392e90d4599d43cd4461a02fefa2865945164e languageName: node linkType: hard -"@rollup/plugin-json@npm:^6.1.0": - version: 6.1.0 - resolution: "@rollup/plugin-json@npm:6.1.0" +"@rollup/plugin-json@npm:^6.0.1": + version: 6.0.1 + resolution: "@rollup/plugin-json@npm:6.0.1" dependencies: - "@rollup/pluginutils": "npm:^5.1.0" + "@rollup/pluginutils": "npm:^5.0.1" peerDependencies: rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 peerDependenciesMeta: rollup: optional: true - checksum: 10/cc018d20c80242a2b8b44fae61a968049cf31bb8406218187cc7cda35747616594e79452dd65722e7da6dd825b392e90d4599d43cd4461a02fefa2865945164e + checksum: 10/86995e3ceec0205bd0b5ae3075f4592e0ab3e6e6327a5dcfc825b44113eaae5819d26d5403d29b177ac59299e0b08c641c8d030e0c72805b92805ededc9cac44 languageName: node linkType: hard -"@rollup/plugin-node-resolve@npm:^15.2.3": +"@rollup/plugin-node-resolve@npm:^15.2.1, @rollup/plugin-node-resolve@npm:^15.2.3": version: 15.2.3 resolution: "@rollup/plugin-node-resolve@npm:15.2.3" dependencies: @@ -5448,7 +5452,7 @@ __metadata: languageName: node linkType: hard -"@rollup/plugin-replace@npm:^5.0.7": +"@rollup/plugin-replace@npm:^5.0.2, @rollup/plugin-replace@npm:^5.0.7": version: 5.0.7 resolution: "@rollup/plugin-replace@npm:5.0.7" dependencies: @@ -5479,6 +5483,20 @@ __metadata: languageName: node linkType: hard +"@rollup/plugin-wasm@npm:^6.2.2": + version: 6.2.2 + resolution: "@rollup/plugin-wasm@npm:6.2.2" + dependencies: + "@rollup/pluginutils": "npm:^5.0.2" + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + checksum: 10/9ae3b17552a0174d48420acc93ffbe394075767feb8f324eb00351d73f56b57c6592591ba615568bb992e8549d8b4c3b9deecc7fb13bd06f876296ec0d9c170c + languageName: node + linkType: hard + "@rollup/plugin-yaml@npm:^4.1.2": version: 4.1.2 resolution: "@rollup/plugin-yaml@npm:4.1.2" @@ -5534,7 +5552,7 @@ __metadata: languageName: node linkType: hard -"@rollup/pluginutils@npm:^5.0.2, @rollup/pluginutils@npm:^5.0.4, @rollup/pluginutils@npm:^5.1.0": +"@rollup/pluginutils@npm:^5.0.2, @rollup/pluginutils@npm:^5.0.3, @rollup/pluginutils@npm:^5.0.4, @rollup/pluginutils@npm:^5.1.0": version: 5.1.0 resolution: "@rollup/pluginutils@npm:5.1.0" dependencies: @@ -8860,7 +8878,7 @@ __metadata: languageName: node linkType: hard -"citty@npm:^0.1.5, citty@npm:^0.1.6": +"citty@npm:^0.1.2, citty@npm:^0.1.5, citty@npm:^0.1.6": version: 0.1.6 resolution: "citty@npm:0.1.6" dependencies: @@ -9620,7 +9638,7 @@ __metadata: languageName: node linkType: hard -"cssnano@npm:^7.0.2": +"cssnano@npm:^7.0.2, cssnano@npm:^7.0.3": version: 7.0.3 resolution: "cssnano@npm:7.0.3" dependencies: @@ -10543,6 +10561,86 @@ __metadata: languageName: node linkType: hard +"esbuild@npm:^0.19.2, esbuild@npm:~0.19.10": + version: 0.19.12 + resolution: "esbuild@npm:0.19.12" + dependencies: + "@esbuild/aix-ppc64": "npm:0.19.12" + "@esbuild/android-arm": "npm:0.19.12" + "@esbuild/android-arm64": "npm:0.19.12" + "@esbuild/android-x64": "npm:0.19.12" + "@esbuild/darwin-arm64": "npm:0.19.12" + "@esbuild/darwin-x64": "npm:0.19.12" + "@esbuild/freebsd-arm64": "npm:0.19.12" + "@esbuild/freebsd-x64": "npm:0.19.12" + "@esbuild/linux-arm": "npm:0.19.12" + "@esbuild/linux-arm64": "npm:0.19.12" + "@esbuild/linux-ia32": "npm:0.19.12" + "@esbuild/linux-loong64": "npm:0.19.12" + "@esbuild/linux-mips64el": "npm:0.19.12" + "@esbuild/linux-ppc64": "npm:0.19.12" + "@esbuild/linux-riscv64": "npm:0.19.12" + "@esbuild/linux-s390x": "npm:0.19.12" + "@esbuild/linux-x64": "npm:0.19.12" + "@esbuild/netbsd-x64": "npm:0.19.12" + "@esbuild/openbsd-x64": "npm:0.19.12" + "@esbuild/sunos-x64": "npm:0.19.12" + "@esbuild/win32-arm64": "npm:0.19.12" + "@esbuild/win32-ia32": "npm:0.19.12" + "@esbuild/win32-x64": "npm:0.19.12" + dependenciesMeta: + "@esbuild/aix-ppc64": + optional: true + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: 10/861fa8eb2428e8d6521a4b7c7930139e3f45e8d51a86985cc29408172a41f6b18df7b3401e7e5e2d528cdf83742da601ddfdc77043ddc4f1c715a8ddb2d8a255 + languageName: node + linkType: hard + "esbuild@npm:^0.19.5": version: 0.19.5 resolution: "esbuild@npm:0.19.5" @@ -10780,86 +10878,6 @@ __metadata: languageName: node linkType: hard -"esbuild@npm:~0.19.10": - version: 0.19.12 - resolution: "esbuild@npm:0.19.12" - dependencies: - "@esbuild/aix-ppc64": "npm:0.19.12" - "@esbuild/android-arm": "npm:0.19.12" - "@esbuild/android-arm64": "npm:0.19.12" - "@esbuild/android-x64": "npm:0.19.12" - "@esbuild/darwin-arm64": "npm:0.19.12" - "@esbuild/darwin-x64": "npm:0.19.12" - "@esbuild/freebsd-arm64": "npm:0.19.12" - "@esbuild/freebsd-x64": "npm:0.19.12" - "@esbuild/linux-arm": "npm:0.19.12" - "@esbuild/linux-arm64": "npm:0.19.12" - "@esbuild/linux-ia32": "npm:0.19.12" - "@esbuild/linux-loong64": "npm:0.19.12" - "@esbuild/linux-mips64el": "npm:0.19.12" - "@esbuild/linux-ppc64": "npm:0.19.12" - "@esbuild/linux-riscv64": "npm:0.19.12" - "@esbuild/linux-s390x": "npm:0.19.12" - "@esbuild/linux-x64": "npm:0.19.12" - "@esbuild/netbsd-x64": "npm:0.19.12" - "@esbuild/openbsd-x64": "npm:0.19.12" - "@esbuild/sunos-x64": "npm:0.19.12" - "@esbuild/win32-arm64": "npm:0.19.12" - "@esbuild/win32-ia32": "npm:0.19.12" - "@esbuild/win32-x64": "npm:0.19.12" - dependenciesMeta: - "@esbuild/aix-ppc64": - optional: true - "@esbuild/android-arm": - optional: true - "@esbuild/android-arm64": - optional: true - "@esbuild/android-x64": - optional: true - "@esbuild/darwin-arm64": - optional: true - "@esbuild/darwin-x64": - optional: true - "@esbuild/freebsd-arm64": - optional: true - "@esbuild/freebsd-x64": - optional: true - "@esbuild/linux-arm": - optional: true - "@esbuild/linux-arm64": - optional: true - "@esbuild/linux-ia32": - optional: true - "@esbuild/linux-loong64": - optional: true - "@esbuild/linux-mips64el": - optional: true - "@esbuild/linux-ppc64": - optional: true - "@esbuild/linux-riscv64": - optional: true - "@esbuild/linux-s390x": - optional: true - "@esbuild/linux-x64": - optional: true - "@esbuild/netbsd-x64": - optional: true - "@esbuild/openbsd-x64": - optional: true - "@esbuild/sunos-x64": - optional: true - "@esbuild/win32-arm64": - optional: true - "@esbuild/win32-ia32": - optional: true - "@esbuild/win32-x64": - optional: true - bin: - esbuild: bin/esbuild - checksum: 10/861fa8eb2428e8d6521a4b7c7930139e3f45e8d51a86985cc29408172a41f6b18df7b3401e7e5e2d528cdf83742da601ddfdc77043ddc4f1c715a8ddb2d8a255 - languageName: node - linkType: hard - "escalade@npm:^3.1.1": version: 3.1.1 resolution: "escalade@npm:3.1.1" @@ -11735,6 +11753,13 @@ __metadata: languageName: node linkType: hard +"estree-walker@npm:^0.6.1": + version: 0.6.1 + resolution: "estree-walker@npm:0.6.1" + checksum: 10/b8da7815030c4e0b735f5f8af370af09525e052ee14e539cecabc24ad6da1782448778361417e7c438091a59e7ca9f4a0c11642f7da4f2ebf1ba7a150a590bcc + languageName: node + linkType: hard + "estree-walker@npm:^1.0.1": version: 1.0.1 resolution: "estree-walker@npm:1.0.1" @@ -12795,6 +12820,19 @@ __metadata: languageName: node linkType: hard +"globby@npm:^13.2.2": + version: 13.2.2 + resolution: "globby@npm:13.2.2" + dependencies: + dir-glob: "npm:^3.0.1" + fast-glob: "npm:^3.3.0" + ignore: "npm:^5.2.4" + merge2: "npm:^1.4.1" + slash: "npm:^4.0.0" + checksum: 10/4494a9d2162a7e4d327988b26be66d8eab87d7f59a83219e74b065e2c3ced23698f68fb10482bf9337133819281803fb886d6ae06afbb2affa743623eb0b1949 + languageName: node + linkType: hard + "globby@npm:^14.0.1": version: 14.0.1 resolution: "globby@npm:14.0.1" @@ -14661,6 +14699,17 @@ __metadata: languageName: node linkType: hard +"jest-worker@npm:^26.2.1": + version: 26.6.2 + resolution: "jest-worker@npm:26.6.2" + dependencies: + "@types/node": "npm:*" + merge-stream: "npm:^2.0.0" + supports-color: "npm:^7.0.0" + checksum: 10/5f6b94cf0e8701392a9402fc7af34a1324d334fc6a440d4d55d2d9348114659c035b8d9b259930f9c9e40cbdda0ef9bfe4d7c780e1107057bbe1202672b38533 + languageName: node + linkType: hard + "jest-worker@npm:^29.7.0": version: 29.7.0 resolution: "jest-worker@npm:29.7.0" @@ -14673,21 +14722,21 @@ __metadata: languageName: node linkType: hard -"jiti@npm:^1.21.0": - version: 1.21.0 - resolution: "jiti@npm:1.21.0" +"jiti@npm:^1.19.3, jiti@npm:^1.21.6": + version: 1.21.6 + resolution: "jiti@npm:1.21.6" bin: jiti: bin/jiti.js - checksum: 10/005a0239e50381b5c9919f59dbab86128367bd64872f3376dbbde54b6523f41bd134bf22909e2a509e38fd87e1c22125ca255b9b6b53e7df0fedd23f737334cc + checksum: 10/289b124cea411c130a14ffe88e3d38376ab44b6695616dfa0a1f32176a8f20ec90cdd6d2b9d81450fc6467cfa4d865f04f49b98452bff0f812bc400fd0ae78d6 languageName: node linkType: hard -"jiti@npm:^1.21.6": - version: 1.21.6 - resolution: "jiti@npm:1.21.6" +"jiti@npm:^1.21.0": + version: 1.21.0 + resolution: "jiti@npm:1.21.0" bin: jiti: bin/jiti.js - checksum: 10/289b124cea411c130a14ffe88e3d38376ab44b6695616dfa0a1f32176a8f20ec90cdd6d2b9d81450fc6467cfa4d865f04f49b98452bff0f812bc400fd0ae78d6 + checksum: 10/005a0239e50381b5c9919f59dbab86128367bd64872f3376dbbde54b6523f41bd134bf22909e2a509e38fd87e1c22125ca255b9b6b53e7df0fedd23f737334cc languageName: node linkType: hard @@ -15604,7 +15653,7 @@ __metadata: languageName: node linkType: hard -"magic-string@npm:^0.25.0, magic-string@npm:^0.25.7": +"magic-string@npm:^0.25.0, magic-string@npm:^0.25.3, magic-string@npm:^0.25.7": version: 0.25.9 resolution: "magic-string@npm:0.25.9" dependencies: @@ -16685,6 +16734,42 @@ __metadata: languageName: node linkType: hard +"mkdist@npm:^1.3.0": + version: 1.5.3 + resolution: "mkdist@npm:1.5.3" + dependencies: + autoprefixer: "npm:^10.4.19" + citty: "npm:^0.1.6" + cssnano: "npm:^7.0.3" + defu: "npm:^6.1.4" + esbuild: "npm:^0.21.5" + fs-extra: "npm:^11.2.0" + globby: "npm:^14.0.1" + jiti: "npm:^1.21.6" + mlly: "npm:^1.7.1" + mri: "npm:^1.2.0" + pathe: "npm:^1.1.2" + pkg-types: "npm:^1.1.1" + postcss: "npm:^8.4.38" + postcss-nested: "npm:^6.0.1" + semver: "npm:^7.6.2" + peerDependencies: + sass: ^1.77.6 + typescript: ">=5.4.5" + vue-tsc: ^1.8.27 || ^2.0.21 + peerDependenciesMeta: + sass: + optional: true + typescript: + optional: true + vue-tsc: + optional: true + bin: + mkdist: dist/cli.cjs + checksum: 10/a18a5096a6eeb59921ea27aae037132dd995da18e45a3f9b9460864e921a0b677cd42d23b5c83f98fc5e3c55442e176f3ba9b6175edc1838e7f6c9e51f037ec0 + languageName: node + linkType: hard + "mlly@npm:^1.2.0, mlly@npm:^1.4.2, mlly@npm:^1.6.1": version: 1.6.1 resolution: "mlly@npm:1.6.1" @@ -16697,7 +16782,7 @@ __metadata: languageName: node linkType: hard -"mlly@npm:^1.3.0, mlly@npm:^1.7.0, mlly@npm:^1.7.1": +"mlly@npm:^1.3.0, mlly@npm:^1.4.0, mlly@npm:^1.7.0, mlly@npm:^1.7.1": version: 1.7.1 resolution: "mlly@npm:1.7.1" dependencies: @@ -19996,6 +20081,22 @@ __metadata: languageName: node linkType: hard +"rollup-plugin-dts@npm:^6.0.0": + version: 6.1.1 + resolution: "rollup-plugin-dts@npm:6.1.1" + dependencies: + "@babel/code-frame": "npm:^7.24.2" + magic-string: "npm:^0.30.10" + peerDependencies: + rollup: ^3.29.4 || ^4 + typescript: ^4.5 || ^5.0 + dependenciesMeta: + "@babel/code-frame": + optional: true + checksum: 10/8a66833a5af32f77d9bbc746339097d4af2382e5160f7629d85dcecb4efad12cbfebd37c79147fa688f073c333d71f53135e08a225a3fc3e9a3b3f92c46b2381 + languageName: node + linkType: hard + "rollup-plugin-dts@npm:^6.1.0": version: 6.1.0 resolution: "rollup-plugin-dts@npm:6.1.0" @@ -20027,6 +20128,26 @@ __metadata: languageName: node linkType: hard +"rollup-plugin-inject@npm:^3.0.0": + version: 3.0.2 + resolution: "rollup-plugin-inject@npm:3.0.2" + dependencies: + estree-walker: "npm:^0.6.1" + magic-string: "npm:^0.25.3" + rollup-pluginutils: "npm:^2.8.1" + checksum: 10/34081611c4b00b582339fc76880844d9729d9a26ede987c9939440cb0affe5965d4c9b1ebb62a021bb67e118426420de77114731404fa57126e35186267548e7 + languageName: node + linkType: hard + +"rollup-plugin-node-polyfills@npm:^0.2.1": + version: 0.2.1 + resolution: "rollup-plugin-node-polyfills@npm:0.2.1" + dependencies: + rollup-plugin-inject: "npm:^3.0.0" + checksum: 10/283c108108f93684975c83fd2b274d028162a9df0db2225737bfd0f8cab9215f0228d3703928ef667a8ba2f4749649ba06c58b89f48a211d7116e7f98fc988dd + languageName: node + linkType: hard + "rollup-plugin-peer-deps-external@npm:^2.2.4": version: 2.2.4 resolution: "rollup-plugin-peer-deps-external@npm:2.2.4" @@ -20036,6 +20157,20 @@ __metadata: languageName: node linkType: hard +"rollup-plugin-terser@npm:^7.0.2": + version: 7.0.2 + resolution: "rollup-plugin-terser@npm:7.0.2" + dependencies: + "@babel/code-frame": "npm:^7.10.4" + jest-worker: "npm:^26.2.1" + serialize-javascript: "npm:^4.0.0" + terser: "npm:^5.0.0" + peerDependencies: + rollup: ^2.0.0 + checksum: 10/af84bb7a7a894cd00852b6486528dfb8653cf94df4c126f95f389a346f401d054b08c46bee519a2ab6a22b33804d1d6ac6d8c90b1b2bf8fffb097eed73fc3c72 + languageName: node + linkType: hard + "rollup-plugin-visualizer@npm:^5.12.0": version: 5.12.0 resolution: "rollup-plugin-visualizer@npm:5.12.0" @@ -20055,6 +20190,15 @@ __metadata: languageName: node linkType: hard +"rollup-pluginutils@npm:^2.8.1": + version: 2.8.2 + resolution: "rollup-pluginutils@npm:2.8.2" + dependencies: + estree-walker: "npm:^0.6.1" + checksum: 10/f3dc20a8731523aff43e07fa50ed84857e9dd3ab81e2cfb0351d517c46820e585bfbd1530a5dddec3ac14d61d41eb9bf50b38ded987e558292790331cc5b0628 + languageName: node + linkType: hard + "rollup@npm:^2.43.1, rollup@npm:^2.77.2": version: 2.79.1 resolution: "rollup@npm:2.79.1" @@ -20069,6 +20213,20 @@ __metadata: languageName: node linkType: hard +"rollup@npm:^3.28.1": + version: 3.29.4 + resolution: "rollup@npm:3.29.4" + dependencies: + fsevents: "npm:~2.3.2" + dependenciesMeta: + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: 10/9e39d54e23731a4c4067e9c02910cdf7479a0f9a7584796e2dc6efaa34bb1e5e015c062c87d1e64d96038baca76cefd47681ff22604fae5827147f54123dc6d0 + languageName: node + linkType: hard + "rollup@npm:^4.13.0, rollup@npm:^4.18.0": version: 4.18.0 resolution: "rollup@npm:4.18.0" @@ -20436,6 +20594,15 @@ __metadata: languageName: node linkType: hard +"serialize-javascript@npm:^4.0.0": + version: 4.0.0 + resolution: "serialize-javascript@npm:4.0.0" + dependencies: + randombytes: "npm:^2.1.0" + checksum: 10/df6809168973a84facade7d73e2d6dc418f5dee704d1e6cbe79e92fdb4c10af55237e99d2e67881ae3b29aa96ba596a0dfec4e609bd289ab8ec93c5ae78ede8e + languageName: node + linkType: hard + "serialize-javascript@npm:^6.0.1": version: 6.0.2 resolution: "serialize-javascript@npm:6.0.2" @@ -21893,7 +22060,7 @@ __metadata: languageName: node linkType: hard -"terser@npm:^5.17.4": +"terser@npm:^5.0.0, terser@npm:^5.17.4": version: 5.31.1 resolution: "terser@npm:5.31.1" dependencies: @@ -22575,6 +22742,45 @@ __metadata: languageName: node linkType: hard +"unbuild@npm:^2.0.0": + version: 2.0.0 + resolution: "unbuild@npm:2.0.0" + dependencies: + "@rollup/plugin-alias": "npm:^5.0.0" + "@rollup/plugin-commonjs": "npm:^25.0.4" + "@rollup/plugin-json": "npm:^6.0.0" + "@rollup/plugin-node-resolve": "npm:^15.2.1" + "@rollup/plugin-replace": "npm:^5.0.2" + "@rollup/pluginutils": "npm:^5.0.3" + chalk: "npm:^5.3.0" + citty: "npm:^0.1.2" + consola: "npm:^3.2.3" + defu: "npm:^6.1.2" + esbuild: "npm:^0.19.2" + globby: "npm:^13.2.2" + hookable: "npm:^5.5.3" + jiti: "npm:^1.19.3" + magic-string: "npm:^0.30.3" + mkdist: "npm:^1.3.0" + mlly: "npm:^1.4.0" + pathe: "npm:^1.1.1" + pkg-types: "npm:^1.0.3" + pretty-bytes: "npm:^6.1.1" + rollup: "npm:^3.28.1" + rollup-plugin-dts: "npm:^6.0.0" + scule: "npm:^1.0.0" + untyped: "npm:^1.4.0" + peerDependencies: + typescript: ^5.1.6 + peerDependenciesMeta: + typescript: + optional: true + bin: + unbuild: dist/cli.mjs + checksum: 10/11fdec2dee6d1b9f72c493518c8d5db4e0c8dffd291589659b0ebbf509042c84b4b9f5c42912019fbbc80ba1d2ab7f2c14fd1412ad3c8bf4c429fbaff9e30fb0 + languageName: node + linkType: hard + "uncrypto@npm:^0.1.3": version: 0.1.3 resolution: "uncrypto@npm:0.1.3" @@ -23051,7 +23257,7 @@ __metadata: languageName: node linkType: hard -"untyped@npm:^1.4.2": +"untyped@npm:^1.4.0, untyped@npm:^1.4.2": version: 1.4.2 resolution: "untyped@npm:1.4.2" dependencies: From 06b88cd561a353393e309e2422cb817ee597f0c6 Mon Sep 17 00:00:00 2001 From: Alec Date: Mon, 1 Jul 2024 15:51:02 +0300 Subject: [PATCH 4/4] refactor ws browser --- apps/backend/build.config.ts | 38 ---------- apps/backend/rollup.config.mjs | 9 ++- apps/backend/src/index.ts | 1 + apps/frontend/src/plugins/client.ts | 5 +- packages/lib/package.json | 4 ++ packages/lib/src/jose/types.ts | 7 ++ packages/lib/src/ws/browser.ts | 106 +++++++++++++++++++++++++++ packages/lib/src/ws/index.ts | 1 + packages/lib/src/ws/types.ts | 16 +++++ packages/lib/src/ws/wrapper.ts | 107 ++++++++++++++++++++++++++++ packages/lib/src/ws/ws.ts | 82 ++------------------- packages/lib/src/ws/wss.ts | 10 ++- 12 files changed, 265 insertions(+), 121 deletions(-) delete mode 100644 apps/backend/build.config.ts create mode 100644 packages/lib/src/ws/browser.ts create mode 100644 packages/lib/src/ws/types.ts create mode 100644 packages/lib/src/ws/wrapper.ts diff --git a/apps/backend/build.config.ts b/apps/backend/build.config.ts deleted file mode 100644 index 105a5d6..0000000 --- a/apps/backend/build.config.ts +++ /dev/null @@ -1,38 +0,0 @@ -import wasm from "@rollup/plugin-wasm"; -import { defineBuildConfig } from "unbuild"; - -export default defineBuildConfig({ - hooks: { - "rollup:options": (_,options) => { - options.plugins = Array.isArray(options.plugins) ? options.plugins : [options.plugins]; - options.plugins.push(wasm()); - } - }, - entries: [ - { - input: "src/index.ts", - outDir: "dist/esm", - builder: "rollup", - - // plugins: [wasm()], - // format: "esm", - // esbuild: {}, - }, - // { - // input: "src/index.ts", - // outDir: "dist/cjs", - // format: "cjs", - // ext: "cjs", - // declaration: false, - - // }, - ], - declaration: true, - rollup: { - emitCJS: true, - // output: { - - // plugins: [wasm()], - // }, - }, -}); diff --git a/apps/backend/rollup.config.mjs b/apps/backend/rollup.config.mjs index 0ac8702..8a203ff 100644 --- a/apps/backend/rollup.config.mjs +++ b/apps/backend/rollup.config.mjs @@ -9,7 +9,7 @@ export default build({ input: './index.ts', pkg: './package.json', - tsconfig: './tsconfig.build.json', + tsconfig: './tsconfig.json', plugins: [ wasm(), // nodePolyfills(), @@ -18,10 +18,13 @@ export default build({ esbuild: { minify: true, }, + dts: { + respectExternal: true, + }, resolve: { - modulePaths: [], - preferBuiltins: false, + // modulePaths: [], + preferBuiltins: true, }, json: { compact: true, diff --git a/apps/backend/src/index.ts b/apps/backend/src/index.ts index f5780c8..6376d35 100644 --- a/apps/backend/src/index.ts +++ b/apps/backend/src/index.ts @@ -7,6 +7,7 @@ import { createContext } from './context' import { router } from './router' import type { Router } from './router' +export * from './router' const logger = consola.withTag('server') export const app = createHTTPServer({ diff --git a/apps/frontend/src/plugins/client.ts b/apps/frontend/src/plugins/client.ts index 999ad3c..e328f02 100644 --- a/apps/frontend/src/plugins/client.ts +++ b/apps/frontend/src/plugins/client.ts @@ -1,8 +1,9 @@ -import { WebSocketBrowserProxy, transformer } from '@sozdev/share-libs/dist/browser' +import { transformer } from '@regioni/lib/transformer' +import { WebSocketBrowserProxy } from '@regioni/lib/ws/browser' import { type CreateTRPCProxyClient, createTRPCProxyClient, createWSClient, wsLink } from '@trpc/client' import consola from 'consola' -import type { AppRouter } from '@sozdev/backend' +import type { Router as AppRouter } from '@regioni/backend' declare module '#app/nuxt' { export interface NuxtApp { diff --git a/packages/lib/package.json b/packages/lib/package.json index d7ac1aa..0fad338 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -63,6 +63,10 @@ "./ws": { "import": "./dist/ws/index.js", "types": "./dist/ws/index.d.ts" + }, + "./ws/browser": { + "import": "./dist/ws/browser.js", + "types": "./dist/ws/browser.d.ts" } }, "files": [ diff --git a/packages/lib/src/jose/types.ts b/packages/lib/src/jose/types.ts index 65e2fca..2abef6d 100644 --- a/packages/lib/src/jose/types.ts +++ b/packages/lib/src/jose/types.ts @@ -1,5 +1,12 @@ import type * as jose from 'jose' +import type { JWTVerifyGetKey } from 'jose' export type KeyPair = jose.GenerateKeyPairResult< jose.KeyLike & jose.JWK > + + +export interface IJoseVerify { + key: KeyPair + jwks: JWTVerifyGetKey +} diff --git a/packages/lib/src/ws/browser.ts b/packages/lib/src/ws/browser.ts new file mode 100644 index 0000000..119d842 --- /dev/null +++ b/packages/lib/src/ws/browser.ts @@ -0,0 +1,106 @@ +import consola from 'consola' + +import { sign, verify } from '../jose/sign' + +import type { IJoseVerify } from '../jose/types' + +export * from './types' + +const logger = consola.withTag('ws/browser') +export class WebSocketBrowserProxy extends WebSocket { + jose?: IJoseVerify + public constructor( + address: string | URL, + protocols?: string | string[], + jose?: IJoseVerify, + ) { + super(address, protocols) + this.jose = jose + + return wrapSocket(this) + } +} + +export function wrapSocket(ws: WebSocketBrowserProxy) { + return new Proxy(ws, { + get: (target, prop) => { + logger.debug('Getting', prop, target) + switch (prop) { + case 'addEventListener': + return customOn.bind(target) + case 'send': + return customSend.bind(target) + } + + return Reflect.get(target, prop) + }, + }) +} + +type BufferLike = string | ArrayBufferView | ArrayBufferLike | Blob + +async function customOn( + this: WebSocketBrowserProxy, + event: string, + listener: (...args: any[]) => void, +) { + this.addEventListener(event, customListener) + + async function customListener(this: WebSocketBrowserProxy, ...args: any[]) { + if (event === 'message') { + const [event] = args as [MessageEvent] + const data = event.data + + if (!this.jose) { + logger.debug('Receiving: jose not initialized', data) + + return listener.call(this, event) + } + try { + const { payload, ..._jws } = await verify(data.toString(), this.jose.jwks) + + const newEvent = createMessageEvent(event, payload) + + logger.debug('Receiving payload"', { payload, event: newEvent }) + + return listener.call(this, newEvent) + } + catch (error) { + const newEvent = createMessageEvent(event, {}) + return listener.call(this, newEvent) + } + } + + logger.debug('Receiving', event, args) + + return listener.call(this, ...args) + } +} + +function createMessageEvent(event: MessageEvent, payload: unknown) { + return new MessageEvent('message', { + data: JSON.stringify(payload), + origin: event.origin, + source: event.source, + lastEventId: event.lastEventId, + ports: [...event.ports], + }) +} + +async function customSend(this: WebSocketBrowserProxy, data: BufferLike) { + if (!this.jose) { + logger.debug('Sending: jose not initialized', data) + this.send(data) + return + } + + logger.debug('Signing payload: ', { payload: data, jose: this.jose }) + + const jws = await sign(this.jose.key, { + payload: JSON.parse(data.toString()), + }) + + logger.debug('Sending', jws) + + this.send(jws) +} diff --git a/packages/lib/src/ws/index.ts b/packages/lib/src/ws/index.ts index 61d02be..3c998e2 100644 --- a/packages/lib/src/ws/index.ts +++ b/packages/lib/src/ws/index.ts @@ -1,2 +1,3 @@ export * from './ws' export * from './wss' +export * from './types' diff --git a/packages/lib/src/ws/types.ts b/packages/lib/src/ws/types.ts new file mode 100644 index 0000000..b7325e5 --- /dev/null +++ b/packages/lib/src/ws/types.ts @@ -0,0 +1,16 @@ +import { IJoseVerify } from '../jose/types' + +declare module 'ws' { + export interface WebSocketServer { + jose?: IJoseVerify + } + export interface WebSocket { + jose?: IJoseVerify + } +} + +declare global { + export interface WebSocket { + jose?: IJoseVerify + } +} diff --git a/packages/lib/src/ws/wrapper.ts b/packages/lib/src/ws/wrapper.ts new file mode 100644 index 0000000..6c9da01 --- /dev/null +++ b/packages/lib/src/ws/wrapper.ts @@ -0,0 +1,107 @@ +import consola from 'consola' + +import { sign, verify } from '../jose/sign' + +import type { WebSocketProxy } from './ws' +import type { IJoseVerify } from '../jose/types' +import type Buffer from 'node:buffer' + +type BufferLike = + | string + | Buffer + | DataView + | number + | ArrayBufferView + | Uint8Array + | ArrayBuffer + | SharedArrayBuffer + | readonly any[] + | readonly number[] + | { valueOf: () => ArrayBuffer } + | { valueOf: () => SharedArrayBuffer } + | { valueOf: () => Uint8Array } + | { valueOf: () => readonly number[] } + | { valueOf: () => string } + | { [Symbol.toPrimitive]: (hint: string) => string } + +const logger = consola.withTag('ws') +export function wrapSocket(ws: WebSocketProxy, jose?: IJoseVerify) { + ws.jose = jose + return new Proxy(ws, { + get: (target, prop, receiver) => { + switch (prop) { + case 'on': + return customOn.bind(target) + case 'send': + return customSend.bind(target) + } + + return Reflect.get(target, prop, receiver) + }, + }) as T +} + +async function customOn( + this: WebSocketProxy, + event: string, + listener: (...args: any[]) => void, +) { + return this.on(event, customListener) + + async function customListener(this: WebSocketProxy, ...args: any[]) { + if (event === 'message') { + const [data, isBinary] = args as | [BufferLike, boolean] + + if (!this.jose) { + logger.debug('Receiving: jose not initialized', data) + + return listener.call(this, data, isBinary) + } + try { + const { payload, ..._jws } = await verify(data.toString(), this.jose.jwks) + + logger.debug('Receiving payload"', { payload }) + + return listener.call( + this, + // JSON.stringify({ ...jws, ...(payload as object) }), + JSON.stringify(payload), + isBinary, + ) + } + catch (e) { + return listener.call( + this, + // JSON.stringify({ ...jws, ...(payload as object) }), + JSON.stringify({}), + isBinary, + ) + } + } + + logger.debug('Receiving', event, args) + + listener.call(this, ...args) + } +} + +async function customSend( + this: WebSocketProxy, + data: BufferLike, + cb?: (error?: Error) => void, +) { + if (!this.jose) { + logger.debug('Sending: jose not initialized', data) + return this.send(data, cb) + } + + logger.debug('Signing payload: ', { payload: data, jose: this.jose }) + + const jws = await sign(this.jose.key, { + payload: JSON.parse(data.toString()), + }) + + logger.debug('Sending', jws) + + this.send(jws, cb) +} diff --git a/packages/lib/src/ws/ws.ts b/packages/lib/src/ws/ws.ts index 74b20ce..f215b11 100644 --- a/packages/lib/src/ws/ws.ts +++ b/packages/lib/src/ws/ws.ts @@ -1,87 +1,19 @@ -import consola from 'consola' -import { WebSocket } from 'ws' +import { WebSocket as WebSocketNode } from 'ws' -// import { jwks, keys1 } from '@/jose/keys' -// import { sign, verify } from '@/jose/sign' +import { wrapSocket } from './wrapper' -import type { Buffer } from 'node:buffer' +import type { IJoseVerify } from '../jose/types' import type { ClientOptions } from 'ws' -const logger = consola.withTag('ws') - -type BufferLike = - | string - | Buffer - | DataView - | number - | ArrayBufferView - | Uint8Array - | ArrayBuffer - | SharedArrayBuffer - | readonly any[] - | readonly number[] - | { valueOf: () => ArrayBuffer } - | { valueOf: () => SharedArrayBuffer } - | { valueOf: () => Uint8Array } - | { valueOf: () => readonly number[] } - | { valueOf: () => string } - | { [Symbol.toPrimitive]: (hint: string) => string } - -export class WebSocketProxy extends WebSocket { +export class WebSocketProxy extends WebSocketNode { + public jose?: IJoseVerify public constructor( address: string | URL, protocols?: string | string[], options?: ClientOptions, + jose?: IJoseVerify, ) { super(address, protocols, options) - - return wrapSocket(this) + return wrapSocket(this, jose) } } - -export function wrapSocket(ws: WebSocket) { - return new Proxy(ws, { - get: (target, prop, receiver) => { - switch (prop) { - case 'on': - return customOn.bind(target) - case 'send': - return customSend.bind(target) - } - - return Reflect.get(target, prop, receiver) - }, - }) -} - -async function customOn( - this: WebSocket, - event: string, - listener: (...args: any[]) => void, -) { - this.on(event, async (...args: any[]) => { - if (event === 'message') { - const [data, isBinary] = args as [BufferLike, boolean] - // const jws = await verify(data.toString(), jwks) - // logger.log('Receiving', event, JSON.stringify(jws)) - - // listener.call(this, JSON.stringify(jws), isBinary) - listener.call(this, data.toString(), isBinary) - - return - } - - listener.call(this, ...args) - }) -} - -async function customSend( - this: WebSocket, - data: BufferLike, - cb?: (error?: Error) => void, -) { - // const jws = await sign(keys1, JSON.parse(data.toString())) - // logger.log('Sending', jws) - - this.send(data, cb) -} diff --git a/packages/lib/src/ws/wss.ts b/packages/lib/src/ws/wss.ts index 1b1051e..481072f 100644 --- a/packages/lib/src/ws/wss.ts +++ b/packages/lib/src/ws/wss.ts @@ -1,15 +1,19 @@ import consola from 'consola' import { WebSocketServer } from 'ws' -import { wrapSocket } from './ws' +import { wrapSocket } from './wrapper' +import type { IJoseVerify } from '../jose/types' import type { ServerOptions, WebSocket } from 'ws' const logger = consola.withTag('wss') export class WebSocketServerProxy extends WebSocketServer { - public constructor(options?: ServerOptions, callback?: () => void) { + jose?: IJoseVerify + public constructor(options?: ServerOptions, jose?: IJoseVerify, callback?: () => void) { super(options, callback) + this.jose = jose + logger.info('new WebSocketServer', jose) return wrapSocketServer(this) } @@ -35,7 +39,7 @@ async function customOn( this.on(event, async (...args: any[]) => { if (event === 'connection') { logger.info('Connection') - args[0] = wrapSocket(args[0] as WebSocket) + args[0] = wrapSocket(args[0] as WebSocket, this.jose) } listener.call(this, ...args)