Skip to content

Commit

Permalink
Use specific imports against protolib to prevent super big loading ti…
Browse files Browse the repository at this point in the history
…mes while in dev mode, since protolib is not compiled while in dev
  • Loading branch information
jcarlosn committed Jul 5, 2024
1 parent 8ae246a commit 4d088a9
Show file tree
Hide file tree
Showing 42 changed files with 63 additions and 44 deletions.
2 changes: 1 addition & 1 deletion apps/electron/pages/[...name].tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useSession } from 'protolib'
import { useSession } from 'protolib/lib/Session'
import Custom404 from './404'
import { useSearchParams } from 'solito/navigation';
import electronPages from 'app/bundles/electronPages'
Expand Down
2 changes: 1 addition & 1 deletion apps/electron/pages/screen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feature from 'app/bundles/custom/pages/screen'
import { useSession } from 'protolib'
import { useSession } from 'protolib/lib/Session'

export default function IndexPage(props:any) {
useSession(props.pageSession)
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/auth/login.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SignInPage } from 'app/features/auth/login'
import Head from 'next/head'
import { hasSessionCookie, SSR } from 'protolib'
import { hasSessionCookie, SSR } from 'protolib/lib/Session'
import { NextPageContext } from 'next'

export default function Page(props:any) {
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/auth/register.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SignInPage } from 'app/features/auth/register'
import Head from 'next/head'
import { hasSessionCookie, SSR } from 'protolib'
import { hasSessionCookie, SSR } from 'protolib/lib/Session'
import { NextPageContext } from 'next'

