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.
Files changed (222) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/Cargo.lock +4 -0
  3. package/Cargo.toml +4 -2
  4. package/README.md +1 -1
  5. package/com/cpp/module.f.d.mts +4 -8
  6. package/com/cpp/module.f.mjs +20 -25
  7. package/com/cpp/testlib.f.mjs +3 -4
  8. package/com/cs/module.f.d.mts +4 -8
  9. package/com/cs/module.f.mjs +18 -23
  10. package/com/cs/testlib.f.mjs +3 -5
  11. package/com/rust/module.f.d.mts +3 -7
  12. package/com/rust/module.f.mjs +25 -30
  13. package/com/rust/nanocom/src/cobject.rs +1 -1
  14. package/com/rust/testlib.f.mjs +3 -5
  15. package/com/test/build.f.d.mts +2 -2
  16. package/com/test/build.f.mjs +2 -2
  17. package/com/test/build.mjs +4 -4
  18. package/com/test/rust/src/lib.rs +4 -4
  19. package/com/types/module.f.d.mts +5 -10
  20. package/com/types/module.f.mjs +5 -12
  21. package/commonjs/build/module.f.d.mts +13 -17
  22. package/commonjs/build/module.f.mjs +23 -28
  23. package/commonjs/build/test.f.mjs +4 -4
  24. package/commonjs/module/function/module.f.d.mts +0 -2
  25. package/commonjs/module/function/module.f.mjs +0 -2
  26. package/commonjs/module/module.f.d.mts +16 -21
  27. package/commonjs/module/module.f.mjs +2 -9
  28. package/commonjs/module.d.mts +1 -5
  29. package/commonjs/module.f.d.mts +0 -2
  30. package/commonjs/module.f.mjs +0 -2
  31. package/commonjs/module.mjs +2 -7
  32. package/commonjs/package/dependencies/module.f.d.mts +3 -7
  33. package/commonjs/package/dependencies/module.f.mjs +5 -10
  34. package/commonjs/package/dependencies/test.f.mjs +1 -1
  35. package/commonjs/package/module.f.d.mts +12 -18
  36. package/commonjs/package/module.f.mjs +6 -13
  37. package/commonjs/package/test.f.mjs +1 -1
  38. package/commonjs/path/module.f.d.mts +25 -32
  39. package/commonjs/path/module.f.mjs +12 -23
  40. package/commonjs/path/test.f.mjs +11 -11
  41. package/commonjs/test.mjs +1 -1
  42. package/dev/module.f.d.mts +1 -4
  43. package/dev/module.f.mjs +1 -4
  44. package/dev/module.mjs +1 -1
  45. package/dev/test/module.f.d.mts +2 -3
  46. package/dev/test/module.f.mjs +5 -7
  47. package/djs/module.f.d.mts +13 -18
  48. package/djs/module.f.mjs +12 -19
  49. package/djs/parser/module.f.d.mts +53 -37
  50. package/djs/parser/module.f.mjs +278 -131
  51. package/djs/parser/test.f.d.mts +4 -0
  52. package/djs/parser/test.f.mjs +186 -70
  53. package/djs/test.f.mjs +4 -4
  54. package/djs/tokenizer/module.f.d.mts +6 -10
  55. package/djs/tokenizer/module.f.mjs +19 -22
  56. package/djs/tokenizer/test.f.mjs +7 -7
  57. package/doc/LANGUAGE.md +17 -16
  58. package/doc/README.md +14 -50
  59. package/fsc/README.md +0 -3
  60. package/fsc/module.f.d.mts +4 -9
  61. package/fsc/module.f.mjs +17 -24
  62. package/fsc/test.f.mjs +3 -3
  63. package/fsm/README.md +1 -1
  64. package/fsm/module.f.d.mts +13 -20
  65. package/fsm/module.f.mjs +27 -38
  66. package/fsm/test.f.mjs +8 -8
  67. package/html/README.md +24 -0
  68. package/html/module.f.d.mts +7 -12
  69. package/html/module.f.mjs +14 -23
  70. package/html/test.f.mjs +4 -4
  71. package/issues/01-test-debug.md +3 -0
  72. package/issues/{publish.md → 05-publish.md} +8 -8
  73. package/issues/17-djs-extension.md +6 -0
  74. package/issues/README.md +20 -13
  75. package/issues/lang/1000-json.md +38 -0
  76. package/issues/lang/2110-default-export.md +2 -2
  77. package/issues/lang/2310-undefined.md +1 -1
  78. package/issues/lang/2330-property-accessor.md +225 -0
  79. package/issues/lang/2360-built-in.md +54 -47
  80. package/issues/lang/3240-export.md +44 -0
  81. package/issues/lang/README.md +64 -22
  82. package/issues/test.f.d.mts +16 -0
  83. package/issues/test.f.mjs +57 -0
  84. package/js/tokenizer/module.f.d.mts +18 -17
  85. package/js/tokenizer/module.f.mjs +80 -61
  86. package/js/tokenizer/test.f.mjs +15 -12
  87. package/json/module.f.d.mts +18 -26
  88. package/json/module.f.mjs +18 -31
  89. package/json/parser/module.f.d.mts +9 -13
  90. package/json/parser/module.f.mjs +9 -14
  91. package/json/parser/test.f.mjs +7 -7
  92. package/json/serializer/module.f.d.mts +11 -20
  93. package/json/serializer/module.f.mjs +14 -29
  94. package/json/serializer/test.f.mjs +2 -2
  95. package/json/test.f.mjs +3 -3
  96. package/json/tokenizer/module.f.d.mts +6 -10
  97. package/json/tokenizer/module.f.mjs +16 -20
  98. package/json/tokenizer/test.f.mjs +6 -6
  99. package/jsr.json +1 -1
  100. package/nanvm-lib/Cargo.toml +6 -0
  101. package/nanvm-lib/src/extension.rs +119 -0
  102. package/nanvm-lib/src/interface.rs +136 -0
  103. package/nanvm-lib/src/lib.rs +7 -0
  104. package/nanvm-lib/src/naive.rs +229 -0
  105. package/nanvm-lib/src/nanenum.rs +230 -0
  106. package/nanvm-lib/src/nullish.rs +7 -0
  107. package/nanvm-lib/src/sign.rs +5 -0
  108. package/nanvm-lib/src/simple.rs +32 -0
  109. package/nanvm-lib/tests/test.f.d.mts +36 -0
  110. package/nanvm-lib/tests/test.f.mjs +79 -0
  111. package/nanvm-lib/tests/test.rs +108 -0
  112. package/nodejs/version/main.mjs +1 -1
  113. package/nodejs/version/module.f.d.mts +4 -9
  114. package/nodejs/version/module.f.mjs +2 -7
  115. package/nodejs/version/test.f.mjs +3 -3
  116. package/package.json +1 -1
  117. package/prime_field/module.f.d.mts +20 -23
  118. package/prime_field/module.f.mjs +9 -12
  119. package/prime_field/test.f.mjs +1 -1
  120. package/secp/module.f.d.mts +27 -28
  121. package/secp/module.f.mjs +38 -39
  122. package/secp/test.f.mjs +4 -4
  123. package/sha2/module.f.d.mts +8 -16
  124. package/sha2/module.f.mjs +7 -20
  125. package/sha2/test.f.mjs +4 -4
  126. package/text/README.md +2 -2
  127. package/text/ascii/module.f.d.mts +69 -72
  128. package/text/ascii/module.f.mjs +5 -10
  129. package/text/ascii/test.f.mjs +3 -3
  130. package/text/module.f.d.mts +9 -14
  131. package/text/module.f.mjs +7 -14
  132. package/text/sgr/module.f.d.mts +7 -9
  133. package/text/sgr/module.f.mjs +2 -4
  134. package/text/test.f.mjs +3 -3
  135. package/text/utf16/module.f.d.mts +8 -15
  136. package/text/utf16/module.f.mjs +17 -28
  137. package/text/utf16/test.f.mjs +5 -5
  138. package/text/utf8/module.f.d.mts +4 -9
  139. package/text/utf8/module.f.mjs +9 -16
  140. package/text/utf8/test.f.mjs +4 -4
  141. package/types/array/module.f.d.mts +14 -24
  142. package/types/array/module.f.mjs +8 -25
  143. package/types/array/test.f.mjs +3 -3
  144. package/types/bigfloat/module.f.d.mts +4 -9
  145. package/types/bigfloat/module.f.mjs +3 -10
  146. package/types/bigfloat/test.f.mjs +1 -1
  147. package/types/bigint/module.f.d.mts +16 -64
  148. package/types/bigint/module.f.mjs +11 -30
  149. package/types/bigint/test.f.mjs +1 -1
  150. package/types/btree/find/module.f.d.mts +20 -26
  151. package/types/btree/find/module.f.mjs +8 -17
  152. package/types/btree/find/test.f.mjs +7 -7
  153. package/types/btree/module.f.d.mts +4 -8
  154. package/types/btree/module.f.mjs +6 -11
  155. package/types/btree/remove/module.f.d.mts +7 -12
  156. package/types/btree/remove/module.f.mjs +10 -17
  157. package/types/btree/remove/test.f.mjs +5 -5
  158. package/types/btree/set/module.f.d.mts +3 -7
  159. package/types/btree/set/module.f.mjs +4 -9
  160. package/types/btree/set/test.f.mjs +4 -4
  161. package/types/btree/test.f.mjs +9 -9
  162. package/types/btree/types/module.f.d.mts +0 -2
  163. package/types/btree/types/module.f.mjs +0 -2
  164. package/types/byte_set/module.f.d.mts +16 -29
  165. package/types/byte_set/module.f.mjs +14 -39
  166. package/types/byte_set/test.f.mjs +5 -5
  167. package/types/function/compare/module.f.d.mts +9 -15
  168. package/types/function/compare/module.f.mjs +3 -12
  169. package/types/function/compare/test.f.mjs +1 -1
  170. package/types/function/module.f.d.mts +20 -27
  171. package/types/function/module.f.mjs +4 -15
  172. package/types/function/operator/module.f.d.mts +28 -43
  173. package/types/function/operator/module.f.mjs +14 -41
  174. package/types/function/test.f.mjs +1 -1
  175. package/types/list/module.f.d.mts +56 -91
  176. package/types/list/module.f.mjs +45 -114
  177. package/types/list/test.f.mjs +10 -10
  178. package/types/map/module.f.d.mts +15 -24
  179. package/types/map/module.f.mjs +15 -30
  180. package/types/map/test.f.mjs +2 -2
  181. package/types/nibble_set/module.f.d.mts +10 -20
  182. package/types/nibble_set/module.f.mjs +7 -24
  183. package/types/nibble_set/test.f.mjs +2 -2
  184. package/types/nullable/module.f.d.mts +3 -8
  185. package/types/nullable/module.f.mjs +2 -9
  186. package/types/nullable/test.f.mjs +1 -1
  187. package/types/number/module.f.d.mts +7 -13
  188. package/types/number/module.f.mjs +8 -19
  189. package/types/number/test.f.mjs +1 -1
  190. package/types/object/module.f.d.mts +11 -18
  191. package/types/object/module.f.mjs +9 -20
  192. package/types/object/test.f.mjs +1 -1
  193. package/types/range/module.f.d.mts +3 -8
  194. package/types/range/module.f.mjs +2 -9
  195. package/types/range/test.f.mjs +1 -1
  196. package/types/range_map/module.f.d.mts +9 -15
  197. package/types/range_map/module.f.mjs +9 -18
  198. package/types/range_map/test.f.mjs +32 -32
  199. package/types/result/module.d.mts +3 -3
  200. package/types/result/module.f.d.mts +6 -12
  201. package/types/result/module.f.mjs +3 -12
  202. package/types/result/module.mjs +2 -2
  203. package/types/sorted_list/module.f.d.mts +22 -28
  204. package/types/sorted_list/module.f.mjs +10 -19
  205. package/types/sorted_list/test.f.mjs +7 -7
  206. package/types/sorted_set/module.f.d.mts +6 -12
  207. package/types/sorted_set/module.f.mjs +7 -16
  208. package/types/sorted_set/test.f.mjs +7 -7
  209. package/types/string/module.f.d.mts +8 -14
  210. package/types/string/module.f.mjs +10 -21
  211. package/types/string/test.f.mjs +2 -2
  212. package/types/string_set/module.f.d.mts +8 -16
  213. package/types/string_set/module.f.mjs +12 -27
  214. package/types/string_set/test.f.mjs +1 -1
  215. package/issues/lang/2351-property-accessor.md +0 -44
  216. package/issues/lang/2352-property-call.md +0 -43
  217. package/issues/lang/2353-property-at.md +0 -19
  218. package/issues/test-debug.md +0 -12
  219. /package/issues/{esm.md → 02-esm.md} +0 -0
  220. /package/issues/{djs.md → 03-djs.md} +0 -0
  221. /package/issues/{fs-load.md → 11-fs-load.md} +0 -0
  222. /package/issues/lang/{2330-grouping.md → 2350-grouping.md} +0 -0
