diff --git a/research/MainApp1.6.1.md b/research/MainApp1.6.1.md
new file mode 100644
index 0000000..a52f55d
--- /dev/null
+++ b/research/MainApp1.6.1.md
@@ -0,0 +1,21 @@
+# 主 APP 1.6.1(40)改造
+
+本轮范围:仅主 APP 产品介绍、插件自动检查/提交注册、成功退出。不加入登录、授权、加密、自动更新或后端接口;以本轮用户说明为准,不执行旧交接中的下一阶段账号计划。
+
+## 界面合同
+
+延续现有 Objective-C/AppKit、Nib 连线和手动内存管理。使用 standard 档原生交互;静态深色渐变、圆角彩色卡片与胶囊按钮呼应用户参考图,不引入常驻动画、模糊或新的渲染依赖。
+
+比较了单列介绍、左右双栏状态+功能、状态+使用指引+双列特色卡三种结构,选择第三种:优先显示注册与宿主入口,接着完整调色、LUT、胶片、蒙版叠层,最后发布地址 https://dayu.media。窗口默认920×790,最小760×620,纵向滚动;介绍可通过按钮/⌘I保留,菜单⌘R重试、⌘W关闭、⌘Q退出。保留可访问的原生按钮、文本、焦点环和状态播报;表面不透明,增强对比度加粗边框。
+
+状态唯一归属 AppDelegate:checking → registering → ready/failed。所有 PluginKit 操作在后台队列;主线程负责状态和窗口。重复检查期间禁用重入。每次打开都提交内嵌组件注册;以回读 Bundle ID、FxPlug登记协议1.1和当前插件完整路径为成功条件,不能仅凭命令退出码判定。成功默认5秒后退出;查看介绍取消本次倒计时;失败保留窗口和重试。关闭窗口退出,无后台常驻。
+
+运行诊断仅记录本机插件登记和版本,写入应用 Application Support/com.dayu.color/Registration.json;不联网、不含凭据。--show-introduction 是保留介绍的启动方式,仍运行真实注册流程。
+
+## 参考来源
+
+用户指定仓库 https://dayu.media/git/dayu/fcpx-qwen3-asr.git ,只读参考提交113069c74aff935db2082b5bcd8e1aa47fe1fbf2的ContentView.swift和LicenseViewModel.swift。借鉴深色渐变、卡片配色和操作层级;未复用会员、识别计费、账号或扩展业务代码。
+
+## 保留范围
+
+主 Bundle ID com.dayu.color,服务com.dayu.color.XPC,唯一正式路径/Library/Plug-Ins/FxPlug/大鱼调色.app。主 APP/内嵌服务版本同步1.6.1(40)。调色/渲染、Uniform、参数、预设、Metal、模板无改动。现有自检及正式安装、宿主、打包/Release证据在verification记录;本文件不预先宣称未执行的验证通过。
diff --git a/大鱼调色/Plugin/Info.plist b/大鱼调色/Plugin/Info.plist
index 6fb5a4c..4e2c4ea 100644
--- a/大鱼调色/Plugin/Info.plist
+++ b/大鱼调色/Plugin/Info.plist
@@ -17,9 +17,9 @@
CFBundlePackageType
XPC!
CFBundleShortVersionString
- 1.6.0
+ 1.6.1
CFBundleVersion
- 39
+ 40
NSHumanReadableCopyright
PlugInKit
@@ -71,7 +71,7 @@
uuid
1C17B73B-F229-4C09-A434-EAF6DFF5F22A
version
- 1.6.0
+ 1.6.1
className
diff --git a/大鱼调色/Wrapper Application/AppDelegate.m b/大鱼调色/Wrapper Application/AppDelegate.m
index 7e69483..d80083e 100644
--- a/大鱼调色/Wrapper Application/AppDelegate.m
+++ b/大鱼调色/Wrapper Application/AppDelegate.m
@@ -1,15 +1,324 @@
#import "AppDelegate.h"
+
+static NSString *const DYPluginID = @"com.dayu.color.XPC";
+static NSString *const DYReleaseAddress = @"https://dayu.media";
+static NSColor *DYColor(CGFloat r, CGFloat g, CGFloat b) { return [NSColor colorWithSRGBRed:r green:g blue:b alpha:1]; }
+static NSColor *DYBlue(void) { return DYColor(.36,.65,1); }
+static NSColor *DYGreen(void) { return DYColor(.26,.86,.53); }
+static NSColor *DYSecondary(void) { return DYColor(.70,.74,.81); }
+
+// Static opaque surfaces preserve the reference palette without expensive blur or motion.
+@interface DYSurface : NSView
+@property(retain) NSColor *tint;
+@property BOOL backdrop;
+@end
+@implementation DYSurface
+- (BOOL)isFlipped { return YES; }
+- (void)drawRect:(NSRect)dirty {
+ BOOL contrast = NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast;
+ NSBezierPath *shape = [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(self.bounds,1,1) xRadius:self.backdrop ? 0 : 22 yRadius:self.backdrop ? 0 : 22];
+ NSColor *base = DYColor(.105,.115,.14);
+ NSColor *start = self.backdrop ? DYColor(.105,.14,.20) : [base blendedColorWithFraction:.17 ofColor:self.tint];
+ NSColor *end = self.backdrop ? DYColor(.105,.115,.115) : base;
+ NSGradient *gradient = [[[NSGradient alloc] initWithStartingColor:start endingColor:end] autorelease];
+ [gradient drawInBezierPath:shape angle:35];
+ if (!self.backdrop) {
+ [[self.tint blendedColorWithFraction:contrast ? .15 : .62 ofColor:base] setStroke];
+ shape.lineWidth = contrast ? 2 : 1; [shape stroke];
+ }
+}
+- (void)dealloc { [_tint release]; [super dealloc]; }
+@end
+
+@interface DYActionButton : NSButton
+@property(retain) NSColor *tint;
+@property BOOL prominent;
+@end
+@implementation DYActionButton
+- (void)drawRect:(NSRect)dirty {
+ NSRect rect = NSInsetRect(self.bounds,2,2);
+ NSBezierPath *shape = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:rect.size.height/2 yRadius:rect.size.height/2];
+ NSColor *base = self.prominent ? self.tint : [DYColor(.10,.12,.16) blendedColorWithFraction:.18 ofColor:self.tint];
+ if (self.highlighted) base = [base blendedColorWithFraction:.2 ofColor:NSColor.blackColor];
+ [base setFill]; [shape fill];
+ [[self.tint blendedColorWithFraction:.35 ofColor:NSColor.whiteColor] setStroke];
+ shape.lineWidth = NSWorkspace.sharedWorkspace.accessibilityDisplayShouldIncreaseContrast ? 2 : 1; [shape stroke];
+ NSColor *text = self.enabled ? (self.prominent ? NSColor.whiteColor : self.tint) : DYSecondary();
+ NSDictionary *attrs = @{NSFontAttributeName:[NSFont systemFontOfSize:13 weight:NSFontWeightSemibold],NSForegroundColorAttributeName:text};
+ NSSize size = [self.title sizeWithAttributes:attrs];
+ [self.title drawAtPoint:NSMakePoint((NSWidth(self.bounds)-size.width)/2,(NSHeight(self.bounds)-size.height)/2) withAttributes:attrs];
+}
+- (void)drawFocusRingMask { [[NSBezierPath bezierPathWithRoundedRect:NSInsetRect(self.bounds,2,2) xRadius:20 yRadius:20] fill]; }
+- (NSRect)focusRingMaskBounds { return self.bounds; }
+- (void)dealloc { [_tint release]; [super dealloc]; }
+@end
+
+static NSTextField *DYLabel(NSString *text, CGFloat size, NSFontWeight weight, NSColor *color) {
+ NSTextField *label = [NSTextField wrappingLabelWithString:text];
+ label.font = [NSFont systemFontOfSize:size weight:weight]; label.textColor = color;
+ label.translatesAutoresizingMaskIntoConstraints = NO;
+ [label setContentCompressionResistancePriority:NSLayoutPriorityRequired forOrientation:NSLayoutConstraintOrientationVertical];
+ return label;
+}
+static NSStackView *DYStack(NSArray *views, NSUserInterfaceLayoutOrientation orientation, CGFloat spacing) {
+ NSStackView *stack = [NSStackView stackViewWithViews:views];
+ stack.orientation = orientation; stack.spacing = spacing;
+ stack.alignment = orientation == NSUserInterfaceLayoutOrientationVertical ? NSLayoutAttributeLeading : NSLayoutAttributeTop;
+ stack.translatesAutoresizingMaskIntoConstraints = NO;
+ if (orientation == NSUserInterfaceLayoutOrientationHorizontal) stack.distribution = NSStackViewDistributionFillEqually;
+ return stack;
+}
+static void DYPin(NSView *child, NSView *parent, CGFloat inset) {
+ child.translatesAutoresizingMaskIntoConstraints = NO; [parent addSubview:child];
+ [NSLayoutConstraint activateConstraints:@[
+ [child.leadingAnchor constraintEqualToAnchor:parent.leadingAnchor constant:inset],
+ [child.trailingAnchor constraintEqualToAnchor:parent.trailingAnchor constant:-inset],
+ [child.topAnchor constraintEqualToAnchor:parent.topAnchor constant:inset],
+ [child.bottomAnchor constraintEqualToAnchor:parent.bottomAnchor constant:-inset]]];
+}
+static DYActionButton *DYButton(NSString *title, NSColor *tint, BOOL prominent, id target, SEL action) {
+ DYActionButton *button = [DYActionButton buttonWithTitle:title target:target action:action];
+ button.tint = tint; button.prominent = prominent; button.bordered = NO;
+ button.translatesAutoresizingMaskIntoConstraints = NO;
+ [button.heightAnchor constraintEqualToConstant:42].active = YES;
+ [button.widthAnchor constraintGreaterThanOrEqualToConstant:124].active = YES;
+ return button;
+}
+static DYSurface *DYCard(NSColor *tint, NSStackView *content) {
+ DYSurface *card = [[[DYSurface alloc] initWithFrame:NSZeroRect] autorelease];
+ card.tint = tint; card.translatesAutoresizingMaskIntoConstraints = NO; DYPin(content,card,22);
+ for (NSView *view in content.arrangedSubviews) [view.widthAnchor constraintEqualToAnchor:content.widthAnchor].active = YES;
+ return card;
+}
+static NSTextField *DYHeading(NSString *symbol, NSString *text, NSColor *color) {
+ NSTextField *label = DYLabel(text,15,NSFontWeightSemibold,color);
+ NSImage *image = [NSImage imageWithSystemSymbolName:symbol accessibilityDescription:nil];
+ if (image) {
+ NSTextAttachment *attachment = [[[NSTextAttachment alloc] init] autorelease];
+ attachment.image = image; attachment.bounds = NSMakeRect(0,-3,18,18);
+ NSMutableAttributedString *value = [[[NSMutableAttributedString alloc] initWithAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]] autorelease];
+ [value appendAttributedString:[[[NSAttributedString alloc] initWithString:[@" " stringByAppendingString:text]
+ attributes:@{NSFontAttributeName:label.font,NSForegroundColorAttributeName:color}] autorelease]];
+ label.attributedStringValue = value; label.accessibilityLabel = text;
+ }
+ return label;
+}
+
+typedef NS_ENUM(NSInteger,DYRegistrationState) { DYChecking, DYRegistering, DYReady, DYFailed };
@interface AppDelegate ()
@property(weak) IBOutlet NSWindow *window;
+@property(assign) NSTextField *statusTitle, *statusDetail, *exitDetail;
+@property(assign) DYActionButton *retryButton, *keepButton;
+@property(assign) NSProgressIndicator *progress;
+@property(assign) DYSurface *registrationCard;
+@property DYRegistrationState registrationState;
+@property BOOL keepOpen, terminating;
+@property NSInteger secondsRemaining;
+@property(retain) NSTimer *exitTimer;
+@property(retain) NSMutableDictionary *diagnostics;
@end
+
@implementation AppDelegate
-- (void)applicationDidFinishLaunching:(NSNotification*)n{
- self.window.title=@"大鱼调色";[self.window setContentSize:NSMakeSize(540,280)];[self.window center];
- NSView*v=[[[NSView alloc]initWithFrame:NSMakeRect(0,0,540,280)]autorelease];v.wantsLayer=YES;v.layer.backgroundColor=[NSColor colorWithSRGBRed:.025 green:.08 blue:.13 alpha:1].CGColor;self.window.contentView=v;
- NSTextField*title=[NSTextField labelWithString:@"大鱼调色"];title.font=[NSFont boldSystemFontOfSize:28];title.textColor=[NSColor colorWithSRGBRed:.3 green:.75 blue:1 alpha:1];title.frame=NSMakeRect(32,212,460,42);[v addSubview:title];
- NSTextField*body=[NSTextField wrappingLabelWithString:@"已安装原生 FxPlug 调色效果。\n\n在 Final Cut Pro 的「效果 → 大鱼调色」中应用,或在 Motion 的滤镜中选择「大鱼调色」。\n\n输入转换、光影、曲线、HSL、色轮与 LUT 均在宿主检查器中编辑。"];body.font=[NSFont systemFontOfSize:14];body.textColor=[NSColor colorWithWhite:.86 alpha:1];body.frame=NSMakeRect(34,65,470,140);[v addSubview:body];
- NSButton*b=[NSButton buttonWithTitle:@"打开 Final Cut Pro" target:self action:@selector(openHost:)];b.frame=NSMakeRect(30,20,170,32);[v addSubview:b];[self.window makeKeyAndOrderFront:nil];
+- (void)applicationDidFinishLaunching:(NSNotification *)notification {
+ self.keepOpen = [NSProcessInfo.processInfo.arguments containsObject:@"--show-introduction"];
+ self.window.title = @"大鱼调色";
+ self.window.appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
+ self.window.titlebarAppearsTransparent = YES; self.window.backgroundColor = DYColor(.105,.14,.20);
+ self.window.contentMinSize = NSMakeSize(760,620); [self.window setContentSize:NSMakeSize(920,790)]; [self.window center];
+ [self buildInterface]; [self buildMenu];
+ [NSWorkspace.sharedWorkspace.notificationCenter addObserver:self selector:@selector(accessibilityChanged:)
+ name:NSWorkspaceAccessibilityDisplayOptionsDidChangeNotification object:nil];
+ [self.window makeKeyAndOrderFront:nil]; [self checkRegistration:nil];
}
-- (void)openHost:(id)sender{NSURL*u=[NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:@"com.apple.FinalCut"];if(u)[NSWorkspace.sharedWorkspace openApplicationAtURL:u configuration:NSWorkspaceOpenConfiguration.configuration completionHandler:nil];}
-- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication*)app{return YES;}
+- (void)buildMenu {
+ NSMenu *menu = [[[NSMenu alloc] initWithTitle:@"大鱼调色"] autorelease];
+ NSMenuItem *root = [[[NSMenuItem alloc] initWithTitle:@"大鱼调色" action:NULL keyEquivalent:@""] autorelease]; [menu addItem:root];
+ NSMenu *app = [[[NSMenu alloc] initWithTitle:@"大鱼调色"] autorelease]; root.submenu = app;
+ for (NSArray *entry in @[@[@"关于大鱼调色",NSStringFromSelector(@selector(orderFrontStandardAboutPanel:)),@""],
+ @[@"查看功能介绍",NSStringFromSelector(@selector(keepIntroduction:)),@"i"],
+ @[@"重新检查插件",NSStringFromSelector(@selector(checkRegistration:)),@"r"],
+ @[@"访问发布地址",NSStringFromSelector(@selector(openWebsite:)),@""],
+ @[@"关闭窗口",NSStringFromSelector(@selector(closeWindow:)),@"w"],
+ @[@"退出大鱼调色",NSStringFromSelector(@selector(terminate:)),@"q"]]) {
+ NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:entry[0] action:NSSelectorFromString(entry[1]) keyEquivalent:entry[2]] autorelease];
+ item.target = [entry[0] isEqualToString:@"退出大鱼调色"] || [entry[0] isEqualToString:@"关于大鱼调色"] ? NSApp : self; [app addItem:item];
+ }
+ NSApp.mainMenu = menu;
+}
+- (void)buildInterface {
+ DYSurface *backdrop = [[[DYSurface alloc] initWithFrame:NSZeroRect] autorelease]; backdrop.backdrop = YES; self.window.contentView = backdrop;
+ NSScrollView *scroll = [[[NSScrollView alloc] initWithFrame:NSZeroRect] autorelease];
+ scroll.drawsBackground = NO; scroll.hasVerticalScroller = YES; scroll.autohidesScrollers = YES; DYPin(scroll,backdrop,0);
+ DYSurface *document = [[[DYSurface alloc] initWithFrame:NSZeroRect] autorelease];
+ document.backdrop = YES; document.translatesAutoresizingMaskIntoConstraints = NO; scroll.documentView = document;
+ [NSLayoutConstraint activateConstraints:@[
+ [document.leadingAnchor constraintEqualToAnchor:scroll.contentView.leadingAnchor],
+ [document.topAnchor constraintEqualToAnchor:scroll.contentView.topAnchor],
+ [document.widthAnchor constraintEqualToAnchor:scroll.contentView.widthAnchor]]];
+ NSDictionary *info = NSBundle.mainBundle.infoDictionary;
+ NSArray *heroLabels = @[DYLabel(@"FINAL CUT PRO / MOTION",11,NSFontWeightSemibold,DYBlue()),
+ DYLabel(@"大鱼调色",42,NSFontWeightBold,NSColor.whiteColor),
+ DYLabel(@"从色彩还原到胶片质感,让每一次调色更从容。",15,NSFontWeightRegular,DYSecondary()),
+ DYLabel([NSString stringWithFormat:@"v%@ · 构建 %@ / 原生 FxPlug 4 · Apple Silicon",info[@"CFBundleShortVersionString"],info[@"CFBundleVersion"]],11,NSFontWeightMedium,DYSecondary())];
+ NSStackView *hero = DYStack(heroLabels,NSUserInterfaceLayoutOrientationVertical,8);
+ for (NSTextField *label in heroLabels) { label.alignment = NSTextAlignmentCenter; [label.widthAnchor constraintEqualToAnchor:hero.widthAnchor].active = YES; }
+ self.statusTitle = DYLabel(@"正在检查插件…",22,NSFontWeightSemibold,NSColor.whiteColor);
+ self.statusDetail = DYLabel(@"正在检查本机插件登记,随后自动提交注册。",13,NSFontWeightRegular,DYSecondary());
+ [self.statusDetail.heightAnchor constraintGreaterThanOrEqualToConstant:42].active = YES;
+ self.progress = [[[NSProgressIndicator alloc] initWithFrame:NSZeroRect] autorelease];
+ self.progress.style = NSProgressIndicatorStyleBar; self.progress.indeterminate = YES; self.progress.translatesAutoresizingMaskIntoConstraints = NO;
+ self.retryButton = DYButton(@"检查中…",DYBlue(),NO,self,@selector(checkRegistration:));
+ self.keepButton = DYButton(@"查看功能介绍",DYColor(.20,.46,.94),YES,self,@selector(keepIntroduction:));
+ NSStackView *registration = DYStack(@[DYHeading(@"puzzlepiece.extension",@"插件连接",DYBlue()),self.statusTitle,self.statusDetail,self.progress,
+ DYStack(@[self.retryButton,self.keepButton],NSUserInterfaceLayoutOrientationHorizontal,8)],NSUserInterfaceLayoutOrientationVertical,13);
+ self.registrationCard = DYCard(DYBlue(),registration);
+ NSStackView *host = DYStack(@[DYHeading(@"play.rectangle",@"在剪辑中开始创作",DYGreen()),
+ DYLabel(@"调色,留在时间线里。",22,NSFontWeightSemibold,NSColor.whiteColor),
+ DYLabel(@"Final Cut Pro:效果 → 大鱼调色\nMotion:滤镜 → 大鱼调色\n将效果应用到片段,在检查器中调整。",13,NSFontWeightRegular,DYSecondary()),
+ DYStack(@[DYButton(@"打开 Final Cut Pro",DYColor(.20,.46,.94),YES,self,@selector(openFinalCut:)),DYButton(@"打开 Motion",DYGreen(),NO,self,@selector(openMotion:))],NSUserInterfaceLayoutOrientationHorizontal,8)],NSUserInterfaceLayoutOrientationVertical,13);
+ DYSurface *hostCard = DYCard(DYGreen(),host);
+ NSStackView *top = DYStack(@[self.registrationCard,hostCard],NSUserInterfaceLayoutOrientationHorizontal,14);
+ [self.registrationCard.heightAnchor constraintEqualToAnchor:hostCard.heightAnchor].active = YES;
+ NSArray *features = @[
+ @[@"slider.horizontal.3",@"完整调色",@"精准还原,自由塑造",@"CST 色彩管理、光影与曲线\nHSL、色轮、蜘蛛盘与白平衡",DYBlue()],
+ @[@"square.grid.2x2",@"LUT 与风格",@"灵感,所见即所得",@"LUT 缩略图浏览与实时预览\n快速收藏,管理常用风格",DYColor(.67,.59,1)],
+ @[@"film",@"胶片质感",@"让画面更有温度",@"八种印片外观、颗粒与晕光\n辉光、暗角及通道混合器",DYColor(1,.67,.30)],
+ @[@"square.on.circle",@"局部与叠层",@"每个细节,都有层次",@"独立工具层、逐层蒙版\n画面控件与关键帧跟踪",DYGreen()]];
+ NSMutableArray *cards = [NSMutableArray array];
+ for (NSArray *feature in features) [cards addObject:DYCard(feature[4],DYStack(@[DYHeading(feature[0],feature[1],feature[4]),
+ DYLabel(feature[2],17,NSFontWeightSemibold,NSColor.whiteColor),DYLabel(feature[3],13,NSFontWeightRegular,DYSecondary())],NSUserInterfaceLayoutOrientationVertical,12))];
+ NSStackView *row1 = DYStack(@[cards[0],cards[1]],NSUserInterfaceLayoutOrientationHorizontal,14);
+ NSStackView *row2 = DYStack(@[cards[2],cards[3]],NSUserInterfaceLayoutOrientationHorizontal,14);
+ [((NSView *)cards[0]).heightAnchor constraintEqualToAnchor:((NSView *)cards[1]).heightAnchor].active = YES;
+ [((NSView *)cards[2]).heightAnchor constraintEqualToAnchor:((NSView *)cards[3]).heightAnchor].active = YES;
+ NSStackView *release = DYStack(@[DYHeading(@"globe",@"发布地址 https://dayu.media",NSColor.whiteColor),
+ DYLabel(@"版本发布、使用资讯与更多插件,尽在大鱼素材网。",13,NSFontWeightRegular,DYSecondary()),
+ DYButton(@"访问发布地址 ↗",DYBlue(),NO,self,@selector(openWebsite:))],NSUserInterfaceLayoutOrientationVertical,10);
+ self.exitDetail = DYLabel(@"注册成功后将自动退出,插件可继续在宿主中使用。",12,NSFontWeightRegular,DYSecondary()); self.exitDetail.alignment = NSTextAlignmentCenter;
+ NSStackView *content = DYStack(@[hero,top,DYHeading(@"sparkles",@"一套工具,完成你的色彩表达",NSColor.whiteColor),row1,row2,
+ DYCard(DYColor(.45,.50,.60),release),self.exitDetail],NSUserInterfaceLayoutOrientationVertical,18);
+ DYPin(content,document,30);
+ for (NSView *view in content.arrangedSubviews) [view.widthAnchor constraintEqualToAnchor:content.widthAnchor].active = YES;
+ [document.heightAnchor constraintGreaterThanOrEqualToAnchor:scroll.contentView.heightAnchor].active = YES;
+}
+
+// PluginKit runs on a worker queue. Arguments are never interpreted as shell commands.
+- (NSDictionary *)runPluginKit:(NSArray *)arguments {
+ NSTask *task = [[[NSTask alloc] init] autorelease]; task.executableURL = [NSURL fileURLWithPath:@"/usr/bin/pluginkit"]; task.arguments = arguments;
+ NSPipe *pipe = [NSPipe pipe]; task.standardOutput = pipe; task.standardError = pipe;
+ NSError *error = nil;
+ if (![task launchAndReturnError:&error]) return @{@"code":@(-1),@"output":error.localizedDescription ?: @"无法启动插件登记服务"};
+ NSDate *deadline = [NSDate dateWithTimeIntervalSinceNow:8];
+ while (task.running && deadline.timeIntervalSinceNow > 0) [NSThread sleepForTimeInterval:.05];
+ if (task.running) { [task terminate]; return @{@"code":@(-2),@"output":@"插件登记服务响应超时"}; }
+ NSData *data = [pipe.fileHandleForReading readDataToEndOfFile];
+ NSString *output = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease] ?: @"";
+ return @{@"code":@(task.terminationStatus),@"output":output};
+}
+- (BOOL)registry:(NSDictionary *)query containsPlugin:(NSString *)path {
+ if ([query[@"code"] intValue] != 0) return NO;
+ for (NSString *line in [query[@"output"] componentsSeparatedByCharactersInSet:NSCharacterSet.newlineCharacterSet]) {
+ NSArray *fields = [line componentsSeparatedByString:@"\t"]; if (fields.count < 4) continue;
+ NSString *identity = [fields[0] stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
+ NSString *registered = [[fields lastObject] stringByTrimmingCharactersInSet:NSCharacterSet.whitespaceCharacterSet];
+ // 1.1 is the registration protocol, not the APP version.
+ NSString *expected = [DYPluginID stringByAppendingString:@"(1.1)"];
+ if (([identity isEqualToString:expected] || [identity isEqualToString:[@"+ " stringByAppendingString:expected]]) &&
+ [registered.stringByResolvingSymlinksInPath isEqualToString:path.stringByResolvingSymlinksInPath]) return YES;
+ }
+ return NO;
+}
+- (void)checkRegistration:(id)sender {
+ if (self.diagnostics && (self.registrationState == DYChecking || self.registrationState == DYRegistering)) return;
+ [self.exitTimer invalidate]; self.exitTimer = nil; self.registrationState = DYChecking;
+ self.retryButton.enabled = NO; self.retryButton.title = @"检查中…";
+ self.statusTitle.stringValue = @"正在检查插件…"; self.statusDetail.stringValue = @"正在检查本机插件登记,随后自动提交注册。";
+ self.progress.indeterminate = YES; [self.progress startAnimation:nil];
+ NSString *path = [NSBundle.mainBundle.bundlePath stringByAppendingPathComponent:@"Contents/PlugIns/大鱼调色 XPC Service.pluginkit"];
+ self.diagnostics = [NSMutableDictionary dictionaryWithDictionary:@{
+ @"bundleID":NSBundle.mainBundle.bundleIdentifier,@"version":[NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"],
+ @"build":[NSBundle.mainBundle objectForInfoDictionaryKey:@"CFBundleVersion"],@"executable":NSBundle.mainBundle.executablePath,
+ @"pid":@(NSProcessInfo.processInfo.processIdentifier),@"plugin":path,@"status":@"checking"}];
+ dispatch_async(dispatch_get_global_queue(QOS_CLASS_USER_INITIATED,0), ^{
+ @autoreleasepool {
+ NSBundle *plugin = [NSBundle bundleWithPath:path];
+ if (![plugin.bundleIdentifier isEqualToString:DYPluginID]) {
+ dispatch_async(dispatch_get_main_queue(), ^{ [self finishRegistration:NO details:@"未找到完整的插件组件。请从发布地址重新安装大鱼调色。" results:@{}]; }); return;
+ }
+ NSDictionary *before = [self runPluginKit:@[@"-m",@"-A",@"-D",@"-v",@"-i",DYPluginID]];
+ dispatch_async(dispatch_get_main_queue(), ^{
+ self.registrationState = DYRegistering; self.statusTitle.stringValue = @"正在注册插件…";
+ self.statusDetail.stringValue = @"正在向系统提交插件注册,并核对当前安装位置。";
+ });
+ NSDictionary *add = [self runPluginKit:@[@"-a",path]];
+ NSDictionary *after = nil; BOOL registered = NO;
+ for (NSInteger attempt=0; attempt<4; attempt++) {
+ if (attempt) [NSThread sleepForTimeInterval:.35];
+ after = [self runPluginKit:@[@"-m",@"-A",@"-D",@"-v",@"-i",DYPluginID]];
+ registered = [self registry:after containsPlugin:path]; if (registered) break;
+ }
+ NSString *message = registered ? @"已确认当前插件登记。请在 Final Cut Pro 或 Motion 中使用;若宿主已打开,请保存后重新打开。" :
+ @"系统尚未确认插件注册。请点击“重新检查”,或重新安装后再试。窗口将保持打开。";
+ NSDictionary *results = @{@"before":before,@"submission":add,@"after":after ?: @{},@"registered":@(registered)};
+ dispatch_async(dispatch_get_main_queue(), ^{ [self finishRegistration:registered details:message results:results]; });
+ }
+ });
+}
+- (void)finishRegistration:(BOOL)success details:(NSString *)details results:(NSDictionary *)results {
+ if (self.terminating) return;
+ self.registrationState = success ? DYReady : DYFailed;
+ [self.progress stopAnimation:nil]; self.progress.indeterminate = NO; self.progress.doubleValue = success ? 100 : 0;
+ self.registrationCard.tint = success ? DYGreen() : DYColor(1,.67,.30); [self.registrationCard setNeedsDisplay:YES];
+ self.statusTitle.stringValue = success ? @"✓ 插件已就绪" : @"需要重新检查";
+ self.statusTitle.textColor = success ? DYGreen() : DYColor(1,.75,.4); self.statusDetail.stringValue = details;
+ self.retryButton.title = @"重新检查"; self.retryButton.enabled = YES;
+ [self.diagnostics addEntriesFromDictionary:results]; self.diagnostics[@"status"] = success ? @"registered" : @"failed"; [self writeDiagnostics];
+ NSAccessibilityPostNotificationWithUserInfo(self.window,NSAccessibilityAnnouncementRequestedNotification,
+ @{NSAccessibilityAnnouncementKey:self.statusTitle.stringValue,NSAccessibilityPriorityKey:@(NSAccessibilityPriorityHigh)});
+ if (success && !self.keepOpen) {
+ self.secondsRemaining = 5; [self updateCountdown];
+ self.exitTimer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(exitTick:) userInfo:nil repeats:YES];
+ } else self.exitDetail.stringValue = success ? @"插件已就绪。关闭此窗口后,可继续在宿主中使用。" : @"注册尚未完成,应用会保留此窗口以便重试。";
+}
+- (void)updateCountdown { self.exitDetail.stringValue = [NSString stringWithFormat:@"注册成功,%ld 秒后自动退出 · 点击“查看功能介绍”可保留窗口",(long)self.secondsRemaining]; }
+- (void)exitTick:(NSTimer *)timer {
+ if (--self.secondsRemaining <= 0) {
+ [timer invalidate]; self.exitTimer = nil; self.diagnostics[@"terminationReason"] = @"registration-succeeded"; [self writeDiagnostics]; [NSApp terminate:nil];
+ } else [self updateCountdown];
+}
+- (void)keepIntroduction:(id)sender {
+ self.keepOpen = YES; [self.exitTimer invalidate]; self.exitTimer = nil;
+ self.keepButton.title = @"正在浏览介绍"; self.keepButton.enabled = NO;
+ self.exitDetail.stringValue = @"已保留功能介绍窗口。插件可独立在宿主中使用。";
+}
+- (void)writeDiagnostics {
+ NSURL *base = [NSFileManager.defaultManager URLsForDirectory:NSApplicationSupportDirectory inDomains:NSUserDomainMask].firstObject;
+ NSURL *folder = [base URLByAppendingPathComponent:@"com.dayu.color" isDirectory:YES];
+ [NSFileManager.defaultManager createDirectoryAtURL:folder withIntermediateDirectories:YES attributes:nil error:nil];
+ NSData *data = [NSJSONSerialization dataWithJSONObject:self.diagnostics options:NSJSONWritingPrettyPrinted error:nil];
+ [data writeToURL:[folder URLByAppendingPathComponent:@"Registration.json"] options:NSDataWritingAtomic error:nil];
+}
+- (void)openHostWithIdentifiers:(NSArray *)identifiers name:(NSString *)name {
+ [self keepIntroduction:nil]; NSURL *url = nil;
+ for (NSString *identifier in identifiers) { url = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:identifier]; if (url) break; }
+ if (!url) { [self showMessage:[@"未找到 " stringByAppendingString:name] detail:@"请先安装宿主应用,再从效果或滤镜中使用大鱼调色。"]; return; }
+ [NSWorkspace.sharedWorkspace openApplicationAtURL:url configuration:NSWorkspaceOpenConfiguration.configuration completionHandler:^(NSRunningApplication *app,NSError *error) {
+ if (error) dispatch_async(dispatch_get_main_queue(), ^{ [self showMessage:@"无法打开宿主" detail:error.localizedDescription]; });
+ }];
+}
+- (void)openFinalCut:(id)sender { [self openHostWithIdentifiers:@[@"com.apple.FinalCut",@"com.apple.FinalCutApp"] name:@"Final Cut Pro"]; }
+- (void)openMotion:(id)sender { [self openHostWithIdentifiers:@[@"com.apple.motionapp",@"com.apple.motionappApp"] name:@"Motion"]; }
+- (void)openWebsite:(id)sender { [self keepIntroduction:nil]; if (![NSWorkspace.sharedWorkspace openURL:[NSURL URLWithString:DYReleaseAddress]]) [self showMessage:@"无法打开发布地址" detail:DYReleaseAddress]; }
+- (void)showMessage:(NSString *)title detail:(NSString *)detail {
+ NSAlert *alert = [[[NSAlert alloc] init] autorelease]; alert.messageText = title; alert.informativeText = detail;
+ [alert addButtonWithTitle:@"好"]; [alert beginSheetModalForWindow:self.window completionHandler:nil];
+}
+- (void)closeWindow:(id)sender { [self.window performClose:sender]; }
+- (void)accessibilityChanged:(NSNotification *)note { [self.window.contentView setNeedsDisplay:YES]; }
+- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)app { return YES; }
+- (void)applicationWillTerminate:(NSNotification *)note {
+ self.terminating = YES; [self.exitTimer invalidate]; self.exitTimer = nil;
+ [NSWorkspace.sharedWorkspace.notificationCenter removeObserver:self];
+}
+- (void)dealloc { [_exitTimer invalidate]; [_exitTimer release]; [_diagnostics release]; [super dealloc]; }
@end
diff --git a/大鱼调色/Wrapper Application/Info.plist b/大鱼调色/Wrapper Application/Info.plist
index 19d4d2c..7401e10 100644
--- a/大鱼调色/Wrapper Application/Info.plist
+++ b/大鱼调色/Wrapper Application/Info.plist
@@ -17,9 +17,9 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.6.0
+ 1.6.1
CFBundleVersion
- 39
+ 40
LSMinimumSystemVersion
$(MACOSX_DEPLOYMENT_TARGET)
NSHumanReadableCopyright