Skip to content

Commit

Permalink
Merge pull request #14 from neuralinterfaces/fix-demo
Browse files Browse the repository at this point in the history
Fix windows demo page and launch dev behavior for PWA
  • Loading branch information
garrettmflynn authored Nov 30, 2024
2 parents 46c31b5 + 4bd09de commit 5e96640
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@commoners/solidarity": "0.0.53",
"@commoners/splash-screen": "0.0.52",
"@commoners/testing": "0.0.53",
"@commoners/windows": "0.0.52",
"@commoners/windows": "0.0.53",
"@vitest/coverage-v8": "^2.0.3",
"search-insights": "^2.15.0",
"commoners": "0.0.53",
Expand Down
1 change: 0 additions & 1 deletion packages/core/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { spawnProcess } from './utils/processes.js'
import { createServer } from './utils/server.js'

import * as mobile from './mobile/index.js'
import { run } from 'node:test';

const open = import('open').then(m => m.default)

Expand Down
8 changes: 7 additions & 1 deletion packages/core/utils/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import http from 'node:http'
import path from 'node:path';
import url from 'node:url';

import { readFileSync, statSync } from 'node:fs';
import { existsSync, readFileSync, statSync } from 'node:fs';


export const createServer = ({ root = process.cwd(), handler }) => {
Expand Down Expand Up @@ -36,6 +36,12 @@ export const createServer = ({ root = process.cwd(), handler }) => {
'.pdf': 'application/pdf',
'.doc': 'application/msword'
};

if (!existsSync(pathname)) {
res.statusCode = 404;
res.end(`File ${pathname} not found!`);
return;
}

if (statSync(pathname).isDirectory()) pathname = path.join(pathname, 'index' + ext);

Expand Down
4 changes: 2 additions & 2 deletions tests/demo/pages/windows/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { READY } from 'commoners:env'
import '../../style.css'

const app = document.getElementById('app')!
const popupButton = document.getElementById('popup')!

// ---------------------- Window Buttons ----------------------

Expand All @@ -29,7 +28,8 @@ const openWindow = async (type, windows) => {

const capitalize = (str) => str.charAt(0).toUpperCase() + str.slice(1)
READY.then(({ windows }) => {
if (!windows || (Object.keys(windows).length === 1 && windows.main)) popupButton.disabled = true
if (!windows) return app.innerHTML = '<p>Windows plugin is not available.</p>'
if (Object.keys(windows).length === 1 && windows.main) return `<p>Cannot open windows from a secondary window.</p>`


Object.entries(windows).forEach(([ name, manager ]) => {
Expand Down

0 comments on commit 5e96640

Please sign in to comment.