@@ -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 list, * as List from '../../types/list/module.f.mjs'
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) => List.List<Field> } */
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: packageT.Get) =>
15
- * <M>(moduleMapInterface: moduleT.MapInterface<M>) =>
16
- * (moduleId: moduleT.Id) =>
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
- declare const getOrBuild: (compile: function_.Compile) => (packageGet: packageT.Get) => <M>(moduleMapInterface: moduleT.MapInterface<M>) => (moduleId: moduleT.Id) => (moduleMap: M) => Result<M>;
22
- import * as packageT from '../package/module.f.mjs';
23
- import * as moduleT from '../module/module.f.mjs';
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 packageT from '../package/module.f.mjs'
3
- import module_, * as moduleT from '../module/module.f.mjs'
4
- const { idToString, dir } = module_
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 map, * as Map from '../../types/map/module.f.mjs'
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 stringSet, * as StringSet from '../../types/string_set/module.f.mjs'
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: packageT.Get
19
- * readonly moduleMapInterface: moduleT.MapInterface<M>
20
- * readonly moduleId: moduleT.Id
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[moduleT.State, M]} Result
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: packageT.Get) =>
36
- * <M>(moduleMapInterface: moduleT.MapInterface<M>) =>
37
- * (moduleId: moduleT.Id) =>
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 moduleT.MapInterface<infer M> ? M : never} M */
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: StringSet.StringSet) =>
47
- * (moduleId: moduleT.Id) =>
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[Map.Map<string>, M]>} */
56
+ /** @type {function_.Require<readonly[map.Map<string>, M]>} */
57
57
  const require_ = p => ([requireMap, m]) => {
58
- /** @type {(e: unknown) => function_.Result<readonly[Map.Map<string>, M]>} */
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: moduleT.State) => (m: M) => Result<M>} */
69
+ /** @type {(s: module.State) => (m: M) => Result<M>} */
70
70
  const set = s => m => [s, moduleMapInterface.setReplace(moduleIdStr)(s)(m)]
