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 | 
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 |
2 |
3 |
4 |
5 |
{{ userId }}
6 |
7 | Created: {{ user.created | timeAgo }} ago
8 | Karma: {{ user.karma }}
9 | {{ user.about | unescape }}
10 |
11 |
12 | loading ...
13 |
14 |
15 |
16 |
17 |
18 |
40 |
41 |
69 |
--------------------------------------------------------------------------------
/src/components/app-header.vue:
--------------------------------------------------------------------------------
1 |
2 |
24 |
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 |
--------------------------------------------------------------------------------