@superwall/cli 2.5.0 → 2.6.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.
Files changed (102) hide show
  1. package/README.md +7 -0
  2. package/dist/{apple-Dyr7OFBx.js → apple-Bmt_iywx.js} +14 -14
  3. package/dist/{approve-Czs1-JO9.js → approve-D2UgqaRx.js} +31 -27
  4. package/dist/{assets-BrB9jQPQ.js → assets-B_quADds.js} +3 -3
  5. package/dist/auth.d.ts +1 -1
  6. package/dist/auth.js +3 -3
  7. package/dist/{session-D3fgXQBt.js → base-ChTi42M0.js} +35 -35
  8. package/dist/{billing-D5qqIlVb.js → billing-ZIETn0j4.js} +3 -3
  9. package/dist/{bind-B3eEcRyp.js → bind-ClFjTt0U.js} +4 -4
  10. package/dist/{build-DD9pSwHX.js → build-BWjXurjs.js} +11 -9
  11. package/dist/{client-AI9H4GGB.js → client-CyrYJzBF.js} +3 -3
  12. package/dist/create-7HDW3DCl.js +20 -0
  13. package/dist/{create-B4m-IKlr.js → create-BCIgjRHn.js} +6 -6
  14. package/dist/{create-ChfgWpiM.js → create-C3uklw-U.js} +31 -31
  15. package/dist/design-lint-CiFc78aM.js +158 -0
  16. package/dist/{doctor-XtXW6tKE.js → doctor-D2Q1EZe8.js} +6 -6
  17. package/dist/{drivers-CMEL13gp.js → drivers-BQkO5tHs.js} +3 -3
  18. package/dist/entry.js +20 -20
  19. package/dist/{environment-BWT2S4qC.js → environment-BocmdvZ-.js} +3 -3
  20. package/dist/{existing-b0GxFcnc.js → existing-Cl5x6_5u.js} +2 -2
  21. package/dist/{selection-BltBpyp5.js → framework-CLmf4swr.js} +50 -50
  22. package/dist/{held-D3PUNky2.js → held-Bykbwy-m.js} +6 -6
  23. package/dist/held-Chw3BtBV.js +17 -0
  24. package/dist/install-dXZZ79Oe.js +109 -0
  25. package/dist/{integrate-qvKd9pVW.js → integrate-DiSjlOjC.js} +23 -23
  26. package/dist/{types-JdxmnCko.js → lock-DgSx-p8Y.js} +79 -79
  27. package/dist/{login-PMoXUGqq.js → login-5sWIKDI2.js} +6 -6
  28. package/dist/login-DZ8Pipf6.js +17 -0
  29. package/dist/{login-COmGHrU5.js → login-Jp6E6d2e.js} +1 -1
  30. package/dist/{lookup-gjcKIZvh.js → lookup-CWzVfPpq.js} +3 -3
  31. package/dist/{migrate-SkkLLdmr.js → migrate-BKiOUsMY.js} +29 -29
  32. package/dist/{migration-DS44-3Zr.js → migration-Z69tLeHC.js} +29 -11
  33. package/dist/{notification-url-BjQPLf4-.js → notification-url-BDBxbwZq.js} +2 -2
  34. package/dist/{open-DQpm2yVs.js → open-DNd49kT-.js} +2 -2
  35. package/dist/{org-C04eAO-j.js → org-Dud1rF9f.js} +3 -3
  36. package/dist/{organization-BOECL3vZ.js → organization-7vJA3uy1.js} +8 -8
  37. package/dist/{orgs-D6Kk96mG.js → orgs-Z0H9WOs1.js} +1 -1
  38. package/dist/{paths-REb-GrbX.js → paths-CzTJVpfi.js} +1 -1
  39. package/dist/{playbook-Du4Oydbf.js → playbook-DJ__edOW.js} +10 -10
  40. package/dist/{project-CP6hiHra.js → project-NoMtbMyl.js} +9 -9
  41. package/dist/{promote-Dm2_b1WK.js → promote-DLtPSvmL.js} +23 -22
  42. package/dist/{pull-F6pvO4To.js → pull-AoUmaiMK.js} +8 -8
  43. package/dist/pull-C1xm2zqG.js +36 -0
  44. package/dist/pull-D-YuT3e0.js +106 -0
  45. package/dist/push-B42D8fKf.js +22 -0
  46. package/dist/{push-BIFLhAiO.js → push-BMblzg_6.js} +122 -22
  47. package/dist/{push-D_l9KJZN.js → push-BrzMFd4Z.js} +47 -47
  48. package/dist/push-Co5jk6Kr.js +30 -0
  49. package/dist/{registry-DIJB0mJa.js → registry-DDU10_Ix.js} +176 -155
  50. package/dist/resolve-DpOSDDdr.js +196 -0
  51. package/dist/{resources-BaP3p_LY.js → resources-CptT7HD6.js} +2 -2
  52. package/dist/{run-C5OPwhvS.js → run-c1O2_8pp.js} +2 -2
  53. package/dist/{run-CgLmD2vR.js → run-r3foWfhV.js} +93 -70
  54. package/dist/scan-D86kLtM7.js +4 -0
  55. package/dist/{scan-Bj5y0zTZ.js → scan-nVQO7JLx.js} +1 -1
  56. package/dist/{scope-CCb_7UvN.js → scope-ehZ7L1nj.js} +25 -11
  57. package/dist/{scope-Bp_zwJOo.js → scope-l1qGLsgz.js} +5 -5
  58. package/dist/{sdk-TvT0p_nO.js → sdk-DEfQttek.js} +7 -7
  59. package/dist/{series-TAixFBWW.js → series-D2ZpZ8cx.js} +96 -63
  60. package/dist/server-BEcsQaPu.js +29 -0
  61. package/dist/{server-CdVIboQn.js → server-DLARhh1k.js} +9 -9
  62. package/dist/session-Csuaw6RU.js +6 -0
  63. package/dist/{session-Ywim-P8M.js → session-Z0BeaJPf.js} +1 -1
  64. package/dist/{setup-zzjtTy8k.js → setup-C6NFy14d.js} +9 -9
  65. package/dist/skills/index.json +2 -2
  66. package/dist/skills/{superwall-workspaces → superwall-artifacts}/SKILL.md +41 -31
  67. package/dist/skills/{superwall-workspaces → superwall-artifacts}/references/cli.md +31 -28
  68. package/dist/skills/{superwall-workspaces → superwall-artifacts}/references/slots.md +9 -9
  69. package/dist/{skills-2qYaUXGE.js → skills-421SFEyF.js} +4 -4
  70. package/dist/{skills-8um2fBPS.js → skills-CdKwaTRS.js} +8 -8
  71. package/dist/{git-D7AVdugb.js → source-BccdO4aL.js} +111 -102
  72. package/dist/{source-push-kAep4gPe.js → source-push-B4s6r9bB.js} +43 -26
  73. package/dist/{spinner-BANVLncC.js → spinner-DPdBlZe2.js} +3 -3
  74. package/dist/{starter-CiLrp1cN.js → starter-0OdVPH4l.js} +27 -27
  75. package/dist/{status-CoYMK7QL.js → status-Dsc7d3z2.js} +42 -39
  76. package/dist/{storage-DzP22xKn.js → storage-DT_wxwJ8.js} +1 -1
  77. package/dist/{storekit-n1x0bWkQ.js → storekit-B9M2raxe.js} +3 -3
  78. package/dist/storekit-BWZf-fNE.js +17 -0
  79. package/dist/{telemetry-CXN6f-ZX.js → telemetry-ovPiseFm.js} +1 -1
  80. package/dist/{token-FmeHywYt.js → token-Bu3FaRkv.js} +1 -1
  81. package/dist/tools.d.ts +1 -1
  82. package/dist/tools.js +148 -128
  83. package/dist/{try-BWbzgelb.js → try-B8FYkTvQ.js} +29 -29
  84. package/dist/{upgrade-Bk5boOgW.js → upgrade-B7TmvEPP.js} +2 -2
  85. package/dist/{upgrade-CoWCEnoi.js → upgrade-CAHyrWUL.js} +2 -2
  86. package/package.json +2 -2
  87. package/dist/create-CJljlkJK.js +0 -20
  88. package/dist/held-CX7Zf8u-.js +0 -17
  89. package/dist/install-CVUXsx8c.js +0 -103
  90. package/dist/login-ClnJi1Ea.js +0 -17
  91. package/dist/pull-DsdOoG-D.js +0 -36
  92. package/dist/pull-zYAbqo9n.js +0 -106
  93. package/dist/push-CJVfvFZq.js +0 -29
  94. package/dist/push-SVzv7fzE.js +0 -22
  95. package/dist/resolve--GsHj0Q1.js +0 -171
  96. package/dist/scan-v_WTE722.js +0 -4
  97. package/dist/server-CvJVusw3.js +0 -29
  98. package/dist/session-B8JNXkwN.js +0 -6
  99. package/dist/storekit-D5eopLM0.js +0 -17
  100. /package/dist/{download-2Zu2I_Og.js → download-DhGd4hOB.js} +0 -0
  101. /package/dist/{reports-CuhB1_ub.js → reports-HYVp169R.js} +0 -0
  102. /package/dist/{storage-BjQCiTuz.d.ts → storage-Bdz5AmqS.d.ts} +0 -0
