@mndw/cli 0.2.0 → 0.3.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.
Files changed (35) hide show
  1. package/dist/meta.json +45 -21
  2. package/dist/mndw.js +72 -23
  3. package/host-dev/assets/index-D5JwgvHN.js +94 -0
  4. package/host-dev/assets/index-DN-pqOy8.css +1 -0
  5. package/host-dev/assets/{sandbox-url-D8HO7UBF.js → sandbox-url-Cn4lLhV3.js} +1 -1
  6. package/host-dev/index.html +3 -3
  7. package/host-dev/shared/{mndw-ui@0.2.0.js → mndw-ui@0.3.1.js} +98 -83
  8. package/package.json +14 -14
  9. package/templates/angular/i18n/en.json +4 -0
  10. package/templates/angular/i18n/ru.json +4 -0
  11. package/templates/angular/src/app.component.ts +0 -6
  12. package/templates/angular/src/index.ts +4 -4
  13. package/templates/angular/src/l10n.test.ts +4 -4
  14. package/templates/go/i18n/en.json +4 -0
  15. package/templates/go/i18n/ru.json +4 -0
  16. package/templates/go/manifest.json +1 -0
  17. package/templates/go/src/index.test.ts +4 -2
  18. package/templates/go/src/index.ts +2 -9
  19. package/templates/go/src/l10n.test.ts +4 -1
  20. package/templates/svelte/i18n/en.json +4 -0
  21. package/templates/svelte/i18n/ru.json +4 -0
  22. package/templates/svelte/src/App.svelte +1 -7
  23. package/templates/svelte/src/index.ts +1 -1
  24. package/templates/svelte/src/l10n.test.ts +5 -5
  25. package/templates/vanilla/i18n/en.json +4 -0
  26. package/templates/vanilla/i18n/ru.json +4 -0
  27. package/templates/vanilla/src/index.ts +2 -9
  28. package/templates/vanilla/src/l10n.test.ts +4 -1
  29. package/templates/vue/i18n/en.json +4 -0
  30. package/templates/vue/i18n/ru.json +4 -0
  31. package/templates/vue/src/App.vue +1 -7
  32. package/templates/vue/src/index.ts +1 -1
  33. package/templates/vue/src/l10n.test.ts +1 -1
  34. package/host-dev/assets/index-BqQCCILo.css +0 -1
  35. package/host-dev/assets/index-DFVRx7na.js +0 -94
package/dist/meta.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "format": "esm"
7
7
  },
8
8
  "../../frontend/sdk-internal/src/manifest.ts": {
9
- "bytes": 1984,
9
+ "bytes": 1968,
10
10
  "imports": [],
11
11
  "format": "esm"
12
12
  },
@@ -43,12 +43,12 @@
43
43
  "format": "esm"
44
44
  },
45
45
  "../../frontend/sdk/src/i18n.ts": {
46
- "bytes": 474,
46
+ "bytes": 390,
47
47
  "imports": [],
48
48
  "format": "esm"
49
49
  },
