functionalscript 0.0.389 → 0.0.392
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/com/cpp/module.f.cjs +41 -31
- package/com/cs/module.f.cjs +60 -41
- package/com/types/module.f.cjs +6 -2
- package/commonjs/build/module.f.cjs +19 -14
- package/commonjs/package/dependencies/module.f.cjs +5 -2
- package/commonjs/package/module.f.cjs +4 -2
- package/commonjs/path/module.f.cjs +16 -14
- package/dev/test/module.f.cjs +19 -0
- package/doc/vm.md +126 -118
- package/html/module.f.cjs +14 -9
- package/json/module.f.cjs +18 -11
- package/json/tokenizer/module.f.cjs +128 -164
- package/nodejs/version/module.f.cjs +4 -4
- package/package.json +1 -1
- package/sha2/module.f.cjs +29 -29
- package/test.f.cjs +1 -1
- package/text/encoding/module.f.cjs +0 -2
- package/text/module.f.cjs +2 -1
- package/types/array/module.f.cjs +2 -1
- package/types/btree/find/module.f.cjs +3 -2
- package/types/btree/remove/module.f.cjs +6 -5
- package/types/btree/set/module.f.cjs +9 -5
- package/types/list/module.f.cjs +38 -12
- package/types/map/module.f.cjs +11 -10
- package/types/module.f.cjs +1 -1
- package/types/object/module.f.cjs +9 -6
- package/types/object/test.html +9 -0
- package/types/result/module.cjs +3 -2
- package/types/{stringset → string_set}/module.f.cjs +12 -8
- /package/types/{stringset → string_set}/test.f.cjs +0 -0
package/com/cpp/module.f.cjs
CHANGED
|
@@ -1,37 +1,44 @@
|
|
|
1
1
|
const types = require('../types/module.f.cjs')
|
|
2
|
+
const { paramList } = types
|
|
2
3
|
const text = require('../../text/module.f.cjs')
|
|
3
4
|
const obj = require('../../types/object/module.f.cjs')
|
|
4
|
-
const
|
|
5
|
+
const list = require('../../types/list/module.f.cjs')
|
|
6
|
+
const { map, join, flatMap } = list
|
|
7
|
+
const { entries } = Object
|
|
5
8
|
|
|
6
9
|
/** @type {(name: string) => (body: text.Block) => text.Block} */
|
|
7
10
|
const struct = name => body => [`struct ${name}`, '{', body, '};']
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
case 'f64': return 'double'
|
|
24
|
-
case 'bool': return '::com::BOOL'
|
|
25
|
-
}
|
|
12
|
+
const baseTypeMap = {
|
|
13
|
+
u8: 'uint8_t',
|
|
14
|
+
i8: 'int8_t',
|
|
15
|
+
u16: 'uint16_t',
|
|
16
|
+
i16: 'int16_t',
|
|
17
|
+
u32: 'uint32_t',
|
|
18
|
+
i32: 'int32_t',
|
|
19
|
+
u64: 'uint64_t',
|
|
20
|
+
i64: 'int64_t',
|
|
21
|
+
usize: 'size_t',
|
|
22
|
+
isize: 'ptrdiff_t',
|
|
23
|
+
f32: 'float',
|
|
24
|
+
f64: 'double',
|
|
25
|
+
bool: '::com::BOOL',
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
+
/** @type {(t: types.BaseType) => string} */
|
|
29
|
+
const baseType = t => baseTypeMap[t]
|
|
30
|
+
|
|
31
|
+
const resultVoid = types.result('void')
|
|
32
|
+
|
|
33
|
+
const namespace = text.curly('namespace')
|
|
34
|
+
|
|
28
35
|
/** @type {(name: string) => (lib: types.Library) => text.Block} */
|
|
29
36
|
const cpp = name => lib => {
|
|
30
37
|
|
|
31
38
|
/** @type {(i: (t: string) => string) => (t: types.Type) => string} */
|
|
32
39
|
const objectType = i => t => {
|
|
33
|
-
if (typeof(t) === 'string') { return baseType(t) }
|
|
34
|
-
if (t.length === 2) { return `${type(t[1])}*` }
|
|
40
|
+
if (typeof (t) === 'string') { return baseType(t) }
|
|
41
|
+
if (t.length === 2) { return `${type(t[1])}*` }
|
|
35
42
|
const [id] = t
|
|
36
43
|
if (lib[id].interface === undefined) { return id }
|
|
37
44
|
return i(id)
|
|
@@ -42,33 +49,36 @@ const cpp = name => lib => {
|
|
|
42
49
|
/** @type {(s: types.Field) => text.Item} */
|
|
43
50
|
const field = ([name, t]) => `${type(t)} ${name};`
|
|
44
51
|
|
|
52
|
+
const mapField = map(field)
|
|
53
|
+
|
|
45
54
|
/** @type {(s: types.Struct) => text.Block} */
|
|
46
|
-
const defStruct = s =>
|
|
55
|
+
const defStruct = s => mapField(entries(s.struct))
|
|
47
56
|
|
|
48
57
|
/** @type {(fa: types.FieldArray) => string} */
|
|
49
|
-
const
|
|
58
|
+
const cppResult = resultVoid(type)
|
|
50
59
|
|
|
51
60
|
/** @type {(p: types.Field) => string} */
|
|
52
61
|
const param = ([name, t]) => `${objectType(id => `${id}&`)(t)} ${name}`
|
|
53
62
|
|
|
63
|
+
const mapParam = map(param)
|
|
64
|
+
|
|
54
65
|
/** @type {(m: types.Method) => text.Item} */
|
|
55
|
-
const method = ([name, paramArray]) =>
|
|
56
|
-
`virtual ${
|
|
66
|
+
const method = ([name, paramArray]) =>
|
|
67
|
+
`virtual ${cppResult(paramArray)} COM_STDCALL ${name}(${join(', ')(mapParam(paramList(paramArray)))}) = 0;`
|
|
68
|
+
|
|
69
|
+
const mapMethod = map(method)
|
|
57
70
|
|
|
58
71
|
/** @type {(i: types.Interface) => text.Block} */
|
|
59
|
-
const defInterface = i =>
|
|
72
|
+
const defInterface = i => mapMethod(entries(i.interface))
|
|
60
73
|
|
|
61
74
|
/** @type {(kv: obj.Entry<types.Definition>) => text.Block} */
|
|
62
|
-
const def = ([name, d]) => d.interface === undefined
|
|
63
|
-
? struct(name)(defStruct(d))
|
|
75
|
+
const def = ([name, d]) => d.interface === undefined
|
|
76
|
+
? struct(name)(defStruct(d))
|
|
64
77
|
: struct(`${name}: ::com::IUnknown`)(defInterface(d))
|
|
65
78
|
|
|
66
79
|
return list.flat([
|
|
67
80
|
['#pragma once', ''],
|
|
68
|
-
|
|
69
|
-
('namespace')
|
|
70
|
-
(name)
|
|
71
|
-
(list.flatMap(def)(Object.entries(lib)))
|
|
81
|
+
namespace(name)(flatMap(def)(entries(lib)))
|
|
72
82
|
])
|
|
73
83
|
}
|
|
74
84
|
|
package/com/cs/module.f.cjs
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
const types = require('../types/module.f.cjs')
|
|
2
|
+
const { result, paramList } = types
|
|
2
3
|
const text = require('../../text/module.f.cjs')
|
|
4
|
+
const { curly } = text
|
|
3
5
|
const list = require('../../types/list/module.f.cjs')
|
|
6
|
+
const { flat, map, some, join, flatMap } = list
|
|
4
7
|
const obj = require('../../types/object/module.f.cjs')
|
|
8
|
+
const { entries } = Object
|
|
5
9
|
|
|
6
10
|
/** @type {(v: string) => string} */
|
|
7
11
|
const using = v => `using ${v};`
|
|
@@ -14,30 +18,30 @@ const using = v => `using ${v};`
|
|
|
14
18
|
* list.List<text.Item>}
|
|
15
19
|
*/
|
|
16
20
|
const typeDef = attributes => type => name => body =>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
flat([
|
|
22
|
+
map(v => `[${v}]`)(attributes),
|
|
23
|
+
curly(`public ${type}`)(name)(body)
|
|
20
24
|
])
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
case 'u8': return 'byte'
|
|
37
|
-
case 'usize': return 'UIntPtr'
|
|
38
|
-
}
|
|
26
|
+
const baseTypeMap = {
|
|
27
|
+
bool: 'bool',
|
|
28
|
+
f32: 'float',
|
|
29
|
+
f64: 'double',
|
|
30
|
+
i16: 'short',
|
|
31
|
+
i32: 'int',
|
|
32
|
+
i64: 'long',
|
|
33
|
+
i8: 'sbyte',
|
|
34
|
+
isize: 'IntPtr',
|
|
35
|
+
u16: 'ushort',
|
|
36
|
+
u32: 'uint',
|
|
37
|
+
u64: 'ulong',
|
|
38
|
+
u8: 'byte',
|
|
39
|
+
usize: 'UIntPtr',
|
|
39
40
|
}
|
|
40
41
|
|
|
42
|
+
/** @type {(t: types.BaseType) => string} */
|
|
43
|
+
const baseType = t => baseTypeMap[t]
|
|
44
|
+
|
|
41
45
|
/** @type {(isUnsafe: boolean) => string} */
|
|
42
46
|
const unsafe = isUnsafe => isUnsafe ? 'unsafe ' : ''
|
|
43
47
|
|
|
@@ -53,6 +57,8 @@ const type = t => fullType(t)[1]
|
|
|
53
57
|
/** @type {(f: types.Field) => string} */
|
|
54
58
|
const param = ([name, t]) => `${type(t)} ${name}`
|
|
55
59
|
|
|
60
|
+
const mapParam = map(param)
|
|
61
|
+
|
|
56
62
|
/** @type {(f: types.Field) => string} */
|
|
57
63
|
const field = ([name, comType]) => {
|
|
58
64
|
const [isUnsafe, t] = fullType(comType)
|
|
@@ -62,46 +68,59 @@ const field = ([name, comType]) => {
|
|
|
62
68
|
/** @type {(field: types.Field) => boolean} */
|
|
63
69
|
const isUnsafeField = field => fullType(field[1])[0]
|
|
64
70
|
|
|
71
|
+
const mapIsUnsafeField = map(isUnsafeField)
|
|
72
|
+
|
|
73
|
+
const resultVoid = result('void')
|
|
74
|
+
|
|
75
|
+
const joinComma = join(', ')
|
|
76
|
+
|
|
65
77
|
/** @type {(e: obj.Entry<types.FieldArray>) => readonly string[]} */
|
|
66
78
|
const method = ([name, m]) => {
|
|
67
|
-
const paramAndResultList =
|
|
68
|
-
const pl =
|
|
69
|
-
const isUnsafe =
|
|
79
|
+
const paramAndResultList = entries(m)
|
|
80
|
+
const pl = paramList(m)
|
|
81
|
+
const isUnsafe = some(mapIsUnsafeField(paramAndResultList))
|
|
70
82
|
return [
|
|
71
83
|
'[PreserveSig]',
|
|
72
|
-
`${unsafe(isUnsafe)}${
|
|
84
|
+
`${unsafe(isUnsafe)}${resultVoid(type)(m)} ${name}(${joinComma(mapParam(pl))});`
|
|
73
85
|
]
|
|
74
86
|
}
|
|
75
87
|
|
|
88
|
+
const struct = typeDef
|
|
89
|
+
(['StructLayout(LayoutKind.Sequential)'])
|
|
90
|
+
('struct')
|
|
91
|
+
|
|
92
|
+
const mapField = map(field)
|
|
93
|
+
|
|
94
|
+
const flatMapMethod = flatMap(method)
|
|
95
|
+
|
|
76
96
|
/** @type {(e: obj.Entry<types.Definition>) => list.List<text.Item>} */
|
|
77
97
|
const def = ([n, d]) => {
|
|
78
98
|
const i = d.interface
|
|
79
99
|
return i === undefined ?
|
|
80
|
-
|
|
81
|
-
(['StructLayout(LayoutKind.Sequential)'])
|
|
82
|
-
('struct')
|
|
83
|
-
(n)
|
|
84
|
-
(list.map(field)(Object.entries(d.struct))) :
|
|
100
|
+
struct(n)(mapField(entries(d.struct))) :
|
|
85
101
|
typeDef
|
|
86
102
|
([`Guid("${d.guid}")`, 'InterfaceType(ComInterfaceType.InterfaceIsIUnknown)'])
|
|
87
103
|
('interface')
|
|
88
104
|
(n)
|
|
89
|
-
(
|
|
105
|
+
(flatMapMethod(entries(i)))
|
|
90
106
|
}
|
|
91
107
|
|
|
92
|
-
|
|
93
|
-
const cs = name => library => {
|
|
94
|
-
const v = list.flatMap(def)(Object.entries(library))
|
|
108
|
+
const flatMapDef = flatMap(def)
|
|
95
109
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
110
|
+
const namespace = curly('namespace')
|
|
111
|
+
|
|
112
|
+
/** @type {text.Block} */
|
|
113
|
+
const header = [
|
|
114
|
+
using('System'),
|
|
115
|
+
using('System.Runtime.InteropServices'),
|
|
116
|
+
''
|
|
117
|
+
]
|
|
102
118
|
|
|
103
|
-
|
|
104
|
-
|
|
119
|
+
/** @type {(name: string) => (library: types.Library) => text.Block} */
|
|
120
|
+
const cs = name => library => {
|
|
121
|
+
const v = flatMapDef(entries(library))
|
|
122
|
+
const ns = namespace(name)(v)
|
|
123
|
+
return flat([header, ns])
|
|
105
124
|
}
|
|
106
125
|
|
|
107
126
|
module.exports = {
|
package/com/types/module.f.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
const obj = require('../../types/object/module.f.cjs')
|
|
2
2
|
const list = require('../../types/list/module.f.cjs')
|
|
3
|
-
const {
|
|
3
|
+
const { compose } = require('../../types/function/module.f.cjs')
|
|
4
|
+
const { filter } = list
|
|
5
|
+
const { entries } = Object
|
|
4
6
|
|
|
5
7
|
/** @typedef {{readonly[k in string]: Definition}} Library */
|
|
6
8
|
|
|
@@ -55,8 +57,10 @@ const { types } = require('../module.f.cjs')
|
|
|
55
57
|
/** @type {(kv: obj.Entry<Type>) => boolean} */
|
|
56
58
|
const isParam = ([name]) => name !== '_'
|
|
57
59
|
|
|
60
|
+
const filterParam = filter(isParam)
|
|
61
|
+
|
|
58
62
|
/** @type {(fa: FieldArray) => list.List<Field> } */
|
|
59
|
-
const paramList =
|
|
63
|
+
const paramList = compose(entries)(filterParam)
|
|
60
64
|
|
|
61
65
|
/** @type {<T>(v: T) => (f: (type: Type) => T) => (fa: FieldArray) => T} */
|
|
62
66
|
const result = v => f => fa => {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
const package_ = require('../package/module.f.cjs')
|
|
2
2
|
const module_ = require('../module/module.f.cjs')
|
|
3
|
+
const { idToString, dir } = module_
|
|
3
4
|
const function_ = require('../module/function/module.f.cjs')
|
|
4
5
|
const map = require('../../types/map/module.f.cjs')
|
|
6
|
+
const { set: mapSet } = map
|
|
5
7
|
const object = require('../../types/object/module.f.cjs')
|
|
8
|
+
const { fromMap } = object
|
|
6
9
|
const path = require('../path/module.f.cjs')
|
|
7
|
-
const
|
|
10
|
+
const { parseAndFind } = path
|
|
11
|
+
const stringSet = require('../../types/string_set/module.f.cjs')
|
|
12
|
+
const { set: setSet, contains: setContains } = stringSet
|
|
8
13
|
|
|
9
14
|
/**
|
|
10
15
|
* @template M
|
|
@@ -44,20 +49,20 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
|
44
49
|
* Result<M>}
|
|
45
50
|
*/
|
|
46
51
|
const build = buildSet => moduleId => {
|
|
47
|
-
const moduleIdStr =
|
|
48
|
-
const buildSet1 =
|
|
49
|
-
const
|
|
52
|
+
const moduleIdStr = idToString(moduleId)
|
|
53
|
+
const buildSet1 = setSet(moduleIdStr)(buildSet)
|
|
54
|
+
const moduleDir = dir(moduleId)
|
|
50
55
|
/** @type {function_.Require<readonly[map.Map<string>, M]>} */
|
|
51
56
|
const require_ = p => ([requireMap, m]) => {
|
|
52
57
|
/** @type {(e: unknown) => function_.Result<readonly[map.Map<string>, M]>} */
|
|
53
58
|
const error = e => [['error', 'file not found'], [requireMap, m]]
|
|
54
|
-
if (
|
|
55
|
-
const r =
|
|
59
|
+
if (moduleDir === undefined) { return error('file not found') }
|
|
60
|
+
const r = parseAndFind(packageGet)(moduleDir)(p)
|
|
56
61
|
if (r === undefined) { return error('file not found') }
|
|
57
|
-
const rIdStr =
|
|
58
|
-
if (
|
|
62
|
+
const rIdStr = idToString(r.id)
|
|
63
|
+
if (setContains(rIdStr)(buildSet1)) { return error('circular reference') }
|
|
59
64
|
const [state, m1] = build(buildSet1)(r.id)(r.source)(m)
|
|
60
|
-
return [state[0] === 'error' ? state : ['ok', state[1].exports], [
|
|
65
|
+
return [state[0] === 'error' ? state : ['ok', state[1].exports], [mapSet(p)(rIdStr)(requireMap), m1]]
|
|
61
66
|
}
|
|
62
67
|
return source => moduleMap => {
|
|
63
68
|
/** @type {(s: module_.State) => (m: M) => Result<M>} */
|
|
@@ -68,16 +73,16 @@ const getOrBuild = compile => packageGet => moduleMapInterface => {
|
|
|
68
73
|
const [kind, result] = compile(source)
|
|
69
74
|
if (kind === 'error') { return error(['compilation error', result])(moduleMap) }
|
|
70
75
|
// build
|
|
71
|
-
const [
|
|
72
|
-
const x =
|
|
73
|
-
error(['runtime error',
|
|
74
|
-
set(['ok', { exports:
|
|
76
|
+
const [[state, value], [requireMap, moduleMap2]] = result(require_)([undefined, moduleMap])
|
|
77
|
+
const x = state === 'error' ?
|
|
78
|
+
error(['runtime error', value]) :
|
|
79
|
+
set(['ok', { exports: value, requireMap: fromMap(requireMap) }])
|
|
75
80
|
return x(moduleMap2)
|
|
76
81
|
}
|
|
77
82
|
}
|
|
78
83
|
/** @type {(moduleId: module_.Id) => (moduleMap: M) => Result<M>} */
|
|
79
84
|
const f = moduleId => moduleMap => {
|
|
80
|
-
const moduleIdStr =
|
|
85
|
+
const moduleIdStr = idToString(moduleId)
|
|
81
86
|
// check moduleMap
|
|
82
87
|
{
|
|
83
88
|
const m = moduleMapInterface.at(moduleIdStr)(moduleMap)
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
const json = require('../../../json/module.f.cjs')
|
|
2
|
+
const { isObject } = json
|
|
2
3
|
const list = require('../../../types/list/module.f.cjs')
|
|
4
|
+
const { map, every } = list
|
|
5
|
+
const { entries } = Object
|
|
3
6
|
|
|
4
7
|
/** @typedef {readonly[string, string]} DependencyJson */
|
|
5
8
|
|
|
@@ -13,8 +16,8 @@ const isDependencyJson = ([, v]) => typeof v === 'string'
|
|
|
13
16
|
/** @type {(j: json.Unknown|undefined) => j is DependenciesJson} */
|
|
14
17
|
const isDependenciesJson = j => {
|
|
15
18
|
if (j === undefined) { return true }
|
|
16
|
-
if (!
|
|
17
|
-
return
|
|
19
|
+
if (!isObject(j)) { return false }
|
|
20
|
+
return every(map(isDependencyJson)(entries(j)))
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
module.exports = {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
const json = require('../../json/module.f.cjs')
|
|
2
|
+
const { isObject } = json
|
|
2
3
|
const dependencies = require('./dependencies/module.f.cjs')
|
|
4
|
+
const { isDependenciesJson } = dependencies
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
7
|
* @typedef {{
|
|
@@ -11,10 +13,10 @@ const dependencies = require('./dependencies/module.f.cjs')
|
|
|
11
13
|
|
|
12
14
|
/** @type {(j: json.Unknown) => j is PackageJson} */
|
|
13
15
|
const isPackageJson = j => {
|
|
14
|
-
if (!
|
|
16
|
+
if (!isObject(j)) { return false }
|
|
15
17
|
if (typeof j.name !== 'string') { return false }
|
|
16
18
|
if (typeof j.version !== 'string') { return false }
|
|
17
|
-
if (!
|
|
19
|
+
if (!isDependenciesJson(j.dependencies)) { return false }
|
|
18
20
|
return true
|
|
19
21
|
}
|
|
20
22
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const list = require("../../types/list/module.f.cjs")
|
|
2
|
+
const { next, reduce, reverse, first, flat, toArray, filterMap, isEmpty, concat, join } = list
|
|
2
3
|
const package_ = require("../package/module.f.cjs")
|
|
3
4
|
const module_ = require("../module/module.f.cjs")
|
|
4
5
|
|
|
@@ -24,7 +25,7 @@ const normItemsOp = first => prior => {
|
|
|
24
25
|
switch (first) {
|
|
25
26
|
case '': case '.': { return prior }
|
|
26
27
|
case '..': {
|
|
27
|
-
const result =
|
|
28
|
+
const result = next(tail)
|
|
28
29
|
if (result === undefined) { return undefined }
|
|
29
30
|
return [result.tail]
|
|
30
31
|
}
|
|
@@ -36,19 +37,20 @@ const normItemsOp = first => prior => {
|
|
|
36
37
|
|
|
37
38
|
/** @type {(items: list.List<string>) => OptionList} */
|
|
38
39
|
const normItems = items => {
|
|
39
|
-
const result =
|
|
40
|
-
|
|
41
|
-
return [list.reverse(result[0])]
|
|
40
|
+
const result = reduce(normItemsOp)([undefined])(items)
|
|
41
|
+
return result === undefined ? result : [reverse(result[0])]
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
const firstUndefined = first(undefined)
|
|
45
|
+
|
|
44
46
|
/** @type {(local: string) => (path: string) => LocalPath|undefined} */
|
|
45
47
|
const parseLocal = local => {
|
|
46
48
|
/** @type {(path: string) => readonly[boolean, boolean, list.List<string>]} */
|
|
47
49
|
const fSeq = path => {
|
|
48
50
|
const pathSeq = split(path)
|
|
49
51
|
const dir = [undefined, '', '.', '..'].includes(pathSeq[pathSeq.length - 1])
|
|
50
|
-
return /** @type {readonly (string|undefined)[]} */(['.', '..']).includes(
|
|
51
|
-
[false, dir,
|
|
52
|
+
return /** @type {readonly (string|undefined)[]} */(['.', '..']).includes(firstUndefined(pathSeq)) ?
|
|
53
|
+
[false, dir, flat([split(local), pathSeq])] :
|
|
52
54
|
[true, dir, pathSeq]
|
|
53
55
|
}
|
|
54
56
|
/** @type {(path: string) => LocalPath|undefined} */
|
|
@@ -59,7 +61,7 @@ const parseLocal = local => {
|
|
|
59
61
|
return {
|
|
60
62
|
external,
|
|
61
63
|
dir,
|
|
62
|
-
items:
|
|
64
|
+
items: toArray(n[0])
|
|
63
65
|
}
|
|
64
66
|
}
|
|
65
67
|
return f
|
|
@@ -70,7 +72,7 @@ const parseLocal = local => {
|
|
|
70
72
|
/** @type {(prior: readonly[string|undefined, list.List<string>]) => list.Thunk<IdPath>} */
|
|
71
73
|
const variants = prior => () => {
|
|
72
74
|
const [a, b] = prior
|
|
73
|
-
const r =
|
|
75
|
+
const r = next(b)
|
|
74
76
|
if (r === undefined) { return undefined }
|
|
75
77
|
const { first, tail } = r
|
|
76
78
|
/** @type {IdPath} */
|
|
@@ -100,12 +102,12 @@ const mapDependency = d => ([external, internal]) => {
|
|
|
100
102
|
*/
|
|
101
103
|
const parseGlobal = dependencies =>
|
|
102
104
|
{
|
|
103
|
-
const
|
|
105
|
+
const fMap = filterMap(mapDependency(dependencies))
|
|
104
106
|
return dir => items => {
|
|
105
107
|
const v = variants([undefined, items])
|
|
106
|
-
const r =
|
|
108
|
+
const r = firstUndefined(fMap(v))
|
|
107
109
|
if (r === undefined) { return undefined }
|
|
108
|
-
return { package: r[0], items:
|
|
110
|
+
return { package: r[0], items: toArray(r[1]), dir }
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
|
|
@@ -154,9 +156,9 @@ const parseAndFind = packageGet => moduleId => path => {
|
|
|
154
156
|
return source === undefined ? undefined : { id: { package: p.package, path: file.split('/') }, source }
|
|
155
157
|
}
|
|
156
158
|
const file = p.items.join('/')
|
|
157
|
-
const indexJs =
|
|
158
|
-
const fileList = p.dir ||
|
|
159
|
-
return
|
|
159
|
+
const indexJs = join('/')(concat(p.items)(['index.js']))
|
|
160
|
+
const fileList = p.dir || isEmpty(p.items) ? [indexJs] : [file, `${file}.js`, indexJs]
|
|
161
|
+
return firstUndefined(filterMap(tryFile)(fileList))
|
|
160
162
|
}
|
|
161
163
|
|
|
162
164
|
module.exports = {
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const { todo } = require('../module.f.cjs')
|
|
2
|
+
const list = require('../../types/list/module.f.cjs')
|
|
3
|
+
const function_ = require('../../commonjs/module/function/module.f.cjs')
|
|
4
|
+
const package_ = require('../../commonjs/package/module.f.cjs')
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* @type {(c: function_.Compile) =>
|
|
8
|
+
* (files: string) =>
|
|
9
|
+
* (packageGet: package_.Get) =>
|
|
10
|
+
* never}
|
|
11
|
+
*/
|
|
12
|
+
const test = compile => files => packageGet => {
|
|
13
|
+
return todo()
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
module.exports = {
|
|
17
|
+
/** @readonly */
|
|
18
|
+
test,
|
|
19
|
+
}
|