@powerlines/plugin-automd 0.1.222 → 0.1.224

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 (94) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +0 -2
  2. package/dist/index.cjs +5 -5
  3. package/dist/index.d.cts +2 -1
  4. package/dist/index.d.mts +1 -1
  5. package/dist/index.mjs +7 -7
  6. package/dist/types/plugin.d.cts +3 -3
  7. package/dist/types/plugin.d.mts +3 -3
  8. package/package.json +3 -3
  9. package/dist/_virtual/rolldown_runtime.mjs +0 -32
  10. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.cjs +0 -78
  11. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.5/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.mjs +0 -77
  12. package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.cjs +0 -5032
  13. package/dist/node_modules/.pnpm/acorn@8.15.0/node_modules/acorn/dist/acorn.mjs +0 -5031
  14. package/dist/node_modules/.pnpm/automd@0.4.2_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/shared/automd.CjwUz8DJ.cjs +0 -593
  15. package/dist/node_modules/.pnpm/automd@0.4.2_patch_hash_0fe864a2d6fa1461e144747e5f0fbc0a5fb51435ec6b3217ffb18ff2d7058778_magicast@0.5.1/node_modules/automd/dist/shared/automd.CjwUz8DJ.mjs +0 -590
  16. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.cjs +0 -23
  17. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DA7CpUDY.mjs +0 -22
  18. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.cjs +0 -405
  19. package/dist/node_modules/.pnpm/confbox@0.2.2/node_modules/confbox/dist/shared/confbox.DnMsyigM.mjs +0 -404
  20. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.cjs +0 -46
  21. package/dist/node_modules/.pnpm/destr@2.0.5/node_modules/destr/dist/index.mjs +0 -45
  22. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.cjs +0 -204
  23. package/dist/node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs +0 -202
  24. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.cjs +0 -1013
  25. package/dist/node_modules/.pnpm/exsolve@1.0.8/node_modules/exsolve/dist/index.mjs +0 -1007
  26. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.cjs +0 -128
  27. package/dist/node_modules/.pnpm/fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs +0 -123
  28. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.cjs +0 -41464
  29. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/babel.mjs +0 -41461
  30. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.cjs +0 -4387
  31. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/dist/jiti.mjs +0 -4384
  32. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.cjs +0 -26
  33. package/dist/node_modules/.pnpm/jiti@2.4.2/node_modules/jiti/lib/jiti.mjs +0 -26
  34. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.cjs +0 -370
  35. package/dist/node_modules/.pnpm/lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs +0 -367
  36. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.cjs +0 -939
  37. package/dist/node_modules/.pnpm/magic-string@0.30.21/node_modules/magic-string/dist/magic-string.es.mjs +0 -939
  38. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.cjs +0 -67
  39. package/dist/node_modules/.pnpm/mdbox@0.1.1/node_modules/mdbox/dist/index.mjs +0 -64
  40. package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.cjs +0 -1292
  41. package/dist/node_modules/.pnpm/mlly@1.8.0/node_modules/mlly/dist/index.mjs +0 -1284
  42. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.cjs +0 -179
  43. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/chunks/multipart-parser.mjs +0 -179
  44. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.cjs +0 -20
  45. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/index.mjs +0 -18
  46. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.cjs +0 -3975
  47. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/node.mjs +0 -3961
  48. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.cjs +0 -16
  49. package/dist/node_modules/.pnpm/node-fetch-native@1.6.7/node_modules/node-fetch-native/dist/shared/node-fetch-native.DfbY2q-x.mjs +0 -14
  50. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.cjs +0 -36
  51. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/node.mjs +0 -33
  52. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.cjs +0 -227
  53. package/dist/node_modules/.pnpm/ofetch@1.5.1/node_modules/ofetch/dist/shared/ofetch.CWycOUEr.mjs +0 -225
  54. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.cjs +0 -139
  55. package/dist/node_modules/.pnpm/pathe@2.0.3/node_modules/pathe/dist/shared/pathe.M-eThtNZ.mjs +0 -133
  56. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.cjs +0 -77
  57. package/dist/node_modules/.pnpm/pkg-types@2.3.0/node_modules/pkg-types/dist/index.mjs +0 -76
  58. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.cjs +0 -72
  59. package/dist/node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs +0 -69
  60. package/dist/node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.cjs +0 -181
  61. package/dist/node_modules/.pnpm/ufo@1.6.3/node_modules/ufo/dist/index.mjs +0 -178
  62. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.cjs +0 -12337
  63. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/babel.mjs +0 -12337
  64. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.cjs +0 -19
  65. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/loader/loader.mjs +0 -18
  66. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.cjs +0 -71
  67. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.BTwOq8Jl.mjs +0 -71
  68. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.cjs +0 -110
  69. package/dist/node_modules/.pnpm/untyped@2.0.0/node_modules/untyped/dist/shared/untyped.Br_uXjZG.mjs +0 -100
  70. package/dist/packages/powerlines/src/internal/helpers/hooks.d.mts +0 -49
  71. package/dist/packages/powerlines/src/types/api.d.mts +0 -104
  72. package/dist/packages/powerlines/src/types/babel.d.mts +0 -2
  73. package/dist/packages/powerlines/src/types/build.d.mts +0 -185
  74. package/dist/packages/powerlines/src/types/commands.d.mts +0 -9
  75. package/dist/packages/powerlines/src/types/config.d.mts +0 -425
  76. package/dist/packages/powerlines/src/types/context.d.mts +0 -514
  77. package/dist/packages/powerlines/src/types/fs.d.mts +0 -486
  78. package/dist/packages/powerlines/src/types/hooks.d.mts +0 -32
  79. package/dist/packages/powerlines/src/types/plugin.d.mts +0 -205
  80. package/dist/packages/powerlines/src/types/resolved.d.mts +0 -93
  81. package/dist/packages/powerlines/src/types/tsconfig.d.mts +0 -69
  82. package/dist/packages/powerlines/src/types/unplugin.d.mts +0 -23
  83. package/dist/powerlines/src/internal/helpers/hooks.d.cts +0 -47
  84. package/dist/powerlines/src/types/api.d.cts +0 -104
  85. package/dist/powerlines/src/types/build.d.cts +0 -185
  86. package/dist/powerlines/src/types/commands.d.cts +0 -8
  87. package/dist/powerlines/src/types/config.d.cts +0 -424
  88. package/dist/powerlines/src/types/context.d.cts +0 -514
  89. package/dist/powerlines/src/types/fs.d.cts +0 -486
  90. package/dist/powerlines/src/types/hooks.d.cts +0 -32
  91. package/dist/powerlines/src/types/plugin.d.cts +0 -205
  92. package/dist/powerlines/src/types/resolved.d.cts +0 -93
  93. package/dist/powerlines/src/types/tsconfig.d.cts +0 -69
  94. package/dist/powerlines/src/types/unplugin.d.cts +0 -22
