Skip to content

Commit 941eb93

Browse files
committed
refactor: restructure module to src directory, update dependencies, and setup playground
1 parent 93c84dd commit 941eb93

17 files changed

Lines changed: 394 additions & 12 deletions

.github/workflows/pages.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Deploy playground to GitHub Pages
2+
on:
3+
push:
4+
branches: [main]
5+
workflow_dispatch:
6+
permissions:
7+
contents: read
8+
pages: write
9+
id-token: write
10+
concurrency:
11+
group: pages
12+
cancel-in-progress: true
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
- uses: actions/setup-node@v6
19+
with:
20+
node-version: 22
21+
- run: npm i -g --force corepack@latest && corepack enable
22+
- run: npx nypm@latest i
23+
- run: npm run dev:prepare
24+
- run: npm run dev:generate
25+
env:
26+
NUXT_APP_BASE_URL: /app-debug/
27+
- uses: actions/upload-pages-artifact@v3
28+
with:
29+
path: playground/.output/public
30+
deploy:
31+
needs: build
32+
runs-on: ubuntu-latest
33+
environment:
34+
name: github-pages
35+
url: ${{ steps.deployment.outputs.page_url }}
36+
steps:
37+
- uses: actions/deploy-pages@v4

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,7 @@
11
node_modules
2+
.nuxt
3+
dist
4+
.output
5+
playground/.nuxt
6+
playground/node_modules
7+
._*

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This app for Open Web Desktop is a test module with window states information.
1515
## Installation
1616

1717
```bash
18-
owd install-app @owdproject/app-debug
18+
pnpm desktop add @owdproject/app-debug
1919
```
2020

2121
## License

package.json

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,51 @@
1313
"name": "Open Web Desktop Team",
1414
"url": "https://github.com/owdproject"
1515
},
16-
"peerDependencies": {
17-
"@owdproject/core": "^3.1.0"
16+
"type": "module",
17+
"exports": {
18+
".": {
19+
"types": "./dist/types.d.mts",
20+
"development": "./src/module.ts",
21+
"import": "./dist/module.mjs"
22+
}
23+
},
24+
"main": "./dist/module.mjs",
25+
"typesVersions": {
26+
"*": {
27+
".": [
28+
"./dist/types.d.mts"
29+
]
30+
}
31+
},
32+
"files": [
33+
"dist"
34+
],
35+
"nx": {
36+
"name": "app-debug"
37+
},
38+
"scripts": {
39+
"prepack": "nuxt-module-build build",
40+
"dev": "pnpm run dev:prepare && cd playground && pnpm exec nuxt dev",
41+
"dev:build": "nuxt build playground",
42+
"dev:generate": "NUXT_APP_BASE_URL=${NUXT_APP_BASE_URL:-/app-debug/} nuxt generate playground",
43+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && cd playground && pnpm exec nuxt prepare",
44+
"validate": "desktop validate ."
45+
},
46+
"dependencies": {
47+
"@nuxt/kit": "^4.4.6"
48+
},
49+
"devDependencies": {
50+
"@nuxt/devtools": "^3.2.4",
51+
"@nuxt/eslint-config": "^1.15.2",
52+
"@nuxt/module-builder": "^1.0.2",
53+
"@nuxt/schema": "^4.4.6",
54+
"@nuxt/test-utils": "^4.0.3",
55+
"@types/node": "latest",
56+
"changelogen": "^0.6.2",
57+
"eslint": "^10.4.0",
58+
"nuxt": "^4.4.6",
59+
"typescript": "~6.0.3",
60+
"vitest": "^4.1.7",
61+
"vue-tsc": "^3.3.1"
1862
}
1963
}

playground/app/app.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<Desktop />
3+
</template>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { nextTick } from 'vue'
2+
import { defineNuxtPlugin } from 'nuxt/app'
3+
import { useApplicationManager } from '@owdproject/core/runtime/composables/useApplicationManager'
4+
5+
const APP_ID = 'org.owdproject.debug'
6+
const WINDOW_MODEL = 'main'
7+
8+
export default defineNuxtPlugin({
9+
name: 'app-debug-playground-launch',
10+
dependsOn: ['owd-app-debug-register'],
11+
async setup(nuxtApp) {
12+
if (!import.meta.dev) return
13+
14+
const applicationManager = useApplicationManager()
15+
16+
async function surfaceWindow() {
17+
if (!applicationManager.isAppDefined(APP_ID)) return false
18+
const app = applicationManager.getAppById(APP_ID)!
19+
if (app.storeWindows.$persistedState) {
20+
await app.storeWindows.$persistedState.isReady()
21+
}
22+
app.closeAllWindows()
23+
app.storeWindows.windows = {}
24+
await applicationManager.execAppCommand(APP_ID, "debug")
25+
const window = app.getFirstWindowByModel(WINDOW_MODEL)
26+
if (window) {
27+
window.actions.setActive(true)
28+
window.actions.bringToFront()
29+
}
30+
return Boolean(window)
31+
}
32+
33+
nuxtApp.hook('app:mounted', async () => {
34+
await nextTick()
35+
36+
for (let attempt = 0; attempt < 80; attempt++) {
37+
if (await surfaceWindow()) return
38+
await new Promise((resolve) => setTimeout(resolve, 50))
39+
}
40+
})
41+
},
42+
})

playground/desktop.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineDesktopConfig } from '@owdproject/core'
2+
3+
export default defineDesktopConfig({
4+
theme: '@owdproject/theme-nova',
5+
apps: ['@owdproject/app-debug'],
6+
systemBar: { enabled: true, startButton: true },
7+
})

playground/nuxt.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export default defineNuxtConfig({
2+
modules: ['@owdproject/core'],
3+
app: { baseURL: process.env.NUXT_APP_BASE_URL || '/' },
4+
i18n: { strategy: 'no_prefix' },
5+
devtools: { enabled: true },
6+
compatibilityDate: 'latest',
7+
ssr: false,
8+
})

playground/package.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"name": "@owdproject/app-debug-playground",
3+
"private": true,
4+
"type": "module",
5+
"scripts": {
6+
"dev": "nuxt dev",
7+
"build": "nuxt build",
8+
"generate": "nuxt generate"
9+
},
10+
"dependencies": {
11+
"@owdproject/app-debug": "latest",
12+
"@owdproject/core": "^3.4.0",
13+
"@owdproject/theme-nova": "^0.0.2"
14+
}
15+
}

playground/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{ "extends": "./.nuxt/tsconfig.json" }

0 commit comments

Comments
 (0)