@mosetta/build 0.0.33 → 0.0.34

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @mosetta/build
2
2
 
3
+ ## 0.0.34
4
+
5
+ ### Patch Changes
6
+
7
+ - The parts a palette plays in a workbench — its assistant, dictation — are the palette's own: `workbench` in `mosetta.json` (`{ "assistant": "<tile>.<action>", "transcribe": "<tile>.<action>" }`), carried by the palette's catalog entry, whichever way a site connects the palette. `service` is the grant alone; any other key in it is refused.
8
+ - Updated dependencies
9
+ - @mosetta/server@0.0.34
10
+ - @mosetta/router@0.0.34
11
+ - @mosetta/runtime@0.0.34
12
+ - @mosetta/server-action@0.0.34
13
+ - @mosetta/tar@0.0.34
14
+
3
15
  ## 0.0.33
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mosetta/build",
3
- "version": "0.0.33",
3
+ "version": "0.0.34",
4
4
  "license": "MIT",
5
5
  "description": "The core of the tile forge: builds a tile palette — its tile side artifacts, their dependency closure, the tile host descriptor. Environment-agnostic — the file system and the bundling engine are supplied from outside.",
6
6
  "type": "module",
@@ -28,11 +28,11 @@
28
28
  "scheduler": "*",
29
29
  "systemjs": "^6.15.1",
30
30
  "yaml": "^2.9.0",
31
- "@mosetta/router": "0.0.33",
32
- "@mosetta/runtime": "0.0.33",
33
- "@mosetta/server": "0.0.33",
34
- "@mosetta/server-action": "0.0.33",
35
- "@mosetta/tar": "0.0.33"
31
+ "@mosetta/runtime": "0.0.34",
32
+ "@mosetta/server": "0.0.34",
33
+ "@mosetta/router": "0.0.34",
34
+ "@mosetta/tar": "0.0.34",
35
+ "@mosetta/server-action": "0.0.34"
36
36
  },
