Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows demo page and launch dev behavior for PWA #14

Merged
merged 2 commits into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading