update: ts

This commit is contained in:
Vick Scarlet
2026-07-29 17:03:26 +08:00
parent 1540a5d142
commit 4043fa887a
380 changed files with 4806 additions and 221348 deletions
-2
View File
@@ -1,2 +0,0 @@
node_modules
npm-debug.log
-15
View File
@@ -1,15 +0,0 @@
FROM node:alpine
ENV NPM_CONFIG_LOGLEVEL info
WORKDIR /usr/src/app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 8080
CMD ["yarn", "dev"]
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2021 神戸小鳥
Copyright (c) 2021-2026 神戸小鳥 and 神户小德
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+18 -15
View File
@@ -4,8 +4,8 @@ import { dirname } from 'path'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
import { readFile } from 'fs/promises'
import Life from '../src/modules/life.js'
import $lang from '../src/i18n/zh-cn.js'
import Life from '../srco/modules/life.js'
import $lang from '../srco/i18n/zh-cn.js'
globalThis.$lang = $lang
globalThis.json = async fileName =>
@@ -235,7 +235,7 @@ class App {
this.#talentExtend = localStorage.talentExtend
await this.#life.initial(
dataSet => json(`${this.#language}/${dataSet}`),
json
json,
)
this.output(
`\rLoading Complete.
@@ -244,14 +244,14 @@ class App {
\x1B[4m/remake\x1B[24m
\x1B[4m/help\x1B[24m `,
true
true,
)
$$on('achievement', ({ name }) =>
this.output(`
-------------------------
${name}
-------------------------
`)
`),
)
}
@@ -561,19 +561,19 @@ class App {
if (this.#talentSelected.has(s)) continue
if (this.#talentSelected.size == 3)
return warn(
'你只能选3个天赋。请使用 \x1B[4m/unselect\x1B[24m 取消选择你不想要的天赋'
'你只能选3个天赋。请使用 \x1B[4m/unselect\x1B[24m 取消选择你不想要的天赋',
)
const exclusive = this.#life.exclude(
Array.from(this.#talentSelected).map(({ id }) => id),
s.id
s.id,
)
if (exclusive != null)
for (const { name, id } of this.#talentSelected)
if (id == exclusive)
return warn(
`天赋【${s.name}】与已选择的天赋【${name}】冲突`
`天赋【${s.name}】与已选择的天赋【${name}】冲突`,
)
this.#talentSelected.add(s)
@@ -628,8 +628,8 @@ class App {
`grade${talent.grade}b`,
`${check(talent) ? '√' : ' '} ${i} ${talent.name}${
talent.description
}`
)
}`,
),
),
]
.flat()
@@ -645,7 +645,7 @@ class App {
return warn(this.list(), `请选择 3 个天赋`)
this.#step = this.Steps.PROPERTY
this.#life.remake(
Array.from(this.#talentSelected).map(({ id }) => id)
Array.from(this.#talentSelected).map(({ id }) => id),
)
this.#propertyAllocation.total = this.#life.getPropertyPoints()
return this.prop()
@@ -673,7 +673,8 @@ class App {
this.#interval = null
this.#auto = false
} else if (this.#auto) {
this.#interval = setInterval(() => {
this.#interval = setInterval(
() => {
const trajectory = this.next()
if (this.#isEnd && this.#interval) {
clearInterval(this.#interval)
@@ -681,7 +682,9 @@ class App {
}
if (!this.#isEnd) return this.output(`${trajectory}\n`)
return this.output(trajectory, true)
}, Number(this.#auto) || 1000)
},
Number(this.#auto) || 1000,
)
return
}
}
@@ -835,7 +838,7 @@ class App {
return this.prop()
case this.Steps.SUMMARY:
this.#talentExtend = Array.from(this.#talentSelected).sort(
() => Math.random() - 0.5
() => Math.random() - 0.5,
)[0].id
return this.list()
}
@@ -847,7 +850,7 @@ class App {
const { judge, grade, value } = summaryData[type]
return this.style(
`grade${grade}b`,
`${name}${value} ${$lang[judge]}`
`${name}${value} ${$lang[judge]}`,
)
}
+14
View File
@@ -0,0 +1,14 @@
{
"name": "@remake/console",
"type": "module",
"version": "3.0.0",
"author": "Vick Scarlet <vick@syaro.io>",
"scripts": {
"start": "bun run src/index.ts",
"lint": "eslint .",
"test": "bun test"
},
"dependencies": {
"@remake/core": "workspace:*"
}
}
+32
View File
@@ -0,0 +1,32 @@
{
"compilerOptions": {
// Environment setup & latest features
"lib": ["ESNext"],
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"types": ["bun"],
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"paths": {
"@/*": ["./src/*"],
},
// Some stricter flags (disabled by default)
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitAny": true
},
"include": ["**/*"]
}
+25
View File
@@ -0,0 +1,25 @@
import { defineConfig } from 'eslint/config'
// @ts-ignore
import preact from 'eslint-config-preact'
import defaultConfig from '../../eslint.config.ts'
export default defineConfig([
defaultConfig,
{
files: ['**/*.{js,jsx,ts,tsx}'],
plugins: { ...preact.plugins },
rules: { ...preact.rules },
settings: { ...preact.settings },
languageOptions: {
sourceType: 'module',
ecmaVersion: 'latest',
parserOptions: {
...preact.parserOptions,
ecmaFeatures: {
jsx: true,
...preact.parserOptions?.ecmaFeatures,
},
},
},
},
])
+26
View File
@@ -0,0 +1,26 @@
{
"name": "@remake/web",
"type": "module",
"version": "3.0.0",
"author": "Vick Scarlet <vick@syaro.io>",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview",
"lint": "eslint",
"test": "vitest"
},
"dependencies": {
"preact": "^10.26.9",
"@remake/core": "workspace:*"
},
"devDependencies": {
"@preact/preset-vite": "^2.10.2",
"eslint-config-preact": "^2.0.0",
"vite": "^8.1.3",
"vitest": "^4.1.10"
},
"eslintConfig": {
"extends": "preact"
}
}
+6
View File
@@ -0,0 +1,6 @@
import { render } from 'preact'
export function App() {
return <div>Hello</div>
}
render(<App />, document.getElementById('app')!)
+39
View File
@@ -0,0 +1,39 @@
{
"compilerOptions": {
// Environment setup & latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "Preserve",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
"types": ["preact"],
// Bundler mode
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
// Best practices
"strict": true,
"skipLibCheck": true,
"noFallthroughCasesInSwitch": true,
"noUncheckedIndexedAccess": true,
"noImplicitOverride": true,
"jsxImportSource": "preact",
"paths": {
"@/*": ["./src/*"],
"@assets/*": ["./assets/*"],
"react": ["./node_modules/preact/compat/"],
"react-dom": ["./node_modules/preact/compat/"]
},
// Some stricter flags (disabled by default)
"noUnusedLocals": true,
"noUnusedParameters": true,
"noPropertyAccessFromIndexSignature": false,
"noImplicitAny": true
},
"include": ["node_modules/vite/client.d.ts", "**/*"]
}
+7
View File
@@ -0,0 +1,7 @@
import { defineConfig } from 'vite'
import preact from '@preact/preset-vite'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [preact()],
})
-180
View File
@@ -1,180 +0,0 @@
颜值: <input class="prop" name="CHR" style="width:300px;" value="5" >(CHR)<br/>
智力: <input class="prop" name="INT" style="width:300px;" value="5" >(INT)<br/>
体质: <input class="prop" name="STR" style="width:300px;" value="5" >(STR)<br/>
家境: <input class="prop" name="MNY" style="width:300px;" value="5" >(MNY)<br/>
快乐: <input class="prop" name="SPR" style="width:300px;" value="5" >(SPR)<br/>
生命: <input class="prop" name="LIF" style="width:300px;" value="5" >(LIF)<br/>
天赋: <input class="prop" name="TLT" style="width:300px;" value="[5]" >(TLT)<br/>
事件: <input class="prop" name="EVT" style="width:300px;" value="[5]" >(EVT)<br/>
<br/><br/>
表达式:<input id="conditions" style="width:500px;"><br/><br/>
结果:<span id="result" style="color:red;"></span><br/><br/>
<button id="submit">&nbsp;&nbsp;&nbsp;&nbsp;</button><br/>
<script>
const DEFAULT_PROP = {
CHR: 5, // 颜值 charm CHR
INT: 5, // 智力 intelligence INT
STR: 5, // 体质 strength STR
MNY: 5, // 家境 money MNY
SPR: 5, // 快乐 spirit SPR
LIF: 5, // 生命 life LIF
TLT: [5], // 天赋 talent TLT
EVT: [5], // 事件 event EVT
};
document.querySelector("#submit").onclick = function() {
document.querySelectorAll('.prop').forEach(({name, value})=>DEFAULT_PROP[name] = JSON.parse(value));
conditions = document.querySelector("#conditions").value;
const result = check(conditions);
document.querySelector("#result").textContent = result;
}
function getProp(prop) {
switch(prop) {
case 'CHR':
case 'INT':
case 'STR':
case 'MNY':
case 'SPR':
case 'LIF':
case 'TLT':
case 'EVT': return DEFAULT_PROP[prop];
default: return null;
}
}
function check(condition) {
const conditions = parseCondition(condition);
return checkParsedCondition(conditions);
}
function checkParsedCondition(conditions) {
if(!Array.isArray(conditions)) return checkLogic(conditions);
if(conditions.length == 0) return true;
if(conditions.length == 1) return checkParsedCondition(conditions[0]);
let ret = checkParsedCondition(conditions[0]);
for(let i=1; i<conditions.length; i+=2) {
switch(conditions[i]) {
case '&':
if(ret) ret = checkParsedCondition(conditions[i+1]);
break;
case '|':
if(ret) return true;
ret = checkParsedCondition(conditions[i+1]);
break;
default: return false;
}
}
return ret;
}
function checkLogic(condition) {
const length = condition.length;
let i = condition.search(/[><\!\?=]/);
const prop = condition.substring(0,i);
const symbol = condition.substring(i, i+=(condition[i+1]=='='?2:1));
const d = condition.substring(i, length);
const propData = getProp(prop);
const conditionData = d[0]=='['? JSON.parse(d): Number(d);
switch(symbol) {
case '>': return propData > conditionData;
case '<': return propData < conditionData;
case '>=': return propData >= conditionData;
case '<=': return propData <= conditionData;
case '=':
if(Array.isArray(propData))
return propData.includes(conditionData);
return propData == conditionData;
case '!=':
if(Array.isArray(propData))
return !propData.includes(conditionData);
return propData == conditionData;
case '?':
if(Array.isArray(propData)) {
for(const p of propData)
if(conditionData.includes(p)) return true;
return false;
}
return conditionData.includes(propData);
case '!':
if(Array.isArray(propData)) {
for(const p of propData)
if(conditionData.includes(p)) return false;
return true;
}
return !conditionData.includes(propData);
default: return false;
}
}
function parseCondition(condition) {
const conditions = [];
const length = condition.length;
const stack = [];
stack.unshift(conditions);
let cursor = 0;
const catchString = i => {
const str = condition.substring(cursor, i).trim();
cursor = i;
if(str) stack[0].push(str);
};
for(let i=0; i<length; i++) {
switch(condition[i]) {
case ' ': continue;
case '(':
catchString(i);
cursor ++;
const sub = [];
stack[0].push(sub);
stack.unshift(sub);
break;
case ')':
catchString(i);
cursor ++;
stack.shift();
break;
case '|':
case '&':
catchString(i);
catchString(i+1);
break;
default: continue;
}
}
catchString(length);
return conditions;
}
// function debug(...conditions) {
// for(const condition of conditions)
// console.debug(check(condition), '\t', condition);
// }
//
// debug(
// '(STR<2&MNY>3)|(MNY<2&CHR<2)',
// '(STR<2&MNY>3)',
// '(STR>2&MNY>3)',
// '((((STR>2&MNY>2))))',
// '((((STR>2&MNY>2)|(MNY<2&CHR<2))))',
// '((((STR>2&MNY>2)|(MNY<2&CHR<2)&(STR>2&MNY>3))))',
// '((((STR>2&MNY>2)|(MNY<2&CHR<2))&(STR>2&MNY>3)))',
// 'EVT![1,2,3]',
// 'EVT![1,2]',
// 'EVT?[1,2,3]',
// 'EVT?[1,2]',
// );
</script>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 37 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 434 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 237 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 110 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 135 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 751 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 143 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 276 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 128 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 186 KiB

