@leexi/shared 0.2.1 → 0.3.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 +143 -0
- package/dist/eslint/{vue.d.ts → base.eslint.config.d.ts} +62 -27
- package/dist/eslint/base.eslint.config.mjs +123 -0
- package/dist/eslint/{base.d.ts → vue.eslint.config.d.ts} +101 -5
- package/dist/eslint/vue.eslint.config.mjs +48 -0
- package/dist/module.d.mts +11 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +39 -0
- package/dist/runtime/composables/index.d.ts +1 -0
- package/dist/runtime/composables/index.js +1 -0
- package/dist/{composables → runtime/composables}/useLocalStorage.d.ts +4 -3
- package/dist/runtime/composables/useLocalStorage.js +12 -0
- package/dist/runtime/utils/index.d.ts +3 -0
- package/dist/runtime/utils/index.js +3 -0
- package/dist/{utils → runtime/utils}/objects/deepDup.d.ts +0 -3
- package/dist/runtime/utils/objects/deepDup.js +17 -0
- package/dist/runtime/utils/objects/index.js +2 -0
- package/dist/{utils → runtime/utils}/objects/isSame.d.ts +0 -4
- package/dist/runtime/utils/objects/isSame.js +1 -0
- package/dist/runtime/utils/records/index.d.ts +1 -0
- package/dist/runtime/utils/records/index.js +1 -0
- package/dist/runtime/utils/records/set.d.ts +19 -0
- package/dist/runtime/utils/records/set.js +5 -0
- package/dist/runtime/utils/strings/capitalize.d.ts +7 -0
- package/dist/runtime/utils/strings/capitalize.js +1 -0
- package/dist/runtime/utils/strings/index.d.ts +1 -0
- package/dist/runtime/utils/strings/index.js +1 -0
- package/dist/types.d.mts +7 -0
- package/package.json +33 -19
- package/dist/composables/index.d.ts +0 -1
- package/dist/composables/index.js +0 -1
- package/dist/composables/useLocalStorage.js +0 -27
- package/dist/eslint/base.js +0 -110
- package/dist/eslint/vue.js +0 -43
- package/dist/module.d.ts +0 -8
- package/dist/module.js +0 -36
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +0 -1
- package/dist/utils/objects/deepDup.js +0 -28
- package/dist/utils/objects/index.js +0 -2
- package/dist/utils/objects/isSame.js +0 -12
- /package/dist/{utils → runtime/utils}/objects/index.d.ts +0 -0
package/dist/module.json
ADDED
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { readdirSync, statSync } from 'fs';
|
|
2
|
+
import { defineNuxtModule, createResolver, addImports } from '@nuxt/kit';
|
|
3
|
+
|
|
4
|
+
const module = defineNuxtModule({
|
|
5
|
+
defaults: {
|
|
6
|
+
composables: true,
|
|
7
|
+
utils: true
|
|
8
|
+
},
|
|
9
|
+
meta: {
|
|
10
|
+
configKey: "leexi",
|
|
11
|
+
name: "@leexi/shared"
|
|
12
|
+
},
|
|
13
|
+
setup: (options) => {
|
|
14
|
+
const resolver = createResolver(import.meta.url);
|
|
15
|
+
const addImportsDir = (dir) => {
|
|
16
|
+
const files = readdirSync(dir);
|
|
17
|
+
files.forEach((file) => {
|
|
18
|
+
if (/index/.test(file) || /\.d\.ts/.test(file)) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const path = resolver.resolve(`${dir}/${file}`);
|
|
22
|
+
const stat = statSync(path);
|
|
23
|
+
if (stat.isDirectory()) {
|
|
24
|
+
return addImportsDir(path);
|
|
25
|
+
}
|
|
26
|
+
const [name] = file.split(".");
|
|
27
|
+
addImports({ as: name, from: path, name });
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
if (options.composables) {
|
|
31
|
+
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
32
|
+
}
|
|
33
|
+
if (options.utils) {
|
|
34
|
+
addImportsDir(resolver.resolve("./runtime/utils"));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
export { module as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLocalStorage } from './useLocalStorage.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useLocalStorage } from "./useLocalStorage.js";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
1
2
|
/**
|
|
2
3
|
* Creates a reactive pointer to a specific localStorage value.
|
|
3
4
|
* The value is stored in the localStorage as a JSON stringified data to enable parsing primitives and objects
|
|
4
5
|
*
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
6
|
+
* @param key - a key pointing to a localStorage value
|
|
7
|
+
* @param defaultValue - an optional default value used if the localStorage value is undefined
|
|
7
8
|
* @returns a reactive variable pointing to that localStorage value
|
|
8
9
|
*
|
|
9
10
|
* @example
|
|
@@ -12,4 +13,4 @@
|
|
|
12
13
|
* fooOne.value // => 'bar'
|
|
13
14
|
* localStorage.foo // => '"bar"'
|
|
14
15
|
*/
|
|
15
|
-
export declare const useLocalStorage: <T>(key: string, defaultValue?: T) =>
|
|
16
|
+
export declare const useLocalStorage: <T>(key: string, defaultValue?: T) => Ref<undefined | T>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useState, watch } from "#imports";
|
|
2
|
+
export const useLocalStorage = (key, defaultValue) => {
|
|
3
|
+
const data = useState(key, () => JSON.parse(localStorage?.getItem(key) || "null") || defaultValue);
|
|
4
|
+
watch(data, () => {
|
|
5
|
+
if (data.value) {
|
|
6
|
+
localStorage?.setItem(key, JSON.stringify(data.value));
|
|
7
|
+
} else {
|
|
8
|
+
localStorage?.removeItem(key);
|
|
9
|
+
}
|
|
10
|
+
}, { immediate: true });
|
|
11
|
+
return data;
|
|
12
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const deepDup = (object) => {
|
|
2
|
+
if (!object || typeof object !== "object") {
|
|
3
|
+
return object;
|
|
4
|
+
}
|
|
5
|
+
const duplicate = (value) => value && typeof value === "object" ? deepDup(value) : value;
|
|
6
|
+
if (Array.isArray(object)) {
|
|
7
|
+
return object.map(duplicate);
|
|
8
|
+
}
|
|
9
|
+
if (object instanceof Set) {
|
|
10
|
+
return new Set([...object].map(duplicate));
|
|
11
|
+
}
|
|
12
|
+
if (Object.getPrototypeOf(object) === Object.prototype) {
|
|
13
|
+
const dup = Object.entries(object).map(([key, value]) => [key, duplicate(value)]);
|
|
14
|
+
return Object.fromEntries(dup);
|
|
15
|
+
}
|
|
16
|
+
return object;
|
|
17
|
+
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Compares whether two objects are identical.
|
|
3
3
|
*
|
|
4
|
-
* @param a - an object
|
|
5
|
-
* @param b - another object
|
|
6
|
-
* @returns whether these objects are identical
|
|
7
|
-
*
|
|
8
4
|
* @example
|
|
9
5
|
* isSame([{ foo: 'bar' }], [{ foo: 'bar' }]) // => `true`
|
|
10
6
|
* isSame([{ foo: 'bar' }], [{ bar: 'foo' }]) // => `false`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isSame = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { set } from './set.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { set } from "./set.js";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
type SetRecord<T extends Record<string, unknown>, P extends readonly string[], V> = P extends [infer F extends string, ...infer R extends readonly string[]] ? T & {
|
|
2
|
+
[K in F]: R extends [] ? V : SetRecord<T[K] extends T ? T[K] : {}, R, V>;
|
|
3
|
+
} : T;
|
|
4
|
+
/**
|
|
5
|
+
* Deeply sets an attribute at a specified path within a nested object.
|
|
6
|
+
* **This method is destructive.**
|
|
7
|
+
*
|
|
8
|
+
* @param record - a record
|
|
9
|
+
* @param path - an array of strings leading to a deeply nested key in the record
|
|
10
|
+
* @param value - a value to be set at the given path
|
|
11
|
+
* @returns the mutated record
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const foo = {}
|
|
15
|
+
* set(foo, ['bar', 'biz'], 'fiz')
|
|
16
|
+
* foo // => { bar: { biz: 'fiz' } }
|
|
17
|
+
*/
|
|
18
|
+
export declare const set: <T extends Record<string, unknown>, const P extends string[], V>(record: T, path: P, value: V) => SetRecord<T, P, V>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const capitalize = (string = "") => `${string.charAt(0).toUpperCase()}${string.slice(1)}`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { capitalize } from './capitalize.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { capitalize } from "./capitalize.js";
|
package/dist/types.d.mts
ADDED
package/package.json
CHANGED
|
@@ -1,39 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
+
"license": "UNLICENSED",
|
|
2
3
|
"name": "@leexi/shared",
|
|
3
4
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"scripts": {
|
|
6
|
-
"build": "yarn lint && yarn test --reporter default && yarn tsc && tsc -p tsconfig.build.json",
|
|
7
|
-
"lint": "eslint .",
|
|
8
|
-
"test": "vitest run",
|
|
9
|
-
"tsc": "nuxt prepare && tsc"
|
|
10
|
-
},
|
|
5
|
+
"version": "0.3.1",
|
|
11
6
|
"exports": {
|
|
12
7
|
"./composables": {
|
|
13
|
-
"import": "./dist/composables/index.js",
|
|
14
|
-
"types": "./dist/composables/index.d.ts"
|
|
8
|
+
"import": "./dist/runtime/composables/index.js",
|
|
9
|
+
"types": "./dist/runtime/composables/index.d.ts"
|
|
15
10
|
},
|
|
16
11
|
"./eslint/base": {
|
|
17
|
-
"import": "./dist/eslint/base.
|
|
18
|
-
"types": "./dist/eslint/base.d.ts"
|
|
12
|
+
"import": "./dist/eslint/base.eslint.config.mjs",
|
|
13
|
+
"types": "./dist/eslint/base.eslint.config.d.ts"
|
|
19
14
|
},
|
|
20
15
|
"./eslint/vue": {
|
|
21
|
-
"import": "./dist/eslint/vue.
|
|
22
|
-
"types": "./dist/eslint/vue.d.ts"
|
|
16
|
+
"import": "./dist/eslint/vue.eslint.config.mjs",
|
|
17
|
+
"types": "./dist/eslint/vue.eslint.config.d.ts"
|
|
23
18
|
},
|
|
24
19
|
"./utils": {
|
|
25
|
-
"import": "./dist/utils/index.js",
|
|
26
|
-
"types": "./dist/utils/index.d.ts"
|
|
20
|
+
"import": "./dist/runtime/utils/index.js",
|
|
21
|
+
"types": "./dist/runtime/utils/index.d.ts"
|
|
27
22
|
},
|
|
28
23
|
".": {
|
|
29
|
-
"import": "./dist/module.
|
|
30
|
-
"types": "./dist/module.d.
|
|
24
|
+
"import": "./dist/module.mjs",
|
|
25
|
+
"types": "./dist/module.d.mts"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"main": "./dist/module.mjs",
|
|
29
|
+
"typesVersions": {
|
|
30
|
+
"*": {
|
|
31
|
+
".": [
|
|
32
|
+
"./dist/types.d.mts"
|
|
33
|
+
]
|
|
31
34
|
}
|
|
32
35
|
},
|
|
33
36
|
"files": [
|
|
34
37
|
"dist"
|
|
35
38
|
],
|
|
36
|
-
"
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "nuxt-module-build build && bun run lib/readme",
|
|
41
|
+
"dev": "nuxi dev playground",
|
|
42
|
+
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
43
|
+
"lint": "eslint .",
|
|
44
|
+
"postinstall": "yarn dev:prepare",
|
|
45
|
+
"prepack": "yarn lint && yarn test --reporter default && yarn tsc && yarn build",
|
|
46
|
+
"release": "npm publish",
|
|
47
|
+
"test": "vitest run",
|
|
48
|
+
"tsc": "vue-tsc --noEmit"
|
|
49
|
+
},
|
|
37
50
|
"dependencies": {
|
|
38
51
|
"@stylistic/eslint-plugin-js": "^4.2.0",
|
|
39
52
|
"@stylistic/eslint-plugin-ts": "^4.2.0",
|
|
@@ -46,6 +59,7 @@
|
|
|
46
59
|
"vue-eslint-parser": "^10.1.1"
|
|
47
60
|
},
|
|
48
61
|
"devDependencies": {
|
|
62
|
+
"@nuxt/module-builder": "^1.0.1",
|
|
49
63
|
"@nuxt/test-utils": "^3.17.2",
|
|
50
64
|
"@types/node": "^22.14.0",
|
|
51
65
|
"eslint": "^9.23.0",
|
|
@@ -53,7 +67,7 @@
|
|
|
53
67
|
"nuxt": "^3.16.2",
|
|
54
68
|
"tailwindcss": "<4.0.0",
|
|
55
69
|
"vitest": "^3.1.1",
|
|
56
|
-
"vue": "^
|
|
70
|
+
"vue-tsc": "^2.2.8"
|
|
57
71
|
},
|
|
58
72
|
"peerDependencies": {
|
|
59
73
|
"eslint": ">9.0.0"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useLocalStorage } from './useLocalStorage';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useLocalStorage } from './useLocalStorage';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { useState, watch } from '#imports';
|
|
2
|
-
/**
|
|
3
|
-
* Creates a reactive pointer to a specific localStorage value.
|
|
4
|
-
* The value is stored in the localStorage as a JSON stringified data to enable parsing primitives and objects
|
|
5
|
-
*
|
|
6
|
-
* @param key - a key pointing to a localStorage value
|
|
7
|
-
* @param defaultValue - an optional default value used if the localStorage value is undefined
|
|
8
|
-
* @returns a reactive variable pointing to that localStorage value
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const fooOne = useLocalStorage('foo')
|
|
12
|
-
* const fooTwo = useLocalStorage('foo', 'bar')
|
|
13
|
-
* fooOne.value // => 'bar'
|
|
14
|
-
* localStorage.foo // => '"bar"'
|
|
15
|
-
*/
|
|
16
|
-
export const useLocalStorage = (key, defaultValue) => {
|
|
17
|
-
const data = useState(key, () => JSON.parse(localStorage?.getItem(key) || 'null') || defaultValue);
|
|
18
|
-
watch(data, () => {
|
|
19
|
-
if (data.value) {
|
|
20
|
-
localStorage?.setItem(key, JSON.stringify(data.value));
|
|
21
|
-
}
|
|
22
|
-
else {
|
|
23
|
-
localStorage?.removeItem(key);
|
|
24
|
-
}
|
|
25
|
-
}, { immediate: true });
|
|
26
|
-
return data;
|
|
27
|
-
};
|
package/dist/eslint/base.js
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
import js from '@eslint/js';
|
|
2
|
-
import stylisticJS from '@stylistic/eslint-plugin-js';
|
|
3
|
-
import stylisticTS from '@stylistic/eslint-plugin-ts';
|
|
4
|
-
import globals from 'globals';
|
|
5
|
-
import tseslint from 'typescript-eslint';
|
|
6
|
-
export default [
|
|
7
|
-
js.configs.recommended,
|
|
8
|
-
...tseslint.configs.recommended,
|
|
9
|
-
// base config
|
|
10
|
-
{
|
|
11
|
-
languageOptions: {
|
|
12
|
-
globals: {
|
|
13
|
-
...globals.browser,
|
|
14
|
-
...globals.node,
|
|
15
|
-
},
|
|
16
|
-
parserOptions: {
|
|
17
|
-
ecmaVersion: 'latest',
|
|
18
|
-
sourceType: 'module',
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
plugins: {
|
|
22
|
-
'@stylistic/js': stylisticJS,
|
|
23
|
-
},
|
|
24
|
-
rules: {
|
|
25
|
-
'arrow-body-style': ['error', 'as-needed'],
|
|
26
|
-
'eqeqeq': ['error', 'smart'],
|
|
27
|
-
'no-console': 'error',
|
|
28
|
-
'no-unused-vars': ['error', {
|
|
29
|
-
argsIgnorePattern: '^_',
|
|
30
|
-
destructuredArrayIgnorePattern: '^_',
|
|
31
|
-
ignoreRestSiblings: true,
|
|
32
|
-
}],
|
|
33
|
-
'prefer-const': ['error', {
|
|
34
|
-
destructuring: 'all',
|
|
35
|
-
}],
|
|
36
|
-
'prefer-template': 'error',
|
|
37
|
-
'@stylistic/js/array-bracket-spacing': ['error', 'never'],
|
|
38
|
-
'@stylistic/js/comma-dangle': ['error', 'always-multiline'],
|
|
39
|
-
'@stylistic/js/comma-spacing': 'error',
|
|
40
|
-
'@stylistic/js/eol-last': ['error', 'always'],
|
|
41
|
-
'@stylistic/js/indent': ['error', 2, {
|
|
42
|
-
SwitchCase: 1,
|
|
43
|
-
}],
|
|
44
|
-
'@stylistic/js/key-spacing': 'error',
|
|
45
|
-
'@stylistic/js/keyword-spacing': 'error',
|
|
46
|
-
'@stylistic/js/no-multi-spaces': 'error',
|
|
47
|
-
'@stylistic/js/no-multiple-empty-lines': ['error', {
|
|
48
|
-
max: 1,
|
|
49
|
-
}],
|
|
50
|
-
'@stylistic/js/no-trailing-spaces': 'error',
|
|
51
|
-
'@stylistic/js/object-curly-spacing': ['error', 'always'],
|
|
52
|
-
'@stylistic/js/quotes': ['error', 'single'],
|
|
53
|
-
'@stylistic/js/quote-props': ['error', 'consistent-as-needed'],
|
|
54
|
-
'@stylistic/js/semi': ['error', 'always'],
|
|
55
|
-
'@stylistic/js/semi-spacing': 'error',
|
|
56
|
-
'@stylistic/js/space-before-blocks': ['error', 'always'],
|
|
57
|
-
'@stylistic/js/space-before-function-paren': ['error', 'always'],
|
|
58
|
-
'@stylistic/js/space-in-parens': ['error', 'never'],
|
|
59
|
-
'@stylistic/js/space-infix-ops': 'error',
|
|
60
|
-
'@stylistic/js/spaced-comment': 'error',
|
|
61
|
-
'@stylistic/js/template-curly-spacing': ['error', 'never'],
|
|
62
|
-
'@typescript-eslint/no-unused-expressions': 'off',
|
|
63
|
-
'@typescript-eslint/no-unused-vars': ['error', {
|
|
64
|
-
argsIgnorePattern: '^_',
|
|
65
|
-
destructuredArrayIgnorePattern: '^_',
|
|
66
|
-
ignoreRestSiblings: true,
|
|
67
|
-
}],
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
// typescript
|
|
71
|
-
{
|
|
72
|
-
files: ['**/*.ts'],
|
|
73
|
-
plugins: {
|
|
74
|
-
'@stylistic/ts': stylisticTS,
|
|
75
|
-
},
|
|
76
|
-
rules: {
|
|
77
|
-
'@stylistic/js/comma-dangle': 'off',
|
|
78
|
-
'@stylistic/js/comma-spacing': 'off',
|
|
79
|
-
'@stylistic/js/indent': 'off',
|
|
80
|
-
'@stylistic/js/key-spacing': 'off',
|
|
81
|
-
'@stylistic/js/keyword-spacing': 'off',
|
|
82
|
-
'@stylistic/js/object-curly-spacing': 'off',
|
|
83
|
-
'@stylistic/js/quotes': 'off',
|
|
84
|
-
'@stylistic/js/quote-props': 'off',
|
|
85
|
-
'@stylistic/js/semi': 'off',
|
|
86
|
-
'@stylistic/js/space-before-blocks': 'off',
|
|
87
|
-
'@stylistic/js/space-before-function-paren': 'off',
|
|
88
|
-
'@stylistic/js/space-infix-ops': 'off',
|
|
89
|
-
'@stylistic/ts/comma-dangle': ['error', 'always-multiline'],
|
|
90
|
-
'@stylistic/ts/comma-spacing': 'error',
|
|
91
|
-
'@stylistic/ts/indent': ['error', 2, {
|
|
92
|
-
SwitchCase: 1,
|
|
93
|
-
}],
|
|
94
|
-
'@stylistic/ts/key-spacing': 'error',
|
|
95
|
-
'@stylistic/ts/keyword-spacing': 'error',
|
|
96
|
-
'@stylistic/ts/object-curly-spacing': ['error', 'always'],
|
|
97
|
-
'@stylistic/ts/quotes': ['error', 'single'],
|
|
98
|
-
'@stylistic/ts/quote-props': ['error', 'consistent-as-needed'],
|
|
99
|
-
'@stylistic/ts/semi': ['error', 'always'],
|
|
100
|
-
'@stylistic/ts/space-before-blocks': ['error', 'always'],
|
|
101
|
-
'@stylistic/ts/space-before-function-paren': ['error', 'always'],
|
|
102
|
-
'@stylistic/ts/space-infix-ops': 'error',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
ignores: [
|
|
107
|
-
'node_modules/',
|
|
108
|
-
],
|
|
109
|
-
},
|
|
110
|
-
];
|
package/dist/eslint/vue.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import tailwind from 'eslint-plugin-tailwindcss';
|
|
2
|
-
import vue from 'eslint-plugin-vue';
|
|
3
|
-
import base from './base.js';
|
|
4
|
-
export default [
|
|
5
|
-
...base,
|
|
6
|
-
...tailwind.configs['flat/recommended'],
|
|
7
|
-
...vue.configs['flat/recommended'],
|
|
8
|
-
{
|
|
9
|
-
files: ['**/*.vue'],
|
|
10
|
-
rules: {
|
|
11
|
-
'@stylistic/js/indent': 'off',
|
|
12
|
-
'@stylistic/js/object-curly-spacing': 'off',
|
|
13
|
-
'tailwindcss/no-custom-classname': 'error',
|
|
14
|
-
'vue/attributes-order': ['error', {
|
|
15
|
-
alphabetical: true,
|
|
16
|
-
}],
|
|
17
|
-
'vue/component-name-in-template-casing': ['error', 'PascalCase', {
|
|
18
|
-
registeredComponentsOnly: false,
|
|
19
|
-
}],
|
|
20
|
-
'vue/first-attribute-linebreak': ['error', {
|
|
21
|
-
singleline: 'beside',
|
|
22
|
-
}],
|
|
23
|
-
'vue/multi-word-component-names': 'off',
|
|
24
|
-
'vue/no-bare-strings-in-template': ['error', {
|
|
25
|
-
allowlist: ['Leexi'],
|
|
26
|
-
}],
|
|
27
|
-
'vue/object-curly-spacing': ['error', 'always'],
|
|
28
|
-
'vue/prefer-template': 'error',
|
|
29
|
-
'vue/script-indent': ['error', 2, {
|
|
30
|
-
baseIndent: 1,
|
|
31
|
-
switchCase: 1,
|
|
32
|
-
}],
|
|
33
|
-
'vue/template-curly-spacing': ['error', 'never'],
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
ignores: [
|
|
38
|
-
'.nuxt/',
|
|
39
|
-
'.output/',
|
|
40
|
-
'dist/',
|
|
41
|
-
],
|
|
42
|
-
},
|
|
43
|
-
];
|
package/dist/module.d.ts
DELETED
package/dist/module.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { readdirSync, statSync } from 'fs';
|
|
2
|
-
import { addImports, createResolver, defineNuxtModule } from '@nuxt/kit';
|
|
3
|
-
export default defineNuxtModule({
|
|
4
|
-
defaults: {
|
|
5
|
-
composables: true,
|
|
6
|
-
utils: true,
|
|
7
|
-
},
|
|
8
|
-
meta: {
|
|
9
|
-
configKey: 'leexi',
|
|
10
|
-
name: '@leexi/shared',
|
|
11
|
-
},
|
|
12
|
-
setup: options => {
|
|
13
|
-
const resolver = createResolver(import.meta.url);
|
|
14
|
-
const addImportsDir = (dir) => {
|
|
15
|
-
const files = readdirSync(dir);
|
|
16
|
-
files.forEach(file => {
|
|
17
|
-
if (/index/.test(file) || /\.d\.ts/.test(file)) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const path = resolver.resolve(`${dir}/${file}`);
|
|
21
|
-
const stat = statSync(path);
|
|
22
|
-
if (stat.isDirectory()) {
|
|
23
|
-
return addImportsDir(path);
|
|
24
|
-
}
|
|
25
|
-
const [name] = file.split('.');
|
|
26
|
-
addImports({ as: name, from: path, name });
|
|
27
|
-
});
|
|
28
|
-
};
|
|
29
|
-
if (options.composables) {
|
|
30
|
-
addImportsDir(resolver.resolve('./composables'));
|
|
31
|
-
}
|
|
32
|
-
if (options.utils) {
|
|
33
|
-
addImportsDir(resolver.resolve('./utils'));
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
});
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './objects/index.js';
|
package/dist/utils/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './objects/index.js';
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Deeply duplicates an object.
|
|
3
|
-
*
|
|
4
|
-
* @param object - an object
|
|
5
|
-
* @returns a duplicate of the same object
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* const object = [{ foo: 'bar' }]
|
|
9
|
-
* const dup = deepDup(object) // => `[{ foo: 'bar' }]`
|
|
10
|
-
* object === dup // => `false`
|
|
11
|
-
*/
|
|
12
|
-
export const deepDup = (object) => {
|
|
13
|
-
if (!object || typeof object !== 'object') {
|
|
14
|
-
return object;
|
|
15
|
-
}
|
|
16
|
-
const duplicate = (value) => value && typeof value === 'object' ? deepDup(value) : value;
|
|
17
|
-
if (Array.isArray(object)) {
|
|
18
|
-
return object.map(duplicate);
|
|
19
|
-
}
|
|
20
|
-
if (object instanceof Set) {
|
|
21
|
-
return new Set([...object].map(duplicate));
|
|
22
|
-
}
|
|
23
|
-
if (Object.getPrototypeOf(object) === Object.prototype) {
|
|
24
|
-
const dup = Object.entries(object).map(([key, value]) => [key, duplicate(value)]);
|
|
25
|
-
return Object.fromEntries(dup);
|
|
26
|
-
}
|
|
27
|
-
return object;
|
|
28
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Compares whether two objects are identical.
|
|
3
|
-
*
|
|
4
|
-
* @param a - an object
|
|
5
|
-
* @param b - another object
|
|
6
|
-
* @returns whether these objects are identical
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* isSame([{ foo: 'bar' }], [{ foo: 'bar' }]) // => `true`
|
|
10
|
-
* isSame([{ foo: 'bar' }], [{ bar: 'foo' }]) // => `false`
|
|
11
|
-
*/
|
|
12
|
-
export const isSame = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
File without changes
|