From 4ff19762b9c9ee7995b607f70b9c2c1db97cbe24 Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Fri, 2 Feb 2018 21:32:33 +0530 Subject: [PATCH 01/52] modified utils.js for creating dom structure --- src/Halogen/VDom/Util.js | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 09f0d66..9ad7359 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -112,7 +112,7 @@ exports.refEq = function (a, b) { exports.createTextNode = function (s, doc) { return function () { - return doc.createTextNode(s); + return {type: "textView", children: [], props: {text: s}} }; }; @@ -124,20 +124,13 @@ exports.setTextContent = function (s, n) { exports.createElement = function (ns, name, doc) { return function () { - if (ns != null) { - return doc.createElementNS(ns, name); - } else { - return doc.createElement(name) - } + return {type: name, children: [], props: {}} }; }; exports.insertChildIx = function (i, a, b) { return function () { - var n = b.childNodes.item(i) || null; - if (n !== a) { - b.insertBefore(a, n); - } + b.children.splice(i, 0, a); }; }; From ef6d2a64f6c9660549d74667b13149e259e9c314 Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Mon, 5 Feb 2018 18:48:28 +0530 Subject: [PATCH 02/52] Modified Utils.js/removeChild --- src/Halogen/VDom/Util.js | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 9ad7359..da7e8ea 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -21,6 +21,7 @@ exports.unsafeDeleteAny = function (key, obj) { }; exports.forE = function (a, f) { + return function () { var b = []; for (var i = 0; i < a.length; i++) { @@ -130,14 +131,26 @@ exports.createElement = function (ns, name, doc) { exports.insertChildIx = function (i, a, b) { return function () { + a.parentNode = b; b.children.splice(i, 0, a); }; }; exports.removeChild = function (a, b) { return function () { + var childIndex = -1; + if (b && a.parentNode === b) { - b.removeChild(a); + for (var i=0; i -1) { + window.removeChild(a, b); + b.children.splice(childIndex, 1); } }; }; @@ -157,7 +170,7 @@ exports.setAttribute = function (ns, attr, val, el) { }; exports.removeAttribute = function (ns, attr, el) { - return function () { + return unction () { if (ns != null) { el.removeAttributeNS(ns, attr); } else { From 76fa2ee07b4c21731f22d5e59d893aa92c372a6c Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Mon, 5 Feb 2018 21:18:48 +0530 Subject: [PATCH 03/52] Modifying Utils.purs for supporting addChild --- src/Halogen/VDom/DOM.purs | 12 ++++++------ src/Halogen/VDom/Util.js | 9 +++++++-- src/Halogen/VDom/Util.purs | 2 +- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index a879124..aa73cd3 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -105,7 +105,7 @@ buildElem (VDomSpec spec) = render node = DOM.elementToNode el onChild = Fn.mkFn2 \ix child → do res@Step n m h ← buildVDom (VDomSpec spec) child - Fn.runFn3 Util.insertChildIx ix n node + Fn.runFn4 Util.insertChildIx "render" ix n node pure res steps ← Fn.runFn2 Util.forE ch1 onChild attrs ← spec.buildAttributes el as1 @@ -129,12 +129,12 @@ buildElem (VDomSpec spec) = render let onThese = Fn.mkFn3 \ix (prev@Step n step halt) vdom → do res@Step n' m' h' ← step vdom - Fn.runFn3 Util.insertChildIx ix n' node + Fn.runFn4 Util.insertChildIx "patch" ix n' node pure res onThis = Fn.mkFn2 \ix (Step n _ halt) → halt onThat = Fn.mkFn2 \ix vdom → do res@Step n m h ← buildVDom (VDomSpec spec) vdom - Fn.runFn3 Util.insertChildIx ix n node + Fn.runFn4 Util.insertChildIx "patch" ix n node pure res steps ← Fn.runFn5 Util.diffWithIxE ch1 ch2 onThese onThis onThat attrs' ← Machine.step attrs as2 @@ -166,7 +166,7 @@ buildKeyed (VDomSpec spec) = render node = DOM.elementToNode el onChild = Fn.mkFn3 \k ix (Tuple _ vdom) → do res@Step n m h ← buildVDom (VDomSpec spec) vdom - Fn.runFn3 Util.insertChildIx ix n node + Fn.runFn4 Util.insertChildIx "render" ix n node pure res steps ← Fn.runFn3 Util.strMapWithIxE ch1 fst onChild attrs ← spec.buildAttributes el as1 @@ -190,12 +190,12 @@ buildKeyed (VDomSpec spec) = render let onThese = Fn.mkFn4 \k ix' (Step n step _) (Tuple _ vdom) → do res@Step n' m' h' ← step vdom - Fn.runFn3 Util.insertChildIx ix' n' node + Fn.runFn4 Util.insertChildIx "patch" ix' n' node pure res onThis = Fn.mkFn2 \k (Step n _ halt) → halt onThat = Fn.mkFn3 \k ix (Tuple _ vdom) → do res@Step n' m' h' ← buildVDom (VDomSpec spec) vdom - Fn.runFn3 Util.insertChildIx ix n' node + Fn.runFn4 Util.insertChildIx "patch" ix n' node pure res steps ← Fn.runFn6 Util.diffWithKeyAndIxE ch1 ch2 fst onThese onThis onThat attrs' ← Machine.step attrs as2 diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index da7e8ea..595202a 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -129,8 +129,12 @@ exports.createElement = function (ns, name, doc) { }; }; -exports.insertChildIx = function (i, a, b) { +exports.insertChildIx = function (type, i, a, b) { return function () { + if (type == "patch") { + window.addChild(a, b, i); + } + a.parentNode = b; b.children.splice(i, 0, a); }; @@ -149,7 +153,8 @@ exports.removeChild = function (a, b) { } if (childIndex > -1) { - window.removeChild(a, b); + window.removeChild(a, b, childIndex); + b.children.splice(childIndex, 1); } }; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index bf6bb0d..60ea5e6 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -149,7 +149,7 @@ foreign import createElement foreign import insertChildIx ∷ ∀ eff - . Fn.Fn3 Int DOM.Node DOM.Node (Eff (dom ∷ DOM | eff) Unit) + . Fn.Fn4 String Int DOM.Node DOM.Node (Eff (dom ∷ DOM | eff) Unit) foreign import removeChild ∷ ∀ eff From ee0aa898ec3dbbf0e2e1454961b75fb9ec98abba Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Mon, 5 Feb 2018 23:00:50 +0530 Subject: [PATCH 04/52] If element is removed, no more child remove calls --- src/Halogen/VDom/Util.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 595202a..0888ba7 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -154,14 +154,18 @@ exports.removeChild = function (a, b) { if (childIndex > -1) { window.removeChild(a, b, childIndex); - + a.props.__removed = true; b.children.splice(childIndex, 1); } }; }; exports.unsafeParent = function (a) { - return a.parentNode; + if (a.parentNode.props.__removed) { + return null; + } else { + return a.parentNode; + } }; exports.setAttribute = function (ns, attr, val, el) { From 2dfd8e134c31b611f4988ecbbf35e7bbf19da81e Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Tue, 6 Feb 2018 18:01:35 +0530 Subject: [PATCH 05/52] added prop __removed `true` to current node with unsafe parent --- src/Halogen/VDom/Util.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 0888ba7..cd5d5f1 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -162,6 +162,7 @@ exports.removeChild = function (a, b) { exports.unsafeParent = function (a) { if (a.parentNode.props.__removed) { + a.props.__removed = true; return null; } else { return a.parentNode; @@ -196,7 +197,7 @@ exports.addEventListener = function (ev, listener, el) { exports.removeEventListener = function (ev, listener, el) { return function () { - el.removeEventListener(ev, listener, false); + el.removeEventListener(ev, listener, false); }; }; From 0cb345ff13980e3e39d2ac8502c3b8be3a4cb20a Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Tue, 6 Feb 2018 22:11:15 +0530 Subject: [PATCH 06/52] minor fix --- src/Halogen/VDom/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index cd5d5f1..833f1be 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -180,7 +180,7 @@ exports.setAttribute = function (ns, attr, val, el) { }; exports.removeAttribute = function (ns, attr, el) { - return unction () { + return function () { if (ns != null) { el.removeAttributeNS(ns, attr); } else { From 1d45a32de00825f01c0bf0c9e0450b1fab5abf24 Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Wed, 7 Feb 2018 21:32:57 +0530 Subject: [PATCH 07/52] addChild fix added --- src/Halogen/VDom/Util.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 833f1be..1f65d68 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -131,12 +131,16 @@ exports.createElement = function (ns, name, doc) { exports.insertChildIx = function (type, i, a, b) { return function () { - if (type == "patch") { - window.addChild(a, b, i); - } + var n = (b.children[i]) || null; + + if (n && n.props.id !== a.props.id) { + if (type == "patch") { + window.addChild(a, b, i); + } - a.parentNode = b; - b.children.splice(i, 0, a); + a.parentNode = b; + b.children.splice(i, 0, a); + } }; }; From 331aa31a55b0d8b2a4f4cc056c7e13a390657c26 Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Thu, 8 Feb 2018 17:42:11 +0530 Subject: [PATCH 08/52] fix added for null handling in insertChildIx --- src/Halogen/VDom/Util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 1f65d68..49844c5 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -131,9 +131,9 @@ exports.createElement = function (ns, name, doc) { exports.insertChildIx = function (type, i, a, b) { return function () { - var n = (b.children[i]) || null; + var n = (b.children[i]) || {props: {id: "-1"}}; - if (n && n.props.id !== a.props.id) { + if (n.props.id !== a.props.id) { if (type == "patch") { window.addChild(a, b, i); } From fe5c2572c83e2a608818239c8dabeff2a8dc5e45 Mon Sep 17 00:00:00 2001 From: Naman Kalkhuria Date: Fri, 9 Feb 2018 15:14:43 +0530 Subject: [PATCH 09/52] used `id` to identify parent child relationship --- src/Halogen/VDom/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 49844c5..821d147 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -148,7 +148,7 @@ exports.removeChild = function (a, b) { return function () { var childIndex = -1; - if (b && a.parentNode === b) { + if (b && a.parentNode.props.id === b.props.id) { for (var i=0; i Date: Mon, 12 Feb 2018 17:51:09 +0530 Subject: [PATCH 10/52] Add create element --- src/Halogen/VDom/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 821d147..e2052e0 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -125,7 +125,7 @@ exports.setTextContent = function (s, n) { exports.createElement = function (ns, name, doc) { return function () { - return {type: name, children: [], props: {}} + return {type: name, children: [], props: {}, __ref: window.createPrestoElement()} }; }; From fdec76c3d5cf0f6a21a11313b6dd0daa07a18dd8 Mon Sep 17 00:00:00 2001 From: "das.ashutosh" Date: Tue, 20 Feb 2018 20:10:00 +0530 Subject: [PATCH 11/52] Added new behaviour handler --- src/Halogen/VDom/DOM/Prop.purs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 8bd3565..6aec308 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -28,6 +28,7 @@ import Halogen.VDom.Types (Namespace(..)) import Halogen.VDom.Util as Util import Unsafe.Coerce (unsafeCoerce) + -- | Attributes, properties, event handlers, and element lifecycles. -- | Parameterized by the type of handlers outputs. data Prop a @@ -35,6 +36,7 @@ data Prop a | Property String PropValue | Handler DOM.EventType (DOM.Event → Maybe a) | Ref (ElemRef DOM.Element → Maybe a) + | BHandler String (String → a) instance functorProp ∷ Functor Prop where map f (Handler ty g) = Handler ty (map f <$> g) @@ -128,6 +130,9 @@ buildProp emit el = render Ref f → do mbEmit (f (Created el)) pure v + BHandler f _ → do + Fn.runFn3 setProperty "custom" (propFromString f) el + pure v diffProp = Fn.mkFn2 \prevEvents events → Fn.mkFn4 \_ _ v1 v2 → case v1, v2 of @@ -172,6 +177,7 @@ buildProp emit el = render let handler = Fn.runFn2 Util.unsafeLookup ty prevEvents Fn.runFn3 Util.removeEventListener ty (fst handler) el + BHandler _ _ → Util.effUnit Ref _ → Util.effUnit @@ -182,6 +188,7 @@ propToStrKey = case _ of Property prop _ → "prop/" <> prop Handler (DOM.EventType ty) _ → "handler/" <> ty Ref _ → "ref" + BHandler _ _ -> "bhandler" setProperty ∷ ∀ eff. Fn.Fn3 String PropValue DOM.Element (Eff (dom ∷ DOM | eff) Unit) setProperty = Util.unsafeSetAny From 63459c1846d756b157658bace6b4eb8d0ae72cce Mon Sep 17 00:00:00 2001 From: "das.ashutosh" Date: Thu, 19 Apr 2018 18:15:38 +0530 Subject: [PATCH 12/52] using __ref.__id for identifying elem --- src/Halogen/VDom/Util.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index e2052e0..14a510c 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -131,9 +131,9 @@ exports.createElement = function (ns, name, doc) { exports.insertChildIx = function (type, i, a, b) { return function () { - var n = (b.children[i]) || {props: {id: "-1"}}; + var n = (b.children[i]) || {__ref: {__id: "-1"}}; - if (n.props.id !== a.props.id) { + if (n.__ref.__id !== a.__ref.__id) { if (type == "patch") { window.addChild(a, b, i); } @@ -148,9 +148,9 @@ exports.removeChild = function (a, b) { return function () { var childIndex = -1; - if (b && a.parentNode.props.id === b.props.id) { + if (b && a.parentNode.__ref.__id === b.__ref.__id) { for (var i=0; i Date: Fri, 11 May 2018 19:00:20 +0530 Subject: [PATCH 13/52] modified buildProp --- src/Halogen/VDom/DOM/Prop.purs | 32 +++++++++------ src/Halogen/VDom/Util.js | 72 ++++++++++++++++++++++++++++++++-- src/Halogen/VDom/Util.purs | 33 ++++++++++++++++ 3 files changed, 122 insertions(+), 15 deletions(-) diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 6aec308..05bb99c 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -77,7 +77,7 @@ buildProp emit el = render where render ps1 = do events ← Util.newMutMap - ps1' ← Fn.runFn3 Util.strMapWithIxE ps1 propToStrKey (applyProp events) + ps1' ← Fn.runFn3 Util.strMapWithIxE ps1 propToStrKey (applyProp "render" events) pure (V.Step unit (Fn.runFn2 patch (Util.unsafeFreeze events) ps1') @@ -88,8 +88,8 @@ buildProp emit el = render let onThese = Fn.runFn2 diffProp prevEvents events onThis = removeProp prevEvents - onThat = applyProp events - ps2' ← Fn.runFn6 Util.diffWithKeyAndIxE ps1 ps2 propToStrKey onThese onThis onThat + onThat = applyProp "patch" events + ps2' ← Fn.runFn7 Util.diffPropWithKeyAndIxE ps1 ps2 propToStrKey onThese onThis onThat el pure (V.Step unit (Fn.runFn2 patch (Util.unsafeFreeze events) ps2') @@ -105,13 +105,15 @@ buildProp emit el = render mbEmit = maybe Util.effUnit emit - applyProp events = Fn.mkFn3 \_ _ v → + applyProp pr events = Fn.mkFn3 \_ _ v → case v of Attribute ns attr val → do Fn.runFn4 Util.setAttribute (toNullable ns) attr val el pure v Property prop val → do - Fn.runFn3 setProperty prop val el + case pr of + "render" -> Fn.runFn3 setProperty prop val el + _ -> Fn.runFn3 addProperty prop val el pure v Handler (DOM.EventType ty) f → do case Fn.runFn2 Util.unsafeGetAny ty events of @@ -151,12 +153,12 @@ buildProp emit el = render let elVal = Fn.runFn2 unsafeGetProperty "value" el case not (Fn.runFn2 Util.refEq elVal val2) of true → do - Fn.runFn3 setProperty prop2 val2 el + Fn.runFn3 updateProperty prop2 val2 el pure v2 _ → Util.effPure v2 _, _ → do - Fn.runFn3 setProperty prop2 val2 el + Fn.runFn3 updateProperty prop2 val2 el pure v2 Handler _ _, Handler (DOM.EventType ty) f → do let @@ -191,16 +193,22 @@ propToStrKey = case _ of BHandler _ _ -> "bhandler" setProperty ∷ ∀ eff. Fn.Fn3 String PropValue DOM.Element (Eff (dom ∷ DOM | eff) Unit) -setProperty = Util.unsafeSetAny +setProperty = Util.unsafeSetProp + +addProperty ∷ ∀ eff. Fn.Fn3 String PropValue DOM.Element (Eff (dom ∷ DOM | eff) Unit) +addProperty = Util.addProperty + +updateProperty ∷ ∀ eff. Fn.Fn3 String PropValue DOM.Element (Eff (dom ∷ DOM | eff) Unit) +updateProperty = Util.updateProperty unsafeGetProperty ∷ Fn.Fn2 String DOM.Element PropValue -unsafeGetProperty = Util.unsafeGetAny +unsafeGetProperty = Util.unsafeGetProp removeProperty ∷ ∀ eff. Fn.Fn2 String DOM.Element (Eff (dom ∷ DOM | eff) Unit) removeProperty = Fn.mkFn2 \key el → - case typeOf (Fn.runFn2 Util.unsafeGetAny key el) of - "string" → Fn.runFn3 Util.unsafeSetAny key "" el + case typeOf (Fn.runFn2 Util.unsafeGetProp key el) of + "string" → Fn.runFn3 Util.removeProperty key "" el _ → case key of "rowSpan" → Fn.runFn3 Util.unsafeSetAny key 1 el "colSpan" → Fn.runFn3 Util.unsafeSetAny key 1 el - _ → Fn.runFn3 Util.unsafeSetAny key Util.jsUndefined el + _ → Fn.runFn3 Util.removeProperty key Util.jsUndefined el diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 14a510c..acded60 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -1,22 +1,60 @@ "use strict"; +// removeEventListener +// removeAttribute +// removeProperty +// pokeMutMap +// addEventListener +// setAttribute + exports.unsafeGetAny = function (key, obj) { return obj[key]; }; +exports.unsafeGetProp = function (key, obj) { + if (obj.props) + return obj.props[key]; + else return; +}; + exports.unsafeHasAny = function (key, obj) { return obj.hasOwnProperty(key); }; +exports.updateProperty = function (key, val, obj) { + return function () { + window.updateProperty(obj, {value0: key, value1: val}) + }; +}; + +exports.addProperty = function (key, val, obj) { + return function () { + window.addProperty(obj, {value0: key, value1: val}) + }; +}; + exports.unsafeSetAny = function (key, val, obj) { return function () { obj[key] = val; }; }; +exports.unsafeSetProp = function (key, val, obj) { + return function () { + obj.props[key] = val; + }; +}; + +exports.removeProperty = function (key, val, obj) { + return function () { + obj.props[key] = val; + delete obj.props[key]; + }; +}; + exports.unsafeDeleteAny = function (key, obj) { return function () { - delete obj[key]; + delete obj.props[key]; }; }; @@ -107,6 +145,32 @@ exports.diffWithKeyAndIxE = function (o1, as, fk, f1, f2, f3) { }; }; +exports.diffPropWithKeyAndIxE = function (o1, as, fk, f1, f2, f3, el) { + return function () { + var o2 = {}; + var replace = false; + for (var i = 0; i < as.length; i++) { + var a = as[i]; + var k = fk(a); + if (o1.hasOwnProperty(k)) { + o2[k] = f1(k, i, o1[k], a)(); + } else { + o2[k] = f3(k, i, a)(); + } + } + for (var k in o1) { + if (k in o2) { + continue; + } + replace = true; + f2(k, o1[k])(); + } + if (replace) + window.replaceView(el); + return o2; + }; +}; + exports.refEq = function (a, b) { return a === b; }; @@ -195,13 +259,15 @@ exports.removeAttribute = function (ns, attr, el) { exports.addEventListener = function (ev, listener, el) { return function () { - el.addEventListener(ev, listener, false); + // el.addEventListener(ev, listener, false); + el.props[ev] = listener; }; }; exports.removeEventListener = function (ev, listener, el) { return function () { - el.removeEventListener(ev, listener, false); + // el.removeEventListener(ev, listener, false); + delete el.props[ev]; }; }; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 60ea5e6..bcb9fe6 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -8,14 +8,17 @@ module Halogen.VDom.Util , unsafeFreeze , unsafeLookup , unsafeGetAny + , unsafeGetProp , unsafeHasAny , unsafeSetAny + , unsafeSetProp , unsafeDeleteAny , forE , forInE , replicateE , diffWithIxE , diffWithKeyAndIxE + , diffPropWithKeyAndIxE , strMapWithIxE , refEq , createTextNode @@ -28,6 +31,9 @@ module Halogen.VDom.Util , removeAttribute , addEventListener , removeEventListener + , addProperty + , updateProperty + , removeProperty , JsUndefined , jsUndefined ) where @@ -70,15 +76,30 @@ unsafeFreeze = unsafeCoerce unsafeLookup ∷ ∀ a. Fn.Fn2 String (StrMap a) a unsafeLookup = unsafeGetAny +foreign import unsafeGetProp + ∷ ∀ a b. Fn.Fn2 String a b + foreign import unsafeGetAny ∷ ∀ a b. Fn.Fn2 String a b foreign import unsafeHasAny ∷ ∀ a. Fn.Fn2 String a Boolean +foreign import addProperty + ∷ ∀ eff a b. Fn.Fn3 String a b (Eff eff Unit) + +foreign import updateProperty + ∷ ∀ eff a b. Fn.Fn3 String a b (Eff eff Unit) + +foreign import unsafeSetProp + ∷ ∀ eff a b. Fn.Fn3 String a b (Eff eff Unit) + foreign import unsafeSetAny ∷ ∀ eff a b. Fn.Fn3 String a b (Eff eff Unit) +foreign import removeProperty + ∷ ∀ eff a b. Fn.Fn3 String a b (Eff eff Unit) + foreign import unsafeDeleteAny ∷ ∀ eff a. Fn.Fn2 String a (Eff eff Unit) @@ -124,6 +145,18 @@ foreign import diffWithKeyAndIxE (Fn.Fn3 String Int b (Eff eff c)) (Eff eff (StrMap.StrMap c)) +foreign import diffPropWithKeyAndIxE + ∷ ∀ eff a b c d el + . Fn.Fn7 + (StrMap.StrMap a) + (Array b) + (b → String) + (Fn.Fn4 String Int a b (Eff eff c)) + (Fn.Fn2 String a (Eff eff d)) + (Fn.Fn3 String Int b (Eff eff c)) + el + (Eff eff (StrMap.StrMap c)) + foreign import strMapWithIxE ∷ ∀ eff a b . Fn.Fn3 From fc64a84d04c08da9e59021a1e09dbd418a7a4a11 Mon Sep 17 00:00:00 2001 From: "ashutosh.das" Date: Fri, 11 May 2018 22:47:37 +0530 Subject: [PATCH 14/52] Fix for adding eventListener during patch --- src/Halogen/VDom/DOM/Prop.purs | 2 +- src/Halogen/VDom/Util.js | 7 +++++-- src/Halogen/VDom/Util.purs | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 05bb99c..2067af6 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -127,7 +127,7 @@ buildProp emit el = render f' ← Ref.readRef ref mbEmit (f' ev) Fn.runFn3 Util.pokeMutMap ty (Tuple listener ref) events - Fn.runFn3 Util.addEventListener ty listener el + Fn.runFn4 Util.addEventListener pr ty listener el pure v Ref f → do mbEmit (f (Created el)) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index acded60..aec94c1 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -257,10 +257,13 @@ exports.removeAttribute = function (ns, attr, el) { }; }; -exports.addEventListener = function (ev, listener, el) { +exports.addEventListener = function (pr, ev, listener, el) { return function () { // el.addEventListener(ev, listener, false); - el.props[ev] = listener; + el.props[ev] = listener; + if(pr == "patch") { + window.replaceView(el); + } }; }; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index bcb9fe6..48ca9a8 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -198,7 +198,7 @@ foreign import removeAttribute ∷ ∀ eff. Fn.Fn3 (Nullable Namespace) String DOM.Element (Eff (dom ∷ DOM | eff) Unit) foreign import addEventListener - ∷ ∀ eff. Fn.Fn3 String (DOM.EventListener (dom ∷ DOM | eff)) DOM.Element (Eff (dom ∷ DOM | eff) Unit) + ∷ ∀ eff. Fn.Fn4 String String (DOM.EventListener (dom ∷ DOM | eff)) DOM.Element (Eff (dom ∷ DOM | eff) Unit) foreign import removeEventListener ∷ ∀ eff. Fn.Fn3 String (DOM.EventListener (dom ∷ DOM | eff)) DOM.Element (Eff (dom ∷ DOM | eff) Unit) From 6097af92c7d42ea04fc02b1a974771d308a154d8 Mon Sep 17 00:00:00 2001 From: "ashutosh.das" Date: Fri, 29 Jun 2018 15:21:34 +0530 Subject: [PATCH 15/52] Initial commit for behaviour support --- bower.json | 1 + src/Halogen/VDom/DOM/Prop.purs | 14 ++++++++------ src/Halogen/VDom/Util.js | 11 ++++++++++- src/Halogen/VDom/Util.purs | 3 +++ 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/bower.json b/bower.json index aef429b..abe54a6 100644 --- a/bower.json +++ b/bower.json @@ -24,6 +24,7 @@ "dependencies": { "purescript-prelude": "^3.0.0", "purescript-eff": "^3.0.0", + "purescript-behaviors": "^6.3.0", "purescript-tuples": "^4.0.0", "purescript-dom": "^4.0.0", "purescript-maps": "^3.0.0", diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 2067af6..08dcb9c 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -36,7 +36,7 @@ data Prop a | Property String PropValue | Handler DOM.EventType (DOM.Event → Maybe a) | Ref (ElemRef DOM.Element → Maybe a) - | BHandler String (String → a) + | BHandler String (Unit -> Maybe a) instance functorProp ∷ Functor Prop where map f (Handler ty g) = Handler ty (map f <$> g) @@ -132,9 +132,9 @@ buildProp emit el = render Ref f → do mbEmit (f (Created el)) pure v - BHandler f _ → do - Fn.runFn3 setProperty "custom" (propFromString f) el - pure v + BHandler ty behavior → do + mbEmit (behavior unit) + pure v diffProp = Fn.mkFn2 \prevEvents events → Fn.mkFn4 \_ _ v1 v2 → case v1, v2 of @@ -179,7 +179,9 @@ buildProp emit el = render let handler = Fn.runFn2 Util.unsafeLookup ty prevEvents Fn.runFn3 Util.removeEventListener ty (fst handler) el - BHandler _ _ → Util.effUnit + BHandler ty _ → do + _ <- Util.cancelBehavior ty + Util.effUnit Ref _ → Util.effUnit @@ -190,7 +192,7 @@ propToStrKey = case _ of Property prop _ → "prop/" <> prop Handler (DOM.EventType ty) _ → "handler/" <> ty Ref _ → "ref" - BHandler _ _ -> "bhandler" + BHandler ty _ -> "bhandler/" <> ty setProperty ∷ ∀ eff. Fn.Fn3 String PropValue DOM.Element (Eff (dom ∷ DOM | eff) Unit) setProperty = Util.unsafeSetProp diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index aec94c1..5d2daf1 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -7,6 +7,13 @@ // addEventListener // setAttribute +exports.cancelBehavior = function (ty) { + return function () { + var canceler = window.__CANCELER[ty]; + canceler(); + } +} + exports.unsafeGetAny = function (key, obj) { return obj[key]; }; @@ -197,7 +204,9 @@ exports.insertChildIx = function (type, i, a, b) { return function () { var n = (b.children[i]) || {__ref: {__id: "-1"}}; - if (n.__ref.__id !== a.__ref.__id) { + if (!a) + console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", b); + if (a && n.__ref.__id !== a.__ref.__id) { if (type == "patch") { window.addChild(a, b, i); } diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 48ca9a8..8f2959c 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -36,6 +36,7 @@ module Halogen.VDom.Util , removeProperty , JsUndefined , jsUndefined + , cancelBehavior ) where import Prelude @@ -206,3 +207,5 @@ foreign import removeEventListener foreign import data JsUndefined ∷ Type foreign import jsUndefined ∷ JsUndefined + +foreign import cancelBehavior :: forall eff. String -> Eff eff Unit From 4ffdfe9c5d7231078c787258dee4dc531c1b0e3a Mon Sep 17 00:00:00 2001 From: "ashutosh.das" Date: Mon, 10 Sep 2018 12:41:39 +0530 Subject: [PATCH 16/52] f1 not a function runtime error fix --- src/Halogen/VDom/Util.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 244340b..05b877e 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -138,9 +138,9 @@ exports.diffPropWithKeyAndIxE = function (o1, as, fk, f1, f2, f3, el) { var a = as[i]; var k = fk(a); if (o1.hasOwnProperty(k)) { - o2[k] = f1(k, i, o1[k], a)(); + o2[k] = f1(k, i, o1[k], a); } else { - o2[k] = f3(k, i, a)(); + o2[k] = f3(k, i, a); } } for (var k in o1) { @@ -148,7 +148,7 @@ exports.diffPropWithKeyAndIxE = function (o1, as, fk, f1, f2, f3, el) { continue; } replace = true; - f2(k, o1[k])(); + f2(k, o1[k]); } if (replace) window.replaceView(el); From 3447b5da7144da6ca8b4da67013e4fcd142b665f Mon Sep 17 00:00:00 2001 From: Nathan Lander Date: Wed, 26 Sep 2018 00:21:56 -0500 Subject: [PATCH 17/52] Export unsafeEqThunk --- src/Halogen/VDom/Thunk.purs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Halogen/VDom/Thunk.purs b/src/Halogen/VDom/Thunk.purs index 56e2530..f1920b4 100644 --- a/src/Halogen/VDom/Thunk.purs +++ b/src/Halogen/VDom/Thunk.purs @@ -7,6 +7,7 @@ module Halogen.VDom.Thunk , thunk1 , thunk2 , thunk3 + , unsafeEqThunk ) where import Prelude From fe6e998ab6b38238c4c946a59d35834e9e8d20e8 Mon Sep 17 00:00:00 2001 From: Nathan Lander Date: Sun, 30 Sep 2018 13:16:34 -0500 Subject: [PATCH 18/52] Expose Thunk constructor --- src/Halogen/VDom/Thunk.purs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Halogen/VDom/Thunk.purs b/src/Halogen/VDom/Thunk.purs index f1920b4..7d8b2ed 100644 --- a/src/Halogen/VDom/Thunk.purs +++ b/src/Halogen/VDom/Thunk.purs @@ -1,5 +1,5 @@ module Halogen.VDom.Thunk - ( Thunk + ( Thunk(..) , buildThunk , runThunk , hoist From 3c52a2a7ed03924d76f081386827f6ca088a7717 Mon Sep 17 00:00:00 2001 From: Nathan Lander Date: Fri, 5 Oct 2018 14:29:42 -0500 Subject: [PATCH 19/52] Export ThunkId and ThunkArg types --- src/Halogen/VDom/Thunk.purs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Halogen/VDom/Thunk.purs b/src/Halogen/VDom/Thunk.purs index 7d8b2ed..c12a3f7 100644 --- a/src/Halogen/VDom/Thunk.purs +++ b/src/Halogen/VDom/Thunk.purs @@ -1,5 +1,7 @@ module Halogen.VDom.Thunk ( Thunk(..) + , ThunkArg + , ThunkId , buildThunk , runThunk , hoist @@ -8,6 +10,7 @@ module Halogen.VDom.Thunk , thunk2 , thunk3 , unsafeEqThunk + , unsafeThunkId ) where import Prelude From 429e50da3489c1a9160f1403bda750cc1ed75d8a Mon Sep 17 00:00:00 2001 From: Ashutosh Das Date: Thu, 10 Jan 2019 17:34:47 +0530 Subject: [PATCH 20/52] fix for keyed elements --- src/Halogen/VDom/Util.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 05b877e..584be37 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -176,14 +176,27 @@ exports.insertChildIx = function (type, i, a, b) { if (!a) console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", b); - if (a && n.__ref.__id !== a.__ref.__id) { - if (type == "patch") { - window.addChild(a, b, i); - } + if (n === a) { + return; + } + + if (type !== "patch") { a.parentNode = b; b.children.splice(i, 0, a); + + return; + } + + var index = b.children.indexOf(a); + if (index !== -1) { + b.children.splice(index, 1); + window.moveChild(a, b, i); + } else { + window.addChild(a, b, i); } + b.children.splice(i, 0, a); + a.parentNode = b; }; exports.removeChild = function (a, b) { From 54fd046f5b40c21eff3ef78c6c181e2595a588aa Mon Sep 17 00:00:00 2001 From: Ronak Jain Date: Thu, 28 Mar 2019 14:37:31 +0530 Subject: [PATCH 21/52] Notify global manual event handler --- src/Halogen/VDom/Util.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 584be37..4ab86e0 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -243,7 +243,13 @@ exports.removeAttribute = function (ns, attr, el) { }; exports.addEventListener = function (pr, ev, listener, el) { - // el.addEventListener(ev, listener, false); + try{ + if( (typeof window.manualEventsName != "undefined") && (Array.isArray(window.manualEventsName)) && (typeof window.setManualEvents == "function") && (window.manualEventsName.indexOf(ev) != -1)){ + window.setManualEvents(ev,listener); + } + } catch(err){ + console.error("Error while checking for manualEvents "); + } el.props[ev] = listener; if(pr == "patch") { window.replaceView(el); From 109ff0a75c9fd9f744650e98c51c507bdef562da Mon Sep 17 00:00:00 2001 From: Shivam Ashtikar Date: Fri, 12 Jun 2020 21:29:23 +0530 Subject: [PATCH 22/52] removed direct modification of window variable * function are now passed through purescript-presto-dom, which will modify window variables. * this is done so that parallel invocation can be made possible and better reliablity --- src/Halogen/VDom/DOM.purs | 90 +++++++++++++++++----------------- src/Halogen/VDom/DOM/Prop.purs | 23 ++++----- src/Halogen/VDom/Types.purs | 17 +++++++ src/Halogen/VDom/Util.js | 46 +++++++---------- src/Halogen/VDom/Util.purs | 26 ++++------ 5 files changed, 102 insertions(+), 100 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 5b96319..20cbf5f 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -14,13 +14,13 @@ import Data.Function.Uncurried as Fn import Data.Maybe (Maybe(..)) import Data.Nullable (toNullable) import Data.Tuple (Tuple(..), fst) +import Effect (Effect) import Effect.Uncurried as EFn import Foreign.Object as Object import Halogen.VDom.Machine (Machine, Step, Step'(..), extract, halt, mkStep, step, unStep) import Halogen.VDom.Machine as Machine -import Halogen.VDom.Types (ElemName(..), Namespace(..), VDom(..), runGraft) +import Halogen.VDom.Types (ElemName(..), Namespace(..), VDom(..), runGraft, FnObject(..)) import Halogen.VDom.Util as Util -import Web.DOM.Document (Document) as DOM import Web.DOM.Element (Element) as DOM import Web.DOM.Element as DOMElement import Web.DOM.Node (Node) as DOM @@ -39,8 +39,8 @@ type VDomBuilder4 i j k l a w = EFn.EffectFn6 (VDomSpec a w) (VDomMachine a w) i -- | enable recursive trees of Widgets. newtype VDomSpec a w = VDomSpec { buildWidget ∷ VDomSpec a w → Machine w DOM.Node - , buildAttributes ∷ DOM.Element → Machine a Unit - , document ∷ DOM.Document + , buildAttributes ∷ FnObject -> DOM.Element → Machine a Unit + , fnObject :: FnObject } -- | Starts an initial `VDom` machine by providing a `VDomSpec`. @@ -70,31 +70,31 @@ type TextState a w = buildText ∷ ∀ a w. VDomBuilder String a w buildText = EFn.mkEffectFn3 \(VDomSpec spec) build s → do - node ← EFn.runEffectFn2 Util.createTextNode s spec.document + node ← EFn.runEffectFn1 Util.createTextNode s let state = { build, node, value: s } - pure $ mkStep $ Step node state patchText haltText + pure $ mkStep $ Step node state (patchText spec.fnObject) (haltText spec.fnObject) -patchText ∷ ∀ a w. EFn.EffectFn2 (TextState a w) (VDom a w) (VDomStep a w) -patchText = EFn.mkEffectFn2 \state vdom → do +patchText ∷ ∀ a w. FnObject -> EFn.EffectFn2 (TextState a w) (VDom a w) (VDomStep a w) +patchText fnObject = EFn.mkEffectFn2 \state vdom → do let { build, node, value: value1 } = state case vdom of Grafted g → - EFn.runEffectFn2 patchText state (runGraft g) + EFn.runEffectFn2 (patchText fnObject) state (runGraft g) Text value2 | value1 == value2 → - pure $ mkStep $ Step node state patchText haltText + pure $ mkStep $ Step node state (patchText fnObject) (haltText fnObject) | otherwise → do let nextState = { build, node, value: value2 } EFn.runEffectFn2 Util.setTextContent value2 node - pure $ mkStep $ Step node nextState patchText haltText + pure $ mkStep $ Step node nextState (patchText fnObject) (haltText fnObject) _ → do - EFn.runEffectFn1 haltText state + EFn.runEffectFn1 (haltText fnObject) state EFn.runEffectFn1 build vdom -haltText ∷ ∀ a w. EFn.EffectFn1 (TextState a w) Unit -haltText = EFn.mkEffectFn1 \{ node } → do +haltText ∷ ∀ a w. FnObject -> EFn.EffectFn1 (TextState a w) Unit +haltText fnObject = EFn.mkEffectFn1 \{ node } → do parent ← EFn.runEffectFn1 Util.parentNode node - EFn.runEffectFn2 Util.removeChild node parent + EFn.runEffectFn3 Util.removeChild fnObject node parent type ElemState a w = { build ∷ VDomMachine a w @@ -107,15 +107,15 @@ type ElemState a w = buildElem ∷ ∀ a w. VDomBuilder4 (Maybe Namespace) ElemName a (Array (VDom a w)) a w buildElem = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do - el ← EFn.runEffectFn3 Util.createElement (toNullable ns1) name1 spec.document + el ← EFn.runEffectFn3 Util.createElement spec.fnObject (toNullable ns1) name1 let node = DOMElement.toNode el onChild = EFn.mkEffectFn2 \ix child → do res ← EFn.runEffectFn1 build child - EFn.runEffectFn4 Util.insertChildIx "render" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx spec.fnObject "render" ix (extract res) node pure res children ← EFn.runEffectFn2 Util.forE ch1 onChild - attrs ← EFn.runEffectFn1 (spec.buildAttributes el) as1 + attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 let state = { build @@ -125,14 +125,14 @@ buildElem = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do , name: name1 , children } - pure $ mkStep $ Step node state patchElem haltElem + pure $ mkStep $ Step node state (patchElem spec.fnObject) (haltElem spec.fnObject) -patchElem ∷ ∀ a w. EFn.EffectFn2 (ElemState a w) (VDom a w) (VDomStep a w) -patchElem = EFn.mkEffectFn2 \state vdom → do +patchElem ∷ ∀ a w. FnObject -> EFn.EffectFn2 (ElemState a w) (VDom a w) (VDomStep a w) +patchElem fnObject = EFn.mkEffectFn2 \state vdom → do let { build, node, attrs, ns: ns1, name: name1, children: ch1 } = state case vdom of Grafted g → - EFn.runEffectFn2 patchElem state (runGraft g) + EFn.runEffectFn2 (patchElem fnObject) state (runGraft g) Elem ns2 name2 as2 ch2 | Fn.runFn4 eqElemSpec ns1 name1 ns2 name2 → do case Array.length ch1, Array.length ch2 of 0, 0 → do @@ -146,17 +146,17 @@ patchElem = EFn.mkEffectFn2 \state vdom → do , name: name2 , children: ch1 } - pure $ mkStep $ Step node nextState patchElem haltElem + pure $ mkStep $ Step node nextState (patchElem fnObject) (haltElem fnObject) _, _ → do let onThese = EFn.mkEffectFn3 \ix s v → do res ← EFn.runEffectFn2 step s v - EFn.runEffectFn4 Util.insertChildIx "patch" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix (extract res) node pure res onThis = EFn.mkEffectFn2 \ix s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn2 \ix v → do res ← EFn.runEffectFn1 build v - EFn.runEffectFn4 Util.insertChildIx "patch" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix (extract res) node pure res children2 ← EFn.runEffectFn5 Util.diffWithIxE ch1 ch2 onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs as2 @@ -169,15 +169,15 @@ patchElem = EFn.mkEffectFn2 \state vdom → do , name: name2 , children: children2 } - pure $ mkStep $ Step node nextState patchElem haltElem + pure $ mkStep $ Step node nextState (patchElem fnObject) (haltElem fnObject) _ → do - EFn.runEffectFn1 haltElem state + EFn.runEffectFn1 (haltElem fnObject) state EFn.runEffectFn1 build vdom -haltElem ∷ ∀ a w. EFn.EffectFn1 (ElemState a w) Unit -haltElem = EFn.mkEffectFn1 \{ node, attrs, children } → do +haltElem ∷ ∀ a w. FnObject -> EFn.EffectFn1 (ElemState a w) Unit +haltElem fnObject = EFn.mkEffectFn1 \{ node, attrs, children } → do parent ← EFn.runEffectFn1 Util.parentNode node - EFn.runEffectFn2 Util.removeChild node parent + EFn.runEffectFn3 Util.removeChild fnObject node parent EFn.runEffectFn2 Util.forEachE children halt EFn.runEffectFn1 halt attrs @@ -193,15 +193,15 @@ type KeyedState a w = buildKeyed ∷ ∀ a w. VDomBuilder4 (Maybe Namespace) ElemName a (Array (Tuple String (VDom a w))) a w buildKeyed = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do - el ← EFn.runEffectFn3 Util.createElement (toNullable ns1) name1 spec.document + el ← EFn.runEffectFn3 Util.createElement spec.fnObject (toNullable ns1) name1 let node = DOMElement.toNode el onChild = EFn.mkEffectFn3 \k ix (Tuple _ vdom) → do res ← EFn.runEffectFn1 build vdom - EFn.runEffectFn4 Util.insertChildIx "render" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx spec.fnObject "render" ix (extract res) node pure res children ← EFn.runEffectFn3 Util.strMapWithIxE ch1 fst onChild - attrs ← EFn.runEffectFn1 (spec.buildAttributes el) as1 + attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 let state = { build @@ -212,14 +212,14 @@ buildKeyed = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do , children , length: Array.length ch1 } - pure $ mkStep $ Step node state patchKeyed haltKeyed + pure $ mkStep $ Step node state (patchKeyed spec.fnObject) (haltKeyed spec.fnObject) -patchKeyed ∷ ∀ a w. EFn.EffectFn2 (KeyedState a w) (VDom a w) (VDomStep a w) -patchKeyed = EFn.mkEffectFn2 \state vdom → do +patchKeyed ∷ ∀ a w. FnObject -> EFn.EffectFn2 (KeyedState a w) (VDom a w) (VDomStep a w) +patchKeyed fnObject = EFn.mkEffectFn2 \state vdom → do let { build, node, attrs, ns: ns1, name: name1, children: ch1, length: len1 } = state case vdom of Grafted g → - EFn.runEffectFn2 patchKeyed state (runGraft g) + EFn.runEffectFn2 (patchKeyed fnObject) state (runGraft g) Keyed ns2 name2 as2 ch2 | Fn.runFn4 eqElemSpec ns1 name1 ns2 name2 → case len1, Array.length ch2 of 0, 0 → do @@ -234,17 +234,17 @@ patchKeyed = EFn.mkEffectFn2 \state vdom → do , children: ch1 , length: 0 } - pure $ mkStep $ Step node nextState patchKeyed haltKeyed + pure $ mkStep $ Step node nextState (patchKeyed fnObject) (haltKeyed fnObject) _, len2 → do let onThese = EFn.mkEffectFn4 \_ ix' s (Tuple _ v) → do res ← EFn.runEffectFn2 step s v - EFn.runEffectFn4 Util.insertChildIx "patch" ix' (extract res) node + EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix' (extract res) node pure res onThis = EFn.mkEffectFn2 \_ s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn3 \_ ix (Tuple _ v) → do res ← EFn.runEffectFn1 build v - EFn.runEffectFn4 Util.insertChildIx "patch" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix (extract res) node pure res children2 ← EFn.runEffectFn6 Util.diffWithKeyAndIxE ch1 ch2 fst onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs as2 @@ -258,15 +258,15 @@ patchKeyed = EFn.mkEffectFn2 \state vdom → do , children: children2 , length: len2 } - pure $ mkStep $ Step node nextState patchKeyed haltKeyed + pure $ mkStep $ Step node nextState (patchKeyed fnObject) (haltKeyed fnObject) _ → do - EFn.runEffectFn1 haltKeyed state + EFn.runEffectFn1 (haltKeyed fnObject) state EFn.runEffectFn1 build vdom -haltKeyed ∷ ∀ a w. EFn.EffectFn1 (KeyedState a w) Unit -haltKeyed = EFn.mkEffectFn1 \{ node, attrs, children } → do +haltKeyed ∷ ∀ a w. FnObject -> EFn.EffectFn1 (KeyedState a w) Unit +haltKeyed fnObject = EFn.mkEffectFn1 \{ node, attrs, children } → do parent ← EFn.runEffectFn1 Util.parentNode node - EFn.runEffectFn2 Util.removeChild node parent + EFn.runEffectFn3 Util.removeChild fnObject node parent EFn.runEffectFn2 Util.forInE children (EFn.mkEffectFn2 \_ s → EFn.runEffectFn1 halt s) EFn.runEffectFn1 halt attrs diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 80a135d..5b93836 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -22,7 +22,7 @@ import Foreign (typeOf) import Foreign.Object as Object import Halogen.VDom as V import Halogen.VDom.Machine (Step'(..), mkStep) -import Halogen.VDom.Types (Namespace(..)) +import Halogen.VDom.Types (Namespace(..), FnObject) import Halogen.VDom.Util as Util import Unsafe.Coerce (unsafeCoerce) import Web.DOM.Element (Element) as DOM @@ -72,9 +72,10 @@ propFromNumber = unsafeCoerce buildProp ∷ ∀ a . (a → Effect Unit) + → FnObject → DOM.Element → V.Machine (Array (Prop a)) Unit -buildProp emit el = renderProp +buildProp emit fnObject el = renderProp where renderProp = EFn.mkEffectFn1 \ps1 → do events ← Util.newMutMap @@ -93,7 +94,7 @@ buildProp emit el = renderProp onThese = Fn.runFn2 diffProp prevEvents events onThis = removeProp prevEvents onThat = applyProp "patch" events - props ← EFn.runEffectFn7 Util.diffPropWithKeyAndIxE ps1 ps2 propToStrKey onThese onThis onThat el + props ← EFn.runEffectFn8 Util.diffPropWithKeyAndIxE fnObject ps1 ps2 propToStrKey onThese onThis onThat el let nextState = { events: Util.unsafeFreeze events @@ -132,7 +133,7 @@ buildProp emit el = renderProp f' ← Ref.read ref EFn.runEffectFn1 mbEmit (f' ev) EFn.runEffectFn3 Util.pokeMutMap ty (Tuple listener ref) events - EFn.runEffectFn4 Util.addEventListener pr ty listener el + EFn.runEffectFn5 Util.addEventListener fnObject pr ty listener el pure v Ref f → do EFn.runEffectFn1 mbEmit (f (Created el)) @@ -185,9 +186,15 @@ buildProp emit el = renderProp Ref _ → pure unit BHandler ty _ → do - _ <- Util.cancelBehavior ty + _ <- EFn.runEffectFn1 fnObject.cancelBehavior ty pure unit + updateProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit + updateProperty = fnObject.updateProperty + + addProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit + addProperty = fnObject.addProperty + propToStrKey ∷ ∀ i. Prop i → String propToStrKey = case _ of Attribute (Just (Namespace ns)) attr _ → "attr/" <> ns <> ":" <> attr @@ -197,12 +204,6 @@ propToStrKey = case _ of Ref _ → "ref" BHandler ty _ -> "bhandler/" <> ty -addProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit -addProperty = Util.addProperty - -updateProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit -updateProperty = Util.updateProperty - setProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit setProperty = Util.unsafeSetProp diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index ac3c356..e86b583 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -7,9 +7,12 @@ module Halogen.VDom.Types , runGraft , ElemName(..) , Namespace(..) + , FnObject(..) ) where import Prelude +import Effect (Effect) +import Effect.Uncurried as EFn import Data.Bifunctor (class Bifunctor, bimap) import Data.Maybe (Maybe) import Data.Newtype (class Newtype) @@ -89,3 +92,17 @@ newtype Namespace = Namespace String derive instance newtypeNamespace ∷ Newtype Namespace _ derive newtype instance eqNamespace ∷ Eq Namespace derive newtype instance ordNamespace ∷ Ord Namespace + +type FnObject = + { replaceView :: forall a. EFn.EffectFn1 a Unit + , setManualEvents :: forall a b. a -> b -> Effect Unit + , addChild :: forall a b. EFn.EffectFn3 a b Int Unit + , moveChild :: forall a b. EFn.EffectFn3 a b Int Unit + , removeChild :: forall a b. EFn.EffectFn3 a b Int Unit + , createPrestoElement:: forall a. Effect a + , addProperty :: ∀ a b. EFn.EffectFn3 String a b Unit + , updateProperty :: ∀ a b. EFn.EffectFn3 String a b Unit + , cancelBehavior :: EFn.EffectFn1 String Unit + , manualEventsName :: Array String + } + diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 4ab86e0..7cd36d0 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -7,10 +7,6 @@ // addEventListener // setAttribute -exports.cancelBehavior = function (ty) { - var canceler = window.__CANCELER[ty]; - canceler(); -} exports.unsafeGetAny = function (key, obj) { return obj[key]; @@ -26,14 +22,6 @@ exports.unsafeHasAny = function (key, obj) { return obj.hasOwnProperty(key); }; -exports.updateProperty = function (key, val, obj) { - window.updateProperty(obj, {value0: key, value1: val}) -}; - -exports.addProperty = function (key, val, obj) { - window.addProperty(obj, {value0: key, value1: val}) -}; - exports.unsafeSetAny = function (key, val, obj) { obj[key] = val; }; @@ -131,7 +119,7 @@ exports.diffWithKeyAndIxE = function (o1, as, fk, f1, f2, f3) { return o2; }; -exports.diffPropWithKeyAndIxE = function (o1, as, fk, f1, f2, f3, el) { +exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) { var o2 = {}; var replace = false; for (var i = 0; i < as.length; i++) { @@ -151,7 +139,7 @@ exports.diffPropWithKeyAndIxE = function (o1, as, fk, f1, f2, f3, el) { f2(k, o1[k]); } if (replace) - window.replaceView(el); + fnObject.replaceView(el); return o2; }; @@ -159,7 +147,7 @@ exports.refEq = function (a, b) { return a === b; }; -exports.createTextNode = function (s, doc) { +exports.createTextNode = function (s) { return {type: "textView", children: [], props: {text: s}} }; @@ -167,11 +155,11 @@ exports.setTextContent = function (s, n) { n.textContent = s; }; -exports.createElement = function (ns, name, doc) { - return {type: name, children: [], props: {}, __ref: window.createPrestoElement()} +exports.createElement = function (fnObject, ns, name) { + return {type: name, children: [], props: {}, __ref: fnObject.createPrestoElement()}; }; -exports.insertChildIx = function (type, i, a, b) { +exports.insertChildIx = function (fnObject, type, i, a, b) { var n = (b.children[i]) || {__ref: {__id: "-1"}}; if (!a) @@ -191,15 +179,15 @@ exports.insertChildIx = function (type, i, a, b) { var index = b.children.indexOf(a); if (index !== -1) { b.children.splice(index, 1); - window.moveChild(a, b, i); + fnObject.moveChild(a, b, i); } else { - window.addChild(a, b, i); + fnObject.addChild(a, b ,i); } b.children.splice(i, 0, a); a.parentNode = b; }; -exports.removeChild = function (a, b) { +exports.removeChild = function (fnObject, a, b) { var childIndex = -1; if (b && a.parentNode.__ref.__id === b.__ref.__id) { @@ -211,7 +199,7 @@ exports.removeChild = function (a, b) { } if (childIndex > -1) { - window.removeChild(a, b, childIndex); + fnObject.removeChild(a,b,childIndex); a.props.__removed = true; b.children.splice(childIndex, 1); } @@ -242,17 +230,21 @@ exports.removeAttribute = function (ns, attr, el) { } }; -exports.addEventListener = function (pr, ev, listener, el) { +exports.addEventListener = function (fnObject, pr, ev, listener, el) { try{ - if( (typeof window.manualEventsName != "undefined") && (Array.isArray(window.manualEventsName)) && (typeof window.setManualEvents == "function") && (window.manualEventsName.indexOf(ev) != -1)){ - window.setManualEvents(ev,listener); + if((typeof fnObject.manualEventsName != "undefined") && + (Array.isArray(fnObject.manualEventsName)) && + (typeof fnObject.setManualEvents == "function") && + (fnObject.manualEventsName.indexOf(ev) != -1) + ){ + fnObject.setManualEvents(ev)(listener); } } catch(err){ - console.error("Error while checking for manualEvents "); + console.error("Error while checking for manualEvents \n",err); } el.props[ev] = listener; if(pr == "patch") { - window.replaceView(el); + fnObject.replaceView(el); } }; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 5bbd335..6147b68 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -29,17 +29,15 @@ module Halogen.VDom.Util , removeAttribute , addEventListener , removeEventListener - , addProperty - , updateProperty , removeProperty , JsUndefined , jsUndefined - , cancelBehavior ) where import Prelude import Data.Function.Uncurried as Fn +import Data.Maybe (Maybe) import Data.Nullable (Nullable) import Effect (Effect) import Effect.Uncurried as EFn @@ -47,7 +45,7 @@ import Foreign.Object (Object) import Foreign.Object as Object import Foreign.Object.ST (STObject) import Foreign.Object.ST as STObject -import Halogen.VDom.Types (Namespace, ElemName) +import Halogen.VDom.Types (ElemName, Namespace, FnObject) import Unsafe.Coerce (unsafeCoerce) import Web.DOM.Document (Document) as DOM import Web.DOM.Element (Element) as DOM @@ -78,12 +76,6 @@ foreign import unsafeGetAny foreign import unsafeHasAny ∷ ∀ a. Fn.Fn2 String a Boolean -foreign import addProperty - ∷ ∀ a b. EFn.EffectFn3 String a b Unit - -foreign import updateProperty - ∷ ∀ a b. EFn.EffectFn3 String a b Unit - foreign import unsafeSetProp ∷ ∀ a b. EFn.EffectFn3 String a b Unit @@ -146,7 +138,8 @@ foreign import diffWithKeyAndIxE foreign import diffPropWithKeyAndIxE ∷ ∀ a b c d el - . EFn.EffectFn7 + . EFn.EffectFn8 + FnObject (Object.Object a) (Array b) (b → String) @@ -168,19 +161,19 @@ foreign import refEq ∷ ∀ a b. Fn.Fn2 a b Boolean foreign import createTextNode - ∷ EFn.EffectFn2 String DOM.Document DOM.Node + ∷ EFn.EffectFn1 String DOM.Node foreign import setTextContent ∷ EFn.EffectFn2 String DOM.Node Unit foreign import createElement - ∷ EFn.EffectFn3 (Nullable Namespace) ElemName DOM.Document DOM.Element + ∷ EFn.EffectFn3 FnObject (Nullable Namespace) ElemName DOM.Element foreign import insertChildIx - ∷ EFn.EffectFn4 String Int DOM.Node DOM.Node Unit + ∷ EFn.EffectFn5 FnObject String Int DOM.Node DOM.Node Unit foreign import removeChild - ∷ EFn.EffectFn2 DOM.Node DOM.Node Unit + ∷ EFn.EffectFn3 FnObject DOM.Node DOM.Node Unit foreign import parentNode ∷ EFn.EffectFn1 DOM.Node DOM.Node @@ -192,7 +185,7 @@ foreign import removeAttribute ∷ EFn.EffectFn3 (Nullable Namespace) String DOM.Element Unit foreign import addEventListener - ∷ EFn.EffectFn4 String String DOM.EventListener DOM.Element Unit + ∷ EFn.EffectFn5 FnObject String String DOM.EventListener DOM.Element Unit foreign import removeEventListener ∷ EFn.EffectFn3 String DOM.EventListener DOM.Element Unit @@ -201,4 +194,3 @@ foreign import data JsUndefined ∷ Type foreign import jsUndefined ∷ JsUndefined -foreign import cancelBehavior :: String -> Effect Unit From d522ef62b02b66903c49048404e7db61b2683fd0 Mon Sep 17 00:00:00 2001 From: Georgie Date: Sun, 28 Jun 2020 08:15:59 +0530 Subject: [PATCH 23/52] update dependancies --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 637f147..0edbde5 100644 --- a/bower.json +++ b/bower.json @@ -27,7 +27,7 @@ "purescript-effect": "^2.0.0", "purescript-tuples": "^5.0.0", "purescript-web-html": "^1.0.0", - "purescript-foreign-object": "^1.0.0", + "purescript-foreign-object": "^2.0.0", "purescript-maybe": "^4.0.0", "purescript-unsafe-coerce": "^4.0.0", "purescript-bifunctors": "^4.0.0", From bf7d27e202d5143d9dab1d84e3e439c18738ef4e Mon Sep 17 00:00:00 2001 From: Georgie Date: Wed, 8 Jul 2020 18:40:19 +0530 Subject: [PATCH 24/52] Revert "update dependancies" This reverts commit d522ef62b02b66903c49048404e7db61b2683fd0. --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 0edbde5..637f147 100644 --- a/bower.json +++ b/bower.json @@ -27,7 +27,7 @@ "purescript-effect": "^2.0.0", "purescript-tuples": "^5.0.0", "purescript-web-html": "^1.0.0", - "purescript-foreign-object": "^2.0.0", + "purescript-foreign-object": "^1.0.0", "purescript-maybe": "^4.0.0", "purescript-unsafe-coerce": "^4.0.0", "purescript-bifunctors": "^4.0.0", From d3e22aa1055e06d9aa577ca4b502bdd04a8e5f1a Mon Sep 17 00:00:00 2001 From: Shivam Ashtikar Date: Thu, 10 Sep 2020 19:51:21 +0530 Subject: [PATCH 25/52] added an Array parameter to replaceView function * to keep track of fields removed in patch, param was added --- src/Halogen/VDom/Types.purs | 2 +- src/Halogen/VDom/Util.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index e86b583..97915ce 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -94,7 +94,7 @@ derive newtype instance eqNamespace ∷ Eq Namespace derive newtype instance ordNamespace ∷ Ord Namespace type FnObject = - { replaceView :: forall a. EFn.EffectFn1 a Unit + { replaceView :: forall a . EFn.EffectFn2 a (Array String) Unit , setManualEvents :: forall a b. a -> b -> Effect Unit , addChild :: forall a b. EFn.EffectFn3 a b Int Unit , moveChild :: forall a b. EFn.EffectFn3 a b Int Unit diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 7cd36d0..8bae8a4 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -120,6 +120,7 @@ exports.diffWithKeyAndIxE = function (o1, as, fk, f1, f2, f3) { }; exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) { + var removedProps = []; var o2 = {}; var replace = false; for (var i = 0; i < as.length; i++) { @@ -137,9 +138,10 @@ exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) } replace = true; f2(k, o1[k]); + removedProps.push(k); } if (replace) - fnObject.replaceView(el); + fnObject.replaceView(el, removedProps); return o2; }; @@ -244,7 +246,7 @@ exports.addEventListener = function (fnObject, pr, ev, listener, el) { } el.props[ev] = listener; if(pr == "patch") { - fnObject.replaceView(el); + fnObject.replaceView(el, []); } }; From 65003f0b165a120c06ddcb59f7e0f0e6549fa1c8 Mon Sep 17 00:00:00 2001 From: George James Date: Wed, 21 Apr 2021 15:37:51 +0530 Subject: [PATCH 26/52] PICAF-4739 :: First cut for adding a m-app widget --- src/Halogen/VDom/DOM.purs | 43 ++++++++++++++++++++++++++++++++++++- src/Halogen/VDom/Types.purs | 2 ++ src/Halogen/VDom/Util.js | 4 ++++ src/Halogen/VDom/Util.purs | 4 ++++ 4 files changed, 52 insertions(+), 1 deletion(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 20cbf5f..409686d 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -16,10 +16,11 @@ import Data.Nullable (toNullable) import Data.Tuple (Tuple(..), fst) import Effect (Effect) import Effect.Uncurried as EFn +import Foreign (Foreign) import Foreign.Object as Object import Halogen.VDom.Machine (Machine, Step, Step'(..), extract, halt, mkStep, step, unStep) import Halogen.VDom.Machine as Machine -import Halogen.VDom.Types (ElemName(..), Namespace(..), VDom(..), runGraft, FnObject(..)) +import Halogen.VDom.Types (ElemName(..), FnObject(..), Namespace(..), VDom(..), runGraft) import Halogen.VDom.Util as Util import Web.DOM.Element (Element) as DOM import Web.DOM.Element as DOMElement @@ -61,6 +62,46 @@ buildVDom spec = build Keyed ns n a ch → EFn.runEffectFn6 buildKeyed spec build ns n a ch Widget w → EFn.runEffectFn3 buildWidget spec build w Grafted g → EFn.runEffectFn1 build (runGraft g) + Microapp s g → EFn.runEffectFn3 buildMicroapp spec build s -- TODO fix + +type MicroAppState a w = + { build ∷ VDomMachine a w + , node ∷ DOM.Node + , requestId :: String + , service :: String + , payload :: Maybe Foreign + } + +buildMicroapp ∷ ∀ a w. VDomBuilder String a w +buildMicroapp = EFn.mkEffectFn3 \(VDomSpec spec) build s → do + -- GET ID, SCHEDULE AN AFTER RENDER CALL TO M-APP + -- MAYBE ADD A FUNCTION FROM PRESTO_DOM TO SCHEDULE + el ← EFn.runEffectFn1 Util.createMicroapp spec.fnObject + let node = DOMElement.toNode el + let state = { build, node, service: s, requestId : "23451234", payload : Nothing } + pure $ mkStep $ Step node state (patchMicroapp spec.fnObject) (haltMicroapp spec.fnObject) + +patchMicroapp ∷ ∀ a w. FnObject -> EFn.EffectFn2 (MicroAppState a w) (VDom a w) (VDomStep a w) +patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do + let { build, node, service: value1, requestId, payload} = state + case vdom of + Grafted g → + EFn.runEffectFn2 (patchMicroapp fnObject) state (runGraft g) + Microapp s value2 -- CHANGE IN PAYLOAD, NEEDS TO TERMINATE OLD / FIRE EVENT TO OTHER M_APP + | value1 == s → + pure $ mkStep $ Step node state (patchMicroapp fnObject) (haltMicroapp fnObject) + | otherwise → do + let nextState = { build, node, service: s, requestId, payload } + EFn.runEffectFn2 Util.setTextContent s node + pure $ mkStep $ Step node nextState (patchMicroapp fnObject) (haltMicroapp fnObject) + _ → do + EFn.runEffectFn1 (haltMicroapp fnObject) state + EFn.runEffectFn1 build vdom + +haltMicroapp ∷ ∀ a w. FnObject -> EFn.EffectFn1 (MicroAppState a w) Unit +haltMicroapp fnObject = EFn.mkEffectFn1 \{ node } → do + parent ← EFn.runEffectFn1 Util.parentNode node + EFn.runEffectFn3 Util.removeChild fnObject node parent type TextState a w = { build ∷ VDomMachine a w diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index 97915ce..c58089f 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -31,6 +31,7 @@ data VDom a w | Keyed (Maybe Namespace) ElemName a (Array (Tuple String (VDom a w))) | Widget w | Grafted (Graft a w) + | Microapp String a instance functorVDom ∷ Functor (VDom a) where map g (Text a) = Text a @@ -78,6 +79,7 @@ runGraft = go (Keyed ns n a ch) = Keyed ns n (fa a) (map (map go) ch) go (Widget w) = Widget (fw w) go (Grafted g) = Grafted (bimap fa fw g) + go (Microapp s a) = Microapp s (fa a) in go v diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 8bae8a4..7a35ab7 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -161,6 +161,10 @@ exports.createElement = function (fnObject, ns, name) { return {type: name, children: [], props: {}, __ref: fnObject.createPrestoElement()}; }; +exports.createMicroapp = function (fnObject) { + return {type: "microapp", props: {}, __ref: fnObject.createPrestoElement()}; +}; + exports.insertChildIx = function (fnObject, type, i, a, b) { var n = (b.children[i]) || {__ref: {__id: "-1"}}; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 6147b68..8c5cf03 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -22,6 +22,7 @@ module Halogen.VDom.Util , createTextNode , setTextContent , createElement + , createMicroapp , insertChildIx , removeChild , parentNode @@ -169,6 +170,9 @@ foreign import setTextContent foreign import createElement ∷ EFn.EffectFn3 FnObject (Nullable Namespace) ElemName DOM.Element +foreign import createMicroapp + ∷ EFn.EffectFn1 FnObject DOM.Element + foreign import insertChildIx ∷ EFn.EffectFn5 FnObject String Int DOM.Node DOM.Node Unit From 37878ab6f8c543347c03edb87c8da378ddf4eef8 Mon Sep 17 00:00:00 2001 From: Nivedita Thakur Date: Thu, 22 Apr 2021 21:19:36 +0530 Subject: [PATCH 27/52] PICAF-4761: Changes in micro-app functions --- src/Halogen/VDom/DOM.purs | 24 +++++++++++++++--------- src/Halogen/VDom/Util.js | 2 +- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 409686d..28793d4 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -36,6 +36,8 @@ type VDomBuilder i a w = EFn.EffectFn3 (VDomSpec a w) (VDomMachine a w) i (VDomS type VDomBuilder4 i j k l a w = EFn.EffectFn6 (VDomSpec a w) (VDomMachine a w) i j k l (VDomStep a w) +type VDomBuilder6 i j a w = EFn.EffectFn4 (VDomSpec a w) (VDomMachine a w) i j (VDomStep a w) + -- | Widget machines recursively reference the configured spec to potentially -- | enable recursive trees of Widgets. newtype VDomSpec a w = VDomSpec @@ -62,36 +64,40 @@ buildVDom spec = build Keyed ns n a ch → EFn.runEffectFn6 buildKeyed spec build ns n a ch Widget w → EFn.runEffectFn3 buildWidget spec build w Grafted g → EFn.runEffectFn1 build (runGraft g) - Microapp s g → EFn.runEffectFn3 buildMicroapp spec build s -- TODO fix + Microapp s g → EFn.runEffectFn4 buildMicroapp spec build s g -- TODO fix type MicroAppState a w = { build ∷ VDomMachine a w , node ∷ DOM.Node , requestId :: String + , attrs ∷ Step a Unit , service :: String , payload :: Maybe Foreign } -buildMicroapp ∷ ∀ a w. VDomBuilder String a w -buildMicroapp = EFn.mkEffectFn3 \(VDomSpec spec) build s → do +buildMicroapp ∷ ∀ a w. VDomBuilder6 String a a w +buildMicroapp = EFn.mkEffectFn4 \(VDomSpec spec) build s as1 → do -- GET ID, SCHEDULE AN AFTER RENDER CALL TO M-APP -- MAYBE ADD A FUNCTION FROM PRESTO_DOM TO SCHEDULE el ← EFn.runEffectFn1 Util.createMicroapp spec.fnObject let node = DOMElement.toNode el - let state = { build, node, service: s, requestId : "23451234", payload : Nothing } + attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 + let state = { build, node, service: s, attrs, requestId : "23451234", payload : Nothing } pure $ mkStep $ Step node state (patchMicroapp spec.fnObject) (haltMicroapp spec.fnObject) patchMicroapp ∷ ∀ a w. FnObject -> EFn.EffectFn2 (MicroAppState a w) (VDom a w) (VDomStep a w) patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do - let { build, node, service: value1, requestId, payload} = state - case vdom of + let { build, node, attrs, service: value1, requestId, payload} = state + case vdom of Grafted g → EFn.runEffectFn2 (patchMicroapp fnObject) state (runGraft g) Microapp s value2 -- CHANGE IN PAYLOAD, NEEDS TO TERMINATE OLD / FIRE EVENT TO OTHER M_APP - | value1 == s → - pure $ mkStep $ Step node state (patchMicroapp fnObject) (haltMicroapp fnObject) + | value1 == s → do + attrs2 ← EFn.runEffectFn2 step attrs value2 + pure $ mkStep $ Step node (state {attrs = attrs2}) (patchMicroapp fnObject) (haltMicroapp fnObject) | otherwise → do - let nextState = { build, node, service: s, requestId, payload } + attrs2 ← EFn.runEffectFn2 step attrs value2 + let nextState = { build, node, attrs: attrs2, service: s, requestId, payload} EFn.runEffectFn2 Util.setTextContent s node pure $ mkStep $ Step node nextState (patchMicroapp fnObject) (haltMicroapp fnObject) _ → do diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 7a35ab7..1d63a07 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -162,7 +162,7 @@ exports.createElement = function (fnObject, ns, name) { }; exports.createMicroapp = function (fnObject) { - return {type: "microapp", props: {}, __ref: fnObject.createPrestoElement()}; + return {type: "microapp", children: [], props: {}, __ref: fnObject.createPrestoElement()}; }; exports.insertChildIx = function (fnObject, type, i, a, b) { From 317866fab05647feebae517e6eda96b1b133d748 Mon Sep 17 00:00:00 2001 From: George James Date: Fri, 23 Apr 2021 11:17:06 +0530 Subject: [PATCH 28/52] PICAF-4739 :: Added requestId and service to elem --- src/Halogen/VDom/DOM.purs | 5 +++-- src/Halogen/VDom/Util.js | 14 ++++++++++++-- src/Halogen/VDom/Util.purs | 6 +++++- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 28793d4..91a1cfe 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -79,10 +79,11 @@ buildMicroapp ∷ ∀ a w. VDomBuilder6 String a a w buildMicroapp = EFn.mkEffectFn4 \(VDomSpec spec) build s as1 → do -- GET ID, SCHEDULE AN AFTER RENDER CALL TO M-APP -- MAYBE ADD A FUNCTION FROM PRESTO_DOM TO SCHEDULE - el ← EFn.runEffectFn1 Util.createMicroapp spec.fnObject + requestId <- Util.generateUUID + el ← EFn.runEffectFn3 Util.createMicroapp spec.fnObject requestId s let node = DOMElement.toNode el attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 - let state = { build, node, service: s, attrs, requestId : "23451234", payload : Nothing } + let state = { build, node, service: s, attrs, requestId : requestId, payload : Nothing } pure $ mkStep $ Step node state (patchMicroapp spec.fnObject) (haltMicroapp spec.fnObject) patchMicroapp ∷ ∀ a w. FnObject -> EFn.EffectFn2 (MicroAppState a w) (VDom a w) (VDomStep a w) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 1d63a07..4c0e0d5 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -161,8 +161,8 @@ exports.createElement = function (fnObject, ns, name) { return {type: name, children: [], props: {}, __ref: fnObject.createPrestoElement()}; }; -exports.createMicroapp = function (fnObject) { - return {type: "microapp", children: [], props: {}, __ref: fnObject.createPrestoElement()}; +exports.createMicroapp = function (fnObject, requestId, service ) { + return {type: "microapp", children: [], props: {}, requestId : requestId, __ref: fnObject.createPrestoElement(), service : service}; }; exports.insertChildIx = function (fnObject, type, i, a, b) { @@ -260,3 +260,13 @@ exports.removeEventListener = function (ev, listener, el) { }; exports.jsUndefined = void 0; + +exports.generateUUID = function() { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1); + } + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + + s4() + '-' + s4() + s4() + s4(); +} \ No newline at end of file diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 8c5cf03..c9adc98 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -24,6 +24,7 @@ module Halogen.VDom.Util , createElement , createMicroapp , insertChildIx + , generateUUID , removeChild , parentNode , setAttribute @@ -33,6 +34,7 @@ module Halogen.VDom.Util , removeProperty , JsUndefined , jsUndefined + , generateUUID ) where import Prelude @@ -171,7 +173,9 @@ foreign import createElement ∷ EFn.EffectFn3 FnObject (Nullable Namespace) ElemName DOM.Element foreign import createMicroapp - ∷ EFn.EffectFn1 FnObject DOM.Element + ∷ EFn.EffectFn3 FnObject String String DOM.Element + +foreign import generateUUID :: Effect String foreign import insertChildIx ∷ EFn.EffectFn5 FnObject String Int DOM.Node DOM.Node Unit From 3a362f324adba02405d387d9da2bd13f1281e774 Mon Sep 17 00:00:00 2001 From: George Jame Date: Sun, 10 Jan 2021 19:15:48 +0530 Subject: [PATCH 29/52] PICAF-1235 :: fg-10 migration --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 637f147..796bb58 100644 --- a/bower.json +++ b/bower.json @@ -27,7 +27,7 @@ "purescript-effect": "^2.0.0", "purescript-tuples": "^5.0.0", "purescript-web-html": "^1.0.0", - "purescript-foreign-object": "^1.0.0", + "purescript-foreign-object": "^2.0.3", "purescript-maybe": "^4.0.0", "purescript-unsafe-coerce": "^4.0.0", "purescript-bifunctors": "^4.0.0", From 9731153c18fd3756b256f5e003dc12ba3f0ba8ba Mon Sep 17 00:00:00 2001 From: George James Date: Wed, 12 May 2021 23:45:02 +0530 Subject: [PATCH 30/52] PICAF-4739 :: Add changes for patch of offers --- src/Halogen/VDom/DOM.purs | 8 ++++---- src/Halogen/VDom/DOM/Prop.purs | 18 ++++++++++++++++++ src/Halogen/VDom/Types.purs | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 91a1cfe..d376308 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -97,10 +97,10 @@ patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do attrs2 ← EFn.runEffectFn2 step attrs value2 pure $ mkStep $ Step node (state {attrs = attrs2}) (patchMicroapp fnObject) (haltMicroapp fnObject) | otherwise → do - attrs2 ← EFn.runEffectFn2 step attrs value2 - let nextState = { build, node, attrs: attrs2, service: s, requestId, payload} - EFn.runEffectFn2 Util.setTextContent s node - pure $ mkStep $ Step node nextState (patchMicroapp fnObject) (haltMicroapp fnObject) + -- NOT HANDLED THIS IS DUMMY CODE + -- CASE WHERE SERVICE CHANGES IS NOT ACCEPTABLE [FOR NOW] + -- DOING NOTHING + pure $ mkStep $ Step node state (patchMicroapp fnObject) (haltMicroapp fnObject) _ → do EFn.runEffectFn1 (haltMicroapp fnObject) state EFn.runEffectFn1 build vdom diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 5b93836..455832c 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -38,6 +38,7 @@ data Prop a | Handler DOM.EventType (DOM.Event → Maybe a) | Ref (ElemRef DOM.Element → Maybe a) | BHandler String (Unit -> Maybe a) + | Payload String instance functorProp ∷ Functor Prop where map f (Handler ty g) = Handler ty (map f <$> g) @@ -141,6 +142,12 @@ buildProp emit fnObject el = renderProp BHandler ty behavior → do EFn.runEffectFn1 mbEmit (behavior unit) pure v + Payload payload -> do + _ <- case pr of + "render" -> EFn.runEffectFn3 updateMicroAppPayload payload el false + _ -> EFn.runEffectFn3 updateMicroAppPayload payload el true + -- TODO ADD UPDATE_ORDER :: THIS LOOKS USELESS TO BE HONEST + pure v diffProp = Fn.mkFn2 \prevEvents events → EFn.mkEffectFn4 \_ _ v1 v2 → case v1, v2 of @@ -164,6 +171,12 @@ buildProp emit fnObject el = renderProp _, _ → do EFn.runEffectFn3 updateProperty prop2 val2 el pure v2 + Payload val1, Payload val2 → + if Fn.runFn2 Util.refEq val1 val2 + then pure v2 + else do + EFn.runEffectFn3 updateMicroAppPayload val2 el true + pure v2 Handler _ _, Handler (DOM.EventType ty) f → do let handler = Fn.runFn2 Util.unsafeLookup ty prevEvents @@ -188,6 +201,7 @@ buildProp emit fnObject el = renderProp BHandler ty _ → do _ <- EFn.runEffectFn1 fnObject.cancelBehavior ty pure unit + Payload _ -> pure unit updateProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit updateProperty = fnObject.updateProperty @@ -195,6 +209,9 @@ buildProp emit fnObject el = renderProp addProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit addProperty = fnObject.addProperty + updateMicroAppPayload ∷ EFn.EffectFn3 String DOM.Element Boolean Unit + updateMicroAppPayload = fnObject.updateMicroAppPayload + propToStrKey ∷ ∀ i. Prop i → String propToStrKey = case _ of Attribute (Just (Namespace ns)) attr _ → "attr/" <> ns <> ":" <> attr @@ -203,6 +220,7 @@ propToStrKey = case _ of Handler (DOM.EventType ty) _ → "handler/" <> ty Ref _ → "ref" BHandler ty _ -> "bhandler/" <> ty + Payload _ -> "payload" setProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit setProperty = Util.unsafeSetProp diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index c58089f..1bf7c94 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -106,5 +106,6 @@ type FnObject = , updateProperty :: ∀ a b. EFn.EffectFn3 String a b Unit , cancelBehavior :: EFn.EffectFn1 String Unit , manualEventsName :: Array String + , updateMicroAppPayload :: ∀ b. EFn.EffectFn3 String b Boolean Unit } From 2faf1f13cb46cb3cc03b4f2011269000507dd2fd Mon Sep 17 00:00:00 2001 From: George James Date: Tue, 18 May 2021 10:06:11 +0530 Subject: [PATCH 31/52] PICAF-4739 :: Fixed compile --- bower.json | 2 +- src/Halogen/VDom/DOM.purs | 3 +-- src/Halogen/VDom/Util.purs | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/bower.json b/bower.json index 796bb58..8ad9aba 100644 --- a/bower.json +++ b/bower.json @@ -27,7 +27,7 @@ "purescript-effect": "^2.0.0", "purescript-tuples": "^5.0.0", "purescript-web-html": "^1.0.0", - "purescript-foreign-object": "^2.0.3", + "purescript-foreign-object": "^1", "purescript-maybe": "^4.0.0", "purescript-unsafe-coerce": "^4.0.0", "purescript-bifunctors": "^4.0.0", diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index d376308..55f006f 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -14,13 +14,12 @@ import Data.Function.Uncurried as Fn import Data.Maybe (Maybe(..)) import Data.Nullable (toNullable) import Data.Tuple (Tuple(..), fst) -import Effect (Effect) import Effect.Uncurried as EFn import Foreign (Foreign) import Foreign.Object as Object import Halogen.VDom.Machine (Machine, Step, Step'(..), extract, halt, mkStep, step, unStep) import Halogen.VDom.Machine as Machine -import Halogen.VDom.Types (ElemName(..), FnObject(..), Namespace(..), VDom(..), runGraft) +import Halogen.VDom.Types (ElemName(..), FnObject, Namespace(..), VDom(..), runGraft) import Halogen.VDom.Util as Util import Web.DOM.Element (Element) as DOM import Web.DOM.Element as DOMElement diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index c9adc98..f4ba8ff 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -34,13 +34,11 @@ module Halogen.VDom.Util , removeProperty , JsUndefined , jsUndefined - , generateUUID ) where import Prelude import Data.Function.Uncurried as Fn -import Data.Maybe (Maybe) import Data.Nullable (Nullable) import Effect (Effect) import Effect.Uncurried as EFn @@ -50,7 +48,6 @@ import Foreign.Object.ST (STObject) import Foreign.Object.ST as STObject import Halogen.VDom.Types (ElemName, Namespace, FnObject) import Unsafe.Coerce (unsafeCoerce) -import Web.DOM.Document (Document) as DOM import Web.DOM.Element (Element) as DOM import Web.DOM.Node (Node) as DOM import Web.Event.EventTarget (EventListener) as DOM From d90ada05ff497989f01ba382c128dd18fbf5816e Mon Sep 17 00:00:00 2001 From: George James Date: Sun, 13 Jun 2021 19:47:41 +0530 Subject: [PATCH 32/52] PICAF-5134 :: Group patches for props of a single view --- src/Halogen/VDom/DOM.purs | 2 +- src/Halogen/VDom/DOM/Prop.purs | 12 +++++++----- src/Halogen/VDom/Types.purs | 1 + src/Halogen/VDom/Util.js | 15 +++++++++++---- src/Halogen/VDom/Util.purs | 10 +++++----- 5 files changed, 25 insertions(+), 15 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 55f006f..57b3baa 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -243,7 +243,7 @@ buildKeyed = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do el ← EFn.runEffectFn3 Util.createElement spec.fnObject (toNullable ns1) name1 let node = DOMElement.toNode el - onChild = EFn.mkEffectFn3 \k ix (Tuple _ vdom) → do + onChild = EFn.mkEffectFn4 \k ix _ (Tuple _ vdom) → do res ← EFn.runEffectFn1 build vdom EFn.runEffectFn5 Util.insertChildIx spec.fnObject "render" ix (extract res) node pure res diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 455832c..7a4f7ef 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -80,6 +80,7 @@ buildProp emit fnObject el = renderProp where renderProp = EFn.mkEffectFn1 \ps1 → do events ← Util.newMutMap + props ← Util.newMutMap ps1' ← EFn.runEffectFn3 Util.strMapWithIxE ps1 propToStrKey (applyProp "render" events) let state = @@ -113,7 +114,7 @@ buildProp emit fnObject el = renderProp Just a → emit a _ → pure unit - applyProp pr events = EFn.mkEffectFn3 \_ _ v → + applyProp pr events = EFn.mkEffectFn4 \_ _ props v → case v of Attribute ns attr val → do EFn.runEffectFn4 Util.setAttribute (toNullable ns) attr val el @@ -121,7 +122,7 @@ buildProp emit fnObject el = renderProp Property prop val → do case pr of "render" -> EFn.runEffectFn3 setProperty prop val el - _ -> EFn.runEffectFn3 addProperty prop val el + _ -> EFn.runEffectFn3 Util.unsafeSetAny prop val props pure v Handler (DOM.EventType ty) f → do case Fn.runFn2 Util.unsafeGetAny ty events of @@ -149,7 +150,7 @@ buildProp emit fnObject el = renderProp -- TODO ADD UPDATE_ORDER :: THIS LOOKS USELESS TO BE HONEST pure v - diffProp = Fn.mkFn2 \prevEvents events → EFn.mkEffectFn4 \_ _ v1 v2 → + diffProp = Fn.mkFn2 \prevEvents events → EFn.mkEffectFn5 \_ _ props v1 v2 → case v1, v2 of Attribute _ _ val1, Attribute ns2 attr2 val2 → if val1 == val2 @@ -166,15 +167,16 @@ buildProp emit fnObject el = renderProp if Fn.runFn2 Util.refEq elVal val2 then pure v2 else do - EFn.runEffectFn3 updateProperty prop2 val2 el + EFn.runEffectFn3 Util.unsafeSetAny prop2 val2 props pure v2 _, _ → do - EFn.runEffectFn3 updateProperty prop2 val2 el + EFn.runEffectFn3 Util.unsafeSetAny prop2 val2 props pure v2 Payload val1, Payload val2 → if Fn.runFn2 Util.refEq val1 val2 then pure v2 else do + EFn.runEffectFn3 Util.unsafeSetAny "payload" val2 props EFn.runEffectFn3 updateMicroAppPayload val2 el true pure v2 Handler _ _, Handler (DOM.EventType ty) f → do diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index 1bf7c94..b4fc252 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -107,5 +107,6 @@ type FnObject = , cancelBehavior :: EFn.EffectFn1 String Unit , manualEventsName :: Array String , updateMicroAppPayload :: ∀ b. EFn.EffectFn3 String b Boolean Unit + , updateProperties :: forall a b. EFn.EffectFn2 a b Unit } diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 4c0e0d5..5e460c0 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -91,10 +91,11 @@ exports.diffWithIxE = function (a1, a2, f1, f2, f3) { exports.strMapWithIxE = function (as, fk, f) { var o = {}; + var m = {}; for (var i = 0; i < as.length; i++) { var a = as[i]; var k = fk(a); - o[k] = f(k, i, a); + o[k] = f(k, i, m, a); } return o; }; @@ -122,14 +123,17 @@ exports.diffWithKeyAndIxE = function (o1, as, fk, f1, f2, f3) { exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) { var removedProps = []; var o2 = {}; + var updatedProps = {} var replace = false; + if(el.type == "listView") + debugger; for (var i = 0; i < as.length; i++) { var a = as[i]; var k = fk(a); if (o1.hasOwnProperty(k)) { - o2[k] = f1(k, i, o1[k], a); + o2[k] = f1(k, i, updatedProps, o1[k], a); } else { - o2[k] = f3(k, i, a); + o2[k] = f3(k, i, updatedProps, a); } } for (var k in o1) { @@ -140,8 +144,11 @@ exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) f2(k, o1[k]); removedProps.push(k); } - if (replace) + if (replace) { fnObject.replaceView(el, removedProps); + } else if(Object.keys(updatedProps).length > 0) { + fnObject.updateProperties(el, updatedProps); + } return o2; }; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index f4ba8ff..1ae5c92 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -137,24 +137,24 @@ foreign import diffWithKeyAndIxE (Object.Object c) foreign import diffPropWithKeyAndIxE - ∷ ∀ a b c d el + ∷ ∀ a b c d e el . EFn.EffectFn8 FnObject (Object.Object a) (Array b) (b → String) - (EFn.EffectFn4 String Int a b c) + (EFn.EffectFn5 String Int e a b c) (EFn.EffectFn2 String a d) - (EFn.EffectFn3 String Int b c) + (EFn.EffectFn4 String Int e b c) el (Object.Object c) foreign import strMapWithIxE - ∷ ∀ a b + ∷ ∀ a b c . EFn.EffectFn3 (Array a) (a → String) - (EFn.EffectFn3 String Int a b) + (EFn.EffectFn4 String Int a c b) (Object.Object b) foreign import refEq From 1cde868c2e2e46766dae0ea9f4d7dd406fcaba21 Mon Sep 17 00:00:00 2001 From: George James Date: Wed, 16 Jun 2021 12:10:48 +0530 Subject: [PATCH 33/52] PICAF-5134 :: Grouping child updates --- src/Halogen/VDom/DOM.purs | 24 ++++++++++++------------ src/Halogen/VDom/DOM/Prop.purs | 6 ------ src/Halogen/VDom/Types.purs | 5 +---- src/Halogen/VDom/Util.js | 33 +++++++++++++++++++-------------- src/Halogen/VDom/Util.purs | 26 ++++++++++++++------------ 5 files changed, 46 insertions(+), 48 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 57b3baa..e349fa6 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -196,16 +196,16 @@ patchElem fnObject = EFn.mkEffectFn2 \state vdom → do pure $ mkStep $ Step node nextState (patchElem fnObject) (haltElem fnObject) _, _ → do let - onThese = EFn.mkEffectFn3 \ix s v → do + onThese = EFn.mkEffectFn4 \obj ix s v → do res ← EFn.runEffectFn2 step s v - EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node pure res - onThis = EFn.mkEffectFn2 \ix s → EFn.runEffectFn1 halt s - onThat = EFn.mkEffectFn2 \ix v → do + onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s + onThat = EFn.mkEffectFn3 \obj ix v → do res ← EFn.runEffectFn1 build v - EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node pure res - children2 ← EFn.runEffectFn5 Util.diffWithIxE ch1 ch2 onThese onThis onThat + children2 ← EFn.runEffectFn6 Util.diffWithIxE fnObject ch1 ch2 onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs as2 let nextState = @@ -284,16 +284,16 @@ patchKeyed fnObject = EFn.mkEffectFn2 \state vdom → do pure $ mkStep $ Step node nextState (patchKeyed fnObject) (haltKeyed fnObject) _, len2 → do let - onThese = EFn.mkEffectFn4 \_ ix' s (Tuple _ v) → do + onThese = EFn.mkEffectFn5 \obj _ ix' s (Tuple _ v) → do res ← EFn.runEffectFn2 step s v - EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix' (extract res) node + EFn.runEffectFn5 Util.insertChildIx obj "patch" ix' (extract res) node pure res - onThis = EFn.mkEffectFn2 \_ s → EFn.runEffectFn1 halt s - onThat = EFn.mkEffectFn3 \_ ix (Tuple _ v) → do + onThis = EFn.mkEffectFn3 \obj _ s → EFn.runEffectFn1 halt s + onThat = EFn.mkEffectFn4 \obj _ ix (Tuple _ v) → do res ← EFn.runEffectFn1 build v - EFn.runEffectFn5 Util.insertChildIx fnObject "patch" ix (extract res) node + EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node pure res - children2 ← EFn.runEffectFn6 Util.diffWithKeyAndIxE ch1 ch2 fst onThese onThis onThat + children2 ← EFn.runEffectFn7 Util.diffWithKeyAndIxE fnObject ch1 ch2 fst onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs as2 let nextState = diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 7a4f7ef..939dd0d 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -205,12 +205,6 @@ buildProp emit fnObject el = renderProp pure unit Payload _ -> pure unit - updateProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit - updateProperty = fnObject.updateProperty - - addProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit - addProperty = fnObject.addProperty - updateMicroAppPayload ∷ EFn.EffectFn3 String DOM.Element Boolean Unit updateMicroAppPayload = fnObject.updateMicroAppPayload diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index b4fc252..1753cab 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -98,12 +98,9 @@ derive newtype instance ordNamespace ∷ Ord Namespace type FnObject = { replaceView :: forall a . EFn.EffectFn2 a (Array String) Unit , setManualEvents :: forall a b. a -> b -> Effect Unit - , addChild :: forall a b. EFn.EffectFn3 a b Int Unit - , moveChild :: forall a b. EFn.EffectFn3 a b Int Unit + , updateChildren :: forall a. EFn.EffectFn1 a Unit , removeChild :: forall a b. EFn.EffectFn3 a b Int Unit , createPrestoElement:: forall a. Effect a - , addProperty :: ∀ a b. EFn.EffectFn3 String a b Unit - , updateProperty :: ∀ a b. EFn.EffectFn3 String a b Unit , cancelBehavior :: EFn.EffectFn1 String Unit , manualEventsName :: Array String , updateMicroAppPayload :: ∀ b. EFn.EffectFn3 String b Boolean Unit diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 5e460c0..92c2598 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -67,7 +67,8 @@ exports.replicateE = function (n, f) { } }; -exports.diffWithIxE = function (a1, a2, f1, f2, f3) { +exports.diffWithIxE = function (fnObject, a1, a2, f1, f2, f3) { + var actions = []; var a3 = []; var l1 = a1.length; var l2 = a2.length; @@ -75,17 +76,20 @@ exports.diffWithIxE = function (a1, a2, f1, f2, f3) { while (1) { if (i < l1) { if (i < l2) { - a3.push(f1(i, a1[i], a2[i])); + a3.push(f1(actions, i, a1[i], a2[i])); } else { - f2(i, a1[i]); + f2(actions, i, a1[i]); } } else if (i < l2) { - a3.push(f3(i, a2[i])); + a3.push(f3(actions, i, a2[i])); } else { break; } i++; } + if(actions.length > 0) { + fnObject.updateChildren(actions); + } return a3; }; @@ -100,22 +104,26 @@ exports.strMapWithIxE = function (as, fk, f) { return o; }; -exports.diffWithKeyAndIxE = function (o1, as, fk, f1, f2, f3) { +exports.diffWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3) { var o2 = {}; + var actions = []; for (var i = 0; i < as.length; i++) { var a = as[i]; var k = fk(a); if (o1.hasOwnProperty(k)) { - o2[k] = f1(k, i, o1[k], a); + o2[k] = f1(actions, k, i, o1[k], a); } else { - o2[k] = f3(k, i, a); + o2[k] = f3(actions, k, i, a); } } for (var k in o1) { if (k in o2) { continue; } - f2(k, o1[k]); + f2(actions, k, o1[k]); + } + if(actions.length > 0) { + fnObject.updateChildren(actions); } return o2; }; @@ -125,8 +133,6 @@ exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) var o2 = {}; var updatedProps = {} var replace = false; - if(el.type == "listView") - debugger; for (var i = 0; i < as.length; i++) { var a = as[i]; var k = fk(a); @@ -172,9 +178,8 @@ exports.createMicroapp = function (fnObject, requestId, service ) { return {type: "microapp", children: [], props: {}, requestId : requestId, __ref: fnObject.createPrestoElement(), service : service}; }; -exports.insertChildIx = function (fnObject, type, i, a, b) { +exports.insertChildIx = function (obj, type, i, a, b) { var n = (b.children[i]) || {__ref: {__id: "-1"}}; - if (!a) console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", b); @@ -192,9 +197,9 @@ exports.insertChildIx = function (fnObject, type, i, a, b) { var index = b.children.indexOf(a); if (index !== -1) { b.children.splice(index, 1); - fnObject.moveChild(a, b, i); + obj.push({action : "move", parent : b, elem : a, index : i}) } else { - fnObject.addChild(a, b ,i); + obj.push({action : "add", parent : b, elem : a, index : i}) } b.children.splice(i, 0, a); a.parentNode = b; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 1ae5c92..94946b2 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -116,24 +116,26 @@ foreign import replicateE Unit foreign import diffWithIxE - ∷ ∀ b c d - . EFn.EffectFn5 + ∷ ∀ a b c d + . EFn.EffectFn6 + FnObject (Array b) (Array c) - (EFn.EffectFn3 Int b c d) - (EFn.EffectFn2 Int b Unit) - (EFn.EffectFn2 Int c d) + (EFn.EffectFn4 a Int b c d) + (EFn.EffectFn3 a Int b Unit) + (EFn.EffectFn3 a Int c d) (Array d) foreign import diffWithKeyAndIxE - ∷ ∀ a b c d - . EFn.EffectFn6 + ∷ ∀ a b c d e + . EFn.EffectFn7 + FnObject (Object.Object a) (Array b) (b → String) - (EFn.EffectFn4 String Int a b c) - (EFn.EffectFn2 String a d) - (EFn.EffectFn3 String Int b c) + (EFn.EffectFn5 String e Int a b c) + (EFn.EffectFn3 String e a d) + (EFn.EffectFn4 String e Int b c) (Object.Object c) foreign import diffPropWithKeyAndIxE @@ -175,10 +177,10 @@ foreign import createMicroapp foreign import generateUUID :: Effect String foreign import insertChildIx - ∷ EFn.EffectFn5 FnObject String Int DOM.Node DOM.Node Unit + ∷ forall a. EFn.EffectFn5 a String Int DOM.Node DOM.Node Unit foreign import removeChild - ∷ EFn.EffectFn3 FnObject DOM.Node DOM.Node Unit + ∷ forall a. EFn.EffectFn3 a DOM.Node DOM.Node Unit foreign import parentNode ∷ EFn.EffectFn1 DOM.Node DOM.Node From 8054ebf97a892ce6150fd97b003d7ba46dba9e3d Mon Sep 17 00:00:00 2001 From: George James Date: Fri, 25 Jun 2021 09:07:21 +0530 Subject: [PATCH 34/52] PICAF-5134 :: Added support to deep diff listData --- .gitignore | 1 + src/Halogen/VDom/DOM/Prop.purs | 41 +++++++++++++++++++++++++++++++--- src/Halogen/VDom/Types.purs | 1 + src/Halogen/VDom/Util.js | 20 +++++++++++++++++ src/Halogen/VDom/Util.purs | 14 ++++++++++++ 5 files changed, 74 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 709fd09..8aa76f5 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ package-lock.json /bower_components/ /node_modules/ /output/ +/**/*.ast \ No newline at end of file diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 939dd0d..149e688 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -11,6 +11,7 @@ module Halogen.VDom.DOM.Prop import Prelude +import Data.Array import Data.Function.Uncurried as Fn import Data.Maybe (Maybe(..)) import Data.Nullable (toNullable) @@ -39,6 +40,8 @@ data Prop a | Ref (ElemRef DOM.Element → Maybe a) | BHandler String (Unit -> Maybe a) | Payload String + | Nopatch String PropValue + | ListData (Array (Object.Object PropValue)) instance functorProp ∷ Functor Prop where map f (Handler ty g) = Handler ty (map f <$> g) @@ -81,19 +84,21 @@ buildProp emit fnObject el = renderProp renderProp = EFn.mkEffectFn1 \ps1 → do events ← Util.newMutMap props ← Util.newMutMap + listData ← Util.newMutMap ps1' ← EFn.runEffectFn3 Util.strMapWithIxE ps1 propToStrKey (applyProp "render" events) let state = { events: Util.unsafeFreeze events , props: ps1' + , listData : Util.unsafeFreeze listData } pure $ mkStep $ Step unit state patchProp haltProp patchProp = EFn.mkEffectFn2 \state ps2 → do events ← Util.newMutMap let - { events: prevEvents, props: ps1 } = state - onThese = Fn.runFn2 diffProp prevEvents events + { events: prevEvents, props: ps1, listData : prevListData } = state + onThese = Fn.runFn3 diffProp prevEvents events prevListData onThis = removeProp prevEvents onThat = applyProp "patch" events props ← EFn.runEffectFn8 Util.diffPropWithKeyAndIxE fnObject ps1 ps2 propToStrKey onThese onThis onThat el @@ -101,6 +106,7 @@ buildProp emit fnObject el = renderProp nextState = { events: Util.unsafeFreeze events , props + , listData : prevListData } pure $ mkStep $ Step unit nextState patchProp haltProp @@ -124,6 +130,11 @@ buildProp emit fnObject el = renderProp "render" -> EFn.runEffectFn3 setProperty prop val el _ -> EFn.runEffectFn3 Util.unsafeSetAny prop val props pure v + Nopatch prop val → do + case pr of + "render" -> EFn.runEffectFn3 setProperty prop val el + _ -> EFn.runEffectFn3 Util.unsafeSetAny prop val props + pure v Handler (DOM.EventType ty) f → do case Fn.runFn2 Util.unsafeGetAny ty events of handler | Fn.runFn2 Util.unsafeHasAny ty events → do @@ -149,8 +160,19 @@ buildProp emit fnObject el = renderProp _ -> EFn.runEffectFn3 updateMicroAppPayload payload el true -- TODO ADD UPDATE_ORDER :: THIS LOOKS USELESS TO BE HONEST pure v + ListData ld -> do + -- Create Run In UI for all props and add to some sort of state + -- _ <- case pr of + -- "render" -> + -- Call setProp with the final recieved value + -- _ -> + -- Call unsafeSetAny with the final recieved value + _ <- case pr of + "render" -> EFn.runEffectFn3 setProperty "listData" (unsafeCoerce ld) el + _ -> EFn.runEffectFn3 Util.unsafeSetAny "listData" (unsafeCoerce ld) props + pure v - diffProp = Fn.mkFn2 \prevEvents events → EFn.mkEffectFn5 \_ _ props v1 v2 → + diffProp = Fn.mkFn3 \prevEvents events listState → EFn.mkEffectFn5 \_ _ props v1 v2 → case v1, v2 of Attribute _ _ val1, Attribute ns2 attr2 val2 → if val1 == val2 @@ -185,6 +207,13 @@ buildProp emit fnObject el = renderProp Ref.write f (snd handler) EFn.runEffectFn3 Util.pokeMutMap ty handler events pure v2 + ListData ld1, ListData ld2 -> do + -- diff; + -- Call parseParams for new props + -- Call removeProp for old props + -- Merge all runInUI props + EFn.runEffectFn6 Util.diffArrayOfObjects fnObject listState el ld1 ld2 props + pure v2 _, _ → pure v2 @@ -194,6 +223,10 @@ buildProp emit fnObject el = renderProp EFn.runEffectFn3 Util.removeAttribute (toNullable ns) attr el Property prop _ → EFn.runEffectFn2 removeProperty prop el + Nopatch prop _ → + EFn.runEffectFn2 removeProperty prop el + ListData _ → + EFn.runEffectFn2 removeProperty "listData" el Handler (DOM.EventType ty) _ → do let handler = Fn.runFn2 Util.unsafeLookup ty prevEvents @@ -213,10 +246,12 @@ propToStrKey = case _ of Attribute (Just (Namespace ns)) attr _ → "attr/" <> ns <> ":" <> attr Attribute _ attr _ → "attr/:" <> attr Property prop _ → "prop/" <> prop + Nopatch prop _ → "prop/" <> prop Handler (DOM.EventType ty) _ → "handler/" <> ty Ref _ → "ref" BHandler ty _ -> "bhandler/" <> ty Payload _ -> "payload" + ListData _ → "prop/listData" setProperty ∷ EFn.EffectFn3 String PropValue DOM.Element Unit setProperty = Util.unsafeSetProp diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index 1753cab..d8b898e 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -105,5 +105,6 @@ type FnObject = , manualEventsName :: Array String , updateMicroAppPayload :: ∀ b. EFn.EffectFn3 String b Boolean Unit , updateProperties :: forall a b. EFn.EffectFn2 a b Unit + , parseParams :: forall a b c d. EFn.EffectFn3 a b c d } diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 92c2598..62f6e85 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -158,6 +158,26 @@ exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) return o2; }; +exports.diffArrayOfObjects = function (fnObject, listState, el, oldArray, newArray, updatedProps) { + // TODO :: Optimise with old Array + list State in the future; + var hasDiff = false + if(oldArray.length != newArray.length) { + hasDiff = true; + } + for(var j = 0; j < newArray.length; ++j) { + for(var key in newArray[j]) { + hasDiff = newArray[j][key] != oldArray[j][key]; + if(hasDiff) + break; + } + if(hasDiff) + break; + } + if(hasDiff) { + updatedProps.listData = newArray + } +} + exports.refEq = function (a, b) { return a === b; }; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 94946b2..09b7f7e 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -17,6 +17,7 @@ module Halogen.VDom.Util , diffWithIxE , diffWithKeyAndIxE , diffPropWithKeyAndIxE + , diffArrayOfObjects , strMapWithIxE , refEq , createTextNode @@ -42,6 +43,7 @@ import Data.Function.Uncurried as Fn import Data.Nullable (Nullable) import Effect (Effect) import Effect.Uncurried as EFn +import Foreign (Foreign) import Foreign.Object (Object) import Foreign.Object as Object import Foreign.Object.ST (STObject) @@ -151,6 +153,18 @@ foreign import diffPropWithKeyAndIxE el (Object.Object c) +foreign import diffArrayOfObjects + ∷ ∀ a b p el + . EFn.EffectFn6 + FnObject + (Object a) + el + (Array (Object p)) + (Array (Object p)) + b + Unit + -- (Array (Object p)) + foreign import strMapWithIxE ∷ ∀ a b c . EFn.EffectFn3 From 4057d5cf9d007d2f0f061197936fec5eb013f2c4 Mon Sep 17 00:00:00 2001 From: George James Date: Mon, 28 Jun 2021 08:31:34 +0530 Subject: [PATCH 35/52] PICAF-5134 :: Fixed usage of effect function for set manual events --- src/Halogen/VDom/Util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 62f6e85..e41eb41 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -275,7 +275,7 @@ exports.addEventListener = function (fnObject, pr, ev, listener, el) { (typeof fnObject.setManualEvents == "function") && (fnObject.manualEventsName.indexOf(ev) != -1) ){ - fnObject.setManualEvents(ev)(listener); + fnObject.setManualEvents(ev)(listener)(); } } catch(err){ console.error("Error while checking for manualEvents \n",err); From 3bac827b88d60bb18b962568a5f8ddb19f038efd Mon Sep 17 00:00:00 2001 From: "Shivam R. Ashtikar" Date: Wed, 15 Apr 2020 06:21:28 +0530 Subject: [PATCH 36/52] PICAF-5134 :: Eq instance for PropValue - in order to compare properties passed, eq instace was required --- bower.json | 2 +- src/Halogen/VDom/DOM/Prop.js | 7 +++++++ src/Halogen/VDom/DOM/Prop.purs | 6 ++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 src/Halogen/VDom/DOM/Prop.js diff --git a/bower.json b/bower.json index 8ad9aba..17a5921 100644 --- a/bower.json +++ b/bower.json @@ -27,7 +27,7 @@ "purescript-effect": "^2.0.0", "purescript-tuples": "^5.0.0", "purescript-web-html": "^1.0.0", - "purescript-foreign-object": "^1", + "purescript-foreign-object": "^2", "purescript-maybe": "^4.0.0", "purescript-unsafe-coerce": "^4.0.0", "purescript-bifunctors": "^4.0.0", diff --git a/src/Halogen/VDom/DOM/Prop.js b/src/Halogen/VDom/DOM/Prop.js new file mode 100644 index 0000000..ad4c447 --- /dev/null +++ b/src/Halogen/VDom/DOM/Prop.js @@ -0,0 +1,7 @@ +"use strict"; + +exports.eqPropValues = function (x) { + return function (y){ + return x == y; + }; +}; diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 149e688..078a5ce 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -58,6 +58,12 @@ instance functorElemRef ∷ Functor ElemRef where foreign import data PropValue ∷ Type +foreign import eqPropValues :: PropValue -> PropValue -> Boolean + +instance eqPropValue :: Eq PropValue where + eq p1 p2 = eqPropValues p1 p2 + + propFromString ∷ String → PropValue propFromString = unsafeCoerce From 00998938dde624b9411a04f2a544be0c50d113db Mon Sep 17 00:00:00 2001 From: George James Date: Wed, 22 Sep 2021 09:24:02 +0530 Subject: [PATCH 37/52] PICAF-5134 :: Fix compilation --- bower.json | 2 +- package.json | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 17a5921..796bb58 100644 --- a/bower.json +++ b/bower.json @@ -27,7 +27,7 @@ "purescript-effect": "^2.0.0", "purescript-tuples": "^5.0.0", "purescript-web-html": "^1.0.0", - "purescript-foreign-object": "^2", + "purescript-foreign-object": "^2.0.3", "purescript-maybe": "^4.0.0", "purescript-unsafe-coerce": "^4.0.0", "purescript-bifunctors": "^4.0.0", diff --git a/package.json b/package.json index 0e745d5..d56baff 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,8 @@ "build": "pulp build -- --censor-lib --strict" }, "devDependencies": { - "pulp": "^12.2.0", - "purescript": "slamdata/node-purescript#0.12", - "purescript-psa": "^0.6.0", + "pulp": "^14", + "purescript": "^0.13.8", "rimraf": "^2.6.2" } } From d9e753edc6eb58e4d8b68fc1a780a33fd4644a20 Mon Sep 17 00:00:00 2001 From: Nandini Singh Date: Wed, 22 Sep 2021 10:50:41 +0530 Subject: [PATCH 38/52] PICAF-4739 sync with master --- src/Halogen/VDom/DOM.purs | 43 +++++++++++++++++++++++++--------- src/Halogen/VDom/DOM/Prop.purs | 1 - src/Halogen/VDom/Types.purs | 9 ++++--- src/Halogen/VDom/Util.purs | 1 - 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index e349fa6..072c861 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -11,7 +11,7 @@ import Prelude import Data.Array as Array import Data.Function.Uncurried as Fn -import Data.Maybe (Maybe(..)) +import Data.Maybe (Maybe(..), fromMaybe) import Data.Nullable (toNullable) import Data.Tuple (Tuple(..), fst) import Effect.Uncurried as EFn @@ -35,6 +35,8 @@ type VDomBuilder i a w = EFn.EffectFn3 (VDomSpec a w) (VDomMachine a w) i (VDomS type VDomBuilder4 i j k l a w = EFn.EffectFn6 (VDomSpec a w) (VDomMachine a w) i j k l (VDomStep a w) +type VDomBuilder5 i j a w ch = EFn.EffectFn5 (VDomSpec a w) (VDomMachine a w) i j ch (VDomStep a w) + type VDomBuilder6 i j a w = EFn.EffectFn4 (VDomSpec a w) (VDomMachine a w) i j (VDomStep a w) -- | Widget machines recursively reference the configured spec to potentially @@ -63,7 +65,7 @@ buildVDom spec = build Keyed ns n a ch → EFn.runEffectFn6 buildKeyed spec build ns n a ch Widget w → EFn.runEffectFn3 buildWidget spec build w Grafted g → EFn.runEffectFn1 build (runGraft g) - Microapp s g → EFn.runEffectFn4 buildMicroapp spec build s g -- TODO fix + Microapp s g ch → EFn.runEffectFn5 buildMicroapp spec build s g ch type MicroAppState a w = { build ∷ VDomMachine a w @@ -72,31 +74,48 @@ type MicroAppState a w = , attrs ∷ Step a Unit , service :: String , payload :: Maybe Foreign + , children :: Array (VDomStep a w) } -buildMicroapp ∷ ∀ a w. VDomBuilder6 String a a w -buildMicroapp = EFn.mkEffectFn4 \(VDomSpec spec) build s as1 → do +buildMicroapp ∷ ∀ a w. VDomBuilder5 String a a w (Maybe (Array (VDom a w))) +buildMicroapp = EFn.mkEffectFn5 \(VDomSpec spec) build s as1 ch → do -- GET ID, SCHEDULE AN AFTER RENDER CALL TO M-APP -- MAYBE ADD A FUNCTION FROM PRESTO_DOM TO SCHEDULE requestId <- Util.generateUUID el ← EFn.runEffectFn3 Util.createMicroapp spec.fnObject requestId s let node = DOMElement.toNode el attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 - let state = { build, node, service: s, attrs, requestId : requestId, payload : Nothing } + let onChild = EFn.mkEffectFn2 \ix child → do + res ← EFn.runEffectFn1 build child + EFn.runEffectFn5 Util.insertChildIx spec.fnObject "render" ix (extract res) node + pure res + children ← EFn.runEffectFn2 Util.forE (fromMaybe [] ch) onChild + let state = { build, node, service: s, attrs, requestId : requestId, payload : Nothing, children } pure $ mkStep $ Step node state (patchMicroapp spec.fnObject) (haltMicroapp spec.fnObject) patchMicroapp ∷ ∀ a w. FnObject -> EFn.EffectFn2 (MicroAppState a w) (VDom a w) (VDomStep a w) patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do - let { build, node, attrs, service: value1, requestId, payload} = state + let { build, node, attrs, service: value1, requestId, payload, children : ch1} = state case vdom of Grafted g → EFn.runEffectFn2 (patchMicroapp fnObject) state (runGraft g) - Microapp s value2 -- CHANGE IN PAYLOAD, NEEDS TO TERMINATE OLD / FIRE EVENT TO OTHER M_APP - | value1 == s → do + Microapp s2 value2 ch2 -- CHANGE IN PAYLOAD, NEEDS TO TERMINATE OLD / FIRE EVENT TO OTHER M_APP + | value1 == s2 → do + let + onThese = EFn.mkEffectFn4 \obj ix s v → do + res ← EFn.runEffectFn2 step s v + EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node + pure res + onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s + onThat = EFn.mkEffectFn3 \obj ix v → do + res ← EFn.runEffectFn1 build v + EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node + pure res + children2 ← EFn.runEffectFn6 Util.diffWithIxE fnObject ch1 (fromMaybe [] ch2) onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs value2 - pure $ mkStep $ Step node (state {attrs = attrs2}) (patchMicroapp fnObject) (haltMicroapp fnObject) + pure $ mkStep $ Step node (state {attrs = attrs2, children= children2}) (patchMicroapp fnObject) (haltMicroapp fnObject) | otherwise → do - -- NOT HANDLED THIS IS DUMMY CODE + -- NOT HANDLED THIS IS DUMMY CODE -- CASE WHERE SERVICE CHANGES IS NOT ACCEPTABLE [FOR NOW] -- DOING NOTHING pure $ mkStep $ Step node state (patchMicroapp fnObject) (haltMicroapp fnObject) @@ -105,9 +124,11 @@ patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do EFn.runEffectFn1 build vdom haltMicroapp ∷ ∀ a w. FnObject -> EFn.EffectFn1 (MicroAppState a w) Unit -haltMicroapp fnObject = EFn.mkEffectFn1 \{ node } → do +haltMicroapp fnObject = EFn.mkEffectFn1 \{ node, attrs, children } → do parent ← EFn.runEffectFn1 Util.parentNode node EFn.runEffectFn3 Util.removeChild fnObject node parent + EFn.runEffectFn2 Util.forEachE children halt + EFn.runEffectFn1 halt attrs type TextState a w = { build ∷ VDomMachine a w diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 078a5ce..d93729c 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -11,7 +11,6 @@ module Halogen.VDom.DOM.Prop import Prelude -import Data.Array import Data.Function.Uncurried as Fn import Data.Maybe (Maybe(..)) import Data.Nullable (toNullable) diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index d8b898e..d7da356 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -14,7 +14,7 @@ import Prelude import Effect (Effect) import Effect.Uncurried as EFn import Data.Bifunctor (class Bifunctor, bimap) -import Data.Maybe (Maybe) +import Data.Maybe (Maybe(..)) import Data.Newtype (class Newtype) import Data.Tuple (Tuple) import Unsafe.Coerce (unsafeCoerce) @@ -31,7 +31,7 @@ data VDom a w | Keyed (Maybe Namespace) ElemName a (Array (Tuple String (VDom a w))) | Widget w | Grafted (Graft a w) - | Microapp String a + | Microapp String a (Maybe (Array (VDom a w))) instance functorVDom ∷ Functor (VDom a) where map g (Text a) = Text a @@ -79,7 +79,10 @@ runGraft = go (Keyed ns n a ch) = Keyed ns n (fa a) (map (map go) ch) go (Widget w) = Widget (fw w) go (Grafted g) = Grafted (bimap fa fw g) - go (Microapp s a) = Microapp s (fa a) + go (Microapp s a child) = Microapp s (fa a) $ + case child of + Just ch -> (Just $ map go ch) + _ -> Nothing in go v diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 09b7f7e..a6c7be2 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -43,7 +43,6 @@ import Data.Function.Uncurried as Fn import Data.Nullable (Nullable) import Effect (Effect) import Effect.Uncurried as EFn -import Foreign (Foreign) import Foreign.Object (Object) import Foreign.Object as Object import Foreign.Object.ST (STObject) From 57687d69b3253793ebedc8c49c4e69681e426e9c Mon Sep 17 00:00:00 2001 From: George James Date: Tue, 5 Oct 2021 13:28:09 +0530 Subject: [PATCH 39/52] PICAF-6839 :: Stop comparison, when lengths are different --- src/Halogen/VDom/Util.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index e41eb41..4bfce53 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -163,15 +163,16 @@ exports.diffArrayOfObjects = function (fnObject, listState, el, oldArray, newArr var hasDiff = false if(oldArray.length != newArray.length) { hasDiff = true; - } - for(var j = 0; j < newArray.length; ++j) { - for(var key in newArray[j]) { - hasDiff = newArray[j][key] != oldArray[j][key]; + } else { + for(var j = 0; j < newArray.length; ++j) { + for(var key in newArray[j]) { + hasDiff = newArray[j][key] != oldArray[j][key]; + if(hasDiff) + break; + } if(hasDiff) break; } - if(hasDiff) - break; } if(hasDiff) { updatedProps.listData = newArray From 6ddde06b6696790fdddd810650e57a15525e8cd0 Mon Sep 17 00:00:00 2001 From: Kartik Gajendra Date: Mon, 22 Nov 2021 16:07:57 +0530 Subject: [PATCH 40/52] PICAF-7147 added support for chunk shimmer layout --- package.json | 4 +- src/Halogen/VDom/DOM.purs | 131 +++++++++++++++++++++++++++++++++++- src/Halogen/VDom/Types.purs | 18 ++++- src/Halogen/VDom/Util.js | 63 +++++++++++++++++ src/Halogen/VDom/Util.purs | 24 ++++++- 5 files changed, 235 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index d56baff..40b8d5f 100644 --- a/package.json +++ b/package.json @@ -3,10 +3,10 @@ "scripts": { "clean": "rimraf output && rimraf", "test": "pulp build -I test -- --censor-lib --strict", - "build": "pulp build -- --censor-lib --strict" + "build": "pulp -w build" }, "devDependencies": { - "pulp": "^14", + "pulp": "^15.0.0", "purescript": "^0.13.8", "rimraf": "^2.6.2" } diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 072c861..f208ade 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -19,11 +19,12 @@ import Foreign (Foreign) import Foreign.Object as Object import Halogen.VDom.Machine (Machine, Step, Step'(..), extract, halt, mkStep, step, unStep) import Halogen.VDom.Machine as Machine -import Halogen.VDom.Types (ElemName(..), FnObject, Namespace(..), VDom(..), runGraft) +import Halogen.VDom.Types (ElemName(..), FnObject, Namespace(..), ShimmerHolder, VDom(..), runGraft) import Halogen.VDom.Util as Util import Web.DOM.Element (Element) as DOM import Web.DOM.Element as DOMElement import Web.DOM.Node (Node) as DOM +import Debug.Trace (spy) type VDomMachine a w = Machine (VDom a w) DOM.Node @@ -62,6 +63,7 @@ buildVDom spec = build build = EFn.mkEffectFn1 case _ of Text s → EFn.runEffectFn3 buildText spec build s Elem ns n a ch → EFn.runEffectFn6 buildElem spec build ns n a ch + Chunk ns n a ch → EFn.runEffectFn6 buildChunk spec build ns n a ch Keyed ns n a ch → EFn.runEffectFn6 buildKeyed spec build ns n a ch Widget w → EFn.runEffectFn3 buildWidget spec build w Grafted g → EFn.runEffectFn1 build (runGraft g) @@ -371,6 +373,102 @@ haltWidget ∷ forall a w. EFn.EffectFn1 (WidgetState a w) Unit haltWidget = EFn.mkEffectFn1 \{ widget } → do EFn.runEffectFn1 halt widget +type ChunkState a w = + { build ∷ VDomMachine a w + , node ∷ DOM.Node + , attrs ∷ Step a Unit + , ns ∷ Maybe Namespace + , name ∷ ElemName + , children ∷ Array ({ shimmer :: VDomStep a w, layout :: VDomStep a w }) + } + +buildChunk ∷ ∀ a w. VDomBuilder4 (Maybe Namespace) ElemName a (ShimmerHolder a w) a w +buildChunk = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do + el ← EFn.runEffectFn3 Util.createChunkedElement spec.fnObject (toNullable ns1) name1 + let + node = DOMElement.toNode el + onChild = EFn.mkEffectFn2 \ix child → do + res1 ← EFn.runEffectFn1 build child.shimmer + res2 ← EFn.runEffectFn1 build child.actualLayout + let res = { shimmer: (extract res1), layout: (extract res2)} + EFn.runEffectFn5 Util.insertChunkIx spec.fnObject "render" ix res node + pure { shimmer: res1, layout: res2 } + children ← EFn.runEffectFn2 Util.forE ch1 onChild + attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 + let + state = + { build + , node + , attrs + , ns: ns1 + , name: name1 + , children + } + pure $ mkStep $ Step node state (patchChunk spec.fnObject) (haltChunk spec.fnObject) + +patchChunk ∷ ∀ a w. FnObject -> EFn.EffectFn2 (ChunkState a w) (VDom a w) (VDomStep a w) +patchChunk fnObject = EFn.mkEffectFn2 \state vdom → do + let { build, node, attrs, ns: ns1, name: name1, children: ch1 } = state + case vdom of + Grafted g → + EFn.runEffectFn2 (patchChunk fnObject) state (runGraft g) + Chunk ns2 name2 as2 ch2 | Fn.runFn4 eqElemSpec ns1 name1 ns2 name2 → do + case Array.length ch1, Array.length ch2 of + 0, 0 → do + attrs2 ← EFn.runEffectFn2 step attrs as2 + let + nextState = + { build + , node + , attrs: attrs2 + , ns: ns2 + , name: name2 + , children: ch1 + } + pure $ mkStep $ Step node nextState (patchChunk fnObject) (haltChunk fnObject) + _, _ → do + let + onThese = EFn.mkEffectFn4 \obj ix s v → do + res1 ← EFn.runEffectFn2 step s v.shimmer + res2 ← EFn.runEffectFn2 step s v.actualLayout + let res = { shimmer: (extract res1), layout: (extract res2) } + EFn.runEffectFn5 Util.insertChunkIx obj "patch" ix res node + pure { shimmer: res1, layout: res2 } + onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s + onThat = EFn.mkEffectFn3 \obj ix v → do + res1 ← EFn.runEffectFn1 build v.shimmer + res2 ← EFn.runEffectFn1 build v.actualLayout + let res = { shimmer: (extract res1), layout: (extract res2)} + EFn.runEffectFn5 Util.insertChunkIx obj "patch" ix res node + pure { shimmer: res1, layout: res2 } + children2 ← EFn.runEffectFn6 Util.diffChunkWithIxE fnObject ch1 ch2 onThese onThis onThat + attrs2 ← EFn.runEffectFn2 step attrs as2 + let + nextState = + { build + , node + , attrs: attrs2 + , ns: ns2 + , name: name2 + , children: children2 + } + pure $ mkStep $ Step node nextState (patchChunk fnObject) (haltChunk fnObject) + _ → do + EFn.runEffectFn1 (haltChunk fnObject) state + EFn.runEffectFn1 build vdom + +haltChunk ∷ ∀ a w. FnObject -> EFn.EffectFn1 (ChunkState a w) Unit +haltChunk fnObject = EFn.mkEffectFn1 \{ node, attrs, children } → do + let _ = spy "haltChunk" children + _ = spy "haltChunk" attrs + _ = spy "haltChunk" node + pure unit + -- parent ← EFn.runEffectFn1 Util.parentNode node + -- EFn.runEffectFn3 Util.removeChild fnObject node parent + -- EFn.runEffectFn2 Util.forEachE children halt + -- EFn.runEffectFn1 halt attrs + + eqElemSpec ∷ Fn.Fn4 (Maybe Namespace) ElemName (Maybe Namespace) ElemName Boolean eqElemSpec = Fn.mkFn4 \ns1 (ElemName name1) ns2 (ElemName name2) → if name1 == name2 @@ -379,3 +477,34 @@ eqElemSpec = Fn.mkFn4 \ns1 (ElemName name1) ns2 (ElemName name2) → Nothing, Nothing → true _, _ → false else false + + +-- var onThis = function (obj, ix, s) { +-- return Halogen_VDom_Machine.halt(s); +-- }; +-- var onThese = function (obj, ix, s, v2) { +-- var v3 = Halogen_VDom_Machine.step(s, v2.shimmer); +-- var v4 = Halogen_VDom_Machine.step(s, v2.actualLayout); +-- var res = { +-- shimmer: Halogen_VDom_Machine.extract(v3), +-- layout: Halogen_VDom_Machine.extract(v4) +-- }; +-- Halogen_VDom_Util.insertChunkIx(obj, "patch", ix, res, state.node); +-- return { +-- shimmer: v3, +-- layout: v4 +-- }; +-- }; +-- var onThat = function (obj, ix, v2) { +-- var v3 = state.build(v2.shimmer); +-- var v4 = state.build(v2.actualLayout); +-- var res = { +-- shimmer: Halogen_VDom_Machine.extract(v3), +-- layout: Halogen_VDom_Machine.extract(v4) +-- }; +-- Halogen_VDom_Util.insertChunkIx(obj, "patch", ix, res, state.node); +-- return { +-- shimmer: v3, +-- layout: v4 +-- }; +-- }; \ No newline at end of file diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index d7da356..c8d6b4d 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -8,6 +8,8 @@ module Halogen.VDom.Types , ElemName(..) , Namespace(..) , FnObject(..) + , ShimmerHolder(..) + , ShimmerItem(..) ) where import Prelude @@ -28,6 +30,7 @@ import Unsafe.Coerce (unsafeCoerce) data VDom a w = Text String | Elem (Maybe Namespace) ElemName a (Array (VDom a w)) + | Chunk (Maybe Namespace) ElemName a (ShimmerHolder a w) | Keyed (Maybe Namespace) ElemName a (Array (Tuple String (VDom a w))) | Widget w | Grafted (Graft a w) @@ -83,9 +86,16 @@ runGraft = case child of Just ch -> (Just $ map go ch) _ -> Nothing + go (Chunk ns n a ch) = Chunk ns n (fa a) (chunkMap go ch) in go v +chunkMap :: forall a a' w w'. (VDom a w -> VDom a' w') -> ShimmerHolder a w -> ShimmerHolder a' w' +chunkMap go shimHolder = map (shimmerItemMap go) shimHolder + +shimmerItemMap :: forall a a' w w'. (VDom a w -> VDom a' w') -> ShimmerItem a w -> ShimmerItem a' w' +shimmerItemMap go item = { shimmer : (go item.shimmer) , actualLayout : (go item.actualLayout) } + newtype ElemName = ElemName String derive instance newtypeElemName ∷ Newtype ElemName _ @@ -98,6 +108,13 @@ derive instance newtypeNamespace ∷ Newtype Namespace _ derive newtype instance eqNamespace ∷ Eq Namespace derive newtype instance ordNamespace ∷ Ord Namespace +type ShimmerHolder a w = Array (ShimmerItem a w) + +type ShimmerItem a w = + { shimmer :: VDom a w + , actualLayout :: VDom a w + } + type FnObject = { replaceView :: forall a . EFn.EffectFn2 a (Array String) Unit , setManualEvents :: forall a b. a -> b -> Effect Unit @@ -110,4 +127,3 @@ type FnObject = , updateProperties :: forall a b. EFn.EffectFn2 a b Unit , parseParams :: forall a b c d. EFn.EffectFn3 a b c d } - diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 4bfce53..43246ec 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -68,6 +68,7 @@ exports.replicateE = function (n, f) { }; exports.diffWithIxE = function (fnObject, a1, a2, f1, f2, f3) { + // console.log("This fails in chunking because:", fnObject, a1, a2, f1, f2, f3); var actions = []; var a3 = []; var l1 = a1.length; @@ -195,11 +196,16 @@ exports.createElement = function (fnObject, ns, name) { return {type: name, children: [], props: {}, __ref: fnObject.createPrestoElement()}; }; +exports.createChunkedElement = function(fnObject, ns, name) { + return {type: name, chunkedLayout: true, children: [], layouts: [], props: {}, __ref: fnObject.createPrestoElement()}; +} + exports.createMicroapp = function (fnObject, requestId, service ) { return {type: "microapp", children: [], props: {}, requestId : requestId, __ref: fnObject.createPrestoElement(), service : service}; }; exports.insertChildIx = function (obj, type, i, a, b) { + // console.log("insertChildIx halogen:", obj, type, i, a, b); var n = (b.children[i]) || {__ref: {__id: "-1"}}; if (!a) console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", b); @@ -226,6 +232,63 @@ exports.insertChildIx = function (obj, type, i, a, b) { a.parentNode = b; }; +exports.insertChunkIx = function(obj, opType, index, child, parentNode) { + console.log("InsertChunkIx halogen:", obj, opType, index, child, parentNode); + var n = (parentNode.children[index]) || {__ref: {__id: "-1"}}; + if (!child) + console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", parentNode); + + if (n === child) { + return; + } + + if (opType !== "patch") { + child.layout.parentNode = child.shimmer.parentNode = parentNode; + parentNode.children.splice(index, 0, child.shimmer); + parentNode.layouts.splice(index, 0, child.layout); + return; + } + debugger; + // no shimmers beyond this point + // treat it like Elem, ignore shimmer + var childPos = parentNode.layouts.findIndex(function(e) { e.__ref.__id === child.layout.__ref.__id }); + if (childPos !== -1) { + parentNode.children.splice(childPos, 1); + obj.push({action : "move", parent : parentNode, elem : child.layout, index : childPos}) + } else { + obj.push({action : "add", parent : parentNode, elem : child.layout, index : childPos}) + } + parentNode.children.splice(index, 0, child.shimmer); + child.layout.parentNode = parentNode; +} + +exports.diffChunkWithIxE = function(fnObject, a1, a2, f1, f2, f3) { + console.log("shimmer chunk:", fnObject, a1, a2, f1, f2, f3); + var actions = []; + var a3 = []; + var l1 = a1.length; + var l2 = a2.length; + var i = 0; + while (1) { + if (i < l1) { + if (i < l2) { + a3.push(f1(actions, i, a1[i].shimmer, a2[i])); + } else { + f2(actions, i, a1[i].shimmer); + } + } else if (i < l2) { + a3.push(f3(actions, i, a2[i])); + } else { + break; + } + i++; + } + if(actions.length > 0) { + fnObject.updateChildren(actions); + } + return a3; +} + exports.removeChild = function (fnObject, a, b) { var childIndex = -1; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index a6c7be2..1236899 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -25,6 +25,7 @@ module Halogen.VDom.Util , createElement , createMicroapp , insertChildIx + , insertChunkIx , generateUUID , removeChild , parentNode @@ -35,6 +36,8 @@ module Halogen.VDom.Util , removeProperty , JsUndefined , jsUndefined + , createChunkedElement + , diffChunkWithIxE ) where import Prelude @@ -47,7 +50,8 @@ import Foreign.Object (Object) import Foreign.Object as Object import Foreign.Object.ST (STObject) import Foreign.Object.ST as STObject -import Halogen.VDom.Types (ElemName, Namespace, FnObject) +import Halogen.VDom.Types (ElemName, FnObject, Namespace, ShimmerHolder, VDom(..)) +import Halogen.VDom.Machine (Step) import Unsafe.Coerce (unsafeCoerce) import Web.DOM.Element (Element) as DOM import Web.DOM.Node (Node) as DOM @@ -152,6 +156,18 @@ foreign import diffPropWithKeyAndIxE el (Object.Object c) +foreign import diffChunkWithIxE + ∷ ∀ a b c d e + . EFn.EffectFn6 + FnObject + (Array b) + (Array c) + (EFn.EffectFn4 a Int e c d) + (EFn.EffectFn3 a Int e Unit) + (EFn.EffectFn3 a Int c d) + (Array d) + + foreign import diffArrayOfObjects ∷ ∀ a b p el . EFn.EffectFn6 @@ -184,6 +200,9 @@ foreign import setTextContent foreign import createElement ∷ EFn.EffectFn3 FnObject (Nullable Namespace) ElemName DOM.Element +foreign import createChunkedElement + ∷ EFn.EffectFn3 FnObject (Nullable Namespace) ElemName DOM.Element + foreign import createMicroapp ∷ EFn.EffectFn3 FnObject String String DOM.Element @@ -192,6 +211,9 @@ foreign import generateUUID :: Effect String foreign import insertChildIx ∷ forall a. EFn.EffectFn5 a String Int DOM.Node DOM.Node Unit +foreign import insertChunkIx + ∷ forall a. EFn.EffectFn5 a String Int ({ shimmer :: DOM.Node, layout :: DOM.Node }) DOM.Node Unit + foreign import removeChild ∷ forall a. EFn.EffectFn3 a DOM.Node DOM.Node Unit From 6c33b5ec29dac3aadc9f37535aa3a57322be6b8e Mon Sep 17 00:00:00 2001 From: Kartik Gajendra Date: Fri, 10 Dec 2021 19:26:22 +0530 Subject: [PATCH 41/52] PICAF-7147 chunking --- src/Halogen/VDom/DOM.purs | 47 ++++----------------------------------- src/Halogen/VDom/Util.js | 20 ++--------------- 2 files changed, 6 insertions(+), 61 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index f208ade..dc442f6 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -24,7 +24,6 @@ import Halogen.VDom.Util as Util import Web.DOM.Element (Element) as DOM import Web.DOM.Element as DOMElement import Web.DOM.Node (Node) as DOM -import Debug.Trace (spy) type VDomMachine a w = Machine (VDom a w) DOM.Node @@ -429,11 +428,11 @@ patchChunk fnObject = EFn.mkEffectFn2 \state vdom → do _, _ → do let onThese = EFn.mkEffectFn4 \obj ix s v → do - res1 ← EFn.runEffectFn2 step s v.shimmer + -- res1 ← EFn.runEffectFn2 step s v.shimmer res2 ← EFn.runEffectFn2 step s v.actualLayout - let res = { shimmer: (extract res1), layout: (extract res2) } + let res = { shimmer: (extract s), layout: (extract res2) } EFn.runEffectFn5 Util.insertChunkIx obj "patch" ix res node - pure { shimmer: res1, layout: res2 } + pure { shimmer: s, layout: res2 } onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn3 \obj ix v → do res1 ← EFn.runEffectFn1 build v.shimmer @@ -459,15 +458,7 @@ patchChunk fnObject = EFn.mkEffectFn2 \state vdom → do haltChunk ∷ ∀ a w. FnObject -> EFn.EffectFn1 (ChunkState a w) Unit haltChunk fnObject = EFn.mkEffectFn1 \{ node, attrs, children } → do - let _ = spy "haltChunk" children - _ = spy "haltChunk" attrs - _ = spy "haltChunk" node pure unit - -- parent ← EFn.runEffectFn1 Util.parentNode node - -- EFn.runEffectFn3 Util.removeChild fnObject node parent - -- EFn.runEffectFn2 Util.forEachE children halt - -- EFn.runEffectFn1 halt attrs - eqElemSpec ∷ Fn.Fn4 (Maybe Namespace) ElemName (Maybe Namespace) ElemName Boolean eqElemSpec = Fn.mkFn4 \ns1 (ElemName name1) ns2 (ElemName name2) → @@ -477,34 +468,4 @@ eqElemSpec = Fn.mkFn4 \ns1 (ElemName name1) ns2 (ElemName name2) → Nothing, Nothing → true _, _ → false else false - - --- var onThis = function (obj, ix, s) { --- return Halogen_VDom_Machine.halt(s); --- }; --- var onThese = function (obj, ix, s, v2) { --- var v3 = Halogen_VDom_Machine.step(s, v2.shimmer); --- var v4 = Halogen_VDom_Machine.step(s, v2.actualLayout); --- var res = { --- shimmer: Halogen_VDom_Machine.extract(v3), --- layout: Halogen_VDom_Machine.extract(v4) --- }; --- Halogen_VDom_Util.insertChunkIx(obj, "patch", ix, res, state.node); --- return { --- shimmer: v3, --- layout: v4 --- }; --- }; --- var onThat = function (obj, ix, v2) { --- var v3 = state.build(v2.shimmer); --- var v4 = state.build(v2.actualLayout); --- var res = { --- shimmer: Halogen_VDom_Machine.extract(v3), --- layout: Halogen_VDom_Machine.extract(v4) --- }; --- Halogen_VDom_Util.insertChunkIx(obj, "patch", ix, res, state.node); --- return { --- shimmer: v3, --- layout: v4 --- }; --- }; \ No newline at end of file + \ No newline at end of file diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 43246ec..90de60d 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -205,7 +205,6 @@ exports.createMicroapp = function (fnObject, requestId, service ) { }; exports.insertChildIx = function (obj, type, i, a, b) { - // console.log("insertChildIx halogen:", obj, type, i, a, b); var n = (b.children[i]) || {__ref: {__id: "-1"}}; if (!a) console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", b); @@ -233,7 +232,6 @@ exports.insertChildIx = function (obj, type, i, a, b) { }; exports.insertChunkIx = function(obj, opType, index, child, parentNode) { - console.log("InsertChunkIx halogen:", obj, opType, index, child, parentNode); var n = (parentNode.children[index]) || {__ref: {__id: "-1"}}; if (!child) console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", parentNode); @@ -241,29 +239,15 @@ exports.insertChunkIx = function(obj, opType, index, child, parentNode) { if (n === child) { return; } - if (opType !== "patch") { child.layout.parentNode = child.shimmer.parentNode = parentNode; parentNode.children.splice(index, 0, child.shimmer); parentNode.layouts.splice(index, 0, child.layout); return; } - debugger; - // no shimmers beyond this point - // treat it like Elem, ignore shimmer - var childPos = parentNode.layouts.findIndex(function(e) { e.__ref.__id === child.layout.__ref.__id }); - if (childPos !== -1) { - parentNode.children.splice(childPos, 1); - obj.push({action : "move", parent : parentNode, elem : child.layout, index : childPos}) - } else { - obj.push({action : "add", parent : parentNode, elem : child.layout, index : childPos}) - } - parentNode.children.splice(index, 0, child.shimmer); - child.layout.parentNode = parentNode; } exports.diffChunkWithIxE = function(fnObject, a1, a2, f1, f2, f3) { - console.log("shimmer chunk:", fnObject, a1, a2, f1, f2, f3); var actions = []; var a3 = []; var l1 = a1.length; @@ -272,9 +256,9 @@ exports.diffChunkWithIxE = function(fnObject, a1, a2, f1, f2, f3) { while (1) { if (i < l1) { if (i < l2) { - a3.push(f1(actions, i, a1[i].shimmer, a2[i])); + a3.push(f1(actions, i, a1[i].layout, a2[i])); } else { - f2(actions, i, a1[i].shimmer); + f2(actions, i, a1[i].layout); } } else if (i < l2) { a3.push(f3(actions, i, a2[i])); From 3033e959a9dc52cf281a8bd838a158500cc3f02a Mon Sep 17 00:00:00 2001 From: Sahaya Gebin Date: Wed, 7 Sep 2022 20:45:16 +0530 Subject: [PATCH 42/52] PICAF-16161 fixed replace view when it both removes and updates props --- src/Halogen/VDom/Util.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 90de60d..4783dd2 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -152,6 +152,9 @@ exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) removedProps.push(k); } if (replace) { + for(var key in updatedProps) { + el.props[key] = updatedProps[key]; + } fnObject.replaceView(el, removedProps); } else if(Object.keys(updatedProps).length > 0) { fnObject.updateProperties(el, updatedProps); From 99b77aefee38a609e07bb2be3b981ec2946054e0 Mon Sep 17 00:00:00 2001 From: Saurav CV Date: Tue, 24 May 2022 17:22:00 +0530 Subject: [PATCH 43/52] PICAF-10982 Halogen changes for vdom caching --- src/Halogen/VDom/DOM.purs | 26 +++++++++++++------------- src/Halogen/VDom/DOM/Prop.purs | 4 ++++ src/Halogen/VDom/Types.purs | 2 +- src/Halogen/VDom/Util.js | 32 +++++++++++++++++++++++--------- src/Halogen/VDom/Util.purs | 4 ++-- 5 files changed, 43 insertions(+), 25 deletions(-) diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index dc442f6..7f077a5 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -88,7 +88,7 @@ buildMicroapp = EFn.mkEffectFn5 \(VDomSpec spec) build s as1 ch → do attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 let onChild = EFn.mkEffectFn2 \ix child → do res ← EFn.runEffectFn1 build child - EFn.runEffectFn5 Util.insertChildIx spec.fnObject "render" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx spec.fnObject "render" ix (extract res) node "" pure res children ← EFn.runEffectFn2 Util.forE (fromMaybe [] ch) onChild let state = { build, node, service: s, attrs, requestId : requestId, payload : Nothing, children } @@ -105,12 +105,12 @@ patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do let onThese = EFn.mkEffectFn4 \obj ix s v → do res ← EFn.runEffectFn2 step s v - EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" pure res onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn3 \obj ix v → do res ← EFn.runEffectFn1 build v - EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" pure res children2 ← EFn.runEffectFn6 Util.diffWithIxE fnObject ch1 (fromMaybe [] ch2) onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs value2 @@ -176,12 +176,12 @@ type ElemState a w = buildElem ∷ ∀ a w. VDomBuilder4 (Maybe Namespace) ElemName a (Array (VDom a w)) a w buildElem = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do - el ← EFn.runEffectFn3 Util.createElement spec.fnObject (toNullable ns1) name1 + el ← EFn.runEffectFn4 Util.createElement spec.fnObject (toNullable ns1) name1 "elem" let node = DOMElement.toNode el onChild = EFn.mkEffectFn2 \ix child → do res ← EFn.runEffectFn1 build child - EFn.runEffectFn5 Util.insertChildIx spec.fnObject "render" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx spec.fnObject "render" ix (extract res) node "" pure res children ← EFn.runEffectFn2 Util.forE ch1 onChild attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 @@ -220,12 +220,12 @@ patchElem fnObject = EFn.mkEffectFn2 \state vdom → do let onThese = EFn.mkEffectFn4 \obj ix s v → do res ← EFn.runEffectFn2 step s v - EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" pure res onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn3 \obj ix v → do res ← EFn.runEffectFn1 build v - EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" pure res children2 ← EFn.runEffectFn6 Util.diffWithIxE fnObject ch1 ch2 onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs as2 @@ -262,12 +262,12 @@ type KeyedState a w = buildKeyed ∷ ∀ a w. VDomBuilder4 (Maybe Namespace) ElemName a (Array (Tuple String (VDom a w))) a w buildKeyed = EFn.mkEffectFn6 \(VDomSpec spec) build ns1 name1 as1 ch1 → do - el ← EFn.runEffectFn3 Util.createElement spec.fnObject (toNullable ns1) name1 + el ← EFn.runEffectFn4 Util.createElement spec.fnObject (toNullable ns1) name1 "keyed" let node = DOMElement.toNode el onChild = EFn.mkEffectFn4 \k ix _ (Tuple _ vdom) → do res ← EFn.runEffectFn1 build vdom - EFn.runEffectFn5 Util.insertChildIx spec.fnObject "render" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx spec.fnObject "render" ix (extract res) node k pure res children ← EFn.runEffectFn3 Util.strMapWithIxE ch1 fst onChild attrs ← EFn.runEffectFn1 (spec.buildAttributes spec.fnObject el) as1 @@ -306,14 +306,14 @@ patchKeyed fnObject = EFn.mkEffectFn2 \state vdom → do pure $ mkStep $ Step node nextState (patchKeyed fnObject) (haltKeyed fnObject) _, len2 → do let - onThese = EFn.mkEffectFn5 \obj _ ix' s (Tuple _ v) → do + onThese = EFn.mkEffectFn5 \obj k ix' s (Tuple _ v) → do res ← EFn.runEffectFn2 step s v - EFn.runEffectFn5 Util.insertChildIx obj "patch" ix' (extract res) node + EFn.runEffectFn6 Util.insertChildIx obj "patch" ix' (extract res) node k pure res onThis = EFn.mkEffectFn3 \obj _ s → EFn.runEffectFn1 halt s - onThat = EFn.mkEffectFn4 \obj _ ix (Tuple _ v) → do + onThat = EFn.mkEffectFn4 \obj k ix (Tuple _ v) → do res ← EFn.runEffectFn1 build v - EFn.runEffectFn5 Util.insertChildIx obj "patch" ix (extract res) node + EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node k pure res children2 ← EFn.runEffectFn7 Util.diffWithKeyAndIxE fnObject ch1 ch2 fst onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs as2 diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index d93729c..0774c52 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -7,6 +7,7 @@ module Halogen.VDom.DOM.Prop , propFromInt , propFromNumber , buildProp + , propFromAny ) where import Prelude @@ -75,6 +76,9 @@ propFromInt = unsafeCoerce propFromNumber ∷ Number → PropValue propFromNumber = unsafeCoerce +propFromAny :: forall a. a -> PropValue +propFromAny = unsafeCoerce + -- | A `Machine`` for applying attributes, properties, and event handlers. -- | An emitter effect must be provided to respond to events. For example, -- | to allow arbitrary effects in event handlers, one could use `id`. diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index c8d6b4d..5aba429 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -116,7 +116,7 @@ type ShimmerItem a w = } type FnObject = - { replaceView :: forall a . EFn.EffectFn2 a (Array String) Unit + { replaceView :: forall a . EFn.EffectFn3 a String (Array String) Unit , setManualEvents :: forall a b. a -> b -> Effect Unit , updateChildren :: forall a. EFn.EffectFn1 a Unit , removeChild :: forall a b. EFn.EffectFn3 a b Int Unit diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 4783dd2..2cc88ae 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -27,7 +27,13 @@ exports.unsafeSetAny = function (key, val, obj) { }; exports.unsafeSetProp = function (key, val, obj) { - obj.props[key] = val; + if(key == "id2"){ + obj.__ref = {__id : val} + obj.props.id = val + delete obj.props.id2 + } else { + obj.props[key] = val; + } }; exports.removeProperty = function (key, val, obj) { @@ -100,6 +106,10 @@ exports.strMapWithIxE = function (as, fk, f) { for (var i = 0; i < as.length; i++) { var a = as[i]; var k = fk(a); + if(k=="prop/id2"){ + f(k,i,m,a) + continue + } o[k] = f(k, i, m, a); } return o; @@ -155,7 +165,7 @@ exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) for(var key in updatedProps) { el.props[key] = updatedProps[key]; } - fnObject.replaceView(el, removedProps); + fnObject.replaceView(el, "", removedProps); } else if(Object.keys(updatedProps).length > 0) { fnObject.updateProperties(el, updatedProps); } @@ -195,8 +205,8 @@ exports.setTextContent = function (s, n) { n.textContent = s; }; -exports.createElement = function (fnObject, ns, name) { - return {type: name, children: [], props: {}, __ref: fnObject.createPrestoElement()}; +exports.createElement = function (fnObject, ns, name, elemType) { + return {type: name, children: [], props: {}, __ref: fnObject.createPrestoElement(), elemType : elemType ? elemType : undefined}; }; exports.createChunkedElement = function(fnObject, ns, name) { @@ -207,7 +217,7 @@ exports.createMicroapp = function (fnObject, requestId, service ) { return {type: "microapp", children: [], props: {}, requestId : requestId, __ref: fnObject.createPrestoElement(), service : service}; }; -exports.insertChildIx = function (obj, type, i, a, b) { +exports.insertChildIx = function (obj, type, i, a, b, keyId) { var n = (b.children[i]) || {__ref: {__id: "-1"}}; if (!a) console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", b); @@ -215,10 +225,14 @@ exports.insertChildIx = function (obj, type, i, a, b) { if (n === a) { return; } - + if(keyId != ""){ + a.keyId = keyId; + } if (type !== "patch") { - a.parentNode = b; - b.children.splice(i, 0, a); + if((!window.parent.generateVdom) || a.elemType == "elem" || a.elemType == "keyed"){ + a.parentNode = b; + b.children.splice(i, 0, a); + } return; } @@ -333,7 +347,7 @@ exports.addEventListener = function (fnObject, pr, ev, listener, el) { } el.props[ev] = listener; if(pr == "patch") { - fnObject.replaceView(el, []); + fnObject.replaceView(el, ev, []); } }; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 1236899..92b086e 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -198,7 +198,7 @@ foreign import setTextContent ∷ EFn.EffectFn2 String DOM.Node Unit foreign import createElement - ∷ EFn.EffectFn3 FnObject (Nullable Namespace) ElemName DOM.Element + ∷ EFn.EffectFn4 FnObject (Nullable Namespace) ElemName String DOM.Element foreign import createChunkedElement ∷ EFn.EffectFn3 FnObject (Nullable Namespace) ElemName DOM.Element @@ -209,7 +209,7 @@ foreign import createMicroapp foreign import generateUUID :: Effect String foreign import insertChildIx - ∷ forall a. EFn.EffectFn5 a String Int DOM.Node DOM.Node Unit + ∷ forall a. EFn.EffectFn6 a String Int DOM.Node DOM.Node String Unit foreign import insertChunkIx ∷ forall a. EFn.EffectFn5 a String Int ({ shimmer :: DOM.Node, layout :: DOM.Node }) DOM.Node Unit From b57530e58f596e0d59865592138e0eaa7073461e Mon Sep 17 00:00:00 2001 From: Shivam Ashtikar Date: Thu, 22 Dec 2022 20:42:22 +0530 Subject: [PATCH 44/52] ci: PICAF-19117: helper tools for version management and Jenkins support --- .gitignore | 5 ++- .husky/commit-msg | 9 +++++ .husky/prepare-commit-msg | 12 ++++++ Jenkinsfile | 53 +++++++++++++++++++++++++++ package.json | 77 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 152 insertions(+), 4 deletions(-) create mode 100755 .husky/commit-msg create mode 100755 .husky/prepare-commit-msg create mode 100644 Jenkinsfile diff --git a/.gitignore b/.gitignore index 8aa76f5..6395167 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -/.* +/.psc-ide-port !/.gitignore !/.eslintrc.json !/.travis.yml @@ -6,4 +6,5 @@ package-lock.json /bower_components/ /node_modules/ /output/ -/**/*.ast \ No newline at end of file +/**/*.ast +/Session.vim diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 0000000..68aaea1 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,9 @@ +#!/bin/sh +. "$(dirname "$0")/_/husky.sh" + +BRANCH_NAME=$(git branch | grep '*' | sed 's/* //') + +if [[ $BRANCH_NAME != *"no branch"* ]] +then + npx --no -- commitlint --edit "${1}" +fi diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg new file mode 100755 index 0000000..ab0fd24 --- /dev/null +++ b/.husky/prepare-commit-msg @@ -0,0 +1,12 @@ +#!/bin/bash + +# Adding hooks to prepare commit message. +# This hook triggers Jira input modules. +# Helps in maintaining code compatblity. + +BRANCH_NAME=$(git branch | grep '*' | sed 's/* //') + +if [[ $BRANCH_NAME != *"no branch"* ]] +then + exec < /dev/tty && node_modules/.bin/git-cz --hook || true +fi diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f709eb7 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,53 @@ +pipeline { + agent { + label "sdk" + } + environment { + NPM_REPO_NAME = "purescript-halogen-vdom" + GIT_AUTHOR_NAME = "Jenkins User" + GIT_AUTHOR_EMAIL = "bitbucket.jenkins.read@juspay.in" + GIT_COMMITTER_NAME = "Jenkins User" + GIT_COMMITTER_EMAIL = "bitbucket.jenkins.read@juspay.in" + + } + + stages { + stage('Checkout') { + steps { + scmSkip(deleteBuild: false, skipPattern:'.*\\[skip ci\\].*') + script { + if (sh(script: "git log -1 --pretty=%B | grep -F -ie '[skip ci]' -e '[ci skip]'", returnStatus: true) == 0) { + currentBuild.result = 'ABORTED' + error 'Aborting because commit message contains [skip ci]' + } + } + } + } + + stage("npm/bower install") { + steps { + script { + sh ("npm config set package-lock=false; npm i") + sh ("bower i") + } + } + } + + stage("PS compilation") { + steps { + script { + // build packages to ensure compilation / tests work fine before updating version + sh ("npm run compile") + } + } + } + + stage("npm release") { + steps { + script { + sh ("npx semantic-release --debug") + } + } + } + } +} diff --git a/package.json b/package.json index 40b8d5f..f9ba76c 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,86 @@ { + "name": "purescript-halogen-vdom", + "version": "1.2.0", "private": true, "scripts": { "clean": "rimraf output && rimraf", "test": "pulp build -I test -- --censor-lib --strict", - "build": "pulp -w build" + "build": "pulp -w build", + "compile": "npx pulp build", + "prepare": "husky install" + }, + "config": { + "commitizen": { + "path": "./node_modules/@digitalroute/cz-conventional-changelog-for-jira", + "jiraPrefix": "PICAF", + "jiraLocation": "post-type", + "jiraAppend": ":" + } + }, + "commitlint": { + "plugins": [ + "commitlint-plugin-jira-rules" + ], + "extends": [ + "jira" + ], + "rules": { + "jira-task-id-max-length": [ + 0 + ], + "jira-commit-message-separator": [ + 0 + ], + "jira-commit-status-case": [ + 0 + ], + "jira-task-id-project-key": [ + 0 + ], + "jira-task-id-separator": [ + 0 + ], + "jira-task-id-case": [ + 0 + ], + "jira-task-id-min-length": [ + 0 + ] + } + }, + "release": { + "branches": [ + "main", + { + "name": "hotfix-[0-9]+.[0-9]+.[0-9]+", + "prerelease": true + } + ], + "repositoryUrl": "git@bitbucket.org:juspay/purescript-halogen-vdom.git", + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/npm", + "@semantic-release/changelog", + "@semantic-release/git" + ] }, "devDependencies": { "pulp": "^15.0.0", "purescript": "^0.13.8", - "rimraf": "^2.6.2" + "rimraf": "^2.6.2", + "@commitlint/cli": "^17.2.0", + "@commitlint/config-conventional": "^17.2.0", + "@digitalroute/cz-conventional-changelog-for-jira": "^7.4.2", + "@semantic-release/changelog": "^6.0.1", + "@semantic-release/commit-analyzer": "^9.0.2", + "@semantic-release/git": "^10.0.1", + "@semantic-release/npm": "^9.0.1", + "@semantic-release/release-notes-generator": "^10.0.3", + "commitlint-config-jira": "^1.6.4", + "commitlint-plugin-jira-rules": "^1.6.4", + "cz-conventional-changelog": "^3.3.0", + "husky": "^8.0.2", + "semantic-release": "^19.0.5" } } From f26a8b8274289ba00134378990597f05c3751aa3 Mon Sep 17 00:00:00 2001 From: anuragdvd Date: Fri, 23 Dec 2022 12:51:51 +0530 Subject: [PATCH 45/52] feat: PICAF-18952: Shifted to PS15 BREAKING CHANGE: Purescript version is changing --- .editorconfig | 13 +++ .eslintrc.json | 32 ++++++++ .gitignore | 2 + .tidyrc.json | 10 +++ bower.json | 25 +++--- package.json | 13 +-- packages.dhall | 105 ++++++++++++++++++++++++ spago.dhall | 21 +++++ src/Halogen/VDom/DOM.purs | 21 +++-- src/Halogen/VDom/DOM/Prop.js | 3 +- src/Halogen/VDom/DOM/Prop.purs | 6 +- src/Halogen/VDom/Thunk.purs | 2 + src/Halogen/VDom/Types.purs | 4 +- src/Halogen/VDom/Util.js | 142 ++++++++++++++++----------------- src/Halogen/VDom/Util.purs | 3 +- test/Main.js | 8 +- 16 files changed, 293 insertions(+), 117 deletions(-) create mode 100644 .editorconfig create mode 100644 .eslintrc.json create mode 100644 .tidyrc.json create mode 100644 packages.dhall create mode 100644 spago.dhall diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..4c69ef2 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,13 @@ +# https://editorconfig.org +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false \ No newline at end of file diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 0000000..61b269c --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,32 @@ +{ + "env": { "browser": true }, + "extends": "eslint:recommended", + "parserOptions": { "ecmaVersion": 2020, "sourceType": "module" }, + "rules": { + "block-scoped-var": "error", + "no-caller": "error", + "no-extra-parens": "off", + "no-extend-native": "error", + "no-loop-func": "error", + "no-new": "error", + "no-return-assign": "error", + "no-sequences": "error", + "no-unused-expressions": "error", + "no-undef": "error", + "no-eq-null": "error", + "indent": ["error", 2, { "SwitchCase": 1 }], + "quotes": ["error", "double"], + "strict": ["error", "global"], + "no-unused-vars": "off", + "no-empty": "off", + "radix": "off", + "no-param-reassign": "off", + "eqeqeq": "off", + "no-bitwise": "off", + "consistent-return": "off", + "guard-for-in": "off", + "no-mixed-spaces-and-tabs": "off", + "no-use-before-define": "off", + "no-dupe-keys": "off" + } +} diff --git a/.gitignore b/.gitignore index 6395167..36ab95b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /.psc-ide-port +!/.editorconfig +!/.tidyrc.json !/.gitignore !/.eslintrc.json !/.travis.yml diff --git a/.tidyrc.json b/.tidyrc.json new file mode 100644 index 0000000..5f6114a --- /dev/null +++ b/.tidyrc.json @@ -0,0 +1,10 @@ +{ + "importSort": "source", + "importWrap": "source", + "indent": 2, + "operatorsFile": null, + "ribbon": 1, + "typeArrowPlacement": "first", + "unicode": "never", + "width": null + } \ No newline at end of file diff --git a/bower.json b/bower.json index 796bb58..9198126 100644 --- a/bower.json +++ b/bower.json @@ -22,20 +22,19 @@ "output" ], "dependencies": { - "purescript-prelude": "^4.0.0", - "purescript-behaviors": "^7.0.0", - "purescript-effect": "^2.0.0", - "purescript-tuples": "^5.0.0", - "purescript-web-html": "^1.0.0", - "purescript-foreign-object": "^2.0.3", - "purescript-maybe": "^4.0.0", - "purescript-unsafe-coerce": "^4.0.0", - "purescript-bifunctors": "^4.0.0", - "purescript-refs": "^4.1.0", - "purescript-foreign": "^5.0.0" + "purescript-prelude": "^6.0.0", + "purescript-effect": "^4.0.0", + "purescript-tuples": "^7.0.0", + "purescript-web-html": "^4.0.0", + "purescript-foreign-object": "^4.0.0", + "purescript-maybe": "^6.0.0", + "purescript-unsafe-coerce": "^6.0.0", + "purescript-bifunctors": "^6.0.0", + "purescript-refs": "^6.0.0", + "purescript-foreign": "^7.0.0" }, "devDependencies": { - "purescript-js-timers": "^4.0.0", - "purescript-exists": "^4.0.0" + "purescript-js-timers": "^6.1.0", + "purescript-exists": "^6.0.0" } } diff --git a/package.json b/package.json index f9ba76c..e3f79f7 100644 --- a/package.json +++ b/package.json @@ -5,8 +5,8 @@ "scripts": { "clean": "rimraf output && rimraf", "test": "pulp build -I test -- --censor-lib --strict", - "build": "pulp -w build", - "compile": "npx pulp build", + "build": "eslint src && pulp -w build", + "compile": "eslint src && npx pulp build", "prepare": "husky install" }, "config": { @@ -66,8 +66,8 @@ ] }, "devDependencies": { - "pulp": "^15.0.0", - "purescript": "^0.13.8", + "pulp": "^16.0.2", + "purescript": "^0.15.6", "rimraf": "^2.6.2", "@commitlint/cli": "^17.2.0", "@commitlint/config-conventional": "^17.2.0", @@ -81,6 +81,9 @@ "commitlint-plugin-jira-rules": "^1.6.4", "cz-conventional-changelog": "^3.3.0", "husky": "^8.0.2", - "semantic-release": "^19.0.5" + "semantic-release": "^19.0.5", + "spago": "^0.20.9", + "eslint": "^8.29.0", + "purescript-psa": "^0.8.2" } } diff --git a/packages.dhall b/packages.dhall new file mode 100644 index 0000000..0fcd980 --- /dev/null +++ b/packages.dhall @@ -0,0 +1,105 @@ +{- +Welcome to your new Dhall package-set! + +Below are instructions for how to edit this file for most use +cases, so that you don't need to know Dhall to use it. + +## Use Cases + +Most will want to do one or both of these options: +1. Override/Patch a package's dependency +2. Add a package not already in the default package set + +This file will continue to work whether you use one or both options. +Instructions for each option are explained below. + +### Overriding/Patching a package + +Purpose: +- Change a package's dependency to a newer/older release than the + default package set's release +- Use your own modified version of some dependency that may + include new API, changed API, removed API by + using your custom git repo of the library rather than + the package set's repo + +Syntax: +where `entityName` is one of the following: +- dependencies +- repo +- version +------------------------------- +let upstream = -- +in upstream + with packageName.entityName = "new value" +------------------------------- + +Example: +------------------------------- +let upstream = -- +in upstream + with halogen.version = "master" + with halogen.repo = "https://example.com/path/to/git/repo.git" + + with halogen-vdom.version = "v4.0.0" + with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies +------------------------------- + +### Additions + +Purpose: +- Add packages that aren't already included in the default package set + +Syntax: +where `` is: +- a tag (i.e. "v4.0.0") +- a branch (i.e. "master") +- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977") +------------------------------- +let upstream = -- +in upstream + with new-package-name = + { dependencies = + [ "dependency1" + , "dependency2" + ] + , repo = + "https://example.com/path/to/git/repo.git" + , version = + "" + } +------------------------------- + +Example: +------------------------------- +let upstream = -- +in upstream + with benchotron = + { dependencies = + [ "arrays" + , "exists" + , "profunctor" + , "strings" + , "quickcheck" + , "lcg" + , "transformers" + , "foldable-traversable" + , "exceptions" + , "node-fs" + , "node-buffer" + , "node-readline" + , "datetime" + , "now" + ] + , repo = + "https://github.com/hdgarrood/purescript-benchotron.git" + , version = + "v7.0.0" + } +------------------------------- +-} +let upstream = + https://github.com/purescript/package-sets/releases/download/psc-0.15.3/packages.dhall + sha256:ffc496e19c93f211b990f52e63e8c16f31273d4369dbae37c7cf6ea852d4442f + +in upstream diff --git a/spago.dhall b/spago.dhall new file mode 100644 index 0000000..48cee96 --- /dev/null +++ b/spago.dhall @@ -0,0 +1,21 @@ +{ name = "halogen-vdom" +, dependencies = + [ "effect" + , "prelude" + , "foreign-object" + , "arrays" + , "bifunctors" + , "foreign" + , "functions" + , "maybe" + , "newtype" + , "nullable" + , "refs" + , "tuples" + , "unsafe-coerce" + , "web-dom" + , "web-events" + ] +, packages = ./packages.dhall +, sources = [ "src/**/*.purs" ] +} diff --git a/src/Halogen/VDom/DOM.purs b/src/Halogen/VDom/DOM.purs index 7f077a5..9be92f3 100644 --- a/src/Halogen/VDom/DOM.purs +++ b/src/Halogen/VDom/DOM.purs @@ -96,7 +96,7 @@ buildMicroapp = EFn.mkEffectFn5 \(VDomSpec spec) build s as1 ch → do patchMicroapp ∷ ∀ a w. FnObject -> EFn.EffectFn2 (MicroAppState a w) (VDom a w) (VDomStep a w) patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do - let { build, node, attrs, service: value1, requestId, payload, children : ch1} = state + let { build, node, attrs, service: value1, children : ch1} = state case vdom of Grafted g → EFn.runEffectFn2 (patchMicroapp fnObject) state (runGraft g) @@ -107,7 +107,7 @@ patchMicroapp fnObject = EFn.mkEffectFn2 \state vdom → do res ← EFn.runEffectFn2 step s v EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" pure res - onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s + onThis = EFn.mkEffectFn3 \_ _ s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn3 \obj ix v → do res ← EFn.runEffectFn1 build v EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" @@ -222,7 +222,7 @@ patchElem fnObject = EFn.mkEffectFn2 \state vdom → do res ← EFn.runEffectFn2 step s v EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" pure res - onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s + onThis = EFn.mkEffectFn3 \_ _ s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn3 \obj ix v → do res ← EFn.runEffectFn1 build v EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node "" @@ -310,7 +310,7 @@ patchKeyed fnObject = EFn.mkEffectFn2 \state vdom → do res ← EFn.runEffectFn2 step s v EFn.runEffectFn6 Util.insertChildIx obj "patch" ix' (extract res) node k pure res - onThis = EFn.mkEffectFn3 \obj _ s → EFn.runEffectFn1 halt s + onThis = EFn.mkEffectFn3 \_ _ s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn4 \obj k ix (Tuple _ v) → do res ← EFn.runEffectFn1 build v EFn.runEffectFn6 Util.insertChildIx obj "patch" ix (extract res) node k @@ -348,7 +348,7 @@ buildWidget ∷ ∀ a w. VDomBuilder w a w buildWidget = EFn.mkEffectFn3 \(VDomSpec spec) build w → do res ← EFn.runEffectFn1 (spec.buildWidget (VDomSpec spec)) w let - res' = res # unStep \(Step n s k1 k2) → + res' = res # unStep \(Step n _ _ _) → mkStep $ Step n { build, widget: res } patchWidget haltWidget pure res' @@ -361,7 +361,7 @@ patchWidget = EFn.mkEffectFn2 \state vdom → do Widget w → do res ← EFn.runEffectFn2 step widget w let - res' = res # unStep \(Step n s k1 k2) → + res' = res # unStep \(Step n _ _ _) → mkStep $ Step n { build, widget: res } patchWidget haltWidget pure res' _ → do @@ -433,13 +433,13 @@ patchChunk fnObject = EFn.mkEffectFn2 \state vdom → do let res = { shimmer: (extract s), layout: (extract res2) } EFn.runEffectFn5 Util.insertChunkIx obj "patch" ix res node pure { shimmer: s, layout: res2 } - onThis = EFn.mkEffectFn3 \obj ix s → EFn.runEffectFn1 halt s + onThis = EFn.mkEffectFn3 \_ _ s → EFn.runEffectFn1 halt s onThat = EFn.mkEffectFn3 \obj ix v → do res1 ← EFn.runEffectFn1 build v.shimmer res2 ← EFn.runEffectFn1 build v.actualLayout - let res = { shimmer: (extract res1), layout: (extract res2)} + let res = { shimmer: (extract res1), layout: (extract res2)} EFn.runEffectFn5 Util.insertChunkIx obj "patch" ix res node - pure { shimmer: res1, layout: res2 } + pure { shimmer: res1, layout: res2 } children2 ← EFn.runEffectFn6 Util.diffChunkWithIxE fnObject ch1 ch2 onThese onThis onThat attrs2 ← EFn.runEffectFn2 step attrs as2 let @@ -457,7 +457,7 @@ patchChunk fnObject = EFn.mkEffectFn2 \state vdom → do EFn.runEffectFn1 build vdom haltChunk ∷ ∀ a w. FnObject -> EFn.EffectFn1 (ChunkState a w) Unit -haltChunk fnObject = EFn.mkEffectFn1 \{ node, attrs, children } → do +haltChunk _ = EFn.mkEffectFn1 \_ → do pure unit eqElemSpec ∷ Fn.Fn4 (Maybe Namespace) ElemName (Maybe Namespace) ElemName Boolean @@ -468,4 +468,3 @@ eqElemSpec = Fn.mkFn4 \ns1 (ElemName name1) ns2 (ElemName name2) → Nothing, Nothing → true _, _ → false else false - \ No newline at end of file diff --git a/src/Halogen/VDom/DOM/Prop.js b/src/Halogen/VDom/DOM/Prop.js index ad4c447..b19e38e 100644 --- a/src/Halogen/VDom/DOM/Prop.js +++ b/src/Halogen/VDom/DOM/Prop.js @@ -1,6 +1,5 @@ -"use strict"; -exports.eqPropValues = function (x) { +export const eqPropValues = function (x) { return function (y){ return x == y; }; diff --git a/src/Halogen/VDom/DOM/Prop.purs b/src/Halogen/VDom/DOM/Prop.purs index 0774c52..668a967 100644 --- a/src/Halogen/VDom/DOM/Prop.purs +++ b/src/Halogen/VDom/DOM/Prop.purs @@ -46,7 +46,7 @@ data Prop a instance functorProp ∷ Functor Prop where map f (Handler ty g) = Handler ty (map f <$> g) map f (Ref g) = Ref (map f <$> g) - map f p = unsafeCoerce p + map _ p = unsafeCoerce p data ElemRef a = Created a @@ -92,7 +92,7 @@ buildProp emit fnObject el = renderProp where renderProp = EFn.mkEffectFn1 \ps1 → do events ← Util.newMutMap - props ← Util.newMutMap + _ ← Util.newMutMap listData ← Util.newMutMap ps1' ← EFn.runEffectFn3 Util.strMapWithIxE ps1 propToStrKey (applyProp "render" events) let @@ -160,7 +160,7 @@ buildProp emit fnObject el = renderProp Ref f → do EFn.runEffectFn1 mbEmit (f (Created el)) pure v - BHandler ty behavior → do + BHandler _ behavior → do EFn.runEffectFn1 mbEmit (behavior unit) pure v Payload payload -> do diff --git a/src/Halogen/VDom/Thunk.purs b/src/Halogen/VDom/Thunk.purs index c12a3f7..748d888 100644 --- a/src/Halogen/VDom/Thunk.purs +++ b/src/Halogen/VDom/Thunk.purs @@ -27,6 +27,7 @@ foreign import data ThunkArg ∷ Type foreign import data ThunkId ∷ Type +data Thunk :: forall k. (k -> Type) -> k -> Type data Thunk f i = Thunk ThunkId (Fn.Fn2 ThunkArg ThunkArg Boolean) (ThunkArg → f i) ThunkArg unsafeThunkId ∷ ∀ a. a → ThunkId @@ -86,6 +87,7 @@ unsafeEqThunk = Fn.mkFn2 \(Thunk a1 b1 _ d1) (Thunk a2 b2 _ d2) → Fn.runFn2 Util.refEq b1 b2 && Fn.runFn2 Util.refEq d1 d2 +type ThunkState :: forall k. (k -> Type) -> k -> Type -> Type -> Type type ThunkState f i a w = { thunk ∷ Thunk f i , vdom ∷ M.Step (V.VDom a w) Node diff --git a/src/Halogen/VDom/Types.purs b/src/Halogen/VDom/Types.purs index 5aba429..0c4c243 100644 --- a/src/Halogen/VDom/Types.purs +++ b/src/Halogen/VDom/Types.purs @@ -37,12 +37,12 @@ data VDom a w | Microapp String a (Maybe (Array (VDom a w))) instance functorVDom ∷ Functor (VDom a) where - map g (Text a) = Text a + map _ (Text a) = Text a map g (Grafted a) = Grafted (map g a) map g a = Grafted (graft (Graft identity g a)) instance bifunctorVDom ∷ Bifunctor VDom where - bimap f g (Text a) = Text a + bimap _ _ (Text a) = Text a bimap f g (Grafted a) = Grafted (bimap f g a) bimap f g a = Grafted (graft (Graft f g a)) diff --git a/src/Halogen/VDom/Util.js b/src/Halogen/VDom/Util.js index 2cc88ae..4913154 100644 --- a/src/Halogen/VDom/Util.js +++ b/src/Halogen/VDom/Util.js @@ -1,51 +1,40 @@ -"use strict"; - -// removeEventListener -// removeAttribute -// removeProperty -// pokeMutMap -// addEventListener -// setAttribute - - -exports.unsafeGetAny = function (key, obj) { +export const unsafeGetAny = function (key, obj) { return obj[key]; }; -exports.unsafeGetProp = function (key, obj) { +export const unsafeGetProp = function (key, obj) { if (obj.props) return obj.props[key]; - else return; }; -exports.unsafeHasAny = function (key, obj) { - return obj.hasOwnProperty(key); +export const unsafeHasAny = function (key, obj) { + return Object.prototype.hasOwnProperty.call(obj,key); }; -exports.unsafeSetAny = function (key, val, obj) { - obj[key] = val; +export const unsafeSetAny = function (key, val, obj) { + obj[key] = val; }; -exports.unsafeSetProp = function (key, val, obj) { +export const unsafeSetProp = function (key, val, obj) { if(key == "id2"){ - obj.__ref = {__id : val} - obj.props.id = val - delete obj.props.id2 + obj.__ref = {__id : val}; + obj.props.id = val; + delete obj.props.id2; } else { obj.props[key] = val; } }; -exports.removeProperty = function (key, val, obj) { +export const removeProperty = function (key, val, obj) { obj.props[key] = val; delete obj.props[key]; }; -exports.unsafeDeleteAny = function (key, obj) { +export const unsafeDeleteAny = function (key, obj) { delete obj.props[key]; }; -exports.forE = function (a, f) { +export const forE = function (a, f) { var b = []; for (var i = 0; i < a.length; i++) { b.push(f(i, a[i])); @@ -53,13 +42,13 @@ exports.forE = function (a, f) { return b; }; -exports.forEachE = function (a, f) { +export const forEachE = function (a, f) { for (var i = 0; i < a.length; i++) { f(a[i]); } }; -exports.forInE = function (o, f) { +export const forInE = function (o, f) { var ks = Object.keys(o); for (var i = 0; i < ks.length; i++) { var k = ks[i]; @@ -67,19 +56,20 @@ exports.forInE = function (o, f) { } }; -exports.replicateE = function (n, f) { +export const replicateE = function (n, f) { for (var i = 0; i < n; i++) { f(); } }; -exports.diffWithIxE = function (fnObject, a1, a2, f1, f2, f3) { +export const diffWithIxE = function (fnObject, a1, a2, f1, f2, f3) { // console.log("This fails in chunking because:", fnObject, a1, a2, f1, f2, f3); var actions = []; var a3 = []; var l1 = a1.length; var l2 = a2.length; var i = 0; + // eslint-disable-next-line no-constant-condition while (1) { if (i < l1) { if (i < l2) { @@ -100,28 +90,28 @@ exports.diffWithIxE = function (fnObject, a1, a2, f1, f2, f3) { return a3; }; -exports.strMapWithIxE = function (as, fk, f) { +export const strMapWithIxE = function (as, fk, f) { var o = {}; var m = {}; for (var i = 0; i < as.length; i++) { var a = as[i]; var k = fk(a); if(k=="prop/id2"){ - f(k,i,m,a) - continue + f(k,i,m,a); + continue; } o[k] = f(k, i, m, a); } return o; }; -exports.diffWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3) { +export const diffWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3) { var o2 = {}; var actions = []; for (var i = 0; i < as.length; i++) { var a = as[i]; - var k = fk(a); - if (o1.hasOwnProperty(k)) { + let k = fk(a); + if (Object.prototype.hasOwnProperty.call(o1,k)) { o2[k] = f1(actions, k, i, o1[k], a); } else { o2[k] = f3(actions, k, i, a); @@ -139,15 +129,15 @@ exports.diffWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3) { return o2; }; -exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) { +export const diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) { var removedProps = []; var o2 = {}; - var updatedProps = {} + var updatedProps = {}; var replace = false; for (var i = 0; i < as.length; i++) { var a = as[i]; - var k = fk(a); - if (o1.hasOwnProperty(k)) { + let k = fk(a); + if (Object.prototype.hasOwnProperty.call(o1,k)) { o2[k] = f1(k, i, updatedProps, o1[k], a); } else { o2[k] = f3(k, i, updatedProps, a); @@ -172,9 +162,9 @@ exports.diffPropWithKeyAndIxE = function (fnObject, o1, as, fk, f1, f2, f3, el) return o2; }; -exports.diffArrayOfObjects = function (fnObject, listState, el, oldArray, newArray, updatedProps) { +export const diffArrayOfObjects = function (fnObject, listState, el, oldArray, newArray, updatedProps) { // TODO :: Optimise with old Array + list State in the future; - var hasDiff = false + var hasDiff = false; if(oldArray.length != newArray.length) { hasDiff = true; } else { @@ -189,37 +179,38 @@ exports.diffArrayOfObjects = function (fnObject, listState, el, oldArray, newArr } } if(hasDiff) { - updatedProps.listData = newArray + updatedProps.listData = newArray; } -} +}; -exports.refEq = function (a, b) { +export const refEq = function (a, b) { return a === b; }; -exports.createTextNode = function (s) { - return {type: "textView", children: [], props: {text: s}} +export const createTextNode = function (s) { + return {type: "textView", children: [], props: {text: s}}; }; -exports.setTextContent = function (s, n) { +export const setTextContent = function (s, n) { n.textContent = s; }; -exports.createElement = function (fnObject, ns, name, elemType) { +export const createElement = function (fnObject, ns, name, elemType) { return {type: name, children: [], props: {}, __ref: fnObject.createPrestoElement(), elemType : elemType ? elemType : undefined}; }; -exports.createChunkedElement = function(fnObject, ns, name) { +export const createChunkedElement = function(fnObject, ns, name) { return {type: name, chunkedLayout: true, children: [], layouts: [], props: {}, __ref: fnObject.createPrestoElement()}; -} +}; -exports.createMicroapp = function (fnObject, requestId, service ) { +export const createMicroapp = function (fnObject, requestId, service ) { return {type: "microapp", children: [], props: {}, requestId : requestId, __ref: fnObject.createPrestoElement(), service : service}; }; -exports.insertChildIx = function (obj, type, i, a, b, keyId) { +export const insertChildIx = function (obj, type, i, a, b, keyId) { var n = (b.children[i]) || {__ref: {__id: "-1"}}; if (!a) + // eslint-disable-next-line no-undef console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", b); if (n === a) { @@ -240,17 +231,18 @@ exports.insertChildIx = function (obj, type, i, a, b, keyId) { var index = b.children.indexOf(a); if (index !== -1) { b.children.splice(index, 1); - obj.push({action : "move", parent : b, elem : a, index : i}) + obj.push({action : "move", parent : b, elem : a, index : i}); } else { - obj.push({action : "add", parent : b, elem : a, index : i}) + obj.push({action : "add", parent : b, elem : a, index : i}); } b.children.splice(i, 0, a); a.parentNode = b; }; -exports.insertChunkIx = function(obj, opType, index, child, parentNode) { +export const insertChunkIx = function(obj, opType, index, child, parentNode) { var n = (parentNode.children[index]) || {__ref: {__id: "-1"}}; if (!child) + // eslint-disable-next-line no-undef console.warn("CUSTOM VDOM ERROR !! : ", "Trying to add undefined element to ", parentNode); if (n === child) { @@ -262,14 +254,15 @@ exports.insertChunkIx = function(obj, opType, index, child, parentNode) { parentNode.layouts.splice(index, 0, child.layout); return; } -} +}; -exports.diffChunkWithIxE = function(fnObject, a1, a2, f1, f2, f3) { +export const diffChunkWithIxE = function(fnObject, a1, a2, f1, f2, f3) { var actions = []; var a3 = []; var l1 = a1.length; var l2 = a2.length; var i = 0; + // eslint-disable-next-line no-constant-condition while (1) { if (i < l1) { if (i < l2) { @@ -288,9 +281,9 @@ exports.diffChunkWithIxE = function(fnObject, a1, a2, f1, f2, f3) { fnObject.updateChildren(actions); } return a3; -} +}; -exports.removeChild = function (fnObject, a, b) { +export const removeChild = function (fnObject, a, b) { var childIndex = -1; if (b && a.parentNode.__ref.__id === b.__ref.__id) { @@ -308,7 +301,7 @@ exports.removeChild = function (fnObject, a, b) { } }; -exports.parentNode = function (a) { +export const parentNode = function (a) { if (a.parentNode.props.__removed) { a.props.__removed = true; return null; @@ -317,23 +310,23 @@ exports.parentNode = function (a) { } }; -exports.setAttribute = function (ns, attr, val, el) { - if (ns != null) { +export const setAttribute = function (ns, attr, val, el) { + if (ns !== null) { el.setAttributeNS(ns, attr, val); } else { el.setAttribute(attr, val); } }; -exports.removeAttribute = function (ns, attr, el) { - if (ns != null) { +export const removeAttribute = function (ns, attr, el) { + if (ns !== null) { el.removeAttributeNS(ns, attr); } else { el.removeAttribute(attr); } }; -exports.addEventListener = function (fnObject, pr, ev, listener, el) { +export const addEventListener = function (fnObject, pr, ev, listener, el) { try{ if((typeof fnObject.manualEventsName != "undefined") && (Array.isArray(fnObject.manualEventsName)) && @@ -343,6 +336,7 @@ exports.addEventListener = function (fnObject, pr, ev, listener, el) { fnObject.setManualEvents(ev)(listener)(); } } catch(err){ + // eslint-disable-next-line no-undef console.error("Error while checking for manualEvents \n",err); } el.props[ev] = listener; @@ -351,19 +345,17 @@ exports.addEventListener = function (fnObject, pr, ev, listener, el) { } }; -exports.removeEventListener = function (ev, listener, el) { - // el.removeEventListener(ev, listener, false); - delete el.props[ev]; +export const removeEventListener = function (ev, listener, el) { + // el.removeEventListener(ev, listener, false); + delete el.props[ev]; }; -exports.jsUndefined = void 0; +export const jsUndefined = void 0; -exports.generateUUID = function() { +export const generateUUID = function() { function s4() { - return Math.floor((1 + Math.random()) * 0x10000) - .toString(16) - .substring(1); + return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1); } - return s4() + s4() + '-' + s4() + '-' + s4() + '-' + - s4() + '-' + s4() + s4() + s4(); -} \ No newline at end of file + return s4() + s4() + "-" + s4() + "-" + s4() + "-" + + s4() + "-" + s4() + s4() + s4(); +}; diff --git a/src/Halogen/VDom/Util.purs b/src/Halogen/VDom/Util.purs index 92b086e..f7167dc 100644 --- a/src/Halogen/VDom/Util.purs +++ b/src/Halogen/VDom/Util.purs @@ -50,8 +50,7 @@ import Foreign.Object (Object) import Foreign.Object as Object import Foreign.Object.ST (STObject) import Foreign.Object.ST as STObject -import Halogen.VDom.Types (ElemName, FnObject, Namespace, ShimmerHolder, VDom(..)) -import Halogen.VDom.Machine (Step) +import Halogen.VDom.Types (ElemName, FnObject, Namespace) import Unsafe.Coerce (unsafeCoerce) import Web.DOM.Element (Element) as DOM import Web.DOM.Node (Node) as DOM diff --git a/test/Main.js b/test/Main.js index 9a3b245..68951b5 100644 --- a/test/Main.js +++ b/test/Main.js @@ -1,16 +1,16 @@ -exports.getData = function () { +export const getData = function () { return ENV.generateData().toArray(); }; -exports.getTimeout = function () { +export const getTimeout = function () { return ENV.timeout }; -exports.pingRenderRate = function () { +export const pingRenderRate = function () { Monitoring.renderRate.ping(); }; -exports.requestAnimationFrame = function (f) { +export const requestAnimationFrame = function (f) { return function () { window.requestAnimationFrame(function () { f(); From ac3847ab463db17d988ccbaaf98d36fae29495b9 Mon Sep 17 00:00:00 2001 From: Jenkins User Date: Fri, 23 Dec 2022 11:17:50 +0000 Subject: [PATCH 46/52] chore(release): 3.0.0 [skip ci] # [3.0.0](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v2.0.1...v3.0.0) (2022-12-23) ### Features * PICAF-18952: Shifted to PS15 ([f26a8b8](https://bitbucket.org/juspay/purescript-halogen-vdom/commits/f26a8b8274289ba00134378990597f05c3751aa3)) ### BREAKING CHANGES * Purescript version is changing --- CHANGELOG.md | 11 +++++++++++ package.json | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9949089 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,11 @@ +# [3.0.0](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v2.0.1...v3.0.0) (2022-12-23) + + +### Features + +* PICAF-18952: Shifted to PS15 ([f26a8b8](https://bitbucket.org/juspay/purescript-halogen-vdom/commits/f26a8b8274289ba00134378990597f05c3751aa3)) + + +### BREAKING CHANGES + +* Purescript version is changing diff --git a/package.json b/package.json index e3f79f7..a5b4595 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "purescript-halogen-vdom", - "version": "1.2.0", + "version": "3.0.0", "private": true, "scripts": { "clean": "rimraf output && rimraf", From b0aa98593d7e23d5e608ad11b90f42d6935f74b6 Mon Sep 17 00:00:00 2001 From: avinash_juspay Date: Mon, 26 Dec 2022 20:04:22 +0530 Subject: [PATCH 47/52] fix: PICAF-19117: adding branch rule to jenkins With this change. We can enable compilation on all PR. And we would know about compilation status before merging PR. --- .gitignore | 1 + Jenkinsfile | 12 +++++++++--- package.json | 7 ++++--- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 36ab95b..c943339 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ package-lock.json /output/ /**/*.ast /Session.vim +/.spago \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile index f709eb7..13d869e 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,3 +1,7 @@ +def isVersionBumpCandidateBranch(branch) { + (branch =~ /(main|hotfix-)/) +} + pipeline { agent { label "sdk" @@ -24,11 +28,11 @@ pipeline { } } - stage("npm/bower install") { + stage("npm/spago install") { steps { script { sh ("npm config set package-lock=false; npm i") - sh ("bower i") + sh ("npm run spago:install") } } } @@ -45,7 +49,9 @@ pipeline { stage("npm release") { steps { script { - sh ("npx semantic-release --debug") + if (isVersionBumpCandidateBranch(env.BRANCH_NAME)) { + sh ("npx semantic-release --debug") + } } } } diff --git a/package.json b/package.json index a5b4595..5b72c90 100644 --- a/package.json +++ b/package.json @@ -4,9 +4,10 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf", - "test": "pulp build -I test -- --censor-lib --strict", - "build": "eslint src && pulp -w build", - "compile": "eslint src && npx pulp build", + "start": "spago build -w --before 'npm run eslint'", + "eslint": "eslint src", + "compile": "eslint src && spago build", + "spago:install": "spago install", "prepare": "husky install" }, "config": { From 14201f08dd6f770cd8ecd5c8fd51fc02404c0c8e Mon Sep 17 00:00:00 2001 From: Jenkins User Date: Tue, 27 Dec 2022 06:04:08 +0000 Subject: [PATCH 48/52] chore(release): 3.0.1 [skip ci] ## [3.0.1](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v3.0.0...v3.0.1) (2022-12-27) ### Bug Fixes * PICAF-19117: adding branch rule to jenkins ([b0aa985](https://bitbucket.org/juspay/purescript-halogen-vdom/commits/b0aa98593d7e23d5e608ad11b90f42d6935f74b6)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9949089..e007524 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.0.1](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v3.0.0...v3.0.1) (2022-12-27) + + +### Bug Fixes + +* PICAF-19117: adding branch rule to jenkins ([b0aa985](https://bitbucket.org/juspay/purescript-halogen-vdom/commits/b0aa98593d7e23d5e608ad11b90f42d6935f74b6)) + # [3.0.0](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v2.0.1...v3.0.0) (2022-12-23) diff --git a/package.json b/package.json index 5b72c90..ec082c8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "purescript-halogen-vdom", - "version": "3.0.0", + "version": "3.0.1", "private": true, "scripts": { "clean": "rimraf output && rimraf", From ad1d72e254c25928f66fc8f049669362dadce519 Mon Sep 17 00:00:00 2001 From: anuragdvd Date: Mon, 2 Jan 2023 21:53:17 +0530 Subject: [PATCH 49/52] fix: PICAF-18952: Updating es-lint rules and adding eslint:fix --- .eslintrc.json | 5 +++-- package.json | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 61b269c..da4accb 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -1,7 +1,7 @@ { - "env": { "browser": true }, + "env": { "browser": true, "es2015": true }, "extends": "eslint:recommended", - "parserOptions": { "ecmaVersion": 2020, "sourceType": "module" }, + "parserOptions": { "ecmaVersion": 2015, "sourceType": "module" }, "rules": { "block-scoped-var": "error", "no-caller": "error", @@ -11,6 +11,7 @@ "no-new": "error", "no-return-assign": "error", "no-sequences": "error", + "no-shadow": "error", "no-unused-expressions": "error", "no-undef": "error", "no-eq-null": "error", diff --git a/package.json b/package.json index ec082c8..bc547c0 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,12 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf", - "start": "spago build -w --before 'npm run eslint'", + "start": "spago build -w --before 'npm run eslint' --purs-args '--censor-lib --strict'", "eslint": "eslint src", - "compile": "eslint src && spago build", + "compile": "eslint src && spago build --purs-args '--censor-lib --strict'", "spago:install": "spago install", - "prepare": "husky install" + "prepare": "husky install", + "eslint:fix": "eslint src --fix" }, "config": { "commitizen": { From 3130c5780b9c775d05aa01ad79176bd5a28c0401 Mon Sep 17 00:00:00 2001 From: Jenkins User Date: Thu, 5 Jan 2023 10:46:00 +0000 Subject: [PATCH 50/52] chore(release): 3.0.2 [skip ci] ## [3.0.2](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v3.0.1...v3.0.2) (2023-01-05) ### Bug Fixes * PICAF-18952: Updating es-lint rules and adding eslint:fix ([ad1d72e](https://bitbucket.org/juspay/purescript-halogen-vdom/commits/ad1d72e254c25928f66fc8f049669362dadce519)) --- CHANGELOG.md | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e007524..a83b991 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## [3.0.2](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v3.0.1...v3.0.2) (2023-01-05) + + +### Bug Fixes + +* PICAF-18952: Updating es-lint rules and adding eslint:fix ([ad1d72e](https://bitbucket.org/juspay/purescript-halogen-vdom/commits/ad1d72e254c25928f66fc8f049669362dadce519)) + ## [3.0.1](https://bitbucket.org/juspay/purescript-halogen-vdom/compare/v3.0.0...v3.0.1) (2022-12-27) diff --git a/package.json b/package.json index bc547c0..f59b975 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "purescript-halogen-vdom", - "version": "3.0.1", + "version": "3.0.2", "private": true, "scripts": { "clean": "rimraf output && rimraf", From 62e0624d401b43e4098233f2d1f5a75681ef1429 Mon Sep 17 00:00:00 2001 From: Shivam Ashtikar Date: Mon, 23 Jan 2023 18:44:12 +0530 Subject: [PATCH 51/52] chore: PICAF-19932: updating urls to Juspay Bitbucket server url --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f59b975..5bae6d2 100644 --- a/package.json +++ b/package.json @@ -58,7 +58,7 @@ "prerelease": true } ], - "repositoryUrl": "git@bitbucket.org:juspay/purescript-halogen-vdom.git", + "repositoryUrl": "git@ssh.bitbucket.juspay.net:picaf/purescript-halogen-vdom.git", "plugins": [ "@semantic-release/commit-analyzer", "@semantic-release/release-notes-generator", From a5c668e622e39c3e1172af2d8120c3ed10fa2024 Mon Sep 17 00:00:00 2001 From: Shivam Ashtikar Date: Tue, 24 Jan 2023 13:45:33 +0530 Subject: [PATCH 52/52] chore: PICAF-19932: updating Git credentials in Jenkinsfile --- Jenkinsfile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 13d869e..3e3039a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -8,10 +8,12 @@ pipeline { } environment { NPM_REPO_NAME = "purescript-halogen-vdom" - GIT_AUTHOR_NAME = "Jenkins User" - GIT_AUTHOR_EMAIL = "bitbucket.jenkins.read@juspay.in" - GIT_COMMITTER_NAME = "Jenkins User" - GIT_COMMITTER_EMAIL = "bitbucket.jenkins.read@juspay.in" + GIT_AUTHOR_NAME = 'jenkins.user' + GIT_AUTHOR_EMAIL = 'jenkins.user@juspay.in' + GIT_COMMITTER_NAME = 'jenkins.user' + GIT_COMMITTER_EMAIL = 'jenkins.user@juspay.in' + GIT_USERNAME = 'jenkins.user' + GIT_EMAIL = 'jenkins.user@juspay.in' }