71
- /** @type {(e: moduleT.Error) => (m: M) => Result<M>} */
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: moduleT.Id) => (moduleMap: M) => Result<M>} */
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 map, * as Map from '../../types/map/module.f.mjs'
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<Map.Map<Module.State>>} */(map))
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>;
@@ -19,5 +19,3 @@ import * as TypesResult from '../../../types/result/module.f.mjs'
19
19
  */
20
20
 
21
21
  /** @typedef {(source: string) => TypesResult.Result<Function_, unknown>} Compile */
22
-
23
- export default {}
@@ -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
- declare const dir: (id: Id) => Id | null;
35
+ export const dir: (id: Id) => Id | null;
55
36
  /** @type {(id: Id) => string} */
56
- declare const idToString: (id: Id) => string;
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('/')}`
@@ -1,7 +1,3 @@
1
- declare namespace _default {
2
- export { compile };
3
- }
4
- export default _default;
5
1
  /** @type {ModuleFunction.Compile} */
6
- declare const compile: ModuleFunction.Compile;
2
+ export const compile: ModuleFunction.Compile;
7
3
  import * as ModuleFunction from './module/function/module.f.mjs';
@@ -1,4 +1,2 @@
1
- declare const _default: {};
2
- export default _default;
3
1
  export type PackageMap = (packageName: string) => PackageMap | Package | null;
4
2
  export type Package = readonly [string, PackageMap, (fileName: string) => string | null];
@@ -9,5 +9,3 @@
9
9
  * (fileName: string) => string|null
10
10
  * ]} Package
11
11
  */
12
-
13
- export default {}
@@ -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
- declare namespace _default {
2
- export { isDependenciesJson };
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
- /** @type {(j: Json.Unknown) => j is DependenciesJson} */
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 json, * as Json from '../../../json/module.f.mjs'
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: Json.Entry) => boolean} */
14
+ /** @type {(entry: json.Entry) => boolean} */
15
15
  const isDependencyJson = ([, v]) => typeof v === 'string'
16
16
 
17
- /** @type {(j: Json.Unknown) => j is DependenciesJson} */
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,4 +1,4 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
 
3
3
  export default () => {
4
4
  if (!_.isDependenciesJson(null)) { throw 'error' }
@@ -1,27 +1,21 @@
1
- declare namespace _default {
2
- export { dependencies };
3
- export { isPackageJson };
4
- }
5
- export default _default;
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?: Dependencies.DependenciesJson;
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 dependencies from './dependencies/module.f.mjs';
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 json, * as Json from '../../json/module.f.mjs'
2
+ import * as json from '../../json/module.f.mjs'
3
3
  const { isObject } = json
4
- import dependencies, * as Dependencies from './dependencies/module.f.mjs'
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?: Dependencies.DependenciesJson
13
+ * readonly dependencies?: dependencies.DependenciesJson
14
14
  * }} PackageJson
15
15
  */
16
16
 
17
- /** @type {(j: Json.Unknown) => j is PackageJson} */
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,4 +1,4 @@
1
- import _ from './module.f.mjs'
1
+ import * as _ from './module.f.mjs'
2
2
 
3
3
  export default () => {
4
4
  if (_.isPackageJson(null)) { throw 'error' }
@@ -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
- declare const parseLocal: (local: string) => (path: string) => LocalPath | null;
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: List.List<string>) =>
13
+ * (items: list.List<string>) =>
39
14
  * Path|null}
40
15
  */
41
- declare const parseGlobal: (d: (local: string) => string | null) => (dir: boolean) => (items: List.List<string>) => Path | null;
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
- declare const parse: (packageId: string) => (dependencies: (local: string) => string | null) => (local: string) => (path: string) => Path | null;
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
- declare const parseAndFind: (packageGet: Package.Get) => (moduleId: Module.Id) => (path: string) => Result;
65
- import * as List from '../../types/list/module.f.mjs';
66
- import * as Module from '../module/module.f.mjs';
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 list, * as List from '../../types/list/module.f.mjs'
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[List.List<string>] | null} OptionList */
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: List.List<string>) => OptionList} */
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, List.List<string>]} */
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, List.List<string>]} IdPath */
72
+ /** @typedef {readonly[string, list.List<string>]} IdPath */
73
73
 
74
- /** @type {(prior: readonly[string|null, List.List<string>]) => List.Thunk<IdPath>} */
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: List.List<string>) =>
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
- }