Skip to content

Commit 94dfcfc

Browse files
committed
it's been a while
1 parent 6b1b79f commit 94dfcfc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1045
-1049
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @okwolf

.github/workflows/ci.yml

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@ name: CI
22
on: [push, pull_request]
33
jobs:
44
test:
5-
runs-on: ubuntu-latest
5+
runs-on: ${{ matrix.os }}
66
strategy:
77
matrix:
8-
node-version: [12.x, 14.x, 16.x]
8+
os: [ubuntu-latest, macos-latest, windows-latest]
9+
node: [18, 20, 22]
910
steps:
10-
- uses: actions/checkout@v2
11-
- name: Use Node.js ${{ matrix.node-version }}
12-
uses: actions/setup-node@v1
11+
- uses: actions/checkout@v4
12+
- name: Use Node.js ${{ matrix.node }}
13+
uses: actions/setup-node@v4
1314
with:
14-
node-version: ${{ matrix.node-version }}
15-
- run: |
16-
npm i -g codecov
17-
npm i
18-
npm run check
19-
codecov
15+
node-version: ${{ matrix.node }}
16+
- run: npm run release:dry
17+
- uses: codecov/codecov-action@v4
18+
with:
19+
token: ${{ secrets.CODECOV_TOKEN }}

.prettierrc

-5
This file was deleted.

