move fs import after dom load

master
howard 2021-04-23 16:53:33 -07:00
parent b657bfb6ba
commit ac01c351d5
3 changed files with 12 additions and 8 deletions

File diff suppressed because one or more lines are too long

View File

@ -37,6 +37,7 @@ const App = ({ store }) => {
} }
export let sce export let sce
export let fs
document.addEventListener('DOMContentLoaded', async () => { document.addEventListener('DOMContentLoaded', async () => {
@ -46,6 +47,8 @@ document.addEventListener('DOMContentLoaded', async () => {
ReactDOM.render(<App store={store} />, document.getElementById('react')); ReactDOM.render(<App store={store} />, document.getElementById('react'));
fs = await import ('../../node_modules/browser-fs-access/dist/index')
}); });
// window.store = store // window.store = store

View File

@ -5,12 +5,12 @@
// fileSave, // fileSave,
// } from '../../extlib/fs/index'; // } from '../../extlib/fs/index';
import { // import {
fileOpen, // fileOpen,
fileSave, // fileSave,
} from 'browser-fs-access'; // } from 'browser-fs-access';
import {sce} from './app' import {sce, fs} from './app'
// https://web.dev/file-system-access/ // https://web.dev/file-system-access/
@ -38,7 +38,7 @@ export async function saveFile(fileHandle, file, dispatch) {
return await saveFileAs(file, dispatch); return await saveFileAs(file, dispatch);
} }
await fileSave(new Blob([file], { type: 'application/json' }), undefined, fileHandle, true) await fs.fileSave(new Blob([file], { type: 'application/json' }), undefined, fileHandle, true)
dispatch({ type: 'set-modified', status: false }) dispatch({ type: 'set-modified', status: false })
} catch (ex) { } catch (ex) {
@ -51,7 +51,7 @@ export async function saveFile(fileHandle, file, dispatch) {
export async function saveFileAs(file, dispatch) { export async function saveFileAs(file, dispatch) {
try { try {
const fileHandle = await fileSave(new Blob([file], { type: 'application/json' }), { const fileHandle = await fs.fileSave(new Blob([file], { type: 'application/json' }), {
extensions: ['.json'], extensions: ['.json'],
}) })
@ -80,7 +80,7 @@ export async function openFile(dispatch) {
description: 'Part files', description: 'Part files',
}; };
file = await fileOpen(options); file = await fs.fileOpen(options);
} catch (ex) { } catch (ex) {
if (ex.name === 'AbortError') { if (ex.name === 'AbortError') {