@wzyjs/cli 0.3.16 → 0.3.18

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.
Files changed (2) hide show
  1. package/dist/index.js +958 -0
  2. package/package.json +8 -4
package/dist/index.js CHANGED
@@ -738,10 +738,968 @@ var summary_default = (cli) => {
738
738
  cli.command("s", "\u751F\u6210\u9879\u76EE\u7684\u4EE3\u7801\u6458\u8981").action(script_default2);
739
739
  };
740
740
 
741
+ // src/commands/scrap/juejin.ts
742
+ import { fetch } from "undici";
743
+
744
+ // ../../node_modules/superjson/dist/double-indexed-kv.js
745
+ class DoubleIndexedKV {
746
+ constructor() {
747
+ this.keyToValue = new Map;
748
+ this.valueToKey = new Map;
749
+ }
750
+ set(key, value) {
751
+ this.keyToValue.set(key, value);
752
+ this.valueToKey.set(value, key);
753
+ }
754
+ getByKey(key) {
755
+ return this.keyToValue.get(key);
756
+ }
757
+ getByValue(value) {
758
+ return this.valueToKey.get(value);
759
+ }
760
+ clear() {
761
+ this.keyToValue.clear();
762
+ this.valueToKey.clear();
763
+ }
764
+ }
765
+
766
+ // ../../node_modules/superjson/dist/registry.js
767
+ class Registry {
768
+ constructor(generateIdentifier) {
769
+ this.generateIdentifier = generateIdentifier;
770
+ this.kv = new DoubleIndexedKV;
771
+ }
772
+ register(value, identifier) {
773
+ if (this.kv.getByValue(value)) {
774
+ return;
775
+ }
776
+ if (!identifier) {
777
+ identifier = this.generateIdentifier(value);
778
+ }
779
+ this.kv.set(identifier, value);
780
+ }
781
+ clear() {
782
+ this.kv.clear();
783
+ }
784
+ getIdentifier(value) {
785
+ return this.kv.getByValue(value);
786
+ }
787
+ getValue(identifier) {
788
+ return this.kv.getByKey(identifier);
789
+ }
790
+ }
791
+
792
+ // ../../node_modules/superjson/dist/class-registry.js
793
+ class ClassRegistry extends Registry {
794
+ constructor() {
795
+ super((c) => c.name);
796
+ this.classToAllowedProps = new Map;
797
+ }
798
+ register(value, options) {
799
+ if (typeof options === "object") {
800
+ if (options.allowProps) {
801
+ this.classToAllowedProps.set(value, options.allowProps);
802
+ }
803
+ super.register(value, options.identifier);
804
+ } else {
805
+ super.register(value, options);
806
+ }
807
+ }
808
+ getAllowedProps(value) {
809
+ return this.classToAllowedProps.get(value);
810
+ }
811
+ }
812
+
813
+ // ../../node_modules/superjson/dist/util.js
814
+ function valuesOfObj(record) {
815
+ if ("values" in Object) {
816
+ return Object.values(record);
817
+ }
818
+ const values = [];
819
+ for (const key in record) {
820
+ if (record.hasOwnProperty(key)) {
821
+ values.push(record[key]);
822
+ }
823
+ }
824
+ return values;
825
+ }
826
+ function find(record, predicate) {
827
+ const values = valuesOfObj(record);
828
+ if ("find" in values) {
829
+ return values.find(predicate);
830
+ }
831
+ const valuesNotNever = values;
832
+ for (let i = 0;i < valuesNotNever.length; i++) {
833
+ const value = valuesNotNever[i];
834
+ if (predicate(value)) {
835
+ return value;
836
+ }
837
+ }
838
+ return;
839
+ }
840
+ function forEach(record, run) {
841
+ Object.entries(record).forEach(([key, value]) => run(value, key));
842
+ }
843
+ function includes(arr, value) {
844
+ return arr.indexOf(value) !== -1;
845
+ }
846
+ function findArr(record, predicate) {
847
+ for (let i = 0;i < record.length; i++) {
848
+ const value = record[i];
849
+ if (predicate(value)) {
850
+ return value;
851
+ }
852
+ }
853
+ return;
854
+ }
855
+
856
+ // ../../node_modules/superjson/dist/custom-transformer-registry.js
857
+ class CustomTransformerRegistry {
858
+ constructor() {
859
+ this.transfomers = {};
860
+ }
861
+ register(transformer) {
862
+ this.transfomers[transformer.name] = transformer;
863
+ }
864
+ findApplicable(v) {
865
+ return find(this.transfomers, (transformer) => transformer.isApplicable(v));
866
+ }
867
+ findByName(name) {
868
+ return this.transfomers[name];
869
+ }
870
+ }
871
+
872
+ // ../../node_modules/superjson/dist/is.js
873
+ var getType = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
874
+ var isUndefined = (payload) => typeof payload === "undefined";
875
+ var isNull = (payload) => payload === null;
876
+ var isPlainObject = (payload) => {
877
+ if (typeof payload !== "object" || payload === null)
878
+ return false;
879
+ if (payload === Object.prototype)
880
+ return false;
881
+ if (Object.getPrototypeOf(payload) === null)
882
+ return true;
883
+ return Object.getPrototypeOf(payload) === Object.prototype;
884
+ };
885
+ var isEmptyObject = (payload) => isPlainObject(payload) && Object.keys(payload).length === 0;
886
+ var isArray = (payload) => Array.isArray(payload);
887
+ var isString = (payload) => typeof payload === "string";
888
+ var isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
889
+ var isBoolean = (payload) => typeof payload === "boolean";
890
+ var isRegExp = (payload) => payload instanceof RegExp;
891
+ var isMap = (payload) => payload instanceof Map;
892
+ var isSet = (payload) => payload instanceof Set;
893
+ var isSymbol = (payload) => getType(payload) === "Symbol";
894
+ var isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
895
+ var isError = (payload) => payload instanceof Error;
896
+ var isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
897
+ var isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
898
+ var isBigint = (payload) => typeof payload === "bigint";
899
+ var isInfinite = (payload) => payload === Infinity || payload === -Infinity;
900
+ var isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
901
+ var isURL = (payload) => payload instanceof URL;
902
+
903
+ // ../../node_modules/superjson/dist/pathstringifier.js
904
+ var escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
905
+ var stringifyPath = (path2) => path2.map(String).map(escapeKey).join(".");
906
+ var parsePath = (string, legacyPaths) => {
907
+ const result = [];
908
+ let segment = "";
909
+ for (let i = 0;i < string.length; i++) {
910
+ let char = string.charAt(i);
911
+ if (!legacyPaths && char === "\\") {
912
+ const escaped = string.charAt(i + 1);
913
+ if (escaped === "\\") {
914
+ segment += "\\";
915
+ i++;
916
+ continue;
917
+ } else if (escaped !== ".") {
918
+ throw Error("invalid path");
919
+ }
920
+ }
921
+ const isEscapedDot = char === "\\" && string.charAt(i + 1) === ".";
922
+ if (isEscapedDot) {
923
+ segment += ".";
924
+ i++;
925
+ continue;
926
+ }
927
+ const isEndOfSegment = char === ".";
928
+ if (isEndOfSegment) {
929
+ result.push(segment);
930
+ segment = "";
931
+ continue;
932
+ }
933
+ segment += char;
934
+ }
935
+ const lastSegment = segment;
936
+ result.push(lastSegment);
937
+ return result;
938
+ };
939
+
940
+ // ../../node_modules/superjson/dist/transformer.js
941
+ function simpleTransformation(isApplicable, annotation, transform, untransform) {
942
+ return {
943
+ isApplicable,
944
+ annotation,
945
+ transform,
946
+ untransform
947
+ };
948
+ }
949
+ var simpleRules = [
950
+ simpleTransformation(isUndefined, "undefined", () => null, () => {
951
+ return;
952
+ }),
953
+ simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
954
+ if (typeof BigInt !== "undefined") {
955
+ return BigInt(v);
956
+ }
957
+ console.error("Please add a BigInt polyfill.");
958
+ return v;
959
+ }),
960
+ simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
961
+ simpleTransformation(isError, "Error", (v, superJson) => {
962
+ const baseError = {
963
+ name: v.name,
964
+ message: v.message
965
+ };
966
+ if ("cause" in v) {
967
+ baseError.cause = v.cause;
968
+ }
969
+ superJson.allowedErrorProps.forEach((prop) => {
970
+ baseError[prop] = v[prop];
971
+ });
972
+ return baseError;
973
+ }, (v, superJson) => {
974
+ const e = new Error(v.message, { cause: v.cause });
975
+ e.name = v.name;
976
+ e.stack = v.stack;
977
+ superJson.allowedErrorProps.forEach((prop) => {
978
+ e[prop] = v[prop];
979
+ });
980
+ return e;
981
+ }),
982
+ simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
983
+ const body = regex.slice(1, regex.lastIndexOf("/"));
984
+ const flags = regex.slice(regex.lastIndexOf("/") + 1);
985
+ return new RegExp(body, flags);
986
+ }),
987
+ simpleTransformation(isSet, "set", (v) => [...v.values()], (v) => new Set(v)),
988
+ simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
989
+ simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
990
+ if (isNaNValue(v)) {
991
+ return "NaN";
992
+ }
993
+ if (v > 0) {
994
+ return "Infinity";
995
+ } else {
996
+ return "-Infinity";
997
+ }
998
+ }, Number),
999
+ simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
1000
+ return "-0";
1001
+ }, Number),
1002
+ simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
1003
+ ];
1004
+ function compositeTransformation(isApplicable, annotation, transform, untransform) {
1005
+ return {
1006
+ isApplicable,
1007
+ annotation,
1008
+ transform,
1009
+ untransform
1010
+ };
1011
+ }
1012
+ var symbolRule = compositeTransformation((s, superJson) => {
1013
+ if (isSymbol(s)) {
1014
+ const isRegistered = !!superJson.symbolRegistry.getIdentifier(s);
1015
+ return isRegistered;
1016
+ }
1017
+ return false;
1018
+ }, (s, superJson) => {
1019
+ const identifier = superJson.symbolRegistry.getIdentifier(s);
1020
+ return ["symbol", identifier];
1021
+ }, (v) => v.description, (_, a, superJson) => {
1022
+ const value = superJson.symbolRegistry.getValue(a[1]);
1023
+ if (!value) {
1024
+ throw new Error("Trying to deserialize unknown symbol");
1025
+ }
1026
+ return value;
1027
+ });
1028
+ var constructorToName = [
1029
+ Int8Array,
1030
+ Uint8Array,
1031
+ Int16Array,
1032
+ Uint16Array,
1033
+ Int32Array,
1034
+ Uint32Array,
1035
+ Float32Array,
1036
+ Float64Array,
1037
+ Uint8ClampedArray
1038
+ ].reduce((obj, ctor) => {
1039
+ obj[ctor.name] = ctor;
1040
+ return obj;
1041
+ }, {});
1042
+ var typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
1043
+ const ctor = constructorToName[a[1]];
1044
+ if (!ctor) {
1045
+ throw new Error("Trying to deserialize unknown typed array");
1046
+ }
1047
+ return new ctor(v);
1048
+ });
1049
+ function isInstanceOfRegisteredClass(potentialClass, superJson) {
1050
+ if (potentialClass?.constructor) {
1051
+ const isRegistered = !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
1052
+ return isRegistered;
1053
+ }
1054
+ return false;
1055
+ }
1056
+ var classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
1057
+ const identifier = superJson.classRegistry.getIdentifier(clazz.constructor);
1058
+ return ["class", identifier];
1059
+ }, (clazz, superJson) => {
1060
+ const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
1061
+ if (!allowedProps) {
1062
+ return { ...clazz };
1063
+ }
1064
+ const result = {};
1065
+ allowedProps.forEach((prop) => {
1066
+ result[prop] = clazz[prop];
1067
+ });
1068
+ return result;
1069
+ }, (v, a, superJson) => {
1070
+ const clazz = superJson.classRegistry.getValue(a[1]);
1071
+ if (!clazz) {
1072
+ throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
1073
+ }
1074
+ return Object.assign(Object.create(clazz.prototype), v);
1075
+ });
1076
+ var customRule = compositeTransformation((value, superJson) => {
1077
+ return !!superJson.customTransformerRegistry.findApplicable(value);
1078
+ }, (value, superJson) => {
1079
+ const transformer = superJson.customTransformerRegistry.findApplicable(value);
1080
+ return ["custom", transformer.name];
1081
+ }, (value, superJson) => {
1082
+ const transformer = superJson.customTransformerRegistry.findApplicable(value);
1083
+ return transformer.serialize(value);
1084
+ }, (v, a, superJson) => {
1085
+ const transformer = superJson.customTransformerRegistry.findByName(a[1]);
1086
+ if (!transformer) {
1087
+ throw new Error("Trying to deserialize unknown custom value");
1088
+ }
1089
+ return transformer.deserialize(v);
1090
+ });
1091
+ var compositeRules = [classRule, symbolRule, customRule, typedArrayRule];
1092
+ var transformValue = (value, superJson) => {
1093
+ const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
1094
+ if (applicableCompositeRule) {
1095
+ return {
1096
+ value: applicableCompositeRule.transform(value, superJson),
1097
+ type: applicableCompositeRule.annotation(value, superJson)
1098
+ };
1099
+ }
1100
+ const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
1101
+ if (applicableSimpleRule) {
1102
+ return {
1103
+ value: applicableSimpleRule.transform(value, superJson),
1104
+ type: applicableSimpleRule.annotation
1105
+ };
1106
+ }
1107
+ return;
1108
+ };
1109
+ var simpleRulesByAnnotation = {};
1110
+ simpleRules.forEach((rule) => {
1111
+ simpleRulesByAnnotation[rule.annotation] = rule;
1112
+ });
1113
+ var untransformValue = (json, type, superJson) => {
1114
+ if (isArray(type)) {
1115
+ switch (type[0]) {
1116
+ case "symbol":
1117
+ return symbolRule.untransform(json, type, superJson);
1118
+ case "class":
1119
+ return classRule.untransform(json, type, superJson);
1120
+ case "custom":
1121
+ return customRule.untransform(json, type, superJson);
1122
+ case "typed-array":
1123
+ return typedArrayRule.untransform(json, type, superJson);
1124
+ default:
1125
+ throw new Error("Unknown transformation: " + type);
1126
+ }
1127
+ } else {
1128
+ const transformation = simpleRulesByAnnotation[type];
1129
+ if (!transformation) {
1130
+ throw new Error("Unknown transformation: " + type);
1131
+ }
1132
+ return transformation.untransform(json, superJson);
1133
+ }
1134
+ };
1135
+
1136
+ // ../../node_modules/superjson/dist/accessDeep.js
1137
+ var getNthKey = (value, n) => {
1138
+ if (n > value.size)
1139
+ throw new Error("index out of bounds");
1140
+ const keys = value.keys();
1141
+ while (n > 0) {
1142
+ keys.next();
1143
+ n--;
1144
+ }
1145
+ return keys.next().value;
1146
+ };
1147
+ function validatePath(path2) {
1148
+ if (includes(path2, "__proto__")) {
1149
+ throw new Error("__proto__ is not allowed as a property");
1150
+ }
1151
+ if (includes(path2, "prototype")) {
1152
+ throw new Error("prototype is not allowed as a property");
1153
+ }
1154
+ if (includes(path2, "constructor")) {
1155
+ throw new Error("constructor is not allowed as a property");
1156
+ }
1157
+ }
1158
+ var getDeep = (object, path2) => {
1159
+ validatePath(path2);
1160
+ for (let i = 0;i < path2.length; i++) {
1161
+ const key = path2[i];
1162
+ if (isSet(object)) {
1163
+ object = getNthKey(object, +key);
1164
+ } else if (isMap(object)) {
1165
+ const row = +key;
1166
+ const type = +path2[++i] === 0 ? "key" : "value";
1167
+ const keyOfRow = getNthKey(object, row);
1168
+ switch (type) {
1169
+ case "key":
1170
+ object = keyOfRow;
1171
+ break;
1172
+ case "value":
1173
+ object = object.get(keyOfRow);
1174
+ break;
1175
+ }
1176
+ } else {
1177
+ object = object[key];
1178
+ }
1179
+ }
1180
+ return object;
1181
+ };
1182
+ var setDeep = (object, path2, mapper) => {
1183
+ validatePath(path2);
1184
+ if (path2.length === 0) {
1185
+ return mapper(object);
1186
+ }
1187
+ let parent = object;
1188
+ for (let i = 0;i < path2.length - 1; i++) {
1189
+ const key = path2[i];
1190
+ if (isArray(parent)) {
1191
+ const index = +key;
1192
+ parent = parent[index];
1193
+ } else if (isPlainObject(parent)) {
1194
+ parent = parent[key];
1195
+ } else if (isSet(parent)) {
1196
+ const row = +key;
1197
+ parent = getNthKey(parent, row);
1198
+ } else if (isMap(parent)) {
1199
+ const isEnd = i === path2.length - 2;
1200
+ if (isEnd) {
1201
+ break;
1202
+ }
1203
+ const row = +key;
1204
+ const type = +path2[++i] === 0 ? "key" : "value";
1205
+ const keyOfRow = getNthKey(parent, row);
1206
+ switch (type) {
1207
+ case "key":
1208
+ parent = keyOfRow;
1209
+ break;
1210
+ case "value":
1211
+ parent = parent.get(keyOfRow);
1212
+ break;
1213
+ }
1214
+ }
1215
+ }
1216
+ const lastKey = path2[path2.length - 1];
1217
+ if (isArray(parent)) {
1218
+ parent[+lastKey] = mapper(parent[+lastKey]);
1219
+ } else if (isPlainObject(parent)) {
1220
+ parent[lastKey] = mapper(parent[lastKey]);
1221
+ }
1222
+ if (isSet(parent)) {
1223
+ const oldValue = getNthKey(parent, +lastKey);
1224
+ const newValue = mapper(oldValue);
1225
+ if (oldValue !== newValue) {
1226
+ parent.delete(oldValue);
1227
+ parent.add(newValue);
1228
+ }
1229
+ }
1230
+ if (isMap(parent)) {
1231
+ const row = +path2[path2.length - 2];
1232
+ const keyToRow = getNthKey(parent, row);
1233
+ const type = +lastKey === 0 ? "key" : "value";
1234
+ switch (type) {
1235
+ case "key": {
1236
+ const newKey = mapper(keyToRow);
1237
+ parent.set(newKey, parent.get(keyToRow));
1238
+ if (newKey !== keyToRow) {
1239
+ parent.delete(keyToRow);
1240
+ }
1241
+ break;
1242
+ }
1243
+ case "value": {
1244
+ parent.set(keyToRow, mapper(parent.get(keyToRow)));
1245
+ break;
1246
+ }
1247
+ }
1248
+ }
1249
+ return object;
1250
+ };
1251
+
1252
+ // ../../node_modules/superjson/dist/plainer.js
1253
+ var enableLegacyPaths = (version) => version < 1;
1254
+ function traverse(tree, walker, version, origin = []) {
1255
+ if (!tree) {
1256
+ return;
1257
+ }
1258
+ const legacyPaths = enableLegacyPaths(version);
1259
+ if (!isArray(tree)) {
1260
+ forEach(tree, (subtree, key) => traverse(subtree, walker, version, [
1261
+ ...origin,
1262
+ ...parsePath(key, legacyPaths)
1263
+ ]));
1264
+ return;
1265
+ }
1266
+ const [nodeValue, children] = tree;
1267
+ if (children) {
1268
+ forEach(children, (child, key) => {
1269
+ traverse(child, walker, version, [
1270
+ ...origin,
1271
+ ...parsePath(key, legacyPaths)
1272
+ ]);
1273
+ });
1274
+ }
1275
+ walker(nodeValue, origin);
1276
+ }
1277
+ function applyValueAnnotations(plain, annotations, version, superJson) {
1278
+ traverse(annotations, (type, path2) => {
1279
+ plain = setDeep(plain, path2, (v) => untransformValue(v, type, superJson));
1280
+ }, version);
1281
+ return plain;
1282
+ }
1283
+ function applyReferentialEqualityAnnotations(plain, annotations, version) {
1284
+ const legacyPaths = enableLegacyPaths(version);
1285
+ function apply(identicalPaths, path2) {
1286
+ const object = getDeep(plain, parsePath(path2, legacyPaths));
1287
+ identicalPaths.map((path3) => parsePath(path3, legacyPaths)).forEach((identicalObjectPath) => {
1288
+ plain = setDeep(plain, identicalObjectPath, () => object);
1289
+ });
1290
+ }
1291
+ if (isArray(annotations)) {
1292
+ const [root, other] = annotations;
1293
+ root.forEach((identicalPath) => {
1294
+ plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
1295
+ });
1296
+ if (other) {
1297
+ forEach(other, apply);
1298
+ }
1299
+ } else {
1300
+ forEach(annotations, apply);
1301
+ }
1302
+ return plain;
1303
+ }
1304
+ var isDeep = (object, superJson) => isPlainObject(object) || isArray(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
1305
+ function addIdentity(object, path2, identities) {
1306
+ const existingSet = identities.get(object);
1307
+ if (existingSet) {
1308
+ existingSet.push(path2);
1309
+ } else {
1310
+ identities.set(object, [path2]);
1311
+ }
1312
+ }
1313
+ function generateReferentialEqualityAnnotations(identitites, dedupe) {
1314
+ const result = {};
1315
+ let rootEqualityPaths = undefined;
1316
+ identitites.forEach((paths) => {
1317
+ if (paths.length <= 1) {
1318
+ return;
1319
+ }
1320
+ if (!dedupe) {
1321
+ paths = paths.map((path2) => path2.map(String)).sort((a, b) => a.length - b.length);
1322
+ }
1323
+ const [representativePath, ...identicalPaths] = paths;
1324
+ if (representativePath.length === 0) {
1325
+ rootEqualityPaths = identicalPaths.map(stringifyPath);
1326
+ } else {
1327
+ result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
1328
+ }
1329
+ });
1330
+ if (rootEqualityPaths) {
1331
+ if (isEmptyObject(result)) {
1332
+ return [rootEqualityPaths];
1333
+ } else {
1334
+ return [rootEqualityPaths, result];
1335
+ }
1336
+ } else {
1337
+ return isEmptyObject(result) ? undefined : result;
1338
+ }
1339
+ }
1340
+ var walker = (object, identities, superJson, dedupe, path2 = [], objectsInThisPath = [], seenObjects = new Map) => {
1341
+ const primitive = isPrimitive(object);
1342
+ if (!primitive) {
1343
+ addIdentity(object, path2, identities);
1344
+ const seen = seenObjects.get(object);
1345
+ if (seen) {
1346
+ return dedupe ? {
1347
+ transformedValue: null
1348
+ } : seen;
1349
+ }
1350
+ }
1351
+ if (!isDeep(object, superJson)) {
1352
+ const transformed2 = transformValue(object, superJson);
1353
+ const result2 = transformed2 ? {
1354
+ transformedValue: transformed2.value,
1355
+ annotations: [transformed2.type]
1356
+ } : {
1357
+ transformedValue: object
1358
+ };
1359
+ if (!primitive) {
1360
+ seenObjects.set(object, result2);
1361
+ }
1362
+ return result2;
1363
+ }
1364
+ if (includes(objectsInThisPath, object)) {
1365
+ return {
1366
+ transformedValue: null
1367
+ };
1368
+ }
1369
+ const transformationResult = transformValue(object, superJson);
1370
+ const transformed = transformationResult?.value ?? object;
1371
+ const transformedValue = isArray(transformed) ? [] : {};
1372
+ const innerAnnotations = {};
1373
+ forEach(transformed, (value, index) => {
1374
+ if (index === "__proto__" || index === "constructor" || index === "prototype") {
1375
+ throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
1376
+ }
1377
+ const recursiveResult = walker(value, identities, superJson, dedupe, [...path2, index], [...objectsInThisPath, object], seenObjects);
1378
+ transformedValue[index] = recursiveResult.transformedValue;
1379
+ if (isArray(recursiveResult.annotations)) {
1380
+ innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
1381
+ } else if (isPlainObject(recursiveResult.annotations)) {
1382
+ forEach(recursiveResult.annotations, (tree, key) => {
1383
+ innerAnnotations[escapeKey(index) + "." + key] = tree;
1384
+ });
1385
+ }
1386
+ });
1387
+ const result = isEmptyObject(innerAnnotations) ? {
1388
+ transformedValue,
1389
+ annotations: transformationResult ? [transformationResult.type] : undefined
1390
+ } : {
1391
+ transformedValue,
1392
+ annotations: transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
1393
+ };
1394
+ if (!primitive) {
1395
+ seenObjects.set(object, result);
1396
+ }
1397
+ return result;
1398
+ };
1399
+
1400
+ // ../../node_modules/is-what/dist/getType.js
1401
+ function getType2(payload) {
1402
+ return Object.prototype.toString.call(payload).slice(8, -1);
1403
+ }
1404
+
1405
+ // ../../node_modules/is-what/dist/isArray.js
1406
+ function isArray2(payload) {
1407
+ return getType2(payload) === "Array";
1408
+ }
1409
+ // ../../node_modules/is-what/dist/isPlainObject.js
1410
+ function isPlainObject2(payload) {
1411
+ if (getType2(payload) !== "Object")
1412
+ return false;
1413
+ const prototype = Object.getPrototypeOf(payload);
1414
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
1415
+ }
1416
+ // ../../node_modules/copy-anything/dist/index.js
1417
+ function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
1418
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
1419
+ if (propType === "enumerable")
1420
+ carry[key] = newVal;
1421
+ if (includeNonenumerable && propType === "nonenumerable") {
1422
+ Object.defineProperty(carry, key, {
1423
+ value: newVal,
1424
+ enumerable: false,
1425
+ writable: true,
1426
+ configurable: true
1427
+ });
1428
+ }
1429
+ }
1430
+ function copy(target, options = {}) {
1431
+ if (isArray2(target)) {
1432
+ return target.map((item) => copy(item, options));
1433
+ }
1434
+ if (!isPlainObject2(target)) {
1435
+ return target;
1436
+ }
1437
+ const props = Object.getOwnPropertyNames(target);
1438
+ const symbols = Object.getOwnPropertySymbols(target);
1439
+ return [...props, ...symbols].reduce((carry, key) => {
1440
+ if (key === "__proto__")
1441
+ return carry;
1442
+ if (isArray2(options.props) && !options.props.includes(key)) {
1443
+ return carry;
1444
+ }
1445
+ const val = target[key];
1446
+ const newVal = copy(val, options);
1447
+ assignProp(carry, key, newVal, target, options.nonenumerable);
1448
+ return carry;
1449
+ }, {});
1450
+ }
1451
+
1452
+ // ../../node_modules/superjson/dist/index.js
1453
+ class SuperJSON {
1454
+ constructor({ dedupe = false } = {}) {
1455
+ this.classRegistry = new ClassRegistry;
1456
+ this.symbolRegistry = new Registry((s) => s.description ?? "");
1457
+ this.customTransformerRegistry = new CustomTransformerRegistry;
1458
+ this.allowedErrorProps = [];
1459
+ this.dedupe = dedupe;
1460
+ }
1461
+ serialize(object) {
1462
+ const identities = new Map;
1463
+ const output = walker(object, identities, this, this.dedupe);
1464
+ const res = {
1465
+ json: output.transformedValue
1466
+ };
1467
+ if (output.annotations) {
1468
+ res.meta = {
1469
+ ...res.meta,
1470
+ values: output.annotations
1471
+ };
1472
+ }
1473
+ const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
1474
+ if (equalityAnnotations) {
1475
+ res.meta = {
1476
+ ...res.meta,
1477
+ referentialEqualities: equalityAnnotations
1478
+ };
1479
+ }
1480
+ if (res.meta)
1481
+ res.meta.v = 1;
1482
+ return res;
1483
+ }
1484
+ deserialize(payload, options) {
1485
+ const { json, meta } = payload;
1486
+ let result = options?.inPlace ? json : copy(json);
1487
+ if (meta?.values) {
1488
+ result = applyValueAnnotations(result, meta.values, meta.v ?? 0, this);
1489
+ }
1490
+ if (meta?.referentialEqualities) {
1491
+ result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, meta.v ?? 0);
1492
+ }
1493
+ return result;
1494
+ }
1495
+ stringify(object) {
1496
+ return JSON.stringify(this.serialize(object));
1497
+ }
1498
+ parse(string) {
1499
+ return this.deserialize(JSON.parse(string), { inPlace: true });
1500
+ }
1501
+ registerClass(v, options) {
1502
+ this.classRegistry.register(v, options);
1503
+ }
1504
+ registerSymbol(v, identifier) {
1505
+ this.symbolRegistry.register(v, identifier);
1506
+ }
1507
+ registerCustom(transformer, name) {
1508
+ this.customTransformerRegistry.register({
1509
+ name,
1510
+ ...transformer
1511
+ });
1512
+ }
1513
+ allowErrorProps(...props) {
1514
+ this.allowedErrorProps.push(...props);
1515
+ }
1516
+ }
1517
+ SuperJSON.defaultInstance = new SuperJSON;
1518
+ SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
1519
+ SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
1520
+ SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
1521
+ SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
1522
+ SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
1523
+ SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
1524
+ SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
1525
+ SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
1526
+ var dist_default2 = SuperJSON;
1527
+ var serialize = SuperJSON.serialize;
1528
+ var deserialize = SuperJSON.deserialize;
1529
+ var stringify = SuperJSON.stringify;
1530
+ var parse = SuperJSON.parse;
1531
+ var registerClass = SuperJSON.registerClass;
1532
+ var registerCustom = SuperJSON.registerCustom;
1533
+ var registerSymbol = SuperJSON.registerSymbol;
1534
+ var allowErrorProps = SuperJSON.allowErrorProps;
1535
+
1536
+ // src/commands/scrap/juejin.ts
1537
+ var url = "http://localhost:3000";
1538
+ var juejin_default = async (procedure, data) => {
1539
+ if (!procedure) {
1540
+ console.error("\u274C \u7F3A\u5C11 procedure \u53C2\u6570");
1541
+ process.exit(1);
1542
+ }
1543
+ let input = {};
1544
+ if (data) {
1545
+ try {
1546
+ input = JSON.parse(data);
1547
+ } catch (e) {
1548
+ console.error("\u274C JSON \u89E3\u6790\u5931\u8D25:", e);
1549
+ process.exit(1);
1550
+ }
1551
+ }
1552
+ if (procedure === "findMany" && input) {
1553
+ if (!input.where) {
1554
+ input.where = {};
1555
+ }
1556
+ if (input.where.isDeleted === undefined) {
1557
+ input.where.isDeleted = false;
1558
+ }
1559
+ if (!input.take) {
1560
+ input.take = 10;
1561
+ }
1562
+ if (!input.select) {
1563
+ input.select = {
1564
+ id: true,
1565
+ pinId: true,
1566
+ content: true,
1567
+ url: true,
1568
+ authorName: true,
1569
+ diggCount: true,
1570
+ commentCount: true,
1571
+ publishedAt: true
1572
+ };
1573
+ }
1574
+ }
1575
+ const baseUrl = url.replace(/\/$/, "");
1576
+ const trpcPath = `juejinPin.${procedure}`;
1577
+ try {
1578
+ const encodedInput = encodeURIComponent(dist_default2.stringify(input));
1579
+ const response = await fetch(`${baseUrl}/api/trpc/${trpcPath}?input=${encodedInput}`, {
1580
+ method: "GET"
1581
+ });
1582
+ const responseText = await response.text();
1583
+ let result;
1584
+ try {
1585
+ result = JSON.parse(responseText);
1586
+ } catch {
1587
+ console.error("\u274C \u54CD\u5E94\u4E0D\u662F JSON \u683C\u5F0F:", responseText.slice(0, 200));
1588
+ process.exit(1);
1589
+ }
1590
+ if (!response.ok) {
1591
+ console.error("\u274C \u8BF7\u6C42\u5931\u8D25:", JSON.stringify(result?.error, null, 2));
1592
+ process.exit(1);
1593
+ }
1594
+ if (result?.error) {
1595
+ console.error("\u274C tRPC \u9519\u8BEF:", JSON.stringify(result.error, null, 2));
1596
+ process.exit(1);
1597
+ }
1598
+ console.log(JSON.stringify(result?.result?.data, null, 2));
1599
+ } catch (e) {
1600
+ console.error("\u274C \u8BF7\u6C42\u5931\u8D25:", e);
1601
+ process.exit(1);
1602
+ }
1603
+ };
1604
+
1605
+ // src/commands/scrap/rss.ts
1606
+ import { fetch as fetch2 } from "undici";
1607
+ var url2 = "http://localhost:3000";
1608
+ var rss_default = async (procedure, data) => {
1609
+ if (!procedure) {
1610
+ console.error("\u274C \u7F3A\u5C11 procedure \u53C2\u6570");
1611
+ process.exit(1);
1612
+ }
1613
+ let input = {};
1614
+ if (data) {
1615
+ try {
1616
+ input = JSON.parse(data);
1617
+ } catch (e) {
1618
+ console.error("\u274C JSON \u89E3\u6790\u5931\u8D25:", e);
1619
+ process.exit(1);
1620
+ }
1621
+ }
1622
+ if (procedure === "findMany" && input) {
1623
+ if (!input.where) {
1624
+ input.where = {};
1625
+ }
1626
+ if (input.where.isDeleted === undefined) {
1627
+ input.where.isDeleted = false;
1628
+ }
1629
+ if (!input.take) {
1630
+ input.take = 10;
1631
+ }
1632
+ if (!input.select) {
1633
+ input.select = {
1634
+ id: true,
1635
+ title: true,
1636
+ description: true,
1637
+ content: true,
1638
+ link: true,
1639
+ pubDate: true,
1640
+ isRead: true,
1641
+ isStarred: true,
1642
+ isSent: true,
1643
+ isInterested: true,
1644
+ tags: true,
1645
+ summary: true,
1646
+ feedId: true
1647
+ };
1648
+ }
1649
+ }
1650
+ const baseUrl = url2.replace(/\/$/, "");
1651
+ const trpcPath = `rssItem.${procedure}`;
1652
+ try {
1653
+ const encodedInput = encodeURIComponent(dist_default2.stringify(input));
1654
+ const response = await fetch2(`${baseUrl}/api/trpc/${trpcPath}?input=${encodedInput}`, {
1655
+ method: "GET"
1656
+ });
1657
+ const responseText = await response.text();
1658
+ let result;
1659
+ try {
1660
+ result = JSON.parse(responseText);
1661
+ } catch {
1662
+ console.error("\u274C \u54CD\u5E94\u4E0D\u662F JSON \u683C\u5F0F:", responseText.slice(0, 200));
1663
+ process.exit(1);
1664
+ }
1665
+ if (!response.ok) {
1666
+ console.error("\u274C \u8BF7\u6C42\u5931\u8D25:", JSON.stringify(result?.error, null, 2));
1667
+ process.exit(1);
1668
+ }
1669
+ if (result?.error) {
1670
+ console.error("\u274C tRPC \u9519\u8BEF:", JSON.stringify(result.error, null, 2));
1671
+ process.exit(1);
1672
+ }
1673
+ console.log(JSON.stringify(result?.result?.data, null, 2));
1674
+ } catch (e) {
1675
+ console.error("\u274C \u8BF7\u6C42\u5931\u8D25:", e);
1676
+ process.exit(1);
1677
+ }
1678
+ };
1679
+
1680
+ // src/commands/scrap/index.ts
1681
+ var scrap_default = (cli) => {
1682
+ cli.command("scrap <source> [procedure] [data]", "\u6293\u53D6\u6570\u636E").action(async (source, procedure, data) => {
1683
+ switch (source) {
1684
+ case "juejin":
1685
+ await juejin_default(procedure, data);
1686
+ break;
1687
+ case "rss":
1688
+ await rss_default(procedure, data);
1689
+ break;
1690
+ default:
1691
+ console.error(`\u274C \u4E0D\u652F\u6301\u7684 source: ${source}`);
1692
+ console.log("\u652F\u6301\u7684 source: juejin, rss");
1693
+ process.exit(1);
1694
+ }
1695
+ });
1696
+ };
1697
+
741
1698
  // src/index.ts
