Browse Source

Add a guix package declaration

main v0.1.1
Tissevert 2 months ago
parent
commit
8a8c07ec64
  1. 6
      CHANGELOG.md
  2. 50
      README.md
  3. 27
      guix.scm
  4. 2
      unit.js.tpl

6
CHANGELOG.md

@ -1,5 +1,11 @@
# Revision history for UnitJS
## 0.1.1 -- 2022-08-09
* Package UnitJS for [guix](https://guix.gnu.org/)
* Fix state bug in Async's sequences and bindings
* Generalize support for events in Dom element maker
## 0.1.0 -- 2020-05-17
* Release UnitJS as a [SJW](https://git.marvid.fr/Tissevert/SJW) package still useable as a standalone script.

50
README.md

@ -1,43 +1,49 @@
# UnitJS
UnitJS is a tiny Javascript framework to write web applications. It provides four essential modules to deal with asynchronous functions (technically, it's a monad obtained by currifying the CPS functions of Javascript like `setTimeout`), value caching, DOM manipulation and basic functional needs like composition or object projections.
UnitJS is a tiny Javascript framework to write web applications. It provides
four essential modules to deal with asynchronous functions (technically, it's a
monad obtained by currifying the CPS functions of Javascript like
`setTimeout`), value caching, DOM manipulation and basic functional needs like
composition or object projections.
## Usage
### With [SJW](https://git.marvid.fr/Tissevert/SJW)
## How to use it in your project
UnitJS comes as a SJW package. You can install it by copying the `src/` directory of this repository to your package database by issuing the following command from the current directory :
### As a [`SJW`](https://git.marvid.fr/Tissevert/SJW) package.
```
$ cp -r src/ ~/.sjw/unitJS
```
#### With [`guix`](https://guix.gnu.org/)
Then, using unitJS in your projects is as simple as writing :
The easiest way to use it in your web projects is to simply [package them with
`guix`](https://git.marvid.fr/Tissevert/SJW#how-not-to-install).
```
import * as Async from UnitJS.Async;
```
#### Otherwise
in any module if you want to use the `Async` module for instance and compile your code using the `--include` option of `sjw` with package `unitJS` :
You can follow [these
instructions](https://git.marvid.fr/Tissevert/SJW#when-guix-is-not-an-option)
to use it without `guix`.
```
$ sjw -I unitJS your/code/src -o your/code/main.js
```
Note that all modules have their path prefixed by a common `UnitJS` component and that SJW will only include the modules actually used in your code, not all of UnitJS.
### Without `SJW`
### As a standalone JS script
If you don't want to or can't use SJW, it's still possible to use UnitJS by generating a single script that can then be loaded from your web page like this :
If you don't want to or can't use SJW, it's still possible to use UnitJS by
generating a single script that can then be loaded from your web page like this
:
```
<script src="/path/to/unit.js"></script>
```
The file `unit.js` can be easily generated with `make`, which actually just calls the `unit.js.tpl` script. Note that you can still generate custom «partial» versions of `unit.js` if you don't use all of it by overriding the `SRC` variable of the `Makefile` like so :
The file `unit.js` can be easily generated with `make`, which actually just
calls the `unit.js.tpl` script. Note that you can still generate custom
«partial» versions of `unit.js` if you don't use all of it by overriding the
`SRC` variable of the `Makefile` like so :
```
make SRC="src/UnitJS/Dom.js src/UnitJS/Cache.js"
```
or by manually calling `./unit.js.tpl` with the files you want, like the `Makefile` does.
or by manually calling `./unit.js.tpl` with the files you want, like the
`Makefile` does.
When used that way, the `UnitJS` library will be available to your Javascript
code as a global variable `unitJS` containing each of the modules (`Async`,
`Dom`, etc.) as an attribute.

27
guix.scm

@ -0,0 +1,27 @@
(use-modules (guix build-system copy)
(guix gexp)
(guix git-download)
(guix licenses)
(guix packages))
(let
((%source-dir (dirname (current-filename))))
(package
(name "sjw-unitJS")
(version "devel")
(source
(local-file %source-dir
#:recursive? #t
#:select? (git-predicate %source-dir)))
(build-system copy-build-system)
(arguments
'(#:install-plan
'(("src" "lib/SJW/unitJS"))))
(home-page "https://git.marvid.fr/Tissevert/SJW")
(synopsis "The Simple Javascript Wrench.")
(description
"A collection of JS modules to write simple web applications. It covers
the basics, providing asynchronous operations without any need for
promises-support from the browser as well as primitives to create DOM
elements and basic functional-programming tooling.")
(license gpl3+)))

2
unit.js.tpl

@ -30,7 +30,7 @@ EOF
cat <<EOF
var unitJS = (function() {
return {
$(printf "${MODULES}" | sed -e 's|:|,\n|g' -e 's|[^,\n]\+|&: &|g' | indent | indent)
$(printf "${MODULES}" | sed -e 's|:|,\n|g' -e 's|[^,\n]\+|&: &()|g' | indent | indent)
};
$(for file in "${@}"; do includeModule "${file}"; done | indent)
})();

Loading…
Cancel
Save