An open-source, self-hosted system for apps built with web technologies.
Remove unused internal modules
zohayrslileheca3d2ca4591
diff --git a/.gitignore b/.gitignoreindex 30e4ccb..7132a8c 100644--- a/.gitignore+++ b/.gitignore@@ -14,7 +14,7 @@ coverage# logslogs-_.log+*.logreport.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json# dotenv environment variable filesdiff --git a/source/libs/react-screen.tsx b/source/libs/react-screen.tsxdeleted file mode 100644index 1c60780..0000000--- a/source/libs/react-screen.tsx+++ /dev/null@@ -1,219 +0,0 @@-import React, { useState, useEffect } from "react"--/**- * The useScreen hook provides responsive design capabilities by tracking- * if the current window width falls within specified minimum and maximum bounds.- *- * This hook enables components to adapt their behavior based on screen size,- * making it easier to implement responsive designs without relying on CSS media queries.- *- * @param min Optional minimum width in pixels for the range to be active- * @param max Optional maximum width in pixels for the range to be active- * @returns A boolean indicating whether the current screen width is within the specified range- *- * @example- *- * const isTablet = useScreen(768, 1024)- *- * if (isTablet) {- * // Render tablet-specific content- * }- */-export const useScreen = function (min?: number, max?: number): boolean {-- /**- * State tracking whether the current screen width is within the specified range.- * Initial value is determined by comparing the window width against min/max values.- */- const [inRange, setInRange] = useState((!min && !max) ? false : (min ? window.innerWidth >= min : true) && (max ? window.innerWidth <= max : true))-- /**- * Sets up an event listener to track window resize events and update- * the inRange state when the screen dimensions change.- *- * The effect cleans up by removing the event listener when the component unmounts- * or when min/max dependencies change.- */- useEffect(() => {-- /**- * Handler function that recalculates whether the screen width- * is within the specified range and updates the state accordingly.- */- const resize = () => setInRange((!min && !max) ? false : (min ? window.innerWidth >= min : true) && (max ? window.innerWidth <= max : true))-- // Add resize listener- window.addEventListener("resize", resize)-- /**- * On end remove resize listener- */- return () => window.removeEventListener("resize", resize)-- }, [min, max])-- return inRange-}--/**- * Screen is a responsive component that conditionally renders content- * based on whether the current screen width falls within specified bounds.- *- * It leverages the useScreen hook internally to determine which content to display,- * providing a declarative way to implement responsive UIs.- *- * @param min Optional minimum width in pixels for the content to be shown- * @param max Optional maximum width in pixels for the content to be shown- * @param available Content to display when the screen width is within range- * @param unavailable Content to display when the screen width is out of range- * @returns Either the 'available' or 'unavailable' content based on current screen size- *- * @example- *- * <Screen- * min={768}- * available={<DesktopNavigation />}- * unavailable={<MobileNavigation />}- * />- */-const Screen = ({ min, max, available, unavailable }: ScreenProps) => {-- /**- * Determines if the current screen width is within the specified range.- * The result controls which content variant is rendered.- */- const screen = useScreen(min, max)-- return <React.Fragment>{screen ? available : unavailable}</React.Fragment>-}--/**- * The useOrientation hook tracks the current device orientation.- *- * It detects whether the device is in landscape, portrait, or square orientation- * based on comparing window width and height dimensions.- *- * @returns The current orientation as "landscape", "portrait", or "square"- *- * @example- *- * const orientation = useOrientation()- *- * if (orientation === "landscape") {- * // Apply landscape-specific logic- * }- */-export const useOrientation = (): OrientationType => {-- /**- * Determines the initial orientation based on comparing- * window width and height dimensions.- */- const initialOrientation: OrientationType = window.innerWidth > window.innerHeight ? "landscape" :- window.innerWidth < window.innerHeight ? "portrait" : "square"-- /**- * State tracking the current device orientation.- */- const [orientation, setOrientation] = useState<OrientationType>(initialOrientation)-- /**- * Sets up an event listener to track window resize events and- * recalculate the orientation when dimensions change.- *- * The effect cleans up by removing the event listener when the component unmounts.- */- useEffect(() => {-- /**- * Handler function that recalculates the current orientation- * based on window dimensions and updates the state accordingly.- */- const resize = function () {-- // Landscape orientation- if (window.innerWidth > window.innerHeight) setOrientation("landscape")-- // Portrait orientation- else if (window.innerWidth < window.innerHeight) setOrientation("portrait")-- // Square orientation- else setOrientation("square")-- }-- // Add resize listener- window.addEventListener("resize", resize)-- /**- * On end remove resize listener- */- return () => window.removeEventListener("resize", resize)-- }, [])-- return orientation-}--/**- * Orientation is a component that conditionally renders content- * based on the current device orientation.- *- * It leverages the useOrientation hook internally to determine which- * content to display, providing a declarative way to adapt UI based on- * device orientation changes.- *- * @param cases An object containing content to display for different orientations- * @returns The content associated with the current orientation- *- * @example- *- * <Orientation- * landscape={<LandscapeLayout />}- * portrait={<PortraitLayout />}- * square={<SquareLayout />}- * />- */-export const Orientation = (cases: Partial<Record<OrientationType, React.ReactNode>>) => {-- /**- * Tracks the current device orientation to determine- * which content variant should be rendered.- */- const orientation = useOrientation()-- return <React.Fragment>{cases[orientation]}</React.Fragment>-}--/**- * Common breakpoint for small screen devices.- * This constant can be used with the useScreen hook or Screen component- * to implement consistent responsive behavior across the application.- */-export const SMALL_SCREEN: number = 768--/**- * Detection for mobile devices based on user agent.- * This boolean can be used to apply mobile-specific logic or optimizations.- */-export const isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)--/**- * Defines the possible device orientation types.- * Used by the useOrientation hook and Orientation component.- */-export type OrientationType = "landscape" | "portrait" | "square"--/**- * Props interface for the Screen component.- * Defines the configuration options and content variants- * for responsive rendering.- */-interface ScreenProps {- min?: number- max?: number- available?: React.ReactNode- unavailable?: React.ReactNode-}--export default Screen\ No newline at end of filediff --git a/source/libs/the-link/decorators/legacy.ts b/source/libs/the-link/decorators/legacy.tsdeleted file mode 100644index 972f633..0000000--- a/source/libs/the-link/decorators/legacy.ts+++ /dev/null@@ -1,166 +0,0 @@-import { Finalizer, Forwarder, Interceptor, Subscriber } from "../tunnel"-import TheLink, { Publisher, TunnelName } from "../the-link"--/**- * Register a method as an interceptor on one of the link tunnels.- *- * The decorated method is bound to each instance during TheLink initialization- * and registered with prefix matching on the selected tunnel.- *- * @param tunnelName Target tunnel for interceptor registration- * @param prefix Event prefix to intercept, or an empty string for all events- * @returns Legacy method decorator- */-export function Intercept(tunnelName: TunnelName, prefix: string = "") {-- return function <TargetLink extends TheLink>(targetLink: TargetLink, interceptorName: string, _descriptor: TypedPropertyDescriptor<Interceptor>) {-- targetLink.addInitializer(function (instanceLink) {-- // Select the tunnel when the concrete instance is available.- const tunnel = tunnelName === "outbound" ? instanceLink.$outbound : instanceLink.$inbound-- const interceptor = instanceLink[interceptorName as keyof TargetLink] as Interceptor-- // Bind the method so decorators preserve instance context.- tunnel.addInterceptor(interceptor.bind(instanceLink), prefix)- })- }-}--/**- * Register a method as a subscriber for a tunnel event.- *- * The decorated method is bound during instance initialization and subscribed to- * the configured event on the selected tunnel.- *- * @param event Event identifier to subscribe to- * @param tunnelName Target tunnel for subscription- * @returns Legacy method decorator- */-export function Subscribe(event: string, tunnelName: TunnelName = "inbound") {-- return function <TargetLink extends TheLink>(targetLink: TargetLink, subscriberName: string, _descriptor: TypedPropertyDescriptor<Subscriber>) {-- targetLink.addInitializer(function (instanceLink) {-- // Select the tunnel when the concrete instance is available.- const tunnel = tunnelName === "outbound" ? instanceLink.$outbound : instanceLink.$inbound-- const subscriber = instanceLink[subscriberName as keyof TargetLink] as Subscriber-- // Bind the method so subscribers run with the instance as `this`.- tunnel.subscribe(event, subscriber.bind(instanceLink))- })- }-}--/**- * Register a method as a forwarder on one of the link tunnels.- *- * Forwarders receive matching events from the selected tunnel and can route them- * to another destination with optional prefix translation.- *- * @param tunnelName Target tunnel for forwarder registration- * @param fromPrefix Source event prefix to match- * @param toPrefix Destination event prefix to apply- * @returns Legacy method decorator- */-export function Forward(tunnelName: TunnelName, fromPrefix: string = "", toPrefix: string = "") {-- return function <TargetLink extends TheLink>(targetLink: TargetLink, forwarderName: string, _descriptor: TypedPropertyDescriptor<Forwarder>) {-- targetLink.addInitializer(function (instanceLink) {-- // Select the tunnel when the concrete instance is available.- const tunnel = tunnelName === "outbound" ? instanceLink.$outbound : instanceLink.$inbound-- const forwarder = instanceLink[forwarderName as keyof TargetLink] as Forwarder-- // Bind the method before registering it as a tunnel forwarder.- tunnel.forwardTo(forwarder.bind(instanceLink), fromPrefix, toPrefix)- })- }-}--/**- * Register a method as a finalizer on one of the link tunnels.- *- * Finalizers run after subscribers and forwarders, allowing result arrays to be- * transformed before publish returns.- *- * @param tunnelName Target tunnel for finalizer registration- * @param prefix Event prefix to finalize, or an empty string for all events- * @returns Legacy method decorator- */-export function Finalize(tunnelName: TunnelName, prefix: string = "") {-- return function <TargetLink extends TheLink>(targetLink: TargetLink, finalizerName: string, _descriptor: TypedPropertyDescriptor<Finalizer>) {-- targetLink.addInitializer(function (instanceLink) {-- // Select the tunnel when the concrete instance is available.- const tunnel = tunnelName === "outbound" ? instanceLink.$outbound : instanceLink.$inbound-- const finalizer = instanceLink[finalizerName as keyof TargetLink] as Finalizer-- // Bind the method so finalizers preserve instance context.- tunnel.addFinalizer(finalizer.bind(instanceLink), prefix)- })- }-}--/**- * Wrap a method so its return value is published as a tunnel event.- *- * The original method still returns its own result. After it resolves, that- * result is published on the configured tunnel.- *- * @param event Event identifier to publish after method execution- * @param tunnelName Target tunnel for publication- * @returns Legacy method decorator- */-export function Publish(event: string, tunnelName: TunnelName = "outbound") {-- return function <TargetLink extends TheLink>(targetLink: TargetLink, publisherName: string, _descriptor: TypedPropertyDescriptor<Publisher>) {-- targetLink.addInitializer(function (instanceLink) {-- // Select the tunnel when the concrete instance is available.- const tunnel = tunnelName === "outbound" ? instanceLink.$outbound : instanceLink.$inbound-- const publisher = instanceLink[publisherName as keyof TargetLink] as Publisher-- // Replace the method with a wrapper that publishes its resolved result.- (instanceLink[publisherName as keyof TargetLink] as Publisher) = async function (...values: unknown[]) {-- const result = await publisher.apply(instanceLink, values)-- await tunnel.publish(event, result)-- return result- }- })- }-}--/**- * Combine inbound subscription with outbound publication for one method.- *- * Equivalent to applying `Publish(publishEvent || subscribeEvent, "outbound")`- * and `Subscribe(subscribeEvent, "inbound")` to the same method.- *- * @param subscribeEvent Inbound event identifier to subscribe to- * @param publishEvent Optional outbound event identifier, defaults to subscribeEvent- * @returns Legacy method decorator- */-export function Connect(subscribeEvent: string, publishEvent?: string) {-- return function <TargetLink extends TheLink>(targetLink: TargetLink, methodName: string, descriptor: TypedPropertyDescriptor<Subscriber & Publisher>) {-- // Register publish first so Subscribe captures the wrapped method.- Publish(publishEvent || subscribeEvent, "outbound")(targetLink, methodName, descriptor)-- Subscribe(subscribeEvent, "inbound")(targetLink, methodName, descriptor)- }-}\ No newline at end of filediff --git a/source/libs/the-link/plugins/tab-link/tab-link.ts b/source/libs/the-link/plugins/tab-link/tab-link.tsdeleted file mode 100644index 78fb67d..0000000--- a/source/libs/the-link/plugins/tab-link/tab-link.ts+++ /dev/null@@ -1,69 +0,0 @@-import TheLink from "../../the-link"--/**- * Cross-tab communication adapter using the BroadcastChannel API.- *- * Provides lightweight bidirectional event routing between browser tabs and- * windows on the same origin. A shared namespace creates an isolated- * BroadcastChannel, preventing unrelated application contexts from receiving- * each other's events.- *- * Outbound tunnel events are posted to the channel with structured cloning, and- * incoming channel messages are published through the inbound tunnel.- *- * @example- * ```typescript- * const firstTab = new TabLink("workspace-sync")- * firstTab.$inbound.subscribe("document:update", handleUpdate)- *- * const secondTab = new TabLink("workspace-sync")- * await secondTab.$outbound.publish("document:update", documentData)- * ```- */-export default class TabLink extends TheLink {-- /**- * Namespace-isolated BroadcastChannel used for cross-tab transport.- */- private readonly channel: BroadcastChannel-- /**- * Initialize a TabLink for one BroadcastChannel namespace.- *- * @param namespace Unique channel name shared by tabs that should communicate- */- public constructor(namespace: string) {-- super()-- // Create the same-origin channel used to exchange events between tabs.- this.channel = new BroadcastChannel(namespace)-- // Route messages from other tabs into the local inbound tunnel.- this.channel.addEventListener("message", this.messageHandler.bind(this))-- // Broadcast local outbound events to other tabs.- this.$outbound.forwardTo(this.publishHandler.bind(this))- }-- /**- * Process an incoming BroadcastChannel message.- *- * @param message BroadcastChannel message containing an event envelope- */- private async messageHandler(message: MessageEvent<[string, ...unknown[]]>) {-- await this.$inbound.publish(...message.data)- }-- /**- * Publish an outbound tunnel event to the BroadcastChannel.- *- * @param event Event identifier for remote tabs- * @param values Event payload values sent through structured cloning- */- private publishHandler(event: string, ...values: unknown[]) {-- this.channel.postMessage([event, ...values])- }-}\ No newline at end of file