10.9提交
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportConfig.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface BaseReportData : NSObject
|
||||
|
||||
@property(nonatomic, strong) NSString *appKey;
|
||||
// 用户版本号
|
||||
@property(nonatomic, strong) NSString *version;
|
||||
// 组件名称,如 QChatKit, ContactKit, CallKit
|
||||
@property(nonatomic, strong) NSString *component;
|
||||
// 应用平台 iOS、MAC 等
|
||||
@property(nonatomic, strong) NSString *platform;
|
||||
// 系统时间戳
|
||||
@property(nonatomic, assign) NSInteger timeStamp;
|
||||
// Rtc SDK 版本
|
||||
@property(nonatomic, strong) NSString *nertcVersion;
|
||||
// IM SDK 版本
|
||||
@property(nonatomic, strong) NSString *imVersion;
|
||||
// 上报类型,可根据需要统计的特性填写,便于统计检索
|
||||
@property(nonatomic, strong) NSString *reportType;
|
||||
// 上报渠道
|
||||
@property(nonatomic, strong) NSString *channel;
|
||||
// 上报渠道
|
||||
@property(nonatomic, strong) NSString *framework;
|
||||
// 上报的内容
|
||||
@property(nonatomic, strong) id data;
|
||||
|
||||
- (instancetype)init;
|
||||
|
||||
- (instancetype)initWithConfig:(ReportConfig *)config;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NECoreApiEvent : NSObject <NECoreEvent>
|
||||
|
||||
/// 用户标识
|
||||
@property(nonatomic, copy) NSString *userId;
|
||||
/// ID标识1
|
||||
@property(nonatomic, copy) NSString *id1;
|
||||
/// ID标识2
|
||||
@property(nonatomic, copy) NSString *id2;
|
||||
/// 额外可带信息
|
||||
@property(nonatomic, copy) NSString *extension;
|
||||
|
||||
/// 创建一个API埋点对象
|
||||
/// - Parameters:
|
||||
/// - methodName: API名称
|
||||
/// - params: API参数
|
||||
- (instancetype)initWithMethodName:(NSString *)methodName params:(NSDictionary *__nullable)params;
|
||||
|
||||
/// 设置API埋点的结果
|
||||
/// - Parameters:
|
||||
/// - code: API调用结果
|
||||
/// - message: API调用结果描述
|
||||
- (void)setResult:(NSInteger)code message:(NSString *__nullable)message;
|
||||
|
||||
/// 强制设置字符串类型的params,调用这个接口后通过init传入的params将失效
|
||||
/// - Parameter params: API参数
|
||||
- (void)setParamsForce:(NSString *_Nonnull)params;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,34 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NECoreTimeConsumingOperation : NSObject
|
||||
- (void)setResult:(NSInteger)code
|
||||
message:(NSString *__nullable)message
|
||||
requestId:(NSString *__nullable)requestId
|
||||
serverCost:(double)serverCost;
|
||||
- (void)setParams:(NSDictionary *)params;
|
||||
- (void)addParams:(NSString *)key value:(id)value;
|
||||
- (void)removeParams:(NSString *)key;
|
||||
- (NSDictionary *)toMap;
|
||||
@end
|
||||
|
||||
@interface NECoreIntervalStep : NECoreTimeConsumingOperation
|
||||
@property(nonatomic, copy) NSString *name;
|
||||
- (instancetype)initWithName:(NSString *)name;
|
||||
@end
|
||||
|
||||
@interface NECoreIntervalEvent : NECoreTimeConsumingOperation <NECoreEvent>
|
||||
- (instancetype)initWithEventId:(NSString *)eventId;
|
||||
|
||||
- (NECoreIntervalStep *)beginStep:(NSString *)name;
|
||||
- (NECoreIntervalStep *_Nullable)currentStep;
|
||||
- (NECoreIntervalStep *_Nullable)getStep:(NSString *)name;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
@@ -0,0 +1,398 @@
|
||||
|
||||
#if defined(__arm64__) && __arm64__ || (__x86_64__) && __x86_64__
|
||||
// Generated by Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
|
||||
#ifndef NECOREKIT_SWIFT_H
|
||||
#define NECOREKIT_SWIFT_H
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wgcc-compat"
|
||||
|
||||
#if !defined(__has_include)
|
||||
# define __has_include(x) 0
|
||||
#endif
|
||||
#if !defined(__has_attribute)
|
||||
# define __has_attribute(x) 0
|
||||
#endif
|
||||
#if !defined(__has_feature)
|
||||
# define __has_feature(x) 0
|
||||
#endif
|
||||
#if !defined(__has_warning)
|
||||
# define __has_warning(x) 0
|
||||
#endif
|
||||
|
||||
#if __has_include(<swift/objc-prologue.h>)
|
||||
# include <swift/objc-prologue.h>
|
||||
#endif
|
||||
|
||||
#pragma clang diagnostic ignored "-Wauto-import"
|
||||
#if defined(__OBJC__)
|
||||
#include <Foundation/Foundation.h>
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdbool>
|
||||
#include <cstring>
|
||||
#include <stdlib.h>
|
||||
#include <new>
|
||||
#include <type_traits>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#if defined(__arm64e__) && __has_include(<ptrauth.h>)
|
||||
# include <ptrauth.h>
|
||||
#else
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wreserved-macro-identifier"
|
||||
# ifndef __ptrauth_swift_value_witness_function_pointer
|
||||
# define __ptrauth_swift_value_witness_function_pointer(x)
|
||||
# endif
|
||||
# ifndef __ptrauth_swift_class_method_pointer
|
||||
# define __ptrauth_swift_class_method_pointer(x)
|
||||
# endif
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_TYPEDEFS)
|
||||
# define SWIFT_TYPEDEFS 1
|
||||
# if __has_include(<uchar.h>)
|
||||
# include <uchar.h>
|
||||
# elif !defined(__cplusplus)
|
||||
typedef uint_least16_t char16_t;
|
||||
typedef uint_least32_t char32_t;
|
||||
# endif
|
||||
typedef float swift_float2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef float swift_float3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef float swift_float4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef double swift_double2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef double swift_double3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef double swift_double4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef int swift_int2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef int swift_int3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef int swift_int4 __attribute__((__ext_vector_type__(4)));
|
||||
typedef unsigned int swift_uint2 __attribute__((__ext_vector_type__(2)));
|
||||
typedef unsigned int swift_uint3 __attribute__((__ext_vector_type__(3)));
|
||||
typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
|
||||
#endif
|
||||
|
||||
#if !defined(SWIFT_PASTE)
|
||||
# define SWIFT_PASTE_HELPER(x, y) x##y
|
||||
# define SWIFT_PASTE(x, y) SWIFT_PASTE_HELPER(x, y)
|
||||
#endif
|
||||
#if !defined(SWIFT_METATYPE)
|
||||
# define SWIFT_METATYPE(X) Class
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_PROPERTY)
|
||||
# if __has_feature(objc_class_property)
|
||||
# define SWIFT_CLASS_PROPERTY(...) __VA_ARGS__
|
||||
# else
|
||||
# define SWIFT_CLASS_PROPERTY(...)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_RUNTIME_NAME)
|
||||
# if __has_attribute(objc_runtime_name)
|
||||
# define SWIFT_RUNTIME_NAME(X) __attribute__((objc_runtime_name(X)))
|
||||
# else
|
||||
# define SWIFT_RUNTIME_NAME(X)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_COMPILE_NAME)
|
||||
# if __has_attribute(swift_name)
|
||||
# define SWIFT_COMPILE_NAME(X) __attribute__((swift_name(X)))
|
||||
# else
|
||||
# define SWIFT_COMPILE_NAME(X)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_METHOD_FAMILY)
|
||||
# if __has_attribute(objc_method_family)
|
||||
# define SWIFT_METHOD_FAMILY(X) __attribute__((objc_method_family(X)))
|
||||
# else
|
||||
# define SWIFT_METHOD_FAMILY(X)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_NOESCAPE)
|
||||
# if __has_attribute(noescape)
|
||||
# define SWIFT_NOESCAPE __attribute__((noescape))
|
||||
# else
|
||||
# define SWIFT_NOESCAPE
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_RELEASES_ARGUMENT)
|
||||
# if __has_attribute(ns_consumed)
|
||||
# define SWIFT_RELEASES_ARGUMENT __attribute__((ns_consumed))
|
||||
# else
|
||||
# define SWIFT_RELEASES_ARGUMENT
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_WARN_UNUSED_RESULT)
|
||||
# if __has_attribute(warn_unused_result)
|
||||
# define SWIFT_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
# else
|
||||
# define SWIFT_WARN_UNUSED_RESULT
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_NORETURN)
|
||||
# if __has_attribute(noreturn)
|
||||
# define SWIFT_NORETURN __attribute__((noreturn))
|
||||
# else
|
||||
# define SWIFT_NORETURN
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS_EXTRA)
|
||||
# define SWIFT_CLASS_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL_EXTRA)
|
||||
# define SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_EXTRA)
|
||||
# define SWIFT_ENUM_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_CLASS)
|
||||
# if __has_attribute(objc_subclassing_restricted)
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_subclassing_restricted)) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# else
|
||||
# define SWIFT_CLASS(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# define SWIFT_CLASS_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_CLASS_EXTRA
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_RESILIENT_CLASS)
|
||||
# if __has_attribute(objc_class_stub)
|
||||
# define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME) __attribute__((objc_class_stub))
|
||||
# define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) __attribute__((objc_class_stub)) SWIFT_CLASS_NAMED(SWIFT_NAME)
|
||||
# else
|
||||
# define SWIFT_RESILIENT_CLASS(SWIFT_NAME) SWIFT_CLASS(SWIFT_NAME)
|
||||
# define SWIFT_RESILIENT_CLASS_NAMED(SWIFT_NAME) SWIFT_CLASS_NAMED(SWIFT_NAME)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_PROTOCOL)
|
||||
# define SWIFT_PROTOCOL(SWIFT_NAME) SWIFT_RUNTIME_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
# define SWIFT_PROTOCOL_NAMED(SWIFT_NAME) SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_PROTOCOL_EXTRA
|
||||
#endif
|
||||
#if !defined(SWIFT_EXTENSION)
|
||||
# define SWIFT_EXTENSION(M) SWIFT_PASTE(M##_Swift_, __LINE__)
|
||||
#endif
|
||||
#if !defined(OBJC_DESIGNATED_INITIALIZER)
|
||||
# if __has_attribute(objc_designated_initializer)
|
||||
# define OBJC_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
|
||||
# else
|
||||
# define OBJC_DESIGNATED_INITIALIZER
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM_ATTR)
|
||||
# if __has_attribute(enum_extensibility)
|
||||
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
|
||||
# else
|
||||
# define SWIFT_ENUM_ATTR(_extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_ENUM)
|
||||
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# if __has_feature(generalized_swift_name)
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
|
||||
# else
|
||||
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE)
|
||||
# define SWIFT_UNAVAILABLE __attribute__((unavailable))
|
||||
#endif
|
||||
#if !defined(SWIFT_UNAVAILABLE_MSG)
|
||||
# define SWIFT_UNAVAILABLE_MSG(msg) __attribute__((unavailable(msg)))
|
||||
#endif
|
||||
#if !defined(SWIFT_AVAILABILITY)
|
||||
# define SWIFT_AVAILABILITY(plat, ...) __attribute__((availability(plat, __VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_WEAK_IMPORT)
|
||||
# define SWIFT_WEAK_IMPORT __attribute__((weak_import))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED)
|
||||
# define SWIFT_DEPRECATED __attribute__((deprecated))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_MSG)
|
||||
# define SWIFT_DEPRECATED_MSG(...) __attribute__((deprecated(__VA_ARGS__)))
|
||||
#endif
|
||||
#if !defined(SWIFT_DEPRECATED_OBJC)
|
||||
# if __has_feature(attribute_diagnose_if_objc)
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) __attribute__((diagnose_if(1, Msg, "warning")))
|
||||
# else
|
||||
# define SWIFT_DEPRECATED_OBJC(Msg) SWIFT_DEPRECATED_MSG(Msg)
|
||||
# endif
|
||||
#endif
|
||||
#if defined(__OBJC__)
|
||||
#if !defined(IBSegueAction)
|
||||
# define IBSegueAction
|
||||
#endif
|
||||
#endif
|
||||
#if !defined(SWIFT_EXTERN)
|
||||
# if defined(__cplusplus)
|
||||
# define SWIFT_EXTERN extern "C"
|
||||
# else
|
||||
# define SWIFT_EXTERN extern
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(SWIFT_CALL)
|
||||
# define SWIFT_CALL __attribute__((swiftcall))
|
||||
#endif
|
||||
#if !defined(SWIFT_INDIRECT_RESULT)
|
||||
# define SWIFT_INDIRECT_RESULT __attribute__((swift_indirect_result))
|
||||
#endif
|
||||
#if !defined(SWIFT_CONTEXT)
|
||||
# define SWIFT_CONTEXT __attribute__((swift_context))
|
||||
#endif
|
||||
#if !defined(SWIFT_ERROR_RESULT)
|
||||
# define SWIFT_ERROR_RESULT __attribute__((swift_error_result))
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
# define SWIFT_NOEXCEPT noexcept
|
||||
#else
|
||||
# define SWIFT_NOEXCEPT
|
||||
#endif
|
||||
#if !defined(SWIFT_C_INLINE_THUNK)
|
||||
# if __has_attribute(always_inline)
|
||||
# if __has_attribute(nodebug)
|
||||
# define SWIFT_C_INLINE_THUNK inline __attribute__((always_inline)) __attribute__((nodebug))
|
||||
# else
|
||||
# define SWIFT_C_INLINE_THUNK inline __attribute__((always_inline))
|
||||
# endif
|
||||
# else
|
||||
# define SWIFT_C_INLINE_THUNK inline
|
||||
# endif
|
||||
#endif
|
||||
#if defined(_WIN32)
|
||||
#if !defined(SWIFT_IMPORT_STDLIB_SYMBOL)
|
||||
# define SWIFT_IMPORT_STDLIB_SYMBOL __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#if !defined(SWIFT_IMPORT_STDLIB_SYMBOL)
|
||||
# define SWIFT_IMPORT_STDLIB_SYMBOL
|
||||
#endif
|
||||
#endif
|
||||
#if defined(__OBJC__)
|
||||
#if __has_feature(objc_modules)
|
||||
#if __has_warning("-Watimport-in-framework-header")
|
||||
#pragma clang diagnostic ignored "-Watimport-in-framework-header"
|
||||
#endif
|
||||
@import Foundation;
|
||||
@import ObjectiveC;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wproperty-attribute-mismatch"
|
||||
#pragma clang diagnostic ignored "-Wduplicate-method-arg"
|
||||
#if __has_warning("-Wpragma-clang-attribute")
|
||||
# pragma clang diagnostic ignored "-Wpragma-clang-attribute"
|
||||
#endif
|
||||
#pragma clang diagnostic ignored "-Wunknown-pragmas"
|
||||
#pragma clang diagnostic ignored "-Wnullability"
|
||||
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
|
||||
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma push_macro("any")
|
||||
# undef any
|
||||
# pragma clang attribute push(__attribute__((external_source_symbol(language="Swift", defined_in="NECoreKit",generated_declaration))), apply_to=any(function,enum,objc_interface,objc_category,objc_protocol))
|
||||
# pragma pop_macro("any")
|
||||
#endif
|
||||
|
||||
#if defined(__OBJC__)
|
||||
@class NSString;
|
||||
|
||||
/// 路径处理封装
|
||||
SWIFT_CLASS("_TtC9NECoreKit11NEPathUtils")
|
||||
@interface NEPathUtils : NSObject
|
||||
/// 获取document目录下的某个文件夹,支持传入多级,如不存在会新建该文件夹
|
||||
/// \param dir 文件夹名称,支持子路径,如 “123/456/789”
|
||||
///
|
||||
///
|
||||
/// returns:
|
||||
/// 文件夹的绝对路径
|
||||
+ (NSString * _Nullable)getDirectoryForDocumentsWithDir:(NSString * _Nonnull)dir SWIFT_WARN_UNUSED_RESULT;
|
||||
/// 获取document目录路径
|
||||
///
|
||||
/// returns:
|
||||
/// document目录路径
|
||||
+ (NSString * _Nullable)getDocumentPath SWIFT_WARN_UNUSED_RESULT;
|
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
|
||||
/// 字符串处理封装
|
||||
SWIFT_CLASS("_TtC9NECoreKit13NEStringUtils")
|
||||
@interface NEStringUtils : NSObject
|
||||
/// 脱敏字符串,比如将 “appkey:123456789” 脱敏为 “appkey:123***789”
|
||||
/// \param string 待脱敏的字符串
|
||||
///
|
||||
/// \param sensitive 脱敏关键字
|
||||
///
|
||||
///
|
||||
/// returns:
|
||||
/// 脱敏后的字符串
|
||||
+ (NSString * _Nonnull)desensitizeWithString:(NSString * _Nonnull)string sensitive:(NSString * _Nonnull)sensitive SWIFT_WARN_UNUSED_RESULT;
|
||||
/// 脱敏字符串,比如将 “123456789” 脱敏为 “123***789”
|
||||
/// \param string 待脱敏的字符串
|
||||
///
|
||||
/// \param left 左边显示几个字符
|
||||
///
|
||||
/// \param right 右边显示几个字符
|
||||
///
|
||||
/// \param template 用什么字符来脱敏,比如 “*”
|
||||
///
|
||||
///
|
||||
/// returns:
|
||||
/// 脱敏后的字符串
|
||||
+ (NSString * _Nonnull)aroundWithString:(NSString * _Nonnull)string left:(NSInteger)left right:(NSInteger)right template:(NSString * _Nonnull)template_ SWIFT_WARN_UNUSED_RESULT;
|
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
@class NSCoder;
|
||||
|
||||
SWIFT_CLASS("_TtC9NECoreKit7Regular")
|
||||
@interface Regular : NSRegularExpression
|
||||
- (nullable instancetype)initWithPattern:(NSString * _Nonnull)pattern options:(NSRegularExpressionOptions)options error:(NSError * _Nullable * _Nullable)error OBJC_DESIGNATED_INITIALIZER;
|
||||
- (nullable instancetype)initWithCoder:(NSCoder * _Nonnull)coder SWIFT_UNAVAILABLE;
|
||||
@end
|
||||
|
||||
enum RouterState : NSInteger;
|
||||
|
||||
SWIFT_CLASS("_TtC9NECoreKit6Router")
|
||||
@interface Router : NSObject
|
||||
SWIFT_CLASS_PROPERTY(@property (nonatomic, class, readonly, strong) Router * _Nonnull shared;)
|
||||
+ (Router * _Nonnull)shared SWIFT_WARN_UNUSED_RESULT;
|
||||
/// Register route
|
||||
- (void)register:(NSString * _Nonnull)url closure:(void (^ _Nonnull)(NSDictionary<NSString *, id> * _Nonnull))closure;
|
||||
/// Use Route
|
||||
/// \param url route address
|
||||
///
|
||||
/// \param parameters route parameters
|
||||
///
|
||||
/// \param closure handle callback closure
|
||||
///
|
||||
- (void)use:(NSString * _Nonnull)url parameters:(NSDictionary<NSString *, id> * _Nullable)parameters closure:(void (^ _Nullable)(id _Nullable, enum RouterState, NSString * _Nonnull))closure;
|
||||
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
|
||||
@end
|
||||
|
||||
/// Routing state
|
||||
typedef SWIFT_ENUM(NSInteger, RouterState, open) {
|
||||
RouterStateBusinessError = -1,
|
||||
RouterStateSystemError = 0,
|
||||
RouterStateSuccess = 1,
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#if __has_attribute(external_source_symbol)
|
||||
# pragma clang attribute pop
|
||||
#endif
|
||||
#if defined(__cplusplus)
|
||||
#endif
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
#else
|
||||
#error unsupported Swift architecture
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
#ifdef __OBJC__
|
||||
#import <UIKit/UIKit.h>
|
||||
#else
|
||||
#ifndef FOUNDATION_EXPORT
|
||||
#if defined(__cplusplus)
|
||||
#define FOUNDATION_EXPORT extern "C"
|
||||
#else
|
||||
#define FOUNDATION_EXPORT extern
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#import "NSObject+YXModel.h"
|
||||
#import "YXClassInfo.h"
|
||||
#import "YXModel.h"
|
||||
#import "BaseReportData.h"
|
||||
#import "NEReportConstans.h"
|
||||
#import "NECoreApiEvent.h"
|
||||
#import "NECoreIntervalEvent.h"
|
||||
#import "NECoreModuleEvent.h"
|
||||
#import "NECoreModuleInitEvent.h"
|
||||
#import "NECorePVInfoEvent.h"
|
||||
#import "NECoreUVInfoEvent.h"
|
||||
#import "ReportConfig.h"
|
||||
#import "ReportEvent.h"
|
||||
#import "ReportModuleInfo.h"
|
||||
#import "NEThreadSafeDictionary.h"
|
||||
#import "XKitReportStrategy.h"
|
||||
#import "XKitDeviceId.h"
|
||||
#import "XKitEventPropertyProviders.h"
|
||||
#import "XKitNetwork.h"
|
||||
#import "XKitReporter.h"
|
||||
#import "XKitReporterLog.h"
|
||||
#import "NECoreKit-Bridging-Header.h"
|
||||
#import "XKit.h"
|
||||
#import "XKitLog.h"
|
||||
#import "XKitLogOptions.h"
|
||||
#import "XKitServiceManager.h"
|
||||
|
||||
FOUNDATION_EXPORT double NECoreKitVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char NECoreKitVersionString[];
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
#import "ReportModuleInfo.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NECoreModuleEvent : NSObject <NECoreEvent>
|
||||
@property(nonatomic, strong, readonly) ReportModuleInfo *moduleInfo;
|
||||
- (instancetype)initWithModuleInfo:(ReportModuleInfo *)moduleInfo
|
||||
userId:(NSString *)userId
|
||||
event:(id<NECoreEvent>)event;
|
||||
- (NSString *)getAppKey;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
#import "ReportModuleInfo.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NECoreModuleInitEvent : NSObject <NECoreEvent>
|
||||
- (instancetype)initWithAppKey:(NSString *)appKey moduleInfo:(ReportModuleInfo *)moduleInfo;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NECorePVInfoEvent : NSObject <NECoreEvent>
|
||||
|
||||
/// 用户标识
|
||||
@property(nonatomic, strong, nullable) NSString *user;
|
||||
/// 当前页面
|
||||
@property(nonatomic, strong, nullable) NSString *page;
|
||||
/// 扩展信息
|
||||
@property(nonatomic, strong, nullable) NSString *extra;
|
||||
/// 事件名称
|
||||
@property(nonatomic, strong) NSString *eventName;
|
||||
/// 前一个页面
|
||||
@property(nonatomic, strong, nullable) NSString *prePage;
|
||||
/// accid
|
||||
@property(nonatomic, strong, nullable) NSString *accid;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface NECoreUVInfoEvent : NSObject <NECoreEvent>
|
||||
|
||||
/// 用户标识
|
||||
@property(nonatomic, strong, nullable) NSString *user;
|
||||
/// 当前页面
|
||||
@property(nonatomic, strong) NSString *page;
|
||||
/// 扩展信息
|
||||
@property(nonatomic, strong, nullable) NSString *extra;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,105 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef NEReportConstans_h
|
||||
#define NEReportConstans_h
|
||||
|
||||
#define URL_REPORT @"https://statistic.live.126.net/statics/report/xkit/action"
|
||||
#define URL_REPORT_V2 @"https://statistic.live.126.net/statics/report/common/form"
|
||||
|
||||
// ----------- report key start ----------
|
||||
|
||||
#define KEY_APP_KEY @"appKey"
|
||||
|
||||
#define KEY_COMPONENT @"component"
|
||||
|
||||
#define KEY_VERSION @"version"
|
||||
|
||||
#define KEY_PLATFORM @"platform"
|
||||
|
||||
#define KEY_TIMESTAMP @"timeStamp"
|
||||
|
||||
#define KEY_NERTC_VERSION @"nertcVersion"
|
||||
|
||||
#define KEY_IM_VERSION @"imVersion"
|
||||
|
||||
#define KEY_REPORT_TYPE @"reportType"
|
||||
|
||||
#define KEY_DATA @"data"
|
||||
|
||||
#define KEY_EXTRA @"extra"
|
||||
|
||||
#define KEY_PV_EVENT_NAME @"eventName"
|
||||
#define KEY_PV_PAGE @"page"
|
||||
#define KEY_PV_PRE_PAGE @"prePage"
|
||||
#define KEY_PV_ACCID @"accid"
|
||||
#define KEY_PV_USER @"user"
|
||||
|
||||
#define KEY_UV_PAGE @"page"
|
||||
#define KEY_UV_USER @"user"
|
||||
|
||||
#define KEY_CODE @"code"
|
||||
#define KEY_MSG @"message"
|
||||
#define KEY_COST_TIME @"costTime"
|
||||
#define KEY_RESPONSE @"response"
|
||||
|
||||
#define KEY_API @"api"
|
||||
#define KEY_API_NAME @"methodName"
|
||||
#define KEY_API_EXTENSION @"extension"
|
||||
#define KEY_API_ID_1 @"id1"
|
||||
#define KEY_API_ID_2 @"id2"
|
||||
|
||||
#define KEY_API_CALLBACK @"apiCallback"
|
||||
|
||||
#define KEY_CALL_BACK @"callback"
|
||||
|
||||
#define KEY_EVENT_USER @"user"
|
||||
|
||||
#define KEY_EVENT_RESULT @"result"
|
||||
|
||||
#define KEY_EVENT_PARAM @"params"
|
||||
|
||||
#define KEY_EVENT_TAG @"tag"
|
||||
|
||||
#define KEY_EVENT_REQUEST_ID @"requestId"
|
||||
|
||||
#define KEY_EVENT_START_TIME @"startTime"
|
||||
#define KEY_EVENT_END_TIME @"endTime"
|
||||
#define KEY_EVENT_DURATION @"duration"
|
||||
|
||||
#define KEY_DEVICE_ID @"deviceId"
|
||||
#define KEY_DEVICE_MODEL @"model"
|
||||
#define KEY_DEVICE_MANUFACTURER @"manufacturer"
|
||||
#define KEY_OS_VERSION @"osVer"
|
||||
#define KEY_APP_NAME @"appName"
|
||||
#define KEY_APP_VERSION @"appVer"
|
||||
#define KEY_PACKAGE_ID @"packageId"
|
||||
#define KEY_FRAMEWORK @"framework"
|
||||
#define KEY_CHANNEL @"channel"
|
||||
#define KEY_USER_ID @"userId"
|
||||
#define KEY_NETWORK_TYPE @"networkType"
|
||||
// ----------- report key end ----------
|
||||
|
||||
// ----------- report type start -------
|
||||
|
||||
#define REPORT_TYPE_INIT @"init"
|
||||
|
||||
#define REPORT_TYPE_PV @"pv"
|
||||
|
||||
#define REPORT_TYPE_UV @"uv"
|
||||
|
||||
#define REPORT_TYPE_EVENT_API @"apiEvent"
|
||||
|
||||
#define REPORT_TYPE_EVENT_CALLBACK @"callbackEvent"
|
||||
|
||||
#define REPORT_TYPE_EVENT_COMMON @"commonEvent"
|
||||
// ----------- report type end ---------
|
||||
|
||||
// --------- platform type start -------
|
||||
|
||||
#define PLATFORM_iOS @"iOS"
|
||||
|
||||
// --------- platform type end ---------
|
||||
|
||||
#endif /* NEReportConstans_h */
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 线程安全 字典
|
||||
@interface NEThreadSafeDictionary<KeyType, ObjectType> : NSMutableDictionary <KeyType, ObjectType>
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,418 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Provide some data-model method:
|
||||
|
||||
* Convert json to any object, or convert any object to json.
|
||||
* Set object properties with a key-value dictionary (like KVC).
|
||||
* Implementations of `NSCoding`, `NSCopying`, `-hash` and `-isEqual:`.
|
||||
|
||||
See `YXModel` protocol for custom methods.
|
||||
|
||||
|
||||
Sample Code:
|
||||
|
||||
********************** json convertor *********************
|
||||
@interface YXAuthor : NSObject
|
||||
@property (nonatomic, strong) NSString *name;
|
||||
@property (nonatomic, assign) NSDate *birthday;
|
||||
@end
|
||||
@implementation YXAuthor
|
||||
@end
|
||||
|
||||
@interface YXBook : NSObject
|
||||
@property (nonatomic, copy) NSString *name;
|
||||
@property (nonatomic, assign) NSUInteger pages;
|
||||
@property (nonatomic, strong) YXAuthor *author;
|
||||
@end
|
||||
@implementation YXBook
|
||||
@end
|
||||
|
||||
int main() {
|
||||
// create model from json
|
||||
YXBook *book = [YXBook yx_modelWithJSON:@"{\"name\": \"Harry Potter\", \"pages\": 256,
|
||||
\"author\": {\"name\": \"J.K.Rowling\", \"birthday\": \"1965-07-31\" }}"];
|
||||
|
||||
// convert model to json
|
||||
NSString *json = [book yx_modelToJSONString];
|
||||
// {"author":{"name":"J.K.Rowling","birthday":"1965-07-31T00:00:00+0000"},"name":"Harry
|
||||
Potter","pages":256}
|
||||
}
|
||||
|
||||
********************** Coding/Copying/hash/equal *********************
|
||||
@interface YXShadow :NSObject <NSCoding, NSCopying>
|
||||
@property (nonatomic, copy) NSString *name;
|
||||
@property (nonatomic, assign) CGSize size;
|
||||
@end
|
||||
|
||||
@implementation YXShadow
|
||||
- (void)encodeWithCoder:(NSCoder *)aCoder { [self yx_modelEncodeWithCoder:aCoder]; }
|
||||
- (id)initWithCoder:(NSCoder *)aDecoder { self = [super init]; return [self
|
||||
yx_modelInitWithCoder:aDecoder]; }
|
||||
- (id)copyWithZone:(NSZone *)zone { return [self yx_modelCopy]; }
|
||||
- (NSUInteger)hash { return [self yx_modelHash]; }
|
||||
- (BOOL)isEqual:(id)object { return [self yx_modelIsEqual:object]; }
|
||||
@end
|
||||
|
||||
*/
|
||||
@interface NSObject (YXModel)
|
||||
|
||||
/**
|
||||
Creates and returns a new instance of the receiver from a json.
|
||||
This method is thread-safe.
|
||||
|
||||
@param json A json object in `NSDictionary`, `NSString` or `NSData`.
|
||||
|
||||
@return A new instance created from the json, or nil if an error occurs.
|
||||
*/
|
||||
+ (nullable instancetype)yx_modelWithJSON:(id)json;
|
||||
|
||||
/**
|
||||
Creates and returns a new instance of the receiver from a key-value dictionary.
|
||||
This method is thread-safe.
|
||||
|
||||
@param dictionary A key-value dictionary mapped to the instance's properties.
|
||||
Any invalid key-value pair in dictionary will be ignored.
|
||||
|
||||
@return A new instance created from the dictionary, or nil if an error occurs.
|
||||
|
||||
@discussion The key in `dictionary` will mapped to the reciever's property name,
|
||||
and the value will set to the property. If the value's type does not match the
|
||||
property, this method will try to convert the value based on these rules:
|
||||
|
||||
`NSString` or `NSNumber` -> c number, such as BOOL, int, long, float, NSUInteger...
|
||||
`NSString` -> NSDate, parsed with format "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd HH:mm:ss" or
|
||||
"yyyy-MM-dd". `NSString` -> NSURL. `NSValue` -> struct or union, such as CGRect, CGSize, ...
|
||||
`NSString` -> SEL, Class.
|
||||
*/
|
||||
+ (nullable instancetype)yx_modelWithDictionary:(NSDictionary *)dictionary;
|
||||
|
||||
/**
|
||||
Set the receiver's properties with a json object.
|
||||
|
||||
@discussion Any invalid data in json will be ignored.
|
||||
|
||||
@param json A json object of `NSDictionary`, `NSString` or `NSData`, mapped to the
|
||||
receiver's properties.
|
||||
|
||||
@return Whether succeed.
|
||||
*/
|
||||
- (BOOL)yx_modelSetWithJSON:(id)json;
|
||||
|
||||
/**
|
||||
Set the receiver's properties with a key-value dictionary.
|
||||
|
||||
@param dic A key-value dictionary mapped to the receiver's properties.
|
||||
Any invalid key-value pair in dictionary will be ignored.
|
||||
|
||||
@discussion The key in `dictionary` will mapped to the reciever's property name,
|
||||
and the value will set to the property. If the value's type doesn't match the
|
||||
property, this method will try to convert the value based on these rules:
|
||||
|
||||
`NSString`, `NSNumber` -> c number, such as BOOL, int, long, float, NSUInteger...
|
||||
`NSString` -> NSDate, parsed with format "yyyy-MM-dd'T'HH:mm:ssZ", "yyyy-MM-dd HH:mm:ss" or
|
||||
"yyyy-MM-dd". `NSString` -> NSURL. `NSValue` -> struct or union, such as CGRect, CGSize, ...
|
||||
`NSString` -> SEL, Class.
|
||||
|
||||
@return Whether succeed.
|
||||
*/
|
||||
- (BOOL)yx_modelSetWithDictionary:(NSDictionary *)dic;
|
||||
|
||||
/**
|
||||
Generate a json object from the receiver's properties.
|
||||
|
||||
@return A json object in `NSDictionary` or `NSArray`, or nil if an error occurs.
|
||||
See [NSJSONSerialization isValidJSONObject] for more information.
|
||||
|
||||
@discussion Any of the invalid property is ignored.
|
||||
If the reciver is `NSArray`, `NSDictionary` or `NSSet`, it just convert
|
||||
the inner object to json object.
|
||||
*/
|
||||
- (nullable id)yx_modelToJSONObject;
|
||||
|
||||
/**
|
||||
Generate a json string's data from the receiver's properties.
|
||||
|
||||
@return A json string's data, or nil if an error occurs.
|
||||
|
||||
@discussion Any of the invalid property is ignored.
|
||||
If the reciver is `NSArray`, `NSDictionary` or `NSSet`, it will also convert the
|
||||
inner object to json string.
|
||||
*/
|
||||
- (nullable NSData *)yx_modelToJSONData;
|
||||
|
||||
/**
|
||||
Generate a json string from the receiver's properties.
|
||||
|
||||
@return A json string, or nil if an error occurs.
|
||||
|
||||
@discussion Any of the invalid property is ignored.
|
||||
If the reciver is `NSArray`, `NSDictionary` or `NSSet`, it will also convert the
|
||||
inner object to json string.
|
||||
*/
|
||||
- (nullable NSString *)yx_modelToJSONString;
|
||||
|
||||
/**
|
||||
Copy a instance with the receiver's properties.
|
||||
|
||||
@return A copied instance, or nil if an error occurs.
|
||||
*/
|
||||
- (nullable id)yx_modelCopy;
|
||||
|
||||
/**
|
||||
Encode the receiver's properties to a coder.
|
||||
|
||||
@param aCoder An archiver object.
|
||||
*/
|
||||
- (void)yx_modelEncodeWithCoder:(NSCoder *)aCoder;
|
||||
|
||||
/**
|
||||
Decode the receiver's properties from a decoder.
|
||||
|
||||
@param aDecoder An archiver object.
|
||||
|
||||
@return self
|
||||
*/
|
||||
- (id)yx_modelInitWithCoder:(NSCoder *)aDecoder;
|
||||
|
||||
/**
|
||||
Get a hash code with the receiver's properties.
|
||||
|
||||
@return Hash code.
|
||||
*/
|
||||
- (NSUInteger)yx_modelHash;
|
||||
|
||||
/**
|
||||
Compares the receiver with another object for equality, based on properties.
|
||||
|
||||
@param model Another object.
|
||||
|
||||
@return `YES` if the reciever is equal to the object, otherwise `NO`.
|
||||
*/
|
||||
- (BOOL)yx_modelIsEqual:(id)model;
|
||||
|
||||
/**
|
||||
Description method for debugging purposes based on properties.
|
||||
|
||||
@return A string that describes the contents of the receiver.
|
||||
*/
|
||||
- (NSString *)yx_modelDescription;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Provide some data-model method for NSArray.
|
||||
*/
|
||||
@interface NSArray (YXModel)
|
||||
|
||||
/**
|
||||
Creates and returns an array from a json-array.
|
||||
This method is thread-safe.
|
||||
|
||||
@param cls The instance's class in array.
|
||||
@param json A json array of `NSArray`, `NSString` or `NSData`.
|
||||
Example: [{"name","Mary"},{name:"Joe"}]
|
||||
|
||||
@return A array, or nil if an error occurs.
|
||||
*/
|
||||
+ (nullable NSArray *)yx_modelArrayWithClass:(Class)cls json:(id)json;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
Provide some data-model method for NSDictionary.
|
||||
*/
|
||||
@interface NSDictionary (YXModel)
|
||||
|
||||
/**
|
||||
Creates and returns a dictionary from a json.
|
||||
This method is thread-safe.
|
||||
|
||||
@param cls The value instance's class in dictionary.
|
||||
@param json A json dictionary of `NSDictionary`, `NSString` or `NSData`.
|
||||
Example: {"user1":{"name","Mary"}, "user2": {name:"Joe"}}
|
||||
|
||||
@return A dictionary, or nil if an error occurs.
|
||||
*/
|
||||
+ (nullable NSDictionary *)yx_modelDictionaryWithClass:(Class)cls json:(id)json;
|
||||
@end
|
||||
|
||||
/**
|
||||
If the default model transform does not fit to your model class, implement one or
|
||||
more method in this protocol to change the default key-value transform process.
|
||||
There's no need to add '<YXModel>' to your class header.
|
||||
*/
|
||||
@protocol YXModel <NSObject>
|
||||
@optional
|
||||
|
||||
/**
|
||||
Custom property mapper.
|
||||
|
||||
@discussion If the key in JSON/Dictionary does not match to the model's property name,
|
||||
implements this method and returns the additional mapper.
|
||||
|
||||
Example:
|
||||
|
||||
json:
|
||||
{
|
||||
"n":"Harry Pottery",
|
||||
"p": 256,
|
||||
"ext" : {
|
||||
"desc" : "A book written by J.K.Rowling."
|
||||
},
|
||||
"ID" : 100010
|
||||
}
|
||||
|
||||
model:
|
||||
@interface YXBook : NSObject
|
||||
@property NSString *name;
|
||||
@property NSInteger page;
|
||||
@property NSString *desc;
|
||||
@property NSString *bookID;
|
||||
@end
|
||||
|
||||
@implementation YXBook
|
||||
+ (NSDictionary *)modelCustomPropertyMapper {
|
||||
return @{@"name" : @"n",
|
||||
@"page" : @"p",
|
||||
@"desc" : @"ext.desc",
|
||||
@"bookID": @[@"id", @"ID", @"book_id"]};
|
||||
}
|
||||
@end
|
||||
|
||||
@return A custom mapper for properties.
|
||||
*/
|
||||
+ (nullable NSDictionary<NSString *, id> *)modelCustomPropertyMapper;
|
||||
|
||||
/**
|
||||
The generic class mapper for container properties.
|
||||
|
||||
@discussion If the property is a container object, such as NSArray/NSSet/NSDictionary,
|
||||
implements this method and returns a property->class mapper, tells which kind of
|
||||
object will be add to the array/set/dictionary.
|
||||
|
||||
Example:
|
||||
@class YXShadow, YXBorder, YXAttachment;
|
||||
|
||||
@interface YXAttributes
|
||||
@property NSString *name;
|
||||
@property NSArray *shadows;
|
||||
@property NSSet *borders;
|
||||
@property NSDictionary *attachments;
|
||||
@end
|
||||
|
||||
@implementation YXAttributes
|
||||
+ (NSDictionary *)modelContainerPropertyGenericClass {
|
||||
return @{@"shadows" : [YXShadow class],
|
||||
@"borders" : YXBorder.class,
|
||||
@"attachments" : @"YXAttachment" };
|
||||
}
|
||||
@end
|
||||
|
||||
@return A class mapper.
|
||||
*/
|
||||
+ (nullable NSDictionary<NSString *, id> *)modelContainerPropertyGenericClass;
|
||||
|
||||
/**
|
||||
If you need to create instances of different classes during json->object transform,
|
||||
use the method to choose custom class based on dictionary data.
|
||||
|
||||
@discussion If the model implements this method, it will be called to determine resulting class
|
||||
during `+modelWithJSON:`, `+modelWithDictionary:`, conveting object of properties of parent objects
|
||||
(both singular and containers via `+modelContainerPropertyGenericClass`).
|
||||
|
||||
Example:
|
||||
@class YXCircle, YXRectangle, YXLine;
|
||||
|
||||
@implementation YXShape
|
||||
|
||||
+ (Class)modelCustomClassForDictionary:(NSDictionary*)dictionary {
|
||||
if (dictionary[@"radius"] != nil) {
|
||||
return [YXCircle class];
|
||||
} else if (dictionary[@"width"] != nil) {
|
||||
return [YXRectangle class];
|
||||
} else if (dictionary[@"y2"] != nil) {
|
||||
return [YXLine class];
|
||||
} else {
|
||||
return [self class];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@param dictionary The json/kv dictionary.
|
||||
|
||||
@return Class to create from this dictionary, `nil` to use current class.
|
||||
|
||||
*/
|
||||
+ (nullable Class)modelCustomClassForDictionary:(NSDictionary *)dictionary;
|
||||
|
||||
/**
|
||||
All the properties in blacklist will be ignored in model transform process.
|
||||
Returns nil to ignore this feature.
|
||||
|
||||
@return An array of property's name.
|
||||
*/
|
||||
+ (nullable NSArray<NSString *> *)modelPropertyBlacklist;
|
||||
|
||||
/**
|
||||
If a property is not in the whitelist, it will be ignored in model transform process.
|
||||
Returns nil to ignore this feature.
|
||||
|
||||
@return An array of property's name.
|
||||
*/
|
||||
+ (nullable NSArray<NSString *> *)modelPropertyWhitelist;
|
||||
|
||||
/**
|
||||
This method's behavior is similar to `- (BOOL)modelCustomTransformFromDictionary:(NSDictionary
|
||||
*)dic;`, but be called before the model transform.
|
||||
|
||||
@discussion If the model implements this method, it will be called before
|
||||
`+modelWithJSON:`, `+modelWithDictionary:`, `-modelSetWithJSON:` and `-modelSetWithDictionary:`.
|
||||
If this method returns nil, the transform process will ignore this model.
|
||||
|
||||
@param dic The json/kv dictionary.
|
||||
|
||||
@return Returns the modified dictionary, or nil to ignore this model.
|
||||
*/
|
||||
- (NSDictionary *)modelCustomWillTransformFromDictionary:(NSDictionary *)dic;
|
||||
|
||||
/**
|
||||
If the default json-to-model transform does not fit to your model object, implement
|
||||
this method to do additional process. You can also use this method to validate the
|
||||
model's properties.
|
||||
|
||||
@discussion If the model implements this method, it will be called at the end of
|
||||
`+modelWithJSON:`, `+modelWithDictionary:`, `-modelSetWithJSON:` and `-modelSetWithDictionary:`.
|
||||
If this method returns NO, the transform process will ignore this model.
|
||||
|
||||
@param dic The json/kv dictionary.
|
||||
|
||||
@return Returns YES if the model is valid, or NO to ignore this model.
|
||||
*/
|
||||
- (BOOL)modelCustomTransformFromDictionary:(NSDictionary *)dic;
|
||||
|
||||
/**
|
||||
If the default model-to-json transform does not fit to your model class, implement
|
||||
this method to do additional process. You can also use this method to validate the
|
||||
json dictionary.
|
||||
|
||||
@discussion If the model implements this method, it will be called at the end of
|
||||
`-modelToJSONObject` and `-modelToJSONString`.
|
||||
If this method returns NO, the transform process will ignore this json dictionary.
|
||||
|
||||
@param dic The json dictionary.
|
||||
|
||||
@return Returns YES if the model is valid, or NO to ignore this model.
|
||||
*/
|
||||
- (BOOL)modelCustomTransformToDictionary:(NSMutableDictionary *)dic;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ReportConfig : NSObject
|
||||
|
||||
@property(nonatomic, strong) NSString *appKey;
|
||||
// Rtc SDK 版本
|
||||
@property(nonatomic, strong) NSString *nertcVersion;
|
||||
// IM SDK 版本
|
||||
@property(nonatomic, strong) NSString *imVersion;
|
||||
|
||||
@property(nonatomic, assign) NSInteger cacheCount;
|
||||
// 组件平台信息,开发者无需关心
|
||||
@property(nonatomic, strong) NSString *framework;
|
||||
// 组件平台信息,开发者无需关心
|
||||
@property(nonatomic, strong) NSString *channel;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
/// 事件优先级
|
||||
typedef NS_ENUM(NSInteger, NECoreEventPriority) {
|
||||
/// 低优先级
|
||||
NECoreEventPriorityLow,
|
||||
/// 中优先级
|
||||
NECoreEventPriorityNormal,
|
||||
/// 高优先级
|
||||
NECoreEventPriorityHigh
|
||||
};
|
||||
|
||||
@protocol NECoreEvent <NSObject>
|
||||
- (NSString *)eventId;
|
||||
- (NECoreEventPriority)priorty;
|
||||
- (NSDictionary<NSString *, id> *)toMap;
|
||||
@end
|
||||
|
||||
@protocol NECoreEventPropertyProvider <NSObject>
|
||||
+ (NSDictionary<NSString *, id> *)provideProperties;
|
||||
@end
|
||||
|
||||
@interface NECoreRawEvent : NSObject <NECoreEvent>
|
||||
|
||||
@property(nonatomic, copy, readonly) NSDictionary<NSString *, id> *data;
|
||||
- (instancetype)initWithEventId:(NSString *)eventId
|
||||
priority:(NECoreEventPriority)priority
|
||||
data:(NSDictionary<NSString *, id> *)data;
|
||||
@end
|
||||
@@ -0,0 +1,27 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface ReportModuleInfo : NSObject
|
||||
|
||||
@property(nonatomic, copy) NSString *serviceName;
|
||||
|
||||
@property(nonatomic, copy) NSString *versionName;
|
||||
|
||||
@property(nonatomic, copy, nullable) NSString *appkey;
|
||||
@property(nonatomic, copy, nullable) NSString *framework;
|
||||
@property(nonatomic, copy, nullable) NSString *channel;
|
||||
|
||||
- (instancetype)initWithName:(NSString *)name
|
||||
version:(NSString *)version
|
||||
appKey:(NSString *__nullable)appKey
|
||||
framework:(NSString *__nullable)framework
|
||||
channel:(NSString *__nullable)channel;
|
||||
- (NSDictionary *)toMap;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol XKitService <NSObject>
|
||||
@optional
|
||||
@property(nonatomic, strong) NSString *serviceName;
|
||||
|
||||
@property(nonatomic, strong) NSString *versionName;
|
||||
|
||||
@property(nonatomic, strong) NSString *appKey;
|
||||
|
||||
- (id)onMethodCall:(NSString *)method param:(NSDictionary *)param;
|
||||
|
||||
@end
|
||||
|
||||
@interface XKit : NSObject
|
||||
|
||||
+ (instancetype)instance;
|
||||
+ (void)setDefaultKey:(NSString *)appKey;
|
||||
- (void)registerService:(id<XKitService>)service;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XKitDeviceId : NSObject
|
||||
/// 设备UUID
|
||||
+ (NSString *)deviceId;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
|
||||
@interface XKitSDKVersionsProvider : NSObject <NECoreEventPropertyProvider>
|
||||
|
||||
@end
|
||||
|
||||
@interface XKitApplicationInfoProvider : NSObject <NECoreEventPropertyProvider>
|
||||
|
||||
@end
|
||||
|
||||
@interface XKitDeviceInfoProvider : NSObject <NECoreEventPropertyProvider>
|
||||
|
||||
@end
|
||||
|
||||
@interface XKitNetworkTypeProvider : NSObject <NECoreEventPropertyProvider>
|
||||
|
||||
@end
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "XKitLogOptions.h"
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XKitLog : NSObject
|
||||
|
||||
+ (XKitLog *)setUp:(XKitLogOptions *)options;
|
||||
|
||||
- (void)apiLog:(NSString *)className desc:(NSString *)desc;
|
||||
|
||||
- (void)infoLog:(NSString *)className desc:(NSString *)desc;
|
||||
|
||||
- (void)warnLog:(NSString *)className desc:(NSString *)desc;
|
||||
|
||||
- (void)errorLog:(NSString *)className desc:(NSString *)desc;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/// 日志级别
|
||||
typedef enum {
|
||||
XKitLogLevelVerbose = 0,
|
||||
XKitLogLevelDebug,
|
||||
XKitLogLevelInfo,
|
||||
XKitLogLevelWarn,
|
||||
XKitLogLevelError,
|
||||
XKitLogLevelNone,
|
||||
} XKitLogLevel;
|
||||
|
||||
@interface XKitLogOptions : NSObject
|
||||
|
||||
@property(nonatomic, assign) XKitLogLevel level;
|
||||
@property(nonatomic, copy) NSString *moduleName;
|
||||
|
||||
/// 敏感词,匹配到之后日志会对其进行脱敏处理
|
||||
@property(nonatomic, strong) NSArray<NSString *> *sensitives;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,14 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XKitNetwork : NSObject
|
||||
+ (NSString *)getNetworkType;
|
||||
+ (BOOL)isNetworkAvailable;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,31 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "ReportEvent.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XKitStrategy : NSObject
|
||||
@property(nonatomic, assign) BOOL enabled;
|
||||
@property(nonatomic, assign) BOOL lowPriorityEnabled;
|
||||
@property(nonatomic, assign) BOOL normalPriorityEnabled;
|
||||
@property(nonatomic, assign) BOOL highPriorityEnabled;
|
||||
@property(nonatomic, strong) NSMutableArray<NSString *> *blackList;
|
||||
@property(nonatomic, strong) NSMutableArray<NSString *> *whiteList;
|
||||
- (instancetype)initWithEnabled:(BOOL)enabled;
|
||||
- (BOOL)inBlackList:(NSString *)component;
|
||||
- (BOOL)inWhiteList:(NSString *)component;
|
||||
@end
|
||||
|
||||
/// 上报策略
|
||||
@interface XKitReportStrategy : NSObject
|
||||
- (instancetype)initWithAppKey:(NSString *)appKey;
|
||||
- (BOOL)shouldReportEvent:(NSString *)appKey
|
||||
component:(NSString *)component
|
||||
priority:(NECoreEventPriority)priorty;
|
||||
- (void)ensureStrategyReady:(void (^)(void))completion;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,70 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "BaseReportData.h"
|
||||
#import "ReportConfig.h"
|
||||
#import "ReportEvent.h"
|
||||
#import "ReportModuleInfo.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XKitReporter : NSObject
|
||||
|
||||
@property(nonatomic, strong) NSString *defaultKey;
|
||||
|
||||
@property(nonatomic, assign) NSInteger requestTimeOut;
|
||||
|
||||
+ (instancetype)shared;
|
||||
|
||||
/// 注册模块
|
||||
/// - Parameters:
|
||||
/// - serviceName: 模块名称
|
||||
/// - versionName: 版本
|
||||
/// - moduleAppKey: appKey
|
||||
- (void)registerModule:(NSString *)serviceName
|
||||
withVersion:(NSString *)versionName
|
||||
moduleAppKey:(NSString *)moduleAppKey;
|
||||
|
||||
/// 注册模块
|
||||
/// - Parameters:
|
||||
/// - serviceName: 模块名称
|
||||
/// - versionName: 版本
|
||||
/// - moduleAppKey: appKey
|
||||
/// - channel: 渠道信息
|
||||
/// - framework: 渠道信息
|
||||
- (void)registerModule:(NSString *)serviceName
|
||||
withVersion:(NSString *)versionName
|
||||
moduleAppKey:(NSString *)moduleAppKey
|
||||
channel:(NSString *__nullable)channel
|
||||
framework:(NSString *__nullable)framework;
|
||||
|
||||
/// 上报 (通过模块信息)
|
||||
/// - Parameters:
|
||||
/// - moduleInfo: 模块信息
|
||||
/// - userId: 用户id
|
||||
/// - event: 上报的事件
|
||||
- (void)reportModuleInfo:(ReportModuleInfo *)moduleInfo
|
||||
userId:(NSString *__nullable)userId
|
||||
event:(id<NECoreEvent>)event;
|
||||
|
||||
/// 上报 (通过模块名称)
|
||||
/// - Parameters:
|
||||
/// - moduleName: 模块名称
|
||||
/// - userId: 用户id
|
||||
/// - event: 上报的事件
|
||||
- (void)reportModuleName:(NSString *)moduleName
|
||||
userId:(NSString *__nullable)userId
|
||||
event:(id<NECoreEvent>)event;
|
||||
|
||||
/// 上报对象
|
||||
/// @param data 数据对象
|
||||
- (void)report:(nullable BaseReportData *)data;
|
||||
|
||||
/// 手动上传并清空缓存队列
|
||||
- (void)flushAsync;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XKitReporterLog : NSObject
|
||||
/// 初始化
|
||||
+ (void)setUp;
|
||||
+ (void)infoLog:(NSString *)className desc:(NSString *)desc;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,20 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "XKit.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XKitServiceManager : NSObject
|
||||
|
||||
+ (instancetype)getInstance;
|
||||
|
||||
- (void)registerService:(NSString *)serviceName service:(id<XKitService>)service;
|
||||
|
||||
- (BOOL)serviceIsRegister:(NSString *)serviceName;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,195 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <objc/runtime.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
Type encoding's type.
|
||||
*/
|
||||
typedef NS_OPTIONS(NSUInteger, YXEncodingType) {
|
||||
YXEncodingTypeMask = 0xFF, ///< mask of type value
|
||||
YXEncodingTypeUnknown = 0, ///< unknown
|
||||
YXEncodingTypeVoid = 1, ///< void
|
||||
YXEncodingTypeBool = 2, ///< bool
|
||||
YXEncodingTypeInt8 = 3, ///< char / BOOL
|
||||
YXEncodingTypeUInt8 = 4, ///< unsigned char
|
||||
YXEncodingTypeInt16 = 5, ///< short
|
||||
YXEncodingTypeUInt16 = 6, ///< unsigned short
|
||||
YXEncodingTypeInt32 = 7, ///< int
|
||||
YXEncodingTypeUInt32 = 8, ///< unsigned int
|
||||
YXEncodingTypeInt64 = 9, ///< long long
|
||||
YXEncodingTypeUInt64 = 10, ///< unsigned long long
|
||||
YXEncodingTypeFloat = 11, ///< float
|
||||
YXEncodingTypeDouble = 12, ///< double
|
||||
YXEncodingTypeLongDouble = 13, ///< long double
|
||||
YXEncodingTypeObject = 14, ///< id
|
||||
YXEncodingTypeClass = 15, ///< Class
|
||||
YXEncodingTypeSEL = 16, ///< SEL
|
||||
YXEncodingTypeBlock = 17, ///< block
|
||||
YXEncodingTypePointer = 18, ///< void*
|
||||
YXEncodingTypeStruct = 19, ///< struct
|
||||
YXEncodingTypeUnion = 20, ///< union
|
||||
YXEncodingTypeCString = 21, ///< char*
|
||||
YXEncodingTypeCArray = 22, ///< char[10] (for example)
|
||||
|
||||
YXEncodingTypeQualifierMask = 0xFF00, ///< mask of qualifier
|
||||
YXEncodingTypeQualifierConst = 1 << 8, ///< const
|
||||
YXEncodingTypeQualifierIn = 1 << 9, ///< in
|
||||
YXEncodingTypeQualifierInout = 1 << 10, ///< inout
|
||||
YXEncodingTypeQualifierOut = 1 << 11, ///< out
|
||||
YXEncodingTypeQualifierBycopy = 1 << 12, ///< bycopy
|
||||
YXEncodingTypeQualifierByref = 1 << 13, ///< byref
|
||||
YXEncodingTypeQualifierOneway = 1 << 14, ///< oneway
|
||||
|
||||
YXEncodingTypePropertyMask = 0xFF0000, ///< mask of property
|
||||
YXEncodingTypePropertyReadonly = 1 << 16, ///< readonly
|
||||
YXEncodingTypePropertyCopy = 1 << 17, ///< copy
|
||||
YXEncodingTypePropertyRetain = 1 << 18, ///< retain
|
||||
YXEncodingTypePropertyNonatomic = 1 << 19, ///< nonatomic
|
||||
YXEncodingTypePropertyWeak = 1 << 20, ///< weak
|
||||
YXEncodingTypePropertyCustomGetter = 1 << 21, ///< getter=
|
||||
YXEncodingTypePropertyCustomSetter = 1 << 22, ///< setter=
|
||||
YXEncodingTypePropertyDynamic = 1 << 23, ///< @dynamic
|
||||
};
|
||||
|
||||
/**
|
||||
Get the type from a Type-Encoding string.
|
||||
|
||||
@discussion See also:
|
||||
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtTypeEncodings.html
|
||||
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/ObjCRuntimeGuide/Articles/ocrtPropertyIntrospection.html
|
||||
|
||||
@param typeEncoding A Type-Encoding string.
|
||||
@return The encoding type.
|
||||
*/
|
||||
YXEncodingType YXEncodingGetType(const char *typeEncoding);
|
||||
|
||||
/**
|
||||
Instance variable information.
|
||||
*/
|
||||
@interface YXClassIvarInfo : NSObject
|
||||
@property(nonatomic, assign, readonly) Ivar ivar; ///< ivar opaque struct
|
||||
@property(nonatomic, strong, readonly) NSString *name; ///< Ivar's name
|
||||
@property(nonatomic, assign, readonly) ptrdiff_t offset; ///< Ivar's offset
|
||||
@property(nonatomic, strong, readonly) NSString *typeEncoding; ///< Ivar's type encoding
|
||||
@property(nonatomic, assign, readonly) YXEncodingType type; ///< Ivar's type
|
||||
|
||||
/**
|
||||
Creates and returns an ivar info object.
|
||||
|
||||
@param ivar ivar opaque struct
|
||||
@return A new object, or nil if an error occurs.
|
||||
*/
|
||||
- (instancetype)initWithIvar:(Ivar)ivar;
|
||||
@end
|
||||
|
||||
/**
|
||||
Method information.
|
||||
*/
|
||||
@interface YXClassMethodInfo : NSObject
|
||||
@property(nonatomic, assign, readonly) Method method; ///< method opaque struct
|
||||
@property(nonatomic, strong, readonly) NSString *name; ///< method name
|
||||
@property(nonatomic, assign, readonly) SEL sel; ///< method's selector
|
||||
@property(nonatomic, assign, readonly) IMP imp; ///< method's implementation
|
||||
@property(nonatomic, strong, readonly)
|
||||
NSString *typeEncoding; ///< method's parameter and return types
|
||||
@property(nonatomic, strong, readonly) NSString *returnTypeEncoding; ///< return value's type
|
||||
@property(nullable, nonatomic, strong, readonly)
|
||||
NSArray<NSString *> *argumentTypeEncodings; ///< array of arguments' type
|
||||
|
||||
/**
|
||||
Creates and returns a method info object.
|
||||
|
||||
@param method method opaque struct
|
||||
@return A new object, or nil if an error occurs.
|
||||
*/
|
||||
- (instancetype)initWithMethod:(Method)method;
|
||||
@end
|
||||
|
||||
/**
|
||||
Property information.
|
||||
*/
|
||||
@interface YXClassPropertyInfo : NSObject
|
||||
@property(nonatomic, assign, readonly) objc_property_t property; ///< property's opaque struct
|
||||
@property(nonatomic, strong, readonly) NSString *name; ///< property's name
|
||||
@property(nonatomic, assign, readonly) YXEncodingType type; ///< property's type
|
||||
@property(nonatomic, strong, readonly) NSString *typeEncoding; ///< property's encoding value
|
||||
@property(nonatomic, strong, readonly) NSString *ivarName; ///< property's ivar name
|
||||
@property(nullable, nonatomic, strong, readonly) Class cls; ///< may be nil
|
||||
@property(nullable, nonatomic, strong, readonly) NSArray<NSString *> *protocols; ///< may nil
|
||||
@property(nonatomic, assign, readonly) SEL getter; ///< getter (nonnull)
|
||||
@property(nonatomic, assign, readonly) SEL setter; ///< setter (nonnull)
|
||||
|
||||
/**
|
||||
Creates and returns a property info object.
|
||||
|
||||
@param property property opaque struct
|
||||
@return A new object, or nil if an error occurs.
|
||||
*/
|
||||
- (instancetype)initWithProperty:(objc_property_t)property;
|
||||
@end
|
||||
|
||||
/**
|
||||
Class information for a class.
|
||||
*/
|
||||
@interface YXClassInfo : NSObject
|
||||
@property(nonatomic, strong, readonly) Class cls; ///< class object
|
||||
@property(nullable, nonatomic, strong, readonly) Class superCls; ///< super class object
|
||||
@property(nullable, nonatomic, strong, readonly) Class metaCls; ///< class's meta class object
|
||||
@property(nonatomic, readonly) BOOL isMeta; ///< whether this class is meta class
|
||||
@property(nonatomic, strong, readonly) NSString *name; ///< class name
|
||||
@property(nullable, nonatomic, strong, readonly)
|
||||
YXClassInfo *superClassInfo; ///< super class's class info
|
||||
@property(nullable, nonatomic, strong, readonly)
|
||||
NSDictionary<NSString *, YXClassIvarInfo *> *ivarInfos; ///< ivars
|
||||
@property(nullable, nonatomic, strong, readonly)
|
||||
NSDictionary<NSString *, YXClassMethodInfo *> *methodInfos; ///< methods
|
||||
@property(nullable, nonatomic, strong, readonly)
|
||||
NSDictionary<NSString *, YXClassPropertyInfo *> *propertyInfos; ///< properties
|
||||
|
||||
/**
|
||||
If the class is changed (for example: you add a method to this class with
|
||||
'class_addMethod()'), you should call this method to refresh the class info cache.
|
||||
|
||||
After called this method, `needUpdate` will returns `YES`, and you should call
|
||||
'classInfoWithClass' or 'classInfoWithClassName' to get the updated class info.
|
||||
*/
|
||||
- (void)setNeedUpdate;
|
||||
|
||||
/**
|
||||
If this method returns `YES`, you should stop using this instance and call
|
||||
`classInfoWithClass` or `classInfoWithClassName` to get the updated class info.
|
||||
|
||||
@return Whether this class info need update.
|
||||
*/
|
||||
- (BOOL)needUpdate;
|
||||
|
||||
/**
|
||||
Get the class info of a specified Class.
|
||||
|
||||
@discussion This method will cache the class info and super-class info
|
||||
at the first access to the Class. This method is thread-safe.
|
||||
|
||||
@param cls A class.
|
||||
@return A class info, or nil if an error occurs.
|
||||
*/
|
||||
+ (nullable instancetype)classInfoWithClass:(Class)cls;
|
||||
|
||||
/**
|
||||
Get the class info of a specified Class.
|
||||
|
||||
@discussion This method will cache the class info and super-class info
|
||||
at the first access to the Class. This method is thread-safe.
|
||||
|
||||
@param className A class name.
|
||||
@return A class info, or nil if an error occurs.
|
||||
*/
|
||||
+ (nullable instancetype)classInfoWithClassName:(NSString *)className;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
@@ -0,0 +1,15 @@
|
||||
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
|
||||
// Use of this source code is governed by a MIT license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
#if __has_include(<YXModel/YXModel.h>)
|
||||
FOUNDATION_EXPORT double YXModelVersionNumber;
|
||||
FOUNDATION_EXPORT const unsigned char YXModelVersionString[];
|
||||
#import <YXModel/NSObject+YXModel.h>
|
||||
#import <YXModel/YXClassInfo.h>
|
||||
#else
|
||||
#import "NSObject+YXModel.h"
|
||||
#import "YXClassInfo.h"
|
||||
#endif
|
||||
Reference in New Issue
Block a user