@bagelink/blox 1.10.42 → 1.11.3

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,5 +1,6 @@
1
1
  import { App } from 'vue';
2
2
  import { Router } from 'vue-router';
3
+ import { BlockModule } from './defineBlock';
3
4
  import { StrategyOptions } from './localeStrategy';
4
5
  import { BlockComponent, BlockDefinition } from './schema';
5
6
  /** Either a full `{ component, schema }` definition or a self-defining component (used `defineBlock()`). */
@@ -7,6 +8,19 @@ export type BloxComponent = BlockDefinition | BlockComponent;
7
8
  export interface BloxOptions extends StrategyOptions {
8
9
  /** Block components or definitions to register. Self-defining components (those that called `defineBlock()`) are auto-discovered. */
9
10
  components?: Record<string, BloxComponent>;
11
+ /**
12
+ * SFC modules with `export const <name> = defineBlock(...)`.
13
+ * Accepts an array of modules or a barrel `import * as` object.
14
+ * @example
15
+ * // barrel (recommended)
16
+ * import * as bloxComps from './blox'
17
+ * createBlox({ modules: bloxComps })
18
+ *
19
+ * // array
20
+ * import * as Vmware from './Vmware.vue'
21
+ * createBlox({ modules: [Vmware] })
22
+ */
23
+ modules?: BlockModule[] | Record<string, BlockModule>;
10
24
  /** Vue Router instance — adds the CMS catch-all and preview routes. */
11
25
  router?: Router;
12
26
  /** CMS website name (must match the `name` field on the Website record). */
@@ -20,6 +34,7 @@ export declare class BloxInstance {
20
34
  private _config;
21
35
  private _strategy;
22
36
  constructor(options?: BloxOptions);
37
+ registerModules(modules: BlockModule[] | Record<string, BlockModule>): this;
23
38
  registerComponents(components: Record<string, BloxComponent>): this;
24
39
  registerRoutes(router: Router): this;
25
40
  install(app: App, options?: BloxOptions): void;
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAa,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,MAAM,EAAE,MAA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AAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAS/D,4GAA4G;AAC5G,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,cAAc,CAAA;AAE5D,MAAM,WAAW,WAAY,SAAQ,eAAe;IACnD,qIAAqI;IACrI,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;IAC1C;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACrD,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,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,eAAe,CAAC,OAAO,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI;IAyB3E,kBAAkB,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,GAAG,IAAI;IAsBnE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAyBpC,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,IAAI;CAgC9C;AAMD,wBAAgB,UAAU,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,YAAY,CAS9D"}
@@ -1,27 +1,44 @@
1
1
  import { SchemaDefinition } from '../../vue/src/index.ts';
2
2
  export interface BlockMeta {
3
- /** Block type key — must be unique across the app. */
3
+ /** Block type key — must be unique across the app. Used as the export name by the Vite plugin. */
4
4
  name: string;
5
5
  /** Human-readable label shown in the editor block picker. */
6
6
  label: string;
7
7
  /** Material icon name. */
8
8
  icon?: string;
9
- /** FormFlow schema for editable props. */
10
- schema: SchemaDefinition;
9
+ /** FormFlow schema for editable props. Omit for blocks with no configurable props. */
10
+ schema?: SchemaDefinition;
11
11
  description?: string;
12
12
  }
13
+ /** A Vue SFC module that has `export const <name> = defineBlock(...)` in its `<script setup>`. */
14
+ export interface BlockModule {
15
+ default: object;
16
+ [key: string]: object | BlockMeta;
17
+ }
13
18
  /**
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.
19
+ * Declare this component as a blox block.
20
+ * Export the result as a named `blox` const from `<script setup>`:
18
21
  *
19
22
  * @example
23
+ * ```vue
24
+ * <script setup lang="ts">
25
+ * import { defineBlock } from '@bagelink/blox'
26
+ * import { defineSchema, $ } from '@bagelink/vue'
27
+ *
28
+ * const schema = defineSchema({ title: $.text('Title') })
29
+ *
30
+ * defineBlock({ name: 'myBlock', label: 'My Block', icon: 'star', schema })
31
+ *
32
+ * defineProps<{ title: string }>()
33
+ * </script>
34
+ * ```
35
+ *
36
+ * Then register via modules:
20
37
  * ```ts
21
- * const schema = defineSchema<MyProps>({ ... })
22
- * defineProps<MyProps>()
23
- * defineBlock({ name: 'my-block', label: 'My Block', icon: 'star', schema })
38
+ * import * as Vmware from './Vmware.vue'
39
+ * import * as Hero from './Hero.vue'
40
+ * createBlox({ modules: [Vmware, Hero] })
24
41
  * ```
25
42
  */
26
- export declare function defineBlock(meta: BlockMeta): void;
43
+ export declare function defineBlock(meta: BlockMeta): BlockMeta;
27
44
  //# sourceMappingURL=defineBlock.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"defineBlock.d.ts","sourceRoot":"","sources":["../src/defineBlock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAErD,MAAM,WAAW,SAAS;IACzB,kGAAkG;IAClG,IAAI,EAAE,MAAM,CAAA;IACZ,6DAA6D;IAC7D,KAAK,EAAE,MAAM,CAAA;IACb,0BAA0B;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,sFAAsF;IACtF,MAAM,CAAC,EAAE,gBAAgB,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,kGAAkG;AAClG,MAAM,WAAW,WAAW;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;CACjC;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,SAAS,CAEtD"}
package/dist/index.cjs CHANGED
@@ -303,11 +303,35 @@ class BloxInstance {
303
303
  };
304
304
  this._strategy = createLocaleStrategy(options ?? {});
305
305
  }
306
+ registerModules(modules) {
307
+ const list = Array.isArray(modules) ? modules : Object.values(modules);
308
+ for (const mod of list) {
309
+ if (!(mod == null ? void 0 : mod.default)) continue;
310
+ for (const [key, value] of Object.entries(mod)) {
311
+ if (key === "default") continue;
312
+ if (value && typeof value === "object" && "label" in value) {
313
+ const meta = value;
314
+ this._registry[meta.name ?? key] = {
315
+ component: mod.default,
316
+ schema: {
317
+ label: meta.label,
318
+ description: meta.description,
319
+ icon: meta.icon,
320
+ fields: meta.schema
321
+ }
322
+ };
323
+ break;
324
+ }
325
+ }
326
+ }
327
+ return this;
328
+ }
306
329
  registerComponents(components) {
307
330
  for (const [key, value] of Object.entries(components)) {
331
+ if (!value || typeof value !== "object" && typeof value !== "function") continue;
308
332
  if (isBlockDefinition(value)) {
309
333
  this._registry[key] = value;
310
- } else {
334
+ } else if (value.__blox) {
311
335
  const meta = value.__blox;
312
336
  this._registry[meta.name ?? key] = {
313
337
  component: value,
@@ -355,6 +379,7 @@ class BloxInstance {
355
379
  supportedLocales: this._config.supportedLocales
356
380
  });
357
381
  }
382
+ if (options == null ? void 0 : options.modules) this.registerModules(options.modules);
358
383
  if (options == null ? void 0 : options.components) this.registerComponents(options.components);
359
384
  if (options == null ? void 0 : options.router) this.registerRoutes(options.router);
360
385
  if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
@@ -378,20 +403,13 @@ function createBlox(options) {
378
403
  if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
379
404
  configureApi(options.websiteName ?? "", options.store ?? "");
380
405
  }
406
+ if (options == null ? void 0 : options.modules) instance.registerModules(options.modules);
381
407
  if (options == null ? void 0 : options.components) instance.registerComponents(options.components);
382
408
  if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
383
409
  return instance;
384
410
  }
385
411
  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
- }
412
+ return meta;
395
413
  }
