@juo/blocks 1.4.2 → 1.4.4

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.
@@ -3,8 +3,8 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import { signal, effect, createBlockInstance } from "@juo/blocks";
5
5
  import { reportBlockWarning, reportBlockError } from "./observability.js";
6
- import { d, t as subscribeContext, T as ThemeStateContext, E, x as withWrapper, v as n } from "./theme-state-BpmgtjdC.js";
7
- import "./juo-workflow-BXGQS82N.js";
6
+ import { d, t as subscribeContext, T as ThemeStateContext, E, x as withWrapper, v as n, o as isStubDefinition, p as onRegisterBlock } from "./theme-state-CItCtH5l.js";
7
+ import "./juo-workflow-1EMEURtn.js";
8
8
  class Block extends HTMLElement {
9
9
  constructor() {
10
10
  super();
@@ -63,6 +63,19 @@ class ExtensionRoot extends HTMLElement {
63
63
  __publicField(this, "themeState", null);
64
64
  __publicField(this, "unsubscribeThemeContext");
65
65
  __publicField(this, "disposeEffect");
66
+ __publicField(this, "__vueInstance", null);
67
+ /**
68
+ * Names of top-level slot children that resolved to a stub on the last
69
+ * render pass — i.e. blocks whose definition hasn't been registered yet.
70
+ * Rebuilt on each render and consulted from the registration listener so
71
+ * we only retrigger when a block we're actually waiting on lands.
72
+ *
73
+ * Only top-level children are tracked — nested stubs inside a registered
74
+ * parent's renderer aren't currently handled (rare in practice; revisit
75
+ * if it shows up).
76
+ */
77
+ __publicField(this, "unresolvedNames", /* @__PURE__ */ new Set());
78
+ __publicField(this, "unregisterListener");
66
79
  /**
67
80
  * Optional function to wrap each rendered block element.
68
81
  * Called with the rendered block HTMLElement, must return an HTMLElement.
@@ -80,7 +93,7 @@ class ExtensionRoot extends HTMLElement {
80
93
  if (!this.wrapperCache.has(block)) {
81
94
  const blockWrapper = this.blockWrapper;
82
95
  const wrapper = withWrapper((block2) => {
83
- const rendered = block2.definition.render(block2);
96
+ const rendered = block2.definition.render({ ...block2, __vueInstance: this.__vueInstance });
84
97
  return blockWrapper ? blockWrapper(rendered) : rendered;
85
98
  });
86
99
  this.wrapperCache.set(block, wrapper);
@@ -123,11 +136,12 @@ class ExtensionRoot extends HTMLElement {
123
136
  const blocks = state.blocks.value;
124
137
  n(() => {
125
138
  var _a;
139
+ let extensionBlocks = [];
126
140
  try {
127
- const extensionBlocks = (((_a = blocks.at(0)) == null ? void 0 : _a.slots) ?? {})[name] ?? [];
141
+ extensionBlocks = (((_a = blocks.at(0)) == null ? void 0 : _a.slots) ?? {})[name] ?? [];
128
142
  const children = extensionBlocks.map(
129
143
  (block) => this.withWrapper(block)
130
- ) ?? [];
144
+ );
131
145
  this.replaceChildren(...children);
132
146
  } catch (error) {
133
147
  reportBlockError(error, {
@@ -138,6 +152,20 @@ class ExtensionRoot extends HTMLElement {
138
152
  }
139
153
  });
140
154
  this.replaceChildren();
155
+ extensionBlocks = [];
156
+ }
157
+ this.unresolvedNames.clear();
158
+ for (const block of extensionBlocks) {
159
+ if (block != null && typeof block === "object" && isStubDefinition(block.definition)) {
160
+ this.unresolvedNames.add(block.type);
161
+ }
162
+ }
163
+ if (this.unresolvedNames.size > 0 && !this.unregisterListener) {
164
+ this.unregisterListener = onRegisterBlock((name2) => {
165
+ if (this.unresolvedNames.has(name2) && this.state.value) {
166
+ this.state.value = { ...this.state.value };
167
+ }
168
+ });
141
169
  }
142
170
  });
143
171
  });
@@ -162,6 +190,11 @@ class ExtensionRoot extends HTMLElement {
162
190
  this.disposeEffect();
163
191
  this.disposeEffect = void 0;
164
192
  }
193
+ if (this.unregisterListener) {
194
+ this.unregisterListener();
195
+ this.unregisterListener = void 0;
196
+ }
197
+ this.unresolvedNames.clear();
165
198
  }
166
199
  }
167
200
  export {
package/dist/block.d.ts CHANGED
@@ -10,7 +10,9 @@ export interface BlockPreset<TState = unknown, TContext extends Record<string, u
10
10
  context: TContext;
11
11
  }
12
12
  export type BlockPresets = Record<string, BlockPreset<unknown, Record<string, unknown>>>;
13
- export type BlockRenderer = (block: BlockInstance) => HTMLElement;
13
+ export type BlockRenderer = (block: BlockInstance & {
14
+ __vueInstance?: unknown;
15
+ }) => HTMLElement;
14
16
  export type BlockLocaleFile = {
15
17
  overrides?: Record<string, string>;
16
18
  [key: string]: string | Record<string, string> | undefined;
@@ -68,7 +70,7 @@ declare global {
68
70
  }
69
71
  export declare function withWrapper(fn: (block: BlockInstance) => HTMLElement): (block: BlockInstance) => HTMLElement;
70
72
  export declare function registerBlock<T>(block: BlockDefinition<T>): void;
71
- export declare function onRegisterBlock(cb: (name: string, block: BlockDefinition) => void): void;
73
+ export declare function onRegisterBlock(cb: (name: string, block: BlockDefinition) => void): () => void;
72
74
  export declare function defineBlock<T>(name: string, opts: {
73
75
  group: "internal" | "juo" | "theme" | "integration" | "page" | "workflow" | "action";
74
76
  schema: JSONSchema;
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAIpD,KAAK,MAAM,GAAG,EAAE,GAAG,CAAC,UAAU,GAAG;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC,CAAC;AAErD,MAAM,WAAW,WAAW,CAC1B,MAAM,GAAG,OAAO,EAChB,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAElE,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,QAAQ,CAAC;CACnB;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAC/B,MAAM,EACN,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM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E,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,GAAG,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C,aAAa,CA2Cf;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAczE;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,MAAM,GAAG,aAAa,CAUxE"}
package/dist/core.js CHANGED
@@ -1,9 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { c as createContext, d, w, r as registerBlock, E, u } from "./theme-state-BpmgtjdC.js";
5
- import { B, C, a, D, S, T, b, e, f, g, h, i, j, k, l, m, n, o, p, q, s, t, v, x } from "./theme-state-BpmgtjdC.js";
6
- import { T as T2, W, c, a as a2, b as b2, g as g2, h as h2 } from "./juo-workflow-BXGQS82N.js";
4
+ import { c as createContext, d, w, r as registerBlock, E, u } from "./theme-state-CItCtH5l.js";
5
+ import { B, C, a, D, S, T, b, e, f, g, h, i, j, k, l, m, n, o, p, q, s, t, v, x } from "./theme-state-CItCtH5l.js";
6
+ import { T as T2, W, c, a as a2, b as b2, g as g2, h as h2 } from "./juo-workflow-1EMEURtn.js";
7
7
  import { reportBlockWarning, reportBlockError } from "./observability.js";
8
8
  function createState() {
9
9
  const discountCode = d(null);
@@ -1 +1 @@
1
- {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/editor/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAkJ9C,qBAAa,YAAa,SAAQ,WAAW;IAC3C,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,WAAW,CAA4B;IAC/C,O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AAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,0BAA0B,EAAE,YAAY,CAAC;KAC1C;CACF"}
package/dist/editor.js CHANGED
@@ -4,7 +4,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
4
4
  import { getDefinedBlocks, onRegisterBlock } from "@juo/blocks";
5
5
  import { a as createEditorBridge, f as createRemoveBlockMessage, g as createRegisterBlocksMessage, h as createRegisterRoutesMessage } from "./bridge-B8cVa2-2.js";
6
6
  import { i, b, j, k, l, m, n, c, o, p, q, r, s, e, t, u, v, w, d, x, y, z, A } from "./bridge-B8cVa2-2.js";
7
- import { f as createBlockInstanceFromObject, m as indexOverrides } from "./theme-state-BpmgtjdC.js";
7
+ import { f as createBlockInstanceFromObject, m as indexOverrides } from "./theme-state-CItCtH5l.js";
8
8
  function createEditorHandler(options) {
9
9
  const { themeState, onBlockSelection } = options;
10
10
  const blockSurfaceIndex = /* @__PURE__ */ new Map();
@@ -299,8 +299,6 @@ const styles = `
299
299
  background-color: white;
300
300
  border: 1px solid #B5B5B5;
301
301
  border-radius: 8px;
302
- justify-self: center;
303
- max-width: 100%;
304
302
  box-sizing: border-box;
305
303
  }
306
304
 
@@ -1,7 +1,7 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { c as createContext, d, E, l as getDefinedBlocks, b as createBlockInstance, w, r as registerBlock, j as defineBlock, t as subscribeContext } from "./theme-state-BpmgtjdC.js";
4
+ import { c as createContext, d, E, l as getDefinedBlocks, b as createBlockInstance, w, r as registerBlock, j as defineBlock, t as subscribeContext } from "./theme-state-CItCtH5l.js";
5
5
  import { a as createEditorBridge, e as createSelectBlockMessage } from "./bridge-B8cVa2-2.js";
6
6
  const TranslationContext = createContext("translation");
7
7
  function toStringRecord(input) {
@@ -566,10 +566,15 @@ function withWrapper(fn) {
566
566
  const registerBlockListeners = [];
567
567
  function registerBlock(block) {
568
568
  blockDefinitions.set(block.name, block);
569
+ stubDefinitionCache.delete(block.name);
569
570
  registerBlockListeners.forEach((cb) => cb(block.name, block));
570
571
  }
571
572
  function onRegisterBlock(cb) {
572
573
  registerBlockListeners.push(cb);
574
+ return () => {
575
+ const idx = registerBlockListeners.indexOf(cb);
576
+ if (idx >= 0) registerBlockListeners.splice(idx, 1);
577
+ };
573
578
  }
574
579
  function defineBlock(name, opts) {
575
580
  const definition = {
@@ -1,6 +1,8 @@
1
- import { Component } from 'vue';
1
+ import { App, Component } from 'vue';
2
2
  import { BlockInstance } from '../main.ts';
3
- export declare function createVueRenderer(component: Component): (block: BlockInstance) => HTMLDivElement;
3
+ export declare function createVueRenderer(component: Component, options?: {
4
+ hostApp?: App;
5
+ }): (block: BlockInstance) => HTMLElement;
4
6
  export declare function createVueCeRenderer(name: string, component: Component, { shadowRoot }?: {
5
7
  shadowRoot?: boolean;
6
8
  }): (block: BlockInstance) => HTMLDivElement;
@@ -1 +1 @@
1
- {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/vue/block.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EAOV,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AAmB9D,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,WAiBrC,aAAa,oBAa7B;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,4CAoCrD"}
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../src/vue/block.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,GAAG,EAGR,SAAS,EAUV,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAoB,MAAM,aAAa,CAAC;AA6B9D,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,SAAS,EACpB,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,GAAG,CAAA;CAAE,WAuCZ,aAAa,iBA0D7B;AAED,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,SAAS,EAAE,SAAS,EACpB,EAAE,UAAiB,EAAE,GAAE;IAAE,UAAU,CAAC,EAAE,OAAO,CAAA;CAAO,4CAoCrD"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=block.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.test.d.ts","sourceRoot":"","sources":["../../src/vue/block.test.ts"],"names":[],"mappings":""}
package/dist/vue.js CHANGED
@@ -1,4 +1,4 @@
1
- import { customRef, toValue, watchEffect, defineComponent, ref, getCurrentInstance, onMounted, provide, h, renderSlot, inject, computed, useHost, defineCustomElement, createApp } from "vue";
1
+ import { customRef, toValue, watchEffect, defineComponent, ref, getCurrentInstance, onMounted, provide, h, renderSlot, inject, computed, useHost, defineCustomElement, triggerRef, render, shallowRef } from "vue";
2
2
  import { effect, signal, injectContext, provideContext, createCeRenderer } from "@juo/blocks";
3
3
  import { c as createRegisterBlockTranslationKeysMessage, a as createEditorBridge } from "./bridge-B8cVa2-2.js";
4
4
  const signalsMap = /* @__PURE__ */ new WeakMap();
@@ -141,35 +141,80 @@ const VueSlotWrapper = defineComponent({
141
141
  return h("div");
142
142
  },
143
143
  mounted() {
144
- const children = (Array.isArray(this.$props.block) ? this.$props.block : [this.$props.block]).map(
145
- (block) => typeof block === "string" ? block : block.definition.render(block)
146
- );
147
- this.$el.replaceChildren(...children);
144
+ this.syncSlotChildren();
145
+ },
146
+ updated() {
147
+ this.syncSlotChildren();
148
+ },
149
+ methods: {
150
+ syncSlotChildren() {
151
+ const children = (Array.isArray(this.$props.block) ? this.$props.block : [this.$props.block]).map(
152
+ (block) => typeof block === "string" ? block : block.definition.render(block)
153
+ );
154
+ this.$el.replaceChildren(...children);
155
+ }
148
156
  }
149
157
  });
150
- function createVueRenderer(component) {
158
+ function createVueRenderer(component, options) {
159
+ const cache = /* @__PURE__ */ new Map();
151
160
  function renderSlots(slots) {
152
161
  if (!slots) {
153
162
  return slots;
154
163
  }
155
- const renderedSlots = Object.fromEntries(
164
+ return Object.fromEntries(
156
165
  Object.entries(slots).map(([key2, value]) => [
157
166
  key2,
158
- // Fix slot rendering
167
+ // Known limitation: if a nested block's props are mutated without changing
168
+ // the slot array reference, VueSlotWrapper won't re-render (updated() won't fire).
169
+ // Not an issue today — all block trees are flat (root → first-level blocks),
170
+ // and first-level blocks are re-rendered directly by ExtensionRoot's effect,
171
+ // bypassing VueSlotWrapper entirely.
159
172
  typeof value === "string" ? value : h(VueSlotWrapper, { block: value })
160
173
  ])
161
174
  );
162
- return renderedSlots;
163
175
  }
164
176
  return (block) => {
165
- const app = createApp(
166
- h(ContextProvider, {}, [
167
- h(component, block.props, renderSlots(block.slots))
168
- ])
177
+ const parentInstance = block.__vueInstance;
178
+ const existing = cache.get(block.id);
179
+ if (existing && existing.parentInstance === parentInstance) {
180
+ existing.propsRef.value = block.props;
181
+ existing.slotsRef.value = block.slots;
182
+ triggerRef(existing.slotsRef);
183
+ return existing.wrapper;
184
+ }
185
+ if (existing) {
186
+ render(null, existing.wrapper);
187
+ }
188
+ const propsRef = shallowRef(block.props);
189
+ const slotsRef = shallowRef(
190
+ block.slots
169
191
  );
170
- const wrapper = document.createElement("div");
171
- wrapper.setAttribute("data-block-id", block.id);
172
- app.mount(wrapper);
192
+ const parentProvides = parentInstance == null ? void 0 : parentInstance.provides;
193
+ const Root = defineComponent({
194
+ setup() {
195
+ if (parentProvides) {
196
+ const instance = getCurrentInstance();
197
+ if (instance) {
198
+ instance.provides = parentProvides;
199
+ }
200
+ }
201
+ return () => h(ContextProvider, {}, [
202
+ h(component, propsRef.value, renderSlots(slotsRef.value))
203
+ ]);
204
+ }
205
+ });
206
+ const wrapper = (existing == null ? void 0 : existing.wrapper) ?? document.createElement("div");
207
+ if (!existing) {
208
+ wrapper.setAttribute("data-block-id", block.id);
209
+ wrapper.setAttribute("data-block-type", block.type);
210
+ wrapper.style.display = "contents";
211
+ }
212
+ const vnode = h(Root);
213
+ if (options == null ? void 0 : options.hostApp) {
214
+ vnode.appContext = options.hostApp._context;
215
+ }
216
+ render(vnode, wrapper);
217
+ cache.set(block.id, { wrapper, propsRef, slotsRef, parentInstance });
173
218
  return wrapper;
174
219
  };
175
220
  }
@@ -3,6 +3,19 @@ export default class ExtensionRoot extends HTMLElement {
3
3
  private themeState;
4
4
  private unsubscribeThemeContext?;
5
5
  private disposeEffect?;
6
+ private __vueInstance;
7
+ /**
8
+ * Names of top-level slot children that resolved to a stub on the last
9
+ * render pass — i.e. blocks whose definition hasn't been registered yet.
10
+ * Rebuilt on each render and consulted from the registration listener so
11
+ * we only retrigger when a block we're actually waiting on lands.
12
+ *
13
+ * Only top-level children are tracked — nested stubs inside a registered
14
+ * parent's renderer aren't currently handled (rare in practice; revisit
15
+ * if it shows up).
16
+ */
17
+ private unresolvedNames;
18
+ private unregisterListener?;
6
19
  /**
7
20
  * Optional function to wrap each rendered block element.
8
21
  * Called with the rendered block HTMLElement, must return an HTMLElement.
@@ -1 +1 @@
1
- {"version":3,"file":"ExtensionRoot.d.ts","sourceRoot":"","sources":["../../src/web-components/ExtensionRoot.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,WAAW;IACpD,OAAO,CAAC,KAAK,CAA8B;IAC3C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,uBAAuB,CAAC,CAAa;IAC7C,OAAO,CAAC,aAAa,CAAC,CAAa;IAEnC;;;;;;OAMG;IACI,YAAY,EAAE,CAAC,CAAC,QAAQ,EAAE,WAAW,KAAK,WAAW,CAAC,GAAG,IAAI,CAAQ;IAE5E,MAAM,KAAK,kBAAk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BAAoB,EAAE,aAAa,CAAC;KACrC;CACF"}
@@ -1,10 +1,10 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { n as injectContext, E, y as ContextRoot } from "./theme-state-BpmgtjdC.js";
5
- import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-8ntJL9wz.js";
4
+ import { n as injectContext, E, y as ContextRoot } from "./theme-state-CItCtH5l.js";
5
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-CQa6unFH.js";
6
6
  import { a as createEditorBridge, b as createFocusInlineTextMessage, d as createUpdateBlockTranslationMessage } from "./bridge-B8cVa2-2.js";
7
- import { T as TranslationContext } from "./juo-workflow-BXGQS82N.js";
7
+ import { T as TranslationContext } from "./juo-workflow-1EMEURtn.js";
8
8
  const _InlineText = class _InlineText extends HTMLElement {
9
9
  constructor() {
10
10
  super();
@@ -1,9 +1,9 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
- import { n as injectContext, E, y as ContextRoot } from "./theme-state-BpmgtjdC.js";
5
- import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-8ntJL9wz.js";
6
- import { T as TranslationContext } from "./juo-workflow-BXGQS82N.js";
4
+ import { n as injectContext, E, y as ContextRoot } from "./theme-state-CItCtH5l.js";
5
+ import { E as ExtensionRoot, B as Block } from "./ExtensionRoot-CQa6unFH.js";
6
+ import { T as TranslationContext } from "./juo-workflow-1EMEURtn.js";
7
7
  class InlineText extends HTMLElement {
8
8
  constructor() {
9
9
  super(...arguments);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@juo/blocks",
3
3
  "private": false,
4
- "version": "1.4.2",
4
+ "version": "1.4.4",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"