@playcademy/sdk 0.12.1-beta.3 → 0.13.0-beta.1

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.
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Content-addressable asset resolver.
3
+ *
4
+ * Provides a synchronous `asset()` function that maps logical asset paths
5
+ * to their content-hashed R2 URLs. The manifest is injected into the page
6
+ * by the edge worker via HTMLRewriter before any JS modules evaluate,
7
+ * so `asset()` is safe to use at module scope.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { asset } from '@playcademy/sdk/assets'
12
+ *
13
+ * // Regular function call
14
+ * const heroUrl = asset('sprites/hero.png')
15
+ *
16
+ * // Tagged template literal
17
+ * const bossUrl = asset`bosses/${bossId}/idle.png`
18
+ *
19
+ * // Module-scope constants (safe — manifest is available before module evaluation)
20
+ * const ASSETS = {
21
+ * bg: asset('backgrounds/title.webp'),
22
+ * music: asset('audio/theme.mp3'),
23
+ * }
24
+ * ```
25
+ *
26
+ * @module
27
+ */
28
+ /**
29
+ * Resolves a logical asset path to its content-hashed URL.
30
+ *
31
+ * Supports both regular function calls and tagged template literals:
32
+ * - `asset('sprites/hero.png')` — string argument
33
+ * - `asset\`sprites/${name}.png\`` — tagged template
34
+ *
35
+ * When no manifest is available (local dev, or the game doesn't use the asset
36
+ * pipeline), returns the path unchanged.
37
+ */
38
+ declare function asset(pathOrStrings: string | TemplateStringsArray, ...values: unknown[]): string;
39
+
40
+ export { asset };
package/dist/assets.js ADDED
@@ -0,0 +1,38 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __export = (target, all) => {
3
+ for (var name in all)
4
+ __defProp(target, name, {
5
+ get: all[name],
6
+ enumerable: true,
7
+ configurable: true,
8
+ set: (newValue) => all[name] = () => newValue
9
+ });
10
+ };
11
+ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
12
+
13
+ // src/assets.ts
14
+ function getManifest() {
15
+ return globalThis.__PLAYCADEMY_ASSET_MANIFEST ?? null;
16
+ }
17
+ function asset(pathOrStrings, ...values) {
18
+ let path;
19
+ if (Array.isArray(pathOrStrings) && "raw" in pathOrStrings) {
20
+ const strings = pathOrStrings;
21
+ path = strings.reduce((acc, str, i) => acc + str + (values[i] != null ? String(values[i]) : ""), "");
22
+ } else {
23
+ path = pathOrStrings;
24
+ }
25
+ const cleanPath = path.startsWith("./") ? path.slice(2) : path;
26
+ const manifest = getManifest();
27
+ if (!manifest) {
28
+ return cleanPath;
29
+ }
30
+ const hashedKey = manifest.files[cleanPath];
31
+ if (hashedKey === undefined) {
32
+ return cleanPath;
33
+ }
34
+ return manifest.base != null ? `${manifest.base}${hashedKey}` : hashedKey;
35
+ }
36
+ export {
37
+ asset
38
+ };
package/dist/index.js CHANGED
@@ -2379,7 +2379,7 @@ async function request({
2379
2379
  return rawText && rawText.length > 0 ? rawText : undefined;
2380
2380
  }
2381
2381
  // src/version.ts
2382
- var SDK_VERSION = "0.12.1-beta.3";
2382
+ var SDK_VERSION = "0.13.0-beta.1";
2383
2383
 
2384
2384
  // src/clients/base.ts
2385
2385
  class PlaycademyBaseClient {
@@ -2215,7 +2215,7 @@ declare const UpsertGameMetadataSchema: z.ZodEffects<z.ZodObject<{
2215
2215
  metadata: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>>>;
2216
2216
  gameType: z.ZodDefault<z.ZodOptional<z.ZodEnum<["hosted", "external"]>>>;
2217
2217
  visibility: z.ZodOptional<z.ZodEnum<["visible", "unlisted", "internal"]>>;
2218
- externalUrl: z.ZodOptional<z.ZodString>;
2218
+ externalUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
2219
2219
  }, "strip", z.ZodTypeAny, {
2220
2220
  displayName: string;
2221
2221
  platform: "godot" | "unity" | "web";
@@ -2631,6 +2631,17 @@ interface CustomRoutesIntegration {
2631
2631
  /** Directory for custom API routes (defaults to 'server/api') */
2632
2632
  directory?: string;
2633
2633
  }
2634
+ /**
2635
+ * Bucket storage integration
2636
+ */
2637
+ interface BucketIntegration {
2638
+ /**
2639
+ * Directory whose contents are synced to the bucket by `playcademy bucket
2640
+ * sync` (defaults to 'bucket'). Synced as a single content-addressed tree:
2641
+ * the whole directory is the manifest's source of truth.
2642
+ */
2643
+ directory?: string;
2644
+ }
2634
2645
  /**
2635
2646
  * Database integration
2636
2647
  */
@@ -2663,7 +2674,7 @@ interface IntegrationsConfig {
2663
2674
  /** Key-Value storage (optional) */
2664
2675
  kv?: boolean;
2665
2676
  /** Bucket storage (optional) */
2666
- bucket?: boolean;
2677
+ bucket?: BucketIntegration | boolean;
2667
2678
  /** Authentication (optional) */
2668
2679
  auth?: boolean;
2669
2680
  /** Queues (optional) */
package/dist/internal.js CHANGED
@@ -3070,7 +3070,7 @@ async function request({
3070
3070
  return rawText && rawText.length > 0 ? rawText : undefined;
3071
3071
  }
3072
3072
  // src/version.ts
3073
- var SDK_VERSION = "0.12.1-beta.3";
3073
+ var SDK_VERSION = "0.13.0-beta.1";
3074
3074
 
3075
3075
  // src/clients/base.ts
3076
3076
  class PlaycademyBaseClient {
@@ -64,6 +64,17 @@ interface CustomRoutesIntegration {
64
64
  /** Directory for custom API routes (defaults to 'server/api') */
65
65
  directory?: string;
66
66
  }
67
+ /**
68
+ * Bucket storage integration
69
+ */
70
+ interface BucketIntegration {
71
+ /**
72
+ * Directory whose contents are synced to the bucket by `playcademy bucket
73
+ * sync` (defaults to 'bucket'). Synced as a single content-addressed tree:
74
+ * the whole directory is the manifest's source of truth.
75
+ */
76
+ directory?: string;
77
+ }
67
78
  /**
68
79
  * Database integration
69
80
  */
@@ -96,7 +107,7 @@ interface IntegrationsConfig {
96
107
  /** Key-Value storage (optional) */
97
108
  kv?: boolean;
98
109
  /** Bucket storage (optional) */
99
- bucket?: boolean;
110
+ bucket?: BucketIntegration | boolean;
100
111
  /** Authentication (optional) */
101
112
  auth?: boolean;
102
113
  /** Queues (optional) */
@@ -233,7 +233,7 @@ function extractApiErrorInfo(error) {
233
233
  }
234
234
 
235
235
  // src/version.ts
236
- var SDK_VERSION = "0.12.1-beta.3";
236
+ var SDK_VERSION = "0.13.0-beta.1";
237
237
 
238
238
  // src/server/request.ts
239
239
  async function makeApiRequest(opts) {
package/dist/server.d.ts CHANGED
@@ -64,6 +64,17 @@ interface CustomRoutesIntegration {
64
64
  /** Directory for custom API routes (defaults to 'server/api') */
65
65
  directory?: string;
66
66
  }
67
+ /**
68
+ * Bucket storage integration
69
+ */
70
+ interface BucketIntegration {
71
+ /**
72
+ * Directory whose contents are synced to the bucket by `playcademy bucket
73
+ * sync` (defaults to 'bucket'). Synced as a single content-addressed tree:
74
+ * the whole directory is the manifest's source of truth.
75
+ */
76
+ directory?: string;
77
+ }
67
78
  /**
68
79
  * Database integration
69
80
  */
@@ -96,7 +107,7 @@ interface IntegrationsConfig {
96
107
  /** Key-Value storage (optional) */
97
108
  kv?: boolean;
98
109
  /** Bucket storage (optional) */
99
- bucket?: boolean;
110
+ bucket?: BucketIntegration | boolean;
100
111
  /** Authentication (optional) */
101
112
  auth?: boolean;
102
113
  /** Queues (optional) */
package/dist/server.js CHANGED
@@ -422,7 +422,7 @@ function extractApiErrorInfo(error) {
422
422
  }
423
423
 
424
424
  // src/version.ts
425
- var SDK_VERSION = "0.12.1-beta.3";
425
+ var SDK_VERSION = "0.13.0-beta.1";
426
426
 
427
427
  // src/server/request.ts
428
428
  async function makeApiRequest(opts) {
package/dist/types.d.ts CHANGED
@@ -257,6 +257,17 @@ interface CustomRoutesIntegration {
257
257
  /** Directory for custom API routes (defaults to 'server/api') */
258
258
  directory?: string;
259
259
  }
260
+ /**
261
+ * Bucket storage integration
262
+ */
263
+ interface BucketIntegration {
264
+ /**
265
+ * Directory whose contents are synced to the bucket by `playcademy bucket
266
+ * sync` (defaults to 'bucket'). Synced as a single content-addressed tree:
267
+ * the whole directory is the manifest's source of truth.
268
+ */
269
+ directory?: string;
270
+ }
260
271
  /**
261
272
  * Database integration
262
273
  */
@@ -289,7 +300,7 @@ interface IntegrationsConfig {
289
300
  /** Key-Value storage (optional) */
290
301
  kv?: boolean;
291
302
  /** Bucket storage (optional) */
292
- bucket?: boolean;
303
+ bucket?: BucketIntegration | boolean;
293
304
  /** Authentication (optional) */
294
305
  auth?: boolean;
295
306
  /** Queues (optional) */
@@ -1049,7 +1060,7 @@ declare const UpsertGameMetadataSchema: z.ZodEffects<z.ZodObject<{
1049
1060
  metadata: z.ZodDefault<z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodUnknown>, Record<string, unknown>, Record<string, unknown>>>>;
1050
1061
  gameType: z.ZodDefault<z.ZodOptional<z.ZodEnum<["hosted", "external"]>>>;
1051
1062
  visibility: z.ZodOptional<z.ZodEnum<["visible", "unlisted", "internal"]>>;
1052
- externalUrl: z.ZodOptional<z.ZodString>;
1063
+ externalUrl: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
1053
1064
  }, "strip", z.ZodTypeAny, {
1054
1065
  displayName: string;
1055
1066
  platform: "godot" | "unity" | "web";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playcademy/sdk",
3
- "version": "0.12.1-beta.3",
3
+ "version": "0.13.0-beta.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -33,6 +33,12 @@
33
33
  "import": "./dist/server/edge.js",
34
34
  "require": "./dist/server/edge.js"
35
35
  },
36
+ "./assets": {
37
+ "source": "./src/assets.ts",
38
+ "types": "./dist/assets.d.ts",
39
+ "import": "./dist/assets.js",
40
+ "require": "./dist/assets.js"
41
+ },
36
42
  "./test": {
37
43
  "import": "./src/test.ts",
38
44
  "types": "./src/test.ts"