ionic-team / capacitor Goto Github PK
View Code? Open in Web Editor NEWBuild cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
Home Page: https://capacitorjs.com
License: MIT License
Build cross-platform Native Progressive Web Apps for iOS, Android, and the Web ⚡️
Home Page: https://capacitorjs.com
License: MIT License
The CLI should support a quiet, non-interactive mode. Additionally, any prompts should be flaggable from the CLI to enable CI/etc.
We now own capacitorapp.net for using in local capacitor apps
For filesystem API
This is for an example project, but as you know, our team doesn't consider this to be a best-practice. Maybe guide users to a better spot, but let them know how to opt out.
// In some cases, a package/library won't have declaration files for TypeScript.
// Depending on your settings, TypeScript may issue errors when importing an untyped library.
// To get around that, write your own .d.ts files, or add a line such as
//
// declare module "your-package-name-here";
//
// If you want to get rid of these errors entirely, you can use a wildcard path as so:
//
// declare module "*";
//
// But be careful! This will permit invalid imports, and give no verification for untyped modules.
See: Geolocation
Then it's in one place
Placeholder issue for Android compatibility for Cordova plugins
Right now ios calls load first time a plugin has been called. Android instead has just a load that gets called right after the constructor
I'm leaning towards doing load right after constructor, as any slow operations can be deferred through queuing and such
@mlynch, Readme
I'm trying to run the example app on android and when the app launches, it crashes immediately. Here's the relevant stack trace from logcat. Device I'm using is a Samsung Galaxy S8+ running Android 8.0. I'm compiling on Windows 10 in android Studio 3.0.
01-23 20:25:26.068 24749-24749/com.getcapacitor.myapp E/Capacitor: Unable to export Capacitor JS. App will not function!
com.getcapacitor.JSExportException: Unable to load native-bridge.js. Capacitor will not function!
at com.getcapacitor.JSExport.getCoreJS(JSExport.java:30)
at com.getcapacitor.Bridge.getJSInjector(Bridge.java:396)
at com.getcapacitor.Bridge.(Bridge.java:125)
at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:45)
at com.getcapacitor.BridgeActivity.onCreate(BridgeActivity.java:35)
at com.getcapacitor.myapp.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:7174)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.io.FileNotFoundException: public/native-bridge.js
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:388)
at android.content.res.AssetManager.open(AssetManager.java:362)
at com.getcapacitor.JSExport.getCoreJS(JSExport.java:20)
at com.getcapacitor.Bridge.getJSInjector(Bridge.java:396)
at com.getcapacitor.Bridge.(Bridge.java:125)
at com.getcapacitor.BridgeActivity.load(BridgeActivity.java:45)
at com.getcapacitor.BridgeActivity.onCreate(BridgeActivity.java:35)
at com.getcapacitor.myapp.MainActivity.onCreate(MainActivity.java:11)
at android.app.Activity.performCreate(Activity.java:7174)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2908)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
01-23 20:25:26.113 24749-24846/com.getcapacitor.myapp A/chromium: [FATAL:jni_android.cc(243)] Please include Java exception stack in crash report
Otherwise two apps listening on the same port will clash (iOS only right now)
Windows can't handle the love of the emoji in the CLI. We should downgrade accordingly to avoid missing character boxes.
😭😭😭😭😭😭😭😭😭
How can we help apps handle background events even if the app is closed?
In particular, we aren't properly cleaning up a callback in this case:
Plugin method uses a callback. Callback is retained by bridge (for example, watchPosition in Geo plugin). Callback is then removed when (ex: clearWatch) clear is called. Callback is not cleared from the client in this case
My gut says E2E testing is going to be easier than unit testing plugins and mocking native APIs. Perhaps we need an app that tests each plugin at the JS layer, or doing something at the native layer. Would be awesome to only have to write it once.
Should we go with "change" or "changed"? That is the great question
ex:
addListener('networkStatusChanged'...
// vs
addListener('networkStatusChange', ...
do it
Placeholder issue for us to figure out our Cordova backwards-compatibility strategy and the implications
Test this case: trigger Camera.getPhoto
, remove permission while camera is open, come back to the app. RIght now it clears the session, but can we reload the state?
Nice error UI for dev-mode when errors happen
capacitor update
clean requirement for iOS? (needed to clean in Xcode before build would succeed) @jcesarmobilenative-bridge.js
gets copied with capacitor copy
OR with installing the core commandcapacitor update
for pod files to node_modules
, instead of the absolute path? @jcesarmobileSupport empty options catchall object
Several native calls have hardcoded strings for titles/etc. Enable i18n on this
Is there any future plans to support windows 10? There are now almost 1 billion windows 10 devices out there and more being added all the time.
If we reload the app we should clear out all stored/remembered callbacks and saved calls
C:\Projects\Capacitor
λ git clone https://github.com/ionic-team/capacitor-starter my-app
Cloning into 'my-app'...
remote: Counting objects: 12, done.
remote: Compressing objects: 100% (8/8), done.
remote: Total 12 (delta 2), reused 12 (delta 2), pack-reused 0
Unpacking objects: 100% (12/12), done.
C:\Projects\Capacitor
λ cd my-app
C:\Projects\Capacitor\my-app (master -> origin) ([email protected])
λ npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
added 155 packages in 11.61s
C:\Projects\Capacitor\my-app (master -> origin) ([email protected])
λ npm run capacitor init
> [email protected] capacitor C:\Projects\Capacitor\my-app
> capacitor "init"
⚡️ Initializing Capacitor project in C:\Projects\Capacitor\my-app ⚡️
? Is this a new app? Answer 'n' if adding Capacitor to an existing project y
√ Creating capacitor.config.json in 3.19ms
√ Downloading and installing seed project in 1.69s
√ Installing dependencies for seed project (npm install) in 3.26s
√ Installing Capacitor dependencies (npm install --save @capacitor/core@latest @capacitor/cli@latest) in 12.77s
√ Adding native android project in: C:\Projects\Capacitor\my-app\android in 85.23ms
√ Adding native platforms in 95.32ms
🎉 Your Capacitor project is ready to go! 🎉
Follow the Getting Started guide for next steps:
https://capacitor.ionicframework.com/docs/getting-started
C:\Projects\Capacitor\my-app (master -> origin) ([email protected])
λ ls
android/ capacitor.config.json node_modules/ package.json package-lock.json public/ README.md
C:\Projects\Capacitor\my-app (master -> origin) ([email protected])
λ npm run capacitor copy android
> [email protected] capacitor C:\Projects\Capacitor\my-app
> capacitor "copy" "android"
√ Copying web assets from public to android\app\src\main\assets\public in 27.10ms
C:\Projects\Capacitor\my-app (master -> origin) ([email protected])
λ npm run capacitor open android
> [email protected] capacitor C:\Projects\Capacitor\my-app
> capacitor "open" "android"
[info] Opening Android project at C:\Projects\Capacitor\my-app\android
C:\Projects\Capacitor\my-app (master -> origin) ([email protected])
λ
Nothing happens.
One difference between Capacitor and Cordova is that Cordova copies your source files directly next to your app source files. This makes it possible for plugins to do things, like, extend AppDelegate
. We don't allow that as plugins are provided through linked frameworks that don't have access to app source.
To work around this, we should think about an abstracted native event handling system that makes it easy for a plugin to handle an AppDelegate method without having to do any extensions or anything.
Link: https://ionic-team.github.io/capacitor/
Screenshot:
Currently no way to cancel a watch
capacitor update ios
✔ Fetching plugins in 157.53ms
[error] TypeError: Cannot read property 'clobbers' of undefined
at jsModules.map (/Users/mhartington/GitHub/tmp2/node_modules/@capacitor/cli/dist/ios/update.js:115:22)
at Array.map (<anonymous>)
at plugins.map (/Users/mhartington/GitHub/tmp2/node_modules/@capacitor/cli/dist/ios/update.js:113:19)
at Array.map (<anonymous>)
at generateCordovaPluginsJSFile (/Users/mhartington/GitHub/tmp2/node_modules/@capacitor/cli/dist/ios/update.js:111:13)
at copyPluginsJS (/Users/mhartington/GitHub/tmp2/node_modules/@capacitor/cli/dist/ios/update.js:38:47)
at Object.updateIOS (/Users/mhartington/GitHub/tmp2/node_modules/@capacitor/cli/dist/ios/update.js:16:11)
at <anonymous>```
Can enable/disable from the dev menu, perhaps
Page navigations/etc. will require us to re-add our special JS magic
Caching doesn't make sense for a local app and will only cause dev challenges
But only if they've enabled ad framework, such that it won't trigger a deny from Apple
We should auto generate documentation for the iOS and Android platforms and each API we offer (camera, etc.).
We need to figure out how to mix this into a site that has some non-generated content, or decide if we want to have the full docs specified in some source code repo, like our JS library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.