396
414
  const PreviewRenderer = vue.defineComponent({
397
415
  name: "PreviewRenderer",
package/dist/index.d.ts CHANGED
@@ -11,7 +11,7 @@ export { usePageContext } from './composables/usePageContext';
11
11
  export { BloxInstance, createBlox } from './core';
12
12
  export type { BloxComponent, BloxOptions } from './core';
13
13
  export { defineBlock } from './defineBlock';
14
- export type { BlockMeta } from './defineBlock';
14
+ export type { BlockMeta, BlockModule } from './defineBlock';
15
15
  export type { LocaleStrategy } from './localeStrategy';
16
16
  export { default as PageRenderer } from './PageRenderer';
17
17
  export { default as PreviewApp } from './PreviewApp.vue';
@@ -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,EACX,cAAc,EACd,QAAQ,EACR,eAAe,EACf,cAAc,EACd,WAAW,GACX,MAAM,aAAa,CAAA;AAIpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AACtD,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAI9E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAK1D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,YAAY,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAK7D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAKxD,OAAO,EAAE,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,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAA;AAK7D,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACjD,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAA;AAKxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3D,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,kBAAkB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAK9D,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAI5E,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAA;AAErE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA"}
package/dist/index.mjs CHANGED
@@ -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 { 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";
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";
5
5
  import { useRoute, useRouter, RouterLink } from "vue-router";
6
6
  import { getI18n } from "@bagelink/vue";
7
7
  const BASE = "/api";
@@ -301,11 +301,35 @@ class BloxInstance {
301
301
  };
302
302
  this._strategy = createLocaleStrategy(options ?? {});
303
303
  }
304
+ registerModules(modules) {
305
+ const list = Array.isArray(modules) ? modules : Object.values(modules);
306
+ for (const mod of list) {
307
+ if (!(mod == null ? void 0 : mod.default)) continue;
308
+ for (const [key, value] of Object.entries(mod)) {
309
+ if (key === "default") continue;
310
+ if (value && typeof value === "object" && "label" in value) {
311
+ const meta = value;
312
+ this._registry[meta.name ?? key] = {
313
+ component: mod.default,
314
+ schema: {
315
+ label: meta.label,
316
+ description: meta.description,
317
+ icon: meta.icon,
318
+ fields: meta.schema
319
+ }
320
+ };
321
+ break;
322
+ }
323
+ }
324
+ }
325
+ return this;
326
+ }
304
327
  registerComponents(components) {
305
328
  for (const [key, value] of Object.entries(components)) {
329
+ if (!value || typeof value !== "object" && typeof value !== "function") continue;
306
330
  if (isBlockDefinition(value)) {
307
331
  this._registry[key] = value;
308
- } else {
332
+ } else if (value.__blox) {
309
333
  const meta = value.__blox;
310
334
  this._registry[meta.name ?? key] = {
311
335
  component: value,
@@ -353,6 +377,7 @@ class BloxInstance {
353
377
  supportedLocales: this._config.supportedLocales
354
378
  });
355
379
  }
380
+ if (options == null ? void 0 : options.modules) this.registerModules(options.modules);
356
381
  if (options == null ? void 0 : options.components) this.registerComponents(options.components);
357
382
  if (options == null ? void 0 : options.router) this.registerRoutes(options.router);
358
383
  if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
@@ -376,20 +401,13 @@ function createBlox(options) {
376
401
  if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
377
402
  configureApi(options.websiteName ?? "", options.store ?? "");
378
403
  }
404
+ if (options == null ? void 0 : options.modules) instance.registerModules(options.modules);
379
405
  if (options == null ? void 0 : options.components) instance.registerComponents(options.components);
380
406
  if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
381
407
  return instance;
382
408
  }
383
409
  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
- }
410
+ return meta;
393
411
  }
394
412
  const PreviewRenderer = defineComponent({
395
413
  name: "PreviewRenderer",
package/dist/schema.d.ts CHANGED
@@ -9,9 +9,9 @@ export interface BlockSchema {
9
9
  icon?: string;
10
10
  /**
11
11
  * FormFlow schema for the block's editable props.
12
- * An empty schema means no configurable props (content comes from context/datastore).
12
+ * Omit for blocks with no configurable props (content comes from context/datastore).
13
13
  */
14
- fields: SchemaDefinition;
14
+ fields?: SchemaDefinition;
15
15
  }
16
16
  export interface BlockDefinition {
17
17
  component: Component;
@@ -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;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"}
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,CAAC,EAAE,gBAAgB,CAAA;CACzB;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"}