Skip to content
This repository was archived by the owner on Jan 10, 2024. It is now read-only.

Commit b723062

Browse files
committed
chore: rebuild native-code for iOS
1 parent 01809d1 commit b723062

File tree

14 files changed

+59
-21
lines changed

14 files changed

+59
-21
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ demo/report/stats.json
2424
package-lock.json
2525
typings
2626
tests/test-runner/index.d.ts
27+
tests/tsconfig.tns.json

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The custom `NSURLProtocol` used with UIWebView is shared with all instances of t
5656
| loadUrl(src: string): Promise<LoadFinishedEventData> | Open a URL and returns a promise once it has finished loading. |
5757
| registerLocalResource(resourceName: string, path: string): void; | Map the "x-local://{resourceName}" => "{path}". |
5858
| unregisterLocalResource(resourceName: string): void; | Removes the mapping from "x-local://{resourceName}" => "{path}" |
59-
| getRegistretLocalResource(resourceName: string): void; | Get the mapping from "x-local://{resourceName}" => "{path}" |
59+
| getRegisteredLocalResource(resourceName: string): void; | Get the mapping from "x-local://{resourceName}" => "{path}" |
6060
| loadJavaScriptFile(scriptName: string, filepath: string) | Inject a javascript-file into the webview. Should be called after the `loadFinishedEvent` |
6161
| loadStyleSheetFile(stylesheetName: string, filepath: string, insertBefore: boolean) | Loads a CSS-file into document.head. If before is true, it will be added to the top of document.head otherwise as the last element |
6262
| loadJavaScriptFiles(files: {resourceName: string, filepath: string}[]) | Inject multiple javascript-files into the webview. Should be called after the `loadFinishedEvent` |

src/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
"run.http-server": "cd ../demo/www && npx hs -p 8080",
3030
"run.demo.android": "cd ../demo && tns run android --syncAllFiles",
3131
"run.demo.ios": "cd ../demo && tns run ios --syncAllFiles",
32-
"run.test.android": "cd ../tests && tns run android --syncAllFiles",
33-
"run.test.ios": "cd ../tests && tns run ios --syncAllFiles",
32+
"run.test.android": "cd ../tests && tns run android --syncAllFiles --bundle",
33+
"run.test.ios": "cd ../tests && tns run ios --syncAllFiles --bundle",
3434
"demo.ios": "npm run build && npm-run-all --parallel build:webview-bridge:watch plugin.tscwatch run.demo.ios run.http-server",
3535
"demo.android": "npm run build && npm-run-all --parallel build:webview-bridge:watch plugin.tscwatch run.demo.android run.http-server",
3636
"demo.reset": "git clean -d -x -f ../demo && npm install",

src/platforms/ios/NotaWebViewExt.framework/Headers/NotaWebViewExt-Swift.h

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Generated by Apple Swift version 4.1.2 (swiftlang-902.0.54 clang-902.0.39.2)
1+
// Generated by Apple Swift version 4.2 effective-4.1.50 (swiftlang-1000.11.37.1 clang-1000.11.45.1)
22
#pragma clang diagnostic push
33
#pragma clang diagnostic ignored "-Wgcc-compat"
44

