native package

This commit is contained in:
pengfei.zhou 2019-08-13 13:54:57 +08:00
parent 1e6fa459c3
commit a3a6d4111f
6 changed files with 23 additions and 10 deletions

View File

@ -1 +1 @@
../../../../../js-framework/demo ../../../../../demo/bundle/src

View File

@ -20,7 +20,7 @@ public class MainActivity extends AppCompatActivity {
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); setContentView(R.layout.activity_main);
DoricContext doricContext = DoricContext.create(this, DoricUtils.readAssetFile("demo/demo.js"), "demo for test"); DoricContext doricContext = DoricContext.create(this, DoricUtils.readAssetFile("demo/Snake.js"), "demo for test");
doricContext.callEntity("__init__", new JSONBuilder() doricContext.callEntity("__init__", new JSONBuilder()
.put("width", ViewGroup.LayoutParams.MATCH_PARENT) .put("width", ViewGroup.LayoutParams.MATCH_PARENT)
.put("height", ViewGroup.LayoutParams.MATCH_PARENT)); .put("height", ViewGroup.LayoutParams.MATCH_PARENT));

View File

@ -8,7 +8,7 @@ package com.github.penfeizhou.doric.utils;
public class DoricConstant { public class DoricConstant {
public static final String DORIC_BUNDLE_SANDBOX = "bundle/doric-sandbox.js"; public static final String DORIC_BUNDLE_SANDBOX = "bundle/doric-sandbox.js";
public static final String DORIC_BUNDLE_LIB = "bundle/doric-lib.js"; public static final String DORIC_BUNDLE_LIB = "bundle/doric-lib.js";
public static final String DORIC_MODULE_LIB = "./index"; public static final String DORIC_MODULE_LIB = "doric";
public static final String INJECT_LOG = "nativeLog"; public static final String INJECT_LOG = "nativeLog";

View File

@ -10,6 +10,8 @@
AAAF5D5802FC6E7E4F481F5D /* libPods-ExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */; }; AAAF5D5802FC6E7E4F481F5D /* libPods-ExampleTests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */; };
B1AF6AE00A9B4675290F5947 /* libPods-ExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 64B9242B26FEC4AEC20FF43D /* libPods-ExampleUITests.a */; }; B1AF6AE00A9B4675290F5947 /* libPods-ExampleUITests.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 64B9242B26FEC4AEC20FF43D /* libPods-ExampleUITests.a */; };
D9E087DE6FF1DB083B30D9E7 /* libPods-Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C043B7BA79339ABA1CF46881 /* libPods-Example.a */; }; D9E087DE6FF1DB083B30D9E7 /* libPods-Example.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C043B7BA79339ABA1CF46881 /* libPods-Example.a */; };
E21DC9D42302870000660C5C /* Snake.js in Resources */ = {isa = PBXBuildFile; fileRef = E21DC9D22302865E00660C5C /* Snake.js */; };
E21DC9D52302870000660C5C /* Counter.js in Resources */ = {isa = PBXBuildFile; fileRef = E21DC9D32302865E00660C5C /* Counter.js */; };
E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AEF22E9D2060098A085 /* AppDelegate.m */; }; E2334AF022E9D2060098A085 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AEF22E9D2060098A085 /* AppDelegate.m */; };
E2334AF322E9D2060098A085 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AF222E9D2060098A085 /* ViewController.m */; }; E2334AF322E9D2060098A085 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AF222E9D2060098A085 /* ViewController.m */; };
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2334AF422E9D2060098A085 /* Main.storyboard */; }; E2334AF622E9D2060098A085 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E2334AF422E9D2060098A085 /* Main.storyboard */; };
@ -18,7 +20,6 @@
E2334AFE22E9D2070098A085 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AFD22E9D2070098A085 /* main.m */; }; E2334AFE22E9D2070098A085 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334AFD22E9D2070098A085 /* main.m */; };
E2334B0822E9D2070098A085 /* ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B0722E9D2070098A085 /* ExampleTests.m */; }; E2334B0822E9D2070098A085 /* ExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B0722E9D2070098A085 /* ExampleTests.m */; };
E2334B1322E9D2070098A085 /* ExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B1222E9D2070098A085 /* ExampleUITests.m */; }; E2334B1322E9D2070098A085 /* ExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = E2334B1222E9D2070098A085 /* ExampleUITests.m */; };
E2F8FD6322ECBD310094BDBB /* demo.js in Resources */ = {isa = PBXBuildFile; fileRef = E2F8FD6222ECBD310094BDBB /* demo.js */; };
/* End PBXBuildFile section */ /* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */ /* Begin PBXContainerItemProxy section */
@ -48,6 +49,8 @@
942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; }; 942158E9B500A4C975FD37F3 /* libPods-ExampleTests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-ExampleTests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
A5AE090AE3815360EC768C8D /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; }; A5AE090AE3815360EC768C8D /* Pods-Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-Example/Pods-Example.release.xcconfig"; sourceTree = "<group>"; };
C043B7BA79339ABA1CF46881 /* libPods-Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Example.a"; sourceTree = BUILT_PRODUCTS_DIR; }; C043B7BA79339ABA1CF46881 /* libPods-Example.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Example.a"; sourceTree = BUILT_PRODUCTS_DIR; };
E21DC9D22302865E00660C5C /* Snake.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Snake.js; sourceTree = "<group>"; };
E21DC9D32302865E00660C5C /* Counter.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = Counter.js; sourceTree = "<group>"; };
E2334AEB22E9D2060098A085 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; E2334AEB22E9D2060098A085 /* Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Example.app; sourceTree = BUILT_PRODUCTS_DIR; };
E2334AEE22E9D2060098A085 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; }; E2334AEE22E9D2060098A085 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
E2334AEF22E9D2060098A085 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; }; E2334AEF22E9D2060098A085 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
@ -64,7 +67,6 @@
E2334B0E22E9D2070098A085 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; E2334B0E22E9D2070098A085 /* ExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
E2334B1222E9D2070098A085 /* ExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExampleUITests.m; sourceTree = "<group>"; }; E2334B1222E9D2070098A085 /* ExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExampleUITests.m; sourceTree = "<group>"; };
E2334B1422E9D2070098A085 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; }; E2334B1422E9D2070098A085 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
E2F8FD6222ECBD310094BDBB /* demo.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = demo.js; path = "../../../js-framework/demo/demo.js"; sourceTree = "<group>"; };
/* End PBXFileReference section */ /* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */ /* Begin PBXFrameworksBuildPhase section */
@ -118,9 +120,20 @@
name = Frameworks; name = Frameworks;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
E21DC9D12302865E00660C5C /* src */ = {
isa = PBXGroup;
children = (
E21DC9D22302865E00660C5C /* Snake.js */,
E21DC9D32302865E00660C5C /* Counter.js */,
);
name = src;
path = ../../demo/bundle/src;
sourceTree = "<group>";
};
E2334AE222E9D2060098A085 = { E2334AE222E9D2060098A085 = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E21DC9D12302865E00660C5C /* src */,
E2334AED22E9D2060098A085 /* Example */, E2334AED22E9D2060098A085 /* Example */,
E2334B0622E9D2070098A085 /* ExampleTests */, E2334B0622E9D2070098A085 /* ExampleTests */,
E2334B1122E9D2070098A085 /* ExampleUITests */, E2334B1122E9D2070098A085 /* ExampleUITests */,
@ -143,7 +156,6 @@
E2334AED22E9D2060098A085 /* Example */ = { E2334AED22E9D2060098A085 /* Example */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
E2F8FD6222ECBD310094BDBB /* demo.js */,
E2334AEE22E9D2060098A085 /* AppDelegate.h */, E2334AEE22E9D2060098A085 /* AppDelegate.h */,
E2334AEF22E9D2060098A085 /* AppDelegate.m */, E2334AEF22E9D2060098A085 /* AppDelegate.m */,
E2334AF122E9D2060098A085 /* ViewController.h */, E2334AF122E9D2060098A085 /* ViewController.h */,
@ -283,10 +295,11 @@
isa = PBXResourcesBuildPhase; isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
files = ( files = (
E21DC9D42302870000660C5C /* Snake.js in Resources */,
E21DC9D52302870000660C5C /* Counter.js in Resources */,
E2334AFB22E9D2070098A085 /* LaunchScreen.storyboard in Resources */, E2334AFB22E9D2070098A085 /* LaunchScreen.storyboard in Resources */,
E2334AF822E9D2070098A085 /* Assets.xcassets in Resources */, E2334AF822E9D2070098A085 /* Assets.xcassets in Resources */,
E2334AF622E9D2060098A085 /* Main.storyboard in Resources */, E2334AF622E9D2060098A085 /* Main.storyboard in Resources */,
E2F8FD6322ECBD310094BDBB /* demo.js in Resources */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };

View File

@ -31,9 +31,9 @@ - (void)viewDidLoad {
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(test:)]; UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(test:)];
[label addGestureRecognizer:recognizer]; [label addGestureRecognizer:recognizer];
label.userInteractionEnabled = YES; label.userInteractionEnabled = YES;
NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"demo" ofType:@"js"]; NSString *path = [[NSBundle bundleForClass:[self class]] pathForResource:@"Snake" ofType:@"js"];
NSString *jsContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil]; NSString *jsContent = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
self.doricContext = [[DoricContext alloc] initWithScript:jsContent source:@"demo"]; self.doricContext = [[DoricContext alloc] initWithScript:jsContent source:@"Snake"];
self.doricContext.rootNode.view = self.view; self.doricContext.rootNode.view = self.view;
[self.doricContext callEntity:@"__init__",@{@"width": [NSNumber numberWithFloat:self.view.width], [self.doricContext callEntity:@"__init__",@{@"width": [NSNumber numberWithFloat:self.view.width],
@"height":[NSNumber numberWithFloat:self.view.height]},nil]; @"height":[NSNumber numberWithFloat:self.view.height]},nil];

View File

@ -9,7 +9,7 @@
NSString * const DORIC_BUNDLE_SANDBOX = @"doric-sandbox"; NSString * const DORIC_BUNDLE_SANDBOX = @"doric-sandbox";
NSString * const DORIC_BUNDLE_LIB = @"doric-lib"; NSString * const DORIC_BUNDLE_LIB = @"doric-lib";
NSString * const DORIC_MODULE_LIB = @"./index"; NSString * const DORIC_MODULE_LIB = @"doric";
NSString * const INJECT_LOG = @"nativeLog"; NSString * const INJECT_LOG = @"nativeLog";