+23
View File
@@ -0,0 +1,23 @@
import { defineConfig } from 'eslint/config'
import parser from '@typescript-eslint/parser'
import plugin from '@typescript-eslint/eslint-plugin'
export default defineConfig([
{
ignores: ['dist/**', 'node_modules/**'],
files: ['**/*.{js,jsx,ts,tsx}'],
},
{
files: ['**/*.{ts,tsx}'],
languageOptions: {
parser,
parserOptions: {
ecmaFeatures: {
jsx: true,
},
},
},
// @ts-ignore
plugins: { '@typescript-eslint': plugin },
},
])
+8 -22
View File
@@ -1,28 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=2.0,user-scalable=yes">
<meta name="description" content="やり直すんだ。そして、次はうまくやる。"/>
<meta name="description" content="人生重开模拟器 - 这垃圾人生一秒也不想待了"/>
<meta name="keywords" content="人生重开模拟器 liferestart life restart remake 人生重来"/>
<meta name="renderer" content="webkit"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="full-screen" content="true"/>
<meta name="x5-fullscreen" content="true"/>
<meta name="360-fullscreen" content="true"/>
<meta name="theme-color" content="#157878"/>
<meta name="laya" screenorientation ="landscape"/>
<meta http-equiv="expires" content="0"/>
<meta http-equiv="Cache-Control" content="no-siteapp"/>
<title>Life Restart</title>
<script type="text/javascript" src="libs/laya/min/laya.core.min.js"></script>
<script type="text/javascript" src="libs/laya/min/laya.webgl.min.js"></script>
<script type="text/javascript" src="libs/laya/min/laya.filter.min.js"></script>
<script type="text/javascript" src="libs/laya/min/laya.particle.min.js"></script>
<script type="text/javascript" src="libs/laya/min/laya.ui.min.js"></script>
<script type="module" src="public/channel.js"></script>
<script type="module" src="src/index.js"></script>
<meta name="color-scheme" content="light dark" />
<title>人生重开模拟器</title>
</head>
<body style="background:black"></body>
<body>
<div id="app"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
-10
View File
@@ -1,10 +0,0 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=759670
// for the documentation about the jsconfig.json format
"compilerOptions": {
"module": "esnext",
"target": "es6",
},
"include":["src", "repl", "vite.config.js"],
"exclude": ["node_modules", "public", "view"]
}
-37
View File
@@ -1,37 +0,0 @@
<project version="0.9.8">
<asynRes>img,temp,sound </asynRes>
<unDealRes>embed </unDealRes>
<resTypes>png,jpg </resTypes>
<resExportPath>public/images/atlas </resExportPath>
<asynResExportPath>public </asynResExportPath>
<codeExportPath>src/ui </codeExportPath>
<codeImports><![CDATA[import laya.ui.*;
import laya.display.*; ]]> </codeImports>
<codeImportsJS><![CDATA[var View=laya.ui.View;
var Dialog=laya.ui.Dialog;]]> </codeImportsJS>
<uiType>0 </uiType>
<uiExportPath>public/ui.json </uiExportPath>
<boxTypes>Box,List,Tab,RadioGroup,ViewStack,Panel,HBox,VBox,Tree,Sprite </boxTypes>
<pageTypes>View,Dialog </pageTypes>
<shareResPath/>
<codeType>2 </codeType>
<resCanCompress/>
<resPublishQuality>80 </resPublishQuality>
<langPath/>
<defaultFont/>
<codeImportsTS><![CDATA[import View=laya.ui.View;
import Dialog=laya.ui.Dialog;]]> </codeImportsTS>
<textureWidth>2048 </textureWidth>
<textureHeight>2048 </textureHeight>
<picWidth>512 </picWidth>
<picHeight>512 </picHeight>
<power2>false </power2>
<trimempty>false </trimempty>
<codeViewExportPath>src/view </codeViewExportPath>
<picType>0 </picType>
<atlasType>1 </atlasType>
<atlasScale/>
<copyRes>true </copyRes>
<dataCompact>true </dataCompact>
<ver>0.9.9 beta </ver>
</project>
Binary file not shown.
Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 195 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 208 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 502 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

Some files were not shown because too many files have changed in this diff Show More