37
37
  "publishConfig": {
38
38
  "access": "public"
package/src/build.mjs CHANGED
@@ -375,10 +375,13 @@ export async function build(root, { mode = 'development', log, fileSystem, resol
375
375
  for (const r of builtRoots) {
376
376
  // the APP's own prefabs are its site's content (the picker's "prefabs of this site"), not a
377
377
  // distribution: the app counts only for blocks of its own
378
- // (a palette offering itself as a service is named too: the sites taking it read its offer here)
378
+ // (a palette offering itself as a service, or playing a part in a workbench, is named too: its
379
+ // offer and its parts are read here)
380
+ const cfg = readConfig(fileSystem, r.dir);
379
381
  const brings = mods.some((m) => m.namespace === r.namespace)
380
382
  || (r.dir !== root && discoverPrefabsIn(fileSystem, r.dir, () => {}).length > 0)
381
- || readConfig(fileSystem, r.dir)?.service !== undefined;
383
+ || cfg?.service !== undefined
384
+ || cfg?.workbench !== undefined;
382
385
  if (!brings) continue;
383
386
  const descriptor = distributionDescriptor(fileSystem, r, (key, file) => {
384
387
  watchFiles.add(file);
@@ -558,8 +561,10 @@ export function sourceLinkOf(repository) {
558
561
 
559
562
  /** what a service may be granted on a site that takes it: palettes, a palette's tile, or the host's doors */
560
563
  const SERVICE_GRANT_RE = /^(?:@(?:previews|media|code|icon|repositories)|[a-z][a-z0-9-]{0,62}(?:\/[a-z][A-Za-z0-9]{0,63})?)$/;
561
- /** a service's action named for a workbench: `<tile>.<action>` */
562
- const SERVICE_ACTION_RE = /^[a-z][A-Za-z0-9]{0,63}\.[A-Za-z][A-Za-z0-9_]{0,63}$/;
564
+ /** an action of the palette named for a workbench: `<tile>.<action>` */
565
+ const WORKBENCH_ACTION_RE = /^[a-z][A-Za-z0-9]{0,63}\.[A-Za-z][A-Za-z0-9_]{0,63}$/;
566
+ /** the parts a palette may play in a workbench */
567
+ const WORKBENCH_ROLES = ['assistant', 'transcribe'];
563
568
 
564
569
  /**
565
570
  * A distribution's offer of itself as a service (mosetta.json `service: { grant: [...] }`): what it
@@ -568,19 +573,34 @@ const SERVICE_ACTION_RE = /^[a-z][A-Za-z0-9]{0,63}\.[A-Za-z][A-Za-z0-9_]{0,63}$/
568
573
  */
569
574
  export function serviceOf(raw) {
570
575
  if (raw === undefined) return null;
576
+ const unknown = raw !== null && typeof raw === 'object' ? Object.keys(raw).find((key) => key !== 'grant') : undefined;
577
+ if (unknown !== undefined) throw new Error(`mosetta.json: service.${unknown} is no part of a service's offer — it is { "grant": [...] }`);
571
578
  const grant = raw?.grant ?? [];
572
579
  if (!Array.isArray(grant) || grant.length > 32 || !grant.every((g) => typeof g === 'string' && SERVICE_GRANT_RE.test(g))) {
573
580
  throw new Error('mosetta.json: service.grant is up to 32 palettes (`brand`), tiles (`brand/tile`) or host doors (`@previews`, `@media`, `@code`, `@icon`, `@repositories`) the service asks to call');
574
581
  }
575
- // the parts it plays in a workbench that takes it — the assistant's turn, dictation — each `<tile>.<action>`
582
+ return { grant: [...new Set(grant)] };
583
+ }
584
+
585
+ /**
586
+ * The parts a palette plays in the workbench of a site it is connected to (mosetta.json
587
+ * `workbench: { assistant, transcribe }`): the assistant's turn, dictation — each an action of its
588
+ * own, `<tile>.<action>`. The palette's own, whichever way a site connects it — as code or as a
589
+ * service. A part named wrong stops the build: a palette that meant one must not ship without it.
590
+ */
591
+ export function workbenchOf(raw) {
592
+ if (raw === undefined) return null;
593
+ if (raw === null || typeof raw !== 'object' || Array.isArray(raw)) throw new Error('mosetta.json: workbench names the parts the palette plays in a workbench: { "assistant": "<tile>.<action>", "transcribe": "<tile>.<action>" }');
594
+ const unknown = Object.keys(raw).find((role) => !WORKBENCH_ROLES.includes(role));
595
+ if (unknown !== undefined) throw new Error(`mosetta.json: workbench.${unknown} is no part of a workbench — the parts are ${WORKBENCH_ROLES.join(', ')}`);
576
596
  const workbench = {};
577
- for (const role of ['assistant', 'transcribe']) {
578
- const named = raw?.workbench?.[role];
597
+ for (const role of WORKBENCH_ROLES) {
598
+ const named = raw[role];
579
599
  if (named === undefined) continue;
580
- if (typeof named !== 'string' || !SERVICE_ACTION_RE.test(named)) throw new Error(`mosetta.json: service.workbench.${role} names an action of the palette, \`<tile>.<action>\``);
600
+ if (typeof named !== 'string' || !WORKBENCH_ACTION_RE.test(named)) throw new Error(`mosetta.json: workbench.${role} names an action of the palette, \`<tile>.<action>\``);
581
601
  workbench[role] = named;
582
602
  }
583
- return { grant: [...new Set(grant)], ...(Object.keys(workbench).length ? { workbench } : {}) };
603
+ return Object.keys(workbench).length ? workbench : null;
584
604
  }
585
605
 
586
606
  /**
@@ -613,6 +633,8 @@ export function distributionDescriptor(fileSystem, root, ship) {
613
633
  ...(cfg.base === true ? { base: true } : {}),
614
634
  // offered to other sites as a SERVICE: what it asks to call on a site that takes it
615
635
  ...(serviceOf(cfg.service) ? { service: serviceOf(cfg.service) } : {}),
636
+ // the parts it plays in a workbench (the assistant's turn, dictation)
637
+ ...(workbenchOf(cfg.workbench) ? { workbench: workbenchOf(cfg.workbench) } : {}),
616
638
  ...(text(cfg.description) ?? text(pkg.description) ? { description: text(cfg.description) ?? text(pkg.description) } : {}),
617
639
  ...(text(cfg.source) ?? sourceLinkOf(pkg.repository) ? { source: text(cfg.source) ?? sourceLinkOf(pkg.repository) } : {}),
618
640
  ...(changesOf(fileSystem, root) ? { changes: changesOf(fileSystem, root) } : {}),