@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,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="app" style="height: 100%"></div>
|
|
11
|
+
<script type="module" src="/src/main.ts"></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": "vue-tsc -b && vite build && node scripts/stamp-manifest.mjs dist",
|
|
10
|
+
"bundle": "vue-tsc -b && vite build && node scripts/stamp-manifest.mjs dist && cd dist && zip -r ../{{APP_NAME}}.zip .",
|
|
11
|
+
"preview": "vite preview",
|
|
12
|
+
"check-types": "vue-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
|
+
"vue": "^3.5.16"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@changesets/cli": "^2.31.0",
|
|
24
|
+
"@tailwindcss/vite": "^4.3.0",
|
|
25
|
+
"@types/node": "^22.19.19",
|
|
26
|
+
"@vitejs/plugin-vue": "^5.2.4",
|
|
27
|
+
"tailwindcss": "4.3.0",
|
|
28
|
+
"typescript": "6.0.3",
|
|
29
|
+
"vite": "8.0.13",
|
|
30
|
+
"vue-tsc": "^2.2.10"
|
|
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,127 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { isDevStandalone, isInsideIframe } from '@bardioc/app-sdk/dev';
|
|
3
|
+
import { ref } from 'vue';
|
|
4
|
+
import { useBardiocBridge, useNotify } from './bardioc-sdk';
|
|
5
|
+
|
|
6
|
+
type ResultState =
|
|
7
|
+
| { status: 'idle' }
|
|
8
|
+
| { status: 'loading'; request: string }
|
|
9
|
+
| { status: 'success'; request: string; data: unknown }
|
|
10
|
+
| { status: 'error'; request: string; message: string };
|
|
11
|
+
|
|
12
|
+
const showSdkDemo = isInsideIframe() || (import.meta.env.VITE_ENABLE_DEV_AUTH === 'true' && isDevStandalone());
|
|
13
|
+
const bridge = useBardiocBridge();
|
|
14
|
+
const notify = useNotify();
|
|
15
|
+
const result = ref<ResultState>({ status: 'idle' });
|
|
16
|
+
const running = ref(false);
|
|
17
|
+
|
|
18
|
+
async function runGetProfile() {
|
|
19
|
+
if (running.value) return;
|
|
20
|
+
running.value = true;
|
|
21
|
+
|
|
22
|
+
const request = 'transport.os.profile.get()';
|
|
23
|
+
result.value = { status: 'loading', request };
|
|
24
|
+
|
|
25
|
+
const startTime = Date.now();
|
|
26
|
+
notify('Getting user profile', 'info');
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
const data = await bridge.transport.os.profile.get();
|
|
30
|
+
|
|
31
|
+
const duration = Date.now() - startTime;
|
|
32
|
+
notify(`Profile loaded (${duration}ms)`, 'success');
|
|
33
|
+
result.value = { status: 'success', request, data };
|
|
34
|
+
} catch (err) {
|
|
35
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
36
|
+
notify(`Failed: ${message}`, 'error');
|
|
37
|
+
result.value = { status: 'error', request, message };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
running.value = false;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function handleNotify() {
|
|
44
|
+
notify('Hello from {{DISPLAY_NAME}}', 'info');
|
|
45
|
+
result.value = {
|
|
46
|
+
status: 'success',
|
|
47
|
+
request: 'SDK_NOTIFY',
|
|
48
|
+
data: { ok: true, message: 'Notification sent to OS' },
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function clearResult() {
|
|
53
|
+
result.value = { status: 'idle' };
|
|
54
|
+
}
|
|
55
|
+
</script>
|
|
56
|
+
|
|
57
|
+
<template>
|
|
58
|
+
<div class="bg-background text-foreground min-h-screen">
|
|
59
|
+
<template v-if="showSdkDemo">
|
|
60
|
+
<div class="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-3 p-4">
|
|
61
|
+
<div class="flex flex-col gap-1">
|
|
62
|
+
<h1 class="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
63
|
+
<p class="text-muted-foreground m-0 text-xs leading-5">
|
|
64
|
+
Minimal hosted-app demo for API transport and SDK APIs.
|
|
65
|
+
</p>
|
|
66
|
+
</div>
|
|
67
|
+
|
|
68
|
+
<div class="flex flex-wrap gap-2">
|
|
69
|
+
<button
|
|
70
|
+
class="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"
|
|
71
|
+
@click="runGetProfile"
|
|
72
|
+
:disabled="running"
|
|
73
|
+
>
|
|
74
|
+
Get Profile
|
|
75
|
+
</button>
|
|
76
|
+
<button
|
|
77
|
+
class="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"
|
|
78
|
+
@click="handleNotify"
|
|
79
|
+
:disabled="running"
|
|
80
|
+
>
|
|
81
|
+
Send Notification OS
|
|
82
|
+
</button>
|
|
83
|
+
<button
|
|
84
|
+
class="border-border text-muted-foreground hover:text-foreground rounded border px-3 py-1 text-xs"
|
|
85
|
+
@click="clearResult"
|
|
86
|
+
:disabled="running"
|
|
87
|
+
>
|
|
88
|
+
Clear
|
|
89
|
+
</button>
|
|
90
|
+
</div>
|
|
91
|
+
|
|
92
|
+
<div class="border-border bg-background flex min-h-0 flex-1 flex-col overflow-hidden rounded border">
|
|
93
|
+
<div v-if="result.status === 'idle'" class="text-muted-foreground flex h-full items-center justify-center p-3 text-center text-xs leading-5">
|
|
94
|
+
Run a query to see results. If the host session is missing, the transport route will return 401.
|
|
95
|
+
</div>
|
|
96
|
+
<div v-else-if="result.status === 'loading'" class="flex h-full flex-col items-center justify-center gap-2 p-3">
|
|
97
|
+
<div class="text-muted-foreground font-mono text-xs">{{ result.request }}</div>
|
|
98
|
+
<div class="text-muted-foreground text-xs">Loading…</div>
|
|
99
|
+
</div>
|
|
100
|
+
<div v-else-if="result.status === 'error'" class="flex h-full flex-col gap-2 p-3 text-xs">
|
|
101
|
+
<div class="text-muted-foreground border-border border-b pb-2 font-mono text-xs">
|
|
102
|
+
{{ result.request }}
|
|
103
|
+
</div>
|
|
104
|
+
<div class="text-destructive whitespace-pre-wrap break-all">{{ result.message }}</div>
|
|
105
|
+
</div>
|
|
106
|
+
<div v-else-if="result.status === 'success'" class="flex h-full flex-col gap-0 overflow-hidden">
|
|
107
|
+
<div class="border-border text-muted-foreground shrink-0 border-b px-3 py-1 font-mono text-xs">
|
|
108
|
+
{{ result.request }}
|
|
109
|
+
</div>
|
|
110
|
+
<pre class="text-foreground flex-1 overflow-auto p-3 text-[11px] leading-5">{{ JSON.stringify(result.data, null, 2) }}</pre>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
</template>
|
|
115
|
+
<template v-else>
|
|
116
|
+
<div class="mx-auto flex min-h-screen w-full max-w-3xl flex-col gap-4 p-4">
|
|
117
|
+
<h1 class="m-0 text-2xl font-semibold">Hello Bardioc App</h1>
|
|
118
|
+
<p class="text-muted-foreground m-0 max-w-2xl text-xs leading-5">
|
|
119
|
+
Open this app inside Bardioc OS to use transport requests and send host notifications.
|
|
120
|
+
</p>
|
|
121
|
+
<div class="border-border bg-muted/20 rounded-xl border p-3 text-xs leading-5">
|
|
122
|
+
Outside the host iframe this page is only a local preview shell.
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
</template>
|
|
126
|
+
</div>
|
|
127
|
+
</template>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { createHostBridge, type HostBridge, type NotifyLevel } from '@bardioc/app-sdk';
|
|
2
|
+
import { inject, type InjectionKey } from 'vue';
|
|
3
|
+
|
|
4
|
+
export const BARDIOC_BRIDGE_KEY: InjectionKey<HostBridge> = Symbol('bardiocBridge');
|
|
5
|
+
|
|
6
|
+
export function createAppSdkBridge(appId: string): HostBridge {
|
|
7
|
+
return createHostBridge({ appId });
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useBardiocBridge(): HostBridge {
|
|
11
|
+
const bridge = inject(BARDIOC_BRIDGE_KEY);
|
|
12
|
+
if (!bridge) {
|
|
13
|
+
throw new Error('useBardiocBridge() must be used after providing BARDIOC_BRIDGE_KEY');
|
|
14
|
+
}
|
|
15
|
+
return bridge;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function useNotify() {
|
|
19
|
+
const bridge = useBardiocBridge();
|
|
20
|
+
return (message: string, level?: NotifyLevel) => {
|
|
21
|
+
bridge.notify(message, level);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
2
|
+
|
|
3
|
+
* {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
html,
|
|
8
|
+
body,
|
|
9
|
+
#app {
|
|
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,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ensureDevAuthSession,
|
|
3
|
+
installDevBridge,
|
|
4
|
+
isDevStandalone,
|
|
5
|
+
isInsideIframe,
|
|
6
|
+
} from '@bardioc/app-sdk/dev';
|
|
7
|
+
import { createApp } from 'vue';
|
|
8
|
+
import App from './App.vue';
|
|
9
|
+
import { BARDIOC_BRIDGE_KEY, createAppSdkBridge } from './bardioc-sdk';
|
|
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
|
+
const app = createApp(App);
|
|
35
|
+
|
|
36
|
+
if (useSdkProvider) {
|
|
37
|
+
app.provide(BARDIOC_BRIDGE_KEY, createAppSdkBridge(APP_ID!));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
app.mount('#app');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
bootstrap();
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
12
|
+
|
|
13
|
+
declare module '*.vue' {
|
|
14
|
+
import type { DefineComponent } from 'vue';
|
|
15
|
+
const component: DefineComponent<object, object, unknown>;
|
|
16
|
+
export default component;
|
|
17
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"module": "ESNext",
|
|
6
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
7
|
+
"skipLibCheck": true,
|
|
8
|
+
"moduleResolution": "bundler",
|
|
9
|
+
"allowImportingTsExtensions": true,
|
|
10
|
+
"isolatedModules": true,
|
|
11
|
+
"moduleDetection": "force",
|
|
12
|
+
"noEmit": true,
|
|
13
|
+
"jsx": "preserve",
|
|
14
|
+
"strict": true,
|
|
15
|
+
"noUnusedLocals": true,
|
|
16
|
+
"noUnusedParameters": true,
|
|
17
|
+
"noFallthroughCasesInSwitch": true,
|
|
18
|
+
"noUncheckedSideEffectImports": true,
|
|
19
|
+
"ignoreDeprecations": "6.0",
|
|
20
|
+
"baseUrl": ".",
|
|
21
|
+
"paths": {
|
|
22
|
+
"@/*": ["./src/*"]
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"include": ["src/**/*.ts", "src/**/*.tsx", "src/**/*.vue"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { bardiocApp, bardiocDevAuth } from '@bardioc/app-sdk/vite';
|
|
2
|
+
import vue from '@vitejs/plugin-vue';
|
|
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 }), vue(), bardiocApp({ appName, port: {{PORT}} }), tailwindcss()],
|
|
16
|
+
};
|
|
17
|
+
});
|