This commit is contained in:
熊潇 2025-03-18 11:24:46 +08:00
commit a765dc8ba7
20 changed files with 1441 additions and 0 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
dist
.DS_Store

2
.npmrc Normal file
View File

@ -0,0 +1,2 @@
//npm.xiongxiao.me/:_authToken=${ME_NPM_TOKEN}
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

21
package.json Normal file
View File

@ -0,0 +1,21 @@
{
"name": "@kevisual/gen-js",
"version": "0.0.1",
"description": "generate js code",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.6.2",
"type": "module",
"dependencies": {
"rollup": "^4.35.0",
"@kevisual/tojs": "workspace:*"
},
"devDependencies": {
"turbo": "^2.4.4"
}
}

968
pnpm-lock.yaml generated Normal file
View File

@ -0,0 +1,968 @@
lockfileVersion: '9.0'
settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
importers:
.:
dependencies:
'@kevisual/tojs':
specifier: workspace:*
version: link:tojs
rollup:
specifier: ^4.35.0
version: 4.35.0
devDependencies:
turbo:
specifier: ^2.4.4
version: 2.4.4
sw:
devDependencies:
vite:
specifier: ^6.2.2
version: 6.2.2(@types/node@22.13.10)
tojs:
dependencies:
'@cacheable/node-cache':
specifier: ^1.5.3
version: 1.5.3
'@kevisual/use-config':
specifier: ^1.0.9
version: 1.0.9
cacheable:
specifier: ^1.8.9
version: 1.8.9
devDependencies:
'@rollup/plugin-node-resolve':
specifier: ^16.0.1
version: 16.0.1(rollup@4.35.0)
'@types/node':
specifier: ^22.13.10
version: 22.13.10
rollup:
specifier: ^4.35.0
version: 4.35.0
rollup-plugin-dts:
specifier: ^6.1.1
version: 6.1.1(rollup@4.35.0)(typescript@5.8.2)
rollup-plugin-esbuild:
specifier: ^6.2.1
version: 6.2.1(esbuild@0.25.1)(rollup@4.35.0)
typescript:
specifier: ^5.8.2
version: 5.8.2
packages:
'@babel/code-frame@7.26.2':
resolution: {integrity: sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==}
engines: {node: '>=6.9.0'}
'@babel/helper-validator-identifier@7.25.9':
resolution: {integrity: sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==}
engines: {node: '>=6.9.0'}
'@cacheable/node-cache@1.5.3':
resolution: {integrity: sha512-xJCYqoxkwg8vpQ/wSv0p4o+j/VEEnP7TUDUsV+VoPVVuwpsUKxU0wyz+VWBbq0SbX6e/oi/jiR/LDQ46miDQ8A==}
'@esbuild/aix-ppc64@0.25.1':
resolution: {integrity: sha512-kfYGy8IdzTGy+z0vFGvExZtxkFlA4zAxgKEahG9KE1ScBjpQnFsNOX8KTU5ojNru5ed5CVoJYXFtoxaq5nFbjQ==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [aix]
'@esbuild/android-arm64@0.25.1':
resolution: {integrity: sha512-50tM0zCJW5kGqgG7fQ7IHvQOcAn9TKiVRuQ/lN0xR+T2lzEFvAi1ZcS8DiksFcEpf1t/GYOeOfCAgDHFpkiSmA==}
engines: {node: '>=18'}
cpu: [arm64]
os: [android]
'@esbuild/android-arm@0.25.1':
resolution: {integrity: sha512-dp+MshLYux6j/JjdqVLnMglQlFu+MuVeNrmT5nk6q07wNhCdSnB7QZj+7G8VMUGh1q+vj2Bq8kRsuyA00I/k+Q==}
engines: {node: '>=18'}
cpu: [arm]
os: [android]
'@esbuild/android-x64@0.25.1':
resolution: {integrity: sha512-GCj6WfUtNldqUzYkN/ITtlhwQqGWu9S45vUXs7EIYf+7rCiiqH9bCloatO9VhxsL0Pji+PF4Lz2XXCES+Q8hDw==}
engines: {node: '>=18'}
cpu: [x64]
os: [android]
'@esbuild/darwin-arm64@0.25.1':
resolution: {integrity: sha512-5hEZKPf+nQjYoSr/elb62U19/l1mZDdqidGfmFutVUjjUZrOazAtwK+Kr+3y0C/oeJfLlxo9fXb1w7L+P7E4FQ==}
engines: {node: '>=18'}
cpu: [arm64]
os: [darwin]
'@esbuild/darwin-x64@0.25.1':
resolution: {integrity: sha512-hxVnwL2Dqs3fM1IWq8Iezh0cX7ZGdVhbTfnOy5uURtao5OIVCEyj9xIzemDi7sRvKsuSdtCAhMKarxqtlyVyfA==}
engines: {node: '>=18'}
cpu: [x64]
os: [darwin]
'@esbuild/freebsd-arm64@0.25.1':
resolution: {integrity: sha512-1MrCZs0fZa2g8E+FUo2ipw6jw5qqQiH+tERoS5fAfKnRx6NXH31tXBKI3VpmLijLH6yriMZsxJtaXUyFt/8Y4A==}
engines: {node: '>=18'}
cpu: [arm64]
os: [freebsd]
'@esbuild/freebsd-x64@0.25.1':
resolution: {integrity: sha512-0IZWLiTyz7nm0xuIs0q1Y3QWJC52R8aSXxe40VUxm6BB1RNmkODtW6LHvWRrGiICulcX7ZvyH6h5fqdLu4gkww==}
engines: {node: '>=18'}
cpu: [x64]
os: [freebsd]
'@esbuild/linux-arm64@0.25.1':
resolution: {integrity: sha512-jaN3dHi0/DDPelk0nLcXRm1q7DNJpjXy7yWaWvbfkPvI+7XNSc/lDOnCLN7gzsyzgu6qSAmgSvP9oXAhP973uQ==}
engines: {node: '>=18'}
cpu: [arm64]
os: [linux]
'@esbuild/linux-arm@0.25.1':
resolution: {integrity: sha512-NdKOhS4u7JhDKw9G3cY6sWqFcnLITn6SqivVArbzIaf3cemShqfLGHYMx8Xlm/lBit3/5d7kXvriTUGa5YViuQ==}
engines: {node: '>=18'}
cpu: [arm]
os: [linux]
'@esbuild/linux-ia32@0.25.1':
resolution: {integrity: sha512-OJykPaF4v8JidKNGz8c/q1lBO44sQNUQtq1KktJXdBLn1hPod5rE/Hko5ugKKZd+D2+o1a9MFGUEIUwO2YfgkQ==}
engines: {node: '>=18'}
cpu: [ia32]
os: [linux]
'@esbuild/linux-loong64@0.25.1':
resolution: {integrity: sha512-nGfornQj4dzcq5Vp835oM/o21UMlXzn79KobKlcs3Wz9smwiifknLy4xDCLUU0BWp7b/houtdrgUz7nOGnfIYg==}
engines: {node: '>=18'}
cpu: [loong64]
os: [linux]
'@esbuild/linux-mips64el@0.25.1':
resolution: {integrity: sha512-1osBbPEFYwIE5IVB/0g2X6i1qInZa1aIoj1TdL4AaAb55xIIgbg8Doq6a5BzYWgr+tEcDzYH67XVnTmUzL+nXg==}
engines: {node: '>=18'}
cpu: [mips64el]
os: [linux]
'@esbuild/linux-ppc64@0.25.1':
resolution: {integrity: sha512-/6VBJOwUf3TdTvJZ82qF3tbLuWsscd7/1w+D9LH0W/SqUgM5/JJD0lrJ1fVIfZsqB6RFmLCe0Xz3fmZc3WtyVg==}
engines: {node: '>=18'}
cpu: [ppc64]
os: [linux]
'@esbuild/linux-riscv64@0.25.1':
resolution: {integrity: sha512-nSut/Mx5gnilhcq2yIMLMe3Wl4FK5wx/o0QuuCLMtmJn+WeWYoEGDN1ipcN72g1WHsnIbxGXd4i/MF0gTcuAjQ==}
engines: {node: '>=18'}
cpu: [riscv64]
os: [linux]
'@esbuild/linux-s390x@0.25.1':
resolution: {integrity: sha512-cEECeLlJNfT8kZHqLarDBQso9a27o2Zd2AQ8USAEoGtejOrCYHNtKP8XQhMDJMtthdF4GBmjR2au3x1udADQQQ==}
engines: {node: '>=18'}
cpu: [s390x]
os: [linux]
'@esbuild/linux-x64@0.25.1':
resolution: {integrity: sha512-xbfUhu/gnvSEg+EGovRc+kjBAkrvtk38RlerAzQxvMzlB4fXpCFCeUAYzJvrnhFtdeyVCDANSjJvOvGYoeKzFA==}
engines: {node: '>=18'}
cpu: [x64]
os: [linux]
'@esbuild/netbsd-arm64@0.25.1':
resolution: {integrity: sha512-O96poM2XGhLtpTh+s4+nP7YCCAfb4tJNRVZHfIE7dgmax+yMP2WgMd2OecBuaATHKTHsLWHQeuaxMRnCsH8+5g==}
engines: {node: '>=18'}
cpu: [arm64]
os: [netbsd]
'@esbuild/netbsd-x64@0.25.1':
resolution: {integrity: sha512-X53z6uXip6KFXBQ+Krbx25XHV/NCbzryM6ehOAeAil7X7oa4XIq+394PWGnwaSQ2WRA0KI6PUO6hTO5zeF5ijA==}
engines: {node: '>=18'}
cpu: [x64]
os: [netbsd]
'@esbuild/openbsd-arm64@0.25.1':
resolution: {integrity: sha512-Na9T3szbXezdzM/Kfs3GcRQNjHzM6GzFBeU1/6IV/npKP5ORtp9zbQjvkDJ47s6BCgaAZnnnu/cY1x342+MvZg==}
engines: {node: '>=18'}
cpu: [arm64]
os: [openbsd]
'@esbuild/openbsd-x64@0.25.1':
resolution: {integrity: sha512-T3H78X2h1tszfRSf+txbt5aOp/e7TAz3ptVKu9Oyir3IAOFPGV6O9c2naym5TOriy1l0nNf6a4X5UXRZSGX/dw==}
engines: {node: '>=18'}
cpu: [x64]
os: [openbsd]
'@esbuild/sunos-x64@0.25.1':
resolution: {integrity: sha512-2H3RUvcmULO7dIE5EWJH8eubZAI4xw54H1ilJnRNZdeo8dTADEZ21w6J22XBkXqGJbe0+wnNJtw3UXRoLJnFEg==}
engines: {node: '>=18'}
cpu: [x64]
os: [sunos]
'@esbuild/win32-arm64@0.25.1':
resolution: {integrity: sha512-GE7XvrdOzrb+yVKB9KsRMq+7a2U/K5Cf/8grVFRAGJmfADr/e/ODQ134RK2/eeHqYV5eQRFxb1hY7Nr15fv1NQ==}
engines: {node: '>=18'}
cpu: [arm64]
os: [win32]
'@esbuild/win32-ia32@0.25.1':
resolution: {integrity: sha512-uOxSJCIcavSiT6UnBhBzE8wy3n0hOkJsBOzy7HDAuTDE++1DJMRRVCPGisULScHL+a/ZwdXPpXD3IyFKjA7K8A==}
engines: {node: '>=18'}
cpu: [ia32]
os: [win32]
'@esbuild/win32-x64@0.25.1':
resolution: {integrity: sha512-Y1EQdcfwMSeQN/ujR5VayLOJ1BHaK+ssyk0AEzPjC+t1lITgsnccPqFjb6V+LsTp/9Iov4ysfjxLaGJ9RPtkVg==}
engines: {node: '>=18'}
cpu: [x64]
os: [win32]
'@jridgewell/sourcemap-codec@1.5.0':
resolution: {integrity: sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==}
'@kevisual/load@0.0.4':
resolution: {integrity: sha512-TJBieKsEoEPfP4+tDyhNZdMX2LMAGiDZ/IrAXPFWB4jeFP0Ywm1W5xDV52LhhHq4nwTmuhyTVmPxJYiEVYTHtA==}
'@kevisual/use-config@1.0.9':
resolution: {integrity: sha512-lJz98WWL178QUaf/rkM9feMm0aUnYd6ikm3ma/9Zi/K2QNrxbTRAgMGkCggUalAES8IbUvEsg+Q+Y2RaPLxCmw==}
'@keyv/serialize@1.0.3':
resolution: {integrity: sha512-qnEovoOp5Np2JDGonIDL6Ayihw0RhnRh6vxPuHo4RDn1UOzwEo4AeIfpL6UGIrsceWrCMiVPgwRjbHu4vYFc3g==}
'@rollup/plugin-node-resolve@16.0.1':
resolution: {integrity: sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==}
engines: {node: '>=14.0.0'}
peerDependencies:
rollup: ^2.78.0||^3.0.0||^4.0.0
peerDependenciesMeta:
rollup:
optional: true
'@rollup/pluginutils@5.1.4':
resolution: {integrity: sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==}
engines: {node: '>=14.0.0'}
peerDependencies:
rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0
peerDependenciesMeta:
rollup:
optional: true
'@rollup/rollup-android-arm-eabi@4.35.0':
resolution: {integrity: sha512-uYQ2WfPaqz5QtVgMxfN6NpLD+no0MYHDBywl7itPYd3K5TjjSghNKmX8ic9S8NU8w81NVhJv/XojcHptRly7qQ==}
cpu: [arm]
os: [android]
'@rollup/rollup-android-arm64@4.35.0':
resolution: {integrity: sha512-FtKddj9XZudurLhdJnBl9fl6BwCJ3ky8riCXjEw3/UIbjmIY58ppWwPEvU3fNu+W7FUsAsB1CdH+7EQE6CXAPA==}
cpu: [arm64]
os: [android]
'@rollup/rollup-darwin-arm64@4.35.0':
resolution: {integrity: sha512-Uk+GjOJR6CY844/q6r5DR/6lkPFOw0hjfOIzVx22THJXMxktXG6CbejseJFznU8vHcEBLpiXKY3/6xc+cBm65Q==}
cpu: [arm64]
os: [darwin]
'@rollup/rollup-darwin-x64@4.35.0':
resolution: {integrity: sha512-3IrHjfAS6Vkp+5bISNQnPogRAW5GAV1n+bNCrDwXmfMHbPl5EhTmWtfmwlJxFRUCBZ+tZ/OxDyU08aF6NI/N5Q==}
cpu: [x64]
os: [darwin]
'@rollup/rollup-freebsd-arm64@4.35.0':
resolution: {integrity: sha512-sxjoD/6F9cDLSELuLNnY0fOrM9WA0KrM0vWm57XhrIMf5FGiN8D0l7fn+bpUeBSU7dCgPV2oX4zHAsAXyHFGcQ==}
cpu: [arm64]
os: [freebsd]
'@rollup/rollup-freebsd-x64@4.35.0':
resolution: {integrity: sha512-2mpHCeRuD1u/2kruUiHSsnjWtHjqVbzhBkNVQ1aVD63CcexKVcQGwJ2g5VphOd84GvxfSvnnlEyBtQCE5hxVVw==}
cpu: [x64]
os: [freebsd]
'@rollup/rollup-linux-arm-gnueabihf@4.35.0':
resolution: {integrity: sha512-mrA0v3QMy6ZSvEuLs0dMxcO2LnaCONs1Z73GUDBHWbY8tFFocM6yl7YyMu7rz4zS81NDSqhrUuolyZXGi8TEqg==}
cpu: [arm]
os: [linux]
'@rollup/rollup-linux-arm-musleabihf@4.35.0':
resolution: {integrity: sha512-DnYhhzcvTAKNexIql8pFajr0PiDGrIsBYPRvCKlA5ixSS3uwo/CWNZxB09jhIapEIg945KOzcYEAGGSmTSpk7A==}
cpu: [arm]
os: [linux]
'@rollup/rollup-linux-arm64-gnu@4.35.0':
resolution: {integrity: sha512-uagpnH2M2g2b5iLsCTZ35CL1FgyuzzJQ8L9VtlJ+FckBXroTwNOaD0z0/UF+k5K3aNQjbm8LIVpxykUOQt1m/A==}
cpu: [arm64]
os: [linux]
'@rollup/rollup-linux-arm64-musl@4.35.0':
resolution: {integrity: sha512-XQxVOCd6VJeHQA/7YcqyV0/88N6ysSVzRjJ9I9UA/xXpEsjvAgDTgH3wQYz5bmr7SPtVK2TsP2fQ2N9L4ukoUg==}
cpu: [arm64]
os: [linux]
'@rollup/rollup-linux-loongarch64-gnu@4.35.0':
resolution: {integrity: sha512-5pMT5PzfgwcXEwOaSrqVsz/LvjDZt+vQ8RT/70yhPU06PTuq8WaHhfT1LW+cdD7mW6i/J5/XIkX/1tCAkh1W6g==}
cpu: [loong64]
os: [linux]
'@rollup/rollup-linux-powerpc64le-gnu@4.35.0':
resolution: {integrity: sha512-c+zkcvbhbXF98f4CtEIP1EBA/lCic5xB0lToneZYvMeKu5Kamq3O8gqrxiYYLzlZH6E3Aq+TSW86E4ay8iD8EA==}
cpu: [ppc64]
os: [linux]
'@rollup/rollup-linux-riscv64-gnu@4.35.0':
resolution: {integrity: sha512-s91fuAHdOwH/Tad2tzTtPX7UZyytHIRR6V4+2IGlV0Cej5rkG0R61SX4l4y9sh0JBibMiploZx3oHKPnQBKe4g==}
cpu: [riscv64]
os: [linux]
'@rollup/rollup-linux-s390x-gnu@4.35.0':
resolution: {integrity: sha512-hQRkPQPLYJZYGP+Hj4fR9dDBMIM7zrzJDWFEMPdTnTy95Ljnv0/4w/ixFw3pTBMEuuEuoqtBINYND4M7ujcuQw==}
cpu: [s390x]
os: [linux]
'@rollup/rollup-linux-x64-gnu@4.35.0':
resolution: {integrity: sha512-Pim1T8rXOri+0HmV4CdKSGrqcBWX0d1HoPnQ0uw0bdp1aP5SdQVNBy8LjYncvnLgu3fnnCt17xjWGd4cqh8/hA==}
cpu: [x64]
os: [linux]
'@rollup/rollup-linux-x64-musl@4.35.0':
resolution: {integrity: sha512-QysqXzYiDvQWfUiTm8XmJNO2zm9yC9P/2Gkrwg2dH9cxotQzunBHYr6jk4SujCTqnfGxduOmQcI7c2ryuW8XVg==}
cpu: [x64]
os: [linux]
'@rollup/rollup-win32-arm64-msvc@4.35.0':
resolution: {integrity: sha512-OUOlGqPkVJCdJETKOCEf1mw848ZyJ5w50/rZ/3IBQVdLfR5jk/6Sr5m3iO2tdPgwo0x7VcncYuOvMhBWZq8ayg==}
cpu: [arm64]
os: [win32]
'@rollup/rollup-win32-ia32-msvc@4.35.0':
resolution: {integrity: sha512-2/lsgejMrtwQe44glq7AFFHLfJBPafpsTa6JvP2NGef/ifOa4KBoglVf7AKN7EV9o32evBPRqfg96fEHzWo5kw==}
cpu: [ia32]
os: [win32]
'@rollup/rollup-win32-x64-msvc@4.35.0':
resolution: {integrity: sha512-PIQeY5XDkrOysbQblSW7v3l1MDZzkTEzAfTPkj5VAu3FW8fS4ynyLg2sINp0fp3SjZ8xkRYpLqoKcYqAkhU1dw==}
cpu: [x64]
os: [win32]
'@types/estree@1.0.6':
resolution: {integrity: sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==}
'@types/node@22.13.10':
resolution: {integrity: sha512-I6LPUvlRH+O6VRUqYOcMudhaIdUVWfsjnZavnsraHvpBwaEyMN29ry+0UVJhImYL16xsscu0aske3yA+uPOWfw==}
'@types/resolve@1.20.2':
resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==}
base64-js@1.5.1:
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
buffer@6.0.3:
resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==}
cacheable@1.8.9:
resolution: {integrity: sha512-FicwAUyWnrtnd4QqYAoRlNs44/a1jTL7XDKqm5gJ90wz1DQPlC7U2Rd1Tydpv+E7WAr4sQHuw8Q8M3nZMAyecQ==}
debug@4.4.0:
resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==}
engines: {node: '>=6.0'}
peerDependencies:
supports-color: '*'
peerDependenciesMeta:
supports-color:
optional: true
deepmerge@4.3.1:
resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==}
engines: {node: '>=0.10.0'}
es-module-lexer@1.6.0:
resolution: {integrity: sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==}
esbuild@0.25.1:
resolution: {integrity: sha512-BGO5LtrGC7vxnqucAe/rmvKdJllfGaYWdyABvyMoXQlfYMb2bbRuReWR5tEGE//4LcNJj9XrkovTqNYRFZHAMQ==}
engines: {node: '>=18'}
hasBin: true
estree-walker@2.0.2:
resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==}
eventemitter3@5.0.1:
resolution: {integrity: sha512-GWkBvjiSZK87ELrYOSESUYeVIc9mvLLf/nXalMOS5dYrgZq9o5OVkbZAVM06CVxYsCwH9BDZFPlQTlPA1j4ahA==}
fsevents@2.3.3:
resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==}
engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0}
os: [darwin]
function-bind@1.1.2:
resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==}
get-tsconfig@4.10.0:
resolution: {integrity: sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==}
hasown@2.0.2:
resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==}
engines: {node: '>= 0.4'}
hookified@1.8.1:
resolution: {integrity: sha512-GrO2l93P8xCWBSTBX9l2BxI78VU/MAAYag+pG8curS3aBGy0++ZlxrQ7PdUOUVMbn5BwkGb6+eRrnf43ipnFEA==}
ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
is-core-module@2.16.1:
resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==}
engines: {node: '>= 0.4'}
is-module@1.0.0:
resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==}
js-tokens@4.0.0:
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
keyv@5.3.2:
resolution: {integrity: sha512-Lji2XRxqqa5Wg+CHLVfFKBImfJZ4pCSccu9eVWK6w4c2SDFLd8JAn1zqTuSFnsxb7ope6rMsnIHfp+eBbRBRZQ==}
magic-string@0.30.17:
resolution: {integrity: sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==}
ms@2.1.3:
resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==}
nanoid@3.3.10:
resolution: {integrity: sha512-vSJJTG+t/dIKAUhUDw/dLdZ9s//5OxcHqLaDWWrW4Cdq7o6tdLIczUkMXt2MBNmk6sJRZBZRXVixs7URY1CmIg==}
engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1}
hasBin: true
path-parse@1.0.7:
resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==}
pathe@2.0.3:
resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==}
picocolors@1.1.1:
resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==}
picomatch@4.0.2:
resolution: {integrity: sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==}
engines: {node: '>=12'}
postcss@8.5.3:
resolution: {integrity: sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==}
engines: {node: ^10 || ^12 || >=14}
resolve-pkg-maps@1.0.0:
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
resolve@1.22.10:
resolution: {integrity: sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==}
engines: {node: '>= 0.4'}
hasBin: true
rollup-plugin-dts@6.1.1:
resolution: {integrity: sha512-aSHRcJ6KG2IHIioYlvAOcEq6U99sVtqDDKVhnwt70rW6tsz3tv5OSjEiWcgzfsHdLyGXZ/3b/7b/+Za3Y6r1XA==}
engines: {node: '>=16'}
peerDependencies:
rollup: ^3.29.4 || ^4
typescript: ^4.5 || ^5.0
rollup-plugin-esbuild@6.2.1:
resolution: {integrity: sha512-jTNOMGoMRhs0JuueJrJqbW8tOwxumaWYq+V5i+PD+8ecSCVkuX27tGW7BXqDgoULQ55rO7IdNxPcnsWtshz3AA==}
engines: {node: '>=14.18.0'}
peerDependencies:
esbuild: '>=0.18.0'
rollup: ^1.20.0 || ^2.0.0 || ^3.0.0 || ^4.0.0
rollup@4.35.0:
resolution: {integrity: sha512-kg6oI4g+vc41vePJyO6dHt/yl0Rz3Thv0kJeVQ3D1kS3E5XSuKbPc29G4IpT/Kv1KQwgHVcN+HtyS+HYLNSvQg==}
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
hasBin: true
source-map-js@1.2.1:
resolution: {integrity: sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==}
engines: {node: '>=0.10.0'}
supports-preserve-symlinks-flag@1.0.0:
resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==}
engines: {node: '>= 0.4'}
turbo-darwin-64@2.4.4:
resolution: {integrity: sha512-5kPvRkLAfmWI0MH96D+/THnDMGXlFNmjeqNRj5grLKiry+M9pKj3pRuScddAXPdlxjO5Ptz06UNaOQrrYGTx1g==}
cpu: [x64]
os: [darwin]
turbo-darwin-arm64@2.4.4:
resolution: {integrity: sha512-/gtHPqbGQXDFhrmy+Q/MFW2HUTUlThJ97WLLSe4bxkDrKHecDYhAjbZ4rN3MM93RV9STQb3Tqy4pZBtsd4DfCw==}
cpu: [arm64]
os: [darwin]
turbo-linux-64@2.4.4:
resolution: {integrity: sha512-SR0gri4k0bda56hw5u9VgDXLKb1Q+jrw4lM7WAhnNdXvVoep4d6LmnzgMHQQR12Wxl3KyWPbkz9d1whL6NTm2Q==}
cpu: [x64]
os: [linux]
turbo-linux-arm64@2.4.4:
resolution: {integrity: sha512-COXXwzRd3vslQIfJhXUklgEqlwq35uFUZ7hnN+AUyXx7hUOLIiD5NblL+ETrHnhY4TzWszrbwUMfe2BYWtaPQg==}
cpu: [arm64]
os: [linux]
turbo-windows-64@2.4.4:
resolution: {integrity: sha512-PV9rYNouGz4Ff3fd6sIfQy5L7HT9a4fcZoEv8PKRavU9O75G7PoDtm8scpHU10QnK0QQNLbE9qNxOAeRvF0fJg==}
cpu: [x64]
os: [win32]
turbo-windows-arm64@2.4.4:
resolution: {integrity: sha512-403sqp9t5sx6YGEC32IfZTVWkRAixOQomGYB8kEc6ZD+//LirSxzeCHCnM8EmSXw7l57U1G+Fb0kxgTcKPU/Lg==}
cpu: [arm64]
os: [win32]
turbo@2.4.4:
resolution: {integrity: sha512-N9FDOVaY3yz0YCOhYIgOGYad7+m2ptvinXygw27WPLQvcZDl3+0Sa77KGVlLSiuPDChOUEnTKE9VJwLSi9BPGQ==}
hasBin: true
typescript@5.8.2:
resolution: {integrity: sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==}
engines: {node: '>=14.17'}
hasBin: true
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
unplugin-utils@0.2.4:
resolution: {integrity: sha512-8U/MtpkPkkk3Atewj1+RcKIjb5WBimZ/WSLhhR3w6SsIj8XJuKTacSP8g+2JhfSGw0Cb125Y+2zA/IzJZDVbhA==}
engines: {node: '>=18.12.0'}
vite@6.2.2:
resolution: {integrity: sha512-yW7PeMM+LkDzc7CgJuRLMW2Jz0FxMOsVJ8Lv3gpgW9WLcb9cTW+121UEr1hvmfR7w3SegR5ItvYyzVz1vxNJgQ==}
engines: {node: ^18.0.0 || ^20.0.0 || >=22.0.0}
hasBin: true
peerDependencies:
'@types/node': ^18.0.0 || ^20.0.0 || >=22.0.0
jiti: '>=1.21.0'
less: '*'
lightningcss: ^1.21.0
sass: '*'
sass-embedded: '*'
stylus: '*'
sugarss: '*'
terser: ^5.16.0
tsx: ^4.8.1
yaml: ^2.4.2
peerDependenciesMeta:
'@types/node':
optional: true
jiti:
optional: true
less:
optional: true
lightningcss:
optional: true
sass:
optional: true
sass-embedded:
optional: true
stylus:
optional: true
sugarss:
optional: true
terser:
optional: true
tsx:
optional: true
yaml:
optional: true
snapshots:
'@babel/code-frame@7.26.2':
dependencies:
'@babel/helper-validator-identifier': 7.25.9
js-tokens: 4.0.0
picocolors: 1.1.1
optional: true
'@babel/helper-validator-identifier@7.25.9':
optional: true
'@cacheable/node-cache@1.5.3':
dependencies:
cacheable: 1.8.9
hookified: 1.8.1
keyv: 5.3.2
'@esbuild/aix-ppc64@0.25.1':
optional: true
'@esbuild/android-arm64@0.25.1':
optional: true
'@esbuild/android-arm@0.25.1':
optional: true
'@esbuild/android-x64@0.25.1':
optional: true
'@esbuild/darwin-arm64@0.25.1':
optional: true
'@esbuild/darwin-x64@0.25.1':
optional: true
'@esbuild/freebsd-arm64@0.25.1':
optional: true
'@esbuild/freebsd-x64@0.25.1':
optional: true
'@esbuild/linux-arm64@0.25.1':
optional: true
'@esbuild/linux-arm@0.25.1':
optional: true
'@esbuild/linux-ia32@0.25.1':
optional: true
'@esbuild/linux-loong64@0.25.1':
optional: true
'@esbuild/linux-mips64el@0.25.1':
optional: true
'@esbuild/linux-ppc64@0.25.1':
optional: true
'@esbuild/linux-riscv64@0.25.1':
optional: true
'@esbuild/linux-s390x@0.25.1':
optional: true
'@esbuild/linux-x64@0.25.1':
optional: true
'@esbuild/netbsd-arm64@0.25.1':
optional: true
'@esbuild/netbsd-x64@0.25.1':
optional: true
'@esbuild/openbsd-arm64@0.25.1':
optional: true
'@esbuild/openbsd-x64@0.25.1':
optional: true
'@esbuild/sunos-x64@0.25.1':
optional: true
'@esbuild/win32-arm64@0.25.1':
optional: true
'@esbuild/win32-ia32@0.25.1':
optional: true
'@esbuild/win32-x64@0.25.1':
optional: true
'@jridgewell/sourcemap-codec@1.5.0': {}
'@kevisual/load@0.0.4':
dependencies:
eventemitter3: 5.0.1
'@kevisual/use-config@1.0.9':
dependencies:
'@kevisual/load': 0.0.4
'@keyv/serialize@1.0.3':
dependencies:
buffer: 6.0.3
'@rollup/plugin-node-resolve@16.0.1(rollup@4.35.0)':
dependencies:
'@rollup/pluginutils': 5.1.4(rollup@4.35.0)
'@types/resolve': 1.20.2
deepmerge: 4.3.1
is-module: 1.0.0
resolve: 1.22.10
optionalDependencies:
rollup: 4.35.0
'@rollup/pluginutils@5.1.4(rollup@4.35.0)':
dependencies:
'@types/estree': 1.0.6
estree-walker: 2.0.2
picomatch: 4.0.2
optionalDependencies:
rollup: 4.35.0
'@rollup/rollup-android-arm-eabi@4.35.0':
optional: true
'@rollup/rollup-android-arm64@4.35.0':
optional: true
'@rollup/rollup-darwin-arm64@4.35.0':
optional: true
'@rollup/rollup-darwin-x64@4.35.0':
optional: true
'@rollup/rollup-freebsd-arm64@4.35.0':
optional: true
'@rollup/rollup-freebsd-x64@4.35.0':
optional: true
'@rollup/rollup-linux-arm-gnueabihf@4.35.0':
optional: true
'@rollup/rollup-linux-arm-musleabihf@4.35.0':
optional: true
'@rollup/rollup-linux-arm64-gnu@4.35.0':
optional: true
'@rollup/rollup-linux-arm64-musl@4.35.0':
optional: true
'@rollup/rollup-linux-loongarch64-gnu@4.35.0':
optional: true
'@rollup/rollup-linux-powerpc64le-gnu@4.35.0':
optional: true
'@rollup/rollup-linux-riscv64-gnu@4.35.0':
optional: true
'@rollup/rollup-linux-s390x-gnu@4.35.0':
optional: true
'@rollup/rollup-linux-x64-gnu@4.35.0':
optional: true
'@rollup/rollup-linux-x64-musl@4.35.0':
optional: true
'@rollup/rollup-win32-arm64-msvc@4.35.0':
optional: true
'@rollup/rollup-win32-ia32-msvc@4.35.0':
optional: true
'@rollup/rollup-win32-x64-msvc@4.35.0':
optional: true
'@types/estree@1.0.6': {}
'@types/node@22.13.10':
dependencies:
undici-types: 6.20.0
'@types/resolve@1.20.2': {}
base64-js@1.5.1: {}
buffer@6.0.3:
dependencies:
base64-js: 1.5.1
ieee754: 1.2.1
cacheable@1.8.9:
dependencies:
hookified: 1.8.1
keyv: 5.3.2
debug@4.4.0:
dependencies:
ms: 2.1.3
deepmerge@4.3.1: {}
es-module-lexer@1.6.0: {}
esbuild@0.25.1:
optionalDependencies:
'@esbuild/aix-ppc64': 0.25.1
'@esbuild/android-arm': 0.25.1
'@esbuild/android-arm64': 0.25.1
'@esbuild/android-x64': 0.25.1
'@esbuild/darwin-arm64': 0.25.1
'@esbuild/darwin-x64': 0.25.1
'@esbuild/freebsd-arm64': 0.25.1
'@esbuild/freebsd-x64': 0.25.1
'@esbuild/linux-arm': 0.25.1
'@esbuild/linux-arm64': 0.25.1
'@esbuild/linux-ia32': 0.25.1
'@esbuild/linux-loong64': 0.25.1
'@esbuild/linux-mips64el': 0.25.1
'@esbuild/linux-ppc64': 0.25.1
'@esbuild/linux-riscv64': 0.25.1
'@esbuild/linux-s390x': 0.25.1
'@esbuild/linux-x64': 0.25.1
'@esbuild/netbsd-arm64': 0.25.1
'@esbuild/netbsd-x64': 0.25.1
'@esbuild/openbsd-arm64': 0.25.1
'@esbuild/openbsd-x64': 0.25.1
'@esbuild/sunos-x64': 0.25.1
'@esbuild/win32-arm64': 0.25.1
'@esbuild/win32-ia32': 0.25.1
'@esbuild/win32-x64': 0.25.1
estree-walker@2.0.2: {}
eventemitter3@5.0.1: {}
fsevents@2.3.3:
optional: true
function-bind@1.1.2: {}
get-tsconfig@4.10.0:
dependencies:
resolve-pkg-maps: 1.0.0
hasown@2.0.2:
dependencies:
function-bind: 1.1.2
hookified@1.8.1: {}
ieee754@1.2.1: {}
is-core-module@2.16.1:
dependencies:
hasown: 2.0.2
is-module@1.0.0: {}
js-tokens@4.0.0:
optional: true
keyv@5.3.2:
dependencies:
'@keyv/serialize': 1.0.3
magic-string@0.30.17:
dependencies:
'@jridgewell/sourcemap-codec': 1.5.0
ms@2.1.3: {}
nanoid@3.3.10: {}
path-parse@1.0.7: {}
pathe@2.0.3: {}
picocolors@1.1.1: {}
picomatch@4.0.2: {}
postcss@8.5.3:
dependencies:
nanoid: 3.3.10
picocolors: 1.1.1
source-map-js: 1.2.1
resolve-pkg-maps@1.0.0: {}
resolve@1.22.10:
dependencies:
is-core-module: 2.16.1
path-parse: 1.0.7
supports-preserve-symlinks-flag: 1.0.0
rollup-plugin-dts@6.1.1(rollup@4.35.0)(typescript@5.8.2):
dependencies:
magic-string: 0.30.17
rollup: 4.35.0
typescript: 5.8.2
optionalDependencies:
'@babel/code-frame': 7.26.2
rollup-plugin-esbuild@6.2.1(esbuild@0.25.1)(rollup@4.35.0):
dependencies:
debug: 4.4.0
es-module-lexer: 1.6.0
esbuild: 0.25.1
get-tsconfig: 4.10.0
rollup: 4.35.0
unplugin-utils: 0.2.4
transitivePeerDependencies:
- supports-color
rollup@4.35.0:
dependencies:
'@types/estree': 1.0.6
optionalDependencies:
'@rollup/rollup-android-arm-eabi': 4.35.0
'@rollup/rollup-android-arm64': 4.35.0
'@rollup/rollup-darwin-arm64': 4.35.0
'@rollup/rollup-darwin-x64': 4.35.0
'@rollup/rollup-freebsd-arm64': 4.35.0
'@rollup/rollup-freebsd-x64': 4.35.0
'@rollup/rollup-linux-arm-gnueabihf': 4.35.0
'@rollup/rollup-linux-arm-musleabihf': 4.35.0
'@rollup/rollup-linux-arm64-gnu': 4.35.0
'@rollup/rollup-linux-arm64-musl': 4.35.0
'@rollup/rollup-linux-loongarch64-gnu': 4.35.0
'@rollup/rollup-linux-powerpc64le-gnu': 4.35.0
'@rollup/rollup-linux-riscv64-gnu': 4.35.0
'@rollup/rollup-linux-s390x-gnu': 4.35.0
'@rollup/rollup-linux-x64-gnu': 4.35.0
'@rollup/rollup-linux-x64-musl': 4.35.0
'@rollup/rollup-win32-arm64-msvc': 4.35.0
'@rollup/rollup-win32-ia32-msvc': 4.35.0
'@rollup/rollup-win32-x64-msvc': 4.35.0
fsevents: 2.3.3
source-map-js@1.2.1: {}
supports-preserve-symlinks-flag@1.0.0: {}
turbo-darwin-64@2.4.4:
optional: true
turbo-darwin-arm64@2.4.4:
optional: true
turbo-linux-64@2.4.4:
optional: true
turbo-linux-arm64@2.4.4:
optional: true
turbo-windows-64@2.4.4:
optional: true
turbo-windows-arm64@2.4.4:
optional: true
turbo@2.4.4:
optionalDependencies:
turbo-darwin-64: 2.4.4
turbo-darwin-arm64: 2.4.4
turbo-linux-64: 2.4.4
turbo-linux-arm64: 2.4.4
turbo-windows-64: 2.4.4
turbo-windows-arm64: 2.4.4
typescript@5.8.2: {}
undici-types@6.20.0: {}
unplugin-utils@0.2.4:
dependencies:
pathe: 2.0.3
picomatch: 4.0.2
vite@6.2.2(@types/node@22.13.10):
dependencies:
esbuild: 0.25.1
postcss: 8.5.3
rollup: 4.35.0
optionalDependencies:
'@types/node': 22.13.10
fsevents: 2.3.3

3
pnpm-workspace.yaml Normal file
View File

@ -0,0 +1,3 @@
packages:
- 'tojs'
- 'sw'

0
rollup.config.js Normal file
View File

5
src/index.ts Normal file
View File

@ -0,0 +1,5 @@
import { toJs } from '@kevisual/tojs';
export const genJs = () => {
console.log('genJs');
};

106
sw/index.html Normal file
View File

@ -0,0 +1,106 @@
<html>
<head>
<title>Service Worker</title>
</head>
<body>
<script>
window.clearSW = () => {
navigator.serviceWorker.getRegistrations().then((registrations) => {
registrations.forEach((registration) => {
registration.unregister();
});
});
}
</script>
<script>
if ('serviceWorker' in navigator) {
window.addEventListener('load', () => {
navigator.serviceWorker.register('./sw.js')
.then(registration => {
console.log('Service Worker registered with scope:', registration.scope);
// 检查是否有新版本的 Service Worker
checkForNewVersion(registration);
})
.catch(error => {
console.error('Service Worker registration failed:', error);
});
});
}
function checkForNewVersion(registration) {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
console.log('A new version is being installed:', installingWorker);
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
console.log('New content is available; please refresh.');
// 显示一个提示给用户,告知他们有新版本可用
showUpdateNotification();
} else {
console.log('Content is cached for offline use.');
}
}
};
};
}
function showUpdateNotification() {
// 显示一个通知给用户,告知他们有新版本可用
if (document.hasFocus()) {
// 如果页面已经聚焦,直接显示通知
alert('New content is available; please refresh.');
window.location.reload();
} else {
// 如果页面没有聚焦,可以使用 Notification API
if (Notification.permission === 'granted') {
new Notification('New content is available; please refresh.');
} else if (Notification.permission !== 'denied') {
Notification.requestPermission().then(permission => {
if (permission === 'granted') {
new Notification('New content is available; please refresh.');
}
});
}
}
}
</script>
<script>
// fetch('/api/s1/sw/js/123.js')
// .then(res => res.text())
// .then(text => {
// console.log('text', text);
// });
// fetch('/api/s1/sw/js/123.js', {
// method: 'POST',
// body: JSON.stringify({
// a: 1,
// }),
// })
// .then(res => res.text())
// .then(text => {
// console.log('text', text);
// });
</script>
<script type="module">
const url = new URL('/api/s1/sw/js/123.js', window.location.origin);
import(url).then(res => {
console.log('res', res);
});
// import(url).then(res => {
// console.log('res2', res);
// });
fetch(url).then(res => {
console.log('res3', res);
});
fetch(url).then(res => {
console.log('res4', res);
});
</script>
</body>
</html>

