Skip to content

Commit

Permalink
Merge pull request #20 from neuralinterfaces/v0.0.59
Browse files Browse the repository at this point in the history
0.0.59 Release
  • Loading branch information
garrettmflynn authored Dec 9, 2024
2 parents e5e8448 + 2b2f1a1 commit 93bce59
Show file tree
Hide file tree
Showing 12 changed files with 57 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docs/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Follow the prompts to select your favorite framework and features.
After running `npm install`, add Commoners as a dependency:

```bash
npm install -D [email protected].58
npm install -D [email protected].59
```

## Configuring the `package.json` File
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
"@commoners/bluetooth": "0.0.55",
"@commoners/custom-protocol": "0.0.55",
"@commoners/serial": "0.0.55",
"@commoners/solidarity": "0.0.58",
"@commoners/solidarity": "0.0.59",
"@commoners/splash-screen": "0.0.55",
"@commoners/testing": "0.0.58",
"@commoners/testing": "0.0.59",
"@commoners/windows": "0.0.58",
"@vitest/coverage-v8": "^2.0.3",
"search-insights": "^2.15.0",
"commoners": "0.0.58",
"commoners": "0.0.59",
"vite": "^5.3.4",
"vitepress": "^1.3.1",
"vitest": "^2.0.3"
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "commoners",
"description": "Cross-Platform Development for the Rest of Us",
"version": "0.0.58",
"version": "0.0.59",
"type": "module",
"license": "MIT",
"engines": {
Expand All @@ -18,7 +18,7 @@
"watch": "vite build --watch"
},
"dependencies": {
"@commoners/solidarity": "^0.0.58",
"@commoners/solidarity": "^0.0.59",
"cac": "^6.7.14"
},
"devDependencies": {
Expand Down
27 changes: 23 additions & 4 deletions packages/core/assets/electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ function normalizeAndCompare(path1, path2, comparison = (a,b) => a === b) {
return comparison(decodePath(path1), decodePath(path2))
}

async function checkLinkType(url) {
try {
const response = await fetch(url, { method: 'HEAD' });
const contentDisposition = response.headers.get('Content-Disposition');
if (contentDisposition && contentDisposition.includes('attachment')) return 'download'; // Download if attachment
if (!response.headers.get('Content-Type').startsWith('text/html')) return 'download'; // Download if not an HTML file
return 'webpage';
} catch (error) { return 'unknown' }
}

// Custom Window Flags
// __main: Is Main Window
// __show: Used to block show behavior
Expand Down Expand Up @@ -297,13 +307,21 @@ const runWindowPlugins = async (win: BrowserWindow | null = null, type = 'load',
})


