exta2 0.0.1-beta.29

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/env.d.ts ADDED
@@ -0,0 +1,138 @@
1
+ /* eslint-disable @typescript-eslint/no-misused-new */
2
+
3
+ // $exta-manifest module is page map for internal core routing.
4
+ declare module '$exta-manifest' {
5
+ export interface PageManifest {
6
+ regexp: RegExp;
7
+ path: string;
8
+ originalPath: string;
9
+ params: string[];
10
+ buildPath: string;
11
+ buildServerPath: string;
12
+ allowedParams?: Record<string, string[]>;
13
+ }
14
+
15
+ export const PAGES_MANIFEST: PageManifest[];
16
+ }
17
+
18
+ declare module '$exta-pages' {
19
+ const pages: Record<string, () => Promise<any>>;
20
+ export = pages;
21
+ }
22
+
23
+ declare module '$exta-router' {
24
+ import { PageManifest } from '$exta-manifest';
25
+
26
+ type ExtaLayout = (props: { children: React.ReactNode }) => React.ReactNode;
27
+ type ExtaErrorComponent = (props: ErrorProps) => React.ReactNode;
28
+
29
+ interface RouteResult {
30
+ regex: RegExp;
31
+ params: string[];
32
+ }
33
+
34
+ /**
35
+ * Return `url.location`.
36
+ */
37
+ export function useLocation(): string;
38
+
39
+ export function useRouter(): {
40
+ location: string;
41
+ push: (path: any) => void;
42
+ replace: (path: any) => void;
43
+ };
44
+
45
+ export function useParams(): {
46
+ [key: string]: string;
47
+ };
48
+
49
+ /**
50
+ * Return `url.pathname`.
51
+ */
52
+ export function usePathname(): string;
53
+
54
+ export function useHash(): string;
55
+
56
+ /**
57
+ * Return `url.searchQuery`.
58
+ */
59
+ export function useSearchQuery(): URLSearchParams;
60
+
61
+ export interface Router {
62
+ routes: PageManifest[];
63
+
64
+ /**
65
+ * Layout component
66
+ */
67
+ layout: { _page: ExtaLayout };
68
+
69
+ /**
70
+ * Error component
71
+ */
72
+ error: { _page: ExtaErrorComponent };
73
+
74
+ /**
75
+ * Loaded page components
76
+ */
77
+ modules: Record<string, any>;
78
+
79
+ /**
80
+ * Loaded page data (`.json`).
81
+ */
82
+ data: Map<string, any>;
83
+
84
+ constructor(routes: PageManifest[]);
85
+
86
+ /**
87
+ * Preload page module (`.js` file)
88
+ * ```ts
89
+ * router.preload(router.findPage("/"));
90
+ * ```
91
+ * @param page target page
92
+ */
93
+ preload(page: PageManifest): void;
94
+
95
+ /**
96
+ * Preload all page modules
97
+ */
98
+ preloadAllPages(): void;
99
+
100
+ /**
101
+ * Load layout component (`_layout.tsx` or default layout)
102
+ */
103
+ loadLayout(): Promise<any>;
104
+
105
+ /**
106
+ * Load layout component (`_error.tsx` or default error component)
107
+ */
108
+ loadError(): Promise<any>;
109
+
110
+ /**
111
+ * Find page and return page info
112
+ * @param url target page url
113
+ */
114
+ findPage(url: string): PageManifest;
115
+
116
+ /**
117
+ * Load all page modules including layout, error and page component
118
+ * @param href target url
119
+ */
120
+ goto(href: string): Promise<{ modules: any; data: any }>;
121
+
122
+ /**
123
+ * Fetch page data (`.json` file)
124
+ * @param url target page url
125
+ */
126
+ prefetch(url: string): Promise<void>;
127
+ }
128
+
129
+ export const router: Router;
130
+ }
131
+
132
+ interface Window {
133
+ __overlay__: {
134
+ show(text: string, error?: boolean): void;
135
+ hide(): void;
136
+ setText(text: string): void;
137
+ };
138
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "exta2",
3
+ "version": "0.0.1-beta.29",
4
+ "main": "./dist/index.js",
5
+ "module": "./dist/index.mjs",
6
+ "types": "./dist/index.d.ts",
7
+ "repository": "https://github.com/do4ng/exta",
8
+ "homepage": "https://extajs.netlify.app",
9
+ "description": "Static Site Generator",
10
+ "files": [
11
+ "dist",
12
+ "env.d.ts",
13
+ "ssr.d.ts"
14
+ ],
15
+ "dependencies": {
16
+ "colors": "^1.4.0",
17
+ "esbuild": "^0.25.8",
18
+ "oxc-parser": "^0.79.1",
19
+ "vite": "^7.0.6"
20
+ },
21
+ "devDependencies": {
22
+ "react": "^19.1.1",
23
+ "react-dom": "^19.1.1"
24
+ },
25
+ "exports": {
26
+ ".": {
27
+ "types": "./dist/index.d.ts",
28
+ "import": "./dist/index.mjs",
29
+ "default": "./dist/index.js"
30
+ },
31
+ "./components": {
32
+ "types": "./dist/components.d.ts",
33
+ "require": "./dist/components.js",
34
+ "import": "./dist/components.mjs"
35
+ },
36
+ "./client": {
37
+ "types": "./dist/client.d.ts",
38
+ "require": "./dist/client.js",
39
+ "import": "./dist/client.mjs"
40
+ },
41
+ "./package.json": "./package.json",
42
+ "./env.d.ts": "./env.d.ts",
43
+ "./ssr.d.ts": "./ssr.d.ts"
44
+ }
45
+ }
package/ssr.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ export {};
2
+
3
+ declare global {
4
+ interface SSRData {
5
+ pathname: string;
6
+ params: Record<string, string>;
7
+ preload: string[];
8
+ head: { type: 'preload-data-link' | 'html'; data: string }[];
9
+ }
10
+
11
+ var __EXTA_SSR_DATA__: SSRData;
12
+ }