Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ group("default") {
deps += [ "platform/harmony" ]
} else if (is_ios) {
deps += [ "platform/darwin/ios/lynx_service:LynxService" ]
deps += [ "platform/darwin/ios/lynx_service_api:LynxServiceAPI_podspec" ]
deps += [ "platform/darwin/ios/lynx_devtool:devtool_podspec" ]
deps += [ "platform/darwin/ios/lynx_xelement:XElement" ]
deps += [ "platform/darwin/ios:iOS" ]
Expand Down
5 changes: 5 additions & 0 deletions core/renderer/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ lynx_core_source_set("tasm") {
deps += [ "../runtime/bindings/napi:napi_binding_jsc" ]
}
}
if (is_mac && !enable_unittests) {
deps += [
"../../platform/darwin/ios/lynx_service_api:lynx_service_api_sources",
]
}

if (lepus_compile) {
public_deps += [ "../template_bundle/template_codec:lepus_compile" ]
Expand Down
3 changes: 3 additions & 0 deletions explorer/darwin/ios/lynx_explorer/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ target 'LynxExplorer' do
'Devtool',
'Http',
]
pod 'LynxServiceAPI', :path => '../../../..', :subspecs => [
'Core'
]

pod 'XElement', :path => '../../../..', :subspecs => [
'Behavior',
Expand Down
1 change: 1 addition & 0 deletions platform/darwin/common/lynx/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ common_lynx_shared_sources = [
"resource/LynxTemplateResource.m",
"service/LynxService.m",
"service/LynxServiceResourceRequestParameters.m",
"service/LynxVerificationResult.m",
"trace/LynxTraceEventDef.h",
"utils/LynxColorUtils.mm",
"utils/LynxConvertUtils.h",
Expand Down
2 changes: 1 addition & 1 deletion platform/darwin/common/lynx/LynxEnv.mm
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#import <Lynx/LynxService.h>
#import <Lynx/LynxServiceDevToolProtocol.h>
#import <Lynx/LynxServiceExtensionProtocol.h>
#import <Lynx/LynxServiceLogProtocol.h>
#import <LynxBase/LynxBaseEnv.h>
#import <LynxBase/LynxBaseService.h>
#import <LynxServiceAPI/LynxServiceLogProtocol.h>

#include "base/include/fml/synchronization/shared_mutex.h"
#include "base/trace/native/trace_event.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,8 @@ - (void)setUp {
// Register LynxServiceResource with the mock instance
_mockLynxServiceResourceProtocol = OCMProtocolMock(@protocol(LynxServiceResourceProtocol));
_mockLynxServices = OCMClassMock([LynxServices class]);
OCMStub(
ClassMethod([_mockLynxServices getInstanceWithProtocol:@protocol(LynxServiceResourceProtocol)
bizID:DEFAULT_LYNX_SERVICE]))
OCMStub(ClassMethod(
[_mockLynxServices getInstanceWithProtocol:@protocol(LynxServiceResourceProtocol)]))
.andReturn(_mockLynxServiceResourceProtocol);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ - (void)onPerformanceEvent:(nonnull LynxPerformanceEntry*)entry {
[_observer onPerformanceEvent:entry];

if (_reporter == nil) {
id<LynxServiceEventReporterProtocol> reporter =
[LynxServices getInstanceWithProtocol:@protocol(LynxServiceEventReporterProtocol)
bizID:DEFAULT_LYNX_SERVICE];
id<LynxServiceEventReporterProtocol> reporter = LynxService(LynxServiceEventReporterProtocol);
if (reporter != nil && [reporter respondsToSelector:@selector(onPerformanceEvent:)]) {
_reporter = reporter;
}
Expand Down
76 changes: 11 additions & 65 deletions platform/darwin/common/lynx/public/service/LynxService.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,85 +4,31 @@

#ifndef DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICE_H_
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICE_H_

#import <Foundation/Foundation.h>
#import <Lynx/LynxDefines.h>
#import <Lynx/LynxServiceModuleProtocol.h>
#import <Lynx/LynxServiceMonitorProtocol.h>
#import <Lynx/LynxServiceProtocol.h>
#import <Lynx/LynxServiceSecurityProtocol.h>
#import <Lynx/LynxServiceTrailProtocol.h>
#import <LynxServiceAPI/LynxServiceTrailProtocol.h>
#import <LynxServiceAPI/ServiceAPI.h>

#if TARGET_OS_IOS
#import <Lynx/LynxServiceImageProtocol.h>
#endif

NS_ASSUME_NONNULL_BEGIN

/*
* You can use @LynxServiceRegister to specify a LynxService will be
* registered into LynxServices instance automatically. This annotation
* should only be used for LynxServices subclasses, and before the
* @implementation code fragment in the .m file. e.g.: LynxMonitorService
* is a subclass of LynxServices, in LynxMonitorService.m
* // ...import headers...
* @LynxServiceRegister(LynxMonitorService)
* @implmentation LynxMonitorService
* //...
* @end
*/

#ifndef LynxServiceRegister
#define LynxServiceRegister(clsName) \
interface LynxServices(clsName) @end @implementation LynxServices(clsName) \
+(NSString *)LYNX_CONCAT(__lynx_auto_register_serivce__, \
LYNX_CONCAT(clsName, LYNX_CONCAT(__LINE__, __COUNTER__))) { \
return @ #clsName; \
} \
@end
#endif
#import <Lynx/LynxServiceTrailExtensionProtocol.h>

/**
* Bind protocol and class, e.g., LYNX_SERVICE_BIND (LynxMonitorService,
* LynxMonitorProtocol)
*/
#define LynxServiceBind(cls, pro) ([LynxServices bindClass:cls toProtocol:@protocol(pro)])

/**
* Get the default object that implements the specified protocol, e.g.,
* LYNX_SERVICE(LynxMonitorProtocol) -> id<LynxMonitorProtocol>
*/
#define LynxService(pro) \
((id<pro>)([LynxServices getInstanceWithProtocol:@protocol(pro) bizID:DEFAULT_LYNX_SERVICE]))
/**
* Get the object that implements the specified protocol, e.g.,
* LYNX_SERVICE(LynxMonitorProtocol, default) -> id<LynxMonitorProtocol>
*/
#define LynxServiceBID(pro, bid) \
((id<pro>)([LynxServices getInstanceWithProtocol:@protocol(pro) bizID:bid]))
@interface LynxServiceHelper : NSObject
+ (nullable id<LynxServiceTrailExtensionProtocol>)getLynxTrailExtensionService;
@end

/**
* Get LynxTrail Instance
* LynxTrail
* Get LynxTrailService Instance
*/
#define LynxTrail LynxService(LynxServiceTrailProtocol)

@interface LynxServices : NSObject

/**
* Register default service
* @param cls Protocol implementation class, which implements sharedInstance and is a singleton.
* Get extended LynxTrailService Instance
*/
+ (void)registerService:(Class)cls;

/**
* Get implementation through protocol
* @param protocol The protocol, which implements sharedInstance and returns a singleton
* @param bizID Business ID
* @return An instance of the protocol implementation class; returns null if the protocol has not
* been bound
*/
+ (id)getInstanceWithProtocol:(Protocol *)protocol bizID:(NSString *__nullable)bizID;

@end
#define LynxTrailExtensionService ([LynxServiceHelper getLynxTrailExtensionService])

NS_ASSUME_NONNULL_END
#endif // DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICE_H_
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICEIDEVTOOLPROTOCOL_H_

#import <Foundation/Foundation.h>
#import <Lynx/LynxServiceProtocol.h>
#import <LynxServiceAPI/ServiceAPI.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#import <Foundation/Foundation.h>
#import <Lynx/LynxEventReporter.h>
#import <Lynx/LynxPerformanceObserverProtocol.h>
#import <Lynx/LynxServiceProtocol.h>
#import <LynxServiceAPI/ServiceAPI.h>

@class LynxView;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <Lynx/LynxConfig.h>
#import <Lynx/LynxContext.h>
#import <Lynx/LynxGroup.h>
#import <Lynx/LynxServiceProtocol.h>
#import <LynxServiceAPI/ServiceAPI.h>

@protocol LynxServiceExtensionProtocol <LynxServiceProtocol>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#import <Lynx/LynxHttpRequest.h>
#import <Lynx/LynxHttpStreamingDelegate.h>
#import <Lynx/LynxServiceProtocol.h>
#import <LynxServiceAPI/ServiceAPI.h>

@protocol LynxHttpInterceptor
// TODO(huzhanbo.luc): let interceptRequest support streaming response by chunk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICEIMAGEPROTOCOL_H_
#import <Foundation/Foundation.h>
#if TARGET_OS_IOS
#import <Lynx/LynxServiceProtocol.h>
#import <Lynx/LynxUIImage.h>
#import <LynxServiceAPI/ServiceAPI.h>
#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

#import <Lynx/LynxServiceProtocol.h>
#import <Lynx/LynxView.h>
#import <LynxServiceAPI/ServiceAPI.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
48 changes: 0 additions & 48 deletions platform/darwin/common/lynx/public/service/LynxServiceProtocol.h

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
#ifndef DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICERESOURCEPROTOCOL_H_
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICERESOURCEPROTOCOL_H_
#import <Foundation/Foundation.h>
#import <Lynx/LynxServiceProtocol.h>
#import <Lynx/LynxServiceResourceRequestOperationProtocol.h>
#import <Lynx/LynxServiceResourceRequestParameters.h>
#import <Lynx/LynxServiceResourceResponseProtocol.h>
#import <LynxServiceAPI/ServiceAPI.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICESECURITYPROTOCOL_H_
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICESECURITYPROTOCOL_H_

#import <Lynx/LynxServiceProtocol.h>
#import <LynxServiceAPI/ServiceAPI.h>

NS_ASSUME_NONNULL_BEGIN

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

#ifndef DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICETRAILEXTENSIONPROTOCOL_H_
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICETRAILEXTENSIONPROTOCOL_H_

#import <Foundation/Foundation.h>
#import <LynxServiceAPI/LynxServiceTrailProtocol.h>

NS_ASSUME_NONNULL_BEGIN

@class LynxViewBuilder;

/**
* This protocol is used to extend the default LynxServiceTrailProtocol, which does not have some
* lynx-specific methods.
*/
@protocol LynxServiceTrailExtensionProtocol

/**
* parse configs of LynxViewBuilder
*/
- (void)parseLynxViewBuilder:(LynxViewBuilder *)builder;

@end

NS_ASSUME_NONNULL_END

#endif // DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICETRAILEXTENSIONPROTOCOL_H_
Original file line number Diff line number Diff line change
@@ -1,45 +1,10 @@
// Copyright 2022 The Lynx Authors. All rights reserved.
// Copyright 2025 The Lynx Authors. All rights reserved.
// Licensed under the Apache License Version 2.0 that can be found in the
// LICENSE file in the root directory of this source tree.

#ifndef DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICETRAILPROTOCOL_H_
#define DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICETRAILPROTOCOL_H_

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@class LynxViewBuilder;

@protocol LynxServiceProtocol;

@protocol LynxServiceTrailProtocol <LynxServiceProtocol>

/**
* Get string value for key from experiment
* @param key key of experiment
*/
- (NSString *)stringValueForTrailKey:(NSString *)key;

/**
* Get object value for key from experiment. Only used for compatibility with different types,
* please use stringValueForTrailKey in most cases
* @param key key of experiment
*/
- (id)objectValueForTrailKey:(NSString *)key;

/**
* Get all values for key from experiment.
*/
- (NSDictionary *)getAllValues;

/**
* parse configs of LynxViewBuilder
*/
- (void)parseLynxViewBuilder:(LynxViewBuilder *)builder;

@end

NS_ASSUME_NONNULL_END
#import <LynxServiceAPI/LynxServiceTrailProtocol.h>

#endif // DARWIN_COMMON_LYNX_SERVICE_LYNXSERVICETRAILPROTOCOL_H_
3 changes: 1 addition & 2 deletions platform/darwin/common/lynx/public/sources_list.gni
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ common_lynx_public_headers =
"service/LynxServiceResourceResponseProtocol.h",
"service/LynxServiceContainerProtocol.h",
"service/LynxServiceHttpProtocol.h",
"service/LynxServiceLogProtocol.h",
"service/LynxServiceResourceProtocol.h",
"service/LynxServiceResourceRequestOperationProtocol.h",
"service/LynxServiceTrailProtocol.h",
"service/LynxServiceTrailExtensionProtocol.h",
"service/LynxServiceModuleProtocol.h",
"service/LynxServiceEventReporterProtocol.h",
"service/LynxServiceExtensionProtocol.h",
Expand All @@ -84,7 +84,6 @@ common_lynx_public_headers =
"service/LynxServiceSecurityProtocol.h",
"service/LynxService.h",
"service/LynxServiceSystemInvokeProtocol.h",
"service/LynxServiceProtocol.h",
"resource/LynxProviderRegistry.h",
"resource/LynxMediaResourceFetcher.h",
"resource/LynxTemplateResourceFetcher.h",
Expand Down
Loading
Loading