17
sw/package.json Normal file
View File

@ -0,0 +1,17 @@
{
"name": "sw",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.6.2",
"type": "module",
"devDependencies": {
"vite": "^6.2.2"
}
}

53
sw/public/sw.js Normal file
View File

@ -0,0 +1,53 @@
async function readStream(stream) {
const reader = stream.getReader();
let result = '';
while (true) {
const { done, value } = await reader.read();
if (done) {
break;
}
result += new TextDecoder().decode(value);
}
return result;
}
self.addEventListener('fetch', async (event) => {
const url = new URL(event.request.url);
// Check if the request is for the specific path
if (url.pathname.startsWith('/api/s1/sw/js/')) {
console.log('event', event);
console.log('url', url, event.request.method, 'mode', event.request.mode, event.request.destination);
// const body = event.request.body;
// const method = event.request.method;
// const bodyText = await readStream(body);
// console.log('body', bodyText);
console.log('event.request', event.request.destination);
event.respondWith(
new Response('export const a = 1', {
status: 200,
headers: {
'Content-Type': 'application/javascript',
},
}),
);
return;
}
if (url.pathname.startsWith('/api/s1/sw/js/')) {
event.respondWith(
fetch(event.request).then((response) => {
// Clone the response to modify headers
const newHeaders = new Headers(response.headers);
newHeaders.set('Content-Type', 'application/javascript');
// Return a new response with the modified headers
return new Response(response.body, {
status: response.status,
statusText: response.statusText,
headers: newHeaders,
});
}),
);
}
});

