@orion-studios/payload-studio 0.5.0-beta.11 → 0.5.0-beta.111
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 +54 -0
- package/dist/admin/client.d.mts +3 -0
- package/dist/admin/client.d.ts +3 -0
- package/dist/admin/client.js +1745 -200
- package/dist/admin/client.mjs +1756 -214
- package/dist/admin/index.d.mts +2 -1
- package/dist/admin/index.d.ts +2 -1
- package/dist/admin/index.js +424 -11
- package/dist/admin/index.mjs +19 -1
- package/dist/admin-app/client.d.mts +7 -0
- package/dist/admin-app/client.d.ts +7 -0
- package/dist/admin-app/client.js +1270 -3
- package/dist/admin-app/client.mjs +1172 -2
- package/dist/admin-app/index.d.mts +1 -1
- package/dist/admin-app/index.d.ts +1 -1
- package/dist/admin-app/index.js +167 -0
- package/dist/admin-app/index.mjs +13 -1
- package/dist/admin-app/styles.css +247 -0
- package/dist/admin.css +8 -0
- package/dist/blocks/index.js +1011 -191
- package/dist/blocks/index.mjs +2 -2
- package/dist/chunk-ADIIWIYL.mjs +322 -0
- package/dist/{chunk-ZLLNO5FM.mjs → chunk-BET2YLAS.mjs} +104 -15
- package/dist/chunk-DAIZDGHL.mjs +614 -0
- package/dist/chunk-GKMBYYXF.mjs +776 -0
- package/dist/chunk-JQAHXYAM.mjs +1829 -0
- package/dist/chunk-OQSEJXC4.mjs +166 -0
- package/dist/chunk-PF3EBZXF.mjs +326 -0
- package/dist/chunk-ROTPP5CU.mjs +99 -0
- package/dist/chunk-XVH5SCBD.mjs +234 -0
- package/dist/chunk-ZTXJG4K5.mjs +85 -0
- package/dist/index-7lxTrxSG.d.mts +128 -0
- package/dist/index-7lxTrxSG.d.ts +128 -0
- package/dist/index-B7QvY3yF.d.mts +245 -0
- package/dist/index-BK03FiEM.d.ts +245 -0
- package/dist/{index-CmR6NInu.d.ts → index-BzKOThsI.d.mts} +30 -3
- package/dist/{index-CmR6NInu.d.mts → index-BzKOThsI.d.ts} +30 -3
- package/dist/{index-DbH0Ljwp.d.mts → index-D8BNfUJb.d.mts} +17 -2
- package/dist/{index-DbH0Ljwp.d.ts → index-DD_E2UfJ.d.ts} +17 -2
- package/dist/index-DUi_XND6.d.ts +193 -0
- package/dist/index-gLl_358v.d.mts +193 -0
- package/dist/index.d.mts +6 -5
- package/dist/index.d.ts +6 -5
- package/dist/index.js +2876 -460
- package/dist/index.mjs +12 -10
- package/dist/nextjs/index.d.mts +2 -1
- package/dist/nextjs/index.d.ts +2 -1
- package/dist/nextjs/index.js +497 -16
- package/dist/nextjs/index.mjs +8 -3
- package/dist/socialMedia-C05Iy-SV.d.mts +21 -0
- package/dist/socialMedia-C05Iy-SV.d.ts +21 -0
- package/dist/studio/index.d.mts +2 -1
- package/dist/studio/index.d.ts +2 -1
- package/dist/studio/index.js +171 -5
- package/dist/studio/index.mjs +7 -3
- package/dist/studio-pages/builder.css +517 -32
- package/dist/studio-pages/client.d.mts +75 -1
- package/dist/studio-pages/client.d.ts +75 -1
- package/dist/studio-pages/client.js +5662 -2759
- package/dist/studio-pages/client.mjs +5578 -2767
- package/dist/studio-pages/index.d.mts +4 -2
- package/dist/studio-pages/index.d.ts +4 -2
- package/dist/studio-pages/index.js +859 -71
- package/dist/studio-pages/index.mjs +10 -4
- package/package.json +35 -13
- package/dist/chunk-AAOHJDNS.mjs +0 -67
- package/dist/chunk-ETRRXURT.mjs +0 -141
- package/dist/chunk-J7W5EE3B.mjs +0 -278
- package/dist/chunk-N67KVM2S.mjs +0 -156
- package/dist/chunk-NESLJZFE.mjs +0 -303
- package/dist/chunk-U5BSPWAD.mjs +0 -1034
- package/dist/index-B9N5MyjF.d.mts +0 -39
- package/dist/index-BallJs-K.d.mts +0 -43
- package/dist/index-BallJs-K.d.ts +0 -43
- package/dist/index-DJFhANvJ.d.mts +0 -128
- package/dist/index-DJFhANvJ.d.ts +0 -128
- package/dist/index-g8tBHLKD.d.ts +0 -39
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
type SocialMediaPlatform = 'facebook' | 'instagram' | 'x' | 'linkedin' | 'youtube' | 'tiktok' | 'pinterest' | 'snapchat';
|
|
2
|
+
type SocialMediaIconLibrary = 'simple-icons' | 'font-awesome-brands' | 'tabler-brands' | 'remix-icons';
|
|
3
|
+
type SocialMediaIconOption = {
|
|
4
|
+
label: string;
|
|
5
|
+
library: SocialMediaIconLibrary;
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
type SocialMediaProfileData = {
|
|
9
|
+
icon?: string | null;
|
|
10
|
+
url?: string | null;
|
|
11
|
+
};
|
|
12
|
+
type SocialMediaProfilesData = Partial<Record<SocialMediaPlatform, SocialMediaProfileData>>;
|
|
13
|
+
type SocialMediaGlobalData = {
|
|
14
|
+
profiles?: SocialMediaProfilesData | null;
|
|
15
|
+
};
|
|
16
|
+
declare const SOCIAL_MEDIA_PLATFORM_LABELS: Record<SocialMediaPlatform, string>;
|
|
17
|
+
declare const SOCIAL_MEDIA_PLATFORMS: SocialMediaPlatform[];
|
|
18
|
+
declare const SOCIAL_MEDIA_ICON_OPTIONS: Record<SocialMediaPlatform, SocialMediaIconOption[]>;
|
|
19
|
+
declare const SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM: Record<SocialMediaPlatform, string>;
|
|
20
|
+
|
|
21
|
+
export { type SocialMediaGlobalData as S, type SocialMediaPlatform as a, SOCIAL_MEDIA_DEFAULT_ICON_BY_PLATFORM as b, SOCIAL_MEDIA_ICON_OPTIONS as c, SOCIAL_MEDIA_PLATFORMS as d, SOCIAL_MEDIA_PLATFORM_LABELS as e, type SocialMediaIconLibrary as f, type SocialMediaIconOption as g, type SocialMediaProfileData as h, type SocialMediaProfilesData as i };
|
package/dist/studio/index.d.mts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { c as StudioCompileResult, S as StudioDocumentV1, d as StudioInspectorField, e as StudioInspectorPanel, f as StudioMigration, b as StudioModuleManifest, g as StudioNode, h as StudioNodeData, a as StudioNodeTypeDefinition, j as StudioPageService, k as StudioPaletteGroup, l as StudioPaletteItem, m as StudioPermission, n as StudioRegistry, o as StudioValidationIssue, p as
|
|
1
|
+
export { I as ImageUploadOptimizationOptions, c as StudioCompileResult, S as StudioDocumentV1, d as StudioInspectorField, e as StudioInspectorPanel, f as StudioMigration, b as StudioModuleManifest, g as StudioNode, h as StudioNodeData, a as StudioNodeTypeDefinition, j as StudioPageService, k as StudioPaletteGroup, l as StudioPaletteItem, m as StudioPermission, n as StudioRegistry, o as StudioValidationIssue, p as SupportedImageMimeType, q as assertStudioDocumentV1, r as compileStudioDocument, s as createEmptyStudioDocument, t as createImageUploadOptimizationHook, u as createStudioRegistry, v as migrateStudioDocument, w as validateStudioDocument, x as withImageUploadOptimization } from '../index-BzKOThsI.mjs';
|
|
2
|
+
import 'payload';
|
package/dist/studio/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { c as StudioCompileResult, S as StudioDocumentV1, d as StudioInspectorField, e as StudioInspectorPanel, f as StudioMigration, b as StudioModuleManifest, g as StudioNode, h as StudioNodeData, a as StudioNodeTypeDefinition, j as StudioPageService, k as StudioPaletteGroup, l as StudioPaletteItem, m as StudioPermission, n as StudioRegistry, o as StudioValidationIssue, p as
|
|
1
|
+
export { I as ImageUploadOptimizationOptions, c as StudioCompileResult, S as StudioDocumentV1, d as StudioInspectorField, e as StudioInspectorPanel, f as StudioMigration, b as StudioModuleManifest, g as StudioNode, h as StudioNodeData, a as StudioNodeTypeDefinition, j as StudioPageService, k as StudioPaletteGroup, l as StudioPaletteItem, m as StudioPermission, n as StudioRegistry, o as StudioValidationIssue, p as SupportedImageMimeType, q as assertStudioDocumentV1, r as compileStudioDocument, s as createEmptyStudioDocument, t as createImageUploadOptimizationHook, u as createStudioRegistry, v as migrateStudioDocument, w as validateStudioDocument, x as withImageUploadOptimization } from '../index-BzKOThsI.js';
|
|
2
|
+
import 'payload';
|
package/dist/studio/index.js
CHANGED
|
@@ -23,11 +23,178 @@ __export(studio_exports, {
|
|
|
23
23
|
assertStudioDocumentV1: () => assertStudioDocumentV1,
|
|
24
24
|
compileStudioDocument: () => compileStudioDocument,
|
|
25
25
|
createEmptyStudioDocument: () => createEmptyStudioDocument,
|
|
26
|
+
createImageUploadOptimizationHook: () => createImageUploadOptimizationHook,
|
|
26
27
|
createStudioRegistry: () => createStudioRegistry,
|
|
27
28
|
migrateStudioDocument: () => migrateStudioDocument,
|
|
28
|
-
validateStudioDocument: () => validateStudioDocument
|
|
29
|
+
validateStudioDocument: () => validateStudioDocument,
|
|
30
|
+
withImageUploadOptimization: () => withImageUploadOptimization
|
|
29
31
|
});
|
|
30
32
|
module.exports = __toCommonJS(studio_exports);
|
|
33
|
+
|
|
34
|
+
// src/studio/imageUploadOptimization.ts
|
|
35
|
+
var import_promises = require("fs/promises");
|
|
36
|
+
var DEFAULT_SUPPORTED_MIME_TYPES = [
|
|
37
|
+
"image/jpeg",
|
|
38
|
+
"image/jpg",
|
|
39
|
+
"image/png",
|
|
40
|
+
"image/webp",
|
|
41
|
+
"image/avif",
|
|
42
|
+
"image/tiff"
|
|
43
|
+
];
|
|
44
|
+
var DEFAULT_OPTIONS = {
|
|
45
|
+
avifQuality: 50,
|
|
46
|
+
enforceSmallerForLossy: true,
|
|
47
|
+
jpegQuality: 78,
|
|
48
|
+
minBytes: 48 * 1024,
|
|
49
|
+
minQualityFloor: 42,
|
|
50
|
+
onlyIfSmaller: true,
|
|
51
|
+
pngCompressionLevel: 9,
|
|
52
|
+
skipAnimated: true,
|
|
53
|
+
tiffQuality: 75,
|
|
54
|
+
webpQuality: 78
|
|
55
|
+
};
|
|
56
|
+
var clamp = (value, min, max) => Math.max(min, Math.min(max, Math.round(value)));
|
|
57
|
+
var isUploadMutationOperation = (operation) => operation === "create" || operation === "update" || operation === "updateByID";
|
|
58
|
+
var isLossyMimeType = (mimetype) => mimetype === "image/jpeg" || mimetype === "image/jpg" || mimetype === "image/webp" || mimetype === "image/avif" || mimetype === "image/tiff";
|
|
59
|
+
var readIncomingBuffer = async (file) => {
|
|
60
|
+
if (file.tempFilePath) {
|
|
61
|
+
return (0, import_promises.readFile)(file.tempFilePath);
|
|
62
|
+
}
|
|
63
|
+
return file.data;
|
|
64
|
+
};
|
|
65
|
+
var writeOptimizedBuffer = async (file, buffer) => {
|
|
66
|
+
if (file.tempFilePath) {
|
|
67
|
+
await (0, import_promises.unlink)(file.tempFilePath).catch(() => void 0);
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
...file,
|
|
71
|
+
data: buffer,
|
|
72
|
+
size: buffer.length,
|
|
73
|
+
tempFilePath: void 0
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
var createImageUploadOptimizationHook = (options = {}) => {
|
|
77
|
+
const supportedMimeTypes = new Set(options.supportedMimeTypes || DEFAULT_SUPPORTED_MIME_TYPES);
|
|
78
|
+
const settings = { ...DEFAULT_OPTIONS, ...options };
|
|
79
|
+
return async ({ operation, req }) => {
|
|
80
|
+
if (!isUploadMutationOperation(operation)) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const file = req.file;
|
|
84
|
+
if (!file) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (!supportedMimeTypes.has(file.mimetype)) {
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if (typeof file.size === "number" && file.size < settings.minBytes) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const sharpFactory = req.payload?.config?.sharp;
|
|
94
|
+
if (typeof sharpFactory !== "function") {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
const originalBuffer = await readIncomingBuffer(file);
|
|
98
|
+
if (!Buffer.isBuffer(originalBuffer) || originalBuffer.length === 0) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
const animatedInput = file.mimetype === "image/avif" || file.mimetype === "image/webp";
|
|
102
|
+
const metadataProbe = await sharpFactory(
|
|
103
|
+
originalBuffer,
|
|
104
|
+
animatedInput ? {
|
|
105
|
+
animated: true
|
|
106
|
+
} : void 0
|
|
107
|
+
).metadata();
|
|
108
|
+
if (settings.skipAnimated && typeof metadataProbe.pages === "number" && metadataProbe.pages > 1) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const buildPipeline = (qualityOverride) => {
|
|
112
|
+
let pipeline = sharpFactory(
|
|
113
|
+
originalBuffer,
|
|
114
|
+
animatedInput ? {
|
|
115
|
+
animated: true
|
|
116
|
+
} : void 0
|
|
117
|
+
);
|
|
118
|
+
switch (file.mimetype) {
|
|
119
|
+
case "image/jpeg":
|
|
120
|
+
case "image/jpg":
|
|
121
|
+
pipeline = pipeline.jpeg({
|
|
122
|
+
mozjpeg: true,
|
|
123
|
+
progressive: true,
|
|
124
|
+
quality: clamp(qualityOverride ?? settings.jpegQuality, 20, 100)
|
|
125
|
+
});
|
|
126
|
+
break;
|
|
127
|
+
case "image/png":
|
|
128
|
+
pipeline = pipeline.png({
|
|
129
|
+
compressionLevel: clamp(settings.pngCompressionLevel, 0, 9),
|
|
130
|
+
palette: false
|
|
131
|
+
});
|
|
132
|
+
break;
|
|
133
|
+
case "image/webp":
|
|
134
|
+
pipeline = pipeline.webp({
|
|
135
|
+
quality: clamp(qualityOverride ?? settings.webpQuality, 20, 100)
|
|
136
|
+
});
|
|
137
|
+
break;
|
|
138
|
+
case "image/avif":
|
|
139
|
+
pipeline = pipeline.avif({
|
|
140
|
+
quality: clamp(qualityOverride ?? settings.avifQuality, 20, 100)
|
|
141
|
+
});
|
|
142
|
+
break;
|
|
143
|
+
case "image/tiff":
|
|
144
|
+
pipeline = pipeline.tiff({
|
|
145
|
+
quality: clamp(qualityOverride ?? settings.tiffQuality, 20, 100)
|
|
146
|
+
});
|
|
147
|
+
break;
|
|
148
|
+
default:
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
return pipeline;
|
|
152
|
+
};
|
|
153
|
+
const initialPipeline = buildPipeline();
|
|
154
|
+
if (!initialPipeline) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
let optimizedBuffer = await initialPipeline.toBuffer();
|
|
158
|
+
const shouldSweepQuality = settings.enforceSmallerForLossy && isLossyMimeType(file.mimetype);
|
|
159
|
+
if (shouldSweepQuality) {
|
|
160
|
+
const initialQuality = file.mimetype === "image/jpeg" || file.mimetype === "image/jpg" ? settings.jpegQuality : file.mimetype === "image/webp" ? settings.webpQuality : file.mimetype === "image/avif" ? settings.avifQuality : settings.tiffQuality;
|
|
161
|
+
let bestBuffer = optimizedBuffer;
|
|
162
|
+
let quality = clamp(initialQuality - 5, settings.minQualityFloor, 100);
|
|
163
|
+
while (quality >= settings.minQualityFloor) {
|
|
164
|
+
const retryPipeline = buildPipeline(quality);
|
|
165
|
+
if (!retryPipeline) {
|
|
166
|
+
break;
|
|
167
|
+
}
|
|
168
|
+
const retryBuffer = await retryPipeline.toBuffer();
|
|
169
|
+
if (retryBuffer.length < bestBuffer.length) {
|
|
170
|
+
bestBuffer = retryBuffer;
|
|
171
|
+
}
|
|
172
|
+
quality -= 5;
|
|
173
|
+
}
|
|
174
|
+
optimizedBuffer = bestBuffer;
|
|
175
|
+
}
|
|
176
|
+
if (settings.onlyIfSmaller && optimizedBuffer.length >= originalBuffer.length) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
req.file = await writeOptimizedBuffer(file, optimizedBuffer);
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
var withImageUploadOptimization = (collection, options = {}) => {
|
|
183
|
+
if (!collection.upload) {
|
|
184
|
+
return collection;
|
|
185
|
+
}
|
|
186
|
+
const existingHooks = collection.hooks || {};
|
|
187
|
+
const beforeOperation = existingHooks.beforeOperation || [];
|
|
188
|
+
return {
|
|
189
|
+
...collection,
|
|
190
|
+
hooks: {
|
|
191
|
+
...existingHooks,
|
|
192
|
+
beforeOperation: [createImageUploadOptimizationHook(options), ...beforeOperation]
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
// src/studio/index.ts
|
|
31
198
|
var isRecord = (value) => Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
32
199
|
var makeIssue = (message, path, code = "studio.invalid") => ({
|
|
33
200
|
code,
|
|
@@ -148,9 +315,6 @@ function compileStudioDocument(document, modules) {
|
|
|
148
315
|
}
|
|
149
316
|
function migrateStudioDocument(value, migrations) {
|
|
150
317
|
const sorted = [...migrations].sort((a, b) => a.fromVersion - b.fromVersion);
|
|
151
|
-
if (isRecord(value) && value.schemaVersion === 1) {
|
|
152
|
-
return assertStudioDocumentV1(value);
|
|
153
|
-
}
|
|
154
318
|
let current = value;
|
|
155
319
|
for (const migration of sorted) {
|
|
156
320
|
if (!isRecord(current) || current.schemaVersion !== migration.fromVersion) {
|
|
@@ -165,7 +329,9 @@ function migrateStudioDocument(value, migrations) {
|
|
|
165
329
|
assertStudioDocumentV1,
|
|
166
330
|
compileStudioDocument,
|
|
167
331
|
createEmptyStudioDocument,
|
|
332
|
+
createImageUploadOptimizationHook,
|
|
168
333
|
createStudioRegistry,
|
|
169
334
|
migrateStudioDocument,
|
|
170
|
-
validateStudioDocument
|
|
335
|
+
validateStudioDocument,
|
|
336
|
+
withImageUploadOptimization
|
|
171
337
|
});
|
package/dist/studio/index.mjs
CHANGED
|
@@ -2,16 +2,20 @@ import {
|
|
|
2
2
|
assertStudioDocumentV1,
|
|
3
3
|
compileStudioDocument,
|
|
4
4
|
createEmptyStudioDocument,
|
|
5
|
+
createImageUploadOptimizationHook,
|
|
5
6
|
createStudioRegistry,
|
|
6
7
|
migrateStudioDocument,
|
|
7
|
-
validateStudioDocument
|
|
8
|
-
|
|
8
|
+
validateStudioDocument,
|
|
9
|
+
withImageUploadOptimization
|
|
10
|
+
} from "../chunk-ADIIWIYL.mjs";
|
|
9
11
|
import "../chunk-6BWS3CLP.mjs";
|
|
10
12
|
export {
|
|
11
13
|
assertStudioDocumentV1,
|
|
12
14
|
compileStudioDocument,
|
|
13
15
|
createEmptyStudioDocument,
|
|
16
|
+
createImageUploadOptimizationHook,
|
|
14
17
|
createStudioRegistry,
|
|
15
18
|
migrateStudioDocument,
|
|
16
|
-
validateStudioDocument
|
|
19
|
+
validateStudioDocument,
|
|
20
|
+
withImageUploadOptimization
|
|
17
21
|
};
|