Skip to content

Commit b9d25c6

Browse files
Update to PureScript v0.15.0 (#15)
* Migrated FFI to ES modules via 'lebab' * Replaced 'export var' with 'export const' * Removed '"use strict";' in FFI files * Update to CI to use 'unstable' purescript * Update Bower dependencies to master or main * Update pulp to 16.0.0-0 * Update psa to 0.8.2 * Update .eslintrc.json to ES6 * Added changelog entry * Update CI to use node 14 * Fix unused name warning * Try to fix node test * Fix Test.Main import * Revert import order back to original * Use async import before running tests `global` isn't assigned until all modules are imprted By wrapping it in an async/await block, we defer importing Test.Main until after XPathResult hsa been defined
1 parent c15b740 commit b9d25c6

File tree

10 files changed

+62
-61
lines changed

10 files changed

+62
-61
lines changed

.eslintrc.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"parserOptions": {
3-
"ecmaVersion": 5
3+
"ecmaVersion": 6,
4+
"sourceType": "module"
45
},
56
"extends": "eslint:recommended",
67
"env": {
7-
"commonjs": true,
88
"browser": true
99
},
1010
"rules": {

.github/workflows/ci.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ jobs:
1313
- uses: actions/checkout@v2
1414

1515
- uses: purescript-contrib/setup-purescript@main
16+
with:
17+
purescript: "unstable"
1618

17-
- uses: actions/setup-node@v1
19+
- uses: actions/setup-node@v2
1820
with:
19-
node-version: "10"
21+
node-version: "14"
2022

2123
- name: Install dependencies
2224
run: |

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Notable changes to this project are documented in this file. The format is based
55
## [Unreleased]
66

77
Breaking changes:
8+
- Migrate FFI to ES modules (#15 by @JordanMartinez)
89

910
New features:
1011

bower.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"package.json"
1616
],
1717
"dependencies": {
18-
"purescript-web-dom": "^5.0.0"
18+
"purescript-web-dom": "master"
1919
},
2020
"devDependencies": {
21-
"purescript-aff": "^6.0.0",
22-
"purescript-assert": "^5.0.0",
23-
"purescript-console": "^5.0.0",
24-
"purescript-foreign": "^6.0.0",
25-
"purescript-web-dom-parser": "^7.0.0"
21+
"purescript-aff": "main",
22+
"purescript-assert": "master",
23+
"purescript-console": "master",
24+
"purescript-foreign": "master",
25+
"purescript-web-dom-parser": "master"
2626
}
2727
}

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
"scripts": {
55
"clean": "rimraf output && rimraf .pulp-cache",
66
"build": "eslint src && pulp build -- --censor-lib --strict",
7-
"test": "eslint src && pulp build -I \"test\" -- --censor-lib && node test/node.js",
7+
"test": "eslint src && pulp build -I \"test\" -- --censor-lib && node test/node.mjs",
88
"testbrowser": "./scripts/testbrowser"
99
},
1010
"devDependencies": {
1111
"eslint": "^7.15.0",
1212
"jsdom": "^16.4.0",
1313
"parcel-bundler": "^1.12.4",
14-
"pulp": "^15.0.0",
15-
"purescript-psa": "^0.8.0",
14+
"pulp": "16.0.0-0",
15+
"purescript-psa": "^0.8.2",
1616
"rimraf": "^3.0.2"
1717
}
1818
}

