@ruan-cat/utils 1.5.0 → 2.0.1

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 (34) hide show
  1. package/{readme.md → README.md} +6 -0
  2. package/dist/index.d.ts +26 -45
  3. package/dist/index.js +1 -37
  4. package/dist/index.js.map +1 -1
  5. package/dist/node-cjs/index.cjs +103 -0
  6. package/dist/node-cjs/index.cjs.map +1 -0
  7. package/dist/node-cjs/index.d.cts +42 -0
  8. package/dist/node-esm/index.d.ts +88 -0
  9. package/dist/node-esm/index.js +388 -0
  10. package/dist/node-esm/index.js.map +1 -0
  11. package/dist/node-esm/template/components.template.js +0 -0
  12. package/dist/node-esm/template/components.template.ts +21 -0
  13. package/package.json +28 -8
  14. package/src/index.ts +5 -4
  15. package/src/node-cjs/index.ts +1 -0
  16. package/src/node-cjs/tools.ts +100 -0
  17. package/src/node-esm/index.ts +5 -0
  18. package/src/node-esm/scripts/clean.ts +45 -0
  19. package/src/node-esm/vite-plugin-autogeneration-import-file/README.md +11 -0
  20. package/src/node-esm/vite-plugin-autogeneration-import-file/index.ts +120 -0
  21. package/src/node-esm/vite-plugin-autogeneration-import-file/template/components.template.ts +21 -0
  22. package/src/node-esm/vite-plugin-autogeneration-import-file/vite-plugin-autogeneration-import-file.test.ts +7 -0
  23. package/src/unplugin-vue-router/index.ts +10 -0
  24. package/src/vueuse/README.md +9 -0
  25. package/src/vueuse/useAxios/README.md +53 -0
  26. package/dist/index.cjs +0 -1040
  27. package/dist/index.cjs.map +0 -1
  28. package/dist/index.d.cts +0 -339
  29. package/dist/index.global.js +0 -70919
  30. package/dist/index.global.js.map +0 -1
  31. package/src/node.ts +0 -17
  32. /package/src/{ruan-cat-pkg-info.ts → node-esm/ruan-cat-pkg-info.ts} +0 -0
  33. /package/src/{Prettify.ts → types/Prettify.ts} +0 -0
  34. /package/src/vueuse/{useAxios.ts → useAxios/index.ts} +0 -0
@@ -1,3 +1,9 @@
1
+ ---
2
+ order: 10
3
+ dir:
4
+ order: 10
5
+ ---
6
+
1
7
  # 工具包
2
8
 
3
9
  这是阮喵喵开发的工具包,提供了一些工具函数。
package/dist/index.d.ts CHANGED
@@ -116,21 +116,6 @@ type Conditions = Condition[];
116
116
  declare function isConditionsEvery(conditions: Condition[]): boolean;
117
117
  declare function isConditionsSome(conditions: Condition[]): boolean;
118
118
 
119
- /**
120
- * `Prettify` 帮助程序是一种实用程序类型,它采用对象类型并使悬停叠加更具可读性。
121
- * @see https://www.totaltypescript.com/concepts/the-prettify-helper
122
- */
123
- type Prettify<T> = {
124
- [K in keyof T]: T[K];
125
- } & {};
126
- /**
127
- * 转换成 NumberLike 类型
128
- * @description
129
- * ### *设计理由*
130
- * 期望让一个数值类型的联合类型 变成`NumberLike`形式的类型
131
- */
132
- type ToNumberLike<T extends number> = T | `${T}`;
133
-
134
119
  type GetRouteName = NonNullable<Options["getRouteName"]>;
135
120
  /**
136
121
  * 自主生成路由名称
@@ -140,6 +125,16 @@ type GetRouteName = NonNullable<Options["getRouteName"]>;
140
125
  * 故自定义。
141
126
  *
142
127
  * unplugin-vue-router 插件的 getRouteName 配置项
128
+ *
129
+ * FIXME: https://github.com/vitejs/vite/issues/5370
130
+ *
131
+ * 该函数设计出来是为了解决这个问题
132
+ *
133
+ * 在vite符号链接未解决时,应该直接使用js文件,如下:
134
+ * import { getRouteName } from "@ruan-cat/utils/dist/index.js";
135
+ *
136
+ * 若已经彻底解决,请直接试图用来自符号链接的ts文件,如下:
137
+ * import { getRouteName } from "@ruan-cat/utils";
143
138
  */
144
139
  declare const getRouteName: GetRouteName;
145
140
 
