@bardioc/create-bardioc-app 0.4.0

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.
Files changed (108) hide show
  1. package/LICENSE +5 -0
  2. package/README.md +105 -0
  3. package/bin/create.mjs +76 -0
  4. package/package.json +45 -0
  5. package/src/scaffold.d.ts +50 -0
  6. package/src/scaffold.js +379 -0
  7. package/templates/_base/.changeset/README.md +17 -0
  8. package/templates/_base/.changeset/config.json +12 -0
  9. package/templates/_base/.claude/commands/changeset-app.md +104 -0
  10. package/templates/_base/.claude/commands/refresh-bundle.md +101 -0
  11. package/templates/_base/README.md +89 -0
  12. package/templates/_base/public/app-manifest.json +10 -0
  13. package/templates/_base/scripts/stamp-manifest.mjs +17 -0
  14. package/templates/_opt-link/_npmrc +2 -0
  15. package/templates/_opt-link/pnpm-workspace.yaml +3 -0
  16. package/templates/_opt-link/scripts/link-source.mjs +188 -0
  17. package/templates/_opt-pipeline/bitbucket-pipelines.yml +100 -0
  18. package/templates/angular/.env.example +5 -0
  19. package/templates/angular/_gitignore +7 -0
  20. package/templates/angular/angular.json +64 -0
  21. package/templates/angular/package.json +49 -0
  22. package/templates/angular/postcss.config.mjs +5 -0
  23. package/templates/angular/public/icon.svg +1 -0
  24. package/templates/angular/public/runtime-env.js +1 -0
  25. package/templates/angular/scripts/dev-auth-proxy.mjs +92 -0
  26. package/templates/angular/scripts/sync-runtime-env.mjs +89 -0
  27. package/templates/angular/src/app/app.component.ts +181 -0
  28. package/templates/angular/src/app/bardioc-bridge.ts +5 -0
  29. package/templates/angular/src/app/bardioc.token.ts +4 -0
  30. package/templates/angular/src/index.html +15 -0
  31. package/templates/angular/src/main.ts +82 -0
  32. package/templates/angular/src/runtime-env.ts +17 -0
  33. package/templates/angular/src/styles.css +258 -0
  34. package/templates/angular/src/vite-env.d.ts +10 -0
  35. package/templates/angular/tsconfig.json +27 -0
  36. package/templates/manifest.json +13 -0
  37. package/templates/nextjs/.env.example +8 -0
  38. package/templates/nextjs/_gitignore +7 -0
  39. package/templates/nextjs/app/globals.css +75 -0
  40. package/templates/nextjs/app/layout.tsx +17 -0
  41. package/templates/nextjs/app/page.tsx +222 -0
  42. package/templates/nextjs/app/proxy/route.ts +85 -0
  43. package/templates/nextjs/global.d.ts +1 -0
  44. package/templates/nextjs/next-env.d.ts +5 -0
  45. package/templates/nextjs/next.config.ts +21 -0
  46. package/templates/nextjs/package.json +32 -0
  47. package/templates/nextjs/postcss.config.mjs +5 -0
  48. package/templates/nextjs/public/icon.svg +1 -0
  49. package/templates/nextjs/tailwind.config.ts +10 -0
  50. package/templates/nextjs/tsconfig.json +27 -0
  51. package/templates/preact/.env.example +13 -0
  52. package/templates/preact/_gitignore +9 -0
  53. package/templates/preact/index.html +13 -0
  54. package/templates/preact/package.json +32 -0
  55. package/templates/preact/public/icon.svg +1 -0
  56. package/templates/preact/src/App.tsx +139 -0
  57. package/templates/preact/src/index.css +76 -0
  58. package/templates/preact/src/main.tsx +46 -0
  59. package/templates/preact/src/vite-env.d.ts +11 -0
  60. package/templates/preact/tsconfig.json +19 -0
  61. package/templates/preact/vite.config.ts +17 -0
  62. package/templates/solid/.env.example +13 -0
  63. package/templates/solid/_gitignore +9 -0
  64. package/templates/solid/index.html +13 -0
  65. package/templates/solid/package.json +32 -0
  66. package/templates/solid/public/icon.svg +1 -0
  67. package/templates/solid/src/App.tsx +150 -0
  68. package/templates/solid/src/bardioc-sdk.tsx +33 -0
  69. package/templates/solid/src/index.css +76 -0
  70. package/templates/solid/src/main.tsx +50 -0
  71. package/templates/solid/src/vite-env.d.ts +11 -0
  72. package/templates/solid/tsconfig.json +20 -0
  73. package/templates/solid/vite.config.ts +17 -0
  74. package/templates/svelte/.env.example +5 -0
  75. package/templates/svelte/_gitignore +6 -0
  76. package/templates/svelte/index.html +13 -0
  77. package/templates/svelte/package.json +32 -0
  78. package/templates/svelte/public/icon.svg +1 -0
  79. package/templates/svelte/src/App.svelte +135 -0
  80. package/templates/svelte/src/index.css +76 -0
  81. package/templates/svelte/src/main.ts +42 -0
  82. package/templates/svelte/src/vite-env.d.ts +11 -0
  83. package/templates/svelte/tsconfig.json +13 -0
  84. package/templates/svelte/vite.config.ts +17 -0
  85. package/templates/vite/.env.example +14 -0
  86. package/templates/vite/CLAUDE.md +114 -0
  87. package/templates/vite/_gitignore +9 -0
  88. package/templates/vite/index.html +13 -0
  89. package/templates/vite/package.json +34 -0
  90. package/templates/vite/public/icon.svg +1 -0
  91. package/templates/vite/src/App.tsx +141 -0
  92. package/templates/vite/src/index.css +76 -0
  93. package/templates/vite/src/main.tsx +44 -0
  94. package/templates/vite/src/vite-env.d.ts +11 -0
  95. package/templates/vite/tsconfig.json +18 -0
  96. package/templates/vite/vite.config.ts +17 -0
  97. package/templates/vue/.env.example +5 -0
  98. package/templates/vue/_gitignore +6 -0
  99. package/templates/vue/index.html +13 -0
  100. package/templates/vue/package.json +32 -0
  101. package/templates/vue/public/icon.svg +1 -0
  102. package/templates/vue/src/App.vue +127 -0
  103. package/templates/vue/src/bardioc-sdk.ts +23 -0
  104. package/templates/vue/src/index.css +76 -0
  105. package/templates/vue/src/main.ts +43 -0
  106. package/templates/vue/src/vite-env.d.ts +17 -0
  107. package/templates/vue/tsconfig.json +26 -0
  108. package/templates/vue/vite.config.ts +17 -0
