@bagelink/blox 1.10.40 → 1.11.1
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 +21 -4
- package/dist/core.d.ts.map +1 -1
- package/dist/defineBlock.d.ts +44 -0
- package/dist/defineBlock.d.ts.map +1 -0
- package/dist/index.cjs +49 -1
- package/dist/index.d.ts +4 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +49 -1
- package/dist/schema.d.ts +7 -2
- package/dist/schema.d.ts.map +1 -1
- package/dist/vite-plugin.cjs +1133 -0
- package/dist/vite-plugin.d.ts +26 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.mjs +1133 -0
- package/package.json +13 -2
package/dist/core.d.ts
CHANGED
|
@@ -1,10 +1,26 @@
|
|
|
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
|
-
import { BlockDefinition } from './schema';
|
|
5
|
+
import { BlockComponent, BlockDefinition } from './schema';
|
|
6
|
+
/** Either a full `{ component, schema }` definition or a self-defining component (used `defineBlock()`). */
|
|
7
|
+
export type BloxComponent = BlockDefinition | BlockComponent;
|
|
5
8
|
export interface BloxOptions extends StrategyOptions {
|
|
6
|
-
/** Block definitions to register
|
|
7
|
-
components?: Record<string,
|
|
9
|
+
/** Block components or definitions to register. Self-defining components (those that called `defineBlock()`) are auto-discovered. */
|
|
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>;
|
|
8
24
|
/** Vue Router instance — adds the CMS catch-all and preview routes. */
|
|
9
25
|
router?: Router;
|
|
10
26
|
/** CMS website name (must match the `name` field on the Website record). */
|
|
@@ -18,7 +34,8 @@ export declare class BloxInstance {
|
|
|
18
34
|
private _config;
|
|
19
35
|
private _strategy;
|
|
20
36
|
constructor(options?: BloxOptions);
|
|
21
|
-
|
|
37
|
+
registerModules(modules: BlockModule[] | Record<string, BlockModule>): this;
|
|
38
|
+
registerComponents(components: Record<string, BloxComponent>): this;
|
|
22
39
|
registerRoutes(router: Router): this;
|
|
23
40
|
install(app: App, options?: BloxOptions): void;
|
|
24
41
|
}
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,
|
|
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,MAAM,YAAY,CAAA;AACxC,OAAO,KAAK,EAAa,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3D,OAAO,KAAK,EAAkB,eAAe,EAAE,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"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { SchemaDefinition } from '../../vue/src/index.ts';
|
|
2
|
+
export interface BlockMeta {
|
|
3
|
+
/** Block type key — must be unique across the app. Used as the export name by the Vite plugin. */
|
|
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. Omit for blocks with no configurable props. */
|
|
10
|
+
schema?: SchemaDefinition;
|
|
11
|
+
description?: string;
|
|
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
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Declare this component as a blox block.
|
|
20
|
+
* Export the result as a named `blox` const from `<script setup>`:
|
|
21
|
+
*
|
|
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:
|
|
37
|
+
* ```ts
|
|
38
|
+
* import * as Vmware from './Vmware.vue'
|
|
39
|
+
* import * as Hero from './Hero.vue'
|
|
40
|
+
* createBlox({ modules: [Vmware, Hero] })
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function defineBlock(meta: BlockMeta): BlockMeta;
|
|
44
|
+
//# 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;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,8 +303,47 @@ 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
|
-
Object.
|
|
330
|
+
for (const [key, value] of Object.entries(components)) {
|
|
331
|
+
if (!value || typeof value !== "object" && typeof value !== "function") continue;
|
|
332
|
+
if (isBlockDefinition(value)) {
|
|
333
|
+
this._registry[key] = value;
|
|
334
|
+
} else if (value.__blox) {
|
|
335
|
+
const meta = value.__blox;
|
|
336
|
+
this._registry[meta.name ?? key] = {
|
|
337
|
+
component: value,
|
|
338
|
+
schema: {
|
|
339
|
+
label: meta.label,
|
|
340
|
+
description: meta.description,
|
|
341
|
+
icon: meta.icon,
|
|
342
|
+
fields: meta.schema
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
}
|
|
308
347
|
return this;
|
|
309
348
|
}
|
|
310
349
|
registerRoutes(router) {
|
|
@@ -340,6 +379,7 @@ class BloxInstance {
|
|
|
340
379
|
supportedLocales: this._config.supportedLocales
|
|
341
380
|
});
|
|
342
381
|
}
|
|
382
|
+
if (options == null ? void 0 : options.modules) this.registerModules(options.modules);
|
|
343
383
|
if (options == null ? void 0 : options.components) this.registerComponents(options.components);
|
|
344
384
|
if (options == null ? void 0 : options.router) this.registerRoutes(options.router);
|
|
345
385
|
if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
|
|
@@ -355,15 +395,22 @@ class BloxInstance {
|
|
|
355
395
|
app.component("RouterLink", _sfc_main$1);
|
|
356
396
|
}
|
|
357
397
|
}
|
|
398
|
+
function isBlockDefinition(value) {
|
|
399
|
+
return typeof value === "object" && "component" in value && "schema" in value;
|
|
400
|
+
}
|
|
358
401
|
function createBlox(options) {
|
|
359
402
|
const instance = new BloxInstance(options);
|
|
360
403
|
if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
|
|
361
404
|
configureApi(options.websiteName ?? "", options.store ?? "");
|
|
362
405
|
}
|
|
406
|
+
if (options == null ? void 0 : options.modules) instance.registerModules(options.modules);
|
|
363
407
|
if (options == null ? void 0 : options.components) instance.registerComponents(options.components);
|
|
364
408
|
if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
|
|
365
409
|
return instance;
|
|
366
410
|
}
|
|
411
|
+
function defineBlock(meta) {
|
|
412
|
+
return meta;
|
|
413
|
+
}
|
|
367
414
|
const PreviewRenderer = vue.defineComponent({
|
|
368
415
|
name: "PreviewRenderer",
|
|
369
416
|
props: {
|
|
@@ -515,6 +562,7 @@ exports.PreviewApp = _sfc_main;
|
|
|
515
562
|
exports.PreviewRenderer = PreviewRenderer;
|
|
516
563
|
exports.configureApi = configureApi;
|
|
517
564
|
exports.createBlox = createBlox;
|
|
565
|
+
exports.defineBlock = defineBlock;
|
|
518
566
|
exports.listItems = listItems;
|
|
519
567
|
exports.resolvePath = resolvePath;
|
|
520
568
|
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, BlockModule } 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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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,WAAW,EAAE,MAAM,QAAQ,CAAA;
|
|
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,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
|
@@ -301,8 +301,47 @@ 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
|
-
Object.
|
|
328
|
+
for (const [key, value] of Object.entries(components)) {
|
|
329
|
+
if (!value || typeof value !== "object" && typeof value !== "function") continue;
|
|
330
|
+
if (isBlockDefinition(value)) {
|
|
331
|
+
this._registry[key] = value;
|
|
332
|
+
} else if (value.__blox) {
|
|
333
|
+
const meta = value.__blox;
|
|
334
|
+
this._registry[meta.name ?? key] = {
|
|
335
|
+
component: value,
|
|
336
|
+
schema: {
|
|
337
|
+
label: meta.label,
|
|
338
|
+
description: meta.description,
|
|
339
|
+
icon: meta.icon,
|
|
340
|
+
fields: meta.schema
|
|
341
|
+
}
|
|
342
|
+
};
|
|
343
|
+
}
|
|
344
|
+
}
|
|
306
345
|
return this;
|
|
307
346
|
}
|
|
308
347
|
registerRoutes(router) {
|
|
@@ -338,6 +377,7 @@ class BloxInstance {
|
|
|
338
377
|
supportedLocales: this._config.supportedLocales
|
|
339
378
|
});
|
|
340
379
|
}
|
|
380
|
+
if (options == null ? void 0 : options.modules) this.registerModules(options.modules);
|
|
341
381
|
if (options == null ? void 0 : options.components) this.registerComponents(options.components);
|
|
342
382
|
if (options == null ? void 0 : options.router) this.registerRoutes(options.router);
|
|
343
383
|
if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
|
|
@@ -353,15 +393,22 @@ class BloxInstance {
|
|
|
353
393
|
app.component("RouterLink", _sfc_main$1);
|
|
354
394
|
}
|
|
355
395
|
}
|
|
396
|
+
function isBlockDefinition(value) {
|
|
397
|
+
return typeof value === "object" && "component" in value && "schema" in value;
|
|
398
|
+
}
|
|
356
399
|
function createBlox(options) {
|
|
357
400
|
const instance = new BloxInstance(options);
|
|
358
401
|
if ((options == null ? void 0 : options.websiteName) || (options == null ? void 0 : options.store)) {
|
|
359
402
|
configureApi(options.websiteName ?? "", options.store ?? "");
|
|
360
403
|
}
|
|
404
|
+
if (options == null ? void 0 : options.modules) instance.registerModules(options.modules);
|
|
361
405
|
if (options == null ? void 0 : options.components) instance.registerComponents(options.components);
|
|
362
406
|
if (options == null ? void 0 : options.router) instance.registerRoutes(options.router);
|
|
363
407
|
return instance;
|
|
364
408
|
}
|
|
409
|
+
function defineBlock(meta) {
|
|
410
|
+
return meta;
|
|
411
|
+
}
|
|
365
412
|
const PreviewRenderer = defineComponent({
|
|
366
413
|
name: "PreviewRenderer",
|
|
367
414
|
props: {
|
|
@@ -514,6 +561,7 @@ export {
|
|
|
514
561
|
PreviewRenderer,
|
|
515
562
|
configureApi,
|
|
516
563
|
createBlox,
|
|
564
|
+
defineBlock,
|
|
517
565
|
listItems,
|
|
518
566
|
resolvePath,
|
|
519
567
|
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;
|
|
@@ -8,12 +9,16 @@ export interface BlockSchema {
|
|
|
8
9
|
icon?: string;
|
|
9
10
|
/**
|
|
10
11
|
* FormFlow schema for the block's editable props.
|
|
11
|
-
*
|
|
12
|
+
* Omit for blocks with no configurable props (content comes from context/datastore).
|
|
12
13
|
*/
|
|
13
|
-
fields
|
|
14
|
+
fields?: SchemaDefinition;
|
|
14
15
|
}
|
|
15
16
|
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
|
package/dist/schema.d.ts.map
CHANGED
|
@@ -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;
|
|
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"}
|