@@ -1,21 +1,21 @@
1
- import "./token-FmeHywYt.js";
1
+ import "./token-Bu3FaRkv.js";
2
2
  import "./output-Ggzq5_-t.js";
3
- import "./environment-BWT2S4qC.js";
4
- import "./storage-DzP22xKn.js";
5
- import { t as ApiError } from "./client-AI9H4GGB.js";
3
+ import "./environment-BocmdvZ-.js";
4
+ import "./storage-DT_wxwJ8.js";
5
+ import { t as ApiError } from "./client-CyrYJzBF.js";
6
6
  import "./config-CGcG7GOt.js";
7
- import "./spinner-BANVLncC.js";
7
+ import "./spinner-DPdBlZe2.js";
8
8
  import "./ui-D_qf3Gvw.js";
9
- import "./orgs-D6Kk96mG.js";
10
- import "./resources-BaP3p_LY.js";
11
- import "./lookup-gjcKIZvh.js";
12
- import "./types-JdxmnCko.js";
13
- import { i as WORKSPACE_FILE } from "./scope-CCb_7UvN.js";
14
- import "./download-2Zu2I_Og.js";
15
- import { a as findEntrypoint, o as readManifest, r as WorkspaceError, s as readProject } from "./project-CP6hiHra.js";
16
- import { C as WORKSPACE_HEADER_PREFIX, S as WORKSPACE_COMPATIBILITY_DATE, _ as METRIC_LIMITS, b as READOUT_LIMITS, c as defaultRange, d as resolveWranglerPackage, f as API_HOST, g as ENTRYPOINT_HEADER, i as seriesProblem, l as parseContextJson, m as CONTEXT_HEADER, o as SLOTS, p as BRIDGE_PROTOCOL, r as readoutProblem, s as buildContext, t as checkMetricQuery, u as bundleWorkspace, v as MOUNT_LOAD_TIMEOUT_MS, w as isInternalPath, x as TRIGGER_HEADER, y as PLATFORM_HOST } from "./series-TAixFBWW.js";
17
- import { n as resolveOrganization, t as resolveAppScope } from "./organization-BOECL3vZ.js";
18
- import { i as warnIfSdkBehind } from "./sdk-TvT0p_nO.js";
9
+ import "./orgs-Z0H9WOs1.js";
10
+ import "./resources-CptT7HD6.js";
11
+ import "./lookup-CWzVfPpq.js";
12
+ import { a as findEntrypoint, o as readManifest, s as readProject, t as ArtifactError } from "./project-NoMtbMyl.js";
13
+ import "./lock-DgSx-p8Y.js";
14
+ import { n as ARTIFACT_FILE } from "./scope-ehZ7L1nj.js";
15
+ import { C as TRIGGER_HEADER, S as READOUT_LIMITS, b as MOUNT_LOAD_TIMEOUT_MS, c as defaultRange, d as resolveWranglerPackage, f as API_HOST, g as CONTEXT_HEADER, h as BRIDGE_PROTOCOL, i as seriesProblem, l as parseContextJson, m as ARTIFACT_HEADER_PREFIX, o as SLOTS, p as ARTIFACT_COMPATIBILITY_DATE, r as readoutProblem, s as buildContext, t as checkMetricQuery, u as bundleArtifact, v as ENTRYPOINT_HEADER, w as isInternalPath, x as PLATFORM_HOST, y as METRIC_LIMITS } from "./series-D2ZpZ8cx.js";
16
+ import { n as resolveOrganization, t as resolveAppScope } from "./organization-7vJA3uy1.js";
17
+ import "./download-DhGd4hOB.js";
18
+ import { i as warnIfSdkBehind } from "./sdk-DEfQttek.js";
19
19
  import { createRequire } from "node:module";
