@base44-preview/cli 0.1.5-pr.577.1701370 → 0.1.5-pr.578.bad1ac7

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.
@@ -9,7 +9,8 @@
9
9
  "preview": "vite preview"
10
10
  },
11
11
  "dependencies": {
12
- "@base44/sdk": "^0.8.3",
12
+ "@base44/sdk": "^0.8.40",
13
+ "@base44/vite-plugin": "^1.0.30",
13
14
  "lucide-react": "^0.475.0",
14
15
  "react": "^18.2.0",
15
16
  "react-dom": "^18.2.0"
@@ -0,0 +1,14 @@
1
+ import { createClient } from '@base44/sdk';
2
+ import { appParams } from '@/lib/app-params';
3
+
4
+ const { appId, token, functionsVersion, appBaseUrl } = appParams;
5
+
6
+ //Create a client with authentication required
7
+ export const base44 = createClient({
8
+ appId,
9
+ token,
10
+ functionsVersion,
11
+ serverUrl: '',
12
+ requiresAuth: false,
13
+ appBaseUrl
14
+ });
@@ -0,0 +1,54 @@
1
+ const isNode = typeof window === 'undefined';
2
+ const windowObj = isNode ? { localStorage: new Map() } : window;
3
+ const storage = windowObj.localStorage;
4
+
5
+ const toSnakeCase = (str) => {
6
+ return str.replace(/([A-Z])/g, '_$1').toLowerCase();
7
+ }
8
+
9
+ const getAppParamValue = (paramName, { defaultValue = undefined, removeFromUrl = false } = {}) => {
10
+ if (isNode) {
11
+ return defaultValue;
12
+ }
13
+ const storageKey = `base44_${toSnakeCase(paramName)}`;
14
+ const urlParams = new URLSearchParams(window.location.search);
15
+ const searchParam = urlParams.get(paramName);
16
+ if (removeFromUrl) {
17
+ urlParams.delete(paramName);
18
+ const newUrl = `${window.location.pathname}${urlParams.toString() ? `?${urlParams.toString()}` : ""
19
+ }${window.location.hash}`;
20
+ window.history.replaceState({}, document.title, newUrl);
21
+ }
22
+ if (searchParam) {
23
+ storage.setItem(storageKey, searchParam);
24
+ return searchParam;
25
+ }
26
+ if (defaultValue) {
27
+ storage.setItem(storageKey, defaultValue);
28
+ return defaultValue;
29
+ }
30
+ const storedValue = storage.getItem(storageKey);
31
+ if (storedValue) {
32
+ return storedValue;
33
+ }
34
+ return null;
35
+ }
36
+
37
+ const getAppParams = () => {
38
+ if (getAppParamValue("clear_access_token") === 'true') {
39
+ storage.removeItem('base44_access_token');
40
+ storage.removeItem('token');
41
+ }
42
+ return {
43
+ appId: getAppParamValue("app_id", { defaultValue: import.meta.env.VITE_BASE44_APP_ID }),
44
+ token: getAppParamValue("access_token", { removeFromUrl: true }),
45
+ fromUrl: getAppParamValue("from_url", { defaultValue: window.location.href }),
46
+ functionsVersion: getAppParamValue("functions_version", { defaultValue: import.meta.env.VITE_BASE44_FUNCTIONS_VERSION }),
47
+ appBaseUrl: getAppParamValue("app_base_url", { defaultValue: import.meta.env.VITE_BASE44_APP_BASE_URL }),
48
+ }
49
+ }
50
+
51
+
52
+ export const appParams = {
53
+ ...getAppParams()
54
+ }
@@ -1,12 +1,7 @@
1
- import { defineConfig } from 'vite';
1
+ import base44 from '@base44/vite-plugin';
2
2
  import react from '@vitejs/plugin-react';
3
- import path from 'path';
3
+ import { defineConfig } from 'vite';
4
4
 
5
5
  export default defineConfig({
6
- plugins: [react()],
7
- resolve: {
8
- alias: {
9
- '@': path.resolve(__dirname, './src'),
10
- },
11
- },
6
+ plugins: [base44(), react()],
12
7
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@base44-preview/cli",
3
- "version": "0.1.5-pr.577.1701370",
3
+ "version": "0.1.5-pr.578.bad1ac7",
4
4
  "description": "Base44 CLI - Unified interface for managing Base44 applications",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,5 +0,0 @@
1
- import { createClient } from '@base44/sdk';
2
-
3
- export const base44 = createClient({
4
- appId: '<%= projectId %>',
5
- });