@dp-bohrium/widget-cli 0.0.0-stage → 0.1.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.
package/dist/core.mjs ADDED
@@ -0,0 +1,39 @@
1
+ import { a as resolveWidgetProjects, i as checkWidgetProject, n as scaffoldDshWidget, o as compileAuthorManifest, r as buildWidgetPackage, t as auditDshPlugin } from "./dsh-DgkNH7L-.mjs";
2
+ //#region src/core.mjs
3
+ /** Validate a community template before registering it in a custom CLI. */
4
+ function defineWidgetTemplate(template) {
5
+ if (!template || typeof template !== "object") throw new TypeError("Widget template must be an object");
6
+ if (typeof template.id !== "string" || template.id.length === 0) throw new TypeError("Widget template id must be a non-empty string");
7
+ if (typeof template.manifest !== "function") throw new TypeError("Widget template must provide manifest(context)");
8
+ if (typeof template.sample !== "function") throw new TypeError("Widget template must provide sample(context)");
9
+ if (typeof template.source !== "string" && typeof template.source !== "function") throw new TypeError("Widget template must provide source or source(context)");
10
+ return Object.freeze({ ...template });
11
+ }
12
+ function createWidgetTemplateRegistry(initialTemplates = []) {
13
+ const templates = /* @__PURE__ */ new Map();
14
+ function register(template) {
15
+ const normalized = defineWidgetTemplate(template);
16
+ if (templates.has(normalized.id)) throw new Error(`Widget template already registered: ${normalized.id}`);
17
+ templates.set(normalized.id, normalized);
18
+ return normalized;
19
+ }
20
+ for (const template of initialTemplates) register(template);
21
+ return Object.freeze({
22
+ register,
23
+ get: (id) => templates.get(id),
24
+ list: () => [...templates.values()]
25
+ });
26
+ }
27
+ /** Stable building blocks for community CLIs and task runners. */
28
+ const widgetCliCore = Object.freeze({
29
+ buildWidgetPackage,
30
+ checkWidgetProject,
31
+ compileAuthorManifest,
32
+ resolveWidgetProjects,
33
+ createWidgetTemplateRegistry,
34
+ defineWidgetTemplate,
35
+ auditDshPlugin,
36
+ scaffoldDshWidget
37
+ });
38
+ //#endregion
39
+ export { auditDshPlugin, buildWidgetPackage, checkWidgetProject, compileAuthorManifest, createWidgetTemplateRegistry, defineWidgetTemplate, resolveWidgetProjects, scaffoldDshWidget, widgetCliCore };