@lbdudc/linea-core 0.1.1 → 0.1.2
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 +132 -260
- package/dist/analysis/analyze.d.ts +0 -54
- package/dist/analysis/analyze.js +1 -70
- package/dist/analysis/analyze.js.map +1 -1
- package/dist/analysis/runtime.d.ts +4 -73
- package/dist/analysis/runtime.js +7 -100
- package/dist/analysis/runtime.js.map +1 -1
- package/dist/analysis/uvl-text.d.ts +8 -0
- package/dist/analysis/uvl-text.js +70 -0
- package/dist/analysis/uvl-text.js.map +1 -0
- package/dist/assets.d.ts +0 -12
- package/dist/assets.js +0 -25
- package/dist/assets.js.map +1 -1
- package/dist/ci/annotations.d.ts +6 -0
- package/dist/ci/annotations.js +12 -0
- package/dist/ci/annotations.js.map +1 -0
- package/dist/ci/leftovers.d.ts +25 -0
- package/dist/ci/leftovers.js +50 -0
- package/dist/ci/leftovers.js.map +1 -0
- package/dist/ci/pairwise.d.ts +11 -0
- package/dist/ci/pairwise.js +35 -0
- package/dist/ci/pairwise.js.map +1 -0
- package/dist/ci/pipeline.d.ts +18 -0
- package/dist/ci/pipeline.js +26 -0
- package/dist/ci/pipeline.js.map +1 -0
- package/dist/ci/select.d.ts +28 -0
- package/dist/ci/select.js +43 -0
- package/dist/ci/select.js.map +1 -0
- package/dist/ci/validate-specs.d.ts +52 -0
- package/dist/ci/validate-specs.js +212 -0
- package/dist/ci/validate-specs.js.map +1 -0
- package/dist/constants.d.ts +1 -60
- package/dist/constants.js +1 -58
- package/dist/constants.js.map +1 -1
- package/dist/derivation/derive.d.ts +0 -56
- package/dist/derivation/derive.js +21 -72
- package/dist/derivation/derive.js.map +1 -1
- package/dist/derivation/engine.d.ts +10 -42
- package/dist/derivation/engine.js +37 -68
- package/dist/derivation/engine.js.map +1 -1
- package/dist/derivation/selection-error.d.ts +7 -0
- package/dist/derivation/selection-error.js +13 -0
- package/dist/derivation/selection-error.js.map +1 -0
- package/dist/errors.d.ts +19 -47
- package/dist/errors.js +28 -47
- package/dist/errors.js.map +1 -1
- package/dist/feature-model/uvl.d.ts +52 -0
- package/dist/feature-model/uvl.js +191 -0
- package/dist/feature-model/uvl.js.map +1 -0
- package/dist/fs/archive.d.ts +0 -16
- package/dist/fs/archive.js +0 -36
- package/dist/fs/archive.js.map +1 -1
- package/dist/fs/diff.d.ts +0 -30
- package/dist/fs/diff.js +4 -65
- package/dist/fs/diff.js.map +1 -1
- package/dist/fs/format.d.ts +0 -16
- package/dist/fs/format.js +0 -52
- package/dist/fs/format.js.map +1 -1
- package/dist/fs/workspace.d.ts +0 -52
- package/dist/fs/workspace.js +0 -56
- package/dist/fs/workspace.js.map +1 -1
- package/dist/index.d.ts +23 -29
- package/dist/index.js +15 -35
- package/dist/index.js.map +1 -1
- package/dist/internal/guards.d.ts +0 -13
- package/dist/internal/guards.js +0 -13
- package/dist/internal/guards.js.map +1 -1
- package/dist/line/deletion.d.ts +33 -0
- package/dist/line/deletion.js +23 -0
- package/dist/line/deletion.js.map +1 -0
- package/dist/line/platform-files.d.ts +15 -64
- package/dist/line/platform-files.js +18 -94
- package/dist/line/platform-files.js.map +1 -1
- package/dist/line/restoration.d.ts +27 -0
- package/dist/line/restoration.js +27 -0
- package/dist/line/restoration.js.map +1 -0
- package/dist/line/scaffold.d.ts +26 -57
- package/dist/line/scaffold.js +32 -93
- package/dist/line/scaffold.js.map +1 -1
- package/dist/line/templates/core/transformation.js +17 -5
- package/dist/line/templates/pipeline/github-ci.yml +50 -0
- package/dist/line/templates/pipeline/spl-gitlab-ci.yml +182 -0
- package/dist/modules/configuration/configure.d.ts +52 -0
- package/dist/modules/configuration/configure.js +101 -0
- package/dist/modules/configuration/configure.js.map +1 -0
- package/dist/modules/configuration/constants.d.ts +17 -0
- package/dist/modules/configuration/constants.js +14 -0
- package/dist/modules/configuration/constants.js.map +1 -0
- package/dist/modules/configuration/index.d.ts +6 -0
- package/dist/modules/configuration/index.js +5 -0
- package/dist/modules/configuration/index.js.map +1 -0
- package/dist/modules/configuration/names.d.ts +9 -0
- package/dist/modules/configuration/names.js +7 -0
- package/dist/modules/configuration/names.js.map +1 -0
- package/dist/modules/configuration/selection.d.ts +32 -0
- package/dist/modules/configuration/selection.js +49 -0
- package/dist/modules/configuration/selection.js.map +1 -0
- package/dist/modules/diagnostics.d.ts +2 -0
- package/dist/modules/diagnostics.js +2 -0
- package/dist/modules/diagnostics.js.map +1 -0
- package/dist/modules/index.d.ts +18 -0
- package/dist/modules/index.js +18 -0
- package/dist/modules/index.js.map +1 -0
- package/dist/modules/metamodels/engine.d.ts +93 -0
- package/dist/modules/metamodels/engine.js +10 -0
- package/dist/modules/metamodels/engine.js.map +1 -0
- package/dist/modules/metamodels/files.d.ts +40 -0
- package/dist/modules/metamodels/files.js +58 -0
- package/dist/modules/metamodels/files.js.map +1 -0
- package/dist/modules/metamodels/index.d.ts +8 -0
- package/dist/modules/metamodels/index.js +5 -0
- package/dist/modules/metamodels/index.js.map +1 -0
- package/dist/modules/metamodels/layout.d.ts +23 -0
- package/dist/modules/metamodels/layout.js +29 -0
- package/dist/modules/metamodels/layout.js.map +1 -0
- package/dist/modules/metamodels/offered.d.ts +15 -0
- package/dist/modules/metamodels/offered.js +14 -0
- package/dist/modules/metamodels/offered.js.map +1 -0
- package/dist/modules/metamodels/prepare.d.ts +20 -0
- package/dist/modules/metamodels/prepare.js +155 -0
- package/dist/modules/metamodels/prepare.js.map +1 -0
- package/dist/modules/packages/index.d.ts +4 -0
- package/dist/modules/packages/index.js +4 -0
- package/dist/modules/packages/index.js.map +1 -0
- package/dist/modules/packages/location.d.ts +21 -0
- package/dist/modules/packages/location.js +34 -0
- package/dist/modules/packages/location.js.map +1 -0
- package/dist/modules/packages/manifests.d.ts +33 -0
- package/dist/modules/packages/manifests.js +231 -0
- package/dist/modules/packages/manifests.js.map +1 -0
- package/dist/modules/packages/source.d.ts +34 -0
- package/dist/modules/packages/source.js +128 -0
- package/dist/modules/packages/source.js.map +1 -0
- package/dist/modules/products/check.d.ts +28 -0
- package/dist/modules/products/check.js +61 -0
- package/dist/modules/products/check.js.map +1 -0
- package/dist/modules/products/derive.d.ts +30 -0
- package/dist/modules/products/derive.js +56 -0
- package/dist/modules/products/derive.js.map +1 -0
- package/dist/modules/products/index.d.ts +5 -0
- package/dist/modules/products/index.js +4 -0
- package/dist/modules/products/index.js.map +1 -0
- package/dist/modules/products/seed.d.ts +18 -0
- package/dist/modules/products/seed.js +23 -0
- package/dist/modules/products/seed.js.map +1 -0
- package/dist/modules/registry/catalog.d.ts +64 -0
- package/dist/modules/registry/catalog.js +91 -0
- package/dist/modules/registry/catalog.js.map +1 -0
- package/dist/modules/registry/index.d.ts +5 -0
- package/dist/modules/registry/index.js +4 -0
- package/dist/modules/registry/index.js.map +1 -0
- package/dist/modules/registry/registry.d.ts +34 -0
- package/dist/modules/registry/registry.js +37 -0
- package/dist/modules/registry/registry.js.map +1 -0
- package/dist/modules/registry/routing.d.ts +8 -0
- package/dist/modules/registry/routing.js +23 -0
- package/dist/modules/registry/routing.js.map +1 -0
- package/dist/modules/resolution/closure.d.ts +28 -0
- package/dist/modules/resolution/closure.js +105 -0
- package/dist/modules/resolution/closure.js.map +1 -0
- package/dist/modules/resolution/index.d.ts +4 -0
- package/dist/modules/resolution/index.js +3 -0
- package/dist/modules/resolution/index.js.map +1 -0
- package/dist/modules/resolution/resolve.d.ts +33 -0
- package/dist/modules/resolution/resolve.js +59 -0
- package/dist/modules/resolution/resolve.js.map +1 -0
- package/dist/modules/resolution/resolvers.d.ts +23 -0
- package/dist/modules/resolution/resolvers.js +34 -0
- package/dist/modules/resolution/resolvers.js.map +1 -0
- package/dist/modules/spl/check.d.ts +25 -0
- package/dist/modules/spl/check.js +21 -0
- package/dist/modules/spl/check.js.map +1 -0
- package/dist/modules/spl/cip.d.ts +67 -0
- package/dist/modules/spl/cip.js +98 -0
- package/dist/modules/spl/cip.js.map +1 -0
- package/dist/modules/spl/feature-model.d.ts +39 -0
- package/dist/modules/spl/feature-model.js +106 -0
- package/dist/modules/spl/feature-model.js.map +1 -0
- package/dist/modules/spl/index.d.ts +6 -0
- package/dist/modules/spl/index.js +4 -0
- package/dist/modules/spl/index.js.map +1 -0
- package/dist/modules/spl/platform.d.ts +49 -0
- package/dist/modules/spl/platform.js +316 -0
- package/dist/modules/spl/platform.js.map +1 -0
- package/dist/modules/types.d.ts +132 -0
- package/dist/modules/types.js +2 -0
- package/dist/modules/types.js.map +1 -0
- package/dist/product/engine-spec.d.ts +0 -16
- package/dist/product/engine-spec.js +4 -50
- package/dist/product/engine-spec.js.map +1 -1
- package/dist/product/spec.d.ts +0 -82
- package/dist/product/spec.js +0 -79
- package/dist/product/spec.js.map +1 -1
- package/dist/product/version.d.ts +0 -23
- package/dist/product/version.js +0 -28
- package/dist/product/version.js.map +1 -1
- package/dist/products-index/products-index.d.ts +0 -165
- package/dist/products-index/products-index.js +0 -176
- package/dist/products-index/products-index.js.map +1 -1
- package/dist/workspace/context.d.ts +25 -0
- package/dist/workspace/context.js +43 -0
- package/dist/workspace/context.js.map +1 -0
- package/dist/workspace/gitExclude.d.ts +2 -0
- package/dist/workspace/gitExclude.js +19 -0
- package/dist/workspace/gitExclude.js.map +1 -0
- package/dist/workspace/host.d.ts +14 -0
- package/dist/workspace/host.js +13 -0
- package/dist/workspace/host.js.map +1 -0
- package/dist/workspace/index.d.ts +12 -0
- package/dist/workspace/index.js +12 -0
- package/dist/workspace/index.js.map +1 -0
- package/dist/workspace/local.d.ts +81 -0
- package/dist/workspace/local.js +287 -0
- package/dist/workspace/local.js.map +1 -0
- package/dist/workspace/modular.d.ts +95 -0
- package/dist/workspace/modular.js +301 -0
- package/dist/workspace/modular.js.map +1 -0
- package/dist/workspace/operations.d.ts +35 -0
- package/dist/workspace/operations.js +57 -0
- package/dist/workspace/operations.js.map +1 -0
- package/dist/workspace/origin.d.ts +20 -0
- package/dist/workspace/origin.js +19 -0
- package/dist/workspace/origin.js.map +1 -0
- package/package.json +22 -7
- package/dist/feature-model/convert.d.ts +0 -35
- package/dist/feature-model/convert.js +0 -47
- package/dist/feature-model/convert.js.map +0 -1
- package/dist/feature-model/engine.d.ts +0 -60
- package/dist/feature-model/engine.js +0 -139
- package/dist/feature-model/engine.js.map +0 -1
- package/dist/feature-model/inspect.d.ts +0 -67
- package/dist/feature-model/inspect.js +0 -113
- package/dist/feature-model/inspect.js.map +0 -1
- package/dist/feature-model/io.d.ts +0 -66
- package/dist/feature-model/io.js +0 -92
- package/dist/feature-model/io.js.map +0 -1
- package/dist/feature-model/parse.d.ts +0 -30
- package/dist/feature-model/parse.js +0 -36
- package/dist/feature-model/parse.js.map +0 -1
- package/dist/feature-model/text.d.ts +0 -54
- package/dist/feature-model/text.js +0 -126
- package/dist/feature-model/text.js.map +0 -1
- package/dist/line/templates/metamodels/dataModel/extra.js +0 -328
- package/dist/line/templates/metamodels/dataModel/transformation.js +0 -211
- package/dist/line/templates/metamodels/sensor/extra.js +0 -36
- package/dist/line/templates/metamodels/sensor/transformation.js +0 -47
- package/dist/selection/selection.d.ts +0 -126
- package/dist/selection/selection.js +0 -152
- package/dist/selection/selection.js.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code insertion points (CIP). A module can leave `/*→ name ←*\/` markers in a `*.cipmain.*` file; other modules provide `*.cip.*`
|
|
3
|
+
* files of the same path in which the code for a marker sits between two markers of that name. Splicing happens before the templates
|
|
4
|
+
* are evaluated and does not depend on the features, so it is done when the platform is composed.
|
|
5
|
+
*
|
|
6
|
+
* The splicing itself is spl-js-engine's (`spliceCip`, the one its derivation uses for components), so a platform composed here is
|
|
7
|
+
* the one the engine builds. What is here is what the engine does not know: which of linea's paths are main files and fragments.
|
|
8
|
+
*/
|
|
9
|
+
import type { ResolvedModule } from '../types.js';
|
|
10
|
+
export declare const CIP_DEFAULT_START = "/*\u2192";
|
|
11
|
+
export declare const CIP_DEFAULT_END = "\u2190*/";
|
|
12
|
+
/** Whether a path is the main file of a code insertion point (`x.cipmain.vue`), or a fragment for one (`x.cip.vue`). */
|
|
13
|
+
export declare const cipKind: ({ file }: {
|
|
14
|
+
file: string;
|
|
15
|
+
}) => "main" | "fragment" | undefined;
|
|
16
|
+
/** `a/_x.cipmain.vue` and `a/_x.cip.vue` both give the path of the file they make: `a/_x.vue`. */
|
|
17
|
+
export declare const cipTarget: ({ file }: {
|
|
18
|
+
file: string;
|
|
19
|
+
}) => string;
|
|
20
|
+
/** The path of the fragment for a main file (`a/_x.cipmain.vue` → `a/_x.cip.vue`). */
|
|
21
|
+
export declare const cipFragmentPath: ({ main }: {
|
|
22
|
+
main: string;
|
|
23
|
+
}) => string;
|
|
24
|
+
export interface CipFragment {
|
|
25
|
+
from: string;
|
|
26
|
+
path: string;
|
|
27
|
+
text: string;
|
|
28
|
+
points: string[];
|
|
29
|
+
unclosed: string[];
|
|
30
|
+
}
|
|
31
|
+
export interface CipComposition {
|
|
32
|
+
target: string;
|
|
33
|
+
main?: {
|
|
34
|
+
from: string;
|
|
35
|
+
path: string;
|
|
36
|
+
text: string;
|
|
37
|
+
};
|
|
38
|
+
fragments: CipFragment[];
|
|
39
|
+
points: {
|
|
40
|
+
name: string;
|
|
41
|
+
providers: string[];
|
|
42
|
+
}[];
|
|
43
|
+
unfilled: string[];
|
|
44
|
+
orphans: {
|
|
45
|
+
name: string;
|
|
46
|
+
from: string;
|
|
47
|
+
}[];
|
|
48
|
+
spliced?: string;
|
|
49
|
+
}
|
|
50
|
+
export interface CipReport {
|
|
51
|
+
start: string;
|
|
52
|
+
end: string;
|
|
53
|
+
compositions: CipComposition[];
|
|
54
|
+
}
|
|
55
|
+
/** The names of the markers of a text, in order, repeated as they are. */
|
|
56
|
+
export declare const cipMarkers: ({ text, start, end }: {
|
|
57
|
+
text: string;
|
|
58
|
+
start?: string;
|
|
59
|
+
end?: string;
|
|
60
|
+
}) => string[];
|
|
61
|
+
/**
|
|
62
|
+
* Who fills what in the code insertion points of some modules: for each file they make, its main file, its fragments in the order they
|
|
63
|
+
* are spliced, which markers nobody fills, which blocks no marker asks for, and the text that comes out.
|
|
64
|
+
*/
|
|
65
|
+
export declare const describeCips: ({ modules }: {
|
|
66
|
+
modules: readonly ResolvedModule[];
|
|
67
|
+
}) => Promise<CipReport>;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Code insertion points (CIP). A module can leave `/*→ name ←*\/` markers in a `*.cipmain.*` file; other modules provide `*.cip.*`
|
|
3
|
+
* files of the same path in which the code for a marker sits between two markers of that name. Splicing happens before the templates
|
|
4
|
+
* are evaluated and does not depend on the features, so it is done when the platform is composed.
|
|
5
|
+
*
|
|
6
|
+
* The splicing itself is spl-js-engine's (`spliceCip`, the one its derivation uses for components), so a platform composed here is
|
|
7
|
+
* the one the engine builds. What is here is what the engine does not know: which of linea's paths are main files and fragments.
|
|
8
|
+
*/
|
|
9
|
+
import { spliceCip } from 'spl-js-engine';
|
|
10
|
+
export const CIP_DEFAULT_START = '/*→';
|
|
11
|
+
export const CIP_DEFAULT_END = '←*/';
|
|
12
|
+
const CIPMAIN_MARK = '.cipmain';
|
|
13
|
+
const CIP_MARK = '.cip';
|
|
14
|
+
/** Whether a path is the main file of a code insertion point (`x.cipmain.vue`), or a fragment for one (`x.cip.vue`). */
|
|
15
|
+
export const cipKind = ({ file }) => {
|
|
16
|
+
const name = file.slice(file.lastIndexOf('/') + 1);
|
|
17
|
+
if (name.includes(CIPMAIN_MARK + '.'))
|
|
18
|
+
return 'main';
|
|
19
|
+
if (name.includes(CIP_MARK + '.'))
|
|
20
|
+
return 'fragment';
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
/** `a/_x.cipmain.vue` and `a/_x.cip.vue` both give the path of the file they make: `a/_x.vue`. */
|
|
24
|
+
export const cipTarget = ({ file }) => file.replace(CIPMAIN_MARK + '.', '.').replace(CIP_MARK + '.', '.');
|
|
25
|
+
/** The path of the fragment for a main file (`a/_x.cipmain.vue` → `a/_x.cip.vue`). */
|
|
26
|
+
export const cipFragmentPath = ({ main }) => main.replace(CIPMAIN_MARK + '.', CIP_MARK + '.');
|
|
27
|
+
const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
28
|
+
/** The names of the markers of a text, in order, repeated as they are. */
|
|
29
|
+
export const cipMarkers = ({ text, start = CIP_DEFAULT_START, end = CIP_DEFAULT_END }) => ([...text.matchAll(new RegExp(`${escapeRegExp(start)}([\\s\\S]*?)${escapeRegExp(end)}`, 'g'))].map((match) => (match[1] ?? '').trim()));
|
|
30
|
+
const blocksOf = (markers) => {
|
|
31
|
+
const counts = new Map();
|
|
32
|
+
for (const name of markers)
|
|
33
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
34
|
+
return {
|
|
35
|
+
points: [...counts].filter(([, count]) => count >= 2).map(([name]) => name),
|
|
36
|
+
unclosed: [...counts].filter(([, count]) => count % 2 === 1).map(([name]) => name),
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
const CONFIG_DIR = '.linea/config';
|
|
40
|
+
const CODE_DIR = 'code';
|
|
41
|
+
/**
|
|
42
|
+
* Who fills what in the code insertion points of some modules: for each file they make, its main file, its fragments in the order they
|
|
43
|
+
* are spliced, which markers nobody fills, which blocks no marker asks for, and the text that comes out.
|
|
44
|
+
*/
|
|
45
|
+
export const describeCips = async ({ modules }) => {
|
|
46
|
+
const decoder = new TextDecoder();
|
|
47
|
+
let start = CIP_DEFAULT_START;
|
|
48
|
+
let end = CIP_DEFAULT_END;
|
|
49
|
+
const mains = new Map();
|
|
50
|
+
const fragments = new Map();
|
|
51
|
+
for (const module of modules) {
|
|
52
|
+
const config = await module.files.read({ path: `${CONFIG_DIR}/config.json` });
|
|
53
|
+
if (config !== undefined) {
|
|
54
|
+
try {
|
|
55
|
+
const { delimiters } = JSON.parse(decoder.decode(config));
|
|
56
|
+
const own = delimiters?.find((delimiter) => delimiter.extension?.includes('cip'));
|
|
57
|
+
if (own?.start !== undefined && own.end !== undefined) {
|
|
58
|
+
start = own.start;
|
|
59
|
+
end = own.end;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
catch {
|
|
63
|
+
// a configuration that cannot be read is reported by the check of the platform
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const listed = [...await module.files.list({ dir: CODE_DIR }), ...await module.files.list({ dir: CONFIG_DIR })];
|
|
67
|
+
for (const path of listed) {
|
|
68
|
+
const kind = cipKind({ file: path });
|
|
69
|
+
if (kind === undefined)
|
|
70
|
+
continue;
|
|
71
|
+
const content = await module.files.read({ path });
|
|
72
|
+
if (content === undefined)
|
|
73
|
+
continue;
|
|
74
|
+
const entry = { from: module.location, path, text: decoder.decode(content) };
|
|
75
|
+
const target = cipTarget({ file: path });
|
|
76
|
+
if (kind === 'main')
|
|
77
|
+
mains.set(target, entry);
|
|
78
|
+
else
|
|
79
|
+
fragments.set(target, [...(fragments.get(target) ?? []), entry]);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
const compositions = [...new Set([...mains.keys(), ...fragments.keys()])].sort().map((target) => {
|
|
83
|
+
const main = mains.get(target);
|
|
84
|
+
const parts = (fragments.get(target) ?? []).map((fragment) => ({ ...fragment, ...blocksOf(cipMarkers({ text: fragment.text, start, end })) }));
|
|
85
|
+
const names = main === undefined ? [] : [...new Set(cipMarkers({ text: main.text, start, end }))];
|
|
86
|
+
const points = names.map((name) => ({ name, providers: parts.filter((part) => part.points.includes(name)).map((part) => part.from) }));
|
|
87
|
+
return {
|
|
88
|
+
target,
|
|
89
|
+
...(main === undefined ? {} : { main, spliced: spliceCip({ main: main.text, fragments: parts.map((part) => part.text), start, end }) }),
|
|
90
|
+
fragments: parts,
|
|
91
|
+
points,
|
|
92
|
+
unfilled: points.filter((point) => point.providers.length === 0).map((point) => point.name),
|
|
93
|
+
orphans: main === undefined ? [] : parts.flatMap((part) => part.points.filter((name) => !names.includes(name)).map((name) => ({ name, from: part.from }))),
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
return { start, end, compositions };
|
|
97
|
+
};
|
|
98
|
+
//# sourceMappingURL=cip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cip.js","sourceRoot":"","sources":["../../../src/modules/spl/cip.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAGzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,CAAA;AACtC,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAA;AAEpC,MAAM,YAAY,GAAG,UAAU,CAAA;AAC/B,MAAM,QAAQ,GAAG,MAAM,CAAA;AAEvB,wHAAwH;AACxH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAE,IAAI,EAAoB,EAAmC,EAAE;IACrF,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;IAClD,IAAI,IAAI,CAAC,QAAQ,CAAC,YAAY,GAAG,GAAG,CAAC;QAAE,OAAO,MAAM,CAAA;IACpD,IAAI,IAAI,CAAC,QAAQ,CAAC,QAAQ,GAAG,GAAG,CAAC;QAAE,OAAO,UAAU,CAAA;IACpD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AAED,kGAAkG;AAClG,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAE,IAAI,EAAoB,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,QAAQ,GAAG,GAAG,EAAE,GAAG,CAAC,CAAA;AAEnI,sFAAsF;AACtF,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAAE,IAAI,EAAoB,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,GAAG,EAAE,QAAQ,GAAG,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M,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC;YAC3F,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SAC3J,CAAA;IACH,CAAC,CAAC,CAAA;IACF,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,CAAA;AACrC,CAAC,CAAA","sourcesContent":["/**\n * Code insertion points (CIP). A module can leave `/*→ name ←*\\/` markers in a `*.cipmain.*` file; other modules provide `*.cip.*`\n * files of the same path in which the code for a marker sits between two markers of that name. Splicing happens before the templates\n * are evaluated and does not depend on the features, so it is done when the platform is composed.\n *\n * The splicing itself is spl-js-engine's (`spliceCip`, the one its derivation uses for components), so a platform composed here is\n * the one the engine builds. What is here is what the engine does not know: which of linea's paths are main files and fragments.\n */\n\nimport { spliceCip } from 'spl-js-engine'\nimport type { ResolvedModule } from '../types.js'\n\nexport const CIP_DEFAULT_START = '/*→'\nexport const CIP_DEFAULT_END = '←*/'\n\nconst CIPMAIN_MARK = '.cipmain'\nconst CIP_MARK = '.cip'\n\n/** Whether a path is the main file of a code insertion point (`x.cipmain.vue`), or a fragment for one (`x.cip.vue`). */\nexport const cipKind = ({ file }: { file: string }): 'main' | 'fragment' | undefined => {\n const name = file.slice(file.lastIndexOf('/') + 1)\n if (name.includes(CIPMAIN_MARK + '.')) return 'main'\n if (name.includes(CIP_MARK + '.')) return 'fragment'\n return undefined\n}\n\n/** `a/_x.cipmain.vue` and `a/_x.cip.vue` both give the path of the file they make: `a/_x.vue`. */\nexport const cipTarget = ({ file }: { file: string }): string => file.replace(CIPMAIN_MARK + '.', '.').replace(CIP_MARK + '.', '.')\n\n/** The path of the fragment for a main file (`a/_x.cipmain.vue` → `a/_x.cip.vue`). */\nexport const cipFragmentPath = ({ main }: { main: string }): string => main.replace(CIPMAIN_MARK + '.', CIP_MARK + '.')\n\nexport interface CipFragment {\n from: string\n path: string\n text: string\n points: string[]\n unclosed: string[]\n}\n\nexport interface CipComposition {\n target: string\n main?: { from: string, path: string, text: string }\n fragments: CipFragment[]\n points: { name: string, providers: string[] }[]\n unfilled: string[]\n orphans: { name: string, from: string }[]\n spliced?: string\n}\n\nexport interface CipReport {\n start: string\n end: string\n compositions: CipComposition[]\n}\n\nconst escapeRegExp = (text: string): string => text.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\n/** The names of the markers of a text, in order, repeated as they are. */\nexport const cipMarkers = ({ text, start = CIP_DEFAULT_START, end = CIP_DEFAULT_END }: { text: string, start?: string, end?: string }): string[] => (\n [...text.matchAll(new RegExp(`${escapeRegExp(start)}([\\\\s\\\\S]*?)${escapeRegExp(end)}`, 'g'))].map((match) => (match[1] ?? '').trim())\n)\n\nconst blocksOf = (markers: string[]): { points: string[], unclosed: string[] } => {\n const counts = new Map<string, number>()\n for (const name of markers) counts.set(name, (counts.get(name) ?? 0) + 1)\n return {\n points: [...counts].filter(([, count]) => count >= 2).map(([name]) => name),\n unclosed: [...counts].filter(([, count]) => count % 2 === 1).map(([name]) => name),\n }\n}\n\nconst CONFIG_DIR = '.linea/config'\nconst CODE_DIR = 'code'\n\n/**\n * Who fills what in the code insertion points of some modules: for each file they make, its main file, its fragments in the order they\n * are spliced, which markers nobody fills, which blocks no marker asks for, and the text that comes out.\n */\nexport const describeCips = async ({ modules }: { modules: readonly ResolvedModule[] }): Promise<CipReport> => {\n const decoder = new TextDecoder()\n let start = CIP_DEFAULT_START\n let end = CIP_DEFAULT_END\n const mains = new Map<string, { from: string, path: string, text: string }>()\n const fragments = new Map<string, { from: string, path: string, text: string }[]>()\n\n for (const module of modules) {\n const config = await module.files.read({ path: `${CONFIG_DIR}/config.json` })\n if (config !== undefined) {\n try {\n const { delimiters } = JSON.parse(decoder.decode(config)) as { delimiters?: { extension?: string[], start?: string, end?: string }[] }\n const own = delimiters?.find((delimiter) => delimiter.extension?.includes('cip'))\n if (own?.start !== undefined && own.end !== undefined) {\n start = own.start\n end = own.end\n }\n } catch {\n // a configuration that cannot be read is reported by the check of the platform\n }\n }\n const listed = [...await module.files.list({ dir: CODE_DIR }), ...await module.files.list({ dir: CONFIG_DIR })]\n for (const path of listed) {\n const kind = cipKind({ file: path })\n if (kind === undefined) continue\n const content = await module.files.read({ path })\n if (content === undefined) continue\n const entry = { from: module.location, path, text: decoder.decode(content) }\n const target = cipTarget({ file: path })\n if (kind === 'main') mains.set(target, entry)\n else fragments.set(target, [...(fragments.get(target) ?? []), entry])\n }\n }\n\n const compositions = [...new Set([...mains.keys(), ...fragments.keys()])].sort().map((target): CipComposition => {\n const main = mains.get(target)\n const parts = (fragments.get(target) ?? []).map((fragment) => ({ ...fragment, ...blocksOf(cipMarkers({ text: fragment.text, start, end })) }))\n const names = main === undefined ? [] : [...new Set(cipMarkers({ text: main.text, start, end }))]\n const points = names.map((name) => ({ name, providers: parts.filter((part) => part.points.includes(name)).map((part) => part.from) }))\n return {\n target,\n ...(main === undefined ? {} : { main, spliced: spliceCip({ main: main.text, fragments: parts.map((part) => part.text), start, end }) }),\n fragments: parts,\n points,\n unfilled: points.filter((point) => point.providers.length === 0).map((point) => point.name),\n orphans: main === undefined ? [] : parts.flatMap((part) => part.points.filter((name) => !names.includes(name)).map((name) => ({ name, from: part.from }))),\n }\n })\n return { start, end, compositions }\n}\n"]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Just enough UVL to put the feature models of modules under the root of an SPL: indentation is structure, so it is handled as lines
|
|
3
|
+
* with a level, never as a grammar. What comes out is parsed by the real parser (`parseUvl`) by whoever uses it.
|
|
4
|
+
*/
|
|
5
|
+
export interface UvlLine {
|
|
6
|
+
readonly level: number;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
}
|
|
9
|
+
export interface UvlSections {
|
|
10
|
+
/** Everything before `features` (`namespace`, `include`...), verbatim. */
|
|
11
|
+
readonly preamble: readonly string[];
|
|
12
|
+
readonly features: readonly UvlLine[];
|
|
13
|
+
readonly constraints: readonly UvlLine[];
|
|
14
|
+
}
|
|
15
|
+
export declare const parseUvlSections: ({ content }: {
|
|
16
|
+
content: string;
|
|
17
|
+
}) => UvlSections;
|
|
18
|
+
/** The feature a line of the `features` section declares, or `undefined` for group keywords, cardinalities and attributes. */
|
|
19
|
+
export declare const featureNameOfLine: ({ text }: {
|
|
20
|
+
text: string;
|
|
21
|
+
}) => string | undefined;
|
|
22
|
+
export declare const featureNamesOfSections: ({ features }: {
|
|
23
|
+
features: readonly UvlLine[];
|
|
24
|
+
}) => string[];
|
|
25
|
+
/**
|
|
26
|
+
* The features a constraint line names. Lines that compare attributes or aggregate them (`price > 3`, `sum(Cost)`) are not logic
|
|
27
|
+
* about features alone, so they are left out: this only looks at `=>`, `<=>`, `&`, `|`, `!` and parentheses.
|
|
28
|
+
*/
|
|
29
|
+
export declare const featuresOfConstraint: ({ text }: {
|
|
30
|
+
text: string;
|
|
31
|
+
}) => string[];
|
|
32
|
+
/**
|
|
33
|
+
* Puts each module's feature tree under the root feature of the SPL, in a `mandatory` group of the root (the group is added when the root
|
|
34
|
+
* has none), and appends the constraints of the modules to those of the SPL.
|
|
35
|
+
*/
|
|
36
|
+
export declare const graftModules: ({ spl, modules }: {
|
|
37
|
+
spl: UvlSections;
|
|
38
|
+
modules: readonly UvlSections[];
|
|
39
|
+
}) => string;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Just enough UVL to put the feature models of modules under the root of an SPL: indentation is structure, so it is handled as lines
|
|
3
|
+
* with a level, never as a grammar. What comes out is parsed by the real parser (`parseUvl`) by whoever uses it.
|
|
4
|
+
*/
|
|
5
|
+
const GROUPS = new Set(['mandatory', 'optional', 'or', 'alternative']);
|
|
6
|
+
const leading = (line) => /^[ \t]*/.exec(line)?.[0] ?? '';
|
|
7
|
+
export const parseUvlSections = ({ content }) => {
|
|
8
|
+
const raw = content.replace(/\r\n/g, '\n').split('\n').filter((line) => line.trim() !== '');
|
|
9
|
+
const usesTabs = raw.some((line) => leading(line).includes('\t'));
|
|
10
|
+
// spaces: the unit of indentation is the smallest one used
|
|
11
|
+
const unit = usesTabs ? 1 : Math.min(...raw.map((line) => leading(line).length).filter((width) => width > 0), Infinity);
|
|
12
|
+
const levelOf = (line) => {
|
|
13
|
+
const space = leading(line);
|
|
14
|
+
return usesTabs ? space.length : Number.isFinite(unit) ? Math.round(space.length / unit) : 0;
|
|
15
|
+
};
|
|
16
|
+
const preamble = [];
|
|
17
|
+
const features = [];
|
|
18
|
+
const constraints = [];
|
|
19
|
+
let section = 'preamble';
|
|
20
|
+
for (const line of raw) {
|
|
21
|
+
const level = levelOf(line);
|
|
22
|
+
const text = line.trim();
|
|
23
|
+
if (level === 0) {
|
|
24
|
+
section = text === 'features' ? 'features' : text === 'constraints' ? 'constraints' : section === 'preamble' ? 'preamble' : 'other';
|
|
25
|
+
if (section === 'preamble')
|
|
26
|
+
preamble.push(text);
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (section === 'features')
|
|
30
|
+
features.push({ level, text });
|
|
31
|
+
else if (section === 'constraints')
|
|
32
|
+
constraints.push({ level, text });
|
|
33
|
+
}
|
|
34
|
+
return { preamble, features, constraints };
|
|
35
|
+
};
|
|
36
|
+
/** The feature a line of the `features` section declares, or `undefined` for group keywords, cardinalities and attributes. */
|
|
37
|
+
export const featureNameOfLine = ({ text }) => {
|
|
38
|
+
if (GROUPS.has(text) || text.startsWith('[') || text.startsWith('{'))
|
|
39
|
+
return undefined;
|
|
40
|
+
const quoted = /^"([^"]+)"/.exec(text);
|
|
41
|
+
if (quoted !== null)
|
|
42
|
+
return quoted[1];
|
|
43
|
+
return /^[A-Za-z_][A-Za-z0-9_]*/.exec(text)?.[0];
|
|
44
|
+
};
|
|
45
|
+
export const featureNamesOfSections = ({ features }) => {
|
|
46
|
+
const names = [];
|
|
47
|
+
for (const line of features) {
|
|
48
|
+
const name = featureNameOfLine({ text: line.text });
|
|
49
|
+
if (name !== undefined)
|
|
50
|
+
names.push(name);
|
|
51
|
+
}
|
|
52
|
+
return names;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* The features a constraint line names. Lines that compare attributes or aggregate them (`price > 3`, `sum(Cost)`) are not logic
|
|
56
|
+
* about features alone, so they are left out: this only looks at `=>`, `<=>`, `&`, `|`, `!` and parentheses.
|
|
57
|
+
*/
|
|
58
|
+
export const featuresOfConstraint = ({ text }) => {
|
|
59
|
+
const withoutImplications = text.replace(/<=>|=>/g, ' ');
|
|
60
|
+
if (/[<>=]|[A-Za-z_][A-Za-z0-9_]*\s*\(/.test(withoutImplications))
|
|
61
|
+
return [];
|
|
62
|
+
const names = [];
|
|
63
|
+
const rest = text.replace(/"([^"]+)"/g, (_match, quoted) => { names.push(quoted); return ' '; });
|
|
64
|
+
for (const word of rest.match(/[A-Za-z_][A-Za-z0-9_]*/g) ?? [])
|
|
65
|
+
names.push(word);
|
|
66
|
+
return names;
|
|
67
|
+
};
|
|
68
|
+
const render = (lines) => lines.map(({ level, text }) => '\t'.repeat(level) + text);
|
|
69
|
+
/**
|
|
70
|
+
* Puts each module's feature tree under the root feature of the SPL, in a `mandatory` group of the root (the group is added when the root
|
|
71
|
+
* has none), and appends the constraints of the modules to those of the SPL.
|
|
72
|
+
*/
|
|
73
|
+
export const graftModules = ({ spl, modules }) => {
|
|
74
|
+
const features = [...spl.features];
|
|
75
|
+
const root = features.findIndex((line) => line.level === 1);
|
|
76
|
+
if (root < 0)
|
|
77
|
+
throw new Error('The feature model of the SPL has no root feature.');
|
|
78
|
+
// the lines of the subtree of the root end where the next level-1 line starts
|
|
79
|
+
let end = features.findIndex((line, index) => index > root && line.level === 1);
|
|
80
|
+
if (end < 0)
|
|
81
|
+
end = features.length;
|
|
82
|
+
const trees = [];
|
|
83
|
+
for (const module of modules) {
|
|
84
|
+
const top = Math.min(...module.features.map((line) => line.level));
|
|
85
|
+
for (const line of module.features)
|
|
86
|
+
trees.push({ level: line.level - top + 3, text: line.text });
|
|
87
|
+
}
|
|
88
|
+
if (trees.length > 0) {
|
|
89
|
+
const group = features.findIndex((line, index) => index > root && index < end && line.level === 2 && line.text === 'mandatory');
|
|
90
|
+
if (group >= 0) {
|
|
91
|
+
let after = group + 1;
|
|
92
|
+
while (after < end && (features[after]).level >= 3)
|
|
93
|
+
after++;
|
|
94
|
+
features.splice(after, 0, ...trees);
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
features.splice(root + 1, 0, { level: 2, text: 'mandatory' }, ...trees);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const constraints = [...spl.constraints, ...modules.flatMap((module) => module.constraints)];
|
|
101
|
+
const out = [...spl.preamble, 'features', ...render(features)];
|
|
102
|
+
if (constraints.length > 0)
|
|
103
|
+
out.push('constraints', ...render(constraints));
|
|
104
|
+
return out.join('\n') + '\n';
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=feature-model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"feature-model.js","sourceRoot":"","sources":["../../../src/modules/spl/feature-model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,MAAM,MAAM,GAAwB,IAAI,GAAG,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC,CAAA;AAE3F,MAAM,OAAO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CAAA;AAC9B,CAAC,CAAA","sourcesContent":["/**\n * Just enough UVL to put the feature models of modules under the root of an SPL: indentation is structure, so it is handled as lines\n * with a level, never as a grammar. What comes out is parsed by the real parser (`parseUvl`) by whoever uses it.\n */\n\nexport interface UvlLine {\n readonly level: number\n readonly text: string\n}\n\nexport interface UvlSections {\n /** Everything before `features` (`namespace`, `include`...), verbatim. */\n readonly preamble: readonly string[]\n readonly features: readonly UvlLine[]\n readonly constraints: readonly UvlLine[]\n}\n\nconst GROUPS: ReadonlySet<string> = new Set(['mandatory', 'optional', 'or', 'alternative'])\n\nconst leading = (line: string): string => /^[ \\t]*/.exec(line)?.[0] ?? ''\n\nexport const parseUvlSections = ({ content }: { content: string }): UvlSections => {\n const raw = content.replace(/\\r\\n/g, '\\n').split('\\n').filter((line) => line.trim() !== '')\n const usesTabs = raw.some((line) => leading(line).includes('\\t'))\n // spaces: the unit of indentation is the smallest one used\n const unit = usesTabs ? 1 : Math.min(...raw.map((line) => leading(line).length).filter((width) => width > 0), Infinity)\n const levelOf = (line: string): number => {\n const space = leading(line)\n return usesTabs ? space.length : Number.isFinite(unit) ? Math.round(space.length / unit) : 0\n }\n const preamble: string[] = []\n const features: UvlLine[] = []\n const constraints: UvlLine[] = []\n let section: 'preamble' | 'features' | 'constraints' | 'other' = 'preamble'\n for (const line of raw) {\n const level = levelOf(line)\n const text = line.trim()\n if (level === 0) {\n section = text === 'features' ? 'features' : text === 'constraints' ? 'constraints' : section === 'preamble' ? 'preamble' : 'other'\n if (section === 'preamble') preamble.push(text)\n continue\n }\n if (section === 'features') features.push({ level, text })\n else if (section === 'constraints') constraints.push({ level, text })\n }\n return { preamble, features, constraints }\n}\n\n/** The feature a line of the `features` section declares, or `undefined` for group keywords, cardinalities and attributes. */\nexport const featureNameOfLine = ({ text }: { text: string }): string | undefined => {\n if (GROUPS.has(text) || text.startsWith('[') || text.startsWith('{')) return undefined\n const quoted = /^\"([^\"]+)\"/.exec(text)\n if (quoted !== null) return quoted[1]\n return /^[A-Za-z_][A-Za-z0-9_]*/.exec(text)?.[0]\n}\n\nexport const featureNamesOfSections = ({ features }: { features: readonly UvlLine[] }): string[] => {\n const names: string[] = []\n for (const line of features) {\n const name = featureNameOfLine({ text: line.text })\n if (name !== undefined) names.push(name)\n }\n return names\n}\n\n/**\n * The features a constraint line names. Lines that compare attributes or aggregate them (`price > 3`, `sum(Cost)`) are not logic\n * about features alone, so they are left out: this only looks at `=>`, `<=>`, `&`, `|`, `!` and parentheses.\n */\nexport const featuresOfConstraint = ({ text }: { text: string }): string[] => {\n const withoutImplications = text.replace(/<=>|=>/g, ' ')\n if (/[<>=]|[A-Za-z_][A-Za-z0-9_]*\\s*\\(/.test(withoutImplications)) return []\n const names: string[] = []\n const rest = text.replace(/\"([^\"]+)\"/g, (_match, quoted: string) => { names.push(quoted); return ' ' })\n for (const word of rest.match(/[A-Za-z_][A-Za-z0-9_]*/g) ?? []) names.push(word)\n return names\n}\n\nconst render = (lines: readonly UvlLine[]): string[] => lines.map(({ level, text }) => '\\t'.repeat(level) + text)\n\n/**\n * Puts each module's feature tree under the root feature of the SPL, in a `mandatory` group of the root (the group is added when the root\n * has none), and appends the constraints of the modules to those of the SPL.\n */\nexport const graftModules = ({\n spl,\n modules\n}: {\n spl: UvlSections\n modules: readonly UvlSections[]\n}): string => {\n const features = [...spl.features]\n const root = features.findIndex((line) => line.level === 1)\n if (root < 0) throw new Error('The feature model of the SPL has no root feature.')\n\n // the lines of the subtree of the root end where the next level-1 line starts\n let end = features.findIndex((line, index) => index > root && line.level === 1)\n if (end < 0) end = features.length\n\n const trees: UvlLine[] = []\n for (const module of modules) {\n const top = Math.min(...module.features.map((line) => line.level))\n for (const line of module.features) trees.push({ level: line.level - top + 3, text: line.text })\n }\n\n if (trees.length > 0) {\n const group = features.findIndex((line, index) => index > root && index < end && line.level === 2 && line.text === 'mandatory')\n if (group >= 0) {\n let after = group + 1\n while (after < end && (features[after]!).level >= 3) after++\n features.splice(after, 0, ...trees)\n } else {\n features.splice(root + 1, 0, { level: 2, text: 'mandatory' }, ...trees)\n }\n }\n\n const constraints = [...spl.constraints, ...modules.flatMap((module) => module.constraints)]\n const out = [...spl.preamble, 'features', ...render(features)]\n if (constraints.length > 0) out.push('constraints', ...render(constraints))\n return out.join('\\n') + '\\n'\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { planPlatform, writePlatform } from './platform.js';
|
|
2
|
+
export type { PlatformPlan } from './platform.js';
|
|
3
|
+
export { cipFragmentPath, cipKind, cipMarkers, cipTarget, describeCips } from './cip.js';
|
|
4
|
+
export type { CipComposition, CipFragment, CipReport } from './cip.js';
|
|
5
|
+
export { checkSpl } from './check.js';
|
|
6
|
+
export type { SplCheckReport } from './check.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/modules/spl/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAE3D,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAExF,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA","sourcesContent":["export { planPlatform, writePlatform } from './platform.js'\nexport type { PlatformPlan } from './platform.js'\nexport { cipFragmentPath, cipKind, cipMarkers, cipTarget, describeCips } from './cip.js'\nexport type { CipComposition, CipFragment, CipReport } from './cip.js'\nexport { checkSpl } from './check.js'\nexport type { SplCheckReport } from './check.js'\n"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Diagnostic, PackageFiles, ResolvedSpl } from '../types.js';
|
|
2
|
+
interface Delimiter {
|
|
3
|
+
extension: string[];
|
|
4
|
+
start: string;
|
|
5
|
+
end: string;
|
|
6
|
+
}
|
|
7
|
+
interface PlatformConfig {
|
|
8
|
+
ignore: string[];
|
|
9
|
+
delimiters: Delimiter[];
|
|
10
|
+
}
|
|
11
|
+
/** Everything a derivation needs, composed from the modules of an SPL, before it is written anywhere. */
|
|
12
|
+
export interface PlatformPlan {
|
|
13
|
+
/** Merged UVL feature model. */
|
|
14
|
+
readonly featureModel: string;
|
|
15
|
+
readonly config: PlatformConfig;
|
|
16
|
+
readonly extraJs: string;
|
|
17
|
+
readonly transformation: string;
|
|
18
|
+
/** Code files, as paths relative to the line directory (`src/platform/code/...`). */
|
|
19
|
+
readonly files: ReadonlyMap<string, {
|
|
20
|
+
readonly content: Uint8Array;
|
|
21
|
+
readonly from: string;
|
|
22
|
+
}>;
|
|
23
|
+
readonly diagnostics: readonly Diagnostic[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Composes the platform of an SPL: the feature models of its modules grafted under its root, their code laid over each other, their
|
|
27
|
+
* helper functions and transformations chained after the core ones. What the SPL has of its own (`src/platform/...`) comes last, so it wins.
|
|
28
|
+
* Problems (a file two modules both provide, a feature name used twice...) are returned, not thrown.
|
|
29
|
+
*/
|
|
30
|
+
export declare const planPlatform: ({ resolved, spl, ownFeatureModel, loadCode }: {
|
|
31
|
+
resolved: ResolvedSpl;
|
|
32
|
+
spl?: PackageFiles;
|
|
33
|
+
/** The SPL's own feature model, as UVL (its model of the feature metamodel): the modules' are grafted under its root. Without it, the root alone. */
|
|
34
|
+
ownFeatureModel?: string;
|
|
35
|
+
/**
|
|
36
|
+
* `false` for a check, where the code is not written anywhere: the code of a package is only listed, and a file is read when its bytes
|
|
37
|
+
* decide something (a file that two packages both provide, and the files of a code insertion point). The diagnostics are the same;
|
|
38
|
+
* `files` then holds those files with no content (`from` says who provides each). A derivation needs `true`, the default.
|
|
39
|
+
*/
|
|
40
|
+
loadCode?: boolean;
|
|
41
|
+
}) => Promise<PlatformPlan>;
|
|
42
|
+
/** Writes a platform plan under `lineDir` as an ordinary line (`src/platform/...`), so the usual derivation runs on it. */
|
|
43
|
+
export declare const writePlatform: ({ plan, lineDir }: {
|
|
44
|
+
plan: PlatformPlan;
|
|
45
|
+
lineDir: string;
|
|
46
|
+
}) => {
|
|
47
|
+
lineDir: string;
|
|
48
|
+
};
|
|
49
|
+
export {};
|