// CAtch all navigation events
win.webContents.on('will-navigate', (event, url) => {
// Catch all navigation events
win.webContents.on('will-navigate', async (event, url) => {

event.preventDefault()

const urlObj = new URL(url)
const file = urlObj.pathname
loadPage(win, file)
const isValid = (devServerURL && devServerURL.startsWith(urlObj.origin)) || urlObj.protocol === 'file:'

if (!isValid) {
const type = await checkLinkType(url)
if (type === 'download') return win.webContents.downloadURL(url) // Download
return shell.openExternal(url) // Opened externally
}

loadPage(win, urlObj.pathname) // Required for successful navigation relative to the root (e.g. "../..")
})


Expand Down Expand Up @@ -334,6 +352,7 @@ const runWindowPlugins = async (win: BrowserWindow | null = null, type = 'load',
// ------------------------ Default Quit Behavior ------------------------
ipcMain.once('commoners:quit', () => app.quit())

// ------------------------ Open Windows Externally ------------------------
win.webContents.setWindowOpenHandler(({ url }) => {
shell.openExternal(url);
return { action: 'deny' };
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@commoners/solidarity",
"description": "Build solidarity across platform",
"version": "0.0.58",
"version": "0.0.59",
"type": "module",
"license": "MIT",
"exports": {
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/windows/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
"vite": "^5.3.4"
},
"peerDependencies": {
"@commoners/solidarity": "^0.0.58"
"@commoners/solidarity": "^0.0.59"
}
}
4 changes: 2 additions & 2 deletions packages/testing/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@commoners/testing",
"version": "0.0.58",
"version": "0.0.59",
"license": "MIT",
"type": "module",
"main": "./dist/main.cjs",
Expand All @@ -21,7 +21,7 @@
"postinstall": "pnpm exec playwright install chromium"
},
"dependencies": {
"@commoners/solidarity": "^0.0.58",
"@commoners/solidarity": "^0.0.59",
"playwright": "^1.48.0",
"vite": "^5.4.2",
"vitest": "^2.0.3"
Expand Down
4 changes: 2 additions & 2 deletions tests/demo/commoners.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
// const root/ = resolve(dirname(fileURLToPath(import.meta.url)))
const root = './'

import * as checksPlugin from './src/plugins/checks.ts'
import * as checksPlugin from './src/plugins/checks'

import splashPagePlugin from '@commoners/splash-screen'
import customProtocolPlugin from '@commoners/custom-protocol'
Expand Down Expand Up @@ -75,7 +75,7 @@ const config = defineConfig({
plugins: {
checks: checksPlugin,
splash: splashPagePlugin(splashSrc),
protocol: customProtocolPlugin('app', { supportFetchAPI: true }),
protocol: customProtocolPlugin('commoners', { supportFetchAPI: true }), // NOTE: Test this in detail with a build
windows: windowsPlugin({
popup: {
src: join(root, "pages", "windows", 'popup.html'),
Expand Down
23 changes: 16 additions & 7 deletions tests/demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@ <h1 id="name"></h1>

<main>
<section>
<h2>Core Features</h2>
<ol>
<li>
<a href="./pages/services/index.html">Services</a>
</li>
</ol>
</section>


<section>
<h2>Plugins</h2>
<h3>Desktop</h3>
<small><a href="" disabled>Download Link</a></small>
</section>

<section>
<h3>Mobile</h3>
<small><a href="" disabled>Download Link</a></small>
</section>

<section>
<h2>Community Plugins</h2>
<ol>
<li>
<a href="./pages/bluetooth/index.html">Bluetooth</a>
Expand All @@ -37,14 +49,11 @@ <h2>Plugins</h2>
</section>

<section>
<h2>Desktop</h2>
<small><a href="" disabled>Download Link</a></small>
<h2>Additional Resources</h2>
<p><a href="https://commoners.dev">Documentation</a></p>
<p><a href="https://github.com/neuralinterfaces/commoners">Source code</a> (<a href="https://github.com/neuralinterfaces/commoners/archive/refs/heads/main.zip">.zip</a>)</p>
</section>

<section>
<h2>Mobile</h2>
<small><a href="" disabled>Download Link</a></small>
</section>
</main>
</body>

Expand Down
2 changes: 1 addition & 1 deletion tests/demo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@commoners/test-app",
"version": "0.0.58",
"version": "0.0.59",
"private": true,
"description": "A test app for the commoners library",
"repository": {
Expand Down
5 changes: 4 additions & 1 deletion tests/demo/src/plugins/checks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import { fileURLToPath } from "node:url";
let src: string | null = null
try { src = resolve(fileURLToPath(import.meta.url)) } catch {}

export const isSupported = { mobile: true, web: true }
export const isSupported = {
mobile: true,
web: true
}

export function load () {
const { commoners } = globalThis
Expand Down
3 changes: 1 addition & 2 deletions tests/demo/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
h1 {
font-size: 3.2em;
line-height: 1.1;
margin: 0;
margin-bottom: 0.5em;
}

h2 {
h1, h2, h3, h4 {
margin: 0;
}

Expand Down

0 comments on commit 93bce59

Please sign in to comment.