functionalscript 0.1.594 → 0.1.597

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 (167) hide show
  1. package/.github/workflows/npm-publish.yml +2 -1
  2. package/com/cpp/module.f.d.mts +8 -0
  3. package/com/cpp/module.f.mjs +18 -18
  4. package/com/cpp/test.f.d.mts +2 -0
  5. package/com/cpp/testlib.f.d.mts +2 -0
  6. package/com/cs/module.f.d.mts +8 -0
  7. package/com/cs/module.f.mjs +1 -1
  8. package/com/cs/test.f.d.mts +2 -0
  9. package/com/cs/testlib.f.d.mts +2 -0
  10. package/com/rust/module.f.d.mts +28 -0
  11. package/com/rust/module.f.mjs +30 -30
  12. package/com/rust/test.f.d.mts +2 -0
  13. package/com/rust/testlib.f.d.mts +2 -0
  14. package/com/test/build.d.mts +1 -0
  15. package/com/test/build.f.d.mts +26 -0
  16. package/com/test/build.mjs +2 -2
  17. package/com/types/module.f.d.mts +28 -0
  18. package/com/types/module.f.mjs +1 -1
  19. package/com/types/testlib.f.d.mts +44 -0
  20. package/commonjs/build/module.f.d.mts +24 -0
  21. package/commonjs/build/test.f.d.mts +3 -0
  22. package/commonjs/module/function/module.f.d.mts +7 -0
  23. package/commonjs/module/module.f.d.mts +57 -0
  24. package/commonjs/module/module.f.mjs +1 -1
  25. package/commonjs/module.d.mts +7 -0
  26. package/commonjs/module.f.d.mts +4 -0
  27. package/commonjs/package/dependencies/module.f.d.mts +10 -0
  28. package/commonjs/package/dependencies/module.f.mjs +3 -3
  29. package/commonjs/package/dependencies/test.f.d.mts +2 -0
  30. package/commonjs/package/module.f.d.mts +27 -0
  31. package/commonjs/package/module.f.mjs +4 -4
  32. package/commonjs/package/test.f.d.mts +2 -0
  33. package/commonjs/path/module.f.d.mts +67 -0
  34. package/commonjs/path/module.f.mjs +5 -5
  35. package/commonjs/path/test.f.d.mts +25 -0
  36. package/commonjs/path/test.f.mjs +7 -7
  37. package/commonjs/test.d.mts +8 -0
  38. package/commonjs/test.mjs +2 -2
  39. package/dev/index.d.mts +1 -0
  40. package/dev/module.d.mts +26 -0
  41. package/dev/module.f.d.mts +4 -0
  42. package/dev/test/module.f.d.mts +26 -0
  43. package/dev/test.d.mts +3 -0
  44. package/dev/test.f.d.mts +9 -0
  45. package/djs/module.f.d.mts +25 -0
  46. package/djs/module.f.mjs +1 -1
  47. package/djs/parser/module.f.d.mts +40 -0
  48. package/djs/parser/test.f.d.mts +8 -0
  49. package/djs/test.f.d.mts +12 -0
  50. package/djs/tokenizer/module.f.d.mts +17 -0
  51. package/djs/tokenizer/module.f.mjs +1 -1
  52. package/djs/tokenizer/test.f.d.mts +6 -0
  53. package/djs/tokenizer/test.f.mjs +1 -1
  54. package/fsc/module.f.d.mts +12 -0
  55. package/fsc/test.f.d.mts +4 -0
  56. package/fsm/module.f.d.mts +21 -0
  57. package/fsm/test.f.d.mts +5 -0
  58. package/html/module.f.d.mts +20 -0
  59. package/html/module.f.mjs +1 -1
  60. package/html/test.f.d.mts +10 -0
  61. package/index.f.d.mts +83 -0
  62. package/js/tokenizer/module.f.d.mts +150 -0
  63. package/js/tokenizer/test.f.d.mts +8 -0
  64. package/js/tokenizer/test.f.mjs +3 -3
  65. package/json/module.f.d.mts +41 -0
  66. package/json/parser/module.f.d.mts +36 -0
  67. package/json/parser/module.f.mjs +12 -12
  68. package/json/parser/test.f.d.mts +5 -0
  69. package/json/parser/test.f.mjs +2 -2
  70. package/json/serializer/module.f.d.mts +45 -0
  71. package/json/serializer/module.f.mjs +2 -2
  72. package/json/serializer/test.f.d.mts +8 -0
  73. package/json/test.f.d.mts +8 -0
  74. package/json/tokenizer/module.f.d.mts +17 -0
  75. package/json/tokenizer/module.f.mjs +7 -7
  76. package/json/tokenizer/test.f.d.mts +6 -0
  77. package/json/tokenizer/test.f.mjs +3 -3
  78. package/jsr.json +1 -1
  79. package/nodejs/version/main.d.mts +1 -0
  80. package/nodejs/version/module.f.d.mts +18 -0
  81. package/nodejs/version/test.f.d.mts +2 -0
  82. package/package.json +2 -1
  83. package/prime_field/module.f.d.mts +44 -0
  84. package/prime_field/test.f.d.mts +12 -0
  85. package/secp/module.f.d.mts +49 -0
  86. package/secp/module.f.mjs +6 -6
  87. package/secp/test.f.d.mts +4 -0
  88. package/secp/test.f.mjs +5 -5
  89. package/sha2/module.f.d.mts +23 -0
  90. package/sha2/module.f.mjs +1 -1
  91. package/sha2/test.f.d.mts +10 -0
  92. package/sha2/test.f.mjs +0 -1
  93. package/text/ascii/module.f.d.mts +73 -0
  94. package/text/ascii/test.f.d.mts +4 -0
  95. package/text/module.f.d.mts +18 -0
  96. package/text/sgr/module.f.d.mts +14 -0
  97. package/text/test.f.d.mts +2 -0
  98. package/text/utf16/module.f.d.mts +19 -0
  99. package/text/utf16/test.f.d.mts +6 -0
  100. package/text/utf16/test.f.mjs +2 -2
  101. package/text/utf8/module.f.d.mts +15 -0
  102. package/text/utf8/module.f.mjs +2 -2
  103. package/text/utf8/test.f.d.mts +6 -0
  104. package/types/array/module.f.d.mts +41 -0
  105. package/types/array/test.f.d.mts +10 -0
  106. package/types/bigfloat/module.f.d.mts +11 -0
  107. package/types/bigfloat/test.f.d.mts +6 -0
  108. package/types/bigint/module.f.d.mts +77 -0
  109. package/types/bigint/module.f.mjs +5 -5
  110. package/types/bigint/test.f.d.mts +16 -0
  111. package/types/btree/find/module.f.d.mts +42 -0
  112. package/types/btree/find/module.f.mjs +4 -4
  113. package/types/btree/find/test.f.d.mts +2 -0
  114. package/types/btree/find/test.f.mjs +2 -2
  115. package/types/btree/module.f.d.mts +9 -0
  116. package/types/btree/remove/module.f.d.mts +19 -0
  117. package/types/btree/remove/module.f.mjs +12 -12
  118. package/types/btree/remove/test.f.d.mts +7 -0
  119. package/types/btree/remove/test.f.mjs +5 -5
  120. package/types/btree/set/module.f.d.mts +9 -0
  121. package/types/btree/set/module.f.mjs +6 -6
  122. package/types/btree/set/test.f.d.mts +2 -0
  123. package/types/btree/set/test.f.mjs +32 -32
  124. package/types/btree/test.f.d.mts +13 -0
  125. package/types/btree/test.f.mjs +7 -11
  126. package/types/btree/types/module.f.d.mts +16 -0
  127. package/types/byte_set/module.f.d.mts +38 -0
  128. package/types/byte_set/module.f.mjs +2 -2
  129. package/types/byte_set/test.f.d.mts +13 -0
  130. package/types/byte_set/test.f.mjs +3 -3
  131. package/types/function/compare/module.f.d.mts +29 -0
  132. package/types/function/compare/module.f.mjs +4 -4
  133. package/types/function/compare/test.f.d.mts +2 -0
  134. package/types/function/module.f.d.mts +36 -0
  135. package/types/function/operator/module.f.d.mts +75 -0
  136. package/types/function/test.f.d.mts +2 -0
  137. package/types/list/module.f.d.mts +117 -0
  138. package/types/list/test.f.d.mts +38 -0
  139. package/types/map/module.f.d.mts +30 -0
  140. package/types/map/module.f.mjs +4 -4
  141. package/types/map/test.f.d.mts +5 -0
  142. package/types/nibble_set/module.f.d.mts +26 -0
  143. package/types/nibble_set/test.f.d.mts +13 -0
  144. package/types/nullable/module.f.d.mts +14 -0
  145. package/types/nullable/test.f.d.mts +2 -0
  146. package/types/number/module.f.d.mts +13 -0
  147. package/types/number/test.f.d.mts +11 -0
  148. package/types/object/module.f.d.mts +29 -0
  149. package/types/object/test.f.d.mts +5 -0
  150. package/types/range/module.f.d.mts +11 -0
  151. package/types/range/test.f.d.mts +2 -0
  152. package/types/range_map/module.f.d.mts +25 -0
  153. package/types/range_map/module.f.mjs +5 -5
  154. package/types/range_map/test.f.d.mts +6 -0
  155. package/types/range_map/test.f.mjs +2 -2
  156. package/types/result/module.d.mts +7 -0
  157. package/types/result/module.f.d.mts +28 -0
  158. package/types/sorted_list/module.f.d.mts +59 -0
  159. package/types/sorted_list/test.f.d.mts +5 -0
  160. package/types/sorted_list/test.f.mjs +2 -2
  161. package/types/sorted_set/module.f.d.mts +25 -0
  162. package/types/sorted_set/test.f.d.mts +6 -0
  163. package/types/sorted_set/test.f.mjs +1 -1
  164. package/types/string/module.f.d.mts +15 -0
  165. package/types/string/test.f.d.mts +15 -0
  166. package/types/string_set/module.f.d.mts +21 -0
  167. package/types/string_set/test.f.d.mts +5 -0
