feat(premiere-uxp): introduce Adobe Premiere Pro UXP plugin for Shumai (#407)

* feat(premiere-uxp): use native Bun bundler and build script instead of Vite

* feat(premiere-uxp): switch FileListView to use Search API consistent with WebUI

* feat(premiere-uxp): add on-demand jpeg preview conversion for uxp compatibility

* feat(premiere-uxp): integrate spectrum web components (swc)

* fix(premiere-uxp): align swc packages with 0.37.0 and fix auth layout

* feat(premiere-uxp): use horizontal 2-column card view for projects and files

* style(premiere-uxp): enlarge file preview by 20% and add row padding

* fix(premiere-uxp): prevent card squishing and overflow with large item counts

* fix(premiere-uxp): change host in manifest to single object

* docs(premiere-uxp): add AGENTS.md with SWC preferences and UXP layout rules

* feat(premiere-uxp): integrate spectrum web components across plugin views

* fix(premiere-uxp): remove breadcrumb icons and use slash separator

* feat(premiere-uxp): add collapsible folder and file sections with infinite scroll

* feat(premiere-uxp): update file card layout with right column info and clean preview

* fix(premiere-uxp): use raw text for file card details and fix black icons

* style(premiere-uxp): use contain object-fit and black background for file card preview

* fix(premiere-uxp): refine header logo, sticky title bars, circular badges, and controls

* fix(premiere-uxp): replace stroke icons with spectrum workflow icons

* fix(premiere-uxp): switch icon buttons to swc sp-button with icon-only and slot=icon

* fix(premiere-uxp): vertically center endpoint text in header

* feat(premiere-uxp): add asset and proxy import support into Premiere Pro

- Implement context menu on file cards with left-click, right-click, and more action button triggers
- Support raw file import for non-video assets and video assets
- Support video proxy submenu listing ready transcode resolutions
- Add UXP native file picker save dialog and binary download orchestration
- Call Premiere Pro project.importFiles API to import downloaded assets into active project
- Add non-blocking toast notification banner for progress and status reporting
- Add unit tests for premiere host service and import orchestration

* fix(premiere-uxp): anchor import menu directly to file card using sp-action-menu

- Replace custom fixed-position ContextMenu with native SWC sp-action-menu
- Anchor menu directly to the triggered file card rather than the top-left window corner
- Support programmatic opening on file card click/contextmenu via imperative handle
- Support video submenu with Original and ready proxy options inside sp-action-menu
- Lazy load video proxies on menu open or hover
- Clean up obsolete fixed-position styles and unused backdrop overlays

* fix(premiere-uxp): align SWC packages to 0.37.0 and guard custom element registry

- Downgrade action-menu and menu SWC packages to 0.37.0 to match the rest of the workspace
- Eliminate duplicate icons-ui and sp-icon-chevron100 customElements.define calls
- Add polyfill guard to customElements.define to prevent duplicate registration errors during UXP reload

* fix(premiere-uxp): polyfill window.matchMedia for Adobe UXP

- Add window.matchMedia polyfill in polyfills.ts
- Satisfies SWC MatchMediaController used by ActionMenu and PickerBase in UXP
- Prevents TypeError when opening files page

* feat(premiere-uxp): replace context menu with card download action and video import dialog

* fix(premiere-uxp): resolve download url before save, pass null targetBin, and center download icon

* fix(premiere-uxp): resolve raw download url via download-url endpoint with fallback

* feat(premiere-uxp): use native folder picker and auto-increment conflict suffixes

* feat(premiere-uxp): add sequence linking, comment-marker sync, and navigation tabs

- Add sequence-to-asset linking with persistent project metadata storage

- Support one-way comment-to-marker timeline synchronization

- Add two-tab navigation (Sequences and Browse) using Spectrum buttons

- Add LinkSequenceDialog, SequencesView, and autoSyncService background engine

- Enforce Spectrum Workflow Icons and UXP layout rules

* feat(premiere-uxp): refine UI layouts, card interactions, and search box activation

* fix(premiere-uxp): set compact fixed width for file list search box

* fix(premiere-uxp): ensure search box click activation across full width in UXP

* fix(premiere-uxp): revert search box hacks and restore simple default sp-search layout

* feat(premiere-uxp): sync non-timestamped comments as markers at time 0

* feat(premiere-uxp): change link icon to unlink when asset is linked in file card

* fix(premiere-uxp): sync linked sequences between host project and browse view

* feat(premiere-uxp): remove synced markers on sequence unlink matching Frame.io

* fix(premiere-uxp): ensure reliable marker GUID capture, normalization, and fallback on unlink

* fix(premiere-uxp): use official Shumai logo for plugin manifest icons

* fix(premiere-uxp): use official PNG icons for manifest and plugin entrypoints

* refactor(premiere-uxp): use single 114x114 icon for plugin and panel

* feat(premiere-uxp): show file version in file list page file card

* build(premiere-uxp): check in built ccx package and update packaging configuration

* fix(premiere-uxp): address code review findings for media conversion, marker sync, and link scoping

- Reset hasJpegCover on project cover update and hasJpegPreview on asset media transcode
- Only advance synced comment metadata after confirmed marker transaction
- Normalize GUID keys and lookups in AutoSyncService map
- Restrict cached sequence link lookups to project-specific keys and prevent cross-project leakage on empty sequences
- Update built CCX distribution package
This commit is contained in:
Yiling-J
2026-09-17 11:51:03 +08:00
committed by GitHub
parent a6b7ac4383
commit 1796de8eda
78 changed files with 11366 additions and 37 deletions
+150
View File
@@ -9,6 +9,8 @@ import { uploadService } from '@shumai/core/src/upload/upload'
import { metadataService } from '@shumai/core/src/metadata/metadata'
import { AssetService } from './asset'
import { ensureJpegInStorage } from '@shumai/core/src/s3/preview-converter'
vi.mock('@shumai/core/src/s3/s3', () => ({
s3Service: {
presign: vi.fn().mockResolvedValue('http://mock-s3-url'),
@@ -19,6 +21,14 @@ vi.mock('@shumai/core/src/s3/s3', () => ({
},
}))
vi.mock('@shumai/core/src/s3/preview-converter', async (importOriginal) => {
const actual = await importOriginal<typeof import('@shumai/core/src/s3/preview-converter')>()
return {
...actual,
ensureJpegInStorage: vi.fn().mockResolvedValue(undefined),
}
})
describe('AssetService', () => {
setupTestDbHooks()
@@ -1918,6 +1928,146 @@ describe('AssetService', () => {
expect(info.preview).toBeDefined()
expect(info.preview?.duration).toBeUndefined()
})
it('converts webp thumbnail to jpeg on demand when hasJpegPreview is false', async () => {
vi.mocked(ensureJpegInStorage).mockClear()
const { project, user } = await setupBasicAssets()
const image = await prisma.asset.create({
data: {
name: 'photo.webp',
type: AssetType.file,
projectId: project.id,
creatorId: user.id,
sizeByte: 2000,
mediaType: 'image/webp',
status: 'processed',
hasJpegPreview: false,
media: {
proxyType: 'image',
thumbnail: { key: 'shumai/files/1/thumb.webp' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
},
})
const preview = await assetService.toPreviewInfo(image, 'jpeg')
expect(preview).toBeDefined()
expect(ensureJpegInStorage).toHaveBeenCalledWith(
expect.any(String),
'shumai/files/1/thumb.webp',
'shumai/files/1/thumb.jpeg',
)
expect(s3Service.presign).toHaveBeenCalledWith(
expect.any(String),
'shumai/files/1/thumb.jpeg',
'GET',
)
const updated = await prisma.asset.findUnique({ where: { id: image.id } })
expect(updated?.hasJpegPreview).toBe(true)
})
it('skips conversion when hasJpegPreview is already true', async () => {
vi.mocked(ensureJpegInStorage).mockClear()
const { project, user } = await setupBasicAssets()
const image = await prisma.asset.create({
data: {
name: 'photo-converted.webp',
type: AssetType.file,
projectId: project.id,
creatorId: user.id,
sizeByte: 2000,
mediaType: 'image/webp',
status: 'processed',
hasJpegPreview: true,
media: {
proxyType: 'image',
thumbnail: { key: 'shumai/files/2/thumb.webp' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
},
})
const preview = await assetService.toPreviewInfo(image, 'jpeg')
expect(preview).toBeDefined()
expect(ensureJpegInStorage).not.toHaveBeenCalled()
expect(s3Service.presign).toHaveBeenCalledWith(
expect.any(String),
'shumai/files/2/thumb.jpeg',
'GET',
)
})
it('gracefully falls back to webp when conversion fails', async () => {
vi.mocked(ensureJpegInStorage).mockRejectedValueOnce(new Error('Sharp conversion failed'))
const { project, user } = await setupBasicAssets()
const image = await prisma.asset.create({
data: {
name: 'failing.webp',
type: AssetType.file,
projectId: project.id,
creatorId: user.id,
sizeByte: 2000,
mediaType: 'image/webp',
status: 'processed',
hasJpegPreview: false,
media: {
proxyType: 'image',
thumbnail: { key: 'shumai/files/3/thumb.webp' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
},
})
const preview = await assetService.toPreviewInfo(image, 'jpeg')
expect(preview).toBeDefined()
expect(s3Service.presign).toHaveBeenCalledWith(
expect.any(String),
'shumai/files/3/thumb.webp',
'GET',
)
const updated = await prisma.asset.findUnique({ where: { id: image.id } })
expect(updated?.hasJpegPreview).toBe(false)
})
it('listAssetsByIds forwards previewFormat and converts preview', async () => {
vi.mocked(ensureJpegInStorage).mockClear()
const { project, user } = await setupBasicAssets()
const image = await prisma.asset.create({
data: {
name: 'list-photo.webp',
type: AssetType.file,
projectId: project.id,
creatorId: user.id,
sizeByte: 2000,
mediaType: 'image/webp',
status: 'processed',
hasJpegPreview: false,
media: {
proxyType: 'image',
thumbnail: { key: 'shumai/files/4/thumb.webp' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any,
},
})
const list = await assetService.listAssetsByIds([image.id], 'jpeg')
expect(list).toHaveLength(1)
expect(ensureJpegInStorage).toHaveBeenCalledWith(
expect.any(String),
'shumai/files/4/thumb.webp',
'shumai/files/4/thumb.jpeg',
)
})
})
describe('Symlinks', () => {
+62 -18
View File
@@ -19,6 +19,7 @@ import {
AssetUserInfo,
ListRecentsRequest,
CommentExportFormat,
PreviewFormat,
} from '@shumai/dtos'
import {
exportCommentsToFormat,
@@ -32,6 +33,11 @@ import { HTTPException } from 'hono/http-exception'
import { logger } from '@shumai/core/src/logger'
import { PaginatedData, paginateQuery, PaginationParams } from '@shumai/core/src/pagination'
import { s3Service } from '@shumai/core/src/s3/s3'
import {
ensureJpegInStorage,
getJpegKeyForWebp,
isWebpKey,
} from '@shumai/core/src/s3/preview-converter'
import { dedupeSymlinksToTarget } from './symlink'
import { watermarkService } from '@shumai/core/src/watermark/watermark'
import { generateKeyBetween } from 'jittered-fractional-indexing'
@@ -133,7 +139,7 @@ export class AssetService {
return [folderId, ...ids]
}
async listAssetsByIds(ids: string[]): Promise<AssetInfo[]> {
async listAssetsByIds(ids: string[], previewFormat?: PreviewFormat): Promise<AssetInfo[]> {
if (ids.length === 0) return []
const assets = await this.prismaClient.asset.findMany({
@@ -145,7 +151,7 @@ export class AssetService {
const orderedAssets = ids
.map((id) => assetMap.get(id))
.filter((a): a is AssetWithIncludes => !!a)
const orderedInfos = await this.toAssetInfos(orderedAssets)
const orderedInfos = await this.toAssetInfos(orderedAssets, previewFormat)
return orderedInfos
}
@@ -2036,7 +2042,10 @@ export class AssetService {
return exportCommentsToFormat(metadata, comments, format, options)
}
async toAssetInfos(assets: AssetWithIncludes[]): Promise<AssetInfo[]> {
async toAssetInfos(
assets: AssetWithIncludes[],
previewFormat?: PreviewFormat,
): Promise<AssetInfo[]> {
const stackIds = new Set<string>()
for (const a of assets) {
@@ -2150,7 +2159,7 @@ export class AssetService {
id: stackId,
versions: await Promise.all(
versions.map(async (v, i) => {
const preview = await this.toPreviewInfo(v as Asset)
const preview = await this.toPreviewInfo(v as Asset, previewFormat)
return {
version: versions.length - i,
current: i === 0,
@@ -2208,12 +2217,12 @@ export class AssetService {
latestChildren.push({
type: mediaType,
preview: await this.toPreviewInfo(previewAsset),
preview: await this.toPreviewInfo(previewAsset, previewFormat),
})
}
}
const preview = await this.toPreviewInfo(latestVersion as Asset)
const preview = await this.toPreviewInfo(latestVersion as Asset, previewFormat)
const creator = latestVersion.creator
? {
@@ -2374,6 +2383,7 @@ export class AssetService {
const assets = await this.prismaClient.asset.findMany({
where: { id: { in: assetIds }, isDeleted: false },
select: {
id: true,
projectId: true,
type: true,
target: { select: { projectId: true } },
@@ -2386,6 +2396,16 @@ export class AssetService {
if (asset.type === 'symlink' && asset.target?.projectId) {
projId = asset.target.projectId
}
if (!projId) {
try {
const ctx = await this.getAssetContext(asset.id)
if (ctx.projectId) {
projId = ctx.projectId
}
} catch {
// ignore if no team/project context
}
}
if (projId) {
projectIds.add(projId)
}
@@ -2604,24 +2624,48 @@ export class AssetService {
)
}
async toPreviewInfo(asset: Asset | AssetWithIncludes): Promise<PreviewInfo | null> {
async toPreviewInfo(
asset: Asset | AssetWithIncludes,
previewFormat?: PreviewFormat,
): Promise<PreviewInfo | null> {
if (!asset.media) return null
const proxyType = (asset.media?.proxyType || null) as 'image' | 'video' | 'audio' | 'pdf' | null
let thumbnailUrl = undefined
let rawThumbKey: string | undefined
if (proxyType === 'image' && asset.media.thumbnail?.key) {
thumbnailUrl = await s3Service.presign(
process.env.S3_BUCKET || 'shumai',
asset.media.thumbnail.key,
'GET',
)
rawThumbKey = asset.media.thumbnail.key
} else if (asset.media.poster?.key) {
thumbnailUrl = await s3Service.presign(
process.env.S3_BUCKET || 'shumai',
asset.media.poster.key,
'GET',
)
rawThumbKey = asset.media.poster.key
}
let thumbnailUrl = undefined
if (rawThumbKey) {
const bucket = process.env.S3_BUCKET || 'shumai'
let finalKey = rawThumbKey
if (previewFormat === 'jpeg' && isWebpKey(rawThumbKey)) {
const targetJpegKey = getJpegKeyForWebp(rawThumbKey)
if (asset.hasJpegPreview) {
finalKey = targetJpegKey
} else {
try {
await ensureJpegInStorage(bucket, rawThumbKey, targetJpegKey)
await this.prismaClient.asset.update({
where: { id: asset.id },
data: { hasJpegPreview: true },
})
asset.hasJpegPreview = true
finalKey = targetJpegKey
} catch (err) {
logger.warn(
{ err, assetId: asset.id, rawThumbKey },
'Failed to ensure JPEG preview for asset, falling back to WebP',
)
finalKey = rawThumbKey
}
}
}
thumbnailUrl = await s3Service.presign(bucket, finalKey, 'GET')
}
let spriteUrl = undefined