50
- "../../frontend/sdk/src/permissions.ts": {
51
- "bytes": 948,
50
+ "../../frontend/sdk/src/capabilities.ts": {
51
+ "bytes": 954,
52
52
  "imports": [
53
53
  {
54
54
  "path": "zod",
@@ -74,8 +74,19 @@
74
74
  ],
75
75
  "format": "esm"
76
76
  },
77
+ "../../frontend/sdk/src/rci.ts": {
78
+ "bytes": 3270,
79
+ "imports": [
80
+ {
81
+ "path": "rxjs",
82
+ "kind": "import-statement",
83
+ "external": true
84
+ }
85
+ ],
86
+ "format": "esm"
87
+ },
77
88
  "../../frontend/sdk/src/backend-client.ts": {
78
- "bytes": 23268,
89
+ "bytes": 26288,
79
90
  "imports": [
80
91
  {
81
92
  "path": "zod",
@@ -83,9 +94,9 @@
83
94
  "external": true
84
95
  },
85
96
  {
86
- "path": "../../frontend/sdk/src/permissions.ts",
97
+ "path": "../../frontend/sdk/src/capabilities.ts",
87
98
  "kind": "import-statement",
88
- "original": "./permissions.js"
99
+ "original": "./capabilities.js"
89
100
  }
90
101
  ],
91
102
  "format": "esm"
@@ -96,7 +107,7 @@
96
107
  "format": "esm"
97
108
  },
98
109
  "../../frontend/sdk-internal/src/sdk-source.ts": {
99
- "bytes": 519,
110
+ "bytes": 668,
100
111
  "imports": [
101
112
  {
102
113
  "path": "../../frontend/sdk/src/catalog.ts",
@@ -119,15 +130,20 @@
119
130
  "original": "../../sdk/src/i18n.js"
120
131
  },
121
132
  {
122
- "path": "../../frontend/sdk/src/permissions.ts",
133
+ "path": "../../frontend/sdk/src/capabilities.ts",
123
134
  "kind": "import-statement",
124
- "original": "../../sdk/src/permissions.js"
135
+ "original": "../../sdk/src/capabilities.js"
125
136
  },
126
137
  {
127
138
  "path": "../../frontend/sdk/src/palette.ts",
128
139
  "kind": "import-statement",
129
140
  "original": "../../sdk/src/palette.js"
130
141
  },
142
+ {
143
+ "path": "../../frontend/sdk/src/rci.ts",
144
+ "kind": "import-statement",
145
+ "original": "../../sdk/src/rci.js"
146
+ },
131
147
  {
132
148
  "path": "../../frontend/sdk/src/backend-client.ts",
133
149
  "kind": "import-statement",
@@ -142,7 +158,7 @@
142
158
  "format": "esm"
143
159
  },
144
160
  "../../frontend/sdk-internal/src/manifest-schema.ts": {
145
- "bytes": 11375,
161
+ "bytes": 12372,
146
162
  "imports": [
147
163
  {
148
164
  "path": "zod",
@@ -163,7 +179,7 @@
163
179
  "format": "esm"
164
180
  },
165
181
  "../../frontend/sdk-internal/src/manifest-validator.ts": {
166
- "bytes": 1182,
182
+ "bytes": 2341,
167
183
  "imports": [
168
184
  {
169
185
  "path": "../../frontend/sdk-internal/src/manifest-schema.ts",
@@ -190,7 +206,7 @@
190
206
  "format": "esm"
191
207
  },
192
208
  "../../frontend/sdk-internal/src/scripts/manifest-schema-document.ts": {
193
- "bytes": 659,
209
+ "bytes": 873,
194
210
  "imports": [
195
211
  {
196
212
  "path": "zod",
@@ -346,7 +362,7 @@
346
362
  "format": "esm"
347
363
  },
348
364
  "src/create.ts": {
349
- "bytes": 21179,
365
+ "bytes": 21413,
350
366
  "imports": [
351
367
  {
352
368
  "path": "node:child_process",
@@ -1328,6 +1344,11 @@
1328
1344
  "kind": "import-statement",
1329
1345
  "external": true
1330
1346
  },
1347
+ {
1348
+ "path": "rxjs",
1349
+ "kind": "import-statement",
1350
+ "external": true
1351
+ },
1331
1352
  {
1332
1353
  "path": "zod",
1333
1354
  "kind": "import-statement",
@@ -1727,7 +1748,7 @@
1727
1748
  "bytesInOutput": 0
1728
1749
  },
1729
1750
  "../../frontend/sdk-internal/src/manifest-schema.ts": {
1730
- "bytesInOutput": 9237
1751
+ "bytesInOutput": 10022
1731
1752
  },
1732
1753
  "../../frontend/sdk-internal/src/page-routes.ts": {
1733
1754
  "bytesInOutput": 232
@@ -1741,17 +1762,20 @@
1741
1762
  "../../frontend/sdk/src/i18n-format.ts": {
1742
1763
  "bytesInOutput": 52
1743
1764
  },
1744
- "../../frontend/sdk/src/permissions.ts": {
1745
- "bytesInOutput": 297
1765
+ "../../frontend/sdk/src/capabilities.ts": {
1766
+ "bytesInOutput": 299
1746
1767
  },
1747
1768
  "../../frontend/sdk/src/palette.ts": {
1748
1769
  "bytesInOutput": 207
1749
1770
  },
1771
+ "../../frontend/sdk/src/rci.ts": {
1772
+ "bytesInOutput": 57
1773
+ },
1750
1774
  "../../frontend/sdk/src/backend-client.ts": {
1751
- "bytesInOutput": 7526
1775
+ "bytesInOutput": 7623
1752
1776
  },
1753
1777
  "../../frontend/sdk-internal/src/manifest-validator.ts": {
1754
- "bytesInOutput": 840
1778
+ "bytesInOutput": 1896
1755
1779
  },
1756
1780
  "../../frontend/sdk-internal/src/mws-member-schema.ts": {
1757
1781
  "bytesInOutput": 341
@@ -1763,7 +1787,7 @@
1763
1787
  "bytesInOutput": 31
1764
1788
  },
1765
1789
  "src/create.ts": {
1766
- "bytesInOutput": 14981
1790
+ "bytesInOutput": 15178
1767
1791
  },
1768
1792
  "src/errors.ts": {
1769
1793
  "bytesInOutput": 40
@@ -1871,7 +1895,7 @@
1871
1895
  "bytesInOutput": 1982
1872
1896
  }
1873
1897
  },
1874
- "bytes": 153108
1898
+ "bytes": 155337
1875
1899
  }
1876
1900
  }
1877
1901
  }
package/dist/mndw.js CHANGED
@@ -24,8 +24,8 @@ var integer = z.number().int();
24
24
  var nonNegativeInteger = integer.nonnegative();
25
25
  var MaxEventPayloadBytes = 4 * 1024;
26
26
  var eventSourceSchema = z.enum(["hook", "log", "internal"]);
27
- var EVENT_PERMISSION_PATTERN = /^events:(\*|[a-z][a-z0-9]*(?:,[a-z][a-z0-9]*)*)$/;
28
- var eventPermissionSchema = z.string().regex(EVENT_PERMISSION_PATTERN);
27
+ var EVENT_CAPABILITY_PATTERN = /^events:(\*|[a-z][a-z0-9]*(?:,[a-z][a-z0-9]*)*)$/;
28
+ var eventCapabilitySchema = z.string().regex(EVENT_CAPABILITY_PATTERN);
29
29
  var eventBranch = (topic, source, payload) => {
30
30
  const sourceSchema = typeof source === "string" ? z.literal(source) : source;
31
31
  return z.object({
@@ -223,11 +223,11 @@ var eventSchema = z.union([
223
223
  // ../../frontend/sdk/src/i18n-format.ts
224
224
  import IntlMessageFormat from "intl-messageformat";
225
225
 
226
- // ../../frontend/sdk/src/permissions.ts
226
+ // ../../frontend/sdk/src/capabilities.ts
227
227
  import { z as z2 } from "zod";
228
- var PERSISTENT_RCI_PERMISSIONS = ["persistent-rci-session:read", "persistent-rci-session:write"];
229
- var persistentRciPermissionSchema = z2.enum(PERSISTENT_RCI_PERMISSIONS);
230
- var pluginPermissionSchema = z2.union([persistentRciPermissionSchema, eventPermissionSchema]);
228
+ var PERSISTENT_RCI_CAPABILITIES = ["persistent-rci-session:read", "persistent-rci-session:write"];
229
+ var persistentRciCapabilitySchema = z2.enum(PERSISTENT_RCI_CAPABILITIES);
230
+ var pluginCapabilitySchema = z2.union([persistentRciCapabilitySchema, eventCapabilitySchema]);
231
231
 
232
232
  // ../../frontend/sdk/src/palette.ts
233
233
  import {
@@ -239,13 +239,16 @@ import {
239
239
  } from "@mndw/palette-core";
240
240
  var TOKENS = PALETTE_CSS_VARIABLES.map((entry) => entry.token);
241
241
 
242
+ // ../../frontend/sdk/src/rci.ts
243
+ import { Observable, firstValueFrom, race } from "rxjs";
244
+
242
245
  // ../../frontend/sdk/src/backend-client.ts
243
246
  import { z as z3 } from "zod";
244
247
  var isRecord = (value) => {
245
248
  return value !== null && typeof value === "object" && !Array.isArray(value);
246
249
  };
247
250
  var backendBlockerSchema = z3.object({
248
- permission: persistentRciPermissionSchema,
251
+ capability: persistentRciCapabilitySchema,
249
252
  reason: z3.string().min(1),
250
253
  prerequisite: z3.string().min(1).optional()
251
254
  });
@@ -286,6 +289,12 @@ var backendStatusSchema = z3.preprocess(
286
289
  rejectVariantOnlyFields,
287
290
  z3.discriminatedUnion("state", [blockedStatusSchema, incompatibleStatusSchema, plainStatusSchema])
288
291
  );
292
+ var BackendSocketCloseCode = Object.freeze(
293
+ {
294
+ notApproved: 4001,
295
+ disabled: 4002
296
+ }
297
+ );
289
298
  var RETRYABLE_CODES = /* @__PURE__ */ new Set([
290
299
  "BACKEND_BUSY",
291
300
  "BACKEND_STARTING",
@@ -432,6 +441,13 @@ var ERROR_BY_CODE = {
432
441
  };
433
442
 
434
443
  // ../../frontend/sdk-internal/src/manifest-schema.ts
444
+ var strictObjectError = (scope) => (issue) => {
445
+ if (issue.code !== "unrecognized_keys") {
446
+ return void 0;
447
+ }
448
+ const key = [...issue.keys].sort()[0] ?? "<unknown>";
449
+ return `${scope} contains unknown field "${key}"`;
450
+ };
435
451
  var pluginNameSchema = z4.string().regex(/^[a-z0-9][a-z0-9-]*$/, {
436
452
  message: "name must be lowercase alphanumeric with hyphens (e.g. my-widget)"
437
453
  });
@@ -594,12 +610,17 @@ var versionField = z4.string().regex(
594
610
  }
595
611
  ).describe("Semantic version of this plugin.");
596
612
  var labelField = z4.string().min(1).describe("Human-readable name shown in the dashboard or navigation.");
613
+ var descriptionField = z4.string().refine((value) => {
614
+ const codePointCount = Array.from(value).length;
615
+ return codePointCount >= 1 && codePointCount <= 160;
616
+ }, {
617
+ message: "Description must contain between 1 and 160 Unicode code points."
618
+ }).meta({ minLength: 1, maxLength: 160 }).describe("Optional plain-text description in the plugin default language.");
597
619
  var entryField = pluginEntrySchema.describe("Relative path to the bundled entry module.");
598
- var iconField = z4.string().optional().describe("Optional icon name.");
599
- var permissionSchema = pluginPermissionSchema;
600
- var permissionsSchema = z4.array(permissionSchema).superRefine((permissions, ctx) => {
601
- if (new Set(permissions).size !== permissions.length) {
602
- ctx.addIssue({ code: "custom", message: "permissions contains duplicate permission" });
620
+ var capabilitySchema = pluginCapabilitySchema;
621
+ var capabilitiesSchema = z4.array(capabilitySchema).superRefine((capabilities, ctx) => {
622
+ if (new Set(capabilities).size !== capabilities.length) {
623
+ ctx.addIssue({ code: "custom", message: "capabilities contains duplicate capability" });
603
624
  }
604
625
  });
605
626
  var sizeSchema = z4.object({
@@ -607,7 +628,7 @@ var sizeSchema = z4.object({
607
628
  h: gridRows,
608
629
  minW: gridColumns.optional(),
609
630
  minH: gridRows.optional()
610
- }).refine((size) => size.minW === void 0 || size.minW <= size.w, {
631
+ }, { error: strictObjectError("size") }).strict().refine((size) => size.minW === void 0 || size.minW <= size.w, {
611
632
  message: "size.minW must be less than or equal to size.w",
612
633
  path: ["minW"]
613
634
  }).refine((size) => size.minH === void 0 || size.minH <= size.h, {
@@ -616,35 +637,41 @@ var sizeSchema = z4.object({
616
637
  });
617
638
  var pageRouteSchema = z4.string().regex(/^\/[^/?#*]+$/).refine((route) => !isReservedPageRoute(route), { message: "route is reserved by the host" });
618
639
  var baseFields = {
640
+ $schema: z4.string({ error: "$schema must be a string" }).optional().describe("JSON Schema editor hint for this manifest."),
619
641
  manifestVersion: versionSchema,
620
642
  name: nameSchema,
621
643
  version: versionField,
622
644
  label: labelField,
645
+ description: descriptionField.optional(),
623
646
  entry: entryField,
624
- icon: iconField,
625
- permissions: permissionsSchema.optional(),
647
+ capabilities: capabilitiesSchema.optional(),
626
648
  i18n: i18nSchema.optional(),
627
649
  backend: backendSchema.optional()
628
650
  };
629
651
  var widgetManifestSchema = z4.object({
630
652
  ...baseFields,
631
653
  type: z4.literal("widget"),
632
- size: sizeSchema,
633
- fixedHeight: z4.boolean().optional()
634
- });
654
+ size: sizeSchema
655
+ }, { error: strictObjectError("manifest") }).strict();
635
656
  var pageManifestSchema = z4.object({
636
657
  ...baseFields,
637
658
  type: z4.literal("page"),
638
659
  route: pageRouteSchema
639
- });
660
+ }, { error: strictObjectError("manifest") }).strict();
640
661
  var pluginManifestSchema = z4.discriminatedUnion("type", [widgetManifestSchema, pageManifestSchema]);
641
662
 
642
663
  // ../../frontend/sdk-internal/src/manifest-validator.ts
664
+ var REMOVED_MANIFEST_KEYS = {
665
+ permissions: "permissions was renamed to capabilities in 0.3",
666
+ icon: "icon was removed in 0.3",
667
+ fixedHeight: "fixedHeight was removed in 0.3"
668
+ };
643
669
  var ManifestValidationError = class extends Error {
644
670
  issues;
645
671
  constructor(pluginName, issues) {
646
672
  const formattedIssues = issues.map((issue) => {
647
- const path3 = issue.path.length === 0 ? "<root>" : issue.path.join(".");
673
+ const issuePath = issue.code === "unrecognized_keys" ? [...issue.path, [...issue.keys].sort()[0] ?? "<unknown>"] : issue.path;
674
+ const path3 = issuePath.length === 0 ? "<root>" : issuePath.join(".");
648
675
  return { path: path3, message: issue.message };
649
676
  });
650
677
  const reason = formattedIssues.map((issue) => `${issue.path}: ${issue.message}`).join("; ");
@@ -653,11 +680,31 @@ var ManifestValidationError = class extends Error {
653
680
  }
654
681
  };
655
682
  function validateManifest(data) {
656
- const result = pluginManifestSchema.safeParse(data);
683
+ let manifestData = data;
684
+ if (typeof data === "object" && data !== null && !Array.isArray(data)) {
685
+ const record = data;
686
+ const pluginName = typeof record.name === "string" ? record.name : "unknown";
687
+ for (const [key, message] of Object.entries(REMOVED_MANIFEST_KEYS)) {
688
+ if (Object.prototype.hasOwnProperty.call(record, key)) {
689
+ throw new ManifestValidationError(pluginName, [{
690
+ code: "custom",
691
+ path: [key],
692
+ message
693
+ }]);
694
+ }
695
+ }
696
+ const normalized = { ...record };
697
+ if (record.type === "page" || record.type === "widget") {
698
+ delete normalized[record.type === "page" ? "size" : "route"];
699
+ }
700
+ manifestData = normalized;
701
+ }
702
+ const result = pluginManifestSchema.safeParse(manifestData);
657
703
  if (!result.success) {
658
704
  const pluginName = typeof data === "object" && data !== null ? typeof data.name === "string" ? data.name : "unknown" : "unknown";
659
705
  throw new ManifestValidationError(pluginName, result.error.issues);
660
706
  }
707
+ delete result.data.$schema;
661
708
  return result.data;
662
709
  }
663
710
 
@@ -713,7 +760,7 @@ var SHARED_DEPENDENCIES = [
713
760
  {
714
761
  specifiers: ["@mndw/ui"],
715
762
  bundle: "mndw-ui",
716
- version: "0.2.0",
763
+ version: "0.3.1",
717
764
  entryPoint: "@mndw/ui",
718
765
  external: ["d3"],
719
766
  framework: "base"
@@ -986,6 +1033,7 @@ function normalize(options) {
986
1033
  framework: options.framework ?? "svelte",
987
1034
  outDir: options.outDir,
988
1035
  label: options.label ?? toLabel(name),
1036
+ description: `A starter ${options.type ?? "widget"} for ${options.label ?? toLabel(name)}.`,
989
1037
  route: options.route ?? `/${name}`,
990
1038
  backend: options.backend
991
1039
  };
@@ -1010,6 +1058,7 @@ function buildManifest(options) {
1010
1058
  version: "0.1.0",
1011
1059
  type: normalized.type,
1012
1060
  label: normalized.label,
1061
+ description: normalized.description,
1013
1062
  entry: "index.js"
1014
1063
  };
1015
1064
  if (normalized.type === "widget") {
@@ -1158,7 +1207,7 @@ function buildPackageJson(normalized) {
1158
1207
  };
1159
1208
  }
1160
1209
  function renderPlaceholders(contents, normalized) {
1161
- return contents.replaceAll("__MNDW_LABEL__", normalized.label).replaceAll("__MNDW_NAME__", normalized.name).replaceAll("__MNDW_ROUTE__", normalized.route).replaceAll("__MNDW_SCHEMA__", schemaReference(normalized.outDir));
1210
+ return contents.replaceAll("__MNDW_LABEL__", normalized.label).replaceAll("__MNDW_DESCRIPTION__", normalized.description).replaceAll("__MNDW_NAME__", normalized.name).replaceAll("__MNDW_ROUTE__", normalized.route).replaceAll("__MNDW_SCHEMA__", schemaReference(normalized.outDir));
1162
1211
  }
1163
1212
  function walkTemplate(dir, prefix) {
1164
1213
  return readdirSync(dir, { withFileTypes: true }).flatMap((entry) => {