v-auto-color 1.0.2 → 1.0.4
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/dist/chunk-465SVM6G.mjs +131 -0
- package/dist/chunk-NJGGDAAU.mjs +140 -0
- package/dist/index.js +12 -20
- package/dist/index.mjs +1 -1
- package/dist/vite-plugin.js +12 -20
- package/dist/vite-plugin.mjs +1 -1
- package/package.json +1 -1
- package/src/vite-plugin.ts +16 -26
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// src/vite-plugin.ts
|
|
6
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
7
|
+
|
|
8
|
+
// src/core/hash.ts
|
|
9
|
+
function murmurHash3(text) {
|
|
10
|
+
let h1 = 3735928559;
|
|
11
|
+
const c1 = 3432918353;
|
|
12
|
+
const c2 = 461845907;
|
|
13
|
+
const r1 = 15;
|
|
14
|
+
const r2 = 13;
|
|
15
|
+
const m = 5;
|
|
16
|
+
const n = 3864292196;
|
|
17
|
+
let i = 0;
|
|
18
|
+
const length = text.length;
|
|
19
|
+
let k1 = 0;
|
|
20
|
+
while (i < length) {
|
|
21
|
+
const char = text.charCodeAt(i++);
|
|
22
|
+
k1 = k1 << 8 | char;
|
|
23
|
+
}
|
|
24
|
+
k1 = k1 * c1 >>> 0;
|
|
25
|
+
k1 = (k1 << r1 | k1 >>> 32 - r1) >>> 0;
|
|
26
|
+
k1 = k1 * c2 >>> 0;
|
|
27
|
+
h1 ^= k1;
|
|
28
|
+
h1 = (h1 << r2 | h1 >>> 32 - r2) >>> 0;
|
|
29
|
+
h1 = h1 * m + n >>> 0;
|
|
30
|
+
h1 ^= length;
|
|
31
|
+
h1 ^= h1 >>> 16;
|
|
32
|
+
h1 = h1 * 2246822507 >>> 0;
|
|
33
|
+
h1 ^= h1 >>> 13;
|
|
34
|
+
h1 = h1 * 3266489909 >>> 0;
|
|
35
|
+
h1 ^= h1 >>> 16;
|
|
36
|
+
return h1;
|
|
37
|
+
}
|
|
38
|
+
function getTextHash(text) {
|
|
39
|
+
return murmurHash3(text);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/core/color.ts
|
|
43
|
+
var ColorGenerator = class {
|
|
44
|
+
constructor(config = {}) {
|
|
45
|
+
__publicField(this, "config");
|
|
46
|
+
this.config = {
|
|
47
|
+
category: config.category || "default",
|
|
48
|
+
hue: config.hue || [0, 360],
|
|
49
|
+
saturation: config.saturation || [70, 100],
|
|
50
|
+
lightness: config.lightness || [40, 60]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Generate color from hash value
|
|
54
|
+
generateColor(hash) {
|
|
55
|
+
const { hue, saturation, lightness } = this.config;
|
|
56
|
+
const hueRange = hue[1] - hue[0];
|
|
57
|
+
const calculatedHue = hue[0] + hash % hueRange;
|
|
58
|
+
const satRange = saturation[1] - saturation[0];
|
|
59
|
+
const calculatedSat = saturation[0] + (hash >> 8) % satRange;
|
|
60
|
+
const lightRange = lightness[1] - lightness[0];
|
|
61
|
+
const calculatedLight = lightness[0] + (hash >> 16) % lightRange;
|
|
62
|
+
return `hsl(${calculatedHue}, ${calculatedSat}%, ${calculatedLight}%)`;
|
|
63
|
+
}
|
|
64
|
+
// Get color for text (wrapper method)
|
|
65
|
+
getColor(text, hashFn) {
|
|
66
|
+
const hash = hashFn(text);
|
|
67
|
+
return this.generateColor(hash);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/vite-plugin.ts
|
|
72
|
+
function viteAutoColorPlugin() {
|
|
73
|
+
const filter = createFilter(["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.vue"]);
|
|
74
|
+
return {
|
|
75
|
+
name: "v-auto-color",
|
|
76
|
+
// Analyze code during build and inject precomputed colors
|
|
77
|
+
transform(code, id) {
|
|
78
|
+
if (!filter(id)) return null;
|
|
79
|
+
if (!code.includes("useAutoColor")) return null;
|
|
80
|
+
const useAutoColorRegex = /useAutoColor\s*\(\s*(?:(['"])([^'"]+)\1|\{[^}]*\})\s*\)/g;
|
|
81
|
+
const getColorRegex = /\.getColor\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
82
|
+
let match;
|
|
83
|
+
const colorSets = /* @__PURE__ */ new Set();
|
|
84
|
+
while ((match = useAutoColorRegex.exec(code)) !== null) {
|
|
85
|
+
let category = "default";
|
|
86
|
+
if (match[2]) {
|
|
87
|
+
category = match[2];
|
|
88
|
+
} else {
|
|
89
|
+
const configMatch = match[0].match(/category\s*:\s*['"]([^'"]+)['"]/);
|
|
90
|
+
if (configMatch) {
|
|
91
|
+
category = configMatch[1];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
colorSets.add(category);
|
|
95
|
+
}
|
|
96
|
+
const texts = /* @__PURE__ */ new Set();
|
|
97
|
+
while ((match = getColorRegex.exec(code)) !== null) {
|
|
98
|
+
texts.add(match[1]);
|
|
99
|
+
}
|
|
100
|
+
const colorUsage = {};
|
|
101
|
+
colorSets.forEach((category) => {
|
|
102
|
+
if (!colorUsage[category]) {
|
|
103
|
+
colorUsage[category] = {};
|
|
104
|
+
}
|
|
105
|
+
texts.forEach((text) => {
|
|
106
|
+
const generator = new ColorGenerator({ category });
|
|
107
|
+
const color = generator.getColor(text, getTextHash);
|
|
108
|
+
colorUsage[category][text] = color;
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
if (Object.keys(colorUsage).length > 0) {
|
|
112
|
+
const precomputedCode = `
|
|
113
|
+
// Precomputed colors for v-auto-color
|
|
114
|
+
import { __internal__setPrecomputedColors } from 'v-auto-color';
|
|
115
|
+
__internal__setPrecomputedColors(${JSON.stringify(colorUsage, null, 2)});
|
|
116
|
+
`;
|
|
117
|
+
code = precomputedCode + "\n" + code;
|
|
118
|
+
}
|
|
119
|
+
return code;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
var vite_plugin_default = viteAutoColorPlugin;
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
__publicField,
|
|
127
|
+
getTextHash,
|
|
128
|
+
ColorGenerator,
|
|
129
|
+
viteAutoColorPlugin,
|
|
130
|
+
vite_plugin_default
|
|
131
|
+
};
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
|
+
|
|
5
|
+
// src/vite-plugin.ts
|
|
6
|
+
import { createFilter } from "@rollup/pluginutils";
|
|
7
|
+
|
|
8
|
+
// src/core/hash.ts
|
|
9
|
+
function murmurHash3(text) {
|
|
10
|
+
let h1 = 3735928559;
|
|
11
|
+
const c1 = 3432918353;
|
|
12
|
+
const c2 = 461845907;
|
|
13
|
+
const r1 = 15;
|
|
14
|
+
const r2 = 13;
|
|
15
|
+
const m = 5;
|
|
16
|
+
const n = 3864292196;
|
|
17
|
+
let i = 0;
|
|
18
|
+
const length = text.length;
|
|
19
|
+
let k1 = 0;
|
|
20
|
+
while (i < length) {
|
|
21
|
+
const char = text.charCodeAt(i++);
|
|
22
|
+
k1 = k1 << 8 | char;
|
|
23
|
+
}
|
|
24
|
+
k1 = k1 * c1 >>> 0;
|
|
25
|
+
k1 = (k1 << r1 | k1 >>> 32 - r1) >>> 0;
|
|
26
|
+
k1 = k1 * c2 >>> 0;
|
|
27
|
+
h1 ^= k1;
|
|
28
|
+
h1 = (h1 << r2 | h1 >>> 32 - r2) >>> 0;
|
|
29
|
+
h1 = h1 * m + n >>> 0;
|
|
30
|
+
h1 ^= length;
|
|
31
|
+
h1 ^= h1 >>> 16;
|
|
32
|
+
h1 = h1 * 2246822507 >>> 0;
|
|
33
|
+
h1 ^= h1 >>> 13;
|
|
34
|
+
h1 = h1 * 3266489909 >>> 0;
|
|
35
|
+
h1 ^= h1 >>> 16;
|
|
36
|
+
return h1;
|
|
37
|
+
}
|
|
38
|
+
function getTextHash(text) {
|
|
39
|
+
return murmurHash3(text);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// src/core/color.ts
|
|
43
|
+
var ColorGenerator = class {
|
|
44
|
+
constructor(config = {}) {
|
|
45
|
+
__publicField(this, "config");
|
|
46
|
+
this.config = {
|
|
47
|
+
category: config.category || "default",
|
|
48
|
+
hue: config.hue || [0, 360],
|
|
49
|
+
saturation: config.saturation || [70, 100],
|
|
50
|
+
lightness: config.lightness || [40, 60]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
// Generate color from hash value
|
|
54
|
+
generateColor(hash) {
|
|
55
|
+
const { hue, saturation, lightness } = this.config;
|
|
56
|
+
const hueRange = hue[1] - hue[0];
|
|
57
|
+
const calculatedHue = hue[0] + hash % hueRange;
|
|
58
|
+
const satRange = saturation[1] - saturation[0];
|
|
59
|
+
const calculatedSat = saturation[0] + (hash >> 8) % satRange;
|
|
60
|
+
const lightRange = lightness[1] - lightness[0];
|
|
61
|
+
const calculatedLight = lightness[0] + (hash >> 16) % lightRange;
|
|
62
|
+
return `hsl(${calculatedHue}, ${calculatedSat}%, ${calculatedLight}%)`;
|
|
63
|
+
}
|
|
64
|
+
// Get color for text (wrapper method)
|
|
65
|
+
getColor(text, hashFn) {
|
|
66
|
+
const hash = hashFn(text);
|
|
67
|
+
return this.generateColor(hash);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
// src/vite-plugin.ts
|
|
72
|
+
function viteAutoColorPlugin() {
|
|
73
|
+
const filter = createFilter(["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.vue"]);
|
|
74
|
+
const colorUsage = {};
|
|
75
|
+
return {
|
|
76
|
+
name: "v-auto-color",
|
|
77
|
+
// Analyze code during build
|
|
78
|
+
transform(code, id) {
|
|
79
|
+
if (!filter(id)) return null;
|
|
80
|
+
const useAutoColorRegex = /useAutoColor\s*\(\s*(?:(['"])([^'"]+)\1|\{[^}]*\})\s*\)/g;
|
|
81
|
+
const getColorRegex = /\.getColor\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
82
|
+
let match;
|
|
83
|
+
const colorSets = /* @__PURE__ */ new Set();
|
|
84
|
+
while ((match = useAutoColorRegex.exec(code)) !== null) {
|
|
85
|
+
let category = "default";
|
|
86
|
+
if (match[2]) {
|
|
87
|
+
category = match[2];
|
|
88
|
+
} else {
|
|
89
|
+
const configMatch = match[0].match(/category\s*:\s*['"]([^'"]+)['"]/);
|
|
90
|
+
if (configMatch) {
|
|
91
|
+
category = configMatch[1];
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
colorSets.add(category);
|
|
95
|
+
}
|
|
96
|
+
const texts = /* @__PURE__ */ new Set();
|
|
97
|
+
while ((match = getColorRegex.exec(code)) !== null) {
|
|
98
|
+
texts.add(match[1]);
|
|
99
|
+
}
|
|
100
|
+
colorSets.forEach((category) => {
|
|
101
|
+
if (!colorUsage[category]) {
|
|
102
|
+
colorUsage[category] = {};
|
|
103
|
+
}
|
|
104
|
+
texts.forEach((text) => {
|
|
105
|
+
const generator = new ColorGenerator({ category });
|
|
106
|
+
const color = generator.getColor(text, getTextHash);
|
|
107
|
+
colorUsage[category][text] = color;
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
return null;
|
|
111
|
+
},
|
|
112
|
+
// Generate precomputed colors module
|
|
113
|
+
generateBundle() {
|
|
114
|
+
const precomputedCode = `
|
|
115
|
+
import { __internal__setPrecomputedColors } from 'v-auto-color';
|
|
116
|
+
__internal__setPrecomputedColors(${JSON.stringify(colorUsage, null, 2)});
|
|
117
|
+
`;
|
|
118
|
+
this.emitFile({
|
|
119
|
+
type: "asset",
|
|
120
|
+
fileName: "v-auto-color-precomputed.js",
|
|
121
|
+
source: precomputedCode
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
// Inject precomputed colors into HTML
|
|
125
|
+
transformIndexHtml(html) {
|
|
126
|
+
return html.replace("</head>", `
|
|
127
|
+
<script type="module" src="/v-auto-color-precomputed.js"></script>
|
|
128
|
+
</head>`);
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
var vite_plugin_default = viteAutoColorPlugin;
|
|
133
|
+
|
|
134
|
+
export {
|
|
135
|
+
__publicField,
|
|
136
|
+
getTextHash,
|
|
137
|
+
ColorGenerator,
|
|
138
|
+
viteAutoColorPlugin,
|
|
139
|
+
vite_plugin_default
|
|
140
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -96,12 +96,12 @@ var ColorGenerator = class {
|
|
|
96
96
|
var import_pluginutils = require("@rollup/pluginutils");
|
|
97
97
|
function viteAutoColorPlugin() {
|
|
98
98
|
const filter = (0, import_pluginutils.createFilter)(["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.vue"]);
|
|
99
|
-
const colorUsage = {};
|
|
100
99
|
return {
|
|
101
100
|
name: "v-auto-color",
|
|
102
|
-
// Analyze code during build
|
|
101
|
+
// Analyze code during build and inject precomputed colors
|
|
103
102
|
transform(code, id) {
|
|
104
103
|
if (!filter(id)) return null;
|
|
104
|
+
if (!code.includes("useAutoColor")) return null;
|
|
105
105
|
const useAutoColorRegex = /useAutoColor\s*\(\s*(?:(['"])([^'"]+)\1|\{[^}]*\})\s*\)/g;
|
|
106
106
|
const getColorRegex = /\.getColor\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
107
107
|
let match;
|
|
@@ -122,6 +122,7 @@ function viteAutoColorPlugin() {
|
|
|
122
122
|
while ((match = getColorRegex.exec(code)) !== null) {
|
|
123
123
|
texts.add(match[1]);
|
|
124
124
|
}
|
|
125
|
+
const colorUsage = {};
|
|
125
126
|
colorSets.forEach((category) => {
|
|
126
127
|
if (!colorUsage[category]) {
|
|
127
128
|
colorUsage[category] = {};
|
|
@@ -132,24 +133,15 @@ function viteAutoColorPlugin() {
|
|
|
132
133
|
colorUsage[category][text] = color;
|
|
133
134
|
});
|
|
134
135
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
type: "asset",
|
|
145
|
-
fileName: "v-auto-color-precomputed.js",
|
|
146
|
-
source: precomputedCode
|
|
147
|
-
});
|
|
148
|
-
this.emitFile({
|
|
149
|
-
type: "asset",
|
|
150
|
-
fileName: "v-auto-color-initializer.js",
|
|
151
|
-
source: `import "/v-auto-color-precomputed.js";`
|
|
152
|
-
});
|
|
136
|
+
if (Object.keys(colorUsage).length > 0) {
|
|
137
|
+
const precomputedCode = `
|
|
138
|
+
// Precomputed colors for v-auto-color
|
|
139
|
+
import { __internal__setPrecomputedColors } from 'v-auto-color';
|
|
140
|
+
__internal__setPrecomputedColors(${JSON.stringify(colorUsage, null, 2)});
|
|
141
|
+
`;
|
|
142
|
+
code = precomputedCode + "\n" + code;
|
|
143
|
+
}
|
|
144
|
+
return code;
|
|
153
145
|
}
|
|
154
146
|
};
|
|
155
147
|
}
|
package/dist/index.mjs
CHANGED
package/dist/vite-plugin.js
CHANGED
|
@@ -94,12 +94,12 @@ var ColorGenerator = class {
|
|
|
94
94
|
// src/vite-plugin.ts
|
|
95
95
|
function viteAutoColorPlugin() {
|
|
96
96
|
const filter = (0, import_pluginutils.createFilter)(["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.vue"]);
|
|
97
|
-
const colorUsage = {};
|
|
98
97
|
return {
|
|
99
98
|
name: "v-auto-color",
|
|
100
|
-
// Analyze code during build
|
|
99
|
+
// Analyze code during build and inject precomputed colors
|
|
101
100
|
transform(code, id) {
|
|
102
101
|
if (!filter(id)) return null;
|
|
102
|
+
if (!code.includes("useAutoColor")) return null;
|
|
103
103
|
const useAutoColorRegex = /useAutoColor\s*\(\s*(?:(['"])([^'"]+)\1|\{[^}]*\})\s*\)/g;
|
|
104
104
|
const getColorRegex = /\.getColor\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
105
105
|
let match;
|
|
@@ -120,6 +120,7 @@ function viteAutoColorPlugin() {
|
|
|
120
120
|
while ((match = getColorRegex.exec(code)) !== null) {
|
|
121
121
|
texts.add(match[1]);
|
|
122
122
|
}
|
|
123
|
+
const colorUsage = {};
|
|
123
124
|
colorSets.forEach((category) => {
|
|
124
125
|
if (!colorUsage[category]) {
|
|
125
126
|
colorUsage[category] = {};
|
|
@@ -130,24 +131,15 @@ function viteAutoColorPlugin() {
|
|
|
130
131
|
colorUsage[category][text] = color;
|
|
131
132
|
});
|
|
132
133
|
});
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
type: "asset",
|
|
143
|
-
fileName: "v-auto-color-precomputed.js",
|
|
144
|
-
source: precomputedCode
|
|
145
|
-
});
|
|
146
|
-
this.emitFile({
|
|
147
|
-
type: "asset",
|
|
148
|
-
fileName: "v-auto-color-initializer.js",
|
|
149
|
-
source: `import "/v-auto-color-precomputed.js";`
|
|
150
|
-
});
|
|
134
|
+
if (Object.keys(colorUsage).length > 0) {
|
|
135
|
+
const precomputedCode = `
|
|
136
|
+
// Precomputed colors for v-auto-color
|
|
137
|
+
import { __internal__setPrecomputedColors } from 'v-auto-color';
|
|
138
|
+
__internal__setPrecomputedColors(${JSON.stringify(colorUsage, null, 2)});
|
|
139
|
+
`;
|
|
140
|
+
code = precomputedCode + "\n" + code;
|
|
141
|
+
}
|
|
142
|
+
return code;
|
|
151
143
|
}
|
|
152
144
|
};
|
|
153
145
|
}
|
package/dist/vite-plugin.mjs
CHANGED
package/package.json
CHANGED
package/src/vite-plugin.ts
CHANGED
|
@@ -6,17 +6,17 @@ import { ColorGenerator } from './core/color';
|
|
|
6
6
|
// Vite plugin for precomputing colors at build time
|
|
7
7
|
export function viteAutoColorPlugin(): Plugin {
|
|
8
8
|
const filter = createFilter(['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx', '**/*.vue']);
|
|
9
|
-
|
|
10
|
-
// Collected color usage data
|
|
11
|
-
const colorUsage: Record<string, Record<string, string>> = {};
|
|
12
9
|
|
|
13
10
|
return {
|
|
14
11
|
name: 'v-auto-color',
|
|
15
12
|
|
|
16
|
-
// Analyze code during build
|
|
13
|
+
// Analyze code during build and inject precomputed colors
|
|
17
14
|
transform(code, id) {
|
|
18
15
|
if (!filter(id)) return null;
|
|
19
16
|
|
|
17
|
+
// Check if this file imports useAutoColor
|
|
18
|
+
if (!code.includes('useAutoColor')) return null;
|
|
19
|
+
|
|
20
20
|
// Extract useAutoColor calls and getColor calls
|
|
21
21
|
const useAutoColorRegex = /useAutoColor\s*\(\s*(?:(['"])([^'"]+)\1|\{[^}]*\})\s*\)/g;
|
|
22
22
|
const getColorRegex = /\.getColor\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
@@ -47,6 +47,7 @@ export function viteAutoColorPlugin(): Plugin {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
// Precompute colors for extracted texts
|
|
50
|
+
const colorUsage: Record<string, Record<string, string>> = {};
|
|
50
51
|
colorSets.forEach(category => {
|
|
51
52
|
if (!colorUsage[category]) {
|
|
52
53
|
colorUsage[category] = {};
|
|
@@ -59,30 +60,19 @@ export function viteAutoColorPlugin(): Plugin {
|
|
|
59
60
|
});
|
|
60
61
|
});
|
|
61
62
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
import { __internal__setPrecomputedColors } from 'v-auto-color';
|
|
70
|
-
__internal__setPrecomputedColors(${JSON.stringify(colorUsage, null, 2)});
|
|
71
|
-
`;
|
|
63
|
+
// Inject precomputed colors into the code
|
|
64
|
+
if (Object.keys(colorUsage).length > 0) {
|
|
65
|
+
const precomputedCode = `
|
|
66
|
+
// Precomputed colors for v-auto-color
|
|
67
|
+
import { __internal__setPrecomputedColors } from 'v-auto-color';
|
|
68
|
+
__internal__setPrecomputedColors(${JSON.stringify(colorUsage, null, 2)});
|
|
69
|
+
`;
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
fileName: 'v-auto-color-precomputed.js',
|
|
77
|
-
source: precomputedCode
|
|
78
|
-
});
|
|
71
|
+
// Add the precomputed code at the top of the file
|
|
72
|
+
code = precomputedCode + '\n' + code;
|
|
73
|
+
}
|
|
79
74
|
|
|
80
|
-
|
|
81
|
-
this.emitFile({
|
|
82
|
-
type: 'asset',
|
|
83
|
-
fileName: 'v-auto-color-initializer.js',
|
|
84
|
-
source: `import "/v-auto-color-precomputed.js";`
|
|
85
|
-
});
|
|
75
|
+
return code;
|
|
86
76
|
}
|
|
87
77
|
};
|
|
88
78
|
}
|