├── .babelrc ├── .eslintignore ├── .eslintrc ├── .gitignore ├── .gitmodules ├── .npmignore ├── .nvmrc ├── .travis.yml ├── CONTRIBUTING.md ├── Comparisons.md ├── LICENSE.txt ├── ManticoreNative.podspec ├── README.md ├── appveyor.yml ├── bin ├── manticore-gen └── mantify ├── examples ├── README.md └── hello-world │ ├── README.md │ └── src │ ├── ios │ ├── .gitignore │ ├── Hello Manticore │ │ ├── Hello Manticore.xcodeproj │ │ │ └── project.pbxproj │ │ └── Hello Manticore │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ │ ├── Info.plist │ │ │ ├── ViewController.h │ │ │ ├── ViewController.m │ │ │ └── main.m │ ├── Podfile │ ├── Podfile.lock │ ├── build.sh │ ├── generated │ │ ├── .gitignore │ │ └── ManticoreGenerated.podspec │ └── package.json │ └── js │ ├── Hello.js │ ├── index.js │ └── package.json ├── index.js ├── lib ├── cli.js ├── manticore-gen │ ├── README.md │ ├── index.js │ └── lib │ │ ├── dustHelpers.js │ │ ├── reader.js │ │ └── writer.js └── mantify │ ├── README.md │ └── index.js ├── package.json ├── runtime ├── README.md ├── android │ ├── .gitignore │ ├── .npmignore │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── js │ │ └── polyfill.js │ ├── manticore │ │ ├── .gitignore │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ ├── src │ │ │ ├── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ │ └── com │ │ │ │ │ │ └── paypal │ │ │ │ │ │ └── manticore │ │ │ │ │ │ ├── DefaultTypeConverter.java │ │ │ │ │ │ ├── FetchResponse.java │ │ │ │ │ │ ├── IManticoreObserver.java │ │ │ │ │ │ ├── IManticoreTypeConverter.java │ │ │ │ │ │ ├── JsBackedObject.java │ │ │ │ │ │ ├── JsExecutor.java │ │ │ │ │ │ ├── ManticoreEngine.java │ │ │ │ │ │ ├── ManticoreException.java │ │ │ │ │ │ └── NativeServices.java │ │ │ │ └── res │ │ │ │ │ └── values │ │ │ │ │ └── strings.xml │ │ │ └── test │ │ │ │ └── java │ │ │ │ └── com │ │ │ │ └── paypal │ │ │ │ └── manticore │ │ │ │ ├── BaseTest.java │ │ │ │ └── EngineTests.java │ │ └── testLibs │ │ │ ├── j2v8_linux_x86_64-3.1.6.jar │ │ │ └── j2v8_macosx_x86_64-3.1.6.jar │ ├── settings.gradle │ └── templates │ │ ├── asyncCbDecl.dust │ │ ├── class.dust │ │ ├── config.json │ │ ├── defaultValue.dust │ │ ├── enum.dust │ │ ├── event.dust │ │ ├── field.dust │ │ ├── fnReturnType.dust │ │ ├── fnType.dust │ │ ├── ifaceDecl.dust │ │ ├── method.dust │ │ ├── toJs.dust │ │ ├── toNative.dust │ │ ├── toString.dust │ │ └── wrapDecl.dust ├── common │ ├── console.js │ ├── fetch.js │ ├── fetch │ │ ├── Body.js │ │ ├── Headers.js │ │ ├── Request.js │ │ └── Response.js │ ├── promise.js │ └── timer.js ├── objc │ ├── .gitignore │ ├── .npmignore │ ├── Common │ │ └── ManticoreTests.m │ ├── Manticore │ │ ├── PPManticoreEngine+Private.h │ │ ├── PPManticoreEngine.h │ │ ├── PPManticoreEngine.m │ │ ├── PPManticoreError.h │ │ ├── PPManticoreError.m │ │ ├── PPManticoreEventHolder.h │ │ ├── PPManticoreEventHolder.m │ │ ├── PPManticoreJSBackedObject.h │ │ ├── PPManticoreJSBackedObject.m │ │ ├── PPManticoreNativeInterface.h │ │ ├── PPManticoreNativeInterface.m │ │ ├── PPManticorePlugin.h │ │ ├── PPManticorePlugin.m │ │ ├── PPManticoreTypeConverter.h │ │ └── PPManticoreTypeConverter.m │ ├── ManticoreContainer │ │ ├── Default-568h@2x.png │ │ ├── ManticoreContainer-OSX │ │ │ ├── AppDelegate.swift │ │ │ ├── Base.lproj │ │ │ │ └── MainMenu.xib │ │ │ └── Info.plist │ │ ├── ManticoreContainer-OSXTests │ │ │ └── Info.plist │ │ ├── ManticoreContainer-iOS │ │ │ └── Info.plist │ │ ├── ManticoreContainer-iOSTests │ │ │ └── Info.plist │ │ ├── ManticoreContainer.xcodeproj │ │ │ ├── project.pbxproj │ │ │ ├── project.xcworkspace │ │ │ │ ├── contents.xcworkspacedata │ │ │ │ └── xcshareddata │ │ │ │ │ └── ManticoreContainer.xccheckout │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ ├── ManticoreContainer-OSX.xcscheme │ │ │ │ └── ManticoreContainer-iOS.xcscheme │ │ └── main.m │ ├── Podfile │ ├── Podfile.lock │ ├── README.md │ ├── js │ │ └── polyfill.js │ └── templates │ │ ├── class.dust │ │ ├── classHeader.dust │ │ ├── config.json │ │ ├── importAll.dust │ │ ├── method.dust │ │ ├── toJs.dust │ │ ├── toNative.dust │ │ └── typedefs.dust ├── win │ ├── .gitignore │ ├── .npmignore │ ├── Manticore.Desktop.Test │ │ ├── EngineTests.cs │ │ ├── Licenses │ │ │ ├── ClearScript.main.license │ │ │ ├── v8.main.license │ │ │ ├── v8.strongtalk.license │ │ │ ├── v8.v8.license │ │ │ └── v8.valgrind.license │ │ ├── Manticore.Desktop.Test.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── packages.config │ ├── Manticore.Desktop │ │ ├── ClearScriptV8-32.dll │ │ ├── ClearScriptV8-64.dll │ │ ├── DefaultConverter.cs │ │ ├── IJsTypeConverter.cs │ │ ├── JsBackedObject.cs │ │ ├── JsErrorBuilder.cs │ │ ├── JsValueHolder.cs │ │ ├── Licenses │ │ │ ├── ClearScript.main.license │ │ │ ├── v8.main.license │ │ │ ├── v8.strongtalk.license │ │ │ ├── v8.v8.license │ │ │ └── v8.valgrind.license │ │ ├── Manticore.Desktop.csproj │ │ ├── ManticoreEngine.cs │ │ ├── ManticoreException.cs │ │ ├── NativeServices.cs │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ ├── ScriptEventArgs.cs │ │ ├── SingleThreadedReentrantScheduler.cs │ │ ├── app.config │ │ ├── packages.config │ │ ├── v8-ia32.dll │ │ └── v8-x64.dll │ ├── Manticore.Net4.Test │ │ ├── Manticore.Net4.Test.csproj │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── packages.config │ ├── Manticore.Net4 │ │ ├── Manticore.Net4.csproj │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── Manticore.WP81.Test │ │ ├── Assets │ │ │ ├── Logo.scale-240.png │ │ │ ├── SmallLogo.scale-240.png │ │ │ ├── SplashScreen.scale-240.png │ │ │ ├── Square71x71Logo.scale-240.png │ │ │ ├── StoreLogo.scale-240.png │ │ │ └── WideLogo.scale-240.png │ │ ├── Manticore.WP81.Test.csproj │ │ ├── Package.appxmanifest │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── packages.config │ ├── Manticore.WP81 │ │ ├── Manticore.WP81.csproj │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── Manticore.Win81.Test │ │ ├── Images │ │ │ ├── UnitTestLogo.scale-100.png │ │ │ ├── UnitTestSmallLogo.scale-100.png │ │ │ ├── UnitTestSplashScreen.scale-100.png │ │ │ └── UnitTestStoreLogo.scale-100.png │ │ ├── Manticore.Win81.Test.csproj │ │ ├── Package.appxmanifest │ │ ├── Properties │ │ │ └── AssemblyInfo.cs │ │ └── packages.config │ ├── Manticore.Win81 │ │ ├── DefaultConverter.cs │ │ ├── IJsTypeConverter.cs │ │ ├── JsBackedObject.cs │ │ ├── Manticore.Win81.csproj │ │ ├── ManticoreEngine.cs │ │ ├── NativeServices.cs │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── Manticore.WinRT │ │ ├── Manticore.WinRT.csproj │ │ └── Properties │ │ │ └── AssemblyInfo.cs │ ├── Manticore.sln │ ├── js │ │ ├── polyfill.clearscript.js │ │ └── polyfill.jint.js │ └── templates │ │ ├── clearscript │ │ ├── argList.dust │ │ ├── class.dust │ │ ├── config.json │ │ ├── delegateDecl.dust │ │ ├── enum.dust │ │ ├── method.dust │ │ ├── toJs.dust │ │ └── toNative.dust │ │ └── jint │ │ ├── argList.dust │ │ ├── class.dust │ │ ├── config.json │ │ ├── enum.dust │ │ ├── method.dust │ │ ├── toJs.dust │ │ └── toNative.dust └── xamarin │ ├── .npmignore │ └── templates │ └── objc │ ├── config.json │ ├── enums.dust │ └── impl.dust ├── scripts ├── ci │ └── travis.sh └── packaging │ └── make-npm-ignores.sh └── test ├── debug-templates ├── class.dust ├── classHeader.dust ├── config.json ├── enum.dust ├── enums.dust ├── header.dust ├── impl.dust ├── importAll.dust └── typedefs.dust ├── expected-outputs ├── csharp-clearscript │ ├── SDKTest.cs │ ├── SDKTestDefault.cs │ ├── SDKTestDefaultSubclass.cs │ └── SDKTestStatuses.cs ├── csharp-jint │ ├── SDKTest.cs │ ├── SDKTestDefault.cs │ ├── SDKTestDefaultSubclass.cs │ └── SDKTestStatuses.cs ├── j2v8 │ ├── SDKTest.java │ ├── SDKTestDefault.java │ ├── SDKTestDefaultSubclass.java │ └── SDKTestStatuses.java ├── objc │ ├── PPManticoreSDKTest.h │ ├── PPManticoreSDKTest.m │ ├── PPManticoreSDKTestDefault.h │ ├── PPManticoreSDKTestDefault.m │ ├── PPManticoreSDKTestDefaultSubclass.h │ ├── PPManticoreSDKTestDefaultSubclass.m │ ├── PayPalManticoreImports.h │ └── PayPalManticoreTypes.h └── xamarin-objc │ ├── ApiDefinition.cs │ └── StructsAndEnums.cs ├── infra.js ├── js-source ├── SDKTest.js ├── SDKTestDefault.js └── index.js ├── test_gen.js └── test_node.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015"], 3 | "sourceMaps": true, 4 | "plugins": ["syntax-async-functions","transform-regenerator"] 5 | } 6 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | **/*.pack.js 2 | **/*_pack.js 3 | /runtime/android/manticore/build 4 | /runtime/win/jint 5 | /build/ -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "extends": "airbnb/base", 4 | "rules": { 5 | "no-param-reassign": [ 6 | 2, 7 | { 8 | "props": false 9 | } 10 | ], 11 | "no-console": 0 12 | } 13 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # ES5 output 2 | /build 3 | 4 | # Logs 5 | logs 6 | *.log 7 | 8 | # Runtime data 9 | pids 10 | *.pid 11 | *.seed 12 | 13 | # Directory for instrumented libs generated by jscoverage/JSCover 14 | lib-cov 15 | 16 | # Coverage directory used by tools like istanbul 17 | coverage 18 | .nyc_output 19 | 20 | # Users Environment Variables 21 | .lock-wscript 22 | 23 | node_modules 24 | npm-debug.log 25 | 26 | .idea 27 | .DS_Store 28 | report.xml 29 | test.tap 30 | 31 | *.pack.js 32 | *_pack.js 33 | /output 34 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "runtime/win/jint"] 2 | path = runtime/win/jint 3 | url = https://github.com/djMax/jint.git 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | .nyc_output 16 | 17 | # test stuff 18 | report.xml 19 | test.tap 20 | 21 | # Users Environment Variables 22 | .lock-wscript 23 | 24 | # npm stuff 25 | node_modules 26 | npm-debug.log 27 | 28 | # OS stuff 29 | .idea 30 | .DS_Store 31 | 32 | 33 | # CI stuff 34 | build/* 35 | appveyor.yml 36 | scripts 37 | examples 38 | 39 | # Unrelated to the node package 40 | ManticoreNative.podspec 41 | output 42 | -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | 4.4 -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | matrix: 2 | include: 3 | - language: node_js 4 | before_install: if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi 5 | env: BUILD_ITEM=node 6 | node_js: "4.4" 7 | - os: osx 8 | language: objective-c 9 | env: BUILD_ITEM=objc 10 | osx_image: xcode7.3 11 | node_js: "4.4" 12 | - language: android 13 | env: BUILD_ITEM=java 14 | node_js: "4.4" 15 | android: 16 | components: 17 | - platform-tools 18 | - tools 19 | - platform-tools 20 | - build-tools-23.0.2 21 | - android-23 22 | 23 | script: 24 | - ./scripts/ci/travis.sh 25 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | We welcome your contributions! 5 | 6 | ### TL;DR 7 | 8 | 1. Fork it ( https://github.com/paypal/manticore-native/fork ) 9 | 2. Create your feature branch (`git checkout -b my-new-feature`) 10 | 3. Commit your changes (`git commit -am 'Add some feature'`) 11 | 4. Push to the branch (`git push origin my-new-feature`) 12 | 5. Create a new Pull Request 13 | 14 | 15 | Guidelines 16 | ========== 17 | 18 | ### Pre-commit 19 | 20 | Your patches will be rejected programmatically if they do not pass (at a bare minimum) the `npm run lint` and `npm test` checks. 21 | An npm script (`npm run precommit-lint`) is available if you'd like to use this in a pre-commit hook. 22 | -------------------------------------------------------------------------------- /Comparisons.md: -------------------------------------------------------------------------------- 1 | 2 | Manticore vs React Native 3 | ========================= 4 | 5 | Someone more familiar with React Native should send a PR to this description, but 6 | the main points of differentiation in our mind are: 7 | 8 | * **Wider Platform Targets** - Manticore runs "natively" on Windows XP+, Mac OS, iOS, and Android. Since it's Javascript, 9 | your code will run natively (without manticore wrappers) in a browser, as a Chrome app, 10 | in Node.js or in node-webkit. 11 | * **No UI** - Manticore does not deal with UI in any way. It is purely a computation and business logic layer. We 12 | don't have to deal with all the differences in UI philosophies among the platforms. There aren't too many different 13 | opinions on for loops and async/await, etc. So it truly is write once run anywhere for Manticore JS code. 14 | * As a result of not being UI-focused, we are not super sensitive to performance. JS is what it is - if you get sloppy 15 | it will get slow. If you're making a video game or a cryptographic toolkit, Manticore probably isn't right for you 16 | (unless of course all the UI and number-crunchery is a Manticore plugin) 17 | * **Lighter Weight** - Manticore is a "smaller decision" about the way you write apps. You can still do 18 | whatever fancy UI stuff you do to make the app look like a million bucks, but add Manticore 19 | to make the boring network service layers, personalization, etc. better. Manticore was created 20 | to provide common code for an SDK, where we cared about low overhead within reason, and we 21 | didn't want to force a complete app rewrite to integrate our components. 22 | * Manticore exposes your Javascript objects to native code. Generally React Native is UI-focused 23 | and up-front - meaning you KNOW React is involved. In theory Manticore users don't even know 24 | that the logic "down there" is in Javascript. 25 | 26 | We love React Native, and we strive to make code targeted for Manticore work in React Native 27 | as well. We started this project before React Native existed (and since we target Windows, Chrome, etc) 28 | it's not an option for us. But there are probably a small set of changes to React Native on iOS 29 | and Android which would allow it to serve as an "output platform" for Manticore JS code, and we 30 | continue to explore that avenue. 31 | 32 | 33 | What we have in common: 34 | ----------------------- 35 | 36 | * Babel 37 | * ES6 + async/await 38 | * require module system 39 | * fetch support 40 | 41 | 42 | Manticore vs Apache Cordova / PhoneGap 43 | ====================================== 44 | 45 | Cordova is a UI-centric system for writing cross-platform apps -- your entire app must be written in HTML, CSS 46 | and JavaScript, your code runs in a web browser, and "plugins" are necessary to access native components. 47 | 48 | Manticore is the opposite of UI-centric; it can't touch the UI at all -- your entire app can be written in the 49 | native language for the platform, your Manticore code runs in a javascript engine, and no plugins are required. 50 | 51 | That said, since Manticore doesn't deal with UI and runs as JavaScript, it should be possible for Manticore 52 | JavaScript to run in Cordova as a plugin. However, no testing has been done in that area and we have no data either way. -------------------------------------------------------------------------------- /ManticoreNative.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | 3 | s.name = "ManticoreNative" 4 | s.version = "1.0.0" 5 | s.summary = "A runtime to expose Javascript classes, logic and code to native components in OS X and iOS" 6 | s.description = %{ 7 | manticore-native runs Javascript on OS X and iOS and allows interaction between native code and JS objects via "shims" 8 | that manage type marshaling, callbacks (both directions) and objects/methods. It is most useful in cases where you want 9 | *broad* platform compatibility (all the way to WinXP) but do not want a cross platform UI solution (e.g. React Native). 10 | In theory, Javascript written for Manticore will also work in React Native, but sometimes you want consolidated business 11 | logic but not consolidated UI code. 12 | } 13 | s.homepage = "https://github.com/paypal/manticore-native" 14 | s.license = 'PayPal' 15 | s.author = { "PayPal" => "DL-PP-manticore@paypal.com" } 16 | s.source = { :git => "git@github.com:paypal/manticore-native.git", :tag => s.version.to_s } 17 | 18 | s.requires_arc = true 19 | 20 | s.ios.deployment_target = '7.0' 21 | s.osx.deployment_target = '10.9' 22 | 23 | source_folders = [ 24 | 'runtime/objc/Manticore/', 25 | ] 26 | 27 | s.resource_bundle = { 28 | 'ManticoreNativeResources' => [ 29 | 'runtime/objc/js/polyfill.pack.js', 30 | ] 31 | } 32 | 33 | s.frameworks = [ 34 | 'Foundation', 35 | 'JavaScriptCore', 36 | ] 37 | 38 | s.source_files = source_folders.map {|f| f + '*.{h,m}'} 39 | s.public_header_files = source_folders.map {|f| f + '*.h'} 40 | 41 | end 42 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | branches: 4 | # blacklist 5 | except: 6 | - gh-pages 7 | 8 | pull_requests: 9 | do_not_increment_build_number: true 10 | 11 | environment: 12 | nodejs_version: 4.4 13 | AppxPackageSigningEnabled: false 14 | 15 | install: 16 | - echo install step 17 | - ps: Install-Product node $env:nodejs_version 18 | - git submodule update --init --recursive 19 | - npm install -g npm@3 20 | - npm install 21 | - npm run postinstall 22 | - npm run build-testjs 23 | - npm run win-polyfill 24 | - npm run win-testjs 25 | 26 | before_build: 27 | - echo before_build step 28 | - ps: nuget restore runtime\win\Manticore.sln 29 | 30 | build: 31 | project: runtime/win/Manticore.sln 32 | verbosity: minimal 33 | 34 | before_test: 35 | - echo before_test step 36 | - dir C:\projects\manticore-native\runtime\win\Manticore.Desktop.Test\bin\Debug 37 | - dir C:\projects\manticore-native\runtime\win\Manticore.Net4.Test\bin\Debug 38 | - dir C:\projects\manticore-native\runtime\win\Manticore.Win81.Test\obj\x86\Debug 39 | 40 | test: off 41 | 42 | test_script: 43 | - '%xunit20%\xunit.console.x86 "C:\projects\manticore-native\runtime\win\Manticore.Desktop.Test\bin\Debug\Manticore.Desktop.Test.dll" -appveyor' 44 | - '%xunit20%\xunit.console.x86 "C:\projects\manticore-native\runtime\win\Manticore.Net4.Test\bin\Debug\Manticore.Net4.Test.dll" -appveyor' 45 | 46 | notifications: 47 | - provider: Webhook 48 | url: https://webhooks.gitter.im/e/ca378df62dd2e3372f46 49 | method: GET 50 | on_build_success: true 51 | on_build_failure: false 52 | on_build_status_changed: false 53 | -------------------------------------------------------------------------------- /bin/manticore-gen: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var path = require('path'); 3 | var process = require('process'); 4 | var built = path.join(__dirname, '..', 'build', 'manticore-gen', 'index.js'); 5 | var gen = require(built); 6 | gen.run(process.argv) 7 | .catch((e) => { 8 | console.error('Generation failed', e.message, e.stack); 9 | process.exit(-1); 10 | }); 11 | -------------------------------------------------------------------------------- /bin/mantify: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | var path = require('path'); 3 | var built = path.join(__dirname, '..', 'build', 'mantify', 'index.js'); 4 | var mantify = require(built); 5 | var process = require('process'); 6 | 7 | mantify.run(process.argv); 8 | -------------------------------------------------------------------------------- /examples/README.md: -------------------------------------------------------------------------------- 1 | 2 | Manticore Example Projects 3 | ========================== 4 | 5 | These examples exist to show soup-to-nuts Manticore integration into projects, from packaging to build scripts. 6 | 7 | * [Hello Manticore](hello-world/): A manticore-powered "Hello World" program 8 | 9 | 10 | See Also 11 | -------- 12 | 13 | * [Runtime documentation in ../runtime/](../runtime/) -------------------------------------------------------------------------------- /examples/hello-world/README.md: -------------------------------------------------------------------------------- 1 | 2 | Hello Manticore 3 | =============== 4 | 5 | The common JavaScript library is found in [src/js/](src/js/). 6 | 7 | * [iOS example](src/ios/) 8 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/.gitignore: -------------------------------------------------------------------------------- 1 | # Manticore generated things 2 | manticore_modules.js 3 | 4 | # node 5 | node_modules 6 | 7 | # Xcode 8 | build/* 9 | *.pbxuser 10 | !default.pbxuser 11 | *.mode1v3 12 | !default.mode1v3 13 | *.mode2v3 14 | !default.mode2v3 15 | *.perspectivev3 16 | !default.perspectivev3 17 | *.xcworkspace 18 | !default.xcworkspace 19 | xcuserdata 20 | profile 21 | *.moved-aside 22 | resources/*/.idea 23 | resources/.idea 24 | **/.DS_Store 25 | .DS_Store 26 | .idea 27 | *.xccheckout 28 | .bundle 29 | .project 30 | *.orig 31 | 32 | 33 | Pods -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // Hello Manticore 4 | // 5 | // Created by Schneider, Griffin on 12/4/15. 6 | // Copyright © 2015 Schneider, Griffin. 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 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // Hello Manticore 4 | // 5 | // Created by Schneider, Griffin on 12/4/15. 6 | // Copyright © 2015 Schneider, Griffin. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import 11 | #import "PPManticoreJSBackedObject.h" 12 | 13 | //////////////////////////////////////////////////////////////////////////////////////////////////// 14 | @implementation AppDelegate 15 | 16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 17 | [PPManticoreJSBackedObject setManticoreEngine:[PPManticoreEngine new]]; 18 | NSString *path = [[NSBundle mainBundle] pathForResource:@"manticore_modules" ofType:@"js"]; 19 | [[PPManticoreJSBackedObject engine] loadScript:[NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:NULL] withName:nil]; 20 | return YES; 21 | } 22 | 23 | @end 24 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "83.5x83.5", 66 | "scale" : "2x" 67 | } 68 | ], 69 | "info" : { 70 | "version" : 1, 71 | "author" : "xcode" 72 | } 73 | } -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/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 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // Hello Manticore 4 | // 5 | // Created by Schneider, Griffin on 12/4/15. 6 | // Copyright © 2015 Schneider, Griffin. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property (weak, nonatomic) IBOutlet UILabel *textLabel; 14 | @property (weak, nonatomic) IBOutlet UIButton *button; 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // Hello Manticore 4 | // 5 | // Created by Schneider, Griffin on 12/4/15. 6 | // Copyright © 2015 Schneider, Griffin. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import 11 | 12 | 13 | @interface ViewController() 14 | @property (nonatomic, strong) PPManticoreHello *hello; 15 | @end 16 | 17 | //////////////////////////////////////////////////////////////////////////////////////////////////// 18 | @implementation ViewController 19 | 20 | 21 | - (void)loadView { 22 | [super loadView]; 23 | 24 | self.hello = [[PPManticoreHello alloc] initWithStringProperty:@"Hello World!" intProperty:42]; 25 | [self updateUI]; 26 | 27 | } 28 | 29 | - (void)updateUI { 30 | 31 | self.textLabel.text = self.hello.stringProperty; 32 | [self.button setTitle:[NSString stringWithFormat:@"%d", self.hello.intProperty] forState:UIControlStateNormal]; 33 | } 34 | 35 | 36 | - (IBAction)buttonPressed:(id)sender { 37 | self.hello.intProperty++; 38 | [self updateUI]; 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Hello Manticore/Hello Manticore/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Hello Manticore 4 | // 5 | // Created by Schneider, Griffin on 12/4/15. 6 | // Copyright © 2015 Schneider, Griffin. 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 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Podfile: -------------------------------------------------------------------------------- 1 | 2 | xcodeproj 'Hello Manticore/Hello Manticore.xcodeproj' 3 | 4 | pod 'ManticoreNative', :path => '../../../../', :inhibit_warnings => true 5 | pod 'ManticoreGenerated', :path => 'generated/', :inhibit_warnings => true 6 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ManticoreGenerated (0.0.1): 3 | - ManticoreNative (~> 1.0.0) 4 | - ManticoreNative (1.0.0) 5 | 6 | DEPENDENCIES: 7 | - ManticoreGenerated (from `generated/`) 8 | - ManticoreNative (from `../../../../`) 9 | 10 | EXTERNAL SOURCES: 11 | ManticoreGenerated: 12 | :path: generated/ 13 | ManticoreNative: 14 | :path: ../../../../ 15 | 16 | SPEC CHECKSUMS: 17 | ManticoreGenerated: fcd81fd16db1fdeefac25bbae637f2f9329f1eea 18 | ManticoreNative: 52236cbc64b97cb969487246c225fc453479de8f 19 | 20 | COCOAPODS: 0.39.0 21 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/build.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | set -ex 3 | npm install --production 4 | ./node_modules/.bin/manticore-gen node_modules/manticore-native/runtime/objc/templates generated/src node_modules/hello-world/*.js 5 | ./node_modules/.bin/mantify generated/manticore_modules.js node_modules/hello-world/*.js 6 | pod install 7 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/generated/.gitignore: -------------------------------------------------------------------------------- 1 | src/* 2 | manticore_modules.js -------------------------------------------------------------------------------- /examples/hello-world/src/ios/generated/ManticoreGenerated.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "ManticoreGenerated" 3 | s.version = "0.0.1" 4 | 5 | s.requires_arc = true 6 | 7 | s.ios.frameworks = [ 8 | 'Foundation' 9 | ] 10 | 11 | s.ios.source_files = ['**/*.{h,m}'] 12 | s.ios.public_header_files = ['**/*.h'] 13 | 14 | s.xcconfig = { 15 | 'OTHER_LDFLAGS' => '-weak_library /usr/lib/libstdc++.dylib', 16 | } 17 | 18 | s.dependency 'ManticoreNative', '~> 1.0.0' 19 | 20 | s.libraries = 'c++', 'stdc++', 'z' 21 | end 22 | -------------------------------------------------------------------------------- /examples/hello-world/src/ios/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world-ios", 3 | "dependencies": { 4 | "hello-world": "file:../js/", 5 | "manticore-native": "file:../../../../", 6 | "webpack": "^1.13.1" 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /examples/hello-world/src/js/Hello.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @class 3 | * @property {string} stringProperty A string 4 | * @property {int} intProperty An int 5 | */ 6 | export default class Hello { 7 | 8 | /** 9 | * Create an instance of Hello. 10 | * @constructor 11 | * @param {string} stringProperty A string 12 | * @param {int} intProperty An int 13 | */ 14 | constructor(stringProperty, intProperty) { 15 | this.stringProperty = stringProperty; 16 | this.intProperty = intProperty; 17 | } 18 | 19 | /** 20 | * @method 21 | * @returns {string} 22 | */ 23 | toString() { 24 | return "{\n\t\"" + this.stringProperty + "\",\n\t" + this.intProperty + "\n}"; 25 | } 26 | 27 | /** 28 | * 29 | */ 30 | testCallback(callback) { 31 | callback(); 32 | } 33 | 34 | set stringProperty(value) { 35 | this._stringProperty = value; 36 | } 37 | 38 | get stringProperty() { 39 | return this._stringProperty; 40 | } 41 | 42 | set intProperty(value) { 43 | this._intProperty = value; 44 | } 45 | 46 | get intProperty() { 47 | return this._intProperty; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /examples/hello-world/src/js/index.js: -------------------------------------------------------------------------------- 1 | var manticore = require('manticore-native'); 2 | 3 | import Hello from './Hello'; 4 | 5 | module.exports = { 6 | Hello, 7 | }; 8 | 9 | manticore.nativeExport(module, { Hello }); 10 | -------------------------------------------------------------------------------- /examples/hello-world/src/js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello-world", 3 | "version": "1.0.0", 4 | "dependencies": { 5 | "manticore-native": "file:../../../../" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // 2 | // A simple shim for all languages that isolates your JS code's interface to manticore services 3 | // 4 | const closure = { 5 | exports: {}, 6 | }; 7 | const g = global; 8 | 9 | /** 10 | * The native interface is where services provided by the hosting process will be injected. 11 | * This is usually just "global.manticore," but in Node.js we don't really want to pollute 12 | * global like that. 13 | */ 14 | export const native = (() => { 15 | if (g.manticore) { 16 | return g.manticore; 17 | } 18 | closure.manticore = {}; 19 | return closure.manticore; 20 | })(); 21 | 22 | /** 23 | * Export a set of objects to the native layer, as well as 24 | * adding them to your module exports (for JS platforms) 25 | * @param module Your module (e.g. put "module" here) 26 | * @param exportsObj The object containing items to export 27 | */ 28 | export function nativeExport(module, exportsObj) { 29 | // const exportsObj = (exports === undefined ? module.exports : exports); // won't work; don't try 30 | if (exportsObj === null || typeof exportsObj !== 'object') { 31 | throw new Error(`nativeExport expected exports to be an object, got ${typeof exportsObj}`); 32 | } 33 | const nativeExports = g.exports || closure.exports; 34 | for (const k of Object.getOwnPropertyNames(exportsObj)) { 35 | nativeExports[k] = module.exports[k] = exportsObj[k]; 36 | } 37 | } 38 | 39 | let _fetch = g.fetch; 40 | 41 | // Trick browserify to avoid pulling node-fetch into all native bundles 42 | // since the native bundles are in charge of providing their own fetch function 43 | if (!_fetch) { 44 | const fakeBrowserify = require; 45 | _fetch = fakeBrowserify('node-fetch'); 46 | } 47 | 48 | /** 49 | * The HTTP "fetch" function, exposed via manticore so that you can write your JS code 50 | * to work in both node and other supported manticore environments. Your code should 51 | * call manticore.fetch, and let higher modules (e.g. the app/tool) decide what 52 | * implementation that should use. 53 | * TODO this is not a faithful implementation of fetch yet. It's close enough for simple 54 | * tasks, but we should flesh this out a lot more in the polyfills for the various 55 | * runtimes (including node). 56 | */ 57 | export function fetch(...args) { 58 | return _fetch.apply(null, args); 59 | } 60 | 61 | /** 62 | * This allows "import manticore from 'manticore';" to do something useful 63 | */ 64 | export default native; 65 | -------------------------------------------------------------------------------- /lib/cli.js: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | // get a decent approximation of the command that was typed in 4 | export function determineCommand(argv) { 5 | const nodeCmd = path.basename(argv[0]); 6 | const script = path.basename(argv[1]); 7 | 8 | if (path.extname(script) === '') { 9 | return path.basename(argv[1]); // something like 'manticore' 10 | } 11 | return `${nodeCmd} ${script}`; // something like 'node index.js' 12 | } 13 | -------------------------------------------------------------------------------- /lib/mantify/README.md: -------------------------------------------------------------------------------- 1 | Mantify 2 | ======= 3 | 4 | The `mantify` script prepares a set of scripts in the filesystem for use within a Manticore project. It's a thin wrapper around `browserify`. 5 | 6 | ``` 7 | Usage: 8 | mantify [options] 9 | 10 | Example: 11 | mantify generated/manticore-modules.js src/input*.js 12 | 13 | ``` -------------------------------------------------------------------------------- /lib/mantify/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | // https://github.com/babel/babel-eslint/issues/163#issuecomment-213620435 4 | const eslintWorkaround = true; // eslint-disable-line no-unused-vars 5 | 6 | // A simple utility script to browserify documents as we want 7 | import fs from 'fs'; 8 | import browserify from 'browserify'; 9 | import path from 'path'; 10 | import mkdirp from 'mkdirp'; 11 | import glob from 'glob'; 12 | import { determineCommand } from '../cli.js'; 13 | 14 | // return an object containing the options that were specified on the command line 15 | // (we provide a name to the positional arguments) 16 | // onError() { what to do } 17 | function parseCliOptions(args) { 18 | const opts = { 19 | }; 20 | const program = require('minimist')(args, opts); 21 | if (program._.length < 2) { 22 | throw new Error('Invalid Arguments'); 23 | } 24 | program.outputFile = program._[0]; 25 | program.inputFiles = program._.slice(1); 26 | return program; 27 | } 28 | 29 | function help(argv) { 30 | const cmd = determineCommand(argv); 31 | console.log(` 32 | Usage: 33 | ${cmd} [options] 34 | 35 | Example: 36 | ${cmd} generated/manticore-modules.js src/input*.js 37 | 38 | Supported options: 39 | TODO: probably stuff that you would pass to browserify 40 | `); 41 | } 42 | 43 | export function mantify(inputFiles, outputFile, browserifyOptions) { 44 | let files = inputFiles; 45 | 46 | if (require('os').platform() === 'win32') { 47 | let targ = []; 48 | for (const file of files) { 49 | targ = targ.concat(glob.sync(file)); 50 | } 51 | files = targ; 52 | } 53 | 54 | // TODO: make this pull from path.join(__dirname, '..', '..', '.babelrc'); 55 | const babelRc = { 56 | presets: ['es2015'], 57 | sourceMaps: true, 58 | plugins: ['syntax-async-functions', 'transform-regenerator'], 59 | }; 60 | 61 | let b = browserify(files, browserifyOptions).transform('babelify', babelRc); 62 | 63 | if (process.env.UGLIFYIFY) { 64 | b = b.transform({ 65 | global: true, 66 | }, 'uglifyify'); 67 | } 68 | 69 | mkdirp.sync(path.dirname(outputFile)); 70 | b.bundle().pipe(fs.createWriteStream(outputFile)); 71 | } 72 | 73 | /** 74 | * entry point for command line arguments; just parse and generate 75 | * 76 | * @param argv 77 | */ 78 | export function run(argv) { 79 | let opts; 80 | try { 81 | const args = argv.slice(2); 82 | opts = parseCliOptions(args); 83 | } catch (e) { 84 | help(argv); 85 | process.exit(-1); // OK to do this, we are called from command line 86 | } 87 | 88 | mantify(opts.inputFiles, opts.outputFile, {}); 89 | } 90 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "manticore-native", 3 | "version": "1.0.0", 4 | "description": "A runtime to expose Javascript classes, logic and code to native components", 5 | "main": "build/index.js", 6 | "bin": { 7 | "manticore-gen": "./bin/manticore-gen", 8 | "mantify": "./bin/mantify" 9 | }, 10 | "scripts": { 11 | "lint": "eslint index.js lib bin", 12 | "precommit-lint": "eslint .; true", 13 | "test": "babel-node ./node_modules/.bin/tape test/**/test_*.js", 14 | "testSome": "babel-node ./node_modules/.bin/tape", 15 | "build-testjs": "babel-node ./bin/mantify ./output/index.pack.js test/js-source/index.js", 16 | "objc-polyfill": "babel-node ./bin/mantify runtime/objc/js/polyfill.pack.js runtime/objc/js/polyfill.js", 17 | "objc-testjs": "mkdirp output/objc && babel-node -- ./bin/manticore-gen -q ./runtime/objc/templates ./output/objc test/js-source/*.js", 18 | "android-polyfill": "babel-node ./bin/mantify runtime/android/manticore/src/main/res/raw/polyfill_pack.js runtime/android/js/polyfill.js", 19 | "android-testjs": "babel-node -- ./bin/manticore-gen -q ./runtime/android/templates ./runtime/android/manticore/src/test/java/com/paypal/manticore/ test/js-source/*.js", 20 | "win-polyfill": "babel-node ./bin/mantify runtime/win/generated/polyfill.clearscript.pack.js runtime/win/js/polyfill.clearscript.js && babel-node ./bin/mantify runtime/win/generated/polyfill.jint.pack.js runtime/win/js/polyfill.jint.js", 21 | "win-testjs": "mkdirp runtime/win/generated/jint runtime/win/generated/ClearScript && babel-node -- ./bin/manticore-gen -q ./runtime/win/templates/jint runtime/win/generated/jint test/js-source/*.js && babel-node -- ./bin/manticore-gen -q ./runtime/win/templates/clearscript runtime/win/generated/ClearScript test/js-source/*.js", 22 | "postinstall": "babel index.js --out-dir build && babel lib --out-dir build", 23 | "dev": "npm run build-testjs && npm run objc-polyfill && npm run android-polyfill && npm run win-polyfill && npm run objc-testjs && npm run android-testjs && npm run win-testjs" 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "https://github.com/paypal/manticore-native" 28 | }, 29 | "keywords": [ 30 | "nodejs", 31 | "mobile", 32 | "javascript", 33 | "sdk" 34 | ], 35 | "author": "PayPal", 36 | "license": "Apache-2.0", 37 | "dependencies": { 38 | "acorn-es7-plugin": "^1.0.12", 39 | "ansidiff": "^1.0.0", 40 | "babel-cli": "^6.6.5", 41 | "babel-loader": "^6.0.0", 42 | "babel-plugin-syntax-async-functions": "^6.5.0", 43 | "babel-plugin-transform-regenerator": "^6.6.5", 44 | "babel-polyfill": "^6.7.4", 45 | "babel-preset-es2015": "^6.6.0", 46 | "babel-regenerator-runtime": "^6.5.0", 47 | "babelify": "^7.2.0", 48 | "bluebird": "^3.3.4", 49 | "browserify": "^13.0.0", 50 | "docchi": "^0.12.0", 51 | "dustjs-helpers": "^1.7.3", 52 | "dustjs-linkedin": "^2.7.2", 53 | "fs-extra": "^0.26.7", 54 | "glob": "^7.0.3", 55 | "lodash": "^4.6.1", 56 | "mkdirp": "^0.5.1", 57 | "node-fetch": "^1.4.1", 58 | "uglifyify": "^3.0.1", 59 | "yaku": "^0.14.1" 60 | }, 61 | "devDependencies": { 62 | "babel-eslint": "^6.0.0", 63 | "eslint": "^2.5.1", 64 | "eslint-config-airbnb": "^6.2.0", 65 | "eslint-plugin-react": "^4.2.3", 66 | "tape": "^4.5.1" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /runtime/README.md: -------------------------------------------------------------------------------- 1 | Manticore Native Runtimes 2 | ========================= 3 | 4 | Manticore's native runtime libraries handle the boilerplate code required to move data into and out of a JavaScript engine. 5 | 6 | Additionally, they provide *polyfill* -- ensuring that the "standard" functions one would expect in a JavaScript engine 7 | are actually present. The necessary functionality is built on the native side, then exposed to the JavaScript side by 8 | a set of polyfill files. 9 | 10 | 11 | Available Runtimes 12 | ------------------ 13 | 14 | * [C#](win/) - Windows and Windows Mobile (Jint and ClearScript engines) 15 | * [Java](android/) - Android 16 | * [Objective-C](objc/) - iOS and MacOS 17 | -------------------------------------------------------------------------------- /runtime/android/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | local.properties 3 | .idea/** 4 | .DS_Store 5 | *.iml 6 | build 7 | 8 | -------------------------------------------------------------------------------- /runtime/android/.npmignore: -------------------------------------------------------------------------------- 1 | build.gradle 2 | gradle 3 | gradle.properties 4 | gradlew 5 | gradlew.bat 6 | manticore 7 | settings.gradle 8 | -------------------------------------------------------------------------------- /runtime/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.1.0' 9 | } 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | jcenter() 15 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /runtime/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 | # 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 -------------------------------------------------------------------------------- /runtime/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /runtime/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 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.10-all.zip 7 | -------------------------------------------------------------------------------- /runtime/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /runtime/android/js/polyfill.js: -------------------------------------------------------------------------------- 1 | const g = global; 2 | const m = g.manticore; 3 | 4 | // Setup the JavaScriptCore runtime to look like what Manticore requires (bind native functions) 5 | m._log('info', 'Loading android polyfill'); 6 | 7 | require('core-js/es6/symbol'); 8 | require('core-js/es6/set'); 9 | require('core-js/fn/string/includes'); 10 | require('core-js/fn/object/is'); 11 | require('core-js/fn/object/assign'); 12 | require('core-js/fn/array/of'); 13 | require('core-js/fn/array/from'); 14 | require('core-js/fn/array/find'); 15 | require('core-js/fn/array/find-index'); 16 | require('core-js/fn/symbol/iterator'); 17 | 18 | require('../../common/console'); 19 | require('../../common/promise'); 20 | require('../../common/timer'); 21 | require('../../common/fetch'); 22 | 23 | m.construct = function _construct(C, args) { 24 | function F() { 25 | return C.apply(this, args); 26 | } 27 | 28 | F.prototype = C.prototype; 29 | return new F(); 30 | }; 31 | 32 | m.newDate = function _newDate(t) { 33 | return new Date(t); 34 | }; 35 | 36 | m._log('info', 'Loaded android polyfill'); 37 | -------------------------------------------------------------------------------- /runtime/android/manticore/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | local.properties 3 | .DS_Store 4 | src/test/java/com/paypal/manticore/SDKTest.java 5 | src/test/java/com/paypal/manticore/SDKTestDefault.java 6 | src/test/java/com/paypal/manticore/SDKTestDefaultSubclass.java 7 | src/test/java/com/paypal/manticore/SDKTestStatuses.java 8 | src/test/java/com/paypal/manticore/model.json 9 | -------------------------------------------------------------------------------- /runtime/android/manticore/build.gradle: -------------------------------------------------------------------------------- 1 | 2 | apply plugin: 'com.android.library' 3 | 4 | repositories { 5 | mavenCentral() 6 | } 7 | 8 | android { 9 | compileSdkVersion 23 10 | buildToolsVersion '23.0.2' 11 | 12 | defaultConfig { 13 | minSdkVersion 10 14 | targetSdkVersion 23 15 | versionCode 2 16 | versionName "1.0.1" 17 | } 18 | buildTypes { 19 | release { 20 | minifyEnabled false 21 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 22 | } 23 | } 24 | 25 | libraryVariants.all { variant -> 26 | variant.outputs.each { output -> 27 | output.outputFile = new File( 28 | output.outputFile.parent, 29 | output.outputFile.name.replace(".aar", "-${defaultConfig.versionName}.aar")) 30 | } 31 | } 32 | 33 | sourceSets { 34 | debug.setRoot('build-types/debug') 35 | release.setRoot('build-types/release') 36 | } 37 | 38 | lintOptions { 39 | abortOnError false 40 | } 41 | } 42 | 43 | dependencies { 44 | 45 | // When updating this, you MUST keep the testCompile JAR's in sync or test will fail 46 | compile 'com.eclipsesource.j2v8:j2v8:3.1.6@aar' 47 | testCompile fileTree(dir: 'testLibs', include: ['*.jar']) 48 | 49 | compile 'com.squareup.okhttp3:okhttp:3.2.0' 50 | testCompile 'junit:junit:4.12' 51 | testCompile 'org.mockito:mockito-core:2.0.5-beta' 52 | testCompile('org.powermock:powermock-api-mockito:1.6.2') { 53 | exclude module: 'hamcrest-core' 54 | exclude module: 'objenesis' 55 | } 56 | testCompile('org.powermock:powermock-module-junit4:1.6.2') { 57 | exclude module: 'hamcrest-core' 58 | exclude module: 'objenesis' 59 | } 60 | } 61 | 62 | task copyTestResources(type: Copy) { 63 | from '../../../output/index.pack.js' 64 | into 'src/test/resources/' 65 | } 66 | 67 | preBuild.dependsOn copyTestResources -------------------------------------------------------------------------------- /runtime/android/manticore/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/mmetral/dev/android/android-sdk-macosx/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 | -------------------------------------------------------------------------------- /runtime/android/manticore/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /runtime/android/manticore/src/main/java/com/paypal/manticore/FetchResponse.java: -------------------------------------------------------------------------------- 1 | package com.paypal.manticore; 2 | 3 | import java.io.IOException; 4 | import java.net.ProtocolException; 5 | 6 | import android.util.Base64; 7 | import com.eclipsesource.v8.V8Object; 8 | import com.eclipsesource.v8.V8RuntimeException; 9 | import com.eclipsesource.v8.V8Value; 10 | import okhttp3.Response; 11 | 12 | /** 13 | * Created by mmetral on 3/31/16. 14 | */ 15 | public class FetchResponse 16 | { 17 | ManticoreEngine _engine; 18 | Response _response; 19 | V8Object _jsThis; 20 | 21 | FetchResponse(ManticoreEngine engine, Response response) { 22 | this._engine = engine; 23 | this._response = response; 24 | this._jsThis = _engine.createJsObject(); 25 | this._jsThis.add("status", response.code()); 26 | V8Object headers = engine.createJsObject(); 27 | for (String hdr : response.headers().names()) 28 | { 29 | headers.add(hdr, response.header(hdr).toString()); 30 | } 31 | this._jsThis.add("headers", headers); 32 | this._jsThis.registerJavaMethod(this, "json", "json", null); 33 | this._jsThis.registerJavaMethod(this, "text", "text", null); 34 | this._jsThis.registerJavaMethod(this, "body", "body", null); 35 | } 36 | 37 | public V8Object getJSInterface() { 38 | return _jsThis; 39 | } 40 | 41 | public String body() { 42 | try 43 | { 44 | if (_response.body().contentLength() == 0) { 45 | return null; 46 | } 47 | 48 | return Base64.encodeToString(_response.body().bytes(), Base64.NO_WRAP); 49 | } 50 | catch (IOException io) { 51 | return null; 52 | } 53 | catch (V8RuntimeException pe) 54 | { 55 | return null; 56 | } 57 | } 58 | 59 | public String text() { 60 | try 61 | { 62 | if (_response.body().contentLength() == 0) { 63 | return null; 64 | } 65 | 66 | return _response.body().string(); 67 | } 68 | catch (IOException io) { 69 | return null; 70 | } 71 | catch (V8RuntimeException pe) 72 | { 73 | return null; 74 | } 75 | } 76 | 77 | public V8Object json() { 78 | try 79 | { 80 | String body = this.text(); 81 | if (body == null || body.length() == 0) 82 | { 83 | return null; 84 | } 85 | else 86 | { 87 | try 88 | { 89 | V8Object jsonBody = _engine.v8.getObject("JSON").executeObjectFunction("parse", _engine.createJsArray().push(body)); 90 | return jsonBody; 91 | } 92 | catch (Exception x) 93 | { 94 | // Tough call here, but for now I think returning null is better, 95 | // though we may want to also store the body. Ok fine, I was just being lazy. 96 | return null; 97 | } 98 | } 99 | } 100 | catch (V8RuntimeException pe) 101 | { 102 | return null; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /runtime/android/manticore/src/main/java/com/paypal/manticore/IManticoreObserver.java: -------------------------------------------------------------------------------- 1 | package com.paypal.manticore; 2 | 3 | /** 4 | * Exposing these elements of the loading cycle allows you to inject your own code 5 | * at appropriate points. Typically this is used to expose new native functionality 6 | * to the javascript. Note that if you load script, your own will/didLoadScript event 7 | * will get called, so make sure to not infinitely do so. 8 | */ 9 | public interface IManticoreObserver 10 | { 11 | public void willLoadPolyfill(ManticoreEngine engine); 12 | public void didLoadPolyfill(ManticoreEngine engine); 13 | public void willLoadScript(ManticoreEngine engine, String script, String name); 14 | public void didLoadScript(ManticoreEngine engine, String script, String name); 15 | } 16 | -------------------------------------------------------------------------------- /runtime/android/manticore/src/main/java/com/paypal/manticore/ManticoreException.java: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | package com.paypal.manticore; 16 | 17 | /** 18 | * You will likely want to make your own exception class and it need not extend from this one. You just 19 | * need to be able to create a Java exception from a Javascript error object. 20 | */ 21 | public class ManticoreException extends Exception 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /runtime/android/manticore/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Manticore 4 | -------------------------------------------------------------------------------- /runtime/android/manticore/testLibs/j2v8_linux_x86_64-3.1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/android/manticore/testLibs/j2v8_linux_x86_64-3.1.6.jar -------------------------------------------------------------------------------- /runtime/android/manticore/testLibs/j2v8_macosx_x86_64-3.1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/android/manticore/testLibs/j2v8_macosx_x86_64-3.1.6.jar -------------------------------------------------------------------------------- /runtime/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':manticore' 2 | -------------------------------------------------------------------------------- /runtime/android/templates/asyncCbDecl.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * Completion callback for {name} 3 | */ 4 | public interface {@firstCap}{name}{/firstCap}Callback { 5 | void done({@type}error{/type}{?returns} error, {@type}{returns.type}{/type} result{/returns}); 6 | } 7 | 8 | /** 9 | * Generate the javascript function for a callback or event 10 | */ 11 | private static V8Object wrapPromise(final {@firstCap}{name}{/firstCap}Callback javaInterface) { 12 | return getEngine().getExecutor().run(new Callable() {~lb} 13 | @Override public V8Object call() throws Exception { 14 | V8Object _jso = getEngine().createJsObject(); 15 | _jso.registerJavaMethod(new JavaVoidCallback() { 16 | @Override 17 | public void invoke(V8Object jsThis, V8Array args) 18 | { 19 | {@type}error{/type} error = null; 20 | {?returns}{@type}{returns.type}{/type} result = {>defaultValue target="{type"/};{/returns} 21 | if (args.length() > 0 && args.getType(0) != V8Value.UNDEFINED && args.getType(0) != V8Value.NULL) { 22 | V8Object jsError = args.getObject(0); 23 | error = {>toNative target="error" arg="jsError"/}; 24 | } 25 | if (args.length() > 1 && args.getType(1) != V8Value.UNDEFINED) { 26 | {>fnReturnType target="{returns.type}"/} jsResult = args.get{>fnType target="{type}"/}(1); 27 | result = {>toNative target="{returns.type}" arg="jsResult"/}; 28 | } 29 | javaInterface.done(error, result); 30 | } 31 | }, "_"); 32 | V8Object fn = _jso.getObject("_"); 33 | _jso.release(); 34 | return fn; 35 | } 36 | }); 37 | } 38 | -------------------------------------------------------------------------------- /runtime/android/templates/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "typeMap": { 3 | "string": "String", 4 | "decimal": "BigDecimal", 5 | "bool": "Boolean", 6 | "int": "Integer", 7 | "object": "Map", 8 | "error": "ManticoreException" 9 | }, 10 | "arrayType": "List<%s>", 11 | "arrayIsTyped": true, 12 | "callbackSuffix": "Callback", 13 | "innerCallbacksAndEvents": true, 14 | "customConverters": [ 15 | "object", 16 | "decimal", 17 | "Date" 18 | ], 19 | "nativeConverters": { 20 | "bool": "Boolean", 21 | "string": "String", 22 | "int": "Integer" 23 | }, 24 | "extensions": { 25 | "impl": ".java", 26 | "enum": ".java", 27 | "class": ".java" 28 | }, 29 | "typePrefix": "", 30 | "namespace": "com.paypal.manticore", 31 | "baseClass": "JsBackedObject" 32 | } -------------------------------------------------------------------------------- /runtime/android/templates/defaultValue.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}null{:enum}{@type}{target}{/type}.fromInt(0){:builtin}{@select key="{target}"}{@eq value="int"}0{/eq}{@none}null{/none}{/select}{:custom}null{:array}null{/converter} -------------------------------------------------------------------------------- /runtime/android/templates/enum.dust: -------------------------------------------------------------------------------- 1 | package {namespace}; 2 | 3 | /** 4 | * {packedName}.java 5 | * 6 | * DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED AND SHOULD NOT BE CHECKED IN. 7 | * {@sourceDocument/} 8 | * 9 | * {copyright} 10 | */ 11 | public enum {packedName} { 12 | {#values} {name}({value}){@sep},{/sep}{@math key=$idx method="add" operand="1"}{@eq value=$len};{/eq}{/math} 13 | {/values} 14 | 15 | private final {type} value; 16 | 17 | private {packedName}({type} value) { 18 | this.value = value; 19 | } 20 | 21 | public {type} getValue() { 22 | return this.value; 23 | } 24 | 25 | public static {packedName} fromInt(int value) { 26 | switch(value) { 27 | {#values}case {$idx}: 28 | return {name}; 29 | {/values} 30 | } 31 | return null; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /runtime/android/templates/event.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * Add an observer for the {name} event 3 | */ 4 | public void add{@firstCap}{name}{/firstCap}Observer(final {@firstCap}{name}{/firstCap}Observer observer) { 5 | if ({name}Handlers == null) { 6 | {name}Handlers = new HashMap<{@firstCap}{name}{/firstCap}Observer,V8Object>(); 7 | } else if ({name}Handlers.containsKey(observer)) { 8 | throw new IllegalArgumentException("That observer has already been added to the {name} event."); 9 | } 10 | final V8Object wrapped = wrapJavaFn(observer); 11 | getEngine().getExecutor().run(new Runnable() 12 | {~lb} 13 | @Override public void run() { 14 | {packedName}.this.impl.executeVoidFunction("on", getEngine().createJsArray().push("{name}").push(wrapped)); 15 | } 16 | }); 17 | {name}Handlers.put(observer,wrapped); 18 | } 19 | 20 | /** 21 | * Remove an observer for the {name} event 22 | */ 23 | public void remove{@firstCap}{name}{/firstCap}Observer({@firstCap}{name}{/firstCap}Observer observer) { 24 | if ({name}Handlers != null && {name}Handlers.containsKey(observer)) { 25 | final V8Object ex = {name}Handlers.get(observer); 26 | getEngine().getExecutor().run(new Runnable() 27 | {~lb} 28 | @Override public void run() { 29 | {packedName}.this.impl.executeVoidFunction("removeListener", getEngine().createJsArray().push("{name}").push(ex)); 30 | ex.release(); 31 | } 32 | }); 33 | {name}Handlers.remove(observer); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /runtime/android/templates/field.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * {@lineify indent=3}{description|s}{/lineify} 3 | */ 4 | public {@type}{type}{/type} get{@firstCap}{name}{/firstCap}() { 5 | return getEngine().getExecutor().run(new Callable<{@type}{type}{/type}>() {~lb} 6 | @Override public {@type}{type}{/type} call() { 7 | int _jsType = {packedName}.this.impl.getType("{name}"); 8 | if (_jsType == V8Value.UNDEFINED || _jsType == V8Value.NULL) { 9 | return {>defaultValue target="{type}"/}; 10 | } 11 | {>fnReturnType target="{type}"/} _{name} = {packedName}.this.impl.get{>fnType target="{type}"/}("{name}"); 12 | return {>toNative target="{type}" arg="_{name}"/}; 13 | } 14 | }); 15 | } 16 | {^readonly} 17 | /** 18 | * {@lineify indent=3}{description|s}{/lineify} 19 | */ 20 | public void set{@firstCap}{name}{/firstCap}(final {@type}{type}{/type} value) { 21 | getEngine().getExecutor().run(new Runnable() 22 | {~lb} 23 | @Override public void run() { 24 | {packedName}.this.impl.add("{name}", {>toJs target="{type}" arg="value"/}); 25 | } 26 | }); 27 | } 28 | {/readonly} 29 | -------------------------------------------------------------------------------- /runtime/android/templates/fnReturnType.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}V8Object{:enum}int{:builtin}{converter}{:custom}{@select key="{type}"}{@eq value="long"}String{/eq}{@none}V8Object{/none}{/select}{:array}V8Array{/converter} -------------------------------------------------------------------------------- /runtime/android/templates/fnType.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}Object{:enum}Integer{:builtin}{converter}{:custom}Object{:array}Array{/converter} -------------------------------------------------------------------------------- /runtime/android/templates/ifaceDecl.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * {@lineify indent=3}{description|s}{/lineify} 3 | */ 4 | public interface {@firstCap}{name}{/firstCap}{suffix} { 5 | {?returns}{@type}{returns.type}{/type}{:else}void{/returns} {name}({#args}{@type}{type}{/type} {name}{@sep}, {/sep}{/args}); 6 | } 7 | -------------------------------------------------------------------------------- /runtime/android/templates/method.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * {@lineify indent=3}{description|s}{/lineify} 3 | */ 4 | public{?static} static{/static} {?async}void{:else}{^returns}void{:else}{@type}{returns.type}{/type}{/returns}{/async} {name}({#args}final {@type}{type}{/type} {name}{@sep}, {/sep}{/args}{@comment} 5 | ***** async gets an extra argument tossed onto it 6 | {/comment}{?async}{?args}, {/args}final {@firstCap}{name}{/firstCap}Callback callback{/async}) { 7 | {^async}{?returns}return {/returns}{/async}getEngine().getExecutor().run({@comment} 8 | 9 | {/comment}new {?async}Runnable{:else}{?returns}Callable<{@type}{returns.type}{/type}>{:else}Runnable{/returns}{/async}() {~lb} 10 | @Override public {?async}void run() {{:else}{?returns}{@type}{returns.type}{/type} call() {{:else}void run() {{/returns}{/async} 11 | V8Array args = {?args}getEngine().createJsArray(){#args} 12 | .push({>toJs target="{type}" arg="{name}"/}){/args}{:else}getEngine().getEmptyArray(){/args}; 13 | V8Object objectToExecuteOn = {?static}getEngine().getJSClass("{packedName}"){:else}{packedName}.this.impl{/static}; 14 | {?async}V8Object promise = {:else}{?returns}{>fnReturnType target="{returns.type}"/} retVal = {/returns}{/async}objectToExecuteOn.execute{?returns}{>fnType target="{returns.type}"/}{:else}Void{/returns}Function("{name}", args); 15 | {?async}getEngine().resolvePromise(promise, wrapPromise(callback));{:else}{@comment} 16 | {/comment}{?returns}return {>toNative target="{returns.type}" arg="retVal"/};{/returns}{/async} 17 | } 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /runtime/android/templates/toJs.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}{@comment} 2 | // Callbacks are wrapped in a generated function and passed to JS 3 | {/comment}{@isCallback type="{target}"}wrapJavaFn({arg}){:else}{@comment} 4 | // The runtime converter function will check the type of arg and do the right thing 5 | {/comment}getEngine().getConverter().asJs({arg}){/isCallback}{:custom}{@comment} 6 | // Custom converters (such as for decimal) adjust types based on the contract between native and JS 7 | {/comment}getEngine().getConverter().asJs{@firstCap}{target}{/firstCap}({arg}){:builtin}{@comment} 8 | // Built in types are passed as is in j2v8 9 | {/comment}{arg}{:enum}{@comment} 10 | // Enums are just ints as far as our JS is concerned 11 | {/comment}{arg}.getValue(){:array}{@comment} 12 | // Arrays. Oh vey, those are hard. 13 | {/comment}getEngine().getConverter().toJsArray({arg}, new IManticoreTypeConverter.JsElementConverter<{@type}{elementType}{/type}>() { 14 | @Override 15 | public void push(V8Array dest, {@type}{elementType}{/type} nativeValue) { 16 | dest.push({>toJs target="{elementType}" arg="nativeValue"/}); 17 | } 18 | }){/converter} -------------------------------------------------------------------------------- /runtime/android/templates/toNative.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}{@comment} 2 | // First, if it's one of our types or one not explicitly configured, call the runtime converter 3 | {/comment}getEngine().getConverter().asNative({arg}, {@type}{target}{/type}.class){:enum}{@comment} 4 | // If it's an enum, pass it back and forth as an int. So here we use fromInt to make the enum instance 5 | {/comment}{@type}{target}{/type}.fromInt((int) {arg}){:custom}{@comment} 6 | // Custom converters have a name convention, let the compiler typing handle the rest 7 | {/comment}getEngine().getConverter().asNative{@firstCap}{target}{/firstCap}({arg}){:builtin}{@comment} 8 | // Built in types are passed as is in j2v8 9 | {/comment}{arg}{:array}{@comment} 10 | // Arrays. Oh vey, those are hard. 11 | {/comment}getEngine().getConverter().toNativeArray({arg}, new IManticoreTypeConverter.NativeElementConverter<{@type}{elementType}{/type}>() { 12 | @Override 13 | public {@type}{elementType}{/type} convert(Object jsValue) { 14 | return ({@type}{elementType}{/type}) {>toNative target="{elementType}" arg="jsValue"/}; 15 | } 16 | }){/converter} -------------------------------------------------------------------------------- /runtime/android/templates/toString.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns a string representing the serialized state of the {packedName} object 3 | */ 4 | public String toString() { 5 | return getEngine().getExecutor().run(new Callable() {~lb} 6 | @Override public String call() { 7 | V8Object objectToExecuteOn = getEngine().getJsObject("JSON"); 8 | V8Object objectStringify = {packedName}.this.impl; 9 | V8Array args = getEngine().createJsArray().push(objectStringify); 10 | String retVal = objectToExecuteOn.executeStringFunction("stringify", args); 11 | return retVal; 12 | } 13 | }); 14 | } 15 | -------------------------------------------------------------------------------- /runtime/android/templates/wrapDecl.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * Generate the javascript function for a callback or event 3 | */ 4 | private static V8Object wrapJavaFn(final {@firstCap}{name}{/firstCap}{suffix} javaInterface) { 5 | return getEngine().getExecutor().run(new Callable() {~lb} 6 | @Override public V8Object call() throws Exception { 7 | V8Object _jso = getEngine().createJsObject(); 8 | _jso.registerJavaMethod(new Java{^returns}Void{/returns}Callback() { 9 | @Override 10 | public {?returns}{@type}{returns.type}{/type}{:else}void{/returns} invoke(V8Object jsThis, V8Array args) 11 | { 12 | {#args}{>fnReturnType target="{type}"/} js{name} = {>defaultValue target="{type}"/}; 13 | {@type}{type}{/type} _{name} = {>defaultValue target="{type}"/}; 14 | if (args.length() > {$idx} && args.getType({$idx}) != V8Value.UNDEFINED) { 15 | js{name} = args.get{>fnType target="{type}"/}({$idx}); 16 | _{name} = {>toNative target="{type}" arg="js{name}"/}; 17 | } 18 | 19 | {/args} 20 | {?returns}{@type}{returns.type}{/type} retVal = {/returns}javaInterface.{name}({#args}_{name}{@sep}, {/sep}{/args}); 21 | {?returns}return {>toJs target="{returns.type}" arg="retVal"/};{/returns} 22 | } 23 | }, "_"); 24 | V8Object fn = _jso.getObject("_"); 25 | _jso.release(); 26 | return fn; 27 | } 28 | }); 29 | } 30 | -------------------------------------------------------------------------------- /runtime/common/console.js: -------------------------------------------------------------------------------- 1 | function logger(level, args) { 2 | global.manticore._log(level, args.join(' ')); 3 | } 4 | 5 | global.console = { 6 | log(...args) { 7 | logger('debug', args); 8 | }, 9 | warn(...args) { 10 | logger('warn', args); 11 | }, 12 | error(...args) { 13 | logger('error', args); 14 | }, 15 | }; 16 | -------------------------------------------------------------------------------- /runtime/common/fetch.js: -------------------------------------------------------------------------------- 1 | // Inspired by 2 | // https://github.com/bitinn/node-fetch 3 | import Request from './fetch/Request'; 4 | import Response from './fetch/Response'; 5 | 6 | global.fetch = function fetcher(url, options) { 7 | return new Promise((accept, reject) => { 8 | const rq = new Request(url, options); 9 | global.manticore._fetch(rq, 10 | (err, native) => (err ? reject(err) : accept(new Response(native, rq)))); 11 | }); 12 | }; 13 | -------------------------------------------------------------------------------- /runtime/common/fetch/Body.js: -------------------------------------------------------------------------------- 1 | /** 2 | * This serves as both the request and response bodies, and this is only used in native 3 | * platforms (node-fetch is used on node, and Chrome uses fetch for reals). 4 | */ 5 | export default class Body { 6 | constructor(body) { 7 | this._body = body; 8 | } 9 | 10 | /** 11 | * Called by manticore to get the request body as a string 12 | * @returns either base64 or regular string depending on isBase64 13 | */ 14 | nativeBody() { 15 | return this._body; 16 | } 17 | 18 | async json() { 19 | return this._body.json(); 20 | } 21 | 22 | async text() { 23 | return this._body.text(); 24 | } 25 | 26 | async body() { 27 | return this._body.body(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /runtime/common/fetch/Headers.js: -------------------------------------------------------------------------------- 1 | export default class Headers { 2 | constructor(headers) { 3 | this._headers = {}; 4 | for (const prop of Object.getOwnPropertyNames(headers)) { 5 | const typ = typeof headers[prop]; 6 | const v = headers[prop]; 7 | if (typ === 'string') { 8 | this.set(prop, headers[prop]); 9 | } else if (typ === 'number' && !isNaN(v)) { 10 | this.set(prop, headers[prop].toString()); 11 | } else if (v instanceof Array) { 12 | for (const item of v) { 13 | this.append(prop, item.toString()); 14 | } 15 | } 16 | } 17 | } 18 | 19 | get(name) { 20 | const list = this._headers[name.toLowerCase()]; 21 | return list ? list[0] : null; 22 | } 23 | 24 | getAll(name) { 25 | if (!this.has(name)) { 26 | return []; 27 | } 28 | return this._headers[name.toLowerCase()]; 29 | } 30 | 31 | forEach(callback, thisArg) { 32 | for (const name of Object.getOwnPropertyNames(this._headers)) { 33 | for (const value of this._headers[name]) { 34 | callback.call(thisArg, value, name, this); 35 | } 36 | } 37 | } 38 | 39 | set(name, value) { 40 | this._headers[name.toLowerCase()] = [value]; 41 | } 42 | 43 | append(name, value) { 44 | if (!this.has(name)) { 45 | this.set(name, value); 46 | return; 47 | } 48 | this._headers[name.toLowerCase()].push(value); 49 | } 50 | 51 | has(name) { 52 | return this._headers.hasOwnProperty(name.toLowerCase()); 53 | } 54 | 55 | delete(name) { 56 | delete this._headers[name.toLowerCase()]; 57 | } 58 | 59 | raw() { 60 | return this._headers; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /runtime/common/fetch/Request.js: -------------------------------------------------------------------------------- 1 | import Body from './Body'; 2 | import Headers from './Headers'; 3 | 4 | export default class Request extends Body { 5 | /** 6 | * Request class 7 | * 8 | * @param Mixed input Url or Request instance 9 | * @param Object init Custom options 10 | * @return Void 11 | */ 12 | constructor(input, init) { 13 | let url; 14 | let _input = input; 15 | const _init = init || {}; 16 | 17 | if (!(input instanceof Request)) { 18 | url = input; 19 | _input = {}; 20 | } else { 21 | url = input.url; 22 | } 23 | // Bypass URL validation. Don't screw it up, caller. 24 | 25 | super(_init.body || _input.body, { 26 | timeout: _init.timeout || _input.timeout || 0, 27 | size: _init.size || _input.size || 0, 28 | }); 29 | 30 | this.isBase64 = !!(_init.isBase64 || _input.isBase64); 31 | this.method = _init.method || _input.method || 'GET'; 32 | this.headers = new Headers(_init.headers || _input.headers || {}); 33 | this.url = url; 34 | } 35 | 36 | clone() { 37 | return new Request(this); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /runtime/common/fetch/Response.js: -------------------------------------------------------------------------------- 1 | import Body from './Body'; 2 | import Headers from './Headers'; 3 | 4 | export default class Response extends Body { 5 | constructor(native, request) { 6 | super(native, {}); 7 | this.url = request.url; 8 | this.status = native.status; 9 | this.headers = new Headers(native.headers); 10 | this.ok = this.status >= 200 && this.status < 300; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /runtime/common/promise.js: -------------------------------------------------------------------------------- 1 | const g = global; 2 | g.Promise = require('yaku'); 3 | g.regeneratorRuntime = require('babel-regenerator-runtime'); 4 | 5 | g.manticore.asCallback = function asCallback(p, c) { 6 | p.then((r) => c(null, r)).catch((e) => c(e, null)); 7 | }; 8 | -------------------------------------------------------------------------------- /runtime/common/timer.js: -------------------------------------------------------------------------------- 1 | const g = global; 2 | const m = g.manticore; 3 | 4 | // Some VMs do not like argument count mismatch, so we fix it up here. 5 | g.setTimeout = g.setTimeout || ((fn, t) => m._setTimeout(fn, t || 0)); 6 | -------------------------------------------------------------------------------- /runtime/objc/.gitignore: -------------------------------------------------------------------------------- 1 | xcuserdata 2 | 3 | js/polyfill.pack.js 4 | Pods 5 | Manticore.xcworkspace -------------------------------------------------------------------------------- /runtime/objc/.npmignore: -------------------------------------------------------------------------------- 1 | Common 2 | Manticore 3 | Manticore.xcworkspace 4 | ManticoreContainer 5 | Podfile 6 | Podfile.lock 7 | Pods 8 | xcodebuild-osx.log 9 | xcodebuild9.log 10 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreEngine+Private.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import 17 | #import "PPManticoreEngine.h" 18 | #import "PPManticoreNativeInterface.h" 19 | 20 | 21 | 22 | static NSString *WILL_LOAD_POLYFILL_NOTIFICATION = @"Manticore.WillLoadPolyfill"; 23 | static NSString *DID_LOAD_POLYFILL_NOTIFICATION = @"Manticore.DidLoadPolyfill"; 24 | static NSString *WILL_LOAD_SCRIPT_NOTIFICATION = @"Manticore.WillLoadScript"; 25 | static NSString *DID_LOAD_SCRIPT_NOTIFICATION = @"Manticore.DidLoadScript"; 26 | 27 | #define SCRIPT_NAME_KEY @"ScriptName" 28 | #define SCRIPT_KEY @"Script" 29 | 30 | @interface PPManticoreEngine (Private) 31 | 32 | @property (nonatomic,strong) JSContext *jsEngine; 33 | @property (nonatomic,strong) JSValue *exports; 34 | @property (nonatomic,strong) PPManticoreNativeInterface *native; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreEngine.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import 17 | #import 18 | 19 | #import "PPManticoreTypeConverter.h" 20 | #import "PPManticoreEventHolder.h" 21 | #import "PPManticorePlugin.h" 22 | 23 | @interface PPManticoreEngine : NSObject 24 | 25 | @property (nonatomic,strong,nonnull) PPManticoreTypeConverter *converter; 26 | @property (nonatomic,readonly,nonnull) JSContext *context; 27 | @property (nonatomic,readonly,nonnull) JSGlobalContextRef globalContext; 28 | 29 | - (void)loadScript:(NSString* _Nonnull)script withName:(NSString* _Nullable)name; 30 | 31 | -(JSValue* _Nullable)createJSObject:(NSString* _Nonnull)jsClassName withArguments:(NSArray* _Nullable)args; 32 | -(id _Nullable)attachNativeObject:(JSValue* _Nonnull)value ofType:(Class _Nonnull)nativeType; 33 | -(id _Nullable)resolveJSObject:(id _Nullable)object ofType:(Class _Nonnull)nativeType; 34 | -(JSValue* _Nullable)resolveJSClass:(NSString* _Nonnull)jsClassName; 35 | -(void)resolvePromise:(JSValue* _Nonnull)promise toCallback:(void (^_Nonnull)(JSValue* _Nullable,JSValue* _Nullable))callback; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreError.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import 17 | 18 | @interface PPManticoreError : NSError 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreError.m: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import "PPManticoreError.h" 17 | #import "PPManticoreJSBackedObject.h" 18 | 19 | @interface PPManticoreError () < 20 | PPManticoreNativeObjectProtocol 21 | > 22 | @property (nonatomic,strong) JSValue *impl; 23 | @end 24 | 25 | @implementation PPManticoreError 26 | -(id)initFromJavascript:(JSValue *)value { 27 | if ((self = [super initWithDomain:[value[@"domain"] toString] 28 | code:[value[@"code"] toInt32] 29 | userInfo:@{ 30 | NSLocalizedDescriptionKey: [value[@"message"] toString] 31 | }])) { 32 | } 33 | return self; 34 | } 35 | 36 | +(PPManticoreEngine *)engine { 37 | return [PPManticoreJSBackedObject engine]; 38 | } 39 | 40 | +(Class)nativeClassForObject:(JSValue *)value { 41 | return [PPManticoreError class]; 42 | } 43 | @end 44 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreEventHolder.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import 17 | 18 | /** 19 | * This class makes event listeners work. It stores the 'translated' block function that 20 | * will be sent to JS for add/remove 21 | */ 22 | @interface PPManticoreEventHolder : NSObject 23 | @property (nonatomic,copy) id block; 24 | @end 25 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreEventHolder.m: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import "PPManticoreEventHolder.h" 17 | 18 | @implementation PPManticoreEventHolder 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreJSBackedObject.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import 17 | #import "PPManticoreNativeInterface.h" 18 | 19 | @interface PPManticoreJSBackedObject : NSObject < 20 | PPManticoreNativeObjectProtocol 21 | > 22 | 23 | @property (nonatomic,strong,nonnull) JSValue *impl; 24 | 25 | - (instancetype _Nullable)initFromJavascript:(JSValue* _Nonnull)value; 26 | 27 | + (void)setManticoreEngine:(PPManticoreEngine* _Nullable)engine; 28 | + (PPManticoreEngine* _Nullable)engine; 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreJSBackedObject.m: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import "PPManticoreJSBackedObject.h" 17 | 18 | @implementation PPManticoreJSBackedObject 19 | + (Class)nativeClassForObject:(JSValue *)value { 20 | return self; 21 | } 22 | 23 | - (instancetype)initFromJavascript:(JSValue *)value { 24 | if ((self = [super init])) { 25 | self.impl = value; 26 | } 27 | return self; 28 | } 29 | 30 | static PPManticoreEngine *_engine; 31 | + (void)setManticoreEngine:(PPManticoreEngine *)engine { 32 | _engine = engine; 33 | } 34 | 35 | + (PPManticoreEngine *)engine { 36 | return _engine; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticorePlugin.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import 17 | 18 | @class PPManticoreEngine; 19 | 20 | /** 21 | * Exposing these elements of the loading cycle allows you to inject your own code 22 | * at appropriate points. Typically this is used to expose new native functionality 23 | * to the javascript. Note that if you load script, your own will/didLoadScript event 24 | * will get called, so make sure to not infinitely do so. 25 | */ 26 | @protocol PPManticorePluginDelegate 27 | @optional 28 | -(void)willLoadPolyfill:(PPManticoreEngine* _Nonnull) engine; 29 | -(void)didLoadPolyfill:(PPManticoreEngine* _Nonnull) engine; 30 | 31 | -(void)engine:(PPManticoreEngine* _Nonnull) engine willLoadScript:(NSString* _Nonnull) script withName:(NSString* _Nullable)name; 32 | -(void)engine:(PPManticoreEngine* _Nonnull) engine didLoadScript:(NSString* _Nonnull) script withName:(NSString* _Nullable)name; 33 | @end 34 | 35 | /** 36 | * This class basically exists to give you a pleasant delegate interface to a 37 | * multicast event model (from NSNotificationCenter) 38 | */ 39 | @interface PPManticorePlugin : NSObject 40 | -(instancetype _Nonnull)initWithDelegate:(id _Nonnull)delegate forEngine:(PPManticoreEngine* _Nullable)engine; 41 | @end 42 | -------------------------------------------------------------------------------- /runtime/objc/Manticore/PPManticoreTypeConverter.h: -------------------------------------------------------------------------------- 1 | /*-------------------------------------------------------------------------------------------------------------------*\ 2 | | Copyright (C) 2015 PayPal | 3 | | | 4 | | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance | 5 | | with the License. | 6 | | | 7 | | You may obtain a copy of the License at | 8 | | | 9 | | http://www.apache.org/licenses/LICENSE-2.0 | 10 | | | 11 | | Unless required by applicable law or agreed to in writing, software distributed under the License is distributed | 12 | | on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for | 13 | | the specific language governing permissions and limitations under the License. | 14 | \*-------------------------------------------------------------------------------------------------------------------*/ 15 | 16 | #import 17 | #import 18 | 19 | @class PPManticoreEngine; 20 | 21 | @interface PPManticoreTypeConverter : NSObject 22 | 23 | -(id)initWithEngine:(PPManticoreEngine*)engine; 24 | 25 | @property (nonatomic,assign) Class errorClass; 26 | 27 | -(int)toNativeInt:(JSValue *)value; 28 | -(JSValue*)toJsInt:(int)integerValue; 29 | 30 | -(BOOL)toNativeBool:(JSValue *)value; 31 | -(JSValue*)toJsBool:(BOOL)boolValue; 32 | 33 | -(NSDecimalNumber *)toNativeDecimal:(JSValue *)value; 34 | -(JSValue *)toJsDecimal:(NSDecimalNumber *)decimalValue; 35 | 36 | -(NSDictionary *)toNativeObject:(JSValue *)value; 37 | -(JSValue *)toJsObject:(NSDictionary *)value; 38 | 39 | -(NSError*)toNativeError:(JSValue *)error; 40 | 41 | -(NSArray *)toNativeArray:(JSValue *)value withConverter:(id (^)(id))converter; 42 | -(JSValue *)toJsArray:(NSArray *)array withConverter:(id (^)(id))converter; 43 | @end 44 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/objc/ManticoreContainer/Default-568h@2x.png -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/ManticoreContainer-OSX/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ManticoreContainer-OSX 4 | // 5 | // Created by Katz, Ian on 5/27/16. 6 | // Copyright © 2016 PayPal. All rights reserved. 7 | // 8 | 9 | import Cocoa 10 | 11 | @NSApplicationMain 12 | class AppDelegate: NSObject, NSApplicationDelegate { 13 | 14 | @IBOutlet weak var window: NSWindow! 15 | 16 | 17 | func applicationDidFinishLaunching(aNotification: NSNotification) { 18 | // Insert code here to initialize your application 19 | } 20 | 21 | func applicationWillTerminate(aNotification: NSNotification) { 22 | // Insert code here to tear down your application 23 | } 24 | 25 | 26 | } 27 | 28 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/ManticoreContainer-OSX/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2016 PayPal. All rights reserved. 29 | NSMainNibFile 30 | MainMenu 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/ManticoreContainer-OSXTests/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 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/ManticoreContainer-iOS/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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UIRequiredDeviceCapabilities 26 | 27 | armv7 28 | 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/ManticoreContainer-iOSTests/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 | NSAppTransportSecurity 22 | 23 | NSAllowsArbitraryLoads 24 | 25 | 26 | CFBundleVersion 27 | 1 28 | 29 | 30 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/ManticoreContainer.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/ManticoreContainer.xcodeproj/project.xcworkspace/xcshareddata/ManticoreContainer.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | D1769324-A638-4882-82D5-2039C19AAF3E 9 | IDESourceControlProjectName 10 | project 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 177BEB6F4FF6F0D476246E5FBBB143ED05AF7F7C 14 | github.paypal.com:RetailSDK-NewGen/manticore-objc.git 15 | 16 | IDESourceControlProjectPath 17 | ManticoreContainer/ManticoreContainer.xcodeproj/project.xcworkspace 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 177BEB6F4FF6F0D476246E5FBBB143ED05AF7F7C 21 | ../../.. 22 | 23 | IDESourceControlProjectURL 24 | github.paypal.com:RetailSDK-NewGen/manticore-objc.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 177BEB6F4FF6F0D476246E5FBBB143ED05AF7F7C 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 177BEB6F4FF6F0D476246E5FBBB143ED05AF7F7C 36 | IDESourceControlWCCName 37 | manticore-objc 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /runtime/objc/ManticoreContainer/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // ManticoreContainer 4 | // 5 | // Copyright (c) 2015 PayPal. All rights reserved. 6 | // 7 | 8 | #import 9 | 10 | #import 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([UIResponder class])); 15 | } 16 | } 17 | 18 | -------------------------------------------------------------------------------- /runtime/objc/Podfile: -------------------------------------------------------------------------------- 1 | workspace 'Manticore' 2 | 3 | xcodeproj 'ManticoreContainer/ManticoreContainer' 4 | 5 | target 'ManticoreContainer-iOS', :exclusive => true do 6 | platform :ios, '7.0' 7 | pod 'ManticoreNative', :path => '../../' 8 | end 9 | 10 | target 'ManticoreContainer-iOSTests', :exclusive => true do 11 | platform :ios, '7.0' 12 | pod 'ManticoreNative', :path => '../../' 13 | end 14 | 15 | target 'ManticoreContainer-OSX', :exclusive => true do 16 | platform :osx, '10.9' 17 | pod 'ManticoreNative', :path => '../../' 18 | end 19 | 20 | target 'ManticoreContainer-OSXTests', :exclusive => true do 21 | platform :osx, '10.9' 22 | pod 'ManticoreNative', :path => '../../' 23 | end 24 | -------------------------------------------------------------------------------- /runtime/objc/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - ManticoreNative (1.0.0) 3 | 4 | DEPENDENCIES: 5 | - ManticoreNative (from `../../`) 6 | 7 | EXTERNAL SOURCES: 8 | ManticoreNative: 9 | :path: ../../ 10 | 11 | SPEC CHECKSUMS: 12 | ManticoreNative: 52236cbc64b97cb969487246c225fc453479de8f 13 | 14 | COCOAPODS: 0.39.0 15 | -------------------------------------------------------------------------------- /runtime/objc/js/polyfill.js: -------------------------------------------------------------------------------- 1 | const g = global; 2 | const m = g.manticore; 3 | 4 | // Setup the JavaScriptCore runtime to look like what Manticore requires (bind native functions) 5 | m._log('info', 'Loading objc polyfill'); 6 | 7 | require('core-js/es6/symbol'); 8 | require('core-js/es6/set'); 9 | require('core-js/fn/string/includes'); 10 | require('core-js/fn/object/is'); 11 | require('core-js/fn/object/assign'); 12 | require('core-js/fn/array/of'); 13 | require('core-js/fn/array/from'); 14 | require('core-js/fn/array/find'); 15 | require('core-js/fn/array/find-index'); 16 | require('core-js/fn/symbol/iterator'); 17 | 18 | require('../../common/console'); 19 | require('../../common/promise'); 20 | require('../../common/timer'); 21 | require('../../common/fetch'); 22 | 23 | m._log('info', 'Loaded objc polyfill'); 24 | -------------------------------------------------------------------------------- /runtime/objc/templates/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "typeMap": { 3 | "string": "NSString", 4 | "decimal": "NSDecimalNumber", 5 | "bool": "BOOL", 6 | "int": "int", 7 | "Date": "NSDate", 8 | "object": "NSDictionary", 9 | "error": "PPManticoreError" 10 | }, 11 | "namespace": "PayPalManticore", 12 | "typePrefix": "PPManticore", 13 | "baseClass": "PPManticoreJSBackedObject", 14 | "arrayType": "NSArray*", 15 | "callbackSuffix": "Handler", 16 | "hasPointers": true, 17 | "valueTypes": [ 18 | "int", 19 | "bool" 20 | ], 21 | "nativeConverters": { 22 | "int": "Int", 23 | "decimal": "Decimal", 24 | "bool": "Bool", 25 | "object": "Object" 26 | }, 27 | "basenames": { 28 | "importAll": "PayPalManticoreImports", 29 | "typedefs": "PayPalManticoreTypes" 30 | }, 31 | "extensions": { 32 | "typedefs": ".h", 33 | "importAll": ".h", 34 | "classHeader": ".h", 35 | "impl": ".m", 36 | "class": ".m" 37 | } 38 | } -------------------------------------------------------------------------------- /runtime/objc/templates/importAll.dust: -------------------------------------------------------------------------------- 1 | #import 2 | #import "{languageSettings.basenames.importAll}{languageSettings.extensions.importAll}" 3 | {#classes}#import "{typePrefix}{packedName}.h" 4 | {/classes} 5 | -------------------------------------------------------------------------------- /runtime/objc/templates/method.dust: -------------------------------------------------------------------------------- 1 | {?isStatic}+{:else}-{/isStatic}({^returns}void{:else}{?async}void{:else}{@type}{returns.type}{/type}{/async}{/returns}){name}{@comment} 2 | ***** argument declarations 3 | {/comment}{#args}{@eq key=$idx value=0}{:else}{name}{/eq}:({@type}{type}{/type}){name}{@sep} {/sep}{/args}{@comment} 4 | ***** async rejoinder 5 | {/comment}{?async}{?args} callback{/args}:({typePrefix}{@firstCap}{name}{/firstCap}Callback _Nullable) callback{/async} { 6 | NSArray *args = nil; 7 | {#args} {@first}args = @[ 8 | {:else} {/first}{>toJs target="{type}" arg="{name}"/}{@isCallback type="{type}"}{:else} ?: [NSNull null]{/isCallback}{@sep}, 9 | {/sep}{@last} 10 | ];{/last}{/args} 11 | JSValue *valueToInvokeMethodOn = {?isStatic}[[{typePrefix}{packedName} engine] resolveJSClass:@"{className}"]{:else}self.impl{/isStatic}; 12 | {?async}JSValue *promise = {:else}{?returns}JSValue *returnValue = {/returns}{/async}[valueToInvokeMethodOn invokeMethod:@"{name}" withArguments:args]; 13 | {?async}{@comment} 14 | ***** async gets a promise back 15 | {/comment}[[{typePrefix}{packedName} engine] resolvePromise:promise toCallback:^(JSValue *error, JSValue *result) { 16 | callback( 17 | {>toNative target="error" arg="error"/}, 18 | {>toNative target="{returns.type}" arg="result"/} 19 | ); 20 | }];{:else}{@comment} 21 | ***** regular return 22 | {/comment}{?returns}return {>toNative target="{returns.type}" arg="returnValue"/};{/returns}{/async} 23 | } 24 | -------------------------------------------------------------------------------- /runtime/objc/templates/toJs.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}{@isCallback type="{target}"}{typePrefix}{packedName}_wrap_{@callbackName}{target}{/callbackName}_callback({arg}){:else}{@comment} 2 | // A type we made 3 | {/comment}[[{typePrefix}{packedName} engine] resolveJSObject:{arg} ofType:[{@type noPointers="true"}{target}{/type} class]]{/isCallback}{@comment} 4 | // Builtins are provided by the Manticore engine 5 | {/comment}{:builtin}[[{typePrefix}{packedName} engine].converter toJs{converter}:{arg}]{@comment} 6 | // Enums are simple, except when part of array (where they're simpler, but different) 7 | {/comment}{:enum}{?isArray}{arg}{:else}@({arg}){/isArray}{@comment} 8 | // One you make 9 | {/comment}{:custom}NativeToJS_{target}({arg}, [{typePrefix}{packedName} engine]){@comment} 10 | // Arrays one element at a time 11 | {/comment}{:array}[[{typePrefix}{packedName} engine].converter toJsArray:{arg} withConverter: ^(id element) { return {>toJs target="{elementType}" arg="element" isArray="true"/}; }]{/converter} -------------------------------------------------------------------------------- /runtime/objc/templates/toNative.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}[[{typePrefix}{packedName} engine] attachNativeObject:{arg} ofType:[{@type noPointers="true"}{target}{/type} class]]{@comment} 2 | // Builtin provided by the Manticore converter 3 | {/comment}{:builtin}{@isStrong type="{target}"}{:else}{?isCollection}@({/isCollection}{/isStrong}[[{typePrefix}{packedName} engine].converter toNative{converter}:{arg}]{@isStrong type="{target}"}{:else}{?isCollection}){/isCollection}{/isStrong}{@comment} 4 | // Custom converters 5 | {/comment}{:custom}JSToNative_{target}({arg}){@comment} 6 | // Enum, but has to be special if it's in a collection 7 | {/comment}{:enum}{?isCollection}[NSNumber numberWithInt:{/isCollection}{arg}.toInt32{?isCollection}]{/isCollection}{@comment} 8 | // Collections 9 | {/comment}{:array}[[{typePrefix}{packedName} engine].converter toNativeArray:{arg} withConverter: ^(JSValue* element) { return {>toNative target="{elementType}" arg="element" isCollection="true"/}; }]{/converter} -------------------------------------------------------------------------------- /runtime/objc/templates/typedefs.dust: -------------------------------------------------------------------------------- 1 | {#classes}@class {typePrefix}{packedName}; 2 | {/classes}{#referencedTypes}{@sdkType type="{.}"}@class {@type noPointers="true"}{.}{/type}; 3 | {/sdkType}{/referencedTypes} 4 | {#enums}{?description} 5 | /** 6 | * {@lineify indent=3}{description|s}{/lineify} 7 | */ 8 | {/description}typedef NS_ENUM(NSInteger, {typePrefix}{packedName}) { 9 | {#values} {typePrefix}{packedName}{name} = {value}{@sep}, 10 | {/sep}{/values} 11 | }; 12 | {/enums} 13 | {#allCallbacks} 14 | /** 15 | * {@lineify indent=3}{description|s}{/lineify} 16 | */ 17 | typedef {^returns}void{:else}{@type}{returns.type}{/type}{/returns} (^{typePrefix}{type}{@firstCap}{name}{/firstCap}Handler)({#args}{@type}{type}{/type} {name}{@sep}, {/sep}{/args}); 18 | {/allCallbacks}{#classes}{#methods}{?async} 19 | /** 20 | * Callback for {typePrefix}{type} {name} method 21 | */ 22 | typedef void (^{typePrefix}{type}{@firstCap}{name}{/firstCap}Callback)({@type}error{/type} error, {@type}{returns.type}{/type} result);{/async}{/methods}{/classes} 23 | {#classes} {#events} 24 | /** 25 | * {@lineify indent=3}{description|s}{/lineify} 26 | */ 27 | typedef {^returns}void{:else}{@type}{returns.type}{/type}{/returns} (^{typePrefix}{type}{@firstCap}{name}{/firstCap}Event)({#args}{@type}{type}{/type} {name}{@sep}, {/sep}{/args}); 28 | 29 | /** 30 | * Returned from add{@firstCap}{name}{/firstCap}Listener and used to unsubscribe from the event. 31 | */ 32 | typedef id {typePrefix}{type}{@firstCap}{name}{/firstCap}Signal; 33 | 34 | {/events} {/classes} 35 | -------------------------------------------------------------------------------- /runtime/win/.npmignore: -------------------------------------------------------------------------------- 1 | Manticore.Desktop 2 | Manticore.Desktop.Test 3 | Manticore.Net4 4 | Manticore.Net4.Test 5 | Manticore.WP81 6 | Manticore.WP81.Test 7 | Manticore.Win81 8 | Manticore.Win81.Test 9 | Manticore.WinRT 10 | Manticore.sln 11 | jint 12 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop.Test/Licenses/ClearScript.main.license: -------------------------------------------------------------------------------- 1 | From https://clearscript.codeplex.com/license 2 | 3 | Microsoft Public License (Ms-PL) 4 | Microsoft Public License (Ms-PL) 5 | 6 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. 7 | 8 | 1. Definitions 9 | 10 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. 11 | 12 | A "contribution" is the original software, or any additions or changes to the software. 13 | 14 | A "contributor" is any person that distributes its contribution under this license. 15 | 16 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 17 | 18 | 2. Grant of Rights 19 | 20 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 21 | 22 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 23 | 24 | 3. Conditions and Limitations 25 | 26 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 27 | 28 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 29 | 30 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 31 | 32 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 33 | 34 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. 35 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop.Test/Licenses/v8.main.license: -------------------------------------------------------------------------------- 1 | From https://code.google.com/p/v8/source/browse/trunk/LICENSE 2 | 3 | This license applies to all parts of V8 that are not externally 4 | maintained libraries. The externally maintained libraries used by V8 5 | are: 6 | 7 | - PCRE test suite, located in 8 | test/mjsunit/third_party/regexp-pcre.js. This is based on the 9 | test suite from PCRE-7.3, which is copyrighted by the University 10 | of Cambridge and Google, Inc. The copyright notice and license 11 | are embedded in regexp-pcre.js. 12 | 13 | - Layout tests, located in test/mjsunit/third_party. These are 14 | based on layout tests from webkit.org which are copyrighted by 15 | Apple Computer, Inc. and released under a 3-clause BSD license. 16 | 17 | - Strongtalk assembler, the basis of the files assembler-arm-inl.h, 18 | assembler-arm.cc, assembler-arm.h, assembler-ia32-inl.h, 19 | assembler-ia32.cc, assembler-ia32.h, assembler-x64-inl.h, 20 | assembler-x64.cc, assembler-x64.h, assembler-mips-inl.h, 21 | assembler-mips.cc, assembler-mips.h, assembler.cc and assembler.h. 22 | This code is copyrighted by Sun Microsystems Inc. and released 23 | under a 3-clause BSD license. 24 | 25 | - Valgrind client API header, located at third_party/valgrind/valgrind.h 26 | This is release under the BSD license. 27 | 28 | These libraries have their own licenses; we recommend you read them, 29 | as their terms may differ from the terms below. 30 | 31 | Copyright 2006-2012, the V8 project authors. All rights reserved. 32 | Redistribution and use in source and binary forms, with or without 33 | modification, are permitted provided that the following conditions are 34 | met: 35 | 36 | * Redistributions of source code must retain the above copyright 37 | notice, this list of conditions and the following disclaimer. 38 | * Redistributions in binary form must reproduce the above 39 | copyright notice, this list of conditions and the following 40 | disclaimer in the documentation and/or other materials provided 41 | with the distribution. 42 | * Neither the name of Google Inc. nor the names of its 43 | contributors may be used to endorse or promote products derived 44 | from this software without specific prior written permission. 45 | 46 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 47 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 48 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 49 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 50 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 51 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 52 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 53 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 54 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 55 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 56 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 57 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop.Test/Licenses/v8.strongtalk.license: -------------------------------------------------------------------------------- 1 | From https://code.google.com/p/v8/source/browse/trunk/LICENSE.strongtalk 2 | 3 | Copyright (c) 1994-2006 Sun Microsystems Inc. 4 | All Rights Reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | - Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | - Redistribution in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of Sun Microsystems or the names of contributors may 18 | be used to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop.Test/Licenses/v8.v8.license: -------------------------------------------------------------------------------- 1 | https://code.google.com/p/v8/source/browse/trunk/LICENSE.v8 2 | 3 | Copyright 2006-2011, the V8 project authors. All rights reserved. 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop.Test/Licenses/v8.valgrind.license: -------------------------------------------------------------------------------- 1 | From https://code.google.com/p/v8/source/browse/trunk/LICENSE.valgrind 2 | 3 | ---------------------------------------------------------------- 4 | 5 | Notice that the following BSD-style license applies to this one 6 | file (valgrind.h) only. The rest of Valgrind is licensed under the 7 | terms of the GNU General Public License, version 2, unless 8 | otherwise indicated. See the COPYING file in the source 9 | distribution for details. 10 | 11 | ---------------------------------------------------------------- 12 | 13 | This file is part of Valgrind, a dynamic binary instrumentation 14 | framework. 15 | 16 | Copyright (C) 2000-2007 Julian Seward. All rights reserved. 17 | 18 | Redistribution and use in source and binary forms, with or without 19 | modification, are permitted provided that the following conditions 20 | are met: 21 | 22 | 1. Redistributions of source code must retain the above copyright 23 | notice, this list of conditions and the following disclaimer. 24 | 25 | 2. The origin of this software must not be misrepresented; you must 26 | not claim that you wrote the original software. If you use this 27 | software in a product, an acknowledgment in the product 28 | documentation would be appreciated but is not required. 29 | 30 | 3. Altered source versions must be plainly marked as such, and must 31 | not be misrepresented as being the original software. 32 | 33 | 4. The name of the author may not be used to endorse or promote 34 | products derived from this software without specific prior written 35 | permission. 36 | 37 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 38 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 39 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 40 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 41 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 42 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 43 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 44 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 45 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 46 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 47 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Xunit; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Manticore.Desktop.Test")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Manticore.Desktop.Test")] 14 | [assembly: AssemblyCopyright("Copyright © 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("c89045d5-1ce5-40ae-bfd2-4a45f131e9cb")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.0")] 37 | [assembly: AssemblyFileVersion("1.0.0.0")] 38 | [assembly: CollectionBehavior(DisableTestParallelization = true)] -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/ClearScriptV8-32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Desktop/ClearScriptV8-32.dll -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/ClearScriptV8-64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Desktop/ClearScriptV8-64.dll -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/IJsTypeConverter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | 4 | namespace Manticore 5 | { 6 | public interface IJsTypeConverter 7 | { 8 | dynamic AsJs(Object nativeValue); 9 | 10 | dynamic AsJsBool(bool b); 11 | dynamic AsJsDate(DateTime date); 12 | dynamic AsJsDecimal(decimal? d); 13 | dynamic AsJsInt(int i); 14 | dynamic AsJsString(string s); 15 | dynamic AsJsObject(IDictionary d); 16 | 17 | bool AsNativeBool(dynamic value); 18 | DateTime AsNativeDateTime(dynamic value); 19 | decimal? AsNativeDecimal(dynamic value); 20 | int AsNativeInt(dynamic value); 21 | string AsNativeString(dynamic s); 22 | Exception AsException(dynamic v); 23 | IDictionary AsNativeObject(dynamic o); 24 | 25 | dynamic ToJsArray(System.Collections.Generic.List v, Func converter); 26 | System.Collections.Generic.List ToNativeArray(object value, Func converter); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/JsBackedObject.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Manticore 9 | { 10 | /** 11 | * The JsBackedObject provides a common base class for your generated classes. If you are building an SDK and don't necessarily 12 | * want to expose the "Javascriptiness" of your system, you can define your own base class, make the methods only visible to your 13 | * package and just reimplement these methods with relevant custom types. Code generation and the compiler should collude to make the 14 | * rest of it just work... 15 | */ 16 | public class JsBackedObject 17 | { 18 | protected dynamic impl; 19 | 20 | public JsBackedObject() { } 21 | 22 | protected JsBackedObject(object value) 23 | { 24 | if (value is JsValueHolder) 25 | { 26 | this.impl = ((JsValueHolder)value).jsValue; 27 | } 28 | else 29 | { 30 | this.impl = value; 31 | } 32 | } 33 | 34 | /// 35 | /// All the classes generated against a particular base class must share a single Manticore engine. 36 | /// This is because we expose raw constructors which need to instantiate Js objects without having 37 | /// to pass the engine around all over the place. 38 | /// 39 | public static ManticoreEngine Engine { get; private set; } 40 | 41 | public static void CreateManticoreEngine(String script, String name) { 42 | if (Engine != null && Engine.IsStarted) 43 | { 44 | throw new InvalidOperationException("You must shut down the existing engine before creating a new one."); 45 | } 46 | var e = new ManticoreEngine(); 47 | e.Converter = new DefaultConverter(e, (native) => native.impl, (jsErr) => new ManticoreException(jsErr)); 48 | // Typically, you would add your own native method implementations to 49 | // the ManticoreJsObject here, before you load your script 50 | e.LoadScript(script, name); 51 | Engine = e; 52 | } 53 | 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/JsErrorBuilder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | #if WINDOWS_PHONE_APP || WINDOWS_APP || DOTNET_4 3 | using Jint.Native; 4 | using Jint.Native.Error; 5 | #else 6 | using System.Dynamic; 7 | #endif 8 | 9 | namespace Manticore 10 | { 11 | /// 12 | /// The purpose of JsErrorBuilder class is to build a JavaScript error object from .Net exception. The constructed object could be 13 | /// returned to Javascript functions or passed as an argument to callbacks 14 | /// 15 | public class JsErrorBuilder 16 | { 17 | private readonly Exception _exception; 18 | private int? _code; 19 | 20 | #if WINDOWS_PHONE_APP || WINDOWS_APP || DOTNET_4 21 | private readonly ManticoreEngine _engine; 22 | public JsErrorBuilder(ManticoreEngine manticoreEngine, Exception ex) 23 | { 24 | _engine = manticoreEngine; 25 | _exception = ex; 26 | } 27 | #else 28 | public JsErrorBuilder(Exception ex) 29 | { 30 | _exception = ex; 31 | } 32 | #endif 33 | 34 | public JsErrorBuilder SetErrorCode(int errorCode) 35 | { 36 | _code = errorCode; 37 | return this; 38 | } 39 | 40 | #if WINDOWS_PHONE_APP || WINDOWS_APP || DOTNET_4 41 | public ManticoreJsError Build() 42 | { 43 | return new ManticoreJsError(_engine, _exception, _code); 44 | } 45 | #else 46 | public ExpandoObject Build() 47 | { 48 | dynamic ex = new ExpandoObject(); 49 | ex.message = _exception != null ? _exception.Message : string.Empty; 50 | ex.stack = _exception != null ? _exception.StackTrace : "native"; 51 | if (_code.HasValue) 52 | { 53 | ex.code = _code.Value; 54 | } 55 | return ex; // TODO - Provide toString implementation 56 | } 57 | #endif 58 | } 59 | 60 | #if WINDOWS_PHONE_APP || WINDOWS_APP || DOTNET_4 61 | public class ManticoreJsError : ErrorInstance 62 | { 63 | internal ManticoreJsError(ManticoreEngine manticoreEngine, Exception ex, int? code = null) 64 | : base(manticoreEngine.jsEngine, ex.Message) 65 | { 66 | FastAddProperty("message", ex.Message, true, false, true); 67 | FastAddProperty("code", code.HasValue ? new JsValue(code.Value) : JsValue.Null, true, false, true); 68 | FastAddProperty("stack", ex.StackTrace, true, false, true); 69 | FastAddProperty("toString", manticoreEngine.AsJsFunction(((thisObj, args) => ex.ToString())), true, false, false); 70 | } 71 | } 72 | #endif 73 | 74 | } -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/JsValueHolder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Manticore 8 | { 9 | /// 10 | /// Because of the way dynamic works in C#, you can't pass a dynamic object to a superclass constructor. 11 | /// This JsValueHolder basically exists to circumvent that and allow inheritance to work. 12 | /// 13 | public class JsValueHolder 14 | { 15 | public JsValueHolder(dynamic value) 16 | { 17 | this.jsValue = value; 18 | } 19 | 20 | public dynamic jsValue { get; private set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/Licenses/ClearScript.main.license: -------------------------------------------------------------------------------- 1 | From https://clearscript.codeplex.com/license 2 | 3 | Microsoft Public License (Ms-PL) 4 | Microsoft Public License (Ms-PL) 5 | 6 | This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. 7 | 8 | 1. Definitions 9 | 10 | The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. 11 | 12 | A "contribution" is the original software, or any additions or changes to the software. 13 | 14 | A "contributor" is any person that distributes its contribution under this license. 15 | 16 | "Licensed patents" are a contributor's patent claims that read directly on its contribution. 17 | 18 | 2. Grant of Rights 19 | 20 | (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. 21 | 22 | (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 23 | 24 | 3. Conditions and Limitations 25 | 26 | (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. 27 | 28 | (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. 29 | 30 | (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. 31 | 32 | (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. 33 | 34 | (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. 35 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/Licenses/v8.main.license: -------------------------------------------------------------------------------- 1 | From https://code.google.com/p/v8/source/browse/trunk/LICENSE 2 | 3 | This license applies to all parts of V8 that are not externally 4 | maintained libraries. The externally maintained libraries used by V8 5 | are: 6 | 7 | - PCRE test suite, located in 8 | test/mjsunit/third_party/regexp-pcre.js. This is based on the 9 | test suite from PCRE-7.3, which is copyrighted by the University 10 | of Cambridge and Google, Inc. The copyright notice and license 11 | are embedded in regexp-pcre.js. 12 | 13 | - Layout tests, located in test/mjsunit/third_party. These are 14 | based on layout tests from webkit.org which are copyrighted by 15 | Apple Computer, Inc. and released under a 3-clause BSD license. 16 | 17 | - Strongtalk assembler, the basis of the files assembler-arm-inl.h, 18 | assembler-arm.cc, assembler-arm.h, assembler-ia32-inl.h, 19 | assembler-ia32.cc, assembler-ia32.h, assembler-x64-inl.h, 20 | assembler-x64.cc, assembler-x64.h, assembler-mips-inl.h, 21 | assembler-mips.cc, assembler-mips.h, assembler.cc and assembler.h. 22 | This code is copyrighted by Sun Microsystems Inc. and released 23 | under a 3-clause BSD license. 24 | 25 | - Valgrind client API header, located at third_party/valgrind/valgrind.h 26 | This is release under the BSD license. 27 | 28 | These libraries have their own licenses; we recommend you read them, 29 | as their terms may differ from the terms below. 30 | 31 | Copyright 2006-2012, the V8 project authors. All rights reserved. 32 | Redistribution and use in source and binary forms, with or without 33 | modification, are permitted provided that the following conditions are 34 | met: 35 | 36 | * Redistributions of source code must retain the above copyright 37 | notice, this list of conditions and the following disclaimer. 38 | * Redistributions in binary form must reproduce the above 39 | copyright notice, this list of conditions and the following 40 | disclaimer in the documentation and/or other materials provided 41 | with the distribution. 42 | * Neither the name of Google Inc. nor the names of its 43 | contributors may be used to endorse or promote products derived 44 | from this software without specific prior written permission. 45 | 46 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 47 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 48 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 49 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 50 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 51 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 52 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 53 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 54 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 55 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 56 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 57 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/Licenses/v8.strongtalk.license: -------------------------------------------------------------------------------- 1 | From https://code.google.com/p/v8/source/browse/trunk/LICENSE.strongtalk 2 | 3 | Copyright (c) 1994-2006 Sun Microsystems Inc. 4 | All Rights Reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are 8 | met: 9 | 10 | - Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | - Redistribution in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | 17 | - Neither the name of Sun Microsystems or the names of contributors may 18 | be used to endorse or promote products derived from this software without 19 | specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22 | IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 25 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/Licenses/v8.v8.license: -------------------------------------------------------------------------------- 1 | https://code.google.com/p/v8/source/browse/trunk/LICENSE.v8 2 | 3 | Copyright 2006-2011, the V8 project authors. All rights reserved. 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following 12 | disclaimer in the documentation and/or other materials provided 13 | with the distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived 16 | from this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/Licenses/v8.valgrind.license: -------------------------------------------------------------------------------- 1 | From https://code.google.com/p/v8/source/browse/trunk/LICENSE.valgrind 2 | 3 | ---------------------------------------------------------------- 4 | 5 | Notice that the following BSD-style license applies to this one 6 | file (valgrind.h) only. The rest of Valgrind is licensed under the 7 | terms of the GNU General Public License, version 2, unless 8 | otherwise indicated. See the COPYING file in the source 9 | distribution for details. 10 | 11 | ---------------------------------------------------------------- 12 | 13 | This file is part of Valgrind, a dynamic binary instrumentation 14 | framework. 15 | 16 | Copyright (C) 2000-2007 Julian Seward. All rights reserved. 17 | 18 | Redistribution and use in source and binary forms, with or without 19 | modification, are permitted provided that the following conditions 20 | are met: 21 | 22 | 1. Redistributions of source code must retain the above copyright 23 | notice, this list of conditions and the following disclaimer. 24 | 25 | 2. The origin of this software must not be misrepresented; you must 26 | not claim that you wrote the original software. If you use this 27 | software in a product, an acknowledgment in the product 28 | documentation would be appreciated but is not required. 29 | 30 | 3. Altered source versions must be plainly marked as such, and must 31 | not be misrepresented as being the original software. 32 | 33 | 4. The name of the author may not be used to endorse or promote 34 | products derived from this software without specific prior written 35 | permission. 36 | 37 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 38 | OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 39 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 40 | ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 41 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 42 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 43 | GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 44 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 45 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 46 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 47 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 48 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/ManticoreException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | #if WINDOWS_PHONE_APP || WINDOWS_APP || DOTNET_4 8 | using Jint.Native.Object; 9 | #endif 10 | 11 | namespace Manticore 12 | { 13 | public class ManticoreException : Exception 14 | { 15 | public string JavascriptStack { get; private set; } 16 | 17 | public ManticoreException(String errorMessage) : base(errorMessage) 18 | { 19 | 20 | } 21 | 22 | #if WINDOWS_PHONE_APP || WINDOWS_APP || DOTNET_4 23 | public static ManticoreException NativeInstanceForObject(ObjectInstance error) 24 | { 25 | return new ManticoreException(error); 26 | } 27 | 28 | public ManticoreException(ObjectInstance error) : base(error.Get("message").AsString()) 29 | { 30 | var stack = error.Get("stack"); 31 | if (stack.IsString()) { 32 | JavascriptStack = stack.AsString(); 33 | } 34 | } 35 | #else 36 | public static ManticoreException NativeInstanceForObject(dynamic jsError) { 37 | return new ManticoreException(jsError); 38 | } 39 | 40 | public ManticoreException(dynamic jsError) 41 | : base(((object)jsError.message).ToString()) 42 | { 43 | } 44 | #endif 45 | } 46 | 47 | public enum ErrorCodes 48 | { 49 | NetworkOffline = -1001 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Manticore.Desktop")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Manticore.Desktop")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d5d51996-c454-4e3a-ae9d-a2d3bee53020")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/ScriptEventArgs.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Manticore 8 | { 9 | /// 10 | /// Event arguments for script will/did load events on ManticoreEngine. 11 | /// 12 | public class ScriptEventArgs : EventArgs 13 | { 14 | public ScriptEventArgs(String name, String script) 15 | { 16 | this.Name = name; 17 | this.Script = script; 18 | } 19 | 20 | public String Name { get; private set; } 21 | public String Script { get; private set; } 22 | } 23 | 24 | public delegate void ScriptEventHandler(object sender, ScriptEventArgs e); 25 | } 26 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/v8-ia32.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Desktop/v8-ia32.dll -------------------------------------------------------------------------------- /runtime/win/Manticore.Desktop/v8-x64.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Desktop/v8-x64.dll -------------------------------------------------------------------------------- /runtime/win/Manticore.Net4.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Xunit; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Manticore.Net4.Test")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Manticore.Net4.Test")] 14 | [assembly: AssemblyCopyright("Copyright © 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("bee3f193-6e29-49d3-a335-efd98f646d64")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.0.0.0")] 37 | [assembly: AssemblyFileVersion("1.0.0.0")] 38 | [assembly: CollectionBehavior(DisableTestParallelization = true)] -------------------------------------------------------------------------------- /runtime/win/Manticore.Net4.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Net4/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Manticore.Net4")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Manticore.Net4")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("82132ba8-cab5-4c21-bb67-4ac178895fc6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Assets/Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.WP81.Test/Assets/Logo.scale-240.png -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Assets/SmallLogo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.WP81.Test/Assets/SmallLogo.scale-240.png -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Assets/SplashScreen.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.WP81.Test/Assets/SplashScreen.scale-240.png -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Assets/Square71x71Logo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.WP81.Test/Assets/Square71x71Logo.scale-240.png -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Assets/StoreLogo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.WP81.Test/Assets/StoreLogo.scale-240.png -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Assets/WideLogo.scale-240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.WP81.Test/Assets/WideLogo.scale-240.png -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | Manticore.WP81.Test 12 | mmetral 13 | Assets\StoreLogo.png 14 | 15 | 16 | 17 | 6.3.1 18 | 6.3.1 19 | 20 | 21 | 22 | 23 | 24 | 27 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Xunit; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Manticore.WP81.Test")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Manticore.WP81.Test")] 14 | [assembly: AssemblyCopyright("Copyright © 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Version information for an assembly consists of the following four values: 19 | // 20 | // Major Version 21 | // Minor Version 22 | // Build Number 23 | // Revision 24 | // 25 | // You can specify all the values or you can default the Build and Revision Numbers 26 | // by using the '*' as shown below: 27 | // [assembly: AssemblyVersion("1.0.*")] 28 | [assembly: AssemblyVersion("1.0.0.0")] 29 | [assembly: AssemblyFileVersion("1.0.0.0")] 30 | [assembly: ComVisible(false)] 31 | [assembly: CollectionBehavior(DisableTestParallelization = true)] -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /runtime/win/Manticore.WP81/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Manticore.WP81")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Manticore.WP81")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81.Test/Images/UnitTestLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Win81.Test/Images/UnitTestLogo.scale-100.png -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81.Test/Images/UnitTestSmallLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Win81.Test/Images/UnitTestSmallLogo.scale-100.png -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81.Test/Images/UnitTestSplashScreen.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Win81.Test/Images/UnitTestSplashScreen.scale-100.png -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81.Test/Images/UnitTestStoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/win/Manticore.Win81.Test/Images/UnitTestStoreLogo.scale-100.png -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81.Test/Package.appxmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 7 | 8 | 9 | Manticore.Win81.Test 10 | mmetral 11 | Images\UnitTestStoreLogo.png 12 | Manticore.Win81.Test 13 | 14 | 15 | 16 | 6.3.0 17 | 6.3.0 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 28 | 35 | 36 | 37 | 38 | 39 | 42 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81.Test/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using Xunit; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Manticore.Win81.Test")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Manticore.Win81.Test")] 14 | [assembly: AssemblyCopyright("Copyright © 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Version information for an assembly consists of the following four values: 19 | // 20 | // Major Version 21 | // Minor Version 22 | // Build Number 23 | // Revision 24 | // 25 | // You can specify all the values or you can default the Build and Revision Numbers 26 | // by using the '*' as shown below: 27 | // [assembly: AssemblyVersion("1.0.*")] 28 | [assembly: AssemblyVersion("1.0.0.0")] 29 | [assembly: AssemblyFileVersion("1.0.0.0")] 30 | [assembly: CollectionBehavior(DisableTestParallelization = true)] -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81.Test/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81/IJsTypeConverter.cs: -------------------------------------------------------------------------------- 1 | using Jint.Native; 2 | using Jint.Native.Array; 3 | using Jint.Runtime.Interop; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace Manticore 11 | { 12 | public interface IJsTypeConverter 13 | { 14 | JsValue AsJs(Object nativeValue); 15 | 16 | JsValue AsJsBool(bool b); 17 | JsValue AsJsDate(DateTime date); 18 | JsValue AsJsDecimal(decimal? d); 19 | JsValue AsJsInt(int i); 20 | JsValue AsJsString(string s); 21 | JsValue AsJsObject(IDictionary d); 22 | 23 | bool AsNativeBool(JsValue value); 24 | DateTime AsNativeDate(JsValue value); 25 | decimal? AsNativeDecimal(JsValue value); 26 | int AsNativeInt(JsValue value); 27 | string AsNativeString(JsValue s); 28 | Exception AsException(JsValue v); 29 | IDictionary AsNativeObject(JsValue o); 30 | 31 | ArrayInstance ToJsArray(System.Collections.Generic.List v, Func converter); 32 | System.Collections.Generic.List ToNativeArray(JsValue value, Func converter); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81/JsBackedObject.cs: -------------------------------------------------------------------------------- 1 | using Jint.Native; 2 | using Jint.Native.Object; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Reflection; 9 | 10 | namespace Manticore 11 | { 12 | /** 13 | * The JsBackedObject provides a common base class for your generated classes. If you are building an SDK and don't necessarily 14 | * want to expose the "Javascriptiness" of your system, you can define your own base class, make the methods only visible to your 15 | * package and just reimplement these methods with relevant custom types. Code generation and the compiler should collude to make the 16 | * rest of it just work... 17 | */ 18 | public class JsBackedObject 19 | { 20 | protected ObjectInstance impl; 21 | 22 | public JsBackedObject() { } 23 | 24 | public JsBackedObject(ObjectInstance impl) 25 | { 26 | this.impl = impl; 27 | } 28 | 29 | /// 30 | /// All the classes generated against a particular base class must share a single Manticore engine. 31 | /// This is because we expose raw constructors which need to instantiate Js objects without having 32 | /// to pass the engine around all over the place. 33 | /// 34 | public static ManticoreEngine Engine { get; private set; } 35 | 36 | public static void CreateManticoreEngine(String script, String name) 37 | { 38 | if (Engine != null && Engine.IsStarted) 39 | { 40 | throw new InvalidOperationException("You must shut down the existing engine before creating a new one."); 41 | } 42 | var e = new ManticoreEngine(); 43 | e.Converter = new DefaultConverter(e, (native) => native.impl, (jsErr) => new ManticoreException(jsErr)); 44 | // Typically, you would add your own native method implementations to 45 | // the ManticoreJsObject here, before you load your script 46 | e.LoadScript(script, name); 47 | Engine = e; 48 | } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /runtime/win/Manticore.Win81/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("Manticore.Win81")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("Manticore.Win81")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Version information for an assembly consists of the following four values: 18 | // 19 | // Major Version 20 | // Minor Version 21 | // Build Number 22 | // Revision 23 | // 24 | // You can specify all the values or you can default the Build and Revision Numbers 25 | // by using the '*' as shown below: 26 | // [assembly: AssemblyVersion("1.0.*")] 27 | [assembly: AssemblyVersion("1.0.0.0")] 28 | [assembly: AssemblyFileVersion("1.0.0.0")] 29 | [assembly: ComVisible(false)] -------------------------------------------------------------------------------- /runtime/win/Manticore.WinRT/Manticore.WinRT.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 12.0 6 | Debug 7 | AnyCPU 8 | {640D96AF-36C4-4D02-BD0B-A2FE2BE26BB9} 9 | Library 10 | Properties 11 | Manticore.WinRT 12 | Manticore.WinRT 13 | en-US 14 | 512 15 | {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 16 | Profile32 17 | v4.6 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 54 | -------------------------------------------------------------------------------- /runtime/win/Manticore.WinRT/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Resources; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("Manticore.WinRT")] 10 | [assembly: AssemblyDescription("")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("")] 13 | [assembly: AssemblyProduct("Manticore.WinRT")] 14 | [assembly: AssemblyCopyright("Copyright © 2015")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | [assembly: NeutralResourcesLanguage("en")] 18 | 19 | // Version information for an assembly consists of the following four values: 20 | // 21 | // Major Version 22 | // Minor Version 23 | // Build Number 24 | // Revision 25 | // 26 | // You can specify all the values or you can default the Build and Revision Numbers 27 | // by using the '*' as shown below: 28 | // [assembly: AssemblyVersion("1.0.*")] 29 | [assembly: AssemblyVersion("1.0.0.0")] 30 | [assembly: AssemblyFileVersion("1.0.0.0")] 31 | -------------------------------------------------------------------------------- /runtime/win/js/polyfill.clearscript.js: -------------------------------------------------------------------------------- 1 | const g = global; 2 | const m = g.manticore; 3 | 4 | // Setup the JavaScriptCore runtime to look like what Manticore requires (bind native functions) 5 | m._log('info', 'Loading ClearScript polyfill'); 6 | 7 | g.exports = g.exports || {}; 8 | 9 | require('core-js/es6/symbol'); 10 | require('core-js/es6/set'); 11 | require('core-js/fn/string/includes'); 12 | require('core-js/fn/object/is'); 13 | require('core-js/fn/object/assign'); 14 | require('core-js/fn/array/of'); 15 | require('core-js/fn/array/from'); 16 | require('core-js/fn/array/find'); 17 | require('core-js/fn/array/find-index'); 18 | require('core-js/fn/symbol/iterator'); 19 | 20 | require('../../common/console'); 21 | require('../../common/promise'); 22 | require('../../common/timer'); 23 | require('../../common/fetch'); 24 | 25 | m._ = { 26 | array() { 27 | return []; 28 | }, 29 | 30 | // native functions (which these callbacks are) can't cope with variable argument length 31 | // on this platform. 32 | // we cannot use 'fnlike.apply(null, a);' 33 | // we MUST match in argument count. 34 | fn(fnlike, count) { 35 | return function csFn(...a) { 36 | switch (count) { 37 | case 0: 38 | return fnlike(); 39 | case 1: 40 | return fnlike(a[0]); 41 | case 2: 42 | return fnlike(a[0], a[1]); 43 | case 3: 44 | return fnlike(a[0], a[1], a[2]); 45 | case 4: 46 | return fnlike(a[0], a[1], a[2], a[3]); 47 | case 5: 48 | return fnlike(a[0], a[1], a[2], a[3], a[4]); 49 | case 6: 50 | return fnlike(a[0], a[1], a[2], a[3], a[4], a[5]); 51 | case 7: 52 | return fnlike(a[0], a[1], a[2], a[3], a[4], a[5], a[6]); 53 | default: 54 | throw new Error('Consider using an object instead of so many arguments in this callback'); 55 | } 56 | }; 57 | }, 58 | construct: function construct(className, args) { 59 | if (!className) return {}; 60 | const cons = g.exports[className]; 61 | 62 | function F() { 63 | return cons.apply(this, args); 64 | } 65 | 66 | F.prototype = cons.prototype; 67 | return new F(); 68 | }, 69 | getClass: function getClass(className) { 70 | return g.exports[className]; 71 | }, 72 | }; 73 | 74 | m._log('info', 'Loaded ClearScript polyfill'); 75 | -------------------------------------------------------------------------------- /runtime/win/js/polyfill.jint.js: -------------------------------------------------------------------------------- 1 | const g = global; 2 | const m = g.manticore; 3 | 4 | // Setup the JavaScriptCore runtime to look like what Manticore requires (bind native functions) 5 | m._log('info', 'Loading Jint polyfill'); 6 | 7 | require('core-js/es6/symbol'); 8 | require('core-js/es6/set'); 9 | require('core-js/fn/string/includes'); 10 | require('core-js/fn/object/is'); 11 | require('core-js/fn/object/assign'); 12 | require('core-js/fn/array/of'); 13 | require('core-js/fn/array/from'); 14 | require('core-js/fn/array/find'); 15 | require('core-js/fn/array/find-index'); 16 | require('core-js/fn/symbol/iterator'); 17 | 18 | require('../../common/console'); 19 | require('../../common/promise'); 20 | require('../../common/timer'); 21 | require('../../common/fetch'); 22 | 23 | m._log('info', 'Loaded Jint polyfill'); 24 | -------------------------------------------------------------------------------- /runtime/win/templates/clearscript/argList.dust: -------------------------------------------------------------------------------- 1 | {#args}{@type}{type}{/type} {name}{@sep}, {/sep}{/args} -------------------------------------------------------------------------------- /runtime/win/templates/clearscript/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "Manticore", 3 | "typeMap": { 4 | "string": "String", 5 | "decimal": "Decimal?", 6 | "bool": "bool", 7 | "int": "int", 8 | "Date": "DateTime", 9 | "error": "ManticoreException", 10 | "object": "IDictionary" 11 | }, 12 | "arrayType": "List<%s>", 13 | "arrayIsTyped": true, 14 | "callbackSuffix": "Delegate", 15 | "innerCallbacksAndEvents": true, 16 | "typePrefix": "", 17 | "baseClass": "JsBackedObject", 18 | "nativeConverters": { 19 | "string": "String", 20 | "bool": "Bool", 21 | "int": "Int", 22 | "decimal": "Decimal", 23 | "Date": "DateTime", 24 | "object": "Object" 25 | }, 26 | "extensions": { 27 | "impl": ".cs", 28 | "enum": ".cs", 29 | "class": ".cs" 30 | } 31 | } -------------------------------------------------------------------------------- /runtime/win/templates/clearscript/delegateDecl.dust: -------------------------------------------------------------------------------- 1 | {?returns}Func<{returns.type}{?args},{/args}{:else}Action{?args}<{/args}{/returns}{#args}dynamic{@sep},{/sep}{/args}{?returns}>{:else}{?args}>{/args}{/returns} -------------------------------------------------------------------------------- /runtime/win/templates/clearscript/enum.dust: -------------------------------------------------------------------------------- 1 | namespace {namespace} 2 | { 3 | public enum {packedName} { 4 | {#values} 5 | /** 6 | * {@lineify indent=9}{description|s}{/lineify} 7 | */ 8 | {name} = {value}{@sep}, 9 | {/sep}{/values} 10 | } 11 | } -------------------------------------------------------------------------------- /runtime/win/templates/clearscript/method.dust: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * {@lineify indent=9}{description|s}{/lineify} 4 | */ 5 | public {?isStatic}static {/isStatic}{?async}async Task{?returns}<{@type}{returns.type}{/type}>{/returns}{:else}{^returns}void{:else}{@comment} 6 | ***** Regular non-async returns 7 | {/comment}{@type}{returns.type}{/type}{/returns}{/async} {@firstCap}{name}{/firstCap}({>argList/}) 8 | { 9 | {?async}var _completer = new TaskCompletionSource{?returns}<{@type}{returns.type}{/type}>{/returns}(); 10 | Engine.Js(() => 11 | { 12 | dynamic _promise = {:else}{?returns}return Engine.JsWithReturn(() => 13 | { 14 | dynamic returnValue = {:else}Engine.Js(() => 15 | {{/returns}{/async}{?isStatic}Engine.GetJsClass("{className}"){:else}this.impl{/isStatic}.{name}({?args}{#args}{>toJs target="{type}" arg="{name}"/}{@sep}, 16 | {/sep}{/args}{/args});{?async} 17 | {@comment} 18 | ***** Async functions return a promise 19 | {/comment}var _promiseCallback = new Action((_err,_result) => { 20 | _completer.TrySetResult({>toNative target="{returns.type}" arg="_result"/}); 21 | }); 22 | Engine.ResolvePromise(_promise, _promiseCallback);{:else}{@comment} 23 | {/comment}{?returns} 24 | return {>toNative target="{returns.type}" arg="returnValue"/};{/returns}{/async} 25 | });{?async} 26 | return await _completer.Task; 27 | {/async} 28 | } -------------------------------------------------------------------------------- /runtime/win/templates/clearscript/toJs.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{type}"}{@isCallback type="{target}"}{@comment} 2 | // Delegates are wrapped in a JS-compatible lambda 3 | {/comment}WrapDelegate({arg}){:else}Engine.Converter.AsJs({arg}){/isCallback}{@comment} 4 | // Custom handlers are methods on the base class 5 | {/comment}{:custom}Engine.Converter.AsJs{@firstCap}{type}{/firstCap}({arg}){@comment} 6 | // Arrays are converted one element at a time 7 | {/comment}{:array}Engine.Converter.ToJsArray({arg}, (element) => {>toJs arg="element" type="{elementType}"/}){@comment} 8 | // Builtin converters are provided by Manticore on the Engine. You can derive from the engine if you need to. 9 | {/comment}{:builtin}Engine.Converter.AsJs{@firstCap}{type}{/firstCap}({arg}){:enum}(int){arg}{/converter} -------------------------------------------------------------------------------- /runtime/win/templates/clearscript/toNative.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}{@comment} 2 | // A type we made 3 | {/comment}(Engine.IsNullOrUndefined({arg}) ? null : {@type}{target}{/type}.NativeInstanceForObject({arg})){:array}{@comment} 4 | // Arrays are converted by the engine one by one 5 | {/comment}Engine.Converter.ToNativeArray((object){arg}, (element) => {>toNative arg="element" target="{elementType}"/}){:custom}{@comment} 6 | // Custom converters hang off your base class 7 | {/comment}Engine.Converter.AsNative{@firstCap}{target}{/firstCap}({arg}){:builtin}{@comment} 8 | // Builtin converters are provided by Manticore 9 | {/comment}Engine.Converter.AsNative{converter}({arg}){:enum}{@comment} 10 | // Enums are ints 11 | {/comment}({@type}{target}{/type}) Engine.Converter.AsNativeInt({arg}){/converter} -------------------------------------------------------------------------------- /runtime/win/templates/jint/argList.dust: -------------------------------------------------------------------------------- 1 | {#args}{@type}{type}{/type} {name}{@sep}, {/sep}{/args} -------------------------------------------------------------------------------- /runtime/win/templates/jint/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "Manticore", 3 | "typeMap": { 4 | "string": "String", 5 | "decimal": "Decimal?", 6 | "bool": "bool", 7 | "int": "int", 8 | "Date": "DateTime", 9 | "error": "ManticoreException", 10 | "object": "IDictionary" 11 | }, 12 | "arrayType": "List<%s>", 13 | "arrayIsTyped": true, 14 | "callbackSuffix": "Delegate", 15 | "innerCallbacksAndEvents": true, 16 | "typePrefix": "", 17 | "baseClass": "JsBackedObject", 18 | "nativeConverters": { 19 | "string": "String", 20 | "bool": "Bool", 21 | "int": "Int", 22 | "decimal": "Decimal", 23 | "Date": "Date", 24 | "object": "Object" 25 | }, 26 | "extensions": { 27 | "class": ".cs", 28 | "enum": ".cs", 29 | "impl": ".cs" 30 | } 31 | } -------------------------------------------------------------------------------- /runtime/win/templates/jint/enum.dust: -------------------------------------------------------------------------------- 1 | namespace {namespace} 2 | { 3 | public enum {packedName} { 4 | {#values} 5 | /** 6 | * {@lineify indent=9}{description|s}{/lineify} 7 | */ 8 | {name} = {value}{@sep}, 9 | {/sep}{/values} 10 | } 11 | } -------------------------------------------------------------------------------- /runtime/win/templates/jint/method.dust: -------------------------------------------------------------------------------- 1 | /** 2 | * {@lineify indent=9}{description|s}{/lineify} 3 | */ 4 | public {?isStatic}static {/isStatic}{?async}async Task{?returns}<{@type}{returns.type}{/type}>{/returns}{:else}{^returns}void{:else}{@comment} 5 | ***** Regular non-async returns 6 | {/comment}{@type}{returns.type}{/type}{/returns}{/async} {@firstCap}{name}{/firstCap}({#args}{@type}{type}{/type} {name}{@sep}, {/sep}{/args}) {{?async} 7 | var _completer = new TaskCompletionSource{?returns}<{@type}{returns.type}{/type}>{:else}{/returns}();{/async} 8 | JsValue[] args = new JsValue[] {{?args} 9 | {#args}{>toJs target="{type}" arg="{name}"/}{@sep}, 10 | {/sep}{/args} 11 | {/args}}; 12 | {?isStatic}var jsClass = Engine.GetJsClass("{className}");{/isStatic} 13 | var func = {?isStatic}jsClass{:else}this.impl{/isStatic}.Get("{name}").As(); 14 | {^async}{?returns}return {/returns}{/async}Engine.Js{?returns}{^async}WithReturn{/async}{/returns}(() => { 15 | {?returns}var returnValue = {/returns}func.Call({?isStatic}jsClass{:else}this.impl{/isStatic}, args); 16 | {?async}var _callback = Engine.AsJsFunction(new Func((thisObject, cbArgs) => { 17 | if (cbArgs.Length > 0 && !cbArgs[0].IsNull() && !cbArgs[0].IsUndefined()) { 18 | _completer.TrySetException(new ManticoreException(cbArgs[0].AsObject())); 19 | } else { 20 | {?returns}if (cbArgs.Length > 1 && !cbArgs[1].IsNull() && !cbArgs[1].IsUndefined()) { 21 | _completer.TrySetResult({>toNative target="{returns.type}" arg="cbArgs[1]"/}); 22 | }{:else}_completer.TrySetResult(true);{/returns} 23 | } 24 | return JsValue.Undefined; 25 | })); 26 | Engine.ResolvePromise(returnValue, _callback); 27 | {:else}{?returns}return {>toNative target="{returns.type}" arg="returnValue"/};{/returns}{/async} 28 | });{?async} 29 | return await _completer.Task;{/async} 30 | } -------------------------------------------------------------------------------- /runtime/win/templates/jint/toJs.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}{@isCallback type="{target}"}WrapDelegate({arg}){@comment} 2 | // Not a callback, likely a type we made 3 | {/comment}{:else}Engine.Converter.AsJs({arg}){/isCallback}{@comment} 4 | // We have a custom converter for some types 5 | {/comment}{:custom}Engine.Converter.AsJs{@firstCap}{target}{/firstCap}({arg}){@comment} 6 | // Build a JS array by converting each element 7 | {/comment}{:array}Engine.Converter.ToJsArray({arg}, (element) => {>toJs arg="element" target="{elementType}"/}){@comment} 8 | // Jint has a converter for us 9 | {/comment}{:builtin}Engine.Converter.AsJs{converter}({arg}){@comment} 10 | // simple conversion 11 | {/comment}{:enum}(int){arg}{/converter} -------------------------------------------------------------------------------- /runtime/win/templates/jint/toNative.dust: -------------------------------------------------------------------------------- 1 | {@converter type="{target}"}{@comment} 2 | // A type we made 3 | {/comment}(({arg}.IsNull()||{arg}.IsUndefined()) ? null : {@type}{target}{/type}.NativeInstanceForObject({arg}.AsObject())){:custom}{@comment} 4 | // Custom converters hang off your base class 5 | {/comment}Engine.Converter.AsNative{@firstCap}{target}{/firstCap}({arg}){:builtin}{@comment} 6 | // Builtin converters are provided by Manticore 7 | {/comment}Engine.Converter.AsNative{converter}({arg}){:array}{@comment} 8 | // Arrays are converted one by one 9 | {/comment}Engine.Converter.ToNativeArray({arg}, new Func((element) => {>toNative arg="element" target="{elementType}"/})){:enum}{@comment} 10 | // Enums are just ints 11 | {/comment}(({@type}{target}{/type})Engine.Converter.AsNativeInt({arg})){/converter} -------------------------------------------------------------------------------- /runtime/xamarin/.npmignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/paypal/manticore-native/e26422100ea04816e637a10b04e0ebde25ec3159/runtime/xamarin/.npmignore -------------------------------------------------------------------------------- /runtime/xamarin/templates/objc/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "Manticore", 3 | "typePrefix": "PPManticore", 4 | "typeMap": { 5 | "string": "string", 6 | "decimal": "NSDecimalNumber", 7 | "bool": "bool", 8 | "int": "int", 9 | "Date": "NSDate", 10 | "object": "NSDictionary", 11 | "error": "PPManticoreError" 12 | }, 13 | "arrayType": "%s[]", 14 | "arrayIsTyped": true, 15 | "callbackSuffix": "Handler", 16 | "hasPointers": false, 17 | "valueTypes": [ 18 | "int", 19 | "bool" 20 | ], 21 | "customConverters": [ 22 | "int", 23 | "decimal", 24 | "bool" 25 | ], 26 | "basenames": { 27 | "impl": "ApiDefinition", 28 | "enums": "StructsAndEnums" 29 | }, 30 | "extensions": { 31 | "impl": ".cs", 32 | "enums": ".cs" 33 | } 34 | } -------------------------------------------------------------------------------- /runtime/xamarin/templates/objc/enums.dust: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace {namespace} 4 | { 5 | {#enums} 6 | public enum {packedName} : uint { 7 | {#values}{name} = {value}{@sep}, 8 | {/sep}{/values} 9 | } 10 | {/enums} 11 | } -------------------------------------------------------------------------------- /scripts/ci/travis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | : ${BUILD_ITEM:=$1} # allow "travis.sh objc" shorthand instead of "BUILD_ITEM=objc travis.sh" 3 | set -o pipefail 4 | 5 | 6 | echo "=*=*=*=*=*=*=*=*=*=*=*=* BUILDING $BUILD_ITEM =*=*=*=*=*=*=*=*=*=*=*=*" 7 | if [ "$BUILD_ITEM" == "objc" ] 8 | then 9 | set -ex 10 | npm install -g npm@3 11 | node -v 12 | npm -v 13 | npm install 14 | npm run build-testjs 15 | npm run objc-polyfill 16 | npm run objc-testjs 17 | 18 | # now the test harness 19 | pushd runtime/objc 20 | pod install 21 | instruments -s devices 22 | xcodebuild test -workspace Manticore.xcworkspace -scheme ManticoreContainer-OSX | tee xcodebuild-osx.log | xcpretty 23 | xcodebuild test -workspace Manticore.xcworkspace -scheme ManticoreContainer-iOS -destination 'platform=iOS Simulator,name=iPhone 6,OS=9.3' | tee xcodebuild9.log | xcpretty 24 | popd 25 | 26 | # now the hello world app 27 | pushd examples/hello-world/src/ios/ 28 | ./build.sh 29 | popd 30 | 31 | elif [ "$BUILD_ITEM" == "node" ] 32 | then 33 | set -ex 34 | . /home/travis/.nvm/nvm.sh 35 | nvm install 4.4 36 | node -v 37 | npm -v 38 | npm run lint 39 | npm test 40 | elif [ "$BUILD_ITEM" == "java" ] 41 | then 42 | set -ex 43 | . /home/travis/.nvm/nvm.sh 44 | nvm install 4.4 45 | npm install -g npm@3 46 | node -v 47 | npm -v 48 | npm install 49 | npm run build-testjs 50 | npm run android-polyfill 51 | npm run android-testjs 52 | find . -name polyfill_pack.js 53 | cd runtime/android 54 | ./gradlew --stacktrace --info clean :manticore:generateDebugSources :manticore:mockableAndroidJar :manticore:prepareDebugUnitTestDependencies :manticore:generateDebugAndroidTestSources testDebug 55 | else 56 | echo "The environment variable BUILD_ITEM contained the unrecognized value '$BUILD_ITEM' (expected {objc, java, node})" 57 | exit 1 58 | fi 59 | -------------------------------------------------------------------------------- /scripts/packaging/make-npm-ignores.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # go to root directory 4 | cd "$(git rev-parse --show-toplevel)" 5 | 6 | DIRS=$(find runtime -type d -depth 1 | grep -v common) 7 | for d in $DIRS; do 8 | echo "Processing '$d' for npm ignore purposes" 9 | ls $d | grep -v templates | grep -v "^js$" | grep -v README > "$d/.npmignore" || echo " Nothing to ignore" 10 | done 11 | -------------------------------------------------------------------------------- /test/debug-templates/class.dust: -------------------------------------------------------------------------------- 1 | {@contextDump/} 2 | -------------------------------------------------------------------------------- /test/debug-templates/classHeader.dust: -------------------------------------------------------------------------------- 1 | {@contextDump/} 2 | -------------------------------------------------------------------------------- /test/debug-templates/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "namespace": "MyNamespace", 3 | "typeMap": { 4 | "string": "typeIsString", 5 | "decimal": "typeIsDecimal", 6 | "bool": "typeIsBool", 7 | "int": "typeIsInt", 8 | "Date": "typeIsDate", 9 | "error": "typeIsError", 10 | "object": "typeIsObject" 11 | }, 12 | "arrayType": "MyArrayType-%s", 13 | "arrayIsTyped": true, 14 | "callbackSuffix": "MyCallbackSuffx", 15 | "innerCallbacksAndEvents": true, 16 | "typePrefix": "myTypePrefix", 17 | "baseClass": "MyBaseClass", 18 | "nativeConverters": { 19 | "string": "String", 20 | "bool": "Bool", 21 | "int": "Int", 22 | "decimal": "Decimal", 23 | "Date": "Date", 24 | "object": "Object" 25 | }, 26 | "basenames": { 27 | "header": "headerFilename", 28 | "enums": "enumsFilename", 29 | "impl": "implFilename", 30 | "importAll": "importAllFilename", 31 | "typedefs": "typedefsFilename" 32 | }, 33 | "extensions": { 34 | "class": ".class", 35 | "classHeader": ".classHeader", 36 | "enum": ".enum", 37 | "enums": ".enums", 38 | "header": ".header", 39 | "impl": ".impl", 40 | "importAll": ".importAll", 41 | "typedefs": ".typedefs" 42 | } 43 | } -------------------------------------------------------------------------------- /test/debug-templates/enum.dust: -------------------------------------------------------------------------------- 1 | {@contextDump/} 2 | -------------------------------------------------------------------------------- /test/debug-templates/enums.dust: -------------------------------------------------------------------------------- 1 | msg={@sourceDocument/} -------------------------------------------------------------------------------- /test/debug-templates/header.dust: -------------------------------------------------------------------------------- 1 | {@contextDump/} 2 | -------------------------------------------------------------------------------- /test/debug-templates/impl.dust: -------------------------------------------------------------------------------- 1 | {@contextDump/} 2 | -------------------------------------------------------------------------------- /test/debug-templates/importAll.dust: -------------------------------------------------------------------------------- 1 | {@contextDump/} 2 | -------------------------------------------------------------------------------- /test/debug-templates/typedefs.dust: -------------------------------------------------------------------------------- 1 | {@contextDump/} 2 | -------------------------------------------------------------------------------- /test/expected-outputs/csharp-clearscript/SDKTestDefaultSubclass.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading.Tasks; 4 | using Manticore; 5 | 6 | /** 7 | * SDKTestDefaultSubclass.cs 8 | * 9 | * 10 | * DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED AND SHOULD NOT BE CHECKED IN. 11 | * 12 | * 13 | * 14 | */ 15 | namespace Manticore 16 | { 17 | public class SDKTestDefaultSubclass : SDKTestDefault { 18 | 19 | new internal static SDKTestDefaultSubclass NativeInstanceForObject(dynamic value) { 20 | if (Engine.IsNullOrUndefined(value)) { 21 | return null; 22 | } 23 | 24 | return new SDKTestDefaultSubclass(new JsValueHolder(value)); 25 | } 26 | 27 | internal SDKTestDefaultSubclass(object value) : base(value) { 28 | } 29 | 30 | public SDKTestDefaultSubclass() { 31 | this.impl = Engine.CreateJsObject("SDKTestDefaultSubclass", null); 32 | } 33 | 34 | 35 | /** 36 | * Test subclass 37 | */ 38 | public bool IsItDerived() 39 | { 40 | return Engine.JsWithReturn(() => 41 | { 42 | dynamic returnValue = this.impl.isItDerived(); 43 | return Engine.Converter.AsNativeBool(returnValue); 44 | }); 45 | } 46 | 47 | /** 48 | * Test derived classes 49 | */ 50 | public static SDKTestDefault GetDerived() 51 | { 52 | return Engine.JsWithReturn(() => 53 | { 54 | dynamic returnValue = Engine.GetJsClass("SDKTestDefaultSubclass").getDerived(); 55 | return (Engine.IsNullOrUndefined(returnValue) ? null : SDKTestDefault.NativeInstanceForObject(returnValue)); 56 | }); 57 | } 58 | 59 | 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /test/expected-outputs/csharp-clearscript/SDKTestStatuses.cs: -------------------------------------------------------------------------------- 1 | namespace Manticore 2 | { 3 | public enum SDKTestStatuses { 4 | 5 | /** 6 | * comments matter apparently 7 | */ 8 | ON_FIRE = 0, 9 | 10 | /** 11 | * you must write one 12 | */ 13 | WET = 1, 14 | 15 | /** 16 | * just, shhhh. 17 | */ 18 | UNINMAGINABLE = 2 19 | } 20 | } -------------------------------------------------------------------------------- /test/expected-outputs/csharp-jint/SDKTestDefaultSubclass.cs: -------------------------------------------------------------------------------- 1 | using Jint; 2 | using Jint.Native; 3 | using Jint.Native.Object; 4 | using Jint.Native.Function; 5 | using Jint.Runtime.Interop; 6 | using System; 7 | using System.Threading.Tasks; 8 | using System.Collections.Generic; 9 | using Manticore; 10 | 11 | /** 12 | * SDKTestDefaultSubclass.cs 13 | * 14 | * DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED AND SHOULD NOT BE CHECKED IN. 15 | * 16 | * 17 | * 18 | */ 19 | namespace Manticore 20 | { 21 | public class SDKTestDefaultSubclass : SDKTestDefault { 22 | 23 | 24 | internal SDKTestDefaultSubclass(ObjectInstance value) : base(value) { 25 | } 26 | 27 | 28 | public SDKTestDefaultSubclass() { 29 | this.impl = Engine.CreateJsObject("SDKTestDefaultSubclass", ManticoreEngine.EmptyArgs); 30 | } 31 | 32 | 33 | new internal static SDKTestDefaultSubclass NativeInstanceForObject(ObjectInstance value) { 34 | if (value == null) { 35 | return null; 36 | } 37 | 38 | return new SDKTestDefaultSubclass(value); 39 | } 40 | /** 41 | * Test subclass 42 | */ 43 | public bool IsItDerived() { 44 | JsValue[] args = new JsValue[] {}; 45 | 46 | var func = this.impl.Get("isItDerived").As(); 47 | return Engine.JsWithReturn(() => { 48 | var returnValue = func.Call(this.impl, args); 49 | return Engine.Converter.AsNativeBool(returnValue); 50 | }); 51 | } 52 | /** 53 | * Test derived classes 54 | */ 55 | public static SDKTestDefault GetDerived() { 56 | JsValue[] args = new JsValue[] {}; 57 | var jsClass = Engine.GetJsClass("SDKTestDefaultSubclass"); 58 | var func = jsClass.Get("getDerived").As(); 59 | return Engine.JsWithReturn(() => { 60 | var returnValue = func.Call(jsClass, args); 61 | return ((returnValue.IsNull()||returnValue.IsUndefined()) ? null : SDKTestDefault.NativeInstanceForObject(returnValue.AsObject())); 62 | }); 63 | } 64 | 65 | 66 | 67 | 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /test/expected-outputs/csharp-jint/SDKTestStatuses.cs: -------------------------------------------------------------------------------- 1 | namespace Manticore 2 | { 3 | public enum SDKTestStatuses { 4 | 5 | /** 6 | * comments matter apparently 7 | */ 8 | ON_FIRE = 0, 9 | 10 | /** 11 | * you must write one 12 | */ 13 | WET = 1, 14 | 15 | /** 16 | * just, shhhh. 17 | */ 18 | UNINMAGINABLE = 2 19 | } 20 | } -------------------------------------------------------------------------------- /test/expected-outputs/j2v8/SDKTestStatuses.java: -------------------------------------------------------------------------------- 1 | package com.paypal.manticore; 2 | 3 | /** 4 | * SDKTestStatuses.java 5 | * 6 | * DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED AND SHOULD NOT BE CHECKED IN. 7 | * 8 | * 9 | * 10 | */ 11 | public enum SDKTestStatuses { 12 | ON_FIRE(0), 13 | WET(1), 14 | UNINMAGINABLE(2); 15 | 16 | 17 | private final int value; 18 | 19 | private SDKTestStatuses(int value) { 20 | this.value = value; 21 | } 22 | 23 | public int getValue() { 24 | return this.value; 25 | } 26 | 27 | public static SDKTestStatuses fromInt(int value) { 28 | switch(value) { 29 | case 0: 30 | return ON_FIRE; 31 | case 1: 32 | return WET; 33 | case 2: 34 | return UNINMAGINABLE; 35 | 36 | } 37 | return null; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /test/expected-outputs/objc/PPManticoreSDKTestDefault.h: -------------------------------------------------------------------------------- 1 | /** 2 | * PPManticoreSDKTestDefault.h 3 | * 4 | * DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED AND SHOULD NOT BE CHECKED IN. 5 | * 6 | * 7 | * 8 | */ 9 | 10 | #import "PayPalManticoreTypes.h" 11 | #import "PPManticoreJSBackedObject.h" 12 | 13 | @class PPManticoreSDKTest; 14 | @class PPManticoreSDKTestDefault; 15 | @class PPManticoreSDKTestDefaultSubclass; 16 | 17 | /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ 18 | /** 19 | * 20 | */ 21 | @interface PPManticoreSDKTestDefault : PPManticoreJSBackedObject 22 | /** 23 | * It's 1 24 | */ 25 | @property (nonatomic,assign) int test;/** 26 | * It's true 27 | */ 28 | @property (nonatomic,assign) BOOL itsTrue;/** 29 | * It's false 30 | */ 31 | @property (nonatomic,assign) BOOL itsFalse;/** 32 | * Starts blank 33 | */ 34 | @property (nonatomic,assign) int blankInt;/** 35 | * Starts 1 36 | */ 37 | @property (nonatomic,assign) int intOne;/** 38 | * Starts blank 39 | */ 40 | @property (nonatomic,strong,nullable) NSDecimalNumber* blankDecimal;/** 41 | * Starts 100.01 42 | */ 43 | @property (nonatomic,strong,nullable) NSDecimalNumber* decimalHundredOhOne;/** 44 | * It's a null string. 45 | */ 46 | @property (nonatomic,strong,nullable) NSString* nullString;/** 47 | * It's now 48 | */ 49 | @property (nonatomic,strong,nullable) NSDate* now;/** 50 | * An array of a, b, c 51 | */ 52 | @property (nonatomic,strong,nullable) NSArray* stringArray; 53 | 54 | 55 | 56 | 57 | 58 | /** 59 | * Test closure 60 | */ 61 | -(BOOL)isItTrue; 62 | 63 | 64 | 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /test/expected-outputs/objc/PPManticoreSDKTestDefaultSubclass.h: -------------------------------------------------------------------------------- 1 | /** 2 | * PPManticoreSDKTestDefaultSubclass.h 3 | * 4 | * DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED AND SHOULD NOT BE CHECKED IN. 5 | * 6 | * 7 | * 8 | */ 9 | 10 | #import "PayPalManticoreTypes.h" 11 | #import "PPManticoreJSBackedObject.h" 12 | 13 | @class PPManticoreSDKTest; 14 | @class PPManticoreSDKTestDefault; 15 | @class PPManticoreSDKTestDefaultSubclass; 16 | 17 | /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/ 18 | /** 19 | * 20 | */ 21 | @interface PPManticoreSDKTestDefaultSubclass : PPManticoreSDKTestDefault 22 | 23 | 24 | 25 | 26 | /** 27 | * Test derived classes 28 | */ 29 | +(PPManticoreSDKTestDefault* _Nullable)getDerived; 30 | 31 | 32 | 33 | /** 34 | * Test subclass 35 | */ 36 | -(BOOL)isItDerived; 37 | 38 | 39 | 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /test/expected-outputs/objc/PPManticoreSDKTestDefaultSubclass.m: -------------------------------------------------------------------------------- 1 | /** 2 | * PPManticoreSDKTestDefaultSubclass.m 3 | * 4 | * DO NOT EDIT THIS FILE! IT IS AUTOMATICALLY GENERATED AND SHOULD NOT BE CHECKED IN. 5 | * 6 | * 7 | * 8 | */ 9 | #import "PayPalManticoreImports.h" 10 | #import "PPManticoreEngine.h" 11 | #import "PPManticoreNativeInterface.h" 12 | #import "PPManticoreError.h" 13 | 14 | 15 | @implementation PPManticoreSDKTestDefaultSubclass 16 | 17 | 18 | 19 | + (Class)nativeClassForObject:(JSValue*)value { 20 | if (value.isNull || value.isUndefined) { 21 | return self; 22 | } 23 | JSValue *nativeClass = value[@"_native"]; 24 | if (nativeClass.isNull || nativeClass.isUndefined) { 25 | return self; 26 | } 27 | 28 | return self; 29 | } 30 | 31 | - (instancetype _Nullable)init { 32 | if ((self = [super init])) { 33 | self.impl = [[PPManticoreSDKTestDefaultSubclass engine] createJSObject:@"SDKTestDefaultSubclass" withArguments:nil]; 34 | } 35 | return self; 36 | } 37 | 38 | -(BOOL)isItDerived { 39 | NSArray *args = nil; 40 | 41 | JSValue *valueToInvokeMethodOn = self.impl; 42 | JSValue *returnValue = [valueToInvokeMethodOn invokeMethod:@"isItDerived" withArguments:args]; 43 | return [[PPManticoreSDKTestDefaultSubclass engine].converter toNativeBool:returnValue]; 44 | } 45 | 46 | +(PPManticoreSDKTestDefault*)getDerived { 47 | NSArray *args = nil; 48 | 49 | JSValue *valueToInvokeMethodOn = [[PPManticoreSDKTestDefaultSubclass engine] resolveJSClass:@"SDKTestDefaultSubclass"]; 50 | JSValue *returnValue = [valueToInvokeMethodOn invokeMethod:@"getDerived" withArguments:args]; 51 | return [[PPManticoreSDKTestDefaultSubclass engine] attachNativeObject:returnValue ofType:[PPManticoreSDKTestDefault class]]; 52 | } 53 | 54 | 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /test/expected-outputs/objc/PayPalManticoreImports.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "PayPalManticoreImports.h" 3 | #import "PPManticoreSDKTest.h" 4 | #import "PPManticoreSDKTestDefault.h" 5 | #import "PPManticoreSDKTestDefaultSubclass.h" 6 | 7 | -------------------------------------------------------------------------------- /test/expected-outputs/objc/PayPalManticoreTypes.h: -------------------------------------------------------------------------------- 1 | @class PPManticoreSDKTest; 2 | @class PPManticoreSDKTestDefault; 3 | @class PPManticoreSDKTestDefaultSubclass; 4 | @class PPManticoreSDKTestDefault; 5 | @class PPManticoreError; 6 | 7 | 8 | /** 9 | * Valid SDK statuses 10 | */ 11 | typedef NS_ENUM(NSInteger, PPManticoreSDKTestStatuses) { 12 | PPManticoreSDKTestStatusesON_FIRE = 0, 13 | PPManticoreSDKTestStatusesWET = 1, 14 | PPManticoreSDKTestStatusesUNINMAGINABLE = 2 15 | }; 16 | 17 | 18 | /** 19 | * Callback for fetch method 20 | */ 21 | typedef void (^PPManticoreSDKTestFetchedHandler)(PPManticoreError* error, NSDictionary* response); 22 | 23 | /** 24 | * Callback for echo method 25 | */ 26 | typedef void (^PPManticoreSDKTestEchoHandler)(PPManticoreError* error, NSString* arg); 27 | 28 | /** 29 | * Callback for echo method with return 30 | */ 31 | typedef NSString* (^PPManticoreSDKTestEchoReturnHandler)(); 32 | 33 | /** 34 | * Callback for PPManticore goFetchP method 35 | */ 36 | typedef void (^PPManticoreGoFetchPCallback)(PPManticoreError* error, NSDictionary* result); 37 | 38 | /** 39 | * Simple event 40 | */ 41 | typedef void (^PPManticoreFakeEventEvent)(PPManticoreSDKTestDefault* item); 42 | 43 | /** 44 | * Returned from addFakeEventListener and used to unsubscribe from the event. 45 | */ 46 | typedef id PPManticoreFakeEventSignal; 47 | 48 | 49 | -------------------------------------------------------------------------------- /test/expected-outputs/xamarin-objc/StructsAndEnums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Manticore 4 | { 5 | 6 | public enum SDKTestStatuses : uint { 7 | ON_FIRE = 0, 8 | WET = 1, 9 | UNINMAGINABLE = 2 10 | } 11 | 12 | } -------------------------------------------------------------------------------- /test/js-source/SDKTestDefault.js: -------------------------------------------------------------------------------- 1 | // Decimals are handled by converting to a string. It's your job 2 | // to convert from that to whatever format you want (e.g. bignumber.js) 3 | class FakeDecimal { 4 | constructor(val) { 5 | this.val = val; 6 | } 7 | 8 | toString() { 9 | return this.val; 10 | } 11 | } 12 | 13 | /** 14 | * @class 15 | * @property {int} test It's 1 16 | * @property {bool} itsTrue It's true 17 | * @property {bool} itsFalse It's false 18 | * @property {int} blankInt Starts blank 19 | * @property {int} intOne Starts 1 20 | * @property {decimal} blankDecimal Starts blank 21 | * @property {decimal} decimalHundredOhOne Starts 100.01 22 | * @property {string} nullString It's a null string. 23 | * @property {Date} now It's now 24 | * @property {[string]} stringArray An array of a, b, c 25 | */ 26 | export class SDKTestDefault { 27 | constructor() { 28 | this.test = 1; 29 | this.itsTrue = true; 30 | this.itsFalse = false; 31 | this.intOne = 1; 32 | this.fakeStuff = 123456; 33 | this.stringArray = ['a', 'b', 'c']; 34 | this.decimalHundredOhOne = new FakeDecimal('100.01'); 35 | this.now = new Date(); 36 | } 37 | 38 | /** 39 | * Test closure 40 | * @returns {bool} true 41 | */ 42 | isItTrue() { 43 | return this.fakeStuff === 123456; 44 | } 45 | 46 | toString() { 47 | return `This is an SDK Default object: ${this.itsTrue}`; 48 | } 49 | } 50 | 51 | /** 52 | * @class 53 | * @extends SDKTestDefault 54 | */ 55 | export class SDKTestDefaultSubclass extends SDKTestDefault { 56 | constructor() { 57 | super(); 58 | this._native = 'SDKTestDefaultSubclass'; 59 | } 60 | 61 | /** 62 | * Test subclass 63 | * @returns {bool} true 64 | */ 65 | isItDerived() { 66 | return true; 67 | } 68 | 69 | /** 70 | * Test derived classes 71 | * @returns {SDKTestDefault} 72 | */ 73 | static getDerived() { 74 | return new SDKTestDefaultSubclass(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /test/js-source/index.js: -------------------------------------------------------------------------------- 1 | console.log('Loading sample JS'); 2 | 3 | import { SDKTest } from './SDKTest'; 4 | import { SDKTestDefault, SDKTestDefaultSubclass } from './SDKTestDefault'; 5 | import { nativeExport } from '../../index'; 6 | 7 | nativeExport(module, { SDKTest, SDKTestDefault, SDKTestDefaultSubclass }); 8 | 9 | console.log('Completed sample JS'); 10 | -------------------------------------------------------------------------------- /test/test_node.js: -------------------------------------------------------------------------------- 1 | import * as infra from './infra'; 2 | import * as SDK from './js-source/index'; 3 | 4 | infra.test('Node.js runtime', (suite) => { 5 | suite.test('Should export the right objects', (t) => { 6 | t.ok(SDK.SDKTest, 'Should export SDKTest'); 7 | t.ok(SDK.SDKTestDefault, 'Should export SDKTestDefault'); 8 | t.ok(SDK.SDKTestDefaultSubclass, 'Should export SDKTestDefaultSubclass'); 9 | t.end(); 10 | }); 11 | 12 | suite.test('Defaults should work', (t) => { 13 | const sdkTestDefault = new SDK.SDKTestDefault(); 14 | t.ok(sdkTestDefault, 'Should create SDKTest instance'); 15 | t.end(); 16 | }); 17 | 18 | suite.test('Fetch should work', infra.wrapTest(async(t) => { 19 | const sdkTest = new SDK.SDKTest(); 20 | sdkTest.goFetch((err, rz) => { 21 | t.ok(!err, 'Fetch should not error'); 22 | t.ok(rz, 'Fetch should get result'); 23 | t.equal(rz.args.foo, 'bar', 'Should echo query string arg'); 24 | t.end(); 25 | }); 26 | })); 27 | 28 | suite.test('Promise fetch should work', async(t) => { 29 | const sdkTest = new SDK.SDKTest(); 30 | const rz = await sdkTest.goFetchP(); 31 | t.ok(rz, 'Promise fetch should get result'); 32 | t.equal(rz.args.baz, 'bop', 'Promise fetch should echo query string arg'); 33 | t.end(); 34 | }); 35 | }); 36 | --------------------------------------------------------------------------------