@bardioc/create-bardioc-app 0.5.6 → 0.5.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/package.json +1 -1
- package/templates/_base/README.md +1 -1
- package/templates/angular/.env.example +4 -1
- package/templates/angular/package.json +2 -2
- package/templates/angular/scripts/dev-env.mjs +41 -0
- package/templates/angular/scripts/dev.mjs +27 -0
- package/templates/angular/scripts/sync-runtime-env.mjs +2 -28
- package/templates/angular/src/app/app.component.ts +5 -5
- package/templates/angular/src/styles.css +4 -0
- package/templates/nextjs/.env.example +4 -1
- package/templates/nextjs/app/page.tsx +11 -8
- package/templates/nextjs/next.config.ts +1 -1
- package/templates/nextjs/package.json +3 -3
- package/templates/nextjs/scripts/dev-env.mjs +41 -0
- package/templates/nextjs/scripts/dev.mjs +27 -0
- package/templates/preact/.env.example +3 -0
- package/templates/preact/package.json +2 -2
- package/templates/preact/src/App.tsx +5 -5
- package/templates/preact/vite.config.ts +4 -1
- package/templates/solid/.env.example +3 -0
- package/templates/solid/package.json +2 -2
- package/templates/solid/src/App.tsx +5 -5
- package/templates/solid/vite.config.ts +4 -1
- package/templates/svelte/.env.example +3 -0
- package/templates/svelte/package.json +2 -2
- package/templates/svelte/src/App.svelte +5 -5
- package/templates/svelte/vite.config.ts +4 -1
- package/templates/vite/.env.example +3 -0
- package/templates/vite/CLAUDE.md +34 -7
- package/templates/vite/package.json +3 -3
- package/templates/vite/src/auth/onboarding.tsx +4 -4
- package/templates/vite/src/climate/conditions-chart.tsx +2 -2
- package/templates/vite/src/climate/overview-view.tsx +1 -1
- package/templates/vite/src/climate/stations-view.tsx +3 -3
- package/templates/vite/src/climate/use-climate.ts +2 -2
- package/templates/vite/src/events/live-events-view.tsx +2 -2
- package/templates/vite/src/graph/explorer-view.tsx +4 -4
- package/templates/vite/src/locales/de.json +4 -4
- package/templates/vite/src/locales/en.json +44 -44
- package/templates/vite/src/profile/profile-view.tsx +5 -5
- package/templates/vite/src/shell/about-dialog.tsx +3 -3
- package/templates/vite/src/shell/app-shell.tsx +16 -12
- package/templates/vite/src/shell/header.tsx +24 -24
- package/templates/vite/vite.config.ts +4 -1
- package/templates/vue/.env.example +3 -0
- package/templates/vue/package.json +2 -2
- package/templates/vue/src/App.vue +5 -5
- package/templates/vue/vite.config.ts +4 -1
- package/templates/angular/scripts/dev-auth-proxy.mjs +0 -17
- package/templates/nextjs/scripts/dev-auth-proxy.mjs +0 -17
package/README.md
CHANGED
|
@@ -72,7 +72,7 @@ Generated apps can run standalone with the `DEV_SECRET` dev-auth proxy.
|
|
|
72
72
|
2. Fill in `VITE_APP_NAME`, `DEV_SECRET`, and `API_BASE_URL`
|
|
73
73
|
3. Run `npm run dev`
|
|
74
74
|
|
|
75
|
-
When running outside the host iframe, the SDK proxies `/rest/*` to `API_BASE_URL` with the `X-Dev-Secret` header and `installDevBridge()` handles SDK messages. Vite templates do this through the `bardiocDevAuth` plugin; the angular and nextjs templates run `scripts/dev
|
|
75
|
+
When running outside the host iframe, the SDK proxies `/rest/*` to `API_BASE_URL` with the `X-Dev-Secret` header and `installDevBridge()` handles SDK messages. Vite templates do this through the `bardiocDevAuth` plugin; the angular and nextjs templates run `scripts/dev.mjs`, which starts it alongside their dev server.
|
|
76
76
|
|
|
77
77
|
## Options
|
|
78
78
|
|
package/package.json
CHANGED
|
@@ -18,7 +18,7 @@ npm run dev # http://localhost:{{PORT}}
|
|
|
18
18
|
|
|
19
19
|
`npm run dev` starts the dev server as a local preview shell. Live SDK data comes when the app is
|
|
20
20
|
opened inside the host, or standalone once `DEV_SECRET` and `API_BASE_URL` are set — the SDK then
|
|
21
|
-
proxies `/rest/*` to the BFF (via the `bardiocDevAuth` Vite plugin, or `scripts/dev
|
|
21
|
+
proxies `/rest/*` to the BFF (via the `bardiocDevAuth` Vite plugin, or `scripts/dev.mjs`
|
|
22
22
|
in the angular and nextjs templates, which `npm run dev` starts alongside the dev server). See
|
|
23
23
|
`.env.example` for the required variables.
|
|
24
24
|
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
VITE_APP_NAME={{APP_NAME}}
|
|
3
3
|
|
|
4
4
|
# Paste the dev secret from the BardiocOS AppStore after registering your app.
|
|
5
|
-
# Used by the dev-auth proxy (scripts/dev
|
|
5
|
+
# Used by the dev-auth proxy (scripts/dev.mjs) to sign requests to the BFF.
|
|
6
6
|
DEV_SECRET=
|
|
7
7
|
|
|
8
8
|
# Base URL of the Bardioc BFF / backend-for-frontend (e.g. https://your-host).
|
|
9
9
|
API_BASE_URL=
|
|
10
|
+
|
|
11
|
+
# By default, the app will start on port {{PORT}}. Feel free to uncomment the following variable and change it to match your local setup preferences.
|
|
12
|
+
#LOCALHOST_PORT={{PORT}}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
"sync:runtime-env": "node ./scripts/sync-runtime-env.mjs",
|
|
7
7
|
"ng": "ng",
|
|
8
8
|
"predev": "npm run sync:runtime-env",
|
|
9
|
-
"dev": "node ./scripts/dev
|
|
9
|
+
"dev": "node ./scripts/dev.mjs",
|
|
10
10
|
"prebuild": "npm run sync:runtime-env",
|
|
11
11
|
"build": "ng build && node scripts/stamp-manifest.mjs dist/{{APP_NAME}}/browser",
|
|
12
12
|
"bundle": "ng build && node scripts/stamp-manifest.mjs dist/{{APP_NAME}}/browser && cd dist/{{APP_NAME}}/browser && zip -r ../../../{{APP_NAME}}.zip .",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"@angular/platform-browser": "^19.2.12",
|
|
29
29
|
"@angular/platform-browser-dynamic": "^19.2.12",
|
|
30
30
|
"@angular/router": "^19.2.12",
|
|
31
|
-
"@bardioc/app-sdk": "^0.
|
|
31
|
+
"@bardioc/app-sdk": "^0.5.0",
|
|
32
32
|
"rxjs": "~7.8.2",
|
|
33
33
|
"tslib": "^2.8.1",
|
|
34
34
|
"zone.js": "~0.15.1"
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
// The port a scaffolded app defaults to. LOCALHOST_PORT overrides it, from .env or the shell.
|
|
5
|
+
const DEFAULT_PORT = {{PORT}};
|
|
6
|
+
|
|
7
|
+
// The dev-auth proxy answers on the app port plus this offset — the same origin the app points
|
|
8
|
+
// installDevBridge at.
|
|
9
|
+
export const PROXY_PORT_OFFSET = 100;
|
|
10
|
+
|
|
11
|
+
// Neither Next nor Angular exposes import.meta.env to a node script, so dotenv values are read
|
|
12
|
+
// here the way Vite's loadEnv does it: a shell value always wins over the files.
|
|
13
|
+
export function readEnvValue(projectDir, key) {
|
|
14
|
+
let value;
|
|
15
|
+
|
|
16
|
+
for (const fileName of ['.env', '.env.local']) {
|
|
17
|
+
let source;
|
|
18
|
+
try {
|
|
19
|
+
source = readFileSync(join(projectDir, fileName), 'utf8');
|
|
20
|
+
} catch {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (const rawLine of source.split(/\r?\n/)) {
|
|
25
|
+
const line = rawLine.trim();
|
|
26
|
+
if (!line.startsWith(`${key}=`)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
value = line
|
|
30
|
+
.slice(key.length + 1)
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/^['"]|['"]$/g, '');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return process.env[key] ?? value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function resolveAppPort(projectDir) {
|
|
40
|
+
return Number(readEnvValue(projectDir, 'LOCALHOST_PORT')) || DEFAULT_PORT;
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { startDevAuthProxy } from '@bardioc/app-sdk/dev-proxy';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { dirname, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { PROXY_PORT_OFFSET, resolveAppPort } from './dev-env.mjs';
|
|
8
|
+
|
|
9
|
+
const projectDir = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
10
|
+
const port = resolveAppPort(projectDir);
|
|
11
|
+
|
|
12
|
+
// Angular's dev server cannot host the SDK Vite plugin, so the proxy runs beside it. Without a
|
|
13
|
+
// DEV_SECRET / API_BASE_URL it stays unstarted and the dev server runs alone, matching how the
|
|
14
|
+
// SDK Vite plugin disables itself.
|
|
15
|
+
const proxy = await startDevAuthProxy({ projectDir, port: port + PROXY_PORT_OFFSET });
|
|
16
|
+
|
|
17
|
+
// shell:true so npm's node_modules/.bin lookup works on Windows too, where the binary is a .cmd.
|
|
18
|
+
const server = spawn('ng', ['serve', '--port', String(port)], { stdio: 'inherit', shell: true });
|
|
19
|
+
|
|
20
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
21
|
+
process.on(signal, () => server.kill(signal));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
server.on('exit', (code, signal) => {
|
|
25
|
+
proxy?.close();
|
|
26
|
+
process.exit(signal ? 1 : (code ?? 0));
|
|
27
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { mkdirSync,
|
|
3
|
+
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { readEnvValue } from './dev-env.mjs';
|
|
6
7
|
|
|
7
8
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
8
9
|
const projectRoot = resolve(__dirname, '..');
|
|
@@ -19,30 +20,3 @@ writeFileSync(
|
|
|
19
20
|
'utf8'
|
|
20
21
|
);
|
|
21
22
|
|
|
22
|
-
// Angular has no import.meta.env, so the app slug is baked into a runtime script instead.
|
|
23
|
-
function readEnvValue(projectDir, key) {
|
|
24
|
-
let value;
|
|
25
|
-
|
|
26
|
-
for (const fileName of ['.env', '.env.local']) {
|
|
27
|
-
let source;
|
|
28
|
-
try {
|
|
29
|
-
source = readFileSync(join(projectDir, fileName), 'utf8');
|
|
30
|
-
} catch {
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (const rawLine of source.split(/\r?\n/)) {
|
|
35
|
-
const line = rawLine.trim();
|
|
36
|
-
if (!line.startsWith(`${key}=`)) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
value = line
|
|
40
|
-
.slice(key.length + 1)
|
|
41
|
-
.trim()
|
|
42
|
-
.replace(/^['"]|['"]$/g, '');
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// A shell value always wins over the dotenv files, like Vite's env loading.
|
|
47
|
-
return process.env[key] ?? value;
|
|
48
|
-
}
|
|
@@ -15,7 +15,7 @@ type ResultState =
|
|
|
15
15
|
standalone: true,
|
|
16
16
|
imports: [JsonPipe],
|
|
17
17
|
template: `
|
|
18
|
-
<div class="bg-background text-foreground min-h-screen">
|
|
18
|
+
<div class="bg-background text-foreground @container/app min-h-screen">
|
|
19
19
|
@if (showSdkDemo) {
|
|
20
20
|
<div class="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-3 p-4">
|
|
21
21
|
<div class="flex flex-col gap-1">
|
|
@@ -82,7 +82,7 @@ type ResultState =
|
|
|
82
82
|
<div class="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
|
|
83
83
|
<h1 class="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
84
84
|
<p class="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
|
|
85
|
-
Open this app inside Bardioc
|
|
85
|
+
Open this app inside Bardioc to use transport requests and send host notifications.
|
|
86
86
|
</p>
|
|
87
87
|
<div class="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
|
|
88
88
|
Outside the host iframe this page is only a local preview shell.
|
|
@@ -107,12 +107,12 @@ export class AppComponent {
|
|
|
107
107
|
this.result.set({ status: 'loading', request });
|
|
108
108
|
|
|
109
109
|
const startTime = Date.now();
|
|
110
|
-
this.bridge.notify('Getting user profile', 'info');
|
|
110
|
+
this.bridge.notify('Getting user profile…', 'info');
|
|
111
111
|
|
|
112
112
|
try {
|
|
113
113
|
const data = await this.bridge.transport.os.profile.get();
|
|
114
114
|
const duration = Date.now() - startTime;
|
|
115
|
-
this.bridge.notify(`Profile loaded (${duration}ms)
|
|
115
|
+
this.bridge.notify(`Profile loaded (${duration}ms).`, 'success');
|
|
116
116
|
this.result.set({ status: 'success', request, data });
|
|
117
117
|
} catch (err) {
|
|
118
118
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -125,7 +125,7 @@ export class AppComponent {
|
|
|
125
125
|
|
|
126
126
|
handleNotify(): void {
|
|
127
127
|
if (!this.bridge) return;
|
|
128
|
-
this.bridge.notify('Hello from {{DISPLAY_NAME}}', 'info');
|
|
128
|
+
this.bridge.notify('Hello from {{DISPLAY_NAME}}.', 'info');
|
|
129
129
|
this.result.set({
|
|
130
130
|
status: 'success',
|
|
131
131
|
request: 'SDK_NOTIFY',
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
NEXT_PUBLIC_APP_NAME={{APP_NAME}}
|
|
3
3
|
|
|
4
4
|
# Paste the dev secret from the BardiocOS AppStore after registering your app.
|
|
5
|
-
# Used by the dev-auth proxy (scripts/dev
|
|
5
|
+
# Used by the dev-auth proxy (scripts/dev.mjs) to sign requests to the BFF.
|
|
6
6
|
DEV_SECRET=
|
|
7
7
|
|
|
8
8
|
# Base URL of the Bardioc BFF / backend-for-frontend (e.g. https://your-host).
|
|
9
9
|
API_BASE_URL=
|
|
10
|
+
|
|
11
|
+
# By default, the app will start on port {{PORT}}. Feel free to uncomment the following variable and change it to match your local setup preferences.
|
|
12
|
+
#LOCALHOST_PORT={{PORT}}
|
|
@@ -12,8 +12,8 @@ type ResultState =
|
|
|
12
12
|
|
|
13
13
|
const APP_NAME = process.env.NEXT_PUBLIC_APP_NAME?.trim();
|
|
14
14
|
|
|
15
|
-
//
|
|
16
|
-
const
|
|
15
|
+
// The port the app falls back to when it is not being served over HTTP (LOCALHOST_PORT moves it).
|
|
16
|
+
const DEFAULT_PORT = Number('{{PORT}}');
|
|
17
17
|
|
|
18
18
|
function SdkDemo() {
|
|
19
19
|
const bridge = useSdk();
|
|
@@ -29,13 +29,13 @@ function SdkDemo() {
|
|
|
29
29
|
setResult({ status: 'loading', request });
|
|
30
30
|
|
|
31
31
|
const startTime = Date.now();
|
|
32
|
-
notify('Getting user profile', 'info');
|
|
32
|
+
notify('Getting user profile…', 'info');
|
|
33
33
|
|
|
34
34
|
try {
|
|
35
35
|
const data = await bridge.transport.os.profile.get();
|
|
36
36
|
|
|
37
37
|
const duration = Date.now() - startTime;
|
|
38
|
-
notify(`Profile loaded (${duration}ms)
|
|
38
|
+
notify(`Profile loaded (${duration}ms).`, 'success');
|
|
39
39
|
setResult({ status: 'success', request, data });
|
|
40
40
|
} catch (err) {
|
|
41
41
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -47,7 +47,7 @@ function SdkDemo() {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function handleNotify() {
|
|
50
|
-
notify('Hello from {{DISPLAY_NAME}}', 'info');
|
|
50
|
+
notify('Hello from {{DISPLAY_NAME}}.', 'info');
|
|
51
51
|
setResult({
|
|
52
52
|
status: 'success',
|
|
53
53
|
request: 'SDK_NOTIFY',
|
|
@@ -129,7 +129,7 @@ function PreviewShell() {
|
|
|
129
129
|
<div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
|
|
130
130
|
<h1 className="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
131
131
|
<p className="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
|
|
132
|
-
Open this app inside Bardioc
|
|
132
|
+
Open this app inside Bardioc to use transport requests and send host notifications.
|
|
133
133
|
</p>
|
|
134
134
|
<div className="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
|
|
135
135
|
Outside the host iframe this page is only a local preview shell.
|
|
@@ -147,12 +147,15 @@ export default function Page() {
|
|
|
147
147
|
|
|
148
148
|
useEffect(() => {
|
|
149
149
|
if (isDevStandalone()) {
|
|
150
|
-
|
|
150
|
+
// scripts/dev.mjs runs the dev-auth proxy on the app port + 100, so read the port the page
|
|
151
|
+
// is actually served on rather than the one baked in at scaffold time.
|
|
152
|
+
const appPort = Number(window.location.port) || DEFAULT_PORT;
|
|
153
|
+
installDevBridge({ apiBaseUrl: `http://127.0.0.1:${appPort + 100}/rest` });
|
|
151
154
|
}
|
|
152
155
|
}, []);
|
|
153
156
|
|
|
154
157
|
return (
|
|
155
|
-
<div className="bg-background text-foreground min-h-screen">
|
|
158
|
+
<div className="bg-background text-foreground @container/app min-h-screen">
|
|
156
159
|
{useSdkProvider ? (
|
|
157
160
|
<AppSdkProvider appId={APP_NAME}>
|
|
158
161
|
<SdkDemo />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NextConfig } from 'next';
|
|
2
2
|
|
|
3
|
-
// Standalone dev auth lives in scripts/dev
|
|
3
|
+
// Standalone dev auth lives in scripts/dev.mjs (the SDK dev-auth proxy), not here:
|
|
4
4
|
// the BFF needs Origin dropped and X-Requested-With stamped, which rewrites cannot do.
|
|
5
5
|
const nextConfig: NextConfig = {
|
|
6
6
|
output: 'export',
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"version": "0.0.1",
|
|
4
4
|
"private": true,
|
|
5
5
|
"scripts": {
|
|
6
|
-
"dev": "node ./scripts/dev
|
|
6
|
+
"dev": "node ./scripts/dev.mjs",
|
|
7
7
|
"build": "next build && node scripts/stamp-manifest.mjs out",
|
|
8
8
|
"bundle": "next build && node scripts/stamp-manifest.mjs out && cd out && zip -r ../{{APP_NAME}}.zip .",
|
|
9
9
|
"start": "next start",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"release:publish": "changeset publish"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@bardioc/app-sdk": "^0.
|
|
20
|
+
"@bardioc/app-sdk": "^0.5.0",
|
|
21
21
|
"next": "^15.3.2",
|
|
22
22
|
"react": "^19.2.5",
|
|
23
23
|
"react-dom": "^19.2.5"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@bardioc/configs": "
|
|
26
|
+
"@bardioc/configs": "0.2.1",
|
|
27
27
|
"@changesets/cli": "^2.31.0",
|
|
28
28
|
"@tailwindcss/postcss": "^4.2.4",
|
|
29
29
|
"@types/node": "^22.10.0",
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
// The port a scaffolded app defaults to. LOCALHOST_PORT overrides it, from .env or the shell.
|
|
5
|
+
const DEFAULT_PORT = {{PORT}};
|
|
6
|
+
|
|
7
|
+
// The dev-auth proxy answers on the app port plus this offset — the same origin the app points
|
|
8
|
+
// installDevBridge at.
|
|
9
|
+
export const PROXY_PORT_OFFSET = 100;
|
|
10
|
+
|
|
11
|
+
// Neither Next nor Angular exposes import.meta.env to a node script, so dotenv values are read
|
|
12
|
+
// here the way Vite's loadEnv does it: a shell value always wins over the files.
|
|
13
|
+
export function readEnvValue(projectDir, key) {
|
|
14
|
+
let value;
|
|
15
|
+
|
|
16
|
+
for (const fileName of ['.env', '.env.local']) {
|
|
17
|
+
let source;
|
|
18
|
+
try {
|
|
19
|
+
source = readFileSync(join(projectDir, fileName), 'utf8');
|
|
20
|
+
} catch {
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (const rawLine of source.split(/\r?\n/)) {
|
|
25
|
+
const line = rawLine.trim();
|
|
26
|
+
if (!line.startsWith(`${key}=`)) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
value = line
|
|
30
|
+
.slice(key.length + 1)
|
|
31
|
+
.trim()
|
|
32
|
+
.replace(/^['"]|['"]$/g, '');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return process.env[key] ?? value;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function resolveAppPort(projectDir) {
|
|
40
|
+
return Number(readEnvValue(projectDir, 'LOCALHOST_PORT')) || DEFAULT_PORT;
|
|
41
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { startDevAuthProxy } from '@bardioc/app-sdk/dev-proxy';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { dirname, resolve } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { PROXY_PORT_OFFSET, resolveAppPort } from './dev-env.mjs';
|
|
8
|
+
|
|
9
|
+
const projectDir = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
|
10
|
+
const port = resolveAppPort(projectDir);
|
|
11
|
+
|
|
12
|
+
// `next dev` cannot host the SDK Vite plugin, so the proxy runs beside it. Without a
|
|
13
|
+
// DEV_SECRET / API_BASE_URL it stays unstarted and the dev server runs alone, matching how the
|
|
14
|
+
// SDK Vite plugin disables itself.
|
|
15
|
+
const proxy = await startDevAuthProxy({ projectDir, port: port + PROXY_PORT_OFFSET });
|
|
16
|
+
|
|
17
|
+
// shell:true so npm's node_modules/.bin lookup works on Windows too, where the binary is a .cmd.
|
|
18
|
+
const server = spawn('next', ['dev', '--port', String(port)], { stdio: 'inherit', shell: true });
|
|
19
|
+
|
|
20
|
+
for (const signal of ['SIGINT', 'SIGTERM']) {
|
|
21
|
+
process.on(signal, () => server.kill(signal));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
server.on('exit', (code, signal) => {
|
|
25
|
+
proxy?.close();
|
|
26
|
+
process.exit(signal ? 1 : (code ?? 0));
|
|
27
|
+
});
|
|
@@ -7,3 +7,6 @@ DEV_SECRET=
|
|
|
7
7
|
|
|
8
8
|
# Base URL of the Bardioc BFF / backend-for-frontend (e.g. https://your-host).
|
|
9
9
|
API_BASE_URL=
|
|
10
|
+
|
|
11
|
+
# By default, the app will start on port {{PORT}}. Feel free to uncomment the following variable and change it to match your local setup preferences.
|
|
12
|
+
#LOCALHOST_PORT={{PORT}}
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"release:publish": "changeset publish"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@bardioc/app-sdk": "^0.
|
|
21
|
+
"@bardioc/app-sdk": "^0.5.0",
|
|
22
22
|
"preact": "^10.26.7"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@bardioc/configs": "
|
|
25
|
+
"@bardioc/configs": "0.2.1",
|
|
26
26
|
"@changesets/cli": "^2.31.0",
|
|
27
27
|
"@preact/preset-vite": "^2.10.6",
|
|
28
28
|
"@tailwindcss/vite": "^4.3.0",
|
|
@@ -22,13 +22,13 @@ function SdkDemo() {
|
|
|
22
22
|
setResult({ status: 'loading', request });
|
|
23
23
|
|
|
24
24
|
const startTime = Date.now();
|
|
25
|
-
notify('Getting user profile', 'info');
|
|
25
|
+
notify('Getting user profile…', 'info');
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
28
|
const data = await bridge.transport.os.profile.get();
|
|
29
29
|
|
|
30
30
|
const duration = Date.now() - startTime;
|
|
31
|
-
notify(`Profile loaded (${duration}ms)
|
|
31
|
+
notify(`Profile loaded (${duration}ms).`, 'success');
|
|
32
32
|
setResult({ status: 'success', request, data });
|
|
33
33
|
} catch (err) {
|
|
34
34
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -40,7 +40,7 @@ function SdkDemo() {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function handleNotify() {
|
|
43
|
-
notify('Hello from {{DISPLAY_NAME}}', 'info');
|
|
43
|
+
notify('Hello from {{DISPLAY_NAME}}.', 'info');
|
|
44
44
|
setResult({
|
|
45
45
|
status: 'success',
|
|
46
46
|
request: 'SDK_NOTIFY',
|
|
@@ -121,14 +121,14 @@ export function App() {
|
|
|
121
121
|
const showSdkDemo = isInsideIframe() || isDevStandalone();
|
|
122
122
|
|
|
123
123
|
return (
|
|
124
|
-
<div className="bg-background text-foreground min-h-screen">
|
|
124
|
+
<div className="bg-background text-foreground @container/app min-h-screen">
|
|
125
125
|
{showSdkDemo ? (
|
|
126
126
|
<SdkDemo />
|
|
127
127
|
) : (
|
|
128
128
|
<div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
|
|
129
129
|
<h1 className="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
130
130
|
<p className="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
|
|
131
|
-
Open this app inside Bardioc
|
|
131
|
+
Open this app inside Bardioc to use transport requests and send host notifications.
|
|
132
132
|
</p>
|
|
133
133
|
<div className="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
|
|
134
134
|
Outside the host iframe this page is only a local preview shell.
|
|
@@ -3,9 +3,12 @@ import preact from '@preact/preset-vite';
|
|
|
3
3
|
import tailwindcss from '@tailwindcss/vite';
|
|
4
4
|
import { defineConfig, loadEnv } from 'vite';
|
|
5
5
|
|
|
6
|
+
const DEFAULT_PORT = {{PORT}};
|
|
7
|
+
|
|
6
8
|
export default defineConfig(({ mode }) => {
|
|
7
9
|
const env = loadEnv(mode, __dirname, '');
|
|
8
10
|
const appName = env.VITE_APP_NAME?.trim();
|
|
11
|
+
const port = Number(env.LOCALHOST_PORT) || DEFAULT_PORT;
|
|
9
12
|
|
|
10
13
|
if (!appName) {
|
|
11
14
|
throw new Error('Missing VITE_APP_NAME for Vite config');
|
|
@@ -15,7 +18,7 @@ export default defineConfig(({ mode }) => {
|
|
|
15
18
|
plugins: [
|
|
16
19
|
bardiocDevAuth({ appName }),
|
|
17
20
|
preact(),
|
|
18
|
-
bardiocApp({ appName, port
|
|
21
|
+
bardiocApp({ appName, port }),
|
|
19
22
|
tailwindcss(),
|
|
20
23
|
],
|
|
21
24
|
};
|
|
@@ -7,3 +7,6 @@ DEV_SECRET=
|
|
|
7
7
|
|
|
8
8
|
# Base URL of the Bardioc BFF / backend-for-frontend (e.g. https://your-host).
|
|
9
9
|
API_BASE_URL=
|
|
10
|
+
|
|
11
|
+
# By default, the app will start on port {{PORT}}. Feel free to uncomment the following variable and change it to match your local setup preferences.
|
|
12
|
+
#LOCALHOST_PORT={{PORT}}
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"release:publish": "changeset publish"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@bardioc/app-sdk": "^0.
|
|
21
|
+
"@bardioc/app-sdk": "^0.5.0",
|
|
22
22
|
"solid-js": "^1.9.7"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@bardioc/configs": "
|
|
25
|
+
"@bardioc/configs": "0.2.1",
|
|
26
26
|
"@changesets/cli": "^2.31.0",
|
|
27
27
|
"@tailwindcss/vite": "^4.3.0",
|
|
28
28
|
"@types/node": "^22.19.19",
|
|
@@ -22,13 +22,13 @@ function SdkDemo() {
|
|
|
22
22
|
setResult({ status: 'loading', request });
|
|
23
23
|
|
|
24
24
|
const startTime = Date.now();
|
|
25
|
-
notify('Getting user profile', 'info');
|
|
25
|
+
notify('Getting user profile…', 'info');
|
|
26
26
|
|
|
27
27
|
try {
|
|
28
28
|
const data = await bridge.transport.os.profile.get();
|
|
29
29
|
|
|
30
30
|
const duration = Date.now() - startTime;
|
|
31
|
-
notify(`Profile loaded (${duration}ms)
|
|
31
|
+
notify(`Profile loaded (${duration}ms).`, 'success');
|
|
32
32
|
setResult({ status: 'success', request, data });
|
|
33
33
|
} catch (err) {
|
|
34
34
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -40,7 +40,7 @@ function SdkDemo() {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
function handleNotify() {
|
|
43
|
-
notify('Hello from {{DISPLAY_NAME}}', 'info');
|
|
43
|
+
notify('Hello from {{DISPLAY_NAME}}.', 'info');
|
|
44
44
|
setResult({
|
|
45
45
|
status: 'success',
|
|
46
46
|
request: 'SDK_NOTIFY',
|
|
@@ -132,14 +132,14 @@ export function App() {
|
|
|
132
132
|
const showSdkDemo = isInsideIframe() || isDevStandalone();
|
|
133
133
|
|
|
134
134
|
return (
|
|
135
|
-
<div class="bg-background text-foreground min-h-screen">
|
|
135
|
+
<div class="bg-background text-foreground @container/app min-h-screen">
|
|
136
136
|
{showSdkDemo ? (
|
|
137
137
|
<SdkDemo />
|
|
138
138
|
) : (
|
|
139
139
|
<div class="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
|
|
140
140
|
<h1 class="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
141
141
|
<p class="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
|
|
142
|
-
Open this app inside Bardioc
|
|
142
|
+
Open this app inside Bardioc to use transport requests and send host notifications.
|
|
143
143
|
</p>
|
|
144
144
|
<div class="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
|
|
145
145
|
Outside the host iframe this page is only a local preview shell.
|
|
@@ -3,9 +3,12 @@ import tailwindcss from '@tailwindcss/vite';
|
|
|
3
3
|
import { defineConfig, loadEnv } from 'vite';
|
|
4
4
|
import solid from 'vite-plugin-solid';
|
|
5
5
|
|
|
6
|
+
const DEFAULT_PORT = {{PORT}};
|
|
7
|
+
|
|
6
8
|
export default defineConfig(({ mode }) => {
|
|
7
9
|
const env = loadEnv(mode, __dirname, '');
|
|
8
10
|
const appName = env.VITE_APP_NAME?.trim();
|
|
11
|
+
const port = Number(env.LOCALHOST_PORT) || DEFAULT_PORT;
|
|
9
12
|
|
|
10
13
|
if (!appName) {
|
|
11
14
|
throw new Error('Missing VITE_APP_NAME for Vite config');
|
|
@@ -15,7 +18,7 @@ export default defineConfig(({ mode }) => {
|
|
|
15
18
|
plugins: [
|
|
16
19
|
bardiocDevAuth({ appName }),
|
|
17
20
|
solid(),
|
|
18
|
-
bardiocApp({ appName, port
|
|
21
|
+
bardiocApp({ appName, port }),
|
|
19
22
|
tailwindcss(),
|
|
20
23
|
],
|
|
21
24
|
};
|
|
@@ -7,3 +7,6 @@ DEV_SECRET=
|
|
|
7
7
|
|
|
8
8
|
# Base URL of the Bardioc BFF / backend-for-frontend (e.g. https://your-host).
|
|
9
9
|
API_BASE_URL=
|
|
10
|
+
|
|
11
|
+
# By default, the app will start on port {{PORT}}. Feel free to uncomment the following variable and change it to match your local setup preferences.
|
|
12
|
+
#LOCALHOST_PORT={{PORT}}
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"release:publish": "changeset publish"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@bardioc/app-sdk": "^0.
|
|
21
|
+
"@bardioc/app-sdk": "^0.5.0",
|
|
22
22
|
"svelte": "^5.33.14"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@bardioc/configs": "
|
|
25
|
+
"@bardioc/configs": "0.2.1",
|
|
26
26
|
"@changesets/cli": "^2.31.0",
|
|
27
27
|
"@sveltejs/vite-plugin-svelte": "^7.2.0",
|
|
28
28
|
"@tailwindcss/vite": "^4.3.0",
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
result = { status: 'loading', request };
|
|
30
30
|
|
|
31
31
|
const startTime = Date.now();
|
|
32
|
-
notify('Getting user profile', 'info');
|
|
32
|
+
notify('Getting user profile…', 'info');
|
|
33
33
|
|
|
34
34
|
try {
|
|
35
35
|
const data = await bridge.transport.os.profile.get();
|
|
36
36
|
|
|
37
37
|
const duration = Date.now() - startTime;
|
|
38
|
-
notify(`Profile loaded (${duration}ms)
|
|
38
|
+
notify(`Profile loaded (${duration}ms).`, 'success');
|
|
39
39
|
result = { status: 'success', request, data };
|
|
40
40
|
} catch (err) {
|
|
41
41
|
const message = err instanceof Error ? err.message : String(err);
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
function handleNotify() {
|
|
50
|
-
notify('Hello from {{DISPLAY_NAME}}', 'info');
|
|
50
|
+
notify('Hello from {{DISPLAY_NAME}}.', 'info');
|
|
51
51
|
result = {
|
|
52
52
|
status: 'success',
|
|
53
53
|
request: 'SDK_NOTIFY',
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
</script>
|
|
62
62
|
|
|
63
|
-
<div class="bg-background text-foreground min-h-screen">
|
|
63
|
+
<div class="bg-background text-foreground @container/app min-h-screen">
|
|
64
64
|
{#if showSdkDemo}
|
|
65
65
|
<div class="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-3 p-4">
|
|
66
66
|
<div class="flex flex-col gap-1">
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
<div class="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
|
|
126
126
|
<h1 class="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
127
127
|
<p class="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
|
|
128
|
-
Open this app inside Bardioc
|
|
128
|
+
Open this app inside Bardioc to use transport requests and send host notifications.
|
|
129
129
|
</p>
|
|
130
130
|
<div class="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
|
|
131
131
|
Outside the host iframe this page is only a local preview shell.
|