Skip to content

Commit b139d41

Browse files
committed
ci: fix macos tests and trusted npm tags
1 parent 3c9b299 commit b139d41

5 files changed

Lines changed: 117 additions & 10 deletions

File tree

.github/workflows/npm_trusted_release.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ on:
4444
required: false
4545
type: string
4646
default: next
47+
npm-tag:
48+
description: "Optional npm dist-tag override for publish, e.g. latest for the RN preview default install"
49+
required: false
50+
type: string
4751
dry-run:
4852
description: "Run release steps without making changes (no git push, no publish)"
4953
required: false
@@ -140,12 +144,14 @@ jobs:
140144
RELEASE_TYPE: ${{ inputs.release-type }}
141145
PACKAGE_VERSION: ${{ inputs.version }}
142146
PREID: ${{ inputs.preid }}
147+
NPM_TAG_OVERRIDE: ${{ inputs.npm-tag }}
143148
TARGET: ${{ matrix.target }}
144149
run: |
145150
set -euo pipefail
146151
release_type="$RELEASE_TYPE"
147152
package_version="$PACKAGE_VERSION"
148153
preid="$PREID"
154+
npm_tag_override="$NPM_TAG_OVERRIDE"
149155
target="$TARGET"
150156
if [ "$target" = "react-native" ]; then
151157
pkg_dir="packages/react-native"
@@ -172,7 +178,20 @@ jobs:
172178
popd >/dev/null
173179
174180
NPM_TAG=$(NPM_VERSION="$NPM_VERSION" node ./scripts/get-npm-tag.js "$npm_tag_target")
175-
if [ -n "$package_version" ] && [ "$release_type" = "prerelease" ] && [ "$NPM_TAG" = "latest" ]; then
181+
if [ -n "$npm_tag_override" ]; then
182+
case "$npm_tag_override" in
183+
*[[:space:]]*)
184+
echo "Invalid npm tag override '$npm_tag_override': dist-tags cannot contain whitespace." >&2
185+
exit 1
186+
;;
187+
esac
188+
if printf '%s\n' "$npm_tag_override" | grep -Eq '^[0-9]+(\.[0-9]+)*$'; then
189+
echo "Invalid npm tag override '$npm_tag_override': dist-tags must not look like semver versions." >&2
190+
exit 1
191+
fi
192+
NPM_TAG="$npm_tag_override"
193+
fi
194+
if [ -n "$package_version" ] && [ "$release_type" = "prerelease" ] && [ -z "$npm_tag_override" ] && [ "$NPM_TAG" = "latest" ]; then
176195
echo "Exact prerelease publishes must include a prerelease identifier (for example 9.0.0-preview.0)." >&2
177196
exit 1
178197
fi
@@ -346,6 +365,7 @@ jobs:
346365
RELEASE_TYPE: ${{ inputs.release-type }}
347366
PACKAGE_VERSION: ${{ inputs.version }}
348367
PREID: ${{ inputs.preid }}
368+
NPM_TAG_OVERRIDE: ${{ inputs.npm-tag }}
349369
DRY_RUN: ${{ inputs.dry-run }}
350370
TARGETS: ${{ needs.matrix.outputs.targets }}
351371
BUILD_RESULT: ${{ needs.build.result }}
@@ -355,6 +375,7 @@ jobs:
355375
echo "Release type: $RELEASE_TYPE"
356376
echo "Exact version: $PACKAGE_VERSION"
357377
echo "Preid: $PREID"
378+
echo "NPM tag override: $NPM_TAG_OVERRIDE"
358379
echo "Dry run: $DRY_RUN"
359380
echo "Targets: $TARGETS"
360381
echo "Build result: $BUILD_RESULT"