2
tojs/.npmrc Normal file
View File

@ -0,0 +1,2 @@
//npm.xiongxiao.me/:_authToken=${ME_NPM_TOKEN}
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

12
tojs/README.md Normal file
View File

@ -0,0 +1,12 @@
# tojs
把一些ts和js文件转为import可以使用的js文件
浏览器请求的时候返回对应的cache。
## 使用
```ts
import { toJs } from '@kevisual/tojs';
```

36
tojs/package.json Normal file
View File

@ -0,0 +1,36 @@
{
"name": "@kevisual/tojs",
"version": "0.0.5",
"description": "generate js from other js code",
"scripts": {
"build": "rollup -c",
"watch": "rollup -c -w"
},
"keywords": [],
"author": "abearxiong <xiongxiao@xiongxiao.me> (https://www.xiongxiao.me)",
"license": "MIT",
"packageManager": "pnpm@10.6.2",
"type": "module",
"publishConfig": {
"access": "public"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^16.0.1",
"@types/node": "^22.13.10",
"rollup": "^4.35.0",
"rollup-plugin-dts": "^6.1.1",
"rollup-plugin-esbuild": "^6.2.1",
"typescript": "^5.8.2"
},
"files": [
"dist"
],
"exports": {
".": "./dist/tojs.js"
},
"dependencies": {
"@cacheable/node-cache": "^1.5.3",
"@kevisual/use-config": "^1.0.9",
"cacheable": "^1.8.9"
}
}

