@playdrop/playdrop-cli 0.13.8 → 0.13.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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "0.13.8",
2
+ "version": "0.13.10",
3
3
  "build": 1,
4
- "runtimeSdkVersion": "0.13.8",
4
+ "runtimeSdkVersion": "0.13.10",
5
5
  "runtimeSdkBuild": 1,
6
6
  "clients": {
7
7
  "all": {
@@ -24,5 +24,6 @@ export declare function prepareStaticHtmlProject(input: {
24
24
  taskId?: number;
25
25
  appName?: string;
26
26
  primarySurface: AppSurface;
27
+ cdnBase: string;
27
28
  }): Promise<PreparedStaticHtmlProject>;
28
29
  export declare function sha256File(filePath: string): string;
@@ -266,15 +266,27 @@ function buildStaticAppTask(input) {
266
266
  graph: { relations: [] },
267
267
  };
268
268
  }
269
- const STATIC_SDK_BOOTSTRAP = [
270
- '<script src="/sdk/playdrop.js" data-playdrop-static-sdk></script>',
271
- '<script data-playdrop-static-bootstrap>',
272
- 'window.addEventListener("load", async () => {',
273
- ' const sdk = await window.playdrop.init();',
274
- ' await sdk.host.ready();',
275
- '}, { once: true });',
276
- '</script>',
277
- ].join('\n');
269
+ function buildStaticSdkBootstrap(cdnBase) {
270
+ let sdkUrl;
271
+ try {
272
+ sdkUrl = new URL('sdk/playdrop.js', `${cdnBase.trim().replace(/\/+$/, '')}/`);
273
+ }
274
+ catch {
275
+ throw new Error('static_game_sdk_base_invalid');
276
+ }
277
+ if (sdkUrl.protocol !== 'http:' && sdkUrl.protocol !== 'https:') {
278
+ throw new Error('static_game_sdk_base_invalid');
279
+ }
280
+ return [
281
+ `<script src="${sdkUrl.toString()}" data-playdrop-static-sdk></script>`,
282
+ '<script data-playdrop-static-bootstrap>',
283
+ 'window.addEventListener("load", async () => {',
284
+ ' const sdk = await window.playdrop.init();',
285
+ ' await sdk.host.ready();',
286
+ '}, { once: true });',
287
+ '</script>',
288
+ ].join('\n');
289
+ }
278
290
  async function prepareStaticHtmlProject(input) {
279
291
  const sourceRoot = (0, node_fs_1.realpathSync)((0, node_path_1.resolve)(input.projectDir));
280
292
  const sourceEntryPath = (0, node_path_1.join)(sourceRoot, 'index.html');
@@ -304,7 +316,7 @@ async function prepareStaticHtmlProject(input) {
304
316
  });
305
317
  const runtimeEntryPath = (0, node_path_1.join)(runtimeDir, 'index.html');
306
318
  const sourceHtml = parsedProject.html;
307
- const runtimeHtml = `${sourceHtml.slice(0, parsedProject.headEndOffset)}${STATIC_SDK_BOOTSTRAP}\n${sourceHtml.slice(parsedProject.headEndOffset)}`;
319
+ const runtimeHtml = `${sourceHtml.slice(0, parsedProject.headEndOffset)}${buildStaticSdkBootstrap(input.cdnBase)}\n${sourceHtml.slice(parsedProject.headEndOffset)}`;
308
320
  await (0, promises_1.writeFile)(runtimeEntryPath, runtimeHtml, 'utf8');
309
321
  const runtimeTask = buildStaticAppTask({
310
322
  projectDir: runtimeDir,
@@ -42,8 +42,7 @@ const LEGACY_SDK_SYMBOL_PATTERNS = [
42
42
  { symbol: 'loadEntity(', pattern: /\.\s*loadEntity\s*\(/g },
43
43
  ];
44
44
  const SDK_REFERENCE_PATTERNS = [
45
- /https:\/\/assets\.playdrop\.ai\/sdk\/playdrop\.js/g,
46
- /["']\/sdk\/playdrop\.js(?:[?"'])/g,
45
+ /\/sdk\/playdrop\.js(?:[?"'])/g,
47
46
  /@playdrop\/sdk(?:\/browser)?/g,
48
47
  ];
49
48
  const SDK_INIT_PATTERNS = [
@@ -651,25 +651,6 @@ function createDevRouterServer(initialPort = exports.DEV_ROUTER_PORT) {
651
651
  });
652
652
  return;
653
653
  }
654
- if (pathname.startsWith('/sdk/') && (method === 'GET' || method === 'HEAD')) {
655
- const assetsBase = process.env.ASSETS_BASE_URL?.trim();
656
- if (!assetsBase) {
657
- respondWithText(res, method, 500, 'ASSETS_BASE_URL is required to serve the development SDK.');
658
- return;
659
- }
660
- let sdkUrl;
661
- try {
662
- sdkUrl = new URL(`${pathname}${requestUrl.search}`, `${assetsBase.replace(/\/$/, '')}/`);
663
- }
664
- catch {
665
- respondWithText(res, method, 500, 'ASSETS_BASE_URL is invalid.');
666
- return;
667
- }
668
- res.statusCode = 307;
669
- res.setHeader('Location', sdkUrl.toString());
670
- res.end();
671
- return;
672
- }
673
654
  if (pathname.startsWith(`${CONTROL_PREFIX}/apps/dev/`) && pathname.endsWith('/runtime-assets') && method === 'GET') {
674
655
  cleanupStaleRouterMounts();
675
656
  const segments = pathname.split('/').filter(Boolean);
@@ -43,6 +43,7 @@ export type StaticHtmlPublishInput = {
43
43
  primarySurface: 'DESKTOP' | 'MOBILE_LANDSCAPE' | 'MOBILE_PORTRAIT';
44
44
  apiBase: string;
45
45
  webBase?: string | null;
46
+ cdnBase: string;
46
47
  token: string;
47
48
  user: UserResponse;
48
49
  taskId?: number;
@@ -1178,6 +1178,9 @@ async function upload(pathOrName, options) {
1178
1178
  if (!userInfo.username || !userInfo.user) {
1179
1179
  throw new Error('static_game_publish_authenticated_user_missing');
1180
1180
  }
1181
+ if (!envConfig.cdnBase) {
1182
+ throw new Error('static_game_publish_cdn_base_missing');
1183
+ }
1181
1184
  const result = await publishStaticHtmlProject({
1182
1185
  client,
1183
1186
  projectDir: (0, node_path_1.dirname)(directEntryPath),
@@ -1185,6 +1188,7 @@ async function upload(pathOrName, options) {
1185
1188
  primarySurface: 'DESKTOP',
1186
1189
  apiBase: envConfig.apiBase,
1187
1190
  webBase: envConfig.webBase,
1191
+ cdnBase: envConfig.cdnBase,
1188
1192
  token: ctx.token,
1189
1193
  user: userInfo.user,
1190
1194
  });
@@ -1925,6 +1929,7 @@ async function publishStaticHtmlProject(input) {
1925
1929
  taskId: input.taskId,
1926
1930
  appName: input.claimedAppName?.trim() || undefined,
1927
1931
  primarySurface: input.primarySurface,
1932
+ cdnBase: input.cdnBase,
1928
1933
  });
1929
1934
  try {
1930
1935
  if (input.taskId !== undefined && !input.claimedAppName?.trim()) {
@@ -4748,6 +4748,9 @@ async function startWorker(options = {}) {
4748
4748
  if (!agentWorkspaceDir) {
4749
4749
  throw new Error('static_game_artifact_workspace_missing');
4750
4750
  }
4751
+ if (!envConfig.cdnBase) {
4752
+ throw new Error('static_game_publish_cdn_base_missing');
4753
+ }
4751
4754
  await client.workerCreateAgentTaskEvent(task.id, {
4752
4755
  workerKey,
4753
4756
  leaseToken,
@@ -4772,6 +4775,7 @@ async function startWorker(options = {}) {
4772
4775
  primarySurface,
4773
4776
  apiBase: envConfig.apiBase,
4774
4777
  webBase: envConfig.webBase ?? null,
4778
+ cdnBase: envConfig.cdnBase,
4775
4779
  claimedAppName: refreshed.task.claimedAppName,
4776
4780
  devRouterPort: devPort,
4777
4781
  token,
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "0.13.8",
2
+ "version": "0.13.10",
3
3
  "build": 1,
4
- "runtimeSdkVersion": "0.13.8",
4
+ "runtimeSdkVersion": "0.13.10",
5
5
  "runtimeSdkBuild": 1,
6
6
  "clients": {
7
7
  "all": {
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-service-origins.d.ts","sourceRoot":"","sources":["../../src/runtime-service-origins.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,6BAA6B;;;;;;;CAOhC,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAAG,MAAM,OAAO,6BAA6B,CAAC;AAC5E,MAAM,MAAM,eAAe,GAAG,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,OAAO,CAAC;AAoEpE,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CA0B/E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;CAC1B,GAAG,MAAM,CAQT;AA2BD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAA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B,0BAA0B,CAAC,KAAK,EAAE;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,eAAe,CAAC;CAC1B,GAAG,MAAM,CAQT;AA2BD,wBAAgB,4BAA4B,CAAC,KAAK,EAAE;IAClD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAChD,GAAG,MAAM,CAgCT;AAED,wBAAgB,wBAAwB,CAAC,KAAK,EAAE;IAC9C,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,MAAM,CAOT;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE;IACnD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,MAAM,CAkCT;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE;IACjD,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B,GAAG,MAAM,CAwBT;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAUjD;AAED,wBAAgB,6BAA6B,IAAI,MAAM,CAUtD;AAED,wBAAgB,2BAA2B,IAAI,MAAM,CAUpD"}
@@ -187,6 +187,10 @@ function resolveRuntimeRealtimeBaseUrl(input) {
187
187
  function resolveRuntimeAssetsBaseUrl(input) {
188
188
  const protocol = normalizeHttpProtocol(input.protocol);
189
189
  const hostname = normalizeHostname(input.hostname);
190
+ const configuredBase = input.envValue?.trim();
191
+ if (configuredBase) {
192
+ return trimTrailingSlash(configuredBase);
193
+ }
190
194
  if (isLoopbackHostname(hostname)) {
191
195
  return "http://localhost:8082";
192
196
  }
@@ -33,6 +33,11 @@ const runtime_service_origins_1 = require("../src/runtime-service-origins");
33
33
  strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeApiBaseUrl)({ protocol: "https:", hostname: "blue.playdrop.ai" }), "https://api.blue.playdrop.ai");
34
34
  strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeRealtimeBaseUrl)({ protocol: "https:", hostname: "green.playdrop.ai" }), "wss://play.green.playdrop.ai/ws");
35
35
  strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeAssetsBaseUrl)({ protocol: "https:", hostname: "green.playdrop.ai" }), "https://assets.playdrop.ai");
36
+ strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeAssetsBaseUrl)({
37
+ protocol: "http:",
38
+ hostname: "0.0.0.0",
39
+ envValue: "https://assets.playdrop.ai/",
40
+ }), "https://assets.playdrop.ai");
36
41
  });
37
42
  (0, node_test_1.default)("runtime realtime resolver preserves explicit env endpoints on generic hosts", () => {
38
43
  strict_1.default.equal((0, runtime_service_origins_1.resolveRuntimeRealtimeBaseUrl)({