@vibingbase/react-router 0.12.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.
@@ -0,0 +1 @@
1
+ /// <reference types="@vibingbase/common-client/global" />
@@ -0,0 +1,36 @@
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import { MemoExoticComponent } from 'react';
3
+ import type { PropsWithChildren } from 'react';
4
+ import { RESET } from 'jotai/utils';
5
+ import type { TauriInitialization } from '@vibingbase/common-client';
6
+ import type { UseColorSchemeValue } from '@mantine/hooks';
7
+
8
+ export declare const appId: string;
9
+
10
+ export declare function clientMiddlewareFunction(context: unknown, next: () => Promise<unknown>): Promise<void>;
11
+
12
+ export declare type ColorScheme = UseColorSchemeValue;
13
+
14
+ export declare const Config: MemoExoticComponent<() => JSX.Element>;
15
+
16
+ export declare type Initialization = TauriInitialization;
17
+
18
+ export declare function isColorScheme(value: unknown): value is ColorScheme;
19
+
20
+ export declare function isTheme(value: unknown): value is Theme;
21
+
22
+ export declare function Provider({ children }: PropsWithChildren): JSX.Element;
23
+
24
+ export declare const tauriURL: string;
25
+
26
+ export declare type Theme = ColorScheme | "auto";
27
+
28
+ export declare function useInitialization(): TauriInitialization;
29
+
30
+ export declare function useTheme(): {
31
+ theme: Theme;
32
+ setTheme: (args_0: Theme | RESET | ((prev: Theme) => Theme | RESET)) => void;
33
+ colorScheme: UseColorSchemeValue;
34
+ };
35
+
36
+ export { }
package/dist/index.js ADDED
@@ -0,0 +1,13 @@
1
+ var m=import.meta.env.VITE_VIBINGBASE_APP_ID||"vibingbase-template";import{getDefaultStore as N}from"jotai";import{isTauri as U}from"@tauri-apps/api/core";import{atomWithWriteOnly as M,hydrationAtom as $,isInitializedAtom as S}from"@vibingbase/common-client";import{atom as B}from"jotai";import{replace as F}from"react-router";import{getCurrentWindow as T}from"@tauri-apps/api/window";import{getCurrent as E,onOpenUrl as z}from"@tauri-apps/plugin-deep-link";import{relaunch as C}from"@tauri-apps/plugin-process";import{check as D}from"@tauri-apps/plugin-updater";import{atomWithWriteOnly as f,generateEventType as P,isSSR as V,normalizeCallback as W,tauriInitializationAtom as a}from"@vibingbase/common-client";var p=import.meta.env.VITE_VIBINGBASE_APP_ENV||"template-preview";var l=p==="development-release"||p==="production-release";var w=l?m:`app-${m}`;var u=`${w}://localhost`;function d(e){return e===u||e.startsWith(`${u}/`)}var _=f((e,t,o)=>{for(let n of o)if(d(n))break});async function I(){let t=(await E())?.find(n=>d(n));if(t)return t;let o=localStorage.getItem("vibingbase-deep-link");if(o&&d(o))return o}var O=f(async(e,t)=>{t(a,{status:"initializing"});let o;if(l){await T().setFocus(),t(a,{status:"checking-for-updates"});let i=await D();if(i){await i.downloadAndInstall(c=>{switch(c.event){case"Started":{t(a,r=>r?.status==="checking-for-updates"?{status:"downloading-updates",totalLength:c.data.contentLength??0,currentLength:0}:r);break}case"Progress":{t(a,r=>r?.status==="downloading-updates"?{...r,currentLength:r.currentLength+c.data.chunkLength}:r);break}case"Finished":{t(a,r=>r?.status==="downloading-updates"?{status:"relaunching"}:r);break}}});let g=await I();g?localStorage.setItem("vibingbase-deep-link",g):localStorage.removeItem("vibingbase-deep-link"),await C();return}t(a,{status:"initializing"}),await z(e(_));let h=await I();h&&(localStorage.removeItem("vibingbase-deep-link"),o=W(h))}return t(a,{status:"initialized"}),o}),s=class e extends CustomEvent{static type=P();constructor(t){super(e.type,{detail:t})}},R=new Promise((e,t)=>{V||addEventListener(s.type,o=>{if(o instanceof s)switch(o.detail.status){case"fulfilled":{e(o.detail.value);break}case"rejected":{t(o.detail.reason);break}}},{once:!0})}),k=f(async(e,t)=>{if(e(a))return R;try{let o=await t(O);return dispatchEvent(new s({status:"fulfilled",value:o})),o}catch(o){throw dispatchEvent(new s({status:"rejected",reason:o})),o}});var v=B(!1),y=M(async(e,t)=>{let o=e(v);if(o||t(v,!0),await e($),U()){let i=await t(k);if(!o&&i)throw F(i)}e(S)||t(S,!0)});async function _e(e,t){await N().set(y),await t()}import{shallowEqual as G}from"@mantine/hooks";import{memo as q}from"react";import{jsx as H}from"react/jsx-runtime";var $e=q(()=>H("script",{dangerouslySetInnerHTML:{__html:`
2
+ (function() {
3
+ let colorScheme = 'light';
4
+ const theme = localStorage.getItem('${m}/vibingbase-theme');
5
+ if (theme === 'light' || theme === 'dark')
6
+ colorScheme = theme;
7
+ else if (matchMedia('(prefers-color-scheme: dark)').matches)
8
+ colorScheme = 'dark';
9
+ document.documentElement.classList.remove('light', 'dark');
10
+ document.documentElement.classList.add(colorScheme);
11
+ document.documentElement.style.colorScheme = colorScheme;
12
+ })();
13
+ `.trim()}}),G);import{isTauri as Y}from"@tauri-apps/api/core";import{JotaiConnector as Z,TauriColorScheme as ee}from"@vibingbase/common-client";import{useEffect as te}from"react";import{useColorScheme as J}from"@mantine/hooks";import{isSSR as j}from"@vibingbase/common-client";import{useAtom as K}from"jotai";import{atomWithStorage as Q}from"jotai/utils";function L(e){return e==="light"||e==="dark"}function b(e){return L(e)||e==="auto"}var X=Q(`${m}/vibingbase-theme`,"auto",{getItem:(e,t)=>{if(j)return t;let o=localStorage.getItem(e);return b(o)?o:t},setItem:(e,t)=>{localStorage.setItem(e,t)},removeItem:e=>{localStorage.removeItem(e)},subscribe:(e,t,o)=>{let n=i=>{i.storageArea===localStorage&&i.key===e&&t(b(i.newValue)?i.newValue:o)};return addEventListener("storage",n),()=>{removeEventListener("storage",n)}}},{getOnInit:!0});function x(){let[e,t]=K(X),o=J("light",{getInitialValueInEffect:!1});return{theme:e,setTheme:t,colorScheme:L(e)?e:o}}import{Fragment as oe,jsx as A,jsxs as ie}from"react/jsx-runtime";function Ze({children:e}){let{colorScheme:t}=x();return te(()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(t),document.documentElement.style.colorScheme=t},[t]),ie(oe,{children:[A(Z,{}),Y()&&A(ee,{colorScheme:t}),e]})}import{isTauri as re}from"@tauri-apps/api/core";import{isInitializedAtom as ne,tauriInitializationAtom as ae}from"@vibingbase/common-client";import{atom as me,useAtomValue as se}from"jotai";var le=me(e=>re()?e(ae)??{status:"initializing"}:{status:e(ne)?"initialized":"initializing"});function nt(){return se(le)}export{$e as Config,Ze as Provider,m as appId,_e as clientMiddlewareFunction,L as isColorScheme,b as isTheme,u as tauriURL,nt as useInitialization,x as useTheme};
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "@vibingbase/react-router",
3
+ "version": "0.12.0",
4
+ "keywords": [
5
+ "vibingbase",
6
+ "vibe-coding",
7
+ "ai-coding",
8
+ "low-code",
9
+ "no-code"
10
+ ],
11
+ "homepage": "https://www.vibingbase.com",
12
+ "bugs": {
13
+ "url": "https://github.com/vibingbase/apps/issues",
14
+ "email": "team@vibingbase.com"
15
+ },
16
+ "license": "MIT",
17
+ "author": {
18
+ "name": "Vibingbase",
19
+ "email": "team@vibingbase.com"
20
+ },
21
+ "type": "module",
22
+ "imports": {
23
+ "#./*": "./*"
24
+ },
25
+ "exports": {
26
+ ".": {
27
+ "import": "./dist/index.js",
28
+ "types": "./dist/index.d.ts"
29
+ },
30
+ "./global": {
31
+ "types": "./dist/global.d.ts"
32
+ }
33
+ },
34
+ "dependencies": {
35
+ "@mantine/hooks": "^8.3.8",
36
+ "@tauri-apps/api": "^2.9.0",
37
+ "@tauri-apps/plugin-deep-link": "^2.4.5",
38
+ "@tauri-apps/plugin-process": "^2.3.1",
39
+ "@tauri-apps/plugin-updater": "^2.9.0",
40
+ "jotai": "^2.15.1",
41
+ "react": "^19.2.0",
42
+ "react-router": "^7.9.6",
43
+ "@vibingbase/common-client": "^0.12.0",
44
+ "@vibingbase/common-util": "^0.12.0"
45
+ },
46
+ "files": [
47
+ "dist"
48
+ ]
49
+ }