@@ -1,202 +0,0 @@
1
- import { __toESM } from "../../../../../../_virtual/rolldown_runtime.mjs";
2
- import { require_fastest_levenshtein } from "../../../../fastest-levenshtein@1.0.16/node_modules/fastest-levenshtein/mod.mjs";
3
- import { require_lodash } from "../../../../lodash.deburr@4.1.0/node_modules/lodash.deburr/index.mjs";
4
-
5
- //#region ../../node_modules/.pnpm/didyoumean2@7.0.4/node_modules/didyoumean2/dist/index.mjs
6
- var import_fastest_levenshtein = require_fastest_levenshtein();
7
- var import_lodash = /* @__PURE__ */ __toESM(require_lodash(), 1);
8
- let ReturnTypeEnums = /* @__PURE__ */ function(ReturnTypeEnums$1) {
9
- ReturnTypeEnums$1["ALL_CLOSEST_MATCHES"] = "all-closest-matches";
10
- ReturnTypeEnums$1["ALL_MATCHES"] = "all-matches";
11
- ReturnTypeEnums$1["ALL_SORTED_MATCHES"] = "all-sorted-matches";
12
- ReturnTypeEnums$1["FIRST_CLOSEST_MATCH"] = "first-closest-match";
13
- ReturnTypeEnums$1["FIRST_MATCH"] = "first-match";
14
- return ReturnTypeEnums$1;
15
- }({});
16
- let ThresholdTypeEnums = /* @__PURE__ */ function(ThresholdTypeEnums$1) {
17
- ThresholdTypeEnums$1["EDIT_DISTANCE"] = "edit-distance";
18
- ThresholdTypeEnums$1["SIMILARITY"] = "similarity";
19
- return ThresholdTypeEnums$1;
20
- }({});
21
- const fillDefaultOptions = (options) => {
22
- const optionsWithDefaultValues = {
23
- caseSensitive: false,
24
- deburr: true,
25
- matchPath: [],
26
- returnType: ReturnTypeEnums.FIRST_CLOSEST_MATCH,
27
- thresholdType: ThresholdTypeEnums.SIMILARITY,
28
- trimSpaces: true,
29
- ...options
30
- };
31
- if (!Object.values(ReturnTypeEnums).includes(optionsWithDefaultValues.returnType)) throw new TypeError("unknown returnType");
32
- if (!Object.values(ThresholdTypeEnums).includes(optionsWithDefaultValues.thresholdType)) throw new TypeError("unknown thresholdType");
33
- switch (optionsWithDefaultValues.thresholdType) {
34
- case ThresholdTypeEnums.EDIT_DISTANCE: return {
35
- threshold: 20,
36
- ...optionsWithDefaultValues
37
- };
38
- case ThresholdTypeEnums.SIMILARITY: return {
39
- threshold: .4,
40
- ...optionsWithDefaultValues
41
- };
42
- }
43
- };
44
- /**
45
- * Using edit distance between `a` and `b` to calculate similarity
46
- *
47
- * @param {string} a - `input`
48
- * @param {string} b - String from `matchList`
49
- * @returns {number} similarity between `a` and `b`
50
- */
51
- const getSimilarity = (a, b) => {
52
- if (!a || !b) return 0;
53
- if (a === b) return 1;
54
- const editDistance = (0, import_fastest_levenshtein.distance)(a, b);
55
- const longestLength = Math.max(a.length, b.length);
56
- return (longestLength - editDistance) / longestLength;
57
- };
58
- /**
59
- * Normalize a string
60
- *
61
- * @param {string} str - any string
62
- * @param {object} options - options that allows you to modify the behavior
63
- * @returns {string} - normalized string
64
- */
65
- const normalizeString = (str, options) => {
66
- let s = str;
67
- if (options.trimSpaces) s = s.trim().replaceAll(/\s+/gu, " ");
68
- if (options.deburr) s = (0, import_lodash.default)(s);
69
- if (!options.caseSensitive) s = s.toLowerCase();
70
- return s;
71
- };
72
- const getMatchItemStr = (matchItem, matchPath) => {
73
- const matchItemStr = matchPath.length > 0 ? matchPath.reduce((acc, prop) => {
74
- return acc?.[prop];
75
- }, matchItem) : matchItem;
76
- if (typeof matchItemStr !== "string") return "";
77
- return matchItemStr;
78
- };
79
- /**
80
- * Process matchItem according to options
81
- *
82
- * @param {object | string} matchItem - Item for matching with `input`
83
- * @param {object} options - options that allows you to modify the behavior
84
- * @returns {string} - processed matchItem
85
- */
86
- const matchItemProcessor = (matchItem, options) => {
87
- const { matchPath } = options;
88
- return normalizeString(getMatchItemStr(matchItem, matchPath), options);
89
- };
90
- /**
91
- * Generate result
92
- *
93
- * @param {object[] | string[]} matchList - List for matching with `input`
94
- * @param {number[]} matchedIndexes - indexes of matchList that need to be returned as result
95
- * @param {ReturnTypeEnums} returnType - how the result will response to user
96
- * @returns {Array | null | object | string} - matched result(s), return object if `match` is `{Object[]}`
97
- */
98
- const resultProcessor = (matchList, matchedIndexes, returnType) => {
99
- switch (returnType) {
100
- case ReturnTypeEnums.ALL_CLOSEST_MATCHES:
101
- case ReturnTypeEnums.ALL_MATCHES:
102
- case ReturnTypeEnums.ALL_SORTED_MATCHES: return matchedIndexes.map((matchedIndex) => matchList[matchedIndex]);
103
- case ReturnTypeEnums.FIRST_CLOSEST_MATCH:
104
- case ReturnTypeEnums.FIRST_MATCH: {
105
- const matchedIndex = matchedIndexes[0];
106
- if (matchedIndex === void 0) return null;
107
- return matchList[matchedIndex];
108
- }
109
- }
110
- };
111
- /**
112
- * Main function for didyoumean2
113
- *
114
- * @param {string} input - string that you are not sure and want to match with `matchList`
115
- * @param {object[] | string[]} matchList - List for matching with `input`
116
- * @param {null | object | undefined} options - options that allows you to modify the behavior
117
- * @returns {Array | null | object | string} - matched result(s), return object if `match` is `{Object[]}`
118
- */
119
- function didYouMean(input, matchList, options) {
120
- const optionsWithDefaults = fillDefaultOptions(options);
121
- const { returnType, threshold, thresholdType } = optionsWithDefaults;
122
- const normalizedInput = normalizeString(input, optionsWithDefaults);
123
- let checkIfMatched;
124
- let scoreProcessor;
125
- switch (thresholdType) {
126
- case ThresholdTypeEnums.EDIT_DISTANCE:
127
- checkIfMatched = (score) => score <= threshold;
128
- scoreProcessor = (matchItem) => (0, import_fastest_levenshtein.distance)(normalizedInput, matchItemProcessor(matchItem, optionsWithDefaults));
129
- break;
130
- case ThresholdTypeEnums.SIMILARITY:
131
- checkIfMatched = (score) => score >= threshold;
132
- scoreProcessor = (matchItem) => getSimilarity(normalizedInput, matchItemProcessor(matchItem, optionsWithDefaults));
133
- break;
134
- }
135
- const matchedIndexes = [];
136
- switch (returnType) {
137
- case ReturnTypeEnums.ALL_CLOSEST_MATCHES:
138
- case ReturnTypeEnums.FIRST_CLOSEST_MATCH: {
139
- const scores = [];
140
- let marginValue;
141
- switch (thresholdType) {
142
- case ThresholdTypeEnums.EDIT_DISTANCE:
143
- marginValue = Number.POSITIVE_INFINITY;
144
- for (const matchItem of matchList) {
145
- const score = scoreProcessor(matchItem);
146
- if (marginValue > score) marginValue = score;
147
- scores.push(score);
148
- }
149
- break;
150
- case ThresholdTypeEnums.SIMILARITY:
151
- marginValue = 0;
152
- for (const matchItem of matchList) {
153
- const score = scoreProcessor(matchItem);
154
- if (marginValue < score) marginValue = score;
155
- scores.push(score);
156
- }
157
- break;
158
- }
159
- for (const [i, score] of scores.entries()) if (checkIfMatched(score) && score === marginValue) matchedIndexes.push(i);
160
- break;
161
- }
162
- case ReturnTypeEnums.ALL_MATCHES:
163
- for (const [i, matchItem] of matchList.entries()) {
164
- const score = scoreProcessor(matchItem);
165
- if (checkIfMatched(score)) matchedIndexes.push(i);
166
- }
167
- break;
168
- case ReturnTypeEnums.ALL_SORTED_MATCHES: {
169
- const unsortedResults = [];
170
- for (const [i, matchItem] of matchList.entries()) {
171
- const score = scoreProcessor(matchItem);
172
- if (checkIfMatched(score)) unsortedResults.push({
173
- score,
174
- index: i
175
- });
176
- }
177
- switch (thresholdType) {
178
- case ThresholdTypeEnums.EDIT_DISTANCE:
179
- unsortedResults.sort((a, b) => a.score - b.score);
180
- break;
181
- case ThresholdTypeEnums.SIMILARITY:
182
- unsortedResults.sort((a, b) => b.score - a.score);
183
- break;
184
- }
185
- for (const unsortedResult of unsortedResults) matchedIndexes.push(unsortedResult.index);
186
- break;
187
- }
188
- case ReturnTypeEnums.FIRST_MATCH:
189
- for (const [i, matchItem] of matchList.entries()) {
190
- const score = scoreProcessor(matchItem);
191
- if (checkIfMatched(score)) {
192
- matchedIndexes.push(i);
193
- break;
194
- }
195
- }
196
- break;
197
- }
198
- return resultProcessor(matchList, matchedIndexes, returnType);
199
- }
200
-
201
- //#endregion
202
- export { ReturnTypeEnums, ThresholdTypeEnums, didYouMean as default };