@yyyu-star/arcade-kit 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +21 -0
- package/README.md +81 -5
- package/dist/fun-logic.d.ts +184 -0
- package/dist/fun-logic.d.ts.map +1 -0
- package/dist/fun-logic.js +249 -0
- package/dist/fun-logic.js.map +1 -0
- package/dist/fun.d.ts +1 -13
- package/dist/fun.d.ts.map +1 -1
- package/dist/fun.js +3 -2
- package/dist/fun.js.map +1 -1
- package/dist/table-fun.d.ts +152 -0
- package/dist/table-fun.d.ts.map +1 -0
- package/dist/table-fun.js +652 -0
- package/dist/table-fun.js.map +1 -0
- package/dist/worker.d.ts +6 -3
- package/dist/worker.d.ts.map +1 -1
- package/dist/worker.js +11 -4
- package/dist/worker.js.map +1 -1
- package/package.json +9 -1
- package/src/fun-logic.ts +351 -0
- package/src/fun.ts +3 -2
- package/src/table-fun.ts +713 -0
- package/src/worker.ts +9 -4
package/src/worker.ts
CHANGED
|
@@ -188,13 +188,18 @@ export async function loginGate(request: Request, env: GateEnv, opts: LoginGateO
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
|
-
*
|
|
192
|
-
*
|
|
193
|
-
*
|
|
191
|
+
* 独立部署时站点根上本该归平台的两个路径(0.10.0;`/api/me` 0.10.2)。只在独立模式下回话,其余回 null,游戏接着走自己的路由:
|
|
192
|
+
* - `/`:游戏挂在 `/games/<id>/`,单独部署到 workers.dev 时有人直接打开 `/`,302 到游戏首页(查询参数原样带上);
|
|
193
|
+
* - `/api/me`:页面的 `detectPlatform` 开局问一次。回 200 `{ standalone: true }`(没有 `user`,认作没有平台),
|
|
194
|
+
* 不让它落到静态资源回 404:404 在浏览器控制台每次都是一条红的资源加载错误。
|
|
195
|
+
* 两个路径都要先过 Worker:把 "/"、"/api/me" 加进 wrangler.jsonc 的 `assets.run_worker_first`。
|
|
196
|
+
* 本站部署时它们由平台的路由接,到不了游戏 Worker;就算到了,有平台绑定时这里也回 null
|
|
194
197
|
*/
|
|
195
198
|
export function standaloneRoot(request: Request, env: ModeEnv, gameId: string): Response | null {
|
|
196
199
|
const url = new URL(request.url);
|
|
197
|
-
if (!isStandalone(env) ||
|
|
200
|
+
if (!isStandalone(env) || !/^[a-z0-9-]+$/.test(gameId)) return null;
|
|
201
|
+
if (url.pathname === '/api/me') return Response.json({ standalone: true }, { headers: { 'cache-control': 'no-store' } });
|
|
202
|
+
if (url.pathname !== '/') return null;
|
|
198
203
|
return new Response(null, { status: 302, headers: { location: `/games/${gameId}/${url.search}`, 'cache-control': 'no-store' } });
|
|
199
204
|
}
|
|
200
205
|
|