Skip to content

Commit 3a9f39b

Browse files
committed
Update JS to ESM, use Spago
1 parent 801a5b0 commit 3a9f39b

File tree

7 files changed

+177
-13
lines changed

7 files changed

+177
-13
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
/.purs*
99
/.psa*
1010
/.vscode/
11+
/.spago/

packages.dhall

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
{-
2+
Welcome to your new Dhall package-set!
3+
4+
Below are instructions for how to edit this file for most use
5+
cases, so that you don't need to know Dhall to use it.
6+
7+
## Use Cases
8+
9+
Most will want to do one or both of these options:
10+
1. Override/Patch a package's dependency
11+
2. Add a package not already in the default package set
12+
13+
This file will continue to work whether you use one or both options.
14+
Instructions for each option are explained below.
15+
16+
### Overriding/Patching a package
17+
18+
Purpose:
19+
- Change a package's dependency to a newer/older release than the
20+
default package set's release
21+
- Use your own modified version of some dependency that may
22+
include new API, changed API, removed API by
23+
using your custom git repo of the library rather than
24+
the package set's repo
25+
26+
Syntax:
27+
where `entityName` is one of the following:
28+
- dependencies
29+
- repo
30+
- version
31+
-------------------------------
32+
let upstream = --
33+
in upstream
34+
with packageName.entityName = "new value"
35+
-------------------------------
36+
37+
Example:
38+
-------------------------------
39+
let upstream = --
40+
in upstream
41+
with halogen.version = "master"
42+
with halogen.repo = "https://example.com/path/to/git/repo.git"
43+
44+
with halogen-vdom.version = "v4.0.0"
45+
with halogen-vdom.dependencies = [ "extra-dependency" ] # halogen-vdom.dependencies
46+
-------------------------------
47+
48+
### Additions
49+
50+
Purpose:
51+
- Add packages that aren't already included in the default package set
52+
53+
Syntax:
54+
where `<version>` is:
55+
- a tag (i.e. "v4.0.0")
56+
- a branch (i.e. "master")
57+
- commit hash (i.e. "701f3e44aafb1a6459281714858fadf2c4c2a977")
58+
-------------------------------
59+
let upstream = --
60+
in upstream
61+
with new-package-name =
62+
{ dependencies =
63+
[ "dependency1"
64+
, "dependency2"
65+
]
66+
, repo =
67+
"https://example.com/path/to/git/repo.git"
68+
, version =
69+
"<version>"
70+
}
71+
-------------------------------
72+
73+
Example:
74+
-------------------------------
75+
let upstream = --
76+
in upstream
77+
with benchotron =
78+
{ dependencies =
79+
[ "arrays"
80+
, "exists"
81+
, "profunctor"
82+
, "strings"
83+
, "quickcheck"
84+
, "lcg"
85+
, "transformers"
86+
, "foldable-traversable"
87+
, "exceptions"
88+
, "node-fs"
89+
, "node-buffer"
90+
, "node-readline"
91+
, "datetime"
92+
, "now"
93+
]
94+
, repo =
95+
"https://github.com/hdgarrood/purescript-benchotron.git"
96+
, version =
97+
"v7.0.0"
98+
}
99+
-------------------------------
100+
-}
101+
let upstream =
102+
https://github.com/purescript/package-sets/releases/download/psc-0.15.0-20220527/packages.dhall
103+
sha256:15dd8041480502850e4043ea2977ed22d6ab3fc24d565211acde6f8c5152a799
104+
105+
in upstream
106+
with react-basic-hooks =
107+
{ dependencies =
108+
[ "aff"
109+
, "aff-promise"
110+
, "bifunctors"
111+
, "console"
112+
, "control"
113+
, "datetime"
114+
, "debug"
115+
, "effect"
116+
, "either"
117+
, "exceptions"
118+
, "foldable-traversable"
119+
, "functions"
120+
, "indexed-monad"
121+
, "integers"
122+
, "maybe"
123+
, "newtype"
124+
, "now"
125+
, "nullable"
126+
, "ordered-collections"
127+
, "prelude"
128+
, "react-basic"
129+
, "refs"
130+
, "tuples"
131+
, "type-equality"
132+
, "unsafe-coerce"
133+
, "unsafe-reference"
134+
, "web-html"
135+
]
136+
, repo = "https://github.com/spicydonuts/purescript-react-basic-hooks.git"
137+
, version = "v8.0.0"
138+
}

spago.dhall

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{-
2+
Welcome to a Spago project!
3+
You can edit this file as you like.
4+
5+
Need help? See the following resources:
6+
- Spago documentation: https://github.com/purescript/spago
7+
- Dhall language tour: https://docs.dhall-lang.org/tutorials/Language-Tour.html
8+
9+
When creating a new Spago project, you can use
10+
`spago init --no-comments` or `spago init -C`
11+
to generate this file without the comments in this block.
12+
-}
13+
{ name = "react-dnd-basic"
14+
, dependencies =
15+
[ "console"
16+
, "effect"
17+
, "maybe"
18+
, "nullable"
19+
, "prelude"
20+
, "react-basic-hooks"
21+
, "web-dom"
22+
]
23+
, packages = ./packages.dhall
24+
, sources = [ "src/**/*.purs", "test/**/*.purs" ]
25+
, license = "Apache-2.0"
26+
, repository = "https://github.com/lumihq/purescript-react-dnd-basic"
27+
}

src/React/Basic/ReactDND.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
"use strict";
1+
import DND from "react-dnd";
22

3-
const DND = require("react-dnd");
3+
export const dndProvider_ = DND.DndProvider;
44

5-
exports.dndProvider_ = DND.DndProvider;
6-
7-
exports.useDrag_ = (options) => {
5+
export const useDrag_ = (options) => {
86
const [{ isDragging }, connectDrag] = DND.useDrag({
97
item: options.item,
108
collect: (monitor) => {
@@ -15,7 +13,7 @@ exports.useDrag_ = (options) => {
1513
return { isDragging, connectDrag };
1614
};
1715

18-
exports.useDrop_ = (options) => {
16+
export const useDrop_ = (options) => {
1917
const [{ id, isOver }, connectDrop] = DND.useDrop({
2018
accept: options.accept,
2119
drop: (item) => {
@@ -33,7 +31,7 @@ exports.useDrop_ = (options) => {
3331
return { id, isOver, connectDrop };
3432
};
3533

36-
exports.mergeTargets = (ref1) => (ref2) => {
34+
export const mergeTargets = (ref1) => (ref2) => {
3735
// shhhhhhh, don't look 🙈
3836
// sometimes refs are React ref objects..
3937
// sometimes they're functions..
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"use strict";
1+
import { HTML5Backend } from "react-dnd-html5-backend";
22

3-
exports.html5Backend = require("react-dnd-html5-backend").HTML5Backend;
3+
export const html5Backend = HTML5Backend;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"use strict";
1+
import { TestBackend } from "react-dnd-test-backend";
22

3-
exports.testBackend = require("react-dnd-test-backend").TestBackend;
3+
export const testBackend = TestBackend;
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
"use strict";
1+
import { TouchBackend } from "react-dnd-touch-backend";
22

3-
exports.touchBackend = require("react-dnd-touch-backend").TouchBackend;
3+
export const touchBackend = TouchBackend;

0 commit comments

Comments
 (0)