├── ios ├── WeexSDK │ ├── README.md │ ├── WeexSDKTests │ │ ├── dependency │ │ │ ├── libOCMock.a │ │ │ └── OCMock │ │ │ │ ├── OCMFunctions.h │ │ │ │ ├── NSNotificationCenter+OCMAdditions.h │ │ │ │ ├── OCMRecorder.h │ │ │ │ ├── OCMLocation.h │ │ │ │ ├── OCMMacroState.h │ │ │ │ └── OCMArg.h │ │ ├── TestSupportUtils.h │ │ ├── Info.plist │ │ ├── WeexSDKTests.m │ │ ├── testRootView.js │ │ ├── WXConvertTests.m │ │ ├── TestSupportUtils.m │ │ └── WXSDKManagerTests.m │ ├── WeexSDK │ │ ├── Resources │ │ │ └── wx_load_error@3x.png │ │ ├── Sources │ │ │ ├── Supporting Files │ │ │ │ └── WeexSDK-Prefix.pch │ │ │ ├── View │ │ │ │ ├── WXView.h │ │ │ │ ├── WXComponent+ViewManagement.h │ │ │ │ ├── WXRootView.h │ │ │ │ ├── WXErrorView.h │ │ │ │ ├── WXRootView.m │ │ │ │ ├── WXErrorView.m │ │ │ │ └── WXView.m │ │ │ ├── Display │ │ │ │ ├── WXLayer.h │ │ │ │ ├── WXComponent+Display.h │ │ │ │ ├── WXDisplayQueue.h │ │ │ │ ├── WXLayer.m │ │ │ │ ├── UIBezierPath+Weex.h │ │ │ │ ├── WXRoundedRect.h │ │ │ │ └── WXDisplayQueue.m │ │ │ ├── Component │ │ │ │ ├── WXImageComponent.h │ │ │ │ ├── WXDivComponent.h │ │ │ │ ├── WXTextComponent.h │ │ │ │ ├── WXSwitchComponent.h │ │ │ │ ├── WXAComponent.h │ │ │ │ ├── WXTextAreaComponent.h │ │ │ │ ├── WXDivComponent.m │ │ │ │ ├── WXRefreshComponent.h │ │ │ │ ├── WXLoadingComponent.h │ │ │ │ ├── WXEmbedComponent.h │ │ │ │ ├── WXComponent+GradientColor.h │ │ │ │ ├── WXLoadingIndicator.h │ │ │ │ ├── WXSliderComponent.h │ │ │ │ ├── WXWebComponent.h │ │ │ │ ├── WXTextInputComponent.h │ │ │ │ ├── WXCanvasComponent.h │ │ │ │ ├── WXCellComponent.h │ │ │ │ ├── WXListComponent.h │ │ │ │ ├── WXScrollerComponent.h │ │ │ │ ├── WXVideoComponent.h │ │ │ │ ├── WXTransform.h │ │ │ │ └── WXIndicatorComponent.h │ │ │ ├── Module │ │ │ │ ├── WXDomModule.h │ │ │ │ ├── WXMetaModule.h │ │ │ │ ├── WXClipboardModule.h │ │ │ │ ├── WXModalUIModule.h │ │ │ │ ├── WXGlobalEventModule.h │ │ │ │ ├── WXNavigatorModule.h │ │ │ │ ├── WXPickerModule.h │ │ │ │ ├── WXWebSocketModule.h │ │ │ │ ├── WXWebViewModule.h │ │ │ │ ├── WXInstanceWrap.h │ │ │ │ ├── WXCanvasModule.h │ │ │ │ ├── WXAnimationModule.h │ │ │ │ ├── WXTimerModule.h │ │ │ │ ├── WXStreamModule.h │ │ │ │ ├── WXStorageModule.h │ │ │ │ ├── WXClipboardModule.m │ │ │ │ ├── WXMetaModule.m │ │ │ │ └── WXInstanceWrap.m │ │ │ ├── Network │ │ │ │ ├── WXResourceResponse.m │ │ │ │ ├── WXResourceResponse.h │ │ │ │ ├── WXResourceRequestHandlerDefaultImpl.h │ │ │ │ ├── WXResourceRequest.h │ │ │ │ └── WXResourceRequestHandler.h │ │ │ ├── Bridge │ │ │ │ ├── WXJSCoreBridge.h │ │ │ │ ├── WXDebugLoggerBridge.h │ │ │ │ ├── JSValue+Weex.h │ │ │ │ ├── WXCallJSMethod.h │ │ │ │ ├── WXComponentMethod.h │ │ │ │ ├── WXPolyfillSet.h │ │ │ │ ├── WXModuleMethod.h │ │ │ │ ├── WXCallJSMethod.m │ │ │ │ ├── WXPolyfillSet.m │ │ │ │ └── WXComponentMethod.m │ │ │ ├── Events │ │ │ │ └── WXComponent+Events.h │ │ │ ├── Layout │ │ │ │ └── WXComponent+Layout.h │ │ │ ├── Protocol │ │ │ │ ├── WXEventModuleProtocol.h │ │ │ │ ├── WXDestroyProtocol.h │ │ │ │ ├── WXTextComponentProtocol.h │ │ │ │ ├── WXImgLoaderProtocol.h │ │ │ │ ├── WXURLRewriteProtocol.h │ │ │ │ ├── WXAppMonitorProtocol.h │ │ │ │ ├── WXScrollerProtocol.h │ │ │ │ └── WXNetworkProtocol.h │ │ │ ├── WebSocket │ │ │ │ ├── WXWebSocketDefaultImpl.h │ │ │ │ ├── SRWebSocket+Weex.h │ │ │ │ ├── WXWebSocketHandler.h │ │ │ │ └── SRWebSocket+Weex.m │ │ │ ├── Handler │ │ │ │ ├── WXNavigationDefaultImpl.h │ │ │ │ ├── WXURLRewriteDefaultImpl.h │ │ │ │ └── WXURLRewriteDefaultImpl.m │ │ │ ├── Utility │ │ │ │ ├── WXThreadSafeMutableArray.h │ │ │ │ ├── NSObject+WXSwizzle.h │ │ │ │ ├── WXWeakObjectWrapper.h │ │ │ │ ├── WXThreadSafeMutableDictionary.h │ │ │ │ ├── WXThreadSafeCounter.h │ │ │ │ ├── WXWeakObjectWrapper.m │ │ │ │ ├── WXSimulatorShortcutMananger.h │ │ │ │ ├── NSTimer+Weex.h │ │ │ │ ├── WXThreadSafeCounter.m │ │ │ │ ├── NSArray+Weex.h │ │ │ │ ├── WXAssert.m │ │ │ │ ├── NSTimer+Weex.m │ │ │ │ ├── NSObject+WXSwizzle.m │ │ │ │ ├── NSArray+Weex.m │ │ │ │ ├── WXAppConfiguration.h │ │ │ │ └── WXType.h │ │ │ ├── Manager │ │ │ │ ├── WXDatePickerManager.h │ │ │ │ ├── WXRuleManager.h │ │ │ │ ├── WXInvocationConfig.h │ │ │ │ ├── WXHandlerFactory.h │ │ │ │ ├── WXServiceFactory.h │ │ │ │ ├── WXSDKManager.h │ │ │ │ ├── WXModuleFactory.h │ │ │ │ ├── WXComponentFactory.h │ │ │ │ └── WXHandlerFactory.m │ │ │ ├── Model │ │ │ │ ├── WXComponent+Navigation.h │ │ │ │ ├── WXBridgeMethod.h │ │ │ │ └── WXSDKInstance_private.h │ │ │ ├── Debug │ │ │ │ └── WXDebugTool.h │ │ │ ├── Loader │ │ │ │ ├── WXWebSocketLoader.h │ │ │ │ └── WXResourceLoader.h │ │ │ ├── Controller │ │ │ │ ├── WXBaseViewController.h │ │ │ │ └── WXRootViewController.h │ │ │ ├── WeexSDK.h │ │ │ └── Engine │ │ │ │ └── WXSDKError.h │ │ └── Info.plist │ ├── WeexSDK.xcodeproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── WeexSDK_MTL │ │ ├── WeexSDK_MTL.m │ │ └── WeexSDK_MTL.h │ ├── NOTICE │ └── WeexSDK.podspec ├── HackerNews.xcodeproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── HackerNews.xcworkspace │ └── contents.xcworkspacedata ├── HackerNews │ ├── ViewController.h │ ├── WXEventModule.h │ ├── AppDelegate.h │ ├── WXImgLoaderDefaultImpl.h │ ├── main.m │ ├── AppDefine.h │ ├── WXEventModule.m │ ├── Assets.xcassets │ │ ├── LaunchImage-2.launchimage │ │ │ └── Contents.json │ │ ├── LaunchImage.launchimage │ │ │ └── Contents.json │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── Main.storyboard │ │ └── LaunchScreen.storyboard │ ├── Info.plist │ └── WXImgLoaderDefaultImpl.m ├── Podfile ├── HackerNewsTests │ ├── Info.plist │ └── HackerNewsTests.m ├── HackerNewsUITests │ ├── Info.plist │ └── HackerNewsUITests.m └── .gitignore ├── android ├── WeexSDK │ ├── assets │ │ ├── .gitkeep │ │ └── .gitkeeper │ ├── publish.sh │ ├── libs │ │ ├── x86 │ │ │ └── libweexv8.so │ │ └── armeabi │ │ │ └── libweexv8.so │ ├── license │ │ ├── plexus-utils-3.0.24.jar │ │ ├── license-gradle-plugin-0.12.1.jar │ │ └── maven-license-plugin-1.10.b1.jar │ ├── src │ │ └── main │ │ │ ├── res │ │ │ └── drawable │ │ │ │ └── error.png │ │ │ ├── java │ │ │ └── com │ │ │ │ └── taobao │ │ │ │ └── weex │ │ │ │ └── dom │ │ │ │ ├── flex │ │ │ │ ├── CSSWrap.java │ │ │ │ ├── CSSDirection.java │ │ │ │ ├── CSSPositionType.java │ │ │ │ ├── CSSAlign.java │ │ │ │ ├── CSSFlexDirection.java │ │ │ │ ├── CSSJustify.java │ │ │ │ ├── MeasureOutput.java │ │ │ │ ├── CSSConstants.java │ │ │ │ ├── FloatUtil.java │ │ │ │ ├── CSSLayoutContext.java │ │ │ │ └── CachedCSSLayout.java │ │ │ │ ├── CSSWrapConvert.java │ │ │ │ ├── CSSPositionTypeConvert.java │ │ │ │ ├── CSSJustifyConvert.java │ │ │ │ ├── CSSFlexDirectionConvert.java │ │ │ │ ├── CSSAlignConvert.java │ │ │ │ └── WXCustomStyleSpan.java │ │ │ └── AndroidManifest.xml │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── unittest.sh │ ├── README.md │ ├── NOTICE │ ├── proguard-rules.pro │ └── gradle.properties ├── app │ ├── .gitignore │ ├── src │ │ ├── main │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ ├── dimens.xml │ │ │ │ │ ├── colors.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── values-w820dp │ │ │ │ │ └── dimens.xml │ │ │ │ └── layout │ │ │ │ │ └── activity_main.xml │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── weex │ │ │ │ │ └── hackernews │ │ │ │ │ └── WXApplication.java │ │ │ └── AndroidManifest.xml │ │ ├── test │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── example │ │ │ │ └── weex │ │ │ │ └── hackernews │ │ │ │ └── ExampleUnitTest.java │ │ └── androidTest │ │ │ └── java │ │ │ └── com │ │ │ └── example │ │ │ └── weex │ │ │ └── hackernews │ │ │ └── ExampleInstrumentedTest.java │ ├── proguard-rules.pro │ └── build.gradle ├── settings.gradle ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── .gitignore ├── build.gradle └── gradle.properties ├── .babelrc ├── qrcode.jpg ├── src ├── mixins │ └── index.js ├── App.vue ├── store │ ├── mutations.js │ ├── fetch.js │ ├── index.js │ └── actions.js ├── components │ ├── external-link.vue │ └── app-header.vue ├── entry.js ├── views │ ├── ArticleView.vue │ └── UserView.vue ├── router.js └── filters │ └── index.js ├── .gitignore ├── index.html ├── package.json ├── webpack.config.js └── README.zh.md /ios/WeexSDK/README.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android/WeexSDK/assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android/WeexSDK/assets/.gitkeeper: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /android/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { "presets": ["es2015"] } 2 | -------------------------------------------------------------------------------- /android/WeexSDK/publish.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | ./gradlew clean assemble publish -------------------------------------------------------------------------------- /qrcode.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/qrcode.jpg -------------------------------------------------------------------------------- /android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | HackerNews 3 | 4 | -------------------------------------------------------------------------------- /android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | include ':weex_sdk' 3 | 4 | project(':weex_sdk').projectDir = new File(settingsDir, 'WeexSDK') 5 | -------------------------------------------------------------------------------- /android/WeexSDK/libs/x86/libweexv8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/WeexSDK/libs/x86/libweexv8.so -------------------------------------------------------------------------------- /android/WeexSDK/libs/armeabi/libweexv8.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/WeexSDK/libs/armeabi/libweexv8.so -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /android/WeexSDK/license/plexus-utils-3.0.24.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/WeexSDK/license/plexus-utils-3.0.24.jar -------------------------------------------------------------------------------- /android/WeexSDK/src/main/res/drawable/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/WeexSDK/src/main/res/drawable/error.png -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/dependency/libOCMock.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/ios/WeexSDK/WeexSDKTests/dependency/libOCMock.a -------------------------------------------------------------------------------- /android/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /android/WeexSDK/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/WeexSDK/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Resources/wx_load_error@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/ios/WeexSDK/WeexSDK/Resources/wx_load_error@3x.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/mixins/index.js: -------------------------------------------------------------------------------- 1 | export default { 2 | methods: { 3 | jump (to) { 4 | if (this.$router) { 5 | this.$router.push(to) 6 | } 7 | } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /android/WeexSDK/license/license-gradle-plugin-0.12.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/WeexSDK/license/license-gradle-plugin-0.12.1.jar -------------------------------------------------------------------------------- /android/WeexSDK/license/maven-license-plugin-1.10.b1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/weexteam/hackernews-App-powered-by-Apache-Weex/HEAD/android/WeexSDK/license/maven-license-plugin-1.10.b1.jar -------------------------------------------------------------------------------- /android/WeexSDK/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | build 4 | captures 5 | local.properties 6 | target 7 | bin 8 | .classpath 9 | .project 10 | .settings 11 | gen 12 | *.iml 13 | lint.xml 14 | project.properties -------------------------------------------------------------------------------- /android/WeexSDK/unittest.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | ./gradlew clean testDebugUnitTest -PtargetSDK=19 3 | ./gradlew jacocoTestReportDebug -PtargetSDK=19 4 | osascript -e 'display notification "Test Done!" with title "Weex Unit Test"' 5 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ios/HackerNews.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #ff9900 4 | #ff6600 5 | #006699 6 | 7 | -------------------------------------------------------------------------------- /android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Mon Dec 28 10:00:20 PST 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 7 | -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 16 | -------------------------------------------------------------------------------- /android/WeexSDK/README.md: -------------------------------------------------------------------------------- 1 | ## Unit Test 2 | 3 | Unit test code is under 'src/test'. You can run unit test use command: 4 | ```bash 5 | ./gradlew clean testDebugUnitTest jacocoTestReportDebug 6 | ``` 7 | This task will run all unit test and produce both unit test report and jacoco test coverage report in 'build/reports'. 8 | -------------------------------------------------------------------------------- /ios/HackerNews.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Supporting Files/WeexSDK-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #import 10 | #import "WXDefine.h" 11 | #endif -------------------------------------------------------------------------------- /ios/HackerNews/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (nonatomic, strong) NSURL *url; 14 | 15 | @end 16 | 17 | -------------------------------------------------------------------------------- /ios/HackerNews/WXEventModule.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXEventModule.h 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface WXEventModule : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/HackerNews/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /ios/Podfile: -------------------------------------------------------------------------------- 1 | source 'https://github.com/CocoaPods/Specs.git' 2 | platform :ios, '7.0' 3 | #inhibit_all_warnings! 4 | 5 | def common 6 | pod 'WeexSDK', :path=>'./WeexSDK/' 7 | pod 'SDWebImage', '3.7.5' 8 | pod 'SocketRocket', '0.4.2' 9 | end 10 | 11 | target 'HackerNews' do 12 | common 13 | end 14 | 15 | target 'HackerNewsUITests' do 16 | common 17 | end 18 | -------------------------------------------------------------------------------- /android/WeexSDK/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Oct 21 11:34:03 PDT 2015 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | # distributionUrl=http://gw.alicdn.com/bao/uploaded/LB1J5WLJVXXXXcMXpXXXXXXXXXX.zip 7 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 8 | -------------------------------------------------------------------------------- /ios/HackerNews/WXImgLoaderDefaultImpl.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSObject_WXImgLoaderDefaultImpl.h 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface WXImgLoaderDefaultImpl : NSObject 13 | @end 14 | -------------------------------------------------------------------------------- /ios/HackerNews/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /android/app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK_MTL/WeexSDK_MTL.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WeexSDK_MTL.h" 10 | 11 | @implementation WeexSDK_MTL 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/View/WXView.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXView : UIView 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK_MTL/WeexSDK_MTL.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WeexSDK_MTL : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Display/WXLayer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXLayer : CALayer 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXImageComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXImageComponent : WXComponent 12 | 13 | @end -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Display/WXComponent+Display.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXComponent (Display) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXDivComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXDivComponent : WXComponent 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXTextComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXTextComponent : WXComponent 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXSwitchComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXSwitchComponent : WXComponent 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/View/WXComponent+ViewManagement.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXComponent (ViewManagement) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXDomModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXModuleProtocol.h" 10 | 11 | @interface WXDomModule : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Network/WXResourceResponse.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | 10 | #import "WXResourceResponse.h" 11 | 12 | @implementation WXResourceResponse 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXJSCoreBridge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXBridgeProtocol.h" 10 | 11 | @interface WXJSCoreBridge : NSObject 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Events/WXComponent+Events.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXComponent (Events) 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXAComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXAComponent : WXComponent 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Network/WXResourceResponse.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | 10 | #import 11 | 12 | @interface WXResourceResponse : NSURLResponse 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSWrap.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public enum CSSWrap { 9 | NOWRAP, 10 | WRAP, 11 | } 12 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXTextAreaComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXTextAreaComponent : WXComponent 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /src/store/mutations.js: -------------------------------------------------------------------------------- 1 | export function SET_ACTIVE_TYPE (state, { type }) { 2 | state.activeType = type 3 | } 4 | 5 | export function SET_LIST (state, { type, ids }) { 6 | state.lists[type] = ids 7 | } 8 | 9 | export function SET_ITEMS (state, { items }) { 10 | items.forEach(item => { 11 | if (item) { 12 | Vue.set(state.items, item.id, item) 13 | } 14 | }) 15 | } 16 | 17 | export function SET_USER (state, { user }) { 18 | Vue.set(state.users, user.id, user) 19 | } 20 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXDivComponent.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXDivComponent.h" 10 | 11 | @interface WXDivComponent () 12 | @end 13 | 14 | @implementation WXDivComponent 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by IDE 2 | .idea/ 3 | *.iml 4 | .DS_Store 5 | 6 | # Created by Builder 7 | coverage 8 | dist 9 | 10 | # Node 11 | logs 12 | *.log 13 | npm-debug.log* 14 | node_modules 15 | .npm 16 | 17 | # Runtime data 18 | pids 19 | *.pid 20 | *.seed 21 | 22 | # Android 23 | android/playground/app/gradlew 24 | android/playground/app/gradlew.bat 25 | android/playground/app/gradle/wrapper/gradle-wrapper.jar 26 | android/playground/app/gradle/wrapper/gradle-wrapper.properties 27 | 28 | docs 29 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/CSSWrapConvert.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.dom; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.taobao.weex.dom.flex.CSSWrap; 6 | 7 | class CSSWrapConvert { 8 | 9 | public static CSSWrap convert(String s) { 10 | CSSWrap cssWrap = CSSWrap.NOWRAP; 11 | if (TextUtils.isEmpty(s)) { 12 | return cssWrap; 13 | } else if (s.equals("wrap")) { 14 | return CSSWrap.WRAP; 15 | } 16 | return cssWrap; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Layout/WXComponent+Layout.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | #import "WXSDKInstance.h" 11 | #import "WXUtility.h" 12 | 13 | @interface WXComponent (Layout) 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXMetaModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXMetaModule : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSDirection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public enum CSSDirection { 9 | INHERIT, 10 | LTR, 11 | RTL, 12 | } 13 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSPositionType.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public enum CSSPositionType { 9 | RELATIVE, 10 | ABSOLUTE, 11 | } 12 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXClipboardModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXClipboardModule : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXModalUIModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXModalUIModule : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXGlobalEventModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXGlobalEventModule : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXEventModuleProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXModuleProtocol.h" 10 | 11 | @protocol WXEventModuleProtocol 12 | 13 | - (void)openURL:(NSString *)url; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXRefreshComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXRefreshComponent : WXComponent 12 | 13 | - (void)refresh; 14 | 15 | - (BOOL)displayState; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXNavigatorModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | 12 | @interface WXNavigatorModule : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/View/WXRootView.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @class WXSDKInstance; 12 | @interface WXRootView : UIView 13 | 14 | @property (nonatomic, weak) WXSDKInstance *instance; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXPickerModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXPickerModule : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXDebugLoggerBridge.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXBridgeProtocol.h" 10 | 11 | @interface WXDebugLoggerBridge : NSObject 12 | 13 | - (instancetype)initWithURL:(NSURL *) URL; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXLoadingComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXLoadingComponent : WXComponent 12 | 13 | - (void)resizeFrame; 14 | - (void)loading; 15 | - (BOOL)displayState; 16 | 17 | @end -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/WebSocket/WXWebSocketDefaultImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXWebSocketHandler.h" 11 | 12 | @interface WXWebSocketDefaultImpl : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSAlign.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public enum CSSAlign { 9 | AUTO, 10 | FLEX_START, 11 | CENTER, 12 | FLEX_END, 13 | STRETCH, 14 | } 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXEmbedComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | #import "WXErrorView.h" 11 | 12 | @interface WXEmbedComponent : WXComponent 13 | 14 | - (void)refreshWeex; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Handler/WXNavigationDefaultImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXNavigationProtocol.h" 11 | 12 | @interface WXNavigationDefaultImpl : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXURLRewriteProtocol.h" 11 | 12 | @interface WXURLRewriteDefaultImpl : NSObject 13 | 14 | @end 15 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSFlexDirection.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public enum CSSFlexDirection { 9 | COLUMN, 10 | COLUMN_REVERSE, 11 | ROW, 12 | ROW_REVERSE 13 | } 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXComponent+GradientColor.h: -------------------------------------------------------------------------------- 1 | // 2 | // WXComponent+GradientColor.h 3 | // Pods 4 | // 5 | // Created by bobning on 16/12/23. 6 | // 7 | // 8 | 9 | #import 10 | #import 11 | #import "WXComponent.h" 12 | #import "WXType.h" 13 | 14 | @interface WXComponent (GradientColor) 15 | 16 | - (void)setGradientLayer; 17 | 18 | - (UIImage *)gradientColorImageFromColors:(NSArray*)colors gradientType:(WXGradientType)gradientType imgSize:(CGSize)imgSize; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXLoadingIndicator.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXLoadingIndicator : WXComponent 12 | 13 | - (void)start; 14 | - (void)stop; 15 | - (void)setFrame:(CGRect)frame; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXWebSocketModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | #import "SRWebSocket.h" 12 | 13 | @interface WXWebSocketModule : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXWebViewModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | #import "WXDomModule.h" 12 | 13 | @interface WXWebViewModule : WXDomModule 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /android/app/src/test/java/com/example/weex/hackernews/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.example.weex.hackernews; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | @Test 14 | public void addition_isCorrect() throws Exception { 15 | assertEquals(4, 2 + 2); 16 | } 17 | } -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Display/WXDisplayQueue.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | // Global queue for displaying content 12 | @interface WXDisplayQueue : NSObject 13 | 14 | + (void)addBlock:(void(^)())block; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXThreadSafeMutableArray.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | /** 12 | * @abstract Thread safe NSMutableArray 13 | */ 14 | @interface WXThreadSafeMutableArray : NSMutableArray 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXInstanceWrap.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXModuleProtocol.h" 10 | 11 | @interface WXInstanceWrap : NSObject 12 | 13 | - (void)error:(NSInteger)type code:(NSInteger)code info:(NSString *)info; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSJustify.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public enum CSSJustify { 9 | FLEX_START, 10 | CENTER, 11 | FLEX_END, 12 | SPACE_BETWEEN, 13 | SPACE_AROUND, 14 | } 15 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXCanvasModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXCanvasModule : NSObject 13 | 14 | - (UIImage *) getImage:(NSString *)imageURL; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXDestroyProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @protocol WXDestroyProtocol 12 | 13 | /** 14 | * @abstract execute unload function before dealloc 15 | */ 16 | - (void)unload; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/JSValue+Weex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface JSValue (Weex) 12 | 13 | + (JSValue *)wx_valueWithReturnValueFromInvocation:(NSInvocation *)invocation inContext:(JSContext *)context; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Network/WXResourceRequestHandlerDefaultImpl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | 10 | #import 11 | #import "WXResourceRequestHandler.h" 12 | 13 | @interface WXResourceRequestHandlerDefaultImpl : NSObject 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/NSObject+WXSwizzle.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | 10 | #import 11 | 12 | @interface NSObject (WXSwizzle) 13 | 14 | + (BOOL)weex_swizzle:(Class)originalClass Method:(SEL)originalSelector withMethod:(SEL)swizzledSelector; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXWeakObjectWrapper.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXWeakObjectWrapper : NSObject 12 | 13 | @property (nonatomic, weak, readonly) id weakObject; 14 | 15 | - (id)initWithWeakObject:(id)weakObject; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXThreadSafeMutableDictionary.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | /** 12 | * @abstract Thread safe NSMutableDictionary 13 | */ 14 | @interface WXThreadSafeMutableDictionary : NSMutableDictionary 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/MeasureOutput.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | /** 9 | * POJO to hold the output of the measure function. 10 | */ 11 | public class MeasureOutput { 12 | 13 | public float width; 14 | public float height; 15 | } 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXSliderComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXComponent.h" 11 | 12 | @class WXIndicatorView; 13 | 14 | @interface WXSliderComponent : WXComponent 15 | 16 | - (void)setIndicatorView:(WXIndicatorView *)indicatorView; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXTextComponentProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | @protocol WXTextComponentProtocol 10 | 11 | @property (nonatomic, strong) NSTextStorage *textStorage; 12 | @property (nonatomic, assign) UIEdgeInsets border; 13 | @property (nonatomic, assign) UIEdgeInsets padding; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Display/WXLayer.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXLayer.h" 10 | #import "WXDefine.h" 11 | #import "WXComponent.h" 12 | #import "WXComponent_internal.h" 13 | 14 | @implementation WXLayer 15 | 16 | - (void)display 17 | { 18 | [self.wx_component _willDisplayLayer:self]; 19 | } 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXWebComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | @interface WXWebComponent : WXComponent 12 | 13 | - (void)notifyWebview:(NSDictionary *) data; 14 | 15 | - (void)reload; 16 | 17 | - (void)goBack; 18 | 19 | - (void)goForward; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXThreadSafeCounter.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | /** 12 | * @abstract a thread-safe counter 13 | */ 14 | @interface WXThreadSafeCounter : NSObject 15 | 16 | @property (atomic, readonly) int32_t value; 17 | 18 | - (int32_t)increase; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/View/WXErrorView.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @protocol WXErrorViewDelegate 12 | 13 | - (void)onclickErrorView; 14 | 15 | @end 16 | 17 | @interface WXErrorView : UIView 18 | 19 | @property (nonatomic, weak) id delegate; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXTextInputComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | #import "WXTextComponentProtocol.h" 11 | #import "WXDatePickerManager.h" 12 | 13 | @interface WXTextInputComponent : WXComponent 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /android/app/src/main/java/com/example/weex/hackernews/WXApplication.java: -------------------------------------------------------------------------------- 1 | package com.example.weex.hackernews; 2 | 3 | 4 | import android.app.Application; 5 | 6 | import com.taobao.weex.InitConfig; 7 | import com.taobao.weex.WXSDKEngine; 8 | 9 | 10 | /** 11 | * Created by Hanks on 16/12/8. 12 | */ 13 | public class WXApplication extends Application { 14 | 15 | @Override 16 | public void onCreate() { 17 | super.onCreate(); 18 | InitConfig config=new InitConfig.Builder().setImgAdapter(new ImageAdapter()).build(); 19 | WXSDKEngine.initialize(this,config); 20 | } 21 | } 22 | 23 | -------------------------------------------------------------------------------- /android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | 21 | task clean(type: Delete) { 22 | delete rootProject.buildDir 23 | } 24 | -------------------------------------------------------------------------------- /android/WeexSDK/NOTICE: -------------------------------------------------------------------------------- 1 | Weex Sdk Android 2 | Copyright 2016 Alibaba Group 3 | 4 | This product includes software developed at Alibaba Group. (http://www.alibabagroup.com) 5 | 6 | This product contains software css-layout(https://github.com/facebook/css-layout) developed 7 | by Facebook Inc., licensed under the BSD License. 8 | 9 | This product contains software React Native(https://github.com/facebook/react-native) developed 10 | by Facebook Inc., licensed under the BSD License. 11 | 12 | This product contains software Guava(https://github.com/google/guava) developed 13 | by Google Inc. , licensed under the Apache License. 14 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXCanvasComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXCanvasModule.h" 11 | #import 12 | 13 | @interface WXCanvasComponent : WXComponent 14 | 15 | - (void) addDrawActions:(NSArray *)actions canvasModule:(WXCanvasModule*)canvasModule; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXAnimationModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXAnimationModule : NSObject 13 | 14 | - (void)animation:(WXComponent *)targetComponent args:(NSDictionary *)args callback:(WXModuleCallback)callback; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXWeakObjectWrapper.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXWeakObjectWrapper.h" 10 | 11 | @implementation WXWeakObjectWrapper 12 | 13 | - (id)initWithWeakObject:(id)weakObject 14 | { 15 | if (self = [super init]) { 16 | _weakObject = weakObject; 17 | } 18 | 19 | return self; 20 | } 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /ios/WeexSDK/NOTICE: -------------------------------------------------------------------------------- 1 | Weex Sdk iOS 2 | Copyright 2016 Alibaba Group 3 | 4 | This product includes software developed at Alibaba Group. (http://www.alibabagroup.com) 5 | 6 | This product contains software css-layout(https://github.com/facebook/css-layout) developed 7 | by Facebook Inc., licensed under the BSD License. 8 | 9 | This product contains software React Native(https://github.com/facebook/react-native) developed 10 | by Facebook Inc., licensed under the BSD License. 11 | 12 | This product contains software SRWebSocket (https://github.com/facebook/SocketRocket)by Facebook Inc., licensed under the Apache License, Version 2.0. 13 | 14 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSConstants.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public class CSSConstants { 9 | 10 | public static final float UNDEFINED = Float.NaN; 11 | 12 | public static boolean isUndefined(float value) { 13 | return Float.compare(value, UNDEFINED) == 0; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXSimulatorShortcutMananger.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | 12 | @interface WXSimulatorShortcutMananger : NSObject 13 | 14 | + (void)registerSimulatorShortcutWithKey:(NSString *)key modifierFlags:(UIKeyModifierFlags)flags action:(dispatch_block_t)action; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/WebSocket/SRWebSocket+Weex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "SRWebSocket.h" 10 | #import "WXWebSocketHandler.h" 11 | #import 12 | 13 | @interface SRWebSocket (Weex) 14 | 15 | @property (nonatomic, copy) NSString *wx_Identifier; 16 | @property (nonatomic, weak) id wx_WebSocketDelegate; 17 | 18 | @end 19 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/CSSPositionTypeConvert.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.dom; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.taobao.weex.dom.flex.CSSPositionType; 6 | 7 | class CSSPositionTypeConvert { 8 | 9 | public static CSSPositionType convert(String s) { 10 | CSSPositionType position = CSSPositionType.RELATIVE; 11 | if (TextUtils.isEmpty(s) || s.equals("relative") || s.equals("sticky")) { 12 | position = CSSPositionType.RELATIVE; 13 | } else if (s.equals("absolute") || s.equals("fixed")) { 14 | position = CSSPositionType.ABSOLUTE; 15 | } 16 | return position; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ios/HackerNews/AppDefine.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDefine.h 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #ifndef AppDefine_h 10 | #define AppDefine_h 11 | 12 | 13 | #define CURRENT_IP @"your computer ip address" 14 | 15 | #if TARGET_IPHONE_SIMULATOR 16 | #define DEMO_HOST @"127.0.0.1" 17 | #else 18 | #define DEMO_HOST CURRENT_IP 19 | #endif 20 | 21 | #define DEMO_URL(path) [NSString stringWithFormat:@"http://%@:12580/%s", DEMO_HOST, #path] 22 | 23 | #define HOME_URL [NSString stringWithFormat:@"http://%@:12580/dist/index.js", DEMO_HOST] 24 | 25 | #endif /* AppDefine_h */ 26 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/NSTimer+Weex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface NSTimer (Weex) 12 | 13 | + (NSTimer *)wx_scheduledTimerWithTimeInterval:(NSTimeInterval)interval 14 | block:(void(^)())block 15 | repeats:(BOOL)repeats; 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /src/components/external-link.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 27 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXThreadSafeCounter.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXThreadSafeCounter.h" 10 | #import 11 | 12 | @implementation WXThreadSafeCounter{ 13 | int32_t _value; 14 | } 15 | 16 | - (int32_t)value 17 | { 18 | return _value; 19 | } 20 | 21 | - (int32_t)increase { 22 | return OSAtomicIncrement32(&_value); 23 | } 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /android/app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 12 | 13 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/TestSupportUtils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | 12 | extern bool WXTransform3DApproximateToTransform(CATransform3D a,CATransform3D b); 13 | 14 | extern bool WXRectApproximateToRect(CGRect a,CGRect b); 15 | 16 | @interface TestSupportUtils : NSObject 17 | /** 18 | *设置等待时间 19 | */ 20 | +(void)waitSecs:(NSTimeInterval)secs; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/NSArray+Weex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface NSArray (Weex) 12 | 13 | - (id)wx_safeObjectAtIndex:(NSUInteger)index; 14 | 15 | @end 16 | 17 | @interface NSMutableArray (Weex) 18 | 19 | + (id)wx_mutableArrayUsingWeakReferences; 20 | 21 | + (id)wx_mutableArrayUsingWeakReferencesWithCapacity:(NSUInteger)capacity; 22 | + (void)wx_releaseArray:(id)array; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXCellComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | @class WXListComponent; 11 | 12 | @interface WXCellComponent : WXComponent 13 | 14 | @property (nonatomic, strong) NSString *scope; 15 | @property (nonatomic, assign) UITableViewRowAnimation insertAnimation; 16 | @property (nonatomic, assign) UITableViewRowAnimation deleteAnimation; 17 | @property (nonatomic, weak) WXListComponent *list; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/FloatUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | public class FloatUtil { 9 | 10 | private static final float EPSILON = .00001f; 11 | 12 | public static boolean floatsEqual(float f1, float f2) { 13 | if (Float.isNaN(f1) || Float.isNaN(f2)) { 14 | return Float.isNaN(f1) && Float.isNaN(f2); 15 | } 16 | return Math.abs(f2 - f1) < EPSILON; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXCallJSMethod.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXBridgeMethod.h" 10 | 11 | @interface WXCallJSMethod : WXBridgeMethod 12 | 13 | - (instancetype)initWithModuleName:(NSString *)moduleName 14 | methodName:(NSString *)methodName 15 | arguments:(NSArray *)arguments 16 | instance:(WXSDKInstance *)instance; 17 | 18 | - (NSDictionary *)callJSTask; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/Hanks/Projects/AndroidSDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXComponentMethod.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXBridgeMethod.h" 10 | @class WXComponent; 11 | 12 | @interface WXComponentMethod : WXBridgeMethod 13 | 14 | - (instancetype)initWithComponentRef:(NSString *)ref 15 | methodName:(NSString *)methodName 16 | arguments:(NSArray *)arguments 17 | instance:(WXSDKInstance *)instance; 18 | 19 | - (void)invoke; 20 | 21 | @end 22 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXDatePickerManager.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @protocol WXDatePickerManagerDelegate 12 | @optional 13 | - (void)fetchDatePickerValue:(NSString *)value; 14 | @end 15 | 16 | @interface WXDatePickerManager : NSObject 17 | 18 | @property (nonatomic, weak) id delegate; 19 | 20 | -(void)show; 21 | -(void)hide; 22 | -(void)updateDatePicker:(NSDictionary *)attributes; 23 | 24 | @end 25 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXTimerModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXTimerModule : NSObject 13 | 14 | - (NSMutableDictionary *)timers; 15 | 16 | - (void)createTimerWithCallback:(NSString *)callbackID time:(NSTimeInterval)milliseconds target:(id)target selector:(SEL)selector shouldRepeat:(BOOL)shouldRepeat; 17 | 18 | - (void)clearTimeout:(NSString *)callbackID; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXStreamModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXStreamModule : NSObject 13 | 14 | - (void)fetch:(NSDictionary *)options callback:(WXModuleCallback)callback progressCallback:(WXModuleKeepAliveCallback)progressCallback; 15 | - (void)sendHttp:(NSDictionary*)param callback:(WXModuleCallback)callback DEPRECATED_MSG_ATTRIBUTE("Use fetch method instead."); 16 | 17 | @end 18 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXPolyfillSet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | 12 | @protocol WXPolyfillSetJSExports 13 | 14 | + (instancetype)create; 15 | 16 | - (BOOL)has:(id)value; 17 | 18 | - (NSUInteger)size; 19 | 20 | - (void)add:(id)value; 21 | 22 | - (BOOL)delete:(id)value; 23 | 24 | - (void)clear; 25 | 26 | @end 27 | 28 | @interface WXPolyfillSet : NSObject 29 | 30 | @end 31 | 32 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | HackerNews 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /ios/HackerNewsTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ios/HackerNewsUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Model/WXComponent+Navigation.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | #import "WXNavigationProtocol.h" 11 | 12 | @interface WXComponent (Navigation) 13 | 14 | - (void)setNavigationBarHidden:(BOOL)hidden; 15 | 16 | - (void)setNavigationBackgroundColor:(UIColor *)backgroundColor; 17 | 18 | - (void)setNavigationItemWithParam:(NSDictionary *)param position:(WXNavigationItemPosition)position; 19 | 20 | - (void)setNavigationWithStyles:(NSDictionary *)styles; 21 | 22 | @end 23 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Display/UIBezierPath+Weex.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface UIBezierPath (Weex) 12 | 13 | + (instancetype)wx_bezierPathWithRoundedRect:(CGRect)rect 14 | topLeft:(CGFloat)topLeftRadius 15 | topRight:(CGFloat)topRightRadius 16 | bottomLeft:(CGFloat)bottomLeftRadius 17 | bottomRight:(CGFloat)bottomRightRadius; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | org.gradle.jvmargs=-Xmx1536m 13 | 14 | # When configured, Gradle will run in incubating parallel mode. 15 | # This option should only be used with decoupled projects. More details, visit 16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 17 | # org.gradle.parallel=true 18 | -------------------------------------------------------------------------------- /src/entry.js: -------------------------------------------------------------------------------- 1 | // import Vue from 'vue' 2 | import App from './App.vue' 3 | import router from './router' 4 | import store from './store' 5 | import { sync } from 'vuex-router-sync' 6 | import * as filters from './filters' 7 | import mixins from './mixins' 8 | 9 | // sync the router with the vuex store. 10 | // this registers `store.state.route` 11 | sync(store, router) 12 | 13 | // register global utility filters. 14 | Object.keys(filters).forEach(key => { 15 | Vue.filter(key, filters[key]) 16 | }) 17 | 18 | // register global mixins. 19 | Vue.mixin(mixins) 20 | 21 | // create the app instance. 22 | // here we inject the router and store to all child components, 23 | // making them available everywhere as `this.$router` and `this.$store`. 24 | new Vue(Vue.util.extend({ el: '#root', router, store }, App)) 25 | 26 | router.push('/') 27 | -------------------------------------------------------------------------------- /src/views/ArticleView.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 24 | 25 | 37 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXListComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXScrollerComponent.h" 10 | 11 | @class WXCellComponent; 12 | @class WXHeaderComponent; 13 | @interface WXListComponent : WXScrollerComponent 14 | 15 | - (void)cellDidRemove:(WXCellComponent *)cell; 16 | 17 | - (void)cellDidLayout:(WXCellComponent *)cell; 18 | 19 | - (void)headerDidLayout:(WXHeaderComponent *)header; 20 | 21 | - (void)cellDidRendered:(WXCellComponent *)cell; 22 | 23 | - (void)cell:(WXCellComponent *)cell didMoveToIndex:(NSUInteger)index; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXAssert.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXAssert.h" 10 | #import "WXLog.h" 11 | 12 | void WXAssertIntenal(NSString *func, NSString *file, int lineNum, NSString *format, ...) 13 | { 14 | va_list args; 15 | va_start(args, format); 16 | NSString *message = [[NSString alloc] initWithFormat:format arguments:args]; 17 | va_end(args); 18 | 19 | WXLogError(@"%@", message); 20 | [[NSAssertionHandler currentHandler] handleFailureInFunction:func file:file lineNumber:lineNum description:format, message]; 21 | } 22 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/View/WXRootView.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXRootView.h" 10 | #import "WXSDKInstance.h" 11 | 12 | @implementation WXRootView 13 | 14 | - (void)setFrame:(CGRect)frame 15 | { 16 | BOOL shouldNotifyLayout = NO; 17 | if (_instance.onLayoutChange && !CGRectEqualToRect(self.frame, frame)) { 18 | shouldNotifyLayout = YES; 19 | } 20 | 21 | [super setFrame:frame]; 22 | 23 | if (shouldNotifyLayout && _instance.onLayoutChange) { 24 | _instance.onLayoutChange(self); 25 | } 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /android/WeexSDK/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/ouy/Library/AndroidStudio/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -keep class com.taobao.weex.bridge.** { *; } 19 | -dontwarn com.taobao.weex.bridge.** 20 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXRuleManager.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | #import "WXThreadSafeMutableDictionary.h" 12 | #import "WXSDKInstance.h" 13 | 14 | @interface WXRuleManager : NSObject 15 | 16 | @property(nonatomic, weak)WXSDKInstance *instance; 17 | 18 | + (WXRuleManager *)sharedInstance; 19 | 20 | - (void)addRule:(NSString *)type rule:(NSDictionary *)rule; 21 | 22 | - (WXThreadSafeMutableDictionary *)getRule:(NSString *)type; 23 | 24 | - (void)removeRule:(NSString *)type rule:(NSDictionary *)rule; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CSSLayoutContext.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | /** 9 | * A context for holding values local to a given instance of layout computation. 10 | * 11 | * This is necessary for making layout thread-safe. A separate instance should 12 | * be used when {@link CSSNode#calculateLayout} is called concurrently on 13 | * different node hierarchies. 14 | */ 15 | public class CSSLayoutContext { 16 | 17 | /*package*/ final MeasureOutput measureOutput = new MeasureOutput(); 18 | } 19 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/CSSJustifyConvert.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.dom; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.taobao.weex.dom.flex.CSSJustify; 6 | 7 | class CSSJustifyConvert { 8 | 9 | public static CSSJustify convert(String s) { 10 | CSSJustify cssJustify = CSSJustify.FLEX_START; 11 | if (TextUtils.isEmpty(s) || s.equals("flex-start")) { 12 | cssJustify = CSSJustify.FLEX_START; 13 | } else if (s.equals("flex-end")) { 14 | cssJustify = CSSJustify.FLEX_END; 15 | } else if (s.equals("center")) { 16 | cssJustify = CSSJustify.CENTER; 17 | } else if (s.equals("space-between")) { 18 | cssJustify = CSSJustify.SPACE_BETWEEN; 19 | } else if (s.equals("space-around")) { 20 | cssJustify = CSSJustify.SPACE_AROUND; 21 | } 22 | return cssJustify; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Debug/WXDebugTool.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @interface WXDebugTool : NSObject 13 | 14 | //+ (void)showFPS; 15 | 16 | + (void)setDebug:(BOOL)isDebug; 17 | 18 | + (BOOL)isDebug; 19 | 20 | + (void)setDevToolDebug:(BOOL)isDevToolDebug; 21 | 22 | + (BOOL)isDevToolDebug; 23 | 24 | + (void)setReplacedBundleJS:(NSURL*)url; 25 | 26 | + (NSString*)getReplacedBundleJS; 27 | 28 | + (void)setReplacedJSFramework:(NSURL*)url; 29 | 30 | + (NSString*)getReplacedJSFramework; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXScrollerComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXScrollerProtocol.h" 10 | #import "WXComponent.h" 11 | 12 | @interface WXScrollerComponent : WXComponent 13 | 14 | @property (nonatomic, copy) void (^onScroll)(UIScrollView *); 15 | 16 | @property (nonatomic, assign) NSUInteger loadmoreretry; 17 | 18 | @property (nonatomic, assign) CGSize contentSize; 19 | 20 | @property (nonatomic, readonly, assign) css_node_t *scrollerCSSNode; 21 | 22 | - (NSUInteger)childrenCountForScrollerLayout; 23 | 24 | - (void)handleAppear; 25 | 26 | @end 27 | 28 | -------------------------------------------------------------------------------- /src/store/fetch.js: -------------------------------------------------------------------------------- 1 | const stream = weex.requireModule('stream') 2 | const baseURL = 'https://hacker-news.firebaseio.com/v0' 3 | 4 | export function fetch (path) { 5 | return new Promise((resolve, reject) => { 6 | stream.fetch({ 7 | method: 'GET', 8 | url: `${baseURL}/${path}.json`, 9 | type: 'json' 10 | }, (response) => { 11 | if (response.status == 200) { 12 | resolve(response.data) 13 | } 14 | else { 15 | reject(response) 16 | } 17 | }, () => {}) 18 | }) 19 | } 20 | 21 | export function fetchIdsByType (type) { 22 | return fetch(`${type}stories`) 23 | } 24 | 25 | export function fetchItem (id) { 26 | return fetch(`item/${id}`) 27 | } 28 | 29 | export function fetchItems (ids) { 30 | return Promise.all(ids.map(id => fetchItem(id))) 31 | } 32 | 33 | export function fetchUser (id) { 34 | return fetch(`user/${id}`) 35 | } 36 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/CSSFlexDirectionConvert.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.dom; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.taobao.weex.dom.flex.CSSFlexDirection; 6 | 7 | class CSSFlexDirectionConvert { 8 | 9 | public static CSSFlexDirection convert(String s) { 10 | CSSFlexDirection cssFlexDirection = CSSFlexDirection.ROW; 11 | if (TextUtils.isEmpty(s)) { 12 | cssFlexDirection = CSSFlexDirection.ROW; 13 | } else if (s.equals("column")) { 14 | cssFlexDirection = CSSFlexDirection.COLUMN; 15 | } else if (s.equals("column-reverse")) { 16 | cssFlexDirection = CSSFlexDirection.COLUMN_REVERSE; 17 | } else if (s.equals("row")) { 18 | cssFlexDirection = CSSFlexDirection.ROW; 19 | } else if (s.equals("row-reverse")) { 20 | cssFlexDirection = CSSFlexDirection.ROW_REVERSE; 21 | } 22 | return cssFlexDirection; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXVideoComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | typedef NS_ENUM(NSInteger, WXPlaybackState) { 12 | WXPlaybackStatePlaying, 13 | WXPlaybackStatePaused, 14 | // WXPlaybackStateStopped, 15 | WXPlaybackStatePlayFinish, 16 | WXPlaybackStateFailed, 17 | }; 18 | 19 | @interface WXVideoView : UIView 20 | 21 | @property (nonatomic, copy) void (^playbackStateChanged)(WXPlaybackState state); 22 | 23 | - (void) setURL:(NSURL*)URL; 24 | 25 | - (void) play; 26 | - (void) pause; 27 | 28 | @end 29 | 30 | @interface WXVideoComponent : WXComponent 31 | 32 | @end 33 | 34 | 35 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXInvocationConfig.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | #import "WXBridgeMethod.h" 12 | 13 | @interface WXInvocationConfig : NSObject 14 | 15 | @property (nonatomic, strong) NSString *name; 16 | @property (nonatomic, strong) NSString *clazz; 17 | /** 18 | * The methods map 19 | **/ 20 | @property (nonatomic, strong) NSMutableDictionary *asyncMethods; 21 | @property (nonatomic, strong) NSMutableDictionary *syncMethods; 22 | 23 | + (instancetype)sharedInstance; 24 | - (instancetype)initWithName:(NSString *)name class:(NSString *)clazz; 25 | - (void)registerMethods; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/flex/CachedCSSLayout.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2014, Facebook, Inc. All rights reserved.

This source code is licensed under 3 | * the BSD-style license found in the LICENSE file in the root directory of this source tree. An 4 | * additional grant of patent rights can be found in the PATENTS file in the same directory. 5 | */ 6 | package com.taobao.weex.dom.flex; 7 | 8 | /** 9 | * CSSLayout with additional information about the conditions under which it was generated. 10 | * {@link #requestedWidth} and {@link #requestedHeight} are the width and height the parent set on 11 | * this node before calling layout visited us. 12 | */ 13 | public class CachedCSSLayout extends CSSLayout { 14 | 15 | public float requestedWidth = CSSConstants.UNDEFINED; 16 | public float requestedHeight = CSSConstants.UNDEFINED; 17 | public float parentMaxWidth = CSSConstants.UNDEFINED; 18 | } 19 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /android/app/src/androidTest/java/com/example/weex/hackernews/ExampleInstrumentedTest.java: -------------------------------------------------------------------------------- 1 | package com.example.weex.hackernews; 2 | 3 | import android.content.Context; 4 | import android.support.test.InstrumentationRegistry; 5 | import android.support.test.runner.AndroidJUnit4; 6 | 7 | import org.junit.Test; 8 | import org.junit.runner.RunWith; 9 | 10 | import static org.junit.Assert.*; 11 | 12 | /** 13 | * Instrumentation test, which will execute on an Android device. 14 | * 15 | * @see Testing documentation 16 | */ 17 | @RunWith(AndroidJUnit4.class) 18 | public class ExampleInstrumentedTest { 19 | @Test 20 | public void useAppContext() throws Exception { 21 | // Context of the app under test. 22 | Context appContext = InstrumentationRegistry.getTargetContext(); 23 | 24 | assertEquals("com.example.weex.hackernews", appContext.getPackageName()); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXStorageModule.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXModuleProtocol.h" 10 | 11 | @interface WXStorageModule : NSObject 12 | 13 | - (void)length:(WXModuleCallback)callback; 14 | 15 | - (void)getAllKeys:(WXModuleCallback)callback; 16 | 17 | - (void)setItem:(NSString *)key value:(NSString *)value callback:(WXModuleCallback)callback; 18 | 19 | - (void)setItemPersistent:(NSString *)key value:(NSString *)value callback:(WXModuleCallback)callback; 20 | 21 | - (void)getItem:(NSString *)key callback:(WXModuleCallback)callback; 22 | 23 | - (void)removeItem:(NSString *)key callback:(WXModuleCallback)callback; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Loader/WXWebSocketLoader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXWebSocketLoader : NSObject 12 | 13 | @property (nonatomic, copy) void (^onOpen)(); 14 | @property (nonatomic, copy) void (^onReceiveMessage)(id); 15 | @property (nonatomic, copy) void (^onClose)(NSInteger,NSString *,BOOL); 16 | @property (nonatomic, copy) void (^onFail)(NSError *); 17 | 18 | - (instancetype)initWithUrl:(NSString *)url protocol:(NSString *)protocol; 19 | - (void)open; 20 | - (void)send:(NSString *)data; 21 | - (void)close; 22 | - (void)close:(NSInteger)code reason:(NSString *)reason; 23 | - (void)clear; 24 | @end 25 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Model/WXBridgeMethod.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | @class WXSDKInstance; 11 | 12 | @interface WXBridgeMethod : NSObject 13 | 14 | @property (nonatomic, strong, readonly) NSString *methodName; 15 | @property (nonatomic, copy, readonly) NSArray *arguments; 16 | @property (nonatomic, weak, readonly) WXSDKInstance *instance; 17 | 18 | - (instancetype)initWithMethodName:(NSString *)methodName 19 | arguments:(NSArray *)arguments 20 | instance:(WXSDKInstance *)instance; 21 | 22 | - (NSInvocation *)invocationWithTarget:(id)target selector:(SEL)selector; 23 | 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/dependency/OCMock/OCMFunctions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | 20 | #if defined(__cplusplus) 21 | #define OCMOCK_EXTERN extern "C" 22 | #else 23 | #define OCMOCK_EXTERN extern 24 | #endif 25 | 26 | 27 | OCMOCK_EXTERN BOOL OCMIsObjectType(const char *objCType); 28 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXModuleMethod.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXBridgeMethod.h" 10 | 11 | typedef enum : NSUInteger { 12 | WXModuleMethodTypeSync, 13 | WXModuleMethodTypeAsync, 14 | } WXModuleMethodType; 15 | 16 | @interface WXModuleMethod : WXBridgeMethod 17 | 18 | @property (nonatomic, assign) WXModuleMethodType methodType; 19 | @property (nonatomic, strong, readonly) NSString *moduleName; 20 | 21 | - (instancetype)initWithModuleName:(NSString *)moduleName 22 | methodName:(NSString *)methodName 23 | arguments:(NSArray *)arguments 24 | instance:(WXSDKInstance *)instance; 25 | 26 | - (NSInvocation *)invoke; 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXHandlerFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXHandlerFactory : NSObject 12 | 13 | /** 14 | * @abstract Register a handler for a given handler instance and specific protocol 15 | * 16 | * @param handler The handler instance to register 17 | * 18 | * @param protocol The protocol to confirm 19 | * 20 | */ 21 | + (void)registerHandler:(id)handler withProtocol:(Protocol *)protocol; 22 | 23 | /** 24 | * @abstract Returns the handler for a given protocol 25 | * 26 | **/ 27 | + (id)handlerForProtocol:(Protocol *)protocol; 28 | 29 | /** 30 | * @abstract Returns the registered handlers. 31 | */ 32 | + (NSDictionary *)handlerConfigs; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/WeexSDKTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WeexSDKTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation WeexSDKTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /ios/HackerNews/WXEventModule.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXEventModule.m 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import "WXEventModule.h" 10 | #import "ViewController.h" 11 | 12 | #import 13 | 14 | @implementation WXEventModule 15 | 16 | @synthesize weexInstance; 17 | 18 | WX_EXPORT_METHOD(@selector(openURL:)) 19 | 20 | - (void)openURL:(NSString *)url 21 | { 22 | NSString *newURL = url; 23 | if ([url hasPrefix:@"//"]) { 24 | newURL = [NSString stringWithFormat:@"http:%@", url]; 25 | } else if (![url hasPrefix:@"http"]) { 26 | // relative path 27 | newURL = [NSURL URLWithString:url relativeToURL:weexInstance.scriptURL].absoluteString; 28 | } 29 | 30 | UIViewController *controller = [[ViewController alloc] init]; 31 | ((ViewController *)controller).url = [NSURL URLWithString:newURL]; 32 | 33 | [[weexInstance.viewController navigationController] pushViewController:controller animated:YES]; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/dependency/OCMock/NSNotificationCenter+OCMAdditions.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @class OCObserverMockObject; 20 | 21 | 22 | @interface NSNotificationCenter(OCMAdditions) 23 | 24 | - (void)addMockObserver:(OCObserverMockObject *)notificationObserver name:(NSString *)notificationName object:(id)notificationSender; 25 | 26 | @end 27 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXTransform.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | @class WXSDKInstance; 12 | 13 | @interface WXTransform : NSObject 14 | 15 | @property CGAffineTransform transform; 16 | 17 | - (instancetype)initWithInstance:(WXSDKInstance *)instance NS_DESIGNATED_INITIALIZER; 18 | 19 | - (CATransform3D)getTransform:(NSString *)cssValue; 20 | - (CATransform3D)getTransform:(NSString *)cssValue withView:(UIView *)view; 21 | - (CATransform3D)getTransform:(NSString *)cssValue withView:(UIView *)view withOrigin:(NSString *)origin; 22 | - (CATransform3D)getTransform:(NSString *)cssValue withView:(UIView *)view withOrigin:(NSString *)origin isTransformRotate:(BOOL)isTransformRotate; 23 | - (float)getRotateAngle; 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /android/WeexSDK/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | org.gradle.daemon=false 22 | org.gradle.parallel=false 23 | org.gradle.jvmargs=-Xmx2048M 24 | -------------------------------------------------------------------------------- /ios/HackerNewsTests/HackerNewsTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HackerNewsTests.m 3 | // HackerNewsTests 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HackerNewsTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation HackerNewsTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Display/WXRoundedRect.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | 10 | #import 11 | 12 | 13 | @interface WXRadii : NSObject 14 | 15 | @property (nonatomic, assign) CGFloat topLeft; 16 | @property (nonatomic, assign) CGFloat topRight; 17 | @property (nonatomic, assign) CGFloat bottomLeft; 18 | @property (nonatomic, assign) CGFloat bottomRight; 19 | 20 | @end 21 | 22 | @interface WXRoundedRect : NSObject 23 | 24 | @property (nonatomic, assign) CGRect rect; 25 | @property (nonatomic, strong) WXRadii *radii; 26 | 27 | - (instancetype)initWithRect:(CGRect)rect 28 | topLeft:(CGFloat)topLeft 29 | topRight:(CGFloat)topRight 30 | bottomLeft:(CGFloat)bottomLeft 31 | bottomRight:(CGFloat)bottomRight; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXCallJSMethod.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXCallJSMethod.h" 10 | 11 | @implementation WXCallJSMethod 12 | { 13 | NSString *_moduleName; 14 | } 15 | 16 | - (instancetype)initWithModuleName:(NSString *)moduleName 17 | methodName:(NSString *)methodName 18 | arguments:(NSArray *)arguments 19 | instance:(WXSDKInstance *)instance 20 | { 21 | if (self = [super initWithMethodName:methodName arguments:arguments instance:instance]) { 22 | _moduleName = moduleName; 23 | } 24 | 25 | return self; 26 | } 27 | 28 | - (NSDictionary *)callJSTask 29 | { 30 | return @{@"module":_moduleName ?: @"", 31 | @"method":self.methodName ?: @"", 32 | @"args":self.arguments ?: @[]}; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXServiceFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXServiceFactory : NSObject 12 | 13 | /** 14 | * @abstract Registers a service for a given name, js code and options 15 | * 16 | * @param name The service name to register 17 | * 18 | * @param options The service options to register 19 | * 20 | * @param code service js code to invoke 21 | * 22 | * @return script 23 | * 24 | */ 25 | + (NSString *)registerServiceScript:(NSString *)name withRawScript:(NSString *)serviceScript withOptions:(NSDictionary *)options; 26 | 27 | 28 | /** 29 | * @abstract Unregisters a component for a given name 30 | * 31 | * @param name The service name to register 32 | * 33 | * @return script 34 | * 35 | */ 36 | + (NSString *)unregisterServiceScript:(NSString *)name; 37 | 38 | @end 39 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/NSTimer+Weex.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "NSTimer+Weex.h" 10 | 11 | @implementation NSTimer (Weex) 12 | 13 | + (NSTimer *)wx_scheduledTimerWithTimeInterval:(NSTimeInterval)interval 14 | block:(void(^)())block 15 | repeats:(BOOL)repeats 16 | { 17 | return [self scheduledTimerWithTimeInterval:interval 18 | target:self 19 | selector:@selector(blockInvoke:) 20 | userInfo:[block copy] 21 | repeats:repeats]; 22 | } 23 | 24 | + (void)blockInvoke:(NSTimer*)timer 25 | { 26 | void (^block)() = timer.userInfo; 27 | if (block) { 28 | block(); 29 | } 30 | } 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/WebSocket/WXWebSocketHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | @protocol WXWebSocketDelegate 13 | - (void)didOpen; 14 | - (void)didFailWithError:(NSError *)error; 15 | - (void)didReceiveMessage:(id)message; 16 | - (void)didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean; 17 | @end 18 | 19 | @protocol WXWebSocketHandler 20 | 21 | - (void)open:(NSString *)url protocol:(NSString *)protocol identifier:(NSString *)identifier withDelegate:(id)delegate; 22 | - (void)send:(NSString *)identifier data:(NSString *)data; 23 | - (void)close:(NSString *)identifier; 24 | - (void)close:(NSString *)identifier code:(NSInteger)code reason:(NSString *)reason; 25 | - (void)clear:(NSString *)identifier; 26 | @end 27 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXPolyfillSet.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXPolyfillSet.h" 10 | 11 | @implementation WXPolyfillSet 12 | { 13 | NSMutableSet *_set; 14 | } 15 | 16 | + (instancetype)create 17 | { 18 | WXPolyfillSet *jsSet = [WXPolyfillSet new]; 19 | jsSet->_set = [NSMutableSet set]; 20 | return jsSet; 21 | } 22 | 23 | - (BOOL)has:(id)value 24 | { 25 | return [_set containsObject:value]; 26 | } 27 | 28 | - (NSUInteger)size 29 | { 30 | return _set.count; 31 | } 32 | 33 | - (void)add:(id)value 34 | { 35 | [_set addObject:value]; 36 | } 37 | 38 | - (BOOL)delete:(id)value 39 | { 40 | if ([_set containsObject:value]) { 41 | [_set removeObject:value]; 42 | return YES; 43 | } 44 | 45 | return NO; 46 | } 47 | 48 | - (void)clear 49 | { 50 | [_set removeAllObjects]; 51 | } 52 | 53 | @end 54 | 55 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/WebSocket/SRWebSocket+Weex.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "SRWebSocket+Weex.h" 10 | static char wx_IdentifierKey; 11 | static char wx_WebSocketDelegateKey; 12 | 13 | 14 | @implementation SRWebSocket (Weex) 15 | 16 | -(void)setWx_Identifier:(NSString *)wx_Identifier 17 | { 18 | objc_setAssociatedObject(self, &wx_IdentifierKey, wx_Identifier, OBJC_ASSOCIATION_COPY); 19 | } 20 | 21 | -(NSString *)wx_Identifier 22 | { 23 | return objc_getAssociatedObject(self, &wx_IdentifierKey); 24 | } 25 | 26 | -(void)setWx_WebSocketDelegate:(id)wx_WebSocketDelegate 27 | { 28 | objc_setAssociatedObject(self, &wx_WebSocketDelegateKey, wx_WebSocketDelegate, OBJC_ASSOCIATION_COPY); 29 | } 30 | 31 | -(NSString *)wx_WebSocketDelegate 32 | { 33 | return objc_getAssociatedObject(self, &wx_WebSocketDelegateKey); 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Loader/WXResourceLoader.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXResourceRequest.h" 11 | #import "WXResourceResponse.h" 12 | 13 | 14 | @interface WXResourceLoader : NSObject 15 | 16 | @property (nonatomic, strong) WXResourceRequest *request; 17 | 18 | @property (nonatomic, copy) void (^onDataSent)(unsigned long long /* bytesSent */, unsigned long long /* totalBytesToBeSent */); 19 | @property (nonatomic, copy) void (^onResponseReceived)(const WXResourceResponse *); 20 | @property (nonatomic, copy) void (^onDataReceived)(NSData *); 21 | @property (nonatomic, copy) void (^onFinished)(const WXResourceResponse *, NSData *); 22 | @property (nonatomic, copy) void (^onFailed)(NSError *); 23 | 24 | - (instancetype)initWithRequest:(WXResourceRequest *)request; 25 | 26 | - (void)start; 27 | 28 | - (void)cancel:(NSError **)error; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /src/router.js: -------------------------------------------------------------------------------- 1 | // import Vue from 'vue' 2 | import Router from 'vue-router' 3 | import StoriesView from './views/StoriesView.vue' 4 | import ArticleView from './views/ArticleView.vue' 5 | import CommentView from './views/CommentView.vue' 6 | import UserView from './views/UserView.vue' 7 | 8 | Vue.use(Router) 9 | 10 | // Story view factory 11 | function createStoriesView (type) { 12 | return { 13 | name: `${type}-stories-view`, 14 | render (createElement) { 15 | return createElement(StoriesView, { props: { type }}) 16 | } 17 | } 18 | } 19 | 20 | export default new Router({ 21 | // mode: 'abstract', 22 | routes: [ 23 | { path: '/top', component: createStoriesView('top') }, 24 | { path: '/new', component: createStoriesView('new') }, 25 | { path: '/show', component: createStoriesView('show') }, 26 | { path: '/ask', component: createStoriesView('ask') }, 27 | { path: '/job', component: createStoriesView('job') }, 28 | { path: '/article/:url(.*)?', component: ArticleView }, 29 | { path: '/item/:id(\\d+)', component: CommentView }, 30 | { path: '/user/:id', component: UserView }, 31 | { path: '/', redirect: '/top' } 32 | ] 33 | }) 34 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Network/WXResourceRequest.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | typedef enum : NSUInteger { 12 | WXResourceTypeMainBundle, 13 | WXResourceTypeServiceBundle, 14 | WXResourceTypeImage, 15 | WXResourceTypeFont, 16 | WXResourceTypeVideo, 17 | WXResourceTypeLink, 18 | WXResourceTypeOthers 19 | } WXResourceType; 20 | 21 | 22 | @interface WXResourceRequest : NSMutableURLRequest 23 | 24 | @property (nonatomic, strong) id taskIdentifier; 25 | @property (nonatomic, assign) WXResourceType type; 26 | 27 | @property (nonatomic, strong) NSString *referrer; 28 | @property (nonatomic, strong) NSString *userAgent; 29 | 30 | + (instancetype)requestWithURL:(NSURL *)url 31 | resourceType:(WXResourceType)type 32 | referrer:(NSString *)referrer 33 | cachePolicy:(NSURLRequestCachePolicy)cachePolicy; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/View/WXErrorView.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXErrorView.h" 10 | 11 | @implementation WXErrorView 12 | 13 | - (id) initWithFrame:(CGRect)frame 14 | { 15 | self = [super initWithFrame:frame]; 16 | 17 | if (self) { 18 | UIImageView *imageView = [[UIImageView alloc]initWithFrame:self.bounds]; 19 | NSBundle *bundle = [NSBundle bundleForClass:self.class]; 20 | NSString *file = [bundle pathForResource:@"wx_load_error@3x" ofType:@"png"]; 21 | imageView.image = [UIImage imageWithContentsOfFile:file]; 22 | [self addSubview:imageView]; 23 | 24 | UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGesture:)]; 25 | [self addGestureRecognizer:tapRecognizer]; 26 | } 27 | return self; 28 | } 29 | 30 | - (void)tapGesture:(UITapGestureRecognizer *)sender 31 | { 32 | [self.delegate onclickErrorView]; 33 | } 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Controller/WXBaseViewController.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | /** 12 | * The WXBaseViewController class provides the infrastructure for managing the weex view in your app. It is 13 | * responsible for creating a weex instance or rendering the weex view, for observing the lifecycle of the 14 | * view such as "appear" or "disapper"、"foreground" or "background" etc. You can initialize this controller by 15 | * special bundle URL. 16 | */ 17 | 18 | @interface WXBaseViewController : UIViewController 19 | 20 | /** 21 | * @abstract initializes the viewcontroller with bundle url. 22 | * 23 | * @param soureURL. The url of bundle rendered to a weex view. 24 | * 25 | * @return a object the class of WXBaseViewController. 26 | * 27 | */ 28 | - (instancetype)initWithSourceURL:(NSURL *)sourceURL; 29 | 30 | /** 31 | * @abstract refreshes the weex view in controller. 32 | */ 33 | - (void)refreshWeex; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXSDKManager.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXSDKInstance.h" 11 | #import "WXBridgeManager.h" 12 | 13 | @class WXModuleManager; 14 | 15 | @interface WXSDKManager : NSObject 16 | 17 | /** 18 | * @abstract Returns bridge manager 19 | **/ 20 | + (WXBridgeManager *)bridgeMgr; 21 | 22 | /** 23 | * @abstract Returns weex instance for specific identifier 24 | **/ 25 | + (WXSDKInstance *)instanceForID:(NSString *)identifier; 26 | 27 | /** 28 | * @abstract Returns weex instance for specific identifier 29 | **/ 30 | + (void)storeInstance:(WXSDKInstance *)instance forID:(NSString *)identifier; 31 | 32 | /** 33 | * @abstract Returns weex instance for specific identifier 34 | **/ 35 | + (void)removeInstanceforID:(NSString *)identifier; 36 | 37 | /** 38 | * @abstract unload 39 | **/ 40 | + (void)unload; 41 | 42 | /** 43 | * @abstract Returns module manager 44 | **/ 45 | + (WXModuleManager *)moduleMgr DEPRECATED_MSG_ATTRIBUTE(); 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/dependency/OCMock/OCMRecorder.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @class OCMockObject; 20 | @class OCMInvocationMatcher; 21 | 22 | 23 | @interface OCMRecorder : NSProxy 24 | { 25 | OCMockObject *mockObject; 26 | OCMInvocationMatcher *invocationMatcher; 27 | } 28 | 29 | - (instancetype)init; 30 | - (instancetype)initWithMockObject:(OCMockObject *)aMockObject; 31 | 32 | - (void)setMockObject:(OCMockObject *)aMockObject; 33 | 34 | - (OCMInvocationMatcher *)invocationMatcher; 35 | 36 | - (id)classMethod; 37 | - (id)ignoringNonObjectArgs; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /src/store/index.js: -------------------------------------------------------------------------------- 1 | // import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import * as actions from './actions' 4 | import * as mutations from './mutations' 5 | 6 | // Vuex is auto installed on the web 7 | if (WXEnvironment.platform !== 'Web') { 8 | Vue.use(Vuex) 9 | } 10 | 11 | const store = new Vuex.Store({ 12 | actions, 13 | mutations, 14 | 15 | state: { 16 | activeType: null, 17 | items: {}, 18 | users: {}, 19 | counts: { 20 | top: 20, 21 | new: 20, 22 | show: 15, 23 | ask: 15, 24 | job: 15 25 | }, 26 | lists: { 27 | top: [], 28 | new: [], 29 | show: [], 30 | ask: [], 31 | job: [] 32 | } 33 | }, 34 | 35 | getters: { 36 | // ids of the items that should be currently displayed based on 37 | // current list type and current pagination 38 | activeIds (state) { 39 | const { activeType, lists, counts } = state 40 | return activeType ? lists[activeType].slice(0, counts[activeType]) : [] 41 | }, 42 | 43 | // items that should be currently displayed. 44 | // this Array may not be fully fetched. 45 | activeItems (state, getters) { 46 | return getters.activeIds.map(id => state.items[id]).filter(_ => _) 47 | } 48 | } 49 | }) 50 | 51 | export default store 52 | -------------------------------------------------------------------------------- /ios/HackerNews/Assets.xcassets/LaunchImage-2.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "minimum-system-version" : "7.0", 7 | "extent" : "full-screen", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "minimum-system-version" : "7.0", 14 | "extent" : "full-screen", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "landscape", 19 | "idiom" : "ipad", 20 | "minimum-system-version" : "7.0", 21 | "extent" : "full-screen", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "portrait", 26 | "idiom" : "iphone", 27 | "minimum-system-version" : "7.0", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "minimum-system-version" : "7.0", 34 | "subtype" : "retina4", 35 | "scale" : "2x" 36 | }, 37 | { 38 | "orientation" : "portrait", 39 | "idiom" : "ipad", 40 | "minimum-system-version" : "7.0", 41 | "extent" : "full-screen", 42 | "scale" : "1x" 43 | } 44 | ], 45 | "info" : { 46 | "version" : 1, 47 | "author" : "xcode" 48 | } 49 | } -------------------------------------------------------------------------------- /ios/HackerNews/Assets.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "ipad", 6 | "minimum-system-version" : "7.0", 7 | "extent" : "full-screen", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "landscape", 12 | "idiom" : "ipad", 13 | "minimum-system-version" : "7.0", 14 | "extent" : "full-screen", 15 | "scale" : "1x" 16 | }, 17 | { 18 | "orientation" : "landscape", 19 | "idiom" : "ipad", 20 | "minimum-system-version" : "7.0", 21 | "extent" : "full-screen", 22 | "scale" : "2x" 23 | }, 24 | { 25 | "orientation" : "portrait", 26 | "idiom" : "iphone", 27 | "minimum-system-version" : "7.0", 28 | "scale" : "2x" 29 | }, 30 | { 31 | "orientation" : "portrait", 32 | "idiom" : "iphone", 33 | "minimum-system-version" : "7.0", 34 | "subtype" : "retina4", 35 | "scale" : "2x" 36 | }, 37 | { 38 | "orientation" : "portrait", 39 | "idiom" : "ipad", 40 | "minimum-system-version" : "7.0", 41 | "extent" : "full-screen", 42 | "scale" : "1x" 43 | } 44 | ], 45 | "info" : { 46 | "version" : 1, 47 | "author" : "xcode" 48 | } 49 | } -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/CSSAlignConvert.java: -------------------------------------------------------------------------------- 1 | package com.taobao.weex.dom; 2 | 3 | import android.text.TextUtils; 4 | 5 | import com.taobao.weex.dom.flex.CSSAlign; 6 | 7 | final class CSSAlignConvert { 8 | 9 | public static CSSAlign convert2AlignItems(String s) { 10 | CSSAlign align = CSSAlign.STRETCH; 11 | if (TextUtils.isEmpty(s)) { 12 | align = CSSAlign.STRETCH; 13 | } else if (s.equals("stretch")) { 14 | align = CSSAlign.STRETCH; 15 | } else if (s.equals("flex-end")) { 16 | align = CSSAlign.FLEX_END; 17 | } else if (s.equals("auto")) { 18 | align = CSSAlign.AUTO; 19 | } else if (s.equals("center")) { 20 | align = CSSAlign.CENTER; 21 | } 22 | 23 | return align; 24 | } 25 | 26 | public static CSSAlign convert2AlignSelf(String s) { 27 | CSSAlign align = CSSAlign.AUTO; 28 | if (TextUtils.isEmpty(s)) { 29 | align = CSSAlign.AUTO; 30 | } else if (s.equals("flex-start")) { 31 | align = CSSAlign.FLEX_START; 32 | } else if (s.equals("flex-end")) { 33 | align = CSSAlign.FLEX_END; 34 | } else if (s.equals("stretch")) { 35 | align = CSSAlign.STRETCH; 36 | } else if (s.equals("center")) { 37 | align = CSSAlign.CENTER; 38 | } 39 | 40 | return align; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/dependency/OCMock/OCMLocation.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | #import "OCMFunctions.h" 19 | 20 | 21 | @interface OCMLocation : NSObject 22 | { 23 | id testCase; 24 | NSString *file; 25 | NSUInteger line; 26 | } 27 | 28 | + (instancetype)locationWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; 29 | 30 | - (instancetype)initWithTestCase:(id)aTestCase file:(NSString *)aFile line:(NSUInteger)aLine; 31 | 32 | - (id)testCase; 33 | - (NSString *)file; 34 | - (NSUInteger)line; 35 | 36 | @end 37 | 38 | OCMOCK_EXTERN OCMLocation *OCMMakeLocation(id testCase, const char *file, int line); 39 | -------------------------------------------------------------------------------- /src/store/actions.js: -------------------------------------------------------------------------------- 1 | import { fetchItems, fetchIdsByType, fetchUser } from './fetch' 2 | 3 | const LOAD_MORE_STEP = 10 4 | 5 | // ensure data for rendering given list type 6 | export function FETCH_LIST_DATA ({ commit, dispatch, state }, { type }) { 7 | commit('SET_ACTIVE_TYPE', { type }) 8 | return fetchIdsByType(type) 9 | .then(ids => commit('SET_LIST', { type, ids })) 10 | .then(() => dispatch('ENSURE_ACTIVE_ITEMS')) 11 | } 12 | 13 | // load more items 14 | export function LOAD_MORE_ITEMS ({ dispatch, state }) { 15 | state.counts[state.activeType] += LOAD_MORE_STEP 16 | return dispatch('ENSURE_ACTIVE_ITEMS') 17 | } 18 | 19 | // ensure all active items are fetched 20 | export function ENSURE_ACTIVE_ITEMS ({ dispatch, getters }) { 21 | return dispatch('FETCH_ITEMS', { 22 | ids: getters.activeIds 23 | }) 24 | } 25 | 26 | export function FETCH_ITEMS ({ commit, state }, { ids }) { 27 | // only fetch items that we don't already have. 28 | const newIds = ids.filter(id => !state.items[id]) 29 | return newIds.length 30 | ? fetchItems(newIds).then(items => commit('SET_ITEMS', { items })) 31 | : Promise.resolve() 32 | } 33 | 34 | export function FETCH_USER ({ commit, state }, { id }) { 35 | return state.users[id] 36 | ? Promise.resolve(state.users[id]) 37 | : fetchUser(id).then(user => commit('SET_USER', { user })) 38 | } 39 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXClipboardModule.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXClipboardModule.h" 10 | 11 | @implementation WXClipboardModule 12 | 13 | WX_EXPORT_METHOD(@selector(setString:)) 14 | WX_EXPORT_METHOD(@selector(getString:)) 15 | 16 | - (dispatch_queue_t)targetExecuteQueue { 17 | return dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); 18 | } 19 | 20 | - (void)setString:(NSString *)content 21 | { 22 | UIPasteboard *clipboard = [UIPasteboard generalPasteboard]; 23 | clipboard.string = (content ? : @""); 24 | } 25 | 26 | - (void)getString:(WXModuleCallback)callback{ 27 | UIPasteboard *clipboard = [UIPasteboard generalPasteboard]; 28 | NSDictionary *result = [@{} mutableCopy]; 29 | if(clipboard.string) 30 | { 31 | [result setValue:clipboard.string forKey:@"data"]; 32 | [result setValue:@"success" forKey:@"result"]; 33 | }else 34 | { 35 | [result setValue:@"" forKey:@"data"]; 36 | [result setValue:@"fail" forKey:@"result"]; 37 | } 38 | callback(result); 39 | 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/WeexSDK.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #ifdef __OBJC__ 10 | 11 | #import "WXUtility.h" 12 | #import "WXURLRewriteProtocol.h" 13 | #import "WXType.h" 14 | #import "WXScrollerProtocol.h" 15 | #import "WXScrollerComponent.h" 16 | #import "WXSDKManager.h" 17 | #import "WXSDKInstance.h" 18 | #import "WXSDKError.h" 19 | #import "WXSDKEngine.h" 20 | #import "WXRootViewController.h" 21 | #import "WXResourceRequest.h" 22 | #import "WXNetworkProtocol.h" 23 | #import "WXNavigationProtocol.h" 24 | #import "WXMonitor.h" 25 | #import "WXModuleProtocol.h" 26 | #import "WXLog.h" 27 | #import "WXListComponent.h" 28 | #import "WXLayoutDefine.h" 29 | #import "WXImgLoaderProtocol.h" 30 | #import "WXEventModuleProtocol.h" 31 | #import "WXDefine.h" 32 | #import "WXDebugTool.h" 33 | #import "WXConvert.h" 34 | #import "WXComponentManager.h" 35 | #import "WXComponent.h" 36 | #import "WXBridgeProtocol.h" 37 | #import "WXBridgeManager.h" 38 | #import "WXBaseViewController.h" 39 | #import "WXAppMonitorProtocol.h" 40 | #import "WXAppConfiguration.h" 41 | #import "Layout.h" 42 | 43 | #endif /* __OBJC__ */ 44 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "weex-hackernews", 3 | "version": "1.0.0", 4 | "description": "Weex HackerNews App, powered by Vue.js.", 5 | "main": "index.js", 6 | "keywords": [ 7 | "weex", 8 | "vue", 9 | "hackernews", 10 | "javascript", 11 | "android", 12 | "ios" 13 | ], 14 | "scripts": { 15 | "build": "webpack", 16 | "dev": "webpack --watch", 17 | "copy:android": "cp dist/index.weex.js android/app/src/main/assets/index.js", 18 | "copy:ios": "cp dist/index.weex.js ios/assets/index.js", 19 | "copy": "npm run copy:android && npm run copy:ios", 20 | "serve": "serve -p 1337", 21 | "test": "echo \"Error: no test specified\" && exit 1" 22 | }, 23 | "engines": { 24 | "node": ">=4.0" 25 | }, 26 | "author": "Hanks ", 27 | "license": "Apache-2.0", 28 | "dependencies": { 29 | "vue": "^2.1.10", 30 | "vue-router": "^2.1.1", 31 | "vuex": "^2.1.1", 32 | "vuex-router-sync": "^4.0.1", 33 | "weex-vue-render": "^0.12.3" 34 | }, 35 | "devDependencies": { 36 | "babel-core": "^6.20.0", 37 | "babel-loader": "^6.2.9", 38 | "babel-preset-es2015": "^6.18.0", 39 | "css-loader": "^0.26.1", 40 | "serve": "^1.4.0", 41 | "vue-loader": "^10.0.2", 42 | "vue-template-compiler": "^2.1.10", 43 | "webpack": "^2.2.1", 44 | "weex-loader": "^0.4.4" 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Model/WXSDKInstance_private.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXSDKInstance.h" 11 | #import "WXComponentManager.h" 12 | #import "WXModuleMethod.h" 13 | 14 | @interface WXSDKInstance () 15 | 16 | @property (nonatomic, assign) CGFloat viewportWidth; 17 | 18 | @property (nonatomic, strong) NSMutableDictionary *moduleInstances; 19 | @property (nonatomic, strong) NSMutableDictionary *naviBarStyles; 20 | @property (nonatomic, strong) NSMutableDictionary *styleConfigs; 21 | @property (nonatomic, strong) NSMutableDictionary *attrConfigs; 22 | 23 | @property (nonatomic, readonly, strong) WXComponentManager *componentManager; 24 | 25 | - (void)addModuleEventObservers:(NSString*)event callback:(NSString*)callbackId option:(NSDictionary*)option moduleClassName:(NSString*)moduleClassName; 26 | - (void)_addModuleEventObserversWithModuleMethod:(WXModuleMethod*)method; 27 | - (void)removeModuleEventObserver:(NSString*)event moduleClassName:(NSString*)moduleClassName; 28 | - (void)_removeModuleEventObserverWithModuleMethod:(WXModuleMethod*)method; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /ios/HackerNewsUITests/HackerNewsUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // HackerNewsUITests.m 3 | // HackerNewsUITests 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface HackerNewsUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation HackerNewsUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/NSObject+WXSwizzle.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "NSObject+WXSwizzle.h" 10 | #import 11 | 12 | @implementation NSObject (WXSwizzle) 13 | 14 | + (BOOL)weex_swizzle:(Class)originalClass Method:(SEL)originalSelector withMethod:(SEL)swizzledSelector 15 | { 16 | if (!(originalClass && originalSelector && swizzledSelector)) { 17 | return NO; 18 | } 19 | 20 | Class class = [self class]; 21 | 22 | Method originalMethod = class_getInstanceMethod(originalClass, originalSelector); 23 | Method swizzledMethod = class_getInstanceMethod(class, swizzledSelector); 24 | 25 | BOOL didAddMethod = class_addMethod(originalClass, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); 26 | 27 | if (didAddMethod) { 28 | class_replaceMethod(class, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod)); 29 | } else { 30 | method_exchangeImplementations(originalMethod, swizzledMethod); 31 | } 32 | 33 | return YES; 34 | } 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXImgLoaderProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXModuleProtocol.h" 10 | #import "WXType.h" 11 | 12 | @protocol WXImageOperationProtocol 13 | 14 | - (void)cancel; 15 | 16 | @end 17 | 18 | @protocol WXImgLoaderProtocol 19 | 20 | /** 21 | * @abstract Creates a image download handler with a given URL 22 | * 23 | * @param imageUrl The URL of the image to download 24 | * 25 | * @param imageFrame The frame of the image you want to set 26 | * 27 | * @param options : The options to be used for this download 28 | * 29 | * @param completedBlock : A block called once the download is completed. 30 | * image : the image which has been download to local. 31 | * error : the error which has happened in download. 32 | * finished : a Boolean value indicating whether download action has finished. 33 | */ 34 | - (id)downloadImageWithURL:(NSString *)url imageFrame:(CGRect)imageFrame userInfo:(NSDictionary *)options completed:(void(^)(UIImage *image, NSError *error, BOOL finished))completedBlock; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXURLRewriteProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXResourceRequest.h" 11 | 12 | @class WXSDKInstance; 13 | 14 | #define WX_REWRITE_URL(url, resourceType, instance, newUrl)\ 15 | do {\ 16 | (*newUrl) = nil;\ 17 | id rewriteHandler = [WXHandlerFactory handlerForProtocol:@protocol(WXURLRewriteProtocol)];\ 18 | if ([rewriteHandler respondsToSelector:@selector(rewriteURL:withResourceType:withInstance:)]) {\ 19 | (*newUrl) = [[rewriteHandler rewriteURL:url withResourceType:WXResourceTypeLink withInstance:instance].absoluteString mutableCopy];\ 20 | }\ 21 | } while(0); 22 | 23 | 24 | @protocol WXURLRewriteProtocol 25 | 26 | /** 27 | * @abstract rewrite and complete URL 28 | * 29 | * @param url The original URL to be rewritten 30 | * 31 | * @param resourceType resource type which the url is sent for 32 | * 33 | * @param instance related instance 34 | * 35 | * @return a new url 36 | */ 37 | - (NSURL *)rewriteURL:(NSString *)url withResourceType:(WXResourceType)resourceType withInstance:(WXSDKInstance *)instance; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/dependency/OCMock/OCMMacroState.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2014-2016 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @class OCMLocation; 20 | @class OCMRecorder; 21 | @class OCMStubRecorder; 22 | @class OCMockObject; 23 | 24 | 25 | @interface OCMMacroState : NSObject 26 | { 27 | OCMRecorder *recorder; 28 | } 29 | 30 | + (void)beginStubMacro; 31 | + (OCMStubRecorder *)endStubMacro; 32 | 33 | + (void)beginExpectMacro; 34 | + (OCMStubRecorder *)endExpectMacro; 35 | 36 | + (void)beginRejectMacro; 37 | + (OCMStubRecorder *)endRejectMacro; 38 | 39 | + (void)beginVerifyMacroAtLocation:(OCMLocation *)aLocation; 40 | + (void)endVerifyMacro; 41 | 42 | + (OCMMacroState *)globalState; 43 | 44 | - (OCMRecorder *)recorder; 45 | 46 | - (void)switchToClassMethod; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXAppMonitorProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXModuleProtocol.h" 10 | 11 | #define BIZTYPE @"bizType" 12 | #define PAGENAME @"pageName" 13 | #define WXSDKVERSION @"WXSDKVersion" 14 | #define JSLIBVERSION @"JSLibVersion" 15 | #define WXREQUESTTYPE @"requestType" 16 | #define WXCONNECTIONTYPE @"connectionType" 17 | #define WXCUSTOMMONITORINFO @"customMonitorInfo" 18 | 19 | #define SDKINITTIME @"SDKInitTime" 20 | #define SDKINITINVOKETIME @"SDKInitInvokeTime" 21 | #define JSLIBINITTIME @"JSLibInitTime" 22 | #define JSTEMPLATESIZE @"JSTemplateSize" 23 | #define NETWORKTIME @"networkTime" 24 | #define COMMUNICATETIME @"communicateTime" 25 | #define SCREENRENDERTIME @"screenRenderTime" 26 | #define TOTALTIME @"totalTime" 27 | 28 | 29 | @protocol WXAppMonitorProtocol 30 | 31 | - (void)commitAppMonitorArgs:(NSDictionary *)args; 32 | 33 | - (void)commitAppMonitorAlarm:(NSString *)pageName monitorPoint:(NSString *)monitorPoint success:(BOOL)success errorCode:(NSString *)errorCode errorMsg:(NSString *)errorMsg arg:(NSString *)arg; 34 | 35 | @end 36 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/NSArray+Weex.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "NSArray+Weex.h" 10 | 11 | @implementation NSArray (Weex) 12 | 13 | - (id)wx_safeObjectAtIndex:(NSUInteger)index 14 | { 15 | if (index >= self.count) { 16 | return nil; 17 | } 18 | 19 | return [self objectAtIndex:index]; 20 | } 21 | 22 | @end 23 | 24 | @implementation NSMutableArray (Weex) 25 | 26 | // It's quite ingenius, using a Category to allow the creation of a mutable array that does no retain/release by backing it with a CFArray with proper callbacks.http://stackoverflow.com/questions/4692161/non-retaining-array-for-delegates 27 | + (id)wx_mutableArrayUsingWeakReferences { 28 | return [self wx_mutableArrayUsingWeakReferencesWithCapacity:0]; 29 | } 30 | 31 | + (id)wx_mutableArrayUsingWeakReferencesWithCapacity:(NSUInteger)capacity { 32 | CFArrayCallBacks callbacks = {0, NULL, NULL, CFCopyDescription, CFEqual}; 33 | // We create a weak reference array 34 | return (__bridge id)(CFArrayCreateMutable(0, capacity, &callbacks)); 35 | } 36 | 37 | + (void)wx_releaseArray:(id)array { 38 | 39 | CFBridgingRelease((__bridge CFArrayRef _Nullable)(array)); 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXMetaModule.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | #import "WXMetaModule.h" 9 | #import "WXConvert.h" 10 | #import "WXUtility.h" 11 | #import "WXSDKInstance_private.h" 12 | 13 | @implementation WXMetaModule 14 | 15 | @synthesize weexInstance; 16 | 17 | WX_EXPORT_METHOD(@selector(setViewport:)) 18 | 19 | - (void)setViewport:(NSDictionary *)viewportArguments 20 | { 21 | CGFloat viewportWidthFloat; 22 | id viewportWidth = viewportArguments[@"width"]; 23 | if ([viewportWidth isKindOfClass:[NSString class]]) { 24 | if ([viewportWidth isEqualToString:@"device-width"]) { 25 | viewportWidthFloat = [WXUtility portraitScreenSize].width * WXScreenScale(); 26 | } else if ([viewportWidth isEqualToString:@"device-height"]) { 27 | viewportWidthFloat = [WXUtility portraitScreenSize].height * WXScreenScale(); 28 | } else { 29 | viewportWidthFloat = [WXConvert CGFloat:viewportWidth]; 30 | } 31 | } else { 32 | viewportWidthFloat = [WXConvert CGFloat:viewportWidth]; 33 | } 34 | 35 | if (viewportWidthFloat > 0) { 36 | self.weexInstance.viewportWidth = viewportWidthFloat; 37 | } 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXScrollerProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | @class WXComponent; 10 | @protocol WXScrollerProtocol 11 | 12 | /** 13 | * @abstract add sticky component 14 | */ 15 | - (void)addStickyComponent:(WXComponent *)sticky; 16 | 17 | /** 18 | * @abstract remove sticky component 19 | */ 20 | - (void)removeStickyComponent:(WXComponent *)sticky; 21 | 22 | /** 23 | * @abstract adjust sticky components 24 | */ 25 | - (void)adjustSticky; 26 | 27 | /** 28 | * @abstract add scroll listener 29 | */ 30 | - (void)addScrollToListener:(WXComponent *)target; 31 | 32 | /** 33 | * @abstract remove scroll listener 34 | */ 35 | - (void)removeScrollToListener:(WXComponent *)target; 36 | 37 | - (void)scrollToComponent:(WXComponent *)component withOffset:(CGFloat)offset; 38 | 39 | - (BOOL)isNeedLoadMore; 40 | 41 | - (void)loadMore; 42 | 43 | - (CGPoint)contentOffset; 44 | 45 | - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated; 46 | 47 | - (CGSize)contentSize; 48 | 49 | - (void)setContentSize:(CGSize)size; 50 | 51 | - (UIEdgeInsets)contentInset; 52 | 53 | - (void)setContentInset:(UIEdgeInsets)contentInset; 54 | 55 | - (void)resetLoadmore; 56 | 57 | @end 58 | 59 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/testRootView.js: -------------------------------------------------------------------------------- 1 | /* 2 | 8 | 9 | */ 10 | 11 | define('@weex-component/59f2ac24414dd31be265c3f06c218e2f', function(require, exports, module) { 12 | 13 | ; 14 | module.exports = { 15 | data: function() { 16 | return {} 17 | } 18 | } 19 | 20 | 21 | ; 22 | module.exports.style = {} 23 | 24 | ; 25 | module.exports.template = { 26 | "type": "div", 27 | "style": { 28 | "left": function() { 29 | return this.left 30 | }, 31 | "top": function() { 32 | return this.top 33 | }, 34 | "width": function() { 35 | return this.width 36 | }, 37 | "height": function() { 38 | return this.height 39 | }, 40 | "backgroundColor": "#FF0000" 41 | }, 42 | "children": [{ 43 | "type": "div", 44 | "style": { 45 | "width": 100, 46 | "height": 200 47 | } 48 | }] 49 | } 50 | 51 | ; 52 | }) 53 | 54 | // require module 55 | bootstrap('@weex-component/59f2ac24414dd31be265c3f06c218e2f', { 56 | "transformerVersion": "0.3.1" 57 | }) 58 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Engine/WXSDKError.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXSDkInstance.h" 11 | 12 | typedef NS_ENUM(int, WXSDKErrCode) 13 | { 14 | WX_ERR_JSFRAMEWORK_START = -1001, 15 | WX_ERR_JSFRAMEWORK_LOAD = -1002, 16 | WX_ERR_JSFRAMEWORK_EXECUTE = -1003, 17 | WX_ERR_JSFRAMEWORK_END = -1099, 18 | 19 | WX_ERR_JSBRIAGE_START = -2001, 20 | WX_ERR_JSFUNC_PARAM = -2009, 21 | WX_ERR_INVOKE_NATIVE = -2012, 22 | WX_ERR_JS_EXECUTE = -2013, 23 | WX_ERR_JSBRIAGE_END = -2099, 24 | 25 | WX_ERR_RENDER_START = -2100, 26 | WX_ERR_RENDER_CREATEBODY = -2100, 27 | WX_ERR_RENDER_UPDATTR = -2101, 28 | WX_ERR_RENDER_UPDSTYLE = -2102, 29 | WX_ERR_RENDER_ADDELEMENT = -2103, 30 | WX_ERR_RENDER_REMOVEELEMENT = -2104, 31 | WX_ERR_RENDER_MOVEELEMENT = -2105, 32 | WX_ERR_RENDER_ADDEVENT = -2106, 33 | WX_ERR_RENDER_REMOVEEVENT = -2107, 34 | WX_ERR_RENDER_SCROLLTOELEMENT = -2110, 35 | WX_ERR_RENDER_END = -2199, 36 | 37 | WX_ERR_DOWNLOAD_START = -2201, 38 | WX_ERR_JSBUNDLE_DOWNLOAD = -2202, 39 | WX_ERR_JSBUNDLE_STRING_CONVERT = -2203, 40 | WX_ERR_CANCEL = -2204, 41 | WX_ERR_DOWNLOAD_END = -2299, 42 | }; 43 | 44 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Handler/WXURLRewriteDefaultImpl.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXURLRewriteDefaultImpl.h" 10 | #import "WXLog.h" 11 | #import "WXSDKInstance.h" 12 | 13 | 14 | NSString *const WXURLLocalScheme = @"local"; 15 | 16 | @implementation WXURLRewriteDefaultImpl 17 | 18 | - (NSURL *)rewriteURL:(NSString *)url 19 | withResourceType:(WXResourceType)resourceType 20 | withInstance:(WXSDKInstance *)instance 21 | { 22 | NSURL *completeURL = [NSURL URLWithString:url]; 23 | if ([completeURL isFileURL]) { 24 | return completeURL; 25 | } else if ([self isLocalURL:completeURL]) { 26 | NSString *resourceName = [[completeURL host] stringByAppendingString:[completeURL path]]; 27 | NSURL *resourceURL = [[NSBundle mainBundle] URLForResource:resourceName withExtension:@""]; 28 | if (!resourceURL) { 29 | WXLogError(@"Invalid local resource URL:%@, no resouce found.", url); 30 | } 31 | 32 | return resourceURL; 33 | } else { 34 | return [instance completeURL:url]; 35 | } 36 | } 37 | 38 | - (BOOL)isLocalURL:(NSURL *)url 39 | { 40 | return[[[url scheme] lowercaseString] isEqualToString:WXURLLocalScheme]; 41 | } 42 | 43 | @end 44 | -------------------------------------------------------------------------------- /src/filters/index.js: -------------------------------------------------------------------------------- 1 | export function host (url) { 2 | if (!url) return '' 3 | const host = url.replace(/^https?:\/\//, '').replace(/\/.*$/, '') 4 | const parts = host.split('.').slice(-3) 5 | if (parts[0] === 'www') parts.shift() 6 | return parts.join('.') 7 | } 8 | 9 | export function https (url) { 10 | const env = weex.config.env || WXEnvironment 11 | if (env.platform === 'iOS' && typeof url === 'string') { 12 | return url.replace(/^http\:/, 'https:') 13 | } 14 | return url 15 | } 16 | 17 | export function timeAgo (time) { 18 | const between = Date.now() / 1000 - Number(time) 19 | if (between < 3600) { 20 | return pluralize(~~(between / 60), ' minute') 21 | } else if (between < 86400) { 22 | return pluralize(~~(between / 3600), ' hour') 23 | } else { 24 | return pluralize(~~(between / 86400), ' day') 25 | } 26 | } 27 | 28 | function pluralize (time, label) { 29 | if (time === 1) { 30 | return time + label 31 | } 32 | return time + label + 's' 33 | } 34 | 35 | export function unescape (text) { 36 | let res = text || '' 37 | 38 | ;[ 39 | ['

', '\n'], 40 | ['&', '&'], 41 | ['&', '&'], 42 | [''', '\''], 43 | [''', '\''], 44 | ['/', '/'], 45 | [''', '\''], 46 | ['/', '/'], 47 | ['<', '<'], 48 | ['>', '>'], 49 | [' ', ' '], 50 | ['"', '"'] 51 | ].forEach(pair => { 52 | res = res.replace(new RegExp(pair[0], 'ig'), pair[1]) 53 | }) 54 | 55 | return res 56 | } 57 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/View/WXView.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXView.h" 10 | #import "WXComponent.h" 11 | #import "WXLayer.h" 12 | 13 | @implementation WXView 14 | 15 | + (Class)layerClass 16 | { 17 | return [WXLayer class]; 18 | } 19 | 20 | - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event 21 | { 22 | /** 23 | * Capturing touches on a subview outside the frame of its superview if it does not clips to bounds. 24 | */ 25 | if (self.hidden || !self.userInteractionEnabled) { 26 | return nil; 27 | } 28 | 29 | UIView* result = [super hitTest:point withEvent:event]; 30 | if (result) { 31 | return result; 32 | } 33 | 34 | // if clips to bounds, no need to detect outside views. 35 | if (self.clipsToBounds) { 36 | return nil; 37 | } 38 | 39 | for (UIView* subView in [self.subviews reverseObjectEnumerator]) { 40 | if (subView.hidden) { 41 | continue; 42 | } 43 | CGPoint subPoint = [self convertPoint:point toView:subView]; 44 | result = [subView hitTest:subPoint withEvent:event]; 45 | if (result) { 46 | return result; 47 | } 48 | } 49 | 50 | return nil; 51 | } 52 | @end 53 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Controller/WXRootViewController.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | /** 12 | * The WXRootViewController class inherited from UINavigationController class which implements a specialized 13 | * view controller that manages the navigation of hierarchical content. Developing an iOS application, you 14 | * need a series of customer pages which will be render by weex bundle. Sometimes, these pages are embedded in 15 | * viewcontroller. This navigation controller makes it possible to present your page efficiently and makes it 16 | * easier for the user to navigate that content. 17 | */ 18 | 19 | @interface WXRootViewController : UINavigationController 20 | 21 | /** 22 | * @abstract initialize the RootViewController with bundle url. 23 | * 24 | * @param soureURL. The bundle url which can be render to a weex view. 25 | * 26 | * @return a object the class of WXRootViewController. 27 | * 28 | * @discussion initialize this controller in function 'application:didFinishLaunchingWithOptions', and make it as rootViewContoller of window. In the 29 | * weex application, all page content can be managed by the navigation, such as push or pop. 30 | */ 31 | - (id)initWithSourceURL:(NSURL *)sourceURL; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Component/WXIndicatorComponent.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponent.h" 10 | 11 | typedef enum 12 | { 13 | WXPointIndicatorAlignCenter, // point indicator align center 14 | WXPointIndicatorAlignLeft, // point indicator align left 15 | WXPointIndicatorAlignRight, // point indicator align right 16 | } WXPointIndicatorAlignStyle; 17 | 18 | @interface WXIndicatorView : UIView 19 | 20 | @property (nonatomic, assign) NSInteger pointCount; // total count point of point indicator 21 | @property (nonatomic, assign) NSInteger currentPoint; // current light index of point at point indicator 22 | @property (nonatomic, strong) UIColor *pointColor; // normal point color of point indicator 23 | @property (nonatomic, strong) UIColor *lightColor; // highlight point color of point indicator 24 | @property (nonatomic, assign) WXPointIndicatorAlignStyle alignStyle; //align style of point indicator 25 | @property (nonatomic, assign) CGFloat pointSize; // point size of point indicator 26 | @property (nonatomic, assign) CGFloat pointSpace; // point space of point indicator 27 | 28 | @end 29 | 30 | 31 | @interface WXIndicatorComponent : WXComponent 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXModuleFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXModuleFactory : NSObject 12 | 13 | /** 14 | * @abstract Returns the class of specific module 15 | * 16 | * @param name The module name 17 | * 18 | **/ 19 | + (Class)classWithModuleName:(NSString *)name; 20 | 21 | /** 22 | * @abstract Returns the instance method implemented by the module 23 | * 24 | * @param name The module name 25 | * 26 | * @param method The module method 27 | * 28 | **/ 29 | + (SEL)selectorWithModuleName:(NSString *)name methodName:(NSString *)method isSync:(BOOL *)isSync; 30 | 31 | /** 32 | * @abstract Registers a module for a given name and the implemented class 33 | * 34 | * @param name The module name to register 35 | * 36 | * @param clazz The module class to register 37 | * 38 | **/ 39 | + (NSString *)registerModule:(NSString *)name withClass:(Class)clazz; 40 | 41 | /** 42 | * @abstract Returns the export methods in the specific module 43 | * 44 | * @param name The module name 45 | **/ 46 | + (NSMutableDictionary *)moduleMethodMapsWithName:(NSString *)name; 47 | 48 | 49 | /** 50 | * @abstract Returns the registered modules. 51 | */ 52 | + (NSDictionary *) moduleConfigs; 53 | 54 | @end 55 | 56 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | var path = require('path') 2 | var webpack = require('webpack') 3 | 4 | var bannerPlugin = new webpack.BannerPlugin({ 5 | banner: '// { "framework": "Vue" }\n', 6 | raw: true 7 | }) 8 | 9 | function getBaseConfig () { 10 | return { 11 | entry: { 12 | 'index': path.resolve('src', 'entry.js') 13 | }, 14 | output: { 15 | path: path.resolve(__dirname, 'dist') 16 | }, 17 | module: { 18 | rules: [ 19 | { 20 | test: /\.js$/, 21 | loader: 'babel-loader', 22 | exclude: /node_modules/ 23 | }, { 24 | test: /\.vue(\?[^?]+)?$/ 25 | } 26 | ] 27 | }, 28 | plugins: [ 29 | // new webpack.optimize.UglifyJsPlugin({compress: { warnings: false }}), 30 | bannerPlugin 31 | ] 32 | } 33 | } 34 | 35 | var webConfig = getBaseConfig() 36 | webConfig.output.filename = '[name].web.js' 37 | webConfig.module.rules[1].loader = 'vue-loader' 38 | /** 39 | * important! should use postTransformNode to add $processStyle for 40 | * inline style normalization. 41 | */ 42 | webConfig.module.rules[1].options = { 43 | compilerModules: [ 44 | { 45 | postTransformNode: el => { 46 | el.staticStyle = `$processStyle(${el.staticStyle})` 47 | el.styleBinding = `$processStyle(${el.styleBinding})` 48 | } 49 | } 50 | ] 51 | } 52 | 53 | var nativeConfig = getBaseConfig() 54 | nativeConfig.output.filename = '[name].weex.js' 55 | nativeConfig.module.rules[1].loader = 'weex-loader' 56 | 57 | module.exports = [webConfig, nativeConfig] 58 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Protocol/WXNetworkProtocol.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXModuleProtocol.h" 11 | 12 | __attribute__ ((deprecated("Use WXResourceRequestHandler instead"))) 13 | @protocol WXNetworkProtocol 14 | 15 | /** 16 | * @abstract send request 17 | * 18 | * @param request The URL Request 19 | * 20 | * @param sendDataCallback This block is called periodically to notify the progress. 21 | * 22 | * @param responseCallback This block is called when receiving a response and no further messages will be received until the completion block is called. 23 | * 24 | * @param receiveDataCallback This block is called when data is available. 25 | * 26 | * @param compeletionCallback This block is called when the last message related to a specific task is sent. 27 | */ 28 | - (id)sendRequest:(NSURLRequest *)request withSendingData:(void (^)(int64_t bytesSent, int64_t totalBytes))sendDataCallback 29 | withResponse:(void (^)(NSURLResponse *response))responseCallback 30 | withReceiveData:(void (^)(NSData *data))receiveDataCallback 31 | withCompeletion:(void (^)(NSData *totalData, NSError *error))compeletionCallback; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXAppConfiguration.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXAppConfiguration : NSObject 12 | 13 | /** 14 | * @abstract Group or organization of your app, default value is nil. 15 | */ 16 | + (NSString *)appGroup; 17 | + (void)setAppGroup:(NSString *) appGroup; 18 | 19 | /** 20 | * @abstract Name of your app, default is value for CFBundleDisplayName in main bundle. 21 | */ 22 | + (NSString *)appName; 23 | + (void)setAppName:(NSString *)appName; 24 | 25 | /** 26 | * @abstract Version of your app, default is value for CFBundleShortVersionString in main bundle. 27 | */ 28 | + (NSString *)appVersion; 29 | + (void)setAppVersion:(NSString *)appVersion; 30 | 31 | /** 32 | * @abstract External user agent of your app, all requests sent by weex will set the user agent on header, default value is nil. 33 | */ 34 | + (NSString *)externalUserAgent; 35 | + (void)setExternalUserAgent:(NSString *)userAgent; 36 | 37 | /** 38 | * @abstract JSFrameworkVersion 39 | */ 40 | + (NSString *)JSFrameworkVersion; 41 | + (void)setJSFrameworkVersion:(NSString *)JSFrameworkVersion; 42 | 43 | 44 | /* 45 | * @abstract customizeProtocolClasses 46 | */ 47 | + (NSArray*)customizeProtocolClasses; 48 | + (void)setCustomizeProtocolClasses:(NSArray*)customizeProtocolClasses; 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /ios/.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.gitignore.io/api/objective-c 2 | 3 | ### Objective-C ### 4 | # Xcode 5 | # 6 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 7 | 8 | ## Build generated 9 | build/ 10 | _demo/ 11 | DerivedData 12 | 13 | ## Various settings 14 | *.pbxuser 15 | !default.pbxuser 16 | *.mode1v3 17 | !default.mode1v3 18 | *.mode2v3 19 | !default.mode2v3 20 | *.perspectivev3 21 | !default.perspectivev3 22 | xcuserdata 23 | 24 | ## Other 25 | *.xccheckout 26 | *.moved-aside 27 | *.xcuserstate 28 | *.xcscmblueprint 29 | 30 | ## Obj-C/Swift specific 31 | *.hmap 32 | *.ipa 33 | 34 | # CocoaPods 35 | # 36 | # We recommend against adding the Pods directory to your .gitignore. However 37 | # you should judge for yourself, the pros and cons are mentioned at: 38 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 39 | # 40 | Pods/ 41 | Podfile.lock 42 | 43 | # Carthage 44 | # 45 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 46 | # Carthage/Checkouts 47 | 48 | Carthage/Build 49 | 50 | # fastlane 51 | # 52 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 53 | # screenshots whenever they are needed. 54 | # For more information about the recommended setup visit: 55 | # https://github.com/fastlane/fastlane/blob/master/docs/Gitignore.md 56 | 57 | fastlane/report.xml 58 | fastlane/screenshots 59 | 60 | ### Objective-C Patch ### 61 | *.xcscmblueprint 62 | 63 | 64 | # Created by https://www.gitignore.io/api/node 65 | 66 | *.gcno 67 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Module/WXInstanceWrap.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXInstanceWrap.h" 10 | #import "WXEmbedComponent.h" 11 | 12 | @implementation WXInstanceWrap 13 | 14 | @synthesize weexInstance; 15 | 16 | WX_EXPORT_METHOD(@selector(error:code:info:)) 17 | WX_EXPORT_METHOD(@selector(refresh)) 18 | 19 | - (void)error:(NSInteger)type code:(NSInteger)code info:(NSString *)info 20 | { 21 | NSString *domain = [NSString stringWithFormat:@"%ld", (long)type]; 22 | NSDictionary *userInfo = @{ NSLocalizedDescriptionKey:info }; 23 | NSError *error = [NSError errorWithDomain:domain code:code userInfo:userInfo]; 24 | if (weexInstance.onFailed) 25 | weexInstance.onFailed(error); 26 | } 27 | 28 | - (void)refresh 29 | { 30 | if (self.weexInstance.parentInstance) { 31 | WXSDKInstance *instance = self.weexInstance.parentInstance; 32 | NSString *nodeRef = self.weexInstance.parentNodeRef; 33 | WXEmbedComponent *embedComponent= (WXEmbedComponent *)[instance componentForRef:nodeRef]; 34 | [embedComponent refreshWeex]; 35 | } 36 | else { 37 | UIViewController *controller = self.weexInstance.viewController; 38 | if ([controller respondsToSelector:@selector(refreshWeex)]) { 39 | [controller performSelector:@selector(refreshWeex) withObject:nil]; 40 | } 41 | } 42 | } 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK.podspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | Pod::Spec.new do |s| 3 | 4 | s.name = "WeexSDK" 5 | 6 | s.version = "0.9.5" 7 | 8 | s.summary = "WeexSDK Source ." 9 | 10 | s.description = <<-DESC 11 | A framework for building Mobile cross-platform UI 12 | DESC 13 | 14 | s.homepage = "https://github.com/alibaba/weex" 15 | s.license = { 16 | :type => 'Copyright', 17 | :text => <<-LICENSE 18 | Alibaba-INC copyright 19 | LICENSE 20 | } 21 | s.authors = { "cxfeng1" => "cxfeng1@gmail.com", 22 | "boboning" => "ningli928@163.com", 23 | "yangshengtao" => "yangshengtao1314@163.com", 24 | "kfeagle" => "sunjjbobo@163.com", 25 | "acton393" => "zhangxing610321@gmail.com" 26 | } 27 | s.platform = :ios 28 | s.ios.deployment_target = '7.0' 29 | s.source = { :path => '.' } 30 | s.source_files = 'WeexSDK/Sources/**/*.{h,m,mm,c}' 31 | s.resources = 'WeexSDK/Resources/main.js', 'WeexSDK/Resources/wx_load_error@3x.png' 32 | 33 | s.requires_arc = true 34 | s.prefix_header_file = 'WeexSDK/Sources/Supporting Files/WeexSDK-Prefix.pch' 35 | 36 | # s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) DEBUG=1' } 37 | 38 | s.xcconfig = { "OTHER_LINK_FLAG" => '$(inherited) -ObjC'} 39 | 40 | s.user_target_xcconfig = { 'FRAMEWORK_SEARCH_PATHS' => "'$(PODS_ROOT)/WeexSDK'" } 41 | 42 | s.frameworks = 'CoreMedia','MediaPlayer','AVFoundation','AVKit','JavaScriptCore', 'GLKit' 43 | 44 | s.dependency 'SocketRocket' 45 | s.libraries = "stdc++" 46 | 47 | end 48 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Display/WXDisplayQueue.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXDisplayQueue.h" 10 | 11 | #define MAX_CONCURRENT_COUNT 8 12 | 13 | static dispatch_semaphore_t WXDisplayConcurrentSemaphore; 14 | 15 | @implementation WXDisplayQueue 16 | 17 | + (dispatch_queue_t)displayQueue 18 | { 19 | static dispatch_queue_t displayQueue = NULL; 20 | static dispatch_once_t onceToken; 21 | dispatch_once(&onceToken, ^{ 22 | displayQueue = dispatch_queue_create("com.taobao.weex.displayQueue", DISPATCH_QUEUE_CONCURRENT); 23 | dispatch_set_target_queue(displayQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0)); 24 | }); 25 | 26 | return displayQueue; 27 | } 28 | 29 | + (void)addBlock:(void(^)())block 30 | { 31 | static dispatch_once_t onceToken; 32 | dispatch_once(&onceToken, ^{ 33 | NSUInteger processorCount = [NSProcessInfo processInfo].activeProcessorCount; 34 | NSUInteger maxConcurrentCount = processorCount <= MAX_CONCURRENT_COUNT ? processorCount : MAX_CONCURRENT_COUNT; 35 | WXDisplayConcurrentSemaphore = dispatch_semaphore_create(maxConcurrentCount); 36 | }); 37 | 38 | dispatch_async([self displayQueue], ^{ 39 | dispatch_semaphore_wait(WXDisplayConcurrentSemaphore, DISPATCH_TIME_FOREVER); 40 | block(); 41 | dispatch_semaphore_signal(WXDisplayConcurrentSemaphore); 42 | }); 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXComponentFactory.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | 11 | @interface WXComponentFactory : NSObject 12 | 13 | /** 14 | * @abstract Register a component for a given name 15 | * 16 | * @param name The component name to register; 17 | * @param clazz The WXComponent subclass to register 18 | * @param pros The component properties to register 19 | */ 20 | + (void)registerComponent:(NSString *)name withClass:(Class)clazz withPros:(NSDictionary *)pros; 21 | 22 | /** 23 | * @abstract Register a list of components 24 | * @param components The components array to register, every element in array should be a dictionary, in the form of @{@"name": @"xxx", @"class":@"yyy"}, which specifies the name and class of the component 25 | */ 26 | + (void)registerComponents:(NSArray *)components; 27 | 28 | + (NSMutableDictionary *)componentMethodMapsWithName:(NSString *)name; 29 | 30 | + (SEL)methodWithComponentName:(NSString *)name withMethod:(NSString *)method; 31 | 32 | /** 33 | * @abstract Unregister all the components 34 | */ 35 | + (void)unregisterAllComponents; 36 | 37 | /** 38 | * @abstract Returns the class with a given component name. 39 | * @param name The component's name 40 | * @return The component's class 41 | */ 42 | + (Class)classWithComponentName:(NSString *)name; 43 | 44 | /** 45 | * @abstract Returns the registered components. 46 | */ 47 | + (NSDictionary *)componentConfigs; 48 | 49 | 50 | @end 51 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Bridge/WXComponentMethod.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXComponentMethod.h" 10 | #import "WXComponentFactory.h" 11 | #import "WXComponentManager.h" 12 | #import "WXSDKInstance.h" 13 | #import "WXLog.h" 14 | #import "WXUtility.h" 15 | 16 | @implementation WXComponentMethod 17 | { 18 | NSString *_componentName; 19 | NSString *_componentRef; 20 | } 21 | 22 | - (instancetype)initWithComponentRef:(NSString *)ref 23 | methodName:(NSString *)methodName 24 | arguments:(NSArray *)arguments 25 | instance:(WXSDKInstance *)instance 26 | { 27 | if (self = [super initWithMethodName:methodName arguments:arguments instance:instance]) { 28 | _componentRef = ref; 29 | } 30 | 31 | return self; 32 | } 33 | 34 | - (void)invoke 35 | { 36 | WXPerformBlockOnComponentThread(^{ 37 | WXComponent *component = [self.instance componentForRef:_componentRef]; 38 | if (!component) { 39 | WXLogError(@"component not found for ref:%@, type:%@", _componentRef, _componentName); 40 | } 41 | SEL selector = [WXComponentFactory methodWithComponentName:component.type withMethod:self.methodName]; 42 | NSInvocation * invocation = [self invocationWithTarget:component selector:selector]; 43 | WXPerformBlockOnMainThread(^{ 44 | [invocation invoke]; 45 | }); 46 | }); 47 | 48 | 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /ios/HackerNews/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Manager/WXHandlerFactory.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "WXHandlerFactory.h" 10 | #import "WXThreadSafeMutableDictionary.h" 11 | #import "WXNavigationDefaultImpl.h" 12 | #import "WXAssert.h" 13 | 14 | @interface WXHandlerFactory () 15 | 16 | @property (nonatomic, strong) WXThreadSafeMutableDictionary *handlers; 17 | 18 | @end 19 | 20 | @implementation WXHandlerFactory 21 | 22 | + (instancetype)sharedInstance { 23 | static WXHandlerFactory* _sharedInstance = nil; 24 | static dispatch_once_t oncePredicate; 25 | dispatch_once(&oncePredicate, ^{ 26 | _sharedInstance = [[self alloc] init]; 27 | _sharedInstance.handlers = [[WXThreadSafeMutableDictionary alloc] init]; 28 | }); 29 | return _sharedInstance; 30 | } 31 | 32 | + (void)registerHandler:(id)handler withProtocol:(Protocol *)protocol 33 | { 34 | WXAssert(handler && protocol, @"Handler or protocol for registering can not be nil."); 35 | WXAssertProtocol(handler, protocol); 36 | 37 | [[WXHandlerFactory sharedInstance].handlers setObject:handler forKey:NSStringFromProtocol(protocol)]; 38 | } 39 | 40 | + (id)handlerForProtocol:(Protocol *)protocol 41 | { 42 | WXAssert(protocol, @"Can not find handler for a nil protocol"); 43 | 44 | id handler = [[WXHandlerFactory sharedInstance].handlers objectForKey:NSStringFromProtocol(protocol)]; 45 | return handler; 46 | } 47 | 48 | + (NSDictionary *)handlerConfigs { 49 | return [WXHandlerFactory sharedInstance].handlers; 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Network/WXResourceRequestHandler.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | 10 | #import 11 | #import "WXResourceRequest.h" 12 | #import "WXResourceResponse.h" 13 | 14 | @protocol WXResourceRequestDelegate 15 | 16 | // Periodically informs the delegate of the progress of sending content to the server. 17 | - (void)request:(WXResourceRequest *)request didSendData:(unsigned long long)bytesSent totalBytesToBeSent:(unsigned long long)totalBytesToBeSent; 18 | 19 | // Tells the delegate that the request received the initial reply (headers) from the server. 20 | - (void)request:(WXResourceRequest *)request didReceiveResponse:(WXResourceResponse *)response; 21 | 22 | // Tells the delegate that the request has received some of the expected data. 23 | - (void)request:(WXResourceRequest *)request didReceiveData:(NSData *)data; 24 | 25 | // Tells the delegate that the request finished transferring data. 26 | - (void)requestDidFinishLoading:(WXResourceRequest *)request; 27 | 28 | // Tells the delegate that the request failed to load successfully. 29 | - (void)request:(WXResourceRequest *)request didFailWithError:(NSError *)error; 30 | 31 | @end 32 | 33 | @protocol WXResourceRequestHandler 34 | 35 | // Send a resource request with a delegate 36 | - (void)sendRequest:(WXResourceRequest *)request withDelegate:(id)delegate; 37 | 38 | @optional 39 | 40 | // Cancel the ongoing request 41 | - (void)cancelRequest:(WXResourceRequest *)request; 42 | 43 | @end 44 | 45 | 46 | -------------------------------------------------------------------------------- /android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | buildscript { 4 | repositories { 5 | mavenCentral() 6 | jcenter() 7 | } 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:2.1.3' 10 | classpath files('license/license-gradle-plugin-0.12.1.jar') 11 | classpath files('license/maven-license-plugin-1.10.b1.jar') 12 | classpath files('license/plexus-utils-3.0.24.jar') 13 | classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.5.0' 14 | } 15 | } 16 | 17 | android { 18 | compileSdkVersion 24 19 | buildToolsVersion "24.0.2" 20 | defaultConfig { 21 | applicationId "com.example.weex.hackernews" 22 | minSdkVersion 15 23 | targetSdkVersion 24 24 | versionCode 1 25 | versionName "1.0" 26 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 27 | } 28 | buildTypes { 29 | release { 30 | minifyEnabled false 31 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 32 | } 33 | } 34 | } 35 | 36 | dependencies { 37 | compile fileTree(dir: 'libs', include: ['*.jar']) 38 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 39 | exclude group: 'com.android.support', module: 'support-annotations' 40 | }) 41 | compile 'com.android.support:appcompat-v7:24.1.1' 42 | compile 'com.android.support:recyclerview-v7:24.1.1' 43 | compile 'com.android.support:support-v4:24.1.1' 44 | compile 'com.android.support:appcompat-v7:24.1.1' 45 | compile 'com.alibaba:fastjson:1.1.46.android' 46 | compile 'com.squareup.picasso:picasso:2.5.2' 47 | compile project(':weex_sdk') 48 | testCompile 'junit:junit:4.12' 49 | } 50 | -------------------------------------------------------------------------------- /ios/HackerNews/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UIRequiresFullScreen 32 | 33 | UIStatusBarHidden 34 | 35 | UIStatusBarStyle 36 | UIStatusBarStyleLightContent 37 | UISupportedInterfaceOrientations 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /ios/HackerNews/WXImgLoaderDefaultImpl.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXImgLoaderDefaultImpl.m 3 | // HackerNews 4 | // 5 | // Created by Hanks on 16/12/8. 6 | // Copyright © 2016年 Weex. All rights reserved. 7 | // 8 | 9 | #import "WXImgLoaderDefaultImpl.h" 10 | #import 11 | 12 | #define MIN_IMAGE_WIDTH 36 13 | #define MIN_IMAGE_HEIGHT 36 14 | 15 | 16 | #if OS_OBJECT_USE_OBJC 17 | #undef WXDispatchQueueRelease 18 | #undef WXDispatchQueueSetterSementics 19 | #define WXDispatchQueueRelease(q) 20 | #define WXDispatchQueueSetterSementics strong 21 | #else 22 | #undef WXDispatchQueueRelease 23 | #undef WXDispatchQueueSetterSementics 24 | #define WXDispatchQueueRelease(q) (dispatch_release(q)) 25 | #define WXDispatchQueueSetterSementics assign 26 | #endif 27 | 28 | @interface WXImgLoaderDefaultImpl() 29 | 30 | @property (WXDispatchQueueSetterSementics, nonatomic) dispatch_queue_t ioQueue; 31 | 32 | @end 33 | 34 | @implementation WXImgLoaderDefaultImpl 35 | 36 | #pragma mark - 37 | #pragma mark WXImgLoaderProtocol 38 | 39 | - (id)downloadImageWithURL:(NSString *)url imageFrame:(CGRect)imageFrame userInfo:(NSDictionary *)userInfo completed:(void(^)(UIImage *image, NSError *error, BOOL finished))completedBlock 40 | { 41 | if ([url hasPrefix:@"//"]) { 42 | url = [@"http:" stringByAppendingString:url]; 43 | } 44 | return (id)[[SDWebImageManager sharedManager] downloadImageWithURL:[NSURL URLWithString:url] options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { 45 | 46 | } completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, BOOL finished, NSURL *imageURL) { 47 | if (completedBlock) { 48 | completedBlock(image, error, finished); 49 | } 50 | }]; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /android/WeexSDK/src/main/java/com/taobao/weex/dom/WXCustomStyleSpan.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. All rights reserved. 3 | *

4 | * This source code is licensed under the BSD-style license found in the LICENSE file in the root 5 | * directory of this source tree. An additional grant of patent rights can be found in the PATENTS 6 | * file in the same directory. 7 | */ 8 | package com.taobao.weex.dom; 9 | 10 | import android.graphics.Typeface; 11 | import android.text.TextPaint; 12 | import android.text.style.MetricAffectingSpan; 13 | import com.taobao.weex.utils.TypefaceUtil; 14 | 15 | public class WXCustomStyleSpan extends MetricAffectingSpan { 16 | 17 | private final int mStyle; 18 | private final int mWeight; 19 | private final String mFontFamily; 20 | 21 | public WXCustomStyleSpan(int fontStyle, int fontWeight, String fontFamily) { 22 | mStyle = fontStyle; 23 | mWeight = fontWeight; 24 | mFontFamily = fontFamily; 25 | } 26 | 27 | @Override 28 | public void updateDrawState(TextPaint ds) { 29 | TypefaceUtil.applyFontStyle(ds, mStyle, mWeight, mFontFamily); 30 | } 31 | 32 | @Override 33 | public void updateMeasureState(TextPaint paint) { 34 | TypefaceUtil.applyFontStyle(paint, mStyle, mWeight, mFontFamily); 35 | } 36 | 37 | /** 38 | * Returns {@link Typeface#NORMAL} or {@link Typeface#ITALIC}. 39 | */ 40 | public int getStyle() { 41 | return (mStyle == WXStyle.UNSET ? 0 : mStyle); 42 | } 43 | 44 | /** 45 | * Returns {@link Typeface#NORMAL} or {@link Typeface#BOLD}. 46 | */ 47 | public int getWeight() { 48 | return (mWeight == WXStyle.UNSET ? 0 : mWeight); 49 | } 50 | 51 | /** 52 | * Returns the font family set for this StyleSpan. 53 | */ 54 | public String getFontFamily() { 55 | return mFontFamily; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /README.zh.md: -------------------------------------------------------------------------------- 1 | # Hacker News App 2 | 3 | 首个使用 Weex 和 Vue 开发的 Hacker News 原生应用。 4 | 5 | ## 预览 6 | 7 | 用 [Weex Playground App](https://weex.apache.org/playground.html) 扫描下方二维码即可。 8 | 9 | > **项目使用的 [Hacker News API](https://github.com/HackerNews/API) 是由 Google 的 [Firebase](https://firebase.google.com/) 提供的网络服务,在国内网络环境里访问可能会受到一些影响。** 10 | 11 | ![QR Code](./qrcode.jpg) 12 | 13 | > 二维码内容是 `http://whatever.cn?_wx_tpl=https://raw.githubusercontent.com/weexteam/weex-hackernews/master/ios/assets/index.js` ,确保你的手机能登上 GitHub 。 14 | 15 | ## 编译项目文件 16 | 17 | 安装依赖: 18 | 19 | ``` 20 | npm install 21 | ``` 22 | 23 | 编译代码: 24 | 25 | ```bash 26 | # 生成 Web 平台和 native 平台可用的 bundle 文件 27 | # 位置: 28 | # dist/index.web.js 29 | # dist/index.web.js 30 | npm run build 31 | 32 | # 监听模式的 npm run build 33 | npm run dev 34 | ``` 35 | 36 | 拷贝 bundle 文件: 37 | 38 | ```bash 39 | # 将生成的 bundle 文件拷贝到 Android 项目的资源目录 40 | npm run copy:android 41 | 42 | # 将生成的 bundle 文件拷贝到 iOS 项目的资源目录 43 | npm run copy:ios 44 | 45 | # run both copy:andriod and copy:ios 46 | npm run copy 47 | ``` 48 | 49 | ### 启动 Web 服务 50 | 51 | ``` 52 | npm run serve 53 | ``` 54 | 55 | 启动服务后会监听 1337 端口,访问 http://127.0.0.1:1337/index.html 即可在浏览器中预览页面。 56 | 57 | ### 启动 Android 项目 58 | 59 | 首先应该安装 [Android Studio](https://developer.android.com/studio/index.html) 和必要的 Android SDK,配置好基本的开发环境。 60 | 61 | 使用 Android Studio 打开 `android` 目录中的项目,等待自动安装完依赖以后,即可启动模拟器或者真机预览页面。 62 | 63 | ### 启动 iOS 项目 64 | 65 | 首先应该配置好 [iOS 开发环境](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppStoreDistributionTutorial/Setup/Setup.html) 并且安装 [CocoaPods](https://guides.cocoapods.org/using/getting-started.html) 工具。 66 | 67 | 进入 `ios` 目录,使用 CocoaPods 安装依赖: 68 | 69 | ``` 70 | pod install 71 | ``` 72 | 73 | 使用 Xcode 打开 `ios` 目录中的项目(`HackerNews.xcworkspace`),然后即可启动模拟器预览页面。 74 | 75 | > 注:如果想要在真机上查看效果,还需要配置开发者签名等信息。 76 | -------------------------------------------------------------------------------- /ios/HackerNews/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/WXConvertTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // WXConvertTests.m 3 | // WeexSDK 4 | // 5 | // Created by Keen Zhi on 16/9/20. 6 | // Copyright © 2016年 taobao. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "WXConvert.h" 11 | 12 | @interface WXConvertTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation WXConvertTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testBOOL { 29 | // This is an example of a functional test case. 30 | // Use XCTAssert and related functions to verify your tests produce the correct results. 31 | BOOL boolval = [WXConvert BOOL:@"-1"]; 32 | XCTAssertTrue(boolval); 33 | boolval = [WXConvert BOOL:@"true"]; 34 | XCTAssertTrue(boolval); 35 | 36 | boolval = [WXConvert BOOL:@"false"]; 37 | XCTAssertTrue(!boolval); 38 | 39 | } 40 | 41 | - (void) testNSUInteger{ 42 | NSUInteger val= [WXConvert NSUInteger:@"x"]; 43 | XCTAssertTrue(0==val); 44 | 45 | 46 | val= [WXConvert NSUInteger:@"9"]; 47 | XCTAssertTrue(9); 48 | 49 | //test max 50 | NSString * unsignedIntMax = [NSString stringWithFormat:@"%lu", NSUIntegerMax ]; 51 | val= [WXConvert NSUInteger:unsignedIntMax]; 52 | XCTAssertTrue(val==NSUIntegerMax); 53 | 54 | 55 | 56 | //test overflow 57 | unsigned long long uio = NSUIntegerMax; 58 | uio++; 59 | 60 | NSString * ulval = [NSString stringWithFormat:@"%llu", uio ]; 61 | val = [WXConvert NSUInteger:ulval]; 62 | XCTAssertTrue(0==val);//overflowed 63 | 64 | } 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /src/views/UserView.vue: -------------------------------------------------------------------------------- 1 | 17 | 18 | 40 | 41 | 69 | -------------------------------------------------------------------------------- /src/components/app-header.vue: -------------------------------------------------------------------------------- 1 | 25 | 26 | 71 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDK/Sources/Utility/WXType.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import 11 | 12 | typedef NS_ENUM(NSUInteger, WXScrollDirection) { 13 | WXScrollDirectionVertical, 14 | WXScrollDirectionHorizontal, 15 | WXScrollDirectionNone, 16 | }; 17 | 18 | typedef NS_ENUM(NSUInteger, WXTextStyle) { 19 | WXTextStyleNormal = 0, 20 | WXTextStyleItalic 21 | }; 22 | 23 | typedef NS_ENUM(NSInteger, WXTextDecoration) { 24 | WXTextDecorationNone = 0, 25 | WXTextDecorationUnderline, 26 | WXTextDecorationLineThrough 27 | }; 28 | 29 | typedef NS_ENUM(NSInteger, WXImageQuality) { 30 | WXImageQualityOriginal = -1, 31 | WXImageQualityLow = 0, 32 | WXImageQualityNormal, 33 | WXImageQualityHigh, 34 | WXImageQualityNone, 35 | }; 36 | 37 | typedef NS_ENUM(NSInteger, WXImageSharp) { 38 | WXImageSharpeningNone = 0, 39 | WXImageSharpening 40 | }; 41 | 42 | typedef NS_ENUM(NSInteger, WXVisibility) { 43 | WXVisibilityShow = 0, 44 | WXVisibilityHidden 45 | }; 46 | 47 | typedef NS_ENUM(NSInteger, WXBorderStyle) { 48 | WXBorderStyleNone = 0, 49 | WXBorderStyleDotted, 50 | WXBorderStyleDashed, 51 | WXBorderStyleSolid 52 | }; 53 | 54 | typedef NS_ENUM(NSInteger, WXPositionType) { 55 | WXPositionTypeRelative = 0, 56 | WXPositionTypeAbsolute, 57 | WXPositionTypeSticky, 58 | WXPositionTypeFixed 59 | }; 60 | 61 | typedef NS_ENUM(NSInteger, WXGradientType) { 62 | WXGradientTypeToTop = 0, 63 | WXGradientTypeToBottom, 64 | WXGradientTypeToLeft, 65 | WXGradientTypeToRight, 66 | WXGradientTypeToTopleft, 67 | WXGradientTypeToBottomright, 68 | }; 69 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/dependency/OCMock/OCMArg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2009-2016 Erik Doernenburg and contributors 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may 5 | * not use these files except in compliance with the License. You may obtain 6 | * a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations 14 | * under the License. 15 | */ 16 | 17 | #import 18 | 19 | @interface OCMArg : NSObject 20 | 21 | // constraining arguments 22 | 23 | + (id)any; 24 | + (SEL)anySelector; 25 | + (void *)anyPointer; 26 | + (id __autoreleasing *)anyObjectRef; 27 | + (id)isNil; 28 | + (id)isNotNil; 29 | + (id)isEqual:(id)value; 30 | + (id)isNotEqual:(id)value; 31 | + (id)isKindOfClass:(Class)cls; 32 | + (id)checkWithSelector:(SEL)selector onObject:(id)anObject; 33 | + (id)checkWithBlock:(BOOL (^)(id obj))block; 34 | 35 | // manipulating arguments 36 | 37 | + (id *)setTo:(id)value; 38 | + (void *)setToValue:(NSValue *)value; 39 | + (id)invokeBlock; 40 | + (id)invokeBlockWithArgs:(id)first,... NS_REQUIRES_NIL_TERMINATION; 41 | 42 | + (id)defaultValue; 43 | 44 | // internal use only 45 | 46 | + (id)resolveSpecialValues:(NSValue *)value; 47 | 48 | @end 49 | 50 | #define OCMOCK_ANY [OCMArg any] 51 | 52 | #if defined(__GNUC__) && !defined(__STRICT_ANSI__) 53 | #define OCMOCK_VALUE(variable) \ 54 | ({ __typeof__(variable) __v = (variable); [NSValue value:&__v withObjCType:@encode(__typeof__(__v))]; }) 55 | #else 56 | #define OCMOCK_VALUE(variable) [NSValue value:&variable withObjCType:@encode(__typeof__(variable))] 57 | #endif 58 | 59 | -------------------------------------------------------------------------------- /ios/HackerNews/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | } 88 | ], 89 | "info" : { 90 | "version" : 1, 91 | "author" : "xcode" 92 | } 93 | } -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/TestSupportUtils.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import "TestSupportUtils.h" 10 | 11 | 12 | bool WXIsDoubleApproximate(double x, double y) { 13 | return fabs(x - y) < 0.001; 14 | } 15 | 16 | bool WXTransform3DApproximateToTransform(CATransform3D a,CATransform3D b) 17 | { 18 | return 19 | WXIsDoubleApproximate(a.m11, b.m11) && 20 | WXIsDoubleApproximate(a.m12, b.m12) && 21 | WXIsDoubleApproximate(a.m13, b.m13) && 22 | WXIsDoubleApproximate(a.m14, b.m14) && 23 | WXIsDoubleApproximate(a.m21, b.m21) && 24 | WXIsDoubleApproximate(a.m22, b.m22) && 25 | WXIsDoubleApproximate(a.m23, b.m23) && 26 | WXIsDoubleApproximate(a.m24, b.m24) && 27 | WXIsDoubleApproximate(a.m31, b.m31) && 28 | WXIsDoubleApproximate(a.m32, b.m32) && 29 | WXIsDoubleApproximate(a.m33, b.m33) && 30 | WXIsDoubleApproximate(a.m34, b.m34) && 31 | WXIsDoubleApproximate(a.m41, b.m41) && 32 | WXIsDoubleApproximate(a.m42, b.m42) && 33 | WXIsDoubleApproximate(a.m43, b.m43) && 34 | WXIsDoubleApproximate(a.m44, b.m44); 35 | } 36 | 37 | bool WXRectApproximateToRect(CGRect a,CGRect b) 38 | { 39 | return 40 | WXIsDoubleApproximate(a.origin.x, b.origin.x) && 41 | WXIsDoubleApproximate(a.origin.y, b.origin.y) && 42 | WXIsDoubleApproximate(a.size.width, b.size.width) && 43 | WXIsDoubleApproximate(a.size.height, b.size.height); 44 | } 45 | 46 | 47 | @implementation TestSupportUtils 48 | 49 | +(void)waitSecs:(NSTimeInterval)secs{ 50 | NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:secs]; 51 | while ( [timeoutDate timeIntervalSinceNow] > 0) { 52 | CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.01, YES); 53 | } 54 | } 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /ios/WeexSDK/WeexSDKTests/WXSDKManagerTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Weex. 3 | * Copyright (c) 2016, Alibaba, Inc. All rights reserved. 4 | * 5 | * This source code is licensed under the Apache Licence 2.0. 6 | * For the full copyright and license information,please view the LICENSE file in the root directory of this source tree. 7 | */ 8 | 9 | #import 10 | #import "WXSDKManager.h" 11 | #import "WXSDKInstance.h" 12 | #import "TestSupportUtils.h" 13 | 14 | @interface WXSDKManagerTests : XCTestCase 15 | 16 | @end 17 | 18 | @implementation WXSDKManagerTests 19 | 20 | - (void)setUp { 21 | [super setUp]; 22 | // Put setup code here. This method is called before the invocation of each test method in the class. 23 | } 24 | 25 | - (void)tearDown { 26 | // Put teardown code here. This method is called after the invocation of each test method in the class. 27 | [super tearDown]; 28 | } 29 | 30 | - (void)testExample { 31 | // This is an example of a functional test case. 32 | // Use XCTAssert and related functions to verify your tests produce the correct results. 33 | } 34 | 35 | - (void)testWXSDKManager { 36 | id bridgeMgr = [WXSDKManager bridgeMgr]; 37 | XCTAssertNotNil(bridgeMgr); 38 | XCTAssertTrue([bridgeMgr isKindOfClass:NSClassFromString(@"WXBridgeManager")]); 39 | 40 | [WXSDKManager storeInstance:[WXSDKInstance new] forID:@"0"]; 41 | WXSDKInstance *instance0 = [WXSDKManager instanceForID:@"0"]; 42 | XCTAssertNotNil(instance0); 43 | 44 | [WXSDKManager storeInstance:[WXSDKInstance new] forID:@"1"]; 45 | WXSDKInstance *instance1 = [WXSDKManager instanceForID:@"1"]; 46 | XCTAssertNotNil(instance1); 47 | 48 | [WXSDKManager removeInstanceforID:@"0"]; 49 | instance0 = [WXSDKManager instanceForID:@"0"]; 50 | XCTAssertNil(instance0); 51 | 52 | [WXSDKManager unload]; 53 | // [TestSupportUtils waitSecs:5]; 54 | instance1 = [WXSDKManager instanceForID:@"1"]; 55 | //XCTAssertNil(instance1); 56 | } 57 | 58 | - (void)testUnload { 59 | 60 | } 61 | 62 | @end 63 | --------------------------------------------------------------------------------