export default function Page(props:any) {
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feature from 'app/bundles/custom/pages/home'
import { useSession } from 'protolib'
import { useSession } from 'protolib/lib/Session'

export default function IndexPage(props:any) {
useSession(props.pageSession)
Expand Down
3 changes: 2 additions & 1 deletion apps/next/pages/profile.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Profile } from 'app/features/profile'
import Head from 'next/head'
import { NextPageContext } from 'next'
import { useSession, withSession, SSR} from 'protolib'
import { useSession, withSession } from 'protolib/lib/Session'
import {SSR} from 'protolib/lib/SSR'

export default function ProfilePage(props:any) {
useSession(props.pageSession)
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/[...page].tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { useEffect } from 'react';
import { useRouter, useSearchParams } from 'solito/navigation';
import { SiteConfig } from 'app/conf';
import { getWorkspaceEnv } from 'protolib';
import { getWorkspaceEnv } from 'protolib/lib/useWorkspaceEnv';
import { getEnv } from 'protolib/base';

const serviceEnv = getEnv()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/apis.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ApisPage from 'protolib/bundles/apis/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/deviceBoards.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DevicesPages from 'protolib/bundles/devices/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
const PageComponent = DevicesPages['deviceBoards/**'].component
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/deviceCores.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DevicesPages from 'protolib/bundles/devices/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
const PageComponent = DevicesPages['deviceCores/**'].component
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/deviceDefinitions.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DevicesPages from 'protolib/bundles/devices/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
const PageComponent = DevicesPages['deviceDefinitions/**'].component
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/deviceSdks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DevicesPages from 'protolib/bundles/devices/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
const PageComponent = DevicesPages['deviceSdks/**'].component
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/devices.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DevicesPages from 'protolib/bundles/devices/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
const PageComponent = DevicesPages['devices/**'].component
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/events.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import EventsPage from 'protolib/bundles/events/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/files.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FilesPage from 'protolib/bundles/files/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/fsm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FSMPages from 'protolib/bundles/fsm/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/groups.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import GroupsPage from 'protolib/bundles/groups/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/keys.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import KeysPage from 'protolib/bundles/keys/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/messages.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import MessagesPage from 'protolib/bundles/messages/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/objects.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ObjectsPage from 'protolib/bundles/objects/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/pages.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import PagesPage from 'protolib/bundles/pages/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/resources.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ResourcesPage from 'protolib/bundles/resources/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/services.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ServicesPage from 'protolib/bundles/services/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/workspace/users.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import UsersPage from 'protolib/bundles/users/adminPages'
import Head from 'next/head'
import { useRedirectToEnviron } from 'protolib'
import { useRedirectToEnviron } from 'protolib/lib/useRedirectToEnviron'

export default function Page(props:any) {
useRedirectToEnviron()
Expand Down
2 changes: 1 addition & 1 deletion packages/app/bundles/custom/menu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { clearSession } from 'protolib'
import { clearSession } from 'protolib/lib/Session'

const logout = (setSession, setSessionContext) => {
clearSession(setSession, setSessionContext)
Expand Down
13 changes: 12 additions & 1 deletion packages/app/bundles/custom/pages/home.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
import React, { useState } from "react";
import { Theme } from "@my/ui";
import { UIWrapLib, UIWrap, withSession, Page, useEditor, API, SSR, useComposedState, Text, Pressable, Icon, VStack, HStack, Image } from "protolib";
import {Page} from 'protolib/components/Page'
import {Text} from 'protolib/components/Text'
import {Pressable} from 'protolib/components/Pressable'
import {Icon} from 'protolib/components/Icon'
import VStack from 'protolib/components/VStack'
import HStack from 'protolib/components/HStack'
import Image from 'protolib/components/Image'
import {useComposedState} from 'protolib/lib/useComposedState'
import {withSession } from "protolib/lib/Session"
import {useEditor} from 'protolib/visualui/useEdit'
import {SSR} from 'protolib/lib/SSR'
import {UIWrapLib, UIWrap} from 'protolib/visualui/visualuiWrapper'
import { DefaultLayout } from "../../../layout/DefaultLayout";
import { Protofy } from "protolib/base";
import { context } from "app/bundles/uiContext";
Expand Down
7 changes: 5 additions & 2 deletions packages/app/bundles/custom/pages/notFound.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { DefaultLayout } from 'app/layout/DefaultLayout'
import { AlertTriangle } from '@tamagui/lucide-icons'
import {Page} from 'protolib'
import {Page} from 'protolib/components/Page'
import { Protofy } from 'protolib/base'
import { Theme, YStack, Text, XStack, Paragraph,H2 } from "@my/ui"
import React, { useState } from 'react'
import { UIWrapLib, UIWrap, withSession, useEditor, SSR } from "protolib"
import {withSession } from "protolib/lib/Session"
import {useEditor} from 'protolib/visualui/useEdit'
import {SSR} from 'protolib/lib/SSR'
import {UIWrapLib, UIWrap} from 'protolib/visualui/visualuiWrapper'

const isProtected = Protofy("protected", false)

Expand Down
2 changes: 1 addition & 1 deletion packages/app/bundles/intents.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {IntentType} from 'protolib'
import {IntentType} from 'protolib/lib/Intent'
import {processFilesIntent} from 'protolib/bundles/files/intents'
import { useMemo } from 'react';

Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/bundles/apis/masks/ApiMask.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Node, Field, FlowPort, NodeParams, FallbackPort, Button, getFieldValue } from 'protoflow';
import { API } from 'protolib'
import { API } from 'protolib/base/Api'
import { Plug } from 'lucide-react';
import { filterCallback, restoreCallback } from 'protoflow';
import { SiteConfig} from 'app/conf'
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/bundles/apis/masks/Automation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Node, getFieldValue, FlowPort, NodeParams, FallbackPort, Button, filterCallback, restoreCallback } from 'protoflow';
import { API } from 'protolib'
import { API } from 'protolib/base/Api'
import { Plug } from 'lucide-react';
import { useColorFromPalette } from 'protoflow/src/diagram/Theme'
import React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/bundles/apis/masks/ExecuteAutomation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Send } from 'lucide-react';
import { useColorFromPalette } from 'protoflow/src/diagram/Theme'
import { filterCallback, restoreCallback } from 'protoflow';
import { useEffect, useState } from 'react';
import { API } from 'protolib'
import { API } from 'protolib/base/Api'

const ExecuteAutomation = (node: any = {}, nodeData = {}) => {
const color = useColorFromPalette(20)
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/bundles/apis/masks/Fetch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Send } from 'lucide-react';
import { useColorFromPalette } from 'protoflow/src/diagram/Theme'
import { filterCallback, restoreCallback } from 'protoflow';
import { useEffect, useState } from 'react';
import { API } from 'protolib'
import { API } from 'protolib/base/Api'

const Fetch = (node: any = {}, nodeData = {}) => {
const color = useColorFromPalette(20)
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/bundles/automations/masks/Automation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useColorFromPalette } from 'protoflow/src/diagram/Theme';
import { Plug } from 'lucide-react';
import React from 'react';
import { SizableText, Spinner, XStack } from 'tamagui';
import { API } from 'protolib'
import { API } from 'protolib/base/Api'
import { SiteConfig} from 'app/conf'
import { useWorkspaceEnv } from 'protolib';

Expand Down
3 changes: 2 additions & 1 deletion packages/protolib/bundles/keys/adminPages.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { KeyModel } from '.'
import { DataView, AdminPage } from 'protolib'
import { DataView } from '../../components/DataView'
import { AdminPage } from '../../components/AdminPage'
import { Key } from '@tamagui/lucide-icons';
import { usePrompt } from '../../context/PromptAtom'
import { PaginatedData } from '../../lib/SSR';
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/bundles/pages/templates/electronPage.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feature from 'app/bundles/custom/pages/{{name}}'
import { useSession } from 'protolib'
import { useSession } from 'protolib/lib/Session'
import { useRouter } from "solito/navigation";

export default function {{upperName}}Page(props:any) {
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/bundles/pages/templates/nextPage.tpl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Feature from 'app/bundles/custom/pages/{{name}}'
import { useSession } from 'protolib'
import { useSession } from 'protolib/lib/Session'

export default function {{upperName}}Page(props:any) {
useSession(props.pageSession)
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/components/Page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from "react";
import { StackProps, YStack, useTheme } from "tamagui";
import { useIsEditing } from "protolib"
import { useIsEditing } from "protolib/visualui/useIsEditing"
import Head from 'next/head'
import { useSession, useSessionContext, useSessionGroup, useWorkspaces } from "../lib/Session";
import { useUpdateEffect } from "usehooks-ts";
Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/components/SearchAndSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Input, InputProps, ListItem, YGroup, YStack } from "@my/ui"
import { useEffect, useRef, useState } from "react"
import { API } from 'protolib'
import { API } from 'protolib/base/Api'

type SearchAndSelectProps = {
getDisplayField?: Function
Expand Down
3 changes: 2 additions & 1 deletion packages/protolib/lib/SSR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import {SiteConfig} from 'app/conf'
export * from '../components/AdminPage'
import { NextPageContext } from 'next'
import { API, withSession, getURLWithToken, AdminPage } from 'protolib'
import {API} from '../base/Api'
import {withSession, getURLWithToken} from './Session'

export const SSR = (fn) => SiteConfig.SSR ? fn : undefined

Expand Down
2 changes: 1 addition & 1 deletion packages/protolib/lib/Session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as cookie from 'cookie'
import { createSession, validateSession, SessionDataType, getSessionContext } from '../api/lib/session';
import { NextPageContext } from 'next'
import { parse } from 'cookie';
import { getLogger } from "protolib/base"
import { getLogger } from "protolib/base/logger"

const logger = getLogger()

Expand Down
3 changes: 2 additions & 1 deletion packages/protolib/lib/useRedirectToEnviron.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AppConfContext, SiteConfigType, getWorkspaceEnv } from 'protolib';
import { AppConfContext, SiteConfigType } from 'protolib';
import { getWorkspaceEnv } from './useWorkspaceEnv';
import { useContext, useEffect } from 'react';
import { useRouter, usePathname } from 'solito/navigation';
import { getEnv } from '../base';
Expand Down
5 changes: 3 additions & 2 deletions packages/protolib/visualui/useEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { useState, useEffect } from 'react'
import { API, Tinted } from 'protolib'
import { API } from 'protolib/base/Api'
import {Tinted} from 'protolib/components/Tinted'
import { Pencil } from '@tamagui/lucide-icons'
import { getTokens } from '@tamagui/core'
import { Button } from 'tamagui'
import dynamic from 'next/dynamic';
import { palettes } from 'app/bundles/palettes'
import { Session } from 'protolib'
import { Session } from 'protolib/lib/Session'
import { useAtom } from 'jotai'
import { useIsEditing } from './useIsEditing'
import { useToastController } from '@my/ui'
Expand Down

0 comments on commit 4d088a9

Please sign in to comment.