@epic-web/workshop-utils 6.60.0 → 6.61.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/dist/apps.server.d.ts +8 -0
- package/dist/apps.server.js +40 -0
- package/package.json +1 -1
package/dist/apps.server.d.ts
CHANGED
|
@@ -4871,6 +4871,14 @@ export declare function getAppFromFile(filePath: string): Promise<{
|
|
|
4871
4871
|
epicVideoEmbeds?: string[] | undefined;
|
|
4872
4872
|
} | undefined>;
|
|
4873
4873
|
export declare function savePlayground(): Promise<void>;
|
|
4874
|
+
export type SavedPlayground = {
|
|
4875
|
+
id: string;
|
|
4876
|
+
appName: string;
|
|
4877
|
+
createdAt: string;
|
|
4878
|
+
createdAtMs: number;
|
|
4879
|
+
fullPath: string;
|
|
4880
|
+
};
|
|
4881
|
+
export declare function getSavedPlaygrounds(): Promise<Array<SavedPlayground>>;
|
|
4874
4882
|
export declare function setPlayground(srcDir: string, { reset }?: {
|
|
4875
4883
|
reset?: boolean;
|
|
4876
4884
|
}): Promise<void>;
|
package/dist/apps.server.js
CHANGED
|
@@ -1049,6 +1049,46 @@ locally and uncheck "Enable saving playground."
|
|
|
1049
1049
|
}
|
|
1050
1050
|
await fsExtra.copy(playgroundDir, path.join(savedPlaygroundsDir, savedPlaygroundDirName));
|
|
1051
1051
|
}
|
|
1052
|
+
const savedPlaygroundTimestampPattern = /^(\d{4})\.(\d{2})\.(\d{2})_(\d{2})\.(\d{2})\.(\d{2})$/;
|
|
1053
|
+
function parseSavedPlaygroundDirName(dirName) {
|
|
1054
|
+
const parts = dirName.split('_');
|
|
1055
|
+
if (parts.length < 3)
|
|
1056
|
+
return null;
|
|
1057
|
+
const timestampPart = `${parts[0]}_${parts[1]}`;
|
|
1058
|
+
const appName = parts.slice(2).join('_') || dirName;
|
|
1059
|
+
const match = savedPlaygroundTimestampPattern.exec(timestampPart);
|
|
1060
|
+
if (!match)
|
|
1061
|
+
return null;
|
|
1062
|
+
const [, year, month, day, hour, minute, second] = match;
|
|
1063
|
+
const createdAt = new Date(Number(year), Number(month) - 1, Number(day), Number(hour), Number(minute), Number(second));
|
|
1064
|
+
if (Number.isNaN(createdAt.getTime()))
|
|
1065
|
+
return null;
|
|
1066
|
+
return { appName, createdAt };
|
|
1067
|
+
}
|
|
1068
|
+
export async function getSavedPlaygrounds() {
|
|
1069
|
+
const savedPlaygroundsDir = path.join(getWorkshopRoot(), 'saved-playgrounds');
|
|
1070
|
+
if (!(await exists(savedPlaygroundsDir)))
|
|
1071
|
+
return [];
|
|
1072
|
+
const dirEntries = await fsExtra.readdir(savedPlaygroundsDir, {
|
|
1073
|
+
withFileTypes: true,
|
|
1074
|
+
});
|
|
1075
|
+
const savedPlaygrounds = await Promise.all(dirEntries
|
|
1076
|
+
.filter((entry) => entry.isDirectory())
|
|
1077
|
+
.map(async (entry) => {
|
|
1078
|
+
const fullPath = path.join(savedPlaygroundsDir, entry.name);
|
|
1079
|
+
const parsed = parseSavedPlaygroundDirName(entry.name);
|
|
1080
|
+
const stat = await fsExtra.stat(fullPath).catch(() => null);
|
|
1081
|
+
const createdAt = parsed?.createdAt ?? (stat ? new Date(stat.mtimeMs) : new Date(0));
|
|
1082
|
+
return {
|
|
1083
|
+
id: entry.name,
|
|
1084
|
+
appName: parsed?.appName ?? entry.name,
|
|
1085
|
+
createdAt: createdAt.toISOString(),
|
|
1086
|
+
createdAtMs: createdAt.getTime(),
|
|
1087
|
+
fullPath,
|
|
1088
|
+
};
|
|
1089
|
+
}));
|
|
1090
|
+
return savedPlaygrounds.sort((a, b) => b.createdAtMs - a.createdAtMs);
|
|
1091
|
+
}
|
|
1052
1092
|
export async function setPlayground(srcDir, { reset } = {}) {
|
|
1053
1093
|
const preferences = await getPreferences();
|
|
1054
1094
|
const playgroundApp = await getAppByName('playground');
|