@ai-workbench/connect 0.0.0-stage → 0.7.5
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/NOTICE.md +18 -0
- package/README.md +24 -2
- package/client/index.cjs +123 -0
- package/cordis.patch.yml +3 -0
- package/helper/auth-status.cjs +18 -0
- package/helper/claude-callback.cjs +29 -0
- package/helper/main.cjs +19 -0
- package/helper/projects.cjs +57 -0
- package/helper/remote-command.cjs +15 -0
- package/helper/remote-login.cjs +25 -0
- package/helper/window.cjs +52 -0
- package/lib/api.d.ts +196 -0
- package/lib/api.js +1 -0
- package/lib/archive.d.ts +1 -0
- package/lib/archive.js +63 -0
- package/lib/auth-status.d.ts +3 -0
- package/lib/auth-status.js +18 -0
- package/lib/cache.d.ts +21 -0
- package/lib/cache.js +156 -0
- package/lib/component-download.d.ts +25 -0
- package/lib/component-download.js +73 -0
- package/lib/components.d.ts +9 -0
- package/lib/components.js +121 -0
- package/lib/connect.d.ts +10 -0
- package/lib/connect.js +246 -0
- package/lib/cordis.d.ts +15 -0
- package/lib/cordis.js +1 -0
- package/lib/defaults.d.ts +29 -0
- package/lib/defaults.js +4 -0
- package/lib/electron.d.ts +8 -0
- package/lib/electron.js +83 -0
- package/lib/enrollment.d.ts +3 -0
- package/lib/enrollment.js +78 -0
- package/lib/index.d.ts +40 -0
- package/lib/index.js +48 -0
- package/lib/integration.d.ts +5 -0
- package/lib/integration.js +47 -0
- package/lib/login.d.ts +35 -0
- package/lib/login.js +81 -0
- package/lib/native-import-picker.d.ts +11 -0
- package/lib/native-import-picker.js +49 -0
- package/lib/needs.d.ts +9 -0
- package/lib/needs.js +52 -0
- package/lib/network.d.ts +26 -0
- package/lib/network.js +226 -0
- package/lib/physical-fs.d.ts +3 -0
- package/lib/physical-fs.js +7 -0
- package/lib/ports.d.ts +43 -0
- package/lib/ports.js +1 -0
- package/lib/private-files.d.ts +3 -0
- package/lib/private-files.js +41 -0
- package/lib/processes.d.ts +5 -0
- package/lib/processes.js +147 -0
- package/lib/profile-activation.d.ts +32 -0
- package/lib/profile-activation.js +118 -0
- package/lib/profile-enrollment.d.ts +21 -0
- package/lib/profile-enrollment.js +275 -0
- package/lib/profile-runtime.d.ts +6 -0
- package/lib/profile-runtime.js +47 -0
- package/lib/profile-settings.d.ts +2 -0
- package/lib/profile-settings.js +10 -0
- package/lib/projects.d.ts +4 -0
- package/lib/projects.js +41 -0
- package/lib/provider.d.ts +73 -0
- package/lib/provider.js +39 -0
- package/lib/remote-login.d.ts +2 -0
- package/lib/remote-login.js +9 -0
- package/lib/ssh.d.ts +10 -0
- package/lib/ssh.js +78 -0
- package/lib/startup.d.ts +18 -0
- package/lib/startup.js +211 -0
- package/lib/workspace-bindings.d.ts +32 -0
- package/lib/workspace-bindings.js +328 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/node_modules/argparse/LICENSE +254 -0
- package/node_modules/argparse/README.md +84 -0
- package/node_modules/argparse/argparse.js +3707 -0
- package/node_modules/argparse/lib/sub.js +67 -0
- package/node_modules/argparse/lib/textwrap.js +440 -0
- package/node_modules/argparse/package.json +31 -0
- package/node_modules/js-yaml/LICENSE +21 -0
- package/node_modules/js-yaml/README.md +233 -0
- package/node_modules/js-yaml/bin/js-yaml.js +117 -0
- package/node_modules/js-yaml/dist/js-yaml.js +3022 -0
- package/node_modules/js-yaml/dist/js-yaml.js.map +1 -0
- package/node_modules/js-yaml/dist/js-yaml.min.js +2 -0
- package/node_modules/js-yaml/dist/js-yaml.min.js.map +1 -0
- package/node_modules/js-yaml/dist/js-yaml.mjs +3082 -0
- package/node_modules/js-yaml/dist/js-yaml.mjs.map +1 -0
- package/node_modules/js-yaml/index.js +44 -0
- package/node_modules/js-yaml/lib/common.js +50 -0
- package/node_modules/js-yaml/lib/dumper.js +937 -0
- package/node_modules/js-yaml/lib/exception.js +51 -0
- package/node_modules/js-yaml/lib/index_vite_proxy.tmp.mjs +37 -0
- package/node_modules/js-yaml/lib/loader.js +1803 -0
- package/node_modules/js-yaml/lib/schema/core.js +9 -0
- package/node_modules/js-yaml/lib/schema/default.js +20 -0
- package/node_modules/js-yaml/lib/schema/failsafe.js +14 -0
- package/node_modules/js-yaml/lib/schema/json.js +17 -0
- package/node_modules/js-yaml/lib/schema.js +109 -0
- package/node_modules/js-yaml/lib/snippet.js +96 -0
- package/node_modules/js-yaml/lib/type/binary.js +122 -0
- package/node_modules/js-yaml/lib/type/bool.js +35 -0
- package/node_modules/js-yaml/lib/type/float.js +99 -0
- package/node_modules/js-yaml/lib/type/int.js +142 -0
- package/node_modules/js-yaml/lib/type/map.js +8 -0
- package/node_modules/js-yaml/lib/type/merge.js +12 -0
- package/node_modules/js-yaml/lib/type/null.js +35 -0
- package/node_modules/js-yaml/lib/type/omap.js +45 -0
- package/node_modules/js-yaml/lib/type/pairs.js +50 -0
- package/node_modules/js-yaml/lib/type/seq.js +8 -0
- package/node_modules/js-yaml/lib/type/set.js +29 -0
- package/node_modules/js-yaml/lib/type/str.js +8 -0
- package/node_modules/js-yaml/lib/type/timestamp.js +88 -0
- package/node_modules/js-yaml/lib/type.js +66 -0
- package/node_modules/js-yaml/package.json +83 -0
- package/node_modules/pend/LICENSE +23 -0
- package/node_modules/pend/README.md +41 -0
- package/node_modules/pend/index.js +55 -0
- package/node_modules/pend/package.json +18 -0
- package/node_modules/pend/test.js +137 -0
- package/node_modules/yauzl/LICENSE +21 -0
- package/node_modules/yauzl/README.md +1015 -0
- package/node_modules/yauzl/crc32.js +45 -0
- package/node_modules/yauzl/fd-slicer.js +188 -0
- package/node_modules/yauzl/index.js +1096 -0
- package/node_modules/yauzl/package.json +40 -0
- package/package.json +89 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Type = require('../type')
|
|
4
|
+
|
|
5
|
+
function resolveYamlNull (data) {
|
|
6
|
+
if (data === null) return true
|
|
7
|
+
|
|
8
|
+
const max = data.length
|
|
9
|
+
|
|
10
|
+
return (max === 1 && data === '~') ||
|
|
11
|
+
(max === 4 && (data === 'null' || data === 'Null' || data === 'NULL'))
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function constructYamlNull () {
|
|
15
|
+
return null
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function isNull (object) {
|
|
19
|
+
return object === null
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
module.exports = new Type('tag:yaml.org,2002:null', {
|
|
23
|
+
kind: 'scalar',
|
|
24
|
+
resolve: resolveYamlNull,
|
|
25
|
+
construct: constructYamlNull,
|
|
26
|
+
predicate: isNull,
|
|
27
|
+
represent: {
|
|
28
|
+
canonical: function () { return '~' },
|
|
29
|
+
lowercase: function () { return 'null' },
|
|
30
|
+
uppercase: function () { return 'NULL' },
|
|
31
|
+
camelcase: function () { return 'Null' },
|
|
32
|
+
empty: function () { return '' }
|
|
33
|
+
},
|
|
34
|
+
defaultStyle: 'lowercase'
|
|
35
|
+
})
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Type = require('../type')
|
|
4
|
+
|
|
5
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty
|
|
6
|
+
const _toString = Object.prototype.toString
|
|
7
|
+
|
|
8
|
+
function resolveYamlOmap (data) {
|
|
9
|
+
if (data === null) return true
|
|
10
|
+
|
|
11
|
+
const objectKeys = {}
|
|
12
|
+
const object = data
|
|
13
|
+
|
|
14
|
+
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
15
|
+
const pair = object[index]
|
|
16
|
+
let pairHasKey = false
|
|
17
|
+
|
|
18
|
+
if (_toString.call(pair) !== '[object Object]') return false
|
|
19
|
+
|
|
20
|
+
let pairKey
|
|
21
|
+
for (pairKey in pair) {
|
|
22
|
+
if (_hasOwnProperty.call(pair, pairKey)) {
|
|
23
|
+
if (!pairHasKey) pairHasKey = true
|
|
24
|
+
else return false
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (!pairHasKey) return false
|
|
29
|
+
|
|
30
|
+
if (_hasOwnProperty.call(objectKeys, pairKey)) return false
|
|
31
|
+
Object.defineProperty(objectKeys, pairKey, { value: true })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function constructYamlOmap (data) {
|
|
38
|
+
return data !== null ? data : []
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
module.exports = new Type('tag:yaml.org,2002:omap', {
|
|
42
|
+
kind: 'sequence',
|
|
43
|
+
resolve: resolveYamlOmap,
|
|
44
|
+
construct: constructYamlOmap
|
|
45
|
+
})
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Type = require('../type')
|
|
4
|
+
|
|
5
|
+
const _toString = Object.prototype.toString
|
|
6
|
+
|
|
7
|
+
function resolveYamlPairs (data) {
|
|
8
|
+
if (data === null) return true
|
|
9
|
+
|
|
10
|
+
const object = data
|
|
11
|
+
|
|
12
|
+
const result = new Array(object.length)
|
|
13
|
+
|
|
14
|
+
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
15
|
+
const pair = object[index]
|
|
16
|
+
|
|
17
|
+
if (_toString.call(pair) !== '[object Object]') return false
|
|
18
|
+
|
|
19
|
+
const keys = Object.keys(pair)
|
|
20
|
+
|
|
21
|
+
if (keys.length !== 1) return false
|
|
22
|
+
|
|
23
|
+
result[index] = [keys[0], pair[keys[0]]]
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function constructYamlPairs (data) {
|
|
30
|
+
if (data === null) return []
|
|
31
|
+
|
|
32
|
+
const object = data
|
|
33
|
+
const result = new Array(object.length)
|
|
34
|
+
|
|
35
|
+
for (let index = 0, length = object.length; index < length; index += 1) {
|
|
36
|
+
const pair = object[index]
|
|
37
|
+
|
|
38
|
+
const keys = Object.keys(pair)
|
|
39
|
+
|
|
40
|
+
result[index] = [keys[0], pair[keys[0]]]
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return result
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
module.exports = new Type('tag:yaml.org,2002:pairs', {
|
|
47
|
+
kind: 'sequence',
|
|
48
|
+
resolve: resolveYamlPairs,
|
|
49
|
+
construct: constructYamlPairs
|
|
50
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Type = require('../type')
|
|
4
|
+
|
|
5
|
+
const _hasOwnProperty = Object.prototype.hasOwnProperty
|
|
6
|
+
|
|
7
|
+
function resolveYamlSet (data) {
|
|
8
|
+
if (data === null) return true
|
|
9
|
+
|
|
10
|
+
const object = data
|
|
11
|
+
|
|
12
|
+
for (const key in object) {
|
|
13
|
+
if (_hasOwnProperty.call(object, key)) {
|
|
14
|
+
if (object[key] !== null) return false
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return true
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function constructYamlSet (data) {
|
|
22
|
+
return data !== null ? data : {}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
module.exports = new Type('tag:yaml.org,2002:set', {
|
|
26
|
+
kind: 'mapping',
|
|
27
|
+
resolve: resolveYamlSet,
|
|
28
|
+
construct: constructYamlSet
|
|
29
|
+
})
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const Type = require('../type')
|
|
4
|
+
|
|
5
|
+
const YAML_DATE_REGEXP = new RegExp(
|
|
6
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
7
|
+
'-([0-9][0-9])' + // [2] month
|
|
8
|
+
'-([0-9][0-9])$') // [3] day
|
|
9
|
+
|
|
10
|
+
const YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
11
|
+
'^([0-9][0-9][0-9][0-9])' + // [1] year
|
|
12
|
+
'-([0-9][0-9]?)' + // [2] month
|
|
13
|
+
'-([0-9][0-9]?)' + // [3] day
|
|
14
|
+
'(?:[Tt]|[ \\t]+)' + // ...
|
|
15
|
+
'([0-9][0-9]?)' + // [4] hour
|
|
16
|
+
':([0-9][0-9])' + // [5] minute
|
|
17
|
+
':([0-9][0-9])' + // [6] second
|
|
18
|
+
'(?:\\.([0-9]*))?' + // [7] fraction
|
|
19
|
+
'(?:[ \\t]*(Z|([-+])([0-9][0-9]?)' + // [8] tz [9] tz_sign [10] tzHour
|
|
20
|
+
'(?::([0-9][0-9]))?))?$') // [11] tzMinute
|
|
21
|
+
|
|
22
|
+
function resolveYamlTimestamp (data) {
|
|
23
|
+
if (data === null) return false
|
|
24
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true
|
|
25
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true
|
|
26
|
+
return false
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function constructYamlTimestamp (data) {
|
|
30
|
+
let fraction = 0
|
|
31
|
+
let delta = null
|
|
32
|
+
|
|
33
|
+
let match = YAML_DATE_REGEXP.exec(data)
|
|
34
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data)
|
|
35
|
+
|
|
36
|
+
if (match === null) throw new Error('Date resolve error')
|
|
37
|
+
|
|
38
|
+
// match: [1] year [2] month [3] day
|
|
39
|
+
|
|
40
|
+
const year = +(match[1])
|
|
41
|
+
const month = +(match[2]) - 1 // JS month starts with 0
|
|
42
|
+
const day = +(match[3])
|
|
43
|
+
|
|
44
|
+
if (!match[4]) { // no hour
|
|
45
|
+
return new Date(Date.UTC(year, month, day))
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// match: [4] hour [5] minute [6] second [7] fraction
|
|
49
|
+
|
|
50
|
+
const hour = +(match[4])
|
|
51
|
+
const minute = +(match[5])
|
|
52
|
+
const second = +(match[6])
|
|
53
|
+
|
|
54
|
+
if (match[7]) {
|
|
55
|
+
fraction = match[7].slice(0, 3)
|
|
56
|
+
while (fraction.length < 3) { // milli-seconds
|
|
57
|
+
fraction += '0'
|
|
58
|
+
}
|
|
59
|
+
fraction = +fraction
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// match: [8] tz [9] tz_sign [10] tzHour [11] tzMinute
|
|
63
|
+
|
|
64
|
+
if (match[9]) {
|
|
65
|
+
const tzHour = +(match[10])
|
|
66
|
+
const tzMinute = +(match[11] || 0)
|
|
67
|
+
delta = (tzHour * 60 + tzMinute) * 60000 // delta in mili-seconds
|
|
68
|
+
if (match[9] === '-') delta = -delta
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const date = new Date(Date.UTC(year, month, day, hour, minute, second, fraction))
|
|
72
|
+
|
|
73
|
+
if (delta) date.setTime(date.getTime() - delta)
|
|
74
|
+
|
|
75
|
+
return date
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function representYamlTimestamp (object /*, style */) {
|
|
79
|
+
return object.toISOString()
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
module.exports = new Type('tag:yaml.org,2002:timestamp', {
|
|
83
|
+
kind: 'scalar',
|
|
84
|
+
resolve: resolveYamlTimestamp,
|
|
85
|
+
construct: constructYamlTimestamp,
|
|
86
|
+
instanceOf: Date,
|
|
87
|
+
represent: representYamlTimestamp
|
|
88
|
+
})
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const YAMLException = require('./exception')
|
|
4
|
+
|
|
5
|
+
const TYPE_CONSTRUCTOR_OPTIONS = [
|
|
6
|
+
'kind',
|
|
7
|
+
'multi',
|
|
8
|
+
'resolve',
|
|
9
|
+
'construct',
|
|
10
|
+
'instanceOf',
|
|
11
|
+
'predicate',
|
|
12
|
+
'represent',
|
|
13
|
+
'representName',
|
|
14
|
+
'defaultStyle',
|
|
15
|
+
'styleAliases'
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
const YAML_NODE_KINDS = [
|
|
19
|
+
'scalar',
|
|
20
|
+
'sequence',
|
|
21
|
+
'mapping'
|
|
22
|
+
]
|
|
23
|
+
|
|
24
|
+
function compileStyleAliases (map) {
|
|
25
|
+
const result = {}
|
|
26
|
+
|
|
27
|
+
if (map !== null) {
|
|
28
|
+
Object.keys(map).forEach(function (style) {
|
|
29
|
+
map[style].forEach(function (alias) {
|
|
30
|
+
result[String(alias)] = style
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return result
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function Type (tag, options) {
|
|
39
|
+
options = options || {}
|
|
40
|
+
|
|
41
|
+
Object.keys(options).forEach(function (name) {
|
|
42
|
+
if (TYPE_CONSTRUCTOR_OPTIONS.indexOf(name) === -1) {
|
|
43
|
+
throw new YAMLException('Unknown option "' + name + '" is met in definition of "' + tag + '" YAML type.')
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// TODO: Add tag format check.
|
|
48
|
+
this.options = options // keep original options in case user wants to extend this type later
|
|
49
|
+
this.tag = tag
|
|
50
|
+
this.kind = options['kind'] || null
|
|
51
|
+
this.resolve = options['resolve'] || function () { return true }
|
|
52
|
+
this.construct = options['construct'] || function (data) { return data }
|
|
53
|
+
this.instanceOf = options['instanceOf'] || null
|
|
54
|
+
this.predicate = options['predicate'] || null
|
|
55
|
+
this.represent = options['represent'] || null
|
|
56
|
+
this.representName = options['representName'] || null
|
|
57
|
+
this.defaultStyle = options['defaultStyle'] || null
|
|
58
|
+
this.multi = options['multi'] || false
|
|
59
|
+
this.styleAliases = compileStyleAliases(options['styleAliases'] || null)
|
|
60
|
+
|
|
61
|
+
if (YAML_NODE_KINDS.indexOf(this.kind) === -1) {
|
|
62
|
+
throw new YAMLException('Unknown kind "' + this.kind + '" is specified for "' + tag + '" YAML type.')
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
module.exports = Type
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "js-yaml",
|
|
3
|
+
"version": "4.3.2",
|
|
4
|
+
"description": "YAML 1.2 parser and serializer",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"yaml",
|
|
7
|
+
"parser",
|
|
8
|
+
"serializer",
|
|
9
|
+
"pyyaml"
|
|
10
|
+
],
|
|
11
|
+
"author": "Vladimir Zapparov <dervus.grim@gmail.com>",
|
|
12
|
+
"contributors": [
|
|
13
|
+
"Aleksey V Zapparov <ixti@member.fsf.org> (http://www.ixti.net/)",
|
|
14
|
+
"Vitaly Puzrin <vitaly@rcdesign.ru> (https://github.com/puzrin)",
|
|
15
|
+
"Martin Grenfell <martin.grenfell@gmail.com> (http://got-ravings.blogspot.com)"
|
|
16
|
+
],
|
|
17
|
+
"license": "MIT",
|
|
18
|
+
"repository": "nodeca/js-yaml",
|
|
19
|
+
"funding": [
|
|
20
|
+
{
|
|
21
|
+
"type": "github",
|
|
22
|
+
"url": "https://github.com/sponsors/puzrin"
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
"type": "github",
|
|
26
|
+
"url": "https://github.com/sponsors/nodeca"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"files": [
|
|
30
|
+
"index.js",
|
|
31
|
+
"lib/",
|
|
32
|
+
"bin/",
|
|
33
|
+
"dist/"
|
|
34
|
+
],
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"tag": "v4-legacy"
|
|
37
|
+
},
|
|
38
|
+
"bin": {
|
|
39
|
+
"js-yaml": "bin/js-yaml.js"
|
|
40
|
+
},
|
|
41
|
+
"module": "./dist/js-yaml.mjs",
|
|
42
|
+
"exports": {
|
|
43
|
+
".": {
|
|
44
|
+
"import": "./dist/js-yaml.mjs",
|
|
45
|
+
"require": "./index.js"
|
|
46
|
+
},
|
|
47
|
+
"./package.json": "./package.json"
|
|
48
|
+
},
|
|
49
|
+
"scripts": {
|
|
50
|
+
"lint": "eslint .",
|
|
51
|
+
"lint-fix": "eslint . --fix",
|
|
52
|
+
"test": "npm run lint && npm run test:core && npm run test:build",
|
|
53
|
+
"test:core": "node --test test/core/*.test.*",
|
|
54
|
+
"test:build": "npm run build && node --test test/build/*.test.*",
|
|
55
|
+
"coverage": "npm run build && c8 --include 'lib/**' -r text -r html -r lcov node --test test/core/*.test.*",
|
|
56
|
+
"build": "node support/build-dist.mjs",
|
|
57
|
+
"build:demo": "npm run lint && node support/build_demo.mjs",
|
|
58
|
+
"gh-demo": "npm run build:demo && gh-pages -d demo -f",
|
|
59
|
+
"prepack": "npm test && npm run build"
|
|
60
|
+
},
|
|
61
|
+
"unpkg": "dist/js-yaml.min.js",
|
|
62
|
+
"jsdelivr": "dist/js-yaml.min.js",
|
|
63
|
+
"dependencies": {
|
|
64
|
+
"argparse": "^2.0.1"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@babel/core": "8.0.1",
|
|
68
|
+
"@babel/preset-env": "8.0.1",
|
|
69
|
+
"@rollup/plugin-commonjs": "29.0.3",
|
|
70
|
+
"@rollup/plugin-terser": "0.4.4",
|
|
71
|
+
"c8": "^11.0.0",
|
|
72
|
+
"codemirror": "^5.65.21",
|
|
73
|
+
"eslint": "^9.39.4",
|
|
74
|
+
"fast-check": "^4.8.0",
|
|
75
|
+
"gh-pages": "^6.3.0",
|
|
76
|
+
"neostandard": "^0.13.0",
|
|
77
|
+
"tinybench": "^6.0.2",
|
|
78
|
+
"vite": "7.3.6",
|
|
79
|
+
"vite-plugin-node-polyfills": "^0.28.0",
|
|
80
|
+
"vite-plugin-singlefile": "^2.3.3",
|
|
81
|
+
"workerpool": "^10.0.2"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License (Expat)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Andrew Kelley
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person
|
|
6
|
+
obtaining a copy of this software and associated documentation files
|
|
7
|
+
(the "Software"), to deal in the Software without restriction,
|
|
8
|
+
including without limitation the rights to use, copy, modify, merge,
|
|
9
|
+
publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
+
and to permit persons to whom the Software is furnished to do so,
|
|
11
|
+
subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
|
|
20
|
+
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
|
|
21
|
+
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
22
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Pend
|
|
2
|
+
|
|
3
|
+
Dead-simple optimistic async helper.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
var Pend = require('pend');
|
|
9
|
+
var pend = new Pend();
|
|
10
|
+
pend.max = 10; // defaults to Infinity
|
|
11
|
+
setTimeout(pend.hold(), 1000); // pend.wait will have to wait for this hold to finish
|
|
12
|
+
pend.go(function(cb) {
|
|
13
|
+
console.log("this function is immediately executed");
|
|
14
|
+
setTimeout(function() {
|
|
15
|
+
console.log("calling cb 1");
|
|
16
|
+
cb();
|
|
17
|
+
}, 500);
|
|
18
|
+
});
|
|
19
|
+
pend.go(function(cb) {
|
|
20
|
+
console.log("this function is also immediately executed");
|
|
21
|
+
setTimeout(function() {
|
|
22
|
+
console.log("calling cb 2");
|
|
23
|
+
cb();
|
|
24
|
+
}, 1000);
|
|
25
|
+
});
|
|
26
|
+
pend.wait(function(err) {
|
|
27
|
+
console.log("this is excuted when the first 2 have returned.");
|
|
28
|
+
console.log("err is a possible error in the standard callback style.");
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Output:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
this function is immediately executed
|
|
36
|
+
this function is also immediately executed
|
|
37
|
+
calling cb 1
|
|
38
|
+
calling cb 2
|
|
39
|
+
this is excuted when the first 2 have returned.
|
|
40
|
+
err is a possible error in the standard callback style.
|
|
41
|
+
```
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module.exports = Pend;
|
|
2
|
+
|
|
3
|
+
function Pend() {
|
|
4
|
+
this.pending = 0;
|
|
5
|
+
this.max = Infinity;
|
|
6
|
+
this.listeners = [];
|
|
7
|
+
this.waiting = [];
|
|
8
|
+
this.error = null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
Pend.prototype.go = function(fn) {
|
|
12
|
+
if (this.pending < this.max) {
|
|
13
|
+
pendGo(this, fn);
|
|
14
|
+
} else {
|
|
15
|
+
this.waiting.push(fn);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
Pend.prototype.wait = function(cb) {
|
|
20
|
+
if (this.pending === 0) {
|
|
21
|
+
cb(this.error);
|
|
22
|
+
} else {
|
|
23
|
+
this.listeners.push(cb);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
Pend.prototype.hold = function() {
|
|
28
|
+
return pendHold(this);
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
function pendHold(self) {
|
|
32
|
+
self.pending += 1;
|
|
33
|
+
var called = false;
|
|
34
|
+
return onCb;
|
|
35
|
+
function onCb(err) {
|
|
36
|
+
if (called) throw new Error("callback called twice");
|
|
37
|
+
called = true;
|
|
38
|
+
self.error = self.error || err;
|
|
39
|
+
self.pending -= 1;
|
|
40
|
+
if (self.waiting.length > 0 && self.pending < self.max) {
|
|
41
|
+
pendGo(self, self.waiting.shift());
|
|
42
|
+
} else if (self.pending === 0) {
|
|
43
|
+
var listeners = self.listeners;
|
|
44
|
+
self.listeners = [];
|
|
45
|
+
listeners.forEach(cbListener);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function cbListener(listener) {
|
|
49
|
+
listener(self.error);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function pendGo(self, fn) {
|
|
54
|
+
fn(pendHold(self));
|
|
55
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pend",
|
|
3
|
+
"version": "1.2.0",
|
|
4
|
+
"description": "dead-simple optimistic async helper",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "node test.js"
|
|
8
|
+
},
|
|
9
|
+
"author": "Andrew Kelley <superjoe30@gmail.com>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git://github.com/andrewrk/node-pend.git"
|
|
14
|
+
},
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/andrewrk/node-pend/issues"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
var assert = require('assert');
|
|
2
|
+
var Pend = require('./');
|
|
3
|
+
|
|
4
|
+
var tests = [
|
|
5
|
+
{
|
|
6
|
+
name: "basic",
|
|
7
|
+
fn: testBasic,
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: "max",
|
|
11
|
+
fn: testWithMax,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
name: "callback twice",
|
|
15
|
+
fn: testCallbackTwice,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: "calling wait twice",
|
|
19
|
+
fn: testCallingWaitTwice,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
name: "hold()",
|
|
23
|
+
fn: testHoldFn,
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
var testCount = tests.length;
|
|
27
|
+
|
|
28
|
+
doOneTest();
|
|
29
|
+
|
|
30
|
+
function doOneTest() {
|
|
31
|
+
var test = tests.shift();
|
|
32
|
+
if (!test) {
|
|
33
|
+
console.log(testCount + " tests passed.");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
process.stdout.write(test.name + "...");
|
|
37
|
+
test.fn(function() {
|
|
38
|
+
process.stdout.write("OK\n");
|
|
39
|
+
doOneTest();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function testBasic(cb) {
|
|
44
|
+
var pend = new Pend();
|
|
45
|
+
var results = [];
|
|
46
|
+
pend.go(function(cb) {
|
|
47
|
+
results.push(1);
|
|
48
|
+
setTimeout(function() {
|
|
49
|
+
results.push(3);
|
|
50
|
+
cb();
|
|
51
|
+
}, 500);
|
|
52
|
+
});
|
|
53
|
+
pend.go(function(cb) {
|
|
54
|
+
results.push(2);
|
|
55
|
+
setTimeout(function() {
|
|
56
|
+
results.push(4);
|
|
57
|
+
cb();
|
|
58
|
+
}, 1000);
|
|
59
|
+
});
|
|
60
|
+
pend.wait(function(err) {
|
|
61
|
+
assert.deepEqual(results, [1,2,3,4]);
|
|
62
|
+
cb();
|
|
63
|
+
});
|
|
64
|
+
assert.deepEqual(results, [1, 2]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function testWithMax(cb) {
|
|
68
|
+
var pend = new Pend();
|
|
69
|
+
var results = [];
|
|
70
|
+
pend.max = 2;
|
|
71
|
+
pend.go(function(cb) {
|
|
72
|
+
results.push('a');
|
|
73
|
+
setTimeout(function() {
|
|
74
|
+
results.push(1);
|
|
75
|
+
cb();
|
|
76
|
+
}, 500);
|
|
77
|
+
});
|
|
78
|
+
pend.go(function(cb) {
|
|
79
|
+
results.push('b');
|
|
80
|
+
setTimeout(function() {
|
|
81
|
+
results.push(1);
|
|
82
|
+
cb();
|
|
83
|
+
}, 500);
|
|
84
|
+
});
|
|
85
|
+
pend.go(function(cb) {
|
|
86
|
+
results.push('c');
|
|
87
|
+
setTimeout(function() {
|
|
88
|
+
results.push(2);
|
|
89
|
+
cb();
|
|
90
|
+
}, 100);
|
|
91
|
+
});
|
|
92
|
+
pend.wait(function(err) {
|
|
93
|
+
assert.deepEqual(results, ['a', 'b', 1, 'c', 1, 2]);
|
|
94
|
+
cb();
|
|
95
|
+
});
|
|
96
|
+
assert.deepEqual(results, ['a', 'b']);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function testCallbackTwice(cb) {
|
|
100
|
+
var pend = new Pend();
|
|
101
|
+
pend.go(function(cb) {
|
|
102
|
+
setTimeout(cb, 100);
|
|
103
|
+
});
|
|
104
|
+
pend.go(function(cb) {
|
|
105
|
+
cb();
|
|
106
|
+
assert.throws(cb, /callback called twice/);
|
|
107
|
+
});
|
|
108
|
+
pend.wait(cb);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function testCallingWaitTwice(cb) {
|
|
112
|
+
var pend = new Pend();
|
|
113
|
+
pend.go(function(cb) {
|
|
114
|
+
setTimeout(cb, 100);
|
|
115
|
+
});
|
|
116
|
+
pend.wait(function() {
|
|
117
|
+
pend.go(function(cb) {
|
|
118
|
+
setTimeout(cb, 50);
|
|
119
|
+
});
|
|
120
|
+
pend.go(function(cb) {
|
|
121
|
+
setTimeout(cb, 10);
|
|
122
|
+
});
|
|
123
|
+
pend.go(function(cb) {
|
|
124
|
+
setTimeout(cb, 20);
|
|
125
|
+
});
|
|
126
|
+
pend.wait(cb);
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function testHoldFn(cb) {
|
|
131
|
+
var pend = new Pend();
|
|
132
|
+
setTimeout(pend.hold(), 100);
|
|
133
|
+
pend.go(function(cb) {
|
|
134
|
+
cb();
|
|
135
|
+
});
|
|
136
|
+
pend.wait(cb);
|
|
137
|
+
}
|