32
tojs/rollup.config.js Normal file
View File

@ -0,0 +1,32 @@
// rollup.config.js
import esbuild from 'rollup-plugin-esbuild';
import resolve from '@rollup/plugin-node-resolve';
import { dts } from 'rollup-plugin-dts';
/**
* @type {import('rollup').RollupOptions}
*/
export default [
{
input: 'src/index.ts', // TypeScript 入口文件
output: {
file: 'dist/tojs.js', // 输出文件
format: 'es', // 输出格式设置为 ES 模块
},
plugins: [
resolve(), // 使用 @rollup/plugin-node-resolve 解析 node_modules 中的模块
esbuild({
sourcemap: true,
minify: false,
}),
],
},
{
input: 'src/index.ts', // TypeScript 入口文件
output: {
file: 'dist/tojs.d.ts', // 输出文件
format: 'es', // 输出格式设置为 ES 模块
},
plugins: [dts()],
},
];

8
tojs/src/core.ts Normal file
View File

@ -0,0 +1,8 @@
export class ToJs {
constructor(private readonly code: string) {}
public toJs() {
return this.code;
}
}

View File

@ -0,0 +1,29 @@
import * as http from 'http';
import url from 'url';
export const parseBody = async (req: http.IncomingMessage) => {
return new Promise((resolve, reject) => {
const arr: any[] = [];
req.on('data', (chunk) => {
arr.push(chunk);
});
req.on('end', () => {
try {
if (arr.length === 0) {
resolve({});
return;
}
const body = Buffer.concat(arr).toString();
resolve(JSON.parse(body));
} catch (e) {
console.error('parse body error', e);
resolve({});
}
});
});
};
export const parseSearch = (req: http.IncomingMessage) => {
const parsedUrl = url.parse(req.url, true);
return parsedUrl.query;
};

