@innet/node 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Mike Lysikov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ <a href="https://www.npmjs.com/package/innet">
2
+ <img src="https://raw.githubusercontent.com/d8corp/innet/main/logo.svg" align="left" width="90" height="90" alt="InnetJs logo by Mikhail Lysikov">
3
+ </a>
4
+
5
+ # &nbsp; @innet/node
6
+
7
+ &nbsp;
8
+
9
+ [![NPM](https://img.shields.io/npm/v/@innet/node.svg)](https://www.npmjs.com/package/@innet/node)
10
+ [![downloads](https://img.shields.io/npm/dm/@innet/node.svg)](https://www.npmtrends.com/@innet/node)
11
+ [![tests](https://img.shields.io/github/actions/workflow/status/d8corp/innet-node/node.js.yml?branch=main&label=tests
12
+ )](https://github.com/d8corp/innet-node/actions/workflows/node.js.yml)
13
+ [![changelog](https://img.shields.io/badge/Changelog-⋮-brightgreen)](https://changelogs.xyz/@innet/node)
14
+ [![license](https://img.shields.io/npm/l/@innet/node)](https://github.com/d8corp/innet-node/blob/main/LICENSE)
15
+
16
+ ## Overview
17
+ `@innet/node` is a lightweight and reactive Node.js application framework built on top of [innet](https://www.npmjs.com/package/innet).
18
+ It provides a simple, JSX-based API for building highly performant Node.js applications with fine-grained reactivity and minimal boilerplate.
19
+
20
+ ## Install
21
+
22
+ ```shell
23
+ npx innetjs init my-app -t node
24
+ ```
25
+
26
+ ## Issues
27
+ If you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/innet-node/issues).
28
+
29
+ [![issues](https://img.shields.io/github/issues-raw/d8corp/innet-node)](https://github.com/d8corp/innet-node/issues)
@@ -0,0 +1,6 @@
1
+ import { type Plugin } from 'innet';
2
+ export declare const arrayPlugins: Plugin[];
3
+ export declare const fnPlugins: Plugin[];
4
+ export declare const objectPlugins: Plugin[];
5
+ export declare const promisePlugins: Plugin[];
6
+ export declare const handler: import("innet").Handler;
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var innet = require('innet');
6
+ var jsx = require('@innet/jsx');
7
+ var utils = require('@innet/utils');
8
+ require('../plugins/index.js');
9
+ var nodeFn = require('../plugins/nodeFn/nodeFn.js');
10
+ var nodeAsync = require('../plugins/nodeAsync/nodeAsync.js');
11
+
12
+ const arrayPlugins = [
13
+ utils.arraySync,
14
+ ];
15
+ const fnPlugins = [
16
+ nodeFn.nodeFn,
17
+ ];
18
+ const objectPlugins = [
19
+ jsx.jsxComponent,
20
+ ];
21
+ const promisePlugins = [
22
+ nodeAsync.nodeAsync,
23
+ ];
24
+ const handler = innet.createHandler([
25
+ utils.promise(promisePlugins),
26
+ utils.array(arrayPlugins),
27
+ utils.nullish([]),
28
+ utils.object(objectPlugins),
29
+ utils.fn(fnPlugins),
30
+ ]);
31
+
32
+ exports.arrayPlugins = arrayPlugins;
33
+ exports.fnPlugins = fnPlugins;
34
+ exports.handler = handler;
35
+ exports.objectPlugins = objectPlugins;
36
+ exports.promisePlugins = promisePlugins;
@@ -0,0 +1,28 @@
1
+ import { createHandler } from 'innet';
2
+ import { jsxComponent } from '@innet/jsx';
3
+ import { arraySync, promise, array, nullish, object, fn } from '@innet/utils';
4
+ import '../plugins/index.mjs';
5
+ import { nodeFn } from '../plugins/nodeFn/nodeFn.mjs';
6
+ import { nodeAsync } from '../plugins/nodeAsync/nodeAsync.mjs';
7
+
8
+ const arrayPlugins = [
9
+ arraySync,
10
+ ];
11
+ const fnPlugins = [
12
+ nodeFn,
13
+ ];
14
+ const objectPlugins = [
15
+ jsxComponent,
16
+ ];
17
+ const promisePlugins = [
18
+ nodeAsync,
19
+ ];
20
+ const handler = createHandler([
21
+ promise(promisePlugins),
22
+ array(arrayPlugins),
23
+ nullish([]),
24
+ object(objectPlugins),
25
+ fn(fnPlugins),
26
+ ]);
27
+
28
+ export { arrayPlugins, fnPlugins, handler, objectPlugins, promisePlugins };
@@ -0,0 +1 @@
1
+ export * from './handler';
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var handler = require('./handler.js');
6
+
7
+
8
+
9
+ exports.arrayPlugins = handler.arrayPlugins;
10
+ exports.fnPlugins = handler.fnPlugins;
11
+ exports.handler = handler.handler;
12
+ exports.objectPlugins = handler.objectPlugins;
13
+ exports.promisePlugins = handler.promisePlugins;
@@ -0,0 +1 @@
1
+ export { arrayPlugins, fnPlugins, handler, objectPlugins, promisePlugins } from './handler.mjs';
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './handler';
2
+ export * from './plugins';
package/index.js ADDED
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('./handler/index.js');
6
+ require('./plugins/index.js');
7
+ var handler = require('./handler/handler.js');
8
+ var nodeAsync = require('./plugins/nodeAsync/nodeAsync.js');
9
+ var nodeFn = require('./plugins/nodeFn/nodeFn.js');
10
+
11
+
12
+
13
+ exports.arrayPlugins = handler.arrayPlugins;
14
+ exports.fnPlugins = handler.fnPlugins;
15
+ exports.handler = handler.handler;
16
+ exports.objectPlugins = handler.objectPlugins;
17
+ exports.promisePlugins = handler.promisePlugins;
18
+ exports.nodeAsync = nodeAsync.nodeAsync;
19
+ exports.nodeFn = nodeFn.nodeFn;
package/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import './handler/index.mjs';
2
+ import './plugins/index.mjs';
3
+ export { arrayPlugins, fnPlugins, handler, objectPlugins, promisePlugins } from './handler/handler.mjs';
4
+ export { nodeAsync } from './plugins/nodeAsync/nodeAsync.mjs';
5
+ export { nodeFn } from './plugins/nodeFn/nodeFn.mjs';
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@innet/node",
3
+ "version": "0.0.1",
4
+ "description": "Create Node.js application with innet",
5
+ "main": "index.js",
6
+ "module": "index.mjs",
7
+ "jsnext:main": "index.mjs",
8
+ "types": "index.d.ts",
9
+ "scripts": {
10
+ "build": "innetjs release -e",
11
+ "start": "innetjs start -n -i example/index",
12
+ "test": "jest",
13
+ "lint": "eslint src --ext .ts,.tsx",
14
+ "lint:fix": "eslint src --ext .ts,.tsx --fix",
15
+ "update": "npx npm-check-updates -i --format group",
16
+ "release": "innetjs release -p",
17
+ "patch": "innetjs patch",
18
+ "minor": "innetjs minor",
19
+ "major": "innetjs major"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/d8corp/innet-node.git"
24
+ },
25
+ "keywords": [
26
+ "innet",
27
+ "node",
28
+ "server"
29
+ ],
30
+ "author": "Mikhail Lysikov <d8corp@mail.ru>",
31
+ "license": "MIT",
32
+ "bugs": {
33
+ "url": "https://github.com/d8corp/innet-node/issues"
34
+ },
35
+ "homepage": "https://github.com/d8corp/innet-node",
36
+ "dependencies": {
37
+ "@innet/jsx": "^2.1.3",
38
+ "@innet/utils": "^2.1.0",
39
+ "innet": "^2.1.1",
40
+ "watch-state": "^3.6.2"
41
+ }
42
+ }
@@ -0,0 +1,2 @@
1
+ export * from './nodeAsync';
2
+ export * from './nodeFn';
@@ -0,0 +1,5 @@
1
+ 'use strict';
2
+
3
+ require('./nodeAsync/index.js');
4
+ require('./nodeFn/index.js');
5
+
@@ -0,0 +1,2 @@
1
+ import './nodeAsync/index.mjs';
2
+ import './nodeFn/index.mjs';
@@ -0,0 +1 @@
1
+ export * from './nodeAsync';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var nodeAsync = require('./nodeAsync.js');
6
+
7
+
8
+
9
+ exports.nodeAsync = nodeAsync.nodeAsync;
@@ -0,0 +1 @@
1
+ export { nodeAsync } from './nodeAsync.mjs';
@@ -0,0 +1,2 @@
1
+ import { type HandlerPlugin } from 'innet';
2
+ export declare function nodeAsync(): HandlerPlugin;
@@ -0,0 +1,28 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var innet = require('innet');
6
+ var watchState = require('watch-state');
7
+
8
+ function nodeAsync() {
9
+ return () => {
10
+ const { activeWatcher } = watchState.scope;
11
+ const app = innet.useApp();
12
+ const handler = innet.useHandler();
13
+ let works = true;
14
+ watchState.onDestroy(() => {
15
+ works = false;
16
+ });
17
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
18
+ app.then(data => {
19
+ if (works) {
20
+ watchState.scope.activeWatcher = activeWatcher;
21
+ innet.innet(data, handler);
22
+ watchState.scope.activeWatcher = undefined;
23
+ }
24
+ });
25
+ };
26
+ }
27
+
28
+ exports.nodeAsync = nodeAsync;
@@ -0,0 +1,24 @@
1
+ import { useApp, useHandler, innet } from 'innet';
2
+ import { scope, onDestroy } from 'watch-state';
3
+
4
+ function nodeAsync() {
5
+ return () => {
6
+ const { activeWatcher } = scope;
7
+ const app = useApp();
8
+ const handler = useHandler();
9
+ let works = true;
10
+ onDestroy(() => {
11
+ works = false;
12
+ });
13
+ // eslint-disable-next-line @typescript-eslint/no-floating-promises
14
+ app.then(data => {
15
+ if (works) {
16
+ scope.activeWatcher = activeWatcher;
17
+ innet(data, handler);
18
+ scope.activeWatcher = undefined;
19
+ }
20
+ });
21
+ };
22
+ }
23
+
24
+ export { nodeAsync };
@@ -0,0 +1 @@
1
+ export * from './nodeFn';
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var nodeFn = require('./nodeFn.js');
6
+
7
+
8
+
9
+ exports.nodeFn = nodeFn.nodeFn;
@@ -0,0 +1 @@
1
+ export { nodeFn } from './nodeFn.mjs';
@@ -0,0 +1,2 @@
1
+ import { type Plugin } from 'innet';
2
+ export declare const nodeFn: Plugin;
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var innet = require('innet');
6
+ var watchState = require('watch-state');
7
+
8
+ const nodeFn = () => {
9
+ return () => {
10
+ const handler = innet.useHandler();
11
+ const fn = innet.useApp();
12
+ new watchState.Watch(() => {
13
+ innet.innet(fn(), handler);
14
+ });
15
+ };
16
+ };
17
+
18
+ exports.nodeFn = nodeFn;
@@ -0,0 +1,14 @@
1
+ import { useHandler, useApp, innet } from 'innet';
2
+ import { Watch } from 'watch-state';
3
+
4
+ const nodeFn = () => {
5
+ return () => {
6
+ const handler = useHandler();
7
+ const fn = useApp();
8
+ new Watch(() => {
9
+ innet(fn(), handler);
10
+ });
11
+ };
12
+ };
13
+
14
+ export { nodeFn };