@@ -24,9 +24,10 @@ jobs:
24
24
  - uses: denoland/setup-deno@v1
25
25
  with:
26
26
  deno-version: 2
27
- # - run: npm ci
27
+ - run: npm ci
28
28
  - run: npm run version
29
29
  - run: npm run index
30
+ - run: npm run tscp
30
31
  - run: npm publish
31
32
  env:
32
33
  NODE_AUTH_TOKEN: ${{secrets.npm_token}}
@@ -0,0 +1,8 @@
1
+ declare namespace _default {
2
+ export { cpp };
3
+ }
4
+ export default _default;
5
+ /** @type {(name: string) => (lib: Types.Library) => Text.Block} */
6
+ declare const cpp: (name: string) => (lib: Types.Library) => Text.Block;
7
+ import * as Types from '../types/module.f.mjs';
8
+ import * as Text from '../../text/module.f.mjs';
@@ -1,6 +1,6 @@
1
- import types, * as typesT from '../types/module.f.mjs'
2
- import text, * as textT from '../../text/module.f.mjs'
3
- import obj, * as O from '../../types/object/module.f.mjs'
1
+ import types, * as Types from '../types/module.f.mjs'
2
+ import text, * as Text from '../../text/module.f.mjs'
3
+ import * as O from '../../types/object/module.f.mjs'
4
4
  import list from '../../types/list/module.f.mjs'
