diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java index e8cf78ca..1fda53a8 100644 --- a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDev.java @@ -70,6 +70,8 @@ public class DoricDev { DoricSingleton.getInstance().getNativeDriver().getRegistry().registerMonitor(new DoricDevMonitor()); DoricSingleton.getInstance().getNativeDriver().getRegistry().setGlobalPerformanceAnchorHook(new DoricDevPerformanceAnchorHook()); DoricSingleton.getInstance().getNativeDriver().getRegistry().registerNativePlugin(DoricDevkitPlugin.class); + //Replace loader + DoricSingleton.getInstance().getNativeDriver().getRegistry().getResourceManager().registerLoader(new DoricDevAssetsLoader()); } public static DoricDev getInstance() { diff --git a/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java new file mode 100644 index 00000000..d3083600 --- /dev/null +++ b/doric-android/devkit/src/main/java/pub/doric/devkit/DoricDevAssetsLoader.java @@ -0,0 +1,37 @@ +/* + * Copyright [2021] [Doric.Pub] + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package pub.doric.devkit; + +import pub.doric.DoricContext; +import pub.doric.resource.DoricAssetsLoader; +import pub.doric.resource.DoricAssetsResource; +import pub.doric.resource.DoricResource; + +/** + * @Description: Load assets in dev mode + * @Author: pengfei.zhou + * @CreateDate: 2021/12/7 + */ +public class DoricDevAssetsLoader extends DoricAssetsLoader { + + @Override + public DoricResource load(DoricContext doricContext, String identifier) { + if (DoricDev.getInstance().isInDevMode()) { + + } + return new DoricAssetsResource(doricContext, "assets/" + identifier); + } +} diff --git a/doric-iOS/Devkit/Classes/DoricDev.m b/doric-iOS/Devkit/Classes/DoricDev.m index 3f7f8ac6..99bb7f0e 100644 --- a/doric-iOS/Devkit/Classes/DoricDev.m +++ b/doric-iOS/Devkit/Classes/DoricDev.m @@ -30,6 +30,7 @@ #import "DoricDevMonitor.h" #import "DoricDevPerformanceAnchorHook.h" #import "DoricDevkitPlugin.h" +#import "DoricDevAssetsLoader.h" @interface DoricContextDebuggable : NSObject @property(nonatomic, weak) DoricContext *doricContext; @@ -83,6 +84,7 @@ - (instancetype)init { [DoricSingleton.instance.nativeDriver.registry registerMonitor:[DoricDevMonitor new]]; DoricSingleton.instance.nativeDriver.registry.globalPerformanceAnchorHook = [DoricDevPerformanceAnchorHook new]; [DoricSingleton.instance.nativeDriver.registry registerNativePlugin:DoricDevkitPlugin.class withName:@"devkit"]; + [DoricSingleton.instance.nativeDriver.registry.loaderManager registerLoader:[DoricDevAssetsLoader new]]; } return self; } diff --git a/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.h b/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.h new file mode 100644 index 00000000..40259bd7 --- /dev/null +++ b/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.h @@ -0,0 +1,9 @@ +// +// Created by pengfei.zhou on 2021/12/7. +// + +#import +#import + +@interface DoricDevAssetsLoader : DoricAssetsResourceLoader +@end \ No newline at end of file diff --git a/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m b/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m new file mode 100644 index 00000000..50da6e54 --- /dev/null +++ b/doric-iOS/Devkit/Classes/DoricDevAssetsLoader.m @@ -0,0 +1,16 @@ +// +// Created by pengfei.zhou on 2021/12/7. +// + +#import "DoricDevAssetsLoader.h" +#import "DoricDev.h" + +@implementation DoricDevAssetsLoader + +- (__kindof DoricResource *)load:(NSString *)identifier withContext:(DoricContext *)context { + if (DoricDev.instance.isInDevMode) { + + } + return [super load:identifier withContext:context]; +} +@end \ No newline at end of file