@@ -285,35 +280,6 @@ D = any> {
285
280
  */
286
281
  declare function useAxiosWrapper<T, K extends KeyAxiosRequestConfig, D = any>(params: UseAxiosWrapperParams): StrictUseAxiosReturn<T, K, AxiosResponse<T, any>, D> & Promise<StrictUseAxiosReturn<T, K, AxiosResponse<T, any>, D>>;
287
282
 
288
- /** 包的信息 */
289
- interface PackageInfo {
290
- /** 包名 */
291
- name: string;
292
- /** 包的描述 */
293
- description: string;
294
- /** 带有包名的官方镜像源地址 */
295
- url: `https://npm.im/${string}`;
296
- }
297
- /**
298
- * 获得阮喵喵全部的包信息
299
- * @description
300
- * 这是一个node环境下的函数,用于获取阮喵喵的所有包的信息。
301
- *
302
- * 使用的是node的child_process模块,调用pnpm命令获取包信息。
303
- *
304
- * - 默认仅考虑pnpm包
305
- * - 在node环境下运行
306
- */
307
- declare function getRuanCatPkgInfo(): Promise<PackageInfo[]>;
308
-
309
- /**
310
- * 一些node环境下的工具函数
311
- */
312
- /**
313
- * 路径转换工具
314
- */
315
- declare function pathChange(path: string): string;
316
-
317
283
  /**
318
284
  * pnpm-workspace.yaml 文件的类型声明
319
285
  * @description
@@ -336,4 +302,19 @@ interface PnpmWorkspace {
336
302
  catalog?: string[];
337
303
  }
338
304
 
339
- export { type AttributePromptTool, type BaseTask, type Condition, type Conditions, type CreateAxiosRequestConfig, type FunctionKeys, type HandleStrategy, type KeyAxiosRequestConfig, type KeyHelper, type PackageInfo, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, type RemoveUrl, RmmvClass, type SimpleAsyncTask, type SingleTasks, type StrictUseAxiosReturn, type Task, type TaskType, type TasksConfig, type ToNumberLike, type UseAxiosWrapperParams, defaultHandleStrategy, type defaultHandleStrategy_FuncationName, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, getRouteName, getRuanCatPkgInfo, initFlag, isConditionsEvery, isConditionsSome, pathChange, rmmvClassExpandTools, runPromiseByConcurrency, runPromiseByQueue, taskTypes, useAxiosWrapper };
305
+ /**
306
+ * `Prettify` 帮助程序是一种实用程序类型,它采用对象类型并使悬停叠加更具可读性。
307
+ * @see https://www.totaltypescript.com/concepts/the-prettify-helper
308
+ */
309
+ type Prettify<T> = {
310
+ [K in keyof T]: T[K];
311
+ } & {};
312
+ /**
313
+ * 转换成 NumberLike 类型
314
+ * @description
315
+ * ### *设计理由*
316
+ * 期望让一个数值类型的联合类型 变成`NumberLike`形式的类型
317
+ */
318
+ type ToNumberLike<T extends number> = T | `${T}`;
319
+
320
+ export { type AttributePromptTool, type BaseTask, type Condition, type Conditions, type CreateAxiosRequestConfig, type FunctionKeys, type HandleStrategy, type KeyAxiosRequestConfig, type KeyHelper, type ParallelTasks, type PnpmWorkspace, type Prettify, type PromiseTasksConfig, type QueueTasks, type RemoveUrl, RmmvClass, type SimpleAsyncTask, type SingleTasks, type StrictUseAxiosReturn, type Task, type TaskType, type TasksConfig, type ToNumberLike, type UseAxiosWrapperParams, defaultHandleStrategy, type defaultHandleStrategy_FuncationName, definePromiseTasks, executePromiseTasks, generateSimpleAsyncTask, getRouteName, initFlag, isConditionsEvery, isConditionsSome, rmmvClassExpandTools, runPromiseByConcurrency, runPromiseByQueue, taskTypes, useAxiosWrapper };
package/dist/index.js CHANGED
@@ -921,7 +921,7 @@ async function runPromiseByConcurrency(promises) {
921
921
  await Promise.all(promises.map((promise) => promise()));
922
922
  }
923
923
 
924
- // src/vueuse/useAxios.ts
924
+ // src/vueuse/useAxios/index.ts
925
925
  import { useAxios } from "@vueuse/integrations/useAxios";
926
926
  function useAxiosWrapper(params) {
927
927
  const {
@@ -932,51 +932,15 @@ function useAxiosWrapper(params) {
932
932
  } = params;
933
933
  return useAxios(url, config, instance, options);
934
934
  }
935
-
936
- // src/ruan-cat-pkg-info.ts
937
- import { spawnSync } from "node:child_process";
938
- async function getRuanCatPkgInfo() {
939
- return new Promise((resolve, reject) => {
940
- const result = spawnSync("pnpm", ["s", "@ruan-cat/*", "--registry", "https://registry.npmmirror.com/", "--json"], {
941
- encoding: "utf-8"
942
- });
943
- if (result.error) {
944
- console.error(`Error executing command: ${result.error.message}`);
945
- reject(result.error);
946
- return;
947
- }
948
- if (result.stderr) {
949
- console.error(`Error in output: ${result.stderr}`);
950
- reject(new Error(result.stderr));
951
- return;
952
- }
953
- const packages = JSON.parse(result.stdout);
954
- const res = packages.map(
955
- (pkg) => ({
956
- name: pkg.name,
957
- description: pkg.description,
958
- url: `https://npm.im/${pkg.name}`
959
- })
960
- );
961
- resolve(res);
962
- });
963
- }
964
-
965
- // src/node.ts
966
- function pathChange(path) {
967
- return path.replace(/\\/g, "/");
968
- }
969
935
  export {
970
936
  defaultHandleStrategy,
971
937
  definePromiseTasks,
972
938
  executePromiseTasks,
973
939
  generateSimpleAsyncTask,
974
940
  getRouteName,
975
- getRuanCatPkgInfo,
976
941
  initFlag,
977
942
  isConditionsEvery,
978
943
  isConditionsSome,
979
- pathChange,
980
944
  rmmvClassExpandTools,
981
945
  runPromiseByConcurrency,
982
946
  runPromiseByQueue,