Refactor: create src/lib to reflect actual sharing of that code

zio/stable
Paul Frazee 2022-11-22 12:02:31 -06:00
parent e858bb52de
commit c2a39d7c1f
21 changed files with 33 additions and 21 deletions

View File

@ -1,4 +1,4 @@
import {extractEntities} from '../src/view/lib/strings' import {extractEntities} from '../src/lib/strings'
describe('extractEntities', () => { describe('extractEntities', () => {
const inputs = [ const inputs = [

View File

@ -0,0 +1,3 @@
export function clamp(v: number, min: number, max: number): number {
return Math.min(max, Math.max(min, v))
}

View File

@ -1,6 +1,6 @@
import {AtUri} from '../../third-party/uri' import {AtUri} from '../third-party/uri'
import {Entity} from '../../third-party/api/src/client/types/app/bsky/feed/post' import {Entity} from '../third-party/api/src/client/types/app/bsky/feed/post'
import {PROD_SERVICE} from '../../state' import {PROD_SERVICE} from '../state'
export const MAX_DISPLAY_NAME = 64 export const MAX_DISPLAY_NAME = 64
export const MAX_DESCRIPTION = 256 export const MAX_DESCRIPTION = 256

View File

@ -10,7 +10,7 @@ import * as Post from '../../third-party/api/src/client/types/app/bsky/feed/post
import {AtUri} from '../../third-party/uri' import {AtUri} from '../../third-party/uri'
import {APP_BSKY_GRAPH} from '../../third-party/api' import {APP_BSKY_GRAPH} from '../../third-party/api'
import {RootStoreModel} from '../models/root-store' import {RootStoreModel} from '../models/root-store'
import {extractEntities} from '../../view/lib/strings' import {extractEntities} from '../../lib/strings'
export function doPolyfill() { export function doPolyfill() {
AtpApi.xrpc.fetch = fetchHandler AtpApi.xrpc.fetch = fetchHandler

View File

@ -4,7 +4,7 @@ import * as GetAuthorFeed from '../../third-party/api/src/client/types/app/bsky/
import {AtUri} from '../../third-party/uri' import {AtUri} from '../../third-party/uri'
import {RootStoreModel} from './root-store' import {RootStoreModel} from './root-store'
import * as apilib from '../lib/api' import * as apilib from '../lib/api'
import {cleanError} from '../../view/lib/strings' import {cleanError} from '../../lib/strings'
export class FeedItemMyStateModel { export class FeedItemMyStateModel {
repost?: string repost?: string

View File

@ -4,7 +4,7 @@ import {RootStoreModel} from './root-store'
import {Declaration} from './_common' import {Declaration} from './_common'
import {hasProp} from '../lib/type-guards' import {hasProp} from '../lib/type-guards'
import {APP_BSKY_GRAPH} from '../../third-party/api' import {APP_BSKY_GRAPH} from '../../third-party/api'
import {cleanError} from '../../view/lib/strings' import {cleanError} from '../../lib/strings'
const UNGROUPABLE_REASONS = ['trend', 'assertion'] const UNGROUPABLE_REASONS = ['trend', 'assertion']

View File

@ -2,7 +2,7 @@ import {makeAutoObservable} from 'mobx'
import * as Post from '../../third-party/api/src/client/types/app/bsky/feed/post' import * as Post from '../../third-party/api/src/client/types/app/bsky/feed/post'
import {AtUri} from '../../third-party/uri' import {AtUri} from '../../third-party/uri'
import {RootStoreModel} from './root-store' import {RootStoreModel} from './root-store'
import {cleanError} from '../../view/lib/strings' import {cleanError} from '../../lib/strings'
export type PostEntities = Post.Record['entities'] export type PostEntities = Post.Record['entities']
export type PostReply = Post.Record['reply'] export type PostReply = Post.Record['reply']

View File

@ -18,7 +18,7 @@ import {
enforceLen, enforceLen,
MAX_DISPLAY_NAME, MAX_DISPLAY_NAME,
MAX_DESCRIPTION, MAX_DESCRIPTION,
} from '../../lib/strings' } from '../../../lib/strings'
import {AppBskyActorCreateScene} from '../../../third-party/api/index' import {AppBskyActorCreateScene} from '../../../third-party/api/index'
export const snapPoints = ['60%'] export const snapPoints = ['60%']

View File

@ -7,7 +7,11 @@ import {ErrorMessage} from '../util/ErrorMessage'
import {useStores} from '../../../state' import {useStores} from '../../../state'
import {ProfileViewModel} from '../../../state/models/profile-view' import {ProfileViewModel} from '../../../state/models/profile-view'
import {s, colors, gradients} from '../../lib/styles' import {s, colors, gradients} from '../../lib/styles'
import {enforceLen, MAX_DISPLAY_NAME, MAX_DESCRIPTION} from '../../lib/strings' import {
enforceLen,
MAX_DISPLAY_NAME,
MAX_DESCRIPTION,
} from '../../../lib/strings'
import * as Profile from '../../../third-party/api/src/client/types/app/bsky/actor/profile' import * as Profile from '../../../third-party/api/src/client/types/app/bsky/actor/profile'
export const snapPoints = ['60%'] export const snapPoints = ['60%']

View File

@ -5,7 +5,7 @@ import {AtUri} from '../../../third-party/uri'
import {FontAwesomeIcon, Props} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon, Props} from '@fortawesome/react-native-fontawesome'
import {NotificationsViewItemModel} from '../../../state/models/notifications-view' import {NotificationsViewItemModel} from '../../../state/models/notifications-view'
import {s, colors} from '../../lib/styles' import {s, colors} from '../../lib/styles'
import {ago, pluralize} from '../../lib/strings' import {ago, pluralize} from '../../../lib/strings'
import {UpIconSolid} from '../../lib/icons' import {UpIconSolid} from '../../lib/icons'
import {UserAvatar} from '../util/UserAvatar' import {UserAvatar} from '../util/UserAvatar'
import {PostText} from '../post/PostText' import {PostText} from '../post/PostText'

View File

@ -12,7 +12,7 @@ import {PostDropdownBtn} from '../util/DropdownBtn'
import Toast from '../util/Toast' import Toast from '../util/Toast'
import {UserAvatar} from '../util/UserAvatar' import {UserAvatar} from '../util/UserAvatar'
import {s, colors} from '../../lib/styles' import {s, colors} from '../../lib/styles'
import {ago, pluralize} from '../../lib/strings' import {ago, pluralize} from '../../../lib/strings'
import {useStores} from '../../../state' import {useStores} from '../../../state'
import {PostMeta} from '../util/PostMeta' import {PostMeta} from '../util/PostMeta'
import {PostCtrls} from '../util/PostCtrls' import {PostCtrls} from '../util/PostCtrls'

View File

@ -17,7 +17,7 @@ import {
EditProfileModel, EditProfileModel,
InviteToSceneModel, InviteToSceneModel,
} from '../../../state/models/shell-ui' } from '../../../state/models/shell-ui'
import {pluralize} from '../../lib/strings' import {pluralize} from '../../../lib/strings'
import {s, colors} from '../../lib/styles' import {s, colors} from '../../lib/styles'
import {getGradient} from '../../lib/asset-gen' import {getGradient} from '../../lib/asset-gen'
import {MagnifyingGlassIcon} from '../../lib/icons' import {MagnifyingGlassIcon} from '../../lib/icons'

View File

@ -13,7 +13,7 @@ import {IconProp} from '@fortawesome/fontawesome-svg-core'
import RootSiblings from 'react-native-root-siblings' import RootSiblings from 'react-native-root-siblings'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {colors} from '../../lib/styles' import {colors} from '../../lib/styles'
import {toShareUrl} from '../../lib/strings' import {toShareUrl} from '../../../lib/strings'
import {useStores} from '../../../state' import {useStores} from '../../../state'
import {ConfirmModel} from '../../../state/models/shell-ui' import {ConfirmModel} from '../../../state/models/shell-ui'
import {TABS_ENABLED} from '../../../build-flags' import {TABS_ENABLED} from '../../../build-flags'

View File

@ -4,7 +4,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {Link} from '../util/Link' import {Link} from '../util/Link'
import {PostDropdownBtn} from '../util/DropdownBtn' import {PostDropdownBtn} from '../util/DropdownBtn'
import {s} from '../../lib/styles' import {s} from '../../lib/styles'
import {ago} from '../../lib/strings' import {ago} from '../../../lib/strings'
interface PostMetaOpts { interface PostMetaOpts {
itemHref: string itemHref: string

View File

@ -16,7 +16,11 @@ import * as EmailValidator from 'email-validator'
import {observer} from 'mobx-react-lite' import {observer} from 'mobx-react-lite'
import {Picker} from '../com/util/Picker' import {Picker} from '../com/util/Picker'
import {s, colors} from '../lib/styles' import {s, colors} from '../lib/styles'
import {makeValidHandle, createFullHandle, toNiceDomain} from '../lib/strings' import {
makeValidHandle,
createFullHandle,
toNiceDomain,
} from '../../lib/strings'
import {useStores, DEFAULT_SERVICE} from '../../state' import {useStores, DEFAULT_SERVICE} from '../../state'
import {ServiceDescription} from '../../state/models/session' import {ServiceDescription} from '../../state/models/session'
import {ServerInputModel} from '../../state/models/shell-ui' import {ServerInputModel} from '../../state/models/shell-ui'

View File

@ -4,7 +4,7 @@ import {ViewHeader} from '../com/util/ViewHeader'
import {PostVotedBy as PostLikedByComponent} from '../com/post-thread/PostVotedBy' import {PostVotedBy as PostLikedByComponent} from '../com/post-thread/PostVotedBy'
import {ScreenParams} from '../routes' import {ScreenParams} from '../routes'
import {useStores} from '../../state' import {useStores} from '../../state'
import {makeRecordUri} from '../lib/strings' import {makeRecordUri} from '../../lib/strings'
export const PostDownvotedBy = ({navIdx, visible, params}: ScreenParams) => { export const PostDownvotedBy = ({navIdx, visible, params}: ScreenParams) => {
const store = useStores() const store = useStores()

View File

@ -4,7 +4,7 @@ import {ViewHeader} from '../com/util/ViewHeader'
import {PostRepostedBy as PostRepostedByComponent} from '../com/post-thread/PostRepostedBy' import {PostRepostedBy as PostRepostedByComponent} from '../com/post-thread/PostRepostedBy'
import {ScreenParams} from '../routes' import {ScreenParams} from '../routes'
import {useStores} from '../../state' import {useStores} from '../../state'
import {makeRecordUri} from '../lib/strings' import {makeRecordUri} from '../../lib/strings'
export const PostRepostedBy = ({navIdx, visible, params}: ScreenParams) => { export const PostRepostedBy = ({navIdx, visible, params}: ScreenParams) => {
const store = useStores() const store = useStores()

View File

@ -1,6 +1,6 @@
import React, {useEffect, useMemo, useState} from 'react' import React, {useEffect, useMemo, useState} from 'react'
import {View} from 'react-native' import {View} from 'react-native'
import {makeRecordUri} from '../lib/strings' import {makeRecordUri} from '../../lib/strings'
import {ViewHeader} from '../com/util/ViewHeader' import {ViewHeader} from '../com/util/ViewHeader'
import {PostThread as PostThreadComponent} from '../com/post-thread/PostThread' import {PostThread as PostThreadComponent} from '../com/post-thread/PostThread'
import {PostThreadViewModel} from '../../state/models/post-thread-view' import {PostThreadViewModel} from '../../state/models/post-thread-view'

View File

@ -4,7 +4,7 @@ import {ViewHeader} from '../com/util/ViewHeader'
import {PostVotedBy as PostLikedByComponent} from '../com/post-thread/PostVotedBy' import {PostVotedBy as PostLikedByComponent} from '../com/post-thread/PostVotedBy'
import {ScreenParams} from '../routes' import {ScreenParams} from '../routes'
import {useStores} from '../../state' import {useStores} from '../../state'
import {makeRecordUri} from '../lib/strings' import {makeRecordUri} from '../../lib/strings'
export const PostUpvotedBy = ({navIdx, visible, params}: ScreenParams) => { export const PostUpvotedBy = ({navIdx, visible, params}: ScreenParams) => {
const store = useStores() const store = useStores()

View File

@ -21,7 +21,7 @@ import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import Swipeable from 'react-native-gesture-handler/Swipeable' import Swipeable from 'react-native-gesture-handler/Swipeable'
import {useStores} from '../../../state' import {useStores} from '../../../state'
import {s, colors} from '../../lib/styles' import {s, colors} from '../../lib/styles'
import {toShareUrl} from '../../lib/strings' import {toShareUrl} from '../../../lib/strings'
import {match} from '../../routes' import {match} from '../../routes'
const TAB_HEIGHT = 42 const TAB_HEIGHT = 42

View File

@ -37,6 +37,7 @@ import {MainMenu} from './MainMenu'
import {TabsSelector} from './TabsSelector' import {TabsSelector} from './TabsSelector'
import {Composer} from './Composer' import {Composer} from './Composer'
import {s, colors} from '../../lib/styles' import {s, colors} from '../../lib/styles'
import {clamp} from '../../../lib/numbers'
import { import {
GridIcon, GridIcon,
GridIconSolid, GridIconSolid,