src/Web/DOM/XPath.js

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"use strict";
2-
3-
exports.evaluateInternal = function (xpathExpression) {
1+
export function evaluateInternal(xpathExpression) {
42
return function (contextNode) {
53
return function (namespaceResolver) {
64
return function (resultType) {
@@ -20,83 +18,82 @@ exports.evaluateInternal = function (xpathExpression) {
2018
};
2119
};
2220
};
23-
};
24-
21+
}
2522

2623
// --- XPathResult functions ---
2724

28-
exports.resultType = function (xpathResult) {
25+
export function resultType(xpathResult) {
2926
return xpathResult.resultType;
30-
};
27+
}
3128

32-
exports.numberValue = function (xpathResult) {
29+
export function numberValue(xpathResult) {
3330
return function () { // Effect thunk
3431
return xpathResult.numberValue;
3532
};
36-
};
33+
}
3734

38-
exports.stringValue = function (xpathResult) {
35+
export function stringValue(xpathResult) {
3936
return function () { // Effect thunk
4037
return xpathResult.stringValue;
4138
};
42-
};
39+
}
4340

44-
exports.booleanValue = function (xpathResult) {
41+
export function booleanValue(xpathResult) {
4542
return function () { // Effect thunk
4643
return xpathResult.booleanValue;
4744
};
48-
};
45+
}
4946

50-
exports.singleNodeValueInternal = function (xpathResult) {
47+
export function singleNodeValueInternal(xpathResult) {
5148
return function () { // Effect thunk
5249
return xpathResult.singleNodeValue;
5350
};
54-
};
51+
}
5552

56-
exports.invalidIteratorState = function (xpathResult) {
53+
export function invalidIteratorState(xpathResult) {
5754
return xpathResult.invalidIteratorState;
58-
};
55+
}
5956

60-
exports.snapshotLengthInternal = function (xpathResult) {
57+
export function snapshotLengthInternal(xpathResult) {
6158
return function () { // Effect thunk
6259
return xpathResult.snapshotLength;
6360
};
64-
};
61+
}
6562

66-
exports.iterateNextInternal = function (xpathResult) {
63+
export function iterateNextInternal(xpathResult) {
6764
return function () { // Effect thunk
6865
return xpathResult.iterateNext();
6966
};
70-
};
67+
}
7168

72-
exports.snapshotItemInternal = function (xpathResult) {
69+
export function snapshotItemInternal(xpathResult) {
7370
return function (index) {
7471
return function () { // Effect thunk
7572
return xpathResult.snapshotItem(index);
7673
};
7774
};
78-
};
75+
}
7976

8077
// --- namespace resolver functions ---
8178

82-
exports.customNSResolver = function (customRes) {
79+
export function customNSResolver(customRes) {
8380
var nsResolver = {
8481
lookupNamespaceURI : customRes
8582
};
8683
return nsResolver;
87-
};
84+
}
8885

89-
exports.createNSResolver = function (nodeResolver) {
86+
export function createNSResolver(nodeResolver) {
9087
return function (doc) {
9188
return doc.createNSResolver(nodeResolver);
9289
};
93-
};
90+
}
9491

95-
exports.lookupNamespaceURIInternal = function (nsResolver) {
92+
export function lookupNamespaceURIInternal(nsResolver) {
9693
return function (prefix) {
9794
return nsResolver.lookupNamespaceURI(prefix);
9895
};
99-
};
96+
}
10097

10198
// exports._makeEmptyDoc = function () { // Effect thunk
10299
// var doc = (new DOMParser()).parseFromString('<dummy/>', 'application/xml');

src/Web/DOM/XPath/ResultType.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
"use strict";
2-
3-
exports.any_type = XPathResult.ANY_TYPE;
4-
exports.number_type = XPathResult.NUMBER_TYPE;
5-
exports.string_type = XPathResult.STRING_TYPE;
6-
exports.boolean_type = XPathResult.BOOLEAN_TYPE;
7-
exports.unordered_node_iterator_type = XPathResult.UNORDERED_NODE_ITERATOR_TYPE;
8-
exports.ordered_node_iterator_type = XPathResult.ORDERED_NODE_ITERATOR_TYPE;
9-
exports.unordered_node_snapshot_type = XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE;
10-
exports.ordered_node_snapshot_type = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
11-
exports.any_unordered_node_type = XPathResult.ANY_UNORDERED_NODE_TYPE;
12-
exports.first_ordered_node_type = XPathResult.FIRST_ORDERED_NODE_TYPE;
1+
export const any_type = XPathResult.ANY_TYPE;
2+
export const number_type = XPathResult.NUMBER_TYPE;
3+
export const string_type = XPathResult.STRING_TYPE;
4+
export const boolean_type = XPathResult.BOOLEAN_TYPE;
5+
export const unordered_node_iterator_type = XPathResult.UNORDERED_NODE_ITERATOR_TYPE;
6+
export const ordered_node_iterator_type = XPathResult.ORDERED_NODE_ITERATOR_TYPE;
7+
export const unordered_node_snapshot_type = XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE;
8+
export const ordered_node_snapshot_type = XPathResult.ORDERED_NODE_SNAPSHOT_TYPE;
9+
export const any_unordered_node_type = XPathResult.ANY_UNORDERED_NODE_TYPE;
10+
export const first_ordered_node_type = XPathResult.FIRST_ORDERED_NODE_TYPE;
1311

test/Main.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ main { browser } = launchAff_ $ flip runReaderT "" do
169169
test "NS resolver construction" do
170170
domParser <- liftEffect $ makeDOMParser
171171

172-
customRes <- pure $ XP.customNSResolver (\x -> "http://foo.com")
172+
customRes <- pure $ XP.customNSResolver (\_ -> "http://foo.com")
173173

174174
assertFalse "custom NS resolver shouldn't be undefined"
175175
(isUndefined $ unsafeToForeign customRes)

test/node.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/node.mjs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import {JSDOM} from "jsdom";
2+
const { XPathResult, DOMParser } = new JSDOM().window;
3+
4+
Object.assign(global, { XPathResult, DOMParser });
5+
6+
(async () => {
7+
const { main } = await import("../output/Test.Main/index.js");
8+
main({ browser: false })();
9+
})();

0 commit comments

Comments
 (0)