Skip to content

Commit

Permalink
Added warning if OPFS config is invalid. Moved viewport meta tag to i…
Browse files Browse the repository at this point in the history
…ndex.html.
  • Loading branch information
Chriztiaan committed Dec 13, 2024
1 parent a2b02df commit c2d0679
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
13 changes: 5 additions & 8 deletions demos/react-supabase-todolist/src/app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ root.render(<App />);

export function App() {
return (
<>
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
<ThemeProviderContainer>
<SystemProvider>
<RouterProvider router={router} />
</SystemProvider>
</ThemeProviderContainer>
</>
<ThemeProviderContainer>
<SystemProvider>
<RouterProvider router={router} />
</SystemProvider>
</ThemeProviderContainer>
);
}
1 change: 1 addition & 0 deletions demos/react-supabase-todolist/src/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<html lang="en">
<head>
<meta name="theme-color" content="#c44eff" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="apple-touch-icon" href="/icons/icon.png" />
<link rel="stylesheet" href="./app/globals.css" />
<script type="module" src="./app/index.tsx"></script>
Expand Down
17 changes: 17 additions & 0 deletions packages/web/src/db/adapters/wa-sqlite/WASQLiteOpenFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export interface ResolvedWASQLiteOpenFactoryOptions extends ResolvedWebSQLOpenOp
export class WASQLiteOpenFactory extends AbstractWebSQLOpenFactory {
constructor(options: WASQLiteOpenFactoryOptions) {
super(options);

assertValidWASQLiteOpenFactoryOptions(options);
}

get waOptions(): WASQLiteOpenFactoryOptions {
Expand Down Expand Up @@ -84,3 +86,18 @@ export class WASQLiteOpenFactory extends AbstractWebSQLOpenFactory {
}
}
}

/**
* Asserts that the factory options are valid.
*/
function assertValidWASQLiteOpenFactoryOptions(options: WASQLiteOpenFactoryOptions): void {
// The OPFS VFS only works in dedicated web workers.
if ('vfs' in options && 'flags' in options) {
const { vfs, flags = {} } = options;
if (vfs !== WASQLiteVFS.IDBBatchAtomicVFS && 'useWebWorker' in flags && !flags.useWebWorker) {
throw new Error(
`Invalid configuration: The 'useWebWorker' flag must be true when using an OPFS-based VFS (${vfs}).`
);
}
}
}

0 comments on commit c2d0679

Please sign in to comment.