react-native-nswindow 0.0.1
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/README.md +150 -0
- package/macos/RNNSWindow.h +142 -0
- package/macos/RNNSWindow.mm +570 -0
- package/macos/RNNSWindowHelper.h +80 -0
- package/macos/RNNSWindowHelper.mm +683 -0
- package/macos/RNNSWindowLoader.mm +19 -0
- package/package.json +53 -0
- package/react-native-nswindow.podspec +18 -0
- package/spec/NativeNSWindow.ts +148 -0
- package/src/index.ts +16 -0
package/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react-native-nswindow",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Multi-window support for react-native-macos using NSWindow",
|
|
5
|
+
"author": "Jim Lake <jim@blueskylabs.com>",
|
|
6
|
+
"homepage": "https://github.com/jim-lake/react-native-nswindow#readme",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/jim-lake/react-native-nswindow.git"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/jim-lake/react-native-nswindow/issues"
|
|
13
|
+
},
|
|
14
|
+
"main": "src/index.ts",
|
|
15
|
+
"types": "src/index.ts",
|
|
16
|
+
"source": "src/index.ts",
|
|
17
|
+
"files": [
|
|
18
|
+
"spec",
|
|
19
|
+
"src",
|
|
20
|
+
"macos",
|
|
21
|
+
"react-native-nswindow.podspec",
|
|
22
|
+
"!**/__tests__"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"ts:check": "tsc --noEmit",
|
|
26
|
+
"lint": "eslint . --fix",
|
|
27
|
+
"pretty": "prettier --write . && clang-format -i macos/*.h macos/*.mm"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"react-native",
|
|
31
|
+
"macos",
|
|
32
|
+
"nswindow",
|
|
33
|
+
"multi-window"
|
|
34
|
+
],
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": ">=19.0.0",
|
|
38
|
+
"react-native": ">=0.81.0",
|
|
39
|
+
"react-native-macos": ">=0.81.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@eslint/js": "^9.39.4",
|
|
43
|
+
"eslint": "^9.39.4",
|
|
44
|
+
"prettier": "^3.8.4",
|
|
45
|
+
"typescript": "^5.4.0",
|
|
46
|
+
"typescript-eslint": "^8.62.0"
|
|
47
|
+
},
|
|
48
|
+
"codegenConfig": {
|
|
49
|
+
"name": "RNNSWindowSpec",
|
|
50
|
+
"type": "modules",
|
|
51
|
+
"jsSrcsDir": "spec"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "react-native-nswindow"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.license = package["license"]
|
|
10
|
+
s.authors = { "Jim Lake" => "jim@blueskylabs.com" }
|
|
11
|
+
s.homepage = "https://github.com/jim-lake/react-native-nswindow"
|
|
12
|
+
s.source = { :git => "https://github.com/jim-lake/react-native-nswindow.git", :tag => s.version }
|
|
13
|
+
|
|
14
|
+
s.osx.deployment_target = "14.0"
|
|
15
|
+
s.source_files = "macos/**/*.{h,mm}"
|
|
16
|
+
|
|
17
|
+
install_modules_dependencies(s)
|
|
18
|
+
end
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { TurboModule } from 'react-native';
|
|
2
|
+
import { TurboModuleRegistry } from 'react-native';
|
|
3
|
+
import type { EventEmitter } from 'react-native/Libraries/Types/CodegenTypes';
|
|
4
|
+
|
|
5
|
+
export type TitleBarStyle =
|
|
6
|
+
'default' | 'hidden' | 'hiddenInset' | 'transparent';
|
|
7
|
+
|
|
8
|
+
export type WindowLevel =
|
|
9
|
+
| 'normal'
|
|
10
|
+
| 'floating'
|
|
11
|
+
| 'modalPanel'
|
|
12
|
+
| 'mainMenu'
|
|
13
|
+
| 'statusBar'
|
|
14
|
+
| 'screenSaver';
|
|
15
|
+
|
|
16
|
+
export interface ModifyableWindowProps {
|
|
17
|
+
x?: number;
|
|
18
|
+
y?: number;
|
|
19
|
+
width?: number;
|
|
20
|
+
height?: number;
|
|
21
|
+
minWidth?: number;
|
|
22
|
+
minHeight?: number;
|
|
23
|
+
maxWidth?: number;
|
|
24
|
+
maxHeight?: number;
|
|
25
|
+
center?: boolean;
|
|
26
|
+
|
|
27
|
+
title?: string;
|
|
28
|
+
titleBarStyle?: TitleBarStyle;
|
|
29
|
+
vibrancy?:
|
|
30
|
+
| 'none'
|
|
31
|
+
| 'sidebar'
|
|
32
|
+
| 'menu'
|
|
33
|
+
| 'popover'
|
|
34
|
+
| 'fullScreenUI'
|
|
35
|
+
| 'underWindowBackground'
|
|
36
|
+
| 'hudWindow';
|
|
37
|
+
backgroundColor?: string;
|
|
38
|
+
transparent?: boolean;
|
|
39
|
+
hasShadow?: boolean;
|
|
40
|
+
|
|
41
|
+
resizable?: boolean;
|
|
42
|
+
movable?: boolean;
|
|
43
|
+
minimizable?: boolean;
|
|
44
|
+
closable?: boolean;
|
|
45
|
+
zoomable?: boolean;
|
|
46
|
+
alwaysOnTop?: boolean;
|
|
47
|
+
level?: WindowLevel;
|
|
48
|
+
|
|
49
|
+
show?: boolean;
|
|
50
|
+
focusOnCreate?: boolean;
|
|
51
|
+
autoSaveFrame?: string;
|
|
52
|
+
|
|
53
|
+
stopShouldClose?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export interface WindowProps extends ModifyableWindowProps {
|
|
56
|
+
componentName: string;
|
|
57
|
+
windowName: string;
|
|
58
|
+
initialProps: Object;
|
|
59
|
+
}
|
|
60
|
+
export interface WindowState {
|
|
61
|
+
windowId: string;
|
|
62
|
+
windowName: string;
|
|
63
|
+
x: number;
|
|
64
|
+
y: number;
|
|
65
|
+
width: number;
|
|
66
|
+
height: number;
|
|
67
|
+
isKeyWindow: boolean;
|
|
68
|
+
isMinimized: boolean;
|
|
69
|
+
isFullScreen: boolean;
|
|
70
|
+
isVisible: boolean;
|
|
71
|
+
isOccluded: boolean;
|
|
72
|
+
backingScaleFactor: number;
|
|
73
|
+
screen: Rect | null;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface Rect {
|
|
77
|
+
x: number;
|
|
78
|
+
y: number;
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
}
|
|
82
|
+
export interface Screen {
|
|
83
|
+
frame: Rect;
|
|
84
|
+
visibleFrame: Rect;
|
|
85
|
+
}
|
|
86
|
+
export interface ScreenInfo {
|
|
87
|
+
total: Rect;
|
|
88
|
+
totalVisibleFrame: Rect;
|
|
89
|
+
|
|
90
|
+
screens: Screen[];
|
|
91
|
+
|
|
92
|
+
main: Rect;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export type WindowId = string;
|
|
96
|
+
|
|
97
|
+
export interface WindowMovePayload {
|
|
98
|
+
windowId: string;
|
|
99
|
+
x: number;
|
|
100
|
+
y: number;
|
|
101
|
+
}
|
|
102
|
+
export interface WindowResizePayload {
|
|
103
|
+
windowId: string;
|
|
104
|
+
width: number;
|
|
105
|
+
height: number;
|
|
106
|
+
}
|
|
107
|
+
export interface WindowOcclusionStatePayload {
|
|
108
|
+
windowId: string;
|
|
109
|
+
isVisible: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface Spec extends TurboModule {
|
|
113
|
+
addWindow(props: WindowProps): Promise<string>;
|
|
114
|
+
closeWindow(windowId: string): Promise<void>;
|
|
115
|
+
modifyWindow(windowId: string, props: ModifyableWindowProps): Promise<void>;
|
|
116
|
+
|
|
117
|
+
listWindows(): Promise<string[]>;
|
|
118
|
+
getWindowState(windowId: string): Promise<WindowState>;
|
|
119
|
+
|
|
120
|
+
focusWindow(windowId: string): Promise<void>;
|
|
121
|
+
hideWindow(windowId: string): Promise<void>;
|
|
122
|
+
showWindow(windowId: string): Promise<void>;
|
|
123
|
+
|
|
124
|
+
minimizeWindow(windowId: string): Promise<void>;
|
|
125
|
+
deminimizeWindow(windowId: string): Promise<void>;
|
|
126
|
+
setFullScreen(windowId: string, fullscreen: boolean): Promise<void>;
|
|
127
|
+
|
|
128
|
+
bringToFront(windowId: string): Promise<void>;
|
|
129
|
+
sendToBack(windowId: string): Promise<void>;
|
|
130
|
+
|
|
131
|
+
getScreenInfo(): Promise<ScreenInfo>;
|
|
132
|
+
|
|
133
|
+
readonly onWindowClose: EventEmitter<WindowId>;
|
|
134
|
+
readonly onWindowWillClose: EventEmitter<WindowId>;
|
|
135
|
+
readonly onWindowMove: EventEmitter<WindowMovePayload>;
|
|
136
|
+
readonly onWindowResize: EventEmitter<WindowResizePayload>;
|
|
137
|
+
readonly onWindowFocus: EventEmitter<WindowId>;
|
|
138
|
+
readonly onWindowBlur: EventEmitter<WindowId>;
|
|
139
|
+
readonly onWindowMinimize: EventEmitter<WindowId>;
|
|
140
|
+
readonly onWindowDeminimize: EventEmitter<WindowId>;
|
|
141
|
+
readonly onWindowEnterFullScreen: EventEmitter<WindowId>;
|
|
142
|
+
readonly onWindowExitFullScreen: EventEmitter<WindowId>;
|
|
143
|
+
readonly onWindowOcclusionStateChange: EventEmitter<WindowOcclusionStatePayload>;
|
|
144
|
+
readonly onWindowBackingPropertiesChange: EventEmitter<WindowId>;
|
|
145
|
+
readonly onScreenInfoChange: EventEmitter<void>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('NSWindowModule');
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export { default } from '../spec/NativeNSWindow';
|
|
2
|
+
export type {
|
|
3
|
+
TitleBarStyle,
|
|
4
|
+
WindowLevel,
|
|
5
|
+
WindowProps,
|
|
6
|
+
ModifyableWindowProps,
|
|
7
|
+
WindowState,
|
|
8
|
+
Rect,
|
|
9
|
+
Screen,
|
|
10
|
+
ScreenInfo,
|
|
11
|
+
WindowId,
|
|
12
|
+
WindowMovePayload,
|
|
13
|
+
WindowResizePayload,
|
|
14
|
+
WindowOcclusionStatePayload,
|
|
15
|
+
Spec,
|
|
16
|
+
} from '../spec/NativeNSWindow';
|