NativeScript/ffi/shared/jsi/NativeApiJsiInstall.h

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,10 @@ void InstallNativeApiJsiGlobalSymbols(Runtime& runtime, const char* globalName)
822822
classMembersInstalled = true;
823823
installClassMembers(constructable, nativeClass.__staticMembers, true);
824824
installClassMembers(basePrototypeTarget, nativeClass.__instanceMembers, false);
825+
try {
826+
delete constructable.__nativeApiInstallMembers;
827+
} catch (_) {
828+
}
825829
}
826830
try {
827831
Object.defineProperty(constructable, '__nativeApiInstallMembers', {
@@ -869,6 +873,7 @@ void InstallNativeApiJsiGlobalSymbols(Runtime& runtime, const char* globalName)
869873
constructable.prototype = typeof Proxy === 'function'
870874
? new Proxy(basePrototypeTarget, {
871875
get: function(target, property, receiver) {
876+
installNativeClassMembersIfNeeded();
872877
if (property in target) {
873878
return Reflect.get(target, property, receiver);
874879
}
@@ -902,7 +907,16 @@ void InstallNativeApiJsiGlobalSymbols(Runtime& runtime, const char* globalName)
902907
return true;
903908
},
904909
has: function(target, property) {
910+
installNativeClassMembersIfNeeded();
905911
return property in target;
912+
},
913+
ownKeys: function(target) {
914+
installNativeClassMembersIfNeeded();
915+
return Reflect.ownKeys(target);
916+
},
917+
getOwnPropertyDescriptor: function(target, property) {
918+
installNativeClassMembersIfNeeded();
919+
return Reflect.getOwnPropertyDescriptor(target, property);
906920
}
907921
})
908922
: basePrototypeTarget;
@@ -952,12 +966,27 @@ void InstallNativeApiJsiGlobalSymbols(Runtime& runtime, const char* globalName)
952966
if (property === '__nativeApiClass') {
953967
return nativeClass;
954968
}
969+
if (property === 'toString') {
970+
return function() {
971+
return String(nativeClass);
972+
};
973+
}
974+
if (property === 'hasOwnProperty') {
975+
return function(key) {
976+
installNativeClassMembersIfNeeded();
977+
return Object.prototype.hasOwnProperty.call(target, key);
978+
};
979+
}
955980
if (Object.prototype.hasOwnProperty.call(target, property) ||
956981
property === 'prototype' ||
957982
property === 'length' ||
958983
property === 'name') {
959984
return Reflect.get(target, property, receiver);
960985
}
986+
installNativeClassMembersIfNeeded();
987+
if (Object.prototype.hasOwnProperty.call(target, property)) {
988+
return Reflect.get(target, property, receiver);
989+
}
961990
if (cachedNativeFunctions && cachedNativeFunctions.has(property)) {
962991
return cachedNativeFunctions.get(property);
963992
}
@@ -1015,13 +1044,37 @@ void InstallNativeApiJsiGlobalSymbols(Runtime& runtime, const char* globalName)
10151044
return Reflect.set(target, property, value, receiver);
10161045
},
10171046
has: function(target, property) {
1047+
installNativeClassMembersIfNeeded();
10181048
return property in target || property in nativeClass;
1049+
},
1050+
ownKeys: function(target) {
1051+
installNativeClassMembersIfNeeded();
1052+
return Reflect.ownKeys(target).filter(function(key) {
1053+
return key !== 'new' &&
1054+
key !== 'hasOwnProperty' &&
1055+
key !== '__nativeApiInstallMembers';
1056+
});
1057+
},
1058+
getOwnPropertyDescriptor: function(target, property) {
1059+
installNativeClassMembersIfNeeded();
1060+
return Reflect.getOwnPropertyDescriptor(target, property);
10191061
}
10201062
})
10211063
: constructable;
10221064
if (classWrappers) {
10231065
classWrappers.set(nativeClass, wrapper);
10241066
}
1067+
try {
1068+
var nativeSuperclass = nativeClass.__superclass;
1069+
if (nativeSuperclass && nativeSuperclass !== nativeClass) {
1070+
var superclassWrapper = wrapNativeClass(nativeSuperclass);
1071+
if (superclassWrapper && superclassWrapper !== wrapper &&
1072+
typeof Object.setPrototypeOf === 'function') {
1073+
Object.setPrototypeOf(wrapper, superclassWrapper);
1074+
}
1075+
}
1076+
} catch (_) {
1077+
}
10251078
try {
10261079
api.__rememberClassWrapper(nativeClass, wrapper, constructable.prototype);
10271080
} catch (_) {

NativeScriptRuntime.xcodeproj/project.pbxproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@
613613
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
614614
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
615615
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
616-
CLANG_WARN_STRICT_PROTOTYPES = YES;
616+
CLANG_WARN_STRICT_PROTOTYPES = NO;
617617
CLANG_WARN_SUSPICIOUS_MOVE = YES;
618618
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
619619
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -650,6 +650,7 @@
650650
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
651651
MTL_FAST_MATH = YES;
652652
ONLY_ACTIVE_ARCH = YES;
653+
OTHER_CFLAGS = "-Wno-invalid-version-availability";
653654
OTHER_LDFLAGS = "-ObjC";
654655
PRODUCT_NAME = "$(TARGET_NAME)";
655656
REGISTER_APP_GROUPS = YES;
@@ -689,7 +690,7 @@
689690
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
690691
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
691692
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
692-
CLANG_WARN_STRICT_PROTOTYPES = YES;
693+
CLANG_WARN_STRICT_PROTOTYPES = NO;
693694
CLANG_WARN_SUSPICIOUS_MOVE = YES;
694695
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
695696
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -716,6 +717,7 @@
716717
LOCALIZATION_PREFERS_STRING_CATALOGS = YES;
717718
MTL_ENABLE_DEBUG_INFO = NO;
718719
MTL_FAST_MATH = YES;
720+
OTHER_CFLAGS = "-Wno-invalid-version-availability";
719721
OTHER_LDFLAGS = "-ObjC";
720722
PRODUCT_NAME = "$(TARGET_NAME)";
721723
SDKROOT = iphoneos;

scripts/check_ffi_boundaries.sh

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,37 @@ if [ "${#EXISTING_DIRECT_DIRS[@]}" -eq 0 ]; then
2828
exit 0
2929
fi
3030

31-
if rg -n '\b(napi_|napi_env|napi_value|js_native_api|node_api)\b' \
32-
"${EXISTING_DIRECT_DIRS[@]}" \
33-
-g '*.{h,hh,hpp,c,cc,cpp,m,mm,inc}'; then
31+
search_sources() {
32+
local pattern="$1"
33+
shift
34+
35+
if command -v rg >/dev/null 2>&1; then
36+
rg -n "$pattern" "$@" -g '*.{h,hh,hpp,c,cc,cpp,m,mm,inc}'
37+
return
38+
fi
39+
40+
find "$@" \
41+
-type f \( \
42+
-name '*.h' -o \
43+
-name '*.hh' -o \
44+
-name '*.hpp' -o \
45+
-name '*.c' -o \
46+
-name '*.cc' -o \
47+
-name '*.cpp' -o \
48+
-name '*.m' -o \
49+
-name '*.mm' -o \
50+
-name '*.inc' \
51+
\) -print0 | xargs -0 grep -nE "$pattern"
52+
}
53+
54+
if search_sources '(^|[^[:alnum:]_])(napi_|napi_env|napi_value|js_native_api|node_api)($|[^[:alnum:]_])' \
55+
"${EXISTING_DIRECT_DIRS[@]}"; then
3456
echo "Node-API symbols are not allowed in shared or direct engine FFI folders." >&2
3557
exit 1
3658
fi
3759

38-
if rg -n '\b(EngineDirect|FastNative|HermesFast|V8Fast|JSCFast|QuickJSFast)\b' \
39-
"$ROOT_DIR/NativeScript/ffi/napi" \
40-
-g '*.{h,hh,hpp,c,cc,cpp,m,mm,inc}' \
41-
-g '!GeneratedSignatureDispatch.inc'; then
60+
if search_sources '(^|[^[:alnum:]_])(EngineDirect|FastNative|HermesFast|V8Fast|JSCFast|QuickJSFast)($|[^[:alnum:]_])' \
61+
"$ROOT_DIR/NativeScript/ffi/napi" | grep -v 'GeneratedSignatureDispatch.inc'; then
4262
echo "Direct-engine FFI code is not allowed in ffi/napi." >&2
4363
exit 1
4464
fi

test/runtime/fixtures/Marshalling/TNSObjCTypes.m

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,17 @@ CFTypeRef TNSFunctionWithCreateCFTypeRefReturn() {
5656
}
5757
return (CFAbsoluteTimeGetCurrent() - startedAt) * 1000.0;
5858
}
59+
#else
60+
double TNSRNMeasureNativeUITabBarControllerNew(int iterations, int touchView) {
61+
(void)iterations;
62+
(void)touchView;
63+
return 0;
64+
}
65+
66+
double TNSRNMeasureNativeUIColorFactory(int iterations) {
67+
(void)iterations;
68+
return 0;
69+
}
5970
#endif
6071

6172
@implementation TNSRNDelegateProbe

0 commit comments

Comments
 (0)