@weasel-js/forge 1.12.0 → 1.13.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -5
- package/dist/{FrameController-CdnaIo4C.d.ts → FrameController-Tv3jrHyT.d.ts} +2 -2
- package/dist/{chunk-WMGEO5M6.js → chunk-35DOPXHZ.js} +72 -5
- package/dist/chunk-35DOPXHZ.js.map +1 -0
- package/dist/{chunk-ATI7FYJ7.js → chunk-BUXUWAI4.js} +42 -60
- package/dist/chunk-BUXUWAI4.js.map +1 -0
- package/dist/{chunk-YDLRSEUN.js → chunk-RKQ277P5.js} +3 -3
- package/dist/{chunk-YDLRSEUN.js.map → chunk-RKQ277P5.js.map} +1 -1
- package/dist/chunk-STF6NQ5N.js +60 -0
- package/dist/chunk-STF6NQ5N.js.map +1 -0
- package/dist/chunk-VUPN73JP.js +16 -0
- package/dist/chunk-VUPN73JP.js.map +1 -0
- package/dist/{config-Mg05Ja9r.d.ts → config-Bd6FVlh7.d.ts} +5 -5
- package/dist/frame/index.css +26 -0
- package/dist/frame/index.css.map +1 -1
- package/dist/frame/index.d.ts +4 -4
- package/dist/frame/index.js +6 -4
- package/dist/frame/index.js.map +1 -1
- package/dist/index.d.ts +28 -5
- package/dist/index.js +1 -1
- package/dist/{mountFrame-Ds3QLnBF.d.ts → mountFrame-FdJDb3TB.d.ts} +1 -1
- package/dist/shell/index.css +31 -2
- package/dist/shell/index.css.map +1 -1
- package/dist/shell/index.d.ts +5 -5
- package/dist/shell/index.js +49 -23
- package/dist/shell/index.js.map +1 -1
- package/dist/test/index.d.ts +1 -1
- package/dist/test/index.js +2 -2
- package/dist/vite/index.js +70 -15
- package/dist/vite/index.js.map +1 -1
- package/package.json +9 -9
- package/dist/chunk-ATI7FYJ7.js.map +0 -1
- package/dist/chunk-WEQSLPKT.js +0 -9
- package/dist/chunk-WEQSLPKT.js.map +0 -1
- package/dist/chunk-WMGEO5M6.js.map +0 -1
package/dist/test/index.d.ts
CHANGED
package/dist/test/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { StoryTrial } from '../chunk-
|
|
1
|
+
import { StoryTrial } from '../chunk-RKQ277P5.js';
|
|
2
2
|
import '../chunk-3BAM6M26.js';
|
|
3
|
-
import { loadStories } from '../chunk-
|
|
3
|
+
import { loadStories } from '../chunk-35DOPXHZ.js';
|
|
4
4
|
import '../chunk-L5XM5VKB.js';
|
|
5
5
|
import '../chunk-5WS67HMU.js';
|
|
6
6
|
import '../chunk-KEQBGDUZ.js';
|
package/dist/vite/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CAPTURE_PAGES, DEFAULT_TITLE, CAPTURE_PATH, parsePayload, messageOf } from '../chunk-ORMMZ5PV.js';
|
|
2
|
-
import {
|
|
2
|
+
import { byComponent } from '../chunk-STF6NQ5N.js';
|
|
3
|
+
import { isGallery } from '../chunk-VUPN73JP.js';
|
|
3
4
|
import { PROP_ARG_TYPES_EXPORT, storyNameFromExport, storyId } from '../chunk-5WS67HMU.js';
|
|
4
5
|
import { readFileSync, mkdtempSync, existsSync, mkdirSync, writeFileSync, globSync, statSync, watch, rmSync } from 'fs';
|
|
5
6
|
import { resolve, sep, relative, join, dirname, basename, matchesGlob, posix } from 'path';
|
|
@@ -1022,36 +1023,89 @@ function componentProps(tsm, checker, source) {
|
|
|
1022
1023
|
}
|
|
1023
1024
|
function propTable(tsm, checker, props, at, skipped) {
|
|
1024
1025
|
const argTypes = {};
|
|
1025
|
-
const
|
|
1026
|
+
const reading = { tsm, checker, at, skipped, sources: /* @__PURE__ */ new Set() };
|
|
1026
1027
|
for (const prop2 of checker.getPropertiesOfType(checker.getApparentType(props))) {
|
|
1027
|
-
const files = (prop2
|
|
1028
|
+
const files = declaredIn(prop2);
|
|
1028
1029
|
if (files.length > 0 && files.every(skipped)) continue;
|
|
1029
1030
|
const argType = controlFor(
|
|
1030
|
-
|
|
1031
|
+
reading,
|
|
1031
1032
|
checker.getNonNullableType(checker.getTypeOfSymbolAtLocation(prop2, at)),
|
|
1032
1033
|
() => writtenOrder(tsm, checker, prop2)
|
|
1033
1034
|
);
|
|
1034
1035
|
if (!argType) continue;
|
|
1035
1036
|
const description = tsm.displayPartsToString(prop2.getDocumentationComment(checker)).replace(/\s+/g, " ").trim();
|
|
1036
1037
|
argTypes[prop2.getName()] = description ? { ...argType, description } : argType;
|
|
1037
|
-
|
|
1038
|
+
record(reading, files);
|
|
1038
1039
|
}
|
|
1039
|
-
return { argTypes, sources: [...sources] };
|
|
1040
|
+
return { argTypes, sources: [...reading.sources] };
|
|
1040
1041
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1042
|
+
var declaredIn = (symbol) => (symbol.getDeclarations() ?? []).map((declaration) => declaration.getSourceFile().fileName);
|
|
1043
|
+
var IN_PACKAGES = /[\\/]node_modules[\\/]/;
|
|
1044
|
+
function record({ sources }, files) {
|
|
1045
|
+
for (const file of files) if (!IN_PACKAGES.test(file)) sources.add(file);
|
|
1046
|
+
}
|
|
1047
|
+
function controlFor(reading, type, written) {
|
|
1048
|
+
const { TypeFlags } = reading.tsm;
|
|
1043
1049
|
const parts = type.isUnion() ? type.types : [type];
|
|
1044
|
-
|
|
1045
|
-
if (
|
|
1046
|
-
if (type.flags & TypeFlags.String) return { control: { type: "text" } };
|
|
1050
|
+
if (parts.every((part) => part.flags & TypeFlags.BooleanLike)) return { control: { type: "boolean" } };
|
|
1051
|
+
if (parts.some((part) => part.flags & TypeFlags.String)) return { control: { type: "text" } };
|
|
1047
1052
|
if (type.flags & TypeFlags.Number) return { control: { type: "number" } };
|
|
1048
|
-
|
|
1049
|
-
|
|
1053
|
+
const options = literalsOf(reading, parts);
|
|
1054
|
+
if (options.length > 1) {
|
|
1050
1055
|
const order = written();
|
|
1051
1056
|
const same = order?.length === options.length && options.every((option) => order.includes(option));
|
|
1052
1057
|
return { options: same ? order : options };
|
|
1053
1058
|
}
|
|
1054
|
-
|
|
1059
|
+
const shape = shapeOf(reading, type, 0);
|
|
1060
|
+
return shape && shape.name !== "enum" && !(shape.name in SCALARS) ? { control: "object", type: shape } : null;
|
|
1061
|
+
}
|
|
1062
|
+
var SCALARS = { boolean: true, string: true, number: true };
|
|
1063
|
+
function literalsOf({ tsm }, parts) {
|
|
1064
|
+
return parts.filter((part) => part.flags & tsm.TypeFlags.StringLiteral).map((part) => part.value);
|
|
1065
|
+
}
|
|
1066
|
+
var MAX_DEPTH2 = 4;
|
|
1067
|
+
function shapeOf(reading, type, depth) {
|
|
1068
|
+
const { tsm, checker } = reading;
|
|
1069
|
+
const { TypeFlags } = tsm;
|
|
1070
|
+
if (depth > MAX_DEPTH2) return null;
|
|
1071
|
+
const whole = checker.getNonNullableType(type);
|
|
1072
|
+
const parts = whole.isUnion() ? whole.types : [whole];
|
|
1073
|
+
if (parts.length === 0) return null;
|
|
1074
|
+
if (parts.every((part) => part.flags & TypeFlags.BooleanLike)) return { name: "boolean" };
|
|
1075
|
+
if (parts.some((part) => part.flags & TypeFlags.String)) return { name: "string" };
|
|
1076
|
+
if (whole.flags & TypeFlags.Number) return { name: "number" };
|
|
1077
|
+
const literals = literalsOf(reading, parts);
|
|
1078
|
+
if (literals.length === parts.length || literals.length > 1) return { name: "enum", value: literals };
|
|
1079
|
+
if (parts.length > 1) {
|
|
1080
|
+
const members = parts.map((part) => shapeOf(reading, part, depth + 1));
|
|
1081
|
+
return members.every((member) => member?.name === "object") ? { name: "union", value: members } : null;
|
|
1082
|
+
}
|
|
1083
|
+
if (checker.isArrayType(whole)) {
|
|
1084
|
+
const [item] = checker.getTypeArguments(whole);
|
|
1085
|
+
const shape = item && shapeOf(reading, item, depth + 1);
|
|
1086
|
+
return shape ? { name: "array", value: shape } : null;
|
|
1087
|
+
}
|
|
1088
|
+
if (checker.isTupleType(whole)) {
|
|
1089
|
+
const items = checker.getTypeArguments(whole).map((item) => shapeOf(reading, item, depth + 1));
|
|
1090
|
+
const [first] = items;
|
|
1091
|
+
const same = first && items.every((item) => JSON.stringify(item) === JSON.stringify(first));
|
|
1092
|
+
return same ? { name: "array", value: first } : null;
|
|
1093
|
+
}
|
|
1094
|
+
if (!(whole.flags & (TypeFlags.Object | TypeFlags.Intersection))) return null;
|
|
1095
|
+
if (whole.getCallSignatures().length > 0 || whole.getConstructSignatures().length > 0) return null;
|
|
1096
|
+
if (checker.getIndexInfosOfType(whole).length > 0) return null;
|
|
1097
|
+
const declared = (whole.getSymbol() ?? whole.aliasSymbol)?.getDeclarations() ?? [];
|
|
1098
|
+
if (declared.some((declaration) => IN_PACKAGES.test(declaration.getSourceFile().fileName))) return null;
|
|
1099
|
+
const fields = {};
|
|
1100
|
+
for (const prop2 of checker.getPropertiesOfType(whole)) {
|
|
1101
|
+
const files = declaredIn(prop2);
|
|
1102
|
+
if (files.some((file) => IN_PACKAGES.test(file) || reading.skipped(file))) return null;
|
|
1103
|
+
const field = shapeOf(reading, checker.getTypeOfSymbolAtLocation(prop2, reading.at), depth + 1);
|
|
1104
|
+
if (field) fields[prop2.getName()] = field;
|
|
1105
|
+
else if (!(prop2.flags & tsm.SymbolFlags.Optional)) return null;
|
|
1106
|
+
record(reading, files);
|
|
1107
|
+
}
|
|
1108
|
+
return Object.keys(fields).length > 0 ? { name: "object", value: fields } : null;
|
|
1055
1109
|
}
|
|
1056
1110
|
function writtenOrder(tsm, checker, prop2) {
|
|
1057
1111
|
const [declaration, ...others] = prop2.getDeclarations() ?? [];
|
|
@@ -1078,6 +1132,7 @@ function writtenOrder(tsm, checker, prop2) {
|
|
|
1078
1132
|
if (alias && rest.length === 0 && tsm.isTypeAliasDeclaration(alias) && !alias.typeParameters) {
|
|
1079
1133
|
return literals(alias.type);
|
|
1080
1134
|
}
|
|
1135
|
+
if (target && target.flags & (tsm.SymbolFlags.Interface | tsm.SymbolFlags.Class)) return [];
|
|
1081
1136
|
}
|
|
1082
1137
|
return null;
|
|
1083
1138
|
};
|
|
@@ -1730,7 +1785,7 @@ function forge(options) {
|
|
|
1730
1785
|
);
|
|
1731
1786
|
return byFile;
|
|
1732
1787
|
};
|
|
1733
|
-
const index = () => [...files().values()].flat();
|
|
1788
|
+
const index = () => byComponent([...files().values()].flat());
|
|
1734
1789
|
const settle = async (targets, resolveImport) => {
|
|
1735
1790
|
const decide = createWrapperResolver((file) => readFileSync(file, "utf8"));
|
|
1736
1791
|
const current = files();
|