functionalscript 0.0.592 → 0.1.594

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 (136) hide show
  1. package/.github/workflows/ci.yml +3 -3
  2. package/README.md +1 -0
  3. package/com/cpp/{module.f.cjs → module.f.mjs} +22 -21
  4. package/com/cpp/{test.f.cjs → test.f.mjs} +2 -2
  5. package/com/cpp/testlib.f.mjs +9 -0
  6. package/com/cs/{module.f.cjs → module.f.mjs} +20 -19
  7. package/com/cs/{test.f.cjs → test.f.mjs} +2 -2
  8. package/com/cs/testlib.f.mjs +10 -0
  9. package/com/rust/{module.f.cjs → module.f.mjs} +37 -35
  10. package/com/rust/{test.f.cjs → test.f.mjs} +2 -2
  11. package/com/rust/testlib.f.mjs +10 -0
  12. package/com/test/{build.f.cjs → build.f.mjs} +6 -6
  13. package/com/test/{build.cjs → build.mjs} +16 -8
  14. package/com/types/{module.f.cjs → module.f.mjs} +9 -8
  15. package/com/types/{testlib.f.cjs → testlib.f.mjs} +2 -2
  16. package/commonjs/build/{module.f.cjs → module.f.mjs} +23 -23
  17. package/commonjs/build/{test.f.cjs → test.f.mjs} +13 -12
  18. package/commonjs/module/function/{module.f.cjs → module.f.mjs} +4 -4
  19. package/commonjs/module/{module.f.cjs → module.f.mjs} +3 -5
  20. package/commonjs/module.f.mjs +11 -0
  21. package/commonjs/{module.cjs → module.mjs} +8 -6
  22. package/commonjs/package/dependencies/{module.f.cjs → module.f.mjs} +5 -5
  23. package/commonjs/package/dependencies/{test.f.cjs → test.f.mjs} +2 -2
  24. package/commonjs/package/{module.f.cjs → module.f.mjs} +7 -6
  25. package/commonjs/package/{test.f.cjs → test.f.mjs} +2 -2
  26. package/commonjs/path/{module.f.cjs → module.f.mjs} +15 -14
  27. package/commonjs/path/{test.f.cjs → test.f.mjs} +16 -14
  28. package/commonjs/{test.cjs → test.mjs} +4 -4
  29. package/dev/{module.f.cjs → module.f.mjs} +1 -1
  30. package/dev/module.mjs +5 -3
  31. package/dev/test/{module.f.cjs → module.f.mjs} +21 -9
  32. package/dev/{test.f.cjs → test.f.mjs} +1 -1
  33. package/dev/test.mjs +1 -1
  34. package/djs/{module.f.cjs → module.f.mjs} +18 -15
  35. package/djs/parser/{module.f.cjs → module.f.mjs} +29 -28
  36. package/djs/parser/{test.f.cjs → test.f.mjs} +10 -8
  37. package/djs/{test.f.cjs → test.f.mjs} +7 -5
  38. package/djs/tokenizer/{module.f.cjs → module.f.mjs} +19 -18
  39. package/djs/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
  40. package/fsc/{module.f.cjs → module.f.mjs} +17 -16
  41. package/fsc/{test.f.cjs → test.f.mjs} +6 -4
  42. package/fsm/{module.f.cjs → module.f.mjs} +28 -24
  43. package/fsm/{test.f.cjs → test.f.mjs} +13 -9
  44. package/html/{module.f.cjs → module.f.mjs} +16 -13
  45. package/html/{test.f.cjs → test.f.mjs} +5 -5
  46. package/index.f.mjs +45 -35
  47. package/issues/README.md +15 -0
  48. package/js/tokenizer/{module.f.cjs → module.f.mjs} +52 -51
  49. package/js/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
  50. package/json/{module.f.cjs → module.f.mjs} +18 -17
  51. package/json/parser/{module.f.cjs → module.f.mjs} +27 -26
  52. package/json/parser/{test.f.cjs → test.f.mjs} +10 -8
  53. package/json/serializer/{module.f.cjs → module.f.mjs} +12 -12
  54. package/json/serializer/{test.f.cjs → test.f.mjs} +4 -3
  55. package/json/{test.f.cjs → test.f.mjs} +6 -4
  56. package/json/tokenizer/{module.f.cjs → module.f.mjs} +16 -15
  57. package/json/tokenizer/{test.f.cjs → test.f.mjs} +9 -7
  58. package/jsr.json +1 -1
  59. package/nodejs/version/main.mjs +5 -0
  60. package/nodejs/version/{module.f.cjs → module.f.mjs} +2 -2
  61. package/nodejs/version/{test.f.cjs → test.f.mjs} +5 -5
  62. package/package.json +3 -3
  63. package/prime_field/{module.f.cjs → module.f.mjs} +6 -5
  64. package/prime_field/{test.f.cjs → test.f.mjs} +3 -2
  65. package/secp/{module.f.cjs → module.f.mjs} +7 -6
  66. package/secp/{test.f.cjs → test.f.mjs} +6 -6
  67. package/sha2/{module.f.cjs → module.f.mjs} +5 -5
  68. package/sha2/{test.f.cjs → test.f.mjs} +7 -6
  69. package/text/ascii/{module.f.cjs → module.f.mjs} +3 -3
  70. package/text/ascii/test.f.mjs +14 -0
  71. package/text/{module.f.cjs → module.f.mjs} +6 -6
  72. package/text/sgr/{module.f.cjs → module.f.mjs} +1 -1
  73. package/text/{test.f.cjs → test.f.mjs} +5 -4
  74. package/text/utf16/{module.f.cjs → module.f.mjs} +16 -14
  75. package/text/utf16/{test.f.cjs → test.f.mjs} +7 -6
  76. package/text/utf8/{module.f.cjs → module.f.mjs} +11 -11
  77. package/text/utf8/{test.f.cjs → test.f.mjs} +6 -5
  78. package/tsconfig.json +2 -2
  79. package/types/array/{module.f.cjs → module.f.mjs} +2 -2
  80. package/types/array/{test.f.cjs → test.f.mjs} +5 -4
  81. package/types/bigfloat/{module.f.cjs → module.f.mjs} +3 -3
  82. package/types/bigfloat/{test.f.cjs → test.f.mjs} +3 -2
  83. package/types/bigint/{module.f.cjs → module.f.mjs} +8 -7
  84. package/types/bigint/{test.f.cjs → test.f.mjs} +3 -2
  85. package/types/btree/find/{module.f.cjs → module.f.mjs} +12 -12
  86. package/types/btree/find/{test.f.cjs → test.f.mjs} +11 -9
  87. package/types/btree/{module.f.cjs → module.f.mjs} +7 -12
  88. package/types/btree/remove/{module.f.cjs → module.f.mjs} +17 -16
  89. package/types/btree/remove/{test.f.cjs → test.f.mjs} +9 -7
  90. package/types/btree/set/{module.f.cjs → module.f.mjs} +9 -9
  91. package/types/btree/set/{test.f.cjs → test.f.mjs} +8 -6
  92. package/types/btree/{test.f.cjs → test.f.mjs} +23 -20
  93. package/types/btree/types/{module.f.cjs → module.f.mjs} +1 -1
  94. package/types/byte_set/{module.f.cjs → module.f.mjs} +8 -7
  95. package/types/byte_set/{test.f.cjs → test.f.mjs} +8 -7
  96. package/types/function/compare/{module.f.cjs → module.f.mjs} +2 -2
  97. package/types/function/compare/{test.f.cjs → test.f.mjs} +3 -2
  98. package/types/function/{module.f.cjs → module.f.mjs} +1 -5
  99. package/types/function/operator/{module.f.cjs → module.f.mjs} +1 -1
  100. package/types/function/{test.f.cjs → test.f.mjs} +4 -2
  101. package/types/list/{module.f.cjs → module.f.mjs} +12 -12
  102. package/types/list/{test.f.cjs → test.f.mjs} +13 -11
  103. package/types/map/{module.f.cjs → module.f.mjs} +21 -18
  104. package/types/map/{test.f.cjs → test.f.mjs} +5 -4
  105. package/types/nibble_set/{module.f.cjs → module.f.mjs} +1 -1
  106. package/types/nibble_set/{test.f.cjs → test.f.mjs} +4 -3
  107. package/types/nullable/{module.f.cjs → module.f.mjs} +1 -1
  108. package/types/nullable/{test.f.cjs → test.f.mjs} +2 -2
  109. package/types/number/module.f.mjs +26 -0
  110. package/types/number/{test.f.cjs → test.f.mjs} +3 -2
  111. package/types/object/{module.f.cjs → module.f.mjs} +6 -6
  112. package/types/object/{test.f.cjs → test.f.mjs} +2 -2
  113. package/types/range/{module.f.cjs → module.f.mjs} +1 -1
  114. package/types/range/{test.f.cjs → test.f.mjs} +2 -2
  115. package/types/range_map/{module.f.cjs → module.f.mjs} +16 -15
  116. package/types/range_map/{test.f.cjs → test.f.mjs} +35 -33
  117. package/types/result/{module.f.cjs → module.f.mjs} +1 -1
  118. package/types/result/{module.cjs → module.mjs} +3 -3
  119. package/types/sorted_list/{module.f.cjs → module.f.mjs} +11 -10
  120. package/types/sorted_list/{test.f.cjs → test.f.mjs} +14 -10
  121. package/types/sorted_set/{module.f.cjs → module.f.mjs} +8 -7
  122. package/types/sorted_set/{test.f.cjs → test.f.mjs} +14 -10
  123. package/types/string/{module.f.cjs → module.f.mjs} +8 -7
  124. package/types/string/{test.f.cjs → test.f.mjs} +5 -3
  125. package/types/string_set/{module.f.cjs → module.f.mjs} +15 -10
  126. package/types/string_set/{test.f.cjs → test.f.mjs} +2 -2
  127. package/com/cpp/testlib.f.cjs +0 -6
  128. package/com/cs/testlib.f.cjs +0 -6
  129. package/com/module.f.cjs +0 -6
  130. package/com/rust/testlib.f.cjs +0 -6
  131. package/commonjs/module.f.cjs +0 -20
  132. package/nodejs/module.f.cjs +0 -4
  133. package/nodejs/version/main.cjs +0 -6
  134. package/text/ascii/test.f.cjs +0 -12
  135. package/types/number/module.f.cjs +0 -24
  136. package/types/object/test.html +0 -9
