@promakeai/cli 0.6.3 → 0.7.1

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.
Files changed (133) hide show
  1. package/README.md +71 -71
  2. package/dist/index.js +317 -429
  3. package/dist/registry/about-page.json +3 -3
  4. package/dist/registry/about-section.json +4 -4
  5. package/dist/registry/animations.json +2 -2
  6. package/dist/registry/announcement-bar.json +4 -4
  7. package/dist/registry/api.json +1 -1
  8. package/dist/registry/auth-core.json +3 -3
  9. package/dist/registry/bento-grid-section.json +4 -4
  10. package/dist/registry/blog-core.json +5 -5
  11. package/dist/registry/blog-list-page.json +4 -4
  12. package/dist/registry/blog-section.json +4 -4
  13. package/dist/registry/cards-carousel-section.json +4 -4
  14. package/dist/registry/cart-drawer.json +4 -4
  15. package/dist/registry/cart-page.json +4 -4
  16. package/dist/registry/case-study-page.json +3 -3
  17. package/dist/registry/category-section.json +4 -4
  18. package/dist/registry/checkout-page.json +4 -4
  19. package/dist/registry/coming-soon-page-minimal.json +4 -4
  20. package/dist/registry/coming-soon-page.json +4 -4
  21. package/dist/registry/contact-info-grid.json +4 -4
  22. package/dist/registry/contact-page-centered.json +4 -4
  23. package/dist/registry/contact-page-map-overlay.json +3 -3
  24. package/dist/registry/contact-page-map-split.json +3 -3
  25. package/dist/registry/contact-page-split.json +4 -4
  26. package/dist/registry/contact-page.json +4 -4
  27. package/dist/registry/content-section.json +4 -4
  28. package/dist/registry/cookie-consent.json +4 -4
  29. package/dist/registry/cookies-page.json +3 -3
  30. package/dist/registry/cta-section.json +3 -3
  31. package/dist/registry/ecommerce-core.json +8 -9
  32. package/dist/registry/empty-page.json +3 -3
  33. package/dist/registry/faq-categorized.json +4 -4
  34. package/dist/registry/faq-simple.json +4 -4
  35. package/dist/registry/favorites-blog-block.json +1 -1
  36. package/dist/registry/favorites-blog-page.json +4 -4
  37. package/dist/registry/favorites-ecommerce-block.json +1 -1
  38. package/dist/registry/favorites-ecommerce-page.json +4 -4
  39. package/dist/registry/feature-section.json +3 -3
  40. package/dist/registry/featured-products.json +4 -4
  41. package/dist/registry/footer-detailed.json +4 -4
  42. package/dist/registry/footer-minimal.json +3 -3
  43. package/dist/registry/footer.json +3 -3
  44. package/dist/registry/forgot-password-page-split.json +4 -4
  45. package/dist/registry/forgot-password-page.json +4 -4
  46. package/dist/registry/google-adsense.json +4 -4
  47. package/dist/registry/google-map.json +2 -2
  48. package/dist/registry/header-centered-pill.json +4 -4
  49. package/dist/registry/header-ecommerce.json +4 -4
  50. package/dist/registry/header-mega.json +4 -4
  51. package/dist/registry/header-minimal.json +4 -4
  52. package/dist/registry/header-simple.json +3 -3
  53. package/dist/registry/hero-carousel.json +3 -3
  54. package/dist/registry/hero-cta.json +4 -4
  55. package/dist/registry/hero-gradient.json +4 -4
  56. package/dist/registry/hero-grid.json +4 -4
  57. package/dist/registry/hero-profile.json +3 -3
  58. package/dist/registry/hero.json +3 -3
  59. package/dist/registry/index.json +103 -103
  60. package/dist/registry/landing-page-app.json +3 -3
  61. package/dist/registry/landing-page-saas.json +3 -3
  62. package/dist/registry/login-page-split.json +4 -4
  63. package/dist/registry/login-page.json +4 -4
  64. package/dist/registry/logo-cloud.json +4 -4
  65. package/dist/registry/masonry-grid.json +3 -3
  66. package/dist/registry/my-orders-page.json +4 -4
  67. package/dist/registry/newsletter-section.json +4 -4
  68. package/dist/registry/order-card-compact.json +3 -3
  69. package/dist/registry/order-confirmation-page.json +4 -4
  70. package/dist/registry/order-detail-block.json +1 -1
  71. package/dist/registry/orders-list-block.json +1 -1
  72. package/dist/registry/payment-success-block.json +2 -2
  73. package/dist/registry/portfolio-page.json +4 -4
  74. package/dist/registry/post-card.json +4 -4
  75. package/dist/registry/post-detail-block.json +4 -4
  76. package/dist/registry/post-detail-page.json +4 -4
  77. package/dist/registry/pricing-card.json +3 -3
  78. package/dist/registry/pricing-page.json +4 -4
  79. package/dist/registry/pricing-section.json +4 -4
  80. package/dist/registry/privacy-page.json +3 -3
  81. package/dist/registry/product-card-detailed.json +4 -4
  82. package/dist/registry/product-card-hover.json +4 -4
  83. package/dist/registry/product-card.json +4 -4
  84. package/dist/registry/product-detail-block.json +2 -2
  85. package/dist/registry/product-detail-page.json +4 -4
  86. package/dist/registry/product-detail-section.json +4 -4
  87. package/dist/registry/product-quick-view.json +4 -4
  88. package/dist/registry/products-page.json +4 -4
  89. package/dist/registry/reading-progress.json +4 -4
  90. package/dist/registry/register-page-split.json +4 -4
  91. package/dist/registry/register-page.json +4 -4
  92. package/dist/registry/related-posts-block.json +1 -1
  93. package/dist/registry/related-products-block.json +2 -2
  94. package/dist/registry/reset-password-page-split.json +4 -4
  95. package/dist/registry/reset-password-page.json +4 -4
  96. package/dist/registry/service-card.json +1 -1
  97. package/dist/registry/share-buttons.json +4 -4
  98. package/dist/registry/skill-card.json +1 -1
  99. package/dist/registry/team-page.json +4 -4
  100. package/dist/registry/terms-page.json +3 -3
  101. package/dist/registry/testimonials-carousel.json +4 -4
  102. package/dist/registry/testimonials-grid.json +4 -4
  103. package/dist/registry/timeline-section.json +4 -4
  104. package/dist/registry/video-hero.json +4 -4
  105. package/dist/registry/youtube-embed.json +4 -4
  106. package/package.json +56 -59
  107. package/template/.env +6 -6
  108. package/template/README.md +54 -54
  109. package/template/eslint.config.js +41 -41
  110. package/template/package.json +94 -94
  111. package/template/public/_redirects +1 -1
  112. package/template/public/robots.txt +14 -14
  113. package/template/scripts/init-db.ts +18 -18
  114. package/template/src/App.tsx +19 -19
  115. package/template/src/components/FormField.tsx +48 -48
  116. package/template/src/components/FormFileInput.tsx +75 -75
  117. package/template/src/components/GoogleAnalytics.tsx +34 -34
  118. package/template/src/components/LanguageSwitcher.tsx +53 -53
  119. package/template/src/components/PasswordInput.tsx +60 -60
  120. package/template/src/components/ScriptInjector.tsx +62 -62
  121. package/template/src/components/Stack.tsx +39 -39
  122. package/template/src/constants/constants.json +67 -67
  123. package/template/src/db/index.ts +20 -20
  124. package/template/src/db/provider.tsx +78 -78
  125. package/template/src/db/schema.json +258 -258
  126. package/template/src/db/types.ts +195 -195
  127. package/template/src/hooks/use-debounced-value.ts +12 -12
  128. package/template/src/lang/index.ts +90 -90
  129. package/template/src/lib/api.ts +345 -345
  130. package/template/src/lib/env.ts +19 -19
  131. package/template/src/router.tsx +14 -14
  132. package/template/src/vite-env.d.ts +1 -1
  133. package/template/vite.config.ts +68 -68
