Rambler.iOS #8 - Make your app extensible with JavaScriptCore
-
Upload
rambler-ios -
Category
Technology
-
view
165 -
download
2
Transcript of Rambler.iOS #8 - Make your app extensible with JavaScriptCore
![Page 1: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/1.jpg)
Extend Your App With
JavaScriptCoreMicha MAZAHERI
iOS > Mac > Python > React
@mittsh
![Page 2: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/2.jpg)
![Page 3: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/3.jpg)
![Page 4: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/4.jpg)
![Page 5: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/5.jpg)
API BlueprintIntegration?
![Page 6: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/6.jpg)
How can we make
Paw hackable with
JavaScriptCore?
![Page 7: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/7.jpg)
OpenSource
Clean Your App
FocusSmallApps
![Page 8: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/8.jpg)
Updates
![Page 9: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/9.jpg)
Updates
![Page 10: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/10.jpg)
![Page 11: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/11.jpg)
CocoaScript
![Page 12: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/12.jpg)
![Page 13: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/13.jpg)
WebKit
![Page 14: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/14.jpg)
Your JS API
InterfaceContract
Testing Use itLike it?
![Page 15: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/15.jpg)
Example
JSContext* context = [[JSContext alloc] init];JSValue* gigaValue = [context evaluateScript:@"Math.pow(2,30)"];NSLog(@"1 GiB = %ld bytes", [gigaValue toNumber].integerValue);// 1 GiB = 1073741824 bytes
![Page 16: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/16.jpg)
JSValueJavaScript Type Objective-C Type Swift Type
string NSString String
boolean BOOL Bool
number
NSNumberdoubleint32_tuint32_t
NSNumber!DoubleInt32UInt32
Date NSDate Date
Array NSArray [AnyObject]
Object NSDictionary [NSObject : AnyObject]
Object custom type custom type
![Page 17: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/17.jpg)
JSContext
VirtualMachine
Holds AllObjects
SingleThread
![Page 18: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/18.jpg)
JSExport
SwiftClass
JavaScriptPrototype
SwiftInstance
JavaScriptObject
![Page 19: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/19.jpg)
/* Extend JSExport protocol */@protocol LMJSRequest <JSExport>
JSExportAs(getMethod, -(id)method);JSExportAs(getUrl, -(id)url);
JSExportAs(setMethod, -(id)method:(NSString*)method);JSExportAs(setUrl, -(id)url:(NSString*)url);
@end
/* Implement protocol as a category */@interface LMRequest (LMJSRequest) <LMJSRequest>
@end
![Page 20: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/20.jpg)
Not The Web
DOM WebWorkers Web Crypto
Local Storage
XHR (Ajax)setTimeout
CSSPromiseWebSocket
File API
![Page 21: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/21.jpg)
Not The Web
Pure Vanilla JS
![Page 22: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/22.jpg)
Multithreading
Core Data Grand Central
Dispatch
![Page 23: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/23.jpg)
Run LoopsetTimeout()
DispatchQueue.main.asyncAfter(deadline: time)
…run code…
![Page 24: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/24.jpg)
Extensions in Paw
ImportersCodeGenerators
DynamicValues
![Page 25: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/25.jpg)
Code Generators• Client Code (Swift, ObjC, Python, Ruby…)• Command Line (cURL, HTTPie)• API Descriptions (API Blueprint, Swagger, RAML…)• 3rd party (Postman)
![Page 26: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/26.jpg)
Importers• HTTP Archives (HAR)• API Descriptions (API Blueprint, Swagger, RAML…)• 3rd party (Postman)
![Page 27: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/27.jpg)
Dynamic Values• Auth (JWT, Digest, Django…)• 3rd party auth (Amazon, Auth0…)• Randomizers (Chance.js, UUID, JSON Schema)
![Page 28: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/28.jpg)
Who uses JavaScriptCore?
React NativeSafari Build Apps
![Page 29: Rambler.iOS #8 - Make your app extensible with JavaScriptCore](https://reader038.fdocuments.in/reader038/viewer/2022110109/58847e371a28ab5e248b7a49/html5/thumbnails/29.jpg)
Conclusion
• We can open source more• Always have an answer• More features than any competitor• Update extensions multiple times a week