@juo/orion-core 0.20.1 → 0.20.2

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.
@@ -6,7 +6,7 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  import { signal, effect, createBlockInstance } from "@juo/orion-core";
8
8
  import { d, j as withWrapper, t as subscribeContext, T as ThemeStateContext, E, v as n } from "./theme-state-D4n_2n_h.js";
9
- import "./juo-workflow-BBbsNhY2.js";
9
+ import "./juo-workflow-Dbh6KMoG.js";
10
10
  class Block extends HTMLElement {
11
11
  constructor() {
12
12
  super();
package/dist/core.js CHANGED
@@ -6,7 +6,7 @@ var __publicField = (obj, key, value) => {
6
6
  };
7
7
  import { c as createContext, d, w, E, u } from "./theme-state-D4n_2n_h.js";
8
8
  import { B, n, C, D, S, T, a, b, e, f, k, l, g, h, i, m, p, o, q, r, s, t, v, j } from "./theme-state-D4n_2n_h.js";
9
- import { T as T2, W, c, b as b2, a as a2, g as g2, h as h2 } from "./juo-workflow-BBbsNhY2.js";
9
+ import { T as T2, W, c, b as b2, a as a2, g as g2, h as h2 } from "./juo-workflow-Dbh6KMoG.js";
10
10
  function createState() {
11
11
  const discountCode = d(null);
12
12
  const products = d([]);
@@ -10,6 +10,7 @@ export declare const WorkflowServiceContext: {
10
10
  isLoading: ReadonlySignal<boolean>;
11
11
  isCompleted: ReadonlySignal<boolean>;
12
12
  hasError: ReadonlySignal<boolean>;
13
+ canRespond: ReadonlySignal<boolean>;
13
14
  currentInteraction: ReadonlySignal<PendingInteraction | null>;
14
15
  currentStepInfo: ReadonlySignal<WorkflowStepInfo | null>;
15
16
  startFlow(flowType: string, context: Record<string, unknown>, workflowId?: string): Promise<void>;
@@ -148,6 +149,7 @@ export declare function createWorkflowService(deps: WorkflowServiceDependencies)
148
149
  isLoading: ReadonlySignal<boolean>;
149
150
  isCompleted: ReadonlySignal<boolean>;
150
151
  hasError: ReadonlySignal<boolean>;
152
+ canRespond: ReadonlySignal<boolean>;
151
153
  currentInteraction: ReadonlySignal<PendingInteraction | null>;
152
154
  currentStepInfo: ReadonlySignal<WorkflowStepInfo | null>;
153
155
  startFlow(flowType: string, context: Record<string, unknown>, workflowId?: string): Promise<void>;
@@ -137,12 +137,20 @@ function createWorkflowService(deps) {
137
137
  outcome: null,
138
138
  dryRun: null
139
139
  });
140
+ const _backendInteractionId = d(null);
140
141
  const _registeredRootBlocks = /* @__PURE__ */ new Set();
141
142
  const isActive = w(() => _state.value.status === "active");
142
143
  const isLoading = w(() => _state.value.status === "loading");
143
144
  const isCompleted = w(() => _state.value.status === "completed");
144
145
  const hasError = w(() => _state.value.status === "error");
145
146
  const currentInteraction = w(() => _state.value.currentInteraction);
147
+ const canRespond = w(() => {
148
+ const interaction = _state.value.currentInteraction;
149
+ const backendId = _backendInteractionId.value;
150
+ if (!interaction || !backendId)
151
+ return false;
152
+ return interaction.interactionId === backendId;
153
+ });
146
154
  const currentStepInfo = w(() => {
147
155
  const interaction = _state.value.currentInteraction;
148
156
  if (!interaction)
@@ -182,6 +190,7 @@ function createWorkflowService(deps) {
182
190
  ...data.invalidatedResources ?? []
183
191
  ];
184
192
  if (data.status === "waiting_interaction" && data.pendingInteraction) {
193
+ _backendInteractionId.value = data.pendingInteraction.interactionId;
185
194
  updateState({
186
195
  status: "active",
187
196
  workflowId: data.workflowId,
@@ -206,6 +215,7 @@ function createWorkflowService(deps) {
206
215
  }
207
216
  }
208
217
  } else if (data.status === "completed") {
218
+ _backendInteractionId.value = null;
209
219
  updateState({
210
220
  status: "completed",
211
221
  currentStepId: null,
@@ -216,8 +226,10 @@ function createWorkflowService(deps) {
216
226
  outcome: data.outcome || null
217
227
  });
218
228
  } else if (data.status === "failed") {
229
+ _backendInteractionId.value = null;
219
230
  handleError(new Error(((_b = data.error) == null ? void 0 : _b.message) || "Flow failed"));
220
231
  } else if (data.status === "cancelled") {
232
+ _backendInteractionId.value = null;
221
233
  updateState({
222
234
  status: "idle",
223
235
  flowType: null,
@@ -362,6 +374,7 @@ function createWorkflowService(deps) {
362
374
  isLoading,
363
375
  isCompleted,
364
376
  hasError,
377
+ canRespond,
365
378
  currentInteraction,
366
379
  currentStepInfo,
367
380
  // Methods
@@ -454,6 +467,7 @@ function createWorkflowService(deps) {
454
467
  service.reset();
455
468
  },
456
469
  reset() {
470
+ _backendInteractionId.value = null;
457
471
  updateState({
458
472
  status: "idle",
459
473
  flowType: null,
@@ -5,9 +5,9 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { p as injectContext, E, x as ContextRoot } from "./theme-state-D4n_2n_h.js";
8
- import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-z_aRSifd.js";
8
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-BmGYqy4C.js";
9
9
  import { a as createEditorBridge, b as createFocusInlineTextMessage, d as createUpdateBlockTranslationMessage } from "./bridge-BHI_2-Xw.js";
10
- import { T as TranslationContext } from "./juo-workflow-BBbsNhY2.js";
10
+ import { T as TranslationContext } from "./juo-workflow-Dbh6KMoG.js";
11
11
  const _InlineText = class _InlineText extends HTMLElement {
12
12
  constructor() {
13
13
  super();
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { p as injectContext, E, x as ContextRoot } from "./theme-state-D4n_2n_h.js";
8
- import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-z_aRSifd.js";
9
- import { T as TranslationContext } from "./juo-workflow-BBbsNhY2.js";
8
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-BmGYqy4C.js";
9
+ import { T as TranslationContext } from "./juo-workflow-Dbh6KMoG.js";
10
10
  class InlineText extends HTMLElement {
11
11
  constructor() {
12
12
  super(...arguments);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@juo/orion-core",
3
3
  "private": false,
4
- "version": "0.20.1",
4
+ "version": "0.20.2",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"