@@ -129,17 +129,17 @@ typedef unsigned int swift_uint4 __attribute__((__ext_vector_type__(4)));
129129
#endif
130130
#if !defined(SWIFT_ENUM_ATTR)
131131
# if defined(__has_attribute) && __has_attribute(enum_extensibility)
132-
# define SWIFT_ENUM_ATTR __attribute__((enum_extensibility(open)))
132+
# define SWIFT_ENUM_ATTR(_extensibility) __attribute__((enum_extensibility(_extensibility)))
133133
# else
134-
# define SWIFT_ENUM_ATTR
134+
# define SWIFT_ENUM_ATTR(_extensibility)
135135
# endif
136136
#endif
137137
#if !defined(SWIFT_ENUM)
138-
# define SWIFT_ENUM(_type, _name) enum _name : _type _name; enum SWIFT_ENUM_ATTR SWIFT_ENUM_EXTRA _name : _type
138+
# define SWIFT_ENUM(_type, _name, _extensibility) enum _name : _type _name; enum SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
139139
# if __has_feature(generalized_swift_name)
140-
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR SWIFT_ENUM_EXTRA _name : _type
140+
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) enum _name : _type _name SWIFT_COMPILE_NAME(SWIFT_NAME); enum SWIFT_COMPILE_NAME(SWIFT_NAME) SWIFT_ENUM_ATTR(_extensibility) SWIFT_ENUM_EXTRA _name : _type
141141
# else
142-
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME) SWIFT_ENUM(_type, _name)
142+
# define SWIFT_ENUM_NAMED(_type, _name, SWIFT_NAME, _extensibility) SWIFT_ENUM(_type, _name, _extensibility)
143143
# endif
144144
#endif
145145
#if !defined(SWIFT_UNAVAILABLE)
@@ -219,7 +219,7 @@ SWIFT_CLASS("_TtC14NotaWebViewExt22CustomUrlSchemeHandler") SWIFT_AVAILABILITY(i
219219
- (void)unregisterLocalResourceForKey:(NSString * _Nonnull)forKey;
220220
- (NSString * _Nullable)getRegisteredLocalResourceForKey:(NSString * _Nonnull)forKey SWIFT_WARN_UNUSED_RESULT;
221221
- (void)clearRegisteredLocalResource;
222-
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER;
222+
- (nonnull instancetype)init OBJC_DESIGNATED_INITIALIZER SWIFT_AVAILABILITY(ios,introduced=11.0);
223223
@end
224224

225225
#if __has_attribute(external_source_symbol)
Binary file not shown.
Binary file not shown.

src/webview-ext-common.ts

+41-5
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ export class WebViewExtBase extends View {
144144
*/
145145
public autoInjectJSBridge = true;
146146

147+
/**
148+
* Enable/disable debug-mode on android.
149+
*/
147150
public debugMode: boolean;
148151

149152
/**
@@ -156,14 +159,23 @@ export class WebViewExtBase extends View {
156159
*/
157160
protected autoInjectStyleSheetFiles = [] as LoadStyleSheetResource[];
158161

159-
/** List of code blocks to be executed after JS-files and CSS-files have been loaded. */
162+
/**
163+
* List of code blocks to be executed after JS-files and CSS-files have been loaded.
164+
*/
160165
protected autoInjectJavaScriptBlocks = [] as InjectExecuteJavaScript[];
161166

162-
/** Prevent this.src loading changes from the webview's onLoadFinished-event */
167+
/**
168+
* Prevent this.src loading changes from the webview's onLoadFinished-event
169+
*/
163170
protected tempSuspendSrcLoading = false;
164171

172+
/**
173+
* Callback for the loadFinished-event. Called from the native-webview
174+
*/
165175
public _onLoadFinished(url: string, error?: string): Promise<LoadFinishedEventData> {
166176
if (!error) {
177+
// When this is called without an error, update with this.src value without loading the url.
178+
// This is needed to keep src up-to-date when linked are clicked inside the webview.
167179
try {
168180
this.tempSuspendSrcLoading = true;
169181
this.src = url;
@@ -194,7 +206,7 @@ export class WebViewExtBase extends View {
194206
return this.injectWebViewBridge()
195207
.then(() => args)
196208
.catch((error) => {
197-
return Object.assign({}, args, {error});
209+
return Object.assign({}, args, { error });
198210
})
199211
.then((args) => {
200212
this.notify(args);
@@ -203,6 +215,12 @@ export class WebViewExtBase extends View {
203215
}
204216
}
205217

218+
/**
219+
* Callback for onLoadStarted-event from the native webview
220+
*
221+
* @param url URL being loaded
222+
* @param navigationType Type of navigation (iOS-only)
223+
*/
206224
public _onLoadStarted(url: string, navigationType?: NavigationType) {
207225
const args = {
208226
eventName: WebViewExtBase.loadStartedEvent,
@@ -214,6 +232,14 @@ export class WebViewExtBase extends View {
214232
this.notify(args);
215233
}
216234

235+
/**
236+
* Callback for should override url loading.
237+
* Called from the native-webview
238+
*
239+
* @param url
240+
* @param httpMethod GET, POST etc
241+
* @param navigationType Type of navigation (iOS-only)
242+
*/
217243
public _onShouldOverrideUrlLoading(url: string, httpMethod: string, navigationType?: NavigationType) {
218244
const args = {
219245
eventName: WebViewExtBase.shouldOverrideUrlLoadingEvent,
@@ -228,10 +254,16 @@ export class WebViewExtBase extends View {
228254
return args.cancel;
229255
}
230256

257+
/**
258+
* Platform specific loadURL-implementation.
259+
*/
231260
public _loadUrl(src: string): void {
232261
throw new Error("Method not implemented.");
233262
}
234263

264+
/**
265+
* Platform specific loadData-implementation.
266+
*/
235267
public _loadData(src: string): void {
236268
throw new Error("Method not implemented.");
237269
}
@@ -292,7 +324,7 @@ export class WebViewExtBase extends View {
292324

293325
if (src.startsWith(this.interceptScheme)) {
294326
this.writeTrace(`WebViewExt.src = "${originSrc}" resolve x-local file`);
295-
const fileparh = this.getRegistretLocalResource(src);
327+
const fileparh = this.getRegisteredLocalResource(src);
296328
if (fileparh) {
297329
src = `file://${fileparh}`;
298330
this.writeTrace(`WebViewExt.src = "${originSrc}" x-local resolved to "${src}"`);
@@ -377,7 +409,10 @@ export class WebViewExtBase extends View {
377409
throw new Error("Method not implemented.");
378410
}
379411

380-
public getRegistretLocalResource(name: string) {
412+
/**
413+
* Resolve a "x-local://{name}" to file-path.
414+
*/
415+
public getRegisteredLocalResource(name: string) {
381416
throw new Error("Method not implemented.");
382417
}
383418

@@ -391,6 +426,7 @@ export class WebViewExtBase extends View {
391426
if (!src) {
392427
return this._onLoadFinished(src, 'empty src');
393428
}
429+
394430
return new Promise<LoadFinishedEventData>((resolve, reject) => {
395431
const loadFinishedEvent = (args: LoadFinishedEventData) => {
396432
this.off(WebViewExtBase.loadFinishedEvent, loadFinishedEvent);

src/webview-ext.android.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ function initializeWebViewClient(): void {
129129
return super.shouldInterceptRequest(view, request);
130130
}
131131

132-
const filepath = owner.getRegistretLocalResource(url);
132+
const filepath = owner.getRegisteredLocalResource(url);
133133
if (!filepath) {
134134
owner.writeTrace(`WebViewClientClass.shouldInterceptRequest("${url}") - no matching file`);
135135
return super.shouldInterceptRequest(view, request);
@@ -395,12 +395,12 @@ export class WebViewExt extends WebViewExtBase {
395395
this.localResourceMap.delete(resourceName);
396396
}
397397

398-
public getRegistretLocalResource(resourceName: string) {
398+
public getRegisteredLocalResource(resourceName: string) {
399399
resourceName = this.fixLocalResourceName(resourceName);
400400

401401
const result = this.localResourceMap.get(resourceName);
402402

403-
this.writeTrace(`WebViewExt<android>.getRegistretLocalResource("${resourceName}") => "${result}"`);
403+
this.writeTrace(`WebViewExt<android>.getRegisteredLocalResource("${resourceName}") => "${result}"`);
404404

405405
return result;
406406
}

src/webview-ext.ios.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ export class WebViewExt extends WebViewExtBase {
281281
}
282282
}
283283

284-
public getRegistretLocalResource(resourceName: string) {
284+
public getRegisteredLocalResource(resourceName: string) {
285285
resourceName = this.fixLocalResourceName(resourceName);
286286

287287
let result: string;
@@ -293,7 +293,7 @@ export class WebViewExt extends WebViewExtBase {
293293
throw new Error('Not implemented for UIWebView');
294294
}
295295

296-
this.writeTrace(`WebViewExt<android>.getRegistretLocalResource("${resourceName}") -> "${result}"`);
296+
this.writeTrace(`WebViewExt<android>.getRegisteredLocalResource("${resourceName}") -> "${result}"`);
297297
return result;
298298
}
299299

tests/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
"byline": "^5.0.0",
3030
"filewalker": "0.1.2",
3131
"lazy": "1.0.11",
32-
"nativescript-dev-typescript": "^0.7.1",
3332
"nativescript-app-environment": "^1.0.0",
33+
"nativescript-dev-typescript": "^0.7.1",
34+
"nativescript-dev-webpack": "^0.16.1",
3435
"tns-platform-declarations": "~4.0.0",
3536
"ts-node": "^6.0.3",
3637
"tslib": "^1.9.1",

0 commit comments

Comments
 (0)