66
tojs/src/http/res.ts Normal file
View File

@ -0,0 +1,66 @@
import { IncomingMessage, ServerResponse } from 'http';
// import { parseBody, parseSearch } from './parse-body.ts';
// import { useContextKey } from '@kevisual/use-config/context';
import { CacheableMemory } from 'cacheable';
// const cache = useContextKey(
// 'cache',
// () =>
// new NodeCacheStore({
// ttl: 5 * 60, // 5 minutes
// }),
// );
const cache = new CacheableMemory({
ttl: 5 * 60, // 5 minutes
});
console.log('cache init');
type Context = {
req: IncomingMessage;
res: ServerResponse;
query?: any;
};
export const returnOriginalJs = async (
ctx: Context,
opts?: {
prefixUrl: string;
},
) => {
const { req, res, query } = ctx;
const prefixUrl = opts?.prefixUrl || '/';
const method = req.method;
const url = new URL(req.url, 'http://localhost');
const pathname = url.pathname;
const cacheKey = pathname.replace(prefixUrl, '');
console.log('keys', cache.keys);
if (method === 'GET') {
let cachedCode = await cache.get(cacheKey);
if (!cachedCode) {
let code = decodeURIComponent((query?.urlCode as string) || '');
if (code) {
await cache.set(cacheKey, code);
cachedCode = code;
}
}
if (cachedCode) {
res.setHeader('Cache-Control', 'public, max-age=43200'); // 12小时
res.setHeader('Content-Type', 'application/javascript');
res.end(cachedCode);
} else {
res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end('Resource not found');
}
return;
}
let code = decodeURIComponent((query?.urlCode as string) || '');
if (!code) {
code = query.code; // body code;
}
res.writeHead(200, { 'Content-Type': 'application/json' });
if (code) {
await cache.set(cacheKey, code);
res.end(JSON.stringify({ code: 200, message: 'success' }));
} else {
res.end(JSON.stringify({ code: 500, message: 'code is required' }));
}
};

