@juo/orion-core 0.19.0 → 0.20.0

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-BAC3Lblr.js";
9
+ import "./juo-workflow-BBbsNhY2.js";
10
10
  class Block extends HTMLElement {
11
11
  constructor() {
12
12
  super();
package/dist/block.d.ts CHANGED
@@ -23,6 +23,8 @@ export type BlockDefinition<T = unknown> = {
23
23
  render: BlockRenderer;
24
24
  presets?: BlockPresets;
25
25
  locales?: {
26
+ /** Locale codes supported by this block (e.g. ["en", "de", "nl"]). */
27
+ supported?: string[];
26
28
  load: (locale: string) => Promise<BlockLocaleFile>;
27
29
  };
28
30
  };
@@ -73,6 +75,7 @@ export declare function defineBlock<T>(name: string, opts: {
73
75
  renderer: (block: BlockInstance) => HTMLElement;
74
76
  presets?: BlockPresets;
75
77
  locales?: {
78
+ supported?: string[];
76
79
  load: (locale: string) => Promise<BlockLocaleFile>;
77
80
  };
78
81
  }): BlockDefinition<T>;
@@ -87,7 +87,7 @@ function createRegisterBlocksMessage(payload) {
87
87
  schema: block.schema == null ? block.schema : JSON.parse(JSON.stringify(block.schema)),
88
88
  initialValue: block.initialValue == null ? block.initialValue : JSON.parse(JSON.stringify(block.initialValue)),
89
89
  presets: block.presets == null ? block.presets : JSON.parse(JSON.stringify(block.presets)),
90
- localeDefaults: block.localeDefaults == null ? block.localeDefaults : JSON.parse(JSON.stringify(block.localeDefaults))
90
+ locales: block.locales == null ? block.locales : JSON.parse(JSON.stringify(block.locales))
91
91
  }));