@@ -0,0 +1,85 @@
1
+ import { NextRequest, NextResponse } from 'next/server';
2
+
3
+ type ProxyPayload = {
4
+ path?: string;
5
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
6
+ body?: unknown;
7
+ contentType?: string;
8
+ scopeId?: string | null;
9
+ scopePolicy?: 'none' | 'optional' | 'required';
10
+ sessionKey?: string;
11
+ hostUrl?: string;
12
+ };
13
+
14
+ const APP_ID = process.env.NEXT_PUBLIC_APP_ID?.trim();
15
+ const DEV_AUTH_HOST_URL =
16
+ process.env.NEXT_PUBLIC_DEV_AUTH_HOST_URL?.trim() ?? process.env.DEV_AUTH_HOST_URL?.trim();
17
+ const DEV_SESSION_KEY =
18
+ process.env.NEXT_PUBLIC_DEV_SESSION_KEY?.trim() ?? process.env.DEV_SESSION_KEY?.trim();
19
+
20
+ export async function POST(request: NextRequest) {
21
+ const payload = (await request.json().catch(() => null)) as ProxyPayload | null;
22
+
23
+ if (!payload?.path) {
24
+ return NextResponse.json(
25
+ { error: 'invalid_payload' },
26
+ { status: 400, headers: noStoreHeaders() }
27
+ );
28
+ }
29
+
30
+ const hostUrl = payload.hostUrl ?? DEV_AUTH_HOST_URL;
31
+ const sessionKey = payload.sessionKey ?? DEV_SESSION_KEY;
32
+
33
+ if (!hostUrl || !sessionKey) {
34
+ return NextResponse.json(
35
+ { error: 'missing_dev_session' },
36
+ { status: 400, headers: noStoreHeaders() }
37
+ );
38
+ }
39
+
40
+ if (!APP_ID) {
41
+ return NextResponse.json(
42
+ { error: 'missing_app_id' },
43
+ { status: 500, headers: noStoreHeaders() }
44
+ );
45
+ }
46
+
47
+ try {
48
+ const transportResponse = await fetch(`${hostUrl.replace(/\/$/, '')}/api/transport`, {
49
+ method: 'POST',
50
+ headers: {
51
+ 'Content-Type': 'application/json',
52
+ 'X-Dev-Session-Key': sessionKey,
53
+ },
54
+ body: JSON.stringify({
55
+ appId: APP_ID,
56
+ path: payload.path,
57
+ method: payload.method ?? 'GET',
58
+ body: payload.body,
59
+ contentType: payload.contentType,
60
+ scopePolicy: payload.scopePolicy,
61
+ scopeId: payload.scopeId ?? null,
62
+ }),
63
+ cache: 'no-store',
64
+ });
65
+
66
+ const responseText = await transportResponse.text();
67
+
68
+ return new NextResponse(responseText, {
69
+ status: transportResponse.status,
70
+ headers: {
71
+ 'Cache-Control': 'no-store',
72
+ 'Content-Type': transportResponse.headers.get('content-type') ?? 'application/json',
73
+ },
74
+ });
75
+ } catch {
76
+ return NextResponse.json(
77
+ { error: 'host_transport_failed' },
78
+ { status: 502, headers: noStoreHeaders() }
79
+ );
80
+ }
81
+ }
82
+
83
+ function noStoreHeaders(): HeadersInit {
84
+ return { 'Cache-Control': 'no-store' };
85
+ }
@@ -0,0 +1 @@
1
+ declare module '*.css';
@@ -0,0 +1,5 @@
1
+ /// <reference types="next" />
2
+ /// <reference types="next/image-types/global" />
3
+
4
+ // NOTE: This file should not be edited
5
+ // see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
@@ -0,0 +1,21 @@
1
+ import type { NextConfig } from 'next';
2
+
3
+ const nextConfig: NextConfig = {
4
+ output: 'export',
5
+ env: {
6
+ NEXT_PUBLIC_APP_NAME: process.env.NEXT_PUBLIC_APP_NAME ?? process.env.VITE_APP_NAME,
7
+ NEXT_PUBLIC_APP_ID: process.env.NEXT_PUBLIC_APP_ID ?? process.env.VITE_APP_ID,
8
+ NEXT_PUBLIC_ENABLE_DEV_AUTH:
9
+ process.env.NEXT_PUBLIC_ENABLE_DEV_AUTH ?? process.env.VITE_ENABLE_DEV_AUTH,
10
+ NEXT_PUBLIC_DEV_AUTH_HOST_URL:
11
+ process.env.NEXT_PUBLIC_DEV_AUTH_HOST_URL ?? process.env.DEV_AUTH_HOST_URL,
12
+ NEXT_PUBLIC_DEV_SESSION_KEY:
13
+ process.env.NEXT_PUBLIC_DEV_SESSION_KEY ?? process.env.DEV_SESSION_KEY,
14
+ },
15
+ images: {
16
+ unoptimized: true,
17
+ },
18
+ trailingSlash: true,
19
+ };
20
+
21
+ export default nextConfig;
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "{{APP_NAME}}",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "scripts": {
6
+ "dev": "bardioc-dev-session -- next dev --port {{PORT}}",
7
+ "dev:live": "BARDIOC_TUNNEL=1 bardioc-dev-session -- next dev --port {{PORT}}",
8
+ "build": "next build && node scripts/stamp-manifest.mjs out",
9
+ "bundle": "next build && node scripts/stamp-manifest.mjs out && cd out && zip -r ../{{APP_NAME}}.zip .",
10
+ "start": "next start",
11
+ "check-types": "tsc --noEmit",
12
+ "changeset": "changeset",
13
+ "release:status": "changeset status --verbose",
14
+ "release:version": "changeset version && pnpm install --lockfile-only",
15
+ "release:publish": "changeset publish"
16
+ },
17
+ "dependencies": {
18
+ "@bardioc/app-sdk": "latest",
19
+ "next": "^15.3.2",
20
+ "react": "^19.2.5",
21
+ "react-dom": "^19.2.5"
22
+ },
23
+ "devDependencies": {
24
+ "@changesets/cli": "^2.31.0",
25
+ "@tailwindcss/postcss": "^4.2.4",
26
+ "@types/node": "^22.10.0",
27
+ "@types/react": "^19.2.14",
28
+ "@types/react-dom": "^19.2.3",
29
+ "tailwindcss": "^4.2.4",
30
+ "typescript": "^6.0.3"
31
+ }
32
+ }
@@ -0,0 +1,5 @@
1
+ export default {
2
+ plugins: {
3
+ '@tailwindcss/postcss': {},
4
+ },
5
+ };
@@ -0,0 +1 @@
1
+ <svg fill="none" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="15.3012" x2="-2.25993" y1="1.77049" y2="12.9254"><stop offset=".4898" stop-color="#c084fc"/><stop offset="1" stop-color="#9333ea"/></linearGradient><path d="m14.3984 3.35791c1.9618.00013 3.5514 1.59021 3.5518 3.55176v8.08593c0 1.9602-1.5896 3.5507-3.5518 3.5508h-8.84567c-1.96194-.0002-3.55273-1.5909-3.55273-3.5527v-8.08403c.00042-1.96151 1.59105-3.55156 3.55273-3.55176zm4.5186 12.18069c.0121-.1019.0221-.2048.0273-.3086.004-.0776.0059-.1559.0059-.2344v-8.08593c0-.18616-.0124-.36951-.0342-.54981.0218.18056.0352.36435.0352.55078v8.08496c0 .1837-.013.3649-.0342.543zm-17.8672.1318c-.03282-.2205-.0498-.4471-.0498-.6767 0 .2298.01694.456.0498.6767zm.00098-9.44042c-.03187.21266-.0494.43015-.05078.65137.00138-.22122.01891-.43871.05078-.65137zm3.60254-3.7832c.0723-.01449.14526-.02707.21875-.03809-.07349.01102-.14645.0236-.21875.03809zm.66504-.08301c-.14548.00737-.2891.02225-.43066.04297.14156-.02072.28518-.0356.43066-.04297zm9.31444 0c.1368.00693.272.02032.4053.03906-.1332-.01872-.2686-.03213-.4053-.03906zm-9.76171 17.13183c-.06758-.0101-.1346-.0221-.20117-.0352.06658.0131.13359.0251.20117.0352zm-2.92578-1.7256c-.0288-.0374-.0573-.075-.08496-.1133.02766.0383.05616.0759.08496.1133zm16.82719-12.11912c.0144.05023.0292.10044.042.15137-.0128-.05093-.0276-.10114-.042-.15137zm.0449.16504c.0166.06713.0313.13485.0449.20312-.0135-.06826-.0284-.13599-.0449-.20312zm.0644.31152c.006.03443.0124.06883.0176.10352-.0052-.03469-.0116-.06909-.0176-.10352zm-17.81246 9.65526c-.00653-.0373-.01393-.0746-.01954-.1123.00561.0377.01301.075.01954.1123zm17.57126-10.5244c.0165.04237.0326.08495.0479.12793-.0153-.04298-.0314-.08556-.0479-.12793zm-14.12888-2.78027c.04696-.01099.09409-.02174.1416-.03125-.04751.00952-.09464.02026-.1416.03125z" fill="url(#a)"/><g opacity=".31"><path d="m3.24438 5.75049v7.11941c0 1.4408.99919 2.6095 2.23108 2.6095h9.00044c1.2319 0 2.231-1.1687 2.231-2.6095v-7.11941z" fill="#fff" fill-opacity=".6"/></g><rect x="6" y="7" width="8" height="1.5" rx="0.75" fill="#eddcff"/><rect x="6" y="10" width="8" height="1.5" rx="0.75" fill="#eddcff"/><rect x="6" y="13" width="5" height="1.5" rx="0.75" fill="#eddcff"/></svg>
@@ -0,0 +1,10 @@
1
+ import type { Config } from 'tailwindcss';
2
+
3
+ const config: Config = {
4
+ content: [
5
+ './app/**/*.{js,ts,jsx,tsx,mdx}',
6
+ './components/**/*.{js,ts,jsx,tsx,mdx}',
7
+ ],
8
+ };
9
+
10
+ export default config;
@@ -0,0 +1,27 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "lib": ["dom", "dom.iterable", "esnext"],
5
+ "allowJs": true,
6
+ "skipLibCheck": true,
7
+ "strict": true,
8
+ "noEmit": true,
9
+ "esModuleInterop": true,
10
+ "module": "esnext",
11
+ "moduleResolution": "bundler",
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "jsx": "preserve",
15
+ "incremental": true,
16
+ "plugins": [
17
+ {
18
+ "name": "next"
19
+ }
20
+ ],
21
+ "paths": {
22
+ "@/*": ["./*"]
23
+ }
24
+ },
25
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
26
+ "exclude": ["node_modules"]
27
+ }
@@ -0,0 +1,13 @@
1
+ # Hosted app slug used by local runtime/dev-auth wiring.
2
+ VITE_APP_NAME={{APP_NAME}}
3
+
4
+ # Get this from the BardiocOS AppStore after registering your app.
5
+ # Required for token exchange
6
+ VITE_APP_ID=your-app-client-id-here
7
+
8
+ # Opt into the host-backed standalone dev session when running outside the host iframe.
9
+ VITE_ENABLE_DEV_AUTH=false
10
+
11
+ # Copy these from the host App Store app details via "Copy Dev Session".
12
+ DEV_AUTH_HOST_URL=
13
+ DEV_SESSION_KEY=
@@ -0,0 +1,9 @@
1
+ node_modules/
2
+ dist/
3
+ coverage/
4
+ .DS_Store
5
+ .env
6
+ .env.local
7
+ .env.*.local
8
+ *.tsbuildinfo
9
+ .linked/
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="dark" style="height: 100%; margin: 0">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{DISPLAY_NAME}}</title>
7
+ <link rel="stylesheet" href="/fonts/bardioc-fonts.css" />
8
+ </head>
9
+ <body style="height: 100%; margin: 0">
10
+ <div id="root" style="height: 100%"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "{{APP_NAME}}",
3
+ "version": "0.0.1",
4
+ "private": true,
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "bardioc-dev-session -- vite",
8
+ "dev:live": "BARDIOC_TUNNEL=1 bardioc-dev-session -- vite",
9
+ "build": "tsc && vite build && node scripts/stamp-manifest.mjs dist",
10
+ "bundle": "tsc && vite build && node scripts/stamp-manifest.mjs dist && cd dist && zip -r ../{{APP_NAME}}.zip .",
11
+ "preview": "vite preview",
12
+ "check-types": "tsc --noEmit",
13
+ "changeset": "changeset",
14
+ "release:status": "changeset status --verbose",
15
+ "release:version": "changeset version && pnpm install --lockfile-only",
16
+ "release:publish": "changeset publish"
17
+ },
18
+ "dependencies": {
19
+ "@bardioc/app-sdk": "latest",
20
+ "preact": "^10.26.7"
21
+ },
22
+ "devDependencies": {
23
+ "@changesets/cli": "^2.31.0",
24
+ "@preact/preset-vite": "^2.10.1",
25
+ "@tailwindcss/vite": "^4.3.0",
26
+ "@types/node": "^22.19.19",
27
+ "preact-render-to-string": "^6.6.1",
28
+ "tailwindcss": "4.3.0",
29
+ "typescript": "6.0.3",
30
+ "vite": "8.0.13"
31
+ }
32
+ }
@@ -0,0 +1 @@
1
+ <svg fill="none" height="20" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientUnits="userSpaceOnUse" x1="15.3012" x2="-2.25993" y1="1.77049" y2="12.9254"><stop offset=".4898" stop-color="#c084fc"/><stop offset="1" stop-color="#9333ea"/></linearGradient><path d="m14.3984 3.35791c1.9618.00013 3.5514 1.59021 3.5518 3.55176v8.08593c0 1.9602-1.5896 3.5507-3.5518 3.5508h-8.84567c-1.96194-.0002-3.55273-1.5909-3.55273-3.5527v-8.08403c.00042-1.96151 1.59105-3.55156 3.55273-3.55176zm4.5186 12.18069c.0121-.1019.0221-.2048.0273-.3086.004-.0776.0059-.1559.0059-.2344v-8.08593c0-.18616-.0124-.36951-.0342-.54981.0218.18056.0352.36435.0352.55078v8.08496c0 .1837-.013.3649-.0342.543zm-17.8672.1318c-.03282-.2205-.0498-.4471-.0498-.6767 0 .2298.01694.456.0498.6767zm.00098-9.44042c-.03187.21266-.0494.43015-.05078.65137.00138-.22122.01891-.43871.05078-.65137zm3.60254-3.7832c.0723-.01449.14526-.02707.21875-.03809-.07349.01102-.14645.0236-.21875.03809zm.66504-.08301c-.14548.00737-.2891.02225-.43066.04297.14156-.02072.28518-.0356.43066-.04297zm9.31444 0c.1368.00693.272.02032.4053.03906-.1332-.01872-.2686-.03213-.4053-.03906zm-9.76171 17.13183c-.06758-.0101-.1346-.0221-.20117-.0352.06658.0131.13359.0251.20117.0352zm-2.92578-1.7256c-.0288-.0374-.0573-.075-.08496-.1133.02766.0383.05616.0759.08496.1133zm16.82719-12.11912c.0144.05023.0292.10044.042.15137-.0128-.05093-.0276-.10114-.042-.15137zm.0449.16504c.0166.06713.0313.13485.0449.20312-.0135-.06826-.0284-.13599-.0449-.20312zm.0644.31152c.006.03443.0124.06883.0176.10352-.0052-.03469-.0116-.06909-.0176-.10352zm-17.81246 9.65526c-.00653-.0373-.01393-.0746-.01954-.1123.00561.0377.01301.075.01954.1123zm17.57126-10.5244c.0165.04237.0326.08495.0479.12793-.0153-.04298-.0314-.08556-.0479-.12793zm-14.12888-2.78027c.04696-.01099.09409-.02174.1416-.03125-.04751.00952-.09464.02026-.1416.03125z" fill="url(#a)"/><g opacity=".31"><path d="m3.24438 5.75049v7.11941c0 1.4408.99919 2.6095 2.23108 2.6095h9.00044c1.2319 0 2.231-1.1687 2.231-2.6095v-7.11941z" fill="#fff" fill-opacity=".6"/></g><rect x="6" y="7" width="8" height="1.5" rx="0.75" fill="#eddcff"/><rect x="6" y="10" width="8" height="1.5" rx="0.75" fill="#eddcff"/><rect x="6" y="13" width="5" height="1.5" rx="0.75" fill="#eddcff"/></svg>
@@ -0,0 +1,139 @@
1
+ import { isDevStandalone, isInsideIframe } from '@bardioc/app-sdk/dev';
2
+ import { useSdk, useNotify } from '@bardioc/app-sdk/react';
3
+ import { useState } from 'preact/hooks';
4
+
5
+ type ResultState =
6
+ | { status: 'idle' }
7
+ | { status: 'loading'; request: string }
8
+ | { status: 'success'; request: string; data: unknown }
9
+ | { status: 'error'; request: string; message: string };
10
+
11
+ function SdkDemo() {
12
+ const bridge = useSdk();
13
+ const notify = useNotify();
14
+ const [result, setResult] = useState<ResultState>({ status: 'idle' });
15
+ const [running, setRunning] = useState(false);
16
+
17
+ async function runGetProfile() {
18
+ if (running) return;
19
+ setRunning(true);
20
+
21
+ const request = 'transport.os.profile.get()';
22
+ setResult({ status: 'loading', request });
23
+
24
+ const startTime = Date.now();
25
+ notify('Getting user profile', 'info');
26
+
27
+ try {
28
+ const data = await bridge.transport.os.profile.get();
29
+
30
+ const duration = Date.now() - startTime;
31
+ notify(`Profile loaded (${duration}ms)`, 'success');
32
+ setResult({ status: 'success', request, data });
33
+ } catch (err) {
34
+ const message = err instanceof Error ? err.message : String(err);
35
+ notify(`Failed: ${message}`, 'error');
36
+ setResult({ status: 'error', request, message });
37
+ }
38
+
39
+ setRunning(false);
40
+ }
41
+
42
+ function handleNotify() {
43
+ notify('Hello from {{DISPLAY_NAME}}', 'info');
44
+ setResult({
45
+ status: 'success',
46
+ request: 'SDK_NOTIFY',
47
+ data: { ok: true, message: 'Notification sent to OS' },
48
+ });
49
+ }
50
+
51
+ return (
52
+ <div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-3 p-4">
53
+ <div className="flex flex-col gap-1">
54
+ <h1 className="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
55
+ <p className="text-muted-foreground m-0 text-xs leading-5">
56
+ Minimal hosted-app demo for API transport and SDK APIs.
57
+ </p>
58
+ </div>
59
+
60
+ <div className="flex flex-wrap gap-2">
61
+ <button
62
+ className="bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 rounded px-3 py-1 text-xs font-medium disabled:cursor-not-allowed"
63
+ onClick={() => void runGetProfile()}
64
+ disabled={running}
65
+ >
66
+ Get Profile
67
+ </button>
68
+ <button
69
+ className="bg-primary text-primary-foreground hover:bg-primary/90 disabled:opacity-50 rounded px-3 py-1 text-xs font-medium disabled:cursor-not-allowed"
70
+ onClick={handleNotify}
71
+ disabled={running}
72
+ >
73
+ Send Notification OS
74
+ </button>
75
+ <button
76
+ className="border-border text-muted-foreground hover:text-foreground rounded border px-3 py-1 text-xs"
77
+ onClick={() => setResult({ status: 'idle' })}
78
+ disabled={running}
79
+ >
80
+ Clear
81
+ </button>
82
+ </div>
83
+
84
+ <div className="border-border bg-background flex min-h-0 flex-1 flex-col overflow-hidden rounded border">
85
+ {result.status === 'idle' && (
86
+ <div className="text-muted-foreground flex h-full items-center justify-center p-3 text-center text-xs leading-5">
87
+ Run a query to see results. If the host session is missing, the transport route will return 401.
88
+ </div>
89
+ )}
90
+ {result.status === 'loading' && (
91
+ <div className="flex h-full flex-col items-center justify-center gap-2 p-3">
92
+ <div className="text-muted-foreground font-mono text-xs">{result.request}</div>
93
+ <div className="text-muted-foreground text-xs">Loading…</div>
94
+ </div>
95
+ )}
96
+ {result.status === 'error' && (
97
+ <div className="flex h-full flex-col gap-2 p-3 text-xs">
98
+ <div className="text-muted-foreground border-border border-b pb-2 font-mono text-xs">
99
+ {result.request}
100
+ </div>
101
+ <div className="text-destructive whitespace-pre-wrap break-all">{result.message}</div>
102
+ </div>
103
+ )}
104
+ {result.status === 'success' && (
105
+ <div className="flex h-full flex-col gap-0 overflow-hidden">
106
+ <div className="border-border text-muted-foreground shrink-0 border-b px-3 py-1 font-mono text-xs">
107
+ {result.request}
108
+ </div>
109
+ <pre className="text-foreground flex-1 overflow-auto p-3 text-[11px] leading-5">
110
+ {JSON.stringify(result.data, null, 2)}
111
+ </pre>
112
+ </div>
113
+ )}
114
+ </div>
115
+ </div>
116
+ );
117
+ }
118
+
119
+ export function App() {
120
+ const showSdkDemo = isInsideIframe() || (import.meta.env.VITE_ENABLE_DEV_AUTH === 'true' && isDevStandalone());
121
+
122
+ return (
123
+ <div className="bg-background text-foreground min-h-screen">
124
+ {showSdkDemo ? (
125
+ <SdkDemo />
126
+ ) : (
127
+ <div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
128
+ <h1 className="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
129
+ <p className="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
130
+ Open this app inside Bardioc OS to use transport requests and send host notifications.
131
+ </p>
132
+ <div className="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
133
+ Outside the host iframe this page is only a local preview shell.
134
+ </div>
135
+ </div>
136
+ )}
137
+ </div>
138
+ );
139
+ }
@@ -0,0 +1,76 @@
1
+ @import 'tailwindcss';
2
+
3
+ * {
4
+ box-sizing: border-box;
5
+ }
6
+
7
+ html,
8
+ body,
9
+ #root {
10
+ margin: 0;
11
+ padding: 0;
12
+ height: 100%;
13
+ width: 100%;
14
+ overflow: hidden;
15
+ }
16
+
17
+ :root {
18
+ --background: oklch(17.88% 0.0075 229.38);
19
+ --foreground: oklch(98.69% 0.0093 99.98);
20
+ --muted-foreground: oklch(86.03% 0.0056 95.11);
21
+ --border: oklch(1 0 0 / 10%);
22
+ --primary: oklch(97.02% 0 0);
23
+ --primary-foreground: oklch(36.94% 0.0053 236.64);
24
+ --destructive: oklch(68.04% 0.1386 21.38);
25
+ --ring: oklch(79.43% 0.0084 98.91);
26
+ }
27
+
28
+ body {
29
+ background: var(--background);
30
+ color: var(--foreground);
31
+ font-family: system-ui, -apple-system, sans-serif;
32
+ }
33
+
34
+ code {
35
+ font-family: inherit;
36
+ }
37
+
38
+ .bg-background {
39
+ background-color: var(--background);
40
+ }
41
+
42
+ .text-foreground {
43
+ color: var(--foreground);
44
+ }
45
+
46
+ .text-muted-foreground {
47
+ color: var(--muted-foreground);
48
+ }
49
+
50
+ .border-border {
51
+ border-color: var(--border);
52
+ }
53
+
54
+ .bg-primary {
55
+ background-color: var(--primary);
56
+ }
57
+
58
+ .text-primary-foreground {
59
+ color: var(--primary-foreground);
60
+ }
61
+
62
+ .text-destructive {
63
+ color: var(--destructive);
64
+ }
65
+
66
+ .focus\:ring-ring:focus {
67
+ --tw-ring-color: var(--ring);
68
+ }
69
+
70
+ .hover\:bg-primary\/90:hover {
71
+ background-color: oklch(from var(--primary) calc(l * 0.9) c h);
72
+ }
73
+
74
+ .hover\:text-foreground:hover {
75
+ color: var(--foreground);
76
+ }
@@ -0,0 +1,46 @@
1
+ import {
2
+ ensureDevAuthSession,
3
+ installDevBridge,
4
+ isDevStandalone,
5
+ isInsideIframe,
6
+ } from '@bardioc/app-sdk/dev';
7
+ import { AppSdkProvider } from '@bardioc/app-sdk/react';
8
+ import { render } from 'preact';
9
+ import { App } from './App';
10
+ import './index.css';
11
+
12
+ const APP_NAME = import.meta.env.VITE_APP_NAME?.trim();
13
+ const APP_ID = import.meta.env.VITE_APP_ID?.trim();
14
+ const standaloneDevAuthEnabled = import.meta.env.DEV && import.meta.env.VITE_ENABLE_DEV_AUTH === 'true';
15
+
16
+ if (!APP_NAME) {
17
+ throw new Error('Missing VITE_APP_NAME for runtime');
18
+ }
19
+
20
+ const insideIframe = isInsideIframe();
21
+ const devStandalone = standaloneDevAuthEnabled && isDevStandalone();
22
+ const useSdkProvider = insideIframe || devStandalone;
23
+
24
+ if (useSdkProvider && !APP_ID) {
25
+ throw new Error('Missing VITE_APP_ID for SDK runtime');
26
+ }
27
+
28
+ async function bootstrap() {
29
+ if (devStandalone) {
30
+ await ensureDevAuthSession({ appId: APP_ID, appName: APP_NAME });
31
+ installDevBridge({ appId: APP_ID, appName: APP_NAME, debug: false });
32
+ }
33
+
34
+ render(
35
+ useSdkProvider ? (
36
+ <AppSdkProvider appId={APP_ID!}>
37
+ <App />
38
+ </AppSdkProvider>
39
+ ) : (
40
+ <App />
41
+ ),
42
+ document.getElementById('root')!
43
+ );
44
+ }
45
+
46
+ bootstrap();
@@ -0,0 +1,11 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ interface ImportMetaEnv {
4
+ readonly VITE_APP_NAME: string
5
+ readonly VITE_APP_ID: string
6
+ readonly VITE_ENABLE_DEV_AUTH?: string
7
+ }
8
+
9
+ interface ImportMeta {
10
+ readonly env: ImportMetaEnv
11
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "jsx": "react-jsx",
8
+ "jsxImportSource": "preact",
9
+ "strict": true,
10
+ "noEmit": true,
11
+ "esModuleInterop": true,
12
+ "skipLibCheck": true,
13
+ "forceConsistentCasingInFileNames": true,
14
+ "resolveJsonModule": true,
15
+ "isolatedModules": true
16
+ },
17
+ "include": ["src"],
18
+ "exclude": ["node_modules", "dist"]
19
+ }
@@ -0,0 +1,17 @@
1
+ import { bardiocApp, bardiocDevAuth } from '@bardioc/app-sdk/vite';
2
+ import preact from '@preact/preset-vite';
3
+ import tailwindcss from '@tailwindcss/vite';
4
+ import { defineConfig, loadEnv } from 'vite';
5
+
6
+ export default defineConfig(({ mode }) => {
7
+ const env = loadEnv(mode, __dirname, '');
8
+ const appName = env.VITE_APP_NAME?.trim();
9
+
10
+ if (!appName) {
11
+ throw new Error('Missing VITE_APP_NAME for Vite config');
12
+ }
13
+
14
+ return {
15
+ plugins: [bardiocDevAuth({ appName }), preact(), bardiocApp({ appName, port: {{PORT}} }), tailwindcss()],
16
+ };
17
+ });
@@ -0,0 +1,13 @@
1
+ # Hosted app slug used by local runtime/dev-auth wiring.
2
+ VITE_APP_NAME={{APP_NAME}}
3
+
4
+ # Get this from the BardiocOS AppStore after registering your app.
5
+ # Required for token exchange
6
+ VITE_APP_ID=your-app-client-id-here
7
+
8
+ # Opt into the host-backed standalone dev session when running outside the host iframe.
9
+ VITE_ENABLE_DEV_AUTH=false
10
+
11
+ # Copy these from the host App Store app details via "Copy Dev Session".
12
+ DEV_AUTH_HOST_URL=
13
+ DEV_SESSION_KEY=
@@ -0,0 +1,9 @@
1
+ node_modules/
2
+ dist/
3
+ coverage/
4
+ .DS_Store
5
+ .env
6
+ .env.local
7
+ .env.*.local
8
+ *.tsbuildinfo
9
+ .linked/
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en" class="dark" style="height: 100%; margin: 0">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>{{DISPLAY_NAME}}</title>
7
+ <link rel="stylesheet" href="/fonts/bardioc-fonts.css" />
8
+ </head>
9
+ <body style="height: 100%; margin: 0">
10
+ <div id="root" style="height: 100%"></div>
11
+ <script type="module" src="/src/main.tsx"></script>
12
+ </body>
13
+ </html>