@promakeai/cli 0.5.8 → 0.6.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/README.md +71 -71
- package/dist/index.js +259 -254
- package/dist/registry/about-page.json +3 -3
- package/dist/registry/about-section.json +4 -4
- package/dist/registry/animations.json +2 -2
- package/dist/registry/announcement-bar.json +4 -4
- package/dist/registry/api.json +1 -1
- package/dist/registry/auth-core.json +3 -3
- package/dist/registry/bento-grid-section.json +4 -4
- package/dist/registry/blog-core.json +5 -5
- package/dist/registry/blog-list-page.json +4 -4
- package/dist/registry/blog-section.json +4 -4
- package/dist/registry/cards-carousel-section.json +4 -4
- package/dist/registry/cart-drawer.json +4 -4
- package/dist/registry/cart-page.json +4 -4
- package/dist/registry/case-study-page.json +3 -3
- package/dist/registry/category-section.json +4 -4
- package/dist/registry/checkout-page.json +4 -4
- package/dist/registry/coming-soon-page-minimal.json +4 -4
- package/dist/registry/coming-soon-page.json +4 -4
- package/dist/registry/contact-info-grid.json +4 -4
- package/dist/registry/contact-page-centered.json +4 -4
- package/dist/registry/contact-page-map-overlay.json +3 -3
- package/dist/registry/contact-page-map-split.json +3 -3
- package/dist/registry/contact-page-split.json +4 -4
- package/dist/registry/contact-page.json +4 -4
- package/dist/registry/content-section.json +4 -4
- package/dist/registry/cookie-consent.json +4 -4
- package/dist/registry/cookies-page.json +3 -3
- package/dist/registry/cta-section.json +3 -3
- package/dist/registry/ecommerce-core.json +8 -8
- package/dist/registry/empty-page.json +3 -3
- package/dist/registry/faq-categorized.json +4 -4
- package/dist/registry/faq-simple.json +4 -4
- package/dist/registry/favorites-blog-block.json +1 -1
- package/dist/registry/favorites-blog-page.json +4 -4
- package/dist/registry/favorites-ecommerce-block.json +1 -1
- package/dist/registry/favorites-ecommerce-page.json +4 -4
- package/dist/registry/feature-section.json +3 -3
- package/dist/registry/featured-products.json +4 -4
- package/dist/registry/footer-detailed.json +4 -4
- package/dist/registry/footer-minimal.json +3 -3
- package/dist/registry/footer.json +3 -3
- package/dist/registry/forgot-password-page-split.json +4 -4
- package/dist/registry/forgot-password-page.json +4 -4
- package/dist/registry/google-adsense.json +4 -4
- package/dist/registry/google-map.json +2 -2
- package/dist/registry/header-centered-pill.json +4 -4
- package/dist/registry/header-ecommerce.json +4 -4
- package/dist/registry/header-mega.json +4 -4
- package/dist/registry/header-minimal.json +4 -4
- package/dist/registry/header-simple.json +3 -3
- package/dist/registry/hero-carousel.json +3 -3
- package/dist/registry/hero-cta.json +4 -4
- package/dist/registry/hero-gradient.json +4 -4
- package/dist/registry/hero-grid.json +4 -4
- package/dist/registry/hero-profile.json +3 -3
- package/dist/registry/hero.json +3 -3
- package/dist/registry/index.json +103 -103
- package/dist/registry/landing-page-app.json +3 -3
- package/dist/registry/landing-page-saas.json +3 -3
- package/dist/registry/login-page-split.json +4 -4
- package/dist/registry/login-page.json +4 -4
- package/dist/registry/logo-cloud.json +4 -4
- package/dist/registry/masonry-grid.json +3 -3
- package/dist/registry/my-orders-page.json +4 -4
- package/dist/registry/newsletter-section.json +4 -4
- package/dist/registry/order-card-compact.json +1 -1
- package/dist/registry/order-confirmation-page.json +4 -4
- package/dist/registry/order-detail-block.json +1 -1
- package/dist/registry/orders-list-block.json +1 -1
- package/dist/registry/payment-success-block.json +2 -2
- package/dist/registry/portfolio-page.json +4 -4
- package/dist/registry/post-card.json +4 -4
- package/dist/registry/post-detail-block.json +2 -2
- package/dist/registry/post-detail-page.json +4 -4
- package/dist/registry/pricing-card.json +3 -3
- package/dist/registry/pricing-page.json +4 -4
- package/dist/registry/pricing-section.json +4 -4
- package/dist/registry/privacy-page.json +3 -3
- package/dist/registry/product-card-detailed.json +4 -4
- package/dist/registry/product-card-hover.json +4 -4
- package/dist/registry/product-card.json +4 -4
- package/dist/registry/product-detail-block.json +2 -2
- package/dist/registry/product-detail-page.json +4 -4
- package/dist/registry/product-detail-section.json +4 -4
- package/dist/registry/product-quick-view.json +4 -4
- package/dist/registry/products-page.json +4 -4
- package/dist/registry/reading-progress.json +4 -4
- package/dist/registry/register-page-split.json +4 -4
- package/dist/registry/register-page.json +4 -4
- package/dist/registry/related-posts-block.json +1 -1
- package/dist/registry/related-products-block.json +2 -2
- package/dist/registry/reset-password-page-split.json +4 -4
- package/dist/registry/reset-password-page.json +4 -4
- package/dist/registry/service-card.json +1 -1
- package/dist/registry/share-buttons.json +4 -4
- package/dist/registry/skill-card.json +1 -1
- package/dist/registry/team-page.json +4 -4
- package/dist/registry/terms-page.json +3 -3
- package/dist/registry/testimonials-carousel.json +4 -4
- package/dist/registry/testimonials-grid.json +4 -4
- package/dist/registry/timeline-section.json +4 -4
- package/dist/registry/video-hero.json +4 -4
- package/dist/registry/youtube-embed.json +4 -4
- package/package.json +59 -56
- package/template/.env +6 -6
- package/template/README.md +54 -54
- package/template/eslint.config.js +41 -41
- package/template/package.json +95 -95
- package/template/public/_redirects +1 -1
- package/template/public/robots.txt +14 -14
- package/template/scripts/init-db.ts +18 -18
- package/template/src/App.tsx +19 -19
- package/template/src/components/FormField.tsx +48 -48
- package/template/src/components/FormFileInput.tsx +75 -75
- package/template/src/components/GoogleAnalytics.tsx +34 -34
- package/template/src/components/LanguageSwitcher.tsx +53 -53
- package/template/src/components/PasswordInput.tsx +60 -60
- package/template/src/components/ScriptInjector.tsx +62 -62
- package/template/src/components/Stack.tsx +39 -39
- package/template/src/constants/constants.json +67 -67
- package/template/src/db/index.ts +20 -20
- package/template/src/db/provider.tsx +78 -78
- package/template/src/db/schema.json +258 -258
- package/template/src/db/types.ts +195 -195
- package/template/src/hooks/use-debounced-value.ts +12 -12
- package/template/src/lang/index.ts +90 -90
- package/template/src/lib/api.ts +345 -345
- package/template/src/lib/env.ts +19 -19
- package/template/src/router.tsx +14 -14
- package/template/src/vite-env.d.ts +1 -1
- package/template/vite.config.ts +68 -64
- package/template/public/data/database.db-shm +0 -0
- package/template/public/data/database.db-wal +0 -0
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import clsx from "clsx";
|
|
2
|
-
import { Children } from "react";
|
|
3
|
-
|
|
4
|
-
type StackProps = {
|
|
5
|
-
as?: keyof HTMLElementTagNameMap; // "div", "ul", "section" vs can be any valid HTML element
|
|
6
|
-
gap?: 0 | 1 | 2 | 3 | 4 | 6 | 8 | 10 | 12; //Tailwind spacing scale
|
|
7
|
-
direction?: "vertical" | "horizontal";
|
|
8
|
-
className?: string;
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
wrapChildren?: boolean; // If true, wraps each child in a Stack with the same gap
|
|
11
|
-
childGap?: 0 | 1 | 2 | 3 | 4 | 6 | 8 | 10 | 12; // Gap for wrapped children
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function Stack({
|
|
15
|
-
as: Component = "div",
|
|
16
|
-
gap = 2,
|
|
17
|
-
direction = "vertical",
|
|
18
|
-
className,
|
|
19
|
-
children,
|
|
20
|
-
wrapChildren = false,
|
|
21
|
-
childGap = 2,
|
|
22
|
-
}: StackProps) {
|
|
23
|
-
const gapClass =
|
|
24
|
-
direction === "vertical" ? `space-y-${gap}` : `space-x-${gap}`;
|
|
25
|
-
|
|
26
|
-
const content = wrapChildren
|
|
27
|
-
? Children.map(children, (child, index) => (
|
|
28
|
-
<Stack key={index} gap={childGap} direction={direction}>
|
|
29
|
-
{child}
|
|
30
|
-
</Stack>
|
|
31
|
-
))
|
|
32
|
-
: children;
|
|
33
|
-
|
|
34
|
-
return (
|
|
35
|
-
<Component className={clsx(gapClass, className)}>
|
|
36
|
-
{content}
|
|
37
|
-
</Component>
|
|
38
|
-
);
|
|
39
|
-
}
|
|
1
|
+
import clsx from "clsx";
|
|
2
|
+
import { Children } from "react";
|
|
3
|
+
|
|
4
|
+
type StackProps = {
|
|
5
|
+
as?: keyof HTMLElementTagNameMap; // "div", "ul", "section" vs can be any valid HTML element
|
|
6
|
+
gap?: 0 | 1 | 2 | 3 | 4 | 6 | 8 | 10 | 12; //Tailwind spacing scale
|
|
7
|
+
direction?: "vertical" | "horizontal";
|
|
8
|
+
className?: string;
|
|
9
|
+
children: React.ReactNode;
|
|
10
|
+
wrapChildren?: boolean; // If true, wraps each child in a Stack with the same gap
|
|
11
|
+
childGap?: 0 | 1 | 2 | 3 | 4 | 6 | 8 | 10 | 12; // Gap for wrapped children
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export function Stack({
|
|
15
|
+
as: Component = "div",
|
|
16
|
+
gap = 2,
|
|
17
|
+
direction = "vertical",
|
|
18
|
+
className,
|
|
19
|
+
children,
|
|
20
|
+
wrapChildren = false,
|
|
21
|
+
childGap = 2,
|
|
22
|
+
}: StackProps) {
|
|
23
|
+
const gapClass =
|
|
24
|
+
direction === "vertical" ? `space-y-${gap}` : `space-x-${gap}`;
|
|
25
|
+
|
|
26
|
+
const content = wrapChildren
|
|
27
|
+
? Children.map(children, (child, index) => (
|
|
28
|
+
<Stack key={index} gap={childGap} direction={direction}>
|
|
29
|
+
{child}
|
|
30
|
+
</Stack>
|
|
31
|
+
))
|
|
32
|
+
: children;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Component className={clsx(gapClass, className)}>
|
|
36
|
+
{content}
|
|
37
|
+
</Component>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
{
|
|
2
|
-
"site": {
|
|
3
|
-
"name": "Site Name",
|
|
4
|
-
"tagline": "Your Site Tagline",
|
|
5
|
-
"description": "A modern, responsive site template for businesses, blogs, ecommerce stores, or portfolios.",
|
|
6
|
-
"logo": "",
|
|
7
|
-
"favicon": "./favicon.svg",
|
|
8
|
-
"currency": "USD",
|
|
9
|
-
"country": "United States",
|
|
10
|
-
"countryCode": "US",
|
|
11
|
-
"defaultLanguage": "en",
|
|
12
|
-
"availableLanguages": {
|
|
13
|
-
"en": "EN"
|
|
14
|
-
},
|
|
15
|
-
"overrideBrowserLanguage": true,
|
|
16
|
-
"timezone": "America/New_York",
|
|
17
|
-
"slug": "site-name",
|
|
18
|
-
"taxName": "Tax"
|
|
19
|
-
},
|
|
20
|
-
"api": {
|
|
21
|
-
"baseUrl": "https://backend.promake.ai/api",
|
|
22
|
-
"endpoints": {
|
|
23
|
-
"contact": "/contact",
|
|
24
|
-
"services": "/services"
|
|
25
|
-
},
|
|
26
|
-
"timeout": 30000
|
|
27
|
-
},
|
|
28
|
-
"seo": {
|
|
29
|
-
"title": "Site Name",
|
|
30
|
-
"description": "Your site description",
|
|
31
|
-
"author": "Site Name",
|
|
32
|
-
"ogTitle": "Site Name",
|
|
33
|
-
"ogDescription": "Your site description",
|
|
34
|
-
"ogImage": "",
|
|
35
|
-
"twitterSite": "",
|
|
36
|
-
"twitterImage": "",
|
|
37
|
-
"googleVerification": ""
|
|
38
|
-
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"gaId": "",
|
|
41
|
-
"headStart": "",
|
|
42
|
-
"headEnd": "",
|
|
43
|
-
"bodyStart": "",
|
|
44
|
-
"bodyEnd": ""
|
|
45
|
-
},
|
|
46
|
-
"email": "hello@example.com",
|
|
47
|
-
"supportEmail": "support@example.com",
|
|
48
|
-
"phone": "+1 (555) 010-0000",
|
|
49
|
-
"whatsapp": "+1 (555) 010-0001",
|
|
50
|
-
"address": {
|
|
51
|
-
"line1": "123 Main Street",
|
|
52
|
-
"line2": "Suite 100",
|
|
53
|
-
"city": "City",
|
|
54
|
-
"state": "State",
|
|
55
|
-
"postalCode": "00000",
|
|
56
|
-
"country": "Country"
|
|
57
|
-
},
|
|
58
|
-
"socialMedia": {
|
|
59
|
-
"twitter": "",
|
|
60
|
-
"facebook": "",
|
|
61
|
-
"instagram": "",
|
|
62
|
-
"linkedin": ""
|
|
63
|
-
},
|
|
64
|
-
"file":{
|
|
65
|
-
"maxFiles": 5,
|
|
66
|
-
"accept": ".pdf,.doc,.docx,.jpg,.jpeg,.png"
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"site": {
|
|
3
|
+
"name": "Site Name",
|
|
4
|
+
"tagline": "Your Site Tagline",
|
|
5
|
+
"description": "A modern, responsive site template for businesses, blogs, ecommerce stores, or portfolios.",
|
|
6
|
+
"logo": "",
|
|
7
|
+
"favicon": "./favicon.svg",
|
|
8
|
+
"currency": "USD",
|
|
9
|
+
"country": "United States",
|
|
10
|
+
"countryCode": "US",
|
|
11
|
+
"defaultLanguage": "en",
|
|
12
|
+
"availableLanguages": {
|
|
13
|
+
"en": "EN"
|
|
14
|
+
},
|
|
15
|
+
"overrideBrowserLanguage": true,
|
|
16
|
+
"timezone": "America/New_York",
|
|
17
|
+
"slug": "site-name",
|
|
18
|
+
"taxName": "Tax"
|
|
19
|
+
},
|
|
20
|
+
"api": {
|
|
21
|
+
"baseUrl": "https://backend.promake.ai/api",
|
|
22
|
+
"endpoints": {
|
|
23
|
+
"contact": "/contact",
|
|
24
|
+
"services": "/services"
|
|
25
|
+
},
|
|
26
|
+
"timeout": 30000
|
|
27
|
+
},
|
|
28
|
+
"seo": {
|
|
29
|
+
"title": "Site Name",
|
|
30
|
+
"description": "Your site description",
|
|
31
|
+
"author": "Site Name",
|
|
32
|
+
"ogTitle": "Site Name",
|
|
33
|
+
"ogDescription": "Your site description",
|
|
34
|
+
"ogImage": "",
|
|
35
|
+
"twitterSite": "",
|
|
36
|
+
"twitterImage": "",
|
|
37
|
+
"googleVerification": ""
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"gaId": "",
|
|
41
|
+
"headStart": "",
|
|
42
|
+
"headEnd": "",
|
|
43
|
+
"bodyStart": "",
|
|
44
|
+
"bodyEnd": ""
|
|
45
|
+
},
|
|
46
|
+
"email": "hello@example.com",
|
|
47
|
+
"supportEmail": "support@example.com",
|
|
48
|
+
"phone": "+1 (555) 010-0000",
|
|
49
|
+
"whatsapp": "+1 (555) 010-0001",
|
|
50
|
+
"address": {
|
|
51
|
+
"line1": "123 Main Street",
|
|
52
|
+
"line2": "Suite 100",
|
|
53
|
+
"city": "City",
|
|
54
|
+
"state": "State",
|
|
55
|
+
"postalCode": "00000",
|
|
56
|
+
"country": "Country"
|
|
57
|
+
},
|
|
58
|
+
"socialMedia": {
|
|
59
|
+
"twitter": "",
|
|
60
|
+
"facebook": "",
|
|
61
|
+
"instagram": "",
|
|
62
|
+
"linkedin": ""
|
|
63
|
+
},
|
|
64
|
+
"file":{
|
|
65
|
+
"maxFiles": 5,
|
|
66
|
+
"accept": ".pdf,.doc,.docx,.jpg,.jpeg,.png"
|
|
67
|
+
}
|
|
68
68
|
}
|
package/template/src/db/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { AppDbProvider } from "./provider";
|
|
2
|
-
|
|
3
|
-
import { parseJSONSchema } from "@promakeai/dbreact";
|
|
4
|
-
import schemaJson from "./schema.json";
|
|
5
|
-
export const schema = parseJSONSchema(schemaJson as any);
|
|
6
|
-
|
|
7
|
-
export {
|
|
8
|
-
useDb,
|
|
9
|
-
useAdapter,
|
|
10
|
-
useDbLang,
|
|
11
|
-
useDbList,
|
|
12
|
-
useDbGet,
|
|
13
|
-
useDbCreate,
|
|
14
|
-
useDbUpdate,
|
|
15
|
-
useDbDelete,
|
|
16
|
-
SqliteAdapter,
|
|
17
|
-
parseJSONSchema,
|
|
18
|
-
} from "@promakeai/dbreact";
|
|
19
|
-
|
|
20
|
-
export * from "./types";
|
|
1
|
+
export { AppDbProvider } from "./provider";
|
|
2
|
+
|
|
3
|
+
import { parseJSONSchema } from "@promakeai/dbreact";
|
|
4
|
+
import schemaJson from "./schema.json";
|
|
5
|
+
export const schema = parseJSONSchema(schemaJson as any);
|
|
6
|
+
|
|
7
|
+
export {
|
|
8
|
+
useDb,
|
|
9
|
+
useAdapter,
|
|
10
|
+
useDbLang,
|
|
11
|
+
useDbList,
|
|
12
|
+
useDbGet,
|
|
13
|
+
useDbCreate,
|
|
14
|
+
useDbUpdate,
|
|
15
|
+
useDbDelete,
|
|
16
|
+
SqliteAdapter,
|
|
17
|
+
parseJSONSchema,
|
|
18
|
+
} from "@promakeai/dbreact";
|
|
19
|
+
|
|
20
|
+
export * from "./types";
|
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
import { useEffect, useState, type ReactNode } from "react";
|
|
2
|
-
import { useTranslation } from "react-i18next";
|
|
3
|
-
import { DbProvider, SqliteAdapter, parseJSONSchema } from "@promakeai/dbreact";
|
|
4
|
-
import constants from "@/constants/constants.json";
|
|
5
|
-
import schemaJson from "./schema.json";
|
|
6
|
-
|
|
7
|
-
const schema = parseJSONSchema(schemaJson as any);
|
|
8
|
-
|
|
9
|
-
interface AppDbProviderProps {
|
|
10
|
-
children: ReactNode;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const DEFAULT_LANG = constants?.site?.defaultLanguage || "en";
|
|
14
|
-
|
|
15
|
-
export function AppDbProvider({ children }: AppDbProviderProps) {
|
|
16
|
-
const { i18n } = useTranslation();
|
|
17
|
-
const [adapter, setAdapter] = useState<SqliteAdapter | null>(null);
|
|
18
|
-
const [error, setError] = useState<Error | null>(null);
|
|
19
|
-
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
let cancelled = false;
|
|
22
|
-
|
|
23
|
-
async function loadDb() {
|
|
24
|
-
try {
|
|
25
|
-
const response = await fetch("/data/database.db");
|
|
26
|
-
if (!response.ok) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`Failed to load database: ${response.status} ${response.statusText}`
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const buffer = await response.arrayBuffer();
|
|
33
|
-
if (cancelled) return;
|
|
34
|
-
|
|
35
|
-
const dbAdapter = new SqliteAdapter({
|
|
36
|
-
schema,
|
|
37
|
-
defaultLang: DEFAULT_LANG,
|
|
38
|
-
wasmPath: "/sql-wasm.wasm",
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
await dbAdapter.connect();
|
|
42
|
-
await dbAdapter.import(new Uint8Array(buffer));
|
|
43
|
-
|
|
44
|
-
if (!cancelled) {
|
|
45
|
-
setAdapter(dbAdapter);
|
|
46
|
-
}
|
|
47
|
-
} catch (err) {
|
|
48
|
-
if (!cancelled) {
|
|
49
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
loadDb();
|
|
55
|
-
|
|
56
|
-
return () => {
|
|
57
|
-
cancelled = true;
|
|
58
|
-
};
|
|
59
|
-
}, []);
|
|
60
|
-
|
|
61
|
-
if (error) {
|
|
62
|
-
console.error(error);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (!adapter) {
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<DbProvider
|
|
71
|
-
adapter={adapter}
|
|
72
|
-
lang={i18n?.language || DEFAULT_LANG}
|
|
73
|
-
fallbackLang={DEFAULT_LANG}
|
|
74
|
-
>
|
|
75
|
-
{children}
|
|
76
|
-
</DbProvider>
|
|
77
|
-
);
|
|
78
|
-
}
|
|
1
|
+
import { useEffect, useState, type ReactNode } from "react";
|
|
2
|
+
import { useTranslation } from "react-i18next";
|
|
3
|
+
import { DbProvider, SqliteAdapter, parseJSONSchema } from "@promakeai/dbreact";
|
|
4
|
+
import constants from "@/constants/constants.json";
|
|
5
|
+
import schemaJson from "./schema.json";
|
|
6
|
+
|
|
7
|
+
const schema = parseJSONSchema(schemaJson as any);
|
|
8
|
+
|
|
9
|
+
interface AppDbProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const DEFAULT_LANG = constants?.site?.defaultLanguage || "en";
|
|
14
|
+
|
|
15
|
+
export function AppDbProvider({ children }: AppDbProviderProps) {
|
|
16
|
+
const { i18n } = useTranslation();
|
|
17
|
+
const [adapter, setAdapter] = useState<SqliteAdapter | null>(null);
|
|
18
|
+
const [error, setError] = useState<Error | null>(null);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
let cancelled = false;
|
|
22
|
+
|
|
23
|
+
async function loadDb() {
|
|
24
|
+
try {
|
|
25
|
+
const response = await fetch("/data/database.db");
|
|
26
|
+
if (!response.ok) {
|
|
27
|
+
throw new Error(
|
|
28
|
+
`Failed to load database: ${response.status} ${response.statusText}`
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const buffer = await response.arrayBuffer();
|
|
33
|
+
if (cancelled) return;
|
|
34
|
+
|
|
35
|
+
const dbAdapter = new SqliteAdapter({
|
|
36
|
+
schema,
|
|
37
|
+
defaultLang: DEFAULT_LANG,
|
|
38
|
+
wasmPath: "/sql-wasm.wasm",
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
await dbAdapter.connect();
|
|
42
|
+
await dbAdapter.import(new Uint8Array(buffer));
|
|
43
|
+
|
|
44
|
+
if (!cancelled) {
|
|
45
|
+
setAdapter(dbAdapter);
|
|
46
|
+
}
|
|
47
|
+
} catch (err) {
|
|
48
|
+
if (!cancelled) {
|
|
49
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
loadDb();
|
|
55
|
+
|
|
56
|
+
return () => {
|
|
57
|
+
cancelled = true;
|
|
58
|
+
};
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
if (error) {
|
|
62
|
+
console.error(error);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (!adapter) {
|
|
66
|
+
return null;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<DbProvider
|
|
71
|
+
adapter={adapter}
|
|
72
|
+
lang={i18n?.language || DEFAULT_LANG}
|
|
73
|
+
fallbackLang={DEFAULT_LANG}
|
|
74
|
+
>
|
|
75
|
+
{children}
|
|
76
|
+
</DbProvider>
|
|
77
|
+
);
|
|
78
|
+
}
|