@blueking/bkui-form 1.0.1-beta.3 → 1.0.1-beta.4

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 (209) hide show
  1. package/dist/adapter/common/FieldGroupWrap.d.ts +209 -0
  2. package/dist/adapter/field/ArrayField.d.ts +147 -0
  3. package/dist/adapter/field/BooleanField.d.ts +145 -0
  4. package/dist/adapter/field/CompositionField.d.ts +151 -0
  5. package/dist/adapter/field/FieldProps.d.ts +70 -0
  6. package/dist/adapter/field/NumberField.d.ts +145 -0
  7. package/dist/adapter/field/ObjectField.d.ts +147 -0
  8. package/dist/adapter/field/SchemaField.d.ts +145 -0
  9. package/dist/adapter/field/StringField.d.ts +4 -0
  10. package/dist/adapter/widget/ArrayWidget.d.ts +154 -0
  11. package/dist/adapter/widget/ButtonWidget.d.ts +16 -0
  12. package/dist/adapter/widget/CheckboxWidget.d.ts +34 -0
  13. package/dist/adapter/widget/CollapseGroupWidget.d.ts +196 -0
  14. package/dist/adapter/widget/ColorPickerWidget.d.ts +8 -0
  15. package/dist/adapter/widget/InputWidget.d.ts +30 -0
  16. package/dist/adapter/widget/KeyValueArrayWidget.d.ts +157 -0
  17. package/dist/adapter/widget/RadioWidget.d.ts +37 -0
  18. package/dist/adapter/widget/SelectWidget.d.ts +37 -0
  19. package/dist/adapter/widget/SwitchWidget.d.ts +10 -0
  20. package/dist/adapter/widget/TabGroupWidget.d.ts +187 -0
  21. package/dist/adapter/widget/TableWidget.d.ts +154 -0
  22. package/dist/adapter/widget/Widget.d.ts +182 -0
  23. package/dist/controller/form.d.ts +141 -0
  24. package/dist/controller/props.d.ts +62 -0
  25. package/dist/core/events.d.ts +10 -0
  26. package/dist/core/expression.d.ts +13 -0
  27. package/dist/core/form.d.ts +5 -0
  28. package/dist/core/lang.d.ts +1 -0
  29. package/dist/core/layout.d.ts +20 -0
  30. package/dist/core/lifecycle.d.ts +0 -0
  31. package/dist/core/path.d.ts +9 -0
  32. package/dist/core/proxy.d.ts +3 -0
  33. package/dist/core/reaction.d.ts +5 -0
  34. package/dist/core/register.d.ts +19 -0
  35. package/dist/core/schema.d.ts +26 -0
  36. package/dist/core/validator.d.ts +35 -0
  37. package/dist/core/widgetTree.d.ts +40 -0
  38. package/dist/index.d.ts +6 -0
  39. package/dist/index.es.js +7443 -0
  40. package/dist/index.umd.js +12 -0
  41. package/dist/style.css +1 -0
  42. package/dist/util/fetch.d.ts +10 -0
  43. package/dist/util/index.d.ts +23 -0
  44. package/package.json +24 -12
  45. package/esm/adapter/common/FieldGroupWrap.tsx.js +0 -199
  46. package/esm/adapter/field/ArrayField.tsx.js +0 -55
  47. package/esm/adapter/field/BooleanField.tsx.js +0 -41
  48. package/esm/adapter/field/CompositionField.tsx.js +0 -113
  49. package/esm/adapter/field/FieldProps.ts.js +0 -85
  50. package/esm/adapter/field/NumberField.tsx.js +0 -19
  51. package/esm/adapter/field/ObjectField.tsx.js +0 -58
  52. package/esm/adapter/field/SchemaField.tsx.js +0 -28
  53. package/esm/adapter/field/StringField.tsx.js +0 -4
  54. package/esm/adapter/widget/ArrayWidget.ts.js +0 -196
  55. package/esm/adapter/widget/ButtonWidget.ts.js +0 -76
  56. package/esm/adapter/widget/CheckboxWidget.ts.js +0 -101
  57. package/esm/adapter/widget/CollapseGroupWidget.ts.js +0 -140
  58. package/esm/adapter/widget/ColorPickerWidget.ts.js +0 -71
  59. package/esm/adapter/widget/InputWidget.ts.js +0 -79
  60. package/esm/adapter/widget/KeyValueArrayWidget.tsx.js +0 -156
  61. package/esm/adapter/widget/RadioWidget.ts.js +0 -98
  62. package/esm/adapter/widget/SelectWidget.ts.js +0 -98
  63. package/esm/adapter/widget/SwitchWidget.ts.js +0 -73
  64. package/esm/adapter/widget/TabGroupWidget.ts.js +0 -145
  65. package/esm/adapter/widget/TableWidget.ts.js +0 -205
  66. package/esm/adapter/widget/Widget.ts.js +0 -497
  67. package/esm/assets/fonts/iconcool.eot +0 -0
  68. package/esm/assets/fonts/iconcool.svg +0 -53
  69. package/esm/assets/fonts/iconcool.ttf +0 -0
  70. package/esm/assets/fonts/iconcool.woff +0 -0
  71. package/esm/assets/style.css +0 -43
  72. package/esm/controller/form.css +0 -164
  73. package/esm/controller/form.tsx.js +0 -159
  74. package/esm/controller/props.ts.js +0 -75
  75. package/esm/core/events.ts.js +0 -74
  76. package/esm/core/expression.ts.js +0 -67
  77. package/esm/core/lang.ts.js +0 -25
  78. package/esm/core/layout.ts.js +0 -149
  79. package/esm/core/path.ts.js +0 -60
  80. package/esm/core/proxy.ts.js +0 -10
  81. package/esm/core/reaction.ts.js +0 -116
  82. package/esm/core/register.ts.js +0 -74
  83. package/esm/core/schema.ts.js +0 -302
  84. package/esm/core/validator.ts.js +0 -248
  85. package/esm/core/widgetTree.ts.js +0 -163
  86. package/esm/index.ts.js +0 -6
  87. package/esm/node_modules/@blueking/cli-service/dist/lib/path.js +0 -35
  88. package/esm/node_modules/@blueking/cli-service/dist/lib/util.js +0 -233
  89. package/esm/node_modules/@blueking/cli-service/dist/tools/rust/helper/path.js +0 -172
  90. package/esm/node_modules/ajv/dist/ajv.js +0 -50
  91. package/esm/node_modules/ajv/dist/compile/codegen/code.js +0 -156
  92. package/esm/node_modules/ajv/dist/compile/codegen/index.js +0 -697
  93. package/esm/node_modules/ajv/dist/compile/codegen/scope.js +0 -143
  94. package/esm/node_modules/ajv/dist/compile/errors.js +0 -123
  95. package/esm/node_modules/ajv/dist/compile/index.js +0 -242
  96. package/esm/node_modules/ajv/dist/compile/names.js +0 -28
  97. package/esm/node_modules/ajv/dist/compile/ref_error.js +0 -12
  98. package/esm/node_modules/ajv/dist/compile/resolve.js +0 -155
  99. package/esm/node_modules/ajv/dist/compile/rules.js +0 -26
  100. package/esm/node_modules/ajv/dist/compile/util.js +0 -178
  101. package/esm/node_modules/ajv/dist/compile/validate/applicability.js +0 -19
  102. package/esm/node_modules/ajv/dist/compile/validate/boolSchema.js +0 -50
  103. package/esm/node_modules/ajv/dist/compile/validate/dataType.js +0 -203
  104. package/esm/node_modules/ajv/dist/compile/validate/defaults.js +0 -35
  105. package/esm/node_modules/ajv/dist/compile/validate/index.js +0 -520
  106. package/esm/node_modules/ajv/dist/compile/validate/keyword.js +0 -124
  107. package/esm/node_modules/ajv/dist/compile/validate/subschema.js +0 -81
  108. package/esm/node_modules/ajv/dist/core.js +0 -618
  109. package/esm/node_modules/ajv/dist/refs/data.json +0 -13
  110. package/esm/node_modules/ajv/dist/refs/json-schema-draft-07.json +0 -151
  111. package/esm/node_modules/ajv/dist/runtime/equal.js +0 -7
  112. package/esm/node_modules/ajv/dist/runtime/ucs2length.js +0 -24
  113. package/esm/node_modules/ajv/dist/runtime/uri.js +0 -6
  114. package/esm/node_modules/ajv/dist/runtime/validation_error.js +0 -11
  115. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +0 -49
  116. package/esm/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +0 -106
  117. package/esm/node_modules/ajv/dist/vocabularies/applicator/allOf.js +0 -23
  118. package/esm/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +0 -12
  119. package/esm/node_modules/ajv/dist/vocabularies/applicator/contains.js +0 -95
  120. package/esm/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +0 -85
  121. package/esm/node_modules/ajv/dist/vocabularies/applicator/if.js +0 -66
  122. package/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +0 -44
  123. package/esm/node_modules/ajv/dist/vocabularies/applicator/items.js +0 -52
  124. package/esm/node_modules/ajv/dist/vocabularies/applicator/items2020.js +0 -30
  125. package/esm/node_modules/ajv/dist/vocabularies/applicator/not.js +0 -26
  126. package/esm/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +0 -60
  127. package/esm/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +0 -75
  128. package/esm/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +0 -12
  129. package/esm/node_modules/ajv/dist/vocabularies/applicator/properties.js +0 -54
  130. package/esm/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +0 -38
  131. package/esm/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +0 -13
  132. package/esm/node_modules/ajv/dist/vocabularies/code.js +0 -131
  133. package/esm/node_modules/ajv/dist/vocabularies/core/id.js +0 -10
  134. package/esm/node_modules/ajv/dist/vocabularies/core/index.js +0 -16
  135. package/esm/node_modules/ajv/dist/vocabularies/core/ref.js +0 -122
  136. package/esm/node_modules/ajv/dist/vocabularies/discriminator/index.js +0 -104
  137. package/esm/node_modules/ajv/dist/vocabularies/discriminator/types.js +0 -9
  138. package/esm/node_modules/ajv/dist/vocabularies/draft7.js +0 -17
  139. package/esm/node_modules/ajv/dist/vocabularies/format/format.js +0 -92
  140. package/esm/node_modules/ajv/dist/vocabularies/format/index.js +0 -6
  141. package/esm/node_modules/ajv/dist/vocabularies/metadata.js +0 -18
  142. package/esm/node_modules/ajv/dist/vocabularies/validation/const.js +0 -25
  143. package/esm/node_modules/ajv/dist/vocabularies/validation/enum.js +0 -48
  144. package/esm/node_modules/ajv/dist/vocabularies/validation/index.js +0 -33
  145. package/esm/node_modules/ajv/dist/vocabularies/validation/limitItems.js +0 -24
  146. package/esm/node_modules/ajv/dist/vocabularies/validation/limitLength.js +0 -27
  147. package/esm/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +0 -27
  148. package/esm/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +0 -24
  149. package/esm/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +0 -26
  150. package/esm/node_modules/ajv/dist/vocabularies/validation/pattern.js +0 -24
  151. package/esm/node_modules/ajv/dist/vocabularies/validation/required.js +0 -79
  152. package/esm/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +0 -64
  153. package/esm/node_modules/ajv-formats/dist/formats.js +0 -173
  154. package/esm/node_modules/ajv-formats/dist/index.js +0 -37
  155. package/esm/node_modules/ajv-formats/dist/limit.js +0 -69
  156. package/esm/node_modules/ajv-i18n/localize/zh/index.js +0 -154
  157. package/esm/node_modules/fast-deep-equal/index.js +0 -46
  158. package/esm/node_modules/fast-uri/index.js +0 -303
  159. package/esm/node_modules/fast-uri/lib/schemes.js +0 -188
  160. package/esm/node_modules/fast-uri/lib/scopedChars.js +0 -30
  161. package/esm/node_modules/fast-uri/lib/utils.js +0 -244
  162. package/esm/node_modules/json-schema-traverse/index.js +0 -89
  163. package/esm/node_modules/semver/classes/comparator.js +0 -143
  164. package/esm/node_modules/semver/classes/range.js +0 -557
  165. package/esm/node_modules/semver/classes/semver.js +0 -333
  166. package/esm/node_modules/semver/functions/clean.js +0 -8
  167. package/esm/node_modules/semver/functions/cmp.js +0 -54
  168. package/esm/node_modules/semver/functions/coerce.js +0 -62
  169. package/esm/node_modules/semver/functions/compare-build.js +0 -9
  170. package/esm/node_modules/semver/functions/compare-loose.js +0 -5
  171. package/esm/node_modules/semver/functions/compare.js +0 -7
  172. package/esm/node_modules/semver/functions/diff.js +0 -60
  173. package/esm/node_modules/semver/functions/eq.js +0 -5
  174. package/esm/node_modules/semver/functions/gt.js +0 -5
  175. package/esm/node_modules/semver/functions/gte.js +0 -5
  176. package/esm/node_modules/semver/functions/inc.js +0 -21
  177. package/esm/node_modules/semver/functions/lt.js +0 -5
  178. package/esm/node_modules/semver/functions/lte.js +0 -5
  179. package/esm/node_modules/semver/functions/major.js +0 -5
  180. package/esm/node_modules/semver/functions/minor.js +0 -5
  181. package/esm/node_modules/semver/functions/neq.js +0 -5
  182. package/esm/node_modules/semver/functions/parse.js +0 -18
  183. package/esm/node_modules/semver/functions/patch.js +0 -5
  184. package/esm/node_modules/semver/functions/prerelease.js +0 -8
  185. package/esm/node_modules/semver/functions/rcompare.js +0 -5
  186. package/esm/node_modules/semver/functions/rsort.js +0 -5
  187. package/esm/node_modules/semver/functions/satisfies.js +0 -12
  188. package/esm/node_modules/semver/functions/sort.js +0 -5
  189. package/esm/node_modules/semver/functions/valid.js +0 -8
  190. package/esm/node_modules/semver/index.js +0 -91
  191. package/esm/node_modules/semver/internal/constants.js +0 -37
  192. package/esm/node_modules/semver/internal/debug.js +0 -11
  193. package/esm/node_modules/semver/internal/identifiers.js +0 -29
  194. package/esm/node_modules/semver/internal/lrucache.js +0 -42
  195. package/esm/node_modules/semver/internal/parse-options.js +0 -17
  196. package/esm/node_modules/semver/internal/re.js +0 -223
  197. package/esm/node_modules/semver/ranges/gtr.js +0 -6
  198. package/esm/node_modules/semver/ranges/intersects.js +0 -9
  199. package/esm/node_modules/semver/ranges/ltr.js +0 -6
  200. package/esm/node_modules/semver/ranges/max-satisfying.js +0 -27
  201. package/esm/node_modules/semver/ranges/min-satisfying.js +0 -26
  202. package/esm/node_modules/semver/ranges/min-version.js +0 -63
  203. package/esm/node_modules/semver/ranges/outside.js +0 -82
  204. package/esm/node_modules/semver/ranges/simplify.js +0 -49
  205. package/esm/node_modules/semver/ranges/subset.js +0 -249
  206. package/esm/node_modules/semver/ranges/to-comparators.js +0 -10
  207. package/esm/node_modules/semver/ranges/valid.js +0 -13
  208. package/esm/util/fetch.ts.js +0 -190
  209. package/esm/util/index.ts.js +0 -276
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- const compareBuild = require('./compare-build.js')
4
- const sort = (list, loose) => list.sort((a, b) => compareBuild(a, b, loose))
5
- module.exports = sort
@@ -1,8 +0,0 @@
1
- 'use strict'
2
-
3
- const parse = require('./parse.js')
4
- const valid = (version, options) => {
5
- const v = parse(version, options)
6
- return v ? v.version : null
7
- }
8
- module.exports = valid
@@ -1,91 +0,0 @@
1
- 'use strict'
2
-
3
- // just pre-load all the stuff that index.js lazily exports
4
- const internalRe = require('./internal/re.js')
5
- const constants = require('./internal/constants.js')
6
- const SemVer = require('./classes/semver.js')
7
- const identifiers = require('./internal/identifiers.js')
8
- const parse = require('./functions/parse.js')
9
- const valid = require('./functions/valid.js')
10
- const clean = require('./functions/clean.js')
11
- const inc = require('./functions/inc.js')
12
- const diff = require('./functions/diff.js')
13
- const major = require('./functions/major.js')
14
- const minor = require('./functions/minor.js')
15
- const patch = require('./functions/patch.js')
16
- const prerelease = require('./functions/prerelease.js')
17
- const compare = require('./functions/compare.js')
18
- const rcompare = require('./functions/rcompare.js')
19
- const compareLoose = require('./functions/compare-loose.js')
20
- const compareBuild = require('./functions/compare-build.js')
21
- const sort = require('./functions/sort.js')
22
- const rsort = require('./functions/rsort.js')
23
- const gt = require('./functions/gt.js')
24
- const lt = require('./functions/lt.js')
25
- const eq = require('./functions/eq.js')
26
- const neq = require('./functions/neq.js')
27
- const gte = require('./functions/gte.js')
28
- const lte = require('./functions/lte.js')
29
- const cmp = require('./functions/cmp.js')
30
- const coerce = require('./functions/coerce.js')
31
- const Comparator = require('./classes/comparator.js')
32
- const Range = require('./classes/range.js')
33
- const satisfies = require('./functions/satisfies.js')
34
- const toComparators = require('./ranges/to-comparators.js')
35
- const maxSatisfying = require('./ranges/max-satisfying.js')
36
- const minSatisfying = require('./ranges/min-satisfying.js')
37
- const minVersion = require('./ranges/min-version.js')
38
- const validRange = require('./ranges/valid.js')
39
- const outside = require('./ranges/outside.js')
40
- const gtr = require('./ranges/gtr.js')
41
- const ltr = require('./ranges/ltr.js')
42
- const intersects = require('./ranges/intersects.js')
43
- const simplifyRange = require('./ranges/simplify.js')
44
- const subset = require('./ranges/subset.js')
45
- module.exports = {
46
- parse,
47
- valid,
48
- clean,
49
- inc,
50
- diff,
51
- major,
52
- minor,
53
- patch,
54
- prerelease,
55
- compare,
56
- rcompare,
57
- compareLoose,
58
- compareBuild,
59
- sort,
60
- rsort,
61
- gt,
62
- lt,
63
- eq,
64
- neq,
65
- gte,
66
- lte,
67
- cmp,
68
- coerce,
69
- Comparator,
70
- Range,
71
- satisfies,
72
- toComparators,
73
- maxSatisfying,
74
- minSatisfying,
75
- minVersion,
76
- validRange,
77
- outside,
78
- gtr,
79
- ltr,
80
- intersects,
81
- simplifyRange,
82
- subset,
83
- SemVer,
84
- re: internalRe.re,
85
- src: internalRe.src,
86
- tokens: internalRe.t,
87
- SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
88
- RELEASE_TYPES: constants.RELEASE_TYPES,
89
- compareIdentifiers: identifiers.compareIdentifiers,
90
- rcompareIdentifiers: identifiers.rcompareIdentifiers,
91
- }
@@ -1,37 +0,0 @@
1
- 'use strict'
2
-
3
- // Note: this is the semver.org version of the spec that it implements
4
- // Not necessarily the package version of this code.
5
- const SEMVER_SPEC_VERSION = '2.0.0'
6
-
7
- const MAX_LENGTH = 256
8
- const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
9
- /* istanbul ignore next */ 9007199254740991
10
-
11
- // Max safe segment length for coercion.
12
- const MAX_SAFE_COMPONENT_LENGTH = 16
13
-
14
- // Max safe length for a build identifier. The max length minus 6 characters for
15
- // the shortest version with a build 0.0.0+BUILD.
16
- const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
17
-
18
- const RELEASE_TYPES = [
19
- 'major',
20
- 'premajor',
21
- 'minor',
22
- 'preminor',
23
- 'patch',
24
- 'prepatch',
25
- 'prerelease',
26
- ]
27
-
28
- module.exports = {
29
- MAX_LENGTH,
30
- MAX_SAFE_COMPONENT_LENGTH,
31
- MAX_SAFE_BUILD_LENGTH,
32
- MAX_SAFE_INTEGER,
33
- RELEASE_TYPES,
34
- SEMVER_SPEC_VERSION,
35
- FLAG_INCLUDE_PRERELEASE: 0b001,
36
- FLAG_LOOSE: 0b010,
37
- }
@@ -1,11 +0,0 @@
1
- 'use strict'
2
-
3
- const debug = (
4
- typeof process === 'object' &&
5
- process.env &&
6
- process.env.NODE_DEBUG &&
7
- /\bsemver\b/i.test(process.env.NODE_DEBUG)
8
- ) ? (...args) => console.error('SEMVER', ...args)
9
- : () => {}
10
-
11
- module.exports = debug
@@ -1,29 +0,0 @@
1
- 'use strict'
2
-
3
- const numeric = /^[0-9]+$/
4
- const compareIdentifiers = (a, b) => {
5
- if (typeof a === 'number' && typeof b === 'number') {
6
- return a === b ? 0 : a < b ? -1 : 1
7
- }
8
-
9
- const anum = numeric.test(a)
10
- const bnum = numeric.test(b)
11
-
12
- if (anum && bnum) {
13
- a = +a
14
- b = +b
15
- }
16
-
17
- return a === b ? 0
18
- : (anum && !bnum) ? -1
19
- : (bnum && !anum) ? 1
20
- : a < b ? -1
21
- : 1
22
- }
23
-
24
- const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
25
-
26
- module.exports = {
27
- compareIdentifiers,
28
- rcompareIdentifiers,
29
- }
@@ -1,42 +0,0 @@
1
- 'use strict'
2
-
3
- class LRUCache {
4
- constructor () {
5
- this.max = 1000
6
- this.map = new Map()
7
- }
8
-
9
- get (key) {
10
- const value = this.map.get(key)
11
- if (value === undefined) {
12
- return undefined
13
- } else {
14
- // Remove the key from the map and add it to the end
15
- this.map.delete(key)
16
- this.map.set(key, value)
17
- return value
18
- }
19
- }
20
-
21
- delete (key) {
22
- return this.map.delete(key)
23
- }
24
-
25
- set (key, value) {
26
- const deleted = this.delete(key)
27
-
28
- if (!deleted && value !== undefined) {
29
- // If cache is full, delete the least recently used item
30
- if (this.map.size >= this.max) {
31
- const firstKey = this.map.keys().next().value
32
- this.delete(firstKey)
33
- }
34
-
35
- this.map.set(key, value)
36
- }
37
-
38
- return this
39
- }
40
- }
41
-
42
- module.exports = LRUCache
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- // parse out just the options we care about
4
- const looseOption = Object.freeze({ loose: true })
5
- const emptyOpts = Object.freeze({ })
6
- const parseOptions = options => {
7
- if (!options) {
8
- return emptyOpts
9
- }
10
-
11
- if (typeof options !== 'object') {
12
- return looseOption
13
- }
14
-
15
- return options
16
- }
17
- module.exports = parseOptions
@@ -1,223 +0,0 @@
1
- 'use strict'
2
-
3
- const {
4
- MAX_SAFE_COMPONENT_LENGTH,
5
- MAX_SAFE_BUILD_LENGTH,
6
- MAX_LENGTH,
7
- } = require('./constants.js')
8
- const debug = require('./debug.js')
9
- exports = module.exports = {}
10
-
11
- // The actual regexps go on exports.re
12
- const re = exports.re = []
13
- const safeRe = exports.safeRe = []
14
- const src = exports.src = []
15
- const safeSrc = exports.safeSrc = []
16
- const t = exports.t = {}
17
- let R = 0
18
-
19
- const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
20
-
21
- // Replace some greedy regex tokens to prevent regex dos issues. These regex are
22
- // used internally via the safeRe object since all inputs in this library get
23
- // normalized first to trim and collapse all extra whitespace. The original
24
- // regexes are exported for userland consumption and lower level usage. A
25
- // future breaking change could export the safer regex only with a note that
26
- // all input should have extra whitespace removed.
27
- const safeRegexReplacements = [
28
- ['\\s', 1],
29
- ['\\d', MAX_LENGTH],
30
- [LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
31
- ]
32
-
33
- const makeSafeRegex = (value) => {
34
- for (const [token, max] of safeRegexReplacements) {
35
- value = value
36
- .split(`${token}*`).join(`${token}{0,${max}}`)
37
- .split(`${token}+`).join(`${token}{1,${max}}`)
38
- }
39
- return value
40
- }
41
-
42
- const createToken = (name, value, isGlobal) => {
43
- const safe = makeSafeRegex(value)
44
- const index = R++
45
- debug(name, index, value)
46
- t[name] = index
47
- src[index] = value
48
- safeSrc[index] = safe
49
- re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
50
- safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
51
- }
52
-
53
- // The following Regular Expressions can be used for tokenizing,
54
- // validating, and parsing SemVer version strings.
55
-
56
- // ## Numeric Identifier
57
- // A single `0`, or a non-zero digit followed by zero or more digits.
58
-
59
- createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*')
60
- createToken('NUMERICIDENTIFIERLOOSE', '\\d+')
61
-
62
- // ## Non-numeric Identifier
63
- // Zero or more digits, followed by a letter or hyphen, and then zero or
64
- // more letters, digits, or hyphens.
65
-
66
- createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)
67
-
68
- // ## Main Version
69
- // Three dot-separated numeric identifiers.
70
-
71
- createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
72
- `(${src[t.NUMERICIDENTIFIER]})\\.` +
73
- `(${src[t.NUMERICIDENTIFIER]})`)
74
-
75
- createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
76
- `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
77
- `(${src[t.NUMERICIDENTIFIERLOOSE]})`)
78
-
79
- // ## Pre-release Version Identifier
80
- // A numeric identifier, or a non-numeric identifier.
81
- // Non-numberic identifiers include numberic identifiers but can be longer.
82
- // Therefore non-numberic identifiers must go first.
83
-
84
- createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NONNUMERICIDENTIFIER]
85
- }|${src[t.NUMERICIDENTIFIER]})`)
86
-
87
- createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NONNUMERICIDENTIFIER]
88
- }|${src[t.NUMERICIDENTIFIERLOOSE]})`)
89
-
90
- // ## Pre-release Version
91
- // Hyphen, followed by one or more dot-separated pre-release version
92
- // identifiers.
93
-
94
- createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
95
- }(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`)
96
-
97
- createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
98
- }(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)
99
-
100
- // ## Build Metadata Identifier
101
- // Any combination of digits, letters, or hyphens.
102
-
103
- createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)
104
-
105
- // ## Build Metadata
106
- // Plus sign, followed by one or more period-separated build metadata
107
- // identifiers.
108
-
109
- createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
110
- }(?:\\.${src[t.BUILDIDENTIFIER]})*))`)
111
-
112
- // ## Full Version String
113
- // A main version, followed optionally by a pre-release version and
114
- // build metadata.
115
-
116
- // Note that the only major, minor, patch, and pre-release sections of
117
- // the version string are capturing groups. The build metadata is not a
118
- // capturing group, because it should not ever be used in version
119
- // comparison.
120
-
121
- createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
122
- }${src[t.PRERELEASE]}?${
123
- src[t.BUILD]}?`)
124
-
125
- createToken('FULL', `^${src[t.FULLPLAIN]}$`)
126
-
127
- // like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
128
- // also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
129
- // common in the npm registry.
130
- createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
131
- }${src[t.PRERELEASELOOSE]}?${
132
- src[t.BUILD]}?`)
133
-
134
- createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
135
-
136
- createToken('GTLT', '((?:<|>)?=?)')
137
-
138
- // Something like "2.*" or "1.2.x".
139
- // Note that "x.x" is a valid xRange identifer, meaning "any version"
140
- // Only the first item is strictly required.
141
- createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
142
- createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
143
-
144
- createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
145
- `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
146
- `(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
147
- `(?:${src[t.PRERELEASE]})?${
148
- src[t.BUILD]}?` +
149
- `)?)?`)
150
-
151
- createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
152
- `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
153
- `(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
154
- `(?:${src[t.PRERELEASELOOSE]})?${
155
- src[t.BUILD]}?` +
156
- `)?)?`)
157
-
158
- createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`)
159
- createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)
160
-
161
- // Coercion.
162
- // Extract anything that could conceivably be a part of a valid semver
163
- createToken('COERCEPLAIN', `${'(^|[^\\d])' +
164
- '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
165
- `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
166
- `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`)
167
- createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`)
168
- createToken('COERCEFULL', src[t.COERCEPLAIN] +
169
- `(?:${src[t.PRERELEASE]})?` +
170
- `(?:${src[t.BUILD]})?` +
171
- `(?:$|[^\\d])`)
172
- createToken('COERCERTL', src[t.COERCE], true)
173
- createToken('COERCERTLFULL', src[t.COERCEFULL], true)
174
-
175
- // Tilde ranges.
176
- // Meaning is "reasonably at or greater than"
177
- createToken('LONETILDE', '(?:~>?)')
178
-
179
- createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true)
180
- exports.tildeTrimReplace = '$1~'
181
-
182
- createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)
183
- createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)
184
-
185
- // Caret ranges.
186
- // Meaning is "at least and backwards compatible with"
187
- createToken('LONECARET', '(?:\\^)')
188
-
189
- createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true)
190
- exports.caretTrimReplace = '$1^'
191
-
192
- createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)
193
- createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)
194
-
195
- // A simple gt/lt/eq thing, or just "" to indicate "any version"
196
- createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`)
197
- createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`)
198
-
199
- // An expression to strip any whitespace between the gtlt and the thing
200
- // it modifies, so that `> 1.2.3` ==> `>1.2.3`
201
- createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
202
- }\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)
203
- exports.comparatorTrimReplace = '$1$2$3'
204
-
205
- // Something like `1.2.3 - 1.2.4`
206
- // Note that these all use the loose form, because they'll be
207
- // checked against either the strict or loose comparator form
208
- // later.
209
- createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
210
- `\\s+-\\s+` +
211
- `(${src[t.XRANGEPLAIN]})` +
212
- `\\s*$`)
213
-
214
- createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
215
- `\\s+-\\s+` +
216
- `(${src[t.XRANGEPLAINLOOSE]})` +
217
- `\\s*$`)
218
-
219
- // Star ranges basically just allow anything at all.
220
- createToken('STAR', '(<|>)?=?\\s*\\*')
221
- // >=0.0.0 is like a star
222
- createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$')
223
- createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$')
@@ -1,6 +0,0 @@
1
- 'use strict'
2
-
3
- // Determine if version is greater than all the versions possible in the range.
4
- const outside = require('./outside.js')
5
- const gtr = (version, range, options) => outside(version, range, '>', options)
6
- module.exports = gtr
@@ -1,9 +0,0 @@
1
- 'use strict'
2
-
3
- const Range = require('../classes/range.js')
4
- const intersects = (r1, r2, options) => {
5
- r1 = new Range(r1, options)
6
- r2 = new Range(r2, options)
7
- return r1.intersects(r2, options)
8
- }
9
- module.exports = intersects
@@ -1,6 +0,0 @@
1
- 'use strict'
2
-
3
- const outside = require('./outside.js')
4
- // Determine if version is less than all the versions possible in the range
5
- const ltr = (version, range, options) => outside(version, range, '<', options)
6
- module.exports = ltr
@@ -1,27 +0,0 @@
1
- 'use strict'
2
-
3
- const SemVer = require('../classes/semver.js')
4
- const Range = require('../classes/range.js')
5
-
6
- const maxSatisfying = (versions, range, options) => {
7
- let max = null
8
- let maxSV = null
9
- let rangeObj = null
10
- try {
11
- rangeObj = new Range(range, options)
12
- } catch (er) {
13
- return null
14
- }
15
- versions.forEach((v) => {
16
- if (rangeObj.test(v)) {
17
- // satisfies(v, range, options)
18
- if (!max || maxSV.compare(v) === -1) {
19
- // compare(max, v, true)
20
- max = v
21
- maxSV = new SemVer(max, options)
22
- }
23
- }
24
- })
25
- return max
26
- }
27
- module.exports = maxSatisfying
@@ -1,26 +0,0 @@
1
- 'use strict'
2
-
3
- const SemVer = require('../classes/semver.js')
4
- const Range = require('../classes/range.js')
5
- const minSatisfying = (versions, range, options) => {
6
- let min = null
7
- let minSV = null
8
- let rangeObj = null
9
- try {
10
- rangeObj = new Range(range, options)
11
- } catch (er) {
12
- return null
13
- }
14
- versions.forEach((v) => {
15
- if (rangeObj.test(v)) {
16
- // satisfies(v, range, options)
17
- if (!min || minSV.compare(v) === 1) {
18
- // compare(min, v, true)
19
- min = v
20
- minSV = new SemVer(min, options)
21
- }
22
- }
23
- })
24
- return min
25
- }
26
- module.exports = minSatisfying
@@ -1,63 +0,0 @@
1
- 'use strict'
2
-
3
- const SemVer = require('../classes/semver.js')
4
- const Range = require('../classes/range.js')
5
- const gt = require('../functions/gt.js')
6
-
7
- const minVersion = (range, loose) => {
8
- range = new Range(range, loose)
9
-
10
- let minver = new SemVer('0.0.0')
11
- if (range.test(minver)) {
12
- return minver
13
- }
14
-
15
- minver = new SemVer('0.0.0-0')
16
- if (range.test(minver)) {
17
- return minver
18
- }
19
-
20
- minver = null
21
- for (let i = 0; i < range.set.length; ++i) {
22
- const comparators = range.set[i]
23
-
24
- let setMin = null
25
- comparators.forEach((comparator) => {
26
- // Clone to avoid manipulating the comparator's semver object.
27
- const compver = new SemVer(comparator.semver.version)
28
- switch (comparator.operator) {
29
- case '>':
30
- if (compver.prerelease.length === 0) {
31
- compver.patch++
32
- } else {
33
- compver.prerelease.push(0)
34
- }
35
- compver.raw = compver.format()
36
- /* fallthrough */
37
- case '':
38
- case '>=':
39
- if (!setMin || gt(compver, setMin)) {
40
- setMin = compver
41
- }
42
- break
43
- case '<':
44
- case '<=':
45
- /* Ignore maximum versions */
46
- break
47
- /* istanbul ignore next */
48
- default:
49
- throw new Error(`Unexpected operation: ${comparator.operator}`)
50
- }
51
- })
52
- if (setMin && (!minver || gt(minver, setMin))) {
53
- minver = setMin
54
- }
55
- }
56
-
57
- if (minver && range.test(minver)) {
58
- return minver
59
- }
60
-
61
- return null
62
- }
63
- module.exports = minVersion