742
1699
  var cli = dist_default();
743
1700
  merge_default(cli);
744
1701
  summary_default(cli);
1702
+ scrap_default(cli);
745
1703
  cli.help();
746
1704
  cli.version("0.0.5");
747
1705
  cli.parse();
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "@wzyjs/cli",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "description": "description",
5
5
  "author": "wzy",
6
+ "main": "index.js",
7
+ "type": "commonjs",
6
8
  "scripts": {
7
9
  "build": "bun build ./src/index.ts --outdir dist --target bun",
8
10
  "build-link": "npm run build && bun link"
9
11
  },
10
12
  "bin": {
11
- "mi": "./bin/mi.js"
13
+ "mi": "bin/mi.js"
12
14
  },
13
15
  "files": [
14
16
  "bin",
@@ -16,7 +18,9 @@
16
18
  ],
17
19
  "dependencies": {
18
20
  "cac": "^6.7.14",
19
- "fs-extra": "^10.1.0"
21
+ "fs-extra": "^10.1.0",
22
+ "superjson": "^2.2.6",
23
+ "undici": "^6.0.0"
20
24
  },
21
25
  "devDependencies": {
22
26
  "@types/fs-extra": "^9.0.13"
@@ -24,5 +28,5 @@
24
28
  "publishConfig": {
25
29
  "access": "public"
26
30
  },
27
- "gitHead": "58a36c9fd59e43928b80701cdd7896754ea0db97"
31
+ "gitHead": "10e941a36df74182a45c73e7e074fc0c5ed5b669"
28
32
  }