@@ -1,62 +1,62 @@
1
- import { useEffect, useRef } from "react";
2
- import constants from "@/constants/constants.json";
3
-
4
- function injectScript(html: string, target: "head" | "body", position: "start" | "end", marker: string) {
5
- if (!html) return;
6
-
7
- // Check if already injected
8
- if (document.querySelector(`[data-injected="${marker}"]`)) return;
9
-
10
- const container = document.createElement("div");
11
- container.innerHTML = html;
12
-
13
- const targetElement = target === "head" ? document.head : document.body;
14
-
15
- // Create wrapper with marker
16
- const wrapper = document.createDocumentFragment();
17
-
18
- Array.from(container.childNodes).forEach((node) => {
19
- if (node.nodeName === "SCRIPT") {
20
- // Recreate script for execution
21
- const script = node as HTMLScriptElement;
22
- const newScript = document.createElement("script");
23
- newScript.setAttribute("data-injected", marker);
24
- Array.from(script.attributes).forEach((attr) => {
25
- newScript.setAttribute(attr.name, attr.value);
26
- });
27
- if (script.innerHTML) {
28
- newScript.innerHTML = script.innerHTML;
29
- }
30
- wrapper.appendChild(newScript);
31
- } else {
32
- const clone = node.cloneNode(true) as HTMLElement;
33
- if (clone.setAttribute) {
34
- clone.setAttribute("data-injected", marker);
35
- }
36
- wrapper.appendChild(clone);
37
- }
38
- });
39
-
40
- if (position === "start") {
41
- targetElement.insertBefore(wrapper, targetElement.firstChild);
42
- } else {
43
- targetElement.appendChild(wrapper);
44
- }
45
- }
46
-
47
- export function ScriptInjector() {
48
- const injected = useRef(false);
49
- const { headStart, headEnd, bodyStart, bodyEnd } = constants.scripts;
50
-
51
- useEffect(() => {
52
- if (injected.current) return;
53
- injected.current = true;
54
-
55
- injectScript(headStart, "head", "start", "head-start");
56
- injectScript(headEnd, "head", "end", "head-end");
57
- injectScript(bodyStart, "body", "start", "body-start");
58
- injectScript(bodyEnd, "body", "end", "body-end");
59
- }, []);
60
-
61
- return null;
62
- }
1
+ import { useEffect, useRef } from "react";
2
+ import constants from "@/constants/constants.json";
3
+
4
+ function injectScript(html: string, target: "head" | "body", position: "start" | "end", marker: string) {
5
+ if (!html) return;
6
+
7
+ // Check if already injected
8
+ if (document.querySelector(`[data-injected="${marker}"]`)) return;
9
+
10
+ const container = document.createElement("div");
11
+ container.innerHTML = html;
12
+
13
+ const targetElement = target === "head" ? document.head : document.body;
14
+
15
+ // Create wrapper with marker
16
+ const wrapper = document.createDocumentFragment();
17
+
18
+ Array.from(container.childNodes).forEach((node) => {
19
+ if (node.nodeName === "SCRIPT") {
20
+ // Recreate script for execution
21
+ const script = node as HTMLScriptElement;
22
+ const newScript = document.createElement("script");
23
+ newScript.setAttribute("data-injected", marker);
24
+ Array.from(script.attributes).forEach((attr) => {
25
+ newScript.setAttribute(attr.name, attr.value);
26
+ });
27
+ if (script.innerHTML) {
28
+ newScript.innerHTML = script.innerHTML;
29
+ }
30
+ wrapper.appendChild(newScript);
31
+ } else {
32
+ const clone = node.cloneNode(true) as HTMLElement;
33
+ if (clone.setAttribute) {
34
+ clone.setAttribute("data-injected", marker);
35
+ }
36
+ wrapper.appendChild(clone);
37
+ }
38
+ });
39
+
40
+ if (position === "start") {
41
+ targetElement.insertBefore(wrapper, targetElement.firstChild);
42
+ } else {
43
+ targetElement.appendChild(wrapper);
44
+ }
45
+ }
46
+
47
+ export function ScriptInjector() {
48
+ const injected = useRef(false);
49
+ const { headStart, headEnd, bodyStart, bodyEnd } = constants.scripts;
50
+
51
+ useEffect(() => {
52
+ if (injected.current) return;
53
+ injected.current = true;
54
+
55
+ injectScript(headStart, "head", "start", "head-start");
56
+ injectScript(headEnd, "head", "end", "head-end");
57
+ injectScript(bodyStart, "body", "start", "body-start");
58
+ injectScript(bodyEnd, "body", "end", "body-end");
59
+ }, []);
60
+
61
+ return null;
62
+ }
@@ -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
  }
@@ -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
+ }