@zeus-js/component-dts 0.1.0-beta.2 → 0.1.0-beta.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/component-dts.cjs.js +102 -16
- package/dist/component-dts.cjs.prod.js +102 -16
- package/dist/component-dts.d.ts +6 -1
- package/dist/component-dts.esm-bundler.js +102 -17
- package/package.json +6 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* component-dts v0.1.0-beta.
|
|
2
|
+
* component-dts v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -41,6 +41,7 @@ function formatPropType(prop) {
|
|
|
41
41
|
case "boolean": return "boolean";
|
|
42
42
|
case "array": return "unknown[]";
|
|
43
43
|
case "object": return "Record<string, unknown>";
|
|
44
|
+
case "function": return "Function";
|
|
44
45
|
default: return "unknown";
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -76,6 +77,17 @@ function isRequiredProp(prop) {
|
|
|
76
77
|
if (prop.default !== void 0) return false;
|
|
77
78
|
return prop.required === true;
|
|
78
79
|
}
|
|
80
|
+
function formatMethodSignature(method, options = {}) {
|
|
81
|
+
var _method$returns;
|
|
82
|
+
const parameters = method.parameters ? method.parameters.map((parameter) => {
|
|
83
|
+
const prefix = parameter.rest ? "..." : "";
|
|
84
|
+
const optional = parameter.optional && !parameter.rest ? "?" : "";
|
|
85
|
+
return `${prefix}${safePropertyName(parameter.name)}${optional}: ${normalizeKnownType(parameter.type)}`;
|
|
86
|
+
}).join(", ") : "...args: unknown[]";
|
|
87
|
+
const result = normalizeKnownType((_method$returns = method.returns) !== null && _method$returns !== void 0 ? _method$returns : "unknown");
|
|
88
|
+
const returnType = method.async || options.forcePromise ? result.startsWith("Promise<") ? result : `Promise<${result}>` : result;
|
|
89
|
+
return `${safePropertyName(method.name)}(${parameters}): ${returnType}`;
|
|
90
|
+
}
|
|
79
91
|
//#endregion
|
|
80
92
|
//#region packages/web-c/component-dts/src/naming.ts
|
|
81
93
|
function getElementTypeName(component) {
|
|
@@ -110,7 +122,7 @@ function generateComponentWCDts(component) {
|
|
|
110
122
|
lines.push("");
|
|
111
123
|
lines.push(generateEventMap(component));
|
|
112
124
|
lines.push("");
|
|
113
|
-
lines.push(generateElementInterface(component));
|
|
125
|
+
lines.push(generateElementInterface$1(component));
|
|
114
126
|
lines.push("");
|
|
115
127
|
lines.push(`export declare const ${component.exportName}: {`);
|
|
116
128
|
lines.push(` new (): ${elementTypeName}`);
|
|
@@ -142,11 +154,15 @@ function generateEventMap(component) {
|
|
|
142
154
|
const lines = [];
|
|
143
155
|
lines.push(`export interface ${eventMapName} {`);
|
|
144
156
|
if (!entries.length) lines.push(" [key: string]: CustomEvent<unknown>");
|
|
145
|
-
else for (const [
|
|
157
|
+
else for (const [key, event] of Object.entries(component.events)) {
|
|
158
|
+
var _event$name, _event$key;
|
|
159
|
+
lines.push(` ${safePropertyName((_event$name = event.name) !== null && _event$name !== void 0 ? _event$name : toKebabCase$1((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}: ${formatEventType(event)}`);
|
|
160
|
+
}
|
|
146
161
|
lines.push("}");
|
|
147
162
|
return lines.join("\n");
|
|
148
163
|
}
|
|
149
|
-
function generateElementInterface(component) {
|
|
164
|
+
function generateElementInterface$1(component) {
|
|
165
|
+
var _component$methods;
|
|
150
166
|
const elementTypeName = getElementTypeName(component);
|
|
151
167
|
const eventMapName = getEventMapTypeName(component);
|
|
152
168
|
const lines = [];
|
|
@@ -155,6 +171,7 @@ function generateElementInterface(component) {
|
|
|
155
171
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
156
172
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
157
173
|
}
|
|
174
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method)}`);
|
|
158
175
|
lines.push("");
|
|
159
176
|
lines.push(` addEventListener<K extends keyof ${eventMapName}>(`);
|
|
160
177
|
lines.push(" type: K,");
|
|
@@ -170,6 +187,9 @@ function generateElementInterface(component) {
|
|
|
170
187
|
lines.push("}");
|
|
171
188
|
return lines.join("\n");
|
|
172
189
|
}
|
|
190
|
+
function toKebabCase$1(value) {
|
|
191
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
192
|
+
}
|
|
173
193
|
//#endregion
|
|
174
194
|
//#region packages/web-c/component-dts/src/generateJsxDts.ts
|
|
175
195
|
function generateWCJsxDts(manifest) {
|
|
@@ -201,6 +221,11 @@ function generateComponentJsxProps(component) {
|
|
|
201
221
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
202
222
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
203
223
|
}
|
|
224
|
+
for (const [key, event] of Object.entries(component.events)) {
|
|
225
|
+
var _event$reactName, _event$key;
|
|
226
|
+
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
227
|
+
lines.push(` ${safePropertyName((_event$reactName = event.reactName) !== null && _event$reactName !== void 0 ? _event$reactName : toReactEventProp$1((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}?: (event: CustomEvent<${detailType}>) => void`);
|
|
228
|
+
}
|
|
204
229
|
lines.push("");
|
|
205
230
|
lines.push(" children?: unknown");
|
|
206
231
|
lines.push(" class?: string");
|
|
@@ -216,9 +241,12 @@ function generateComponentJsxProps(component) {
|
|
|
216
241
|
lines.push("}");
|
|
217
242
|
return lines.join("\n");
|
|
218
243
|
}
|
|
244
|
+
function toReactEventProp$1(value) {
|
|
245
|
+
return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
|
|
246
|
+
}
|
|
219
247
|
//#endregion
|
|
220
248
|
//#region packages/web-c/component-dts/src/generateReactDts.ts
|
|
221
|
-
function generateReactDts(manifest) {
|
|
249
|
+
function generateReactDts(manifest, options = {}) {
|
|
222
250
|
const lines = [];
|
|
223
251
|
lines.push("/* eslint-disable */");
|
|
224
252
|
lines.push("// Generated by @zeus-js/component-dts.");
|
|
@@ -226,12 +254,13 @@ function generateReactDts(manifest) {
|
|
|
226
254
|
lines.push(`import type * as React from 'react'`);
|
|
227
255
|
lines.push("");
|
|
228
256
|
for (const component of manifest.components) {
|
|
229
|
-
lines.push(generateReactComponentDts(component));
|
|
257
|
+
lines.push(generateReactComponentDts(component, options));
|
|
230
258
|
lines.push("");
|
|
231
259
|
}
|
|
232
260
|
return lines.join("\n");
|
|
233
261
|
}
|
|
234
|
-
function generateReactComponentDts(component) {
|
|
262
|
+
function generateReactComponentDts(component, options) {
|
|
263
|
+
var _component$methods;
|
|
235
264
|
const propsTypeName = getPropsTypeName(component);
|
|
236
265
|
const elementTypeName = getElementTypeName(component);
|
|
237
266
|
const lines = [];
|
|
@@ -244,10 +273,15 @@ function generateReactComponentDts(component) {
|
|
|
244
273
|
lines.push(" children?: React.ReactNode");
|
|
245
274
|
lines.push(" className?: string");
|
|
246
275
|
lines.push(" style?: React.CSSProperties");
|
|
247
|
-
for (const [
|
|
248
|
-
|
|
276
|
+
for (const [key, event] of Object.entries(component.events)) {
|
|
277
|
+
var _event$reactName, _event$key;
|
|
278
|
+
const propName = (_event$reactName = event.reactName) !== null && _event$reactName !== void 0 ? _event$reactName : toReactEventProp((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key);
|
|
249
279
|
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
250
|
-
lines.push(` ${propName}?: (event: CustomEvent<${detailType}>) => void`);
|
|
280
|
+
lines.push(` ${safePropertyName(propName)}?: (event: CustomEvent<${detailType}>) => void`);
|
|
281
|
+
}
|
|
282
|
+
if (options.namedSlots !== "none") for (const name of Object.keys(component.slots)) {
|
|
283
|
+
if (name === "default") continue;
|
|
284
|
+
lines.push(` ${safePropertyName(name)}?: React.ReactNode`);
|
|
251
285
|
}
|
|
252
286
|
lines.push("}");
|
|
253
287
|
lines.push("");
|
|
@@ -256,6 +290,7 @@ function generateReactComponentDts(component) {
|
|
|
256
290
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
257
291
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
258
292
|
}
|
|
293
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method)}`);
|
|
259
294
|
lines.push("}");
|
|
260
295
|
lines.push("");
|
|
261
296
|
lines.push(`export declare const ${component.name}: React.ForwardRefExoticComponent<`);
|
|
@@ -263,8 +298,8 @@ function generateReactComponentDts(component) {
|
|
|
263
298
|
lines.push(">");
|
|
264
299
|
return lines.join("\n");
|
|
265
300
|
}
|
|
266
|
-
function toReactEventProp(
|
|
267
|
-
return
|
|
301
|
+
function toReactEventProp(value) {
|
|
302
|
+
return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
|
|
268
303
|
}
|
|
269
304
|
//#endregion
|
|
270
305
|
//#region packages/web-c/component-dts/src/generateVueDts.ts
|
|
@@ -323,12 +358,23 @@ function generateVueComponentDts(component) {
|
|
|
323
358
|
return lines.join("\n");
|
|
324
359
|
}
|
|
325
360
|
function generateVueEmitsType(component) {
|
|
361
|
+
var _component$models;
|
|
326
362
|
const entries = Object.entries(component.events);
|
|
327
|
-
|
|
328
|
-
|
|
363
|
+
const modelEntries = Array.from(new Map(((_component$models = component.models) !== null && _component$models !== void 0 ? _component$models : []).map((model) => {
|
|
364
|
+
const prop = component.props[model.prop];
|
|
365
|
+
const type = prop ? formatPropType(prop) : "unknown";
|
|
366
|
+
const name = `update:${model.prop}`;
|
|
367
|
+
return [name, `${JSON.stringify(name)}: (value: ${type}) => void`];
|
|
368
|
+
})).values());
|
|
369
|
+
if (!entries.length && !modelEntries.length) return "{}";
|
|
370
|
+
return `{ ${[...entries.map(([key, event]) => {
|
|
371
|
+
var _event$name, _event$key;
|
|
329
372
|
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
330
|
-
return `${JSON.stringify(name)}: (event: CustomEvent<${detailType}>) => void`;
|
|
331
|
-
}).join("; ")} }`;
|
|
373
|
+
return `${JSON.stringify((_event$name = event.name) !== null && _event$name !== void 0 ? _event$name : toKebabCase((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}: (event: CustomEvent<${detailType}>) => void`;
|
|
374
|
+
}), ...modelEntries].join("; ")} }`;
|
|
375
|
+
}
|
|
376
|
+
function toKebabCase(value) {
|
|
377
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
332
378
|
}
|
|
333
379
|
//#endregion
|
|
334
380
|
//#region packages/web-c/component-dts/src/generateFiles.ts
|
|
@@ -361,10 +407,50 @@ function normalizeOptions(options) {
|
|
|
361
407
|
};
|
|
362
408
|
}
|
|
363
409
|
//#endregion
|
|
410
|
+
//#region packages/web-c/component-dts/src/generateLoaderDts.ts
|
|
411
|
+
function generateLoaderDts(manifest) {
|
|
412
|
+
const lines = [];
|
|
413
|
+
lines.push("/* eslint-disable */");
|
|
414
|
+
lines.push("// Generated by @zeus-js/component-dts.");
|
|
415
|
+
lines.push("");
|
|
416
|
+
for (const component of manifest.components) {
|
|
417
|
+
lines.push(generateElementInterface(component));
|
|
418
|
+
lines.push("");
|
|
419
|
+
}
|
|
420
|
+
lines.push("export declare function defineCustomElements(): void");
|
|
421
|
+
lines.push("");
|
|
422
|
+
lines.push("export declare const defineLazyElements: typeof defineCustomElements");
|
|
423
|
+
lines.push("");
|
|
424
|
+
lines.push("declare global {");
|
|
425
|
+
lines.push(" interface HTMLElementTagNameMap {");
|
|
426
|
+
for (const component of manifest.components) lines.push(` ${JSON.stringify(component.tag)}: ${getElementTypeName(component)}`);
|
|
427
|
+
lines.push(" }");
|
|
428
|
+
lines.push("}");
|
|
429
|
+
lines.push("");
|
|
430
|
+
lines.push("export {}");
|
|
431
|
+
lines.push("");
|
|
432
|
+
return lines.join("\n");
|
|
433
|
+
}
|
|
434
|
+
function generateElementInterface(component) {
|
|
435
|
+
var _component$methods;
|
|
436
|
+
const elementTypeName = getElementTypeName(component);
|
|
437
|
+
const lines = [];
|
|
438
|
+
lines.push(`export interface ${elementTypeName} extends HTMLElement {`);
|
|
439
|
+
for (const [name, prop] of Object.entries(component.props)) {
|
|
440
|
+
const optional = isRequiredProp(prop) ? "" : "?";
|
|
441
|
+
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
442
|
+
}
|
|
443
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method, { forcePromise: true })}`);
|
|
444
|
+
lines.push(" componentOnReady(): Promise<this>");
|
|
445
|
+
lines.push("}");
|
|
446
|
+
return lines.join("\n");
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
364
449
|
exports.formatDetailType = formatDetailType;
|
|
365
450
|
exports.formatEventType = formatEventType;
|
|
366
451
|
exports.formatPropType = formatPropType;
|
|
367
452
|
exports.generateComponentWCDts = generateComponentWCDts;
|
|
453
|
+
exports.generateLoaderDts = generateLoaderDts;
|
|
368
454
|
exports.generateReactDts = generateReactDts;
|
|
369
455
|
exports.generateVueDts = generateVueDts;
|
|
370
456
|
exports.generateVueGlobalDts = generateVueGlobalDts;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* component-dts v0.1.0-beta.
|
|
2
|
+
* component-dts v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -41,6 +41,7 @@ function formatPropType(prop) {
|
|
|
41
41
|
case "boolean": return "boolean";
|
|
42
42
|
case "array": return "unknown[]";
|
|
43
43
|
case "object": return "Record<string, unknown>";
|
|
44
|
+
case "function": return "Function";
|
|
44
45
|
default: return "unknown";
|
|
45
46
|
}
|
|
46
47
|
}
|
|
@@ -76,6 +77,17 @@ function isRequiredProp(prop) {
|
|
|
76
77
|
if (prop.default !== void 0) return false;
|
|
77
78
|
return prop.required === true;
|
|
78
79
|
}
|
|
80
|
+
function formatMethodSignature(method, options = {}) {
|
|
81
|
+
var _method$returns;
|
|
82
|
+
const parameters = method.parameters ? method.parameters.map((parameter) => {
|
|
83
|
+
const prefix = parameter.rest ? "..." : "";
|
|
84
|
+
const optional = parameter.optional && !parameter.rest ? "?" : "";
|
|
85
|
+
return `${prefix}${safePropertyName(parameter.name)}${optional}: ${normalizeKnownType(parameter.type)}`;
|
|
86
|
+
}).join(", ") : "...args: unknown[]";
|
|
87
|
+
const result = normalizeKnownType((_method$returns = method.returns) !== null && _method$returns !== void 0 ? _method$returns : "unknown");
|
|
88
|
+
const returnType = method.async || options.forcePromise ? result.startsWith("Promise<") ? result : `Promise<${result}>` : result;
|
|
89
|
+
return `${safePropertyName(method.name)}(${parameters}): ${returnType}`;
|
|
90
|
+
}
|
|
79
91
|
//#endregion
|
|
80
92
|
//#region packages/web-c/component-dts/src/naming.ts
|
|
81
93
|
function getElementTypeName(component) {
|
|
@@ -110,7 +122,7 @@ function generateComponentWCDts(component) {
|
|
|
110
122
|
lines.push("");
|
|
111
123
|
lines.push(generateEventMap(component));
|
|
112
124
|
lines.push("");
|
|
113
|
-
lines.push(generateElementInterface(component));
|
|
125
|
+
lines.push(generateElementInterface$1(component));
|
|
114
126
|
lines.push("");
|
|
115
127
|
lines.push(`export declare const ${component.exportName}: {`);
|
|
116
128
|
lines.push(` new (): ${elementTypeName}`);
|
|
@@ -142,11 +154,15 @@ function generateEventMap(component) {
|
|
|
142
154
|
const lines = [];
|
|
143
155
|
lines.push(`export interface ${eventMapName} {`);
|
|
144
156
|
if (!entries.length) lines.push(" [key: string]: CustomEvent<unknown>");
|
|
145
|
-
else for (const [
|
|
157
|
+
else for (const [key, event] of Object.entries(component.events)) {
|
|
158
|
+
var _event$name, _event$key;
|
|
159
|
+
lines.push(` ${safePropertyName((_event$name = event.name) !== null && _event$name !== void 0 ? _event$name : toKebabCase$1((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}: ${formatEventType(event)}`);
|
|
160
|
+
}
|
|
146
161
|
lines.push("}");
|
|
147
162
|
return lines.join("\n");
|
|
148
163
|
}
|
|
149
|
-
function generateElementInterface(component) {
|
|
164
|
+
function generateElementInterface$1(component) {
|
|
165
|
+
var _component$methods;
|
|
150
166
|
const elementTypeName = getElementTypeName(component);
|
|
151
167
|
const eventMapName = getEventMapTypeName(component);
|
|
152
168
|
const lines = [];
|
|
@@ -155,6 +171,7 @@ function generateElementInterface(component) {
|
|
|
155
171
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
156
172
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
157
173
|
}
|
|
174
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method)}`);
|
|
158
175
|
lines.push("");
|
|
159
176
|
lines.push(` addEventListener<K extends keyof ${eventMapName}>(`);
|
|
160
177
|
lines.push(" type: K,");
|
|
@@ -170,6 +187,9 @@ function generateElementInterface(component) {
|
|
|
170
187
|
lines.push("}");
|
|
171
188
|
return lines.join("\n");
|
|
172
189
|
}
|
|
190
|
+
function toKebabCase$1(value) {
|
|
191
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
192
|
+
}
|
|
173
193
|
//#endregion
|
|
174
194
|
//#region packages/web-c/component-dts/src/generateJsxDts.ts
|
|
175
195
|
function generateWCJsxDts(manifest) {
|
|
@@ -201,6 +221,11 @@ function generateComponentJsxProps(component) {
|
|
|
201
221
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
202
222
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
203
223
|
}
|
|
224
|
+
for (const [key, event] of Object.entries(component.events)) {
|
|
225
|
+
var _event$reactName, _event$key;
|
|
226
|
+
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
227
|
+
lines.push(` ${safePropertyName((_event$reactName = event.reactName) !== null && _event$reactName !== void 0 ? _event$reactName : toReactEventProp$1((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}?: (event: CustomEvent<${detailType}>) => void`);
|
|
228
|
+
}
|
|
204
229
|
lines.push("");
|
|
205
230
|
lines.push(" children?: unknown");
|
|
206
231
|
lines.push(" class?: string");
|
|
@@ -216,9 +241,12 @@ function generateComponentJsxProps(component) {
|
|
|
216
241
|
lines.push("}");
|
|
217
242
|
return lines.join("\n");
|
|
218
243
|
}
|
|
244
|
+
function toReactEventProp$1(value) {
|
|
245
|
+
return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
|
|
246
|
+
}
|
|
219
247
|
//#endregion
|
|
220
248
|
//#region packages/web-c/component-dts/src/generateReactDts.ts
|
|
221
|
-
function generateReactDts(manifest) {
|
|
249
|
+
function generateReactDts(manifest, options = {}) {
|
|
222
250
|
const lines = [];
|
|
223
251
|
lines.push("/* eslint-disable */");
|
|
224
252
|
lines.push("// Generated by @zeus-js/component-dts.");
|
|
@@ -226,12 +254,13 @@ function generateReactDts(manifest) {
|
|
|
226
254
|
lines.push(`import type * as React from 'react'`);
|
|
227
255
|
lines.push("");
|
|
228
256
|
for (const component of manifest.components) {
|
|
229
|
-
lines.push(generateReactComponentDts(component));
|
|
257
|
+
lines.push(generateReactComponentDts(component, options));
|
|
230
258
|
lines.push("");
|
|
231
259
|
}
|
|
232
260
|
return lines.join("\n");
|
|
233
261
|
}
|
|
234
|
-
function generateReactComponentDts(component) {
|
|
262
|
+
function generateReactComponentDts(component, options) {
|
|
263
|
+
var _component$methods;
|
|
235
264
|
const propsTypeName = getPropsTypeName(component);
|
|
236
265
|
const elementTypeName = getElementTypeName(component);
|
|
237
266
|
const lines = [];
|
|
@@ -244,10 +273,15 @@ function generateReactComponentDts(component) {
|
|
|
244
273
|
lines.push(" children?: React.ReactNode");
|
|
245
274
|
lines.push(" className?: string");
|
|
246
275
|
lines.push(" style?: React.CSSProperties");
|
|
247
|
-
for (const [
|
|
248
|
-
|
|
276
|
+
for (const [key, event] of Object.entries(component.events)) {
|
|
277
|
+
var _event$reactName, _event$key;
|
|
278
|
+
const propName = (_event$reactName = event.reactName) !== null && _event$reactName !== void 0 ? _event$reactName : toReactEventProp((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key);
|
|
249
279
|
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
250
|
-
lines.push(` ${propName}?: (event: CustomEvent<${detailType}>) => void`);
|
|
280
|
+
lines.push(` ${safePropertyName(propName)}?: (event: CustomEvent<${detailType}>) => void`);
|
|
281
|
+
}
|
|
282
|
+
if (options.namedSlots !== "none") for (const name of Object.keys(component.slots)) {
|
|
283
|
+
if (name === "default") continue;
|
|
284
|
+
lines.push(` ${safePropertyName(name)}?: React.ReactNode`);
|
|
251
285
|
}
|
|
252
286
|
lines.push("}");
|
|
253
287
|
lines.push("");
|
|
@@ -256,6 +290,7 @@ function generateReactComponentDts(component) {
|
|
|
256
290
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
257
291
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
258
292
|
}
|
|
293
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method)}`);
|
|
259
294
|
lines.push("}");
|
|
260
295
|
lines.push("");
|
|
261
296
|
lines.push(`export declare const ${component.name}: React.ForwardRefExoticComponent<`);
|
|
@@ -263,8 +298,8 @@ function generateReactComponentDts(component) {
|
|
|
263
298
|
lines.push(">");
|
|
264
299
|
return lines.join("\n");
|
|
265
300
|
}
|
|
266
|
-
function toReactEventProp(
|
|
267
|
-
return
|
|
301
|
+
function toReactEventProp(value) {
|
|
302
|
+
return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
|
|
268
303
|
}
|
|
269
304
|
//#endregion
|
|
270
305
|
//#region packages/web-c/component-dts/src/generateVueDts.ts
|
|
@@ -323,12 +358,23 @@ function generateVueComponentDts(component) {
|
|
|
323
358
|
return lines.join("\n");
|
|
324
359
|
}
|
|
325
360
|
function generateVueEmitsType(component) {
|
|
361
|
+
var _component$models;
|
|
326
362
|
const entries = Object.entries(component.events);
|
|
327
|
-
|
|
328
|
-
|
|
363
|
+
const modelEntries = Array.from(new Map(((_component$models = component.models) !== null && _component$models !== void 0 ? _component$models : []).map((model) => {
|
|
364
|
+
const prop = component.props[model.prop];
|
|
365
|
+
const type = prop ? formatPropType(prop) : "unknown";
|
|
366
|
+
const name = `update:${model.prop}`;
|
|
367
|
+
return [name, `${JSON.stringify(name)}: (value: ${type}) => void`];
|
|
368
|
+
})).values());
|
|
369
|
+
if (!entries.length && !modelEntries.length) return "{}";
|
|
370
|
+
return `{ ${[...entries.map(([key, event]) => {
|
|
371
|
+
var _event$name, _event$key;
|
|
329
372
|
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
330
|
-
return `${JSON.stringify(name)}: (event: CustomEvent<${detailType}>) => void`;
|
|
331
|
-
}).join("; ")} }`;
|
|
373
|
+
return `${JSON.stringify((_event$name = event.name) !== null && _event$name !== void 0 ? _event$name : toKebabCase((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}: (event: CustomEvent<${detailType}>) => void`;
|
|
374
|
+
}), ...modelEntries].join("; ")} }`;
|
|
375
|
+
}
|
|
376
|
+
function toKebabCase(value) {
|
|
377
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
332
378
|
}
|
|
333
379
|
//#endregion
|
|
334
380
|
//#region packages/web-c/component-dts/src/generateFiles.ts
|
|
@@ -361,10 +407,50 @@ function normalizeOptions(options) {
|
|
|
361
407
|
};
|
|
362
408
|
}
|
|
363
409
|
//#endregion
|
|
410
|
+
//#region packages/web-c/component-dts/src/generateLoaderDts.ts
|
|
411
|
+
function generateLoaderDts(manifest) {
|
|
412
|
+
const lines = [];
|
|
413
|
+
lines.push("/* eslint-disable */");
|
|
414
|
+
lines.push("// Generated by @zeus-js/component-dts.");
|
|
415
|
+
lines.push("");
|
|
416
|
+
for (const component of manifest.components) {
|
|
417
|
+
lines.push(generateElementInterface(component));
|
|
418
|
+
lines.push("");
|
|
419
|
+
}
|
|
420
|
+
lines.push("export declare function defineCustomElements(): void");
|
|
421
|
+
lines.push("");
|
|
422
|
+
lines.push("export declare const defineLazyElements: typeof defineCustomElements");
|
|
423
|
+
lines.push("");
|
|
424
|
+
lines.push("declare global {");
|
|
425
|
+
lines.push(" interface HTMLElementTagNameMap {");
|
|
426
|
+
for (const component of manifest.components) lines.push(` ${JSON.stringify(component.tag)}: ${getElementTypeName(component)}`);
|
|
427
|
+
lines.push(" }");
|
|
428
|
+
lines.push("}");
|
|
429
|
+
lines.push("");
|
|
430
|
+
lines.push("export {}");
|
|
431
|
+
lines.push("");
|
|
432
|
+
return lines.join("\n");
|
|
433
|
+
}
|
|
434
|
+
function generateElementInterface(component) {
|
|
435
|
+
var _component$methods;
|
|
436
|
+
const elementTypeName = getElementTypeName(component);
|
|
437
|
+
const lines = [];
|
|
438
|
+
lines.push(`export interface ${elementTypeName} extends HTMLElement {`);
|
|
439
|
+
for (const [name, prop] of Object.entries(component.props)) {
|
|
440
|
+
const optional = isRequiredProp(prop) ? "" : "?";
|
|
441
|
+
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
442
|
+
}
|
|
443
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method, { forcePromise: true })}`);
|
|
444
|
+
lines.push(" componentOnReady(): Promise<this>");
|
|
445
|
+
lines.push("}");
|
|
446
|
+
return lines.join("\n");
|
|
447
|
+
}
|
|
448
|
+
//#endregion
|
|
364
449
|
exports.formatDetailType = formatDetailType;
|
|
365
450
|
exports.formatEventType = formatEventType;
|
|
366
451
|
exports.formatPropType = formatPropType;
|
|
367
452
|
exports.generateComponentWCDts = generateComponentWCDts;
|
|
453
|
+
exports.generateLoaderDts = generateLoaderDts;
|
|
368
454
|
exports.generateReactDts = generateReactDts;
|
|
369
455
|
exports.generateVueDts = generateVueDts;
|
|
370
456
|
exports.generateVueGlobalDts = generateVueGlobalDts;
|
package/dist/component-dts.d.ts
CHANGED
|
@@ -7,7 +7,10 @@ export declare function generateWCIndexDts(manifest: ComponentManifest, options:
|
|
|
7
7
|
|
|
8
8
|
export declare function generateWCJsxDts(manifest: ComponentManifest): string;
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface GenerateReactDtsOptions {
|
|
11
|
+
namedSlots?: 'props' | 'none';
|
|
12
|
+
}
|
|
13
|
+
export declare function generateReactDts(manifest: ComponentManifest, options?: GenerateReactDtsOptions): string;
|
|
11
14
|
|
|
12
15
|
export declare function generateVueDts(manifest: ComponentManifest): string;
|
|
13
16
|
export declare function generateVueGlobalDts(manifest: ComponentManifest): string;
|
|
@@ -56,6 +59,8 @@ export interface ComponentDtsOptions {
|
|
|
56
59
|
|
|
57
60
|
export declare function generateWCDtsFiles(manifest: ComponentManifest, options?: ComponentDtsOptions): DtsOutputFile[];
|
|
58
61
|
|
|
62
|
+
export declare function generateLoaderDts(manifest: ComponentManifest): string;
|
|
63
|
+
|
|
59
64
|
export declare function formatPropType(prop: ComponentProp): string;
|
|
60
65
|
export declare function formatEventType(event: ComponentEvent): string;
|
|
61
66
|
export declare function formatDetailType(detail: Record<string, string>): string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* component-dts v0.1.0-beta.
|
|
2
|
+
* component-dts v0.1.0-beta.4
|
|
3
3
|
* (c) 2026 baicie
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
**/
|
|
@@ -14,6 +14,7 @@ function formatPropType(prop) {
|
|
|
14
14
|
case "boolean": return "boolean";
|
|
15
15
|
case "array": return "unknown[]";
|
|
16
16
|
case "object": return "Record<string, unknown>";
|
|
17
|
+
case "function": return "Function";
|
|
17
18
|
default: return "unknown";
|
|
18
19
|
}
|
|
19
20
|
}
|
|
@@ -49,6 +50,17 @@ function isRequiredProp(prop) {
|
|
|
49
50
|
if (prop.default !== void 0) return false;
|
|
50
51
|
return prop.required === true;
|
|
51
52
|
}
|
|
53
|
+
function formatMethodSignature(method, options = {}) {
|
|
54
|
+
var _method$returns;
|
|
55
|
+
const parameters = method.parameters ? method.parameters.map((parameter) => {
|
|
56
|
+
const prefix = parameter.rest ? "..." : "";
|
|
57
|
+
const optional = parameter.optional && !parameter.rest ? "?" : "";
|
|
58
|
+
return `${prefix}${safePropertyName(parameter.name)}${optional}: ${normalizeKnownType(parameter.type)}`;
|
|
59
|
+
}).join(", ") : "...args: unknown[]";
|
|
60
|
+
const result = normalizeKnownType((_method$returns = method.returns) !== null && _method$returns !== void 0 ? _method$returns : "unknown");
|
|
61
|
+
const returnType = method.async || options.forcePromise ? result.startsWith("Promise<") ? result : `Promise<${result}>` : result;
|
|
62
|
+
return `${safePropertyName(method.name)}(${parameters}): ${returnType}`;
|
|
63
|
+
}
|
|
52
64
|
//#endregion
|
|
53
65
|
//#region packages/web-c/component-dts/src/naming.ts
|
|
54
66
|
function getElementTypeName(component) {
|
|
@@ -83,7 +95,7 @@ function generateComponentWCDts(component) {
|
|
|
83
95
|
lines.push("");
|
|
84
96
|
lines.push(generateEventMap(component));
|
|
85
97
|
lines.push("");
|
|
86
|
-
lines.push(generateElementInterface(component));
|
|
98
|
+
lines.push(generateElementInterface$1(component));
|
|
87
99
|
lines.push("");
|
|
88
100
|
lines.push(`export declare const ${component.exportName}: {`);
|
|
89
101
|
lines.push(` new (): ${elementTypeName}`);
|
|
@@ -115,11 +127,15 @@ function generateEventMap(component) {
|
|
|
115
127
|
const lines = [];
|
|
116
128
|
lines.push(`export interface ${eventMapName} {`);
|
|
117
129
|
if (!entries.length) lines.push(" [key: string]: CustomEvent<unknown>");
|
|
118
|
-
else for (const [
|
|
130
|
+
else for (const [key, event] of Object.entries(component.events)) {
|
|
131
|
+
var _event$name, _event$key;
|
|
132
|
+
lines.push(` ${safePropertyName((_event$name = event.name) !== null && _event$name !== void 0 ? _event$name : toKebabCase$1((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}: ${formatEventType(event)}`);
|
|
133
|
+
}
|
|
119
134
|
lines.push("}");
|
|
120
135
|
return lines.join("\n");
|
|
121
136
|
}
|
|
122
|
-
function generateElementInterface(component) {
|
|
137
|
+
function generateElementInterface$1(component) {
|
|
138
|
+
var _component$methods;
|
|
123
139
|
const elementTypeName = getElementTypeName(component);
|
|
124
140
|
const eventMapName = getEventMapTypeName(component);
|
|
125
141
|
const lines = [];
|
|
@@ -128,6 +144,7 @@ function generateElementInterface(component) {
|
|
|
128
144
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
129
145
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
130
146
|
}
|
|
147
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method)}`);
|
|
131
148
|
lines.push("");
|
|
132
149
|
lines.push(` addEventListener<K extends keyof ${eventMapName}>(`);
|
|
133
150
|
lines.push(" type: K,");
|
|
@@ -143,6 +160,9 @@ function generateElementInterface(component) {
|
|
|
143
160
|
lines.push("}");
|
|
144
161
|
return lines.join("\n");
|
|
145
162
|
}
|
|
163
|
+
function toKebabCase$1(value) {
|
|
164
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
165
|
+
}
|
|
146
166
|
//#endregion
|
|
147
167
|
//#region packages/web-c/component-dts/src/generateJsxDts.ts
|
|
148
168
|
function generateWCJsxDts(manifest) {
|
|
@@ -174,6 +194,11 @@ function generateComponentJsxProps(component) {
|
|
|
174
194
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
175
195
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
176
196
|
}
|
|
197
|
+
for (const [key, event] of Object.entries(component.events)) {
|
|
198
|
+
var _event$reactName, _event$key;
|
|
199
|
+
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
200
|
+
lines.push(` ${safePropertyName((_event$reactName = event.reactName) !== null && _event$reactName !== void 0 ? _event$reactName : toReactEventProp$1((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}?: (event: CustomEvent<${detailType}>) => void`);
|
|
201
|
+
}
|
|
177
202
|
lines.push("");
|
|
178
203
|
lines.push(" children?: unknown");
|
|
179
204
|
lines.push(" class?: string");
|
|
@@ -189,9 +214,12 @@ function generateComponentJsxProps(component) {
|
|
|
189
214
|
lines.push("}");
|
|
190
215
|
return lines.join("\n");
|
|
191
216
|
}
|
|
217
|
+
function toReactEventProp$1(value) {
|
|
218
|
+
return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
|
|
219
|
+
}
|
|
192
220
|
//#endregion
|
|
193
221
|
//#region packages/web-c/component-dts/src/generateReactDts.ts
|
|
194
|
-
function generateReactDts(manifest) {
|
|
222
|
+
function generateReactDts(manifest, options = {}) {
|
|
195
223
|
const lines = [];
|
|
196
224
|
lines.push("/* eslint-disable */");
|
|
197
225
|
lines.push("// Generated by @zeus-js/component-dts.");
|
|
@@ -199,12 +227,13 @@ function generateReactDts(manifest) {
|
|
|
199
227
|
lines.push(`import type * as React from 'react'`);
|
|
200
228
|
lines.push("");
|
|
201
229
|
for (const component of manifest.components) {
|
|
202
|
-
lines.push(generateReactComponentDts(component));
|
|
230
|
+
lines.push(generateReactComponentDts(component, options));
|
|
203
231
|
lines.push("");
|
|
204
232
|
}
|
|
205
233
|
return lines.join("\n");
|
|
206
234
|
}
|
|
207
|
-
function generateReactComponentDts(component) {
|
|
235
|
+
function generateReactComponentDts(component, options) {
|
|
236
|
+
var _component$methods;
|
|
208
237
|
const propsTypeName = getPropsTypeName(component);
|
|
209
238
|
const elementTypeName = getElementTypeName(component);
|
|
210
239
|
const lines = [];
|
|
@@ -217,10 +246,15 @@ function generateReactComponentDts(component) {
|
|
|
217
246
|
lines.push(" children?: React.ReactNode");
|
|
218
247
|
lines.push(" className?: string");
|
|
219
248
|
lines.push(" style?: React.CSSProperties");
|
|
220
|
-
for (const [
|
|
221
|
-
|
|
249
|
+
for (const [key, event] of Object.entries(component.events)) {
|
|
250
|
+
var _event$reactName, _event$key;
|
|
251
|
+
const propName = (_event$reactName = event.reactName) !== null && _event$reactName !== void 0 ? _event$reactName : toReactEventProp((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key);
|
|
222
252
|
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
223
|
-
lines.push(` ${propName}?: (event: CustomEvent<${detailType}>) => void`);
|
|
253
|
+
lines.push(` ${safePropertyName(propName)}?: (event: CustomEvent<${detailType}>) => void`);
|
|
254
|
+
}
|
|
255
|
+
if (options.namedSlots !== "none") for (const name of Object.keys(component.slots)) {
|
|
256
|
+
if (name === "default") continue;
|
|
257
|
+
lines.push(` ${safePropertyName(name)}?: React.ReactNode`);
|
|
224
258
|
}
|
|
225
259
|
lines.push("}");
|
|
226
260
|
lines.push("");
|
|
@@ -229,6 +263,7 @@ function generateReactComponentDts(component) {
|
|
|
229
263
|
const optional = isRequiredProp(prop) ? "" : "?";
|
|
230
264
|
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
231
265
|
}
|
|
266
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method)}`);
|
|
232
267
|
lines.push("}");
|
|
233
268
|
lines.push("");
|
|
234
269
|
lines.push(`export declare const ${component.name}: React.ForwardRefExoticComponent<`);
|
|
@@ -236,8 +271,8 @@ function generateReactComponentDts(component) {
|
|
|
236
271
|
lines.push(">");
|
|
237
272
|
return lines.join("\n");
|
|
238
273
|
}
|
|
239
|
-
function toReactEventProp(
|
|
240
|
-
return
|
|
274
|
+
function toReactEventProp(value) {
|
|
275
|
+
return `on${value.split("-").filter(Boolean).map((part) => `${part.charAt(0).toUpperCase()}${part.slice(1)}`).join("")}`;
|
|
241
276
|
}
|
|
242
277
|
//#endregion
|
|
243
278
|
//#region packages/web-c/component-dts/src/generateVueDts.ts
|
|
@@ -296,12 +331,23 @@ function generateVueComponentDts(component) {
|
|
|
296
331
|
return lines.join("\n");
|
|
297
332
|
}
|
|
298
333
|
function generateVueEmitsType(component) {
|
|
334
|
+
var _component$models;
|
|
299
335
|
const entries = Object.entries(component.events);
|
|
300
|
-
|
|
301
|
-
|
|
336
|
+
const modelEntries = Array.from(new Map(((_component$models = component.models) !== null && _component$models !== void 0 ? _component$models : []).map((model) => {
|
|
337
|
+
const prop = component.props[model.prop];
|
|
338
|
+
const type = prop ? formatPropType(prop) : "unknown";
|
|
339
|
+
const name = `update:${model.prop}`;
|
|
340
|
+
return [name, `${JSON.stringify(name)}: (value: ${type}) => void`];
|
|
341
|
+
})).values());
|
|
342
|
+
if (!entries.length && !modelEntries.length) return "{}";
|
|
343
|
+
return `{ ${[...entries.map(([key, event]) => {
|
|
344
|
+
var _event$name, _event$key;
|
|
302
345
|
const detailType = event.detail ? formatDetailType(event.detail) : "unknown";
|
|
303
|
-
return `${JSON.stringify(name)}: (event: CustomEvent<${detailType}>) => void`;
|
|
304
|
-
}).join("; ")} }`;
|
|
346
|
+
return `${JSON.stringify((_event$name = event.name) !== null && _event$name !== void 0 ? _event$name : toKebabCase((_event$key = event.key) !== null && _event$key !== void 0 ? _event$key : key))}: (event: CustomEvent<${detailType}>) => void`;
|
|
347
|
+
}), ...modelEntries].join("; ")} }`;
|
|
348
|
+
}
|
|
349
|
+
function toKebabCase(value) {
|
|
350
|
+
return value.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
305
351
|
}
|
|
306
352
|
//#endregion
|
|
307
353
|
//#region packages/web-c/component-dts/src/generateFiles.ts
|
|
@@ -334,4 +380,43 @@ function normalizeOptions(options) {
|
|
|
334
380
|
};
|
|
335
381
|
}
|
|
336
382
|
//#endregion
|
|
337
|
-
|
|
383
|
+
//#region packages/web-c/component-dts/src/generateLoaderDts.ts
|
|
384
|
+
function generateLoaderDts(manifest) {
|
|
385
|
+
const lines = [];
|
|
386
|
+
lines.push("/* eslint-disable */");
|
|
387
|
+
lines.push("// Generated by @zeus-js/component-dts.");
|
|
388
|
+
lines.push("");
|
|
389
|
+
for (const component of manifest.components) {
|
|
390
|
+
lines.push(generateElementInterface(component));
|
|
391
|
+
lines.push("");
|
|
392
|
+
}
|
|
393
|
+
lines.push("export declare function defineCustomElements(): void");
|
|
394
|
+
lines.push("");
|
|
395
|
+
lines.push("export declare const defineLazyElements: typeof defineCustomElements");
|
|
396
|
+
lines.push("");
|
|
397
|
+
lines.push("declare global {");
|
|
398
|
+
lines.push(" interface HTMLElementTagNameMap {");
|
|
399
|
+
for (const component of manifest.components) lines.push(` ${JSON.stringify(component.tag)}: ${getElementTypeName(component)}`);
|
|
400
|
+
lines.push(" }");
|
|
401
|
+
lines.push("}");
|
|
402
|
+
lines.push("");
|
|
403
|
+
lines.push("export {}");
|
|
404
|
+
lines.push("");
|
|
405
|
+
return lines.join("\n");
|
|
406
|
+
}
|
|
407
|
+
function generateElementInterface(component) {
|
|
408
|
+
var _component$methods;
|
|
409
|
+
const elementTypeName = getElementTypeName(component);
|
|
410
|
+
const lines = [];
|
|
411
|
+
lines.push(`export interface ${elementTypeName} extends HTMLElement {`);
|
|
412
|
+
for (const [name, prop] of Object.entries(component.props)) {
|
|
413
|
+
const optional = isRequiredProp(prop) ? "" : "?";
|
|
414
|
+
lines.push(` ${safePropertyName(name)}${optional}: ${formatPropType(prop)}`);
|
|
415
|
+
}
|
|
416
|
+
for (const method of Object.values((_component$methods = component.methods) !== null && _component$methods !== void 0 ? _component$methods : {})) lines.push(` ${formatMethodSignature(method, { forcePromise: true })}`);
|
|
417
|
+
lines.push(" componentOnReady(): Promise<this>");
|
|
418
|
+
lines.push("}");
|
|
419
|
+
return lines.join("\n");
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
export { formatDetailType, formatEventType, formatPropType, generateComponentWCDts, generateLoaderDts, generateReactDts, generateVueDts, generateVueGlobalDts, generateWCDtsFiles, generateWCIndexDts, generateWCJsxDts };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zeus-js/component-dts",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.4",
|
|
4
4
|
"description": "DTS generators for Zeus component manifest",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -13,14 +13,14 @@
|
|
|
13
13
|
"exports": {
|
|
14
14
|
".": {
|
|
15
15
|
"types": "./dist/component-dts.d.ts",
|
|
16
|
+
"module": "./dist/component-dts.esm-bundler.js",
|
|
17
|
+
"import": "./dist/component-dts.esm-bundler.js",
|
|
18
|
+
"require": "./index.js",
|
|
16
19
|
"node": {
|
|
17
20
|
"production": "./dist/component-dts.cjs.prod.js",
|
|
18
21
|
"development": "./dist/component-dts.cjs.js",
|
|
19
22
|
"default": "./index.js"
|
|
20
|
-
}
|
|
21
|
-
"module": "./dist/component-dts.esm-bundler.js",
|
|
22
|
-
"import": "./dist/component-dts.esm-bundler.js",
|
|
23
|
-
"require": "./index.js"
|
|
23
|
+
}
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"sideEffects": false,
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
]
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@zeus-js/component-analyzer": "0.1.0-beta.
|
|
39
|
+
"@zeus-js/component-analyzer": "0.1.0-beta.4"
|
|
40
40
|
},
|
|
41
41
|
"keywords": [
|
|
42
42
|
"zeus",
|