Skip to content

Commit 27113d1

Browse files
committed
Migrate to Spec
1 parent 48c87c9 commit 27113d1

File tree

20 files changed

+375
-371
lines changed

20 files changed

+375
-371
lines changed

packages.dhall

+2-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ let additions =
117117
-------------------------------
118118
-}
119119
let upstream =
120-
https://github.com/purescript/package-sets/releases/download/psc-0.14.5-20220203/packages.dhall sha256:f8905bf5d7ce9d886cf4ef1c5893ab55de0b30c82c2b4137f272d075000fbc50
120+
https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220504/packages.dhall
121+
sha256:fd37736ecaa24491c907af6a6422156417f21fbf25763de19f65bd641e8340d3
121122

122123
let overrides = {=}
123124

spago.dhall

+1-2
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,10 @@ You can edit this file as you like.
2424
, "nullable"
2525
, "partial"
2626
, "prelude"
27-
, "psci-support"
2827
, "random"
2928
, "refs"
3029
, "strings"
31-
, "test-unit"
30+
, "spec"
3231
, "tuples"
3332
, "typelevel-prelude"
3433
, "unsafe-coerce"

src/Flame/Application/Effectful.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
exports.unsafeMergeFields = function (model) {
1+
export function unsafeMergeFields(model) {
22
return function (subset) {
33
let copy = {};
44

src/Flame/Application/Internal/Dom.js

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11

2-
exports.querySelector_ = function (selector) {
2+
export function querySelector_(selector) {
33
return document.querySelector(selector);
4-
};
4+
}
55

6-
exports.textContent_ = function (element) {
6+
export function textContent_(element) {
77
return element.textContent || '';
8-
};
8+
}
99

10-
exports.removeElement_ = function (selector) {
10+
export function removeElement_(selector) {
1111
document.querySelector(selector).remove();
12-
};
12+
}
1313

14-
exports.createWindowListener_ = function (eventName, updater) {
14+
export function createWindowListener_(eventName, updater) {
1515
window.addEventListener(eventName, function(event) {
1616
updater(event)();
1717
});
18-
};
18+
}
1919

20-
exports.createDocumentListener_ = function (eventName, updater) {
20+
export function createDocumentListener_(eventName, updater) {
2121
document.addEventListener(eventName, function(event) {
2222
updater(event)();
2323
});
24-
};
24+
}
2525

26-
exports.createCustomListener_ = function (eventName, updater) {
26+
export function createCustomListener_(eventName, updater) {
2727
document.addEventListener(eventName, function (event) {
2828
updater(event.detail)();
2929
});
30-
};
30+
}
3131

32-
exports.dispatchCustomEvent_ = function(eventName, payload) {
32+
export function dispatchCustomEvent_(eventName, payload) {
3333
document.dispatchEvent(new CustomEvent(eventName, { detail: payload } ));
3434
}

src/Flame/Application/Internal/PreMount.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ let textNode = 1,
44
fragmentNode = 4,
55
lazyNode = 5;
66

7-
exports.injectState = function (stateHtml) {
7+
export function injectState(stateHtml) {
88
return function (html) {
99
return injectTo(stateHtml, html);
1010
};
11-
};
11+
}
1212

1313
function injectTo(stateHtml, html) {
1414
switch (html.nodeType) {
@@ -43,5 +43,5 @@ function injectTo(stateHtml, html) {
4343

4444
return html;
4545
}
46-
};
46+
}
4747

src/Flame/Html/Attribute/Event.js

+14-14
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,46 @@
33
let messageEventData = 5,
44
rawEventData = 6;
55

6-
exports.createEvent_ = function (name) {
6+
export function createEvent_(name) {
77
return function (message) {
88
return [messageEventData, name, message];
99
};
10-
};
10+
}
1111

12-
exports.createRawEvent_ = function (name) {
12+
export function createRawEvent_(name) {
1313
return function (handler) {
1414
return [rawEventData, name, handler];
1515
};
16-
};
16+
}
1717

18-
exports.nodeValue_ = function (event) {
18+
export function nodeValue_(event) {
1919
if (event.target.contentEditable === true || event.target.contentEditable === "true" || event.target.contentEditable === "")
2020
return event.target.innerText;
2121

2222
return event.target.value;
23-
};
23+
}
2424

25-
exports.checkedValue_ = function (event) {
25+
export function checkedValue_(event) {
2626
if (event.target.tagName === "INPUT" && (event.target.type === "checkbox" || event.target.type === "radio"))
2727
return event.target.checked;
2828

2929
return false;
30-
};
30+
}
3131

32-
exports.preventDefault_ = function (event) {
32+
export function preventDefault_(event) {
3333
event.preventDefault();
34-
};
34+
}
3535

36-
exports.key_ = function (event) {
36+
export function key_(event) {
3737
if (event.type === "keyup" || event.type === "keydown" || event.type === "keypress")
3838
return event.key;
3939

4040
return "";
41-
};
41+
}
4242

43-
exports.selection_ = function (event) {
43+
export function selection_(event) {
4444
if (event.target.tagName === "INPUT" && event.target.type == "text" || event.target.tagName === "TEXTAREA")
4545
return event.target.value.substring(event.target.selectionStart, event.target.selectionEnd);
4646

4747
return "";
48-
};
48+
}

src/Flame/Html/Attribute/Internal.js

+10-10
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ let styleData = 1,
66
attributeData = 4,
77
keyData = 7;
88

9-
exports.createProperty_ = function (name) {
9+
export function createProperty_(name) {
1010
return function (value) {
1111
return [propertyData, name, value];
1212
};
13-
};
13+
}
1414

15-
exports.createAttribute_ = function (name) {
15+
export function createAttribute_(name) {
1616
return function (value) {
1717
return [attributeData, name, value];
1818
};
19-
};
19+
}
2020

21-
exports.createClass = function (array) {
21+
export function createClass(array) {
2222
return [classData, array];
23-
};
23+
}
2424

25-
exports.createStyle = function (object) {
25+
export function createStyle(object) {
2626
return [styleData, object];
27-
};
27+
}
2828

29-
exports.createKey = function (value) {
29+
export function createKey(value) {
3030
return [keyData, value];
31-
};
31+
}

src/Flame/Html/Element.js

+24-24
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ let styleData = 1,
1010
attributeData = 4,
1111
keyData = 7;
1212

13-
exports.createElementNode = function (tag) {
13+
export function createElementNode(tag) {
1414
return function (nodeData) {
1515
return function (potentialChildren) {
1616
let children = potentialChildren,
@@ -31,9 +31,9 @@ exports.createElementNode = function (tag) {
3131
};
3232
};
3333
};
34-
};
34+
}
3535

36-
exports.createDatalessElementNode = function (tag) {
36+
export function createDatalessElementNode(tag) {
3737
return function (potentialChildren) {
3838
let children = potentialChildren,
3939
text = undefined;
@@ -52,9 +52,9 @@ exports.createDatalessElementNode = function (tag) {
5252
text: text
5353
};
5454
};
55-
};
55+
}
5656

57-
exports.createSingleElementNode = function (tag) {
57+
export function createSingleElementNode(tag) {
5858
return function (nodeData) {
5959
return {
6060
nodeType: elementNode,
@@ -63,34 +63,34 @@ exports.createSingleElementNode = function (tag) {
6363
nodeData: fromNodeData(nodeData)
6464
};
6565
};
66-
};
66+
}
6767

68-
exports.createEmptyElement = function (tag) {
68+
export function createEmptyElement(tag) {
6969
return {
7070
nodeType: tag.trim().toLowerCase() === 'svg' ? svgNode : elementNode,
7171
node: undefined,
7272
tag: tag,
7373
nodeData: {}
7474
};
75-
};
75+
}
7676

77-
exports.createFragmentNode = function (children) {
77+
export function createFragmentNode(children) {
7878
return {
7979
nodeType: fragmentNode,
8080
node: undefined,
8181
children: children
8282
};
83-
};
83+
}
8484

85-
exports.text = function (value) {
85+
export function text(value) {
8686
return {
8787
nodeType: textNode,
8888
node: undefined,
8989
text: value
9090
};
91-
};
91+
}
9292

93-
exports.createLazyNode = function (nodeData) {
93+
export function createLazyNode(nodeData) {
9494
return function (render) {
9595
return function (arg) {
9696
let key = nodeData[0];
@@ -105,9 +105,9 @@ exports.createLazyNode = function (nodeData) {
105105
};
106106
};
107107
};
108-
};
108+
}
109109

110-
exports.createManagedNode = function (render) {
110+
export function createManagedNode(render) {
111111
return function (nodeData) {
112112
return function (arg) {
113113
return {
@@ -120,9 +120,9 @@ exports.createManagedNode = function (render) {
120120
};
121121
};
122122
};
123-
};
123+
}
124124

125-
exports.createDatalessManagedNode = function (render) {
125+
export function createDatalessManagedNode(render) {
126126
return function (arg) {
127127
return {
128128
nodeType: managedNode,
@@ -133,9 +133,9 @@ exports.createDatalessManagedNode = function (render) {
133133
arg: arg
134134
};
135135
};
136-
};
136+
}
137137

138-
exports.createSvgNode = function (nodeData) {
138+
export function createSvgNode(nodeData) {
139139
return function (children) {
140140
return {
141141
nodeType: svgNode,
@@ -145,26 +145,26 @@ exports.createSvgNode = function (nodeData) {
145145
children: asSvg(children)
146146
};
147147
};
148-
};
148+
}
149149

150-
exports.createDatalessSvgNode = function (children) {
150+
export function createDatalessSvgNode(children) {
151151
return {
152152
nodeType: svgNode,
153153
node: undefined,
154154
tag: 'svg',
155155
nodeData: {},
156156
children: asSvg(children)
157157
};
158-
};
158+
}
159159

160-
exports.createSingleSvgNode = function (nodeData) {
160+
export function createSingleSvgNode(nodeData) {
161161
return {
162162
nodeType: svgNode,
163163
node: undefined,
164164
tag: 'svg',
165165
nodeData: fromNodeData(nodeData)
166166
};
167-
};
167+
}
168168

169169
function asSvg(elements) {
170170
for (let e of elements) {

src/Flame/Internal/Equality.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
exports.compareReference_ = function (a) {
1+
export function compareReference_(a) {
22
return function (b) {
33
return a === b;
44
};
5-
};
5+
}

src/Flame/Renderer/Internal/Dom.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ let textNode = 1,
1212
//these events cannot be synthetic
1313
let nonBubblingEvents = ["focus", "blur", "scroll"];
1414

15-
exports.start_ = function (eventWrapper, root, updater, html) {
15+
export function start_(eventWrapper, root, updater, html) {
1616
return new F(eventWrapper, root, updater, html, false);
17-
};
17+
}
1818

19-
exports.startFrom_ = function (eventWrapper, root, updater, html) {
19+
export function startFrom_(eventWrapper, root, updater, html) {
2020
return new F(eventWrapper, root, updater, html, true);
21-
};
21+
}
2222

23-
exports.resume_ = function (f, html) {
23+
export function resume_(f, html) {
2424
f.resume(html);
25-
};
25+
}
2626

2727
/** Class to scope application data since a document can have many mount points */
2828
function F(eventWrapper, root, updater, html, isDry) {

src/Flame/Renderer/String.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ let booleanAttributes = new Set([
110110
]);
111111

112112
/** String rendering adapted from https://github.com/snabbdom/snabbdom-to-html */
113-
exports.render_ = stringify;
113+
export {stringify as render_};
114114

115115
function stringify(html) {
116116
switch (html.nodeType) {
@@ -156,7 +156,7 @@ function stringify(html) {
156156

157157
return markup.join('');
158158
}
159-
};
159+
}
160160

161161
function stringifyNodeData(nodeData) {
162162
let result = [],

0 commit comments

Comments
 (0)