@vibingbase/react-router 0.12.13 → 0.12.15

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/dist/index.d.ts CHANGED
@@ -21,8 +21,12 @@ export declare function isColorScheme(value: unknown): value is ColorScheme;
21
21
 
22
22
  export declare const isLive: boolean;
23
23
 
24
+ export declare const isMac: boolean;
25
+
24
26
  export declare function isTheme(value: unknown): value is Theme;
25
27
 
28
+ export declare const isWindows: boolean;
29
+
26
30
  export declare function Provider({ children }: PropsWithChildren): JSX.Element;
27
31
 
28
32
  export declare type Theme = ColorScheme | "auto";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- function L(){let e="vibingbase-template";try{let t=import.meta.env.VITE_VIBINGBASE_APP_ID;return typeof t=="string"&&t||e}catch{return e}}var i=L();function T(){let e="1.0.0";try{let t=import.meta.env.VITE_VIBINGBASE_APP_VERSION;return typeof t=="string"&&t||e}catch{return e}}var ge=T();import{getDefaultStore as j}from"jotai";import{isTauri as F}from"@tauri-apps/api/core";import{atomWithWriteOnly as G,hydrationAtom as q,isInitializedAtom as v}from"@vibingbase/common-client";import{atom as H}from"jotai";import{replace as J}from"react-router";import{getCurrentWindow as V}from"@tauri-apps/api/window";import{getCurrent as P,onOpenUrl as D}from"@tauri-apps/plugin-deep-link";import{relaunch as _}from"@tauri-apps/plugin-process";import{check as W}from"@tauri-apps/plugin-updater";import{atomWithWriteOnly as f,generateEventType as $,isSSR as O,normalizeCallback as R,tauriInitializationAtom as s}from"@vibingbase/common-client";function z(e){return e==="local-preview"||e==="development-preview"||e==="production-preview"||e==="development-release"||e==="production-release"}function C(){let e="local-preview";try{let t=import.meta.env.VITE_VIBINGBASE_APP_ENV;return z(t)?t:e}catch{return e}}var p=C();var c=p==="development-release"||p==="production-release";var w=c?i:`app-${i}`;var u=`${w}://localhost`;async function U(){try{return await W()??void 0}catch(e){let t="";if(typeof e=="string"?t=e:e instanceof Error&&(t=e.message),!t.includes("error sending request for url"))throw e}}function d(e){return e===u||e.startsWith(`${u}/`)}var B=f((e,t,o)=>{for(let a of o)if(d(a))break});async function I(){let t=(await P())?.find(a=>d(a));if(t)return t;let o=localStorage.getItem(`${i}/vibingbase-deep-link`);if(o&&d(o))return o}var M=f(async(e,t)=>{t(s,{status:"initializing"});let o;if(c){await V().setFocus(),t(s,{status:"checking-for-updates"});let r=await U();if(r){await r.downloadAndInstall(l=>{switch(l.event){case"Started":{t(s,n=>n?.status==="checking-for-updates"?{status:"downloading-updates",totalLength:l.data.contentLength??0,currentLength:0}:n);break}case"Progress":{t(s,n=>n?.status==="downloading-updates"?{...n,currentLength:n.currentLength+l.data.chunkLength}:n);break}case"Finished":{t(s,n=>n?.status==="downloading-updates"?{status:"relaunching"}:n);break}}});let g=await I();g?localStorage.setItem(`${i}/vibingbase-deep-link`,g):localStorage.removeItem(`${i}/vibingbase-deep-link`),await _();return}t(s,{status:"initializing"}),await D(e(B));let h=await I();h&&(localStorage.removeItem(`${i}/vibingbase-deep-link`),o=R(h))}return t(s,{status:"initialized"}),o}),m=class e extends CustomEvent{static type=$();constructor(t){super(e.type,{detail:t})}},N=new Promise((e,t)=>{O||addEventListener(m.type,o=>{if(o instanceof m)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(s))return N;try{let o=await t(M);return dispatchEvent(new m({status:"fulfilled",value:o})),o}catch(o){throw dispatchEvent(new m({status:"rejected",reason:o})),o}});var S=H(!1),y=G(async(e,t)=>{let o=e(S);if(o||t(S,!0),await e(q),F()){let r=await t(k);if(!o&&r)throw J(r)}e(v)||t(v,!0)});async function Fe(e,t){await j().set(y),await t()}import{shallowEqual as K}from"@mantine/hooks";import{memo as Q}from"react";import{jsx as X}from"react/jsx-runtime";var je=Q(()=>X("script",{dangerouslySetInnerHTML:{__html:`
1
+ function V(){let t="vibingbase-template";try{let e=import.meta.env.VITE_VIBINGBASE_APP_ID;return typeof e=="string"&&e||t}catch{return t}}var r=V();function C(){let t="1.0.0";try{let e=import.meta.env.VITE_VIBINGBASE_APP_VERSION;return typeof e=="string"&&e||t}catch{return t}}var xt=C();import{getDefaultStore as Y}from"jotai";import{isTauri as J}from"@tauri-apps/api/core";import{atomWithWriteOnly as j,hydrationAtom as K,isInitializedAtom as A}from"@vibingbase/common-client";import{atom as Q}from"jotai";import{replace as X}from"react-router";import{getCurrentWindow as _}from"@tauri-apps/api/window";import{getCurrent as M,onOpenUrl as O}from"@tauri-apps/plugin-deep-link";import{relaunch as R}from"@tauri-apps/plugin-process";import{check as $}from"@tauri-apps/plugin-updater";import{atomWithWriteOnly as h,generateEventType as B,isSSR as U,normalizeCallback as N,tauriInitializationAtom as m}from"@vibingbase/common-client";function D(t){return t==="local-preview"||t==="development-preview"||t==="production-preview"||t==="development-release"||t==="production-release"}function W(){let t="local-preview";try{let e=import.meta.env.VITE_VIBINGBASE_APP_ENV;return D(e)?e:t}catch{return t}}var a=W();var p=a==="development-release"||a==="production-release";var I=p?r:`app-${r}`;var d=`${I}://localhost`;async function G(){try{return await $()??void 0}catch(t){let e="";if(typeof t=="string"?e=t:t instanceof Error&&(e=t.message),!e.includes("error sending request for url"))throw t}}function f(t){return t===d||t.startsWith(`${d}/`)}var F=h((t,e,o)=>{for(let s of o)if(f(s))break});async function k(){let e=(await M())?.find(s=>f(s));if(e)return e;let o=localStorage.getItem(`${r}/vibingbase-deep-link`);if(o&&f(o))return o}var q=h(async(t,e)=>{e(m,{status:"initializing"});let o;if(p){await _().setFocus(),e(m,{status:"checking-for-updates"});let i=await G();if(i){await i.downloadAndInstall(u=>{switch(u.event){case"Started":{e(m,n=>n?.status==="checking-for-updates"?{status:"downloading-updates",totalLength:u.data.contentLength??0,currentLength:0}:n);break}case"Progress":{e(m,n=>n?.status==="downloading-updates"?{...n,currentLength:n.currentLength+u.data.chunkLength}:n);break}case"Finished":{e(m,n=>n?.status==="downloading-updates"?{status:"relaunching"}:n);break}}});let v=await k();v?localStorage.setItem(`${r}/vibingbase-deep-link`,v):localStorage.removeItem(`${r}/vibingbase-deep-link`),await R();return}e(m,{status:"initializing"}),await O(t(F));let w=await k();w&&(localStorage.removeItem(`${r}/vibingbase-deep-link`),o=N(w))}return e(m,{status:"initialized"}),o}),c=class t extends CustomEvent{static type=B();constructor(e){super(t.type,{detail:e})}},H=new Promise((t,e)=>{U||addEventListener(c.type,o=>{if(o instanceof c)switch(o.detail.status){case"fulfilled":{t(o.detail.value);break}case"rejected":{e(o.detail.reason);break}}},{once:!0})}),S=h(async(t,e)=>{if(t(m))return H;try{let o=await e(q);return dispatchEvent(new c({status:"fulfilled",value:o})),o}catch(o){throw dispatchEvent(new c({status:"rejected",reason:o})),o}});var y=Q(!1),T=j(async(t,e)=>{let o=t(y);if(o||e(y,!0),await t(K),J()){let i=await e(S);if(!o&&i)throw X(i)}t(A)||e(A,!0)});async function Yt(t,e){await Y().set(T),await e()}import{shallowEqual as Z}from"@mantine/hooks";import{memo as tt}from"react";import{jsx as et}from"react/jsx-runtime";var re=tt(()=>et("script",{dangerouslySetInnerHTML:{__html:`
2
2
  (function() {
3
3
  let colorScheme = 'light';
4
- const theme = localStorage.getItem('${i}/vibingbase-theme');
4
+ const theme = localStorage.getItem('${r}/vibingbase-theme');
5
5
  if (theme === 'light' || theme === 'dark')
6
6
  colorScheme = theme;
7
7
  else if (matchMedia('(prefers-color-scheme: dark)').matches)
@@ -10,4 +10,4 @@ function L(){let e="vibingbase-template";try{let t=import.meta.env.VITE_VIBINGBA
10
10
  document.documentElement.classList.add(colorScheme);
11
11
  document.documentElement.style.colorScheme = colorScheme;
12
12
  })();
13
- `.trim()}}),K);import{isTauri as ie}from"@tauri-apps/api/core";import{JotaiConnector as re,TauriColorScheme as ne}from"@vibingbase/common-client";import{useEffect as ae}from"react";import{useColorScheme as Y}from"@mantine/hooks";import{isSSR as Z}from"@vibingbase/common-client";import{useAtom as ee}from"jotai";import{atomWithStorage as te}from"jotai/utils";function b(e){return e==="light"||e==="dark"}function A(e){return b(e)||e==="auto"}var oe=te(`${i}/vibingbase-theme`,"auto",{getItem:(e,t)=>{if(Z)return t;let o=localStorage.getItem(e);return A(o)?o:t},setItem:(e,t)=>{localStorage.setItem(e,t)},removeItem:e=>{localStorage.removeItem(e)},subscribe:(e,t,o)=>{let a=r=>{r.storageArea===localStorage&&r.key===e&&t(A(r.newValue)?r.newValue:o)};return addEventListener("storage",a),()=>{removeEventListener("storage",a)}}},{getOnInit:!0});function E(){let[e,t]=ee(oe),o=Y("light",{getInitialValueInEffect:!1});return{theme:e,setTheme:t,colorScheme:b(e)?e:o}}import{Fragment as se,jsx as x,jsxs as me}from"react/jsx-runtime";function st({children:e}){let{colorScheme:t}=E();return ae(()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(t),document.documentElement.style.colorScheme=t},[t]),me(se,{children:[x(re,{}),ie()&&x(ne,{colorScheme:t}),e]})}import{isTauri as ce}from"@tauri-apps/api/core";import{isInitializedAtom as le,tauriInitializationAtom as pe}from"@vibingbase/common-client";import{atom as ue,useAtomValue as de}from"jotai";var fe=ue(e=>ce()?e(pe)??{status:"initializing"}:{status:e(le)?"initialized":"initializing"});function dt(){return de(fe)}export{je as Config,st as Provider,i as appId,ge as appVersion,Fe as clientMiddlewareFunction,b as isColorScheme,c as isLive,A as isTheme,dt as useInitialization,E as useTheme};
13
+ `.trim()}}),Z);import{isAppTarget as nt}from"@vibingbase/common-client";import{isSSR as ot}from"@vibingbase/common-client";import{connect as rt,WindowMessenger as it}from"penpal";var x=a==="development-preview"||a==="production-preview";var E=a==="production-preview"||a==="production-release";var g=x&&!ot?await rt({messenger:new it({remoteWindow:parent,allowedOrigins:[E?"https://app.vibingbase.com":"http://localhost:1420","tauri://localhost","http://tauri.localhost","https://tauri.localhost"]})}).promise:void 0;function at(){try{if(g)return g.getAppTarget();let t=import.meta.env.VITE_VIBINGBASE_APP_TARGET;return nt(t)?t:void 0}catch{}}var l=await at();var Ie=l==="macOS";var Ae=l==="Windows";import{isTauri as ut}from"@tauri-apps/api/core";import{JotaiConnector as dt,TauriColorScheme as ft}from"@vibingbase/common-client";import{useEffect as ht}from"react";import{useColorScheme as st}from"@mantine/hooks";import{isSSR as mt}from"@vibingbase/common-client";import{useAtom as ct}from"jotai";import{atomWithStorage as pt}from"jotai/utils";function L(t){return t==="light"||t==="dark"}function b(t){return L(t)||t==="auto"}var lt=pt(`${r}/vibingbase-theme`,"auto",{getItem:(t,e)=>{if(mt)return e;let o=localStorage.getItem(t);return b(o)?o:e},setItem:(t,e)=>{localStorage.setItem(t,e)},removeItem:t=>{localStorage.removeItem(t)},subscribe:(t,e,o)=>{let s=i=>{i.storageArea===localStorage&&i.key===t&&e(b(i.newValue)?i.newValue:o)};return addEventListener("storage",s),()=>{removeEventListener("storage",s)}}},{getOnInit:!0});function z(){let[t,e]=ct(lt),o=st("light",{getInitialValueInEffect:!1});return{theme:t,setTheme:e,colorScheme:L(t)?t:o}}import{Fragment as gt,jsx as P,jsxs as wt}from"react/jsx-runtime";function We({children:t}){let{colorScheme:e}=z();return ht(()=>{document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(e),document.documentElement.style.colorScheme=e},[e]),wt(gt,{children:[P(dt,{}),ut()&&P(ft,{colorScheme:e}),t]})}import{isTauri as vt}from"@tauri-apps/api/core";import{isInitializedAtom as It,tauriInitializationAtom as kt}from"@vibingbase/common-client";import{atom as St,useAtomValue as At}from"jotai";var yt=St(t=>vt()?t(kt)??{status:"initializing"}:{status:t(It)?"initialized":"initializing"});function Be(){return At(yt)}export{re as Config,We as Provider,r as appId,xt as appVersion,Yt as clientMiddlewareFunction,L as isColorScheme,p as isLive,Ie as isMac,b as isTheme,Ae as isWindows,Be as useInitialization,z as useTheme};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibingbase/react-router",
3
- "version": "0.12.13",
3
+ "version": "0.12.15",
4
4
  "keywords": [
5
5
  "vibingbase",
6
6
  "vibe-coding",
@@ -38,10 +38,11 @@
38
38
  "@tauri-apps/plugin-process": "^2.3.1",
39
39
  "@tauri-apps/plugin-updater": "^2.9.0",
40
40
  "jotai": "^2.15.1",
41
+ "penpal": "^7.0.4",
41
42
  "react": "^19.2.0",
42
43
  "react-router": "^7.9.6",
43
- "@vibingbase/common-client": "^0.12.13",
44
- "@vibingbase/common-util": "^0.12.13"
44
+ "@vibingbase/common-client": "^0.12.15",
45
+ "@vibingbase/common-util": "^0.12.15"
45
46
  },
46
47
  "files": [
47
48
  "dist"