;;;; SPDX-FileCopyrightText: Atlas Engineer LLC ;;;; SPDX-License-Identifier: BSD-3-Clause (in-package :electron/examples) (defun electron-asset-example () (setf electron:*interface* (make-instance 'electron:interface) (electron:protocols electron:*interface*) (list (make-instance 'electron:protocol :scheme-name "test" :privileges "{}") (make-instance 'electron:protocol :scheme-name "resxyz" :privileges "{}"))) (electron:launch electron:*interface*) (let* ((win (make-instance 'electron:browser-window)) (font-vector (alexandria:read-file-into-byte-vector "/home/jmercouris/Source/Lisp/cl-electron/examples/mono.ttf")) (style (lass:compile-and-write '(:font-face :font-family "xyz" :src "url('resxyz:salmon')" "format('ttf')") '(p :font-family "xyz"))) (html (spinneret:with-html-string (:head (:style (:raw style))) (:body (:p "Hello world")))) (contents (electron:web-contents win))) (electron:handle (find "test" (electron:protocols electron:*interface*) :key #'electron:scheme-name :test #'string-equal) "() => {return new Response('Hello test scheme.')}") (electron:handle-callback (find "resxyz" (electron:protocols electron:*interface*) :key #'electron:scheme-name :test #'string-equal) (lambda (xyz) (declare (ignore xyz)) (values font-vector "application/x-font-ttf"))) (electron:load-url win "test:salmon") (electron:execute-javascript-synchronous contents (ps:ps (setf (ps:chain document (get-elements-by-tag-name "html") 0 |innerHTML|) (ps:lisp html)))) (electron:open-dev-tools contents) (electron:load-url win "resxyz:salmon") win)) (electron:terminate) (electron-asset-example)