@react-native-menu/menu 2.1.2 → 2.2.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/Package.swift +94 -0
- package/lib/commonjs/NativeModuleSpecs/UIMenuNativeComponent.ts +7 -0
- package/lib/commonjs/UIMenuView.android.js +1 -3
- package/lib/commonjs/UIMenuView.android.js.map +1 -1
- package/lib/module/NativeModuleSpecs/UIMenuNativeComponent.ts +7 -0
- package/lib/module/UIMenuView.android.js +1 -2
- package/lib/module/UIMenuView.android.js.map +1 -1
- package/lib/typescript/src/NativeModuleSpecs/UIMenuNativeComponent.d.ts.map +1 -1
- package/lib/typescript/src/UIMenuView.android.d.ts.map +1 -1
- package/package.json +12 -5
- package/spm-headers/RCTBridge.h +1 -0
- package/spm-headers/RCTFabricComponentsPlugins.h +1 -0
- package/spm-headers/public/module.modulemap +4 -0
- package/spm-headers/react_native_menu-Swift.h +36 -0
- package/spm-support/Imports.swift +2 -0
- package/spm-support/SwiftHeaderPin.swift +75 -0
- package/src/NativeModuleSpecs/UIMenuNativeComponent.ts +7 -0
- package/src/UIMenuView.android.tsx +1 -1
package/Package.swift
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
// swift-tools-version: 6.0
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
import PackageDescription
|
|
5
|
+
|
|
6
|
+
// React Native evaluates this package through build/generated/autolinking/libs/.
|
|
7
|
+
let reactHeaders: [Target.Dependency] = [
|
|
8
|
+
.product(name: "ReactHeaders", package: "ReactNative"),
|
|
9
|
+
.product(name: "ReactNativeHeaders", package: "ReactNative"),
|
|
10
|
+
.product(name: "ReactNativeDependenciesHeaders", package: "ReactNative"),
|
|
11
|
+
.product(name: "ReactAppHeaders", package: "React-GeneratedCode"),
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
// The Swift import shim lives outside ios/. Keep unrelated repository and npm
|
|
15
|
+
// package contents out of SwiftPM's resource discovery.
|
|
16
|
+
let usedRootEntries: Set<String> = ["ios", "spm-support", "spm-headers", "Package.swift"]
|
|
17
|
+
// `try?` rather than `try!`: a manifest that traps reports a Swift fatal error
|
|
18
|
+
// instead of a SwiftPM diagnostic, which is a miserable thing to debug.
|
|
19
|
+
let unusedRootEntries = ((try? FileManager.default.contentsOfDirectory(atPath: Context.packageDirectory)) ?? [])
|
|
20
|
+
.filter { !usedRootEntries.contains($0) }
|
|
21
|
+
.sorted()
|
|
22
|
+
|
|
23
|
+
// Discover sources as folders, splitting the podspec's native and Swift files.
|
|
24
|
+
// Exclude projects and non-source files from both targets.
|
|
25
|
+
let iosDirectory = URL(fileURLWithPath: Context.packageDirectory).appendingPathComponent("ios")
|
|
26
|
+
let iosEntries = ((try? FileManager.default.subpathsOfDirectory(atPath: iosDirectory.path)) ?? [])
|
|
27
|
+
.filter { !$0.contains(".xcodeproj/") }
|
|
28
|
+
func unusedIosEntries(sourceExtensions: Set<String>) -> [String] {
|
|
29
|
+
iosEntries.filter { entry in
|
|
30
|
+
let url = iosDirectory.appendingPathComponent(entry)
|
|
31
|
+
if url.pathExtension == "xcodeproj" { return true }
|
|
32
|
+
// An entry that cannot be stat'd -- a dangling symlink, say -- counts as
|
|
33
|
+
// a file so it stays excludable. Excluding a directory would drop
|
|
34
|
+
// everything inside it.
|
|
35
|
+
let isDirectory = (try? url.resourceValues(forKeys: [.isDirectoryKey]))?.isDirectory ?? false
|
|
36
|
+
return !isDirectory && (!sourceExtensions.contains(url.pathExtension)
|
|
37
|
+
|| entry == "Menu-Bridging-Header.h")
|
|
38
|
+
}
|
|
39
|
+
.map { "ios/" + $0 }
|
|
40
|
+
.sorted()
|
|
41
|
+
}
|
|
42
|
+
let unusedSwiftIosEntries = unusedIosEntries(sourceExtensions: ["swift"])
|
|
43
|
+
let unusedObjCIosEntries = unusedIosEntries(sourceExtensions: ["h", "m", "mm"])
|
|
44
|
+
|
|
45
|
+
let package = Package(
|
|
46
|
+
name: "react_native_menu",
|
|
47
|
+
platforms: [.iOS("15.1")],
|
|
48
|
+
products: [
|
|
49
|
+
.library(name: "react_native_menu", targets: ["react_native_menu", "ReactNativeMenuObjC"]),
|
|
50
|
+
],
|
|
51
|
+
dependencies: [
|
|
52
|
+
.package(name: "ReactNative", path: "../../../../xcframeworks"),
|
|
53
|
+
.package(name: "React-GeneratedCode", path: "../../../ios"),
|
|
54
|
+
],
|
|
55
|
+
targets: [
|
|
56
|
+
// Preserve the CocoaPods Swift module name. Swift depends on React only;
|
|
57
|
+
// the Fabric adapter below depends on Swift, avoiding a target cycle.
|
|
58
|
+
.target(
|
|
59
|
+
name: "react_native_menu",
|
|
60
|
+
dependencies: reactHeaders,
|
|
61
|
+
path: ".",
|
|
62
|
+
exclude: unusedRootEntries + ["spm-headers"] + unusedSwiftIosEntries,
|
|
63
|
+
sources: ["ios/Shared", "ios/OldArch", "ios/NewArch", "spm-support"]
|
|
64
|
+
),
|
|
65
|
+
.target(
|
|
66
|
+
name: "ReactNativeMenuObjC",
|
|
67
|
+
dependencies: [.target(name: "react_native_menu")] + reactHeaders,
|
|
68
|
+
// Root the target here so its empty public module stays outside ios/.
|
|
69
|
+
path: ".",
|
|
70
|
+
exclude: unusedRootEntries + ["spm-support"] + unusedObjCIosEntries,
|
|
71
|
+
// Name the source directories rather than all of ios/: a stray .h,
|
|
72
|
+
// .m or .mm anywhere under ios/ (stale codegen output under
|
|
73
|
+
// ios/build/, say, in a consumer using this as a path dependency)
|
|
74
|
+
// would otherwise be compiled into this target.
|
|
75
|
+
sources: ["ios/MenuViewManager.mm", "ios/Shared", "ios/OldArch", "ios/NewArch"],
|
|
76
|
+
// Required: without it SwiftPM looks for a default include/ folder, which this target does not have.
|
|
77
|
+
publicHeadersPath: "spm-headers/public",
|
|
78
|
+
cSettings: [
|
|
79
|
+
.define("RCT_NEW_ARCH_ENABLED", to: "1"),
|
|
80
|
+
.headerSearchPath("ios/NewArch"),
|
|
81
|
+
.headerSearchPath("spm-headers"),
|
|
82
|
+
],
|
|
83
|
+
cxxSettings: [
|
|
84
|
+
.define("RCT_NEW_ARCH_ENABLED", to: "1"),
|
|
85
|
+
.define("DEBUG", .when(configuration: .debug)),
|
|
86
|
+
.define("NDEBUG", .when(configuration: .release)),
|
|
87
|
+
.headerSearchPath("ios/NewArch"),
|
|
88
|
+
.headerSearchPath("spm-headers"),
|
|
89
|
+
]
|
|
90
|
+
),
|
|
91
|
+
],
|
|
92
|
+
swiftLanguageModes: [.v5],
|
|
93
|
+
cxxLanguageStandard: .cxx20
|
|
94
|
+
)
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// biome-ignore-start lint/suspicious/noReactNativeDeepImports: this is a codegen spec file.
|
|
2
|
+
// React Native's codegen parses these imports directly and expects CodegenTypes and
|
|
3
|
+
// codegenNativeComponent on these exact paths. react-native/index.js does re-export
|
|
4
|
+
// codegenNativeComponent, but rewriting an import that codegen parses risks breaking native
|
|
5
|
+
// builds for no benefit -- see the note on this file in CLAUDE.md. Scoped to this import
|
|
6
|
+
// block rather than the whole file, so accidental deep imports below are still caught.
|
|
1
7
|
import type {
|
|
2
8
|
DirectEventHandler,
|
|
3
9
|
Int32,
|
|
@@ -5,6 +11,7 @@ import type {
|
|
|
5
11
|
} from "react-native/Libraries/Types/CodegenTypes";
|
|
6
12
|
import type { HostComponent, ViewProps } from "react-native";
|
|
7
13
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
14
|
+
// biome-ignore-end lint/suspicious/noReactNativeDeepImports: end of the codegen import block.
|
|
8
15
|
|
|
9
16
|
/*
|
|
10
17
|
Caution, those below are not just typescript types.
|
|
@@ -6,11 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _react = require("react");
|
|
9
|
-
var _codegenNativeCommands = _interopRequireDefault(require("react-native/Libraries/Utilities/codegenNativeCommands"));
|
|
10
9
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
10
|
const NativeMenuComponent = (0, _reactNative.requireNativeComponent)("MenuView");
|
|
13
|
-
const Commands = (0,
|
|
11
|
+
const Commands = (0, _reactNative.codegenNativeCommands)({
|
|
14
12
|
supportedCommands: ["show"]
|
|
15
13
|
});
|
|
16
14
|
const MenuComponent = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_react","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_react","_jsxRuntime","NativeMenuComponent","requireNativeComponent","Commands","codegenNativeCommands","supportedCommands","MenuComponent","forwardRef","props","ref","nativeRef","useRef","useImperativeHandle","show","current","isFabric","global","nativeFabricUIManager","node","findNodeHandle","command","UIManager","getViewManagerConfig","dispatchViewManagerCommand","undefined","jsx","_default","exports","default"],"sourceRoot":"../../src","sources":["UIMenuView.android.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAQA,IAAAC,MAAA,GAAAD,OAAA;AAAgE,IAAAE,WAAA,GAAAF,OAAA;AAEhE,MAAMG,mBAAmB,GAAG,IAAAC,mCAAsB,EACjD,UACD,CAA4C;AAI5C,MAAMC,QAAQ,GAAG,IAAAC,kCAAqB,EAEnC;EACFC,iBAAiB,EAAE,CAAC,MAAM;AAC3B,CAAC,CAAC;AAEF,MAAMC,aAAa,gBAAG,IAAAC,iBAAU,EAC/B,CAACC,KAAK,EAAEC,GAAG,KAAK;EACf,MAAMC,SAAS,GAAG,IAAAC,aAAM,EAAC,IAAI,CAAC;EAE9B,IAAAC,0BAAmB,EAClBH,GAAG,EACH,OAAO;IACNI,IAAI,EAAEA,CAAA,KAAM;MACX,IAAIH,SAAS,CAACI,OAAO,EAAE;QACtB;QACA,MAAMC,QAAQ,GAAG,CAAC,CAAEC,MAAM,CAASC,qBAAqB;QAExD,IAAIF,QAAQ,EAAE;UACbZ,QAAQ,CAACU,IAAI,CAACH,SAAS,CAACI,OAAO,CAAC;QACjC,CAAC,MAAM;UACN,MAAMI,IAAI,GAAG,IAAAC,2BAAc,EAACT,SAAS,CAACI,OAAO,CAAC;UAC9C,MAAMM,OAAO,GACZC,sBAAS,CAACC,oBAAoB,CAAC,UAAU,CAAC,CAACnB,QAAQ,CAACU,IAAI;UAEzDQ,sBAAS,CAACE,0BAA0B,CAACL,IAAI,EAAEE,OAAO,EAAEI,SAAS,CAAC;QAC/D;MACD;IACD;EACD,CAAC,CAAC,EACF,EACD,CAAC;EAED,oBAAO,IAAAxB,WAAA,CAAAyB,GAAA,EAACxB,mBAAmB;IAAA,GAAKO,KAAK;IAAEC,GAAG,EAAEC;EAAU,CAAE,CAAC;AAC1D,CACD,CAAC;AAAC,IAAAgB,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEatB,aAAa","ignoreList":[]}
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// biome-ignore-start lint/suspicious/noReactNativeDeepImports: this is a codegen spec file.
|
|
2
|
+
// React Native's codegen parses these imports directly and expects CodegenTypes and
|
|
3
|
+
// codegenNativeComponent on these exact paths. react-native/index.js does re-export
|
|
4
|
+
// codegenNativeComponent, but rewriting an import that codegen parses risks breaking native
|
|
5
|
+
// builds for no benefit -- see the note on this file in CLAUDE.md. Scoped to this import
|
|
6
|
+
// block rather than the whole file, so accidental deep imports below are still caught.
|
|
1
7
|
import type {
|
|
2
8
|
DirectEventHandler,
|
|
3
9
|
Int32,
|
|
@@ -5,6 +11,7 @@ import type {
|
|
|
5
11
|
} from "react-native/Libraries/Types/CodegenTypes";
|
|
6
12
|
import type { HostComponent, ViewProps } from "react-native";
|
|
7
13
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
14
|
+
// biome-ignore-end lint/suspicious/noReactNativeDeepImports: end of the codegen import block.
|
|
8
15
|
|
|
9
16
|
/*
|
|
10
17
|
Caution, those below are not just typescript types.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { findNodeHandle, requireNativeComponent, UIManager } from "react-native";
|
|
3
|
+
import { codegenNativeCommands, findNodeHandle, requireNativeComponent, UIManager } from "react-native";
|
|
4
4
|
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
5
|
-
import codegenNativeCommands from "react-native/Libraries/Utilities/codegenNativeCommands";
|
|
6
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
6
|
const NativeMenuComponent = requireNativeComponent("MenuView");
|
|
8
7
|
const Commands = codegenNativeCommands({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["findNodeHandle","requireNativeComponent","UIManager","forwardRef","useImperativeHandle","useRef","
|
|
1
|
+
{"version":3,"names":["codegenNativeCommands","findNodeHandle","requireNativeComponent","UIManager","forwardRef","useImperativeHandle","useRef","jsx","_jsx","NativeMenuComponent","Commands","supportedCommands","MenuComponent","props","ref","nativeRef","show","current","isFabric","global","nativeFabricUIManager","node","command","getViewManagerConfig","dispatchViewManagerCommand","undefined"],"sourceRoot":"../../src","sources":["UIMenuView.android.tsx"],"mappings":";;AAAA,SACCA,qBAAqB,EACrBC,cAAc,EAEdC,sBAAsB,EACtBC,SAAS,QACH,cAAc;AAErB,SAASC,UAAU,EAAEC,mBAAmB,EAAEC,MAAM,QAAQ,OAAO;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAEhE,MAAMC,mBAAmB,GAAGP,sBAAsB,CACjD,UACD,CAA4C;AAI5C,MAAMQ,QAAQ,GAAGV,qBAAqB,CAEnC;EACFW,iBAAiB,EAAE,CAAC,MAAM;AAC3B,CAAC,CAAC;AAEF,MAAMC,aAAa,gBAAGR,UAAU,CAC/B,CAACS,KAAK,EAAEC,GAAG,KAAK;EACf,MAAMC,SAAS,GAAGT,MAAM,CAAC,IAAI,CAAC;EAE9BD,mBAAmB,CAClBS,GAAG,EACH,OAAO;IACNE,IAAI,EAAEA,CAAA,KAAM;MACX,IAAID,SAAS,CAACE,OAAO,EAAE;QACtB;QACA,MAAMC,QAAQ,GAAG,CAAC,CAAEC,MAAM,CAASC,qBAAqB;QAExD,IAAIF,QAAQ,EAAE;UACbR,QAAQ,CAACM,IAAI,CAACD,SAAS,CAACE,OAAO,CAAC;QACjC,CAAC,MAAM;UACN,MAAMI,IAAI,GAAGpB,cAAc,CAACc,SAAS,CAACE,OAAO,CAAC;UAC9C,MAAMK,OAAO,GACZnB,SAAS,CAACoB,oBAAoB,CAAC,UAAU,CAAC,CAACb,QAAQ,CAACM,IAAI;UAEzDb,SAAS,CAACqB,0BAA0B,CAACH,IAAI,EAAEC,OAAO,EAAEG,SAAS,CAAC;QAC/D;MACD;IACD;EACD,CAAC,CAAC,EACF,EACD,CAAC;EAED,oBAAOjB,IAAA,CAACC,mBAAmB;IAAA,GAAKI,KAAK;IAAEC,GAAG,EAAEC;EAAU,CAAE,CAAC;AAC1D,CACD,CAAC;AAED,eAAeH,aAAa","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIMenuNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/NativeModuleSpecs/UIMenuNativeComponent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UIMenuNativeComponent.d.ts","sourceRoot":"","sources":["../../../../src/NativeModuleSpecs/UIMenuNativeComponent.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EACX,kBAAkB,EAClB,KAAK,EACL,WAAW,EACX,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAa7D,KAAK,SAAS,GAAG;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE;QACZ,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;CACF,CAAC;AACF,KAAK,UAAU,GAAG;IACjB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,KAAK,CAAC;IACnB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE;QACZ,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,MAAM,CAAC,EAAE,OAAO,CAAC;KACjB,CAAC;IACF,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;CAC9B,CAAC;AACF,MAAM,WAAW,WAAY,SAAQ,SAAS;IAC7C,aAAa,CAAC,EAAE,kBAAkB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,WAAW,CAAC,EAAE,kBAAkB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACpD,UAAU,CAAC,EAAE,kBAAkB,CAAC;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,OAAO,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,OAAO,EAAE;QACR,GAAG,EAAE,KAAK,CAAC;QACX,MAAM,EAAE,KAAK,CAAC;QACd,IAAI,EAAE,KAAK,CAAC;QACZ,KAAK,EAAE,KAAK,CAAC;KACb,CAAC;CACF;wBAII,aAAa,CAAC,WAAW,CAAC;AAF/B,wBAEgC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIMenuView.android.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.android.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"UIMenuView.android.d.ts","sourceRoot":"","sources":["../../../src/UIMenuView.android.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAe1E,QAAA,MAAM,aAAa,oIA6BlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-menu/menu",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "UIMenu component for react-native",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"android",
|
|
14
14
|
"ios",
|
|
15
15
|
"cpp",
|
|
16
|
+
"Package.swift",
|
|
17
|
+
"spm-support",
|
|
18
|
+
"spm-headers",
|
|
16
19
|
"react-native-menu.podspec",
|
|
17
20
|
"!lib/typescript/example",
|
|
18
21
|
"!**/__tests__",
|
|
@@ -28,6 +31,7 @@
|
|
|
28
31
|
"pods": "cd example && pod-install --quiet",
|
|
29
32
|
"prepare": "bob build",
|
|
30
33
|
"release": "release-it",
|
|
34
|
+
"spm:check": "node scripts/check-spm.mjs",
|
|
31
35
|
"start": "react-native start",
|
|
32
36
|
"test": "jest",
|
|
33
37
|
"typescript": "tsc --noEmit",
|
|
@@ -49,12 +53,12 @@
|
|
|
49
53
|
},
|
|
50
54
|
"homepage": "https://github.com/react-native-menu/menu#readme",
|
|
51
55
|
"devDependencies": {
|
|
52
|
-
"@biomejs/biome": "
|
|
56
|
+
"@biomejs/biome": "2.6.8",
|
|
53
57
|
"@callstack/react-native-visionos": "^0.79.6",
|
|
54
58
|
"@react-native-community/cli": "^20.0.2",
|
|
55
59
|
"@react-native/babel-preset": "^0.81.1",
|
|
56
60
|
"@react-native/metro-config": "0.81.1",
|
|
57
|
-
"@release-it/conventional-changelog": "^
|
|
61
|
+
"@release-it/conventional-changelog": "^12.0.2",
|
|
58
62
|
"@rnx-kit/metro-config": "^2.1.1",
|
|
59
63
|
"@types/jest": "^29.1.2",
|
|
60
64
|
"@types/react": "^19.1.12",
|
|
@@ -65,7 +69,7 @@
|
|
|
65
69
|
"react-native": "^0.81.1",
|
|
66
70
|
"react-native-builder-bob": "^0.44.1",
|
|
67
71
|
"react-native-test-app": "^4.4.9",
|
|
68
|
-
"release-it": "^
|
|
72
|
+
"release-it": "^21.1.2",
|
|
69
73
|
"typescript": "5.9.3"
|
|
70
74
|
},
|
|
71
75
|
"peerDependencies": {
|
|
@@ -110,7 +114,10 @@
|
|
|
110
114
|
"access": "public"
|
|
111
115
|
},
|
|
112
116
|
"volta": {
|
|
113
|
-
"node": "22.
|
|
117
|
+
"node": "22.23.5"
|
|
118
|
+
},
|
|
119
|
+
"swiftpmConfig": {
|
|
120
|
+
"name": "react_native_menu"
|
|
114
121
|
},
|
|
115
122
|
"codegenConfig": {
|
|
116
123
|
"name": "RNMenuViewSpec",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#import <React/RCTBridge.h>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Private SwiftPM declarations for the Fabric adapter. Xcode's generated
|
|
2
|
+
// react_native_menu-Swift.h is exposed through a module map, but C++ module
|
|
3
|
+
// imports are disabled and its directory is not an ObjC++ header search path.
|
|
4
|
+
// Keep this narrow interface in sync with that header and ios/NewArch/*.swift.
|
|
5
|
+
// The Swift classes use explicit @objc names, so these declarations resolve to
|
|
6
|
+
// their implementations without a Swift -> ObjC target dependency.
|
|
7
|
+
#pragma once
|
|
8
|
+
#import <UIKit/UIKit.h>
|
|
9
|
+
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
|
+
__attribute__((objc_runtime_name("_TtP17react_native_menu32FabricViewImplementationProtocol_")))
|
|
12
|
+
@protocol FabricViewImplementationProtocol
|
|
13
|
+
@property (nonatomic, copy, nullable) NSArray<NSDictionary *> *actions;
|
|
14
|
+
@property (nonatomic, strong, nullable) NSString *title;
|
|
15
|
+
@property (nonatomic, strong, nullable) NSString *themeVariant;
|
|
16
|
+
@property (nonatomic) BOOL shouldOpenOnLongPress;
|
|
17
|
+
@property (nonatomic, copy, nullable) void (^onPressAction)(NSString *);
|
|
18
|
+
@property (nonatomic, copy, nullable) void (^onCloseMenu)(void);
|
|
19
|
+
@property (nonatomic, copy, nullable) void (^onOpenMenu)(void);
|
|
20
|
+
@optional
|
|
21
|
+
@property (nonatomic) UIEdgeInsets hitSlop;
|
|
22
|
+
@end
|
|
23
|
+
|
|
24
|
+
// The superclasses are flattened on purpose: MenuView.mm only ever reaches
|
|
25
|
+
// protocol members and UIKit ones, so mirroring MenuViewImplementation and
|
|
26
|
+
// ActionSheetView here would double the surface that can drift. If MenuView.mm
|
|
27
|
+
// ever needs a member declared on one of those bases, mirror the base class
|
|
28
|
+
// rather than widening the protocol. Availability has to match the Swift
|
|
29
|
+
// declarations, though -- calling an iOS 14 only class outside an availability
|
|
30
|
+
// check does not compile. scripts/check-spm.mjs enforces both halves.
|
|
31
|
+
API_AVAILABLE(ios(14.0))
|
|
32
|
+
@interface FabricMenuViewImplementation : UIButton <FabricViewImplementationProtocol>
|
|
33
|
+
@end
|
|
34
|
+
@interface FabricActionSheetView : UIView <FabricViewImplementationProtocol>
|
|
35
|
+
@end
|
|
36
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Pins the Swift API mirrored by spm-headers/react_native_menu-Swift.h.
|
|
2
|
+
// If this file fails to compile, update both files together.
|
|
3
|
+
import UIKit
|
|
4
|
+
|
|
5
|
+
// Swift cannot check explicit @objc class/member names (#selector follows the
|
|
6
|
+
// current name) or the protocol's mangled runtime name at compile time.
|
|
7
|
+
|
|
8
|
+
private let _menuBase: (UIButton & FabricViewImplementationProtocol).Type = FabricMenuViewImplementation.self
|
|
9
|
+
private let _sheetBase: (UIView & FabricViewImplementationProtocol).Type = FabricActionSheetView.self
|
|
10
|
+
|
|
11
|
+
private let _protocol_actions: ReferenceWritableKeyPath<any FabricViewImplementationProtocol, [NSDictionary]?> = \.actions
|
|
12
|
+
private let _protocol_title: ReferenceWritableKeyPath<any FabricViewImplementationProtocol, NSString?> = \.title
|
|
13
|
+
private let _protocol_themeVariant: ReferenceWritableKeyPath<any FabricViewImplementationProtocol, NSString?> = \.themeVariant
|
|
14
|
+
private let _protocol_shouldOpenOnLongPress: ReferenceWritableKeyPath<any FabricViewImplementationProtocol, Bool> = \.shouldOpenOnLongPress
|
|
15
|
+
private let _protocol_onPressAction: ReferenceWritableKeyPath<any FabricViewImplementationProtocol, ((String) -> Void)?> = \.onPressAction
|
|
16
|
+
private let _protocol_onCloseMenu: ReferenceWritableKeyPath<any FabricViewImplementationProtocol, (() -> Void)?> = \.onCloseMenu
|
|
17
|
+
private let _protocol_onOpenMenu: ReferenceWritableKeyPath<any FabricViewImplementationProtocol, (() -> Void)?> = \.onOpenMenu
|
|
18
|
+
|
|
19
|
+
private let _menu_actions: ReferenceWritableKeyPath<FabricMenuViewImplementation, [NSDictionary]?> = \.actions
|
|
20
|
+
private let _menu_title: ReferenceWritableKeyPath<FabricMenuViewImplementation, NSString?> = \.title
|
|
21
|
+
private let _menu_themeVariant: ReferenceWritableKeyPath<FabricMenuViewImplementation, NSString?> = \.themeVariant
|
|
22
|
+
private let _menu_shouldOpenOnLongPress: ReferenceWritableKeyPath<FabricMenuViewImplementation, Bool> = \.shouldOpenOnLongPress
|
|
23
|
+
private let _menu_onPressAction: ReferenceWritableKeyPath<FabricMenuViewImplementation, ((String) -> Void)?> = \.onPressAction
|
|
24
|
+
private let _menu_onCloseMenu: ReferenceWritableKeyPath<FabricMenuViewImplementation, (() -> Void)?> = \.onCloseMenu
|
|
25
|
+
private let _menu_onOpenMenu: ReferenceWritableKeyPath<FabricMenuViewImplementation, (() -> Void)?> = \.onOpenMenu
|
|
26
|
+
private let _menu_hitSlop: ReferenceWritableKeyPath<FabricMenuViewImplementation, UIEdgeInsets> = \.hitSlop
|
|
27
|
+
|
|
28
|
+
private let _menu_selectors: [Selector] = [
|
|
29
|
+
#selector(getter: FabricMenuViewImplementation.actions),
|
|
30
|
+
#selector(setter: FabricMenuViewImplementation.actions),
|
|
31
|
+
#selector(getter: FabricMenuViewImplementation.title),
|
|
32
|
+
#selector(setter: FabricMenuViewImplementation.title),
|
|
33
|
+
#selector(getter: FabricMenuViewImplementation.themeVariant),
|
|
34
|
+
#selector(setter: FabricMenuViewImplementation.themeVariant),
|
|
35
|
+
#selector(getter: FabricMenuViewImplementation.shouldOpenOnLongPress),
|
|
36
|
+
#selector(setter: FabricMenuViewImplementation.shouldOpenOnLongPress),
|
|
37
|
+
#selector(getter: FabricMenuViewImplementation.onPressAction),
|
|
38
|
+
#selector(setter: FabricMenuViewImplementation.onPressAction),
|
|
39
|
+
#selector(getter: FabricMenuViewImplementation.onCloseMenu),
|
|
40
|
+
#selector(setter: FabricMenuViewImplementation.onCloseMenu),
|
|
41
|
+
#selector(getter: FabricMenuViewImplementation.onOpenMenu),
|
|
42
|
+
#selector(setter: FabricMenuViewImplementation.onOpenMenu),
|
|
43
|
+
#selector(getter: FabricMenuViewImplementation.hitSlop),
|
|
44
|
+
#selector(setter: FabricMenuViewImplementation.hitSlop),
|
|
45
|
+
]
|
|
46
|
+
|
|
47
|
+
private let _sheet_actions: ReferenceWritableKeyPath<FabricActionSheetView, [NSDictionary]?> = \.actions
|
|
48
|
+
private let _sheet_title: ReferenceWritableKeyPath<FabricActionSheetView, NSString?> = \.title
|
|
49
|
+
private let _sheet_themeVariant: ReferenceWritableKeyPath<FabricActionSheetView, NSString?> = \.themeVariant
|
|
50
|
+
private let _sheet_shouldOpenOnLongPress: ReferenceWritableKeyPath<FabricActionSheetView, Bool> = \.shouldOpenOnLongPress
|
|
51
|
+
private let _sheet_onPressAction: ReferenceWritableKeyPath<FabricActionSheetView, ((String) -> Void)?> = \.onPressAction
|
|
52
|
+
private let _sheet_onCloseMenu: ReferenceWritableKeyPath<FabricActionSheetView, (() -> Void)?> = \.onCloseMenu
|
|
53
|
+
private let _sheet_onOpenMenu: ReferenceWritableKeyPath<FabricActionSheetView, (() -> Void)?> = \.onOpenMenu
|
|
54
|
+
|
|
55
|
+
private let _sheet_selectors: [Selector] = [
|
|
56
|
+
#selector(getter: FabricActionSheetView.actions),
|
|
57
|
+
#selector(setter: FabricActionSheetView.actions),
|
|
58
|
+
#selector(getter: FabricActionSheetView.title),
|
|
59
|
+
#selector(setter: FabricActionSheetView.title),
|
|
60
|
+
#selector(getter: FabricActionSheetView.themeVariant),
|
|
61
|
+
#selector(setter: FabricActionSheetView.themeVariant),
|
|
62
|
+
#selector(getter: FabricActionSheetView.shouldOpenOnLongPress),
|
|
63
|
+
#selector(setter: FabricActionSheetView.shouldOpenOnLongPress),
|
|
64
|
+
#selector(getter: FabricActionSheetView.onPressAction),
|
|
65
|
+
#selector(setter: FabricActionSheetView.onPressAction),
|
|
66
|
+
#selector(getter: FabricActionSheetView.onCloseMenu),
|
|
67
|
+
#selector(setter: FabricActionSheetView.onCloseMenu),
|
|
68
|
+
#selector(getter: FabricActionSheetView.onOpenMenu),
|
|
69
|
+
#selector(setter: FabricActionSheetView.onOpenMenu),
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
private let _protocol_hitSlopSelectors: [Selector] = [
|
|
73
|
+
#selector(getter: FabricViewImplementationProtocol.hitSlop),
|
|
74
|
+
#selector(setter: FabricViewImplementationProtocol.hitSlop),
|
|
75
|
+
]
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// biome-ignore-start lint/suspicious/noReactNativeDeepImports: this is a codegen spec file.
|
|
2
|
+
// React Native's codegen parses these imports directly and expects CodegenTypes and
|
|
3
|
+
// codegenNativeComponent on these exact paths. react-native/index.js does re-export
|
|
4
|
+
// codegenNativeComponent, but rewriting an import that codegen parses risks breaking native
|
|
5
|
+
// builds for no benefit -- see the note on this file in CLAUDE.md. Scoped to this import
|
|
6
|
+
// block rather than the whole file, so accidental deep imports below are still caught.
|
|
1
7
|
import type {
|
|
2
8
|
DirectEventHandler,
|
|
3
9
|
Int32,
|
|
@@ -5,6 +11,7 @@ import type {
|
|
|
5
11
|
} from "react-native/Libraries/Types/CodegenTypes";
|
|
6
12
|
import type { HostComponent, ViewProps } from "react-native";
|
|
7
13
|
import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
|
|
14
|
+
// biome-ignore-end lint/suspicious/noReactNativeDeepImports: end of the codegen import block.
|
|
8
15
|
|
|
9
16
|
/*
|
|
10
17
|
Caution, those below are not just typescript types.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
+
codegenNativeCommands,
|
|
2
3
|
findNodeHandle,
|
|
3
4
|
type HostComponent,
|
|
4
5
|
requireNativeComponent,
|
|
@@ -6,7 +7,6 @@ import {
|
|
|
6
7
|
} from "react-native";
|
|
7
8
|
import type { MenuComponentRef, NativeMenuComponentProps } from "./types";
|
|
8
9
|
import { forwardRef, useImperativeHandle, useRef } from "react";
|
|
9
|
-
import codegenNativeCommands from "react-native/Libraries/Utilities/codegenNativeCommands";
|
|
10
10
|
|
|
11
11
|
const NativeMenuComponent = requireNativeComponent(
|
|
12
12
|
"MenuView",
|