@skyvexsoftware/stratos-sdk 0.1.1
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 +21 -0
- package/README.md +201 -0
- package/dist/helpers/createPlugin.d.ts +22 -0
- package/dist/helpers/createPlugin.js +32 -0
- package/dist/helpers/index.d.ts +4 -0
- package/dist/helpers/index.js +3 -0
- package/dist/helpers/units.d.ts +36 -0
- package/dist/helpers/units.js +101 -0
- package/dist/hooks/context.d.ts +12 -0
- package/dist/hooks/context.js +18 -0
- package/dist/hooks/index.d.ts +16 -0
- package/dist/hooks/index.js +16 -0
- package/dist/hooks/useFlightEvents.d.ts +37 -0
- package/dist/hooks/useFlightEvents.js +152 -0
- package/dist/hooks/useFlightManager.d.ts +20 -0
- package/dist/hooks/useFlightManager.js +90 -0
- package/dist/hooks/useFlightPhase.d.ts +31 -0
- package/dist/hooks/useFlightPhase.js +67 -0
- package/dist/hooks/useLandingAnalysis.d.ts +37 -0
- package/dist/hooks/useLandingAnalysis.js +87 -0
- package/dist/hooks/usePluginLogger.d.ts +13 -0
- package/dist/hooks/usePluginLogger.js +16 -0
- package/dist/hooks/useShellAuth.d.ts +14 -0
- package/dist/hooks/useShellAuth.js +13 -0
- package/dist/hooks/useShellConfig.d.ts +14 -0
- package/dist/hooks/useShellConfig.js +14 -0
- package/dist/hooks/useShellNavigation.d.ts +12 -0
- package/dist/hooks/useShellNavigation.js +15 -0
- package/dist/hooks/useShellToast.d.ts +12 -0
- package/dist/hooks/useShellToast.js +15 -0
- package/dist/hooks/useSimData.d.ts +70 -0
- package/dist/hooks/useSimData.js +135 -0
- package/dist/hooks/useSimulatorData.d.ts +57 -0
- package/dist/hooks/useSimulatorData.js +258 -0
- package/dist/hooks/useTrackingSession.d.ts +40 -0
- package/dist/hooks/useTrackingSession.js +152 -0
- package/dist/icons.d.ts +13 -0
- package/dist/icons.js +13 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +28 -0
- package/dist/shared-types/flight-manager.d.ts +112 -0
- package/dist/shared-types/flight-manager.js +2 -0
- package/dist/shared-types/index.d.ts +7 -0
- package/dist/shared-types/index.js +4 -0
- package/dist/shared-types/simulator.d.ts +386 -0
- package/dist/shared-types/simulator.js +48 -0
- package/dist/shared-types/socket-events.d.ts +171 -0
- package/dist/shared-types/socket-events.js +79 -0
- package/dist/shared-types/theme.d.ts +3 -0
- package/dist/shared-types/theme.js +2 -0
- package/dist/types/context.d.ts +206 -0
- package/dist/types/context.js +8 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +2 -0
- package/dist/types/manifest.d.ts +42 -0
- package/dist/types/manifest.js +12 -0
- package/dist/types/module.d.ts +31 -0
- package/dist/types/module.js +7 -0
- package/dist/ui/alert-dialog.d.ts +21 -0
- package/dist/ui/alert-dialog.js +27 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/badge.js +21 -0
- package/dist/ui/button.d.ts +17 -0
- package/dist/ui/button.js +39 -0
- package/dist/ui/card.d.ts +10 -0
- package/dist/ui/card.js +25 -0
- package/dist/ui/dialog.d.ts +14 -0
- package/dist/ui/dialog.js +25 -0
- package/dist/ui/index.d.ts +18 -0
- package/dist/ui/index.js +16 -0
- package/dist/ui/input.d.ts +4 -0
- package/dist/ui/input.js +7 -0
- package/dist/ui/label.d.ts +5 -0
- package/dist/ui/label.js +8 -0
- package/dist/ui/radio-group.d.ts +6 -0
- package/dist/ui/radio-group.js +11 -0
- package/dist/ui/select.d.ts +14 -0
- package/dist/ui/select.js +27 -0
- package/dist/ui/separator.d.ts +5 -0
- package/dist/ui/separator.js +8 -0
- package/dist/ui/slider.d.ts +5 -0
- package/dist/ui/slider.js +8 -0
- package/dist/ui/switch.d.ts +13 -0
- package/dist/ui/switch.js +9 -0
- package/dist/ui/tabs.d.ts +8 -0
- package/dist/ui/tabs.js +13 -0
- package/dist/ui/textarea.d.ts +4 -0
- package/dist/ui/textarea.js +7 -0
- package/dist/ui/tooltip.d.ts +8 -0
- package/dist/ui/tooltip.js +11 -0
- package/dist/utils/cn.d.ts +3 -0
- package/dist/utils/cn.js +6 -0
- package/dist/vite/externals.d.ts +9 -0
- package/dist/vite/externals.js +19 -0
- package/dist/vite/plugin-config.d.ts +49 -0
- package/dist/vite/plugin-config.js +236 -0
- package/dist/vite/serve-externals.d.ts +9 -0
- package/dist/vite/serve-externals.js +78 -0
- package/dist/vite/stratos-dev-server.d.ts +21 -0
- package/dist/vite/stratos-dev-server.js +188 -0
- package/package.json +96 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as RadioGroupPrimitive from "@radix-ui/react-radio-group";
|
|
4
|
+
import { Circle } from "lucide-react";
|
|
5
|
+
import { cn } from "../utils/cn";
|
|
6
|
+
const RadioGroup = React.forwardRef(({ className, ...props }, ref) => (_jsx(RadioGroupPrimitive.Root, { className: cn("grid gap-2", className), ...props, ref: ref })));
|
|
7
|
+
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
|
|
8
|
+
const RadioGroupItem = React.forwardRef(({ className, ...props }, ref) => (_jsx(RadioGroupPrimitive.Item, { ref: ref, className: cn("border-primary text-primary focus-visible:ring-ring aspect-square h-4 w-4 rounded-full border shadow-sm focus:outline-hidden focus-visible:ring-1 disabled:cursor-not-allowed disabled:opacity-50", className), ...props, children: _jsx(RadioGroupPrimitive.Indicator, { className: "flex items-center justify-center", children: _jsx(Circle, { className: "fill-primary h-2.5 w-2.5" }) }) })));
|
|
9
|
+
RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName;
|
|
10
|
+
export { RadioGroup, RadioGroupItem };
|
|
11
|
+
//# sourceMappingURL=radio-group.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
3
|
+
declare const Select: React.FC<SelectPrimitive.SelectProps>;
|
|
4
|
+
declare const SelectGroup: React.ForwardRefExoticComponent<SelectPrimitive.SelectGroupProps & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
declare const SelectValue: React.ForwardRefExoticComponent<SelectPrimitive.SelectValueProps & React.RefAttributes<HTMLSpanElement>>;
|
|
6
|
+
declare const SelectTrigger: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
7
|
+
declare const SelectScrollUpButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollUpButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
8
|
+
declare const SelectScrollDownButton: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectScrollDownButtonProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
9
|
+
declare const SelectContent: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
10
|
+
declare const SelectLabel: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectLabelProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
11
|
+
declare const SelectItem: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectItemProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
12
|
+
declare const SelectSeparator: React.ForwardRefExoticComponent<Omit<SelectPrimitive.SelectSeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
13
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
|
|
14
|
+
//# sourceMappingURL=select.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as SelectPrimitive from "@radix-ui/react-select";
|
|
4
|
+
import { Check, ChevronDown, ChevronUp } from "lucide-react";
|
|
5
|
+
import { cn } from "../utils/cn";
|
|
6
|
+
const Select = SelectPrimitive.Root;
|
|
7
|
+
const SelectGroup = SelectPrimitive.Group;
|
|
8
|
+
const SelectValue = SelectPrimitive.Value;
|
|
9
|
+
const SelectTrigger = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Trigger, { ref: ref, className: cn("border-input bg-background ring-offset-background placeholder:text-muted-foreground focus:ring-ring flex h-10 w-full items-center justify-between rounded-md border px-3 py-2 text-sm focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1", className), ...props, children: [children, _jsx(SelectPrimitive.Icon, { asChild: true, children: _jsx(ChevronDown, { className: "h-4 w-4 opacity-50" }) })] })));
|
|
10
|
+
SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
|
|
11
|
+
const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronUp, { className: "h-4 w-4" }) })));
|
|
12
|
+
SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;
|
|
13
|
+
const SelectScrollDownButton = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.ScrollDownButton, { ref: ref, className: cn("flex cursor-default items-center justify-center py-1", className), ...props, children: _jsx(ChevronDown, { className: "h-4 w-4" }) })));
|
|
14
|
+
SelectScrollDownButton.displayName =
|
|
15
|
+
SelectPrimitive.ScrollDownButton.displayName;
|
|
16
|
+
const SelectContent = React.forwardRef(({ className, children, position = "popper", ...props }, ref) => (_jsx(SelectPrimitive.Portal, { children: _jsxs(SelectPrimitive.Content, { ref: ref, className: cn("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md", position === "popper" &&
|
|
17
|
+
"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1", className), position: position, ...props, children: [_jsx(SelectScrollUpButton, {}), _jsx(SelectPrimitive.Viewport, { className: cn("p-1", position === "popper" &&
|
|
18
|
+
"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"), children: children }), _jsx(SelectScrollDownButton, {})] }) })));
|
|
19
|
+
SelectContent.displayName = SelectPrimitive.Content.displayName;
|
|
20
|
+
const SelectLabel = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Label, { ref: ref, className: cn("py-1.5 pr-2 pl-8 text-sm font-semibold", className), ...props })));
|
|
21
|
+
SelectLabel.displayName = SelectPrimitive.Label.displayName;
|
|
22
|
+
const SelectItem = React.forwardRef(({ className, children, ...props }, ref) => (_jsxs(SelectPrimitive.Item, { ref: ref, className: cn("focus:bg-accent focus:text-accent-foreground relative flex w-full cursor-default items-center rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className), ...props, children: [_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(SelectPrimitive.ItemIndicator, { children: _jsx(Check, { className: "h-4 w-4" }) }) }), _jsx(SelectPrimitive.ItemText, { children: children })] })));
|
|
23
|
+
SelectItem.displayName = SelectPrimitive.Item.displayName;
|
|
24
|
+
const SelectSeparator = React.forwardRef(({ className, ...props }, ref) => (_jsx(SelectPrimitive.Separator, { ref: ref, className: cn("bg-muted -mx-1 my-1 h-px", className), ...props })));
|
|
25
|
+
SelectSeparator.displayName = SelectPrimitive.Separator.displayName;
|
|
26
|
+
export { Select, SelectGroup, SelectValue, SelectTrigger, SelectContent, SelectLabel, SelectItem, SelectSeparator, SelectScrollUpButton, SelectScrollDownButton, };
|
|
27
|
+
//# sourceMappingURL=select.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
3
|
+
declare const Separator: React.ForwardRefExoticComponent<Omit<SeparatorPrimitive.SeparatorProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
export { Separator };
|
|
5
|
+
//# sourceMappingURL=separator.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
|
|
4
|
+
import { cn } from "../utils/cn";
|
|
5
|
+
const Separator = React.forwardRef(({ className, orientation = "horizontal", decorative = true, ...props }, ref) => (_jsx(SeparatorPrimitive.Root, { ref: ref, decorative: decorative, orientation: orientation, className: cn("bg-border shrink-0", orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]", className), ...props })));
|
|
6
|
+
Separator.displayName = SeparatorPrimitive.Root.displayName;
|
|
7
|
+
export { Separator };
|
|
8
|
+
//# sourceMappingURL=separator.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
3
|
+
declare const Slider: React.ForwardRefExoticComponent<Omit<SliderPrimitive.SliderProps & React.RefAttributes<HTMLSpanElement>, "ref"> & React.RefAttributes<HTMLSpanElement>>;
|
|
4
|
+
export { Slider };
|
|
5
|
+
//# sourceMappingURL=slider.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as SliderPrimitive from "@radix-ui/react-slider";
|
|
4
|
+
import { cn } from "../utils/cn";
|
|
5
|
+
const Slider = React.forwardRef(({ className, ...props }, ref) => (_jsxs(SliderPrimitive.Root, { ref: ref, className: cn("relative flex w-full touch-none items-center select-none", className), ...props, children: [_jsx(SliderPrimitive.Track, { className: "bg-primary/20 relative h-1.5 w-full grow overflow-hidden rounded-full", children: _jsx(SliderPrimitive.Range, { className: "bg-primary absolute h-full" }) }), _jsx(SliderPrimitive.Thumb, { className: "border-primary/50 bg-background focus-visible:ring-ring block h-4 w-4 rounded-full border shadow-sm transition-colors focus-visible:ring-1 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50" })] })));
|
|
6
|
+
Slider.displayName = SliderPrimitive.Root.displayName;
|
|
7
|
+
export { Slider };
|
|
8
|
+
//# sourceMappingURL=slider.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
type SwitchProps = {
|
|
3
|
+
checked?: boolean;
|
|
4
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
className?: string;
|
|
7
|
+
id?: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
};
|
|
10
|
+
declare const Switch: React.ForwardRefExoticComponent<SwitchProps & React.RefAttributes<HTMLButtonElement>>;
|
|
11
|
+
export { Switch };
|
|
12
|
+
export type { SwitchProps };
|
|
13
|
+
//# sourceMappingURL=switch.d.ts.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { cn } from "../utils/cn";
|
|
4
|
+
const Switch = React.forwardRef(({ checked = false, onCheckedChange, disabled, className, ...props }, ref) => (_jsx("button", { type: "button", role: "switch", "aria-checked": checked, ref: ref, disabled: disabled, onClick: () => onCheckedChange?.(!checked), className: cn("relative inline-flex shrink-0 cursor-pointer rounded-md transition-all duration-150", "h-[18px] w-[32px]", checked
|
|
5
|
+
? "border-primary bg-primary border"
|
|
6
|
+
: "border-border-interactive bg-muted border", disabled && "cursor-not-allowed opacity-50", className), ...props, children: _jsx("span", { className: cn("pointer-events-none absolute top-[2px] h-[12px] w-[12px] rounded-sm bg-white transition-[left] duration-150", checked ? "left-[16px]" : "left-[2px]") }) })));
|
|
7
|
+
Switch.displayName = "Switch";
|
|
8
|
+
export { Switch };
|
|
9
|
+
//# sourceMappingURL=switch.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
3
|
+
declare const Tabs: React.ForwardRefExoticComponent<TabsPrimitive.TabsProps & React.RefAttributes<HTMLDivElement>>;
|
|
4
|
+
declare const TabsList: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsListProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
5
|
+
declare const TabsTrigger: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsTriggerProps & React.RefAttributes<HTMLButtonElement>, "ref"> & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
declare const TabsContent: React.ForwardRefExoticComponent<Omit<TabsPrimitive.TabsContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
8
|
+
//# sourceMappingURL=tabs.d.ts.map
|
package/dist/ui/tabs.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as TabsPrimitive from "@radix-ui/react-tabs";
|
|
4
|
+
import { cn } from "../utils/cn";
|
|
5
|
+
const Tabs = TabsPrimitive.Root;
|
|
6
|
+
const TabsList = React.forwardRef(({ className, ...props }, ref) => (_jsx(TabsPrimitive.List, { ref: ref, className: cn("bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1", className), ...props })));
|
|
7
|
+
TabsList.displayName = TabsPrimitive.List.displayName;
|
|
8
|
+
const TabsTrigger = React.forwardRef(({ className, ...props }, ref) => (_jsx(TabsPrimitive.Trigger, { ref: ref, className: cn("ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm", className), ...props })));
|
|
9
|
+
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
|
|
10
|
+
const TabsContent = React.forwardRef(({ className, ...props }, ref) => (_jsx(TabsPrimitive.Content, { ref: ref, className: cn("ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-hidden", className), ...props })));
|
|
11
|
+
TabsContent.displayName = TabsPrimitive.Content.displayName;
|
|
12
|
+
export { Tabs, TabsList, TabsTrigger, TabsContent };
|
|
13
|
+
//# sourceMappingURL=tabs.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../utils/cn";
|
|
3
|
+
function Textarea({ className, ...props }) {
|
|
4
|
+
return (_jsx("textarea", { "data-slot": "textarea", className: cn("border-input bg-background placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 flex min-h-[60px] w-full rounded-md border px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm", "aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", className), ...props }));
|
|
5
|
+
}
|
|
6
|
+
export { Textarea };
|
|
7
|
+
//# sourceMappingURL=textarea.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
3
|
+
declare const TooltipProvider: React.FC<TooltipPrimitive.TooltipProviderProps>;
|
|
4
|
+
declare const Tooltip: React.FC<TooltipPrimitive.TooltipProps>;
|
|
5
|
+
declare const TooltipTrigger: React.ForwardRefExoticComponent<TooltipPrimitive.TooltipTriggerProps & React.RefAttributes<HTMLButtonElement>>;
|
|
6
|
+
declare const TooltipContent: React.ForwardRefExoticComponent<Omit<TooltipPrimitive.TooltipContentProps & React.RefAttributes<HTMLDivElement>, "ref"> & React.RefAttributes<HTMLDivElement>>;
|
|
7
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
8
|
+
//# sourceMappingURL=tooltip.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import * as TooltipPrimitive from "@radix-ui/react-tooltip";
|
|
4
|
+
import { cn } from "../utils/cn";
|
|
5
|
+
const TooltipProvider = TooltipPrimitive.Provider;
|
|
6
|
+
const Tooltip = TooltipPrimitive.Root;
|
|
7
|
+
const TooltipTrigger = TooltipPrimitive.Trigger;
|
|
8
|
+
const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(TooltipPrimitive.Content, { ref: ref, sideOffset: sideOffset, className: cn("bg-popover text-popover-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 overflow-hidden rounded-md border px-3 py-1.5 text-sm shadow-md", className), ...props })));
|
|
9
|
+
TooltipContent.displayName = TooltipPrimitive.Content.displayName;
|
|
10
|
+
export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
|
|
11
|
+
//# sourceMappingURL=tooltip.js.map
|
package/dist/utils/cn.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical list of modules provided by the Stratos shell at runtime via
|
|
3
|
+
* `window.__stratos_modules__`. This is the single source of truth — both
|
|
4
|
+
* `vite-plugin.config.ts` (build-time) and `serve-externals.ts` (dev-time)
|
|
5
|
+
* import from here.
|
|
6
|
+
*/
|
|
7
|
+
export declare const UI_EXTERNALS: readonly ["react", "react-dom", "react/jsx-runtime", "@tanstack/react-router", "@tanstack/react-query", "@skyvexsoftware/stratos-sdk", "sonner", "socket.io-client", "maplibre-gl", "react-map-gl/maplibre"];
|
|
8
|
+
export type UIExternal = (typeof UI_EXTERNALS)[number];
|
|
9
|
+
//# sourceMappingURL=externals.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical list of modules provided by the Stratos shell at runtime via
|
|
3
|
+
* `window.__stratos_modules__`. This is the single source of truth — both
|
|
4
|
+
* `vite-plugin.config.ts` (build-time) and `serve-externals.ts` (dev-time)
|
|
5
|
+
* import from here.
|
|
6
|
+
*/
|
|
7
|
+
export const UI_EXTERNALS = [
|
|
8
|
+
"react",
|
|
9
|
+
"react-dom",
|
|
10
|
+
"react/jsx-runtime",
|
|
11
|
+
"@tanstack/react-router",
|
|
12
|
+
"@tanstack/react-query",
|
|
13
|
+
"@skyvexsoftware/stratos-sdk",
|
|
14
|
+
"sonner",
|
|
15
|
+
"socket.io-client",
|
|
16
|
+
"maplibre-gl",
|
|
17
|
+
"react-map-gl/maplibre",
|
|
18
|
+
];
|
|
19
|
+
//# sourceMappingURL=externals.js.map
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Vite configuration for Stratos plugin builds.
|
|
3
|
+
*
|
|
4
|
+
* Plugins import `createPluginConfig` to get a Vite config that handles:
|
|
5
|
+
* - UI bundle (ESM, shared deps externalized to window.__stratos_modules__)
|
|
6
|
+
* - Background bundle (ESM for Node.js, Electron + SDK externalized)
|
|
7
|
+
* - Manifest and asset copying to dist/
|
|
8
|
+
*
|
|
9
|
+
* Usage in a plugin's vite.config.ts:
|
|
10
|
+
*
|
|
11
|
+
* import { createPluginConfig } from '../../sdk/src/vite/plugin-config';
|
|
12
|
+
* export default createPluginConfig({
|
|
13
|
+
* pluginDir: import.meta.dirname,
|
|
14
|
+
* ui: { entry: 'src/ui/index.ts' },
|
|
15
|
+
* background: { entry: 'src/background/index.ts' },
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
import type { Plugin, UserConfig } from "vite";
|
|
19
|
+
import { UI_EXTERNALS } from "./externals";
|
|
20
|
+
/** Modules external in background builds (available in Electron main process) */
|
|
21
|
+
declare const BG_EXTERNALS: string[];
|
|
22
|
+
/**
|
|
23
|
+
* Rollup plugin that transforms ESM import statements for externalized modules
|
|
24
|
+
* into runtime lookups from window.__stratos_modules__.
|
|
25
|
+
*
|
|
26
|
+
* This allows plugin UI bundles to remain valid ES modules that can be loaded
|
|
27
|
+
* via dynamic import() while resolving shared dependencies from the shell's
|
|
28
|
+
* global registry.
|
|
29
|
+
*/
|
|
30
|
+
declare function stratosExternals(): Plugin;
|
|
31
|
+
export type PluginBuildOptions = {
|
|
32
|
+
pluginDir: string;
|
|
33
|
+
ui?: {
|
|
34
|
+
entry: string;
|
|
35
|
+
};
|
|
36
|
+
background?: {
|
|
37
|
+
entry: string;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Create a Vite config for building a Stratos plugin.
|
|
42
|
+
*
|
|
43
|
+
* The build target is determined by the BUILD_TARGET environment variable:
|
|
44
|
+
* - undefined / "ui" → builds the UI module (renderer, ESM with externals)
|
|
45
|
+
* - "background" → builds the background module (Node.js, ESM)
|
|
46
|
+
*/
|
|
47
|
+
export declare function createPluginConfig(options: PluginBuildOptions): UserConfig;
|
|
48
|
+
export { UI_EXTERNALS, BG_EXTERNALS, stratosExternals };
|
|
49
|
+
//# sourceMappingURL=plugin-config.d.ts.map
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared Vite configuration for Stratos plugin builds.
|
|
3
|
+
*
|
|
4
|
+
* Plugins import `createPluginConfig` to get a Vite config that handles:
|
|
5
|
+
* - UI bundle (ESM, shared deps externalized to window.__stratos_modules__)
|
|
6
|
+
* - Background bundle (ESM for Node.js, Electron + SDK externalized)
|
|
7
|
+
* - Manifest and asset copying to dist/
|
|
8
|
+
*
|
|
9
|
+
* Usage in a plugin's vite.config.ts:
|
|
10
|
+
*
|
|
11
|
+
* import { createPluginConfig } from '../../sdk/src/vite/plugin-config';
|
|
12
|
+
* export default createPluginConfig({
|
|
13
|
+
* pluginDir: import.meta.dirname,
|
|
14
|
+
* ui: { entry: 'src/ui/index.ts' },
|
|
15
|
+
* background: { entry: 'src/background/index.ts' },
|
|
16
|
+
* });
|
|
17
|
+
*/
|
|
18
|
+
import * as fs from "fs";
|
|
19
|
+
import * as path from "path";
|
|
20
|
+
import react from "@vitejs/plugin-react";
|
|
21
|
+
import { UI_EXTERNALS } from "./externals";
|
|
22
|
+
import { serveExternals } from "./serve-externals";
|
|
23
|
+
import { stratosDevServer } from "./stratos-dev-server";
|
|
24
|
+
/** Modules external in background builds (available in Electron main process) */
|
|
25
|
+
const BG_EXTERNALS = [
|
|
26
|
+
"electron",
|
|
27
|
+
"@skyvexsoftware/stratos-sdk",
|
|
28
|
+
"socket.io-client",
|
|
29
|
+
];
|
|
30
|
+
/** Node.js built-in modules to externalize in background builds */
|
|
31
|
+
const NODE_BUILTINS = [
|
|
32
|
+
"assert",
|
|
33
|
+
"buffer",
|
|
34
|
+
"child_process",
|
|
35
|
+
"cluster",
|
|
36
|
+
"crypto",
|
|
37
|
+
"dgram",
|
|
38
|
+
"dns",
|
|
39
|
+
"events",
|
|
40
|
+
"fs",
|
|
41
|
+
"http",
|
|
42
|
+
"https",
|
|
43
|
+
"module",
|
|
44
|
+
"net",
|
|
45
|
+
"os",
|
|
46
|
+
"path",
|
|
47
|
+
"perf_hooks",
|
|
48
|
+
"querystring",
|
|
49
|
+
"readline",
|
|
50
|
+
"stream",
|
|
51
|
+
"tls",
|
|
52
|
+
"url",
|
|
53
|
+
"util",
|
|
54
|
+
"v8",
|
|
55
|
+
"vm",
|
|
56
|
+
"worker_threads",
|
|
57
|
+
"zlib",
|
|
58
|
+
];
|
|
59
|
+
/**
|
|
60
|
+
* Rollup plugin that transforms ESM import statements for externalized modules
|
|
61
|
+
* into runtime lookups from window.__stratos_modules__.
|
|
62
|
+
*
|
|
63
|
+
* This allows plugin UI bundles to remain valid ES modules that can be loaded
|
|
64
|
+
* via dynamic import() while resolving shared dependencies from the shell's
|
|
65
|
+
* global registry.
|
|
66
|
+
*/
|
|
67
|
+
function stratosExternals() {
|
|
68
|
+
return {
|
|
69
|
+
name: "stratos-externals",
|
|
70
|
+
renderChunk(code) {
|
|
71
|
+
let result = code;
|
|
72
|
+
for (const modId of UI_EXTERNALS) {
|
|
73
|
+
const escaped = modId.replace(/[-/\\^$*+?.()|[\]{}@]/g, "\\$&");
|
|
74
|
+
const global = `window.__stratos_modules__[${JSON.stringify(modId)}]`;
|
|
75
|
+
// 1. import Default, { named as alias } from 'mod';
|
|
76
|
+
// Note: [\w$]+ handles Rollup's conflict-resolution names like Map$1
|
|
77
|
+
result = result.replace(new RegExp(`import\\s+([\\w$]+)\\s*,\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, def, names) => {
|
|
78
|
+
const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
|
|
79
|
+
return `const ${def} = ${global}.default || ${global};\nconst {${destructured}} = ${global};`;
|
|
80
|
+
});
|
|
81
|
+
// 2. import { named as alias } from 'mod';
|
|
82
|
+
result = result.replace(new RegExp(`import\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, names) => {
|
|
83
|
+
const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
|
|
84
|
+
return `const {${destructured}} = ${global};`;
|
|
85
|
+
});
|
|
86
|
+
// 3. import * as ns from 'mod';
|
|
87
|
+
result = result.replace(new RegExp(`import\\s+\\*\\s+as\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, name) => `const ${name} = ${global};`);
|
|
88
|
+
// 4. import Default from 'mod';
|
|
89
|
+
result = result.replace(new RegExp(`import\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, def) => `const ${def} = ${global}.default || ${global};`);
|
|
90
|
+
// 5. import 'mod'; (side effect only)
|
|
91
|
+
result = result.replace(new RegExp(`import\\s+['"]${escaped}['"]\\s*;?`, "g"), "");
|
|
92
|
+
// 6. export { name } from 'mod'; (re-export)
|
|
93
|
+
result = result.replace(new RegExp(`export\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, names) => {
|
|
94
|
+
const parts = names.split(",").map((n) => n.trim());
|
|
95
|
+
const decls = [];
|
|
96
|
+
const exportNames = [];
|
|
97
|
+
for (const part of parts) {
|
|
98
|
+
const asMatch = part.match(/^([\w$]+)\s+as\s+([\w$]+)$/);
|
|
99
|
+
if (asMatch) {
|
|
100
|
+
decls.push(`const ${asMatch[2]} = ${global}[${JSON.stringify(asMatch[1])}];`);
|
|
101
|
+
exportNames.push(asMatch[2]);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
exportNames.push(part);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (decls.length > 0) {
|
|
108
|
+
return `${decls.join("\n")}\nconst {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
|
|
109
|
+
}
|
|
110
|
+
return `const {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return result;
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Rollup plugin that copies plugin.json and assets/ to dist/ after the build.
|
|
119
|
+
* Only runs during the UI build (not background) to avoid duplicate copies.
|
|
120
|
+
*/
|
|
121
|
+
function copyPluginAssets(pluginDir) {
|
|
122
|
+
return {
|
|
123
|
+
name: "copy-plugin-assets",
|
|
124
|
+
closeBundle() {
|
|
125
|
+
const distDir = path.resolve(pluginDir, "dist");
|
|
126
|
+
fs.mkdirSync(distDir, { recursive: true });
|
|
127
|
+
// Copy plugin.json
|
|
128
|
+
const manifestSrc = path.resolve(pluginDir, "plugin.json");
|
|
129
|
+
if (fs.existsSync(manifestSrc)) {
|
|
130
|
+
fs.copyFileSync(manifestSrc, path.resolve(distDir, "plugin.json"));
|
|
131
|
+
}
|
|
132
|
+
// Copy assets/ directory
|
|
133
|
+
const assetsSrc = path.resolve(pluginDir, "assets");
|
|
134
|
+
if (fs.existsSync(assetsSrc)) {
|
|
135
|
+
copyDirSync(assetsSrc, path.resolve(distDir, "assets"));
|
|
136
|
+
}
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
function copyDirSync(src, dest) {
|
|
141
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
142
|
+
for (const entry of fs.readdirSync(src, { withFileTypes: true })) {
|
|
143
|
+
const srcPath = path.join(src, entry.name);
|
|
144
|
+
const destPath = path.join(dest, entry.name);
|
|
145
|
+
if (entry.isDirectory()) {
|
|
146
|
+
copyDirSync(srcPath, destPath);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
fs.copyFileSync(srcPath, destPath);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Create a Vite config for building a Stratos plugin.
|
|
155
|
+
*
|
|
156
|
+
* The build target is determined by the BUILD_TARGET environment variable:
|
|
157
|
+
* - undefined / "ui" → builds the UI module (renderer, ESM with externals)
|
|
158
|
+
* - "background" → builds the background module (Node.js, ESM)
|
|
159
|
+
*/
|
|
160
|
+
export function createPluginConfig(options) {
|
|
161
|
+
const { pluginDir, ui, background } = options;
|
|
162
|
+
const target = process.env.BUILD_TARGET;
|
|
163
|
+
if (target === "background" && background) {
|
|
164
|
+
return createBackgroundConfig(pluginDir, background.entry);
|
|
165
|
+
}
|
|
166
|
+
if (ui) {
|
|
167
|
+
return createUIConfig(pluginDir, ui.entry);
|
|
168
|
+
}
|
|
169
|
+
throw new Error("No build target. Provide a ui entry or set BUILD_TARGET=background.");
|
|
170
|
+
}
|
|
171
|
+
function createUIConfig(pluginDir, entry) {
|
|
172
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
173
|
+
return {
|
|
174
|
+
root: pluginDir,
|
|
175
|
+
plugins: [
|
|
176
|
+
{ ...react(), apply: "serve" },
|
|
177
|
+
serveExternals(),
|
|
178
|
+
stratosDevServer({ pluginDir }),
|
|
179
|
+
stratosExternals(),
|
|
180
|
+
copyPluginAssets(pluginDir),
|
|
181
|
+
],
|
|
182
|
+
server: {
|
|
183
|
+
cors: {
|
|
184
|
+
origin: [
|
|
185
|
+
"http://localhost:2066",
|
|
186
|
+
"http://127.0.0.1:2066",
|
|
187
|
+
/^http:\/\/localhost:\d+$/,
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
build: {
|
|
192
|
+
outDir: path.resolve(pluginDir, "dist/ui"),
|
|
193
|
+
emptyOutDir: true,
|
|
194
|
+
lib: {
|
|
195
|
+
entry: path.resolve(pluginDir, entry),
|
|
196
|
+
formats: ["es"],
|
|
197
|
+
fileName: () => "index.js",
|
|
198
|
+
},
|
|
199
|
+
rollupOptions: {
|
|
200
|
+
external: [...UI_EXTERNALS],
|
|
201
|
+
},
|
|
202
|
+
sourcemap: !isProduction,
|
|
203
|
+
minify: isProduction ? "esbuild" : false,
|
|
204
|
+
},
|
|
205
|
+
esbuild: {
|
|
206
|
+
jsx: "automatic",
|
|
207
|
+
jsxImportSource: "react",
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
function createBackgroundConfig(pluginDir, entry) {
|
|
212
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
213
|
+
return {
|
|
214
|
+
root: pluginDir,
|
|
215
|
+
build: {
|
|
216
|
+
outDir: path.resolve(pluginDir, "dist/background"),
|
|
217
|
+
emptyOutDir: true,
|
|
218
|
+
lib: {
|
|
219
|
+
entry: path.resolve(pluginDir, entry),
|
|
220
|
+
formats: ["es"],
|
|
221
|
+
fileName: () => "index.js",
|
|
222
|
+
},
|
|
223
|
+
rollupOptions: {
|
|
224
|
+
external: [
|
|
225
|
+
...BG_EXTERNALS,
|
|
226
|
+
...NODE_BUILTINS,
|
|
227
|
+
...NODE_BUILTINS.map((b) => `node:${b}`),
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
sourcemap: !isProduction,
|
|
231
|
+
minify: false,
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export { UI_EXTERNALS, BG_EXTERNALS, stratosExternals };
|
|
236
|
+
//# sourceMappingURL=plugin-config.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
/**
|
|
3
|
+
* Vite plugin that rewrites external imports to `window.__stratos_modules__`
|
|
4
|
+
* lookups in serve (dev) mode. This mirrors what `stratosExternals()` does at
|
|
5
|
+
* build time via `renderChunk`, but operates on source-level files so that
|
|
6
|
+
* the Vite dev server can resolve shared shell dependencies correctly.
|
|
7
|
+
*/
|
|
8
|
+
export declare function serveExternals(): Plugin;
|
|
9
|
+
//# sourceMappingURL=serve-externals.d.ts.map
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { UI_EXTERNALS } from "./externals";
|
|
2
|
+
const EXTERNAL_PACKAGES = [
|
|
3
|
+
...UI_EXTERNALS,
|
|
4
|
+
"react/jsx-runtime",
|
|
5
|
+
"react/jsx-dev-runtime",
|
|
6
|
+
"react-dom/client",
|
|
7
|
+
];
|
|
8
|
+
const JS_EXTENSIONS = new Set([".ts", ".tsx", ".js", ".jsx"]);
|
|
9
|
+
function escapeRegExp(str) {
|
|
10
|
+
return str.replace(/[-/\\^$*+?.()|[\]{}@]/g, "\\$&");
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Vite plugin that rewrites external imports to `window.__stratos_modules__`
|
|
14
|
+
* lookups in serve (dev) mode. This mirrors what `stratosExternals()` does at
|
|
15
|
+
* build time via `renderChunk`, but operates on source-level files so that
|
|
16
|
+
* the Vite dev server can resolve shared shell dependencies correctly.
|
|
17
|
+
*/
|
|
18
|
+
export function serveExternals() {
|
|
19
|
+
return {
|
|
20
|
+
name: "stratos-serve-externals",
|
|
21
|
+
apply: "serve",
|
|
22
|
+
enforce: "pre",
|
|
23
|
+
transform(code, id) {
|
|
24
|
+
// Only process JS/TS source files
|
|
25
|
+
const ext = id.slice(id.lastIndexOf("."));
|
|
26
|
+
if (!JS_EXTENSIONS.has(ext))
|
|
27
|
+
return null;
|
|
28
|
+
// Skip node_modules
|
|
29
|
+
if (id.includes("/node_modules/"))
|
|
30
|
+
return null;
|
|
31
|
+
let result = code;
|
|
32
|
+
for (const modId of EXTERNAL_PACKAGES) {
|
|
33
|
+
const escaped = escapeRegExp(modId);
|
|
34
|
+
const global = `window.__stratos_modules__[${JSON.stringify(modId)}]`;
|
|
35
|
+
// 1. Combined default + named: import Default, { Named } from "pkg"
|
|
36
|
+
result = result.replace(new RegExp(`import\\s+([\\w$]+)\\s*,\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, def, names) => {
|
|
37
|
+
const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
|
|
38
|
+
return `const ${def} = ${global}.default || ${global};\nconst {${destructured}} = ${global};`;
|
|
39
|
+
});
|
|
40
|
+
// 2. Named imports: import { Foo, Bar } from "pkg"
|
|
41
|
+
result = result.replace(new RegExp(`import\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, names) => {
|
|
42
|
+
const destructured = names.replace(/([\w$]+)\s+as\s+([\w$]+)/g, "$1: $2");
|
|
43
|
+
return `const {${destructured}} = ${global};`;
|
|
44
|
+
});
|
|
45
|
+
// 3. Namespace imports: import * as Foo from "pkg"
|
|
46
|
+
result = result.replace(new RegExp(`import\\s+\\*\\s+as\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, name) => `const ${name} = ${global};`);
|
|
47
|
+
// 4. Default imports: import Foo from "pkg"
|
|
48
|
+
result = result.replace(new RegExp(`import\\s+([\\w$]+)\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, def) => `const ${def} = ${global}.default || ${global};`);
|
|
49
|
+
// 5. Re-exports: export { name } from "pkg"
|
|
50
|
+
result = result.replace(new RegExp(`export\\s*\\{([^}]+)\\}\\s+from\\s+['"]${escaped}['"]\\s*;?`, "g"), (_, names) => {
|
|
51
|
+
const parts = names.split(",").map((n) => n.trim());
|
|
52
|
+
const decls = [];
|
|
53
|
+
const exportNames = [];
|
|
54
|
+
for (const part of parts) {
|
|
55
|
+
const asMatch = part.match(/^([\w$]+)\s+as\s+([\w$]+)$/);
|
|
56
|
+
if (asMatch) {
|
|
57
|
+
decls.push(`const ${asMatch[2]} = ${global}[${JSON.stringify(asMatch[1])}];`);
|
|
58
|
+
exportNames.push(asMatch[2]);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
exportNames.push(part);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
if (decls.length > 0) {
|
|
65
|
+
return `${decls.join("\n")}\nconst {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
|
|
66
|
+
}
|
|
67
|
+
return `const {${exportNames.join(", ")}} = ${global};\nexport {${exportNames.join(", ")}};`;
|
|
68
|
+
});
|
|
69
|
+
// 6. Side-effect imports: import "pkg"
|
|
70
|
+
result = result.replace(new RegExp(`import\\s+['"]${escaped}['"]\\s*;?`, "g"), `// (stratos-serve-externals: side-effect import of "${modId}" removed)`);
|
|
71
|
+
}
|
|
72
|
+
if (result === code)
|
|
73
|
+
return null;
|
|
74
|
+
return { code: result, map: null };
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=serve-externals.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Plugin } from "vite";
|
|
2
|
+
type StratosDevServerOptions = {
|
|
3
|
+
pluginDir: string;
|
|
4
|
+
stratosPort?: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Vite plugin that auto-connects a plugin's dev server to a running Stratos
|
|
8
|
+
* app. Only active in serve (dev) mode.
|
|
9
|
+
*
|
|
10
|
+
* On startup it:
|
|
11
|
+
* - Reads plugin.json from the plugin directory
|
|
12
|
+
* - Derives the dev URL from the Vite HTTP server address
|
|
13
|
+
* - Connects to Stratos's Socket.io server and emits dev:plugin-connect
|
|
14
|
+
* - Retries with exponential backoff if Stratos isn't running
|
|
15
|
+
*
|
|
16
|
+
* If src/background/ exists, it watches for changes and rebuilds the
|
|
17
|
+
* background bundle, then notifies Stratos via dev:plugin-bg-updated.
|
|
18
|
+
*/
|
|
19
|
+
export declare function stratosDevServer(options: StratosDevServerOptions): Plugin;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=stratos-dev-server.d.ts.map
|