@@ -34,14 +34,14 @@ jobs:
34
34
 
35
35
  strategy:
36
36
  matrix:
37
- deno-version: [2]
37
+ deno-version: [1, 2]
38
38
 
39
39
  steps:
40
40
  - uses: actions/checkout@v2
41
41
  - uses: denoland/setup-deno@v1
42
42
  with:
43
43
  deno-version: ${{ matrix.deno-version }}
44
- - run: deno run --quiet --allow-read --allow-env --allow-net --allow-hrtime ./dev/test.mjs
44
+ - run: deno run --quiet --allow-read --allow-env --allow-net ./dev/test.mjs
45
45
 
46
46
  bun:
47
47
 
@@ -64,7 +64,7 @@ jobs:
64
64
  - uses: actions/checkout@v3
65
65
  - uses: actions/setup-node@v2
66
66
  with:
67
- node-version: 22
67
+ node-version: 23
68
68
  - uses: actions/setup-dotnet@v3
69
69
  with:
70
70
  dotnet-version: 9
package/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # FunctionalScript
2
2
 
3
3
  [![NPM Version](https://img.shields.io/npm/v/functionalscript)](https://www.npmjs.com/package/functionalscript)
4
+ [![JSR Version](https://img.shields.io/jsr/v/%40functionalscript/functionalscript)](https://jsr.io/@functionalscript/functionalscript)
4
5
 
5
6
  FunctionalScript is a purely functional programming language and a strict subset of
6
7
  [ECMAScript](https://en.wikipedia.org/wiki/ECMAScript)/[JavaScript](https://en.wikipedia.org/wiki/JavaScript). It's inspired by
@@ -1,13 +1,14 @@
1
- const types = require('../types/module.f.cjs')
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'
4
+ import list from '../../types/list/module.f.mjs'
5
+ import string from '../../types/string/module.f.mjs'
6
+ const { join } = string
2
7
  const { paramList } = types
3
- const text = require('../../text/module.f.cjs')
4
- const obj = require('../../types/object/module.f.cjs')
5
- const list = require('../../types/list/module.f.cjs')
6
8
  const { map, flatMap, flat } = list
7
- const { join } = require('../../types/string/module.f.cjs')
8
9
  const { entries } = Object
9
10
 
10
- /** @type {(name: string) => (body: text.Block) => text.Block} */
11
+ /** @type {(name: string) => (body: textT.Block) => textT.Block} */
11
12
  const struct = name => body => [`struct ${name}`, '{', body, '};']
12
13
 
13
14
  const baseTypeMap = {
@@ -26,7 +27,7 @@ const baseTypeMap = {
26
27
  bool: 'bool',
27
28
  }
28
29
 
29
- /** @type {(t: types.BaseType) => string} */
30
+ /** @type {(t: typesT.BaseType) => string} */
30
31
  const baseType = t => baseTypeMap[t]
31
32
 
32
33
  const resultVoid = types.result('void')
@@ -42,17 +43,17 @@ const ptr = id => `${id} const*`
42
43
  /** @type {(id: string) => string} */
43
44
  const ref = id => `${id} const&`
44
45
 
45
- /** @type {(p: types.Field) => string} */
46
+ /** @type {(p: typesT.Field) => string} */
46
47
  const paramName = ([name]) => name
47
48
 
48
49
  const mapParamName = map(paramName)
49
50
 
50
51
  const joinComma = join(', ')
51
52
 
52
- /** @type {(name: string) => (lib: types.Library) => text.Block} */
53
+ /** @type {(name: string) => (lib: typesT.Library) => textT.Block} */
53
54
  const cpp = name => lib => {
54
55
 
55
- /** @type {(t: types.Type) => string|null} */
56
+ /** @type {(t: typesT.Type) => string|null} */
56
57
  const interface_ = t => {
57
58
  if (!(t instanceof Array) || t.length !== 1) {
58
59
  return null
@@ -61,7 +62,7 @@ const cpp = name => lib => {
61
62
  return 'interface' in lib[name] ? name : null
62
63
  }
63
64
 
64
- /** @type {(i: (t: string) => string) => (t: types.Type) => string} */
65
+ /** @type {(i: (t: string) => string) => (t: typesT.Type) => string} */
65
66
  const objectType = i => t => {
66
67
  if (typeof (t) === 'string') { return baseType(t) }
67
68
  if (t.length === 2) { return `${type(t[1])} const*` }
@@ -73,27 +74,27 @@ const cpp = name => lib => {
73
74
 
74
75
  const resultType = objectType(ptr)
75
76
 
76
- /** @type {(s: types.Field) => text.Item} */
77
+ /** @type {(s: typesT.Field) => textT.Item} */
77
78
  const field = ([name, t]) => `${type(t)} ${name};`
78
79
 
79
80
  const mapField = map(field)
80
81
 
81
- /** @type {(s: types.Struct) => text.Block} */
82
+ /** @type {(s: typesT.Struct) => textT.Block} */
82
83
  const defStruct = s => mapField(entries(s.struct))
83
84
 
84
- /** @type {(fa: types.FieldArray) => string} */
85
+ /** @type {(fa: typesT.FieldArray) => string} */
85
86
  const cppResult = resultVoid(resultType)
86
87
 
87
- /** @type {(p: types.Field) => string} */
88
+ /** @type {(p: typesT.Field) => string} */
88
89
  const param = ([name, t]) => `${objectType(ref)(t)} ${name}`
89
90
 
90
91
  const mapParam = map(param)
91
92
 
92
- /** @type {(result: string) => (paramArrayStr: string) => (name: string) => text.Item} */
93
+ /** @type {(result: string) => (paramArrayStr: string) => (name: string) => textT.Item} */
93
94
  const methodHeader = result => paramArrayStr => name =>
94
95
  `virtual ${result} ${name}${paramArrayStr} const noexcept = 0;`
95
96
 
96
- /** @type {(m: types.Method) => readonly text.Item[]} */
97
+ /** @type {(m: typesT.Method) => readonly textT.Item[]} */
97
98
  const method = ([name, paramArray]) => {
98
99
  const result = cppResult(paramArray)
99
100
  const paramL = paramList(paramArray)
@@ -114,7 +115,7 @@ const cpp = name => lib => {
114
115
 
115
116
  const mapMethod = flatMap(method)
116
117
 
117
- /** @type {(i: types.Interface) => text.Block} */
118
+ /** @type {(i: typesT.Interface) => textT.Block} */
118
119
  const defInterface = ({ guid, interface: i }) => {
119
120
  const g = guid.replaceAll('-', '');
120
121
  const lo = g.substring(0, 16);
@@ -125,7 +126,7 @@ const cpp = name => lib => {
125
126
  ])
126
127
  }
127
128
 
128
- /** @type {(kv: obj.Entry<types.Definition>) => text.Block} */
129
+ /** @type {(kv: O.Entry<typesT.Definition>) => textT.Block} */
129
130
  const def = ([name, d]) => 'interface' in d
130
131
  ? [
131
132
  `class ${name} : public ::nanocom::IUnknown`,
@@ -136,7 +137,7 @@ const cpp = name => lib => {
136
137
  ]
137
138
  : struct(name)(defStruct(d))
138
139
 
139
- /** @type {(kv: obj.Entry<types.Definition>) => text.Block} */
140
+ /** @type {(kv: O.Entry<typesT.Definition>) => textT.Block} */
140
141
  const forward = ([name]) => [`struct ${name};`]
141
142
 
142
143
  const e = entries(lib)
@@ -147,7 +148,7 @@ const cpp = name => lib => {
147
148
  ])
148
149
  }
149
150
 
150
- module.exports = {
151
+ export default {
151
152
  /** @readonly */
152
153
  cpp,
153
154
  }
@@ -1,4 +1,4 @@
1
- const cpp = require('./testlib.f.cjs')
1
+ import cpp from './testlib.f.mjs'
2
2
 
3
3
  const f = () =>
4
4
  {
@@ -39,4 +39,4 @@ const f = () =>
39
39
  if (cpp() !== e) { throw cpp }
40
40
  }
41
41
 
42
- module.exports = f
42
+ export default f
@@ -0,0 +1,9 @@
1
+ import string from '../../types/string/module.f.mjs'
2
+ const { join } = string
3
+ import text from '../../text/module.f.mjs'
4
+ const { flat } = text
5
+ import library from '../types/testlib.f.mjs'
6
+ import m from './module.f.mjs'
7
+ const { cpp } = m
8
+
9
+ export default () => join('\n')(flat(' ')(cpp('My')(library)))
@@ -1,22 +1,23 @@
1
- const types = require('../types/module.f.cjs')
1
+ import types, * as typesT from '../types/module.f.mjs'
2
2
  const { result, paramList } = types
3
- const text = require('../../text/module.f.cjs')
3
+ import text, * as textT from '../../text/module.f.mjs'
4
4
  const { curly } = text
5
- const list = require('../../types/list/module.f.cjs')
5
+ import list, * as List from '../../types/list/module.f.mjs'
6
6
  const { flat, map, some, flatMap } = list
7
- const { join } = require('../../types/string/module.f.cjs')
8
- const obj = require('../../types/object/module.f.cjs')
7
+ import string from '../../types/string/module.f.mjs'
8
+ const { join } = string
9
+ import obj, * as O from '../../types/object/module.f.mjs'
9
10
  const { entries } = Object
10
11
 
11
12
  /** @type {(v: string) => string} */
12
13
  const using = v => `using ${v};`
13
14
 
14
15
  /**
15
- * @type {(attributes: list.List<string>) =>
16
+ * @type {(attributes: List.List<string>) =>
16
17
  * (type: string) =>
17
18
  * (name: string) =>
18
- * (body: text.Block) =>
19
- * list.List<text.Item>}
19
+ * (body: textT.Block) =>
20
+ * List.List<textT.Item>}
20
21
  */
21
22
  const typeDef = attributes => type => name => body =>
22
23
  flat([
@@ -40,33 +41,33 @@ const baseTypeMap = {
40
41
  usize: 'UIntPtr',
41
42
  }
42
43
 
43
- /** @type {(t: types.BaseType) => string} */
44
+ /** @type {(t: typesT.BaseType) => string} */
44
45
  const baseType = t => baseTypeMap[t]
45
46
 
46
47
  /** @type {(isUnsafe: boolean) => string} */
47
48
  const unsafe = isUnsafe => isUnsafe ? 'unsafe ' : ''
48
49
 
49
- /** @type {(t: types.Type) => readonly[boolean, string]} */
50
+ /** @type {(t: typesT.Type) => readonly[boolean, string]} */
50
51
  const fullType = t =>
51
52
  typeof (t) === 'string' ? [false, baseType(t)] :
52
53
  t.length === 1 ? [false, t[0]] :
53
54
  [true, `${type(t[1])}*`]
54
55
 
55
- /** @type {(m: types.Type) => string} */
56
+ /** @type {(m: typesT.Type) => string} */
56
57
  const type = t => fullType(t)[1]
57
58
 
58
- /** @type {(f: types.Field) => string} */
59
+ /** @type {(f: typesT.Field) => string} */
59
60
  const param = ([name, t]) => `${type(t)} ${name}`
60
61
 
61
62
  const mapParam = map(param)
62
63
 
63
- /** @type {(f: types.Field) => string} */
64
+ /** @type {(f: typesT.Field) => string} */
64
65
  const field = ([name, comType]) => {
65
66
  const [isUnsafe, t] = fullType(comType)
66
67
  return `public ${unsafe(isUnsafe)}${t} ${name};`
67
68
  }
68
69
 
69
- /** @type {(field: types.Field) => boolean} */
70
+ /** @type {(field: typesT.Field) => boolean} */
70
71
  const isUnsafeField = field => fullType(field[1])[0]
71
72
 
72
73
  const mapIsUnsafeField = map(isUnsafeField)
@@ -75,7 +76,7 @@ const resultVoid = result('void')
75
76
 
76
77
  const joinComma = join(', ')
77
78
 
78
- /** @type {(e: obj.Entry<types.FieldArray>) => readonly string[]} */
79
+ /** @type {(e: O.Entry<typesT.FieldArray>) => readonly string[]} */
79
80
  const method = ([name, m]) => {
80
81
  const paramAndResultList = entries(m)
81
82
  const pl = paramList(m)
@@ -94,7 +95,7 @@ const mapField = map(field)
94
95
 
95
96
  const flatMapMethod = flatMap(method)
96
97
 
97
- /** @type {(e: obj.Entry<types.Definition>) => list.List<text.Item>} */
98
+ /** @type {(e: O.Entry<typesT.Definition>) => List.List<textT.Item>} */
98
99
  const def = ([n, d]) => {
99
100
  return !('interface' in d) ?
100
101
  struct(n)(mapField(entries(d.struct))) :
@@ -109,21 +110,21 @@ const flatMapDef = flatMap(def)
109
110
 
110
111
  const namespace = curly('namespace')
111
112
 
112
- /** @type {text.Block} */
113
+ /** @type {textT.Block} */
113
114
  const header = [
114
115
  using('System'),
115
116
  using('System.Runtime.InteropServices'),
116
117
  ''
117
118
  ]
118
119
 
119
- /** @type {(name: string) => (library: types.Library) => text.Block} */
120
+ /** @type {(name: string) => (library: typesT.Library) => textT.Block} */
120
121
  const cs = name => library => {
121
122
  const v = flatMapDef(entries(library))
122
123
  const ns = namespace(name)(v)
123
124
  return flat([header, ns])
124
125
  }
125
126
 
126
- module.exports = {
127
+ export default {
127
128
  /** @readonly */
128
129
  cs,
129
130
  }
@@ -1,4 +1,4 @@
1
- const cs = require('./testlib.f.cjs')
1
+ import cs from './testlib.f.mjs'
2
2
 
3
3
  const f = () =>
4
4
  {
@@ -42,4 +42,4 @@ const f = () =>
42
42
  if (cs !== e) { throw cs }
43
43
  }
44
44
 
45
- module.exports = f
45
+ export default f
@@ -0,0 +1,10 @@
1
+ import text from '../../text/module.f.mjs'
2
+ const { flat } = text
3
+ import string from '../../types/string/module.f.mjs'
4
+ const { join } = string
5
+ import x from './module.f.mjs'
6
+ import library from '../types/testlib.f.mjs'
7
+
8
+ const { cs } = x
9
+
10
+ export default join('\n')(flat(' ')(cs('My')(library)))
@@ -1,19 +1,21 @@
1
- const types = require('../types/module.f.cjs')
1
+ import types, * as typesT from '../types/module.f.mjs'
2
2
  const { paramList } = types
3
- const text = require('../../text/module.f.cjs')
4
- const object = require('../../types/object/module.f.cjs')
5
- const list = require('../../types/list/module.f.cjs')
6
- const { flat, map, flatMap, isEmpty } = list
3
+ import text, * as textT from '../../text/module.f.mjs'
4
+ import object, * as O from '../../types/object/module.f.mjs'
5
+ import list, * as List from '../../types/list/module.f.mjs'
6
+ const { flat, map, flatMap } = list
7
7
  const { entries } = Object
8
- const { fn } = require('../../types/function/module.f.cjs')
9
- const { join } = require('../../types/string/module.f.cjs')
8
+ import func from '../../types/function/module.f.mjs'
9
+ const { fn } = func
10
+ import string from '../../types/string/module.f.mjs'
11
+ const { join } = string
10
12
 
11
13
  /** @type {(field: string) => string} */
12
14
  const rustField = field => `pub ${field},`
13
15
 
14
16
  const mapRustField = map(rustField)
15
17
 
16
- /** @type {(b: list.Thunk<string>) => (name: string) => text.Block} */
18
+ /** @type {(b: List.Thunk<string>) => (name: string) => textT.Block} */
17
19
  const rustStruct = b => name => [`#[repr(C)]`, `pub struct ${name} {`, mapRustField(b), `}`]
18
20
 
19
21
  const commaJoin = join(', ')
@@ -26,21 +28,21 @@ const obj = name => `&${name}::Object`
26
28
 
27
29
  const self = ['&self']
28
30
 
29
- /** @type {(p: types.Field) => string} */
31
+ /** @type {(p: typesT.Field) => string} */
30
32
  const paramName = ([n]) => n
31
33
 
32
- /** @type {(p: types.FieldArray) => list.Thunk<string>} */
34
+ /** @type {(p: typesT.FieldArray) => List.Thunk<string>} */
33
35
  const callList = p => map(paramName)(paramList(p))
34
36
 
35
- /** @type {(p: types.FieldArray) => string} */
37
+ /** @type {(p: typesT.FieldArray) => string} */
36
38
  const call = p => commaJoin(callList(p))
37
39
 
38
- /** @type {(p: types.FieldArray) => string} */
40
+ /** @type {(p: typesT.FieldArray) => string} */
39
41
  const virtualCall = p => commaJoin(flat([['self'], callList(p)]))
40
42
 
41
43
  const super_ = 'super::'
42
44
 
43
- /** @type {(m: types.Method) => string} */
45
+ /** @type {(m: typesT.Method) => string} */
44
46
  const assign = ([n]) => `${n}: Self::${n},`
45
47
 
46
48
  const mapAssign = map(assign)
@@ -58,10 +60,10 @@ const rustType = n => `pub type ${n} = nanocom::${n}<Interface>;`
58
60
  /** @typedef {{readonly where: readonly string[]}} Where */
59
61
 
60
62
  /**
61
- * @typedef {OptionalProperty<Where> & {readonly content: text.Block}} WhereContent
63
+ * @typedef {OptionalProperty<Where> & {readonly content: textT.Block}} WhereContent
62
64
  */
63
65
 
64
- /** @type {(h: string) => (wh: WhereContent) => text.Block} */
66
+ /** @type {(h: string) => (wh: WhereContent) => textT.Block} */
65
67
  const whereContent = h => wh => {
66
68
  const w = 'where' in wh ? [
67
69
  h,
@@ -82,11 +84,11 @@ const whereContent = h => wh => {
82
84
  * readonly trait: string
83
85
  * readonly type: string
84
86
  * readonly where?: readonly string[]
85
- * readonly content: text.Block
87
+ * readonly content: textT.Block
86
88
  * }} Impl
87
89
  */
88
90
 
89
- /** @type {(impl: Impl) => text.Block} */
91
+ /** @type {(impl: Impl) => textT.Block} */
90
92
  const rustImpl = i => {
91
93
  const p = 'param' in i ? `<${i.param}>` : ''
92
94
  const header = `impl${p} ${i.trait} for ${i.type}`
@@ -98,7 +100,7 @@ const rustImpl = i => {
98
100
  * readonly pub?: true
99
101
  * readonly type: string
100
102
  * readonly where?: readonly string[]
101
- * readonly content: text.Block
103
+ * readonly content: textT.Block
102
104
  * }} Trait
103
105
  */
104
106
 
@@ -107,14 +109,14 @@ const comma = s => `${s},`
107
109
 
108
110
  const mapComma = map(comma)
109
111
 
110
- /** @type {(t: Trait) => text.Block} */
112
+ /** @type {(t: Trait) => textT.Block} */
111
113
  const trait = t => {
112
114
  const p = t.pub === true ? 'pub ' : ''
113
115
  const h = `${p}trait ${t.type}`
114
116
  return whereContent(h)(t)
115
117
  }
116
118
 
117
- /** @type {(t: Trait) => text.Block} */
119
+ /** @type {(t: Trait) => textT.Block} */
118
120
  const traitImpl = t => {
119
121
  const i = rustImpl({
120
122
  param: 'T',
@@ -128,12 +130,12 @@ const traitImpl = t => {
128
130
 
129
131
  const where = ['Self: nanocom::Class<Interface = Interface>', 'nanocom::CObject<Self>: Ex']
130
132
 
131
- /** @type {(library: types.Library) => text.Block} */
133
+ /** @type {(library: typesT.Library) => textT.Block} */
132
134
  const rust = library => {
133
135
 
134
- /** @type {(p: string) => (o: (_: string) => string) => (t: types.Type) => string} */
136
+ /** @type {(p: string) => (o: (_: string) => string) => (t: typesT.Type) => string} */
135
137
  const type = p => {
136
- /** @type {(o: (_: string) => string) => (t: types.Type) => string} */
138
+ /** @type {(o: (_: string) => string) => (t: typesT.Type) => string} */
137
139
  const f = o => t => {
138
140
  if (typeof t === 'string') { return t }
139
141
  if (t.length === 2) { return `*const ${f(ref)(t[1])}` }
@@ -144,7 +146,7 @@ const rust = library => {
144
146
  return f
145
147
  }
146
148
 
147
- /** @type {(p: string) => (o: (_: string) => string) => (f: types.Field) => string} */
149
+ /** @type {(p: string) => (o: (_: string) => string) => (f: typesT.Field) => string} */
148
150
  const pf = p => o => ([name, t]) => `${name}: ${type(p)(o)(t)}`
149
151
 
150
152
  const param = pf(super_)(obj)
@@ -153,36 +155,36 @@ const rust = library => {
153
155
 
154
156
  const mapField = map(pf('')(ref))
155
157
 
156
- /** @type {(fa: types.FieldArray) => (name: string) => text.Block} */
158
+ /** @type {(fa: typesT.FieldArray) => (name: string) => textT.Block} */
157
159
  const struct = fn(entries)
158
160
  .then(mapField)
159
161
  .then(rustStruct)
160
162
  .result
161
163
 
162
- /** @type {(first: readonly string[]) => (p: types.FieldArray) => string} */
164
+ /** @type {(first: readonly string[]) => (p: typesT.FieldArray) => string} */
163
165
  const func = first => p => {
164
166
  const resultStr = '_' in p ? ` -> ${type(super_)(ref)(p._)}` : ''
165
167
  const params = commaJoin(flat([first, mapParam(paramList(p))]))
166
168
  return `(${params})${resultStr}`
167
169
  }
168
170
 
169
- /** @type {(n: string) => (p: types.FieldArray) => string} */
171
+ /** @type {(n: string) => (p: typesT.FieldArray) => string} */
170
172
  const virtualFnType = n => p => `extern "system" fn${n}${func(this_)(p)}`
171
173
 
172
- /** @type {(m: types.Method) => string} */
174
+ /** @type {(m: typesT.Method) => string} */
173
175
  const virtualFn = ([n, p]) => `${n}: unsafe ${virtualFnType('')(p)}`
174
176
 
175
177
  const mapVirtualFn = map(virtualFn)
176
178
 
177
- /** @type {(m: types.Method) => string} */
179
+ /** @type {(m: typesT.Method) => string} */
178
180
  const headerFn = ([n, p]) => `fn ${n}${func(self)(p)}`
179
181
 
180
- /** @type {(m: types.Method) => string} */
182
+ /** @type {(m: typesT.Method) => string} */
181
183
  const traitFn = m => `${headerFn(m)};`
182
184
 
183
185
  const mapTraitFn = map(traitFn)
184
186
 
185
- /** @type {(m: types.Method) => text.Block} */
187
+ /** @type {(m: typesT.Method) => textT.Block} */
186
188
  const implFn = m => {
187
189
  const [n, p] = m
188
190
  return [
@@ -194,7 +196,7 @@ const rust = library => {
194
196
 
195
197
  const flatMapImplFn = flatMap(implFn)
196
198
 
197
- /** @type {(m: types.Method) => text.Block} */
199
+ /** @type {(m: typesT.Method) => textT.Block} */
198
200
  const impl = ([n, p]) => {
199
201
  const type = virtualFnType(` ${n}`)(p)
200
202
  return [
@@ -206,7 +208,7 @@ const rust = library => {
206
208
 
207
209
  const flatMapImpl = flatMap(impl)
208
210
 
209
- /** @type {(i: types.Interface) => (name: string) => text.Block} */
211
+ /** @type {(i: typesT.Interface) => (name: string) => textT.Block} */
210
212
  const interface_ = ({ interface: i, guid }) => name => {
211
213
 
212
214
  const e = entries(i)
@@ -250,13 +252,13 @@ const rust = library => {
250
252
  ]
251
253
  }
252
254
 
253
- /** @type {(type: object.Entry<types.Definition>) => text.Block} */
255
+ /** @type {(type: O.Entry<typesT.Definition>) => textT.Block} */
254
256
  const def = ([name, type]) => ('interface' in type ? interface_(type) : struct(type.struct))(name)
255
257
 
256
258
  return flat([['#![allow(non_snake_case)]'], flatMap(def)(entries(library))])
257
259
  }
258
260
 
259
- module.exports = {
261
+ export default {
260
262
  /** @readonly */
261
263
  rust,
262
264
  }
@@ -1,6 +1,6 @@
1
- const rust = require('./testlib.f.cjs')
1
+ import rust from './testlib.f.mjs'
2
2
 
3
- module.exports = () => {
3
+ export default () => {
4
4
  const e =
5
5
  '#![allow(non_snake_case)]\n' +
6
6
  '#[repr(C)]\n' +
@@ -0,0 +1,10 @@
1
+ import text from '../../text/module.f.mjs'
2
+ const { flat } = text
3
+ import string from '../../types/string/module.f.mjs'
4
+ const { join } = string
5
+ import x from './module.f.mjs'
6
+ import library from '../types/testlib.f.mjs'
7
+
8
+ const { rust } = x
9
+
10
+ export default join('\n')(flat(' ')(rust(library)))
@@ -1,9 +1,9 @@
1
- const list = require('../../types/list/module.f.cjs')
1
+ import list, * as List from '../../types/list/module.f.mjs'
2
2
  const { flat } = list
3
3
 
4
- const cppContent = require('../cpp/testlib.f.cjs')
5
- const csContent = require('../cs/testlib.f.cjs')
6
- const rustContent = require("../rust/testlib.f.cjs")
4
+ import cppContent from '../cpp/testlib.f.mjs'
5
+ import csContent from '../cs/testlib.f.mjs'
6
+ import rustContent from '../rust/testlib.f.mjs'
7
7
 
8
8
  /**
9
9
  * @typedef {|
@@ -34,7 +34,7 @@ const rustContent = require("../rust/testlib.f.cjs")
34
34
  * readonly name: string
35
35
  * readonly content: string
36
36
  * }
37
- * readonly line: list.List<list.List<string>>
37
+ * readonly line: List.List<List.List<string>>
38
38
  * }} Output
39
39
  */
40
40
 
@@ -99,7 +99,7 @@ const rust = ({ dirname }) => ({
99
99
  line: [['cargo', 'build' /**, '--locked' */]]
100
100
  })
101
101
 
102
- module.exports = {
102
+ export default {
103
103
  /** @readonly */
104
104
  cpp,
105
105
  /** @readonly */
@@ -1,19 +1,27 @@
1
- const { writeFileSync } = require('node:fs')
2
- const { execSync } = require('node:child_process')
3
- const { platform, exit } = require('node:process')
4
- const build = require('./build.f.cjs')
1
+ import { writeFileSync } from 'node:fs'
2
+ import { execSync } from 'node:child_process'
3
+ import { platform, exit } from 'node:process'
4
+ import build, * as buildT from './build.f.mjs'
5
5
  const { cpp, cs, rust } = build
6
- const { join } = require('../../types/string/module.f.cjs')
6
+ import string from '../../types/string/module.f.mjs'
7
+ const { join } = string
7
8
  const { log, error } = console
8
- const { bold, reset } = require('../../text/sgr/module.f.cjs')
9
- const list = require('../../types/list/module.f.cjs')
9
+ import sgr from '../../text/sgr/module.f.mjs'
10
+ const { bold, reset } = sgr
11
+ import list from '../../types/list/module.f.mjs'
12
+
13
+ import { fileURLToPath } from 'node:url'
14
+ import { dirname } from 'node:path'
15
+
16
+ const __filename = fileURLToPath(import.meta.url);
17
+ const __dirname = dirname(__filename)
10
18
 
11
19
  const nodeJs = {
12
20
  dirname: __dirname,
13
21
  platform,
14
22
  }
15
23
 
16
- /** @type {(f: build.Func) => void} */
24
+ /** @type {(f: buildT.Func) => void} */
17
25
  const run = f => {
18
26
  const { file: { name, content }, line } = f(nodeJs)
19
27
  log(`${bold}writing: ${name}${reset}`)