wv-context
1 Overview
wv-context%
new
context
settings
base-url
9.1

wv-context🔗ℹ

Hans Dijkema <hans@dijkewijk.nl>

 (require wv-context)

1 Overview🔗ℹ

The library is organized around two main concepts: contexts and windows.

A context represents the shared runtime environment for one or more webview windows. It owns the underlying webview context, provides the base URL used by those windows, and gives access to persistent settings through wv-settings.

A context stores both JavaScript and CSS boilerplate. The JavaScript boilerplate is passed to the native runtime, while the CSS boilerplate is injected into HTML documents served by the local HTTPS server.

This module exports the wv-context% class.

class

wv-context% : class?

  superclass: object%

Represents a webview context.
A wv-context% object is a thin class-based wrapper around the higher-level context support provided by racket-webview. It creates and stores a wv-context value internally and provides methods to access that value, its base URL, and a settings object.

constructor

(new wv-context% 
    [base-path base-path] 
    [[file-getter file-getter] 
    [context-js context-js] 
    [context-css context-css] 
    [boilerplate-js boilerplate-js] 
    [boilerplate-css boilerplate-css] 
    [ini ini]]) 
  (is-a?/c wv-context%)
  base-path : path-string?
  file-getter : procedure?
   = (webview-standard-file-getter base-path)
  context-js : procedure? = (λ () "")
  context-css : procedure? = (λ () "")
  boilerplate-js : string?
   = (webview-default-boilerplate-js context-js)
  boilerplate-css : string?
   = (webview-default-boilerplate-css context-css)
  ini : any/c
   = 
(error
 (string-append "You need to provide a 'ini' "
                "file settings interface for "
                "settings, e.g. simple-ini/class"))
Creates a new context object.

The constructor accepts the following initialization fields.

  • base-path is the base path used by the default file getter.

  • file-getter is the procedure used to resolve files for the local web server. Its default value is (webview-standard-file-getter base-path).

  • context-js is a procedure producing additional JavaScript for the context. Its default value is (λ () "").

  • context-css is a procedure producing additional CSS for the context. Its default value is (λ () "").

  • boilerplate-js is the JavaScript boilerplate installed into the underlying webview context. Its default value is (webview-default-boilerplate-js context-js).

  • boilerplate-css is the CSS boilerplate stored in the context and injected into HTML documents. Its default value is (webview-default-boilerplate-css context-css).

  • ini is the settings backend used to construct the associated wv-settings% object. No default backend is provided; omitting it raises an error.

After super-new, the constructor creates the underlying wv-context value using webview-new-context, and then creates a settings object using:

(new wv-settings% [ini ini] [wv-context 'global])

The settings object is stored internally and used by the settings method.

method

(send a-wv-context context)  wv-context?

Returns the internal context value created by webview-new-context.

This is the underlying racket-webview context object used by the rest of the library.

method

(send a-wv-context settings section)  wv-settings%

  section : symbol?
Returns a cloned settings object for section.

The method delegates to the internal wv-settings% instance as:

(send settings-obj clone section)

This allows per-section settings access while preserving the original settings object stored by the context.

method

(send a-wv-context base-url)  string?

Returns the base URL of the underlying context.

The method delegates to wv-context-base-url applied to the internal context value.