@bagelink/blox 1.10.40 → 1.10.42

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.
package/dist/core.d.ts CHANGED
@@ -1,10 +1,12 @@
1
1
  import { App } from 'vue';
2
2
  import { Router } from 'vue-router';
3
3
  import { StrategyOptions } from './localeStrategy';
4
- import { BlockDefinition } from './schema';
4
+ import { BlockComponent, BlockDefinition } from './schema';
5
+ /** Either a full `{ component, schema }` definition or a self-defining component (used `defineBlock()`). */
6
+ export type BloxComponent = BlockDefinition | BlockComponent;
5
7
  export interface BloxOptions extends StrategyOptions {
6
- /** Block definitions to register, keyed by block type. */
7
- components?: Record<string, BlockDefinition>;
8
+ /** Block components or definitions to register. Self-defining components (those that called `defineBlock()`) are auto-discovered. */
9
+ components?: Record<string, BloxComponent>;
8
10
  /** Vue Router instance — adds the CMS catch-all and preview routes. */
9
11
  router?: Router;
10
12
  /** CMS website name (must match the `name` field on the Website record). */
@@ -18,7 +20,7 @@ export declare class BloxInstance {
18
20
  private _config;
19
21
  private _strategy;
20
22
  constructor(options?: BloxOptions);
21
- registerComponents(components: Record<string, BlockDefinition>): this;
23
+ registerComponents(components: Record<string, BloxComponent>): this;
22
24
  registerRoutes(router: Router): this;
23
25
  install(app: App, options?: BloxOptions): void;
24
26
  }
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAkB,eAAe,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAS/C,MAAM,WAAW,WAAY,SAAQ,eAAe;IACnD,0DAA0D;IAC1D,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,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AM,CAAA;IACpB,kCAAkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAA;CACd;AAED,qBAAa,YAAY;IACxB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAsC;IAChE,OAAO,CAAC,gBAAgB,CAAQ;IAChC,OAAO,CAAC,OAAO,CAAY;IAC3B,OAAO,CAAC,SAAS,CAAgB;gBAErB,OAAO,CAAC,EAAE,WAAW;IAQjC,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI;IAqBnE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAyBpC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;CA+B9C;AAMD,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,CAQ9D"}
@@ -0,0 +1,27 @@
1
+ import { SchemaDefinition } from '../../vue/src/index.ts';
2
+ export interface BlockMeta {
3
+ /** Block type key — must be unique across the app. */
4
+ name: string;
5
+ /** Human-readable label shown in the editor block picker. */
6
+ label: string;
7
+ /** Material icon name. */
8
+ icon?: string;
9
+ /** FormFlow schema for editable props. */
10
+ schema: SchemaDefinition;
11
+ description?: string;
12
+ }
13
+ /**
14
+ * Declare the current component as a blox block.
15
+ * Call this inside `<script setup>` — it stamps the component definition
16
+ * so that `createBlox({ components })` can auto-discover it without
17
+ * needing a manual `{ component, schema }` wrapper.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * const schema = defineSchema<MyProps>({ ... })
22
+ * defineProps<MyProps>()
23
+ * defineBlock({ name: 'my-block', label: 'My Block', icon: 'star', schema })
24
+ * ```
25
+ */
26
+ export declare function defineBlock(meta: BlockMeta): void;
27
+ //# sourceMappingURL=defineBlock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defineBlock.d.ts","sourceRoot":"","sources":["../src/defineBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAGrD,MAAM,WAAW,SAAS;IACzB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,0CAA0C;IAC1C,MAAM,EAAE,gBAAgB,CAAA;IACxB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,IAAI,CAYjD"}
package/dist/index.cjs CHANGED
@@ -304,7 +304,22 @@ class BloxInstance {
304
304
  this._strategy = createLocaleStrategy(options ?? {});
305
305
  }
306
306
  registerComponents(components) {
307
- Object.assign(this._registry, components);
307
+ for (const [key, value] of Object.entries(components)) {
308
+ if (isBlockDefinition(value)) {
309
+ this._registry[key] = value;
310
+ } else {
311
+ const meta = value.__blox;
312
+ this._registry[meta.name ?? key] = {
313
+ component: value,
314
+ schema: {
315
+ label: meta.label,
316
+ description: meta.description,
317
+ icon: meta.icon,
318
+ fields: meta.schema
319
+ }
320
+ };
321
+ }
322
+ }
308
323
  return this;
309
324
  }
310
325
  registerRoutes(router) {
@@ -355,6 +370,9 @@ class BloxInstance {
355
370
  app.component("RouterLink", _sfc_main$1);
356
371
  }
357
372
  }
373
+ function isBlockDefinition(value) {
374
+ return typeof value === "object" && "component" in value && "schema" in value;
375
+ }
358
376
  function createBlox(options) {
359
377
  const instance = new BloxInstance(options);
360
378
  if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
@@ -364,6 +382,17 @@ function createBlox(options) {
364
382
  if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
365
383
  return instance;
366
384
  }
385
+ function defineBlock(meta) {
386
+ const instance = vue.getCurrentInstance();
387
+ if (!instance) {
388
+ console.warn("[defineBlock] Must be called inside <script setup>");
389
+ return;
390
+ }
391
+ const type = instance.type;
392
+ if (!type.__blox) {
393
+ type.__blox = meta;
394
+ }
395
+ }
367
396
  const PreviewRenderer = vue.defineComponent({
368
397
  name: "PreviewRenderer",
369
398
  props: {
@@ -515,6 +544,7 @@ exports.PreviewApp = _sfc_main;
515
544
  exports.PreviewRenderer = PreviewRenderer;
516
545
  exports.configureApi = configureApi;
517
546
  exports.createBlox = createBlox;
547
+ exports.defineBlock = defineBlock;
518
548
  exports.listItems = listItems;
519
549
  exports.resolvePath = resolvePath;
520
550
  exports.sendToEditor = sendToEditor;
package/dist/index.d.ts CHANGED
@@ -9,12 +9,14 @@ export type { Locale } from './composables/useLocale';
9
9
  export { useLocaleNav } from './composables/useLocaleNav';
10
10
  export { usePageContext } from './composables/usePageContext';
11
11
  export { BloxInstance, createBlox } from './core';
12
- export type { BloxOptions } from './core';
12
+ export type { BloxComponent, BloxOptions } from './core';
13
+ export { defineBlock } from './defineBlock';
14
+ export type { BlockMeta } from './defineBlock';
13
15
  export type { LocaleStrategy } from './localeStrategy';
14
16
  export { default as PageRenderer } from './PageRenderer';
15
17
  export { default as PreviewApp } from './PreviewApp.vue';
16
18
  export { default as PreviewRenderer } from './PreviewRenderer';
17
- export type { BlockDefinition, BlockSchema } from './schema';
19
+ export type { BlockComponent, BlockDefinition, BlockSchema } from './schema';
18
20
  export { BLOX_CONFIG_KEY, BLOX_LOCALE_STRATEGY_KEY } from './symbols';
19
21
  export type { BloxConfig } from './symbols';
20
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAClE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAKnD,YAAY,EACX,cAAc,EACd,KAAK,EAEL,kBAAkB,EAClB,cAAc,EACd,mBAAmB,EACnB,aAAa,EACb,WAAW,EAC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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 { computed, ref, defineComponent, inject, h, provide, watch, resolveComponent, createElementBlock, openBlock, createBlock, createElementVNode, createVNode, toDisplayString, unref, withCtx, createTextVNode, normalizeProps, guardReactiveProps, renderSlot, onMounted, onUnmounted, nextTick } from "vue";
4
+ import { computed, ref, defineComponent, inject, h, provide, watch, resolveComponent, createElementBlock, openBlock, createBlock, createElementVNode, createVNode, toDisplayString, unref, withCtx, createTextVNode, normalizeProps, guardReactiveProps, renderSlot, getCurrentInstance, onMounted, onUnmounted, nextTick } from "vue";
5
5
  import { useRoute, useRouter, RouterLink } from "vue-router";
6
6
  import { getI18n } from "@bagelink/vue";
7
7
  const BASE = "/api";
@@ -302,7 +302,22 @@ class BloxInstance {
302
302
  this._strategy = createLocaleStrategy(options ?? {});
303
303
  }
304
304
  registerComponents(components) {
305
- Object.assign(this._registry, components);
305
+ for (const [key, value] of Object.entries(components)) {
306
+ if (isBlockDefinition(value)) {
307
+ this._registry[key] = value;
308
+ } else {
309
+ const meta = value.__blox;
310
+ this._registry[meta.name ?? key] = {
311
+ component: value,
312
+ schema: {
313
+ label: meta.label,
314
+ description: meta.description,
315
+ icon: meta.icon,
316
+ fields: meta.schema
317
+ }
318
+ };
319
+ }
320
+ }
306
321
  return this;
307
322
  }
308
323
  registerRoutes(router) {
@@ -353,6 +368,9 @@ class BloxInstance {
353
368
  app.component("RouterLink", _sfc_main$1);
354
369
  }
355
370
  }
371
+ function isBlockDefinition(value) {
372
+ return typeof value === "object" && "component" in value && "schema" in value;
373
+ }
356
374
  function createBlox(options) {
357
375
  const instance = new BloxInstance(options);
358
376
  if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
@@ -362,6 +380,17 @@ function createBlox(options) {
362
380
  if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
363
381
  return instance;
364
382
  }
383
+ function defineBlock(meta) {
384
+ const instance = getCurrentInstance();
385
+ if (!instance) {
386
+ console.warn("[defineBlock] Must be called inside <script setup>");
387
+ return;
388
+ }
389
+ const type = instance.type;
390
+ if (!type.__blox) {
391
+ type.__blox = meta;
392
+ }
393
+ }
365
394
  const PreviewRenderer = defineComponent({
366
395
  name: "PreviewRenderer",
367
396
  props: {
@@ -514,6 +543,7 @@ export {
514
543
  PreviewRenderer,
515
544
  configureApi,
516
545
  createBlox,
546
+ defineBlock,
517
547
  listItems,
518
548
  resolvePath,
519
549
  sendToEditor,
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { SchemaDefinition } from '../../vue/src/index.ts';
2
2
  import { Component } from 'vue';
3
+ import { BlockMeta } from './defineBlock';
3
4
  export interface BlockSchema {
4
5
  /** Human-readable name shown in the editor. */
5
6
  label: string;
@@ -16,4 +17,8 @@ export interface BlockDefinition {
16
17
  component: Component;
17
18
  schema: BlockSchema;
18
19
  }
20
+ /** A Vue component that has called `defineBlock()` in its `<script setup>`. */
21
+ export type BlockComponent = Component & {
22
+ __blox: BlockMeta;
23
+ };
19
24
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AAEpC,MAAM,WAAW,WAAW;IAC3B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,MAAM,EAAE,gBAAgB,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,WAAW,CAAA;CACnB"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,KAAK,CAAA;AACpC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAE9C,MAAM,WAAW,WAAW;IAC3B,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,sDAAsD;IACtD,IAAI,CAAC,EAAE,MAAM,CAAA;IACb;;;OAGG;IACH,MAAM,EAAE,gBAAgB,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC/B,SAAS,EAAE,SAAS,CAAA;IACpB,MAAM,EAAE,WAAW,CAAA;CACnB;AAED,+EAA+E;AAC/E,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@bagelink/blox",
3
3
  "type": "module",
4
- "version": "1.10.40",
4
+ "version": "1.10.42",
5
5
  "description": "Blox page builder library for drag-and-drop page building and static data management",
6
6
  "author": {
7
7
  "name": "Bagel Studio",