git.iko.soy/purestack-dev/purescript-plum
on master help sign in
10 files changed+481−4056
since splitsnapshots
unifiedsplit
.gitignore+1 plum/index.js−2976 plum/spago.dhall+5 plum/src/Main.purs+43−9 plum/src/Maquette.js−953 plum/src/Maquette.purs−33 plum/src/Plum.purs+58−29 plum/src/Plum/View.purs+328−56 plum/src/Snabbdom.js+1 plum/src/Snabbdom.purs+45
.gitignore+1
@@ -8,3 +8,4 @@
88/.purs*
99/.psa*
1010/.spago
11+plum/index.js
plum/index.jsdeleted−2976
@@ -1,2976 +0,0 @@
1−(() => {
2− // output/Control.Semigroupoid/index.js
3− var semigroupoidFn = {
4− compose: function(f) {
5− return function(g) {
6− return function(x) {
7− return f(g(x));
8− };
9− };
10− }
11− };
12−
13− // output/Control.Category/index.js
14− var identity = function(dict) {
15− return dict.identity;
16− };
17− var categoryFn = {
18− identity: function(x) {
19− return x;
20− },
21− Semigroupoid0: function() {
22− return semigroupoidFn;
23− }
24− };
25−
26− // output/Data.Function/index.js
27− var flip = function(f) {
28− return function(b) {
29− return function(a) {
30− return f(a)(b);
31− };
32− };
33− };
34− var applyFlipped = function(x) {
35− return function(f) {
36− return f(x);
37− };
38− };
39−
40− // output/Data.Functor/foreign.js
41− var arrayMap = function(f) {
42− return function(arr) {
43− var l = arr.length;
44− var result = new Array(l);
45− for (var i = 0; i < l; i++) {
46− result[i] = f(arr[i]);
47− }
48− return result;
49− };
50− };
51−
52− // output/Data.Unit/foreign.js
53− var unit = void 0;
54−
55− // output/Type.Proxy/index.js
56− var $$Proxy = /* @__PURE__ */ function() {
57− function $$Proxy2() {
58− }
59− ;
60− $$Proxy2.value = new $$Proxy2();
61− return $$Proxy2;
62− }();
63−
64− // output/Data.Functor/index.js
65− var map = function(dict) {
66− return dict.map;
67− };
68− var functorArray = {
69− map: arrayMap
70− };
71−
72− // output/Control.Apply/index.js
73− var apply = function(dict) {
74− return dict.apply;
75− };
76− var lift2 = function(dictApply) {
77− var apply1 = apply(dictApply);
78− var map4 = map(dictApply.Functor0());
79− return function(f) {
80− return function(a) {
81− return function(b) {
82− return apply1(map4(f)(a))(b);
83− };
84− };
85− };
86− };
87−
88− // output/Control.Applicative/index.js
89− var pure = function(dict) {
90− return dict.pure;
91− };
92− var liftA1 = function(dictApplicative) {
93− var apply2 = apply(dictApplicative.Apply0());
94− var pure1 = pure(dictApplicative);
95− return function(f) {
96− return function(a) {
97− return apply2(pure1(f))(a);
98− };
99− };
100− };
101−
102− // output/Control.Bind/foreign.js
103− var arrayBind = typeof Array.prototype.flatMap === "function" ? function(arr) {
104− return function(f) {
105− return arr.flatMap(f);
106− };
107− } : function(arr) {
108− return function(f) {
109− var result = [];
110− var l = arr.length;
111− for (var i = 0; i < l; i++) {
112− var xs = f(arr[i]);
113− var k = xs.length;
114− for (var j = 0; j < k; j++) {
115− result.push(xs[j]);
116− }
117− }
118− return result;
119− };
120− };
121−
122− // output/Control.Bind/index.js
123− var discard = function(dict) {
124− return dict.discard;
125− };
126− var bind = function(dict) {
127− return dict.bind;
128− };
129− var bindFlipped = function(dictBind) {
130− return flip(bind(dictBind));
131− };
132− var discardUnit = {
133− discard: function(dictBind) {
134− return bind(dictBind);
135− }
136− };
137−
138− // output/Data.Symbol/index.js
139− var reflectSymbol = function(dict) {
140− return dict.reflectSymbol;
141− };
142−
143− // output/Record.Unsafe/foreign.js
144− var unsafeGet = function(label4) {
145− return function(rec) {
146− return rec[label4];
147− };
148− };
149− var unsafeSet = function(label4) {
150− return function(value12) {
151− return function(rec) {
152− var copy = {};
153− for (var key in rec) {
154− if ({}.hasOwnProperty.call(rec, key)) {
155− copy[key] = rec[key];
156− }
157− }
158− copy[label4] = value12;
159− return copy;
160− };
161− };
162− };
163−
164− // output/Data.Semigroup/foreign.js
165− var concatString = function(s1) {
166− return function(s2) {
167− return s1 + s2;
168− };
169− };
170− var concatArray = function(xs) {
171− return function(ys) {
172− if (xs.length === 0) return ys;
173− if (ys.length === 0) return xs;
174− return xs.concat(ys);
175− };
176− };
177−
178− // output/Data.Semigroup/index.js
179− var semigroupUnit = {
180− append: function(v) {
181− return function(v1) {
182− return unit;
183− };
184− }
185− };
186− var semigroupString = {
187− append: concatString
188− };
189− var semigroupRecordNil = {
190− appendRecord: function(v) {
191− return function(v1) {
192− return function(v2) {
193− return {};
194− };
195− };
196− }
197− };
198− var semigroupArray = {
199− append: concatArray
200− };
201− var appendRecord = function(dict) {
202− return dict.appendRecord;
203− };
204− var semigroupRecord = function() {
205− return function(dictSemigroupRecord) {
206− return {
207− append: appendRecord(dictSemigroupRecord)($$Proxy.value)
208− };
209− };
210− };
211− var append = function(dict) {
212− return dict.append;
213− };
214− var semigroupRecordCons = function(dictIsSymbol) {
215− var reflectSymbol2 = reflectSymbol(dictIsSymbol);
216− return function() {
217− return function(dictSemigroupRecord) {
218− var appendRecord1 = appendRecord(dictSemigroupRecord);
219− return function(dictSemigroup) {
220− var append1 = append(dictSemigroup);
221− return {
222− appendRecord: function(v) {
223− return function(ra) {
224− return function(rb) {
225− var tail = appendRecord1($$Proxy.value)(ra)(rb);
226− var key = reflectSymbol2($$Proxy.value);
227− var insert = unsafeSet(key);
228− var get = unsafeGet(key);
229− return insert(append1(get(ra))(get(rb)))(tail);
230− };
231− };
232− }
233− };
234− };
235− };
236− };
237− };
238−
239− // output/Data.Monoid/index.js
240− var semigroupRecord2 = /* @__PURE__ */ semigroupRecord();
241− var monoidUnit = {
242− mempty: unit,
243− Semigroup0: function() {
244− return semigroupUnit;
245− }
246− };
247− var monoidString = {
248− mempty: "",
249− Semigroup0: function() {
250− return semigroupString;
251− }
252− };
253− var monoidRecordNil = {
254− memptyRecord: function(v) {
255− return {};
256− },
257− SemigroupRecord0: function() {
258− return semigroupRecordNil;
259− }
260− };
261− var monoidArray = {
262− mempty: [],
263− Semigroup0: function() {
264− return semigroupArray;
265− }
266− };
267− var memptyRecord = function(dict) {
268− return dict.memptyRecord;
269− };
270− var monoidRecord = function() {
271− return function(dictMonoidRecord) {
272− var semigroupRecord1 = semigroupRecord2(dictMonoidRecord.SemigroupRecord0());
273− return {
274− mempty: memptyRecord(dictMonoidRecord)($$Proxy.value),
275− Semigroup0: function() {
276− return semigroupRecord1;
277− }
278− };
279− };
280− };
281− var mempty = function(dict) {
282− return dict.mempty;
283− };
284− var monoidRecordCons = function(dictIsSymbol) {
285− var reflectSymbol2 = reflectSymbol(dictIsSymbol);
286− var semigroupRecordCons3 = semigroupRecordCons(dictIsSymbol)();
287− return function(dictMonoid) {
288− var mempty12 = mempty(dictMonoid);
289− var Semigroup0 = dictMonoid.Semigroup0();
290− return function() {
291− return function(dictMonoidRecord) {
292− var memptyRecord1 = memptyRecord(dictMonoidRecord);
293− var semigroupRecordCons1 = semigroupRecordCons3(dictMonoidRecord.SemigroupRecord0())(Semigroup0);
294− return {
295− memptyRecord: function(v) {
296− var tail = memptyRecord1($$Proxy.value);
297− var key = reflectSymbol2($$Proxy.value);
298− var insert = unsafeSet(key);
299− return insert(mempty12)(tail);
300− },
301− SemigroupRecord0: function() {
302− return semigroupRecordCons1;
303− }
304− };
305− };
306− };
307− };
308− };
309−
310− // output/Effect/foreign.js
311− var pureE = function(a) {
312− return function() {
313− return a;
314− };
315− };
316− var bindE = function(a) {
317− return function(f) {
318− return function() {
319− return f(a())();
320− };
321− };
322− };
323−
324− // output/Control.Monad/index.js
325− var ap = function(dictMonad) {
326− var bind4 = bind(dictMonad.Bind1());
327− var pure4 = pure(dictMonad.Applicative0());
328− return function(f) {
329− return function(a) {
330− return bind4(f)(function(f$prime) {
331− return bind4(a)(function(a$prime) {
332− return pure4(f$prime(a$prime));
333− });
334− });
335− };
336− };
337− };
338−
339− // output/Effect/index.js
340− var $runtime_lazy = function(name15, moduleName, init) {
341− var state3 = 0;
342− var val;
343− return function(lineNumber) {
344− if (state3 === 2) return val;
345− if (state3 === 1) throw new ReferenceError(name15 + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
346− state3 = 1;
347− val = init();
348− state3 = 2;
349− return val;
350− };
351− };
352− var monadEffect = {
353− Applicative0: function() {
354− return applicativeEffect;
355− },
356− Bind1: function() {
357− return bindEffect;
358− }
359− };
360− var bindEffect = {
361− bind: bindE,
362− Apply0: function() {
363− return $lazy_applyEffect(0);
364− }
365− };
366− var applicativeEffect = {
367− pure: pureE,
368− Apply0: function() {
369− return $lazy_applyEffect(0);
370− }
371− };
372− var $lazy_functorEffect = /* @__PURE__ */ $runtime_lazy("functorEffect", "Effect", function() {
373− return {
374− map: liftA1(applicativeEffect)
375− };
376− });
377− var $lazy_applyEffect = /* @__PURE__ */ $runtime_lazy("applyEffect", "Effect", function() {
378− return {
379− apply: ap(monadEffect),
380− Functor0: function() {
381− return $lazy_functorEffect(0);
382− }
383− };
384− });
385− var functorEffect = /* @__PURE__ */ $lazy_functorEffect(20);
386−
387− // output/Data.Array/foreign.js
388− var replicateFill = function(count, value12) {
389− if (count < 1) {
390− return [];
391− }
392− var result = new Array(count);
393− return result.fill(value12);
394− };
395− var replicatePolyfill = function(count, value12) {
396− var result = [];
397− var n = 0;
398− for (var i = 0; i < count; i++) {
399− result[n++] = value12;
400− }
401− return result;
402− };
403− var replicateImpl = typeof Array.prototype.fill === "function" ? replicateFill : replicatePolyfill;
404− var indexImpl = function(just, nothing, xs, i) {
405− return i < 0 || i >= xs.length ? nothing : just(xs[i]);
406− };
407− var concat = function(xss) {
408− if (xss.length <= 1e4) {
409− return Array.prototype.concat.apply([], xss);
410− }
411− var result = [];
412− for (var i = 0, l = xss.length; i < l; i++) {
413− var xs = xss[i];
414− for (var j = 0, m = xs.length; j < m; j++) {
415− result.push(xs[j]);
416− }
417− }
418− return result;
419− };
420−
421− // output/Data.Bounded/foreign.js
422− var topChar = String.fromCharCode(65535);
423− var bottomChar = String.fromCharCode(0);
424− var topNumber = Number.POSITIVE_INFINITY;
425− var bottomNumber = Number.NEGATIVE_INFINITY;
426−
427− // output/Data.Show/foreign.js
428− var showIntImpl = function(n) {
429− return n.toString();
430− };
431− var showNumberImpl = function(n) {
432− var str = n.toString();
433− return isNaN(str + ".0") ? str : str + ".0";
434− };
435−
436− // output/Data.Show/index.js
437− var showNumber = {
438− show: showNumberImpl
439− };
440− var showInt = {
441− show: showIntImpl
442− };
443− var show = function(dict) {
444− return dict.show;
445− };
446−
447− // output/Data.Maybe/index.js
448− var identity2 = /* @__PURE__ */ identity(categoryFn);
449− var Nothing = /* @__PURE__ */ function() {
450− function Nothing2() {
451− }
452− ;
453− Nothing2.value = new Nothing2();
454− return Nothing2;
455− }();
456− var Just = /* @__PURE__ */ function() {
457− function Just2(value0) {
458− this.value0 = value0;
459− }
460− ;
461− Just2.create = function(value0) {
462− return new Just2(value0);
463− };
464− return Just2;
465− }();
466− var maybe = function(v) {
467− return function(v1) {
468− return function(v2) {
469− if (v2 instanceof Nothing) {
470− return v;
471− }
472− ;
473− if (v2 instanceof Just) {
474− return v1(v2.value0);
475− }
476− ;
477− throw new Error("Failed pattern match at Data.Maybe (line 237, column 1 - line 237, column 51): " + [v.constructor.name, v1.constructor.name, v2.constructor.name]);
478− };
479− };
480− };
481− var fromMaybe = function(a) {
482− return maybe(a)(identity2);
483− };
484−
485− // output/Data.Identity/index.js
486− var Identity = function(x) {
487− return x;
488− };
489− var functorIdentity = {
490− map: function(f) {
491− return function(m) {
492− return f(m);
493− };
494− }
495− };
496− var applyIdentity = {
497− apply: function(v) {
498− return function(v1) {
499− return v(v1);
500− };
501− },
502− Functor0: function() {
503− return functorIdentity;
504− }
505− };
506− var bindIdentity = {
507− bind: function(v) {
508− return function(f) {
509− return f(v);
510− };
511− },
512− Apply0: function() {
513− return applyIdentity;
514− }
515− };
516− var applicativeIdentity = {
517− pure: Identity,
518− Apply0: function() {
519− return applyIdentity;
520− }
521− };
522− var monadIdentity = {
523− Applicative0: function() {
524− return applicativeIdentity;
525− },
526− Bind1: function() {
527− return bindIdentity;
528− }
529− };
530−
531− // output/Effect.Ref/foreign.js
532− var _new = function(val) {
533− return function() {
534− return { value: val };
535− };
536− };
537− var read = function(ref) {
538− return function() {
539− return ref.value;
540− };
541− };
542− var write = function(val) {
543− return function(ref) {
544− return function() {
545− ref.value = val;
546− };
547− };
548− };
549−
550− // output/Effect.Ref/index.js
551− var $$new = _new;
552−
553− // output/Control.Monad.ST.Internal/foreign.js
554− var map_ = function(f) {
555− return function(a) {
556− return function() {
557− return f(a());
558− };
559− };
560− };
561− var pure_ = function(a) {
562− return function() {
563− return a;
564− };
565− };
566− var bind_ = function(a) {
567− return function(f) {
568− return function() {
569− return f(a())();
570− };
571− };
572− };
573−
574− // output/Control.Monad.ST.Internal/index.js
575− var $runtime_lazy2 = function(name15, moduleName, init) {
576− var state3 = 0;
577− var val;
578− return function(lineNumber) {
579− if (state3 === 2) return val;
580− if (state3 === 1) throw new ReferenceError(name15 + " was needed before it finished initializing (module " + moduleName + ", line " + lineNumber + ")", moduleName, lineNumber);
581− state3 = 1;
582− val = init();
583− state3 = 2;
584− return val;
585− };
586− };
587− var functorST = {
588− map: map_
589− };
590− var monadST = {
591− Applicative0: function() {
592− return applicativeST;
593− },
594− Bind1: function() {
595− return bindST;
596− }
597− };
598− var bindST = {
599− bind: bind_,
600− Apply0: function() {
601− return $lazy_applyST(0);
602− }
603− };
604− var applicativeST = {
605− pure: pure_,
606− Apply0: function() {
607− return $lazy_applyST(0);
608− }
609− };
610− var $lazy_applyST = /* @__PURE__ */ $runtime_lazy2("applyST", "Control.Monad.ST.Internal", function() {
611− return {
612− apply: ap(monadST),
613− Functor0: function() {
614− return functorST;
615− }
616− };
617− });
618−
619− // output/Data.Foldable/foreign.js
620− var foldrArray = function(f) {
621− return function(init) {
622− return function(xs) {
623− var acc = init;
624− var len = xs.length;
625− for (var i = len - 1; i >= 0; i--) {
626− acc = f(xs[i])(acc);
627− }
628− return acc;
629− };
630− };
631− };
632− var foldlArray = function(f) {
633− return function(init) {
634− return function(xs) {
635− var acc = init;
636− var len = xs.length;
637− for (var i = 0; i < len; i++) {
638− acc = f(acc)(xs[i]);
639− }
640− return acc;
641− };
642− };
643− };
644−
645− // output/Data.Tuple/index.js
646− var Tuple = /* @__PURE__ */ function() {
647− function Tuple2(value0, value1) {
648− this.value0 = value0;
649− this.value1 = value1;
650− }
651− ;
652− Tuple2.create = function(value0) {
653− return function(value1) {
654− return new Tuple2(value0, value1);
655− };
656− };
657− return Tuple2;
658− }();
659−
660− // output/Unsafe.Coerce/foreign.js
661− var unsafeCoerce2 = function(x) {
662− return x;
663− };
664−
665− // output/Safe.Coerce/index.js
666− var coerce = function() {
667− return unsafeCoerce2;
668− };
669−
670− // output/Data.Newtype/index.js
671− var coerce2 = /* @__PURE__ */ coerce();
672− var unwrap = function() {
673− return coerce2;
674− };
675−
676− // output/Data.Foldable/index.js
677− var foldr = function(dict) {
678− return dict.foldr;
679− };
680− var foldl = function(dict) {
681− return dict.foldl;
682− };
683− var intercalate = function(dictFoldable) {
684− var foldl2 = foldl(dictFoldable);
685− return function(dictMonoid) {
686− var append3 = append(dictMonoid.Semigroup0());
687− var mempty5 = mempty(dictMonoid);
688− return function(sep) {
689− return function(xs) {
690− var go2 = function(v) {
691− return function(v1) {
692− if (v.init) {
693− return {
694− init: false,
695− acc: v1
696− };
697− }
698− ;
699− return {
700− init: false,
701− acc: append3(v.acc)(append3(sep)(v1))
702− };
703− };
704− };
705− return foldl2(go2)({
706− init: true,
707− acc: mempty5
708− })(xs).acc;
709− };
710− };
711− };
712− };
713− var foldMapDefaultR = function(dictFoldable) {
714− var foldr2 = foldr(dictFoldable);
715− return function(dictMonoid) {
716− var append3 = append(dictMonoid.Semigroup0());
717− var mempty5 = mempty(dictMonoid);
718− return function(f) {
719− return foldr2(function(x) {
720− return function(acc) {
721− return append3(f(x))(acc);
722− };
723− })(mempty5);
724− };
725− };
726− };
727− var foldableArray = {
728− foldr: foldrArray,
729− foldl: foldlArray,
730− foldMap: function(dictMonoid) {
731− return foldMapDefaultR(foldableArray)(dictMonoid);
732− }
733− };
734−
735− // output/Data.Function.Uncurried/foreign.js
736− var runFn2 = function(fn) {
737− return function(a) {
738− return function(b) {
739− return fn(a, b);
740− };
741− };
742− };
743− var runFn4 = function(fn) {
744− return function(a) {
745− return function(b) {
746− return function(c) {
747− return function(d) {
748− return fn(a, b, c, d);
749− };
750− };
751− };
752− };
753− };
754−
755− // output/Data.Traversable/foreign.js
756− var traverseArrayImpl = /* @__PURE__ */ function() {
757− function array1(a) {
758− return [a];
759− }
760− function array2(a) {
761− return function(b) {
762− return [a, b];
763− };
764− }
765− function array3(a) {
766− return function(b) {
767− return function(c) {
768− return [a, b, c];
769− };
770− };
771− }
772− function concat2(xs) {
773− return function(ys) {
774− return xs.concat(ys);
775− };
776− }
777− return function(apply2) {
778− return function(map4) {
779− return function(pure4) {
780− return function(f) {
781− return function(array) {
782− function go2(bot, top2) {
783− switch (top2 - bot) {
784− case 0:
785− return pure4([]);
786− case 1:
787− return map4(array1)(f(array[bot]));
788− case 2:
789− return apply2(map4(array2)(f(array[bot])))(f(array[bot + 1]));
790− case 3:
791− return apply2(apply2(map4(array3)(f(array[bot])))(f(array[bot + 1])))(f(array[bot + 2]));
792− default:
793− var pivot = bot + Math.floor((top2 - bot) / 4) * 2;
794− return apply2(map4(concat2)(go2(bot, pivot)))(go2(pivot, top2));
795− }
796− }
797− return go2(0, array.length);
798− };
799− };
800− };
801− };
802− };
803− }();
804−
805− // output/Data.Traversable/index.js
806− var identity3 = /* @__PURE__ */ identity(categoryFn);
807− var traverse = function(dict) {
808− return dict.traverse;
809− };
810− var sequenceDefault = function(dictTraversable) {
811− var traverse22 = traverse(dictTraversable);
812− return function(dictApplicative) {
813− return traverse22(dictApplicative)(identity3);
814− };
815− };
816− var traversableArray = {
817− traverse: function(dictApplicative) {
818− var Apply0 = dictApplicative.Apply0();
819− return traverseArrayImpl(apply(Apply0))(map(Apply0.Functor0()))(pure(dictApplicative));
820− },
821− sequence: function(dictApplicative) {
822− return sequenceDefault(traversableArray)(dictApplicative);
823− },
824− Functor0: function() {
825− return functorArray;
826− },
827− Foldable1: function() {
828− return foldableArray;
829− }
830− };
831−
832− // output/Data.Array/index.js
833− var intercalate1 = /* @__PURE__ */ intercalate(foldableArray);
834− var intercalate2 = function(dictMonoid) {
835− return intercalate1(dictMonoid);
836− };
837− var index = /* @__PURE__ */ function() {
838− return runFn4(indexImpl)(Just.create)(Nothing.value);
839− }();
840− var head = function(xs) {
841− return index(xs)(0);
842− };
843−
844− // output/Maquette/foreign.js
845− var NAMESPACE_W3 = "http://www.w3.org/";
846− var NAMESPACE_SVG = NAMESPACE_W3 + "2000/svg";
847− var NAMESPACE_XLINK = NAMESPACE_W3 + "1999/xlink";
848− var emptyArray = [];
849− var extend2 = function(base, overrides) {
850− var result = {};
851− Object.keys(base).forEach(function(key) {
852− result[key] = base[key];
853− });
854− if (overrides) {
855− Object.keys(overrides).forEach(function(key) {
856− result[key] = overrides[key];
857− });
858− }
859− return result;
860− };
861− var same = function(vnode1, vnode2) {
862− if (vnode1.vnodeSelector !== vnode2.vnodeSelector) {
863− return false;
864− }
865− if (vnode1.properties && vnode2.properties) {
866− if (vnode1.properties.key !== vnode2.properties.key) {
867− return false;
868− }
869− return vnode1.properties.bind === vnode2.properties.bind;
870− }
871− return !vnode1.properties && !vnode2.properties;
872− };
873− var checkStyleValue = function(styleValue) {
874− if (typeof styleValue !== "string") {
875− throw new Error("Style values must be strings");
876− }
877− };
878− var findIndexOfChild = function(children, sameAs, start2) {
879− if (sameAs.vnodeSelector !== "") {
880− for (var i = start2; i < children.length; i++) {
881− if (same(children[i], sameAs)) {
882− return i;
883− }
884− }
885− }
886− return -1;
887− };
888− var checkDistinguishable = function(childNodes, indexToCheck, parentVNode, operation) {
889− var childNode = childNodes[indexToCheck];
890− if (childNode.vnodeSelector === "") {
891− return;
892− }
893− var properties = childNode.properties;
894− var key = properties ? properties.key === void 0 ? properties.bind : properties.key : void 0;
895− if (!key) {
896− for (var i = 0; i < childNodes.length; i++) {
897− if (i !== indexToCheck) {
898− var node = childNodes[i];
899− if (same(node, childNode)) {
900− throw {
901− error: new Error(parentVNode.vnodeSelector + " had a " + childNode.vnodeSelector + " child " + (operation === "added" ? operation : "removed") + ", but there is now more than one. You must add unique key properties to make them distinguishable."),
902− parentNode: parentVNode,
903− childNode
904− };
905− }
906− }
907− }
908− }
909− };
910− var nodeAdded = function(vNode) {
911− if (vNode.properties) {
912− var enterAnimation = vNode.properties.enterAnimation;
913− if (enterAnimation) {
914− enterAnimation(vNode.domNode, vNode.properties);
915− }
916− }
917− };
918− var removedNodes = [];
919− var requestedIdleCallback = false;
920− var visitRemovedNode = function(node) {
921− (node.children || []).forEach(visitRemovedNode);
922− if (node.properties && node.properties.afterRemoved) {
923− node.properties.afterRemoved.apply(node.properties.bind || node.properties, [
924− node.domNode
925− ]);
926− }
927− };
928− var processPendingNodeRemovals = function() {
929− requestedIdleCallback = false;
930− removedNodes.forEach(visitRemovedNode);
931− removedNodes.length = 0;
932− };
933− var scheduleNodeRemoval = function(vNode) {
934− removedNodes.push(vNode);
935− if (!requestedIdleCallback) {
936− requestedIdleCallback = true;
937− if (typeof window !== "undefined" && "requestIdleCallback" in window) {
938− window.requestIdleCallback(processPendingNodeRemovals, { timeout: 16 });
939− } else {
940− setTimeout(processPendingNodeRemovals, 16);
941− }
942− }
943− };
944− var nodeToRemove = function(vNode) {
945− var domNode = vNode.domNode;
946− if (vNode.properties) {
947− var exitAnimation = vNode.properties.exitAnimation;
948− if (exitAnimation) {
949− domNode.style.pointerEvents = "none";
950− var removeDomNode = function() {
951− if (domNode.parentNode) {
952− domNode.parentNode.removeChild(domNode);
953− scheduleNodeRemoval(vNode);
954− }
955− };
956− exitAnimation(domNode, removeDomNode, vNode.properties);
957− return;
958− }
959− }
960− if (domNode.parentNode) {
961− domNode.parentNode.removeChild(domNode);
962− scheduleNodeRemoval(vNode);
963− }
964− };
965− var vnodeOnlyProps = [
966− "afterCreate",
967− "afterUpdate",
968− "afterRemoved",
969− "enterAnimation",
970− "exitAnimation",
971− "updateAnimation"
972− ];
973− function filterVNodeOnlyProps(name15) {
974− return !vnodeOnlyProps.includes(name15);
975− }
976− var setProperties = function(domNode, properties, projectionOptions) {
977− if (!properties) {
978− return;
979− }
980− var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor;
981− var propNames = Object.keys(properties).filter(filterVNodeOnlyProps);
982− var propCount = propNames.length;
983− for (var i = 0; i < propCount; i++) {
984− var propName = propNames[i];
985− var propValue = properties[propName];
986− if (propName === "className") {
987− throw new Error('Property "className" is not supported, use "class".');
988− } else if (propName === "class") {
989− toggleClasses(domNode, propValue, true);
990− } else if (propName === "classes") {
991− var classNames = Object.keys(propValue);
992− var classNameCount = classNames.length;
993− for (var j = 0; j < classNameCount; j++) {
994− var className = classNames[j];
995− if (propValue[className]) {
996− domNode.classList.add(className);
997− }
998− }
999− } else if (propName === "styles") {
1000− var styleNames = Object.keys(propValue);
1001− var styleCount = styleNames.length;
1002− for (var j = 0; j < styleCount; j++) {
1003− var styleName = styleNames[j];
1004− var styleValue = propValue[styleName];
1005− if (styleValue) {
1006− checkStyleValue(styleValue);
1007− projectionOptions.styleApplyer(domNode, styleName, styleValue);
1008− }
1009− }
1010− } else if (propName === "on" && propValue) {
1011− for (var _i = 0, _a = Object.entries(properties.on); _i < _a.length; _i++) {
1012− var _b = _a[_i], key = _b[0], handler = _b[1];
1013− var listener = typeof handler === "function" ? handler : handler.listener;
1014− if (eventHandlerInterceptor) {
1015− listener = eventHandlerInterceptor(key, listener, domNode, properties);
1016− }
1017− if (listener) {
1018− domNode.addEventListener(key, listener, typeof handler === "function" ? void 0 : handler.options);
1019− }
1020− }
1021− } else if (propName !== "key" && propValue !== null && propValue !== void 0) {
1022− var type = typeof propValue;
1023− if (type === "function") {
1024− if (propName.lastIndexOf("on", 0) === 0) {
1025− if (eventHandlerInterceptor) {
1026− propValue = eventHandlerInterceptor(propName, propValue, domNode, properties);
1027− }
1028− }
1029− domNode[propName] = propValue;
1030− } else if (projectionOptions.namespace === NAMESPACE_SVG) {
1031− if (propName === "href") {
1032− domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);
1033− } else {
1034− domNode.setAttribute(propName, propValue);
1035− }
1036− } else if (type === "string" && propName !== "value" && propName !== "innerHTML") {
1037− domNode.setAttribute(propName, propValue);
1038− } else {
1039− domNode[propName] = propValue;
1040− }
1041− }
1042− }
1043− };
1044− var addChildren = function(domNode, children, projectionOptions) {
1045− if (!children) {
1046− return;
1047− }
1048− for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
1049− var child = children_1[_i];
1050− createDom(child, domNode, void 0, projectionOptions);
1051− }
1052− };
1053− var initPropertiesAndChildren = function(domNode, vnode, projectionOptions) {
1054− addChildren(domNode, vnode.children, projectionOptions);
1055− if (vnode.text) {
1056− domNode.textContent = vnode.text;
1057− }
1058− setProperties(domNode, vnode.properties, projectionOptions);
1059− if (vnode.properties && vnode.properties.afterCreate) {
1060− vnode.properties.afterCreate.apply(vnode.properties.bind || vnode.properties, [
1061− domNode,
1062− projectionOptions,
1063− vnode.vnodeSelector,
1064− vnode.properties,
1065− vnode.children
1066− ]);
1067− }
1068− };
1069− var createDom = function(vnode, parentNode, insertBefore, projectionOptions) {
1070− var _a;
1071− var domNode;
1072− var start2 = 0;
1073− var vnodeSelector = vnode.vnodeSelector;
1074− var doc = parentNode.ownerDocument;
1075− if (vnodeSelector === "") {
1076− if (vnode.domNode) {
1077− vnode.domNode.nodeValue = vnode.text;
1078− } else {
1079− domNode = vnode.domNode = doc.createTextNode(vnode.text);
1080− if (insertBefore !== void 0) {
1081− parentNode.insertBefore(domNode, insertBefore);
1082− } else {
1083− parentNode.appendChild(domNode);
1084− }
1085− }
1086− } else {
1087− for (var i = 0; i <= vnodeSelector.length; ++i) {
1088− var c = vnodeSelector.charAt(i);
1089− if (i === vnodeSelector.length || c === "." || c === "#") {
1090− var type = vnodeSelector.charAt(start2 - 1);
1091− var found = vnodeSelector.slice(start2, i);
1092− if (type === ".") {
1093− domNode.classList.add(found);
1094− } else if (type === "#") {
1095− domNode.id = found;
1096− } else {
1097− if (found === "svg") {
1098− projectionOptions = extend2(projectionOptions, {
1099− namespace: NAMESPACE_SVG
1100− });
1101− }
1102− if (projectionOptions.namespace !== void 0) {
1103− domNode = vnode.domNode = doc.createElementNS(projectionOptions.namespace, found);
1104− } else {
1105− domNode = vnode.domNode = vnode.domNode || (((_a = vnode.properties) === null || _a === void 0 ? void 0 : _a.is) ? doc.createElement(found, { is: vnode.properties.is }) : doc.createElement(found));
1106− if (found === "input" && vnode.properties && vnode.properties.type !== void 0) {
1107− domNode.setAttribute("type", vnode.properties.type);
1108− }
1109− }
1110− if (insertBefore !== void 0) {
1111− parentNode.insertBefore(domNode, insertBefore);
1112− } else if (domNode.parentNode !== parentNode) {
1113− parentNode.appendChild(domNode);
1114− }
1115− }
1116− start2 = i + 1;
1117− }
1118− }
1119− initPropertiesAndChildren(domNode, vnode, projectionOptions);
1120− }
1121− };
1122− var updateDom;
1123− var toggleClasses = function(domNode, classes, on2) {
1124− if (!classes) {
1125− return;
1126− }
1127− classes.split(" ").forEach(function(classToToggle) {
1128− if (classToToggle) {
1129− domNode.classList.toggle(classToToggle, on2);
1130− }
1131− });
1132− };
1133− var updateProperties = function(domNode, previousProperties, properties, projectionOptions) {
1134− if (!properties) {
1135− return;
1136− }
1137− var propertiesUpdated = false;
1138− var propNames = Object.keys(properties).filter(filterVNodeOnlyProps);
1139− var propCount = propNames.length;
1140− for (var i = 0; i < propCount; i++) {
1141− var propName = propNames[i];
1142− var propValue = properties[propName];
1143− var previousValue = previousProperties[propName];
1144− if (propName === "class") {
1145− if (previousValue !== propValue) {
1146− toggleClasses(domNode, previousValue, false);
1147− toggleClasses(domNode, propValue, true);
1148− }
1149− } else if (propName === "classes") {
1150− var classList = domNode.classList;
1151− var classNames = Object.keys(propValue);
1152− var classNameCount = classNames.length;
1153− for (var j = 0; j < classNameCount; j++) {
1154− var className = classNames[j];
1155− var on2 = !!propValue[className];
1156− var previousOn = !!previousValue[className];
1157− if (on2 === previousOn) {
1158− continue;
1159− }
1160− propertiesUpdated = true;
1161− if (on2) {
1162− classList.add(className);
1163− } else {
1164− classList.remove(className);
1165− }
1166− }
1167− } else if (propName === "styles") {
1168− var styleNames = Object.keys(propValue);
1169− var styleCount = styleNames.length;
1170− for (var j = 0; j < styleCount; j++) {
1171− var styleName = styleNames[j];
1172− var newStyleValue = propValue[styleName];
1173− var oldStyleValue = previousValue[styleName];
1174− if (newStyleValue === oldStyleValue) {
1175− continue;
1176− }
1177− propertiesUpdated = true;
1178− if (newStyleValue) {
1179− checkStyleValue(newStyleValue);
1180− projectionOptions.styleApplyer(domNode, styleName, newStyleValue);
1181− } else {
1182− projectionOptions.styleApplyer(domNode, styleName, "");
1183− }
1184− }
1185− } else {
1186− if (!propValue && typeof previousValue === "string") {
1187− propValue = "";
1188− }
1189− if (propName === "value") {
1190− var domValue = domNode[propName];
1191− if (domValue !== propValue && // The 'value' in the DOM tree !== newValue
1192− propValue !== previousValue) {
1193− domNode[propName] = propValue;
1194− }
1195− if (propValue !== previousValue) {
1196− propertiesUpdated = true;
1197− }
1198− } else if (propValue !== previousValue) {
1199− var type = typeof propValue;
1200− if (type !== "function" || !projectionOptions.eventHandlerInterceptor) {
1201− if (projectionOptions.namespace === NAMESPACE_SVG) {
1202− if (propName === "href") {
1203− domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);
1204− } else {
1205− domNode.setAttribute(propName, propValue);
1206− }
1207− } else if (type === "string" && propName !== "innerHTML") {
1208− if (propName === "role" && propValue === "") {
1209− domNode.removeAttribute(propName);
1210− } else {
1211− domNode.setAttribute(propName, propValue);
1212− }
1213− } else if (domNode[propName] !== propValue) {
1214− domNode[propName] = propValue;
1215− }
1216− propertiesUpdated = true;
1217− }
1218− }
1219− }
1220− }
1221− return propertiesUpdated;
1222− };
1223− var updateChildren = function(vnode, domNode, oldChildren, newChildren, projectionOptions) {
1224− if (oldChildren === newChildren) {
1225− return false;
1226− }
1227− oldChildren = oldChildren || emptyArray;
1228− newChildren = newChildren || emptyArray;
1229− var oldChildrenLength = oldChildren.length;
1230− var newChildrenLength = newChildren.length;
1231− var oldIndex = 0;
1232− var newIndex = 0;
1233− var i;
1234− var textUpdated = false;
1235− while (newIndex < newChildrenLength) {
1236− var oldChild = oldIndex < oldChildrenLength ? oldChildren[oldIndex] : void 0;
1237− var newChild = newChildren[newIndex];
1238− if (oldChild !== void 0 && same(oldChild, newChild)) {
1239− textUpdated = updateDom(oldChild, newChild, projectionOptions, domNode, oldChildren) || textUpdated;
1240− oldIndex++;
1241− } else {
1242− var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1);
1243− if (findOldIndex >= 0) {
1244− for (i = oldIndex; i < findOldIndex; i++) {
1245− nodeToRemove(oldChildren[i]);
1246− checkDistinguishable(oldChildren, i, vnode, "removed");
1247− }
1248− textUpdated = updateDom(oldChildren[findOldIndex], newChild, projectionOptions, domNode, oldChildren) || textUpdated;
1249− oldIndex = findOldIndex + 1;
1250− } else {
1251− createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : void 0, projectionOptions);
1252− nodeAdded(newChild);
1253− checkDistinguishable(newChildren, newIndex, vnode, "added");
1254− }
1255− }
1256− newIndex++;
1257− }
1258− if (oldChildrenLength > oldIndex) {
1259− for (i = oldIndex; i < oldChildrenLength; i++) {
1260− nodeToRemove(oldChildren[i]);
1261− checkDistinguishable(oldChildren, i, vnode, "removed");
1262− }
1263− }
1264− return textUpdated;
1265− };
1266− updateDom = function(previous, vnode, projectionOptions, parentNode, oldChildren) {
1267− var domNode = previous.domNode;
1268− var textUpdated = false;
1269− if (previous === vnode) {
1270− return false;
1271− }
1272− var updated = false;
1273− if (vnode.vnodeSelector === "") {
1274− if (vnode.text !== previous.text) {
1275− var newTextNode = domNode.ownerDocument.createTextNode(vnode.text);
1276− try {
1277− parentNode.replaceChild(newTextNode, domNode);
1278− } catch (e) {
1279− parentNode.replaceChild(newTextNode, parentNode.childNodes[oldChildren.indexOf(previous)]);
1280− }
1281− vnode.domNode = newTextNode;
1282− textUpdated = true;
1283− return textUpdated;
1284− }
1285− vnode.domNode = domNode;
1286− } else {
1287− if (vnode.vnodeSelector.lastIndexOf("svg", 0) === 0) {
1288− projectionOptions = extend2(projectionOptions, {
1289− namespace: NAMESPACE_SVG
1290− });
1291− }
1292− if (previous.text !== vnode.text) {
1293− updated = true;
1294− if (vnode.text === void 0) {
1295− domNode.removeChild(domNode.firstChild);
1296− } else {
1297− domNode.textContent = vnode.text;
1298− }
1299− }
1300− vnode.domNode = domNode;
1301− updated = updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) || updated;
1302− updated = updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) || updated;
1303− if (vnode.properties && vnode.properties.afterUpdate) {
1304− vnode.properties.afterUpdate.apply(vnode.properties.bind || vnode.properties, [
1305− domNode,
1306− projectionOptions,
1307− vnode.vnodeSelector,
1308− vnode.properties,
1309− vnode.children
1310− ]);
1311− }
1312− }
1313− if (updated && vnode.properties && vnode.properties.updateAnimation) {
1314− vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties);
1315− }
1316− return textUpdated;
1317− };
1318− var createProjection = function(vnode, projectionOptions) {
1319− return {
1320− getLastRender: function() {
1321− return vnode;
1322− },
1323− update: function(updatedVnode) {
1324− if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) {
1325− throw new Error("The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)");
1326− }
1327− var previousVNode = vnode;
1328− vnode = updatedVnode;
1329− updateDom(previousVNode, updatedVnode, projectionOptions, previousVNode.domNode.parentNode, [previousVNode]);
1330− },
1331− domNode: vnode.domNode
1332− };
1333− };
1334− var DEFAULT_PROJECTION_OPTIONS = {
1335− namespace: void 0,
1336− performanceLogger: function() {
1337− return void 0;
1338− },
1339− eventHandlerInterceptor: void 0,
1340− styleApplyer: function(domNode, styleName, value12) {
1341− if (styleName.charAt(0) === "-") {
1342− domNode.style.setProperty(styleName, value12);
1343− } else {
1344− domNode.style[styleName] = value12;
1345− }
1346− }
1347− };
1348− var applyDefaultProjectionOptions = function(projectorOptions) {
1349− return extend2(DEFAULT_PROJECTION_OPTIONS, projectorOptions);
1350− };
1351− var dom = {
1352− /**
1353− * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in
1354− * its [[Projection.domNode|domNode]] property.
1355− * This is a low-level method. Users will typically use a [[Projector]] instead.
1356− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
1357− * objects may only be rendered once.
1358− * @param projectionOptions - Options to be used to create and update the projection.
1359− * @returns The [[Projection]] which also contains the DOM Node that was created.
1360− */
1361− create: function(vnode, projectionOptions) {
1362− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
1363− createDom(vnode, document.createElement("div"), void 0, projectionOptions);
1364− return createProjection(vnode, projectionOptions);
1365− },
1366− /**
1367− * Appends a new child node to the DOM which is generated from a [[VNode]].
1368− * This is a low-level method. Users will typically use a [[Projector]] instead.
1369− * @param parentNode - The parent node for the new child node.
1370− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
1371− * objects may only be rendered once.
1372− * @param projectionOptions - Options to be used to create and update the [[Projection]].
1373− * @returns The [[Projection]] that was created.
1374− */
1375− append: function(parentNode, vnode, projectionOptions) {
1376− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
1377− createDom(vnode, parentNode, void 0, projectionOptions);
1378− return createProjection(vnode, projectionOptions);
1379− },
1380− /**
1381− * Inserts a new DOM node which is generated from a [[VNode]].
1382− * This is a low-level method. Users wil typically use a [[Projector]] instead.
1383− * @param beforeNode - The node that the DOM Node is inserted before.
1384− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.
1385− * NOTE: [[VNode]] objects may only be rendered once.
1386− * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
1387− * @returns The [[Projection]] that was created.
1388− */
1389− insertBefore: function(beforeNode, vnode, projectionOptions) {
1390− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
1391− createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions);
1392− return createProjection(vnode, projectionOptions);
1393− },
1394− /**
1395− * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.
1396− * This means that the virtual DOM and the real DOM will have one overlapping element.
1397− * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.
1398− * This is a low-level method. Users wil typically use a [[Projector]] instead.
1399− * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.
1400− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects
1401− * may only be rendered once.
1402− * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
1403− * @returns The [[Projection]] that was created.
1404− */
1405− merge: function(element, vnode, projectionOptions) {
1406− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
1407− vnode.domNode = element;
1408− initPropertiesAndChildren(element, vnode, projectionOptions);
1409− return createProjection(vnode, projectionOptions);
1410− },
1411− /**
1412− * Replaces an existing DOM node with a node generated from a [[VNode]].
1413− * This is a low-level method. Users will typically use a [[Projector]] instead.
1414− * @param element - The node for the [[VNode]] to replace.
1415− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
1416− * objects may only be rendered once.
1417− * @param projectionOptions - Options to be used to create and update the [[Projection]].
1418− * @returns The [[Projection]] that was created.
1419− */
1420− replace: function(element, vnode, projectionOptions) {
1421− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
1422− createDom(vnode, element.parentNode, element, projectionOptions);
1423− element.parentNode.removeChild(element);
1424− return createProjection(vnode, projectionOptions);
1425− }
1426− };
1427− var toTextVNode = function(data) {
1428− return {
1429− vnodeSelector: "",
1430− properties: void 0,
1431− children: void 0,
1432− text: data.toString(),
1433− domNode: null
1434− };
1435− };
1436− var appendChildren = function(parentSelector, insertions, main2) {
1437− for (var i = 0, length_1 = insertions.length; i < length_1; i++) {
1438− var item = insertions[i];
1439− if (Array.isArray(item)) {
1440− appendChildren(parentSelector, item, main2);
1441− } else {
1442− if (item !== null && item !== void 0 && item !== false) {
1443− if (typeof item === "string") {
1444− item = toTextVNode(item);
1445− }
1446− main2.push(item);
1447− }
1448− }
1449− }
1450− };
1451− function h(selector, properties, children) {
1452− if (Array.isArray(properties)) {
1453− children = properties;
1454− properties = void 0;
1455− } else if (properties && (typeof properties === "string" || properties.vnodeSelector) || children && (typeof children === "string" || children.vnodeSelector)) {
1456− throw new Error("h called with invalid arguments");
1457− }
1458− var text6;
1459− var flattenedChildren;
1460− if (children && children.length === 1 && typeof children[0] === "string") {
1461− text6 = children[0];
1462− } else if (children) {
1463− flattenedChildren = [];
1464− appendChildren(selector, children, flattenedChildren);
1465− if (flattenedChildren.length === 0) {
1466− flattenedChildren = void 0;
1467− }
1468− }
1469− return {
1470− vnodeSelector: selector,
1471− properties,
1472− children: flattenedChildren,
1473− text: text6 === "" ? void 0 : text6,
1474− domNode: null
1475− };
1476− }
1477− var createParentNodePath = function(node, rootNode) {
1478− var parentNodePath = [];
1479− while (node && node !== rootNode) {
1480− parentNodePath.push(node);
1481− node = node.parentNode;
1482− }
1483− return parentNodePath;
1484− };
1485− var find2;
1486− if (Array.prototype.find) {
1487− find2 = function(items, predicate) {
1488− return items.find(predicate);
1489− };
1490− } else {
1491− find2 = function(items, predicate) {
1492− return items.filter(predicate)[0];
1493− };
1494− }
1495− var findVNodeByParentNodePath = function(vnode, parentNodePath) {
1496− var result = vnode;
1497− parentNodePath.forEach(function(node) {
1498− result = result && result.children ? find2(result.children, function(child) {
1499− return child.domNode === node;
1500− }) : void 0;
1501− });
1502− return result;
1503− };
1504− var createEventHandlerInterceptor = function(projector, getProjection, performanceLogger) {
1505− return function(propertyName, eventHandler, domNode, properties) {
1506− return modifiedEventHandler;
1507− };
1508− function modifiedEventHandler(evt) {
1509− var _a, _b;
1510− performanceLogger("domEvent", evt);
1511− var projection = getProjection();
1512− var parentNodePath = createParentNodePath(evt.currentTarget, projection.domNode);
1513− parentNodePath.reverse();
1514− var matchingVNode = findVNodeByParentNodePath(projection.getLastRender(), parentNodePath);
1515− projector.scheduleRender();
1516− var result;
1517− if (matchingVNode) {
1518− var listener = (_b = (_a = matchingVNode.properties["on" + evt.type]) !== null && _a !== void 0 ? _a : matchingVNode.properties.on[evt.type].listener) !== null && _b !== void 0 ? _b : matchingVNode.properties.on[evt.type];
1519− result = listener.apply(matchingVNode.properties.bind || this, arguments);
1520− }
1521− performanceLogger("domEventProcessed", evt);
1522− return result;
1523− }
1524− };
1525− var createProjector = function(projectorOptions) {
1526− var projector;
1527− var projectionOptions = applyDefaultProjectionOptions(projectorOptions);
1528− var performanceLogger = projectionOptions.performanceLogger;
1529− var renderCompleted = true;
1530− var scheduled;
1531− var stopped = false;
1532− var projections = [];
1533− var renderFunctions = [];
1534− var addProjection = function(domFunction, node, renderFunction) {
1535− var projection;
1536− var getProjection = function() {
1537− return projection;
1538− };
1539− projectionOptions.eventHandlerInterceptor = createEventHandlerInterceptor(projector, getProjection, performanceLogger);
1540− projection = domFunction(node, renderFunction(), projectionOptions);
1541− projections.push(projection);
1542− renderFunctions.push(renderFunction);
1543− };
1544− var doRender = function() {
1545− scheduled = void 0;
1546− if (!renderCompleted) {
1547− return;
1548− }
1549− renderCompleted = false;
1550− performanceLogger("renderStart", void 0);
1551− for (var i = 0; i < projections.length; i++) {
1552− var updatedVnode = renderFunctions[i]();
1553− performanceLogger("rendered", void 0);
1554− projections[i].update(updatedVnode);
1555− performanceLogger("patched", void 0);
1556− }
1557− performanceLogger("renderDone", void 0);
1558− renderCompleted = true;
1559− };
1560− projector = {
1561− renderNow: doRender,
1562− scheduleRender: function() {
1563− if (!scheduled && !stopped) {
1564− scheduled = requestAnimationFrame(doRender);
1565− }
1566− },
1567− stop: function() {
1568− if (scheduled) {
1569− cancelAnimationFrame(scheduled);
1570− scheduled = void 0;
1571− }
1572− stopped = true;
1573− },
1574− resume: function() {
1575− stopped = false;
1576− renderCompleted = true;
1577− projector.scheduleRender();
1578− },
1579− append: function(parentNode, renderFunction) {
1580− addProjection(dom.append, parentNode, renderFunction);
1581− },
1582− insertBefore: function(beforeNode, renderFunction) {
1583− addProjection(dom.insertBefore, beforeNode, renderFunction);
1584− },
1585− merge: function(domNode, renderFunction) {
1586− addProjection(dom.merge, domNode, renderFunction);
1587− },
1588− replace: function(domNode, renderFunction) {
1589− addProjection(dom.replace, domNode, renderFunction);
1590− },
1591− detach: function(renderFunction) {
1592− for (var i = 0; i < renderFunctions.length; i++) {
1593− if (renderFunctions[i] === renderFunction) {
1594− renderFunctions.splice(i, 1);
1595− return projections.splice(i, 1)[0];
1596− }
1597− }
1598− throw new Error("renderFunction was not found");
1599− }
1600− };
1601− return projector;
1602− };
1603− function _h(selector) {
1604− return function(properties) {
1605− return function(children) {
1606− return h(selector, properties, children);
1607− };
1608− };
1609− }
1610− function scheduleRender(projector) {
1611− return function() {
1612− projector.scheduleRender();
1613− };
1614− }
1615− function replace(projector) {
1616− return function(el) {
1617− return function(render3) {
1618− return function() {
1619− projector.replace(el, render3);
1620− };
1621− };
1622− };
1623− }
1624−
1625− // output/Maquette/index.js
1626− var string = unsafeCoerce2;
1627− var h2 = _h;
1628−
1629− // output/Control.Monad.Writer.Class/index.js
1630− var tell = function(dict) {
1631− return dict.tell;
1632− };
1633−
1634− // output/Control.Monad.Writer.Trans/index.js
1635− var WriterT = function(x) {
1636− return x;
1637− };
1638− var runWriterT = function(v) {
1639− return v;
1640− };
1641− var mapWriterT = function(f) {
1642− return function(v) {
1643− return f(v);
1644− };
1645− };
1646− var functorWriterT = function(dictFunctor) {
1647− var map4 = map(dictFunctor);
1648− return {
1649− map: function(f) {
1650− return mapWriterT(map4(function(v) {
1651− return new Tuple(f(v.value0), v.value1);
1652− }));
1653− }
1654− };
1655− };
1656− var applyWriterT = function(dictSemigroup) {
1657− var append3 = append(dictSemigroup);
1658− return function(dictApply) {
1659− var apply2 = apply(dictApply);
1660− var Functor0 = dictApply.Functor0();
1661− var map4 = map(Functor0);
1662− var functorWriterT1 = functorWriterT(Functor0);
1663− return {
1664− apply: function(v) {
1665− return function(v1) {
1666− var k = function(v3) {
1667− return function(v4) {
1668− return new Tuple(v3.value0(v4.value0), append3(v3.value1)(v4.value1));
1669− };
1670− };
1671− return apply2(map4(k)(v))(v1);
1672− };
1673− },
1674− Functor0: function() {
1675− return functorWriterT1;
1676− }
1677− };
1678− };
1679− };
1680− var bindWriterT = function(dictSemigroup) {
1681− var append3 = append(dictSemigroup);
1682− var applyWriterT1 = applyWriterT(dictSemigroup);
1683− return function(dictBind) {
1684− var bind4 = bind(dictBind);
1685− var Apply0 = dictBind.Apply0();
1686− var map4 = map(Apply0.Functor0());
1687− var applyWriterT2 = applyWriterT1(Apply0);
1688− return {
1689− bind: function(v) {
1690− return function(k) {
1691− return bind4(v)(function(v1) {
1692− var v2 = k(v1.value0);
1693− return map4(function(v3) {
1694− return new Tuple(v3.value0, append3(v1.value1)(v3.value1));
1695− })(v2);
1696− });
1697− };
1698− },
1699− Apply0: function() {
1700− return applyWriterT2;
1701− }
1702− };
1703− };
1704− };
1705− var semigroupWriterT = function(dictApply) {
1706− return function(dictSemigroup) {
1707− var lift22 = lift2(applyWriterT(dictSemigroup)(dictApply));
1708− return function(dictSemigroup1) {
1709− return {
1710− append: lift22(append(dictSemigroup1))
1711− };
1712− };
1713− };
1714− };
1715− var applicativeWriterT = function(dictMonoid) {
1716− var mempty5 = mempty(dictMonoid);
1717− var applyWriterT1 = applyWriterT(dictMonoid.Semigroup0());
1718− return function(dictApplicative) {
1719− var pure4 = pure(dictApplicative);
1720− var applyWriterT2 = applyWriterT1(dictApplicative.Apply0());
1721− return {
1722− pure: function(a) {
1723− return pure4(new Tuple(a, mempty5));
1724− },
1725− Apply0: function() {
1726− return applyWriterT2;
1727− }
1728− };
1729− };
1730− };
1731− var monadWriterT = function(dictMonoid) {
1732− var applicativeWriterT1 = applicativeWriterT(dictMonoid);
1733− var bindWriterT1 = bindWriterT(dictMonoid.Semigroup0());
1734− return function(dictMonad) {
1735− var applicativeWriterT22 = applicativeWriterT1(dictMonad.Applicative0());
1736− var bindWriterT22 = bindWriterT1(dictMonad.Bind1());
1737− return {
1738− Applicative0: function() {
1739− return applicativeWriterT22;
1740− },
1741− Bind1: function() {
1742− return bindWriterT22;
1743− }
1744− };
1745− };
1746− };
1747− var monadTellWriterT = function(dictMonoid) {
1748− var Semigroup0 = dictMonoid.Semigroup0();
1749− var monadWriterT1 = monadWriterT(dictMonoid);
1750− return function(dictMonad) {
1751− var monadWriterT2 = monadWriterT1(dictMonad);
1752− return {
1753− tell: function() {
1754− var $262 = pure(dictMonad.Applicative0());
1755− var $263 = Tuple.create(unit);
1756− return function($264) {
1757− return WriterT($262($263($264)));
1758− };
1759− }(),
1760− Semigroup0: function() {
1761− return Semigroup0;
1762− },
1763− Monad1: function() {
1764− return monadWriterT2;
1765− }
1766− };
1767− };
1768− };
1769− var monoidWriterT = function(dictApplicative) {
1770− var semigroupWriterT1 = semigroupWriterT(dictApplicative.Apply0());
1771− return function(dictMonoid) {
1772− var pure4 = pure(applicativeWriterT(dictMonoid)(dictApplicative));
1773− var semigroupWriterT2 = semigroupWriterT1(dictMonoid.Semigroup0());
1774− return function(dictMonoid1) {
1775− var semigroupWriterT3 = semigroupWriterT2(dictMonoid1.Semigroup0());
1776− return {
1777− mempty: pure4(mempty(dictMonoid1)),
1778− Semigroup0: function() {
1779− return semigroupWriterT3;
1780− }
1781− };
1782− };
1783− };
1784− };
1785−
1786− // output/Control.Monad.Writer/index.js
1787− var unwrap2 = /* @__PURE__ */ unwrap();
1788− var runWriter = function($5) {
1789− return unwrap2(runWriterT($5));
1790− };
1791−
1792− // output/Foreign.Object/foreign.js
1793− function _copyST(m) {
1794− return function() {
1795− var r = {};
1796− for (var k in m) {
1797− if (hasOwnProperty.call(m, k)) {
1798− r[k] = m[k];
1799− }
1800− }
1801− return r;
1802− };
1803− }
1804− var empty2 = {};
1805− function runST(f) {
1806− return f();
1807− }
1808− function _foldM(bind4) {
1809− return function(f) {
1810− return function(mz) {
1811− return function(m) {
1812− var acc = mz;
1813− function g(k2) {
1814− return function(z) {
1815− return f(z)(k2)(m[k2]);
1816− };
1817− }
1818− for (var k in m) {
1819− if (hasOwnProperty.call(m, k)) {
1820− acc = bind4(acc)(g(k));
1821− }
1822− }
1823− return acc;
1824− };
1825− };
1826− };
1827− }
1828− function toArrayWithKey(f) {
1829− return function(m) {
1830− var r = [];
1831− for (var k in m) {
1832− if (hasOwnProperty.call(m, k)) {
1833− r.push(f(k)(m[k]));
1834− }
1835− }
1836− return r;
1837− };
1838− }
1839− var keys = Object.keys || toArrayWithKey(function(k) {
1840− return function() {
1841− return k;
1842− };
1843− });
1844−
1845− // output/Foreign.Object.ST/foreign.js
1846− var newImpl = function() {
1847− return {};
1848− };
1849− function poke2(k) {
1850− return function(v) {
1851− return function(m) {
1852− return function() {
1853− m[k] = v;
1854− return m;
1855− };
1856− };
1857− };
1858− }
1859−
1860− // output/Foreign.Object/index.js
1861− var bindFlipped2 = /* @__PURE__ */ bindFlipped(bindST);
1862− var thawST = _copyST;
1863− var singleton2 = function(k) {
1864− return function(v) {
1865− return runST(bindFlipped2(poke2(k)(v))(newImpl));
1866− };
1867− };
1868− var mutate = function(f) {
1869− return function(m) {
1870− return runST(function __do() {
1871− var s = thawST(m)();
1872− f(s)();
1873− return s;
1874− });
1875− };
1876− };
1877− var foldM = function(dictMonad) {
1878− var bind1 = bind(dictMonad.Bind1());
1879− var pure1 = pure(dictMonad.Applicative0());
1880− return function(f) {
1881− return function(z) {
1882− return _foldM(bind1)(f)(pure1(z));
1883− };
1884− };
1885− };
1886− var foldM1 = /* @__PURE__ */ foldM(monadST);
1887− var union = function(m) {
1888− return mutate(function(s) {
1889− return foldM1(function(s$prime) {
1890− return function(k) {
1891− return function(v) {
1892− return poke2(k)(v)(s$prime);
1893− };
1894− };
1895− })(s)(m);
1896− });
1897− };
1898− var fold2 = /* @__PURE__ */ _foldM(applyFlipped);
1899− var foldMap2 = function(dictMonoid) {
1900− var append1 = append(dictMonoid.Semigroup0());
1901− var mempty5 = mempty(dictMonoid);
1902− return function(f) {
1903− return fold2(function(acc) {
1904− return function(k) {
1905− return function(v) {
1906− return append1(acc)(f(k)(v));
1907− };
1908− };
1909− })(mempty5);
1910− };
1911− };
1912−
1913− // output/Record.Unsafe.Union/foreign.js
1914− function unsafeUnionFn(r1, r2) {
1915− var copy = {};
1916− for (var k1 in r2) {
1917− if ({}.hasOwnProperty.call(r2, k1)) {
1918− copy[k1] = r2[k1];
1919− }
1920− }
1921− for (var k2 in r1) {
1922− if ({}.hasOwnProperty.call(r1, k2)) {
1923− copy[k2] = r1[k2];
1924− }
1925− }
1926− return copy;
1927− }
1928−
1929− // output/Record.Unsafe.Union/index.js
1930− var unsafeUnion = /* @__PURE__ */ runFn2(unsafeUnionFn);
1931−
1932− // output/Plum.View/index.js
1933− var append2 = /* @__PURE__ */ append(semigroupArray);
1934− var semigroupRecord3 = /* @__PURE__ */ semigroupRecord();
1935− var childrenIsSymbol = {
1936− reflectSymbol: function() {
1937− return "children";
1938− }
1939− };
1940− var downIsSymbol = {
1941− reflectSymbol: function() {
1942− return "down";
1943− }
1944− };
1945− var hoverIsSymbol = {
1946− reflectSymbol: function() {
1947− return "hover";
1948− }
1949− };
1950− var meatIsSymbol = {
1951− reflectSymbol: function() {
1952− return "meat";
1953− }
1954− };
1955− var nervesIsSymbol = {
1956− reflectSymbol: function() {
1957− return "nerves";
1958− }
1959− };
1960− var semigroupRecordCons2 = /* @__PURE__ */ semigroupRecordCons(childrenIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(downIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(hoverIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(meatIsSymbol)()(/* @__PURE__ */ semigroupRecordCons(nervesIsSymbol)()(semigroupRecordNil)(semigroupArray))(semigroupArray))(semigroupArray))(semigroupArray));
1961− var show2 = /* @__PURE__ */ show(showInt);
1962− var show1 = /* @__PURE__ */ show(showNumber);
1963− var mempty2 = /* @__PURE__ */ mempty(monoidArray);
1964− var monoidRecord2 = /* @__PURE__ */ monoidRecord();
1965− var monoidRecordCons2 = /* @__PURE__ */ monoidRecordCons(childrenIsSymbol);
1966− var monoidRecordCons1 = /* @__PURE__ */ monoidRecordCons(downIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(hoverIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(meatIsSymbol)(monoidArray)()(/* @__PURE__ */ monoidRecordCons(nervesIsSymbol)(monoidArray)()(monoidRecordNil))));
1967− var mempty1 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidRecord2(/* @__PURE__ */ monoidRecordCons2(monoidArray)()(monoidRecordCons1)));
1968− var foldMap3 = /* @__PURE__ */ foldMap2(monoidString);
1969− var intercalate3 = /* @__PURE__ */ intercalate2(monoidString);
1970− var map2 = /* @__PURE__ */ map(/* @__PURE__ */ functorWriterT(functorIdentity));
1971− var Px = /* @__PURE__ */ function() {
1972− function Px2(value0) {
1973− this.value0 = value0;
1974− }
1975− ;
1976− Px2.create = function(value0) {
1977− return new Px2(value0);
1978− };
1979− return Px2;
1980− }();
1981− var Fill = /* @__PURE__ */ function() {
1982− function Fill2() {
1983− }
1984− ;
1985− Fill2.value = new Fill2();
1986− return Fill2;
1987− }();
1988− var Fit = /* @__PURE__ */ function() {
1989− function Fit2() {
1990− }
1991− ;
1992− Fit2.value = new Fit2();
1993− return Fit2;
1994− }();
1995− var Max2 = /* @__PURE__ */ function() {
1996− function Max3(value0, value1) {
1997− this.value0 = value0;
1998− this.value1 = value1;
1999− }
2000− ;
2001− Max3.create = function(value0) {
2002− return function(value1) {
2003− return new Max3(value0, value1);
2004− };
2005− };
2006− return Max3;
2007− }();
2008− var Min2 = /* @__PURE__ */ function() {
2009− function Min3(value0, value1) {
2010− this.value0 = value0;
2011− this.value1 = value1;
2012− }
2013− ;
2014− Min3.create = function(value0) {
2015− return function(value1) {
2016− return new Min3(value0, value1);
2017− };
2018− };
2019− return Min3;
2020− }();
2021− var X = /* @__PURE__ */ function() {
2022− function X2() {
2023− }
2024− ;
2025− X2.value = new X2();
2026− return X2;
2027− }();
2028− var Y = /* @__PURE__ */ function() {
2029− function Y2() {
2030− }
2031− ;
2032− Y2.value = new Y2();
2033− return Y2;
2034− }();
2035− var Grid = /* @__PURE__ */ function() {
2036− function Grid2() {
2037− }
2038− ;
2039− Grid2.value = new Grid2();
2040− return Grid2;
2041− }();
2042− var Flexbox = /* @__PURE__ */ function() {
2043− function Flexbox2(value0) {
2044− this.value0 = value0;
2045− }
2046− ;
2047− Flexbox2.create = function(value0) {
2048− return new Flexbox2(value0);
2049− };
2050− return Flexbox2;
2051− }();
2052− var Generic = /* @__PURE__ */ function() {
2053− function Generic2() {
2054− }
2055− ;
2056− Generic2.value = new Generic2();
2057− return Generic2;
2058− }();
2059− var Span = /* @__PURE__ */ function() {
2060− function Span2() {
2061− }
2062− ;
2063− Span2.value = new Span2();
2064− return Span2;
2065− }();
2066− var Start = /* @__PURE__ */ function() {
2067− function Start2() {
2068− }
2069− ;
2070− Start2.value = new Start2();
2071− return Start2;
2072− }();
2073− var Center = /* @__PURE__ */ function() {
2074− function Center2() {
2075− }
2076− ;
2077− Center2.value = new Center2();
2078− return Center2;
2079− }();
2080− var End = /* @__PURE__ */ function() {
2081− function End2() {
2082− }
2083− ;
2084− End2.value = new End2();
2085− return End2;
2086− }();
2087− var Spacing = /* @__PURE__ */ function() {
2088− function Spacing2(value0, value1) {
2089− this.value0 = value0;
2090− this.value1 = value1;
2091− }
2092− ;
2093− Spacing2.create = function(value0) {
2094− return function(value1) {
2095− return new Spacing2(value0, value1);
2096− };
2097− };
2098− return Spacing2;
2099− }();
2100− var Explain = /* @__PURE__ */ function() {
2101− function Explain2() {
2102− }
2103− ;
2104− Explain2.value = new Explain2();
2105− return Explain2;
2106− }();
2107− var Align = /* @__PURE__ */ function() {
2108− function Align2(value0, value1) {
2109− this.value0 = value0;
2110− this.value1 = value1;
2111− }
2112− ;
2113− Align2.create = function(value0) {
2114− return function(value1) {
2115− return new Align2(value0, value1);
2116− };
2117− };
2118− return Align2;
2119− }();
2120− var Width = /* @__PURE__ */ function() {
2121− function Width2(value0) {
2122− this.value0 = value0;
2123− }
2124− ;
2125− Width2.create = function(value0) {
2126− return new Width2(value0);
2127− };
2128− return Width2;
2129− }();
2130− var Height = /* @__PURE__ */ function() {
2131− function Height2(value0) {
2132− this.value0 = value0;
2133− }
2134− ;
2135− Height2.create = function(value0) {
2136− return new Height2(value0);
2137− };
2138− return Height2;
2139− }();
2140− var Wrapped = /* @__PURE__ */ function() {
2141− function Wrapped2() {
2142− }
2143− ;
2144− Wrapped2.value = new Wrapped2();
2145− return Wrapped2;
2146− }();
2147− var BackgroundColor = /* @__PURE__ */ function() {
2148− function BackgroundColor2(value0) {
2149− this.value0 = value0;
2150− }
2151− ;
2152− BackgroundColor2.create = function(value0) {
2153− return new BackgroundColor2(value0);
2154− };
2155− return BackgroundColor2;
2156− }();
2157− var Padding = /* @__PURE__ */ function() {
2158− function Padding2(value0) {
2159− this.value0 = value0;
2160− }
2161− ;
2162− Padding2.create = function(value0) {
2163− return new Padding2(value0);
2164− };
2165− return Padding2;
2166− }();
2167− var Spread = /* @__PURE__ */ function() {
2168− function Spread2() {
2169− }
2170− ;
2171− Spread2.value = new Spread2();
2172− return Spread2;
2173− }();
2174− var Opacity = /* @__PURE__ */ function() {
2175− function Opacity2(value0) {
2176− this.value0 = value0;
2177− }
2178− ;
2179− Opacity2.create = function(value0) {
2180− return new Opacity2(value0);
2181− };
2182− return Opacity2;
2183− }();
2184− var Pointer = /* @__PURE__ */ function() {
2185− function Pointer2() {
2186− }
2187− ;
2188− Pointer2.value = new Pointer2();
2189− return Pointer2;
2190− }();
2191− var Move = /* @__PURE__ */ function() {
2192− function Move2(value0) {
2193− this.value0 = value0;
2194− }
2195− ;
2196− Move2.create = function(value0) {
2197− return new Move2(value0);
2198− };
2199− return Move2;
2200− }();
2201− var Clip = /* @__PURE__ */ function() {
2202− function Clip2(value0) {
2203− this.value0 = value0;
2204− }
2205− ;
2206− Clip2.create = function(value0) {
2207− return new Clip2(value0);
2208− };
2209− return Clip2;
2210− }();
2211− var UI = /* @__PURE__ */ function() {
2212− function UI2(value0, value1) {
2213− this.value0 = value0;
2214− this.value1 = value1;
2215− }
2216− ;
2217− UI2.create = function(value0) {
2218− return function(value1) {
2219− return new UI2(value0, value1);
2220− };
2221− };
2222− return UI2;
2223− }();
2224− var Column = /* @__PURE__ */ function() {
2225− function Column2(value0) {
2226− this.value0 = value0;
2227− }
2228− ;
2229− Column2.create = function(value0) {
2230− return new Column2(value0);
2231− };
2232− return Column2;
2233− }();
2234− var Row = /* @__PURE__ */ function() {
2235− function Row2(value0) {
2236− this.value0 = value0;
2237− }
2238− ;
2239− Row2.create = function(value0) {
2240− return new Row2(value0);
2241− };
2242− return Row2;
2243− }();
2244− var Stack = /* @__PURE__ */ function() {
2245− function Stack2(value0) {
2246− this.value0 = value0;
2247− }
2248− ;
2249− Stack2.create = function(value0) {
2250− return new Stack2(value0);
2251− };
2252− return Stack2;
2253− }();
2254− var Wrapper = /* @__PURE__ */ function() {
2255− function Wrapper2(value0) {
2256− this.value0 = value0;
2257− }
2258− ;
2259− Wrapper2.create = function(value0) {
2260− return new Wrapper2(value0);
2261− };
2262− return Wrapper2;
2263− }();
2264− var Text = /* @__PURE__ */ function() {
2265− function Text2(value0) {
2266− this.value0 = value0;
2267− }
2268− ;
2269− Text2.create = function(value0) {
2270− return new Text2(value0);
2271− };
2272− return Text2;
2273− }();
2274− var Link = /* @__PURE__ */ function() {
2275− function Link2(value0, value1, value22) {
2276− this.value0 = value0;
2277− this.value1 = value1;
2278− this.value2 = value22;
2279− }
2280− ;
2281− Link2.create = function(value0) {
2282− return function(value1) {
2283− return function(value22) {
2284− return new Link2(value0, value1, value22);
2285− };
2286− };
2287− };
2288− return Link2;
2289− }();
2290− var Download = /* @__PURE__ */ function() {
2291− function Download2(value0, value1, value22) {
2292− this.value0 = value0;
2293− this.value1 = value1;
2294− this.value2 = value22;
2295− }
2296− ;
2297− Download2.create = function(value0) {
2298− return function(value1) {
2299− return function(value22) {
2300− return new Download2(value0, value1, value22);
2301− };
2302− };
2303− };
2304− return Download2;
2305− }();
2306− var Image2 = /* @__PURE__ */ function() {
2307− function Image3(value0, value1) {
2308− this.value0 = value0;
2309− this.value1 = value1;
2310− }
2311− ;
2312− Image3.create = function(value0) {
2313− return function(value1) {
2314− return new Image3(value0, value1);
2315− };
2316− };
2317− return Image3;
2318− }();
2319− var None = /* @__PURE__ */ function() {
2320− function None3() {
2321− }
2322− ;
2323− None3.value = new None3();
2324− return None3;
2325− }();
2326− var semigroupSkinGrowth = {
2327− append: function(v) {
2328− return function(v1) {
2329− return union(v)(v1);
2330− };
2331− }
2332− };
2333− var bindWriterT2 = /* @__PURE__ */ bindWriterT(semigroupSkinGrowth)(bindIdentity);
2334− var discard2 = /* @__PURE__ */ discard(discardUnit)(bindWriterT2);
2335− var bind2 = /* @__PURE__ */ bind(bindWriterT2);
2336− var append22 = /* @__PURE__ */ append(/* @__PURE__ */ semigroupWriterT(applyIdentity)(semigroupSkinGrowth)(semigroupArray));
2337− var semigroupMutation = {
2338− append: function(v) {
2339− return function(v1) {
2340− return {
2341− extraSkin: append2(v.extraSkin)(v1.extraSkin)
2342− };
2343− };
2344− }
2345− };
2346− var semigroupGenericUI = function(dictSemigroup) {
2347− var append3 = append(semigroupRecord3(semigroupRecordCons2(dictSemigroup)));
2348− return function(dictSemigroup1) {
2349− var append4 = append(dictSemigroup1);
2350− return {
2351− append: function(v) {
2352− return function(v1) {
2353− return new UI(append3(v.value0)(v1.value0), append4(v.value1)(v1.value1));
2354− };
2355− }
2356− };
2357− };
2358− };
2359− var renderableColor = {
2360− render: function(v) {
2361− return "rgba(" + (show2(v.r) + ("," + (show2(v.g) + ("," + (show2(v.b) + ("," + (show1(v.a) + ")")))))));
2362− },
2363− renderKey: function(v) {
2364− return show2(v.r) + ("-" + (show2(v.g) + ("-" + (show2(v.b) + ("-" + show1(v.a))))));
2365− }
2366− };
2367− var monoidSkinGrowth = {
2368− mempty: empty2,
2369− Semigroup0: function() {
2370− return semigroupSkinGrowth;
2371− }
2372− };
2373− var tell2 = /* @__PURE__ */ tell(/* @__PURE__ */ monadTellWriterT(monoidSkinGrowth)(monadIdentity));
2374− var applicativeWriterT2 = /* @__PURE__ */ applicativeWriterT(monoidSkinGrowth)(applicativeIdentity);
2375− var pure2 = /* @__PURE__ */ pure(applicativeWriterT2);
2376− var mempty22 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidWriterT(applicativeIdentity)(monoidSkinGrowth)(monoidArray));
2377− var traverse2 = /* @__PURE__ */ traverse(traversableArray)(applicativeWriterT2);
2378− var monoidMutation = {
2379− mempty: {
2380− extraSkin: mempty2
2381− },
2382− Semigroup0: function() {
2383− return semigroupMutation;
2384− }
2385− };
2386− var mempty3 = /* @__PURE__ */ mempty(monoidMutation);
2387− var monoidGenericUI = function(dictMonoid) {
2388− var mempty42 = mempty(monoidRecord2(monoidRecordCons2(dictMonoid)()(monoidRecordCons1)));
2389− var semigroupGenericUI1 = semigroupGenericUI(dictMonoid.Semigroup0());
2390− return function(dictMonoid1) {
2391− var semigroupGenericUI2 = semigroupGenericUI1(dictMonoid1.Semigroup0());
2392− return {
2393− mempty: new UI(mempty42, mempty(dictMonoid1)),
2394− Semigroup0: function() {
2395− return semigroupGenericUI2;
2396− }
2397− };
2398− };
2399− };
2400− var functorGenericUI = {
2401− map: function(f) {
2402− return function(v) {
2403− return new UI(v.value0, f(v.value1));
2404− };
2405− }
2406− };
2407− var applyGenericUI = function(dictMonoid) {
2408− var append3 = append(semigroupRecord3(semigroupRecordCons2(dictMonoid.Semigroup0())));
2409− return {
2410− apply: function(v) {
2411− return function(v1) {
2412− return new UI(append3(v.value0)(v1.value0), v.value1(v1.value1));
2413− };
2414− },
2415− Functor0: function() {
2416− return functorGenericUI;
2417− }
2418− };
2419− };
2420− var bindGenericUI = function(dictMonoid) {
2421− var append3 = append(semigroupRecord3(semigroupRecordCons2(dictMonoid.Semigroup0())));
2422− var applyGenericUI1 = applyGenericUI(dictMonoid);
2423− return {
2424− bind: function(v) {
2425− return function(f) {
2426− var v1 = f(v.value1);
2427− return new UI(append3(v.value0)(v1.value0), v1.value1);
2428− };
2429− },
2430− Apply0: function() {
2431− return applyGenericUI1;
2432− }
2433− };
2434− };
2435− var text = function(s) {
2436− return function(v) {
2437− return new UI({
2438− nerves: mempty1.nerves,
2439− meat: mempty1.meat,
2440− hover: mempty1.hover,
2441− down: mempty1.down,
2442− children: [new Tuple({
2443− meat: v.value0.meat,
2444− nerves: v.value0.nerves,
2445− hover: v.value0.hover,
2446− down: v.value0.down
2447− }, new Text(s))]
2448− }, v.value1);
2449− };
2450− };
2451− var styleSkinGrowth = function(v) {
2452− return foldMap3(function(className) {
2453− return function(v1) {
2454− return "." + (className + ("{" + (v1.key + (":" + (v1.value + ";}")))));
2455− };
2456− })(v);
2457− };
2458− var sk = function(cName) {
2459− return function(key) {
2460− return function(value12) {
2461− return discard2(tell2(singleton2(cName)({
2462− key,
2463− value: value12
2464− })))(function() {
2465− return pure2([cName]);
2466− });
2467− };
2468− };
2469− };
2470− var renderKey = function(dict) {
2471− return dict.renderKey;
2472− };
2473− var renderKey1 = /* @__PURE__ */ renderKey(renderableColor);
2474− var render = function(dict) {
2475− return dict.render;
2476− };
2477− var render1 = /* @__PURE__ */ render(renderableColor);
2478− var renderableLength = {
2479− render: function(v) {
2480− if (v instanceof Px) {
2481− return show2(v.value0) + "px";
2482− }
2483− ;
2484− if (v instanceof Fit) {
2485− return "fit-content";
2486− }
2487− ;
2488− if (v instanceof Fill) {
2489− return "100%";
2490− }
2491− ;
2492− if (v instanceof Max2) {
2493− return "max(" + (show2(v.value0) + ("px," + (render(renderableLength)(v.value1) + ")")));
2494− }
2495− ;
2496− if (v instanceof Min2) {
2497− return "min(" + (show2(v.value0) + ("px," + (render(renderableLength)(v.value1) + ")")));
2498− }
2499− ;
2500− throw new Error("Failed pattern match at Plum.View (line 295, column 12 - line 300, column 62): " + [v.constructor.name]);
2501− },
2502− renderKey: function(v) {
2503− if (v instanceof Px) {
2504− return show2(v.value0);
2505− }
2506− ;
2507− if (v instanceof Fit) {
2508− return "fit-content";
2509− }
2510− ;
2511− if (v instanceof Fill) {
2512− return "fill";
2513− }
2514− ;
2515− if (v instanceof Max2) {
2516− return "max-" + (show2(v.value0) + ("-" + renderKey(renderableLength)(v.value1)));
2517− }
2518− ;
2519− if (v instanceof Min2) {
2520− return "min-" + (show2(v.value0) + ("-" + renderKey(renderableLength)(v.value1)));
2521− }
2522− ;
2523− throw new Error("Failed pattern match at Plum.View (line 301, column 15 - line 306, column 56): " + [v.constructor.name]);
2524− }
2525− };
2526− var renderKey2 = /* @__PURE__ */ renderKey(renderableLength);
2527− var render2 = /* @__PURE__ */ render(renderableLength);
2528− var skin = function(ctx) {
2529− return function(v) {
2530− if (v instanceof Spacing) {
2531− return sk("spacing-" + (show2(v.value0) + ("-" + show2(v.value1))))("gap")(show2(v.value0) + ("px " + (show2(v.value1) + "px")));
2532− }
2533− ;
2534− if (v instanceof Explain) {
2535− return sk("explain")("border")("dashed magenta");
2536− }
2537− ;
2538− if (v instanceof Align) {
2539− if (ctx instanceof Generic) {
2540− return mempty22;
2541− }
2542− ;
2543− if (ctx instanceof Span) {
2544− return mempty22;
2545− }
2546− ;
2547− if (ctx instanceof Grid) {
2548− var v1 = function() {
2549− if (v.value1 instanceof Start) {
2550− return "start";
2551− }
2552− ;
2553− if (v.value1 instanceof Center) {
2554− return "center";
2555− }
2556− ;
2557− if (v.value1 instanceof End) {
2558− return "end";
2559− }
2560− ;
2561− throw new Error("Failed pattern match at Plum.View (line 244, column 13 - line 247, column 27): " + [v.value1.constructor.name]);
2562− }();
2563− var k = function() {
2564− if (v.value0 instanceof X) {
2565− return "justify-items";
2566− }
2567− ;
2568− if (v.value0 instanceof Y) {
2569− return "align-items";
2570− }
2571− ;
2572− throw new Error("Failed pattern match at Plum.View (line 239, column 13 - line 241, column 33): " + [v.value0.constructor.name]);
2573− }();
2574− return sk("align-grid-" + (k + ("-" + v1)))(k)(v1);
2575− }
2576− ;
2577− if (ctx instanceof Flexbox) {
2578− var v1 = function() {
2579− if (v.value1 instanceof Start) {
2580− return "flex-start";
2581− }
2582− ;
2583− if (v.value1 instanceof Center) {
2584− return "center";
2585− }
2586− ;
2587− if (v.value1 instanceof End) {
2588− return "flex-end";
2589− }
2590− ;
2591− throw new Error("Failed pattern match at Plum.View (line 263, column 13 - line 266, column 32): " + [v.value1.constructor.name]);
2592− }();
2593− var k = function() {
2594− var v2 = new Tuple(ctx.value0, v.value0);
2595− if (v2.value0 instanceof X && v2.value1 instanceof X) {
2596− return "justify-content";
2597− }
2598− ;
2599− if (v2.value0 instanceof X && v2.value1 instanceof Y) {
2600− return "align-items";
2601− }
2602− ;
2603− if (v2.value0 instanceof Y && v2.value1 instanceof X) {
2604− return "align-items";
2605− }
2606− ;
2607− if (v2.value0 instanceof Y && v2.value1 instanceof Y) {
2608− return "justify-content";
2609− }
2610− ;
2611− throw new Error("Failed pattern match at Plum.View (line 255, column 13 - line 259, column 42): " + [v2.constructor.name]);
2612− }();
2613− return sk("align-flexbox-" + (k + ("-" + v1)))(k)(v1);
2614− }
2615− ;
2616− throw new Error("Failed pattern match at Plum.View (line 233, column 26 - line 269, column 51): " + [ctx.constructor.name]);
2617− }
2618− ;
2619− if (v instanceof Width) {
2620− return sk("width-" + renderKey2(v.value0))("width")(render2(v.value0));
2621− }
2622− ;
2623− if (v instanceof Height) {
2624− return sk("width-" + renderKey2(v.value0))("height")(render2(v.value0));
2625− }
2626− ;
2627− if (v instanceof Wrapped) {
2628− if (ctx instanceof Flexbox) {
2629− return sk("wrapped")("flex-wrap")("wrap");
2630− }
2631− ;
2632− return pure2([]);
2633− }
2634− ;
2635− if (v instanceof BackgroundColor) {
2636− return sk("bg-color-" + renderKey1(v.value0))("background-color")(render1(v.value0));
2637− }
2638− ;
2639− if (v instanceof Padding) {
2640− return sk("padding-" + (show2(v.value0.top) + ("-" + (show2(v.value0.right) + ("-" + (show2(v.value0.bottom) + ("-" + show2(v.value0.left))))))))("padding")(show2(v.value0.top) + ("px " + (show2(v.value0.right) + ("px " + (show2(v.value0.bottom) + ("px " + (show2(v.value0.left) + "px")))))));
2641− }
2642− ;
2643− if (v instanceof Spread) {
2644− if (ctx instanceof Flexbox) {
2645− return sk("spread")("justify-content")("space-between");
2646− }
2647− ;
2648− return pure2([]);
2649− }
2650− ;
2651− if (v instanceof Opacity) {
2652− return sk("opacity-" + show1(v.value0))("opacity")(show1(v.value0));
2653− }
2654− ;
2655− if (v instanceof Pointer) {
2656− return sk("pointer")("cursor")("pointer");
2657− }
2658− ;
2659− if (v instanceof Move) {
2660− return sk("move-" + (show2(v.value0.x) + ("-" + show2(v.value0.y))))("transform")("translate(" + (show2(v.value0.x) + ("px, " + (show2(v.value0.y) + "px)"))));
2661− }
2662− ;
2663− if (v instanceof Clip && v.value0 instanceof X) {
2664− return sk("clip-x")("overflow-x")("hidden");
2665− }
2666− ;
2667− if (v instanceof Clip && v.value0 instanceof Y) {
2668− return sk("clip-y")("overflow-y")("hidden");
2669− }
2670− ;
2671− throw new Error("Failed pattern match at Plum.View (line 230, column 12 - line 288, column 46): " + [v.constructor.name]);
2672− };
2673− };
2674− var hWith = function(elem2) {
2675− return function(props) {
2676− return function(classes) {
2677− return function(children) {
2678− return h2(elem2)(unsafeUnion(props)({
2679− "class": intercalate3(" ")(classes)
2680− }))(children);
2681− };
2682− };
2683− };
2684− };
2685− var h3 = function(elem2) {
2686− return function(classes) {
2687− return function(children) {
2688− return h2(elem2)({
2689− "class": intercalate3(" ")(classes)
2690− })(children);
2691− };
2692− };
2693− };
2694− var growSkin = function(fire) {
2695− return function(v) {
2696− return function(v1) {
2697− var widthFill = [new Width(Fill.value), new Height(Fill.value)];
2698− var alignCenter = [new Align(X.value, Center.value), new Align(Y.value, Center.value)];
2699− var skn = function(ctx) {
2700− return map2(function($424) {
2701− return function(v2) {
2702− return append2(v2)(v.extraSkin);
2703− }(concat($424));
2704− })(traverse2(skin(ctx))(append2(v1.value0.meat)(append2(function() {
2705− if (ctx instanceof Span) {
2706− return mempty2;
2707− }
2708− ;
2709− if (ctx instanceof Grid) {
2710− return widthFill;
2711− }
2712− ;
2713− if (ctx instanceof Flexbox) {
2714− return widthFill;
2715− }
2716− ;
2717− if (ctx instanceof Generic) {
2718− return widthFill;
2719− }
2720− ;
2721− throw new Error("Failed pattern match at Plum.View (line 368, column 16 - line 372, column 35): " + [ctx.constructor.name]);
2722− }())(function() {
2723− if (ctx instanceof Grid) {
2724− return alignCenter;
2725− }
2726− ;
2727− if (ctx instanceof Flexbox) {
2728− return alignCenter;
2729− }
2730− ;
2731− if (ctx instanceof Span) {
2732− return mempty2;
2733− }
2734− ;
2735− if (ctx instanceof Generic) {
2736− return alignCenter;
2737− }
2738− ;
2739− throw new Error("Failed pattern match at Plum.View (line 373, column 16 - line 377, column 37): " + [ctx.constructor.name]);
2740− }()))));
2741− };
2742− if (v1.value1 instanceof Text) {
2743− return map2(function(c) {
2744− return h3("span")(c)([string(v1.value1.value0)]);
2745− })(skn(Span.value));
2746− }
2747− ;
2748− if (v1.value1 instanceof Wrapper) {
2749− return bind2(append22(skn(new Flexbox(X.value)))(append22(sk("display-flex")("display")("flex"))(sk("flex-direction-row")("flex-direction")("row"))))(function(classes) {
2750− return bind2(growSkin(fire)(mempty3)(v1.value1.value0))(function(x$prime) {
2751− return pure2(h3("div")(classes)([x$prime]));
2752− });
2753− });
2754− }
2755− ;
2756− if (v1.value1 instanceof Stack) {
2757− return bind2(append22(skn(Grid.value))(sk("display-grid")("display")("grid")))(function(classes) {
2758− return bind2(append22(sk("grid-row-1")("grid-row")("1"))(sk("grid-column-1")("grid-column")("1")))(function(extraSkin) {
2759− return bind2(traverse2(growSkin(fire)({
2760− extraSkin
2761− }))(v1.value1.value0))(function(children$prime) {
2762− return pure2(h3("div")(classes)(children$prime));
2763− });
2764− });
2765− });
2766− }
2767− ;
2768− if (v1.value1 instanceof Row) {
2769− return bind2(append22(skn(new Flexbox(X.value)))(append22(sk("display-flex")("display")("flex"))(sk("flex-direction-row")("flex-direction")("row"))))(function(classes) {
2770− return bind2(traverse2(growSkin(fire)(mempty3))(v1.value1.value0))(function(children$prime) {
2771− return pure2(h3("div")(classes)(children$prime));
2772− });
2773− });
2774− }
2775− ;
2776− if (v1.value1 instanceof Column) {
2777− return bind2(append22(skn(new Flexbox(Y.value)))(append22(sk("display-flex")("display")("flex"))(sk("flex-direction-column")("flex-direction")("column"))))(function(classes) {
2778− return bind2(traverse2(growSkin(fire)(mempty3))(v1.value1.value0))(function(children$prime) {
2779− return pure2(h3("div")(classes)(children$prime));
2780− });
2781− });
2782− }
2783− ;
2784− if (v1.value1 instanceof Link) {
2785− return bind2(append22(skn(new Flexbox(X.value)))(append22(sk("display-flex")("display")("flex"))(sk("flex-direction-row")("flex-direction")("row"))))(function(classes) {
2786− return bind2(growSkin(fire)(mempty3)(v1.value1.value2))(function(child$prime) {
2787− return pure2(hWith("a")({
2788− href: v1.value1.value0,
2789− rel: "noopener noreferrer",
2790− target: function() {
2791− if (v1.value1.value1.newTab) {
2792− return "_blank";
2793− }
2794− ;
2795− return "_self";
2796− }()
2797− })(classes)([child$prime]));
2798− });
2799− });
2800− }
2801− ;
2802− if (v1.value1 instanceof Download) {
2803− return bind2(append22(skn(new Flexbox(X.value)))(append22(sk("display-flex")("display")("flex"))(sk("flex-direction-row")("flex-direction")("row"))))(function(classes) {
2804− return bind2(growSkin(fire)(mempty3)(v1.value1.value2))(function(child$prime) {
2805− return pure2(hWith("a")({
2806− href: v1.value1.value0,
2807− download: fromMaybe("")(v1.value1.value1.filename)
2808− })(classes)([child$prime]));
2809− });
2810− });
2811− }
2812− ;
2813− if (v1.value1 instanceof Image2) {
2814− return map2(function(c) {
2815− return hWith("img")({
2816− src: v1.value1.value0,
2817− alt: v1.value1.value1.description
2818− })(c)([]);
2819− })(skn(Generic.value));
2820− }
2821− ;
2822− if (v1.value1 instanceof None) {
2823− return pure2(h3("div")(mempty2)([]));
2824− }
2825− ;
2826− throw new Error("Failed pattern match at Plum.View (line 380, column 3 - line 421, column 37): " + [v1.value1.constructor.name]);
2827− };
2828− };
2829− };
2830− var grow = function(fire) {
2831− return function(v) {
2832− var v1 = runWriter(growSkin(fire)(mempty3)(v));
2833− return {
2834− node: v1.value0,
2835− style: styleSkinGrowth(v1.value1)
2836− };
2837− };
2838− };
2839− var column = function(v) {
2840− return new UI({
2841− nerves: mempty1.nerves,
2842− meat: mempty1.meat,
2843− hover: mempty1.hover,
2844− down: mempty1.down,
2845− children: [new Tuple({
2846− meat: v.value0.meat,
2847− nerves: v.value0.nerves,
2848− hover: v.value0.hover,
2849− down: v.value0.down
2850− }, new Column(v.value0.children))]
2851− }, v.value1);
2852− };
2853−
2854− // output/Web.DOM.NonElementParentNode/foreign.js
2855− function _getElementById(id) {
2856− return function(node) {
2857− return function() {
2858− return node.getElementById(id);
2859− };
2860− };
2861− }
2862−
2863− // output/Data.Nullable/foreign.js
2864− function nullable(a, r, f) {
2865− return a == null ? r : f(a);
2866− }
2867−
2868− // output/Data.Nullable/index.js
2869− var toMaybe = function(n) {
2870− return nullable(n, Nothing.value, Just.create);
2871− };
2872−
2873− // output/Web.DOM.NonElementParentNode/index.js
2874− var map3 = /* @__PURE__ */ map(functorEffect);
2875− var getElementById = function(eid) {
2876− var $2 = map3(toMaybe);
2877− var $3 = _getElementById(eid);
2878− return function($4) {
2879− return $2($3($4));
2880− };
2881− };
2882−
2883− // output/Web.HTML/foreign.js
2884− var windowImpl = function() {
2885− return window;
2886− };
2887−
2888− // output/Web.HTML.HTMLDocument/index.js
2889− var toNonElementParentNode = unsafeCoerce2;
2890−
2891− // output/Web.HTML.Window/foreign.js
2892− function document2(window2) {
2893− return function() {
2894− return window2.document;
2895− };
2896− }
2897−
2898− // output/Plum/index.js
2899− var bind3 = /* @__PURE__ */ bind(bindEffect);
2900− var outerStyle = "html,body{height:100%;padding:0;margin:0;}";
2901− var run3 = function(id) {
2902− return function(plum2) {
2903− return function __do() {
2904− var modelRef = bind3(plum2.init)($$new)();
2905− var v = bind3(bind3(windowImpl)(document2))(function() {
2906− var $21 = getElementById(id);
2907− return function($22) {
2908− return $21(toNonElementParentNode($22));
2909− };
2910− }())();
2911− if (v instanceof Just) {
2912− var projector = createProjector();
2913− return replace(projector)(v.value0)(function __do2() {
2914− var model = read(modelRef)();
2915− var v1 = plum2.view(model);
2916− var v2 = head(v1.value0.children);
2917− if (v2 instanceof Nothing) {
2918− return h2("div")({})([]);
2919− }
2920− ;
2921− if (v2 instanceof Just) {
2922− var v3 = grow(function(msg) {
2923− return function __do3() {
2924− var m = read(modelRef)();
2925− var m_ = plum2.update(msg)(m)();
2926− write(m_)(modelRef)();
2927− return scheduleRender(projector)();
2928− };
2929− })(v2.value0);
2930− return h2("div")({
2931− styles: {
2932− height: "100%",
2933− width: "100%"
2934− }
2935− })([h2("style")({})([string(outerStyle + v3.style)]), v3.node]);
2936− }
2937− ;
2938− throw new Error("Failed pattern match at Plum (line 35, column 20 - line 52, column 94): " + [v2.constructor.name]);
2939− })();
2940− }
2941− ;
2942− if (v instanceof Nothing) {
2943− return unit;
2944− }
2945− ;
2946− throw new Error("Failed pattern match at Plum (line 26, column 92 - line 54, column 25): " + [v.constructor.name]);
2947− };
2948− };
2949− };
2950−
2951− // output/Main/index.js
2952− var pure3 = /* @__PURE__ */ pure(applicativeEffect);
2953− var discard3 = /* @__PURE__ */ discard(discardUnit)(/* @__PURE__ */ bindGenericUI(monoidArray));
2954− var mempty4 = /* @__PURE__ */ mempty(/* @__PURE__ */ monoidGenericUI(monoidUnit)(monoidUnit));
2955− var plum = {
2956− init: /* @__PURE__ */ pure3({
2957− text: "Test"
2958− }),
2959− view: function(model) {
2960− return column(discard3(text("hi")(mempty4))(function() {
2961− return text("hello")(mempty4);
2962− }));
2963− },
2964− update: function(msg) {
2965− return function(model) {
2966− return pure3({
2967− text: "Button pressed"
2968− });
2969− };
2970− }
2971− };
2972− var main = /* @__PURE__ */ run3("plum")(plum);
2973−
2974− // <stdin>
2975− main();
2976−})();
plum/spago.dhall+5
@@ -6,12 +6,15 @@
66 , "effect"
77 , "foldable-traversable"
88 , "foreign-object"
9+ , "functions"
910 , "integers"
11+ , "literals"
1012 , "maybe"
1113 , "numbers"
1214 , "prelude"
1315 , "record"
1416 , "refs"
17+ , "strings"
1518 , "strings-extra"
1619 , "transformers"
1720 , "tuples"
@@ -19,7 +22,9 @@
1922 , "unsafe-coerce"
2023 , "untagged-union"
2124 , "web-dom"
25+ , "web-events"
2226 , "web-html"
27+ , "web-uievents"
2328 ]
2429, packages = ../packages.dhall
2530, sources = [ "src/**/*.purs", "test/**/*.purs" ]
plum/src/Main.purs+43−9
@@ -1,25 +1,59 @@
11module Main where
22
3+import Plum.View
34import Prelude
45
5−import Data.Array as Array
66import Effect (Effect)
77import Plum as Plum
8−import Plum.View
98
109main :: Effect Unit
1110main = do
1211 Plum.run "plum" plum
1312
14−type Model = { text :: String }
13+type Model = { text :: String, numberOfClicks :: Int }
14+
15+data Msg = Clicked | UpdateText String
1516
16−plum :: Plum.Plum Unit Model
17+plum :: Plum.Plum Msg Model
1718plum =
18− { init: pure { text: "Test" }
19+ { init: pure { text: "Test", numberOfClicks: 0 }
1920 , view: \model -> do
20− column $ do
21− text "hi" mempty
22− text "hello" mempty
21+ column do
22+ stack do
23+ align Y End
24+ height Fit
25+ row do
26+ align Y End
27+ column do
28+ bgColor $ rgb 0.0 0.0 0.0
29+ height (Px 10)
30+ column mempty
31+ pure unit
32+ column do
33+ font "sans-serif"
34+ column do
35+ height (Px 100)
36+ width Fit
37+ align Y Start
38+ width Fill
39+ column $ do
40+ width Fill
41+ width Fit
42+ height Fit
43+ text "PureStack" do
44+ fontSize 72
45+ fontWeight 1000
46+ column do
47+ bgColor $ rgb 0.0 0.0 0.0
48+ height (Px 10)
49+ width Fill
50+ column do
51+ width Fill
52+ row do
53+ text (model.text <> ": " <> show model.numberOfClicks) mempty
54+ onClick Clicked
55+ textInput { onChange: UpdateText, value: model.text } mempty
2356 , update: \msg model -> case msg of
24− _ -> pure { text: "Button pressed" }
57+ Clicked -> pure model { text = "Button pressed", numberOfClicks = model.numberOfClicks + 1 }
58+ UpdateText text -> pure model { text = text }
2559 }
plum/src/Maquette.jsdeleted−953
@@ -1,953 +0,0 @@
1−'use strict';
2−
3−var NAMESPACE_W3 = "http://www.w3.org/";
4−var NAMESPACE_SVG = NAMESPACE_W3 + "2000/svg";
5−var NAMESPACE_XLINK = NAMESPACE_W3 + "1999/xlink";
6−var emptyArray = [];
7−var extend = function (base, overrides) {
8− var result = {};
9− Object.keys(base).forEach(function (key) {
10− result[key] = base[key];
11− });
12− if (overrides) {
13− Object.keys(overrides).forEach(function (key) {
14− result[key] = overrides[key];
15− });
16− }
17− return result;
18−};
19−var same = function (vnode1, vnode2) {
20− if (vnode1.vnodeSelector !== vnode2.vnodeSelector) {
21− return false;
22− }
23− if (vnode1.properties && vnode2.properties) {
24− if (vnode1.properties.key !== vnode2.properties.key) {
25− return false;
26− }
27− return vnode1.properties.bind === vnode2.properties.bind;
28− }
29− return !vnode1.properties && !vnode2.properties;
30−};
31−var checkStyleValue = function (styleValue) {
32− if (typeof styleValue !== "string") {
33− throw new Error("Style values must be strings");
34− }
35−};
36−var findIndexOfChild = function (children, sameAs, start) {
37− if (sameAs.vnodeSelector !== "") {
38− // Never scan for text-nodes
39− for (var i = start; i < children.length; i++) {
40− if (same(children[i], sameAs)) {
41− return i;
42− }
43− }
44− }
45− return -1;
46−};
47−var checkDistinguishable = function (childNodes, indexToCheck, parentVNode, operation) {
48− var childNode = childNodes[indexToCheck];
49− if (childNode.vnodeSelector === "") {
50− return; // Text nodes need not be distinguishable
51− }
52− var properties = childNode.properties;
53− var key = properties
54− ? properties.key === undefined
55− ? properties.bind
56− : properties.key
57− : undefined;
58− if (!key) {
59− // A key is just assumed to be unique
60− for (var i = 0; i < childNodes.length; i++) {
61− if (i !== indexToCheck) {
62− var node = childNodes[i];
63− if (same(node, childNode)) {
64− throw {
65− error: new Error(parentVNode.vnodeSelector + " had a " + childNode.vnodeSelector + " child " + (operation === "added" ? operation : "removed") + ", but there is now more than one. You must add unique key properties to make them distinguishable."),
66− parentNode: parentVNode,
67− childNode: childNode,
68− };
69− }
70− }
71− }
72− }
73−};
74−var nodeAdded = function (vNode) {
75− if (vNode.properties) {
76− var enterAnimation = vNode.properties.enterAnimation;
77− if (enterAnimation) {
78− enterAnimation(vNode.domNode, vNode.properties);
79− }
80− }
81−};
82−var removedNodes = [];
83−var requestedIdleCallback = false;
84−var visitRemovedNode = function (node) {
85− (node.children || []).forEach(visitRemovedNode);
86− if (node.properties && node.properties.afterRemoved) {
87− node.properties.afterRemoved.apply(node.properties.bind || node.properties, [
88− node.domNode,
89− ]);
90− }
91−};
92−var processPendingNodeRemovals = function () {
93− requestedIdleCallback = false;
94− removedNodes.forEach(visitRemovedNode);
95− removedNodes.length = 0;
96−};
97−var scheduleNodeRemoval = function (vNode) {
98− removedNodes.push(vNode);
99− if (!requestedIdleCallback) {
100− requestedIdleCallback = true;
101− if (typeof window !== "undefined" && "requestIdleCallback" in window) {
102− window.requestIdleCallback(processPendingNodeRemovals, { timeout: 16 });
103− }
104− else {
105− setTimeout(processPendingNodeRemovals, 16);
106− }
107− }
108−};
109−var nodeToRemove = function (vNode) {
110− var domNode = vNode.domNode;
111− if (vNode.properties) {
112− var exitAnimation = vNode.properties.exitAnimation;
113− if (exitAnimation) {
114− domNode.style.pointerEvents = "none";
115− var removeDomNode = function () {
116− if (domNode.parentNode) {
117− domNode.parentNode.removeChild(domNode);
118− scheduleNodeRemoval(vNode);
119− }
120− };
121− exitAnimation(domNode, removeDomNode, vNode.properties);
122− return;
123− }
124− }
125− if (domNode.parentNode) {
126− domNode.parentNode.removeChild(domNode);
127− scheduleNodeRemoval(vNode);
128− }
129−};
130−var vnodeOnlyProps = [
131− "afterCreate",
132− "afterUpdate",
133− "afterRemoved",
134− "enterAnimation",
135− "exitAnimation",
136− "updateAnimation",
137−];
138−function filterVNodeOnlyProps(name) {
139− return !vnodeOnlyProps.includes(name);
140−}
141−var setProperties = function (domNode, properties, projectionOptions) {
142− if (!properties) {
143− return;
144− }
145− var eventHandlerInterceptor = projectionOptions.eventHandlerInterceptor;
146− var propNames = Object.keys(properties).filter(filterVNodeOnlyProps);
147− var propCount = propNames.length;
148− for (var i = 0; i < propCount; i++) {
149− var propName = propNames[i];
150− var propValue = properties[propName];
151− if (propName === "className") {
152− throw new Error('Property "className" is not supported, use "class".');
153− }
154− else if (propName === "class") {
155− toggleClasses(domNode, propValue, true);
156− }
157− else if (propName === "classes") {
158− // object with string keys and boolean values
159− var classNames = Object.keys(propValue);
160− var classNameCount = classNames.length;
161− for (var j = 0; j < classNameCount; j++) {
162− var className = classNames[j];
163− if (propValue[className]) {
164− domNode.classList.add(className);
165− }
166− }
167− }
168− else if (propName === "styles") {
169− // object with string keys and string (!) values
170− var styleNames = Object.keys(propValue);
171− var styleCount = styleNames.length;
172− for (var j = 0; j < styleCount; j++) {
173− var styleName = styleNames[j];
174− var styleValue = propValue[styleName];
175− if (styleValue) {
176− checkStyleValue(styleValue);
177− projectionOptions.styleApplyer(domNode, styleName, styleValue);
178− }
179− }
180− }
181− else if (propName === "on" && propValue) {
182− // object with string keys and function values
183− for (var _i = 0, _a = Object.entries(properties.on); _i < _a.length; _i++) {
184− var _b = _a[_i], key = _b[0], handler = _b[1];
185− var listener = typeof handler === "function" ? handler : handler.listener;
186− if (eventHandlerInterceptor) {
187− listener = eventHandlerInterceptor(key, listener, domNode, properties);
188− }
189− if (listener) {
190− domNode.addEventListener(key, listener, typeof handler === "function" ? undefined : handler.options);
191− }
192− }
193− }
194− else if (propName !== "key" && propValue !== null && propValue !== undefined) {
195− var type = typeof propValue;
196− if (type === "function") {
197− if (propName.lastIndexOf("on", 0) === 0) {
198− // lastIndexOf(,0)===0 -> startsWith
199− if (eventHandlerInterceptor) {
200− propValue = eventHandlerInterceptor(propName, propValue, domNode, properties); // intercept eventhandlers
201− }
202− }
203− domNode[propName] = propValue;
204− }
205− else if (projectionOptions.namespace === NAMESPACE_SVG) {
206− if (propName === "href") {
207− domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);
208− }
209− else {
210− // all SVG attributes are read-only in DOM, so...
211− domNode.setAttribute(propName, propValue);
212− }
213− }
214− else if (type === "string" && propName !== "value" && propName !== "innerHTML") {
215− domNode.setAttribute(propName, propValue);
216− }
217− else {
218− domNode[propName] = propValue;
219− }
220− }
221− }
222−};
223−var addChildren = function (domNode, children, projectionOptions) {
224− if (!children) {
225− return;
226− }
227− for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
228− var child = children_1[_i];
229− createDom(child, domNode, undefined, projectionOptions);
230− }
231−};
232−var initPropertiesAndChildren = function (domNode, vnode, projectionOptions) {
233− addChildren(domNode, vnode.children, projectionOptions); // children before properties, needed for value property of <select>.
234− if (vnode.text) {
235− domNode.textContent = vnode.text;
236− }
237− setProperties(domNode, vnode.properties, projectionOptions);
238− if (vnode.properties && vnode.properties.afterCreate) {
239− vnode.properties.afterCreate.apply(vnode.properties.bind || vnode.properties, [
240− domNode,
241− projectionOptions,
242− vnode.vnodeSelector,
243− vnode.properties,
244− vnode.children,
245− ]);
246− }
247−};
248−var createDom = function (vnode, parentNode, insertBefore, projectionOptions) {
249− var _a;
250− var domNode;
251− var start = 0;
252− var vnodeSelector = vnode.vnodeSelector;
253− var doc = parentNode.ownerDocument;
254− if (vnodeSelector === "") {
255− if (vnode.domNode) {
256− vnode.domNode.nodeValue = vnode.text;
257− }
258− else {
259− domNode = vnode.domNode = doc.createTextNode(vnode.text);
260− if (insertBefore !== undefined) {
261− parentNode.insertBefore(domNode, insertBefore);
262− }
263− else {
264− parentNode.appendChild(domNode);
265− }
266− }
267− }
268− else {
269− for (var i = 0; i <= vnodeSelector.length; ++i) {
270− var c = vnodeSelector.charAt(i);
271− if (i === vnodeSelector.length || c === "." || c === "#") {
272− var type = vnodeSelector.charAt(start - 1);
273− var found = vnodeSelector.slice(start, i);
274− if (type === ".") {
275− domNode.classList.add(found);
276− }
277− else if (type === "#") {
278− domNode.id = found;
279− }
280− else {
281− if (found === "svg") {
282− projectionOptions = extend(projectionOptions, {
283− namespace: NAMESPACE_SVG,
284− });
285− }
286− if (projectionOptions.namespace !== undefined) {
287− domNode = vnode.domNode = doc.createElementNS(projectionOptions.namespace, found);
288− }
289− else {
290− domNode = vnode.domNode =
291− vnode.domNode ||
292− (((_a = vnode.properties) === null || _a === void 0 ? void 0 : _a.is) ? doc.createElement(found, { is: vnode.properties.is })
293− : doc.createElement(found));
294− if (found === "input" && vnode.properties && vnode.properties.type !== undefined) {
295− // IE8 and older don't support setting input type after the DOM Node has been added to the document
296− domNode.setAttribute("type", vnode.properties.type);
297− }
298− }
299− if (insertBefore !== undefined) {
300− parentNode.insertBefore(domNode, insertBefore);
301− }
302− else if (domNode.parentNode !== parentNode) {
303− parentNode.appendChild(domNode);
304− }
305− }
306− start = i + 1;
307− }
308− }
309− initPropertiesAndChildren(domNode, vnode, projectionOptions);
310− }
311−};
312−var updateDom;
313−/**
314− * Adds or removes classes from an Element
315− * @param domNode the element
316− * @param classes a string separated list of classes
317− * @param on true means add classes, false means remove
318− */
319−var toggleClasses = function (domNode, classes, on) {
320− if (!classes) {
321− return;
322− }
323− classes.split(" ").forEach(function (classToToggle) {
324− if (classToToggle) {
325− domNode.classList.toggle(classToToggle, on);
326− }
327− });
328−};
329−var updateProperties = function (domNode, previousProperties, properties, projectionOptions) {
330− if (!properties) {
331− return;
332− }
333− var propertiesUpdated = false;
334− var propNames = Object.keys(properties).filter(filterVNodeOnlyProps);
335− var propCount = propNames.length;
336− for (var i = 0; i < propCount; i++) {
337− var propName = propNames[i];
338− // assuming that properties will be nullified instead of missing is by design
339− var propValue = properties[propName];
340− var previousValue = previousProperties[propName];
341− if (propName === "class") {
342− if (previousValue !== propValue) {
343− toggleClasses(domNode, previousValue, false);
344− toggleClasses(domNode, propValue, true);
345− }
346− }
347− else if (propName === "classes") {
348− var classList = domNode.classList;
349− var classNames = Object.keys(propValue);
350− var classNameCount = classNames.length;
351− for (var j = 0; j < classNameCount; j++) {
352− var className = classNames[j];
353− var on = !!propValue[className];
354− var previousOn = !!previousValue[className];
355− if (on === previousOn) {
356− continue;
357− }
358− propertiesUpdated = true;
359− if (on) {
360− classList.add(className);
361− }
362− else {
363− classList.remove(className);
364− }
365− }
366− }
367− else if (propName === "styles") {
368− var styleNames = Object.keys(propValue);
369− var styleCount = styleNames.length;
370− for (var j = 0; j < styleCount; j++) {
371− var styleName = styleNames[j];
372− var newStyleValue = propValue[styleName];
373− var oldStyleValue = previousValue[styleName];
374− if (newStyleValue === oldStyleValue) {
375− continue;
376− }
377− propertiesUpdated = true;
378− if (newStyleValue) {
379− checkStyleValue(newStyleValue);
380− projectionOptions.styleApplyer(domNode, styleName, newStyleValue);
381− }
382− else {
383− projectionOptions.styleApplyer(domNode, styleName, "");
384− }
385− }
386− }
387− else {
388− if (!propValue && typeof previousValue === "string") {
389− propValue = "";
390− }
391− if (propName === "value") {
392− // value can be manipulated by the user directly and using event.preventDefault() is not an option
393− var domValue = domNode[propName];
394− if (domValue !== propValue && // The 'value' in the DOM tree !== newValue
395− propValue !== previousValue // Only update the value if the vdom changed
396− ) {
397− // The edge cases are described in the tests
398− domNode[propName] = propValue; // Reset the value, even if the virtual DOM did not change
399− } // else do not update the domNode, otherwise the cursor position would be changed
400− if (propValue !== previousValue) {
401− propertiesUpdated = true;
402− }
403− }
404− else if (propValue !== previousValue) {
405− var type = typeof propValue;
406− if (type !== "function" || !projectionOptions.eventHandlerInterceptor) {
407− // Function updates are expected to be handled by the EventHandlerInterceptor
408− if (projectionOptions.namespace === NAMESPACE_SVG) {
409− if (propName === "href") {
410− domNode.setAttributeNS(NAMESPACE_XLINK, propName, propValue);
411− }
412− else {
413− // all SVG attributes are read-only in DOM, so...
414− domNode.setAttribute(propName, propValue);
415− }
416− }
417− else if (type === "string" && propName !== "innerHTML") {
418− if (propName === "role" && propValue === "") {
419− domNode.removeAttribute(propName);
420− }
421− else {
422− domNode.setAttribute(propName, propValue);
423− }
424− }
425− else if (domNode[propName] !== propValue) {
426− // Comparison is here for side-effects in Edge with scrollLeft and scrollTop
427− domNode[propName] = propValue;
428− }
429− propertiesUpdated = true;
430− }
431− }
432− }
433− }
434− return propertiesUpdated;
435−};
436−var updateChildren = function (vnode, domNode, oldChildren, newChildren, projectionOptions) {
437− if (oldChildren === newChildren) {
438− return false;
439− }
440− oldChildren = oldChildren || emptyArray;
441− newChildren = newChildren || emptyArray;
442− var oldChildrenLength = oldChildren.length;
443− var newChildrenLength = newChildren.length;
444− var oldIndex = 0;
445− var newIndex = 0;
446− var i;
447− var textUpdated = false;
448− while (newIndex < newChildrenLength) {
449− var oldChild = oldIndex < oldChildrenLength ? oldChildren[oldIndex] : undefined;
450− var newChild = newChildren[newIndex];
451− if (oldChild !== undefined && same(oldChild, newChild)) {
452− textUpdated =
453− updateDom(oldChild, newChild, projectionOptions, domNode, oldChildren) || textUpdated;
454− oldIndex++;
455− }
456− else {
457− var findOldIndex = findIndexOfChild(oldChildren, newChild, oldIndex + 1);
458− if (findOldIndex >= 0) {
459− // Remove preceding missing children
460− for (i = oldIndex; i < findOldIndex; i++) {
461− nodeToRemove(oldChildren[i]);
462− checkDistinguishable(oldChildren, i, vnode, "removed");
463− }
464− textUpdated =
465− updateDom(oldChildren[findOldIndex], newChild, projectionOptions, domNode, oldChildren) ||
466− textUpdated;
467− oldIndex = findOldIndex + 1;
468− }
469− else {
470− // New child
471− createDom(newChild, domNode, oldIndex < oldChildrenLength ? oldChildren[oldIndex].domNode : undefined, projectionOptions);
472− nodeAdded(newChild);
473− checkDistinguishable(newChildren, newIndex, vnode, "added");
474− }
475− }
476− newIndex++;
477− }
478− if (oldChildrenLength > oldIndex) {
479− // Remove child fragments
480− for (i = oldIndex; i < oldChildrenLength; i++) {
481− nodeToRemove(oldChildren[i]);
482− checkDistinguishable(oldChildren, i, vnode, "removed");
483− }
484− }
485− return textUpdated;
486−};
487−updateDom = function (previous, vnode, projectionOptions, parentNode, oldChildren) {
488− var domNode = previous.domNode;
489− var textUpdated = false;
490− if (previous === vnode) {
491− return false; // By contract, VNode objects may not be modified anymore after passing them to maquette
492− }
493− var updated = false;
494− if (vnode.vnodeSelector === "") {
495− if (vnode.text !== previous.text) {
496− var newTextNode = domNode.ownerDocument.createTextNode(vnode.text);
497− try {
498− parentNode.replaceChild(newTextNode, domNode);
499− }
500− catch (e) {
501− // Text nodes can be substituted by google translate
502− parentNode.replaceChild(newTextNode, parentNode.childNodes[oldChildren.indexOf(previous)]);
503− }
504− vnode.domNode = newTextNode;
505− textUpdated = true;
506− return textUpdated;
507− }
508− vnode.domNode = domNode;
509− }
510− else {
511− if (vnode.vnodeSelector.lastIndexOf("svg", 0) === 0) {
512− // lastIndexOf(needle,0)===0 means StartsWith
513− projectionOptions = extend(projectionOptions, {
514− namespace: NAMESPACE_SVG,
515− });
516− }
517− if (previous.text !== vnode.text) {
518− updated = true;
519− if (vnode.text === undefined) {
520− domNode.removeChild(domNode.firstChild); // the only textnode presumably
521− }
522− else {
523− domNode.textContent = vnode.text;
524− }
525− }
526− vnode.domNode = domNode;
527− updated =
528− updateChildren(vnode, domNode, previous.children, vnode.children, projectionOptions) ||
529− updated;
530− updated =
531− updateProperties(domNode, previous.properties, vnode.properties, projectionOptions) ||
532− updated;
533− if (vnode.properties && vnode.properties.afterUpdate) {
534− vnode.properties.afterUpdate.apply(vnode.properties.bind || vnode.properties, [
535− domNode,
536− projectionOptions,
537− vnode.vnodeSelector,
538− vnode.properties,
539− vnode.children,
540− ]);
541− }
542− }
543− if (updated && vnode.properties && vnode.properties.updateAnimation) {
544− vnode.properties.updateAnimation(domNode, vnode.properties, previous.properties);
545− }
546− return textUpdated;
547−};
548−var createProjection = function (vnode, projectionOptions) {
549− return {
550− getLastRender: function () { return vnode; },
551− update: function (updatedVnode) {
552− if (vnode.vnodeSelector !== updatedVnode.vnodeSelector) {
553− throw new Error("The selector for the root VNode may not be changed. (consider using dom.merge and add one extra level to the virtual DOM)");
554− }
555− var previousVNode = vnode;
556− vnode = updatedVnode;
557− updateDom(previousVNode, updatedVnode, projectionOptions, previousVNode.domNode.parentNode, [previousVNode]);
558− },
559− domNode: vnode.domNode,
560− };
561−};
562−
563−var DEFAULT_PROJECTION_OPTIONS = {
564− namespace: undefined,
565− performanceLogger: function () { return undefined; },
566− eventHandlerInterceptor: undefined,
567− styleApplyer: function (domNode, styleName, value) {
568− if (styleName.charAt(0) === "-") {
569− // CSS variables must be set using setProperty
570− domNode.style.setProperty(styleName, value);
571− }
572− else {
573− // properties like 'backgroundColor' must be set as a js-property
574− domNode.style[styleName] = value;
575− }
576− },
577−};
578−var applyDefaultProjectionOptions = function (projectorOptions) {
579− return extend(DEFAULT_PROJECTION_OPTIONS, projectorOptions);
580−};
581−export var dom = {
582− /**
583− * Creates a real DOM tree from `vnode`. The [[Projection]] object returned will contain the resulting DOM Node in
584− * its [[Projection.domNode|domNode]] property.
585− * This is a low-level method. Users will typically use a [[Projector]] instead.
586− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
587− * objects may only be rendered once.
588− * @param projectionOptions - Options to be used to create and update the projection.
589− * @returns The [[Projection]] which also contains the DOM Node that was created.
590− */
591− create: function (vnode, projectionOptions) {
592− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
593− createDom(vnode, document.createElement("div"), undefined, projectionOptions);
594− return createProjection(vnode, projectionOptions);
595− },
596− /**
597− * Appends a new child node to the DOM which is generated from a [[VNode]].
598− * This is a low-level method. Users will typically use a [[Projector]] instead.
599− * @param parentNode - The parent node for the new child node.
600− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
601− * objects may only be rendered once.
602− * @param projectionOptions - Options to be used to create and update the [[Projection]].
603− * @returns The [[Projection]] that was created.
604− */
605− append: function (parentNode, vnode, projectionOptions) {
606− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
607− createDom(vnode, parentNode, undefined, projectionOptions);
608− return createProjection(vnode, projectionOptions);
609− },
610− /**
611− * Inserts a new DOM node which is generated from a [[VNode]].
612− * This is a low-level method. Users wil typically use a [[Projector]] instead.
613− * @param beforeNode - The node that the DOM Node is inserted before.
614− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function.
615− * NOTE: [[VNode]] objects may only be rendered once.
616− * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
617− * @returns The [[Projection]] that was created.
618− */
619− insertBefore: function (beforeNode, vnode, projectionOptions) {
620− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
621− createDom(vnode, beforeNode.parentNode, beforeNode, projectionOptions);
622− return createProjection(vnode, projectionOptions);
623− },
624− /**
625− * Merges a new DOM node which is generated from a [[VNode]] with an existing DOM Node.
626− * This means that the virtual DOM and the real DOM will have one overlapping element.
627− * Therefore the selector for the root [[VNode]] will be ignored, but its properties and children will be applied to the Element provided.
628− * This is a low-level method. Users wil typically use a [[Projector]] instead.
629− * @param element - The existing element to adopt as the root of the new virtual DOM. Existing attributes and child nodes are preserved.
630− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]] objects
631− * may only be rendered once.
632− * @param projectionOptions - Options to be used to create and update the projection, see [[createProjector]].
633− * @returns The [[Projection]] that was created.
634− */
635− merge: function (element, vnode, projectionOptions) {
636− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
637− vnode.domNode = element;
638− initPropertiesAndChildren(element, vnode, projectionOptions);
639− return createProjection(vnode, projectionOptions);
640− },
641− /**
642− * Replaces an existing DOM node with a node generated from a [[VNode]].
643− * This is a low-level method. Users will typically use a [[Projector]] instead.
644− * @param element - The node for the [[VNode]] to replace.
645− * @param vnode - The root of the virtual DOM tree that was created using the [[h]] function. NOTE: [[VNode]]
646− * objects may only be rendered once.
647− * @param projectionOptions - Options to be used to create and update the [[Projection]].
648− * @returns The [[Projection]] that was created.
649− */
650− replace: function (element, vnode, projectionOptions) {
651− projectionOptions = applyDefaultProjectionOptions(projectionOptions);
652− createDom(vnode, element.parentNode, element, projectionOptions);
653− element.parentNode.removeChild(element);
654− return createProjection(vnode, projectionOptions);
655− },
656−};
657−
658−var toTextVNode = function (data) {
659− return {
660− vnodeSelector: "",
661− properties: undefined,
662− children: undefined,
663− text: data.toString(),
664− domNode: null,
665− };
666−};
667−var appendChildren = function (parentSelector, insertions, main) {
668− for (var i = 0, length_1 = insertions.length; i < length_1; i++) {
669− var item = insertions[i];
670− if (Array.isArray(item)) {
671− appendChildren(parentSelector, item, main);
672− }
673− else {
674− if (item !== null && item !== undefined && item !== false) {
675− if (typeof item === "string") {
676− item = toTextVNode(item);
677− }
678− main.push(item);
679− }
680− }
681− }
682−};
683−function h(selector, properties, children) {
684− if (Array.isArray(properties)) {
685− children = properties;
686− properties = undefined;
687− }
688− else if ((properties && (typeof properties === "string" || properties.vnodeSelector)) ||
689− (children && (typeof children === "string" || children.vnodeSelector))) {
690− throw new Error("h called with invalid arguments");
691− }
692− var text;
693− var flattenedChildren;
694− // Recognize a common special case where there is only a single text node
695− if (children && children.length === 1 && typeof children[0] === "string") {
696− text = children[0];
697− }
698− else if (children) {
699− flattenedChildren = [];
700− appendChildren(selector, children, flattenedChildren);
701− if (flattenedChildren.length === 0) {
702− flattenedChildren = undefined;
703− }
704− }
705− return {
706− vnodeSelector: selector,
707− properties: properties,
708− children: flattenedChildren,
709− text: text === "" ? undefined : text,
710− domNode: null,
711− };
712−}
713−
714−var createParentNodePath = function (node, rootNode) {
715− var parentNodePath = [];
716− while (node && node !== rootNode) {
717− parentNodePath.push(node);
718− node = node.parentNode;
719− }
720− return parentNodePath;
721−};
722−var find;
723−if (Array.prototype.find) {
724− find = function (items, predicate) { return items.find(predicate); };
725−}
726−else {
727− find = function (items, predicate) { return items.filter(predicate)[0]; };
728−}
729−var findVNodeByParentNodePath = function (vnode, parentNodePath) {
730− var result = vnode;
731− parentNodePath.forEach(function (node) {
732− result =
733− result && result.children
734− ? find(result.children, function (child) { return child.domNode === node; })
735− : undefined;
736− });
737− return result;
738−};
739−var createEventHandlerInterceptor = function (projector, getProjection, performanceLogger) {
740− return function (propertyName, eventHandler, domNode, properties) { return modifiedEventHandler; };
741− function modifiedEventHandler(evt) {
742− var _a, _b;
743− performanceLogger("domEvent", evt);
744− var projection = getProjection();
745− var parentNodePath = createParentNodePath(evt.currentTarget, projection.domNode);
746− parentNodePath.reverse();
747− var matchingVNode = findVNodeByParentNodePath(projection.getLastRender(), parentNodePath);
748− projector.scheduleRender();
749− var result;
750− if (matchingVNode) {
751− /* eslint-disable prefer-rest-params */
752− var listener = (_b = (_a = matchingVNode.properties["on" + evt.type]) !== null && _a !== void 0 ? _a : matchingVNode.properties.on[evt.type].listener) !== null && _b !== void 0 ? _b : matchingVNode.properties.on[evt.type];
753− result = listener.apply(matchingVNode.properties.bind || this, arguments);
754− /* eslint-enable prefer-rest-params */
755− }
756− performanceLogger("domEventProcessed", evt);
757− return result;
758− }
759−};
760−/**
761− * Creates a [[Projector]] instance using the provided projectionOptions.
762− *
763− * For more information, see [[Projector]].
764− *
765− * @param projectorOptions Options that influence how the DOM is rendered and updated.
766− */
767−export var createProjector = function (projectorOptions) {
768− var projector;
769− var projectionOptions = applyDefaultProjectionOptions(projectorOptions);
770− var performanceLogger = projectionOptions.performanceLogger;
771− var renderCompleted = true;
772− var scheduled;
773− var stopped = false;
774− var projections = [];
775− var renderFunctions = []; // matches the projections array
776− var addProjection = function (
777− /* one of: dom.append, dom.insertBefore, dom.replace, dom.merge */
778− domFunction,
779− /* the parameter of the domFunction */
780− node, renderFunction) {
781− var projection;
782− var getProjection = function () { return projection; };
783− projectionOptions.eventHandlerInterceptor = createEventHandlerInterceptor(projector, getProjection, performanceLogger);
784− projection = domFunction(node, renderFunction(), projectionOptions);
785− projections.push(projection);
786− renderFunctions.push(renderFunction);
787− };
788− var doRender = function () {
789− scheduled = undefined;
790− if (!renderCompleted) {
791− return; // The last render threw an error, it should have been logged in the browser console.
792− }
793− renderCompleted = false;
794− performanceLogger("renderStart", undefined);
795− for (var i = 0; i < projections.length; i++) {
796− var updatedVnode = renderFunctions[i]();
797− performanceLogger("rendered", undefined);
798− projections[i].update(updatedVnode);
799− performanceLogger("patched", undefined);
800− }
801− performanceLogger("renderDone", undefined);
802− renderCompleted = true;
803− };
804− projector = {
805− renderNow: doRender,
806− scheduleRender: function () {
807− if (!scheduled && !stopped) {
808− scheduled = requestAnimationFrame(doRender);
809− }
810− },
811− stop: function () {
812− if (scheduled) {
813− cancelAnimationFrame(scheduled);
814− scheduled = undefined;
815− }
816− stopped = true;
817− },
818− resume: function () {
819− stopped = false;
820− renderCompleted = true;
821− projector.scheduleRender();
822− },
823− append: function (parentNode, renderFunction) {
824− addProjection(dom.append, parentNode, renderFunction);
825− },
826− insertBefore: function (beforeNode, renderFunction) {
827− addProjection(dom.insertBefore, beforeNode, renderFunction);
828− },
829− merge: function (domNode, renderFunction) {
830− addProjection(dom.merge, domNode, renderFunction);
831− },
832− replace: function (domNode, renderFunction) {
833− addProjection(dom.replace, domNode, renderFunction);
834− },
835− detach: function (renderFunction) {
836− for (var i = 0; i < renderFunctions.length; i++) {
837− if (renderFunctions[i] === renderFunction) {
838− renderFunctions.splice(i, 1);
839− return projections.splice(i, 1)[0];
840− }
841− }
842− throw new Error("renderFunction was not found");
843− },
844− };
845− return projector;
846−};
847−
848−/**
849− * Creates a [[CalculationCache]] object, useful for caching [[VNode]] trees.
850− * In practice, caching of [[VNode]] trees is not needed, because achieving 60 frames per second is almost never a problem.
851− * For more information, see [[CalculationCache]].
852− *
853− * @param <Result> The type of the value that is cached.
854− */
855−export var createCache = function () {
856− var cachedInputs;
857− var cachedOutcome;
858− return {
859− invalidate: function () {
860− cachedOutcome = undefined;
861− cachedInputs = undefined;
862− },
863− result: function (inputs, calculation) {
864− if (cachedInputs) {
865− for (var i = 0; i < inputs.length; i++) {
866− if (cachedInputs[i] !== inputs[i]) {
867− cachedOutcome = undefined;
868− }
869− }
870− }
871− if (!cachedOutcome) {
872− cachedOutcome = calculation();
873− cachedInputs = inputs;
874− }
875− return cachedOutcome;
876− },
877− };
878−};
879−
880−/**
881− * Creates a {@link Mapping} instance that keeps an array of result objects synchronized with an array of source objects.
882− * See {@link http://maquettejs.org/docs/arrays.html Working with arrays}.
883− *
884− * @param <Source> The type of source items. A database-record for instance.
885− * @param <Target> The type of target items. A [[MaquetteComponent]] for instance.
886− * @param getSourceKey `function(source)` that must return a key to identify each source object. The result must either be a string or a number.
887− * @param createResult `function(source, index)` that must create a new result object from a given source. This function is identical
888− * to the `callback` argument in `Array.map(callback)`.
889− * @param updateResult `function(source, target, index)` that updates a result to an updated source.
890− */
891−export var createMapping = function (getSourceKey, createResult, updateResult) {
892− var keys = [];
893− var results = [];
894− return {
895− results: results,
896− map: function (newSources) {
897− var newKeys = newSources.map(getSourceKey);
898− var oldTargets = results.slice();
899− var oldIndex = 0;
900− for (var i = 0; i < newSources.length; i++) {
901− var source = newSources[i];
902− var sourceKey = newKeys[i];
903− if (sourceKey === keys[oldIndex]) {
904− results[i] = oldTargets[oldIndex];
905− updateResult(source, oldTargets[oldIndex], i);
906− oldIndex++;
907− }
908− else {
909− var found = false;
910− for (var j = 1; j < keys.length + 1; j++) {
911− var searchIndex = (oldIndex + j) % keys.length;
912− if (keys[searchIndex] === sourceKey) {
913− results[i] = oldTargets[searchIndex];
914− updateResult(newSources[i], oldTargets[searchIndex], i);
915− oldIndex = searchIndex + 1;
916− found = true;
917− break;
918− }
919− }
920− if (!found) {
921− results[i] = createResult(source, i);
922− }
923− }
924− }
925− results.length = newSources.length;
926− keys = newKeys;
927− },
928− };
929−};
930−
931−export function _h(selector) {
932− return function (properties) {
933− return function (children) {
934− return h(selector, properties, children)
935− }
936− }
937−}
938−
939−export function scheduleRender(projector) {
940− return function () {
941− projector.scheduleRender()
942− }
943−}
944−
945−export function replace(projector) {
946− return function (el) {
947− return function (render) {
948− return function () {
949− projector.replace(el, render)
950− }
951− }
952− }
953−}
plum/src/Maquette.pursdeleted−33
@@ -1,33 +0,0 @@
1−module Maquette
2− ( Projector
3− , createProjector
4− , string
5− , VNode
6− , h
7− , replace
8− , scheduleRender
9− ) where
10−
11−import Prelude
12−
13−import Effect (Effect)
14−import Unsafe.Coerce (unsafeCoerce)
15−import Web.DOM (Element)
16−
17−foreign import data Projector :: Type
18−
19−foreign import createProjector :: Effect Projector
20−
21−foreign import data VNode :: Type
22−
23−foreign import _h :: forall props. String -> { | props } -> Array VNode -> VNode
24−
25−h :: forall props. String -> Record props -> Array VNode -> VNode
26−h = _h
27−
28−string :: String -> VNode
29−string = unsafeCoerce
30−
31−foreign import scheduleRender :: Projector -> Effect Unit
32−
33−foreign import replace :: Projector -> Element -> Effect VNode -> Effect Unit
plum/src/Plum.purs+58−29
@@ -2,13 +2,16 @@ module Plum (Plum, run) where
22
33import Prelude
44
5−import Data.Array ((:))
65import Data.Array as Array
76import Data.Maybe (Maybe(..))
87import Effect (Effect)
8+import Effect.Console (log)
99import Effect.Ref as Ref
10−import Maquette as Maquette
10+import Foreign.Object as Object
11+import Literals.Undefined (undefined)
1112import Plum.View (GenericUI(..), UI, grow)
13+import Snabbdom as Snabbdom
14+import Untagged.Union (asOneOf)
1215import Web.DOM.NonElementParentNode (getElementById) as Web
1316import Web.HTML (window) as Web
1417import Web.HTML.HTMLDocument (toNonElementParentNode) as Web
@@ -22,35 +25,61 @@ type Plum msg model =
2225
2326run :: forall msg model. String -> Plum msg model -> Effect Unit
2427run id plum = do
25− modelRef <- plum.init >>= Ref.new
2628 Web.window >>= Web.document >>= Web.getElementById id <<< Web.toNonElementParentNode >>= case _ of
2729 Just element -> do
28− projector <- Maquette.createProjector
29− Maquette.replace projector element do
30− model <- Ref.read modelRef
31−
32− ( let
33− UI { children } _ = plum.view model
34− in
35− pure $ case Array.head children of
36− Nothing -> Maquette.h "div" {} []
37− Just child ->
38− let
39− { node, style } =
40− ( grow
41− ( \msg -> do
42− m <- Ref.read modelRef
43− m_ <- plum.update msg m
44− Ref.write m_ modelRef
45− Maquette.scheduleRender projector
46− )
47− ) child
48− in
49− Maquette.h
50− "div"
51− { styles: { height: "100%", width: "100%" } }
52− [ Maquette.h "style" {} [ Maquette.string (outerStyle <> style) ], node ]
53− )
30+ let node = Snabbdom.toVNode element
31+ patch <- Snabbdom.init
32+ initModel <- plum.init
33+ modelRef <- Ref.new { model: initModel, lastNode: node }
34+ let
35+ view model = do
36+ let UI { children } _ = plum.view model
37+ case Array.uncons children of
38+ Just { head: child } -> do
39+ let
40+ { node, style } = grow
41+ ( \msg -> do
42+ log "in"
43+ { model: m, lastNode } <- Ref.read modelRef
44+ m_ <- plum.update msg m
45+ node <- view m_
46+ newNode <- patch lastNode node
47+ Ref.write { model: m_, lastNode: newNode } modelRef
48+ pure unit
49+ )
50+ child
51+ pure $
52+ Snabbdom.h "div"
53+ { attrs: Object.empty
54+ , on: Object.empty
55+ , style: Object.empty
56+ , props: Object.empty
57+ }
58+ [ Snabbdom.h "style"
59+ { attrs: Object.empty
60+ , on: Object.empty
61+ , style: Object.empty
62+ , props: Object.empty
63+ }
64+ []
65+ (asOneOf $ outerStyle <> style)
66+ , node
67+ ]
68+ (asOneOf undefined)
69+ Nothing -> pure $
70+ Snabbdom.h "div"
71+ { attrs: Object.empty
72+ , on: Object.empty
73+ , style: Object.empty
74+ , props: Object.empty
75+ }
76+ []
77+ (asOneOf undefined)
78+ newNode <- view initModel
79+ newNode_ <- patch node newNode
80+ log "patched"
81+ Ref.write { model: initModel, lastNode: newNode_ } modelRef
82+ pure unit
5483 Nothing -> pure unit
5584
5685outerStyle :: String
plum/src/Plum/View.purs+328−56
@@ -2,6 +2,12 @@ module Plum.View
22 ( View
33 , Nerve(..)
44 , Meat(..)
5+ , Font
6+ , BorderStyle(..)
7+ , Corner(..)
8+ , Shadow(..)
9+ , ShadowCfg
10+ , Side(..)
511 , Bones(..)
612 , grow
713 , Direction(..)
@@ -21,30 +27,69 @@ module Plum.View
2127 , text
2228 , link
2329 , newTabLink
24− , el
2530 , download
2631 , downloadAs
2732 , image
33+ , textInput
2834 , spacing
2935 , explain
36+ , align
37+ , width
38+ , height
39+ , wrapped
40+ , bgColor
41+ , padding
42+ , spread
43+ , opacity
44+ , pointer
45+ , move
46+ , clip
47+ , borders
48+ , border
49+ , borderStyle
50+ , roundAll
51+ , round
52+ , shadow
53+ , innerShadow
54+ , onHover
55+ , onMouseDown
56+ , font
57+ , fontSize
58+ , fontWeight
59+ , onClick
3060 ) where
3161
3262import Prelude
3363
3464import Control.Monad.Writer (Writer, runWriter, tell)
65+import Control.Monad.Writer.Trans (mapWriterT)
66+import Data.Array (foldMap)
3567import Data.Array as Array
68+import Data.Array.NonEmpty (concatMap)
3669import Data.Int as Int
3770import Data.Maybe (Maybe(..))
3871import Data.Maybe as Maybe
72+import Data.String as String
3973import Data.Traversable (traverse)
74+import Data.TraversableWithIndex (traverseWithIndex)
4075import Data.Tuple.Nested (type (/\), (/\))
4176import Effect (Effect)
4277import Foreign.Object (Object)
4378import Foreign.Object as Object
44−import Maquette (VNode, string)
45−import Maquette as Maquette
46−import Record.Unsafe.Union as Record
47−import Web.HTML (ClassName)
79+import Literals.Undefined (undefined)
80+import Prim.TypeError (class Warn)
81+import Prim.TypeError as TypeError
82+import Snabbdom (VNode)
83+import Snabbdom as Snabbdom
84+import Type.Row.Homogeneous (class Homogeneous)
85+import Unsafe.Coerce (unsafeCoerce)
86+import Untagged.Union (asOneOf)
87+import Web.DOM.Element as Element
88+import Web.DOM.ParentNode (firstElementChild)
89+import Web.Event.Event (Event)
90+import Web.Event.Event as Event
91+import Web.UIEvent.InputEvent as InputEvent
92+import Web.HTML.HTMLInputElement as HTMLInputElement
4893
4994type GenericUIView children msg =
5095 { nerves :: Array (Nerve msg)
@@ -84,9 +129,9 @@ instance Monoid children => Bind (GenericUI children msg) where
84129
85130instance Monoid children => Monad (GenericUI children msg)
86131
87−column :: forall msg a. UI msg a -> UI msg a
88−column (UI { nerves, meat, hover, down, children } a) =
89− UI (mempty :: UIView msg) { children = [ { meat, nerves, hover, down } /\ Column children ] } a
132+column :: forall msg. UI msg Unit -> UI msg Unit
133+column (UI { nerves, meat, hover, down, children } _) =
134+ UI (mempty :: UIView msg) { children = [ { meat, nerves, hover, down } /\ Column children ] } unit
90135
91136row :: forall msg a. UI msg a -> UI msg a
92137row (UI { nerves, meat, hover, down, children } a) =
@@ -112,19 +157,6 @@ link url (UI { nerves, meat, hover, down, children } a) = UI
112157 }
113158 a
114159
115−el :: forall msg a. UI msg a -> UI msg a
116−el (UI { nerves, meat, down, hover, children } a) = UI
117− (mempty :: UIView msg)
118− { children =
119− [ { meat
120− , nerves
121− , hover
122− , down
123− } /\ Wrapper (Maybe.fromMaybe none $ Array.head children)
124− ]
125− }
126− a
127−
128160newTabLink :: forall msg a. String -> UI msg a -> UI msg a
129161newTabLink url (UI { nerves, meat, hover, down, children } a) = UI
130162 (mempty :: UIView msg)
@@ -168,11 +200,42 @@ image :: forall msg a. String -> { description :: String } -> GenericUI Unit msg
168200image url description (UI { nerves, meat, hover, down } a) =
169201 UI (mempty :: UIView msg) { children = [ { meat, nerves, hover, down } /\ Image url description ] } a
170202
171−h :: String -> Classes -> Array VNode -> VNode
172−h elem classes children = Maquette.h elem { class: Array.intercalate " " classes } children
173−
174−hWith :: forall props. String -> Record props -> Classes -> Array VNode -> VNode
175−hWith elem props classes children = Maquette.h elem (Record.unsafeUnion props { class: Array.intercalate " " classes }) children
203+textInput :: forall msg a. { value :: String, onChange :: String -> msg } -> GenericUI Unit msg a -> UI msg a
204+textInput props (UI { nerves, meat, hover, down } a) =
205+ UI (mempty :: UIView msg) { children = [ { meat, nerves, hover, down } /\ TextInput props ] } a
206+
207+string :: String -> Classes -> WiredNerves -> String -> VNode
208+string elem classes (WiredNerves on) s =
209+ Snabbdom.h elem
210+ { attrs: Object.singleton "class" (Array.intercalate " " classes)
211+ , on
212+ , style: Object.empty
213+ , props: Object.empty
214+ }
215+ []
216+ (asOneOf s)
217+
218+h :: String -> Classes -> WiredNerves -> Array VNode -> VNode
219+h elem classes (WiredNerves on) children =
220+ Snabbdom.h elem
221+ { attrs: Object.singleton "class" (Array.intercalate " " classes)
222+ , on
223+ , props: Object.empty
224+ , style: Object.empty
225+ }
226+ children
227+ (asOneOf undefined)
228+
229+hWith :: forall props. Homogeneous props String => String -> Record props -> Classes -> WiredNerves -> Array VNode -> VNode
230+hWith elem props classes (WiredNerves on) children =
231+ Snabbdom.h elem
232+ { attrs: Object.singleton "class" (Array.intercalate " " classes)
233+ , on
234+ , props: Object.fromHomogeneous props
235+ , style: Object.empty
236+ }
237+ children
238+ (asOneOf undefined)
176239
177240data Length = Px Int | Fill | Fit | Max Int Length | Min Int Length
178241
@@ -180,15 +243,90 @@ data Alignment = Start | Center | End
180243
181244data Direction = X | Y
182245
183−m :: forall ch msg a. Monoid ch => Monoid a => Meat -> GenericUI ch msg a
246+n :: forall ch msg. Monoid ch => Nerve msg -> GenericUI ch msg Unit
247+n nerve = UI (mempty :: GenericUIView ch msg) { nerves = [ nerve ] } mempty
248+
249+onClick :: forall ch msg. Monoid ch => msg -> GenericUI ch msg Unit
250+onClick msg = n $ OnClick msg
251+
252+m :: forall ch msg. Monoid ch => Meat -> GenericUI ch msg Unit
184253m meat = UI (mempty :: GenericUIView ch msg) { meat = [ meat ] } mempty
185254
186−spacing :: forall ch msg a. Monoid ch => Monoid a => { x :: Int, y :: Int } -> GenericUI ch msg a
255+spacing :: forall ch msg. Monoid ch => { x :: Int, y :: Int } -> GenericUI ch msg Unit
187256spacing { x, y } = m $ Spacing x y
188257
189−explain :: forall ch msg a. Monoid ch => Monoid a => GenericUI ch msg a
258+explain :: forall ch msg. Monoid ch => Warn (TypeError.Text "Debug explain present") => GenericUI ch msg Unit
190259explain = m Explain
191260
261+align :: forall ch msg. Monoid ch => Direction -> Alignment -> GenericUI ch msg Unit
262+align dir al = m $ Align dir al
263+
264+width :: forall ch msg. Monoid ch => Length -> GenericUI ch msg Unit
265+width l = m $ Width l
266+
267+height :: forall ch msg. Monoid ch => Length -> GenericUI ch msg Unit
268+height l = m $ Height l
269+
270+wrapped :: forall ch msg. Monoid ch => GenericUI ch msg Unit
271+wrapped = m Wrapped
272+
273+bgColor :: forall ch msg. Monoid ch => Color -> GenericUI ch msg Unit
274+bgColor c = m $ BackgroundColor c
275+
276+padding :: forall ch msg. Monoid ch => Side -> Int -> GenericUI ch msg Unit
277+padding s l = m $ Padding s l
278+
279+spread :: forall ch msg. Monoid ch => GenericUI ch msg Unit
280+spread = m Spread
281+
282+opacity :: forall ch msg. Monoid ch => Number -> GenericUI ch msg Unit
283+opacity o = m $ Opacity o
284+
285+pointer :: forall ch msg. Monoid ch => GenericUI ch msg Unit
286+pointer = m Pointer
287+
288+move :: forall ch msg. Monoid ch => { x :: Int, y :: Int } -> GenericUI ch msg Unit
289+move a = m $ Move a
290+
291+clip :: forall ch msg. Monoid ch => Direction -> GenericUI ch msg Unit
292+clip dir = m $ Clip dir
293+
294+onHover :: forall ch msg. Monoid ch => GenericUI Unit msg Unit -> GenericUI ch msg Unit
295+onHover (UI { meat } a) = UI (mempty :: GenericUIView ch msg) { hover = meat } a
296+
297+onMouseDown :: forall ch msg. Monoid ch => GenericUI Unit msg Unit -> GenericUI ch msg Unit
298+onMouseDown (UI { meat } a) = UI (mempty :: GenericUIView ch msg) { down = meat } a
299+
300+borders :: forall ch msg. Monoid ch => Int -> GenericUI ch msg Unit
301+borders l = Array.foldMap (\s -> m $ BorderWidth s l) [ Top, Right, Bottom, Left ]
302+
303+border :: forall ch msg. Monoid ch => Side -> Int -> GenericUI ch msg Unit
304+border s l = m $ BorderWidth s l
305+
306+borderStyle :: forall ch msg. Monoid ch => BorderStyle -> GenericUI ch msg Unit
307+borderStyle s = m $ BorderStyle s
308+
309+roundAll :: forall ch msg. Monoid ch => Int -> GenericUI ch msg Unit
310+roundAll l = Array.foldMap (\c -> m $ Round c l) [ TopLeft, TopRight, BottomRight, BottomLeft ]
311+
312+round :: forall ch msg. Monoid ch => Corner -> Int -> GenericUI ch msg Unit
313+round c l = m $ Round c l
314+
315+shadow :: forall ch msg. Monoid ch => ShadowCfg -> GenericUI ch msg Unit
316+shadow cfg = m $ Shadow $ ShadowCfg cfg
317+
318+innerShadow :: forall ch msg. Monoid ch => ShadowCfg -> GenericUI ch msg Unit
319+innerShadow cfg = m $ InnerShadow $ ShadowCfg cfg
320+
321+font :: forall ch msg. Monoid ch => String -> GenericUI ch msg Unit
322+font f = m $ Font f
323+
324+fontSize :: forall ch msg. Monoid ch => Int -> GenericUI ch msg Unit
325+fontSize f = m $ FontSize f
326+
327+fontWeight :: forall ch msg. Monoid ch => Int -> GenericUI ch msg Unit
328+fontWeight f = m $ FontWeight f
329+
192330data Meat
193331 = Spacing Int Int
194332 | Explain
@@ -197,16 +335,93 @@ data Meat
197335 | Height Length
198336 | Wrapped
199337 | BackgroundColor Color
200− | Padding { top :: Int, right :: Int, bottom :: Int, left :: Int }
338+ | Padding Side Int
201339 | Spread
202340 | Opacity Number
203341 | Pointer
204342 | Move { x :: Int, y :: Int }
205343 | Clip Direction
344+ | BorderWidth Side Int
345+ | BorderStyle BorderStyle
346+ | Round Corner Int
347+ | Shadow Shadow
348+ | InnerShadow Shadow
349+ | FontColor Color
350+ | FontWeight Int
351+ | FontSize Int
352+ | Font Font
353+
354+type Font = String
355+
356+type ShadowCfg = { offset :: { x :: Int, y :: Int }, size :: Number, blur :: Number, color :: Color }
357+
358+newtype Shadow = ShadowCfg ShadowCfg
359+
360+instance Renderable Shadow where
361+ render (ShadowCfg s) = show s.offset.x <> "px " <> show s.offset.y <> "px " <> show s.blur <> "px " <> show s.size <> "px " <> render s.color
362+ renderKey (ShadowCfg s) = show s.offset.x <> "-" <> show s.offset.y <> "-" <> show s.blur <> "-" <> show s.size <> "-" <> renderKey s.color
363+
364+data Corner = TopLeft | TopRight | BottomRight | BottomLeft
365+
366+instance Renderable Corner where
367+ render = case _ of
368+ TopLeft -> "top-left"
369+ TopRight -> "top-right"
370+ BottomRight -> "bottom-right"
371+ BottomLeft -> "bottom-left"
372+ renderKey = case _ of
373+ TopLeft -> "top-left"
374+ TopRight -> "top-right"
375+ BottomRight -> "bottom-right"
376+ BottomLeft -> "bottom-left"
377+
378+data BorderStyle = Solid | Dashed | Dotted
379+
380+instance Renderable BorderStyle where
381+ render = case _ of
382+ Solid -> "solid"
383+ Dashed -> "dashed"
384+ Dotted -> "dotted"
385+ renderKey = case _ of
386+ Solid -> "solid"
387+ Dashed -> "dashed"
388+ Dotted -> "dotted"
389+
390+data Side = Top | Right | Bottom | Left
391+
392+instance Renderable Side where
393+ render = case _ of
394+ Top -> "top"
395+ Right -> "right"
396+ Bottom -> "bottom"
397+ Left -> "left"
398+ renderKey = case _ of
399+ Top -> "top"
400+ Right -> "right"
401+ Bottom -> "bottom"
402+ Left -> "left"
206403
207404data Nerve msg = OnClick msg
208405
209−type View msg = { nerves :: Array (Nerve msg), meat :: Array Meat, hover :: Array Meat, down :: Array Meat } /\ Bones msg
406+newtype WiredNerves = WiredNerves (Object (Event -> Effect Unit))
407+
408+instance Semigroup WiredNerves where
409+ append (WiredNerves x) (WiredNerves y) =
410+ WiredNerves $ Object.unionWith (\f g ev -> f ev *> g ev) x y
411+
412+instance Monoid WiredNerves where
413+ mempty = WiredNerves Object.empty
414+
415+wireNerve :: forall msg. (msg -> Effect Unit) -> Nerve msg -> WiredNerves
416+wireNerve fire nerve = WiredNerves $ case nerve of
417+ OnClick msg -> Object.singleton "click" $ \_ev -> fire msg
418+
419+type View msg =
420+ { nerves :: Array (Nerve msg)
421+ , meat :: Array Meat
422+ , hover :: Array Meat
423+ , down :: Array Meat
424+ } /\ Bones msg
210425
211426none :: forall msg. View msg
212427none = mempty /\ None
@@ -215,7 +430,7 @@ newtype Skin = Skin (Object String)
215430
216431sk :: String -> String -> String -> Writer SkinGrowth Classes
217432sk cName key value = do
218− tell $ SkinGrowth $ Object.singleton cName { key, value }
433+ tell $ SkinGrowth $ { meat: Object.singleton cName { key, value }, hover: Object.empty, down: Object.empty }
219434 pure [ cName ]
220435
221436instance Semigroup Skin where
@@ -268,16 +483,16 @@ skin ctx = case _ of
268483 in
269484 sk ("align-flexbox-" <> k <> "-" <> v) k v
270485 Width l -> sk ("width-" <> renderKey l) "width" (render l)
271− Height l -> sk ("width-" <> renderKey l) "height" (render l)
486+ Height l -> sk ("height-" <> renderKey l) "height" (render l)
272487 Wrapped -> case ctx of
273488 Flexbox _ -> sk "wrapped" "flex-wrap" "wrap"
274489 _ -> pure []
275490 BackgroundColor color -> sk ("bg-color-" <> renderKey color) "background-color" (render color)
276− Padding { top, right, bottom, left } ->
491+ Padding side l ->
277492 sk
278− ("padding-" <> show top <> "-" <> show right <> "-" <> show bottom <> "-" <> show left)
279− "padding"
280− (show top <> "px " <> show right <> "px " <> show bottom <> "px " <> show left <> "px")
493+ ("padding-" <> renderKey side <> "-" <> show l)
494+ ("padding-" <> render side)
495+ (show l <> "px")
281496 Spread -> case ctx of
282497 Flexbox _ -> sk "spread" "justify-content" "space-between"
283498 _ -> pure []
@@ -286,6 +501,18 @@ skin ctx = case _ of
286501 Move { x, y } -> sk ("move-" <> show x <> "-" <> show y) "transform" ("translate(" <> show x <> "px, " <> show y <> "px)")
287502 Clip X -> sk "clip-x" "overflow-x" "hidden"
288503 Clip Y -> sk "clip-y" "overflow-y" "hidden"
504+ BorderWidth side l -> sk ("border-width-" <> renderKey side <> "-" <> show l) ("border-" <> render side <> "-width") (show l <> "px")
505+ BorderStyle s -> sk ("border-style-" <> renderKey s) "border-style" (render s)
506+ Round corner l -> sk ("round-" <> renderKey corner <> "-" <> show l) ("border-" <> render corner <> "-radius") (show l <> "px")
507+ Shadow s -> sk ("shadow-" <> renderKey s) "box-shadow" (render s)
508+ InnerShadow s -> sk ("inner-shadow-" <> renderKey s) "box-shadow" (render s <> " inset")
509+ FontColor c -> sk ("font-color-" <> renderKey c) "color" (render c)
510+ FontSize l -> sk ("font-size-" <> show l) "font-size" (show l <> "px")
511+ Font f -> sk ("font-" <> removeSpaces f) "font-family" f
512+ FontWeight w -> sk ("font-weight-" <> show w) "font-weight" (show w)
513+
514+removeSpaces :: String -> String
515+removeSpaces = String.replaceAll (String.Pattern " ") (String.Replacement "-")
289516
290517class Renderable x where
291518 render :: x -> String
@@ -305,22 +532,22 @@ instance Renderable Length where
305532 Max px l -> "max-" <> show px <> "-" <> renderKey l
306533 Min px l -> "min-" <> show px <> "-" <> renderKey l
307534
308−newtype Color = Color { r :: Int, g :: Int, b :: Int, a :: Number }
535+newtype Color = Color { r :: Int, g :: Int, b :: Int, a :: Int }
309536
310537rgb255 :: Int -> Int -> Int -> Color
311−rgb255 r g b = Color { r, g, b, a: 1.0 }
538+rgb255 r g b = Color { r, g, b, a: 100 }
312539
313−rgba255 :: Int -> Int -> Int -> Number -> Color
540+rgba255 :: Int -> Int -> Int -> Int -> Color
314541rgba255 r g b a = Color { r, g, b, a }
315542
316543rgb :: Number -> Number -> Number -> Color
317−rgb r g b = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a: 1.0 }
544+rgb r g b = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a: 100 }
318545
319546rgba :: Number -> Number -> Number -> Number -> Color
320−rgba r g b a = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a }
547+rgba r g b a = Color { r: Int.round (r * 255.0), g: Int.round (g * 255.0), b: Int.round (b * 255.0), a: Int.round (a * 100.0) }
321548
322549instance Renderable Color where
323− render (Color { r, g, b, a }) = "rgba(" <> show r <> "," <> show g <> "," <> show b <> "," <> show a <> ")"
550+ render (Color { r, g, b, a }) = "rgb(" <> show r <> "," <> show g <> "," <> show b <> "," <> show a <> "%)"
324551 renderKey (Color { r, g, b, a }) = show r <> "-" <> show g <> "-" <> show b <> "-" <> show a
325552
326553data Bones :: Type -> Type
@@ -333,6 +560,7 @@ data Bones msg
333560 | Link String { newTab :: Boolean } (View msg)
334561 | Download String { filename :: Maybe String } (View msg)
335562 | Image String { description :: String }
563+ | TextInput { value :: String, onChange :: String -> msg }
336564 | None
337565
338566type Classes = Array String
@@ -345,25 +573,36 @@ instance Semigroup Mutation where
345573instance Monoid Mutation where
346574 mempty = Mutation { extraSkin: mempty }
347575
348−newtype SkinGrowth = SkinGrowth (Object { key :: String, value :: String })
576+newtype SkinGrowth = SkinGrowth
577+ { meat :: Object { key :: String, value :: String }
578+ , hover :: Object { key :: String, value :: String }
579+ , down :: Object { key :: String, value :: String }
580+ }
349581
350582styleSkinGrowth :: SkinGrowth -> String
351583styleSkinGrowth (SkinGrowth o) =
352− Object.foldMap (\className { key, value } -> "." <> className <> "{" <> key <> ":" <> value <> ";}") o
584+ Object.foldMap (\className { key, value } -> "." <> className <> "{" <> key <> ":" <> value <> ";}") o.meat
585+ <> Object.foldMap (\className { key, value } -> "." <> className <> "{" <> key <> ":" <> value <> ";}") o.hover
586+ <> Object.foldMap (\className { key, value } -> "." <> className <> "{" <> key <> ":" <> value <> ";}") o.down
353587
354588instance Semigroup SkinGrowth where
355− append (SkinGrowth x) (SkinGrowth y) = SkinGrowth $ Object.union x y
589+ append (SkinGrowth x) (SkinGrowth y) = SkinGrowth $
590+ { meat: Object.union x.meat y.meat
591+ , hover: Object.union x.hover y.hover
592+ , down: Object.union x.down y.down
593+ }
356594
357595instance Monoid SkinGrowth where
358− mempty = SkinGrowth Object.empty
596+ mempty = SkinGrowth mempty
359597
360598growSkin :: forall msg. (msg -> Effect Unit) -> Mutation -> View msg -> Writer SkinGrowth VNode
361599growSkin fire (Mutation mutation) ({ meat, hover, down, nerves } /\ bones) = do
362600 let
601+ wiredNerves = Array.foldMap (wireNerve fire) nerves
363602 alignCenter = [ Align X Center, Align Y Center ]
364603 widthFill = [ Width Fill, Height Fill ]
365− skn ctx =
366− ((_ <> mutation.extraSkin) <<< Array.concat) <$> traverse (skin ctx)
604+ skn ctx = do
605+ meatClasses <- ((_ <> mutation.extraSkin) <<< Array.concat) <$> traverse (skin ctx)
367606 ( meat
368607 <> case ctx of
369608 Span -> mempty
@@ -376,27 +615,47 @@ growSkin fire (Mutation mutation) ({ meat, hover, down, nerves } /\ bones) = do
376615 Span -> mempty
377616 Generic -> alignCenter
378617 )
618+ let hoverClasses /\ (SkinGrowth hover') = runWriter $ traverse (skin ctx) hover
619+ _ <- traverseWithIndex
620+ ( \key val -> tell $ SkinGrowth $
621+ { meat: Object.empty
622+ , hover: Object.singleton (key <> "-hover:hover") val
623+ , down: Object.empty
624+ }
625+ )
626+ hover'.meat
627+ let downClasses /\ (SkinGrowth down') = runWriter $ traverse (skin ctx) down
628+ _ <- traverseWithIndex
629+ ( \key val -> tell $ SkinGrowth $
630+ { meat: Object.empty
631+ , hover: Object.empty
632+ , down: Object.singleton (key <> "-down:active") val
633+ }
634+ )
635+ down'.meat
636+
637+ pure $ meatClasses <> map (_ <> "-hover") (Array.concat hoverClasses) <> map (_ <> "-down") (Array.concat downClasses)
379638
380639 case bones of
381− Text t -> (\c -> h "span" c [ string t ]) <$> (skn Span)
640+ Text t -> (\c -> string "span" c wiredNerves t) <$> (skn Span)
382641 Wrapper x -> do
383642 classes <- (skn (Flexbox X) <> sk "display-flex" "display" "flex" <> sk "flex-direction-row" "flex-direction" "row")
384643 x' <- growSkin fire mempty x
385− pure $ h "div" classes [ x' ]
644+ pure $ h "div" classes wiredNerves [ x' ]
386645 Stack children -> do
387646 classes <- (skn Grid <> sk "display-grid" "display" "grid")
388647 extraSkin <- sk "grid-row-1" "grid-row" "1" <> sk "grid-column-1" "grid-column" "1"
389648 children' <- (traverse (growSkin fire $ Mutation { extraSkin }) children)
390− pure $ h "div" classes children'
649+ pure $ h "div" classes wiredNerves children'
391650
392651 Row children -> do
393652 classes <- (skn (Flexbox X) <> sk "display-flex" "display" "flex" <> sk "flex-direction-row" "flex-direction" "row")
394653 children' <- traverse (growSkin fire mempty) children
395− pure $ h "div" classes children'
654+ pure $ h "div" classes wiredNerves children'
396655 Column children -> do
397656 classes <- (skn (Flexbox Y) <> sk "display-flex" "display" "flex" <> sk "flex-direction-column" "flex-direction" "column")
398657 children' <- traverse (growSkin fire mempty) children
399− pure $ h "div" classes children'
658+ pure $ h "div" classes wiredNerves children'
400659 Link href { newTab } child -> do
401660 classes <- (skn (Flexbox X) <> sk "display-flex" "display" "flex" <> sk "flex-direction-row" "flex-direction" "row")
402661 child' <- growSkin fire mempty child
@@ -406,6 +665,7 @@ growSkin fire (Mutation mutation) ({ meat, hover, down, nerves } /\ bones) = do
406665 , target: if newTab then "_blank" else "_self"
407666 }
408667 classes
668+ wiredNerves
409669 [ child' ]
410670
411671 Download href { filename } child -> do
@@ -416,9 +676,20 @@ growSkin fire (Mutation mutation) ({ meat, hover, down, nerves } /\ bones) = do
416676 , download: Maybe.fromMaybe "" filename
417677 }
418678 classes
679+ wiredNerves
419680 [ child' ]
420− Image src { description } -> (\c -> hWith "img" { src, alt: description } c []) <$> (skn Generic)
421− None -> pure $ h "div" mempty []
681+ Image src { description } -> (\c -> hWith "img" { src, alt: description } c wiredNerves []) <$> (skn Generic)
682+ TextInput { value, onChange } -> do
683+ classes <- skn Generic
684+ let
685+ onInputNerve = WiredNerves $ Object.singleton "input" $ \ev ->
686+ case Event.currentTarget ev >>= HTMLInputElement.fromEventTarget of
687+ Nothing -> pure unit
688+ Just inputEl -> do
689+ val <- HTMLInputElement.value inputEl
690+ fire $ onChange val
691+ pure $ hWith "input" { value } classes (wiredNerves <> onInputNerve) []
692+ None -> pure $ h "div" mempty wiredNerves []
422693
423694grow :: forall msg. (msg -> Effect Unit) -> View msg -> { node :: VNode, style :: String }
424695grow fire v =
@@ -426,3 +697,4 @@ grow fire v =
426697 node /\ skinGrowth = runWriter (growSkin fire mempty v)
427698 in
428699 { node, style: styleSkinGrowth skinGrowth }
700+
plum/src/Snabbdom.jsnew file+1
@@ -0,0 +1 @@
1+function m(f,G){let z,W=G.elm,X=f.data.attrs,Z=G.data.attrs;if(!X&&!Z)return;if(X===Z)return;X=X||{},Z=Z||{};for(z in Z){let K=Z[z];if(X[z]!==K)if(K===!0)W.setAttribute(z,"");else if(K===!1)W.removeAttribute(z);else if(z.charCodeAt(0)!==120)W.setAttribute(z,K);else if(z.charCodeAt(3)===58)W.setAttributeNS("http://www.w3.org/XML/1998/namespace",z,K);else if(z.charCodeAt(5)===58)z.charCodeAt(1)===109?W.setAttributeNS("http://www.w3.org/2000/xmlns/",z,K):W.setAttributeNS("http://www.w3.org/1999/xlink",z,K);else W.setAttribute(z,K)}for(z in X)if(!(z in Z))W.removeAttribute(z)}var s={create:m,update:m};function r(f,G,z){if(typeof f==="function")f.call(G,z,G);else if(typeof f==="object")for(let W=0;W<f.length;W++)r(f[W],G,z)}function G0(f,G){let z=f.type,W=G.data.on;if(W&&W[z])r(W[z],G,f)}function J0(){return function f(G){G0(G,f.vnode)}}function x(f,G){let z=f.data.on,W=f.listener,X=f.elm,Z=G&&G.data.on,K=G&&G.elm,U;if(z===Z)return;if(z&&W){if(!Z)for(U in z)X.removeEventListener(U,W,!1);else for(U in z)if(!Z[U])X.removeEventListener(U,W,!1)}if(Z){let D=G.listener=f.listener||J0();if(D.vnode=G,!z)for(U in Z)K.addEventListener(U,D,!1);else for(U in Z)if(!z[U])K.addEventListener(U,D,!1)}}var l={create:x,update:x,destroy:x};function N(f,G,z,W,X){let Z=G===void 0?void 0:G.key;return{sel:f,data:G,children:z,text:W,elm:X,key:Z}}var u=Array.isArray;function a(f){return typeof f==="string"||typeof f==="number"||f instanceof String||f instanceof Number}function Y0(f,G){return document.createElement(f,G)}function Z0(f,G,z){return document.createElementNS(f,G,z)}function $0(){return I(document.createDocumentFragment())}function B0(f){return document.createTextNode(f)}function q0(f){return document.createComment(f)}function K0(f,G,z){if(S(f)){let W=f;while(W&&S(W))W=I(W).parent;f=W!==null&&W!==void 0?W:f}if(S(G))G=I(G,f);if(z&&S(z))z=I(z).firstChildNode;f.insertBefore(G,z)}function P0(f,G){f.removeChild(G)}function H0(f,G){if(S(G))G=I(G,f);f.appendChild(G)}function t(f){if(S(f)){while(f&&S(f))f=I(f).parent;return f!==null&&f!==void 0?f:null}return f.parentNode}function O0(f){var G;if(S(f)){let z=I(f),W=t(z);if(W&&z.lastChildNode){let X=Array.from(W.childNodes),Z=X.indexOf(z.lastChildNode);return(G=X[Z+1])!==null&&G!==void 0?G:null}return null}return f.nextSibling}function U0(f){return f.tagName}function R0(f,G){f.textContent=G}function T0(f){return f.textContent}function L0(f){return f.nodeType===1}function M0(f){return f.nodeType===3}function D0(f){return f.nodeType===8}function S(f){return f.nodeType===11}function I(f,G){var z,W,X;let Z=f;return(z=Z.parent)!==null&&z!==void 0||(Z.parent=G!==null&&G!==void 0?G:null),(W=Z.firstChildNode)!==null&&W!==void 0||(Z.firstChildNode=f.firstChild),(X=Z.lastChildNode)!==null&&X!==void 0||(Z.lastChildNode=f.lastChild),Z}var E={createElement:Y0,createElementNS:Z0,createTextNode:B0,createDocumentFragment:$0,createComment:q0,insertBefore:K0,removeChild:P0,appendChild:H0,parentNode:t,nextSibling:O0,tagName:U0,setTextContent:R0,getTextContent:T0,isElement:L0,isText:M0,isComment:D0,isDocumentFragment:S};var V=N("",{},[],void 0,void 0);function w(f,G){var z,W;let X=f.key===G.key,Z=((z=f.data)===null||z===void 0?void 0:z.is)===((W=G.data)===null||W===void 0?void 0:W.is),K=f.sel===G.sel,U=!f.sel&&f.sel===G.sel?typeof f.text===typeof G.text:!0;return K&&X&&Z&&U}function A0(){throw new Error("The document fragment is not supported on this platform.")}function j0(f,G){return f.isElement(G)}function F0(f,G){return f.isDocumentFragment(G)}function Q0(f,G,z){var W;let X={};for(let Z=G;Z<=z;++Z){let K=(W=f[Z])===null||W===void 0?void 0:W.key;if(K!==void 0)X[K]=Z}return X}var g0=["create","update","remove","destroy","pre","post"];function n(f,G,z){let W={create:[],update:[],remove:[],destroy:[],pre:[],post:[]},X=G!==void 0?G:E;for(let J of g0)for(let Y of f){let $=Y[J];if($!==void 0)W[J].push($)}function Z(J){let Y=J.id?"#"+J.id:"",$=J.getAttribute("class"),B=$?"."+$.split(" ").join("."):"";return N(X.tagName(J).toLowerCase()+Y+B,{},[],void 0,J)}function K(J){return N(void 0,{},[],void 0,J)}function U(J,Y){return function $(){if(--Y===0){let B=X.parentNode(J);if(B!==null)X.removeChild(B,J)}}}function D(J,Y){var $,B,P,O,L;let q,R=J.data,M=R===null||R===void 0?void 0:R.hook;($=M===null||M===void 0?void 0:M.init)===null||$===void 0||$.call(M,J);let{children:T,sel:H}=J;if(H==="!")(B=J.text)!==null&&B!==void 0||(J.text=""),J.elm=X.createComment(J.text);else if(H==="")J.elm=X.createTextNode(J.text);else if(H!==void 0){let A=H.indexOf("#"),j=H.indexOf(".",A),F=A>0?A:H.length,b=j>0?j:H.length,i=A!==-1||j!==-1?H.slice(0,Math.min(F,b)):H,p=R===null||R===void 0?void 0:R.ns,_=p===void 0?X.createElement(i,R):X.createElementNS(p,i,R);if(J.elm=_,F<b)_.setAttribute("id",H.slice(F+1,b));if(j>0)_.setAttribute("class",H.slice(b+1).replace(/\./g," "));for(q=0;q<W.create.length;++q)W.create[q](V,J);if(a(J.text)&&(!u(T)||T.length===0))X.appendChild(_,X.createTextNode(J.text));if(u(T))for(q=0;q<T.length;++q){let v=T[q];if(v!=null)X.appendChild(_,D(v,Y))}if(M!==void 0){if((P=M.create)===null||P===void 0||P.call(M,V,J),M.insert!==void 0)Y.push(J)}}else if(((O=z===null||z===void 0?void 0:z.experimental)===null||O===void 0?void 0:O.fragments)&&J.children){J.elm=((L=X.createDocumentFragment)!==null&&L!==void 0?L:A0)();for(q=0;q<W.create.length;++q)W.create[q](V,J);for(q=0;q<J.children.length;++q){let A=J.children[q];if(A!=null)X.appendChild(J.elm,D(A,Y))}}else J.elm=X.createTextNode(J.text);return J.elm}function y(J,Y,$,B,P,O){for(;B<=P;++B){let L=$[B];if(L!=null)X.insertBefore(J,D(L,O),Y)}}function k(J){var Y,$;let B=J.data;if(B!==void 0){($=(Y=B===null||B===void 0?void 0:B.hook)===null||Y===void 0?void 0:Y.destroy)===null||$===void 0||$.call(Y,J);for(let P=0;P<W.destroy.length;++P)W.destroy[P](J);if(J.children!==void 0)for(let P=0;P<J.children.length;++P){let O=J.children[P];if(O!=null&&typeof O!=="string")k(O)}}}function g(J,Y,$,B){var P,O;for(;$<=B;++$){let L,q=Y[$];if(q!=null)if(q.sel!==void 0){k(q),L=W.remove.length+1;let R=U(q.elm,L);for(let T=0;T<W.remove.length;++T)W.remove[T](q,R);let M=(O=(P=q===null||q===void 0?void 0:q.data)===null||P===void 0?void 0:P.hook)===null||O===void 0?void 0:O.remove;if(M!==void 0)M(q,R);else R()}else if(q.children)k(q),g(J,q.children,0,q.children.length-1);else X.removeChild(J,q.elm)}}function C(J,Y,$,B){let P=0,O=0,L=Y.length-1,q=Y[0],R=Y[L],M=$.length-1,T=$[0],H=$[M],A,j,F,b;while(P<=L&&O<=M)if(q==null)q=Y[++P];else if(R==null)R=Y[--L];else if(T==null)T=$[++O];else if(H==null)H=$[--M];else if(w(q,T))Q(q,T,B),q=Y[++P],T=$[++O];else if(w(R,H))Q(R,H,B),R=Y[--L],H=$[--M];else if(w(q,H))Q(q,H,B),X.insertBefore(J,q.elm,X.nextSibling(R.elm)),q=Y[++P],H=$[--M];else if(w(R,T))Q(R,T,B),X.insertBefore(J,R.elm,q.elm),R=Y[--L],T=$[++O];else{if(A===void 0)A=Q0(Y,P,L);if(j=A[T.key],j===void 0)X.insertBefore(J,D(T,B),q.elm),T=$[++O];else if(A[H.key]===void 0)X.insertBefore(J,D(H,B),X.nextSibling(R.elm)),H=$[--M];else{if(F=Y[j],F.sel!==T.sel)X.insertBefore(J,D(T,B),q.elm);else Q(F,T,B),Y[j]=void 0,X.insertBefore(J,F.elm,q.elm);T=$[++O]}}if(O<=M)b=$[M+1]==null?null:$[M+1].elm,y(J,b,$,O,M,B);if(P<=L)g(J,Y,P,L)}function Q(J,Y,$){var B,P,O,L,q,R,M,T;let H=(B=Y.data)===null||B===void 0?void 0:B.hook;(P=H===null||H===void 0?void 0:H.prepatch)===null||P===void 0||P.call(H,J,Y);let A=Y.elm=J.elm;if(J===Y)return;if(Y.data!==void 0||Y.text!==void 0&&Y.text!==J.text){(O=Y.data)!==null&&O!==void 0||(Y.data={}),(L=J.data)!==null&&L!==void 0||(J.data={});for(let b=0;b<W.update.length;++b)W.update[b](J,Y);(M=(R=(q=Y.data)===null||q===void 0?void 0:q.hook)===null||R===void 0?void 0:R.update)===null||M===void 0||M.call(R,J,Y)}let j=J.children,F=Y.children;if(Y.text===void 0){if(j!==void 0&&F!==void 0){if(j!==F)C(A,j,F,$)}else if(F!==void 0){if(J.text!==void 0)X.setTextContent(A,"");y(A,null,F,0,F.length-1,$)}else if(j!==void 0)g(A,j,0,j.length-1);else if(J.text!==void 0)X.setTextContent(A,"")}else if(J.text!==Y.text){if(j!==void 0)g(A,j,0,j.length-1);X.setTextContent(A,Y.text)}(T=H===null||H===void 0?void 0:H.postpatch)===null||T===void 0||T.call(H,J,Y)}return function J(Y,$){let B,P,O,L=[];for(B=0;B<W.pre.length;++B)W.pre[B]();if(j0(X,Y))Y=Z(Y);else if(F0(X,Y))Y=K(Y);if(w(Y,$))Q(Y,$,L);else if(P=Y.elm,O=X.parentNode(P),D($,L),O!==null)X.insertBefore(O,$.elm,X.nextSibling(P)),g(O,[Y],0,0);for(B=0;B<L.length;++B)L[B].data.hook.insert(L[B]);for(B=0;B<W.post.length;++B)W.post[B]();return $}}var o=typeof(window===null||window===void 0?void 0:window.requestAnimationFrame)==="function"?window.requestAnimationFrame.bind(window):setTimeout,b0=(f)=>{o(()=>{o(f)})},c=!1;function k0(f,G,z){b0(()=>{f[G]=z})}function d(f,G){let z,W,X=G.elm,Z=f.data.style,K=G.data.style;if(!Z&&!K)return;if(Z===K)return;Z=Z||{},K=K||{};let U="delayed"in Z;for(W in Z)if(!(W in K))if(W[0]==="-"&&W[1]==="-")X.style.removeProperty(W);else X.style[W]="";for(W in K)if(z=K[W],W==="delayed"&&K.delayed){for(let D in K.delayed)if(z=K.delayed[D],!U||z!==Z.delayed[D])k0(X.style,D,z)}else if(W!=="remove"&&z!==Z[W])if(W[0]==="-"&&W[1]==="-")X.style.setProperty(W,z);else X.style[W]=z}function N0(f){let G,z,W=f.elm,X=f.data.style;if(!X||!(G=X.destroy))return;for(z in G)W.style[z]=G[z]}function S0(f,G){let z=f.data.style;if(!z||!z.remove){G();return}if(!c)f.elm.offsetLeft,c=!0;let W,X=f.elm,Z=0,K=z.remove,U=0,D=[];for(W in K)D.push(W),X.style[W]=K[W];let k=getComputedStyle(X)["transition-property"].split(", ");for(;Z<k.length;++Z)if(D.indexOf(k[Z])!==-1)U++;X.addEventListener("transitionend",(g)=>{if(g.target===X)--U;if(U===0)G()})}function y0(){c=!1}var e={pre:y0,create:d,update:d,destroy:N0,remove:S0};function f0(f,G){let z,W,X,Z=G.elm,K=f.data.props,U=G.data.props;if(!K&&!U)return;if(K===U)return;K=K||{},U=U||{};for(z in U)if(W=U[z],X=K[z],X!==W&&(z!=="value"||Z[z]!==W))Z[z]=W}var W0={create:f0,update:f0};function h(f,G,z){if(f.ns="http://www.w3.org/2000/svg",z!=="foreignObject"&&G!==void 0)for(let W=0;W<G.length;++W){let X=G[W];if(typeof X==="string")continue;let Z=X.data;if(Z!==void 0)h(Z,X.children,X.sel)}}function I0(f){return f.slice(5).replace(/-([a-z])/g,(G,z)=>z.toUpperCase())}function z0(f,G){var z;let W=G!==void 0?G:E,X;if(W.isElement(f)){let Z=f.id?"#"+f.id:"",K=(z=f.getAttribute("class"))===null||z===void 0?void 0:z.match(/[^\t\r\n\f ]+/g),U=K?"."+K.join("."):"",D=W.tagName(f).toLowerCase()+Z+U,y={},k={},g={},C=[],Q,J,Y,$=f.attributes,B=f.childNodes;for(J=0,Y=$.length;J<Y;J++)if(Q=$[J].nodeName,Q.startsWith("data-"))k[I0(Q)]=$[J].nodeValue||"";else if(Q!=="id"&&Q!=="class")y[Q]=$[J].nodeValue;for(J=0,Y=B.length;J<Y;J++)C.push(z0(B[J],G));if(Object.keys(y).length>0)g.attrs=y;if(Object.keys(k).length>0)g.dataset=k;if(D.startsWith("svg")&&(D.length===3||D[3]==="."||D[3]==="#"))h(g,C,D);return N(D,g,C,void 0,f)}else if(W.isText(f))return X=W.getTextContent(f),N(void 0,void 0,void 0,X,f);else if(W.isComment(f))return X=W.getTextContent(f),N("!",{},[],X,f);else return N("",{},[],void 0,f)}function o0(){return n([s,l,e,W0])}export{N as vnode,z0 as toVNode,o0 as initWithModules};
plum/src/Snabbdom.pursnew file+45
@@ -0,0 +1,45 @@
1+module Snabbdom (h, VNode, init, toVNode) where
2+
3+import Prelude
4+
5+import Data.Function.Uncurried (Fn4, runFn4)
6+import Effect (Effect)
7+import Effect.Uncurried (EffectFn1, EffectFn2, mkEffectFn1, runEffectFn2)
8+import Foreign.Object (Object)
9+import Literals.Undefined (Undefined)
10+import Untagged.Union (type (|+|))
11+import Web.DOM (Element)
12+import Web.Event.Event (Event)
13+
14+foreign import data VNode :: Type
15+
16+foreign import initWithModules :: Effect (EffectFn2 VNode VNode VNode)
17+
18+init :: Effect (VNode -> VNode -> Effect VNode)
19+init = initWithModules <#> runEffectFn2
20+
21+foreign import vnode :: forall props. Fn4 String (Record props) (Array VNode) (String |+| Undefined) VNode
22+
23+h
24+ :: String
25+ -> { attrs :: Object String
26+ , on :: Object (Event -> Effect Unit)
27+ , style :: Object String
28+ , props :: Object String
29+ }
30+ -> Array VNode
31+ -> (String |+| Undefined)
32+ -> VNode
33+h tag props children text = runFn4 vnode
34+ tag
35+ ( props { on = mkEffectFn1 <$> props.on }
36+ :: { attrs :: Object String
37+ , on :: Object (EffectFn1 Event Unit)
38+ , style :: Object String
39+ , props :: Object String
40+ }
41+ )
42+ children
43+ text
44+
45+foreign import toVNode :: Element -> VNode