@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.
- package/LICENSE +5 -0
- package/README.md +105 -0
- package/bin/create.mjs +76 -0
- package/package.json +45 -0
- package/src/scaffold.d.ts +50 -0
- package/src/scaffold.js +379 -0
- package/templates/_base/.changeset/README.md +17 -0
- package/templates/_base/.changeset/config.json +12 -0
- package/templates/_base/.claude/commands/changeset-app.md +104 -0
- package/templates/_base/.claude/commands/refresh-bundle.md +101 -0
- package/templates/_base/README.md +89 -0
- package/templates/_base/public/app-manifest.json +10 -0
- package/templates/_base/scripts/stamp-manifest.mjs +17 -0
- package/templates/_opt-link/_npmrc +2 -0
- package/templates/_opt-link/pnpm-workspace.yaml +3 -0
- package/templates/_opt-link/scripts/link-source.mjs +188 -0
- package/templates/_opt-pipeline/bitbucket-pipelines.yml +100 -0
- package/templates/angular/.env.example +5 -0
- package/templates/angular/_gitignore +7 -0
- package/templates/angular/angular.json +64 -0
- package/templates/angular/package.json +49 -0
- package/templates/angular/postcss.config.mjs +5 -0
- package/templates/angular/public/icon.svg +1 -0
- package/templates/angular/public/runtime-env.js +1 -0
- package/templates/angular/scripts/dev-auth-proxy.mjs +92 -0
- package/templates/angular/scripts/sync-runtime-env.mjs +89 -0
- package/templates/angular/src/app/app.component.ts +181 -0
- package/templates/angular/src/app/bardioc-bridge.ts +5 -0
- package/templates/angular/src/app/bardioc.token.ts +4 -0
- package/templates/angular/src/index.html +15 -0
- package/templates/angular/src/main.ts +82 -0
- package/templates/angular/src/runtime-env.ts +17 -0
- package/templates/angular/src/styles.css +258 -0
- package/templates/angular/src/vite-env.d.ts +10 -0
- package/templates/angular/tsconfig.json +27 -0
- package/templates/manifest.json +13 -0
- package/templates/nextjs/.env.example +8 -0
- package/templates/nextjs/_gitignore +7 -0
- package/templates/nextjs/app/globals.css +75 -0
- package/templates/nextjs/app/layout.tsx +17 -0
- package/templates/nextjs/app/page.tsx +222 -0
- package/templates/nextjs/app/proxy/route.ts +85 -0
- package/templates/nextjs/global.d.ts +1 -0
- package/templates/nextjs/next-env.d.ts +5 -0
- package/templates/nextjs/next.config.ts +21 -0
- package/templates/nextjs/package.json +32 -0
- package/templates/nextjs/postcss.config.mjs +5 -0
- package/templates/nextjs/public/icon.svg +1 -0
- package/templates/nextjs/tailwind.config.ts +10 -0
- package/templates/nextjs/tsconfig.json +27 -0
- package/templates/preact/.env.example +13 -0
- package/templates/preact/_gitignore +9 -0
- package/templates/preact/index.html +13 -0
- package/templates/preact/package.json +32 -0
- package/templates/preact/public/icon.svg +1 -0
- package/templates/preact/src/App.tsx +139 -0
- package/templates/preact/src/index.css +76 -0
- package/templates/preact/src/main.tsx +46 -0
- package/templates/preact/src/vite-env.d.ts +11 -0
- package/templates/preact/tsconfig.json +19 -0
- package/templates/preact/vite.config.ts +17 -0
- package/templates/solid/.env.example +13 -0
- package/templates/solid/_gitignore +9 -0
- package/templates/solid/index.html +13 -0
- package/templates/solid/package.json +32 -0
- package/templates/solid/public/icon.svg +1 -0
- package/templates/solid/src/App.tsx +150 -0
- package/templates/solid/src/bardioc-sdk.tsx +33 -0
- package/templates/solid/src/index.css +76 -0
- package/templates/solid/src/main.tsx +50 -0
- package/templates/solid/src/vite-env.d.ts +11 -0
- package/templates/solid/tsconfig.json +20 -0
- package/templates/solid/vite.config.ts +17 -0
- package/templates/svelte/.env.example +5 -0
- package/templates/svelte/_gitignore +6 -0
- package/templates/svelte/index.html +13 -0
- package/templates/svelte/package.json +32 -0
- package/templates/svelte/public/icon.svg +1 -0
- package/templates/svelte/src/App.svelte +135 -0
- package/templates/svelte/src/index.css +76 -0
- package/templates/svelte/src/main.ts +42 -0
- package/templates/svelte/src/vite-env.d.ts +11 -0
- package/templates/svelte/tsconfig.json +13 -0
- package/templates/svelte/vite.config.ts +17 -0
- package/templates/vite/.env.example +14 -0
- package/templates/vite/CLAUDE.md +114 -0
- package/templates/vite/_gitignore +9 -0
- package/templates/vite/index.html +13 -0
- package/templates/vite/package.json +34 -0
- package/templates/vite/public/icon.svg +1 -0
- package/templates/vite/src/App.tsx +141 -0
- package/templates/vite/src/index.css +76 -0
- package/templates/vite/src/main.tsx +44 -0
- package/templates/vite/src/vite-env.d.ts +11 -0
- package/templates/vite/tsconfig.json +18 -0
- package/templates/vite/vite.config.ts +17 -0
- package/templates/vue/.env.example +5 -0
- package/templates/vue/_gitignore +6 -0
- package/templates/vue/index.html +13 -0
- package/templates/vue/package.json +32 -0
- package/templates/vue/public/icon.svg +1 -0
- package/templates/vue/src/App.vue +127 -0
- package/templates/vue/src/bardioc-sdk.ts +23 -0
- package/templates/vue/src/index.css +76 -0
- package/templates/vue/src/main.ts +43 -0
- package/templates/vue/src/vite-env.d.ts +17 -0
- package/templates/vue/tsconfig.json +26 -0
- package/templates/vue/vite.config.ts +17 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
html,
|
|
6
|
+
body,
|
|
7
|
+
app-root {
|
|
8
|
+
margin: 0;
|
|
9
|
+
padding: 0;
|
|
10
|
+
height: 100%;
|
|
11
|
+
width: 100%;
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:root {
|
|
16
|
+
--background: oklch(17.88% 0.0075 229.38);
|
|
17
|
+
--foreground: oklch(98.69% 0.0093 99.98);
|
|
18
|
+
--muted-foreground: oklch(86.03% 0.0056 95.11);
|
|
19
|
+
--border: oklch(1 0 0 / 10%);
|
|
20
|
+
--primary: oklch(97.02% 0 0);
|
|
21
|
+
--primary-foreground: oklch(36.94% 0.0053 236.64);
|
|
22
|
+
--destructive: oklch(68.04% 0.1386 21.38);
|
|
23
|
+
--ring: oklch(79.43% 0.0084 98.91);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
body {
|
|
27
|
+
background: var(--background);
|
|
28
|
+
color: var(--foreground);
|
|
29
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
code {
|
|
33
|
+
font-family: inherit;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.bg-background {
|
|
37
|
+
background-color: var(--background);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.text-foreground {
|
|
41
|
+
color: var(--foreground);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.text-muted-foreground {
|
|
45
|
+
color: var(--muted-foreground);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.border-border {
|
|
49
|
+
border-color: var(--border);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.bg-primary {
|
|
53
|
+
background-color: var(--primary);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.text-primary-foreground {
|
|
57
|
+
color: var(--primary-foreground);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.text-destructive {
|
|
61
|
+
color: var(--destructive);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.focus\:ring-ring:focus {
|
|
65
|
+
--tw-ring-color: var(--ring);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.hover\:bg-primary\/90:hover {
|
|
69
|
+
background-color: oklch(from var(--primary) calc(l * 0.9) c h);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.hover\:text-foreground:hover {
|
|
73
|
+
color: var(--foreground);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.mx-auto {
|
|
77
|
+
margin-left: auto;
|
|
78
|
+
margin-right: auto;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.m-0 {
|
|
82
|
+
margin: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.flex {
|
|
86
|
+
display: flex;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.min-h-0 {
|
|
90
|
+
min-height: 0;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.min-h-screen {
|
|
94
|
+
min-height: 100vh;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.h-full {
|
|
98
|
+
height: 100%;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.w-full {
|
|
102
|
+
width: 100%;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.max-w-2xl {
|
|
106
|
+
max-width: 42rem;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
.max-w-3xl {
|
|
110
|
+
max-width: 48rem;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.shrink-0 {
|
|
114
|
+
flex-shrink: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.flex-1 {
|
|
118
|
+
flex: 1 1 0%;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.flex-col {
|
|
122
|
+
flex-direction: column;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.flex-wrap {
|
|
126
|
+
flex-wrap: wrap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.items-center {
|
|
130
|
+
align-items: center;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.justify-center {
|
|
134
|
+
justify-content: center;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
.gap-0 {
|
|
138
|
+
gap: 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.gap-1 {
|
|
142
|
+
gap: 0.25rem;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.gap-2 {
|
|
146
|
+
gap: 0.5rem;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
.gap-3 {
|
|
150
|
+
gap: 0.75rem;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
.gap-4 {
|
|
154
|
+
gap: 1rem;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
.overflow-hidden {
|
|
158
|
+
overflow: hidden;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
.overflow-auto {
|
|
162
|
+
overflow: auto;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.rounded {
|
|
166
|
+
border-radius: 0.25rem;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
.rounded-xl {
|
|
170
|
+
border-radius: 0.75rem;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.border {
|
|
174
|
+
border-width: 1px;
|
|
175
|
+
border-style: solid;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
.border-b {
|
|
179
|
+
border-bottom-width: 1px;
|
|
180
|
+
border-bottom-style: solid;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.p-3 {
|
|
184
|
+
padding: 0.75rem;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
.p-4 {
|
|
188
|
+
padding: 1rem;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.px-3 {
|
|
192
|
+
padding-left: 0.75rem;
|
|
193
|
+
padding-right: 0.75rem;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
.py-1 {
|
|
197
|
+
padding-top: 0.25rem;
|
|
198
|
+
padding-bottom: 0.25rem;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
.pb-2 {
|
|
202
|
+
padding-bottom: 0.5rem;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.text-center {
|
|
206
|
+
text-align: center;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.text-2xl {
|
|
210
|
+
font-size: 1.5rem;
|
|
211
|
+
line-height: 2rem;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.text-xs {
|
|
215
|
+
font-size: 0.75rem;
|
|
216
|
+
line-height: 1rem;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
.text-\[11px\] {
|
|
220
|
+
font-size: 11px;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.font-medium {
|
|
224
|
+
font-weight: 500;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.font-semibold {
|
|
228
|
+
font-weight: 600;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.font-mono {
|
|
232
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono',
|
|
233
|
+
'Courier New', monospace;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.leading-5 {
|
|
237
|
+
line-height: 1.25rem;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
.whitespace-pre-wrap {
|
|
241
|
+
white-space: pre-wrap;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.break-all {
|
|
245
|
+
word-break: break-all;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.bg-muted\/20 {
|
|
249
|
+
background-color: oklch(from var(--muted-foreground) l c h / 0.2);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
.disabled\:opacity-50:disabled {
|
|
253
|
+
opacity: 0.5;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.disabled\:cursor-not-allowed:disabled {
|
|
257
|
+
cursor: not-allowed;
|
|
258
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compileOnSave": false,
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "./dist",
|
|
5
|
+
"strict": true,
|
|
6
|
+
"noImplicitOverride": true,
|
|
7
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
8
|
+
"noImplicitReturns": true,
|
|
9
|
+
"noFallthroughCasesInSwitch": true,
|
|
10
|
+
"skipLibCheck": true,
|
|
11
|
+
"esModuleInterop": true,
|
|
12
|
+
"sourceMap": true,
|
|
13
|
+
"declaration": false,
|
|
14
|
+
"experimentalDecorators": true,
|
|
15
|
+
"moduleResolution": "bundler",
|
|
16
|
+
"importHelpers": true,
|
|
17
|
+
"target": "ES2022",
|
|
18
|
+
"module": "ES2022",
|
|
19
|
+
"lib": ["ES2022", "dom"]
|
|
20
|
+
},
|
|
21
|
+
"angularCompilerOptions": {
|
|
22
|
+
"enableI18nLegacyMessageIdFormat": false,
|
|
23
|
+
"strictInjectionParameters": true,
|
|
24
|
+
"strictInputAccessModifiers": true,
|
|
25
|
+
"strictTemplates": true
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
NEXT_PUBLIC_APP_NAME={{APP_NAME}}
|
|
2
|
+
NEXT_PUBLIC_APP_ID=your-app-client-id-here
|
|
3
|
+
NEXT_PUBLIC_ENABLE_DEV_AUTH=false
|
|
4
|
+
|
|
5
|
+
# Required host URL for standalone dev auth. Run `bardioc login` once, then
|
|
6
|
+
# `pnpm dev` will refresh DEV_SESSION_KEY automatically before Next starts.
|
|
7
|
+
DEV_AUTH_HOST_URL=
|
|
8
|
+
DEV_SESSION_KEY=
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
2
|
+
|
|
3
|
+
* {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
html,
|
|
8
|
+
body {
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
height: 100%;
|
|
12
|
+
width: 100%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
:root {
|
|
17
|
+
--background: oklch(17.88% 0.0075 229.38);
|
|
18
|
+
--foreground: oklch(98.69% 0.0093 99.98);
|
|
19
|
+
--muted-foreground: oklch(86.03% 0.0056 95.11);
|
|
20
|
+
--border: oklch(1 0 0 / 10%);
|
|
21
|
+
--primary: oklch(97.02% 0 0);
|
|
22
|
+
--primary-foreground: oklch(36.94% 0.0053 236.64);
|
|
23
|
+
--destructive: oklch(68.04% 0.1386 21.38);
|
|
24
|
+
--ring: oklch(79.43% 0.0084 98.91);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
body {
|
|
28
|
+
background: var(--background);
|
|
29
|
+
color: var(--foreground);
|
|
30
|
+
font-family: system-ui, -apple-system, sans-serif;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
code {
|
|
34
|
+
font-family: inherit;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.bg-background {
|
|
38
|
+
background-color: var(--background);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.text-foreground {
|
|
42
|
+
color: var(--foreground);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.text-muted-foreground {
|
|
46
|
+
color: var(--muted-foreground);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.border-border {
|
|
50
|
+
border-color: var(--border);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.bg-primary {
|
|
54
|
+
background-color: var(--primary);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.text-primary-foreground {
|
|
58
|
+
color: var(--primary-foreground);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.text-destructive {
|
|
62
|
+
color: var(--destructive);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.focus\:ring-ring:focus {
|
|
66
|
+
--tw-ring-color: var(--ring);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.hover\:bg-primary\/90:hover {
|
|
70
|
+
background-color: oklch(from var(--primary) calc(l * 0.9) c h);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.hover\:text-foreground:hover {
|
|
74
|
+
color: var(--foreground);
|
|
75
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Metadata } from 'next';
|
|
2
|
+
import './globals.css';
|
|
3
|
+
|
|
4
|
+
export const metadata: Metadata = {
|
|
5
|
+
title: '{{DISPLAY_NAME}}',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
|
|
9
|
+
return (
|
|
10
|
+
<html lang="en" className="dark" style={{ height: '100%', margin: 0 }}>
|
|
11
|
+
<head>
|
|
12
|
+
<link rel="stylesheet" href="/fonts/bardioc-fonts.css" />
|
|
13
|
+
</head>
|
|
14
|
+
<body style={{ height: '100%', margin: 0 }}>{children}</body>
|
|
15
|
+
</html>
|
|
16
|
+
);
|
|
17
|
+
}
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { ensureDevAuthSession, installDevBridge } from '@bardioc/app-sdk/dev';
|
|
4
|
+
import { AppSdkProvider, useNotify, useSdk } from '@bardioc/app-sdk/react';
|
|
5
|
+
import { useEffect, useState, type ReactNode } from 'react';
|
|
6
|
+
|
|
7
|
+
type ResultState =
|
|
8
|
+
| { status: 'idle' }
|
|
9
|
+
| { status: 'loading'; request: string }
|
|
10
|
+
| { status: 'success'; request: string; data: unknown }
|
|
11
|
+
| { status: 'error'; request: string; message: string };
|
|
12
|
+
|
|
13
|
+
type InjectedDevAuthConfig = {
|
|
14
|
+
hostUrl?: string;
|
|
15
|
+
sessionKey?: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const APP_NAME = process.env.NEXT_PUBLIC_APP_NAME?.trim();
|
|
19
|
+
const APP_ID = process.env.NEXT_PUBLIC_APP_ID?.trim();
|
|
20
|
+
const standaloneDevAuthEnabled =
|
|
21
|
+
process.env.NODE_ENV === 'development' && process.env.NEXT_PUBLIC_ENABLE_DEV_AUTH === 'true';
|
|
22
|
+
const DEV_AUTH_HOST_URL = process.env.NEXT_PUBLIC_DEV_AUTH_HOST_URL?.trim();
|
|
23
|
+
const DEV_SESSION_KEY = process.env.NEXT_PUBLIC_DEV_SESSION_KEY?.trim();
|
|
24
|
+
|
|
25
|
+
function installInjectedDevAuthConfig() {
|
|
26
|
+
if (!DEV_AUTH_HOST_URL || !DEV_SESSION_KEY) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
(
|
|
31
|
+
window as Window &
|
|
32
|
+
typeof globalThis & {
|
|
33
|
+
__BARDIOC_DEV_AUTH__?: InjectedDevAuthConfig;
|
|
34
|
+
}
|
|
35
|
+
).__BARDIOC_DEV_AUTH__ = {
|
|
36
|
+
hostUrl: DEV_AUTH_HOST_URL,
|
|
37
|
+
sessionKey: DEV_SESSION_KEY,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function SdkDemo() {
|
|
42
|
+
const bridge = useSdk();
|
|
43
|
+
const notify = useNotify();
|
|
44
|
+
const [result, setResult] = useState<ResultState>({ status: 'idle' });
|
|
45
|
+
const [running, setRunning] = useState(false);
|
|
46
|
+
|
|
47
|
+
async function runGetProfile() {
|
|
48
|
+
if (running) return;
|
|
49
|
+
setRunning(true);
|
|
50
|
+
|
|
51
|
+
const request = 'transport.os.profile.get()';
|
|
52
|
+
setResult({ status: 'loading', request });
|
|
53
|
+
|
|
54
|
+
const startTime = Date.now();
|
|
55
|
+
notify('Getting user profile', 'info');
|
|
56
|
+
|
|
57
|
+
try {
|
|
58
|
+
const data = await bridge.transport.os.profile.get();
|
|
59
|
+
|
|
60
|
+
const duration = Date.now() - startTime;
|
|
61
|
+
notify(`Profile loaded (${duration}ms)`, 'success');
|
|
62
|
+
setResult({ status: 'success', request, data });
|
|
63
|
+
} catch (err) {
|
|
64
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
65
|
+
notify(`Failed: ${message}`, 'error');
|
|
66
|
+
setResult({ status: 'error', request, message });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
setRunning(false);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleNotify() {
|
|
73
|
+
notify('Hello from {{DISPLAY_NAME}}', 'info');
|
|
74
|
+
setResult({
|
|
75
|
+
status: 'success',
|
|
76
|
+
request: 'SDK_NOTIFY',
|
|
77
|
+
data: { ok: true, message: 'Notification sent to OS' },
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-3 p-4">
|
|
83
|
+
<div className="flex flex-col gap-1">
|
|
84
|
+
<h1 className="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
85
|
+
<p className="text-muted-foreground m-0 text-xs leading-5">
|
|
86
|
+
Minimal hosted-app demo for API transport and SDK APIs.
|
|
87
|
+
</p>
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<div className="flex flex-wrap gap-2">
|
|
91
|
+
<button
|
|
92
|
+
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"
|
|
93
|
+
onClick={() => void runGetProfile()}
|
|
94
|
+
disabled={running}
|
|
95
|
+
>
|
|
96
|
+
Get Profile
|
|
97
|
+
</button>
|
|
98
|
+
<button
|
|
99
|
+
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"
|
|
100
|
+
onClick={handleNotify}
|
|
101
|
+
disabled={running}
|
|
102
|
+
>
|
|
103
|
+
Send Notification OS
|
|
104
|
+
</button>
|
|
105
|
+
<button
|
|
106
|
+
className="border-border text-muted-foreground hover:text-foreground rounded border px-3 py-1 text-xs"
|
|
107
|
+
onClick={() => setResult({ status: 'idle' })}
|
|
108
|
+
disabled={running}
|
|
109
|
+
>
|
|
110
|
+
Clear
|
|
111
|
+
</button>
|
|
112
|
+
</div>
|
|
113
|
+
|
|
114
|
+
<div className="border-border bg-background flex min-h-0 flex-1 flex-col overflow-hidden rounded border">
|
|
115
|
+
{result.status === 'idle' && (
|
|
116
|
+
<div className="text-muted-foreground flex h-full items-center justify-center p-3 text-center text-xs leading-5">
|
|
117
|
+
Run a query to see results. If the host session is missing, the transport route will
|
|
118
|
+
return 401.
|
|
119
|
+
</div>
|
|
120
|
+
)}
|
|
121
|
+
{result.status === 'loading' && (
|
|
122
|
+
<div className="flex h-full flex-col items-center justify-center gap-2 p-3">
|
|
123
|
+
<div className="text-muted-foreground font-mono text-xs">{result.request}</div>
|
|
124
|
+
<div className="text-muted-foreground text-xs">Loading…</div>
|
|
125
|
+
</div>
|
|
126
|
+
)}
|
|
127
|
+
{result.status === 'error' && (
|
|
128
|
+
<div className="flex h-full flex-col gap-2 p-3 text-xs">
|
|
129
|
+
<div className="text-muted-foreground border-border border-b pb-2 font-mono text-xs">
|
|
130
|
+
{result.request}
|
|
131
|
+
</div>
|
|
132
|
+
<div className="text-destructive whitespace-pre-wrap break-all">{result.message}</div>
|
|
133
|
+
</div>
|
|
134
|
+
)}
|
|
135
|
+
{result.status === 'success' && (
|
|
136
|
+
<div className="flex h-full flex-col gap-0 overflow-hidden">
|
|
137
|
+
<div className="border-border text-muted-foreground shrink-0 border-b px-3 py-1 font-mono text-xs">
|
|
138
|
+
{result.request}
|
|
139
|
+
</div>
|
|
140
|
+
<pre className="text-foreground flex-1 overflow-auto p-3 text-[11px] leading-5">
|
|
141
|
+
{JSON.stringify(result.data, null, 2)}
|
|
142
|
+
</pre>
|
|
143
|
+
</div>
|
|
144
|
+
)}
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function PreviewShell() {
|
|
151
|
+
return (
|
|
152
|
+
<div className="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
|
|
153
|
+
<h1 className="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
154
|
+
<p className="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
|
|
155
|
+
Open this app inside Bardioc OS to use transport requests and send host notifications.
|
|
156
|
+
</p>
|
|
157
|
+
<div className="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
|
|
158
|
+
Outside the host iframe this page is only a local preview shell.
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function DevAuthProvider({ children, enabled }: { children: ReactNode; enabled: boolean }) {
|
|
165
|
+
const requiresStandaloneDevAuth = enabled && standaloneDevAuthEnabled && !!APP_ID && !!APP_NAME;
|
|
166
|
+
const [ready, setReady] = useState(!requiresStandaloneDevAuth);
|
|
167
|
+
|
|
168
|
+
useEffect(() => {
|
|
169
|
+
if (!requiresStandaloneDevAuth) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
installInjectedDevAuthConfig();
|
|
174
|
+
|
|
175
|
+
ensureDevAuthSession({ appId: APP_ID, appName: APP_NAME })
|
|
176
|
+
.then(() => {
|
|
177
|
+
installDevBridge({ appId: APP_ID, appName: APP_NAME, debug: false });
|
|
178
|
+
setReady(true);
|
|
179
|
+
})
|
|
180
|
+
.catch(error => {
|
|
181
|
+
console.error('[template-smoke-nextjs] failed to initialize dev bridge', error);
|
|
182
|
+
setReady(true);
|
|
183
|
+
});
|
|
184
|
+
}, [requiresStandaloneDevAuth]);
|
|
185
|
+
|
|
186
|
+
if (!ready) {
|
|
187
|
+
return (
|
|
188
|
+
<div className="flex min-h-screen items-center justify-center">
|
|
189
|
+
<div className="text-muted-foreground text-xs">Initializing dev bridge...</div>
|
|
190
|
+
</div>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return <>{children}</>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export default function Page() {
|
|
198
|
+
const useSdkProvider =
|
|
199
|
+
standaloneDevAuthEnabled || (typeof window !== 'undefined' && window.parent !== window);
|
|
200
|
+
|
|
201
|
+
if (!APP_NAME) {
|
|
202
|
+
throw new Error('Missing NEXT_PUBLIC_APP_NAME for runtime');
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (useSdkProvider && !APP_ID) {
|
|
206
|
+
throw new Error('Missing NEXT_PUBLIC_APP_ID for SDK runtime');
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return (
|
|
210
|
+
<div className="bg-background text-foreground min-h-screen">
|
|
211
|
+
<DevAuthProvider enabled={useSdkProvider}>
|
|
212
|
+
{useSdkProvider ? (
|
|
213
|
+
<AppSdkProvider appId={APP_ID!}>
|
|
214
|
+
<SdkDemo />
|
|
215
|
+
</AppSdkProvider>
|
|
216
|
+
) : (
|
|
217
|
+
<PreviewShell />
|
|
218
|
+
)}
|
|
219
|
+
</DevAuthProvider>
|
|
220
|
+
</div>
|
|
221
|
+
);
|
|
222
|
+
}
|