typewritingclass-compiler 0.1.4 → 0.1.8
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-Y33BZFTH.js → chunk-IPFCUN6B.js} +8 -0
- package/dist/index.cjs +50 -35
- package/dist/{index.d-BP-BhWXf.d.cts → index.d-Bks8QAue.d.cts} +2 -0
- package/dist/{index.d-BP-BhWXf.d.ts → index.d-Bks8QAue.d.ts} +2 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +43 -36
- package/dist/loadTheme.cjs +8 -0
- package/dist/loadTheme.d.cts +1 -1
- package/dist/loadTheme.d.ts +1 -1
- package/dist/loadTheme.js +1 -1
- package/index.d.ts +2 -0
- package/index.node +0 -0
- package/package.json +5 -3
|
@@ -71,6 +71,13 @@ async function loadTheme() {
|
|
|
71
71
|
fontWeights[name] = val;
|
|
72
72
|
}
|
|
73
73
|
}
|
|
74
|
+
const fontFamiliesObj = typographyModule.fontFamilies;
|
|
75
|
+
const fontFamilies = {};
|
|
76
|
+
if (fontFamiliesObj && typeof fontFamiliesObj === "object") {
|
|
77
|
+
for (const [key, val] of Object.entries(fontFamiliesObj)) {
|
|
78
|
+
fontFamilies[key] = val;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
74
81
|
const radiusNames = ["none", "sm", "DEFAULT", "md", "lg", "xl", "_2xl", "_3xl", "full"];
|
|
75
82
|
const radii = {};
|
|
76
83
|
for (const name of radiusNames) {
|
|
@@ -101,6 +108,7 @@ async function loadTheme() {
|
|
|
101
108
|
spacing: JSON.stringify(spacing),
|
|
102
109
|
textSizes: JSON.stringify(textSizes),
|
|
103
110
|
fontWeights: JSON.stringify(fontWeights),
|
|
111
|
+
fontFamilies: JSON.stringify(fontFamilies),
|
|
104
112
|
radii: JSON.stringify(radii),
|
|
105
113
|
shadows: JSON.stringify(shadows),
|
|
106
114
|
sizes: JSON.stringify(sizes),
|
package/dist/index.cjs
CHANGED
|
@@ -119,6 +119,13 @@ async function loadTheme() {
|
|
|
119
119
|
fontWeights[name] = val;
|
|
120
120
|
}
|
|
121
121
|
}
|
|
122
|
+
const fontFamiliesObj = typographyModule.fontFamilies;
|
|
123
|
+
const fontFamilies = {};
|
|
124
|
+
if (fontFamiliesObj && typeof fontFamiliesObj === "object") {
|
|
125
|
+
for (const [key, val] of Object.entries(fontFamiliesObj)) {
|
|
126
|
+
fontFamilies[key] = val;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
122
129
|
const radiusNames = ["none", "sm", "DEFAULT", "md", "lg", "xl", "_2xl", "_3xl", "full"];
|
|
123
130
|
const radii = {};
|
|
124
131
|
for (const name of radiusNames) {
|
|
@@ -149,6 +156,7 @@ async function loadTheme() {
|
|
|
149
156
|
spacing: JSON.stringify(spacing),
|
|
150
157
|
textSizes: JSON.stringify(textSizes),
|
|
151
158
|
fontWeights: JSON.stringify(fontWeights),
|
|
159
|
+
fontFamilies: JSON.stringify(fontFamilies),
|
|
152
160
|
radii: JSON.stringify(radii),
|
|
153
161
|
shadows: JSON.stringify(shadows),
|
|
154
162
|
sizes: JSON.stringify(sizes),
|
|
@@ -167,7 +175,9 @@ var RESOLVED_VIRTUAL_CSS_ID = "\0" + VIRTUAL_CSS_ID;
|
|
|
167
175
|
function twcPlugin(options) {
|
|
168
176
|
const strict = options?.strict ?? true;
|
|
169
177
|
let themeInput;
|
|
170
|
-
let
|
|
178
|
+
let prodLayer = 0;
|
|
179
|
+
const fileLayerOffsets = /* @__PURE__ */ new Map();
|
|
180
|
+
let nextFileLayer = 0;
|
|
171
181
|
const fileRules = /* @__PURE__ */ new Map();
|
|
172
182
|
let devServer = null;
|
|
173
183
|
return {
|
|
@@ -188,38 +198,55 @@ function twcPlugin(options) {
|
|
|
188
198
|
return generateAllCss();
|
|
189
199
|
}
|
|
190
200
|
},
|
|
201
|
+
async handleHotUpdate(ctx) {
|
|
202
|
+
const { file, read, server, modules } = ctx;
|
|
203
|
+
if (!file.match(/\.[jt]sx?$/) || file.includes("node_modules")) return;
|
|
204
|
+
const code = await read();
|
|
205
|
+
if (!code.includes("typewritingclass")) return;
|
|
206
|
+
if (!fileLayerOffsets.has(file)) {
|
|
207
|
+
fileLayerOffsets.set(file, nextFileLayer);
|
|
208
|
+
nextFileLayer += 1e3;
|
|
209
|
+
}
|
|
210
|
+
const layerOffset = fileLayerOffsets.get(file);
|
|
211
|
+
try {
|
|
212
|
+
const result = native.transform(code, file, layerOffset, themeInput, strict);
|
|
213
|
+
fileRules.set(file, result.rules.map((r) => r.cssText));
|
|
214
|
+
} catch {
|
|
215
|
+
}
|
|
216
|
+
const cssMod = server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CSS_ID);
|
|
217
|
+
if (cssMod) {
|
|
218
|
+
server.moduleGraph.invalidateModule(cssMod);
|
|
219
|
+
return [...modules, cssMod];
|
|
220
|
+
}
|
|
221
|
+
return modules;
|
|
222
|
+
},
|
|
191
223
|
transform(code, id) {
|
|
192
224
|
if (!id.match(/\.[jt]sx?$/) || id.includes("node_modules")) return;
|
|
193
225
|
if (!code.includes("typewritingclass")) return;
|
|
226
|
+
let layerOffset;
|
|
227
|
+
if (devServer) {
|
|
228
|
+
if (!fileLayerOffsets.has(id)) {
|
|
229
|
+
fileLayerOffsets.set(id, nextFileLayer);
|
|
230
|
+
nextFileLayer += 1e3;
|
|
231
|
+
}
|
|
232
|
+
layerOffset = fileLayerOffsets.get(id);
|
|
233
|
+
} else {
|
|
234
|
+
layerOffset = prodLayer;
|
|
235
|
+
}
|
|
194
236
|
try {
|
|
195
|
-
const result = native.transform(code, id,
|
|
196
|
-
|
|
237
|
+
const result = native.transform(code, id, layerOffset, themeInput, strict);
|
|
238
|
+
if (!devServer) {
|
|
239
|
+
prodLayer = result.nextLayer;
|
|
240
|
+
}
|
|
197
241
|
for (const diag of result.diagnostics) {
|
|
198
242
|
if (diag.severity === "error") {
|
|
199
|
-
this.error({
|
|
200
|
-
message: diag.message,
|
|
201
|
-
id,
|
|
202
|
-
pos: diag.line
|
|
203
|
-
});
|
|
243
|
+
this.error({ message: diag.message, id, pos: diag.line });
|
|
204
244
|
} else {
|
|
205
|
-
this.warn({
|
|
206
|
-
message: diag.message,
|
|
207
|
-
id,
|
|
208
|
-
pos: diag.line
|
|
209
|
-
});
|
|
245
|
+
this.warn({ message: diag.message, id, pos: diag.line });
|
|
210
246
|
}
|
|
211
247
|
}
|
|
212
248
|
if (result.rules.length > 0) {
|
|
213
|
-
fileRules.set(
|
|
214
|
-
id,
|
|
215
|
-
result.rules.map((r) => r.cssText)
|
|
216
|
-
);
|
|
217
|
-
if (devServer) {
|
|
218
|
-
const mod = devServer.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CSS_ID);
|
|
219
|
-
if (mod) {
|
|
220
|
-
devServer.moduleGraph.invalidateModule(mod);
|
|
221
|
-
}
|
|
222
|
-
}
|
|
249
|
+
fileRules.set(id, result.rules.map((r) => r.cssText));
|
|
223
250
|
}
|
|
224
251
|
const s = new import_magic_string.default(code);
|
|
225
252
|
if (result.code !== code) {
|
|
@@ -245,9 +272,6 @@ function twcPlugin(options) {
|
|
|
245
272
|
}
|
|
246
273
|
}
|
|
247
274
|
},
|
|
248
|
-
// Production builds: inject CSS into the output after all files are
|
|
249
|
-
// transformed. This fixes the timing issue where virtual:twc.css is
|
|
250
|
-
// loaded by Rollup before component files have been processed.
|
|
251
275
|
generateBundle(_, bundle) {
|
|
252
276
|
const css = generateAllCss();
|
|
253
277
|
if (!css) return;
|
|
@@ -263,15 +287,6 @@ function twcPlugin(options) {
|
|
|
263
287
|
fileName: "assets/twc.css",
|
|
264
288
|
source: css
|
|
265
289
|
});
|
|
266
|
-
},
|
|
267
|
-
handleHotUpdate({ file, server }) {
|
|
268
|
-
if (file.match(/\.[jt]sx?$/) && fileRules.has(file)) {
|
|
269
|
-
const mod = server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CSS_ID);
|
|
270
|
-
if (mod) {
|
|
271
|
-
server.moduleGraph.invalidateModule(mod);
|
|
272
|
-
return [mod];
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
290
|
}
|
|
276
291
|
};
|
|
277
292
|
function generateAllCss() {
|
|
@@ -27,6 +27,8 @@ interface ThemeInput {
|
|
|
27
27
|
textSizes: string
|
|
28
28
|
/** JSON: { "thin": "100", "light": "300", ... } */
|
|
29
29
|
fontWeights: string
|
|
30
|
+
/** JSON: { "sans": "ui-sans-serif, system-ui, ...", ... } */
|
|
31
|
+
fontFamilies: string
|
|
30
32
|
/** JSON: { "none": "0px", "sm": "0.125rem", "DEFAULT": "0.25rem", ... } */
|
|
31
33
|
radii: string
|
|
32
34
|
/** JSON: { "sm": "0 1px 2px ...", "DEFAULT": "0 1px 3px ...", ... } */
|
|
@@ -27,6 +27,8 @@ interface ThemeInput {
|
|
|
27
27
|
textSizes: string
|
|
28
28
|
/** JSON: { "thin": "100", "light": "300", ... } */
|
|
29
29
|
fontWeights: string
|
|
30
|
+
/** JSON: { "sans": "ui-sans-serif, system-ui, ...", ... } */
|
|
31
|
+
fontFamilies: string
|
|
30
32
|
/** JSON: { "none": "0px", "sm": "0.125rem", "DEFAULT": "0.25rem", ... } */
|
|
31
33
|
radii: string
|
|
32
34
|
/** JSON: { "sm": "0 1px 2px ...", "DEFAULT": "0 1px 3px ...", ... } */
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as generateCss$1, t as transform } from './index.d-
|
|
2
|
-
export { D as Diagnostic, E as ExtractedRule, T as ThemeInput, a as TransformOutput } from './index.d-
|
|
1
|
+
import { g as generateCss$1, t as transform } from './index.d-Bks8QAue.cjs';
|
|
2
|
+
export { D as Diagnostic, E as ExtractedRule, T as ThemeInput, a as TransformOutput } from './index.d-Bks8QAue.cjs';
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
4
|
|
|
5
5
|
declare const nativeTransform: typeof transform;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { g as generateCss$1, t as transform } from './index.d-
|
|
2
|
-
export { D as Diagnostic, E as ExtractedRule, T as ThemeInput, a as TransformOutput } from './index.d-
|
|
1
|
+
import { g as generateCss$1, t as transform } from './index.d-Bks8QAue.js';
|
|
2
|
+
export { D as Diagnostic, E as ExtractedRule, T as ThemeInput, a as TransformOutput } from './index.d-Bks8QAue.js';
|
|
3
3
|
import { Plugin } from 'vite';
|
|
4
4
|
|
|
5
5
|
declare const nativeTransform: typeof transform;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
loadTheme
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IPFCUN6B.js";
|
|
4
4
|
|
|
5
5
|
// src/index.ts
|
|
6
6
|
import MagicString from "magic-string";
|
|
@@ -16,7 +16,9 @@ var RESOLVED_VIRTUAL_CSS_ID = "\0" + VIRTUAL_CSS_ID;
|
|
|
16
16
|
function twcPlugin(options) {
|
|
17
17
|
const strict = options?.strict ?? true;
|
|
18
18
|
let themeInput;
|
|
19
|
-
let
|
|
19
|
+
let prodLayer = 0;
|
|
20
|
+
const fileLayerOffsets = /* @__PURE__ */ new Map();
|
|
21
|
+
let nextFileLayer = 0;
|
|
20
22
|
const fileRules = /* @__PURE__ */ new Map();
|
|
21
23
|
let devServer = null;
|
|
22
24
|
return {
|
|
@@ -37,38 +39,55 @@ function twcPlugin(options) {
|
|
|
37
39
|
return generateAllCss();
|
|
38
40
|
}
|
|
39
41
|
},
|
|
42
|
+
async handleHotUpdate(ctx) {
|
|
43
|
+
const { file, read, server, modules } = ctx;
|
|
44
|
+
if (!file.match(/\.[jt]sx?$/) || file.includes("node_modules")) return;
|
|
45
|
+
const code = await read();
|
|
46
|
+
if (!code.includes("typewritingclass")) return;
|
|
47
|
+
if (!fileLayerOffsets.has(file)) {
|
|
48
|
+
fileLayerOffsets.set(file, nextFileLayer);
|
|
49
|
+
nextFileLayer += 1e3;
|
|
50
|
+
}
|
|
51
|
+
const layerOffset = fileLayerOffsets.get(file);
|
|
52
|
+
try {
|
|
53
|
+
const result = native.transform(code, file, layerOffset, themeInput, strict);
|
|
54
|
+
fileRules.set(file, result.rules.map((r) => r.cssText));
|
|
55
|
+
} catch {
|
|
56
|
+
}
|
|
57
|
+
const cssMod = server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CSS_ID);
|
|
58
|
+
if (cssMod) {
|
|
59
|
+
server.moduleGraph.invalidateModule(cssMod);
|
|
60
|
+
return [...modules, cssMod];
|
|
61
|
+
}
|
|
62
|
+
return modules;
|
|
63
|
+
},
|
|
40
64
|
transform(code, id) {
|
|
41
65
|
if (!id.match(/\.[jt]sx?$/) || id.includes("node_modules")) return;
|
|
42
66
|
if (!code.includes("typewritingclass")) return;
|
|
67
|
+
let layerOffset;
|
|
68
|
+
if (devServer) {
|
|
69
|
+
if (!fileLayerOffsets.has(id)) {
|
|
70
|
+
fileLayerOffsets.set(id, nextFileLayer);
|
|
71
|
+
nextFileLayer += 1e3;
|
|
72
|
+
}
|
|
73
|
+
layerOffset = fileLayerOffsets.get(id);
|
|
74
|
+
} else {
|
|
75
|
+
layerOffset = prodLayer;
|
|
76
|
+
}
|
|
43
77
|
try {
|
|
44
|
-
const result = native.transform(code, id,
|
|
45
|
-
|
|
78
|
+
const result = native.transform(code, id, layerOffset, themeInput, strict);
|
|
79
|
+
if (!devServer) {
|
|
80
|
+
prodLayer = result.nextLayer;
|
|
81
|
+
}
|
|
46
82
|
for (const diag of result.diagnostics) {
|
|
47
83
|
if (diag.severity === "error") {
|
|
48
|
-
this.error({
|
|
49
|
-
message: diag.message,
|
|
50
|
-
id,
|
|
51
|
-
pos: diag.line
|
|
52
|
-
});
|
|
84
|
+
this.error({ message: diag.message, id, pos: diag.line });
|
|
53
85
|
} else {
|
|
54
|
-
this.warn({
|
|
55
|
-
message: diag.message,
|
|
56
|
-
id,
|
|
57
|
-
pos: diag.line
|
|
58
|
-
});
|
|
86
|
+
this.warn({ message: diag.message, id, pos: diag.line });
|
|
59
87
|
}
|
|
60
88
|
}
|
|
61
89
|
if (result.rules.length > 0) {
|
|
62
|
-
fileRules.set(
|
|
63
|
-
id,
|
|
64
|
-
result.rules.map((r) => r.cssText)
|
|
65
|
-
);
|
|
66
|
-
if (devServer) {
|
|
67
|
-
const mod = devServer.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CSS_ID);
|
|
68
|
-
if (mod) {
|
|
69
|
-
devServer.moduleGraph.invalidateModule(mod);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
90
|
+
fileRules.set(id, result.rules.map((r) => r.cssText));
|
|
72
91
|
}
|
|
73
92
|
const s = new MagicString(code);
|
|
74
93
|
if (result.code !== code) {
|
|
@@ -94,9 +113,6 @@ function twcPlugin(options) {
|
|
|
94
113
|
}
|
|
95
114
|
}
|
|
96
115
|
},
|
|
97
|
-
// Production builds: inject CSS into the output after all files are
|
|
98
|
-
// transformed. This fixes the timing issue where virtual:twc.css is
|
|
99
|
-
// loaded by Rollup before component files have been processed.
|
|
100
116
|
generateBundle(_, bundle) {
|
|
101
117
|
const css = generateAllCss();
|
|
102
118
|
if (!css) return;
|
|
@@ -112,15 +128,6 @@ function twcPlugin(options) {
|
|
|
112
128
|
fileName: "assets/twc.css",
|
|
113
129
|
source: css
|
|
114
130
|
});
|
|
115
|
-
},
|
|
116
|
-
handleHotUpdate({ file, server }) {
|
|
117
|
-
if (file.match(/\.[jt]sx?$/) && fileRules.has(file)) {
|
|
118
|
-
const mod = server.moduleGraph.getModuleById(RESOLVED_VIRTUAL_CSS_ID);
|
|
119
|
-
if (mod) {
|
|
120
|
-
server.moduleGraph.invalidateModule(mod);
|
|
121
|
-
return [mod];
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
131
|
}
|
|
125
132
|
};
|
|
126
133
|
function generateAllCss() {
|
package/dist/loadTheme.cjs
CHANGED
|
@@ -105,6 +105,13 @@ async function loadTheme() {
|
|
|
105
105
|
fontWeights[name] = val;
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
+
const fontFamiliesObj = typographyModule.fontFamilies;
|
|
109
|
+
const fontFamilies = {};
|
|
110
|
+
if (fontFamiliesObj && typeof fontFamiliesObj === "object") {
|
|
111
|
+
for (const [key, val] of Object.entries(fontFamiliesObj)) {
|
|
112
|
+
fontFamilies[key] = val;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
108
115
|
const radiusNames = ["none", "sm", "DEFAULT", "md", "lg", "xl", "_2xl", "_3xl", "full"];
|
|
109
116
|
const radii = {};
|
|
110
117
|
for (const name of radiusNames) {
|
|
@@ -135,6 +142,7 @@ async function loadTheme() {
|
|
|
135
142
|
spacing: JSON.stringify(spacing),
|
|
136
143
|
textSizes: JSON.stringify(textSizes),
|
|
137
144
|
fontWeights: JSON.stringify(fontWeights),
|
|
145
|
+
fontFamilies: JSON.stringify(fontFamilies),
|
|
138
146
|
radii: JSON.stringify(radii),
|
|
139
147
|
shadows: JSON.stringify(shadows),
|
|
140
148
|
sizes: JSON.stringify(sizes),
|
package/dist/loadTheme.d.cts
CHANGED
package/dist/loadTheme.d.ts
CHANGED
package/dist/loadTheme.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export interface ThemeInput {
|
|
|
27
27
|
textSizes: string
|
|
28
28
|
/** JSON: { "thin": "100", "light": "300", ... } */
|
|
29
29
|
fontWeights: string
|
|
30
|
+
/** JSON: { "sans": "ui-sans-serif, system-ui, ...", ... } */
|
|
31
|
+
fontFamilies: string
|
|
30
32
|
/** JSON: { "none": "0px", "sm": "0.125rem", "DEFAULT": "0.25rem", ... } */
|
|
31
33
|
radii: string
|
|
32
34
|
/** JSON: { "sm": "0 1px 2px ...", "DEFAULT": "0 1px 3px ...", ... } */
|
package/index.node
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typewritingclass-compiler",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"magic-string": "^0.30.21",
|
|
55
|
-
"typewritingclass": "0.2.
|
|
55
|
+
"typewritingclass": "0.2.5"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@types/node": "^25.2.2",
|
|
@@ -62,6 +62,8 @@
|
|
|
62
62
|
"scripts": {
|
|
63
63
|
"build": "tsup",
|
|
64
64
|
"build:native": "napi build --release",
|
|
65
|
-
"build:native:debug": "napi build"
|
|
65
|
+
"build:native:debug": "napi build",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"test:watch": "vitest"
|
|
66
68
|
}
|
|
67
69
|
}
|