satset-react 0.4.5 → 0.4.7
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/package.json +2 -3
- package/dist/adapter/index.d.ts +0 -4
- package/dist/adapter/index.d.ts.map +0 -1
- package/dist/adapter/index.js +0 -8
- package/dist/adapter/index.js.map +0 -1
- package/dist/adapter/node.d.ts +0 -3
- package/dist/adapter/node.d.ts.map +0 -1
- package/dist/adapter/node.js +0 -244
- package/dist/adapter/node.js.map +0 -1
- package/dist/adapter/types.d.ts +0 -24
- package/dist/adapter/types.d.ts.map +0 -1
- package/dist/adapter/types.js +0 -3
- package/dist/adapter/types.js.map +0 -1
- package/dist/adapter/vercel.d.ts +0 -10
- package/dist/adapter/vercel.d.ts.map +0 -1
- package/dist/adapter/vercel.js +0 -320
- package/dist/adapter/vercel.js.map +0 -1
- package/dist/assets/favicon.d.ts +0 -2
- package/dist/assets/favicon.d.ts.map +0 -1
- package/dist/assets/favicon.js +0 -67
- package/dist/assets/favicon.js.map +0 -1
- package/dist/assets/index.d.ts +0 -7
- package/dist/assets/index.d.ts.map +0 -1
- package/dist/assets/index.js +0 -31
- package/dist/assets/index.js.map +0 -1
- package/dist/assets/metadata.d.ts +0 -29
- package/dist/assets/metadata.d.ts.map +0 -1
- package/dist/assets/metadata.js +0 -55
- package/dist/assets/metadata.js.map +0 -1
- package/dist/assets/robots.d.ts +0 -23
- package/dist/assets/robots.d.ts.map +0 -1
- package/dist/assets/robots.js +0 -95
- package/dist/assets/robots.js.map +0 -1
- package/dist/assets/sitemap.d.ts +0 -19
- package/dist/assets/sitemap.d.ts.map +0 -1
- package/dist/assets/sitemap.js +0 -78
- package/dist/assets/sitemap.js.map +0 -1
- package/dist/cli/commands.d.ts +0 -5
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -165
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/index.d.ts +0 -3
- package/dist/cli/index.d.ts.map +0 -1
- package/dist/cli/index.js +0 -40
- package/dist/cli/index.js.map +0 -1
- package/dist/components/ErrorBoundary.d.ts +0 -22
- package/dist/components/ErrorBoundary.d.ts.map +0 -1
- package/dist/components/ErrorBoundary.js +0 -61
- package/dist/components/ErrorBoundary.js.map +0 -1
- package/dist/components/Image.d.ts +0 -15
- package/dist/components/Image.d.ts.map +0 -1
- package/dist/components/Image.js +0 -67
- package/dist/components/Image.js.map +0 -1
- package/dist/components/Link.d.ts +0 -14
- package/dist/components/Link.d.ts.map +0 -1
- package/dist/components/Link.js +0 -66
- package/dist/components/Link.js.map +0 -1
- package/dist/components/Script.d.ts +0 -10
- package/dist/components/Script.d.ts.map +0 -1
- package/dist/components/Script.js +0 -60
- package/dist/components/Script.js.map +0 -1
- package/dist/components/index.d.ts +0 -6
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/index.js +0 -30
- package/dist/components/index.js.map +0 -1
- package/dist/components/theme.d.ts +0 -23
- package/dist/components/theme.d.ts.map +0 -1
- package/dist/components/theme.js +0 -118
- package/dist/components/theme.js.map +0 -1
- package/dist/config.d.ts +0 -23
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js +0 -9
- package/dist/config.js.map +0 -1
- package/dist/core/dynamic.d.ts +0 -10
- package/dist/core/dynamic.d.ts.map +0 -1
- package/dist/core/dynamic.js +0 -51
- package/dist/core/dynamic.js.map +0 -1
- package/dist/core/hydrate.d.ts +0 -8
- package/dist/core/hydrate.d.ts.map +0 -1
- package/dist/core/hydrate.js +0 -73
- package/dist/core/hydrate.js.map +0 -1
- package/dist/core/index.d.ts +0 -10
- package/dist/core/index.d.ts.map +0 -1
- package/dist/core/index.js +0 -22
- package/dist/core/index.js.map +0 -1
- package/dist/core/response.d.ts +0 -26
- package/dist/core/response.d.ts.map +0 -1
- package/dist/core/response.js +0 -48
- package/dist/core/response.js.map +0 -1
- package/dist/core/ssr.d.ts +0 -29
- package/dist/core/ssr.d.ts.map +0 -1
- package/dist/core/ssr.js +0 -91
- package/dist/core/ssr.js.map +0 -1
- package/dist/core/translation.d.ts +0 -19
- package/dist/core/translation.d.ts.map +0 -1
- package/dist/core/translation.js +0 -84
- package/dist/core/translation.js.map +0 -1
- package/dist/core/types.d.ts +0 -47
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js +0 -3
- package/dist/core/types.js.map +0 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -25
- package/dist/index.js.map +0 -1
- package/dist/navigation/notFound.d.ts +0 -3
- package/dist/navigation/notFound.d.ts.map +0 -1
- package/dist/navigation/notFound.js +0 -15
- package/dist/navigation/notFound.js.map +0 -1
- package/dist/router/file-system.d.ts +0 -19
- package/dist/router/file-system.d.ts.map +0 -1
- package/dist/router/file-system.js +0 -364
- package/dist/router/file-system.js.map +0 -1
- package/dist/router/index.d.ts +0 -3
- package/dist/router/index.d.ts.map +0 -1
- package/dist/router/index.js +0 -10
- package/dist/router/index.js.map +0 -1
- package/dist/router/router.d.ts +0 -17
- package/dist/router/router.d.ts.map +0 -1
- package/dist/router/router.js +0 -158
- package/dist/router/router.js.map +0 -1
- package/dist/router/types.d.ts +0 -11
- package/dist/router/types.d.ts.map +0 -1
- package/dist/router/types.js +0 -3
- package/dist/router/types.js.map +0 -1
- package/dist/server/build.d.ts +0 -5
- package/dist/server/build.d.ts.map +0 -1
- package/dist/server/build.js +0 -780
- package/dist/server/build.js.map +0 -1
- package/dist/server/bundler.d.ts +0 -28
- package/dist/server/bundler.d.ts.map +0 -1
- package/dist/server/bundler.js +0 -401
- package/dist/server/bundler.js.map +0 -1
- package/dist/server/dev.d.ts +0 -11
- package/dist/server/dev.d.ts.map +0 -1
- package/dist/server/dev.js +0 -1818
- package/dist/server/dev.js.map +0 -1
- package/dist/server/env.d.ts +0 -10
- package/dist/server/env.d.ts.map +0 -1
- package/dist/server/env.js +0 -102
- package/dist/server/env.js.map +0 -1
- package/dist/server/error-overlay.d.ts +0 -12
- package/dist/server/error-overlay.d.ts.map +0 -1
- package/dist/server/error-overlay.js +0 -396
- package/dist/server/error-overlay.js.map +0 -1
- package/dist/server/hmr.d.ts +0 -8
- package/dist/server/hmr.d.ts.map +0 -1
- package/dist/server/hmr.js +0 -166
- package/dist/server/hmr.js.map +0 -1
- package/dist/server/index.d.ts +0 -10
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -25
- package/dist/server/index.js.map +0 -1
- package/dist/server/response.d.ts +0 -30
- package/dist/server/response.d.ts.map +0 -1
- package/dist/server/response.js +0 -238
- package/dist/server/response.js.map +0 -1
- package/dist/server/storage.d.ts +0 -13
- package/dist/server/storage.d.ts.map +0 -1
- package/dist/server/storage.js +0 -26
- package/dist/server/storage.js.map +0 -1
- package/dist/server/tui.d.ts +0 -23
- package/dist/server/tui.d.ts.map +0 -1
- package/dist/server/tui.js +0 -182
- package/dist/server/tui.js.map +0 -1
- package/dist/server/types.d.ts +0 -14
- package/dist/server/types.d.ts.map +0 -1
- package/dist/server/types.js +0 -3
- package/dist/server/types.js.map +0 -1
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
2
|
-
export type Dictionaries = Record<string, Record<string, string>>;
|
|
3
|
-
interface I18nContextType {
|
|
4
|
-
locale: string;
|
|
5
|
-
setLocale: (locale: string) => void;
|
|
6
|
-
t: (key: string, params?: Record<string, string>) => string;
|
|
7
|
-
dictionaries: Dictionaries;
|
|
8
|
-
dict: Record<string, string>;
|
|
9
|
-
}
|
|
10
|
-
interface I18nProviderProps {
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
initialLocale?: string;
|
|
13
|
-
dictionaries: Dictionaries;
|
|
14
|
-
}
|
|
15
|
-
export declare function I18nProvider({ children, initialLocale, dictionaries }: I18nProviderProps): React.JSX.Element;
|
|
16
|
-
export declare function useTranslation(): I18nContextType;
|
|
17
|
-
export declare const useLang: typeof useTranslation;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=translation.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translation.d.ts","sourceRoot":"","sources":["../../src/core/translation.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAkD,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzF,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAElE,UAAU,eAAe;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC;IAC5D,YAAY,EAAE,YAAY,CAAC;IAC3B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAID,UAAU,iBAAiB;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAuB,EAAE,YAAY,EAAE,EAAE,iBAAiB,qBA6ClG;AAED,wBAAgB,cAAc,oBAM7B;AAED,eAAO,MAAM,OAAO,uBAAiB,CAAC"}
|
package/dist/core/translation.js
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.useLang = void 0;
|
|
37
|
-
exports.I18nProvider = I18nProvider;
|
|
38
|
-
exports.useTranslation = useTranslation;
|
|
39
|
-
const react_1 = __importStar(require("react"));
|
|
40
|
-
const I18nContext = (0, react_1.createContext)(null);
|
|
41
|
-
function I18nProvider({ children, initialLocale = 'en-US', dictionaries }) {
|
|
42
|
-
const [locale, setLocale] = (0, react_1.useState)(initialLocale);
|
|
43
|
-
// Sync locale with URL path on client side if not provided or changed
|
|
44
|
-
(0, react_1.useEffect)(() => {
|
|
45
|
-
if (typeof window !== 'undefined') {
|
|
46
|
-
// Priority: 1. window.__SATSET_LOCALE__ (injected by server)
|
|
47
|
-
// 2. URL path segment
|
|
48
|
-
const injected = window.__SATSET_LOCALE__;
|
|
49
|
-
if (injected) {
|
|
50
|
-
setLocale(injected);
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
const path = window.location.pathname;
|
|
54
|
-
const segments = path.split('/').filter(Boolean);
|
|
55
|
-
const first = segments[0];
|
|
56
|
-
// Check if first segment matches a locale pattern (xx or xx-XX)
|
|
57
|
-
if (first && /^[a-zA-Z]{2}(?:-[a-zA-Z]{2})?$/.test(first)) {
|
|
58
|
-
// Check if we have this locale in dictionaries (optional validation)
|
|
59
|
-
// For now, trust the URL or fallback
|
|
60
|
-
setLocale(first);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}, []);
|
|
64
|
-
const dict = dictionaries[locale] || dictionaries['en-US'] || dictionaries[Object.keys(dictionaries)[0]] || {};
|
|
65
|
-
const t = (key, params) => {
|
|
66
|
-
let text = dict[key] || key;
|
|
67
|
-
if (params) {
|
|
68
|
-
Object.entries(params).forEach(([k, v]) => {
|
|
69
|
-
text = text.replace(new RegExp(`{${k}}`, 'g'), v);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return text;
|
|
73
|
-
};
|
|
74
|
-
return (react_1.default.createElement(I18nContext.Provider, { value: { locale, setLocale, t, dictionaries, dict } }, children));
|
|
75
|
-
}
|
|
76
|
-
function useTranslation() {
|
|
77
|
-
const context = (0, react_1.useContext)(I18nContext);
|
|
78
|
-
if (!context) {
|
|
79
|
-
throw new Error('useTranslation must be used within an I18nProvider. The framework should wrap your app automatically.');
|
|
80
|
-
}
|
|
81
|
-
return context;
|
|
82
|
-
}
|
|
83
|
-
exports.useLang = useTranslation;
|
|
84
|
-
//# sourceMappingURL=translation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"translation.js","sourceRoot":"","sources":["../../src/core/translation.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoBA,oCA6CC;AAED,wCAMC;AAzED,+CAAyF;AAYzF,MAAM,WAAW,GAAG,IAAA,qBAAa,EAAyB,IAAI,CAAC,CAAC;AAQhE,SAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,EAAE,YAAY,EAAqB;IACjG,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAA,gBAAQ,EAAC,aAAa,CAAC,CAAC;IAEpD,sEAAsE;IACtE,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;YAClC,6DAA6D;YAC7D,gCAAgC;YAChC,MAAM,QAAQ,GAAI,MAAc,CAAC,iBAAiB,CAAC;YACnD,IAAI,QAAQ,EAAE,CAAC;gBACb,SAAS,CAAC,QAAQ,CAAC,CAAC;gBACpB,OAAO;YACT,CAAC;YAED,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YACjD,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC1B,gEAAgE;YAChE,IAAI,KAAK,IAAI,gCAAgC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC1D,qEAAqE;gBACrE,qCAAqC;gBACrC,SAAS,CAAC,KAAK,CAAC,CAAC;YACnB,CAAC;QACH,CAAC;IACH,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,IAAI,GAAG,YAAY,CAAC,MAAM,CAAC,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAE/G,MAAM,CAAC,GAAG,CAAC,GAAW,EAAE,MAA+B,EAAU,EAAE;QACjE,IAAI,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;QAE5B,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;gBACxC,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACpD,CAAC,CAAC,CAAC;QACL,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;IAEF,OAAO,CACL,8BAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,EAAE,YAAY,EAAE,IAAI,EAAE,IACtE,QAAQ,CACY,CACxB,CAAC;AACJ,CAAC;AAED,SAAgB,cAAc;IAC5B,MAAM,OAAO,GAAG,IAAA,kBAAU,EAAC,WAAW,CAAC,CAAC;IACxC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uGAAuG,CAAC,CAAC;IAC3H,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAEY,QAAA,OAAO,GAAG,cAAc,CAAC"}
|
package/dist/core/types.d.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface SatsetApp {
|
|
3
|
-
default: React.ComponentType<any>;
|
|
4
|
-
getServerSideProps?: (context: ServerContext) => Promise<any>;
|
|
5
|
-
getStaticProps?: () => Promise<any>;
|
|
6
|
-
}
|
|
7
|
-
export interface ServerContext {
|
|
8
|
-
req: any;
|
|
9
|
-
res: any;
|
|
10
|
-
params: Record<string, string>;
|
|
11
|
-
query: Record<string, string>;
|
|
12
|
-
}
|
|
13
|
-
export interface PageProps {
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
}
|
|
16
|
-
export interface LayoutProps {
|
|
17
|
-
children: React.ReactNode;
|
|
18
|
-
params?: Record<string, string>;
|
|
19
|
-
}
|
|
20
|
-
export interface ErrorPageProps {
|
|
21
|
-
error: Error;
|
|
22
|
-
reset: () => void;
|
|
23
|
-
}
|
|
24
|
-
export declare namespace MetadataRoute {
|
|
25
|
-
type Sitemap = Array<{
|
|
26
|
-
url: string;
|
|
27
|
-
lastModified?: string | Date;
|
|
28
|
-
changeFrequency?: 'always' | 'hourly' | 'daily' | 'weekly' | 'monthly' | 'yearly' | 'never';
|
|
29
|
-
priority?: number;
|
|
30
|
-
}>;
|
|
31
|
-
type Robots = {
|
|
32
|
-
rules: {
|
|
33
|
-
userAgent?: string | string[];
|
|
34
|
-
allow?: string | string[];
|
|
35
|
-
disallow?: string | string[];
|
|
36
|
-
crawlDelay?: number;
|
|
37
|
-
} | Array<{
|
|
38
|
-
userAgent?: string | string[];
|
|
39
|
-
allow?: string | string[];
|
|
40
|
-
disallow?: string | string[];
|
|
41
|
-
crawlDelay?: number;
|
|
42
|
-
}>;
|
|
43
|
-
sitemap?: string | string[];
|
|
44
|
-
host?: string;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/core/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IAClC,kBAAkB,CAAC,EAAE,CAAC,OAAO,EAAE,aAAa,KAAK,OAAO,CAAC,GAAG,CAAC,CAAC;IAC9D,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,GAAG,CAAC;IACT,GAAG,EAAE,GAAG,CAAC;IACT,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,SAAS;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB;AAED,yBAAiB,aAAa,CAAC;IAC7B,KAAY,OAAO,GAAG,KAAK,CAAC;QAC1B,GAAG,EAAE,MAAM,CAAC;QACZ,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC7B,eAAe,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,OAAO,CAAC;QAC5F,QAAQ,CAAC,EAAE,MAAM,CAAC;KACnB,CAAC,CAAC;IAEH,KAAY,MAAM,GAAG;QACnB,KAAK,EAAE;YACL,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;YAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;YAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;YAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,GAAG,KAAK,CAAC;YACR,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;YAC9B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;YAC1B,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;YAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;SACrB,CAAC,CAAC;QACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH"}
|
package/dist/core/types.js
DELETED
package/dist/core/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './core';
|
|
2
|
-
export * from './router';
|
|
3
|
-
export * from './components';
|
|
4
|
-
export * from './assets';
|
|
5
|
-
export { defineConfig, satsetConfig } from './config';
|
|
6
|
-
export type { SatsetConfig, SatsetServerConfig, SatsetAssetsConfig, SatsetResolveConfig, } from './config';
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACtD,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,UAAU,CAAC"}
|
package/dist/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.satsetConfig = exports.defineConfig = void 0;
|
|
18
|
-
__exportStar(require("./core"), exports);
|
|
19
|
-
__exportStar(require("./router"), exports);
|
|
20
|
-
__exportStar(require("./components"), exports);
|
|
21
|
-
__exportStar(require("./assets"), exports);
|
|
22
|
-
var config_1 = require("./config");
|
|
23
|
-
Object.defineProperty(exports, "defineConfig", { enumerable: true, get: function () { return config_1.defineConfig; } });
|
|
24
|
-
Object.defineProperty(exports, "satsetConfig", { enumerable: true, get: function () { return config_1.satsetConfig; } });
|
|
25
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,yCAAuB;AACvB,2CAAyB;AACzB,+CAA6B;AAC7B,2CAAyB;AACzB,mCAAsD;AAA7C,sGAAA,YAAY,OAAA;AAAE,sGAAA,YAAY,OAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.d.ts","sourceRoot":"","sources":["../../src/navigation/notFound.ts"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,IAAI,KAAK,CAIhC;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,SAAM,GAAG,KAAK,CAIzD"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.notFound = notFound;
|
|
4
|
-
exports.redirect = redirect;
|
|
5
|
-
function notFound() {
|
|
6
|
-
const e = new Error('Not Found');
|
|
7
|
-
e.__SATSET_NOT_FOUND = true;
|
|
8
|
-
throw e;
|
|
9
|
-
}
|
|
10
|
-
function redirect(url, status = 307) {
|
|
11
|
-
const e = new Error('Redirect');
|
|
12
|
-
e.__SATSET_REDIRECT = { url, status };
|
|
13
|
-
throw e;
|
|
14
|
-
}
|
|
15
|
-
//# sourceMappingURL=notFound.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"notFound.js","sourceRoot":"","sources":["../../src/navigation/notFound.ts"],"names":[],"mappings":";;AAAA,4BAIC;AAED,4BAIC;AAVD,SAAgB,QAAQ;IACtB,MAAM,CAAC,GAAQ,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC;IACtC,CAAC,CAAC,kBAAkB,GAAG,IAAI,CAAC;IAC5B,MAAM,CAAC,CAAC;AACV,CAAC;AAED,SAAgB,QAAQ,CAAC,GAAW,EAAE,MAAM,GAAG,GAAG;IAChD,MAAM,CAAC,GAAQ,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IACrC,CAAC,CAAC,iBAAiB,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IACtC,MAAM,CAAC,CAAC;AACV,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export interface Route {
|
|
2
|
-
path: string;
|
|
3
|
-
component: string;
|
|
4
|
-
exact?: boolean;
|
|
5
|
-
dynamic?: boolean;
|
|
6
|
-
params?: string[];
|
|
7
|
-
catchAllOptional?: boolean;
|
|
8
|
-
}
|
|
9
|
-
export interface RouteTree {
|
|
10
|
-
routes: Route[];
|
|
11
|
-
apiRoutes: Route[];
|
|
12
|
-
}
|
|
13
|
-
export declare function getRoutes(appDir: string): RouteTree;
|
|
14
|
-
export declare function matchRoute(pathname: string, routes: Route[]): {
|
|
15
|
-
route: Route;
|
|
16
|
-
params: Record<string, string>;
|
|
17
|
-
} | null;
|
|
18
|
-
export declare function generateRouteManifest(routes: Route[]): string;
|
|
19
|
-
//# sourceMappingURL=file-system.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"file-system.d.ts","sourceRoot":"","sources":["../../src/router/file-system.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAElB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,KAAK,EAAE,CAAC;IAChB,SAAS,EAAE,KAAK,EAAE,CAAC;CACpB;AAED,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAsDnD;AA2PD,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG,IAAI,CAqBrH;AAwDD,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,CAS7D"}
|
|
@@ -1,364 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getRoutes = getRoutes;
|
|
7
|
-
exports.matchRoute = matchRoute;
|
|
8
|
-
exports.generateRouteManifest = generateRouteManifest;
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
function getRoutes(appDir) {
|
|
12
|
-
const routes = [];
|
|
13
|
-
const apiRoutes = [];
|
|
14
|
-
// Debug: log which folders exist
|
|
15
|
-
const appPath = path_1.default.join(appDir, 'src', 'app');
|
|
16
|
-
const pagesPath = path_1.default.join(appDir, 'src', 'pages');
|
|
17
|
-
const srcPath = path_1.default.join(appDir, 'src');
|
|
18
|
-
console.debug('[file-system] checking paths:', { appPathExists: fs_1.default.existsSync(appPath), pagesPathExists: fs_1.default.existsSync(pagesPath), srcPathExists: fs_1.default.existsSync(srcPath) });
|
|
19
|
-
// Check for app router (src/app)
|
|
20
|
-
if (fs_1.default.existsSync(appPath)) {
|
|
21
|
-
console.debug('[file-system] scanning appPath', appPath);
|
|
22
|
-
scanDirectory(appPath, '', routes, apiRoutes, 'app');
|
|
23
|
-
}
|
|
24
|
-
// Check for pages router (src/pages)
|
|
25
|
-
if (fs_1.default.existsSync(pagesPath)) {
|
|
26
|
-
console.debug('[file-system] scanning pagesPath', pagesPath);
|
|
27
|
-
scanDirectory(pagesPath, '', routes, apiRoutes, 'pages');
|
|
28
|
-
}
|
|
29
|
-
// Fallback: support flat `src/` layout (no `app` or `pages` folders),
|
|
30
|
-
// or when `src/app` or `src/pages` exists but contains no page routes.
|
|
31
|
-
// Note: we only require there be no discovered page routes — api routes should not prevent
|
|
32
|
-
// scanning the top-level `src` for pages (e.g., projects that colocate APIs and pages).
|
|
33
|
-
if (fs_1.default.existsSync(srcPath) && routes.length === 0) {
|
|
34
|
-
console.debug('[file-system] fallback scanning srcPath', srcPath);
|
|
35
|
-
// Treat top-level src like a pages router for compatibility with simple projects
|
|
36
|
-
scanDirectory(srcPath, '', routes, apiRoutes, 'pages');
|
|
37
|
-
}
|
|
38
|
-
console.debug('[file-system] found routes', routes.map(r => r.path), 'apiRoutes', apiRoutes.map(r => r.path));
|
|
39
|
-
// Persist a small debug file so CI or environments with silent consoles can inspect the discovery
|
|
40
|
-
try {
|
|
41
|
-
const debugDir = path_1.default.join(appDir, '.satset');
|
|
42
|
-
if (!fs_1.default.existsSync(debugDir))
|
|
43
|
-
fs_1.default.mkdirSync(debugDir, { recursive: true });
|
|
44
|
-
fs_1.default.writeFileSync(path_1.default.join(debugDir, 'routes-debug.json'), JSON.stringify({
|
|
45
|
-
appPath: appPath,
|
|
46
|
-
pagesPath: pagesPath,
|
|
47
|
-
srcPath: srcPath,
|
|
48
|
-
appPathExists: fs_1.default.existsSync(appPath),
|
|
49
|
-
pagesPathExists: fs_1.default.existsSync(pagesPath),
|
|
50
|
-
srcPathExists: fs_1.default.existsSync(srcPath),
|
|
51
|
-
routes: routes.map(r => ({ path: r.path, component: r.component })),
|
|
52
|
-
apiRoutes: apiRoutes.map(r => ({ path: r.path, component: r.component }))
|
|
53
|
-
}, null, 2));
|
|
54
|
-
}
|
|
55
|
-
catch (e) {
|
|
56
|
-
// ignore write errors
|
|
57
|
-
}
|
|
58
|
-
return { routes, apiRoutes };
|
|
59
|
-
}
|
|
60
|
-
function scanDirectory(dir, prefix, routes, apiRoutes, type) {
|
|
61
|
-
const files = fs_1.default.readdirSync(dir);
|
|
62
|
-
for (const file of files) {
|
|
63
|
-
const fullPath = path_1.default.join(dir, file);
|
|
64
|
-
const stat = fs_1.default.statSync(fullPath);
|
|
65
|
-
if (stat.isDirectory()) {
|
|
66
|
-
// Skip utility folders that are not pages
|
|
67
|
-
if (file === 'lib' || file === 'styles' || file === 'assets' || file === 'types' || file === 'components' || file === 'utils' || file === 'hooks') {
|
|
68
|
-
// Also skip TypeScript declaration files under `src/types` that should never be pages
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
// Special handling for api routes
|
|
72
|
-
if (file === 'api') {
|
|
73
|
-
scanApiDirectory(fullPath, '/api', apiRoutes);
|
|
74
|
-
continue;
|
|
75
|
-
}
|
|
76
|
-
// Skip route groups (folders with parentheses)
|
|
77
|
-
if (file.startsWith('(') && file.endsWith(')')) {
|
|
78
|
-
scanDirectory(fullPath, prefix, routes, apiRoutes, type);
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
// Handle optional catch-all routes [[...param]]
|
|
82
|
-
if (file.startsWith('[[...') && file.endsWith(']]')) {
|
|
83
|
-
const paramName = file.slice(5, -2);
|
|
84
|
-
// We include a small marker (? after the *) in the prefix so that when
|
|
85
|
-
// a page file is found we can mark the resulting route as optional.
|
|
86
|
-
const newPrefix = prefix + '/*?' + paramName;
|
|
87
|
-
scanDirectory(fullPath, newPrefix, routes, apiRoutes, type);
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
// Handle catch-all routes [...param]
|
|
91
|
-
if (file.startsWith('[...') && file.endsWith(']')) {
|
|
92
|
-
const paramName = file.slice(4, -1);
|
|
93
|
-
const newPrefix = prefix + '/*' + paramName;
|
|
94
|
-
scanDirectory(fullPath, newPrefix, routes, apiRoutes, type);
|
|
95
|
-
continue;
|
|
96
|
-
}
|
|
97
|
-
// Handle dynamic routes [param]
|
|
98
|
-
if (file.startsWith('[') && file.endsWith(']')) {
|
|
99
|
-
const paramName = file.slice(1, -1);
|
|
100
|
-
const newPrefix = prefix + '/:' + paramName;
|
|
101
|
-
scanDirectory(fullPath, newPrefix, routes, apiRoutes, type);
|
|
102
|
-
continue;
|
|
103
|
-
}
|
|
104
|
-
// Regular folder
|
|
105
|
-
const newPrefix = prefix + '/' + file;
|
|
106
|
-
scanDirectory(fullPath, newPrefix, routes, apiRoutes, type);
|
|
107
|
-
}
|
|
108
|
-
else if ((file === 'layout.tsx' || file === 'layout.jsx' || file === 'layout.ts' || file === 'layout.js') &&
|
|
109
|
-
prefix === '') {
|
|
110
|
-
// Root Layout
|
|
111
|
-
routes.push({
|
|
112
|
-
path: '/layout',
|
|
113
|
-
component: fullPath,
|
|
114
|
-
exact: false,
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
else if (file === 'page.tsx' || file === 'page.jsx' || file === 'page.ts' || file === 'page.js') {
|
|
118
|
-
// Main page file
|
|
119
|
-
let routePath = prefix === '' ? '/' : prefix;
|
|
120
|
-
// Detect our optional catch-all marker and normalize the path while capturing the flag
|
|
121
|
-
let catchAllOptional = false;
|
|
122
|
-
if (routePath.includes('/*?')) {
|
|
123
|
-
routePath = routePath.replace('/*?', '/*');
|
|
124
|
-
catchAllOptional = true;
|
|
125
|
-
}
|
|
126
|
-
const isDynamic = routePath.includes(':') || routePath.includes('*');
|
|
127
|
-
const params = extractParams(routePath);
|
|
128
|
-
routes.push({
|
|
129
|
-
path: routePath,
|
|
130
|
-
component: fullPath,
|
|
131
|
-
exact: !isDynamic,
|
|
132
|
-
dynamic: isDynamic,
|
|
133
|
-
params,
|
|
134
|
-
catchAllOptional,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
else if (file === 'not-found.tsx' || file === 'not-found.jsx' || file === 'not-found.ts' || file === 'not-found.js' ||
|
|
138
|
-
file === '404.tsx' || file === '404.jsx' || file === '404.ts' || file === '404.js') {
|
|
139
|
-
// Register Not Found / 404 pages
|
|
140
|
-
// If at root, map to /not-found or /404. If nested, map to /path/not-found
|
|
141
|
-
let routePath = prefix + '/' + file.split('.')[0];
|
|
142
|
-
if (prefix === '')
|
|
143
|
-
routePath = '/' + file.split('.')[0];
|
|
144
|
-
// Normalize for dev server lookup which checks /404 and /not-found
|
|
145
|
-
routes.push({
|
|
146
|
-
path: routePath,
|
|
147
|
-
component: fullPath,
|
|
148
|
-
exact: true,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
else if (type === 'pages' &&
|
|
152
|
-
(file.endsWith('.tsx') || file.endsWith('.jsx') || file.endsWith('.ts') || file.endsWith('.js')) &&
|
|
153
|
-
!file.startsWith('_') &&
|
|
154
|
-
!file.endsWith('.d.ts') &&
|
|
155
|
-
!['sitemap', 'robots', 'middleware', 'layout', 'loading', 'error', 'not-found', 'global-error'].includes(file.replace(/\.[^/.]+$/, ''))) {
|
|
156
|
-
// Pages router style
|
|
157
|
-
const fileName = file.replace(/\.(tsx|jsx|ts|js)$/, '');
|
|
158
|
-
// Handle dynamic routes and catch-alls in pages router
|
|
159
|
-
if (fileName.startsWith('[') && fileName.endsWith(']') && !fileName.startsWith('[...')) {
|
|
160
|
-
const paramName = fileName.slice(1, -1);
|
|
161
|
-
const routePath = prefix + '/:' + paramName;
|
|
162
|
-
routes.push({
|
|
163
|
-
path: routePath,
|
|
164
|
-
component: fullPath,
|
|
165
|
-
exact: false,
|
|
166
|
-
dynamic: true,
|
|
167
|
-
params: [paramName],
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
else if (fileName.startsWith('[...') && fileName.endsWith(']')) {
|
|
171
|
-
const paramName = fileName.slice(4, -1);
|
|
172
|
-
const routePath = prefix + '/*' + paramName;
|
|
173
|
-
routes.push({
|
|
174
|
-
path: routePath,
|
|
175
|
-
component: fullPath,
|
|
176
|
-
exact: false,
|
|
177
|
-
dynamic: true,
|
|
178
|
-
params: [paramName],
|
|
179
|
-
});
|
|
180
|
-
}
|
|
181
|
-
else if (fileName.startsWith('[[...') && fileName.endsWith(']]')) {
|
|
182
|
-
const paramName = fileName.slice(5, -2);
|
|
183
|
-
const routePath = prefix + '/*' + paramName;
|
|
184
|
-
routes.push({
|
|
185
|
-
path: routePath,
|
|
186
|
-
component: fullPath,
|
|
187
|
-
exact: false,
|
|
188
|
-
dynamic: true,
|
|
189
|
-
params: [paramName],
|
|
190
|
-
catchAllOptional: true,
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
const routePath = prefix + '/' + fileName;
|
|
195
|
-
routes.push({
|
|
196
|
-
path: routePath === '/index' ? '/' : routePath,
|
|
197
|
-
component: fullPath,
|
|
198
|
-
exact: true,
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
function scanApiDirectory(dir, prefix, apiRoutes) {
|
|
205
|
-
const files = fs_1.default.readdirSync(dir);
|
|
206
|
-
for (const file of files) {
|
|
207
|
-
const fullPath = path_1.default.join(dir, file);
|
|
208
|
-
const stat = fs_1.default.statSync(fullPath);
|
|
209
|
-
if (stat.isDirectory()) {
|
|
210
|
-
// Handle optional catch-all API route directories [[...param]]
|
|
211
|
-
if (file.startsWith('[[...') && file.endsWith(']]')) {
|
|
212
|
-
const paramName = file.slice(5, -2);
|
|
213
|
-
const newPrefix = prefix + '/*?' + paramName;
|
|
214
|
-
scanApiDirectory(fullPath, newPrefix, apiRoutes);
|
|
215
|
-
continue;
|
|
216
|
-
}
|
|
217
|
-
// Handle catch-all API route directories [...param]
|
|
218
|
-
if (file.startsWith('[...') && file.endsWith(']')) {
|
|
219
|
-
const paramName = file.slice(4, -1);
|
|
220
|
-
const newPrefix = prefix + '/*' + paramName;
|
|
221
|
-
scanApiDirectory(fullPath, newPrefix, apiRoutes);
|
|
222
|
-
continue;
|
|
223
|
-
}
|
|
224
|
-
// Handle dynamic API route directories [param]
|
|
225
|
-
if (file.startsWith('[') && file.endsWith(']')) {
|
|
226
|
-
const paramName = file.slice(1, -1);
|
|
227
|
-
const newPrefix = prefix + '/:' + paramName;
|
|
228
|
-
scanApiDirectory(fullPath, newPrefix, apiRoutes);
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
231
|
-
const newPrefix = prefix + '/' + file;
|
|
232
|
-
scanApiDirectory(fullPath, newPrefix, apiRoutes);
|
|
233
|
-
}
|
|
234
|
-
else if ((file.endsWith('.ts') || file.endsWith('.js')) && !file.endsWith('.d.ts')) {
|
|
235
|
-
const fileName = file.replace(/\.(ts|js)$/, '');
|
|
236
|
-
let routePath;
|
|
237
|
-
let params = [];
|
|
238
|
-
// Next.js-style API route convention: `route.ts` uses the folder path as the URL
|
|
239
|
-
// Example: src/api/auth/register/route.ts -> /api/auth/register
|
|
240
|
-
if (fileName === 'route') {
|
|
241
|
-
routePath = prefix || '/';
|
|
242
|
-
}
|
|
243
|
-
else if (fileName.startsWith('[') && fileName.endsWith(']') && !fileName.startsWith('[...')) {
|
|
244
|
-
const paramName = fileName.slice(1, -1);
|
|
245
|
-
routePath = prefix + '/:' + paramName;
|
|
246
|
-
params = [paramName];
|
|
247
|
-
}
|
|
248
|
-
else if (fileName.startsWith('[...') && fileName.endsWith(']')) {
|
|
249
|
-
const paramName = fileName.slice(4, -1);
|
|
250
|
-
routePath = prefix + '/*' + paramName;
|
|
251
|
-
params = [paramName];
|
|
252
|
-
}
|
|
253
|
-
else if (fileName.startsWith('[[...') && fileName.endsWith(']]')) {
|
|
254
|
-
const paramName = fileName.slice(5, -2);
|
|
255
|
-
routePath = prefix + '/*' + paramName;
|
|
256
|
-
params = [paramName];
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
routePath = prefix + '/' + fileName;
|
|
260
|
-
}
|
|
261
|
-
const isDynamic = routePath.includes(':') || routePath.includes('*');
|
|
262
|
-
if (!params.length && isDynamic) {
|
|
263
|
-
params = extractParams(routePath);
|
|
264
|
-
}
|
|
265
|
-
apiRoutes.push({
|
|
266
|
-
path: routePath,
|
|
267
|
-
component: fullPath,
|
|
268
|
-
dynamic: isDynamic,
|
|
269
|
-
params,
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
function extractParams(routePath) {
|
|
275
|
-
const params = [];
|
|
276
|
-
const segments = routePath.split('/');
|
|
277
|
-
for (const segment of segments) {
|
|
278
|
-
if (segment.startsWith(':')) {
|
|
279
|
-
params.push(segment.slice(1));
|
|
280
|
-
}
|
|
281
|
-
else if (segment.startsWith('*')) {
|
|
282
|
-
params.push(segment.slice(1));
|
|
283
|
-
}
|
|
284
|
-
}
|
|
285
|
-
return params;
|
|
286
|
-
}
|
|
287
|
-
function matchRoute(pathname, routes) {
|
|
288
|
-
for (const route of routes) {
|
|
289
|
-
if (route.dynamic) {
|
|
290
|
-
const match = matchDynamicRoute(pathname, route.path, !!route.catchAllOptional);
|
|
291
|
-
if (match) {
|
|
292
|
-
return { route, params: match };
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
else {
|
|
296
|
-
if (route.exact) {
|
|
297
|
-
if (pathname === route.path) {
|
|
298
|
-
return { route, params: {} };
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
else {
|
|
302
|
-
if (pathname.startsWith(route.path)) {
|
|
303
|
-
return { route, params: {} };
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
function matchDynamicRoute(pathname, routePath, catchAllOptional = false) {
|
|
311
|
-
const pathSegments = pathname.split('/').filter(Boolean);
|
|
312
|
-
const routeSegments = routePath.split('/').filter(Boolean);
|
|
313
|
-
// Handle catch-all routes
|
|
314
|
-
if (routePath.includes('*')) {
|
|
315
|
-
const params = {};
|
|
316
|
-
const catchAllIndex = routeSegments.findIndex(s => s.startsWith('*'));
|
|
317
|
-
// Verify that static prefix segments match the incoming path
|
|
318
|
-
for (let i = 0; i < catchAllIndex; i++) {
|
|
319
|
-
if (pathSegments[i] !== routeSegments[i]) {
|
|
320
|
-
return null;
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
// Normalize parameter name (support '*?name' marker from scan)
|
|
324
|
-
let paramName = routeSegments[catchAllIndex].slice(1);
|
|
325
|
-
if (paramName.startsWith('?'))
|
|
326
|
-
paramName = paramName.slice(1);
|
|
327
|
-
// If path has fewer segments than the catch-all index, allow match for optional catch-all
|
|
328
|
-
if (pathSegments.length <= catchAllIndex && catchAllOptional) {
|
|
329
|
-
params[paramName] = '';
|
|
330
|
-
return params;
|
|
331
|
-
}
|
|
332
|
-
params[paramName] = pathSegments.slice(catchAllIndex).join('/');
|
|
333
|
-
return params;
|
|
334
|
-
}
|
|
335
|
-
// Must have same number of segments
|
|
336
|
-
if (pathSegments.length !== routeSegments.length) {
|
|
337
|
-
return null;
|
|
338
|
-
}
|
|
339
|
-
const params = {};
|
|
340
|
-
for (let i = 0; i < routeSegments.length; i++) {
|
|
341
|
-
const routeSegment = routeSegments[i];
|
|
342
|
-
const pathSegment = pathSegments[i];
|
|
343
|
-
if (routeSegment.startsWith(':')) {
|
|
344
|
-
// Dynamic segment
|
|
345
|
-
const paramName = routeSegment.slice(1);
|
|
346
|
-
params[paramName] = pathSegment;
|
|
347
|
-
}
|
|
348
|
-
else if (routeSegment !== pathSegment) {
|
|
349
|
-
// Static segment doesn't match
|
|
350
|
-
return null;
|
|
351
|
-
}
|
|
352
|
-
}
|
|
353
|
-
return params;
|
|
354
|
-
}
|
|
355
|
-
function generateRouteManifest(routes) {
|
|
356
|
-
const manifest = routes.map(route => ({
|
|
357
|
-
path: route.path,
|
|
358
|
-
component: route.component,
|
|
359
|
-
dynamic: route.dynamic,
|
|
360
|
-
params: route.params,
|
|
361
|
-
}));
|
|
362
|
-
return JSON.stringify(manifest, null, 2);
|
|
363
|
-
}
|
|
364
|
-
//# sourceMappingURL=file-system.js.map
|