Skip to content

Commit 49151eb

Browse files
committed
Modify how HyperApp JS code is included
1 parent 9719908 commit 49151eb

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

engine/hyperapp.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
11
package engine
22

3-
/*
4-
5-
HyperApp MIT LICENSE for the JavaScript code below
6-
--------------------------------------------------
3+
import (
4+
_ "embed"
5+
)
76

7+
/*
8+
HyperApp MIT LICENSE for the HyperApp JavaScript code
9+
-----------------------------------------------------
810
Copyright © 2017-present Jorge Bucaran
9-
1011
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
11-
1212
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13-
1413
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1514
*/
1615

17-
// From https://unpkg.com/hyperapp, version 0.15.1
18-
var hyperAppJSBytes = []byte(`!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.hyperapp={})}(this,function(e){"use strict";function n(e,n){var t,i=[];for(r=arguments.length;r-- >2;)o.push(arguments[r]);for(;o.length;)if(Array.isArray(t=o.pop()))for(r=t.length;r--;)o.push(t[r]);else null!=t&&!0!==t&&!1!==t&&i.push("number"==typeof t?t+="":t);return"string"==typeof e?{type:e,props:n||{},children:i}:e(n||{},i)}function t(e,t){function r(){e.view&&!m&&requestAnimationFrame(o,m=!m)}function o(){i(b=v(t,b,k,k=e.view(g,w),m=!m))}function i(e){for(;e=A.pop();)e()}function u(e,t){return e&&n(e.tagName.toLowerCase(),{},t.call(e.childNodes,function(e){return 3===e.nodeType?e.nodeValue:u(e,t)}))}function p(e,n,t){e.init&&A.push(function(){e.init(n,t)}),c(n,e.state),f(n,t,e.actions);for(var r in e.modules)p(e.modules[r],n[r]={},t[r]={})}function f(e,n,t){function o(n){return"function"==typeof n?o(n(e)):n&&r(c(e,n)),e}Object.keys(t||{}).map(function(r){"function"==typeof t[r]?n[r]=function(i){return"function"==typeof(i=t[r](e,n,i))?i(o):o(i)}:f(e[r]||(e[r]={}),n[r]={},t[r])})}function c(e,n){for(var t in n)e[t]=n[t];return e}function l(e,n){return c(c({},e),n)}function s(e,n){if("string"==typeof e)var t=document.createTextNode(e);else{var t=(n=n||"svg"===e.type)?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type);e.props&&e.props.oncreate&&A.push(function(){e.props.oncreate(t)});for(var r=0;r<e.children.length;r++)t.appendChild(s(e.children[r],n));for(var r in e.props)a(t,r,e.props[r])}return t}function a(e,n,t,r){if("key"===n);else if("style"===n)for(var n in l(r,t=t||{}))e.style[n]=t[n]||"";else{try{e[n]=t}catch(e){}"function"!=typeof t&&(t?e.setAttribute(n,t):e.removeAttribute(n))}}function d(e,n,t){for(var r in l(n,t)){var o=t[r],i="value"===r||"checked"===r?e[r]:n[r];o!==i&&o!==i&&a(e,r,o,i)}t&&t.onupdate&&A.push(function(){t.onupdate(e,n)})}function y(e,n,t){function r(){e.removeChild(n)}t&&t.onremove&&"function"==typeof(t=t.onremove(n))?t(r):r()}function h(e){if(e&&e.props)return e.props.key}function v(e,n,t,r,o,i){if(null==t)n=e.insertBefore(s(r,o),n);else if(null!=r.type&&r.type===t.type){d(n,t.props,r.props),o=o||"svg"===r.type;for(var u=r.children.length,p=t.children.length,f={},c=[],l={},a=0;a<p;a++){var m=c[a]=n.childNodes[a],g=t.children[a],w=h(g);null!=w&&(f[w]=[m,g])}for(var a=0,b=0;b<u;){var m=c[a],g=t.children[a],k=r.children[b],w=h(g);if(l[w])a++;else{var A=h(k),N=f[A]||[];null==A?(null==w&&(v(n,m,g,k,o),b++),a++):(w===A?(v(n,N[0],N[1],k,o),a++):N[0]?(n.insertBefore(N[0],m),v(n,N[0],N[1],k,o)):v(n,m,null,k,o),b++,l[A]=k)}}for(;a<p;){var g=t.children[a],w=h(g);null==w&&y(n,c[a],g.props),a++}for(var a in f){var N=f[a],x=N[1];l[x.props.key]||y(n,N[0],x.props)}}else n&&r!==n.nodeValue&&("string"==typeof r&&"string"==typeof t?n.nodeValue=r:(n=e.insertBefore(s(r,o),i=n),y(e,i,t.props)));return n}var m,g,w,b=(t=t||document.body).children[0],k=u(b,[].map),A=[];return r(i(p(e,g={},w={}))),w}var r,o=[];e.h=n,e.app=t});`)
16+
// From https://unpkg.com/hyperapp, version 0.15.1 (latest version is 2.0.22). TODO: Upgrade.
17+
//
18+
//go:embed hyperapp.js
19+
var hyperAppJSBytes []byte

engine/hyperapp.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)