vueless 0.0.478-beta.17 → 0.0.478-beta.19
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/constants.js +3 -0
- package/package.json +3 -3
- package/ui.image-icon/UIcon.vue +1 -1
- package/ui.image-icon/storybook/Docs.mdx +1 -1
- package/ui.image-icon/useAttrs.js +1 -1
- package/utils/node/helper.js +26 -5
- package/utils/node/loaderIcon.js +33 -43
- package/utils/node/mergeConfigs.js +1 -1
- package/utils/node/vuelessConfig.js +7 -5
- package/utils/storybook.ts +4 -1
- package/vite.d.ts +10 -0
- package/vite.js +2 -2
- package/web-types.json +10785 -0
- package/assets/icons/sentiment_satisfied.svg +0 -1
- /package/ui.image-icon/{config.js → config.ts} +0 -0
package/constants.js
CHANGED
|
@@ -190,3 +190,6 @@ export const PX_IN_REM = 16;
|
|
|
190
190
|
export const NESTED_COMPONENT_REG_EXP = /\{U[^}]*}/g;
|
|
191
191
|
export const DYNAMIC_COLOR_PATTERN = "{color}";
|
|
192
192
|
export const TAILWIND_CLASS_DELIMITER = ":";
|
|
193
|
+
export const CACHE_PATH = "node_modules/.cache/vueless";
|
|
194
|
+
export const WEB_TYPES_FILE_NAME_WITH_EXT = "web-types.json";
|
|
195
|
+
export const VUELESS_CONFIG_FILE_NAME = "vueless.config";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vueless",
|
|
3
|
-
"version": "0.0.478-beta.
|
|
3
|
+
"version": "0.0.478-beta.19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Vue Styleless UI Component Library, powered by Tailwind CSS.",
|
|
6
6
|
"keywords": [
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"build": "npx @vueless/web-types && node .scripts/icons && storybook build --docs",
|
|
33
33
|
"preview": "vite preview --host --outDir=storybook-static",
|
|
34
34
|
"ts:check": "vue-tsc --build --force",
|
|
35
|
-
"release:prepare": "node .scripts/icons && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE README.md dist/ && node .scripts/package",
|
|
35
|
+
"release:prepare": "npx @vueless/web-types && node .scripts/icons && rm -rf dist && mkdir -p dist && cp -r src/. package.json LICENSE README.md node_modules/.cache/vueless/web-types.json dist/ && node .scripts/package",
|
|
36
36
|
"release:beta": "release-it --ci --npm.publish --preRelease=beta --increment=prerelease",
|
|
37
37
|
"release:patch": "release-it patch --ci --npm.publish",
|
|
38
38
|
"release:minor": "release-it minor --ci --npm.publish --git.tag --github.release",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"@vue/eslint-config-typescript": "^14.1.1",
|
|
67
67
|
"@vue/tsconfig": "^0.5.1",
|
|
68
68
|
"@vueless/storybook": "^0.0.37",
|
|
69
|
-
"@vueless/web-types": "^0.0.
|
|
69
|
+
"@vueless/web-types": "^0.0.20",
|
|
70
70
|
"autoprefixer": "^10.4.19",
|
|
71
71
|
"cssnano": "^6.1.2",
|
|
72
72
|
"eslint": "^9.12.0",
|
package/ui.image-icon/UIcon.vue
CHANGED
|
@@ -15,7 +15,7 @@ import { getDefault } from "../utils/ui.ts";
|
|
|
15
15
|
import { isSSR } from "../utils/helper.ts";
|
|
16
16
|
|
|
17
17
|
import { UIcon } from "./constants.js";
|
|
18
|
-
import defaultConfig from "./config.
|
|
18
|
+
import defaultConfig from "./config.ts";
|
|
19
19
|
import useAttrs from "./useAttrs.js";
|
|
20
20
|
|
|
21
21
|
import { vTooltip } from "../directives";
|
|
@@ -2,7 +2,7 @@ import { Meta, Title, Subtitle, Description, Primary, Controls, Stories, Source
|
|
|
2
2
|
import { getSource } from "../../utils/storybook.ts";
|
|
3
3
|
|
|
4
4
|
import * as stories from "./stories.js";
|
|
5
|
-
import defaultConfig from "../config.
|
|
5
|
+
import defaultConfig from "../config.ts?raw"
|
|
6
6
|
|
|
7
7
|
<Meta of={stories} />
|
|
8
8
|
<Title of={stories} />
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import useUI from "../composables/useUI.ts";
|
|
2
2
|
|
|
3
|
-
import defaultConfig from "./config.
|
|
3
|
+
import defaultConfig from "./config.ts";
|
|
4
4
|
|
|
5
5
|
export default function useAttrs(props) {
|
|
6
6
|
const { config, getKeysAttrs, hasSlotContent } = useUI(defaultConfig, () => props.config);
|
package/utils/node/helper.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import fs, { statSync } from "fs";
|
|
3
3
|
import { readdir } from "node:fs/promises";
|
|
4
|
+
import { CACHE_PATH, WEB_TYPES_FILE_NAME_WITH_EXT } from "../../constants.js";
|
|
4
5
|
|
|
5
|
-
export function addWebTypesToPackageJson(env) {
|
|
6
|
-
if (env === "vueless") return;
|
|
6
|
+
export function addWebTypesToPackageJson({ env, debug, noWebTypesInPackageJson } = {}) {
|
|
7
|
+
if (env === "vueless" || noWebTypesInPackageJson) return;
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const projectWebTypesPath = path.join(process.cwd(), CACHE_PATH, WEB_TYPES_FILE_NAME_WITH_EXT);
|
|
10
|
+
|
|
11
|
+
const webTypesPath = fs.existsSync(projectWebTypesPath)
|
|
12
|
+
? `./${CACHE_PATH}/${WEB_TYPES_FILE_NAME_WITH_EXT}`
|
|
13
|
+
: `./node_modules/vueless/${WEB_TYPES_FILE_NAME_WITH_EXT}`;
|
|
11
14
|
|
|
12
15
|
try {
|
|
13
16
|
const packageJsonPath = path.resolve(process.cwd(), "package.json");
|
|
@@ -17,6 +20,11 @@ export function addWebTypesToPackageJson(env) {
|
|
|
17
20
|
packageJson["web-types"] = webTypesPath;
|
|
18
21
|
|
|
19
22
|
fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2) + "\n", "utf8");
|
|
23
|
+
|
|
24
|
+
if (debug) {
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
console.error("Web-types added to project package.json", webTypesPath);
|
|
27
|
+
}
|
|
20
28
|
} catch (error) {
|
|
21
29
|
// eslint-disable-next-line no-console
|
|
22
30
|
console.error("Error:", error);
|
|
@@ -84,3 +92,16 @@ export function getDefaultConfigJson(fileContents) {
|
|
|
84
92
|
// indirect eval
|
|
85
93
|
return (0, eval)("(" + objectString + ")"); // Converting into JS object
|
|
86
94
|
}
|
|
95
|
+
|
|
96
|
+
export function merge(source, target) {
|
|
97
|
+
for (const [key, val] of Object.entries(source)) {
|
|
98
|
+
if (val !== null && typeof val === `object`) {
|
|
99
|
+
target[key] ??= new val.__proto__.constructor();
|
|
100
|
+
merge(val, target[key]);
|
|
101
|
+
} else {
|
|
102
|
+
target[key] = val;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return target; // we're replacing in-situ, so this is more for chaining than anything else
|
|
107
|
+
}
|
package/utils/node/loaderIcon.js
CHANGED
|
@@ -14,21 +14,23 @@ import { createRequire } from "module";
|
|
|
14
14
|
import { rm, cp } from "node:fs/promises";
|
|
15
15
|
|
|
16
16
|
import { vuelessConfig } from "./vuelessConfig.js";
|
|
17
|
-
import { getDirFiles, getDefaultConfigJson } from "./helper.js";
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const
|
|
17
|
+
import { getDirFiles, getDefaultConfigJson, merge } from "./helper.js";
|
|
18
|
+
import { CACHE_PATH, VUELESS_CONFIG_FILE_NAME } from "../../constants.js";
|
|
19
|
+
|
|
20
|
+
const ICONS_DIR = "assets/icons";
|
|
21
|
+
const NUXT_ASSETS_DIR = path.join(process.cwd(), "assets/.vueless/icons");
|
|
22
|
+
const DEFAULT_ICONS_DIR = path.join(process.cwd(), `src/${ICONS_DIR}`);
|
|
23
|
+
const CACHED_ICONS_DIR = path.join(process.cwd(), `${CACHE_PATH}/${ICONS_DIR}`);
|
|
24
|
+
const ICON_CONFIG_PATH = "ui.image-icon/config.ts";
|
|
24
25
|
const ICON_COMPONENT_NAME = "UIcon";
|
|
26
|
+
const STORYBOOK_STORY_EXTENSIONS = ["/stories.js", "/stories.ts"];
|
|
25
27
|
|
|
26
28
|
let isDebug = false;
|
|
27
29
|
let isVuelessEnv = false;
|
|
28
30
|
let isDefaultMode = false;
|
|
29
31
|
let isStorybookMode = false;
|
|
30
32
|
let isVuelessIconsMode = false;
|
|
31
|
-
let
|
|
33
|
+
let cachedIconsDir = CACHED_ICONS_DIR;
|
|
32
34
|
|
|
33
35
|
// perform icons copy magick... ✨
|
|
34
36
|
export async function copyIcons({ mode = "", env, debug, targetFiles = [], isNuxt } = {}) {
|
|
@@ -38,49 +40,50 @@ export async function copyIcons({ mode = "", env, debug, targetFiles = [], isNux
|
|
|
38
40
|
isStorybookMode = mode === "storybook";
|
|
39
41
|
isVuelessIconsMode = mode === "vuelessIcons";
|
|
40
42
|
|
|
41
|
-
if (isVuelessIconsMode && isVuelessEnv)
|
|
42
|
-
if (isStorybookMode && isVuelessEnv)
|
|
43
|
+
if (isVuelessIconsMode && isVuelessEnv) cachedIconsDir = DEFAULT_ICONS_DIR;
|
|
44
|
+
if (isStorybookMode && isVuelessEnv) cachedIconsDir = CACHED_ICONS_DIR;
|
|
43
45
|
|
|
44
46
|
if (isStorybookMode) {
|
|
45
|
-
const
|
|
47
|
+
const storybookStoriesJs = await getDirFiles("src", STORYBOOK_STORY_EXTENSIONS[0]);
|
|
48
|
+
const storybookStoriesTs = await getDirFiles("src", STORYBOOK_STORY_EXTENSIONS[1]);
|
|
46
49
|
|
|
47
|
-
findAndCopyIcons(
|
|
50
|
+
findAndCopyIcons([...storybookStoriesJs.flat(), ...storybookStoriesTs.flat()]);
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
if (isVuelessIconsMode || isDefaultMode || isStorybookMode) {
|
|
51
54
|
const vueFiles = targetFiles.map((componentPath) => getDirFiles(componentPath, ".vue"));
|
|
52
55
|
|
|
53
56
|
const jsFiles = targetFiles.map((jsFilePath) =>
|
|
54
|
-
getDirFiles(jsFilePath, ".js", { exclude: [
|
|
57
|
+
getDirFiles(jsFilePath, ".js", { exclude: [STORYBOOK_STORY_EXTENSIONS[0]] }),
|
|
55
58
|
);
|
|
56
59
|
|
|
57
60
|
const tsFiles = targetFiles.map((tsFilePath) =>
|
|
58
|
-
getDirFiles(tsFilePath, ".ts", { exclude: [
|
|
61
|
+
getDirFiles(tsFilePath, ".ts", { exclude: [STORYBOOK_STORY_EXTENSIONS[1], ".d.ts"] }),
|
|
59
62
|
);
|
|
60
63
|
|
|
61
64
|
const iconFiles = await Promise.all([...vueFiles, ...jsFiles, ...tsFiles]);
|
|
62
65
|
|
|
63
|
-
findAndCopyIcons([
|
|
66
|
+
findAndCopyIcons([
|
|
67
|
+
...iconFiles.flat(),
|
|
68
|
+
`${VUELESS_CONFIG_FILE_NAME}.js`,
|
|
69
|
+
`${VUELESS_CONFIG_FILE_NAME}.ts`,
|
|
70
|
+
]);
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
if (isNuxt) {
|
|
67
|
-
await cp(
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{
|
|
71
|
-
recursive: true,
|
|
72
|
-
},
|
|
73
|
-
);
|
|
74
|
+
await cp(CACHED_ICONS_DIR, NUXT_ASSETS_DIR, {
|
|
75
|
+
recursive: true,
|
|
76
|
+
});
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
|
|
77
80
|
export async function removeIcons({ debug, isNuxt }) {
|
|
78
|
-
if (!fs.existsSync(
|
|
81
|
+
if (!fs.existsSync(cachedIconsDir)) return;
|
|
79
82
|
|
|
80
|
-
await rm(
|
|
83
|
+
await rm(cachedIconsDir, { recursive: true, force: true });
|
|
81
84
|
|
|
82
85
|
if (isNuxt) {
|
|
83
|
-
await rm(
|
|
86
|
+
await rm(NUXT_ASSETS_DIR, { recursive: true, force: true });
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
if (debug) {
|
|
@@ -174,19 +177,19 @@ function findAndCopyIcons(files) {
|
|
|
174
177
|
vueless: {
|
|
175
178
|
// @material-symbols icons which used across the components.
|
|
176
179
|
source: `${process.cwd()}/node_modules/${library}/svg-${weight}/${style}/${name}.svg`,
|
|
177
|
-
destination: `${
|
|
180
|
+
destination: `${cachedIconsDir}/${name}.svg`
|
|
178
181
|
},
|
|
179
182
|
"@material-symbols": {
|
|
180
183
|
source: `${process.cwd()}/node_modules/${library}/svg-${weight}/${style}/${name}.svg`,
|
|
181
|
-
destination: `${
|
|
184
|
+
destination: `${cachedIconsDir}/${library}/svg-${weight}/${style}/${name}.svg`
|
|
182
185
|
},
|
|
183
186
|
"bootstrap-icons": {
|
|
184
187
|
source: `${process.cwd()}/node_modules/${library}/icons/${name}.svg`,
|
|
185
|
-
destination: `${
|
|
188
|
+
destination: `${cachedIconsDir}/${library}/icons/${name}.svg`
|
|
186
189
|
},
|
|
187
190
|
heroicons: {
|
|
188
191
|
source: `${process.cwd()}/node_modules/${library}/24/${name.endsWith("-fill") ? "solid" : "outline"}/${name}.svg`,
|
|
189
|
-
destination: `${
|
|
192
|
+
destination: `${cachedIconsDir}/24/${style}/${name.endsWith("-fill") ? "solid" : "outline"}/${name}.svg`
|
|
190
193
|
}
|
|
191
194
|
};
|
|
192
195
|
/* eslint-enable vue/max-len, prettier/prettier */
|
|
@@ -216,7 +219,7 @@ function getSafelistIcons() {
|
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
function getMergedConfig() {
|
|
219
|
-
const defaultConfigPath = (isVuelessEnv ? "src/" : "node_modules/vueless/") +
|
|
222
|
+
const defaultConfigPath = (isVuelessEnv ? "src/" : "node_modules/vueless/") + ICON_CONFIG_PATH;
|
|
220
223
|
|
|
221
224
|
if (fs.existsSync(defaultConfigPath)) {
|
|
222
225
|
const defaultConfigFile = fs.readFileSync(defaultConfigPath).toString();
|
|
@@ -227,16 +230,3 @@ function getMergedConfig() {
|
|
|
227
230
|
return merge(globalConfig?.defaults || {}, defaultConfig.defaults);
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
|
-
|
|
231
|
-
function merge(source, target) {
|
|
232
|
-
for (const [key, val] of Object.entries(source)) {
|
|
233
|
-
if (val !== null && typeof val === `object`) {
|
|
234
|
-
target[key] ??= new val.__proto__.constructor();
|
|
235
|
-
merge(val, target[key]);
|
|
236
|
-
} else {
|
|
237
|
-
target[key] = val;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
return target; // we're replacing in-situ, so this is more for chaining than anything else
|
|
242
|
-
}
|
|
@@ -181,7 +181,7 @@ export function createMergeConfigsFunction(cx) {
|
|
|
181
181
|
: defaultConfigItem;
|
|
182
182
|
});
|
|
183
183
|
|
|
184
|
-
return [...config, ...globalConfigUniqueItems, ...propsConfigUniqueItems];
|
|
184
|
+
return [...(config || []), ...globalConfigUniqueItems, ...propsConfigUniqueItems];
|
|
185
185
|
}
|
|
186
186
|
|
|
187
187
|
return mergeConfigs;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
3
|
import esbuild from "esbuild";
|
|
4
4
|
|
|
5
|
+
import { CACHE_PATH, VUELESS_CONFIG_FILE_NAME } from "../../constants.js";
|
|
6
|
+
|
|
5
7
|
/**
|
|
6
8
|
* Load Vueless config from the project root.
|
|
7
9
|
* IIFE is used to prevent top level await issue.
|
|
@@ -9,9 +11,9 @@ import esbuild from "esbuild";
|
|
|
9
11
|
export let vuelessConfig = {};
|
|
10
12
|
|
|
11
13
|
(async () => {
|
|
12
|
-
const configPathJs = path.join(process.cwd(),
|
|
13
|
-
const configPathTs = path.join(process.cwd(),
|
|
14
|
-
const configOutPath = path.join(process.cwd(),
|
|
14
|
+
const configPathJs = path.join(process.cwd(), `${VUELESS_CONFIG_FILE_NAME}.js`);
|
|
15
|
+
const configPathTs = path.join(process.cwd(), `${VUELESS_CONFIG_FILE_NAME}.ts`);
|
|
16
|
+
const configOutPath = path.join(process.cwd(), `${CACHE_PATH}/${VUELESS_CONFIG_FILE_NAME}.mjs`);
|
|
15
17
|
|
|
16
18
|
if (!fs.existsSync(configPathJs) && !fs.existsSync(configPathTs)) {
|
|
17
19
|
vuelessConfig = {};
|
package/utils/storybook.ts
CHANGED
|
@@ -103,7 +103,10 @@ interface TableConfig {
|
|
|
103
103
|
|
|
104
104
|
/* Load Web-Types from the project root. */
|
|
105
105
|
const [webTypes]: WebTypes[] = Object.values(
|
|
106
|
-
import.meta.glob("/web-types.json", {
|
|
106
|
+
import.meta.glob("/node_modules/.cache/vueless/web-types.json", {
|
|
107
|
+
eager: true,
|
|
108
|
+
import: "default",
|
|
109
|
+
}),
|
|
107
110
|
);
|
|
108
111
|
|
|
109
112
|
const getComponentData = (componentName: string | undefined) => {
|
package/vite.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function VuelessUnpluginComponents(options?: unknown): import("vite").Plugin<unknown> & {
|
|
2
|
+
api: import("unplugin-vue-components/types.js").PublicPluginAPI;
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
export function Vueless(options?: {
|
|
6
|
+
env?: string;
|
|
7
|
+
mode?: string;
|
|
8
|
+
debug?: boolean;
|
|
9
|
+
include?: string[];
|
|
10
|
+
}): never;
|
package/vite.js
CHANGED
|
@@ -25,7 +25,7 @@ export const VuelessUnpluginComponents = (options) =>
|
|
|
25
25
|
– Loads SVG images as a Vue components.
|
|
26
26
|
*/
|
|
27
27
|
export const Vueless = function (options = {}) {
|
|
28
|
-
const { mode, debug, env, include } = options;
|
|
28
|
+
const { mode, debug, env, include, noWebTypesInPackageJson } = options;
|
|
29
29
|
|
|
30
30
|
const isNuxt = mode === "nuxt-module";
|
|
31
31
|
const srcDir = isNuxt ? process.cwd() : getVueSourceFile();
|
|
@@ -74,7 +74,7 @@ export const Vueless = function (options = {}) {
|
|
|
74
74
|
await removeIcons({ debug, isNuxt });
|
|
75
75
|
|
|
76
76
|
/* add web-types config to the package.json */
|
|
77
|
-
addWebTypesToPackageJson(env, debug);
|
|
77
|
+
addWebTypesToPackageJson({ env, debug, noWebTypesInPackageJson });
|
|
78
78
|
}
|
|
79
79
|
},
|
|
80
80
|
|