Skip to content

Commit d5acece

Browse files
Update to PureScript v0.15.0 (#185)
1 parent dc20cc0 commit d5acece

12 files changed

+95
-99
lines changed

.eslintrc.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
2-
"env": { "commonjs": true },
32
"extends": "eslint:recommended",
4-
"parserOptions": { "ecmaVersion": 5 },
3+
"parserOptions": { "ecmaVersion": 6, "sourceType": "module" },
54
"rules": {
65
"block-scoped-var": "error",
76
"consistent-return": "error",

.github/workflows/ci.yml

+12-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
- name: Set up PureScript toolchain
1717
uses: purescript-contrib/setup-purescript@main
1818
with:
19+
purescript: "unstable"
1920
purs-tidy: "latest"
2021

2122
- name: Cache PureScript dependencies
@@ -49,8 +50,17 @@ jobs:
4950
- name: Build the project
5051
run: npm run build
5152

52-
- name: Run tests
53-
run: npm run test
53+
# - name: Run tests
54+
# run: npm run test
5455

5556
- name: Check formatting
5657
run: purs-tidy check src test
58+
59+
- name: Verify Bower & Pulp
60+
run: |
61+
npm install bower [email protected]
62+
npx bower install
63+
npx pulp build -- --censor-lib --strict
64+
if [ -d "test" ]; then
65+
npx pulp test
66+
fi

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ 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 (#185 by @JordanMartinez)
9+
- Replaced polymorphic proxies with monomorphic `Proxy` (#185 by @JordanMartinez)
810

911
New features:
1012

bower.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@
1717
"url": "https://github.com/purescript-contrib/purescript-react.git"
1818
},
1919
"dependencies": {
20-
"purescript-effect": "^3.0.0",
21-
"purescript-exceptions": "^5.0.0",
22-
"purescript-maybe": "^5.0.0",
23-
"purescript-nullable": "^5.0.0",
24-
"purescript-prelude": "^5.0.0",
25-
"purescript-typelevel-prelude": "^6.0.0",
26-
"purescript-unsafe-coerce": "^5.0.0"
20+
"purescript-effect": "master",
21+
"purescript-exceptions": "master",
22+
"purescript-maybe": "master",
23+
"purescript-nullable": "main",
24+
"purescript-prelude": "master",
25+
"purescript-typelevel-prelude": "master",
26+
"purescript-unsafe-coerce": "master"
2727
},
2828
"devDependencies": {
29-
"purescript-console": "^5.0.0"
29+
"purescript-console": "master"
3030
}
3131
}

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@
66
},
77
"devDependencies": {
88
"eslint": "^7.10.0",
9-
"purescript-psa": "^0.8.0"
9+
"purescript-psa": "^0.8.2"
1010
}
1111
}

packages.dhall

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
let upstream =
2-
https://github.com/purescript/package-sets/releases/download/psc-0.14.3-20210722/packages.dhall sha256:1ceb43aa59436bf5601bac45f6f3781c4e1f0e4c2b8458105b018e5ed8c30f8c
2+
https://raw.githubusercontent.com/purescript/package-sets/prepare-0.15/src/packages.dhall
33

44
in upstream

spago.dhall

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
, "maybe"
77
, "nullable"
88
, "prelude"
9-
, "psci-support"
109
, "typelevel-prelude"
1110
, "unsafe-coerce"
1211
]

src/React.js

+42-46
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,40 @@
1-
/* global exports */
2-
"use strict";
3-
4-
var React = require("react");
1+
import React from "react";
52