92
92
  return {
93
93
  type: "REGISTER_BLOCKS",
@@ -470,16 +470,16 @@ export {
470
470
  createFocusInlineTextMessage as b,
471
471
  createRegisterBlockTranslationKeysMessage as c,
472
472
  createUpdateBlockTranslationMessage as d,
473
- createRemoveBlockMessage as e,
474
- createRegisterBlocksMessage as f,
475
- createRegisterRoutesMessage as g,
476
- isIframeMessage as h,
473
+ createSelectBlockMessage as e,
474
+ createRemoveBlockMessage as f,
475
+ createRegisterBlocksMessage as g,
476
+ createRegisterRoutesMessage as h,
477
477
  isEditorMessage as i,
478
- createProvideThemeStateMessage as j,
479
- createRequestThemeStateMessage as k,
480
- createRequestTranslationOverridesMessage as l,
481
- createProvideTranslationOverridesMessage as m,
482
- createSelectBlockMessage as n,
478
+ isIframeMessage as j,
479
+ createProvideThemeStateMessage as k,
480
+ createRequestThemeStateMessage as l,
481
+ createRequestTranslationOverridesMessage as m,
482
+ createProvideTranslationOverridesMessage as n,
483
483
  createUpdateBlockPropsMessage as o,
484
484
  createAddBlockMessage as p,
485
485
  createMoveBlockMessage as q,
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-BAC3Lblr.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";
10
10
  function createState() {
11
11
  const discountCode = d(null);
12
12
  const products = d([]);
@@ -123,7 +123,8 @@ export interface RegisterBlocksMessage extends BaseMessage {
123
123
  schema: unknown;
124
124
  initialValue: unknown;
125
125
  presets?: BlockPresets;
126
- localeDefaults?: Record<string, string>;
126
+ /** Locale code → flattened translation strings for all supported locales. */
127
+ locales?: Record<string, Record<string, string>>;
127
128
  }>;
128
129
  };
129
130
  }
package/dist/editor.js CHANGED
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { getDefinedBlocks, onRegisterBlock } from "@juo/orion-core";
8
- import { a as createEditorBridge, e as createRemoveBlockMessage, f as createRegisterBlocksMessage, g as createRegisterRoutesMessage } from "./bridge-SZyjoSJS.js";
9
- import { p, b, q, v, w, j, m, c, y, u, k, l, x, n, r, t, s, o, d, z, i, h } from "./bridge-SZyjoSJS.js";
8
+ import { a as createEditorBridge, f as createRemoveBlockMessage, g as createRegisterBlocksMessage, h as createRegisterRoutesMessage } from "./bridge-BHI_2-Xw.js";
9
+ import { p, b, q, v, w, k, n, c, y, u, l, m, x, e, r, t, s, o, d, z, i, j } from "./bridge-BHI_2-Xw.js";
10
10
  import { e as createBlockInstanceFromObject, m as indexOverrides } from "./theme-state-D4n_2n_h.js";
11
11
  function createEditorHandler(options) {
12
12
  const { themeState, onBlockSelection } = options;
@@ -471,8 +471,8 @@ class BlockWrapper extends HTMLElement {
471
471
  const moreBtn = document.createElement("button");
472
472
  moreBtn.type = "button";
473
473
  moreBtn.innerHTML = moreIconSvg;
474
- moreBtn.addEventListener("click", (e) => {
475
- e.stopPropagation();
474
+ moreBtn.addEventListener("click", (e2) => {
475
+ e2.stopPropagation();
476
476
  this.toggleMenu();
477
477
  });
478
478
  const menuEl = document.createElement("div");
@@ -488,8 +488,8 @@ class BlockWrapper extends HTMLElement {
488
488
  deleteBtn.className = "block-wrapper__menu-item block-wrapper__menu-item--danger";
489
489
  deleteBtn.setAttribute("role", "menuitem");
490
490
  deleteBtn.innerHTML = `${trashIconSvg}<span>Delete</span>`;
491
- deleteBtn.addEventListener("click", (e) => {
492
- e.stopPropagation();
491
+ deleteBtn.addEventListener("click", (e2) => {
492
+ e2.stopPropagation();
493
493
  this.closeMenu();
494
494
  this.handleRemoveBlock();
495
495
  });
@@ -538,8 +538,8 @@ class BlockWrapper extends HTMLElement {
538
538
  return;
539
539
  this.menuElement.classList.add("open");
540
540
  this.isMenuOpen = true;
541
- this.closeMenuOnOutsideClick = (e) => {
542
- if (!this.shadowRoot.contains(e.composedPath()[0])) {
541
+ this.closeMenuOnOutsideClick = (e2) => {
542
+ if (!this.shadowRoot.contains(e2.composedPath()[0])) {
543
543
  this.closeMenu();
544
544
  }
545
545
  };
@@ -622,7 +622,7 @@ class BlockWrapper extends HTMLElement {
622
622
  if (customElements.get("juo-editor-block-wrapper") == null) {
623
623
  customElements.define("juo-editor-block-wrapper", BlockWrapper);
624
624
  }
625
- function serializeBlock(block) {
625
+ async function serializeBlock(block) {
626
626
  let initialValue = block.initialValue;
627
627
  if (typeof initialValue === "function") {
628
628
  try {
@@ -631,12 +631,36 @@ function serializeBlock(block) {
631
631
  initialValue = void 0;
632
632
  }
633
633
  }
634
+ let locales;
635
+ if (block.locales) {
636
+ const supported = block.locales.supported ?? ["en"];
637
+ const entries = await Promise.all(
638
+ supported.map(async (code) => {
639
+ try {
640
+ const localeFile = await block.locales.load(code);
641
+ const topLevel = Object.fromEntries(
642
+ Object.entries(localeFile).filter(
643
+ ([key, value]) => key !== "overrides" && typeof value === "string"
644
+ )
645
+ );
646
+ return [code, { ...topLevel, ...localeFile.overrides ?? {} }];
647
+ } catch {
648
+ return null;
649
+ }
650
+ })
651
+ );
652
+ const loaded = entries.filter((e2) => e2 !== null);
653
+ if (loaded.length > 0) {
654
+ locales = Object.fromEntries(loaded);
655
+ }
656
+ }
634
657
  return {
635
658
  name: block.name,
636
659
  group: block.group,
637
660
  schema: block.schema,
638
661
  initialValue,
639
- presets: block.presets
662
+ presets: block.presets,
663
+ locales
640
664
  };
641
665
  }
642
666
  async function setupEditorMode(routes, themeState) {
@@ -647,16 +671,18 @@ async function setupEditorMode(routes, themeState) {
647
671
  const { unsubscribe } = editor.onMessage((message) => {
648
672
  handler.handleMessage(message);
649
673
  });
650
- const blocks = getDefinedBlocks().map(serializeBlock);
674
+ const blocks = await Promise.all(getDefinedBlocks().map(serializeBlock));
651
675
  editor.sendMessage(createRegisterBlocksMessage({ blocks }));
652
676
  editor.sendMessage(createRegisterRoutesMessage({ routes }));
653
- onRegisterBlock(
654
- (_, block) => editor.sendMessage(
655
- createRegisterBlocksMessage({
656
- blocks: [serializeBlock(block)]
657
- })
658
- )
659
- );
677
+ onRegisterBlock((_, block) => {
678
+ void serializeBlock(block).then(
679
+ (serialized) => editor.sendMessage(
680
+ createRegisterBlocksMessage({
681
+ blocks: [serialized]
682
+ })
683
+ )
684
+ );
685
+ });
660
686
  return () => {
661
687
  unsubscribe();
662
688
  editor.destroy();
@@ -671,18 +697,18 @@ export {
671
697
  q as createMoveBlockMessage,
672
698
  v as createProvideGlobalStylesMessage,
673
699
  w as createProvideInitialGlobalStylesMessage,
674
- j as createProvideThemeStateMessage,
675
- m as createProvideTranslationOverridesMessage,
700
+ k as createProvideThemeStateMessage,
701
+ n as createProvideTranslationOverridesMessage,
676
702
  c as createRegisterBlockTranslationKeysMessage,
677
703
  createRegisterBlocksMessage,
678
704
  createRegisterRoutesMessage,
679
705
  createRemoveBlockMessage,
680
706
  y as createReportContentHeightMessage,
681
707
  u as createRequestGlobalStylesMessage,
682
- k as createRequestThemeStateMessage,
683
- l as createRequestTranslationOverridesMessage,
708
+ l as createRequestThemeStateMessage,
709
+ m as createRequestTranslationOverridesMessage,
684
710
  x as createScrollSyncMessage,
685
- n as createSelectBlockMessage,
711
+ e as createSelectBlockMessage,
686
712
  r as createSetBlockPresetMessage,
687
713
  t as createSetGlobalStylesMessage,
688
714
  s as createSetLocaleMessage,
@@ -690,6 +716,6 @@ export {
690
716
  d as createUpdateBlockTranslationMessage,
691
717
  z as getEditorBridge,
692
718
  i as isEditorMessage,
693
- h as isIframeMessage,
719
+ j as isIframeMessage,
694
720
  setupEditorMode
695
721
  };
@@ -5,7 +5,7 @@ var __publicField = (obj, key, value) => {
5
5
  return value;
6
6
  };
7
7
  import { c as createContext, d, E, i as getDefinedBlocks, a as createBlockInstance, w, r as registerBlock, g as defineBlock, t as subscribeContext } from "./theme-state-D4n_2n_h.js";
8
- import { a as createEditorBridge } from "./bridge-SZyjoSJS.js";
8
+ import { a as createEditorBridge, e as createSelectBlockMessage } from "./bridge-BHI_2-Xw.js";
9
9
  const TranslationContext = createContext("translation");
10
10
  function toStringRecord(input) {
11
11
  if (input == null)
@@ -176,7 +176,7 @@ function createWorkflowService(deps) {
176
176
  return `wf-${shortenId(workflowId)}-${shortenId(stepId)}`;
177
177
  }
178
178
  function handleFlowResponse(data) {
179
- var _a;
179
+ var _a, _b;
180
180
  const mergedInvalidated = [
181
181
  ..._state.value.invalidatedResources,
182
182
  ...data.invalidatedResources ?? []
@@ -193,6 +193,18 @@ function createWorkflowService(deps) {
193
193
  invalidatedResources: mergedInvalidated,
194
194
  outcome: null
195
195
  });
196
+ if (editor.isEditorMode) {
197
+ const overlayBlocks = deps.themeState.overlay.blocks.value;
198
+ const rootBlock = overlayBlocks[0];
199
+ const stepSlot = (_a = rootBlock == null ? void 0 : rootBlock.slots) == null ? void 0 : _a[data.pendingInteraction.stepId];
200
+ const stepBlock = Array.isArray(stepSlot) ? stepSlot[0] : null;
201
+ const blockId = stepBlock && typeof stepBlock === "object" && "id" in stepBlock ? stepBlock.id : null;
202
+ if (blockId) {
203
+ editor.sendMessage(
204
+ createSelectBlockMessage({ blockId }, blockId)
205
+ );
206
+ }
207
+ }
196
208
  } else if (data.status === "completed") {
197
209
  updateState({
198
210
  status: "completed",
@@ -204,7 +216,7 @@ function createWorkflowService(deps) {
204
216
  outcome: data.outcome || null
205
217
  });
206
218
  } else if (data.status === "failed") {
207
- handleError(new Error(((_a = data.error) == null ? void 0 : _a.message) || "Flow failed"));
219
+ handleError(new Error(((_b = data.error) == null ? void 0 : _b.message) || "Flow failed"));
208
220
  } else if (data.status === "cancelled") {
209
221
  updateState({
210
222
  status: "idle",
package/dist/preact.js CHANGED
@@ -9,7 +9,7 @@ import { useState, useRef, useEffect, useContext as useContext$1, useMemo } from
9
9
  import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-DPjf_G7G.js";
10
10
  import { t } from "./block-DPjf_G7G.js";
11
11
  import { createContext, h, render } from "preact";
12
- import { a as createEditorBridge } from "./bridge-SZyjoSJS.js";
12
+ import { a as createEditorBridge } from "./bridge-BHI_2-Xw.js";
13
13
  function toState(signal) {
14
14
  const [value, setValue] = useState(() => getSignalValue(signal));
15
15
  const disposeRef = useRef(null);
package/dist/react.js CHANGED
@@ -9,7 +9,7 @@ import React, { useSyncExternalStore, createContext, useState, useContext as use
9
9
  import { g as getSignalValue, s as setSignalValue, w as wrapContext, c as createSlotChildren } from "./block-DPjf_G7G.js";
10
10
  import { t } from "./block-DPjf_G7G.js";
11
11
  import { createRoot } from "react-dom/client";
12
- import { a as createEditorBridge } from "./bridge-SZyjoSJS.js";
12
+ import { a as createEditorBridge } from "./bridge-BHI_2-Xw.js";
13
13
  function toState(signal) {
14
14
  const subscribe = (callback) => {
15
15
  const dispose = effect(() => {
package/dist/vue.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { toValue, watchEffect, customRef, defineComponent, ref, getCurrentInstance, onMounted, provide, h, renderSlot, inject, computed, createApp, useHost, defineCustomElement } from "vue";
2
2
  import { signal, effect, injectContext, provideContext, createCeRenderer } from "@juo/orion-core";
3
- import { c as createRegisterBlockTranslationKeysMessage, a as createEditorBridge } from "./bridge-SZyjoSJS.js";
3
+ import { c as createRegisterBlockTranslationKeysMessage, a as createEditorBridge } from "./bridge-BHI_2-Xw.js";
4
4
  const signalsMap = /* @__PURE__ */ new WeakMap();
5
5
  function toSignal(ref2) {
6
6
  if (!signalsMap.has(ref2)) {
@@ -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-Cd9xPgd2.js";
9
- import { a as createEditorBridge, b as createFocusInlineTextMessage, d as createUpdateBlockTranslationMessage } from "./bridge-SZyjoSJS.js";
10
- import { T as TranslationContext } from "./juo-workflow-BAC3Lblr.js";
8
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-z_aRSifd.js";
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";
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-Cd9xPgd2.js";
9
- import { T as TranslationContext } from "./juo-workflow-BAC3Lblr.js";
8
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-z_aRSifd.js";
9
+ import { T as TranslationContext } from "./juo-workflow-BBbsNhY2.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.19.0",
4
+ "version": "0.20.0",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"