@legendapp/spark 0.0.1-next.7 → 0.0.1-next.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +8 -8
- package/schema.json +9 -0
- package/skills/spark/SKILL.md +1 -1
- package/skills/spark/UPGRADING.md +21 -0
- package/vendor/node_modules/@legendapp/spark-ai/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-audio/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-auth-session/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-cli/dist/add-desktop.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/build.js +16 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/create.js +16 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/init-template.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/dist/macos-release.js +4 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/project.js +10 -4
- package/vendor/node_modules/@legendapp/spark-cli/dist/release-driver.js +35 -0
- package/vendor/node_modules/@legendapp/spark-cli/dist/release.json +18 -18
- package/vendor/node_modules/@legendapp/spark-cli/dist/updates.js +18 -8
- package/vendor/node_modules/@legendapp/spark-cli/dist/windows.js +1 -1
- package/vendor/node_modules/@legendapp/spark-cli/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/app.json +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/gitignore +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/blank-typescript/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/app.json +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/gitignore +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/universal/package.json +8 -8
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/app.json +5 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/gitignore +2 -1
- package/vendor/node_modules/@legendapp/spark-cli/templates/windows/package.json +8 -8
- package/vendor/node_modules/@legendapp/spark-clipboard/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-codex/cpp/HybridCodexAppServer.mm +88 -76
- package/vendor/node_modules/@legendapp/spark-codex/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-commands/package.json +5 -5
- package/vendor/node_modules/@legendapp/spark-context-menu/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-app/RNDesktopApp.podspec +12 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/RNDesktopApp.mm +8 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.h +8 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkDesktop.mm +84 -21
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.h +27 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkInstance.mm +207 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.h +44 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkTestDriver.mm +349 -0
- package/vendor/node_modules/@legendapp/spark-desktop-app/macos/SparkWindow.mm +3 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/package.json +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/api.ts +39 -6
- package/vendor/node_modules/@legendapp/spark-desktop-app/src/contracts/menu.ts +21 -7
- package/vendor/node_modules/@legendapp/spark-desktop-config/accessibility-state.cjs +50 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/app.plugin.cjs +9 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/autolinking.cjs +8 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.cjs +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/config.d.cts +7 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-scroll-view.cjs +144 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-alignment.cjs +60 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/rtl-text-input-alignment.cjs +112 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/schema.json +9 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.cjs +11 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/test-driver.d.cts +2 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/text-input-accessibility.cjs +47 -0
- package/vendor/node_modules/@legendapp/spark-desktop-config/updates.cjs +4 -2
- package/vendor/node_modules/@legendapp/spark-desktop-config/validation.cjs +2 -1
- package/vendor/node_modules/@legendapp/spark-desktop-config/windows.plugin.cjs +1 -1
- package/vendor/node_modules/@legendapp/spark-desktop-host/AppDelegate.mm +18 -6
- package/vendor/node_modules/@legendapp/spark-desktop-host/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/application.inc +61 -15
- package/vendor/node_modules/@legendapp/spark-desktop-host/windows/launch.inc +67 -0
- package/vendor/node_modules/@legendapp/spark-desktop-links/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-shortcuts/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/RNDesktopWindows.podspec +3 -0
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/RNDesktopWindows.mm +5 -2
- package/vendor/node_modules/@legendapp/spark-desktop-windows/macos/window-manager/RNWindowManager.mm +22 -3
- package/vendor/node_modules/@legendapp/spark-desktop-windows/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-documents/package.json +7 -7
- package/vendor/node_modules/@legendapp/spark-drag-drop/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/RNFileDialog.podspec +1 -0
- package/vendor/node_modules/@legendapp/spark-file-dialog/ios/RNFileDialog.mm +153 -64
- package/vendor/node_modules/@legendapp/spark-file-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/index.ts +19 -7
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/native.ts +5 -1
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/options.ts +42 -4
- package/vendor/node_modules/@legendapp/spark-file-dialog/src/types.ts +18 -2
- package/vendor/node_modules/@legendapp/spark-file-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-global-shortcuts/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-html/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-markdown/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-markdown/src/Markdown.tsx +2 -1
- package/vendor/node_modules/@legendapp/spark-message-dialog/macos/RNDesktopMessageDialog.mm +113 -12
- package/vendor/node_modules/@legendapp/spark-message-dialog/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-message-dialog/src/index.ts +110 -14
- package/vendor/node_modules/@legendapp/spark-native-menu/ios/RNNativeMenu.mm +116 -8
- package/vendor/node_modules/@legendapp/spark-native-menu/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-native-menu/src/api.ts +63 -18
- package/vendor/node_modules/@legendapp/spark-native-menu/src/hooks.ts +9 -3
- package/vendor/node_modules/@legendapp/spark-notifications/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-processes/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-rich-text/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-secure-storage/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-settings/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-settings-ui/package.json +4 -4
- package/vendor/node_modules/@legendapp/spark-settings-ui/src/index.tsx +5 -2
- package/vendor/node_modules/@legendapp/spark-sqlite/package.json +3 -3
- package/vendor/node_modules/@legendapp/spark-system/macos/RNDesktopSystem.mm +13 -3
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.h +9 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkAppearancePreferences.mm +31 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.h +24 -0
- package/vendor/node_modules/@legendapp/spark-system/macos/SparkDockTile.mm +101 -0
- package/vendor/node_modules/@legendapp/spark-system/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-system/src/index.ts +73 -7
- package/vendor/node_modules/@legendapp/spark-tray/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkButton.mm +2 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkLayoutDirection.h +17 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/RNSparkTextInput.mm +6 -1
- package/vendor/node_modules/@legendapp/spark-ui/macos/appkit-split-view/RNSidebarSplitViewComponent.mm +55 -8
- package/vendor/node_modules/@legendapp/spark-ui/macos/glass-effect-view/RNGlassEffectView.mm +11 -7
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSegmentedControl.mm +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/native-select/RNNativeSelect.mm +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sf-symbol/RNSFSymbol.mm +4 -0
- package/vendor/node_modules/@legendapp/spark-ui/macos/sidebar/RNSidebar.mm +77 -14
- package/vendor/node_modules/@legendapp/spark-ui/macos/swipe-actions/RNSwipeActions.mm +31 -7
- package/vendor/node_modules/@legendapp/spark-ui/macos/text-input-search/RNTextInputSearch.mm +25 -1
- package/vendor/node_modules/@legendapp/spark-ui/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/SidebarNativeComponent.ts +5 -0
- package/vendor/node_modules/@legendapp/spark-ui/src/sidebar/index.tsx +19 -8
- package/vendor/node_modules/@legendapp/spark-updates/macos/RNDesktopUpdates.mm +25 -13
- package/vendor/node_modules/@legendapp/spark-updates/macos/SparkUpdateState.h +39 -0
- package/vendor/node_modules/@legendapp/spark-updates/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-updates/src/index.ts +45 -9
- package/vendor/node_modules/@legendapp/spark-webview/package.json +2 -2
- package/vendor/node_modules/@legendapp/spark-window-options/package.json +1 -1
|
@@ -112,7 +112,7 @@ function toExpo(value, target) {
|
|
|
112
112
|
...backend,
|
|
113
113
|
name: value.name, slug: backend.slug ?? value.name.toLowerCase().replace(/[^a-z0-9-]/g, "-"), version: value.version,
|
|
114
114
|
platforms: [selected], newArchEnabled: true,
|
|
115
|
-
...(value.macos ? { macos: { ...value.macos, infoPlist: { CFBundleName: value.name, ...value.macos.infoPlist } } } : {}),
|
|
115
|
+
...(value.macos ? { macos: { ...value.macos, version: value.version, buildNumber: value.macos.buildNumber ?? backend.ios?.buildNumber ?? "1", infoPlist: { CFBundleName: value.name, ...value.macos.infoPlist } } } : {}),
|
|
116
116
|
...(value.scheme !== undefined ? { scheme: value.scheme } : {}),
|
|
117
117
|
extra: { ...backend.extra, spark: { ...extra, ...(platforms.length > 1 ? { supportedPlatforms: platforms } : {}) } },
|
|
118
118
|
experiments: { ...backend.experiments, outOfTreePlatforms: true },
|
|
@@ -3,7 +3,7 @@ import type { WindowConfiguration } from "@legendapp/spark-window-options";
|
|
|
3
3
|
export type { WindowConfiguration } from "@legendapp/spark-window-options";
|
|
4
4
|
export type SparkPlatform = "macos" | "windows" | "ios" | "android" | "web";
|
|
5
5
|
export type JsonValue = null | boolean | number | string | JsonValue[] | { [key: string]: JsonValue };
|
|
6
|
-
export interface UpdateConfiguration { feedURL: string; publicKey: string }
|
|
6
|
+
export interface UpdateConfiguration { feedURL: string; publicKey: string; maximumDeltas?: number }
|
|
7
7
|
export interface DocumentType { name: string; contentTypes: string[]; role?: "Editor" | "Viewer" }
|
|
8
8
|
export type HelperTarget = "macos-arm64" | "macos-x64" | "windows-arm64" | "windows-x64";
|
|
9
9
|
export type HelperConfiguration = string | Partial<Record<HelperTarget, { directory: string; executable: string }>>;
|
|
@@ -12,6 +12,12 @@ export interface MacOSConfiguration {
|
|
|
12
12
|
buildNumber?: string;
|
|
13
13
|
infoPlist?: Record<string, JsonValue>;
|
|
14
14
|
entitlements?: Record<string, JsonValue>;
|
|
15
|
+
/**
|
|
16
|
+
* Compile the in-app test driver into release builds too; Debug builds always have it. Default false: release builds
|
|
17
|
+
* contain no driver code, which the CLI checks after each release build. For apps the release gate drives, such as
|
|
18
|
+
* the Kitchen Sink; never for apps you distribute (docs/test-driver.md#builds).
|
|
19
|
+
*/
|
|
20
|
+
testDriverInRelease?: boolean;
|
|
15
21
|
lifecycle?: MacOSLifecycle;
|
|
16
22
|
}
|
|
17
23
|
export interface SigningConfiguration {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-desktop-config",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "app.plugin.cjs",
|
|
6
6
|
"files": [
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
"*.d.cts"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"expo-desktop-config-plugins": "1.2
|
|
14
|
-
"@legendapp/spark-desktop-host": "0.0.1-next.
|
|
15
|
-
"@legendapp/spark-window-options": "0.0.1-next.
|
|
13
|
+
"expo-desktop-config-plugins": "1.3.2",
|
|
14
|
+
"@legendapp/spark-desktop-host": "0.0.1-next.8",
|
|
15
|
+
"@legendapp/spark-window-options": "0.0.1-next.8",
|
|
16
16
|
"@expo/config-plugins": "54.0.5",
|
|
17
17
|
"@expo/config-types": "54.0.10",
|
|
18
18
|
"diff": "8.0.4"
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// RN macOS 0.81.7 Fabric mirrors ScrollView content in RTL: it flips the content container with a
|
|
2
|
+
// layer transform, but the scroll view flip that cancels it on iOS is iOS-only. AppKit ignores layer
|
|
3
|
+
// transforms when it scrolls NSClipView and routes events, so macOS flips nothing (Yoga already
|
|
4
|
+
// places RTL content), reports offsets unconverted, and anchors RTL content to its right end.
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const file = "React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm";
|
|
8
|
+
const replacements = [
|
|
9
|
+
[
|
|
10
|
+
`- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
11
|
+
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
12
|
+
{
|
|
13
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
14
|
+
if (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection) {
|
|
15
|
+
CGAffineTransform transform = (layoutMetrics.layoutDirection == LayoutDirection::LeftToRight)
|
|
16
|
+
? CGAffineTransformIdentity
|
|
17
|
+
: CGAffineTransformMakeScale(-1, 1);
|
|
18
|
+
|
|
19
|
+
_containerView.transform = transform;
|
|
20
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
21
|
+
_scrollView.transform = transform;
|
|
22
|
+
#endif // [macOS]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
`#if TARGET_OS_OSX // [macOS
|
|
27
|
+
// iOS mirrors both the scroll view and its content in RTL, so offset 0 shows the content's right end.
|
|
28
|
+
// AppKit scrolls NSClipView by bounds origin and routes clicks, wheel deltas and scroller drags
|
|
29
|
+
// without layer transforms, so macOS flips nothing: Yoga already places RTL content. Instead the
|
|
30
|
+
// visible region keeps its distance from the content's right end, as the mirrored iOS offset does,
|
|
31
|
+
// and a scroll view that becomes RTL starts there (the RTL leading edge).
|
|
32
|
+
static void RCTPreserveRTLRightEdge(RCTUIScrollView *scrollView, BOOL wasRTL, BOOL isRTL, void (^block)(void))
|
|
33
|
+
{
|
|
34
|
+
CGFloat viewport = scrollView.frame.size.width;
|
|
35
|
+
CGFloat fromRight =
|
|
36
|
+
wasRTL && viewport > 0 ? fmax(scrollView.contentSize.width - viewport - scrollView.contentOffset.x, 0) : 0;
|
|
37
|
+
block();
|
|
38
|
+
if (!isRTL) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
CGFloat x = fmax(scrollView.contentSize.width - scrollView.frame.size.width - fromRight, 0);
|
|
42
|
+
if (x != scrollView.contentOffset.x) {
|
|
43
|
+
scrollView.contentOffset = CGPointMake(x, scrollView.contentOffset.y);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
#endif // macOS]
|
|
47
|
+
|
|
48
|
+
- (void)updateLayoutMetrics:(const LayoutMetrics &)layoutMetrics
|
|
49
|
+
oldLayoutMetrics:(const LayoutMetrics &)oldLayoutMetrics
|
|
50
|
+
{
|
|
51
|
+
#if !TARGET_OS_OSX // [macOS]
|
|
52
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
53
|
+
if (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection) {
|
|
54
|
+
CGAffineTransform transform = (layoutMetrics.layoutDirection == LayoutDirection::LeftToRight)
|
|
55
|
+
? CGAffineTransformIdentity
|
|
56
|
+
: CGAffineTransformMakeScale(-1, 1);
|
|
57
|
+
|
|
58
|
+
_containerView.transform = transform;
|
|
59
|
+
_scrollView.transform = transform;
|
|
60
|
+
}
|
|
61
|
+
#else // [macOS
|
|
62
|
+
RCTPreserveRTLRightEdge(
|
|
63
|
+
_scrollView,
|
|
64
|
+
_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft,
|
|
65
|
+
layoutMetrics.layoutDirection == LayoutDirection::RightToLeft,
|
|
66
|
+
^{
|
|
67
|
+
[super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
68
|
+
});
|
|
69
|
+
#endif // macOS]
|
|
70
|
+
}
|
|
71
|
+
`,
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
` _containerView.frame = CGRect{RCTCGPointFromPoint(data.contentBoundingRect.origin), contentSize};
|
|
75
|
+
|
|
76
|
+
[self _preserveContentOffsetIfNeededWithBlock:^{
|
|
77
|
+
self->_scrollView.contentSize = contentSize;
|
|
78
|
+
}];
|
|
79
|
+
`,
|
|
80
|
+
`#if !TARGET_OS_OSX // [macOS]
|
|
81
|
+
_containerView.frame = CGRect{RCTCGPointFromPoint(data.contentBoundingRect.origin), contentSize};
|
|
82
|
+
|
|
83
|
+
[self _preserveContentOffsetIfNeededWithBlock:^{
|
|
84
|
+
self->_scrollView.contentSize = contentSize;
|
|
85
|
+
}];
|
|
86
|
+
#else // [macOS
|
|
87
|
+
// contentSize reads the container (document view) frame, so measure before resizing it.
|
|
88
|
+
CGRect containerFrame = CGRect{RCTCGPointFromPoint(data.contentBoundingRect.origin), contentSize};
|
|
89
|
+
BOOL isRTL = _layoutMetrics.layoutDirection == LayoutDirection::RightToLeft;
|
|
90
|
+
RCTPreserveRTLRightEdge(_scrollView, isRTL, isRTL, ^{
|
|
91
|
+
self->_containerView.frame = containerFrame;
|
|
92
|
+
[self _preserveContentOffsetIfNeededWithBlock:^{
|
|
93
|
+
self->_scrollView.contentSize = contentSize;
|
|
94
|
+
}];
|
|
95
|
+
});
|
|
96
|
+
#endif // macOS]
|
|
97
|
+
`,
|
|
98
|
+
],
|
|
99
|
+
[
|
|
100
|
+
` if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
|
|
101
|
+
metrics.contentOffset.x = metrics.contentSize.width - metrics.containerSize.width - metrics.contentOffset.x;
|
|
102
|
+
}
|
|
103
|
+
`,
|
|
104
|
+
`#if !TARGET_OS_OSX // [macOS] The unmirrored macOS offset already counts from the left edge.
|
|
105
|
+
if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
|
|
106
|
+
metrics.contentOffset.x = metrics.contentSize.width - metrics.containerSize.width - metrics.contentOffset.x;
|
|
107
|
+
}
|
|
108
|
+
#endif // [macOS]
|
|
109
|
+
`,
|
|
110
|
+
],
|
|
111
|
+
[
|
|
112
|
+
` if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
|
|
113
|
+
// Adjusting offset.x in right to left layout direction.
|
|
114
|
+
offset.x = self.contentSize.width - _scrollView.frame.size.width - offset.x;
|
|
115
|
+
}
|
|
116
|
+
`,
|
|
117
|
+
`#if !TARGET_OS_OSX // [macOS] The unmirrored macOS offset already counts from the left edge.
|
|
118
|
+
if (_layoutMetrics.layoutDirection == LayoutDirection::RightToLeft) {
|
|
119
|
+
// Adjusting offset.x in right to left layout direction.
|
|
120
|
+
offset.x = self.contentSize.width - _scrollView.frame.size.width - offset.x;
|
|
121
|
+
}
|
|
122
|
+
#endif // [macOS]
|
|
123
|
+
`,
|
|
124
|
+
],
|
|
125
|
+
];
|
|
126
|
+
function patchScrollViewSource(source) {
|
|
127
|
+
if (replacements.every(([, after]) => source.includes(after))) return source;
|
|
128
|
+
if (replacements.some(([before, after]) => source.split(before).length !== 2 || source.includes(after)))
|
|
129
|
+
throw new Error(`React Native macOS ScrollView source changed (${file}); review the RTL scroll patch before building.`);
|
|
130
|
+
return replacements.reduce((patched, [before, after]) => patched.replace(before, after), source);
|
|
131
|
+
}
|
|
132
|
+
function installRTLScrollViewPatch(root) {
|
|
133
|
+
const manifest = require.resolve("react-native-macos/package.json", { paths: [root] });
|
|
134
|
+
const version = JSON.parse(fs.readFileSync(manifest, "utf8")).version;
|
|
135
|
+
if (version !== "0.81.7") throw new Error(`spark's RTL scroll patch requires react-native-macos@0.81.7; found ${version}.`);
|
|
136
|
+
const target = path.join(path.dirname(manifest), file);
|
|
137
|
+
const before = fs.readFileSync(target, "utf8"), after = patchScrollViewSource(before);
|
|
138
|
+
if (before !== after) {
|
|
139
|
+
const temporary = `${target}.spark-${process.pid}.tmp`;
|
|
140
|
+
fs.writeFileSync(temporary, after);
|
|
141
|
+
fs.renameSync(temporary, target); // Preserve package-manager cache hardlinks.
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
module.exports = { replacements, patchScrollViewSource, installRTLScrollViewPatch };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// RN macOS 0.81.7 Fabric leaves natural ("auto" or unset) textAlign as NSTextAlignmentNatural. TextKit resolves that
|
|
2
|
+
// from the user's language, not the Yoga layout direction, so text in an RTL subtree of an LTR-localized app aligns
|
|
3
|
+
// left. The patch resolves natural alignment from the layout direction. "left" and "right" keep the upstream
|
|
4
|
+
// behavior, shared with iOS: they swap in RTL.
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const file = "ReactCommon/react/renderer/textlayoutmanager/platform/ios/react/renderer/textlayoutmanager/RCTAttributedTextUtils.mm";
|
|
8
|
+
const before = ` if (textAttributes.alignment.has_value()) {
|
|
9
|
+
TextAlignment textAlignment = textAttributes.alignment.value_or(TextAlignment::Natural);
|
|
10
|
+
if (textAttributes.layoutDirection.value_or(LayoutDirection::LeftToRight) == LayoutDirection::RightToLeft) {
|
|
11
|
+
if (textAlignment == TextAlignment::Right) {
|
|
12
|
+
textAlignment = TextAlignment::Left;
|
|
13
|
+
} else if (textAlignment == TextAlignment::Left) {
|
|
14
|
+
textAlignment = TextAlignment::Right;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
paragraphStyle.alignment = RCTNSTextAlignmentFromTextAlignment(textAlignment);
|
|
19
|
+
isParagraphStyleUsed = YES;
|
|
20
|
+
}
|
|
21
|
+
`;
|
|
22
|
+
const after = ` // [macOS] TextKit resolves NSTextAlignmentNatural from the user's language, not the Yoga layout direction,
|
|
23
|
+
// so natural ("auto" or unset) alignment is resolved here from the layout direction.
|
|
24
|
+
LayoutDirection layoutDirection = textAttributes.layoutDirection.value_or(LayoutDirection::Undefined);
|
|
25
|
+
if (textAttributes.alignment.has_value() || layoutDirection != LayoutDirection::Undefined) {
|
|
26
|
+
TextAlignment textAlignment = textAttributes.alignment.value_or(TextAlignment::Natural);
|
|
27
|
+
if (textAttributes.layoutDirection.value_or(LayoutDirection::LeftToRight) == LayoutDirection::RightToLeft) {
|
|
28
|
+
if (textAlignment == TextAlignment::Right) {
|
|
29
|
+
textAlignment = TextAlignment::Left;
|
|
30
|
+
} else if (textAlignment == TextAlignment::Left) {
|
|
31
|
+
textAlignment = TextAlignment::Right;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
if (textAlignment == TextAlignment::Natural && layoutDirection != LayoutDirection::Undefined) {
|
|
35
|
+
textAlignment = layoutDirection == LayoutDirection::RightToLeft ? TextAlignment::Right : TextAlignment::Left;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
paragraphStyle.alignment = RCTNSTextAlignmentFromTextAlignment(textAlignment);
|
|
39
|
+
isParagraphStyleUsed = YES;
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
function patchTextAlignmentSource(source) {
|
|
43
|
+
if (source.includes(after)) return source;
|
|
44
|
+
if (source.split(before).length !== 2)
|
|
45
|
+
throw new Error(`React Native macOS text attribute source changed (${file}); review the RTL text alignment patch before building.`);
|
|
46
|
+
return source.replace(before, after);
|
|
47
|
+
}
|
|
48
|
+
function installRTLTextAlignmentPatch(root) {
|
|
49
|
+
const manifest = require.resolve("react-native-macos/package.json", { paths: [root] });
|
|
50
|
+
const version = JSON.parse(fs.readFileSync(manifest, "utf8")).version;
|
|
51
|
+
if (version !== "0.81.7") throw new Error(`spark's RTL text alignment patch requires react-native-macos@0.81.7; found ${version}.`);
|
|
52
|
+
const target = path.join(path.dirname(manifest), file);
|
|
53
|
+
const source = fs.readFileSync(target, "utf8"), patched = patchTextAlignmentSource(source);
|
|
54
|
+
if (source !== patched) {
|
|
55
|
+
const temporary = `${target}.spark-${process.pid}.tmp`;
|
|
56
|
+
fs.writeFileSync(temporary, patched);
|
|
57
|
+
fs.renameSync(temporary, target); // Preserve package-manager cache hardlinks.
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
module.exports = { before, after, patchTextAlignmentSource, installRTLTextAlignmentPatch };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
// RN macOS 0.81.7 Fabric gives a TextInput no layout direction: its text attributes have none, and the iOS
|
|
2
|
+
// semanticContentAttribute that makes UIKit's natural alignment follow it isn't set on macOS. TextKit resolves
|
|
3
|
+
// NSTextAlignmentNatural from the user's language, so in an RTL layout a TextInput with natural ("auto" or unset)
|
|
4
|
+
// textAlign draws its text and placeholder from the left. The patch aligns them to the leading edge of the input's
|
|
5
|
+
// layout direction, and again when that changes, as rtl-text-alignment.cjs does for Text. An explicit textAlign is
|
|
6
|
+
// unchanged.
|
|
7
|
+
const fs = require("node:fs");
|
|
8
|
+
const path = require("node:path");
|
|
9
|
+
const file = "React/Fabric/Mounting/ComponentViews/TextInput/RCTTextInputComponentView.mm";
|
|
10
|
+
const helpers = `// [Spark] TextKit resolves natural alignment from the user's language, not the Yoga layout direction, so a TextInput
|
|
11
|
+
// whose textAlign is natural ("auto" or unset) aligns every paragraph, and the placeholder through the default
|
|
12
|
+
// attributes, to the leading edge of its layout direction. An explicit textAlign is unchanged.
|
|
13
|
+
static std::optional<NSTextAlignment> RCTSparkNaturalAlignment(const TextInputProps &props, LayoutDirection direction)
|
|
14
|
+
{
|
|
15
|
+
if (props.textAttributes.alignment.value_or(TextAlignment::Natural) != TextAlignment::Natural ||
|
|
16
|
+
direction == LayoutDirection::Undefined) {
|
|
17
|
+
return std::nullopt;
|
|
18
|
+
}
|
|
19
|
+
return direction == LayoutDirection::RightToLeft ? NSTextAlignmentRight : NSTextAlignmentLeft;
|
|
20
|
+
}
|
|
21
|
+
static NSParagraphStyle *RCTSparkAlignedParagraphStyle(NSParagraphStyle *style, NSTextAlignment alignment)
|
|
22
|
+
{
|
|
23
|
+
NSMutableParagraphStyle *aligned = [(style ?: NSParagraphStyle.defaultParagraphStyle) mutableCopy];
|
|
24
|
+
aligned.alignment = alignment;
|
|
25
|
+
return aligned;
|
|
26
|
+
}
|
|
27
|
+
static NSMutableDictionary<NSAttributedStringKey, id> *RCTSparkAlignNaturalAttributes(
|
|
28
|
+
NSDictionary<NSAttributedStringKey, id> *attributes, const TextInputProps &props, LayoutDirection direction)
|
|
29
|
+
{
|
|
30
|
+
NSMutableDictionary<NSAttributedStringKey, id> *aligned = [attributes mutableCopy];
|
|
31
|
+
if (auto alignment = RCTSparkNaturalAlignment(props, direction)) {
|
|
32
|
+
aligned[NSParagraphStyleAttributeName] = RCTSparkAlignedParagraphStyle(attributes[NSParagraphStyleAttributeName], *alignment);
|
|
33
|
+
}
|
|
34
|
+
return aligned;
|
|
35
|
+
}
|
|
36
|
+
static NSAttributedString *RCTSparkAlignNaturalText(NSAttributedString *text, const TextInputProps &props, LayoutDirection direction)
|
|
37
|
+
{
|
|
38
|
+
auto alignment = RCTSparkNaturalAlignment(props, direction);
|
|
39
|
+
if (!alignment || text.length == 0) {
|
|
40
|
+
return text;
|
|
41
|
+
}
|
|
42
|
+
NSMutableAttributedString *aligned = [text mutableCopy];
|
|
43
|
+
[text enumerateAttribute:NSParagraphStyleAttributeName
|
|
44
|
+
inRange:NSMakeRange(0, text.length)
|
|
45
|
+
options:0
|
|
46
|
+
usingBlock:^(NSParagraphStyle *style, NSRange range, BOOL *stop) {
|
|
47
|
+
[aligned addAttribute:NSParagraphStyleAttributeName
|
|
48
|
+
value:RCTSparkAlignedParagraphStyle(style, *alignment)
|
|
49
|
+
range:range];
|
|
50
|
+
}];
|
|
51
|
+
return aligned;
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
const replacements = [
|
|
55
|
+
[`using namespace facebook::react;
|
|
56
|
+
`, `using namespace facebook::react;
|
|
57
|
+
|
|
58
|
+
${helpers}`],
|
|
59
|
+
[` NSMutableDictionary<NSAttributedStringKey, id> *attrs =
|
|
60
|
+
RCTNSTextAttributesFromTextAttributes(props.getEffectiveTextAttributes(RCTFontSizeMultiplier()));
|
|
61
|
+
`, ` NSMutableDictionary<NSAttributedStringKey, id> *attrs = RCTSparkAlignNaturalAttributes( // [Spark]
|
|
62
|
+
RCTNSTextAttributesFromTextAttributes(props.getEffectiveTextAttributes(RCTFontSizeMultiplier())),
|
|
63
|
+
props,
|
|
64
|
+
_layoutMetrics.layoutDirection);
|
|
65
|
+
`],
|
|
66
|
+
[` _backedTextInputView.defaultTextAttributes[RCTAttributedStringEventEmitterKey];
|
|
67
|
+
_backedTextInputView.defaultTextAttributes = defaultAttributes;
|
|
68
|
+
`, ` _backedTextInputView.defaultTextAttributes[RCTAttributedStringEventEmitterKey];
|
|
69
|
+
_backedTextInputView.defaultTextAttributes = RCTSparkAlignNaturalAttributes( // [Spark]
|
|
70
|
+
defaultAttributes, newTextInputProps, _layoutMetrics.layoutDirection);
|
|
71
|
+
`],
|
|
72
|
+
[` [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
73
|
+
`, ` [super updateLayoutMetrics:layoutMetrics oldLayoutMetrics:oldLayoutMetrics];
|
|
74
|
+
|
|
75
|
+
// [Spark] Natural alignment follows the layout direction, so realign the text and placeholder when it changes.
|
|
76
|
+
if (layoutMetrics.layoutDirection != oldLayoutMetrics.layoutDirection) {
|
|
77
|
+
_backedTextInputView.defaultTextAttributes = RCTSparkAlignNaturalAttributes(
|
|
78
|
+
_backedTextInputView.defaultTextAttributes,
|
|
79
|
+
static_cast<const TextInputProps &>(*_props),
|
|
80
|
+
layoutMetrics.layoutDirection);
|
|
81
|
+
_comingFromJS = YES;
|
|
82
|
+
[self _setAttributedString:_backedTextInputView.attributedText];
|
|
83
|
+
_comingFromJS = NO;
|
|
84
|
+
}
|
|
85
|
+
`],
|
|
86
|
+
[`- (void)_setAttributedString:(NSAttributedString *)attributedString
|
|
87
|
+
{
|
|
88
|
+
`, `- (void)_setAttributedString:(NSAttributedString *)attributedString
|
|
89
|
+
{
|
|
90
|
+
attributedString = RCTSparkAlignNaturalText( // [Spark]
|
|
91
|
+
attributedString, static_cast<const TextInputProps &>(*_props), _layoutMetrics.layoutDirection);
|
|
92
|
+
`],
|
|
93
|
+
];
|
|
94
|
+
function patchTextInputAlignmentSource(source) {
|
|
95
|
+
if (replacements.every(([, after]) => source.includes(after))) return source;
|
|
96
|
+
if (replacements.some(([before, after]) => source.split(before).length !== 2 || source.includes(after)))
|
|
97
|
+
throw new Error(`React Native macOS TextInput source changed (${file}); review the RTL TextInput alignment patch before building.`);
|
|
98
|
+
return replacements.reduce((patched, [before, after]) => patched.replace(before, after), source);
|
|
99
|
+
}
|
|
100
|
+
function installRTLTextInputAlignmentPatch(root) {
|
|
101
|
+
const manifest = require.resolve("react-native-macos/package.json", { paths: [root] });
|
|
102
|
+
const version = JSON.parse(fs.readFileSync(manifest, "utf8")).version;
|
|
103
|
+
if (version !== "0.81.7") throw new Error(`spark's RTL TextInput alignment patch requires react-native-macos@0.81.7; found ${version}.`);
|
|
104
|
+
const target = path.join(path.dirname(manifest), file);
|
|
105
|
+
const source = fs.readFileSync(target, "utf8"), patched = patchTextInputAlignmentSource(source);
|
|
106
|
+
if (source !== patched) {
|
|
107
|
+
const temporary = `${target}.spark-${process.pid}.tmp`;
|
|
108
|
+
fs.writeFileSync(temporary, patched);
|
|
109
|
+
fs.renameSync(temporary, target); // Preserve package-manager cache hardlinks.
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
module.exports = { file, helpers, replacements, patchTextInputAlignmentSource, installRTLTextInputAlignmentPatch };
|
|
@@ -188,6 +188,10 @@
|
|
|
188
188
|
"infoPlist": {
|
|
189
189
|
"type": "object"
|
|
190
190
|
},
|
|
191
|
+
"testDriverInRelease": {
|
|
192
|
+
"type": "boolean",
|
|
193
|
+
"description": "Compile the in-app test driver into release builds too; Debug builds always have it. For apps the release gate drives: keep it off for apps you distribute (docs/test-driver.md#builds)."
|
|
194
|
+
},
|
|
191
195
|
"lifecycle": {
|
|
192
196
|
"type": "object",
|
|
193
197
|
"additionalProperties": false,
|
|
@@ -334,6 +338,11 @@
|
|
|
334
338
|
"publicKey": {
|
|
335
339
|
"type": "string",
|
|
336
340
|
"pattern": "^[A-Za-z0-9+/]{43}=$"
|
|
341
|
+
},
|
|
342
|
+
"maximumDeltas": {
|
|
343
|
+
"type": "integer",
|
|
344
|
+
"minimum": 0,
|
|
345
|
+
"maximum": 10
|
|
337
346
|
}
|
|
338
347
|
},
|
|
339
348
|
"additionalProperties": false
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// The in-app test driver compiles in Debug builds; macos.testDriverInRelease adds it to other builds by exporting a
|
|
2
|
+
// variable to the Podfile that the Spark podspecs turn into a build setting (docs/test-driver.md#builds).
|
|
3
|
+
const MARKER = "# spark: test driver in release builds";
|
|
4
|
+
|
|
5
|
+
/** The Podfile with the release opt-in line when `macos` sets testDriverInRelease, and without it otherwise. */
|
|
6
|
+
function testDriverPodfile(contents, macos) {
|
|
7
|
+
const stripped = contents.split("\n").filter(line => !line.endsWith(MARKER)).join("\n");
|
|
8
|
+
return macos?.testDriverInRelease === true ? `ENV['SPARK_TEST_DRIVER_RELEASE'] = '1' ${MARKER}\n${stripped}` : stripped;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = { testDriverPodfile };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// RN macOS 0.81.7 Fabric sets a TextInput's accessibilityLabel on its accessibilityElement, the backed text input view.
|
|
2
|
+
// A multiline input's backed view is RCTWrappedTextView, a plain view around a scroll view, while the NSTextView inside
|
|
3
|
+
// it is the accessibility element, so VoiceOver announces a labelled multiline input without its label. The patch
|
|
4
|
+
// keeps the label on that text view.
|
|
5
|
+
const fs = require("node:fs");
|
|
6
|
+
const path = require("node:path");
|
|
7
|
+
const file = "Libraries/Text/TextInput/Multiline/RCTWrappedTextView.m";
|
|
8
|
+
// The file has CRLF line endings, so the patch is joined with the source's own.
|
|
9
|
+
const before = (eol) => ["#pragma mark First Responder forwarding", ""].join(eol);
|
|
10
|
+
const after = (eol) => [
|
|
11
|
+
"#pragma mark Accessibility",
|
|
12
|
+
"",
|
|
13
|
+
"// [Spark] The text view is the accessibility element, so the label React Native sets here describes it.",
|
|
14
|
+
"- (void)setAccessibilityLabel:(NSString *)accessibilityLabel",
|
|
15
|
+
"{",
|
|
16
|
+
" _forwardingTextView.accessibilityLabel = accessibilityLabel;",
|
|
17
|
+
"}",
|
|
18
|
+
"",
|
|
19
|
+
"- (NSString *)accessibilityLabel",
|
|
20
|
+
"{",
|
|
21
|
+
" return _forwardingTextView.accessibilityLabel;",
|
|
22
|
+
"}",
|
|
23
|
+
"",
|
|
24
|
+
"#pragma mark -",
|
|
25
|
+
"#pragma mark First Responder forwarding",
|
|
26
|
+
"",
|
|
27
|
+
].join(eol);
|
|
28
|
+
function patchTextInputAccessibilitySource(source) {
|
|
29
|
+
const eol = source.includes("\r\n") ? "\r\n" : "\n";
|
|
30
|
+
if (source.includes(after(eol))) return source;
|
|
31
|
+
if (source.split(before(eol)).length !== 2)
|
|
32
|
+
throw new Error(`React Native macOS multiline TextInput source changed (${file}); review the TextInput accessibility patch before building.`);
|
|
33
|
+
return source.replace(before(eol), after(eol));
|
|
34
|
+
}
|
|
35
|
+
function installTextInputAccessibilityPatch(root) {
|
|
36
|
+
const manifest = require.resolve("react-native-macos/package.json", { paths: [root] });
|
|
37
|
+
const version = JSON.parse(fs.readFileSync(manifest, "utf8")).version;
|
|
38
|
+
if (version !== "0.81.7") throw new Error(`spark's TextInput accessibility patch requires react-native-macos@0.81.7; found ${version}.`);
|
|
39
|
+
const target = path.join(path.dirname(manifest), file);
|
|
40
|
+
const source = fs.readFileSync(target, "utf8"), patched = patchTextInputAccessibilitySource(source);
|
|
41
|
+
if (source !== patched) {
|
|
42
|
+
const temporary = `${target}.spark-${process.pid}.tmp`;
|
|
43
|
+
fs.writeFileSync(temporary, patched);
|
|
44
|
+
fs.renameSync(temporary, target); // Preserve package-manager cache hardlinks.
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
module.exports = { before, after, patchTextInputAccessibilitySource, installTextInputAccessibilityPatch };
|
|
@@ -2,12 +2,14 @@ function updateConfiguration(expo) {
|
|
|
2
2
|
const updates = expo.extra?.spark?.updates;
|
|
3
3
|
if (updates === undefined) return undefined;
|
|
4
4
|
if (!updates || typeof updates !== "object" || Array.isArray(updates)) throw new Error("extra.spark.updates must be an object");
|
|
5
|
-
for (const key of Object.keys(updates)) if (!["feedURL", "publicKey"].includes(key)) throw new Error(`Unknown updates field: ${key}`);
|
|
5
|
+
for (const key of Object.keys(updates)) if (!["feedURL", "publicKey", "maximumDeltas"].includes(key)) throw new Error(`Unknown updates field: ${key}`);
|
|
6
6
|
let url;
|
|
7
7
|
try { url = new URL(updates.feedURL); } catch { throw new Error("Updates need an HTTPS feedURL"); }
|
|
8
8
|
if (url.protocol !== "https:" || !url.hostname || url.username || url.password || url.search || url.hash || !url.pathname.endsWith(".xml")) throw new Error("Update feedURL must be an HTTPS .xml URL without credentials, query or fragment");
|
|
9
9
|
if (typeof updates.publicKey !== "string" || !/^[A-Za-z0-9+/]{43}=$/.test(updates.publicKey) || Buffer.from(updates.publicKey, "base64").length !== 32) throw new Error("Updates need a base64 Ed25519 publicKey; run spark updates init <feedURL>");
|
|
10
|
-
|
|
10
|
+
const { maximumDeltas } = updates;
|
|
11
|
+
if (maximumDeltas !== undefined && (!Number.isInteger(maximumDeltas) || maximumDeltas < 0 || maximumDeltas > 10)) throw new Error("Updates maximumDeltas must be an integer from 0 to 10");
|
|
12
|
+
return { feedURL: url.href, publicKey: updates.publicKey, ...(maximumDeltas === undefined ? {} : { maximumDeltas }) };
|
|
11
13
|
}
|
|
12
14
|
function updatePlist(expo) {
|
|
13
15
|
const updates = updateConfiguration(expo);
|
|
@@ -9,9 +9,10 @@ function validatePlatforms(value) {
|
|
|
9
9
|
}
|
|
10
10
|
function validateOwned(value) {
|
|
11
11
|
if (value.macos !== undefined) {
|
|
12
|
-
object(value.macos, "macos", ["bundleIdentifier", "buildNumber", "entitlements", "infoPlist", "lifecycle"]);
|
|
12
|
+
object(value.macos, "macos", ["bundleIdentifier", "buildNumber", "entitlements", "infoPlist", "testDriverInRelease", "lifecycle"]);
|
|
13
13
|
if (typeof value.macos.bundleIdentifier !== "string" || !/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(value.macos.bundleIdentifier)) throw new Error("macos.bundleIdentifier must be a reverse-DNS identifier");
|
|
14
14
|
if (value.macos.buildNumber !== undefined && typeof value.macos.buildNumber !== "string") throw new Error("macos.buildNumber must be a string");
|
|
15
|
+
if (value.macos.testDriverInRelease !== undefined && typeof value.macos.testDriverInRelease !== "boolean") throw new Error("macos.testDriverInRelease must be a boolean");
|
|
15
16
|
for (const key of ["entitlements", "infoPlist"]) if (value.macos[key] !== undefined) object(value.macos[key], `macos.${key}`);
|
|
16
17
|
require("./lifecycle.cjs").validateLifecycle(value.macos.lifecycle);
|
|
17
18
|
}
|
|
@@ -38,7 +38,7 @@ module.exports = config => {
|
|
|
38
38
|
SPARK_PROJECT_VERSION: expo.version, SPARK_WINDOW_CONFIG: JSON.stringify(nativeWindowOptions(expo.extra.spark.window ?? {})),
|
|
39
39
|
SPARK_SESSION_FILE: statePath(root, 'windows-connection.json', 'windows'),
|
|
40
40
|
} : {};
|
|
41
|
-
mod.modResults.contents = patchHost(mod.modResults.contents, fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/runtime.inc'), 'utf8') + '\n' + fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/application.inc'), 'utf8') + '\n' + fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/notifications.inc'), 'utf8') + (Object.hasOwn(metadata.modules ?? {}, '@react-native-runtimes/core') ? '\n' + fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/runtimes.inc'), 'utf8') : ''), metadata, defaults);
|
|
41
|
+
mod.modResults.contents = patchHost(mod.modResults.contents, fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/runtime.inc'), 'utf8') + '\n' + fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/launch.inc'), 'utf8') + '\n' + fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/application.inc'), 'utf8') + '\n' + fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/notifications.inc'), 'utf8') + (Object.hasOwn(metadata.modules ?? {}, '@react-native-runtimes/core') ? '\n' + fs.readFileSync(require.resolve('@legendapp/spark-desktop-host/windows/runtimes.inc'), 'utf8') : ''), metadata, defaults);
|
|
42
42
|
return mod;
|
|
43
43
|
});
|
|
44
44
|
const { withMod } = require('@expo/config-plugins');
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
#import "AppDelegate.h"
|
|
2
2
|
#import <RNDesktopApp/SparkDesktop.h>
|
|
3
|
+
#import <RNDesktopApp/SparkTestDriver.h>
|
|
3
4
|
#import <React/RCTBundleURLProvider.h>
|
|
4
5
|
#import <React/RCTUIKit.h>
|
|
5
6
|
#import <QuartzCore/QuartzCore.h>
|
|
6
7
|
#include <cxxreact/ReactMarker.h>
|
|
7
8
|
#import <React-RCTAppDelegate/RCTRootViewFactory.h>
|
|
8
9
|
#import <ReactAppDependencyProvider/RCTAppDependencyProvider.h>
|
|
10
|
+
#import <React/RCTSurfacePresenter.h>
|
|
11
|
+
#import <ReactCommon/RCTHost.h>
|
|
9
12
|
|
|
10
13
|
#if __has_include(<NativeComposeThreadedRuntime/ThreadedRuntime.h>)
|
|
11
14
|
#import <NativeComposeThreadedRuntime/ThreadedRuntime.h>
|
|
12
15
|
#import <React/RCTReloadCommand.h>
|
|
13
16
|
#endif
|
|
14
17
|
|
|
15
|
-
@interface AppDelegate () <NSWindowDelegate>
|
|
18
|
+
@interface AppDelegate () <NSWindowDelegate, RCTSurfacePresenterObserver>
|
|
16
19
|
@property (nonatomic, assign) BOOL sparkPrimaryInstance;
|
|
17
20
|
@property (nonatomic, weak) NSWindow *sparkLastFocusedWindow;
|
|
18
21
|
@property (nonatomic, strong) NSColor *sparkStartupColor;
|
|
@@ -20,8 +23,10 @@
|
|
|
20
23
|
|
|
21
24
|
@implementation AppDelegate
|
|
22
25
|
- (void)applicationWillFinishLaunching:(NSNotification *)notification {
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
// A driven instance never signals (and so never activates) a normal running instance.
|
|
27
|
+
self.sparkPrimaryInstance = SparkTestDriverStart() || SparkAcquireInstance();
|
|
28
|
+
// A second process forwards its launch to the owner and exits (SparkAcquireInstance).
|
|
29
|
+
if (!self.sparkPrimaryInstance) return;
|
|
25
30
|
facebook::react::ReactMarker::logMarkerDone(facebook::react::ReactMarker::APP_STARTUP_START, CACurrentMediaTime() * 1000);
|
|
26
31
|
[self sparkPrepareMainMenu];
|
|
27
32
|
SparkPrepareApplication();
|
|
@@ -90,7 +95,7 @@
|
|
|
90
95
|
SparkApplyWindowOptions(self.window, options);
|
|
91
96
|
SparkRestoreWindow(self.window, @"main", options);
|
|
92
97
|
NSString *autosave = policy[@"autosaveName"];
|
|
93
|
-
if (autosave.length) { [self.window setFrameAutosaveName:autosave]; [self.window setFrameUsingName:autosave]; }
|
|
98
|
+
if (autosave.length && !SparkSafeMode() && !SparkTestDriverActive()) { [self.window setFrameAutosaveName:autosave]; [self.window setFrameUsingName:autosave]; }
|
|
94
99
|
if (policy[@"toolbarStyle"]) {
|
|
95
100
|
self.window.toolbar = [[NSToolbar alloc] initWithIdentifier:@"main"];
|
|
96
101
|
self.window.toolbar.displayMode = NSToolbarDisplayModeIconOnly;
|
|
@@ -111,13 +116,19 @@
|
|
|
111
116
|
placeholder.wantsLayer = YES; placeholder.layer.backgroundColor = self.sparkStartupColor.CGColor;
|
|
112
117
|
self.window.contentView = placeholder;
|
|
113
118
|
SparkPrepareMainWindow(self.window);
|
|
114
|
-
|
|
119
|
+
// The test driver renders the window in-process without ever showing it.
|
|
120
|
+
if (!SparkTestDriverActive() && ![policy[@"hidden"] boolValue] && ![[NSBundle.mainBundle objectForInfoDictionaryKey:@"SparkMenuBarOnly"] boolValue]) {
|
|
115
121
|
[self.window makeKeyAndOrderFront:nil]; [self.window displayIfNeeded]; SparkRecordMainWindowShown();
|
|
116
122
|
}
|
|
117
123
|
}
|
|
118
124
|
- (void)loadReactNativeWindow:(NSDictionary *)launchOptions {
|
|
119
125
|
[self sparkPrepareMainWindow];
|
|
120
126
|
NSView *root = [self.rootViewFactory viewWithModuleName:self.moduleName initialProperties:self.initialProps launchOptions:launchOptions];
|
|
127
|
+
if (SparkTestDriverActive()) {
|
|
128
|
+
RCTSurfacePresenter *presenter = self.rootViewFactory.reactHost.surfacePresenter;
|
|
129
|
+
if (!presenter) [NSException raise:NSInternalInconsistencyException format:@"The test driver needs the Fabric surface presenter"];
|
|
130
|
+
[presenter addObserver:self];
|
|
131
|
+
}
|
|
121
132
|
root.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
|
|
122
133
|
NSDictionary *options = SparkWindowConfiguration();
|
|
123
134
|
if ([options[@"transparent"] boolValue] || options[@"backgroundColor"] || SparkLifecycleConfiguration()[@"mainWindow"][@"backgroundColors"])
|
|
@@ -141,13 +152,14 @@
|
|
|
141
152
|
}
|
|
142
153
|
});
|
|
143
154
|
}
|
|
155
|
+
- (void)didMountComponentsWithRootTag:(NSInteger)rootTag { SparkTestDriverDidMount(); }
|
|
144
156
|
- (BOOL)windowShouldClose:(NSWindow *)window {
|
|
145
157
|
NSString *behavior = SparkLifecycleConfiguration()[@"mainWindow"][@"closeBehavior"];
|
|
146
158
|
if ([behavior isEqual:@"hide"]) { [window orderOut:nil]; return NO; }
|
|
147
159
|
if ([behavior isEqual:@"request"]) { SparkEmit(@{ @"type": @"closeRequested", @"windowId": @"main" }); return NO; }
|
|
148
160
|
return YES;
|
|
149
161
|
}
|
|
150
|
-
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { return SparkShouldQuit(); }
|
|
162
|
+
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender { return SparkTestDriverEnding() ? NSTerminateNow : SparkShouldQuit(); }
|
|
151
163
|
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { return NO; }
|
|
152
164
|
- (void)applicationDidBecomeActive:(NSNotification *)note { SparkEmit(@{ @"type": @"activate" }); }
|
|
153
165
|
- (void)applicationDidResignActive:(NSNotification *)note { SparkEmit(@{ @"type": @"deactivate" }); }
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legendapp/spark-desktop-host",
|
|
3
|
-
"version": "0.0.1-next.
|
|
3
|
+
"version": "0.0.1-next.8",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"files": [
|
|
6
6
|
"AppDelegate.mm",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"SparkCustomize.mm"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@legendapp/spark-desktop-app": "0.0.1-next.
|
|
11
|
+
"@legendapp/spark-desktop-app": "0.0.1-next.8"
|
|
12
12
|
},
|
|
13
13
|
"private": true
|
|
14
14
|
}
|