@leexi/shared 0.6.0 → 0.7.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.
package/README.md CHANGED
@@ -211,9 +211,16 @@ console.log(sum); // Output: 3
211
211
  ```
212
212
 
213
213
  #### uniq
214
+ Returns a new array by removing duplicate values in self.
214
215
  - Type
215
216
  ```ts
217
+ const uniq: (primitives: Primitive[]) => Primitive[];
218
+ ```
219
+ - Example
220
+ ```ts
221
+ const uniq = uniq([true, true, false, 1, 1, 2, 'foo', 'foo', 'bar'])
216
222
 
223
+ console.log(uniq); // Output: [true, false, 1, 2, 'foo', 'bar']
217
224
  ```
218
225
 
219
226
  #### uniqBy
@@ -258,7 +265,7 @@ console.log(originalObject.e === duplicatedObject.e); // Output: false
258
265
 
259
266
  #### isSame
260
267
  Checks if two objects are the same by comparing their JSON stringified representations.
261
- Note: This method has limitations and may not accurately compare objects with different key orders, non-primitive values like functions or Dates, or circular references.
268
+ Note: This method has limitations and may not accurately compare objects with different key orders, complex values like functions or Dates, or circular references.
262
269
  - Type
263
270
  ```ts
264
271
  const isSame: (a: object, b: object) => boolean;
@@ -32,6 +32,11 @@ const config = [
32
32
  destructuredArrayIgnorePattern: "^_",
33
33
  ignoreRestSiblings: true
34
34
  }],
35
+ "padding-line-between-statements": [
36
+ "error",
37
+ { blankLine: "always", next: "*", prev: "if" },
38
+ { blankLine: "any", next: "if", prev: "if" }
39
+ ],
35
40
  "prefer-const": ["error", {
36
41
  destructuring: "all"
37
42
  }],
@@ -15,7 +15,6 @@ const config = [
15
15
  },
