nativescript-community / ui-webview

Extended WebView which adds many options such as custom scheme handlers, JavaScript execution, URL capturing, and more.
Apache License 2.0
13 stars 7 forks source link

iOS - Add debug mode + emit events without data #13

Closed sebj54 closed 7 months ago

sebj54 commented 7 months ago

Hi @farfromrefug!

Here is a PR fixing two bugs.

About the issue with events emission, I noticed it in my app and decided to handle it the same way it is handled on Android.

I also wanted to fix the Webpack issue reported in #9, but I don't know what is the best way. Personnaly, I would completely get rid of the normalizeUrl part and use urls as they are. What do you think?

farfromrefug commented 7 months ago

@sebj54 that seem fine to me. and I agree let s drop normalizeUrl. can you do this in this PR?

sebj54 commented 7 months ago

Yes, sure! I will do this during the day

sebj54 commented 7 months ago

I've tried to build to check if it works on a real project, but I'm actually stuck with an error thrown by Lerna:

yarn build
lerna notice cli v8.0.0

 >  Lerna (powered by Nx)   Running target build for 2 projects
    ✖  @nativescript-community/ui-webview:build
       > @nativescript-community/ui-webview@1.4.9 build.www
       > cd ../../www-src && rollup -c && cd .. && ts-node make-bridge-loader

       bridge.android.ts → ../build/bridge.android.js...
       created ../build/bridge.android.js in 1.2s

       bridge.ios.ts → ../build/bridge.ios.js...
       created ../build/bridge.ios.js in 957ms

       metadata-view-port.ts → ../build/metadata-view-port.js...
       created ../build/metadata-view-port.js in 688ms

       > @nativescript-community/ui-webview@1.4.9 tsc
       > cpy '**/*.d.ts' '../../packages/webview' --parents --cwd=../../src/webview && tsc -skipLibCheck -d

       ../../src/webview/index.android.ts:871:18 - error TS2339: Property 'setAppCachePath' does not exist on type 'WebSettings'.

       871         settings.setAppCachePath(pth);
                            ~~~~~~~~~~~~~~~

       ../../src/webview/index.android.ts:872:18 - error TS2339: Property 'setAppCacheEnabled' does not exist on type 'WebSettings'.

       872         settings.setAppCacheEnabled(!!pth);
                            ~~~~~~~~~~~~~~~~~~

       Found 2 errors in the same file, starting at: ../../src/webview/index.android.ts:871

       npm ERR! Lifecycle script `tsc` failed with error:
       npm ERR! Error: command failed
       npm ERR!   in workspace: @nativescript-community/ui-webview@1.4.9
       npm ERR!   at location: /Users/sebjean/projects/ui-webview/packages/webview

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  Lerna (powered by Nx)   Ran target build for 2 projects (14s)

    ✔    0/1 succeeded [0 read from cache]

    ✖    1/1 targets failed, including the following:
         - @nativescript-community/ui-webview:build

It seems to be a false positive but I can't figure out how to fix this.

Also, I had to tweak some yarn and npm related files, I will submit them with the PR, so be sure to check if my changes are relevant when it will be ready to merge.

farfromrefug commented 7 months ago

@sebj54 does vscode report the same errors? Please dont submit npm/yarn changes in this PR. either create a new one or create an issue to explain the issue you have with it So the PR is ready from your side?

sebj54 commented 7 months ago

PR is ready but I couldn't test the build. Vscode does not report the same error, I don't know what's wrong on Lerna's side. Maybe it is because android.webkit.WebSettings is a class and a namespace at the same time.

Ok I won't submit any other change then!

farfromrefug commented 7 months ago

@sebj54 ok the issue is not in lerna but in tsc from the command line. Lerna is only there to run the tsc command.

sebj54 commented 7 months ago

Ok then, let me know when it's published, I will test it right away

farfromrefug commented 7 months ago

@sebj54 it is released. BTW the lint error was 100% normal and i am glad we got it. That api was removed from android

sebj54 commented 7 months ago

@farfromrefug Everything works fine!

BTW the lint error was 100% normal and i am glad we got it. That api was removed from android

Oh I see! typings were outdated then? Glad you found the issue, it would have taken me so long to find out