README.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ A handy set of effects for use with [Hyperapp](https://github.com/jorgebucaran/h
1111
Here's a taste of how to use a common effect for making HTTP requests. The app displays inspiring quotes about design, fetching a new quote each time the user clicks on the current one. Go ahead and [try it online here](https://codepen.io/okwolf/pen/vPbMaa?editors=0010).
1212

1313
```js
14-
import { app, h, text } from "hyperapp"
15-
import { Http } from "hyperapp-fx"
14+
import { app, h, text } from "hyperapp";
15+
import { Http } from "hyperapp-fx";
1616

1717
const GetQuote = () => [
1818
"...",
1919
Http({
2020
url: "https://api.quotable.io/random",
2121
action: (_, { content }) => content
2222
})
23-
]
23+
];
2424

2525
app({
2626
init: "Click here for quotes",
2727
view: quote => h("h1", { onclick: GetQuote }, text(quote)),
2828
node: document.getElementById("app")
29-
})
29+
});
3030
```
3131

3232
More [examples](https://github.com/okwolf/hyperapp-playground) are available to show other effects in action.
@@ -40,13 +40,13 @@ npm i <a href=https://www.npmjs.com/package/hyperapp-fx>hyperapp-fx</a>
4040
Then with a module bundler like [Rollup](https://rollupjs.org) or [Webpack](https://webpack.js.org), use as you would anything else.
4141

4242
```js
43-
import { Http } from "hyperapp-fx"
43+
import { Http } from "hyperapp-fx";
4444
```
4545

46-
If you don't want to set up a build environment, you can download Hyperapp FX from a CDN like [unpkg.com](https://unpkg.com/hyperapp-fx) and it will be globally available through the <samp>window.hyperappFx</samp> object. We support all ES5-compliant browsers, including Internet Explorer 10 and above. Use of the [`Http`](api.md#module_fx.exports.Http) effect requires a polyfill.
46+
If you don't want to set up a build environment, you can import Hyperapp FX from a CDN like [esm.sh](https://esm.sh/hyperapp-fx). We support all modern browsers used by at least 1% of the world.
4747

48-
```html
49-
<script src="https://unpkg.com/hyperapp-fx"></script>
48+
```js
49+
import { Http } from "https://esm.sh/hyperapp-fx";
5050
```
5151

5252
## [API documentation](api.md)

eslint.config.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import compat from "eslint-plugin-compat";
4+
5+
export default [
6+
js.configs.recommended,
7+
{
8+
plugins: { compat },
9+
rules: {
10+
"no-use-before-define": "error",
11+
"no-var": "error",
12+
"prefer-const": "error",
13+
"compat/compat": "error"
14+
}
15+
},
16+
{
17+
files: ["src/**/*.js", "test/**/*.js"],
18+
languageOptions: {
19+
globals: globals.browser
20+
}
21+
},
22+
{
23+
files: ["test/**/*.js", "*.js"],
24+
languageOptions: {
25+
globals: globals.node
26+
}
27+
},
28+
{
29+
files: ["test/**/*.js"],
30+
languageOptions: {
31+
globals: globals.jest
32+
}
33+
}
34+
];

package.json

+17-39
Original file line numberDiff line numberDiff line change
@@ -2,60 +2,38 @@
22
"name": "hyperapp-fx",
33
"version": "2.0.0-beta.2",
44
"description": "Effects for use with Hyperapp",
5-
"main": "dist/hyperappFx.js",
65
"type": "module",
76
"module": "src/index.js",
87
"peerDependencies": {
98
"hyperapp": "^2.0.0"
109
},
1110
"devDependencies": {
12-
"eslint": "=8.8.0",
13-
"eslint-plugin-compat": "=4.0.2",
14-
"jest": "=27.5.0",
15-
"jsdoc-to-markdown": "=7.1.1",
16-
"jsdom": "=19.0.0",
17-
"prettier": "=2.5.1",
18-
"rollup": "=2.67.0",
19-
"uglify-js": "=3.15.0"
11+
"eslint": "=8.57.0",
12+
"eslint-plugin-compat": "=5.0.0",
13+
"jest": "=29.7.0",
14+
"jest-environment-jsdom": "=29.7.0",
15+
"jsdoc-to-markdown": "=8.0.1",
16+
"prettier": "=3.3.2",
17+
"rollup": "=4.18.0",
18+
"uglify-js": "=3.18.0"
2019
},
2120
"scripts": {
22-
"clean": "npx --ignore-existing --quiet rimraf coverage dist node_modules",
23-
"format": "prettier --write \"{src,test}/**/*.js\"",
24-
"format:check": "prettier --list-different \"{src,test}/**/*.js\"",
25-
"lint": "eslint {src,test}/**/*.js",
21+
"clean": "npx --quiet rimraf coverage dist node_modules",
22+
"format": "prettier --write \"**/*.js\"",
23+
"format:check": "prettier --list-different \"**/*.js\"",
24+
"lint": "eslint . --ignore-pattern dist",
2625
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage --no-cache",
2726
"doc": "jsdoc2md src/fx/*.js src/subs/*.js > api.md",
28-
"bundle": "rollup -i src/index.js -o dist/hyperappFx.js -m -f umd -n hyperappFx",
29-
"minify": "uglifyjs dist/hyperappFx.js -o dist/hyperappFx.js -mc pure_funcs=['Object.defineProperty'] --source-map includeSources,url=hyperappFx.js.map",
3027
"check": "npm run format:check && npm run lint && npm t",
31-
"build": "npm run check && npm run bundle && npm run minify",
32-
"release:dry": "npm run clean && npm i && npm run check && npm run build && npm run doc",
28+
"release:dry": "npm run clean && npm i && npm run check && npm run doc",
3329
"release": "node --experimental-json-modules release"
3430
},
35-
"eslintConfig": {
36-
"extends": "eslint:recommended",
37-
"plugins": [
38-
"compat"
39-
],
40-
"parserOptions": {
41-
"ecmaVersion": "latest",
42-
"sourceType": "module"
43-
},
44-
"env": {
45-
"browser": true
46-
},
47-
"rules": {
48-
"no-use-before-define": "error",
49-
"compat/compat": "error"
50-
},
51-
"settings": {
52-
"polyfills": [
53-
"fetch"
54-
]
55-
}
31+
"prettier": {
32+
"trailingComma": "none",
33+
"arrowParens": "avoid"
5634
},
5735
"browserslist": [
58-
"IE 10"
36+
"> 1%"
5937
],
6038
"jest": {
6139
"testEnvironment": "jsdom",

release.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
import { execSync } from "child_process"
2-
import packageJson from "./package.json"
3-
import { fileURLToPath } from "url"
4-
import { dirname } from "path"
1+
import { execSync } from "child_process";
2+
import packageJson from "./package.json";
3+
import { fileURLToPath } from "url";
4+
import { dirname } from "path";
55

6-
const __filename = fileURLToPath(import.meta.url)
7-
const __dirname = dirname(__filename)
8-
const exec = command => execSync(command, { encoding: "utf8" }).trim()
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = dirname(__filename);
8+
const exec = command => execSync(command, { encoding: "utf8" }).trim();
99

1010
const exitWithError = error => {
11-
process.stderr.write(`\x1b[1;31m${error}\x1b[0m\n\n`)
12-
process.exit(1)
13-
}
11+
process.stderr.write(`\x1b[1;31m${error}\x1b[0m\n\n`);
12+
process.exit(1);
13+
};
1414

15-
const gitBranchName = exec("git rev-parse --abbrev-ref HEAD")
15+
const gitBranchName = exec("git rev-parse --abbrev-ref HEAD");
1616
if (gitBranchName !== "master") {
17-
exitWithError("please checkout the master branch to make a release!")
17+
exitWithError("please checkout the master branch to make a release!");
1818
}
1919

20-
const workingCopyChanges = exec("git status --porcelain")
20+
const workingCopyChanges = exec("git status --porcelain");
2121
if (workingCopyChanges) {
22-
exitWithError("please commit your changes before making a release!")
22+
exitWithError("please commit your changes before making a release!");
2323
}
2424

25-
const tagExists = exec(`git tag -l "${packageJson.version}"`)
25+
const tagExists = exec(`git tag -l "${packageJson.version}"`);
2626
if (tagExists) {
27-
exitWithError(`${packageJson.version} has already been released!`)
27+
exitWithError(`${packageJson.version} has already been released!`);
2828
}
2929

3030
execSync(
@@ -34,4 +34,4 @@ execSync(
3434
stdio: "inherit",
3535
cwd: __dirname
3636
}
37-
)
37+
);

src/fx/Console.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
function consoleEffect(_, args) {
22
// eslint-disable-next-line no-console
3-
console.log.apply(null, args)
3+
console.log.apply(null, args);
44
}
55

66
/**
@@ -22,5 +22,5 @@ function consoleEffect(_, args) {
2222
* ]
2323
*/
2424
export function Console() {
25-
return [consoleEffect, arguments]
25+
return [consoleEffect, arguments];
2626
}

src/fx/Cookie.js

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,63 @@
1-
import { assign } from "../utils.js"
1+
import { assign } from "../utils.js";
22

3-
var validCookieNameChars =
4-
"abdefghijklmnqrstuvxyzABDEFGHIJKLMNQRSTUVXYZ0123456789!#$%&'*+-.^_`|~"
5-
var validCookieValueChars = validCookieNameChars + "()/:<>?@[]{}"
3+
const validCookieNameChars =
4+
"abdefghijklmnqrstuvxyzABDEFGHIJKLMNQRSTUVXYZ0123456789!#$%&'*+-.^_`|~";
5+
const validCookieValueChars = validCookieNameChars + "()/:<>?@[]{}";
66

77
function nameEncoder(value) {
88
return value
99
.toString()
1010
.split("")
1111
.map(function (c) {
12-
return validCookieNameChars.indexOf(c) > -1 ? c : encodeURIComponent(c)
12+
return validCookieNameChars.indexOf(c) > -1 ? c : encodeURIComponent(c);
1313
})
14-
.join("")
14+
.join("");
1515
}
1616

1717
function valueEncoder(value) {
1818
return value
1919
.toString()
2020
.split("")
2121
.map(function (c) {
22-
return validCookieValueChars.indexOf(c) > -1 ? c : encodeURIComponent(c)
22+
return validCookieValueChars.indexOf(c) > -1 ? c : encodeURIComponent(c);
2323
})
24-
.join("")
24+
.join("");
2525
}
2626

2727
function writeCookie(name, value, attributes) {
28-
var attrs = Object.keys(attributes)
28+
const attrs = Object.keys(attributes)
2929
.map(function (k) {
30-
return k + "=" + attributes[k]
30+
return k + "=" + attributes[k];
3131
})
32-
.join(";")
33-
document.cookie = name + "=" + value + (attrs ? ";" + attrs : "")
32+
.join(";");
33+
document.cookie = name + "=" + value + (attrs ? ";" + attrs : "");
3434
}
3535

3636
function readCookieEffect(dispatch, props) {
37-
var cookies = document.cookie.split("; ")
38-
var cookie = cookies.find(function (c) {
39-
return c.substr(0, c.indexOf("=")) === props.nameEncoder(props.name)
40-
})
37+
const cookies = document.cookie.split("; ");
38+
const cookie = cookies.find(function (c) {
39+
return c.substr(0, c.indexOf("=")) === props.nameEncoder(props.name);
40+
});
4141
if (cookie) {
42-
var dispatchProps = assign({}, props.props || {})
42+
const dispatchProps = assign({}, props.props || {});
4343
dispatchProps[props.prop || "value"] = props.converter(
4444
props.decoder(cookie.substr(props.nameEncoder(props.name).length + 1))
45-
)
46-
dispatch(props.action, dispatchProps)
45+
);
46+
dispatch(props.action, dispatchProps);
4747
}
4848
}
4949

5050
function writeCookieEffect(dispatch, props) {
51-
var name = (props.nameEncoder || nameEncoder)(props.name)
52-
var value = (props.encoder || valueEncoder)(props.converter(props.value))
53-
var attributes = {}
51+
const name = (props.nameEncoder || nameEncoder)(props.name);
52+
const value = (props.encoder || valueEncoder)(props.converter(props.value));
53+
const attributes = {};
5454
if (props.ttl)
55-
props.expires = new Date(new Date().getTime() + props.ttl * 1000)
56-
if (props.path) attributes.path = props.path
57-
if (props.domain) attributes.domain = props.domain
58-
if (props.expires) attributes.expires = props.expires.toUTCString()
55+
props.expires = new Date(new Date().getTime() + props.ttl * 1000);
56+
if (props.path) attributes.path = props.path;
57+
if (props.domain) attributes.domain = props.domain;
58+
if (props.expires) attributes.expires = props.expires.toUTCString();
5959

60-
writeCookie(name, value, attributes)
60+
writeCookie(name, value, attributes);
6161
}
6262

6363
/**
@@ -97,13 +97,13 @@ export function ReadCookie(props) {
9797
props.converter || props.json
9898
? JSON.parse
9999
: function (v) {
100-
return v
100+
return v;
101101
},
102102
decoder: props.decoder || decodeURIComponent
103103
},
104104
props
105105
)
106-
]
106+
];
107107
}
108108

109109
/**
@@ -143,12 +143,12 @@ export function WriteCookie(props) {
143143
props.converter || props.json
144144
? JSON.stringify
145145
: function (v) {
146-
return v
146+
return v;
147147
}
148148
},
149149
props
150150
)
151-
]
151+
];
152152
}
153153

154154
/**
@@ -170,5 +170,5 @@ export function WriteCookie(props) {
170170
*/
171171

172172
export function DeleteCookie(props) {
173-
return WriteCookie(assign(props, { ttl: -1, value: "" }))
173+
return WriteCookie(assign(props, { ttl: -1, value: "" }));
174174
}

0 commit comments

Comments
 (0)