Skip to content

Commit ab57781

Browse files
committed
Migrate to using vite.
1 parent f3851b1 commit ab57781

File tree

196 files changed

+1636
-5984
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+1636
-5984
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
### OSX ###
22
.DS_Store
3+
.cursor
34

45
.vscode
56
logs
@@ -17,8 +18,9 @@ node_modules/
1718
*.map
1819

1920
.sass-cache
20-
### folders built by preact or gulp
21+
### folders built by vite, preact or gulp
2122
/build/
23+
/dist/
2224
/extension/
2325
/app/
2426

package.json

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33
"version": "1.0.24",
44
"description": "A real-time tool for generating sequence diagrams",
55
"main": "index.html",
6+
"type": "module",
67
"scripts": {
78
"engine": "use yarn instead of npm please",
89
"start": "if-env NODE_ENV=production && yarn serve || yarn dev",
9-
"build": "preact build --template src/index.html --no-inline-css --no-prerender --no-sw",
10+
"build": "vite build",
1011
"release": "gulp release",
1112
"prep:release:git-tag-push": "git tag release-`date +%Y%m%d%H%M` && git push origin release-`date +%Y%m%d%H%M`",
12-
"dev": "preact watch --template src/index.html --no-prerender",
13+
"dev": "vite",
14+
"preview": "vite preview",
1315
"lint": "eslint src",
1416
"test": "jest ./",
1517
"deploy:staging": "firebase deploy --project staging",
@@ -25,6 +27,7 @@
2527
},
2628
"eslintIgnore": [
2729
"build/*",
30+
"dist/*",
2831
"src/lib/",
2932
"src/tests/",
3033
"src/CodeMirror.js",
@@ -39,6 +42,9 @@
3942
"devDependencies": {
4043
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
4144
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
45+
"@preact/preset-vite": "^2.10.1",
46+
"@vitejs/plugin-legacy": "^6.1.1",
47+
"autoprefixer": "^10.4.21",
4248
"babel-minify": "^0.5.2",
4349
"enzyme": "^3.11.0",
4450
"enzyme-adapter-preact-pure": "^2.3.0",
@@ -55,12 +61,14 @@
5561
"gulp-zip": "^5.0.2",
5662
"jest": "^24.9.0",
5763
"jest-preset-preact": "^1.0.0",
64+
"postcss": "^8.5.4",
5865
"postcss-custom-media": "^10.0.4",
59-
"preact-cli": "^3.5.1",
6066
"prettier": "^3.2.5",
6167
"run-sequence": "^2.2.1",
6268
"sirv-cli": "1.0.3",
63-
"tailwindcss": "^3.4.3"
69+
"tailwindcss": "^3.4.3",
70+
"terser": "^5.41.0",
71+
"vite": "^6.3.5"
6472
},
6573
"dependencies": {
6674
"@emmetio/codemirror-plugin": "^1.1.3",
@@ -82,6 +90,7 @@
8290
"http-server": "^0.12.3",
8391
"jszip": "3.8.0",
8492
"preact": "10.18.1",
93+
"preact-compat": "^3.19.0",
8594
"preact-render-to-string": "^6.2.2",
8695
"preact-router": "^4.1.2",
8796
"split.js": "1.6.0",

postcss.config.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default {
2+
plugins: {
3+
'postcss-custom-media': {},
4+
tailwindcss: {},
5+
autoprefixer: {},
6+
},
7+
};

preact.config.js

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/components/CheatSheetModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Dialog from '@radix-ui/react-dialog';
2-
import React from 'preact';
2+
import { h } from 'preact';
33

44
const CheatSheetModal = ({ open, onClose }) => {
55
return (

src/components/ContentWrap.jsx

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { Component } from 'preact';
1+
import { h, Component } from 'preact';
22
import { saveAs } from 'file-saver';
33
import UserCodeMirror from './UserCodeMirror.jsx';
44
import Toolbox from './Toolbox.jsx';
@@ -287,13 +287,31 @@ export default class ContentWrap extends Component {
287287

288288
showErrors(lang, errors) {
289289
var editor = this.cm[lang];
290+
291+
// Safety checks to prevent CodeMirror errors
292+
if (!editor || !editor.getDoc()) {
293+
console.warn(`Editor for ${lang} is not properly initialized`);
294+
return;
295+
}
296+
290297
errors.forEach(function (e) {
291-
editor.operation(function () {
292-
var n = document.createElement('div');
293-
n.setAttribute('data-title', e.message);
294-
n.classList.add('gutter-error-marker');
295-
editor.setGutterMarker(e.lineNumber, 'error-gutter', n);
296-
});
298+
try {
299+
editor.operation(function () {
300+
// Additional safety check for line number validity
301+
const doc = editor.getDoc();
302+
const lineCount = doc.lineCount();
303+
304+
// Ensure lineNumber is valid (0-based indexing)
305+
const lineNumber = Math.max(0, Math.min(e.lineNumber || 0, lineCount - 1));
306+
307+
var n = document.createElement('div');
308+
n.setAttribute('data-title', e.message);
309+
n.classList.add('gutter-error-marker');
310+
editor.setGutterMarker(lineNumber, 'error-gutter', n);
311+
});
312+
} catch (error) {
313+
console.warn('Error setting gutter marker:', error);
314+
}
297315
});
298316
}
299317

src/components/CreateNewModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'preact';
1+
import { h } from 'preact';
22
import { ItemTile } from './ItemTile';
33
import templates from '../templateList';
44
import * as Dialog from '@radix-ui/react-dialog';

src/components/KeyboardShortcutsModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Dialog from '@radix-ui/react-dialog';
2-
import React from 'preact';
2+
import { h } from 'preact';
33

44
const KeyboardShortcutsModal = ({ open, onClose }) => {
55
return (

src/components/LibraryAutoSuggest.jsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ export class LibraryAutoSuggest extends Component {
3333
var line = this.currentLineNumber;
3434
return this.t.value.split('\n')[line - 1];
3535
}
36-
listMouseDownHandler() {}
3736
closeSuggestions() {
3837
this.list.classList.remove('is-open');
3938
this.isShowingSuggestions = false;

src/components/LoginModal.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { auth } from '../auth';
22
import * as Dialog from '@radix-ui/react-dialog';
3-
import { useEffect } from 'preact-compat';
3+
import { useEffect } from 'preact/hooks';
44
import mixpanel from '../services/mixpanel';
55

66
export default function LoginModal({ open, onClose }) {

0 commit comments

Comments
 (0)