@mosetta/build 0.0.31 → 0.0.32
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 +12 -0
- package/package.json +6 -6
- package/src/build.mjs +29 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @mosetta/build
|
|
2
2
|
|
|
3
|
+
## 0.0.32
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- A palette can offer itself as a service in its mosetta.json (`service: { grant, workbench }`): what it asks to call on a site that takes it, and the part it plays in that site's workbench (the assistant: which of its actions a turn of the conversation is). The site that publishes it lists it among its offers; a site that takes it keeps the part from the offer, takes the palette's blocks (its public code only), and declares where its services are (host capability `services`).
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @mosetta/server@0.0.32
|
|
10
|
+
- @mosetta/router@0.0.32
|
|
11
|
+
- @mosetta/runtime@0.0.32
|
|
12
|
+
- @mosetta/server-action@0.0.32
|
|
13
|
+
- @mosetta/tar@0.0.32
|
|
14
|
+
|
|
3
15
|
## 0.0.31
|
|
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.
|
|
3
|
+
"version": "0.0.32",
|
|
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/
|
|
32
|
-
"@mosetta/
|
|
33
|
-
"@mosetta/server": "0.0.
|
|
34
|
-
"@mosetta/
|
|
35
|
-
"@mosetta/
|
|
31
|
+
"@mosetta/router": "0.0.32",
|
|
32
|
+
"@mosetta/runtime": "0.0.32",
|
|
33
|
+
"@mosetta/server": "0.0.32",
|
|
34
|
+
"@mosetta/server-action": "0.0.32",
|
|
35
|
+
"@mosetta/tar": "0.0.32"
|
|
36
36
|
},
|
|
37
37
|
"publishConfig": {
|
|
38
38
|
"access": "public"
|
package/src/build.mjs
CHANGED
|
@@ -375,8 +375,10 @@ 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
379
|
const brings = mods.some((m) => m.namespace === r.namespace)
|
|
379
|
-
|| (r.dir !== root && discoverPrefabsIn(fileSystem, r.dir, () => {}).length > 0)
|
|
380
|
+
|| (r.dir !== root && discoverPrefabsIn(fileSystem, r.dir, () => {}).length > 0)
|
|
381
|
+
|| readConfig(fileSystem, r.dir)?.service !== undefined;
|
|
380
382
|
if (!brings) continue;
|
|
381
383
|
const descriptor = distributionDescriptor(fileSystem, r, (key, file) => {
|
|
382
384
|
watchFiles.add(file);
|
|
@@ -554,6 +556,30 @@ export function sourceLinkOf(repository) {
|
|
|
554
556
|
return directory ? `${base}/tree/HEAD/${directory}` : base;
|
|
555
557
|
}
|
|
556
558
|
|
|
559
|
+
/** what a service may be granted on a site that takes it: palettes, a palette's tile, or the host's doors */
|
|
560
|
+
const SERVICE_GRANT_RE = /^(?:@(?:previews|media)|[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}$/;
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* A distribution's offer of itself as a service (mosetta.json `service: { grant: [...] }`): what it
|
|
566
|
+
* asks to call on a site that takes it, as the person a call comes from. Anything else is no offer —
|
|
567
|
+
* loudly: a palette that meant one must not ship without it.
|
|
568
|
+
*/
|
|
569
|
+
export function serviceOf(raw) {
|
|
570
|
+
if (raw === undefined) return null;
|
|
571
|
+
const grant = raw?.grant ?? [];
|
|
572
|
+
if (!Array.isArray(grant) || grant.length > 32 || !grant.every((g) => typeof g === 'string' && SERVICE_GRANT_RE.test(g))) {
|
|
573
|
+
throw new Error('mosetta.json: service.grant is up to 32 palettes (`brand`), tiles (`brand/tile`) or host doors (`@previews`, `@media`) the service asks to call');
|
|
574
|
+
}
|
|
575
|
+
// the part it plays in a workbench that takes it: the assistant — its turn, as `<tile>.<action>`
|
|
576
|
+
const assistant = raw?.workbench?.assistant;
|
|
577
|
+
if (assistant !== undefined && (typeof assistant !== 'string' || !SERVICE_ACTION_RE.test(assistant))) {
|
|
578
|
+
throw new Error('mosetta.json: service.workbench.assistant names the action a turn of the conversation is, `<tile>.<action>`');
|
|
579
|
+
}
|
|
580
|
+
return { grant: [...new Set(grant)], ...(assistant ? { workbench: { assistant } } : {}) };
|
|
581
|
+
}
|
|
582
|
+
|
|
557
583
|
/**
|
|
558
584
|
* A distribution's catalog entity: what it calls itself, from its mosetta.json (title,
|
|
559
585
|
* description, icon, cover, source) with package.json behind the description and the source.
|
|
@@ -582,6 +608,8 @@ export function distributionDescriptor(fileSystem, root, ship) {
|
|
|
582
608
|
...(cfg.internal === true ? { internal: true } : {}),
|
|
583
609
|
// the distribution others are built on (the UI kit): always connected, no switch
|
|
584
610
|
...(cfg.base === true ? { base: true } : {}),
|
|
611
|
+
// offered to other sites as a SERVICE: what it asks to call on a site that takes it
|
|
612
|
+
...(serviceOf(cfg.service) ? { service: serviceOf(cfg.service) } : {}),
|
|
585
613
|
...(text(cfg.description) ?? text(pkg.description) ? { description: text(cfg.description) ?? text(pkg.description) } : {}),
|
|
586
614
|
...(text(cfg.source) ?? sourceLinkOf(pkg.repository) ? { source: text(cfg.source) ?? sourceLinkOf(pkg.repository) } : {}),
|
|
587
615
|
...(changesOf(fileSystem, root) ? { changes: changesOf(fileSystem, root) } : {}),
|