@makeswift/runtime 0.10.9 → 0.10.10
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.js +47 -90
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +47 -90
- package/dist/index.es.js.map +1 -1
- package/dist/types/src/next/client.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -258,35 +258,6 @@ const FileFragment = `
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
`;
|
|
261
|
-
const TypographyFragment = `
|
|
262
|
-
fragment Typography on Typography {
|
|
263
|
-
__typename
|
|
264
|
-
id
|
|
265
|
-
name
|
|
266
|
-
style {
|
|
267
|
-
deviceId
|
|
268
|
-
value {
|
|
269
|
-
fontFamily
|
|
270
|
-
fontSize {
|
|
271
|
-
value
|
|
272
|
-
unit
|
|
273
|
-
}
|
|
274
|
-
color {
|
|
275
|
-
swatchId
|
|
276
|
-
alpha
|
|
277
|
-
}
|
|
278
|
-
lineHeight
|
|
279
|
-
letterSpacing
|
|
280
|
-
fontWeight
|
|
281
|
-
textAlign
|
|
282
|
-
uppercase
|
|
283
|
-
underline
|
|
284
|
-
strikethrough
|
|
285
|
-
italic
|
|
286
|
-
}
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
`;
|
|
290
261
|
const PagePathnameSliceFragment = `
|
|
291
262
|
fragment PagePathnameSlice on PagePathnameSlice {
|
|
292
263
|
__typename
|
|
@@ -294,20 +265,6 @@ const PagePathnameSliceFragment = `
|
|
|
294
265
|
pathname
|
|
295
266
|
}
|
|
296
267
|
`;
|
|
297
|
-
const GlobalElementFragment = `
|
|
298
|
-
fragment GlobalElement on GlobalElement {
|
|
299
|
-
__typename
|
|
300
|
-
id
|
|
301
|
-
data
|
|
302
|
-
}
|
|
303
|
-
`;
|
|
304
|
-
const LocalizedGlobalElementFragment = `
|
|
305
|
-
fragment LocalizedGlobalElement on LocalizedGlobalElement {
|
|
306
|
-
__typename
|
|
307
|
-
id
|
|
308
|
-
data
|
|
309
|
-
}
|
|
310
|
-
`;
|
|
311
268
|
const TableFragment = `
|
|
312
269
|
fragment Table on Table {
|
|
313
270
|
__typename
|
|
@@ -362,15 +319,6 @@ const FileQuery = `
|
|
|
362
319
|
|
|
363
320
|
${FileFragment}
|
|
364
321
|
`;
|
|
365
|
-
const TypographyQuery = `
|
|
366
|
-
query Typography($typographyId: ID!) {
|
|
367
|
-
typography(id: $typographyId) {
|
|
368
|
-
...Typography
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
${TypographyFragment}
|
|
373
|
-
`;
|
|
374
322
|
const PagePathnamesByIdQuery = `
|
|
375
323
|
query PagePathnamesById($pageIds: [ID!]!) {
|
|
376
324
|
pagePathnamesById(ids: $pageIds) {
|
|
@@ -389,33 +337,6 @@ const TableQuery = `
|
|
|
389
337
|
|
|
390
338
|
${TableFragment}
|
|
391
339
|
`;
|
|
392
|
-
const TypographiesQuery = `
|
|
393
|
-
query Typographies($typographyIds: [ID!]!) {
|
|
394
|
-
typographies(ids: $typographyIds) {
|
|
395
|
-
...Typography
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
${TypographyFragment}
|
|
400
|
-
`;
|
|
401
|
-
const GlobalElementQuery = `
|
|
402
|
-
query GlobalElement($globalElementId: ID!) {
|
|
403
|
-
globalElement(id: $globalElementId) {
|
|
404
|
-
...GlobalElement
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
${GlobalElementFragment}
|
|
409
|
-
`;
|
|
410
|
-
const LocalizedGlobalElementQuery = `
|
|
411
|
-
query LocalizedGlobalElement($globalElementId: ID!, $locale: Locale!) {
|
|
412
|
-
localizedGlobalElement(globalElementId: $globalElementId, locale: $locale) {
|
|
413
|
-
...LocalizedGlobalElement
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
${LocalizedGlobalElementFragment}
|
|
418
|
-
`;
|
|
419
340
|
const CreateTableRecordMutation = `
|
|
420
341
|
mutation CreateTableRecord($input: CreateTableRecordInput!) {
|
|
421
342
|
createTableRecord(input: $input) {
|
|
@@ -897,9 +818,24 @@ Received "${apiKey}" instead.`);
|
|
|
897
818
|
const json = await response.json();
|
|
898
819
|
return json;
|
|
899
820
|
}
|
|
900
|
-
async getTypographies(typographyIds) {
|
|
901
|
-
|
|
902
|
-
|
|
821
|
+
async getTypographies(typographyIds, preview) {
|
|
822
|
+
var _a;
|
|
823
|
+
const isUsingVersioning = this.siteVersion != null;
|
|
824
|
+
const url = new URL(`${isUsingVersioning ? "v2" : "v1"}/typographies/bulk`, this.apiOrigin);
|
|
825
|
+
typographyIds.forEach((id) => {
|
|
826
|
+
url.searchParams.append("ids", id);
|
|
827
|
+
});
|
|
828
|
+
const response = await this.fetch(url.pathname + url.search, {
|
|
829
|
+
headers: {
|
|
830
|
+
"Makeswift-Site-Version": (_a = this.siteVersion) != null ? _a : preview ? MakeswiftSiteVersion.Working : MakeswiftSiteVersion.Live
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
if (!response.ok) {
|
|
834
|
+
console.error("Failed to get typographies", await response.json());
|
|
835
|
+
return [];
|
|
836
|
+
}
|
|
837
|
+
const body = await response.json();
|
|
838
|
+
return body;
|
|
903
839
|
}
|
|
904
840
|
async getSwatches(ids, preview) {
|
|
905
841
|
var _a;
|
|
@@ -987,7 +923,7 @@ Received "${apiKey}" instead.`);
|
|
|
987
923
|
continue;
|
|
988
924
|
getResourcesFromElementDescriptors(elementDescriptors, element2.props);
|
|
989
925
|
}
|
|
990
|
-
const typographies = await this.getTypographies([...typographyIds]);
|
|
926
|
+
const typographies = await this.getTypographies([...typographyIds], preview);
|
|
991
927
|
typographies.forEach((typography) => {
|
|
992
928
|
typography == null ? void 0 : typography.style.forEach((style) => {
|
|
993
929
|
var _a2;
|
|
@@ -1108,16 +1044,37 @@ Received "${apiKey}" instead.`);
|
|
|
1108
1044
|
return result.file;
|
|
1109
1045
|
}
|
|
1110
1046
|
async getTypography(typographyId) {
|
|
1111
|
-
const
|
|
1112
|
-
|
|
1047
|
+
const isUsingVersioning = this.siteVersion != null;
|
|
1048
|
+
const response = await this.fetch(`${isUsingVersioning ? "v2" : "v1"}/typographies/${typographyId}`);
|
|
1049
|
+
if (!response.ok) {
|
|
1050
|
+
if (response.status !== 404)
|
|
1051
|
+
console.error("Failed to get typography", await response.json());
|
|
1052
|
+
return null;
|
|
1053
|
+
}
|
|
1054
|
+
const typography = await response.json();
|
|
1055
|
+
return typography;
|
|
1113
1056
|
}
|
|
1114
1057
|
async getGlobalElement(globalElementId) {
|
|
1115
|
-
const
|
|
1116
|
-
|
|
1058
|
+
const isUsingVersioning = this.siteVersion != null;
|
|
1059
|
+
const response = await this.fetch(`${isUsingVersioning ? "v2" : "v1"}/global-elements/${globalElementId}`);
|
|
1060
|
+
if (!response.ok) {
|
|
1061
|
+
if (response.status !== 404)
|
|
1062
|
+
console.error("Failed to get global element", await response.json());
|
|
1063
|
+
return null;
|
|
1064
|
+
}
|
|
1065
|
+
const globalElement = await response.json();
|
|
1066
|
+
return globalElement;
|
|
1117
1067
|
}
|
|
1118
1068
|
async getLocalizedGlobalElement(globalElementId, locale) {
|
|
1119
|
-
const
|
|
1120
|
-
|
|
1069
|
+
const isUsingVersioning = this.siteVersion != null;
|
|
1070
|
+
const response = await this.fetch(`${isUsingVersioning ? "v2" : "v1"}/localized-global-elements/${globalElementId}?locale=${locale}`);
|
|
1071
|
+
if (!response.ok) {
|
|
1072
|
+
if (response.status !== 404)
|
|
1073
|
+
console.error("Failed to get localized global element", await response.json());
|
|
1074
|
+
return null;
|
|
1075
|
+
}
|
|
1076
|
+
const localizedGlobalElement = await response.json();
|
|
1077
|
+
return localizedGlobalElement;
|
|
1121
1078
|
}
|
|
1122
1079
|
async getPagePathnameSlice(pageId) {
|
|
1123
1080
|
var _a;
|
|
@@ -1202,7 +1159,7 @@ async function fonts(_req, res, { getFonts } = {}) {
|
|
|
1202
1159
|
const fonts2 = (_a = await (getFonts == null ? void 0 : getFonts())) != null ? _a : [];
|
|
1203
1160
|
return res.json(fonts2);
|
|
1204
1161
|
}
|
|
1205
|
-
const version = "0.10.
|
|
1162
|
+
const version = "0.10.10";
|
|
1206
1163
|
async function handler(req, res, { apiKey, unstable_siteVersions }) {
|
|
1207
1164
|
if (req.query.secret !== apiKey) {
|
|
1208
1165
|
return res.status(401).json({ message: "Unauthorized" });
|