functionalscript 0.0.587 → 0.0.589
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/.github/workflows/ci.yml +4 -24
- package/Cargo.lock +14 -0
- package/com/rust/nanocom/Cargo.lock +7 -0
- package/dev/module.mjs +13 -43
- package/dev/test/module.f.cjs +2 -3
- package/dev/test.mjs +2 -2
- package/index.f.cjs +26 -26
- package/issues/README.md +3 -19
- package/issues/publish.md +35 -0
- package/jsr.json +1 -1
- package/package.json +2 -2
package/.github/workflows/ci.yml
CHANGED
|
@@ -10,26 +10,12 @@ on:
|
|
|
10
10
|
pull_request:
|
|
11
11
|
|
|
12
12
|
jobs:
|
|
13
|
-
locks:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- uses: actions/checkout@v2
|
|
17
|
-
- uses: actions/setup-node@v2
|
|
18
|
-
with:
|
|
19
|
-
node-version: 22
|
|
20
|
-
- run: npm install
|
|
21
|
-
- uses: actions/upload-artifact@v4
|
|
22
|
-
with:
|
|
23
|
-
name: package-lock.json
|
|
24
|
-
path: package-lock.json
|
|
25
|
-
|
|
26
13
|
node:
|
|
27
|
-
needs: locks
|
|
28
14
|
runs-on: ubuntu-latest
|
|
29
15
|
|
|
30
16
|
strategy:
|
|
31
17
|
matrix:
|
|
32
|
-
node-version: [16
|
|
18
|
+
node-version: [16, 18, 20, 22, 23]
|
|
33
19
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
34
20
|
|
|
35
21
|
steps:
|
|
@@ -37,9 +23,6 @@ jobs:
|
|
|
37
23
|
- uses: actions/setup-node@v2
|
|
38
24
|
with:
|
|
39
25
|
node-version: ${{ matrix.node-version }}
|
|
40
|
-
- uses: actions/download-artifact@v4
|
|
41
|
-
with:
|
|
42
|
-
name: package-lock.json
|
|
43
26
|
- run: npm ci
|
|
44
27
|
- run: npm test
|
|
45
28
|
- run: npm run version
|
|
@@ -51,7 +34,7 @@ jobs:
|
|
|
51
34
|
|
|
52
35
|
strategy:
|
|
53
36
|
matrix:
|
|
54
|
-
deno-version: [
|
|
37
|
+
deno-version: [2]
|
|
55
38
|
|
|
56
39
|
steps:
|
|
57
40
|
- uses: actions/checkout@v2
|
|
@@ -70,10 +53,10 @@ jobs:
|
|
|
70
53
|
- run: /home/runner/.bun/bin/bun ./dev/test.mjs
|
|
71
54
|
|
|
72
55
|
COM:
|
|
73
|
-
needs: locks
|
|
74
56
|
strategy:
|
|
75
57
|
matrix:
|
|
76
|
-
|
|
58
|
+
# https://docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#choosing-github-hosted-runners
|
|
59
|
+
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
|
|
77
60
|
|
|
78
61
|
runs-on: ${{ matrix.os }}
|
|
79
62
|
|
|
@@ -82,9 +65,6 @@ jobs:
|
|
|
82
65
|
- uses: actions/setup-node@v2
|
|
83
66
|
with:
|
|
84
67
|
node-version: 22
|
|
85
|
-
- uses: actions/download-artifact@v4
|
|
86
|
-
with:
|
|
87
|
-
name: package-lock.json
|
|
88
68
|
- uses: actions/setup-dotnet@v3
|
|
89
69
|
with:
|
|
90
70
|
dotnet-version: 9
|
package/Cargo.lock
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# This file is automatically @generated by Cargo.
|
|
2
|
+
# It is not intended for manual editing.
|
|
3
|
+
version = 3
|
|
4
|
+
|
|
5
|
+
[[package]]
|
|
6
|
+
name = "nanocom"
|
|
7
|
+
version = "0.2.1"
|
|
8
|
+
|
|
9
|
+
[[package]]
|
|
10
|
+
name = "testrust"
|
|
11
|
+
version = "0.1.0"
|
|
12
|
+
dependencies = [
|
|
13
|
+
"nanocom",
|
|
14
|
+
]
|
package/dev/module.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { readdir,
|
|
1
|
+
import { readdir, writeFile } from 'node:fs/promises'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {{
|
|
@@ -22,36 +22,16 @@ import { readdir, readFile, writeFile } from 'node:fs/promises'
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* @typedef {{
|
|
25
|
-
*
|
|
26
|
-
* }} MutableDependencyMap
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* @typedef {{
|
|
31
|
-
* dependencyMap: MutableDependencyMap
|
|
32
|
-
* exports?: unknown
|
|
33
|
-
* }} MutableModule
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @typedef {{
|
|
38
|
-
* readonly dependencyMap: DependencyMap
|
|
39
|
-
* readonly exports?: unknown
|
|
25
|
+
* readonly default?: unknown
|
|
40
26
|
* }} Module
|
|
41
27
|
*/
|
|
42
28
|
|
|
43
|
-
/**
|
|
44
|
-
* @typedef {{
|
|
45
|
-
* readonly[k in string]?: Module
|
|
46
|
-
* }} DependencyMap
|
|
47
|
-
*/
|
|
48
|
-
|
|
49
29
|
/** @typedef {(name: string) => unknown} Require */
|
|
50
30
|
|
|
51
31
|
/**
|
|
52
32
|
* @typedef {{
|
|
53
|
-
* readonly[k in string]:
|
|
54
|
-
* }}
|
|
33
|
+
* readonly[k in string]: unknown
|
|
34
|
+
* }} UnknownMap
|
|
55
35
|
*/
|
|
56
36
|
|
|
57
37
|
/**
|
|
@@ -59,12 +39,12 @@ import { readdir, readFile, writeFile } from 'node:fs/promises'
|
|
|
59
39
|
* @typedef {readonly[string, T]} Entry
|
|
60
40
|
*/
|
|
61
41
|
|
|
62
|
-
/** @type {(a: Entry<
|
|
42
|
+
/** @type {(a: Entry<unknown>, b: Entry<unknown>) => number} */
|
|
63
43
|
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
64
44
|
|
|
65
45
|
/**
|
|
66
46
|
* @typedef {{
|
|
67
|
-
* [k in string]:
|
|
47
|
+
* [k in string]: Module
|
|
68
48
|
* }} MutableModuleMap
|
|
69
49
|
*/
|
|
70
50
|
|
|
@@ -94,9 +74,9 @@ export const env =
|
|
|
94
74
|
}
|
|
95
75
|
|
|
96
76
|
export const loadModuleMap = async () => {
|
|
97
|
-
/** @type {() => Promise<
|
|
77
|
+
/** @type {() => Promise<UnknownMap>} */
|
|
98
78
|
const load = async () => {
|
|
99
|
-
/** @type {(readonly[string,
|
|
79
|
+
/** @type {(readonly[string, unknown])[]} */
|
|
100
80
|
const map = []
|
|
101
81
|
/** @type {(path: string) => Promise<void>} */
|
|
102
82
|
const f = async p => {
|
|
@@ -107,8 +87,8 @@ export const loadModuleMap = async () => {
|
|
|
107
87
|
if (i.isDirectory()) {
|
|
108
88
|
await f(file)
|
|
109
89
|
} else if (name.endsWith('.f.cjs')) {
|
|
110
|
-
const source = await
|
|
111
|
-
map.push([file,
|
|
90
|
+
const source = await import(`../${file}`)
|
|
91
|
+
map.push([file, source.default])
|
|
112
92
|
}
|
|
113
93
|
}
|
|
114
94
|
}
|
|
@@ -124,7 +104,7 @@ export const loadModuleMap = async () => {
|
|
|
124
104
|
const build = () => {
|
|
125
105
|
/** @type {MutableModuleMap} */
|
|
126
106
|
const d = {}
|
|
127
|
-
/** @type {(base: readonly string[]) => (k: string) => readonly[string,
|
|
107
|
+
/** @type {(base: readonly string[]) => (k: string) => readonly[string, Module]} */
|
|
128
108
|
const getModule = base => k => {
|
|
129
109
|
const relativePath = k.split('/')
|
|
130
110
|
const dif = relativePath.filter(v => v === '..').length
|
|
@@ -138,18 +118,8 @@ export const loadModuleMap = async () => {
|
|
|
138
118
|
}
|
|
139
119
|
}
|
|
140
120
|
{
|
|
141
|
-
/** @type {
|
|
142
|
-
const
|
|
143
|
-
/** @type {MutableModule} */
|
|
144
|
-
const module = { dependencyMap }
|
|
145
|
-
const get = getModule(remove_tail(path)(1))
|
|
146
|
-
/** @type {(s: string) => unknown} */
|
|
147
|
-
const newReq = s => {
|
|
148
|
-
const [p, result] = get(s)
|
|
149
|
-
dependencyMap[p] = result
|
|
150
|
-
return result.exports
|
|
151
|
-
}
|
|
152
|
-
map[pathStr](module, newReq)
|
|
121
|
+
/** @type {Module} */
|
|
122
|
+
const module = { default: map[pathStr] }
|
|
153
123
|
d[pathStr] = module
|
|
154
124
|
return [pathStr, module]
|
|
155
125
|
}
|
package/dev/test/module.f.cjs
CHANGED
|
@@ -11,8 +11,7 @@ const result = require('../../types/result/module.f.cjs')
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @typedef {{
|
|
14
|
-
* readonly
|
|
15
|
-
* readonly exports?: unknown
|
|
14
|
+
* readonly default?: unknown
|
|
16
15
|
* }} Module
|
|
17
16
|
*/
|
|
18
17
|
|
|
@@ -121,7 +120,7 @@ const main = input => {
|
|
|
121
120
|
return ([ts, state]) => {
|
|
122
121
|
if (isTest(k)) {
|
|
123
122
|
state = log(`testing ${k}`)(state);
|
|
124
|
-
[ts, state] = test('| ')(v.
|
|
123
|
+
[ts, state] = test('| ')(v.default)([ts, state])
|
|
125
124
|
}
|
|
126
125
|
return [ts, state]
|
|
127
126
|
}
|
package/dev/test.mjs
CHANGED
|
@@ -24,7 +24,7 @@ const anyLog = f => s => state => {
|
|
|
24
24
|
|
|
25
25
|
/** @type {<T>(f: () => T) => Result<T, unknown>} */
|
|
26
26
|
const tryCatch = f => {
|
|
27
|
-
//
|
|
27
|
+
// `try catch` is not allowed in FunctionalScript.
|
|
28
28
|
try {
|
|
29
29
|
return ['ok', f()]
|
|
30
30
|
} catch (e) {
|
|
@@ -45,7 +45,7 @@ const main = async() => {
|
|
|
45
45
|
const moduleMap = await loadModuleMap()
|
|
46
46
|
|
|
47
47
|
/** @type {any} */
|
|
48
|
-
const f = moduleMap['./dev/test/module.f.cjs'].
|
|
48
|
+
const f = moduleMap['./dev/test/module.f.cjs'].default
|
|
49
49
|
const r = f({
|
|
50
50
|
moduleMap,
|
|
51
51
|
log: anyLog(console.log),
|
package/index.f.cjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
// Generated file.
|
|
2
2
|
module.exports = {
|
|
3
|
-
types: {
|
|
4
|
-
nullable: require("./types/nullable/module.f.cjs"),
|
|
5
|
-
array: require("./types/array/module.f.cjs"),
|
|
6
|
-
function: require("./types/function/module.f.cjs"),
|
|
7
|
-
list: require("./types/list/module.f.cjs"),
|
|
8
|
-
btree: require("./types/btree/module.f.cjs"),
|
|
9
|
-
string: require("./types/string/module.f.cjs"),
|
|
10
|
-
map: require("./types/map/module.f.cjs"),
|
|
11
|
-
object: require("./types/object/module.f.cjs"),
|
|
12
|
-
bigint: require("./types/bigint/module.f.cjs"),
|
|
13
|
-
bigfloat: require("./types/bigfloat/module.f.cjs"),
|
|
14
|
-
sorted_list: require("./types/sorted_list/module.f.cjs"),
|
|
15
|
-
number: require("./types/number/module.f.cjs"),
|
|
16
|
-
range: require("./types/range/module.f.cjs"),
|
|
17
|
-
range_map: require("./types/range_map/module.f.cjs"),
|
|
18
|
-
result: require("./types/result/module.f.cjs"),
|
|
19
|
-
string_set: require("./types/string_set/module.f.cjs"),
|
|
20
|
-
sorted_set: require("./types/sorted_set/module.f.cjs"),
|
|
21
|
-
byte_set: require("./types/byte_set/module.f.cjs"),
|
|
22
|
-
nibble_set: require("./types/nibble_set/module.f.cjs"),
|
|
23
|
-
},
|
|
24
3
|
com: require("./com/module.f.cjs"),
|
|
25
|
-
text: require("./text/module.f.cjs"),
|
|
26
|
-
json: require("./json/module.f.cjs"),
|
|
27
|
-
js: {
|
|
28
|
-
tokenizer: require("./js/tokenizer/module.f.cjs"),
|
|
29
|
-
},
|
|
30
4
|
commonjs: require("./commonjs/module.f.cjs"),
|
|
31
5
|
dev: require("./dev/module.f.cjs"),
|
|
32
6
|
djs: require("./djs/module.f.cjs"),
|
|
33
7
|
fsc: require("./fsc/module.f.cjs"),
|
|
34
8
|
fsm: require("./fsm/module.f.cjs"),
|
|
35
9
|
html: require("./html/module.f.cjs"),
|
|
10
|
+
js: {
|
|
11
|
+
tokenizer: require("./js/tokenizer/module.f.cjs"),
|
|
12
|
+
},
|
|
13
|
+
json: require("./json/module.f.cjs"),
|
|
36
14
|
nodejs: require("./nodejs/module.f.cjs"),
|
|
37
15
|
prime_field: require("./prime_field/module.f.cjs"),
|
|
38
16
|
secp: require("./secp/module.f.cjs"),
|
|
39
17
|
sha2: require("./sha2/module.f.cjs"),
|
|
18
|
+
text: require("./text/module.f.cjs"),
|
|
19
|
+
types: {
|
|
20
|
+
array: require("./types/array/module.f.cjs"),
|
|
21
|
+
bigfloat: require("./types/bigfloat/module.f.cjs"),
|
|
22
|
+
bigint: require("./types/bigint/module.f.cjs"),
|
|
23
|
+
btree: require("./types/btree/module.f.cjs"),
|
|
24
|
+
byte_set: require("./types/byte_set/module.f.cjs"),
|
|
25
|
+
function: require("./types/function/module.f.cjs"),
|
|
26
|
+
list: require("./types/list/module.f.cjs"),
|
|
27
|
+
map: require("./types/map/module.f.cjs"),
|
|
28
|
+
nibble_set: require("./types/nibble_set/module.f.cjs"),
|
|
29
|
+
nullable: require("./types/nullable/module.f.cjs"),
|
|
30
|
+
number: require("./types/number/module.f.cjs"),
|
|
31
|
+
object: require("./types/object/module.f.cjs"),
|
|
32
|
+
range: require("./types/range/module.f.cjs"),
|
|
33
|
+
range_map: require("./types/range_map/module.f.cjs"),
|
|
34
|
+
result: require("./types/result/module.f.cjs"),
|
|
35
|
+
sorted_list: require("./types/sorted_list/module.f.cjs"),
|
|
36
|
+
sorted_set: require("./types/sorted_set/module.f.cjs"),
|
|
37
|
+
string: require("./types/string/module.f.cjs"),
|
|
38
|
+
string_set: require("./types/string_set/module.f.cjs"),
|
|
39
|
+
},
|
|
40
40
|
}
|
package/issues/README.md
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
# Issues
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Currently, we regenerate [./index.f.cjs](./index.f.cjs) using `npm run index` during CD (publishing). However, we don't check in CI if it was regenerated. The idea is that CI should check if all generated files in Git are updated:
|
|
8
|
-
- [package.json](./package.json) `version` property
|
|
9
|
-
- [jsr.json](./jsr.json), `version` property
|
|
10
|
-
- [index.f.cjs](./index.f.cjs)
|
|
11
|
-
|
|
12
|
-
`version` property should be `version` calculated on a `main` branch.
|
|
13
|
-
|
|
14
|
-
We may abandon the idea to publish on every commit on `main`. Instead, we will publish only we when we update a version in the `main` branch. This strategy can also work for Rust packages. The idea is that people can still reference from Git if they would like to have a not-published version of a package. We will still release in CI but only when there is a new version.
|
|
15
|
-
|
|
16
|
-
## Publishing
|
|
17
|
-
|
|
18
|
-
Before publishing, we have to be sure that
|
|
19
|
-
|
|
20
|
-
1. [index.f.cjs](./index.f.cjs) is up to date
|
|
21
|
-
2. `version` is updated in [jsr.json](./jsr.json) and [package.json](./package.json).
|
|
3
|
+
1. [test-debug](./test-debug.md).
|
|
4
|
+
2. [esm](./esm.md)
|
|
5
|
+
3. [publish](publish.md)
|
package/issues/publish.md
CHANGED
|
@@ -8,3 +8,38 @@ We are targeting the following systems:
|
|
|
8
8
|
- https://esm.sh/ optional
|
|
9
9
|
- Rust:
|
|
10
10
|
- https://crates.io/
|
|
11
|
+
|
|
12
|
+
## Creating `./index.f.cjs`
|
|
13
|
+
|
|
14
|
+
Currently, we regenerate [./index.f.cjs](./index.f.cjs) using `npm run index` during CD (publishing). However, we don't check in CI if it was regenerated. The idea is that CI should check if all generated files in Git are updated:
|
|
15
|
+
|
|
16
|
+
- [package.json](./package.json) `version` property
|
|
17
|
+
- [jsr.json](./jsr.json), `version` property
|
|
18
|
+
- [index.f.cjs](./index.f.cjs)
|
|
19
|
+
|
|
20
|
+
`version` property should be `version` calculated on a `main` branch.
|
|
21
|
+
|
|
22
|
+
We may abandon the idea to publish on every commit on `main`. Instead, we will publish only we when we update a version in the `main` branch. This strategy can also work for Rust packages. The idea is that people can still reference from Git if they would like to have a not-published version of a package. We will still release in CI but only when there is a new version.
|
|
23
|
+
|
|
24
|
+
## Publishing
|
|
25
|
+
|
|
26
|
+
Before publishing, we have to be sure that
|
|
27
|
+
|
|
28
|
+
1. [index.f.cjs](./index.f.cjs) is up to date
|
|
29
|
+
2. `version` is updated in [jsr.json](./jsr.json) and [package.json](./package.json).
|
|
30
|
+
|
|
31
|
+
## CI Jobs
|
|
32
|
+
|
|
33
|
+
### 1. Publishing (merge to `main`)
|
|
34
|
+
|
|
35
|
+
Check if the version is new, then publish.
|
|
36
|
+
|
|
37
|
+
### 2. CI
|
|
38
|
+
|
|
39
|
+
Errors:
|
|
40
|
+
|
|
41
|
+
- correct `index.f.mjs` is merged.
|
|
42
|
+
|
|
43
|
+
Warnings (not blocking CI):
|
|
44
|
+
|
|
45
|
+
- out of date lock files, such as `package-lock.json` and `Cargo.lock`.
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.589",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "index.f.cjs",
|
|
6
6
|
"scripts": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
},
|
|
32
32
|
"homepage": "https://github.com/functionalscript/functionalscript#readme",
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@types/node": "^22.10.
|
|
34
|
+
"@types/node": "^22.10.1",
|
|
35
35
|
"typescript": "^5.7.2"
|
|
36
36
|
}
|
|
37
37
|
}
|