fix: global route interceptor
This commit is contained in:
parent
33c45c7cc5
commit
12b538a6ab
5 changed files with 22 additions and 29 deletions
24
package-lock.json
generated
24
package-lock.json
generated
|
@ -1134,9 +1134,9 @@
|
||||||
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
|
"integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q=="
|
||||||
},
|
},
|
||||||
"node_modules/acorn": {
|
"node_modules/acorn": {
|
||||||
"version": "8.11.0",
|
"version": "8.11.2",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.11.2.tgz",
|
||||||
"integrity": "sha512-hNiSyky+cuYVALBrsjB7f9gMN9P4u09JyAiMNMLaVfsmkDJuH84M1T/0pfDX/OJfGWcobd2A7ecXYzygn8wibA==",
|
"integrity": "sha512-nc0Axzp/0FILLEVsm4fNwLCwMttvhEI263QtVPQcbpfZZ3ts0hLsZGOpE6czNlid7CJ9MlyH8reXkpsf3YUY4w==",
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
|
@ -2659,9 +2659,9 @@
|
||||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||||
},
|
},
|
||||||
"node_modules/nitropack": {
|
"node_modules/nitropack": {
|
||||||
"version": "2.7.0",
|
"version": "2.7.2",
|
||||||
"resolved": "https://registry.npmjs.org/nitropack/-/nitropack-2.7.0.tgz",
|
"resolved": "https://registry.npmjs.org/nitropack/-/nitropack-2.7.2.tgz",
|
||||||
"integrity": "sha512-U5/Uq0k4PO3/yDM1Sao6JZc/i1DhiI2Eq/AMm92idgQ6B3NbwD0A3u9SZNIHyqEyFogOgi3qsdnRo9KWc5jgVg==",
|
"integrity": "sha512-6vQbGdBNR20N8wTChzIQUZQmNVhWVDrjUdpOYD68u2hlyUiJembth2fQuoWw3KlsoNYWFvcyqL9X3DPjjnoEUQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cloudflare/kv-asset-handler": "^0.3.0",
|
"@cloudflare/kv-asset-handler": "^0.3.0",
|
||||||
"@netlify/functions": "^2.3.0",
|
"@netlify/functions": "^2.3.0",
|
||||||
|
@ -2683,8 +2683,8 @@
|
||||||
"citty": "^0.1.4",
|
"citty": "^0.1.4",
|
||||||
"consola": "^3.2.3",
|
"consola": "^3.2.3",
|
||||||
"cookie-es": "^1.0.0",
|
"cookie-es": "^1.0.0",
|
||||||
"defu": "^6.1.2",
|
"defu": "^6.1.3",
|
||||||
"destr": "^2.0.1",
|
"destr": "^2.0.2",
|
||||||
"dot-prop": "^8.0.2",
|
"dot-prop": "^8.0.2",
|
||||||
"esbuild": "^0.19.5",
|
"esbuild": "^0.19.5",
|
||||||
"escape-string-regexp": "^5.0.0",
|
"escape-string-regexp": "^5.0.0",
|
||||||
|
@ -2704,7 +2704,7 @@
|
||||||
"mime": "^3.0.0",
|
"mime": "^3.0.0",
|
||||||
"mlly": "^1.4.2",
|
"mlly": "^1.4.2",
|
||||||
"mri": "^1.2.0",
|
"mri": "^1.2.0",
|
||||||
"node-fetch-native": "^1.4.0",
|
"node-fetch-native": "^1.4.1",
|
||||||
"ofetch": "^1.3.3",
|
"ofetch": "^1.3.3",
|
||||||
"ohash": "^1.1.3",
|
"ohash": "^1.1.3",
|
||||||
"openapi-typescript": "^6.7.0",
|
"openapi-typescript": "^6.7.0",
|
||||||
|
@ -4031,9 +4031,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"templates/basic/node_modules/@mcflyjs/cli": {
|
"templates/basic/node_modules/@mcflyjs/cli": {
|
||||||
"version": "0.0.12",
|
"version": "0.0.13",
|
||||||
"resolved": "https://registry.npmjs.org/@mcflyjs/cli/-/cli-0.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/@mcflyjs/cli/-/cli-0.0.13.tgz",
|
||||||
"integrity": "sha512-T3owNmdodzHIh4+DkGrenM8IyHtnKi98rwWGMmpBYaO9j5eshxIOm3Mie+tQ/xeQ3oyJFESXu25A38wmHKS2Nw==",
|
"integrity": "sha512-RaFR+PK4HW5ksSkjiQakJ/GLOYh/Vw89VZV897aHWRhDuesuOdYCWKIeny307gNX1SUS2JZmyPeM8bNBpLcsXg==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"citty": "^0.1.4",
|
"citty": "^0.1.4",
|
||||||
"consola": "^3.2.3",
|
"consola": "^3.2.3",
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import { consola } from "consola";
|
import { consola } from "consola";
|
||||||
import { defineCommand } from "citty";
|
import { defineCommand } from "citty";
|
||||||
import { copyFileSync, readFileSync, writeFileSync } from "node:fs";
|
import { appendFileSync, copyFileSync, readFileSync } from "node:fs";
|
||||||
import { createRequire } from "node:module";
|
import { createRequire } from "node:module";
|
||||||
import { execSync as exec } from "child_process";
|
import { execSync as exec } from "child_process";
|
||||||
import { tryCatch } from "../utils/try-catch.mjs";
|
import { tryCatch } from "../utils/try-catch.mjs";
|
||||||
|
@ -26,18 +26,11 @@ export default defineCommand({
|
||||||
`${globalsPath}/globals/mcfly-imports.d.ts`,
|
`${globalsPath}/globals/mcfly-imports.d.ts`,
|
||||||
".nitro/types/mcfly-imports.d.ts"
|
".nitro/types/mcfly-imports.d.ts"
|
||||||
),
|
),
|
||||||
() =>
|
|
||||||
copyFileSync(
|
|
||||||
`${globalsPath}/globals/mcfly.d.ts`,
|
|
||||||
".nitro/types/mcfly.d.ts"
|
|
||||||
),
|
|
||||||
() => {
|
() => {
|
||||||
const path = ".nitro/types/tsconfig.json";
|
const ref = `\n${readFileSync(
|
||||||
const tsconfig = readFileSync(path);
|
`${globalsPath}/globals/mcfly.d.ts`
|
||||||
const configStr = tsconfig.toString();
|
).toString()}`;
|
||||||
const config = JSON.parse(configStr);
|
appendFileSync(".nitro/types/nitro.d.ts", ref);
|
||||||
config.include.push("./mcfly.d.ts");
|
|
||||||
writeFileSync(path, JSON.stringify(config));
|
|
||||||
},
|
},
|
||||||
].map((fn) => () => tryCatch(fn));
|
].map((fn) => () => tryCatch(fn));
|
||||||
|
|
||||||
|
|
5
packages/cli/globals/mcfly-imports.d.ts
vendored
5
packages/cli/globals/mcfly-imports.d.ts
vendored
|
@ -1,6 +1,5 @@
|
||||||
|
import { WebComponent as W } from "web-component-base/WebComponent.mjs";
|
||||||
declare global {
|
declare global {
|
||||||
class WebComponent extends import("web-component-base/WebComponent.mjs") {}
|
class WebComponent extends W {}
|
||||||
const defineRoute: typeof import("@mcflyjs/core/event-handler.mjs").defineRoute;
|
|
||||||
}
|
}
|
||||||
export { WebComponent } from "web-component-base/WebComponent.mjs";
|
export { WebComponent } from "web-component-base/WebComponent.mjs";
|
||||||
export { defineRoute } from "@mcflyjs/core/event-handler.mjs";
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ import { parseScript } from "esprima";
|
||||||
* }} param0
|
* }} param0
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export function defineRoute({ config, storage }) {
|
export function useMcFlyRoute({ config, storage }) {
|
||||||
return eventHandler(async (event) => {
|
return eventHandler(async (event) => {
|
||||||
const { path } = event;
|
const { path } = event;
|
||||||
const { components: componentType } = config();
|
const { components: componentType } = config();
|
||||||
|
|
|
@ -6,5 +6,6 @@
|
||||||
* ...reusable code are in ./src/components
|
* ...reusable code are in ./src/components
|
||||||
* @see https://ayco.io/gh/McFly#special-directories
|
* @see https://ayco.io/gh/McFly#special-directories
|
||||||
*/
|
*/
|
||||||
|
import { useMcFlyRoute } from "@mcflyjs/core/event-handler.mjs";
|
||||||
import config from "../mcfly.config.mjs";
|
import config from "../mcfly.config.mjs";
|
||||||
export default defineRoute({ config, storage: useStorage() });
|
export default useMcFlyRoute({ config, storage: useStorage() });
|
||||||
|
|
Loading…
Reference in a new issue