20
20
  import * as fs from "node:fs";
21
21
  import * as path from "node:path";
@@ -23,7 +23,7 @@ import { pathToFileURL } from "node:url";
23
23
  import { randomBytes } from "node:crypto";
24
24
  import * as http from "node:http";
25
25
 
26
- //#region src/core/workspaces/dev/credential.ts
26
+ //#region src/core/artifacts/dev/credential.ts
27
27
  const MAX_TOKEN_RENEWALS = 3;
28
28
  function createAgentCredential(mint) {
29
29
  let latest;
@@ -45,7 +45,7 @@ function createAgentCredential(mint) {
45
45
  renew(rejected, { expired = false } = {}) {
46
46
  if (renewing) return renewing;
47
47
  if (latest !== void 0 && latest !== rejected) return Promise.resolve(latest);
48
- if (!expired && renewals >= MAX_TOKEN_RENEWALS) return Promise.reject(new WorkspaceError(`The API kept refusing dev's token after ${MAX_TOKEN_RENEWALS} new ones, so it stopped making more. Check \`superwall whoami\`, then restart dev.`));
48
+ if (!expired && renewals >= MAX_TOKEN_RENEWALS) return Promise.reject(new ArtifactError(`The API kept refusing dev's token after ${MAX_TOKEN_RENEWALS} new ones, so it stopped making more. Check \`superwall whoami\`, then restart dev.`));
49
49
  if (!expired) renewals += 1;
50
50
  renewing = start().finally(() => {
51
51
  renewing = void 0;
@@ -56,8 +56,8 @@ function createAgentCredential(mint) {
56
56
  }
57
57
 
58
58
  //#endregion
59
- //#region src/core/workspaces/routes.ts
60
- const WORKSPACE_ROUTE_REFUSAL = "Workspaces may not call this endpoint.";
59
+ //#region src/core/artifacts/routes.ts
60
+ const ARTIFACT_ROUTE_REFUSAL = "Artifacts may not call this endpoint.";
61
61
  const READ = new Set(["GET", "HEAD"]);
62
62
  const WRITE = new Set([
63
63
  "POST",
@@ -244,13 +244,13 @@ const pathSpellings = (target) => {
244
244
  }
245
245
  };
246
246
  const isAllowedPath = (method, path$1, narrowed) => !DENIED.some((pattern) => pattern.test(path$1)) && ALLOWED.some((rule) => rule.methods.has(method) && rule.path.test(path$1)) && (!narrowed || NARROWED.some((rule) => rule.methods.has(method) && rule.path.test(path$1)));
247
- const isWorkspaceRequestAllowed = (method, target, narrowed) => {
247
+ const isArtifactRequestAllowed = (method, target, narrowed) => {
248
248
  const normalized = method.toUpperCase();
249
249
  return pathSpellings(target).every((path$1) => isAllowedPath(normalized, path$1, narrowed));
250
250
  };
251
251
 
252
252
  //#endregion
253
- //#region src/core/workspaces/scopes.ts
253
+ //#region src/core/artifacts/scopes.ts
254
254
  const READ_FAMILIES = [
255
255
  [/^\/v2\/organizations\/[^/]+\/query$/, "data:read"],
256
256
  [/^\/v2\/projects\/[^/]+\/custom-stores(\/|$)/, "custom_stores:read"],
@@ -274,7 +274,7 @@ function scopeForRoute(method, pathname) {
274
274
  }
275
275
 
276
276
  //#endregion
277
- //#region src/core/workspaces/dev/outbound.ts
277
+ //#region src/core/artifacts/dev/outbound.ts
278
278
  const FORWARDED_HEADERS = [
279
279
  "accept",
280
280
  "accept-encoding",
@@ -302,7 +302,7 @@ const refuse = (status, message) => new Response(JSON.stringify({ message }), {
302
302
  const refuseRoute = () => new Response(JSON.stringify({
303
303
  type: "permission_error",
304
304
  code: "insufficient_permissions",
305
- message: WORKSPACE_ROUTE_REFUSAL
305
+ message: ARTIFACT_ROUTE_REFUSAL
306
306
  }), {
307
307
  status: 403,
308
308
  headers: { "content-type": "application/json" }
@@ -349,16 +349,16 @@ function createOutbound({ apiOrigin, credential, log, declaredScopes, limitedTo,
349
349
  return async (request, caller) => {
350
350
  const url = new URL(request.url);
351
351
  if (url.hostname === PLATFORM_HOST) {
352
- log.warn("Workspace storage, jobs and logs aren't available in dev.");
353
- return refuse(501, "Workspace storage, jobs and logs aren't available in dev.");
352
+ log.warn("Artifact storage, jobs and logs aren't available in dev.");
353
+ return refuse(501, "Artifact storage, jobs and logs aren't available in dev.");
354
354
  }
355
355
  if (url.hostname !== API_HOST) {
356
356
  log.warn(`Refused ${request.method} ${url.origin}: dev runs like a draft, with no outside hosts.`);
357
357
  return refuse(403, `Dev runs like a draft, with no outside hosts: ${url.hostname} isn't reachable.`);
358
358
  }
359
359
  const label = `${request.method} ${url.pathname}`;
360
- if (!isWorkspaceRequestAllowed(request.method, `${url.pathname}${url.search}`, caller.narrowed)) {
361
- log.warn(`${label} 403. ${WORKSPACE_ROUTE_REFUSAL} ${routeHint(url.pathname, caller.narrowed)}`);
360
+ if (!isArtifactRequestAllowed(request.method, `${url.pathname}${url.search}`, caller.narrowed)) {
361
+ log.warn(`${label} 403. ${ARTIFACT_ROUTE_REFUSAL} ${routeHint(url.pathname, caller.narrowed)}`);
362
362
  return refuseRoute();
363
363
  }
364
364
  const scope = scopeForRoute(request.method, url.pathname);
@@ -382,7 +382,7 @@ function createOutbound({ apiOrigin, credential, log, declaredScopes, limitedTo,
382
382
  if (answer.status === 403) {
383
383
  const { message } = await refusalOf(answer);
384
384
  const organization = limitedTo?.();
385
- const reach = organization === void 0 ? "Dev is read-only." : `Dev's token is read-only, limited to organization ${organization} and the routes a workspace can read.`;
385
+ const reach = organization === void 0 ? "Dev is read-only." : `Dev's token is read-only, limited to organization ${organization} and the routes an artifact can read.`;
386
386
  log.warn(`${label} ${answer.status} ${took}ms. ${reach} ${String(message ?? "").slice(0, 200)}`.trimEnd());
387
387
  } else log.info(`${label} ${answer.status} ${took}ms`);
388
388
  const headers = new Headers(answer.headers);
@@ -392,28 +392,28 @@ function createOutbound({ apiOrigin, credential, log, declaredScopes, limitedTo,
392
392
  }
393
393
 
394
394
  //#endregion
395
- //#region src/core/workspaces/dev/runtime.ts
395
+ //#region src/core/artifacts/dev/runtime.ts
396
396
  const INVOKE_PATH = "/__sw/invoke/";
397
- const NARROWED_HEADER = "x-superwall-workspace-dev-narrowed";
397
+ const NARROWED_HEADER = "x-superwall-artifact-dev-narrowed";
398
398
  const INVOCABLE = ["metric", "readout"];
399
399
  const SANDBOX_MODULE = "delete globalThis.caches\n";
400
400
  const MAIN_MODULE = `import "./sandbox.mjs"
401
401
  import { WorkerEntrypoint } from "cloudflare:workers"
402
402
  import handlers from "./worker.mjs"
403
403
  export * from "./worker.mjs"
404
- export default class Workspace extends WorkerEntrypoint {
404
+ export default class Artifact extends WorkerEntrypoint {
405
405
  fetch(request) {
406
406
  return handlers.fetch(request)
407
407
  }
408
408
  metric(request) {
409
409
  if (typeof handlers.metric !== "function") {
410
- throw new Error("This workspace has no metric handler")
410
+ throw new Error("This artifact has no metric handler")
411
411
  }
412
412
  return handlers.metric(request)
413
413
  }
414
414
  readout(request) {
415
415
  if (typeof handlers.readout !== "function") {
416
- throw new Error("This workspace has no readout handler")
416
+ throw new Error("This artifact has no readout handler")
417
417
  }
418
418
  return handlers.readout(request)
419
419
  }
@@ -444,12 +444,12 @@ export default {
444
444
  async fetch(request, env, ctx) {
445
445
  const narrowed = request.headers.get(${JSON.stringify(NARROWED_HEADER)}) === "1"
446
446
  const { pathname } = new URL(request.url)
447
- const workspace = load(env, ctx.exports, narrowed).getEntrypoint()
447
+ const artifact = load(env, ctx.exports, narrowed).getEntrypoint()
448
448
  if (pathname.startsWith(${JSON.stringify(INVOKE_PATH)})) {
449
449
  const kind = pathname.slice(13)
450
450
  if (!${JSON.stringify(INVOCABLE)}.includes(kind)) return json({ error: "Not found." }, 404)
451
451
  try {
452
- return json({ result: await workspace[kind](await request.json()) }, 200)
452
+ return json({ result: await artifact[kind](await request.json()) }, 200)
453
453
  } catch (error) {
454
454
  return json({ error: String(error?.message ?? error) }, 500)
455
455
  }
@@ -457,7 +457,7 @@ export default {
457
457
  const headers = new Headers(request.headers)
458
458
  headers.delete(${JSON.stringify(NARROWED_HEADER)})
459
459
  try {
460
- return await workspace.fetch(new Request(request, { headers }))
460
+ return await artifact.fetch(new Request(request, { headers }))
461
461
  } catch (error) {
462
462
  return new Response(String(error?.message ?? error), { status: 502 })
463
463
  }
@@ -465,12 +465,12 @@ export default {
465
465
  }
466
466
  `;
467
467
  const DEFAULT_COMPATIBILITY = {
468
- date: WORKSPACE_COMPATIBILITY_DATE,
468
+ date: ARTIFACT_COMPATIBILITY_DATE,
469
469
  flags: []
470
470
  };
471
471
  const workerOptions = (module, compatibility = DEFAULT_COMPATIBILITY) => ({
472
- name: "workspace-host",
473
- compatibilityDate: WORKSPACE_COMPATIBILITY_DATE,
472
+ name: "artifact-host",
473
+ compatibilityDate: ARTIFACT_COMPATIBILITY_DATE,
474
474
  modules: [{
475
475
  type: "ESModule",
476
476
  path: "host.mjs",
@@ -498,7 +498,7 @@ const startMiniflare = async ({ root, module, compatibility, outbound }) => {
498
498
  await miniflare.ready;
499
499
  } catch (error) {
500
500
  await miniflare.dispose().catch(() => {});
501
- throw new WorkspaceError(`The workspace didn't start: ${error.message}\nIf the runtime says the compatibility date is too new, update wrangler with \`npm install -D wrangler@latest\`.`);
501
+ throw new ArtifactError(`The artifact didn't start: ${error.message}\nIf the runtime says the compatibility date is too new, update wrangler with \`npm install -D wrangler@latest\`.`);
502
502
  }
503
503
  return {
504
504
  fetch: (url, init, caller) => {
@@ -516,7 +516,7 @@ const startMiniflare = async ({ root, module, compatibility, outbound }) => {
516
516
  };
517
517
 
518
518
  //#endregion
519
- //#region src/core/workspaces/dev/host-page.ts
519
+ //#region src/core/artifacts/dev/host-page.ts
520
520
  const LIGHT_TOKENS = {
521
521
  background: "#ffffff",
522
522
  foreground: "#14151a",
@@ -587,7 +587,28 @@ svg { display: block; width: 100%; height: 160px; margin-bottom: 12px; }
587
587
  .row label { margin-bottom: 0; }
588
588
  .row h1 { flex: 1; }
589
589
  `;
590
+ const WATCH_LOAD = `
591
+ const watchLoad = (doc, ms, isReady, onLate) => {
592
+ let timer = 0;
593
+ const stop = () => {
594
+ clearTimeout(timer);
595
+ doc.removeEventListener("visibilitychange", restart);
596
+ };
597
+ const restart = () => {
598
+ clearTimeout(timer);
599
+ if (doc.visibilityState !== "visible") return;
600
+ timer = setTimeout(() => {
601
+ stop();
602
+ if (!isReady()) onLate();
603
+ }, ms);
604
+ };
605
+ doc.addEventListener("visibilitychange", restart);
606
+ restart();
607
+ return stop;
608
+ };
609
+ `;
590
610
  const SCRIPT = `
611
+ ${WATCH_LOAD}
591
612
  const PROTOCOL = ${JSON.stringify(BRIDGE_PROTOCOL)};
592
613
  const LOAD_TIMEOUT_MS = ${MOUNT_LOAD_TIMEOUT_MS};
593
614
  const TOKENS = { light: ${JSON.stringify(LIGHT_TOKENS)}, dark: ${JSON.stringify(DARK_TOKENS)} };
@@ -669,7 +690,8 @@ const showFrame = async (entrypoint, generation) => {
669
690
  const slot = state.slots[session.slot];
670
691
  const fills = slot.shape === "page" || session.slot === "app.dashboard.widget@1";
671
692
  const nonce = crypto.randomUUID().replaceAll("-", "");
672
- mount = { nonce, origin: session.origin, connected: false, slot, ready: false, timer: 0 };
693
+ mount?.stopWatching?.();
694
+ mount = { nonce, origin: session.origin, connected: false, slot, ready: false, stopWatching: null };
673
695
  frame = el("iframe", {
674
696
  class: fills ? "fills" : undefined,
675
697
  title: entrypoint.title,
@@ -678,10 +700,11 @@ const showFrame = async (entrypoint, generation) => {
678
700
  onload: () => {
679
701
  mount.connected = true;
680
702
  frame.contentWindow.postMessage(hostMessage({ _tag: "connect", theme: theme(), context: session.context }), mount.origin);
681
- clearTimeout(mount.timer);
682
- mount.timer = setTimeout(() => {
683
- if (!mount.ready) log("It didn't send ready within " + LOAD_TIMEOUT_MS / 1000 + " seconds. In the dashboard this shows as: This app couldn't load. Try again.");
684
- }, LOAD_TIMEOUT_MS);
703
+ mount.stopWatching?.();
704
+ const watched = mount;
705
+ mount.stopWatching = watchLoad(document, LOAD_TIMEOUT_MS, () => watched.ready || mount !== watched, () => {
706
+ log("It didn't send ready within " + LOAD_TIMEOUT_MS / 1000 + " seconds. In the dashboard this shows as: This app couldn't load. Try again.");
707
+ });
685
708
  },
686
709
  });
687
710
  if (!fills && slot.minHeight) frame.style.height = slot.minHeight + "px";
@@ -863,12 +886,12 @@ function renderHostPage() {
863
886
  <html lang="en">
864
887
  <head>
865
888
  <meta charset="utf-8" />
866
- <title>Workspace dev</title>
889
+ <title>Artifact dev</title>
867
890
  <style>${STYLES}</style>
868
891
  </head>
869
892
  <body>
870
893
  <aside>
871
- <div class="row"><h1 id="title">Workspace</h1><button id="theme">Theme</button></div>
894
+ <div class="row"><h1 id="title">Artifact</h1><button id="theme">Theme</button></div>
872
895
  <div id="entrypoints"></div>
873
896
  <div id="context"></div>
874
897
  </aside>
@@ -882,7 +905,7 @@ function renderHostPage() {
882
905
  }
883
906
 
884
907
  //#endregion
885
- //#region src/core/workspaces/dev/server.ts
908
+ //#region src/core/artifacts/dev/server.ts
886
909
  const readBody = (request) => new Promise((resolve$1, reject) => {
887
910
  const chunks = [];
888
911
  request.on("data", (chunk) => chunks.push(chunk));
@@ -898,7 +921,7 @@ const sendJson = (response, status, body) => {
898
921
  };
899
922
  const listen = (server, port) => new Promise((resolve$1, reject) => {
900
923
  server.once("error", (error) => {
901
- reject(error.code === "EADDRINUSE" ? new WorkspaceError(`Port ${port} is already in use. Pick another with --port; dev also takes the one after it.`) : error);
924
+ reject(error.code === "EADDRINUSE" ? new ArtifactError(`Port ${port} is already in use. Pick another with --port; dev also takes the one after it.`) : error);
902
925
  });
903
926
  server.listen(port, "127.0.0.1", () => {
904
927
  const address = server.address();
@@ -928,7 +951,7 @@ const headerJson = (value) => JSON.stringify(value).replace(/[\u007f-
928
951
  const withTimeout = async (work, ms, message) => {
929
952
  let timer;
930
953
  const timeout = new Promise((_, reject) => {
931
- timer = setTimeout(() => reject(new WorkspaceError(message)), ms);
954
+ timer = setTimeout(() => reject(new ArtifactError(message)), ms);
932
955
  });
933
956
  try {
934
957
  return await Promise.race([work, timeout]);
@@ -970,7 +993,7 @@ async function startDevServer(options) {
970
993
  headers: { "content-type": "application/json" },
971
994
  body: JSON.stringify(payload)
972
995
  }), timeoutMs, `The ${kind} handler didn't answer within ${timeoutMs / 1e3} seconds.`)).json();
973
- if (body.error !== void 0) throw new WorkspaceError(body.error);
996
+ if (body.error !== void 0) throw new ArtifactError(body.error);
974
997
  return body.result;
975
998
  };
976
999
  const contextFor = (slot, input) => {
@@ -979,12 +1002,12 @@ async function startDevServer(options) {
979
1002
  ...input
980
1003
  });
981
1004
  const { organizationId } = context;
982
- if (defaults.organizationId !== void 0 && organizationId !== void 0 && String(organizationId) !== defaults.organizationId) throw new WorkspaceError(`This dev is running against organization ${defaults.organizationId}, and its token reaches only that one. Restart dev with --org ${String(organizationId)} to use ${String(organizationId)}.`);
1005
+ if (defaults.organizationId !== void 0 && organizationId !== void 0 && String(organizationId) !== defaults.organizationId) throw new ArtifactError(`This dev is running against organization ${defaults.organizationId}, and its token reaches only that one. Restart dev with --org ${String(organizationId)} to use ${String(organizationId)}.`);
983
1006
  return context;
984
1007
  };
985
1008
  const runMetric = async (call) => {
986
1009
  const entrypoint = findEntrypoint(getManifest(), call.entrypoint);
987
- if (entrypoint.slot !== "chart.source@1") throw new WorkspaceError(`\`${entrypoint.id}\` (${entrypoint.slot}) isn't a metric.`);
1010
+ if (entrypoint.slot !== "chart.source@1") throw new ArtifactError(`\`${entrypoint.id}\` (${entrypoint.slot}) isn't a metric.`);
988
1011
  const filters = Object.fromEntries(Object.entries(call.filters ?? {}).filter(([, values]) => values.length > 0));
989
1012
  checkMetricQuery(entrypoint.metric, {
990
1013
  breakdown: call.breakdown,
@@ -1003,7 +1026,7 @@ async function startDevServer(options) {
1003
1026
  filters
1004
1027
  }, METRIC_LIMITS.timeoutMs);
1005
1028
  const problem = seriesProblem(series);
1006
- if (problem) throw new WorkspaceError(problem);
1029
+ if (problem) throw new ArtifactError(problem);
1007
1030
  return {
1008
1031
  series,
1009
1032
  took_ms: Date.now() - started
@@ -1011,7 +1034,7 @@ async function startDevServer(options) {
1011
1034
  };
1012
1035
  const runReadout = async (call) => {
1013
1036
  const entrypoint = findEntrypoint(getManifest(), call.entrypoint);
1014
- if (entrypoint.slot !== "campaign.metric@1") throw new WorkspaceError(`\`${entrypoint.id}\` (${entrypoint.slot}) isn't a readout.`);
1037
+ if (entrypoint.slot !== "campaign.metric@1") throw new ArtifactError(`\`${entrypoint.id}\` (${entrypoint.slot}) isn't a readout.`);
1015
1038
  const context = contextFor(entrypoint.slot, call.input);
1016
1039
  const started = Date.now();
1017
1040
  const result = await invoke("readout", {
@@ -1019,7 +1042,7 @@ async function startDevServer(options) {
1019
1042
  context
1020
1043
  }, READOUT_LIMITS.timeoutMs);
1021
1044
  const problem = readoutProblem(result, context.variantIds ?? []);
1022
- if (problem) throw new WorkspaceError(problem);
1045
+ if (problem) throw new ArtifactError(problem);
1023
1046
  return {
1024
1047
  result,
1025
1048
  took_ms: Date.now() - started
@@ -1027,7 +1050,7 @@ async function startDevServer(options) {
1027
1050
  };
1028
1051
  const createSession = (call) => {
1029
1052
  const entrypoint = findEntrypoint(getManifest(), call.entrypoint);
1030
- if (entrypoint.path === void 0) throw new WorkspaceError(`\`${entrypoint.id}\` (${entrypoint.slot}) has no path to open.`);
1053
+ if (entrypoint.path === void 0) throw new ArtifactError(`\`${entrypoint.id}\` (${entrypoint.slot}) has no path to open.`);
1031
1054
  const context = contextFor(entrypoint.slot, call.input);
1032
1055
  const token = randomBytes(24).toString("hex");
1033
1056
  const code = randomBytes(24).toString("hex");
@@ -1109,7 +1132,7 @@ async function startDevServer(options) {
1109
1132
  if (session === void 0) return sendJson(response, 401, { error: `This frame has no session. Open it from ${hostOrigin}.` });
1110
1133
  const headers = new Headers();
1111
1134
  for (const [name, value] of Object.entries(request.headers)) {
1112
- if (name === "cookie" || name === "host" || name.startsWith("mf-") || name.startsWith(WORKSPACE_HEADER_PREFIX)) continue;
1135
+ if (name === "cookie" || name === "host" || name.startsWith("mf-") || name.startsWith(ARTIFACT_HEADER_PREFIX)) continue;
1113
1136
  if (typeof value === "string") headers.set(name, value);
1114
1137
  }
1115
1138
  headers.set(CONTEXT_HEADER, headerJson(session.context));
@@ -1167,9 +1190,9 @@ async function startDevServer(options) {
1167
1190
  }
1168
1191
 
1169
1192
  //#endregion
1170
- //#region src/core/workspaces/dev/run.ts
1193
+ //#region src/core/artifacts/dev/run.ts
1171
1194
  const UNWATCHED_DIRS = new Set(["node_modules", "dist"]);
1172
- const UNWATCHED_FILES = new Set([WORKSPACE_FILE]);
1195
+ const UNWATCHED_FILES = new Set([ARTIFACT_FILE]);
1173
1196
  const DEBOUNCE_MS = 150;
1174
1197
  const TOKEN_TTL_SECONDS = 3600;
1175
1198
  const SOURCE_FILE = /\.(?:tsx?|jsx?|mts|mjs|cts|cjs|css|jsonc?|toml|svg|png|jpe?g|gif|webp|avif|ico|woff2?|ttf|otf)$/;
@@ -1203,7 +1226,7 @@ function watchProject(root, onChange) {
1203
1226
  };
1204
1227
  }
1205
1228
  function mintRefusal(error) {
1206
- return /WorkOS access token/i.test(error.message) ? "`superwall workspaces dev` needs a browser login: it makes its read-only token from your session, and an API key can't. Run `superwall login`." : error.message;
1229
+ return /WorkOS access token/i.test(error.message) ? "`superwall artifacts dev` needs a browser login: it makes its read-only token from your session, and an API key can't. Run `superwall login`." : error.message;
1207
1230
  }
1208
1231
  function agentCredential(ctx, organizationId) {
1209
1232
  let limited = true;
@@ -1220,7 +1243,7 @@ function agentCredential(ctx, organizationId) {
1220
1243
  }
1221
1244
  return minted.token;
1222
1245
  } catch (error) {
1223
- if (error instanceof ApiError && error.status === 403) throw new WorkspaceError(mintRefusal(error));
1246
+ if (error instanceof ApiError && error.status === 403) throw new ArtifactError(mintRefusal(error));
1224
1247
  throw error;
1225
1248
  }
1226
1249
  }),
@@ -1251,22 +1274,22 @@ async function resolveDefaults(ctx, input) {
1251
1274
  const named = input.context === void 0 ? void 0 : parseContextJson(input.context).organizationId;
1252
1275
  const scope = input.app === void 0 ? { organizationId: input.org ?? (named === void 0 ? await resolveOrganization(ctx, void 0) : String(named)) } : await resolveAppScope(ctx.api, input.app, input.org);
1253
1276
  const { organizationId } = scope;
1254
- if (organizationId === void 0) throw new WorkspaceError(`Couldn't find the organization of app ${input.app}. Say which with --org <id>.`);
1255
- if (!/^[1-9]\d*$/.test(organizationId)) throw new WorkspaceError(`--org takes an organization's id, a number. Got ${organizationId}.`);
1277
+ if (organizationId === void 0) throw new ArtifactError(`Couldn't find the organization of app ${input.app}. Say which with --org <id>.`);
1278
+ if (!/^[1-9]\d*$/.test(organizationId)) throw new ArtifactError(`--org takes an organization's id, a number. Got ${organizationId}.`);
1256
1279
  return {
1257
1280
  ...context,
1258
1281
  ...scope,
1259
1282
  organizationId
1260
1283
  };
1261
1284
  }
1262
- async function runWorkspaceDev(ctx, input, seams = {}) {
1285
+ async function runArtifactDev(ctx, input, seams = {}) {
1263
1286
  const { root } = readProject(input.dir);
1264
- ctx.ui.intro("Workspace dev");
1287
+ ctx.ui.intro("Artifact dev");
1265
1288
  warnIfSdkBehind(ctx.ui, root);
1266
1289
  const defaults = await resolveDefaults(ctx, input);
1267
1290
  const { credential, limitedTo } = agentCredential(ctx, defaults.organizationId);
1268
1291
  await credential.current();
1269
- const first = await bundleWorkspace(root, seams.wrangler);
1292
+ const first = await bundleArtifact(root, seams.wrangler);
1270
1293
  const log = {
1271
1294
  info: (text) => ctx.ui.step(text),
1272
1295
  warn: (text) => ctx.ui.warn(text)
@@ -1311,7 +1334,7 @@ async function runWorkspaceDev(ctx, input, seams = {}) {
1311
1334
  rebuilding = rebuilding.then(async () => {
1312
1335
  try {
1313
1336
  const nextManifest = readManifest(root);
1314
- const next = await bundleWorkspace(root, seams.wrangler);
1337
+ const next = await bundleArtifact(root, seams.wrangler);
1315
1338
  await runtime.update(next.module, next.compatibility);
1316
1339
  manifest = nextManifest;
1317
1340
  ctx.ui.step(`Rebuilt, ${next.bytes} bytes`);
@@ -1342,4 +1365,4 @@ async function runWorkspaceDev(ctx, input, seams = {}) {
1342
1365
  }
1343
1366
 
1344
1367
  //#endregion
1345
- export { runWorkspaceDev, watchProject };
1368
+ export { runArtifactDev, watchProject };
@@ -0,0 +1,4 @@
1
+ import "./environment-BocmdvZ-.js";
2
+ import { t as scanProject } from "./scan-nVQO7JLx.js";
3
+
4
+ export { scanProject };
@@ -1,4 +1,4 @@
1
- import { h as Integration } from "./environment-BWT2S4qC.js";
1
+ import { h as Integration } from "./environment-BocmdvZ-.js";
2
2
  import { existsSync, readFileSync } from "node:fs";
3
3
  import { basename, dirname, join, relative, sep } from "node:path";
4
4
  import fg from "fast-glob";
@@ -1,11 +1,11 @@
1
- import { i as NewerLockError, l as originKey, o as formatLock, t as TYPES_FILE, u as parseLock } from "./types-JdxmnCko.js";
1
+ import { o as originKey, r as formatLock, s as parseLock, t as NewerLockError, v as TYPES_FILE } from "./lock-DgSx-p8Y.js";
2
2
 
3
3
  //#region src/core/paywalls/source/scope.ts
4
4
  const LOCK_FILE = "superwall.lock";
5
- const WORKSPACE_FILE = "superwall.workspace.json";
5
+ const ARTIFACT_FILE = "superwall.artifact.json";
6
6
  const DERIVED_FILES = new Set([LOCK_FILE, TYPES_FILE]);
7
- const WORKSPACE_DERIVED_FILES = new Set([WORKSPACE_FILE]);
8
- const derivedFilesOf = (scope) => scope.kind === "workspace" ? WORKSPACE_DERIVED_FILES : DERIVED_FILES;
7
+ const ARTIFACT_DERIVED_FILES = new Set([ARTIFACT_FILE]);
8
+ const derivedFilesOf = (scope) => scope.kind === "artifact" ? ARTIFACT_DERIVED_FILES : DERIVED_FILES;
9
9
  const SURFACE_DIRS = {
10
10
  paywalls: "paywall",
11
11
  funnels: "funnel"
@@ -21,16 +21,18 @@ function surfaceOf(relative) {
21
21
  }
22
22
  function classifyPath(relative, scope) {
23
23
  if (derivedFilesOf(scope).has(relative)) return "derived";
24
- if (scope.kind === "workspace") return "own";
24
+ if (scope.kind === "artifact") return "own";
25
25
  const surface = surfaceOf(relative);
26
26
  if (!surface) return "shared";
27
+ if (scope.kind === "project") return "other";
27
28
  return surface.kind === scope.kind && surface.id === scope.id ? "own" : "other";
28
29
  }
29
- const isSurfaceRoot = (top, scope) => scope?.kind !== "workspace" && SURFACE_DIRS[top] !== void 0;
30
+ const isSurfaceRoot = (top, scope) => scope?.kind !== "artifact" && SURFACE_DIRS[top] !== void 0;
30
31
  const isOtherSurfaceDir = (top, child, scope) => {
31
- if (scope.kind === "workspace") return false;
32
+ if (scope.kind === "artifact") return false;
32
33
  const kind = SURFACE_DIRS[top];
33
- return kind !== void 0 && !(kind === scope.kind && child === scope.id);
34
+ if (kind === void 0) return false;
35
+ return scope.kind === "project" || !(kind === scope.kind && child === scope.id);
34
36
  };
35
37
  var SourceLockUnreadableError = class extends Error {
36
38
  constructor(reason) {
@@ -48,11 +50,11 @@ const readable = (text) => {
48
50
  function mergeLockText(theirs, mine, scope, options = {}) {
49
51
  const own = readable(mine);
50
52
  if (!("lock" in own)) return mine;
51
- if (theirs === void 0) return formatLock(withoutSources(own.lock));
53
+ if (theirs === void 0) return formatLock(scoped(own.lock, scope));
52
54
  const read = readable(theirs);
53
55
  if (!("lock" in read)) {
54
56
  if (!options.replaceUnreadable) throw new SourceLockUnreadableError(read.reason);
55
- return formatLock(withoutSources(own.lock));
57
+ return formatLock(scoped(own.lock, scope));
56
58
  }
57
59
  return mergeLocks(read.lock, own.lock, scope);
58
60
  }
@@ -69,6 +71,10 @@ function mergeLocks(other, own, scope) {
69
71
  paywalls: { ...other.paywalls },
70
72
  funnels: { ...other.funnels }
71
73
  };
74
+ if (scope.kind === "project") {
75
+ if (other.origins) merged.origins = other.origins;
76
+ return formatLock(merged);
77
+ }
72
78
  const target = section(merged);
73
79
  const theirEntry = section(other)[scope.id] ?? {};
74
80
  const mineEntry = section(own)[scope.id] ?? {};
@@ -84,6 +90,14 @@ function mergeLocks(other, own, scope) {
84
90
  return formatLock(merged);
85
91
  }
86
92
  const withoutSources = ({ sources: _,...lock }) => lock;
93
+ const scoped = (lock, scope) => {
94
+ const { origins: _,...rest } = withoutSources(lock);
95
+ return scope.kind === "project" ? {
96
+ ...rest,
97
+ paywalls: {},
98
+ funnels: {}
99
+ } : withoutSources(lock);
100
+ };
87
101
 
88
102
  //#endregion
89
- export { classifyPath as a, isSurfaceRoot as c, WORKSPACE_FILE as i, mergeLockText as l, LOCK_FILE as n, derivedFilesOf as o, WORKSPACE_DERIVED_FILES as r, isOtherSurfaceDir as s, DERIVED_FILES as t };
103
+ export { classifyPath as a, isSurfaceRoot as c, LOCK_FILE as i, mergeLockText as l, ARTIFACT_FILE as n, derivedFilesOf as o, DERIVED_FILES as r, isOtherSurfaceDir as s, ARTIFACT_DERIVED_FILES as t };
@@ -1,9 +1,9 @@
1
1
  import { f as writeDefaultApp, r as readDefaultApp } from "./config-CGcG7GOt.js";
2
- import { t as apiCall, u as currentHost } from "./spinner-BANVLncC.js";
3
- import { i as orgIdOf, o as organizationOf, t as listOrgGroups } from "./orgs-D6Kk96mG.js";
4
- import { l as findPaywall, m as listProjects, y as platformLabel } from "./resources-BaP3p_LY.js";
5
- import { t as chooseOrgOfApps } from "./org-C04eAO-j.js";
6
- import { n as findApplication, r as findProject, t as appNotFound } from "./lookup-gjcKIZvh.js";
2
+ import { t as apiCall, u as currentHost } from "./spinner-DPdBlZe2.js";
3
+ import { i as orgIdOf, o as organizationOf, t as listOrgGroups } from "./orgs-Z0H9WOs1.js";
4
+ import { l as findPaywall, m as listProjects, y as platformLabel } from "./resources-CptT7HD6.js";
5
+ import { t as chooseOrgOfApps } from "./org-Dud1rF9f.js";
6
+ import { n as findApplication, r as findProject, t as appNotFound } from "./lookup-CWzVfPpq.js";
7
7
 
8
8
  //#region src/core/account/scope.ts
9
9
  function moveFirst(items, match) {
@@ -1,12 +1,12 @@
1
- import { n as PUBLIC_REPO, t as PUBLIC_REF } from "./download-2Zu2I_Og.js";
2
- import { n as VENDORED_SDK } from "./project-CP6hiHra.js";
1
+ import { r as VENDORED_SDK } from "./project-NoMtbMyl.js";
2
+ import { n as PUBLIC_REPO, t as PUBLIC_REF } from "./download-DhGd4hOB.js";
3
3
  import * as fs from "node:fs";
4
4
  import * as path from "node:path";
5
5
 
6
- //#region src/core/workspaces/sdk.ts
7
- const STARTER_DIR = "workspaces/starter";
6
+ //#region src/core/artifacts/sdk.ts
7
+ const STARTER_DIR = "artifacts/starter";
8
8
  const LATEST_TIMEOUT_MS = 1500;
9
- const LATEST_URL = () => `https://raw.githubusercontent.com/${PUBLIC_REPO}/${PUBLIC_REF}/${STARTER_DIR}/vendor/workspace-sdk/package.json`;
9
+ const LATEST_URL = () => `https://raw.githubusercontent.com/${PUBLIC_REPO}/${PUBLIC_REF}/${STARTER_DIR}/vendor/artifact-sdk/package.json`;
10
10
  function versionOf(manifest) {
11
11
  const version = manifest?.version;
12
12
  return typeof version === "string" ? version : void 0;
@@ -60,11 +60,11 @@ const isBehind = (current, latest) => compareVersions(current, latest) < 0;
60
60
  async function warnIfSdkBehind(ui, root, fetchImpl) {
61
61
  const current = vendoredVersion(root);
62
62
  if (current === void 0) {
63
- ui.warn("This workspace has no vendored SDK package. Run `superwall workspaces update` to add it.");
63
+ ui.warn("This artifact has no vendored SDK package. Run `superwall artifacts update` to add it.");
64
64
  return;
65
65
  }
66
66
  const latest = await latestVersion(fetchImpl);
67
- if (latest !== void 0 && isBehind(current, latest)) ui.warn(`Its workspace SDK is ${current}, and ${latest} is out. Run \`superwall workspaces update\` to get it.`);
67
+ if (latest !== void 0 && isBehind(current, latest)) ui.warn(`Its artifact SDK is ${current}, and ${latest} is out. Run \`superwall artifacts update\` to get it.`);
68
68
  }
69
69
 
70
70
  //#endregion