@unhead/schema-org 1.11.10 → 1.11.12
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/index.cjs +5 -1
- package/dist/index.mjs +6 -2
- package/dist/shared/{schema-org.a7784df3.mjs → schema-org.ac0c24a5.mjs} +42 -634
- package/dist/shared/{schema-org.65a68144.cjs → schema-org.f5bc531c.cjs} +45 -637
- package/dist/vue.cjs +2 -1
- package/dist/vue.mjs +3 -2
- package/package.json +15 -5
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { hasProtocol, withBase, withoutTrailingSlash, hasTrailingSlash, withTrailingSlash, joinURL } from 'ufo';
|
|
2
|
+
import { hash } from 'ohash';
|
|
2
3
|
|
|
3
4
|
function defineSchemaOrgResolver(schema) {
|
|
4
5
|
return schema;
|
|
@@ -991,632 +992,6 @@ const movieResolver = defineSchemaOrgResolver({
|
|
|
991
992
|
}
|
|
992
993
|
});
|
|
993
994
|
|
|
994
|
-
const defaults = Object.freeze({
|
|
995
|
-
ignoreUnknown: false,
|
|
996
|
-
respectType: false,
|
|
997
|
-
respectFunctionNames: false,
|
|
998
|
-
respectFunctionProperties: false,
|
|
999
|
-
unorderedObjects: true,
|
|
1000
|
-
unorderedArrays: false,
|
|
1001
|
-
unorderedSets: false,
|
|
1002
|
-
excludeKeys: void 0,
|
|
1003
|
-
excludeValues: void 0,
|
|
1004
|
-
replacer: void 0
|
|
1005
|
-
});
|
|
1006
|
-
function objectHash(object, options) {
|
|
1007
|
-
if (options) {
|
|
1008
|
-
options = { ...defaults, ...options };
|
|
1009
|
-
} else {
|
|
1010
|
-
options = defaults;
|
|
1011
|
-
}
|
|
1012
|
-
const hasher = createHasher(options);
|
|
1013
|
-
hasher.dispatch(object);
|
|
1014
|
-
return hasher.toString();
|
|
1015
|
-
}
|
|
1016
|
-
const defaultPrototypesKeys = Object.freeze([
|
|
1017
|
-
"prototype",
|
|
1018
|
-
"__proto__",
|
|
1019
|
-
"constructor"
|
|
1020
|
-
]);
|
|
1021
|
-
function createHasher(options) {
|
|
1022
|
-
let buff = "";
|
|
1023
|
-
let context = /* @__PURE__ */ new Map();
|
|
1024
|
-
const write = (str) => {
|
|
1025
|
-
buff += str;
|
|
1026
|
-
};
|
|
1027
|
-
return {
|
|
1028
|
-
toString() {
|
|
1029
|
-
return buff;
|
|
1030
|
-
},
|
|
1031
|
-
getContext() {
|
|
1032
|
-
return context;
|
|
1033
|
-
},
|
|
1034
|
-
dispatch(value) {
|
|
1035
|
-
if (options.replacer) {
|
|
1036
|
-
value = options.replacer(value);
|
|
1037
|
-
}
|
|
1038
|
-
const type = value === null ? "null" : typeof value;
|
|
1039
|
-
return this[type](value);
|
|
1040
|
-
},
|
|
1041
|
-
object(object) {
|
|
1042
|
-
if (object && typeof object.toJSON === "function") {
|
|
1043
|
-
return this.object(object.toJSON());
|
|
1044
|
-
}
|
|
1045
|
-
const objString = Object.prototype.toString.call(object);
|
|
1046
|
-
let objType = "";
|
|
1047
|
-
const objectLength = objString.length;
|
|
1048
|
-
if (objectLength < 10) {
|
|
1049
|
-
objType = "unknown:[" + objString + "]";
|
|
1050
|
-
} else {
|
|
1051
|
-
objType = objString.slice(8, objectLength - 1);
|
|
1052
|
-
}
|
|
1053
|
-
objType = objType.toLowerCase();
|
|
1054
|
-
let objectNumber = null;
|
|
1055
|
-
if ((objectNumber = context.get(object)) === void 0) {
|
|
1056
|
-
context.set(object, context.size);
|
|
1057
|
-
} else {
|
|
1058
|
-
return this.dispatch("[CIRCULAR:" + objectNumber + "]");
|
|
1059
|
-
}
|
|
1060
|
-
if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
|
1061
|
-
write("buffer:");
|
|
1062
|
-
return write(object.toString("utf8"));
|
|
1063
|
-
}
|
|
1064
|
-
if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
|
|
1065
|
-
if (this[objType]) {
|
|
1066
|
-
this[objType](object);
|
|
1067
|
-
} else if (!options.ignoreUnknown) {
|
|
1068
|
-
this.unkown(object, objType);
|
|
1069
|
-
}
|
|
1070
|
-
} else {
|
|
1071
|
-
let keys = Object.keys(object);
|
|
1072
|
-
if (options.unorderedObjects) {
|
|
1073
|
-
keys = keys.sort();
|
|
1074
|
-
}
|
|
1075
|
-
let extraKeys = [];
|
|
1076
|
-
if (options.respectType !== false && !isNativeFunction(object)) {
|
|
1077
|
-
extraKeys = defaultPrototypesKeys;
|
|
1078
|
-
}
|
|
1079
|
-
if (options.excludeKeys) {
|
|
1080
|
-
keys = keys.filter((key) => {
|
|
1081
|
-
return !options.excludeKeys(key);
|
|
1082
|
-
});
|
|
1083
|
-
extraKeys = extraKeys.filter((key) => {
|
|
1084
|
-
return !options.excludeKeys(key);
|
|
1085
|
-
});
|
|
1086
|
-
}
|
|
1087
|
-
write("object:" + (keys.length + extraKeys.length) + ":");
|
|
1088
|
-
const dispatchForKey = (key) => {
|
|
1089
|
-
this.dispatch(key);
|
|
1090
|
-
write(":");
|
|
1091
|
-
if (!options.excludeValues) {
|
|
1092
|
-
this.dispatch(object[key]);
|
|
1093
|
-
}
|
|
1094
|
-
write(",");
|
|
1095
|
-
};
|
|
1096
|
-
for (const key of keys) {
|
|
1097
|
-
dispatchForKey(key);
|
|
1098
|
-
}
|
|
1099
|
-
for (const key of extraKeys) {
|
|
1100
|
-
dispatchForKey(key);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
},
|
|
1104
|
-
array(arr, unordered) {
|
|
1105
|
-
unordered = unordered === void 0 ? options.unorderedArrays !== false : unordered;
|
|
1106
|
-
write("array:" + arr.length + ":");
|
|
1107
|
-
if (!unordered || arr.length <= 1) {
|
|
1108
|
-
for (const entry of arr) {
|
|
1109
|
-
this.dispatch(entry);
|
|
1110
|
-
}
|
|
1111
|
-
return;
|
|
1112
|
-
}
|
|
1113
|
-
const contextAdditions = /* @__PURE__ */ new Map();
|
|
1114
|
-
const entries = arr.map((entry) => {
|
|
1115
|
-
const hasher = createHasher(options);
|
|
1116
|
-
hasher.dispatch(entry);
|
|
1117
|
-
for (const [key, value] of hasher.getContext()) {
|
|
1118
|
-
contextAdditions.set(key, value);
|
|
1119
|
-
}
|
|
1120
|
-
return hasher.toString();
|
|
1121
|
-
});
|
|
1122
|
-
context = contextAdditions;
|
|
1123
|
-
entries.sort();
|
|
1124
|
-
return this.array(entries, false);
|
|
1125
|
-
},
|
|
1126
|
-
date(date) {
|
|
1127
|
-
return write("date:" + date.toJSON());
|
|
1128
|
-
},
|
|
1129
|
-
symbol(sym) {
|
|
1130
|
-
return write("symbol:" + sym.toString());
|
|
1131
|
-
},
|
|
1132
|
-
unkown(value, type) {
|
|
1133
|
-
write(type);
|
|
1134
|
-
if (!value) {
|
|
1135
|
-
return;
|
|
1136
|
-
}
|
|
1137
|
-
write(":");
|
|
1138
|
-
if (value && typeof value.entries === "function") {
|
|
1139
|
-
return this.array(
|
|
1140
|
-
Array.from(value.entries()),
|
|
1141
|
-
true
|
|
1142
|
-
/* ordered */
|
|
1143
|
-
);
|
|
1144
|
-
}
|
|
1145
|
-
},
|
|
1146
|
-
error(err) {
|
|
1147
|
-
return write("error:" + err.toString());
|
|
1148
|
-
},
|
|
1149
|
-
boolean(bool) {
|
|
1150
|
-
return write("bool:" + bool);
|
|
1151
|
-
},
|
|
1152
|
-
string(string) {
|
|
1153
|
-
write("string:" + string.length + ":");
|
|
1154
|
-
write(string);
|
|
1155
|
-
},
|
|
1156
|
-
function(fn) {
|
|
1157
|
-
write("fn:");
|
|
1158
|
-
if (isNativeFunction(fn)) {
|
|
1159
|
-
this.dispatch("[native]");
|
|
1160
|
-
} else {
|
|
1161
|
-
this.dispatch(fn.toString());
|
|
1162
|
-
}
|
|
1163
|
-
if (options.respectFunctionNames !== false) {
|
|
1164
|
-
this.dispatch("function-name:" + String(fn.name));
|
|
1165
|
-
}
|
|
1166
|
-
if (options.respectFunctionProperties) {
|
|
1167
|
-
this.object(fn);
|
|
1168
|
-
}
|
|
1169
|
-
},
|
|
1170
|
-
number(number) {
|
|
1171
|
-
return write("number:" + number);
|
|
1172
|
-
},
|
|
1173
|
-
xml(xml) {
|
|
1174
|
-
return write("xml:" + xml.toString());
|
|
1175
|
-
},
|
|
1176
|
-
null() {
|
|
1177
|
-
return write("Null");
|
|
1178
|
-
},
|
|
1179
|
-
undefined() {
|
|
1180
|
-
return write("Undefined");
|
|
1181
|
-
},
|
|
1182
|
-
regexp(regex) {
|
|
1183
|
-
return write("regex:" + regex.toString());
|
|
1184
|
-
},
|
|
1185
|
-
uint8array(arr) {
|
|
1186
|
-
write("uint8array:");
|
|
1187
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1188
|
-
},
|
|
1189
|
-
uint8clampedarray(arr) {
|
|
1190
|
-
write("uint8clampedarray:");
|
|
1191
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1192
|
-
},
|
|
1193
|
-
int8array(arr) {
|
|
1194
|
-
write("int8array:");
|
|
1195
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1196
|
-
},
|
|
1197
|
-
uint16array(arr) {
|
|
1198
|
-
write("uint16array:");
|
|
1199
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1200
|
-
},
|
|
1201
|
-
int16array(arr) {
|
|
1202
|
-
write("int16array:");
|
|
1203
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1204
|
-
},
|
|
1205
|
-
uint32array(arr) {
|
|
1206
|
-
write("uint32array:");
|
|
1207
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1208
|
-
},
|
|
1209
|
-
int32array(arr) {
|
|
1210
|
-
write("int32array:");
|
|
1211
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1212
|
-
},
|
|
1213
|
-
float32array(arr) {
|
|
1214
|
-
write("float32array:");
|
|
1215
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1216
|
-
},
|
|
1217
|
-
float64array(arr) {
|
|
1218
|
-
write("float64array:");
|
|
1219
|
-
return this.dispatch(Array.prototype.slice.call(arr));
|
|
1220
|
-
},
|
|
1221
|
-
arraybuffer(arr) {
|
|
1222
|
-
write("arraybuffer:");
|
|
1223
|
-
return this.dispatch(new Uint8Array(arr));
|
|
1224
|
-
},
|
|
1225
|
-
url(url) {
|
|
1226
|
-
return write("url:" + url.toString());
|
|
1227
|
-
},
|
|
1228
|
-
map(map) {
|
|
1229
|
-
write("map:");
|
|
1230
|
-
const arr = [...map];
|
|
1231
|
-
return this.array(arr, options.unorderedSets !== false);
|
|
1232
|
-
},
|
|
1233
|
-
set(set) {
|
|
1234
|
-
write("set:");
|
|
1235
|
-
const arr = [...set];
|
|
1236
|
-
return this.array(arr, options.unorderedSets !== false);
|
|
1237
|
-
},
|
|
1238
|
-
file(file) {
|
|
1239
|
-
write("file:");
|
|
1240
|
-
return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
|
|
1241
|
-
},
|
|
1242
|
-
blob() {
|
|
1243
|
-
if (options.ignoreUnknown) {
|
|
1244
|
-
return write("[blob]");
|
|
1245
|
-
}
|
|
1246
|
-
throw new Error(
|
|
1247
|
-
'Hashing Blob objects is currently not supported\nUse "options.replacer" or "options.ignoreUnknown"\n'
|
|
1248
|
-
);
|
|
1249
|
-
},
|
|
1250
|
-
domwindow() {
|
|
1251
|
-
return write("domwindow");
|
|
1252
|
-
},
|
|
1253
|
-
bigint(number) {
|
|
1254
|
-
return write("bigint:" + number.toString());
|
|
1255
|
-
},
|
|
1256
|
-
/* Node.js standard native objects */
|
|
1257
|
-
process() {
|
|
1258
|
-
return write("process");
|
|
1259
|
-
},
|
|
1260
|
-
timer() {
|
|
1261
|
-
return write("timer");
|
|
1262
|
-
},
|
|
1263
|
-
pipe() {
|
|
1264
|
-
return write("pipe");
|
|
1265
|
-
},
|
|
1266
|
-
tcp() {
|
|
1267
|
-
return write("tcp");
|
|
1268
|
-
},
|
|
1269
|
-
udp() {
|
|
1270
|
-
return write("udp");
|
|
1271
|
-
},
|
|
1272
|
-
tty() {
|
|
1273
|
-
return write("tty");
|
|
1274
|
-
},
|
|
1275
|
-
statwatcher() {
|
|
1276
|
-
return write("statwatcher");
|
|
1277
|
-
},
|
|
1278
|
-
securecontext() {
|
|
1279
|
-
return write("securecontext");
|
|
1280
|
-
},
|
|
1281
|
-
connection() {
|
|
1282
|
-
return write("connection");
|
|
1283
|
-
},
|
|
1284
|
-
zlib() {
|
|
1285
|
-
return write("zlib");
|
|
1286
|
-
},
|
|
1287
|
-
context() {
|
|
1288
|
-
return write("context");
|
|
1289
|
-
},
|
|
1290
|
-
nodescript() {
|
|
1291
|
-
return write("nodescript");
|
|
1292
|
-
},
|
|
1293
|
-
httpparser() {
|
|
1294
|
-
return write("httpparser");
|
|
1295
|
-
},
|
|
1296
|
-
dataview() {
|
|
1297
|
-
return write("dataview");
|
|
1298
|
-
},
|
|
1299
|
-
signal() {
|
|
1300
|
-
return write("signal");
|
|
1301
|
-
},
|
|
1302
|
-
fsevent() {
|
|
1303
|
-
return write("fsevent");
|
|
1304
|
-
},
|
|
1305
|
-
tlswrap() {
|
|
1306
|
-
return write("tlswrap");
|
|
1307
|
-
}
|
|
1308
|
-
};
|
|
1309
|
-
}
|
|
1310
|
-
const nativeFunc = "[native code] }";
|
|
1311
|
-
const nativeFuncLength = nativeFunc.length;
|
|
1312
|
-
function isNativeFunction(f) {
|
|
1313
|
-
if (typeof f !== "function") {
|
|
1314
|
-
return false;
|
|
1315
|
-
}
|
|
1316
|
-
return Function.prototype.toString.call(f).slice(-nativeFuncLength) === nativeFunc;
|
|
1317
|
-
}
|
|
1318
|
-
|
|
1319
|
-
var __defProp$1 = Object.defineProperty;
|
|
1320
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1321
|
-
var __publicField$1 = (obj, key, value) => {
|
|
1322
|
-
__defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1323
|
-
return value;
|
|
1324
|
-
};
|
|
1325
|
-
class WordArray {
|
|
1326
|
-
constructor(words, sigBytes) {
|
|
1327
|
-
__publicField$1(this, "words");
|
|
1328
|
-
__publicField$1(this, "sigBytes");
|
|
1329
|
-
words = this.words = words || [];
|
|
1330
|
-
this.sigBytes = sigBytes === void 0 ? words.length * 4 : sigBytes;
|
|
1331
|
-
}
|
|
1332
|
-
toString(encoder) {
|
|
1333
|
-
return (encoder || Hex).stringify(this);
|
|
1334
|
-
}
|
|
1335
|
-
concat(wordArray) {
|
|
1336
|
-
this.clamp();
|
|
1337
|
-
if (this.sigBytes % 4) {
|
|
1338
|
-
for (let i = 0; i < wordArray.sigBytes; i++) {
|
|
1339
|
-
const thatByte = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
1340
|
-
this.words[this.sigBytes + i >>> 2] |= thatByte << 24 - (this.sigBytes + i) % 4 * 8;
|
|
1341
|
-
}
|
|
1342
|
-
} else {
|
|
1343
|
-
for (let j = 0; j < wordArray.sigBytes; j += 4) {
|
|
1344
|
-
this.words[this.sigBytes + j >>> 2] = wordArray.words[j >>> 2];
|
|
1345
|
-
}
|
|
1346
|
-
}
|
|
1347
|
-
this.sigBytes += wordArray.sigBytes;
|
|
1348
|
-
return this;
|
|
1349
|
-
}
|
|
1350
|
-
clamp() {
|
|
1351
|
-
this.words[this.sigBytes >>> 2] &= 4294967295 << 32 - this.sigBytes % 4 * 8;
|
|
1352
|
-
this.words.length = Math.ceil(this.sigBytes / 4);
|
|
1353
|
-
}
|
|
1354
|
-
clone() {
|
|
1355
|
-
return new WordArray([...this.words]);
|
|
1356
|
-
}
|
|
1357
|
-
}
|
|
1358
|
-
const Hex = {
|
|
1359
|
-
stringify(wordArray) {
|
|
1360
|
-
const hexChars = [];
|
|
1361
|
-
for (let i = 0; i < wordArray.sigBytes; i++) {
|
|
1362
|
-
const bite = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
1363
|
-
hexChars.push((bite >>> 4).toString(16), (bite & 15).toString(16));
|
|
1364
|
-
}
|
|
1365
|
-
return hexChars.join("");
|
|
1366
|
-
}
|
|
1367
|
-
};
|
|
1368
|
-
const Base64 = {
|
|
1369
|
-
stringify(wordArray) {
|
|
1370
|
-
const keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
1371
|
-
const base64Chars = [];
|
|
1372
|
-
for (let i = 0; i < wordArray.sigBytes; i += 3) {
|
|
1373
|
-
const byte1 = wordArray.words[i >>> 2] >>> 24 - i % 4 * 8 & 255;
|
|
1374
|
-
const byte2 = wordArray.words[i + 1 >>> 2] >>> 24 - (i + 1) % 4 * 8 & 255;
|
|
1375
|
-
const byte3 = wordArray.words[i + 2 >>> 2] >>> 24 - (i + 2) % 4 * 8 & 255;
|
|
1376
|
-
const triplet = byte1 << 16 | byte2 << 8 | byte3;
|
|
1377
|
-
for (let j = 0; j < 4 && i * 8 + j * 6 < wordArray.sigBytes * 8; j++) {
|
|
1378
|
-
base64Chars.push(keyStr.charAt(triplet >>> 6 * (3 - j) & 63));
|
|
1379
|
-
}
|
|
1380
|
-
}
|
|
1381
|
-
return base64Chars.join("");
|
|
1382
|
-
}
|
|
1383
|
-
};
|
|
1384
|
-
const Latin1 = {
|
|
1385
|
-
parse(latin1Str) {
|
|
1386
|
-
const latin1StrLength = latin1Str.length;
|
|
1387
|
-
const words = [];
|
|
1388
|
-
for (let i = 0; i < latin1StrLength; i++) {
|
|
1389
|
-
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 255) << 24 - i % 4 * 8;
|
|
1390
|
-
}
|
|
1391
|
-
return new WordArray(words, latin1StrLength);
|
|
1392
|
-
}
|
|
1393
|
-
};
|
|
1394
|
-
const Utf8 = {
|
|
1395
|
-
parse(utf8Str) {
|
|
1396
|
-
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
|
1397
|
-
}
|
|
1398
|
-
};
|
|
1399
|
-
class BufferedBlockAlgorithm {
|
|
1400
|
-
constructor() {
|
|
1401
|
-
__publicField$1(this, "_data", new WordArray());
|
|
1402
|
-
__publicField$1(this, "_nDataBytes", 0);
|
|
1403
|
-
__publicField$1(this, "_minBufferSize", 0);
|
|
1404
|
-
__publicField$1(this, "blockSize", 512 / 32);
|
|
1405
|
-
}
|
|
1406
|
-
reset() {
|
|
1407
|
-
this._data = new WordArray();
|
|
1408
|
-
this._nDataBytes = 0;
|
|
1409
|
-
}
|
|
1410
|
-
_append(data) {
|
|
1411
|
-
if (typeof data === "string") {
|
|
1412
|
-
data = Utf8.parse(data);
|
|
1413
|
-
}
|
|
1414
|
-
this._data.concat(data);
|
|
1415
|
-
this._nDataBytes += data.sigBytes;
|
|
1416
|
-
}
|
|
1417
|
-
_doProcessBlock(_dataWords, _offset) {
|
|
1418
|
-
}
|
|
1419
|
-
_process(doFlush) {
|
|
1420
|
-
let processedWords;
|
|
1421
|
-
let nBlocksReady = this._data.sigBytes / (this.blockSize * 4);
|
|
1422
|
-
if (doFlush) {
|
|
1423
|
-
nBlocksReady = Math.ceil(nBlocksReady);
|
|
1424
|
-
} else {
|
|
1425
|
-
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
|
1426
|
-
}
|
|
1427
|
-
const nWordsReady = nBlocksReady * this.blockSize;
|
|
1428
|
-
const nBytesReady = Math.min(nWordsReady * 4, this._data.sigBytes);
|
|
1429
|
-
if (nWordsReady) {
|
|
1430
|
-
for (let offset = 0; offset < nWordsReady; offset += this.blockSize) {
|
|
1431
|
-
this._doProcessBlock(this._data.words, offset);
|
|
1432
|
-
}
|
|
1433
|
-
processedWords = this._data.words.splice(0, nWordsReady);
|
|
1434
|
-
this._data.sigBytes -= nBytesReady;
|
|
1435
|
-
}
|
|
1436
|
-
return new WordArray(processedWords, nBytesReady);
|
|
1437
|
-
}
|
|
1438
|
-
}
|
|
1439
|
-
class Hasher extends BufferedBlockAlgorithm {
|
|
1440
|
-
update(messageUpdate) {
|
|
1441
|
-
this._append(messageUpdate);
|
|
1442
|
-
this._process();
|
|
1443
|
-
return this;
|
|
1444
|
-
}
|
|
1445
|
-
finalize(messageUpdate) {
|
|
1446
|
-
if (messageUpdate) {
|
|
1447
|
-
this._append(messageUpdate);
|
|
1448
|
-
}
|
|
1449
|
-
}
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
var __defProp = Object.defineProperty;
|
|
1453
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1454
|
-
var __publicField = (obj, key, value) => {
|
|
1455
|
-
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
1456
|
-
return value;
|
|
1457
|
-
};
|
|
1458
|
-
const H = [
|
|
1459
|
-
1779033703,
|
|
1460
|
-
-1150833019,
|
|
1461
|
-
1013904242,
|
|
1462
|
-
-1521486534,
|
|
1463
|
-
1359893119,
|
|
1464
|
-
-1694144372,
|
|
1465
|
-
528734635,
|
|
1466
|
-
1541459225
|
|
1467
|
-
];
|
|
1468
|
-
const K = [
|
|
1469
|
-
1116352408,
|
|
1470
|
-
1899447441,
|
|
1471
|
-
-1245643825,
|
|
1472
|
-
-373957723,
|
|
1473
|
-
961987163,
|
|
1474
|
-
1508970993,
|
|
1475
|
-
-1841331548,
|
|
1476
|
-
-1424204075,
|
|
1477
|
-
-670586216,
|
|
1478
|
-
310598401,
|
|
1479
|
-
607225278,
|
|
1480
|
-
1426881987,
|
|
1481
|
-
1925078388,
|
|
1482
|
-
-2132889090,
|
|
1483
|
-
-1680079193,
|
|
1484
|
-
-1046744716,
|
|
1485
|
-
-459576895,
|
|
1486
|
-
-272742522,
|
|
1487
|
-
264347078,
|
|
1488
|
-
604807628,
|
|
1489
|
-
770255983,
|
|
1490
|
-
1249150122,
|
|
1491
|
-
1555081692,
|
|
1492
|
-
1996064986,
|
|
1493
|
-
-1740746414,
|
|
1494
|
-
-1473132947,
|
|
1495
|
-
-1341970488,
|
|
1496
|
-
-1084653625,
|
|
1497
|
-
-958395405,
|
|
1498
|
-
-710438585,
|
|
1499
|
-
113926993,
|
|
1500
|
-
338241895,
|
|
1501
|
-
666307205,
|
|
1502
|
-
773529912,
|
|
1503
|
-
1294757372,
|
|
1504
|
-
1396182291,
|
|
1505
|
-
1695183700,
|
|
1506
|
-
1986661051,
|
|
1507
|
-
-2117940946,
|
|
1508
|
-
-1838011259,
|
|
1509
|
-
-1564481375,
|
|
1510
|
-
-1474664885,
|
|
1511
|
-
-1035236496,
|
|
1512
|
-
-949202525,
|
|
1513
|
-
-778901479,
|
|
1514
|
-
-694614492,
|
|
1515
|
-
-200395387,
|
|
1516
|
-
275423344,
|
|
1517
|
-
430227734,
|
|
1518
|
-
506948616,
|
|
1519
|
-
659060556,
|
|
1520
|
-
883997877,
|
|
1521
|
-
958139571,
|
|
1522
|
-
1322822218,
|
|
1523
|
-
1537002063,
|
|
1524
|
-
1747873779,
|
|
1525
|
-
1955562222,
|
|
1526
|
-
2024104815,
|
|
1527
|
-
-2067236844,
|
|
1528
|
-
-1933114872,
|
|
1529
|
-
-1866530822,
|
|
1530
|
-
-1538233109,
|
|
1531
|
-
-1090935817,
|
|
1532
|
-
-965641998
|
|
1533
|
-
];
|
|
1534
|
-
const W = [];
|
|
1535
|
-
class SHA256 extends Hasher {
|
|
1536
|
-
constructor() {
|
|
1537
|
-
super(...arguments);
|
|
1538
|
-
__publicField(this, "_hash", new WordArray([...H]));
|
|
1539
|
-
}
|
|
1540
|
-
/**
|
|
1541
|
-
* Resets the internal state of the hash object to initial values.
|
|
1542
|
-
*/
|
|
1543
|
-
reset() {
|
|
1544
|
-
super.reset();
|
|
1545
|
-
this._hash = new WordArray([...H]);
|
|
1546
|
-
}
|
|
1547
|
-
_doProcessBlock(M, offset) {
|
|
1548
|
-
const H2 = this._hash.words;
|
|
1549
|
-
let a = H2[0];
|
|
1550
|
-
let b = H2[1];
|
|
1551
|
-
let c = H2[2];
|
|
1552
|
-
let d = H2[3];
|
|
1553
|
-
let e = H2[4];
|
|
1554
|
-
let f = H2[5];
|
|
1555
|
-
let g = H2[6];
|
|
1556
|
-
let h = H2[7];
|
|
1557
|
-
for (let i = 0; i < 64; i++) {
|
|
1558
|
-
if (i < 16) {
|
|
1559
|
-
W[i] = M[offset + i] | 0;
|
|
1560
|
-
} else {
|
|
1561
|
-
const gamma0x = W[i - 15];
|
|
1562
|
-
const gamma0 = (gamma0x << 25 | gamma0x >>> 7) ^ (gamma0x << 14 | gamma0x >>> 18) ^ gamma0x >>> 3;
|
|
1563
|
-
const gamma1x = W[i - 2];
|
|
1564
|
-
const gamma1 = (gamma1x << 15 | gamma1x >>> 17) ^ (gamma1x << 13 | gamma1x >>> 19) ^ gamma1x >>> 10;
|
|
1565
|
-
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
|
1566
|
-
}
|
|
1567
|
-
const ch = e & f ^ ~e & g;
|
|
1568
|
-
const maj = a & b ^ a & c ^ b & c;
|
|
1569
|
-
const sigma0 = (a << 30 | a >>> 2) ^ (a << 19 | a >>> 13) ^ (a << 10 | a >>> 22);
|
|
1570
|
-
const sigma1 = (e << 26 | e >>> 6) ^ (e << 21 | e >>> 11) ^ (e << 7 | e >>> 25);
|
|
1571
|
-
const t1 = h + sigma1 + ch + K[i] + W[i];
|
|
1572
|
-
const t2 = sigma0 + maj;
|
|
1573
|
-
h = g;
|
|
1574
|
-
g = f;
|
|
1575
|
-
f = e;
|
|
1576
|
-
e = d + t1 | 0;
|
|
1577
|
-
d = c;
|
|
1578
|
-
c = b;
|
|
1579
|
-
b = a;
|
|
1580
|
-
a = t1 + t2 | 0;
|
|
1581
|
-
}
|
|
1582
|
-
H2[0] = H2[0] + a | 0;
|
|
1583
|
-
H2[1] = H2[1] + b | 0;
|
|
1584
|
-
H2[2] = H2[2] + c | 0;
|
|
1585
|
-
H2[3] = H2[3] + d | 0;
|
|
1586
|
-
H2[4] = H2[4] + e | 0;
|
|
1587
|
-
H2[5] = H2[5] + f | 0;
|
|
1588
|
-
H2[6] = H2[6] + g | 0;
|
|
1589
|
-
H2[7] = H2[7] + h | 0;
|
|
1590
|
-
}
|
|
1591
|
-
/**
|
|
1592
|
-
* Finishes the hash calculation and returns the hash as a WordArray.
|
|
1593
|
-
*
|
|
1594
|
-
* @param {string} messageUpdate - Additional message content to include in the hash.
|
|
1595
|
-
* @returns {WordArray} The finalised hash as a WordArray.
|
|
1596
|
-
*/
|
|
1597
|
-
finalize(messageUpdate) {
|
|
1598
|
-
super.finalize(messageUpdate);
|
|
1599
|
-
const nBitsTotal = this._nDataBytes * 8;
|
|
1600
|
-
const nBitsLeft = this._data.sigBytes * 8;
|
|
1601
|
-
this._data.words[nBitsLeft >>> 5] |= 128 << 24 - nBitsLeft % 32;
|
|
1602
|
-
this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 14] = Math.floor(
|
|
1603
|
-
nBitsTotal / 4294967296
|
|
1604
|
-
);
|
|
1605
|
-
this._data.words[(nBitsLeft + 64 >>> 9 << 4) + 15] = nBitsTotal;
|
|
1606
|
-
this._data.sigBytes = this._data.words.length * 4;
|
|
1607
|
-
this._process();
|
|
1608
|
-
return this._hash;
|
|
1609
|
-
}
|
|
1610
|
-
}
|
|
1611
|
-
function sha256base64(message) {
|
|
1612
|
-
return new SHA256().finalize(message).toString(Base64);
|
|
1613
|
-
}
|
|
1614
|
-
|
|
1615
|
-
function hash(object, options = {}) {
|
|
1616
|
-
const hashed = typeof object === "string" ? object : objectHash(object, options);
|
|
1617
|
-
return sha256base64(hashed).slice(0, 10);
|
|
1618
|
-
}
|
|
1619
|
-
|
|
1620
995
|
const ProductId = "#product";
|
|
1621
996
|
const productResolver = defineSchemaOrgResolver({
|
|
1622
997
|
defaults: {
|
|
@@ -1742,7 +1117,7 @@ function hashCode(s) {
|
|
|
1742
1117
|
}
|
|
1743
1118
|
|
|
1744
1119
|
const sepSub = "%separator";
|
|
1745
|
-
function sub(p, token) {
|
|
1120
|
+
function sub(p, token, isJson = false) {
|
|
1746
1121
|
let val;
|
|
1747
1122
|
if (token === "s" || token === "pageTitle") {
|
|
1748
1123
|
val = p.pageTitle;
|
|
@@ -1752,10 +1127,13 @@ function sub(p, token) {
|
|
|
1752
1127
|
} else {
|
|
1753
1128
|
val = p[token];
|
|
1754
1129
|
}
|
|
1755
|
-
|
|
1130
|
+
if (val !== void 0) {
|
|
1131
|
+
return isJson ? (val || "").replace(/"/g, '\\"') : val || "";
|
|
1132
|
+
}
|
|
1133
|
+
return void 0;
|
|
1756
1134
|
}
|
|
1757
1135
|
const sepSubRe = new RegExp(`${sepSub}(?:\\s*${sepSub})*`, "g");
|
|
1758
|
-
function processTemplateParams(s, p, sep) {
|
|
1136
|
+
function processTemplateParams(s, p, sep, isJson = false) {
|
|
1759
1137
|
if (typeof s !== "string" || !s.includes("%"))
|
|
1760
1138
|
return s;
|
|
1761
1139
|
let decoded = s;
|
|
@@ -1772,7 +1150,7 @@ function processTemplateParams(s, p, sep) {
|
|
|
1772
1150
|
if (token === sepSub || !tokens.includes(token)) {
|
|
1773
1151
|
return token;
|
|
1774
1152
|
}
|
|
1775
|
-
const re = sub(p, token.slice(1));
|
|
1153
|
+
const re = sub(p, token.slice(1), isJson);
|
|
1776
1154
|
return re !== void 0 ? re : token;
|
|
1777
1155
|
}).trim();
|
|
1778
1156
|
if (hasSepSub) {
|
|
@@ -2052,6 +1430,7 @@ function createDefu(merger) {
|
|
|
2052
1430
|
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
2053
1431
|
);
|
|
2054
1432
|
}
|
|
1433
|
+
const defu = createDefu();
|
|
2055
1434
|
|
|
2056
1435
|
function groupBy(array, predicate) {
|
|
2057
1436
|
return array.reduce((acc, value, index, array2) => {
|
|
@@ -2068,7 +1447,10 @@ function uniqueBy(array, predicate) {
|
|
|
2068
1447
|
const merge = createDefu((object, key, value) => {
|
|
2069
1448
|
if (Array.isArray(object[key])) {
|
|
2070
1449
|
if (Array.isArray(value)) {
|
|
2071
|
-
|
|
1450
|
+
const map = {};
|
|
1451
|
+
for (const item of [...object[key], ...value])
|
|
1452
|
+
map[hash(item)] = item;
|
|
1453
|
+
object[key] = Object.values(map);
|
|
2072
1454
|
if (key === "itemListElement") {
|
|
2073
1455
|
object[key] = [...uniqueBy(object[key], (item) => item.position)];
|
|
2074
1456
|
}
|
|
@@ -2191,9 +1573,13 @@ function SchemaOrgUnheadPlugin(config, meta, options) {
|
|
|
2191
1573
|
},
|
|
2192
1574
|
"tag:normalise": async ({ tag }) => {
|
|
2193
1575
|
if (tag.tag === "script" && tag.props.type === "application/ld+json" && tag.props.nodes) {
|
|
1576
|
+
console.log("tag", tag);
|
|
2194
1577
|
const { loadResolver } = await Promise.resolve().then(function () { return resolver; });
|
|
2195
1578
|
const nodes = await tag.props.nodes;
|
|
2196
1579
|
for (const node of Array.isArray(nodes) ? nodes : [nodes]) {
|
|
1580
|
+
if (typeof node !== "object" || Object.keys(node).length === 0) {
|
|
1581
|
+
continue;
|
|
1582
|
+
}
|
|
2197
1583
|
const newNode = {
|
|
2198
1584
|
...node,
|
|
2199
1585
|
_dedupeStrategy: tag.tagDuplicateStrategy,
|
|
@@ -2229,21 +1615,43 @@ function SchemaOrgUnheadPlugin(config, meta, options) {
|
|
|
2229
1615
|
}
|
|
2230
1616
|
},
|
|
2231
1617
|
"tags:resolve": async (ctx) => {
|
|
2232
|
-
for (const
|
|
1618
|
+
for (const k in ctx.tags) {
|
|
1619
|
+
const tag = ctx.tags[k];
|
|
2233
1620
|
if (tag.tag === "script" && tag.props.type === "application/ld+json" && tag.props.nodes) {
|
|
1621
|
+
delete tag.props.nodes;
|
|
1622
|
+
const resolvedGraph = graph.resolveGraph({ ...await meta?.() || {}, ...config, ...resolvedMeta });
|
|
1623
|
+
if (!resolvedGraph.length) {
|
|
1624
|
+
tag.props = {};
|
|
1625
|
+
return;
|
|
1626
|
+
}
|
|
2234
1627
|
const minify = options?.minify || process.env.NODE_ENV === "production";
|
|
2235
1628
|
tag.innerHTML = JSON.stringify({
|
|
2236
1629
|
"@context": "https://schema.org",
|
|
2237
|
-
"@graph":
|
|
1630
|
+
"@graph": resolvedGraph
|
|
2238
1631
|
}, (_, value) => {
|
|
2239
1632
|
if (typeof value !== "object")
|
|
2240
1633
|
return processTemplateParams(value, head._templateParams, head._separator);
|
|
2241
1634
|
return value;
|
|
2242
1635
|
}, minify ? 0 : 2);
|
|
2243
|
-
delete tag.props.nodes;
|
|
2244
1636
|
return;
|
|
2245
1637
|
}
|
|
2246
1638
|
}
|
|
1639
|
+
},
|
|
1640
|
+
"tags:afterResolve": (ctx) => {
|
|
1641
|
+
let firstNodeKey;
|
|
1642
|
+
for (const k in ctx.tags) {
|
|
1643
|
+
const tag = ctx.tags[k];
|
|
1644
|
+
if (tag.props.type === "application/ld+json" && tag.props.nodes || tag.key === "schema-org-graph") {
|
|
1645
|
+
if (typeof firstNodeKey === "undefined") {
|
|
1646
|
+
firstNodeKey = k;
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
ctx.tags[firstNodeKey].props = defu(ctx.tags[firstNodeKey].props, tag.props);
|
|
1650
|
+
delete ctx.tags[firstNodeKey].props.nodes;
|
|
1651
|
+
ctx.tags[k] = false;
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
ctx.tags = ctx.tags.filter(Boolean);
|
|
2247
1655
|
}
|
|
2248
1656
|
}
|
|
2249
1657
|
}));
|