functionalscript 0.1.608 → 0.2.0
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/CHANGELOG.md +10 -0
- package/Cargo.lock +4 -0
- package/Cargo.toml +4 -2
- package/README.md +1 -1
- package/com/cpp/module.f.d.mts +4 -8
- package/com/cpp/module.f.mjs +20 -25
- package/com/cpp/testlib.f.mjs +3 -4
- package/com/cs/module.f.d.mts +4 -8
- package/com/cs/module.f.mjs +18 -23
- package/com/cs/testlib.f.mjs +3 -5
- package/com/rust/module.f.d.mts +3 -7
- package/com/rust/module.f.mjs +25 -30
- package/com/rust/nanocom/src/cobject.rs +1 -1
- package/com/rust/testlib.f.mjs +3 -5
- package/com/test/build.f.d.mts +2 -2
- package/com/test/build.f.mjs +2 -2
- package/com/test/build.mjs +4 -4
- package/com/test/rust/src/lib.rs +4 -4
- package/com/types/module.f.d.mts +5 -10
- package/com/types/module.f.mjs +5 -12
- package/commonjs/build/module.f.d.mts +13 -17
- package/commonjs/build/module.f.mjs +23 -28
- package/commonjs/build/test.f.mjs +4 -4
- package/commonjs/module/function/module.f.d.mts +0 -2
- package/commonjs/module/function/module.f.mjs +0 -2
- package/commonjs/module/module.f.d.mts +16 -21
- package/commonjs/module/module.f.mjs +2 -9
- package/commonjs/module.d.mts +1 -5
- package/commonjs/module.f.d.mts +0 -2
- package/commonjs/module.f.mjs +0 -2
- package/commonjs/module.mjs +2 -7
- package/commonjs/package/dependencies/module.f.d.mts +3 -7
- package/commonjs/package/dependencies/module.f.mjs +5 -10
- package/commonjs/package/dependencies/test.f.mjs +1 -1
- package/commonjs/package/module.f.d.mts +12 -18
- package/commonjs/package/module.f.mjs +6 -13
- package/commonjs/package/test.f.mjs +1 -1
- package/commonjs/path/module.f.d.mts +25 -32
- package/commonjs/path/module.f.mjs +12 -23
- package/commonjs/path/test.f.mjs +11 -11
- package/commonjs/test.mjs +1 -1
- package/dev/module.f.d.mts +1 -4
- package/dev/module.f.mjs +1 -4
- package/dev/module.mjs +1 -1
- package/dev/test/module.f.d.mts +2 -3
- package/dev/test/module.f.mjs +5 -7
- package/djs/module.f.d.mts +13 -18
- package/djs/module.f.mjs +12 -19
- package/djs/parser/module.f.d.mts +53 -37
- package/djs/parser/module.f.mjs +278 -131
- package/djs/parser/test.f.d.mts +4 -0
- package/djs/parser/test.f.mjs +186 -70
- package/djs/test.f.mjs +4 -4
- package/djs/tokenizer/module.f.d.mts +6 -10
- package/djs/tokenizer/module.f.mjs +19 -22
- package/djs/tokenizer/test.f.mjs +7 -7
- package/doc/LANGUAGE.md +17 -16
- package/doc/README.md +14 -50
- package/fsc/README.md +0 -3
- package/fsc/module.f.d.mts +4 -9
- package/fsc/module.f.mjs +17 -24
- package/fsc/test.f.mjs +3 -3
- package/fsm/README.md +1 -1
- package/fsm/module.f.d.mts +13 -20
- package/fsm/module.f.mjs +27 -38
- package/fsm/test.f.mjs +8 -8
- package/html/README.md +24 -0
- package/html/module.f.d.mts +7 -12
- package/html/module.f.mjs +14 -23
- package/html/test.f.mjs +4 -4
- package/issues/01-test-debug.md +3 -0
- package/issues/{publish.md → 05-publish.md} +8 -8
- package/issues/17-djs-extension.md +6 -0
- package/issues/README.md +20 -13
- package/issues/lang/1000-json.md +38 -0
- package/issues/lang/2110-default-export.md +2 -2
- package/issues/lang/2310-undefined.md +1 -1
- package/issues/lang/2330-property-accessor.md +225 -0
- package/issues/lang/2360-built-in.md +54 -47
- package/issues/lang/3240-export.md +44 -0
- package/issues/lang/README.md +64 -22
- package/issues/test.f.d.mts +16 -0
- package/issues/test.f.mjs +57 -0
- package/js/tokenizer/module.f.d.mts +18 -17
- package/js/tokenizer/module.f.mjs +80 -61
- package/js/tokenizer/test.f.mjs +15 -12
- package/json/module.f.d.mts +18 -26
- package/json/module.f.mjs +18 -31
- package/json/parser/module.f.d.mts +9 -13
- package/json/parser/module.f.mjs +9 -14
- package/json/parser/test.f.mjs +7 -7
- package/json/serializer/module.f.d.mts +11 -20
- package/json/serializer/module.f.mjs +14 -29
- package/json/serializer/test.f.mjs +2 -2
- package/json/test.f.mjs +3 -3
- package/json/tokenizer/module.f.d.mts +6 -10
- package/json/tokenizer/module.f.mjs +16 -20
- package/json/tokenizer/test.f.mjs +6 -6
- package/jsr.json +1 -1
- package/nanvm-lib/Cargo.toml +6 -0
- package/nanvm-lib/src/extension.rs +119 -0
- package/nanvm-lib/src/interface.rs +136 -0
- package/nanvm-lib/src/lib.rs +7 -0
- package/nanvm-lib/src/naive.rs +229 -0
- package/nanvm-lib/src/nanenum.rs +230 -0
- package/nanvm-lib/src/nullish.rs +7 -0
- package/nanvm-lib/src/sign.rs +5 -0
- package/nanvm-lib/src/simple.rs +32 -0
- package/nanvm-lib/tests/test.f.d.mts +36 -0
- package/nanvm-lib/tests/test.f.mjs +79 -0
- package/nanvm-lib/tests/test.rs +108 -0
- package/nodejs/version/main.mjs +1 -1
- package/nodejs/version/module.f.d.mts +4 -9
- package/nodejs/version/module.f.mjs +2 -7
- package/nodejs/version/test.f.mjs +3 -3
- package/package.json +1 -1
- package/prime_field/module.f.d.mts +20 -23
- package/prime_field/module.f.mjs +9 -12
- package/prime_field/test.f.mjs +1 -1
- package/secp/module.f.d.mts +27 -28
- package/secp/module.f.mjs +38 -39
- package/secp/test.f.mjs +4 -4
- package/sha2/module.f.d.mts +8 -16
- package/sha2/module.f.mjs +7 -20
- package/sha2/test.f.mjs +4 -4
- package/text/README.md +2 -2
- package/text/ascii/module.f.d.mts +69 -72
- package/text/ascii/module.f.mjs +5 -10
- package/text/ascii/test.f.mjs +3 -3
- package/text/module.f.d.mts +9 -14
- package/text/module.f.mjs +7 -14
- package/text/sgr/module.f.d.mts +7 -9
- package/text/sgr/module.f.mjs +2 -4
- package/text/test.f.mjs +3 -3
- package/text/utf16/module.f.d.mts +8 -15
- package/text/utf16/module.f.mjs +17 -28
- package/text/utf16/test.f.mjs +5 -5
- package/text/utf8/module.f.d.mts +4 -9
- package/text/utf8/module.f.mjs +9 -16
- package/text/utf8/test.f.mjs +4 -4
- package/types/array/module.f.d.mts +14 -24
- package/types/array/module.f.mjs +8 -25
- package/types/array/test.f.mjs +3 -3
- package/types/bigfloat/module.f.d.mts +4 -9
- package/types/bigfloat/module.f.mjs +3 -10
- package/types/bigfloat/test.f.mjs +1 -1
- package/types/bigint/module.f.d.mts +16 -64
- package/types/bigint/module.f.mjs +11 -30
- package/types/bigint/test.f.mjs +1 -1
- package/types/btree/find/module.f.d.mts +20 -26
- package/types/btree/find/module.f.mjs +8 -17
- package/types/btree/find/test.f.mjs +7 -7
- package/types/btree/module.f.d.mts +4 -8
- package/types/btree/module.f.mjs +6 -11
- package/types/btree/remove/module.f.d.mts +7 -12
- package/types/btree/remove/module.f.mjs +10 -17
- package/types/btree/remove/test.f.mjs +5 -5
- package/types/btree/set/module.f.d.mts +3 -7
- package/types/btree/set/module.f.mjs +4 -9
- package/types/btree/set/test.f.mjs +4 -4
- package/types/btree/test.f.mjs +9 -9
- package/types/btree/types/module.f.d.mts +0 -2
- package/types/btree/types/module.f.mjs +0 -2
- package/types/byte_set/module.f.d.mts +16 -29
- package/types/byte_set/module.f.mjs +14 -39
- package/types/byte_set/test.f.mjs +5 -5
- package/types/function/compare/module.f.d.mts +9 -15
- package/types/function/compare/module.f.mjs +3 -12
- package/types/function/compare/test.f.mjs +1 -1
- package/types/function/module.f.d.mts +20 -27
- package/types/function/module.f.mjs +4 -15
- package/types/function/operator/module.f.d.mts +28 -43
- package/types/function/operator/module.f.mjs +14 -41
- package/types/function/test.f.mjs +1 -1
- package/types/list/module.f.d.mts +56 -91
- package/types/list/module.f.mjs +45 -114
- package/types/list/test.f.mjs +10 -10
- package/types/map/module.f.d.mts +15 -24
- package/types/map/module.f.mjs +15 -30
- package/types/map/test.f.mjs +2 -2
- package/types/nibble_set/module.f.d.mts +10 -20
- package/types/nibble_set/module.f.mjs +7 -24
- package/types/nibble_set/test.f.mjs +2 -2
- package/types/nullable/module.f.d.mts +3 -8
- package/types/nullable/module.f.mjs +2 -9
- package/types/nullable/test.f.mjs +1 -1
- package/types/number/module.f.d.mts +7 -13
- package/types/number/module.f.mjs +8 -19
- package/types/number/test.f.mjs +1 -1
- package/types/object/module.f.d.mts +11 -18
- package/types/object/module.f.mjs +9 -20
- package/types/object/test.f.mjs +1 -1
- package/types/range/module.f.d.mts +3 -8
- package/types/range/module.f.mjs +2 -9
- package/types/range/test.f.mjs +1 -1
- package/types/range_map/module.f.d.mts +9 -15
- package/types/range_map/module.f.mjs +9 -18
- package/types/range_map/test.f.mjs +32 -32
- package/types/result/module.d.mts +3 -3
- package/types/result/module.f.d.mts +6 -12
- package/types/result/module.f.mjs +3 -12
- package/types/result/module.mjs +2 -2
- package/types/sorted_list/module.f.d.mts +22 -28
- package/types/sorted_list/module.f.mjs +10 -19
- package/types/sorted_list/test.f.mjs +7 -7
- package/types/sorted_set/module.f.d.mts +6 -12
- package/types/sorted_set/module.f.mjs +7 -16
- package/types/sorted_set/test.f.mjs +7 -7
- package/types/string/module.f.d.mts +8 -14
- package/types/string/module.f.mjs +10 -21
- package/types/string/test.f.mjs +2 -2
- package/types/string_set/module.f.d.mts +8 -16
- package/types/string_set/module.f.mjs +12 -27
- package/types/string_set/test.f.mjs +1 -1
- package/issues/lang/2351-property-accessor.md +0 -44
- package/issues/lang/2352-property-call.md +0 -43
- package/issues/lang/2353-property-at.md +0 -19
- package/issues/test-debug.md +0 -12
- /package/issues/{esm.md → 02-esm.md} +0 -0
- /package/issues/{djs.md → 03-djs.md} +0 -0
- /package/issues/{fs-load.md → 11-fs-load.md} +0 -0
- /package/issues/lang/{2330-grouping.md → 2350-grouping.md} +0 -0
package/com/types/module.f.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
2
|
import * as O from '../../types/object/module.f.mjs'
|
|
3
|
-
import
|
|
4
|
-
import f from '../../types/function/module.f.mjs'
|
|
3
|
+
import * as list from '../../types/list/module.f.mjs'
|
|
4
|
+
import * as f from '../../types/function/module.f.mjs'
|
|
5
5
|
const { compose } = f
|
|
6
6
|
const { filter } = list
|
|
7
7
|
const { entries } = Object
|
|
@@ -60,15 +60,8 @@ const isParam = ([name]) => name !== '_'
|
|
|
60
60
|
|
|
61
61
|
const filterParam = filter(isParam)
|
|
62
62
|
|
|
63
|
-
/** @type {(fa: FieldArray) =>
|
|
64
|
-
const paramList = compose(entries)(filterParam)
|
|
63
|
+
/** @type {(fa: FieldArray) => list.List<Field> } */
|
|
64
|
+
export const paramList = compose(entries)(filterParam)
|
|
65
65
|
|
|
66
66
|
/** @type {<T>(v: T) => (f: (type: Type) => T) => (fa: FieldArray) => T} */
|
|
67
|
-
const result = v => f => fa => '_' in fa ? f(fa._) : v
|
|
68
|
-
|
|
69
|
-
export default {
|
|
70
|
-
/** @readonly */
|
|
71
|
-
paramList,
|
|
72
|
-
/** @readonly */
|
|
73
|
-
result,
|
|
74
|
-
}
|
|
67
|
+
export const result = v => f => fa => '_' in fa ? f(fa._) : v
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { getOrBuild };
|
|
3
|
-
}
|
|
4
|
-
export default _default;
|
|
5
|
-
export type Config<M> = {
|
|
6
|
-
readonly packageGet: packageT.Get;
|
|
7
|
-
readonly moduleMapInterface: moduleT.MapInterface<M>;
|
|
8
|
-
readonly moduleId: moduleT.Id;
|
|
9
|
-
readonly moduleMap: M;
|
|
10
|
-
};
|
|
11
|
-
export type Result<M> = readonly [moduleT.State, M];
|
|
12
1
|
/**
|
|
13
2
|
* @type {(compile: function_.Compile) =>
|
|
14
|
-
* (packageGet:
|
|
15
|
-
* <M>(moduleMapInterface:
|
|
16
|
-
* (moduleId:
|
|
3
|
+
* (packageGet: package_.Get) =>
|
|
4
|
+
* <M>(moduleMapInterface: module.MapInterface<M>) =>
|
|
5
|
+
* (moduleId: module.Id) =>
|
|
17
6
|
* (moduleMap: M) =>
|
|
18
7
|
* Result<M>
|
|
19
8
|
* }
|
|
20
9
|
*/
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
10
|
+
export const getOrBuild: (compile: function_.Compile) => (packageGet: package_.Get) => <M>(moduleMapInterface: module.MapInterface<M>) => (moduleId: module.Id) => (moduleMap: M) => Result<M>;
|
|
11
|
+
export type Config<M> = {
|
|
12
|
+
readonly packageGet: package_.Get;
|
|
13
|
+
readonly moduleMapInterface: module.MapInterface<M>;
|
|
14
|
+
readonly moduleId: module.Id;
|
|
15
|
+
readonly moduleMap: M;
|
|
16
|
+
};
|
|
17
|
+
export type Result<M> = readonly [module.State, M];
|
|
24
18
|
import * as function_ from '../module/function/module.f.mjs';
|
|
19
|
+
import * as package_ from '../package/module.f.mjs';
|
|
20
|
+
import * as module from '../module/module.f.mjs';
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import * as
|
|
3
|
-
import
|
|
4
|
-
const { idToString, dir } =
|
|
2
|
+
import * as package_ from '../package/module.f.mjs'
|
|
3
|
+
import * as module from '../module/module.f.mjs'
|
|
4
|
+
const { idToString, dir } = module
|
|
5
5
|
import * as function_ from '../module/function/module.f.mjs'
|
|
6
|
-
import
|
|
6
|
+
import * as map from '../../types/map/module.f.mjs'
|
|
7
7
|
const { empty: mapEmpty, setReplace } = map
|
|
8
|
-
import object from '../../types/object/module.f.mjs'
|
|
8
|
+
import * as object from '../../types/object/module.f.mjs'
|
|
9
9
|
const { fromMap } = object
|
|
10
|
-
import path from '../path/module.f.mjs'
|
|
10
|
+
import * as path from '../path/module.f.mjs'
|
|
11
11
|
const { parseAndFind } = path
|
|
12
|
-
import
|
|
12
|
+
import * as stringSet from '../../types/string_set/module.f.mjs'
|
|
13
13
|
const { set: setSet, contains: setContains, empty: stringSetEmpty } = stringSet
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* @template M
|
|
17
17
|
* @typedef {{
|
|
18
|
-
* readonly packageGet:
|
|
19
|
-
* readonly moduleMapInterface:
|
|
20
|
-
* readonly moduleId:
|
|
18
|
+
* readonly packageGet: package_.Get
|
|
19
|
+
* readonly moduleMapInterface: module.MapInterface<M>
|
|
20
|
+
* readonly moduleId: module.Id
|
|
21
21
|
* readonly moduleMap: M
|
|
22
22
|
* }} Config
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* @template M
|
|
27
|
-
* @typedef {readonly[
|
|
27
|
+
* @typedef {readonly[module.State, M]} Result
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
/** @type {<M>(moduleMap: M) => Result<M>} */
|
|
@@ -32,19 +32,19 @@ const notFound = moduleMap => [['error', ['file not found']], moduleMap]
|
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
34
|
* @type {(compile: function_.Compile) =>
|
|
35
|
-
* (packageGet:
|
|
36
|
-
* <M>(moduleMapInterface:
|
|
37
|
-
* (moduleId:
|
|
35
|
+
* (packageGet: package_.Get) =>
|
|
36
|
+
* <M>(moduleMapInterface: module.MapInterface<M>) =>
|
|
37
|
+
* (moduleId: module.Id) =>
|
|
38
38
|
* (moduleMap: M) =>
|
|
39
39
|
* Result<M>
|
|
40
40
|
* }
|
|
41
41
|
*/
|
|
42
|
-
const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
43
|
-
/** @typedef {typeof moduleMapInterface extends
|
|
42
|
+
export const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
43
|
+
/** @typedef {typeof moduleMapInterface extends module.MapInterface<infer M> ? M : never} M */
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* @type {(buildSet:
|
|
47
|
-
* (moduleId:
|
|
46
|
+
* @type {(buildSet: stringSet.StringSet) =>
|
|
47
|
+
* (moduleId: module.Id) =>
|
|
48
48
|
* (source: string) =>
|
|
49
49
|
* (moduleMap: M) =>
|
|
50
50
|
* Result<M>}
|
|
@@ -53,9 +53,9 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
|
53
53
|
const moduleIdStr = idToString(moduleId)
|
|
54
54
|
const buildSet1 = setSet(moduleIdStr)(buildSet)
|
|
55
55
|
const moduleDir = dir(moduleId)
|
|
56
|
-
/** @type {function_.Require<readonly[
|
|
56
|
+
/** @type {function_.Require<readonly[map.Map<string>, M]>} */
|
|
57
57
|
const require_ = p => ([requireMap, m]) => {
|
|
58
|
-
/** @type {(e: unknown) => function_.Result<readonly[
|
|
58
|
+
/** @type {(e: unknown) => function_.Result<readonly[map.Map<string>, M]>} */
|
|
59
59
|
const error = e => [['error', e], [requireMap, m]]
|
|
60
60
|
if (moduleDir === null) { return error('file not found') }
|
|
61
61
|
const r = parseAndFind(packageGet)(moduleDir)(p)
|
|
@@ -66,9 +66,9 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
|
66
66
|
return [state[0] === 'error' ? state : ['ok', state[1].exports], [setReplace(p)(rIdStr)(requireMap), m1]]
|
|
67
67
|
}
|
|
68
68
|
return source => moduleMap => {
|
|
69
|
-
/** @type {(s:
|
|
69
|
+
/** @type {(s: module.State) => (m: M) => Result<M>} */
|
|
70
70
|
const set = s => m => [s, moduleMapInterface.setReplace(moduleIdStr)(s)(m)]
|
|
71
|
-
/** @type {(e:
|
|
71
|
+
/** @type {(e: module.Error) => (m: M) => Result<M>} */
|
|
72
72
|
const error = e => set(['error', e])
|
|
73
73
|
// check compilation
|
|
74
74
|
const [kind, result] = compile(source)
|
|
@@ -81,7 +81,7 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
|
81
81
|
return x(moduleMap2)
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
/** @type {(moduleId:
|
|
84
|
+
/** @type {(moduleId: module.Id) => (moduleMap: M) => Result<M>} */
|
|
85
85
|
const f = moduleId => moduleMap => {
|
|
86
86
|
const moduleIdStr = idToString(moduleId)
|
|
87
87
|
// check moduleMap
|
|
@@ -98,8 +98,3 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
|
98
98
|
}
|
|
99
99
|
return f
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
export default {
|
|
103
|
-
/** @readonly */
|
|
104
|
-
getOrBuild,
|
|
105
|
-
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import _ from './module.f.mjs'
|
|
2
|
-
import
|
|
1
|
+
import * as _ from './module.f.mjs'
|
|
2
|
+
import * as map from '../../types/map/module.f.mjs'
|
|
3
3
|
import * as Module from '../module/module.f.mjs'
|
|
4
4
|
import * as ModuleFunction from '../module/function/module.f.mjs'
|
|
5
5
|
import * as Result from '../../types/result/module.f.mjs'
|
|
6
6
|
import * as Package from '../package/module.f.mjs'
|
|
7
|
-
import o from '../../types/object/module.f.mjs'
|
|
7
|
+
import * as o from '../../types/object/module.f.mjs'
|
|
8
8
|
const { at } = o
|
|
9
9
|
|
|
10
10
|
/** @type {{ readonly [k in string]?: Result.Result<ModuleFunction.Function_, unknown> }} */
|
|
@@ -69,7 +69,7 @@ const packageGet = packageId => {
|
|
|
69
69
|
const getOrBuild = _.getOrBuild
|
|
70
70
|
(compile)
|
|
71
71
|
(packageGet)
|
|
72
|
-
(/** @type {Module.MapInterface<
|
|
72
|
+
(/** @type {Module.MapInterface<map.Map<Module.State>>} */(map))
|
|
73
73
|
|
|
74
74
|
export default () => {
|
|
75
75
|
let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(map.empty)
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
declare const _default: {};
|
|
2
|
-
export default _default;
|
|
3
1
|
export type Function_ = <M>(require: Require<M>) => (prior: M) => Result<M>;
|
|
4
2
|
export type Result<M> = readonly [TypesResult.Result<unknown, unknown>, M];
|
|
5
3
|
export type Require<M> = (path: string) => (prior: M) => Result<M>;
|
|
@@ -1,22 +1,3 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { dir };
|
|
3
|
-
export { idToString };
|
|
4
|
-
}
|
|
5
|
-
export default _default;
|
|
6
|
-
export type MapInterface<M> = {
|
|
7
|
-
readonly at: (moduleId: string) => (moduleMap: M) => State | null;
|
|
8
|
-
readonly setReplace: (moduleId: string) => (moduleState: State) => (moduleMap: M) => M;
|
|
9
|
-
};
|
|
10
|
-
export type State = readonly ["ok", Module] | readonly ["error", Error];
|
|
11
|
-
export type Module = {
|
|
12
|
-
readonly exports: unknown;
|
|
13
|
-
readonly requireMap: O.Map<string>;
|
|
14
|
-
};
|
|
15
|
-
export type Error = ["file not found"] | ["compilation error", unknown] | ["runtime error", unknown] | ["circular reference"];
|
|
16
|
-
export type Id = {
|
|
17
|
-
readonly package: string;
|
|
18
|
-
readonly path: readonly string[];
|
|
19
|
-
};
|
|
20
1
|
/**
|
|
21
2
|
* @template M
|
|
22
3
|
* @typedef {{
|
|
@@ -51,7 +32,21 @@ export type Id = {
|
|
|
51
32
|
* }} Id
|
|
52
33
|
*/
|
|
53
34
|
/** @type {(id: Id) => Id | null} */
|
|
54
|
-
|
|
35
|
+
export const dir: (id: Id) => Id | null;
|
|
55
36
|
/** @type {(id: Id) => string} */
|
|
56
|
-
|
|
37
|
+
export const idToString: (id: Id) => string;
|
|
38
|
+
export type MapInterface<M> = {
|
|
39
|
+
readonly at: (moduleId: string) => (moduleMap: M) => State | null;
|
|
40
|
+
readonly setReplace: (moduleId: string) => (moduleState: State) => (moduleMap: M) => M;
|
|
41
|
+
};
|
|
42
|
+
export type State = readonly ["ok", Module] | readonly ["error", Error];
|
|
43
|
+
export type Module = {
|
|
44
|
+
readonly exports: unknown;
|
|
45
|
+
readonly requireMap: O.Map<string>;
|
|
46
|
+
};
|
|
47
|
+
export type Error = ["file not found"] | ["compilation error", unknown] | ["runtime error", unknown] | ["circular reference"];
|
|
48
|
+
export type Id = {
|
|
49
|
+
readonly package: string;
|
|
50
|
+
readonly path: readonly string[];
|
|
51
|
+
};
|
|
57
52
|
import * as O from '../../types/object/module.f.mjs';
|
|
@@ -40,7 +40,7 @@ import * as O from '../../types/object/module.f.mjs'
|
|
|
40
40
|
*/
|
|
41
41
|
|
|
42
42
|
/** @type {(id: Id) => Id | null} */
|
|
43
|
-
const dir = id => {
|
|
43
|
+
export const dir = id => {
|
|
44
44
|
const len = id.path.length
|
|
45
45
|
if (len < 1) { return null }
|
|
46
46
|
return {
|
|
@@ -50,11 +50,4 @@ const dir = id => {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/** @type {(id: Id) => string} */
|
|
53
|
-
const idToString = id => `${id.package}/${id.path.join('/')}`
|
|
54
|
-
|
|
55
|
-
export default {
|
|
56
|
-
/** @readonly */
|
|
57
|
-
dir,
|
|
58
|
-
/** @readonly */
|
|
59
|
-
idToString,
|
|
60
|
-
}
|
|
53
|
+
export const idToString = id => `${id.package}/${id.path.join('/')}`
|
package/commonjs/module.d.mts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { compile };
|
|
3
|
-
}
|
|
4
|
-
export default _default;
|
|
5
1
|
/** @type {ModuleFunction.Compile} */
|
|
6
|
-
|
|
2
|
+
export const compile: ModuleFunction.Compile;
|
|
7
3
|
import * as ModuleFunction from './module/function/module.f.mjs';
|
package/commonjs/module.f.d.mts
CHANGED
package/commonjs/module.f.mjs
CHANGED
package/commonjs/module.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import unsafeResult from '../types/result/module.mjs'
|
|
2
2
|
const { tryCatch } = unsafeResult
|
|
3
|
-
import result from '../types/result/module.f.mjs'
|
|
3
|
+
import * as result from '../types/result/module.f.mjs'
|
|
4
4
|
const { unwrap } = result
|
|
5
5
|
import * as ModuleFunction from './module/function/module.f.mjs'
|
|
6
6
|
|
|
@@ -23,11 +23,6 @@ const build = f => immutableRequire => mutableData => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** @type {ModuleFunction.Compile} */
|
|
26
|
-
const compile = source =>
|
|
26
|
+
export const compile = source =>
|
|
27
27
|
// Side effect: a `Function` constructor is not allowed in FunctionalScript.
|
|
28
28
|
tryCatch(() => build(Function('module', 'require', `"use strict";${source}`)))
|
|
29
|
-
|
|
30
|
-
export default {
|
|
31
|
-
/** @readonly */
|
|
32
|
-
compile,
|
|
33
|
-
}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
}
|
|
4
|
-
export default _default;
|
|
1
|
+
/** @type {(j: json.Unknown) => j is DependenciesJson} */
|
|
2
|
+
export const isDependenciesJson: (j: json.Unknown) => j is DependenciesJson;
|
|
5
3
|
export type DependencyJson = readonly [string, string];
|
|
6
4
|
export type DependencyMapJson = { readonly [k in string]: string; };
|
|
7
5
|
export type DependenciesJson = DependencyMapJson | null;
|
|
8
|
-
|
|
9
|
-
declare const isDependenciesJson: (j: Json.Unknown) => j is DependenciesJson;
|
|
10
|
-
import * as Json from '../../../json/module.f.mjs';
|
|
6
|
+
import * as json from '../../../json/module.f.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as json from '../../../json/module.f.mjs'
|
|
3
3
|
const { isObject } = json
|
|
4
|
-
import list from '../../../types/list/module.f.mjs'
|
|
4
|
+
import * as list from '../../../types/list/module.f.mjs'
|
|
5
5
|
const { map, every } = list
|
|
6
6
|
const { entries } = Object
|
|
7
7
|
|
|
@@ -11,17 +11,12 @@ const { entries } = Object
|
|
|
11
11
|
|
|
12
12
|
/** @typedef {DependencyMapJson|null} DependenciesJson */
|
|
13
13
|
|
|
14
|
-
/** @type {(entry:
|
|
14
|
+
/** @type {(entry: json.Entry) => boolean} */
|
|
15
15
|
const isDependencyJson = ([, v]) => typeof v === 'string'
|
|
16
16
|
|
|
17
|
-
/** @type {(j:
|
|
18
|
-
const isDependenciesJson = j => {
|
|
17
|
+
/** @type {(j: json.Unknown) => j is DependenciesJson} */
|
|
18
|
+
export const isDependenciesJson = j => {
|
|
19
19
|
if (j === null) { return true }
|
|
20
20
|
if (!isObject(j)) { return false }
|
|
21
21
|
return every(map(isDependencyJson)(entries(j)))
|
|
22
22
|
}
|
|
23
|
-
|
|
24
|
-
export default {
|
|
25
|
-
/** @readonly */
|
|
26
|
-
isDependenciesJson,
|
|
27
|
-
}
|
|
@@ -1,27 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* readonly name: string
|
|
4
|
+
* readonly version: string
|
|
5
|
+
* readonly dependencies?: dependencies.DependenciesJson
|
|
6
|
+
* }} PackageJson
|
|
7
|
+
*/
|
|
8
|
+
/** @type {(j: json.Unknown) => j is PackageJson} */
|
|
9
|
+
export const isPackageJson: (j: json.Unknown) => j is PackageJson;
|
|
6
10
|
export type PackageJson = {
|
|
7
11
|
readonly name: string;
|
|
8
12
|
readonly version: string;
|
|
9
|
-
readonly dependencies?:
|
|
13
|
+
readonly dependencies?: dependencies.DependenciesJson;
|
|
10
14
|
};
|
|
11
15
|
export type Package = {
|
|
12
16
|
readonly dependency: (localPackageId: string) => string | null;
|
|
13
17
|
readonly file: (localFileId: string) => string | null;
|
|
14
18
|
};
|
|
15
19
|
export type Get = (packageId: string) => Package | null;
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
* @typedef {{
|
|
19
|
-
* readonly name: string
|
|
20
|
-
* readonly version: string
|
|
21
|
-
* readonly dependencies?: Dependencies.DependenciesJson
|
|
22
|
-
* }} PackageJson
|
|
23
|
-
*/
|
|
24
|
-
/** @type {(j: Json.Unknown) => j is PackageJson} */
|
|
25
|
-
declare const isPackageJson: (j: Json.Unknown) => j is PackageJson;
|
|
26
|
-
import * as Dependencies from './dependencies/module.f.mjs';
|
|
27
|
-
import * as Json from '../../json/module.f.mjs';
|
|
20
|
+
import * as json from '../../json/module.f.mjs';
|
|
21
|
+
import * as dependencies from './dependencies/module.f.mjs';
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as json from '../../json/module.f.mjs'
|
|
3
3
|
const { isObject } = json
|
|
4
|
-
import
|
|
4
|
+
import * as dependencies from './dependencies/module.f.mjs'
|
|
5
5
|
const { isDependenciesJson } = dependencies
|
|
6
|
-
import o from '../../types/object/module.f.mjs'
|
|
6
|
+
import * as o from '../../types/object/module.f.mjs'
|
|
7
7
|
const { at } = o
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* @typedef {{
|
|
11
11
|
* readonly name: string
|
|
12
12
|
* readonly version: string
|
|
13
|
-
* readonly dependencies?:
|
|
13
|
+
* readonly dependencies?: dependencies.DependenciesJson
|
|
14
14
|
* }} PackageJson
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
/** @type {(j:
|
|
18
|
-
const isPackageJson = j => {
|
|
17
|
+
/** @type {(j: json.Unknown) => j is PackageJson} */
|
|
18
|
+
export const isPackageJson = j => {
|
|
19
19
|
if (!isObject(j)) { return false }
|
|
20
20
|
if (typeof j.name !== 'string') { return false }
|
|
21
21
|
if (typeof j.version !== 'string') { return false }
|
|
@@ -34,10 +34,3 @@ const isPackageJson = j => {
|
|
|
34
34
|
* @note Current package has an empty string '' as a packageId.
|
|
35
35
|
* @typedef {(packageId: string) => Package | null} Get
|
|
36
36
|
*/
|
|
37
|
-
|
|
38
|
-
export default {
|
|
39
|
-
/** @readonly */
|
|
40
|
-
dependencies,
|
|
41
|
-
/** @readonly */
|
|
42
|
-
isPackageJson,
|
|
43
|
-
}
|
|
@@ -1,30 +1,5 @@
|
|
|
1
|
-
declare namespace _default {
|
|
2
|
-
export { parseLocal };
|
|
3
|
-
export { parseGlobal };
|
|
4
|
-
export { parse };
|
|
5
|
-
export { parseAndFind };
|
|
6
|
-
}
|
|
7
|
-
export default _default;
|
|
8
|
-
export type Items = readonly string[];
|
|
9
|
-
export type LocalPath = {
|
|
10
|
-
readonly external: boolean;
|
|
11
|
-
readonly dir: boolean;
|
|
12
|
-
readonly items: Items;
|
|
13
|
-
};
|
|
14
|
-
export type OptionList = readonly [List.List<string>] | null;
|
|
15
|
-
export type IdPath = readonly [string, List.List<string>];
|
|
16
|
-
export type Path = {
|
|
17
|
-
readonly package: string;
|
|
18
|
-
readonly items: Items;
|
|
19
|
-
readonly dir: boolean;
|
|
20
|
-
};
|
|
21
|
-
export type FoundResult = {
|
|
22
|
-
readonly id: Module.Id;
|
|
23
|
-
readonly source: string;
|
|
24
|
-
};
|
|
25
|
-
export type Result = FoundResult | null;
|
|
26
1
|
/** @type {(local: string) => (path: string) => LocalPath|null} */
|
|
27
|
-
|
|
2
|
+
export const parseLocal: (local: string) => (path: string) => LocalPath | null;
|
|
28
3
|
/**
|
|
29
4
|
* @typedef {{
|
|
30
5
|
* readonly package: string,
|
|
@@ -35,10 +10,10 @@ declare const parseLocal: (local: string) => (path: string) => LocalPath | null;
|
|
|
35
10
|
/**
|
|
36
11
|
* @type {(d: (local: string) => string|null) =>
|
|
37
12
|
* (dir: boolean) =>
|
|
38
|
-
* (items:
|
|
13
|
+
* (items: list.List<string>) =>
|
|
39
14
|
* Path|null}
|
|
40
15
|
*/
|
|
41
|
-
|
|
16
|
+
export const parseGlobal: (d: (local: string) => string | null) => (dir: boolean) => (items: list.List<string>) => Path | null;
|
|
42
17
|
/**
|
|
43
18
|
* @type {(packageId: string) =>
|
|
44
19
|
* (dependencies: (local: string) => string|null) =>
|
|
@@ -46,7 +21,7 @@ declare const parseGlobal: (d: (local: string) => string | null) => (dir: boolea
|
|
|
46
21
|
* (path: string) =>
|
|
47
22
|
* Path|null }
|
|
48
23
|
*/
|
|
49
|
-
|
|
24
|
+
export const parse: (packageId: string) => (dependencies: (local: string) => string | null) => (local: string) => (path: string) => Path | null;
|
|
50
25
|
/**
|
|
51
26
|
* @typedef {{
|
|
52
27
|
* readonly id: Module.Id
|
|
@@ -61,7 +36,25 @@ declare const parse: (packageId: string) => (dependencies: (local: string) => st
|
|
|
61
36
|
* Result
|
|
62
37
|
* }
|
|
63
38
|
*/
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
39
|
+
export const parseAndFind: (packageGet: Package.Get) => (moduleId: Module.Id) => (path: string) => Result;
|
|
40
|
+
export type Items = readonly string[];
|
|
41
|
+
export type LocalPath = {
|
|
42
|
+
readonly external: boolean;
|
|
43
|
+
readonly dir: boolean;
|
|
44
|
+
readonly items: Items;
|
|
45
|
+
};
|
|
46
|
+
export type OptionList = readonly [list.List<string>] | null;
|
|
47
|
+
export type IdPath = readonly [string, list.List<string>];
|
|
48
|
+
export type Path = {
|
|
49
|
+
readonly package: string;
|
|
50
|
+
readonly items: Items;
|
|
51
|
+
readonly dir: boolean;
|
|
52
|
+
};
|
|
53
|
+
export type FoundResult = {
|
|
54
|
+
readonly id: Module.Id;
|
|
55
|
+
readonly source: string;
|
|
56
|
+
};
|
|
57
|
+
export type Result = FoundResult | null;
|
|
58
|
+
import * as list from '../../types/list/module.f.mjs';
|
|
67
59
|
import * as Package from '../package/module.f.mjs';
|
|
60
|
+
import * as Module from '../module/module.f.mjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-self-types="./module.f.d.mts"
|
|
2
|
-
import
|
|
2
|
+
import * as list from '../../types/list/module.f.mjs'
|
|
3
3
|
const { next, fold, reverse, first, flat, toArray, filterMap, isEmpty, concat } = list
|
|
4
|
-
import string from '../../types/string/module.f.mjs'
|
|
4
|
+
import * as string from '../../types/string/module.f.mjs'
|
|
5
5
|
const { join } = string
|
|
6
6
|
import * as Package from '../package/module.f.mjs'
|
|
7
7
|
import * as Module from '../module/module.f.mjs'
|
|
@@ -19,7 +19,7 @@ import * as Module from '../module/module.f.mjs'
|
|
|
19
19
|
/** @type {(path: string) => readonly string[]} */
|
|
20
20
|
const split = path => path.split('/')
|
|
21
21
|
|
|
22
|
-
/** @typedef {readonly[
|
|
22
|
+
/** @typedef {readonly[list.List<string>] | null} OptionList */
|
|
23
23
|
|
|
24
24
|
/** @type {(items: string) => (prior: OptionList) => OptionList} */
|
|
25
25
|
const normItemsOp = first => prior => {
|
|
@@ -38,7 +38,7 @@ const normItemsOp = first => prior => {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
/** @type {(items:
|
|
41
|
+
/** @type {(items: list.List<string>) => OptionList} */
|
|
42
42
|
const normItems = items => {
|
|
43
43
|
const result = fold(normItemsOp)([list.empty])(items)
|
|
44
44
|
return result === null ? result : [reverse(result[0])]
|
|
@@ -47,8 +47,8 @@ const normItems = items => {
|
|
|
47
47
|
const firstNull = first(null)
|
|
48
48
|
|
|
49
49
|
/** @type {(local: string) => (path: string) => LocalPath|null} */
|
|
50
|
-
const parseLocal = local => {
|
|
51
|
-
/** @type {(path: string) => readonly[boolean, boolean,
|
|
50
|
+
export const parseLocal = local => {
|
|
51
|
+
/** @type {(path: string) => readonly[boolean, boolean, list.List<string>]} */
|
|
52
52
|
const fSeq = path => {
|
|
53
53
|
const pathSeq = split(path)
|
|
54
54
|
const dir = [null, '', '.', '..'].includes(pathSeq[pathSeq.length - 1])
|
|
@@ -69,9 +69,9 @@ const parseLocal = local => {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
/** @typedef {readonly[string,
|
|
72
|
+
/** @typedef {readonly[string, list.List<string>]} IdPath */
|
|
73
73
|
|
|
74
|
-
/** @type {(prior: readonly[string|null,
|
|
74
|
+
/** @type {(prior: readonly[string|null, list.List<string>]) => list.Thunk<IdPath>} */
|
|
75
75
|
const variants = prior => () => {
|
|
76
76
|
const [a, b] = prior
|
|
77
77
|
const r = next(b)
|
|
@@ -99,10 +99,10 @@ const mapDependency = d => ([external, internal]) => {
|
|
|
99
99
|
/**
|
|
100
100
|
* @type {(d: (local: string) => string|null) =>
|
|
101
101
|
* (dir: boolean) =>
|
|
102
|
-
* (items:
|
|
102
|
+
* (items: list.List<string>) =>
|
|
103
103
|
* Path|null}
|
|
104
104
|
*/
|
|
105
|
-
const parseGlobal = dependencies =>
|
|
105
|
+
export const parseGlobal = dependencies =>
|
|
106
106
|
{
|
|
107
107
|
const fMap = filterMap(mapDependency(dependencies))
|
|
108
108
|
return dir => items => {
|
|
@@ -120,7 +120,7 @@ const parseGlobal = dependencies =>
|
|
|
120
120
|
* (path: string) =>
|
|
121
121
|
* Path|null }
|
|
122
122
|
*/
|
|
123
|
-
const parse = packageId => dependencies => {
|
|
123
|
+
export const parse = packageId => dependencies => {
|
|
124
124
|
const pg = parseGlobal(dependencies)
|
|
125
125
|
return local => path => {
|
|
126
126
|
const parsed = parseLocal(local)(path)
|
|
@@ -147,7 +147,7 @@ const parse = packageId => dependencies => {
|
|
|
147
147
|
* Result
|
|
148
148
|
* }
|
|
149
149
|
*/
|
|
150
|
-
const parseAndFind = packageGet => moduleId => path => {
|
|
150
|
+
export const parseAndFind = packageGet => moduleId => path => {
|
|
151
151
|
const currentPack = packageGet(moduleId.package)
|
|
152
152
|
if (currentPack === null) { return null }
|
|
153
153
|
const p = parse(moduleId.package)(currentPack.dependency)(moduleId.path.join('/'))(path)
|
|
@@ -164,14 +164,3 @@ const parseAndFind = packageGet => moduleId => path => {
|
|
|
164
164
|
const fileList = p.dir || isEmpty(p.items) ? [indexJs] : [file, `${file}.js`, indexJs]
|
|
165
165
|
return firstNull(filterMap(tryFile)(fileList))
|
|
166
166
|
}
|
|
167
|
-
|
|
168
|
-
export default {
|
|
169
|
-
/** @readonly */
|
|
170
|
-
parseLocal,
|
|
171
|
-
/** @readonly */
|
|
172
|
-
parseGlobal,
|
|
173
|
-
/** @readonly */
|
|
174
|
-
parse,
|
|
175
|
-
/** @readonly */
|
|
176
|
-
parseAndFind,
|
|
177
|
-
}
|