5
5
  import string from '../../types/string/module.f.mjs'
6
6
  const { join } = string
@@ -8,7 +8,7 @@ const { paramList } = types
8
8
  const { map, flatMap, flat } = list
9
9
  const { entries } = Object
10
10
 
11
- /** @type {(name: string) => (body: textT.Block) => textT.Block} */
11
+ /** @type {(name: string) => (body: Text.Block) => Text.Block} */
12
12
  const struct = name => body => [`struct ${name}`, '{', body, '};']
13
13
 
14
14
  const baseTypeMap = {
@@ -27,7 +27,7 @@ const baseTypeMap = {
27
27
  bool: 'bool',
28
28
  }
29
29
 
30
- /** @type {(t: typesT.BaseType) => string} */
30
+ /** @type {(t: Types.BaseType) => string} */
31
31
  const baseType = t => baseTypeMap[t]
32
32
 
33
33
  const resultVoid = types.result('void')
@@ -43,17 +43,17 @@ const ptr = id => `${id} const*`
43
43
  /** @type {(id: string) => string} */
44
44
  const ref = id => `${id} const&`
45
45
 
46
- /** @type {(p: typesT.Field) => string} */
46
+ /** @type {(p: Types.Field) => string} */
47
47
  const paramName = ([name]) => name
48
48
 
49
49
  const mapParamName = map(paramName)
50
50
 
51
51
  const joinComma = join(', ')
52
52
 
53
- /** @type {(name: string) => (lib: typesT.Library) => textT.Block} */
53
+ /** @type {(name: string) => (lib: Types.Library) => Text.Block} */
54
54
  const cpp = name => lib => {
55
55
 
56
- /** @type {(t: typesT.Type) => string|null} */
56
+ /** @type {(t: Types.Type) => string|null} */
57
57
  const interface_ = t => {
58
58
  if (!(t instanceof Array) || t.length !== 1) {
59
59
  return null
@@ -62,7 +62,7 @@ const cpp = name => lib => {
62
62
  return 'interface' in lib[name] ? name : null
63
63
  }
64
64
 
65
- /** @type {(i: (t: string) => string) => (t: typesT.Type) => string} */
65
+ /** @type {(i: (t: string) => string) => (t: Types.Type) => string} */
66
66
  const objectType = i => t => {
67
67
  if (typeof (t) === 'string') { return baseType(t) }
68
68
  if (t.length === 2) { return `${type(t[1])} const*` }
@@ -74,27 +74,27 @@ const cpp = name => lib => {
74
74
 
75
75
  const resultType = objectType(ptr)
76
76
 
77
- /** @type {(s: typesT.Field) => textT.Item} */
77
+ /** @type {(s: Types.Field) => Text.Item} */
78
78
  const field = ([name, t]) => `${type(t)} ${name};`
79
79
 
80
80
  const mapField = map(field)
81
81
 
82
- /** @type {(s: typesT.Struct) => textT.Block} */
82
+ /** @type {(s: Types.Struct) => Text.Block} */
83
83
  const defStruct = s => mapField(entries(s.struct))
84
84
 
85
- /** @type {(fa: typesT.FieldArray) => string} */
85
+ /** @type {(fa: Types.FieldArray) => string} */
86
86
  const cppResult = resultVoid(resultType)
87
87
 
88
- /** @type {(p: typesT.Field) => string} */
88
+ /** @type {(p: Types.Field) => string} */
89
89
  const param = ([name, t]) => `${objectType(ref)(t)} ${name}`
90
90
 
91
91
  const mapParam = map(param)
92
92
 
93
- /** @type {(result: string) => (paramArrayStr: string) => (name: string) => textT.Item} */
93
+ /** @type {(result: string) => (paramArrayStr: string) => (name: string) => Text.Item} */
94
94
  const methodHeader = result => paramArrayStr => name =>
95
95
  `virtual ${result} ${name}${paramArrayStr} const noexcept = 0;`
96
96
 
97
- /** @type {(m: typesT.Method) => readonly textT.Item[]} */
97
+ /** @type {(m: Types.Method) => readonly Text.Item[]} */
98
98
  const method = ([name, paramArray]) => {
99
99
  const result = cppResult(paramArray)
100
100
  const paramL = paramList(paramArray)
@@ -115,7 +115,7 @@ const cpp = name => lib => {
115
115
 
116
116
  const mapMethod = flatMap(method)
117
117
 
118
- /** @type {(i: typesT.Interface) => textT.Block} */
118
+ /** @type {(i: Types.Interface) => Text.Block} */
119
119
  const defInterface = ({ guid, interface: i }) => {
120
120
  const g = guid.replaceAll('-', '');
121
121
  const lo = g.substring(0, 16);
@@ -126,7 +126,7 @@ const cpp = name => lib => {
126
126
  ])
127
127
  }
128
128
 
129
- /** @type {(kv: O.Entry<typesT.Definition>) => textT.Block} */
129
+ /** @type {(kv: O.Entry<Types.Definition>) => Text.Block} */
130
130
  const def = ([name, d]) => 'interface' in d
131
131
  ? [
132
132
  `class ${name} : public ::nanocom::IUnknown`,
@@ -137,7 +137,7 @@ const cpp = name => lib => {
137
137
  ]
138
138
  : struct(name)(defStruct(d))
139
139
 
140
- /** @type {(kv: O.Entry<typesT.Definition>) => textT.Block} */
140
+ /** @type {(kv: O.Entry<Types.Definition>) => Text.Block} */
141
141
  const forward = ([name]) => [`struct ${name};`]
142
142
 
143
143
  const e = entries(lib)
@@ -0,0 +1,2 @@
1
+ export default f;
2
+ declare function f(): void;
@@ -0,0 +1,2 @@
1
+ declare function _default(): string;
2
+ export default _default;
@@ -0,0 +1,8 @@
1
+ declare namespace _default {
2
+ export { cs };
3
+ }
4
+ export default _default;
5
+ /** @type {(name: string) => (library: typesT.Library) => textT.Block} */
6
+ declare const cs: (name: string) => (library: typesT.Library) => textT.Block;
7
+ import * as typesT from '../types/module.f.mjs';
8
+ import * as textT from '../../text/module.f.mjs';
@@ -6,7 +6,7 @@ import list, * as List from '../../types/list/module.f.mjs'
6
6
  const { flat, map, some, flatMap } = list
7
7
  import string from '../../types/string/module.f.mjs'
8
8
  const { join } = string
9
- import obj, * as O from '../../types/object/module.f.mjs'
9
+ import * as O from '../../types/object/module.f.mjs'
10
10
  const { entries } = Object
11
11
 
12
12
  /** @type {(v: string) => string} */
@@ -0,0 +1,2 @@
1
+ export default f;
2
+ declare function f(): void;
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;
@@ -0,0 +1,28 @@
1
+ declare namespace _default {
2
+ export { rust };
3
+ }
4
+ export default _default;
5
+ export type OptionalProperty<T> = T | {};
6
+ export type Where = {
7
+ readonly where: readonly string[];
8
+ };
9
+ export type WhereContent = OptionalProperty<Where> & {
10
+ readonly content: Text.Block;
11
+ };
12
+ export type Impl = {
13
+ readonly param?: string;
14
+ readonly trait: string;
15
+ readonly type: string;
16
+ readonly where?: readonly string[];
17
+ readonly content: Text.Block;
18
+ };
19
+ export type Trait = {
20
+ readonly pub?: true;
21
+ readonly type: string;
22
+ readonly where?: readonly string[];
23
+ readonly content: Text.Block;
24
+ };
25
+ /** @type {(library: Types.Library) => Text.Block} */
26
+ declare const rust: (library: Types.Library) => Text.Block;
27
+ import * as Text from '../../text/module.f.mjs';
28
+ import * as Types from '../types/module.f.mjs';
@@ -1,7 +1,7 @@
1
- import types, * as typesT from '../types/module.f.mjs'
1
+ import types, * as Types from '../types/module.f.mjs'
2
2
  const { paramList } = types
3
- import text, * as textT from '../../text/module.f.mjs'
4
- import object, * as O from '../../types/object/module.f.mjs'
3
+ import * as Text from '../../text/module.f.mjs'
4
+ import * as O from '../../types/object/module.f.mjs'
5
5
  import list, * as List from '../../types/list/module.f.mjs'
6
6
  const { flat, map, flatMap } = list
7
7
  const { entries } = Object
@@ -15,7 +15,7 @@ const rustField = field => `pub ${field},`
15
15
 
16
16
  const mapRustField = map(rustField)
17
17
 
18
- /** @type {(b: List.Thunk<string>) => (name: string) => textT.Block} */
18
+ /** @type {(b: List.Thunk<string>) => (name: string) => Text.Block} */
19
19
  const rustStruct = b => name => [`#[repr(C)]`, `pub struct ${name} {`, mapRustField(b), `}`]
20
20
 
21
21
  const commaJoin = join(', ')
@@ -28,21 +28,21 @@ const obj = name => `&${name}::Object`
28
28
 
29
29
  const self = ['&self']
30
30
 
31
- /** @type {(p: typesT.Field) => string} */
31
+ /** @type {(p: Types.Field) => string} */
32
32
  const paramName = ([n]) => n
33
33
 
34
- /** @type {(p: typesT.FieldArray) => List.Thunk<string>} */
34
+ /** @type {(p: Types.FieldArray) => List.Thunk<string>} */
35
35
  const callList = p => map(paramName)(paramList(p))
36
36
 
37
- /** @type {(p: typesT.FieldArray) => string} */
37
+ /** @type {(p: Types.FieldArray) => string} */
38
38
  const call = p => commaJoin(callList(p))
39
39
 
40
- /** @type {(p: typesT.FieldArray) => string} */
40
+ /** @type {(p: Types.FieldArray) => string} */
41
41
  const virtualCall = p => commaJoin(flat([['self'], callList(p)]))
42
42
 
43
43
  const super_ = 'super::'
44
44
 
45
- /** @type {(m: typesT.Method) => string} */
45
+ /** @type {(m: Types.Method) => string} */
46
46
  const assign = ([n]) => `${n}: Self::${n},`
47
47
 
48
48
  const mapAssign = map(assign)
@@ -60,10 +60,10 @@ const rustType = n => `pub type ${n} = nanocom::${n}<Interface>;`
60
60
  /** @typedef {{readonly where: readonly string[]}} Where */
61
61
 
62
62
  /**
63
- * @typedef {OptionalProperty<Where> & {readonly content: textT.Block}} WhereContent
63
+ * @typedef {OptionalProperty<Where> & {readonly content: Text.Block}} WhereContent
64
64
  */
65
65
 
66
- /** @type {(h: string) => (wh: WhereContent) => textT.Block} */
66
+ /** @type {(h: string) => (wh: WhereContent) => Text.Block} */
67
67
  const whereContent = h => wh => {
68
68
  const w = 'where' in wh ? [
69
69
  h,
@@ -84,11 +84,11 @@ const whereContent = h => wh => {
84
84
  * readonly trait: string
85
85
  * readonly type: string
86
86
  * readonly where?: readonly string[]
87
- * readonly content: textT.Block
87
+ * readonly content: Text.Block
88
88
  * }} Impl
89
89
  */
90
90
 
91
- /** @type {(impl: Impl) => textT.Block} */
91
+ /** @type {(impl: Impl) => Text.Block} */
92
92
  const rustImpl = i => {
93
93
  const p = 'param' in i ? `<${i.param}>` : ''
94
94
  const header = `impl${p} ${i.trait} for ${i.type}`
@@ -100,7 +100,7 @@ const rustImpl = i => {
100
100
  * readonly pub?: true
101
101
  * readonly type: string
102
102
  * readonly where?: readonly string[]
103
- * readonly content: textT.Block
103
+ * readonly content: Text.Block
104
104
  * }} Trait
105
105
  */
106
106
 
@@ -109,14 +109,14 @@ const comma = s => `${s},`
109
109
 
110
110
  const mapComma = map(comma)
111
111
 
112
- /** @type {(t: Trait) => textT.Block} */
112
+ /** @type {(t: Trait) => Text.Block} */
113
113
  const trait = t => {
114
114
  const p = t.pub === true ? 'pub ' : ''
115
115
  const h = `${p}trait ${t.type}`
116
116
  return whereContent(h)(t)
117
117
  }
118
118
 
119
- /** @type {(t: Trait) => textT.Block} */
119
+ /** @type {(t: Trait) => Text.Block} */
120
120
  const traitImpl = t => {
121
121
  const i = rustImpl({
122
122
  param: 'T',
@@ -130,12 +130,12 @@ const traitImpl = t => {
130
130
 
131
131
  const where = ['Self: nanocom::Class<Interface = Interface>', 'nanocom::CObject<Self>: Ex']
132
132
 
133
- /** @type {(library: typesT.Library) => textT.Block} */
133
+ /** @type {(library: Types.Library) => Text.Block} */
134
134
  const rust = library => {
135
135
 
136
- /** @type {(p: string) => (o: (_: string) => string) => (t: typesT.Type) => string} */
136
+ /** @type {(p: string) => (o: (_: string) => string) => (t: Types.Type) => string} */
137
137
  const type = p => {
138
- /** @type {(o: (_: string) => string) => (t: typesT.Type) => string} */
138
+ /** @type {(o: (_: string) => string) => (t: Types.Type) => string} */
139
139
  const f = o => t => {
140
140
  if (typeof t === 'string') { return t }
141
141
  if (t.length === 2) { return `*const ${f(ref)(t[1])}` }
@@ -146,7 +146,7 @@ const rust = library => {
146
146
  return f
147
147
  }
148
148
 
149
- /** @type {(p: string) => (o: (_: string) => string) => (f: typesT.Field) => string} */
149
+ /** @type {(p: string) => (o: (_: string) => string) => (f: Types.Field) => string} */
150
150
  const pf = p => o => ([name, t]) => `${name}: ${type(p)(o)(t)}`
151
151
 
152
152
  const param = pf(super_)(obj)
@@ -155,36 +155,36 @@ const rust = library => {
155
155
 
156
156
  const mapField = map(pf('')(ref))
157
157
 
158
- /** @type {(fa: typesT.FieldArray) => (name: string) => textT.Block} */
158
+ /** @type {(fa: Types.FieldArray) => (name: string) => Text.Block} */
159
159
  const struct = fn(entries)
160
160
  .then(mapField)
161
161
  .then(rustStruct)
162
162
  .result
163
163
 
164
- /** @type {(first: readonly string[]) => (p: typesT.FieldArray) => string} */
164
+ /** @type {(first: readonly string[]) => (p: Types.FieldArray) => string} */
165
165
  const func = first => p => {
166
166
  const resultStr = '_' in p ? ` -> ${type(super_)(ref)(p._)}` : ''
167
167
  const params = commaJoin(flat([first, mapParam(paramList(p))]))
168
168
  return `(${params})${resultStr}`
169
169
  }
170
170
 
171
- /** @type {(n: string) => (p: typesT.FieldArray) => string} */
171
+ /** @type {(n: string) => (p: Types.FieldArray) => string} */
172
172
  const virtualFnType = n => p => `extern "system" fn${n}${func(this_)(p)}`
173
173
 
174
- /** @type {(m: typesT.Method) => string} */
174
+ /** @type {(m: Types.Method) => string} */
175
175
  const virtualFn = ([n, p]) => `${n}: unsafe ${virtualFnType('')(p)}`
176
176
 
177
177
  const mapVirtualFn = map(virtualFn)
178
178
 
179
- /** @type {(m: typesT.Method) => string} */
179
+ /** @type {(m: Types.Method) => string} */
180
180
  const headerFn = ([n, p]) => `fn ${n}${func(self)(p)}`
181
181
 
182
- /** @type {(m: typesT.Method) => string} */
182
+ /** @type {(m: Types.Method) => string} */
183
183
  const traitFn = m => `${headerFn(m)};`
184
184
 
185
185
  const mapTraitFn = map(traitFn)
186
186
 
187
- /** @type {(m: typesT.Method) => textT.Block} */
187
+ /** @type {(m: Types.Method) => Text.Block} */
188
188
  const implFn = m => {
189
189
  const [n, p] = m
190
190
  return [
@@ -196,7 +196,7 @@ const rust = library => {
196
196
 
197
197
  const flatMapImplFn = flatMap(implFn)
198
198
 
199
- /** @type {(m: typesT.Method) => textT.Block} */
199
+ /** @type {(m: Types.Method) => Text.Block} */
200
200
  const impl = ([n, p]) => {
201
201
  const type = virtualFnType(` ${n}`)(p)
202
202
  return [
@@ -208,7 +208,7 @@ const rust = library => {
208
208
 
209
209
  const flatMapImpl = flatMap(impl)
210
210
 
211
- /** @type {(i: typesT.Interface) => (name: string) => textT.Block} */
211
+ /** @type {(i: Types.Interface) => (name: string) => Text.Block} */
212
212
  const interface_ = ({ interface: i, guid }) => name => {
213
213
 
214
214
  const e = entries(i)
@@ -252,7 +252,7 @@ const rust = library => {
252
252
  ]
253
253
  }
254
254
 
255
- /** @type {(type: O.Entry<typesT.Definition>) => textT.Block} */
255
+ /** @type {(type: O.Entry<Types.Definition>) => Text.Block} */
256
256
  const def = ([name, type]) => ('interface' in type ? interface_(type) : struct(type.struct))(name)
257
257
 
258
258
  return flat([['#![allow(non_snake_case)]'], flatMap(def)(entries(library))])
@@ -0,0 +1,2 @@
1
+ declare function _default(): void;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: string;
2
+ export default _default;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,26 @@
1
+ declare namespace _default {
2
+ export { cpp };
3
+ export { cs };
4
+ export { rust };
5
+ }
6
+ export default _default;
7
+ export type Platform = "aix" | "android" | "darwin" | "freebsd" | "haiku" | "linux" | "openbsd" | "sunos" | "win32" | "cygwin" | "netbsd";
8
+ export type NodeJs = {
9
+ readonly dirname: string;
10
+ readonly platform: Platform;
11
+ };
12
+ export type Output = {
13
+ readonly file: {
14
+ readonly name: string;
15
+ readonly content: string;
16
+ };
17
+ readonly line: List.List<List.List<string>>;
18
+ };
19
+ export type Func = (nodejs: NodeJs) => Output;
20
+ /** @type {Func} */
21
+ declare const cpp: Func;
22
+ /** @type {Func} */
23
+ declare const cs: Func;
24
+ /** @type {Func} */
25
+ declare const rust: Func;
26
+ import * as List from '../../types/list/module.f.mjs';
@@ -1,7 +1,7 @@
1
1
  import { writeFileSync } from 'node:fs'
2
2
  import { execSync } from 'node:child_process'
3
3
  import { platform, exit } from 'node:process'
4
- import build, * as buildT from './build.f.mjs'
4
+ import build, * as Build from './build.f.mjs'
5
5
  const { cpp, cs, rust } = build
6
6
  import string from '../../types/string/module.f.mjs'
7
7
  const { join } = string
@@ -21,7 +21,7 @@ const nodeJs = {
21
21
  platform,
22
22
  }
23
23
 
24
- /** @type {(f: buildT.Func) => void} */
24
+ /** @type {(f: Build.Func) => void} */
25
25
  const run = f => {
26
26
  const { file: { name, content }, line } = f(nodeJs)
27
27
  log(`${bold}writing: ${name}${reset}`)
@@ -0,0 +1,28 @@
1
+ declare namespace _default {
2
+ export { paramList };
3
+ export { result };
4
+ }
5
+ export default _default;
6
+ export type Library = { readonly [k in string]: Definition; };
7
+ export type Definition = Struct | Interface;
8
+ export type Struct = {
9
+ readonly struct: FieldArray;
10
+ };
11
+ export type FieldArray = { readonly [k in string]: Type; };
12
+ export type Field = O.Entry<Type>;
13
+ export type Interface = {
14
+ readonly interface: MethodArray;
15
+ readonly guid: string;
16
+ };
17
+ export type MethodArray = { readonly [k in string]: FieldArray; };
18
+ export type Method = O.Entry<FieldArray>;
19
+ export type Type = BaseType | Id | Pointer;
20
+ export type Id = readonly [string];
21
+ export type BaseType = "u8" | "i8" | "u16" | "i16" | "u32" | "i32" | "u64" | "i64" | "usize" | "isize" | "f32" | "f64" | "bool";
22
+ export type Pointer = readonly ["*", Type];
23
+ /** @type {(fa: FieldArray) => List.List<Field> } */
24
+ declare const paramList: (fa: FieldArray) => List.List<Field>;
25
+ /** @type {<T>(v: T) => (f: (type: Type) => T) => (fa: FieldArray) => T} */
26
+ declare const result: <T>(v: T) => (f: (type: Type) => T) => (fa: FieldArray) => T;
27
+ import * as O from '../../types/object/module.f.mjs';
28
+ import * as List from '../../types/list/module.f.mjs';
@@ -1,4 +1,4 @@
1
- import obj, * as O from '../../types/object/module.f.mjs'
1
+ import * as O from '../../types/object/module.f.mjs'
2
2
  import list, * as List from '../../types/list/module.f.mjs'
3
3
  import f from '../../types/function/module.f.mjs'
4
4
  const { compose } = f
@@ -0,0 +1,44 @@
1
+ declare const _default: {
2
+ Slice: {
3
+ struct: {
4
+ Start: ["*", "u8"];
5
+ Size: "usize";
6
+ };
7
+ };
8
+ ManagedStruct: {
9
+ struct: {
10
+ M: ["IMy"];
11
+ };
12
+ };
13
+ IMy: {
14
+ guid: string;
15
+ interface: {
16
+ GetSlice: {
17
+ _: ["Slice"];
18
+ };
19
+ SetSlice: {
20
+ slice: ["Slice"];
21
+ };
22
+ GetUnsafe: {
23
+ _: ["*", "bool"];
24
+ };
25
+ SetUnsafe: {
26
+ p: ["*", ["Slice"]];
27
+ size: "u32";
28
+ };
29
+ Some: {
30
+ p: ["IMy"];
31
+ _: "bool";
32
+ };
33
+ GetIMy: {
34
+ a: "u16";
35
+ b: "i16";
36
+ _: ["IMy"];
37
+ };
38
+ SetManagedStruct: {
39
+ a: ["ManagedStruct"];
40
+ };
41
+ };
42
+ };
43
+ };
44
+ export default _default;
@@ -0,0 +1,24 @@
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
+ /**
13
+ * @type {(compile: function_.Compile) =>
14
+ * (packageGet: packageT.Get) =>
15
+ * <M>(moduleMapInterface: moduleT.MapInterface<M>) =>
16
+ * (moduleId: moduleT.Id) =>
17
+ * (moduleMap: M) =>
18
+ * Result<M>
19
+ * }
20
+ */
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';
24
+ import * as function_ from '../module/function/module.f.mjs';
@@ -0,0 +1,3 @@
1
+ declare function _default(): void;
2
+ export default _default;
3
+ export type StringMap = { readonly [k in string]: string; };
@@ -0,0 +1,7 @@
1
+ declare const _default: {};
2
+ export default _default;
3
+ export type Function_ = <M>(require: Require<M>) => (prior: M) => Result<M>;
4
+ export type Result<M> = readonly [Result.Result<unknown, unknown>, M];
5
+ export type Require<M> = (path: string) => (prior: M) => Result<M>;
6
+ export type Compile = (source: string) => Result.Result<Function_, unknown>;
7
+ import * as Result from '../../../types/result/module.f.mjs';
@@ -0,0 +1,57 @@
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
+ /**
21
+ * @template M
22
+ * @typedef {{
23
+ * readonly at: (moduleId: string) => (moduleMap: M) => State | null
24
+ * readonly setReplace: (moduleId: string) => (moduleState: State) => (moduleMap: M) => M
25
+ * }} MapInterface
26
+ */
27
+ /**
28
+ * @typedef {|
29
+ * readonly['ok', Module] |
30
+ * readonly['error', Error]
31
+ * } State
32
+ */
33
+ /**
34
+ * @typedef {{
35
+ * readonly exports: unknown
36
+ * readonly requireMap: O.Map<string>
37
+ * }} Module
38
+ */
39
+ /**
40
+ * @typedef {|
41
+ * ['file not found'] |
42
+ * ['compilation error', unknown] |
43
+ * ['runtime error', unknown] |
44
+ * ['circular reference']
45
+ * } Error
46
+ */
47
+ /**
48
+ * @typedef {{
49
+ * readonly package: string
50
+ * readonly path: readonly string[]
51
+ * }} Id
52
+ */
53
+ /** @type {(id: Id) => Id | null} */
54
+ declare const dir: (id: Id) => Id | null;
55
+ /** @type {(id: Id) => string} */
56
+ declare const idToString: (id: Id) => string;
57
+ import * as O from '../../types/object/module.f.mjs';
@@ -1,4 +1,4 @@
1
- import object, * as O from '../../types/object/module.f.mjs'
1
+ import * as O from '../../types/object/module.f.mjs'
2
2
 
3
3
  /**
4
4
  * @template M
@@ -0,0 +1,7 @@
1
+ declare namespace _default {
2
+ export { compile };
3
+ }
4
+ export default _default;
5
+ /** @type {ModuleFunction.Compile} */
6
+ declare const compile: ModuleFunction.Compile;
7
+ import * as ModuleFunction from './module/function/module.f.mjs';
@@ -0,0 +1,4 @@
1
+ declare const _default: {};
2
+ export default _default;
3
+ export type PackageMap = (packageName: string) => PackageMap | Package | null;
4
+ export type Package = readonly [string, PackageMap, (fileName: string) => string | null];