@promakeai/cli 0.9.8 → 0.9.10
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 +111 -111
- package/dist/index.js +142 -142
- 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 +2 -2
- 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 +3 -3
- 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 +4 -4
- 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/verify-email-page.json +4 -4
- package/dist/registry/video-hero.json +4 -4
- package/dist/registry/youtube-embed.json +4 -4
- package/package.json +1 -1
- package/template/.env +5 -5
- package/template/README.md +54 -54
- package/template/eslint.config.js +41 -41
- package/template/index.html +237 -237
- package/template/package.json +96 -96
- 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 +21 -21
- 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/MetriaAnalytics.tsx +68 -68
- 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 +71 -71
- package/template/src/db/index.ts +21 -21
- package/template/src/db/provider.tsx +106 -106
- package/template/src/db/schema.json +278 -278
- package/template/src/db/types.ts +195 -195
- package/template/src/hooks/use-debounced-value.ts +12 -12
- package/template/src/hooks/use-page-title.ts +55 -55
- 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 +194 -194
|
@@ -1,71 +1,71 @@
|
|
|
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": "Built with Promake — a website created in minutes with AI.",
|
|
31
|
-
"author": "Site Name",
|
|
32
|
-
"ogTitle": "Site Name",
|
|
33
|
-
"ogDescription": "Built with Promake — a website created in minutes with AI.",
|
|
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
|
-
"database": {
|
|
65
|
-
"adapter": "rest"
|
|
66
|
-
},
|
|
67
|
-
"file": {
|
|
68
|
-
"maxFiles": 5,
|
|
69
|
-
"accept": ".pdf,.doc,.docx,.jpg,.jpeg,.png"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
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": "Built with Promake — a website created in minutes with AI.",
|
|
31
|
+
"author": "Site Name",
|
|
32
|
+
"ogTitle": "Site Name",
|
|
33
|
+
"ogDescription": "Built with Promake — a website created in minutes with AI.",
|
|
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
|
+
"database": {
|
|
65
|
+
"adapter": "rest"
|
|
66
|
+
},
|
|
67
|
+
"file": {
|
|
68
|
+
"maxFiles": 5,
|
|
69
|
+
"accept": ".pdf,.doc,.docx,.jpg,.jpeg,.png"
|
|
70
|
+
}
|
|
71
|
+
}
|
package/template/src/db/index.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
export { AppDbProvider } from "./provider";
|
|
2
|
-
|
|
3
|
-
import { parseJSONSchema } from "@promakeai/orm";
|
|
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
|
-
} from "@promakeai/dbreact";
|
|
18
|
-
|
|
19
|
-
export { RestAdapter, parseJSONSchema } from "@promakeai/orm";
|
|
20
|
-
|
|
21
|
-
export * from "./types";
|
|
1
|
+
export { AppDbProvider } from "./provider";
|
|
2
|
+
|
|
3
|
+
import { parseJSONSchema } from "@promakeai/orm";
|
|
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
|
+
} from "@promakeai/dbreact";
|
|
18
|
+
|
|
19
|
+
export { RestAdapter, parseJSONSchema } from "@promakeai/orm";
|
|
20
|
+
|
|
21
|
+
export * from "./types";
|
|
@@ -1,106 +1,106 @@
|
|
|
1
|
-
import { useEffect, useState, type ReactNode } from 'react';
|
|
2
|
-
import { useTranslation } from 'react-i18next';
|
|
3
|
-
import { DbProvider, SqliteAdapter } from '@promakeai/dbreact';
|
|
4
|
-
import { RestAdapter, parseJSONSchema } from '@promakeai/orm';
|
|
5
|
-
import type { IDataAdapter } from '@promakeai/orm';
|
|
6
|
-
import constants from '@/constants/constants.json';
|
|
7
|
-
import schemaJson from './schema.json';
|
|
8
|
-
|
|
9
|
-
const schema = parseJSONSchema(schemaJson as any);
|
|
10
|
-
|
|
11
|
-
interface AppDbProviderProps {
|
|
12
|
-
children: ReactNode;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const DEFAULT_LANG = constants?.site?.defaultLanguage || 'en';
|
|
16
|
-
const DB_CONFIG = (constants as any)?.database;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Read auth token from localStorage (where auth-core's Zustand store persists).
|
|
20
|
-
* Returns null when auth-core is not installed or user is not logged in.
|
|
21
|
-
*/
|
|
22
|
-
function getAuthToken(): string | null {
|
|
23
|
-
try {
|
|
24
|
-
const raw = localStorage.getItem('auth-storage');
|
|
25
|
-
if (!raw) return null;
|
|
26
|
-
const parsed = JSON.parse(raw);
|
|
27
|
-
return parsed?.state?.tokens?.accessToken ?? null;
|
|
28
|
-
} catch {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function AppDbProvider({ children }: AppDbProviderProps) {
|
|
34
|
-
const { i18n } = useTranslation();
|
|
35
|
-
const [adapter, setAdapter] = useState<IDataAdapter | null>(null);
|
|
36
|
-
const [error, setError] = useState<Error | null>(null);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
let cancelled = false;
|
|
40
|
-
|
|
41
|
-
async function loadDb() {
|
|
42
|
-
try {
|
|
43
|
-
if (DB_CONFIG?.adapter === 'rest') {
|
|
44
|
-
// REST API mode
|
|
45
|
-
const restAdapter = new RestAdapter({
|
|
46
|
-
baseUrl: 'https://' + import.meta.env.VITE_TENANT_UUID + '.backend.promake.ai',
|
|
47
|
-
databasePrefix: '/database',
|
|
48
|
-
schema,
|
|
49
|
-
defaultLang: DEFAULT_LANG,
|
|
50
|
-
getToken: getAuthToken,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
if (!cancelled) {
|
|
54
|
-
setAdapter(restAdapter);
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
// SQLite mode (default)
|
|
58
|
-
const response = await fetch('/data/database.db');
|
|
59
|
-
if (!response.ok) {
|
|
60
|
-
throw new Error(`Failed to load database: ${response.status} ${response.statusText}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const buffer = await response.arrayBuffer();
|
|
64
|
-
if (cancelled) return;
|
|
65
|
-
|
|
66
|
-
const dbAdapter = new SqliteAdapter({
|
|
67
|
-
schema,
|
|
68
|
-
defaultLang: DEFAULT_LANG,
|
|
69
|
-
wasmPath: '/sql-wasm.wasm',
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
await dbAdapter.connect();
|
|
73
|
-
await dbAdapter.import(new Uint8Array(buffer));
|
|
74
|
-
|
|
75
|
-
if (!cancelled) {
|
|
76
|
-
setAdapter(dbAdapter);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
} catch (err) {
|
|
80
|
-
if (!cancelled) {
|
|
81
|
-
setError(err instanceof Error ? err : new Error(String(err)));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
loadDb();
|
|
87
|
-
|
|
88
|
-
return () => {
|
|
89
|
-
cancelled = true;
|
|
90
|
-
};
|
|
91
|
-
}, []);
|
|
92
|
-
|
|
93
|
-
if (error) {
|
|
94
|
-
console.error(error);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (!adapter) {
|
|
98
|
-
return null;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<DbProvider adapter={adapter} lang={i18n?.language || DEFAULT_LANG} fallbackLang={DEFAULT_LANG} autoConnect={false}>
|
|
103
|
-
{children}
|
|
104
|
-
</DbProvider>
|
|
105
|
-
);
|
|
106
|
-
}
|
|
1
|
+
import { useEffect, useState, type ReactNode } from 'react';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
3
|
+
import { DbProvider, SqliteAdapter } from '@promakeai/dbreact';
|
|
4
|
+
import { RestAdapter, parseJSONSchema } from '@promakeai/orm';
|
|
5
|
+
import type { IDataAdapter } from '@promakeai/orm';
|
|
6
|
+
import constants from '@/constants/constants.json';
|
|
7
|
+
import schemaJson from './schema.json';
|
|
8
|
+
|
|
9
|
+
const schema = parseJSONSchema(schemaJson as any);
|
|
10
|
+
|
|
11
|
+
interface AppDbProviderProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const DEFAULT_LANG = constants?.site?.defaultLanguage || 'en';
|
|
16
|
+
const DB_CONFIG = (constants as any)?.database;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Read auth token from localStorage (where auth-core's Zustand store persists).
|
|
20
|
+
* Returns null when auth-core is not installed or user is not logged in.
|
|
21
|
+
*/
|
|
22
|
+
function getAuthToken(): string | null {
|
|
23
|
+
try {
|
|
24
|
+
const raw = localStorage.getItem('auth-storage');
|
|
25
|
+
if (!raw) return null;
|
|
26
|
+
const parsed = JSON.parse(raw);
|
|
27
|
+
return parsed?.state?.tokens?.accessToken ?? null;
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function AppDbProvider({ children }: AppDbProviderProps) {
|
|
34
|
+
const { i18n } = useTranslation();
|
|
35
|
+
const [adapter, setAdapter] = useState<IDataAdapter | null>(null);
|
|
36
|
+
const [error, setError] = useState<Error | null>(null);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
let cancelled = false;
|
|
40
|
+
|
|
41
|
+
async function loadDb() {
|
|
42
|
+
try {
|
|
43
|
+
if (DB_CONFIG?.adapter === 'rest') {
|
|
44
|
+
// REST API mode
|
|
45
|
+
const restAdapter = new RestAdapter({
|
|
46
|
+
baseUrl: 'https://' + import.meta.env.VITE_TENANT_UUID + '.backend.promake.ai',
|
|
47
|
+
databasePrefix: '/database',
|
|
48
|
+
schema,
|
|
49
|
+
defaultLang: DEFAULT_LANG,
|
|
50
|
+
getToken: getAuthToken,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
if (!cancelled) {
|
|
54
|
+
setAdapter(restAdapter);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
// SQLite mode (default)
|
|
58
|
+
const response = await fetch('/data/database.db');
|
|
59
|
+
if (!response.ok) {
|
|
60
|
+
throw new Error(`Failed to load database: ${response.status} ${response.statusText}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const buffer = await response.arrayBuffer();
|
|
64
|
+
if (cancelled) return;
|
|
65
|
+
|
|
66
|
+
const dbAdapter = new SqliteAdapter({
|
|
67
|
+
schema,
|
|
68
|
+
defaultLang: DEFAULT_LANG,
|
|
69
|
+
wasmPath: '/sql-wasm.wasm',
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
await dbAdapter.connect();
|
|
73
|
+
await dbAdapter.import(new Uint8Array(buffer));
|
|
74
|
+
|
|
75
|
+
if (!cancelled) {
|
|
76
|
+
setAdapter(dbAdapter);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
} catch (err) {
|
|
80
|
+
if (!cancelled) {
|
|
81
|
+
setError(err instanceof Error ? err : new Error(String(err)));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
loadDb();
|
|
87
|
+
|
|
88
|
+
return () => {
|
|
89
|
+
cancelled = true;
|
|
90
|
+
};
|
|
91
|
+
}, []);
|
|
92
|
+
|
|
93
|
+
if (error) {
|
|
94
|
+
console.error(error);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (!adapter) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<DbProvider adapter={adapter} lang={i18n?.language || DEFAULT_LANG} fallbackLang={DEFAULT_LANG} autoConnect={false}>
|
|
103
|
+
{children}
|
|
104
|
+
</DbProvider>
|
|
105
|
+
);
|
|
106
|
+
}
|