WebDomHandling - A Swift Package for handling JavaScript code between WebKit and Swift implemented by WebKit

Overview

WebDomHandling

A Swift Package for handling JavaScript code between WebKit and Swift implemented by WebKit.

Quick Start

Importtant

You have to set delegate to able to handle the result and error return from WKWebView,

You can initialize the webObject for JavaScript environment by calling:

import WebDomHandling

let webObject = WDWebObject()
webObject.delegate = self

Or yu can call initialize it with a source of JavaScript code and website URL:

let webObject = WDWebObject(
    forResource: "path/of/your/JavaScript-Code",
    url: "https://url/to/your/websites")

forResource doesn't need js extension name. You just need to type your filename.

Example: WDWebObject(forResource: "script")

You can also inherit it with the following code:

class ExampleWebObject: WDWebObject, WDWebObjectDelegate {
    
    override init() {
        super.init()
        
        delegate = self

        loadJavaScriptString(forResource: "script")
        load("https://url/to/your/websites")
    }

    // Protocol implementation.
    func webView(_ webView: WKWebView, didFinishEvaluateJavaScript result: String) {
        // handle result...
    }
    
    func webView(_ webView: WKWebView, didFailEvaluateJavaScript error: String) {
        // handle error...
    }
}

WDWebObjectDelegate

it has 2 functions:

  • func webView(_ webView: WKWebView, didFinishEvaluateJavaScript result: String) for handling result return from WKWebView.
  • func webView(_ webView: WKWebView, didFailEvaluateJavaScript error: String) for handling error return from WKWebView.

For example of delegate implementation, check Example.swift, this example shows how to implement delegation in SwiftUI.

You might also like...
A Swift package that provides convenient Lorem Ipsum text, images, colors and other placeholders for rapidly prototyping, building and testing your iOS applications.
A Swift package that provides convenient Lorem Ipsum text, images, colors and other placeholders for rapidly prototyping, building and testing your iOS applications.

Lorem Introducing Lorem, a placeholder generator library for iOS to help you rapidly prototype, build and test your iOS applications. By leveraging Sw

A Swift package for encoding and decoding Swift Symbol Graph files.
A Swift package for encoding and decoding Swift Symbol Graph files.

SymbolKit The specification and reference model for the Symbol Graph File Format. A Symbol Graph models a module, also known in various programming la

A corresponding package to RxKotlin Plus, but for Swift and iOS

A corresponding package to RxKotlin Plus, but for Swift and iOS

An IPFS client/api Swift Package, with the ability to add and pin any data on iOS/iPadOS/macOS

An IPFS client/api Swift Package, with the ability to add and pin any data on iOS/iPadOS/macOS. Originally bundled with GraniteUI, pulled out for independant use by any party.

Flutter package for detecting NSFW images and videos using native implementation

Flutter NSFW 1- Download, tflite modle and put it in assets folder 2 - Add the path of the tfliet to pubspec.yaml 3 - Read the file using path_provide

FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app
FlutterNativeDragAndDrop - A package that allows you to add native drag and drop support into your flutter app

native_drag_n_drop A package that allows you to add native drag and drop support

This is a Swift Package bundling different Train APIs into one simple Swift interface.

This is a Swift Package bundling different Train APIs into one simple Swift interface.

This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package.

This repository hosts the PushwooshGeozones iOS SDK as an XCFramework based Swift Package. Use this repository's Swift Package in Xcode 12+

SafeDecoder - a swift package that set defaults when Codable fails to decode a field

SafeDecoder is a swift package that set defaults when Codable fails to decode a field. SafeDecoder supports configurable default values, See SafeDecoder.Configuration.

Releases(1.0.1)
Owner
null
Inject JavaScript to all websites!

Inject Javascript Safari Extension Hi, so, you want to Inject Javascript to a website? Great. Since this is a very basic (demo) project it has not tha

Wesley De Groot 6 Jun 7, 2022
PokePicker - a web application in JavaScript/VSCode with Google Firebase as the database

We would like to create a web application in JavaScript/VSCode with Google Firebase as the database. We want to make a Pokemon team creator

Saima Teasha 1 Aug 4, 2022
Signal Handling with more normal Swift conventions

SignalHandler Adds support for signal handlers in a fully swifty way. Why this over raw signal handling or other packages. Signal handler functions ar

Braden Scothern 2 Apr 3, 2022
Near Procedure Call between flutter and native.

npcx A new flutter plugin project. Getting Started This project is a starting point for a Flutter plug-in package, a specialized package that includes

null 0 Jun 17, 2022
Calculate your tip and split the bill between any number of people

Calculate your tip and split the bill between any number of people

Tirupati Balan 6 Feb 9, 2022
Bridge between onfido-auth and react-native

react-native-onfido-auth-sdk Table of contents Overview Installation Usage 1. Creating the SDK configuration 2. Parameter details 3. Success Response

null 1 Mar 30, 2022
A Simple way help you drop or drag your source (like UIImage) between different App.

A Simple way help you drop or drag your source (like UIImage) between different App.

逸风 13 Nov 24, 2022
a playground app using `MultipeerConnectivity` to transfor data wirelessly between iOS / iPadOS

README An example app using MultipeerConnectivity to transfor data wirelessly between iOS / iPadOS. Both using Data and Stream to transfer data are su

null 3 Aug 6, 2022
An iOS app that resolves issues of dividing the debt between roomates.

An iOS app that resolves issues of dividing the debt between roomates.

Jason Mai 2 Jun 12, 2022
MQTagged provides a Tagged structure which helps differentiating between values of the same type.

MQTagged provides a Tagged structure which helps differentiating between values of the same type.

Miquido 2 Jun 29, 2022