4
tojs/src/index.ts Normal file
View File

@ -0,0 +1,4 @@
import { returnOriginalJs } from './http/res.ts';
import { parseBody, parseSearch } from './http/parse-body.ts';
export { returnOriginalJs, parseBody, parseSearch };

36
tojs/tsconfig.json Normal file
View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "esnext",
"noImplicitAny": false,
"outDir": "./dist",
"sourceMap": false,
"allowJs": true,
"newLine": "LF",
"baseUrl": "./",
"declaration": false,
"typeRoots": [
"node_modules/@types",
],
"noEmit": true,
"allowImportingTsExtensions": true,
"moduleResolution": "NodeNext",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"paths": {
"@/*": [
"src/*"
],
"*": [
"types/*"
]
}
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
]
}

36
tsconfig.json Normal file
View File

@ -0,0 +1,36 @@
{
"compilerOptions": {
"module": "NodeNext",
"target": "esnext",
"noImplicitAny": false,
"outDir": "./dist",
"sourceMap": false,
"allowJs": true,
"newLine": "LF",
"baseUrl": "./",
"declaration": false,
"typeRoots": [
"node_modules/@types",
],
"noEmit": true,
"allowImportingTsExtensions": true,
"moduleResolution": "NodeNext",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"esModuleInterop": true,
"paths": {
"@/*": [
"src/*"
],
"*": [
"types/*"
]
}
},
"include": [
"src/**/*.ts"
],
"exclude": [
"node_modules",
]
}