@blueking/bkui-form 1.0.1-beta.3 → 1.0.1-beta.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.
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,82 +0,0 @@
1
- 'use strict'
2
-
3
- const SemVer = require('../classes/semver.js')
4
- const Comparator = require('../classes/comparator.js')
5
- const { ANY } = Comparator
6
- const Range = require('../classes/range.js')
7
- const satisfies = require('../functions/satisfies.js')
8
- const gt = require('../functions/gt.js')
9
- const lt = require('../functions/lt.js')
10
- const lte = require('../functions/lte.js')
11
- const gte = require('../functions/gte.js')
12
-
13
- const outside = (version, range, hilo, options) => {
14
- version = new SemVer(version, options)
15
- range = new Range(range, options)
16
-
17
- let gtfn, ltefn, ltfn, comp, ecomp
18
- switch (hilo) {
19
- case '>':
20
- gtfn = gt
21
- ltefn = lte
22
- ltfn = lt
23
- comp = '>'
24
- ecomp = '>='
25
- break
26
- case '<':
27
- gtfn = lt
28
- ltefn = gte
29
- ltfn = gt
30
- comp = '<'
31
- ecomp = '<='
32
- break
33
- default:
34
- throw new TypeError('Must provide a hilo val of "<" or ">"')
35
- }
36
-
37
- // If it satisfies the range it is not outside
38
- if (satisfies(version, range, options)) {
39
- return false
40
- }
41
-
42
- // From now on, variable terms are as if we're in "gtr" mode.
43
- // but note that everything is flipped for the "ltr" function.
44
-
45
- for (let i = 0; i < range.set.length; ++i) {
46
- const comparators = range.set[i]
47
-
48
- let high = null
49
- let low = null
50
-
51
- comparators.forEach((comparator) => {
52
- if (comparator.semver === ANY) {
53
- comparator = new Comparator('>=0.0.0')
54
- }
55
- high = high || comparator
56
- low = low || comparator
57
- if (gtfn(comparator.semver, high.semver, options)) {
58
- high = comparator
59
- } else if (ltfn(comparator.semver, low.semver, options)) {
60
- low = comparator
61
- }
62
- })
63
-
64
- // If the edge version comparator has a operator then our version
65
- // isn't outside it
66
- if (high.operator === comp || high.operator === ecomp) {
67
- return false
68
- }
69
-
70
- // If the lowest version comparator has an operator and our version
71
- // is less than it then it isn't higher than the range
72
- if ((!low.operator || low.operator === comp) &&
73
- ltefn(version, low.semver)) {
74
- return false
75
- } else if (low.operator === ecomp && ltfn(version, low.semver)) {
76
- return false
77
- }
78
- }
79
- return true
80
- }
81
-
82
- module.exports = outside
@@ -1,49 +0,0 @@
1
- 'use strict'
2
-
3
- // given a set of versions and a range, create a "simplified" range
4
- // that includes the same versions that the original range does
5
- // If the original range is shorter than the simplified one, return that.
6
- const satisfies = require('../functions/satisfies.js')
7
- const compare = require('../functions/compare.js')
8
- module.exports = (versions, range, options) => {
9
- const set = []
10
- let first = null
11
- let prev = null
12
- const v = versions.sort((a, b) => compare(a, b, options))
13
- for (const version of v) {
14
- const included = satisfies(version, range, options)
15
- if (included) {
16
- prev = version
17
- if (!first) {
18
- first = version
19
- }
20
- } else {
21
- if (prev) {
22
- set.push([first, prev])
23
- }
24
- prev = null
25
- first = null
26
- }
27
- }
28
- if (first) {
29
- set.push([first, null])
30
- }
31
-
32
- const ranges = []
33
- for (const [min, max] of set) {
34
- if (min === max) {
35
- ranges.push(min)
36
- } else if (!max && min === v[0]) {
37
- ranges.push('*')
38
- } else if (!max) {
39
- ranges.push(`>=${min}`)
40
- } else if (min === v[0]) {
41
- ranges.push(`<=${max}`)
42
- } else {
43
- ranges.push(`${min} - ${max}`)
44
- }
45
- }
46
- const simplified = ranges.join(' || ')
47
- const original = typeof range.raw === 'string' ? range.raw : String(range)
48
- return simplified.length < original.length ? simplified : range
49
- }
@@ -1,249 +0,0 @@
1
- 'use strict'
2
-
3
- const Range = require('../classes/range.js')
4
- const Comparator = require('../classes/comparator.js')
5
- const { ANY } = Comparator
6
- const satisfies = require('../functions/satisfies.js')
7
- const compare = require('../functions/compare.js')
8
-
9
- // Complex range `r1 || r2 || ...` is a subset of `R1 || R2 || ...` iff:
10
- // - Every simple range `r1, r2, ...` is a null set, OR
11
- // - Every simple range `r1, r2, ...` which is not a null set is a subset of
12
- // some `R1, R2, ...`
13
- //
14
- // Simple range `c1 c2 ...` is a subset of simple range `C1 C2 ...` iff:
15
- // - If c is only the ANY comparator
16
- // - If C is only the ANY comparator, return true
17
- // - Else if in prerelease mode, return false
18
- // - else replace c with `[>=0.0.0]`
19
- // - If C is only the ANY comparator
20
- // - if in prerelease mode, return true
21
- // - else replace C with `[>=0.0.0]`
22
- // - Let EQ be the set of = comparators in c
23
- // - If EQ is more than one, return true (null set)
24
- // - Let GT be the highest > or >= comparator in c
25
- // - Let LT be the lowest < or <= comparator in c
26
- // - If GT and LT, and GT.semver > LT.semver, return true (null set)
27
- // - If any C is a = range, and GT or LT are set, return false
28
- // - If EQ
29
- // - If GT, and EQ does not satisfy GT, return true (null set)
30
- // - If LT, and EQ does not satisfy LT, return true (null set)
31
- // - If EQ satisfies every C, return true
32
- // - Else return false
33
- // - If GT
34
- // - If GT.semver is lower than any > or >= comp in C, return false
35
- // - If GT is >=, and GT.semver does not satisfy every C, return false
36
- // - If GT.semver has a prerelease, and not in prerelease mode
37
- // - If no C has a prerelease and the GT.semver tuple, return false
38
- // - If LT
39
- // - If LT.semver is greater than any < or <= comp in C, return false
40
- // - If LT is <=, and LT.semver does not satisfy every C, return false
41
- // - If GT.semver has a prerelease, and not in prerelease mode
42
- // - If no C has a prerelease and the LT.semver tuple, return false
43
- // - Else return true
44
-
45
- const subset = (sub, dom, options = {}) => {
46
- if (sub === dom) {
47
- return true
48
- }
49
-
50
- sub = new Range(sub, options)
51
- dom = new Range(dom, options)
52
- let sawNonNull = false
53
-
54
- OUTER: for (const simpleSub of sub.set) {
55
- for (const simpleDom of dom.set) {
56
- const isSub = simpleSubset(simpleSub, simpleDom, options)
57
- sawNonNull = sawNonNull || isSub !== null
58
- if (isSub) {
59
- continue OUTER
60
- }
61
- }
62
- // the null set is a subset of everything, but null simple ranges in
63
- // a complex range should be ignored. so if we saw a non-null range,
64
- // then we know this isn't a subset, but if EVERY simple range was null,
65
- // then it is a subset.
66
- if (sawNonNull) {
67
- return false
68
- }
69
- }
70
- return true
71
- }
72
-
73
- const minimumVersionWithPreRelease = [new Comparator('>=0.0.0-0')]
74
- const minimumVersion = [new Comparator('>=0.0.0')]
75
-
76
- const simpleSubset = (sub, dom, options) => {
77
- if (sub === dom) {
78
- return true
79
- }
80
-
81
- if (sub.length === 1 && sub[0].semver === ANY) {
82
- if (dom.length === 1 && dom[0].semver === ANY) {
83
- return true
84
- } else if (options.includePrerelease) {
85
- sub = minimumVersionWithPreRelease
86
- } else {
87
- sub = minimumVersion
88
- }
89
- }
90
-
91
- if (dom.length === 1 && dom[0].semver === ANY) {
92
- if (options.includePrerelease) {
93
- return true
94
- } else {
95
- dom = minimumVersion
96
- }
97
- }
98
-
99
- const eqSet = new Set()
100
- let gt, lt
101
- for (const c of sub) {
102
- if (c.operator === '>' || c.operator === '>=') {
103
- gt = higherGT(gt, c, options)
104
- } else if (c.operator === '<' || c.operator === '<=') {
105
- lt = lowerLT(lt, c, options)
106
- } else {
107
- eqSet.add(c.semver)
108
- }
109
- }
110
-
111
- if (eqSet.size > 1) {
112
- return null
113
- }
114
-
115
- let gtltComp
116
- if (gt && lt) {
117
- gtltComp = compare(gt.semver, lt.semver, options)
118
- if (gtltComp > 0) {
119
- return null
120
- } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
121
- return null
122
- }
123
- }
124
-
125
- // will iterate one or zero times
126
- for (const eq of eqSet) {
127
- if (gt && !satisfies(eq, String(gt), options)) {
128
- return null
129
- }
130
-
131
- if (lt && !satisfies(eq, String(lt), options)) {
132
- return null
133
- }
134
-
135
- for (const c of dom) {
136
- if (!satisfies(eq, String(c), options)) {
137
- return false
138
- }
139
- }
140
-
141
- return true
142
- }
143
-
144
- let higher, lower
145
- let hasDomLT, hasDomGT
146
- // if the subset has a prerelease, we need a comparator in the superset
147
- // with the same tuple and a prerelease, or it's not a subset
148
- let needDomLTPre = lt &&
149
- !options.includePrerelease &&
150
- lt.semver.prerelease.length ? lt.semver : false
151
- let needDomGTPre = gt &&
152
- !options.includePrerelease &&
153
- gt.semver.prerelease.length ? gt.semver : false
154
- // exception: <1.2.3-0 is the same as <1.2.3
155
- if (needDomLTPre && needDomLTPre.prerelease.length === 1 &&
156
- lt.operator === '<' && needDomLTPre.prerelease[0] === 0) {
157
- needDomLTPre = false
158
- }
159
-
160
- for (const c of dom) {
161
- hasDomGT = hasDomGT || c.operator === '>' || c.operator === '>='
162
- hasDomLT = hasDomLT || c.operator === '<' || c.operator === '<='
163
- if (gt) {
164
- if (needDomGTPre) {
165
- if (c.semver.prerelease && c.semver.prerelease.length &&
166
- c.semver.major === needDomGTPre.major &&
167
- c.semver.minor === needDomGTPre.minor &&
168
- c.semver.patch === needDomGTPre.patch) {
169
- needDomGTPre = false
170
- }
171
- }
172
- if (c.operator === '>' || c.operator === '>=') {
173
- higher = higherGT(gt, c, options)
174
- if (higher === c && higher !== gt) {
175
- return false
176
- }
177
- } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
178
- return false
179
- }
180
- }
181
- if (lt) {
182
- if (needDomLTPre) {
183
- if (c.semver.prerelease && c.semver.prerelease.length &&
184
- c.semver.major === needDomLTPre.major &&
185
- c.semver.minor === needDomLTPre.minor &&
186
- c.semver.patch === needDomLTPre.patch) {
187
- needDomLTPre = false
188
- }
189
- }
190
- if (c.operator === '<' || c.operator === '<=') {
191
- lower = lowerLT(lt, c, options)
192
- if (lower === c && lower !== lt) {
193
- return false
194
- }
195
- } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
196
- return false
197
- }
198
- }
199
- if (!c.operator && (lt || gt) && gtltComp !== 0) {
200
- return false
201
- }
202
- }
203
-
204
- // if there was a < or >, and nothing in the dom, then must be false
205
- // UNLESS it was limited by another range in the other direction.
206
- // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
207
- if (gt && hasDomLT && !lt && gtltComp !== 0) {
208
- return false
209
- }
210
-
211
- if (lt && hasDomGT && !gt && gtltComp !== 0) {
212
- return false
213
- }
214
-
215
- // we needed a prerelease range in a specific tuple, but didn't get one
216
- // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
217
- // because it includes prereleases in the 1.2.3 tuple
218
- if (needDomGTPre || needDomLTPre) {
219
- return false
220
- }
221
-
222
- return true
223
- }
224
-
225
- // >=1.2.3 is lower than >1.2.3
226
- const higherGT = (a, b, options) => {
227
- if (!a) {
228
- return b
229
- }
230
- const comp = compare(a.semver, b.semver, options)
231
- return comp > 0 ? a
232
- : comp < 0 ? b
233
- : b.operator === '>' && a.operator === '>=' ? b
234
- : a
235
- }
236
-
237
- // <=1.2.3 is higher than <1.2.3
238
- const lowerLT = (a, b, options) => {
239
- if (!a) {
240
- return b
241
- }
242
- const comp = compare(a.semver, b.semver, options)
243
- return comp < 0 ? a
244
- : comp > 0 ? b
245
- : b.operator === '<' && a.operator === '<=' ? b
246
- : a
247
- }
248
-
249
- module.exports = subset
@@ -1,10 +0,0 @@
1
- 'use strict'
2
-
3
- const Range = require('../classes/range.js')
4
-
5
- // Mostly just for testing and legacy API reasons
6
- const toComparators = (range, options) =>
7
- new Range(range, options).set
8
- .map(comp => comp.map(c => c.value).join(' ').trim().split(' '))
9
-
10
- module.exports = toComparators
@@ -1,13 +0,0 @@
1
- 'use strict'
2
-
3
- const Range = require('../classes/range.js')
4
- const validRange = (range, options) => {
5
- try {
6
- // Return '*' instead of '' so that truthiness works.
7
- // This will throw if it's invalid anyway
8
- return new Range(range, options).range || '*'
9
- } catch (er) {
10
- return null
11
- }
12
- }
13
- module.exports = validRange
@@ -1,190 +0,0 @@
1
- function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
2
- try {
3
- var info = gen[key](arg);
4
- var value = info.value;
5
- } catch (error) {
6
- reject(error);
7
- return;
8
- }
9
- if (info.done) {
10
- resolve(value);
11
- } else {
12
- Promise.resolve(value).then(_next, _throw);
13
- }
14
- }
15
- function _async_to_generator(fn) {
16
- return function() {
17
- var self = this, args = arguments;
18
- return new Promise(function(resolve, reject) {
19
- var gen = fn.apply(self, args);
20
- function _next(value) {
21
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
22
- }
23
- function _throw(err) {
24
- asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
25
- }
26
- _next(undefined);
27
- });
28
- };
29
- }
30
- function _define_property(obj, key, value) {
31
- if (key in obj) {
32
- Object.defineProperty(obj, key, {
33
- value: value,
34
- enumerable: true,
35
- configurable: true,
36
- writable: true
37
- });
38
- } else {
39
- obj[key] = value;
40
- }
41
- return obj;
42
- }
43
- function _object_spread(target) {
44
- for(var i = 1; i < arguments.length; i++){
45
- var source = arguments[i] != null ? arguments[i] : {};
46
- var ownKeys = Object.keys(source);
47
- if (typeof Object.getOwnPropertySymbols === "function") {
48
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
49
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
50
- }));
51
- }
52
- ownKeys.forEach(function(key) {
53
- _define_property(target, key, source[key]);
54
- });
55
- }
56
- return target;
57
- }
58
- function ownKeys(object, enumerableOnly) {
59
- var keys = Object.keys(object);
60
- if (Object.getOwnPropertySymbols) {
61
- var symbols = Object.getOwnPropertySymbols(object);
62
- if (enumerableOnly) {
63
- symbols = symbols.filter(function(sym) {
64
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
65
- });
66
- }
67
- keys.push.apply(keys, symbols);
68
- }
69
- return keys;
70
- }
71
- function _object_spread_props(target, source) {
72
- source = source != null ? source : {};
73
- if (Object.getOwnPropertyDescriptors) {
74
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
75
- } else {
76
- ownKeys(Object(source)).forEach(function(key) {
77
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
78
- });
79
- }
80
- return target;
81
- }
82
- function _object_without_properties(source, excluded) {
83
- if (source == null) return {};
84
- var target = _object_without_properties_loose(source, excluded);
85
- var key, i;
86
- if (Object.getOwnPropertySymbols) {
87
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
88
- for(i = 0; i < sourceSymbolKeys.length; i++){
89
- key = sourceSymbolKeys[i];
90
- if (excluded.indexOf(key) >= 0) continue;
91
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
92
- target[key] = source[key];
93
- }
94
- }
95
- return target;
96
- }
97
- function _object_without_properties_loose(source, excluded) {
98
- if (source == null) return {};
99
- var target = {};
100
- var sourceKeys = Object.keys(source);
101
- var key, i;
102
- for(i = 0; i < sourceKeys.length; i++){
103
- key = sourceKeys[i];
104
- if (excluded.indexOf(key) >= 0) continue;
105
- target[key] = source[key];
106
- }
107
- return target;
108
- }
109
- import { isObj, mergeDeep } from './index.ts.js';
110
- const methodsWithoutData = [
111
- 'GET',
112
- 'HEAD',
113
- 'OPTIONS',
114
- 'DELETE'
115
- ];
116
- const defaultConfig = {
117
- responseType: 'json',
118
- method: 'GET',
119
- params: {},
120
- headers: {},
121
- cache: 'no-cache'
122
- };
123
- export default (function() {
124
- var _ref = _async_to_generator(function*(url, config = {}) {
125
- const _mergeDeep = mergeDeep(defaultConfig, config), { params, responseType = 'json', method = 'GET', headers = {}, responseParse } = _mergeDeep, reset = _object_without_properties(_mergeDeep, [
126
- "params",
127
- "responseType",
128
- "method",
129
- "headers",
130
- "responseParse"
131
- ]);
132
- let body;
133
- let requestURL = url;
134
- // 处理参数
135
- if (methodsWithoutData.includes(method.toUpperCase())) {
136
- requestURL = `${requestURL}?${isObj(params) ? new URLSearchParams(params) : params || ''}`;
137
- } else {
138
- if (isObj(params)) {
139
- // 处理JSON类型的请求
140
- headers['Content-Type'] = 'application/json;charset=utf-8';
141
- body = JSON.stringify(params);
142
- } else {
143
- body = params;
144
- }
145
- }
146
- try {
147
- const response = yield fetch(requestURL, _object_spread_props(_object_spread({}, reset), {
148
- method: method.toLocaleUpperCase(),
149
- headers,
150
- body
151
- }));
152
- if (response.ok) {
153
- // 对应 HTTP 请求的状态码 200 到 299
154
- // 如果后端有自己的code,则需要自己在response后再判断一层
155
- const res = yield response[responseType]();
156
- if (responseParse) {
157
- if (typeof responseParse === 'function') {
158
- return Promise.resolve(responseParse(res));
159
- }
160
- if (isObj(responseParse)) {
161
- const { dataKey = 'data', labelKey, valueKey } = responseParse;
162
- const data = ((res === null || res === void 0 ? void 0 : res[dataKey]) || []).map((item)=>_object_spread_props(_object_spread({}, item), {
163
- label: item === null || item === void 0 ? void 0 : item[labelKey],
164
- value: item === null || item === void 0 ? void 0 : item[valueKey]
165
- }));
166
- return Promise.resolve(data);
167
- }
168
- return Promise.resolve(res);
169
- }
170
- return Promise.resolve(res);
171
- }
172
- switch(response.status){
173
- case 400:
174
- break;
175
- case 401:
176
- break;
177
- case 403:
178
- // 无权限
179
- case 500:
180
- break;
181
- }
182
- } catch (err) {
183
- console.error('Request Failed', err);
184
- Promise.reject(err);
185
- }
186
- });
187
- return function(url) {
188
- return _ref.apply(this, arguments);
189
- };
190
- })();