| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| #import <Foundation/Foundation.h> |
| #import <JavaScriptCore/JavaScriptCore.h> |
| #import "WXBridgeProtocol.h" |
| |
| @class WXCallJSMethod; |
| @class WXSDKInstance; |
| |
| @interface WXBridgeContext : NSObject |
| |
| /** |
| * return instance at the top of the stack. |
| **/ |
| @property (nonatomic, weak, readonly) WXSDKInstance *topInstance; |
| |
| /** |
| * Create Instance Method |
| * @param instance : instance id |
| * @param temp : template data |
| * @param options : parameters |
| * @param data : external data |
| **/ |
| - (void)createInstance:(NSString *)instance |
| template:(NSString *)temp |
| options:(NSDictionary *)options |
| data:(id)data; |
| |
| /** |
| * Create Instance with opcode |
| * @param instance : instance id |
| * @param contents : opcode data |
| * @param options : parameters |
| * @param data : external data |
| **/ |
| - (void)createInstance:(NSString *)instance |
| contents:(NSData *)contents |
| options:(NSDictionary *)options |
| data:(id)data; |
| |
| /** |
| * Destroy Instance Method |
| * @param instance : instance id |
| **/ |
| - (void)destroyInstance:(NSString *)instance; |
| |
| /** |
| * Trigger full GC, for dev and debug only. |
| **/ |
| - (void)forceGarbageCollection; |
| |
| /** |
| * Refresh Instance Method |
| * @param instance : instance id |
| * @param data : external data |
| **/ |
| - (void)refreshInstance:(NSString *)instance |
| data:(id)data; |
| |
| /** |
| * Update Instance State Method |
| * @param instance : instance id |
| * @param data : parameters |
| **/ |
| - (void)updateState:(NSString *)instance |
| data:(id)data; |
| |
| /** |
| * Execute JSFramework Script |
| * @param script : script code |
| **/ |
| - (void)executeJsFramework:(NSString *)script; |
| |
| /** |
| * Execute JS Method |
| * @param method : object of bridge method |
| **/ |
| - (void)executeJsMethod:(WXCallJSMethod *)method; |
| |
| - (JSValue *)excuteJSMethodWithResult:(WXCallJSMethod *)method; |
| |
| /** |
| * Register Modules Method |
| * @param modules : module list |
| **/ |
| - (void)registerModules:(NSDictionary *)modules; |
| |
| /** |
| * Execute JS Service |
| * @param script : JS services script |
| * @param name : JS services name |
| **/ |
| - (void)executeJsService:(NSString *)script withName: (NSString *)name; |
| |
| /** |
| * Register Components Method |
| * @param components component list |
| **/ |
| - (void)registerComponents:(NSArray *)components; |
| |
| /** |
| * Connect To WebSocket for devtool debug |
| * @param url : url to connect |
| **/ |
| - (void)connectToDevToolWithUrl:(NSURL *)url; |
| |
| /** |
| * Connect To WebSocket for collecting log |
| * @param url : url to connect |
| **/ |
| - (void)connectToWebSocket:(NSURL *)url; |
| |
| /** |
| * Log To WebSocket |
| * @param flag : the tag to identify |
| * @param message : message to output |
| **/ |
| - (void)logToWebSocket:(NSString *)flag message:(NSString *)message; |
| |
| /** |
| * Reset Environment |
| **/ |
| - (void)resetEnvironment; |
| |
| + (void)mountContextEnvironment:(JSContext*)context; |
| - (void)callJSMethod:(NSString *)method args:(NSArray *)args onContext:(id<WXBridgeProtocol>)bridge completion:(void (^)(JSValue * value))complection; |
| |
| @end |