/
githubmirror
/
tldraw
Обзор
Документация
Войти
/
githubmirror
/
tldraw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
apps/vscode/extension/src/file.ts
36 строк
859 B
Mime Čuvalo
npm: upgrade eslint v8 → v9 (#4757)
23 окт 2024, 17:55
Не верифицирован
23 окт 2024, 17:55
b301aeb
Код
Авторство
О чём код?
import { TldrawFile, createTLSchema } from 'tldraw' import * as vscode from 'vscode' import { nicelog } from './utils' export const defaultFileContents: TldrawFile = { tldrawFileFormatVersion: 1, schema: createTLSchema().serialize(), records: [], } export const fileContentWithErrors: TldrawFile = { tldrawFileFormatVersion: 1, schema: createTLSchema().serialize(), records: [{ typeName: 'shape', id: null } as any], } export function loadFile(fileContents: string): TldrawFile { if (!fileContents) return defaultFileContents try { return JSON.parse(fileContents) as TldrawFile } catch { return fileContentWithErrors } } export async function fileExists(destination: vscode.Uri) { try { await vscode.workspace.fs.stat(destination) return true } catch (e: any) { if (e.code !== 'FileNotFound') { nicelog(e) } return false } }