finish phase 3: type-only codemod and zero non-bridge @atproto/api imports
Task 8: codemod repointed 150 namespace-type files to #/lexicons (AppBskyFeedDefs.PostView -> app.bsky.feed.defs.PostView, .Record -> .Main) plus ~105 hand-fixed consumers (composer/video state, DebugMod, Profile, onboarding, dialogs). DM_SERVICE_HEADERS deleted; last chat call sites on the chat client. RichText.tsx flipped to SDK-only. Remaining @atproto/api importers: the three session bridge files, the deliberate dual-world matcher in lib/xrpc-error.ts, and test fixtures. toLex boundary casts are TODO(phase4)-tagged for bridge removal. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,7 @@ import {sha256} from 'js-sha256'
|
||||
import {CID} from 'multiformats/cid'
|
||||
import * as Hasher from 'multiformats/hashes/hasher'
|
||||
|
||||
import {app} from '#/lexicons'
|
||||
import {type app} from '#/lexicons'
|
||||
|
||||
/*
|
||||
* Client-side CID computation for post records, extracted from the post
|
||||
|
||||
+38
-47
@@ -1,17 +1,10 @@
|
||||
import {
|
||||
type AppBskyActorDefs,
|
||||
AppBskyEmbedRecord,
|
||||
AppBskyEmbedRecordWithMedia,
|
||||
AppBskyFeedDefs,
|
||||
AppBskyFeedPost,
|
||||
} from '@atproto/api'
|
||||
|
||||
import {app} from '#/lexicons'
|
||||
import * as bsky from '#/types/bsky'
|
||||
import {isPostInLanguage} from '../../locale/helpers'
|
||||
import {FALLBACK_MARKER_POST} from './feed/home'
|
||||
import {type ReasonFeedSource} from './feed/types'
|
||||
|
||||
type FeedViewPost = AppBskyFeedDefs.FeedViewPost
|
||||
type FeedViewPost = app.bsky.feed.defs.FeedViewPost
|
||||
|
||||
export type FeedTunerFn = (
|
||||
tuner: FeedTuner,
|
||||
@@ -20,18 +13,18 @@ export type FeedTunerFn = (
|
||||
) => FeedViewPostsSlice[]
|
||||
|
||||
type FeedSliceItem = {
|
||||
post: AppBskyFeedDefs.PostView
|
||||
record: AppBskyFeedPost.Record
|
||||
parentAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
post: app.bsky.feed.defs.PostView
|
||||
record: app.bsky.feed.post.Main
|
||||
parentAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
isParentBlocked: boolean
|
||||
isParentNotFound: boolean
|
||||
}
|
||||
|
||||
type AuthorContext = {
|
||||
author: AppBskyActorDefs.ProfileViewBasic
|
||||
parentAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
grandparentAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
rootAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
author: app.bsky.actor.defs.ProfileViewBasic
|
||||
parentAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
grandparentAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
rootAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
}
|
||||
|
||||
export class FeedViewPostsSlice {
|
||||
@@ -53,7 +46,7 @@ export class FeedViewPostsSlice {
|
||||
this.isOrphan = false
|
||||
this.isThreadMuted = post.viewer?.threadMuted ?? false
|
||||
this.feedPostUri = post.uri
|
||||
if (AppBskyFeedDefs.isPostView(reply?.root)) {
|
||||
if (bsky.isType(app.bsky.feed.defs.postView, reply?.root)) {
|
||||
this.rootUri = reply.root.uri
|
||||
} else {
|
||||
this.rootUri = post.uri
|
||||
@@ -68,17 +61,17 @@ export class FeedViewPostsSlice {
|
||||
this.isFallbackMarker = true
|
||||
return
|
||||
}
|
||||
if (
|
||||
!AppBskyFeedPost.isRecord(post.record) ||
|
||||
!bsky.validate(post.record, AppBskyFeedPost.validateRecord)
|
||||
) {
|
||||
if (!bsky.matches(app.bsky.feed.post, post.record)) {
|
||||
return
|
||||
}
|
||||
const parent = reply?.parent
|
||||
const isParentBlocked = AppBskyFeedDefs.isBlockedPost(parent)
|
||||
const isParentNotFound = AppBskyFeedDefs.isNotFoundPost(parent)
|
||||
let parentAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
if (AppBskyFeedDefs.isPostView(parent)) {
|
||||
const isParentBlocked = bsky.isType(app.bsky.feed.defs.blockedPost, parent)
|
||||
const isParentNotFound = bsky.isType(
|
||||
app.bsky.feed.defs.notFoundPost,
|
||||
parent,
|
||||
)
|
||||
let parentAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
if (bsky.isType(app.bsky.feed.defs.postView, parent)) {
|
||||
parentAuthor = parent.author
|
||||
}
|
||||
this.items.push({
|
||||
@@ -100,18 +93,17 @@ export class FeedViewPostsSlice {
|
||||
return
|
||||
}
|
||||
if (
|
||||
!AppBskyFeedDefs.isPostView(parent) ||
|
||||
!AppBskyFeedPost.isRecord(parent.record) ||
|
||||
!bsky.validate(parent.record, AppBskyFeedPost.validateRecord)
|
||||
!bsky.isType(app.bsky.feed.defs.postView, parent) ||
|
||||
!bsky.matches(app.bsky.feed.post, parent.record)
|
||||
) {
|
||||
this.isOrphan = true
|
||||
return
|
||||
}
|
||||
const root = reply.root
|
||||
const rootIsView =
|
||||
AppBskyFeedDefs.isPostView(root) ||
|
||||
AppBskyFeedDefs.isBlockedPost(root) ||
|
||||
AppBskyFeedDefs.isNotFoundPost(root)
|
||||
bsky.isType(app.bsky.feed.defs.postView, root) ||
|
||||
bsky.isType(app.bsky.feed.defs.blockedPost, root) ||
|
||||
bsky.isType(app.bsky.feed.defs.notFoundPost, root)
|
||||
/*
|
||||
* If the parent is also the root, we just so happen to have the data we
|
||||
* need to compute if the parent's parent (grandparent) is blocked. This
|
||||
@@ -124,10 +116,10 @@ export class FeedViewPostsSlice {
|
||||
: undefined
|
||||
const grandparentAuthor = reply.grandparentAuthor
|
||||
const isGrandparentBlocked = Boolean(
|
||||
grandparent && AppBskyFeedDefs.isBlockedPost(grandparent),
|
||||
grandparent && bsky.isType(app.bsky.feed.defs.blockedPost, grandparent),
|
||||
)
|
||||
const isGrandparentNotFound = Boolean(
|
||||
grandparent && AppBskyFeedDefs.isNotFoundPost(grandparent),
|
||||
grandparent && bsky.isType(app.bsky.feed.defs.notFoundPost, grandparent),
|
||||
)
|
||||
this.items.unshift({
|
||||
post: parent,
|
||||
@@ -142,9 +134,8 @@ export class FeedViewPostsSlice {
|
||||
// de-deduping
|
||||
}
|
||||
if (
|
||||
!AppBskyFeedDefs.isPostView(root) ||
|
||||
!AppBskyFeedPost.isRecord(root.record) ||
|
||||
!bsky.validate(root.record, AppBskyFeedPost.validateRecord)
|
||||
!bsky.isType(app.bsky.feed.defs.postView, root) ||
|
||||
!bsky.matches(app.bsky.feed.post, root.record)
|
||||
) {
|
||||
this.isOrphan = true
|
||||
return
|
||||
@@ -167,14 +158,14 @@ export class FeedViewPostsSlice {
|
||||
get isQuotePost() {
|
||||
const embed = this._feedPost.post.embed
|
||||
return (
|
||||
AppBskyEmbedRecord.isView(embed) ||
|
||||
AppBskyEmbedRecordWithMedia.isView(embed)
|
||||
bsky.isType(app.bsky.embed.record.view, embed) ||
|
||||
bsky.isType(app.bsky.embed.recordWithMedia.view, embed)
|
||||
)
|
||||
}
|
||||
|
||||
get isReply() {
|
||||
return (
|
||||
AppBskyFeedPost.isRecord(this._feedPost.post.record) &&
|
||||
bsky.isType(app.bsky.feed.post, this._feedPost.post.record) &&
|
||||
!!this._feedPost.post.record.reply
|
||||
)
|
||||
}
|
||||
@@ -195,7 +186,7 @@ export class FeedViewPostsSlice {
|
||||
|
||||
get isRepost() {
|
||||
const reason = this._feedPost.reason
|
||||
return AppBskyFeedDefs.isReasonRepost(reason)
|
||||
return bsky.isType(app.bsky.feed.defs.reasonRepost, reason)
|
||||
}
|
||||
|
||||
get likeCount() {
|
||||
@@ -208,18 +199,18 @@ export class FeedViewPostsSlice {
|
||||
|
||||
getAuthors(): AuthorContext {
|
||||
const feedPost = this._feedPost
|
||||
let author: AppBskyActorDefs.ProfileViewBasic = feedPost.post.author
|
||||
let parentAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
let grandparentAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
let rootAuthor: AppBskyActorDefs.ProfileViewBasic | undefined
|
||||
let author: app.bsky.actor.defs.ProfileViewBasic = feedPost.post.author
|
||||
let parentAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
let grandparentAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
let rootAuthor: app.bsky.actor.defs.ProfileViewBasic | undefined
|
||||
if (feedPost.reply) {
|
||||
if (AppBskyFeedDefs.isPostView(feedPost.reply.parent)) {
|
||||
if (bsky.isType(app.bsky.feed.defs.postView, feedPost.reply.parent)) {
|
||||
parentAuthor = feedPost.reply.parent.author
|
||||
}
|
||||
if (feedPost.reply.grandparentAuthor) {
|
||||
grandparentAuthor = feedPost.reply.grandparentAuthor
|
||||
}
|
||||
if (AppBskyFeedDefs.isPostView(feedPost.reply.root)) {
|
||||
if (bsky.isType(app.bsky.feed.defs.postView, feedPost.reply.root)) {
|
||||
rootAuthor = feedPost.reply.root.author
|
||||
}
|
||||
}
|
||||
@@ -514,7 +505,7 @@ function shouldDisplayReplyInFollowing(
|
||||
}
|
||||
|
||||
function isSelfOrFollowing(
|
||||
profile: AppBskyActorDefs.ProfileViewBasic,
|
||||
profile: app.bsky.actor.defs.ProfileViewBasic,
|
||||
userDid: string,
|
||||
) {
|
||||
return Boolean(profile.did === userDid || profile.viewer?.following)
|
||||
|
||||
Reference in New Issue
Block a user