@b9g/crank 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -15
- package/crank.cjs +7 -2
- package/crank.cjs.map +1 -1
- package/crank.d.ts +12 -4
- package/crank.js +7 -3
- package/crank.js.map +1 -1
- package/dom.cjs +3 -6
- package/dom.cjs.map +1 -1
- package/dom.d.ts +1 -1
- package/dom.js +3 -6
- package/dom.js.map +1 -1
- package/html.cjs +5 -0
- package/html.cjs.map +1 -1
- package/html.d.ts +1 -1
- package/html.js +5 -0
- package/html.js.map +1 -1
- package/index.cjs +1 -0
- package/index.cjs.map +1 -1
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/package.json +7 -9
- package/umd.d.ts +3 -3
- package/umd.js +8 -7
- package/umd.js.map +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ All components in Crank are just functions or generator functions. No classes, h
|
|
|
14
14
|
Crank provides first-class support for promises. You can define components as async functions and race renderings to display fallback UIs.
|
|
15
15
|
|
|
16
16
|
### Lightweight
|
|
17
|
-
Crank has no dependencies, and its core is a single file. It currently measures at [
|
|
17
|
+
Crank has no dependencies, and its core is a single file. It currently measures at [5KB minified and gzipped](https://bundlephobia.com/result?p=@b9g/crank).
|
|
18
18
|
|
|
19
19
|
### Performant
|
|
20
20
|
[According to benchmarks](https://github.com/krausest/js-framework-benchmark), Crank beats React in terms of speed and memory usage, and is currently comparable to Preact or Vue.
|
|
@@ -23,16 +23,16 @@ Crank has no dependencies, and its core is a single file. It currently measures
|
|
|
23
23
|
The core renderer can be extended to target alternative environments such as WebGL libraries, terminals, smartphones or smart TVs.
|
|
24
24
|
|
|
25
25
|
## Installation
|
|
26
|
-
Crank is available on [NPM](https://npmjs.org/@
|
|
26
|
+
Crank is available on [NPM](https://npmjs.org/@b9g/crank) in the ESModule and CommonJS formats.
|
|
27
27
|
|
|
28
28
|
```shell
|
|
29
|
-
$ npm install @
|
|
29
|
+
$ npm install @b9g/crank
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
```jsx
|
|
33
33
|
/** @jsx createElement */
|
|
34
|
-
import {createElement} from "@
|
|
35
|
-
import {renderer} from "@
|
|
34
|
+
import {createElement} from "@b9g/crank";
|
|
35
|
+
import {renderer} from "@b9g/crank/dom";
|
|
36
36
|
|
|
37
37
|
renderer.render(<div id="hello">Hello world</div>, document.body);
|
|
38
38
|
```
|
|
@@ -41,8 +41,8 @@ If your environment does not support ESModules (you may see a message like `Synt
|
|
|
41
41
|
|
|
42
42
|
```jsx
|
|
43
43
|
/** @jsx createElement */
|
|
44
|
-
import {createElement} from "@
|
|
45
|
-
import {renderer} from "@
|
|
44
|
+
import {createElement} from "@b9g/crank/cjs";
|
|
45
|
+
import {renderer} from "@b9g/crank/cjs/dom";
|
|
46
46
|
|
|
47
47
|
renderer.render(<div id="hello">Hello world</div>, document.body);
|
|
48
48
|
```
|
|
@@ -51,8 +51,8 @@ renderer.render(<div id="hello">Hello world</div>, document.body);
|
|
|
51
51
|
### A Simple Component
|
|
52
52
|
```jsx
|
|
53
53
|
/** @jsx createElement */
|
|
54
|
-
import {createElement} from "@
|
|
55
|
-
import {renderer} from "@
|
|
54
|
+
import {createElement} from "@b9g/crank";
|
|
55
|
+
import {renderer} from "@b9g/crank/dom";
|
|
56
56
|
|
|
57
57
|
function Greeting({name = "World"}) {
|
|
58
58
|
return (
|
|
@@ -68,8 +68,8 @@ renderer.render(<Greeting />, document.body);
|
|
|
68
68
|
### A Stateful Component
|
|
69
69
|
```jsx
|
|
70
70
|
/** @jsx createElement */
|
|
71
|
-
import {createElement} from "@
|
|
72
|
-
import {renderer} from "@
|
|
71
|
+
import {createElement} from "@b9g/crank";
|
|
72
|
+
import {renderer} from "@b9g/crank/dom";
|
|
73
73
|
|
|
74
74
|
function *Timer() {
|
|
75
75
|
let seconds = 0;
|
|
@@ -94,8 +94,8 @@ renderer.render(<Timer />, document.body);
|
|
|
94
94
|
### An Async Component
|
|
95
95
|
```jsx
|
|
96
96
|
/** @jsx createElement */
|
|
97
|
-
import {createElement} from "@
|
|
98
|
-
import {renderer} from "@
|
|
97
|
+
import {createElement} from "@b9g/crank";
|
|
98
|
+
import {renderer} from "@b9g/crank/dom";
|
|
99
99
|
|
|
100
100
|
async function QuoteOfTheDay() {
|
|
101
101
|
const res = await fetch("https://favqs.com/api/qotd");
|
|
@@ -115,8 +115,8 @@ renderer.render(<QuoteOfTheDay />, document.body);
|
|
|
115
115
|
### A Loading Component
|
|
116
116
|
```jsx
|
|
117
117
|
/** @jsx createElement */
|
|
118
|
-
import {createElement, Fragment} from "@
|
|
119
|
-
import {renderer} from "@
|
|
118
|
+
import {createElement, Fragment} from "@b9g/crank";
|
|
119
|
+
import {renderer} from "@b9g/crank/dom";
|
|
120
120
|
|
|
121
121
|
async function LoadingIndicator() {
|
|
122
122
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
package/crank.cjs
CHANGED
|
@@ -126,7 +126,6 @@ function createElement(tag, props, ...children) {
|
|
|
126
126
|
let static_ = false;
|
|
127
127
|
const props1 = {};
|
|
128
128
|
if (props != null) {
|
|
129
|
-
// TODO: deprecate crank-whatever props
|
|
130
129
|
for (const name in props) {
|
|
131
130
|
switch (name) {
|
|
132
131
|
case "crank-key":
|
|
@@ -1634,7 +1633,12 @@ function propagateError(ctx, err) {
|
|
|
1634
1633
|
return result.catch((err) => propagateError(ctx.parent, err));
|
|
1635
1634
|
}
|
|
1636
1635
|
return result;
|
|
1637
|
-
}
|
|
1636
|
+
}
|
|
1637
|
+
/**
|
|
1638
|
+
* Some JSX transpilation tools expect these functions to be defined on the
|
|
1639
|
+
* default export. Prefer named exports when importing directly.
|
|
1640
|
+
*/
|
|
1641
|
+
var crank = { createElement, Fragment };
|
|
1638
1642
|
|
|
1639
1643
|
exports.Context = Context;
|
|
1640
1644
|
exports.Copy = Copy;
|
|
@@ -1645,5 +1649,6 @@ exports.Raw = Raw;
|
|
|
1645
1649
|
exports.Renderer = Renderer;
|
|
1646
1650
|
exports.cloneElement = cloneElement;
|
|
1647
1651
|
exports.createElement = createElement;
|
|
1652
|
+
exports["default"] = crank;
|
|
1648
1653
|
exports.isElement = isElement;
|
|
1649
1654
|
//# sourceMappingURL=crank.cjs.map
|