16
16
  rules: {
17
17
  "@stylistic/indent": "off",
18
- "@stylistic/object-curly-spacing": "off",
19
18
  "tailwindcss/no-custom-classname": "error",
20
19
  "vue/array-bracket-spacing": ["error", "never"],
21
20
  "vue/arrow-spacing": "error",
package/dist/module.d.mts CHANGED
@@ -1,11 +1,9 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
 
3
3
  declare const _default: _nuxt_schema.NuxtModule<{
4
- composables: boolean;
5
- utils: boolean;
4
+ iconDir: string;
6
5
  }, {
7
- composables: boolean;
8
- utils: boolean;
6
+ iconDir: string;
9
7
  }, false>;
10
8
 
11
9
  export { _default as default };
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "configKey": "leexi",
3
3
  "name": "@leexi/shared",
4
- "version": "0.6.0",
4
+ "version": "0.7.1",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -1,17 +1,17 @@
1
- import { readdirSync, statSync } from 'fs';
2
- import { defineNuxtModule, createResolver, addImports } from '@nuxt/kit';
1
+ import { existsSync, readdirSync, statSync } from 'fs';
2
+ import { defineNuxtModule, createResolver, addTypeTemplate, updateTemplates, addImports } from '@nuxt/kit';
3
3
 
4
4
  const module = defineNuxtModule({
5
5
  defaults: {
6
- composables: true,
7
- utils: true
6
+ iconDir: "app/assets/images/icons"
8
7
  },
9
8
  meta: {
10
9
  configKey: "leexi",
11
10
  name: "@leexi/shared"
12
11
  },
13
- setup: (options) => {
12
+ setup: (options, nuxt) => {
14
13
  const resolver = createResolver(import.meta.url);
14
+ const rootResolver = createResolver(nuxt.options.rootDir);
15
15
  const addImportsDir = (dir) => {
16
16
  const files = readdirSync(dir);
17
17
  files.forEach((file) => {
@@ -27,12 +27,32 @@ const module = defineNuxtModule({
27
27
  addImports({ as: name, from: path, name });
28
28
  });
29
29
  };
30
- if (options.composables) {
31
- addImportsDir(resolver.resolve("./runtime/composables"));
32
- }
33
- if (options.utils) {
34
- addImportsDir(resolver.resolve("./runtime/utils"));
30
+ addImportsDir(resolver.resolve("./runtime/composables"));
31
+ addImportsDir(resolver.resolve("./runtime/utils"));
32
+ const iconDir = rootResolver.resolve(options.iconDir);
33
+ if (!existsSync(iconDir)) {
34
+ return;
35
35
  }
36
+ addTypeTemplate({
37
+ filename: "types/leexi-shared.d.ts",
38
+ getContents: () => {
39
+ const icons = readdirSync(iconDir).map((filename) => filename.replace(".svg", ""));
40
+ return [
41
+ "// Generated by @leexi/shared",
42
+ "",
43
+ "declare module '@leexi/shared' {",
44
+ ` export type IconName = ${icons.map((icon) => `'${icon}'`).join(" | ")}`,
45
+ "}",
46
+ "",
47
+ "export {}"
48
+ ].join("\n");
49
+ }
50
+ });
51
+ nuxt.hook("builder:watch", (event, path) => {
52
+ if (["add", "unlink"].includes(event) && path.includes(options.iconDir)) {
53
+ updateTemplates({ filter: ({ filename }) => filename === "types/leexi-shared.d.ts" });
54
+ }
55
+ });
36
56
  }
37
57
  });
38
58
 
@@ -1 +1,13 @@
1
- export function uniq(values: any): any[];
1
+ import type { Primitive } from '~/types';
2
+ /**
3
+ * Returns a new array by removing duplicate values in self.
4
+ *
5
+ * @param primitives An array of boolean, number and/or string.
6
+ * @returns The filtered array of primitives.
7
+ *
8
+ * @example
9
+ * const uniq = uniq([true, true, false, 1, 1, 2, 'foo', 'foo', 'bar'])
10
+ *
11
+ * console.log(uniq); // Output: [true, false, 1, 2, 'foo', 'bar']
12
+ */
13
+ export declare const uniq: (primitives: Primitive[]) => Primitive[];
@@ -1 +1 @@
1
- export const uniq = values => [...new Set(values || [])];
1
+ export const uniq = (primitives) => [...new Set(primitives || [])];
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Checks if two objects are the same by comparing their JSON stringified representations.
3
- * Note: This method has limitations and may not accurately compare objects with different key orders, non-primitive values like functions or Dates, or circular references.
3
+ * Note: This method has limitations and may not accurately compare objects with different key orders, complex values like functions or Dates, or circular references.
4
4
  *
5
5
  * @param a The first object to compare.
6
6
  * @param b The second object to compare.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "license": "UNLICENSED",
3
3
  "name": "@leexi/shared",
4
4
  "type": "module",
5
- "version": "0.6.0",
5
+ "version": "0.7.1",
6
6
  "exports": {
7
7
  "./composables": {
8
8
  "import": "./dist/runtime/composables/index.js",
@@ -46,25 +46,25 @@
46
46
  "tsc": "vue-tsc --noEmit"
47
47
  },
48
48
  "dependencies": {
49
- "@stylistic/eslint-plugin": "^5.4.0",
49
+ "@stylistic/eslint-plugin": "^5.5.0",
50
50
  "@types/eslint-plugin-tailwindcss": "^3.17.0",
51
- "eslint": "^9.36.0",
51
+ "eslint": "^9.39.0",
52
52
  "eslint-plugin-sort-keys-plus": "^1.5.0",
53
53
  "eslint-plugin-tailwindcss": "^3.18.2",
54
- "eslint-plugin-vue": "^10.5.0",
55
- "globals": "^16.4.0",
54
+ "eslint-plugin-vue": "^10.5.1",
55
+ "globals": "^16.5.0",
56
56
  "typescript": "^5.9.3",
57
- "typescript-eslint": "^8.45.0",
57
+ "typescript-eslint": "^8.46.2",
58
58
  "vue-eslint-parser": "^10.2.0"
59
59
  },
60
60
  "devDependencies": {
61
61
  "@nuxt/module-builder": "^1.0.2",
62
- "@nuxt/test-utils": "^3.19.2",
62
+ "@nuxt/test-utils": "^3.20.1",
63
63
  "@types/node": "<23.0.0",
64
- "happy-dom": "^19.0.2",
65
- "nuxt": "^4.1.2",
64
+ "happy-dom": "^20.0.10",
65
+ "nuxt": "^4.2.0",
66
66
  "tailwindcss": "<4.0.0",
67
- "vitest": "^3.2.4",
68
- "vue-tsc": "^3.1.0"
67
+ "vitest": "^4.0.6",
68
+ "vue-tsc": "^3.1.3"
69
69
  }
70
70
  }