63
function createClass(baseClass) {
74
function bindProperty(instance, prop, value) {
85
switch (prop) {
9-
case 'state':
10-
case 'render':
11-
case 'componentDidMount':
12-
case 'componentWillUnmount':
6+
case "state":
7+
case "render":
8+
case "componentDidMount":
9+
case "componentWillUnmount":
1310
instance[prop] = value;
1411
break;
1512

16-
case 'componentDidCatch':
17-
case 'componentWillUpdate':
18-
case 'shouldComponentUpdate':
19-
case 'getSnapshotBeforeUpdate':
13+
case "componentDidCatch":
14+
case "componentWillUpdate":
15+
case "shouldComponentUpdate":
16+
case "getSnapshotBeforeUpdate":
2017
instance[prop] = function (a, b) { return value(a)(b)(); };
2118
break;
2219

23-
case 'componentDidUpdate':
20+
case "componentDidUpdate":
2421
instance[prop] = function (a, b, c) { return value(a)(b)(c)(); };
2522
break;
2623

27-
case 'unsafeComponentWillMount':
28-
instance['UNSAFE_componentWillMount'] = value;
24+
case "unsafeComponentWillMount":
25+
instance["UNSAFE_componentWillMount"] = value;
2926
break;
3027

31-
case 'unsafeComponentWillReceiveProps':
32-
instance['UNSAFE_componentWillReceiveProps'] = function (a) { return value(a)(); };
28+
case "unsafeComponentWillReceiveProps":
29+
instance["UNSAFE_componentWillReceiveProps"] = function (a) { return value(a)(); };
3330
break;
3431

35-
case 'unsafeComponentWillUpdate':
36-
instance['UNSAFE_componentWillUpdate'] = function (a, b) { return value(a)(b)(); };
32+
case "unsafeComponentWillUpdate":
33+
instance["UNSAFE_componentWillUpdate"] = function (a, b) { return value(a)(b)(); };
3734
break;
3835

3936
default:
40-
throw new Error('[purescript-react] Not a component property: ' + prop);
37+
throw new Error("[purescript-react] Not a component property: " + prop);
4138
}
4239
}
4340

@@ -46,6 +43,7 @@ function createClass(baseClass) {
4643
var Constructor = function (props) {
4744
baseClass.call(this, props);
4845
var spec = ctrFn(this)();
46+
// eslint-disable-next-line guard-for-in
4947
for (var k in spec) {
5048
bindProperty(this, k, spec[k]);
5149
}
@@ -60,6 +58,10 @@ function createClass(baseClass) {
6058
};
6159
}
6260

61+
var componentImpl = createClass(React.Component);
62+
export {componentImpl};
63+
64+
// eslint-disable-next-line no-unused-vars
6365
function createClassWithDerivedState(classCtr) {
6466
return function(displayName) {
6567
return function(getDerivedStateFromProps) {
@@ -72,28 +74,22 @@ function createClassWithDerivedState(classCtr) {
7274
};
7375
}
7476

75-
var componentImpl = createClass(React.Component);
76-
exports.componentImpl = componentImpl;
77-
exports.componentWithDerivedStateImpl = createClassWithDerivedState(componentImpl);
77+
export const componentWithDerivedStateImpl = createClassWithDerivedState(componentImpl);
7878

7979
var pureComponentImpl = createClass(React.PureComponent);
80-
exports.pureComponentImpl = pureComponentImpl;
81-
exports.pureComponentWithDerivedStateImpl = createClassWithDerivedState(pureComponentImpl);
82-
83-
exports.statelessComponent = function(x) { return x; };
84-
85-
exports.fragment = React.Fragment;
80+
export {pureComponentImpl};
81+
export const pureComponentWithDerivedStateImpl = createClassWithDerivedState(pureComponentImpl);
82+
export function statelessComponent(x) { return x; }
83+
export const fragment = React.Fragment;
8684

8785
function getProps(this_) {
8886
return function(){
8987
return this_.props;
9088
};
9189
}
92-
exports.getProps = getProps;
93-
94-
exports.childrenToArray = React.Children.toArray;
95-
96-
exports.childrenCount = React.Children.count;
90+
export {getProps};
91+
export const childrenToArray = React.Children.toArray;
92+
export const childrenCount = React.Children.count;
9793

9894
function setStateImpl(this_) {
9995
return function(state){
@@ -102,7 +98,7 @@ function setStateImpl(this_) {
10298
};
10399
};
104100
}
105-
exports.setStateImpl = setStateImpl;
101+
export {setStateImpl};
106102

107103
function setStateWithCallbackImpl(this_) {
108104
return function(state){
@@ -113,17 +109,17 @@ function setStateWithCallbackImpl(this_) {
113109
};
114110
};
115111
}
116-
exports.setStateWithCallbackImpl = setStateWithCallbackImpl;
112+
export {setStateWithCallbackImpl};
117113

118114
function getState(this_) {
119115
return function(){
120116
if (!this_.state) {
121-
throw new Error('[purescript-react] Cannot get state within constructor');
117+
throw new Error("[purescript-react] Cannot get state within constructor");
122118
}
123119
return this_.state;
124120
};
125121
}
126-
exports.getState = getState;
122+
export {getState};
127123

128124
function forceUpdateWithCallback(this_) {
129125
return function(cb) {
@@ -132,7 +128,7 @@ function forceUpdateWithCallback(this_) {
132128
};
133129
};
134130
}
135-
exports.forceUpdateWithCallback = forceUpdateWithCallback;
131+
export {forceUpdateWithCallback};
136132

137133
function createElement(class_) {
138134
return function(props){
@@ -141,25 +137,25 @@ function createElement(class_) {
141137
};
142138
};
143139
}
144-
exports.createElementImpl = createElement;
145-
exports.createElementTagName = createElement;
140+
export {createElement as createElementImpl};
141+
export {createElement as createElementTagName};
146142

147143
function createLeafElement(class_) {
148144
return function(props) {
149145
return React.createElement(class_, props);
150146
};
151147
}
152-
exports.createLeafElementImpl = createLeafElement;
148+
export {createLeafElement as createLeafElementImpl};
153149

154150
function createElementDynamic(class_) {
155151
return function(props) {
156152
return function(children){
157153
return React.createElement(class_, props, children);
158154
};
159155
};
160-
};
161-
exports.createElementDynamicImpl = createElementDynamic;
162-
exports.createElementTagNameDynamic = createElementDynamic;
156+
}
157+
export {createElementDynamic as createElementDynamicImpl};
158+
export {createElementDynamic as createElementTagNameDynamic};
163159

164160
function createContext(defaultValue) {
165161
var context = React.createContext(defaultValue);
@@ -168,4 +164,4 @@ function createContext(defaultValue) {
168164
provider: context.Provider
169165
};
170166
}
171-
exports.createContext = createContext;
167+
export {createContext};

src/React/DOM/Props.js

+8-13
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
1-
/* global exports */
2-
"use strict";
3-
4-
var React = require("react");
5-
61
function unsafeMkProps(key) {
72
return function(value){
83
var result = {};
94
result[key] = value;
105
return result;
116
};
127
}
13-
exports.unsafeMkProps = unsafeMkProps;
8+
export {unsafeMkProps};
149

1510
function unsafeUnfoldProps(key) {
1611
return function(value){
@@ -19,30 +14,30 @@ function unsafeUnfoldProps(key) {
1914
props[key] = result;
2015

2116
for (var subprop in value) {
22-
if (value.hasOwnProperty(subprop)) {
17+
if (Object.hasOwnProperty.apply(value, [subprop])) {
2318
result[subprop] = value[subprop];
2419
}
2520
}
2621

2722
return props;
2823
};
2924
}
30-
exports.unsafeUnfoldProps = unsafeUnfoldProps;
25+
export {unsafeUnfoldProps};
3126

3227
function unsafePrefixProps(prefix) {
3328
return function(value){
3429
var result = {};
3530

3631
for (var prop in value) {
37-
if (value.hasOwnProperty(prop)) {
32+
if (Object.hasOwnProperty.apply(value, [prop])) {
3833
result[prefix + prop] = value[prop];
3934
}
4035
}
4136

4237
return result;
4338
};
4439
}
45-
exports.unsafePrefixProps = unsafePrefixProps;
40+
export {unsafePrefixProps};
4641

4742
function unsafeFromPropsArray(props) {
4843
var result = {};
@@ -51,12 +46,12 @@ function unsafeFromPropsArray(props) {
5146
var prop = props[i];
5247

5348
for (var key in prop) {
54-
if (prop.hasOwnProperty(key)) {
49+
if (Object.hasOwnProperty.apply(prop, [key])) {
5550
result[key] = prop[key];
5651
}
5752
}
5853
}
5954

6055
return result;
61-
};
62-
exports.unsafeFromPropsArray = unsafeFromPropsArray;
56+
}
57+
export {unsafeFromPropsArray};

src/React/Ref.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1-
"use strict";
1+
import React from "react";
2+
export const createRef = React.createRef;
23

3-
var React = require("react");
4-
5-
exports.createRef = React.createRef;
6-
7-
exports.liftCallbackRef = function(ref) {
4+
export function liftCallbackRef(ref) {
85
return { current: ref };
96
}
107

11-
exports.getCurrentRef_ = function(ref) {
8+
export function getCurrentRef_(ref) {
129
return ref.current;
1310
}

0 commit comments

Comments
 (0)