veo-sdk 0.5.21 → 0.5.22

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,5 @@
1
+ export { VEO_BLOCK_MIME, attachBlockDropTarget, attachDesignManipulator, createBuilderSession, initBuilderMode, startElementPicker, stopElementPicker } from './chunk-TFJSBKWN.mjs';
2
+ import './chunk-PSMDJDZK.mjs';
3
+ import './chunk-PTG3BTJE.mjs';
4
+ //# sourceMappingURL=builder-YJT44MRF.mjs.map
5
+ //# sourceMappingURL=builder-YJT44MRF.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"builder-TBIRGQDI.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"builder-YJT44MRF.mjs"}
package/dist/builder.cjs CHANGED
@@ -3301,6 +3301,26 @@ function safeDestroy(renderer) {
3301
3301
  }
3302
3302
  }
3303
3303
 
3304
+ // src/plugins/guides/url-match.ts
3305
+ function matchesUrl(matcher, pageUrl) {
3306
+ switch (matcher.type) {
3307
+ case "exact":
3308
+ return matcher.pattern === pageUrl;
3309
+ case "prefix":
3310
+ return pageUrl.startsWith(matcher.pattern);
3311
+ case "regex":
3312
+ try {
3313
+ return new RegExp(matcher.pattern).test(pageUrl);
3314
+ } catch {
3315
+ return false;
3316
+ }
3317
+ }
3318
+ }
3319
+ function stepMatchesPage(loc, pageUrl) {
3320
+ if (!loc || loc.scope === "sitewide" || !loc.pattern) return true;
3321
+ return matchesUrl({ type: loc.matchType ?? "prefix", pattern: loc.pattern }, pageUrl);
3322
+ }
3323
+
3304
3324
  // src/plugins/builder/bridge-protocol.ts
3305
3325
  var VEO_BUILDER_SOURCE = "veo-builder";
3306
3326
 
@@ -4018,10 +4038,28 @@ function initBuilderMode() {
4018
4038
  let dragGhost = null;
4019
4039
  let previewStepIndex = 0;
4020
4040
  let pendingPreview = null;
4041
+ let lastPreview = null;
4021
4042
  const getTarget = () => panel ? panel.target() : staticTarget;
4022
4043
  const post = (event) => {
4023
4044
  getTarget()?.postMessage({ source: VEO_BUILDER_SOURCE, token, ...event }, dashboardOrigin);
4024
4045
  };
4046
+ const previewMatchesPage = (cmd) => {
4047
+ const steps = cmd.guide.guideSteps;
4048
+ const step = steps?.[cmd.guide.startStepIndex ?? 0];
4049
+ return stepMatchesPage(step?.pageLocation, window.location.href);
4050
+ };
4051
+ const applyPreviewGated = (cmd) => {
4052
+ lastPreview = cmd;
4053
+ if (previewMatchesPage(cmd)) {
4054
+ applyPreview(cmd);
4055
+ } else {
4056
+ manipulator?.detach();
4057
+ manipulator = null;
4058
+ dropTarget?.detach();
4059
+ dropTarget = null;
4060
+ closeGuidePreview();
4061
+ }
4062
+ };
4025
4063
  const applyPreview = (cmd) => {
4026
4064
  manipulator?.detach();
4027
4065
  manipulator = null;
@@ -4043,7 +4081,7 @@ function initBuilderMode() {
4043
4081
  if (!pendingPreview) return;
4044
4082
  const queued = pendingPreview;
4045
4083
  pendingPreview = null;
4046
- applyPreview(queued);
4084
+ applyPreviewGated(queued);
4047
4085
  }
4048
4086
  });
4049
4087
  dropTarget = attachBlockDropTarget({
@@ -4121,7 +4159,7 @@ function initBuilderMode() {
4121
4159
  case "preview":
4122
4160
  if (!cmd.guide) break;
4123
4161
  if (manipulator?.isDragging()) pendingPreview = cmd;
4124
- else applyPreview(cmd);
4162
+ else applyPreviewGated(cmd);
4125
4163
  break;
4126
4164
  case "block-drag":
4127
4165
  handleBlockDrag(cmd);
@@ -4133,6 +4171,7 @@ function initBuilderMode() {
4133
4171
  dropTarget = null;
4134
4172
  hideDragGhost();
4135
4173
  pendingPreview = null;
4174
+ lastPreview = null;
4136
4175
  closeGuidePreview();
4137
4176
  break;
4138
4177
  case "teardown":
@@ -4147,9 +4186,35 @@ function initBuilderMode() {
4147
4186
  handleCommand(data);
4148
4187
  };
4149
4188
  const onPageHide = () => post({ type: "closed" });
4189
+ const onNav = () => {
4190
+ if (lastPreview && !manipulator?.isDragging()) applyPreviewGated(lastPreview);
4191
+ };
4192
+ const origPush = window.history.pushState;
4193
+ const origReplace = window.history.replaceState;
4194
+ const installNavWatcher = () => {
4195
+ window.history.pushState = function pushState(...args) {
4196
+ const r = origPush.apply(this, args);
4197
+ onNav();
4198
+ return r;
4199
+ };
4200
+ window.history.replaceState = function replaceState(...args) {
4201
+ const r = origReplace.apply(this, args);
4202
+ onNav();
4203
+ return r;
4204
+ };
4205
+ window.addEventListener("popstate", onNav);
4206
+ window.addEventListener("hashchange", onNav);
4207
+ };
4208
+ const removeNavWatcher = () => {
4209
+ window.history.pushState = origPush;
4210
+ window.history.replaceState = origReplace;
4211
+ window.removeEventListener("popstate", onNav);
4212
+ window.removeEventListener("hashchange", onNav);
4213
+ };
4150
4214
  const teardown = () => {
4151
4215
  window.removeEventListener("message", onMessage);
4152
4216
  window.removeEventListener("pagehide", onPageHide);
4217
+ removeNavWatcher();
4153
4218
  picker?.stop();
4154
4219
  picker = null;
4155
4220
  manipulator?.detach();
@@ -4180,6 +4245,7 @@ function initBuilderMode() {
4180
4245
  const activate = () => {
4181
4246
  window.addEventListener("message", onMessage);
4182
4247
  window.addEventListener("pagehide", onPageHide);
4248
+ installNavWatcher();
4183
4249
  if (!ctx.panel) post({ type: "ready" });
4184
4250
  };
4185
4251
  const cfg = window.__veoBuilder;