@mearl/preset 3.0.0-beta.5 → 3.0.0-beta.7
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/README.md +45 -2
- package/dist/browserControls.d.ts +29 -0
- package/dist/browserControls.js +54 -0
- package/dist/browserPreset.js +8 -3
- package/dist/browserViews.d.ts +1 -1
- package/dist/browserViews.js +5 -5
- package/dist/bundle.d.ts +4 -1
- package/dist/bundle.js +24 -5
- package/dist/bundleStore.js +80 -75
- package/dist/bundles.d.ts +7 -1
- package/dist/bundles.js +4 -1
- package/dist/{nodeSnapshot.d.ts → capabilitySnapshot.d.ts} +11 -11
- package/dist/{nodeSnapshot.js → capabilitySnapshot.js} +36 -35
- package/dist/extensionContributions.d.ts +29 -0
- package/dist/extensionContributions.js +57 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +2 -1
- package/dist/manifest.js +5 -5
- package/dist/networkRoutes.d.ts +12 -0
- package/dist/networkRoutes.js +32 -0
- package/dist/prepare.d.ts +6 -0
- package/dist/prepare.js +81 -16
- package/dist/preset.js +3 -1
- package/dist/requestUi.d.ts +3 -1
- package/dist/requestUi.js +2 -2
- package/dist/resolve.js +4 -0
- package/dist/toolboxCatalogs.d.ts +8 -0
- package/dist/toolboxCatalogs.js +34 -0
- package/dist/types.d.ts +2 -1
- package/installation-site.json +1 -1
- package/package.json +7 -3
package/dist/preset.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { browserPresetSnapshot } from './browserPreset.js';
|
|
2
|
-
import { preparePresetPackages, presetSnapshotRevision, verifyPresetGraph } from './prepare.js';
|
|
2
|
+
import { preparePresetPackages, presetSnapshotRevision, verifyPresetGraph, verifyPackageTargets } from './prepare.js';
|
|
3
3
|
import { satisfies } from 'semver';
|
|
4
4
|
import { BundleError, MAX_BROWSER_STORAGE_BYTES, verifyBundle } from './bundle.js';
|
|
5
5
|
export async function preparePreset(source, options) {
|
|
@@ -9,6 +9,7 @@ export async function preparePreset(source, options) {
|
|
|
9
9
|
source: prepared.source,
|
|
10
10
|
manifests: prepared.manifests,
|
|
11
11
|
bundleRevisions: Object.fromEntries(prepared.bundles.map(bundle => [bundle.manifest.id, bundle.revision])),
|
|
12
|
+
packageTargets: prepared.packageTargets,
|
|
12
13
|
};
|
|
13
14
|
const snapshot = { ...data, revision: await presetSnapshotRevision(data) };
|
|
14
15
|
const browser = await browserPresetSnapshot(prepared.source, prepared.manifests, prepared.preset, prepared.bundles);
|
|
@@ -44,6 +45,7 @@ export async function verifyPreparedPreset(value, mearlApiVersion) {
|
|
|
44
45
|
Promise.all(value.bundles.map(bundle => verifyBundle(bundle, mearlApiVersion))),
|
|
45
46
|
]);
|
|
46
47
|
const { snapshot, preset } = graph;
|
|
48
|
+
verifyPackageTargets(preset, bundles);
|
|
47
49
|
if (bundles.length !== Object.keys(snapshot.bundleRevisions).length || new Set(bundles.map(bundle => bundle.manifest.id)).size !== bundles.length || bundles.some(bundle => {
|
|
48
50
|
const entry = preset.packages[bundle.manifest.id];
|
|
49
51
|
return snapshot.bundleRevisions[bundle.manifest.id] !== bundle.revision || entry?.source !== bundle.source || (entry.version && !satisfies(bundle.manifest.version, entry.version));
|
package/dist/requestUi.d.ts
CHANGED
|
@@ -49,7 +49,9 @@ export interface SelectedBrowserRequestUi {
|
|
|
49
49
|
definition: BrowserRequestUi;
|
|
50
50
|
}
|
|
51
51
|
export declare function validateBrowserUiText(value: unknown): void;
|
|
52
|
-
export declare function browserUiHttpUrl(value: unknown
|
|
52
|
+
export declare function browserUiHttpUrl(value: unknown, options?: {
|
|
53
|
+
allowFragment?: boolean;
|
|
54
|
+
}): string;
|
|
53
55
|
export declare function validateBrowserRequestUi(input: unknown): BrowserRequestUi;
|
|
54
56
|
/** Contribution validation is pure; factories and UI side effects belong to the host. */
|
|
55
57
|
export declare function selectBrowserRequestUi(bundles: PreparedBundle[], apiVersion: string): SelectedBrowserRequestUi | undefined;
|
package/dist/requestUi.js
CHANGED
|
@@ -10,7 +10,7 @@ export function validateBrowserUiText(value) {
|
|
|
10
10
|
if (typeof value.en !== 'string' || !value.en.trim() || Object.values(value).some(entry => typeof entry !== 'string' || entry.length > 1024 || !entry.trim()))
|
|
11
11
|
invalid('Request UI text requires bounded translations');
|
|
12
12
|
}
|
|
13
|
-
export function browserUiHttpUrl(value) {
|
|
13
|
+
export function browserUiHttpUrl(value, options = {}) {
|
|
14
14
|
if (typeof value !== 'string' || value.length > 4096)
|
|
15
15
|
invalid('Invalid request UI URL');
|
|
16
16
|
let url;
|
|
@@ -20,7 +20,7 @@ export function browserUiHttpUrl(value) {
|
|
|
20
20
|
catch {
|
|
21
21
|
invalid('Invalid request UI URL');
|
|
22
22
|
}
|
|
23
|
-
if (url.username || url.password || url.hash || url.protocol !== 'https:' && !(url.protocol === 'http:' && ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)))
|
|
23
|
+
if (url.username || url.password || !options.allowFragment && url.hash || url.protocol !== 'https:' && !(url.protocol === 'http:' && ['127.0.0.1', 'localhost', '[::1]'].includes(url.hostname)))
|
|
24
24
|
invalid('Request UI requires credential-free HTTPS or loopback URLs');
|
|
25
25
|
return url.href;
|
|
26
26
|
}
|
package/dist/resolve.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseToolboxCatalogs } from './toolboxCatalogs.js';
|
|
1
2
|
import { satisfies, valid } from 'semver';
|
|
2
3
|
import { clonePresetDefaults, isJsonObject, PresetError, validatePreset } from './manifest.js';
|
|
3
4
|
const kinds = ['packages', 'skills', 'providers'];
|
|
@@ -127,6 +128,9 @@ export async function resolvePreset(source, options) {
|
|
|
127
128
|
return result;
|
|
128
129
|
};
|
|
129
130
|
const result = await load(sourceUrl(source));
|
|
131
|
+
const extension = result.defaults.extension;
|
|
132
|
+
if (isJsonObject(extension))
|
|
133
|
+
parseToolboxCatalogs(extension.toolCatalogs);
|
|
130
134
|
// Dependency validity is checked on the final graph, so children may complete or disable parent entries.
|
|
131
135
|
for (const kind of kinds)
|
|
132
136
|
validateDependencies(kind, result[kind]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface ToolboxCatalogConfig {
|
|
2
|
+
url?: string;
|
|
3
|
+
label?: string;
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export type ToolboxCatalogConfigs = Record<string, ToolboxCatalogConfig>;
|
|
7
|
+
/** Stable keys let child presets patch or disable a parent directory through defaults merging. */
|
|
8
|
+
export declare function parseToolboxCatalogs(input: unknown): ToolboxCatalogConfigs;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isJsonObject, PresetError } from './manifest.js';
|
|
2
|
+
/** Stable keys let child presets patch or disable a parent directory through defaults merging. */
|
|
3
|
+
export function parseToolboxCatalogs(input) {
|
|
4
|
+
if (input === undefined)
|
|
5
|
+
return {};
|
|
6
|
+
function invalid() { throw new PresetError('PRESET_INVALID', 'Invalid extension.toolCatalogs configuration'); }
|
|
7
|
+
if (!isJsonObject(input) || Object.keys(input).length > 16)
|
|
8
|
+
invalid();
|
|
9
|
+
return Object.fromEntries(Object.entries(input).map(([id, entry]) => {
|
|
10
|
+
if (!/^[a-z][a-z0-9-]{0,63}$/.test(id) || id === 'official' || !isJsonObject(entry) || Object.keys(entry).some(key => !['url', 'label', 'enabled'].includes(key)))
|
|
11
|
+
invalid();
|
|
12
|
+
if (entry.enabled !== undefined && typeof entry.enabled !== 'boolean')
|
|
13
|
+
invalid();
|
|
14
|
+
if (entry.label !== undefined && (typeof entry.label !== 'string' || !entry.label.trim() || entry.label.length > 120))
|
|
15
|
+
invalid();
|
|
16
|
+
let url;
|
|
17
|
+
if (entry.url !== undefined) {
|
|
18
|
+
if (typeof entry.url !== 'string' || entry.url.length > 2048)
|
|
19
|
+
invalid();
|
|
20
|
+
try {
|
|
21
|
+
const parsed = new URL(entry.url);
|
|
22
|
+
if (parsed.username || parsed.password || parsed.hash || !(parsed.protocol === 'https:' || parsed.protocol === 'http:' && ['localhost', '127.0.0.1', '[::1]'].includes(parsed.hostname)))
|
|
23
|
+
invalid();
|
|
24
|
+
url = parsed.href;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
invalid();
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (entry.enabled !== false)
|
|
31
|
+
invalid();
|
|
32
|
+
return [id, { ...(url ? { url } : {}), ...(entry.label !== undefined ? { label: entry.label } : {}), ...(entry.enabled !== undefined ? { enabled: entry.enabled } : {}) }];
|
|
33
|
+
}));
|
|
34
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -11,7 +11,8 @@ export interface PresetComponent {
|
|
|
11
11
|
/** Previous Skill sources eligible for migration only when setup owns the installation. */
|
|
12
12
|
migrateFrom?: string[];
|
|
13
13
|
enabled?: boolean;
|
|
14
|
-
|
|
14
|
+
/** Optional activation subset; supported locations are defined by the package. */
|
|
15
|
+
targets?: PresetRuntime[];
|
|
15
16
|
dependsOn?: string[];
|
|
16
17
|
}
|
|
17
18
|
export interface PresetReference {
|
package/installation-site.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mearl/preset",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.7",
|
|
4
4
|
"description": "Browser-compatible preset validation, inheritance and capability resolution for Mearl",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -19,7 +19,11 @@
|
|
|
19
19
|
"types": "./dist/installation.d.ts",
|
|
20
20
|
"import": "./dist/installation.js"
|
|
21
21
|
},
|
|
22
|
-
"./installation-site.json": "./installation-site.json"
|
|
22
|
+
"./installation-site.json": "./installation-site.json",
|
|
23
|
+
"./networkRoutes": {
|
|
24
|
+
"types": "./dist/networkRoutes.d.ts",
|
|
25
|
+
"import": "./dist/networkRoutes.js"
|
|
26
|
+
}
|
|
23
27
|
},
|
|
24
28
|
"files": [
|
|
25
29
|
"dist",
|
|
@@ -34,7 +38,7 @@
|
|
|
34
38
|
},
|
|
35
39
|
"repository": {
|
|
36
40
|
"type": "git",
|
|
37
|
-
"url": "git+https://github.com/
|
|
41
|
+
"url": "git+https://github.com/mearlhq/mearl.git",
|
|
38
42
|
"directory": "packages/preset"
|
|
39
43
|
},
|
|
40
44
|
"scripts": {
|