@buoy-gg/three 7.0.76 → 7.0.78

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ThreeModal=ThreeModal;exports.ThreeToolView=ThreeToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _runtime=require("./runtime");var _jsxRuntime=require("react/jsx-runtime");const text={color:_sharedUi.night.color.text,fontSize:13};function Field({label:s,value:n,save:h}){const[x,l]=(0,_react.useState)(n);const[r,a]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{if(!r)l(n)},[n,r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",gap:8,padding:4},children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:s}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{testID:`three-edit-${s}`,accessibilityLabel:s,value:x,onChangeText:u=>{l(u);a(true)},style:[text,{borderWidth:1,borderColor:"#666",padding:4,flex:1}]}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`three-save-${s}`,onPress:()=>{h(x);a(false)},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Save"})})]})}function ThreeToolView({scenes:s,dispatch:n,refresh:h}){const[x,l]=(0,_react.useState)(_runtime.getThreeScene);const[r,a]=(0,_react.useState)();const[u,T]=(0,_react.useState)("");(0,_react.useEffect)(()=>s?void 0:(0,_runtime.subscribeThree)(()=>l((0,_runtime.getThreeScene)())),[s]);const f=s??x;const o=async e=>{try{await(n??_runtime.threeAction)(e);T("");if(!s)l((0,_runtime.getThreeScene)())}catch(t){T(t instanceof Error?t.message:"The change failed.")}};const i=f.find(e=>e.id===r?.rendererId)?.nodes.find(e=>e.id===r?.id);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{testID:"three-panel",style:{flex:1,backgroundColor:_sharedUi.night.color.bg},contentContainerStyle:{padding:12,gap:8},children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[text,{fontSize:18}],children:"Scene"}),!f.length&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"No scene found. Call registerThree in your app."}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"three-refresh",onPress:async()=>{try{if(h)await h();else l((0,_runtime.getThreeScene)());T("")}catch(e){T(e instanceof Error?e.message:"The refresh failed.")}},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Refresh"})}),i&&r&&(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"three-details",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:i.name||i.type}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"three-visible",onPress:()=>void o({...r,action:"visible",value:!i.visible}),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:i.visible?"Hide":"Show"})}),["position","rotation","scale"].map(e=>(0,_jsxRuntime.jsx)(Field,{label:e,value:i[e].join(", "),save:t=>void o({...r,action:e,value:t.split(",").map(d=>d.trim()?Number(d):NaN)})},e)),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Turn values use radians."}),i.color&&(0,_jsxRuntime.jsx)(Field,{label:"color",value:i.color,save:e=>void o({...r,action:"color",value:e})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"three-clear-selection",onPress:()=>{void o({...r,action:"clearSelection"});a(void 0)},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Clear box"})})]},`${r.rendererId}:${r.id}`),f.map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:e.id}),!e.nodes.length&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Pass a scene to registerThree to link this view."}),e.nodes.map(t=>(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`three-node-${t.name||t.type}`,onPress:()=>{a({rendererId:e.id,id:t.id});void o({rendererId:e.id,id:t.id,action:"select"})},children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[text,{padding:5,paddingLeft:5+Math.min(20,(()=>{let d=0;let c=t.parent;const p=new Set;while(c&&!p.has(c)){p.add(c);d++;c=e.nodes.find(y=>y.id===c)?.parent??null}return d})())*12}],children:[t.visible?"\u25CF":"\u25CB"," ",t.name||t.type]})},t.id)),e.truncated&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Tree limit reached. Some nodes are left out."})]},e.id)),!!u&&(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"alert",style:text,children:u})]})}function ThreeModal({visible:s,onClose:n}){return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:s,onClose:n,header:{title:"Scene"},initialMode:"bottomSheet",disableScrollWrapper:true,children:(0,_jsxRuntime.jsx)(ThreeToolView,{})})}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ThreeModal=ThreeModal;exports.ThreeToolView=ThreeToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _runtime=require("./runtime");var _jsxRuntime=require("react/jsx-runtime");const text={color:_sharedUi.night.color.text,fontSize:13};function Field({label:s,value:n,save:h}){const[u,l]=(0,_react.useState)(n);const[r,a]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{if(!r)l(n)},[n,r]);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:{flexDirection:"row",gap:8,padding:4},children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:s}),(0,_jsxRuntime.jsx)(_reactNative.TextInput,{testID:`three-edit-${s}`,accessibilityLabel:s,value:u,onChangeText:x=>{l(x);a(true)},style:[text,{borderWidth:1,borderColor:"#666",padding:4,flex:1}]}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`three-save-${s}`,onPress:()=>{h(u);a(false)},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Save"})})]})}function ThreeToolView({scenes:s,dispatch:n,refresh:h}){const[u,l]=(0,_react.useState)(_runtime.getThreeScene);const[r,a]=(0,_react.useState)();const[x,T]=(0,_react.useState)("");(0,_react.useEffect)(()=>s?void 0:(0,_runtime.subscribeThree)(()=>l((0,_runtime.getThreeScene)())),[s]);const p=s??u;const o=async e=>{try{await(n??_runtime.threeAction)(e);T("");if(!s)l((0,_runtime.getThreeScene)())}catch(t){T(t instanceof Error?t.message:"The change failed.")}};const i=p.find(e=>e.id===r?.rendererId)?.nodes.find(e=>e.id===r?.id);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",testID:"three-panel",style:{flex:1,backgroundColor:_sharedUi.night.color.bg},contentContainerStyle:{padding:12,gap:8},children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[text,{fontSize:18}],children:"Scene"}),!p.length&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"No scene found. Call registerThree in your app."}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"three-refresh",onPress:async()=>{try{if(h)await h();else l((0,_runtime.getThreeScene)());T("")}catch(e){T(e instanceof Error?e.message:"The refresh failed.")}},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Refresh"})}),i&&r&&(0,_jsxRuntime.jsxs)(_reactNative.View,{testID:"three-details",children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:i.name||i.type}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"three-visible",onPress:()=>void o({...r,action:"visible",value:!i.visible}),children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:i.visible?"Hide":"Show"})}),["position","rotation","scale"].map(e=>(0,_jsxRuntime.jsx)(Field,{label:e,value:i[e].join(", "),save:t=>void o({...r,action:e,value:t.split(",").map(d=>d.trim()?Number(d):NaN)})},e)),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Turn values use radians."}),i.color&&(0,_jsxRuntime.jsx)(Field,{label:"color",value:i.color,save:e=>void o({...r,action:"color",value:e})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:"three-clear-selection",onPress:()=>{void o({...r,action:"clearSelection"});a(void 0)},children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Clear box"})})]},`${r.rendererId}:${r.id}`),p.map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:e.id}),!e.nodes.length&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Pass a scene to registerThree to link this view."}),e.nodes.map(t=>(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{testID:`three-node-${t.name||t.type}`,onPress:()=>{a({rendererId:e.id,id:t.id});void o({rendererId:e.id,id:t.id,action:"select"})},children:(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[text,{padding:5,paddingLeft:5+Math.min(20,(()=>{let d=0;let c=t.parent;const y=new Set;while(c&&!y.has(c)){y.add(c);d++;c=e.nodes.find(f=>f.id===c)?.parent??null}return d})())*12}],children:[t.visible?"\u25CF":"\u25CB"," ",t.name||t.type]})},t.id)),e.truncated&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:text,children:"Tree limit reached. Some nodes are left out."})]},e.id)),!!x&&(0,_jsxRuntime.jsx)(_reactNative.Text,{accessibilityRole:"alert",style:text,children:x})]})}function ThreeModal({visible:s,onClose:n}){return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:s,onClose:n,header:{title:"Scene"},initialMode:"bottomSheet",disableScrollWrapper:true,children:(0,_jsxRuntime.jsx)(ThreeToolView,{})})}
@@ -1 +1 @@
1
- "use strict";import{useEffect as w,useState as u}from"react";import{ScrollView as $,Text as n,TextInput as E,TouchableOpacity as y,View as I}from"react-native";import{JsModal as M,night as C}from"@buoy-gg/shared-ui";import{getThreeScene as T,threeAction as N,subscribeThree as L}from"./runtime";import{jsx as t,jsxs as v}from"react/jsx-runtime";const r={color:C.color.text,fontSize:13};function P({label:l,value:d,save:b}){const[g,a]=u(d);const[s,c]=u(false);w(()=>{if(!s)a(d)},[d,s]);return v(I,{style:{flexDirection:"row",gap:8,padding:4},children:[t(n,{style:r,children:l}),t(E,{testID:`three-edit-${l}`,accessibilityLabel:l,value:g,onChangeText:S=>{a(S);c(true)},style:[r,{borderWidth:1,borderColor:"#666",padding:4,flex:1}]}),t(y,{testID:`three-save-${l}`,onPress:()=>{b(g);c(false)},children:t(n,{style:r,children:"Save"})})]})}export function ThreeToolView({scenes:l,dispatch:d,refresh:b}){const[g,a]=u(T);const[s,c]=u();const[S,x]=u("");w(()=>l?void 0:L(()=>a(T())),[l]);const m=l??g;const h=async e=>{try{await(d??N)(e);x("");if(!l)a(T())}catch(i){x(i instanceof Error?i.message:"The change failed.")}};const o=m.find(e=>e.id===s?.rendererId)?.nodes.find(e=>e.id===s?.id);return v($,{testID:"three-panel",style:{flex:1,backgroundColor:C.color.bg},contentContainerStyle:{padding:12,gap:8},children:[t(n,{style:[r,{fontSize:18}],children:"Scene"}),!m.length&&t(n,{style:r,children:"No scene found. Call registerThree in your app."}),t(y,{testID:"three-refresh",onPress:async()=>{try{if(b)await b();else a(T());x("")}catch(e){x(e instanceof Error?e.message:"The refresh failed.")}},children:t(n,{style:r,children:"Refresh"})}),o&&s&&v(I,{testID:"three-details",children:[t(n,{style:r,children:o.name||o.type}),t(y,{testID:"three-visible",onPress:()=>void h({...s,action:"visible",value:!o.visible}),children:t(n,{style:r,children:o.visible?"Hide":"Show"})}),["position","rotation","scale"].map(e=>t(P,{label:e,value:o[e].join(", "),save:i=>void h({...s,action:e,value:i.split(",").map(f=>f.trim()?Number(f):NaN)})},e)),t(n,{style:r,children:"Turn values use radians."}),o.color&&t(P,{label:"color",value:o.color,save:e=>void h({...s,action:"color",value:e})}),t(y,{testID:"three-clear-selection",onPress:()=>{void h({...s,action:"clearSelection"});c(void 0)},children:t(n,{style:r,children:"Clear box"})})]},`${s.rendererId}:${s.id}`),m.map(e=>v(I,{children:[t(n,{style:r,children:e.id}),!e.nodes.length&&t(n,{style:r,children:"Pass a scene to registerThree to link this view."}),e.nodes.map(i=>t(y,{testID:`three-node-${i.name||i.type}`,onPress:()=>{c({rendererId:e.id,id:i.id});void h({rendererId:e.id,id:i.id,action:"select"})},children:v(n,{style:[r,{padding:5,paddingLeft:5+Math.min(20,(()=>{let f=0;let p=i.parent;const D=new Set;while(p&&!D.has(p)){D.add(p);f++;p=e.nodes.find(j=>j.id===p)?.parent??null}return f})())*12}],children:[i.visible?"\u25CF":"\u25CB"," ",i.name||i.type]})},i.id)),e.truncated&&t(n,{style:r,children:"Tree limit reached. Some nodes are left out."})]},e.id)),!!S&&t(n,{accessibilityRole:"alert",style:r,children:S})]})}export function ThreeModal({visible:l,onClose:d}){return t(M,{visible:l,onClose:d,header:{title:"Scene"},initialMode:"bottomSheet",disableScrollWrapper:true,children:t(ThreeToolView,{})})}
1
+ "use strict";import{useEffect as w,useState as u}from"react";import{ScrollView as $,Text as n,TextInput as E,TouchableOpacity as y,View as I}from"react-native";import{JsModal as M,night as C}from"@buoy-gg/shared-ui";import{getThreeScene as x,threeAction as N,subscribeThree as L}from"./runtime";import{jsx as t,jsxs as b}from"react/jsx-runtime";const r={color:C.color.text,fontSize:13};function P({label:l,value:d,save:v}){const[g,a]=u(d);const[s,c]=u(false);w(()=>{if(!s)a(d)},[d,s]);return b(I,{style:{flexDirection:"row",gap:8,padding:4},children:[t(n,{style:r,children:l}),t(E,{testID:`three-edit-${l}`,accessibilityLabel:l,value:g,onChangeText:S=>{a(S);c(true)},style:[r,{borderWidth:1,borderColor:"#666",padding:4,flex:1}]}),t(y,{testID:`three-save-${l}`,onPress:()=>{v(g);c(false)},children:t(n,{style:r,children:"Save"})})]})}export function ThreeToolView({scenes:l,dispatch:d,refresh:v}){const[g,a]=u(x);const[s,c]=u();const[S,T]=u("");w(()=>l?void 0:L(()=>a(x())),[l]);const m=l??g;const h=async e=>{try{await(d??N)(e);T("");if(!l)a(x())}catch(i){T(i instanceof Error?i.message:"The change failed.")}};const o=m.find(e=>e.id===s?.rendererId)?.nodes.find(e=>e.id===s?.id);return b($,{keyboardShouldPersistTaps:"handled",testID:"three-panel",style:{flex:1,backgroundColor:C.color.bg},contentContainerStyle:{padding:12,gap:8},children:[t(n,{style:[r,{fontSize:18}],children:"Scene"}),!m.length&&t(n,{style:r,children:"No scene found. Call registerThree in your app."}),t(y,{testID:"three-refresh",onPress:async()=>{try{if(v)await v();else a(x());T("")}catch(e){T(e instanceof Error?e.message:"The refresh failed.")}},children:t(n,{style:r,children:"Refresh"})}),o&&s&&b(I,{testID:"three-details",children:[t(n,{style:r,children:o.name||o.type}),t(y,{testID:"three-visible",onPress:()=>void h({...s,action:"visible",value:!o.visible}),children:t(n,{style:r,children:o.visible?"Hide":"Show"})}),["position","rotation","scale"].map(e=>t(P,{label:e,value:o[e].join(", "),save:i=>void h({...s,action:e,value:i.split(",").map(f=>f.trim()?Number(f):NaN)})},e)),t(n,{style:r,children:"Turn values use radians."}),o.color&&t(P,{label:"color",value:o.color,save:e=>void h({...s,action:"color",value:e})}),t(y,{testID:"three-clear-selection",onPress:()=>{void h({...s,action:"clearSelection"});c(void 0)},children:t(n,{style:r,children:"Clear box"})})]},`${s.rendererId}:${s.id}`),m.map(e=>b(I,{children:[t(n,{style:r,children:e.id}),!e.nodes.length&&t(n,{style:r,children:"Pass a scene to registerThree to link this view."}),e.nodes.map(i=>t(y,{testID:`three-node-${i.name||i.type}`,onPress:()=>{c({rendererId:e.id,id:i.id});void h({rendererId:e.id,id:i.id,action:"select"})},children:b(n,{style:[r,{padding:5,paddingLeft:5+Math.min(20,(()=>{let f=0;let p=i.parent;const D=new Set;while(p&&!D.has(p)){D.add(p);f++;p=e.nodes.find(j=>j.id===p)?.parent??null}return f})())*12}],children:[i.visible?"\u25CF":"\u25CB"," ",i.name||i.type]})},i.id)),e.truncated&&t(n,{style:r,children:"Tree limit reached. Some nodes are left out."})]},e.id)),!!S&&t(n,{accessibilityRole:"alert",style:r,children:S})]})}export function ThreeModal({visible:l,onClose:d}){return t(M,{visible:l,onClose:d,header:{title:"Scene"},initialMode:"bottomSheet",disableScrollWrapper:true,children:t(ThreeToolView,{})})}
package/lib/web/index.mjs CHANGED
@@ -1 +1 @@
1
- "use client";var J=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var ke=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:true})},X=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ee(t))!Se.call(e,r)&&r!==n&&J(e,r,{get:()=>t[r],enumerable:!(o=xe(t,r))||o.enumerable});return e},Te=(e,t,n)=>(X(e,t,"default"),n&&X(n,t,"default"));var tr=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);var Q={};ke(Q,{AccessibilityInfo:()=>Pe,ActivityIndicator:()=>Mt,Alert:()=>Bt,Animated:()=>Ct,AppRegistry:()=>Ie,AppState:()=>Me,Appearance:()=>$e,BackHandler:()=>Ne,Button:()=>Nt,CheckBox:()=>qe,Clipboard:()=>De,DeviceEventEmitter:()=>ut,Dimensions:()=>Be,Easing:()=>Re,FlatList:()=>Je,I18nManager:()=>Oe,Image:()=>Xe,ImageBackground:()=>Qe,InteractionManager:()=>We,Keyboard:()=>je,KeyboardAvoidingView:()=>Ze,LayoutAnimation:()=>Ve,Linking:()=>Fe,LogBox:()=>ct,Modal:()=>$t,NativeEventEmitter:()=>Ke,NativeModules:()=>Le,PanResponder:()=>ze,Picker:()=>et,PixelRatio:()=>He,Platform:()=>_e,Pressable:()=>Pt,ProgressBar:()=>tt,RefreshControl:()=>rt,SafeAreaView:()=>nt,ScrollView:()=>oe,SectionList:()=>ot,Share:()=>Ue,StatusBar:()=>at,StyleSheet:()=>Tt,Switch:()=>It,Text:()=>m,TextInput:()=>ne,Touchable:()=>it,TouchableHighlight:()=>At,TouchableNativeFeedback:()=>st,TouchableOpacity:()=>C,TouchableWithoutFeedback:()=>Lt,UIManager:()=>Ge,Vibration:()=>Ye,View:()=>L,VirtualizedList:()=>lt,YellowBox:()=>dt,findNodeHandle:()=>Dt,unstable_createElement:()=>Ae,useColorScheme:()=>ft,useLocaleContext:()=>pt,useWindowDimensions:()=>ht});Te(Q,Ce);import*as Ce from"react-native-web";import{unstable_createElement as Ae,NativeModules as Le,AccessibilityInfo as Pe,Appearance as $e,AppRegistry as Ie,AppState as Me,BackHandler as Ne,Clipboard as De,Dimensions as Be,Easing as Re,I18nManager as Oe,Keyboard as je,InteractionManager as We,LayoutAnimation as Ve,Linking as Fe,NativeEventEmitter as Ke,PanResponder as ze,PixelRatio as He,Platform as _e,Share as Ue,UIManager as Ge,Vibration as Ye,CheckBox as qe,FlatList as Je,Image as Xe,ImageBackground as Qe,KeyboardAvoidingView as Ze,Picker as et,ProgressBar as tt,RefreshControl as rt,SafeAreaView as nt,SectionList as ot,StatusBar as at,Touchable as it,TouchableNativeFeedback as st,VirtualizedList as lt,YellowBox as dt,LogBox as ct,DeviceEventEmitter as ut,useColorScheme as ft,useLocaleContext as pt,useWindowDimensions as ht}from"react-native-web";import*as b from"react-native-web";import{createElement as j,forwardRef as Z,useCallback as mt,useRef as yt}from"react";import{useEffect as bt,useState as vt}from"react";import{createPortal as gt}from"react-dom";var wt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as xt}from"react/jsx-runtime";var A=Symbol.for("@buoy-gg/portal-host"),ee=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function te(){let e=document;if(e[A])return e[A].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:wt});let n=()=>{let i=document.fullscreenElement,s=i&&i.tagName!=="CANVAS"?i:document.body;t.parentElement!==s&&s.appendChild(t)},o=new Map,r=i=>{(!t.contains(i.target)||!ee(i.target))&&o.set(i.code||i.key,{key:i.key,code:i.code,location:i.location,keyCode:i.keyCode,which:i.which,altKey:i.altKey,ctrlKey:i.ctrlKey,metaKey:i.metaKey,shiftKey:i.shiftKey})},a=i=>{o.delete(i.code||i.key)},l=()=>o.clear(),p=()=>{let i=[...o.values()];o.clear();for(let s of i)document.dispatchEvent(new KeyboardEvent("keyup",{...s,bubbles:true}))},c=i=>{ee(i.target)&&i.stopPropagation()},u=i=>i.stopPropagation();return n(),document.addEventListener("fullscreenchange",n),document.addEventListener("keydown",r,true),document.addEventListener("keyup",a,true),window.addEventListener("blur",l),t.addEventListener("focusin",p),t.addEventListener("keydown",c),t.addEventListener("keyup",c),t.addEventListener("keypress",c),t.addEventListener("wheel",u,{passive:true}),e[A]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",n),document.removeEventListener("keydown",r,true),document.removeEventListener("keyup",a,true),window.removeEventListener("blur",l),t.remove(),delete e[A]}},t}function Et({children:e}){let[t,n]=vt(null);return bt(()=>{let o=te(),r=document[A];return r.users++,n(o),()=>{--r.users===0&&r.dispose()}},[]),t?gt(xt("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var k=b,St=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],T=e=>typeof e=="number"?`${e}px`:e;function W(e){if(Array.isArray(e)){let s=e.map(W);return s.some((d,f)=>d!==e[f])?s:e}if(!e||typeof e!="object"||!St.some(s=>e[s]!=null))return e;let{shadowColor:t,shadowOffset:n,shadowOpacity:o,shadowRadius:r,textShadowColor:a,textShadowOffset:l,textShadowRadius:p,...c}=e;if(t!=null||n!=null||o!=null||r!=null){let s=t??"black",d=o==null?s:`color-mix(in srgb, ${s} ${Math.min(o,1)*100}%, transparent)`,f=`${T(n?.width??0)} ${T(n?.height??0)} ${T(r??0)} ${d}`;c.boxShadow=typeof c.boxShadow=="string"?`${c.boxShadow}, ${f}`:c.boxShadow??f}let{width:u=0,height:i=0}=l??{};if(a&&(u||i||p)){let s=`${T(u)} ${T(i)} ${T(p??0)} ${a}`;c.textShadow=c.textShadow?`${c.textShadow}, ${s}`:s}return c}var kt=k.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function re(e,t){if(typeof e=="function")return o=>re(e(o),t);let n=W(e);return t?[n,kt[t]]:n}var Tt={...k.StyleSheet,create:e=>k.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,n])=>[t,W(n)])))};function w(e){let t=Z((o,r)=>{let{accessibilityState:a,accessibilityValue:l,pointerEvents:p,...c}=o;for(let i of["busy","checked","disabled","expanded","selected"])a?.[i]!==void 0&&c[`aria-${i}`]===void 0&&(c[`aria-${i}`]=a[i]);for(let[i,s]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[i]!==void 0&&c[`aria-${s}`]===void 0&&(c[`aria-${s}`]=l[i]);let u=re(c.style,p);return u!==c.style&&(c.style=u),j(e,{...c,ref:r})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var L=w(b.View),m=w(b.Text),Ct={...k.Animated,View:k.Animated.createAnimatedComponent(L),Text:k.Animated.createAnimatedComponent(m)},ne=w(b.TextInput),C=w(b.TouchableOpacity),At=w(b.TouchableHighlight),Lt=w(b.TouchableWithoutFeedback),Pt=w(b.Pressable),oe=w(b.ScrollView),ae=Z((e,t)=>{let n=yt(null),o=mt(r=>{if(r){let a=r;for(;a.parentElement&&a.parentElement!==document.body;)a=a.parentElement;a.parentElement===document.body&&(n.current=a,Object.assign(a.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),te().appendChild(a))}else n.current&&(document.body.appendChild(n.current),n.current=null);typeof t=="function"?t(r):t&&(t.current=r)},[t]);return j(Et,null,j(b.Modal,{...e,ref:o}))});ae.displayName="Modal";var $t=w(ae),It=w(b.Switch),Mt=w(b.ActivityIndicator),Nt=w(b.Button),Dt=b.findNodeHandle,Bt={alert(e,t,n,o){if(typeof document>"u")return;let r=document.createElement("dialog");r.dataset.buoyRoot="",r.setAttribute("aria-label",e),r.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",r.appendChild(a),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",r.appendChild(u)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let p=n?.length?n:[{text:"OK"}],c=()=>{r.close?.(),r.remove()};for(let u of p){let i=document.createElement("button");i.type="button",i.textContent=u.text??"OK",i.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,i.onclick=()=>{c(),u.onPress?.()},l.appendChild(i)}r.addEventListener("cancel",u=>{u.preventDefault(),o?.cancelable!==false&&(c(),o?.onDismiss?.())}),r.appendChild(l),document.body.appendChild(r),r.showModal?r.showModal():r.setAttribute("open","")}};import{defineToolPreset as Rt,createToolFactory as Ot}from"@buoy-gg/shared-ui/web";import{useEffect as ie,useState as P}from"react";import{JsModal as jt,night as se}from"@buoy-gg/shared-ui/web";import{BoxHelper as Wt,DefaultLoadingManager as le}from"three";import{registerPerfSeries as Vt}from"@buoy-gg/perf-monitor/web";import{subscribeThreeBootEvents as Ft}from"@buoy-gg/core/web/three";var $=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Kt(e){let{render:t,memory:n,programs:o}=e.info,r=e.isWebGPURenderer===true;return{kind:r?"WebGPU":"WebGL",calls:$(r?t?.drawCalls:t?.calls),triangles:$(t?.triangles),geometries:$(n?.geometries),textures:$(n?.textures),programs:r?$(n?.programs):Array.isArray(o)?o.length:null}}var V=new WeakMap;function de(e,t){return()=>{let n=e.deref();if(!n)return;let o=V.get(n);!o||t&&o.token!==t||(o.deactivate(),n.render===o.wrapped&&(n.render=o.original),V.delete(n))}}function zt(e,t){let n=new WeakRef(e);de(n)();let o={},r=e.render,a=false,l=true,p,c=0,u=0;function i(){a||!l||(a=true,queueMicrotask(()=>{a=false;let d=n.deref();if(!l||!d)return;let f=Kt(d),v=Date.now();v-u>=1e3&&(c=p&&["geometries","textures"].some(x=>{let E=p[x],B=f[x];return E!==null&&B!==null&&B>E})?c+1:0,p=f,u=v),c>=5&&(f.note="Keeps growing");try{t(f)}catch{}}))}function s(...d){let f=r.apply(this,d);return f&&typeof f.then=="function"?f.then(i,()=>{}):i(),f}return e.render=s,V.set(e,{token:o,original:r,wrapped:s,deactivate:()=>{l=false}}),de(n,o)}var Ht=500;function ce(e,t=500){let n=Number.isFinite(t)?Math.max(1,Math.min(500,Math.floor(t))):500,o=[],r=[{node:e,parent:null}],a=new Set,l=false;for(;r.length&&o.length<n;){let{node:p,parent:c}=r.pop();if(a.has(p)||p.userData.__buoyThreeHelper)continue;a.add(p),o.push({node:p,parent:c});let u=n-o.length-r.length;p.children.length>u&&(l=true);for(let i=Math.min(p.children.length,u)-1;i>=0;i--)r.push({node:p.children[i],parent:p.uuid})}return{nodes:o,truncated:l||r.length>0}}function ue(e,t=500){let n=ce(e,t);return{nodes:n.nodes.map(({node:o,parent:r})=>{let a=o.material,l=(Array.isArray(a)?a[0]:a)?.color;return{id:o.uuid,parent:r,name:o.name.slice(0,160),type:o.type.slice(0,80),visible:o.visible,position:o.position.toArray(),rotation:[o.rotation.x,o.rotation.y,o.rotation.z],scale:o.scale.toArray(),color:l?.isColor?`#${l.getHexString()}`:null}}),truncated:n.truncated}}function _t(e,t){return ce(e).nodes.find(({node:n})=>n.uuid===t)?.node}import{Cache as R}from"three";import{recordBrowserAssetLoad as Ut}from"@buoy-gg/assets/web";var F=new Set,Gt=0,Yt=e=>(F.add(e),()=>{F.delete(e)});function qt(e,t,n,o){let r;if(typeof performance<"u"&&typeof performance.getEntriesByName=="function"){let a;try{a=typeof document<"u"?new URL(e,document.baseURI).href:e}catch{a=e}r=performance.getEntriesByName(a,"resource").filter(l=>l.responseEnd>=o).pop()}return{url:e,status:t,bytes:r&&r.encodedBodySize>0?r.encodedBodySize:null,durationMs:r?r.duration:null,cacheHit:n===true?true:r&&r.encodedBodySize>0?r.transferSize===0:null}}var O=new WeakMap;function fe(e){let t=false;return()=>{if(t)return;t=true;let n=e.deref();if(!n)return;let o=O.get(n);o&&--o.users===0&&(o.stop(),O.delete(n))}}function pe(e){let t=new WeakRef(e),n=O.get(e);if(n)return n.users++,fe(t);let o=e.itemStart,r=e.itemEnd,a=e.itemError,l=new Map;function p(s){let d=l.get(s)??[],f=R.get(`image-bitmap:${s}`);return d.push({started:performance.now(),cached:R.get(`file:${s}`)!==void 0||R.get(`image:${s}`)?.complete===true||f!==void 0&&typeof f?.then!="function"||R.get(s)!==void 0,failed:false}),l.set(s,d),o.call(this,s)}function c(s,d){let f=l.get(s)?.[0];if(!f||f.failed)return;f.failed=d;let v=qt(s,d?"error":"success",f.cached,f.started);try{Ut(v)}catch{}let x={id:`three-load-${++Gt}`,source:"three",timestamp:Date.now(),title:d?"Load failed":v.cacheHit?"Cache hit":"Loaded",subtitle:s.slice(0,512),status:v.status,originalEvent:v};F.forEach(E=>{try{E(x)}catch{}})}function u(s){c(s,false);let d=l.get(s);return d?.shift(),d?.length||l.delete(s),r.call(this,s)}function i(s){return c(s,true),a.call(this,s)}return e.itemStart=p,e.itemEnd=u,e.itemError=i,O.set(e,{users:1,stop:()=>{let s=t.deref();s?.itemStart===p&&(s.itemStart=o),s?.itemEnd===u&&(s.itemEnd=r),s?.itemError===i&&(s.itemError=a),l.clear()}}),fe(t)}var g=new Map,K=new Set,Jt=0,z=false,I,H,_,M=()=>{z=true};function N(e){e.stop(),e.helper?.deref()?.removeFromParent(),e.helper?.deref()?.dispose(),g.delete(e.id),M()}function U(e,t,n,o){for(let u of g.values())(e&&u.renderer?.deref()===e||t&&u.scene?.deref()===t&&!u.renderer)&&N(u);g.size>=32&&N(g.values().next().value);let r=`three-${++Jt}`,a={id:r,renderer:e&&new WeakRef(e),scene:t&&new WeakRef(t),camera:n&&new WeakRef(n),stop:()=>{}},l=Vt(r),p=e?zt(e,u=>{a.stats=u,l.update(["calls","triangles","geometries","textures","programs"].map(i=>({id:`${r}:${i}`,label:`${r} ${i}`,value:u[i],unit:"count",note:u.note}))),M()}):()=>{},c=o&&o!==le?pe(o):()=>{};return a.stop=()=>{p(),c(),l.dispose()},g.set(r,a),M(),()=>{g.get(r)===a&&N(a)}}function Xt(e){return he(),U(e.renderer,e.scene,e.camera,e.loadingManager)}function he(){I||(_=pe(le),typeof window<"u"&&(H=Ft(({type:e,detail:t})=>{if(e!=="observe"||!t||typeof t!="object")return;let n=t;n.isScene&&![...g.values()].some(o=>o.scene?.deref()===n)&&U(void 0,n),n.info&&typeof n.render=="function"&&![...g.values()].some(o=>o.renderer?.deref()===n)&&U(n)})),I=setInterval(()=>{for(let e of g.values())(e.renderer&&!e.renderer.deref()||e.scene&&!e.scene.deref())&&N(e);z&&(z=false,K.forEach(e=>e()))},500))}function me(){H?.(),_?.(),H=void 0,_=void 0,I&&clearInterval(I),I=void 0;for(let e of g.values())N(e)}function G(e){return K.add(e),()=>{K.delete(e)}}function Y(){return[...g.values()].map(e=>({id:e.id,stats:e.stats??null}))}function S(){return[...g.values()].map(e=>({id:e.id,...e.scene?.deref()&&ue(e.scene.deref())||{nodes:[],truncated:false}}))}function q(e){let t=g.get(e.rendererId),n=t?.scene?.deref();if(!t||!n)throw new Error("Scene not found. Refresh the list.");if(e.action==="clearSelection")return t.helper?.deref()?.removeFromParent(),t.helper?.deref()?.dispose(),t.helper=void 0,{ok:true};let o=e.id&&_t(n,e.id);if(!o)throw new Error("Object not found in this scene.");switch(e.action){case"select":{t.helper?.deref()?.removeFromParent(),t.helper?.deref()?.dispose(),o.updateWorldMatrix(true,false);let r=new Wt(o,16776960);r.userData.__buoyThreeHelper=true,n.add(r),t.helper=new WeakRef(r);break}case"visible":if(typeof e.value!="boolean")throw new Error("Use true or false.");o.visible=e.value;break;case"position":case"rotation":case"scale":{let r=e.value;if(!Array.isArray(r)||r.length!==3||!r.every(a=>typeof a=="number"&&Number.isFinite(a)))throw new Error("Use three finite numbers.");o[e.action].set(r[0],r[1],r[2]);break}case"color":{if(typeof e.value!="string"||!/^#[0-9a-f]{6}$/i.test(e.value))throw new Error("Use a six digit hex color.");let r=o.material,a=Array.isArray(r)?r:[r];if(!a.some(l=>l?.color?.isColor))throw new Error("This object has no color.");a.forEach(l=>l?.color?.set(e.value));break}default:throw new Error("Unknown scene action.")}return o.updateWorldMatrix(true,false),t.helper?.deref()?.update(),M(),{ok:true}}var Qt={version:1,getSnapshot:()=>({scenes:S(),stats:Y()}),subscribe:G,actions:{getScene:()=>(M(),S()),getStats:Y,action:e=>q(e)}},ye=globalThis;ye.__buoyThreeDispose?.();ye.__buoyThreeDispose=me;import{jsx as h,jsxs as D}from"react/jsx-runtime";var y={color:se.color.text,fontSize:13};function be({label:e,value:t,save:n}){let[o,r]=P(t),[a,l]=P(false);return ie(()=>{a||r(t)},[t,a]),D(L,{style:{flexDirection:"row",gap:8,padding:4},children:[h(m,{style:y,children:e}),h(ne,{testID:`three-edit-${e}`,accessibilityLabel:e,value:o,onChangeText:p=>{r(p),l(true)},style:[y,{borderWidth:1,borderColor:"#666",padding:4,flex:1}]}),h(C,{testID:`three-save-${e}`,onPress:()=>{n(o),l(false)},children:h(m,{style:y,children:"Save"})})]})}function ve({scenes:e,dispatch:t,refresh:n}){let[o,r]=P(S),[a,l]=P(),[p,c]=P("");ie(()=>e?void 0:G(()=>r(S())),[e]);let u=e??o,i=async d=>{try{await(t??q)(d),c(""),e||r(S())}catch(f){c(f instanceof Error?f.message:"The change failed.")}},s=u.find(d=>d.id===a?.rendererId)?.nodes.find(d=>d.id===a?.id);return D(oe,{testID:"three-panel",style:{flex:1,backgroundColor:se.color.bg},contentContainerStyle:{padding:12,gap:8},children:[h(m,{style:[y,{fontSize:18}],children:"Scene"}),!u.length&&h(m,{style:y,children:"No scene found. Call registerThree in your app."}),h(C,{testID:"three-refresh",onPress:async()=>{try{n?await n():r(S()),c("")}catch(d){c(d instanceof Error?d.message:"The refresh failed.")}},children:h(m,{style:y,children:"Refresh"})}),s&&a&&D(L,{testID:"three-details",children:[h(m,{style:y,children:s.name||s.type}),h(C,{testID:"three-visible",onPress:()=>void i({...a,action:"visible",value:!s.visible}),children:h(m,{style:y,children:s.visible?"Hide":"Show"})}),["position","rotation","scale"].map(d=>h(be,{label:d,value:s[d].join(", "),save:f=>void i({...a,action:d,value:f.split(",").map(v=>v.trim()?Number(v):NaN)})},d)),h(m,{style:y,children:"Turn values use radians."}),s.color&&h(be,{label:"color",value:s.color,save:d=>void i({...a,action:"color",value:d})}),h(C,{testID:"three-clear-selection",onPress:()=>{i({...a,action:"clearSelection"}),l(void 0)},children:h(m,{style:y,children:"Clear box"})})]},`${a.rendererId}:${a.id}`),u.map(d=>D(L,{children:[h(m,{style:y,children:d.id}),!d.nodes.length&&h(m,{style:y,children:"Pass a scene to registerThree to link this view."}),d.nodes.map(f=>h(C,{testID:`three-node-${f.name||f.type}`,onPress:()=>{l({rendererId:d.id,id:f.id}),i({rendererId:d.id,id:f.id,action:"select"})},children:D(m,{style:[y,{padding:5,paddingLeft:5+Math.min(20,(()=>{let v=0,x=f.parent,E=new Set;for(;x&&!E.has(x);)E.add(x),v++,x=d.nodes.find(B=>B.id===x)?.parent??null;return v})())*12}],children:[f.visible?"\u25CF":"\u25CB"," ",f.name||f.type]})},f.id)),d.truncated&&h(m,{style:y,children:"Tree limit reached. Some nodes are left out."})]},d.id)),!!p&&h(m,{accessibilityRole:"alert",style:y,children:p})]})}function ge({visible:e,onClose:t}){return h(jt,{visible:e,onClose:t,header:{title:"Scene"},initialMode:"bottomSheet",disableScrollWrapper:true,children:h(ve,{})})}import{jsx as Zt}from"react/jsx-runtime";var we=Rt({id:"three",name:"SCENE",description:"See and edit the 3D scene.",slot:"both",icon:({size:e,color:t})=>Zt(m,{style:{fontSize:e,color:t??"#F59E0B"},children:"\u25C7"}),component:ge}),er=Ot(we);export{Ht as MAX_SCENE_NODES,ge as ThreeModal,ve as ThreeToolView,er as createThreeTool,me as disposeThree,S as getThreeScene,Y as getThreeStats,Yt as onThreeLoad,Xt as registerThree,ue as snapshotScene,he as startThreeCapture,G as subscribeThree,q as threeAction,Qt as threeSyncAdapter,we as threeToolPreset};
1
+ "use client";var J=Object.defineProperty;var xe=Object.getOwnPropertyDescriptor;var Ee=Object.getOwnPropertyNames;var Se=Object.prototype.hasOwnProperty;var ke=(e,t)=>{for(var n in t)J(e,n,{get:t[n],enumerable:true})},X=(e,t,n,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ee(t))!Se.call(e,r)&&r!==n&&J(e,r,{get:()=>t[r],enumerable:!(o=xe(t,r))||o.enumerable});return e},Te=(e,t,n)=>(X(e,t,"default"),n&&X(n,t,"default"));var tr=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);var Q={};ke(Q,{AccessibilityInfo:()=>Pe,ActivityIndicator:()=>Mt,Alert:()=>Bt,Animated:()=>Ct,AppRegistry:()=>Ie,AppState:()=>Me,Appearance:()=>$e,BackHandler:()=>Ne,Button:()=>Nt,CheckBox:()=>qe,Clipboard:()=>De,DeviceEventEmitter:()=>ut,Dimensions:()=>Be,Easing:()=>Re,FlatList:()=>Je,I18nManager:()=>Oe,Image:()=>Xe,ImageBackground:()=>Qe,InteractionManager:()=>We,Keyboard:()=>je,KeyboardAvoidingView:()=>Ze,LayoutAnimation:()=>Ve,Linking:()=>Fe,LogBox:()=>ct,Modal:()=>$t,NativeEventEmitter:()=>Ke,NativeModules:()=>Le,PanResponder:()=>ze,Picker:()=>et,PixelRatio:()=>He,Platform:()=>_e,Pressable:()=>Pt,ProgressBar:()=>tt,RefreshControl:()=>rt,SafeAreaView:()=>nt,ScrollView:()=>oe,SectionList:()=>ot,Share:()=>Ue,StatusBar:()=>at,StyleSheet:()=>Tt,Switch:()=>It,Text:()=>m,TextInput:()=>ne,Touchable:()=>it,TouchableHighlight:()=>At,TouchableNativeFeedback:()=>st,TouchableOpacity:()=>C,TouchableWithoutFeedback:()=>Lt,UIManager:()=>Ge,Vibration:()=>Ye,View:()=>L,VirtualizedList:()=>lt,YellowBox:()=>dt,findNodeHandle:()=>Dt,unstable_createElement:()=>Ae,useColorScheme:()=>ft,useLocaleContext:()=>pt,useWindowDimensions:()=>ht});Te(Q,Ce);import*as Ce from"react-native-web";import{unstable_createElement as Ae,NativeModules as Le,AccessibilityInfo as Pe,Appearance as $e,AppRegistry as Ie,AppState as Me,BackHandler as Ne,Clipboard as De,Dimensions as Be,Easing as Re,I18nManager as Oe,Keyboard as je,InteractionManager as We,LayoutAnimation as Ve,Linking as Fe,NativeEventEmitter as Ke,PanResponder as ze,PixelRatio as He,Platform as _e,Share as Ue,UIManager as Ge,Vibration as Ye,CheckBox as qe,FlatList as Je,Image as Xe,ImageBackground as Qe,KeyboardAvoidingView as Ze,Picker as et,ProgressBar as tt,RefreshControl as rt,SafeAreaView as nt,SectionList as ot,StatusBar as at,Touchable as it,TouchableNativeFeedback as st,VirtualizedList as lt,YellowBox as dt,LogBox as ct,DeviceEventEmitter as ut,useColorScheme as ft,useLocaleContext as pt,useWindowDimensions as ht}from"react-native-web";import*as b from"react-native-web";import{createElement as j,forwardRef as Z,useCallback as mt,useRef as yt}from"react";import{useEffect as bt,useState as vt}from"react";import{createPortal as gt}from"react-dom";var wt='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as xt}from"react/jsx-runtime";var A=Symbol.for("@buoy-gg/portal-host"),ee=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function te(){let e=document;if(e[A])return e[A].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:wt});let n=()=>{let i=document.fullscreenElement,s=i&&i.tagName!=="CANVAS"?i:document.body;t.parentElement!==s&&s.appendChild(t)},o=new Map,r=i=>{(!t.contains(i.target)||!ee(i.target))&&o.set(i.code||i.key,{key:i.key,code:i.code,location:i.location,keyCode:i.keyCode,which:i.which,altKey:i.altKey,ctrlKey:i.ctrlKey,metaKey:i.metaKey,shiftKey:i.shiftKey})},a=i=>{o.delete(i.code||i.key)},l=()=>o.clear(),p=()=>{let i=[...o.values()];o.clear();for(let s of i)document.dispatchEvent(new KeyboardEvent("keyup",{...s,bubbles:true}))},c=i=>{ee(i.target)&&i.stopPropagation()},u=i=>i.stopPropagation();return n(),document.addEventListener("fullscreenchange",n),document.addEventListener("keydown",r,true),document.addEventListener("keyup",a,true),window.addEventListener("blur",l),t.addEventListener("focusin",p),t.addEventListener("keydown",c),t.addEventListener("keyup",c),t.addEventListener("keypress",c),t.addEventListener("wheel",u,{passive:true}),e[A]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",n),document.removeEventListener("keydown",r,true),document.removeEventListener("keyup",a,true),window.removeEventListener("blur",l),t.remove(),delete e[A]}},t}function Et({children:e}){let[t,n]=vt(null);return bt(()=>{let o=te(),r=document[A];return r.users++,n(o),()=>{--r.users===0&&r.dispose()}},[]),t?gt(xt("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var k=b,St=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],T=e=>typeof e=="number"?`${e}px`:e;function W(e){if(Array.isArray(e)){let s=e.map(W);return s.some((d,f)=>d!==e[f])?s:e}if(!e||typeof e!="object"||!St.some(s=>e[s]!=null))return e;let{shadowColor:t,shadowOffset:n,shadowOpacity:o,shadowRadius:r,textShadowColor:a,textShadowOffset:l,textShadowRadius:p,...c}=e;if(t!=null||n!=null||o!=null||r!=null){let s=t??"black",d=o==null?s:`color-mix(in srgb, ${s} ${Math.min(o,1)*100}%, transparent)`,f=`${T(n?.width??0)} ${T(n?.height??0)} ${T(r??0)} ${d}`;c.boxShadow=typeof c.boxShadow=="string"?`${c.boxShadow}, ${f}`:c.boxShadow??f}let{width:u=0,height:i=0}=l??{};if(a&&(u||i||p)){let s=`${T(u)} ${T(i)} ${T(p??0)} ${a}`;c.textShadow=c.textShadow?`${c.textShadow}, ${s}`:s}return c}var kt=k.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function re(e,t){if(typeof e=="function")return o=>re(e(o),t);let n=W(e);return t?[n,kt[t]]:n}var Tt={...k.StyleSheet,create:e=>k.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,n])=>[t,W(n)])))};function w(e){let t=Z((o,r)=>{let{accessibilityState:a,accessibilityValue:l,pointerEvents:p,...c}=o;for(let i of["busy","checked","disabled","expanded","selected"])a?.[i]!==void 0&&c[`aria-${i}`]===void 0&&(c[`aria-${i}`]=a[i]);for(let[i,s]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))l?.[i]!==void 0&&c[`aria-${s}`]===void 0&&(c[`aria-${s}`]=l[i]);let u=re(c.style,p);return u!==c.style&&(c.style=u),j(e,{...c,ref:r})}),n=e.State;return n&&Object.assign(t,{State:n}),t.displayName=e.displayName??e.name??"NativeWebView",t}var L=w(b.View),m=w(b.Text),Ct={...k.Animated,View:k.Animated.createAnimatedComponent(L),Text:k.Animated.createAnimatedComponent(m)},ne=w(b.TextInput),C=w(b.TouchableOpacity),At=w(b.TouchableHighlight),Lt=w(b.TouchableWithoutFeedback),Pt=w(b.Pressable),oe=w(b.ScrollView),ae=Z((e,t)=>{let n=yt(null),o=mt(r=>{if(r){let a=r;for(;a.parentElement&&a.parentElement!==document.body;)a=a.parentElement;a.parentElement===document.body&&(n.current=a,Object.assign(a.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),te().appendChild(a))}else n.current&&(document.body.appendChild(n.current),n.current=null);typeof t=="function"?t(r):t&&(t.current=r)},[t]);return j(Et,null,j(b.Modal,{...e,ref:o}))});ae.displayName="Modal";var $t=w(ae),It=w(b.Switch),Mt=w(b.ActivityIndicator),Nt=w(b.Button),Dt=b.findNodeHandle,Bt={alert(e,t,n,o){if(typeof document>"u")return;let r=document.createElement("dialog");r.dataset.buoyRoot="",r.setAttribute("aria-label",e),r.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",r.appendChild(a),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",r.appendChild(u)}let l=document.createElement("div");l.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let p=n?.length?n:[{text:"OK"}],c=()=>{r.close?.(),r.remove()};for(let u of p){let i=document.createElement("button");i.type="button",i.textContent=u.text??"OK",i.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,i.onclick=()=>{c(),u.onPress?.()},l.appendChild(i)}r.addEventListener("cancel",u=>{u.preventDefault(),o?.cancelable!==false&&(c(),o?.onDismiss?.())}),r.appendChild(l),document.body.appendChild(r),r.showModal?r.showModal():r.setAttribute("open","")}};import{defineToolPreset as Rt,createToolFactory as Ot}from"@buoy-gg/shared-ui/web";import{useEffect as ie,useState as P}from"react";import{JsModal as jt,night as se}from"@buoy-gg/shared-ui/web";import{BoxHelper as Wt,DefaultLoadingManager as le}from"three";import{registerPerfSeries as Vt}from"@buoy-gg/perf-monitor/web";import{subscribeThreeBootEvents as Ft}from"@buoy-gg/core/web/three";var $=e=>typeof e=="number"&&Number.isFinite(e)?e:null;function Kt(e){let{render:t,memory:n,programs:o}=e.info,r=e.isWebGPURenderer===true;return{kind:r?"WebGPU":"WebGL",calls:$(r?t?.drawCalls:t?.calls),triangles:$(t?.triangles),geometries:$(n?.geometries),textures:$(n?.textures),programs:r?$(n?.programs):Array.isArray(o)?o.length:null}}var V=new WeakMap;function de(e,t){return()=>{let n=e.deref();if(!n)return;let o=V.get(n);!o||t&&o.token!==t||(o.deactivate(),n.render===o.wrapped&&(n.render=o.original),V.delete(n))}}function zt(e,t){let n=new WeakRef(e);de(n)();let o={},r=e.render,a=false,l=true,p,c=0,u=0;function i(){a||!l||(a=true,queueMicrotask(()=>{a=false;let d=n.deref();if(!l||!d)return;let f=Kt(d),v=Date.now();v-u>=1e3&&(c=p&&["geometries","textures"].some(x=>{let E=p[x],B=f[x];return E!==null&&B!==null&&B>E})?c+1:0,p=f,u=v),c>=5&&(f.note="Keeps growing");try{t(f)}catch{}}))}function s(...d){let f=r.apply(this,d);return f&&typeof f.then=="function"?f.then(i,()=>{}):i(),f}return e.render=s,V.set(e,{token:o,original:r,wrapped:s,deactivate:()=>{l=false}}),de(n,o)}var Ht=500;function ce(e,t=500){let n=Number.isFinite(t)?Math.max(1,Math.min(500,Math.floor(t))):500,o=[],r=[{node:e,parent:null}],a=new Set,l=false;for(;r.length&&o.length<n;){let{node:p,parent:c}=r.pop();if(a.has(p)||p.userData.__buoyThreeHelper)continue;a.add(p),o.push({node:p,parent:c});let u=n-o.length-r.length;p.children.length>u&&(l=true);for(let i=Math.min(p.children.length,u)-1;i>=0;i--)r.push({node:p.children[i],parent:p.uuid})}return{nodes:o,truncated:l||r.length>0}}function ue(e,t=500){let n=ce(e,t);return{nodes:n.nodes.map(({node:o,parent:r})=>{let a=o.material,l=(Array.isArray(a)?a[0]:a)?.color;return{id:o.uuid,parent:r,name:o.name.slice(0,160),type:o.type.slice(0,80),visible:o.visible,position:o.position.toArray(),rotation:[o.rotation.x,o.rotation.y,o.rotation.z],scale:o.scale.toArray(),color:l?.isColor?`#${l.getHexString()}`:null}}),truncated:n.truncated}}function _t(e,t){return ce(e).nodes.find(({node:n})=>n.uuid===t)?.node}import{Cache as R}from"three";import{recordBrowserAssetLoad as Ut}from"@buoy-gg/assets/web";var F=new Set,Gt=0,Yt=e=>(F.add(e),()=>{F.delete(e)});function qt(e,t,n,o){let r;if(typeof performance<"u"&&typeof performance.getEntriesByName=="function"){let a;try{a=typeof document<"u"?new URL(e,document.baseURI).href:e}catch{a=e}r=performance.getEntriesByName(a,"resource").filter(l=>l.responseEnd>=o).pop()}return{url:e,status:t,bytes:r&&r.encodedBodySize>0?r.encodedBodySize:null,durationMs:r?r.duration:null,cacheHit:n===true?true:r&&r.encodedBodySize>0?r.transferSize===0:null}}var O=new WeakMap;function fe(e){let t=false;return()=>{if(t)return;t=true;let n=e.deref();if(!n)return;let o=O.get(n);o&&--o.users===0&&(o.stop(),O.delete(n))}}function pe(e){let t=new WeakRef(e),n=O.get(e);if(n)return n.users++,fe(t);let o=e.itemStart,r=e.itemEnd,a=e.itemError,l=new Map;function p(s){let d=l.get(s)??[],f=R.get(`image-bitmap:${s}`);return d.push({started:performance.now(),cached:R.get(`file:${s}`)!==void 0||R.get(`image:${s}`)?.complete===true||f!==void 0&&typeof f?.then!="function"||R.get(s)!==void 0,failed:false}),l.set(s,d),o.call(this,s)}function c(s,d){let f=l.get(s)?.[0];if(!f||f.failed)return;f.failed=d;let v=qt(s,d?"error":"success",f.cached,f.started);try{Ut(v)}catch{}let x={id:`three-load-${++Gt}`,source:"three",timestamp:Date.now(),title:d?"Load failed":v.cacheHit?"Cache hit":"Loaded",subtitle:s.slice(0,512),status:v.status,originalEvent:v};F.forEach(E=>{try{E(x)}catch{}})}function u(s){c(s,false);let d=l.get(s);return d?.shift(),d?.length||l.delete(s),r.call(this,s)}function i(s){return c(s,true),a.call(this,s)}return e.itemStart=p,e.itemEnd=u,e.itemError=i,O.set(e,{users:1,stop:()=>{let s=t.deref();s?.itemStart===p&&(s.itemStart=o),s?.itemEnd===u&&(s.itemEnd=r),s?.itemError===i&&(s.itemError=a),l.clear()}}),fe(t)}var g=new Map,K=new Set,Jt=0,z=false,I,H,_,M=()=>{z=true};function N(e){e.stop(),e.helper?.deref()?.removeFromParent(),e.helper?.deref()?.dispose(),g.delete(e.id),M()}function U(e,t,n,o){for(let u of g.values())(e&&u.renderer?.deref()===e||t&&u.scene?.deref()===t&&!u.renderer)&&N(u);g.size>=32&&N(g.values().next().value);let r=`three-${++Jt}`,a={id:r,renderer:e&&new WeakRef(e),scene:t&&new WeakRef(t),camera:n&&new WeakRef(n),stop:()=>{}},l=Vt(r),p=e?zt(e,u=>{a.stats=u,l.update(["calls","triangles","geometries","textures","programs"].map(i=>({id:`${r}:${i}`,label:`${r} ${i}`,value:u[i],unit:"count",note:u.note}))),M()}):()=>{},c=o&&o!==le?pe(o):()=>{};return a.stop=()=>{p(),c(),l.dispose()},g.set(r,a),M(),()=>{g.get(r)===a&&N(a)}}function Xt(e){return he(),U(e.renderer,e.scene,e.camera,e.loadingManager)}function he(){I||(_=pe(le),typeof window<"u"&&(H=Ft(({type:e,detail:t})=>{if(e!=="observe"||!t||typeof t!="object")return;let n=t;n.isScene&&![...g.values()].some(o=>o.scene?.deref()===n)&&U(void 0,n),n.info&&typeof n.render=="function"&&![...g.values()].some(o=>o.renderer?.deref()===n)&&U(n)})),I=setInterval(()=>{for(let e of g.values())(e.renderer&&!e.renderer.deref()||e.scene&&!e.scene.deref())&&N(e);z&&(z=false,K.forEach(e=>e()))},500))}function me(){H?.(),_?.(),H=void 0,_=void 0,I&&clearInterval(I),I=void 0;for(let e of g.values())N(e)}function G(e){return K.add(e),()=>{K.delete(e)}}function Y(){return[...g.values()].map(e=>({id:e.id,stats:e.stats??null}))}function S(){return[...g.values()].map(e=>({id:e.id,...e.scene?.deref()&&ue(e.scene.deref())||{nodes:[],truncated:false}}))}function q(e){let t=g.get(e.rendererId),n=t?.scene?.deref();if(!t||!n)throw new Error("Scene not found. Refresh the list.");if(e.action==="clearSelection")return t.helper?.deref()?.removeFromParent(),t.helper?.deref()?.dispose(),t.helper=void 0,{ok:true};let o=e.id&&_t(n,e.id);if(!o)throw new Error("Object not found in this scene.");switch(e.action){case"select":{t.helper?.deref()?.removeFromParent(),t.helper?.deref()?.dispose(),o.updateWorldMatrix(true,false);let r=new Wt(o,16776960);r.userData.__buoyThreeHelper=true,n.add(r),t.helper=new WeakRef(r);break}case"visible":if(typeof e.value!="boolean")throw new Error("Use true or false.");o.visible=e.value;break;case"position":case"rotation":case"scale":{let r=e.value;if(!Array.isArray(r)||r.length!==3||!r.every(a=>typeof a=="number"&&Number.isFinite(a)))throw new Error("Use three finite numbers.");o[e.action].set(r[0],r[1],r[2]);break}case"color":{if(typeof e.value!="string"||!/^#[0-9a-f]{6}$/i.test(e.value))throw new Error("Use a six digit hex color.");let r=o.material,a=Array.isArray(r)?r:[r];if(!a.some(l=>l?.color?.isColor))throw new Error("This object has no color.");a.forEach(l=>l?.color?.set(e.value));break}default:throw new Error("Unknown scene action.")}return o.updateWorldMatrix(true,false),t.helper?.deref()?.update(),M(),{ok:true}}var Qt={version:1,getSnapshot:()=>({scenes:S(),stats:Y()}),subscribe:G,actions:{getScene:()=>(M(),S()),getStats:Y,action:e=>q(e)}},ye=globalThis;ye.__buoyThreeDispose?.();ye.__buoyThreeDispose=me;import{jsx as h,jsxs as D}from"react/jsx-runtime";var y={color:se.color.text,fontSize:13};function be({label:e,value:t,save:n}){let[o,r]=P(t),[a,l]=P(false);return ie(()=>{a||r(t)},[t,a]),D(L,{style:{flexDirection:"row",gap:8,padding:4},children:[h(m,{style:y,children:e}),h(ne,{testID:`three-edit-${e}`,accessibilityLabel:e,value:o,onChangeText:p=>{r(p),l(true)},style:[y,{borderWidth:1,borderColor:"#666",padding:4,flex:1}]}),h(C,{testID:`three-save-${e}`,onPress:()=>{n(o),l(false)},children:h(m,{style:y,children:"Save"})})]})}function ve({scenes:e,dispatch:t,refresh:n}){let[o,r]=P(S),[a,l]=P(),[p,c]=P("");ie(()=>e?void 0:G(()=>r(S())),[e]);let u=e??o,i=async d=>{try{await(t??q)(d),c(""),e||r(S())}catch(f){c(f instanceof Error?f.message:"The change failed.")}},s=u.find(d=>d.id===a?.rendererId)?.nodes.find(d=>d.id===a?.id);return D(oe,{keyboardShouldPersistTaps:"handled",testID:"three-panel",style:{flex:1,backgroundColor:se.color.bg},contentContainerStyle:{padding:12,gap:8},children:[h(m,{style:[y,{fontSize:18}],children:"Scene"}),!u.length&&h(m,{style:y,children:"No scene found. Call registerThree in your app."}),h(C,{testID:"three-refresh",onPress:async()=>{try{n?await n():r(S()),c("")}catch(d){c(d instanceof Error?d.message:"The refresh failed.")}},children:h(m,{style:y,children:"Refresh"})}),s&&a&&D(L,{testID:"three-details",children:[h(m,{style:y,children:s.name||s.type}),h(C,{testID:"three-visible",onPress:()=>void i({...a,action:"visible",value:!s.visible}),children:h(m,{style:y,children:s.visible?"Hide":"Show"})}),["position","rotation","scale"].map(d=>h(be,{label:d,value:s[d].join(", "),save:f=>void i({...a,action:d,value:f.split(",").map(v=>v.trim()?Number(v):NaN)})},d)),h(m,{style:y,children:"Turn values use radians."}),s.color&&h(be,{label:"color",value:s.color,save:d=>void i({...a,action:"color",value:d})}),h(C,{testID:"three-clear-selection",onPress:()=>{i({...a,action:"clearSelection"}),l(void 0)},children:h(m,{style:y,children:"Clear box"})})]},`${a.rendererId}:${a.id}`),u.map(d=>D(L,{children:[h(m,{style:y,children:d.id}),!d.nodes.length&&h(m,{style:y,children:"Pass a scene to registerThree to link this view."}),d.nodes.map(f=>h(C,{testID:`three-node-${f.name||f.type}`,onPress:()=>{l({rendererId:d.id,id:f.id}),i({rendererId:d.id,id:f.id,action:"select"})},children:D(m,{style:[y,{padding:5,paddingLeft:5+Math.min(20,(()=>{let v=0,x=f.parent,E=new Set;for(;x&&!E.has(x);)E.add(x),v++,x=d.nodes.find(B=>B.id===x)?.parent??null;return v})())*12}],children:[f.visible?"\u25CF":"\u25CB"," ",f.name||f.type]})},f.id)),d.truncated&&h(m,{style:y,children:"Tree limit reached. Some nodes are left out."})]},d.id)),!!p&&h(m,{accessibilityRole:"alert",style:y,children:p})]})}function ge({visible:e,onClose:t}){return h(jt,{visible:e,onClose:t,header:{title:"Scene"},initialMode:"bottomSheet",disableScrollWrapper:true,children:h(ve,{})})}import{jsx as Zt}from"react/jsx-runtime";var we=Rt({id:"three",name:"SCENE",description:"See and edit the 3D scene.",slot:"both",icon:({size:e,color:t})=>Zt(m,{style:{fontSize:e,color:t??"#F59E0B"},children:"\u25C7"}),component:ge}),er=Ot(we);export{Ht as MAX_SCENE_NODES,ge as ThreeModal,ve as ThreeToolView,er as createThreeTool,me as disposeThree,S as getThreeScene,Y as getThreeStats,Yt as onThreeLoad,Xt as registerThree,ue as snapshotScene,he as startThreeCapture,G as subscribeThree,q as threeAction,Qt as threeSyncAdapter,we as threeToolPreset};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/three",
3
- "version": "7.0.76",
3
+ "version": "7.0.78",
4
4
  "description": "See and edit a three.js scene.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -16,11 +16,11 @@
16
16
  "**/autoCapture.*"
17
17
  ],
18
18
  "dependencies": {
19
- "@buoy-gg/shared-ui": "^7.0.76",
20
- "@buoy-gg/perf-monitor": "^7.0.76",
21
- "@buoy-gg/core": "^7.0.76",
22
- "@buoy-gg/assets": "^7.0.76",
23
- "@buoy-gg/events": "^7.0.76"
19
+ "@buoy-gg/shared-ui": "^7.0.78",
20
+ "@buoy-gg/core": "^7.0.78",
21
+ "@buoy-gg/assets": "^7.0.78",
22
+ "@buoy-gg/perf-monitor": "^7.0.78",
23
+ "@buoy-gg/events": "^7.0.78"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "react": "*",