@playcademy/vite-plugin 1.2.1-beta.6 → 1.2.1-beta.7
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.js +81 -26
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -24315,7 +24315,7 @@ import path2 from "node:path";
|
|
|
24315
24315
|
// package.json
|
|
24316
24316
|
var package_default = {
|
|
24317
24317
|
name: "@playcademy/vite-plugin",
|
|
24318
|
-
version: "1.2.1-beta.
|
|
24318
|
+
version: "1.2.1-beta.7",
|
|
24319
24319
|
type: "module",
|
|
24320
24320
|
exports: {
|
|
24321
24321
|
".": {
|
|
@@ -25913,7 +25913,7 @@ var package_default2;
|
|
|
25913
25913
|
var init_package = __esm(() => {
|
|
25914
25914
|
package_default2 = {
|
|
25915
25915
|
name: "@playcademy/sandbox",
|
|
25916
|
-
version: "0.7.1-beta.
|
|
25916
|
+
version: "0.7.1-beta.7",
|
|
25917
25917
|
description: "Local development server for Playcademy game development",
|
|
25918
25918
|
type: "module",
|
|
25919
25919
|
exports: {
|
|
@@ -57204,6 +57204,9 @@ var init_assessment_runtime_lock_util = __esm(() => {
|
|
|
57204
57204
|
init_locks();
|
|
57205
57205
|
init_errors2();
|
|
57206
57206
|
});
|
|
57207
|
+
function hasPagingOptions(options) {
|
|
57208
|
+
return options.cursor !== undefined || options.limit !== undefined || options.delimiter !== undefined;
|
|
57209
|
+
}
|
|
57207
57210
|
|
|
57208
57211
|
class BucketService {
|
|
57209
57212
|
deps;
|
|
@@ -57225,16 +57228,18 @@ class BucketService {
|
|
|
57225
57228
|
getBucketName(slug) {
|
|
57226
57229
|
return getGameDeploymentId(slug, this.deps.sstStage);
|
|
57227
57230
|
}
|
|
57228
|
-
async listFiles(slug, user,
|
|
57231
|
+
async listFiles(slug, user, options = {}) {
|
|
57229
57232
|
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
57230
57233
|
const bucketName = this.getBucketName(game2.slug);
|
|
57231
|
-
const
|
|
57234
|
+
const paged = hasPagingOptions(options);
|
|
57235
|
+
const page = paged ? await this.deps.storage.listObjectsPage(bucketName, options) : { files: await this.deps.storage.listObjects(bucketName, options.prefix) };
|
|
57232
57236
|
setAttributes({
|
|
57233
57237
|
"app.bucket.operation": "list",
|
|
57234
|
-
"app.bucket.file_count": files.length,
|
|
57235
|
-
"app.bucket.key_prefix": BucketService.getKeyPrefix(prefix)
|
|
57238
|
+
"app.bucket.file_count": page.files.length,
|
|
57239
|
+
"app.bucket.key_prefix": BucketService.getKeyPrefix(options.prefix),
|
|
57240
|
+
"app.bucket.paged": paged
|
|
57236
57241
|
});
|
|
57237
|
-
return
|
|
57242
|
+
return page;
|
|
57238
57243
|
}
|
|
57239
57244
|
async getFile(slug, key, user) {
|
|
57240
57245
|
const game2 = await this.deps.validateDeveloperAccessBySlug(user, slug);
|
|
@@ -121020,6 +121025,11 @@ var cache;
|
|
|
121020
121025
|
var init_cache_provider = __esm(() => {
|
|
121021
121026
|
cache = new Map;
|
|
121022
121027
|
});
|
|
121028
|
+
function keyLevelEntry(key, prefix, delimiter) {
|
|
121029
|
+
const remainder = key.slice(prefix.length);
|
|
121030
|
+
const cut = remainder.indexOf(delimiter);
|
|
121031
|
+
return cut === -1 ? { name: key, rolled: false } : { name: prefix + remainder.slice(0, cut + delimiter.length), rolled: true };
|
|
121032
|
+
}
|
|
121023
121033
|
function getBucket2(bucketName) {
|
|
121024
121034
|
let bucket = storage.get(bucketName);
|
|
121025
121035
|
if (!bucket) {
|
|
@@ -121032,18 +121042,57 @@ function createSandboxStorageProvider() {
|
|
|
121032
121042
|
return {
|
|
121033
121043
|
async listObjects(bucketName, prefix) {
|
|
121034
121044
|
const bucket = getBucket2(bucketName);
|
|
121045
|
+
const keys = [...bucket.keys()].filter((key) => !prefix || key.startsWith(prefix)).toSorted();
|
|
121046
|
+
return keys.map((key) => {
|
|
121047
|
+
const data = bucket.get(key);
|
|
121048
|
+
return {
|
|
121049
|
+
key,
|
|
121050
|
+
size: data.body.length,
|
|
121051
|
+
lastModified: new Date().toISOString(),
|
|
121052
|
+
contentType: data.contentType
|
|
121053
|
+
};
|
|
121054
|
+
});
|
|
121055
|
+
},
|
|
121056
|
+
async listObjectsPage(bucketName, options) {
|
|
121057
|
+
const { cursor: cursor2, delimiter } = options;
|
|
121058
|
+
const all = await this.listObjects(bucketName, options.prefix);
|
|
121059
|
+
let entries;
|
|
121060
|
+
if (delimiter) {
|
|
121061
|
+
const requestPrefix = options.prefix ?? "";
|
|
121062
|
+
const seen = new Set;
|
|
121063
|
+
entries = [];
|
|
121064
|
+
for (const file3 of all) {
|
|
121065
|
+
const entry2 = keyLevelEntry(file3.key, requestPrefix, delimiter);
|
|
121066
|
+
if (!entry2.rolled) {
|
|
121067
|
+
entries.push({ name: entry2.name, file: file3 });
|
|
121068
|
+
} else if (!seen.has(entry2.name)) {
|
|
121069
|
+
seen.add(entry2.name);
|
|
121070
|
+
entries.push({ name: entry2.name });
|
|
121071
|
+
}
|
|
121072
|
+
}
|
|
121073
|
+
} else {
|
|
121074
|
+
entries = all.map((file3) => ({ name: file3.key, file: file3 }));
|
|
121075
|
+
}
|
|
121076
|
+
const remaining = cursor2 ? entries.filter((entry2) => entry2.name > cursor2) : entries;
|
|
121077
|
+
const limit = options.limit ?? 1000;
|
|
121078
|
+
const pageEntries = remaining.slice(0, limit);
|
|
121035
121079
|
const files = [];
|
|
121036
|
-
|
|
121037
|
-
|
|
121038
|
-
|
|
121039
|
-
|
|
121040
|
-
|
|
121041
|
-
|
|
121042
|
-
contentType: data.contentType
|
|
121043
|
-
});
|
|
121080
|
+
const prefixes = [];
|
|
121081
|
+
for (const entry2 of pageEntries) {
|
|
121082
|
+
if (entry2.file) {
|
|
121083
|
+
files.push(entry2.file);
|
|
121084
|
+
} else {
|
|
121085
|
+
prefixes.push(entry2.name);
|
|
121044
121086
|
}
|
|
121045
121087
|
}
|
|
121046
|
-
|
|
121088
|
+
const page = { files };
|
|
121089
|
+
if (prefixes.length > 0) {
|
|
121090
|
+
page.prefixes = prefixes;
|
|
121091
|
+
}
|
|
121092
|
+
if (remaining.length > limit) {
|
|
121093
|
+
page.cursor = pageEntries[pageEntries.length - 1].name;
|
|
121094
|
+
}
|
|
121095
|
+
return page;
|
|
121047
121096
|
},
|
|
121048
121097
|
async getObject(bucketName, key) {
|
|
121049
121098
|
const bucket = getBucket2(bucketName);
|
|
@@ -179495,6 +179544,17 @@ function requireUserId(userId) {
|
|
|
179495
179544
|
}
|
|
179496
179545
|
return userId;
|
|
179497
179546
|
}
|
|
179547
|
+
function parseLimitParam(url4, max2) {
|
|
179548
|
+
const raw2 = url4.searchParams.get("limit");
|
|
179549
|
+
if (raw2 === null) {
|
|
179550
|
+
return;
|
|
179551
|
+
}
|
|
179552
|
+
const limit = Number(raw2);
|
|
179553
|
+
if (!Number.isInteger(limit) || limit < 1 || limit > max2) {
|
|
179554
|
+
throw ApiError.badRequest(`limit must be an integer between 1 and ${max2}`);
|
|
179555
|
+
}
|
|
179556
|
+
return limit;
|
|
179557
|
+
}
|
|
179498
179558
|
var init_params_util = __esm(() => {
|
|
179499
179559
|
init_src5();
|
|
179500
179560
|
init_errors2();
|
|
@@ -179566,8 +179626,10 @@ var init_bucket_controller = __esm(() => {
|
|
|
179566
179626
|
}
|
|
179567
179627
|
const url4 = ctx.url;
|
|
179568
179628
|
const prefix2 = url4.searchParams.get("prefix") || undefined;
|
|
179569
|
-
const
|
|
179570
|
-
|
|
179629
|
+
const cursor2 = url4.searchParams.get("cursor") || undefined;
|
|
179630
|
+
const delimiter = url4.searchParams.get("delimiter") || undefined;
|
|
179631
|
+
const limit = parseLimitParam(url4, 1000);
|
|
179632
|
+
return ctx.services.bucket.listFiles(slug2, ctx.user, { prefix: prefix2, cursor: cursor2, limit, delimiter });
|
|
179571
179633
|
});
|
|
179572
179634
|
getFile = requireDeveloper(async (ctx) => {
|
|
179573
179635
|
const slug2 = ctx.params.slug;
|
|
@@ -179842,14 +179904,7 @@ var init_deployment_state_controller = __esm(() => {
|
|
|
179842
179904
|
});
|
|
179843
179905
|
history = requireDeveloper(async (ctx) => {
|
|
179844
179906
|
const slug2 = requireSlug(ctx.params.slug);
|
|
179845
|
-
const
|
|
179846
|
-
let limit;
|
|
179847
|
-
if (limitParam !== null) {
|
|
179848
|
-
limit = Number(limitParam);
|
|
179849
|
-
if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
|
|
179850
|
-
throw ApiError.badRequest("limit must be an integer between 1 and 100");
|
|
179851
|
-
}
|
|
179852
|
-
}
|
|
179907
|
+
const limit = parseLimitParam(ctx.url, 100);
|
|
179853
179908
|
return ctx.services.deploymentState.history(slug2, ctx.user, { limit });
|
|
179854
179909
|
});
|
|
179855
179910
|
restorePoints = requireDeveloper(async (ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@playcademy/vite-plugin",
|
|
3
|
-
"version": "1.2.1-beta.
|
|
3
|
+
"version": "1.2.1-beta.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
"dependencies": {
|
|
20
20
|
"archiver": "^7.0.1",
|
|
21
21
|
"picocolors": "^1.1.1",
|
|
22
|
-
"playcademy": "0.28.1-beta.
|
|
22
|
+
"playcademy": "0.28.1-beta.7"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@electric-sql/pglite": "^0.3.16",
|
|
26
26
|
"@inquirer/prompts": "^7.8.6",
|
|
27
27
|
"@playcademy/constants": "0.0.1",
|
|
28
|
-
"@playcademy/sandbox": "0.7.1-beta.
|
|
29
|
-
"@playcademy/sdk": "0.16.1-beta.
|
|
28
|
+
"@playcademy/sandbox": "0.7.1-beta.7",
|
|
29
|
+
"@playcademy/sdk": "0.16.1-beta.7",
|
|
30
30
|
"@playcademy/types": "0.0.1",
|
|
31
31
|
"@playcademy/utils": "0.0.1",
|
|
32
32
|
"@types/archiver": "^6.0.3",
|