@vivix-labs/studio-workbench 1.0.0-beta.17 → 1.0.0-beta.18

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 (2) hide show
  1. package/dist/client.bundle.js +104 -15
  2. package/package.json +9 -9
@@ -2888,7 +2888,7 @@ function StudioHome({
2888
2888
  const Component2 = ui?.kind === "component" ? ui.component : void 0;
2889
2889
  return /* @__PURE__ */ React4.createElement(CardBoundary, { key: ref.plugin + "/" + ref.id, title: ui?.title ?? ref.id }, Component2 ? /* @__PURE__ */ React4.createElement(Component2, { ...props }) : /* @__PURE__ */ React4.createElement("p", { role: "status" }, "View unavailable: ", ref.plugin, "/", ref.id));
2890
2890
  };
2891
- const saved = client.config.savedViews;
2891
+ const saved = client.config.savedViews ?? [];
2892
2892
  const selected = saved.find(
2893
2893
  (ref) => "plugin" in ref && ref.plugin + "/" + ref.id === route.selected
2894
2894
  );
@@ -3026,9 +3026,35 @@ var samples = [
3026
3026
  { name: "out-of-steps", cover: "drama", label: "View a Short Drama Sample" },
3027
3027
  { name: "cobalt-headphones", cover: "ad", label: "View a Product Ad Sample" }
3028
3028
  ];
3029
+ function welcomeLocalKey(client) {
3030
+ return welcomeKey + "." + (client.scope?.id ?? "user");
3031
+ }
3032
+ async function markWelcomeSeen(client) {
3033
+ const dataInstance = client.config.dataInstance;
3034
+ const localKey = welcomeLocalKey(client);
3035
+ try {
3036
+ await client.invoke(
3037
+ { instanceId: dataInstance, operationId: "documents.create" },
3038
+ { name: "Studio welcome", payload: { namespace: welcomeKey } },
3039
+ { requestKey: welcomeKey }
3040
+ );
3041
+ } catch {
3042
+ try {
3043
+ localStorage.setItem(localKey, "seen");
3044
+ } catch {
3045
+ }
3046
+ }
3047
+ }
3048
+ function findCreatedWelcomeProject(initialIds, projects) {
3049
+ const added = projects.filter((project) => project.available && !initialIds.has(project.id));
3050
+ return added[added.length - 1];
3051
+ }
3029
3052
  function WelcomeDialog({
3030
3053
  client,
3031
3054
  instanceId,
3055
+ catalogReady,
3056
+ projects,
3057
+ paused = false,
3032
3058
  onCreate,
3033
3059
  onProject
3034
3060
  }) {
@@ -3036,8 +3062,27 @@ function WelcomeDialog({
3036
3062
  const [pending, setPending] = React5.useState();
3037
3063
  const [error, setError] = React5.useState("");
3038
3064
  const dataInstance = client.config.dataInstance;
3039
- const localKey = welcomeKey + "." + (client.scope?.id ?? "user");
3065
+ const localKey = welcomeLocalKey(client);
3066
+ const evaluatedRef = React5.useRef(void 0);
3067
+ const markedRef = React5.useRef(void 0);
3068
+ const initialIdsRef = React5.useRef(/* @__PURE__ */ new Set());
3069
+ const projectsRef = React5.useRef(projects);
3070
+ projectsRef.current = projects;
3071
+ const onProjectEvent = React5.useEffectEvent(onProject);
3072
+ const markSeen = React5.useEffectEvent(() => {
3073
+ if (markedRef.current?.client === client && markedRef.current.localKey === localKey) return;
3074
+ markedRef.current = { client, localKey };
3075
+ void markWelcomeSeen(client);
3076
+ });
3040
3077
  React5.useEffect(() => {
3078
+ if (!catalogReady) return;
3079
+ if (evaluatedRef.current?.client === client && evaluatedRef.current.localKey === localKey)
3080
+ return;
3081
+ evaluatedRef.current = { client, localKey };
3082
+ if (projectsRef.current.length > 0) {
3083
+ markSeen();
3084
+ return;
3085
+ }
3041
3086
  let active = true;
3042
3087
  async function firstVisit() {
3043
3088
  try {
@@ -3055,26 +3100,65 @@ function WelcomeDialog({
3055
3100
  } catch {
3056
3101
  }
3057
3102
  }
3058
- if (active) setOpen(true);
3103
+ if (!active) return;
3104
+ if (projectsRef.current.length > 0) {
3105
+ markSeen();
3106
+ return;
3107
+ }
3108
+ initialIdsRef.current = /* @__PURE__ */ new Set();
3109
+ setOpen(true);
3059
3110
  }
3060
3111
  void firstVisit();
3061
3112
  return () => {
3062
3113
  active = false;
3063
3114
  };
3064
- }, [client, dataInstance, localKey]);
3065
- if (!open) return null;
3066
- function dismiss() {
3067
- setOpen(false);
3068
- void client.invoke(
3069
- { instanceId: dataInstance, operationId: "documents.create" },
3070
- { name: "Studio welcome", payload: { namespace: welcomeKey } },
3071
- { requestKey: welcomeKey }
3072
- ).catch(() => {
3115
+ }, [client, dataInstance, localKey, catalogReady]);
3116
+ React5.useEffect(() => {
3117
+ if (!open || paused || pending) return;
3118
+ const fromCatalog = findCreatedWelcomeProject(initialIdsRef.current, projects);
3119
+ if (fromCatalog) {
3120
+ setOpen(false);
3121
+ markSeen();
3122
+ onProjectEvent(fromCatalog);
3123
+ return;
3124
+ }
3125
+ const listProjects = client.projects?.list;
3126
+ if (!listProjects) return;
3127
+ let active = true;
3128
+ let checking = false;
3129
+ async function checkExternalProject() {
3130
+ if (!active || checking) return;
3131
+ checking = true;
3073
3132
  try {
3074
- localStorage.setItem(localKey, "seen");
3133
+ const latest = await listProjects();
3134
+ if (!active) return;
3135
+ const created = findCreatedWelcomeProject(initialIdsRef.current, latest);
3136
+ if (!created) return;
3137
+ setOpen(false);
3138
+ markSeen();
3139
+ onProjectEvent(created);
3075
3140
  } catch {
3141
+ } finally {
3142
+ checking = false;
3076
3143
  }
3077
- });
3144
+ }
3145
+ const timer = window.setInterval(() => void checkExternalProject(), 1e3);
3146
+ const onWake = () => {
3147
+ if (document.visibilityState !== "hidden") void checkExternalProject();
3148
+ };
3149
+ window.addEventListener("focus", onWake);
3150
+ document.addEventListener("visibilitychange", onWake);
3151
+ return () => {
3152
+ active = false;
3153
+ window.clearInterval(timer);
3154
+ window.removeEventListener("focus", onWake);
3155
+ document.removeEventListener("visibilitychange", onWake);
3156
+ };
3157
+ }, [client, open, paused, pending, projects]);
3158
+ if (!open) return null;
3159
+ function dismiss() {
3160
+ setOpen(false);
3161
+ markSeen();
3078
3162
  }
3079
3163
  async function openSample(sample) {
3080
3164
  if (pending) return;
@@ -3107,6 +3191,7 @@ function WelcomeDialog({
3107
3191
  { requestKey: crypto.randomUUID() }
3108
3192
  );
3109
3193
  }
3194
+ dismiss();
3110
3195
  onProject(project);
3111
3196
  } catch (error2) {
3112
3197
  setError(error2 instanceof Error ? error2.message : String(error2));
@@ -3950,7 +4035,7 @@ function GlobalWorkbench({ client }) {
3950
4035
  if (route.project.view !== view2) navigate({ ...route, project: { ...route.project, view: view2 } });
3951
4036
  requestProjectView.current?.(view2, true);
3952
4037
  }
3953
- const sidebarPreferenceKey = `studio-sidebar-collapsed:${client.project.id}`;
4038
+ const sidebarPreferenceKey = `studio-sidebar-collapsed:${client.project?.id ?? client.scope?.id ?? "user"}`;
3954
4039
  const [collapsed, setCollapsed] = React8.useState(() => {
3955
4040
  try {
3956
4041
  return window.localStorage.getItem(sidebarPreferenceKey) === "true";
@@ -4379,6 +4464,7 @@ function GlobalWorkbench({ client }) {
4379
4464
  });
4380
4465
  }
4381
4466
  function onProjectCreated(project) {
4467
+ void markWelcomeSeen(client);
4382
4468
  setCatalog((items) => [...(items ?? []).filter((item) => item.id !== project.id), project]);
4383
4469
  refreshCatalog();
4384
4470
  navigate({
@@ -5473,6 +5559,9 @@ function GlobalWorkbench({ client }) {
5473
5559
  {
5474
5560
  client,
5475
5561
  instanceId: ownInstance,
5562
+ catalogReady,
5563
+ projects: catalog,
5564
+ paused: creatingProject,
5476
5565
  onCreate: NewProjectDialog ? () => setCreatingProject(true) : void 0,
5477
5566
  onProject: onProjectCreated
5478
5567
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vivix-labs/studio-workbench",
3
- "version": "1.0.0-beta.17",
3
+ "version": "1.0.0-beta.18",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -44,12 +44,9 @@
44
44
  "archiver": "7.0.1"
45
45
  },
46
46
  "devDependencies": {
47
- "@vivix-labs/project-studio": "workspace:*",
48
- "@vivix-labs/ui-system": "workspace:*",
49
- "@types/archiver": "7.0.0"
50
- },
51
- "scripts": {
52
- "build": "node ../../scripts/build-product-packages.mjs studio-workbench"
47
+ "@types/archiver": "7.0.0",
48
+ "@vivix-labs/ui-system": "1.0.0-beta.17",
49
+ "@vivix-labs/project-studio": "1.0.0-beta.17"
53
50
  },
54
51
  "vivixStudio": {
55
52
  "runtimePlugins": {
@@ -70,11 +67,14 @@
70
67
  "@vivix-labs/short-drama-storyboard": "1.0.0-beta.17",
71
68
  "@vivix-labs/short-drama-workbench": "1.0.0-beta.17",
72
69
  "@vivix-labs/studio-asset-list": "1.0.0-beta.17",
73
- "@vivix-labs/studio-workbench": "1.0.0-beta.17",
70
+ "@vivix-labs/studio-workbench": "1.0.0-beta.18",
74
71
  "@vivix-labs/vivix-api": "1.0.0-beta.17",
75
72
  "@vivix-labs/ads-workbench": "1.0.0-beta.17",
76
73
  "@vivix-labs/chat-components": "1.0.0-beta.17",
77
74
  "@vivix-labs/short-drama-authoring": "1.0.0-beta.17"
78
75
  }
76
+ },
77
+ "scripts": {
78
+ "build": "node ../../scripts/build-product-packages.mjs studio-workbench"
79
79
  }
80
- }
80
+ }